#9100 Thermal Fracture: add action to place using template data

This commit is contained in:
Kristian Bendiksen 2022-08-25 15:10:23 +02:00
parent 2691f6dca9
commit 96c4d48c9d
6 changed files with 167 additions and 0 deletions

View File

@ -21,6 +21,7 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RicCreateMultipleFracturesUi.h
${CMAKE_CURRENT_LIST_DIR}/RicNewOptionItemFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicDeleteOptionItemFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicPlaceThermalFractureUsingTemplateDataFeature.h
)
set(SOURCE_GROUP_SOURCE_FILES
@ -46,6 +47,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RicCreateMultipleFracturesUi.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewOptionItemFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicDeleteOptionItemFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicPlaceThermalFractureUsingTemplateDataFeature.cpp
)
list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})

View File

@ -0,0 +1,106 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicPlaceThermalFractureUsingTemplateDataFeature.h"
#include "RiaLogging.h"
#include "RigWellPath.h"
#include "RimProject.h"
#include "RimThermalFractureTemplate.h"
#include "RimWellPath.h"
#include "RimWellPathFracture.h"
#include "cafSelectionManager.h"
#include "cvfAssert.h"
#include <QAction>
#include <cmath>
CAF_CMD_SOURCE_INIT( RicPlaceThermalFractureUsingTemplateDataFeature, "RicPlaceThermalFractureUsingTemplateDataFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPlaceThermalFractureUsingTemplateDataFeature::onActionTriggered( bool isChecked )
{
RimWellPathFracture* fracture = RicPlaceThermalFractureUsingTemplateDataFeature::selectedThermalFracture();
if ( !fracture ) return;
if ( !fracture->fractureTemplate() ) return;
RimThermalFractureTemplate* thermalTemplate = dynamic_cast<RimThermalFractureTemplate*>( fracture->fractureTemplate() );
if ( !thermalTemplate ) return;
RimWellPath* wellPath = nullptr;
fracture->firstAncestorOrThisOfTypeAsserted( wellPath );
auto wellPathGeometry = wellPath->wellPathGeometry();
if ( !wellPathGeometry ) return;
auto [centerPosition, rotation] = thermalTemplate->computePositionAndRotation();
// TODO: y conversion is workaround for strange test data
centerPosition.y() = std::fabs( centerPosition.y() );
centerPosition.z() *= -1.0;
double md = wellPathGeometry->closestMeasuredDepth( centerPosition );
RiaLogging::info( QString( "Placing thermal fracture. Posotion: [%1 %2 %3]" )
.arg( centerPosition.x() )
.arg( centerPosition.y() )
.arg( centerPosition.z() ) );
RiaLogging::info( QString( "Computed MD: %1" ).arg( md ) );
fracture->setMeasuredDepth( md );
fracture->updateConnectedEditors();
RimProject* project = RimProject::current();
project->reloadCompletionTypeResultsInAllViews();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPlaceThermalFractureUsingTemplateDataFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Place Using Template Data" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicPlaceThermalFractureUsingTemplateDataFeature::isCommandEnabled()
{
return selectedThermalFracture() != nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellPathFracture* RicPlaceThermalFractureUsingTemplateDataFeature::selectedThermalFracture()
{
auto fracture = caf::SelectionManager::instance()->selectedItemOfType<RimWellPathFracture>();
if ( !fracture->fractureTemplate() ) return nullptr;
RimThermalFractureTemplate* thermalTemplate = dynamic_cast<RimThermalFractureTemplate*>( fracture->fractureTemplate() );
if ( !thermalTemplate ) return nullptr;
return fracture;
}

View File

@ -0,0 +1,39 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafCmdFeature.h"
class RimWellPathFracture;
//==================================================================================================
///
//==================================================================================================
class RicPlaceThermalFractureUsingTemplateDataFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
bool isCommandEnabled() override;
private:
static RimWellPathFracture* selectedThermalFracture();
};

View File

@ -689,3 +689,19 @@ QString RimThermalFractureTemplate::wellPathDepthAtFractureUiName() const
{
return "Well/Fracture Intersection Depth";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::pair<cvf::Vec3d, cvf::Vec3d> RimThermalFractureTemplate::computePositionAndRotation() const
{
cvf::Vec3d centerPosition = cvf::Vec3d::UNDEFINED;
cvf::Vec3d rotation = cvf::Vec3d::UNDEFINED;
if ( m_fractureDefinitionData )
{
centerPosition = m_fractureDefinitionData->centerPosition();
}
return std::make_pair( centerPosition, rotation );
}

View File

@ -100,6 +100,8 @@ public:
static std::pair<QString, QString>
widthParameterNameAndUnit( std::shared_ptr<RigThermalFractureDefinition> fractureDefinitionData );
std::pair<cvf::Vec3d, cvf::Vec3d> computePositionAndRotation() const;
protected:
QString getFileSelectionFilter() const override;
QStringList conductivityResultNames() const override;

View File

@ -457,6 +457,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
dynamic_cast<RimWellPathFracture*>( firstUiItem ) )
{
menuBuilder << "RicNewWellPathFractureFeature";
if ( dynamic_cast<RimWellPathFracture*>( firstUiItem ) )
menuBuilder << "RicPlaceThermalFractureUsingTemplateDataFeature";
appendExportCompletions( menuBuilder );
}
else if ( dynamic_cast<RimWellPathAttributeCollection*>( firstUiItem ) )