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"
|
2019-10-30 10:52:25 -05:00
|
|
|
#include "RimEclipseResultCase.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()
|
|
|
|
{
|
2019-10-30 10:52:25 -05:00
|
|
|
return caf::SelectionManager::instance()->selectedItemOfType<RimEclipseInputPropertyCollection>() ||
|
2019-11-05 02:25:35 -06:00
|
|
|
caf::SelectionManager::instance()->selectedItemOfType<RimEclipseInputCase>() ||
|
2019-10-30 10:52:25 -05:00
|
|
|
caf::SelectionManager::instance()->selectedItemOfType<RimEclipseResultCase>();
|
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
|
|
|
{
|
2019-10-30 10:52:25 -05:00
|
|
|
RimEclipseCase* eclipseCase = nullptr;
|
2018-10-10 02:50:46 -05:00
|
|
|
|
2019-10-30 10:52:25 -05:00
|
|
|
RimEclipseInputPropertyCollection* inputPropertyCollection =
|
|
|
|
caf::SelectionManager::instance()->selectedItemOfType<RimEclipseInputPropertyCollection>();
|
|
|
|
if ( !inputPropertyCollection )
|
2018-10-10 02:50:46 -05:00
|
|
|
{
|
2019-11-05 02:25:35 -06:00
|
|
|
// No property collection selected: triggered from RimEclipseInputCase/RimEclipseResultCase.
|
2019-10-30 10:52:25 -05:00
|
|
|
eclipseCase = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseCase>();
|
|
|
|
if ( eclipseCase )
|
|
|
|
{
|
|
|
|
inputPropertyCollection = eclipseCase->inputPropertyCollection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Triggered from collection: get eclipse case ancestor
|
|
|
|
inputPropertyCollection->firstAncestorOrThisOfTypeAsserted( eclipseCase );
|
2018-10-10 02:50:46 -05:00
|
|
|
}
|
|
|
|
|
2019-10-30 10:52:25 -05:00
|
|
|
if ( !inputPropertyCollection || !eclipseCase ) return;
|
|
|
|
|
|
|
|
QFileInfo fi( eclipseCase->gridFileName() );
|
|
|
|
QString 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 );
|
2019-10-30 10:52:25 -05:00
|
|
|
eclipseCase->importAsciiInputProperties( fileNames );
|
|
|
|
inputPropertyCollection->updateConnectedEditors();
|
2019-11-05 05:00:28 -06:00
|
|
|
eclipseCase->updateConnectedEditors();
|
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
|
|
|
}
|