mirror of
https://github.com/OPM/ResInsight.git
synced 2024-12-29 10:21:54 -06:00
VFP Plots : Select one or multiple files when creating VFP plots
This commit is contained in:
parent
3e2ddce10d
commit
44bae5dad6
@ -19,6 +19,7 @@
|
||||
#include "RicNewVfpPlotFeature.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaGuiApplication.h"
|
||||
|
||||
#include "RimMainPlotCollection.h"
|
||||
#include "RimProject.h"
|
||||
@ -29,11 +30,14 @@
|
||||
#include "RimWellLogTrack.h"
|
||||
#include "RimWellPath.h"
|
||||
|
||||
#include "RiuFileDialogTools.h"
|
||||
#include "RiuPlotMainWindow.h"
|
||||
#include "RiuPlotMainWindowTools.h"
|
||||
|
||||
#include "cafSelectionManagerTools.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include <vector>
|
||||
|
||||
@ -55,16 +59,46 @@ void RicNewVfpPlotFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
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();
|
||||
if ( vfpPlotColl )
|
||||
{
|
||||
RimVfpPlot* vfpPlot = new RimVfpPlot();
|
||||
vfpPlotColl->addPlot( vfpPlot );
|
||||
std::vector<RimVfpPlot*> vfpPlots;
|
||||
for ( const auto& fileName : fileNames )
|
||||
{
|
||||
RimVfpPlot* vfpPlot = new RimVfpPlot();
|
||||
vfpPlot->setFileName( fileName );
|
||||
vfpPlotColl->addPlot( vfpPlot );
|
||||
|
||||
vfpPlots.push_back( vfpPlot );
|
||||
}
|
||||
|
||||
vfpPlotColl->updateConnectedEditors();
|
||||
vfpPlot->loadDataAndUpdate();
|
||||
|
||||
for ( auto plot : vfpPlots )
|
||||
{
|
||||
plot->loadDataAndUpdate();
|
||||
}
|
||||
|
||||
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 )
|
||||
{
|
||||
actionToSetup->setText( "New VFP Plot" );
|
||||
actionToSetup->setText( "New VFP Plots" );
|
||||
// TODO: add icon
|
||||
// actionToSetup->setIcon( QIcon( ":/VerticalFlowPerformancePlot16x16.png" ) );
|
||||
}
|
||||
|
@ -164,6 +164,14 @@ RimVfpPlot::~RimVfpPlot()
|
||||
deleteViewWidget();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimVfpPlot::setFileName( const QString& filename )
|
||||
{
|
||||
m_filePath = filename;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -43,6 +43,8 @@ public:
|
||||
RimVfpPlot();
|
||||
~RimVfpPlot() override;
|
||||
|
||||
void setFileName( const QString& filename );
|
||||
|
||||
// RimPlot implementations
|
||||
RiuQwtPlotWidget* viewer() override;
|
||||
void setAutoScaleXEnabled( bool enabled ) override;
|
||||
|
@ -151,6 +151,7 @@ QString Utils::makeValidFileBasename( const QString& fileBasenameCandidate )
|
||||
cleanBasename.replace( "?", "_" );
|
||||
cleanBasename.replace( "*", "_" );
|
||||
cleanBasename.replace( "\n", "_" );
|
||||
cleanBasename.replace( "#", "_" );
|
||||
|
||||
cleanBasename.replace( QRegExp( "_+" ), "_" );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user