diff --git a/ApplicationLibCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.cpp b/ApplicationLibCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.cpp index 4092bfd06c..6d5424577f 100644 --- a/ApplicationLibCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.cpp +++ b/ApplicationLibCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.cpp @@ -37,6 +37,7 @@ #include #include +#include CAF_CMD_SOURCE_INIT( RicNewStimPlanFractureTemplateFeature, "RicNewStimPlanFractureTemplateFeature" ); @@ -84,7 +85,23 @@ std::vector RicNewStimPlanFractureTemplateFeature: defaultDir, "StimPlan XML File (*.xml);;All files(*.*)" ); - if ( fileNames.isEmpty() ) return std::vector(); + auto templates = createNewTemplatesFromFiles( fileNames.toVector().toStdVector() ); + + if ( !fileNames.isEmpty() ) + { + app->setLastUsedDialogDirectory( "STIMPLAN_XML_DIR", QFileInfo( fileNames.last() ).absolutePath() ); + } + + return templates; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector + RicNewStimPlanFractureTemplateFeature::createNewTemplatesFromFiles( const std::vector& fileNames ) +{ + if ( fileNames.empty() ) return std::vector(); RimProject* project = RimProject::current(); CVF_ASSERT( project ); @@ -119,8 +136,6 @@ std::vector RicNewStimPlanFractureTemplateFeature: newFractures.push_back( fractureDef ); } - app->setLastUsedDialogDirectory( "STIMPLAN_XML_DIR", QFileInfo( fileNames.last() ).absolutePath() ); - return newFractures; } diff --git a/ApplicationLibCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.h b/ApplicationLibCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.h index ad30a88ae2..475595494e 100644 --- a/ApplicationLibCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.h +++ b/ApplicationLibCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.h @@ -35,6 +35,7 @@ class RicNewStimPlanFractureTemplateFeature : 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 ); protected: static std::vector createNewTemplates();