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
|
|
|
|
2018-10-11 09:03:49 -05:00
|
|
|
#include "RiaColorTables.h"
|
2017-01-11 08:03:39 -06:00
|
|
|
#include "RigCaseCellResultsData.h"
|
|
|
|
#include "RigEclipseCaseData.h"
|
|
|
|
#include "RigFlowDiagResults.h"
|
|
|
|
#include "RigFormationNames.h"
|
|
|
|
|
2016-08-03 09:01:44 -05:00
|
|
|
#include "RimCellEdgeColors.h"
|
2017-01-11 08:03:39 -06:00
|
|
|
#include "RimEclipseCase.h"
|
2015-09-23 06:48:25 -05:00
|
|
|
#include "RimEclipseFaultColors.h"
|
2015-05-21 03:34:38 -05:00
|
|
|
#include "RimEclipseView.h"
|
2018-04-18 03:10:39 -05:00
|
|
|
#include "RimRegularLegendConfig.h"
|
2017-10-13 02:29:42 -05:00
|
|
|
#include "RimSimWellInView.h"
|
2017-10-13 07:20:47 -05:00
|
|
|
#include "RimSimWellInViewCollection.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-08-05 08:06:50 -05:00
|
|
|
|
2016-06-16 08:59:20 -05:00
|
|
|
#include "cafPdmUiTreeOrdering.h"
|
2013-05-06 03:55:00 -05:00
|
|
|
|
2018-01-25 05:00:48 -06:00
|
|
|
#include <QMessageBox>
|
2018-01-25 04:59:43 -06: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
|
|
|
|
2019-03-29 06:03:09 -05:00
|
|
|
CAF_PDM_InitFieldNoDefault(&obsoleteField_legendConfig, "LegendDefinition", "Color Legend", "", "", "");
|
2015-08-06 01:08:00 -05:00
|
|
|
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", "", "", "", "");
|
|
|
|
|
2019-03-29 06:03:09 -05:00
|
|
|
CAF_PDM_InitFieldNoDefault(&m_ternaryLegendConfig, "TernaryLegendDefinition", "Ternary Color Legend", "", "", "");
|
2018-09-24 15:26:14 -05:00
|
|
|
this->m_ternaryLegendConfig = new RimTernaryLegendConfig();
|
2015-08-06 01:08:00 -05:00
|
|
|
|
2019-03-29 06:03:09 -05:00
|
|
|
CAF_PDM_InitFieldNoDefault(&m_legendConfigPtrField, "LegendDefinitionPtrField", "Color Legend PtrField", "", "", "");
|
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
|
|
|
{
|
2018-02-18 11:56:43 -06:00
|
|
|
CVF_ASSERT(obsoleteField_legendConfig() == nullptr);
|
2015-08-07 04:09:05 -05:00
|
|
|
|
|
|
|
m_legendConfigData.deleteAllChildObjects();
|
|
|
|
|
2018-09-24 15:26:14 -05:00
|
|
|
delete m_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
|
|
|
}
|
|
|
|
|
2017-06-13 08:41:52 -05:00
|
|
|
if (newValue != RiaDefines::undefinedResultName())
|
2012-08-31 12:12:47 -05:00
|
|
|
{
|
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
|
|
|
}
|
2016-08-03 09:01:44 -05:00
|
|
|
|
|
|
|
RimCellEdgeColors* cellEdgeColors = dynamic_cast<RimCellEdgeColors*>(this->parentField()->ownerObject());
|
|
|
|
if (cellEdgeColors)
|
|
|
|
{
|
|
|
|
cellEdgeColors->updateConnectedEditors();
|
|
|
|
}
|
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
|
|
|
{
|
2017-06-13 08:41:52 -05:00
|
|
|
if (resultVarNameOfNewLegend != RiaDefines::ternarySaturationResultName())
|
2014-05-06 15:39:53 -05:00
|
|
|
{
|
2015-08-06 01:08:00 -05:00
|
|
|
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
|
|
|
{
|
2017-03-06 04:18:57 -06:00
|
|
|
bool found = false;
|
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)
|
|
|
|
{
|
2018-04-18 03:10:39 -05:00
|
|
|
RimRegularLegendConfig* newLegend = new RimRegularLegendConfig;
|
2015-08-06 01:08:00 -05:00
|
|
|
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
|
|
|
}
|
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
|
2018-04-18 03:10:39 -05:00
|
|
|
RimRegularLegendConfig* obsoleteLegend = obsoleteField_legendConfig();
|
2015-08-07 05:40:47 -05:00
|
|
|
|
2018-10-10 03:17:07 -05:00
|
|
|
// set to nullptr before pushing into container
|
2018-02-18 11:56:43 -06:00
|
|
|
obsoleteField_legendConfig = nullptr;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-04-15 04:06:27 -05:00
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimEclipseCellColors::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
|
|
|
{
|
|
|
|
RimEclipseResultDefinition::defineUiOrdering(uiConfigName, uiOrdering);
|
|
|
|
|
|
|
|
if (uiConfigName == "AddLegendLevels")
|
|
|
|
{
|
|
|
|
legendConfig()->uiOrdering("NumIntervalsOnly", uiOrdering);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2016-06-16 08:59:20 -05:00
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimEclipseCellColors::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/)
|
|
|
|
{
|
2017-06-13 08:41:52 -05:00
|
|
|
if (this->resultVariable() == RiaDefines::ternarySaturationResultName())
|
2016-08-05 08:06:50 -05:00
|
|
|
{
|
2018-09-24 15:26:14 -05:00
|
|
|
uiTreeOrdering.add(m_ternaryLegendConfig());
|
2016-08-05 08:06:50 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
uiTreeOrdering.add(m_legendConfigPtrField());
|
|
|
|
}
|
|
|
|
|
2017-03-22 09:57:04 -05:00
|
|
|
uiTreeOrdering.skipRemainingChildren(true);
|
2016-06-16 08:59:20 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2016-09-07 04:41:02 -05:00
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimEclipseCellColors::updateLegendCategorySettings()
|
|
|
|
{
|
|
|
|
changeLegendConfig(this->resultVariable());
|
|
|
|
|
|
|
|
if (this->hasCategoryResult())
|
|
|
|
{
|
2018-04-18 03:10:39 -05:00
|
|
|
legendConfig()->setMappingMode(RimRegularLegendConfig::CATEGORY_INTEGER);
|
2018-05-11 01:01:10 -05:00
|
|
|
legendConfig()->setColorRange(RimRegularLegendConfig::CATEGORY);
|
2016-09-07 04:41:02 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-04-18 03:10:39 -05:00
|
|
|
if (legendConfig()->mappingMode() == RimRegularLegendConfig::CATEGORY_INTEGER)
|
2016-09-07 04:41:02 -05:00
|
|
|
{
|
2018-04-18 03:10:39 -05:00
|
|
|
legendConfig()->setMappingMode(RimRegularLegendConfig::LINEAR_CONTINUOUS);
|
2016-09-07 04:41:02 -05:00
|
|
|
}
|
|
|
|
|
2018-05-11 01:01:10 -05:00
|
|
|
if (legendConfig()->colorRange() == RimRegularLegendConfig::CATEGORY)
|
2016-09-07 04:41:02 -05:00
|
|
|
{
|
2018-05-11 01:01:10 -05:00
|
|
|
legendConfig()->setColorRange(RimRegularLegendConfig::NORMAL);
|
2016-09-07 04:41:02 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-05 05:37:58 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimEclipseCellColors::uiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/)
|
|
|
|
{
|
|
|
|
defineUiTreeOrdering(uiTreeOrdering, uiConfigName);
|
|
|
|
}
|
|
|
|
|
2016-09-07 04:41:02 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
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
|
|
|
{
|
2019-03-13 04:16:46 -05:00
|
|
|
m_reservoirView = ownerReservoirView;
|
2019-03-12 08:31:11 -05:00
|
|
|
if (ownerReservoirView)
|
|
|
|
{
|
|
|
|
this->setEclipseCase(ownerReservoirView->eclipseCase());
|
|
|
|
}
|
2014-06-13 01:12:45 -05:00
|
|
|
}
|
2016-08-05 08:06:50 -05:00
|
|
|
|
2015-09-01 06:56:35 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimEclipseView* RimEclipseCellColors::reservoirView()
|
|
|
|
{
|
|
|
|
return m_reservoirView;
|
|
|
|
}
|
|
|
|
|
2017-03-21 09:58:02 -05:00
|
|
|
bool operator<(const cvf::Color3ub first, const cvf::Color3ub second)
|
|
|
|
{
|
|
|
|
if (first.r() != second.r()) return first.r() < second.r();
|
|
|
|
if (first.g() != second.g()) return first.g() < second.g();
|
|
|
|
if (first.b() != second.b()) return first.b() < second.b();
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
class TupleCompare
|
|
|
|
{
|
|
|
|
public :
|
|
|
|
bool operator() (const std::tuple<QString, int, cvf::Color3ub>& t1, const std::tuple<QString, int, cvf::Color3ub>& t2) const
|
|
|
|
{
|
|
|
|
using namespace std;
|
|
|
|
if (get<0>(t1) != get<0>(t2)) return get<0>(t1) < get<0>(t2);
|
|
|
|
if (get<1>(t1) != get<1>(t2)) return get<1>(t1) < get<1>(t2);
|
|
|
|
if (get<2>(t1) != get<2>(t2)) return get<2>(t1) < get<2>(t2);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-06-13 01:12:45 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-05 05:37:58 -06:00
|
|
|
void RimEclipseCellColors::updateLegendData(RimEclipseCase* rimEclipseCase,
|
|
|
|
int currentTimeStep,
|
2018-04-18 03:10:39 -05:00
|
|
|
RimRegularLegendConfig* legendConfig,
|
2018-02-01 10:45:22 -06:00
|
|
|
RimTernaryLegendConfig* ternaryLegendConfig)
|
2017-01-11 08:03:39 -06:00
|
|
|
{
|
2018-02-01 10:45:22 -06:00
|
|
|
if (!legendConfig) legendConfig = this->legendConfig();
|
2018-09-24 15:26:14 -05:00
|
|
|
if (!ternaryLegendConfig) ternaryLegendConfig = this->m_ternaryLegendConfig();
|
2018-02-01 10:45:22 -06:00
|
|
|
|
|
|
|
if ( this->hasResult() )
|
2017-01-11 08:03:39 -06:00
|
|
|
{
|
2018-02-01 10:45:22 -06:00
|
|
|
if ( this->isFlowDiagOrInjectionFlooding() )
|
|
|
|
{
|
2019-03-05 05:37:58 -06:00
|
|
|
CVF_ASSERT(currentTimeStep >= 0);
|
|
|
|
|
2018-02-01 10:45:22 -06:00
|
|
|
double globalMin, globalMax;
|
|
|
|
double globalPosClosestToZero, globalNegClosestToZero;
|
|
|
|
RigFlowDiagResults* flowResultsData = this->flowDiagSolution()->flowDiagResults();
|
|
|
|
RigFlowDiagResultAddress resAddr = this->flowDiagResAddress();
|
2017-01-11 08:03:39 -06:00
|
|
|
|
2019-03-05 05:37:58 -06:00
|
|
|
flowResultsData->minMaxScalarValues(resAddr, currentTimeStep, &globalMin, &globalMax);
|
|
|
|
flowResultsData->posNegClosestToZero(resAddr, currentTimeStep, &globalPosClosestToZero, &globalNegClosestToZero);
|
2017-01-11 08:03:39 -06:00
|
|
|
|
2018-02-01 10:45:22 -06:00
|
|
|
double localMin, localMax;
|
|
|
|
double localPosClosestToZero, localNegClosestToZero;
|
|
|
|
if ( this->hasDynamicResult() )
|
|
|
|
{
|
2019-03-05 05:37:58 -06:00
|
|
|
flowResultsData->minMaxScalarValues(resAddr, currentTimeStep, &localMin, &localMax);
|
|
|
|
flowResultsData->posNegClosestToZero(resAddr, currentTimeStep, &localPosClosestToZero, &localNegClosestToZero);
|
2018-02-01 10:45:22 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
localMin = globalMin;
|
|
|
|
localMax = globalMax;
|
2017-01-11 08:03:39 -06:00
|
|
|
|
2018-02-01 10:45:22 -06:00
|
|
|
localPosClosestToZero = globalPosClosestToZero;
|
|
|
|
localNegClosestToZero = globalNegClosestToZero;
|
|
|
|
}
|
2017-01-11 08:03:39 -06:00
|
|
|
|
2018-02-01 10:45:22 -06:00
|
|
|
CVF_ASSERT(legendConfig);
|
2017-01-11 08:03:39 -06:00
|
|
|
|
2018-02-01 10:45:22 -06:00
|
|
|
legendConfig->disableAllTimeStepsRange(true);
|
|
|
|
legendConfig->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero,
|
|
|
|
localPosClosestToZero, localNegClosestToZero);
|
|
|
|
legendConfig->setAutomaticRanges(globalMin, globalMax, localMin, localMax);
|
2017-01-11 08:03:39 -06:00
|
|
|
|
2019-03-05 05:37:58 -06:00
|
|
|
if ( this->hasCategoryResult() && m_reservoirView)
|
2018-02-01 10:45:22 -06:00
|
|
|
{
|
|
|
|
std::set<std::tuple<QString, int, cvf::Color3ub>, TupleCompare > categories;
|
|
|
|
//std::set<std::tuple<QString, int, cvf::Color3ub> > categories;
|
|
|
|
|
|
|
|
std::vector<QString> tracerNames = this->flowDiagSolution()->tracerNames();
|
|
|
|
int tracerIndex = 0;
|
|
|
|
for ( const auto& tracerName : tracerNames )
|
|
|
|
{
|
|
|
|
RimSimWellInView* well = m_reservoirView->wellCollection()->findWell(RimFlowDiagSolution::removeCrossFlowEnding(tracerName));
|
|
|
|
cvf::Color3ub color(cvf::Color3::GRAY);
|
|
|
|
if ( well ) color = cvf::Color3ub(well->wellPipeColor());
|
2017-02-10 11:53:14 -06:00
|
|
|
|
2018-02-01 10:45:22 -06:00
|
|
|
categories.insert(std::make_tuple(tracerName, tracerIndex, color));
|
|
|
|
++tracerIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::tuple<QString, int, cvf::Color3ub>> reverseCategories;
|
|
|
|
for ( auto tupIt = categories.rbegin(); tupIt != categories.rend(); ++tupIt )
|
|
|
|
{
|
|
|
|
reverseCategories.push_back(*tupIt);
|
|
|
|
}
|
|
|
|
|
|
|
|
legendConfig->setCategoryItems(reverseCategories);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CVF_ASSERT(rimEclipseCase);
|
|
|
|
if ( !rimEclipseCase ) return;
|
|
|
|
|
|
|
|
RigEclipseCaseData* eclipseCase = rimEclipseCase->eclipseCaseData();
|
|
|
|
CVF_ASSERT(eclipseCase);
|
|
|
|
if ( !eclipseCase ) return;
|
|
|
|
|
|
|
|
RigCaseCellResultsData* cellResultsData = eclipseCase->results(this->porosityModel());
|
|
|
|
CVF_ASSERT(cellResultsData);
|
|
|
|
|
|
|
|
double globalMin, globalMax;
|
|
|
|
double globalPosClosestToZero, globalNegClosestToZero;
|
2019-01-22 01:54:00 -06:00
|
|
|
|
2019-01-23 07:24:12 -06:00
|
|
|
cellResultsData->minMaxCellScalarValues(this->eclipseResultAddress(), globalMin, globalMax);
|
|
|
|
cellResultsData->posNegClosestToZero(this->eclipseResultAddress(), globalPosClosestToZero, globalNegClosestToZero);
|
2018-02-01 10:45:22 -06:00
|
|
|
|
|
|
|
double localMin, localMax;
|
|
|
|
double localPosClosestToZero, localNegClosestToZero;
|
2019-03-05 05:37:58 -06:00
|
|
|
if ( this->hasDynamicResult() && currentTimeStep >= 0)
|
2018-02-01 10:45:22 -06:00
|
|
|
{
|
2019-01-23 07:24:12 -06:00
|
|
|
cellResultsData->minMaxCellScalarValues(this->eclipseResultAddress(), currentTimeStep, localMin, localMax);
|
|
|
|
cellResultsData->posNegClosestToZero(this->eclipseResultAddress(), currentTimeStep, localPosClosestToZero, localNegClosestToZero);
|
2018-02-01 10:45:22 -06:00
|
|
|
}
|
|
|
|
else
|
2017-02-10 11:53:14 -06:00
|
|
|
{
|
2018-02-01 10:45:22 -06:00
|
|
|
localMin = globalMin;
|
|
|
|
localMax = globalMax;
|
2017-02-15 08:21:13 -06:00
|
|
|
|
2018-02-01 10:45:22 -06:00
|
|
|
localPosClosestToZero = globalPosClosestToZero;
|
|
|
|
localNegClosestToZero = globalNegClosestToZero;
|
2017-02-10 11:53:14 -06:00
|
|
|
}
|
|
|
|
|
2018-02-01 10:45:22 -06:00
|
|
|
CVF_ASSERT(legendConfig);
|
|
|
|
|
|
|
|
legendConfig->disableAllTimeStepsRange(false);
|
|
|
|
legendConfig->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero);
|
|
|
|
legendConfig->setAutomaticRanges(globalMin, globalMax, localMin, localMax);
|
|
|
|
|
|
|
|
if ( this->hasCategoryResult() )
|
2017-03-21 09:58:02 -05:00
|
|
|
{
|
2018-02-01 10:45:22 -06:00
|
|
|
if ( this->resultType() == RiaDefines::FORMATION_NAMES )
|
|
|
|
{
|
|
|
|
const std::vector<QString>& fnVector = eclipseCase->activeFormationNames()->formationNames();
|
|
|
|
legendConfig->setNamedCategoriesInverse(fnVector);
|
|
|
|
}
|
|
|
|
else if ( this->resultType() == RiaDefines::DYNAMIC_NATIVE && this->resultVariable() == RiaDefines::completionTypeResultName() )
|
2018-10-11 09:03:49 -05:00
|
|
|
{
|
2019-01-23 07:24:12 -06:00
|
|
|
const std::vector<int>& visibleCategories = cellResultsData->uniqueCellScalarValues(this->eclipseResultAddress());
|
2018-03-20 09:10:41 -05:00
|
|
|
|
2018-10-11 09:03:49 -05:00
|
|
|
std::vector<RiaDefines::WellPathComponentType> supportedCompletionTypes =
|
|
|
|
{ RiaDefines::WELL_PATH, RiaDefines::FISHBONES, RiaDefines::PERFORATION_INTERVAL, RiaDefines::FRACTURE };
|
|
|
|
|
|
|
|
RiaColorTables::WellPathComponentColors colors = RiaColorTables::wellPathComponentColors();
|
|
|
|
|
|
|
|
std::vector< std::tuple<QString, int, cvf::Color3ub> > categories;
|
|
|
|
for (auto completionType : supportedCompletionTypes)
|
2018-03-20 09:10:41 -05:00
|
|
|
{
|
2018-10-11 09:03:49 -05:00
|
|
|
if (std::find(visibleCategories.begin(), visibleCategories.end(), completionType) != visibleCategories.end())
|
|
|
|
{
|
|
|
|
QString categoryText = caf::AppEnum<RiaDefines::WellPathComponentType>::uiText(completionType);
|
|
|
|
categories.push_back(std::make_tuple(categoryText, completionType, colors[completionType]));
|
|
|
|
}
|
2018-03-20 09:10:41 -05:00
|
|
|
}
|
2018-02-01 10:45:22 -06:00
|
|
|
|
|
|
|
legendConfig->setCategoryItems(categories);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-01-23 07:24:12 -06:00
|
|
|
legendConfig->setIntegerCategories(cellResultsData->uniqueCellScalarValues(this->eclipseResultAddress()));
|
2018-02-01 10:45:22 -06:00
|
|
|
}
|
2017-03-21 09:58:02 -05:00
|
|
|
}
|
2017-01-11 08:03:39 -06:00
|
|
|
}
|
|
|
|
}
|
2018-02-01 10:45:22 -06:00
|
|
|
|
|
|
|
// Ternary legend update
|
2017-01-11 08:03:39 -06:00
|
|
|
{
|
|
|
|
CVF_ASSERT(rimEclipseCase);
|
2018-02-01 10:45:22 -06:00
|
|
|
if ( !rimEclipseCase ) return;
|
2017-01-11 08:03:39 -06:00
|
|
|
|
2017-03-15 03:10:16 -05:00
|
|
|
RigEclipseCaseData* eclipseCase = rimEclipseCase->eclipseCaseData();
|
2017-01-11 08:03:39 -06:00
|
|
|
CVF_ASSERT(eclipseCase);
|
2018-02-01 10:45:22 -06:00
|
|
|
if ( !eclipseCase ) return;
|
2017-01-11 08:03:39 -06:00
|
|
|
|
|
|
|
|
2018-02-01 10:45:22 -06:00
|
|
|
RigCaseCellResultsData* cellResultsData = eclipseCase->results(this->porosityModel());
|
2017-01-11 08:03:39 -06:00
|
|
|
|
2018-02-01 10:45:22 -06:00
|
|
|
size_t maxTimeStepCount = cellResultsData->maxTimeStepCount();
|
|
|
|
if ( this->isTernarySaturationSelected() && maxTimeStepCount > 1 )
|
2017-01-11 08:03:39 -06:00
|
|
|
{
|
2018-02-01 10:45:22 -06:00
|
|
|
RigCaseCellResultsData* gridCellResults = this->currentGridCellResults();
|
|
|
|
{
|
2019-01-25 05:58:07 -06:00
|
|
|
RigEclipseResultAddress resAddr(RiaDefines::DYNAMIC_NATIVE, "SOIL");
|
|
|
|
|
2019-01-28 09:18:28 -06:00
|
|
|
if ( gridCellResults->ensureKnownResultLoaded(resAddr) )
|
2018-02-01 10:45:22 -06:00
|
|
|
{
|
|
|
|
double globalMin = 0.0;
|
|
|
|
double globalMax = 1.0;
|
|
|
|
double localMin = 0.0;
|
|
|
|
double localMax = 1.0;
|
2017-01-11 08:03:39 -06:00
|
|
|
|
2019-01-25 05:58:07 -06:00
|
|
|
cellResultsData->minMaxCellScalarValues(resAddr, globalMin, globalMax);
|
|
|
|
cellResultsData->minMaxCellScalarValues(resAddr, currentTimeStep, localMin, localMax);
|
2017-01-11 08:03:39 -06:00
|
|
|
|
2018-02-01 10:45:22 -06:00
|
|
|
ternaryLegendConfig->setAutomaticRanges(RimTernaryLegendConfig::TERNARY_SOIL_IDX, globalMin, globalMax, localMin, localMax);
|
|
|
|
}
|
2017-05-31 09:16:28 -05:00
|
|
|
}
|
2017-06-01 05:55:13 -05:00
|
|
|
|
2018-02-01 10:45:22 -06:00
|
|
|
{
|
2019-01-25 05:58:07 -06:00
|
|
|
RigEclipseResultAddress resAddr(RiaDefines::DYNAMIC_NATIVE, "SGAS");
|
2019-01-28 09:18:28 -06:00
|
|
|
|
|
|
|
if ( gridCellResults->ensureKnownResultLoaded(resAddr) )
|
2018-02-01 10:45:22 -06:00
|
|
|
{
|
|
|
|
double globalMin = 0.0;
|
|
|
|
double globalMax = 1.0;
|
|
|
|
double localMin = 0.0;
|
|
|
|
double localMax = 1.0;
|
2017-06-01 05:55:13 -05:00
|
|
|
|
2019-01-25 05:58:07 -06:00
|
|
|
cellResultsData->minMaxCellScalarValues(resAddr, globalMin, globalMax);
|
|
|
|
cellResultsData->minMaxCellScalarValues(resAddr, currentTimeStep, localMin, localMax);
|
2017-06-01 05:55:13 -05:00
|
|
|
|
2018-02-01 10:45:22 -06:00
|
|
|
ternaryLegendConfig->setAutomaticRanges(RimTernaryLegendConfig::TERNARY_SGAS_IDX, globalMin, globalMax, localMin, localMax);
|
|
|
|
}
|
2017-01-11 08:03:39 -06:00
|
|
|
}
|
2018-02-01 10:45:22 -06:00
|
|
|
|
2017-01-11 08:03:39 -06:00
|
|
|
{
|
2019-01-25 05:58:07 -06:00
|
|
|
RigEclipseResultAddress resAddr(RiaDefines::DYNAMIC_NATIVE, "SWAT");
|
2019-01-28 09:18:28 -06:00
|
|
|
|
|
|
|
if ( gridCellResults->ensureKnownResultLoaded(resAddr) )
|
2018-02-01 10:45:22 -06:00
|
|
|
{
|
|
|
|
double globalMin = 0.0;
|
|
|
|
double globalMax = 1.0;
|
|
|
|
double localMin = 0.0;
|
|
|
|
double localMax = 1.0;
|
|
|
|
|
2019-01-25 05:58:07 -06:00
|
|
|
cellResultsData->minMaxCellScalarValues(resAddr, globalMin, globalMax);
|
|
|
|
cellResultsData->minMaxCellScalarValues(resAddr, currentTimeStep, localMin, localMax);
|
2018-02-01 10:45:22 -06:00
|
|
|
|
|
|
|
ternaryLegendConfig->setAutomaticRanges(RimTernaryLegendConfig::TERNARY_SWAT_IDX, globalMin, globalMax, localMin, localMax);
|
|
|
|
}
|
2017-01-11 08:03:39 -06: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
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-04-18 03:10:39 -05:00
|
|
|
RimRegularLegendConfig* RimEclipseCellColors::legendConfig()
|
2015-08-06 01:08:00 -05:00
|
|
|
{
|
|
|
|
return m_legendConfigPtrField;
|
|
|
|
}
|
|
|
|
|
2018-09-24 15:26:14 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimTernaryLegendConfig* RimEclipseCellColors::ternaryLegendConfig()
|
|
|
|
{
|
|
|
|
return m_ternaryLegendConfig;
|
|
|
|
}
|
|
|
|
|
2015-09-23 06:48:25 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimEclipseCellColors::updateIconState()
|
|
|
|
{
|
2019-03-05 05:37:58 -06:00
|
|
|
if (m_reservoirView)
|
2015-09-23 06:48:25 -05:00
|
|
|
{
|
2019-03-05 05:37:58 -06:00
|
|
|
RimViewController* viewController = m_reservoirView->viewController();
|
|
|
|
if (viewController && viewController->isResultColorControlled())
|
|
|
|
{
|
|
|
|
updateUiIconFromState(false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
updateUiIconFromState(true);
|
|
|
|
}
|
2015-09-23 06:48:25 -05:00
|
|
|
}
|
|
|
|
uiCapability()->updateConnectedEditors();
|
|
|
|
}
|
|
|
|
|