2016-12-19 04:23:02 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2019-01-16 07:57:43 -06:00
|
|
|
// Copyright (C) 2017-2018 Statoil ASA
|
|
|
|
// Copyright (C) 2018- Equinor ASA
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2016-12-19 04:23:02 -06: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
|
|
|
//
|
2016-12-19 04:23:02 -06: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>
|
2016-12-19 04:23:02 -06:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2017-02-07 02:09:00 -06:00
|
|
|
#include "RicNewStimPlanFractureTemplateFeature.h"
|
2016-12-19 04:23:02 -06:00
|
|
|
|
|
|
|
#include "RiaApplication.h"
|
|
|
|
|
2018-01-18 04:42:29 -06:00
|
|
|
#include "RimEclipseView.h"
|
2017-02-07 04:08:56 -06:00
|
|
|
#include "RimFractureTemplateCollection.h"
|
2018-01-18 04:42:29 -06:00
|
|
|
#include "RimOilField.h"
|
2016-12-19 04:23:02 -06:00
|
|
|
#include "RimProject.h"
|
2017-02-07 02:09:00 -06:00
|
|
|
#include "RimStimPlanFractureTemplate.h"
|
2019-01-16 07:57:43 -06:00
|
|
|
#include "RimWellPathFracture.h"
|
2016-12-19 04:23:02 -06:00
|
|
|
|
2018-02-27 08:53:33 -06:00
|
|
|
#include "Riu3DMainWindowTools.h"
|
2020-08-21 11:56:44 -05:00
|
|
|
#include "RiuFileDialogTools.h"
|
2017-01-04 03:17:54 -06:00
|
|
|
|
2016-12-19 04:23:02 -06:00
|
|
|
#include "cafSelectionManager.h"
|
|
|
|
|
|
|
|
#include "cvfAssert.h"
|
|
|
|
|
2017-01-02 03:10:45 -06:00
|
|
|
#include <QAction>
|
2020-08-21 11:56:44 -05:00
|
|
|
#include <QFileInfo>
|
2016-12-19 04:23:02 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_CMD_SOURCE_INIT( RicNewStimPlanFractureTemplateFeature, "RicNewStimPlanFractureTemplateFeature" );
|
2016-12-19 04:23:02 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-16 07:57:43 -06:00
|
|
|
///
|
2016-12-19 04:23:02 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicNewStimPlanFractureTemplateFeature::createNewTemplateForFractureAndUpdate( RimFracture* fracture )
|
2019-01-16 07:57:43 -06:00
|
|
|
{
|
|
|
|
std::vector<RimStimPlanFractureTemplate*> newTemplates = createNewTemplates();
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !newTemplates.empty() )
|
2019-01-16 07:57:43 -06:00
|
|
|
{
|
|
|
|
RimStimPlanFractureTemplate* lastTemplateCreated = newTemplates.back();
|
2019-09-06 03:40:57 -05:00
|
|
|
fracture->setFractureTemplate( lastTemplateCreated );
|
|
|
|
|
|
|
|
selectFractureTemplateAndUpdate( lastTemplateCreated );
|
2019-01-16 07:57:43 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicNewStimPlanFractureTemplateFeature::selectFractureTemplateAndUpdate( RimFractureTemplate* fractureTemplate )
|
2016-12-19 04:23:02 -06:00
|
|
|
{
|
2019-01-16 07:57:43 -06:00
|
|
|
fractureTemplate->loadDataAndUpdate();
|
2017-02-23 01:21:45 -06:00
|
|
|
|
2019-01-16 07:57:43 -06:00
|
|
|
RimFractureTemplateCollection* templateCollection = nullptr;
|
2019-09-06 03:40:57 -05:00
|
|
|
fractureTemplate->firstAncestorOrThisOfTypeAsserted( templateCollection );
|
2019-01-16 07:57:43 -06:00
|
|
|
templateCollection->updateConnectedEditors();
|
|
|
|
|
2020-05-12 02:50:38 -05:00
|
|
|
RimProject* project = RimProject::current();
|
2019-01-16 07:57:43 -06:00
|
|
|
|
|
|
|
project->scheduleCreateDisplayModelAndRedrawAllViews();
|
2019-09-06 03:40:57 -05:00
|
|
|
Riu3DMainWindowTools::selectAsCurrentItem( fractureTemplate );
|
2019-01-16 07:57:43 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::vector<RimStimPlanFractureTemplate*> RicNewStimPlanFractureTemplateFeature::createNewTemplates()
|
|
|
|
{
|
|
|
|
RiaApplication* app = RiaApplication::instance();
|
2021-01-15 08:59:06 -06:00
|
|
|
QString defaultDir = app->lastUsedDialogDirectoryWithFallbackToProjectFolder( "STIMPLAN_XML_DIR" );
|
2020-08-21 11:56:44 -05:00
|
|
|
QStringList fileNames = RiuFileDialogTools::getOpenFileNames( nullptr,
|
|
|
|
"Open StimPlan XML File",
|
|
|
|
defaultDir,
|
|
|
|
"StimPlan XML File (*.xml);;All files(*.*)" );
|
2019-01-16 07:57:43 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( fileNames.isEmpty() ) return std::vector<RimStimPlanFractureTemplate*>();
|
2017-02-23 01:21:45 -06:00
|
|
|
|
2020-05-12 02:50:38 -05:00
|
|
|
RimProject* project = RimProject::current();
|
2019-09-06 03:40:57 -05:00
|
|
|
CVF_ASSERT( project );
|
2016-12-19 04:23:02 -06:00
|
|
|
|
|
|
|
RimOilField* oilfield = project->activeOilField();
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( oilfield == nullptr ) return std::vector<RimStimPlanFractureTemplate*>();
|
2016-12-19 04:23:02 -06:00
|
|
|
|
2017-02-07 04:08:56 -06:00
|
|
|
RimFractureTemplateCollection* fracDefColl = oilfield->fractureDefinitionCollection();
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !fracDefColl ) return std::vector<RimStimPlanFractureTemplate*>();
|
2016-12-19 04:23:02 -06:00
|
|
|
|
2019-01-16 07:57:43 -06:00
|
|
|
std::vector<RimStimPlanFractureTemplate*> newFractures;
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( auto fileName : fileNames )
|
2016-12-19 04:23:02 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( fileName.isEmpty() ) continue;
|
2018-07-11 04:22:11 -05:00
|
|
|
|
2017-02-07 02:09:00 -06:00
|
|
|
RimStimPlanFractureTemplate* fractureDef = new RimStimPlanFractureTemplate();
|
2019-09-06 03:40:57 -05:00
|
|
|
fracDefColl->addFractureTemplate( fractureDef );
|
2018-02-15 08:00:09 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
QFileInfo stimplanfileFileInfo( fileName );
|
2019-01-16 07:57:43 -06:00
|
|
|
QString name = stimplanfileFileInfo.baseName();
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( name.isEmpty() )
|
2018-02-15 08:00:09 -06:00
|
|
|
{
|
|
|
|
name = "StimPlan Fracture Template";
|
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
fractureDef->setName( name );
|
2018-02-15 08:00:09 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
fractureDef->setFileName( fileName );
|
2017-02-27 03:49:46 -06:00
|
|
|
fractureDef->loadDataAndUpdate();
|
2017-03-02 04:43:28 -06:00
|
|
|
fractureDef->setDefaultsBasedOnXMLfile();
|
2017-06-08 02:15:50 -05:00
|
|
|
fractureDef->setDefaultWellDiameterFromUnit();
|
2019-09-06 03:40:57 -05:00
|
|
|
newFractures.push_back( fractureDef );
|
2016-12-19 04:23:02 -06:00
|
|
|
}
|
2021-01-15 08:59:06 -06:00
|
|
|
|
|
|
|
app->setLastUsedDialogDirectory( "STIMPLAN_XML_DIR", QFileInfo( fileNames.last() ).absolutePath() );
|
|
|
|
|
2019-01-16 07:57:43 -06:00
|
|
|
return newFractures;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2019-01-16 07:57:43 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicNewStimPlanFractureTemplateFeature::onActionTriggered( bool isChecked )
|
2019-01-16 07:57:43 -06:00
|
|
|
{
|
|
|
|
std::vector<RimStimPlanFractureTemplate*> newFractures = createNewTemplates();
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !newFractures.empty() )
|
2019-02-07 03:10:06 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
selectFractureTemplateAndUpdate( newFractures.back() );
|
2019-02-07 03:10:06 -06:00
|
|
|
}
|
2016-12-19 04:23:02 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2016-12-19 04:23:02 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicNewStimPlanFractureTemplateFeature::setupActionLook( QAction* actionToSetup )
|
2016-12-19 04:23:02 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
actionToSetup->setIcon( QIcon( ":/FractureTemplate16x16.png" ) );
|
|
|
|
actionToSetup->setText( "New StimPlan Fracture Template" );
|
2016-12-19 04:23:02 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2016-12-19 04:23:02 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-02-07 02:09:00 -06:00
|
|
|
bool RicNewStimPlanFractureTemplateFeature::isCommandEnabled()
|
2016-12-19 04:23:02 -06:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|