Skip to content

Commit

Permalink
Use childFieldChangedByUi to trigger update of curves and titles
Browse files Browse the repository at this point in the history
  • Loading branch information
magnesj committed Sep 26, 2023
1 parent 675acaf commit 9dd8012
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
38 changes: 28 additions & 10 deletions ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#include "RimSummaryCaseCollection.h"
#include "RimSummaryCurve.h"
#include "RimSummaryCurveAutoName.h"
#include "RimSummaryMultiPlot.h"
#include "RimSummaryPlot.h"
#include "RimTimeStepFilter.h"

Expand Down Expand Up @@ -151,8 +152,6 @@ RimEnsembleCurveSet::RimEnsembleCurveSet()
m_xAddressSelector.uiCapability()->setUiTreeHidden( true );
m_xAddressSelector.uiCapability()->setUiTreeChildrenHidden( true );

m_xAddressSelector->addressChanged.connect( this, &RimEnsembleCurveSet::onXAxisAddressChanged );

CAF_PDM_InitField( &m_colorMode, "ColorMode", caf::AppEnum<ColorMode>( ColorMode::SINGLE_COLOR_WITH_ALPHA ), "Coloring Mode" );

CAF_PDM_InitField( &m_colorForRealizations, "Color", RiaColorTools::textColor3f(), "Color" );
Expand Down Expand Up @@ -998,6 +997,33 @@ void RimEnsembleCurveSet::defineObjectEditorAttribute( QString uiConfigName, caf
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEnsembleCurveSet::childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField )
{
if ( changedChildField == &m_xAddressSelector )
{
updateAllCurves();

// The recommended way to trigger update in a parent object is by using caf::Signal. Here we need to update two parent classes, and
// they are multiple levels away. To avoid a long signal path that is hard to debug, we use firstAncestorOrThisOfType()

auto summaryPlot = firstAncestorOrThisOfType<RimSummaryPlot>();
if ( summaryPlot )
{
summaryPlot->updateAll();
summaryPlot->zoomAll();
}

auto multiPlot = firstAncestorOrThisOfType<RimSummaryMultiPlot>();
if ( multiPlot )
{
multiPlot->updatePlotTitles();
}
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -1087,14 +1113,6 @@ void RimEnsembleCurveSet::onCustomObjectiveFunctionChanged( const caf::SignalEmi
updateObjectiveFunctionLegend();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEnsembleCurveSet::onXAxisAddressChanged( const caf::SignalEmitter* emitter )
{
updateAllCurves();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ class RimEnsembleCurveSet : public caf::PdmObject, public RimEnsembleCurveSetInt

void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
void childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) override;

void updatePlotAxis();

Expand All @@ -221,7 +222,6 @@ class RimEnsembleCurveSet : public caf::PdmObject, public RimEnsembleCurveSetInt

void onObjectiveFunctionChanged( const caf::SignalEmitter* emitter );
void onCustomObjectiveFunctionChanged( const caf::SignalEmitter* emitter );
void onXAxisAddressChanged( const caf::SignalEmitter* emitter );

void setTransparentCurveColor();
void onColorTagClicked( const SignalEmitter* emitter, size_t index );
Expand Down

0 comments on commit 9dd8012

Please sign in to comment.