From cb0bc1392dd30ed8f215c104a8210606675afce7 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 20 Jun 2022 13:55:55 +0200 Subject: [PATCH] Thermal Fracture: Add action to import Reveal csv --- .../FractureCommands/CMakeLists_files.cmake | 2 + .../RicMeshFractureTemplateHelper.h | 52 ++++++ .../RicMeshFractureTemplateHelper.inl | 157 ++++++++++++++++++ .../RicNewStimPlanFractureTemplateFeature.cpp | 143 +++++----------- .../RicNewStimPlanFractureTemplateFeature.h | 5 + .../RicNewThermalFractureTemplateFeature.cpp | 131 +++++++++++++++ .../RicNewThermalFractureTemplateFeature.h | 51 ++++++ .../RimContextCommandBuilder.cpp | 3 + 8 files changed, 447 insertions(+), 97 deletions(-) create mode 100644 ApplicationLibCode/Commands/FractureCommands/RicMeshFractureTemplateHelper.h create mode 100644 ApplicationLibCode/Commands/FractureCommands/RicMeshFractureTemplateHelper.inl create mode 100644 ApplicationLibCode/Commands/FractureCommands/RicNewThermalFractureTemplateFeature.cpp create mode 100644 ApplicationLibCode/Commands/FractureCommands/RicNewThermalFractureTemplateFeature.h diff --git a/ApplicationLibCode/Commands/FractureCommands/CMakeLists_files.cmake b/ApplicationLibCode/Commands/FractureCommands/CMakeLists_files.cmake index 02cd25ab68..44b3c832ed 100644 --- a/ApplicationLibCode/Commands/FractureCommands/CMakeLists_files.cmake +++ b/ApplicationLibCode/Commands/FractureCommands/CMakeLists_files.cmake @@ -9,6 +9,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RicNewSimWellFractureAtPosFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicNewSimWellFractureFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicNewStimPlanFractureTemplateFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicNewThermalFractureTemplateFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathFractureAtPosFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathFractureFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicNewStimPlanModelFeature.h @@ -33,6 +34,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RicNewSimWellFractureAtPosFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewSimWellFractureFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewStimPlanFractureTemplateFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicNewThermalFractureTemplateFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathFractureAtPosFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathFractureFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewStimPlanModelFeature.cpp diff --git a/ApplicationLibCode/Commands/FractureCommands/RicMeshFractureTemplateHelper.h b/ApplicationLibCode/Commands/FractureCommands/RicMeshFractureTemplateHelper.h new file mode 100644 index 0000000000..3659f41780 --- /dev/null +++ b/ApplicationLibCode/Commands/FractureCommands/RicMeshFractureTemplateHelper.h @@ -0,0 +1,52 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022- 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include + +#include + +class RimFracture; +class RimFractureTemplate; +class RimThermalFractureTemplate; + +//================================================================================================== +/// +//================================================================================================== +template +class RicMeshFractureTemplateHelper +{ +public: + static void createNewTemplateForFractureAndUpdate( RimFracture* fracture, + const QString& title, + const QString& lastUsedDialogFallback, + const QString& fileFilter, + const QString& defaultTemplateName ); + + static void selectFractureTemplateAndUpdate( RimFractureTemplate* fractureTemplate ); + static std::vector createNewTemplatesFromFiles( const std::vector& fileNames, + const QString& defaultTemplateName, + bool reuseExistingTemplatesWithMatchingNames = false ); + static std::vector createNewTemplates( const QString& title, + const QString& lastUsedDialogFallback, + const QString& fileFilter, + const QString& defaultTemplateName ); +}; + +#include "RicMeshFractureTemplateHelper.inl" diff --git a/ApplicationLibCode/Commands/FractureCommands/RicMeshFractureTemplateHelper.inl b/ApplicationLibCode/Commands/FractureCommands/RicMeshFractureTemplateHelper.inl new file mode 100644 index 0000000000..990245c210 --- /dev/null +++ b/ApplicationLibCode/Commands/FractureCommands/RicMeshFractureTemplateHelper.inl @@ -0,0 +1,157 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022- 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiaApplication.h" + +#include "RimEclipseView.h" +#include "RimFractureTemplateCollection.h" +#include "RimOilField.h" +#include "RimProject.h" +#include "RimThermalFractureTemplate.h" +#include "RimWellPathFracture.h" + +#include "Riu3DMainWindowTools.h" +#include "RiuFileDialogTools.h" + +#include "cafSelectionManager.h" + +#include "cvfAssert.h" + +#include +#include +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +template +void RicMeshFractureTemplateHelper::createNewTemplateForFractureAndUpdate( RimFracture* fracture, + const QString& title, + const QString& lastUsedDialogFallback, + const QString& fileFilter, + const QString& defaultTemplateName ) +{ + std::vector newTemplates = createNewTemplates( title, lastUsedDialogFallback, fileFilter, defaultTemplateName ); + if ( !newTemplates.empty() ) + { + T* lastTemplateCreated = newTemplates.back(); + fracture->setFractureTemplate( lastTemplateCreated ); + + selectFractureTemplateAndUpdate( lastTemplateCreated ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +template +void RicMeshFractureTemplateHelper::selectFractureTemplateAndUpdate( RimFractureTemplate* fractureTemplate ) +{ + fractureTemplate->loadDataAndUpdate(); + + RimFractureTemplateCollection* templateCollection = nullptr; + fractureTemplate->firstAncestorOrThisOfTypeAsserted( templateCollection ); + templateCollection->updateConnectedEditors(); + + RimProject* project = RimProject::current(); + + project->scheduleCreateDisplayModelAndRedrawAllViews(); + Riu3DMainWindowTools::selectAsCurrentItem( fractureTemplate ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +template +std::vector RicMeshFractureTemplateHelper::createNewTemplates( const QString& title, + const QString& lastUsedDialogFallback, + const QString& fileFilter, + const QString& defaultTemplateName ) +{ + RiaApplication* app = RiaApplication::instance(); + QString defaultDir = app->lastUsedDialogDirectoryWithFallbackToProjectFolder( lastUsedDialogFallback ); + QStringList fileNames = RiuFileDialogTools::getOpenFileNames( nullptr, title, defaultDir, fileFilter ); + + auto templates = + createNewTemplatesFromFiles( std::vector( fileNames.begin(), fileNames.end() ), defaultTemplateName ); + + if ( !fileNames.isEmpty() ) + { + app->setLastUsedDialogDirectory( lastUsedDialogFallback, QFileInfo( fileNames.last() ).absolutePath() ); + } + + return templates; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +template +std::vector RicMeshFractureTemplateHelper::createNewTemplatesFromFiles( const std::vector& fileNames, + const QString& defaultTemplateName, + bool reuseExistingTemplatesWithMatchingNames ) +{ + if ( fileNames.empty() ) return std::vector(); + + RimProject* project = RimProject::current(); + CVF_ASSERT( project ); + + RimOilField* oilfield = project->activeOilField(); + if ( oilfield == nullptr ) return std::vector(); + + RimFractureTemplateCollection* fracDefColl = oilfield->fractureDefinitionCollection(); + if ( !fracDefColl ) return std::vector(); + + auto findTemplateByName = []( RimFractureTemplateCollection* coll, const QString& name ) -> T* { + for ( auto t : coll->fractureTemplates() ) + if ( t->name() == name ) return dynamic_cast( t ); + + return nullptr; + }; + + std::vector newFractures; + for ( auto fileName : fileNames ) + { + if ( fileName.isEmpty() ) continue; + + QFileInfo stimplanfileFileInfo( fileName ); + QString name = stimplanfileFileInfo.baseName(); + if ( name.isEmpty() ) + { + name = defaultTemplateName; + } + + T* fractureDef = nullptr; + if ( reuseExistingTemplatesWithMatchingNames ) fractureDef = findTemplateByName( fracDefColl, name ); + + if ( fractureDef == nullptr ) + { + fractureDef = new T(); + fracDefColl->addFractureTemplate( fractureDef ); + fractureDef->setName( name ); + } + + fractureDef->setFileName( fileName ); + fractureDef->loadDataAndUpdate(); + fractureDef->setDefaultsBasedOnFile(); + fractureDef->setDefaultWellDiameterFromUnit(); + newFractures.push_back( fractureDef ); + } + + return newFractures; +} diff --git a/ApplicationLibCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.cpp b/ApplicationLibCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.cpp index a1c93f796f..c632fc890e 100644 --- a/ApplicationLibCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.cpp +++ b/ApplicationLibCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.cpp @@ -19,24 +19,10 @@ #include "RicNewStimPlanFractureTemplateFeature.h" -#include "RiaApplication.h" +#include "RicMeshFractureTemplateHelper.h" -#include "RimEclipseView.h" -#include "RimFractureTemplateCollection.h" -#include "RimOilField.h" -#include "RimProject.h" #include "RimStimPlanFractureTemplate.h" -#include "RimWellPathFracture.h" -#include "Riu3DMainWindowTools.h" -#include "RiuFileDialogTools.h" - -#include "cafSelectionManager.h" - -#include "cvfAssert.h" - -#include -#include #include CAF_CMD_SOURCE_INIT( RicNewStimPlanFractureTemplateFeature, "RicNewStimPlanFractureTemplateFeature" ); @@ -46,14 +32,11 @@ CAF_CMD_SOURCE_INIT( RicNewStimPlanFractureTemplateFeature, "RicNewStimPlanFract //-------------------------------------------------------------------------------------------------- void RicNewStimPlanFractureTemplateFeature::createNewTemplateForFractureAndUpdate( RimFracture* fracture ) { - std::vector newTemplates = createNewTemplates(); - if ( !newTemplates.empty() ) - { - RimStimPlanFractureTemplate* lastTemplateCreated = newTemplates.back(); - fracture->setFractureTemplate( lastTemplateCreated ); - - selectFractureTemplateAndUpdate( lastTemplateCreated ); - } + RicMeshFractureTemplateHelper::createNewTemplateForFractureAndUpdate( fracture, + title(), + lastUsedDialogFallback(), + fileFilter(), + defaultTemplateName() ); } //-------------------------------------------------------------------------------------------------- @@ -61,16 +44,7 @@ void RicNewStimPlanFractureTemplateFeature::createNewTemplateForFractureAndUpdat //-------------------------------------------------------------------------------------------------- void RicNewStimPlanFractureTemplateFeature::selectFractureTemplateAndUpdate( RimFractureTemplate* fractureTemplate ) { - fractureTemplate->loadDataAndUpdate(); - - RimFractureTemplateCollection* templateCollection = nullptr; - fractureTemplate->firstAncestorOrThisOfTypeAsserted( templateCollection ); - templateCollection->updateConnectedEditors(); - - RimProject* project = RimProject::current(); - - project->scheduleCreateDisplayModelAndRedrawAllViews(); - Riu3DMainWindowTools::selectAsCurrentItem( fractureTemplate ); + RicMeshFractureTemplateHelper::selectFractureTemplateAndUpdate( fractureTemplate ); } //-------------------------------------------------------------------------------------------------- @@ -78,21 +52,10 @@ void RicNewStimPlanFractureTemplateFeature::selectFractureTemplateAndUpdate( Rim //-------------------------------------------------------------------------------------------------- std::vector RicNewStimPlanFractureTemplateFeature::createNewTemplates() { - RiaApplication* app = RiaApplication::instance(); - QString defaultDir = app->lastUsedDialogDirectoryWithFallbackToProjectFolder( "STIMPLAN_XML_DIR" ); - QStringList fileNames = RiuFileDialogTools::getOpenFileNames( nullptr, - "Open StimPlan XML File", - defaultDir, - "StimPlan XML File (*.xml);;All files(*.*)" ); - - auto templates = createNewTemplatesFromFiles( std::vector( fileNames.begin(), fileNames.end() ) ); - - if ( !fileNames.isEmpty() ) - { - app->setLastUsedDialogDirectory( "STIMPLAN_XML_DIR", QFileInfo( fileNames.last() ).absolutePath() ); - } - - return templates; + return RicMeshFractureTemplateHelper::createNewTemplates( title(), + lastUsedDialogFallback(), + fileFilter(), + defaultTemplateName() ); } //-------------------------------------------------------------------------------------------------- @@ -102,55 +65,9 @@ std::vector RicNewStimPlanFractureTemplateFeature::createNewTemplatesFromFiles( const std::vector& fileNames, bool reuseExistingTemplatesWithMatchingNames ) { - if ( fileNames.empty() ) return std::vector(); - - RimProject* project = RimProject::current(); - CVF_ASSERT( project ); - - RimOilField* oilfield = project->activeOilField(); - if ( oilfield == nullptr ) return std::vector(); - - RimFractureTemplateCollection* fracDefColl = oilfield->fractureDefinitionCollection(); - if ( !fracDefColl ) return std::vector(); - - auto findTemplateByName = []( RimFractureTemplateCollection* coll, - const QString& name ) -> RimStimPlanFractureTemplate* { - for ( auto t : coll->fractureTemplates() ) - if ( t->name() == name ) return dynamic_cast( t ); - - return nullptr; - }; - - std::vector newFractures; - for ( auto fileName : fileNames ) - { - if ( fileName.isEmpty() ) continue; - - QFileInfo stimplanfileFileInfo( fileName ); - QString name = stimplanfileFileInfo.baseName(); - if ( name.isEmpty() ) - { - name = "StimPlan Fracture Template"; - } - - RimStimPlanFractureTemplate* fractureDef = nullptr; - if ( reuseExistingTemplatesWithMatchingNames ) fractureDef = findTemplateByName( fracDefColl, name ); - - if ( fractureDef == nullptr ) - { - fractureDef = new RimStimPlanFractureTemplate(); - fracDefColl->addFractureTemplate( fractureDef ); - fractureDef->setName( name ); - } - - fractureDef->setFileName( fileName ); - fractureDef->loadDataAndUpdate(); - fractureDef->setDefaultsBasedOnFile(); - fractureDef->setDefaultWellDiameterFromUnit(); - newFractures.push_back( fractureDef ); - } - - return newFractures; + return RicMeshFractureTemplateHelper::createNewTemplatesFromFiles( fileNames, + defaultTemplateName(), + reuseExistingTemplatesWithMatchingNames ); } //-------------------------------------------------------------------------------------------------- @@ -181,3 +98,35 @@ bool RicNewStimPlanFractureTemplateFeature::isCommandEnabled() { return true; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicNewStimPlanFractureTemplateFeature::fileFilter() +{ + return "StimPlan XML File (*.xml);;All files(*.*)"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicNewStimPlanFractureTemplateFeature::title() +{ + return "Open StimPlan XML File"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicNewStimPlanFractureTemplateFeature::lastUsedDialogFallback() +{ + return "STIMPLAN_XML_DIR"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicNewStimPlanFractureTemplateFeature::defaultTemplateName() +{ + return "StimPlan Fracture Template"; +} diff --git a/ApplicationLibCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.h b/ApplicationLibCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.h index 80b4d33ace..f2482a5d8f 100644 --- a/ApplicationLibCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.h +++ b/ApplicationLibCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.h @@ -44,4 +44,9 @@ protected: void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; bool isCommandEnabled() override; + + static QString fileFilter(); + static QString title(); + static QString defaultTemplateName(); + static QString lastUsedDialogFallback(); }; diff --git a/ApplicationLibCode/Commands/FractureCommands/RicNewThermalFractureTemplateFeature.cpp b/ApplicationLibCode/Commands/FractureCommands/RicNewThermalFractureTemplateFeature.cpp new file mode 100644 index 0000000000..689766406e --- /dev/null +++ b/ApplicationLibCode/Commands/FractureCommands/RicNewThermalFractureTemplateFeature.cpp @@ -0,0 +1,131 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022- 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicNewThermalFractureTemplateFeature.h" + +#include "RicMeshFractureTemplateHelper.h" + +#include "RimThermalFractureTemplate.h" + +#include + +CAF_CMD_SOURCE_INIT( RicNewThermalFractureTemplateFeature, "RicNewThermalFractureTemplateFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewThermalFractureTemplateFeature::createNewTemplateForFractureAndUpdate( RimFracture* fracture ) +{ + RicMeshFractureTemplateHelper::createNewTemplateForFractureAndUpdate( fracture, + title(), + lastUsedDialogFallback(), + fileFilter(), + defaultTemplateName() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewThermalFractureTemplateFeature::selectFractureTemplateAndUpdate( RimFractureTemplate* fractureTemplate ) +{ + RicMeshFractureTemplateHelper::selectFractureTemplateAndUpdate( fractureTemplate ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RicNewThermalFractureTemplateFeature::createNewTemplates() +{ + return RicMeshFractureTemplateHelper::createNewTemplates( title(), + lastUsedDialogFallback(), + fileFilter(), + defaultTemplateName() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector + RicNewThermalFractureTemplateFeature::createNewTemplatesFromFiles( const std::vector& fileNames, + bool reuseExistingTemplatesWithMatchingNames ) +{ + return RicMeshFractureTemplateHelper::createNewTemplatesFromFiles( fileNames, + defaultTemplateName(), + reuseExistingTemplatesWithMatchingNames ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewThermalFractureTemplateFeature::onActionTriggered( bool isChecked ) +{ + std::vector newFractures = createNewTemplates(); + if ( !newFractures.empty() ) + { + selectFractureTemplateAndUpdate( newFractures.back() ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewThermalFractureTemplateFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setIcon( QIcon( ":/FractureTemplate16x16.png" ) ); + actionToSetup->setText( "New Thermal Fracture Template" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicNewThermalFractureTemplateFeature::isCommandEnabled() +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicNewThermalFractureTemplateFeature::fileFilter() +{ + return "Reveal Open-Server Files (*.csv);;All files (*.*)"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicNewThermalFractureTemplateFeature::title() +{ + return "Open Thermal Fracture File"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicNewThermalFractureTemplateFeature::lastUsedDialogFallback() +{ + return "REVEAL_CSV_DIR"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicNewThermalFractureTemplateFeature::defaultTemplateName() +{ + return "Thermal Fracture Template"; +} diff --git a/ApplicationLibCode/Commands/FractureCommands/RicNewThermalFractureTemplateFeature.h b/ApplicationLibCode/Commands/FractureCommands/RicNewThermalFractureTemplateFeature.h new file mode 100644 index 0000000000..d2790d9b5f --- /dev/null +++ b/ApplicationLibCode/Commands/FractureCommands/RicNewThermalFractureTemplateFeature.h @@ -0,0 +1,51 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022- 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +#include + +class RimFracture; +class RimFractureTemplate; +class RimThermalFractureTemplate; + +//================================================================================================== +/// +//================================================================================================== +class RicNewThermalFractureTemplateFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + static void createNewTemplateForFractureAndUpdate( RimFracture* fracture ); + static void selectFractureTemplateAndUpdate( RimFractureTemplate* fractureTemplate ); + static std::vector + createNewTemplatesFromFiles( const std::vector& fileNames, + bool reuseExistingTemplatesWithMatchingNames = false ); + +protected: + static std::vector createNewTemplates(); + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; + bool isCommandEnabled() override; + + static QString fileFilter(); + static QString title(); + static QString defaultTemplateName(); + static QString lastUsedDialogFallback(); +}; diff --git a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp index 2663b6a066..7a979e476e 100644 --- a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -954,6 +954,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder.addSeparator(); menuBuilder << "RicNewEllipseFractureTemplateFeature"; menuBuilder << "RicNewStimPlanFractureTemplateFeature"; + menuBuilder << "RicNewThermalFractureTemplateFeature"; menuBuilder << "Separator"; menuBuilder << "RicConvertAllFractureTemplatesToMetricFeature"; menuBuilder << "RicConvertAllFractureTemplatesToFieldFeature"; @@ -965,6 +966,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder.addSeparator(); menuBuilder << "RicNewEllipseFractureTemplateFeature"; menuBuilder << "RicNewStimPlanFractureTemplateFeature"; + menuBuilder << "RicNewThermalFractureTemplateFeature"; menuBuilder << "Separator"; menuBuilder << "RicConvertFractureTemplateUnitFeature"; } @@ -975,6 +977,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder.addSeparator(); menuBuilder << "RicNewEllipseFractureTemplateFeature"; menuBuilder << "RicNewStimPlanFractureTemplateFeature"; + menuBuilder << "RicNewThermalFractureTemplateFeature"; menuBuilder << "Separator"; menuBuilder << "RicConvertFractureTemplateUnitFeature"; }