From 40d2aa2dcc4dfd44bc0ee08e88cd7518e0e645e8 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 21 Sep 2023 11:46:27 +0200 Subject: [PATCH] cleanup --- .../RimSummaryRegressionAnalysisCurve.cpp | 28 ++++++++++++------- .../RimSummaryRegressionAnalysisCurve.h | 3 -- .../cafPdmUiValueRangeEditor.cpp | 10 +++---- .../cafPdmUiValueRangeEditor.h | 6 ++-- 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryRegressionAnalysisCurve.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryRegressionAnalysisCurve.cpp index 7838f221a1..5a47421158 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryRegressionAnalysisCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryRegressionAnalysisCurve.cpp @@ -27,6 +27,7 @@ #include "cafPdmUiDateEditor.h" #include "cafPdmUiLineEditor.h" +#include "cafPdmUiSliderEditor.h" #include "cafPdmUiSliderTools.h" #include "cafPdmUiTextEditor.h" @@ -95,12 +96,11 @@ RimSummaryRegressionAnalysisCurve::RimSummaryRegressionAnalysisCurve() m_expressionText.uiCapability()->setUiReadOnly( true ); m_expressionText.xmlCapability()->disableIO(); - CAF_PDM_InitField( &m_filterValuesX, "FilterValuesX", false, "Filter X" ); CAF_PDM_InitField( &m_valueRangeX, "ValueRangeX", std::make_pair( 0.0, 0.0 ), "Value Range X" ); m_valueRangeX.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); - CAF_PDM_InitField( &m_filterValuesY, "FilterValuesY", false, "Filter Y" ); CAF_PDM_InitField( &m_valueRangeY, "ValueRangeY", std::make_pair( 0.0, 0.0 ), "Value Range Y" ); + m_valueRangeY.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); } //-------------------------------------------------------------------------------------------------- @@ -125,7 +125,6 @@ void RimSummaryRegressionAnalysisCurve::onLoadDataAndUpdate( bool updateParentPl auto yValues = RimSummaryCurve::valuesY(); auto timeStepsY = RimSummaryCurve::timeStepsY(); - if ( m_filterValuesX ) { auto values = xValues; for ( size_t i = 0; i < values.size(); i++ ) @@ -137,7 +136,6 @@ void RimSummaryRegressionAnalysisCurve::onLoadDataAndUpdate( bool updateParentPl } } - if ( m_filterValuesY ) { auto values = yValues; for ( size_t i = 0; i < values.size(); i++ ) @@ -316,13 +314,11 @@ void RimSummaryRegressionAnalysisCurve::defineUiOrdering( QString uiConfigName, if ( axisTypeX() == RiaDefines::HorizontalAxisType::SUMMARY_VECTOR ) { - timeSelectionGroup->add( &m_filterValuesX ); - timeSelectionGroup->add( &m_valueRangeX ); - m_valueRangeX.uiCapability()->setUiReadOnly( !m_filterValuesX() ); + caf::PdmUiGroup* valueRangeXGroup = uiOrdering.addNewGroup( "Value Range X" ); + valueRangeXGroup->add( &m_valueRangeX ); - timeSelectionGroup->add( &m_filterValuesY ); - timeSelectionGroup->add( &m_valueRangeY ); - m_valueRangeY.uiCapability()->setUiReadOnly( !m_filterValuesY() ); + caf::PdmUiGroup* valueRangeYGroup = uiOrdering.addNewGroup( "Value Range Y" ); + valueRangeYGroup->add( &m_valueRangeY ); } caf::PdmUiGroup* forecastingGroup = uiOrdering.addNewGroup( "Forecasting" ); @@ -643,6 +639,18 @@ void RimSummaryRegressionAnalysisCurve::updateDefaultValues() m_minTimeStep = timeSteps.front(); m_maxTimeStep = timeSteps.back(); } + + auto values = RimSummaryCurve::valuesX(); + if ( !values.empty() ) + { + m_valueRangeX = std::make_pair( *std::min_element( values.begin(), values.end() ), *std::max_element( values.begin(), values.end() ) ); + } + + values = RimSummaryCurve::valuesY(); + if ( !values.empty() ) + { + m_valueRangeY = std::make_pair( *std::min_element( values.begin(), values.end() ), *std::max_element( values.begin(), values.end() ) ); + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryRegressionAnalysisCurve.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryRegressionAnalysisCurve.h index df4eac7273..5fd94148de 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryRegressionAnalysisCurve.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryRegressionAnalysisCurve.h @@ -126,10 +126,7 @@ class RimSummaryRegressionAnalysisCurve : public RimSummaryCurve caf::PdmField m_forecastBackward; caf::PdmField> m_forecastUnit; - caf::PdmField m_filterValuesX; caf::PdmField> m_valueRangeX; - - caf::PdmField m_filterValuesY; caf::PdmField> m_valueRangeY; caf::PdmPointer m_timeRangeAnnotation; diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiValueRangeEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiValueRangeEditor.cpp index b8507ea540..9ff10d2fdb 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiValueRangeEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiValueRangeEditor.cpp @@ -114,8 +114,6 @@ void PdmUiValueRangeEditor::configureAndUpdateUi( const QString& uiConfigName ) QString textValueMax = QString( "%1" ).arg( maximum ); - PdmDoubleValidator* pdmValidator = - new PdmDoubleValidator( m_attributes.m_minimum, m_attributes.m_maximum, m_attributes.m_decimals, this ); pdmValidator->fixup( textValueMax ); m_lineEditMax->setValidator( pdmValidator ); @@ -192,7 +190,7 @@ void PdmUiValueRangeEditor::slotMaxSliderValueChanged( int value ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void PdmUiValueRangeEditor::slotSliderReleasedMin() +void PdmUiValueRangeEditor::slotMinSliderReleased() { clampAndWriteValues( m_sliderValueMin, m_sliderValueMax, true ); } @@ -200,7 +198,7 @@ void PdmUiValueRangeEditor::slotSliderReleasedMin() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void PdmUiValueRangeEditor::slotSliderReleasedMax() +void PdmUiValueRangeEditor::slotMaxSliderReleased() { clampAndWriteValues( m_sliderValueMin, m_sliderValueMax, false ); } @@ -275,7 +273,7 @@ QWidget* PdmUiValueRangeEditor::createEditorWidget( QWidget* parent ) layout->addWidget( m_sliderMin, 0, 1 ); connect( m_sliderMin, SIGNAL( valueChanged( int ) ), this, SLOT( slotMinSliderValueChanged( int ) ) ); - connect( m_sliderMin, SIGNAL( sliderReleased() ), this, SLOT( slotSliderReleasedMin() ) ); + connect( m_sliderMin, SIGNAL( sliderReleased() ), this, SLOT( slotMinSliderReleased() ) ); m_lineEditMax = new QLineEdit( containerWidget ); m_lineEditMax->setMaximumWidth( 100 ); @@ -287,7 +285,7 @@ QWidget* PdmUiValueRangeEditor::createEditorWidget( QWidget* parent ) layout->addWidget( m_sliderMax, 1, 1 ); connect( m_sliderMax, SIGNAL( valueChanged( int ) ), this, SLOT( slotMaxSliderValueChanged( int ) ) ); - connect( m_sliderMax, SIGNAL( sliderReleased() ), this, SLOT( slotSliderReleasedMax() ) ); + connect( m_sliderMax, SIGNAL( sliderReleased() ), this, SLOT( slotMaxSliderReleased() ) ); return containerWidget; } diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiValueRangeEditor.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiValueRangeEditor.h index a7f3a7f1a5..f4e09cb02e 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiValueRangeEditor.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiValueRangeEditor.h @@ -58,13 +58,13 @@ class PdmUiValueRangeEditor : public PdmUiFieldEditorHandle QWidget* createLabelWidget( QWidget* parent ) override; void configureAndUpdateUi( const QString& uiConfigName ) override; -protected slots: +private slots: void slotMinEditingFinished(); void slotMaxEditingFinished(); void slotMinSliderValueChanged( int value ); void slotMaxSliderValueChanged( int value ); - void slotSliderReleasedMin(); - void slotSliderReleasedMax(); + void slotMinSliderReleased(); + void slotMaxSliderReleased(); private: void clampAndWriteValues( double valueMin, double valueMax, bool isMinChanged );