Skip to content

Commit

Permalink
Adjustments related to cross plot curves
Browse files Browse the repository at this point in the history
* Verify vector size only for cross plot regression curves
* Add filtering on axis orientation
Makes it possible to show only horizontal or vertical axes when selecting an axis to attach a curve to.

* Send curvesChanged signal to trigger multi plot updates
This signal will trigger update of axes and set correct scaling factor

* Use object name for axis object
* Use address for both x and y axis to create ensemble curve name
* Fix bug for drag/drop of ensemble object into plot
* Add RiaSummaryCurveAddress to RiaSummaryCurveDefinition
* Remove SummaryDataSource
* Use childFieldChangedByUi to trigger update of curves and titles
  • Loading branch information
magnesj authored Sep 27, 2023
1 parent 2d13cfd commit 1b1984e
Show file tree
Hide file tree
Showing 13 changed files with 258 additions and 126 deletions.
30 changes: 30 additions & 0 deletions ApplicationLibCode/Application/RiaSummaryCurveDefinition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "RiaSummaryCurveDefinition.h"
#include "RiaStdStringTools.h"
#include "RiaSummaryCurveAddress.h"

#include "RifSummaryReaderInterface.h"

Expand Down Expand Up @@ -66,6 +67,19 @@ RiaSummaryCurveDefinition::RiaSummaryCurveDefinition( RimSummaryCaseCollection*
{
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaSummaryCurveDefinition::RiaSummaryCurveDefinition( RimSummaryCaseCollection* ensemble, const RiaSummaryCurveAddress& summaryCurveAddress )
: m_summaryCaseY( nullptr )
, m_summaryAddressY( summaryCurveAddress.summaryAddressY() )
, m_summaryCaseX( nullptr )
, m_summaryAddressX( summaryCurveAddress.summaryAddressX() )
, m_ensemble( ensemble )
, m_isEnsembleCurve( true )
{
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand All @@ -82,6 +96,14 @@ RimSummaryCaseCollection* RiaSummaryCurveDefinition::ensemble() const
return m_ensemble;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaSummaryCurveDefinition::setEnsemble( RimSummaryCaseCollection* ensemble )
{
m_ensemble = ensemble;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -138,6 +160,14 @@ RifEclipseSummaryAddress RiaSummaryCurveDefinition::summaryAddressX() const
return m_summaryAddressX;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaSummaryCurveAddress RiaSummaryCurveDefinition::summaryCurveAddress() const
{
return RiaSummaryCurveAddress( m_summaryAddressX, m_summaryAddressY );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
17 changes: 12 additions & 5 deletions ApplicationLibCode/Application/RiaSummaryCurveDefinition.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

class RimSummaryCase;
class RimSummaryCaseCollection;
class RiaSummaryCurveAddress;

//==================================================================================================
///
Expand All @@ -40,20 +41,26 @@ class RiaSummaryCurveDefinition
RiaSummaryCurveDefinition();
explicit RiaSummaryCurveDefinition( RimSummaryCase* summaryCaseY, const RifEclipseSummaryAddress& summaryAddressY, bool isEnsembleCurve );
explicit RiaSummaryCurveDefinition( RimSummaryCaseCollection* ensemble, const RifEclipseSummaryAddress& summaryAddressY );
explicit RiaSummaryCurveDefinition( RimSummaryCaseCollection* ensemble, const RiaSummaryCurveAddress& summaryCurveAddress );

// Y Axis
RimSummaryCase* summaryCaseY() const;
RifEclipseSummaryAddress summaryAddressY() const;
// X and Y Axis
RimSummaryCaseCollection* ensemble() const;
bool isEnsembleCurve() const;
void setSummaryAddressY( const RifEclipseSummaryAddress& address );
void setEnsemble( RimSummaryCaseCollection* ensemble );

// Y Axis
RimSummaryCase* summaryCaseY() const;
RifEclipseSummaryAddress summaryAddressY() const;
bool isEnsembleCurve() const;
void setSummaryAddressY( const RifEclipseSummaryAddress& address );

// X Axis
void setSummaryCaseX( RimSummaryCase* summaryCase );
void setSummaryAddressX( const RifEclipseSummaryAddress& summaryAddress );
RimSummaryCase* summaryCaseX() const;
RifEclipseSummaryAddress summaryAddressX() const;

RiaSummaryCurveAddress summaryCurveAddress() const;

void setIdentifierText( SummaryCategory category, const std::string& name );

bool operator<( const RiaSummaryCurveDefinition& other ) const;
Expand Down
7 changes: 7 additions & 0 deletions ApplicationLibCode/ProjectDataModel/RimPlotAxisProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ class RimPlotAxisProperties : public RimPlotAxisPropertiesInterface
NUMBER_FORMAT_SCIENTIFIC
};

enum class Orientation
{
HORIZONTAL,
VERTICAL,
ANY
};

public:
caf::Signal<bool> logarithmicChanged;
caf::Signal<RimPlotAxisProperties*, RiuPlotAxis, RiuPlotAxis> axisPositionChanged;
Expand Down
100 changes: 76 additions & 24 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 @@ -147,11 +148,10 @@ RimEnsembleCurveSet::RimEnsembleCurveSet()

CAF_PDM_InitFieldNoDefault( &m_xAddressSelector, "XAddressSelector", "" );
m_xAddressSelector = new RimSummaryAddressSelector;
m_xAddressSelector->setAxisOrientation( RimPlotAxisProperties::Orientation::HORIZONTAL );
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 @@ -203,7 +203,7 @@ RimEnsembleCurveSet::RimEnsembleCurveSet()
CAF_PDM_InitFieldNoDefault( &m_plotAxis_OBSOLETE, "PlotAxis", "Axis" );
m_plotAxis_OBSOLETE.xmlCapability()->setIOWritable( false );

CAF_PDM_InitFieldNoDefault( &m_plotAxisProperties, "Axis", "Axis" );
CAF_PDM_InitFieldNoDefault( &m_yPlotAxisProperties, "Axis", "Axis" );

CAF_PDM_InitFieldNoDefault( &m_legendConfig, "LegendConfig", "" );
m_legendConfig = new RimRegularLegendConfig();
Expand Down Expand Up @@ -425,6 +425,15 @@ void RimEnsembleCurveSet::setCurveAddress( RiaSummaryCurveAddress address )
{
setSummaryAddress( address.summaryAddressY() );
setSummaryAddressX( address.summaryAddressX() );

if ( address.summaryAddressX().category() == SummaryCategory::SUMMARY_TIME )
{
m_xAxisType = RiaDefines::HorizontalAxisType::TIME;
}
else
{
m_xAxisType = RiaDefines::HorizontalAxisType::SUMMARY_VECTOR;
}
}

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -564,6 +573,7 @@ void RimEnsembleCurveSet::onLegendDefinitionChanged()
void RimEnsembleCurveSet::setSummaryCaseCollection( RimSummaryCaseCollection* sumCaseCollection )
{
m_yValuesSummaryCaseCollection = sumCaseCollection;
m_xAddressSelector->setEnsemble( sumCaseCollection );
}

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -853,7 +863,7 @@ void RimEnsembleCurveSet::fieldChangedByUi( const caf::PdmFieldHandle* changedFi
updateCurveColors();
updateTimeAnnotations();
}
else if ( changedField == &m_plotAxisProperties )
else if ( changedField == &m_yPlotAxisProperties )
{
for ( RimSummaryCurve* curve : curves() )
{
Expand Down Expand Up @@ -987,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 All @@ -1000,7 +1037,7 @@ void RimEnsembleCurveSet::defineUiOrdering( QString uiConfigName, caf::PdmUiOrde
curveDataGroup->add( &m_yValuesSummaryAddressUiField );
curveDataGroup->add( &m_yPushButtonSelectSummaryAddress, { false, 1, 0 } );
curveDataGroup->add( &m_resampling );
curveDataGroup->add( &m_plotAxisProperties );
curveDataGroup->add( &m_yPlotAxisProperties );
}

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

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

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -1431,10 +1460,10 @@ QList<caf::PdmOptionItemInfo> RimEnsembleCurveSet::calculateValueOptions( const
options.push_back( caf::PdmOptionItemInfo( name, objFunc ) );
}
}
else if ( fieldNeedingOptions == &m_plotAxisProperties )
else if ( fieldNeedingOptions == &m_yPlotAxisProperties )
{
auto plot = firstAncestorOrThisOfTypeAsserted<RimSummaryPlot>();
for ( auto axis : plot->plotAxes() )
for ( auto axis : plot->plotAxes( RimPlotAxisProperties::Orientation::VERTICAL ) )
{
options.push_back( caf::PdmOptionItemInfo( axis->objectName(), axis ) );
}
Expand Down Expand Up @@ -2331,9 +2360,7 @@ QString RimEnsembleCurveSet::createAutoName() const
{
auto plot = firstAncestorOrThisOfTypeAsserted<RimSummaryPlot>();

QString curveSetName = m_summaryAddressNameTools->curveName( RiaSummaryCurveAddress( m_yValuesSummaryAddress->address() ),
plot->plotTitleHelper(),
plot->plotTitleHelper() );
QString curveSetName = m_summaryAddressNameTools->curveName( curveAddress(), plot->plotTitleHelper(), plot->plotTitleHelper() );

if ( curveSetName.isEmpty() )
{
Expand Down Expand Up @@ -2391,37 +2418,62 @@ int statisticsCurveSymbolSize( RiuPlotCurveSymbol::PointSymbolEnum symbol )
//--------------------------------------------------------------------------------------------------
RiuPlotAxis RimEnsembleCurveSet::axisY() const
{
if ( m_plotAxisProperties )
return m_plotAxisProperties->plotAxis();
if ( m_yPlotAxisProperties )
return m_yPlotAxisProperties->plotAxis();
else
return RiuPlotAxis::defaultLeft();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuPlotAxis RimEnsembleCurveSet::axisX() const
{
if ( m_xAddressSelector->plotAxisProperties() )
return m_xAddressSelector->plotAxisProperties()->plotAxis();
else
return RiuPlotAxis::defaultBottomForSummaryVectors();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEnsembleCurveSet::setLeftOrRightAxisY( RiuPlotAxis plotAxis )
{
auto plot = firstAncestorOrThisOfTypeAsserted<RimSummaryPlot>();
m_plotAxisProperties = plot->axisPropertiesForPlotAxis( plotAxis );
auto plot = firstAncestorOrThisOfTypeAsserted<RimSummaryPlot>();
m_yPlotAxisProperties = plot->axisPropertiesForPlotAxis( plotAxis );

for ( RimSummaryCurve* curve : curves() )
{
curve->setLeftOrRightAxisY( axisY() );
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEnsembleCurveSet::setBottomOrTopAxisX( RiuPlotAxis plotAxis )
{
auto plot = firstAncestorOrThisOfTypeAsserted<RimSummaryPlot>();
m_xAddressSelector->setPlotAxisProperties( plot->axisPropertiesForPlotAxis( plotAxis ) );

for ( RimSummaryCurve* curve : curves() )
{
curve->setTopOrBottomAxisX( axisX() );
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEnsembleCurveSet::initAfterRead()
{
if ( m_plotAxisProperties.value() == nullptr )
if ( m_yPlotAxisProperties.value() == nullptr )
{
auto plot = firstAncestorOrThisOfType<RimSummaryPlot>();
if ( plot )
{
m_plotAxisProperties = plot->axisPropertiesForPlotAxis( RiuPlotAxis( m_plotAxis_OBSOLETE() ) );
m_yPlotAxisProperties = plot->axisPropertiesForPlotAxis( RiuPlotAxis( m_plotAxis_OBSOLETE() ) );
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ class RimEnsembleCurveSet : public caf::PdmObject, public RimEnsembleCurveSetInt
std::vector<cvf::Color3f> generateColorsForCases( const std::vector<RimSummaryCase*>& summaryCases ) const;

RiuPlotAxis axisY() const;
RiuPlotAxis axisX() const;
void setLeftOrRightAxisY( RiuPlotAxis plotAxis );
void setBottomOrTopAxisX( RiuPlotAxis plotAxis );

protected:
void initAfterRead() override;
Expand All @@ -204,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 @@ -219,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 Expand Up @@ -261,7 +263,7 @@ class RimEnsembleCurveSet : public caf::PdmObject, public RimEnsembleCurveSetInt
caf::PdmField<std::vector<QDateTime>> m_selectedTimeSteps;

caf::PdmField<caf::AppEnum<RiaDefines::PlotAxis>> m_plotAxis_OBSOLETE;
caf::PdmPtrField<RimPlotAxisPropertiesInterface*> m_plotAxisProperties;
caf::PdmPtrField<RimPlotAxisPropertiesInterface*> m_yPlotAxisProperties;

caf::PdmChildField<RimRegularLegendConfig*> m_legendConfig;
caf::PdmChildField<RimEnsembleCurveFilterCollection*> m_curveFilters;
Expand Down
Loading

0 comments on commit 1b1984e

Please sign in to comment.