Add parsing of *.DATA and add zoom to VFP plots

Parse *.DATA and create VFP plots for all tables
Add zoom in VFP plots
This commit is contained in:
Magne Sjaastad
2024-05-03 09:58:55 +02:00
parent b7e5867430
commit a55b53c725
20 changed files with 613 additions and 148 deletions

View File

@@ -132,6 +132,7 @@ list(
ProjectDataModel/Tools/CMakeLists_files.cmake
ProjectDataModelCommands/CMakeLists_files.cmake
ProjectDataModelCommands/CommandRouter/CMakeLists_files.cmake
ProjectDataModel/VerticalFlowPerformance/CMakeLists_files.cmake
GeoMech/GeoMechVisualization/CMakeLists_files.cmake
ModelVisualization/CMakeLists_files.cmake
ModelVisualization/Faults/CMakeLists_files.cmake

View File

@@ -33,11 +33,12 @@
#include "RimPlotWindow.h"
#include "RimProject.h"
#include "RimSummaryPlot.h"
#include "RimVfpPlot.h"
#include "RimWellAllocationOverTimePlot.h"
#include "RimWellLogPlot.h"
#include "RimWellLogTrack.h"
#include "VerticalFlowPerformance/RimVfpPlot.h"
#include "RiuPlotMainWindow.h"
#include "RiuTextDialog.h"

View File

@@ -22,12 +22,10 @@
#include "RiaGuiApplication.h"
#include "RimMainPlotCollection.h"
#include "RimSimWellInView.h"
#include "RimVfpPlot.h"
#include "RimVfpPlotCollection.h"
#include "RimWellLogPlot.h"
#include "RimWellLogTrack.h"
#include "RimWellPath.h"
#include "VerticalFlowPerformance/RimVfpDeck.h"
#include "VerticalFlowPerformance/RimVfpPlot.h"
#include "VerticalFlowPerformance/RimVfpPlotCollection.h"
#include "RiuFileDialogTools.h"
#include "RiuPlotMainWindow.h"
@@ -38,8 +36,6 @@
#include <QAction>
#include <QFileInfo>
#include <vector>
CAF_CMD_SOURCE_INIT( RicNewVfpPlotFeature, "RicNewVfpPlotFeature" );
//--------------------------------------------------------------------------------------------------
@@ -47,7 +43,7 @@ CAF_CMD_SOURCE_INIT( RicNewVfpPlotFeature, "RicNewVfpPlotFeature" );
//--------------------------------------------------------------------------------------------------
bool RicNewVfpPlotFeature::isCommandEnabled() const
{
RimVfpPlotCollection* plotColl = caf::firstAncestorOfTypeFromSelectedObject<RimVfpPlotCollection>();
auto plotColl = caf::firstAncestorOfTypeFromSelectedObject<RimVfpPlotCollection>();
return ( plotColl != nullptr );
}
@@ -56,44 +52,64 @@ bool RicNewVfpPlotFeature::isCommandEnabled() const
//--------------------------------------------------------------------------------------------------
void RicNewVfpPlotFeature::onActionTriggered( bool isChecked )
{
RimVfpPlotCollection* vfpPlotColl = RimMainPlotCollection::current()->vfpPlotCollection();
if ( !vfpPlotColl ) return;
RiaApplication* app = RiaGuiApplication::instance();
RiuPlotMainWindow* mpw = RiaGuiApplication::instance()->mainPlotWindow();
const QString vfpDataKey = "VFP_DATA";
QString defaultDir = app->lastUsedDialogDirectory( vfpDataKey );
QStringList fileNames =
RiuFileDialogTools::getOpenFileNames( mpw, "Import VFP Files", defaultDir, "VFP Text Files (*.ecl *.vfp);;All Files (*.*)" );
RiuFileDialogTools::getOpenFileNames( mpw, "Import VFP Files", defaultDir, "VFP Text Files (*.ecl *.vfp *.data);;All Files (*.*)" );
if ( fileNames.isEmpty() ) return;
app->setLastUsedDialogDirectory( vfpDataKey, QFileInfo( fileNames.last() ).absolutePath() );
RimVfpPlotCollection* vfpPlotColl = RimMainPlotCollection::current()->vfpPlotCollection();
if ( vfpPlotColl )
std::vector<RimVfpPlot*> vfpPlots;
std::vector<RimVfpDeck*> vfpDecks;
for ( const auto& fileName : fileNames )
{
std::vector<RimVfpPlot*> vfpPlots;
for ( const auto& fileName : fileNames )
if ( fileName.contains( ".DATA" ) )
{
RimVfpPlot* vfpPlot = new RimVfpPlot();
auto vfpDeck = vfpPlotColl->addDeck( fileName );
vfpDecks.push_back( vfpDeck );
}
else
{
auto vfpPlot = new RimVfpPlot();
vfpPlot->setFileName( fileName );
vfpPlotColl->addPlot( vfpPlot );
vfpPlots.push_back( vfpPlot );
}
}
vfpPlotColl->updateConnectedEditors();
vfpPlotColl->updateConnectedEditors();
for ( auto plot : vfpPlots )
{
plot->loadDataAndUpdate();
}
for ( auto deck : vfpDecks )
{
deck->loadDataAndUpdate();
deck->updateConnectedEditors();
}
RiuPlotMainWindowTools::showPlotMainWindow();
for ( auto plot : vfpPlots )
{
plot->loadDataAndUpdate();
}
if ( !vfpPlots.empty() )
{
RiuPlotMainWindowTools::onObjectAppended( vfpPlots.front() );
}
RiuPlotMainWindowTools::showPlotMainWindow();
if ( !vfpPlots.empty() )
{
RiuPlotMainWindowTools::onObjectAppended( vfpPlots.front() );
}
if ( !vfpDecks.empty() )
{
RiuPlotMainWindowTools::onObjectAppended( vfpDecks.front() );
}
}

View File

@@ -31,6 +31,4 @@ private:
bool isCommandEnabled() const override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
static QString selectedWellName();
};

