diff --git a/.github/workflows/ResInsightWithCache.yml b/.github/workflows/ResInsightWithCache.yml index 1d45d0c2bb..7c83bd0a88 100644 --- a/.github/workflows/ResInsightWithCache.yml +++ b/.github/workflows/ResInsightWithCache.yml @@ -87,7 +87,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -r GrpcInterface/Python/requirements.txt + pip install -r GrpcInterface/Python/dev-requirements.txt - name: Use CMake uses: lukka/get-cmake@latest diff --git a/ApplicationExeCode/Resources/ResInsight.qrc b/ApplicationExeCode/Resources/ResInsight.qrc index 32ff262ffc..1a1b8b97d9 100644 --- a/ApplicationExeCode/Resources/ResInsight.qrc +++ b/ApplicationExeCode/Resources/ResInsight.qrc @@ -277,14 +277,15 @@ SeismicDelta16x16.png SeismicView16x16.png SeismicView24x24.png - SeismicViews24x24.png - SeismicData24x24.png - SeismicSection16x16.png - Fullscreen.png + SeismicViews24x24.png + SeismicData24x24.png + SeismicSection16x16.png + Fullscreen.png plot-template-standard.svg plot-template-ensemble.svg decline-curve.svg regression-curve.svg + padlock.svg fs_CellFace.glsl diff --git a/ApplicationExeCode/Resources/padlock.svg b/ApplicationExeCode/Resources/padlock.svg new file mode 100644 index 0000000000..5009f6cebf --- /dev/null +++ b/ApplicationExeCode/Resources/padlock.svg @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/ApplicationExeCode/RiaMain.cpp b/ApplicationExeCode/RiaMain.cpp index 700114d1cc..b8d35b48c2 100644 --- a/ApplicationExeCode/RiaMain.cpp +++ b/ApplicationExeCode/RiaMain.cpp @@ -48,7 +48,7 @@ RiaApplication* createApplication( int& argc, char* argv[] ) { for ( int i = 1; i < argc; ++i ) { - if ( !qstrcmp( argv[i], "--console" ) || !qstrcmp( argv[i], "--unittest" ) || !qstrcmp( argv[i], "--version" ) ) + if ( !qstrcmp( argv[i], "--console" ) || !qstrcmp( argv[i], "--unittest" ) ) { #ifdef ENABLE_GRPC return new RiaGrpcConsoleApplication( argc, argv ); diff --git a/ApplicationLibCode/Adm/RiaVersionInfo.h.cmake b/ApplicationLibCode/Adm/RiaVersionInfo.h.cmake index 5cdacb8332..8e2910f76a 100644 --- a/ApplicationLibCode/Adm/RiaVersionInfo.h.cmake +++ b/ApplicationLibCode/Adm/RiaVersionInfo.h.cmake @@ -34,3 +34,5 @@ #define RESINSIGHT_OCTAVE_VERSION "@OCTAVE_VERSION_STRING@" #define RESINSIGHT_PYTHON_VERSION "@Python3_VERSION@" + +#define RESINSIGHT_GIT_HASH "@RESINSIGHT_GIT_HASH@" \ No newline at end of file diff --git a/ApplicationLibCode/Application/RiaApplication.cpp b/ApplicationLibCode/Application/RiaApplication.cpp index 478566d908..7bef9598e1 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(); } { @@ -658,7 +662,10 @@ bool RiaApplication::loadProject( const QString& projectFileName, ProjectLoadAct } } - setActiveReservoirView( riv ); + if ( riv->showWindow() ) + { + setActiveReservoirView( riv ); + } RimGridView* rigv = dynamic_cast( riv ); if ( rigv ) rigv->cellFilterCollection()->updateIconState(); diff --git a/ApplicationLibCode/Application/RiaConsoleApplication.cpp b/ApplicationLibCode/Application/RiaConsoleApplication.cpp index 1e3c85c51e..97a4b8b88b 100644 --- a/ApplicationLibCode/Application/RiaConsoleApplication.cpp +++ b/ApplicationLibCode/Application/RiaConsoleApplication.cpp @@ -131,6 +131,7 @@ RiaApplication::ApplicationStatus RiaConsoleApplication::handleArguments( gsl::n if ( progOpt->option( "version" ) ) { QString text = QString( STRPRODUCTVER ) + "\n"; + text += "SHA " + QString( RESINSIGHT_GIT_HASH ) + "\n"; showFormattedTextInMessageBoxOrConsole( text ); 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/Application/RiaGuiApplication.cpp b/ApplicationLibCode/Application/RiaGuiApplication.cpp index 1a51c974df..461e99ec54 100644 --- a/ApplicationLibCode/Application/RiaGuiApplication.cpp +++ b/ApplicationLibCode/Application/RiaGuiApplication.cpp @@ -463,6 +463,16 @@ RiaApplication::ApplicationStatus RiaGuiApplication::handleArguments( gsl::not_n return RiaApplication::ApplicationStatus::EXIT_COMPLETED; } + if ( progOpt->option( "version" ) ) + { + QString text = QString( STRPRODUCTVER ) + "\n"; + text += "SHA " + QString( RESINSIGHT_GIT_HASH ) + "\n"; + + showFormattedTextInMessageBoxOrConsole( text ); + + return RiaApplication::ApplicationStatus::EXIT_COMPLETED; + } + // Code generation // ----------------- if ( cvf::Option o = progOpt->option( "generate" ) ) diff --git a/ApplicationLibCode/Application/RiaMemoryCleanup.cpp b/ApplicationLibCode/Application/RiaMemoryCleanup.cpp index ee5d5bf64a..d72e85f2a0 100644 --- a/ApplicationLibCode/Application/RiaMemoryCleanup.cpp +++ b/ApplicationLibCode/Application/RiaMemoryCleanup.cpp @@ -59,10 +59,10 @@ RiaMemoryCleanup::RiaMemoryCleanup() m_resultsToDelete.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); CAF_PDM_InitFieldNoDefault( &m_performDelete, "ClearSelectedData", "" ); - caf::PdmUiPushButtonEditor::configureEditorForField( &m_performDelete ); + caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_performDelete ); CAF_PDM_InitFieldNoDefault( &m_showMemoryReport, "ShowMemoryReport", "" ); - caf::PdmUiPushButtonEditor::configureEditorForField( &m_showMemoryReport ); + caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_showMemoryReport ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/RiaPreferencesSummary.cpp b/ApplicationLibCode/Application/RiaPreferencesSummary.cpp index 9983ba5364..ae0b493ff3 100644 --- a/ApplicationLibCode/Application/RiaPreferencesSummary.cpp +++ b/ApplicationLibCode/Application/RiaPreferencesSummary.cpp @@ -121,8 +121,7 @@ RiaPreferencesSummary::RiaPreferencesSummary() "" ); CAF_PDM_InitField( &m_selectDefaultTemplates, "selectDefaultTemplate", false, "", "", "Select Default Templates" ); - m_selectDefaultTemplates.xmlCapability()->disableIO(); - m_selectDefaultTemplates.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_selectDefaultTemplates ); CAF_PDM_InitFieldNoDefault( &m_selectedDefaultTemplates, "defaultSummaryTemplates", "Select Summary Plot Templates" ); m_selectedDefaultTemplates.uiCapability()->setUiReadOnly( true ); diff --git a/ApplicationLibCode/Application/RiaResultNames.cpp b/ApplicationLibCode/Application/RiaResultNames.cpp index 9752c9ff31..cac4338ada 100644 --- a/ApplicationLibCode/Application/RiaResultNames.cpp +++ b/ApplicationLibCode/Application/RiaResultNames.cpp @@ -595,5 +595,9 @@ std::vector RiaResultNames::wbsDerivedResultNames() wbsSHMkMaxResult(), wbsFGMkExpResult(), wbsFGMkMinResult(), + wbsPPMinResult(), + wbsPPMaxResult(), + wbsPPExpResult(), + wbsPPInitialResult(), }; } 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/CellFilterCommands/RicNewPolygonFilter3dviewFeature.cpp b/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilter3dviewFeature.cpp index 52db3a8110..def2a95673 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" @@ -46,7 +48,7 @@ void RicNewPolygonFilter3dviewFeature::onActionTriggered( bool isChecked ) // and the case to use RimCase* sourceCase = viewOrComparisonView->ownerCase(); - RimPolygonFilter* lastCreatedOrUpdated = filtColl->addNewPolygonFilter( sourceCase ); + RimPolygonFilter* lastCreatedOrUpdated = filtColl->addNewPolygonFilter( sourceCase, nullptr ); if ( lastCreatedOrUpdated ) { Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated ); diff --git a/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.cpp b/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.cpp index 4e8ba926b2..8ffa493ef8 100644 --- a/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.cpp +++ b/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.cpp @@ -18,9 +18,16 @@ #include "RicNewPolygonFilterFeature.h" +#include "RiaApplication.h" + +#include "Polygons/RimPolygon.h" +#include "Polygons/RimPolygonInView.h" + #include "RimCase.h" #include "RimCellFilterCollection.h" +#include "RimGridView.h" #include "RimPolygonFilter.h" + #include "Riu3DMainWindowTools.h" #include "cafSelectionManagerTools.h" @@ -35,16 +42,31 @@ CAF_CMD_SOURCE_INIT( RicNewPolygonFilterFeature, "RicNewPolygonFilterFeature" ); //-------------------------------------------------------------------------------------------------- void RicNewPolygonFilterFeature::onActionTriggered( bool isChecked ) { - // Find the selected Cell Filter Collection - std::vector colls = caf::selectedObjectsByTypeStrict(); - if ( colls.empty() ) return; - RimCellFilterCollection* filtColl = colls[0]; + auto cellFilterCollection = caf::SelectionManager::instance()->selectedItemOfType(); - // and the case to use - RimCase* sourceCase = filtColl->firstAncestorOrThisOfTypeAsserted(); + if ( !cellFilterCollection ) + { + RimGridView* activeView = RiaApplication::instance()->activeMainOrComparisonGridView(); + if ( activeView ) + { + cellFilterCollection = activeView->cellFilterCollection(); + } + } - RimPolygonFilter* lastCreatedOrUpdated = filtColl->addNewPolygonFilter( sourceCase ); - if ( lastCreatedOrUpdated ) + if ( !cellFilterCollection ) return; + + auto polygon = caf::SelectionManager::instance()->selectedItemOfType(); + if ( !polygon ) + { + if ( auto polygonInView = caf::SelectionManager::instance()->selectedItemOfType() ) + { + polygon = polygonInView->polygon(); + } + } + + auto sourceCase = cellFilterCollection->firstAncestorOrThisOfTypeAsserted(); + + if ( auto lastCreatedOrUpdated = cellFilterCollection->addNewPolygonFilter( sourceCase, polygon ) ) { Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated ); } diff --git a/ApplicationLibCode/Commands/CrossSectionCommands/CMakeLists_files.cmake b/ApplicationLibCode/Commands/CrossSectionCommands/CMakeLists_files.cmake index d1a18ed21d..bb0d00bef9 100644 --- a/ApplicationLibCode/Commands/CrossSectionCommands/CMakeLists_files.cmake +++ b/ApplicationLibCode/Commands/CrossSectionCommands/CMakeLists_files.cmake @@ -6,6 +6,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RicNewPolylineIntersectionFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicNewAzimuthDipIntersectionFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicCopyIntersectionsToAllViewsInCaseFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicNewPolygonIntersectionFeature.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -16,6 +17,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RicNewPolylineIntersectionFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewAzimuthDipIntersectionFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicCopyIntersectionsToAllViewsInCaseFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicNewPolygonIntersectionFeature.cpp ) list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) diff --git a/ApplicationLibCode/Commands/CrossSectionCommands/RicNewPolygonIntersectionFeature.cpp b/ApplicationLibCode/Commands/CrossSectionCommands/RicNewPolygonIntersectionFeature.cpp new file mode 100644 index 0000000000..3ee2f4e7a3 --- /dev/null +++ b/ApplicationLibCode/Commands/CrossSectionCommands/RicNewPolygonIntersectionFeature.cpp @@ -0,0 +1,68 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicNewPolygonIntersectionFeature.h" + +#include "RiaApplication.h" + +#include "RimExtrudedCurveIntersection.h" +#include "RimGridView.h" +#include "RimIntersectionCollection.h" + +#include "Polygons/RimPolygon.h" +#include "Polygons/RimPolygonInView.h" + +#include "cafSelectionManager.h" + +#include + +CAF_CMD_SOURCE_INIT( RicNewPolygonIntersectionFeature, "RicNewPolygonIntersectionFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewPolygonIntersectionFeature::onActionTriggered( bool isChecked ) +{ + RimGridView* activeView = RiaApplication::instance()->activeMainOrComparisonGridView(); + if ( !activeView ) return; + + auto collection = activeView->intersectionCollection(); + if ( !collection ) return; + + auto polygon = caf::SelectionManager::instance()->selectedItemOfType(); + if ( !polygon ) + { + if ( auto polygonInView = caf::SelectionManager::instance()->selectedItemOfType() ) + { + polygon = polygonInView->polygon(); + } + } + + auto intersection = new RimExtrudedCurveIntersection(); + intersection->configureForProjectPolyLine( polygon ); + collection->appendIntersectionAndUpdate( intersection ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewPolygonIntersectionFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setIcon( QIcon( ":/CrossSection16x16.png" ) ); + actionToSetup->setText( "Create Polygon Intersection" ); +} diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicAppendPointsToPolygonFilterFeature.h b/ApplicationLibCode/Commands/CrossSectionCommands/RicNewPolygonIntersectionFeature.h similarity index 88% rename from ApplicationLibCode/Commands/WellPathCommands/RicAppendPointsToPolygonFilterFeature.h rename to ApplicationLibCode/Commands/CrossSectionCommands/RicNewPolygonIntersectionFeature.h index 35cee0a6c5..f06741ab06 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicAppendPointsToPolygonFilterFeature.h +++ b/ApplicationLibCode/Commands/CrossSectionCommands/RicNewPolygonIntersectionFeature.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 @@ -23,12 +23,11 @@ //================================================================================================== /// //================================================================================================== -class RicAppendPointsToPolygonFilterFeature : public caf::CmdFeature +class RicNewPolygonIntersectionFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; protected: - bool isCommandEnabled() const override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; }; diff --git a/ApplicationLibCode/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..3c061583d2 --- /dev/null +++ b/ApplicationLibCode/Commands/PolygonCommands/RicNewPolygonFileFeature.cpp @@ -0,0 +1,57 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 "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/Commands/RicUserDefinedCalculatorUi.cpp b/ApplicationLibCode/Commands/RicUserDefinedCalculatorUi.cpp index 771f36f912..af596fcd5c 100644 --- a/ApplicationLibCode/Commands/RicUserDefinedCalculatorUi.cpp +++ b/ApplicationLibCode/Commands/RicUserDefinedCalculatorUi.cpp @@ -91,7 +91,9 @@ bool RicUserDefinedCalculatorUi::parseExpression() const notifyCalculatedNameChanged( m_currentCalculation()->id(), currentCurveName ); } - m_currentCalculation()->updateDependentObjects(); + // Always rebuild the case meta data after parsing the expression. A change in name or change in result type will require rebuild of + // case metadata. The rebuild is considered lightweight and should not be a performance issue. + calculationCollection()->rebuildCaseMetaData(); } return true; @@ -198,8 +200,7 @@ void RicUserDefinedCalculatorUi::assignPushButtonEditor( caf::PdmFieldHandle* fi CAF_ASSERT( fieldHandle ); CAF_ASSERT( fieldHandle->uiCapability() ); - fieldHandle->uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); - fieldHandle->uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( fieldHandle ); } //-------------------------------------------------------------------------------------------------- @@ -221,17 +222,7 @@ bool RicUserDefinedCalculatorUi::calculate() const { if ( m_currentCalculation() ) { - QString previousCurveName = m_currentCalculation->description(); - if ( !m_currentCalculation()->parseExpression() ) - { - return false; - } - - QString currentCurveName = m_currentCalculation->description(); - if ( previousCurveName != currentCurveName ) - { - notifyCalculatedNameChanged( m_currentCalculation()->id(), currentCurveName ); - } + if ( !parseExpression() ) return false; if ( !m_currentCalculation()->preCalculate() ) { diff --git a/ApplicationLibCode/Commands/SeismicCommands/RicSeismicSectionFromIntersectionFeature.cpp b/ApplicationLibCode/Commands/SeismicCommands/RicSeismicSectionFromIntersectionFeature.cpp index 445ead3336..180db89511 100644 --- a/ApplicationLibCode/Commands/SeismicCommands/RicSeismicSectionFromIntersectionFeature.cpp +++ b/ApplicationLibCode/Commands/SeismicCommands/RicSeismicSectionFromIntersectionFeature.cpp @@ -47,6 +47,7 @@ bool RicSeismicSectionFromIntersectionFeature::isCommandEnabled() const if ( intersection != nullptr ) { return ( ( intersection->type() == RimExtrudedCurveIntersection::CrossSectionEnum::CS_POLYLINE ) || + ( intersection->type() == RimExtrudedCurveIntersection::CrossSectionEnum::CS_POLYGON ) || ( intersection->type() == RimExtrudedCurveIntersection::CrossSectionEnum::CS_WELL_PATH ) ); } @@ -70,7 +71,8 @@ void RicSeismicSectionFromIntersectionFeature::onActionTriggered( bool isChecked RimSeismicSection* newSection = seisColl->addNewSection(); if ( !newSection ) return; - if ( intersection->type() == RimExtrudedCurveIntersection::CrossSectionEnum::CS_POLYLINE ) + if ( ( intersection->type() == RimExtrudedCurveIntersection::CrossSectionEnum::CS_POLYLINE ) || + ( intersection->type() == RimExtrudedCurveIntersection::CrossSectionEnum::CS_POLYGON ) ) { newSection->setSectionType( RiaDefines::SeismicSectionType::SS_POLYLINE ); newSection->setUserDescription( intersection->name() ); diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp index e8b7d53233..b7f465dfc0 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp @@ -56,6 +56,7 @@ #include "cafProgressInfo.h" #include "cafSelectionManager.h" #include "cvfAssert.h" +#include "cvfColor3.h" #include "cvfMath.h" #include @@ -63,6 +64,7 @@ #include #include +#include CAF_CMD_SOURCE_INIT( RicNewWellBoreStabilityPlotFeature, "RicNewWellBoreStabilityPlotFeature" ); @@ -262,7 +264,7 @@ void RicNewWellBoreStabilityPlotFeature::createParametersTrack( RimWellBoreStabi paramCurvesTrack->setFormationCase( geoMechCase ); paramCurvesTrack->setShowRegionLabels( true ); paramCurvesTrack->setShowWindow( false ); - std::set parameters = RigWbsParameter::allParameters(); + std::set parameters = parametersForTrack(); caf::ColorTable colors = RiaColorTables::contrastCategoryPaletteColors(); std::vector lineStyles = { RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID, @@ -321,6 +323,15 @@ void RicNewWellBoreStabilityPlotFeature::createStabilityCurvesTrack( RimWellBore std::vector lineStyles( resultNames.size(), RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID ); lineStyles.back() = RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_DASH; + std::set defaultOffResults = { + RiaResultNames::wbsSHMkResult(), + RiaResultNames::wbsSHMkExpResult(), + RiaResultNames::wbsSHMkMinResult(), + RiaResultNames::wbsSHMkMaxResult(), + RiaResultNames::wbsFGMkExpResult(), + RiaResultNames::wbsFGMkMinResult(), + }; + for ( size_t i = 0; i < resultNames.size(); ++i ) { const QString& resultName = resultNames[i]; @@ -330,13 +341,14 @@ void RicNewWellBoreStabilityPlotFeature::createStabilityCurvesTrack( RimWellBore curve->setGeoMechResultAddress( resAddr ); curve->setCurrentTimeStep( timeStep ); curve->setAutoNameComponents( false, true, false, false, false ); - curve->setColor( colors[i % colors.size()] ); - curve->setLineStyle( lineStyles[i] ); + auto [color, lineStyle] = getColorAndLineStyle( resultName, i, colors ); + curve->setColor( color ); + curve->setLineStyle( lineStyle ); curve->setLineThickness( 2 ); curve->loadDataAndUpdate( false ); curve->setSmoothCurve( true ); curve->setSmoothingThreshold( 0.002 ); - if ( resultNames[i] == RiaResultNames::wbsSHMkResult() ) + if ( defaultOffResults.count( resultNames[i] ) ) { curve->setCheckState( false ); } @@ -361,6 +373,34 @@ void RicNewWellBoreStabilityPlotFeature::createStabilityCurvesTrack( RimWellBore stabilityCurvesTrack->setAutoScalePropertyValuesEnabled( true ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair + RicNewWellBoreStabilityPlotFeature::getColorAndLineStyle( const QString& resultName, size_t i, const std::vector& colors ) +{ + if ( resultName == RiaResultNames::wbsSHMkResult() ) return { cvf::Color3f::GREEN, RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID }; + if ( resultName == RiaResultNames::wbsSHMkExpResult() ) + return { cvf::Color3f::GREEN, RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_DASH }; + if ( resultName == RiaResultNames::wbsSHMkMinResult() ) + return { cvf::Color3f::GREEN, RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_DOT }; + if ( resultName == RiaResultNames::wbsSHMkMaxResult() ) + return { cvf::Color3f::GREEN, RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_DASH_DOT }; + + if ( resultName == RiaResultNames::wbsFGMkExpResult() ) + return { cvf::Color3f::BLUE, RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_DASH }; + if ( resultName == RiaResultNames::wbsFGMkMinResult() ) return { cvf::Color3f::BLUE, RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_DOT }; + + if ( resultName == RiaResultNames::wbsPPInitialResult() ) + return { cvf::Color3f::RED, RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID }; + if ( resultName == RiaResultNames::wbsPPExpResult() ) return { cvf::Color3f::RED, RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_DASH }; + if ( resultName == RiaResultNames::wbsPPMinResult() ) return { cvf::Color3f::RED, RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_DOT }; + if ( resultName == RiaResultNames::wbsPPMaxResult() ) + return { cvf::Color3f::RED, RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_DASH_DOT }; + + return { colors[i % colors.size()], RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID }; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -408,3 +448,22 @@ void RicNewWellBoreStabilityPlotFeature::createAnglesTrack( RimWellBoreStability wellPathAnglesTrack->setAnnotationDisplay( RiaDefines::LIGHT_LINES ); wellPathAnglesTrack->setShowRegionLabels( false ); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::set RicNewWellBoreStabilityPlotFeature::parametersForTrack() +{ + return { RigWbsParameter::PP_Reservoir(), + RigWbsParameter::PP_NonReservoir(), + RigWbsParameter::poissonRatio(), + RigWbsParameter::UCS(), + RigWbsParameter::OBG(), + RigWbsParameter::OBG0(), + RigWbsParameter::SH(), + RigWbsParameter::DF(), + RigWbsParameter::K0_FG(), + RigWbsParameter::K0_SH(), + RigWbsParameter::FG_Shale(), + RigWbsParameter::waterDensity() }; +} diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.h b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.h index e9fd749ae0..9fc6dd4162 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.h +++ b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.h @@ -20,6 +20,14 @@ #include "cafCmdFeature.h" +#include "RigWbsParameter.h" + +#include "RimPlotCurveAppearance.h" + +#include "cvfColor3.h" + +#include + class RimGeoMechCase; class RimGeoMechView; class RimWbsParameters; @@ -48,4 +56,8 @@ private: static void createParametersTrack( RimWellBoreStabilityPlot* plot, RimWellPath* wellPath, RimGeoMechCase* geoMechCase, int timeStep ); static void createStabilityCurvesTrack( RimWellBoreStabilityPlot* plot, RimWellPath* wellPath, RimGeoMechCase* geoMechCase, int timeStep ); static void createAnglesTrack( RimWellBoreStabilityPlot* plot, RimWellPath* wellPath, RimGeoMechCase* geoMechCase, int timeStep ); + + static std::set parametersForTrack(); + static std::pair + getColorAndLineStyle( const QString& resultName, size_t i, const std::vector& colors ); }; 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/RicPolyline3dEditor.cpp b/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicPolyline3dEditor.cpp index f67db7f3ff..2c0c094dd0 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicPolyline3dEditor.cpp +++ b/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicPolyline3dEditor.cpp @@ -62,7 +62,7 @@ void RicPolyline3dEditor::configureAndUpdateUi( const QString& uiConfigName ) } m_targetEditors.clear(); - if ( !pickerInterface ) return; + if ( !pickerInterface || !pickerInterface->pickEventHandler() ) return; if ( pickerInterface->pickingEnabled() ) { diff --git a/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicPolylineTarget3dEditor.cpp b/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicPolylineTarget3dEditor.cpp index 4c1860e278..6bf4a98b48 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicPolylineTarget3dEditor.cpp +++ b/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicPolylineTarget3dEditor.cpp @@ -21,10 +21,8 @@ #include "RicPointTangentManipulator.h" #include "Rim3dView.h" -#include "RimAnnotationCollectionBase.h" -#include "RimCase.h" +#include "RimPolylinePickerInterface.h" #include "RimPolylineTarget.h" -#include "RimUserDefinedPolylinesAnnotation.h" #include "RiuViewer.h" @@ -57,7 +55,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 +69,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 +95,17 @@ 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(); + + 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->setTangent(target->tangent()); m_manipulator->setHandleSize( handleSize ); m_cvfModel->removeAllParts(); m_manipulator->appendPartsToModel( m_cvfModel.p() ); @@ -114,7 +118,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 +130,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 +144,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 +152,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 +166,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/Commands/WellPathCommands/RicAppendPointsToPolygonFilterFeature.cpp b/ApplicationLibCode/Commands/WellPathCommands/RicAppendPointsToPolygonFilterFeature.cpp deleted file mode 100644 index 05908fcacd..0000000000 --- a/ApplicationLibCode/Commands/WellPathCommands/RicAppendPointsToPolygonFilterFeature.cpp +++ /dev/null @@ -1,83 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2021- Equinor ASA -// -// ResInsight is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY -// WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. -// -// See the GNU General Public License at -// for more details. -// -///////////////////////////////////////////////////////////////////////////////// - -#include "RicAppendPointsToPolygonFilterFeature.h" - -#include "RiaTextStringTools.h" - -#include "RimPolygonFilter.h" -#include "RimPolylineTarget.h" - -#include "OperationsUsingObjReferences/RicPasteFeatureImpl.h" - -#include "cafSelectionManager.h" -#include "cafSelectionManagerTools.h" - -#include -#include - -CAF_CMD_SOURCE_INIT( RicAppendPointsToPolygonFilterFeature, "RicAppendPointsToPolygonFilterFeature" ); - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RicAppendPointsToPolygonFilterFeature::isCommandEnabled() const -{ - auto obj = caf::firstAncestorOfTypeFromSelectedObject(); - return obj != nullptr; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicAppendPointsToPolygonFilterFeature::onActionTriggered( bool isChecked ) -{ - auto polygonFilter = caf::firstAncestorOfTypeFromSelectedObject(); - if ( !polygonFilter ) return; - - QStringList listOfThreeDoubles; - - QClipboard* clipboard = QApplication::clipboard(); - if ( clipboard ) - { - QString content = clipboard->text(); - listOfThreeDoubles = RiaTextStringTools::splitSkipEmptyParts( content, "\n" ); - } - - std::vector points; - caf::PdmValueFieldSpecialization>::setFromVariant( listOfThreeDoubles, points ); - - for ( const auto& p : points ) - { - auto newTarget = new RimPolylineTarget; - newTarget->setAsPointTargetXYD( p ); - polygonFilter->insertTarget( nullptr, newTarget ); - } - - polygonFilter->updateEditorsAndVisualization(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicAppendPointsToPolygonFilterFeature::setupActionLook( QAction* actionToSetup ) -{ - actionToSetup->setText( "Append Points from Clipboard" ); - - RicPasteFeatureImpl::setIconAndShortcuts( actionToSetup ); -} diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicCreateWellTargetsPickEventHandler.cpp b/ApplicationLibCode/Commands/WellPathCommands/RicCreateWellTargetsPickEventHandler.cpp index 6925f3e03e..69b73bd1cd 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicCreateWellTargetsPickEventHandler.cpp +++ b/ApplicationLibCode/Commands/WellPathCommands/RicCreateWellTargetsPickEventHandler.cpp @@ -18,9 +18,6 @@ #include "RicCreateWellTargetsPickEventHandler.h" -#include "RiaGuiApplication.h" -#include "RiaOffshoreSphericalCoords.h" - #include "RigFemPart.h" #include "RigFemPartCollection.h" #include "RigFemPartGrid.h" @@ -30,6 +27,7 @@ #include "RigWellPathGeometryTools.h" #include "Rim3dView.h" +#include "RimCase.h" #include "RimEclipseView.h" #include "RimGeoMechView.h" #include "RimModeledWellPath.h" @@ -47,10 +45,6 @@ #include "cafDisplayCoordTransform.h" #include "cafSelectionManager.h" -#include "cvfStructGridGeometryGenerator.h" - -#include - #include //-------------------------------------------------------------------------------------------------- @@ -130,7 +124,14 @@ bool RicCreateWellTargetsPickEventHandler::handle3dPickEvent( const Ric3dPickEve doSetAzimuthAndInclination = false; cvf::Vec3d domainRayOrigin = rimView->displayCoordTransform()->transformToDomainCoord( firstPickItem.globalRayOrigin() ); - cvf::Vec3d domainRayEnd = targetPointInDomain + ( targetPointInDomain - domainRayOrigin ); + + auto rayVector = ( targetPointInDomain - domainRayOrigin ); + const double minimumRayLength = rimView->ownerCase()->characteristicCellSize() * 2; + if ( rayVector.length() < minimumRayLength ) + { + rayVector = rayVector.getNormalized() * minimumRayLength; + } + cvf::Vec3d domainRayEnd = targetPointInDomain + rayVector; cvf::Vec3d hexElementIntersection = findHexElementIntersection( rimView, firstPickItem, domainRayOrigin, domainRayEnd ); CVF_TIGHT_ASSERT( !hexElementIntersection.isUndefined() ); @@ -255,22 +256,27 @@ cvf::Vec3d RicCreateWellTargetsPickEventHandler::findHexElementIntersection( gsl { std::vector intersectionInfo; RigHexIntersectionTools::lineHexCellIntersection( domainRayOrigin, domainRayEnd, cornerVertices.data(), cellIndex, &intersectionInfo ); - if ( !intersectionInfo.empty() ) + + if ( intersectionInfo.empty() ) return cvf::Vec3d::UNDEFINED; + + if ( intersectionInfo.size() == 1 ) { - // Sort intersection on distance to ray origin - CVF_ASSERT( intersectionInfo.size() > 1 ); - std::sort( intersectionInfo.begin(), - intersectionInfo.end(), - [&domainRayOrigin]( const HexIntersectionInfo& lhs, const HexIntersectionInfo& rhs ) { - return ( lhs.m_intersectionPoint - domainRayOrigin ).lengthSquared() < - ( rhs.m_intersectionPoint - domainRayOrigin ).lengthSquared(); - } ); - const double eps = 1.0e-2; - cvf::Vec3d intersectionRay = intersectionInfo.back().m_intersectionPoint - intersectionInfo.front().m_intersectionPoint; - cvf::Vec3d newPoint = intersectionInfo.front().m_intersectionPoint + intersectionRay * eps; - CVF_ASSERT( RigHexIntersectionTools::isPointInCell( newPoint, cornerVertices.data() ) ); - return newPoint; + return intersectionInfo.front().m_intersectionPoint; } + + // Sort intersection on distance to ray origin + std::sort( intersectionInfo.begin(), + intersectionInfo.end(), + [&domainRayOrigin]( const HexIntersectionInfo& lhs, const HexIntersectionInfo& rhs ) { + return ( lhs.m_intersectionPoint - domainRayOrigin ).lengthSquared() < + ( rhs.m_intersectionPoint - domainRayOrigin ).lengthSquared(); + } ); + const double eps = 1.0e-2; + cvf::Vec3d intersectionRay = intersectionInfo.back().m_intersectionPoint - intersectionInfo.front().m_intersectionPoint; + cvf::Vec3d newPoint = intersectionInfo.front().m_intersectionPoint + intersectionRay * eps; + CVF_ASSERT( RigHexIntersectionTools::isPointInCell( newPoint, cornerVertices.data() ) ); + return newPoint; } + return cvf::Vec3d::UNDEFINED; } diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicIntersectionPickEventHandler.cpp b/ApplicationLibCode/Commands/WellPathCommands/RicIntersectionPickEventHandler.cpp index bcdb1233c1..b699df4383 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicIntersectionPickEventHandler.cpp +++ b/ApplicationLibCode/Commands/WellPathCommands/RicIntersectionPickEventHandler.cpp @@ -44,44 +44,41 @@ bool RicIntersectionPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& e std::vector selection; caf::SelectionManager::instance()->objectsByType( &selection ); - if ( selection.size() == 1 ) + if ( selection.size() != 1 ) return false; + + RimExtrudedCurveIntersection* intersection = selection[0]; + + RimGridView* gridView = intersection->firstAncestorOrThisOfTypeAsserted(); + + if ( RiaApplication::instance()->activeMainOrComparisonGridView() != gridView ) { - { - RimExtrudedCurveIntersection* intersection = selection[0]; + return false; + } - RimGridView* gridView = intersection->firstAncestorOrThisOfTypeAsserted(); + cvf::ref transForm = gridView->displayCoordTransform(); - if ( RiaApplication::instance()->activeMainOrComparisonGridView() != gridView ) - { - return false; - } + cvf::Vec3d domainCoord = transForm->transformToDomainCoord( eventObject.m_pickItemInfos.front().globalPickedPoint() ); - cvf::ref transForm = gridView->displayCoordTransform(); + if ( intersection->inputPolyLineFromViewerEnabled() ) + { + intersection->appendPointToPolyLine( domainCoord ); - cvf::Vec3d domainCoord = transForm->transformToDomainCoord( eventObject.m_pickItemInfos.front().globalPickedPoint() ); + // Further Ui processing is stopped when true is returned + return true; + } + else if ( intersection->inputExtrusionPointsFromViewerEnabled() ) + { + intersection->appendPointToExtrusionDirection( domainCoord ); - if ( intersection->inputPolyLineFromViewerEnabled() ) - { - intersection->appendPointToPolyLine( domainCoord ); + // Further Ui processing is stopped when true is returned + return true; + } + else if ( intersection->inputTwoAzimuthPointsFromViewerEnabled() ) + { + intersection->appendPointToAzimuthLine( domainCoord ); - // Further Ui processing is stopped when true is returned - return true; - } - else if ( intersection->inputExtrusionPointsFromViewerEnabled() ) - { - intersection->appendPointToExtrusionDirection( domainCoord ); - - // Further Ui processing is stopped when true is returned - return true; - } - else if ( intersection->inputTwoAzimuthPointsFromViewerEnabled() ) - { - intersection->appendPointToAzimuthLine( domainCoord ); - - // Further Ui processing is stopped when true is returned - return true; - } - } + // Further Ui processing is stopped when true is returned + return true; } return false; 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(); + cvf::Vec3d newPos = cvf::Vec3d::ZERO; + size_t targetCount = activeTargets.size(); - - if ( targetCount == 0 ) + 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/FileInterface/RifEclEclipseSummary.h b/ApplicationLibCode/FileInterface/RifEclEclipseSummary.h index d6d51ac789..da75646132 100644 --- a/ApplicationLibCode/FileInterface/RifEclEclipseSummary.h +++ b/ApplicationLibCode/FileInterface/RifEclEclipseSummary.h @@ -56,7 +56,7 @@ public: private: int indexFromAddress( const RifEclipseSummaryAddress& resultAddress ) const; - void buildMetaData(); + void buildMetaData() override; private: ecl_sum_type* m_ecl_sum; diff --git a/ApplicationLibCode/FileInterface/RifFaultReactivationModelExporter.cpp b/ApplicationLibCode/FileInterface/RifFaultReactivationModelExporter.cpp index a38541a9c4..3f97281136 100644 --- a/ApplicationLibCode/FileInterface/RifFaultReactivationModelExporter.cpp +++ b/ApplicationLibCode/FileInterface/RifFaultReactivationModelExporter.cpp @@ -62,13 +62,13 @@ std::pair RifFaultReactivationModelExporter::exportToStream( // The two parts are "mirrored", so face number 4 of the two parts should face eachother. using FaultGridPart = RimFaultReactivation::GridPart; - std::map, int> faces = { { { FaultGridPart::FW, PartBorderSurface::FaultSurface }, 4 }, - { { FaultGridPart::FW, PartBorderSurface::UpperSurface }, 4 }, - { { FaultGridPart::FW, PartBorderSurface::LowerSurface }, 4 }, + std::map, int> faces = { { { FaultGridPart::FW, PartBorderSurface::FaultSurface }, 5 }, + { { FaultGridPart::FW, PartBorderSurface::UpperSurface }, 5 }, + { { FaultGridPart::FW, PartBorderSurface::LowerSurface }, 5 }, { { FaultGridPart::FW, PartBorderSurface::Seabed }, 2 }, - { { FaultGridPart::HW, PartBorderSurface::FaultSurface }, 4 }, - { { FaultGridPart::HW, PartBorderSurface::UpperSurface }, 4 }, - { { FaultGridPart::HW, PartBorderSurface::LowerSurface }, 4 }, + { { FaultGridPart::HW, PartBorderSurface::FaultSurface }, 5 }, + { { FaultGridPart::HW, PartBorderSurface::UpperSurface }, 5 }, + { { FaultGridPart::HW, PartBorderSurface::LowerSurface }, 5 }, { { FaultGridPart::HW, PartBorderSurface::Seabed }, 2 } }; std::map partNames = { @@ -327,6 +327,7 @@ std::pair double poissonNumber; double permeability1; double permeability2; + double expansion; }; RifInpExportTools::printSectionComment( stream, "MATERIALS" ); @@ -334,7 +335,7 @@ std::pair for ( auto [element, materialName] : materialNames ) { - std::array parameters = rimModel.materialParameters( element ); + std::array parameters = rimModel.materialParameters( element ); // Incoming unit for Young's Modulus is GPa: convert to Pa. double youngsModulus = RiaEclipseUnitTools::gigaPascalToPascal( parameters[0] ); @@ -345,12 +346,15 @@ std::pair // Unit is already kg/m^3 double density = parameters[2]; + double expansion = parameters[3]; + materials.push_back( Material{ .name = materialName, .density = density, .youngsModulus = youngsModulus, .poissonNumber = poissonNumber, .permeability1 = 1e-09, - .permeability2 = 0.3 } ); + .permeability2 = 0.3, + .expansion = expansion } ); } for ( Material mat : materials ) @@ -378,6 +382,8 @@ std::pair RifInpExportTools::printHeading( stream, "Permeability, specific=1." ); RifInpExportTools::printNumbers( stream, { mat.permeability1, mat.permeability2 } ); + RifInpExportTools::printHeading( stream, "Expansion" ); + RifInpExportTools::printNumbers( stream, { mat.expansion } ); } if ( densityFromGrid ) diff --git a/ApplicationLibCode/FileInterface/RifMultipleSummaryReaders.cpp b/ApplicationLibCode/FileInterface/RifMultipleSummaryReaders.cpp index 785220b1f2..98df37a642 100644 --- a/ApplicationLibCode/FileInterface/RifMultipleSummaryReaders.cpp +++ b/ApplicationLibCode/FileInterface/RifMultipleSummaryReaders.cpp @@ -36,7 +36,7 @@ void RifMultipleSummaryReaders::addReader( RifSummaryReaderInterface* reader ) m_readers.push_back( reader ); - rebuildMetaData(); + buildMetaData(); } //-------------------------------------------------------------------------------------------------- @@ -45,7 +45,7 @@ void RifMultipleSummaryReaders::addReader( RifSummaryReaderInterface* reader ) void RifMultipleSummaryReaders::removeReader( RifSummaryReaderInterface* reader ) { m_readers.erase( reader ); - rebuildMetaData(); + buildMetaData(); } //-------------------------------------------------------------------------------------------------- @@ -100,7 +100,7 @@ RiaDefines::EclipseUnitSystem RifMultipleSummaryReaders::unitSystem() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RifMultipleSummaryReaders::rebuildMetaData() +void RifMultipleSummaryReaders::buildMetaData() { m_allErrorAddresses.clear(); m_allResultAddresses.clear(); diff --git a/ApplicationLibCode/FileInterface/RifMultipleSummaryReaders.h b/ApplicationLibCode/FileInterface/RifMultipleSummaryReaders.h index a18d91fa09..996fa4e66a 100644 --- a/ApplicationLibCode/FileInterface/RifMultipleSummaryReaders.h +++ b/ApplicationLibCode/FileInterface/RifMultipleSummaryReaders.h @@ -40,7 +40,7 @@ public: std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override; RiaDefines::EclipseUnitSystem unitSystem() const override; - void rebuildMetaData(); + void buildMetaData() override; private: cvf::Collection m_readers; diff --git a/ApplicationLibCode/FileInterface/RifOpmCommonSummary.h b/ApplicationLibCode/FileInterface/RifOpmCommonSummary.h index 8dc0de8232..570e7e9d73 100644 --- a/ApplicationLibCode/FileInterface/RifOpmCommonSummary.h +++ b/ApplicationLibCode/FileInterface/RifOpmCommonSummary.h @@ -78,7 +78,7 @@ public: RiaDefines::EclipseUnitSystem unitSystem() const override; private: - void buildMetaData(); + void buildMetaData() override; bool openFileReader( const QString& fileName, bool includeRestartFiles, RiaThreadSafeLogger* threadSafeLogger ); static void increaseEsmryFileCount(); diff --git a/ApplicationLibCode/FileInterface/RifOpmHdf5Summary.h b/ApplicationLibCode/FileInterface/RifOpmHdf5Summary.h index 8c08ba11bf..dc2727171f 100644 --- a/ApplicationLibCode/FileInterface/RifOpmHdf5Summary.h +++ b/ApplicationLibCode/FileInterface/RifOpmHdf5Summary.h @@ -62,7 +62,7 @@ public: RiaDefines::EclipseUnitSystem unitSystem() const override; private: - void buildMetaData(); + void buildMetaData() override; bool openESmryFile( const QString& headerFileName, bool includeRestartFiles, RiaThreadSafeLogger* threadSafeLogger ); private: diff --git a/ApplicationLibCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationLibCode/FileInterface/RifReaderEclipseOutput.cpp index b4ee519238..78621b4e02 100644 --- a/ApplicationLibCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderEclipseOutput.cpp @@ -379,14 +379,13 @@ bool RifReaderEclipseOutput::open( const QString& fileName, RigEclipseCaseData* if ( !RifEclipseOutputFileTools::findSiblingFilesWithSameBaseName( fileName, &fileSet ) ) return false; - m_fileName = fileName; + m_fileName = fileName; + m_filesWithSameBaseName = fileSet; } ecl_grid_type* mainEclGrid = nullptr; { auto task = progress.task( "Open Init File and Load Main Grid", 19 ); - // Keep the set of files of interest - m_filesWithSameBaseName = fileSet; openInitFile(); @@ -608,39 +607,6 @@ const size_t* RifReaderEclipseOutput::eclipseCellIndexMapping() return cellMappingECLRi; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RifReaderEclipseOutput::importFaults( const QStringList& fileSet, cvf::Collection* faults ) -{ - if ( !filenamesWithFaults().empty() ) - { - for ( size_t i = 0; i < filenamesWithFaults().size(); i++ ) - { - QString faultFilename = filenamesWithFaults()[i]; - - RifEclipseInputFileTools::parseAndReadFaults( faultFilename, faults ); - } - } - else - { - foreach ( QString fname, fileSet ) - { - if ( fname.endsWith( ".DATA" ) ) - { - std::vector filenamesWithFaults; - RifEclipseInputFileTools::readFaultsInGridSection( fname, faults, &filenamesWithFaults, faultIncludeFileAbsolutePathPrefix() ); - - std::sort( filenamesWithFaults.begin(), filenamesWithFaults.end() ); - std::vector::iterator last = std::unique( filenamesWithFaults.begin(), filenamesWithFaults.end() ); - filenamesWithFaults.erase( last, filenamesWithFaults.end() ); - - setFilenamesWithFaults( filenamesWithFaults ); - } - } - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/FileInterface/RifReaderEclipseOutput.h b/ApplicationLibCode/FileInterface/RifReaderEclipseOutput.h index 7984fc88b7..39d976de4b 100644 --- a/ApplicationLibCode/FileInterface/RifReaderEclipseOutput.h +++ b/ApplicationLibCode/FileInterface/RifReaderEclipseOutput.h @@ -103,8 +103,6 @@ private: const well_segment_type* segment, const char* wellName ); - void importFaults( const QStringList& fileSet, cvf::Collection* faults ); - void openInitFile(); void extractResultValuesBasedOnPorosityModel( RiaDefines::PorosityModelType matrixOrFracture, diff --git a/ApplicationLibCode/FileInterface/RifReaderEclipseSummary.h b/ApplicationLibCode/FileInterface/RifReaderEclipseSummary.h index 7028e384d3..769aaf1251 100644 --- a/ApplicationLibCode/FileInterface/RifReaderEclipseSummary.h +++ b/ApplicationLibCode/FileInterface/RifReaderEclipseSummary.h @@ -54,10 +54,9 @@ public: std::pair> values( const RifEclipseSummaryAddress& resultAddress ) const override; std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override; RiaDefines::EclipseUnitSystem unitSystem() const override; + void buildMetaData() override; private: - void buildMetaData(); - RifSummaryReaderInterface* currentSummaryReader() const; private: diff --git a/ApplicationLibCode/FileInterface/RifReaderInterface.cpp b/ApplicationLibCode/FileInterface/RifReaderInterface.cpp index 9012df12ca..341f172dbb 100644 --- a/ApplicationLibCode/FileInterface/RifReaderInterface.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderInterface.cpp @@ -21,6 +21,7 @@ #include "RiaPreferences.h" +#include "RifEclipseInputFileTools.h" #include "RifReaderSettings.h" //-------------------------------------------------------------------------------------------------- @@ -144,3 +145,36 @@ void RifReaderInterface::setReaderSettings( std::shared_ptr r { m_readerSettings = readerSettings; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifReaderInterface::importFaults( const QStringList& fileSet, cvf::Collection* faults ) +{ + if ( !filenamesWithFaults().empty() ) + { + for ( size_t i = 0; i < filenamesWithFaults().size(); i++ ) + { + QString faultFilename = filenamesWithFaults()[i]; + + RifEclipseInputFileTools::parseAndReadFaults( faultFilename, faults ); + } + } + else + { + foreach ( QString fname, fileSet ) + { + if ( fname.endsWith( ".DATA" ) ) + { + std::vector filenamesWithFaults; + RifEclipseInputFileTools::readFaultsInGridSection( fname, faults, &filenamesWithFaults, faultIncludeFileAbsolutePathPrefix() ); + + std::sort( filenamesWithFaults.begin(), filenamesWithFaults.end() ); + std::vector::iterator last = std::unique( filenamesWithFaults.begin(), filenamesWithFaults.end() ); + filenamesWithFaults.erase( last, filenamesWithFaults.end() ); + + setFilenamesWithFaults( filenamesWithFaults ); + } + } + } +} diff --git a/ApplicationLibCode/FileInterface/RifReaderInterface.h b/ApplicationLibCode/FileInterface/RifReaderInterface.h index 9bd4e4477b..7619b392e3 100644 --- a/ApplicationLibCode/FileInterface/RifReaderInterface.h +++ b/ApplicationLibCode/FileInterface/RifReaderInterface.h @@ -23,6 +23,7 @@ #include "RiaDefines.h" #include "RiaPorosityModel.h" +#include "cvfCollection.h" #include "cvfObject.h" #include "cafPdmPointer.h" @@ -36,6 +37,7 @@ class RigEclipseCaseData; class RifReaderSettings; +class RigFault; //================================================================================================== // @@ -77,6 +79,7 @@ public: protected: bool isTimeStepIncludedByFilter( size_t timeStepIndex ) const; size_t timeStepIndexOnFile( size_t timeStepIndex ) const; + void importFaults( const QStringList& fileSet, cvf::Collection* faults ); private: const RifReaderSettings* readerSettings() const; diff --git a/ApplicationLibCode/FileInterface/RifReaderOpmCommon.cpp b/ApplicationLibCode/FileInterface/RifReaderOpmCommon.cpp index 3c8fd09394..a71d9b4a04 100644 --- a/ApplicationLibCode/FileInterface/RifReaderOpmCommon.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderOpmCommon.cpp @@ -31,6 +31,8 @@ #include "RigSimWellData.h" #include "RigWellResultFrame.h" +#include "cafProgressInfo.h" + #include "opm/input/eclipse/Deck/Deck.hpp" #include "opm/input/eclipse/EclipseState/Runspec.hpp" #include "opm/input/eclipse/Parser/Parser.hpp" @@ -65,6 +67,8 @@ RifReaderOpmCommon::~RifReaderOpmCommon() //-------------------------------------------------------------------------------------------------- bool RifReaderOpmCommon::open( const QString& fileName, RigEclipseCaseData* eclipseCase ) { + caf::ProgressInfo progress( 100, "Reading Grid" ); + QStringList fileSet; if ( !RifEclipseOutputFileTools::findSiblingFilesWithSameBaseName( fileName, &fileSet ) ) return false; @@ -79,7 +83,24 @@ bool RifReaderOpmCommon::open( const QString& fileName, RigEclipseCaseData* ecli return false; } - buildMetaData( eclipseCase ); + { + auto task = progress.task( "Reading faults", 25 ); + + if ( isFaultImportEnabled() ) + { + cvf::Collection faults; + + importFaults( fileSet, &faults ); + + RigMainGrid* mainGrid = eclipseCase->mainGrid(); + mainGrid->setFaults( faults ); + } + } + + { + auto task = progress.task( "Reading Results Meta data", 50 ); + buildMetaData( eclipseCase ); + } return true; } diff --git a/ApplicationLibCode/FileInterface/RifSummaryReaderInterface.cpp b/ApplicationLibCode/FileInterface/RifSummaryReaderInterface.cpp index 599ab33b0e..01ee289adb 100644 --- a/ApplicationLibCode/FileInterface/RifSummaryReaderInterface.cpp +++ b/ApplicationLibCode/FileInterface/RifSummaryReaderInterface.cpp @@ -49,6 +49,13 @@ RifEclipseSummaryAddress RifSummaryReaderInterface::errorAddress( const RifEclip return m_allErrorAddresses.find( errAddr ) != m_allErrorAddresses.end() ? errAddr : RifEclipseSummaryAddress(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifSummaryReaderInterface::buildMetaData() +{ +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/FileInterface/RifSummaryReaderInterface.h b/ApplicationLibCode/FileInterface/RifSummaryReaderInterface.h index 1c7c3b32a4..efdd2973c6 100644 --- a/ApplicationLibCode/FileInterface/RifSummaryReaderInterface.h +++ b/ApplicationLibCode/FileInterface/RifSummaryReaderInterface.h @@ -51,6 +51,8 @@ public: virtual std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const = 0; virtual RiaDefines::EclipseUnitSystem unitSystem() const = 0; + virtual void buildMetaData(); + protected: std::set m_allResultAddresses; // Result and error addresses std::set m_allErrorAddresses; // Error addresses 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.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/ModelVisualization/RivPolylinePartMgr.cpp b/ApplicationLibCode/ModelVisualization/RivPolylinePartMgr.cpp index 12ba78f953..d7c15ced50 100644 --- a/ApplicationLibCode/ModelVisualization/RivPolylinePartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/RivPolylinePartMgr.cpp @@ -82,7 +82,7 @@ bool RivPolylinePartMgr::isPolylinesInBoundingBox( std::vectorpolyLinesData(); - if ( polylineDef.isNull() || polylineDef->polyLines().empty() ) + if ( polylineDef.isNull() || polylineDef->rawPolyLines().empty() ) { clearAllGeometry(); return; @@ -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 ); @@ -190,7 +192,7 @@ void RivPolylinePartMgr::buildPolylineParts( const caf::DisplayCoordTransform* d //-------------------------------------------------------------------------------------------------- std::vector> RivPolylinePartMgr::getPolylinesPointsInDomain( RigPolyLinesData* lineDef ) { - auto polylines = lineDef->polyLines(); + auto polylines = lineDef->rawPolyLines(); if ( !lineDef->lockToZPlane() ) return polylines; const double planeZ = lineDef->lockedZValue(); diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/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 @@ public: 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 @@ private: 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/Annotations/RimPolylinesFromFileAnnotation.cpp b/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesFromFileAnnotation.cpp index a78843ddd0..ca7a0c6efc 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesFromFileAnnotation.cpp +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesFromFileAnnotation.cpp @@ -158,7 +158,7 @@ bool RimPolylinesFromFileAnnotation::isEmpty() { if ( m_polyLinesData.isNull() ) return true; - for ( const std::vector& line : m_polyLinesData->polyLines() ) + for ( const std::vector& line : m_polyLinesData->rawPolyLines() ) { if ( !line.empty() ) return false; } diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimReachCircleAnnotation.cpp b/ApplicationLibCode/ProjectDataModel/Annotations/RimReachCircleAnnotation.cpp index db573a91d7..005b771caf 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimReachCircleAnnotation.cpp +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimReachCircleAnnotation.cpp @@ -44,8 +44,7 @@ RimReachCircleAnnotation::RimReachCircleAnnotation() CAF_PDM_InitField( &m_centerPointXyd, "CenterPointXyd", Vec3d::ZERO, "Center Point" ); m_centerPointXyd.uiCapability()->setUiEditorTypeName( caf::PdmUiPickableLineEditor::uiEditorTypeName() ); CAF_PDM_InitField( &m_centerPointPickEnabled, "AnchorPointPick", false, "" ); - caf::PdmUiPushButtonEditor::configureEditorForField( &m_centerPointPickEnabled ); - m_centerPointPickEnabled.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosType::HIDDEN ); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_centerPointPickEnabled ); CAF_PDM_InitField( &m_radius, "Radius", 100.0, "Radius" ); CAF_PDM_InitField( &m_name, "Name", QString( "Circle Annotation" ), "Name" ); diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimTextAnnotation.cpp b/ApplicationLibCode/ProjectDataModel/Annotations/RimTextAnnotation.cpp index cbdd9e99b5..5c18975bce 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimTextAnnotation.cpp +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimTextAnnotation.cpp @@ -51,14 +51,12 @@ RimTextAnnotation::RimTextAnnotation() CAF_PDM_InitField( &m_anchorPointXyd, "AnchorPointXyd", Vec3d::ZERO, "Anchor Point" ); m_anchorPointXyd.uiCapability()->setUiEditorTypeName( caf::PdmUiPickableLineEditor::uiEditorTypeName() ); CAF_PDM_InitField( &m_anchorPointPickEnabledButtonField, "AnchorPointPick", false, "" ); - caf::PdmUiPushButtonEditor::configureEditorForField( &m_anchorPointPickEnabledButtonField ); - m_anchorPointPickEnabledButtonField.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosType::HIDDEN ); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_anchorPointPickEnabledButtonField ); CAF_PDM_InitField( &m_labelPointXyd, "LabelPointXyd", Vec3d::ZERO, "Label Point" ); m_labelPointXyd.uiCapability()->setUiEditorTypeName( caf::PdmUiPickableLineEditor::uiEditorTypeName() ); CAF_PDM_InitField( &m_labelPointPickEnabledButtonField, "LabelPointPick", false, "" ); - caf::PdmUiPushButtonEditor::configureEditorForField( &m_labelPointPickEnabledButtonField ); - m_labelPointPickEnabledButtonField.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosType::HIDDEN ); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_labelPointPickEnabledButtonField ); CAF_PDM_InitField( &m_text, "Text", QString( "(New text)" ), "Text" ); m_text.uiCapability()->setUiEditorTypeName( caf::PdmUiTextEditor::uiEditorTypeName() ); diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimUserDefinedPolylinesAnnotation.cpp b/ApplicationLibCode/ProjectDataModel/Annotations/RimUserDefinedPolylinesAnnotation.cpp index 82916de56c..d86ab4b699 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimUserDefinedPolylinesAnnotation.cpp +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimUserDefinedPolylinesAnnotation.cpp @@ -49,7 +49,7 @@ RimUserDefinedPolylinesAnnotation::RimUserDefinedPolylinesAnnotation() CAF_PDM_InitField( &m_name, "Name", QString( "User Defined Polyline" ), "Name" ); CAF_PDM_InitField( &m_enablePicking, "EnablePicking", false, "" ); - caf::PdmUiPushButtonEditor::configureEditorForField( &m_enablePicking ); + caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_enablePicking ); m_enablePicking.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosType::HIDDEN ); CAF_PDM_InitFieldNoDefault( &m_targets, "Targets", "Targets" ); @@ -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 @@ 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/CellFilters/RimCellFilterCollection.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp index debe2ba6f7..c6b0c38d64 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp @@ -145,6 +145,12 @@ void RimCellFilterCollection::fieldChangedByUi( const caf::PdmFieldHandle* chang uiCapability()->updateConnectedEditors(); onFilterUpdated( nullptr ); + + for ( const auto& filter : m_cellFilters ) + { + // Update the filters to make sure the 3D polygon targets are removed if the filter collection is disabled + filter->updateConnectedEditors(); + } } //-------------------------------------------------------------------------------------------------- @@ -255,12 +261,22 @@ bool RimCellFilterCollection::hasActiveIncludeRangeFilters() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimPolygonFilter* RimCellFilterCollection::addNewPolygonFilter( RimCase* srcCase ) +RimPolygonFilter* RimCellFilterCollection::addNewPolygonFilter( RimCase* srcCase, RimPolygon* polygon ) { RimPolygonFilter* pFilter = new RimPolygonFilter(); pFilter->setCase( srcCase ); + pFilter->setPolygon( polygon ); addFilter( pFilter ); - pFilter->enablePicking( true ); + pFilter->configurePolygonEditor(); + if ( polygon ) + { + pFilter->enableFilter( true ); + } + else + { + pFilter->enablePicking( true ); + } + onFilterUpdated( pFilter ); return pFilter; } @@ -485,3 +501,23 @@ void RimCellFilterCollection::updateCellVisibilityByIndex( cvf::UByteArray* incl } } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimCellFilterCollection::enabledCellFilterPolygons() const +{ + std::vector polyInView; + + for ( const auto& filter : m_cellFilters ) + { + if ( !filter->isActive() ) continue; + + 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..7184a32541 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.h +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.h @@ -32,6 +32,8 @@ class RimPolygonFilter; class RimUserDefinedFilter; class RimUserDefinedIndexFilter; class RimCase; +class RimPolygonInView; +class RimPolygon; namespace cvf { @@ -52,7 +54,7 @@ public: caf::Signal<> filtersChanged; - RimPolygonFilter* addNewPolygonFilter( RimCase* srcCase ); + RimPolygonFilter* addNewPolygonFilter( RimCase* srcCase, RimPolygon* polygon ); RimCellRangeFilter* addNewCellRangeFilter( RimCase* srcCase, int gridIndex, int sliceDirection = -1, int defaultSlice = -1 ); RimCellIndexFilter* addNewCellIndexFilter( RimCase* srcCase ); RimUserDefinedFilter* addNewUserDefinedFilter( RimCase* srcCase ); @@ -69,7 +71,8 @@ public: 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 enabledCellFilterPolygons() const; + std::vector filters() const; bool hasActiveFilters() const; bool hasActiveIncludeIndexFilters() const; diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimEclipsePropertyFilter.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimEclipsePropertyFilter.cpp index 6722a70070..81d2479bfe 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimEclipsePropertyFilter.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimEclipsePropertyFilter.cpp @@ -389,7 +389,7 @@ void RimEclipsePropertyFilter::defineObjectEditorAttribute( QString uiConfigName if ( treeItemAttribute ) { treeItemAttribute->tags.clear(); - auto tag = caf::PdmUiTreeViewItemAttribute::Tag::create(); + auto tag = caf::PdmUiTreeViewItemAttribute::createTag(); tag->icon = caf::IconProvider( ":/chain.png" ); treeItemAttribute->tags.push_back( std::move( tag ) ); diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp index 7267dff235..54614df48c 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp @@ -20,39 +20,29 @@ #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 "Polygons/RimPolygon.h" +#include "Polygons/RimPolygonCollection.h" +#include "Polygons/RimPolygonInView.h" +#include "Polygons/RimPolygonTools.h" + +#include "Riu3DMainWindowTools.h" #include "WellPathCommands/PointTangentManipulator/RicPolyline3dEditor.h" #include "WellPathCommands/RicPolylineTargetsPickEventHandler.h" -#include "RiuViewerCommands.h" - -#include "RiaStdStringTools.h" - -#include "cafCmdFeatureMenuBuilder.h" -#include "cafPdmUiLineEditor.h" #include "cafPdmUiPushButtonEditor.h" -#include "cafPdmUiTableViewEditor.h" -#include "cafPdmUiTreeOrdering.h" -#include - -#include "cvfBoundingBox.h" -#include "cvfStructGrid.h" - -#include #include @@ -75,44 +65,24 @@ void caf::AppEnum::setUp() setDefault( RimPolygonFilter::PolygonIncludeType::CENTER ); } +template <> +void caf::AppEnum::setUp() +{ + addItem( RimPolygonFilter::GeometricalShape::AREA, "AREA", "Area Filter" ); + addItem( RimPolygonFilter::GeometricalShape::LINE, "LINE", "Line Filter" ); + setDefault( RimPolygonFilter::GeometricalShape::AREA ); +} + +template <> +void caf::AppEnum::setUp() +{ + addItem( RimPolygonFilter::PolygonDataSource::DEFINED_IN_FILTER, "DEFINED_IN_FILTER", "Defined in Filter" ); + addItem( RimPolygonFilter::PolygonDataSource::GLOBAL_POLYGON, "GLOBAL_POLYGON", "Polygon in Project" ); + setDefault( RimPolygonFilter::PolygonDataSource::DEFINED_IN_FILTER ); +} + } // namespace caf -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -class ThicknessValidator : public QValidator -{ -public: - State validate( QString& input, int& pos ) const override - { - if ( input.isEmpty() ) return State::Intermediate; - - int val = RiaStdStringTools::toInt( input.toStdString() ); - if ( val > 0 && val < 8 ) - return State::Acceptable; - else - return State::Invalid; - } -}; - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -class RadiusValidator : public QValidator -{ -public: - State validate( QString& input, int& pos ) const override - { - if ( input.isEmpty() ) return State::Intermediate; - - double val = RiaStdStringTools::toDouble( input.toStdString() ); - if ( val > 0.001 && val <= 2.0 ) - return State::Acceptable; - else - return State::Invalid; - } -}; - CAF_PDM_SOURCE_INIT( RimPolygonFilter, "PolygonFilter", "PolyLineFilter" ); //-------------------------------------------------------------------------------------------------- @@ -128,70 +98,44 @@ 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_geometricalShape, "GeometricalShape", "" ); + m_geometricalShape.registerGetMethod( this, &RimPolygonFilter::geometricalShape ); + m_geometricalShape.registerSetMethod( this, &RimPolygonFilter::setGeometricalShape ); - CAF_PDM_InitFieldNoDefault( &m_targets, "Targets", "Targets" ); - m_targets.uiCapability()->setUiEditorTypeName( caf::PdmUiTableViewEditor::uiEditorTypeName() ); - m_targets.uiCapability()->setUiTreeChildrenHidden( true ); - m_targets.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); - m_targets.uiCapability()->setCustomContextMenuEnabled( true ); + CAF_PDM_InitFieldNoDefault( &m_internalPolygon, "InternalPolygon", "Polygon For Filter" ); + m_internalPolygon = new RimPolygon; + m_internalPolygon->setName( "Polygon For Filter" ); + m_internalPolygon->uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitField( &m_showLines, "ShowLines", true, "Show Lines" ); - CAF_PDM_InitField( &m_showSpheres, "ShowSpheres", false, "Show Spheres" ); - CAF_PDM_InitField( &m_closePolygon, "ClosePolygon", true, "Closed Polygon" ); + CAF_PDM_InitFieldNoDefault( &m_cellFilterPolygon, "Polygon", "Polygon" ); - CAF_PDM_InitField( &m_lineThickness, "LineThickness", 3, "Line Thickness" ); - CAF_PDM_InitField( &m_sphereRadiusFactor, "SphereRadiusFactor", 0.15, "Sphere Radius Factor" ); - - CAF_PDM_InitField( &m_lineColor, "LineColor", cvf::Color3f( cvf::Color3f::WHITE ), "Line Color" ); - CAF_PDM_InitField( &m_sphereColor, "SphereColor", cvf::Color3f( cvf::Color3f::WHITE ), "Sphere Color" ); + CAF_PDM_InitFieldNoDefault( &m_polygonEditor, "PolygonEditor", "Polygon Editor" ); + m_polygonEditor = new RimPolygonInView; + 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" ); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_editPolygonButton ); - 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() ); } //-------------------------------------------------------------------------------------------------- @@ -210,6 +154,18 @@ void RimPolygonFilter::enableKFilter( bool bEnable ) m_enableKFilter = bEnable; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonFilter::setPolygon( RimPolygon* polygon ) +{ + if ( polygon ) + { + m_polygonDataSource = PolygonDataSource::GLOBAL_POLYGON; + m_cellFilterPolygon = polygon; + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -238,32 +194,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 +218,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 +236,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(); } //-------------------------------------------------------------------------------------------------- @@ -359,34 +253,26 @@ void RimPolygonFilter::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin auto group = uiOrdering.addNewGroup( "General" ); group->add( &m_filterMode ); + group->add( &m_geometricalShape ); group->add( &m_enableFiltering ); - group->add( &m_closePolygon ); + group->add( &m_polygonDataSource ); + if ( !isPolygonDefinedLocally() ) + { + group->add( &m_cellFilterPolygon ); + group->add( &m_editPolygonButton, { .newRow = false } ); + } auto group1 = uiOrdering.addNewGroup( "Polygon Selection" ); group1->add( &m_polyFilterMode ); - if ( m_closePolygon() ) group1->add( &m_polyIncludeType ); - group1->add( &m_targets ); - group1->add( &m_enablePicking ); + + bool isPolygonClosed = m_cellFilterPolygon() ? m_cellFilterPolygon->isClosed() : false; + if ( isPolygonClosed ) + { + group1->add( &m_polyIncludeType ); + } 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 ) - { - group2->add( &m_sphereRadiusFactor ); - group2->add( &m_sphereColor ); - } - group2->add( &m_lockPolygonToPlane ); - if ( m_lockPolygonToPlane ) group2->add( &m_polygonPlaneDepth ); - group2->setCollapsedByDefault(); - auto group3 = uiOrdering.addNewGroup( "Advanced Filter Settings" ); group3->add( &m_enableKFilter ); group3->add( &m_kFilterStr ); @@ -402,7 +288,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 +297,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 +328,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::selectAndActivatePolygonInView( 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 +373,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 +496,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 +504,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 +547,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 +565,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 +633,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 +752,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 +778,17 @@ void RimPolygonFilter::updateCells() // get polyline as vector std::vector points; - for ( auto& target : m_targets ) + + if ( m_polygonEditor && m_polygonEditor->polygon() ) { - if ( target->isEnabled() ) points.push_back( target->targetPointXYZ() ); + points = m_polygonEditor->polygon()->pointsInDomainCoords(); } // 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 +806,119 @@ 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 ) - { - if ( target->isEnabled() ) line.push_back( target->targetPointXYZ() ); - } - pld->setPolyLine( line ); + RimPolygon* polygon = nullptr; + if ( isPolygonDefinedLocally() ) + polygon = m_internalPolygon(); + else + polygon = m_cellFilterPolygon(); - pld->setLineAppearance( m_lineThickness, m_lineColor, m_closePolygon ); - pld->setSphereAppearance( m_sphereRadiusFactor, m_sphereColor ); - pld->setZPlaneLock( m_lockPolygonToPlane, -m_polygonPlaneDepth ); + m_polygonEditor->setPolygon( polygon ); - if ( isActive() ) + // 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(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimPolygonFilter::pickingEnabled() const +{ + return m_polygonEditor->pickingEnabled(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PickEventHandler* RimPolygonFilter::pickEventHandler() const +{ + auto filterColl = firstAncestorOfType(); + if ( filterColl && !filterColl->isActive() ) return nullptr; + + if ( !isActive() ) return nullptr; + + return m_pickTargetsEventHandler.get(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +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 +935,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..52e82a064f 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,32 @@ public: }; RimPolygonFilter(); - ~RimPolygonFilter() override; void enableFilter( bool bEnable ); void enableKFilter( bool bEnable ); + void setPolygon( RimPolygon* polygon ); 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 +112,45 @@ private: 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/Completions/RimFractureTemplate.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimFractureTemplate.cpp index 763837ea6c..2083b5811e 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimFractureTemplate.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimFractureTemplate.cpp @@ -210,9 +210,7 @@ RimFractureTemplate::RimFractureTemplate() "" ); CAF_PDM_InitField( &m_scaleApplyButton, "ScaleApplyButton", false, "Apply" ); - m_scaleApplyButton.xmlCapability()->disableIO(); - m_scaleApplyButton.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); - m_scaleApplyButton.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_scaleApplyButton ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimAbstractCorrelationPlot.cpp b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimAbstractCorrelationPlot.cpp index a4b69ec1a4..fbea61f87b 100644 --- a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimAbstractCorrelationPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimAbstractCorrelationPlot.cpp @@ -66,8 +66,7 @@ RimAbstractCorrelationPlot::RimAbstractCorrelationPlot() m_dataSources.uiCapability()->setUiTreeChildrenHidden( true ); CAF_PDM_InitFieldNoDefault( &m_pushButtonSelectSummaryAddress, "SelectAddress", "" ); - caf::PdmUiPushButtonEditor::configureEditorForField( &m_pushButtonSelectSummaryAddress ); - m_pushButtonSelectSummaryAddress.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_pushButtonSelectSummaryAddress ); m_pushButtonSelectSummaryAddress = false; CAF_PDM_InitFieldNoDefault( &m_timeStepFilter, "TimeStepFilter", "Available Time Steps" ); diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationDataAccessorTemperature.cpp b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationDataAccessorTemperature.cpp index 7dbbdf3525..be16499b68 100644 --- a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationDataAccessorTemperature.cpp +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationDataAccessorTemperature.cpp @@ -17,6 +17,7 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RimFaultReactivationDataAccessorTemperature.h" +#include "RigFaultReactivationModel.h" #include "RimFaultReactivationEnums.h" #include "RiaDefines.h" @@ -74,10 +75,55 @@ void RimFaultReactivationDataAccessorTemperature::updateResultAccessor() m_resultAccessor = RigResultAccessorFactory::createFromResultAddress( m_caseData, 0, RiaDefines::PorosityModelType::MATRIX_MODEL, m_timeStep, resVarAddress ); - auto [wellPaths, extractors] = - RimFaultReactivationDataAccessorWellLogExtraction::createEclipseWellPathExtractors( *m_model, *m_caseData, m_seabedDepth ); - m_wellPaths = wellPaths; - m_extractors = extractors; + if ( m_resultAccessor.notNull() ) + { + auto [wellPaths, extractors] = + RimFaultReactivationDataAccessorWellLogExtraction::createEclipseWellPathExtractors( *m_model, *m_caseData, m_seabedDepth ); + m_wellPaths = wellPaths; + m_extractors = extractors; + + m_gradient = computeGradient(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// Find the top encounter with reservoir (of the two well paths), and create gradient from that point +//-------------------------------------------------------------------------------------------------- +double RimFaultReactivationDataAccessorTemperature::computeGradient() const +{ + double gradient = std::numeric_limits::infinity(); + double minDepth = -std::numeric_limits::max(); + for ( auto gridPart : m_model->allGridParts() ) + { + auto extractor = m_extractors.find( gridPart )->second; + auto wellPath = m_wellPaths.find( gridPart )->second; + + auto [values, intersections] = + RimFaultReactivationDataAccessorWellLogExtraction::extractValuesAndIntersections( *m_resultAccessor.p(), *extractor.p(), *wellPath ); + + int lastOverburdenIndex = RimFaultReactivationDataAccessorWellLogExtraction::findLastOverburdenIndex( values ); + if ( lastOverburdenIndex != -1 ) + { + double depth = intersections[lastOverburdenIndex].z(); + double value = values[lastOverburdenIndex]; + + if ( !std::isinf( value ) ) + { + double currentGradient = + RimFaultReactivationDataAccessorWellLogExtraction::computeGradient( intersections[0].z(), + m_seabedTemperature, + intersections[lastOverburdenIndex].z(), + values[lastOverburdenIndex] ); + if ( !std::isinf( value ) && !std::isnan( currentGradient ) && depth > minDepth ) + { + gradient = currentGradient; + minDepth = depth; + } + } + } + } + + return gradient; } //-------------------------------------------------------------------------------------------------- @@ -100,6 +146,13 @@ double RimFaultReactivationDataAccessorTemperature::valueAtPosition( const cvf:: { if ( ( m_mainGrid != nullptr ) && m_resultAccessor.notNull() ) { + auto cellIdx = m_mainGrid->findReservoirCellIndexFromPoint( position ); + if ( cellIdx != cvf::UNDEFINED_SIZE_T ) + { + double tempFromEclipse = m_resultAccessor->cellScalar( cellIdx ); + if ( !std::isinf( tempFromEclipse ) ) return tempFromEclipse; + } + CAF_ASSERT( m_extractors.find( gridPart ) != m_extractors.end() ); auto extractor = m_extractors.find( gridPart )->second; @@ -110,16 +163,7 @@ double RimFaultReactivationDataAccessorTemperature::valueAtPosition( const cvf:: RimFaultReactivationDataAccessorWellLogExtraction::extractValuesAndIntersections( *m_resultAccessor.p(), *extractor.p(), *wellPath ); auto [value, pos] = - RimFaultReactivationDataAccessorWellLogExtraction::calculateTemperature( intersections, values, position, m_seabedTemperature ); - if ( pos.isUndefined() ) - { - auto cellIdx = m_mainGrid->findReservoirCellIndexFromPoint( position ); - if ( cellIdx != cvf::UNDEFINED_SIZE_T ) - { - double tempFromEclipse = m_resultAccessor->cellScalar( cellIdx ); - if ( !std::isinf( tempFromEclipse ) ) return tempFromEclipse; - } - } + RimFaultReactivationDataAccessorWellLogExtraction::calculateTemperature( intersections, position, m_seabedTemperature, m_gradient ); return value; } diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationDataAccessorTemperature.h b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationDataAccessorTemperature.h index 058d23cdba..d8b5b1fce0 100644 --- a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationDataAccessorTemperature.h +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationDataAccessorTemperature.h @@ -51,13 +51,15 @@ public: size_t elementIndex = std::numeric_limits::max() ) const override; private: - void updateResultAccessor() override; + void updateResultAccessor() override; + double computeGradient() const; RimEclipseCase* m_eclipseCase; RigEclipseCaseData* m_caseData; const RigMainGrid* m_mainGrid; double m_seabedTemperature; double m_seabedDepth; + double m_gradient; cvf::ref m_resultAccessor; diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationDataAccessorWellLogExtraction.cpp b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationDataAccessorWellLogExtraction.cpp index b9779af1d4..a126f1087b 100644 --- a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationDataAccessorWellLogExtraction.cpp +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationDataAccessorWellLogExtraction.cpp @@ -96,23 +96,11 @@ std::pair RimFaultReactivationDataAccessorWellLogExtraction: //-------------------------------------------------------------------------------------------------- std::pair RimFaultReactivationDataAccessorWellLogExtraction::calculateTemperature( const std::vector& intersections, - std::vector& values, const cvf::Vec3d& position, - double seabedTemperature ) + double seabedTemperature, + double gradient ) { - // Fill in missing values - fillInMissingValuesWithTopValue( intersections, values, seabedTemperature ); - auto [value, extractionPosition] = findValueAndPosition( intersections, values, position ); - - double minDistance = computeMinimumDistance( position, intersections ); - if ( minDistance < 1.0 ) - { - return { value, extractionPosition }; - } - else - { - return { value, cvf::Vec3d::UNDEFINED }; - } + return { calculateTemperature( seabedTemperature, intersections[0].z(), std::abs( position.z() ), gradient ), position }; } //-------------------------------------------------------------------------------------------------- @@ -182,16 +170,6 @@ std::pair RimFaultReactivationDataAccessorWellLogExtraction::findInter //-------------------------------------------------------------------------------------------------- std::pair RimFaultReactivationDataAccessorWellLogExtraction::findOverburdenAndUnderburdenIndex( const std::vector& values ) { - auto findLastOverburdenIndex = []( const std::vector& values ) - { - for ( size_t i = 0; i < values.size(); i++ ) - { - if ( !std::isinf( values[i] ) ) return static_cast( i ); - } - - return -1; - }; - auto findFirstUnderburdenIndex = []( const std::vector& values ) { for ( size_t i = values.size() - 1; i > 0; i-- ) @@ -207,6 +185,19 @@ std::pair RimFaultReactivationDataAccessorWellLogExtraction::findOverb return { lastOverburdenIndex, firstUnderburdenIndex }; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimFaultReactivationDataAccessorWellLogExtraction::findLastOverburdenIndex( const std::vector& values ) +{ + for ( size_t i = 0; i < values.size(); i++ ) + { + if ( !std::isinf( values[i] ) ) return static_cast( i ); + } + + return -1; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -481,3 +472,12 @@ double RimFaultReactivationDataAccessorWellLogExtraction::calculatePorePressure( { return RiaEclipseUnitTools::pascalToBar( gradient * 9.81 * depth * 1000.0 ); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimFaultReactivationDataAccessorWellLogExtraction::calculateTemperature( double topValue, double topDepth, double depth, double gradient ) +{ + double tvdDiff = topDepth - depth; + return tvdDiff * gradient + topValue; +} diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationDataAccessorWellLogExtraction.h b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationDataAccessorWellLogExtraction.h index 4d840b492d..489309cb68 100644 --- a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationDataAccessorWellLogExtraction.h +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationDataAccessorWellLogExtraction.h @@ -51,9 +51,9 @@ public: double gradient ); static std::pair calculateTemperature( const std::vector& intersections, - std::vector& values, const cvf::Vec3d& position, - double seabedTemperature ); + double seabedTemperature, + double gradient ); static std::pair>, std::map>> createEclipseWellPathExtractors( const RigFaultReactivationModel& model, RigEclipseCaseData& eclipseCaseData, double seabedDepth ); @@ -76,6 +76,10 @@ public: const cvf::Vec3d& point, const std::map>& elementSets ); + static int findLastOverburdenIndex( const std::vector& values ); + + static double computeGradient( double depth1, double value1, double depth2, double value2 ); + protected: static std::pair findOverburdenAndUnderburdenIndex( const std::vector& values ); static double computeValueWithGradient( const std::vector& intersections, @@ -89,7 +93,6 @@ protected: static std::pair findValueAndPosition( const std::vector& intersections, const std::vector& values, const cvf::Vec3d& position ); - static double computeGradient( double depth1, double value1, double depth2, double value2 ); static std::vector extractDepthValues( const std::vector& intersections ); static void insertUnderburdenValues( const std::vector& intersections, @@ -103,4 +106,5 @@ protected: static double computeMinimumDistance( const cvf::Vec3d& position, const std::vector& positions ); static double calculatePorePressure( double depth, double gradient ); + static double calculateTemperature( double topValue, double topDepth, double depth, double gradient ); }; diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationModel.cpp b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationModel.cpp index e0e552bc72..67c3427332 100644 --- a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationModel.cpp +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationModel.cpp @@ -99,8 +99,6 @@ RimFaultReactivationModel::RimFaultReactivationModel() CAF_PDM_InitField( &m_faultZoneCells, "FaultZoneCells", 0, "Fault Zone Width [cells]" ); CAF_PDM_InitField( &m_showModelPlane, "ShowModelPlane", true, "Show 2D Model" ); - CAF_PDM_InitField( &m_flipNodeOrderFW, "FlipNodeOrderFW", false, "FW: Flip Node Order" ); - CAF_PDM_InitField( &m_flipNodeOrderHW, "FlipNodeOrderHW", false, "HW: Flip Node Order" ); CAF_PDM_InitFieldNoDefault( &m_fault, "Fault", "Fault" ); m_fault.uiCapability()->setUiReadOnly( true ); @@ -344,7 +342,6 @@ void RimFaultReactivationModel::updateVisualization() m_2Dmodel->setGenerator( generator ); m_2Dmodel->updateGeometry( m_startCellIndex, (cvf::StructGridInterface::FaceType)m_startCellFace() ); m_2Dmodel->postProcessElementSets( eclipseCase() ); - m_2Dmodel->flipNodeOrder( m_flipNodeOrderFW, m_flipNodeOrderHW ); view->scheduleCreateDisplayModelAndRedraw(); } @@ -475,9 +472,6 @@ void RimFaultReactivationModel::defineUiOrdering( QString uiConfigName, caf::Pdm gridModelGrp->add( &m_modelThickness ); - gridModelGrp->add( &m_flipNodeOrderFW ); - gridModelGrp->add( &m_flipNodeOrderHW ); - auto appModelGrp = modelGrp->addNewGroup( "Appearance" ); appModelGrp->setCollapsedByDefault(); appModelGrp->add( &m_modelPart1Color ); @@ -741,9 +735,9 @@ std::string RimFaultReactivationModel::baseFilePath() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::array RimFaultReactivationModel::materialParameters( ElementSets elementSet ) const +std::array RimFaultReactivationModel::materialParameters( ElementSets elementSet ) const { - std::array retVal = { 0.0, 0.0, 0.0 }; + std::array retVal = { 0.0, 0.0, 0.0, 0.0 }; static std::map groupMap = { { ElementSets::OverBurden, "material_overburden" }, { ElementSets::Reservoir, "material_reservoir" }, { ElementSets::IntraReservoir, "material_intrareservoir" }, @@ -759,6 +753,7 @@ std::array RimFaultReactivationModel::materialParameters( ElementSets retVal[0] = grp->parameterDoubleValue( "youngs_modulus", 0.0 ); retVal[1] = grp->parameterDoubleValue( "poissons_number", 0.0 ); retVal[2] = grp->parameterDoubleValue( "density", 0.0 ); + retVal[3] = grp->parameterDoubleValue( "expansion", 0.0 ); break; } diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationModel.h b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationModel.h index 846e6d666f..00de04def1 100644 --- a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationModel.h +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationModel.h @@ -107,7 +107,7 @@ public: std::vector selectedTimeSteps() const; std::vector selectedTimeStepIndexes() const; - std::array materialParameters( ElementSets elementSet ) const; + std::array materialParameters( ElementSets elementSet ) const; QStringList commandParameters() const; @@ -162,8 +162,6 @@ private: caf::PdmField m_modelPart2Color; caf::PdmField m_showModelPlane; - caf::PdmField m_flipNodeOrderFW; - caf::PdmField m_flipNodeOrderHW; caf::PdmField m_modelExtentFromAnchor; caf::PdmField m_modelMinZ; diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimFlowCharacteristicsPlot.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimFlowCharacteristicsPlot.cpp index 0313cd03a2..805a5dde6e 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimFlowCharacteristicsPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimFlowCharacteristicsPlot.cpp @@ -78,7 +78,7 @@ RimFlowCharacteristicsPlot::RimFlowCharacteristicsPlot() m_selectedTimeSteps.uiCapability()->setUiHidden( true ); CAF_PDM_InitFieldNoDefault( &m_selectedTimeStepsUi, "SelectedTimeStepsUi", "" ); CAF_PDM_InitFieldNoDefault( &m_applyTimeSteps, "ApplyTimeSteps", "" ); - caf::PdmUiPushButtonEditor::configureEditorForField( &m_applyTimeSteps ); + caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_applyTimeSteps ); CAF_PDM_InitField( &m_maxPvFraction, "CellPVThreshold", @@ -97,7 +97,7 @@ RimFlowCharacteristicsPlot::RimFlowCharacteristicsPlot() CAF_PDM_InitField( &m_tracerFilter, "TracerFilter", QString(), "Tracer Filter" ); CAF_PDM_InitFieldNoDefault( &m_selectedTracerNames, "SelectedTracerNames", " " ); CAF_PDM_InitFieldNoDefault( &m_showRegion, "ShowRegion", "" ); - caf::PdmUiPushButtonEditor::configureEditorForField( &m_showRegion ); + caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_showRegion ); CAF_PDM_InitField( &m_minCommunication, "MinCommunication", 0.0, "Min Communication" ); CAF_PDM_InitField( &m_maxTof, "MaxTof", 146000, "Max Time of Flight [days]" ); diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellAllocationOverTimePlot.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimWellAllocationOverTimePlot.cpp index 39d18ae5d4..9d2669b88a 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellAllocationOverTimePlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellAllocationOverTimePlot.cpp @@ -116,7 +116,7 @@ RimWellAllocationOverTimePlot::RimWellAllocationOverTimePlot() CAF_PDM_InitFieldNoDefault( &m_excludeTimeSteps, "ExcludeTimeSteps", "" ); m_excludeTimeSteps.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); CAF_PDM_InitFieldNoDefault( &m_applyTimeStepSelections, "ApplyTimeStepSelections", "" ); - caf::PdmUiPushButtonEditor::configureEditorForField( &m_applyTimeStepSelections ); + caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_applyTimeStepSelections ); CAF_PDM_InitFieldNoDefault( &m_flowDiagSolution, "FlowDiagSolution", "Plot Type" ); CAF_PDM_InitFieldNoDefault( &m_flowValueType, "FlowValueType", "Value Type" ); diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellConnectivityTable.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimWellConnectivityTable.cpp index 12bbbbe8be..2788a18535 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellConnectivityTable.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellConnectivityTable.cpp @@ -157,7 +157,7 @@ RimWellConnectivityTable::RimWellConnectivityTable() CAF_PDM_InitFieldNoDefault( &m_excludeTimeSteps, "ExcludeTimeSteps", "" ); m_excludeTimeSteps.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); CAF_PDM_InitFieldNoDefault( &m_applyTimeStepSelections, "ApplyTimeStepSelections", "" ); - caf::PdmUiPushButtonEditor::configureEditorForField( &m_applyTimeStepSelections ); + caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_applyTimeStepSelections ); // Producer/Injector tracer configuration CAF_PDM_InitFieldNoDefault( &m_selectedProducerTracersUiField, "SelectedProducerTracers", "Producer Tracers" ); @@ -169,7 +169,7 @@ RimWellConnectivityTable::RimWellConnectivityTable() CAF_PDM_InitField( &m_syncSelectedProducersFromInjectorSelection, "SyncSelectedInjProd", false, "<- Synch Communicators" ); m_syncSelectedProducersFromInjectorSelection.uiCapability()->setUiEditorTypeName( caf::PdmUiToolButtonEditor::uiEditorTypeName() ); CAF_PDM_InitFieldNoDefault( &m_applySelectedInectorProducerTracers, "ApplySelectedInectorProducerTracers", "" ); - caf::PdmUiPushButtonEditor::configureEditorForField( &m_applySelectedInectorProducerTracers ); + caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_applySelectedInectorProducerTracers ); // Table settings CAF_PDM_InitField( &m_showValueLabels, "ShowValueLabels", false, "Show Value Labels" ); diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCase.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCase.cpp index 3f68d3f34e..8c75cd8aa2 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCase.cpp @@ -116,13 +116,13 @@ RimGeoMechCase::RimGeoMechCase() m_elementPropertyFileNameIndexUiSelection.xmlCapability()->disableIO(); CAF_PDM_InitField( &m_importElementPropertyFileCommand, "importElementPropertyFileCommad", false, "" ); - caf::PdmUiPushButtonEditor::configureEditorForField( &m_importElementPropertyFileCommand ); + caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_importElementPropertyFileCommand ); CAF_PDM_InitField( &m_closeElementPropertyFileCommand, "closeElementPropertyFileCommad", false, "" ); - caf::PdmUiPushButtonEditor::configureEditorForField( &m_closeElementPropertyFileCommand ); + caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_closeElementPropertyFileCommand ); CAF_PDM_InitField( &m_reloadElementPropertyFileCommand, "reloadElementPropertyFileCommand", false, "" ); - caf::PdmUiPushButtonEditor::configureEditorForField( &m_reloadElementPropertyFileCommand ); + caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_reloadElementPropertyFileCommand ); caf::AppEnum defaultBiotCoefficientType = RimGeoMechCase::BiotCoefficientType::BIOT_NONE; CAF_PDM_InitField( &m_biotCoefficientType, "BiotCoefficientType", defaultBiotCoefficientType, "Biot Coefficient" ); diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechFaultReactivationResult.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechFaultReactivationResult.cpp index e4e6570253..511c115e5c 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechFaultReactivationResult.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechFaultReactivationResult.cpp @@ -74,7 +74,7 @@ RimGeoMechFaultReactivationResult::RimGeoMechFaultReactivationResult() CAF_PDM_InitField( &m_distanceFromFault, "DistanceFromFault", 5.0, "Distance From Fault" ); CAF_PDM_InitFieldNoDefault( &m_createFaultReactivationPlot, "CreateReactivationPlot", "" ); - caf::PdmUiPushButtonEditor::configureEditorForField( &m_createFaultReactivationPlot ); + caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_createFaultReactivationPlot ); CAF_PDM_InitFieldNoDefault( &m_faultNormal, "FaultNormal", "" ); CAF_PDM_InitFieldNoDefault( &m_faultTopPosition, "FaultTopPosition", "" ); diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp index 7ff399e36a..d94b027858 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" @@ -31,6 +32,7 @@ #include "RigFormationNames.h" #include "RigGeoMechCaseData.h" +#include "Polygons/RimPolygonInViewCollection.h" #include "Rim3dOverlayInfoConfig.h" #include "RimCellFilterCollection.h" #include "RimEclipseResultDefinition.h" @@ -153,7 +155,7 @@ void RimGeoMechView::onLoadDataAndUpdate() onUpdateScaleTransform(); - updateSurfacesInViewTreeItems(); + updateViewTreeItems( RiaDefines::ItemIn3dView::ALL ); if ( m_geomechCase ) { @@ -319,6 +321,9 @@ void RimGeoMechView::onCreateDisplayModel() m_seismicSectionCollection->appendPartsToModel( this, m_seismicVizModel.p(), transform.p(), femBBox ); nativeOrOverrideViewer()->addStaticModelOnce( m_seismicVizModel.p(), isUsingOverrideViewer() ); + // Polygons + appendPolygonPartsToModel( transform.p(), ownerCase()->allCellsBoundingBox() ); + // Surfaces m_surfaceVizModel->removeAllParts(); @@ -1043,6 +1048,11 @@ void RimGeoMechView::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrderin if ( surfaceInViewCollection() ) uiTreeOrdering.add( surfaceInViewCollection() ); if ( seismicSectionCollection()->shouldBeVisibleInTree() ) uiTreeOrdering.add( seismicSectionCollection() ); + if ( RiaApplication::enableDevelopmentFeatures() ) + { + uiTreeOrdering.add( m_polygonInViewCollection ); + } + uiTreeOrdering.skipRemainingChildren( true ); } diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimBoxIntersection.cpp b/ApplicationLibCode/ProjectDataModel/Intersections/RimBoxIntersection.cpp index 6cc32f71c3..3633f6a7f1 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimBoxIntersection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimBoxIntersection.cpp @@ -91,7 +91,7 @@ RimBoxIntersection::RimBoxIntersection() CAF_PDM_InitField( &m_depthSliderStepSize, "DepthSliderStepSize", 0.5, "Depth Slider Step Size" ); CAF_PDM_InitFieldNoDefault( &m_show3DManipulator, "show3DManipulator", "" ); - caf::PdmUiPushButtonEditor::configureEditorForField( &m_show3DManipulator ); + caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_show3DManipulator ); m_show3DManipulator = false; setDeletable( true ); diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp b/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp index bd3faab8f0..42fd132f98 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp @@ -21,23 +21,20 @@ #include "RiaVec3Tools.h" -#include "RigEclipseCaseData.h" #include "RigMainGrid.h" +#include "RigPolyLinesData.h" #include "RigSimulationWellCenterLineCalculator.h" #include "RigWellPath.h" +#include "Polygons/RimPolygon.h" +#include "Polygons/RimPolygonCollection.h" +#include "Polygons/RimPolygonTools.h" + #include "Rim2dIntersectionView.h" #include "Rim3dView.h" #include "RimCase.h" -#include "RimEclipseCase.h" #include "RimEclipseView.h" -#include "RimEnsembleSurface.h" #include "RimGeoMechView.h" -#include "RimGridView.h" -#include "RimIntersectionResultDefinition.h" -#include "RimIntersectionResultsDefinitionCollection.h" -#include "RimOilField.h" -#include "RimProject.h" #include "RimSimWellInView.h" #include "RimSimWellInViewCollection.h" #include "RimSurface.h" @@ -48,12 +45,8 @@ #include "RimTools.h" #include "RimWellPath.h" -#include "RiuViewer.h" - #include "RivExtrudedCurveIntersectionPartMgr.h" -#include "cafCmdFeature.h" -#include "cafCmdFeatureManager.h" #include "cafPdmFieldScriptingCapability.h" #include "cafPdmFieldScriptingCapabilityCvfVec3d.h" #include "cafPdmObjectScriptingCapability.h" @@ -61,12 +54,9 @@ #include "cafPdmUiDoubleSliderEditor.h" #include "cafPdmUiListEditor.h" #include "cafPdmUiPushButtonEditor.h" -#include "cafPdmUiSliderEditor.h" #include "cafPdmUiTreeOrdering.h" -#include "cafPdmUiTreeSelectionEditor.h" #include "cvfBoundingBox.h" #include "cvfGeometryTools.h" -#include "cvfPlane.h" namespace caf { @@ -77,6 +67,7 @@ void caf::AppEnum::setUp() addItem( RimExtrudedCurveIntersection::CrossSectionEnum::CS_SIMULATION_WELL, "CS_SIMULATION_WELL", "Simulation Well" ); addItem( RimExtrudedCurveIntersection::CrossSectionEnum::CS_POLYLINE, "CS_POLYLINE", "Polyline" ); addItem( RimExtrudedCurveIntersection::CrossSectionEnum::CS_AZIMUTHLINE, "CS_AZIMUTHLINE", "Azimuth and Dip" ); + addItem( RimExtrudedCurveIntersection::CrossSectionEnum::CS_POLYGON, "CS_POLYGON", "Project Polygon" ); setDefault( RimExtrudedCurveIntersection::CrossSectionEnum::CS_POLYLINE ); } @@ -186,6 +177,17 @@ void RimExtrudedCurveIntersection::configureForPolyLine() m_inputPolylineFromViewerEnabled = true; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimExtrudedCurveIntersection::configureForProjectPolyLine( RimPolygon* polygon ) +{ + m_type = CrossSectionEnum::CS_POLYGON; + m_projectPolygon = polygon; + + updateName(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -207,6 +209,11 @@ RimExtrudedCurveIntersection::RimExtrudedCurveIntersection() CAF_PDM_InitFieldNoDefault( &m_direction, "Direction", "Direction" ); CAF_PDM_InitScriptableFieldNoDefault( &m_wellPath, "WellPath", "Well Path " ); CAF_PDM_InitScriptableFieldNoDefault( &m_simulationWell, "SimulationWell", "Simulation Well" ); + + CAF_PDM_InitFieldNoDefault( &m_projectPolygon, "ProjectPolygon", "Project Polygon" ); + CAF_PDM_InitField( &m_editPolygonButton, "EditPolygonButton", false, "Edit" ); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_editPolygonButton ); + CAF_PDM_InitScriptableFieldNoDefault( &m_userPolylineXyz, "Points", "Points", "", "Use Ctrl-C for copy and Ctrl-V for paste", "" ); CAF_PDM_InitFieldNoDefault( &m_userPolylineXydForUi, "PointsUi", "Points", "", "Use Ctrl-C for copy and Ctrl-V for paste", "" ); @@ -233,15 +240,15 @@ RimExtrudedCurveIntersection::RimExtrudedCurveIntersection() CAF_PDM_InitField( &m_lengthDown, "lengthDown", 1000.0, "Length Down" ); CAF_PDM_InitFieldNoDefault( &m_inputPolylineFromViewerEnabled, "m_activateUiAppendPointsCommand", "" ); - caf::PdmUiPushButtonEditor::configureEditorForField( &m_inputPolylineFromViewerEnabled ); + caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_inputPolylineFromViewerEnabled ); m_inputPolylineFromViewerEnabled = false; CAF_PDM_InitFieldNoDefault( &m_inputExtrusionPointsFromViewerEnabled, "inputExtrusionPointsFromViewerEnabled", "" ); - caf::PdmUiPushButtonEditor::configureEditorForField( &m_inputExtrusionPointsFromViewerEnabled ); + caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_inputExtrusionPointsFromViewerEnabled ); m_inputExtrusionPointsFromViewerEnabled = false; CAF_PDM_InitFieldNoDefault( &m_inputTwoAzimuthPointsFromViewerEnabled, "inputTwoAzimuthPointsFromViewerEnabled", "" ); - caf::PdmUiPushButtonEditor::configureEditorForField( &m_inputTwoAzimuthPointsFromViewerEnabled ); + caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_inputTwoAzimuthPointsFromViewerEnabled ); m_inputTwoAzimuthPointsFromViewerEnabled = false; CAF_PDM_InitFieldNoDefault( &m_surfaceIntersections, "SurfaceIntersections", "Surface Intersections" ); @@ -439,11 +446,11 @@ void RimExtrudedCurveIntersection::setKFilterOverride( bool collectionOverride, void RimExtrudedCurveIntersection::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) { if ( changedField == &m_isActive || changedField == &m_type || changedField == &m_direction || changedField == &m_wellPath || - changedField == &m_simulationWell || changedField == &m_branchIndex || changedField == &m_extentLength || - changedField == &m_lengthUp || changedField == &m_lengthDown || changedField == &m_showInactiveCells || - changedField == &m_useSeparateDataSource || changedField == &m_separateDataSource || changedField == &m_depthUpperThreshold || - changedField == &m_depthLowerThreshold || changedField == &m_depthThresholdOverridden || changedField == &m_depthFilterType || - changedField == &m_enableKFilter || changedField == &m_kFilterText || changedField == &m_kFilterCollectionOverride ) + changedField == &m_simulationWell || changedField == &m_branchIndex || changedField == &m_extentLength || changedField == &m_lengthUp || + changedField == &m_lengthDown || changedField == &m_showInactiveCells || changedField == &m_useSeparateDataSource || + changedField == &m_separateDataSource || changedField == &m_depthUpperThreshold || changedField == &m_depthLowerThreshold || + changedField == &m_depthThresholdOverridden || changedField == &m_depthFilterType || changedField == &m_enableKFilter || + changedField == &m_kFilterText || changedField == &m_kFilterCollectionOverride || changedField == &m_projectPolygon ) { rebuildGeometryAndScheduleCreateDisplayModel(); } @@ -453,7 +460,8 @@ void RimExtrudedCurveIntersection::fieldChangedByUi( const caf::PdmFieldHandle* recomputeSimulationWellBranchData(); } - if ( changedField == &m_simulationWell || changedField == &m_wellPath || changedField == &m_branchIndex ) + if ( changedField == &m_simulationWell || changedField == &m_wellPath || changedField == &m_branchIndex || + changedField == &m_projectPolygon || changedField == &m_type ) { updateName(); } @@ -511,6 +519,15 @@ void RimExtrudedCurveIntersection::fieldChangedByUi( const caf::PdmFieldHandle* { rebuildGeometryAndScheduleCreateDisplayModel(); } + + if ( changedField == &m_editPolygonButton ) + { + RimPolygonTools::selectAndActivatePolygonInView( m_projectPolygon(), this ); + + m_editPolygonButton = false; + + return; + } } //-------------------------------------------------------------------------------------------------- @@ -540,6 +557,11 @@ void RimExtrudedCurveIntersection::defineUiOrdering( QString uiConfigName, caf:: geometryGroup->add( &m_userPolylineXydForUi ); geometryGroup->add( &m_inputPolylineFromViewerEnabled ); } + else if ( type() == CrossSectionEnum::CS_POLYGON ) + { + geometryGroup->add( &m_projectPolygon ); + geometryGroup->add( &m_editPolygonButton, { .newRow = false } ); + } else if ( type() == CrossSectionEnum::CS_AZIMUTHLINE ) { geometryGroup->add( &m_twoAzimuthPoints ); @@ -668,6 +690,19 @@ QList RimExtrudedCurveIntersection::calculateValueOption options.push_front( caf::PdmOptionItemInfo( "None", nullptr ) ); } } + else if ( fieldNeedingOptions == &m_projectPolygon ) + { + options.push_back( caf::PdmOptionItemInfo( "None", nullptr ) ); + + RimTools::polygonOptionItems( &options ); + + if ( m_projectPolygon() == nullptr ) + { + auto polygonCollection = RimTools::polygonCollection(); + auto polygons = polygonCollection->allPolygons(); + if ( !polygons.empty() ) m_projectPolygon = polygons.front(); + } + } else if ( fieldNeedingOptions == &m_branchIndex ) { updateSimulationWellCenterline(); @@ -775,8 +810,6 @@ std::vector> RimExtrudedCurveIntersection::polyLines( cv { if ( m_simulationWell() ) { - updateSimulationWellCenterline(); - int branchIndexToUse = branchIndex(); if ( 0 <= branchIndexToUse && branchIndexToUse < static_cast( m_simulationWellBranchCenterlines.size() ) ) @@ -794,6 +827,13 @@ std::vector> RimExtrudedCurveIntersection::polyLines( cv { lines.push_back( m_userPolylineXyz ); } + else if ( type() == CrossSectionEnum::CS_POLYGON ) + { + if ( m_projectPolygon ) + { + lines = m_projectPolygon->polyLinesData()->completePolyLines(); + } + } else if ( type() == CrossSectionEnum::CS_AZIMUTHLINE ) { lines.push_back( m_twoAzimuthPoints ); @@ -863,7 +903,7 @@ std::vector RimExtrudedCurveIntersection::polyLinesForExtrusionDirec //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimExtrudedCurveIntersection::updateSimulationWellCenterline() const +void RimExtrudedCurveIntersection::updateSimulationWellCenterline() { if ( m_isActive() && type() == CrossSectionEnum::CS_SIMULATION_WELL && m_simulationWell() ) { @@ -954,6 +994,10 @@ void RimExtrudedCurveIntersection::updateName() { m_name = m_wellPath()->name(); } + else if ( m_type() == CrossSectionEnum::CS_POLYGON && m_projectPolygon() ) + { + m_name = m_projectPolygon->name(); + } Rim2dIntersectionView* iView = correspondingIntersectionView(); if ( iView ) @@ -1081,6 +1125,14 @@ void RimExtrudedCurveIntersection::defineEditorAttribute( const caf::PdmFieldHan { setBaseColor( m_inputExtrusionPointsFromViewerEnabled, dynamic_cast( attribute ) ); } + + if ( field == &m_editPolygonButton ) + { + if ( auto attrib = dynamic_cast( attribute ) ) + { + attrib->m_buttonText = "Edit"; + } + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.h b/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.h index a27079113e..22d6836593 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.h +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.h @@ -24,9 +24,10 @@ #include "RimIntersectionEnums.h" #include "cafPdmChildField.h" +#include "cafPdmFieldCvfVec3d.h" #include "cafPdmProxyValueField.h" -#include +#include "cvfVector3.h" class RimWellPath; class RivExtrudedCurveIntersectionPartMgr; @@ -40,6 +41,7 @@ class RimSurfaceCollection; class RimSurfaceIntersectionCollection; class RimSurfaceIntersectionCurve; class RimSurfaceIntersectionBand; +class RimPolygon; namespace caf { @@ -62,7 +64,8 @@ public: CS_WELL_PATH, CS_SIMULATION_WELL, CS_POLYLINE, - CS_AZIMUTHLINE + CS_AZIMUTHLINE, + CS_POLYGON, }; enum class CrossSectionDirEnum @@ -102,6 +105,7 @@ public: void configureForSimulationWell( RimSimWellInView* simWell ); void configureForWellPath( RimWellPath* wellPath ); void configureForPolyLine(); + void configureForProjectPolyLine( RimPolygon* polygon ); void configureForAzimuthLine(); std::vector> polyLines( cvf::Vec3d* flattenedPolylineStartPoint = nullptr ) const; @@ -134,7 +138,7 @@ public: int branchIndex() const; void rebuildGeometryAndScheduleCreateDisplayModel(); -protected: +private: caf::PdmFieldHandle* userDescriptionField() final; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; @@ -143,13 +147,12 @@ protected: void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; -private: static void setPushButtonText( bool buttonEnable, caf::PdmUiPushButtonEditorAttribute* attribute ); static void setBaseColor( bool enable, caf::PdmUiListEditorAttribute* attribute ); RimSimWellInViewCollection* simulationWellCollection() const; void updateAzimuthLine(); - void updateSimulationWellCenterline() const; + void updateSimulationWellCenterline(); void addExtents( std::vector& polyLine ) const; void updateName(); static double azimuthInRadians( cvf::Vec3d vec ); @@ -181,6 +184,9 @@ private: caf::PdmPtrField m_wellPath; caf::PdmPtrField m_simulationWell; + caf::PdmPtrField m_projectPolygon; + caf::PdmField m_editPolygonButton; + caf::PdmField m_inputPolylineFromViewerEnabled; caf::PdmField m_inputExtrusionPointsFromViewerEnabled; caf::PdmField m_inputTwoAzimuthPointsFromViewerEnabled; @@ -202,11 +208,11 @@ private: cvf::ref m_crossSectionPartMgr; - mutable std::vector> m_simulationWellBranchCenterlines; + std::vector> m_simulationWellBranchCenterlines; caf::PdmField m_enableKFilter; caf::PdmField m_kFilterText; caf::PdmField m_kFilterCollectionOverride; caf::PdmField m_kFilterCollectionText; -}; \ No newline at end of file +}; diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersection.cpp b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersection.cpp index a5226cf1a5..5eabceaf88 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersection.cpp @@ -19,7 +19,6 @@ #include "RimIntersection.h" #include "RigEclipseCaseData.h" -#include "RigFemPartCollection.h" #include "RigGeoMechCaseData.h" #include "RimEclipseCase.h" #include "RimEclipseResultDefinition.h" diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersection.h b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersection.h index e94d2ff776..df8b70d7ba 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersection.h +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersection.h @@ -18,7 +18,6 @@ #pragma once #include "cafPdmField.h" -#include "cafPdmFieldCvfVec3d.h" #include "cafPdmObject.h" #include "cafPdmPtrField.h" diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/Polygons/CMakeLists_files.cmake new file mode 100644 index 0000000000..ace8580f7d --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Polygons/CMakeLists_files.cmake @@ -0,0 +1,29 @@ +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 + ${CMAKE_CURRENT_LIST_DIR}/RimPolygonTools.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 + ${CMAKE_CURRENT_LIST_DIR}/RimPolygonTools.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..04d65d24c0 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.cpp @@ -0,0 +1,206 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RiaApplication.h" +#include "Rim3dView.h" +#include "RimPolygonAppearance.h" +#include "RimPolygonTools.h" + +#include "cafCmdFeatureMenuBuilder.h" +#include "cafPdmUiPushButtonEditor.h" +#include "cafPdmUiTreeAttributes.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_InitField( &m_editPolygonButton, "EditPolygonButton", false, "Edit" ); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_editPolygonButton ); + + 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::uiOrderingForLocalPolygon( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +{ + m_appearance->uiOrdering( uiConfigName, uiOrdering ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygon::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const +{ + menuBuilder << "RicNewPolygonIntersectionFeature"; + menuBuilder << "RicNewPolygonFilterFeature"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygon::setPointsInDomainCoords( const std::vector& points ) +{ + m_pointsInDomainCoords = points; + + objectChanged.send(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimPolygon::pointsInDomainCoords() const +{ + return m_pointsInDomainCoords(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygon::setIsClosed( bool isClosed ) +{ + m_appearance->setIsClosed( isClosed ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimPolygon::isClosed() const +{ + return m_appearance->isClosed(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygon::setReadOnly( bool isReadOnly ) +{ + m_isReadOnly = isReadOnly; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimPolygon::isReadOnly() const +{ + return m_isReadOnly(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygon::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +{ + uiOrdering.add( nameField() ); + uiOrdering.add( &m_isReadOnly ); + uiOrdering.add( &m_editPolygonButton ); + + auto groupPoints = uiOrdering.addNewGroup( "Points" ); + groupPoints->setCollapsedByDefault(); + groupPoints->add( &m_pointsInDomainCoords ); + + m_pointsInDomainCoords.uiCapability()->setUiReadOnly( m_isReadOnly() ); + + 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(); + } + + if ( changedField == &m_editPolygonButton ) + { + auto activeView = RiaApplication::instance()->activeReservoirView(); + RimPolygonTools::selectAndActivatePolygonInView( this, activeView ); + + m_editPolygonButton = false; + + return; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygon::childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) +{ + objectChanged.send(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygon::defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) +{ + if ( field == &m_editPolygonButton ) + { + if ( auto attrib = dynamic_cast( attribute ) ) + { + attrib->m_buttonText = "Edit in Active View"; + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygon::defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) +{ + if ( m_isReadOnly ) + { + caf::PdmUiTreeViewItemAttribute::createTagIfTreeViewItemAttribute( attribute, ":/padlock.svg" ); + } +} diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.h b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.h new file mode 100644 index 0000000000..0562acd652 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.h @@ -0,0 +1,71 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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; + +namespace caf +{ +class CmdFeatureMenuBuilder; +} + +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; + void setIsClosed( bool isClosed ); + bool isClosed() const; + + void setReadOnly( bool isReadOnly ); + bool isReadOnly() const; + + cvf::ref polyLinesData() const override; + + void uiOrderingForLocalPolygon( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ); + void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const 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 childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) override; + void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; + +private: + caf::PdmField m_isReadOnly; + caf::PdmField m_editPolygonButton; + 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..1cd83a0a5c --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.cpp @@ -0,0 +1,214 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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", true, "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 ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonAppearance::setIsClosed( bool isClosed ) +{ + m_isClosed = isClosed; + objectChanged.send(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +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..4fae753127 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.h @@ -0,0 +1,60 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 ); + + void setIsClosed( bool isClosed ); + 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..32cfc6732b --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonCollection.cpp @@ -0,0 +1,206 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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(); + scheduleRedrawViews(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +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/ModelVisualization/RivCellFilterPartMgr.cpp b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonFile.cpp similarity index 53% rename from ApplicationLibCode/ModelVisualization/RivCellFilterPartMgr.cpp rename to ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonFile.cpp index e8d82cd12f..cec7ec8160 100644 --- a/ApplicationLibCode/ModelVisualization/RivCellFilterPartMgr.cpp +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonFile.cpp @@ -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 @@ -16,73 +16,67 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RivCellFilterPartMgr.h" +#include "RimPolygonFile.h" +#include "RimPolygon.h" -#include "Rim3dView.h" -#include "RimCellFilterCollection.h" -#include "RimPolygonFilter.h" - -#include "RivPolylinePartMgr.h" - -#include "cafPdmObject.h" +CAF_PDM_SOURCE_INIT( RimPolygonFile, "RimPolygonFileFile" ); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RivCellFilterPartMgr::RivCellFilterPartMgr( Rim3dView* view ) - : m_rimView( view ) +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 ) { } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RivCellFilterPartMgr::~RivCellFilterPartMgr() +void RimPolygonFile::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) { + loadPolygonsFromFile(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivCellFilterPartMgr::appendGeometryPartsToModel( cvf::ModelBasicList* model, - const caf::DisplayCoordTransform* displayCoordTransform, - const cvf::BoundingBox& boundingBox ) +void RimPolygonFile::loadPolygonsFromFile() { - createCellFilterPartManagers(); + // m_polygons()->deletePolygons(); - 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(); + 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..d45b557261 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.cpp @@ -0,0 +1,439 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RimPolygonInViewCollection.h" +#include "RimPolylineTarget.h" +#include "RimTools.h" + +#include "WellPathCommands/PointTangentManipulator/RicPolyline3dEditor.h" +#include "WellPathCommands/RicPolylineTargetsPickEventHandler.h" + +#include "Riu3DMainWindowTools.h" +#include "RiuGuiTheme.h" + +#include "RivPolylinePartMgr.h" + +#include "cafCmdFeatureMenuBuilder.h" +#include "cafDisplayCoordTransform.h" +#include "cafPdmUiPushButtonEditor.h" +#include "cafPdmUiTableViewEditor.h" +#include "cafPdmUiTreeAttributes.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::configureEditorLabelHidden( &m_enablePicking ); + + CAF_PDM_InitField( &m_selectPolygon, "SelectPolygon", false, "" ); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_selectPolygon ); + + 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 ); + 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 +{ + auto filterColl = firstAncestorOfType(); + if ( filterColl && !filterColl->isChecked() ) return nullptr; + + if ( !isChecked() ) return nullptr; + + if ( m_polygon() && polygon()->isReadOnly() ) return nullptr; + + 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(); + + bool enableEdit = true; + if ( m_polygon() && m_polygon->isReadOnly() ) enableEdit = false; + + uiOrdering.add( m_polygon ); + + if ( enableEdit ) + { + uiOrdering.add( &m_enablePicking ); + uiOrdering.add( &m_targets ); + uiOrdering.add( &m_handleScalingFactor ); + } + + if ( m_polygon() ) + { + uiOrdering.add( &m_selectPolygon ); + } + + uiOrdering.skipRemainingFields(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonInView::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) +{ + if ( changedField == &m_enablePicking ) + { + updateConnectedEditors(); + } + + if ( changedField == &m_selectPolygon && m_polygon() ) + { + Riu3DMainWindowTools::selectAsCurrentItem( m_polygon() ); + } + + 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; + } + + if ( m_polygon() && m_polygon->isReadOnly() ) + { + caf::PdmUiTreeViewItemAttribute::createTagIfTreeViewItemAttribute( attribute, ":/padlock.svg" ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonInView::uiOrderingForLocalPolygon( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +{ + uiOrdering.add( &m_enablePicking ); + uiOrdering.add( &m_targets ); + uiOrdering.add( &m_handleScalingFactor ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonInView::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const +{ + if ( m_polygon() ) m_polygon->appendMenuItems( menuBuilder ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimPolygonInView::scalingFactorForTarget() const +{ + return m_handleScalingFactor(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +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_selectPolygon ) + { + auto* pbAttribute = dynamic_cast( attribute ); + if ( pbAttribute ) + { + pbAttribute->m_buttonText = "Go to Polygon"; + } + } + + 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 ) +{ + if ( m_polygon() && m_polygon->isReadOnly() ) return; + + 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..c77494d0d3 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.h @@ -0,0 +1,99 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 ); + + 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; + 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; + 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; + void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override; + +private: + void updateNameField(); + + void updatePolygonFromTargets(); + void updateTargetsFromPolygon(); + +private: + caf::PdmPtrField m_polygon; + + caf::PdmField m_selectPolygon; + caf::PdmField m_enablePicking; + caf::PdmField m_handleScalingFactor; + 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..3ee9722878 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInViewCollection.cpp @@ -0,0 +1,107 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "Rim3dView.h" +#include "RimPolygon.h" +#include "RimPolygonCollection.h" +#include "RimPolygonInView.h" +#include "RimTools.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; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimPolygonInViewCollection::polygonsInView() const +{ + return m_polygons.childrenByType(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonInViewCollection::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) +{ + RimCheckableObject::fieldChangedByUi( changedField, oldValue, newValue ); + + if ( changedField == &m_isChecked ) + { + for ( auto poly : polygonsInView() ) + { + poly->updateConnectedEditors(); + } + + if ( auto view = firstAncestorOfType() ) + { + view->scheduleCreateDisplayModelAndRedraw(); + } + } +} diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInViewCollection.h b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInViewCollection.h new file mode 100644 index 0000000000..87e947d83a --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInViewCollection.h @@ -0,0 +1,46 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RimCheckableObject.h" +#include "cafPdmChildArrayField.h" + +class RimPolygonInView; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimPolygonInViewCollection : public RimCheckableObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimPolygonInViewCollection(); + + void syncPolygonsInView(); + + std::vector polygonsInView() const; + +private: + void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; + +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..52c5fd37c5 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonTools.cpp @@ -0,0 +1,68 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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::selectAndActivatePolygonInView( 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 ( !polygon || !sourceObject ) + { + return nullptr; + } + + if ( auto gridView = sourceObject->firstAncestorOrThisOfType() ) + { + auto polyCollection = gridView->polygonInViewCollection(); + + for ( auto polygonInView : polyCollection->polygonsInView() ) + { + if ( polygonInView && polygonInView->polygon() == polygon ) + { + return polygonInView; + } + } + } + + return nullptr; +} diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonTools.h b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonTools.h new file mode 100644 index 0000000000..8f7d3a65d3 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonTools.h @@ -0,0 +1,36 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +class RimPolygon; +class RimPolygonInView; + +namespace caf +{ +class PdmObject; +} + +class RimPolygonTools +{ +public: + static void selectAndActivatePolygonInView( 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 2805312a19..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() ); - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1860,7 +1821,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..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 @@ -193,7 +192,7 @@ public: RimViewLinker* assosiatedViewLinker() const override; RimViewController* viewController() const override; - virtual void updateSurfacesInViewTreeItems(); + virtual void updateViewTreeItems( RiaDefines::ItemIn3dView itemType ); RimAnnotationInViewCollection* annotationCollection() const; void syncronizeLocalAnnotationsFromGlobal(); @@ -222,7 +221,6 @@ protected: double characteristicCellSize ); void addAnnotationsToModel( cvf::ModelBasicList* annotationsModel ); void addMeasurementToModel( cvf::ModelBasicList* measureModel ); - void addCellFiltersToModel( cvf::ModelBasicList* cellFilterModel ); // Override viewer @@ -311,7 +309,6 @@ private: void createHighlightAndGridBoxDisplayModel(); void appendMeasurementToModel(); - void appendCellFiltersToModel(); void appendAnnotationsToModel(); void updateScreenSpaceModel(); @@ -349,7 +346,6 @@ private: // 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/RimCommandObject.cpp b/ApplicationLibCode/ProjectDataModel/RimCommandObject.cpp index 4b51937e9e..d6fc849771 100644 --- a/ApplicationLibCode/ProjectDataModel/RimCommandObject.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimCommandObject.cpp @@ -63,9 +63,7 @@ RimCommandExecuteScript::RimCommandExecuteScript() CAF_PDM_InitField( &isEnabled, "IsEnabled", true, "Enabled " ); CAF_PDM_InitField( &execute, "Execute", true, "Execute" ); - execute.xmlCapability()->disableIO(); - execute.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); - execute.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &execute ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp index d036783239..7adc007c08 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 ) ) { @@ -1151,6 +1157,11 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() if ( firstUiItem ) { + if ( auto pdmObject = dynamic_cast( firstUiItem ) ) + { + pdmObject->appendMenuItems( menuBuilder ); + } + // Work in progress -- Start // All commands should be aware of selection of multiple objects // Based on the selection, the command feature can decide if the command diff --git a/ApplicationLibCode/ProjectDataModel/RimCustomObjectiveFunctionWeight.cpp b/ApplicationLibCode/ProjectDataModel/RimCustomObjectiveFunctionWeight.cpp index 5e87607dcc..977d8c2903 100644 --- a/ApplicationLibCode/ProjectDataModel/RimCustomObjectiveFunctionWeight.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimCustomObjectiveFunctionWeight.cpp @@ -52,8 +52,7 @@ RimCustomObjectiveFunctionWeight::RimCustomObjectiveFunctionWeight() m_objectiveValuesSummaryAddresses.uiCapability()->setUiTreeChildrenHidden( true ); CAF_PDM_InitFieldNoDefault( &m_objectiveValuesSelectSummaryAddressPushButton, "SelectObjectiveSummaryAddress", "" ); - caf::PdmUiPushButtonEditor::configureEditorForField( &m_objectiveValuesSelectSummaryAddressPushButton ); - m_objectiveValuesSelectSummaryAddressPushButton.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_objectiveValuesSelectSummaryAddressPushButton ); m_objectiveValuesSelectSummaryAddressPushButton = false; CAF_PDM_InitField( &m_weightValue, "WeightValue", 1.0, "Weight" ); diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp index 6f60b58228..17c2c98d8a 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp @@ -99,9 +99,11 @@ RimEclipseCase::RimEclipseCase() CAF_PDM_InitField( &m_flipXAxis, "FlipXAxis", false, "Flip X Axis" ); CAF_PDM_InitField( &m_flipYAxis, "FlipYAxis", false, "Flip Y Axis" ); - CAF_PDM_InitFieldNoDefault( &m_filesContainingFaults_OBSOLETE, "CachedFileNamesContainingFaults", "" ); - m_filesContainingFaults_OBSOLETE.uiCapability()->setUiHidden( true ); - m_filesContainingFaults_OBSOLETE.xmlCapability()->disableIO(); + CAF_PDM_InitFieldNoDefault( &m_filesContainingFaults, "CachedFileNamesContainingFaults", "" ); + m_filesContainingFaults.uiCapability()->setUiHidden( true ); + // Caching of file names causes issues when using the project file as template, do not save to disk + // https://github.com/OPM/ResInsight/issues/7308 + m_filesContainingFaults.xmlCapability()->disableIO(); CAF_PDM_InitFieldNoDefault( &m_contourMapCollection, "ContourMaps", "2d Contour Maps" ); m_contourMapCollection = new RimEclipseContourMapViewCollection; @@ -927,7 +929,7 @@ std::vector RimEclipseCase::filesContainingFaults() const { std::vector stdPathList; - for ( auto& filePath : m_filesContainingFaults_OBSOLETE() ) + for ( auto& filePath : m_filesContainingFaults() ) { stdPathList.push_back( filePath.path() ); } @@ -946,7 +948,7 @@ void RimEclipseCase::setFilesContainingFaults( const std::vector& pathS filePaths.push_back( pathString ); } - m_filesContainingFaults_OBSOLETE = filePaths; + m_filesContainingFaults = filePaths; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.h b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.h index d5ace3d6b0..dad144c78d 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.h +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.h @@ -167,7 +167,5 @@ private: caf::PdmChildField m_matrixModelResults; caf::PdmChildField m_fractureModelResults; - // To be removed as the caching of file names causes issues when using the project file as template - // https://github.com/OPM/ResInsight/issues/7308 - caf::PdmField> m_filesContainingFaults_OBSOLETE; + caf::PdmField> m_filesContainingFaults; }; diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCase.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCase.cpp index 070b9e55b2..de14294092 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCase.cpp @@ -82,7 +82,7 @@ RimEclipseStatisticsCase::RimEclipseStatisticsCase() CAF_PDM_InitScriptableObject( "Case Group Statistics", ":/Histogram16x16.png" ); CAF_PDM_InitFieldNoDefault( &m_calculateEditCommand, "m_editingAllowed", "" ); - caf::PdmUiPushButtonEditor::configureEditorForField( &m_calculateEditCommand ); + caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_calculateEditCommand ); m_calculateEditCommand = false; CAF_PDM_InitField( &m_selectionSummary, "SelectionSummary", QString( "" ), "Summary of Calculation Setup" ); diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp index a851c24600..80a74c8e9e 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" @@ -41,6 +42,7 @@ #include "RigWellResultFrame.h" #include "RigWellResultPoint.h" +#include "Polygons/RimPolygonInViewCollection.h" #include "Rim2dIntersectionView.h" #include "Rim3dOverlayInfoConfig.h" #include "RimAnnotationCollection.h" @@ -671,6 +673,9 @@ void RimEclipseView::onCreateDisplayModel() nativeOrOverrideViewer()->addStaticModelOnce( m_surfaceVizModel.p(), isUsingOverrideViewer() ); } + // Polygons + appendPolygonPartsToModel( transform.p(), ownerCase()->allCellsBoundingBox() ); + // Well path model m_wellPathPipeVizModel->removeAllParts(); @@ -1101,7 +1106,7 @@ void RimEclipseView::appendStreamlinesToModel() //-------------------------------------------------------------------------------------------------- void RimEclipseView::onLoadDataAndUpdate() { - updateSurfacesInViewTreeItems(); + updateViewTreeItems( RiaDefines::ItemIn3dView::ALL ); onUpdateScaleTransform(); @@ -1982,6 +1987,11 @@ void RimEclipseView::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrderin if ( surfaceInViewCollection() ) uiTreeOrdering.add( surfaceInViewCollection() ); if ( seismicSectionCollection()->shouldBeVisibleInTree() ) uiTreeOrdering.add( seismicSectionCollection() ); + if ( RiaApplication::enableDevelopmentFeatures() ) + { + uiTreeOrdering.add( m_polygonInViewCollection ); + } + uiTreeOrdering.skipRemainingChildren( true ); } diff --git a/ApplicationLibCode/ProjectDataModel/RimGridCalculation.cpp b/ApplicationLibCode/ProjectDataModel/RimGridCalculation.cpp index 43427b03b1..bc0cd5910e 100644 --- a/ApplicationLibCode/ProjectDataModel/RimGridCalculation.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimGridCalculation.cpp @@ -102,8 +102,7 @@ RimGridCalculation::RimGridCalculation() m_nonVisibleResultAddress = new RimEclipseResultAddress; CAF_PDM_InitField( &m_editNonVisibleResultAddress, "EditNonVisibleResultAddress", false, "Edit" ); - m_editNonVisibleResultAddress.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); - m_editNonVisibleResultAddress.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_editNonVisibleResultAddress ); CAF_PDM_InitFieldNoDefault( &m_nonVisibleResultText, "NonVisibleResultText", "" ); m_nonVisibleResultText.registerGetMethod( this, &RimGridCalculation::nonVisibleResultAddressText ); diff --git a/ApplicationLibCode/ProjectDataModel/RimGridCalculationVariable.cpp b/ApplicationLibCode/ProjectDataModel/RimGridCalculationVariable.cpp index 14dcd9c3a7..21040520c6 100644 --- a/ApplicationLibCode/ProjectDataModel/RimGridCalculationVariable.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimGridCalculationVariable.cpp @@ -56,8 +56,7 @@ RimGridCalculationVariable::RimGridCalculationVariable() CAF_PDM_InitField( &m_timeStep, "TimeStep", allTimeStepsValue(), "Time Step" ); CAF_PDM_InitFieldNoDefault( &m_button, "PushButton", "" ); - m_button.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); - m_button.xmlCapability()->disableIO(); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_button ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimGridView.cpp b/ApplicationLibCode/ProjectDataModel/RimGridView.cpp index 81006c365b..51813b0e7d 100644 --- a/ApplicationLibCode/ProjectDataModel/RimGridView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimGridView.cpp @@ -41,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" @@ -96,6 +99,9 @@ RimGridView::RimGridView() CAF_PDM_InitFieldNoDefault( &m_seismicSectionCollection, "SeismicSectionCollection", "Seismic Collection Field" ); m_seismicSectionCollection = new RimSeismicSectionCollection(); + 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(); @@ -104,6 +110,9 @@ RimGridView::RimGridView() m_intersectionVizModel = new cvf::ModelBasicList; m_intersectionVizModel->setName( "CrossSectionModel" ); + + m_polygonVizModel = new cvf::ModelBasicList; + m_polygonVizModel->setName( "PolygonModel" ); } //-------------------------------------------------------------------------------------------------- @@ -161,6 +170,14 @@ RimSeismicSectionCollection* RimGridView::seismicSectionCollection() const return m_seismicSectionCollection(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimPolygonInViewCollection* RimGridView::polygonInViewCollection() const +{ + return m_polygonInViewCollection(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -380,6 +397,43 @@ void RimGridView::onCreatePartCollectionFromSelection( cvf::CollectionremoveAllParts(); + + std::vector polygonsInView; + if ( m_polygonInViewCollection && m_polygonInViewCollection->isChecked() ) + { + auto candidates = m_polygonInViewCollection->polygonsInView(); + for ( auto polygonInView : candidates ) + { + if ( polygonInView->isChecked() ) + { + polygonsInView.push_back( polygonInView ); + } + } + } + + if ( cellFilterCollection() && cellFilterCollection()->isActive() ) + { + auto cellFilterPolygonsInView = cellFilterCollection()->enabledCellFilterPolygons(); + 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() ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -455,23 +509,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_polygonInViewCollection->syncPolygonsInView(); } updateConnectedEditors(); diff --git a/ApplicationLibCode/ProjectDataModel/RimGridView.h b/ApplicationLibCode/ProjectDataModel/RimGridView.h index f3115e2f34..e7132010c8 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 @@ public: RimIntersectionResultsDefinitionCollection* separateSurfaceResultsCollection() const; RimWellMeasurementInViewCollection* measurementCollection() const; RimSeismicSectionCollection* seismicSectionCollection() const; + RimPolygonInViewCollection* polygonInViewCollection() const; virtual const RimPropertyFilterCollection* propertyFilterCollection() const = 0; @@ -68,7 +70,7 @@ public: bool isGridVisualizationMode() const override; void updateWellMeasurements(); - void updateSurfacesInViewTreeItems() override; + void updateViewTreeItems( RiaDefines::ItemIn3dView itemType ) override; protected: virtual void updateViewFollowingCellFilterUpdates(); @@ -78,6 +80,7 @@ protected: 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; @@ -90,6 +93,7 @@ protected: protected: cvf::ref m_surfaceVizModel; cvf::ref m_intersectionVizModel; + cvf::ref m_polygonVizModel; // Fields caf::PdmChildField m_intersectionCollection; @@ -104,10 +108,12 @@ protected: caf::PdmChildField m_cellFilterCollection; caf::PdmChildField m_overrideCellFilterCollection; caf::PdmChildField m_seismicSectionCollection; + caf::PdmChildField m_polygonInViewCollection; private: void onCreatePartCollectionFromSelection( cvf::Collection* parts ) override; +private: cvf::ref m_currentReservoirCellVisibility; bool m_previousGridModeMeshLinesWasFaults; }; 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 @@ public: caf::PdmChildField seismicDataCollection; caf::PdmChildField seismicViewCollection; caf::PdmChildField ensembleWellLogsCollection; + caf::PdmChildField polygonCollection; protected: void initAfterRead() override; diff --git a/ApplicationLibCode/ProjectDataModel/RimPlotAxisProperties.cpp b/ApplicationLibCode/ProjectDataModel/RimPlotAxisProperties.cpp index 9d4cf3cae0..25060d3655 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPlotAxisProperties.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimPlotAxisProperties.cpp @@ -731,7 +731,7 @@ void RimPlotAxisProperties::defineObjectEditorAttribute( QString uiConfigName, c if ( treeItemAttribute ) { treeItemAttribute->tags.clear(); - auto tag = caf::PdmUiTreeViewItemAttribute::Tag::create(); + auto tag = caf::PdmUiTreeViewItemAttribute::createTag(); tag->icon = caf::IconProvider( ":/chain.png" ); treeItemAttribute->tags.push_back( std::move( tag ) ); diff --git a/ApplicationLibCode/ProjectDataModel/RimPlotCurve.cpp b/ApplicationLibCode/ProjectDataModel/RimPlotCurve.cpp index 5e3a6143cf..5fb6ce2068 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPlotCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimPlotCurve.cpp @@ -1262,7 +1262,7 @@ void RimPlotCurve::defineObjectEditorAttribute( QString uiConfigName, caf::PdmUi if ( auto* treeItemAttribute = dynamic_cast( attribute ) ) { treeItemAttribute->tags.clear(); - auto tag = caf::PdmUiTreeViewItemAttribute::Tag::create(); + auto tag = caf::PdmUiTreeViewItemAttribute::createTag(); // Blend with background for a nice look auto backgroundColor = RiuGuiTheme::getColorByVariableName( "backgroundColor1" ); diff --git a/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.cpp b/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.cpp new file mode 100644 index 0000000000..8c04d6124c --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.cpp @@ -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. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimPolylinePickerInterface.h" + +#include "RimPolylineTarget.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimPolylinePickerInterface::scalingFactorForTarget() const +{ + return 1.0; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +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 ( !after && foundTarget ) after = wt; + + if ( !foundTarget ) before = wt; + } + + return { before, after }; +} diff --git a/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.h b/ApplicationLibCode/ProjectDataModel/RimPolylinePickerInterface.h index 5a99bed648..7dc6b61a9a 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: @@ -33,4 +38,7 @@ public: 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 ); }; diff --git a/ApplicationLibCode/ProjectDataModel/RimProject.cpp b/ApplicationLibCode/ProjectDataModel/RimProject.cpp index 2aec13c3fd..3405b3c75c 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,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 ( RiaApplication::enableDevelopmentFeatures() ) + { + if ( oilField->polygonCollection() ) uiTreeOrdering.add( oilField->polygonCollection() ); + } } uiTreeOrdering.add( colorLegendCollection() ); diff --git a/ApplicationLibCode/ProjectDataModel/RimRegularLegendConfig.cpp b/ApplicationLibCode/ProjectDataModel/RimRegularLegendConfig.cpp index 0a038c0a84..32e799bb2c 100644 --- a/ApplicationLibCode/ProjectDataModel/RimRegularLegendConfig.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimRegularLegendConfig.cpp @@ -203,8 +203,7 @@ RimRegularLegendConfig::RimRegularLegendConfig() m_categoryLegend = new caf::CategoryLegend( standardFont, m_categoryMapper.p() ); CAF_PDM_InitField( &m_resetUserDefinedValuesButton, "ResetDefaultValues", false, "Reset Default Values" ); - m_resetUserDefinedValuesButton.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); - m_resetUserDefinedValuesButton.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_resetUserDefinedValuesButton ); CAF_PDM_InitField( &m_centerLegendAroundZero, "CenterLegendAroundZero", false, "Center Legend Around Zero" ); diff --git a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculation.cpp b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculation.cpp index 111c7b7bad..c83a240de3 100644 --- a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculation.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculation.cpp @@ -27,26 +27,17 @@ #include "RifSummaryReaderInterface.h" #include "RimDataSourceSteppingTools.h" -#include "RimObservedDataCollection.h" -#include "RimObservedSummaryData.h" #include "RimProject.h" #include "RimSummaryAddress.h" #include "RimSummaryCalculationCollection.h" #include "RimSummaryCalculationVariable.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" -#include "RimSummaryCaseMainCollection.h" #include "RimSummaryCurve.h" #include "RimSummaryMultiPlot.h" #include "RimSummaryMultiPlotCollection.h" #include "RimSummaryPlot.h" -#include "RiuExpressionContextMenuManager.h" - #include "cafPdmUiCheckBoxEditor.h" -#include "cafPdmUiLineEditor.h" -#include "cafPdmUiTableViewEditor.h" -#include "cafPdmUiTextEditor.h" #include "expressionparser/ExpressionParser.h" @@ -402,35 +393,6 @@ std::optional, std::vector>> //-------------------------------------------------------------------------------------------------- void RimSummaryCalculation::updateDependentObjects() { - RimSummaryCalculationCollection* calcColl = firstAncestorOrThisOfTypeAsserted(); - calcColl->rebuildCaseMetaData(); - - // Refresh data sources tree. - // TODO: refresh too much: would be enough to only refresh calculated resutls. - RimSummaryCaseMainCollection* summaryCaseCollection = RiaSummaryTools::summaryCaseMainCollection(); - auto summaryCases = summaryCaseCollection->allSummaryCases(); - for ( RimSummaryCase* summaryCase : summaryCases ) - { - summaryCase->createSummaryReaderInterface(); - summaryCase->createRftReaderInterface(); - summaryCase->refreshMetaData(); - } - - RimObservedDataCollection* observedDataCollection = RiaSummaryTools::observedDataCollection(); - auto observedData = observedDataCollection->allObservedSummaryData(); - for ( auto obs : observedData ) - { - obs->createSummaryReaderInterface(); - obs->createRftReaderInterface(); - obs->refreshMetaData(); - } - - auto summaryCaseCollections = summaryCaseCollection->summaryCaseCollections(); - for ( RimSummaryCaseCollection* summaryCaseCollection : summaryCaseCollections ) - { - summaryCaseCollection->refreshMetaData(); - } - RimSummaryMultiPlotCollection* summaryPlotCollection = RiaSummaryTools::summaryMultiPlotCollection(); for ( auto multiPlot : summaryPlotCollection->multiPlots() ) { @@ -438,7 +400,7 @@ void RimSummaryCalculation::updateDependentObjects() { bool plotContainsCalculatedCurves = false; - for ( RimSummaryCurve* sumCurve : sumPlot->summaryCurves() ) + for ( RimSummaryCurve* sumCurve : sumPlot->summaryAndEnsembleCurves() ) { if ( sumCurve->summaryAddressY().isCalculated() ) { @@ -461,6 +423,7 @@ void RimSummaryCalculation::updateDependentObjects() //-------------------------------------------------------------------------------------------------- void RimSummaryCalculation::removeDependentObjects() { + updateDependentObjects(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationCollection.cpp index e8e8cf5eda..f2de3ba444 100644 --- a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationCollection.cpp @@ -18,7 +18,15 @@ #include "RimSummaryCalculationCollection.h" +#include "RiaSummaryTools.h" + +#include "RifSummaryReaderInterface.h" + +#include "RimObservedSummaryData.h" #include "RimSummaryCalculation.h" +#include "RimSummaryCase.h" +#include "RimSummaryCaseCollection.h" +#include "RimSummaryCaseMainCollection.h" CAF_PDM_SOURCE_INIT( RimSummaryCalculationCollection, "RimSummaryCalculationCollection" ); //-------------------------------------------------------------------------------------------------- @@ -37,12 +45,53 @@ RimSummaryCalculation* RimSummaryCalculationCollection::createCalculation() cons return new RimSummaryCalculation; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCalculationCollection::updateDataDependingOnCalculations() +{ + // Refresh data sources tree + // Refresh meta data for all summary cases and rebuild AddressNodes in the summary tree + RimSummaryCaseMainCollection* summaryCaseCollection = RiaSummaryTools::summaryCaseMainCollection(); + auto summaryCases = summaryCaseCollection->allSummaryCases(); + for ( RimSummaryCase* summaryCase : summaryCases ) + { + if ( !summaryCase ) continue; + + if ( auto reader = summaryCase->summaryReader() ) + { + reader->buildMetaData(); + summaryCase->onCalculationUpdated(); + } + } + + RimObservedDataCollection* observedDataCollection = RiaSummaryTools::observedDataCollection(); + auto observedData = observedDataCollection->allObservedSummaryData(); + for ( auto obs : observedData ) + { + if ( !obs ) continue; + + if ( auto reader = obs->summaryReader() ) + { + reader->buildMetaData(); + obs->onCalculationUpdated(); + } + } + + auto summaryCaseCollections = summaryCaseCollection->summaryCaseCollections(); + for ( RimSummaryCaseCollection* summaryCaseCollection : summaryCaseCollections ) + { + summaryCaseCollection->onCalculationUpdated(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimSummaryCalculationCollection::rebuildCaseMetaData() { ensureValidCalculationIds(); + updateDataDependingOnCalculations(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationCollection.h b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationCollection.h index 8d7f21d06c..e4953189ba 100644 --- a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationCollection.h +++ b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationCollection.h @@ -42,5 +42,6 @@ public: RimSummaryCalculation* createCalculation() const override; private: + void updateDataDependingOnCalculations(); void initAfterRead() override; }; diff --git a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationVariable.cpp b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationVariable.cpp index 1578e48f6b..3c90249bef 100644 --- a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationVariable.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationVariable.cpp @@ -47,8 +47,7 @@ RimSummaryCalculationVariable::RimSummaryCalculationVariable() CAF_PDM_InitObject( "RimSummaryCalculationVariable", ":/octave.png" ); CAF_PDM_InitFieldNoDefault( &m_button, "PushButton", "" ); - m_button.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); - m_button.xmlCapability()->disableIO(); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_button ); CAF_PDM_InitFieldNoDefault( &m_case, "SummaryCase", "Summary Case" ); CAF_PDM_InitFieldNoDefault( &m_summaryAddress, "SummaryAddress", "Summary Address" ); diff --git a/ApplicationLibCode/ProjectDataModel/RimTernaryLegendConfig.cpp b/ApplicationLibCode/ProjectDataModel/RimTernaryLegendConfig.cpp index 45df0d9e93..2ac160a382 100644 --- a/ApplicationLibCode/ProjectDataModel/RimTernaryLegendConfig.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimTernaryLegendConfig.cpp @@ -59,15 +59,15 @@ RimTernaryLegendConfig::RimTernaryLegendConfig() "" ); CAF_PDM_InitFieldNoDefault( &applyLocalMinMax, "m_applyLocalMinMax", "" ); - caf::PdmUiPushButtonEditor::configureEditorForField( &applyLocalMinMax ); + caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &applyLocalMinMax ); applyLocalMinMax = false; CAF_PDM_InitFieldNoDefault( &applyGlobalMinMax, "m_applyGlobalMinMax", "" ); - caf::PdmUiPushButtonEditor::configureEditorForField( &applyGlobalMinMax ); + caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &applyGlobalMinMax ); applyGlobalMinMax = false; CAF_PDM_InitFieldNoDefault( &applyFullRangeMinMax, "m_applyFullRangeMinMax", "" ); - caf::PdmUiPushButtonEditor::configureEditorForField( &applyFullRangeMinMax ); + caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &applyFullRangeMinMax ); applyFullRangeMinMax = false; CAF_PDM_InitFieldNoDefault( &ternaryRangeSummary, "ternaryRangeSummary", "Range summary" ); diff --git a/ApplicationLibCode/ProjectDataModel/RimTimeStepFilter.cpp b/ApplicationLibCode/ProjectDataModel/RimTimeStepFilter.cpp index 4d4f42d7c9..fcdca27964 100644 --- a/ApplicationLibCode/ProjectDataModel/RimTimeStepFilter.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimTimeStepFilter.cpp @@ -89,7 +89,7 @@ RimTimeStepFilter::RimTimeStepFilter() caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_readOnlyLastFrame ); CAF_PDM_InitFieldNoDefault( &m_applyReloadOfCase, "ApplyReloadOfCase", "" ); - caf::PdmUiPushButtonEditor::configureEditorForField( &m_applyReloadOfCase ); + caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_applyReloadOfCase ); } //-------------------------------------------------------------------------------------------------- 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 @@ public: 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 @@ public: static RimWellPath* firstWellPath(); static RimSurfaceCollection* surfaceCollection(); + static RimPolygonCollection* polygonCollection(); static void timeStepsForCase( RimCase* gridCase, QList* options ); diff --git a/ApplicationLibCode/ProjectDataModel/RimUserDefinedCalculation.cpp b/ApplicationLibCode/ProjectDataModel/RimUserDefinedCalculation.cpp index 6601ac4588..cdfdb98b86 100644 --- a/ApplicationLibCode/ProjectDataModel/RimUserDefinedCalculation.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimUserDefinedCalculation.cpp @@ -53,8 +53,7 @@ RimUserDefinedCalculation::RimUserDefinedCalculation() m_expression.uiCapability()->setUiEditorTypeName( caf::PdmUiTextEditor::uiEditorTypeName() ); CAF_PDM_InitFieldNoDefault( &m_helpButton, "HelpButton", "" ); - caf::PdmUiPushButtonEditor::configureEditorForField( &m_helpButton ); - m_helpButton.xmlCapability()->disableIO(); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_helpButton ); CAF_PDM_InitFieldNoDefault( &m_helpText, "Label", diff --git a/ApplicationLibCode/ProjectDataModel/RimUserDefinedCalculationCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimUserDefinedCalculationCollection.cpp index b30dcf0ec4..b8572c84b1 100644 --- a/ApplicationLibCode/ProjectDataModel/RimUserDefinedCalculationCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimUserDefinedCalculationCollection.cpp @@ -103,9 +103,11 @@ RimUserDefinedCalculation* RimUserDefinedCalculationCollection::addCalculationCo //-------------------------------------------------------------------------------------------------- void RimUserDefinedCalculationCollection::deleteCalculation( RimUserDefinedCalculation* calculation ) { - calculation->removeDependentObjects(); m_calculations.removeChild( calculation ); + // Call this function after the object is removed from the collection + calculation->removeDependentObjects(); + rebuildCaseMetaData(); delete calculation; diff --git a/ApplicationLibCode/ProjectDataModel/RimViewWindow.cpp b/ApplicationLibCode/ProjectDataModel/RimViewWindow.cpp index 7300d1220a..516128c6c2 100644 --- a/ApplicationLibCode/ProjectDataModel/RimViewWindow.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimViewWindow.cpp @@ -319,7 +319,7 @@ void RimViewWindow::defineObjectEditorAttribute( QString uiConfigName, caf::PdmU if ( treeItemAttribute && RiaPreferencesSystem::current()->showViewIdInProjectTree() && id() >= 0 ) { treeItemAttribute->tags.clear(); - auto tag = caf::PdmUiTreeViewItemAttribute::Tag::create(); + auto tag = caf::PdmUiTreeViewItemAttribute::createTag(); tag->text = QString( "%1" ).arg( id() ); cvf::Color3f viewColor = RiaColorTables::contrastCategoryPaletteColors().cycledColor3f( (size_t)id() ); cvf::Color3f viewTextColor = RiaColorTools::contrastColor( viewColor ); diff --git a/ApplicationLibCode/ProjectDataModel/Seismic/RimSeismicSection.cpp b/ApplicationLibCode/ProjectDataModel/Seismic/RimSeismicSection.cpp index eccc174573..6a34ebdf63 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" @@ -84,12 +85,10 @@ RimSeismicSection::RimSeismicSection() CAF_PDM_InitFieldNoDefault( &m_wellPath, "WellPath", "Well Path" ); CAF_PDM_InitField( &m_enablePicking, "EnablePicking", false, "" ); - caf::PdmUiPushButtonEditor::configureEditorForField( &m_enablePicking ); - m_enablePicking.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosType::HIDDEN ); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_enablePicking ); CAF_PDM_InitField( &m_showImage, "ShowImage", false, "" ); - caf::PdmUiPushButtonEditor::configureEditorForField( &m_showImage ); - m_showImage.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosType::HIDDEN ); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_showImage ); CAF_PDM_InitFieldNoDefault( &m_targets, "Targets", "Targets" ); m_targets.uiCapability()->setUiEditorTypeName( caf::PdmUiTableViewEditor::uiEditorTypeName() ); @@ -599,7 +598,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 ); } 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 @@ protected: void setDefaultView() override; - void updateSurfacesInViewTreeItems() override; + void updateViewTreeItems( RiaDefines::ItemIn3dView itemType ) override; private: caf::PdmChildField m_surfaceCollection; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimCalculatedSummaryCurveReader.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimCalculatedSummaryCurveReader.cpp index e5efa6f85e..22f0a32fca 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimCalculatedSummaryCurveReader.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimCalculatedSummaryCurveReader.cpp @@ -87,11 +87,11 @@ void RifCalculatedSummaryCurveReader::buildMetaData() for ( RimUserDefinedCalculation* calc : m_calculationCollection->calculations() ) { - RimSummaryCalculation* sumCalc = dynamic_cast( calc ); + auto* sumCalc = dynamic_cast( calc ); CAF_ASSERT( sumCalc ); const auto& allAddresses = sumCalc->allAddressesForSummaryCase( m_summaryCase ); - for ( auto calculationAddress : allAddresses ) + for ( const auto& calculationAddress : allAddresses ) { if ( calculationAddress.address().isValid() ) { diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimCalculatedSummaryCurveReader.h b/ApplicationLibCode/ProjectDataModel/Summary/RimCalculatedSummaryCurveReader.h index b8f036a5f2..5eb786d75a 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimCalculatedSummaryCurveReader.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimCalculatedSummaryCurveReader.h @@ -39,7 +39,7 @@ public: std::pair> values( const RifEclipseSummaryAddress& resultAddress ) const override; std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override; - void buildMetaData(); + void buildMetaData() override; RiaDefines::EclipseUnitSystem unitSystem() const override; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimDerivedEnsembleCaseCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimDerivedEnsembleCaseCollection.cpp index 1da0afbd4f..3d09020a86 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimDerivedEnsembleCaseCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimDerivedEnsembleCaseCollection.cpp @@ -67,9 +67,7 @@ RimDerivedEnsembleCaseCollection::RimDerivedEnsembleCaseCollection() CAF_PDM_InitFieldNoDefault( &m_operator, "Operator", "Operator" ); CAF_PDM_InitField( &m_swapEnsemblesButton, "SwapEnsembles", false, "SwapEnsembles" ); - m_swapEnsemblesButton.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); - m_swapEnsemblesButton.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); - m_swapEnsemblesButton.xmlCapability()->disableIO(); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_swapEnsemblesButton ); CAF_PDM_InitField( &m_caseCount, "CaseCount", QString( "" ), "Matching Cases" ); m_caseCount.uiCapability()->setUiReadOnly( true ); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveFilter.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveFilter.cpp index e56e99938b..0c388ca2ef 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveFilter.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveFilter.cpp @@ -87,8 +87,7 @@ RimEnsembleCurveFilter::RimEnsembleCurveFilter() m_objectiveValuesSummaryAddresses.uiCapability()->setUiTreeChildrenHidden( true ); CAF_PDM_InitFieldNoDefault( &m_objectiveValuesSelectSummaryAddressPushButton, "SelectObjectiveSummaryAddress", "" ); - caf::PdmUiPushButtonEditor::configureEditorForField( &m_objectiveValuesSelectSummaryAddressPushButton ); - m_objectiveValuesSelectSummaryAddressPushButton.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_objectiveValuesSelectSummaryAddressPushButton ); m_objectiveValuesSelectSummaryAddressPushButton = false; CAF_PDM_InitFieldNoDefault( &m_objectiveFunction, "ObjectiveFunction", "Objective Function" ); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveFilterCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveFilterCollection.cpp index 066a1f106d..17f4f0832e 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveFilterCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveFilterCollection.cpp @@ -47,9 +47,8 @@ RimEnsembleCurveFilterCollection::RimEnsembleCurveFilterCollection() m_filters.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); CAF_PDM_InitFieldNoDefault( &m_newFilterButton, "NewEnsembleFilter", "New Filter" ); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_newFilterButton ); m_newFilterButton = false; - m_newFilterButton.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); - m_newFilterButton.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 587db0da3a..5cf84dff46 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -139,8 +139,7 @@ RimEnsembleCurveSet::RimEnsembleCurveSet() m_yValuesSummaryAddress = new RimSummaryAddress; CAF_PDM_InitFieldNoDefault( &m_yPushButtonSelectSummaryAddress, "SelectAddress", "" ); - caf::PdmUiPushButtonEditor::configureEditorForField( &m_yPushButtonSelectSummaryAddress ); - m_yPushButtonSelectSummaryAddress.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_yPushButtonSelectSummaryAddress ); m_yPushButtonSelectSummaryAddress = false; CAF_PDM_InitFieldNoDefault( &m_resampling, "Resampling", "Resampling" ); @@ -191,8 +190,7 @@ RimEnsembleCurveSet::RimEnsembleCurveSet() m_objectiveValuesSummaryAddresses.uiCapability()->setUiTreeChildrenHidden( true ); CAF_PDM_InitFieldNoDefault( &m_objectiveValuesSelectSummaryAddressPushButton, "SelectObjectiveSummaryAddress", "" ); - caf::PdmUiPushButtonEditor::configureEditorForField( &m_objectiveValuesSelectSummaryAddressPushButton ); - m_objectiveValuesSelectSummaryAddressPushButton.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_objectiveValuesSelectSummaryAddressPushButton ); m_objectiveValuesSelectSummaryAddressPushButton = false; CAF_PDM_InitFieldNoDefault( &m_customObjectiveFunction, "CustomObjectiveFunction", "Objective Function" ); @@ -1064,7 +1062,7 @@ void RimEnsembleCurveSet::defineObjectEditorAttribute( QString uiConfigName, caf if ( auto* treeItemAttribute = dynamic_cast( attribute ) ) { treeItemAttribute->tags.clear(); - auto tag = caf::PdmUiTreeViewItemAttribute::Tag::create(); + auto tag = caf::PdmUiTreeViewItemAttribute::createTag(); tag->bgColor = RiaColorTools::toQColor( m_colorForRealizations ); tag->fgColor = RiaColorTools::toQColor( m_statistics->color() ); tag->text = "---"; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.cpp index fceb1e0f5a..c27e0140a6 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.cpp @@ -99,7 +99,7 @@ RimSummaryAddressCollection::~RimSummaryAddressCollection() //-------------------------------------------------------------------------------------------------- bool RimSummaryAddressCollection::hasDataVector( const QString quantityName ) const { - for ( auto& address : m_adresses ) + for ( const auto& address : m_adresses ) { if ( address->quantityName() == quantityName ) return true; } @@ -346,6 +346,32 @@ void RimSummaryAddressCollection::deleteChildren() m_subfolders.deleteChildren(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryAddressCollection::deleteCalculatedObjects() +{ + std::vector toDelete; + for ( const auto& a : m_adresses ) + { + if ( a->address().isCalculated() ) + { + toDelete.push_back( a ); + } + } + + for ( auto a : toDelete ) + { + m_adresses.removeChild( a ); + delete a; + } + + for ( auto& folder : m_subfolders ) + { + folder->deleteCalculatedObjects(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.h index b0b2f02a92..9381c94813 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.h @@ -66,6 +66,7 @@ public: void updateFolderStructure( const std::set& addresses, int caseId, int ensembleId = -1 ); void deleteChildren(); + void deleteCalculatedObjects(); bool isEmpty() const; bool isEnsemble() const; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.cpp index 0683514bce..5bc5789dd9 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.cpp @@ -64,8 +64,7 @@ RimSummaryAddressSelector::RimSummaryAddressSelector() m_summaryAddress.uiCapability()->setUiTreeChildrenHidden( true ); CAF_PDM_InitFieldNoDefault( &m_pushButtonSelectSummaryAddress, "SelectAddress", "" ); - caf::PdmUiPushButtonEditor::configureEditorForField( &m_pushButtonSelectSummaryAddress ); - m_pushButtonSelectSummaryAddress.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_pushButtonSelectSummaryAddress ); m_pushButtonSelectSummaryAddress = false; CAF_PDM_InitFieldNoDefault( &m_plotAxisProperties, "PlotAxisProperties", "Axis" ); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.cpp index dd301f6d83..7171f50e21 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.cpp @@ -400,3 +400,20 @@ void RimSummaryCase::refreshMetaData() buildChildNodes(); updateConnectedEditors(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCase::onCalculationUpdated() +{ + // Delete all calculated address objects + m_dataVectorFolders->deleteCalculatedObjects(); + + if ( auto reader = summaryReader() ) + { + auto addresses = reader->allResultAddresses(); + m_dataVectorFolders->updateFolderStructure( addresses, m_caseId ); + } + + updateConnectedEditors(); +} diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.h index 1ea198777a..d305e9d73c 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.h @@ -66,6 +66,7 @@ public: int caseId() const; void refreshMetaData(); + void onCalculationUpdated(); virtual void createSummaryReaderInterface() = 0; virtual void createRftReaderInterface() {} diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp index cc93a84820..6e5fc541e7 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp @@ -22,30 +22,23 @@ #include "RiaFieldHandleTools.h" #include "RiaLogging.h" #include "RiaStatisticsTools.h" -#include "RiaStdStringTools.h" #include "RiaSummaryAddressAnalyzer.h" -#include "RiaWeightedMeanCalculator.h" - -#include "RicfCommandObject.h" #include "RifReaderRftInterface.h" #include "RifSummaryReaderInterface.h" -#include "RimAnalysisPlotDataEntry.h" #include "RimDerivedEnsembleCaseCollection.h" #include "RimEnsembleCurveSet.h" #include "RimProject.h" #include "RimSummaryAddressCollection.h" -#include "RimSummaryCalculationCollection.h" #include "RimSummaryCase.h" #include "cafPdmFieldScriptingCapability.h" +#include "cafPdmObjectScriptingCapability.h" #include "cafPdmUiTreeOrdering.h" -#include #include -#include #include CAF_PDM_SOURCE_INIT( RimSummaryCaseCollection, "SummaryCaseSubCollection" ); @@ -284,7 +277,7 @@ void RimSummaryCaseCollection::setAsEnsemble( bool isEnsemble ) calculateEnsembleParametersIntersectionHash(); } - refreshMetaData(); + buildMetaData(); } } @@ -1155,13 +1148,24 @@ void RimSummaryCaseCollection::buildChildNodes() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCaseCollection::refreshMetaData() +void RimSummaryCaseCollection::buildMetaData() { clearChildNodes(); buildChildNodes(); updateConnectedEditors(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCaseCollection::onCalculationUpdated() +{ + m_dataVectorFolders->deleteCalculatedObjects(); + m_dataVectorFolders->updateFolderStructure( ensembleSummaryAddresses(), -1, m_ensembleId ); + + updateConnectedEditors(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h index 725f7d376a..b2798c954e 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h @@ -19,20 +19,17 @@ #pragma once #include "RiaDefines.h" + #include "RifEclipseSummaryAddress.h" #include "RigEnsembleParameter.h" -#include "RimObjectiveFunction.h" - #include "cafPdmChildArrayField.h" #include "cafPdmChildField.h" #include "cafPdmField.h" #include "cafPdmObject.h" #include "cafPdmProxyValueField.h" -#include "cvfObject.h" - #include #include @@ -103,7 +100,7 @@ public: RiaDefines::EclipseUnitSystem unitSystem() const; - void refreshMetaData(); + void onCalculationUpdated(); void updateReferringCurveSets(); @@ -127,6 +124,7 @@ private: void onCaseNameChanged( const SignalEmitter* emitter ); + void buildMetaData(); void buildChildNodes(); void clearChildNodes(); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp index db65e2582a..3fa046e92a 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp @@ -79,8 +79,7 @@ RimSummaryCurve::RimSummaryCurve() CAF_PDM_InitFieldNoDefault( &m_yValuesSummaryAddress, "SummaryAddress", "Summary Address" ); CAF_PDM_InitFieldNoDefault( &m_yPushButtonSelectSummaryAddress, "SelectAddress", "" ); - caf::PdmUiPushButtonEditor::configureEditorForField( &m_yPushButtonSelectSummaryAddress ); - m_yPushButtonSelectSummaryAddress.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_yPushButtonSelectSummaryAddress ); m_yPushButtonSelectSummaryAddress = false; m_yValuesSummaryAddress = new RimSummaryAddress; @@ -105,9 +104,7 @@ RimSummaryCurve::RimSummaryCurve() CAF_PDM_InitFieldNoDefault( &m_xValuesSummaryAddress, "SummaryAddressX", "Summary Address" ); CAF_PDM_InitFieldNoDefault( &m_xPushButtonSelectSummaryAddress, "SelectAddressX", "" ); - caf::PdmUiPushButtonEditor::configureEditorForField( &m_xPushButtonSelectSummaryAddress ); - m_xPushButtonSelectSummaryAddress.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); - + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_xPushButtonSelectSummaryAddress ); m_xPushButtonSelectSummaryAddress = false; m_xValuesSummaryAddress = new RimSummaryAddress; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp index 3b253deae0..8ea9fda02b 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp @@ -57,8 +57,7 @@ RimSummaryCurveCollection::RimSummaryCurveCollection() m_showCurves.uiCapability()->setUiHidden( true ); CAF_PDM_InitField( &m_editPlot, "EditPlot", false, "" ); - m_editPlot.xmlCapability()->disableIO(); - m_editPlot.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_editPlot ); CAF_PDM_InitFieldNoDefault( &m_ySourceStepping, "YSourceStepping", "" ); m_ySourceStepping = new RimSummaryPlotSourceStepping; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.cpp index e81c15426d..bac202cdc3 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.cpp @@ -114,33 +114,27 @@ RimSummaryMultiPlot::RimSummaryMultiPlot() CAF_PDM_InitField( &m_autoSubPlotTitle, "AutoSubPlotTitle", true, "Auto Sub Plot Title" ); CAF_PDM_InitField( &m_createPlotDuplicate, "DuplicatePlot", false, "", "", "Duplicate Plot" ); - m_createPlotDuplicate.xmlCapability()->disableIO(); - m_createPlotDuplicate.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_createPlotDuplicate ); m_createPlotDuplicate.uiCapability()->setUiIconFromResourceString( ":/Copy.svg" ); CAF_PDM_InitField( &m_disableWheelZoom, "DisableWheelZoom", true, "", "", "Disable Mouse Wheel Zooming in Multi Summary Plot" ); - m_disableWheelZoom.xmlCapability()->disableIO(); - m_disableWheelZoom.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_disableWheelZoom ); m_disableWheelZoom.uiCapability()->setUiIconFromResourceString( ":/DisableZoom.png" ); CAF_PDM_InitField( &m_appendNextPlot, "AppendNextPlot", false, "", "", "Step Next and Add to New Plot" ); - m_appendNextPlot.xmlCapability()->disableIO(); - m_appendNextPlot.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_appendNextPlot ); m_appendNextPlot.uiCapability()->setUiIconFromResourceString( ":/AppendNext.png" ); CAF_PDM_InitField( &m_appendPrevPlot, "AppendPrevPlot", false, "", "", "Step Previous and Add to New Plot" ); - m_appendPrevPlot.xmlCapability()->disableIO(); - m_appendPrevPlot.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_appendPrevPlot ); m_appendPrevPlot.uiCapability()->setUiIconFromResourceString( ":/AppendPrev.png" ); CAF_PDM_InitField( &m_appendNextCurve, "AppendNextCurve", false, "", "", "Step Next and Add Curve to Plot" ); - m_appendNextCurve.xmlCapability()->disableIO(); - m_appendNextCurve.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_appendNextCurve ); m_appendNextCurve.uiCapability()->setUiIconFromResourceString( ":/AppendNextCurve.png" ); CAF_PDM_InitField( &m_appendPrevCurve, "AppendPrevCurve", false, "", "", "Step Previous and Add Curve to Plot" ); - m_appendPrevCurve.xmlCapability()->disableIO(); - m_appendPrevCurve.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_appendPrevCurve ); m_appendPrevCurve.uiCapability()->setUiIconFromResourceString( ":/AppendPrevCurve.png" ); CAF_PDM_InitField( &m_linkSubPlotAxes, "LinkSubPlotAxes", false, "Link Y Axes" ); @@ -155,8 +149,7 @@ RimSummaryMultiPlot::RimSummaryMultiPlot() CAF_PDM_InitFieldNoDefault( &m_axisRangeAggregation, "AxisRangeAggregation", "Y Axis Range" ); CAF_PDM_InitField( &m_hidePlotsWithValuesBelow, "HidePlotsWithValuesBelow", false, "" ); - m_hidePlotsWithValuesBelow.xmlCapability()->disableIO(); - m_hidePlotsWithValuesBelow.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_hidePlotsWithValuesBelow ); CAF_PDM_InitField( &m_plotFilterYAxisThreshold, "PlotFilterYAxisThreshold", 0.0, "Y-Axis Filter Threshold" ); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotManager.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotManager.cpp index a3f9be3ff2..c71a20221e 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotManager.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotManager.cpp @@ -93,16 +93,13 @@ RimSummaryPlotManager::RimSummaryPlotManager() m_includeDiffCurves.uiCapability()->setUiEditorTypeName( caf::PdmUiNativeCheckBoxEditor::uiEditorTypeName() ); CAF_PDM_InitFieldNoDefault( &m_pushButtonReplace, "PushButtonReplace", "Replace (CTRL + Enter)" ); - m_pushButtonReplace.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); - m_pushButtonReplace.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_pushButtonReplace ); CAF_PDM_InitFieldNoDefault( &m_pushButtonNewPlot, "PushButtonNewPlot", "New (Alt + Enter)" ); - m_pushButtonNewPlot.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); - m_pushButtonNewPlot.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_pushButtonNewPlot ); CAF_PDM_InitFieldNoDefault( &m_pushButtonAppend, "PushButtonAppend", "Append (Shift + Enter)" ); - m_pushButtonAppend.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); - m_pushButtonAppend.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_pushButtonAppend ); CAF_PDM_InitFieldNoDefault( &m_labelA, "LabelA", "" ); m_labelA.uiCapability()->setUiEditorTypeName( caf::PdmUiLabelEditor::uiEditorTypeName() ); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryTimeAxisProperties.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryTimeAxisProperties.cpp index aa706887e0..4d10357f62 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryTimeAxisProperties.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryTimeAxisProperties.cpp @@ -204,7 +204,7 @@ void RimSummaryTimeAxisProperties::defineObjectEditorAttribute( QString uiConfig if ( treeItemAttribute ) { treeItemAttribute->tags.clear(); - auto tag = caf::PdmUiTreeViewItemAttribute::Tag::create(); + auto tag = caf::PdmUiTreeViewItemAttribute::createTag(); tag->icon = caf::IconProvider( ":/chain.png" ); treeItemAttribute->tags.push_back( std::move( tag ) ); 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 ) diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTools.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTools.cpp index b88cfdb79b..b6ac8e17f7 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTools.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTools.cpp @@ -178,27 +178,48 @@ QList RimRftTools::segmentBranchIndexOptions( RifReaderR //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimRftTools::seglenstValues( RifReaderRftInterface* readerRft, - const QString& wellName, - const QDateTime& dateTime, - int segmentBranchIndex, - RiaDefines::RftBranchType segmentBranchType ) +std::vector RimRftTools::segmentStartMdValues( RifReaderRftInterface* readerRft, + const QString& wellName, + const QDateTime& dateTime, + int segmentBranchIndex, + RiaDefines::RftBranchType segmentBranchType ) { - std::vector seglenstValues; + std::vector values; auto resultNameSeglenst = RifEclipseRftAddress::createBranchSegmentAddress( wellName, dateTime, RiaDefines::segmentStartDepthResultName(), segmentBranchIndex, segmentBranchType ); - readerRft->values( resultNameSeglenst, &seglenstValues ); + readerRft->values( resultNameSeglenst, &values ); - if ( seglenstValues.size() > 2 ) + if ( values.size() > 2 ) { // Segment 1 has zero length, assign seglenst to the start value of segment 2 // Ref mail dated June 10, 2022, topic "SELENST fix" - seglenstValues[0] = seglenstValues[1]; + values[0] = values[1]; } - return seglenstValues; + return values; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimRftTools::segmentEndMdValues( RifReaderRftInterface* readerRft, + const QString& wellName, + const QDateTime& dateTime, + int segmentBranchIndex, + RiaDefines::RftBranchType segmentBranchType ) +{ + std::vector values; + + auto resultNameSeglenst = RifEclipseRftAddress::createBranchSegmentAddress( wellName, + dateTime, + RiaDefines::segmentEndDepthResultName(), + segmentBranchIndex, + segmentBranchType ); + readerRft->values( resultNameSeglenst, &values ); + + return values; } diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTools.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTools.h index c73e4474e2..acc7f79437 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTools.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTools.h @@ -46,9 +46,15 @@ public: const QDateTime& timeStep, RiaDefines::RftBranchType branchType ); - static std::vector seglenstValues( RifReaderRftInterface* readerRft, - const QString& wellName, - const QDateTime& dateTime, - int segmentBranchIndex, - RiaDefines::RftBranchType segmentBranchType ); + static std::vector segmentStartMdValues( RifReaderRftInterface* readerRft, + const QString& wellName, + const QDateTime& dateTime, + int segmentBranchIndex, + RiaDefines::RftBranchType segmentBranchType ); + + static std::vector segmentEndMdValues( RifReaderRftInterface* readerRft, + const QString& wellName, + const QDateTime& dateTime, + int segmentBranchIndex, + RiaDefines::RftBranchType segmentBranchType ); }; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTopologyCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTopologyCurve.cpp index 771eefbf2d..e0e638839b 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTopologyCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTopologyCurve.cpp @@ -48,6 +48,15 @@ void caf::AppEnum::setUp() setDefault( RimRftTopologyCurve::CurveType::TUBING ); } +template <> +void caf::AppEnum::setUp() +{ + addItem( RimRftTopologyCurve::SymbolLocationType::START, "START", "Start" ); + addItem( RimRftTopologyCurve::SymbolLocationType::MID, "MID", "Midpoint" ); + addItem( RimRftTopologyCurve::SymbolLocationType::END, "END", "End" ); + + setDefault( RimRftTopologyCurve::SymbolLocationType::END ); +} } // End namespace caf @@ -68,6 +77,7 @@ RimRftTopologyCurve::RimRftTopologyCurve() CAF_PDM_InitFieldNoDefault( &m_segmentBranchType, "SegmentBranchType", "Completion" ); CAF_PDM_InitFieldNoDefault( &m_curveType, "CurveType", "Curve Type" ); + CAF_PDM_InitFieldNoDefault( &m_symbolLocation, "SymbolLocation", "Symbol Location on Segment" ); } //-------------------------------------------------------------------------------------------------- @@ -221,6 +231,7 @@ void RimRftTopologyCurve::defineUiOrdering( QString uiConfigName, caf::PdmUiOrde curveDataGroup->add( &m_wellName ); curveDataGroup->add( &m_timeStep ); curveDataGroup->add( &m_curveType ); + curveDataGroup->add( &m_symbolLocation ); curveDataGroup->add( &m_segmentBranchIndex ); curveDataGroup->add( &m_segmentBranchType ); @@ -289,8 +300,32 @@ void RimRftTopologyCurve::onLoadDataAndUpdate( bool updateParentPlot ) std::vector depths; std::vector propertyValues; - std::vector seglenstValues = - RimRftTools::seglenstValues( rftReader, m_wellName, m_timeStep, -1, RiaDefines::RftBranchType::RFT_UNKNOWN ); + std::vector symbolLocationDepths; + if ( m_symbolLocation() == SymbolLocationType::START ) + { + symbolLocationDepths = + RimRftTools::segmentStartMdValues( rftReader, m_wellName, m_timeStep, -1, RiaDefines::RftBranchType::RFT_UNKNOWN ); + } + else if ( m_symbolLocation() == SymbolLocationType::MID ) + { + symbolLocationDepths = + RimRftTools::segmentStartMdValues( rftReader, m_wellName, m_timeStep, -1, RiaDefines::RftBranchType::RFT_UNKNOWN ); + auto endDepths = + RimRftTools::segmentEndMdValues( rftReader, m_wellName, m_timeStep, -1, RiaDefines::RftBranchType::RFT_UNKNOWN ); + + if ( symbolLocationDepths.size() == endDepths.size() ) + { + for ( size_t i = 0; i < symbolLocationDepths.size(); ++i ) + { + symbolLocationDepths[i] = ( symbolLocationDepths[i] + endDepths[i] ) / 2.0; + } + } + } + else if ( m_symbolLocation() == SymbolLocationType::END ) + { + symbolLocationDepths = + RimRftTools::segmentEndMdValues( rftReader, m_wellName, m_timeStep, -1, RiaDefines::RftBranchType::RFT_UNKNOWN ); + } auto segment = rftReader->segmentForWell( m_wellName, m_timeStep ); auto segmentIndices = segment.segmentIndicesForBranchIndex( m_segmentBranchIndex(), m_segmentBranchType() ); @@ -317,7 +352,7 @@ void RimRftTopologyCurve::onLoadDataAndUpdate( bool updateParentPlot ) for ( auto segmentIndex : packerSegmentIndices ) { - depths.push_back( seglenstValues[segmentIndex] ); + depths.push_back( symbolLocationDepths[segmentIndex] ); propertyValues.push_back( curveValue ); } @@ -326,7 +361,7 @@ void RimRftTopologyCurve::onLoadDataAndUpdate( bool updateParentPlot ) { for ( auto segmentIndex : segmentIndices ) { - depths.push_back( seglenstValues[segmentIndex] ); + depths.push_back( symbolLocationDepths[segmentIndex] ); propertyValues.push_back( curveValue ); } diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTopologyCurve.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTopologyCurve.h index 449d7daeca..893e9c7abf 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTopologyCurve.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTopologyCurve.h @@ -44,6 +44,13 @@ public: ANNULUS }; + enum class SymbolLocationType + { + START, + MID, + END + }; + public: RimRftTopologyCurve(); @@ -77,12 +84,13 @@ protected: void onLoadDataAndUpdate( bool updateParentPlot ) override; private: - caf::PdmPtrField m_summaryCase; - caf::PdmField m_timeStep; - caf::PdmField m_wellName; - caf::PdmField m_segmentBranchIndex; - caf::PdmField> m_segmentBranchType; - caf::PdmField> m_curveType; + caf::PdmPtrField m_summaryCase; + caf::PdmField m_timeStep; + caf::PdmField m_wellName; + caf::PdmField m_segmentBranchIndex; + caf::PdmField> m_segmentBranchType; + caf::PdmField> m_curveType; + caf::PdmField> m_symbolLocation; public: void setAdditionalDataSources( const std::vector& additionalDataSources ); diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurve.cpp index 6b01a74ac3..3ed71e357f 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurve.cpp @@ -1152,7 +1152,8 @@ std::vector RimWellLogRftCurve::measuredDepthValues( QString& prefixText { prefixText = "SEGMENT/"; - return RimRftTools::seglenstValues( reader, m_wellName(), m_timeStep, segmentBranchIndex(), m_segmentBranchType() ); + // Always use segment end MD values for segment data, as the curve is plotted as step left + return RimRftTools::segmentEndMdValues( reader, m_wellName(), m_timeStep, segmentBranchIndex(), m_segmentBranchType() ); } return {}; } diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathGeometryDef.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathGeometryDef.cpp index b76b3c9de8..f6bd5bda93 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathGeometryDef.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathGeometryDef.cpp @@ -102,7 +102,7 @@ RimWellPathGeometryDef::RimWellPathGeometryDef() CAF_PDM_InitFieldNoDefault( &m_fixedMeasuredDepths, "FixedMeasuredDepths", "" ); CAF_PDM_InitField( &m_pickPointsEnabled, "m_pickPointsEnabled", false, "" ); - caf::PdmUiPushButtonEditor::configureEditorForField( &m_pickPointsEnabled ); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_pickPointsEnabled ); CAF_PDM_InitScriptableField( &m_showSpheres, "ShowSpheres", true, "Spheres" ); CAF_PDM_InitField( &m_sphereColor, "SphereColor", cvf::Color3f( cvf::Color3f::CEETRON ), "Sphere Color" ); diff --git a/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModel.cpp b/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModel.cpp index 7f2b70db9e..286e91b986 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModel.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModel.cpp @@ -264,12 +264,3 @@ void RigFaultReactivationModel::postProcessElementSets( const RimEclipseCase* eC m_3dparts[part]->postProcessElementSets( eCase->mainGrid(), cellInfo ); } } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RigFaultReactivationModel::flipNodeOrder( bool flipFW, bool flipHW ) -{ - if ( flipFW ) m_3dparts[GridPart::FW]->flipNodeOrder(); - if ( flipHW ) m_3dparts[GridPart::HW]->flipNodeOrder(); -} \ No newline at end of file diff --git a/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModel.h b/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModel.h index 5072902375..97a0417660 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModel.h +++ b/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModel.h @@ -87,7 +87,6 @@ public: RimFaultReactivation::GridPart normalPointsAt() const; void postProcessElementSets( const RimEclipseCase* eCase ); - void flipNodeOrder( bool flipFW, bool flipHW ); private: std::shared_ptr m_generator; diff --git a/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModelGenerator.cpp b/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModelGenerator.cpp index a2b6d31524..aac975721e 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModelGenerator.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModelGenerator.cpp @@ -590,7 +590,7 @@ void RigFaultReactivationModelGenerator::generateGeometry( size_t sta m_horizontalPartition, m_modelThickness, m_topReservoirBack.z(), - m_modelNormal, + -1.0 * m_modelNormal, m_faultZoneCells ); frontPart->generateLocalNodes( m_localCoordTransform ); diff --git a/ApplicationLibCode/ReservoirDataModel/RigGriddedPart3d.cpp b/ApplicationLibCode/ReservoirDataModel/RigGriddedPart3d.cpp index f5267362fc..f98e3c19f8 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigGriddedPart3d.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigGriddedPart3d.cpp @@ -236,9 +236,9 @@ void RigGriddedPart3d::generateGeometry( const std::array& input nVertCells += layersPerRegion[region].size(); } - const std::vector m_thicknessFactors = { -1.0, 0.0, 1.0 }; - const int nThicknessCells = 2; - cvf::Vec3d tVec = modelThickness * thicknessDirection; + const std::vector thicknessFactors = { -1.0, 0.0, 1.0 }; + const int nThicknessCells = 2; + cvf::Vec3d tVec = modelThickness * thicknessDirection; size_t reserveSize = ( nVertCells + 1 ) * ( nHorzCells + 1 ) * ( nThicknessCells + 1 ); m_nodes.reserve( reserveSize ); @@ -320,7 +320,7 @@ void RigGriddedPart3d::generateGeometry( const std::array& input for ( int t = 0; t <= nThicknessCells; t++, nodeIndex++ ) { - m_nodes.push_back( p + m_thicknessFactors[t] * tVec ); + m_nodes.push_back( p + thicknessFactors[t] * tVec ); if ( h == (int)nHorzCells ) { @@ -400,15 +400,15 @@ void RigGriddedPart3d::generateGeometry( const std::array& input { for ( int t = 0; t < nThicknessCells; t++, elementIdx++ ) { - m_elementIndices[elementIdx].push_back( t + nextLayerIdxOff + i ); - m_elementIndices[elementIdx].push_back( t + nextLayerIdxOff + i + nThicknessOff ); - m_elementIndices[elementIdx].push_back( t + nextLayerIdxOff + i + nThicknessOff + 1 ); - m_elementIndices[elementIdx].push_back( t + nextLayerIdxOff + i + 1 ); - m_elementIndices[elementIdx].push_back( t + i ); - m_elementIndices[elementIdx].push_back( t + i + nThicknessOff ); - m_elementIndices[elementIdx].push_back( t + i + nThicknessOff + 1 ); m_elementIndices[elementIdx].push_back( t + i + 1 ); + m_elementIndices[elementIdx].push_back( t + i + nThicknessOff + 1 ); + m_elementIndices[elementIdx].push_back( t + i + nThicknessOff ); + + m_elementIndices[elementIdx].push_back( t + nextLayerIdxOff + i ); + m_elementIndices[elementIdx].push_back( t + nextLayerIdxOff + i + 1 ); + m_elementIndices[elementIdx].push_back( t + nextLayerIdxOff + i + nThicknessOff + 1 ); + m_elementIndices[elementIdx].push_back( t + nextLayerIdxOff + i + nThicknessOff ); if ( v == 0 ) { @@ -767,15 +767,3 @@ void RigGriddedPart3d::updateElementSet( ElementSets elSet, } } } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RigGriddedPart3d::flipNodeOrder() -{ - for ( auto& nodes : m_elementIndices ) - { - std::swap( nodes[1], nodes[3] ); - std::swap( nodes[5], nodes[7] ); - } -} \ No newline at end of file diff --git a/ApplicationLibCode/ReservoirDataModel/RigGriddedPart3d.h b/ApplicationLibCode/ReservoirDataModel/RigGriddedPart3d.h index dfcaa7d500..49f44269c8 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigGriddedPart3d.h +++ b/ApplicationLibCode/ReservoirDataModel/RigGriddedPart3d.h @@ -61,7 +61,6 @@ public: void setUseLocalCoordinates( bool useLocalCoordinates ); void postProcessElementSets( const RigMainGrid* mainGrid, const RigActiveCellInfo* cellInfo ); - void flipNodeOrder(); bool useLocalCoordinates() const; double topHeight() const; diff --git a/ApplicationLibCode/ReservoirDataModel/RigPolyLinesData.cpp b/ApplicationLibCode/ReservoirDataModel/RigPolyLinesData.cpp index 88318e1ec5..7a282e3a85 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigPolyLinesData.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigPolyLinesData.cpp @@ -44,11 +44,37 @@ RigPolyLinesData::~RigPolyLinesData() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const std::vector>& RigPolyLinesData::polyLines() const +const std::vector>& RigPolyLinesData::rawPolyLines() const { return m_polylines; } +//-------------------------------------------------------------------------------------------------- +/// Returns the polylines with the last point equal to the first point if the polyline is closed +//-------------------------------------------------------------------------------------------------- +const std::vector> RigPolyLinesData::completePolyLines() const +{ + if ( !m_closePolyline ) return m_polylines; + + std::vector> completeLines; + for ( const auto& polyline : m_polylines ) + { + auto completePolyline = polyline; + if ( !polyline.empty() ) + { + const double epsilon = 1e-6; + + if ( polyline.front().pointDistance( polyline.back() ) > epsilon ) + { + completePolyline.push_back( polyline.front() ); + } + } + completeLines.push_back( completePolyline ); + } + + return completeLines; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ReservoirDataModel/RigPolyLinesData.h b/ApplicationLibCode/ReservoirDataModel/RigPolyLinesData.h index 5e0fcf176b..f11c92dc27 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigPolyLinesData.h +++ b/ApplicationLibCode/ReservoirDataModel/RigPolyLinesData.h @@ -34,7 +34,8 @@ public: RigPolyLinesData(); ~RigPolyLinesData() override; - const std::vector>& polyLines() const; + const std::vector>& rawPolyLines() const; + const std::vector> completePolyLines() const; void setPolyLines( const std::vector>& polyLines ); void setPolyLine( const std::vector& polyline ); diff --git a/ApplicationLibCode/ReservoirDataModel/RigWbsParameter.cpp b/ApplicationLibCode/ReservoirDataModel/RigWbsParameter.cpp index 0535752604..e010a3d6ab 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigWbsParameter.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigWbsParameter.cpp @@ -438,6 +438,7 @@ RigWbsParameter RigWbsParameter::waterDensity() { LAS_FILE, SourceAddress( "RHO_INP", "", RiaWellLogUnitTools::gPerCm3UnitString() ) } } ); return param; } + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/UserInterface/RiuFemResultTextBuilder.cpp b/ApplicationLibCode/UserInterface/RiuFemResultTextBuilder.cpp index 0f1f0b8281..329b3ba39c 100644 --- a/ApplicationLibCode/UserInterface/RiuFemResultTextBuilder.cpp +++ b/ApplicationLibCode/UserInterface/RiuFemResultTextBuilder.cpp @@ -281,16 +281,16 @@ void RiuFemResultTextBuilder::appendTextFromResultColors( RigGeoMechCaseData* if ( resultDefinition->hasResult() ) { - const std::vector& scalarResults = - geomData->femPartResults()->resultValues( resultDefinition->resultAddress(), gridIndex, timeStepIndex, frameIndex ); + auto address = RigFemAddressDefines::getResultLookupAddress( resultDefinition->resultAddress() ); + const std::vector& scalarResults = geomData->femPartResults()->resultValues( address, gridIndex, timeStepIndex, frameIndex ); if ( !scalarResults.empty() ) { - caf::AppEnum resPosAppEnum = resultDefinition->resultPositionType(); + caf::AppEnum resPosAppEnum = address.resultPosType; resultInfoText->append( resPosAppEnum.uiText() + ", " ); resultInfoText->append( resultDefinition->resultFieldUiName() + ", " ); resultInfoText->append( resultDefinition->resultComponentUiName() + ":\n" ); - if ( resultDefinition->resultPositionType() != RIG_ELEMENT_NODAL_FACE ) + if ( address.resultPosType != RIG_ELEMENT_NODAL_FACE ) { RigFemPart* femPart = geomData->femParts()->part( gridIndex ); RigElementType elmType = femPart->elementType( cellIndex ); @@ -302,8 +302,8 @@ void RiuFemResultTextBuilder::appendTextFromResultColors( RigGeoMechCaseData* { float scalarValue = std::numeric_limits::infinity(); int nodeIdx = elementConn[lNodeIdx]; - if ( resultDefinition->resultPositionType() == RIG_NODAL || - ( resultDefinition->resultPositionType() == RIG_DIFFERENTIALS && + if ( address.resultPosType == RIG_NODAL || + ( address.resultPosType == RIG_DIFFERENTIALS && resultDefinition->resultFieldName() == QString::fromStdString( RigFemAddressDefines::porBar() ) ) ) { scalarValue = scalarResults[nodeIdx]; @@ -407,13 +407,15 @@ QString RiuFemResultTextBuilder::closestNodeResultText( RimGeoMechResultDefiniti RigGeoMechCaseData* geomData = m_geomResDef->geoMechCase()->geoMechData(); + auto address = RigFemAddressDefines::getResultLookupAddress( resultColors->resultAddress() ); + const std::vector& scalarResults = - geomData->femPartResults()->resultValues( resultColors->resultAddress(), m_gridIndex, m_timeStepIndex, m_frameIndex ); + geomData->femPartResults()->resultValues( address, m_gridIndex, m_timeStepIndex, m_frameIndex ); if ( !scalarResults.empty() && m_displayCoordView ) { RigFemPart* femPart = geomData->femParts()->part( m_gridIndex ); - RigFemResultPosEnum activeResultPosition = resultColors->resultPositionType(); + RigFemResultPosEnum activeResultPosition = address.resultPosType; cvf::Vec3d intersectionPointInDomain = m_displayCoordView->displayCoordTransform()->translateToDomainCoord( m_intersectionPointInDisplay ); @@ -443,11 +445,7 @@ QString RiuFemResultTextBuilder::closestNodeResultText( RimGeoMechResultDefiniti } else if ( m_isIntersectionTriangleSet && activeResultPosition == RIG_ELEMENT_NODAL_FACE ) { - RiuGeoMechXfTensorResultAccessor tensAccessor( geomData->femPartResults(), - resultColors->resultAddress(), - m_gridIndex, - m_timeStepIndex, - m_frameIndex ); + RiuGeoMechXfTensorResultAccessor tensAccessor( geomData->femPartResults(), address, m_gridIndex, m_timeStepIndex, m_frameIndex ); float tensValue = tensAccessor.calculateElmNodeValue( m_intersectionTriangle, closestElmNodResIdx ); text.append( QString( "Closest result: N[%1], in Element[%2] transformed onto intersection: %3 \n" ) diff --git a/CMakeLists.txt b/CMakeLists.txt index a74efe8d97..be662dc9da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -324,6 +324,12 @@ set(CMAKE_CXX_COMPILER_LAUNCHER ${TEMP_CMAKE_CXX_COMPILER_LAUNCHER}) # ############################################################################## find_package(Git QUIET) if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") + execute_process( + COMMAND git log -1 --pretty=format:%h + OUTPUT_VARIABLE RESINSIGHT_GIT_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET + ) + # Update submodules as needed option(RESINSIGHT_UPDATE_SUBMODULES "Check submodules during build" ON) mark_as_advanced(RESINSIGHT_UPDATE_SUBMODULES) diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmReferenceHelper.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmReferenceHelper.cpp index dc6c396aa5..1b5f0d9f58 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmReferenceHelper.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmReferenceHelper.cpp @@ -328,7 +328,7 @@ PdmObjectHandle* PdmReferenceHelper::objectFromFieldReference( PdmFieldHandle* f if ( reference.isEmpty() ) return nullptr; if ( reference.trimmed().isEmpty() ) return nullptr; -#if ( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) ) +#if ( QT_VERSION < QT_VERSION_CHECK( 5, 14, 0 ) ) auto SkipEmptyParts = QString::SkipEmptyParts; #else auto SkipEmptyParts = Qt::SkipEmptyParts; diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.h index ee395297a1..b65fc7d242 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.h @@ -13,6 +13,7 @@ class PdmObjectHandle; class PdmUiOrdering; class PdmFieldHandle; class PdmUiEditorAttribute; +class CmdFeatureMenuBuilder; class PdmUiObjectHandle : public PdmUiItem, public PdmObjectCapability { @@ -44,6 +45,9 @@ public: void updateUiIconFromToggleField(); + /// Append actions to menu builder + virtual void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const {} + // Virtual interface to override in subclasses to support special behaviour if needed public: // Virtual virtual caf::PdmFieldHandle* userDescriptionField() { return nullptr; } diff --git a/Fwk/AppFwk/cafTests/cafTestApplication/LineEditAndPushButtons.cpp b/Fwk/AppFwk/cafTests/cafTestApplication/LineEditAndPushButtons.cpp index ab4e0dac6a..e3fe762732 100644 --- a/Fwk/AppFwk/cafTests/cafTestApplication/LineEditAndPushButtons.cpp +++ b/Fwk/AppFwk/cafTests/cafTestApplication/LineEditAndPushButtons.cpp @@ -35,20 +35,16 @@ LineEditAndPushButtons::LineEditAndPushButtons() m_textListField.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() ); CAF_PDM_InitFieldNoDefault( &m_pushButton_a, "PushButtonA", "Rotate", "", "", "" ); - m_pushButton_a.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); - m_pushButton_a.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_pushButton_a ); CAF_PDM_InitFieldNoDefault( &m_pushButtonReplace, "PushButtonB", "Replace (CTRL + Enter)", "", "", "" ); - m_pushButtonReplace.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); - m_pushButtonReplace.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_pushButtonReplace ); CAF_PDM_InitFieldNoDefault( &m_pushButtonClear, "PushButtonC", "Clear (Alt + Enter)", "", "", "" ); - m_pushButtonClear.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); - m_pushButtonClear.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_pushButtonClear ); CAF_PDM_InitFieldNoDefault( &m_pushButtonAppend, "PushButtonD", "Append (Shift + Enter)", "", "", "" ); - m_pushButtonAppend.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); - m_pushButtonAppend.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); + caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_pushButtonAppend ); std::vector items; items.push_back( "sldkfj" ); diff --git a/Fwk/AppFwk/cafUserInterface/CMakeLists.txt b/Fwk/AppFwk/cafUserInterface/CMakeLists.txt index ed547d8be9..06453f27ec 100644 --- a/Fwk/AppFwk/cafUserInterface/CMakeLists.txt +++ b/Fwk/AppFwk/cafUserInterface/CMakeLists.txt @@ -182,6 +182,7 @@ set(PROJECT_FILES cafPdmUiTreeViewItemDelegate.h cafPdmUiTreeViewItemDelegate.cpp cafPdmUiTreeAttributes.h + cafPdmUiTreeAttributes.cpp cafUiAppearanceSettings.cpp cafUiIconFactory.cpp cafPdmUiSliderTools.h diff --git a/Fwk/AppFwk/cafUserInterface/cafMemoryInspector.cpp b/Fwk/AppFwk/cafUserInterface/cafMemoryInspector.cpp index 48f97baec6..686a75e0c0 100644 --- a/Fwk/AppFwk/cafUserInterface/cafMemoryInspector.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafMemoryInspector.cpp @@ -25,7 +25,7 @@ #ifdef __linux__ -#if ( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) ) +#if ( QT_VERSION < QT_VERSION_CHECK( 5, 14, 0 ) ) auto SkipEmptyParts = QString::SkipEmptyParts; #else auto SkipEmptyParts = Qt::SkipEmptyParts; diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiPushButtonEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiPushButtonEditor.cpp index 70de460ee1..711d27a328 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiPushButtonEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiPushButtonEditor.cpp @@ -114,19 +114,39 @@ void PdmUiPushButtonEditor::configureAndUpdateUi( const QString& uiConfigName ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void PdmUiPushButtonEditor::configureEditorForField( PdmFieldHandle* fieldHandle ) +void PdmUiPushButtonEditor::configureEditorLabelLeft( PdmFieldHandle* fieldHandle ) { if ( fieldHandle ) { - if ( fieldHandle->xmlCapability() ) + if ( auto xmlCap = fieldHandle->xmlCapability() ) { - fieldHandle->xmlCapability()->disableIO(); + xmlCap->disableIO(); } - if ( fieldHandle->uiCapability() ) + if ( auto uiCap = fieldHandle->uiCapability() ) { - fieldHandle->uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); - fieldHandle->uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LEFT ); + uiCap->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); + uiCap->setUiLabelPosition( caf::PdmUiItemInfo::LEFT ); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void PdmUiPushButtonEditor::configureEditorLabelHidden( PdmFieldHandle* fieldHandle ) +{ + if ( fieldHandle ) + { + if ( auto xmlCap = fieldHandle->xmlCapability() ) + { + xmlCap->disableIO(); + } + + if ( auto uiCap = fieldHandle->uiCapability() ) + { + uiCap->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); + uiCap->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); } } } diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiPushButtonEditor.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiPushButtonEditor.h index 00c1eb6a7e..ae94955b34 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiPushButtonEditor.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiPushButtonEditor.h @@ -67,7 +67,8 @@ public: PdmUiPushButtonEditor() {} ~PdmUiPushButtonEditor() override {} - static void configureEditorForField( PdmFieldHandle* fieldHandle ); + static void configureEditorLabelLeft( PdmFieldHandle* fieldHandle ); + static void configureEditorLabelHidden( PdmFieldHandle* fieldHandle ); protected: QWidget* createEditorWidget( QWidget* parent ) override; 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 @@ public: , resizePolicy( NO_AUTOMATIC_RESIZE ) , enableDropTarget( false ) { - QPalette myPalette; - baseColor = myPalette.color( QPalette::Active, QPalette::Base ); } - int selectionLevel; int tableSelectionLevel; int rowSelectionLevel; bool enableHeaderText; diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeAttributes.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeAttributes.cpp new file mode 100644 index 0000000000..06172c8a57 --- /dev/null +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeAttributes.cpp @@ -0,0 +1,61 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2011-2013 Ceetron AS +// +// This library may be used under the terms of either the GNU General Public License or +// the GNU Lesser General Public License as follows: +// +// GNU General Public License Usage +// This library 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. +// +// This library 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. +// +// GNU Lesser General Public License Usage +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// This library 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 Lesser General Public License at <> +// for more details. +// +//################################################################################################## + +#include "cafPdmUiTreeAttributes.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::unique_ptr caf::PdmUiTreeViewItemAttribute::createTag() +{ + return std::make_unique(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void caf::PdmUiTreeViewItemAttribute::createTagIfTreeViewItemAttribute( caf::PdmUiEditorAttribute* attribute, + const QString& iconResourceString ) +{ + if ( auto* treeItemAttribute = dynamic_cast( attribute ) ) + { + treeItemAttribute->tags.clear(); + auto tag = caf::PdmUiTreeViewItemAttribute::createTag(); + tag->icon = caf::IconProvider( iconResourceString ); + + treeItemAttribute->tags.push_back( std::move( tag ) ); + } +} diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeAttributes.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeAttributes.h index de171f7000..c138db8a2f 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeAttributes.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeAttributes.h @@ -1,5 +1,3 @@ - - //################################################################################################## // // Custom Visualization Core library @@ -73,12 +71,13 @@ public: caf::Signal clicked; - static std::unique_ptr create() { return std::make_unique(); } - private: Tag& operator=( const Tag& rhs ) { return *this; } }; + static std::unique_ptr createTag(); + static void createTagIfTreeViewItemAttribute( caf::PdmUiEditorAttribute* attribute, const QString& iconString ); + std::vector> tags; }; diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp index 60d1b0e480..1035f8d393 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp @@ -598,7 +598,7 @@ void PdmUiTreeSelectionEditor::slotInvertCheckedStateOfAll() //-------------------------------------------------------------------------------------------------- void PdmUiTreeSelectionEditor::setCheckedStateForIntegerItemsMatchingFilter() { -#if ( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) ) +#if ( QT_VERSION < QT_VERSION_CHECK( 5, 14, 0 ) ) auto SkipEmptyParts = QString::SkipEmptyParts; #else auto SkipEmptyParts = Qt::SkipEmptyParts; diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.cpp index e77c3038cc..3c036fcef3 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.cpp @@ -615,7 +615,7 @@ void PdmUiTreeViewEditor::updateItemDelegateForSubTree( const QModelIndex& subRo { size_t indexInParentField = reorderability->indexOf( pdmObject ); { - auto tag = PdmUiTreeViewItemAttribute::Tag::create(); + auto tag = PdmUiTreeViewItemAttribute::createTag(); tag->icon = caf::IconProvider( ":/caf/Up16x16.png" ); tag->selectedOnly = true; if ( reorderability->canItemBeMovedUp( indexInParentField ) ) @@ -630,7 +630,7 @@ void PdmUiTreeViewEditor::updateItemDelegateForSubTree( const QModelIndex& subRo m_delegate->addTag( filterIndex, std::move( tag ) ); } { - auto tag = PdmUiTreeViewItemAttribute::Tag::create(); + auto tag = PdmUiTreeViewItemAttribute::createTag(); tag->icon = IconProvider( ":/caf/Down16x16.png" ); tag->selectedOnly = true; if ( reorderability->canItemBeMovedDown( indexInParentField ) ) diff --git a/GrpcInterface/CMakeLists.txt b/GrpcInterface/CMakeLists.txt index 8cc5a5ea45..152122dffb 100644 --- a/GrpcInterface/CMakeLists.txt +++ b/GrpcInterface/CMakeLists.txt @@ -267,13 +267,10 @@ endif() # install gRPC Python files if(RESINSIGHT_GRPC_PYTHON_EXECUTABLE AND RESINSIGHT_GRPC_DOWNLOAD_PYTHON_MODULE) - message(STATUS "Installing Python modules") + message(STATUS "Installing Python modules (dev-requirements.txt)") add_custom_command( TARGET PipInstall - COMMAND ${RESINSIGHT_GRPC_PYTHON_EXECUTABLE} ARGS -m pip install --user - wheel setuptools pytest - COMMAND ${RESINSIGHT_GRPC_PYTHON_EXECUTABLE} ARGS -m pip install --user - grpcio-tools) + COMMAND ${RESINSIGHT_GRPC_PYTHON_EXECUTABLE} ARGS -m pip install -r ${GRPC_PYTHON_SOURCE_PATH}/dev-requirements.txt --user ) endif() if(RESINSIGHT_GRPC_PYTHON_EXECUTABLE AND RESINSIGHT_GRPC_BUNDLE_PYTHON_MODULE) diff --git a/GrpcInterface/Python/dev-requirements.txt b/GrpcInterface/Python/dev-requirements.txt new file mode 100644 index 0000000000..26207d9c11 --- /dev/null +++ b/GrpcInterface/Python/dev-requirements.txt @@ -0,0 +1,6 @@ +grpcio +grpcio-tools +protobuf +wheel +typing-extensions +pytest diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index f9c23e01ca..bd82396262 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -11,7 +11,7 @@ set(RESINSIGHT_VERSION_TEXT "-dev") # Must be unique and increasing within one combination of major/minor/patch version # The uniqueness of this text is independent of RESINSIGHT_VERSION_TEXT # Format of text must be ".xx" -set(RESINSIGHT_DEV_VERSION ".19") +set(RESINSIGHT_DEV_VERSION ".22") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f")