2020-06-12 04:38:20 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2020- 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.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2020-11-04 06:46:17 -06:00
|
|
|
#include "RicExportStimPlanModelToFileFeature.h"
|
2020-06-12 04:38:20 -05:00
|
|
|
|
|
|
|
#include "RiaApplication.h"
|
|
|
|
|
2020-11-04 06:46:17 -06:00
|
|
|
#include "RimStimPlanModel.h"
|
2020-06-12 04:38:20 -05:00
|
|
|
|
2020-09-04 03:23:19 -05:00
|
|
|
#include "RiuFileDialogTools.h"
|
|
|
|
|
2020-11-04 06:46:17 -06:00
|
|
|
#include "RifStimPlanModelExporter.h"
|
2020-06-12 04:38:20 -05:00
|
|
|
|
|
|
|
#include "cafSelectionManager.h"
|
|
|
|
#include "cafUtils.h"
|
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
2020-11-04 06:46:17 -06:00
|
|
|
CAF_CMD_SOURCE_INIT( RicExportStimPlanModelToFileFeature, "RicExportStimPlanModelToFileFeature" );
|
2020-06-12 04:38:20 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-11-04 06:46:17 -06:00
|
|
|
bool RicExportStimPlanModelToFileFeature::isCommandEnabled()
|
2020-06-12 04:38:20 -05:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-11-04 06:46:17 -06:00
|
|
|
void RicExportStimPlanModelToFileFeature::onActionTriggered( bool isChecked )
|
2020-06-12 04:38:20 -05:00
|
|
|
{
|
2020-11-04 06:46:17 -06:00
|
|
|
RimStimPlanModel* stimPlanModel = caf::SelectionManager::instance()->selectedItemOfType<RimStimPlanModel>();
|
|
|
|
if ( !stimPlanModel ) return;
|
|
|
|
if ( !stimPlanModel->stimPlanModelTemplate() ) return;
|
2020-06-12 04:38:20 -05:00
|
|
|
|
|
|
|
RiaApplication* app = RiaApplication::instance();
|
2020-10-19 02:41:05 -05:00
|
|
|
QString defaultDir = app->lastUsedDialogDirectory( "FRACTURE_MODEL_EXPORT" );
|
2020-06-12 04:38:20 -05:00
|
|
|
|
2023-02-26 03:48:40 -06:00
|
|
|
QString directoryPath = RiuFileDialogTools::getExistingDirectory( nullptr, "Select Directory for StimPlan Model Export", defaultDir );
|
2020-06-12 04:38:20 -05:00
|
|
|
|
2020-09-04 03:23:19 -05:00
|
|
|
if ( directoryPath.isEmpty() ) return;
|
2020-06-12 04:38:20 -05:00
|
|
|
|
2020-11-04 06:46:17 -06:00
|
|
|
RifStimPlanModelExporter::writeToDirectory( stimPlanModel, stimPlanModel->useDetailedFluidLoss(), directoryPath );
|
2020-06-12 04:38:20 -05:00
|
|
|
|
|
|
|
// Remember the path to next time
|
2020-10-19 02:41:05 -05:00
|
|
|
app->setLastUsedDialogDirectory( "FRACTURE_MODEL_EXPORT", directoryPath );
|
2020-06-12 04:38:20 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-11-04 06:46:17 -06:00
|
|
|
void RicExportStimPlanModelToFileFeature::setupActionLook( QAction* actionToSetup )
|
2020-06-12 04:38:20 -05:00
|
|
|
{
|
2020-11-04 06:46:17 -06:00
|
|
|
actionToSetup->setText( "Export StimPlan Model to File" );
|
2020-10-01 10:25:19 -05:00
|
|
|
actionToSetup->setIcon( QIcon( ":/Save.svg" ) );
|
2020-06-12 04:38:20 -05:00
|
|
|
}
|