From c8b1c21b956a1e0255ab0da7de0302a57e621833 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 8 Feb 2024 09:56:27 +0100 Subject: [PATCH 1/6] Modify the the background color of table using stylesheets --- .../cafPdmUiTableViewEditor.cpp | 22 ++++++++++++++++--- .../cafPdmUiTableViewEditor.h | 3 --- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.cpp index 71ee591f97..797c32f473 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.cpp @@ -193,9 +193,25 @@ void PdmUiTableViewEditor::configureAndUpdateUi( const QString& uiConfigName ) this->setRowSelectionLevel( editorAttrib.rowSelectionLevel ); this->enableHeaderText( editorAttrib.enableHeaderText ); - QPalette myPalette( m_tableView->palette() ); - myPalette.setColor( QPalette::Base, editorAttrib.baseColor ); - m_tableView->setPalette( myPalette ); + QString styleSheetTable; + QString styleSheetHeader; + + if ( editorAttrib.baseColor.isValid() ) + { + // Configure style sheet to set the background color of the table and headers, including the corner button + + styleSheetTable = QString( "QTableView QTableCornerButton::section { background: %1 } QTableView { " + "background-color : %1 } " ) + .arg( editorAttrib.baseColor.name() ); + + styleSheetHeader = + QString( "QHeaderView { background-color: %1 } QHeaderView::section { background-color: %1 }" ) + .arg( editorAttrib.baseColor.name() ); + } + + m_tableView->setStyleSheet( styleSheetTable ); + m_tableView->horizontalHeader()->setStyleSheet( styleSheetHeader ); + m_tableView->verticalHeader()->setStyleSheet( styleSheetHeader ); // Drop target settings m_tableView->setAcceptDrops( editorAttrib.enableDropTarget ); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.h index f66fe42eb6..324ed59799 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.h @@ -107,11 +107,8 @@ class PdmUiTableViewEditorAttribute : public PdmUiEditorAttribute , resizePolicy( NO_AUTOMATIC_RESIZE ) , enableDropTarget( false ) { - QPalette myPalette; - baseColor = myPalette.color( QPalette::Active, QPalette::Base ); } - int selectionLevel; int tableSelectionLevel; int rowSelectionLevel; bool enableHeaderText; From b98e76276c1dbe92b70da862168f31bc80ac6d0b Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 8 Feb 2024 10:07:42 +0100 Subject: [PATCH 2/6] Move findActiveTargetsAroundInsertionPoint to base class --- .../RicNewPolylineTargetFeature.cpp | 55 ++++++++----------- .../RimUserDefinedPolylinesAnnotation.cpp | 25 --------- .../RimUserDefinedPolylinesAnnotation.h | 2 - .../ProjectDataModel/CMakeLists_files.cmake | 1 + .../RimPolylinePickerInterface.cpp | 48 ++++++++++++++++ .../RimPolylinePickerInterface.h | 2 + 6 files changed, 75 insertions(+), 58 deletions(-) create mode 100644 ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.cpp diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicNewPolylineTargetFeature.cpp b/ApplicationLibCode/Commands/WellPathCommands/RicNewPolylineTargetFeature.cpp index 013eadff30..eec85c6ce3 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicNewPolylineTargetFeature.cpp +++ b/ApplicationLibCode/Commands/WellPathCommands/RicNewPolylineTargetFeature.cpp @@ -21,21 +21,23 @@ CAF_CMD_SOURCE_INIT( RicNewPolylineTargetFeature, "RicNewPolylineTargetFeature" #include "RimCase.h" #include "RimGridView.h" +#include "RimPolylinePickerInterface.h" #include "RimPolylineTarget.h" #include "RimProject.h" -#include "RimUserDefinedPolylinesAnnotation.h" + #include "cafSelectionManager.h" -#include #include "cvfBoundingBox.h" +#include + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- bool RicNewPolylineTargetFeature::isCommandEnabled() const { { - std::vector objects; + std::vector objects; caf::SelectionManager::instance()->objectsByType( &objects ); if ( !objects.empty() ) @@ -66,7 +68,7 @@ void RicNewPolylineTargetFeature::onActionTriggered( bool isChecked ) if ( !selectedTargets.empty() ) { auto firstTarget = selectedTargets.front(); - RimUserDefinedPolylinesAnnotation* polylineDef = firstTarget->firstAncestorOrThisOfTypeAsserted(); + auto polylineDef = firstTarget->firstAncestorOrThisOfTypeAsserted(); auto afterBeforePair = polylineDef->findActiveTargetsAroundInsertionPoint( firstTarget ); @@ -109,49 +111,40 @@ void RicNewPolylineTargetFeature::onActionTriggered( bool isChecked ) return; } - std::vector polylineDefs; + std::vector polylineDefs; caf::SelectionManager::instance()->objectsByType( &polylineDefs ); if ( !polylineDefs.empty() ) { auto* polylineDef = polylineDefs[0]; std::vector activeTargets = polylineDef->activeTargets(); - size_t targetCount = activeTargets.size(); + cvf::Vec3d newPos = cvf::Vec3d::ZERO; - if ( targetCount == 0 ) + size_t targetCount = activeTargets.size(); + if ( targetCount > 1 ) + { + newPos = activeTargets[targetCount - 1]->targetPointXYZ(); + cvf::Vec3d nextLastToLast = newPos - activeTargets[targetCount - 2]->targetPointXYZ(); + newPos += 0.5 * nextLastToLast; + } + else if ( targetCount > 0 ) + { + newPos = activeTargets[targetCount - 1]->targetPointXYZ() + cvf::Vec3d( 0, 0, 200 ); + } + else { - auto defaultPos = cvf::Vec3d::ZERO; - - // Set decent position std::vector gridViews; RimProject::current()->allVisibleGridViews( gridViews ); if ( !gridViews.empty() ) { auto minPos = gridViews.front()->ownerCase()->allCellsBoundingBox().min(); - defaultPos = minPos; + newPos = minPos; } - - polylineDef->appendTarget( defaultPos ); } - else - { - cvf::Vec3d newPos = cvf::Vec3d::ZERO; - - if ( targetCount > 1 ) - { - newPos = activeTargets[targetCount - 1]->targetPointXYZ(); - cvf::Vec3d nextLastToLast = newPos - activeTargets[targetCount - 2]->targetPointXYZ(); - newPos += 0.5 * nextLastToLast; - } - else if ( targetCount > 0 ) - { - newPos = activeTargets[targetCount - 1]->targetPointXYZ() + cvf::Vec3d( 0, 0, 200 ); - } - auto* newTarget = new RimPolylineTarget; - newTarget->setAsPointTargetXYD( { newPos[0], newPos[1], -newPos[2] } ); - polylineDef->insertTarget( nullptr, newTarget ); - } + auto* newTarget = new RimPolylineTarget; + newTarget->setAsPointTargetXYD( { newPos[0], newPos[1], -newPos[2] } ); + polylineDef->insertTarget( nullptr, newTarget ); polylineDef->updateEditorsAndVisualization(); } diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimUserDefinedPolylinesAnnotation.cpp b/ApplicationLibCode/ProjectDataModel/Annotations/RimUserDefinedPolylinesAnnotation.cpp index 82916de56c..95ce19c8b3 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimUserDefinedPolylinesAnnotation.cpp +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimUserDefinedPolylinesAnnotation.cpp @@ -152,31 +152,6 @@ void RimUserDefinedPolylinesAnnotation::deleteTarget( RimPolylineTarget* targetT delete targetToDelete; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::pair - RimUserDefinedPolylinesAnnotation::findActiveTargetsAroundInsertionPoint( const RimPolylineTarget* targetToInsertBefore ) -{ - RimPolylineTarget* before = nullptr; - RimPolylineTarget* after = nullptr; - - bool foundTarget = false; - for ( const auto& wt : m_targets ) - { - if ( wt == targetToInsertBefore ) - { - foundTarget = true; - } - - if ( wt->isEnabled() && !after && foundTarget ) after = wt; - - if ( wt->isEnabled() && !foundTarget ) before = wt; - } - - return { before, after }; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimUserDefinedPolylinesAnnotation.h b/ApplicationLibCode/ProjectDataModel/Annotations/RimUserDefinedPolylinesAnnotation.h index 9afb83e562..000a2492e2 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimUserDefinedPolylinesAnnotation.h +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimUserDefinedPolylinesAnnotation.h @@ -60,8 +60,6 @@ class RimUserDefinedPolylinesAnnotation : public RimPolylinesAnnotation, public void appendTarget( const cvf::Vec3d& defaultPos = cvf::Vec3d::ZERO ); - std::pair findActiveTargetsAroundInsertionPoint( const RimPolylineTarget* targetToInsertBefore ); - void enablePicking( bool enable ); protected: diff --git a/ApplicationLibCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/CMakeLists_files.cmake index 6b50a735aa..d3366768f1 100644 --- a/ApplicationLibCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationLibCode/ProjectDataModel/CMakeLists_files.cmake @@ -267,6 +267,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RimResultSelectionUi.cpp ${CMAKE_CURRENT_LIST_DIR}/RimPlotRectAnnotation.cpp ${CMAKE_CURRENT_LIST_DIR}/RimEmCase.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimPolylinePickerInterface.cpp ) if(RESINSIGHT_USE_QT_CHARTS) diff --git a/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.cpp b/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.cpp new file mode 100644 index 0000000000..9ca78cfffd --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.cpp @@ -0,0 +1,48 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2020 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 "RimPolylinePickerInterface.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair + RimPolylinePickerInterface::findActiveTargetsAroundInsertionPoint( const RimPolylineTarget* targetToInsertBefore ) +{ + auto targets = activeTargets(); + + RimPolylineTarget* before = nullptr; + RimPolylineTarget* after = nullptr; + + bool foundTarget = false; + for ( const auto& wt : targets ) + { + if ( wt == targetToInsertBefore ) + { + foundTarget = true; + } + + if ( wt->isEnabled() && !after && foundTarget ) after = wt; + + if ( wt->isEnabled() && !foundTarget ) before = wt; + } + + return { before, after }; +} diff --git a/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.h b/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.h index 5a99bed648..26e53beaf9 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.h +++ b/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.h @@ -33,4 +33,6 @@ class RimPolylinePickerInterface virtual std::vector activeTargets() const = 0; virtual bool pickingEnabled() const = 0; virtual caf::PickEventHandler* pickEventHandler() const = 0; + + std::pair findActiveTargetsAroundInsertionPoint( const RimPolylineTarget* targetToInsertBefore ); }; From 127b9ed57d63aeaec7cd3205d5d4f6295afa5aba Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 8 Feb 2024 14:15:07 +0100 Subject: [PATCH 3/6] Update bounding box of parts in polyline part manager The part visualization was missing in some cases due to an invalid bounding box --- ApplicationLibCode/ModelVisualization/RivPolylinePartMgr.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ApplicationLibCode/ModelVisualization/RivPolylinePartMgr.cpp b/ApplicationLibCode/ModelVisualization/RivPolylinePartMgr.cpp index 12ba78f953..95b7a54332 100644 --- a/ApplicationLibCode/ModelVisualization/RivPolylinePartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/RivPolylinePartMgr.cpp @@ -107,6 +107,7 @@ void RivPolylinePartMgr::buildPolylineParts( const caf::DisplayCoordTransform* d cvf::ref part = new cvf::Part; part->setName( "RivPolylinePartMgr" ); part->setDrawable( drawableGeo.p() ); + part->updateBoundingBox(); caf::MeshEffectGenerator effgen( polylineDef->lineColor() ); effgen.setLineWidth( polylineDef->lineThickness() ); @@ -177,6 +178,7 @@ void RivPolylinePartMgr::buildPolylineParts( const caf::DisplayCoordTransform* d cvf::ref part = new cvf::Part; part->setName( "RivPolylinePartMgr" ); part->setDrawable( vectorDrawable.p() ); + part->updateBoundingBox(); part->setEffect( new cvf::Effect() ); part->setPriority( RivPartPriority::PartType::MeshLines ); From 0a5d8ea234c2d29a9342d438433085677c213971 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 12 Feb 2024 10:19:52 +0100 Subject: [PATCH 4/6] Add polygon classes --- .../Application/RiaApplication.cpp | 4 + ApplicationLibCode/Application/RiaDefines.h | 9 + ApplicationLibCode/CMakeLists.txt | 1 + ApplicationLibCode/Commands/CMakeLists.txt | 1 + .../PolygonCommands/CMakeLists_files.cmake | 19 + .../PolygonCommands/RicNewPolygonFeature.cpp | 54 +++ .../PolygonCommands/RicNewPolygonFeature.h | 33 ++ .../RicNewPolygonFileFeature.cpp | 57 +++ .../RicNewPolygonFileFeature.h | 33 ++ .../GeoMech/RimGeoMechView.cpp | 11 +- .../Polygons/CMakeLists_files.cmake | 27 ++ .../ProjectDataModel/Polygons/RimPolygon.cpp | 115 ++++++ .../ProjectDataModel/Polygons/RimPolygon.h | 56 +++ .../Polygons/RimPolygonAppearance.cpp | 205 ++++++++++ .../Polygons/RimPolygonAppearance.h | 59 +++ .../Polygons/RimPolygonCollection.cpp | 205 ++++++++++ .../Polygons/RimPolygonCollection.h | 65 ++++ .../Polygons/RimPolygonFile.cpp | 82 ++++ .../Polygons/RimPolygonFile.h | 49 +++ .../Polygons/RimPolygonInView.cpp | 362 ++++++++++++++++++ .../Polygons/RimPolygonInView.h | 94 +++++ .../Polygons/RimPolygonInViewCollection.cpp | 97 +++++ .../Polygons/RimPolygonInViewCollection.h | 54 +++ .../ProjectDataModel/Rim3dView.cpp | 2 +- .../ProjectDataModel/Rim3dView.h | 2 +- .../RimContextCommandBuilder.cpp | 6 + .../ProjectDataModel/RimEclipseView.cpp | 10 +- .../ProjectDataModel/RimGridView.cpp | 44 ++- .../ProjectDataModel/RimGridView.h | 6 +- .../ProjectDataModel/RimOilField.cpp | 4 + .../ProjectDataModel/RimOilField.h | 2 + .../RimPolylinePickerInterface.cpp | 6 +- .../RimPolylinePickerInterface.h | 11 +- .../ProjectDataModel/RimProject.cpp | 2 + .../ProjectDataModel/RimTools.cpp | 25 ++ .../ProjectDataModel/RimTools.h | 3 + .../Seismic/RimSeismicSection.cpp | 1 + .../Seismic/RimSeismicView.cpp | 31 +- .../ProjectDataModel/Seismic/RimSeismicView.h | 2 +- .../Surfaces/RimSurfaceCollection.cpp | 4 +- 40 files changed, 1816 insertions(+), 37 deletions(-) create mode 100644 ApplicationLibCode/Commands/PolygonCommands/CMakeLists_files.cmake create mode 100644 ApplicationLibCode/Commands/PolygonCommands/RicNewPolygonFeature.cpp create mode 100644 ApplicationLibCode/Commands/PolygonCommands/RicNewPolygonFeature.h create mode 100644 ApplicationLibCode/Commands/PolygonCommands/RicNewPolygonFileFeature.cpp create mode 100644 ApplicationLibCode/Commands/PolygonCommands/RicNewPolygonFileFeature.h create mode 100644 ApplicationLibCode/ProjectDataModel/Polygons/CMakeLists_files.cmake create mode 100644 ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.cpp create mode 100644 ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.h create mode 100644 ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.cpp create mode 100644 ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.h create mode 100644 ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonCollection.cpp create mode 100644 ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonCollection.h create mode 100644 ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonFile.cpp create mode 100644 ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonFile.h create mode 100644 ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.cpp create mode 100644 ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.h create mode 100644 ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInViewCollection.cpp create mode 100644 ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInViewCollection.h diff --git a/ApplicationLibCode/Application/RiaApplication.cpp b/ApplicationLibCode/Application/RiaApplication.cpp index 478566d908..98f8af811e 100644 --- a/ApplicationLibCode/Application/RiaApplication.cpp +++ b/ApplicationLibCode/Application/RiaApplication.cpp @@ -40,6 +40,8 @@ #include "RicfCommandObject.h" #include "PlotTemplates/RimPlotTemplateFolderItem.h" +#include "Polygons/RimPolygonCollection.h" + #include "Rim2dIntersectionViewCollection.h" #include "RimAnnotationCollection.h" #include "RimAnnotationInViewCollection.h" @@ -544,6 +546,8 @@ bool RiaApplication::loadProject( const QString& projectFileName, ProjectLoadAct { seismicData->ensureFileReaderIsInitialized(); } + + oilField->polygonCollection()->loadData(); } { diff --git a/ApplicationLibCode/Application/RiaDefines.h b/ApplicationLibCode/Application/RiaDefines.h index 27afa6fd2b..4eaee4a384 100644 --- a/ApplicationLibCode/Application/RiaDefines.h +++ b/ApplicationLibCode/Application/RiaDefines.h @@ -243,8 +243,17 @@ enum class View3dContent ALL = 0b00011111 }; +enum class ItemIn3dView +{ + NONE = 0b00000000, + SURFACE = 0b00000001, + POLYGON = 0b00000010, + ALL = 0b00000011 +}; + }; // namespace RiaDefines // Activate bit mask operators at global scope ENABLE_BITMASK_OPERATORS( RiaDefines::MultiPlotPageUpdateType ) ENABLE_BITMASK_OPERATORS( RiaDefines::View3dContent ) +ENABLE_BITMASK_OPERATORS( RiaDefines::ItemIn3dView ) diff --git a/ApplicationLibCode/CMakeLists.txt b/ApplicationLibCode/CMakeLists.txt index 82e15fe623..e88e49300d 100644 --- a/ApplicationLibCode/CMakeLists.txt +++ b/ApplicationLibCode/CMakeLists.txt @@ -123,6 +123,7 @@ list( ProjectDataModel/Intersections/CMakeLists_files.cmake ProjectDataModel/CellFilters/CMakeLists_files.cmake ProjectDataModel/ProcessControl/CMakeLists_files.cmake + ProjectDataModel/Polygons/CMakeLists_files.cmake ProjectDataModel/WellLog/CMakeLists_files.cmake ProjectDataModel/WellMeasurement/CMakeLists_files.cmake ProjectDataModel/WellPath/CMakeLists_files.cmake diff --git a/ApplicationLibCode/Commands/CMakeLists.txt b/ApplicationLibCode/Commands/CMakeLists.txt index 931eb11e82..740ee78f12 100644 --- a/ApplicationLibCode/Commands/CMakeLists.txt +++ b/ApplicationLibCode/Commands/CMakeLists.txt @@ -41,6 +41,7 @@ set(COMMAND_REFERENCED_CMAKE_FILES PlotTemplateCommands/CMakeLists_files.cmake FractureCommands/CMakeLists_files.cmake PlotBuilderCommands/CMakeLists_files.cmake + PolygonCommands/CMakeLists_files.cmake ) # Include source file lists from *.cmake files diff --git a/ApplicationLibCode/Commands/PolygonCommands/CMakeLists_files.cmake b/ApplicationLibCode/Commands/PolygonCommands/CMakeLists_files.cmake new file mode 100644 index 0000000000..8392652004 --- /dev/null +++ b/ApplicationLibCode/Commands/PolygonCommands/CMakeLists_files.cmake @@ -0,0 +1,19 @@ +set(SOURCE_GROUP_HEADER_FILES + ${CMAKE_CURRENT_LIST_DIR}/RicNewPolygonFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicNewPolygonFileFeature.h +) + +set(SOURCE_GROUP_SOURCE_FILES + ${CMAKE_CURRENT_LIST_DIR}/RicNewPolygonFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicNewPolygonFileFeature.cpp +) + +list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) + +list(APPEND COMMAND_CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES}) + +source_group( + "CommandFeature\\Polygons" + FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} + ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake +) diff --git a/ApplicationLibCode/Commands/PolygonCommands/RicNewPolygonFeature.cpp b/ApplicationLibCode/Commands/PolygonCommands/RicNewPolygonFeature.cpp new file mode 100644 index 0000000000..7ff2d4aded --- /dev/null +++ b/ApplicationLibCode/Commands/PolygonCommands/RicNewPolygonFeature.cpp @@ -0,0 +1,54 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 "RicNewPolygonFeature.h" + +#include "Polygons/RimPolygon.h" +#include "Polygons/RimPolygonCollection.h" +#include "RimOilField.h" +#include "RimProject.h" + +#include "RiuPlotMainWindowTools.h" + +#include + +CAF_CMD_SOURCE_INIT( RicNewPolygonFeature, "RicNewPolygonFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewPolygonFeature::onActionTriggered( bool isChecked ) +{ + auto proj = RimProject::current(); + auto polygonCollection = proj->activeOilField()->polygonCollection(); + + auto newPolygon = polygonCollection->appendUserDefinedPolygon(); + polygonCollection->uiCapability()->updateAllRequiredEditors(); + + RiuPlotMainWindowTools::setExpanded( newPolygon ); + RiuPlotMainWindowTools::selectAsCurrentItem( newPolygon ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewPolygonFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setText( "New Polygon" ); + actionToSetup->setIcon( QIcon( ":/PolylinesFromFile16x16.png" ) ); +} diff --git a/ApplicationLibCode/Commands/PolygonCommands/RicNewPolygonFeature.h b/ApplicationLibCode/Commands/PolygonCommands/RicNewPolygonFeature.h new file mode 100644 index 0000000000..ebb92b9b2c --- /dev/null +++ b/ApplicationLibCode/Commands/PolygonCommands/RicNewPolygonFeature.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 RicNewPolygonFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; +}; diff --git a/ApplicationLibCode/Commands/PolygonCommands/RicNewPolygonFileFeature.cpp b/ApplicationLibCode/Commands/PolygonCommands/RicNewPolygonFileFeature.cpp new file mode 100644 index 0000000000..5a5a681fbe --- /dev/null +++ b/ApplicationLibCode/Commands/PolygonCommands/RicNewPolygonFileFeature.cpp @@ -0,0 +1,57 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicNewPolygonFileFeature.h" + +#include "Polygons/RimPolygon.h" +#include "Polygons/RimPolygonCollection.h" +#include "Polygons/RimPolygonFile.h" +#include "RimOilField.h" +#include "RimProject.h" + +#include "RiuPlotMainWindowTools.h" + +#include + +CAF_CMD_SOURCE_INIT( RicNewPolygonFileFeature, "RicNewPolygonFileFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewPolygonFileFeature::onActionTriggered( bool isChecked ) +{ + auto proj = RimProject::current(); + auto polygonCollection = proj->activeOilField()->polygonCollection(); + + auto newPolygonFile = new RimPolygonFile(); + newPolygonFile->setName( "File Polygon " + QString::number( polygonCollection->polygonFiles().size() + 1 ) ); + polygonCollection->addPolygonFile( newPolygonFile ); + polygonCollection->uiCapability()->updateAllRequiredEditors(); + + RiuPlotMainWindowTools::setExpanded( newPolygonFile ); + RiuPlotMainWindowTools::selectAsCurrentItem( newPolygonFile ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewPolygonFileFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setText( "New File Polygon" ); + actionToSetup->setIcon( QIcon( ":/PolylinesFromFile16x16.png" ) ); +} diff --git a/ApplicationLibCode/Commands/PolygonCommands/RicNewPolygonFileFeature.h b/ApplicationLibCode/Commands/PolygonCommands/RicNewPolygonFileFeature.h new file mode 100644 index 0000000000..8c3ff090ef --- /dev/null +++ b/ApplicationLibCode/Commands/PolygonCommands/RicNewPolygonFileFeature.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 RicNewPolygonFileFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; +}; diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp index 7ff399e36a..db9ae62cdb 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp @@ -31,6 +31,7 @@ #include "RigFormationNames.h" #include "RigGeoMechCaseData.h" +#include "Polygons/RimPolygonInViewCollection.h" #include "Rim3dOverlayInfoConfig.h" #include "RimCellFilterCollection.h" #include "RimEclipseResultDefinition.h" @@ -153,7 +154,7 @@ void RimGeoMechView::onLoadDataAndUpdate() onUpdateScaleTransform(); - updateSurfacesInViewTreeItems(); + updateViewTreeItems( RiaDefines::ItemIn3dView::ALL ); if ( m_geomechCase ) { @@ -319,6 +320,12 @@ void RimGeoMechView::onCreateDisplayModel() m_seismicSectionCollection->appendPartsToModel( this, m_seismicVizModel.p(), transform.p(), femBBox ); 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() ); + // Surfaces m_surfaceVizModel->removeAllParts(); @@ -1043,6 +1050,8 @@ void RimGeoMechView::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrderin if ( surfaceInViewCollection() ) uiTreeOrdering.add( surfaceInViewCollection() ); if ( seismicSectionCollection()->shouldBeVisibleInTree() ) uiTreeOrdering.add( seismicSectionCollection() ); + uiTreeOrdering.add( m_polygonCollection ); + uiTreeOrdering.skipRemainingChildren( true ); } diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/Polygons/CMakeLists_files.cmake new file mode 100644 index 0000000000..af99df45c7 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Polygons/CMakeLists_files.cmake @@ -0,0 +1,27 @@ +set(SOURCE_GROUP_HEADER_FILES + ${CMAKE_CURRENT_LIST_DIR}/RimPolygon.h + ${CMAKE_CURRENT_LIST_DIR}/RimPolygonFile.h + ${CMAKE_CURRENT_LIST_DIR}/RimPolygonCollection.h + ${CMAKE_CURRENT_LIST_DIR}/RimPolygonInView.h + ${CMAKE_CURRENT_LIST_DIR}/RimPolygonInViewCollection.h + ${CMAKE_CURRENT_LIST_DIR}/RimPolygonAppearance.h +) + +set(SOURCE_GROUP_SOURCE_FILES + ${CMAKE_CURRENT_LIST_DIR}/RimPolygon.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimPolygonFile.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimPolygonCollection.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimPolygonInView.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimPolygonInViewCollection.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimPolygonAppearance.cpp +) + +list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) + +list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES}) + +source_group( + "ProjectDataModel\\Polygons" + FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} + ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake +) diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.cpp b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.cpp new file mode 100644 index 0000000000..c505ac9345 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.cpp @@ -0,0 +1,115 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RimPolygon.h" + +#include "RigPolyLinesData.h" +#include "RimPolygonAppearance.h" + +CAF_PDM_SOURCE_INIT( RimPolygon, "RimPolygon" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimPolygon::RimPolygon() + : objectChanged( this ) +{ + CAF_PDM_InitObject( "Polygon", ":/PolylinesFromFile16x16.png" ); + + CAF_PDM_InitField( &m_isReadOnly, "IsReadOnly", false, "Read Only" ); + CAF_PDM_InitFieldNoDefault( &m_pointsInDomainCoords, "PointsInDomainCoords", "Points" ); + CAF_PDM_InitFieldNoDefault( &m_appearance, "Appearance", "Appearance" ); + m_appearance = new RimPolygonAppearance; + m_appearance.uiCapability()->setUiTreeChildrenHidden( true ); + + setDeletable( true ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref RimPolygon::polyLinesData() const +{ + cvf::ref pld = new RigPolyLinesData; + + pld->setPolyLine( m_pointsInDomainCoords() ); + m_appearance->applyAppearanceSettings( pld.p() ); + + return pld; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygon::setPointsInDomainCoords( const std::vector& points ) +{ + m_pointsInDomainCoords = points; + + objectChanged.send(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimPolygon::pointsInDomainCoords() const +{ + return m_pointsInDomainCoords(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimPolygon::isClosed() const +{ + return m_appearance->isClosed(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygon::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +{ + uiOrdering.add( nameField() ); + uiOrdering.add( &m_isReadOnly ); + + auto groupPoints = uiOrdering.addNewGroup( "Points" ); + groupPoints->setCollapsedByDefault(); + groupPoints->add( &m_pointsInDomainCoords ); + + auto group = uiOrdering.addNewGroup( "Appearance" ); + m_appearance->uiOrdering( uiConfigName, *group ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygon::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) +{ + if ( changedField == &m_pointsInDomainCoords ) + { + objectChanged.send(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygon::childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) +{ + objectChanged.send(); +} diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.h b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.h new file mode 100644 index 0000000000..ede74d9f49 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.h @@ -0,0 +1,56 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RimNamedObject.h" + +#include "RimPolylinesDataInterface.h" + +#include "cafPdmChildField.h" +#include "cafPdmFieldCvfVec3d.h" + +#include "cvfVector3.h" + +class RimPolygonAppearance; + +class RimPolygon : public RimNamedObject, public RimPolylinesDataInterface +{ + CAF_PDM_HEADER_INIT; + +public: + caf::Signal<> objectChanged; + +public: + RimPolygon(); + + void setPointsInDomainCoords( const std::vector& points ); + std::vector pointsInDomainCoords() const; + bool isClosed() const; + + cvf::ref polyLinesData() const override; + +protected: + 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; + +private: + caf::PdmField m_isReadOnly; + caf::PdmField> m_pointsInDomainCoords; + caf::PdmChildField m_appearance; +}; diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.cpp b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.cpp new file mode 100644 index 0000000000..038ee5e7f0 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.cpp @@ -0,0 +1,205 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RimPolygonAppearance.h" + +#include "RimCase.h" +#include "RimProject.h" + +#include "RigPolyLinesData.h" + +#include "RiaNumericalTools.h" +#include "RiaStdStringTools.h" + +#include "cafPdmUiDoubleSliderEditor.h" +#include "cafPdmUiLineEditor.h" + +#include "cvfBoundingBox.h" + +CAF_PDM_SOURCE_INIT( RimPolygonAppearance, "RimPolygonAppearance" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +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; + } +}; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimPolygonAppearance::RimPolygonAppearance() + : objectChanged( this ) + +{ + CAF_PDM_InitObject( "Polygon", ":/PolylinesFromFile16x16.png" ); + + CAF_PDM_InitField( &m_isClosed, "IsClosed", false, "Closed Polygon" ); + CAF_PDM_InitField( &m_showLines, "ShowLines", true, "Show Lines" ); + CAF_PDM_InitField( &m_showSpheres, "ShowSpheres", false, "Show Spheres" ); + + 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_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 ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonAppearance::applyAppearanceSettings( RigPolyLinesData* polyLinesData ) +{ + polyLinesData->setLineAppearance( m_lineThickness, m_lineColor, m_isClosed ); + polyLinesData->setSphereAppearance( m_sphereRadiusFactor, m_sphereColor ); + polyLinesData->setZPlaneLock( m_lockPolygonToPlane, -m_polygonPlaneDepth ); + polyLinesData->setVisibility( m_showLines, m_showSpheres ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimPolygonAppearance::isClosed() const +{ + return m_isClosed(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonAppearance::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +{ + uiOrdering.add( &m_showLines ); + if ( m_showLines ) + { + uiOrdering.add( &m_lineThickness ); + uiOrdering.add( &m_lineColor ); + } + + uiOrdering.add( &m_showSpheres ); + if ( m_showSpheres ) + { + uiOrdering.add( &m_sphereRadiusFactor ); + uiOrdering.add( &m_sphereColor ); + } + + uiOrdering.add( &m_lockPolygonToPlane ); + if ( m_lockPolygonToPlane ) + { + uiOrdering.add( &m_polygonPlaneDepth ); + } + + uiOrdering.add( &m_isClosed ); + + uiOrdering.skipRemainingFields(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonAppearance::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) +{ + objectChanged.send(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonAppearance::defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) +{ + if ( field == &m_lineThickness ) + { + if ( auto myAttr = dynamic_cast( attribute ) ) + { + myAttr->validator = new ThicknessValidator(); + } + } + else if ( field == &m_lineThickness ) + { + if ( auto myAttr = dynamic_cast( attribute ) ) + { + myAttr->validator = new RadiusValidator(); + } + } + else if ( field == &m_polygonPlaneDepth ) + { + if ( auto attr = dynamic_cast( attribute ) ) + { + auto allCases = RimProject::current()->allGridCases(); + if ( allCases.empty() ) + { + attr->m_minimum = 0; + attr->m_maximum = 10000.0; + } + else + { + double min = std::numeric_limits::max(); + double max = -std::numeric_limits::max(); + + for ( auto gridCase : allCases ) + { + auto bb = gridCase->allCellsBoundingBox(); + + min = std::min( min, bb.min().z() ); + max = std::max( max, bb.max().z() ); + } + + auto adjustedMin = RiaNumericalTools::roundToNumSignificantDigitsFloor( -min, 2 ); + auto adjustedMax = RiaNumericalTools::roundToNumSignificantDigitsCeil( -max, 2 ); + + attr->m_minimum = adjustedMax; + attr->m_maximum = adjustedMin; + } + } + } +} diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.h b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.h new file mode 100644 index 0000000000..05a9b2284e --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.h @@ -0,0 +1,59 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "cafPdmField.h" +#include "cafPdmObject.h" + +#include "cafPdmFieldCvfColor.h" +#include "cvfVector3.h" + +class RigPolyLinesData; + +class RimPolygonAppearance : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + caf::Signal<> objectChanged; + + void applyAppearanceSettings( RigPolyLinesData* polyLinesData ); + + bool isClosed() const; + +public: + RimPolygonAppearance(); + +protected: + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; + void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; + +private: + caf::PdmField m_isClosed; + caf::PdmField m_showLines; + caf::PdmField m_lineThickness; + caf::PdmField m_lineColor; + + caf::PdmField m_showSpheres; + caf::PdmField m_sphereRadiusFactor; + caf::PdmField m_sphereColor; + + caf::PdmField m_lockPolygonToPlane; + caf::PdmField m_polygonPlaneDepth; +}; diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonCollection.cpp b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonCollection.cpp new file mode 100644 index 0000000000..ea085b6522 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonCollection.cpp @@ -0,0 +1,205 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RimPolygonCollection.h" + +#include "Rim3dView.h" +#include "RimPolygon.h" +#include "RimPolygonFile.h" +#include "RimProject.h" + +CAF_PDM_SOURCE_INIT( RimPolygonCollection, "RimPolygonCollection" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimPolygonCollection::RimPolygonCollection() +{ + CAF_PDM_InitObject( "Polygons (Under construction)", ":/PolylinesFromFile16x16.png" ); + + CAF_PDM_InitFieldNoDefault( &m_polygons, "Polygons", "Polygons" ); + CAF_PDM_InitFieldNoDefault( &m_polygonFiles, "PolygonFiles", "Polygon Files" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonCollection::loadData() +{ + for ( auto& p : m_polygonFiles() ) + { + p->loadData(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimPolygon* RimPolygonCollection::appendUserDefinedPolygon() +{ + auto newPolygon = new RimPolygon(); + newPolygon->setName( "Polygon " + QString::number( userDefinedPolygons().size() + 1 ) ); + addUserDefinedPolygon( newPolygon ); + + return newPolygon; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonCollection::addUserDefinedPolygon( RimPolygon* polygon ) +{ + m_polygons().push_back( polygon ); + + connectSignals( polygon ); + + updateViewTreeItems(); + scheduleRedrawViews(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonCollection::deleteUserDefinedPolygons() +{ + m_polygons().deleteChildren(); + + updateViewTreeItems(); + scheduleRedrawViews(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonCollection::addPolygonFile( RimPolygonFile* polygonFile ) +{ + m_polygonFiles().push_back( polygonFile ); + + updateViewTreeItems(); + scheduleRedrawViews(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimPolygonCollection::userDefinedPolygons() const +{ + return m_polygons.childrenByType(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimPolygonCollection::polygonFiles() const +{ + return m_polygonFiles.childrenByType(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimPolygonCollection::allPolygons() const +{ + std::vector allPolygons; + + for ( auto& p : m_polygonFiles() ) + { + for ( auto& polygon : p->polygons() ) + { + allPolygons.push_back( polygon ); + } + } + + for ( auto& polygon : m_polygons.childrenByType() ) + { + allPolygons.push_back( polygon ); + } + + return allPolygons; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonCollection::onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, std::vector& referringObjects ) +{ + updateViewTreeItems(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonCollection::childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) +{ + scheduleRedrawViews(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonCollection::updateViewTreeItems() +{ + RimProject* proj = RimProject::current(); + + // Make sure the tree items are synchronized + std::vector views; + proj->allViews( views ); + for ( auto view : views ) + { + view->updateViewTreeItems( RiaDefines::ItemIn3dView::POLYGON ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonCollection::scheduleRedrawViews() +{ + RimProject* proj = RimProject::current(); + proj->scheduleCreateDisplayModelAndRedrawAllViews(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonCollection::connectSignals( RimPolygon* polygon ) +{ + if ( polygon ) + { + polygon->objectChanged.connect( this, &RimPolygonCollection::onObjectChanged ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonCollection::onObjectChanged( const caf::SignalEmitter* emitter ) +{ + scheduleRedrawViews(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonCollection::initAfterRead() +{ + for ( auto& p : m_polygons() ) + { + connectSignals( p ); + } +} diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonCollection.h b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonCollection.h new file mode 100644 index 0000000000..4246dae416 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonCollection.h @@ -0,0 +1,65 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "cafPdmChildArrayField.h" +#include "cafPdmObject.h" + +class RimPolygon; +class RimPolygonFile; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimPolygonCollection : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimPolygonCollection(); + + void loadData(); + RimPolygon* appendUserDefinedPolygon(); + void addUserDefinedPolygon( RimPolygon* polygon ); + void deleteUserDefinedPolygons(); + + void addPolygonFile( RimPolygonFile* polygonFile ); + + std::vector userDefinedPolygons() const; + std::vector polygonFiles() const; + std::vector allPolygons() const; + + void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, std::vector& referringObjects ) override; + + void childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) override; + +private: + void updateViewTreeItems(); + void scheduleRedrawViews(); + void connectSignals( RimPolygon* polygon ); + void onObjectChanged( const caf::SignalEmitter* emitter ); + +private: + caf::PdmChildArrayField m_polygons; + caf::PdmChildArrayField m_polygonFiles; + +protected: + void initAfterRead() override; +}; diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonFile.cpp b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonFile.cpp new file mode 100644 index 0000000000..cec7ec8160 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonFile.cpp @@ -0,0 +1,82 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RimPolygonFile.h" +#include "RimPolygon.h" + +CAF_PDM_SOURCE_INIT( RimPolygonFile, "RimPolygonFileFile" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimPolygonFile::RimPolygonFile() +{ + CAF_PDM_InitObject( "PolygonFile", ":/PolylinesFromFile16x16.png" ); + + CAF_PDM_InitFieldNoDefault( &m_fileName, "StimPlanFileName", "File Name" ); + CAF_PDM_InitFieldNoDefault( &m_polygons, "Polygons", "Polygons" ); + + setDeletable( true ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonFile::loadData() +{ + loadPolygonsFromFile(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimPolygonFile::polygons() const +{ + return m_polygons.childrenByType(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonFile::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonFile::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) +{ + loadPolygonsFromFile(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonFile::loadPolygonsFromFile() +{ + // m_polygons()->deletePolygons(); + + auto polygon = new RimPolygon(); + polygon->setName( "Polygon 1" ); + m_polygons.push_back( polygon ); + + polygon = new RimPolygon(); + polygon->setName( "Polygon 2" ); + m_polygons.push_back( polygon ); +} diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonFile.h b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonFile.h new file mode 100644 index 0000000000..540f9ce32c --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonFile.h @@ -0,0 +1,49 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RimNamedObject.h" + +#include "cafFilePath.h" +#include "cafPdmChildArrayField.h" + +class RimPolygon; + +class RimPolygonFile : public RimNamedObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimPolygonFile(); + + void loadData(); + + std::vector polygons() const; + +protected: + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; + +private: + void loadPolygonsFromFile(); + +private: + caf::PdmField m_fileName; + + caf::PdmChildArrayField m_polygons; +}; diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.cpp b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.cpp new file mode 100644 index 0000000000..60371b247d --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.cpp @@ -0,0 +1,362 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RimPolygonInView.h" + +#include "RigPolyLinesData.h" + +#include "Rim3dView.h" +#include "RimPolygon.h" +#include "RimPolylineTarget.h" +#include "RimTools.h" + +#include "WellPathCommands/PointTangentManipulator/RicPolyline3dEditor.h" +#include "WellPathCommands/RicPolylineTargetsPickEventHandler.h" + +#include "RiuGuiTheme.h" + +#include "RivPolylinePartMgr.h" + +#include "cafCmdFeatureMenuBuilder.h" +#include "cafDisplayCoordTransform.h" +#include "cafPdmUiPushButtonEditor.h" +#include "cafPdmUiTableViewEditor.h" + +#include "cvfModelBasicList.h" + +CAF_PDM_SOURCE_INIT( RimPolygonInView, "RimPolygonInView" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimPolygonInView::RimPolygonInView() + : m_pickTargetsEventHandler( new RicPolylineTargetsPickEventHandler( this ) ) +{ + CAF_PDM_InitObject( "Polygon", ":/PolylinesFromFile16x16.png" ); + + CAF_PDM_InitFieldNoDefault( &m_polygon, "Polygon", "Polygon" ); + m_polygon.uiCapability()->setUiReadOnly( true ); + + nameField()->uiCapability()->setUiReadOnly( true ); + + 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 ); + + setUi3dEditorTypeName( RicPolyline3dEditor::uiEditorTypeName() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimPolygon* RimPolygonInView::polygon() const +{ + return m_polygon(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonInView::setPolygon( RimPolygon* polygon ) +{ + m_polygon = polygon; + + updateTargetsFromPolygon(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonInView::appendPartsToModel( cvf::ModelBasicList* model, + const caf::DisplayCoordTransform* scaleTransform, + const cvf::BoundingBox& boundingBox ) +{ + auto view = firstAncestorOfType(); + + if ( m_polylinePartMgr.isNull() ) m_polylinePartMgr = new RivPolylinePartMgr( view, this, this ); + + m_polylinePartMgr->appendDynamicGeometryPartsToModel( model, scaleTransform, boundingBox ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonInView::enablePicking( bool enable ) +{ + m_enablePicking = enable; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonInView::insertTarget( const RimPolylineTarget* targetToInsertBefore, RimPolylineTarget* targetToInsert ) +{ + size_t index = m_targets.indexOf( targetToInsertBefore ); + if ( index < m_targets.size() ) + m_targets.insert( index, targetToInsert ); + else + m_targets.push_back( targetToInsert ); + + updatePolygonFromTargets(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonInView::deleteTarget( RimPolylineTarget* targetToDelete ) +{ + m_targets.removeChild( targetToDelete ); + delete targetToDelete; + + updatePolygonFromTargets(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonInView::updateEditorsAndVisualization() +{ + updateConnectedEditors(); + updateVisualization(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonInView::updateVisualization() +{ + auto view = firstAncestorOfType(); + if ( view ) + { + view->scheduleCreateDisplayModelAndRedraw(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimPolygonInView::activeTargets() const +{ + return m_targets.childrenByType(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimPolygonInView::pickingEnabled() const +{ + return m_enablePicking(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PickEventHandler* RimPolygonInView::pickEventHandler() const +{ + return m_pickTargetsEventHandler.get(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonInView::onChildrenUpdated( caf::PdmChildArrayFieldHandle* childArray, std::vector& updatedObjects ) +{ + if ( childArray == &m_targets ) + { + updatePolygonFromTargets(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref RimPolygonInView::polyLinesData() const +{ + if ( m_polygon ) + { + return m_polygon->polyLinesData(); + } + + return nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonInView::updatePolygonFromTargets() +{ + if ( m_polygon ) + { + std::vector points; + for ( const RimPolylineTarget* target : m_targets ) + { + points.push_back( target->targetPointXYZ() ); + } + m_polygon->setPointsInDomainCoords( points ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonInView::updateTargetsFromPolygon() +{ + if ( m_polygon ) + { + m_targets.deleteChildren(); + + for ( const auto& p : m_polygon->pointsInDomainCoords() ) + { + auto target = new RimPolylineTarget(); + target->setAsPointXYZ( p ); + + m_targets.push_back( target ); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonInView::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +{ + updateNameField(); + + if ( m_polygon() ) uiOrdering.add( m_polygon ); + uiOrdering.add( &m_enablePicking ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonInView::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) +{ + if ( changedField == &m_enablePicking ) + { + updateConnectedEditors(); + } + + updateVisualization(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimPolygonInView::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) +{ + QList options; + if ( fieldNeedingOptions == &m_polygon ) + { + options.push_back( caf::PdmOptionItemInfo( "None", nullptr ) ); + + RimTools::polygonOptionItems( &options ); + } + + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonInView::defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) +{ + if ( auto attrib = dynamic_cast( attribute ) ) + { + attrib->pickEventHandler = m_pickTargetsEventHandler; + attrib->enablePicking = m_enablePicking; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonInView::defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) +{ + if ( field == &m_enablePicking ) + { + auto* pbAttribute = dynamic_cast( attribute ); + if ( pbAttribute ) + { + if ( !m_enablePicking ) + { + pbAttribute->m_buttonText = "Start Picking Points"; + } + else + { + pbAttribute->m_buttonText = "Stop Picking Points"; + } + } + } + + if ( field == &m_targets ) + { + if ( auto tvAttribute = dynamic_cast( attribute ) ) + { + tvAttribute->resizePolicy = caf::PdmUiTableViewEditorAttribute::RESIZE_TO_FIT_CONTENT; + + if ( m_enablePicking ) + { + tvAttribute->baseColor = RiuGuiTheme::getColorByVariableName( "externalInputColor" ); + } + tvAttribute->alwaysEnforceResizePolicy = true; + tvAttribute->heightHint = 1000; + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonInView::defineCustomContextMenu( const caf::PdmFieldHandle* fieldNeedingMenu, QMenu* menu, QWidget* fieldEditorWidget ) +{ + caf::CmdFeatureMenuBuilder menuBuilder; + + menuBuilder << "RicNewPolylineTargetFeature"; + menuBuilder << "Separator"; + menuBuilder << "RicDeletePolylineTargetFeature"; + + menuBuilder.appendToMenu( menu ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonInView::updateNameField() +{ + QString name = "Undefined"; + if ( m_polygon() ) + { + name = m_polygon->name(); + } + + setName( name ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonInView::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= "" */ ) +{ + updateNameField(); +} diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.h b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.h new file mode 100644 index 0000000000..3e8a6864cd --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.h @@ -0,0 +1,94 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RimCheckableNamedObject.h" +#include "RimPolylinePickerInterface.h" +#include "RimPolylinesDataInterface.h" + +#include "RivPolylinePartMgr.h" + +#include "cafPdmChildArrayField.h" +#include "cafPdmPtrField.h" + +class RimPolygon; +class RivPolylinePartMgr; +class RicPolylineTargetsPickEventHandler; +class RimPolylineTarget; + +namespace cvf +{ +class ModelBasicList; +class BoundingBox; +} // namespace cvf + +namespace caf +{ +class DisplayCoordTransform; +} // namespace caf + +class RimPolygonInView : public RimCheckableNamedObject, public RimPolylinesDataInterface, public RimPolylinePickerInterface +{ + CAF_PDM_HEADER_INIT; + +public: + RimPolygonInView(); + + RimPolygon* polygon() const; + void setPolygon( RimPolygon* polygon ); + + 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; + void updateVisualization() override; + std::vector activeTargets() const override; + bool pickingEnabled() const override; + caf::PickEventHandler* pickEventHandler() const override; + + cvf::ref polyLinesData() const override; + + void onChildrenUpdated( caf::PdmChildArrayFieldHandle* childArray, std::vector& updatedObjects ) override; + void defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; + +protected: + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; + void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; + 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; + +private: + void updateNameField(); + + void updatePolygonFromTargets(); + void updateTargetsFromPolygon(); + +private: + caf::PdmPtrField m_polygon; + + caf::PdmField m_enablePicking; + caf::PdmChildArrayField m_targets; + + cvf::ref m_polylinePartMgr; + std::shared_ptr m_pickTargetsEventHandler; +}; diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInViewCollection.cpp b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInViewCollection.cpp new file mode 100644 index 0000000000..fadd762d44 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInViewCollection.cpp @@ -0,0 +1,97 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RimPolygonInViewCollection.h" + +#include "RimPolygon.h" +#include "RimPolygonCollection.h" +#include "RimPolygonInView.h" +#include "RimTools.h" + +#include "cafDisplayCoordTransform.h" + +#include "cvfModelBasicList.h" + +CAF_PDM_SOURCE_INIT( RimPolygonInViewCollection, "RimPolygonInViewCollection" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimPolygonInViewCollection::RimPolygonInViewCollection() +{ + CAF_PDM_InitObject( "Polygons (Under construction)", ":/PolylinesFromFile16x16.png" ); + + CAF_PDM_InitFieldNoDefault( &m_polygons, "Polygons", "Polygons" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonInViewCollection::syncPolygonsInView() +{ + std::vector existingPolygonsInView = m_polygons.childrenByType(); + m_polygons.clearWithoutDelete(); + + auto polygonCollection = RimTools::polygonCollection(); + if ( polygonCollection ) + { + std::vector newPolygonsInView; + + for ( auto polygon : polygonCollection->allPolygons() ) + { + auto it = std::find_if( existingPolygonsInView.begin(), + existingPolygonsInView.end(), + [polygon]( auto* polygonInView ) { return polygonInView->polygon() == polygon; } ); + + if ( it != existingPolygonsInView.end() ) + { + newPolygonsInView.push_back( *it ); + existingPolygonsInView.erase( it ); + } + else + { + auto polygonInView = new RimPolygonInView(); + polygonInView->setPolygon( polygon ); + newPolygonsInView.push_back( polygonInView ); + } + } + + m_polygons.setValue( newPolygonsInView ); + } + + for ( auto polyInView : existingPolygonsInView ) + { + delete polyInView; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonInViewCollection::appendPartsToModel( cvf::ModelBasicList* model, + caf::DisplayCoordTransform* scaleTransform, + const cvf::BoundingBox& boundingBox ) +{ + for ( auto polygon : m_polygons ) + { + if ( polygon && polygon->isChecked() ) + { + polygon->appendPartsToModel( model, scaleTransform, boundingBox ); + } + } +} diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInViewCollection.h b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInViewCollection.h new file mode 100644 index 0000000000..7d79a1b853 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInViewCollection.h @@ -0,0 +1,54 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "cafPdmChildArrayField.h" +#include "cafPdmObject.h" + +class RimPolygonInView; + +namespace cvf +{ +class ModelBasicList; +class BoundingBox; +} // namespace cvf + +namespace caf +{ +class DisplayCoordTransform; +} // namespace caf + +//================================================================================================== +/// +/// +//================================================================================================== +class RimPolygonInViewCollection : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimPolygonInViewCollection(); + + void syncPolygonsInView(); + + void appendPartsToModel( cvf::ModelBasicList* model, caf::DisplayCoordTransform* scaleTransform, const cvf::BoundingBox& boundingBox ); + +private: + caf::PdmChildArrayField m_polygons; +}; diff --git a/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp b/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp index 2805312a19..eaba599751 100644 --- a/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp +++ b/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp @@ -1860,7 +1860,7 @@ void Rim3dView::onUpdateScaleTransform() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void Rim3dView::updateSurfacesInViewTreeItems() +void Rim3dView::updateViewTreeItems( RiaDefines::ItemIn3dView itemType ) { // default is to do nothing } diff --git a/ApplicationLibCode/ProjectDataModel/Rim3dView.h b/ApplicationLibCode/ProjectDataModel/Rim3dView.h index c58b5daedd..e25459dacd 100644 --- a/ApplicationLibCode/ProjectDataModel/Rim3dView.h +++ b/ApplicationLibCode/ProjectDataModel/Rim3dView.h @@ -193,7 +193,7 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface, public RimViewLinker* assosiatedViewLinker() const override; RimViewController* viewController() const override; - virtual void updateSurfacesInViewTreeItems(); + virtual void updateViewTreeItems( RiaDefines::ItemIn3dView itemType ); RimAnnotationInViewCollection* annotationCollection() const; void syncronizeLocalAnnotationsFromGlobal(); diff --git a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp index d036783239..6c6b658358 100644 --- a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -23,6 +23,7 @@ #include "PlotTemplates/RimPlotTemplateFileItem.h" #include "PlotTemplates/RimPlotTemplateFolderItem.h" +#include "Polygons/RimPolygonCollection.h" #include "Rim3dOverlayInfoConfig.h" #include "Rim3dWellLogCurveCollection.h" #include "Rim3dWellLogExtractionCurve.h" @@ -1138,6 +1139,11 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() { menuBuilder << "RicAddGridCalculationFeature"; } + else if ( dynamic_cast( firstUiItem ) ) + { + menuBuilder << "RicNewPolygonFeature"; + menuBuilder << "RicNewPolygonFileFeature"; + } if ( dynamic_cast( firstUiItem ) ) { diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp index 00483713dd..b30d82fd6b 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp @@ -41,6 +41,7 @@ #include "RigWellResultFrame.h" #include "RigWellResultPoint.h" +#include "Polygons/RimPolygonInViewCollection.h" #include "Rim2dIntersectionView.h" #include "Rim3dOverlayInfoConfig.h" #include "RimAnnotationCollection.h" @@ -647,6 +648,11 @@ void RimEclipseView::onCreateDisplayModel() nativeOrOverrideViewer()->addStaticModelOnce( m_surfaceVizModel.p(), isUsingOverrideViewer() ); } + // Polygons + m_polygonVizModel->removeAllParts(); + m_polygonCollection->appendPartsToModel( m_polygonVizModel.p(), transform.p(), ownerCase()->allCellsBoundingBox() ); + nativeOrOverrideViewer()->addStaticModelOnce( m_polygonVizModel.p(), isUsingOverrideViewer() ); + // Well path model m_wellPathPipeVizModel->removeAllParts(); @@ -1077,7 +1083,7 @@ void RimEclipseView::appendStreamlinesToModel() //-------------------------------------------------------------------------------------------------- void RimEclipseView::onLoadDataAndUpdate() { - updateSurfacesInViewTreeItems(); + updateViewTreeItems( RiaDefines::ItemIn3dView::ALL ); onUpdateScaleTransform(); @@ -1947,6 +1953,8 @@ void RimEclipseView::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrderin if ( surfaceInViewCollection() ) uiTreeOrdering.add( surfaceInViewCollection() ); if ( seismicSectionCollection()->shouldBeVisibleInTree() ) uiTreeOrdering.add( seismicSectionCollection() ); + uiTreeOrdering.add( m_polygonCollection ); + uiTreeOrdering.skipRemainingChildren( true ); } diff --git a/ApplicationLibCode/ProjectDataModel/RimGridView.cpp b/ApplicationLibCode/ProjectDataModel/RimGridView.cpp index 81006c365b..98a57cd0d3 100644 --- a/ApplicationLibCode/ProjectDataModel/RimGridView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimGridView.cpp @@ -18,6 +18,7 @@ #include "RimGridView.h" +#include "Polygons/RimPolygonInViewCollection.h" #include "Rim3dOverlayInfoConfig.h" #include "RimCellFilterCollection.h" #include "RimEclipseCase.h" @@ -96,6 +97,9 @@ 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_cellFilterCollection, "RangeFilters", "Cell Filter Collection Field" ); m_cellFilterCollection = new RimCellFilterCollection(); @@ -104,6 +108,9 @@ RimGridView::RimGridView() m_intersectionVizModel = new cvf::ModelBasicList; m_intersectionVizModel->setName( "CrossSectionModel" ); + + m_polygonVizModel = new cvf::ModelBasicList; + m_polygonVizModel->setName( "PolygonModel" ); } //-------------------------------------------------------------------------------------------------- @@ -161,6 +168,14 @@ RimSeismicSectionCollection* RimGridView::seismicSectionCollection() const return m_seismicSectionCollection(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimPolygonInViewCollection* RimGridView::polygonCollection() const +{ + return m_polygonCollection(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -455,23 +470,32 @@ void RimGridView::updateWellMeasurements() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimGridView::updateSurfacesInViewTreeItems() +void RimGridView::updateViewTreeItems( RiaDefines::ItemIn3dView itemType ) { - RimSurfaceCollection* surfColl = RimTools::surfaceCollection(); + auto bitmaskEnum = BitmaskEnum( itemType ); - if ( surfColl && surfColl->containsSurface() ) + if ( bitmaskEnum.AnyOf( RiaDefines::ItemIn3dView::SURFACE ) ) { - if ( !m_surfaceCollection() ) + RimSurfaceCollection* surfColl = RimTools::surfaceCollection(); + if ( surfColl && surfColl->containsSurface() ) { - m_surfaceCollection = new RimSurfaceInViewCollection(); - } + if ( !m_surfaceCollection() ) + { + m_surfaceCollection = new RimSurfaceInViewCollection(); + } - m_surfaceCollection->setSurfaceCollection( surfColl ); - m_surfaceCollection->updateFromSurfaceCollection(); + m_surfaceCollection->setSurfaceCollection( surfColl ); + m_surfaceCollection->updateFromSurfaceCollection(); + } + else + { + delete m_surfaceCollection; + } } - else + + if ( bitmaskEnum.AnyOf( RiaDefines::ItemIn3dView::POLYGON ) ) { - delete m_surfaceCollection; + m_polygonCollection->syncPolygonsInView(); } updateConnectedEditors(); diff --git a/ApplicationLibCode/ProjectDataModel/RimGridView.h b/ApplicationLibCode/ProjectDataModel/RimGridView.h index f3115e2f34..203f7e9100 100644 --- a/ApplicationLibCode/ProjectDataModel/RimGridView.h +++ b/ApplicationLibCode/ProjectDataModel/RimGridView.h @@ -32,6 +32,7 @@ class RimCellFilterCollection; class RimWellMeasurementInViewCollection; class RimSurfaceInViewCollection; class RimSeismicSectionCollection; +class RimPolygonInViewCollection; class RimGridView : public Rim3dView { @@ -54,6 +55,7 @@ class RimGridView : public Rim3dView RimIntersectionResultsDefinitionCollection* separateSurfaceResultsCollection() const; RimWellMeasurementInViewCollection* measurementCollection() const; RimSeismicSectionCollection* seismicSectionCollection() const; + RimPolygonInViewCollection* polygonCollection() const; virtual const RimPropertyFilterCollection* propertyFilterCollection() const = 0; @@ -68,7 +70,7 @@ class RimGridView : public Rim3dView bool isGridVisualizationMode() const override; void updateWellMeasurements(); - void updateSurfacesInViewTreeItems() override; + void updateViewTreeItems( RiaDefines::ItemIn3dView itemType ) override; protected: virtual void updateViewFollowingCellFilterUpdates(); @@ -90,6 +92,7 @@ class RimGridView : public Rim3dView protected: cvf::ref m_surfaceVizModel; cvf::ref m_intersectionVizModel; + cvf::ref m_polygonVizModel; // Fields caf::PdmChildField m_intersectionCollection; @@ -104,6 +107,7 @@ class RimGridView : public Rim3dView caf::PdmChildField m_cellFilterCollection; caf::PdmChildField m_overrideCellFilterCollection; caf::PdmChildField m_seismicSectionCollection; + caf::PdmChildField m_polygonCollection; private: void onCreatePartCollectionFromSelection( cvf::Collection* parts ) override; diff --git a/ApplicationLibCode/ProjectDataModel/RimOilField.cpp b/ApplicationLibCode/ProjectDataModel/RimOilField.cpp index f0f421c609..ac36308e79 100644 --- a/ApplicationLibCode/ProjectDataModel/RimOilField.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimOilField.cpp @@ -35,6 +35,8 @@ #include "RimSurfaceCollection.h" #include "RimWellPathCollection.h" +#include "Polygons/RimPolygonCollection.h" + CAF_PDM_SOURCE_INIT( RimOilField, "ResInsightOilField" ); //-------------------------------------------------------------------------------------------------- /// @@ -55,6 +57,7 @@ RimOilField::RimOilField() CAF_PDM_InitFieldNoDefault( &annotationCollection, "AnnotationCollection", "Annotations" ); CAF_PDM_InitFieldNoDefault( &ensembleWellLogsCollection, "EnsembleWellLogsCollection", "Ensemble Well Logs" ); + CAF_PDM_InitFieldNoDefault( &polygonCollection, "PolygonCollection", "Polygons" ); CAF_PDM_InitFieldNoDefault( &m_fractureTemplateCollection_OBSOLETE, "FractureDefinitionCollection", "Defenition of Fractures" ); @@ -80,6 +83,7 @@ RimOilField::RimOilField() formationNamesCollection = new RimFormationNamesCollection(); annotationCollection = new RimAnnotationCollection(); ensembleWellLogsCollection = new RimEnsembleWellLogsCollection(); + polygonCollection = new RimPolygonCollection(); m_fractureTemplateCollection_OBSOLETE = new RimFractureTemplateCollection; m_fractureTemplateCollection_OBSOLETE.xmlCapability()->setIOWritable( false ); diff --git a/ApplicationLibCode/ProjectDataModel/RimOilField.h b/ApplicationLibCode/ProjectDataModel/RimOilField.h index a45ed80936..60b17c698b 100644 --- a/ApplicationLibCode/ProjectDataModel/RimOilField.h +++ b/ApplicationLibCode/ProjectDataModel/RimOilField.h @@ -41,6 +41,7 @@ class RimSeismicDataCollection; class RimSeismicViewCollection; class RimSurfaceCollection; class RimEnsembleWellLogsCollection; +class RimPolygonCollection; //================================================================================================== /// @@ -73,6 +74,7 @@ class RimOilField : public caf::PdmObject caf::PdmChildField seismicDataCollection; caf::PdmChildField seismicViewCollection; caf::PdmChildField ensembleWellLogsCollection; + caf::PdmChildField polygonCollection; protected: void initAfterRead() override; diff --git a/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.cpp b/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.cpp index 9ca78cfffd..db5e648fc6 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2020 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 @@ -16,10 +16,10 @@ // ///////////////////////////////////////////////////////////////////////////////// -#pragma once - #include "RimPolylinePickerInterface.h" +#include "RimPolylineTarget.h" + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.h b/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.h index 26e53beaf9..6210db7832 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.h +++ b/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.h @@ -18,11 +18,16 @@ #pragma once -#include "RimPolylineTarget.h" -#include "cafPickEventHandler.h" - +#include #include +namespace caf +{ +class PickEventHandler; +} + +class RimPolylineTarget; + class RimPolylinePickerInterface { public: diff --git a/ApplicationLibCode/ProjectDataModel/RimProject.cpp b/ApplicationLibCode/ProjectDataModel/RimProject.cpp index 2aec13c3fd..a83a566f5b 100644 --- a/ApplicationLibCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimProject.cpp @@ -33,6 +33,7 @@ #include "RigGridBase.h" #include "PlotTemplates/RimPlotTemplateFolderItem.h" +#include "Polygons/RimPolygonCollection.h" #include "RimAdvancedSnapshotExportDefinition.h" #include "RimAnalysisPlotCollection.h" #include "RimAnnotationCollection.h" @@ -1533,6 +1534,7 @@ void RimProject::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, Q if ( oilField->formationNamesCollection() ) uiTreeOrdering.add( oilField->formationNamesCollection() ); if ( oilField->completionTemplateCollection() ) uiTreeOrdering.add( oilField->completionTemplateCollection() ); if ( oilField->annotationCollection() ) uiTreeOrdering.add( oilField->annotationCollection() ); + if ( oilField->polygonCollection() ) uiTreeOrdering.add( oilField->polygonCollection() ); } uiTreeOrdering.add( colorLegendCollection() ); diff --git a/ApplicationLibCode/ProjectDataModel/RimTools.cpp b/ApplicationLibCode/ProjectDataModel/RimTools.cpp index 5e3bad0eb7..47c6e8d9a3 100644 --- a/ApplicationLibCode/ProjectDataModel/RimTools.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimTools.cpp @@ -25,6 +25,8 @@ #include "RigGeoMechCaseData.h" #include "RigReservoirGridTools.h" +#include "Polygons/RimPolygon.h" +#include "Polygons/RimPolygonCollection.h" #include "RimCase.h" #include "RimColorLegend.h" #include "RimColorLegendCollection.h" @@ -493,6 +495,20 @@ void RimTools::seismicDataOptionItems( QList* options, c } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimTools::polygonOptionItems( QList* options ) +{ + auto project = RimProject::current(); + auto coll = project->activeOilField()->polygonCollection(); + + for ( auto* p : coll->allPolygons() ) + { + options->push_back( caf::PdmOptionItemInfo( p->name(), p, false, p->uiIconProvider() ) ); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -546,6 +562,15 @@ RimSurfaceCollection* RimTools::surfaceCollection() return proj->activeOilField()->surfaceCollection(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimPolygonCollection* RimTools::polygonCollection() +{ + RimProject* proj = RimProject::current(); + return proj->activeOilField()->polygonCollection(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimTools.h b/ApplicationLibCode/ProjectDataModel/RimTools.h index 187e5d684f..5146a59cc7 100644 --- a/ApplicationLibCode/ProjectDataModel/RimTools.h +++ b/ApplicationLibCode/ProjectDataModel/RimTools.h @@ -41,6 +41,7 @@ class RimCase; class RimWellPath; class RimSurfaceCollection; class RimFaultInViewCollection; +class RimPolygonCollection; //-------------------------------------------------------------------------------------------------- /// @@ -69,6 +70,7 @@ class RimTools static void colorLegendOptionItems( QList* options ); static void seismicDataOptionItems( QList* options, cvf::BoundingBox worldBBox, bool basicDataOnly = false ); static void seismicDataOptionItems( QList* options ); + static void polygonOptionItems( QList* options ); static void faultOptionItems( QList* options, RimFaultInViewCollection* coll ); @@ -76,6 +78,7 @@ class RimTools static RimWellPath* firstWellPath(); static RimSurfaceCollection* surfaceCollection(); + static RimPolygonCollection* polygonCollection(); static void timeStepsForCase( RimCase* gridCase, QList* options ); diff --git a/ApplicationLibCode/ProjectDataModel/Seismic/RimSeismicSection.cpp b/ApplicationLibCode/ProjectDataModel/Seismic/RimSeismicSection.cpp index eccc174573..914e18b66d 100644 --- a/ApplicationLibCode/ProjectDataModel/Seismic/RimSeismicSection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Seismic/RimSeismicSection.cpp @@ -22,6 +22,7 @@ #include "RiuSeismicHistogramPanel.h" #include "Rim3dView.h" +#include "RimPolylineTarget.h" #include "RimRegularLegendConfig.h" #include "RimSeismicAlphaMapper.h" #include "RimSeismicDataInterface.h" diff --git a/ApplicationLibCode/ProjectDataModel/Seismic/RimSeismicView.cpp b/ApplicationLibCode/ProjectDataModel/Seismic/RimSeismicView.cpp index 2d66d04664..800bc01985 100644 --- a/ApplicationLibCode/ProjectDataModel/Seismic/RimSeismicView.cpp +++ b/ApplicationLibCode/ProjectDataModel/Seismic/RimSeismicView.cpp @@ -407,7 +407,7 @@ void RimSeismicView::onUpdateLegends() //-------------------------------------------------------------------------------------------------- void RimSeismicView::onLoadDataAndUpdate() { - updateSurfacesInViewTreeItems(); + updateViewTreeItems( RiaDefines::ItemIn3dView::ALL ); syncronizeLocalAnnotationsFromGlobal(); onUpdateScaleTransform(); @@ -461,23 +461,28 @@ void RimSeismicView::updateGridBoxData() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSeismicView::updateSurfacesInViewTreeItems() +void RimSeismicView::updateViewTreeItems( RiaDefines::ItemIn3dView itemType ) { - RimSurfaceCollection* surfColl = RimTools::surfaceCollection(); + auto bitmaskEnum = BitmaskEnum( itemType ); - if ( surfColl && surfColl->containsSurface() ) + if ( bitmaskEnum.AnyOf( RiaDefines::ItemIn3dView::SURFACE ) ) { - if ( !m_surfaceCollection() ) + RimSurfaceCollection* surfColl = RimTools::surfaceCollection(); + + if ( surfColl && surfColl->containsSurface() ) { - m_surfaceCollection = new RimSurfaceInViewCollection(); - } + if ( !m_surfaceCollection() ) + { + m_surfaceCollection = new RimSurfaceInViewCollection(); + } - m_surfaceCollection->setSurfaceCollection( surfColl ); - m_surfaceCollection->updateFromSurfaceCollection(); - } - else - { - delete m_surfaceCollection; + m_surfaceCollection->setSurfaceCollection( surfColl ); + m_surfaceCollection->updateFromSurfaceCollection(); + } + else + { + delete m_surfaceCollection; + } } updateConnectedEditors(); diff --git a/ApplicationLibCode/ProjectDataModel/Seismic/RimSeismicView.h b/ApplicationLibCode/ProjectDataModel/Seismic/RimSeismicView.h index dbfb1a6db5..b18d60a1e2 100644 --- a/ApplicationLibCode/ProjectDataModel/Seismic/RimSeismicView.h +++ b/ApplicationLibCode/ProjectDataModel/Seismic/RimSeismicView.h @@ -90,7 +90,7 @@ class RimSeismicView : public Rim3dView, public RimPolylinesDataInterface void setDefaultView() override; - void updateSurfacesInViewTreeItems() override; + void updateViewTreeItems( RiaDefines::ItemIn3dView itemType ) override; private: caf::PdmChildField m_surfaceCollection; diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceCollection.cpp b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceCollection.cpp index be7f01c1ac..6332511ee5 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceCollection.cpp @@ -302,7 +302,7 @@ void RimSurfaceCollection::updateViews( const std::vector& surfsToR proj->allViews( views ); for ( auto view : views ) { - view->updateSurfacesInViewTreeItems(); + view->updateViewTreeItems( RiaDefines::ItemIn3dView::SURFACE ); if ( auto gridView = dynamic_cast( view ) ) { @@ -355,7 +355,7 @@ void RimSurfaceCollection::updateViews() for ( auto view : views ) { - view->updateSurfacesInViewTreeItems(); + view->updateViewTreeItems( RiaDefines::ItemIn3dView::SURFACE ); } for ( auto view : views ) From 1eafc378f33077636d8b7d024a1d2b2254092ccf Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 12 Feb 2024 09:27:02 +0100 Subject: [PATCH 5/6] Cleanup obsolete code --- .../RicPolylineTarget3dEditor.cpp | 32 ++++++++----------- .../RicPolylineTarget3dEditor.h | 3 +- .../Annotations/RimPolylineTarget.cpp | 18 ----------- .../Annotations/RimPolylineTarget.h | 5 --- .../CellFilters/RimPolygonFilter.cpp | 4 +-- .../RimPolylinePickerInterface.cpp | 4 +-- .../Seismic/RimSeismicSection.cpp | 2 +- 7 files changed, 21 insertions(+), 47 deletions(-) diff --git a/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicPolylineTarget3dEditor.cpp b/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicPolylineTarget3dEditor.cpp index 4c1860e278..d536f59251 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicPolylineTarget3dEditor.cpp +++ b/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicPolylineTarget3dEditor.cpp @@ -21,10 +21,7 @@ #include "RicPointTangentManipulator.h" #include "Rim3dView.h" -#include "RimAnnotationCollectionBase.h" -#include "RimCase.h" #include "RimPolylineTarget.h" -#include "RimUserDefinedPolylinesAnnotation.h" #include "RiuViewer.h" @@ -57,7 +54,7 @@ RicPolylineTarget3dEditor::~RicPolylineTarget3dEditor() ownerRiuViewer->removeStaticModel( m_cvfModel.p() ); } - RimPolylineTarget* oldTarget = dynamic_cast( pdmObject() ); + auto* oldTarget = dynamic_cast( pdmObject() ); if ( oldTarget ) { oldTarget->targetPointUiCapability()->removeFieldEditor( this ); @@ -71,11 +68,11 @@ RicPolylineTarget3dEditor::~RicPolylineTarget3dEditor() //-------------------------------------------------------------------------------------------------- void RicPolylineTarget3dEditor::configureAndUpdateUi( const QString& uiConfigName ) { - RimPolylineTarget* target = dynamic_cast( pdmObject() ); - RiuViewer* ownerRiuViewer = dynamic_cast( ownerViewer() ); - Rim3dView* view = mainOrComparisonView(); + auto* target = dynamic_cast( pdmObject() ); + RiuViewer* ownerRiuViewer = dynamic_cast( ownerViewer() ); + Rim3dView* view = mainOrComparisonView(); - if ( !target || !target->isEnabled() || !view ) + if ( !target || !view ) { if ( m_cvfModel.notNull() ) m_cvfModel->removeAllParts(); @@ -97,11 +94,12 @@ void RicPolylineTarget3dEditor::configureAndUpdateUi( const QString& uiConfigNam ownerRiuViewer->addStaticModelOnce( m_cvfModel.p(), isInComparisonView() ); } - cvf::ref dispXf = view->displayCoordTransform(); - double handleSize = 0.7 * view->characteristicCellSize(); + cvf::ref dispXf = view->displayCoordTransform(); + + const double handleScalingFactor = 0.7; + const double handleSize = handleScalingFactor * view->characteristicCellSize(); m_manipulator->setOrigin( dispXf->transformToDisplayCoord( target->targetPointXYZ() ) ); - // m_manipulator->setTangent(target->tangent()); m_manipulator->setHandleSize( handleSize ); m_cvfModel->removeAllParts(); m_manipulator->appendPartsToModel( m_cvfModel.p() ); @@ -114,7 +112,7 @@ void RicPolylineTarget3dEditor::configureAndUpdateUi( const QString& uiConfigNam //-------------------------------------------------------------------------------------------------- void RicPolylineTarget3dEditor::cleanupBeforeSettingPdmObject() { - RimPolylineTarget* oldTarget = dynamic_cast( pdmObject() ); + auto* oldTarget = dynamic_cast( pdmObject() ); if ( oldTarget ) { oldTarget->targetPointUiCapability()->removeFieldEditor( this ); @@ -126,8 +124,8 @@ void RicPolylineTarget3dEditor::cleanupBeforeSettingPdmObject() //-------------------------------------------------------------------------------------------------- void RicPolylineTarget3dEditor::slotUpdated( const cvf::Vec3d& origin, const cvf::Vec3d& tangent ) { - RimPolylineTarget* target = dynamic_cast( pdmObject() ); - Rim3dView* view = mainOrComparisonView(); + auto* target = dynamic_cast( pdmObject() ); + Rim3dView* view = mainOrComparisonView(); if ( !target || !view ) { @@ -140,9 +138,7 @@ void RicPolylineTarget3dEditor::slotUpdated( const cvf::Vec3d& origin, const cvf domainOrigin.z() = -domainOrigin.z(); QVariant originVariant = caf::PdmValueFieldSpecialization::convert( domainOrigin ); - target->enableFullUpdate( false ); caf::PdmUiCommandSystemProxy::instance()->setUiValueToField( target->targetPointUiCapability(), originVariant ); - target->enableFullUpdate( true ); } //-------------------------------------------------------------------------------------------------- @@ -150,7 +146,7 @@ void RicPolylineTarget3dEditor::slotUpdated( const cvf::Vec3d& origin, const cvf //-------------------------------------------------------------------------------------------------- void RicPolylineTarget3dEditor::slotSelectedIn3D() { - RimPolylineTarget* target = dynamic_cast( pdmObject() ); + auto* target = dynamic_cast( pdmObject() ); if ( !target ) { return; @@ -164,7 +160,7 @@ void RicPolylineTarget3dEditor::slotSelectedIn3D() //-------------------------------------------------------------------------------------------------- void RicPolylineTarget3dEditor::slotDragFinished() { - RimPolylineTarget* target = dynamic_cast( pdmObject() ); + auto* target = dynamic_cast( pdmObject() ); if ( target ) { target->triggerVisualizationUpdate(); diff --git a/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicPolylineTarget3dEditor.h b/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicPolylineTarget3dEditor.h index 918d7a631e..3fe127d12d 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicPolylineTarget3dEditor.h +++ b/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicPolylineTarget3dEditor.h @@ -25,13 +25,14 @@ class RicPointTangentManipulator; #include "cvfObject.h" #include "cvfVector3.h" +#include + namespace cvf { class ModelBasicList; } class QString; -#include class RicPolylineTarget3dEditor : public Ric3dObjectEditorHandle { diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylineTarget.cpp b/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylineTarget.cpp index 009b87bc3e..b2c48b8ffc 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylineTarget.cpp +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylineTarget.cpp @@ -29,9 +29,7 @@ CAF_PDM_SOURCE_INIT( RimPolylineTarget, "PolylineTarget" ); /// //-------------------------------------------------------------------------------------------------- RimPolylineTarget::RimPolylineTarget() - : m_isFullUpdateEnabled( true ) { - CAF_PDM_InitField( &m_isEnabled, "IsEnabled", true, "" ); CAF_PDM_InitFieldNoDefault( &m_targetPointXyd, "TargetPointXyd", "Point" ); } @@ -42,14 +40,6 @@ RimPolylineTarget::~RimPolylineTarget() { } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RimPolylineTarget::isEnabled() const -{ - return m_isEnabled; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -84,14 +74,6 @@ caf::PdmUiFieldHandle* RimPolylineTarget::targetPointUiCapability() return m_targetPointXyd.uiCapability(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimPolylineTarget::enableFullUpdate( bool enable ) -{ - m_isFullUpdateEnabled = enable; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylineTarget.h b/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylineTarget.h index 272362deb4..799c983b58 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylineTarget.h +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylineTarget.h @@ -38,14 +38,11 @@ class RimPolylineTarget : public caf::PdmObject RimPolylineTarget(); ~RimPolylineTarget() override; - bool isEnabled() const; - void setAsPointTargetXYD( const cvf::Vec3d& point ); void setAsPointXYZ( const cvf::Vec3d& point ); cvf::Vec3d targetPointXYZ() const; caf::PdmUiFieldHandle* targetPointUiCapability(); - void enableFullUpdate( bool enable ); void triggerVisualizationUpdate() const; @@ -54,7 +51,5 @@ class RimPolylineTarget : public caf::PdmObject void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; private: - bool m_isFullUpdateEnabled; - caf::PdmField m_isEnabled; caf::PdmField m_targetPointXyd; }; diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp index 7267dff235..c68963a176 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp @@ -867,7 +867,7 @@ void RimPolygonFilter::updateCells() std::vector points; for ( auto& target : m_targets ) { - if ( target->isEnabled() ) points.push_back( target->targetPointXYZ() ); + points.push_back( target->targetPointXYZ() ); } // We need at least three points to make a closed polygon, or just 2 for a polyline @@ -898,7 +898,7 @@ cvf::ref RimPolygonFilter::polyLinesData() const std::vector line; for ( const RimPolylineTarget* target : m_targets ) { - if ( target->isEnabled() ) line.push_back( target->targetPointXYZ() ); + line.push_back( target->targetPointXYZ() ); } pld->setPolyLine( line ); diff --git a/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.cpp b/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.cpp index db5e648fc6..b039bc681b 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.cpp @@ -39,9 +39,9 @@ std::pair foundTarget = true; } - if ( wt->isEnabled() && !after && foundTarget ) after = wt; + if ( !after && foundTarget ) after = wt; - if ( wt->isEnabled() && !foundTarget ) before = wt; + if ( !foundTarget ) before = wt; } return { before, after }; diff --git a/ApplicationLibCode/ProjectDataModel/Seismic/RimSeismicSection.cpp b/ApplicationLibCode/ProjectDataModel/Seismic/RimSeismicSection.cpp index 914e18b66d..ebf15becd1 100644 --- a/ApplicationLibCode/ProjectDataModel/Seismic/RimSeismicSection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Seismic/RimSeismicSection.cpp @@ -600,7 +600,7 @@ cvf::ref RimSeismicSection::texturedSection() for ( int i = 0; i < (int)m_targets.size(); i++ ) { - if ( m_targets[i]->isEnabled() ) points.push_back( m_targets[i]->targetPointXYZ() ); + points.push_back( m_targets[i]->targetPointXYZ() ); } updateTextureSectionFromPoints( points, zmin, zmax ); } From 6472e4510d545c007dcdbc6f19d2cfd5c8b2a108 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 16 Feb 2024 13:56:02 +0100 Subject: [PATCH 6/6] Display polygon project items if RiaApplication::enableDevelopmentFeatures() is defined --- .../ProjectDataModel/GeoMech/RimGeoMechView.cpp | 6 +++++- ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp | 6 +++++- ApplicationLibCode/ProjectDataModel/RimProject.cpp | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp index db9ae62cdb..e5c39de868 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp @@ -19,6 +19,7 @@ #include "RimGeoMechView.h" +#include "RiaApplication.h" #include "RiaLogging.h" #include "RiaPreferences.h" #include "RiaRegressionTestRunner.h" @@ -1050,7 +1051,10 @@ void RimGeoMechView::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrderin if ( surfaceInViewCollection() ) uiTreeOrdering.add( surfaceInViewCollection() ); if ( seismicSectionCollection()->shouldBeVisibleInTree() ) uiTreeOrdering.add( seismicSectionCollection() ); - uiTreeOrdering.add( m_polygonCollection ); + if ( RiaApplication::enableDevelopmentFeatures() ) + { + uiTreeOrdering.add( m_polygonCollection ); + } uiTreeOrdering.skipRemainingChildren( true ); } diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp index b30d82fd6b..b5c413224d 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp @@ -20,6 +20,7 @@ #include "RimEclipseView.h" +#include "RiaApplication.h" #include "RiaColorTables.h" #include "RiaFieldHandleTools.h" #include "RiaLogging.h" @@ -1953,7 +1954,10 @@ void RimEclipseView::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrderin if ( surfaceInViewCollection() ) uiTreeOrdering.add( surfaceInViewCollection() ); if ( seismicSectionCollection()->shouldBeVisibleInTree() ) uiTreeOrdering.add( seismicSectionCollection() ); - uiTreeOrdering.add( m_polygonCollection ); + if ( RiaApplication::enableDevelopmentFeatures() ) + { + uiTreeOrdering.add( m_polygonCollection ); + } uiTreeOrdering.skipRemainingChildren( true ); } diff --git a/ApplicationLibCode/ProjectDataModel/RimProject.cpp b/ApplicationLibCode/ProjectDataModel/RimProject.cpp index a83a566f5b..3405b3c75c 100644 --- a/ApplicationLibCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimProject.cpp @@ -1534,7 +1534,11 @@ void RimProject::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, Q if ( oilField->formationNamesCollection() ) uiTreeOrdering.add( oilField->formationNamesCollection() ); if ( oilField->completionTemplateCollection() ) uiTreeOrdering.add( oilField->completionTemplateCollection() ); if ( oilField->annotationCollection() ) uiTreeOrdering.add( oilField->annotationCollection() ); - if ( oilField->polygonCollection() ) uiTreeOrdering.add( oilField->polygonCollection() ); + + if ( RiaApplication::enableDevelopmentFeatures() ) + { + if ( oilField->polygonCollection() ) uiTreeOrdering.add( oilField->polygonCollection() ); + } } uiTreeOrdering.add( colorLegendCollection() );