diff --git a/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilter3dviewFeature.cpp b/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilter3dviewFeature.cpp index 52db3a8110..a33936e93f 100644 --- a/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilter3dviewFeature.cpp +++ b/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilter3dviewFeature.cpp @@ -18,6 +18,8 @@ #include "RicNewPolygonFilter3dviewFeature.h" +#include "Polygons/RimPolygonInView.h" + #include "RiaApplication.h" #include "RimCase.h" #include "RimCellFilterCollection.h" diff --git a/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.cpp b/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.cpp index 4e8ba926b2..343d8ed97c 100644 --- a/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.cpp +++ b/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.cpp @@ -18,9 +18,12 @@ #include "RicNewPolygonFilterFeature.h" +#include "Polygons/RimPolygonInView.h" + #include "RimCase.h" #include "RimCellFilterCollection.h" #include "RimPolygonFilter.h" + #include "Riu3DMainWindowTools.h" #include "cafSelectionManagerTools.h" diff --git a/ApplicationLibCode/Commands/PolygonCommands/RicNewPolygonFileFeature.cpp b/ApplicationLibCode/Commands/PolygonCommands/RicNewPolygonFileFeature.cpp index 5a5a681fbe..3c061583d2 100644 --- a/ApplicationLibCode/Commands/PolygonCommands/RicNewPolygonFileFeature.cpp +++ b/ApplicationLibCode/Commands/PolygonCommands/RicNewPolygonFileFeature.cpp @@ -1,6 +1,6 @@ //////////////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2022 Equinor ASA +// Copyright (C) 2024 Equinor ASA // // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/ApplicationLibCode/Commands/WellPathCommands/CMakeLists_files.cmake b/ApplicationLibCode/Commands/WellPathCommands/CMakeLists_files.cmake index 57cb2f675e..e8720d49b1 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/CMakeLists_files.cmake +++ b/ApplicationLibCode/Commands/WellPathCommands/CMakeLists_files.cmake @@ -30,7 +30,6 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPointTangentManipulatorPartMgr.h ${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPolyline3dEditor.h ${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPolylineTarget3dEditor.h - ${CMAKE_CURRENT_LIST_DIR}/RicAppendPointsToPolygonFilterFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicDuplicateWellPathFeature.h ) @@ -66,7 +65,6 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPointTangentManipulatorPartMgr.cpp ${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPolyline3dEditor.cpp ${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPolylineTarget3dEditor.cpp - ${CMAKE_CURRENT_LIST_DIR}/RicAppendPointsToPolygonFilterFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicDuplicateWellPathFeature.cpp ) diff --git a/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicPolylineTarget3dEditor.cpp b/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicPolylineTarget3dEditor.cpp index d536f59251..6bf4a98b48 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicPolylineTarget3dEditor.cpp +++ b/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicPolylineTarget3dEditor.cpp @@ -21,6 +21,7 @@ #include "RicPointTangentManipulator.h" #include "Rim3dView.h" +#include "RimPolylinePickerInterface.h" #include "RimPolylineTarget.h" #include "RiuViewer.h" @@ -96,8 +97,13 @@ void RicPolylineTarget3dEditor::configureAndUpdateUi( const QString& uiConfigNam cvf::ref dispXf = view->displayCoordTransform(); - const double handleScalingFactor = 0.7; - const double handleSize = handleScalingFactor * view->characteristicCellSize(); + double scalingFactor = 0.7; + if ( auto pickerInterface = target->firstAncestorOrThisOfType() ) + { + scalingFactor *= pickerInterface->scalingFactorForTarget(); + } + + const double handleSize = scalingFactor * view->characteristicCellSize(); m_manipulator->setOrigin( dispXf->transformToDisplayCoord( target->targetPointXYZ() ) ); m_manipulator->setHandleSize( handleSize ); diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicAppendPointsToPolygonFilterFeature.cpp b/ApplicationLibCode/Commands/WellPathCommands/RicAppendPointsToPolygonFilterFeature.cpp deleted file mode 100644 index 05908fcacd..0000000000 --- a/ApplicationLibCode/Commands/WellPathCommands/RicAppendPointsToPolygonFilterFeature.cpp +++ /dev/null @@ -1,83 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2021- Equinor ASA -// -// ResInsight is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY -// WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. -// -// See the GNU General Public License at -// for more details. -// -///////////////////////////////////////////////////////////////////////////////// - -#include "RicAppendPointsToPolygonFilterFeature.h" - -#include "RiaTextStringTools.h" - -#include "RimPolygonFilter.h" -#include "RimPolylineTarget.h" - -#include "OperationsUsingObjReferences/RicPasteFeatureImpl.h" - -#include "cafSelectionManager.h" -#include "cafSelectionManagerTools.h" - -#include -#include - -CAF_CMD_SOURCE_INIT( RicAppendPointsToPolygonFilterFeature, "RicAppendPointsToPolygonFilterFeature" ); - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RicAppendPointsToPolygonFilterFeature::isCommandEnabled() const -{ - auto obj = caf::firstAncestorOfTypeFromSelectedObject(); - return obj != nullptr; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicAppendPointsToPolygonFilterFeature::onActionTriggered( bool isChecked ) -{ - auto polygonFilter = caf::firstAncestorOfTypeFromSelectedObject(); - if ( !polygonFilter ) return; - - QStringList listOfThreeDoubles; - - QClipboard* clipboard = QApplication::clipboard(); - if ( clipboard ) - { - QString content = clipboard->text(); - listOfThreeDoubles = RiaTextStringTools::splitSkipEmptyParts( content, "\n" ); - } - - std::vector points; - caf::PdmValueFieldSpecialization>::setFromVariant( listOfThreeDoubles, points ); - - for ( const auto& p : points ) - { - auto newTarget = new RimPolylineTarget; - newTarget->setAsPointTargetXYD( p ); - polygonFilter->insertTarget( nullptr, newTarget ); - } - - polygonFilter->updateEditorsAndVisualization(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicAppendPointsToPolygonFilterFeature::setupActionLook( QAction* actionToSetup ) -{ - actionToSetup->setText( "Append Points from Clipboard" ); - - RicPasteFeatureImpl::setIconAndShortcuts( actionToSetup ); -} diff --git a/ApplicationLibCode/ModelVisualization/CMakeLists_files.cmake b/ApplicationLibCode/ModelVisualization/CMakeLists_files.cmake index 36c5f0a7b6..83fa8fa67f 100644 --- a/ApplicationLibCode/ModelVisualization/CMakeLists_files.cmake +++ b/ApplicationLibCode/ModelVisualization/CMakeLists_files.cmake @@ -54,7 +54,6 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RivWellDiskPartMgr.h ${CMAKE_CURRENT_LIST_DIR}/RivElementVectorResultPartMgr.h ${CMAKE_CURRENT_LIST_DIR}/RivPolylinePartMgr.h - ${CMAKE_CURRENT_LIST_DIR}/RivCellFilterPartMgr.h ${CMAKE_CURRENT_LIST_DIR}/RivDrawableSpheres.h ${CMAKE_CURRENT_LIST_DIR}/RivBoxGeometryGenerator.h ${CMAKE_CURRENT_LIST_DIR}/RivAnnotationTools.h @@ -112,7 +111,6 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RivWellDiskPartMgr.cpp ${CMAKE_CURRENT_LIST_DIR}/RivElementVectorResultPartMgr.cpp ${CMAKE_CURRENT_LIST_DIR}/RivPolylinePartMgr.cpp - ${CMAKE_CURRENT_LIST_DIR}/RivCellFilterPartMgr.cpp ${CMAKE_CURRENT_LIST_DIR}/RivDrawableSpheres.cpp ${CMAKE_CURRENT_LIST_DIR}/RivBoxGeometryGenerator.cpp ${CMAKE_CURRENT_LIST_DIR}/RivAnnotationTools.cpp diff --git a/ApplicationLibCode/ModelVisualization/RivCellFilterPartMgr.cpp b/ApplicationLibCode/ModelVisualization/RivCellFilterPartMgr.cpp deleted file mode 100644 index e8d82cd12f..0000000000 --- a/ApplicationLibCode/ModelVisualization/RivCellFilterPartMgr.cpp +++ /dev/null @@ -1,88 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2021 Equinor ASA -// -// ResInsight is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY -// WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. -// -// See the GNU General Public License at -// for more details. -// -///////////////////////////////////////////////////////////////////////////////// - -#include "RivCellFilterPartMgr.h" - -#include "Rim3dView.h" -#include "RimCellFilterCollection.h" -#include "RimPolygonFilter.h" - -#include "RivPolylinePartMgr.h" - -#include "cafPdmObject.h" - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RivCellFilterPartMgr::RivCellFilterPartMgr( Rim3dView* view ) - : m_rimView( view ) -{ -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RivCellFilterPartMgr::~RivCellFilterPartMgr() -{ -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RivCellFilterPartMgr::appendGeometryPartsToModel( cvf::ModelBasicList* model, - const caf::DisplayCoordTransform* displayCoordTransform, - const cvf::BoundingBox& boundingBox ) -{ - createCellFilterPartManagers(); - - for ( auto& partMgr : m_cellFilterPartMgrs ) - { - partMgr->appendDynamicGeometryPartsToModel( model, displayCoordTransform, boundingBox ); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RivCellFilterPartMgr::createCellFilterPartManagers() -{ - std::vector colls = m_rimView->descendantsIncludingThisOfType(); - - if ( colls.empty() ) return; - auto coll = colls.front(); - - clearGeometryCache(); - - for ( auto filter : coll->filters() ) - { - RimPolygonFilter* polyFilter = dynamic_cast( filter ); - if ( polyFilter ) - { - RivPolylinePartMgr* ppm = new RivPolylinePartMgr( m_rimView, polyFilter, coll ); - m_cellFilterPartMgrs.push_back( ppm ); - } - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RivCellFilterPartMgr::clearGeometryCache() -{ - m_cellFilterPartMgrs.clear(); -} diff --git a/ApplicationLibCode/ModelVisualization/RivCellFilterPartMgr.h b/ApplicationLibCode/ModelVisualization/RivCellFilterPartMgr.h deleted file mode 100644 index a58d0d1916..0000000000 --- a/ApplicationLibCode/ModelVisualization/RivCellFilterPartMgr.h +++ /dev/null @@ -1,60 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2021 Equinor ASA -// -// ResInsight is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY -// WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. -// -// See the GNU General Public License at -// for more details. -// -///////////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include "cafPdmPointer.h" -#include "cvfAssert.h" -#include "cvfCollection.h" -#include "cvfObject.h" - -namespace cvf -{ -class BoundingBox; -class Part; -class ModelBasicList; -class Transform; -class Font; -} // namespace cvf -namespace caf -{ -class DisplayCoordTransform; -} - -class Rim3dView; -class RivPolylinePartMgr; - -class RivCellFilterPartMgr : public cvf::Object -{ -public: - RivCellFilterPartMgr( Rim3dView* view ); - ~RivCellFilterPartMgr() override; - - void appendGeometryPartsToModel( cvf::ModelBasicList* model, - const caf::DisplayCoordTransform* displayCoordTransform, - const cvf::BoundingBox& boundingBox ); - - void clearGeometryCache(); - -private: - void createCellFilterPartManagers(); - -private: - caf::PdmPointer m_rimView; - cvf::Collection m_cellFilterPartMgrs; -}; diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp index debe2ba6f7..ef0c5feaf8 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp @@ -260,6 +260,7 @@ RimPolygonFilter* RimCellFilterCollection::addNewPolygonFilter( RimCase* srcCase RimPolygonFilter* pFilter = new RimPolygonFilter(); pFilter->setCase( srcCase ); addFilter( pFilter ); + pFilter->configurePolygonEditor(); pFilter->enablePicking( true ); onFilterUpdated( pFilter ); return pFilter; @@ -485,3 +486,21 @@ void RimCellFilterCollection::updateCellVisibilityByIndex( cvf::UByteArray* incl } } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimCellFilterCollection::cellFilterPolygons() const +{ + std::vector polyInView; + + for ( const auto& filter : m_cellFilters ) + { + if ( auto polygonFilter = dynamic_cast( filter.p() ) ) + { + polyInView.push_back( polygonFilter->polygonInView() ); + } + } + + return polyInView; +} diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.h b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.h index 87a7d808ba..1ad20dc819 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.h +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.h @@ -32,6 +32,7 @@ class RimPolygonFilter; class RimUserDefinedFilter; class RimUserDefinedIndexFilter; class RimCase; +class RimPolygonInView; namespace cvf { @@ -69,7 +70,8 @@ class RimCellFilterCollection : public caf::PdmObject void compoundCellRangeFilter( cvf::CellRangeFilter* cellRangeFilter, size_t gridIndex ) const; void updateCellVisibilityByIndex( cvf::UByteArray* cellsIncluded, cvf::UByteArray* cellsExcluded, size_t gridIndex ) const; - std::vector filters() const; + std::vector cellFilterPolygons() const; + std::vector filters() const; bool hasActiveFilters() const; bool hasActiveIncludeIndexFilters() const; diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp index c68963a176..11ce1e2c40 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp @@ -20,39 +20,28 @@ #include "RigCellGeometryTools.h" #include "RigEclipseCaseData.h" -#include "RigFemPart.h" #include "RigFemPartCollection.h" #include "RigFemPartGrid.h" #include "RigGeoMechCaseData.h" #include "RigMainGrid.h" -#include "RigPolyLinesData.h" #include "RigReservoirGridTools.h" -#include "Rim3dView.h" -#include "RimCase.h" -#include "RimCellFilterCollection.h" #include "RimEclipseCase.h" #include "RimGeoMechCase.h" #include "RimPolylineTarget.h" +#include "RimTools.h" -#include "WellPathCommands/PointTangentManipulator/RicPolyline3dEditor.h" -#include "WellPathCommands/RicPolylineTargetsPickEventHandler.h" +#include "Polygons/RimPolygon.h" +#include "Polygons/RimPolygonCollection.h" +#include "Polygons/RimPolygonInView.h" +#include "Polygons/RimPolygonTools.h" -#include "RiuViewerCommands.h" +#include "Riu3DMainWindowTools.h" -#include "RiaStdStringTools.h" +#include "WellPathCommands/PointTangentManipulator/RicPolyline3dEditor.h" +#include "WellPathCommands/RicPolylineTargetsPickEventHandler.h" -#include "cafCmdFeatureMenuBuilder.h" -#include "cafPdmUiLineEditor.h" #include "cafPdmUiPushButtonEditor.h" -#include "cafPdmUiTableViewEditor.h" -#include "cafPdmUiTreeOrdering.h" -#include - -#include "cvfBoundingBox.h" -#include "cvfStructGrid.h" - -#include #include @@ -75,43 +64,23 @@ void caf::AppEnum::setUp() setDefault( RimPolygonFilter::PolygonIncludeType::CENTER ); } -} // namespace caf - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -class ThicknessValidator : public QValidator +template <> +void caf::AppEnum::setUp() { -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; - } -}; + addItem( RimPolygonFilter::GeometricalShape::AREA, "AREA", "Area Filter" ); + addItem( RimPolygonFilter::GeometricalShape::LINE, "LINE", "Line Filter" ); + setDefault( RimPolygonFilter::GeometricalShape::AREA ); +} -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -class RadiusValidator : public QValidator +template <> +void caf::AppEnum::setUp() { -public: - State validate( QString& input, int& pos ) const override - { - if ( input.isEmpty() ) return State::Intermediate; + addItem( RimPolygonFilter::PolygonDataSource::DEFINED_IN_FILTER, "DEFINED_IN_FILTER", "Defined in Filter" ); + addItem( RimPolygonFilter::PolygonDataSource::GLOBAL_POLYGON, "GLOBAL_POLYGON", "Polygon in Project" ); + setDefault( RimPolygonFilter::PolygonDataSource::DEFINED_IN_FILTER ); +} - double val = RiaStdStringTools::toDouble( input.toStdString() ); - if ( val > 0.001 && val <= 2.0 ) - return State::Acceptable; - else - return State::Invalid; - } -}; +} // namespace caf CAF_PDM_SOURCE_INIT( RimPolygonFilter, "PolygonFilter", "PolyLineFilter" ); @@ -128,70 +97,45 @@ RimPolygonFilter::RimPolygonFilter() CAF_PDM_InitFieldNoDefault( &m_polyFilterMode, "PolygonFilterType", "Vertical Filter" ); CAF_PDM_InitFieldNoDefault( &m_polyIncludeType, "PolyIncludeType", "Cells to include" ); + CAF_PDM_InitFieldNoDefault( &m_polygonDataSource, "PolygonDataSource", "Data Source" ); - CAF_PDM_InitField( &m_enablePicking, "EnablePicking", false, "" ); - caf::PdmUiPushButtonEditor::configureEditorForField( &m_enablePicking ); - m_enablePicking.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosType::HIDDEN ); - - CAF_PDM_InitFieldNoDefault( &m_targets, "Targets", "Targets" ); - m_targets.uiCapability()->setUiEditorTypeName( caf::PdmUiTableViewEditor::uiEditorTypeName() ); - m_targets.uiCapability()->setUiTreeChildrenHidden( true ); - m_targets.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); - m_targets.uiCapability()->setCustomContextMenuEnabled( true ); + CAF_PDM_InitFieldNoDefault( &m_geometricalShape, "GeometricalShape", "" ); + m_geometricalShape.registerGetMethod( this, &RimPolygonFilter::geometricalShape ); + m_geometricalShape.registerSetMethod( this, &RimPolygonFilter::setGeometricalShape ); - CAF_PDM_InitField( &m_showLines, "ShowLines", true, "Show Lines" ); - CAF_PDM_InitField( &m_showSpheres, "ShowSpheres", false, "Show Spheres" ); - CAF_PDM_InitField( &m_closePolygon, "ClosePolygon", true, "Closed Polygon" ); + CAF_PDM_InitFieldNoDefault( &m_internalPolygon, "InternalPolygon", "Polygon For Filter" ); + m_internalPolygon = new RimPolygon; + m_internalPolygon->setName( "Polygon For Filter" ); + m_internalPolygon->uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitField( &m_lineThickness, "LineThickness", 3, "Line Thickness" ); - CAF_PDM_InitField( &m_sphereRadiusFactor, "SphereRadiusFactor", 0.15, "Sphere Radius Factor" ); + CAF_PDM_InitFieldNoDefault( &m_cellFilterPolygon, "Polygon", "Polygon" ); - CAF_PDM_InitField( &m_lineColor, "LineColor", cvf::Color3f( cvf::Color3f::WHITE ), "Line Color" ); - CAF_PDM_InitField( &m_sphereColor, "SphereColor", cvf::Color3f( cvf::Color3f::WHITE ), "Sphere Color" ); + CAF_PDM_InitFieldNoDefault( &m_polygonEditor, "PolygonEditor", "Polygon Editor" ); + m_polygonEditor = new RimPolygonInView; + m_polygonEditor->uiCapability()->setUiTreeHidden( true ); + m_polygonEditor.xmlCapability()->disableIO(); CAF_PDM_InitField( &m_enableFiltering, "EnableFiltering", false, "Enable Filter" ); CAF_PDM_InitField( &m_enableKFilter, "EnableKFilter", false, "Enable K Range Filter" ); CAF_PDM_InitFieldNoDefault( &m_kFilterStr, "KRangeFilter", "K Range Filter", "", "Example: 2,4-6,10-20:2", "" ); - CAF_PDM_InitField( &m_polygonPlaneDepth, "PolygonPlaneDepth", 0.0, "Polygon Plane Depth" ); - CAF_PDM_InitField( &m_lockPolygonToPlane, "LockPolygon", false, "Lock Polygon to Plane" ); + CAF_PDM_InitField( &m_editPolygonButton, "EditPolygonButton", false, "Edit" ); + m_editPolygonButton.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); + m_editPolygonButton.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); - m_polygonPlaneDepth.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); - m_polygonPlaneDepth.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosType::TOP ); - - setUi3dEditorTypeName( RicPolyline3dEditor::uiEditorTypeName() ); - uiCapability()->setUiTreeChildrenHidden( true ); + CAF_PDM_InitFieldNoDefault( &m_OBSOLETE_targets, "Targets", "Targets" ); + m_OBSOLETE_targets.uiCapability()->setUiTreeChildrenHidden( true ); + m_OBSOLETE_targets.uiCapability()->setUiTreeHidden( true ); + m_OBSOLETE_targets.uiCapability()->setUiHidden( true ); + m_OBSOLETE_targets.xmlCapability()->setIOWritable( false ); m_propagateToSubGrids = false; updateIconState(); setDeletable( true ); -} -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimPolygonFilter::~RimPolygonFilter() -{ -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimPolygonFilter::updateVisualization() -{ - updateCells(); - filterChanged.send(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimPolygonFilter::updateEditorsAndVisualization() -{ - updateConnectedEditors(); - updateVisualization(); + setUi3dEditorTypeName( RicPolyline3dEditor::uiEditorTypeName() ); } //-------------------------------------------------------------------------------------------------- @@ -238,32 +182,23 @@ QString RimPolygonFilter::fullName() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimPolygonFilter::activeTargets() const +void RimPolygonFilter::initAfterRead() { - return m_targets.childrenByType(); -} + RimCellFilter::initAfterRead(); -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimPolygonFilter::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 ); + // Move existing polygons to global polygon + if ( !m_OBSOLETE_targets.empty() ) + { + std::vector points; + for ( const auto& target : m_OBSOLETE_targets ) + { + points.push_back( target->targetPointXYZ() ); + } - updateCells(); -} + m_internalPolygon->setPointsInDomainCoords( points ); + } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimPolygonFilter::deleteTarget( RimPolylineTarget* targetToDelete ) -{ - m_targets.removeChild( targetToDelete ); - delete targetToDelete; + configurePolygonEditor(); } //-------------------------------------------------------------------------------------------------- @@ -271,68 +206,17 @@ void RimPolygonFilter::deleteTarget( RimPolylineTarget* targetToDelete ) //-------------------------------------------------------------------------------------------------- void RimPolygonFilter::defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) { - if ( field == &m_enablePicking ) + if ( auto attrib = dynamic_cast( attribute ) ) { - auto* pbAttribute = dynamic_cast( attribute ); - if ( pbAttribute ) - { - if ( !m_enablePicking ) - { - pbAttribute->m_buttonText = "Start Picking Points"; - } - else - { - pbAttribute->m_buttonText = "Stop Picking Points"; - } - } + attrib->pickEventHandler = m_pickTargetsEventHandler; + attrib->enablePicking = m_polygonEditor->pickingEnabled(); } - else if ( field == &m_targets ) - { - auto tvAttribute = dynamic_cast( attribute ); - if ( tvAttribute ) - { - tvAttribute->resizePolicy = caf::PdmUiTableViewEditorAttribute::RESIZE_TO_FIT_CONTENT; - if ( m_enablePicking ) - { - tvAttribute->baseColor.setRgb( 255, 220, 255 ); - tvAttribute->alwaysEnforceResizePolicy = true; - } - } - } - else if ( field == &m_lineThickness ) + if ( field == &m_editPolygonButton ) { - auto myAttr = dynamic_cast( attribute ); - if ( myAttr ) + if ( auto attrib = dynamic_cast( attribute ) ) { - myAttr->validator = new ThicknessValidator(); - } - } - else if ( field == &m_lineThickness ) - { - auto myAttr = dynamic_cast( attribute ); - if ( myAttr ) - { - myAttr->validator = new RadiusValidator(); - } - } - else if ( field == &m_polygonPlaneDepth ) - { - auto* attr = dynamic_cast( attribute ); - - if ( attr ) - { - if ( m_srcCase ) - { - auto bb = m_srcCase->allCellsBoundingBox(); - attr->m_minimum = -bb.max().z(); - attr->m_maximum = -bb.min().z(); - } - else - { - attr->m_minimum = 0; - attr->m_maximum = 10000; - } + attrib->m_buttonText = "Edit"; } } } @@ -340,14 +224,12 @@ void RimPolygonFilter::defineEditorAttribute( const caf::PdmFieldHandle* field, //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimPolygonFilter::defineCustomContextMenu( const caf::PdmFieldHandle* fieldNeedingMenu, QMenu* menu, QWidget* fieldEditorWidget ) +void RimPolygonFilter::childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) { - caf::CmdFeatureMenuBuilder menuBuilder; + // When interactive edit of polyline coordinates in enabled in RimPolygonInView::m_enablePicking, the editors to RimPolygonFilter must + // be updated to trigger calls to RimPolylinePickerInterface - menuBuilder << "RicDeletePolylineTargetFeature"; - menuBuilder << "RicAppendPointsToPolygonFilterFeature"; - - menuBuilder.appendToMenu( menu ); + updateConnectedEditors(); } //-------------------------------------------------------------------------------------------------- @@ -357,35 +239,29 @@ void RimPolygonFilter::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin { uiOrdering.add( &m_name ); + auto dataSourceGroup = uiOrdering.addNewGroup( "Polygon Data Source" ); + dataSourceGroup->add( &m_polygonDataSource ); + if ( !isPolygonDefinedLocally() ) + { + dataSourceGroup->add( &m_cellFilterPolygon ); + dataSourceGroup->add( &m_editPolygonButton, { .newRow = false } ); + } + auto group = uiOrdering.addNewGroup( "General" ); group->add( &m_filterMode ); + group->add( &m_geometricalShape ); group->add( &m_enableFiltering ); - group->add( &m_closePolygon ); auto group1 = uiOrdering.addNewGroup( "Polygon Selection" ); group1->add( &m_polyFilterMode ); - if ( m_closePolygon() ) group1->add( &m_polyIncludeType ); - group1->add( &m_targets ); - group1->add( &m_enablePicking ); - - m_polyIncludeType.uiCapability()->setUiName( "Cells to " + modeString() ); - auto group2 = uiOrdering.addNewGroup( "Appearance" ); - group2->add( &m_showLines ); - group2->add( &m_showSpheres ); - if ( m_showLines ) - { - group2->add( &m_lineThickness ); - group2->add( &m_lineColor ); - } - if ( m_showSpheres ) + bool isPolygonClosed = m_cellFilterPolygon() ? m_cellFilterPolygon->isClosed() : false; + if ( isPolygonClosed ) { - group2->add( &m_sphereRadiusFactor ); - group2->add( &m_sphereColor ); + group1->add( &m_polyIncludeType ); } - group2->add( &m_lockPolygonToPlane ); - if ( m_lockPolygonToPlane ) group2->add( &m_polygonPlaneDepth ); - group2->setCollapsedByDefault(); + + m_polyIncludeType.uiCapability()->setUiName( "Cells to " + modeString() ); auto group3 = uiOrdering.addNewGroup( "Advanced Filter Settings" ); group3->add( &m_enableKFilter ); @@ -402,7 +278,7 @@ void RimPolygonFilter::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin objField->uiCapability()->setUiReadOnly( readOnlyState ); } - if ( !m_closePolygon() ) + if ( !isPolygonClosed ) { m_polyFilterMode = RimPolygonFilter::PolygonFilterModeType::INDEX_K; m_polyFilterMode.uiCapability()->setUiReadOnly( true ); @@ -411,6 +287,30 @@ void RimPolygonFilter::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin { m_polyFilterMode.uiCapability()->setUiReadOnly( readOnlyState ); } + + if ( isPolygonDefinedLocally() ) + { + caf::PdmUiGroup* polyDefinitionGroup = uiOrdering.addNewGroup( "Polygon Definition" ); + m_polygonEditor()->uiOrderingForLocalPolygon( uiConfigName, *polyDefinitionGroup ); + + caf::PdmUiGroup* appearanceGroup = uiOrdering.addNewGroup( "Appearance" ); + appearanceGroup->setCollapsedByDefault(); + m_internalPolygon->uiOrderingForLocalPolygon( uiConfigName, *appearanceGroup ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimPolygonFilter::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) +{ + QList options; + if ( fieldNeedingOptions == &m_cellFilterPolygon ) + { + RimTools::polygonOptionItems( &options ); + } + + return options; } //-------------------------------------------------------------------------------------------------- @@ -418,20 +318,39 @@ void RimPolygonFilter::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin //-------------------------------------------------------------------------------------------------- void RimPolygonFilter::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) { - if ( changedField == &m_enablePicking ) + if ( changedField == &m_editPolygonButton ) { - updateConnectedEditors(); + RimPolygonTools::selectPolygonInView( m_cellFilterPolygon(), this ); - enableFilter( !m_enablePicking() ); - filterChanged.send(); + m_editPolygonButton = false; + + return; } - else if ( ( changedField == &m_showLines ) || ( changedField == &m_showSpheres ) || ( changedField == &m_sphereColor ) || - ( changedField == &m_sphereRadiusFactor ) || ( changedField == &m_lineThickness ) || ( changedField == &m_lineColor ) || - ( changedField == &m_lockPolygonToPlane ) || ( changedField == &m_polygonPlaneDepth ) ) + + if ( changedField == &m_polygonDataSource ) { - filterChanged.send(); + if ( !isPolygonDefinedLocally() ) + { + if ( m_cellFilterPolygon() == nullptr || m_cellFilterPolygon() == m_internalPolygon ) + { + auto polygonCollection = RimTools::polygonCollection(); + if ( polygonCollection && !polygonCollection->allPolygons().empty() ) + { + m_cellFilterPolygon = polygonCollection->allPolygons().front(); + } + } + } + configurePolygonEditor(); + updateAllRequiredEditors(); } - else if ( changedField != &m_name ) + + if ( changedField == &m_cellFilterPolygon ) + { + configurePolygonEditor(); + updateAllRequiredEditors(); + } + + if ( changedField != &m_name ) { updateCells(); filterChanged.send(); @@ -444,26 +363,10 @@ void RimPolygonFilter::fieldChangedByUi( const caf::PdmFieldHandle* changedField //-------------------------------------------------------------------------------------------------- void RimPolygonFilter::enablePicking( bool enable ) { - m_enablePicking = enable; + m_polygonEditor->enablePicking( enable ); updateConnectedEditors(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RimPolygonFilter::pickingEnabled() const -{ - return m_enablePicking(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -caf::PickEventHandler* RimPolygonFilter::pickEventHandler() const -{ - return m_pickTargetsEventHandler.get(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -583,7 +486,7 @@ void RimPolygonFilter::updateCellsKIndexEclipse( const std::vector& const int gIdx = static_cast( grid->gridIndex() ); std::list foundCells; - const bool closedPolygon = m_closePolygon(); + const bool closedPolygon = isPolygonClosed(); // find all cells in the K layer that matches the polygon #pragma omp parallel for @@ -591,8 +494,8 @@ void RimPolygonFilter::updateCellsKIndexEclipse( const std::vector& { for ( size_t j = 0; j < grid->cellCountJ(); j++ ) { - size_t cellIdx = grid->cellIndexFromIJK( i, j, K ); - RigCell cell = grid->cell( cellIdx ); + size_t cellIdx = grid->cellIndexFromIJK( i, j, K ); + const RigCell& cell = grid->cell( cellIdx ); // valid cell? if ( cell.isInvalid() ) continue; @@ -634,7 +537,7 @@ void RimPolygonFilter::updateCellsKIndexEclipse( const std::vector& // get the cell index size_t newIdx = grid->cellIndexFromIJK( ci, cj, k ); // valid cell? - RigCell cell = grid->cell( newIdx ); + const RigCell& cell = grid->cell( newIdx ); if ( cell.isInvalid() ) continue; m_cells[gIdx].push_back( newIdx ); @@ -652,7 +555,7 @@ void RimPolygonFilter::updateCellsForEclipse( const std::vector& poi if ( m_polyFilterMode == PolygonFilterModeType::DEPTH_Z ) { - if ( !m_closePolygon() ) return; + if ( !isPolygonClosed() ) return; for ( size_t gridIndex = 0; gridIndex < data->gridCount(); gridIndex++ ) { @@ -720,7 +623,7 @@ void RimPolygonFilter::updateCellsDepthGeoMech( const std::vector& p //-------------------------------------------------------------------------------------------------- void RimPolygonFilter::updateCellsKIndexGeoMech( const std::vector& points, const RigFemPartGrid* grid, int partId ) { - const bool closedPolygon = m_closePolygon(); + const bool closedPolygon = isPolygonClosed(); // we need to find the K layer we hit with the first point size_t nk; @@ -839,7 +742,7 @@ void RimPolygonFilter::updateCellsForGeoMech( const std::vector& poi if ( m_polyFilterMode == PolygonFilterModeType::DEPTH_Z ) { - if ( m_closePolygon() ) + if ( isPolygonClosed() ) { updateCellsDepthGeoMech( points, grid, i ); } @@ -865,16 +768,17 @@ void RimPolygonFilter::updateCells() // get polyline as vector std::vector points; - for ( auto& target : m_targets ) + + for ( auto target : m_polygonEditor->activeTargets() ) { points.push_back( target->targetPointXYZ() ); } // We need at least three points to make a closed polygon, or just 2 for a polyline - if ( ( !m_closePolygon() && ( points.size() < 2 ) ) || ( m_closePolygon() && ( points.size() < 3 ) ) ) return; + if ( ( !isPolygonClosed() && ( points.size() < 2 ) ) || ( isPolygonClosed() && ( points.size() < 3 ) ) ) return; // make sure first and last point is the same (req. by closed polygon methods used later) - if ( m_closePolygon() ) points.push_back( points.front() ); + if ( isPolygonClosed() ) points.push_back( points.front() ); RimEclipseCase* eCase = eclipseCase(); RimGeoMechCase* gCase = geoMechCase(); @@ -892,30 +796,114 @@ void RimPolygonFilter::updateCells() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::ref RimPolygonFilter::polyLinesData() const +void RimPolygonFilter::configurePolygonEditor() { - cvf::ref pld = new RigPolyLinesData; - std::vector line; - for ( const RimPolylineTarget* target : m_targets ) - { - line.push_back( target->targetPointXYZ() ); - } - pld->setPolyLine( line ); + RimPolygon* polygon = nullptr; + if ( isPolygonDefinedLocally() ) + polygon = m_internalPolygon(); + else + polygon = m_cellFilterPolygon(); + + m_polygonEditor->setPolygon( polygon ); + + // Must connect the signals after polygon is assigned to the polygon editor + // When assigning an object to a ptr field, all signals are disconnected + connectObjectSignals( polygon ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimPolygonInView* RimPolygonFilter::polygonInView() const +{ + return m_polygonEditor(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonFilter::insertTarget( const RimPolylineTarget* targetToInsertBefore, RimPolylineTarget* targetToInsert ) +{ + m_polygonEditor->insertTarget( targetToInsertBefore, targetToInsert ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonFilter::deleteTarget( RimPolylineTarget* targetToDelete ) +{ + m_polygonEditor->deleteTarget( targetToDelete ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonFilter::updateEditorsAndVisualization() +{ + updateConnectedEditors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonFilter::updateVisualization() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimPolygonFilter::activeTargets() const +{ + return m_polygonEditor->activeTargets(); +} - pld->setLineAppearance( m_lineThickness, m_lineColor, m_closePolygon ); - pld->setSphereAppearance( m_sphereRadiusFactor, m_sphereColor ); - pld->setZPlaneLock( m_lockPolygonToPlane, -m_polygonPlaneDepth ); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimPolygonFilter::pickingEnabled() const +{ + return m_polygonEditor->pickingEnabled(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PickEventHandler* RimPolygonFilter::pickEventHandler() const +{ + return m_pickTargetsEventHandler.get(); +} - if ( isActive() ) +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::AppEnum RimPolygonFilter::geometricalShape() const +{ + if ( isPolygonDefinedLocally() ) { - pld->setVisibility( m_showLines, m_showSpheres ); + if ( !m_internalPolygon->isClosed() ) return GeometricalShape::LINE; } else { - pld->setVisibility( false, false ); + if ( m_cellFilterPolygon && !m_cellFilterPolygon->isClosed() ) return GeometricalShape::LINE; } - return pld; + return GeometricalShape::AREA; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonFilter::setGeometricalShape( const caf::AppEnum& shape ) +{ + if ( isPolygonDefinedLocally() ) + { + m_internalPolygon->setIsClosed( shape == GeometricalShape::AREA ); + } + else if ( m_cellFilterPolygon() ) + { + m_cellFilterPolygon->setIsClosed( shape == GeometricalShape::AREA ); + } } //-------------------------------------------------------------------------------------------------- @@ -932,6 +920,53 @@ void RimPolygonFilter::initializeCellList() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimPolygonFilter::isPolygonClosed() const +{ + if ( isPolygonDefinedLocally() ) return m_internalPolygon->isClosed(); + + if ( m_cellFilterPolygon() ) return m_cellFilterPolygon->isClosed(); + + return true; +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimPolygonFilter::isPolygonDefinedLocally() const +{ + return m_polygonDataSource() == PolygonDataSource::DEFINED_IN_FILTER; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonFilter::connectObjectSignals( RimPolygon* polygon ) +{ + if ( m_cellFilterPolygon() ) + { + m_cellFilterPolygon()->objectChanged.disconnect( this ); + } + + if ( polygon ) + { + m_cellFilterPolygon = polygon; + + polygon->objectChanged.connect( this, &RimPolygonFilter::onObjectChanged ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonFilter::onObjectChanged( const caf::SignalEmitter* emitter ) +{ + updateCells(); + filterChanged.send(); + updateIconState(); +} + //-------------------------------------------------------------------------------------------------- /// Find which K layer we hit, in any of the grids, for any of the selected points //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.h b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.h index 94018cf843..ec9acefa91 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.h +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.h @@ -21,42 +21,42 @@ #include "RimCellFilter.h" #include "RimCellFilterIntervalTool.h" #include "RimPolylinePickerInterface.h" -#include "RimPolylinesDataInterface.h" #include "cafAppEnum.h" #include "cafPdmChildArrayField.h" -#include "cafPdmField.h" -#include "cafPdmFieldCvfColor.h" -#include "cafPdmFieldCvfVec3d.h" +#include "cafPdmChildField.h" #include "cafPdmObject.h" #include "cafPdmPtrField.h" -#include "cafPickEventHandler.h" -#include "cvfColor3.h" - -#include -#include - -class RicPolylineTargetsPickEventHandler; +class RimPolygon; class RimPolylineTarget; -class RimCase; -class RimEclipseCase; -class RimGeoMechCase; class RigGridBase; -class RigMainGrid; class RigFemPartGrid; -class RigPolylinesData; +class RimPolygonInView; class RigEclipseCaseData; +class RicPolylineTargetsPickEventHandler; //================================================================================================== /// /// //================================================================================================== -class RimPolygonFilter : public RimCellFilter, public RimPolylinePickerInterface, public RimPolylinesDataInterface +class RimPolygonFilter : public RimCellFilter, public RimPolylinePickerInterface { CAF_PDM_HEADER_INIT; public: + enum class PolygonDataSource + { + DEFINED_IN_FILTER, + GLOBAL_POLYGON + }; + + enum class GeometricalShape + { + AREA, + LINE + }; + enum class PolygonFilterModeType { DEPTH_Z, @@ -71,38 +71,31 @@ class RimPolygonFilter : public RimCellFilter, public RimPolylinePickerInterface }; RimPolygonFilter(); - ~RimPolygonFilter() override; void enableFilter( bool bEnable ); void enableKFilter( bool bEnable ); bool isFilterEnabled() const override; - void updateVisualization() override; - void updateEditorsAndVisualization() override; - void insertTarget( const RimPolylineTarget* targetToInsertBefore, RimPolylineTarget* targetToInsert ) override; - void deleteTarget( RimPolylineTarget* targetToDelete ) override; void enablePicking( bool enable ); - std::vector activeTargets() const override; - bool pickingEnabled() const override; - caf::PickEventHandler* pickEventHandler() const override; - void updateCellIndexFilter( cvf::UByteArray* includeVisibility, cvf::UByteArray* excludeVisibility, int gridIndex ) override; void onGridChanged() override; - cvf::ref polyLinesData() const override; + void configurePolygonEditor(); + RimPolygonInView* polygonInView() const; protected: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; + void initAfterRead() override; + void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; + void childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) override; QString fullName() const override; private: - void defineCustomContextMenu( const caf::PdmFieldHandle* fieldNeedingMenu, QMenu* menu, QWidget* fieldEditorWidget ) override; - void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; - void updateCells(); void updateCellsForEclipse( const std::vector& points, RimEclipseCase* eCase ); void updateCellsForGeoMech( const std::vector& points, RimGeoMechCase* gCase ); @@ -118,26 +111,45 @@ class RimPolygonFilter : public RimCellFilter, public RimPolylinePickerInterface void initializeCellList(); - caf::PdmField m_enablePicking; - caf::PdmChildArrayField m_targets; - caf::PdmField> m_polyFilterMode; - caf::PdmField> m_polyIncludeType; - caf::PdmField m_enableFiltering; - caf::PdmField m_showLines; - caf::PdmField m_showSpheres; - caf::PdmField m_lineThickness; - caf::PdmField m_sphereRadiusFactor; - caf::PdmField m_lineColor; - caf::PdmField m_sphereColor; - caf::PdmField m_polygonPlaneDepth; - caf::PdmField m_lockPolygonToPlane; - caf::PdmField m_enableKFilter; - caf::PdmField m_kFilterStr; - caf::PdmField m_closePolygon; + bool isPolygonClosed() const; + bool isPolygonDefinedLocally() const; - std::shared_ptr m_pickTargetsEventHandler; + void connectObjectSignals( RimPolygon* polygon ); + void onObjectChanged( const caf::SignalEmitter* emitter ); + + // RimPolylinePickerInterface used to forward events to m_polygonEditor + void insertTarget( const RimPolylineTarget* targetToInsertBefore, RimPolylineTarget* targetToInsert ) override; + void deleteTarget( RimPolylineTarget* targetToDelete ) override; + void updateEditorsAndVisualization() override; + void updateVisualization() override; + std::vector activeTargets() const override; + bool pickingEnabled() const override; + caf::PickEventHandler* pickEventHandler() const override; + + caf::AppEnum geometricalShape() const; + void setGeometricalShape( const caf::AppEnum& shape ); + +private: + caf::PdmField> m_polyFilterMode; + caf::PdmField> m_polyIncludeType; + caf::PdmField> m_polygonDataSource; + caf::PdmProxyValueField> m_geometricalShape; + + caf::PdmField m_enableFiltering; + caf::PdmField m_enableKFilter; + caf::PdmField m_kFilterStr; std::vector> m_cells; RimCellFilterIntervalTool m_intervalTool; + + // Local polygon and polygon editor + caf::PdmPtrField m_cellFilterPolygon; + caf::PdmChildField m_internalPolygon; + caf::PdmChildField m_polygonEditor; + caf::PdmField m_editPolygonButton; + + std::shared_ptr m_pickTargetsEventHandler; + + caf::PdmChildArrayField m_OBSOLETE_targets; }; diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp index e5c39de868..d94b027858 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp @@ -322,10 +322,7 @@ void RimGeoMechView::onCreateDisplayModel() nativeOrOverrideViewer()->addStaticModelOnce( m_seismicVizModel.p(), isUsingOverrideViewer() ); // Polygons - - m_polygonVizModel->removeAllParts(); - m_polygonCollection->appendPartsToModel( m_polygonVizModel.p(), transform.p(), femBBox ); - nativeOrOverrideViewer()->addStaticModelOnce( m_polygonVizModel.p(), isUsingOverrideViewer() ); + appendPolygonPartsToModel( transform.p(), ownerCase()->allCellsBoundingBox() ); // Surfaces @@ -1053,7 +1050,7 @@ void RimGeoMechView::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrderin if ( RiaApplication::enableDevelopmentFeatures() ) { - uiTreeOrdering.add( m_polygonCollection ); + uiTreeOrdering.add( m_polygonInViewCollection ); } uiTreeOrdering.skipRemainingChildren( true ); diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/Polygons/CMakeLists_files.cmake index af99df45c7..ace8580f7d 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/CMakeLists_files.cmake +++ b/ApplicationLibCode/ProjectDataModel/Polygons/CMakeLists_files.cmake @@ -5,6 +5,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RimPolygonInView.h ${CMAKE_CURRENT_LIST_DIR}/RimPolygonInViewCollection.h ${CMAKE_CURRENT_LIST_DIR}/RimPolygonAppearance.h + ${CMAKE_CURRENT_LIST_DIR}/RimPolygonTools.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -14,6 +15,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RimPolygonInView.cpp ${CMAKE_CURRENT_LIST_DIR}/RimPolygonInViewCollection.cpp ${CMAKE_CURRENT_LIST_DIR}/RimPolygonAppearance.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimPolygonTools.cpp ) list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.cpp b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.cpp index c505ac9345..074a7d20e8 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.cpp +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.cpp @@ -53,6 +53,14 @@ cvf::ref RimPolygon::polyLinesData() const return pld; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygon::uiOrderingForLocalPolygon( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +{ + m_appearance->uiOrdering( uiConfigName, uiOrdering ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -71,6 +79,14 @@ std::vector RimPolygon::pointsInDomainCoords() const return m_pointsInDomainCoords(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygon::setIsClosed( bool isClosed ) +{ + m_appearance->setIsClosed( isClosed ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.h b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.h index ede74d9f49..455ace4578 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.h +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.h @@ -40,10 +40,13 @@ class RimPolygon : public RimNamedObject, public RimPolylinesDataInterface void setPointsInDomainCoords( const std::vector& points ); std::vector pointsInDomainCoords() const; + void setIsClosed( bool isClosed ); bool isClosed() const; cvf::ref polyLinesData() const override; + void uiOrderingForLocalPolygon( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ); + protected: void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.cpp b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.cpp index 038ee5e7f0..1cd83a0a5c 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.cpp +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.cpp @@ -78,7 +78,7 @@ RimPolygonAppearance::RimPolygonAppearance() { CAF_PDM_InitObject( "Polygon", ":/PolylinesFromFile16x16.png" ); - CAF_PDM_InitField( &m_isClosed, "IsClosed", false, "Closed Polygon" ); + CAF_PDM_InitField( &m_isClosed, "IsClosed", true, "Closed Polygon" ); CAF_PDM_InitField( &m_showLines, "ShowLines", true, "Show Lines" ); CAF_PDM_InitField( &m_showSpheres, "ShowSpheres", false, "Show Spheres" ); @@ -106,6 +106,15 @@ void RimPolygonAppearance::applyAppearanceSettings( RigPolyLinesData* polyLinesD polyLinesData->setVisibility( m_showLines, m_showSpheres ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonAppearance::setIsClosed( bool isClosed ) +{ + m_isClosed = isClosed; + objectChanged.send(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.h b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.h index 05a9b2284e..4fae753127 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.h +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.h @@ -34,6 +34,7 @@ class RimPolygonAppearance : public caf::PdmObject void applyAppearanceSettings( RigPolyLinesData* polyLinesData ); + void setIsClosed( bool isClosed ); bool isClosed() const; public: diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.cpp b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.cpp index 60371b247d..a4c1e1c346 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.cpp +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.cpp @@ -58,6 +58,8 @@ RimPolygonInView::RimPolygonInView() caf::PdmUiPushButtonEditor::configureEditorForField( &m_enablePicking ); m_enablePicking.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosType::HIDDEN ); + CAF_PDM_InitField( &m_handleScalingFactor, "HandleScalingFactor", 1.0, "Handle Scaling Factor" ); + CAF_PDM_InitFieldNoDefault( &m_targets, "Targets", "Targets" ); m_targets.uiCapability()->setUiEditorTypeName( caf::PdmUiTableViewEditor::uiEditorTypeName() ); m_targets.uiCapability()->setUiTreeChildrenHidden( true ); @@ -243,6 +245,8 @@ void RimPolygonInView::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin { updateNameField(); + uiOrdering.add( &m_handleScalingFactor ); + if ( m_polygon() ) uiOrdering.add( m_polygon ); uiOrdering.add( &m_enablePicking ); } @@ -288,6 +292,24 @@ void RimPolygonInView::defineObjectEditorAttribute( QString uiConfigName, caf::P } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonInView::uiOrderingForLocalPolygon( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +{ + uiOrdering.add( &m_enablePicking ); + uiOrdering.add( &m_targets ); + uiOrdering.add( &m_handleScalingFactor ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimPolygonInView::scalingFactorForTarget() const +{ + return m_handleScalingFactor(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.h b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.h index 3e8a6864cd..2883ead0c7 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.h +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.h @@ -55,7 +55,6 @@ class RimPolygonInView : public RimCheckableNamedObject, public RimPolylinesData void appendPartsToModel( cvf::ModelBasicList* model, const caf::DisplayCoordTransform* scaleTransform, const cvf::BoundingBox& boundingBox ); void enablePicking( bool enable ); - // RimPolylinesDataInterface void insertTarget( const RimPolylineTarget* targetToInsertBefore, RimPolylineTarget* targetToInsert ) override; void deleteTarget( RimPolylineTarget* targetToDelete ) override; void updateEditorsAndVisualization() override; @@ -63,12 +62,15 @@ class RimPolygonInView : public RimCheckableNamedObject, public RimPolylinesData std::vector activeTargets() const override; bool pickingEnabled() const override; caf::PickEventHandler* pickEventHandler() const override; + double scalingFactorForTarget() const override; cvf::ref polyLinesData() const override; void onChildrenUpdated( caf::PdmChildArrayFieldHandle* childArray, std::vector& updatedObjects ) override; void defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; + void uiOrderingForLocalPolygon( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ); + protected: void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; @@ -87,6 +89,7 @@ class RimPolygonInView : public RimCheckableNamedObject, public RimPolylinesData caf::PdmPtrField m_polygon; caf::PdmField m_enablePicking; + caf::PdmField m_handleScalingFactor; caf::PdmChildArrayField m_targets; cvf::ref m_polylinePartMgr; diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInViewCollection.cpp b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInViewCollection.cpp index fadd762d44..9aa7034018 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInViewCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInViewCollection.cpp @@ -23,10 +23,6 @@ #include "RimPolygonInView.h" #include "RimTools.h" -#include "cafDisplayCoordTransform.h" - -#include "cvfModelBasicList.h" - CAF_PDM_SOURCE_INIT( RimPolygonInViewCollection, "RimPolygonInViewCollection" ); //-------------------------------------------------------------------------------------------------- @@ -83,15 +79,7 @@ void RimPolygonInViewCollection::syncPolygonsInView() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimPolygonInViewCollection::appendPartsToModel( cvf::ModelBasicList* model, - caf::DisplayCoordTransform* scaleTransform, - const cvf::BoundingBox& boundingBox ) +std::vector RimPolygonInViewCollection::polygonsInView() const { - for ( auto polygon : m_polygons ) - { - if ( polygon && polygon->isChecked() ) - { - polygon->appendPartsToModel( model, scaleTransform, boundingBox ); - } - } + return m_polygons.childrenByType(); } diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInViewCollection.h b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInViewCollection.h index 7d79a1b853..2659f0beee 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInViewCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInViewCollection.h @@ -23,17 +23,6 @@ class RimPolygonInView; -namespace cvf -{ -class ModelBasicList; -class BoundingBox; -} // namespace cvf - -namespace caf -{ -class DisplayCoordTransform; -} // namespace caf - //================================================================================================== /// /// @@ -47,7 +36,7 @@ class RimPolygonInViewCollection : public caf::PdmObject void syncPolygonsInView(); - void appendPartsToModel( cvf::ModelBasicList* model, caf::DisplayCoordTransform* scaleTransform, const cvf::BoundingBox& boundingBox ); + std::vector polygonsInView() const; private: caf::PdmChildArrayField m_polygons; diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonTools.cpp b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonTools.cpp new file mode 100644 index 0000000000..d42ebbc9d5 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonTools.cpp @@ -0,0 +1,63 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimPolygonTools.h" + +#include "RimGridView.h" +#include "RimOilField.h" +#include "RimPolygon.h" +#include "RimPolygonCollection.h" +#include "RimPolygonInView.h" +#include "RimPolygonInViewCollection.h" +#include "RimProject.h" + +#include "Riu3DMainWindowTools.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonTools::selectPolygonInView( RimPolygon* polygon, caf::PdmObject* sourceObject ) +{ + auto polygonInView = findPolygonInView( polygon, sourceObject ); + if ( polygonInView ) + { + polygonInView->enablePicking( true ); + Riu3DMainWindowTools::selectAsCurrentItem( polygonInView ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimPolygonInView* RimPolygonTools::findPolygonInView( RimPolygon* polygon, caf::PdmObject* sourceObject ) +{ + if ( auto gridView = sourceObject->firstAncestorOfType() ) + { + auto polyCollection = gridView->polygonInViewCollection(); + + for ( auto polygonInView : polyCollection->polygonsInView() ) + { + if ( polygonInView && polygonInView->polygon() == polygon ) + { + return polygonInView; + } + } + } + + return nullptr; +} diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicAppendPointsToPolygonFilterFeature.h b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonTools.h similarity index 58% rename from ApplicationLibCode/Commands/WellPathCommands/RicAppendPointsToPolygonFilterFeature.h rename to ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonTools.h index 35cee0a6c5..e45826e4e8 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicAppendPointsToPolygonFilterFeature.h +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonTools.h @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2021- 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 @@ -18,17 +18,19 @@ #pragma once -#include "cafCmdFeature.h" +class RimPolygon; +class RimPolygonInView; -//================================================================================================== -/// -//================================================================================================== -class RicAppendPointsToPolygonFilterFeature : public caf::CmdFeature +namespace caf { - CAF_CMD_HEADER_INIT; +class PdmObject; +} -protected: - bool isCommandEnabled() const override; - void onActionTriggered( bool isChecked ) override; - void setupActionLook( QAction* actionToSetup ) override; +class RimPolygonTools +{ +public: + static void selectPolygonInView( RimPolygon* polygon, caf::PdmObject* sourceObject ); + +private: + static RimPolygonInView* findPolygonInView( RimPolygon* polygon, caf::PdmObject* sourceObject ); }; diff --git a/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp b/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp index eaba599751..dd450bd55a 100644 --- a/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp +++ b/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp @@ -51,7 +51,6 @@ #include "RimWellPathCollection.h" #include "RivAnnotationsPartMgr.h" -#include "RivCellFilterPartMgr.h" #include "RivMeasurementPartMgr.h" #include "RivWellPathsPartMgr.h" @@ -174,7 +173,6 @@ Rim3dView::Rim3dView() m_wellPathsPartManager = new RivWellPathsPartMgr( this ); m_annotationsPartManager = new RivAnnotationsPartMgr( this ); - m_cellfilterPartManager = new RivCellFilterPartMgr( this ); m_measurementPartManager = new RivMeasurementPartMgr( this ); this->setAs3DViewMdiWindow(); @@ -701,14 +699,12 @@ void Rim3dView::updateDisplayModelForCurrentTimeStepAndRedraw() this->onUpdateDisplayModelForCurrentTimeStep(); appendAnnotationsToModel(); appendMeasurementToModel(); - appendCellFiltersToModel(); if ( Rim3dView* depView = prepareComparisonView() ) { depView->onUpdateDisplayModelForCurrentTimeStep(); depView->appendAnnotationsToModel(); depView->appendMeasurementToModel(); - depView->appendCellFiltersToModel(); restoreComparisonView(); } @@ -1133,19 +1129,6 @@ void Rim3dView::addAnnotationsToModel( cvf::ModelBasicList* annotationsModel ) annotationsModel->updateBoundingBoxesRecursive(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void Rim3dView::addCellFiltersToModel( cvf::ModelBasicList* cellFilterModel ) -{ - if ( !this->ownerCase() ) return; - - cvf::ref transForm = displayCoordTransform(); - m_cellfilterPartManager->appendGeometryPartsToModel( cellFilterModel, transForm.p(), ownerCase()->allCellsBoundingBox() ); - - cellFilterModel->updateBoundingBoxesRecursive(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1716,28 +1699,6 @@ void Rim3dView::updateScreenSpaceModel() nativeOrOverrideViewer()->addStaticModelOnce( m_screenSpaceModel.p(), isUsingOverrideViewer() ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void Rim3dView::appendCellFiltersToModel() -{ - if ( !nativeOrOverrideViewer() ) return; - - cvf::Scene* frameScene = nativeOrOverrideViewer()->frame( m_currentTimeStep, isUsingOverrideViewer() ); - if ( frameScene ) - { - cvf::String name = "CellFilters"; - this->removeModelByName( frameScene, name ); - - cvf::ref model = new cvf::ModelBasicList; - model->setName( name ); - - addCellFiltersToModel( model.p() ); - - frameScene->addModel( model.p() ); - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Rim3dView.h b/ApplicationLibCode/ProjectDataModel/Rim3dView.h index e25459dacd..a193617c6a 100644 --- a/ApplicationLibCode/ProjectDataModel/Rim3dView.h +++ b/ApplicationLibCode/ProjectDataModel/Rim3dView.h @@ -52,7 +52,6 @@ class RiuViewer; class RivAnnotationsPartMgr; class RivMeasurementPartMgr; class RivWellPathsPartMgr; -class RivCellFilterPartMgr; class RimViewNameConfig; namespace cvf @@ -222,7 +221,6 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface, public double characteristicCellSize ); void addAnnotationsToModel( cvf::ModelBasicList* annotationsModel ); void addMeasurementToModel( cvf::ModelBasicList* measureModel ); - void addCellFiltersToModel( cvf::ModelBasicList* cellFilterModel ); // Override viewer @@ -311,7 +309,6 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface, public void createHighlightAndGridBoxDisplayModel(); void appendMeasurementToModel(); - void appendCellFiltersToModel(); void appendAnnotationsToModel(); void updateScreenSpaceModel(); @@ -349,7 +346,6 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface, public // 3D display model data cvf::ref m_annotationsPartManager; cvf::ref m_measurementPartManager; - cvf::ref m_cellfilterPartManager; // Timer for animations std::unique_ptr m_animationTimer; diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp index b5c413224d..d62cc93db5 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp @@ -650,9 +650,7 @@ void RimEclipseView::onCreateDisplayModel() } // Polygons - m_polygonVizModel->removeAllParts(); - m_polygonCollection->appendPartsToModel( m_polygonVizModel.p(), transform.p(), ownerCase()->allCellsBoundingBox() ); - nativeOrOverrideViewer()->addStaticModelOnce( m_polygonVizModel.p(), isUsingOverrideViewer() ); + appendPolygonPartsToModel( transform.p(), ownerCase()->allCellsBoundingBox() ); // Well path model m_wellPathPipeVizModel->removeAllParts(); @@ -1956,7 +1954,7 @@ void RimEclipseView::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrderin if ( RiaApplication::enableDevelopmentFeatures() ) { - uiTreeOrdering.add( m_polygonCollection ); + uiTreeOrdering.add( m_polygonInViewCollection ); } uiTreeOrdering.skipRemainingChildren( true ); diff --git a/ApplicationLibCode/ProjectDataModel/RimGridView.cpp b/ApplicationLibCode/ProjectDataModel/RimGridView.cpp index 98a57cd0d3..8b2c9a33cf 100644 --- a/ApplicationLibCode/ProjectDataModel/RimGridView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimGridView.cpp @@ -18,7 +18,6 @@ #include "RimGridView.h" -#include "Polygons/RimPolygonInViewCollection.h" #include "Rim3dOverlayInfoConfig.h" #include "RimCellFilterCollection.h" #include "RimEclipseCase.h" @@ -42,6 +41,9 @@ #include "RimWellMeasurementInViewCollection.h" #include "RimWellPathCollection.h" +#include "Polygons/RimPolygonInView.h" +#include "Polygons/RimPolygonInViewCollection.h" + #include "Riu3DMainWindowTools.h" #include "Riu3dSelectionManager.h" #include "RiuMainWindow.h" @@ -97,8 +99,8 @@ RimGridView::RimGridView() CAF_PDM_InitFieldNoDefault( &m_seismicSectionCollection, "SeismicSectionCollection", "Seismic Collection Field" ); m_seismicSectionCollection = new RimSeismicSectionCollection(); - CAF_PDM_InitFieldNoDefault( &m_polygonCollection, "PolygonCollection", "Polygon Collection Field" ); - m_polygonCollection = new RimPolygonInViewCollection(); + CAF_PDM_InitFieldNoDefault( &m_polygonInViewCollection, "PolygonInViewCollection", "Polygon Collection Field" ); + m_polygonInViewCollection = new RimPolygonInViewCollection(); CAF_PDM_InitFieldNoDefault( &m_cellFilterCollection, "RangeFilters", "Cell Filter Collection Field" ); m_cellFilterCollection = new RimCellFilterCollection(); @@ -171,9 +173,9 @@ RimSeismicSectionCollection* RimGridView::seismicSectionCollection() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimPolygonInViewCollection* RimGridView::polygonCollection() const +RimPolygonInViewCollection* RimGridView::polygonInViewCollection() const { - return m_polygonCollection(); + return m_polygonInViewCollection(); } //-------------------------------------------------------------------------------------------------- @@ -395,6 +397,36 @@ void RimGridView::onCreatePartCollectionFromSelection( cvf::CollectionremoveAllParts(); + + std::vector polygonsInView; + if ( m_polygonInViewCollection ) + { + polygonsInView = m_polygonInViewCollection->polygonsInView(); + } + + if ( cellFilterCollection() ) + { + auto cellFilterPolygonsInView = cellFilterCollection()->cellFilterPolygons(); + polygonsInView.insert( polygonsInView.end(), cellFilterPolygonsInView.begin(), cellFilterPolygonsInView.end() ); + } + + for ( RimPolygonInView* polygonInView : polygonsInView ) + { + if ( polygonInView ) + { + polygonInView->appendPartsToModel( m_polygonVizModel.p(), scaleTransform, boundingBox ); + } + } + + nativeOrOverrideViewer()->addStaticModelOnce( m_polygonVizModel.p(), isUsingOverrideViewer() ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -495,7 +527,7 @@ void RimGridView::updateViewTreeItems( RiaDefines::ItemIn3dView itemType ) if ( bitmaskEnum.AnyOf( RiaDefines::ItemIn3dView::POLYGON ) ) { - m_polygonCollection->syncPolygonsInView(); + m_polygonInViewCollection->syncPolygonsInView(); } updateConnectedEditors(); diff --git a/ApplicationLibCode/ProjectDataModel/RimGridView.h b/ApplicationLibCode/ProjectDataModel/RimGridView.h index 203f7e9100..e7132010c8 100644 --- a/ApplicationLibCode/ProjectDataModel/RimGridView.h +++ b/ApplicationLibCode/ProjectDataModel/RimGridView.h @@ -55,7 +55,7 @@ class RimGridView : public Rim3dView RimIntersectionResultsDefinitionCollection* separateSurfaceResultsCollection() const; RimWellMeasurementInViewCollection* measurementCollection() const; RimSeismicSectionCollection* seismicSectionCollection() const; - RimPolygonInViewCollection* polygonCollection() const; + RimPolygonInViewCollection* polygonInViewCollection() const; virtual const RimPropertyFilterCollection* propertyFilterCollection() const = 0; @@ -80,6 +80,7 @@ class RimGridView : public Rim3dView RimGridCollection* gridCollection() const; void clearReservoirCellVisibilities(); void addRequiredUiTreeObjects( caf::PdmUiTreeOrdering& uiTreeOrdering ); + void appendPolygonPartsToModel( caf::DisplayCoordTransform* scaleTransform, const cvf::BoundingBox& boundingBox ); void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void initAfterRead() override; @@ -107,11 +108,12 @@ class RimGridView : public Rim3dView caf::PdmChildField m_cellFilterCollection; caf::PdmChildField m_overrideCellFilterCollection; caf::PdmChildField m_seismicSectionCollection; - caf::PdmChildField m_polygonCollection; + caf::PdmChildField m_polygonInViewCollection; private: void onCreatePartCollectionFromSelection( cvf::Collection* parts ) override; +private: cvf::ref m_currentReservoirCellVisibility; bool m_previousGridModeMeshLinesWasFaults; }; diff --git a/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.cpp b/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.cpp index b039bc681b..8c04d6124c 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.cpp @@ -20,6 +20,14 @@ #include "RimPolylineTarget.h" +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimPolylinePickerInterface::scalingFactorForTarget() const +{ + return 1.0; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.h b/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.h index 6210db7832..7dc6b61a9a 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.h +++ b/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.h @@ -38,6 +38,7 @@ class RimPolylinePickerInterface virtual std::vector activeTargets() const = 0; virtual bool pickingEnabled() const = 0; virtual caf::PickEventHandler* pickEventHandler() const = 0; + virtual double scalingFactorForTarget() const; std::pair findActiveTargetsAroundInsertionPoint( const RimPolylineTarget* targetToInsertBefore ); };