Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void RicViewZoomAllFeature::onActionTriggered( bool isChecked )
{
if ( auto activePlotView = plotMainWin->activeViewer() )
{
activePlotView->zoomAll();
activePlotView->zoomAllAndReleaseUserDefinedRanges();
}
}
}
Expand Down
20 changes: 15 additions & 5 deletions ApplicationLibCode/ProjectDataModel/RimPlotAxisProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,14 +586,14 @@ double RimPlotAxisProperties::visibleRangeMax() const
//--------------------------------------------------------------------------------------------------
void RimPlotAxisProperties::enableAutoValueMinMax( bool enable )
{
// Never replace a range defined by the user by an automatically computed range
const bool useAutoValue = enable && !isRangeUserDefined();

m_visibleRangeMin.uiCapability()->enableAutoValueSupport( enable );
m_visibleRangeMax.uiCapability()->enableAutoValueSupport( enable );

if ( enable )
{
m_visibleRangeMin.uiCapability()->enableAutoValue( enable );
m_visibleRangeMax.uiCapability()->enableAutoValue( enable );
}
m_visibleRangeMin.uiCapability()->enableAutoValue( useAutoValue );
m_visibleRangeMax.uiCapability()->enableAutoValue( useAutoValue );
}

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -711,12 +711,22 @@ void RimPlotAxisProperties::fieldChangedByUi( const caf::PdmFieldHandle* changed
if ( m_visibleRangeMin > m_visibleRangeMax ) m_visibleRangeMax = oldValue.toDouble();

m_isAutoZoom = false;

// The range is defined by the user unless the value comes from the auto value of the field
setRangeUserDefined( !m_visibleRangeMax.uiCapability()->isAutoValueEnabled() );
}
else if ( changedField == &m_visibleRangeMin )
{
if ( m_visibleRangeMin > m_visibleRangeMax ) m_visibleRangeMin = oldValue.toDouble();

m_isAutoZoom = false;

// The range is defined by the user unless the value comes from the auto value of the field
setRangeUserDefined( !m_visibleRangeMin.uiCapability()->isAutoValueEnabled() );
}
else if ( changedField == &m_isAutoZoom )
{
setRangeUserDefined( !m_isAutoZoom() );
}

if ( changedField == &m_isLogarithmicScaleEnabled )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,26 @@ RimPlotAxisPropertiesInterface::RimPlotAxisPropertiesInterface()
: settingsChanged( this )
{
CAF_PDM_InitObject( "Plot Axis Properties Interface" );

CAF_PDM_InitField( &m_isRangeUserDefined, "IsRangeUserDefined", false, "Is Range Defined by User" );
m_isRangeUserDefined.uiCapability()->setUiHidden( true );
}

