Added toggle option for legends.

This commit is contained in:
Gaute Lindkvist
2018-04-06 15:30:51 +02:00
parent e93f79790e
commit fe56375be6
5 changed files with 57 additions and 38 deletions

View File

@@ -1055,6 +1055,8 @@ void RimEclipseView::updateLegends()
updateMinMaxValuesAndAddLegendToView(QString("Fault Results: \n"), this->currentFaultResultColors(), results); updateMinMaxValuesAndAddLegendToView(QString("Fault Results: \n"), this->currentFaultResultColors(), results);
} }
if (this->cellEdgeResult()->legendConfig()->enableLegend())
{
if (this->cellEdgeResult()->hasResult()) if (this->cellEdgeResult()->hasResult())
{ {
if (this->cellEdgeResult()->isUsingSingleVariable()) if (this->cellEdgeResult()->isUsingSingleVariable())
@@ -1093,9 +1095,10 @@ void RimEclipseView::updateLegends()
this->cellEdgeResult()->legendConfig()->setClosestToZeroValues(0, 0, 0, 0); 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()->setAutomaticRanges(cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE);
} }
}
RimLegendConfig* stimPlanLegend = fractureColors()->activeLegend(); RimLegendConfig* stimPlanLegend = fractureColors()->activeLegend();
if (stimPlanLegend) if (stimPlanLegend && stimPlanLegend->enableLegend())
{ {
fractureColors()->updateLegendData(); fractureColors()->updateLegendData();
@@ -1105,12 +1108,11 @@ void RimEclipseView::updateLegends()
} }
} }
if (m_virtualPerforationResult->isActive()) if (m_virtualPerforationResult->isActive() && m_virtualPerforationResult->legendConfig()->enableLegend())
{ {
updateVirtualConnectionLegendRanges(); updateVirtualConnectionLegendRanges();
RimLegendConfig* virtLegend = m_virtualPerforationResult->legendConfig(); RimLegendConfig* virtLegend = m_virtualPerforationResult->legendConfig();
m_viewer->addColorLegendToBottomLeftCorner(virtLegend->legend(), this->backgroundColor()); m_viewer->addColorLegendToBottomLeftCorner(virtLegend->legend(), this->backgroundColor());
} }
} }
@@ -1124,7 +1126,7 @@ void RimEclipseView::updateMinMaxValuesAndAddLegendToView(QString legendLabel,
{ {
resultColors->updateLegendData(m_currentTimeStep); resultColors->updateLegendData(m_currentTimeStep);
if (resultColors->hasResult()) if (resultColors->hasResult() && resultColors->legendConfig()->enableLegend())
{ {
m_viewer->addColorLegendToBottomLeftCorner(resultColors->legendConfig()->legend(), this->backgroundColor()); m_viewer->addColorLegendToBottomLeftCorner(resultColors->legendConfig()->legend(), this->backgroundColor());
resultColors->legendConfig()->setTitle(legendLabel + resultColors->resultVariableUiShortName()); resultColors->legendConfig()->setTitle(legendLabel + resultColors->resultVariableUiShortName());
@@ -1133,7 +1135,7 @@ void RimEclipseView::updateMinMaxValuesAndAddLegendToView(QString legendLabel,
size_t maxTimeStepCount = cellResultsData->maxTimeStepCount(); size_t maxTimeStepCount = cellResultsData->maxTimeStepCount();
if (resultColors->isTernarySaturationSelected() && maxTimeStepCount > 1) if (resultColors->isTernarySaturationSelected() && maxTimeStepCount > 1)
{ {
if (resultColors->ternaryLegendConfig->legend()) if (resultColors->ternaryLegendConfig->enableLegend() && resultColors->ternaryLegendConfig->legend())
{ {
resultColors->ternaryLegendConfig->setTitle(legendLabel); resultColors->ternaryLegendConfig->setTitle(legendLabel);
m_viewer->addColorLegendToBottomLeftCorner(resultColors->ternaryLegendConfig->legend(), this->backgroundColor()); m_viewer->addColorLegendToBottomLeftCorner(resultColors->ternaryLegendConfig->legend(), this->backgroundColor());

View File

@@ -123,6 +123,7 @@ RimLegendConfig::RimLegendConfig()
m_isAllTimeStepsRangeDisabled(false) m_isAllTimeStepsRangeDisabled(false)
{ {
CAF_PDM_InitObject("Legend Definition", ":/Legend.png", "", ""); CAF_PDM_InitObject("Legend Definition", ":/Legend.png", "", "");
CAF_PDM_InitField(&enableLegend, "EnableLegend", true, "Enable Legend", "", "", "");
CAF_PDM_InitField(&m_numLevels, "NumberOfLevels", 8, "Number of Levels", "", "A hint on how many tick marks you whish.",""); CAF_PDM_InitField(&m_numLevels, "NumberOfLevels", 8, "Number of Levels", "", "A hint on how many tick marks you whish.","");
CAF_PDM_InitField(&m_precision, "Precision", 4, "Significant Digits", "", "The number of significant digits displayed in the legend numbers",""); CAF_PDM_InitField(&m_precision, "Precision", 4, "Significant Digits", "", "The number of significant digits displayed in the legend numbers","");
CAF_PDM_InitField(&m_tickNumberFormat, "TickNumberFormat", caf::AppEnum<RimLegendConfig::NumberFormatType>(FIXED), "Number format", "", "",""); CAF_PDM_InitField(&m_tickNumberFormat, "TickNumberFormat", caf::AppEnum<RimLegendConfig::NumberFormatType>(FIXED), "Number format", "", "","");
@@ -465,6 +466,11 @@ void RimLegendConfig::initAfterRead()
updateFieldVisibility(); updateFieldVisibility();
} }
caf::PdmFieldHandle* RimLegendConfig::objectToggleField()
{
return &enableLegend;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@@ -122,9 +122,12 @@ public:
cvf::ScalarMapper* scalarMapper() { return m_currentScalarMapper.p(); } cvf::ScalarMapper* scalarMapper() { return m_currentScalarMapper.p(); }
caf::TitledOverlayFrame* legend(); caf::TitledOverlayFrame* legend();
caf::PdmField<bool> enableLegend;
protected: protected:
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
virtual void initAfterRead(); virtual void initAfterRead();
virtual caf::PdmFieldHandle* objectToggleField();
friend class RimStimPlanLegendConfig; friend class RimStimPlanLegendConfig;
virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ); virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering );

View File

@@ -57,7 +57,7 @@ namespace caf {
RimTernaryLegendConfig::RimTernaryLegendConfig() RimTernaryLegendConfig::RimTernaryLegendConfig()
{ {
CAF_PDM_InitObject("Ternary Legend Definition", ":/Legend.png", "", ""); CAF_PDM_InitObject("Ternary Legend Definition", ":/Legend.png", "", "");
CAF_PDM_InitField(&enableLegend, "EnableTernaryLegend", true, "Enable Ternary Legend", "", "", "");
CAF_PDM_InitField(&precision, "Precision", 2, "Significant digits", "", "The number of significant digits displayed in the legend numbers",""); CAF_PDM_InitField(&precision, "Precision", 2, "Significant digits", "", "The number of significant digits displayed in the legend numbers","");
CAF_PDM_InitField(&rangeMode, "RangeType", RangeModeEnum(USER_DEFINED), "Range type", "", "Switches between automatic and user defined range on the legend", ""); CAF_PDM_InitField(&rangeMode, "RangeType", RangeModeEnum(USER_DEFINED), "Range type", "", "Switches between automatic and user defined range on the legend", "");
@@ -491,3 +491,7 @@ const RivTernaryScalarMapper* RimTernaryLegendConfig::scalarMapper() const
return m_scalarMapper.p(); return m_scalarMapper.p();
} }
caf::PdmFieldHandle* RimTernaryLegendConfig::objectToggleField()
{
return &enableLegend;
}

View File

@@ -73,6 +73,9 @@ public:
const RivTernarySaturationOverlayItem* legend() const; const RivTernarySaturationOverlayItem* legend() const;
RivTernarySaturationOverlayItem* legend(); RivTernarySaturationOverlayItem* legend();
caf::PdmField<bool> enableLegend;
void setTitle(const QString& title); void setTitle(const QString& title);
const RivTernaryScalarMapper* scalarMapper() const; const RivTernaryScalarMapper* scalarMapper() const;
@@ -81,6 +84,7 @@ protected:
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering ); virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering );
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute); virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute);
virtual caf::PdmFieldHandle* objectToggleField();
private: private:
void updateLegend(); void updateLegend();