mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Set default tick marks to min/max for StimPlan model plots (#8221)
Closes #8087
This commit is contained in:
parent
cde2be80a7
commit
3d2409412b
@ -422,6 +422,8 @@ void RicNewStimPlanModelPlotFeature::createParametersTrack( RimStimPlanModelPlot
|
|||||||
plotTrack->setShowRegionLabels( true );
|
plotTrack->setShowRegionLabels( true );
|
||||||
plotTrack->setLogarithmicScale( isPlotLogarithmic );
|
plotTrack->setLogarithmicScale( isPlotLogarithmic );
|
||||||
plotTrack->setAutoScaleXEnabled( true );
|
plotTrack->setAutoScaleXEnabled( true );
|
||||||
|
plotTrack->setMinAndMaxTicksOnly( useMinMaxTicksOnly( propertyTypes[0] ) );
|
||||||
|
|
||||||
plotTrack->updateConnectedEditors();
|
plotTrack->updateConnectedEditors();
|
||||||
plot->updateConnectedEditors();
|
plot->updateConnectedEditors();
|
||||||
|
|
||||||
@ -627,3 +629,18 @@ RimPlot::RowOrColSpan RicNewStimPlanModelPlotFeature::defaultColSpan( RiaDefines
|
|||||||
|
|
||||||
return RimPlot::ONE;
|
return RimPlot::ONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RicNewStimPlanModelPlotFeature::useMinMaxTicksOnly( RiaDefines::CurveProperty property )
|
||||||
|
{
|
||||||
|
std::set<RiaDefines::CurveProperty> useMajorAndMinorTickmarks = { RiaDefines::CurveProperty::STRESS,
|
||||||
|
RiaDefines::CurveProperty::INITIAL_STRESS,
|
||||||
|
RiaDefines::CurveProperty::PRESSURE,
|
||||||
|
RiaDefines::CurveProperty::INITIAL_PRESSURE };
|
||||||
|
|
||||||
|
if ( useMajorAndMinorTickmarks.count( property ) ) return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@ -76,4 +76,5 @@ private:
|
|||||||
static RimPlotCurveAppearance::FillStyle defaultFillStyle( RiaDefines::CurveProperty property );
|
static RimPlotCurveAppearance::FillStyle defaultFillStyle( RiaDefines::CurveProperty property );
|
||||||
static RiuQwtPlotCurveDefines::LineStyleEnum defaultLineStyle( RiaDefines::CurveProperty property );
|
static RiuQwtPlotCurveDefines::LineStyleEnum defaultLineStyle( RiaDefines::CurveProperty property );
|
||||||
static RimPlot::RowOrColSpan defaultColSpan( RiaDefines::CurveProperty property );
|
static RimPlot::RowOrColSpan defaultColSpan( RiaDefines::CurveProperty property );
|
||||||
|
static bool useMinMaxTicksOnly( RiaDefines::CurveProperty property );
|
||||||
};
|
};
|
||||||
|
@ -202,6 +202,7 @@ RimWellLogTrack::RimWellLogTrack()
|
|||||||
CAF_PDM_InitFieldNoDefault( &m_xAxisGridVisibility, "ShowXGridLines", "Show Grid Lines", "", "", "" );
|
CAF_PDM_InitFieldNoDefault( &m_xAxisGridVisibility, "ShowXGridLines", "Show Grid Lines", "", "", "" );
|
||||||
|
|
||||||
CAF_PDM_InitField( &m_explicitTickIntervals, "ExplicitTickIntervals", false, "Manually Set Tick Intervals", "", "", "" );
|
CAF_PDM_InitField( &m_explicitTickIntervals, "ExplicitTickIntervals", false, "Manually Set Tick Intervals", "", "", "" );
|
||||||
|
CAF_PDM_InitField( &m_minAndMaxTicksOnly, "MinAndMaxTicksOnly", false, "Show Ticks at Min and Max", "", "", "" );
|
||||||
CAF_PDM_InitField( &m_majorTickInterval, "MajorTickIntervals", 0.0, "Major Tick Interval", "", "", "" );
|
CAF_PDM_InitField( &m_majorTickInterval, "MajorTickIntervals", 0.0, "Major Tick Interval", "", "", "" );
|
||||||
CAF_PDM_InitField( &m_minorTickInterval, "MinorTickIntervals", 0.0, "Minor Tick Interval", "", "", "" );
|
CAF_PDM_InitField( &m_minorTickInterval, "MinorTickIntervals", 0.0, "Minor Tick Interval", "", "", "" );
|
||||||
m_majorTickInterval.uiCapability()->setUiHidden( true );
|
m_majorTickInterval.uiCapability()->setUiHidden( true );
|
||||||
@ -560,7 +561,7 @@ void RimWellLogTrack::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( changedField == &m_xAxisGridVisibility || changedField == &m_majorTickInterval ||
|
else if ( changedField == &m_xAxisGridVisibility || changedField == &m_majorTickInterval ||
|
||||||
changedField == &m_minorTickInterval )
|
changedField == &m_minorTickInterval || changedField == &m_minAndMaxTicksOnly )
|
||||||
{
|
{
|
||||||
updateXAxisAndGridTickIntervals();
|
updateXAxisAndGridTickIntervals();
|
||||||
}
|
}
|
||||||
@ -778,7 +779,43 @@ void RimWellLogTrack::updateXAxisAndGridTickIntervals()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_plotWidget->setAxisLabelsAndTicksEnabled( QwtPlot::xTop, true, true );
|
m_plotWidget->setAxisLabelsAndTicksEnabled( QwtPlot::xTop, true, true );
|
||||||
if ( m_explicitTickIntervals )
|
if ( m_minAndMaxTicksOnly )
|
||||||
|
{
|
||||||
|
auto roundToDigits = []( double value, int numberOfDigits, bool useFloor ) {
|
||||||
|
if ( value == 0.0 ) return 0.0;
|
||||||
|
|
||||||
|
double factor = std::pow( 10.0, numberOfDigits - std::ceil( std::log10( std::fabs( value ) ) ) );
|
||||||
|
|
||||||
|
if ( useFloor )
|
||||||
|
{
|
||||||
|
// Use floor for maximum value to ensure we get a value inside the complete range
|
||||||
|
return std::floor( value * factor ) / factor;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use ceil for minimum value to ensure we get a value inside the complete range
|
||||||
|
return std::ceil( value * factor ) / factor;
|
||||||
|
};
|
||||||
|
|
||||||
|
auto div = QwtScaleDiv( m_visibleXRangeMin(), m_visibleXRangeMax() );
|
||||||
|
|
||||||
|
QList<double> majorTicks;
|
||||||
|
|
||||||
|
auto min = roundToDigits( m_visibleXRangeMin(), 2, false );
|
||||||
|
auto max = roundToDigits( m_visibleXRangeMax(), 2, true );
|
||||||
|
if ( min == max )
|
||||||
|
{
|
||||||
|
min = roundToDigits( m_visibleXRangeMin(), 3, false );
|
||||||
|
max = roundToDigits( m_visibleXRangeMax(), 3, true );
|
||||||
|
}
|
||||||
|
|
||||||
|
majorTicks.push_back( min );
|
||||||
|
majorTicks.push_back( max );
|
||||||
|
|
||||||
|
div.setTicks( QwtScaleDiv::TickType::MajorTick, majorTicks );
|
||||||
|
|
||||||
|
m_plotWidget->setAxisScaleDiv( QwtPlot::xTop, div );
|
||||||
|
}
|
||||||
|
else if ( m_explicitTickIntervals )
|
||||||
{
|
{
|
||||||
m_plotWidget->setMajorAndMinorTickIntervals( QwtPlot::xTop,
|
m_plotWidget->setMajorAndMinorTickIntervals( QwtPlot::xTop,
|
||||||
m_majorTickInterval(),
|
m_majorTickInterval(),
|
||||||
@ -1587,6 +1624,14 @@ void RimWellLogTrack::setTickIntervals( double majorTickInterval, double minorTi
|
|||||||
m_minorTickInterval = minorTickInterval;
|
m_minorTickInterval = minorTickInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RimWellLogTrack::setMinAndMaxTicksOnly( bool enable )
|
||||||
|
{
|
||||||
|
m_minAndMaxTicksOnly = enable;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -2195,12 +2240,13 @@ void RimWellLogTrack::uiOrderingForXAxisSettings( caf::PdmUiOrdering& uiOrdering
|
|||||||
gridGroup->add( &m_visibleXRangeMin );
|
gridGroup->add( &m_visibleXRangeMin );
|
||||||
gridGroup->add( &m_visibleXRangeMax );
|
gridGroup->add( &m_visibleXRangeMax );
|
||||||
gridGroup->add( &m_xAxisGridVisibility );
|
gridGroup->add( &m_xAxisGridVisibility );
|
||||||
|
gridGroup->add( &m_minAndMaxTicksOnly );
|
||||||
|
|
||||||
// TODO Revisit if these settings are required
|
// TODO Revisit if these settings are required
|
||||||
// See issue https://github.com/OPM/ResInsight/issues/4367
|
// See issue https://github.com/OPM/ResInsight/issues/4367
|
||||||
// gridGroup->add(&m_explicitTickIntervals);
|
// gridGroup->add( &m_explicitTickIntervals );
|
||||||
// gridGroup->add(&m_majorTickInterval);
|
// gridGroup->add( &m_majorTickInterval );
|
||||||
// gridGroup->add(&m_minorTickInterval);
|
// gridGroup->add( &m_minorTickInterval );
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -162,6 +162,7 @@ public:
|
|||||||
void updateEditors();
|
void updateEditors();
|
||||||
|
|
||||||
void setTickIntervals( double majorTickInterval, double minorTickInterval );
|
void setTickIntervals( double majorTickInterval, double minorTickInterval );
|
||||||
|
void setMinAndMaxTicksOnly( bool enable );
|
||||||
void setXAxisGridVisibility( RimWellLogPlot::AxisGridVisibility gridLines );
|
void setXAxisGridVisibility( RimWellLogPlot::AxisGridVisibility gridLines );
|
||||||
|
|
||||||
void setAnnotationType( RiuPlotAnnotationTool::RegionAnnotationType annotationType );
|
void setAnnotationType( RiuPlotAnnotationTool::RegionAnnotationType annotationType );
|
||||||
@ -319,9 +320,11 @@ private:
|
|||||||
caf::PdmField<bool> m_isAutoScaleXEnabled;
|
caf::PdmField<bool> m_isAutoScaleXEnabled;
|
||||||
caf::PdmField<bool> m_isLogarithmicScaleEnabled;
|
caf::PdmField<bool> m_isLogarithmicScaleEnabled;
|
||||||
caf::PdmField<RimWellLogPlot::AxisGridEnum> m_xAxisGridVisibility;
|
caf::PdmField<RimWellLogPlot::AxisGridEnum> m_xAxisGridVisibility;
|
||||||
caf::PdmField<bool> m_explicitTickIntervals;
|
|
||||||
caf::PdmField<double> m_majorTickInterval;
|
caf::PdmField<bool> m_explicitTickIntervals;
|
||||||
caf::PdmField<double> m_minorTickInterval;
|
caf::PdmField<bool> m_minAndMaxTicksOnly;
|
||||||
|
caf::PdmField<double> m_majorTickInterval;
|
||||||
|
caf::PdmField<double> m_minorTickInterval;
|
||||||
|
|
||||||
caf::PdmField<caf::FontTools::RelativeSizeEnum> m_axisFontSize;
|
caf::PdmField<caf::FontTools::RelativeSizeEnum> m_axisFontSize;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user