//--------------------------------------------------------------------------------------------------
/// A user defined axis range is kept when the data source of a plot is changed, and is released when the user asks for
/// automatic range computation (Zoom All or "Set Range Automatically").
//--------------------------------------------------------------------------------------------------
bool RimPlotAxisPropertiesInterface::isRangeUserDefined() const
{
return m_isRangeUserDefined();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotAxisPropertiesInterface::setRangeUserDefined( bool isUserDefined )
{
m_isRangeUserDefined = isUserDefined;
}

//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ class RimPlotAxisPropertiesInterface : public caf::PdmObject
virtual bool isAutoZoom() const = 0;
virtual void setAutoZoom( bool enableAutoZoom ) = 0;

bool isRangeUserDefined() const;
void setRangeUserDefined( bool isUserDefined );

virtual bool isActive() const = 0;

virtual const QString objectName() const = 0;
Expand All @@ -83,4 +86,7 @@ class RimPlotAxisPropertiesInterface : public caf::PdmObject
virtual AxisTitlePositionType titlePosition() const = 0;
virtual int titleFontSize() const = 0;
virtual int valuesFontSize() const = 0;

private:
caf::PdmField<bool> m_isRangeUserDefined;
};
8 changes: 8 additions & 0 deletions ApplicationLibCode/ProjectDataModel/RimViewWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,14 @@ QImage RimViewWindow::snapshotWindowContent()
return image;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimViewWindow::zoomAllAndReleaseUserDefinedRanges()
{
zoomAll();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions ApplicationLibCode/ProjectDataModel/RimViewWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ class RimViewWindow : public caf::PdmObject, public caf::FontHolderInterface
virtual QImage snapshotWindowContent();
virtual void zoomAll() = 0;

// Zoom all triggered explicitly by the user. This will also release any axis ranges defined by the user.
virtual void zoomAllAndReleaseUserDefinedRanges();

void viewNavigationChanged();

virtual void updateWindowTitle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,15 @@ void RimSummaryMultiPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedFi
}
else if ( changedField == &m_axisRangeAggregation )
{
// The user has asked for a new computation of the Y axis range, release any user defined ranges
for ( auto p : summaryPlots() )
{
for ( auto axis : p->plotAxes( RimPlotAxisProperties::Orientation::VERTICAL ) )
{
axis->setRangeUserDefined( false );
}
}

setAutoValueStates();
syncAxisRanges();
analyzePlotsAndAdjustAppearanceSettings();
Expand Down Expand Up @@ -798,6 +807,19 @@ void RimSummaryMultiPlot::zoomAll()
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryMultiPlot::zoomAllAndReleaseUserDefinedRanges()
{
for ( auto p : summaryPlots() )
{
p->releaseUserDefinedAxisRanges();
}

zoomAll();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class RimSummaryMultiPlot : public RimMultiPlot, public RimSummaryDataSourceStep
std::pair<int, int> gridLayoutInfoForSubPlot( RimSummaryPlot* summaryPlot ) const;

void zoomAll() override;
void zoomAllAndReleaseUserDefinedRanges() override;

void setDefaultRangeAggregationSteppingDimension();
void analyzePlotsAndAdjustAppearanceSettings();
Expand Down
35 changes: 34 additions & 1 deletion ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1404,6 +1404,28 @@ void RimSummaryPlot::zoomAll()
axisChanged.send( this );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::zoomAllAndReleaseUserDefinedRanges()
{
releaseUserDefinedAxisRanges();

zoomAll();
}

//--------------------------------------------------------------------------------------------------
/// Axis ranges defined by the user are kept when the data source of the plot is changed. Release the user defined
/// ranges to make the axes follow the data again.
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::releaseUserDefinedAxisRanges()
{
for ( const auto& ap : m_axisPropertiesArray )
{
ap->setRangeUserDefined( false );
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -1602,7 +1624,7 @@ void RimSummaryPlot::zoomAllForMultiPlot()
{
if ( auto multiPlot = firstAncestorOrThisOfType<RimMultiPlot>() )
{
multiPlot->zoomAll();
multiPlot->zoomAllAndReleaseUserDefinedRanges();
}
}

Expand Down Expand Up @@ -2628,6 +2650,13 @@ void RimSummaryPlot::onPlotZoomed()
setAutoScaleXEnabled( false );
setAutoScaleYEnabled( false );

// The user has defined the visible range by interactive zoom, and the range is kept when the data source of the
// plot is changed
for ( const auto& ap : m_axisPropertiesArray )
{
ap->setRangeUserDefined( true );
}

// Disable auto value for min/max fields
for ( auto p : plotAxes( RimPlotAxisProperties::Orientation::ANY ) )
{
Expand Down Expand Up @@ -2998,6 +3027,8 @@ void RimSummaryPlot::setAutoScaleXEnabled( bool enabled )
{
if ( ap->plotAxis().axis() == RiaDefines::PlotAxis::PLOT_AXIS_TOP || ap->plotAxis().axis() == RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM )
{
if ( enabled && ap->isRangeUserDefined() ) continue;

ap->setAutoZoom( enabled );
}
}
Expand All @@ -3012,6 +3043,8 @@ void RimSummaryPlot::setAutoScaleYEnabled( bool enabled )
{
if ( ap->plotAxis().axis() == RiaDefines::PlotAxis::PLOT_AXIS_LEFT || ap->plotAxis().axis() == RiaDefines::PlotAxis::PLOT_AXIS_RIGHT )
{
if ( enabled && ap->isRangeUserDefined() ) continue;

ap->setAutoZoom( enabled );
}
}
Expand Down
2 changes: 2 additions & 0 deletions ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ class RimSummaryPlot : public RimPlot, public RimSummaryDataSourceStepping, publ
RiuPlotWidget* plotWidget() override;
RiuSummaryPlot* summaryPlotWidget() const;
void zoomAll() override;
void zoomAllAndReleaseUserDefinedRanges() override;
void releaseUserDefinedAxisRanges();
void updatePlotWidgetFromAxisRanges() override;
void updateAxisRangesFromPlotWidget() override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,7 @@ void RimSummaryTimeAxisProperties::fieldChangedByUi( const caf::PdmFieldHandle*

updateTimeVisibleRange();
m_isAutoZoom = false;
setRangeUserDefined( true );
}
else if ( changedField == &m_visibleTimeRangeMax )
{
Expand All @@ -943,6 +944,7 @@ void RimSummaryTimeAxisProperties::fieldChangedByUi( const caf::PdmFieldHandle*

updateTimeVisibleRange();
m_isAutoZoom = false;
setRangeUserDefined( true );
}
else if ( changedField == &m_visibleDateRangeMin )
{
Expand All @@ -954,6 +956,7 @@ void RimSummaryTimeAxisProperties::fieldChangedByUi( const caf::PdmFieldHandle*

updateTimeVisibleRange();
m_isAutoZoom = false;
setRangeUserDefined( true );
}
else if ( changedField == &m_visibleTimeRangeMin )
{
Expand All @@ -965,11 +968,17 @@ void RimSummaryTimeAxisProperties::fieldChangedByUi( const caf::PdmFieldHandle*

updateTimeVisibleRange();
m_isAutoZoom = false;
setRangeUserDefined( true );
}
else if ( changedField == &m_visibleTimeSinceStartRangeMin || changedField == &m_visibleTimeSinceStartRangeMax )
{
updateDateVisibleRange();
m_isAutoZoom = false;
setRangeUserDefined( true );
}
else if ( changedField == &m_isAutoZoom )
{
setRangeUserDefined( !m_isAutoZoom() );
}
else if ( changedField == &m_timeMode )
{
Expand Down