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,47 +1055,50 @@ void RimEclipseView::updateLegends()
updateMinMaxValuesAndAddLegendToView(QString("Fault Results: \n"), this->currentFaultResultColors(), results);
}
if (this->cellEdgeResult()->hasResult())
if (this->cellEdgeResult()->legendConfig()->enableLegend())
{
if (this->cellEdgeResult()->isUsingSingleVariable())
if (this->cellEdgeResult()->hasResult())
{
this->cellEdgeResult()->singleVarEdgeResultColors()->updateLegendData(m_currentTimeStep);
if (this->cellEdgeResult()->isUsingSingleVariable())
{
this->cellEdgeResult()->singleVarEdgeResultColors()->updateLegendData(m_currentTimeStep);
}
else
{
double globalMin, globalMax;
double globalPosClosestToZero, globalNegClosestToZero;
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);
if (this->cellEdgeResult()->hasCategoryResult())
{
if (cellEdgeResult()->singleVarEdgeResultColors()->resultType() != RiaDefines::FORMATION_NAMES)
{
cellEdgeResult()->legendConfig()->setIntegerCategories(results->uniqueCellScalarValues(cellEdgeResult()->singleVarEdgeResultColors()->scalarResultIndex()));
}
else
{
const std::vector<QString>& fnVector = eclipseCase->activeFormationNames()->formationNames();
cellEdgeResult()->legendConfig()->setNamedCategoriesInverse(fnVector);
}
}
}
m_viewer->addColorLegendToBottomLeftCorner(this->cellEdgeResult()->legendConfig()->legend(), this->backgroundColor());
this->cellEdgeResult()->legendConfig()->setTitle(QString("Edge Results: \n") + this->cellEdgeResult()->resultVariableUiShortName());
}
else
{
double globalMin, globalMax;
double globalPosClosestToZero, globalNegClosestToZero;
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);
if (this->cellEdgeResult()->hasCategoryResult())
{
if(cellEdgeResult()->singleVarEdgeResultColors()->resultType() != RiaDefines::FORMATION_NAMES)
{
cellEdgeResult()->legendConfig()->setIntegerCategories(results->uniqueCellScalarValues(cellEdgeResult()->singleVarEdgeResultColors()->scalarResultIndex()));
}
else
{
const std::vector<QString>& fnVector = eclipseCase->activeFormationNames()->formationNames();
cellEdgeResult()->legendConfig()->setNamedCategoriesInverse(fnVector);
}
}
this->cellEdgeResult()->legendConfig()->setClosestToZeroValues(0, 0, 0, 0);
this->cellEdgeResult()->legendConfig()->setAutomaticRanges(cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE);
}
m_viewer->addColorLegendToBottomLeftCorner(this->cellEdgeResult()->legendConfig()->legend(), this->backgroundColor());
this->cellEdgeResult()->legendConfig()->setTitle(QString("Edge Results: \n") + this->cellEdgeResult()->resultVariableUiShortName());
}
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);
}
RimLegendConfig* stimPlanLegend = fractureColors()->activeLegend();
if (stimPlanLegend)
if (stimPlanLegend && stimPlanLegend->enableLegend())
{
fractureColors()->updateLegendData();
@ -1105,12 +1108,11 @@ void RimEclipseView::updateLegends()
}
}
if (m_virtualPerforationResult->isActive())
if (m_virtualPerforationResult->isActive() && m_virtualPerforationResult->legendConfig()->enableLegend())
{
updateVirtualConnectionLegendRanges();
RimLegendConfig* virtLegend = m_virtualPerforationResult->legendConfig();
m_viewer->addColorLegendToBottomLeftCorner(virtLegend->legend(), this->backgroundColor());
}
}
@ -1124,7 +1126,7 @@ void RimEclipseView::updateMinMaxValuesAndAddLegendToView(QString legendLabel,
{
resultColors->updateLegendData(m_currentTimeStep);
if (resultColors->hasResult())
if (resultColors->hasResult() && resultColors->legendConfig()->enableLegend())
{
m_viewer->addColorLegendToBottomLeftCorner(resultColors->legendConfig()->legend(), this->backgroundColor());
resultColors->legendConfig()->setTitle(legendLabel + resultColors->resultVariableUiShortName());
@ -1133,7 +1135,7 @@ void RimEclipseView::updateMinMaxValuesAndAddLegendToView(QString legendLabel,
size_t maxTimeStepCount = cellResultsData->maxTimeStepCount();
if (resultColors->isTernarySaturationSelected() && maxTimeStepCount > 1)
{
if (resultColors->ternaryLegendConfig->legend())
if (resultColors->ternaryLegendConfig->enableLegend() && resultColors->ternaryLegendConfig->legend())
{
resultColors->ternaryLegendConfig->setTitle(legendLabel);
m_viewer->addColorLegendToBottomLeftCorner(resultColors->ternaryLegendConfig->legend(), this->backgroundColor());

View File

@ -123,6 +123,7 @@ RimLegendConfig::RimLegendConfig()
m_isAllTimeStepsRangeDisabled(false)
{
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_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", "", "","");
@ -465,6 +466,11 @@ void RimLegendConfig::initAfterRead()
updateFieldVisibility();
}
caf::PdmFieldHandle* RimLegendConfig::objectToggleField()
{
return &enableLegend;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

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

View File

@ -57,7 +57,7 @@ namespace caf {
RimTernaryLegendConfig::RimTernaryLegendConfig()
{
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(&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();
}
caf::PdmFieldHandle* RimTernaryLegendConfig::objectToggleField()
{
return &enableLegend;
}

View File

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