From c1ff03864229239a370cb521fb6e74874a739f7b Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Thu, 4 Mar 2021 15:30:55 +0100 Subject: [PATCH] #7453 StimPlanModel: Add pressure date to pressure table. Also start using it in header and plot. --- .../StimPlanModel/RimPressureTable.cpp | 24 +++++++++++++++++++ .../StimPlanModel/RimPressureTable.h | 5 ++++ .../StimPlanModel/RimPressureTableItem.cpp | 11 +++++++++ .../StimPlanModel/RimPressureTableItem.h | 2 ++ .../StimPlanModel/RimStimPlanModel.cpp | 16 +++++++++++++ .../StimPlanModel/RimStimPlanModel.h | 2 ++ .../StimPlanModel/RimStimPlanModelCurve.cpp | 7 ++++++ 7 files changed, 67 insertions(+) diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimPressureTable.cpp b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimPressureTable.cpp index 467bd63bfb..eebfc6a389 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimPressureTable.cpp +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimPressureTable.cpp @@ -38,6 +38,8 @@ RimPressureTable::RimPressureTable() m_pressureTableItems.uiCapability()->setUiEditorTypeName( caf::PdmUiTableViewEditor::uiEditorTypeName() ); m_pressureTableItems.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); m_pressureTableItems.uiCapability()->setCustomContextMenuEnabled( true ); + + CAF_PDM_InitFieldNoDefault( &m_pressureDate, "PressureDate", "Pressure Date", "", "", "" ); } //-------------------------------------------------------------------------------------------------- @@ -137,6 +139,7 @@ void RimPressureTable::defineEditorAttribute( const caf::PdmFieldHandle* field, void RimPressureTable::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { uiOrdering.add( &m_pressureTableItems ); + uiOrdering.add( &m_pressureDate ); } //-------------------------------------------------------------------------------------------------- @@ -154,6 +157,8 @@ void RimPressureTable::fieldChangedByUi( const caf::PdmFieldHandle* changedField const QVariant& oldValue, const QVariant& newValue ) { + if ( changedField == &m_pressureDate ) updatePressureDate(); + onTableChanged(); } @@ -170,8 +175,27 @@ void RimPressureTable::onTableChanged( const caf::SignalEmitter* emitter ) //-------------------------------------------------------------------------------------------------- void RimPressureTable::initAfterRead() { + updatePressureDate(); + for ( auto item : items() ) { item->changed.connect( this, &RimPressureTable::onTableChanged ); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPressureTable::updatePressureDate() +{ + for ( auto item : items() ) + item->setPressureDate( m_pressureDate() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const QString& RimPressureTable::pressureDate() const +{ + return m_pressureDate(); +} diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimPressureTable.h b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimPressureTable.h index 7bcfd2e64e..4258642b26 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimPressureTable.h +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimPressureTable.h @@ -44,6 +44,8 @@ public: void deleteItem( RimPressureTableItem* itemToDelete ); void deleteAllItems(); + const QString& pressureDate() const; + protected: void defineCustomContextMenu( const caf::PdmFieldHandle* fieldNeedingMenu, QMenu* menu, QWidget* fieldEditorWidget ) override; void defineEditorAttribute( const caf::PdmFieldHandle* field, @@ -55,8 +57,11 @@ protected: void onTableChanged( const caf::SignalEmitter* emitter = nullptr ); + void updatePressureDate(); + void initAfterRead() override; private: caf::PdmChildArrayField m_pressureTableItems; + caf::PdmField m_pressureDate; }; diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimPressureTableItem.cpp b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimPressureTableItem.cpp index 48b4b85e75..81ac53ee7c 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimPressureTableItem.cpp +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimPressureTableItem.cpp @@ -84,3 +84,14 @@ void RimPressureTableItem::fieldChangedByUi( const caf::PdmFieldHandle* changedF { changed.send(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPressureTableItem::setPressureDate( const QString& pressureDate ) +{ + if ( pressureDate.isEmpty() ) + m_pressure.uiCapability()->setUiName( "Pressure [Bar]" ); + else + m_pressure.uiCapability()->setUiName( QString( "Pressure %1 [Bar]" ).arg( pressureDate ) ); +} diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimPressureTableItem.h b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimPressureTableItem.h index cfc69bb9fb..81cb0c9725 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimPressureTableItem.h +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimPressureTableItem.h @@ -40,6 +40,8 @@ public: double initialPressure() const; double pressure() const; + void setPressureDate( const QString& pressureDate ); + private: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModel.cpp b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModel.cpp index 69030cec53..3c0a993670 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModel.cpp +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModel.cpp @@ -47,6 +47,7 @@ #include "RimNonNetLayers.h" #include "RimOilField.h" #include "RimPolylineTarget.h" +#include "RimPressureTable.h" #include "RimProject.h" #include "RimStimPlanModelCalculator.h" #include "RimStimPlanModelPlot.h" @@ -1699,3 +1700,18 @@ bool RimStimPlanModel::isScaledByNetToGross( RiaDefines::CurveProperty curveProp return std::find( matching.begin(), matching.end(), curveProperty ) != matching.end(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimStimPlanModel::pressureDate() const +{ + if ( !m_stimPlanModelTemplate ) return QString(); + + if ( m_stimPlanModelTemplate->usePressureTableForProperty( RiaDefines::CurveProperty::PRESSURE ) ) + return m_stimPlanModelTemplate->pressureTable()->pressureDate(); + else if ( m_eclipseCase && m_timeStep >= 0 && m_timeStep < m_eclipseCase->timeStepStrings().size() ) + return m_eclipseCase->timeStepStrings()[m_timeStep]; + else + return QString(); +} diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModel.h b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModel.h index 00f0bb0c67..7dc7093f8c 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModel.h +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModel.h @@ -180,6 +180,8 @@ public: bool isScaledByNetToGross( RiaDefines::CurveProperty curveProperty ) const; + QString pressureDate() const; + protected: void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelCurve.cpp b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelCurve.cpp index 8537c5c6d6..a2f539bab6 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelCurve.cpp @@ -176,6 +176,13 @@ void RimStimPlanModelCurve::performDataExtraction( bool* isUsingPseudoLength ) QString RimStimPlanModelCurve::createCurveAutoName() { QString textWithLineFeed = caf::AppEnum::uiText( m_curveProperty() ).trimmed(); + if ( m_curveProperty == RiaDefines::CurveProperty::PRESSURE ) + { + // Append date for pressure + QString pressureDate = m_stimPlanModel->pressureDate(); + if ( !pressureDate.isEmpty() ) return QString( "%1 (%2)" ).arg( textWithLineFeed ).arg( pressureDate ); + } + textWithLineFeed.replace( " ", "\n" ); return textWithLineFeed;