(#829) Moved RimLegendConfig as a private field to be able to switch between standard and single var result color

This commit is contained in:
Magne Sjaastad 2016-09-07 10:46:47 +02:00
parent f1c214c1d7
commit f404299702
3 changed files with 30 additions and 13 deletions

View File

@ -49,14 +49,14 @@ RimCellEdgeColors::RimCellEdgeColors()
CAF_PDM_InitField(&useYVariable, "UseYVariable", true, "Use Y values", "", "", "");
CAF_PDM_InitField(&useZVariable, "UseZVariable", true, "Use Z values", "", "", "");
CAF_PDM_InitFieldNoDefault(&legendConfig, "LegendDefinition", "Legend Definition", ":/Legend.png", "", "");
CAF_PDM_InitFieldNoDefault(&m_legendConfig, "LegendDefinition", "Legend Definition", ":/Legend.png", "", "");
CAF_PDM_InitFieldNoDefault(&m_singleVarEdgeResultColors, "CustomEdgeResult", "Custom Edge Result", ":/CellResult.png", "", "");
m_singleVarEdgeResultColors = new RimEclipseCellColors();
m_resultVariable.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName());
legendConfig = new RimLegendConfig();
m_legendConfig = new RimLegendConfig();
m_ignoredResultScalar = cvf::UNDEFINED_DOUBLE;
resetResultIndices();
@ -67,7 +67,7 @@ RimCellEdgeColors::RimCellEdgeColors()
//--------------------------------------------------------------------------------------------------
RimCellEdgeColors::~RimCellEdgeColors()
{
delete legendConfig();
delete m_legendConfig();
delete m_singleVarEdgeResultColors;
}
@ -77,7 +77,7 @@ RimCellEdgeColors::~RimCellEdgeColors()
void RimCellEdgeColors::setReservoirView(RimEclipseView* ownerReservoirView)
{
m_reservoirView = ownerReservoirView;
this->legendConfig()->setReservoirView(ownerReservoirView);
this->m_legendConfig()->setReservoirView(ownerReservoirView);
m_singleVarEdgeResultColors->setReservoirView(ownerReservoirView);
}
@ -537,3 +537,18 @@ RimEclipseCellColors* RimCellEdgeColors::singleVarEdgeResultColors()
return m_singleVarEdgeResultColors;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimLegendConfig* RimCellEdgeColors::legendConfig()
{
if (isUsingSingleVariable())
{
return m_singleVarEdgeResultColors->legendConfig();
}
else
{
return m_legendConfig;
}
}

View File

@ -70,7 +70,6 @@ public:
caf::PdmField<bool> enableCellEdgeColors;
caf::PdmChildField<RimLegendConfig*> legendConfig;
double ignoredScalarValue() { return m_ignoredResultScalar; }
void gridScalarIndices(size_t resultIndices[6]);
void cellEdgeMetaData(std::vector<RimCellEdgeMetaData>* metaData);
@ -79,6 +78,7 @@ public:
bool hasResult() const;
bool hasCategoryResult() const;
RimEclipseCellColors* singleVarEdgeResultColors();
RimLegendConfig* legendConfig();
void minMaxCellEdgeValues(double& min, double& max);
void posNegClosestToZero(double& pos, double& neg);
@ -113,6 +113,8 @@ private:
bool isUsingSingleVariable() const;
static QString singleVarEdgeResultUiText() { return "Custom Edge Result"; }
caf::PdmChildField<RimLegendConfig*> m_legendConfig;
caf::PdmChildField<RimEclipseCellColors*> m_singleVarEdgeResultColors;
};

View File

@ -941,8 +941,8 @@ void RimEclipseView::updateLegends()
this->cellEdgeResult()->minMaxCellEdgeValues(globalMin, globalMax);
this->cellEdgeResult()->posNegClosestToZero(globalPosClosestToZero, globalNegClosestToZero);
this->cellEdgeResult()->legendConfig->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, globalPosClosestToZero, globalNegClosestToZero);
this->cellEdgeResult()->legendConfig->setAutomaticRanges(globalMin, globalMax, globalMin, globalMax);
this->cellEdgeResult()->legendConfig()->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, globalPosClosestToZero, globalNegClosestToZero);
this->cellEdgeResult()->legendConfig()->setAutomaticRanges(globalMin, globalMax, globalMin, globalMax);
if (this->cellEdgeResult()->hasCategoryResult())
{
@ -965,13 +965,13 @@ void RimEclipseView::updateLegends()
}
}
m_viewer->addColorLegendToBottomLeftCorner(this->cellEdgeResult()->legendConfig->legend());
this->cellEdgeResult()->legendConfig->setTitle(cvfqt::Utils::toString(QString("Edge Results: \n") + this->cellEdgeResult()->resultVariable()));
m_viewer->addColorLegendToBottomLeftCorner(this->cellEdgeResult()->legendConfig()->legend());
this->cellEdgeResult()->legendConfig()->setTitle(cvfqt::Utils::toString(QString("Edge Results: \n") + this->cellEdgeResult()->resultVariable()));
}
else
{
this->cellEdgeResult()->legendConfig->setClosestToZeroValues(0, 0, 0, 0);
this->cellEdgeResult()->legendConfig->setAutomaticRanges(cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE);
this->cellEdgeResult()->legendConfig()->setClosestToZeroValues(0, 0, 0, 0);
this->cellEdgeResult()->legendConfig()->setAutomaticRanges(cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE);
}
}
@ -1554,13 +1554,13 @@ void RimEclipseView::resetLegendsInViewer()
if (cellResultNormalLegendConfig) cellResultNormalLegendConfig->recreateLegend();
this->cellResult()->ternaryLegendConfig->recreateLegend();
this->cellEdgeResult()->legendConfig->recreateLegend();
this->cellEdgeResult()->legendConfig()->recreateLegend();
m_viewer->removeAllColorLegends();
if (cellResultNormalLegendConfig) m_viewer->addColorLegendToBottomLeftCorner(cellResultNormalLegendConfig->legend());
m_viewer->addColorLegendToBottomLeftCorner(this->cellEdgeResult()->legendConfig->legend());
m_viewer->addColorLegendToBottomLeftCorner(this->cellEdgeResult()->legendConfig()->legend());
}
//--------------------------------------------------------------------------------------------------