Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
magnesj committed Sep 21, 2023
1 parent bb6f1fe commit 40d2aa2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include "cafPdmUiDateEditor.h"
#include "cafPdmUiLineEditor.h"
#include "cafPdmUiSliderEditor.h"
#include "cafPdmUiSliderTools.h"
#include "cafPdmUiTextEditor.h"

Expand Down Expand Up @@ -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 );
}

//--------------------------------------------------------------------------------------------------
Expand All @@ -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++ )
Expand All @@ -137,7 +136,6 @@ void RimSummaryRegressionAnalysisCurve::onLoadDataAndUpdate( bool updateParentPl
}
}

if ( m_filterValuesY )
{
auto values = yValues;
for ( size_t i = 0; i < values.size(); i++ )
Expand Down Expand Up @@ -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" );
Expand Down Expand Up @@ -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() ) );
}
}

//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,7 @@ class RimSummaryRegressionAnalysisCurve : public RimSummaryCurve
caf::PdmField<int> m_forecastBackward;
caf::PdmField<caf::AppEnum<ForecastUnit>> m_forecastUnit;

caf::PdmField<bool> m_filterValuesX;
caf::PdmField<std::pair<double, double>> m_valueRangeX;

caf::PdmField<bool> m_filterValuesY;
caf::PdmField<std::pair<double, double>> m_valueRangeY;

caf::PdmPointer<RimTimeAxisAnnotation> m_timeRangeAnnotation;
Expand Down
10 changes: 4 additions & 6 deletions Fwk/AppFwk/cafUserInterface/cafPdmUiValueRangeEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -192,15 +190,15 @@ void PdmUiValueRangeEditor::slotMaxSliderValueChanged( int value )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmUiValueRangeEditor::slotSliderReleasedMin()
void PdmUiValueRangeEditor::slotMinSliderReleased()
{
clampAndWriteValues( m_sliderValueMin, m_sliderValueMax, true );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmUiValueRangeEditor::slotSliderReleasedMax()
void PdmUiValueRangeEditor::slotMaxSliderReleased()
{
clampAndWriteValues( m_sliderValueMin, m_sliderValueMax, false );
}
Expand Down Expand Up @@ -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 );
Expand All @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions Fwk/AppFwk/cafUserInterface/cafPdmUiValueRangeEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down

0 comments on commit 40d2aa2

Please sign in to comment.