View File

@@ -48,9 +48,6 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RimMainPlotCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimRftPlotCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimPltPlotCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimVfpPlotCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimVfpPlot.h
${CMAKE_CURRENT_LIST_DIR}/RimVfpDefines.h
${CMAKE_CURRENT_LIST_DIR}/RimPlot.h
${CMAKE_CURRENT_LIST_DIR}/RimPlotWindow.h
${CMAKE_CURRENT_LIST_DIR}/RimMultiPlot.h
@@ -188,9 +185,6 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RimMainPlotCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimRftPlotCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimPltPlotCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimVfpPlotCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimVfpPlot.cpp
${CMAKE_CURRENT_LIST_DIR}/RimVfpDefines.cpp
${CMAKE_CURRENT_LIST_DIR}/RimPlot.cpp
${CMAKE_CURRENT_LIST_DIR}/RimPlotWindow.cpp
${CMAKE_CURRENT_LIST_DIR}/RimMultiPlot.cpp

View File

@@ -52,9 +52,9 @@ Opm::VFPInjTable createInjectionTable( const Opm::DeckKeyword& keyword )
if ( header.getItem<Opm::ParserKeywords::VFPINJ::UNITS>().hasValue( 0 ) )
{
std::string units_string;
units_string = header.getItem<Opm::ParserKeywords::VFPINJ::UNITS>().get<std::string>( 0 );
unitSystem = Opm::UnitSystem( units_string );
std::string unitString;
unitString = header.getItem<Opm::ParserKeywords::VFPINJ::UNITS>().get<std::string>( 0 );
unitSystem = Opm::UnitSystem( unitString );
}
}
@@ -72,9 +72,9 @@ Opm::VFPProdTable createProductionTable( const Opm::DeckKeyword& keyword )
if ( header.getItem<Opm::ParserKeywords::VFPPROD::UNITS>().hasValue( 0 ) )
{
std::string units_string;
units_string = header.getItem<Opm::ParserKeywords::VFPPROD::UNITS>().get<std::string>( 0 );
unitSystem = Opm::UnitSystem( units_string );
std::string unitString;
unitString = header.getItem<Opm::ParserKeywords::VFPPROD::UNITS>().get<std::string>( 0 );
unitSystem = Opm::UnitSystem( unitString );
}
}
@@ -101,9 +101,8 @@ std::vector<Opm::VFPInjTable> extractVfpInjectionTables( const std::string& file
auto deck = parser.parseFile( filename );
std::string myKeyword = "VFPINJ";
auto keywordList = deck.getKeywordList( myKeyword );
std::string keyword = ::Opm::ParserKeywords::VFPINJ::keywordName;
auto keywordList = deck.getKeywordList( keyword );
for ( auto kw : keywordList )
{
auto table = createInjectionTable( *kw );
@@ -133,9 +132,8 @@ std::vector<Opm::VFPProdTable> extractVfpProductionTables( const std::string& fi
auto deck = parser.parseFile( filename );
std::string myKeyword = "VFPPROD";
auto keywordList = deck.getKeywordList( myKeyword );
std::string keyword = ::Opm::ParserKeywords::VFPPROD::keywordName;
auto keywordList = deck.getKeywordList( keyword );
for ( auto kw : keywordList )
{
auto table = createProductionTable( *kw );

View File

@@ -148,7 +148,6 @@
#include "RimSurfaceCollection.h"
#include "RimValveTemplate.h"
#include "RimValveTemplateCollection.h"
#include "RimVfpPlotCollection.h"
#include "RimViewController.h"
#include "RimViewLinker.h"
#include "RimViewLinkerCollection.h"
@@ -587,10 +586,6 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
{
menuBuilder << "RicNewPltPlotFeature";
}
else if ( dynamic_cast<RimVfpPlotCollection*>( firstUiItem ) )
{
menuBuilder << "RicNewVfpPlotFeature";
}
else if ( dynamic_cast<RimSummaryMultiPlotCollection*>( firstUiItem ) )
{
menuBuilder << "RicNewSummaryMultiPlotFeature";

View File

@@ -49,7 +49,6 @@
#include "RimSummaryMultiPlotCollection.h"
#include "RimSummaryPlotCollection.h"
#include "RimSummaryTableCollection.h"
#include "RimVfpPlotCollection.h"
#include "RimViewWindow.h"
#include "RimWellAllocationOverTimePlot.h"
#include "RimWellAllocationPlot.h"
@@ -58,6 +57,7 @@
#include "RimWellLogPlotCollection.h"
#include "RimWellPltPlot.h"
#include "RimWellRftPlot.h"
#include "VerticalFlowPerformance/RimVfpPlotCollection.h"
#ifdef USE_QTCHARTS
#include "RimEnsembleFractureStatisticsPlot.h"

View File

@@ -92,7 +92,6 @@
#include "RimUserDefinedPolylinesAnnotation.h"
#include "RimValveTemplate.h"
#include "RimValveTemplateCollection.h"
#include "RimVfpPlotCollection.h"
#include "RimViewLinker.h"
#include "RimViewLinkerCollection.h"
#include "RimViewWindow.h"
@@ -100,6 +99,7 @@
#include "RimWellLogPlotCollection.h"
#include "RimWellPath.h"
#include "RimWellPathCollection.h"
#include "VerticalFlowPerformance/RimVfpPlotCollection.h"
#include "Tools/RiaVariableMapper.h"

View File

@@ -44,11 +44,11 @@ void RimPlotAxisTools::updateVisibleRangesFromPlotWidget( RimPlotAxisProperties*
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotAxisTools::updatePlotWidgetFromAxisProperties( RiuPlotWidget* plotWidget,
RiuPlotAxis axis,
const RimPlotAxisProperties* const axisProperties,
const QString& axisTitle,
std::vector<const RimPlotCurve*> plotCurves )
void RimPlotAxisTools::updatePlotWidgetFromAxisProperties( RiuPlotWidget* plotWidget,
RiuPlotAxis axis,
const RimPlotAxisProperties* const axisProperties,
const QString& axisTitle,
const std::vector<const RimPlotCurve*>& plotCurves )
{
if ( !plotWidget || !axisProperties ) return;

View File

@@ -30,10 +30,10 @@ namespace RimPlotAxisTools
{
void updateVisibleRangesFromPlotWidget( RimPlotAxisProperties* axisProperties, RiuPlotAxis plotAxis, const RiuPlotWidget* const plotWidget );
void updatePlotWidgetFromAxisProperties( RiuPlotWidget* plotWidget,
RiuPlotAxis plotAxis,
const RimPlotAxisProperties* const axisProperties,
const QString& axisTitle,
std::vector<const RimPlotCurve*> plotCurves );
void updatePlotWidgetFromAxisProperties( RiuPlotWidget* plotWidget,
RiuPlotAxis plotAxis,
const RimPlotAxisProperties* const axisProperties,
const QString& axisTitle,
const std::vector<const RimPlotCurve*>& plotCurves );
}; // namespace RimPlotAxisTools

View File

@@ -0,0 +1,21 @@
set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RimVfpDefines.h
${CMAKE_CURRENT_LIST_DIR}/RimVfpDeck.h
${CMAKE_CURRENT_LIST_DIR}/RimVfpPlot.h
${CMAKE_CURRENT_LIST_DIR}/RimVfpPlotCollection.h
)
set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RimVfpDeck.cpp
${CMAKE_CURRENT_LIST_DIR}/RimVfpDefines.cpp
${CMAKE_CURRENT_LIST_DIR}/RimVfpPlot.cpp
${CMAKE_CURRENT_LIST_DIR}/RimVfpPlotCollection.cpp
)
list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES})
source_group(
"VFP Plots" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES}
${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake
)

View File

@@ -0,0 +1,139 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024 Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RimVfpDeck.h"
#include "RiaOpmParserTools.h"
#include "RimVfpPlotCollection.h"
#include "cafPdmUiTreeOrdering.h"
#include <QFileInfo>
CAF_PDM_SOURCE_INIT( RimVfpDeck, "RimVfpDeck" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimVfpDeck::RimVfpDeck()
{
CAF_PDM_InitObject( "VFP Plot", ":/VfpPlot.svg" );
CAF_PDM_InitFieldNoDefault( &m_filePath, "FilePath", "File Path" );
CAF_PDM_InitFieldNoDefault( &m_vfpPlotCollection, "VfpPlotCollection", "Plot Collection" );
m_vfpPlotCollection = new RimVfpPlotCollection();
setDeletable( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimVfpDeck::setFileName( const QString& filename )
{
m_filePath = filename;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimVfpDeck::loadDataAndUpdate()
{
updateObjectName();
auto createRimVfpPlot = [&]() -> RimVfpPlot*
{
auto plot = new RimVfpPlot();
plot->setFileName( m_filePath().path() );
return plot;
};
std::vector<RimVfpPlot*> currentPlots = m_vfpPlotCollection->plots();
auto [vfpProdTables, vfpInjTables] = RiaOpmParserTools::extractVfpTablesFromDataFile( m_filePath().path().toStdString() );
for ( const auto& prodTable : vfpProdTables )
{
RimVfpPlot* plot = m_vfpPlotCollection->plotForTableNumber( prodTable.getTableNum() );
if ( !plot )
{
plot = createRimVfpPlot();
m_vfpPlotCollection->addPlot( plot );
}
else
{
std::erase( currentPlots, plot );
}
plot->setProductionTable( prodTable );
plot->setDataIsImportedExternally( true );
plot->setDeletable( false );
plot->loadDataAndUpdate();
}
for ( const auto& injTable : vfpInjTables )
{
RimVfpPlot* plot = m_vfpPlotCollection->plotForTableNumber( injTable.getTableNum() );
if ( !plot )
{
plot = createRimVfpPlot();
m_vfpPlotCollection->addPlot( plot );
}
else
{
std::erase( currentPlots, plot );
}
plot->setInjectionTable( injTable );
plot->setDataIsImportedExternally( true );
plot->setDeletable( false );
plot->loadDataAndUpdate();
}
for ( auto plotToDelete : currentPlots )
{
m_vfpPlotCollection->removePlot( plotToDelete );
delete plotToDelete;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimVfpDeck::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName )
{
for ( auto p : m_vfpPlotCollection->plots() )
{
uiTreeOrdering.add( p );
}
uiTreeOrdering.skipRemainingChildren( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimVfpDeck::updateObjectName()
{
QString name = "VFP Plots";
QFileInfo fileInfo( m_filePath().path() );
auto fileName = fileInfo.fileName();
if ( !fileName.isEmpty() )
{
name += " - " + fileName;
}
setName( name );
}

View File

@@ -0,0 +1,47 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024 Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RimNamedObject.h"
#include "cafFilePath.h"
class RimVfpPlotCollection;
//--------------------------------------------------------------------------------------------------
/// RimVfpDeck parses a deck file (*.DATA) containing VFP data and creates a collection of VFP plots.
//--------------------------------------------------------------------------------------------------
class RimVfpDeck : public RimNamedObject
{
CAF_PDM_HEADER_INIT;
public:
RimVfpDeck();
void setFileName( const QString& filename );
void loadDataAndUpdate();
private:
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override;
void updateObjectName();
private:
caf::PdmField<caf::FilePath> m_filePath;
caf::PdmChildField<RimVfpPlotCollection*> m_vfpPlotCollection;
};

View File

@@ -18,23 +18,29 @@
#include "RimVfpPlot.h"
#include "RiaDefines.h"
#include "RiaOpmParserTools.h"
#include "RimVfpDefines.h"
#include "RiaColorTables.h"
#include "RiaEclipseUnitTools.h"
#include "RiaOpmParserTools.h"
#include "RimPlotAxisProperties.h"
#include "RimVfpDefines.h"
#include "Tools/RimPlotAxisTools.h"
#include "RiuContextMenuLauncher.h"
#include "RiuPlotCurve.h"
#include "RiuPlotWidget.h"
#include "RiuQwtPlotCurveDefines.h"
#include "RiuQwtPlotWheelZoomer.h"
#include "RiuQwtPlotWidget.h"
#include "RiuQwtSymbol.h"
#include "cafCmdFeatureMenuBuilder.h"
#include "RiuQwtCurvePointTracker.h"
#include "RiuQwtPlotWidget.h"
#include "RiuQwtPlotZoomer.h"
#include "cafPdmUiComboBoxEditor.h"
#include "qwt_plot_panner.h"
#include <QFileInfo>
#include <memory>
@@ -137,8 +143,22 @@ RimVfpPlot::RimVfpPlot()
CAF_PDM_InitField( &m_gasLiquidRatioIdx, "GasLiquidRatioIdx", 0, "Gas Liquid Ratio" );
m_gasLiquidRatioIdx.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() );
m_showWindow = true;
m_showPlotLegends = true;
CAF_PDM_InitFieldNoDefault( &m_xAxisProperties, "xAxisProperties", "X Axis" );
m_xAxisProperties = new RimPlotAxisProperties;
m_xAxisProperties->setNameAndAxis( "X-Axis", "X-Axis", RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM );
m_xAxisProperties->setEnableTitleTextSettings( false );
CAF_PDM_InitFieldNoDefault( &m_yAxisProperties, "yAxisProperties", "Y Axis" );
m_yAxisProperties = new RimPlotAxisProperties;
m_yAxisProperties->setNameAndAxis( "Y-Axis", "Y-Axis", RiaDefines::PlotAxis::PLOT_AXIS_LEFT );
m_yAxisProperties->setEnableTitleTextSettings( false );
connectAxisSignals( m_xAxisProperties() );
connectAxisSignals( m_yAxisProperties() );
m_showWindow = true;
m_showPlotLegends = true;
m_dataIsImportedExternally = false;
setAsPlotMdiWindow();
@@ -181,15 +201,17 @@ bool RimVfpPlot::isCurveHighlightSupported() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimVfpPlot::setAutoScaleXEnabled( bool /*enabled*/ )
void RimVfpPlot::setAutoScaleXEnabled( bool enabled )
{
m_xAxisProperties->setAutoZoom( enabled );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimVfpPlot::setAutoScaleYEnabled( bool /*enabled*/ )
void RimVfpPlot::setAutoScaleYEnabled( bool enabled )
{
m_yAxisProperties->setAutoZoom( enabled );
}
//--------------------------------------------------------------------------------------------------
@@ -197,6 +219,13 @@ void RimVfpPlot::setAutoScaleYEnabled( bool /*enabled*/ )
//--------------------------------------------------------------------------------------------------
void RimVfpPlot::updateAxes()
{
if ( !m_plotWidget ) return;
QString title;
RimPlotAxisTools::updatePlotWidgetFromAxisProperties( m_plotWidget, RiuPlotAxis::defaultBottom(), m_xAxisProperties(), title, {} );
RimPlotAxisTools::updatePlotWidgetFromAxisProperties( m_plotWidget, RiuPlotAxis::defaultLeft(), m_yAxisProperties(), title, {} );
m_plotWidget->scheduleReplot();
}
//--------------------------------------------------------------------------------------------------
@@ -209,7 +238,7 @@ void RimVfpPlot::updateLegend()
return;
}
// Hide the legend when in multiplot mode, as the legend is handeled by the multi plot grid layout
// Hide the legend when in multiplot mode, as the legend is handled by the multi plot grid layout
bool doShowLegend = false;
if ( isMdiWindow() )
{
@@ -350,6 +379,44 @@ QImage RimVfpPlot::snapshotWindowContent()
//--------------------------------------------------------------------------------------------------
void RimVfpPlot::zoomAll()
{
setAutoScaleXEnabled( true );
setAutoScaleYEnabled( true );
updatePlotWidgetFromAxisRanges();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimVfpPlot::setProductionTable( const Opm::VFPProdTable& table )
{
m_prodTable = std::make_unique<Opm::VFPProdTable>( table );
m_injectionTable.reset();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimVfpPlot::setInjectionTable( const Opm::VFPInjTable& table )
{
m_prodTable.reset();
m_injectionTable = std::make_unique<Opm::VFPInjTable>( table );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimVfpPlot::setDataIsImportedExternally( bool dataIsImportedExternally )
{
m_dataIsImportedExternally = dataIsImportedExternally;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimVfpPlot::tableNumber() const
{
return m_tableNumber();
}
//--------------------------------------------------------------------------------------------------
@@ -365,21 +432,35 @@ void RimVfpPlot::doRemoveFromCollection()
RiuPlotWidget* RimVfpPlot::doCreatePlotViewWidget( QWidget* mainWindowParent )
{
// It seems we risk being called multiple times
if ( m_plotWidget )
{
return m_plotWidget;
}
if ( m_plotWidget ) return m_plotWidget;
{
RiuPlotWidget* plotWidget = new RiuQwtPlotWidget( this, mainWindowParent );
auto qwtPlotWidget = new RiuQwtPlotWidget( this, mainWindowParent );
auto qwtPlot = qwtPlotWidget->qwtPlot();
new RiuQwtCurvePointTracker( qwtPlot, true, nullptr );
// Remove event filter to disable unwanted highlighting on left click in plot.
plotWidget->removeEventFilter();
// LeftButton for the zooming
auto plotZoomer = new RiuQwtPlotZoomer( qwtPlot->canvas() );
plotZoomer->setTrackerMode( QwtPicker::AlwaysOff );
plotZoomer->initMousePattern( 1 );
new RiuContextMenuLauncher( plotWidget, { "RicShowPlotDataFeature" } );
// MidButton for the panning
auto panner = new QwtPlotPanner( qwtPlot->canvas() );
panner->setMouseButton( Qt::MiddleButton );
m_plotWidget = plotWidget;
}
auto wheelZoomer = new RiuQwtPlotWheelZoomer( qwtPlot );
// Use lambda functions to connect signals to functions instead of slots
connect( wheelZoomer, &RiuQwtPlotWheelZoomer::zoomUpdated, [=]() { onPlotZoomed(); } );
connect( plotZoomer, &RiuQwtPlotZoomer::zoomed, [=]() { onPlotZoomed(); } );
connect( panner, &QwtPlotPanner::panned, [=]() { onPlotZoomed(); } );
connect( qwtPlotWidget, &RiuQwtPlotWidget::plotZoomed, [=]() { onPlotZoomed(); } );
// Remove event filter to disable unwanted highlighting on left click in plot.
qwtPlotWidget->removeEventFilter();
new RiuContextMenuLauncher( qwtPlotWidget, { "RicShowPlotDataFeature" } );
m_plotWidget = qwtPlotWidget;
updateLegend();
onLoadDataAndUpdate();
@@ -423,46 +504,63 @@ void RimVfpPlot::onLoadDataAndUpdate()
updateLegend();
QString filePath = m_filePath.v().path();
if ( !filePath.isEmpty() )
{
QFileInfo fi( filePath );
QString wellName = fi.baseName();
QString wellName;
// Try to read the file as an prod table first (most common)
const std::vector<Opm::VFPProdTable> tables = RiaOpmParserTools::extractVfpProductionTables( filePath.toStdString() );
if ( !tables.empty() )
if ( !m_dataIsImportedExternally )
{
QString filePath = m_filePath.v().path();
if ( !filePath.isEmpty() )
{
m_prodTable = std::make_unique<Opm::VFPProdTable>( tables[0] );
m_tableType = RimVfpDefines::TableType::PRODUCTION;
m_tableNumber = tables[0].getTableNum();
m_referenceDepth = tables[0].getDatumDepth();
m_flowingPhase = getFlowingPhaseType( tables[0] );
m_flowingGasFraction = getFlowingGasFractionType( tables[0] );
m_flowingWaterFraction = getFlowingWaterFractionType( tables[0] );
populatePlotWidgetWithCurveData( m_plotWidget, tables[0], m_primaryVariable(), m_familyVariable() );
}
else
{
const std::vector<Opm::VFPInjTable> tables = RiaOpmParserTools::extractVfpInjectionTables( filePath.toStdString() );
QFileInfo fi( filePath );
wellName = fi.baseName();
// Try to read the file as an prod table first (most common)
const std::vector<Opm::VFPProdTable> tables = RiaOpmParserTools::extractVfpProductionTables( filePath.toStdString() );
if ( !tables.empty() )
{
m_injectionTable = std::make_unique<Opm::VFPInjTable>( tables[0] );
m_tableType = RimVfpDefines::TableType::INJECTION;
m_tableNumber = tables[0].getTableNum();
m_referenceDepth = tables[0].getDatumDepth();
m_flowingPhase = getFlowingPhaseType( tables[0] );
populatePlotWidgetWithCurveData( m_plotWidget, tables[0] );
setProductionTable( tables[0] );
}
else
{
const std::vector<Opm::VFPInjTable> tables = RiaOpmParserTools::extractVfpInjectionTables( filePath.toStdString() );
if ( !tables.empty() )
{
setInjectionTable( tables[0] );
}
}
}
updatePlotTitle(
generatePlotTitle( wellName, m_tableNumber(), m_tableType(), m_interpolatedVariable(), m_primaryVariable(), m_familyVariable() ) );
m_plotWidget->setAxisTitleEnabled( RiuPlotAxis::defaultBottom(), true );
m_plotWidget->setAxisTitleEnabled( RiuPlotAxis::defaultLeft(), true );
}
if ( m_prodTable )
{
auto table = *m_prodTable;
m_tableType = RimVfpDefines::TableType::PRODUCTION;
m_tableNumber = table.getTableNum();
m_referenceDepth = table.getDatumDepth();
m_flowingPhase = getFlowingPhaseType( table );
m_flowingGasFraction = getFlowingGasFractionType( table );
m_flowingWaterFraction = getFlowingWaterFractionType( table );
populatePlotWidgetWithCurveData( m_plotWidget, table, m_primaryVariable(), m_familyVariable() );
}
else if ( m_injectionTable )
{
auto table = *m_injectionTable;
m_tableType = RimVfpDefines::TableType::INJECTION;
m_tableNumber = table.getTableNum();
m_referenceDepth = table.getDatumDepth();
m_flowingPhase = getFlowingPhaseType( table );
populatePlotWidgetWithCurveData( m_plotWidget, table );
}
updatePlotTitle(
generatePlotTitle( wellName, m_tableNumber(), m_tableType(), m_interpolatedVariable(), m_primaryVariable(), m_familyVariable() ) );
m_plotWidget->setAxisTitleEnabled( RiuPlotAxis::defaultBottom(), true );
m_plotWidget->setAxisTitleEnabled( RiuPlotAxis::defaultLeft(), true );
updatePlotWidgetFromAxisRanges();
m_plotWidget->scheduleReplot();
}
@@ -509,10 +607,10 @@ void RimVfpPlot::populatePlotData( const Opm::VFPInjTable& table
double value = convertToDisplayUnit( thpValues[thp], RimVfpDefines::ProductionVariableType::THP );
QString unit = getDisplayUnit( RimVfpDefines::ProductionVariableType::THP );
QString title = QString( "%1: %2 %3" )
QString title = QString( "%1 [%2]: %3" )
.arg( caf::AppEnum<RimVfpDefines::ProductionVariableType>::uiText( RimVfpDefines::ProductionVariableType::THP ) )
.arg( value )
.arg( unit );
.arg( unit )
.arg( value );
convertToDisplayUnit( yVals, RimVfpDefines::ProductionVariableType::THP );
convertToDisplayUnit( xVals, RimVfpDefines::ProductionVariableType::FLOW_RATE );
@@ -590,6 +688,69 @@ QString RimVfpPlot::axisTitle( RimVfpDefines::ProductionVariableType variableTyp
return title;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimVfpPlot::connectAxisSignals( RimPlotAxisProperties* axis )
{
axis->settingsChanged.connect( this, &RimVfpPlot::axisSettingsChanged );
axis->logarithmicChanged.connect( this, &RimVfpPlot::axisLogarithmicChanged );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimVfpPlot::axisSettingsChanged( const caf::SignalEmitter* emitter )
{
updateAxes();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimVfpPlot::axisLogarithmicChanged( const caf::SignalEmitter* emitter, bool isLogarithmic )
{
// Currently not supported
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimVfpPlot::updatePlotWidgetFromAxisRanges()
{
if ( m_plotWidget )
{
updateAxes();
if ( auto qwtWidget = dynamic_cast<RiuQwtPlotWidget*>( m_plotWidget.data() ) )
{
if ( qwtWidget->qwtPlot() ) qwtWidget->qwtPlot()->updateAxes();
}
updateAxisRangesFromPlotWidget();
m_plotWidget->scheduleReplot();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimVfpPlot::updateAxisRangesFromPlotWidget()
{
RimPlotAxisTools::updateVisibleRangesFromPlotWidget( m_xAxisProperties(), RiuPlotAxis::defaultBottom(), m_plotWidget );
RimPlotAxisTools::updateVisibleRangesFromPlotWidget( m_yAxisProperties(), RiuPlotAxis::defaultLeft(), m_plotWidget );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimVfpPlot::onPlotZoomed()
{
setAutoScaleXEnabled( false );
setAutoScaleYEnabled( false );
updateAxisRangesFromPlotWidget();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -764,37 +925,35 @@ size_t RimVfpPlot::getVariableIndex( const Opm::VFPProdTable& table
void RimVfpPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
uiOrdering.add( &m_filePath );
m_filePath.uiCapability()->setUiReadOnly( m_dataIsImportedExternally );
if ( !m_filePath.v().path().isEmpty() )
uiOrdering.add( &m_tableType );
uiOrdering.add( &m_tableNumber );
uiOrdering.add( &m_referenceDepth );
uiOrdering.add( &m_interpolatedVariable );
uiOrdering.add( &m_flowingPhase );
if ( m_tableType == RimVfpDefines::TableType::PRODUCTION )
{
uiOrdering.add( &m_tableType );
uiOrdering.add( &m_tableNumber );
uiOrdering.add( &m_referenceDepth );
uiOrdering.add( &m_interpolatedVariable );
uiOrdering.add( &m_flowingPhase );
uiOrdering.add( &m_flowingWaterFraction );
uiOrdering.add( &m_flowingGasFraction );
if ( m_tableType == RimVfpDefines::TableType::PRODUCTION )
{
uiOrdering.add( &m_flowingWaterFraction );
uiOrdering.add( &m_flowingGasFraction );
uiOrdering.add( &m_primaryVariable );
uiOrdering.add( &m_familyVariable );
uiOrdering.add( &m_primaryVariable );
uiOrdering.add( &m_familyVariable );
caf::PdmUiOrdering* fixedVariablesGroup = uiOrdering.addNewGroup( "Fixed Variables" );
fixedVariablesGroup->add( &m_flowRateIdx );
fixedVariablesGroup->add( &m_thpIdx );
fixedVariablesGroup->add( &m_articifialLiftQuantityIdx );
fixedVariablesGroup->add( &m_waterCutIdx );
fixedVariablesGroup->add( &m_gasLiquidRatioIdx );
caf::PdmUiOrdering* fixedVariablesGroup = uiOrdering.addNewGroup( "Fixed Variables" );
fixedVariablesGroup->add( &m_flowRateIdx );
fixedVariablesGroup->add( &m_thpIdx );
fixedVariablesGroup->add( &m_articifialLiftQuantityIdx );
fixedVariablesGroup->add( &m_waterCutIdx );
fixedVariablesGroup->add( &m_gasLiquidRatioIdx );
// Disable the choices for variables as primary or family
setFixedVariableUiEditability( m_flowRateIdx, RimVfpDefines::ProductionVariableType::FLOW_RATE );
setFixedVariableUiEditability( m_thpIdx, RimVfpDefines::ProductionVariableType::THP );
setFixedVariableUiEditability( m_articifialLiftQuantityIdx, RimVfpDefines::ProductionVariableType::ARTIFICIAL_LIFT_QUANTITY );
setFixedVariableUiEditability( m_waterCutIdx, RimVfpDefines::ProductionVariableType::WATER_CUT );
setFixedVariableUiEditability( m_gasLiquidRatioIdx, RimVfpDefines::ProductionVariableType::GAS_LIQUID_RATIO );
}
// Disable the choices for variables as primary or family
setFixedVariableUiEditability( m_flowRateIdx, RimVfpDefines::ProductionVariableType::FLOW_RATE );
setFixedVariableUiEditability( m_thpIdx, RimVfpDefines::ProductionVariableType::THP );
setFixedVariableUiEditability( m_articifialLiftQuantityIdx, RimVfpDefines::ProductionVariableType::ARTIFICIAL_LIFT_QUANTITY );
setFixedVariableUiEditability( m_waterCutIdx, RimVfpDefines::ProductionVariableType::WATER_CUT );
setFixedVariableUiEditability( m_gasLiquidRatioIdx, RimVfpDefines::ProductionVariableType::GAS_LIQUID_RATIO );
}
uiOrdering.skipRemainingFields( true );

View File

@@ -22,7 +22,6 @@
#include "RimVfpDefines.h"
#include "cafFilePath.h"
#include "cafPdmPtrField.h"
#include <QPointer>
@@ -31,6 +30,7 @@
class RiuPlotWidget;
class VfpPlotData;
class RimPlotAxisProperties;
//--------------------------------------------------------------------------------------------------
/// Vertical Flow Performance Plot
@@ -65,6 +65,11 @@ public:
QImage snapshotWindowContent() override;
void zoomAll() override;
void setProductionTable( const Opm::VFPProdTable& table );
void setInjectionTable( const Opm::VFPInjTable& table );
void setDataIsImportedExternally( bool dataIsImportedExternally );
int tableNumber() const;
private:
// RimPlot implementations
void doRemoveFromCollection();
@@ -137,6 +142,14 @@ private:
static QString axisTitle( RimVfpDefines::ProductionVariableType variableType, RimVfpDefines::FlowingPhaseType flowingPhase );
void connectAxisSignals( RimPlotAxisProperties* axis );
void axisSettingsChanged( const caf::SignalEmitter* emitter );
void axisLogarithmicChanged( const caf::SignalEmitter* emitter, bool isLogarithmic );
void updatePlotWidgetFromAxisRanges() override;
void updateAxisRangesFromPlotWidget() override;
void onPlotZoomed();
private:
caf::PdmField<QString> m_plotTitle;
caf::PdmField<caf::FilePath> m_filePath;
@@ -157,7 +170,12 @@ private:
caf::PdmField<int> m_waterCutIdx;
caf::PdmField<int> m_gasLiquidRatioIdx;
caf::PdmChildField<RimPlotAxisProperties*> m_yAxisProperties;
caf::PdmChildField<RimPlotAxisProperties*> m_xAxisProperties;
QPointer<RiuPlotWidget> m_plotWidget;
std::unique_ptr<Opm::VFPProdTable> m_prodTable;
std::unique_ptr<Opm::VFPInjTable> m_injectionTable;
bool m_dataIsImportedExternally;
};

View File

@@ -27,7 +27,9 @@
#include "RimEclipseResultCase.h"
#include "RimProject.h"
#include "RimVfpPlot.h"
#include "RimVfpDeck.h"
#include "cafCmdFeatureMenuBuilder.h"
CAF_PDM_SOURCE_INIT( RimVfpPlotCollection, "RimVfpPlotCollection" );
@@ -39,6 +41,7 @@ RimVfpPlotCollection::RimVfpPlotCollection()
CAF_PDM_InitObject( "VFP Plots", ":/VfpPlotCollection.svg" );
CAF_PDM_InitFieldNoDefault( &m_vfpPlots, "VfpPlots", "Vertical Flow Performance Plots" );
CAF_PDM_InitFieldNoDefault( &m_vfpDecks, "VfpDecks", "Vertical Flow Performance Decks" );
}
//--------------------------------------------------------------------------------------------------
@@ -80,6 +83,22 @@ void RimVfpPlotCollection::deleteChildren()
m_vfpPlots.deleteChildren();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimVfpPlot* RimVfpPlotCollection::plotForTableNumber( int tableNumber ) const
{
for ( auto plot : plots() )
{
if ( plot->tableNumber() == tableNumber )
{
return plot;
}
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -96,3 +115,50 @@ void RimVfpPlotCollection::removePlot( RimVfpPlot* vfpPlot )
m_vfpPlots.removeChild( vfpPlot );
updateAllRequiredEditors();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimVfpDeck* RimVfpPlotCollection::addDeck( const QString& filename )
{
RimVfpDeck* deck = new RimVfpDeck();
deck->setFileName( filename );
m_vfpDecks.push_back( deck );
return deck;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimVfpPlotCollection::onChildrenUpdated( caf::PdmChildArrayFieldHandle* childArray, std::vector<caf::PdmObjectHandle*>& updatedObjects )
{
for ( auto plot : plots() )
{
plot->updateMdiWindowVisibility();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimVfpPlotCollection::loadDataAndUpdateAllPlots()
{
for ( auto plot : plots() )
{
plot->loadDataAndUpdate();
}
for ( auto deck : m_vfpDecks.childrenByType() )
{
deck->loadDataAndUpdate();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimVfpPlotCollection::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const
{
menuBuilder << "RicNewVfpPlotFeature";
}

View File

@@ -23,6 +23,8 @@
#include "cafPdmChildArrayField.h"
#include "cafPdmObject.h"
class RimVfpDeck;
//==================================================================================================
///
///
@@ -38,11 +40,21 @@ public:
void addPlot( RimVfpPlot* newPlot ) override;
std::vector<RimVfpPlot*> plots() const override;
void deleteChildren();
RimVfpPlot* plotForTableNumber( int tableNumber ) const;
size_t plotCount() const final;
void insertPlot( RimVfpPlot* vfpPlot, size_t index ) final;
void removePlot( RimVfpPlot* vfpPlot ) final;
RimVfpDeck* addDeck( const QString& filename );
private:
void loadDataAndUpdateAllPlots() override;
void onChildrenUpdated( caf::PdmChildArrayFieldHandle* childArray, std::vector<caf::PdmObjectHandle*>& updatedObjects ) override;
void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override;
private:
caf::PdmChildArrayField<RimVfpPlot*> m_vfpPlots;
caf::PdmChildArrayField<RimVfpDeck*> m_vfpDecks;
};