From fb71a5a056229bd85bdec7b52c171a471e7e524c Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 19 Feb 2024 09:59:34 +0100 Subject: [PATCH 01/23] Prototype polygon editor as child object of cell filter --- .../RicNewPolygonFilter3dviewFeature.cpp | 4 +- .../RicNewPolygonFilterFeature.cpp | 5 +- .../RicNewPolygonFileFeature.cpp | 2 +- .../WellPathCommands/CMakeLists_files.cmake | 2 - .../RicAppendPointsToPolygonFilterFeature.cpp | 83 ---- .../RicAppendPointsToPolygonFilterFeature.h | 34 -- .../RivCellFilterPartMgr.cpp | 38 +- .../ModelVisualization/RivCellFilterPartMgr.h | 12 +- .../CellFilters/RimCellFilterCollection.cpp | 1 + .../CellFilters/RimPolygonFilter.cpp | 430 ++++++------------ .../CellFilters/RimPolygonFilter.h | 83 ++-- 11 files changed, 199 insertions(+), 495 deletions(-) delete mode 100644 ApplicationLibCode/Commands/WellPathCommands/RicAppendPointsToPolygonFilterFeature.cpp delete mode 100644 ApplicationLibCode/Commands/WellPathCommands/RicAppendPointsToPolygonFilterFeature.h diff --git a/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilter3dviewFeature.cpp b/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilter3dviewFeature.cpp index 52db3a8110..1c1c6b1082 100644 --- a/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilter3dviewFeature.cpp +++ b/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilter3dviewFeature.cpp @@ -18,6 +18,8 @@ #include "RicNewPolygonFilter3dviewFeature.h" +#include "Polygons/RimPolygonInView.h" + #include "RiaApplication.h" #include "RimCase.h" #include "RimCellFilterCollection.h" @@ -49,7 +51,7 @@ void RicNewPolygonFilter3dviewFeature::onActionTriggered( bool isChecked ) RimPolygonFilter* lastCreatedOrUpdated = filtColl->addNewPolygonFilter( sourceCase ); if ( lastCreatedOrUpdated ) { - Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated ); + Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated->polygonEditor() ); } } diff --git a/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.cpp b/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.cpp index 4e8ba926b2..3c40d0dfc8 100644 --- a/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.cpp +++ b/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.cpp @@ -18,9 +18,12 @@ #include "RicNewPolygonFilterFeature.h" +#include "Polygons/RimPolygonInView.h" + #include "RimCase.h" #include "RimCellFilterCollection.h" #include "RimPolygonFilter.h" + #include "Riu3DMainWindowTools.h" #include "cafSelectionManagerTools.h" @@ -46,7 +49,7 @@ void RicNewPolygonFilterFeature::onActionTriggered( bool isChecked ) RimPolygonFilter* lastCreatedOrUpdated = filtColl->addNewPolygonFilter( sourceCase ); if ( lastCreatedOrUpdated ) { - Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated ); + Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated->polygonEditor() ); } } diff --git a/ApplicationLibCode/Commands/PolygonCommands/RicNewPolygonFileFeature.cpp b/ApplicationLibCode/Commands/PolygonCommands/RicNewPolygonFileFeature.cpp index 5a5a681fbe..3c061583d2 100644 --- a/ApplicationLibCode/Commands/PolygonCommands/RicNewPolygonFileFeature.cpp +++ b/ApplicationLibCode/Commands/PolygonCommands/RicNewPolygonFileFeature.cpp @@ -1,6 +1,6 @@ //////////////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2022 Equinor ASA +// Copyright (C) 2024 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 diff --git a/ApplicationLibCode/Commands/WellPathCommands/CMakeLists_files.cmake b/ApplicationLibCode/Commands/WellPathCommands/CMakeLists_files.cmake index 57cb2f675e..e8720d49b1 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/CMakeLists_files.cmake +++ b/ApplicationLibCode/Commands/WellPathCommands/CMakeLists_files.cmake @@ -30,7 +30,6 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPointTangentManipulatorPartMgr.h ${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPolyline3dEditor.h ${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPolylineTarget3dEditor.h - ${CMAKE_CURRENT_LIST_DIR}/RicAppendPointsToPolygonFilterFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicDuplicateWellPathFeature.h ) @@ -66,7 +65,6 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPointTangentManipulatorPartMgr.cpp ${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPolyline3dEditor.cpp ${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPolylineTarget3dEditor.cpp - ${CMAKE_CURRENT_LIST_DIR}/RicAppendPointsToPolygonFilterFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicDuplicateWellPathFeature.cpp ) diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicAppendPointsToPolygonFilterFeature.cpp b/ApplicationLibCode/Commands/WellPathCommands/RicAppendPointsToPolygonFilterFeature.cpp deleted file mode 100644 index 05908fcacd..0000000000 --- a/ApplicationLibCode/Commands/WellPathCommands/RicAppendPointsToPolygonFilterFeature.cpp +++ /dev/null @@ -1,83 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// 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 -// for more details. -// -///////////////////////////////////////////////////////////////////////////////// - -#include "RicAppendPointsToPolygonFilterFeature.h" - -#include "RiaTextStringTools.h" - -#include "RimPolygonFilter.h" -#include "RimPolylineTarget.h" - -#include "OperationsUsingObjReferences/RicPasteFeatureImpl.h" - -#include "cafSelectionManager.h" -#include "cafSelectionManagerTools.h" - -#include -#include - -CAF_CMD_SOURCE_INIT( RicAppendPointsToPolygonFilterFeature, "RicAppendPointsToPolygonFilterFeature" ); - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RicAppendPointsToPolygonFilterFeature::isCommandEnabled() const -{ - auto obj = caf::firstAncestorOfTypeFromSelectedObject(); - return obj != nullptr; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicAppendPointsToPolygonFilterFeature::onActionTriggered( bool isChecked ) -{ - auto polygonFilter = caf::firstAncestorOfTypeFromSelectedObject(); - if ( !polygonFilter ) return; - - QStringList listOfThreeDoubles; - - QClipboard* clipboard = QApplication::clipboard(); - if ( clipboard ) - { - QString content = clipboard->text(); - listOfThreeDoubles = RiaTextStringTools::splitSkipEmptyParts( content, "\n" ); - } - - std::vector points; - caf::PdmValueFieldSpecialization>::setFromVariant( listOfThreeDoubles, points ); - - for ( const auto& p : points ) - { - auto newTarget = new RimPolylineTarget; - newTarget->setAsPointTargetXYD( p ); - polygonFilter->insertTarget( nullptr, newTarget ); - } - - polygonFilter->updateEditorsAndVisualization(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicAppendPointsToPolygonFilterFeature::setupActionLook( QAction* actionToSetup ) -{ - actionToSetup->setText( "Append Points from Clipboard" ); - - RicPasteFeatureImpl::setIconAndShortcuts( actionToSetup ); -} diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicAppendPointsToPolygonFilterFeature.h b/ApplicationLibCode/Commands/WellPathCommands/RicAppendPointsToPolygonFilterFeature.h deleted file mode 100644 index 35cee0a6c5..0000000000 --- a/ApplicationLibCode/Commands/WellPathCommands/RicAppendPointsToPolygonFilterFeature.h +++ /dev/null @@ -1,34 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// 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 -// for more details. -// -///////////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include "cafCmdFeature.h" - -//================================================================================================== -/// -//================================================================================================== -class RicAppendPointsToPolygonFilterFeature : public caf::CmdFeature -{ - CAF_CMD_HEADER_INIT; - -protected: - bool isCommandEnabled() const override; - void onActionTriggered( bool isChecked ) override; - void setupActionLook( QAction* actionToSetup ) override; -}; diff --git a/ApplicationLibCode/ModelVisualization/RivCellFilterPartMgr.cpp b/ApplicationLibCode/ModelVisualization/RivCellFilterPartMgr.cpp index e8d82cd12f..3e16517cd8 100644 --- a/ApplicationLibCode/ModelVisualization/RivCellFilterPartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/RivCellFilterPartMgr.cpp @@ -22,8 +22,6 @@ #include "RimCellFilterCollection.h" #include "RimPolygonFilter.h" -#include "RivPolylinePartMgr.h" - #include "cafPdmObject.h" //-------------------------------------------------------------------------------------------------- @@ -34,55 +32,23 @@ RivCellFilterPartMgr::RivCellFilterPartMgr( Rim3dView* view ) { } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RivCellFilterPartMgr::~RivCellFilterPartMgr() -{ -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RivCellFilterPartMgr::appendGeometryPartsToModel( cvf::ModelBasicList* model, const caf::DisplayCoordTransform* displayCoordTransform, const cvf::BoundingBox& boundingBox ) -{ - createCellFilterPartManagers(); - - for ( auto& partMgr : m_cellFilterPartMgrs ) - { - partMgr->appendDynamicGeometryPartsToModel( model, displayCoordTransform, boundingBox ); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RivCellFilterPartMgr::createCellFilterPartManagers() { std::vector colls = m_rimView->descendantsIncludingThisOfType(); if ( colls.empty() ) return; auto coll = colls.front(); - clearGeometryCache(); - for ( auto filter : coll->filters() ) { - RimPolygonFilter* polyFilter = dynamic_cast( filter ); - if ( polyFilter ) + if ( auto polyFilter = dynamic_cast( filter ) ) { - RivPolylinePartMgr* ppm = new RivPolylinePartMgr( m_rimView, polyFilter, coll ); - m_cellFilterPartMgrs.push_back( ppm ); + polyFilter->appendPartsToModel( model, displayCoordTransform, boundingBox ); } } } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RivCellFilterPartMgr::clearGeometryCache() -{ - m_cellFilterPartMgrs.clear(); -} diff --git a/ApplicationLibCode/ModelVisualization/RivCellFilterPartMgr.h b/ApplicationLibCode/ModelVisualization/RivCellFilterPartMgr.h index a58d0d1916..38d4608915 100644 --- a/ApplicationLibCode/ModelVisualization/RivCellFilterPartMgr.h +++ b/ApplicationLibCode/ModelVisualization/RivCellFilterPartMgr.h @@ -19,8 +19,6 @@ #pragma once #include "cafPdmPointer.h" -#include "cvfAssert.h" -#include "cvfCollection.h" #include "cvfObject.h" namespace cvf @@ -37,24 +35,16 @@ class DisplayCoordTransform; } class Rim3dView; -class RivPolylinePartMgr; class RivCellFilterPartMgr : public cvf::Object { public: RivCellFilterPartMgr( Rim3dView* view ); - ~RivCellFilterPartMgr() override; void appendGeometryPartsToModel( cvf::ModelBasicList* model, const caf::DisplayCoordTransform* displayCoordTransform, const cvf::BoundingBox& boundingBox ); - void clearGeometryCache(); - -private: - void createCellFilterPartManagers(); - private: - caf::PdmPointer m_rimView; - cvf::Collection m_cellFilterPartMgrs; + caf::PdmPointer m_rimView; }; diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp index debe2ba6f7..0ffae32dba 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp @@ -260,6 +260,7 @@ RimPolygonFilter* RimCellFilterCollection::addNewPolygonFilter( RimCase* srcCase RimPolygonFilter* pFilter = new RimPolygonFilter(); pFilter->setCase( srcCase ); addFilter( pFilter ); + pFilter->configurePolygonEditor(); pFilter->enablePicking( true ); onFilterUpdated( pFilter ); return pFilter; diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp index c68963a176..bc57049cb8 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp @@ -20,39 +20,23 @@ #include "RigCellGeometryTools.h" #include "RigEclipseCaseData.h" -#include "RigFemPart.h" #include "RigFemPartCollection.h" #include "RigFemPartGrid.h" #include "RigGeoMechCaseData.h" #include "RigMainGrid.h" -#include "RigPolyLinesData.h" #include "RigReservoirGridTools.h" -#include "Rim3dView.h" -#include "RimCase.h" -#include "RimCellFilterCollection.h" +#include "Polygons/RimPolygon.h" +#include "Polygons/RimPolygonInView.h" #include "RimEclipseCase.h" #include "RimGeoMechCase.h" #include "RimPolylineTarget.h" +#include "RimTools.h" -#include "WellPathCommands/PointTangentManipulator/RicPolyline3dEditor.h" -#include "WellPathCommands/RicPolylineTargetsPickEventHandler.h" +#include "Riu3DMainWindowTools.h" -#include "RiuViewerCommands.h" - -#include "RiaStdStringTools.h" - -#include "cafCmdFeatureMenuBuilder.h" -#include "cafPdmUiLineEditor.h" #include "cafPdmUiPushButtonEditor.h" -#include "cafPdmUiTableViewEditor.h" #include "cafPdmUiTreeOrdering.h" -#include - -#include "cvfBoundingBox.h" -#include "cvfStructGrid.h" - -#include #include @@ -77,42 +61,6 @@ void caf::AppEnum::setUp() } // namespace caf -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -class ThicknessValidator : public QValidator -{ -public: - State validate( QString& input, int& pos ) const override - { - if ( input.isEmpty() ) return State::Intermediate; - - int val = RiaStdStringTools::toInt( input.toStdString() ); - if ( val > 0 && val < 8 ) - return State::Acceptable; - else - return State::Invalid; - } -}; - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -class RadiusValidator : public QValidator -{ -public: - State validate( QString& input, int& pos ) const override - { - if ( input.isEmpty() ) return State::Intermediate; - - double val = RiaStdStringTools::toDouble( input.toStdString() ); - if ( val > 0.001 && val <= 2.0 ) - return State::Acceptable; - else - return State::Invalid; - } -}; - CAF_PDM_SOURCE_INIT( RimPolygonFilter, "PolygonFilter", "PolyLineFilter" ); //-------------------------------------------------------------------------------------------------- @@ -120,7 +68,6 @@ CAF_PDM_SOURCE_INIT( RimPolygonFilter, "PolygonFilter", "PolyLineFilter" ); //-------------------------------------------------------------------------------------------------- RimPolygonFilter::RimPolygonFilter() : RimCellFilter( RimCellFilter::INDEX ) - , m_pickTargetsEventHandler( new RicPolylineTargetsPickEventHandler( this ) ) , m_intervalTool( true ) { CAF_PDM_InitObject( "Polyline Filter", ":/CellFilter_Polygon.png" ); @@ -129,39 +76,25 @@ RimPolygonFilter::RimPolygonFilter() CAF_PDM_InitFieldNoDefault( &m_polyIncludeType, "PolyIncludeType", "Cells to include" ); - CAF_PDM_InitField( &m_enablePicking, "EnablePicking", false, "" ); - caf::PdmUiPushButtonEditor::configureEditorForField( &m_enablePicking ); - m_enablePicking.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosType::HIDDEN ); - - CAF_PDM_InitFieldNoDefault( &m_targets, "Targets", "Targets" ); - m_targets.uiCapability()->setUiEditorTypeName( caf::PdmUiTableViewEditor::uiEditorTypeName() ); - m_targets.uiCapability()->setUiTreeChildrenHidden( true ); - m_targets.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); - m_targets.uiCapability()->setCustomContextMenuEnabled( true ); + CAF_PDM_InitFieldNoDefault( &m_internalPolygon, "InternalPolygon", "Polygon For Filter" ); + m_internalPolygon = new RimPolygon; + m_internalPolygon->setName( "Polygon For Filter" ); + m_internalPolygon->uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitField( &m_showLines, "ShowLines", true, "Show Lines" ); - CAF_PDM_InitField( &m_showSpheres, "ShowSpheres", false, "Show Spheres" ); - CAF_PDM_InitField( &m_closePolygon, "ClosePolygon", true, "Closed Polygon" ); + CAF_PDM_InitFieldNoDefault( &m_cellFilterPolygon, "Polygon", "Polygon" ); + m_cellFilterPolygon = m_internalPolygon; - CAF_PDM_InitField( &m_lineThickness, "LineThickness", 3, "Line Thickness" ); - CAF_PDM_InitField( &m_sphereRadiusFactor, "SphereRadiusFactor", 0.15, "Sphere Radius Factor" ); - - CAF_PDM_InitField( &m_lineColor, "LineColor", cvf::Color3f( cvf::Color3f::WHITE ), "Line Color" ); - CAF_PDM_InitField( &m_sphereColor, "SphereColor", cvf::Color3f( cvf::Color3f::WHITE ), "Sphere Color" ); + CAF_PDM_InitFieldNoDefault( &m_polygonEditor, "PolygonEditor", "Polygon Editor" ); + m_polygonEditor = new RimPolygonInView; CAF_PDM_InitField( &m_enableFiltering, "EnableFiltering", false, "Enable Filter" ); CAF_PDM_InitField( &m_enableKFilter, "EnableKFilter", false, "Enable K Range Filter" ); CAF_PDM_InitFieldNoDefault( &m_kFilterStr, "KRangeFilter", "K Range Filter", "", "Example: 2,4-6,10-20:2", "" ); - CAF_PDM_InitField( &m_polygonPlaneDepth, "PolygonPlaneDepth", 0.0, "Polygon Plane Depth" ); - CAF_PDM_InitField( &m_lockPolygonToPlane, "LockPolygon", false, "Lock Polygon to Plane" ); - - m_polygonPlaneDepth.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); - m_polygonPlaneDepth.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosType::TOP ); - - setUi3dEditorTypeName( RicPolyline3dEditor::uiEditorTypeName() ); - uiCapability()->setUiTreeChildrenHidden( true ); + CAF_PDM_InitField( &m_editPolygonButton, "EditPolygonButton", false, "Edit" ); + m_editPolygonButton.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); + m_editPolygonButton.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); m_propagateToSubGrids = false; @@ -169,31 +102,6 @@ RimPolygonFilter::RimPolygonFilter() setDeletable( true ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimPolygonFilter::~RimPolygonFilter() -{ -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimPolygonFilter::updateVisualization() -{ - updateCells(); - filterChanged.send(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimPolygonFilter::updateEditorsAndVisualization() -{ - updateConnectedEditors(); - updateVisualization(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -238,32 +146,11 @@ QString RimPolygonFilter::fullName() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimPolygonFilter::activeTargets() const -{ - return m_targets.childrenByType(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimPolygonFilter::insertTarget( const RimPolylineTarget* targetToInsertBefore, RimPolylineTarget* targetToInsert ) +void RimPolygonFilter::initAfterRead() { - size_t index = m_targets.indexOf( targetToInsertBefore ); - if ( index < m_targets.size() ) - m_targets.insert( index, targetToInsert ); - else - m_targets.push_back( targetToInsert ); - - updateCells(); -} + RimCellFilter::initAfterRead(); -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimPolygonFilter::deleteTarget( RimPolylineTarget* targetToDelete ) -{ - m_targets.removeChild( targetToDelete ); - delete targetToDelete; + configurePolygonEditor(); } //-------------------------------------------------------------------------------------------------- @@ -271,83 +158,13 @@ void RimPolygonFilter::deleteTarget( RimPolylineTarget* targetToDelete ) //-------------------------------------------------------------------------------------------------- void RimPolygonFilter::defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) { - if ( field == &m_enablePicking ) + if ( field == &m_editPolygonButton ) { - auto* pbAttribute = dynamic_cast( attribute ); - if ( pbAttribute ) + if ( auto attrib = dynamic_cast( attribute ) ) { - if ( !m_enablePicking ) - { - pbAttribute->m_buttonText = "Start Picking Points"; - } - else - { - pbAttribute->m_buttonText = "Stop Picking Points"; - } - } - } - else if ( field == &m_targets ) - { - auto tvAttribute = dynamic_cast( attribute ); - if ( tvAttribute ) - { - tvAttribute->resizePolicy = caf::PdmUiTableViewEditorAttribute::RESIZE_TO_FIT_CONTENT; - - if ( m_enablePicking ) - { - tvAttribute->baseColor.setRgb( 255, 220, 255 ); - tvAttribute->alwaysEnforceResizePolicy = true; - } + attrib->m_buttonText = "Edit"; } } - else if ( field == &m_lineThickness ) - { - auto myAttr = dynamic_cast( attribute ); - if ( myAttr ) - { - myAttr->validator = new ThicknessValidator(); - } - } - else if ( field == &m_lineThickness ) - { - auto myAttr = dynamic_cast( attribute ); - if ( myAttr ) - { - myAttr->validator = new RadiusValidator(); - } - } - else if ( field == &m_polygonPlaneDepth ) - { - auto* attr = dynamic_cast( attribute ); - - if ( attr ) - { - if ( m_srcCase ) - { - auto bb = m_srcCase->allCellsBoundingBox(); - attr->m_minimum = -bb.max().z(); - attr->m_maximum = -bb.min().z(); - } - else - { - attr->m_minimum = 0; - attr->m_maximum = 10000; - } - } - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimPolygonFilter::defineCustomContextMenu( const caf::PdmFieldHandle* fieldNeedingMenu, QMenu* menu, QWidget* fieldEditorWidget ) -{ - caf::CmdFeatureMenuBuilder menuBuilder; - - menuBuilder << "RicDeletePolylineTargetFeature"; - menuBuilder << "RicAppendPointsToPolygonFilterFeature"; - - menuBuilder.appendToMenu( menu ); } //-------------------------------------------------------------------------------------------------- @@ -360,32 +177,23 @@ void RimPolygonFilter::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin auto group = uiOrdering.addNewGroup( "General" ); group->add( &m_filterMode ); group->add( &m_enableFiltering ); - group->add( &m_closePolygon ); + + uiOrdering.add( &m_cellFilterPolygon ); + if ( m_cellFilterPolygon() != m_internalPolygon() ) + { + uiOrdering.add( &m_editPolygonButton, { .newRow = false } ); + } auto group1 = uiOrdering.addNewGroup( "Polygon Selection" ); group1->add( &m_polyFilterMode ); - if ( m_closePolygon() ) group1->add( &m_polyIncludeType ); - group1->add( &m_targets ); - group1->add( &m_enablePicking ); - m_polyIncludeType.uiCapability()->setUiName( "Cells to " + modeString() ); - - auto group2 = uiOrdering.addNewGroup( "Appearance" ); - group2->add( &m_showLines ); - group2->add( &m_showSpheres ); - if ( m_showLines ) - { - group2->add( &m_lineThickness ); - group2->add( &m_lineColor ); - } - if ( m_showSpheres ) + bool isPolygonClosed = m_cellFilterPolygon() ? m_cellFilterPolygon->isClosed() : false; + if ( isPolygonClosed ) { - group2->add( &m_sphereRadiusFactor ); - group2->add( &m_sphereColor ); + group1->add( &m_polyIncludeType ); } - group2->add( &m_lockPolygonToPlane ); - if ( m_lockPolygonToPlane ) group2->add( &m_polygonPlaneDepth ); - group2->setCollapsedByDefault(); + + m_polyIncludeType.uiCapability()->setUiName( "Cells to " + modeString() ); auto group3 = uiOrdering.addNewGroup( "Advanced Filter Settings" ); group3->add( &m_enableKFilter ); @@ -402,7 +210,7 @@ void RimPolygonFilter::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin objField->uiCapability()->setUiReadOnly( readOnlyState ); } - if ( !m_closePolygon() ) + if ( !isPolygonClosed ) { m_polyFilterMode = RimPolygonFilter::PolygonFilterModeType::INDEX_K; m_polyFilterMode.uiCapability()->setUiReadOnly( true ); @@ -416,52 +224,76 @@ void RimPolygonFilter::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimPolygonFilter::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) +void RimPolygonFilter::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= "" */ ) { - if ( changedField == &m_enablePicking ) - { - updateConnectedEditors(); + RimCellFilter::defineUiTreeOrdering( uiTreeOrdering, uiConfigName ); - enableFilter( !m_enablePicking() ); - filterChanged.send(); - } - else if ( ( changedField == &m_showLines ) || ( changedField == &m_showSpheres ) || ( changedField == &m_sphereColor ) || - ( changedField == &m_sphereRadiusFactor ) || ( changedField == &m_lineThickness ) || ( changedField == &m_lineColor ) || - ( changedField == &m_lockPolygonToPlane ) || ( changedField == &m_polygonPlaneDepth ) ) - { - filterChanged.send(); - } - else if ( changedField != &m_name ) + bool showPolygonEditor = ( m_cellFilterPolygon() == m_internalPolygon() ); + + if ( showPolygonEditor ) { - updateCells(); - filterChanged.send(); - updateIconState(); + uiTreeOrdering.add( m_polygonEditor() ); } + + uiTreeOrdering.skipRemainingChildren(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimPolygonFilter::enablePicking( bool enable ) +QList RimPolygonFilter::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { - m_enablePicking = enable; - updateConnectedEditors(); + QList options; + if ( fieldNeedingOptions == &m_cellFilterPolygon ) + { + RimTools::polygonOptionItems( &options ); + if ( !options.empty() ) + { + options.push_front( caf::PdmOptionItemInfo( "Project Polygons", nullptr ) ); + } + + options.push_front( + caf::PdmOptionItemInfo( m_internalPolygon()->name(), m_internalPolygon(), false, m_internalPolygon->uiIconProvider() ) ); + } + + return options; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimPolygonFilter::pickingEnabled() const +void RimPolygonFilter::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) { - return m_enablePicking(); + if ( changedField == &m_editPolygonButton ) + { + if ( m_cellFilterPolygon() ) Riu3DMainWindowTools::selectAsCurrentItem( m_cellFilterPolygon() ); + + m_editPolygonButton = false; + + return; + } + + if ( changedField == &m_cellFilterPolygon ) + { + configurePolygonEditor(); + updateAllRequiredEditors(); + } + + if ( changedField != &m_name ) + { + updateCells(); + filterChanged.send(); + updateIconState(); + } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PickEventHandler* RimPolygonFilter::pickEventHandler() const +void RimPolygonFilter::enablePicking( bool enable ) { - return m_pickTargetsEventHandler.get(); + m_polygonEditor->enablePicking( enable ); + updateConnectedEditors(); } //-------------------------------------------------------------------------------------------------- @@ -583,7 +415,7 @@ void RimPolygonFilter::updateCellsKIndexEclipse( const std::vector& const int gIdx = static_cast( grid->gridIndex() ); std::list foundCells; - const bool closedPolygon = m_closePolygon(); + const bool closedPolygon = isPolygonClosed(); // find all cells in the K layer that matches the polygon #pragma omp parallel for @@ -591,8 +423,8 @@ void RimPolygonFilter::updateCellsKIndexEclipse( const std::vector& { for ( size_t j = 0; j < grid->cellCountJ(); j++ ) { - size_t cellIdx = grid->cellIndexFromIJK( i, j, K ); - RigCell cell = grid->cell( cellIdx ); + size_t cellIdx = grid->cellIndexFromIJK( i, j, K ); + const RigCell& cell = grid->cell( cellIdx ); // valid cell? if ( cell.isInvalid() ) continue; @@ -634,7 +466,7 @@ void RimPolygonFilter::updateCellsKIndexEclipse( const std::vector& // get the cell index size_t newIdx = grid->cellIndexFromIJK( ci, cj, k ); // valid cell? - RigCell cell = grid->cell( newIdx ); + const RigCell& cell = grid->cell( newIdx ); if ( cell.isInvalid() ) continue; m_cells[gIdx].push_back( newIdx ); @@ -652,7 +484,7 @@ void RimPolygonFilter::updateCellsForEclipse( const std::vector& poi if ( m_polyFilterMode == PolygonFilterModeType::DEPTH_Z ) { - if ( !m_closePolygon() ) return; + if ( !isPolygonClosed() ) return; for ( size_t gridIndex = 0; gridIndex < data->gridCount(); gridIndex++ ) { @@ -720,7 +552,7 @@ void RimPolygonFilter::updateCellsDepthGeoMech( const std::vector& p //-------------------------------------------------------------------------------------------------- void RimPolygonFilter::updateCellsKIndexGeoMech( const std::vector& points, const RigFemPartGrid* grid, int partId ) { - const bool closedPolygon = m_closePolygon(); + const bool closedPolygon = isPolygonClosed(); // we need to find the K layer we hit with the first point size_t nk; @@ -839,7 +671,7 @@ void RimPolygonFilter::updateCellsForGeoMech( const std::vector& poi if ( m_polyFilterMode == PolygonFilterModeType::DEPTH_Z ) { - if ( m_closePolygon() ) + if ( isPolygonClosed() ) { updateCellsDepthGeoMech( points, grid, i ); } @@ -865,16 +697,17 @@ void RimPolygonFilter::updateCells() // get polyline as vector std::vector points; - for ( auto& target : m_targets ) + + for ( auto target : m_polygonEditor->activeTargets() ) { points.push_back( target->targetPointXYZ() ); } // We need at least three points to make a closed polygon, or just 2 for a polyline - if ( ( !m_closePolygon() && ( points.size() < 2 ) ) || ( m_closePolygon() && ( points.size() < 3 ) ) ) return; + if ( ( !isPolygonClosed() && ( points.size() < 2 ) ) || ( isPolygonClosed() && ( points.size() < 3 ) ) ) return; // make sure first and last point is the same (req. by closed polygon methods used later) - if ( m_closePolygon() ) points.push_back( points.front() ); + if ( isPolygonClosed() ) points.push_back( points.front() ); RimEclipseCase* eCase = eclipseCase(); RimGeoMechCase* gCase = geoMechCase(); @@ -892,30 +725,31 @@ void RimPolygonFilter::updateCells() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::ref RimPolygonFilter::polyLinesData() const +void RimPolygonFilter::configurePolygonEditor() { - cvf::ref pld = new RigPolyLinesData; - std::vector line; - for ( const RimPolylineTarget* target : m_targets ) - { - line.push_back( target->targetPointXYZ() ); - } - pld->setPolyLine( line ); + m_polygonEditor->setPolygon( m_cellFilterPolygon() ); - pld->setLineAppearance( m_lineThickness, m_lineColor, m_closePolygon ); - pld->setSphereAppearance( m_sphereRadiusFactor, m_sphereColor ); - pld->setZPlaneLock( m_lockPolygonToPlane, -m_polygonPlaneDepth ); + // Must connect the signals after polygon is assigned to the polygon editor + // When assigning an object to a ptr field, all signals are disconnected + connectObjectSignals( m_cellFilterPolygon() ); +} - if ( isActive() ) - { - pld->setVisibility( m_showLines, m_showSpheres ); - } - else - { - pld->setVisibility( false, false ); - } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonFilter::appendPartsToModel( cvf::ModelBasicList* model, + const caf::DisplayCoordTransform* scaleTransform, + const cvf::BoundingBox& boundingBox ) +{ + return m_polygonEditor->appendPartsToModel( model, scaleTransform, boundingBox ); +} - return pld; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimPolygonInView* RimPolygonFilter::polygonEditor() const +{ + return m_polygonEditor(); } //-------------------------------------------------------------------------------------------------- @@ -932,6 +766,44 @@ void RimPolygonFilter::initializeCellList() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimPolygonFilter::isPolygonClosed() const +{ + if ( m_polygonEditor->polygon() ) return m_polygonEditor->polygon()->isClosed(); + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonFilter::connectObjectSignals( RimPolygon* polygon ) +{ + if ( m_cellFilterPolygon() ) + { + m_cellFilterPolygon()->objectChanged.disconnect( this ); + } + + if ( polygon ) + { + m_cellFilterPolygon = polygon; + + polygon->objectChanged.connect( this, &RimPolygonFilter::onObjectChanged ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonFilter::onObjectChanged( const caf::SignalEmitter* emitter ) +{ + updateCells(); + filterChanged.send(); + updateIconState(); +} + //-------------------------------------------------------------------------------------------------- /// Find which K layer we hit, in any of the grids, for any of the selected points //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.h b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.h index 94018cf843..52a63e5da1 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.h +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.h @@ -20,39 +20,34 @@ #include "RimCellFilter.h" #include "RimCellFilterIntervalTool.h" -#include "RimPolylinePickerInterface.h" -#include "RimPolylinesDataInterface.h" #include "cafAppEnum.h" -#include "cafPdmChildArrayField.h" -#include "cafPdmField.h" -#include "cafPdmFieldCvfColor.h" -#include "cafPdmFieldCvfVec3d.h" +#include "cafPdmChildField.h" #include "cafPdmObject.h" #include "cafPdmPtrField.h" -#include "cafPickEventHandler.h" -#include "cvfColor3.h" - -#include -#include - -class RicPolylineTargetsPickEventHandler; -class RimPolylineTarget; -class RimCase; -class RimEclipseCase; -class RimGeoMechCase; +class RimPolygon; class RigGridBase; -class RigMainGrid; class RigFemPartGrid; -class RigPolylinesData; -class RigEclipseCaseData; +class RimPolygonInView; + +namespace cvf +{ +class ModelBasicList; +class BoundingBox; + +}; // namespace cvf + +namespace caf +{ +class DisplayCoordTransform; +}; //================================================================================================== /// /// //================================================================================================== -class RimPolygonFilter : public RimCellFilter, public RimPolylinePickerInterface, public RimPolylinesDataInterface +class RimPolygonFilter : public RimCellFilter { CAF_PDM_HEADER_INIT; @@ -71,38 +66,33 @@ class RimPolygonFilter : public RimCellFilter, public RimPolylinePickerInterface }; RimPolygonFilter(); - ~RimPolygonFilter() override; void enableFilter( bool bEnable ); void enableKFilter( bool bEnable ); bool isFilterEnabled() const override; - void updateVisualization() override; - void updateEditorsAndVisualization() override; - void insertTarget( const RimPolylineTarget* targetToInsertBefore, RimPolylineTarget* targetToInsert ) override; - void deleteTarget( RimPolylineTarget* targetToDelete ) override; void enablePicking( bool enable ); - std::vector activeTargets() const override; - bool pickingEnabled() const override; - caf::PickEventHandler* pickEventHandler() const override; - void updateCellIndexFilter( cvf::UByteArray* includeVisibility, cvf::UByteArray* excludeVisibility, int gridIndex ) override; void onGridChanged() override; - cvf::ref polyLinesData() const override; + void configurePolygonEditor(); + void appendPartsToModel( cvf::ModelBasicList* model, const caf::DisplayCoordTransform* scaleTransform, const cvf::BoundingBox& boundingBox ); + + RimPolygonInView* polygonEditor() const; protected: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; + void initAfterRead() override; + void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; QString fullName() const override; private: - void defineCustomContextMenu( const caf::PdmFieldHandle* fieldNeedingMenu, QMenu* menu, QWidget* fieldEditorWidget ) override; - void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; - void updateCells(); void updateCellsForEclipse( const std::vector& points, RimEclipseCase* eCase ); void updateCellsForGeoMech( const std::vector& points, RimGeoMechCase* gCase ); @@ -118,26 +108,25 @@ class RimPolygonFilter : public RimCellFilter, public RimPolylinePickerInterface void initializeCellList(); - caf::PdmField m_enablePicking; - caf::PdmChildArrayField m_targets; + bool isPolygonClosed() const; + + void connectObjectSignals( RimPolygon* polygon ); + void onObjectChanged( const caf::SignalEmitter* emitter ); + +private: caf::PdmField> m_polyFilterMode; caf::PdmField> m_polyIncludeType; caf::PdmField m_enableFiltering; - caf::PdmField m_showLines; - caf::PdmField m_showSpheres; - caf::PdmField m_lineThickness; - caf::PdmField m_sphereRadiusFactor; - caf::PdmField m_lineColor; - caf::PdmField m_sphereColor; - caf::PdmField m_polygonPlaneDepth; - caf::PdmField m_lockPolygonToPlane; caf::PdmField m_enableKFilter; caf::PdmField m_kFilterStr; - caf::PdmField m_closePolygon; - - std::shared_ptr m_pickTargetsEventHandler; std::vector> m_cells; RimCellFilterIntervalTool m_intervalTool; + + // Local polygon and polygon editor + caf::PdmPtrField m_cellFilterPolygon; + caf::PdmChildField m_internalPolygon; + caf::PdmChildField m_polygonEditor; + caf::PdmField m_editPolygonButton; }; From bab4b0c1b4ec225bc8623779437d0acf21c573ab Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 19 Feb 2024 10:24:23 +0100 Subject: [PATCH 02/23] Add missing include --- .../ProjectDataModel/CellFilters/RimPolygonFilter.h | 1 + 1 file changed, 1 insertion(+) diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.h b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.h index 52a63e5da1..6432c2adfe 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.h +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.h @@ -30,6 +30,7 @@ class RimPolygon; class RigGridBase; class RigFemPartGrid; class RimPolygonInView; +class RigEclipseCaseData; namespace cvf { From cda0c80917c2d565f3efdfd54480be637346cef4 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 19 Feb 2024 12:54:21 +0100 Subject: [PATCH 03/23] Add scaling to polygon in view --- .../RicPolylineTarget3dEditor.cpp | 10 ++++++++-- .../ProjectDataModel/Polygons/RimPolygonInView.cpp | 12 ++++++++++++ .../ProjectDataModel/Polygons/RimPolygonInView.h | 3 ++- .../ProjectDataModel/RimPolylinePickerInterface.cpp | 8 ++++++++ .../ProjectDataModel/RimPolylinePickerInterface.h | 1 + 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicPolylineTarget3dEditor.cpp b/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicPolylineTarget3dEditor.cpp index d536f59251..504eff978d 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicPolylineTarget3dEditor.cpp +++ b/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicPolylineTarget3dEditor.cpp @@ -21,6 +21,7 @@ #include "RicPointTangentManipulator.h" #include "Rim3dView.h" +#include "RimPolylinePickerInterface.h" #include "RimPolylineTarget.h" #include "RiuViewer.h" @@ -96,8 +97,13 @@ void RicPolylineTarget3dEditor::configureAndUpdateUi( const QString& uiConfigNam cvf::ref dispXf = view->displayCoordTransform(); - const double handleScalingFactor = 0.7; - const double handleSize = handleScalingFactor * view->characteristicCellSize(); + double scalingFactor = 0.7; + if ( auto pickerInterface = target->firstAncestorOrThisOfType() ) + { + scalingFactor *= pickerInterface->handleScalingFactor(); + } + + const double handleSize = scalingFactor * view->characteristicCellSize(); m_manipulator->setOrigin( dispXf->transformToDisplayCoord( target->targetPointXYZ() ) ); m_manipulator->setHandleSize( handleSize ); diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.cpp b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.cpp index 60371b247d..282ad14e2a 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.cpp +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.cpp @@ -58,6 +58,8 @@ RimPolygonInView::RimPolygonInView() caf::PdmUiPushButtonEditor::configureEditorForField( &m_enablePicking ); m_enablePicking.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosType::HIDDEN ); + CAF_PDM_InitField( &m_handleScalingFactor, "HandleScalingFactor", 1.0, "Handle Scaling Factor" ); + CAF_PDM_InitFieldNoDefault( &m_targets, "Targets", "Targets" ); m_targets.uiCapability()->setUiEditorTypeName( caf::PdmUiTableViewEditor::uiEditorTypeName() ); m_targets.uiCapability()->setUiTreeChildrenHidden( true ); @@ -243,6 +245,8 @@ void RimPolygonInView::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin { updateNameField(); + uiOrdering.add( &m_handleScalingFactor ); + if ( m_polygon() ) uiOrdering.add( m_polygon ); uiOrdering.add( &m_enablePicking ); } @@ -288,6 +292,14 @@ void RimPolygonInView::defineObjectEditorAttribute( QString uiConfigName, caf::P } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimPolygonInView::handleScalingFactor() const +{ + return m_handleScalingFactor(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.h b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.h index 3e8a6864cd..15175d41eb 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.h +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.h @@ -55,7 +55,6 @@ class RimPolygonInView : public RimCheckableNamedObject, public RimPolylinesData void appendPartsToModel( cvf::ModelBasicList* model, const caf::DisplayCoordTransform* scaleTransform, const cvf::BoundingBox& boundingBox ); void enablePicking( bool enable ); - // RimPolylinesDataInterface void insertTarget( const RimPolylineTarget* targetToInsertBefore, RimPolylineTarget* targetToInsert ) override; void deleteTarget( RimPolylineTarget* targetToDelete ) override; void updateEditorsAndVisualization() override; @@ -63,6 +62,7 @@ class RimPolygonInView : public RimCheckableNamedObject, public RimPolylinesData std::vector activeTargets() const override; bool pickingEnabled() const override; caf::PickEventHandler* pickEventHandler() const override; + double handleScalingFactor() const override; cvf::ref polyLinesData() const override; @@ -87,6 +87,7 @@ class RimPolygonInView : public RimCheckableNamedObject, public RimPolylinesData caf::PdmPtrField m_polygon; caf::PdmField m_enablePicking; + caf::PdmField m_handleScalingFactor; caf::PdmChildArrayField m_targets; cvf::ref m_polylinePartMgr; diff --git a/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.cpp b/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.cpp index b039bc681b..9a737a0d5a 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.cpp @@ -20,6 +20,14 @@ #include "RimPolylineTarget.h" +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimPolylinePickerInterface::handleScalingFactor() const +{ + return 1.0; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.h b/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.h index 6210db7832..5ec2007d73 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.h +++ b/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.h @@ -38,6 +38,7 @@ class RimPolylinePickerInterface virtual std::vector activeTargets() const = 0; virtual bool pickingEnabled() const = 0; virtual caf::PickEventHandler* pickEventHandler() const = 0; + virtual double handleScalingFactor() const; std::pair findActiveTargetsAroundInsertionPoint( const RimPolylineTarget* targetToInsertBefore ); }; From 3e6573ec6434e0dd5e35326f34789157d04d4c3a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 20 Feb 2024 15:26:43 +0100 Subject: [PATCH 04/23] Use polygon as child object of polygon cell filter --- .../RicNewPolygonFilter3dviewFeature.cpp | 2 +- .../RicNewPolygonFilterFeature.cpp | 2 +- .../CellFilters/RimPolygonFilter.cpp | 79 +++++++++++++++---- .../CellFilters/RimPolygonFilter.h | 18 ++++- 4 files changed, 81 insertions(+), 20 deletions(-) diff --git a/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilter3dviewFeature.cpp b/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilter3dviewFeature.cpp index 1c1c6b1082..a33936e93f 100644 --- a/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilter3dviewFeature.cpp +++ b/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilter3dviewFeature.cpp @@ -51,7 +51,7 @@ void RicNewPolygonFilter3dviewFeature::onActionTriggered( bool isChecked ) RimPolygonFilter* lastCreatedOrUpdated = filtColl->addNewPolygonFilter( sourceCase ); if ( lastCreatedOrUpdated ) { - Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated->polygonEditor() ); + Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated ); } } diff --git a/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.cpp b/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.cpp index 3c40d0dfc8..343d8ed97c 100644 --- a/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.cpp +++ b/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.cpp @@ -49,7 +49,7 @@ void RicNewPolygonFilterFeature::onActionTriggered( bool isChecked ) RimPolygonFilter* lastCreatedOrUpdated = filtColl->addNewPolygonFilter( sourceCase ); if ( lastCreatedOrUpdated ) { - Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated->polygonEditor() ); + Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated ); } } diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp index bc57049cb8..a0677b5e8a 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp @@ -35,8 +35,10 @@ #include "Riu3DMainWindowTools.h" +#include "WellPathCommands/PointTangentManipulator/RicPolyline3dEditor.h" +#include "WellPathCommands/RicPolylineTargetsPickEventHandler.h" + #include "cafPdmUiPushButtonEditor.h" -#include "cafPdmUiTreeOrdering.h" #include @@ -68,6 +70,7 @@ CAF_PDM_SOURCE_INIT( RimPolygonFilter, "PolygonFilter", "PolyLineFilter" ); //-------------------------------------------------------------------------------------------------- RimPolygonFilter::RimPolygonFilter() : RimCellFilter( RimCellFilter::INDEX ) + , m_pickTargetsEventHandler( new RicPolylineTargetsPickEventHandler( this ) ) , m_intervalTool( true ) { CAF_PDM_InitObject( "Polyline Filter", ":/CellFilter_Polygon.png" ); @@ -86,6 +89,8 @@ RimPolygonFilter::RimPolygonFilter() CAF_PDM_InitFieldNoDefault( &m_polygonEditor, "PolygonEditor", "Polygon Editor" ); m_polygonEditor = new RimPolygonInView; + m_polygonEditor->uiCapability()->setUiTreeHidden( true ); + m_polygonEditor.xmlCapability()->disableIO(); CAF_PDM_InitField( &m_enableFiltering, "EnableFiltering", false, "Enable Filter" ); @@ -100,6 +105,8 @@ RimPolygonFilter::RimPolygonFilter() updateIconState(); setDeletable( true ); + + setUi3dEditorTypeName( RicPolyline3dEditor::uiEditorTypeName() ); } //-------------------------------------------------------------------------------------------------- @@ -158,6 +165,12 @@ void RimPolygonFilter::initAfterRead() //-------------------------------------------------------------------------------------------------- void RimPolygonFilter::defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) { + if ( auto attrib = dynamic_cast( attribute ) ) + { + attrib->pickEventHandler = m_pickTargetsEventHandler; + attrib->enablePicking = m_polygonEditor->pickingEnabled(); + } + if ( field == &m_editPolygonButton ) { if ( auto attrib = dynamic_cast( attribute ) ) @@ -219,23 +232,14 @@ void RimPolygonFilter::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin { m_polyFilterMode.uiCapability()->setUiReadOnly( readOnlyState ); } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimPolygonFilter::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= "" */ ) -{ - RimCellFilter::defineUiTreeOrdering( uiTreeOrdering, uiConfigName ); bool showPolygonEditor = ( m_cellFilterPolygon() == m_internalPolygon() ); if ( showPolygonEditor ) { - uiTreeOrdering.add( m_polygonEditor() ); + caf::PdmUiGroup* mudWeightWindowGroup = uiOrdering.addNewGroup( "Mud Weight Window" ); + m_polygonEditor()->uiOrdering( uiConfigName, *mudWeightWindowGroup ); } - - uiTreeOrdering.skipRemainingChildren(); } //-------------------------------------------------------------------------------------------------- @@ -747,9 +751,56 @@ void RimPolygonFilter::appendPartsToModel( cvf::ModelBasicList* mod //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimPolygonInView* RimPolygonFilter::polygonEditor() const +void RimPolygonFilter::insertTarget( const RimPolylineTarget* targetToInsertBefore, RimPolylineTarget* targetToInsert ) +{ + m_polygonEditor->insertTarget( targetToInsertBefore, targetToInsert ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonFilter::deleteTarget( RimPolylineTarget* targetToDelete ) +{ + m_polygonEditor->deleteTarget( targetToDelete ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonFilter::updateEditorsAndVisualization() +{ + updateConnectedEditors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonFilter::updateVisualization() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimPolygonFilter::activeTargets() const +{ + return m_polygonEditor->activeTargets(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimPolygonFilter::pickingEnabled() const +{ + return m_polygonEditor->pickingEnabled(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PickEventHandler* RimPolygonFilter::pickEventHandler() const { - return m_polygonEditor(); + return m_pickTargetsEventHandler.get(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.h b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.h index 6432c2adfe..153c9ce111 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.h +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.h @@ -20,6 +20,7 @@ #include "RimCellFilter.h" #include "RimCellFilterIntervalTool.h" +#include "RimPolylinePickerInterface.h" #include "cafAppEnum.h" #include "cafPdmChildField.h" @@ -31,6 +32,7 @@ class RigGridBase; class RigFemPartGrid; class RimPolygonInView; class RigEclipseCaseData; +class RicPolylineTargetsPickEventHandler; namespace cvf { @@ -48,7 +50,7 @@ class DisplayCoordTransform; /// /// //================================================================================================== -class RimPolygonFilter : public RimCellFilter +class RimPolygonFilter : public RimCellFilter, public RimPolylinePickerInterface { CAF_PDM_HEADER_INIT; @@ -81,12 +83,9 @@ class RimPolygonFilter : public RimCellFilter void configurePolygonEditor(); void appendPartsToModel( cvf::ModelBasicList* model, const caf::DisplayCoordTransform* scaleTransform, const cvf::BoundingBox& boundingBox ); - RimPolygonInView* polygonEditor() const; - protected: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; - void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void initAfterRead() override; void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; @@ -114,6 +113,15 @@ class RimPolygonFilter : public RimCellFilter void connectObjectSignals( RimPolygon* polygon ); void onObjectChanged( const caf::SignalEmitter* emitter ); + // RimPolylinePickerInterface used to forward events to m_polygonEditor + void insertTarget( const RimPolylineTarget* targetToInsertBefore, RimPolylineTarget* targetToInsert ) override; + void deleteTarget( RimPolylineTarget* targetToDelete ) override; + void updateEditorsAndVisualization() override; + void updateVisualization() override; + std::vector activeTargets() const override; + bool pickingEnabled() const override; + caf::PickEventHandler* pickEventHandler() const override; + private: caf::PdmField> m_polyFilterMode; caf::PdmField> m_polyIncludeType; @@ -130,4 +138,6 @@ class RimPolygonFilter : public RimCellFilter caf::PdmChildField m_internalPolygon; caf::PdmChildField m_polygonEditor; caf::PdmField m_editPolygonButton; + + std::shared_ptr m_pickTargetsEventHandler; }; From 7fa66dc37722808068ff0ddf72dd86b9e07f66f8 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 21 Feb 2024 08:00:27 +0100 Subject: [PATCH 05/23] Move polygon line visualization to RimGridView --- .../CellFilters/RimCellFilterCollection.cpp | 18 ++++++++++ .../CellFilters/RimCellFilterCollection.h | 4 ++- .../CellFilters/RimPolygonFilter.cpp | 10 ++++++ .../CellFilters/RimPolygonFilter.h | 1 + .../GeoMech/RimGeoMechView.cpp | 5 +-- .../Polygons/RimPolygonInViewCollection.cpp | 16 ++------- .../Polygons/RimPolygonInViewCollection.h | 13 +------ .../ProjectDataModel/RimEclipseView.cpp | 4 +-- .../ProjectDataModel/RimGridView.cpp | 34 ++++++++++++++++++- .../ProjectDataModel/RimGridView.h | 2 ++ 10 files changed, 72 insertions(+), 35 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp index 0ffae32dba..ef0c5feaf8 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp @@ -486,3 +486,21 @@ void RimCellFilterCollection::updateCellVisibilityByIndex( cvf::UByteArray* incl } } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimCellFilterCollection::cellFilterPolygons() const +{ + std::vector polyInView; + + for ( const auto& filter : m_cellFilters ) + { + if ( auto polygonFilter = dynamic_cast( filter.p() ) ) + { + polyInView.push_back( polygonFilter->polygonInView() ); + } + } + + return polyInView; +} diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.h b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.h index 87a7d808ba..1ad20dc819 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.h +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.h @@ -32,6 +32,7 @@ class RimPolygonFilter; class RimUserDefinedFilter; class RimUserDefinedIndexFilter; class RimCase; +class RimPolygonInView; namespace cvf { @@ -69,7 +70,8 @@ class RimCellFilterCollection : public caf::PdmObject void compoundCellRangeFilter( cvf::CellRangeFilter* cellRangeFilter, size_t gridIndex ) const; void updateCellVisibilityByIndex( cvf::UByteArray* cellsIncluded, cvf::UByteArray* cellsExcluded, size_t gridIndex ) const; - std::vector filters() const; + std::vector cellFilterPolygons() const; + std::vector filters() const; bool hasActiveFilters() const; bool hasActiveIncludeIndexFilters() const; diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp index a0677b5e8a..cf6eab646c 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp @@ -745,9 +745,19 @@ void RimPolygonFilter::appendPartsToModel( cvf::ModelBasicList* mod const caf::DisplayCoordTransform* scaleTransform, const cvf::BoundingBox& boundingBox ) { + return; + return m_polygonEditor->appendPartsToModel( model, scaleTransform, boundingBox ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimPolygonInView* RimPolygonFilter::polygonInView() const +{ + return m_polygonEditor(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.h b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.h index 153c9ce111..949d9dd212 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.h +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.h @@ -82,6 +82,7 @@ class RimPolygonFilter : public RimCellFilter, public RimPolylinePickerInterface void configurePolygonEditor(); void appendPartsToModel( cvf::ModelBasicList* model, const caf::DisplayCoordTransform* scaleTransform, const cvf::BoundingBox& boundingBox ); + RimPolygonInView* polygonInView() const; protected: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp index e5c39de868..a2b28b2172 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp @@ -322,10 +322,7 @@ void RimGeoMechView::onCreateDisplayModel() nativeOrOverrideViewer()->addStaticModelOnce( m_seismicVizModel.p(), isUsingOverrideViewer() ); // Polygons - - m_polygonVizModel->removeAllParts(); - m_polygonCollection->appendPartsToModel( m_polygonVizModel.p(), transform.p(), femBBox ); - nativeOrOverrideViewer()->addStaticModelOnce( m_polygonVizModel.p(), isUsingOverrideViewer() ); + appendPolygonPartsToModel( transform.p(), ownerCase()->allCellsBoundingBox() ); // Surfaces diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInViewCollection.cpp b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInViewCollection.cpp index fadd762d44..9aa7034018 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInViewCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInViewCollection.cpp @@ -23,10 +23,6 @@ #include "RimPolygonInView.h" #include "RimTools.h" -#include "cafDisplayCoordTransform.h" - -#include "cvfModelBasicList.h" - CAF_PDM_SOURCE_INIT( RimPolygonInViewCollection, "RimPolygonInViewCollection" ); //-------------------------------------------------------------------------------------------------- @@ -83,15 +79,7 @@ void RimPolygonInViewCollection::syncPolygonsInView() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimPolygonInViewCollection::appendPartsToModel( cvf::ModelBasicList* model, - caf::DisplayCoordTransform* scaleTransform, - const cvf::BoundingBox& boundingBox ) +std::vector RimPolygonInViewCollection::polygonsInView() const { - for ( auto polygon : m_polygons ) - { - if ( polygon && polygon->isChecked() ) - { - polygon->appendPartsToModel( model, scaleTransform, boundingBox ); - } - } + return m_polygons.childrenByType(); } diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInViewCollection.h b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInViewCollection.h index 7d79a1b853..2659f0beee 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInViewCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInViewCollection.h @@ -23,17 +23,6 @@ class RimPolygonInView; -namespace cvf -{ -class ModelBasicList; -class BoundingBox; -} // namespace cvf - -namespace caf -{ -class DisplayCoordTransform; -} // namespace caf - //================================================================================================== /// /// @@ -47,7 +36,7 @@ class RimPolygonInViewCollection : public caf::PdmObject void syncPolygonsInView(); - void appendPartsToModel( cvf::ModelBasicList* model, caf::DisplayCoordTransform* scaleTransform, const cvf::BoundingBox& boundingBox ); + std::vector polygonsInView() const; private: caf::PdmChildArrayField m_polygons; diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp index b5c413224d..7f23f772c1 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp @@ -650,9 +650,7 @@ void RimEclipseView::onCreateDisplayModel() } // Polygons - m_polygonVizModel->removeAllParts(); - m_polygonCollection->appendPartsToModel( m_polygonVizModel.p(), transform.p(), ownerCase()->allCellsBoundingBox() ); - nativeOrOverrideViewer()->addStaticModelOnce( m_polygonVizModel.p(), isUsingOverrideViewer() ); + appendPolygonPartsToModel( transform.p(), ownerCase()->allCellsBoundingBox() ); // Well path model m_wellPathPipeVizModel->removeAllParts(); diff --git a/ApplicationLibCode/ProjectDataModel/RimGridView.cpp b/ApplicationLibCode/ProjectDataModel/RimGridView.cpp index 98a57cd0d3..bc0ff08351 100644 --- a/ApplicationLibCode/ProjectDataModel/RimGridView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimGridView.cpp @@ -18,7 +18,6 @@ #include "RimGridView.h" -#include "Polygons/RimPolygonInViewCollection.h" #include "Rim3dOverlayInfoConfig.h" #include "RimCellFilterCollection.h" #include "RimEclipseCase.h" @@ -42,6 +41,9 @@ #include "RimWellMeasurementInViewCollection.h" #include "RimWellPathCollection.h" +#include "Polygons/RimPolygonInView.h" +#include "Polygons/RimPolygonInViewCollection.h" + #include "Riu3DMainWindowTools.h" #include "Riu3dSelectionManager.h" #include "RiuMainWindow.h" @@ -395,6 +397,36 @@ void RimGridView::onCreatePartCollectionFromSelection( cvf::CollectionremoveAllParts(); + + std::vector polygonsInView; + if ( m_polygonCollection ) + { + polygonsInView = m_polygonCollection->polygonsInView(); + } + + if ( cellFilterCollection() ) + { + auto cellFilterPolygonsInView = cellFilterCollection()->cellFilterPolygons(); + polygonsInView.insert( polygonsInView.end(), cellFilterPolygonsInView.begin(), cellFilterPolygonsInView.end() ); + } + + for ( RimPolygonInView* polygonInView : polygonsInView ) + { + if ( polygonInView ) + { + polygonInView->appendPartsToModel( m_polygonVizModel.p(), scaleTransform, boundingBox ); + } + } + + nativeOrOverrideViewer()->addStaticModelOnce( m_polygonVizModel.p(), isUsingOverrideViewer() ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimGridView.h b/ApplicationLibCode/ProjectDataModel/RimGridView.h index 203f7e9100..53413a950a 100644 --- a/ApplicationLibCode/ProjectDataModel/RimGridView.h +++ b/ApplicationLibCode/ProjectDataModel/RimGridView.h @@ -80,6 +80,7 @@ class RimGridView : public Rim3dView RimGridCollection* gridCollection() const; void clearReservoirCellVisibilities(); void addRequiredUiTreeObjects( caf::PdmUiTreeOrdering& uiTreeOrdering ); + void appendPolygonPartsToModel( caf::DisplayCoordTransform* scaleTransform, const cvf::BoundingBox& boundingBox ); void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void initAfterRead() override; @@ -112,6 +113,7 @@ class RimGridView : public Rim3dView private: void onCreatePartCollectionFromSelection( cvf::Collection* parts ) override; +private: cvf::ref m_currentReservoirCellVisibility; bool m_previousGridModeMeshLinesWasFaults; }; From 30688bb2c6df75e2bcd766236ca7fcc645b0b75c Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 21 Feb 2024 08:05:09 +0100 Subject: [PATCH 06/23] Cleanup --- .../RivCellFilterPartMgr.cpp | 18 ++++++++++-------- .../CellFilters/RimPolygonFilter.cpp | 12 ------------ .../CellFilters/RimPolygonFilter.h | 15 +-------------- 3 files changed, 11 insertions(+), 34 deletions(-) diff --git a/ApplicationLibCode/ModelVisualization/RivCellFilterPartMgr.cpp b/ApplicationLibCode/ModelVisualization/RivCellFilterPartMgr.cpp index 3e16517cd8..e28ecc6c58 100644 --- a/ApplicationLibCode/ModelVisualization/RivCellFilterPartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/RivCellFilterPartMgr.cpp @@ -39,16 +39,18 @@ void RivCellFilterPartMgr::appendGeometryPartsToModel( cvf::ModelBasicList* const caf::DisplayCoordTransform* displayCoordTransform, const cvf::BoundingBox& boundingBox ) { - std::vector colls = m_rimView->descendantsIncludingThisOfType(); + /* + std::vector colls = m_rimView->descendantsIncludingThisOfType(); - if ( colls.empty() ) return; - auto coll = colls.front(); + if ( colls.empty() ) return; + auto coll = colls.front(); - for ( auto filter : coll->filters() ) - { - if ( auto polyFilter = dynamic_cast( filter ) ) + for ( auto filter : coll->filters() ) { - polyFilter->appendPartsToModel( model, displayCoordTransform, boundingBox ); + if ( auto polyFilter = dynamic_cast( filter ) ) + { + polyFilter->appendPartsToModel( model, displayCoordTransform, boundingBox ); + } } - } + */ } diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp index cf6eab646c..6d07b97ab1 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp @@ -738,18 +738,6 @@ void RimPolygonFilter::configurePolygonEditor() connectObjectSignals( m_cellFilterPolygon() ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimPolygonFilter::appendPartsToModel( cvf::ModelBasicList* model, - const caf::DisplayCoordTransform* scaleTransform, - const cvf::BoundingBox& boundingBox ) -{ - return; - - return m_polygonEditor->appendPartsToModel( model, scaleTransform, boundingBox ); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.h b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.h index 949d9dd212..e5ba105c55 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.h +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.h @@ -34,18 +34,6 @@ class RimPolygonInView; class RigEclipseCaseData; class RicPolylineTargetsPickEventHandler; -namespace cvf -{ -class ModelBasicList; -class BoundingBox; - -}; // namespace cvf - -namespace caf -{ -class DisplayCoordTransform; -}; - //================================================================================================== /// /// @@ -80,8 +68,7 @@ class RimPolygonFilter : public RimCellFilter, public RimPolylinePickerInterface void updateCellIndexFilter( cvf::UByteArray* includeVisibility, cvf::UByteArray* excludeVisibility, int gridIndex ) override; void onGridChanged() override; - void configurePolygonEditor(); - void appendPartsToModel( cvf::ModelBasicList* model, const caf::DisplayCoordTransform* scaleTransform, const cvf::BoundingBox& boundingBox ); + void configurePolygonEditor(); RimPolygonInView* polygonInView() const; protected: From bba7a2ef0007b1fdc3cf616399b5cd97c9a95dc1 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 20 Feb 2024 07:58:39 +0100 Subject: [PATCH 07/23] Remove obsolete code --- .../ModelVisualization/CMakeLists_files.cmake | 2 - .../RivCellFilterPartMgr.cpp | 56 ------------------- .../ModelVisualization/RivCellFilterPartMgr.h | 50 ----------------- .../ProjectDataModel/Rim3dView.cpp | 39 ------------- .../ProjectDataModel/Rim3dView.h | 4 -- 5 files changed, 151 deletions(-) delete mode 100644 ApplicationLibCode/ModelVisualization/RivCellFilterPartMgr.cpp delete mode 100644 ApplicationLibCode/ModelVisualization/RivCellFilterPartMgr.h diff --git a/ApplicationLibCode/ModelVisualization/CMakeLists_files.cmake b/ApplicationLibCode/ModelVisualization/CMakeLists_files.cmake index 36c5f0a7b6..83fa8fa67f 100644 --- a/ApplicationLibCode/ModelVisualization/CMakeLists_files.cmake +++ b/ApplicationLibCode/ModelVisualization/CMakeLists_files.cmake @@ -54,7 +54,6 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RivWellDiskPartMgr.h ${CMAKE_CURRENT_LIST_DIR}/RivElementVectorResultPartMgr.h ${CMAKE_CURRENT_LIST_DIR}/RivPolylinePartMgr.h - ${CMAKE_CURRENT_LIST_DIR}/RivCellFilterPartMgr.h ${CMAKE_CURRENT_LIST_DIR}/RivDrawableSpheres.h ${CMAKE_CURRENT_LIST_DIR}/RivBoxGeometryGenerator.h ${CMAKE_CURRENT_LIST_DIR}/RivAnnotationTools.h @@ -112,7 +111,6 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RivWellDiskPartMgr.cpp ${CMAKE_CURRENT_LIST_DIR}/RivElementVectorResultPartMgr.cpp ${CMAKE_CURRENT_LIST_DIR}/RivPolylinePartMgr.cpp - ${CMAKE_CURRENT_LIST_DIR}/RivCellFilterPartMgr.cpp ${CMAKE_CURRENT_LIST_DIR}/RivDrawableSpheres.cpp ${CMAKE_CURRENT_LIST_DIR}/RivBoxGeometryGenerator.cpp ${CMAKE_CURRENT_LIST_DIR}/RivAnnotationTools.cpp diff --git a/ApplicationLibCode/ModelVisualization/RivCellFilterPartMgr.cpp b/ApplicationLibCode/ModelVisualization/RivCellFilterPartMgr.cpp deleted file mode 100644 index e28ecc6c58..0000000000 --- a/ApplicationLibCode/ModelVisualization/RivCellFilterPartMgr.cpp +++ /dev/null @@ -1,56 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// 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 -// for more details. -// -///////////////////////////////////////////////////////////////////////////////// - -#include "RivCellFilterPartMgr.h" - -#include "Rim3dView.h" -#include "RimCellFilterCollection.h" -#include "RimPolygonFilter.h" - -#include "cafPdmObject.h" - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RivCellFilterPartMgr::RivCellFilterPartMgr( Rim3dView* view ) - : m_rimView( view ) -{ -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RivCellFilterPartMgr::appendGeometryPartsToModel( cvf::ModelBasicList* model, - const caf::DisplayCoordTransform* displayCoordTransform, - const cvf::BoundingBox& boundingBox ) -{ - /* - std::vector colls = m_rimView->descendantsIncludingThisOfType(); - - if ( colls.empty() ) return; - auto coll = colls.front(); - - for ( auto filter : coll->filters() ) - { - if ( auto polyFilter = dynamic_cast( filter ) ) - { - polyFilter->appendPartsToModel( model, displayCoordTransform, boundingBox ); - } - } - */ -} diff --git a/ApplicationLibCode/ModelVisualization/RivCellFilterPartMgr.h b/ApplicationLibCode/ModelVisualization/RivCellFilterPartMgr.h deleted file mode 100644 index 38d4608915..0000000000 --- a/ApplicationLibCode/ModelVisualization/RivCellFilterPartMgr.h +++ /dev/null @@ -1,50 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// 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 -// for more details. -// -///////////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include "cafPdmPointer.h" -#include "cvfObject.h" - -namespace cvf -{ -class BoundingBox; -class Part; -class ModelBasicList; -class Transform; -class Font; -} // namespace cvf -namespace caf -{ -class DisplayCoordTransform; -} - -class Rim3dView; - -class RivCellFilterPartMgr : public cvf::Object -{ -public: - RivCellFilterPartMgr( Rim3dView* view ); - - void appendGeometryPartsToModel( cvf::ModelBasicList* model, - const caf::DisplayCoordTransform* displayCoordTransform, - const cvf::BoundingBox& boundingBox ); - -private: - caf::PdmPointer m_rimView; -}; diff --git a/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp b/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp index eaba599751..dd450bd55a 100644 --- a/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp +++ b/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp @@ -51,7 +51,6 @@ #include "RimWellPathCollection.h" #include "RivAnnotationsPartMgr.h" -#include "RivCellFilterPartMgr.h" #include "RivMeasurementPartMgr.h" #include "RivWellPathsPartMgr.h" @@ -174,7 +173,6 @@ Rim3dView::Rim3dView() m_wellPathsPartManager = new RivWellPathsPartMgr( this ); m_annotationsPartManager = new RivAnnotationsPartMgr( this ); - m_cellfilterPartManager = new RivCellFilterPartMgr( this ); m_measurementPartManager = new RivMeasurementPartMgr( this ); this->setAs3DViewMdiWindow(); @@ -701,14 +699,12 @@ void Rim3dView::updateDisplayModelForCurrentTimeStepAndRedraw() this->onUpdateDisplayModelForCurrentTimeStep(); appendAnnotationsToModel(); appendMeasurementToModel(); - appendCellFiltersToModel(); if ( Rim3dView* depView = prepareComparisonView() ) { depView->onUpdateDisplayModelForCurrentTimeStep(); depView->appendAnnotationsToModel(); depView->appendMeasurementToModel(); - depView->appendCellFiltersToModel(); restoreComparisonView(); } @@ -1133,19 +1129,6 @@ void Rim3dView::addAnnotationsToModel( cvf::ModelBasicList* annotationsModel ) annotationsModel->updateBoundingBoxesRecursive(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void Rim3dView::addCellFiltersToModel( cvf::ModelBasicList* cellFilterModel ) -{ - if ( !this->ownerCase() ) return; - - cvf::ref transForm = displayCoordTransform(); - m_cellfilterPartManager->appendGeometryPartsToModel( cellFilterModel, transForm.p(), ownerCase()->allCellsBoundingBox() ); - - cellFilterModel->updateBoundingBoxesRecursive(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1716,28 +1699,6 @@ void Rim3dView::updateScreenSpaceModel() nativeOrOverrideViewer()->addStaticModelOnce( m_screenSpaceModel.p(), isUsingOverrideViewer() ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void Rim3dView::appendCellFiltersToModel() -{ - if ( !nativeOrOverrideViewer() ) return; - - cvf::Scene* frameScene = nativeOrOverrideViewer()->frame( m_currentTimeStep, isUsingOverrideViewer() ); - if ( frameScene ) - { - cvf::String name = "CellFilters"; - this->removeModelByName( frameScene, name ); - - cvf::ref model = new cvf::ModelBasicList; - model->setName( name ); - - addCellFiltersToModel( model.p() ); - - frameScene->addModel( model.p() ); - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Rim3dView.h b/ApplicationLibCode/ProjectDataModel/Rim3dView.h index e25459dacd..a193617c6a 100644 --- a/ApplicationLibCode/ProjectDataModel/Rim3dView.h +++ b/ApplicationLibCode/ProjectDataModel/Rim3dView.h @@ -52,7 +52,6 @@ class RiuViewer; class RivAnnotationsPartMgr; class RivMeasurementPartMgr; class RivWellPathsPartMgr; -class RivCellFilterPartMgr; class RimViewNameConfig; namespace cvf @@ -222,7 +221,6 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface, public double characteristicCellSize ); void addAnnotationsToModel( cvf::ModelBasicList* annotationsModel ); void addMeasurementToModel( cvf::ModelBasicList* measureModel ); - void addCellFiltersToModel( cvf::ModelBasicList* cellFilterModel ); // Override viewer @@ -311,7 +309,6 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface, public void createHighlightAndGridBoxDisplayModel(); void appendMeasurementToModel(); - void appendCellFiltersToModel(); void appendAnnotationsToModel(); void updateScreenSpaceModel(); @@ -349,7 +346,6 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface, public // 3D display model data cvf::ref m_annotationsPartManager; cvf::ref m_measurementPartManager; - cvf::ref m_cellfilterPartManager; // Timer for animations std::unique_ptr m_animationTimer; From a54e3ba41362e639a005591789505d3c6b205e4b Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 21 Feb 2024 09:05:19 +0100 Subject: [PATCH 08/23] add polygon shape and data source --- .../CellFilters/RimPolygonFilter.cpp | 95 +++++++++++++++---- .../CellFilters/RimPolygonFilter.h | 28 +++++- .../ProjectDataModel/Polygons/RimPolygon.cpp | 8 ++ .../ProjectDataModel/Polygons/RimPolygon.h | 1 + .../Polygons/RimPolygonAppearance.cpp | 9 ++ .../Polygons/RimPolygonAppearance.h | 1 + 6 files changed, 118 insertions(+), 24 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp index 6d07b97ab1..d33f3f6ad0 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp @@ -26,13 +26,15 @@ #include "RigMainGrid.h" #include "RigReservoirGridTools.h" -#include "Polygons/RimPolygon.h" -#include "Polygons/RimPolygonInView.h" #include "RimEclipseCase.h" #include "RimGeoMechCase.h" #include "RimPolylineTarget.h" #include "RimTools.h" +#include "Polygons/RimPolygon.h" +#include "Polygons/RimPolygonCollection.h" +#include "Polygons/RimPolygonInView.h" + #include "Riu3DMainWindowTools.h" #include "WellPathCommands/PointTangentManipulator/RicPolyline3dEditor.h" @@ -61,6 +63,22 @@ void caf::AppEnum::setUp() setDefault( RimPolygonFilter::PolygonIncludeType::CENTER ); } +template <> +void caf::AppEnum::setUp() +{ + addItem( RimPolygonFilter::GeometricalShape::AREA, "AREA", "Area Filter" ); + addItem( RimPolygonFilter::GeometricalShape::LINE, "LINE", "Line Filter" ); + setDefault( RimPolygonFilter::GeometricalShape::AREA ); +} + +template <> +void caf::AppEnum::setUp() +{ + addItem( RimPolygonFilter::PolygonDataSource::DEFINED_IN_FILTER, "DEFINED_IN_FILTER", "Defined in Filter" ); + addItem( RimPolygonFilter::PolygonDataSource::GLOBAL_POLYGON, "GLOBAL_POLYGON", "Polygon in Project" ); + setDefault( RimPolygonFilter::PolygonDataSource::DEFINED_IN_FILTER ); +} + } // namespace caf CAF_PDM_SOURCE_INIT( RimPolygonFilter, "PolygonFilter", "PolyLineFilter" ); @@ -78,6 +96,11 @@ RimPolygonFilter::RimPolygonFilter() CAF_PDM_InitFieldNoDefault( &m_polyFilterMode, "PolygonFilterType", "Vertical Filter" ); CAF_PDM_InitFieldNoDefault( &m_polyIncludeType, "PolyIncludeType", "Cells to include" ); + CAF_PDM_InitFieldNoDefault( &m_polygonDataSource, "PolygonDataSource", "Data Source" ); + + CAF_PDM_InitFieldNoDefault( &m_geometricalShape, "GeometricalShape", "" ); + m_geometricalShape.registerGetMethod( this, &RimPolygonFilter::geometricalShape ); + m_geometricalShape.registerSetMethod( this, &RimPolygonFilter::setGeometricalShape ); CAF_PDM_InitFieldNoDefault( &m_internalPolygon, "InternalPolygon", "Polygon For Filter" ); m_internalPolygon = new RimPolygon; @@ -187,16 +210,19 @@ void RimPolygonFilter::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin { uiOrdering.add( &m_name ); + auto dataSourceGroup = uiOrdering.addNewGroup( "Polygon Data Source" ); + dataSourceGroup->add( &m_polygonDataSource ); + if ( m_polygonDataSource() == PolygonDataSource::GLOBAL_POLYGON ) + { + dataSourceGroup->add( &m_cellFilterPolygon ); + dataSourceGroup->add( &m_editPolygonButton, { .newRow = false } ); + } + auto group = uiOrdering.addNewGroup( "General" ); group->add( &m_filterMode ); + group->add( &m_geometricalShape ); group->add( &m_enableFiltering ); - uiOrdering.add( &m_cellFilterPolygon ); - if ( m_cellFilterPolygon() != m_internalPolygon() ) - { - uiOrdering.add( &m_editPolygonButton, { .newRow = false } ); - } - auto group1 = uiOrdering.addNewGroup( "Polygon Selection" ); group1->add( &m_polyFilterMode ); @@ -233,11 +259,9 @@ void RimPolygonFilter::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin m_polyFilterMode.uiCapability()->setUiReadOnly( readOnlyState ); } - bool showPolygonEditor = ( m_cellFilterPolygon() == m_internalPolygon() ); - - if ( showPolygonEditor ) + if ( m_polygonDataSource() == PolygonDataSource::DEFINED_IN_FILTER ) { - caf::PdmUiGroup* mudWeightWindowGroup = uiOrdering.addNewGroup( "Mud Weight Window" ); + caf::PdmUiGroup* mudWeightWindowGroup = uiOrdering.addNewGroup( "Polygon Definition" ); m_polygonEditor()->uiOrdering( uiConfigName, *mudWeightWindowGroup ); } } @@ -251,13 +275,6 @@ QList RimPolygonFilter::calculateValueOptions( const caf if ( fieldNeedingOptions == &m_cellFilterPolygon ) { RimTools::polygonOptionItems( &options ); - if ( !options.empty() ) - { - options.push_front( caf::PdmOptionItemInfo( "Project Polygons", nullptr ) ); - } - - options.push_front( - caf::PdmOptionItemInfo( m_internalPolygon()->name(), m_internalPolygon(), false, m_internalPolygon->uiIconProvider() ) ); } return options; @@ -277,6 +294,18 @@ void RimPolygonFilter::fieldChangedByUi( const caf::PdmFieldHandle* changedField return; } + if ( changedField == &m_polygonDataSource ) + { + if ( m_polygonDataSource() == PolygonDataSource::GLOBAL_POLYGON && m_cellFilterPolygon() == nullptr ) + { + auto polygonCollection = RimTools::polygonCollection(); + if ( polygonCollection && !polygonCollection->allPolygons().empty() ) + { + m_cellFilterPolygon = polygonCollection->allPolygons().front(); + } + } + } + if ( changedField == &m_cellFilterPolygon ) { configurePolygonEditor(); @@ -801,6 +830,34 @@ caf::PickEventHandler* RimPolygonFilter::pickEventHandler() const return m_pickTargetsEventHandler.get(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::AppEnum RimPolygonFilter::geometricalShape() const +{ + if ( m_cellFilterPolygon && !m_cellFilterPolygon->isClosed() ) return GeometricalShape::LINE; + + return GeometricalShape::AREA; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonFilter::setGeometricalShape( const caf::AppEnum& shape ) +{ + if ( m_cellFilterPolygon ) + { + if ( shape == GeometricalShape::LINE ) + { + m_cellFilterPolygon->setIsClosed( false ); + } + else + { + m_cellFilterPolygon->setIsClosed( true ); + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.h b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.h index e5ba105c55..4ae1e227fa 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.h +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.h @@ -43,6 +43,18 @@ class RimPolygonFilter : public RimCellFilter, public RimPolylinePickerInterface CAF_PDM_HEADER_INIT; public: + enum class PolygonDataSource + { + DEFINED_IN_FILTER, + GLOBAL_POLYGON + }; + + enum class GeometricalShape + { + AREA, + LINE + }; + enum class PolygonFilterModeType { DEPTH_Z, @@ -110,12 +122,18 @@ class RimPolygonFilter : public RimCellFilter, public RimPolylinePickerInterface bool pickingEnabled() const override; caf::PickEventHandler* pickEventHandler() const override; + caf::AppEnum geometricalShape() const; + void setGeometricalShape( const caf::AppEnum& shape ); + private: - caf::PdmField> m_polyFilterMode; - caf::PdmField> m_polyIncludeType; - caf::PdmField m_enableFiltering; - caf::PdmField m_enableKFilter; - caf::PdmField m_kFilterStr; + caf::PdmField> m_polyFilterMode; + caf::PdmField> m_polyIncludeType; + caf::PdmField> m_polygonDataSource; + caf::PdmProxyValueField> m_geometricalShape; + + caf::PdmField m_enableFiltering; + caf::PdmField m_enableKFilter; + caf::PdmField m_kFilterStr; std::vector> m_cells; diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.cpp b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.cpp index c505ac9345..e81f422fb8 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.cpp +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.cpp @@ -71,6 +71,14 @@ std::vector RimPolygon::pointsInDomainCoords() const return m_pointsInDomainCoords(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygon::setIsClosed( bool isClosed ) +{ + m_appearance->setIsClosed( isClosed ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.h b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.h index ede74d9f49..9bedb18a97 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.h +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.h @@ -40,6 +40,7 @@ class RimPolygon : public RimNamedObject, public RimPolylinesDataInterface void setPointsInDomainCoords( const std::vector& points ); std::vector pointsInDomainCoords() const; + void setIsClosed( bool isClosed ); bool isClosed() const; cvf::ref polyLinesData() const override; diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.cpp b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.cpp index 038ee5e7f0..80d41212f2 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.cpp +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.cpp @@ -106,6 +106,15 @@ void RimPolygonAppearance::applyAppearanceSettings( RigPolyLinesData* polyLinesD polyLinesData->setVisibility( m_showLines, m_showSpheres ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonAppearance::setIsClosed( bool isClosed ) +{ + m_isClosed = isClosed; + objectChanged.send(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.h b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.h index 05a9b2284e..4fae753127 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.h +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.h @@ -34,6 +34,7 @@ class RimPolygonAppearance : public caf::PdmObject void applyAppearanceSettings( RigPolyLinesData* polyLinesData ); + void setIsClosed( bool isClosed ); bool isClosed() const; public: From 242df5f9324ecb6935f8077acbfb626d0bbf8bdd Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 21 Feb 2024 09:51:49 +0100 Subject: [PATCH 09/23] Improve update signals --- .../CellFilters/RimPolygonFilter.cpp | 68 +++++++++++++------ .../CellFilters/RimPolygonFilter.h | 2 + 2 files changed, 50 insertions(+), 20 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp index d33f3f6ad0..dd9cf2a41c 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp @@ -108,7 +108,6 @@ RimPolygonFilter::RimPolygonFilter() m_internalPolygon->uiCapability()->setUiTreeHidden( true ); CAF_PDM_InitFieldNoDefault( &m_cellFilterPolygon, "Polygon", "Polygon" ); - m_cellFilterPolygon = m_internalPolygon; CAF_PDM_InitFieldNoDefault( &m_polygonEditor, "PolygonEditor", "Polygon Editor" ); m_polygonEditor = new RimPolygonInView; @@ -203,6 +202,14 @@ void RimPolygonFilter::defineEditorAttribute( const caf::PdmFieldHandle* field, } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonFilter::childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) +{ + updateConnectedEditors(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -212,7 +219,7 @@ void RimPolygonFilter::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin auto dataSourceGroup = uiOrdering.addNewGroup( "Polygon Data Source" ); dataSourceGroup->add( &m_polygonDataSource ); - if ( m_polygonDataSource() == PolygonDataSource::GLOBAL_POLYGON ) + if ( !isPolygonDefinedLocally() ) { dataSourceGroup->add( &m_cellFilterPolygon ); dataSourceGroup->add( &m_editPolygonButton, { .newRow = false } ); @@ -259,10 +266,10 @@ void RimPolygonFilter::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin m_polyFilterMode.uiCapability()->setUiReadOnly( readOnlyState ); } - if ( m_polygonDataSource() == PolygonDataSource::DEFINED_IN_FILTER ) + if ( isPolygonDefinedLocally() ) { - caf::PdmUiGroup* mudWeightWindowGroup = uiOrdering.addNewGroup( "Polygon Definition" ); - m_polygonEditor()->uiOrdering( uiConfigName, *mudWeightWindowGroup ); + caf::PdmUiGroup* polyDefinitionGroup = uiOrdering.addNewGroup( "Polygon Definition" ); + m_polygonEditor()->uiOrdering( uiConfigName, *polyDefinitionGroup ); } } @@ -296,7 +303,7 @@ void RimPolygonFilter::fieldChangedByUi( const caf::PdmFieldHandle* changedField if ( changedField == &m_polygonDataSource ) { - if ( m_polygonDataSource() == PolygonDataSource::GLOBAL_POLYGON && m_cellFilterPolygon() == nullptr ) + if ( !isPolygonDefinedLocally() && m_cellFilterPolygon() == nullptr ) { auto polygonCollection = RimTools::polygonCollection(); if ( polygonCollection && !polygonCollection->allPolygons().empty() ) @@ -304,6 +311,8 @@ void RimPolygonFilter::fieldChangedByUi( const caf::PdmFieldHandle* changedField m_cellFilterPolygon = polygonCollection->allPolygons().front(); } } + configurePolygonEditor(); + updateAllRequiredEditors(); } if ( changedField == &m_cellFilterPolygon ) @@ -760,11 +769,17 @@ void RimPolygonFilter::updateCells() //-------------------------------------------------------------------------------------------------- void RimPolygonFilter::configurePolygonEditor() { - m_polygonEditor->setPolygon( m_cellFilterPolygon() ); + RimPolygon* polygon = nullptr; + if ( isPolygonDefinedLocally() ) + polygon = m_internalPolygon(); + else + polygon = m_cellFilterPolygon(); + + m_polygonEditor->setPolygon( polygon ); // Must connect the signals after polygon is assigned to the polygon editor // When assigning an object to a ptr field, all signals are disconnected - connectObjectSignals( m_cellFilterPolygon() ); + connectObjectSignals( polygon ); } //-------------------------------------------------------------------------------------------------- @@ -835,7 +850,14 @@ caf::PickEventHandler* RimPolygonFilter::pickEventHandler() const //-------------------------------------------------------------------------------------------------- caf::AppEnum RimPolygonFilter::geometricalShape() const { - if ( m_cellFilterPolygon && !m_cellFilterPolygon->isClosed() ) return GeometricalShape::LINE; + if ( isPolygonDefinedLocally() ) + { + if ( !m_internalPolygon->isClosed() ) return GeometricalShape::LINE; + } + else + { + if ( m_cellFilterPolygon && !m_cellFilterPolygon->isClosed() ) return GeometricalShape::LINE; + } return GeometricalShape::AREA; } @@ -845,16 +867,13 @@ caf::AppEnum RimPolygonFilter::geometricalSh //-------------------------------------------------------------------------------------------------- void RimPolygonFilter::setGeometricalShape( const caf::AppEnum& shape ) { - if ( m_cellFilterPolygon ) + if ( isPolygonDefinedLocally() ) { - if ( shape == GeometricalShape::LINE ) - { - m_cellFilterPolygon->setIsClosed( false ); - } - else - { - m_cellFilterPolygon->setIsClosed( true ); - } + m_internalPolygon->setIsClosed( shape == GeometricalShape::AREA ); + } + else if ( m_cellFilterPolygon() ) + { + m_cellFilterPolygon->setIsClosed( shape == GeometricalShape::AREA ); } } @@ -877,9 +896,18 @@ void RimPolygonFilter::initializeCellList() //-------------------------------------------------------------------------------------------------- bool RimPolygonFilter::isPolygonClosed() const { - if ( m_polygonEditor->polygon() ) return m_polygonEditor->polygon()->isClosed(); + if ( isPolygonDefinedLocally() ) return m_internalPolygon->isClosed(); + + if ( m_cellFilterPolygon() ) return m_cellFilterPolygon->isClosed(); - return false; + return true; +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimPolygonFilter::isPolygonDefinedLocally() const +{ + return m_polygonDataSource() == PolygonDataSource::DEFINED_IN_FILTER; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.h b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.h index 4ae1e227fa..72d71a5978 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.h +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.h @@ -89,6 +89,7 @@ class RimPolygonFilter : public RimCellFilter, public RimPolylinePickerInterface QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void initAfterRead() override; void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; + void childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) override; QString fullName() const override; @@ -109,6 +110,7 @@ class RimPolygonFilter : public RimCellFilter, public RimPolylinePickerInterface void initializeCellList(); bool isPolygonClosed() const; + bool isPolygonDefinedLocally() const; void connectObjectSignals( RimPolygon* polygon ); void onObjectChanged( const caf::SignalEmitter* emitter ); From 780c548772636339c8c2857044c2da0e41e7adef Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 21 Feb 2024 11:02:27 +0100 Subject: [PATCH 10/23] Improve UI ordering for contained polygons --- .../CellFilters/RimPolygonFilter.cpp | 16 +++++++++++----- .../Polygons/RimPolygonAppearance.cpp | 2 +- .../Polygons/RimPolygonInView.cpp | 10 ++++++++++ .../ProjectDataModel/Polygons/RimPolygonInView.h | 2 ++ 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp index dd9cf2a41c..c24f1e62ec 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp @@ -207,6 +207,9 @@ void RimPolygonFilter::defineEditorAttribute( const caf::PdmFieldHandle* field, //-------------------------------------------------------------------------------------------------- void RimPolygonFilter::childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) { + // When interactive edit of polyline coordinates in enabled in RimPolygonInView::m_enablePicking, the editors to RimPolygonFilter must + // be updated to trigger calls to RimPolylinePickerInterface + updateConnectedEditors(); } @@ -269,7 +272,7 @@ void RimPolygonFilter::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin if ( isPolygonDefinedLocally() ) { caf::PdmUiGroup* polyDefinitionGroup = uiOrdering.addNewGroup( "Polygon Definition" ); - m_polygonEditor()->uiOrdering( uiConfigName, *polyDefinitionGroup ); + m_polygonEditor()->uiOrderingForLocalPolygon( uiConfigName, *polyDefinitionGroup ); } } @@ -303,12 +306,15 @@ void RimPolygonFilter::fieldChangedByUi( const caf::PdmFieldHandle* changedField if ( changedField == &m_polygonDataSource ) { - if ( !isPolygonDefinedLocally() && m_cellFilterPolygon() == nullptr ) + if ( !isPolygonDefinedLocally() ) { - auto polygonCollection = RimTools::polygonCollection(); - if ( polygonCollection && !polygonCollection->allPolygons().empty() ) + if ( m_cellFilterPolygon() == nullptr || m_cellFilterPolygon() == m_internalPolygon ) { - m_cellFilterPolygon = polygonCollection->allPolygons().front(); + auto polygonCollection = RimTools::polygonCollection(); + if ( polygonCollection && !polygonCollection->allPolygons().empty() ) + { + m_cellFilterPolygon = polygonCollection->allPolygons().front(); + } } } configurePolygonEditor(); diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.cpp b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.cpp index 80d41212f2..1cd83a0a5c 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.cpp +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.cpp @@ -78,7 +78,7 @@ RimPolygonAppearance::RimPolygonAppearance() { CAF_PDM_InitObject( "Polygon", ":/PolylinesFromFile16x16.png" ); - CAF_PDM_InitField( &m_isClosed, "IsClosed", false, "Closed Polygon" ); + CAF_PDM_InitField( &m_isClosed, "IsClosed", true, "Closed Polygon" ); CAF_PDM_InitField( &m_showLines, "ShowLines", true, "Show Lines" ); CAF_PDM_InitField( &m_showSpheres, "ShowSpheres", false, "Show Spheres" ); diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.cpp b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.cpp index 282ad14e2a..673a6e5bf9 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.cpp +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.cpp @@ -292,6 +292,16 @@ void RimPolygonInView::defineObjectEditorAttribute( QString uiConfigName, caf::P } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonInView::uiOrderingForLocalPolygon( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +{ + uiOrdering.add( &m_enablePicking ); + uiOrdering.add( &m_targets ); + uiOrdering.add( &m_handleScalingFactor ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.h b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.h index 15175d41eb..bf402f18cb 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.h +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.h @@ -69,6 +69,8 @@ class RimPolygonInView : public RimCheckableNamedObject, public RimPolylinesData void onChildrenUpdated( caf::PdmChildArrayFieldHandle* childArray, std::vector& updatedObjects ) override; void defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; + void uiOrderingForLocalPolygon( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ); + protected: void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; From 7f80d58c6e67ccf36a051d3098c9dbbfa7ff2f56 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 21 Feb 2024 11:09:54 +0100 Subject: [PATCH 11/23] Rename to polygonInViewCollection --- .../ProjectDataModel/GeoMech/RimGeoMechView.cpp | 2 +- .../ProjectDataModel/RimEclipseView.cpp | 2 +- .../ProjectDataModel/RimGridView.cpp | 14 +++++++------- ApplicationLibCode/ProjectDataModel/RimGridView.h | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp index a2b28b2172..d94b027858 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp @@ -1050,7 +1050,7 @@ void RimGeoMechView::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrderin if ( RiaApplication::enableDevelopmentFeatures() ) { - uiTreeOrdering.add( m_polygonCollection ); + uiTreeOrdering.add( m_polygonInViewCollection ); } uiTreeOrdering.skipRemainingChildren( true ); diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp index 7f23f772c1..d62cc93db5 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp @@ -1954,7 +1954,7 @@ void RimEclipseView::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrderin if ( RiaApplication::enableDevelopmentFeatures() ) { - uiTreeOrdering.add( m_polygonCollection ); + uiTreeOrdering.add( m_polygonInViewCollection ); } uiTreeOrdering.skipRemainingChildren( true ); diff --git a/ApplicationLibCode/ProjectDataModel/RimGridView.cpp b/ApplicationLibCode/ProjectDataModel/RimGridView.cpp index bc0ff08351..8b2c9a33cf 100644 --- a/ApplicationLibCode/ProjectDataModel/RimGridView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimGridView.cpp @@ -99,8 +99,8 @@ RimGridView::RimGridView() CAF_PDM_InitFieldNoDefault( &m_seismicSectionCollection, "SeismicSectionCollection", "Seismic Collection Field" ); m_seismicSectionCollection = new RimSeismicSectionCollection(); - CAF_PDM_InitFieldNoDefault( &m_polygonCollection, "PolygonCollection", "Polygon Collection Field" ); - m_polygonCollection = new RimPolygonInViewCollection(); + CAF_PDM_InitFieldNoDefault( &m_polygonInViewCollection, "PolygonInViewCollection", "Polygon Collection Field" ); + m_polygonInViewCollection = new RimPolygonInViewCollection(); CAF_PDM_InitFieldNoDefault( &m_cellFilterCollection, "RangeFilters", "Cell Filter Collection Field" ); m_cellFilterCollection = new RimCellFilterCollection(); @@ -173,9 +173,9 @@ RimSeismicSectionCollection* RimGridView::seismicSectionCollection() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimPolygonInViewCollection* RimGridView::polygonCollection() const +RimPolygonInViewCollection* RimGridView::polygonInViewCollection() const { - return m_polygonCollection(); + return m_polygonInViewCollection(); } //-------------------------------------------------------------------------------------------------- @@ -405,9 +405,9 @@ void RimGridView::appendPolygonPartsToModel( caf::DisplayCoordTransform* scaleTr m_polygonVizModel->removeAllParts(); std::vector polygonsInView; - if ( m_polygonCollection ) + if ( m_polygonInViewCollection ) { - polygonsInView = m_polygonCollection->polygonsInView(); + polygonsInView = m_polygonInViewCollection->polygonsInView(); } if ( cellFilterCollection() ) @@ -527,7 +527,7 @@ void RimGridView::updateViewTreeItems( RiaDefines::ItemIn3dView itemType ) if ( bitmaskEnum.AnyOf( RiaDefines::ItemIn3dView::POLYGON ) ) { - m_polygonCollection->syncPolygonsInView(); + m_polygonInViewCollection->syncPolygonsInView(); } updateConnectedEditors(); diff --git a/ApplicationLibCode/ProjectDataModel/RimGridView.h b/ApplicationLibCode/ProjectDataModel/RimGridView.h index 53413a950a..e7132010c8 100644 --- a/ApplicationLibCode/ProjectDataModel/RimGridView.h +++ b/ApplicationLibCode/ProjectDataModel/RimGridView.h @@ -55,7 +55,7 @@ class RimGridView : public Rim3dView RimIntersectionResultsDefinitionCollection* separateSurfaceResultsCollection() const; RimWellMeasurementInViewCollection* measurementCollection() const; RimSeismicSectionCollection* seismicSectionCollection() const; - RimPolygonInViewCollection* polygonCollection() const; + RimPolygonInViewCollection* polygonInViewCollection() const; virtual const RimPropertyFilterCollection* propertyFilterCollection() const = 0; @@ -108,7 +108,7 @@ class RimGridView : public Rim3dView caf::PdmChildField m_cellFilterCollection; caf::PdmChildField m_overrideCellFilterCollection; caf::PdmChildField m_seismicSectionCollection; - caf::PdmChildField m_polygonCollection; + caf::PdmChildField m_polygonInViewCollection; private: void onCreatePartCollectionFromSelection( cvf::Collection* parts ) override; From e20f91b3d53deabd31ab32b6186671350a0efc48 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 21 Feb 2024 13:14:37 +0100 Subject: [PATCH 12/23] Make well targets obsolete --- .../CellFilters/RimPolygonFilter.cpp | 21 +++++- .../CellFilters/RimPolygonFilter.h | 4 ++ .../Polygons/CMakeLists_files.cmake | 2 + .../Polygons/RimPolygonTools.cpp | 64 +++++++++++++++++++ .../Polygons/RimPolygonTools.h | 36 +++++++++++ 5 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonTools.cpp create mode 100644 ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonTools.h diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp index c24f1e62ec..8473461797 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp @@ -34,6 +34,7 @@ #include "Polygons/RimPolygon.h" #include "Polygons/RimPolygonCollection.h" #include "Polygons/RimPolygonInView.h" +#include "Polygons/RimPolygonTools.h" #include "Riu3DMainWindowTools.h" @@ -123,6 +124,12 @@ RimPolygonFilter::RimPolygonFilter() m_editPolygonButton.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); m_editPolygonButton.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); + CAF_PDM_InitFieldNoDefault( &m_OBSOLETE_targets, "Targets", "Targets" ); + m_OBSOLETE_targets.uiCapability()->setUiTreeChildrenHidden( true ); + m_OBSOLETE_targets.uiCapability()->setUiTreeHidden( true ); + m_OBSOLETE_targets.uiCapability()->setUiHidden( true ); + m_OBSOLETE_targets.xmlCapability()->setIOWritable( false ); + m_propagateToSubGrids = false; updateIconState(); @@ -179,6 +186,18 @@ void RimPolygonFilter::initAfterRead() { RimCellFilter::initAfterRead(); + // Move existing polygons to global polygon + if ( !m_OBSOLETE_targets.empty() ) + { + std::vector points; + for ( const auto& target : m_OBSOLETE_targets ) + { + points.push_back( target->targetPointXYZ() ); + } + + m_internalPolygon->setPointsInDomainCoords( points ); + } + configurePolygonEditor(); } @@ -297,7 +316,7 @@ void RimPolygonFilter::fieldChangedByUi( const caf::PdmFieldHandle* changedField { if ( changedField == &m_editPolygonButton ) { - if ( m_cellFilterPolygon() ) Riu3DMainWindowTools::selectAsCurrentItem( m_cellFilterPolygon() ); + RimPolygonTools::selectPolygonInView( m_cellFilterPolygon(), this ); m_editPolygonButton = false; diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.h b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.h index 72d71a5978..ec9acefa91 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.h +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.h @@ -23,11 +23,13 @@ #include "RimPolylinePickerInterface.h" #include "cafAppEnum.h" +#include "cafPdmChildArrayField.h" #include "cafPdmChildField.h" #include "cafPdmObject.h" #include "cafPdmPtrField.h" class RimPolygon; +class RimPolylineTarget; class RigGridBase; class RigFemPartGrid; class RimPolygonInView; @@ -148,4 +150,6 @@ class RimPolygonFilter : public RimCellFilter, public RimPolylinePickerInterface caf::PdmField m_editPolygonButton; std::shared_ptr m_pickTargetsEventHandler; + + caf::PdmChildArrayField m_OBSOLETE_targets; }; diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/Polygons/CMakeLists_files.cmake index af99df45c7..ace8580f7d 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/CMakeLists_files.cmake +++ b/ApplicationLibCode/ProjectDataModel/Polygons/CMakeLists_files.cmake @@ -5,6 +5,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RimPolygonInView.h ${CMAKE_CURRENT_LIST_DIR}/RimPolygonInViewCollection.h ${CMAKE_CURRENT_LIST_DIR}/RimPolygonAppearance.h + ${CMAKE_CURRENT_LIST_DIR}/RimPolygonTools.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -14,6 +15,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RimPolygonInView.cpp ${CMAKE_CURRENT_LIST_DIR}/RimPolygonInViewCollection.cpp ${CMAKE_CURRENT_LIST_DIR}/RimPolygonAppearance.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimPolygonTools.cpp ) list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonTools.cpp b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonTools.cpp new file mode 100644 index 0000000000..544f343edd --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonTools.cpp @@ -0,0 +1,64 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "RimPolygonTools.h" + +#include "RimGridView.h" +#include "RimOilField.h" +#include "RimPolygon.h" +#include "RimPolygonCollection.h" +#include "RimPolygonInView.h" +#include "RimPolygonInViewCollection.h" +#include "RimProject.h" + +#include "Riu3DMainWindowTools.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonTools::selectPolygonInView( RimPolygon* polygon, caf::PdmObject* sourceObject ) +{ + auto polygonInView = findPolygonInView( polygon, sourceObject ); + if ( polygonInView ) + { + polygonInView->enablePicking( true ); + Riu3DMainWindowTools::selectAsCurrentItem( polygonInView ); + } +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimPolygonInView* RimPolygonTools::findPolygonInView( RimPolygon* polygon, caf::PdmObject* sourceObject ) +{ + if ( auto gridView = sourceObject->firstAncestorOfType() ) + { + auto polyCollection = gridView->polygonInViewCollection(); + + for ( auto polygonInView : polyCollection->polygonsInView() ) + { + if ( polygonInView && polygonInView->polygon() == polygon ) + { + return polygonInView; + } + } + } + + return nullptr; +} diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonTools.h b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonTools.h new file mode 100644 index 0000000000..e45826e4e8 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonTools.h @@ -0,0 +1,36 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 + +class RimPolygon; +class RimPolygonInView; + +namespace caf +{ +class PdmObject; +} + +class RimPolygonTools +{ +public: + static void selectPolygonInView( RimPolygon* polygon, caf::PdmObject* sourceObject ); + +private: + static RimPolygonInView* findPolygonInView( RimPolygon* polygon, caf::PdmObject* sourceObject ); +}; From 3c3a12bb759a4b824a197c9ef622420bc28d9606 Mon Sep 17 00:00:00 2001 From: magnesj Date: Wed, 21 Feb 2024 12:15:21 +0000 Subject: [PATCH 13/23] Fixes by clang-format --- ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonTools.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonTools.cpp b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonTools.cpp index 544f343edd..d42ebbc9d5 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonTools.cpp +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonTools.cpp @@ -41,7 +41,6 @@ void RimPolygonTools::selectPolygonInView( RimPolygon* polygon, caf::PdmObject* } } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- From 5db14e1cbd5a6bd8d6a28c379424bf298e7d80fc Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 21 Feb 2024 13:23:43 +0100 Subject: [PATCH 14/23] Renaming --- .../PointTangentManipulator/RicPolylineTarget3dEditor.cpp | 2 +- .../ProjectDataModel/Polygons/RimPolygonInView.cpp | 2 +- ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.h | 2 +- .../ProjectDataModel/RimPolylinePickerInterface.cpp | 2 +- .../ProjectDataModel/RimPolylinePickerInterface.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicPolylineTarget3dEditor.cpp b/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicPolylineTarget3dEditor.cpp index 504eff978d..6bf4a98b48 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicPolylineTarget3dEditor.cpp +++ b/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicPolylineTarget3dEditor.cpp @@ -100,7 +100,7 @@ void RicPolylineTarget3dEditor::configureAndUpdateUi( const QString& uiConfigNam double scalingFactor = 0.7; if ( auto pickerInterface = target->firstAncestorOrThisOfType() ) { - scalingFactor *= pickerInterface->handleScalingFactor(); + scalingFactor *= pickerInterface->scalingFactorForTarget(); } const double handleSize = scalingFactor * view->characteristicCellSize(); diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.cpp b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.cpp index 673a6e5bf9..a4c1e1c346 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.cpp +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.cpp @@ -305,7 +305,7 @@ void RimPolygonInView::uiOrderingForLocalPolygon( QString uiConfigName, caf::Pdm //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double RimPolygonInView::handleScalingFactor() const +double RimPolygonInView::scalingFactorForTarget() const { return m_handleScalingFactor(); } diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.h b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.h index bf402f18cb..2883ead0c7 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.h +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.h @@ -62,7 +62,7 @@ class RimPolygonInView : public RimCheckableNamedObject, public RimPolylinesData std::vector activeTargets() const override; bool pickingEnabled() const override; caf::PickEventHandler* pickEventHandler() const override; - double handleScalingFactor() const override; + double scalingFactorForTarget() const override; cvf::ref polyLinesData() const override; diff --git a/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.cpp b/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.cpp index 9a737a0d5a..8c04d6124c 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.cpp @@ -23,7 +23,7 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double RimPolylinePickerInterface::handleScalingFactor() const +double RimPolylinePickerInterface::scalingFactorForTarget() const { return 1.0; } diff --git a/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.h b/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.h index 5ec2007d73..7dc6b61a9a 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.h +++ b/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.h @@ -38,7 +38,7 @@ class RimPolylinePickerInterface virtual std::vector activeTargets() const = 0; virtual bool pickingEnabled() const = 0; virtual caf::PickEventHandler* pickEventHandler() const = 0; - virtual double handleScalingFactor() const; + virtual double scalingFactorForTarget() const; std::pair findActiveTargetsAroundInsertionPoint( const RimPolylineTarget* targetToInsertBefore ); }; From 4f069c04740d4ab054fc22c6e4653cf13f8127cc Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 21 Feb 2024 15:22:44 +0100 Subject: [PATCH 15/23] Show appearance for local polygon --- .../ProjectDataModel/CellFilters/RimPolygonFilter.cpp | 4 ++++ .../ProjectDataModel/Polygons/RimPolygon.cpp | 8 ++++++++ ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.h | 2 ++ 3 files changed, 14 insertions(+) diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp index 8473461797..11ce1e2c40 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp @@ -292,6 +292,10 @@ void RimPolygonFilter::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin { caf::PdmUiGroup* polyDefinitionGroup = uiOrdering.addNewGroup( "Polygon Definition" ); m_polygonEditor()->uiOrderingForLocalPolygon( uiConfigName, *polyDefinitionGroup ); + + caf::PdmUiGroup* appearanceGroup = uiOrdering.addNewGroup( "Appearance" ); + appearanceGroup->setCollapsedByDefault(); + m_internalPolygon->uiOrderingForLocalPolygon( uiConfigName, *appearanceGroup ); } } diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.cpp b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.cpp index e81f422fb8..074a7d20e8 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.cpp +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.cpp @@ -53,6 +53,14 @@ cvf::ref RimPolygon::polyLinesData() const return pld; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygon::uiOrderingForLocalPolygon( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +{ + m_appearance->uiOrdering( uiConfigName, uiOrdering ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.h b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.h index 9bedb18a97..455ace4578 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.h +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.h @@ -45,6 +45,8 @@ class RimPolygon : public RimNamedObject, public RimPolylinesDataInterface cvf::ref polyLinesData() const override; + void uiOrderingForLocalPolygon( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ); + protected: void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; From 646d216befabacdfa7924819f20df1ea213886d2 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 22 Feb 2024 07:20:54 +0100 Subject: [PATCH 16/23] Clean up includes --- .../RicIntersectionPickEventHandler.cpp | 71 +++++++++---------- .../RimExtrudedCurveIntersection.cpp | 19 +---- .../RimExtrudedCurveIntersection.h | 12 ++-- .../Intersections/RimIntersection.cpp | 1 - .../Intersections/RimIntersection.h | 1 - 5 files changed, 41 insertions(+), 63 deletions(-) diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicIntersectionPickEventHandler.cpp b/ApplicationLibCode/Commands/WellPathCommands/RicIntersectionPickEventHandler.cpp index bcdb1233c1..b699df4383 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicIntersectionPickEventHandler.cpp +++ b/ApplicationLibCode/Commands/WellPathCommands/RicIntersectionPickEventHandler.cpp @@ -44,44 +44,41 @@ bool RicIntersectionPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& e std::vector selection; caf::SelectionManager::instance()->objectsByType( &selection ); - if ( selection.size() == 1 ) + if ( selection.size() != 1 ) return false; + + RimExtrudedCurveIntersection* intersection = selection[0]; + + RimGridView* gridView = intersection->firstAncestorOrThisOfTypeAsserted(); + + if ( RiaApplication::instance()->activeMainOrComparisonGridView() != gridView ) + { + return false; + } + + cvf::ref transForm = gridView->displayCoordTransform(); + + cvf::Vec3d domainCoord = transForm->transformToDomainCoord( eventObject.m_pickItemInfos.front().globalPickedPoint() ); + + if ( intersection->inputPolyLineFromViewerEnabled() ) { - { - RimExtrudedCurveIntersection* intersection = selection[0]; - - RimGridView* gridView = intersection->firstAncestorOrThisOfTypeAsserted(); - - if ( RiaApplication::instance()->activeMainOrComparisonGridView() != gridView ) - { - return false; - } - - cvf::ref transForm = gridView->displayCoordTransform(); - - cvf::Vec3d domainCoord = transForm->transformToDomainCoord( eventObject.m_pickItemInfos.front().globalPickedPoint() ); - - if ( intersection->inputPolyLineFromViewerEnabled() ) - { - intersection->appendPointToPolyLine( domainCoord ); - - // Further Ui processing is stopped when true is returned - return true; - } - else if ( intersection->inputExtrusionPointsFromViewerEnabled() ) - { - intersection->appendPointToExtrusionDirection( domainCoord ); - - // Further Ui processing is stopped when true is returned - return true; - } - else if ( intersection->inputTwoAzimuthPointsFromViewerEnabled() ) - { - intersection->appendPointToAzimuthLine( domainCoord ); - - // Further Ui processing is stopped when true is returned - return true; - } - } + intersection->appendPointToPolyLine( domainCoord ); + + // Further Ui processing is stopped when true is returned + return true; + } + else if ( intersection->inputExtrusionPointsFromViewerEnabled() ) + { + intersection->appendPointToExtrusionDirection( domainCoord ); + + // Further Ui processing is stopped when true is returned + return true; + } + else if ( intersection->inputTwoAzimuthPointsFromViewerEnabled() ) + { + intersection->appendPointToAzimuthLine( domainCoord ); + + // Further Ui processing is stopped when true is returned + return true; } return false; diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp b/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp index bd3faab8f0..519f244b4e 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp @@ -21,7 +21,6 @@ #include "RiaVec3Tools.h" -#include "RigEclipseCaseData.h" #include "RigMainGrid.h" #include "RigSimulationWellCenterLineCalculator.h" #include "RigWellPath.h" @@ -29,15 +28,8 @@ #include "Rim2dIntersectionView.h" #include "Rim3dView.h" #include "RimCase.h" -#include "RimEclipseCase.h" #include "RimEclipseView.h" -#include "RimEnsembleSurface.h" #include "RimGeoMechView.h" -#include "RimGridView.h" -#include "RimIntersectionResultDefinition.h" -#include "RimIntersectionResultsDefinitionCollection.h" -#include "RimOilField.h" -#include "RimProject.h" #include "RimSimWellInView.h" #include "RimSimWellInViewCollection.h" #include "RimSurface.h" @@ -48,12 +40,8 @@ #include "RimTools.h" #include "RimWellPath.h" -#include "RiuViewer.h" - #include "RivExtrudedCurveIntersectionPartMgr.h" -#include "cafCmdFeature.h" -#include "cafCmdFeatureManager.h" #include "cafPdmFieldScriptingCapability.h" #include "cafPdmFieldScriptingCapabilityCvfVec3d.h" #include "cafPdmObjectScriptingCapability.h" @@ -61,12 +49,9 @@ #include "cafPdmUiDoubleSliderEditor.h" #include "cafPdmUiListEditor.h" #include "cafPdmUiPushButtonEditor.h" -#include "cafPdmUiSliderEditor.h" #include "cafPdmUiTreeOrdering.h" -#include "cafPdmUiTreeSelectionEditor.h" #include "cvfBoundingBox.h" #include "cvfGeometryTools.h" -#include "cvfPlane.h" namespace caf { @@ -775,8 +760,6 @@ std::vector> RimExtrudedCurveIntersection::polyLines( cv { if ( m_simulationWell() ) { - updateSimulationWellCenterline(); - int branchIndexToUse = branchIndex(); if ( 0 <= branchIndexToUse && branchIndexToUse < static_cast( m_simulationWellBranchCenterlines.size() ) ) @@ -863,7 +846,7 @@ std::vector RimExtrudedCurveIntersection::polyLinesForExtrusionDirec //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimExtrudedCurveIntersection::updateSimulationWellCenterline() const +void RimExtrudedCurveIntersection::updateSimulationWellCenterline() { if ( m_isActive() && type() == CrossSectionEnum::CS_SIMULATION_WELL && m_simulationWell() ) { diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.h b/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.h index a27079113e..5a2a6ccc24 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.h +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.h @@ -24,9 +24,10 @@ #include "RimIntersectionEnums.h" #include "cafPdmChildField.h" +#include "cafPdmFieldCvfVec3d.h" #include "cafPdmProxyValueField.h" -#include +#include "cvfVector3.h" class RimWellPath; class RivExtrudedCurveIntersectionPartMgr; @@ -134,7 +135,7 @@ class RimExtrudedCurveIntersection : public RimIntersection int branchIndex() const; void rebuildGeometryAndScheduleCreateDisplayModel(); -protected: +private: caf::PdmFieldHandle* userDescriptionField() final; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; @@ -143,13 +144,12 @@ class RimExtrudedCurveIntersection : public RimIntersection void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; -private: static void setPushButtonText( bool buttonEnable, caf::PdmUiPushButtonEditorAttribute* attribute ); static void setBaseColor( bool enable, caf::PdmUiListEditorAttribute* attribute ); RimSimWellInViewCollection* simulationWellCollection() const; void updateAzimuthLine(); - void updateSimulationWellCenterline() const; + void updateSimulationWellCenterline(); void addExtents( std::vector& polyLine ) const; void updateName(); static double azimuthInRadians( cvf::Vec3d vec ); @@ -202,11 +202,11 @@ class RimExtrudedCurveIntersection : public RimIntersection cvf::ref m_crossSectionPartMgr; - mutable std::vector> m_simulationWellBranchCenterlines; + std::vector> m_simulationWellBranchCenterlines; caf::PdmField m_enableKFilter; caf::PdmField m_kFilterText; caf::PdmField m_kFilterCollectionOverride; caf::PdmField m_kFilterCollectionText; -}; \ No newline at end of file +}; diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersection.cpp b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersection.cpp index a5226cf1a5..5eabceaf88 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersection.cpp @@ -19,7 +19,6 @@ #include "RimIntersection.h" #include "RigEclipseCaseData.h" -#include "RigFemPartCollection.h" #include "RigGeoMechCaseData.h" #include "RimEclipseCase.h" #include "RimEclipseResultDefinition.h" diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersection.h b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersection.h index e94d2ff776..df8b70d7ba 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersection.h +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersection.h @@ -18,7 +18,6 @@ #pragma once #include "cafPdmField.h" -#include "cafPdmFieldCvfVec3d.h" #include "cafPdmObject.h" #include "cafPdmPtrField.h" From c564bcb52e2b7d98923c658ee796082034e1a36e Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 22 Feb 2024 08:20:48 +0100 Subject: [PATCH 17/23] Add polygon as data source for intersection --- ...cSeismicSectionFromIntersectionFeature.cpp | 4 +- .../RimExtrudedCurveIntersection.cpp | 72 +++++++++++++++++-- .../RimExtrudedCurveIntersection.h | 8 ++- .../Polygons/RimPolygonTools.cpp | 5 ++ 4 files changed, 82 insertions(+), 7 deletions(-) diff --git a/ApplicationLibCode/Commands/SeismicCommands/RicSeismicSectionFromIntersectionFeature.cpp b/ApplicationLibCode/Commands/SeismicCommands/RicSeismicSectionFromIntersectionFeature.cpp index 445ead3336..180db89511 100644 --- a/ApplicationLibCode/Commands/SeismicCommands/RicSeismicSectionFromIntersectionFeature.cpp +++ b/ApplicationLibCode/Commands/SeismicCommands/RicSeismicSectionFromIntersectionFeature.cpp @@ -47,6 +47,7 @@ bool RicSeismicSectionFromIntersectionFeature::isCommandEnabled() const if ( intersection != nullptr ) { return ( ( intersection->type() == RimExtrudedCurveIntersection::CrossSectionEnum::CS_POLYLINE ) || + ( intersection->type() == RimExtrudedCurveIntersection::CrossSectionEnum::CS_POLYGON ) || ( intersection->type() == RimExtrudedCurveIntersection::CrossSectionEnum::CS_WELL_PATH ) ); } @@ -70,7 +71,8 @@ void RicSeismicSectionFromIntersectionFeature::onActionTriggered( bool isChecked RimSeismicSection* newSection = seisColl->addNewSection(); if ( !newSection ) return; - if ( intersection->type() == RimExtrudedCurveIntersection::CrossSectionEnum::CS_POLYLINE ) + if ( ( intersection->type() == RimExtrudedCurveIntersection::CrossSectionEnum::CS_POLYLINE ) || + ( intersection->type() == RimExtrudedCurveIntersection::CrossSectionEnum::CS_POLYGON ) ) { newSection->setSectionType( RiaDefines::SeismicSectionType::SS_POLYLINE ); newSection->setUserDescription( intersection->name() ); diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp b/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp index 519f244b4e..dfc251b0e8 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp @@ -22,9 +22,14 @@ #include "RiaVec3Tools.h" #include "RigMainGrid.h" +#include "RigPolyLinesData.h" #include "RigSimulationWellCenterLineCalculator.h" #include "RigWellPath.h" +#include "Polygons/RimPolygon.h" +#include "Polygons/RimPolygonCollection.h" +#include "Polygons/RimPolygonTools.h" + #include "Rim2dIntersectionView.h" #include "Rim3dView.h" #include "RimCase.h" @@ -62,6 +67,7 @@ void caf::AppEnum::setUp() addItem( RimExtrudedCurveIntersection::CrossSectionEnum::CS_SIMULATION_WELL, "CS_SIMULATION_WELL", "Simulation Well" ); addItem( RimExtrudedCurveIntersection::CrossSectionEnum::CS_POLYLINE, "CS_POLYLINE", "Polyline" ); addItem( RimExtrudedCurveIntersection::CrossSectionEnum::CS_AZIMUTHLINE, "CS_AZIMUTHLINE", "Azimuth and Dip" ); + addItem( RimExtrudedCurveIntersection::CrossSectionEnum::CS_POLYGON, "CS_POLYGON", "Project Polygon" ); setDefault( RimExtrudedCurveIntersection::CrossSectionEnum::CS_POLYLINE ); } @@ -171,6 +177,14 @@ void RimExtrudedCurveIntersection::configureForPolyLine() m_inputPolylineFromViewerEnabled = true; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimExtrudedCurveIntersection::configureForProjectPolyLine() +{ + m_type = CrossSectionEnum::CS_POLYGON; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -192,6 +206,12 @@ RimExtrudedCurveIntersection::RimExtrudedCurveIntersection() CAF_PDM_InitFieldNoDefault( &m_direction, "Direction", "Direction" ); CAF_PDM_InitScriptableFieldNoDefault( &m_wellPath, "WellPath", "Well Path " ); CAF_PDM_InitScriptableFieldNoDefault( &m_simulationWell, "SimulationWell", "Simulation Well" ); + + CAF_PDM_InitScriptableFieldNoDefault( &m_projectPolygon, "ProjectPolygon", "Project Polygon" ); + CAF_PDM_InitField( &m_editPolygonButton, "EditPolygonButton", false, "Edit" ); + m_editPolygonButton.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); + m_editPolygonButton.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); + CAF_PDM_InitScriptableFieldNoDefault( &m_userPolylineXyz, "Points", "Points", "", "Use Ctrl-C for copy and Ctrl-V for paste", "" ); CAF_PDM_InitFieldNoDefault( &m_userPolylineXydForUi, "PointsUi", "Points", "", "Use Ctrl-C for copy and Ctrl-V for paste", "" ); @@ -424,11 +444,11 @@ void RimExtrudedCurveIntersection::setKFilterOverride( bool collectionOverride, void RimExtrudedCurveIntersection::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) { if ( changedField == &m_isActive || changedField == &m_type || changedField == &m_direction || changedField == &m_wellPath || - changedField == &m_simulationWell || changedField == &m_branchIndex || changedField == &m_extentLength || - changedField == &m_lengthUp || changedField == &m_lengthDown || changedField == &m_showInactiveCells || - changedField == &m_useSeparateDataSource || changedField == &m_separateDataSource || changedField == &m_depthUpperThreshold || - changedField == &m_depthLowerThreshold || changedField == &m_depthThresholdOverridden || changedField == &m_depthFilterType || - changedField == &m_enableKFilter || changedField == &m_kFilterText || changedField == &m_kFilterCollectionOverride ) + changedField == &m_simulationWell || changedField == &m_branchIndex || changedField == &m_extentLength || changedField == &m_lengthUp || + changedField == &m_lengthDown || changedField == &m_showInactiveCells || changedField == &m_useSeparateDataSource || + changedField == &m_separateDataSource || changedField == &m_depthUpperThreshold || changedField == &m_depthLowerThreshold || + changedField == &m_depthThresholdOverridden || changedField == &m_depthFilterType || changedField == &m_enableKFilter || + changedField == &m_kFilterText || changedField == &m_kFilterCollectionOverride || changedField == &m_projectPolygon ) { rebuildGeometryAndScheduleCreateDisplayModel(); } @@ -496,6 +516,15 @@ void RimExtrudedCurveIntersection::fieldChangedByUi( const caf::PdmFieldHandle* { rebuildGeometryAndScheduleCreateDisplayModel(); } + + if ( changedField == &m_editPolygonButton ) + { + RimPolygonTools::selectPolygonInView( m_projectPolygon(), this ); + + m_editPolygonButton = false; + + return; + } } //-------------------------------------------------------------------------------------------------- @@ -525,6 +554,11 @@ void RimExtrudedCurveIntersection::defineUiOrdering( QString uiConfigName, caf:: geometryGroup->add( &m_userPolylineXydForUi ); geometryGroup->add( &m_inputPolylineFromViewerEnabled ); } + else if ( type() == CrossSectionEnum::CS_POLYGON ) + { + geometryGroup->add( &m_projectPolygon ); + geometryGroup->add( &m_editPolygonButton, { .newRow = false } ); + } else if ( type() == CrossSectionEnum::CS_AZIMUTHLINE ) { geometryGroup->add( &m_twoAzimuthPoints ); @@ -653,6 +687,19 @@ QList RimExtrudedCurveIntersection::calculateValueOption options.push_front( caf::PdmOptionItemInfo( "None", nullptr ) ); } } + else if ( fieldNeedingOptions == &m_projectPolygon ) + { + options.push_back( caf::PdmOptionItemInfo( "None", nullptr ) ); + + RimTools::polygonOptionItems( &options ); + + if ( m_projectPolygon() == nullptr ) + { + auto polygonCollection = RimTools::polygonCollection(); + auto polygons = polygonCollection->allPolygons(); + if ( !polygons.empty() ) m_projectPolygon = polygons.front(); + } + } else if ( fieldNeedingOptions == &m_branchIndex ) { updateSimulationWellCenterline(); @@ -777,6 +824,13 @@ std::vector> RimExtrudedCurveIntersection::polyLines( cv { lines.push_back( m_userPolylineXyz ); } + else if ( type() == CrossSectionEnum::CS_POLYGON ) + { + if ( m_projectPolygon ) + { + lines = m_projectPolygon->polyLinesData()->polyLines(); + } + } else if ( type() == CrossSectionEnum::CS_AZIMUTHLINE ) { lines.push_back( m_twoAzimuthPoints ); @@ -1064,6 +1118,14 @@ void RimExtrudedCurveIntersection::defineEditorAttribute( const caf::PdmFieldHan { setBaseColor( m_inputExtrusionPointsFromViewerEnabled, dynamic_cast( attribute ) ); } + + if ( field == &m_editPolygonButton ) + { + if ( auto attrib = dynamic_cast( attribute ) ) + { + attrib->m_buttonText = "Edit"; + } + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.h b/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.h index 5a2a6ccc24..67701f1b0d 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.h +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.h @@ -41,6 +41,7 @@ class RimSurfaceCollection; class RimSurfaceIntersectionCollection; class RimSurfaceIntersectionCurve; class RimSurfaceIntersectionBand; +class RimPolygon; namespace caf { @@ -63,7 +64,8 @@ class RimExtrudedCurveIntersection : public RimIntersection CS_WELL_PATH, CS_SIMULATION_WELL, CS_POLYLINE, - CS_AZIMUTHLINE + CS_AZIMUTHLINE, + CS_POLYGON, }; enum class CrossSectionDirEnum @@ -103,6 +105,7 @@ class RimExtrudedCurveIntersection : public RimIntersection void configureForSimulationWell( RimSimWellInView* simWell ); void configureForWellPath( RimWellPath* wellPath ); void configureForPolyLine(); + void configureForProjectPolyLine(); void configureForAzimuthLine(); std::vector> polyLines( cvf::Vec3d* flattenedPolylineStartPoint = nullptr ) const; @@ -181,6 +184,9 @@ class RimExtrudedCurveIntersection : public RimIntersection caf::PdmPtrField m_wellPath; caf::PdmPtrField m_simulationWell; + caf::PdmPtrField m_projectPolygon; + caf::PdmField m_editPolygonButton; + caf::PdmField m_inputPolylineFromViewerEnabled; caf::PdmField m_inputExtrusionPointsFromViewerEnabled; caf::PdmField m_inputTwoAzimuthPointsFromViewerEnabled; diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonTools.cpp b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonTools.cpp index d42ebbc9d5..d77eedb328 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonTools.cpp +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonTools.cpp @@ -46,6 +46,11 @@ void RimPolygonTools::selectPolygonInView( RimPolygon* polygon, caf::PdmObject* //-------------------------------------------------------------------------------------------------- RimPolygonInView* RimPolygonTools::findPolygonInView( RimPolygon* polygon, caf::PdmObject* sourceObject ) { + if ( !polygon || !sourceObject ) + { + return nullptr; + } + if ( auto gridView = sourceObject->firstAncestorOfType() ) { auto polyCollection = gridView->polygonInViewCollection(); From 6aa77dcdb1fa6dee2fd93bd60b4ad15206127aee Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 22 Feb 2024 08:39:44 +0100 Subject: [PATCH 18/23] Add support for returning complete closed polygon --- .../ModelVisualization/RivPolylinePartMgr.cpp | 4 +-- .../RimPolylinesFromFileAnnotation.cpp | 2 +- .../RimExtrudedCurveIntersection.cpp | 2 +- .../ReservoirDataModel/RigPolyLinesData.cpp | 28 ++++++++++++++++++- .../ReservoirDataModel/RigPolyLinesData.h | 3 +- 5 files changed, 33 insertions(+), 6 deletions(-) diff --git a/ApplicationLibCode/ModelVisualization/RivPolylinePartMgr.cpp b/ApplicationLibCode/ModelVisualization/RivPolylinePartMgr.cpp index 95b7a54332..d7c15ced50 100644 --- a/ApplicationLibCode/ModelVisualization/RivPolylinePartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/RivPolylinePartMgr.cpp @@ -82,7 +82,7 @@ bool RivPolylinePartMgr::isPolylinesInBoundingBox( std::vectorpolyLinesData(); - if ( polylineDef.isNull() || polylineDef->polyLines().empty() ) + if ( polylineDef.isNull() || polylineDef->rawPolyLines().empty() ) { clearAllGeometry(); return; @@ -192,7 +192,7 @@ void RivPolylinePartMgr::buildPolylineParts( const caf::DisplayCoordTransform* d //-------------------------------------------------------------------------------------------------- std::vector> RivPolylinePartMgr::getPolylinesPointsInDomain( RigPolyLinesData* lineDef ) { - auto polylines = lineDef->polyLines(); + auto polylines = lineDef->rawPolyLines(); if ( !lineDef->lockToZPlane() ) return polylines; const double planeZ = lineDef->lockedZValue(); diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesFromFileAnnotation.cpp b/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesFromFileAnnotation.cpp index a78843ddd0..ca7a0c6efc 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesFromFileAnnotation.cpp +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesFromFileAnnotation.cpp @@ -158,7 +158,7 @@ bool RimPolylinesFromFileAnnotation::isEmpty() { if ( m_polyLinesData.isNull() ) return true; - for ( const std::vector& line : m_polyLinesData->polyLines() ) + for ( const std::vector& line : m_polyLinesData->rawPolyLines() ) { if ( !line.empty() ) return false; } diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp b/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp index dfc251b0e8..d9128dc51a 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp @@ -828,7 +828,7 @@ std::vector> RimExtrudedCurveIntersection::polyLines( cv { if ( m_projectPolygon ) { - lines = m_projectPolygon->polyLinesData()->polyLines(); + lines = m_projectPolygon->polyLinesData()->completePolyLines(); } } else if ( type() == CrossSectionEnum::CS_AZIMUTHLINE ) diff --git a/ApplicationLibCode/ReservoirDataModel/RigPolyLinesData.cpp b/ApplicationLibCode/ReservoirDataModel/RigPolyLinesData.cpp index 88318e1ec5..7a282e3a85 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigPolyLinesData.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigPolyLinesData.cpp @@ -44,11 +44,37 @@ RigPolyLinesData::~RigPolyLinesData() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const std::vector>& RigPolyLinesData::polyLines() const +const std::vector>& RigPolyLinesData::rawPolyLines() const { return m_polylines; } +//-------------------------------------------------------------------------------------------------- +/// Returns the polylines with the last point equal to the first point if the polyline is closed +//-------------------------------------------------------------------------------------------------- +const std::vector> RigPolyLinesData::completePolyLines() const +{ + if ( !m_closePolyline ) return m_polylines; + + std::vector> completeLines; + for ( const auto& polyline : m_polylines ) + { + auto completePolyline = polyline; + if ( !polyline.empty() ) + { + const double epsilon = 1e-6; + + if ( polyline.front().pointDistance( polyline.back() ) > epsilon ) + { + completePolyline.push_back( polyline.front() ); + } + } + completeLines.push_back( completePolyline ); + } + + return completeLines; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ReservoirDataModel/RigPolyLinesData.h b/ApplicationLibCode/ReservoirDataModel/RigPolyLinesData.h index 5e0fcf176b..f11c92dc27 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigPolyLinesData.h +++ b/ApplicationLibCode/ReservoirDataModel/RigPolyLinesData.h @@ -34,7 +34,8 @@ class RigPolyLinesData : public cvf::Object RigPolyLinesData(); ~RigPolyLinesData() override; - const std::vector>& polyLines() const; + const std::vector>& rawPolyLines() const; + const std::vector> completePolyLines() const; void setPolyLines( const std::vector>& polyLines ); void setPolyLine( const std::vector& polyline ); From a6838c60b089e24d83b68cad979ccaf594c34337 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 22 Feb 2024 10:07:41 +0100 Subject: [PATCH 19/23] Fix build --- .../Intersections/RimExtrudedCurveIntersection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp b/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp index d9128dc51a..f4639815c4 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp @@ -207,7 +207,7 @@ RimExtrudedCurveIntersection::RimExtrudedCurveIntersection() CAF_PDM_InitScriptableFieldNoDefault( &m_wellPath, "WellPath", "Well Path " ); CAF_PDM_InitScriptableFieldNoDefault( &m_simulationWell, "SimulationWell", "Simulation Well" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_projectPolygon, "ProjectPolygon", "Project Polygon" ); + CAF_PDM_InitFieldNoDefault( &m_projectPolygon, "ProjectPolygon", "Project Polygon" ); CAF_PDM_InitField( &m_editPolygonButton, "EditPolygonButton", false, "Edit" ); m_editPolygonButton.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); m_editPolygonButton.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); From 8e8b2c2fff521fe45ab0c38b7f6a807c09aa40a7 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 22 Feb 2024 10:51:48 +0100 Subject: [PATCH 20/23] Make it possible to add items to context menu in Pdm objects --- .../ProjectDataModel/RimContextCommandBuilder.cpp | 5 +++++ .../cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.h | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp index 6c6b658358..7adc007c08 100644 --- a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -1157,6 +1157,11 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() if ( firstUiItem ) { + if ( auto pdmObject = dynamic_cast( firstUiItem ) ) + { + pdmObject->appendMenuItems( menuBuilder ); + } + // Work in progress -- Start // All commands should be aware of selection of multiple objects // Based on the selection, the command feature can decide if the command diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.h index ee395297a1..b65fc7d242 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.h @@ -13,6 +13,7 @@ class PdmObjectHandle; class PdmUiOrdering; class PdmFieldHandle; class PdmUiEditorAttribute; +class CmdFeatureMenuBuilder; class PdmUiObjectHandle : public PdmUiItem, public PdmObjectCapability { @@ -44,6 +45,9 @@ class PdmUiObjectHandle : public PdmUiItem, public PdmObjectCapability void updateUiIconFromToggleField(); + /// Append actions to menu builder + virtual void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const {} + // Virtual interface to override in subclasses to support special behaviour if needed public: // Virtual virtual caf::PdmFieldHandle* userDescriptionField() { return nullptr; } From 21b64a55adce0dc4f9763b3aee3b127c13149b57 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 22 Feb 2024 11:00:52 +0100 Subject: [PATCH 21/23] Add new polygon intersection feature --- .../CMakeLists_files.cmake | 2 + .../RicNewPolygonIntersectionFeature.cpp | 69 +++++++++++++++++++ .../RicNewPolygonIntersectionFeature.h | 33 +++++++++ .../RimExtrudedCurveIntersection.cpp | 12 +++- .../RimExtrudedCurveIntersection.h | 2 +- .../ProjectDataModel/Polygons/RimPolygon.cpp | 11 +++ .../ProjectDataModel/Polygons/RimPolygon.h | 6 ++ 7 files changed, 131 insertions(+), 4 deletions(-) create mode 100644 ApplicationLibCode/Commands/CrossSectionCommands/RicNewPolygonIntersectionFeature.cpp create mode 100644 ApplicationLibCode/Commands/CrossSectionCommands/RicNewPolygonIntersectionFeature.h diff --git a/ApplicationLibCode/Commands/CrossSectionCommands/CMakeLists_files.cmake b/ApplicationLibCode/Commands/CrossSectionCommands/CMakeLists_files.cmake index d1a18ed21d..bb0d00bef9 100644 --- a/ApplicationLibCode/Commands/CrossSectionCommands/CMakeLists_files.cmake +++ b/ApplicationLibCode/Commands/CrossSectionCommands/CMakeLists_files.cmake @@ -6,6 +6,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RicNewPolylineIntersectionFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicNewAzimuthDipIntersectionFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicCopyIntersectionsToAllViewsInCaseFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicNewPolygonIntersectionFeature.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -16,6 +17,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RicNewPolylineIntersectionFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewAzimuthDipIntersectionFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicCopyIntersectionsToAllViewsInCaseFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicNewPolygonIntersectionFeature.cpp ) list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) diff --git a/ApplicationLibCode/Commands/CrossSectionCommands/RicNewPolygonIntersectionFeature.cpp b/ApplicationLibCode/Commands/CrossSectionCommands/RicNewPolygonIntersectionFeature.cpp new file mode 100644 index 0000000000..d1d70be46a --- /dev/null +++ b/ApplicationLibCode/Commands/CrossSectionCommands/RicNewPolygonIntersectionFeature.cpp @@ -0,0 +1,69 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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 "RicNewPolygonIntersectionFeature.h" + +#include "RiaApplication.h" + +#include "RimExtrudedCurveIntersection.h" +#include "RimGridView.h" +#include "RimIntersectionCollection.h" + +#include "Polygons/RimPolygon.h" +#include "Polygons/RimPolygonInView.h" + +#include "cafSelectionManager.h" + +#include + +CAF_CMD_SOURCE_INIT( RicNewPolygonIntersectionFeature, "RicNewPolygonIntersectionFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewPolygonIntersectionFeature::onActionTriggered( bool isChecked ) +{ + RimGridView* activeView = RiaApplication::instance()->activeMainOrComparisonGridView(); + if ( !activeView ) return; + + auto collection = activeView->intersectionCollection(); + if ( !collection ) return; + + auto polygon = caf::SelectionManager::instance()->selectedItemOfType(); + if ( !polygon ) + { + if ( auto polygonInView = caf::SelectionManager::instance()->selectedItemOfType() ) + { + polygon = polygonInView->polygon(); + } + } + + auto intersection = new RimExtrudedCurveIntersection(); + // intersection->setName( polygon->name() ); + intersection->configureForProjectPolyLine( polygon ); + collection->appendIntersectionAndUpdate( intersection ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewPolygonIntersectionFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setIcon( QIcon( ":/CrossSection16x16.png" ) ); + actionToSetup->setText( "Create Polygon Intersection" ); +} diff --git a/ApplicationLibCode/Commands/CrossSectionCommands/RicNewPolygonIntersectionFeature.h b/ApplicationLibCode/Commands/CrossSectionCommands/RicNewPolygonIntersectionFeature.h new file mode 100644 index 0000000000..f06741ab06 --- /dev/null +++ b/ApplicationLibCode/Commands/CrossSectionCommands/RicNewPolygonIntersectionFeature.h @@ -0,0 +1,33 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 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" + +//================================================================================================== +/// +//================================================================================================== +class RicNewPolygonIntersectionFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; +}; diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp b/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp index f4639815c4..9bb82322fe 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp @@ -180,9 +180,10 @@ void RimExtrudedCurveIntersection::configureForPolyLine() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimExtrudedCurveIntersection::configureForProjectPolyLine() +void RimExtrudedCurveIntersection::configureForProjectPolyLine( RimPolygon* polygon ) { - m_type = CrossSectionEnum::CS_POLYGON; + m_type = CrossSectionEnum::CS_POLYGON; + m_projectPolygon = polygon; } //-------------------------------------------------------------------------------------------------- @@ -458,7 +459,8 @@ void RimExtrudedCurveIntersection::fieldChangedByUi( const caf::PdmFieldHandle* recomputeSimulationWellBranchData(); } - if ( changedField == &m_simulationWell || changedField == &m_wellPath || changedField == &m_branchIndex ) + if ( changedField == &m_simulationWell || changedField == &m_wellPath || changedField == &m_branchIndex || + changedField == &m_projectPolygon || changedField == &m_type ) { updateName(); } @@ -991,6 +993,10 @@ void RimExtrudedCurveIntersection::updateName() { m_name = m_wellPath()->name(); } + else if ( m_type() == CrossSectionEnum::CS_POLYGON && m_projectPolygon() ) + { + m_name = m_projectPolygon->name(); + } Rim2dIntersectionView* iView = correspondingIntersectionView(); if ( iView ) diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.h b/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.h index 67701f1b0d..22d6836593 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.h +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.h @@ -105,7 +105,7 @@ class RimExtrudedCurveIntersection : public RimIntersection void configureForSimulationWell( RimSimWellInView* simWell ); void configureForWellPath( RimWellPath* wellPath ); void configureForPolyLine(); - void configureForProjectPolyLine(); + void configureForProjectPolyLine( RimPolygon* polygon ); void configureForAzimuthLine(); std::vector> polyLines( cvf::Vec3d* flattenedPolylineStartPoint = nullptr ) const; diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.cpp b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.cpp index 074a7d20e8..3c30092758 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.cpp +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.cpp @@ -19,8 +19,11 @@ #include "RimPolygon.h" #include "RigPolyLinesData.h" + #include "RimPolygonAppearance.h" +#include "cafCmdFeatureMenuBuilder.h" + CAF_PDM_SOURCE_INIT( RimPolygon, "RimPolygon" ); //-------------------------------------------------------------------------------------------------- @@ -61,6 +64,14 @@ void RimPolygon::uiOrderingForLocalPolygon( QString uiConfigName, caf::PdmUiOrde m_appearance->uiOrdering( uiConfigName, uiOrdering ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygon::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const +{ + menuBuilder << "RicNewPolygonIntersectionFeature"; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.h b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.h index 455ace4578..eb2646d51a 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.h +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.h @@ -28,6 +28,11 @@ class RimPolygonAppearance; +namespace caf +{ +class CmdFeatureMenuBuilder; +} + class RimPolygon : public RimNamedObject, public RimPolylinesDataInterface { CAF_PDM_HEADER_INIT; @@ -48,6 +53,7 @@ class RimPolygon : public RimNamedObject, public RimPolylinesDataInterface void uiOrderingForLocalPolygon( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ); protected: + void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) override; From 730d29a4a97b166a856075bf4f325a3fc80609d4 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 22 Feb 2024 11:07:29 +0100 Subject: [PATCH 22/23] Append menu items in polygon in view --- .../RicNewPolygonIntersectionFeature.cpp | 1 - .../Intersections/RimExtrudedCurveIntersection.cpp | 2 ++ .../ProjectDataModel/Polygons/RimPolygonInView.cpp | 8 ++++++++ .../ProjectDataModel/Polygons/RimPolygonInView.h | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ApplicationLibCode/Commands/CrossSectionCommands/RicNewPolygonIntersectionFeature.cpp b/ApplicationLibCode/Commands/CrossSectionCommands/RicNewPolygonIntersectionFeature.cpp index d1d70be46a..3ee2f4e7a3 100644 --- a/ApplicationLibCode/Commands/CrossSectionCommands/RicNewPolygonIntersectionFeature.cpp +++ b/ApplicationLibCode/Commands/CrossSectionCommands/RicNewPolygonIntersectionFeature.cpp @@ -54,7 +54,6 @@ void RicNewPolygonIntersectionFeature::onActionTriggered( bool isChecked ) } auto intersection = new RimExtrudedCurveIntersection(); - // intersection->setName( polygon->name() ); intersection->configureForProjectPolyLine( polygon ); collection->appendIntersectionAndUpdate( intersection ); } diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp b/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp index 9bb82322fe..0d6a575bd3 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp @@ -184,6 +184,8 @@ void RimExtrudedCurveIntersection::configureForProjectPolyLine( RimPolygon* poly { m_type = CrossSectionEnum::CS_POLYGON; m_projectPolygon = polygon; + + updateName(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.cpp b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.cpp index a4c1e1c346..9aa70c6841 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.cpp +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.cpp @@ -302,6 +302,14 @@ void RimPolygonInView::uiOrderingForLocalPolygon( QString uiConfigName, caf::Pdm uiOrdering.add( &m_handleScalingFactor ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonInView::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const +{ + menuBuilder << "RicNewPolygonIntersectionFeature"; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.h b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.h index 2883ead0c7..cf60a1c785 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.h +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.h @@ -78,6 +78,7 @@ class RimPolygonInView : public RimCheckableNamedObject, public RimPolylinesData QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; void defineCustomContextMenu( const caf::PdmFieldHandle* fieldNeedingMenu, QMenu* menu, QWidget* fieldEditorWidget ) override; + void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override; private: void updateNameField(); From 45bf27616ad4b0a4bc203fb724d9b281f3920b35 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 22 Feb 2024 11:55:04 +0100 Subject: [PATCH 23/23] Add new polygon filter from polygons --- .../RicNewPolygonFilter3dviewFeature.cpp | 2 +- .../RicNewPolygonFilterFeature.cpp | 33 ++++++++++++++----- .../CellFilters/RimCellFilterCollection.cpp | 13 ++++++-- .../CellFilters/RimCellFilterCollection.h | 3 +- .../CellFilters/RimPolygonFilter.cpp | 12 +++++++ .../CellFilters/RimPolygonFilter.h | 1 + .../ProjectDataModel/Polygons/RimPolygon.cpp | 1 + .../ProjectDataModel/Polygons/RimPolygon.h | 2 +- .../Polygons/RimPolygonInView.cpp | 2 +- 9 files changed, 55 insertions(+), 14 deletions(-) diff --git a/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilter3dviewFeature.cpp b/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilter3dviewFeature.cpp index a33936e93f..def2a95673 100644 --- a/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilter3dviewFeature.cpp +++ b/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilter3dviewFeature.cpp @@ -48,7 +48,7 @@ void RicNewPolygonFilter3dviewFeature::onActionTriggered( bool isChecked ) // and the case to use RimCase* sourceCase = viewOrComparisonView->ownerCase(); - RimPolygonFilter* lastCreatedOrUpdated = filtColl->addNewPolygonFilter( sourceCase ); + RimPolygonFilter* lastCreatedOrUpdated = filtColl->addNewPolygonFilter( sourceCase, nullptr ); if ( lastCreatedOrUpdated ) { Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated ); diff --git a/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.cpp b/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.cpp index 343d8ed97c..6fa19c52d6 100644 --- a/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.cpp +++ b/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.cpp @@ -18,10 +18,12 @@ #include "RicNewPolygonFilterFeature.h" +#include "Polygons/RimPolygon.h" #include "Polygons/RimPolygonInView.h" #include "RimCase.h" #include "RimCellFilterCollection.h" +#include "RimGridView.h" #include "RimPolygonFilter.h" #include "Riu3DMainWindowTools.h" @@ -38,16 +40,31 @@ CAF_CMD_SOURCE_INIT( RicNewPolygonFilterFeature, "RicNewPolygonFilterFeature" ); //-------------------------------------------------------------------------------------------------- void RicNewPolygonFilterFeature::onActionTriggered( bool isChecked ) { - // Find the selected Cell Filter Collection - std::vector colls = caf::selectedObjectsByTypeStrict(); - if ( colls.empty() ) return; - RimCellFilterCollection* filtColl = colls[0]; + auto cellFilterCollection = caf::SelectionManager::instance()->selectedItemOfType(); - // and the case to use - RimCase* sourceCase = filtColl->firstAncestorOrThisOfTypeAsserted(); + if ( !cellFilterCollection ) + { + RimGridView* activeView = RiaApplication::instance()->activeMainOrComparisonGridView(); + if ( activeView ) + { + cellFilterCollection = activeView->cellFilterCollection(); + } + } + + if ( !cellFilterCollection ) return; + + auto polygon = caf::SelectionManager::instance()->selectedItemOfType(); + if ( !polygon ) + { + if ( auto polygonInView = caf::SelectionManager::instance()->selectedItemOfType() ) + { + polygon = polygonInView->polygon(); + } + } + + auto sourceCase = cellFilterCollection->firstAncestorOrThisOfTypeAsserted(); - RimPolygonFilter* lastCreatedOrUpdated = filtColl->addNewPolygonFilter( sourceCase ); - if ( lastCreatedOrUpdated ) + if ( auto lastCreatedOrUpdated = cellFilterCollection->addNewPolygonFilter( sourceCase, polygon ) ) { Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated ); } diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp index ef0c5feaf8..a61aa2b603 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp @@ -255,13 +255,22 @@ bool RimCellFilterCollection::hasActiveIncludeRangeFilters() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimPolygonFilter* RimCellFilterCollection::addNewPolygonFilter( RimCase* srcCase ) +RimPolygonFilter* RimCellFilterCollection::addNewPolygonFilter( RimCase* srcCase, RimPolygon* polygon ) { RimPolygonFilter* pFilter = new RimPolygonFilter(); pFilter->setCase( srcCase ); + pFilter->setPolygon( polygon ); addFilter( pFilter ); pFilter->configurePolygonEditor(); - pFilter->enablePicking( true ); + if ( polygon ) + { + pFilter->enableFilter( true ); + } + else + { + pFilter->enablePicking( true ); + } + onFilterUpdated( pFilter ); return pFilter; } diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.h b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.h index 1ad20dc819..d2e4d4d9f2 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.h +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.h @@ -33,6 +33,7 @@ class RimUserDefinedFilter; class RimUserDefinedIndexFilter; class RimCase; class RimPolygonInView; +class RimPolygon; namespace cvf { @@ -53,7 +54,7 @@ class RimCellFilterCollection : public caf::PdmObject caf::Signal<> filtersChanged; - RimPolygonFilter* addNewPolygonFilter( RimCase* srcCase ); + RimPolygonFilter* addNewPolygonFilter( RimCase* srcCase, RimPolygon* polygon ); RimCellRangeFilter* addNewCellRangeFilter( RimCase* srcCase, int gridIndex, int sliceDirection = -1, int defaultSlice = -1 ); RimCellIndexFilter* addNewCellIndexFilter( RimCase* srcCase ); RimUserDefinedFilter* addNewUserDefinedFilter( RimCase* srcCase ); diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp index 11ce1e2c40..3670a5514d 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp @@ -154,6 +154,18 @@ void RimPolygonFilter::enableKFilter( bool bEnable ) m_enableKFilter = bEnable; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonFilter::setPolygon( RimPolygon* polygon ) +{ + if ( polygon ) + { + m_polygonDataSource = PolygonDataSource::GLOBAL_POLYGON; + m_cellFilterPolygon = polygon; + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.h b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.h index ec9acefa91..52e82a064f 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.h +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.h @@ -74,6 +74,7 @@ class RimPolygonFilter : public RimCellFilter, public RimPolylinePickerInterface void enableFilter( bool bEnable ); void enableKFilter( bool bEnable ); + void setPolygon( RimPolygon* polygon ); bool isFilterEnabled() const override; diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.cpp b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.cpp index 3c30092758..32ad86b4a4 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.cpp +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.cpp @@ -70,6 +70,7 @@ void RimPolygon::uiOrderingForLocalPolygon( QString uiConfigName, caf::PdmUiOrde void RimPolygon::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const { menuBuilder << "RicNewPolygonIntersectionFeature"; + menuBuilder << "RicNewPolygonFilterFeature"; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.h b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.h index eb2646d51a..958cb6d4c8 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.h +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.h @@ -51,9 +51,9 @@ class RimPolygon : public RimNamedObject, public RimPolylinesDataInterface cvf::ref polyLinesData() const override; void uiOrderingForLocalPolygon( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ); + void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override; protected: - void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) override; diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.cpp b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.cpp index 9aa70c6841..c0230854dd 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.cpp +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.cpp @@ -307,7 +307,7 @@ void RimPolygonInView::uiOrderingForLocalPolygon( QString uiConfigName, caf::Pdm //-------------------------------------------------------------------------------------------------- void RimPolygonInView::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const { - menuBuilder << "RicNewPolygonIntersectionFeature"; + if ( m_polygon() ) m_polygon->appendMenuItems( menuBuilder ); } //--------------------------------------------------------------------------------------------------