From 254cd196f9792001730b94d41f7976264f7f7047 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Herje?= Date: Thu, 4 May 2023 16:30:13 +0200 Subject: [PATCH] Backup --- .../GeoMech/CMakeLists_files.cmake | 2 + .../RimGeoMechFaultReactivationResult.cpp | 172 ++++++++++++++++++ .../RimGeoMechFaultReactivationResult.h | 54 ++++++ .../GeoMech/RimGeoMechView.cpp | 6 + .../ProjectDataModel/GeoMech/RimGeoMechView.h | 2 + .../WellPath/RimWellPathGeometryDef.cpp | 2 +- .../WellPath/RimWellPathGeometryDef.h | 2 +- 7 files changed, 238 insertions(+), 2 deletions(-) create mode 100644 ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechFaultReactivationResult.cpp create mode 100644 ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechFaultReactivationResult.h diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/GeoMech/CMakeLists_files.cmake index c634b8a2b3..09273eece6 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/CMakeLists_files.cmake +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/CMakeLists_files.cmake @@ -9,6 +9,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RimGeoMechContourMapViewCollection.h ${CMAKE_CURRENT_LIST_DIR}/RimGeoMechPartCollection.h ${CMAKE_CURRENT_LIST_DIR}/RimGeoMechPart.h + ${CMAKE_CURRENT_LIST_DIR}/RimGeoMechFaultReactivationResult.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -22,6 +23,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RimGeoMechContourMapViewCollection.cpp ${CMAKE_CURRENT_LIST_DIR}/RimGeoMechPartCollection.cpp ${CMAKE_CURRENT_LIST_DIR}/RimGeoMechPart.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimGeoMechFaultReactivationResult.cpp ) list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechFaultReactivationResult.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechFaultReactivationResult.cpp new file mode 100644 index 0000000000..f87433075c --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechFaultReactivationResult.cpp @@ -0,0 +1,172 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2023- 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 "RimGeoMechFaultReactivationResult.h" + +#include "RiaApplication.h" + +#include "RimGeoMechCase.h" +#include "RimGeoMechView.h" +#include "RimGridView.h" +#include "RimIntersectionCollection.h" +#include "RimModeledWellPath.h" +#include "RimWellPathGeometryDef.h" + +#include "RimOilField.h" +#include "RimProject.h" +#include "RimWellPathCollection.h" + +#include "cafPdmFieldScriptingCapability.h" +#include "cafPdmObjectScriptingCapability.h" +#include "cafPdmUiPushButtonEditor.h" + +CAF_PDM_SOURCE_INIT( RimGeoMechFaultReactivationResult, "RimGeoMechFaultReactivationResult" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGeoMechFaultReactivationResult::RimGeoMechFaultReactivationResult() +{ + // TODO: Update icon + CAF_PDM_InitObject( "Fault Reactivation Result", ":/GeoMechCase24x24.png" ); + + CAF_PDM_InitFieldNoDefault( &m_intersection, "Intersection", "Intersection" ); + + CAF_PDM_InitField( &m_wellDistanceFromIntersection, "FaceDistanceFromIntersection", 0.0, "Face Distance From Intersection" ); + CAF_PDM_InitField( &m_wellWidthOutsideIntersection, "FaceWidthOutsideIntersection", 0.0, "Face Width Outside Intersection" ); + + CAF_PDM_InitFieldNoDefault( &m_createFaultReactivationResult, "CreateReactivationResult", "" ); + caf::PdmUiPushButtonEditor::configureEditorForField( &m_createFaultReactivationResult ); + + setDeletable( false ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGeoMechFaultReactivationResult::~RimGeoMechFaultReactivationResult() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimGeoMechFaultReactivationResult::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) +{ + QList options; + + if ( fieldNeedingOptions == &m_intersection ) + { + RimGridView* activeView = RiaApplication::instance()->activeGridView(); + if ( !activeView || !activeView->intersectionCollection() ) return options; + + for ( auto* intersection : activeView->intersectionCollection()->intersections() ) + { + // Only utilize polyline intersections? + if ( intersection && intersection->type() == RimExtrudedCurveIntersection::CrossSectionEnum::CS_POLYLINE ) + options.push_back( caf::PdmOptionItemInfo( intersection->name(), intersection ) ); + } + } + + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechFaultReactivationResult::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +{ + caf::PdmUiGroup* group = uiOrdering.addNewGroup( "Fault Reactivation Result" ); + group->add( &m_intersection ); + group->add( &m_wellDistanceFromIntersection ); + group->add( &m_wellWidthOutsideIntersection ); + group->add( &m_createFaultReactivationResult ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechFaultReactivationResult::fieldChangedByUi( const caf::PdmFieldHandle* changedField, + const QVariant& oldValue, + const QVariant& newValue ) +{ + if ( changedField == &m_createFaultReactivationResult && m_intersection() ) + { + // Using first two points from first polyline + const auto polyLines = m_intersection()->polyLines(); + if ( polyLines.size() != 1 || polyLines[0].size() != 2 ) return; + + const std::vector wellPoints = { polyLines[0][0], polyLines[0][1] }; + + RimModeledWellPath* faceAWellPath = new RimModeledWellPath; + RimModeledWellPath* faceBWellPath = new RimModeledWellPath; + auto* faceAWellPathGeometryDef = faceAWellPath->geometryDefinition(); + auto* faceBWellPathGeometryDef = faceBWellPath->geometryDefinition(); + + if ( !faceAWellPathGeometryDef || !faceBWellPathGeometryDef ) return; + + faceAWellPath->setName( "Fault Face A Well" ); + faceBWellPath->setName( "Fault Face B Well" ); + + faceAWellPathGeometryDef->createAndInsertTargets( wellPoints ); + faceBWellPathGeometryDef->createAndInsertTargets( wellPoints ); + faceAWellPathGeometryDef->setUseAutoGeneratedTargetAtSeaLevel( false ); + faceBWellPathGeometryDef->setUseAutoGeneratedTargetAtSeaLevel( false ); + faceAWellPath->createWellPathGeometry(); + faceBWellPath->createWellPathGeometry(); + + RimWellPathCollection* wellPathCollection = RimProject::current()->activeOilField()->wellPathCollection(); + if ( wellPathCollection ) + { + wellPathCollection->addWellPath( faceAWellPath ); + wellPathCollection->addWellPath( faceBWellPath ); + + wellPathCollection->uiCapability()->updateConnectedEditors(); + + RimProject::current()->scheduleCreateDisplayModelAndRedrawAllViews(); + } + + // Add well paths to internal storage? + // Apply m_wellDistanceFromIntersection and m_wellWidthOutsideIntersection for adjustement of well paths + // Find vector normal onto intersection plane, i.e. cross product of z-axis and wellpath angle + // Create vector from first and last point in well paths/ wellPoints and use w/ z-axis to create normal vector with cross product + } + // if ( changedField == objectToggleField() ) + //{ + // RimGeoMechView* ownerView; + // firstAncestorOrThisOfType( ownerView ); + // if ( ownerView ) ownerView->scheduleCreateDisplayModelAndRedraw(); + // } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechFaultReactivationResult::defineEditorAttribute( const caf::PdmFieldHandle* field, + QString uiConfigName, + caf::PdmUiEditorAttribute* attribute ) +{ + if ( field == &m_createFaultReactivationResult ) + { + caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast( attribute ); + if ( attrib ) + { + attrib->m_buttonText = "Apply"; + } + } +} diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechFaultReactivationResult.h b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechFaultReactivationResult.h new file mode 100644 index 0000000000..01c4f5c6a0 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechFaultReactivationResult.h @@ -0,0 +1,54 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2023- 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 "RimCheckableNamedObject.h" +#include "RimExtrudedCurveIntersection.h" +#include "RimIntersectionResultsDefinitionCollection.h" + +#include "cafPdmField.h" +#include "cafPdmObject.h" +#include "cafPdmPtrField.h" + +#include "cvfVector3.h" + +#include + +class RimGeoMechFaultReactivationResult : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimGeoMechFaultReactivationResult(); + ~RimGeoMechFaultReactivationResult() override; + +private: + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; + void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; + +private: + caf::PdmPtrField m_intersection; + + caf::PdmField m_createFaultReactivationResult; + + // TODO: Remove "well" from name? + caf::PdmField m_wellDistanceFromIntersection; // To move wells to each side of intersection + caf::PdmField m_wellWidthOutsideIntersection; // To stretch well points outside intersection +}; diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp index b8bf48e775..f62eab6c53 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp @@ -37,6 +37,7 @@ #include "RimEclipseView.h" #include "RimGeoMechCase.h" #include "RimGeoMechCellColors.h" +#include "RimGeoMechFaultReactivationResult.h" #include "RimGeoMechPart.h" #include "RimGeoMechPartCollection.h" #include "RimGeoMechPropertyFilterCollection.h" @@ -98,6 +99,9 @@ RimGeoMechView::RimGeoMechView() m_tensorResults = new RimTensorResults(); m_tensorResults.uiCapability()->setUiTreeHidden( true ); + CAF_PDM_InitFieldNoDefault( &m_faultReactivationResult, "FaultReactivationResult", "Fault Reactivation Result" ); + m_faultReactivationResult = new RimGeoMechFaultReactivationResult(); + CAF_PDM_InitFieldNoDefault( &m_propertyFilterCollection, "PropertyFilters", "Property Filters" ); m_propertyFilterCollection = new RimGeoMechPropertyFilterCollection(); m_propertyFilterCollection.uiCapability()->setUiTreeHidden( true ); @@ -132,6 +136,7 @@ RimGeoMechView::~RimGeoMechView() delete m_tensorResults; delete cellResult; delete m_propertyFilterCollection; + delete m_faultReactivationResult; } //-------------------------------------------------------------------------------------------------- @@ -1051,6 +1056,7 @@ void RimGeoMechView::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrderin uiTreeOrdering.add( m_tensorResults() ); uiTreeOrdering.add( m_cellFilterCollection() ); uiTreeOrdering.add( m_propertyFilterCollection() ); + uiTreeOrdering.add( m_faultReactivationResult() ); addRequiredUiTreeObjects( uiTreeOrdering ); diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.h b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.h index c6b87fa3ef..d6842831cd 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.h +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.h @@ -37,6 +37,7 @@ class Rim3dOverlayInfoConfig; class RimCellRangeFilterCollection; class RimGeoMechCase; class RimGeoMechCellColors; +class RimGeoMechFaultReactivationResult; class RimGeoMechPartCollection; class RimGeoMechPropertyFilterCollection; class RimGeoMechResultDefinition; @@ -150,6 +151,7 @@ private: caf::PdmChildField m_tensorResults; caf::PdmChildField m_propertyFilterCollection; + caf::PdmChildField m_faultReactivationResult; caf::PdmPointer m_overridePropertyFilterCollection; caf::PdmChildField m_partsCollection; caf::PdmPointer m_geomechCase; diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathGeometryDef.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathGeometryDef.cpp index d5cc6628eb..c90d213d01 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathGeometryDef.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathGeometryDef.cpp @@ -236,7 +236,7 @@ void RimWellPathGeometryDef::setFixedMeasuredDepths( const std::vector& //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimWellPathGeometryDef::createTargets( const std::vector& points ) +std::vector RimWellPathGeometryDef::createAndInsertTargets( const std::vector& points ) { CAF_ASSERT( points.size() >= 2u ); diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathGeometryDef.h b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathGeometryDef.h index 8bc5a9a959..d76ad00e7d 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathGeometryDef.h +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathGeometryDef.h @@ -66,7 +66,7 @@ public: void setFixedWellPathPoints( const std::vector& points ); void setFixedMeasuredDepths( const std::vector& mds ); - std::vector createTargets( const std::vector& points ); + std::vector createAndInsertTargets( const std::vector& points ); std::pair findActiveTargetsAroundInsertionPoint( const RimWellPathTarget* targetToInsertBefore );