diff --git a/ApplicationCode/ProjectDataModel/RimVfpPlot.cpp b/ApplicationCode/ProjectDataModel/RimVfpPlot.cpp index 4b168b17bd..36b303ad05 100644 --- a/ApplicationCode/ProjectDataModel/RimVfpPlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimVfpPlot.cpp @@ -112,6 +112,9 @@ RimVfpPlot::RimVfpPlot() // TODO: add icon CAF_PDM_InitObject( "VFP Plot", "", "", "" ); + CAF_PDM_InitField( &m_plotTitle, "PlotTitle", QString( "VFP Plot" ), "Plot Title", "", "", "" ); + m_plotTitle.uiCapability()->setUiHidden( true ); + CAF_PDM_InitFieldNoDefault( &m_filePath, "FilePath", "File Path", "", "", "" ); caf::AppEnum defaultTableType = RimVfpPlot::TableType::INJECTION; @@ -395,6 +398,9 @@ void RimVfpPlot::onLoadDataAndUpdate() QString filePath = m_filePath.v().path(); if ( !filePath.isEmpty() ) { + QFileInfo fi( filePath ); + QString wellName = fi.baseName(); + // Try to read the file as an prod table first (most common) const std::vector tables = RimVfpTableExtractor::extractVfpProductionTables( filePath.toStdString() ); @@ -424,11 +430,8 @@ void RimVfpPlot::onLoadDataAndUpdate() } } - QFileInfo fi( filePath ); - QString wellName = fi.baseName(); - - const QString plotTitleStr = QString( "%1 VFP Plot" ).arg( wellName ); - m_plotWidget->setTitle( plotTitleStr ); + updatePlotTitle( + generatePlotTitle( wellName, m_tableType(), m_interpolatedVariable(), m_primaryVariable(), m_familyVariable() ) ); m_plotWidget->setAxisTitleEnabled( QwtPlot::xBottom, true ); m_plotWidget->setAxisTitleEnabled( QwtPlot::yLeft, true ); @@ -920,3 +923,44 @@ void RimVfpPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField, cons loadDataAndUpdate(); updateLayout(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpPlot::updatePlotTitle( const QString& plotTitle ) +{ + m_plotTitle = plotTitle; + + updateMdiWindowTitle(); + + if ( m_plotWidget ) + { + m_plotWidget->setTitle( plotTitle ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimVfpPlot::generatePlotTitle( const QString& wellName, + RimVfpPlot::TableType tableType, + RimVfpPlot::InterpolatedVariableType interpolatedVariable, + RimVfpPlot::ProductionVariableType primaryVariable, + RimVfpPlot::ProductionVariableType familyVariable ) +{ + QString tableTypeText = caf::AppEnum::uiText( tableType ); + QString interpolatedVariableText = caf::AppEnum::uiText( interpolatedVariable ); + QString primaryVariableText = caf::AppEnum::uiText( primaryVariable ); + QString plotTitleStr = + QString( "VFP: %1 (%2) - %3 x %4" ).arg( wellName ).arg( tableTypeText ).arg( interpolatedVariableText ).arg( primaryVariableText ); + + return plotTitleStr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* RimVfpPlot::userDescriptionField() +{ + return &m_plotTitle; +} diff --git a/ApplicationCode/ProjectDataModel/RimVfpPlot.h b/ApplicationCode/ProjectDataModel/RimVfpPlot.h index edda87d214..c2bcb90f22 100644 --- a/ApplicationCode/ProjectDataModel/RimVfpPlot.h +++ b/ApplicationCode/ProjectDataModel/RimVfpPlot.h @@ -117,6 +117,9 @@ private: void deleteViewWidget() override; void onLoadDataAndUpdate() override; + // PDM methods + caf::PdmFieldHandle* userDescriptionField() override; + private: RiuQwtPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent ) override; @@ -145,6 +148,13 @@ private: void setFixedVariableUiEditability( caf::PdmField& field, RimVfpPlot::ProductionVariableType variableType ); + void updatePlotTitle( const QString& plotTitle ); + static QString generatePlotTitle( const QString& wellName, + RimVfpPlot::TableType tableType, + RimVfpPlot::InterpolatedVariableType interpolatedVariable, + RimVfpPlot::ProductionVariableType primaryVariable, + RimVfpPlot::ProductionVariableType familyVariable ); + static QwtPlotCurve* createPlotCurve( const QString title, const QColor& color ); static double convertToDisplayUnit( double value, RimVfpPlot::ProductionVariableType variableType ); static void convertToDisplayUnit( std::vector& values, RimVfpPlot::ProductionVariableType variableType ); @@ -159,6 +169,7 @@ private: static RimVfpPlot::FlowingGasFractionType getFlowingGasFractionType( const Opm::VFPProdTable& table ); private: + caf::PdmField m_plotTitle; caf::PdmField m_filePath; caf::PdmField m_tableNumber; caf::PdmField m_referenceDepth;