2015-08-24 03:40:47 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2015- Statoil ASA
|
|
|
|
// Copyright (C) 2015- Ceetron Solutions AS
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2015-08-24 03:40:47 -05:00
|
|
|
// 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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2015-08-24 03:40:47 -05:00
|
|
|
// 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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2015-08-24 03:40:47 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RicAddEclipseInputPropertyFeature.h"
|
|
|
|
|
|
|
|
#include "RimEclipseInputCase.h"
|
2019-09-06 03:40:57 -05:00
|
|
|
#include "RimEclipseInputPropertyCollection.h"
|
2015-08-24 03:40:47 -05:00
|
|
|
|
|
|
|
#include "RiaApplication.h"
|
2018-02-27 09:37:06 -06:00
|
|
|
#include "Riu3DMainWindowTools.h"
|
2019-09-06 03:40:57 -05:00
|
|
|
|
2015-08-24 03:40:47 -05:00
|
|
|
#include "cafSelectionManager.h"
|
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QFileInfo>
|
2019-09-06 03:40:57 -05:00
|
|
|
#include <QStringList>
|
2015-08-24 03:40:47 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_CMD_SOURCE_INIT( RicAddEclipseInputPropertyFeature, "RicAddEclipseInputPropertyFeature" );
|
2015-08-24 03:40:47 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-08-24 03:40:47 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RicAddEclipseInputPropertyFeature::isCommandEnabled()
|
|
|
|
{
|
2018-02-18 11:56:43 -06:00
|
|
|
return selectedInputPropertyCollection() != nullptr;
|
2015-08-24 03:40:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-08-24 03:40:47 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicAddEclipseInputPropertyFeature::onActionTriggered( bool isChecked )
|
2015-08-24 03:40:47 -05:00
|
|
|
{
|
2018-10-10 02:50:46 -05:00
|
|
|
RimEclipseInputPropertyCollection* inputPropertyCollection = selectedInputPropertyCollection();
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !inputPropertyCollection ) return;
|
2018-10-10 02:50:46 -05:00
|
|
|
|
|
|
|
QString casePath;
|
|
|
|
{
|
|
|
|
RimEclipseInputCase* inputReservoir = nullptr;
|
2019-09-06 03:40:57 -05:00
|
|
|
inputPropertyCollection->firstAncestorOrThisOfTypeAsserted( inputReservoir );
|
2018-10-10 02:50:46 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
QFileInfo fi( inputReservoir->gridFileName() );
|
2018-10-10 02:50:46 -05:00
|
|
|
casePath = fi.absolutePath();
|
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
RiaApplication* app = RiaApplication::instance();
|
|
|
|
QString defaultDir = app->lastUsedDialogDirectoryWithFallback( "INPUT_FILES", casePath );
|
|
|
|
QStringList fileNames = QFileDialog::getOpenFileNames( Riu3DMainWindowTools::mainWindowWidget(),
|
|
|
|
"Select Eclipse Input Property Files",
|
|
|
|
defaultDir,
|
|
|
|
"All Files (*.* *)" );
|
2015-08-24 03:40:47 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( fileNames.isEmpty() ) return;
|
2015-08-24 03:40:47 -05:00
|
|
|
|
|
|
|
// Remember the directory to next time
|
2019-09-06 03:40:57 -05:00
|
|
|
defaultDir = QFileInfo( fileNames.last() ).absolutePath();
|
|
|
|
app->setLastUsedDialogDirectory( "INPUT_FILES", defaultDir );
|
2015-08-24 03:40:47 -05:00
|
|
|
|
2019-11-03 04:43:46 -06:00
|
|
|
addEclipseInputProperty( fileNames, inputPropertyCollection );
|
2015-08-24 03:40:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-08-24 03:40:47 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicAddEclipseInputPropertyFeature::setupActionLook( QAction* actionToSetup )
|
2015-08-24 03:40:47 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
actionToSetup->setText( "Add Input Property" );
|
2015-08-24 03:40:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-08-24 03:40:47 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimEclipseInputPropertyCollection* RicAddEclipseInputPropertyFeature::selectedInputPropertyCollection() const
|
|
|
|
{
|
2018-10-10 02:50:46 -05:00
|
|
|
return caf::SelectionManager::instance()->selectedItemOfType<RimEclipseInputPropertyCollection>();
|
2015-08-24 03:40:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-08-24 03:40:47 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicAddEclipseInputPropertyFeature::addEclipseInputProperty( const QStringList& fileNames,
|
|
|
|
RimEclipseInputPropertyCollection* inputPropertyCollection )
|
2015-08-24 03:40:47 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
CVF_ASSERT( inputPropertyCollection );
|
2015-08-24 03:40:47 -05:00
|
|
|
|
2018-10-10 02:50:46 -05:00
|
|
|
RimEclipseInputCase* inputReservoir = nullptr;
|
2019-09-06 03:40:57 -05:00
|
|
|
inputPropertyCollection->firstAncestorOrThisOfTypeAsserted( inputReservoir );
|
|
|
|
inputReservoir->openDataFileSet( fileNames );
|
2015-08-24 03:40:47 -05:00
|
|
|
|
|
|
|
inputPropertyCollection->updateConnectedEditors();
|
|
|
|
}
|