2012-05-18 02:45:23 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2014-09-23 08:04:57 -05:00
|
|
|
// Copyright (C) 2011- Statoil ASA
|
|
|
|
// Copyright (C) 2013- Ceetron Solutions AS
|
|
|
|
// Copyright (C) 2011-2012 Ceetron AS
|
2012-05-18 02:45:23 -05:00
|
|
|
//
|
|
|
|
// ResInsight is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2015-06-25 06:32:00 -05:00
|
|
|
#include "RimEclipseCellColors.h"
|
2012-05-18 02:45:23 -05:00
|
|
|
|
2015-09-23 06:48:25 -05:00
|
|
|
#include "RimEclipseFaultColors.h"
|
2015-05-21 03:34:38 -05:00
|
|
|
#include "RimEclipseView.h"
|
2016-08-01 15:27:03 -05:00
|
|
|
#include "RimLegendConfig.h"
|
2014-05-06 15:39:53 -05:00
|
|
|
#include "RimTernaryLegendConfig.h"
|
2015-10-13 03:24:11 -05:00
|
|
|
#include "RimViewController.h"
|
2015-09-23 06:48:25 -05:00
|
|
|
#include "RimViewLinker.h"
|
|
|
|
|
2014-05-06 15:51:17 -05:00
|
|
|
#include "RiuMainWindow.h"
|
2016-06-16 08:59:20 -05:00
|
|
|
#include "cafPdmUiTreeOrdering.h"
|
2013-05-06 03:55:00 -05:00
|
|
|
|
2015-06-25 05:04:46 -05:00
|
|
|
CAF_PDM_SOURCE_INIT(RimEclipseCellColors, "ResultSlot");
|
2012-05-18 02:45:23 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-06-25 05:04:46 -05:00
|
|
|
RimEclipseCellColors::RimEclipseCellColors()
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2015-08-09 07:12:09 -05:00
|
|
|
CAF_PDM_InitObject("Cell Result", ":/CellResult.png", "", "");
|
2012-05-18 02:45:23 -05:00
|
|
|
|
2015-08-06 01:08:00 -05:00
|
|
|
CAF_PDM_InitFieldNoDefault(&obsoleteField_legendConfig, "LegendDefinition", "Legend Definition", "", "", "");
|
|
|
|
this->obsoleteField_legendConfig.uiCapability()->setUiHidden(true);
|
|
|
|
this->obsoleteField_legendConfig.uiCapability()->setUiChildrenHidden(true);
|
|
|
|
this->obsoleteField_legendConfig.xmlCapability()->setIOWritable(false);
|
2014-06-13 01:12:45 -05:00
|
|
|
|
2012-05-18 02:45:23 -05:00
|
|
|
CAF_PDM_InitFieldNoDefault(&m_legendConfigData, "ResultVarLegendDefinitionList", "", "", "", "");
|
2015-08-05 06:27:36 -05:00
|
|
|
m_legendConfigData.uiCapability()->setUiHidden(true);
|
|
|
|
m_legendConfigData.uiCapability()->setUiChildrenHidden(true);
|
2012-05-18 02:45:23 -05:00
|
|
|
|
2014-05-06 15:39:53 -05:00
|
|
|
CAF_PDM_InitFieldNoDefault(&ternaryLegendConfig, "TernaryLegendDefinition", "Ternary Legend Definition", "", "", "");
|
2014-06-13 01:12:45 -05:00
|
|
|
this->ternaryLegendConfig = new RimTernaryLegendConfig();
|
2015-08-05 06:27:36 -05:00
|
|
|
this->ternaryLegendConfig.uiCapability()->setUiHidden(true);
|
|
|
|
this->ternaryLegendConfig.uiCapability()->setUiChildrenHidden(true);
|
2015-08-06 01:08:00 -05:00
|
|
|
|
|
|
|
CAF_PDM_InitFieldNoDefault(&m_legendConfigPtrField, "LegendDefinitionPtrField", "Legend Definition PtrField", "", "", "");
|
|
|
|
this->m_legendConfigPtrField.uiCapability()->setUiHidden(true);
|
|
|
|
this->m_legendConfigPtrField.uiCapability()->setUiChildrenHidden(true);
|
2015-09-01 06:53:04 -05:00
|
|
|
|
|
|
|
// Make sure we have a created legend for the default/undefined result variable
|
|
|
|
changeLegendConfig(this->resultVariable());
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-06-25 05:04:46 -05:00
|
|
|
RimEclipseCellColors::~RimEclipseCellColors()
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2015-08-07 04:09:05 -05:00
|
|
|
CVF_ASSERT(obsoleteField_legendConfig() == NULL);
|
|
|
|
|
|
|
|
m_legendConfigData.deleteAllChildObjects();
|
|
|
|
|
2014-05-06 15:39:53 -05:00
|
|
|
delete ternaryLegendConfig();
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-06-25 05:04:46 -05:00
|
|
|
void RimEclipseCellColors::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2015-06-25 02:38:53 -05:00
|
|
|
RimEclipseResultDefinition::fieldChangedByUi(changedField, oldValue, newValue);
|
2013-08-02 06:04:25 -05:00
|
|
|
|
2015-08-10 07:14:22 -05:00
|
|
|
// Update of legend config must happen after RimEclipseResultDefinition::fieldChangedByUi(), as this function modifies this->resultVariable()
|
2013-08-02 06:04:25 -05:00
|
|
|
if (changedField == &m_resultVariableUiField)
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
|
|
|
if (oldValue != newValue)
|
|
|
|
{
|
2013-08-02 06:04:25 -05:00
|
|
|
changeLegendConfig(this->resultVariable());
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
|
2012-08-31 12:12:47 -05:00
|
|
|
if (newValue != RimDefines::undefinedResultName())
|
|
|
|
{
|
2015-06-09 09:18:11 -05:00
|
|
|
if (m_reservoirView) m_reservoirView->hasUserRequestedAnimation = true;
|
2012-08-31 12:12:47 -05:00
|
|
|
}
|
2014-06-13 01:12:45 -05:00
|
|
|
|
2015-08-10 07:14:22 -05:00
|
|
|
RimEclipseFaultColors* faultColors = dynamic_cast<RimEclipseFaultColors*>(this->parentField()->ownerObject());
|
|
|
|
if (faultColors)
|
|
|
|
{
|
2015-08-11 04:12:43 -05:00
|
|
|
faultColors->updateConnectedEditors();
|
2015-08-10 07:14:22 -05:00
|
|
|
}
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (m_reservoirView) m_reservoirView->createDisplayModelAndRedraw();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-06-25 05:04:46 -05:00
|
|
|
void RimEclipseCellColors::changeLegendConfig(QString resultVarNameOfNewLegend)
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2014-05-06 15:39:53 -05:00
|
|
|
if (resultVarNameOfNewLegend == RimDefines::ternarySaturationResultName())
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2015-08-05 06:27:36 -05:00
|
|
|
this->ternaryLegendConfig.uiCapability()->setUiChildrenHidden(false);
|
2015-08-06 01:08:00 -05:00
|
|
|
this->m_legendConfigPtrField.uiCapability()->setUiChildrenHidden(true);
|
2014-05-06 15:39:53 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-08-05 06:27:36 -05:00
|
|
|
this->ternaryLegendConfig.uiCapability()->setUiChildrenHidden(true);
|
2014-05-06 15:39:53 -05:00
|
|
|
|
2015-08-06 01:08:00 -05:00
|
|
|
bool found = false;
|
|
|
|
|
|
|
|
QString legendResultVariable;
|
|
|
|
|
|
|
|
if (this->m_legendConfigPtrField())
|
|
|
|
{
|
|
|
|
legendResultVariable = this->m_legendConfigPtrField()->resultVariableName();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this->m_legendConfigPtrField() || legendResultVariable != resultVarNameOfNewLegend)
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2015-07-31 11:58:23 -05:00
|
|
|
for (size_t i = 0; i < m_legendConfigData.size(); i++)
|
2014-05-06 15:39:53 -05:00
|
|
|
{
|
2015-07-31 11:58:23 -05:00
|
|
|
if (m_legendConfigData[i]->resultVariableName() == resultVarNameOfNewLegend)
|
2014-05-06 15:39:53 -05:00
|
|
|
{
|
2015-08-06 01:08:00 -05:00
|
|
|
this->m_legendConfigPtrField = m_legendConfigData[i];
|
2014-05-06 15:39:53 -05:00
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Not found ?
|
|
|
|
if (!found)
|
|
|
|
{
|
2015-08-06 01:08:00 -05:00
|
|
|
RimLegendConfig* newLegend = new RimLegendConfig;
|
|
|
|
newLegend->setReservoirView(m_reservoirView);
|
|
|
|
newLegend->resultVariableName = resultVarNameOfNewLegend;
|
|
|
|
m_legendConfigData.push_back(newLegend);
|
|
|
|
|
|
|
|
this->m_legendConfigPtrField = newLegend;
|
2014-05-06 15:39:53 -05:00
|
|
|
}
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
|
2015-08-06 01:08:00 -05:00
|
|
|
this->m_legendConfigPtrField.uiCapability()->setUiChildrenHidden(false);
|
|
|
|
}
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-06-25 05:04:46 -05:00
|
|
|
void RimEclipseCellColors::initAfterRead()
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2015-06-25 02:38:53 -05:00
|
|
|
RimEclipseResultDefinition::initAfterRead();
|
2012-05-18 02:45:23 -05:00
|
|
|
|
2015-08-06 01:08:00 -05:00
|
|
|
if (this->m_legendConfigPtrField() && this->m_legendConfigPtrField()->resultVariableName == "")
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2015-08-06 01:08:00 -05:00
|
|
|
this->m_legendConfigPtrField()->resultVariableName = this->resultVariable();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (obsoleteField_legendConfig)
|
|
|
|
{
|
|
|
|
// The current legend config is NOT stored in <ResultVarLegendDefinitionList> in ResInsight up to v 1.3.7-dev
|
2015-08-07 05:40:47 -05:00
|
|
|
RimLegendConfig* obsoleteLegend = obsoleteField_legendConfig();
|
|
|
|
|
|
|
|
// set to NULL before pushing into container
|
2015-08-07 04:09:05 -05:00
|
|
|
obsoleteField_legendConfig = NULL;
|
2015-08-07 05:40:47 -05:00
|
|
|
|
|
|
|
m_legendConfigData.push_back(obsoleteLegend);
|
|
|
|
m_legendConfigPtrField = obsoleteLegend;
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
2014-05-06 15:39:53 -05:00
|
|
|
|
|
|
|
changeLegendConfig(this->resultVariable());
|
2015-09-23 06:48:25 -05:00
|
|
|
|
|
|
|
updateIconState();
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2016-06-16 08:59:20 -05:00
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimEclipseCellColors::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/)
|
|
|
|
{
|
|
|
|
uiTreeOrdering.add(m_legendConfigPtrField());
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2012-05-18 02:45:23 -05:00
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-06-25 05:04:46 -05:00
|
|
|
void RimEclipseCellColors::setReservoirView(RimEclipseView* ownerReservoirView)
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2015-09-01 06:56:35 -05:00
|
|
|
this->setEclipseCase(ownerReservoirView->eclipseCase());
|
2014-08-01 05:55:43 -05:00
|
|
|
|
2012-05-18 02:45:23 -05:00
|
|
|
m_reservoirView = ownerReservoirView;
|
2015-07-31 11:58:23 -05:00
|
|
|
|
2015-08-06 01:08:00 -05:00
|
|
|
for (size_t i = 0; i < m_legendConfigData.size(); i++)
|
|
|
|
{
|
|
|
|
m_legendConfigData[i]->setReservoirView(ownerReservoirView);
|
|
|
|
}
|
2014-05-06 15:39:53 -05:00
|
|
|
|
2014-06-13 01:12:45 -05:00
|
|
|
this->ternaryLegendConfig()->setReservoirView(ownerReservoirView);
|
|
|
|
}
|
2015-09-01 06:56:35 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimEclipseView* RimEclipseCellColors::reservoirView()
|
|
|
|
{
|
|
|
|
return m_reservoirView;
|
|
|
|
}
|
|
|
|
|
2014-06-13 01:12:45 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-06-25 05:04:46 -05:00
|
|
|
void RimEclipseCellColors::setResultVariable(const QString& val)
|
2014-06-13 01:12:45 -05:00
|
|
|
{
|
2015-06-25 02:38:53 -05:00
|
|
|
RimEclipseResultDefinition::setResultVariable(val);
|
2014-06-13 01:12:45 -05:00
|
|
|
|
|
|
|
this->changeLegendConfig(val);
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
2014-05-06 15:39:53 -05:00
|
|
|
|
2015-08-06 01:08:00 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimLegendConfig* RimEclipseCellColors::legendConfig()
|
|
|
|
{
|
|
|
|
return m_legendConfigPtrField;
|
|
|
|
}
|
|
|
|
|
2015-09-23 06:48:25 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimEclipseCellColors::updateIconState()
|
|
|
|
{
|
2015-09-25 04:01:41 -05:00
|
|
|
RimViewController* viewController = m_reservoirView->viewController();
|
|
|
|
if (viewController && viewController->isResultColorControlled())
|
2015-09-23 06:48:25 -05:00
|
|
|
{
|
|
|
|
updateUiIconFromState(false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
updateUiIconFromState(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
uiCapability()->updateConnectedEditors();
|
|
|
|
}
|
|
|
|
|