VFP Plot: Improve autogenerated plot title.

This commit is contained in:
Kristian Bendiksen
2020-12-22 14:24:12 +01:00
parent afacc0968e
commit 21b5cfe470
2 changed files with 60 additions and 5 deletions

View File

@@ -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<RimVfpPlot::TableType> 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<Opm::VFPProdTable> 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<RimVfpPlot::TableType>::uiText( tableType );
QString interpolatedVariableText = caf::AppEnum<RimVfpPlot::InterpolatedVariableType>::uiText( interpolatedVariable );
QString primaryVariableText = caf::AppEnum<RimVfpPlot::ProductionVariableType>::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;
}

View File

@@ -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<int>& 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<double>& values, RimVfpPlot::ProductionVariableType variableType );
@@ -159,6 +169,7 @@ private:
static RimVfpPlot::FlowingGasFractionType getFlowingGasFractionType( const Opm::VFPProdTable& table );
private:
caf::PdmField<QString> m_plotTitle;
caf::PdmField<caf::FilePath> m_filePath;
caf::PdmField<int> m_tableNumber;
caf::PdmField<double> m_referenceDepth;