diff --git a/ApplicationExeCode/Resources/ResInsight.qrc b/ApplicationExeCode/Resources/ResInsight.qrc index 1a1b8b97d9..7c2e9a61bd 100644 --- a/ApplicationExeCode/Resources/ResInsight.qrc +++ b/ApplicationExeCode/Resources/ResInsight.qrc @@ -286,6 +286,7 @@ decline-curve.svg regression-curve.svg padlock.svg + warning.svg fs_CellFace.glsl diff --git a/ApplicationExeCode/Resources/warning.svg b/ApplicationExeCode/Resources/warning.svg new file mode 100644 index 0000000000..7944bbfa8e --- /dev/null +++ b/ApplicationExeCode/Resources/warning.svg @@ -0,0 +1,2 @@ + +ionicons-v5-r \ No newline at end of file diff --git a/ApplicationExeCode/RiaGrpcConsoleApplication.cpp b/ApplicationExeCode/RiaGrpcConsoleApplication.cpp index b0e17ee9ab..dae4ef68d2 100644 --- a/ApplicationExeCode/RiaGrpcConsoleApplication.cpp +++ b/ApplicationExeCode/RiaGrpcConsoleApplication.cpp @@ -46,7 +46,7 @@ RiaGrpcConsoleApplication::RiaGrpcConsoleApplication( int& argc, char** argv ) { m_idleTimer = new QTimer( this ); connect( m_idleTimer, SIGNAL( timeout() ), this, SLOT( doIdleProcessing() ) ); - m_idleTimer->start( 0 ); + m_idleTimer->start( 5 ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/RiaApplication.h b/ApplicationLibCode/Application/RiaApplication.h index ee34b42017..5496295dbf 100644 --- a/ApplicationLibCode/Application/RiaApplication.h +++ b/ApplicationLibCode/Application/RiaApplication.h @@ -21,12 +21,11 @@ #include "RiaDefines.h" -#include "cafPdmField.h" -#include "cafPdmObject.h" - -#include "cvfFont.h" +#include "cafPdmPointer.h" #include "cvfObject.h" +#include +#include #include #include #include @@ -35,7 +34,6 @@ #include -#include #include class QAction; @@ -79,7 +77,8 @@ class UiProcess; namespace cvf { class ProgramOptions; -} +class Font; +} // namespace cvf //================================================================================================== /// Base class for all ResInsight applications. I.e. console and GUI diff --git a/ApplicationLibCode/Application/RiaFontCache.cpp b/ApplicationLibCode/Application/RiaFontCache.cpp index 188b9ced9a..85e4f53d31 100644 --- a/ApplicationLibCode/Application/RiaFontCache.cpp +++ b/ApplicationLibCode/Application/RiaFontCache.cpp @@ -20,9 +20,11 @@ #include "RiaGuiApplication.h" +#include "cafAssert.h" #include "cafFixedAtlasFont.h" #include + #include //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/RiaGuiApplication.h b/ApplicationLibCode/Application/RiaGuiApplication.h index 9a725e018c..2e293d380b 100644 --- a/ApplicationLibCode/Application/RiaGuiApplication.h +++ b/ApplicationLibCode/Application/RiaGuiApplication.h @@ -21,11 +21,6 @@ #include "RiaApplication.h" #include "RiaDefines.h" -#include "cafPdmField.h" -#include "cafPdmObject.h" - -#include "cvfObject.h" - #include #include #include diff --git a/ApplicationLibCode/Application/RiaPreferences.cpp b/ApplicationLibCode/Application/RiaPreferences.cpp index f935916aab..d0ea2ebdee 100644 --- a/ApplicationLibCode/Application/RiaPreferences.cpp +++ b/ApplicationLibCode/Application/RiaPreferences.cpp @@ -41,6 +41,7 @@ #include "cafPdmUiFilePathEditor.h" #include "cafPdmUiLineEditor.h" +#include #include #include #include diff --git a/ApplicationLibCode/Application/Tools/RiaEclipseUnitTools.cpp b/ApplicationLibCode/Application/Tools/RiaEclipseUnitTools.cpp index 1e005e5b4f..45f13f274c 100644 --- a/ApplicationLibCode/Application/Tools/RiaEclipseUnitTools.cpp +++ b/ApplicationLibCode/Application/Tools/RiaEclipseUnitTools.cpp @@ -48,7 +48,7 @@ double RiaEclipseUnitTools::darcysConstant( RiaDefines::EclipseUnitSystem unitSy //-------------------------------------------------------------------------------------------------- /// Convert Gas to oil equivalents -/// If field unit, the Gas is in Mega ft^3 while the others are in [stb] (barrel) +/// If field unit, the Gas is in Mft^3(=1000ft^3) while the others are in [stb] (barrel) //-------------------------------------------------------------------------------------------------- double RiaEclipseUnitTools::convertSurfaceGasFlowRateToOilEquivalents( RiaDefines::EclipseUnitSystem caseUnitSystem, double eclGasFlowRate ) { @@ -56,18 +56,24 @@ double RiaEclipseUnitTools::convertSurfaceGasFlowRateToOilEquivalents( RiaDefine /// we convert gas to stb as well. Based on /// 1 [stb] = 0.15898729492800007 [m^3] /// 1 [ft] = 0.3048 [m] - /// megaFt3ToStbFactor = 1.0 / (1.0e-6 * 0.15898729492800007 * ( 1.0 / 0.3048 )^3 ) - /// double megaFt3ToStbFactor = 178107.60668; + /// + /// NB Mft^3 = 1000 ft^3 - can wrongly be interpreted as M for Mega in metric units - double fieldGasToOilEquivalent = 1.0e6 / 5800; // Mega ft^3 to BOE - double metricGasToOilEquivalent = 1.0 / 1.0e3; // Sm^3 Gas to Sm^3 oe + if ( caseUnitSystem == RiaDefines::EclipseUnitSystem::UNITS_FIELD ) + { + const double fieldGasToOilEquivalent = 1000.0 / 5614.63; - double oilEquivalentGasRate = HUGE_VAL; + return fieldGasToOilEquivalent * eclGasFlowRate; + } - if ( caseUnitSystem == RiaDefines::EclipseUnitSystem::UNITS_FIELD ) oilEquivalentGasRate = fieldGasToOilEquivalent * eclGasFlowRate; - if ( caseUnitSystem == RiaDefines::EclipseUnitSystem::UNITS_METRIC ) oilEquivalentGasRate = metricGasToOilEquivalent * eclGasFlowRate; + if ( caseUnitSystem == RiaDefines::EclipseUnitSystem::UNITS_METRIC ) + { + double metricGasToOilEquivalent = 1.0 / 1000.0; // Sm^3 Gas to Sm^3 oe + + return metricGasToOilEquivalent * eclGasFlowRate; + } - return oilEquivalentGasRate; + return HUGE_VAL; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/Tools/RiaStdStringTools.cpp b/ApplicationLibCode/Application/Tools/RiaStdStringTools.cpp index 794f1a7b2f..0b444b698e 100644 --- a/ApplicationLibCode/Application/Tools/RiaStdStringTools.cpp +++ b/ApplicationLibCode/Application/Tools/RiaStdStringTools.cpp @@ -20,7 +20,6 @@ #include "fast_float/include/fast_float/fast_float.h" -#include #include #include #include diff --git a/ApplicationLibCode/Commands/ExportCommands/RicAdvancedSnapshotExportFeature.cpp b/ApplicationLibCode/Commands/ExportCommands/RicAdvancedSnapshotExportFeature.cpp index ebd090ed0d..0a4085f80f 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicAdvancedSnapshotExportFeature.cpp +++ b/ApplicationLibCode/Commands/ExportCommands/RicAdvancedSnapshotExportFeature.cpp @@ -47,6 +47,7 @@ #include "cafUtils.h" #include +#include #include #include diff --git a/ApplicationLibCode/Commands/ExportCommands/RicCreateDepthAdjustedLasFilesUi.cpp b/ApplicationLibCode/Commands/ExportCommands/RicCreateDepthAdjustedLasFilesUi.cpp index 021f429aa8..ad275a9233 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicCreateDepthAdjustedLasFilesUi.cpp +++ b/ApplicationLibCode/Commands/ExportCommands/RicCreateDepthAdjustedLasFilesUi.cpp @@ -31,7 +31,6 @@ #include "cafPdmUiCheckBoxEditor.h" #include "cafPdmUiFilePathEditor.h" -#include "cafPdmUiOrdering.h" #include "cafPdmUiTreeSelectionEditor.h" CAF_PDM_SOURCE_INIT( RicCreateDepthAdjustedLasFilesUi, "RicCreateDepthAdjustedLasFilesUi" ); diff --git a/ApplicationLibCode/Commands/ExportCommands/RicExportEclipseSectorModelUi.cpp b/ApplicationLibCode/Commands/ExportCommands/RicExportEclipseSectorModelUi.cpp index 9629952ff4..88a5c427d1 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicExportEclipseSectorModelUi.cpp +++ b/ApplicationLibCode/Commands/ExportCommands/RicExportEclipseSectorModelUi.cpp @@ -33,7 +33,6 @@ #include "cafPdmUiFilePathEditor.h" #include "cafPdmUiGroup.h" #include "cafPdmUiLineEditor.h" -#include "cafPdmUiOrdering.h" #include "cafPdmUiTreeSelectionEditor.h" #include diff --git a/ApplicationLibCode/Commands/ExportCommands/RicExportToLasFileResampleUi.cpp b/ApplicationLibCode/Commands/ExportCommands/RicExportToLasFileResampleUi.cpp index 152d23c9e4..c2dfb84fa1 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicExportToLasFileResampleUi.cpp +++ b/ApplicationLibCode/Commands/ExportCommands/RicExportToLasFileResampleUi.cpp @@ -20,7 +20,6 @@ #include "cafPdmUiCheckBoxEditor.h" #include "cafPdmUiFilePathEditor.h" -#include "cafPdmUiOrdering.h" #include diff --git a/ApplicationLibCode/Commands/ExportCommands/RicExportWellPathsUi.cpp b/ApplicationLibCode/Commands/ExportCommands/RicExportWellPathsUi.cpp index c44aac515c..87a2decc15 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicExportWellPathsUi.cpp +++ b/ApplicationLibCode/Commands/ExportCommands/RicExportWellPathsUi.cpp @@ -25,7 +25,6 @@ #include "RimProject.h" #include "cafPdmUiFilePathEditor.h" -#include "cafPdmUiOrdering.h" CAF_PDM_SOURCE_INIT( RicExportWellPathsUi, "RicExportWellPathsUi" ); diff --git a/ApplicationLibCode/Commands/ExportCommands/RicSaveEclipseInputVisibleCellsUi.cpp b/ApplicationLibCode/Commands/ExportCommands/RicSaveEclipseInputVisibleCellsUi.cpp index 0745a3b89f..8ed93cd536 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicSaveEclipseInputVisibleCellsUi.cpp +++ b/ApplicationLibCode/Commands/ExportCommands/RicSaveEclipseInputVisibleCellsUi.cpp @@ -22,7 +22,6 @@ #include "RiaPreferences.h" #include "cafPdmUiFilePathEditor.h" -#include "cafPdmUiOrdering.h" #include diff --git a/ApplicationLibCode/Commands/HoloLensCommands/RicHoloLensCreateSessionUi.cpp b/ApplicationLibCode/Commands/HoloLensCommands/RicHoloLensCreateSessionUi.cpp index 80766ce294..ccbed05d73 100644 --- a/ApplicationLibCode/Commands/HoloLensCommands/RicHoloLensCreateSessionUi.cpp +++ b/ApplicationLibCode/Commands/HoloLensCommands/RicHoloLensCreateSessionUi.cpp @@ -24,7 +24,6 @@ #include "RicHoloLensServerSettings.h" #include "cafPdmSettings.h" -#include "cafPdmUiOrdering.h" #include "cvfAssert.h" diff --git a/ApplicationLibCode/Commands/HoloLensCommands/RicHoloLensExportToFolderUi.cpp b/ApplicationLibCode/Commands/HoloLensCommands/RicHoloLensExportToFolderUi.cpp index 45a63791a3..fd3406b999 100644 --- a/ApplicationLibCode/Commands/HoloLensCommands/RicHoloLensExportToFolderUi.cpp +++ b/ApplicationLibCode/Commands/HoloLensCommands/RicHoloLensExportToFolderUi.cpp @@ -25,7 +25,6 @@ #include "RimProject.h" #include "cafPdmUiFilePathEditor.h" -#include "cafPdmUiOrdering.h" CAF_PDM_SOURCE_INIT( RicHoloLensExportToFolderUi, "RicHoloLensExportToFolderUi" ); diff --git a/ApplicationLibCode/Commands/MeasurementCommands/RicMeasurementPickEventHandler.cpp b/ApplicationLibCode/Commands/MeasurementCommands/RicMeasurementPickEventHandler.cpp index 774a8686e4..e8ef60d643 100644 --- a/ApplicationLibCode/Commands/MeasurementCommands/RicMeasurementPickEventHandler.cpp +++ b/ApplicationLibCode/Commands/MeasurementCommands/RicMeasurementPickEventHandler.cpp @@ -19,8 +19,6 @@ #include "RicMeasurementPickEventHandler.h" #include "RiaApplication.h" -#include "RiuViewer.h" -#include "RiuViewerCommands.h" #include "Rim3dView.h" #include "RimExtrudedCurveIntersection.h" @@ -28,13 +26,18 @@ #include "RimMeasurement.h" #include "RimProject.h" -#include "cafDisplayCoordTransform.h" -#include "cafSelectionManager.h" +#include "RiuViewer.h" +#include "RiuViewerCommands.h" #include "RivPartPriority.h" +#include "cafDisplayCoordTransform.h" +#include "cafSelectionManager.h" + #include "cvfPart.h" +#include + #include //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteFeatureImpl.cpp b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteFeatureImpl.cpp index 71bdef8551..5185d11fbc 100644 --- a/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteFeatureImpl.cpp +++ b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteFeatureImpl.cpp @@ -33,6 +33,7 @@ #include "cafPdmObjectHandle.h" #include +#include #include #include diff --git a/ApplicationLibCode/Commands/PolygonCommands/CMakeLists_files.cmake b/ApplicationLibCode/Commands/PolygonCommands/CMakeLists_files.cmake index 8392652004..c4afbccf2d 100644 --- a/ApplicationLibCode/Commands/PolygonCommands/CMakeLists_files.cmake +++ b/ApplicationLibCode/Commands/PolygonCommands/CMakeLists_files.cmake @@ -1,11 +1,21 @@ set(SOURCE_GROUP_HEADER_FILES - ${CMAKE_CURRENT_LIST_DIR}/RicNewPolygonFeature.h - ${CMAKE_CURRENT_LIST_DIR}/RicNewPolygonFileFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicCreatePolygonFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicImportPolygonFileFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicReloadPolygonFileFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicDuplicatePolygonFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicExportPolygonCsvFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicExportPolygonPolFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicSimplifyPolygonFeature.h ) set(SOURCE_GROUP_SOURCE_FILES - ${CMAKE_CURRENT_LIST_DIR}/RicNewPolygonFeature.cpp - ${CMAKE_CURRENT_LIST_DIR}/RicNewPolygonFileFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicCreatePolygonFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicImportPolygonFileFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicReloadPolygonFileFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicDuplicatePolygonFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicExportPolygonCsvFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicExportPolygonPolFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicSimplifyPolygonFeature.cpp ) list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) diff --git a/ApplicationLibCode/Commands/PolygonCommands/RicNewPolygonFeature.cpp b/ApplicationLibCode/Commands/PolygonCommands/RicCreatePolygonFeature.cpp similarity index 72% rename from ApplicationLibCode/Commands/PolygonCommands/RicNewPolygonFeature.cpp rename to ApplicationLibCode/Commands/PolygonCommands/RicCreatePolygonFeature.cpp index 7ff2d4aded..1b4770b9ee 100644 --- a/ApplicationLibCode/Commands/PolygonCommands/RicNewPolygonFeature.cpp +++ b/ApplicationLibCode/Commands/PolygonCommands/RicCreatePolygonFeature.cpp @@ -16,23 +16,27 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RicNewPolygonFeature.h" +#include "RicCreatePolygonFeature.h" + +#include "RiaApplication.h" #include "Polygons/RimPolygon.h" #include "Polygons/RimPolygonCollection.h" +#include "Polygons/RimPolygonTools.h" +#include "Rim3dView.h" #include "RimOilField.h" #include "RimProject.h" -#include "RiuPlotMainWindowTools.h" +#include "Riu3DMainWindowTools.h" #include -CAF_CMD_SOURCE_INIT( RicNewPolygonFeature, "RicNewPolygonFeature" ); +CAF_CMD_SOURCE_INIT( RicCreatePolygonFeature, "RicCreatePolygonFeature" ); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicNewPolygonFeature::onActionTriggered( bool isChecked ) +void RicCreatePolygonFeature::onActionTriggered( bool isChecked ) { auto proj = RimProject::current(); auto polygonCollection = proj->activeOilField()->polygonCollection(); @@ -40,15 +44,17 @@ void RicNewPolygonFeature::onActionTriggered( bool isChecked ) auto newPolygon = polygonCollection->appendUserDefinedPolygon(); polygonCollection->uiCapability()->updateAllRequiredEditors(); - RiuPlotMainWindowTools::setExpanded( newPolygon ); - RiuPlotMainWindowTools::selectAsCurrentItem( newPolygon ); + Riu3DMainWindowTools::setExpanded( newPolygon ); + + auto activeView = RiaApplication::instance()->activeReservoirView(); + RimPolygonTools::activate3dEditOfPolygonInView( newPolygon, activeView ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicNewPolygonFeature::setupActionLook( QAction* actionToSetup ) +void RicCreatePolygonFeature::setupActionLook( QAction* actionToSetup ) { - actionToSetup->setText( "New Polygon" ); + actionToSetup->setText( "Create Polygon" ); actionToSetup->setIcon( QIcon( ":/PolylinesFromFile16x16.png" ) ); } diff --git a/ApplicationLibCode/Commands/PolygonCommands/RicNewPolygonFeature.h b/ApplicationLibCode/Commands/PolygonCommands/RicCreatePolygonFeature.h similarity index 95% rename from ApplicationLibCode/Commands/PolygonCommands/RicNewPolygonFeature.h rename to ApplicationLibCode/Commands/PolygonCommands/RicCreatePolygonFeature.h index ebb92b9b2c..414d25f86c 100644 --- a/ApplicationLibCode/Commands/PolygonCommands/RicNewPolygonFeature.h +++ b/ApplicationLibCode/Commands/PolygonCommands/RicCreatePolygonFeature.h @@ -23,7 +23,7 @@ //================================================================================================== /// //================================================================================================== -class RicNewPolygonFeature : public caf::CmdFeature +class RicCreatePolygonFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; diff --git a/ApplicationLibCode/Commands/PolygonCommands/RicDuplicatePolygonFeature.cpp b/ApplicationLibCode/Commands/PolygonCommands/RicDuplicatePolygonFeature.cpp new file mode 100644 index 0000000000..7c0101dd7e --- /dev/null +++ b/ApplicationLibCode/Commands/PolygonCommands/RicDuplicatePolygonFeature.cpp @@ -0,0 +1,79 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 "RicDuplicatePolygonFeature.h" + +#include "RiaApplication.h" + +#include "Polygons/RimPolygon.h" +#include "Polygons/RimPolygonCollection.h" +#include "Polygons/RimPolygonInView.h" +#include "Polygons/RimPolygonTools.h" +#include "Rim3dView.h" +#include "RimOilField.h" +#include "RimProject.h" + +#include "Riu3DMainWindowTools.h" + +#include "cafSelectionManager.h" +#include + +CAF_CMD_SOURCE_INIT( RicDuplicatePolygonFeature, "RicDuplicatePolygonFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicDuplicatePolygonFeature::onActionTriggered( bool isChecked ) +{ + auto sourcePolygon = caf::SelectionManager::instance()->selectedItemOfType(); + if ( !sourcePolygon ) + { + auto sourcePolygonInView = caf::SelectionManager::instance()->selectedItemOfType(); + if ( sourcePolygonInView ) + { + sourcePolygon = sourcePolygonInView->polygon(); + } + } + + if ( !sourcePolygon ) return; + + auto proj = RimProject::current(); + auto polygonCollection = proj->activeOilField()->polygonCollection(); + + auto newPolygon = polygonCollection->createUserDefinedPolygon(); + newPolygon->setPointsInDomainCoords( sourcePolygon->pointsInDomainCoords() ); + auto sourceName = sourcePolygon->name(); + newPolygon->setName( "Copy of " + sourceName ); + polygonCollection->addUserDefinedPolygon( newPolygon ); + + polygonCollection->uiCapability()->updateAllRequiredEditors(); + + Riu3DMainWindowTools::setExpanded( newPolygon ); + + auto activeView = RiaApplication::instance()->activeReservoirView(); + RimPolygonTools::selectPolygonInView( newPolygon, activeView ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicDuplicatePolygonFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setText( "Duplicate Polygon" ); + actionToSetup->setIcon( QIcon( ":/caf/duplicate.svg" ) ); +} diff --git a/ApplicationLibCode/Commands/PolygonCommands/RicDuplicatePolygonFeature.h b/ApplicationLibCode/Commands/PolygonCommands/RicDuplicatePolygonFeature.h new file mode 100644 index 0000000000..a54a5975fa --- /dev/null +++ b/ApplicationLibCode/Commands/PolygonCommands/RicDuplicatePolygonFeature.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 RicDuplicatePolygonFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; +}; diff --git a/ApplicationLibCode/Commands/PolygonCommands/RicExportPolygonCsvFeature.cpp b/ApplicationLibCode/Commands/PolygonCommands/RicExportPolygonCsvFeature.cpp new file mode 100644 index 0000000000..64e05b7942 --- /dev/null +++ b/ApplicationLibCode/Commands/PolygonCommands/RicExportPolygonCsvFeature.cpp @@ -0,0 +1,82 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicExportPolygonCsvFeature.h" + +#include "RiaGuiApplication.h" +#include "RiaLogging.h" + +#include "Polygons/RimPolygon.h" +#include "Polygons/RimPolygonInView.h" +#include "Polygons/RimPolygonTools.h" + +#include "RiuFileDialogTools.h" + +#include "cafSelectionManager.h" + +#include +#include + +CAF_CMD_SOURCE_INIT( RicExportPolygonCsvFeature, "RicExportPolygonCsvFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicExportPolygonCsvFeature::onActionTriggered( bool isChecked ) +{ + auto sourcePolygon = caf::SelectionManager::instance()->selectedItemOfType(); + if ( !sourcePolygon ) + { + auto sourcePolygonInView = caf::SelectionManager::instance()->selectedItemOfType(); + if ( sourcePolygonInView ) + { + sourcePolygon = sourcePolygonInView->polygon(); + } + } + + if ( !sourcePolygon ) return; + + auto app = RiaGuiApplication::instance(); + auto fallbackPath = app->lastUsedDialogDirectory( "BINARY_GRID" ); + auto polygonPath = app->lastUsedDialogDirectoryWithFallback( RimPolygonTools::polygonCacheName(), fallbackPath ); + auto polygonFileName = polygonPath + "/" + sourcePolygon->name() + ".csv"; + + auto fileName = RiuFileDialogTools::getSaveFileName( nullptr, + "Select File for Polygon Export to CSV", + polygonFileName, + "CSV Files (*.csv);;All files(*.*)" ); + + if ( !RimPolygonTools::exportPolygonCsv( sourcePolygon, fileName ) ) + { + RiaLogging::error( "Failed to export polygon to " + fileName ); + } + else + { + RiaLogging::info( "Completed polygon export to " + fileName ); + app->setLastUsedDialogDirectory( RimPolygonTools::polygonCacheName(), QFileInfo( fileName ).absolutePath() ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicExportPolygonCsvFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setText( "Export Polygon CSV" ); + actionToSetup->setIcon( QIcon( ":/Save.svg" ) ); +} diff --git a/ApplicationLibCode/Commands/PolygonCommands/RicExportPolygonCsvFeature.h b/ApplicationLibCode/Commands/PolygonCommands/RicExportPolygonCsvFeature.h new file mode 100644 index 0000000000..844b87248a --- /dev/null +++ b/ApplicationLibCode/Commands/PolygonCommands/RicExportPolygonCsvFeature.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 RicExportPolygonCsvFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; +}; diff --git a/ApplicationLibCode/Commands/PolygonCommands/RicExportPolygonPolFeature.cpp b/ApplicationLibCode/Commands/PolygonCommands/RicExportPolygonPolFeature.cpp new file mode 100644 index 0000000000..cfdf1839f4 --- /dev/null +++ b/ApplicationLibCode/Commands/PolygonCommands/RicExportPolygonPolFeature.cpp @@ -0,0 +1,82 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicExportPolygonPolFeature.h" + +#include "RiaGuiApplication.h" +#include "RiaLogging.h" + +#include "Polygons/RimPolygon.h" +#include "Polygons/RimPolygonInView.h" +#include "Polygons/RimPolygonTools.h" + +#include "RiuFileDialogTools.h" + +#include "cafSelectionManager.h" + +#include +#include + +CAF_CMD_SOURCE_INIT( RicExportPolygonPolFeature, "RicExportPolygonPolFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicExportPolygonPolFeature::onActionTriggered( bool isChecked ) +{ + auto sourcePolygon = caf::SelectionManager::instance()->selectedItemOfType(); + if ( !sourcePolygon ) + { + auto sourcePolygonInView = caf::SelectionManager::instance()->selectedItemOfType(); + if ( sourcePolygonInView ) + { + sourcePolygon = sourcePolygonInView->polygon(); + } + } + + if ( !sourcePolygon ) return; + + auto app = RiaGuiApplication::instance(); + auto fallbackPath = app->lastUsedDialogDirectory( "BINARY_GRID" ); + auto polygonPath = app->lastUsedDialogDirectoryWithFallback( RimPolygonTools::polygonCacheName(), fallbackPath ); + auto polygonFileName = polygonPath + "/" + sourcePolygon->name() + ".pol"; + + auto fileName = RiuFileDialogTools::getSaveFileName( nullptr, + "Select File for Polygon Export to POL", + polygonFileName, + "POL Files (*.pol);;All files(*.*)" ); + + if ( !RimPolygonTools::exportPolygonPol( sourcePolygon, fileName ) ) + { + RiaLogging::error( "Failed to export polygon to " + fileName ); + } + else + { + RiaLogging::info( "Completed polygon export to " + fileName ); + RiaApplication::instance()->setLastUsedDialogDirectory( RimPolygonTools::polygonCacheName(), QFileInfo( fileName ).absolutePath() ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicExportPolygonPolFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setText( "Export Polygon POL" ); + actionToSetup->setIcon( QIcon( ":/Save.svg" ) ); +} diff --git a/ApplicationLibCode/Commands/PolygonCommands/RicExportPolygonPolFeature.h b/ApplicationLibCode/Commands/PolygonCommands/RicExportPolygonPolFeature.h new file mode 100644 index 0000000000..66f3a7babb --- /dev/null +++ b/ApplicationLibCode/Commands/PolygonCommands/RicExportPolygonPolFeature.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 RicExportPolygonPolFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; +}; diff --git a/ApplicationLibCode/Commands/PolygonCommands/RicImportPolygonFileFeature.cpp b/ApplicationLibCode/Commands/PolygonCommands/RicImportPolygonFileFeature.cpp new file mode 100644 index 0000000000..f4f1ffc8ed --- /dev/null +++ b/ApplicationLibCode/Commands/PolygonCommands/RicImportPolygonFileFeature.cpp @@ -0,0 +1,87 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 "RicImportPolygonFileFeature.h" + +#include "RiaApplication.h" + +#include "Polygons/RimPolygon.h" +#include "Polygons/RimPolygonCollection.h" +#include "Polygons/RimPolygonFile.h" +#include "Polygons/RimPolygonTools.h" +#include "RimOilField.h" +#include "RimProject.h" + +#include "Riu3DMainWindowTools.h" +#include "RiuFileDialogTools.h" + +#include +#include + +CAF_CMD_SOURCE_INIT( RicImportPolygonFileFeature, "RicImportPolygonFileFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicImportPolygonFileFeature::onActionTriggered( bool isChecked ) +{ + RiaApplication* app = RiaApplication::instance(); + + auto fallbackPath = app->lastUsedDialogDirectory( "BINARY_GRID" ); + auto polygonPath = app->lastUsedDialogDirectoryWithFallback( RimPolygonTools::polygonCacheName(), fallbackPath ); + + QStringList fileNames = RiuFileDialogTools::getOpenFileNames( Riu3DMainWindowTools::mainWindowWidget(), + "Import Polygons", + polygonPath, + "Polylines (*.csv *.dat *.pol);;Text Files (*.txt);;Polylines " + "(*.dat);;Polylines (*.pol);;Polylines (*.csv);;All Files (*.*)" ); + + if ( fileNames.isEmpty() ) return; + + // Remember the path to next time + app->setLastUsedDialogDirectory( RimPolygonTools::polygonCacheName(), QFileInfo( fileNames.last() ).absolutePath() ); + + auto proj = RimProject::current(); + auto polygonCollection = proj->activeOilField()->polygonCollection(); + + RimPolygon* objectToSelect = nullptr; + + for ( const auto& filename : fileNames ) + { + auto newPolygonFile = new RimPolygonFile(); + newPolygonFile->setFileName( filename ); + newPolygonFile->loadData(); + polygonCollection->addPolygonFile( newPolygonFile ); + + if ( !newPolygonFile->polygons().empty() ) objectToSelect = newPolygonFile->polygons().front(); + } + + polygonCollection->uiCapability()->updateAllRequiredEditors(); + + Riu3DMainWindowTools::setExpanded( objectToSelect ); + Riu3DMainWindowTools::selectAsCurrentItem( objectToSelect ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicImportPolygonFileFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setText( "Import Polygon" ); + actionToSetup->setIcon( QIcon( ":/PolylinesFromFile16x16.png" ) ); +} diff --git a/ApplicationLibCode/Commands/PolygonCommands/RicImportPolygonFileFeature.h b/ApplicationLibCode/Commands/PolygonCommands/RicImportPolygonFileFeature.h new file mode 100644 index 0000000000..c1309c517a --- /dev/null +++ b/ApplicationLibCode/Commands/PolygonCommands/RicImportPolygonFileFeature.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 RicImportPolygonFileFeature : 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/RicReloadPolygonFileFeature.cpp similarity index 53% rename from ApplicationLibCode/Commands/PolygonCommands/RicNewPolygonFileFeature.cpp rename to ApplicationLibCode/Commands/PolygonCommands/RicReloadPolygonFileFeature.cpp index 3c061583d2..b3bb1ff89c 100644 --- a/ApplicationLibCode/Commands/PolygonCommands/RicNewPolygonFileFeature.cpp +++ b/ApplicationLibCode/Commands/PolygonCommands/RicReloadPolygonFileFeature.cpp @@ -16,42 +16,36 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RicNewPolygonFileFeature.h" +#include "RicReloadPolygonFileFeature.h" -#include "Polygons/RimPolygon.h" -#include "Polygons/RimPolygonCollection.h" #include "Polygons/RimPolygonFile.h" -#include "RimOilField.h" -#include "RimProject.h" -#include "RiuPlotMainWindowTools.h" +#include "cafSelectionManager.h" #include -CAF_CMD_SOURCE_INIT( RicNewPolygonFileFeature, "RicNewPolygonFileFeature" ); +CAF_CMD_SOURCE_INIT( RicReloadPolygonFileFeature, "RicReloadPolygonFileFeature" ); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicNewPolygonFileFeature::onActionTriggered( bool isChecked ) +void RicReloadPolygonFileFeature::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 ); + auto polygonFile = caf::SelectionManager::instance()->selectedItemOfType(); + if ( polygonFile ) + { + polygonFile->loadData(); + polygonFile->objectChanged.send(); + + polygonFile->updateConnectedEditors(); + } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicNewPolygonFileFeature::setupActionLook( QAction* actionToSetup ) +void RicReloadPolygonFileFeature::setupActionLook( QAction* actionToSetup ) { - actionToSetup->setText( "New File Polygon" ); - actionToSetup->setIcon( QIcon( ":/PolylinesFromFile16x16.png" ) ); + actionToSetup->setText( "Reload" ); + actionToSetup->setIcon( QIcon( ":/Refresh.svg" ) ); } diff --git a/ApplicationLibCode/Commands/PolygonCommands/RicReloadPolygonFileFeature.h b/ApplicationLibCode/Commands/PolygonCommands/RicReloadPolygonFileFeature.h new file mode 100644 index 0000000000..14d4a263a2 --- /dev/null +++ b/ApplicationLibCode/Commands/PolygonCommands/RicReloadPolygonFileFeature.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 RicReloadPolygonFileFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; +}; diff --git a/ApplicationLibCode/Commands/PolygonCommands/RicSimplifyPolygonFeature.cpp b/ApplicationLibCode/Commands/PolygonCommands/RicSimplifyPolygonFeature.cpp new file mode 100644 index 0000000000..d8695176fc --- /dev/null +++ b/ApplicationLibCode/Commands/PolygonCommands/RicSimplifyPolygonFeature.cpp @@ -0,0 +1,73 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 "RicSimplifyPolygonFeature.h" + +#include "Polygons/RimPolygon.h" +#include "Polygons/RimPolygonInView.h" + +#include "RigCellGeometryTools.h" + +#include "cafSelectionManager.h" + +#include +#include + +CAF_CMD_SOURCE_INIT( RicSimplifyPolygonFeature, "RicSimplifyPolygonFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSimplifyPolygonFeature::onActionTriggered( bool isChecked ) +{ + auto sourcePolygon = caf::SelectionManager::instance()->selectedItemOfType(); + if ( !sourcePolygon ) + { + auto sourcePolygonInView = caf::SelectionManager::instance()->selectedItemOfType(); + if ( sourcePolygonInView ) + { + sourcePolygon = sourcePolygonInView->polygon(); + } + } + + if ( !sourcePolygon ) return; + + const double defaultEpsilon = 10.0; + + bool ok; + auto epsilon = + QInputDialog::getDouble( nullptr, "Simplify Polygon Threshold", "Threshold:", defaultEpsilon, 1.0, 1000.0, 1, &ok, Qt::WindowFlags(), 1 ); + + if ( ok ) + { + auto coords = sourcePolygon->pointsInDomainCoords(); + RigCellGeometryTools::simplifyPolygon( &coords, epsilon ); + + sourcePolygon->setPointsInDomainCoords( coords ); + sourcePolygon->coordinatesChanged.send(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSimplifyPolygonFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setText( "Simplify Polygon" ); + actionToSetup->setIcon( QIcon( ":/PolylinesFromFile16x16.png" ) ); +} diff --git a/ApplicationLibCode/Commands/PolygonCommands/RicNewPolygonFileFeature.h b/ApplicationLibCode/Commands/PolygonCommands/RicSimplifyPolygonFeature.h similarity index 95% rename from ApplicationLibCode/Commands/PolygonCommands/RicNewPolygonFileFeature.h rename to ApplicationLibCode/Commands/PolygonCommands/RicSimplifyPolygonFeature.h index 8c3ff090ef..1b74d5876c 100644 --- a/ApplicationLibCode/Commands/PolygonCommands/RicNewPolygonFileFeature.h +++ b/ApplicationLibCode/Commands/PolygonCommands/RicSimplifyPolygonFeature.h @@ -23,7 +23,7 @@ //================================================================================================== /// //================================================================================================== -class RicNewPolygonFileFeature : public caf::CmdFeature +class RicSimplifyPolygonFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; diff --git a/ApplicationLibCode/Commands/RicCopyGridStatisticsToClipboardFeature.cpp b/ApplicationLibCode/Commands/RicCopyGridStatisticsToClipboardFeature.cpp index 665ff94603..c0d3f023e8 100644 --- a/ApplicationLibCode/Commands/RicCopyGridStatisticsToClipboardFeature.cpp +++ b/ApplicationLibCode/Commands/RicCopyGridStatisticsToClipboardFeature.cpp @@ -18,7 +18,7 @@ #include "RicCopyGridStatisticsToClipboardFeature.h" -#include "RiaApplication.h" +#include "RiaGuiApplication.h" #include "RicWellLogTools.h" diff --git a/ApplicationLibCode/Commands/RicCreateEnsembleSurfaceUi.cpp b/ApplicationLibCode/Commands/RicCreateEnsembleSurfaceUi.cpp index f29e549794..49b2dbec12 100644 --- a/ApplicationLibCode/Commands/RicCreateEnsembleSurfaceUi.cpp +++ b/ApplicationLibCode/Commands/RicCreateEnsembleSurfaceUi.cpp @@ -22,7 +22,6 @@ #include "cafPdmObject.h" #include "cafPdmUiCheckBoxEditor.h" -#include "cafPdmUiOrdering.h" #include "cafPdmUiTreeSelectionEditor.h" CAF_PDM_SOURCE_INIT( RicCreateEnsembleSurfaceUi, "RicCreateEnsembleSurfaceUi" ); diff --git a/ApplicationLibCode/Commands/RicCreateEnsembleWellLogUi.cpp b/ApplicationLibCode/Commands/RicCreateEnsembleWellLogUi.cpp index f486cf5dda..4d81c07d67 100644 --- a/ApplicationLibCode/Commands/RicCreateEnsembleWellLogUi.cpp +++ b/ApplicationLibCode/Commands/RicCreateEnsembleWellLogUi.cpp @@ -34,7 +34,6 @@ #include "cafPdmObject.h" #include "cafPdmUiCheckBoxEditor.h" #include "cafPdmUiFilePathEditor.h" -#include "cafPdmUiOrdering.h" #include "cafPdmUiTreeSelectionEditor.h" CAF_PDM_SOURCE_INIT( RicCreateEnsembleWellLogUi, "RicCreateEnsembleWellLogUi" ); diff --git a/ApplicationLibCode/Commands/SeismicCommands/RicNewSeismicDifferenceFeature.cpp b/ApplicationLibCode/Commands/SeismicCommands/RicNewSeismicDifferenceFeature.cpp index 9e0b15332b..39df6fa9da 100644 --- a/ApplicationLibCode/Commands/SeismicCommands/RicNewSeismicDifferenceFeature.cpp +++ b/ApplicationLibCode/Commands/SeismicCommands/RicNewSeismicDifferenceFeature.cpp @@ -18,7 +18,7 @@ #include "RicNewSeismicDifferenceFeature.h" -#include "RiaApplication.h" +#include "RiaGuiApplication.h" #include "RimOilField.h" #include "RimProject.h" diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp index b7f465dfc0..25bb643b7c 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp @@ -286,6 +286,7 @@ void RicNewWellBoreStabilityPlotFeature::createParametersTrack( RimWellBoreStabi curve->setLineThickness( 2 ); curve->loadDataAndUpdate( false ); curve->setAutoNameComponents( false, true, false, false, false ); + curve->updateCurveName(); i++; } @@ -352,6 +353,7 @@ void RicNewWellBoreStabilityPlotFeature::createStabilityCurvesTrack( RimWellBore { curve->setCheckState( false ); } + curve->updateCurveName(); } RimWellPathCollection* wellPathCollection = RimTools::wellPathCollection(); @@ -392,11 +394,13 @@ std::pair 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 }; + return { cvf::Color3f::DEEP_PINK, RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID }; + if ( resultName == RiaResultNames::wbsPPExpResult() ) + return { cvf::Color3f::DEEP_PINK, RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_DASH }; + if ( resultName == RiaResultNames::wbsPPMinResult() ) + return { cvf::Color3f::DEEP_PINK, RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_DOT }; if ( resultName == RiaResultNames::wbsPPMaxResult() ) - return { cvf::Color3f::RED, RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_DASH_DOT }; + return { cvf::Color3f::DEEP_PINK, RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_DASH_DOT }; return { colors[i % colors.size()], RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID }; } diff --git a/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicWellTarget3dEditor.cpp b/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicWellTarget3dEditor.cpp index 05c878c35a..471e5eeebb 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicWellTarget3dEditor.cpp +++ b/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicWellTarget3dEditor.cpp @@ -40,6 +40,8 @@ #include "cvfModelBasicList.h" #include "cvfPart.h" +#include + CAF_PDM_UI_3D_OBJECT_EDITOR_SOURCE_INIT( RicWellTarget3dEditor ); //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicCreateWellTargetsPickEventHandler.cpp b/ApplicationLibCode/Commands/WellPathCommands/RicCreateWellTargetsPickEventHandler.cpp index 69b73bd1cd..f864f55675 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicCreateWellTargetsPickEventHandler.cpp +++ b/ApplicationLibCode/Commands/WellPathCommands/RicCreateWellTargetsPickEventHandler.cpp @@ -31,19 +31,17 @@ #include "RimEclipseView.h" #include "RimGeoMechView.h" #include "RimModeledWellPath.h" -#include "RimWellPath.h" #include "RimWellPathGeometryDef.h" #include "RimWellPathTarget.h" -#include "RiuViewerCommands.h" - #include "RivFemPartGeometryGenerator.h" #include "RivFemPickSourceInfo.h" #include "RivSourceInfo.h" #include "RivWellPathSourceInfo.h" #include "cafDisplayCoordTransform.h" -#include "cafSelectionManager.h" + +#include #include diff --git a/ApplicationLibCode/FileInterface/CMakeLists_files.cmake b/ApplicationLibCode/FileInterface/CMakeLists_files.cmake index 310f3cfbd9..8d2d0a8123 100644 --- a/ApplicationLibCode/FileInterface/CMakeLists_files.cmake +++ b/ApplicationLibCode/FileInterface/CMakeLists_files.cmake @@ -95,6 +95,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RifSummaryCalculation.h ${CMAKE_CURRENT_LIST_DIR}/RifSummaryCalculationImporter.h ${CMAKE_CURRENT_LIST_DIR}/RifSummaryCalculationExporter.h + ${CMAKE_CURRENT_LIST_DIR}/RifPolygonReader.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -189,6 +190,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RifGridCalculationExporter.cpp ${CMAKE_CURRENT_LIST_DIR}/RifSummaryCalculationImporter.cpp ${CMAKE_CURRENT_LIST_DIR}/RifSummaryCalculationExporter.cpp + ${CMAKE_CURRENT_LIST_DIR}/RifPolygonReader.cpp ) list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) diff --git a/ApplicationLibCode/FileInterface/RifCsvDataTableFormatter.cpp b/ApplicationLibCode/FileInterface/RifCsvDataTableFormatter.cpp index f94fa2892a..98600886d4 100644 --- a/ApplicationLibCode/FileInterface/RifCsvDataTableFormatter.cpp +++ b/ApplicationLibCode/FileInterface/RifCsvDataTableFormatter.cpp @@ -118,7 +118,7 @@ void RifCsvDataTableFormatter::tableCompleted() //-------------------------------------------------------------------------------------------------- void RifCsvDataTableFormatter::outputBuffer() { - if ( !m_columnHeaders.empty() ) + if ( isAnyTextInHeader() ) { for ( size_t i = 0; i < m_columnHeaders.size(); i++ ) { @@ -152,3 +152,21 @@ void RifCsvDataTableFormatter::outputBuffer() m_columnHeaders.clear(); m_buffer.clear(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifCsvDataTableFormatter::isAnyTextInHeader() const +{ + for ( auto& header : m_columnHeaders ) + { + for ( const auto& titleRow : header.titles ) + { + if ( !titleRow.trimmed().isEmpty() ) + { + return true; + } + } + } + return false; +} diff --git a/ApplicationLibCode/FileInterface/RifCsvDataTableFormatter.h b/ApplicationLibCode/FileInterface/RifCsvDataTableFormatter.h index 57b20d91d3..46f0d9649b 100644 --- a/ApplicationLibCode/FileInterface/RifCsvDataTableFormatter.h +++ b/ApplicationLibCode/FileInterface/RifCsvDataTableFormatter.h @@ -42,6 +42,7 @@ class RifCsvDataTableFormatter private: void outputBuffer(); + bool isAnyTextInHeader() const; private: QTextStream& m_out; diff --git a/ApplicationLibCode/FileInterface/RifFaultReactivationModelExporter.cpp b/ApplicationLibCode/FileInterface/RifFaultReactivationModelExporter.cpp index 3f97281136..22cb9bbbc3 100644 --- a/ApplicationLibCode/FileInterface/RifFaultReactivationModelExporter.cpp +++ b/ApplicationLibCode/FileInterface/RifFaultReactivationModelExporter.cpp @@ -204,13 +204,13 @@ std::pair RifFaultReactivationModelExporter::printParts( for ( auto [boundary, boundaryName] : boundaries ) { // Create boundary condition sets for each side of the parts (except top). - auto boundaryNodes = grid->boundaryNodes(); - auto boundaryElements = grid->boundaryElements(); + const auto& boundaryNodes = grid->boundaryNodes(); + const auto& boundaryElements = grid->boundaryElements(); - const std::vector& nodes = boundaryNodes[boundary]; + const std::vector& nodes = boundaryNodes.at( boundary ); RifInpExportTools::printNodeSet( stream, boundaryName, false, nodes ); - const std::vector& elements = boundaryElements[boundary]; + const std::vector& elements = boundaryElements.at( boundary ); RifInpExportTools::printElementSet( stream, boundaryName, false, elements ); } @@ -834,6 +834,10 @@ bool RifFaultReactivationModelExporter::exportModelSettings( const RimFaultReact auto [topPosition, bottomPosition] = model->faultTopBottom(); auto faultNormal = model->modelNormal(); + // make sure we export in local coordinates, if that is used + topPosition = model->transformPointIfNeeded( topPosition ); + bottomPosition = model->transformPointIfNeeded( bottomPosition ); + // make sure we move horizontally, and along the 2D model faultNormal.z() = 0.0; faultNormal.normalize(); diff --git a/ApplicationLibCode/FileInterface/RifInpExportTools.cpp b/ApplicationLibCode/FileInterface/RifInpExportTools.cpp index 19c792f37d..f4a7957e11 100644 --- a/ApplicationLibCode/FileInterface/RifInpExportTools.cpp +++ b/ApplicationLibCode/FileInterface/RifInpExportTools.cpp @@ -61,7 +61,7 @@ bool RifInpExportTools::printNodes( std::ostream& stream, const std::vector map ) { QFile file; file.setFileName( filePath ); - if ( file.open( QIODevice::ReadWrite | QIODevice::Text ) ) + if ( file.open( QIODevice::ReadWrite | QIODevice::Text | QIODevice::Truncate ) ) { QString content = Json::encode( map, true ); QTextStream out( &file ); diff --git a/ApplicationLibCode/FileInterface/RifPolygonReader.cpp b/ApplicationLibCode/FileInterface/RifPolygonReader.cpp new file mode 100644 index 0000000000..2bfbd34e3c --- /dev/null +++ b/ApplicationLibCode/FileInterface/RifPolygonReader.cpp @@ -0,0 +1,209 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RifPolygonReader.h" + +#include "RiaTextStringTools.h" + +#include "SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeatureUi.h" + +#include "RifCsvUserDataParser.h" + +#include +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector>> RifPolygonReader::parsePolygonFile( const QString& fileName, QString* errorMessage ) +{ + QFileInfo fi( fileName ); + + QFile dataFile( fileName ); + + if ( !dataFile.open( QFile::ReadOnly ) ) + { + if ( errorMessage ) ( *errorMessage ) += "Could not open file: " + fileName + "\n"; + return {}; + } + + QTextStream stream( &dataFile ); + auto fileContent = stream.readAll(); + + if ( fi.suffix().trimmed().toLower() == "csv" ) + { + return parseTextCsv( fileContent, errorMessage ); + } + else + { + auto polygons = parseText( fileContent, errorMessage ); + + std::vector>> polygonsWithIds; + for ( auto& polygon : polygons ) + { + polygonsWithIds.push_back( std::make_pair( -1, polygon ) ); + } + + return polygonsWithIds; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector> RifPolygonReader::parseText( const QString& content, QString* errorMessage ) +{ + std::vector> polylines( 1 ); + + QString myString = content; + QTextStream stream( &myString ); + int lineNumber = 1; + while ( !stream.atEnd() ) + { + QString line = stream.readLine(); + QStringList commentLineSegs = line.split( "#" ); + if ( commentLineSegs.empty() ) continue; // Empty line + + QStringList lineSegs = RiaTextStringTools::splitSkipEmptyParts( commentLineSegs[0], QRegExp( "\\s+" ) ); + + if ( lineSegs.empty() ) continue; // No data + + if ( lineSegs.size() != 3 ) + { + if ( errorMessage ) ( *errorMessage ) += "Unexpected number of words on line: " + QString::number( lineNumber ) + "\n"; + continue; + } + + { + bool isNumberParsingOk = true; + bool isOk = true; + double x = lineSegs[0].toDouble( &isOk ); + isNumberParsingOk &= isOk; + double y = lineSegs[1].toDouble( &isOk ); + isNumberParsingOk &= isOk; + double z = lineSegs[2].toDouble( &isOk ); + isNumberParsingOk &= isOk; + + if ( !isNumberParsingOk ) + { + if ( errorMessage ) ( *errorMessage ) += "Could not read the point at line: " + QString::number( lineNumber ) + "\n"; + continue; + } + + if ( x == 999.0 && y == 999.0 && z == 999.0 ) // New PolyLine + { + polylines.push_back( std::vector() ); + continue; + } + + cvf::Vec3d point( x, y, -z ); + polylines.back().push_back( point ); + } + + ++lineNumber; + } + + if ( polylines.back().empty() ) + { + polylines.pop_back(); + } + + return polylines; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector>> RifPolygonReader::parseTextCsv( const QString& content, QString* errorMessage ) +{ + RifCsvUserDataPastedTextParser parser( content, errorMessage ); + + AsciiDataParseOptions parseOptions; + parseOptions.cellSeparator = ","; + parseOptions.decimalSeparator = "."; + + std::vector>> readValues; + + if ( parser.parse( parseOptions ) ) + { + for ( auto s : parser.tableData().columnInfos() ) + { + if ( s.dataType != Column::NUMERIC ) continue; + + QString columnName = QString::fromStdString( s.columnName() ); + bool isNumber = false; + auto value = columnName.toDouble( &isNumber ); + std::vector values = s.values; + if ( isNumber ) + { + values.insert( values.begin(), value ); + } + readValues.push_back( { columnName, values } ); + } + } + + if ( readValues.size() == 4 ) + { + // Three first columns represent XYZ, last column polygon ID + + const auto firstSize = readValues[0].second.size(); + if ( ( firstSize == readValues[1].second.size() ) && ( firstSize == readValues[2].second.size() ) && + ( firstSize == readValues[3].second.size() ) ) + { + std::vector>> polylines; + + std::vector polygon; + + int polygonId = -1; + for ( size_t i = 0; i < firstSize; i++ ) + { + int currentPolygonId = static_cast( readValues[3].second[i] ); + if ( polygonId != currentPolygonId ) + { + if ( !polygon.empty() ) polylines.push_back( std::make_pair( polygonId, polygon ) ); + polygon.clear(); + polygonId = currentPolygonId; + } + + cvf::Vec3d point( readValues[0].second[i], readValues[1].second[i], -readValues[2].second[i] ); + + polygon.push_back( point ); + } + + if ( !polygon.empty() ) polylines.push_back( std::make_pair( polygonId, polygon ) ); + + return polylines; + } + } + + if ( readValues.size() == 3 ) + { + std::vector points; + + for ( size_t i = 0; i < readValues[0].second.size(); i++ ) + { + cvf::Vec3d point( readValues[0].second[i], readValues[1].second[i], -readValues[2].second[i] ); + points.push_back( point ); + } + + int polygonId = -1; + return { std::make_pair( polygonId, points ) }; + } + + return {}; +} diff --git a/ApplicationLibCode/FileInterface/RifPolygonReader.h b/ApplicationLibCode/FileInterface/RifPolygonReader.h new file mode 100644 index 0000000000..da7a91b78f --- /dev/null +++ b/ApplicationLibCode/FileInterface/RifPolygonReader.h @@ -0,0 +1,40 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "cvfVector3.h" + +#include + +#include + +//================================================================================================== +// +// +//================================================================================================== +class RifPolygonReader +{ +public: + static std::vector>> parsePolygonFile( const QString& fileName, QString* errorMessage ); + + // Defined public for testing purposes +public: + static std::vector> parseText( const QString& content, QString* errorMessage ); + static std::vector>> parseTextCsv( const QString& content, QString* errorMessage ); +}; diff --git a/ApplicationLibCode/FileInterface/RifSurfaceImporter.cpp b/ApplicationLibCode/FileInterface/RifSurfaceImporter.cpp index 5ad12dd943..0982f47799 100644 --- a/ApplicationLibCode/FileInterface/RifSurfaceImporter.cpp +++ b/ApplicationLibCode/FileInterface/RifSurfaceImporter.cpp @@ -465,6 +465,8 @@ std::pair, std::vector> RifSurfaceImporter::re } } + if ( surfacePoints.empty() ) return { {}, {} }; + // Determine axes vectors std::vector> pairs; for ( auto itr = axesVectorCandidatesNum.begin(); itr != axesVectorCandidatesNum.end(); ++itr ) diff --git a/ApplicationLibCode/FileInterface/RifTextDataTableFormatter.cpp b/ApplicationLibCode/FileInterface/RifTextDataTableFormatter.cpp index 811deb01e4..b3756e3ce8 100644 --- a/ApplicationLibCode/FileInterface/RifTextDataTableFormatter.cpp +++ b/ApplicationLibCode/FileInterface/RifTextDataTableFormatter.cpp @@ -320,7 +320,13 @@ bool RifTextDataTableFormatter::isAllHeadersEmpty( const std::vectorresize( femPart->elementCount() ); @@ -74,9 +75,19 @@ void RivFemElmVisibilityCalculator::computeRangeVisibility( cvf::UByteArray* for ( int elmIdx = 0; elmIdx < femPart->elementCount(); ++elmIdx ) { grid->ijkFromCellIndex( elmIdx, &mainGridI, &mainGridJ, &mainGridK ); - ( *elmVisibilities )[elmIdx] = - ( ( *indexIncludeVisibility )[elmIdx] || rangeFilter.isCellVisible( mainGridI, mainGridJ, mainGridK, false ) ) && - ( *indexExcludeVisibility )[elmIdx]; + + if ( useAndOperation ) + { + ( *elmVisibilities )[elmIdx] = + ( ( *indexIncludeVisibility )[elmIdx] && rangeFilter.isCellVisible( mainGridI, mainGridJ, mainGridK, false ) ) && + ( *indexExcludeVisibility )[elmIdx]; + } + else + { + ( *elmVisibilities )[elmIdx] = + ( ( *indexIncludeVisibility )[elmIdx] || rangeFilter.isCellVisible( mainGridI, mainGridJ, mainGridK, false ) ) && + ( *indexExcludeVisibility )[elmIdx]; + } } } else diff --git a/ApplicationLibCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.h b/ApplicationLibCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.h index 1b2529ad75..a0d3a567bd 100644 --- a/ApplicationLibCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.h +++ b/ApplicationLibCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.h @@ -41,7 +41,8 @@ class RivFemElmVisibilityCalculator const cvf::CellRangeFilter& rangeFilter, const cvf::UByteArray* indexIncludeVisibility, const cvf::UByteArray* indexExcludeVisibility, - bool useIndexInclude ); + bool useIndexInclude, + bool useAndOperation ); static void computePropertyVisibility( cvf::UByteArray* cellVisibility, const RigFemPart* grid, diff --git a/ApplicationLibCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp b/ApplicationLibCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp index dca38c6410..223ef6f37a 100644 --- a/ApplicationLibCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp @@ -251,7 +251,8 @@ RivGeoMechPartMgr* RivGeoMechVizLogic::getUpdatedPartMgr( RivGeoMechPartMgrCache cellRangeFilter, &indexIncludeVisibility, &indexExcludeVisibility, - m_geomechView->cellFilterCollection()->hasActiveIncludeIndexFilters() ); + m_geomechView->cellFilterCollection()->hasActiveIncludeIndexFilters(), + m_geomechView->cellFilterCollection()->useAndOperation() ); } else if ( pMgrKey.geometryType() == PROPERTY_FILTERED ) { diff --git a/ApplicationLibCode/ModelVisualization/RivReservoirViewPartMgr.cpp b/ApplicationLibCode/ModelVisualization/RivReservoirViewPartMgr.cpp index ac55abb8f4..5e39ce8166 100644 --- a/ApplicationLibCode/ModelVisualization/RivReservoirViewPartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/RivReservoirViewPartMgr.cpp @@ -749,9 +749,11 @@ void RivReservoirViewPartMgr::computeFilterVisibility( RivCellSetEnum parentGridVisibilities = reservoirGridPartMgr->cellVisibility( parentGridIndex ); } - bool hasAdditiveRangeFilters = cellFilterColl->hasActiveIncludeRangeFilters() || - m_reservoirView->wellCollection()->hasVisibleWellCells(); - bool hasAdditiveIndexFilters = cellFilterColl->hasActiveIncludeIndexFilters(); + const bool hasAdditiveRangeFilters = cellFilterColl->hasActiveIncludeRangeFilters() || + m_reservoirView->wellCollection()->hasVisibleWellCells(); + const bool hasAdditiveIndexFilters = cellFilterColl->hasActiveIncludeIndexFilters(); + + const bool useAndOperation = cellFilterColl->useAndOperation(); #pragma omp parallel for for ( int cellIndex = 0; cellIndex < static_cast( grid->cellCount() ); cellIndex++ ) @@ -771,7 +773,7 @@ void RivReservoirViewPartMgr::computeFilterVisibility( RivCellSetEnum size_t mainGridJ; size_t mainGridK; - bool isInSubGridArea = cell.subGrid() != nullptr; + const bool isInSubGridArea = cell.subGrid() != nullptr; grid->ijkFromCellIndex( cellIndex, &mainGridI, &mainGridJ, &mainGridK ); bool nativeRangeVisibility = false; @@ -780,8 +782,16 @@ void RivReservoirViewPartMgr::computeFilterVisibility( RivCellSetEnum { if ( hasAdditiveIndexFilters ) { - nativeRangeVisibility = indexIncludeVisibility[cellIndex] || - gridCellRangeFilter.isCellVisible( mainGridI, mainGridJ, mainGridK, isInSubGridArea ); + if ( useAndOperation ) + { + nativeRangeVisibility = indexIncludeVisibility[cellIndex] && + gridCellRangeFilter.isCellVisible( mainGridI, mainGridJ, mainGridK, isInSubGridArea ); + } + else + { + nativeRangeVisibility = indexIncludeVisibility[cellIndex] || + gridCellRangeFilter.isCellVisible( mainGridI, mainGridJ, mainGridK, isInSubGridArea ); + } } else { diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesAnnotationInView.h b/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesAnnotationInView.h index aba72d219a..83852d2f6e 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesAnnotationInView.h +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesAnnotationInView.h @@ -28,7 +28,6 @@ #include "cafPdmObject.h" #include "cafPdmPointer.h" #include "cafPdmPtrField.h" -#include "cafPdmUiOrdering.h" // Include to make Pdm work for cvf::Color #include "cafPdmChildField.h" diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesFromFileAnnotationInView.h b/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesFromFileAnnotationInView.h index 213d4cfddd..2562dfb70e 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesFromFileAnnotationInView.h +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesFromFileAnnotationInView.h @@ -26,7 +26,6 @@ #include "cafPdmObject.h" #include "cafPdmPointer.h" #include "cafPdmPtrField.h" -#include "cafPdmUiOrdering.h" // Include to make Pdm work for cvf::Color #include "cafPdmChildField.h" diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimReachCircleAnnotation.h b/ApplicationLibCode/ProjectDataModel/Annotations/RimReachCircleAnnotation.h index c642077f30..d08ec594db 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimReachCircleAnnotation.h +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimReachCircleAnnotation.h @@ -23,7 +23,6 @@ #include "cafPdmField.h" #include "cafPdmObject.h" #include "cafPdmPointer.h" -#include "cafPdmUiOrdering.h" // Include to make Pdm work for cvf::Color #include "cafPdmChildField.h" diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimReachCircleAnnotationInView.h b/ApplicationLibCode/ProjectDataModel/Annotations/RimReachCircleAnnotationInView.h index 8cbca90336..1988f7b81c 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimReachCircleAnnotationInView.h +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimReachCircleAnnotationInView.h @@ -26,7 +26,6 @@ #include "cafPdmObject.h" #include "cafPdmPointer.h" #include "cafPdmPtrField.h" -#include "cafPdmUiOrdering.h" // Include to make Pdm work for cvf::Color #include "cafPdmChildField.h" diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimTextAnnotation.h b/ApplicationLibCode/ProjectDataModel/Annotations/RimTextAnnotation.h index 998418ed39..dc457a1b1b 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimTextAnnotation.h +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimTextAnnotation.h @@ -23,7 +23,6 @@ #include "cafPdmField.h" #include "cafPdmObject.h" #include "cafPdmPointer.h" -#include "cafPdmUiOrdering.h" // Include to make Pdm work for cvf::Color #include "cafPdmChildField.h" diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimTextAnnotationInView.h b/ApplicationLibCode/ProjectDataModel/Annotations/RimTextAnnotationInView.h index 6add6a3570..0d3548a269 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimTextAnnotationInView.h +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimTextAnnotationInView.h @@ -24,7 +24,6 @@ #include "cafPdmObject.h" #include "cafPdmPointer.h" #include "cafPdmPtrField.h" -#include "cafPdmUiOrdering.h" // Include to make Pdm work for cvf::Color #include "cafPdmChildField.h" diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimUserDefinedPolylinesAnnotationInView.h b/ApplicationLibCode/ProjectDataModel/Annotations/RimUserDefinedPolylinesAnnotationInView.h index 667258b8fb..8a707a46a2 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimUserDefinedPolylinesAnnotationInView.h +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimUserDefinedPolylinesAnnotationInView.h @@ -26,7 +26,6 @@ #include "cafPdmObject.h" #include "cafPdmPointer.h" #include "cafPdmPtrField.h" -#include "cafPdmUiOrdering.h" // Include to make Pdm work for cvf::Color #include "cafPdmChildField.h" diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp index c6b0c38d64..5fe2bb0774 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp @@ -24,6 +24,7 @@ #include "RimCellIndexFilter.h" #include "RimCellRangeFilter.h" #include "RimPolygonFilter.h" +#include "RimProject.h" #include "RimUserDefinedFilter.h" #include "RimUserDefinedIndexFilter.h" #include "RimViewController.h" @@ -32,8 +33,21 @@ #include "cafPdmFieldReorderCapability.h" #include "cafPdmFieldScriptingCapability.h" #include "cafPdmObjectScriptingCapability.h" +#include "cafPdmUiLabelEditor.h" + #include "cvfStructGridGeometryGenerator.h" +namespace caf +{ +template <> +void caf::AppEnum::setUp() +{ + addItem( RimCellFilterCollection::AND, "AND", "AND" ); + addItem( RimCellFilterCollection::OR, "OR", "OR" ); + setDefault( RimCellFilterCollection::AND ); +} +} // namespace caf + CAF_PDM_SOURCE_INIT( RimCellFilterCollection, "CellFilterCollection", "RimCellFilterCollection", "CellRangeFilterCollection" ); //-------------------------------------------------------------------------------------------------- @@ -47,6 +61,12 @@ RimCellFilterCollection::RimCellFilterCollection() CAF_PDM_InitScriptableField( &m_isActive, "Active", true, "Active" ); m_isActive.uiCapability()->setUiHidden( true ); + CAF_PDM_InitFieldNoDefault( &m_combineFilterMode, "CombineFilterMode", "" ); + + CAF_PDM_InitField( &m_combineModeLabel, "CombineModeLabel", QString( "" ), "Combine Polygon and Range Filters Using Operation" ); + m_combineModeLabel.uiCapability()->setUiEditorTypeName( caf::PdmUiLabelEditor::uiEditorTypeName() ); + m_combineModeLabel.xmlCapability()->disableIO(); + CAF_PDM_InitFieldNoDefault( &m_cellFilters, "CellFilters", "Filters" ); caf::PdmFieldReorderCapability::addToField( &m_cellFilters ); @@ -87,6 +107,14 @@ void RimCellFilterCollection::setActive( bool bActive ) updateIconState(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimCellFilterCollection::useAndOperation() const +{ + return m_combineFilterMode() == RimCellFilterCollection::AND; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -124,6 +152,12 @@ void RimCellFilterCollection::initAfterRead() m_cellFilters.push_back( filter ); } + // fallback to OR mode for older projects made without AND support + if ( RimProject::current()->isProjectFileVersionEqualOrOlderThan( "2023.12.0" ) ) + { + m_combineFilterMode = RimCellFilterCollection::OR; + } + // Copy by xml serialization does not give a RimCase parent the first time initAfterRead is called here when creating a new a contour // view from a 3d view. The second time we get called it is ok, so just skip setting up the filter connections if we have no case. auto rimCase = firstAncestorOrThisOfType(); @@ -161,6 +195,17 @@ caf::PdmFieldHandle* RimCellFilterCollection::objectToggleField() return &m_isActive; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCellFilterCollection::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +{ + uiOrdering.add( &m_combineModeLabel ); + uiOrdering.add( &m_combineFilterMode ); + + uiOrdering.skipRemainingFields(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -182,6 +227,18 @@ void RimCellFilterCollection::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTr updateIconState(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCellFilterCollection::defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) +{ + caf::PdmUiLabelEditorAttribute* myAttr = dynamic_cast( attribute ); + if ( myAttr ) + { + myAttr->m_useSingleWidgetInsteadOfLabelAndEditorWidget = true; + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.h b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.h index 7184a32541..45e23fc90b 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.h +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.h @@ -49,6 +49,12 @@ class RimCellFilterCollection : public caf::PdmObject CAF_PDM_HEADER_INIT; public: + enum CombineFilterModeType + { + OR, + AND + }; + RimCellFilterCollection(); ~RimCellFilterCollection() override; @@ -68,6 +74,8 @@ class RimCellFilterCollection : public caf::PdmObject bool isActive() const; void setActive( bool bActive ); + bool useAndOperation() const; + void compoundCellRangeFilter( cvf::CellRangeFilter* cellRangeFilter, size_t gridIndex ) const; void updateCellVisibilityByIndex( cvf::UByteArray* cellsIncluded, cvf::UByteArray* cellsExcluded, size_t gridIndex ) const; @@ -87,7 +95,10 @@ class RimCellFilterCollection : public caf::PdmObject protected: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName ) override; + void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; + caf::PdmFieldHandle* objectToggleField() override; void initAfterRead() override; @@ -97,8 +108,10 @@ class RimCellFilterCollection : public caf::PdmObject void setAutoName( RimCellFilter* pFilter ); void addFilter( RimCellFilter* pFilter ); - caf::PdmChildArrayField m_cellFilters; - caf::PdmField m_isActive; + caf::PdmChildArrayField m_cellFilters; + caf::PdmField m_isActive; + caf::PdmField m_combineModeLabel; + caf::PdmField> m_combineFilterMode; caf::PdmChildArrayField m_rangeFilters_OBSOLETE; }; diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp index 54614df48c..965c5bb2b6 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp @@ -330,7 +330,7 @@ void RimPolygonFilter::fieldChangedByUi( const caf::PdmFieldHandle* changedField { if ( changedField == &m_editPolygonButton ) { - RimPolygonTools::selectAndActivatePolygonInView( m_cellFilterPolygon(), this ); + RimPolygonTools::activate3dEditOfPolygonInView( m_cellFilterPolygon(), this ); m_editPolygonButton = false; diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathCompletionSettings.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathCompletionSettings.cpp index ca2b8c7424..38e292d358 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathCompletionSettings.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathCompletionSettings.cpp @@ -27,7 +27,6 @@ #include "cafPdmFieldScriptingCapability.h" #include "cafPdmObjectScriptingCapability.h" #include "cafPdmUiLineEditor.h" -#include "cafPdmUiOrdering.h" #include "cafPdmUiTreeOrdering.h" namespace caf diff --git a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationReportPlot.cpp b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationReportPlot.cpp index b36cd65c62..e75eb7d66d 100644 --- a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationReportPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationReportPlot.cpp @@ -33,7 +33,6 @@ #include "RiuQwtPlotWidget.h" #include "cafAssert.h" -#include "cafPdmUiOrdering.h" #include "cafPdmUiTreeOrdering.h" #include diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationEnums.h b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationEnums.h index cb2d84e242..6bc81eef46 100644 --- a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationEnums.h +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationEnums.h @@ -39,7 +39,8 @@ enum class Boundary { FarSide, Bottom, - Fault + Fault, + Reservoir }; enum class ElementSets diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationModel.cpp b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationModel.cpp index 67c3427332..91c42fec25 100644 --- a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationModel.cpp +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationModel.cpp @@ -113,7 +113,7 @@ RimFaultReactivationModel::RimFaultReactivationModel() CAF_PDM_InitField( &m_minReservoirCellWidth, "MinReservoirCellWidth", 5.0, "Reservoir Cell Width" ); CAF_PDM_InitField( &m_cellWidthGrowFactor, "CellWidthGrowFactor", 1.15, "Cell Width Grow Factor" ); - CAF_PDM_InitField( &m_useLocalCoordinates, "UseLocalCoordinates", false, "Use Local Coordinates" ); + CAF_PDM_InitField( &m_useLocalCoordinates, "UseLocalCoordinates", true, "Use Local Coordinates" ); // Time Step Selection CAF_PDM_InitFieldNoDefault( &m_timeStepFilter, "TimeStepFilter", "Available Time Steps" ); diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftEnsembleCurveSet.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftEnsembleCurveSet.cpp index 4792198871..1c368d3566 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftEnsembleCurveSet.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftEnsembleCurveSet.cpp @@ -31,7 +31,6 @@ #include "RiuQwtPlotWidget.h" #include "cafPdmUiObjectHandle.h" -#include "cafPdmUiOrdering.h" #include "cafPdmUiTreeOrdering.h" #include "cafPdmUiTreeSelectionEditor.h" diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCase.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCase.cpp index 8c75cd8aa2..ee72f023b1 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCase.cpp @@ -63,6 +63,7 @@ #include "cvfVector3.h" +#include #include #include diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapProjection.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapProjection.cpp index 1d092dc7b5..5e8d3946b8 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapProjection.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapProjection.cpp @@ -161,7 +161,8 @@ cvf::ref RimGeoMechContourMapProjection::getCellVisibility() co cellRangeFilter, &indexIncludeVis, &indexExcludeVis, - view()->cellFilterCollection()->hasActiveIncludeIndexFilters() ); + view()->cellFilterCollection()->hasActiveIncludeIndexFilters(), + view()->cellFilterCollection()->useAndOperation() ); } if ( view()->propertyFilterCollection()->isActive() ) { diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp index d94b027858..293eea1334 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp @@ -1048,10 +1048,7 @@ 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.add( m_polygonInViewCollection ); uiTreeOrdering.skipRemainingChildren( true ); } diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp b/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp index 42fd132f98..b8cbb0d76f 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp @@ -457,7 +457,7 @@ void RimExtrudedCurveIntersection::fieldChangedByUi( const caf::PdmFieldHandle* if ( changedField == &m_simulationWell || changedField == &m_isActive || changedField == &m_type ) { - recomputeSimulationWellBranchData(); + rebuildGeometryAndScheduleCreateDisplayModel(); } if ( changedField == &m_simulationWell || changedField == &m_wellPath || changedField == &m_branchIndex || @@ -522,7 +522,7 @@ void RimExtrudedCurveIntersection::fieldChangedByUi( const caf::PdmFieldHandle* if ( changedField == &m_editPolygonButton ) { - RimPolygonTools::selectAndActivatePolygonInView( m_projectPolygon(), this ); + RimPolygonTools::activate3dEditOfPolygonInView( m_projectPolygon(), this ); m_editPolygonButton = false; @@ -546,10 +546,14 @@ void RimExtrudedCurveIntersection::defineUiOrdering( QString uiConfigName, caf:: else if ( type() == CrossSectionEnum::CS_SIMULATION_WELL ) { geometryGroup->add( &m_simulationWell ); - updateSimulationWellCenterline(); - if ( m_simulationWell() && m_simulationWellBranchCenterlines.size() > 1 ) + + if ( m_simulationWell() ) { - geometryGroup->add( &m_branchIndex ); + auto branchCenterLines = simulationWellBranchCenterlines(); + if ( branchCenterLines.size() > 1 ) + { + geometryGroup->add( &m_branchIndex ); + } } } else if ( type() == CrossSectionEnum::CS_POLYLINE ) @@ -705,9 +709,8 @@ QList RimExtrudedCurveIntersection::calculateValueOption } else if ( fieldNeedingOptions == &m_branchIndex ) { - updateSimulationWellCenterline(); - - size_t branchCount = m_simulationWellBranchCenterlines.size(); + auto branchCenterLines = simulationWellBranchCenterlines(); + size_t branchCount = branchCenterLines.size(); options.push_back( caf::PdmOptionItemInfo( "All", -1 ) ); @@ -812,14 +815,16 @@ std::vector> RimExtrudedCurveIntersection::polyLines( cv { int branchIndexToUse = branchIndex(); - if ( 0 <= branchIndexToUse && branchIndexToUse < static_cast( m_simulationWellBranchCenterlines.size() ) ) + auto branchCenterLines = simulationWellBranchCenterlines(); + + if ( 0 <= branchIndexToUse && branchIndexToUse < static_cast( branchCenterLines.size() ) ) { - lines.push_back( m_simulationWellBranchCenterlines[branchIndexToUse] ); + lines.push_back( branchCenterLines[branchIndexToUse] ); } if ( branchIndexToUse == -1 ) { - lines = m_simulationWellBranchCenterlines; + lines = branchCenterLines; } } } @@ -900,27 +905,6 @@ std::vector RimExtrudedCurveIntersection::polyLinesForExtrusionDirec return m_customExtrusionPoints; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimExtrudedCurveIntersection::updateSimulationWellCenterline() -{ - if ( m_isActive() && type() == CrossSectionEnum::CS_SIMULATION_WELL && m_simulationWell() ) - { - if ( m_simulationWellBranchCenterlines.empty() ) - { - auto simWells = m_simulationWell()->wellBranchesForVisualization(); - const auto& [coords, wellCells] = RigSimulationWellCenterLineCalculator::extractBranchData( simWells ); - - m_simulationWellBranchCenterlines = coords; - } - } - else - { - m_simulationWellBranchCenterlines.clear(); - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1019,7 +1003,8 @@ int RimExtrudedCurveIntersection::branchIndex() const return -1; } - if ( m_branchIndex >= static_cast( m_simulationWellBranchCenterlines.size() ) ) + auto branchCenterLines = simulationWellBranchCenterlines(); + if ( m_branchIndex >= static_cast( branchCenterLines.size() ) ) { return -1; } @@ -1279,20 +1264,6 @@ double RimExtrudedCurveIntersection::extentLength() return m_extentLength(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimExtrudedCurveIntersection::recomputeSimulationWellBranchData() -{ - if ( m_type() == CrossSectionEnum::CS_SIMULATION_WELL ) - { - m_simulationWellBranchCenterlines.clear(); - updateSimulationWellCenterline(); - - m_crossSectionPartMgr = nullptr; - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1426,3 +1397,16 @@ RimEclipseView* RimExtrudedCurveIntersection::eclipseView() const { return firstAncestorOrThisOfType(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector> RimExtrudedCurveIntersection::simulationWellBranchCenterlines() const +{ + if ( !m_simulationWell() ) return {}; + + const auto simWells = m_simulationWell()->wellBranchesForVisualization(); + const auto& [branchCenterLines, wellCells] = RigSimulationWellCenterLineCalculator::extractBranchData( simWells ); + + return branchCenterLines; +} diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.h b/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.h index 22d6836593..5e0388b90a 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.h +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.h @@ -127,7 +127,6 @@ class RimExtrudedCurveIntersection : public RimIntersection void setLengthUp( double heightUp ); void setLengthDown( double heightDown ); double extentLength(); - void recomputeSimulationWellBranchData(); bool hasDefiningPoints() const; std::vector surfaceIntersectionCurves() const; @@ -152,7 +151,6 @@ class RimExtrudedCurveIntersection : public RimIntersection RimSimWellInViewCollection* simulationWellCollection() const; void updateAzimuthLine(); - void updateSimulationWellCenterline(); void addExtents( std::vector& polyLine ) const; void updateName(); static double azimuthInRadians( cvf::Vec3d vec ); @@ -166,6 +164,8 @@ class RimExtrudedCurveIntersection : public RimIntersection RimEclipseView* eclipseView() const; + std::vector> simulationWellBranchCenterlines() const; + private: caf::PdmField m_name; diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.cpp b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.cpp index e54c331853..3157f32f49 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.cpp @@ -295,17 +295,6 @@ std::vector RimIntersectionCollection::intersectionBoxes() return m_intersectionBoxes.childrenByType(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimIntersectionCollection::recomputeSimWellBranchData() -{ - for ( const auto& intersection : intersections() ) - { - intersection->recomputeSimulationWellBranchData(); - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.h b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.h index a634f2e2d9..47e67d35e9 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.h @@ -68,7 +68,6 @@ class RimIntersectionCollection : public caf::PdmObject void syncronize2dIntersectionViews(); void scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); - void recomputeSimWellBranchData(); bool shouldApplyCellFiltersToIntersections() const; diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.cpp b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.cpp index 04d65d24c0..e160e457d9 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.cpp +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.cpp @@ -18,14 +18,19 @@ #include "RimPolygon.h" +#include "RiaApplication.h" +#include "RiaColorTools.h" + #include "RigPolyLinesData.h" -#include "RiaApplication.h" #include "Rim3dView.h" #include "RimPolygonAppearance.h" #include "RimPolygonTools.h" +#include "RiuGuiTheme.h" + #include "cafCmdFeatureMenuBuilder.h" +#include "cafPdmUiColorEditor.h" #include "cafPdmUiPushButtonEditor.h" #include "cafPdmUiTreeAttributes.h" @@ -36,6 +41,7 @@ CAF_PDM_SOURCE_INIT( RimPolygon, "RimPolygon" ); //-------------------------------------------------------------------------------------------------- RimPolygon::RimPolygon() : objectChanged( this ) + , coordinatesChanged( this ) { CAF_PDM_InitObject( "Polygon", ":/PolylinesFromFile16x16.png" ); @@ -78,8 +84,14 @@ void RimPolygon::uiOrderingForLocalPolygon( QString uiConfigName, caf::PdmUiOrde //-------------------------------------------------------------------------------------------------- void RimPolygon::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const { + menuBuilder << "RicDuplicatePolygonFeature"; menuBuilder << "RicNewPolygonIntersectionFeature"; menuBuilder << "RicNewPolygonFilterFeature"; + menuBuilder << "Separator"; + menuBuilder << "RicExportPolygonCsvFeature"; + menuBuilder << "RicExportPolygonPolFeature"; + menuBuilder << "Separator"; + menuBuilder << "RicSimplifyPolygonFeature"; } //-------------------------------------------------------------------------------------------------- @@ -88,8 +100,6 @@ void RimPolygon::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) cons void RimPolygon::setPointsInDomainCoords( const std::vector& points ) { m_pointsInDomainCoords = points; - - objectChanged.send(); } //-------------------------------------------------------------------------------------------------- @@ -132,6 +142,30 @@ bool RimPolygon::isReadOnly() const return m_isReadOnly(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygon::disableStorageOfPolygonPoints() +{ + m_pointsInDomainCoords.xmlCapability()->setIOWritable( false ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Color3f RimPolygon::color() const +{ + return m_appearance->lineColor(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygon::setColor( const cvf::Color3f& color ) +{ + m_appearance->setLineColor( color ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -158,13 +192,14 @@ void RimPolygon::fieldChangedByUi( const caf::PdmFieldHandle* changedField, cons { if ( changedField == &m_pointsInDomainCoords ) { + coordinatesChanged.send(); objectChanged.send(); } if ( changedField == &m_editPolygonButton ) { auto activeView = RiaApplication::instance()->activeReservoirView(); - RimPolygonTools::selectAndActivatePolygonInView( this, activeView ); + RimPolygonTools::activate3dEditOfPolygonInView( this, activeView ); m_editPolygonButton = false; @@ -189,18 +224,51 @@ void RimPolygon::defineEditorAttribute( const caf::PdmFieldHandle* field, QStrin { if ( auto attrib = dynamic_cast( attribute ) ) { - attrib->m_buttonText = "Edit in Active View"; + if ( m_isReadOnly() ) + { + attrib->m_buttonText = "Select in Active View"; + } + else + { + attrib->m_buttonText = "Edit in Active View"; + } } } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygon::onColorTagClicked( const SignalEmitter* emitter, size_t index ) +{ + QColor sourceColor = RiaColorTools::toQColor( color() ); + QColor newColor = caf::PdmUiColorEditor::getColor( sourceColor ); + + if ( newColor.isValid() && newColor != sourceColor ) + { + setColor( RiaColorTools::fromQColorTo3f( newColor ) ); + objectChanged.send(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimPolygon::defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) { + if ( auto* treeItemAttribute = dynamic_cast( attribute ) ) + { + auto tag = caf::PdmUiTreeViewItemAttribute::createTag( RiaColorTools::toQColor( color() ), + RiuGuiTheme::getColorByVariableName( "backgroundColor1" ), + "---" ); + + tag->clicked.connect( this, &RimPolygon::onColorTagClicked ); + + treeItemAttribute->tags.push_back( std::move( tag ) ); + } + if ( m_isReadOnly ) { - caf::PdmUiTreeViewItemAttribute::createTagIfTreeViewItemAttribute( attribute, ":/padlock.svg" ); + caf::PdmUiTreeViewItemAttribute::appendTagToTreeViewItemAttribute( attribute, ":/padlock.svg" ); } } diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.h b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.h index 0562acd652..f0eaa16c53 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.h +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygon.h @@ -24,6 +24,7 @@ #include "cafPdmChildField.h" #include "cafPdmFieldCvfVec3d.h" +#include "cvfColor3.h" #include "cvfVector3.h" class RimPolygonAppearance; @@ -39,6 +40,7 @@ class RimPolygon : public RimNamedObject, public RimPolylinesDataInterface public: caf::Signal<> objectChanged; + caf::Signal<> coordinatesChanged; public: RimPolygon(); @@ -51,13 +53,19 @@ class RimPolygon : public RimNamedObject, public RimPolylinesDataInterface void setReadOnly( bool isReadOnly ); bool isReadOnly() const; + void disableStorageOfPolygonPoints(); + + cvf::Color3f color() const; + void setColor( const cvf::Color3f& color ); + 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; + void onColorTagClicked( const SignalEmitter* emitter, size_t index ); -protected: +private: + void defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) override; diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.cpp b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.cpp index 1cd83a0a5c..ea8446151c 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.cpp +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.cpp @@ -85,8 +85,8 @@ RimPolygonAppearance::RimPolygonAppearance() 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_lineColor, "LineColor", cvf::Color3f( cvf::Color3f::ORANGE ), "Line Color" ); + CAF_PDM_InitField( &m_sphereColor, "SphereColor", cvf::Color3f( cvf::Color3f::ORANGE ), "Sphere Color" ); CAF_PDM_InitField( &m_polygonPlaneDepth, "PolygonPlaneDepth", 0.0, "Polygon Plane Depth" ); CAF_PDM_InitField( &m_lockPolygonToPlane, "LockPolygon", false, "Lock Polygon to Plane" ); @@ -123,6 +123,22 @@ bool RimPolygonAppearance::isClosed() const return m_isClosed(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Color3f RimPolygonAppearance::lineColor() const +{ + return m_lineColor(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonAppearance::setLineColor( const cvf::Color3f& color ) +{ + m_lineColor = color; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.h b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.h index 4fae753127..0f6fd767d0 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.h +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonAppearance.h @@ -37,6 +37,9 @@ class RimPolygonAppearance : public caf::PdmObject void setIsClosed( bool isClosed ); bool isClosed() const; + cvf::Color3f lineColor() const; + void setLineColor( const cvf::Color3f& color ); + public: RimPolygonAppearance(); diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonCollection.cpp b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonCollection.cpp index 32cfc6732b..3905598723 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonCollection.cpp @@ -23,6 +23,8 @@ #include "RimPolygonFile.h" #include "RimProject.h" +#include "cafCmdFeatureMenuBuilder.h" + CAF_PDM_SOURCE_INIT( RimPolygonCollection, "RimPolygonCollection" ); //-------------------------------------------------------------------------------------------------- @@ -30,7 +32,7 @@ CAF_PDM_SOURCE_INIT( RimPolygonCollection, "RimPolygonCollection" ); //-------------------------------------------------------------------------------------------------- RimPolygonCollection::RimPolygonCollection() { - CAF_PDM_InitObject( "Polygons (Under construction)", ":/PolylinesFromFile16x16.png" ); + CAF_PDM_InitObject( "Polygons", ":/PolylinesFromFile16x16.png" ); CAF_PDM_InitFieldNoDefault( &m_polygons, "Polygons", "Polygons" ); CAF_PDM_InitFieldNoDefault( &m_polygonFiles, "PolygonFiles", "Polygon Files" ); @@ -50,10 +52,20 @@ void RimPolygonCollection::loadData() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimPolygon* RimPolygonCollection::appendUserDefinedPolygon() +RimPolygon* RimPolygonCollection::createUserDefinedPolygon() { auto newPolygon = new RimPolygon(); newPolygon->setName( "Polygon " + QString::number( userDefinedPolygons().size() + 1 ) ); + + return newPolygon; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimPolygon* RimPolygonCollection::appendUserDefinedPolygon() +{ + auto newPolygon = createUserDefinedPolygon(); addUserDefinedPolygon( newPolygon ); return newPolygon; @@ -66,7 +78,7 @@ void RimPolygonCollection::addUserDefinedPolygon( RimPolygon* polygon ) { m_polygons().push_back( polygon ); - connectSignals( polygon ); + connectPolygonSignals( polygon ); updateViewTreeItems(); scheduleRedrawViews(); @@ -90,6 +102,8 @@ void RimPolygonCollection::addPolygonFile( RimPolygonFile* polygonFile ) { m_polygonFiles().push_back( polygonFile ); + connectPolygonFileSignals( polygonFile ); + updateViewTreeItems(); scheduleRedrawViews(); } @@ -150,6 +164,15 @@ void RimPolygonCollection::childFieldChangedByUi( const caf::PdmFieldHandle* cha scheduleRedrawViews(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonCollection::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const +{ + menuBuilder << "RicCreatePolygonFeature"; + menuBuilder << "RicImportPolygonFileFeature"; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -178,19 +201,39 @@ void RimPolygonCollection::scheduleRedrawViews() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimPolygonCollection::connectSignals( RimPolygon* polygon ) +void RimPolygonCollection::connectPolygonSignals( RimPolygon* polygon ) { if ( polygon ) { - polygon->objectChanged.connect( this, &RimPolygonCollection::onObjectChanged ); + polygon->objectChanged.connect( this, &RimPolygonCollection::onPolygonChanged ); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimPolygonCollection::onObjectChanged( const caf::SignalEmitter* emitter ) +void RimPolygonCollection::connectPolygonFileSignals( RimPolygonFile* polygonFile ) { + if ( polygonFile ) + { + polygonFile->objectChanged.connect( this, &RimPolygonCollection::onPolygonFileChanged ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonCollection::onPolygonChanged( const caf::SignalEmitter* emitter ) +{ + scheduleRedrawViews(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonCollection::onPolygonFileChanged( const caf::SignalEmitter* emitter ) +{ + updateViewTreeItems(); scheduleRedrawViews(); } @@ -201,6 +244,11 @@ void RimPolygonCollection::initAfterRead() { for ( auto& p : m_polygons() ) { - connectSignals( p ); + connectPolygonSignals( p ); + } + + for ( auto& pf : m_polygonFiles() ) + { + connectPolygonFileSignals( pf ); } } diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonCollection.h b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonCollection.h index 4246dae416..aad69d97dc 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonCollection.h @@ -36,6 +36,7 @@ class RimPolygonCollection : public caf::PdmObject RimPolygonCollection(); void loadData(); + RimPolygon* createUserDefinedPolygon(); RimPolygon* appendUserDefinedPolygon(); void addUserDefinedPolygon( RimPolygon* polygon ); void deleteUserDefinedPolygons(); @@ -46,15 +47,18 @@ class RimPolygonCollection : public caf::PdmObject std::vector polygonFiles() const; std::vector allPolygons() const; +private: void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, std::vector& referringObjects ) override; - void childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) override; + void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override; -private: void updateViewTreeItems(); void scheduleRedrawViews(); - void connectSignals( RimPolygon* polygon ); - void onObjectChanged( const caf::SignalEmitter* emitter ); + + void connectPolygonSignals( RimPolygon* polygon ); + void connectPolygonFileSignals( RimPolygonFile* polygonFile ); + void onPolygonChanged( const caf::SignalEmitter* emitter ); + void onPolygonFileChanged( const caf::SignalEmitter* emitter ); private: caf::PdmChildArrayField m_polygons; diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonFile.cpp b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonFile.cpp index cec7ec8160..2b3aeb4519 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonFile.cpp +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonFile.cpp @@ -17,14 +17,25 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RimPolygonFile.h" + +#include "RiaLogging.h" + +#include "RifPolygonReader.h" + #include "RimPolygon.h" +#include "cafCmdFeatureMenuBuilder.h" +#include "cafPdmUiTreeAttributes.h" + +#include + CAF_PDM_SOURCE_INIT( RimPolygonFile, "RimPolygonFileFile" ); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RimPolygonFile::RimPolygonFile() + : objectChanged( this ) { CAF_PDM_InitObject( "PolygonFile", ":/PolylinesFromFile16x16.png" ); @@ -34,12 +45,48 @@ RimPolygonFile::RimPolygonFile() setDeletable( true ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonFile::setFileName( const QString& fileName ) +{ + m_fileName = fileName; + + updateName(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimPolygonFile::loadData() { - loadPolygonsFromFile(); + auto polygonsFromFile = importDataFromFile( m_fileName().path() ); + + if ( m_polygons.size() == polygonsFromFile.size() ) + { + for ( size_t i = 0; i < m_polygons.size(); i++ ) + { + auto projectPoly = m_polygons()[i]; + auto filePoly = polygonsFromFile[i]; + projectPoly->setPointsInDomainCoords( filePoly->pointsInDomainCoords() ); + delete filePoly; + } + } + else + { + m_polygons.deleteChildren(); + + m_polygons.setValue( polygonsFromFile ); + } + + if ( polygonsFromFile.empty() ) + { + RiaLogging::warning( "No polygons found in file: " + m_fileName().path() ); + } + else + { + RiaLogging::info( QString( "Imported %1 polygons from file: " ).arg( polygonsFromFile.size() ) + m_fileName().path() ); + } } //-------------------------------------------------------------------------------------------------- @@ -50,11 +97,36 @@ std::vector RimPolygonFile::polygons() const return m_polygons.childrenByType(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimPolygonFile::name() const +{ + QString nameCandidate = RimNamedObject::name(); + + if ( !nameCandidate.isEmpty() ) + { + return nameCandidate; + } + + auto fileName = m_fileName().path(); + if ( fileName.isEmpty() ) + { + return "Polygon File"; + } + + QFileInfo fileInfo( fileName ); + return fileInfo.fileName(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimPolygonFile::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { + uiOrdering.add( nameField() ); + uiOrdering.add( &m_fileName ); + uiOrdering.skipRemainingFields(); } //-------------------------------------------------------------------------------------------------- @@ -62,21 +134,71 @@ void RimPolygonFile::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& //-------------------------------------------------------------------------------------------------- void RimPolygonFile::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) { - loadPolygonsFromFile(); + if ( changedField == &m_fileName ) + { + updateName(); + + m_polygons.deleteChildren(); + loadData(); + } + + objectChanged.send(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimPolygonFile::loadPolygonsFromFile() +std::vector RimPolygonFile::importDataFromFile( const QString& fileName ) { - // m_polygons()->deletePolygons(); + QString errorMessages; + auto filePolygons = RifPolygonReader::parsePolygonFile( fileName, &errorMessages ); + + std::vector polygons; + + for ( const auto& [polygonId, filePolygon] : filePolygons ) + { + auto polygon = new RimPolygon(); + polygon->disableStorageOfPolygonPoints(); + polygon->setReadOnly( true ); + + int id = ( polygonId != -1 ) ? polygonId : static_cast( polygons.size() + 1 ); + polygon->setName( QString( "Polygon %1" ).arg( id ) ); + polygon->setPointsInDomainCoords( filePolygon ); + polygons.push_back( polygon ); + } + + if ( !errorMessages.isEmpty() ) + { + RiaLogging::error( errorMessages ); + } - auto polygon = new RimPolygon(); - polygon->setName( "Polygon 1" ); - m_polygons.push_back( polygon ); + return polygons; +} - polygon = new RimPolygon(); - polygon->setName( "Polygon 2" ); - m_polygons.push_back( polygon ); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonFile::updateName() +{ + QFileInfo fileInfo( m_fileName().path() ); + setName( fileInfo.fileName() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonFile::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const +{ + menuBuilder << "RicReloadPolygonFileFeature"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonFile::defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) +{ + if ( m_polygons.empty() ) + { + caf::PdmUiTreeViewItemAttribute::appendTagToTreeViewItemAttribute( attribute, ":/warning.svg" ); + } } diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonFile.h b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonFile.h index 540f9ce32c..d90442097e 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonFile.h +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonFile.h @@ -28,19 +28,29 @@ class RimPolygonFile : public RimNamedObject { CAF_PDM_HEADER_INIT; +public: + caf::Signal<> objectChanged; + public: RimPolygonFile(); + void setFileName( const QString& fileName ); + void loadData(); std::vector polygons() const; + QString name() const override; + protected: void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; + void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override; + void defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; private: - void loadPolygonsFromFile(); + static std::vector importDataFromFile( const QString& fileName ); + void updateName(); private: caf::PdmField m_fileName; diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.cpp b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.cpp index d45b557261..713077d2c1 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.cpp +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.cpp @@ -18,6 +18,8 @@ #include "RimPolygonInView.h" +#include "RiaColorTools.h" + #include "RigPolyLinesData.h" #include "Rim3dView.h" @@ -70,6 +72,7 @@ RimPolygonInView::RimPolygonInView() m_targets.uiCapability()->setUiTreeChildrenHidden( true ); m_targets.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); m_targets.uiCapability()->setCustomContextMenuEnabled( true ); + m_targets.xmlCapability()->disableIO(); setUi3dEditorTypeName( RicPolyline3dEditor::uiEditorTypeName() ); } @@ -89,6 +92,8 @@ void RimPolygonInView::setPolygon( RimPolygon* polygon ) { m_polygon = polygon; + connectSignals(); + updateTargetsFromPolygon(); } @@ -231,6 +236,18 @@ void RimPolygonInView::updatePolygonFromTargets() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonInView::connectSignals() +{ + if ( m_polygon ) + { + m_polygon->objectChanged.connect( this, &RimPolygonInView::onObjectChanged ); + m_polygon->coordinatesChanged.connect( this, &RimPolygonInView::onCoordinatesChanged ); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -322,9 +339,23 @@ void RimPolygonInView::defineObjectEditorAttribute( QString uiConfigName, caf::P attrib->enablePicking = m_enablePicking; } - if ( m_polygon() && m_polygon->isReadOnly() ) + if ( m_polygon() ) { - caf::PdmUiTreeViewItemAttribute::createTagIfTreeViewItemAttribute( attribute, ":/padlock.svg" ); + if ( auto* treeItemAttribute = dynamic_cast( attribute ) ) + { + auto tag = caf::PdmUiTreeViewItemAttribute::createTag( RiaColorTools::toQColor( m_polygon->color() ), + RiuGuiTheme::getColorByVariableName( "backgroundColor1" ), + "---" ); + + tag->clicked.connect( m_polygon(), &RimPolygon::onColorTagClicked ); + + treeItemAttribute->tags.push_back( std::move( tag ) ); + } + + if ( m_polygon->isReadOnly() ) + { + caf::PdmUiTreeViewItemAttribute::appendTagToTreeViewItemAttribute( attribute, ":/padlock.svg" ); + } } } @@ -346,6 +377,33 @@ void RimPolygonInView::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder if ( m_polygon() ) m_polygon->appendMenuItems( menuBuilder ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonInView::onObjectChanged( const caf::SignalEmitter* emitter ) +{ + updateVisualization(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonInView::onCoordinatesChanged( const caf::SignalEmitter* emitter ) +{ + updateTargetsFromPolygon(); + + updateConnectedEditors(); + updateVisualization(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonInView::initAfterRead() +{ + connectSignals(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.h b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.h index c77494d0d3..dbe5d07a96 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.h +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.h @@ -51,6 +51,7 @@ class RimPolygonInView : public RimCheckableNamedObject, public RimPolylinesData RimPolygon* polygon() const; void setPolygon( RimPolygon* polygon ); + void updateTargetsFromPolygon(); void appendPartsToModel( cvf::ModelBasicList* model, const caf::DisplayCoordTransform* scaleTransform, const cvf::BoundingBox& boundingBox ); void enablePicking( bool enable ); @@ -79,12 +80,15 @@ class RimPolygonInView : public RimCheckableNamedObject, public RimPolylinesData 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; + void onObjectChanged( const caf::SignalEmitter* emitter ); + void onCoordinatesChanged( const caf::SignalEmitter* emitter ); + void initAfterRead() override; private: void updateNameField(); void updatePolygonFromTargets(); - void updateTargetsFromPolygon(); + void connectSignals(); private: caf::PdmPtrField m_polygon; diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInViewCollection.cpp b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInViewCollection.cpp index 3ee9722878..d964417218 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInViewCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInViewCollection.cpp @@ -21,6 +21,7 @@ #include "Rim3dView.h" #include "RimPolygon.h" #include "RimPolygonCollection.h" +#include "RimPolygonFile.h" #include "RimPolygonInView.h" #include "RimTools.h" @@ -31,58 +32,74 @@ CAF_PDM_SOURCE_INIT( RimPolygonInViewCollection, "RimPolygonInViewCollection" ); //-------------------------------------------------------------------------------------------------- RimPolygonInViewCollection::RimPolygonInViewCollection() { - CAF_PDM_InitObject( "Polygons (Under construction)", ":/PolylinesFromFile16x16.png" ); + CAF_PDM_InitObject( "Polygons", ":/PolylinesFromFile16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_polygons, "Polygons", "Polygons" ); + CAF_PDM_InitFieldNoDefault( &m_polygonsInView, "Polygons", "Polygons" ); + CAF_PDM_InitFieldNoDefault( &m_collectionsInView, "Collections", "Collections" ); + + nameField()->uiCapability()->setUiHidden( true ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimPolygonInViewCollection::syncPolygonsInView() +void RimPolygonInViewCollection::updateFromPolygonCollection() { - std::vector existingPolygonsInView = m_polygons.childrenByType(); - m_polygons.clearWithoutDelete(); + updateAllViewItems(); +} - auto polygonCollection = RimTools::polygonCollection(); - if ( polygonCollection ) - { - std::vector newPolygonsInView; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimPolygonInViewCollection::visiblePolygonsInView() const +{ + if ( !m_isChecked ) return {}; - for ( auto polygon : polygonCollection->allPolygons() ) - { - auto it = std::find_if( existingPolygonsInView.begin(), - existingPolygonsInView.end(), - [polygon]( auto* polygonInView ) { return polygonInView->polygon() == polygon; } ); + std::vector polys = m_polygonsInView.childrenByType(); - if ( it != existingPolygonsInView.end() ) - { - newPolygonsInView.push_back( *it ); - existingPolygonsInView.erase( it ); - } - else - { - auto polygonInView = new RimPolygonInView(); - polygonInView->setPolygon( polygon ); - newPolygonsInView.push_back( polygonInView ); - } - } + for ( auto coll : m_collectionsInView ) + { + if ( !coll->isChecked() ) continue; - m_polygons.setValue( newPolygonsInView ); + auto other = coll->visiblePolygonsInView(); + polys.insert( polys.end(), other.begin(), other.end() ); } - for ( auto polyInView : existingPolygonsInView ) + return polys; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimPolygonInViewCollection::allPolygonsInView() const +{ + std::vector polys = m_polygonsInView.childrenByType(); + + for ( auto coll : m_collectionsInView ) { - delete polyInView; + auto other = coll->visiblePolygonsInView(); + polys.insert( polys.end(), other.begin(), other.end() ); } + + return polys; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonInViewCollection::setPolygonFile( RimPolygonFile* polygonFile ) +{ + m_polygonFile = polygonFile; + + updateName(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimPolygonInViewCollection::polygonsInView() const +RimPolygonFile* RimPolygonInViewCollection::polygonFile() const { - return m_polygons.childrenByType(); + return m_polygonFile; } //-------------------------------------------------------------------------------------------------- @@ -90,11 +107,11 @@ std::vector RimPolygonInViewCollection::polygonsInView() cons //-------------------------------------------------------------------------------------------------- void RimPolygonInViewCollection::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) { - RimCheckableObject::fieldChangedByUi( changedField, oldValue, newValue ); + RimCheckableNamedObject::fieldChangedByUi( changedField, oldValue, newValue ); if ( changedField == &m_isChecked ) { - for ( auto poly : polygonsInView() ) + for ( auto poly : visiblePolygonsInView() ) { poly->updateConnectedEditors(); } @@ -105,3 +122,152 @@ void RimPolygonInViewCollection::fieldChangedByUi( const caf::PdmFieldHandle* ch } } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonInViewCollection::updateAllViewItems() +{ + // Based on the same concept as RimSurfaceInViewCollection + + syncCollectionsWithView(); + syncPolygonsWithView(); + updateConnectedEditors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonInViewCollection::syncCollectionsWithView() +{ + // Based on the same concept as RimSurfaceInViewCollection + + auto colls = m_collectionsInView.childrenByType(); + + for ( auto coll : colls ) + { + if ( !coll->polygonFile() ) + { + m_collectionsInView.removeChild( coll ); + delete coll; + } + } + + if ( !m_polygonFile ) + { + std::vector orderedColls; + + if ( auto polygonCollection = RimTools::polygonCollection() ) + { + std::vector newPolygonsInView; + + for ( auto polygonFile : polygonCollection->polygonFiles() ) + { + if ( polygonFile->polygons().empty() ) continue; + + auto viewPolygonFile = getCollectionInViewForPolygonFile( polygonFile ); + if ( viewPolygonFile == nullptr ) + { + auto newColl = new RimPolygonInViewCollection(); + newColl->setPolygonFile( polygonFile ); + orderedColls.push_back( newColl ); + } + else + { + viewPolygonFile->updateName(); + orderedColls.push_back( viewPolygonFile ); + } + } + } + + m_collectionsInView.clearWithoutDelete(); + for ( auto viewColl : orderedColls ) + { + m_collectionsInView.push_back( viewColl ); + viewColl->updateAllViewItems(); + } + } + + updateName(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonInViewCollection::syncPolygonsWithView() +{ + std::vector existingPolygonsInView = m_polygonsInView.childrenByType(); + m_polygonsInView.clearWithoutDelete(); + + std::vector polygons; + + if ( m_polygonFile ) + { + polygons = m_polygonFile->polygons(); + } + else + { + auto polygonCollection = RimTools::polygonCollection(); + polygons = polygonCollection->userDefinedPolygons(); + } + + std::vector newPolygonsInView; + + for ( auto polygon : polygons ) + { + 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 ); + ( *it )->updateTargetsFromPolygon(); + } + else + { + auto polygonInView = new RimPolygonInView(); + polygonInView->setPolygon( polygon ); + newPolygonsInView.push_back( polygonInView ); + } + } + + m_polygonsInView.setValue( newPolygonsInView ); + + for ( auto polyInView : existingPolygonsInView ) + { + delete polyInView; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonInViewCollection::updateName() +{ + QString name = "Polygons"; + + if ( m_polygonFile ) + { + name = m_polygonFile->name(); + } + + setName( name ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimPolygonInViewCollection* RimPolygonInViewCollection::getCollectionInViewForPolygonFile( const RimPolygonFile* polygonFile ) const +{ + for ( auto collInView : m_collectionsInView ) + { + if ( collInView->polygonFile() == polygonFile ) + { + return collInView; + } + } + + return nullptr; +} diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInViewCollection.h b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInViewCollection.h index 87e947d83a..bee9b066b3 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInViewCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInViewCollection.h @@ -18,29 +18,47 @@ #pragma once -#include "RimCheckableObject.h" +#include "RimCheckableNamedObject.h" + #include "cafPdmChildArrayField.h" +#include "cafPdmPointer.h" class RimPolygonInView; +class RimPolygonFile; +class RimPolygon; //================================================================================================== /// /// //================================================================================================== -class RimPolygonInViewCollection : public RimCheckableObject +class RimPolygonInViewCollection : public RimCheckableNamedObject { CAF_PDM_HEADER_INIT; public: RimPolygonInViewCollection(); - void syncPolygonsInView(); + void updateFromPolygonCollection(); - std::vector polygonsInView() const; + std::vector visiblePolygonsInView() const; + std::vector allPolygonsInView() const; private: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; + void setPolygonFile( RimPolygonFile* polygonFile ); + RimPolygonFile* polygonFile() const; + + void updateAllViewItems(); + void syncCollectionsWithView(); + void syncPolygonsWithView(); + void updateName(); + + RimPolygonInViewCollection* getCollectionInViewForPolygonFile( const RimPolygonFile* polygonFile ) const; + private: - caf::PdmChildArrayField m_polygons; + caf::PdmChildArrayField m_polygonsInView; + caf::PdmChildArrayField m_collectionsInView; + + caf::PdmPointer m_polygonFile; }; diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonTools.cpp b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonTools.cpp index 52c5fd37c5..11d2d49425 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonTools.cpp +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonTools.cpp @@ -18,6 +18,10 @@ #include "RimPolygonTools.h" +#include "RiaPreferences.h" + +#include "RifCsvDataTableFormatter.h" + #include "RimGridView.h" #include "RimOilField.h" #include "RimPolygon.h" @@ -28,10 +32,13 @@ #include "Riu3DMainWindowTools.h" +#include +#include + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimPolygonTools::selectAndActivatePolygonInView( RimPolygon* polygon, caf::PdmObject* sourceObject ) +void RimPolygonTools::activate3dEditOfPolygonInView( RimPolygon* polygon, caf::PdmObject* sourceObject ) { auto polygonInView = findPolygonInView( polygon, sourceObject ); if ( polygonInView ) @@ -41,6 +48,109 @@ void RimPolygonTools::selectAndActivatePolygonInView( RimPolygon* polygon, caf:: } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonTools::selectPolygonInView( RimPolygon* polygon, caf::PdmObject* sourceObject ) +{ + auto polygonInView = findPolygonInView( polygon, sourceObject ); + if ( polygonInView ) + { + Riu3DMainWindowTools::selectAsCurrentItem( polygonInView ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimPolygonTools::exportPolygonCsv( const RimPolygon* polygon, const QString& filePath ) +{ + if ( !polygon ) return false; + + QFile file( filePath ); + if ( !file.open( QIODevice::WriteOnly | QIODevice::Text ) ) + { + return false; + } + + QTextStream out( &file ); + + QString fieldSeparator = RiaPreferences::current()->csvTextExportFieldSeparator; + RifCsvDataTableFormatter formatter( out, fieldSeparator ); + const int precision = 2; + + std::vector header; + header.emplace_back( "X", RifTextDataTableDoubleFormatting( RIF_FLOAT, precision ) ); + header.emplace_back( "Y", RifTextDataTableDoubleFormatting( RIF_FLOAT, precision ) ); + header.emplace_back( "Z", RifTextDataTableDoubleFormatting( RIF_FLOAT, precision ) ); + formatter.header( header ); + + for ( const auto& point : polygon->pointsInDomainCoords() ) + { + formatter.add( point.x() ); + formatter.add( point.y() ); + formatter.add( -point.z() ); + formatter.rowCompleted(); + } + + formatter.tableCompleted(); + + file.close(); + + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimPolygonTools::exportPolygonPol( const RimPolygon* polygon, const QString& filePath ) +{ + if ( !polygon ) return false; + + QFile file( filePath ); + if ( !file.open( QIODevice::WriteOnly | QIODevice::Text ) ) return false; + + QTextStream out( &file ); + + QString fieldSeparator = " "; + RifCsvDataTableFormatter formatter( out, fieldSeparator ); + const int precision = 2; + + std::vector header; + header.emplace_back( " ", RifTextDataTableDoubleFormatting( RIF_FLOAT, precision ) ); + header.emplace_back( " ", RifTextDataTableDoubleFormatting( RIF_FLOAT, precision ) ); + header.emplace_back( " ", RifTextDataTableDoubleFormatting( RIF_FLOAT, precision ) ); + formatter.header( header ); + + for ( const auto& point : polygon->pointsInDomainCoords() ) + { + formatter.add( point.x() ); + formatter.add( point.y() ); + formatter.add( -point.z() ); + formatter.rowCompleted(); + } + + const double endOfPolygon = 999.0; + formatter.add( endOfPolygon ); + formatter.add( endOfPolygon ); + formatter.add( endOfPolygon ); + formatter.rowCompleted(); + + formatter.tableCompleted(); + + file.close(); + + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimPolygonTools::polygonCacheName() +{ + return "POLYGON"; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -55,7 +165,7 @@ RimPolygonInView* RimPolygonTools::findPolygonInView( RimPolygon* polygon, caf:: { auto polyCollection = gridView->polygonInViewCollection(); - for ( auto polygonInView : polyCollection->polygonsInView() ) + for ( auto polygonInView : polyCollection->allPolygonsInView() ) { if ( polygonInView && polygonInView->polygon() == polygon ) { diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonTools.h b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonTools.h index 8f7d3a65d3..29fb32b401 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonTools.h +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonTools.h @@ -21,6 +21,8 @@ class RimPolygon; class RimPolygonInView; +class QString; + namespace caf { class PdmObject; @@ -29,7 +31,12 @@ class PdmObject; class RimPolygonTools { public: - static void selectAndActivatePolygonInView( RimPolygon* polygon, caf::PdmObject* sourceObject ); + static void activate3dEditOfPolygonInView( RimPolygon* polygon, caf::PdmObject* sourceObject ); + static void selectPolygonInView( RimPolygon* polygon, caf::PdmObject* sourceObject ); + static bool exportPolygonCsv( const RimPolygon* polygon, const QString& filePath ); + static bool exportPolygonPol( const RimPolygon* polygon, const QString& filePath ); + + static QString polygonCacheName(); private: static RimPolygonInView* findPolygonInView( RimPolygon* polygon, caf::PdmObject* sourceObject ); diff --git a/ApplicationLibCode/ProjectDataModel/ProcessControl/RimProcess.cpp b/ApplicationLibCode/ProjectDataModel/ProcessControl/RimProcess.cpp index 5fe493acef..770b6f3684 100644 --- a/ApplicationLibCode/ProjectDataModel/ProcessControl/RimProcess.cpp +++ b/ApplicationLibCode/ProjectDataModel/ProcessControl/RimProcess.cpp @@ -23,6 +23,7 @@ #include "cafPdmFieldCapability.h" +#include #include #include diff --git a/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp b/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp index dd450bd55a..8d98b5067c 100644 --- a/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp +++ b/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp @@ -1706,18 +1706,19 @@ void Rim3dView::appendMeasurementToModel() { if ( !nativeOrOverrideViewer() ) return; - cvf::Scene* frameScene = nativeOrOverrideViewer()->frame( m_currentTimeStep, isUsingOverrideViewer() ); - if ( frameScene ) + const cvf::String name = "Measurement"; + + cvf::Scene* scene = nativeOrOverrideViewer()->currentScene( isUsingOverrideViewer() ); + if ( scene ) { - cvf::String name = "Measurement"; - this->removeModelByName( frameScene, name ); + Rim3dView::removeModelByName( scene, name ); cvf::ref model = new cvf::ModelBasicList; model->setName( name ); addMeasurementToModel( model.p() ); - frameScene->addModel( model.p() ); + scene->addModel( model.p() ); } } diff --git a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp index 7adc007c08..a6769cf17d 100644 --- a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -23,7 +23,6 @@ #include "PlotTemplates/RimPlotTemplateFileItem.h" #include "PlotTemplates/RimPlotTemplateFolderItem.h" -#include "Polygons/RimPolygonCollection.h" #include "Rim3dOverlayInfoConfig.h" #include "Rim3dWellLogCurveCollection.h" #include "Rim3dWellLogExtractionCurve.h" @@ -1139,11 +1138,6 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() { menuBuilder << "RicAddGridCalculationFeature"; } - else if ( dynamic_cast( firstUiItem ) ) - { - menuBuilder << "RicNewPolygonFeature"; - menuBuilder << "RicNewPolygonFileFeature"; - } if ( dynamic_cast( firstUiItem ) ) { diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.cpp index 45e4e8498e..5cb28a8360 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.cpp @@ -49,7 +49,6 @@ #include "RimEclipseInputPropertyCollection.h" #include "RimEclipseView.h" #include "RimFlowDiagSolution.h" -#include "RimIntersectionCollection.h" #include "RimMockModelSettings.h" #include "RimProject.h" #include "RimReservoirCellResultsStorage.h" @@ -62,9 +61,11 @@ #include "cafProgressInfo.h" #include "cafUtils.h" +#include #include #include #include + #include #include @@ -660,7 +661,6 @@ void RimEclipseResultCase::fieldChangedByUi( const caf::PdmFieldHandle* changedF { resView->scheduleSimWellGeometryRegen(); resView->scheduleCreateDisplayModelAndRedraw(); - resView->intersectionCollection()->recomputeSimWellBranchData(); } } diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp index 80a74c8e9e..324ce843bc 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp @@ -1981,16 +1981,13 @@ void RimEclipseView::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrderin if ( faultReactivationModelCollection()->shouldBeVisibleInTree() ) uiTreeOrdering.add( faultReactivationModelCollection() ); - uiTreeOrdering.add( annotationCollection() ); uiTreeOrdering.add( intersectionCollection() ); + uiTreeOrdering.add( m_polygonInViewCollection ); if ( surfaceInViewCollection() ) uiTreeOrdering.add( surfaceInViewCollection() ); if ( seismicSectionCollection()->shouldBeVisibleInTree() ) uiTreeOrdering.add( seismicSectionCollection() ); - if ( RiaApplication::enableDevelopmentFeatures() ) - { - uiTreeOrdering.add( m_polygonInViewCollection ); - } + uiTreeOrdering.add( annotationCollection() ); uiTreeOrdering.skipRemainingChildren( true ); } diff --git a/ApplicationLibCode/ProjectDataModel/RimGridCalculation.cpp b/ApplicationLibCode/ProjectDataModel/RimGridCalculation.cpp index bc0cd5910e..7160b3d9ed 100644 --- a/ApplicationLibCode/ProjectDataModel/RimGridCalculation.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimGridCalculation.cpp @@ -609,10 +609,13 @@ std::vector RimGridCalculation::getDataForResult( const QString& values[i] = resultAccessor->cellScalarGlobIdx( activeReservoirCells[i] ); } - auto categoriesToExclude = { RiaDefines::ResultCatType::GENERATED }; + if ( m_releaseMemoryAfterDataIsExtracted ) + { + auto categoriesToExclude = { RiaDefines::ResultCatType::GENERATED }; - sourceCase->results( RiaDefines::PorosityModelType::MATRIX_MODEL )->freeAllocatedResultsData( categoriesToExclude, timeStepToUse ); - sourceCase->results( RiaDefines::PorosityModelType::FRACTURE_MODEL )->freeAllocatedResultsData( categoriesToExclude, timeStepToUse ); + sourceCase->results( RiaDefines::PorosityModelType::MATRIX_MODEL )->freeAllocatedResultsData( categoriesToExclude, timeStepToUse ); + sourceCase->results( RiaDefines::PorosityModelType::FRACTURE_MODEL )->freeAllocatedResultsData( categoriesToExclude, timeStepToUse ); + } return values; } @@ -782,6 +785,9 @@ bool RimGridCalculation::calculateForCases( const std::vector& m_expression().contains( "min" ) || m_expression().contains( "max" ) || m_expression().contains( "count" ); + // If multiple cases are present, release memory after data is extracted to avoid memory issues. + m_releaseMemoryAfterDataIsExtracted = isMultipleCasesPresent; + if ( isMultipleCasesPresent ) { QString txt = "Starting calculation '" + description() + "' for " + QString::number( calculationCases.size() ) + " cases."; diff --git a/ApplicationLibCode/ProjectDataModel/RimGridCalculation.h b/ApplicationLibCode/ProjectDataModel/RimGridCalculation.h index 715b045937..45f1e75309 100644 --- a/ApplicationLibCode/ProjectDataModel/RimGridCalculation.h +++ b/ApplicationLibCode/ProjectDataModel/RimGridCalculation.h @@ -155,4 +155,6 @@ class RimGridCalculation : public RimUserDefinedCalculation caf::PdmField m_editNonVisibleResultAddress; caf::PdmField m_applyToAllCases_OBSOLETE; + + bool m_releaseMemoryAfterDataIsExtracted = false; }; diff --git a/ApplicationLibCode/ProjectDataModel/RimGridView.cpp b/ApplicationLibCode/ProjectDataModel/RimGridView.cpp index 51813b0e7d..d9074993b9 100644 --- a/ApplicationLibCode/ProjectDataModel/RimGridView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimGridView.cpp @@ -405,16 +405,9 @@ void RimGridView::appendPolygonPartsToModel( caf::DisplayCoordTransform* scaleTr m_polygonVizModel->removeAllParts(); std::vector polygonsInView; - if ( m_polygonInViewCollection && m_polygonInViewCollection->isChecked() ) + if ( m_polygonInViewCollection ) { - auto candidates = m_polygonInViewCollection->polygonsInView(); - for ( auto polygonInView : candidates ) - { - if ( polygonInView->isChecked() ) - { - polygonsInView.push_back( polygonInView ); - } - } + polygonsInView = m_polygonInViewCollection->visiblePolygonsInView(); } if ( cellFilterCollection() && cellFilterCollection()->isActive() ) @@ -534,7 +527,7 @@ void RimGridView::updateViewTreeItems( RiaDefines::ItemIn3dView itemType ) if ( bitmaskEnum.AnyOf( RiaDefines::ItemIn3dView::POLYGON ) ) { - m_polygonInViewCollection->syncPolygonsInView(); + m_polygonInViewCollection->updateFromPolygonCollection(); } updateConnectedEditors(); diff --git a/ApplicationLibCode/ProjectDataModel/RimPlotCurve.cpp b/ApplicationLibCode/ProjectDataModel/RimPlotCurve.cpp index 5fb6ce2068..52c4784268 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPlotCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimPlotCurve.cpp @@ -1162,7 +1162,7 @@ void RimPlotCurve::setParentPlotNoReplot( RiuPlotWidget* plotWidget ) } auto color = RiaColorTools::toQColor( m_curveAppearance->color() ); - m_plotCurve = m_parentPlot->createPlotCurve( this, "" ); + m_plotCurve = m_parentPlot->createPlotCurve( this, m_curveName ); m_plotCurve->updateErrorBarsAppearance( m_showErrorBars, color ); // PERFORMANCE NOTE @@ -1262,19 +1262,10 @@ void RimPlotCurve::defineObjectEditorAttribute( QString uiConfigName, caf::PdmUi if ( auto* treeItemAttribute = dynamic_cast( attribute ) ) { treeItemAttribute->tags.clear(); - auto tag = caf::PdmUiTreeViewItemAttribute::createTag(); - - // Blend with background for a nice look - auto backgroundColor = RiuGuiTheme::getColorByVariableName( "backgroundColor1" ); - auto color = RiaColorTools::toQColor( m_curveAppearance->color() ); - auto sourceWeight = 100; - double transparency = 0.3; - int backgroundWeight = std::max( 1, static_cast( sourceWeight * 10 * transparency ) ); - auto blendedColor = RiaColorTools::blendQColors( backgroundColor, color, backgroundWeight, sourceWeight ); - - tag->bgColor = blendedColor; - tag->fgColor = RiaColorTools::toQColor( m_curveAppearance->color() ); - tag->text = "---"; + + auto tag = caf::PdmUiTreeViewItemAttribute::createTag( RiaColorTools::toQColor( m_curveAppearance->color() ), + RiuGuiTheme::getColorByVariableName( "backgroundColor1" ), + "---" ); tag->clicked.connect( this, &RimPlotCurve::onColorTagClicked ); diff --git a/ApplicationLibCode/ProjectDataModel/RimProject.cpp b/ApplicationLibCode/ProjectDataModel/RimProject.cpp index 3405b3c75c..2fa9253844 100644 --- a/ApplicationLibCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimProject.cpp @@ -1524,6 +1524,7 @@ void RimProject::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, Q if ( oilField->analysisModels() ) uiTreeOrdering.add( oilField->analysisModels() ); if ( oilField->geoMechModels() ) uiTreeOrdering.add( oilField->geoMechModels() ); if ( oilField->wellPathCollection() ) uiTreeOrdering.add( oilField->wellPathCollection() ); + if ( oilField->polygonCollection() ) uiTreeOrdering.add( oilField->polygonCollection() ); if ( oilField->surfaceCollection() ) uiTreeOrdering.add( oilField->surfaceCollection() ); if ( oilField->seismicDataCollection() ) { @@ -1534,11 +1535,6 @@ 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/RimSimWellInViewCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimSimWellInViewCollection.cpp index 0b3f0d472f..4124a28645 100644 --- a/ApplicationLibCode/ProjectDataModel/RimSimWellInViewCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimSimWellInViewCollection.cpp @@ -31,7 +31,6 @@ #include "RimEclipseContourMapView.h" #include "RimEclipseResultCase.h" #include "RimEclipseView.h" -#include "RimIntersectionCollection.h" #include "RimProject.h" #include "RimSimWellFractureCollection.h" #include "RimSimWellInView.h" @@ -483,10 +482,7 @@ void RimSimWellInViewCollection::fieldChangedByUi( const caf::PdmFieldHandle* ch if ( &wellPipeCoordType == changedField || &isAutoDetectingBranches == changedField ) { - if ( m_reservoirView ) - { - m_reservoirView->intersectionCollection()->recomputeSimWellBranchData(); - } + if ( m_reservoirView ) m_reservoirView->scheduleCreateDisplayModelAndRedraw(); for ( RimSimWellInView* w : wells ) { diff --git a/ApplicationLibCode/ProjectDataModel/RimStimPlanLegendConfig.cpp b/ApplicationLibCode/ProjectDataModel/RimStimPlanLegendConfig.cpp index 93cf19c2d3..46cdf42dd7 100644 --- a/ApplicationLibCode/ProjectDataModel/RimStimPlanLegendConfig.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimStimPlanLegendConfig.cpp @@ -20,7 +20,6 @@ #include "RimRegularLegendConfig.h" -#include "cafPdmUiOrdering.h" #include "cafPdmUiTreeOrdering.h" CAF_PDM_SOURCE_INIT( RimStimPlanLegendConfig, "RimStimPlanLegendConfig" ); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp index 6e5650c74f..bd193480c2 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp @@ -47,6 +47,7 @@ #include "cafProgressInfo.h" +#include #include CAF_PDM_SOURCE_INIT( RimSummaryCaseMainCollection, "SummaryCaseCollection" ); diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCsvFile.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCsvFile.cpp index f5e38452d1..cc71b7b498 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCsvFile.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCsvFile.cpp @@ -117,22 +117,25 @@ std::vector> RimWellLogCsvFile::findMdAndChannelValues std::vector wellLogFiles = wellPath.descendantsIncludingThisOfType(); for ( RimWellLogCsvFile* wellLogFile : wellLogFiles ) { - RigWellLogCsvFile* fileData = wellLogFile->wellLogFileData(); - std::vector channelValues = fileData->values( channelName ); - if ( !channelValues.empty() ) + RigWellLogCsvFile* fileData = wellLogFile->wellLogFileData(); + if ( fileData ) { - if ( unitString ) + std::vector channelValues = fileData->values( channelName ); + if ( !channelValues.empty() ) { - *unitString = fileData->wellLogChannelUnitString( channelName ); + if ( unitString ) + { + *unitString = fileData->wellLogChannelUnitString( channelName ); + } + std::vector depthValues = fileData->depthValues(); + CVF_ASSERT( depthValues.size() == channelValues.size() ); + std::vector> depthValuePairs; + for ( size_t i = 0; i < depthValues.size(); ++i ) + { + depthValuePairs.push_back( std::make_pair( depthValues[i], channelValues[i] ) ); + } + return depthValuePairs; } - std::vector depthValues = fileData->depthValues(); - CVF_ASSERT( depthValues.size() == channelValues.size() ); - std::vector> depthValuePairs; - for ( size_t i = 0; i < depthValues.size(); ++i ) - { - depthValuePairs.push_back( std::make_pair( depthValues[i], channelValues[i] ) ); - } - return depthValuePairs; } } return std::vector>(); diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.h index fe7c9fd36b..d5bc0d0191 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.h @@ -24,7 +24,6 @@ #include "cafPdmField.h" #include "cafPdmObject.h" #include "cafPdmPtrField.h" -#include "cafPdmUiOrdering.h" #include "cafTristate.h" #include diff --git a/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModel.cpp b/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModel.cpp index 286e91b986..bf34be9ae8 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModel.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModel.cpp @@ -139,6 +139,15 @@ std::pair RigFaultReactivationModel::modelLocalNormalsXY return m_generator->modelLocalNormalsXY(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec3d RigFaultReactivationModel::transformPointIfNeeded( const cvf::Vec3d point ) const +{ + if ( m_generator.get() == nullptr ) return point; + return m_generator->transformPointIfNeeded( point ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -261,6 +270,7 @@ void RigFaultReactivationModel::postProcessElementSets( const RimEclipseCase* eC for ( auto part : allGridParts() ) { - m_3dparts[part]->postProcessElementSets( eCase->mainGrid(), cellInfo ); + auto gridPart = m_3dparts[part]; + gridPart->postProcessElementSets( eCase->mainGrid(), cellInfo ); } } diff --git a/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModel.h b/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModel.h index 97a0417660..7a6f17fa41 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModel.h +++ b/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModel.h @@ -69,6 +69,7 @@ class RigFaultReactivationModel : public cvf::Object void setGenerator( std::shared_ptr generator ); std::pair modelLocalNormalsXY() const; + cvf::Vec3d transformPointIfNeeded( const cvf::Vec3d point ) const; void updateGeometry( size_t startCell, cvf::StructGridInterface::FaceType startFace ); diff --git a/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModelGenerator.cpp b/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModelGenerator.cpp index aac975721e..8530dd74b4 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModelGenerator.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModelGenerator.cpp @@ -167,6 +167,16 @@ void RigFaultReactivationModelGenerator::setupLocalCoordinateTransform() m_localCoordTransform.setTranslation( center ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec3d RigFaultReactivationModelGenerator::transformPointIfNeeded( const cvf::Vec3d point ) const +{ + if ( !m_useLocalCoordinates ) return point; + + return point.getTransformedPoint( m_localCoordTransform ); +} + //-------------------------------------------------------------------------------------------------- /// change corner order to be consistent so that index (0,1) and (2,3) gives the lower and upper horz. lines no matter what I or J face we /// have @@ -488,6 +498,20 @@ std::pair RigFaultReactivationModelGenerator::findCellWithInters return { i, j }; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::array RigFaultReactivationModelGenerator::shiftOrigin( const std::array& points, + const cvf::Vec3d& newOrigin ) +{ + std::array retPoints; + for ( int i = 0; i < (int)points.size(); i++ ) + { + retPoints[i] = points[i] - newOrigin; + } + return retPoints; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -574,25 +598,54 @@ void RigFaultReactivationModelGenerator::generateGeometry( size_t sta generatePointsFrontBack(); - frontPart->generateGeometry( m_frontPoints, - frontReservoirLayers, + // use temp origin in start position, at zero depth + cvf::Vec3d origin( m_startPosition ); + origin.z() = 0.0; + + cvf::Vec3d tVec = m_modelThickness * m_modelNormal; + std::vector thicknessVectors; + std::vector> faultLines; + const std::vector thicknessFactors = { -1.0, 0.0, 1.0 }; + + for ( int i = 0; i < 3; i++ ) + { + faultLines.push_back( + caf::Line( m_topFault - origin + thicknessFactors[i] * tVec, m_bottomFault - origin + thicknessFactors[i] * tVec ) ); + thicknessVectors.push_back( thicknessFactors[i] * tVec ); + } + + std::array shiftedFrontPoints = shiftOrigin( m_frontPoints, origin ); + std::array shiftedBackPoints = shiftOrigin( m_backPoints, origin ); + + std::vector frontResZ = extractZValues( frontReservoirLayers ); + std::vector backResZ = extractZValues( backReservoirLayers ); + + frontPart->generateGeometry( shiftedFrontPoints, + frontResZ, m_maxCellHeight, m_cellSizeHeightFactor, m_horizontalPartition, - m_modelThickness, + faultLines, + thicknessVectors, m_topReservoirFront.z(), - m_modelNormal, m_faultZoneCells ); - backPart->generateGeometry( m_backPoints, - backReservoirLayers, + + std::reverse( faultLines.begin(), faultLines.end() ); + std::reverse( thicknessVectors.begin(), thicknessVectors.end() ); + + backPart->generateGeometry( shiftedBackPoints, + backResZ, m_maxCellHeight, m_cellSizeHeightFactor, m_horizontalPartition, - m_modelThickness, + faultLines, + thicknessVectors, m_topReservoirBack.z(), - -1.0 * m_modelNormal, m_faultZoneCells ); + frontPart->shiftNodes( origin ); + backPart->shiftNodes( origin ); + frontPart->generateLocalNodes( m_localCoordTransform ); backPart->generateLocalNodes( m_localCoordTransform ); @@ -777,3 +830,18 @@ std::pair RigFaultReactivationModelGenerator::depthTopBottom() c { return { -m_startDepth, m_bottomDepth }; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RigFaultReactivationModelGenerator::extractZValues( const std::vector& points ) +{ + std::vector layers; + + for ( auto& p : points ) + { + layers.push_back( p.z() ); + } + + return layers; +} diff --git a/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModelGenerator.h b/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModelGenerator.h index 5a110a5151..23fbe91dc4 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModelGenerator.h +++ b/ApplicationLibCode/ReservoirDataModel/RigFaultReactivationModelGenerator.h @@ -58,6 +58,8 @@ class RigFaultReactivationModelGenerator : cvf::Object void setUseLocalCoordinates( bool useLocalCoordinates ); void setupLocalCoordinateTransform(); + cvf::Vec3d transformPointIfNeeded( const cvf::Vec3d point ) const; + std::pair modelLocalNormalsXY(); void generateGeometry( size_t startCellIndex, FaceType startFace, RigGriddedPart3d* frontPart, RigGriddedPart3d* backPart ); @@ -74,9 +76,11 @@ class RigFaultReactivationModelGenerator : cvf::Object static const std::vector partition( double distance, double startSize, double sizeFactor ); static std::pair sideFacesIJ( FaceType face ); - static cvf::Vec3d extrapolatePoint( cvf::Vec3d startPoint, cvf::Vec3d endPoint, double stopDepth ); - static void splitLargeLayers( std::map& layers, double maxHeight ); - static void mergeTinyLayers( std::map& layers, double minHeight ); + static cvf::Vec3d extrapolatePoint( cvf::Vec3d startPoint, cvf::Vec3d endPoint, double stopDepth ); + static void splitLargeLayers( std::map& layers, double maxHeight ); + static void mergeTinyLayers( std::map& layers, double minHeight ); + static std::vector extractZValues( const std::vector& points ); + static std::array shiftOrigin( const std::array& points, const cvf::Vec3d& newOrigin ); std::vector buildCellColumn( size_t startCell, FaceType startFace, std::map& layers ); diff --git a/ApplicationLibCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp b/ApplicationLibCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp index f8d99514cc..86ded27774 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp @@ -49,6 +49,7 @@ #include #include +#include #include const double RigGeoMechWellLogExtractor::PURE_WATER_DENSITY_GCM3 = 1.0; // g / cm^3 @@ -195,7 +196,6 @@ QString RigGeoMechWellLogExtractor::curveData( const RigFemResultAddress& resAdd auto [ppResultName, pp0ResultName] = mapSHMkToPP( QString::fromStdString( resAddr.fieldName ) ); wellBoreSH_MatthewsKelly( timeStepIndex, frameIndex, ppResultName, pp0ResultName, values ); - values->front() = wbsCurveValuesAtMsl(); } else { @@ -740,7 +740,7 @@ void RigGeoMechWellLogExtractor::wellBoreFGShale( const RigWbsParameter& paramet WbsParameterSource source = m_parameterSources.at( parameter ); if ( source == RigWbsParameter::DERIVED_FROM_K0FG ) { - wellBoreFGDerivedFromK0FG( RiaResultNames::wbsPPResult(), timeStepIndex, frameIndex, values ); + wellBoreFGDerivedFromK0FG( RiaResultNames::wbsPPResult(), timeStepIndex, frameIndex, values, false ); } else { @@ -766,7 +766,11 @@ void RigGeoMechWellLogExtractor::wellBoreFGShale( const RigWbsParameter& paramet //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigGeoMechWellLogExtractor::wellBoreFGDerivedFromK0FG( const QString& ppResult, int timeStepIndex, int frameIndex, std::vector* values ) +void RigGeoMechWellLogExtractor::wellBoreFGDerivedFromK0FG( const QString& ppResult, + int timeStepIndex, + int frameIndex, + std::vector* values, + bool onlyForPPReservoir ) { std::vector PP0; // results std::vector K0_FG, OBG0; // parameters @@ -774,6 +778,23 @@ void RigGeoMechWellLogExtractor::wellBoreFGDerivedFromK0FG( const QString& ppRes RigFemResultAddress ppAddr( RIG_WELLPATH_DERIVED, ppResult.toStdString(), "" ); wellPathScaledCurveData( ppAddr, 0, 0, &PP0, true ); + if ( onlyForPPReservoir ) + { + std::vector PP( intersections().size(), std::numeric_limits::infinity() ); + std::vector ppSources = + calculateWbsParameterForAllSegments( RigWbsParameter::PP_Reservoir(), timeStepIndex, frameIndex, &PP, false ); + + // Invalidate PP results from outside the reservoir zone. +#pragma omp parallel for + for ( int64_t intersectionIdx = 0; intersectionIdx < static_cast( intersections().size() ); ++intersectionIdx ) + { + if ( !isValid( PP[intersectionIdx] ) || ppSources[intersectionIdx] != RigWbsParameter::GRID ) + { + PP0[intersectionIdx] = std::numeric_limits::infinity(); + } + } + } + calculateWbsParameterForAllSegments( RigWbsParameter::K0_FG(), timeStepIndex, frameIndex, &K0_FG, true ); calculateWbsParameterForAllSegments( RigWbsParameter::OBG0(), 0, 0, &OBG0, true ); @@ -801,7 +822,8 @@ void RigGeoMechWellLogExtractor::wellBoreFG_MatthewsKelly( const RigWbsParameter { values->resize( intersections().size(), std::numeric_limits::infinity() ); - WbsParameterSource source = m_parameterSources.at( parameter ); + // Use FG_Shale source to avoid creating more options. + WbsParameterSource source = m_parameterSources.at( RigWbsParameter::FG_Shale() ); if ( source == RigWbsParameter::DERIVED_FROM_K0FG ) { auto mapParameterToPPResult = []( const RigWbsParameter& parameter ) @@ -811,8 +833,9 @@ void RigGeoMechWellLogExtractor::wellBoreFG_MatthewsKelly( const RigWbsParameter return RiaResultNames::wbsPPResult(); }; - QString ppResultName = mapParameterToPPResult( parameter ); - wellBoreFGDerivedFromK0FG( ppResultName, timeStepIndex, frameIndex, values ); + QString ppResultName = mapParameterToPPResult( parameter ); + bool onlyForPPReservoir = true; + wellBoreFGDerivedFromK0FG( ppResultName, timeStepIndex, frameIndex, values, onlyForPPReservoir ); } else { @@ -830,22 +853,23 @@ void RigGeoMechWellLogExtractor::wellBoreFG_MatthewsKelly( const RigWbsParameter curveData( SHMkAddr, timeStepIndex, frameIndex, &SH ); CVF_ASSERT( SH.size() == intersections().size() ); + + std::vector PP( intersections().size(), std::numeric_limits::infinity() ); + std::vector ppSources = + calculateWbsParameterForAllSegments( RigWbsParameter::PP_Reservoir(), timeStepIndex, frameIndex, &PP, false ); + double multiplier = m_userDefinedValues.at( parameter ); CVF_ASSERT( multiplier != std::numeric_limits::infinity() ); #pragma omp parallel for for ( int64_t intersectionIdx = 0; intersectionIdx < static_cast( intersections().size() ); ++intersectionIdx ) { - if ( !isValid( ( *values )[intersectionIdx] ) ) + if ( !isValid( ( *values )[intersectionIdx] ) && ppSources[intersectionIdx] == RigWbsParameter::GRID && + isValid( PP[intersectionIdx] ) && isValid( SH[intersectionIdx] ) ) { - if ( isValid( SH[intersectionIdx] ) ) - { - ( *values )[intersectionIdx] = SH[intersectionIdx] * multiplier; - } + ( *values )[intersectionIdx] = SH[intersectionIdx] * multiplier; } } } - - values->front() = wbsCurveValuesAtMsl(); } //-------------------------------------------------------------------------------------------------- @@ -870,6 +894,10 @@ void RigGeoMechWellLogExtractor::wellBoreSH_MatthewsKelly( int calculateWbsParameterForAllSegments( RigWbsParameter::OBG0(), 0, 0, &OBG0, true ); calculateWbsParameterForAllSegments( RigWbsParameter::DF(), timeStepIndex, frameIndex, &DF, true ); + std::vector ppSandAllSegments( intersections().size(), std::numeric_limits::infinity() ); + std::vector ppSources = + calculateWbsParameterForAllSegments( RigWbsParameter::PP_Reservoir(), timeStepIndex, frameIndex, &ppSandAllSegments, false ); + values->resize( intersections().size(), std::numeric_limits::infinity() ); if ( PP.size() != intersections().size() || PP0.size() != intersections().size() ) return; @@ -880,8 +908,8 @@ void RigGeoMechWellLogExtractor::wellBoreSH_MatthewsKelly( int #pragma omp parallel for for ( int64_t intersectionIdx = 0; intersectionIdx < static_cast( intersections().size() ); ++intersectionIdx ) { - if ( isValid( PP[intersectionIdx] ) && isValid( PP0[intersectionIdx] ) && isValid( OBG0[intersectionIdx] ) && - isValid( K0_SH[intersectionIdx] ) && isValid( DF[intersectionIdx] ) ) + if ( ppSources[intersectionIdx] == RigWbsParameter::GRID && isValid( PP[intersectionIdx] ) && isValid( PP0[intersectionIdx] ) && + isValid( OBG0[intersectionIdx] ) && isValid( K0_SH[intersectionIdx] ) && isValid( DF[intersectionIdx] ) ) { ( *values )[intersectionIdx] = ( K0_SH[intersectionIdx] * ( OBG0[intersectionIdx] - PP0[intersectionIdx] ) + PP0[intersectionIdx] + DF[intersectionIdx] * ( PP[intersectionIdx] - PP0[intersectionIdx] ) ); diff --git a/ApplicationLibCode/ReservoirDataModel/RigGeoMechWellLogExtractor.h b/ApplicationLibCode/ReservoirDataModel/RigGeoMechWellLogExtractor.h index aead1a2d45..e846bf440d 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigGeoMechWellLogExtractor.h +++ b/ApplicationLibCode/ReservoirDataModel/RigGeoMechWellLogExtractor.h @@ -131,7 +131,7 @@ class RigGeoMechWellLogExtractor : public RigWellLogExtractor const QString& wbsPP0ResultName, std::vector* values ); - void wellBoreFGDerivedFromK0FG( const QString& ppResult, int timeStepIndex, int frameIndex, std::vector* values ); + void wellBoreFGDerivedFromK0FG( const QString& ppResult, int timeStepIndex, int frameIndex, std::vector* values, bool onlyForPPReservoir ); void wellBoreFG_MatthewsKelly( const RigWbsParameter& parameter, int timeStepIndex, int frameIndex, std::vector* values ); diff --git a/ApplicationLibCode/ReservoirDataModel/RigGriddedPart3d.cpp b/ApplicationLibCode/ReservoirDataModel/RigGriddedPart3d.cpp index f98e3c19f8..2a693b37ef 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigGriddedPart3d.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigGriddedPart3d.cpp @@ -25,8 +25,11 @@ #include "RimFaultReactivationEnums.h" #include "cvfBoundingBox.h" +#include "cvfPlane.h" #include "cvfTextureImage.h" +#include "cafLine.h" + #include #include @@ -162,21 +165,6 @@ std::vector RigGriddedPart3d::generateGrowingLayers( double zFrom, doubl return layers; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RigGriddedPart3d::extractZValues( std::vector points ) -{ - std::vector layers; - - for ( auto& p : points ) - { - layers.push_back( p.z() ); - } - - return layers; -} - //-------------------------------------------------------------------------------------------------- /// Point index in input /// @@ -199,15 +187,15 @@ std::vector RigGriddedPart3d::extractZValues( std::vector po /// Assumes horizontal lines are parallel /// //-------------------------------------------------------------------------------------------------- -void RigGriddedPart3d::generateGeometry( const std::array& inputPoints, - const std::vector& reservoirLayers, - const double maxCellHeight, - double cellSizeFactor, - const std::vector& horizontalPartition, - double modelThickness, - double topHeight, - cvf::Vec3d thicknessDirection, - int nFaultZoneCells ) +void RigGriddedPart3d::generateGeometry( const std::array& inputPoints, + const std::vector& reservoirZ, + double maxCellHeight, + double cellSizeFactor, + const std::vector& horizontalPartition, + const std::vector> faultLines, + const std::vector& thicknessVectors, + double topHeight, + int nFaultZoneCells ) { reset(); @@ -217,16 +205,18 @@ void RigGriddedPart3d::generateGeometry( const std::array& input layersPerRegion[Regions::LowerUnderburden] = generateGrowingLayers( inputPoints[1].z(), inputPoints[0].z(), maxCellHeight, cellSizeFactor ); layersPerRegion[Regions::UpperUnderburden] = generateConstantLayers( inputPoints[1].z(), inputPoints[2].z(), maxCellHeight ); - layersPerRegion[Regions::Reservoir] = extractZValues( reservoirLayers ); - layersPerRegion[Regions::LowerOverburden] = generateConstantLayers( inputPoints[3].z(), inputPoints[4].z(), maxCellHeight ); + layersPerRegion[Regions::Reservoir] = reservoirZ; + + layersPerRegion[Regions::LowerOverburden] = generateConstantLayers( inputPoints[3].z(), inputPoints[4].z(), maxCellHeight ); layersPerRegion[Regions::UpperOverburden] = generateGrowingLayers( inputPoints[4].z(), inputPoints[5].z(), maxCellHeight, cellSizeFactor ); layersPerRegion[Regions::LowerUnderburden].pop_back(); // to avoid overlap with bottom of next region layersPerRegion[Regions::Reservoir].pop_back(); // to avoid overlap with bottom of next region - m_boundaryNodes[Boundary::Bottom] = {}; - m_boundaryNodes[Boundary::FarSide] = {}; - m_boundaryNodes[Boundary::Fault] = {}; + m_boundaryNodes[Boundary::Bottom] = {}; + m_boundaryNodes[Boundary::FarSide] = {}; + m_boundaryNodes[Boundary::Fault] = {}; + m_boundaryNodes[Boundary::Reservoir] = {}; size_t nVertCells = 0; const size_t nHorzCells = horizontalPartition.size() - 1; @@ -236,9 +226,7 @@ void RigGriddedPart3d::generateGeometry( const std::array& input nVertCells += layersPerRegion[region].size(); } - const std::vector thicknessFactors = { -1.0, 0.0, 1.0 }; - const int nThicknessCells = 2; - cvf::Vec3d tVec = modelThickness * thicknessDirection; + const int nThicknessCells = 2; size_t reserveSize = ( nVertCells + 1 ) * ( nHorzCells + 1 ) * ( nThicknessCells + 1 ); m_nodes.reserve( reserveSize ); @@ -302,8 +290,10 @@ void RigGriddedPart3d::generateGeometry( const std::array& input } else if ( region == Regions::Reservoir ) { - toPos = reservoirLayers[v]; - fromPos.z() = toPos.z(); + fromPos.z() = reservoirZ[v]; + cvf::Plane zPlane; + zPlane.setFromPointAndNormal( fromPos, cvf::Vec3d::Z_AXIS ); + zPlane.intersect( faultLines[1].start(), faultLines[1].end(), &toPos ); } cvf::Vec3d stepHorz = toPos - fromPos; @@ -320,8 +310,20 @@ void RigGriddedPart3d::generateGeometry( const std::array& input for ( int t = 0; t <= nThicknessCells; t++, nodeIndex++ ) { - m_nodes.push_back( p + thicknessFactors[t] * tVec ); + auto nodePoint = p + thicknessVectors[t]; + + // adjust points along the fault line inside the reservoir to make sure they end up at the fault + if ( ( h == (int)nHorzCells ) && + ( ( region == Regions::Reservoir ) || region == Regions::LowerOverburden || region == Regions::UpperUnderburden ) ) + { + cvf::Plane zPlane; + zPlane.setFromPointAndNormal( p, cvf::Vec3d::Z_AXIS ); + zPlane.intersect( faultLines[t].start(), faultLines[t].end(), &nodePoint ); + } + + m_nodes.push_back( nodePoint ); + // move nodes at fault used for data extraction a bit away from the fault if ( h == (int)nHorzCells ) { m_dataNodes.push_back( p + safetyOffset ); @@ -342,6 +344,11 @@ void RigGriddedPart3d::generateGeometry( const std::array& input else if ( h == (int)nHorzCells ) { m_boundaryNodes[Boundary::Fault].push_back( nodeIndex ); + + if ( region == Regions::Reservoir ) + { + m_boundaryNodes[Boundary::Reservoir].push_back( nodeIndex ); + } } } } @@ -661,6 +668,25 @@ void RigGriddedPart3d::generateLocalNodes( const cvf::Mat4d transform ) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigGriddedPart3d::shiftNodes( const cvf::Vec3d offset ) +{ + for ( int i = 0; i < (int)m_nodes.size(); i++ ) + { + m_nodes[i] += offset; + } + + for ( int i = 0; i < (int)m_meshLines.size(); i++ ) + { + for ( int j = 0; j < (int)m_meshLines[i].size(); j++ ) + { + m_meshLines[i][j] += offset; + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ReservoirDataModel/RigGriddedPart3d.h b/ApplicationLibCode/ReservoirDataModel/RigGriddedPart3d.h index 49f44269c8..13167d21f8 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigGriddedPart3d.h +++ b/ApplicationLibCode/ReservoirDataModel/RigGriddedPart3d.h @@ -24,6 +24,8 @@ #include "cvfObject.h" #include "cvfVector3.h" +#include "cafLine.h" + #include #include #include @@ -47,16 +49,17 @@ class RigGriddedPart3d : public cvf::Object void reset(); - void generateGeometry( const std::array& inputPoints, - const std::vector& reservoirLayers, - double maxCellHeight, - double cellSizeFactor, - const std::vector& horizontalPartition, - double modelThickness, - double topHeight, - cvf::Vec3d thicknessDirection, - int nFaultZoneCells ); - + void generateGeometry( const std::array& inputPoints, + const std::vector& reservoirZ, + double maxCellHeight, + double cellSizeFactor, + const std::vector& horizontalPartition, + const std::vector> faultLines, + const std::vector& thicknessVectors, + double topHeight, + int nFaultZoneCells ); + + void shiftNodes( const cvf::Vec3d offset ); void generateLocalNodes( const cvf::Mat4d transform ); void setUseLocalCoordinates( bool useLocalCoordinates ); @@ -87,7 +90,6 @@ class RigGriddedPart3d : public cvf::Object static cvf::Vec3d stepVector( cvf::Vec3d start, cvf::Vec3d stop, int nSteps ); static std::vector generateConstantLayers( double zFrom, double zTo, double maxSize ); static std::vector generateGrowingLayers( double zFrom, double zTo, double maxSize, double growfactor ); - static std::vector extractZValues( std::vector ); void generateVerticalMeshlines( const std::vector& cornerPoints, const std::vector& horzPartition ); diff --git a/ApplicationLibCode/UnitTests/CMakeLists.txt b/ApplicationLibCode/UnitTests/CMakeLists.txt index 941bf2afbb..d25c8bd5c9 100644 --- a/ApplicationLibCode/UnitTests/CMakeLists.txt +++ b/ApplicationLibCode/UnitTests/CMakeLists.txt @@ -101,6 +101,7 @@ set(SOURCE_UNITTEST_FILES ${CMAKE_CURRENT_LIST_DIR}/RifGridCalculationIO-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RifSummaryCalculationIO-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RimEmReader-Test.cpp + ${CMAKE_CURRENT_LIST_DIR}/RifPolygonReader-Test.cpp ) if(RESINSIGHT_ENABLE_GRPC) diff --git a/ApplicationLibCode/UnitTests/RifPolygonReader-Test.cpp b/ApplicationLibCode/UnitTests/RifPolygonReader-Test.cpp new file mode 100644 index 0000000000..f556ba332e --- /dev/null +++ b/ApplicationLibCode/UnitTests/RifPolygonReader-Test.cpp @@ -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. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "gtest/gtest.h" + +#include "RifPolygonReader.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST( RifPolygonReader, MultiplePolygonsInSameFile ) +{ + std::string fileContent = R"( +# This is a comment +# This is a comment +58177.76 732.7 1643.6 +58260.83 732.8 1596.6 +57985.66 732.7 1542.0 +59601.45 732.4 3639.0 +59422.01 732.2 3639.0 +59793.41 732.2 3639.0 +999 999 999 +# starting polyline 2 +58260.83 732.8 1596.6 +57985.66 732.7 1542.0 +59601.45 732.4 3639.0 )"; + + QString fileContentAsQString = QString::fromStdString( fileContent ); + QString errorMessage; + + auto polygons = RifPolygonReader::parseText( fileContentAsQString, &errorMessage ); + EXPECT_TRUE( polygons.size() == 2 ); + + auto firstPolygon = polygons.front(); + EXPECT_TRUE( firstPolygon.size() == 6 ); + EXPECT_DOUBLE_EQ( firstPolygon.front().x(), 58177.76 ); + + auto secondPolygon = polygons.back(); + EXPECT_TRUE( secondPolygon.size() == 3 ); + EXPECT_DOUBLE_EQ( secondPolygon.back().x(), 59601.45 ); +} + +TEST( RifPolygonReader, CsvImport ) +{ + std::string fileContent = R"( +X_UTME,Y_UTMN,Z_TVDSS,POLY_ID +460536.5500488281,5934613.072753906,1652.97265625,0 +460535.4345703125,5934678.220581055,1652.8203125,0 +460534.3497314453,5934741.589111328,1652.672119140625,0 +460534.5389404297,5934747.926269531,1652.6595458984375,0 +460530.44287109375,5934829.321044922,1652.448974609375,0 +460530.20642089844,5934842.320922852,1652.6920166015625,0 +460535.5516357422,5934890.617675781,1653.71240234375,0 +460548.05139160156,5935007.113769531,1656.166259765625,0 +460550.3292236328,5935027.826538086,1656.641845703125,0 +)"; + + QString fileContentAsQString = QString::fromStdString( fileContent ); + QString errorMessage; + + auto polygons = RifPolygonReader::parseTextCsv( fileContentAsQString, &errorMessage ); + EXPECT_TRUE( polygons.size() == 1 ); + + auto firstPolygon = polygons.front(); + EXPECT_TRUE( firstPolygon.second.size() == 9 ); + EXPECT_DOUBLE_EQ( firstPolygon.second.back().z(), -1656.641845703125 ); +} + +TEST( RifPolygonReader, CsvImportNoHeader ) +{ + std::string fileContent = R"( +460536.5500488281,5934613.072753906,1652.97265625,0 +460535.4345703125,5934678.220581055,1652.8203125,0 +)"; + + QString fileContentAsQString = QString::fromStdString( fileContent ); + QString errorMessage; + + auto polygons = RifPolygonReader::parseTextCsv( fileContentAsQString, &errorMessage ); + EXPECT_TRUE( polygons.size() == 1 ); + + auto firstPolygon = polygons.front(); + EXPECT_TRUE( firstPolygon.second.size() == 2 ); +} diff --git a/ApplicationLibCode/UserInterface/RiuMainWindowBase.cpp b/ApplicationLibCode/UserInterface/RiuMainWindowBase.cpp index 8f32f714f2..adfcd08106 100644 --- a/ApplicationLibCode/UserInterface/RiuMainWindowBase.cpp +++ b/ApplicationLibCode/UserInterface/RiuMainWindowBase.cpp @@ -43,6 +43,7 @@ #include "DockWidget.h" #include +#include #include #include #include diff --git a/ApplicationLibCode/UserInterface/RiuPlotMainWindowTools.cpp b/ApplicationLibCode/UserInterface/RiuPlotMainWindowTools.cpp index d81d95ab43..1910726831 100644 --- a/ApplicationLibCode/UserInterface/RiuPlotMainWindowTools.cpp +++ b/ApplicationLibCode/UserInterface/RiuPlotMainWindowTools.cpp @@ -20,6 +20,8 @@ #include "RiaGuiApplication.h" #include "RiuPlotMainWindow.h" +#include "cafPdmObject.h" + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/UserInterface/RiuPlotObjectPicker.cpp b/ApplicationLibCode/UserInterface/RiuPlotObjectPicker.cpp index e189c13961..c3c844050f 100644 --- a/ApplicationLibCode/UserInterface/RiuPlotObjectPicker.cpp +++ b/ApplicationLibCode/UserInterface/RiuPlotObjectPicker.cpp @@ -21,6 +21,8 @@ #include "RiaGuiApplication.h" #include "RiuPlotMainWindow.h" +#include "cafPdmObject.h" + #include //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/UserInterface/RiuSummaryPlot.cpp b/ApplicationLibCode/UserInterface/RiuSummaryPlot.cpp index 5e0de6acfc..9cd95d1fda 100644 --- a/ApplicationLibCode/UserInterface/RiuSummaryPlot.cpp +++ b/ApplicationLibCode/UserInterface/RiuSummaryPlot.cpp @@ -32,6 +32,7 @@ #include "cafCmdFeatureMenuBuilder.h" +#include #include #include diff --git a/ApplicationLibCode/UserInterface/RiuViewerCommands.cpp b/ApplicationLibCode/UserInterface/RiuViewerCommands.cpp index 37833f816a..1fb9b04446 100644 --- a/ApplicationLibCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationLibCode/UserInterface/RiuViewerCommands.cpp @@ -393,6 +393,7 @@ void RiuViewerCommands::displayContextMenu( QMouseEvent* event ) } menuBuilder << "RicNewPolygonFilter3dviewFeature"; + menuBuilder.addCmdFeature( "RicCreatePolygonFeature", "Polygon" ); menuBuilder << "RicEclipsePropertyFilterNewInViewFeature"; menuBuilder << "RicGeoMechPropertyFilterNewInViewFeature"; diff --git a/Fwk/AppFwk/CommonCode/CMakeLists.txt b/Fwk/AppFwk/CommonCode/CMakeLists.txt index 9a78a8b941..0bf5a214e8 100644 --- a/Fwk/AppFwk/CommonCode/CMakeLists.txt +++ b/Fwk/AppFwk/CommonCode/CMakeLists.txt @@ -14,13 +14,23 @@ find_package(OpenGL) # These headers need to go through Qt's MOC compiler set(MOC_HEADER_FILES cafMessagePanel.h) -find_package( - Qt5 - COMPONENTS - REQUIRED Core Gui Widgets OpenGL -) -set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::Widgets Qt5::OpenGL) -qt5_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES}) +if(CEE_USE_QT6) + find_package( + Qt6 + COMPONENTS + REQUIRED Core Gui Widgets OpenGL + ) + set(QT_LIBRARIES Qt6::Core Qt6::Gui Qt6::Widgets Qt6::OpenGL) + qt_standard_project_setup() +else() + find_package( + Qt5 + COMPONENTS + REQUIRED Core Gui Widgets OpenGL + ) + set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::Widgets Qt5::OpenGL) + qt5_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES}) +endif() add_library( ${PROJECT_NAME} diff --git a/Fwk/AppFwk/CommonCode/cafEffectGenerator.cpp b/Fwk/AppFwk/CommonCode/cafEffectGenerator.cpp index 80cd9b9255..04d246afa1 100644 --- a/Fwk/AppFwk/CommonCode/cafEffectGenerator.cpp +++ b/Fwk/AppFwk/CommonCode/cafEffectGenerator.cpp @@ -58,8 +58,6 @@ #include "cvfTextureImage.h" #include "cvfUniform.h" -#include - namespace caf { //############################################################################################################################# diff --git a/Fwk/AppFwk/CommonCode/cafUtils.cpp b/Fwk/AppFwk/CommonCode/cafUtils.cpp index b137915258..07afa25f7f 100644 --- a/Fwk/AppFwk/CommonCode/cafUtils.cpp +++ b/Fwk/AppFwk/CommonCode/cafUtils.cpp @@ -42,8 +42,6 @@ #include #include -#include - #include #include diff --git a/Fwk/AppFwk/CommonCode/cafUtils.h b/Fwk/AppFwk/CommonCode/cafUtils.h index da265dd334..d681c6427a 100644 --- a/Fwk/AppFwk/CommonCode/cafUtils.h +++ b/Fwk/AppFwk/CommonCode/cafUtils.h @@ -38,9 +38,10 @@ #include +#include + class QLineEdit; class QString; -class QStringList; namespace caf { diff --git a/Fwk/AppFwk/cafCommand/cafCmdFeatureMenuBuilder.cpp b/Fwk/AppFwk/cafCommand/cafCmdFeatureMenuBuilder.cpp index 6ee608ad6f..5b5702c0ee 100644 --- a/Fwk/AppFwk/cafCommand/cafCmdFeatureMenuBuilder.cpp +++ b/Fwk/AppFwk/cafCommand/cafCmdFeatureMenuBuilder.cpp @@ -204,7 +204,7 @@ void CmdFeatureMenuBuilder::appendToMenu( QMenu* menu ) } else { - act = commandManager->action( m_items[i].itemName ); + act = commandManager->action( m_items[i].itemName, m_items[i].uiText ); } CAF_ASSERT( act ); diff --git a/Fwk/AppFwk/cafCommand/cafCmdFieldChangeExec.cpp b/Fwk/AppFwk/cafCommand/cafCmdFieldChangeExec.cpp index 3cf7280206..827e3d2966 100644 --- a/Fwk/AppFwk/cafCommand/cafCmdFieldChangeExec.cpp +++ b/Fwk/AppFwk/cafCommand/cafCmdFieldChangeExec.cpp @@ -38,6 +38,7 @@ #include "cafNotificationCenter.h" #include "cafPdmReferenceHelper.h" +#include "cafPdmUiOrdering.h" namespace caf { diff --git a/Fwk/AppFwk/cafCommand/cafCmdUiCommandSystemImpl.cpp b/Fwk/AppFwk/cafCommand/cafCmdUiCommandSystemImpl.cpp index 3c555155b7..49d8c4c78f 100644 --- a/Fwk/AppFwk/cafCommand/cafCmdUiCommandSystemImpl.cpp +++ b/Fwk/AppFwk/cafCommand/cafCmdUiCommandSystemImpl.cpp @@ -43,8 +43,7 @@ #include "cafPdmChildArrayField.h" #include "cafPdmFieldHandle.h" #include "cafPdmObjectHandle.h" -#include "cafPdmUiObjectHandle.h" -#include "cafPdmXmlFieldHandle.h" +#include "cafPdmReferenceHelper.h" #include "cafSelectionManager.h" #include diff --git a/Fwk/AppFwk/cafCommandFeatures/ToggleCommands/cafToggleItemsFeatureImpl.cpp b/Fwk/AppFwk/cafCommandFeatures/ToggleCommands/cafToggleItemsFeatureImpl.cpp index 4a91543dd8..7994eb173d 100644 --- a/Fwk/AppFwk/cafCommandFeatures/ToggleCommands/cafToggleItemsFeatureImpl.cpp +++ b/Fwk/AppFwk/cafCommandFeatures/ToggleCommands/cafToggleItemsFeatureImpl.cpp @@ -36,11 +36,8 @@ #include "cafToggleItemsFeatureImpl.h" -//#include "RiaFeatureCommandContext.h" -//#include "RiaGuiApplication.h" -//#include "RiuMainWindow.h" -//#include "RiuPlotMainWindow.h" - +#include "cafCmdFeatureManager.h" +#include "cafPdmField.h" #include "cafPdmUiFieldHandle.h" #include "cafPdmUiItem.h" #include "cafPdmUiObjectHandle.h" @@ -50,7 +47,6 @@ #include -#include "cafCmdFeatureManager.h" #include namespace caf diff --git a/Fwk/AppFwk/cafPdmScripting/cafPdmFieldScriptingCapability.h b/Fwk/AppFwk/cafPdmScripting/cafPdmFieldScriptingCapability.h index d5513fe2e4..0440d0c237 100644 --- a/Fwk/AppFwk/cafPdmScripting/cafPdmFieldScriptingCapability.h +++ b/Fwk/AppFwk/cafPdmScripting/cafPdmFieldScriptingCapability.h @@ -45,11 +45,6 @@ #include "cafPdmScriptIOMessages.h" #include -#include -#include -#include - -#include #define CAF_PDM_InitScriptableField( field, keyword, default, uiName, ... ) \ { \ diff --git a/Fwk/AppFwk/cafPdmScripting/cafPdmObjectMethod.h b/Fwk/AppFwk/cafPdmScripting/cafPdmObjectMethod.h index 210340ddec..0458006556 100644 --- a/Fwk/AppFwk/cafPdmScripting/cafPdmObjectMethod.h +++ b/Fwk/AppFwk/cafPdmScripting/cafPdmObjectMethod.h @@ -37,9 +37,7 @@ #include "cafAssert.h" #include "cafPdmObject.h" -#include "cafPdmObjectFactory.h" #include "cafPdmPointer.h" -#include "cafPdmScriptResponse.h" /// CAF_PDM_OBJECT_METHOD_SOURCE_INIT associates the self class keyword and the method keyword with the method factory /// Place this in the cpp file, preferably above the constructor diff --git a/Fwk/AppFwk/cafPdmScripting/cafPdmObjectScriptingCapability.h b/Fwk/AppFwk/cafPdmScripting/cafPdmObjectScriptingCapability.h index 37d7c037b0..bff28f0eac 100644 --- a/Fwk/AppFwk/cafPdmScripting/cafPdmObjectScriptingCapability.h +++ b/Fwk/AppFwk/cafPdmScripting/cafPdmObjectScriptingCapability.h @@ -35,15 +35,9 @@ //################################################################################################## #pragma once -#include "cafPdmChildArrayField.h" #include "cafPdmObjectCapability.h" -#include "cafPdmObjectMethod.h" #include "cafPdmObjectScriptingCapabilityRegister.h" -#include - -#include -#include #include class QTextStream; diff --git a/Fwk/AppFwk/cafPdmScripting/cafPdmScriptResponse.h b/Fwk/AppFwk/cafPdmScripting/cafPdmScriptResponse.h index 482a586435..c8983d6e8d 100644 --- a/Fwk/AppFwk/cafPdmScripting/cafPdmScriptResponse.h +++ b/Fwk/AppFwk/cafPdmScripting/cafPdmScriptResponse.h @@ -36,7 +36,6 @@ #pragma once #include "cafPdmObject.h" -#include "cafPdmPointer.h" #include #include diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmBase.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmBase.h index 503fbe84af..23b540257e 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmBase.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmBase.h @@ -1,8 +1,5 @@ #pragma once -// Brings in size_t and definition of NULL -#include - // Macro to disable the copy constructor and assignment operator // Should be used in the private section of a class #define PDM_DISABLE_COPY_AND_ASSIGN( CLASS_NAME ) \ diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmReferenceHelper.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmReferenceHelper.h index c2d20a734c..50ce298a44 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmReferenceHelper.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmReferenceHelper.h @@ -37,9 +37,6 @@ #pragma once #include "cafPdmObjectHandle.h" -#include "cafPdmPointer.h" - -#include namespace caf { diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafSignal.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafSignal.h index 32b0122df8..4b3ba669d6 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafSignal.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafSignal.h @@ -40,7 +40,6 @@ #include #include #include -#include #include namespace caf diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmDocument.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmDocument.h index 23c54ab357..21164263a2 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmDocument.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmDocument.h @@ -35,9 +35,9 @@ //################################################################################################## #pragma once + #include "cafPdmField.h" #include "cafPdmObject.h" -#include "cafPdmPointer.h" namespace caf { diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmObject.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmObject.cpp index 1c3d8c8a65..968ff651ad 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmObject.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmObject.cpp @@ -1,5 +1,7 @@ #include "cafPdmObject.h" +#include "cafPdmUiFieldHandle.h" + using namespace caf; CAF_PDM_ABSTRACT_SOURCE_INIT( PdmObject, "PdmObjectBase" ); @@ -15,6 +17,20 @@ caf::PdmObject::PdmObject() CAF_PDM_InitObject( "Base PDM Object", "", "", "The Abstract Base Class for the Project Data Model" ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void PdmObject::addFieldUiNoDefault( PdmFieldHandle* field, const QString& keyword, PdmUiItemInfo* fieldDescription ) +{ + addField( field, keyword ); + + PdmUiFieldHandle* uiFieldHandle = field->uiCapability(); + if ( uiFieldHandle ) + { + uiFieldHandle->setUiItemInfo( fieldDescription ); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmObject.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmObject.h index 1616b01cd9..4f4c8fb71c 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmObject.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmObject.h @@ -38,27 +38,16 @@ #include "cafPdmObjectHandle.h" -#include "cafPdmPointer.h" -#include "cafPdmUiOrdering.h" - -#include - class QXmlStreamReader; class QXmlStreamWriter; +#include "cafInternalPdmUiFieldCapability.h" #include "cafPdmObjectCapability.h" - #include "cafPdmUiObjectHandle.h" +#include "cafPdmUiOrdering.h" #include "cafPdmXmlObjectHandle.h" #include "cafPdmXmlObjectHandleMacros.h" -#include "cafInternalPdmUiFieldCapability.h" -#include "cafInternalPdmXmlFieldCapability.h" -#include "cafPdmFieldHandle.h" - -#include "cafIconProvider.h" -#include "cafPdmUiFieldSpecialization.h" - namespace caf { class PdmFieldHandle; @@ -183,16 +172,7 @@ class PdmObject : public PdmObjectHandle, public PdmXmlObjectHandle, public PdmU /// Does the same as the above method, but omits the default value. /// Consider this method private. Please use the CAF_PDM_InitFieldNoDefault() macro instead. - void addFieldUiNoDefault( PdmFieldHandle* field, const QString& keyword, PdmUiItemInfo* fieldDescription ) - { - addField( field, keyword ); - - PdmUiFieldHandle* uiFieldHandle = field->uiCapability(); - if ( uiFieldHandle ) - { - uiFieldHandle->setUiItemInfo( fieldDescription ); - } - } + void addFieldUiNoDefault( PdmFieldHandle* field, const QString& keyword, PdmUiItemInfo* fieldDescription ); /// Returns _this_ if _this_ has requested class keyword /// Traverses parents recursively and returns first parent of the requested diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafInternalPdmFieldTypeSpecializations.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafInternalPdmFieldTypeSpecializations.h index b07a0da80b..4486578654 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafInternalPdmFieldTypeSpecializations.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafInternalPdmFieldTypeSpecializations.h @@ -4,10 +4,6 @@ #include "cafPdmObjectHandle.h" #include "cafPdmPointer.h" -#include - -#include - namespace caf { template diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafInternalPdmUiFieldCapability.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafInternalPdmUiFieldCapability.h index 451880046f..47ffa2ce5f 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafInternalPdmUiFieldCapability.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafInternalPdmUiFieldCapability.h @@ -1,5 +1,7 @@ #pragma once +#include "cafPdmChildArrayField.h" +#include "cafPdmChildField.h" #include "cafPdmUiFieldHandle.h" namespace caf diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiEditorHandle.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiEditorHandle.h index f6200ceaa1..2378d5527f 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiEditorHandle.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiEditorHandle.h @@ -43,7 +43,6 @@ namespace caf { -class PdmUiItem; //================================================================================================== /// Abstract class to handle editors. Inherits QObject to be able to use signals and slots diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldEditorHandle.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldEditorHandle.cpp index 09d985f71f..7c2cb1ca0d 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldEditorHandle.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldEditorHandle.cpp @@ -42,9 +42,7 @@ #include "cafPdmUiObjectHandle.h" #include -#include #include -#include namespace caf { @@ -137,6 +135,30 @@ void PdmUiFieldEditorHandle::createWidgets( QWidget* parent ) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QWidget* PdmUiFieldEditorHandle::combinedWidget() +{ + return m_combinedWidget; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QWidget* PdmUiFieldEditorHandle::editorWidget() +{ + return m_editorWidget; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QWidget* PdmUiFieldEditorHandle::labelWidget() +{ + return m_labelWidget; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -153,6 +175,30 @@ int PdmUiFieldEditorHandle::rowStretchFactor() const return isMultiRowEditor() ? 1 : 0; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QWidget* PdmUiFieldEditorHandle::createCombinedWidget( QWidget* parent ) +{ + return nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QWidget* PdmUiFieldEditorHandle::createEditorWidget( QWidget* parent ) +{ + return nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QWidget* PdmUiFieldEditorHandle::createLabelWidget( QWidget* parent ) +{ + return nullptr; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldEditorHandle.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldEditorHandle.h index 11a3c464cc..5587792a66 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldEditorHandle.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldEditorHandle.h @@ -40,14 +40,6 @@ #include "cafPdmUiEditorHandle.h" #include "cafQShortenedLabel.h" -#include - -#include -#include -#include - -class QLabel; - namespace caf { //================================================================================================== @@ -99,9 +91,9 @@ class PdmUiFieldEditorHandle : public PdmUiEditorHandle void setUiField( PdmUiFieldHandle* uiFieldHandle ); void createWidgets( QWidget* parent ); - QWidget* combinedWidget() { return m_combinedWidget; } - QWidget* editorWidget() { return m_editorWidget; } - QWidget* labelWidget() { return m_labelWidget; } + QWidget* combinedWidget(); + QWidget* editorWidget(); + QWidget* labelWidget(); QMargins labelContentMargins() const; int rowStretchFactor() const; @@ -109,9 +101,9 @@ class PdmUiFieldEditorHandle : public PdmUiEditorHandle /// Implement one of these, or both editor and label. The widgets will be used in the parent layout according to /// being "Label" Editor" or a single combined widget. - virtual QWidget* createCombinedWidget( QWidget* parent ) { return nullptr; } - virtual QWidget* createEditorWidget( QWidget* parent ) { return nullptr; } - virtual QWidget* createLabelWidget( QWidget* parent ) { return nullptr; } + virtual QWidget* createCombinedWidget( QWidget* parent ); + virtual QWidget* createEditorWidget( QWidget* parent ); + virtual QWidget* createLabelWidget( QWidget* parent ); void setValueToField( const QVariant& value ); diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.cpp index 37829e1e03..e5b4d1b88b 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.cpp @@ -35,7 +35,6 @@ //################################################################################################## #include "cafPdmUiItem.h" -#include "cafPdmPtrField.h" #include "cafPdmUiEditorHandle.h" #include "cafPdmUiObjectEditorHandle.h" diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.h index 947b9ce0c7..07d757ceab 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.h @@ -39,10 +39,6 @@ #include "cafIconProvider.h" #include "cafPdmUiFieldSpecialization.h" -#include -#include -#include -#include #include #include diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectEditorHandle.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectEditorHandle.h index 05f043c4aa..23074f25f0 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectEditorHandle.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectEditorHandle.h @@ -37,7 +37,6 @@ #pragma once -#include "cafPdmPointer.h" #include "cafPdmUiEditorHandle.h" #include diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.h index b65fc7d242..c17447eb65 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.h @@ -91,13 +91,6 @@ class PdmUiObjectHandle : public PdmUiItem, public PdmObjectCapability { } - /// Override to provide tree editor specific attributes for the field and uiConfigName - virtual void defineTreeEditorAttribute( const caf::PdmFieldHandle* field, - QString uiConfigName, - caf::PdmUiEditorAttribute* attribute ) - { - } - /// Override to provide editor specific data for the uiConfigName for the object virtual void defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) {} diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiOrdering.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiOrdering.cpp index 74c0b73f95..eacaf1bd3e 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiOrdering.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiOrdering.cpp @@ -36,7 +36,6 @@ #include "cafPdmUiOrdering.h" -#include "cafPdmDataValueField.h" #include "cafPdmObjectHandle.h" #include "cafPdmUiFieldHandle.h" #include "cafPdmUiObjectHandle.h" diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiTreeOrdering.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiTreeOrdering.cpp index 4ac222882c..656ff92704 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiTreeOrdering.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiTreeOrdering.cpp @@ -37,7 +37,6 @@ #include "cafPdmUiTreeOrdering.h" #include "cafAssert.h" -#include "cafPdmDataValueField.h" #include "cafPdmObjectHandle.h" #include "cafPdmUiEditorHandle.h" #include "cafPdmUiFieldHandle.h" diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiTreeOrdering.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiTreeOrdering.h index f531cc8d37..9bc32f4ff1 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiTreeOrdering.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiTreeOrdering.h @@ -41,8 +41,6 @@ #include #include -#include - namespace caf { class PdmFieldHandle; diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafQShortenedLabel.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafQShortenedLabel.cpp index 305e81d1ed..9230fae456 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafQShortenedLabel.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafQShortenedLabel.cpp @@ -36,9 +36,7 @@ #include "cafQShortenedLabel.h" #include -#include #include -#include using namespace caf; diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManager.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManager.h index b48433fee5..96acde4c0f 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManager.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManager.h @@ -37,7 +37,6 @@ #include "cafSelectionChangedReceiver.h" -#include "cafPdmField.h" #include "cafPdmObjectHandle.h" #include "cafPdmPointer.h" #include "cafPdmUiItem.h" diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafUiTreeItem.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafUiTreeItem.h index cd2d7c8ee6..1d0b04abe3 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafUiTreeItem.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafUiTreeItem.h @@ -36,7 +36,6 @@ #pragma once -//#include #include #include diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmXmlFieldCapability.inl b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmXmlFieldCapability.inl index 85b9ecd63f..7027f4a642 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmXmlFieldCapability.inl +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmXmlFieldCapability.inl @@ -2,6 +2,8 @@ #include "cafAssert.h" #include "cafInternalPdmFieldIoHelper.h" #include "cafPdmObjectFactory.h" +#include "cafPdmObjectHandle.h" +#include "cafPdmReferenceHelper.h" #include "cafPdmXmlObjectHandle.h" #include diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmXmlFieldReaderWriter.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmXmlFieldReaderWriter.h index fa72d6cc19..0712c393f5 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmXmlFieldReaderWriter.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmXmlFieldReaderWriter.h @@ -7,7 +7,6 @@ #include "cafInternalPdmFieldIoHelper.h" #include "cafInternalPdmFilePathStreamOperators.h" #include "cafInternalPdmStreamOperators.h" -#include "cafPdmReferenceHelper.h" namespace caf { @@ -71,56 +70,4 @@ void PdmFieldReader::readFieldData( DataType& fieldValue, QXmlStreamRe template <> void PdmFieldReader::readFieldData( QString& field, QXmlStreamReader& xmlStream, PdmObjectFactory* objectFactory ); -#if 0 -//-------------------------------------------------------------------------------------------------- -/// Specialized IO for PdmPointer -//-------------------------------------------------------------------------------------------------- -template -struct PdmFieldWriter< PdmPointer > -{ - static void writeFieldData(const PdmPointer & fieldValue, QXmlStreamWriter& xmlStream, PdmReferenceHelper* referenceHelper) - { - QString dataString; - - CAF_ASSERT(referenceHelper); - - if (fieldValue.isNull()) - { - dataString = "NULL"; - } - else - { - dataString = referenceHelper->referenceFromRootToObject(fieldValue.p()); - } - - xmlStream.writeCharacters(dataString); - } -}; - -template -struct PdmFieldReader< PdmPointer > -{ - static void readFieldData(PdmPointer & fieldValue, QXmlStreamReader& xmlStream, PdmObjectFactory*, PdmReferenceHelper* referenceHelper) - { - PdmFieldIOHelper::skipComments(xmlStream); - if (!xmlStream.isCharacters()) return; - - QString dataString = xmlStream.text().toString(); - - // Make stream point to end of element - QXmlStreamReader::TokenType type = xmlStream.readNext(); - Q_UNUSED(type); - PdmFieldIOHelper::skipCharactersAndComments(xmlStream); - - if (dataString != "NULL") - { - CAF_ASSERT(referenceHelper); - - PdmObjectHandle* objHandle = referenceHelper->objectFromReference(dataString); - fieldValue.setRawPtr(objHandle); - } - } -}; - -#endif } // End of namespace caf diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmSettings.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmSettings.cpp index 2f1d1dd423..6ac0284ada 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmSettings.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmSettings.cpp @@ -35,10 +35,12 @@ //################################################################################################## #include "cafPdmSettings.h" - -#include "cafPdmField.h" +#include "cafPdmObjectHandle.h" +#include "cafPdmValueField.h" #include "cafPdmXmlObjectHandle.h" +#include + namespace caf { //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmSettings.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmSettings.h index d9d7689197..6da23c60c7 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmSettings.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmSettings.h @@ -36,7 +36,7 @@ #pragma once -#include +#include namespace caf { diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXmlFieldHandle.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXmlFieldHandle.h index b158215453..63741d0874 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXmlFieldHandle.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXmlFieldHandle.h @@ -2,7 +2,6 @@ #include "cafPdmFieldCapability.h" #include -#include class QXmlStreamReader; class QXmlStreamWriter; diff --git a/Fwk/AppFwk/cafTests/cafTestApplication/LineEditAndPushButtons.cpp b/Fwk/AppFwk/cafTests/cafTestApplication/LineEditAndPushButtons.cpp index e3fe762732..18b9bc4c01 100644 --- a/Fwk/AppFwk/cafTests/cafTestApplication/LineEditAndPushButtons.cpp +++ b/Fwk/AppFwk/cafTests/cafTestApplication/LineEditAndPushButtons.cpp @@ -7,6 +7,8 @@ #include "cafPdmUiPushButtonEditor.h" #include "cafPdmUiTreeSelectionEditor.h" +#include + CAF_PDM_SOURCE_INIT( LineEditAndPushButtons, "LineEditAndPushButtons" ); //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafTests/cafTestApplication/MainWindow.cpp b/Fwk/AppFwk/cafTests/cafTestApplication/MainWindow.cpp index 4d87f66a0c..3e0bdee720 100644 --- a/Fwk/AppFwk/cafTests/cafTestApplication/MainWindow.cpp +++ b/Fwk/AppFwk/cafTests/cafTestApplication/MainWindow.cpp @@ -33,7 +33,6 @@ #include "cafPdmUiFilePathEditor.h" #include "cafPdmUiItem.h" #include "cafPdmUiListEditor.h" -#include "cafPdmUiOrdering.h" #include "cafPdmUiPropertyView.h" #include "cafPdmUiPushButtonEditor.h" #include "cafPdmUiTableView.h" diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiActionPushButtonEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiActionPushButtonEditor.cpp index d1ba0976bd..2b692f5e32 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiActionPushButtonEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiActionPushButtonEditor.cpp @@ -41,7 +41,6 @@ #include "cafPdmField.h" #include "cafPdmObject.h" #include "cafPdmUiFieldEditorHandle.h" -#include "cafPdmUiOrdering.h" #include "cafFactory.h" diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiCheckBoxAndTextEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiCheckBoxAndTextEditor.cpp index b50f347bc0..4092b50f8c 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiCheckBoxAndTextEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiCheckBoxAndTextEditor.cpp @@ -41,8 +41,6 @@ #include "cafPdmUiDefaultObjectEditor.h" #include "cafPdmUiFieldEditorHandle.h" #include "cafPdmUiLineEditor.h" -#include "cafPdmUiOrdering.h" -#include "cafQShortenedLabel.h" #include #include diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiCheckBoxEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiCheckBoxEditor.cpp index d52dd26fe9..48cf6ff17b 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiCheckBoxEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiCheckBoxEditor.cpp @@ -41,8 +41,6 @@ #include "cafPdmField.h" #include "cafPdmObject.h" #include "cafPdmUiFieldEditorHandle.h" -#include "cafPdmUiOrdering.h" -#include "cafQShortenedLabel.h" #include "cafFactory.h" diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiCheckBoxTristateEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiCheckBoxTristateEditor.cpp index 7e621d99ea..fd3749b7d9 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiCheckBoxTristateEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiCheckBoxTristateEditor.cpp @@ -7,8 +7,6 @@ #include "cafPdmField.h" #include "cafPdmObject.h" #include "cafPdmUiFieldEditorHandle.h" -#include "cafPdmUiOrdering.h" -#include "cafQShortenedLabel.h" #include "cafFactory.h" #include "cafTristate.h" diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiColorEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiColorEditor.cpp index da19e6d17a..f8adaf40b0 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiColorEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiColorEditor.cpp @@ -41,8 +41,6 @@ #include "cafPdmField.h" #include "cafPdmObject.h" #include "cafPdmUiFieldEditorHandle.h" -#include "cafPdmUiOrdering.h" -#include "cafQShortenedLabel.h" #include "cafFactory.h" diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiComboBoxEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiComboBoxEditor.cpp index e0a9db744b..428674510e 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiComboBoxEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiComboBoxEditor.cpp @@ -40,7 +40,6 @@ #include "cafPdmField.h" #include "cafPdmObject.h" #include "cafPdmUiFieldEditorHandle.h" -#include "cafQShortenedLabel.h" #include "cafUiAppearanceSettings.h" #include "cafUiIconFactory.h" diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiDateEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiDateEditor.cpp index 50f0e32ba8..8d1a1d4c2b 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiDateEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiDateEditor.cpp @@ -41,8 +41,6 @@ #include "cafPdmObject.h" #include "cafPdmUiDefaultObjectEditor.h" #include "cafPdmUiFieldEditorHandle.h" -#include "cafPdmUiOrdering.h" -#include "cafQShortenedLabel.h" #include "cafSelectionManager.h" #include diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleSliderEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleSliderEditor.cpp index d5edbf88c8..78573a8605 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleSliderEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleSliderEditor.cpp @@ -39,7 +39,6 @@ #include "cafPdmField.h" #include "cafPdmUiFieldHandle.h" #include "cafPdmUiObjectHandle.h" -#include "cafQShortenedLabel.h" #include #include diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleValueEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleValueEditor.cpp index 0d44160155..cf0607a388 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleValueEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleValueEditor.cpp @@ -42,7 +42,6 @@ #include "cafPdmUiFieldEditorHandle.h" #include "cafFactory.h" -#include "cafQShortenedLabel.h" #include #include diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiFilePathEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiFilePathEditor.cpp index 07ab2c0be1..b2acbd40dc 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiFilePathEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiFilePathEditor.cpp @@ -42,9 +42,8 @@ #include "cafPdmUiDefaultObjectEditor.h" #include "cafPdmUiFieldEditorHandle.h" #include "cafPdmUiLineEditor.h" -#include "cafPdmUiOrdering.h" -#include "cafQShortenedLabel.h" +#include #include #include #include diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiFormLayoutObjectEditor.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiFormLayoutObjectEditor.h index 054ca7b941..4c49a76172 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiFormLayoutObjectEditor.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiFormLayoutObjectEditor.h @@ -36,7 +36,6 @@ #pragma once -#include "cafPdmUiOrdering.h" #include "cafPdmUiWidgetObjectEditorHandle.h" #include diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp index be15ba0e29..15ab06d5b8 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp @@ -41,9 +41,7 @@ #include "cafPdmObject.h" #include "cafPdmUiDefaultObjectEditor.h" #include "cafPdmUiFieldEditorHandle.h" -#include "cafPdmUiOrdering.h" #include "cafPdmUniqueIdValidator.h" -#include "cafQShortenedLabel.h" #include "cafSelectionManager.h" #include "cafUiAppearanceSettings.h" #include "cafUiIconFactory.h" diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp index e77b6d1616..c9bb4147d9 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp @@ -41,9 +41,6 @@ #include "cafPdmUiDefaultObjectEditor.h" #include "cafPdmUiFieldEditorHandle.h" -#include "cafFactory.h" -#include "cafQShortenedLabel.h" - #include #include #include diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiPushButtonEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiPushButtonEditor.cpp index 711d27a328..9667434ab4 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiPushButtonEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiPushButtonEditor.cpp @@ -41,10 +41,8 @@ #include "cafPdmField.h" #include "cafPdmObject.h" #include "cafPdmUiFieldEditorHandle.h" -#include "cafPdmUiOrdering.h" #include "cafFactory.h" -#include "cafQShortenedLabel.h" #include diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiPushButtonEditor.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiPushButtonEditor.h index ae94955b34..269c80a97a 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiPushButtonEditor.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiPushButtonEditor.h @@ -35,12 +35,14 @@ //################################################################################################## #pragma once + #include "cafPdmUiFieldEditorHandle.h" #include #include #include #include + class QHBoxLayout; namespace caf diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiSliderEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiSliderEditor.cpp index d34aaf9a9f..f3140d4518 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiSliderEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiSliderEditor.cpp @@ -42,7 +42,6 @@ #include "cafPdmUiFieldEditorHandle.h" #include "cafFactory.h" -#include "cafQShortenedLabel.h" #include #include diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiSliderEditor.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiSliderEditor.h index 9ff9e53fc4..8f76eb660d 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiSliderEditor.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiSliderEditor.h @@ -35,6 +35,7 @@ //################################################################################################## #pragma once + #include "cafPdmUiFieldEditorHandle.h" #include diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableRowEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableRowEditor.cpp index 7162f75bf6..fe7ec29c91 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableRowEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableRowEditor.cpp @@ -36,9 +36,8 @@ #include "cafPdmUiTableRowEditor.h" -#include "cafPdmField.h" -#include "cafPdmObject.h" -#include "cafPdmUiEditorHandle.h" +#include "cafPdmUiObjectHandle.h" +#include "cafPdmUiOrdering.h" #include "cafPdmUiTableViewQModel.h" namespace caf diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.cpp index 797c32f473..55adc2893c 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.cpp @@ -42,7 +42,6 @@ #include "cafPdmUiEditorHandle.h" #include "cafPdmUiTableViewDelegate.h" #include "cafPdmUiTableViewQModel.h" -#include "cafQShortenedLabel.h" #include "cafSelectionManager.h" #include diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.h index 324ed59799..b95cab8712 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.h @@ -36,11 +36,11 @@ #pragma once -#include "cafPdmDocument.h" #include "cafPdmUiFieldEditorHandle.h" #include "cafSelectionChangedReceiver.h" #include +#include #include #include #include diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewQModel.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewQModel.cpp index 4add98a298..0814e67c08 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewQModel.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewQModel.cpp @@ -37,18 +37,13 @@ #include "cafPdmUiTableViewQModel.h" #include "cafPdmChildArrayField.h" -#include "cafPdmField.h" -#include "cafPdmObject.h" -#include "cafPdmUiComboBoxEditor.h" #include "cafPdmUiCommandSystemProxy.h" #include "cafPdmUiDateEditor.h" #include "cafPdmUiFieldEditorHelper.h" #include "cafPdmUiLineEditor.h" +#include "cafPdmUiObjectHandle.h" +#include "cafPdmUiOrdering.h" #include "cafPdmUiTableRowEditor.h" -#include "cafPdmUiTableView.h" -#include "cafSelectionManager.h" - -#include namespace caf { diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTextEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTextEditor.cpp index adeea776c1..d87f427d1a 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTextEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTextEditor.cpp @@ -40,8 +40,6 @@ #include "cafPdmObject.h" #include "cafPdmUiDefaultObjectEditor.h" #include "cafPdmUiFieldEditorHandle.h" -#include "cafPdmUiOrdering.h" -#include "cafQShortenedLabel.h" #include #include diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTextEditor.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiTextEditor.h index eaccdd07a2..e68caf2526 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTextEditor.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTextEditor.h @@ -35,7 +35,9 @@ //################################################################################################## #pragma once + #include "cafPdmUiFieldEditorHandle.h" + #include #include #include diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTimeEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTimeEditor.cpp index c5a1ad4fcd..6b68545df1 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTimeEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTimeEditor.cpp @@ -41,8 +41,6 @@ #include "cafPdmObject.h" #include "cafPdmUiDefaultObjectEditor.h" #include "cafPdmUiFieldEditorHandle.h" -#include "cafPdmUiOrdering.h" -#include "cafQShortenedLabel.h" #include "cafSelectionManager.h" #include diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTimeEditor.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiTimeEditor.h index 109057a4b8..41f9a6b18a 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTimeEditor.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTimeEditor.h @@ -38,7 +38,6 @@ #include "cafPdmUiFieldEditorHandle.h" -#include #include #include #include diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiToolBarEditor.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiToolBarEditor.h index be53429233..9bc187bfdd 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiToolBarEditor.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiToolBarEditor.h @@ -45,6 +45,7 @@ class QToolBar; class QMainWindow; +class QAction; namespace caf { diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeAttributes.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeAttributes.cpp index 06172c8a57..56fc50f440 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeAttributes.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeAttributes.cpp @@ -47,12 +47,36 @@ std::unique_ptr caf::PdmUiTreeViewItemAttr //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void caf::PdmUiTreeViewItemAttribute::createTagIfTreeViewItemAttribute( caf::PdmUiEditorAttribute* attribute, +std::unique_ptr + caf::PdmUiTreeViewItemAttribute::createTag( const QColor& color, const QColor& backgroundColor, const QString& text ) +{ + auto tag = createTag(); + + auto weight1 = 100; + double transparency = 0.3; + int weight2 = std::max( 1, static_cast( weight1 * 10 * transparency ) ); + + int weightsum = weight1 + weight2; + + auto blendedColor = QColor( ( color.red() * weight1 + backgroundColor.red() * weight2 ) / weightsum, + ( color.green() * weight1 + backgroundColor.green() * weight2 ) / weightsum, + ( color.blue() * weight1 + backgroundColor.blue() * weight2 ) / weightsum ); + + tag->bgColor = blendedColor; + tag->fgColor = color; + tag->text = text; + + return tag; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void caf::PdmUiTreeViewItemAttribute::appendTagToTreeViewItemAttribute( 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 ); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeAttributes.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeAttributes.h index c138db8a2f..b5e6442be1 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeAttributes.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeAttributes.h @@ -76,7 +76,8 @@ class PdmUiTreeViewItemAttribute : public PdmUiEditorAttribute }; static std::unique_ptr createTag(); - static void createTagIfTreeViewItemAttribute( caf::PdmUiEditorAttribute* attribute, const QString& iconString ); + static std::unique_ptr createTag( const QColor& color, const QColor& backgroundColor, const QString& text ); + static void appendTagToTreeViewItemAttribute( caf::PdmUiEditorAttribute* attribute, const QString& iconString ); std::vector> tags; }; diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp index 1035f8d393..8f64b77103 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp @@ -39,7 +39,6 @@ #include "cafPdmObject.h" #include "cafPdmUiCommandSystemProxy.h" #include "cafPdmUiTreeSelectionQModel.h" -#include "cafQShortenedLabel.h" #include #include diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.cpp index 3c036fcef3..1701b29442 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.cpp @@ -49,6 +49,7 @@ #include "cafPdmUiTreeViewQModel.h" #include "cafSelectionManager.h" +#include #include #include #include diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewItemDelegate.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewItemDelegate.cpp index c0b4fa5d7a..0f093e01ae 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewItemDelegate.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewItemDelegate.cpp @@ -49,6 +49,7 @@ #include "cafPdmUiTreeViewQModel.h" #include "cafSelectionManager.h" +#include #include #include #include diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewQModel.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewQModel.cpp index ec28ec433a..8f2e093828 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewQModel.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewQModel.cpp @@ -36,10 +36,11 @@ #include "cafPdmUiTreeViewQModel.h" -#include "cafPdmField.h" -#include "cafPdmObject.h" +#include "cafPdmReferenceHelper.h" #include "cafPdmUiCommandSystemProxy.h" #include "cafPdmUiDragDropInterface.h" +#include "cafPdmUiFieldHandle.h" +#include "cafPdmUiObjectHandle.h" #include "cafPdmUiTreeItemEditor.h" #include "cafPdmUiTreeOrdering.h" #include "cafPdmUiTreeViewEditor.h" diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiValueRangeEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiValueRangeEditor.cpp index ecdfd99f75..8c86f63aad 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiValueRangeEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiValueRangeEditor.cpp @@ -41,8 +41,6 @@ #include "cafPdmUiDefaultObjectEditor.h" #include "cafPdmUiFieldEditorHandle.h" #include "cafPdmUiLineEditor.h" -#include "cafPdmUiOrdering.h" -#include "cafQShortenedLabel.h" #include #include diff --git a/Fwk/AppFwk/cafViewer/CMakeLists.txt b/Fwk/AppFwk/cafViewer/CMakeLists.txt index 3563c7b006..33411039bf 100644 --- a/Fwk/AppFwk/cafViewer/CMakeLists.txt +++ b/Fwk/AppFwk/cafViewer/CMakeLists.txt @@ -11,13 +11,23 @@ endif() # These headers need to go through Qt's MOC compiler set(MOC_HEADER_FILES cafViewer.h) -find_package( - Qt5 - COMPONENTS - REQUIRED Core Gui Widgets OpenGL -) -set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::Widgets Qt5::OpenGL) -qt5_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES}) +if(CEE_USE_QT6) + find_package( + Qt6 + COMPONENTS + REQUIRED Core Gui Widgets OpenGL + ) + set(QT_LIBRARIES Qt6::Core Qt6::Gui Qt6::Widgets Qt6::OpenGL) + qt_standard_project_setup() +else() + find_package( + Qt5 + COMPONENTS + REQUIRED Core Gui Widgets OpenGL + ) + set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::Widgets Qt5::OpenGL) + qt5_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES}) +endif() add_library( ${PROJECT_NAME} diff --git a/Fwk/AppFwk/cafViewer/cafCadNavigation.cpp b/Fwk/AppFwk/cafViewer/cafCadNavigation.cpp index 483e9fd5ec..416e13ea97 100644 --- a/Fwk/AppFwk/cafViewer/cafCadNavigation.cpp +++ b/Fwk/AppFwk/cafViewer/cafCadNavigation.cpp @@ -144,16 +144,22 @@ bool caf::CadNavigation::handleInputEvent( QInputEvent* inputEvent ) { QWheelEvent* we = static_cast( inputEvent ); - updatePointOfInterestDuringZoomIfNecessary( we->x(), we->y() ); +#if ( QT_VERSION < QT_VERSION_CHECK( 5, 15, 0 ) ) + QPoint cursorPosition = we->pos(); +#else + QPoint cursorPosition = we->position().toPoint(); +#endif + + updatePointOfInterestDuringZoomIfNecessary( cursorPosition.x(), cursorPosition.y() ); if ( m_isRotCenterInitialized ) { int translatedMousePosX, translatedMousePosY; - cvfEventPos( we->x(), we->y(), &translatedMousePosX, &translatedMousePosY ); + cvfEventPos( cursorPosition.x(), cursorPosition.y(), &translatedMousePosX, &translatedMousePosY ); cvf::ref ray = createZoomRay( translatedMousePosX, translatedMousePosY ); - zoomAlongRay( ray.p(), -we->delta() ); + zoomAlongRay( ray.p(), -we->angleDelta().y() ); } isEventHandled = true; } diff --git a/Fwk/AppFwk/cafViewer/cafCeetronNavigation.cpp b/Fwk/AppFwk/cafViewer/cafCeetronNavigation.cpp index bdd52b41be..e511934184 100644 --- a/Fwk/AppFwk/cafViewer/cafCeetronNavigation.cpp +++ b/Fwk/AppFwk/cafViewer/cafCeetronNavigation.cpp @@ -200,13 +200,18 @@ void caf::CeetronNavigation::wheelEvent( QWheelEvent* event ) if ( vpHeight <= 0 ) return; int navDelta = vpHeight / 5; - if ( event->delta() < 0 ) navDelta *= -1; + if ( event->angleDelta().y() < 0 ) navDelta *= -1; - int posY = m_viewer->height() - event->y(); +#if ( QT_VERSION < QT_VERSION_CHECK( 5, 15, 0 ) ) + QPoint cursorPosition = event->pos(); +#else + QPoint cursorPosition = event->position().toPoint(); +#endif + int posY = m_viewer->height() - cursorPosition.y(); - m_trackball->startNavigation( ManipulatorTrackball::WALK, event->x(), posY ); + m_trackball->startNavigation( ManipulatorTrackball::WALK, cursorPosition.x(), posY ); - m_trackball->updateNavigation( event->x(), posY + navDelta ); + m_trackball->updateNavigation( cursorPosition.x(), posY + navDelta ); m_trackball->endNavigation(); m_viewer->updateParallelProjectionHeightFromMoveZoom( m_pointOfInterest ); diff --git a/Fwk/AppFwk/cafViewer/cafCeetronPlusNavigation.cpp b/Fwk/AppFwk/cafViewer/cafCeetronPlusNavigation.cpp index e6df70a6d0..b55c1f72de 100644 --- a/Fwk/AppFwk/cafViewer/cafCeetronPlusNavigation.cpp +++ b/Fwk/AppFwk/cafViewer/cafCeetronPlusNavigation.cpp @@ -185,16 +185,22 @@ bool caf::CeetronPlusNavigation::handleInputEvent( QInputEvent* inputEvent ) { QWheelEvent* we = static_cast( inputEvent ); - updatePointOfInterestDuringZoomIfNecessary( we->x(), we->y() ); +#if ( QT_VERSION < QT_VERSION_CHECK( 5, 15, 0 ) ) + QPoint cursorPosition = we->pos(); +#else + QPoint cursorPosition = we->position().toPoint(); +#endif + + updatePointOfInterestDuringZoomIfNecessary( cursorPosition.x(), cursorPosition.y() ); if ( m_isRotCenterInitialized ) { int translatedMousePosX, translatedMousePosY; - cvfEventPos( we->x(), we->y(), &translatedMousePosX, &translatedMousePosY ); + cvfEventPos( cursorPosition.x(), cursorPosition.y(), &translatedMousePosX, &translatedMousePosY ); cvf::ref ray = createZoomRay( translatedMousePosX, translatedMousePosY ); - zoomAlongRay( ray.p(), we->delta() ); + zoomAlongRay( ray.p(), we->angleDelta().y() ); } isEventHandled = true; } diff --git a/Fwk/AppFwk/cafVizExtensions/CMakeLists.txt b/Fwk/AppFwk/cafVizExtensions/CMakeLists.txt index 464207036f..bc552e2022 100644 --- a/Fwk/AppFwk/cafVizExtensions/CMakeLists.txt +++ b/Fwk/AppFwk/cafVizExtensions/CMakeLists.txt @@ -10,13 +10,26 @@ endif() find_package(OpenGL) # Qt -find_package( - Qt5 - COMPONENTS - REQUIRED Core Gui Widgets OpenGL -) -set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::Widgets Qt5::OpenGL) -qt5_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES}) +if(CEE_USE_QT6) + find_package( + Qt6 + COMPONENTS + REQUIRED Core Gui Widgets OpenGL + ) + set(QT_LIBRARIES Qt6::Core Qt6::Gui Qt6::Widgets Qt6::OpenGL) + qt_standard_project_setup() + set_property( + SOURCE cafTransparentWBRenderConfiguration.cpp PROPERTY SKIP_AUTOMOC ON + ) +else() + find_package( + Qt5 + COMPONENTS + REQUIRED Core Gui Widgets OpenGL + ) + set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::Widgets Qt5::OpenGL) + qt5_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES}) +endif() add_library( ${PROJECT_NAME} diff --git a/Fwk/AppFwk/cafVizExtensions/cafLine.h b/Fwk/AppFwk/cafVizExtensions/cafLine.h index 2c549a2361..272c0548e5 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafLine.h +++ b/Fwk/AppFwk/cafVizExtensions/cafLine.h @@ -56,6 +56,8 @@ class Line Line findLineBetweenNearestPoints( const Line& otherLine, bool* withinLineSegments = nullptr ); + cvf::Vector3 closestPointOnLine( const cvf::Vector3& point ) const; + private: cvf::Vector3 m_start; cvf::Vector3 m_end; diff --git a/Fwk/AppFwk/cafVizExtensions/cafLine.inl b/Fwk/AppFwk/cafVizExtensions/cafLine.inl index a0795abc07..02c110d431 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafLine.inl +++ b/Fwk/AppFwk/cafVizExtensions/cafLine.inl @@ -105,3 +105,27 @@ caf::Line caf::Line::findLineBetweenNearestPoints( const Line& otherLine, } return Line( start() + s * d1, otherLine.start() + t * d2 ); } + +//-------------------------------------------------------------------------------------------------- +/// Returns the closest point on the line segment to the given point +/// From https://paulbourke.net/geometry/pointlineplane/ +//-------------------------------------------------------------------------------------------------- +template +cvf::Vector3 caf::Line::closestPointOnLine( const cvf::Vector3& point ) const +{ + S distance = vector().length(); + + const double u = ( ( ( point.x() - start().x() ) * ( end().x() - start().x() ) ) + + ( ( point.y() - start().y() ) * ( end().y() - start().y() ) ) + + ( ( point.z() - start().z() ) * ( end().z() - start().z() ) ) ) / + ( distance * distance ); + + if ( u < 0.0 ) return start(); + if ( u > 1.0 ) return end(); + + cvf::Vector3 projectedPoint( ( start().x() + u * ( end().x() - start().x() ) ), + ( start().y() + u * ( end().y() - start().y() ) ), + ( start().z() + u * ( end().z() - start().z() ) ) ); + + return projectedPoint; +} diff --git a/Fwk/CMakeLists.txt b/Fwk/CMakeLists.txt index ebc03e7082..14cf32a91e 100644 --- a/Fwk/CMakeLists.txt +++ b/Fwk/CMakeLists.txt @@ -32,9 +32,22 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNO_DEBUG") endif() - -find_package(Qt5 COMPONENTS REQUIRED Core Gui OpenGL Widgets) -set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::OpenGL Qt5::Widgets) +if(CEE_USE_QT6) + find_package( + Qt6 + COMPONENTS + REQUIRED Core Gui OpenGL Widgets + ) + set(QT_LIBRARIES Qt6::Core Qt6::Gui Qt6::OpenGL Qt6::Widgets) + qt_standard_project_setup() +else() + find_package( + Qt5 + COMPONENTS + REQUIRED Core Gui OpenGL Widgets + ) + set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::OpenGL Qt5::Widgets) +endif() # Libraries add_subdirectory(AppFwk/cafProjectDataModel/cafPdmCore) diff --git a/GrpcInterface/RiaGrpcApplicationInterface.cpp b/GrpcInterface/RiaGrpcApplicationInterface.cpp index 410ec00ffb..70f97ecc3a 100644 --- a/GrpcInterface/RiaGrpcApplicationInterface.cpp +++ b/GrpcInterface/RiaGrpcApplicationInterface.cpp @@ -21,6 +21,7 @@ #include "cvfProgramOptions.h" +#include #include //-------------------------------------------------------------------------------------------------- diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index bd82396262..8c73cef38e 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 ".22") +set(RESINSIGHT_DEV_VERSION ".24") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f")