ResInsight/ApplicationLibCode/ProjectDataModelCommands/RimcFractureTemplateCollection.cpp
Magne Sjaastad f8c5cf389f
clang-format: Set column width to 140
* Set column width to 140
* Use c++20
* Remove redundant virtual
2023-02-26 10:48:40 +01:00

127 lines
5.9 KiB
C++

/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021- 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.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RimcFractureTemplateCollection.h"
#include "FractureCommands/RicFractureNameGenerator.h"
#include "FractureCommands/RicNewStimPlanFractureTemplateFeature.h"
#include "FractureCommands/RicNewStimPlanModelFeature.h"
#include "FractureCommands/RicNewThermalFractureTemplateFeature.h"
#include "RimEclipseCase.h"
#include "RimFractureTemplate.h"
#include "RimFractureTemplateCollection.h"
#include "RimStimPlanFractureTemplate.h"
#include "RimThermalFractureTemplate.h"
#include "cafPdmAbstractFieldScriptingCapability.h"
#include "cafPdmFieldScriptingCapability.h"
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimFractureTemplateCollection,
RimcFractureTemplateCollection_appendFractureTemplate,
"AppendFractureTemplate" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimcFractureTemplateCollection_appendFractureTemplate::RimcFractureTemplateCollection_appendFractureTemplate( caf::PdmObjectHandle* self )
: caf::PdmObjectMethod( self )
{
CAF_PDM_InitObject( "Create Fracture Template", "", "", "Create a new StimPlan Fracture Template" );
CAF_PDM_InitScriptableFieldNoDefault( &m_filePath, "FilePath", "", "", "", "File Path to StimPlan Countour File" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmObjectHandle* RimcFractureTemplateCollection_appendFractureTemplate::execute()
{
RimFractureTemplateCollection* stimPlanModelTemplateCollection = self<RimFractureTemplateCollection>();
bool reuseExistingTemplatesWithMatchingNames = false;
auto newTemplates =
RicNewStimPlanFractureTemplateFeature::createNewTemplatesFromFiles( { m_filePath }, reuseExistingTemplatesWithMatchingNames );
if ( newTemplates.empty() ) return nullptr;
stimPlanModelTemplateCollection->updateAllRequiredEditors();
return newTemplates[0];
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimcFractureTemplateCollection_appendFractureTemplate::resultIsPersistent() const
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::unique_ptr<caf::PdmObjectHandle> RimcFractureTemplateCollection_appendFractureTemplate::defaultResult() const
{
return std::unique_ptr<caf::PdmObjectHandle>( new RimStimPlanFractureTemplate );
}
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimFractureTemplateCollection,
RimcFractureTemplateCollection_appendThermalFractureTemplate,
"AppendThermalFractureTemplate" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimcFractureTemplateCollection_appendThermalFractureTemplate::RimcFractureTemplateCollection_appendThermalFractureTemplate( caf::PdmObjectHandle* self )
: caf::PdmObjectMethod( self )
{
CAF_PDM_InitObject( "Create Fracture Template", "", "", "Create a new Thermal Fracture Template" );
CAF_PDM_InitScriptableFieldNoDefault( &m_filePath, "FilePath", "", "", "", "File Path to Thermal Fracture CSV File" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmObjectHandle* RimcFractureTemplateCollection_appendThermalFractureTemplate::execute()
{
RimFractureTemplateCollection* fractureTemplateCollection = self<RimFractureTemplateCollection>();
bool reuseExistingTemplatesWithMatchingNames = false;
auto newTemplates =
RicNewThermalFractureTemplateFeature::createNewTemplatesFromFiles( { m_filePath }, reuseExistingTemplatesWithMatchingNames );
if ( newTemplates.empty() ) return nullptr;
fractureTemplateCollection->updateAllRequiredEditors();
return newTemplates[0];
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimcFractureTemplateCollection_appendThermalFractureTemplate::resultIsPersistent() const
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::unique_ptr<caf::PdmObjectHandle> RimcFractureTemplateCollection_appendThermalFractureTemplate::defaultResult() const
{
return std::unique_ptr<caf::PdmObjectHandle>( new RimThermalFractureTemplate );
}