Legends (#2749): Clean up enable/showLegend option

* Make public field private ...
* Make the option invisible from within the property panel.
This commit is contained in:
Gaute Lindkvist 2018-04-17 15:59:50 +02:00
parent c3e9a39532
commit 56dd1b3eb9
6 changed files with 28 additions and 14 deletions

View File

@ -1055,7 +1055,7 @@ 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()->legendConfig()->showLegend())
{ {
if (this->cellEdgeResult()->hasResult()) if (this->cellEdgeResult()->hasResult())
{ {
@ -1098,7 +1098,7 @@ void RimEclipseView::updateLegends()
} }
RimLegendConfig* stimPlanLegend = fractureColors()->activeLegend(); RimLegendConfig* stimPlanLegend = fractureColors()->activeLegend();
if (stimPlanLegend && stimPlanLegend->enableLegend()) if (stimPlanLegend && stimPlanLegend->showLegend())
{ {
fractureColors()->updateLegendData(); fractureColors()->updateLegendData();
@ -1108,7 +1108,7 @@ void RimEclipseView::updateLegends()
} }
} }
if (m_virtualPerforationResult->isActive() && m_virtualPerforationResult->legendConfig()->enableLegend()) if (m_virtualPerforationResult->isActive() && m_virtualPerforationResult->legendConfig()->showLegend())
{ {
updateVirtualConnectionLegendRanges(); updateVirtualConnectionLegendRanges();
@ -1126,7 +1126,7 @@ void RimEclipseView::updateMinMaxValuesAndAddLegendToView(QString legendLabel,
{ {
resultColors->updateLegendData(m_currentTimeStep); resultColors->updateLegendData(m_currentTimeStep);
if (resultColors->hasResult() && resultColors->legendConfig()->enableLegend()) if (resultColors->hasResult() && resultColors->legendConfig()->showLegend())
{ {
m_viewer->addColorLegendToBottomLeftCorner(resultColors->legendConfig()->legend()); m_viewer->addColorLegendToBottomLeftCorner(resultColors->legendConfig()->legend());
resultColors->legendConfig()->setTitle(legendLabel + resultColors->resultVariableUiShortName()); resultColors->legendConfig()->setTitle(legendLabel + resultColors->resultVariableUiShortName());
@ -1135,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->enableLegend() && resultColors->ternaryLegendConfig->legend()) if (resultColors->ternaryLegendConfig->showLegend() && resultColors->ternaryLegendConfig->legend())
{ {
resultColors->ternaryLegendConfig->setTitle(legendLabel); resultColors->ternaryLegendConfig->setTitle(legendLabel);
m_viewer->addColorLegendToBottomLeftCorner(resultColors->ternaryLegendConfig->legend()); m_viewer->addColorLegendToBottomLeftCorner(resultColors->ternaryLegendConfig->legend());

View File

@ -378,7 +378,7 @@ void RimGeoMechView::updateLegends()
this->updateLegendTextAndRanges(cellResult()->legendConfig(), m_currentTimeStep()); this->updateLegendTextAndRanges(cellResult()->legendConfig(), m_currentTimeStep());
if (cellResult()->hasResult() && cellResult()->legendConfig()->enableLegend()) if (cellResult()->hasResult() && cellResult()->legendConfig()->showLegend())
{ {
m_viewer->addColorLegendToBottomLeftCorner(cellResult()->legendConfig->legend()); m_viewer->addColorLegendToBottomLeftCorner(cellResult()->legendConfig->legend());
} }
@ -387,7 +387,7 @@ void RimGeoMechView::updateLegends()
if (tensorResults()->vectorColors() == RimTensorResults::RESULT_COLORS && tensorResults()->showTensors()) if (tensorResults()->vectorColors() == RimTensorResults::RESULT_COLORS && tensorResults()->showTensors())
{ {
if (tensorResults()->arrowColorLegendConfig()->enableLegend()) if (tensorResults()->arrowColorLegendConfig()->showLegend())
{ {
m_viewer->addColorLegendToBottomLeftCorner(m_tensorResults->arrowColorLegendConfig->legend()); m_viewer->addColorLegendToBottomLeftCorner(m_tensorResults->arrowColorLegendConfig->legend());
} }

View File

@ -123,7 +123,8 @@ 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_showLegend, "ShowLegend", true, "Show Legend", "", "", "");
m_showLegend.uiCapability()->setUiHidden(true);
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", "", "","");
@ -442,7 +443,7 @@ void RimLegendConfig::initAfterRead()
caf::PdmFieldHandle* RimLegendConfig::objectToggleField() caf::PdmFieldHandle* RimLegendConfig::objectToggleField()
{ {
return &enableLegend; return &m_showLegend;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -669,6 +670,11 @@ caf::TitledOverlayFrame* RimLegendConfig::legend()
} }
} }
bool RimLegendConfig::showLegend() const
{
return m_showLegend;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -121,8 +121,7 @@ public:
cvf::ScalarMapper* scalarMapper() { return m_currentScalarMapper.p(); } cvf::ScalarMapper* scalarMapper() { return m_currentScalarMapper.p(); }
caf::TitledOverlayFrame* legend(); caf::TitledOverlayFrame* legend();
bool showLegend() const;
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);
@ -172,6 +171,7 @@ private:
cvf::Color3ubArray m_categoryColors; cvf::Color3ubArray m_categoryColors;
// Fields // Fields
caf::PdmField<bool> m_showLegend;
caf::PdmField<int> m_numLevels; caf::PdmField<int> m_numLevels;
caf::PdmField<int> m_precision; caf::PdmField<int> m_precision;
caf::PdmField<caf::AppEnum<NumberFormatType> > m_tickNumberFormat; caf::PdmField<caf::AppEnum<NumberFormatType> > m_tickNumberFormat;

View File

@ -57,7 +57,8 @@ 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(&m_showLegend, "ShowTernaryLegend", true, "Show Ternary Legend", "", "", "");
m_showLegend.uiCapability()->setUiHidden(true);
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", "");
@ -340,6 +341,11 @@ RivTernarySaturationOverlayItem* RimTernaryLegendConfig::legend()
return m_legend.p(); return m_legend.p();
} }
bool RimTernaryLegendConfig::showLegend() const
{
return m_showLegend;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -493,5 +499,5 @@ const RivTernaryScalarMapper* RimTernaryLegendConfig::scalarMapper() const
caf::PdmFieldHandle* RimTernaryLegendConfig::objectToggleField() caf::PdmFieldHandle* RimTernaryLegendConfig::objectToggleField()
{ {
return &enableLegend; return &m_showLegend;
} }

View File

@ -74,7 +74,7 @@ public:
const RivTernarySaturationOverlayItem* legend() const; const RivTernarySaturationOverlayItem* legend() const;
RivTernarySaturationOverlayItem* legend(); RivTernarySaturationOverlayItem* legend();
caf::PdmField<bool> enableLegend; bool showLegend() const;
void setTitle(const QString& title); void setTitle(const QString& title);
@ -107,6 +107,8 @@ private:
caf::PdmField<bool> applyFullRangeMinMax; caf::PdmField<bool> applyFullRangeMinMax;
caf::PdmField<QString> ternaryRangeSummary; caf::PdmField<QString> ternaryRangeSummary;
caf::PdmField<bool> m_showLegend;
std::vector<double> m_globalAutoMax; std::vector<double> m_globalAutoMax;
std::vector<double> m_globalAutoMin; std::vector<double> m_globalAutoMin;
std::vector<double> m_localAutoMax; std::vector<double> m_localAutoMax;