diff --git a/ApplicationLibCode/ProjectDataModel/RimPlotAxisProperties.h b/ApplicationLibCode/ProjectDataModel/RimPlotAxisProperties.h index dc9acacd7a6..bfde0844d81 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPlotAxisProperties.h +++ b/ApplicationLibCode/ProjectDataModel/RimPlotAxisProperties.h @@ -50,6 +50,13 @@ class RimPlotAxisProperties : public RimPlotAxisPropertiesInterface NUMBER_FORMAT_SCIENTIFIC }; + enum class Orientation + { + HORIZONTAL, + VERTICAL, + ANY + }; + public: caf::Signal logarithmicChanged; caf::Signal axisPositionChanged; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 5aacf58197a..71501f8d823 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -147,6 +147,7 @@ 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 ); @@ -203,7 +204,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(); @@ -853,7 +854,7 @@ void RimEnsembleCurveSet::fieldChangedByUi( const caf::PdmFieldHandle* changedFi updateCurveColors(); updateTimeAnnotations(); } - else if ( changedField == &m_plotAxisProperties ) + else if ( changedField == &m_yPlotAxisProperties ) { for ( RimSummaryCurve* curve : curves() ) { @@ -1000,7 +1001,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 ); } { @@ -1431,10 +1432,10 @@ QList RimEnsembleCurveSet::calculateValueOptions( const options.push_back( caf::PdmOptionItemInfo( name, objFunc ) ); } } - else if ( fieldNeedingOptions == &m_plotAxisProperties ) + else if ( fieldNeedingOptions == &m_yPlotAxisProperties ) { auto plot = firstAncestorOrThisOfTypeAsserted(); - for ( auto axis : plot->plotAxes() ) + for ( auto axis : plot->plotAxes( RimPlotAxisProperties::Orientation::VERTICAL ) ) { options.push_back( caf::PdmOptionItemInfo( axis->objectName(), axis ) ); } @@ -2391,8 +2392,8 @@ 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(); } @@ -2402,8 +2403,8 @@ RiuPlotAxis RimEnsembleCurveSet::axisY() const //-------------------------------------------------------------------------------------------------- void RimEnsembleCurveSet::setLeftOrRightAxisY( RiuPlotAxis plotAxis ) { - auto plot = firstAncestorOrThisOfTypeAsserted(); - m_plotAxisProperties = plot->axisPropertiesForPlotAxis( plotAxis ); + auto plot = firstAncestorOrThisOfTypeAsserted(); + m_yPlotAxisProperties = plot->axisPropertiesForPlotAxis( plotAxis ); for ( RimSummaryCurve* curve : curves() ) { @@ -2416,12 +2417,12 @@ void RimEnsembleCurveSet::setLeftOrRightAxisY( RiuPlotAxis plotAxis ) //-------------------------------------------------------------------------------------------------- void RimEnsembleCurveSet::initAfterRead() { - if ( m_plotAxisProperties.value() == nullptr ) + if ( m_yPlotAxisProperties.value() == nullptr ) { auto plot = firstAncestorOrThisOfType(); if ( plot ) { - m_plotAxisProperties = plot->axisPropertiesForPlotAxis( RiuPlotAxis( m_plotAxis_OBSOLETE() ) ); + m_yPlotAxisProperties = plot->axisPropertiesForPlotAxis( RiuPlotAxis( m_plotAxis_OBSOLETE() ) ); } } } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h index ce41861608a..8fd4823bed9 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h @@ -261,7 +261,7 @@ class RimEnsembleCurveSet : public caf::PdmObject, public RimEnsembleCurveSetInt caf::PdmField> m_selectedTimeSteps; caf::PdmField> m_plotAxis_OBSOLETE; - caf::PdmPtrField m_plotAxisProperties; + caf::PdmPtrField m_yPlotAxisProperties; caf::PdmChildField m_legendConfig; caf::PdmChildField m_curveFilters; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.cpp index c4e5a10cf7f..e4a683877be 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.cpp @@ -72,8 +72,9 @@ RimSummaryAddressSelector::RimSummaryAddressSelector() CAF_PDM_InitFieldNoDefault( &m_resamplingPeriod, "Resampling", "Resampling" ); - m_dataSource = SummaryDataSource::SINGLE_CASE; - m_showDataSource = true; + m_dataSource = SummaryDataSource::SINGLE_CASE; + m_showDataSource = true; + m_plotAxisOrientation = RimPlotAxisProperties::Orientation::ANY; } //-------------------------------------------------------------------------------------------------- @@ -126,6 +127,14 @@ void RimSummaryAddressSelector::setShowDataSource( bool enable ) m_showDataSource = enable; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryAddressSelector::setAxisOrientation( RimPlotAxisProperties::Orientation orientation ) +{ + m_plotAxisOrientation = orientation; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -304,7 +313,7 @@ QList RimSummaryAddressSelector::calculateValueOptions( if ( auto plot = firstAncestorOrThisOfTypeAsserted() ) { QList options; - for ( auto axis : plot->plotAxes() ) + for ( auto axis : plot->plotAxes( m_plotAxisOrientation ) ) { options.push_back( caf::PdmOptionItemInfo( axis->objectName(), axis ) ); } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.h index e3270471a8f..b6edcd8dec6 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.h @@ -55,6 +55,7 @@ class RimSummaryAddressSelector : public caf::PdmObject void setResamplingPeriod( RiaDefines::DateTimePeriodEnum resampling ); void setPlotAxisProperties( RimPlotAxisPropertiesInterface* plotAxisProperties ); void setShowDataSource( bool enable ); + void setAxisOrientation( RimPlotAxisProperties::Orientation orientation ); RimSummaryCase* summaryCase() const; RimSummaryCaseCollection* ensemble() const; @@ -79,4 +80,6 @@ class RimSummaryAddressSelector : public caf::PdmObject SummaryDataSource m_dataSource; bool m_showDataSource; + + RimPlotAxisProperties::Orientation m_plotAxisOrientation; }; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp index 6f7891bd7a1..c7e571195d5 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp @@ -551,20 +551,16 @@ QList RimSummaryCurve::calculateValueOptions( const caf: { auto plot = firstAncestorOrThisOfTypeAsserted(); - for ( auto axis : plot->plotAxes() ) + for ( auto axis : plot->plotAxes( RimPlotAxisProperties::Orientation::VERTICAL ) ) { - // TODO: Should we allow time axis to be used as Y axis? - if ( dynamic_cast( axis ) ) - { - options.push_back( caf::PdmOptionItemInfo( axis->objectName(), axis ) ); - } + options.push_back( caf::PdmOptionItemInfo( axis->objectName(), axis ) ); } } else if ( fieldNeedingOptions == &m_xPlotAxisProperties ) { auto plot = firstAncestorOrThisOfTypeAsserted(); - for ( auto axis : plot->plotAxes() ) + for ( auto axis : plot->plotAxes( RimPlotAxisProperties::Orientation::HORIZONTAL ) ) { options.push_back( caf::PdmOptionItemInfo( axis->objectName(), axis ) ); } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.cpp index d3c5ceab670..9007522c4da 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.cpp @@ -864,7 +864,7 @@ void RimSummaryMultiPlot::syncAxisRanges() for ( auto p : summaryPlots() ) { - for ( auto ax : p->plotYAxes() ) + for ( auto ax : p->plotAxes( RimPlotAxisProperties::Orientation::ANY ) ) { ax->setAutoZoomIfNoCustomRangeIsSet(); } @@ -878,7 +878,7 @@ void RimSummaryMultiPlot::syncAxisRanges() // gather current min/max values for each category (axis label) for ( auto plot : summaryPlots() ) { - for ( auto axis : plot->plotYAxes() ) + for ( auto axis : plot->plotAxes( RimPlotAxisProperties::Orientation::ANY ) ) { double minVal = axis->visibleRangeMin(); double maxVal = axis->visibleRangeMax(); @@ -900,7 +900,7 @@ void RimSummaryMultiPlot::syncAxisRanges() // set all plots to use the global min/max values for each category for ( auto plot : summaryPlots() ) { - for ( auto axis : plot->plotYAxes() ) + for ( auto axis : plot->plotAxes( RimPlotAxisProperties::Orientation::ANY ) ) { auto [minVal, maxVal] = axisRanges[axis->objectName()]; if ( axis->isAxisInverted() ) std::swap( minVal, maxVal ); @@ -1080,7 +1080,7 @@ void RimSummaryMultiPlot::computeAggregatedAxisRange() { std::map> axisRanges; - for ( auto axis : plot->plotYAxes() ) + for ( auto axis : plot->plotAxes( RimPlotAxisProperties::Orientation::ANY ) ) { for ( auto curve : plot->summaryCurves() ) { @@ -1146,7 +1146,7 @@ void RimSummaryMultiPlot::computeAggregatedAxisRange() } // set all plots to use the global min/max values for each category - for ( auto axis : plot->plotYAxes() ) + for ( auto axis : plot->plotAxes( RimPlotAxisProperties::Orientation::ANY ) ) { auto [minVal, maxVal] = axisRanges[axis->plotAxis()]; if ( RiaDefines::isVertical( axis->plotAxis().axis() ) && !std::isinf( minVal ) && !std::isinf( maxVal ) ) @@ -1215,7 +1215,7 @@ void RimSummaryMultiPlot::setAutoValueStatesForPlot( RimSummaryPlot* summaryPlot auto timeAxisProp = summaryPlot->timeAxisProperties(); if ( timeAxisProp ) timeAxisProp->enableAutoValueForMajorTickmarkCount( enableAutoValueAppearance ); - for ( auto plotAxis : summaryPlot->plotYAxes() ) + for ( auto plotAxis : summaryPlot->plotAxes( RimPlotAxisProperties::Orientation::ANY ) ) { plotAxis->enableAutoValueMinMax( enableAutoValueMinMax ); plotAxis->enableAutoValueForMajorTickmarkCount( enableAutoValueAppearance ); @@ -1281,10 +1281,8 @@ void RimSummaryMultiPlot::analyzePlotsAndAdjustAppearanceSettings() timeAxisProp->setAutoValueForMajorTickmarkCount( tickMarkCount, notifyFieldChanged ); } - for ( auto* axisProp : p->plotYAxes() ) + for ( auto* axisProp : p->plotAxes( RimPlotAxisProperties::Orientation::ANY ) ) { - if ( !axisProp ) continue; - auto tickMarkCount = ( rowsPerPage() == 1 ) ? RimPlotAxisProperties::LegendTickmarkCount::TICKMARK_DEFAULT : RimPlotAxisProperties::LegendTickmarkCount::TICKMARK_FEW; @@ -1314,10 +1312,8 @@ void RimSummaryMultiPlot::analyzePlotsAndAdjustAppearanceSettings() { for ( auto p : summaryPlots() ) { - for ( auto* axisProp : p->plotYAxes() ) + for ( auto* axisProp : p->plotAxes( RimPlotAxisProperties::Orientation::ANY ) ) { - if ( !axisProp ) continue; - axisProp->computeAndSetAutoValueForScaleFactor(); axisProp->setShowUnitText( true ); axisProp->setShowDescription( true ); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index 66dfb20a8af..15785a25cf0 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -49,7 +49,6 @@ #include "RimGridTimeHistoryCurve.h" #include "RimMultiPlot.h" #include "RimPlotAxisLogRangeCalculator.h" -#include "RimPlotAxisProperties.h" #include "RimProject.h" #include "RimSummaryAddress.h" #include "RimSummaryAddressCollection.h" @@ -621,7 +620,7 @@ const RimSummaryNameHelper* RimSummaryPlot::plotTitleHelper() const //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::copyAxisPropertiesFromOther( const RimSummaryPlot& sourceSummaryPlot ) { - for ( auto ap : sourceSummaryPlot.plotAxes() ) + for ( auto ap : sourceSummaryPlot.allPlotAxes() ) { QString data = ap->writeObjectToXmlString(); @@ -638,7 +637,7 @@ void RimSummaryPlot::copyAxisPropertiesFromOther( const RimSummaryPlot& sourceSu //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::copyAxisPropertiesFromOther( RiaDefines::PlotAxis plotAxisType, const RimSummaryPlot& sourceSummaryPlot ) { - for ( auto ap : sourceSummaryPlot.plotAxes() ) + for ( auto ap : sourceSummaryPlot.allPlotAxes() ) { if ( ap->plotAxis().axis() != plotAxisType ) continue; @@ -657,9 +656,9 @@ void RimSummaryPlot::copyAxisPropertiesFromOther( RiaDefines::PlotAxis plotAxisT //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::copyMatchingAxisPropertiesFromOther( const RimSummaryPlot& summaryPlot ) { - for ( auto apToCopy : summaryPlot.plotAxes() ) + for ( auto apToCopy : summaryPlot.allPlotAxes() ) { - for ( auto ap : plotAxes() ) + for ( auto ap : allPlotAxes() ) { if ( ap->objectName().compare( apToCopy->objectName() ) == 0 ) { @@ -2659,7 +2658,7 @@ void RimSummaryPlot::onPlotZoomed() setAutoScaleYEnabled( false ); // Disable auto value for min/max fields - for ( auto p : plotYAxes() ) + for ( auto p : plotAxes( RimPlotAxisProperties::Orientation::ANY ) ) { p->enableAutoValueMinMax( false ); } @@ -3106,27 +3105,29 @@ bool RimSummaryPlot::isDeletable() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimSummaryPlot::plotAxes() const +std::vector RimSummaryPlot::allPlotAxes() const { - std::vector axisProps; - for ( const auto& ap : m_axisPropertiesArray ) - { - axisProps.push_back( ap ); - } - - return axisProps; + return m_axisPropertiesArray.childrenByType(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimSummaryPlot::plotYAxes() const +std::vector RimSummaryPlot::plotAxes( RimPlotAxisProperties::Orientation orientation ) const { std::vector axisProps; for ( const auto& ap : m_axisPropertiesArray ) { auto plotAxisProp = dynamic_cast( ap.p() ); - if ( plotAxisProp && plotAxisProp->plotAxis().isVertical() ) + if ( !plotAxisProp ) continue; + + if ( ( orientation == RimPlotAxisProperties::Orientation::ANY ) || + ( orientation == RimPlotAxisProperties::Orientation::VERTICAL && plotAxisProp->plotAxis().isVertical() ) ) + { + axisProps.push_back( plotAxisProp ); + } + else if ( ( orientation == RimPlotAxisProperties::Orientation::ANY ) || + ( orientation == RimPlotAxisProperties::Orientation::HORIZONTAL && plotAxisProp->plotAxis().isHorizontal() ) ) { axisProps.push_back( plotAxisProp ); } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.h index 007e1273621..94094106ce2 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.h @@ -22,6 +22,7 @@ #include "RiaPlotDefines.h" #include "RimPlot.h" +#include "RimPlotAxisProperties.h" #include "RimSummaryDataSourceStepping.h" #include "RiuQwtPlotWidget.h" @@ -201,8 +202,7 @@ class RimSummaryPlot : public RimPlot, public RimSummaryDataSourceStepping std::vector curveSets() const override; std::vector allCurves( RimSummaryDataSourceStepping::Axis axis ) const override; - std::vector plotAxes() const; - std::vector plotYAxes() const; + std::vector plotAxes( RimPlotAxisProperties::Orientation orientation ) const; RimPlotAxisPropertiesInterface* axisPropertiesForPlotAxis( RiuPlotAxis plotAxis ) const; RimPlotAxisProperties* addNewAxisProperties( RiaDefines::PlotAxis, const QString& name ); @@ -293,6 +293,8 @@ private slots: RiuPlotAxis oldPlotAxis, RiuPlotAxis newPlotAxis ); + std::vector allPlotAxes() const; + void timeAxisSettingsChanged( const caf::SignalEmitter* emitter ); void timeAxisSettingsChangedReloadRequired( const caf::SignalEmitter* emitter );