diff --git a/ApplicationLibCode/ProjectDataModel/Histogram/RimHistogramCurve.cpp b/ApplicationLibCode/ProjectDataModel/Histogram/RimHistogramCurve.cpp index 8f3acd71c0..160d505fb2 100644 --- a/ApplicationLibCode/ProjectDataModel/Histogram/RimHistogramCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/Histogram/RimHistogramCurve.cpp @@ -54,7 +54,10 @@ RimHistogramCurve::RimHistogramCurve() CAF_PDM_InitFieldNoDefault( &m_dataSource, "DataSource", "Data Source" ); m_dataSource.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitField( &m_showPercentiles, "ShowPercentiles", true, "Show P10, Mean, and P90" ); + CAF_PDM_InitField( &m_showP10Curve, "ShowP10Curve", true, "P10" ); + CAF_PDM_InitField( &m_showP90Curve, "ShowP90Curve", true, "P90" ); + CAF_PDM_InitField( &m_showMeanCurve, "ShowMeanCurve", true, "Mean" ); + CAF_PDM_InitField( &m_showValue, "ShowValue", true, "Show Value" ); setSymbolSkipDistance( 10.0f ); setLineThickness( 2 ); @@ -260,27 +263,35 @@ void RimHistogramCurve::onLoadDataAndUpdate( bool updateParentPlot ) QColor color = RiaColorTools::toQColor( m_curveAppearance->color() ); if ( plot->plotWidget() ) { - if ( m_showPercentiles() ) + QwtPlot* qwtPlot = dynamic_cast( plot->plotWidget() )->qwtPlot(); + + auto makeCurveName = []( const QString& pType, const QString& valueName, double value, bool showValue ) -> QString { - QwtPlot* qwtPlot = dynamic_cast( plot->plotWidget() )->qwtPlot(); + QString prefix = " "; + QString str = QString( "%1%2: %3" ).arg( prefix ).arg( pType ).arg( valueName ); + if ( showValue ) + return str + QString( " (%1)" ).arg( value ); + else + return str; + }; - QString autoName = createCurveAutoName(); - std::map percentiles = { { QString( "P10: %1" ).arg( autoName ), result.p10 }, - { QString( "Mean: %1" ).arg( autoName ), result.mean }, - { QString( "P90: %1" ).arg( autoName ), result.p90 } }; + QString autoName = createCurveAutoName(); + std::map percentiles; + if ( m_showP10Curve ) percentiles[makeCurveName( "P10", autoName, result.p10, m_showValue() )] = result.p10; + if ( m_showP90Curve ) percentiles[makeCurveName( "P90", autoName, result.p90, m_showValue() )] = result.p90; + if ( m_showMeanCurve ) percentiles[makeCurveName( "Mean", autoName, result.mean, m_showValue() )] = result.mean; - for ( const auto& [name, value] : percentiles ) + for ( const auto& [name, value] : percentiles ) + { + if ( !std::isinf( value ) ) { - if ( !std::isinf( value ) ) - { - m_annotationTool->attachAnnotationLine( qwtPlot, - color, - name, - Qt::PenStyle::DashDotDotLine, - value, - RiaDefines::Orientation::VERTICAL, - Qt::AlignmentFlag::AlignCenter ); - } + m_annotationTool->attachAnnotationLine( qwtPlot, + color, + name, + Qt::PenStyle::DashDotDotLine, + value, + RiaDefines::Orientation::VERTICAL, + Qt::AlignmentFlag::AlignCenter ); } } } @@ -345,7 +356,11 @@ void RimHistogramCurve::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderi nameGroup->add( &m_showLegend ); RimPlotCurve::curveNameUiOrdering( *nameGroup ); - uiOrdering.add( &m_showPercentiles ); + auto group = uiOrdering.addNewGroup( "Statistics" ); + group->add( &m_showP90Curve ); + group->add( &m_showMeanCurve ); + group->add( &m_showP10Curve ); + group->add( &m_showValue ); uiOrdering.skipRemainingFields(); } @@ -386,7 +401,8 @@ void RimHistogramCurve::fieldChangedByUi( const caf::PdmFieldHandle* changedFiel plot->updateAxes(); dataChanged.send(); } - else if ( changedField == &m_showPercentiles ) + else if ( changedField == &m_showP10Curve || changedField == &m_showMeanCurve || changedField == &m_showP90Curve || + changedField == &m_showValue ) { loadAndUpdate = true; } diff --git a/ApplicationLibCode/ProjectDataModel/Histogram/RimHistogramCurve.h b/ApplicationLibCode/ProjectDataModel/Histogram/RimHistogramCurve.h index fc2423b0be..6f73c2196f 100644 --- a/ApplicationLibCode/ProjectDataModel/Histogram/RimHistogramCurve.h +++ b/ApplicationLibCode/ProjectDataModel/Histogram/RimHistogramCurve.h @@ -88,7 +88,10 @@ private: caf::PdmChildField m_dataSource; - caf::PdmField m_showPercentiles; + caf::PdmField m_showP10Curve; + caf::PdmField m_showP90Curve; + caf::PdmField m_showMeanCurve; + caf::PdmField m_showValue; std::unique_ptr m_annotationTool; };