mirror of
https://github.com/OPM/ResInsight.git
synced 2026-09-03 20:53:13 -05:00
VFP Plots : Select one or multiple files when creating VFP plots
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
#include "RicNewVfpPlotFeature.h"
|
#include "RicNewVfpPlotFeature.h"
|
||||||
|
|
||||||
#include "RiaApplication.h"
|
#include "RiaApplication.h"
|
||||||
|
#include "RiaGuiApplication.h"
|
||||||
|
|
||||||
#include "RimMainPlotCollection.h"
|
#include "RimMainPlotCollection.h"
|
||||||
#include "RimProject.h"
|
#include "RimProject.h"
|
||||||
@@ -29,11 +30,14 @@
|
|||||||
#include "RimWellLogTrack.h"
|
#include "RimWellLogTrack.h"
|
||||||
#include "RimWellPath.h"
|
#include "RimWellPath.h"
|
||||||
|
|
||||||
|
#include "RiuFileDialogTools.h"
|
||||||
|
#include "RiuPlotMainWindow.h"
|
||||||
#include "RiuPlotMainWindowTools.h"
|
#include "RiuPlotMainWindowTools.h"
|
||||||
|
|
||||||
#include "cafSelectionManagerTools.h"
|
#include "cafSelectionManagerTools.h"
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
|
#include <QFileInfo>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -55,16 +59,46 @@ void RicNewVfpPlotFeature::onActionTriggered( bool isChecked )
|
|||||||
{
|
{
|
||||||
RimProject* proj = RiaApplication::instance()->project();
|
RimProject* proj = RiaApplication::instance()->project();
|
||||||
|
|
||||||
|
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 (*.*)" );
|
||||||
|
|
||||||
|
if ( fileNames.isEmpty() ) return;
|
||||||
|
|
||||||
|
app->setLastUsedDialogDirectory( vfpDataKey, QFileInfo( fileNames.last() ).absolutePath() );
|
||||||
|
|
||||||
RimVfpPlotCollection* vfpPlotColl = proj->mainPlotCollection()->vfpPlotCollection();
|
RimVfpPlotCollection* vfpPlotColl = proj->mainPlotCollection()->vfpPlotCollection();
|
||||||
if ( vfpPlotColl )
|
if ( vfpPlotColl )
|
||||||
{
|
{
|
||||||
RimVfpPlot* vfpPlot = new RimVfpPlot();
|
std::vector<RimVfpPlot*> vfpPlots;
|
||||||
vfpPlotColl->addPlot( vfpPlot );
|
for ( const auto& fileName : fileNames )
|
||||||
|
{
|
||||||
|
RimVfpPlot* vfpPlot = new RimVfpPlot();
|
||||||
|
vfpPlot->setFileName( fileName );
|
||||||
|
vfpPlotColl->addPlot( vfpPlot );
|
||||||
|
|
||||||
|
vfpPlots.push_back( vfpPlot );
|
||||||
|
}
|
||||||
|
|
||||||
vfpPlotColl->updateConnectedEditors();
|
vfpPlotColl->updateConnectedEditors();
|
||||||
vfpPlot->loadDataAndUpdate();
|
|
||||||
|
for ( auto plot : vfpPlots )
|
||||||
|
{
|
||||||
|
plot->loadDataAndUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
RiuPlotMainWindowTools::showPlotMainWindow();
|
RiuPlotMainWindowTools::showPlotMainWindow();
|
||||||
RiuPlotMainWindowTools::selectAsCurrentItem( vfpPlot );
|
|
||||||
|
if ( !vfpPlots.empty() )
|
||||||
|
{
|
||||||
|
RiuPlotMainWindowTools::selectAsCurrentItem( vfpPlots.front() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +107,7 @@ void RicNewVfpPlotFeature::onActionTriggered( bool isChecked )
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RicNewVfpPlotFeature::setupActionLook( QAction* actionToSetup )
|
void RicNewVfpPlotFeature::setupActionLook( QAction* actionToSetup )
|
||||||
{
|
{
|
||||||
actionToSetup->setText( "New VFP Plot" );
|
actionToSetup->setText( "New VFP Plots" );
|
||||||
// TODO: add icon
|
// TODO: add icon
|
||||||
// actionToSetup->setIcon( QIcon( ":/VerticalFlowPerformancePlot16x16.png" ) );
|
// actionToSetup->setIcon( QIcon( ":/VerticalFlowPerformancePlot16x16.png" ) );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -164,6 +164,14 @@ RimVfpPlot::~RimVfpPlot()
|
|||||||
deleteViewWidget();
|
deleteViewWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RimVfpPlot::setFileName( const QString& filename )
|
||||||
|
{
|
||||||
|
m_filePath = filename;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ public:
|
|||||||
RimVfpPlot();
|
RimVfpPlot();
|
||||||
~RimVfpPlot() override;
|
~RimVfpPlot() override;
|
||||||
|
|
||||||
|
void setFileName( const QString& filename );
|
||||||
|
|
||||||
// RimPlot implementations
|
// RimPlot implementations
|
||||||
RiuQwtPlotWidget* viewer() override;
|
RiuQwtPlotWidget* viewer() override;
|
||||||
void setAutoScaleXEnabled( bool enabled ) override;
|
void setAutoScaleXEnabled( bool enabled ) override;
|
||||||
|
|||||||
@@ -151,6 +151,7 @@ QString Utils::makeValidFileBasename( const QString& fileBasenameCandidate )
|
|||||||
cleanBasename.replace( "?", "_" );
|
cleanBasename.replace( "?", "_" );
|
||||||
cleanBasename.replace( "*", "_" );
|
cleanBasename.replace( "*", "_" );
|
||||||
cleanBasename.replace( "\n", "_" );
|
cleanBasename.replace( "\n", "_" );
|
||||||
|
cleanBasename.replace( "#", "_" );
|
||||||
|
|
||||||
cleanBasename.replace( QRegExp( "_+" ), "_" );
|
cleanBasename.replace( QRegExp( "_+" ), "_" );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user