diff --git a/.github/workflows/ResInsightWithCache.yml b/.github/workflows/ResInsightWithCache.yml index 63e4c4586c..6c7baa128e 100644 --- a/.github/workflows/ResInsightWithCache.yml +++ b/.github/workflows/ResInsightWithCache.yml @@ -50,16 +50,6 @@ jobs: build-python-module: true, execute-unit-tests: true, } - - { - name: "Mac OS", - os: macos-latest, - cc: "clang", - cxx: "clang++", - vcpkg-response-file: vcpkg_x64-osx.txt, - vcpkg-triplet: x64-osx, - build-python-module: false, - execute-unit-tests: false, - } steps: - name: Checkout uses: actions/checkout@v2 diff --git a/ApplicationExeCode/CMakeLists.txt b/ApplicationExeCode/CMakeLists.txt index 3e57febf37..443e6c5b40 100644 --- a/ApplicationExeCode/CMakeLists.txt +++ b/ApplicationExeCode/CMakeLists.txt @@ -21,15 +21,11 @@ endif() # Open GL find_package(OpenGL) -find_package( - Qt5 - COMPONENTS Core - QUIET -) +find_package(Qt5 ${RI_QT_MINIMUM_VERSION} COMPONENTS Core) if(Qt5Core_FOUND) find_package( - Qt5 + Qt5 ${RI_QT_MINIMUM_VERSION} COMPONENTS Core Gui OpenGL @@ -68,9 +64,9 @@ endif() # Defining all the source (and header) files # ############################################################################## -set(CODE_HEADER_FILES) +set(CODE_HEADER_FILES RiaMainTools.h) -set(CODE_SOURCE_FILES RiaMain.cpp) +set(CODE_SOURCE_FILES RiaMain.cpp RiaMainTools.cpp) if(RESINSIGHT_ENABLE_GRPC) list(APPEND CODE_HEAD_FILES RiaGrpcConsoleApplication.h @@ -210,12 +206,6 @@ if(MSVC) set(BUILD_FLAGS_FOR_MSVC "/wd4190 /wd4100 /wd4127 /wd4245 /wd4005") - if(Qt5Core_VERSION_STRING GREATER_EQUAL 5.10) - # Disable warning for deprecated functions in newer versions of Qt - # https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4996?view=msvc-160 - set(BUILD_FLAGS_FOR_MSVC "${BUILD_FLAGS_FOR_MSVC} /wd4996") - endif() - if(CMAKE_CXX_COMPILER_VERSION LESS_EQUAL 19.14) # The following warning is generated over 800 times from a qwt header only # using VS2015 Disabling temporarily warning C4505 'function' : unreferenced diff --git a/ApplicationExeCode/Resources/AppendNext.png b/ApplicationExeCode/Resources/AppendNext.png new file mode 100644 index 0000000000..1073b89a23 Binary files /dev/null and b/ApplicationExeCode/Resources/AppendNext.png differ diff --git a/ApplicationExeCode/Resources/AppendNext.svg b/ApplicationExeCode/Resources/AppendNext.svg new file mode 100644 index 0000000000..4a3bf78a69 --- /dev/null +++ b/ApplicationExeCode/Resources/AppendNext.svg @@ -0,0 +1,74 @@ + + + +First Aid + + + diff --git a/ApplicationExeCode/Resources/AppendNextCurve.png b/ApplicationExeCode/Resources/AppendNextCurve.png new file mode 100644 index 0000000000..46ca68fa25 Binary files /dev/null and b/ApplicationExeCode/Resources/AppendNextCurve.png differ diff --git a/ApplicationExeCode/Resources/AppendNextCurve.svg b/ApplicationExeCode/Resources/AppendNextCurve.svg new file mode 100644 index 0000000000..b29ed3db85 --- /dev/null +++ b/ApplicationExeCode/Resources/AppendNextCurve.svg @@ -0,0 +1,70 @@ + + + +First Aid + + + diff --git a/ApplicationExeCode/Resources/AppendPrev.png b/ApplicationExeCode/Resources/AppendPrev.png new file mode 100644 index 0000000000..33d26afaf1 Binary files /dev/null and b/ApplicationExeCode/Resources/AppendPrev.png differ diff --git a/ApplicationExeCode/Resources/AppendPrev.svg b/ApplicationExeCode/Resources/AppendPrev.svg new file mode 100644 index 0000000000..2aa05757cd --- /dev/null +++ b/ApplicationExeCode/Resources/AppendPrev.svg @@ -0,0 +1,63 @@ + + + +First Aid + + + diff --git a/ApplicationExeCode/Resources/AppendPrevCurve.png b/ApplicationExeCode/Resources/AppendPrevCurve.png new file mode 100644 index 0000000000..ebbac2239c Binary files /dev/null and b/ApplicationExeCode/Resources/AppendPrevCurve.png differ diff --git a/ApplicationExeCode/Resources/AppendPrevCurve.svg b/ApplicationExeCode/Resources/AppendPrevCurve.svg new file mode 100644 index 0000000000..4c864605c9 --- /dev/null +++ b/ApplicationExeCode/Resources/AppendPrevCurve.svg @@ -0,0 +1,69 @@ + + + +First Aid + + + diff --git a/ApplicationExeCode/Resources/AxesSync16x16.png b/ApplicationExeCode/Resources/AxesSync16x16.png new file mode 100644 index 0000000000..3d6480f791 Binary files /dev/null and b/ApplicationExeCode/Resources/AxesSync16x16.png differ diff --git a/ApplicationExeCode/Resources/CheckOverlay16x16.png b/ApplicationExeCode/Resources/CheckOverlay16x16.png new file mode 100644 index 0000000000..23979cd107 Binary files /dev/null and b/ApplicationExeCode/Resources/CheckOverlay16x16.png differ diff --git a/ApplicationExeCode/Resources/DataVector.png b/ApplicationExeCode/Resources/DataVector.png new file mode 100644 index 0000000000..17778a1002 Binary files /dev/null and b/ApplicationExeCode/Resources/DataVector.png differ diff --git a/ApplicationExeCode/Resources/DisableZoom.png b/ApplicationExeCode/Resources/DisableZoom.png new file mode 100644 index 0000000000..5f14b04504 Binary files /dev/null and b/ApplicationExeCode/Resources/DisableZoom.png differ diff --git a/ApplicationExeCode/Resources/DisableZoom.svg b/ApplicationExeCode/Resources/DisableZoom.svg new file mode 100644 index 0000000000..1afcab49eb --- /dev/null +++ b/ApplicationExeCode/Resources/DisableZoom.svg @@ -0,0 +1,70 @@ + + + + + No Entry + + + + + + + + diff --git a/ApplicationExeCode/Resources/ResInsight.qrc b/ApplicationExeCode/Resources/ResInsight.qrc index 36cf73cb3c..f0ce42be12 100644 --- a/ApplicationExeCode/Resources/ResInsight.qrc +++ b/ApplicationExeCode/Resources/ResInsight.qrc @@ -13,6 +13,7 @@ AnalysisPlotFilter16x16.png AppLogo48x48.png Axes16x16.png + AxesSync16x16.png BottomAxis16x16.png Bullet.png CascadeWindows.svg @@ -145,6 +146,7 @@ SummaryPlots16x16.png SummaryPlotsLight16x16.png SummaryTemplate16x16.png + SummaryEnsembleTemplate16x16.png SummaryXPlotLight16x16.png SummaryXPlotsLight16x16.png Swap.png @@ -240,6 +242,33 @@ ComboBoxDown.svg ComboBoxUp.svg WellIntAnalysis.png + DataVector.png + data-sources.svg + edit.svg + graph.svg + messages.svg + multiplot.svg + plot-manager.svg + plots.svg + property-editor.svg + scripts.svg + standard.svg + summary-plot.svg + undo-stack.svg + view.svg + view-snapshots.svg + well-log-plot.svg + window-management.svg + DisableZoom.png + AppendNext.svg + AppendPrev.svg + AppendNext.png + AppendPrev.png + AppendNextCurve.svg + AppendPrevCurve.svg + AppendNextCurve.png + AppendPrevCurve.png + CheckOverlay16x16.png fs_CellFace.glsl diff --git a/ApplicationExeCode/Resources/SummaryEnsembleTemplate16x16.png b/ApplicationExeCode/Resources/SummaryEnsembleTemplate16x16.png new file mode 100644 index 0000000000..cac7f2e6bb Binary files /dev/null and b/ApplicationExeCode/Resources/SummaryEnsembleTemplate16x16.png differ diff --git a/ApplicationExeCode/Resources/ZoomAll.svg b/ApplicationExeCode/Resources/ZoomAll.svg index 306d8cb4e7..5aa7e97096 100644 --- a/ApplicationExeCode/Resources/ZoomAll.svg +++ b/ApplicationExeCode/Resources/ZoomAll.svg @@ -1,5 +1,53 @@ - - - - - \ No newline at end of file + + + + + + + + + diff --git a/ApplicationExeCode/Resources/data-sources.svg b/ApplicationExeCode/Resources/data-sources.svg new file mode 100644 index 0000000000..19a6b13dbc --- /dev/null +++ b/ApplicationExeCode/Resources/data-sources.svg @@ -0,0 +1,3 @@ + + + diff --git a/ApplicationExeCode/Resources/edit.svg b/ApplicationExeCode/Resources/edit.svg new file mode 100644 index 0000000000..08f6b38e54 --- /dev/null +++ b/ApplicationExeCode/Resources/edit.svg @@ -0,0 +1,3 @@ + + + diff --git a/ApplicationExeCode/Resources/graph.svg b/ApplicationExeCode/Resources/graph.svg new file mode 100644 index 0000000000..40a5c774f6 --- /dev/null +++ b/ApplicationExeCode/Resources/graph.svg @@ -0,0 +1,3 @@ + + + diff --git a/ApplicationExeCode/Resources/messages.svg b/ApplicationExeCode/Resources/messages.svg new file mode 100644 index 0000000000..1d3be011f8 --- /dev/null +++ b/ApplicationExeCode/Resources/messages.svg @@ -0,0 +1,3 @@ + + + diff --git a/ApplicationExeCode/Resources/multiplot.svg b/ApplicationExeCode/Resources/multiplot.svg new file mode 100644 index 0000000000..b4fb3c0af0 --- /dev/null +++ b/ApplicationExeCode/Resources/multiplot.svg @@ -0,0 +1,12 @@ + + + + + + + + + diff --git a/ApplicationExeCode/Resources/plot-manager.svg b/ApplicationExeCode/Resources/plot-manager.svg new file mode 100644 index 0000000000..1f5e31274e --- /dev/null +++ b/ApplicationExeCode/Resources/plot-manager.svg @@ -0,0 +1,3 @@ + + + diff --git a/ApplicationExeCode/Resources/plots.svg b/ApplicationExeCode/Resources/plots.svg new file mode 100644 index 0000000000..40a5c774f6 --- /dev/null +++ b/ApplicationExeCode/Resources/plots.svg @@ -0,0 +1,3 @@ + + + diff --git a/ApplicationExeCode/Resources/property-editor.svg b/ApplicationExeCode/Resources/property-editor.svg new file mode 100644 index 0000000000..a9b9ee76b0 --- /dev/null +++ b/ApplicationExeCode/Resources/property-editor.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/ApplicationExeCode/Resources/scripts.svg b/ApplicationExeCode/Resources/scripts.svg new file mode 100644 index 0000000000..5f29574b2d --- /dev/null +++ b/ApplicationExeCode/Resources/scripts.svg @@ -0,0 +1,3 @@ + + + diff --git a/ApplicationExeCode/Resources/standard.svg b/ApplicationExeCode/Resources/standard.svg new file mode 100644 index 0000000000..bc321cdffa --- /dev/null +++ b/ApplicationExeCode/Resources/standard.svg @@ -0,0 +1,3 @@ + + + diff --git a/ApplicationExeCode/Resources/summary-plot.svg b/ApplicationExeCode/Resources/summary-plot.svg new file mode 100644 index 0000000000..5b1a8abbb8 --- /dev/null +++ b/ApplicationExeCode/Resources/summary-plot.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + diff --git a/ApplicationExeCode/Resources/themes/default.qss b/ApplicationExeCode/Resources/themes/default.qss index 0304d4cc46..45893da97c 100644 --- a/ApplicationExeCode/Resources/themes/default.qss +++ b/ApplicationExeCode/Resources/themes/default.qss @@ -84,6 +84,10 @@ QwtPlot["PvtPlot"]::lineMarker["*"] { color: $textColor; } +QLabel, RiuQwtPlotLegend { + background-color: transparent; +} + QwtPlot["PvtPlot"]::pointMarker["*"] { color: $textColor; } diff --git a/ApplicationExeCode/Resources/undo-stack.svg b/ApplicationExeCode/Resources/undo-stack.svg new file mode 100644 index 0000000000..eabdd7e0c5 --- /dev/null +++ b/ApplicationExeCode/Resources/undo-stack.svg @@ -0,0 +1,3 @@ + + + diff --git a/ApplicationExeCode/Resources/view-snapshots.svg b/ApplicationExeCode/Resources/view-snapshots.svg new file mode 100644 index 0000000000..c5343b4117 --- /dev/null +++ b/ApplicationExeCode/Resources/view-snapshots.svg @@ -0,0 +1,3 @@ + + + diff --git a/ApplicationExeCode/Resources/view.svg b/ApplicationExeCode/Resources/view.svg new file mode 100644 index 0000000000..390221b8da --- /dev/null +++ b/ApplicationExeCode/Resources/view.svg @@ -0,0 +1,3 @@ + + + diff --git a/ApplicationExeCode/Resources/well-log-plot.svg b/ApplicationExeCode/Resources/well-log-plot.svg new file mode 100644 index 0000000000..9df12a42ec --- /dev/null +++ b/ApplicationExeCode/Resources/well-log-plot.svg @@ -0,0 +1,12 @@ + + + + + + + diff --git a/ApplicationExeCode/Resources/window-management.svg b/ApplicationExeCode/Resources/window-management.svg new file mode 100644 index 0000000000..829ba31e38 --- /dev/null +++ b/ApplicationExeCode/Resources/window-management.svg @@ -0,0 +1,3 @@ + + + diff --git a/ApplicationExeCode/RiaMain.cpp b/ApplicationExeCode/RiaMain.cpp index 7e158905aa..67fb3b5232 100644 --- a/ApplicationExeCode/RiaMain.cpp +++ b/ApplicationExeCode/RiaMain.cpp @@ -18,6 +18,7 @@ #include "RiaArgumentParser.h" #include "RiaLogging.h" +#include "RiaMainTools.h" #ifdef ENABLE_GRPC #include "RiaGrpcConsoleApplication.h" @@ -26,6 +27,7 @@ #include "RiaConsoleApplication.h" #include "RiaGuiApplication.h" #endif + #include "cvfProgramOptions.h" #include "cvfqtUtils.h" @@ -66,8 +68,12 @@ int main( int argc, char* argv[] ) return 1; } #endif + // Global initialization RiaLogging::loggerInstance()->setLevel( int( RILogLevel::RI_LL_DEBUG ) ); + // Create feature manager before the application object is created + RiaMainTools::initializeSingletons(); + std::unique_ptr app( createApplication( argc, argv ) ); cvf::ProgramOptions progOpt; @@ -112,6 +118,9 @@ int main( int argc, char* argv[] ) // Make sure project is closed to avoid assert and crash in destruction of widgets app->closeProject(); + app.reset(); + RiaMainTools::releaseSingletonAndFactoryObjects(); + return 0; } else if ( status == RiaApplication::ApplicationStatus::EXIT_WITH_ERROR ) @@ -147,6 +156,9 @@ int main( int argc, char* argv[] ) throw; } + app.reset(); + RiaMainTools::releaseSingletonAndFactoryObjects(); + return exitCode; } diff --git a/ApplicationExeCode/RiaMainTools.cpp b/ApplicationExeCode/RiaMainTools.cpp new file mode 100644 index 0000000000..4a2fdcded3 --- /dev/null +++ b/ApplicationExeCode/RiaMainTools.cpp @@ -0,0 +1,61 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiaMainTools.h" +#include "RiaRegressionTestRunner.h" +#include "RiaSocketCommand.h" + +#include "cafCmdFeature.h" +#include "cafCmdFeatureManager.h" +#include "cafPdmDefaultObjectFactory.h" +#include "cafPdmUiFieldEditorHandle.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaMainTools::initializeSingletons() +{ + caf::CmdFeatureManager::createSingleton(); + RiaRegressionTestRunner::createSingleton(); + caf::PdmDefaultObjectFactory::createSingleton(); +} + +//-------------------------------------------------------------------------------------------------- +/// This method is used to release memory allocated by static functions. This enables use of memory allocation tools +/// after the application has closed down. +//-------------------------------------------------------------------------------------------------- +void RiaMainTools::releaseSingletonAndFactoryObjects() +{ + caf::CmdFeatureManager::deleteSingleton(); + RiaRegressionTestRunner::deleteSingleton(); + caf::PdmDefaultObjectFactory::deleteSingleton(); + + { + auto factory = caf::Factory::instance(); + factory->deleteCreatorObjects(); + } + + { + auto factory = caf::Factory::instance(); + factory->deleteCreatorObjects(); + } + { + auto factory = caf::Factory::instance(); + factory->deleteCreatorObjects(); + } +} diff --git a/ApplicationExeCode/RiaMainTools.h b/ApplicationExeCode/RiaMainTools.h new file mode 100644 index 0000000000..025e9bc256 --- /dev/null +++ b/ApplicationExeCode/RiaMainTools.h @@ -0,0 +1,25 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// +#pragma once + +class RiaMainTools +{ +public: + static void initializeSingletons(); + static void releaseSingletonAndFactoryObjects(); +}; diff --git a/ApplicationLibCode/Application/CMakeLists_files.cmake b/ApplicationLibCode/Application/CMakeLists_files.cmake index 57990caa03..6a3a6e2c22 100644 --- a/ApplicationLibCode/Application/CMakeLists_files.cmake +++ b/ApplicationLibCode/Application/CMakeLists_files.cmake @@ -21,9 +21,14 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RiaFeatureCommandContext.h ${CMAKE_CURRENT_LIST_DIR}/RiaStringListSerializer.h ${CMAKE_CURRENT_LIST_DIR}/RiaNncDefines.h + ${CMAKE_CURRENT_LIST_DIR}/RiaPlotDefines.h ${CMAKE_CURRENT_LIST_DIR}/RiaStimPlanModelDefines.h ${CMAKE_CURRENT_LIST_DIR}/RiaResultNames.h ${CMAKE_CURRENT_LIST_DIR}/RiaNumberFormat.h + ${CMAKE_CURRENT_LIST_DIR}/RiaRftDefines.h + ${CMAKE_CURRENT_LIST_DIR}/RiaDateTimeDefines.h + ${CMAKE_CURRENT_LIST_DIR}/RiaPlotCollectionScheduler.h + ${CMAKE_CURRENT_LIST_DIR}/RiaScheduler.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -49,9 +54,14 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RiaFeatureCommandContext.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaStringListSerializer.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaNncDefines.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiaPlotDefines.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaStimPlanModelDefines.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaResultNames.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaNumberFormat.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiaRftDefines.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiaDateTimeDefines.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiaPlotCollectionScheduler.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiaScheduler.cpp ) list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) @@ -63,8 +73,8 @@ set(QT_MOC_HEADERS ${CMAKE_CURRENT_LIST_DIR}/RiaConsoleApplication.h ${CMAKE_CURRENT_LIST_DIR}/RiaGuiApplication.h ${CMAKE_CURRENT_LIST_DIR}/RiaCompletionTypeCalculationScheduler.h - ${CMAKE_CURRENT_LIST_DIR}/RiaViewRedrawScheduler.h ${CMAKE_CURRENT_LIST_DIR}/RiaPlotWindowRedrawScheduler.h + ${CMAKE_CURRENT_LIST_DIR}/RiaScheduler.h ) source_group( diff --git a/ApplicationLibCode/Application/RiaApplication.cpp b/ApplicationLibCode/Application/RiaApplication.cpp index 4063921982..221f6b0da7 100644 --- a/ApplicationLibCode/Application/RiaApplication.cpp +++ b/ApplicationLibCode/Application/RiaApplication.cpp @@ -31,6 +31,7 @@ #include "RiaTextStringTools.h" #include "RiaVersionInfo.h" #include "RiaViewRedrawScheduler.h" +#include "RiaWellNameComparer.h" #include "ExportCommands/RicSnapshotAllViewsToFileFeature.h" #include "HoloLensCommands/RicHoloLensSessionManager.h" @@ -39,6 +40,7 @@ #include "RicfCommandObject.h" #include "CommandRouter/RimCommandRouter.h" +#include "PlotTemplates/RimPlotTemplateFolderItem.h" #include "Rim2dIntersectionViewCollection.h" #include "RimAnnotationCollection.h" #include "RimAnnotationInViewCollection.h" @@ -55,6 +57,7 @@ #include "RimGeoMechCellColors.h" #include "RimGeoMechModels.h" #include "RimGeoMechView.h" +#include "RimGridCalculationCollection.h" #include "RimIdenticalGridCaseGroup.h" #include "RimMainPlotCollection.h" #include "RimObservedDataCollection.h" @@ -63,6 +66,7 @@ #include "RimOilField.h" #include "RimPlotWindow.h" #include "RimProject.h" +#include "RimScriptCollection.h" #include "RimSimWellInViewCollection.h" #include "RimStimPlanColors.h" #include "RimStimPlanModel.h" @@ -94,6 +98,7 @@ #include "cafPdmSettings.h" #include "cafPdmUiModelChangeDetector.h" #include "cafProgressInfo.h" +#include "cafSelectionManager.h" #include "cafUiProcess.h" #include "cafUtils.h" @@ -161,6 +166,8 @@ RiaApplication::RiaApplication() RiaApplication::~RiaApplication() { RiaFontCache::clear(); + + caf::SelectionManager::instance()->setPdmRootObject( nullptr ); } //-------------------------------------------------------------------------------------------------- @@ -701,6 +708,14 @@ bool RiaApplication::loadProject( const QString& projectFileName, // Execute command objects, and release the mutex when the queue is empty executeCommandObjects(); + // Recalculate the results from grid property calculations. + // Has to be done late since the results are filtered by view cell visibility + for ( auto gridCalculation : m_project->gridCalculationCollection()->calculations() ) + { + gridCalculation->calculate(); + gridCalculation->updateDependentObjects(); + } + RiaLogging::info( QString( "Completed open of project file : '%1'" ).arg( projectFileName ) ); return true; @@ -782,6 +797,8 @@ void RiaApplication::closeProject() m_project->close(); m_commandQueue.clear(); + RiaWellNameComparer::clearCache(); + onProjectClosed(); caf::PdmUiModelChangeDetector::instance()->reset(); @@ -1209,9 +1226,11 @@ void RiaApplication::applyPreferences() if ( this->project() ) { - this->project()->setScriptDirectories( m_preferences->scriptDirectories() ); + this->project()->setScriptDirectories( m_preferences->scriptDirectories(), m_preferences->maxScriptFoldersDepth() ); this->project()->setPlotTemplateFolders( m_preferences->plotTemplateFolders() ); - this->project()->updateConnectedEditors(); + + project()->scriptCollection()->updateConnectedEditors(); + project()->rootPlotTemplateItem()->updateConnectedEditors(); } caf::ProgressInfoStatic::setEnabled( RiaPreferencesSystem::current()->showProgressBar() ); @@ -1494,8 +1513,10 @@ void RiaApplication::initialize() // Start with a project m_project = std::make_unique(); - m_project->setScriptDirectories( m_preferences->scriptDirectories() ); + m_project->setScriptDirectories( m_preferences->scriptDirectories(), m_preferences->maxScriptFoldersDepth() ); m_project->setPlotTemplateFolders( m_preferences->plotTemplateFolders() ); + + caf::SelectionManager::instance()->setPdmRootObject( project() ); } //-------------------------------------------------------------------------------------------------- @@ -1525,7 +1546,9 @@ void RiaApplication::resetProject() m_project.reset(); m_preferences.reset(); - initialize(); + // Call RiaApplication::initialize() to recreate project and preferences. Do not call virtual method initialize(), + // as RiaGuiApplication::initialize() creates a new logger causing console text to disappear. + RiaApplication::initialize(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/RiaCompletionTypeCalculationScheduler.cpp b/ApplicationLibCode/Application/RiaCompletionTypeCalculationScheduler.cpp index 3730f07273..c103de733d 100644 --- a/ApplicationLibCode/Application/RiaCompletionTypeCalculationScheduler.cpp +++ b/ApplicationLibCode/Application/RiaCompletionTypeCalculationScheduler.cpp @@ -56,7 +56,7 @@ RiaCompletionTypeCalculationScheduler* RiaCompletionTypeCalculationScheduler::in void RiaCompletionTypeCalculationScheduler::scheduleRecalculateCompletionTypeAndRedrawAllViews() { std::vector eclipseCases = - RimProject::current()->activeOilField()->analysisModels->cases().childObjects(); + RimProject::current()->activeOilField()->analysisModels->cases().children(); scheduleRecalculateCompletionTypeAndRedrawAllViews( eclipseCases ); } @@ -78,38 +78,50 @@ void RiaCompletionTypeCalculationScheduler::scheduleRecalculateCompletionTypeAnd void RiaCompletionTypeCalculationScheduler::scheduleRecalculateCompletionTypeAndRedrawAllViews( const std::vector& eclipseCases ) { + clearCompletionTypeResults( eclipseCases ); + for ( RimEclipseCase* eclipseCase : eclipseCases ) { - CVF_ASSERT( eclipseCase ); - - if ( eclipseCase->eclipseCaseData() ) - { - eclipseCase->eclipseCaseData() - ->results( RiaDefines::PorosityModelType::MATRIX_MODEL ) - ->clearScalarResult( RiaDefines::ResultCatType::DYNAMIC_NATIVE, - RiaResultNames::completionTypeResultName() ); + if ( eclipseCase ) m_eclipseCasesToRecalculate.emplace_back( eclipseCase ); + } - // Delete virtual perforation transmissibilities, as these are the basis for the computation of completion type - eclipseCase->eclipseCaseData()->setVirtualPerforationTransmissibilities( nullptr ); - } + startTimer( 0 ); +} - m_eclipseCasesToRecalculate.push_back( eclipseCase ); - } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaCompletionTypeCalculationScheduler::clearCompletionTypeResultsInAllCases() +{ + std::vector eclipseCases = + RimProject::current()->activeOilField()->analysisModels->cases().children(); - startTimer(); + clearCompletionTypeResults( eclipseCases ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaCompletionTypeCalculationScheduler::slotRecalculateCompletionType() +void RiaCompletionTypeCalculationScheduler::clearCompletionTypeResults( const std::vector& eclipseCases ) { - if ( caf::ProgressState::isActive() ) + for ( RimEclipseCase* eclipseCase : eclipseCases ) { - startTimer(); - return; + if ( !eclipseCase || !eclipseCase->eclipseCaseData() ) continue; + + eclipseCase->eclipseCaseData() + ->results( RiaDefines::PorosityModelType::MATRIX_MODEL ) + ->clearScalarResult( RiaDefines::ResultCatType::DYNAMIC_NATIVE, RiaResultNames::completionTypeResultName() ); + + // Delete virtual perforation transmissibilities, as these are the basis for the computation of completion type + eclipseCase->eclipseCaseData()->setVirtualPerforationTransmissibilities( nullptr ); } +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaCompletionTypeCalculationScheduler::performScheduledUpdates() +{ std::set uniqueCases( m_eclipseCasesToRecalculate.begin(), m_eclipseCasesToRecalculate.end() ); Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); @@ -149,28 +161,11 @@ void RiaCompletionTypeCalculationScheduler::slotRecalculateCompletionType() //-------------------------------------------------------------------------------------------------- RiaCompletionTypeCalculationScheduler::~RiaCompletionTypeCalculationScheduler() { - delete m_recalculateCompletionTypeTimer; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RiaCompletionTypeCalculationScheduler::RiaCompletionTypeCalculationScheduler() - : m_recalculateCompletionTypeTimer( nullptr ) -{ -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiaCompletionTypeCalculationScheduler::startTimer() { - if ( !m_recalculateCompletionTypeTimer ) - { - m_recalculateCompletionTypeTimer = new QTimer( this ); - m_recalculateCompletionTypeTimer->setSingleShot( true ); - connect( m_recalculateCompletionTypeTimer, SIGNAL( timeout() ), this, SLOT( slotRecalculateCompletionType() ) ); - } - - m_recalculateCompletionTypeTimer->start( 1500 ); } diff --git a/ApplicationLibCode/Application/RiaCompletionTypeCalculationScheduler.h b/ApplicationLibCode/Application/RiaCompletionTypeCalculationScheduler.h index 9ea5fb94c3..1f7ad10416 100644 --- a/ApplicationLibCode/Application/RiaCompletionTypeCalculationScheduler.h +++ b/ApplicationLibCode/Application/RiaCompletionTypeCalculationScheduler.h @@ -18,29 +18,30 @@ #pragma once -#include "cafPdmPointer.h" +#include "RiaScheduler.h" -#include +#include "cafPdmPointer.h" #include -class QTimer; class RimEclipseCase; //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -class RiaCompletionTypeCalculationScheduler : public QObject +class RiaCompletionTypeCalculationScheduler : public RiaScheduler { Q_OBJECT; public: static RiaCompletionTypeCalculationScheduler* instance(); void scheduleRecalculateCompletionTypeAndRedrawAllViews(); + void clearCompletionTypeResultsInAllCases(); + void scheduleRecalculateCompletionTypeAndRedrawAllViews( RimEclipseCase* eclipseCase ); + void clearCompletionTypeResults( const std::vector& eclipseCases ); -private slots: - void slotRecalculateCompletionType(); + void performScheduledUpdates() override; private: RiaCompletionTypeCalculationScheduler(); @@ -51,9 +52,6 @@ private slots: void scheduleRecalculateCompletionTypeAndRedrawAllViews( const std::vector& eclipseCases ); - void startTimer(); - private: std::vector> m_eclipseCasesToRecalculate; - QTimer* m_recalculateCompletionTypeTimer; }; diff --git a/ApplicationLibCode/Application/RiaDateTimeDefines.cpp b/ApplicationLibCode/Application/RiaDateTimeDefines.cpp new file mode 100644 index 0000000000..bbac4778a0 --- /dev/null +++ b/ApplicationLibCode/Application/RiaDateTimeDefines.cpp @@ -0,0 +1,60 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiaDateTimeDefines.h" + +#include "cafAppEnum.h" + +namespace caf +{ +template <> +void caf::AppEnum::setUp() +{ + addItem( RiaDefines::DateFormatComponents::DATE_FORMAT_NONE, "NO_DATE", "No Date" ); + addItem( RiaDefines::DateFormatComponents::DATE_FORMAT_YEAR, "YEAR", "Year Only" ); + addItem( RiaDefines::DateFormatComponents::DATE_FORMAT_YEAR_MONTH, "YEAR_MONTH", "Year and Month" ); + addItem( RiaDefines::DateFormatComponents::DATE_FORMAT_YEAR_MONTH_DAY, "YEAR_MONTH_DAY", "Year, Month and Day" ); + setDefault( RiaDefines::DateFormatComponents::DATE_FORMAT_YEAR_MONTH_DAY ); +} + +template <> +void caf::AppEnum::setUp() +{ + addItem( RiaDefines::TimeFormatComponents::TIME_FORMAT_NONE, "NO_TIME", "No Time of Day" ); + addItem( RiaDefines::TimeFormatComponents::TIME_FORMAT_HOUR, "HOUR", "Hour Only" ); + addItem( RiaDefines::TimeFormatComponents::TIME_FORMAT_HOUR_MINUTE, "HOUR_MINUTE", "Hour and Minute" ); + addItem( RiaDefines::TimeFormatComponents::TIME_FORMAT_HOUR_MINUTE_SECOND, + "HOUR_MINUTE_SECONDS", + "Hour, Minutes and Seconds" ); + setDefault( RiaDefines::TimeFormatComponents::TIME_FORMAT_NONE ); +} + +template <> +void caf::AppEnum::setUp() +{ + addItem( RiaDefines::DateTimePeriod::NONE, "NONE", "None" ); + addItem( RiaDefines::DateTimePeriod::DAY, "DAY", "Day" ); + addItem( RiaDefines::DateTimePeriod::WEEK, "WEEK", "Week" ); + addItem( RiaDefines::DateTimePeriod::MONTH, "MONTH", "Month" ); + addItem( RiaDefines::DateTimePeriod::QUARTER, "QUARTER", "Quarter" ); + addItem( RiaDefines::DateTimePeriod::HALFYEAR, "HALFYEAR", "Half Year" ); + addItem( RiaDefines::DateTimePeriod::YEAR, "YEAR", "Year" ); + addItem( RiaDefines::DateTimePeriod::DECADE, "DECADE", "Decade" ); + setDefault( RiaDefines::DateTimePeriod::NONE ); +} +} // namespace caf diff --git a/ApplicationLibCode/Application/RiaDateTimeDefines.h b/ApplicationLibCode/Application/RiaDateTimeDefines.h new file mode 100644 index 0000000000..dcd235464d --- /dev/null +++ b/ApplicationLibCode/Application/RiaDateTimeDefines.h @@ -0,0 +1,59 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafAppEnum.h" + +namespace RiaDefines +{ +enum class DateFormatComponents +{ + DATE_FORMAT_UNSPECIFIED = -2, + DATE_FORMAT_NONE = -1, + DATE_FORMAT_YEAR = 0, + DATE_FORMAT_YEAR_MONTH, + DATE_FORMAT_YEAR_MONTH_DAY, +}; + +enum class TimeFormatComponents +{ + TIME_FORMAT_UNSPECIFIED = -2, + TIME_FORMAT_NONE = -1, + TIME_FORMAT_HOUR, + TIME_FORMAT_HOUR_MINUTE, + TIME_FORMAT_HOUR_MINUTE_SECOND, + TIME_FORMAT_HOUR_MINUTE_SECOND_MILLISECOND, + TIME_FORMAT_SIZE +}; + +enum class DateTimePeriod +{ + NONE = -1, + DAY, + WEEK, + MONTH, + QUARTER, + HALFYEAR, + YEAR, + DECADE +}; + +using DateTimePeriodEnum = caf::AppEnum; + +}; // namespace RiaDefines diff --git a/ApplicationLibCode/Application/RiaDefines.cpp b/ApplicationLibCode/Application/RiaDefines.cpp index 9df23af602..d9bb911053 100644 --- a/ApplicationLibCode/Application/RiaDefines.cpp +++ b/ApplicationLibCode/Application/RiaDefines.cpp @@ -72,15 +72,6 @@ void caf::AppEnum::setUp() setDefault( RiaDefines::DepthTypeEnum::MEASURED_DEPTH ); } -template <> -void caf::AppEnum::setUp() -{ - addItem( RiaDefines::PlotAxis::PLOT_AXIS_LEFT, "PLOT_AXIS_LEFT", "Left" ); - addItem( RiaDefines::PlotAxis::PLOT_AXIS_RIGHT, "PLOT_AXIS_RIGHT", "Right" ); - - setDefault( RiaDefines::PlotAxis::PLOT_AXIS_LEFT ); -} - template <> void caf::AppEnum::setUp() { @@ -146,6 +137,26 @@ void AppEnum::setUp() setDefault( RiaDefines::RINavigationPolicy::NAVIGATION_POLICY_RMS ); } +template <> +void caf::AppEnum::setUp() +{ + addItem( RiaDefines::ColumnCount::COLUMNS_1, "1", "1 Column" ); + addItem( RiaDefines::ColumnCount::COLUMNS_2, "2", "2 Columns" ); + addItem( RiaDefines::ColumnCount::COLUMNS_3, "3", "3 Columns" ); + addItem( RiaDefines::ColumnCount::COLUMNS_4, "4", "4 Columns" ); + setDefault( RiaDefines::ColumnCount::COLUMNS_2 ); +} + +template <> +void caf::AppEnum::setUp() +{ + addItem( RiaDefines::RowCount::ROWS_1, "1", "1 Row" ); + addItem( RiaDefines::RowCount::ROWS_2, "2", "2 Rows" ); + addItem( RiaDefines::RowCount::ROWS_3, "3", "3 Rows" ); + addItem( RiaDefines::RowCount::ROWS_4, "4", "4 Rows" ); + setDefault( RiaDefines::RowCount::ROWS_2 ); +} + } // namespace caf //-------------------------------------------------------------------------------------------------- @@ -243,30 +254,6 @@ RiaDefines::EclipseUnitSystem RiaDefines::fromDepthUnit( DepthUnitType depthUnit return RiaDefines::EclipseUnitSystem::UNITS_UNKNOWN; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -double RiaDefines::minimumDefaultValuePlot() -{ - return -10.0; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -double RiaDefines::minimumDefaultLogValuePlot() -{ - return 1.0; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -double RiaDefines::maximumDefaultValuePlot() -{ - return 100.0; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -350,3 +337,11 @@ bool RiaDefines::isInjector( WellProductionType wellProductionType ) return false; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaDefines::stringListSeparator() +{ + return "|"; +} diff --git a/ApplicationLibCode/Application/RiaDefines.h b/ApplicationLibCode/Application/RiaDefines.h index 77407d96fa..e52b34965a 100644 --- a/ApplicationLibCode/Application/RiaDefines.h +++ b/ApplicationLibCode/Application/RiaDefines.h @@ -107,18 +107,6 @@ enum class DepthTypeEnum TRUE_VERTICAL_DEPTH_RKB }; -// Defines relate to plotting -enum class PlotAxis -{ - PLOT_AXIS_LEFT, - PLOT_AXIS_RIGHT, - PLOT_AXIS_BOTTOM -}; - -double minimumDefaultValuePlot(); -double minimumDefaultLogValuePlot(); -double maximumDefaultValuePlot(); - enum class PhaseType { OIL_PHASE, @@ -197,4 +185,44 @@ enum class WellProductionType : short bool isInjector( WellProductionType wellProductionType ); +QString stringListSeparator(); + +enum class ColumnCount +{ + COLUMNS_1 = 1, + COLUMNS_2 = 2, + COLUMNS_3 = 3, + COLUMNS_4 = 4, + COLUMNS_UNLIMITED = 1000, +}; + +enum class RowCount +{ + ROWS_1 = 1, + ROWS_2 = 2, + ROWS_3 = 3, + ROWS_4 = 4, +}; + +enum class MultiPlotPageUpdateType : uint32_t +{ + NONE = 0b00000000, + LEGEND = 0b00000001, + PLOT = 0b00000010, + TITLE = 0b00000100, + ALL = 0b00000111 +}; + +constexpr enum MultiPlotPageUpdateType operator|( const enum MultiPlotPageUpdateType selfValue, + const enum MultiPlotPageUpdateType inValue ) +{ + return ( enum MultiPlotPageUpdateType )( uint32_t( selfValue ) | uint32_t( inValue ) ); +} + +constexpr enum MultiPlotPageUpdateType operator&( const enum MultiPlotPageUpdateType selfValue, + const enum MultiPlotPageUpdateType inValue ) +{ + return ( enum MultiPlotPageUpdateType )( uint32_t( selfValue ) & uint32_t( inValue ) ); +} + }; // namespace RiaDefines diff --git a/ApplicationLibCode/Application/RiaGuiApplication.cpp b/ApplicationLibCode/Application/RiaGuiApplication.cpp index 449a2578d3..c492c4d4d3 100644 --- a/ApplicationLibCode/Application/RiaGuiApplication.cpp +++ b/ApplicationLibCode/Application/RiaGuiApplication.cpp @@ -22,6 +22,7 @@ #include "RiaArgumentParser.h" #include "RiaBaseDefs.h" +#include "RiaDefines.h" #include "RiaFilePathTools.h" #include "RiaFontCache.h" #include "RiaImportEclipseCaseTools.h" @@ -78,7 +79,6 @@ #include "RimSummaryCaseMainCollection.h" #include "RimSummaryCrossPlotCollection.h" #include "RimSummaryPlot.h" -#include "RimSummaryPlotCollection.h" #include "RimTextAnnotation.h" #include "RimTextAnnotationInView.h" #include "RimViewLinker.h" @@ -100,6 +100,7 @@ #include "RiuMdiMaximizeWindowGuard.h" #include "RiuMessagePanel.h" #include "RiuPlotMainWindow.h" +#include "RiuPlotMainWindowTools.h" #include "RiuProcessMonitor.h" #include "RiuRecentFileActionProvider.h" #include "RiuViewer.h" @@ -124,6 +125,7 @@ #include #include #include +#include #include #include #include @@ -188,8 +190,7 @@ RiaGuiApplication::RiaGuiApplication( int& argc, char** argv ) //-------------------------------------------------------------------------------------------------- RiaGuiApplication::~RiaGuiApplication() { - deleteMainPlotWindow(); - deleteMainWindow(); + m_mainWindow.clear(); } //-------------------------------------------------------------------------------------------------- @@ -294,39 +295,46 @@ bool RiaGuiApplication::saveProjectAs( const QString& fileName ) //-------------------------------------------------------------------------------------------------- void RiaGuiApplication::storeTreeViewState() { + if ( m_mainWindow ) { - if ( mainPlotWindow() && mainPlotWindow()->projectTreeView() ) - { - caf::PdmUiTreeView* projectTreeView = mainPlotWindow()->projectTreeView(); + QStringList treeStates; + QStringList treeIndexes; + for ( auto& tv : m_mainWindow->projectTreeViews() ) + { QString treeViewState; - caf::QTreeViewStateSerializer::storeTreeViewStateToString( projectTreeView->treeView(), treeViewState ); + tv->storeTreeViewStateToString( treeViewState ); + treeStates.append( treeViewState ); - QModelIndex mi = projectTreeView->treeView()->currentIndex(); - - QString encodedModelIndexString; + QModelIndex mi = tv->treeView()->currentIndex(); + QString encodedModelIndexString; caf::QTreeViewStateSerializer::encodeStringFromModelIndex( mi, encodedModelIndexString ); - - project()->plotWindowTreeViewState = treeViewState; - project()->plotWindowCurrentModelIndexPath = encodedModelIndexString; + treeIndexes.append( encodedModelIndexString ); } + + project()->mainWindowTreeViewStates = treeStates.join( RiaDefines::stringListSeparator() ); + project()->mainWindowCurrentModelIndexPaths = treeIndexes.join( RiaDefines::stringListSeparator() ); } + if ( m_mainPlotWindow ) { - caf::PdmUiTreeView* projectTreeView = m_mainWindow->projectTreeView(); - if ( projectTreeView ) + QStringList treeStates; + QStringList treeIndexes; + + for ( auto& tv : mainPlotWindow()->projectTreeViews() ) { QString treeViewState; - caf::QTreeViewStateSerializer::storeTreeViewStateToString( projectTreeView->treeView(), treeViewState ); - - QModelIndex mi = projectTreeView->treeView()->currentIndex(); + tv->storeTreeViewStateToString( treeViewState ); + treeStates.append( treeViewState ); - QString encodedModelIndexString; + QModelIndex mi = tv->treeView()->currentIndex(); + QString encodedModelIndexString; caf::QTreeViewStateSerializer::encodeStringFromModelIndex( mi, encodedModelIndexString ); - - project()->mainWindowTreeViewState = treeViewState; - project()->mainWindowCurrentModelIndexPath = encodedModelIndexString; + treeIndexes.append( encodedModelIndexString ); } + + project()->plotWindowTreeViewStates = treeStates.join( RiaDefines::stringListSeparator() ); + project()->plotWindowCurrentModelIndexPaths = treeIndexes.join( RiaDefines::stringListSeparator() ); } } @@ -562,6 +570,12 @@ RiaApplication::ApplicationStatus RiaGuiApplication::handleArguments( gsl::not_n RicSummaryPlotFeatureImpl::createSummaryPlotsFromArgumentLine( cvfqt::Utils::toQStringList( o.values() ) ); } + if ( cvf::Option o = progOpt->option( "openplotwindow" ) ) + { + if ( m_mainWindow ) m_mainWindow->hide(); + getOrCreateAndShowMainPlotWindow(); + } + QString projectFileName; if ( progOpt->hasOption( "last" ) ) @@ -775,7 +789,7 @@ RiaApplication::ApplicationStatus RiaGuiApplication::handleArguments( gsl::not_n mainPlotWnd->loadWinGeoAndDockToolBarLayout(); } - RiuMainWindow::instance()->loadWinGeoAndDockToolBarLayout(); + if ( RiuMainWindow::instance() ) RiuMainWindow::instance()->loadWinGeoAndDockToolBarLayout(); return ApplicationStatus::EXIT_COMPLETED; } @@ -909,6 +923,7 @@ RiuMainWindow* RiaGuiApplication::getOrCreateAndShowMainWindow() else { m_mainWindow->loadWinGeoAndDockToolBarLayout(); + m_mainWindow->show(); } return m_mainWindow; @@ -933,7 +948,7 @@ RiuPlotMainWindow* RiaGuiApplication::getOrCreateMainPlotWindow() m_mainPlotWindow->initializeGuiNewProjectLoaded(); loadAndUpdatePlotData(); } - return m_mainPlotWindow; + return m_mainPlotWindow.get(); } //-------------------------------------------------------------------------------------------------- @@ -958,18 +973,6 @@ void RiaGuiApplication::createMainWindow() m_mainWindow->showWindow(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiaGuiApplication::deleteMainWindow() -{ - if ( m_mainWindow ) - { - delete m_mainWindow; - m_mainWindow = nullptr; - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -982,26 +985,13 @@ void RiaGuiApplication::createMainPlotWindow() caf::CmdExecCommandManager::instance()->enableUndoCommandSystem( true ); } - m_mainPlotWindow = new RiuPlotMainWindow; + m_mainPlotWindow = std::make_unique(); m_mainPlotWindow->setWindowTitle( "Plots - ResInsight" ); m_mainPlotWindow->setDefaultWindowSize(); m_mainPlotWindow->loadWinGeoAndDockToolBarLayout(); m_mainPlotWindow->hideAllDockWidgets(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiaGuiApplication::deleteMainPlotWindow() -{ - if ( m_mainPlotWindow ) - { - m_mainPlotWindow->setParent( nullptr ); - delete m_mainPlotWindow; - m_mainPlotWindow = nullptr; - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1038,7 +1028,7 @@ RiuPlotMainWindow* RiaGuiApplication::getOrCreateAndShowMainPlotWindow() m_mainPlotWindow->restoreDockWidgetVisibilities(); } - return m_mainPlotWindow; + return m_mainPlotWindow.get(); } //-------------------------------------------------------------------------------------------------- @@ -1046,7 +1036,7 @@ RiuPlotMainWindow* RiaGuiApplication::getOrCreateAndShowMainPlotWindow() //-------------------------------------------------------------------------------------------------- RiuPlotMainWindow* RiaGuiApplication::mainPlotWindow() { - return m_mainPlotWindow; + return m_mainPlotWindow.get(); } //-------------------------------------------------------------------------------------------------- @@ -1057,7 +1047,7 @@ RiuMainWindowBase* RiaGuiApplication::mainWindowByID( int mainWindowID ) if ( mainWindowID == 0 ) return m_mainWindow; else if ( mainWindowID == 1 ) - return m_mainPlotWindow; + return m_mainPlotWindow.get(); else return nullptr; } @@ -1152,7 +1142,7 @@ void RiaGuiApplication::clearAllSelections() void RiaGuiApplication::showFormattedTextInMessageBoxOrConsole( const QString& text ) { // Create a message dialog with cut/paste friendly text - QDialog dlg( RiuMainWindow::instance() ); + QDialog dlg; dlg.setModal( true ); QGridLayout* layout = new QGridLayout; @@ -1235,7 +1225,7 @@ void RiaGuiApplication::onProjectBeingOpened() void RiaGuiApplication::onProjectOpeningError( const QString& errMsg ) { RiaLogging::errorInMessageBox( nullptr, "Error when opening project file", errMsg ); - m_mainWindow->setPdmRoot( nullptr ); + if ( m_mainWindow ) m_mainWindow->setPdmRoot( nullptr ); } //-------------------------------------------------------------------------------------------------- @@ -1245,11 +1235,11 @@ void RiaGuiApplication::onProjectOpened() { if ( m_project->show3DWindow() ) { - m_mainWindow->show(); + getOrCreateAndShowMainWindow(); } else { - m_mainWindow->hide(); + if ( m_mainWindow ) m_mainWindow->hide(); } if ( m_project->showPlotWindow() ) @@ -1288,6 +1278,9 @@ void RiaGuiApplication::onProjectOpened() m_maximizeWindowGuard.reset(); processEvents(); + + // Make sure to process events before this function to avoid strange Qt crash + RiuPlotMainWindowTools::refreshToolbars(); } //-------------------------------------------------------------------------------------------------- @@ -1303,12 +1296,8 @@ void RiaGuiApplication::onProjectBeingClosed() RiaGuiApplication::clearAllSelections(); - m_mainWindow->cleanupGuiBeforeProjectClose(); - - if ( m_mainPlotWindow ) - { - m_mainPlotWindow->cleanupGuiBeforeProjectClose(); - } + if ( m_mainWindow ) m_mainWindow->cleanupGuiBeforeProjectClose(); + if ( m_mainPlotWindow ) m_mainPlotWindow->cleanupGuiBeforeProjectClose(); caf::EffectGenerator::clearEffectCache(); } @@ -1318,14 +1307,8 @@ void RiaGuiApplication::onProjectBeingClosed() //-------------------------------------------------------------------------------------------------- void RiaGuiApplication::onProjectClosed() { - if ( m_mainWindow ) - { - m_mainWindow->initializeGuiNewProjectLoaded(); - } - if ( m_mainPlotWindow ) - { - m_mainPlotWindow->initializeGuiNewProjectLoaded(); - } + if ( m_mainWindow ) m_mainWindow->initializeGuiNewProjectLoaded(); + if ( m_mainPlotWindow ) m_mainPlotWindow->initializeGuiNewProjectLoaded(); setWindowCaptionFromAppState(); @@ -1374,13 +1357,19 @@ void RiaGuiApplication::applyGuiPreferences( const RiaPreferences* caf::EffectGenerator::setRenderingMode( caf::EffectGenerator::FIXED_FUNCTION ); } - if ( m_mainWindow && m_mainWindow->projectTreeView() ) + if ( m_mainWindow ) { - m_mainWindow->projectTreeView()->enableAppendOfClassNameToUiItemText( - RiaPreferencesSystem::current()->appendClassNameToUiText() ); - if ( mainPlotWindow() ) - mainPlotWindow()->projectTreeView()->enableAppendOfClassNameToUiItemText( - RiaPreferencesSystem::current()->appendClassNameToUiText() ); + for ( auto& tv : m_mainWindow->projectTreeViews() ) + { + tv->enableAppendOfClassNameToUiItemText( RiaPreferencesSystem::current()->appendClassNameToUiText() ); + } + } + if ( mainPlotWindow() ) + { + for ( auto& tv : mainPlotWindow()->projectTreeViews() ) + { + tv->enableAppendOfClassNameToUiItemText( RiaPreferencesSystem::current()->appendClassNameToUiText() ); + } } for ( auto fontObject : defaultFontObjects ) @@ -1494,7 +1483,7 @@ void RiaGuiApplication::applyGuiPreferences( const RiaPreferences* rim3dView->updateScaling(); if ( rim3dView == activeViewWindow() ) { - RiuMainWindow::instance()->updateScaleValue(); + if ( RiuMainWindow::instance() ) RiuMainWindow::instance()->updateScaleValue(); } } @@ -1567,6 +1556,7 @@ int RiaGuiApplication::applicationResolution() //-------------------------------------------------------------------------------------------------- void RiaGuiApplication::startMonitoringWorkProgress( caf::UiProcess* uiProcess ) { + CAF_ASSERT( m_mainWindow ); m_mainWindow->processMonitor()->startMonitorWorkProcess( uiProcess ); } @@ -1575,6 +1565,7 @@ void RiaGuiApplication::startMonitoringWorkProgress( caf::UiProcess* uiProcess ) //-------------------------------------------------------------------------------------------------- void RiaGuiApplication::stopMonitoringWorkProgress() { + CAF_ASSERT( m_mainWindow ); m_mainWindow->processMonitor()->stopMonitorWorkProcess(); } @@ -1583,6 +1574,8 @@ void RiaGuiApplication::stopMonitoringWorkProgress() //-------------------------------------------------------------------------------------------------- void RiaGuiApplication::slotWorkerProcessFinished( int exitCode, QProcess::ExitStatus exitStatus ) { + CAF_ASSERT( m_mainWindow ); + m_mainWindow->processMonitor()->stopMonitorWorkProcess(); QProcessEnvironment processEnvironment = m_workerProcess->processEnvironment(); @@ -1688,13 +1681,35 @@ bool RiaGuiApplication::notify( QObject* receiver, QEvent* event ) "unstable and will probably crash soon." ); } - bool done = true; + bool done = false; try { - done = QApplication::notify( receiver, event ); + if ( event->type() == QEvent::KeyPress ) + { + if ( activeWindow() != mainWindow() ) + { + QKeyEvent* keyEvent = static_cast( event ); + RimPlotWindow* plot = dynamic_cast( activePlotWindow() ); + if ( plot ) done = plot->handleGlobalKeyEvent( keyEvent ); + } + } + else if ( event->type() == QEvent::Wheel ) + { + if ( activeWindow() != mainWindow() ) + { + QWheelEvent* wheelEvent = static_cast( event ); + RimPlotWindow* plot = dynamic_cast( activePlotWindow() ); + if ( plot ) done = plot->handleGlobalWheelEvent( wheelEvent ); + } + } + if ( !done ) + { + done = QApplication::notify( receiver, event ); + } } catch ( const std::bad_alloc& ) { + done = true; if ( memoryExhaustedBox ) memoryExhaustedBox->exec(); std::cout << "ResInsight: Memory is Exhausted!\n ResInsight could not allocate the memory needed, and is now " "unstable " diff --git a/ApplicationLibCode/Application/RiaGuiApplication.h b/ApplicationLibCode/Application/RiaGuiApplication.h index e4fd72590f..8e2fbcb10f 100644 --- a/ApplicationLibCode/Application/RiaGuiApplication.h +++ b/ApplicationLibCode/Application/RiaGuiApplication.h @@ -134,6 +134,8 @@ class RiaGuiApplication : public QApplication, public RiaApplication void showFormattedTextInMessageBoxOrConsole( const QString& errMsg ) override; protected: + bool notify( QObject* receiver, QEvent* event ) override; + // Protected RiaApplication overrides void invokeProcessEvents( QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents ) override; void onFileSuccessfullyLoaded( const QString& fileName, RiaDefines::ImportFileType fileType ) override; @@ -155,21 +157,17 @@ class RiaGuiApplication : public QApplication, public RiaApplication void setWindowCaptionFromAppState(); void createMainWindow(); - void deleteMainWindow(); void createMainPlotWindow(); - void deleteMainPlotWindow(); void storeTreeViewState(); - bool notify( QObject*, QEvent* ) override; - private slots: void slotWorkerProcessFinished( int exitCode, QProcess::ExitStatus exitStatus ); void onLastWindowClosed(); private: - QPointer m_mainWindow; - QPointer m_mainPlotWindow; + QPointer m_mainWindow; + std::unique_ptr m_mainPlotWindow; std::unique_ptr m_recentFileActionProvider; diff --git a/ApplicationLibCode/Application/RiaMemoryCleanup.cpp b/ApplicationLibCode/Application/RiaMemoryCleanup.cpp index ae2b4f0af2..52fa4158b8 100644 --- a/ApplicationLibCode/Application/RiaMemoryCleanup.cpp +++ b/ApplicationLibCode/Application/RiaMemoryCleanup.cpp @@ -47,14 +47,14 @@ CAF_PDM_SOURCE_INIT( RiaMemoryCleanup, "RiaMemoryCleanup" ); RiaMemoryCleanup::RiaMemoryCleanup() { // clang-format off - CAF_PDM_InitFieldNoDefault(&m_case, "DataCase", "Case", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_case, "DataCase", "Case"); m_case = nullptr; - CAF_PDM_InitFieldNoDefault(&m_resultsToDelete, "ResultsToDelete", "Results In Memory", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_resultsToDelete, "ResultsToDelete", "Results In Memory"); m_resultsToDelete.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP); m_resultsToDelete.uiCapability()->setUiEditorTypeName(caf::PdmUiTreeSelectionEditor::uiEditorTypeName()); - CAF_PDM_InitFieldNoDefault(&m_performDelete, "ClearSelectedData", "", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_performDelete, "ClearSelectedData", ""); caf::PdmUiPushButtonEditor::configureEditorForField(&m_performDelete); // clang-format on } @@ -215,8 +215,7 @@ void RiaMemoryCleanup::fieldChangedByUi( const caf::PdmFieldHandle* changedField //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RiaMemoryCleanup::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RiaMemoryCleanup::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; if ( fieldNeedingOptions == &m_case ) diff --git a/ApplicationLibCode/Application/RiaMemoryCleanup.h b/ApplicationLibCode/Application/RiaMemoryCleanup.h index c15087e52c..99f9190944 100644 --- a/ApplicationLibCode/Application/RiaMemoryCleanup.h +++ b/ApplicationLibCode/Application/RiaMemoryCleanup.h @@ -48,8 +48,7 @@ class RiaMemoryCleanup : public caf::PdmObject std::set findGeoMechCaseResultsInUse() const; std::set findEclipseResultsInUse() const; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, @@ -61,4 +60,4 @@ class RiaMemoryCleanup : public caf::PdmObject std::vector m_geomResultAddresses; std::vector m_eclipseResultAddresses; caf::PdmField m_performDelete; -}; \ No newline at end of file +}; diff --git a/ApplicationLibCode/Application/RiaPlotCollectionScheduler.cpp b/ApplicationLibCode/Application/RiaPlotCollectionScheduler.cpp new file mode 100644 index 0000000000..25055c0893 --- /dev/null +++ b/ApplicationLibCode/Application/RiaPlotCollectionScheduler.cpp @@ -0,0 +1,73 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiaPlotCollectionScheduler.h" + +#include "RimAbstractPlotCollection.h" +#include "RimViewWindow.h" + +#include "cafProgressState.h" + +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaPlotCollectionScheduler::RiaPlotCollectionScheduler() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaPlotCollectionScheduler::~RiaPlotCollectionScheduler() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaPlotCollectionScheduler* RiaPlotCollectionScheduler::instance() +{ + static RiaPlotCollectionScheduler theInstance; + + return &theInstance; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaPlotCollectionScheduler::schedulePlotCollectionUpdate( const std::vector plotCollections ) +{ + m_plotCollectionsToUpdate.insert( m_plotCollectionsToUpdate.end(), plotCollections.begin(), plotCollections.end() ); + + startTimer( 0 ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaPlotCollectionScheduler::performScheduledUpdates() +{ + for ( auto p : m_plotCollectionsToUpdate ) + { + if ( p == nullptr ) continue; + + p->loadDataAndUpdateAllPlots(); + } +} diff --git a/ApplicationLibCode/Application/RiaPlotCollectionScheduler.h b/ApplicationLibCode/Application/RiaPlotCollectionScheduler.h new file mode 100644 index 0000000000..aded19656a --- /dev/null +++ b/ApplicationLibCode/Application/RiaPlotCollectionScheduler.h @@ -0,0 +1,42 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RiaScheduler.h" + +class RimPlotCollection; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +class RiaPlotCollectionScheduler : public RiaScheduler +{ +public: + RiaPlotCollectionScheduler(); + ~RiaPlotCollectionScheduler() override; + + static RiaPlotCollectionScheduler* instance(); + + void schedulePlotCollectionUpdate( const std::vector plotCollections ); + + void performScheduledUpdates() override; + +private: + std::vector m_plotCollectionsToUpdate; +}; diff --git a/ApplicationLibCode/Application/RiaPlotDefines.cpp b/ApplicationLibCode/Application/RiaPlotDefines.cpp new file mode 100644 index 0000000000..6ee4a9f171 --- /dev/null +++ b/ApplicationLibCode/Application/RiaPlotDefines.cpp @@ -0,0 +1,95 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiaPlotDefines.h" + +#include "RiaGuiApplication.h" +#include "RiaPreferencesSystem.h" + +#include "cafAppEnum.h" + +namespace caf +{ +template <> +void caf::AppEnum::setUp() +{ + addItem( RiaDefines::PlotAxis::PLOT_AXIS_LEFT, "PLOT_AXIS_LEFT", "Left" ); + addItem( RiaDefines::PlotAxis::PLOT_AXIS_RIGHT, "PLOT_AXIS_RIGHT", "Right" ); + addItem( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, "PLOT_AXIS_BOTTOM", "Bottom" ); + addItem( RiaDefines::PlotAxis::PLOT_AXIS_TOP, "PLOT_AXIS_TOP", "Top" ); + + setDefault( RiaDefines::PlotAxis::PLOT_AXIS_LEFT ); +} +}; // namespace caf + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RiaDefines::minimumDefaultValuePlot() +{ + return -10.0; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RiaDefines::minimumDefaultLogValuePlot() +{ + return 1.0; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RiaDefines::maximumDefaultValuePlot() +{ + return 100.0; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaDefines::isHorizontal( RiaDefines::PlotAxis axis ) +{ + return !isVertical( axis ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaDefines::isVertical( RiaDefines::PlotAxis axis ) +{ + return ( axis == RiaDefines::PlotAxis::PLOT_AXIS_LEFT || axis == RiaDefines::PlotAxis::PLOT_AXIS_RIGHT ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RiaDefines::scalingFactor( QPaintDevice* paintDevice ) +{ + auto scalingFactor = RiaPreferencesSystem::current()->exportPdfScalingFactor(); + + if ( scalingFactor > 0.0 ) return scalingFactor; + + if ( !paintDevice ) return 1.0; + + int resolution = paintDevice->logicalDpiX(); + double scaling = resolution / static_cast( RiaGuiApplication::applicationResolution() ); + + return scaling; +} diff --git a/ApplicationLibCode/Application/RiaPlotDefines.h b/ApplicationLibCode/Application/RiaPlotDefines.h new file mode 100644 index 0000000000..1bbb56cae2 --- /dev/null +++ b/ApplicationLibCode/Application/RiaPlotDefines.h @@ -0,0 +1,43 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +class QPaintDevice; + +// Defines relate to plotting +namespace RiaDefines +{ +enum class PlotAxis +{ + PLOT_AXIS_LEFT, + PLOT_AXIS_RIGHT, + PLOT_AXIS_BOTTOM, + PLOT_AXIS_TOP +}; + +double minimumDefaultValuePlot(); +double minimumDefaultLogValuePlot(); +double maximumDefaultValuePlot(); + +bool isHorizontal( PlotAxis axis ); +bool isVertical( PlotAxis axis ); + +double scalingFactor( QPaintDevice* paintDevice ); + +}; // namespace RiaDefines diff --git a/ApplicationLibCode/Application/RiaPlotWindowRedrawScheduler.cpp b/ApplicationLibCode/Application/RiaPlotWindowRedrawScheduler.cpp index 0aafd16592..f0d1f65c2f 100644 --- a/ApplicationLibCode/Application/RiaPlotWindowRedrawScheduler.cpp +++ b/ApplicationLibCode/Application/RiaPlotWindowRedrawScheduler.cpp @@ -19,7 +19,7 @@ #include "RiuMultiPlotBook.h" #include "RiuMultiPlotPage.h" -#include "RiuQwtPlotWidget.h" +#include "RiuPlotWidget.h" #include #include @@ -41,9 +41,17 @@ RiaPlotWindowRedrawScheduler* RiaPlotWindowRedrawScheduler::instance() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaPlotWindowRedrawScheduler::scheduleMultiPlotWindowUpdate( RiuMultiPlotBook* plotWindow ) +void RiaPlotWindowRedrawScheduler::scheduleMultiPlotBookUpdate( RiuMultiPlotBook* plotBook, + RiaDefines::MultiPlotPageUpdateType updateType ) { - m_plotWindowsToUpdate.push_back( plotWindow ); + if ( m_plotBooksToUpdate.count( plotBook ) == 0 ) + { + m_plotBooksToUpdate[plotBook] = updateType; + } + else + { + m_plotBooksToUpdate[plotBook] = m_plotBooksToUpdate[plotBook] | updateType; + } startTimer( 0 ); } @@ -51,9 +59,17 @@ void RiaPlotWindowRedrawScheduler::scheduleMultiPlotWindowUpdate( RiuMultiPlotBo //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaPlotWindowRedrawScheduler::scheduleMultiPlotPageUpdate( RiuMultiPlotPage* plotPage ) +void RiaPlotWindowRedrawScheduler::scheduleMultiPlotPageUpdate( RiuMultiPlotPage* plotPage, + RiaDefines::MultiPlotPageUpdateType updateType ) { - m_plotPagesToUpdate.push_back( plotPage ); + if ( m_plotPagesToUpdate.count( plotPage ) == 0 ) + { + m_plotPagesToUpdate[plotPage] = updateType; + } + else + { + m_plotPagesToUpdate[plotPage] = m_plotPagesToUpdate[plotPage] | updateType; + } startTimer( 0 ); } @@ -61,9 +77,9 @@ void RiaPlotWindowRedrawScheduler::scheduleMultiPlotPageUpdate( RiuMultiPlotPage //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaPlotWindowRedrawScheduler::schedulePlotWidgetReplot( RiuQwtPlotWidget* plotWidget ) +void RiaPlotWindowRedrawScheduler::schedulePlotWidgetReplot( RiuPlotWidget* plotWidget ) { - m_plotWidgetsToReplot.push_back( plotWidget ); + m_plotWidgetsToReplot.insert( plotWidget ); startTimer( 0 ); } @@ -82,7 +98,7 @@ void RiaPlotWindowRedrawScheduler::clearAllScheduledUpdates() } m_plotWidgetsToReplot.clear(); m_plotPagesToUpdate.clear(); - m_plotWindowsToUpdate.clear(); + m_plotBooksToUpdate.clear(); } //-------------------------------------------------------------------------------------------------- @@ -90,49 +106,44 @@ void RiaPlotWindowRedrawScheduler::clearAllScheduledUpdates() //-------------------------------------------------------------------------------------------------- void RiaPlotWindowRedrawScheduler::performScheduledUpdatesAndReplots() { - std::vector> plotWindowsToUpdate; - std::vector> plotPagesToUpdate; - std::vector> plotWidgetsToReplot; + std::map, RiaDefines::MultiPlotPageUpdateType> plotBooksToUpdate; + std::map, RiaDefines::MultiPlotPageUpdateType> pagesToUpdate; - plotWindowsToUpdate.swap( m_plotWindowsToUpdate ); - plotPagesToUpdate.swap( m_plotPagesToUpdate ); - plotWidgetsToReplot.swap( m_plotWidgetsToReplot ); + pagesToUpdate.swap( m_plotPagesToUpdate ); + plotBooksToUpdate.swap( m_plotBooksToUpdate ); - std::set> updatedPlots; - std::set> updatedPlotWindows; - std::set> updatedPlotPages; - - for ( QPointer plotWindow : plotWindowsToUpdate ) + for ( auto& [plotBook, updateType] : plotBooksToUpdate ) { - if ( !plotWindow.isNull() && !updatedPlotWindows.count( plotWindow ) ) + if ( plotBook.isNull() ) continue; + + if ( ( updateType & RiaDefines::MultiPlotPageUpdateType::PLOT ) == RiaDefines::MultiPlotPageUpdateType::PLOT ) { - for ( RiuMultiPlotPage* page : plotWindow->pages() ) + for ( RiuMultiPlotPage* page : plotBook->pages() ) { - plotPagesToUpdate.erase( std::remove( plotPagesToUpdate.begin(), plotPagesToUpdate.end(), page ), - plotPagesToUpdate.end() ); + if ( pagesToUpdate.count( page ) > 0 ) pagesToUpdate.erase( page ); } - - plotWindow->performUpdate(); - updatedPlotWindows.insert( plotWindow ); } + plotBook->performUpdate( updateType ); } - for ( QPointer plotPage : plotPagesToUpdate ) + for ( auto& [page, updateType] : pagesToUpdate ) { - if ( !plotPage.isNull() && !updatedPlotPages.count( plotPage ) ) - { - plotPage->performUpdate(); - updatedPlotPages.insert( plotPage ); - } + if ( page.isNull() ) continue; + + page->performUpdate( updateType ); } - // Perform update and replot. Make sure we handle legend update - for ( QPointer plot : plotWidgetsToReplot ) + // PERFORMANCE NOTE + // As the book and page updates can trigger widget updates, make sure to get the list of widgets to replot after + // these updates + std::set> plotWidgetsToReplot; + plotWidgetsToReplot.swap( m_plotWidgetsToReplot ); + + for ( const QPointer& plot : plotWidgetsToReplot ) { - if ( !plot.isNull() && !updatedPlots.count( plot ) ) + if ( !plot.isNull() ) { plot->replot(); - updatedPlots.insert( plot ); } } } diff --git a/ApplicationLibCode/Application/RiaPlotWindowRedrawScheduler.h b/ApplicationLibCode/Application/RiaPlotWindowRedrawScheduler.h index 4f43b0664d..a3a196d39a 100644 --- a/ApplicationLibCode/Application/RiaPlotWindowRedrawScheduler.h +++ b/ApplicationLibCode/Application/RiaPlotWindowRedrawScheduler.h @@ -19,16 +19,19 @@ #include "cafPdmPointer.h" +#include "RiaDefines.h" + #include #include #include #include +#include #include class RiuMultiPlotPage; class RiuMultiPlotBook; -class RiuQwtPlotWidget; +class RiuPlotWidget; class RiaPlotWindowRedrawScheduler : public QObject { @@ -36,24 +39,31 @@ class RiaPlotWindowRedrawScheduler : public QObject public: static RiaPlotWindowRedrawScheduler* instance(); - void scheduleMultiPlotWindowUpdate( RiuMultiPlotBook* plotWindow ); - void scheduleMultiPlotPageUpdate( RiuMultiPlotPage* plotWindow ); - void schedulePlotWidgetReplot( RiuQwtPlotWidget* plotWidget ); - void clearAllScheduledUpdates(); - void performScheduledUpdatesAndReplots(); + + void scheduleMultiPlotBookUpdate( + RiuMultiPlotBook* plotWindow, + RiaDefines::MultiPlotPageUpdateType updateType = RiaDefines::MultiPlotPageUpdateType::ALL ); + void scheduleMultiPlotPageUpdate( + RiuMultiPlotPage* plotWindow, + RiaDefines::MultiPlotPageUpdateType updateType = RiaDefines::MultiPlotPageUpdateType::ALL ); + void schedulePlotWidgetReplot( RiuPlotWidget* plotWidget ); + void clearAllScheduledUpdates(); + void performScheduledUpdatesAndReplots(); private slots: void slotUpdateAndReplotScheduledItemsWhenReady(); private: - RiaPlotWindowRedrawScheduler() = default; + RiaPlotWindowRedrawScheduler() = default; ~RiaPlotWindowRedrawScheduler() override = default; void startTimer( int msecs ); private: - std::vector> m_plotWidgetsToReplot; - std::vector> m_plotWindowsToUpdate; - std::vector> m_plotPagesToUpdate; - QScopedPointer m_plotWindowUpdateTimer; + std::map, RiaDefines::MultiPlotPageUpdateType> m_plotPagesToUpdate; + std::map, RiaDefines::MultiPlotPageUpdateType> m_plotBooksToUpdate; + + std::set> m_plotWidgetsToReplot; + + QScopedPointer m_plotWindowUpdateTimer; }; diff --git a/ApplicationLibCode/Application/RiaPreferences.cpp b/ApplicationLibCode/Application/RiaPreferences.cpp index 080a441376..8cbe778f3b 100644 --- a/ApplicationLibCode/Application/RiaPreferences.cpp +++ b/ApplicationLibCode/Application/RiaPreferences.cpp @@ -26,6 +26,7 @@ #include "RiaPreferencesGeoMech.h" #include "RiaPreferencesSummary.h" #include "RiaPreferencesSystem.h" +#include "RiaQDateTimeTools.h" #include "RiaValidRegExpValidator.h" #include "RifReaderSettings.h" @@ -81,10 +82,7 @@ RiaPreferences::RiaPreferences() CAF_PDM_InitField( &m_navigationPolicy, "navigationPolicy", caf::AppEnum( RiaDefines::RINavigationPolicy::NAVIGATION_POLICY_RMS ), - "Navigation Mode", - "", - "", - "" ); + "Navigation Mode" ); CAF_PDM_InitField( &enableGrpcServer, "enableGrpcServer", @@ -93,9 +91,9 @@ RiaPreferences::RiaPreferences() "", "Remote Procedure Call Scripting Engine", "" ); - CAF_PDM_InitField( &defaultGrpcPortNumber, "defaultGrpcPort", 50051, "Default Python Script Server Port", "", "", "" ); + CAF_PDM_InitField( &defaultGrpcPortNumber, "defaultGrpcPort", 50051, "Default Python Script Server Port" ); - CAF_PDM_InitFieldNoDefault( &scriptDirectories, "scriptDirectory", "Shared Script Folder(s)", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &scriptDirectories, "scriptDirectory", "Shared Script Folder(s)" ); scriptDirectories.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); // TODO: This only currently works for installed ResInsight. @@ -112,45 +110,35 @@ RiaPreferences::RiaPreferences() } #endif - CAF_PDM_InitField( &scriptEditorExecutable, "scriptEditorExecutable", defaultTextEditor, "Script Editor", "", "", "" ); + CAF_PDM_InitField( &scriptEditorExecutable, "scriptEditorExecutable", defaultTextEditor, "Script Editor" ); scriptEditorExecutable.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_octaveExecutable, "octaveExecutable", QString( "octave" ), "Octave Executable Location", "", "", "" ); + CAF_PDM_InitField( &m_maxScriptFoldersDepth, "MaxScriptFoldersDepth", 2, "Maximum Scripts Folder Search Depth" ); + + CAF_PDM_InitField( &m_octaveExecutable, "octaveExecutable", QString( "octave" ), "Octave Executable Location" ); m_octaveExecutable.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); m_octaveExecutable.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); CAF_PDM_InitField( &octaveShowHeaderInfoWhenExecutingScripts, "octaveShowHeaderInfoWhenExecutingScripts", false, - "Show Text Header When Executing Scripts", - "", - "", - "" ); + "Show Text Header When Executing Scripts" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &octaveShowHeaderInfoWhenExecutingScripts ); - CAF_PDM_InitField( &m_pythonExecutable, "pythonExecutable", QString( "python" ), "Python Executable Location", "", "", "" ); + CAF_PDM_InitField( &m_pythonExecutable, "pythonExecutable", QString( "python" ), "Python Executable Location" ); m_pythonExecutable.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); m_pythonExecutable.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); - CAF_PDM_InitField( &showPythonDebugInfo, "pythonDebugInfo", false, "Show Python Debug Info", "", "", "" ); + CAF_PDM_InitField( &showPythonDebugInfo, "pythonDebugInfo", false, "Show Python Debug Info" ); - CAF_PDM_InitField( &ssihubAddress, "ssihubAddress", QString( "http://" ), "SSIHUB Address", "", "", "" ); + CAF_PDM_InitField( &ssihubAddress, "ssihubAddress", QString( "http://" ), "SSIHUB Address" ); ssihubAddress.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); - CAF_PDM_InitFieldNoDefault( &m_defaultMeshModeType, "defaultMeshModeType", "Show Grid Lines", "", "", "" ); - CAF_PDM_InitField( &defaultGridLineColors, - "defaultGridLineColors", - RiaColorTables::defaultGridLineColor(), - "Mesh Color", - "", - "", - "" ); + CAF_PDM_InitFieldNoDefault( &m_defaultMeshModeType, "defaultMeshModeType", "Show Grid Lines" ); + CAF_PDM_InitField( &defaultGridLineColors, "defaultGridLineColors", RiaColorTables::defaultGridLineColor(), "Mesh Color" ); CAF_PDM_InitField( &defaultFaultGridLineColors, "defaultFaultGridLineColors", RiaColorTables::defaultFaultLineColor(), - "Mesh Color Along Faults", - "", - "", - "" ); + "Mesh Color Along Faults" ); CAF_PDM_InitField( &defaultWellLabelColor, "defaultWellLableColor", RiaColorTables::defaultWellLabelColor(), @@ -167,26 +155,26 @@ RiaPreferences::RiaPreferences() "The viewer background color for new views", "" ); - CAF_PDM_InitField( &m_defaultScaleFactorZ, "defaultScaleFactorZ", 5, "Default Z Scale Factor", "", "", "" ); + CAF_PDM_InitField( &m_defaultScaleFactorZ, "defaultScaleFactorZ", 5, "Default Z Scale Factor" ); - CAF_PDM_InitFieldNoDefault( &defaultSceneFontSize, "defaultSceneFontSizePt", "Viewer Font Size", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &defaultAnnotationFontSize, "defaultAnnotationFontSizePt", "Annotation Font Size", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &defaultWellLabelFontSize, "defaultWellLabelFontSizePt", "Well Label Font Size", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &defaultPlotFontSize, "defaultPlotFontSizePt", "Plot Font Size", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &defaultSceneFontSize, "defaultSceneFontSizePt", "Viewer Font Size" ); + CAF_PDM_InitFieldNoDefault( &defaultAnnotationFontSize, "defaultAnnotationFontSizePt", "Annotation Font Size" ); + CAF_PDM_InitFieldNoDefault( &defaultWellLabelFontSize, "defaultWellLabelFontSizePt", "Well Label Font Size" ); + CAF_PDM_InitFieldNoDefault( &defaultPlotFontSize, "defaultPlotFontSizePt", "Plot Font Size" ); - CAF_PDM_InitField( &m_showLegendBackground, "showLegendBackground", true, "Show Box around Legends", "", "", "" ); + CAF_PDM_InitField( &m_showLegendBackground, "showLegendBackground", true, "Show Box around Legends" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_showLegendBackground ); - CAF_PDM_InitField( &m_enableFaultsByDefault, "enableFaultsByDefault", true, "Enable Faults By Default", "", "", "" ); + CAF_PDM_InitField( &m_enableFaultsByDefault, "enableFaultsByDefault", true, "Enable Faults By Default" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_enableFaultsByDefault ); - CAF_PDM_InitField( &m_showInfoBox, "showInfoBox", true, "Show Info Box in New Projects", "", "", "" ); + CAF_PDM_InitField( &m_showInfoBox, "showInfoBox", true, "Show Info Box in New Projects" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_showInfoBox ); - CAF_PDM_InitField( &m_showGridBox, "showGridBox", true, "Show Grid Box in New Projects", "", "", "" ); + CAF_PDM_InitField( &m_showGridBox, "showGridBox", true, "Show Grid Box in New Projects" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_showGridBox ); - CAF_PDM_InitFieldNoDefault( &lastUsedProjectFileName, "lastUsedProjectFileName", "Last Used Project File", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &lastUsedProjectFileName, "lastUsedProjectFileName", "Last Used Project File" ); lastUsedProjectFileName.uiCapability()->setUiHidden( true ); CAF_PDM_InitField( &autocomputeDepthRelatedProperties, @@ -198,62 +186,55 @@ RiaPreferences::RiaPreferences() "" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &autocomputeDepthRelatedProperties ); - CAF_PDM_InitField( &loadAndShowSoil, "loadAndShowSoil", true, "Load and Show SOIL", "", "", "" ); + CAF_PDM_InitField( &loadAndShowSoil, "loadAndShowSoil", true, "Load and Show SOIL" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &loadAndShowSoil ); CAF_PDM_InitField( &holoLensDisableCertificateVerification, "holoLensDisableCertificateVerification", false, - "Disable SSL Certificate Verification (HoloLens)", - "", - "", - "" ); + "Disable SSL Certificate Verification (HoloLens)" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &holoLensDisableCertificateVerification ); CAF_PDM_InitField( &csvTextExportFieldSeparator, "csvTextExportFieldSeparator", QString( "," ), - "CSV Text Export Field Separator", - "", - "", - "" ); + "CSV Text Export Field Separator" ); - CAF_PDM_InitFieldNoDefault( &m_readerSettings, "readerSettings", "Reader Settings", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_readerSettings, "readerSettings", "Reader Settings" ); m_readerSettings = new RifReaderSettings; - CAF_PDM_InitFieldNoDefault( &m_dateFormat, "dateFormat", "Date Format", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_dateFormat, "dateFormat", "Date Format" ); m_dateFormat.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); m_dateFormat = RiaQDateTimeTools::supportedDateFormats().front(); - CAF_PDM_InitFieldNoDefault( &m_timeFormat, "timeFormat", "Time Format", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_timeFormat, "timeFormat", "Time Format" ); m_timeFormat.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); m_timeFormat = RiaQDateTimeTools::supportedTimeFormats().front(); - CAF_PDM_InitField( &m_useUndoRedo, "useUndoRedo", true, "Enable Undo/Redo for Property Editor changes", "", "", "" ); + CAF_PDM_InitField( &m_useUndoRedo, "useUndoRedo", false, "Enable Undo/Redo for Property Editor changes" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_useUndoRedo ); - CAF_PDM_InitFieldNoDefault( &m_plotTemplateFolders, "plotTemplateFolders", "Plot Template Folder(s)", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_plotTemplateFolders, "plotTemplateFolders", "Plot Template Folder(s)" ); m_plotTemplateFolders.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_searchPlotTemplateFoldersRecursively, - "SearchPlotTemplateFoldersRecursively", - true, - "Search Plot Templates Recursively", - "", - "", - "" ); - caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_searchPlotTemplateFoldersRecursively ); + CAF_PDM_InitField( &m_maxPlotTemplateFoldersDepth, + "MaxPlotTemplateFoldersDepth", + 2, + "Maximum Plot Template Folder Search Depth" ); - CAF_PDM_InitFieldNoDefault( &m_defaultPlotTemplate, "defaultPlotTemplate", "Default Plot Template", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_lastUsedPlotTemplate, "defaultPlotTemplate", "Default Plot Template" ); - CAF_PDM_InitFieldNoDefault( &m_pageSize, "pageSize", "Page Size", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_pageOrientation, "pageOrientation", "Page Orientation", "", "", "" ); - CAF_PDM_InitField( &m_pageLeftMargin, "pageLeftMargin", defaultMarginSize( m_pageSize() ), "Left Margin", "", "", "" ); - CAF_PDM_InitField( &m_pageTopMargin, "pageTopMargin", defaultMarginSize( m_pageSize() ), "Top Margin", "", "", "" ); - CAF_PDM_InitField( &m_pageRightMargin, "pageRightMargin", defaultMarginSize( m_pageSize() ), "Right Margin", "", "", "" ); - CAF_PDM_InitField( &m_pageBottomMargin, "pageBottomMargin", defaultMarginSize( m_pageSize() ), "Bottom Margin", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_pageSize, "pageSize", "Page Size" ); + CAF_PDM_InitFieldNoDefault( &m_pageOrientation, "pageOrientation", "Page Orientation" ); + CAF_PDM_InitField( &m_pageLeftMargin, "pageLeftMargin", defaultMarginSize( m_pageSize() ), "Left Margin" ); + CAF_PDM_InitField( &m_pageTopMargin, "pageTopMargin", defaultMarginSize( m_pageSize() ), "Top Margin" ); + CAF_PDM_InitField( &m_pageRightMargin, "pageRightMargin", defaultMarginSize( m_pageSize() ), "Right Margin" ); + CAF_PDM_InitField( &m_pageBottomMargin, "pageBottomMargin", defaultMarginSize( m_pageSize() ), "Bottom Margin" ); - CAF_PDM_InitField( &m_openExportedPdfInViewer, "openExportedPdfInViewer", false, "Open Exported PDF in Viewer", "", "", "" ); + CAF_PDM_InitField( &m_openExportedPdfInViewer, "openExportedPdfInViewer", false, "Open Exported PDF in Viewer" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_openExportedPdfInViewer ); + CAF_PDM_InitField( &m_useQtChartsPlotByDefault, "useQtChartsPlotByDefault", false, "Use QtChart as Default Plot Type" ); + caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_useQtChartsPlotByDefault ); + CAF_PDM_InitField( &m_surfaceImportResamplingDistance, "SurfaceImportResamplingDistance", 100.0, @@ -272,15 +253,15 @@ RiaPreferences::RiaPreferences() "" ); m_multiLateralWellPattern.uiCapability()->setUiEditorTypeName( caf::PdmUiLineEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_guiTheme, "guiTheme", "GUI theme", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_guiTheme, "guiTheme", "GUI theme" ); - CAF_PDM_InitFieldNoDefault( &m_summaryPreferences, "summaryPreferences", "summaryPreferences", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_summaryPreferences, "summaryPreferences", "summaryPreferences" ); m_summaryPreferences = new RiaPreferencesSummary; - CAF_PDM_InitFieldNoDefault( &m_geoMechPreferences, "geoMechPreferences", "geoMechPreferences", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_geoMechPreferences, "geoMechPreferences", "geoMechPreferences" ); m_geoMechPreferences = new RiaPreferencesGeoMech; - CAF_PDM_InitFieldNoDefault( &m_systemPreferences, "systemPreferences", "systemPreferences", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_systemPreferences, "systemPreferences", "systemPreferences" ); m_systemPreferences = new RiaPreferencesSystem; } @@ -308,6 +289,7 @@ void RiaPreferences::defineEditorAttribute( const caf::PdmFieldHandle* field, caf::PdmUiEditorAttribute* attribute ) { m_readerSettings->defineEditorAttribute( field, uiConfigName, attribute ); + m_summaryPreferences->defineEditorAttribute( field, uiConfigName, attribute ); { caf::PdmUiFilePathEditorAttribute* myAttr = dynamic_cast( attribute ); @@ -376,7 +358,7 @@ void RiaPreferences::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& otherGroup->add( &holoLensDisableCertificateVerification ); otherGroup->add( &m_useUndoRedo ); } - else if ( uiConfigName == RiaPreferences::tabNameEclipseGrid() ) + else if ( uiConfigName == RiaPreferences::tabNameGrid() ) { caf::PdmUiGroup* newCaseBehaviourGroup = uiOrdering.addNewGroup( "Behavior When Loading Data" ); newCaseBehaviourGroup->add( &autocomputeDepthRelatedProperties ); @@ -384,7 +366,7 @@ void RiaPreferences::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& m_readerSettings->uiOrdering( uiConfigName, *newCaseBehaviourGroup ); } - else if ( uiConfigName == RiaPreferences::tabNameEclipseSummary() ) + else if ( uiConfigName == RiaPreferences::tabNameSummary() ) { m_summaryPreferences->appendRestartFileGroup( uiOrdering ); @@ -396,16 +378,20 @@ void RiaPreferences::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& } else if ( uiConfigName == RiaPreferences::tabNamePlotting() ) { - uiOrdering.add( &m_dateFormat ); - uiOrdering.add( &m_timeFormat ); + caf::PdmUiGroup* summaryGrp = uiOrdering.addNewGroup( "Summary Plots" ); - summaryPreferences()->appendItemsToPlottingGroup( uiOrdering ); + summaryPreferences()->appendItemsToPlottingGroup( *summaryGrp ); - caf::PdmUiGroup* group = uiOrdering.addNewGroup( "Plot Templates" ); + caf::PdmUiGroup* group = summaryGrp->addNewGroup( "Plot Templates" ); group->add( &m_plotTemplateFolders ); - group->add( &m_searchPlotTemplateFoldersRecursively ); + group->add( &m_maxPlotTemplateFoldersDepth ); + + caf::PdmUiGroup* generalGrp = uiOrdering.addNewGroup( "General" ); + + generalGrp->add( &m_dateFormat ); + generalGrp->add( &m_timeFormat ); - caf::PdmUiGroup* pageSetup = uiOrdering.addNewGroup( "Page Setup" ); + caf::PdmUiGroup* pageSetup = generalGrp->addNewGroup( "Page Setup" ); pageSetup->add( &m_pageSize ); pageSetup->add( &m_pageOrientation, false ); pageSetup->add( &m_pageLeftMargin ); @@ -413,6 +399,9 @@ void RiaPreferences::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& pageSetup->add( &m_pageTopMargin ); pageSetup->add( &m_pageBottomMargin, false ); + generalGrp->add( &m_useQtChartsPlotByDefault ); + m_useQtChartsPlotByDefault.uiCapability()->setUiHidden( true ); + QString unitLabel = " [mm]"; if ( QPageSize( m_pageSize() ).definitionUnits() == QPageSize::Inch ) { @@ -439,6 +428,7 @@ void RiaPreferences::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& #endif caf::PdmUiGroup* scriptGroup = uiOrdering.addNewGroup( "Script files" ); scriptGroup->add( &scriptDirectories ); + scriptGroup->add( &m_maxScriptFoldersDepth ); scriptGroup->add( &scriptEditorExecutable ); } #ifdef USE_ODB_API @@ -447,15 +437,15 @@ void RiaPreferences::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& m_geoMechPreferences()->appendItems( uiOrdering ); } #endif - else if ( uiConfigName == RiaPreferences::tabNameExport() ) - { - uiOrdering.add( &csvTextExportFieldSeparator ); - uiOrdering.add( &m_openExportedPdfInViewer ); - } - else if ( uiConfigName == RiaPreferences::tabNameImport() ) + else if ( uiConfigName == RiaPreferences::tabNameImportExport() ) { - uiOrdering.add( &m_surfaceImportResamplingDistance ); - uiOrdering.add( &m_multiLateralWellPattern ); + caf::PdmUiGroup* importGroup = uiOrdering.addNewGroup( "Import" ); + importGroup->add( &m_surfaceImportResamplingDistance ); + importGroup->add( &m_multiLateralWellPattern ); + + caf::PdmUiGroup* exportGroup = uiOrdering.addNewGroup( "Export" ); + exportGroup->add( &csvTextExportFieldSeparator ); + exportGroup->add( &m_openExportedPdfInViewer ); } else if ( RiaApplication::enableDevelopmentFeatures() && uiConfigName == RiaPreferences::tabNameSystem() ) { @@ -468,11 +458,9 @@ void RiaPreferences::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RiaPreferences::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RiaPreferences::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; - *useOptionsOnly = true; if ( fieldNeedingOptions == &m_dateFormat ) { @@ -480,7 +468,8 @@ QList RiaPreferences::calculateValueOptions( const caf:: { QDate exampleDate = QDate( 2019, 8, 16 ); QString fullDateFormat = - RiaQDateTimeTools::dateFormatString( dateFormat, RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH_DAY ); + RiaQDateTimeTools::dateFormatString( dateFormat, + RiaDefines::DateFormatComponents::DATE_FORMAT_YEAR_MONTH_DAY ); QString uiText = QString( "%1 (%2)" ).arg( fullDateFormat ).arg( exampleDate.toString( fullDateFormat ) ); uiText.replace( "AP", "AM/PM" ); options.push_back( caf::PdmOptionItemInfo( uiText, QVariant::fromValue( dateFormat ) ) ); @@ -493,7 +482,7 @@ QList RiaPreferences::calculateValueOptions( const caf:: QTime exampleTime = QTime( 15, 48, 22 ); QString timeFormatString = RiaQDateTimeTools::timeFormatString( timeFormat, - RiaQDateTimeTools::TimeFormatComponents::TIME_FORMAT_HOUR_MINUTE_SECOND ); + RiaDefines::TimeFormatComponents::TIME_FORMAT_HOUR_MINUTE_SECOND ); QString uiText = QString( "%1 (%2)" ).arg( timeFormatString ).arg( exampleTime.toString( timeFormatString ) ); uiText.replace( "AP", "AM/PM" ); options.push_back( caf::PdmOptionItemInfo( uiText, QVariant::fromValue( timeFormat ) ) ); @@ -524,11 +513,14 @@ void RiaPreferences::fieldChangedByUi( const caf::PdmFieldHandle* changedField, m_pageTopMargin = defaultMarginSize( m_pageSize() ); m_pageBottomMargin = defaultMarginSize( m_pageSize() ); } - - if ( changedField == &m_guiTheme ) + else if ( changedField == &m_guiTheme ) { RiuGuiTheme::updateGuiTheme( m_guiTheme() ); } + else + { + m_summaryPreferences->fieldChangedByUi( changedField, oldValue, newValue ); + } } //-------------------------------------------------------------------------------------------------- /// @@ -541,17 +533,17 @@ QString RiaPreferences::tabNameGeneral() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RiaPreferences::tabNameEclipseGrid() +QString RiaPreferences::tabNameGrid() { - return "Eclipse Grid"; + return "Grid"; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RiaPreferences::tabNameEclipseSummary() +QString RiaPreferences::tabNameSummary() { - return "Eclipse Summary"; + return "Summary"; } //-------------------------------------------------------------------------------------------------- @@ -578,14 +570,6 @@ QString RiaPreferences::tabNameScripting() return "Scripting"; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RiaPreferences::tabNameExport() -{ - return "Export"; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -597,9 +581,9 @@ QString RiaPreferences::tabNameSystem() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RiaPreferences::tabNameImport() +QString RiaPreferences::tabNameImportExport() { - return "Import"; + return "Import/Export"; } //-------------------------------------------------------------------------------------------------- @@ -626,15 +610,14 @@ QStringList RiaPreferences::tabNames() QStringList names; names << tabNameGeneral(); - names << tabNameEclipseGrid(); - names << tabNameEclipseSummary(); + names << tabNameGrid(); + names << tabNameSummary(); names << tabNamePlotting(); names << tabNameScripting(); #ifdef USE_ODB_API names << tabNameGeomech(); #endif - names << tabNameExport(); - names << tabNameImport(); + names << tabNameImportExport(); if ( RiaApplication::enableDevelopmentFeatures() ) { @@ -679,7 +662,8 @@ const QString& RiaPreferences::timeFormat() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RiaPreferences::dateTimeFormat( DateFormatComponents dateComponents, TimeFormatComponents timeComponents ) const +QString RiaPreferences::dateTimeFormat( RiaDefines::DateFormatComponents dateComponents, + RiaDefines::TimeFormatComponents timeComponents ) const { return QString( "%1 %2" ) .arg( RiaQDateTimeTools::dateFormatString( m_dateFormat(), dateComponents ) ) @@ -689,9 +673,17 @@ QString RiaPreferences::dateTimeFormat( DateFormatComponents dateComponents, Tim //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RiaPreferences::searchPlotTemplateFoldersRecursively() const +int RiaPreferences::maxScriptFoldersDepth() const +{ + return m_maxScriptFoldersDepth(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RiaPreferences::maxPlotTemplateFoldersDepth() const { - return m_searchPlotTemplateFoldersRecursively(); + return m_maxPlotTemplateFoldersDepth(); } //-------------------------------------------------------------------------------------------------- @@ -732,17 +724,17 @@ void RiaPreferences::appendPlotTemplateFolders( const QString& folder ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RiaPreferences::defaultPlotTemplateAbsolutePath() const +QString RiaPreferences::lastUsedPlotTemplateAbsolutePath() const { - return m_defaultPlotTemplate().path(); + return m_lastUsedPlotTemplate().path(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaPreferences::setDefaultPlotTemplatePath( const QString& templatePath ) +void RiaPreferences::setLastUsedPlotTemplatePath( const QString& templatePath ) { - m_defaultPlotTemplate = templatePath; + m_lastUsedPlotTemplate = templatePath; } //-------------------------------------------------------------------------------------------------- @@ -753,6 +745,14 @@ bool RiaPreferences::openExportedPdfInViewer() const return m_openExportedPdfInViewer; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaPreferences::useQtChartsAsDefaultPlotType() const +{ + return m_useQtChartsPlotByDefault; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/RiaPreferences.h b/ApplicationLibCode/Application/RiaPreferences.h index eff3d69aac..2606cadbbb 100644 --- a/ApplicationLibCode/Application/RiaPreferences.h +++ b/ApplicationLibCode/Application/RiaPreferences.h @@ -21,9 +21,9 @@ #pragma once +#include "RiaDateTimeDefines.h" #include "RiaDefines.h" #include "RiaFontCache.h" -#include "RiaQDateTimeTools.h" #include "cafAppEnum.h" #include "cafPdmChildField.h" @@ -52,9 +52,6 @@ class RiaPreferences : public caf::PdmObject CAF_PDM_HEADER_INIT; public: - using DateFormatComponents = RiaQDateTimeTools::DateFormatComponents; - using TimeFormatComponents = RiaQDateTimeTools::TimeFormatComponents; - using FontSizeEnum = RiaFontCache::FontSizeEnum; using PageSizeEnum = caf::AppEnum; using PageOrientationEnum = caf::AppEnum; @@ -75,15 +72,19 @@ class RiaPreferences : public caf::PdmObject const QString& dateFormat() const; const QString& timeFormat() const; - QString dateTimeFormat( DateFormatComponents dateComponents = DateFormatComponents::DATE_FORMAT_YEAR_MONTH_DAY, - TimeFormatComponents timeComponents = TimeFormatComponents::TIME_FORMAT_HOUR_MINUTE_SECOND ) const; + QString dateTimeFormat( + RiaDefines::DateFormatComponents dateComponents = RiaDefines::DateFormatComponents::DATE_FORMAT_YEAR_MONTH_DAY, + RiaDefines::TimeFormatComponents timeComponents = RiaDefines::TimeFormatComponents::TIME_FORMAT_HOUR_MINUTE_SECOND ) const; + + int maxScriptFoldersDepth() const; + int maxPlotTemplateFoldersDepth() const; - bool searchPlotTemplateFoldersRecursively() const; QStringList plotTemplateFolders() const; void appendPlotTemplateFolders( const QString& folder ); - QString defaultPlotTemplateAbsolutePath() const; - void setDefaultPlotTemplatePath( const QString& templatePath ); + QString lastUsedPlotTemplateAbsolutePath() const; + void setLastUsedPlotTemplatePath( const QString& templatePath ); bool openExportedPdfInViewer() const; + bool useQtChartsAsDefaultPlotType() const; RiaDefines::ThemeEnum guiTheme() const; @@ -148,21 +149,19 @@ class RiaPreferences : public caf::PdmObject QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void initAfterRead() override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; private: static QString tabNameGeneral(); - static QString tabNameEclipseGrid(); - static QString tabNameEclipseSummary(); + static QString tabNameGrid(); + static QString tabNameSummary(); static QString tabNameGeomech(); static QString tabNamePlotting(); static QString tabNameScripting(); - static QString tabNameExport(); static QString tabNameSystem(); - static QString tabNameImport(); + static QString tabNameImportExport(); static double defaultMarginSize( QPageSize::PageSizeId pageSizeId ); @@ -176,6 +175,8 @@ class RiaPreferences : public caf::PdmObject caf::PdmField> m_guiTheme; + caf::PdmField m_maxScriptFoldersDepth; + caf::PdmField m_pageSize; caf::PdmField m_pageOrientation; caf::PdmField m_pageLeftMargin; @@ -185,8 +186,9 @@ class RiaPreferences : public caf::PdmObject caf::PdmField m_openExportedPdfInViewer; caf::PdmField m_plotTemplateFolders; - caf::PdmField m_searchPlotTemplateFoldersRecursively; - caf::PdmField m_defaultPlotTemplate; + caf::PdmField m_maxPlotTemplateFoldersDepth; + caf::PdmField m_lastUsedPlotTemplate; + caf::PdmField m_useQtChartsPlotByDefault; // Script paths caf::PdmField m_octaveExecutable; diff --git a/ApplicationLibCode/Application/RiaPreferencesGeoMech.cpp b/ApplicationLibCode/Application/RiaPreferencesGeoMech.cpp index bfe7ce24c5..899e568ed8 100644 --- a/ApplicationLibCode/Application/RiaPreferencesGeoMech.cpp +++ b/ApplicationLibCode/Application/RiaPreferencesGeoMech.cpp @@ -34,41 +34,33 @@ CAF_PDM_SOURCE_INIT( RiaPreferencesGeoMech, "RiaPreferencesGeoMech" ); //-------------------------------------------------------------------------------------------------- RiaPreferencesGeoMech::RiaPreferencesGeoMech() { - CAF_PDM_InitFieldNoDefault( &m_geomechFRAPreprocCommand, "geomechFRAPreprocCommand", "Pre-Processing Command", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_geomechFRAPreprocCommand, "geomechFRAPreprocCommand", "Pre-Processing Command" ); m_geomechFRAPreprocCommand.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); m_geomechFRAPreprocCommand.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); - CAF_PDM_InitFieldNoDefault( &m_geomechFRAPostprocCommand, "geomechFRAPostprocCommand", "Post-Processing Command", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_geomechFRAPostprocCommand, "geomechFRAPostprocCommand", "Post-Processing Command" ); m_geomechFRAPostprocCommand.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); m_geomechFRAPostprocCommand.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); - CAF_PDM_InitFieldNoDefault( &m_geomechFRAMacrisCommand, "geomechFRAMacrisCommand", "Main Macris Command", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_geomechFRAMacrisCommand, "geomechFRAMacrisCommand", "Main Macris Command" ); m_geomechFRAMacrisCommand.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); m_geomechFRAMacrisCommand.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); - CAF_PDM_InitFieldNoDefault( &m_geomechFRADefaultBasicXML, - "geomechFRADefaultXML", - "Basic Processing Parameter XML File", - "", - "", - "" ); + CAF_PDM_InitFieldNoDefault( &m_geomechFRADefaultBasicXML, "geomechFRADefaultXML", "Basic Processing Parameter XML File" ); m_geomechFRADefaultBasicXML.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); m_geomechFRADefaultBasicXML.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); CAF_PDM_InitFieldNoDefault( &m_geomechFRADefaultAdvXML, "geomechFRADefaultAdvXML", - "Advanced Processing Parameter XML File", - "", - "", - "" ); + "Advanced Processing Parameter XML File" ); m_geomechFRADefaultAdvXML.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); m_geomechFRADefaultAdvXML.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); - CAF_PDM_InitFieldNoDefault( &m_geomechWIADefaultXML, "geomechWIADefaultXML", "Default Parameter XML File", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_geomechWIADefaultXML, "geomechWIADefaultXML", "Default Parameter XML File" ); m_geomechWIADefaultXML.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); m_geomechWIADefaultXML.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); - CAF_PDM_InitFieldNoDefault( &m_geomechWIACommand, "geomechWIACommand", "Command to run", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_geomechWIACommand, "geomechWIACommand", "Command to run" ); m_geomechWIACommand.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); m_geomechWIACommand.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); diff --git a/ApplicationLibCode/Application/RiaPreferencesSummary.cpp b/ApplicationLibCode/Application/RiaPreferencesSummary.cpp index 23dbef7232..7cefefb4ac 100644 --- a/ApplicationLibCode/Application/RiaPreferencesSummary.cpp +++ b/ApplicationLibCode/Application/RiaPreferencesSummary.cpp @@ -18,12 +18,21 @@ #include "RiaPreferencesSummary.h" +#include "PlotTemplateCommands/RicSummaryPlotTemplateTools.h" + #include "RiaApplication.h" +#include "RiaColorTables.h" #include "RiaPreferences.h" +#include "PlotTemplates/RimPlotTemplateFileItem.h" + #include "cafPdmUiCheckBoxEditor.h" +#include "cafPdmUiComboBoxEditor.h" +#include "cafPdmUiListEditor.h" +#include "cafPdmUiPushButtonEditor.h" #include +#include namespace caf { @@ -55,6 +64,16 @@ void RiaPreferencesSummary::SummaryReaderModeType::setUp() addItem( RiaPreferencesSummary::SummaryReaderMode::OPM_COMMON, "OPM_COMMON", "ESMRY (opm-common)" ); setDefault( RiaPreferencesSummary::SummaryReaderMode::HDF5_OPM_COMMON ); } + +template <> +void RiaPreferencesSummary::DefaultSummaryPlotEnum::setUp() +{ + addItem( RiaPreferencesSummary::DefaultSummaryPlotType::NONE, "NONE", "No Plots" ); + addItem( RiaPreferencesSummary::DefaultSummaryPlotType::DATA_VECTORS, "DATA_VECTORS", "Use Data Vector Names" ); + addItem( RiaPreferencesSummary::DefaultSummaryPlotType::PLOT_TEMPLATES, "PLOT_TEMPLATES", "Use Plot Templates" ); + setDefault( RiaPreferencesSummary::DefaultSummaryPlotType::DATA_VECTORS ); +} + } // namespace caf CAF_PDM_SOURCE_INIT( RiaPreferencesSummary, "RiaPreferencesSummary" ); @@ -66,42 +85,27 @@ RiaPreferencesSummary::RiaPreferencesSummary() { CAF_PDM_InitFieldNoDefault( &m_summaryRestartFilesShowImportDialog, "summaryRestartFilesShowImportDialog", - "Show Import Dialog", - "", - "", - "" ); + "Show Import Dialog" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_summaryRestartFilesShowImportDialog ); CAF_PDM_InitField( &m_summaryImportMode, "summaryImportMode", SummaryRestartFilesImportModeType( RiaPreferencesSummary::SummaryRestartFilesImportMode::IMPORT ), - "Default Summary Import Option", - "", - "", - "" ); + "Default Summary Import Option" ); CAF_PDM_InitField( &m_gridImportMode, "gridImportMode", SummaryRestartFilesImportModeType( RiaPreferencesSummary::SummaryRestartFilesImportMode::NOT_IMPORT ), - "Default Grid Import Option", - "", - "", - "" ); + "Default Grid Import Option" ); CAF_PDM_InitField( &m_summaryEnsembleImportMode, "summaryEnsembleImportMode", SummaryRestartFilesImportModeType( RiaPreferencesSummary::SummaryRestartFilesImportMode::IMPORT ), - "Default Ensemble Summary Import Option", - "", - "", - "" ); + "Default Ensemble Summary Import Option" ); CAF_PDM_InitField( &m_defaultSummaryHistoryCurveStyle, "defaultSummaryHistoryCurveStyle", SummaryHistoryCurveStyleModeType( RiaPreferencesSummary::SummaryHistoryCurveStyleMode::SYMBOLS ), - "Default Curve Style for History Vectors", - "", - "", - "" ); + "Default Curve Style for History Vectors" ); CAF_PDM_InitField( &m_defaultSummaryCurvesTextFilter, "defaultSummaryCurvesTextFilter", QString( "FOPT" ), @@ -109,6 +113,16 @@ RiaPreferencesSummary::RiaPreferencesSummary() "", "Semicolon separated list of filters used to create curves in new summary plots", "" ); + CAF_PDM_InitFieldNoDefault( &m_defaultSummaryPlot, "defaultSummaryPlot", "Create Plot On Summary Data Import" ); + + CAF_PDM_InitField( &m_selectDefaultTemplates, "selectDefaultTemplate", false, "", "", "Select Default Templates" ); + m_selectDefaultTemplates.xmlCapability()->disableIO(); + m_selectDefaultTemplates.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); + + CAF_PDM_InitFieldNoDefault( &m_selectedDefaultTemplates, "defaultSummaryTemplates", "Select Summary Plot Templates" ); + m_selectedDefaultTemplates.uiCapability()->setUiReadOnly( true ); + m_selectedDefaultTemplates.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() ); + m_selectedDefaultTemplates.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); CAF_PDM_InitField( &m_createEnhancedSummaryDataFile, "createEnhancedSummaryDataFile_v01", @@ -137,33 +151,43 @@ RiaPreferencesSummary::RiaPreferencesSummary() "" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_createH5SummaryDataFile ); - CAF_PDM_InitField( &m_createH5SummaryFileThreadCount, - "createH5SummaryFileThreadCount", - 1, - "h5 Summary Export Thread Count", - "", - "", - "" ); + CAF_PDM_InitField( &m_createH5SummaryFileThreadCount, "createH5SummaryFileThreadCount", 1, "h5 Summary Export Thread Count" ); - CAF_PDM_InitFieldNoDefault( &m_summaryReader, "summaryReaderType_v01", "File Format", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_summaryReader, "summaryReaderType_v01", "File Format" ); CAF_PDM_InitField( &m_showSummaryTimeAsLongString, "showSummaryTimeAsLongString", false, - "Show resample time text as long time text (2010-11-21 23:15:00)", - "", - "", - "" ); + "Show resample time text as long time text (2010-11-21 23:15:00)" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_showSummaryTimeAsLongString ); CAF_PDM_InitField( &m_useMultipleThreadsWhenLoadingSummaryCases, "useMultipleThreadsWhenLoadingSummaryCases", true, - "Use Multiple Threads for Import of Summary Files", - "", - "", - "" ); + "Use Multiple Threads for Import of Summary Files" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_useMultipleThreadsWhenLoadingSummaryCases ); + + CAF_PDM_InitFieldNoDefault( &m_defaultColumnCount, "DefaultNumberOfColumns", "Columns" ); + m_defaultColumnCount = RiaDefines::ColumnCount::COLUMNS_2; + CAF_PDM_InitFieldNoDefault( &m_defaultRowsPerPage, "DefaultRowsPerPage", "Rows per Page" ); + m_defaultRowsPerPage = RiaDefines::RowCount::ROWS_2; + + CAF_PDM_InitField( &m_curveColorByPhase, "curveColorByPhase", true, "Curve Color By Phase" ); + caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_curveColorByPhase ); + + CAF_PDM_InitField( &m_appendHistoryVectors, + "appendHistoryVectorForDragDrop", + false, + "Append History Vectors", + "", + "When a simulated summary vector is inserted into a plot, also include the corresponding " + "history vector" ); + caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_appendHistoryVectors ); + + CAF_PDM_InitField( &m_historyCurveContrastColor, + "historyCurveContrastColor", + RiaColorTables::historyCurveContrastColor(), + "History Curve Color" ); } //-------------------------------------------------------------------------------------------------- @@ -245,9 +269,36 @@ void RiaPreferencesSummary::appendRestartFileGroup( caf::PdmUiOrdering& uiOrderi //-------------------------------------------------------------------------------------------------- void RiaPreferencesSummary::appendItemsToPlottingGroup( caf::PdmUiOrdering& uiOrdering ) const { - uiOrdering.add( &m_defaultSummaryCurvesTextFilter ); - uiOrdering.add( &m_defaultSummaryHistoryCurveStyle ); + uiOrdering.add( &m_defaultSummaryPlot ); + + switch ( m_defaultSummaryPlot() ) + { + case RiaPreferencesSummary::DefaultSummaryPlotType::DATA_VECTORS: + uiOrdering.add( &m_defaultSummaryCurvesTextFilter ); + break; + + case RiaPreferencesSummary::DefaultSummaryPlotType::PLOT_TEMPLATES: + uiOrdering.add( &m_selectedDefaultTemplates ); + uiOrdering.add( &m_selectDefaultTemplates ); + break; + + default: + break; + } + + auto historyCurveGroup = uiOrdering.addNewGroup( "History Vectors" ); + + historyCurveGroup->add( &m_defaultSummaryHistoryCurveStyle ); + historyCurveGroup->add( &m_historyCurveContrastColor ); + historyCurveGroup->add( &m_appendHistoryVectors ); + + uiOrdering.add( &m_curveColorByPhase ); uiOrdering.add( &m_showSummaryTimeAsLongString ); + + auto multiGroup = uiOrdering.addNewGroup( "Multi Plot Defaults" ); + + multiGroup->add( &m_defaultColumnCount ); + multiGroup->add( &m_defaultRowsPerPage ); } //-------------------------------------------------------------------------------------------------- @@ -306,6 +357,22 @@ QString RiaPreferencesSummary::defaultSummaryCurvesTextFilter() const return m_defaultSummaryCurvesTextFilter; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaPreferencesSummary::colorCurvesByPhase() const +{ + return m_curveColorByPhase(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaPreferencesSummary::appendHistoryVectors() const +{ + return m_appendHistoryVectors(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -346,11 +413,42 @@ void RiaPreferencesSummary::defineUiOrdering( QString uiConfigName, caf::PdmUiOr //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList - RiaPreferencesSummary::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) +void RiaPreferencesSummary::defineEditorAttribute( const caf::PdmFieldHandle* field, + QString uiConfigName, + caf::PdmUiEditorAttribute* attribute ) +{ + if ( field == &m_defaultRowsPerPage || field == &m_defaultColumnCount ) + { + auto myattr = dynamic_cast( attribute ); + if ( myattr ) + { + myattr->iconSize = QSize( 24, 16 ); + } + } + else if ( field == &m_selectDefaultTemplates ) + { + auto attrib = dynamic_cast( attribute ); + if ( attrib ) + { + attrib->m_buttonText = "Select Default Templates"; + } + } + else if ( field == &m_selectedDefaultTemplates ) + { + auto attrib = dynamic_cast( attribute ); + if ( attrib ) + { + attrib->m_heightHint = 30; + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RiaPreferencesSummary::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; - *useOptionsOnly = true; if ( fieldNeedingOptions == &m_summaryReader ) { @@ -389,6 +487,144 @@ QList options.push_back( caf::PdmOptionItemInfo( allowImport.uiText(), RiaPreferencesSummary::SummaryRestartFilesImportMode::IMPORT ) ); } + else if ( fieldNeedingOptions == &m_defaultColumnCount ) + { + for ( size_t i = 0; i < ColumnCountEnum::size(); ++i ) + { + RiaDefines::ColumnCount enumVal = ColumnCountEnum::fromIndex( i ); + QString columnCountString = ( enumVal == RiaDefines::ColumnCount::COLUMNS_UNLIMITED ) + ? "Unlimited" + : QString( "%1" ).arg( static_cast( enumVal ) ); + QString iconPath = QString( ":/Columns%1.png" ).arg( columnCountString ); + options.push_back( caf::PdmOptionItemInfo( ColumnCountEnum::uiText( enumVal ), + enumVal, + false, + caf::IconProvider( iconPath, QSize( 24, 16 ) ) ) ); + } + } + else if ( fieldNeedingOptions == &m_defaultRowsPerPage ) + { + for ( size_t i = 0; i < RowCountEnum::size(); ++i ) + { + RiaDefines::RowCount enumVal = RowCountEnum::fromIndex( i ); + QString iconPath = QString( ":/Rows%1.png" ).arg( static_cast( enumVal ) ); + options.push_back( caf::PdmOptionItemInfo( RowCountEnum::uiText( enumVal ), + enumVal, + false, + caf::IconProvider( iconPath, QSize( 24, 16 ) ) ) ); + } + } return options; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaDefines::ColumnCount RiaPreferencesSummary::defaultMultiPlotColumnCount() const +{ + return m_defaultColumnCount(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaDefines::RowCount RiaPreferencesSummary::defaultMultiPlotRowCount() const +{ + return m_defaultRowsPerPage(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Color3f RiaPreferencesSummary::historyCurveContrastColor() const +{ + return m_historyCurveContrastColor(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaPreferencesSummary::fieldChangedByUi( const caf::PdmFieldHandle* changedField, + const QVariant& oldValue, + const QVariant& newValue ) +{ + if ( changedField == &m_selectDefaultTemplates ) + { + m_selectDefaultTemplates = false; + + auto selection = RicSummaryPlotTemplateTools::selectDefaultPlotTemplates( m_selectedDefaultTemplates() ); + if ( selection.empty() ) return; + + m_selectedDefaultTemplates = selection; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaPreferencesSummary::DefaultSummaryPlotType RiaPreferencesSummary::defaultSummaryPlotType() const +{ + return m_defaultSummaryPlot(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RiaPreferencesSummary::defaultSummaryPlotTemplates( bool returnEnsembleTemplates ) const +{ + std::vector templatesToUse; + for ( auto& fileName : m_selectedDefaultTemplates() ) + { + bool singleTemplate = fileName.toLower().endsWith( ".rpt" ); + if ( singleTemplate && returnEnsembleTemplates ) continue; + if ( !singleTemplate && !returnEnsembleTemplates ) continue; + + if ( std::count( templatesToUse.begin(), templatesToUse.end(), fileName ) == 0 ) + templatesToUse.push_back( fileName ); + } + + return templatesToUse; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaPreferencesSummary::isDefaultSummaryPlotTemplate( QString filename ) const +{ + int count = std::count( m_selectedDefaultTemplates().begin(), m_selectedDefaultTemplates().end(), filename ); + return ( count > 0 ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaPreferencesSummary::addToDefaultPlotTemplates( QString filename ) +{ + if ( isDefaultSummaryPlotTemplate( filename ) ) return; + + std::vector newlist; + newlist.insert( newlist.end(), m_selectedDefaultTemplates().begin(), m_selectedDefaultTemplates().end() ); + newlist.push_back( filename ); + m_selectedDefaultTemplates = newlist; + + RiaPreferences::current()->writePreferencesToApplicationStore(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaPreferencesSummary::removeFromDefaultPlotTemplates( QString filename ) +{ + if ( !isDefaultSummaryPlotTemplate( filename ) ) return; + + std::vector newlist; + + for ( auto& item : m_selectedDefaultTemplates() ) + { + if ( item != filename ) newlist.push_back( item ); + } + m_selectedDefaultTemplates = newlist; + + RiaPreferences::current()->writePreferencesToApplicationStore(); +} diff --git a/ApplicationLibCode/Application/RiaPreferencesSummary.h b/ApplicationLibCode/Application/RiaPreferencesSummary.h index a7d267cc77..c4611e7f81 100644 --- a/ApplicationLibCode/Application/RiaPreferencesSummary.h +++ b/ApplicationLibCode/Application/RiaPreferencesSummary.h @@ -19,9 +19,19 @@ #pragma once #include "cafAppEnum.h" +#include "cafPdmChildArrayField.h" #include "cafPdmField.h" #include "cafPdmObject.h" +#include "RiaDefines.h" + +// Include to make Pdm work for cvf::Color +#include "cafPdmFieldCvfColor.h" + +#include + +#include + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -54,6 +64,17 @@ class RiaPreferencesSummary : public caf::PdmObject }; using SummaryHistoryCurveStyleModeType = caf::AppEnum; + enum class DefaultSummaryPlotType + { + NONE, + DATA_VECTORS, + PLOT_TEMPLATES + }; + using DefaultSummaryPlotEnum = caf::AppEnum; + + using ColumnCountEnum = caf::AppEnum; + using RowCountEnum = caf::AppEnum; + public: RiaPreferencesSummary(); @@ -66,6 +87,12 @@ class RiaPreferencesSummary : public caf::PdmObject bool createH5SummaryDataFiles() const; int createH5SummaryDataThreadCount() const; + DefaultSummaryPlotType defaultSummaryPlotType() const; + std::vector defaultSummaryPlotTemplates( bool returnEnsembleTemplates ) const; + bool isDefaultSummaryPlotTemplate( QString filename ) const; + void addToDefaultPlotTemplates( QString filename ); + void removeFromDefaultPlotTemplates( QString filename ); + void appendRestartFileGroup( caf::PdmUiOrdering& uiOrdering ) const; void appendItemsToPlottingGroup( caf::PdmUiOrdering& uiOrdering ) const; @@ -77,15 +104,30 @@ class RiaPreferencesSummary : public caf::PdmObject SummaryRestartFilesImportMode gridImportMode() const; SummaryRestartFilesImportMode summaryEnsembleImportMode() const; QString defaultSummaryCurvesTextFilter() const; + bool colorCurvesByPhase() const; + bool appendHistoryVectors() const; SummaryHistoryCurveStyleMode defaultSummaryHistoryCurveStyle() const; + RiaDefines::ColumnCount defaultMultiPlotColumnCount() const; + RiaDefines::RowCount defaultMultiPlotRowCount() const; + + cvf::Color3f historyCurveContrastColor() const; + + void defineEditorAttribute( const caf::PdmFieldHandle* field, + QString uiConfigName, + caf::PdmUiEditorAttribute* attribute ) override; + void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; + protected: void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; private: + caf::PdmField m_defaultSummaryPlot; + caf::PdmField m_selectDefaultTemplates; + caf::PdmField> m_selectedDefaultTemplates; + caf::PdmField m_summaryRestartFilesShowImportDialog; caf::PdmField m_summaryImportMode; caf::PdmField m_gridImportMode; @@ -93,6 +135,8 @@ class RiaPreferencesSummary : public caf::PdmObject caf::PdmField m_defaultSummaryCurvesTextFilter; caf::PdmField m_defaultSummaryHistoryCurveStyle; + caf::PdmField m_curveColorByPhase; + caf::PdmField m_appendHistoryVectors; caf::PdmField m_showSummaryTimeAsLongString; caf::PdmField m_useMultipleThreadsWhenLoadingSummaryCases; @@ -104,4 +148,9 @@ class RiaPreferencesSummary : public caf::PdmObject caf::PdmField m_createH5SummaryFileThreadCount; caf::PdmField m_summaryReader; + + caf::PdmField m_defaultColumnCount; + caf::PdmField m_defaultRowsPerPage; + + caf::PdmField m_historyCurveContrastColor; }; diff --git a/ApplicationLibCode/Application/RiaPreferencesSystem.cpp b/ApplicationLibCode/Application/RiaPreferencesSystem.cpp index 33d2e09749..b815dfec34 100644 --- a/ApplicationLibCode/Application/RiaPreferencesSystem.cpp +++ b/ApplicationLibCode/Application/RiaPreferencesSystem.cpp @@ -46,62 +46,51 @@ CAF_PDM_SOURCE_INIT( RiaPreferencesSystem, "RiaPreferencesSystem" ); //-------------------------------------------------------------------------------------------------- RiaPreferencesSystem::RiaPreferencesSystem() { - CAF_PDM_InitField( &m_useShaders, "useShaders", true, "Use Shaders", "", "", "" ); + CAF_PDM_InitField( &m_useShaders, "useShaders", true, "Use Shaders" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_useShaders ); - CAF_PDM_InitField( &m_showHud, "showHud", false, "Show 3D Information", "", "", "" ); + CAF_PDM_InitField( &m_showHud, "showHud", false, "Show 3D Information" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_showHud ); - CAF_PDM_InitField( &m_appendClassNameToUiText, "appendClassNameToUiText", false, "Show Class Names", "", "", "" ); + CAF_PDM_InitField( &m_appendClassNameToUiText, "appendClassNameToUiText", false, "Show Class Names" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_appendClassNameToUiText ); CAF_PDM_InitField( &m_appendFieldKeywordToToolTipText, "appendFieldKeywordToToolTipText", false, - "Show Field Keyword in ToolTip", - "", - "", - "" ); + "Show Field Keyword in ToolTip" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_appendFieldKeywordToToolTipText ); - CAF_PDM_InitField( &m_showViewIdInProjectTree, "showViewIdInTree", false, "Show View Id in Project Tree", "", "", "" ); + CAF_PDM_InitField( &m_showViewIdInProjectTree, "showViewIdInTree", false, "Show View Id in Project Tree" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_showViewIdInProjectTree ); - CAF_PDM_InitField( &m_showTestToolbar, "showTestToolbar", false, "Enable Test Toolbar", "", "", "" ); + CAF_PDM_InitField( &m_showTestToolbar, "showTestToolbar", false, "Enable Test Toolbar" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_showTestToolbar ); CAF_PDM_InitField( &m_includeFractureDebugInfoFile, "includeFractureDebugInfoFile", false, - "Include Fracture Debug Info for Completion Export", - "", - "", - "" ); + "Include Fracture Debug Info for Completion Export" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_includeFractureDebugInfoFile ); - CAF_PDM_InitFieldNoDefault( &m_holoLensExportFolder, "holoLensExportFolder", "HoloLens Export Folder", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_holoLensExportFolder, "holoLensExportFolder", "HoloLens Export Folder" ); m_holoLensExportFolder.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); m_holoLensExportFolder.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_showProjectChangedDialog, - "showProjectChangedDialog", - true, - "Show 'Project has changed' dialog", - "", - "", - "" ); + CAF_PDM_InitField( &m_showProjectChangedDialog, "showProjectChangedDialog", true, "Show 'Project has changed' dialog" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_showProjectChangedDialog ); - CAF_PDM_InitField( &m_showProgressBar, "showProgressBar", true, "Show Progress Bar", "", "", "" ); + CAF_PDM_InitField( &m_showProgressBar, "showProgressBar", true, "Show Progress Bar" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_showProgressBar ); - CAF_PDM_InitField( &m_gtestFilter, "gtestFilter", QString(), "Unit Test Filter (gtest)", "", "", "" ); + CAF_PDM_InitField( &m_showPdfExportDialog, "showPdfExportDialog", true, "Show PDF Export Dialog" ); + caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_showPdfExportDialog ); + + CAF_PDM_InitField( &m_gtestFilter, "gtestFilter", QString(), "Unit Test Filter (gtest)" ); + CAF_PDM_InitField( &m_exportScalingFactor, "exportScalingFactor", -1.0, "Export Scaling Factor (<0 disable)" ); CAF_PDM_InitField( &m_eclipseReaderMode, "eclipseReaderMode", EclipseTextFileReaderModeType( RiaPreferencesSystem::EclipseTextFileReaderMode::FILE ), - "Eclipse Text File Import mode (GRDECL)", - "", - "", - "" ); + "Eclipse Text File Import mode (GRDECL)" ); } //-------------------------------------------------------------------------------------------------- @@ -112,6 +101,14 @@ RiaPreferencesSystem* RiaPreferencesSystem::current() return RiaApplication::instance()->preferences()->systemPreferences(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaPreferencesSystem::setAppendClassNameToUiText( bool enable ) +{ + m_appendClassNameToUiText = enable; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -210,6 +207,22 @@ bool RiaPreferencesSystem::showProgressBar() const return m_showProgressBar(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaPreferencesSystem::showPdfExportDialog() const +{ + return m_showPdfExportDialog(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RiaPreferencesSystem::exportPdfScalingFactor() const +{ + return m_exportScalingFactor(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -242,16 +255,17 @@ void RiaPreferencesSystem::defineUiOrdering( QString uiConfigName, caf::PdmUiOrd uiOrdering.add( &m_includeFractureDebugInfoFile ); uiOrdering.add( &m_holoLensExportFolder ); uiOrdering.add( &m_showProgressBar ); + + uiOrdering.add( &m_showPdfExportDialog ); + uiOrdering.add( &m_exportScalingFactor ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList - RiaPreferencesSystem::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) +QList RiaPreferencesSystem::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; - *useOptionsOnly = true; return options; } diff --git a/ApplicationLibCode/Application/RiaPreferencesSystem.h b/ApplicationLibCode/Application/RiaPreferencesSystem.h index 9e1e421cf6..7b2cb77f66 100644 --- a/ApplicationLibCode/Application/RiaPreferencesSystem.h +++ b/ApplicationLibCode/Application/RiaPreferencesSystem.h @@ -42,6 +42,7 @@ class RiaPreferencesSystem : public caf::PdmObject static RiaPreferencesSystem* current(); + void setAppendClassNameToUiText( bool enable ); bool appendClassNameToUiText() const; bool appendFieldKeywordToToolTipText() const; bool showViewIdInProjectTree() const; @@ -53,13 +54,14 @@ class RiaPreferencesSystem : public caf::PdmObject bool show3dInformation() const; QString gtestFilter() const; bool showProgressBar() const; + bool showPdfExportDialog() const; + double exportPdfScalingFactor() const; EclipseTextFileReaderMode eclipseTextFileReaderMode() const; protected: void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; @@ -77,6 +79,9 @@ class RiaPreferencesSystem : public caf::PdmObject caf::PdmField m_includeFractureDebugInfoFile; caf::PdmField m_holoLensExportFolder; + caf::PdmField m_showPdfExportDialog; + caf::PdmField m_exportScalingFactor; + caf::PdmField m_showProgressBar; caf::PdmField m_gtestFilter; diff --git a/ApplicationLibCode/Application/RiaResultNames.cpp b/ApplicationLibCode/Application/RiaResultNames.cpp index 0d44f2c3ed..0e96b96946 100644 --- a/ApplicationLibCode/Application/RiaResultNames.cpp +++ b/ApplicationLibCode/Application/RiaResultNames.cpp @@ -84,6 +84,17 @@ bool RiaResultNames::isLogarithmicResult( const QString& resultName ) return false; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaResultNames::isFlowResultWithBothPosAndNegValues( const QString& resultName ) +{ + if ( resultName.startsWith( "FLR", Qt::CaseInsensitive ) ) return true; + if ( resultName.startsWith( "FLO", Qt::CaseInsensitive ) ) return true; + + return false; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -350,6 +361,30 @@ QString RiaResultNames::indexKResultName() return "INDEX_K"; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaResultNames::soil() +{ + return "SOIL"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaResultNames::sgas() +{ + return "SGAS"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaResultNames::swat() +{ + return "SWAT"; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/RiaResultNames.h b/ApplicationLibCode/Application/RiaResultNames.h index f0b32033df..1d0974375a 100644 --- a/ApplicationLibCode/Application/RiaResultNames.h +++ b/ApplicationLibCode/Application/RiaResultNames.h @@ -28,6 +28,7 @@ namespace RiaResultNames { bool isPerCellFaceResult( const QString& resultName ); bool isLogarithmicResult( const QString& resultName ); +bool isFlowResultWithBothPosAndNegValues( const QString& resultName ); QString undefinedResultName(); QString undefinedGridFaultName(); @@ -69,6 +70,10 @@ QString indexIResultName(); QString indexJResultName(); QString indexKResultName(); +QString soil(); +QString sgas(); +QString swat(); + // Well path derived results QString wbsAzimuthResult(); QString wbsInclinationResult(); diff --git a/ApplicationLibCode/Application/RiaRftDefines.cpp b/ApplicationLibCode/Application/RiaRftDefines.cpp new file mode 100644 index 0000000000..410dde165b --- /dev/null +++ b/ApplicationLibCode/Application/RiaRftDefines.cpp @@ -0,0 +1,67 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiaRftDefines.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaDefines::segmentStartDepthResultName() +{ + return "SEGLENST"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaDefines::segmentEndDepthResultName() +{ + return "SEGLENEN"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaDefines::segmentTvdDepthResultName() +{ + return "SEGDEPTH"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaDefines::segmentNumberResultName() +{ + return "SEGMENTNUMBER"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaDefines::allBranches() +{ + return "All"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaDefines::segmentBranchNumberResultName() +{ + return "SegmenBranchNumber"; +} diff --git a/ApplicationLibCode/Application/RiaRftDefines.h b/ApplicationLibCode/Application/RiaRftDefines.h new file mode 100644 index 0000000000..5467b6c4ed --- /dev/null +++ b/ApplicationLibCode/Application/RiaRftDefines.h @@ -0,0 +1,41 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include + +namespace RiaDefines +{ +QString segmentStartDepthResultName(); +QString segmentEndDepthResultName(); +QString segmentTvdDepthResultName(); +QString segmentNumberResultName(); + +QString allBranches(); +QString segmentBranchNumberResultName(); + +enum class RftBranchType +{ + RFT_TUBING, + RFT_ANNULAR, + RFT_DEVICE, + RFT_UNKNOWN +}; + +}; // namespace RiaDefines diff --git a/ApplicationLibCode/Application/RiaScheduler.cpp b/ApplicationLibCode/Application/RiaScheduler.cpp new file mode 100644 index 0000000000..123ef0b5bc --- /dev/null +++ b/ApplicationLibCode/Application/RiaScheduler.cpp @@ -0,0 +1,83 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiaScheduler.h" + +#include "cafProgressState.h" + +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaScheduler::RiaScheduler() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaScheduler::~RiaScheduler() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaScheduler::slotUpdateScheduledItemsWhenReady() +{ + if ( caf::ProgressState::isActive() ) + { + startTimer( 100 ); + return; + } + + performScheduledUpdates(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaScheduler::startTimer( int msecs ) +{ + if ( !m_updateTimer ) + { + m_updateTimer.reset( new QTimer( this ) ); + connect( m_updateTimer.data(), SIGNAL( timeout() ), this, SLOT( slotUpdateScheduledItemsWhenReady() ) ); + } + + if ( !m_updateTimer->isActive() ) + { + m_updateTimer->setSingleShot( true ); + m_updateTimer->start( msecs ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaScheduler::waitUntilWorkIsDone() +{ + if ( m_updateTimer ) + { + while ( m_updateTimer->isActive() ) + { + QCoreApplication::processEvents(); + } + } +} diff --git a/ApplicationLibCode/Application/RiaScheduler.h b/ApplicationLibCode/Application/RiaScheduler.h new file mode 100644 index 0000000000..ad0dbc3c28 --- /dev/null +++ b/ApplicationLibCode/Application/RiaScheduler.h @@ -0,0 +1,47 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +class RiaScheduler : public QObject +{ + Q_OBJECT + +public: + RiaScheduler(); + ~RiaScheduler() override; + + virtual void performScheduledUpdates() = 0; + +protected: + void startTimer( int msecs ); + void waitUntilWorkIsDone(); + +private slots: + void slotUpdateScheduledItemsWhenReady(); + +private: + QScopedPointer m_updateTimer; +}; diff --git a/ApplicationLibCode/Application/RiaSummaryCurveDefinition.cpp b/ApplicationLibCode/Application/RiaSummaryCurveDefinition.cpp index 4dc0d45ecf..4aaa94c576 100644 --- a/ApplicationLibCode/Application/RiaSummaryCurveDefinition.cpp +++ b/ApplicationLibCode/Application/RiaSummaryCurveDefinition.cpp @@ -42,14 +42,9 @@ RiaSummaryCurveDefinition::RiaSummaryCurveDefinition( RimSummaryCase* bool isEnsembleCurve ) : m_summaryCase( summaryCase ) , m_summaryAddress( summaryAddress ) + , m_ensemble( nullptr ) , m_isEnsembleCurve( isEnsembleCurve ) { - if ( summaryCase ) - { - RimSummaryCaseCollection* ensemble = nullptr; - summaryCase->firstAncestorOfType( ensemble ); - m_ensemble = ensemble; - } } //-------------------------------------------------------------------------------------------------- @@ -96,6 +91,14 @@ bool RiaSummaryCurveDefinition::isEnsembleCurve() const return m_isEnsembleCurve; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSummaryCurveDefinition::setSummaryAddress( const RifEclipseSummaryAddress& address ) +{ + m_summaryAddress = address; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -226,7 +229,7 @@ void RiaSummaryCurveDefinitionAnalyser::setCurveDefinitions( const std::vector m_ensembles; // All the ensembles referenced by the summary cases std::set m_summaryAdresses; - std::set m_quantityNames; // Quantity names from the addresses + std::set m_vectorNames; }; diff --git a/ApplicationLibCode/Application/RiaViewRedrawScheduler.cpp b/ApplicationLibCode/Application/RiaViewRedrawScheduler.cpp index 622574db93..67b8d1de9e 100644 --- a/ApplicationLibCode/Application/RiaViewRedrawScheduler.cpp +++ b/ApplicationLibCode/Application/RiaViewRedrawScheduler.cpp @@ -17,14 +17,25 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RiaViewRedrawScheduler.h" -#include "Rim3dView.h" -#include -#include +#include "Rim3dView.h" -#include "cafProgressState.h" #include +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaViewRedrawScheduler::RiaViewRedrawScheduler() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaViewRedrawScheduler::~RiaViewRedrawScheduler() +{ +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -51,13 +62,8 @@ void RiaViewRedrawScheduler::scheduleDisplayModelUpdateAndRedraw( Rim3dView* res //-------------------------------------------------------------------------------------------------- void RiaViewRedrawScheduler::clearViewsScheduledForUpdate() { - if ( m_resViewUpdateTimer ) - { - while ( m_resViewUpdateTimer->isActive() ) - { - QCoreApplication::processEvents(); - } - } + waitUntilWorkIsDone(); + m_resViewsToUpdate.clear(); } @@ -105,39 +111,7 @@ void RiaViewRedrawScheduler::updateAndRedrawScheduledViews() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaViewRedrawScheduler::slotUpdateAndRedrawScheduledViewsWhenReady() +void RiaViewRedrawScheduler::performScheduledUpdates() { - if ( caf::ProgressState::isActive() ) - { - startTimer( 100 ); - return; - } - updateAndRedrawScheduledViews(); } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiaViewRedrawScheduler::startTimer( int msecs ) -{ - if ( !m_resViewUpdateTimer ) - { - m_resViewUpdateTimer = new QTimer( this ); - connect( m_resViewUpdateTimer, SIGNAL( timeout() ), this, SLOT( slotUpdateAndRedrawScheduledViewsWhenReady() ) ); - } - - if ( !m_resViewUpdateTimer->isActive() ) - { - m_resViewUpdateTimer->setSingleShot( true ); - m_resViewUpdateTimer->start( msecs ); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RiaViewRedrawScheduler::~RiaViewRedrawScheduler() -{ - delete m_resViewUpdateTimer; -} diff --git a/ApplicationLibCode/Application/RiaViewRedrawScheduler.h b/ApplicationLibCode/Application/RiaViewRedrawScheduler.h index e80f38b801..59f31daae6 100644 --- a/ApplicationLibCode/Application/RiaViewRedrawScheduler.h +++ b/ApplicationLibCode/Application/RiaViewRedrawScheduler.h @@ -18,38 +18,28 @@ #pragma once +#include "RiaScheduler.h" + #include "cafPdmPointer.h" -#include + #include -class QTimer; class Rim3dView; -class RiaViewRedrawScheduler : public QObject +class RiaViewRedrawScheduler : public RiaScheduler { - Q_OBJECT; - public: - static RiaViewRedrawScheduler* instance(); - void scheduleDisplayModelUpdateAndRedraw( Rim3dView* resViewToUpdate ); - void clearViewsScheduledForUpdate(); - void updateAndRedrawScheduledViews(); - -private slots: - void slotUpdateAndRedrawScheduledViewsWhenReady(); + RiaViewRedrawScheduler(); + ~RiaViewRedrawScheduler() override; -private: - void startTimer( int msecs ); + static RiaViewRedrawScheduler* instance(); - RiaViewRedrawScheduler() - : m_resViewUpdateTimer( nullptr ) - { - } - ~RiaViewRedrawScheduler() override; + void scheduleDisplayModelUpdateAndRedraw( Rim3dView* resViewToUpdate ); + void clearViewsScheduledForUpdate(); + void updateAndRedrawScheduledViews(); - RiaViewRedrawScheduler( const RiaViewRedrawScheduler& o ) = delete; - void operator=( const RiaViewRedrawScheduler& o ) = delete; + void performScheduledUpdates() override; +private: std::vector> m_resViewsToUpdate; - QTimer* m_resViewUpdateTimer; }; diff --git a/ApplicationLibCode/Application/Tools/CMakeLists_files.cmake b/ApplicationLibCode/Application/Tools/CMakeLists_files.cmake index ea3b07a223..5c122e3be8 100644 --- a/ApplicationLibCode/Application/Tools/CMakeLists_files.cmake +++ b/ApplicationLibCode/Application/Tools/CMakeLists_files.cmake @@ -16,7 +16,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RiaWellNameComparer.h ${CMAKE_CURRENT_LIST_DIR}/RiaStdStringTools.h ${CMAKE_CURRENT_LIST_DIR}/RiaInterpolationTools.h - ${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveAnalyzer.h + ${CMAKE_CURRENT_LIST_DIR}/RiaSummaryAddressAnalyzer.h ${CMAKE_CURRENT_LIST_DIR}/RiaSimWellBranchTools.h ${CMAKE_CURRENT_LIST_DIR}/RiaProjectFileVersionTools.h ${CMAKE_CURRENT_LIST_DIR}/RiaStringEncodingTools.h @@ -48,6 +48,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RiaValidRegExpValidator.h ${CMAKE_CURRENT_LIST_DIR}/RiaVec3Tools.h ${CMAKE_CURRENT_LIST_DIR}/RiaEnsembleNameTools.h + ${CMAKE_CURRENT_LIST_DIR}/RiaSummaryStringTools.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -68,7 +69,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RiaWellNameComparer.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaStdStringTools.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaInterpolationTools.cpp - ${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveAnalyzer.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiaSummaryAddressAnalyzer.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaSimWellBranchTools.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaProjectFileVersionTools.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaStringEncodingTools.cpp @@ -93,6 +94,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RiaValidRegExpValidator.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaEnsembleNameTools.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaVec3Tools.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiaSummaryStringTools.cpp ) list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES}) diff --git a/ApplicationLibCode/Application/Tools/RiaArgumentParser.cpp b/ApplicationLibCode/Application/Tools/RiaArgumentParser.cpp index 868fb49870..640e37d2fa 100644 --- a/ApplicationLibCode/Application/Tools/RiaArgumentParser.cpp +++ b/ApplicationLibCode/Application/Tools/RiaArgumentParser.cpp @@ -143,6 +143,7 @@ bool RiaArgumentParser::parseArguments( cvf::ProgramOptions* progOpt ) progOpt->registerOption( "generate", "[]", "Generate code or documentation", cvf::ProgramOptions::SINGLE_VALUE ); progOpt->registerOption( "ignoreArgs", "", "System command. Ignore all arguments. Mostly for testing purposes" ); progOpt->registerOption( "version", "", "Display the application version string" ); + progOpt->registerOption( "openplotwindow", "", "Open the 2D plot window. By default, the 3D window is displayed." ); progOpt->setOptionPrefix( cvf::ProgramOptions::DOUBLE_DASH ); diff --git a/ApplicationLibCode/Application/Tools/RiaColorTables.cpp b/ApplicationLibCode/Application/Tools/RiaColorTables.cpp index 4522989faa..bdb9912a42 100644 --- a/ApplicationLibCode/Application/Tools/RiaColorTables.cpp +++ b/ApplicationLibCode/Application/Tools/RiaColorTables.cpp @@ -682,6 +682,16 @@ cvf::Color3f RiaColorTables::phaseColor( RiaDefines::PhaseType phase ) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Color3f RiaColorTables::historyCurveContrastColor() +{ + auto unsignedColor = cvf::Color3ub( 248, 0, 170 ); // Magenta + + return cvf::Color3f( unsignedColor ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/Tools/RiaColorTables.h b/ApplicationLibCode/Application/Tools/RiaColorTables.h index aa2db4a804..509447f787 100644 --- a/ApplicationLibCode/Application/Tools/RiaColorTables.h +++ b/ApplicationLibCode/Application/Tools/RiaColorTables.h @@ -81,6 +81,8 @@ class RiaColorTables static std::map phaseColors(); static cvf::Color3f phaseColor( RiaDefines::PhaseType phase ); + static cvf::Color3f historyCurveContrastColor(); + private: static std::vector categoryColors(); static std::vector contrastCategoryColors(); diff --git a/ApplicationLibCode/Application/Tools/RiaColorTools.cpp b/ApplicationLibCode/Application/Tools/RiaColorTools.cpp index 9c333b3423..04bdce0935 100644 --- a/ApplicationLibCode/Application/Tools/RiaColorTools.cpp +++ b/ApplicationLibCode/Application/Tools/RiaColorTools.cpp @@ -184,6 +184,26 @@ QColor RiaColorTools::blendQColors( const QColor& color1, const QColor& color2, ( color1.blue() * weight1 + color2.blue() * weight2 ) / weightsum ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Color3f RiaColorTools::makeLighter( const cvf::Color3f& color, float normalizedScalingFactor ) +{ + auto qColor = toQColor( color ); + + double h = 0.0; + double s = 0.0; + double l = 0.0; + qColor.getHslF( &h, &s, &l ); + + l = l + ( 1.0 - l ) * normalizedScalingFactor; + l = std::min( 1.0, l ); + + qColor.setHslF( h, s, l ); + + return fromQColorTo3f( qColor ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/Tools/RiaColorTools.h b/ApplicationLibCode/Application/Tools/RiaColorTools.h index 2030cc233b..7c7b4e2ebe 100644 --- a/ApplicationLibCode/Application/Tools/RiaColorTools.h +++ b/ApplicationLibCode/Application/Tools/RiaColorTools.h @@ -49,6 +49,8 @@ class RiaColorTools blendCvfColors( const cvf::Color3f& color1, const cvf::Color3f& color2, int weight1 = 1, int weight2 = 1 ); static QColor blendQColors( const QColor& color1, const QColor& color2, int weight1 = 1, int weight2 = 1 ); + static cvf::Color3f makeLighter( const cvf::Color3f& color1, float normalizedScalingFactor ); + // Factor > 1 increases saturation, a factor < 1 decreases saturation static QColor modifySaturation( const QColor& color, double factor ); diff --git a/ApplicationLibCode/Application/Tools/RiaEnsembleNameTools.cpp b/ApplicationLibCode/Application/Tools/RiaEnsembleNameTools.cpp index 3a484c80d3..51f4769348 100644 --- a/ApplicationLibCode/Application/Tools/RiaEnsembleNameTools.cpp +++ b/ApplicationLibCode/Application/Tools/RiaEnsembleNameTools.cpp @@ -22,6 +22,9 @@ #include "RiaTextStringTools.h" #include "RimCaseDisplayNameTools.h" +#include "RimProject.h" +#include "RimSummaryCase.h" +#include "RimSummaryCaseCollection.h" #include "cafAppEnum.h" @@ -131,6 +134,54 @@ std::vector RiaEnsembleNameTools::groupFilesByEnsemble( const QStri return groupedByIteration; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaEnsembleNameTools::uniqueShortNameForEnsembleCase( RimSummaryCase* summaryCase ) +{ + CAF_ASSERT( summaryCase && summaryCase->ensemble() ); + + auto ensembleCaseName = summaryCase->nativeCaseName(); + auto ensemble = summaryCase->ensemble(); + auto summaryCases = ensemble->allSummaryCases(); + + QStringList summaryFilePaths; + summaryFilePaths.push_back( summaryCase->summaryHeaderFilename() ); + + for ( auto otherSummaryCase : summaryCases ) + { + if ( otherSummaryCase != summaryCase ) + { + summaryFilePaths.push_back( otherSummaryCase->summaryHeaderFilename() ); + } + } + + return RiaEnsembleNameTools::uniqueShortName( summaryCase->summaryHeaderFilename(), summaryFilePaths, ensembleCaseName ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaEnsembleNameTools::uniqueShortNameForSummaryCase( RimSummaryCase* summaryCase ) +{ + std::set allAutoShortNames; + + std::vector allCases; + RimProject::current()->descendantsOfType( allCases ); + + for ( auto sumCase : allCases ) + { + if ( sumCase && sumCase != summaryCase ) + { + allAutoShortNames.insert( sumCase->displayCaseName() ); + } + } + + return RimCaseDisplayNameTools::uniqueShortName( summaryCase->nativeCaseName(), + allAutoShortNames, + RimCaseDisplayNameTools::CASE_SHORT_NAME_LENGTH ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/Tools/RiaEnsembleNameTools.h b/ApplicationLibCode/Application/Tools/RiaEnsembleNameTools.h index ddf7290f79..d085814b54 100644 --- a/ApplicationLibCode/Application/Tools/RiaEnsembleNameTools.h +++ b/ApplicationLibCode/Application/Tools/RiaEnsembleNameTools.h @@ -19,9 +19,12 @@ #pragma once #include + #include #include +class RimSummaryCase; + //================================================================================================== // //================================================================================================== @@ -49,6 +52,9 @@ class RiaEnsembleNameTools static std::vector groupFilesByEnsemble( const QStringList& fileNames, EnsembleGroupingMode groupingMode ); + static QString uniqueShortNameForEnsembleCase( RimSummaryCase* summaryCase ); + static QString uniqueShortNameForSummaryCase( RimSummaryCase* summaryCase ); + private: static QStringList findUniqueEnsembleNames( const QStringList& fileNames, const std::vector& fileNameComponents, diff --git a/ApplicationLibCode/Application/Tools/RiaFieldHandleTools.cpp b/ApplicationLibCode/Application/Tools/RiaFieldHandleTools.cpp index 55517ec38e..c65dae93a7 100644 --- a/ApplicationLibCode/Application/Tools/RiaFieldHandleTools.cpp +++ b/ApplicationLibCode/Application/Tools/RiaFieldHandleTools.cpp @@ -30,7 +30,7 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaFieldhandleTools::disableWriteAndSetFieldHidden( caf::PdmFieldHandle* fieldHandle ) +void RiaFieldHandleTools::disableWriteAndSetFieldHidden( caf::PdmFieldHandle* fieldHandle ) { CVF_ASSERT( fieldHandle ); @@ -48,3 +48,19 @@ void RiaFieldhandleTools::disableWriteAndSetFieldHidden( caf::PdmFieldHandle* fi fieldHandle->xmlCapability()->setIOWritable( false ); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaFieldHandleTools::updateOverrideStateAndLabel( caf::PdmFieldHandle* fieldHandle, + bool isOverridden, + const QString& toolTip ) +{ + // Get the label text as given by the init_field macro + QString labelText = fieldHandle->uiCapability()->uiName( fieldHandle->uiCapability()->uiConfigNameForStaticData() ); + + if ( isOverridden ) labelText += " (overridden)"; + fieldHandle->uiCapability()->setUiToolTip( toolTip ); + fieldHandle->uiCapability()->setUiName( labelText ); + fieldHandle->uiCapability()->setUiReadOnly( isOverridden ); +} diff --git a/ApplicationLibCode/Application/Tools/RiaFieldHandleTools.h b/ApplicationLibCode/Application/Tools/RiaFieldHandleTools.h index 0eaa0913b4..4029b3a313 100644 --- a/ApplicationLibCode/Application/Tools/RiaFieldHandleTools.h +++ b/ApplicationLibCode/Application/Tools/RiaFieldHandleTools.h @@ -19,6 +19,8 @@ #pragma once +#include + namespace caf { class PdmFieldHandle; @@ -27,8 +29,9 @@ class PdmFieldHandle; //================================================================================================== // //================================================================================================== -class RiaFieldhandleTools +class RiaFieldHandleTools { public: static void disableWriteAndSetFieldHidden( caf::PdmFieldHandle* fieldHandle ); + static void updateOverrideStateAndLabel( caf::PdmFieldHandle* fieldHandle, bool isOverridden, const QString& toolTip ); }; diff --git a/ApplicationLibCode/Application/Tools/RiaGitDiff.cpp b/ApplicationLibCode/Application/Tools/RiaGitDiff.cpp index 2a86a6bfe3..332e9712f4 100644 --- a/ApplicationLibCode/Application/Tools/RiaGitDiff.cpp +++ b/ApplicationLibCode/Application/Tools/RiaGitDiff.cpp @@ -23,6 +23,10 @@ #include #include +// Disable deprecation warning for QProcess::start() +#ifdef _MSC_VER +#pragma warning( disable : 4996 ) +#endif //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/Tools/RiaImageFileCompare.cpp b/ApplicationLibCode/Application/Tools/RiaImageFileCompare.cpp index 3667f596bf..66c86da047 100644 --- a/ApplicationLibCode/Application/Tools/RiaImageFileCompare.cpp +++ b/ApplicationLibCode/Application/Tools/RiaImageFileCompare.cpp @@ -19,6 +19,11 @@ #include "RiaImageFileCompare.h" #include +// Disable deprecation warning for QProcess::start() +#ifdef _MSC_VER +#pragma warning( disable : 4996 ) +#endif + //================================================================================================== // // diff --git a/ApplicationLibCode/Application/Tools/RiaImportEclipseCaseTools.cpp b/ApplicationLibCode/Application/Tools/RiaImportEclipseCaseTools.cpp index 22b8dd29dd..211199f370 100644 --- a/ApplicationLibCode/Application/Tools/RiaImportEclipseCaseTools.cpp +++ b/ApplicationLibCode/Application/Tools/RiaImportEclipseCaseTools.cpp @@ -20,8 +20,8 @@ #include "ApplicationCommands/RicShowMainWindowFeature.h" +#include "PlotBuilderCommands/RicSummaryPlotBuilder.h" #include "SummaryPlotCommands/RicNewSummaryCurveFeature.h" -#include "SummaryPlotCommands/RicNewSummaryPlotFeature.h" #include "SummaryPlotCommands/RicSummaryPlotFeatureImpl.h" #include "RiaApplication.h" @@ -52,9 +52,7 @@ #include "RimSummaryCaseMainCollection.h" #include "RimSummaryCurve.h" #include "RimSummaryCurveCollection.h" -#include "RimSummaryCurveFilter.h" #include "RimSummaryPlot.h" -#include "RimSummaryPlotCollection.h" #include "RimWellLogRftCurve.h" #include "Riu3DMainWindowTools.h" @@ -197,10 +195,7 @@ bool RiaImportEclipseCaseTools::openEclipseCasesFromFile( const QStringList& if ( !newSumCases.empty() ) { - RimSummaryPlotCollection* summaryPlotColl = project->mainPlotCollection()->summaryPlotCollection(); - - RicSummaryPlotFeatureImpl::ensureAtLeastOnePlot( summaryPlotColl, newSumCases.front() ); - + RicSummaryPlotBuilder::createAndAppendDefaultSummaryMultiPlot( { newSumCases.front() }, {} ); RiuPlotMainWindowTools::setExpanded( newSumCases.front() ); } } @@ -372,7 +367,7 @@ int RiaImportEclipseCaseTools::openEclipseCaseShowTimeStepFilterImpl( const QStr if ( RiaGuiApplication::isRunning() ) { - RiuMainWindow::instance()->selectAsCurrentItem( riv->cellResult() ); + if ( RiuMainWindow::instance() ) RiuMainWindow::instance()->selectAsCurrentItem( riv->cellResult() ); } } else @@ -484,7 +479,8 @@ bool RiaImportEclipseCaseTools::addEclipseCases( const QStringList& fil if ( RiaGuiApplication::isRunning() && gridCaseGroup && !gridCaseGroup->statisticsCaseCollection()->reservoirs.empty() ) { - RiuMainWindow::instance()->selectAsCurrentItem( gridCaseGroup->statisticsCaseCollection()->reservoirs[0] ); + if ( RiuMainWindow::instance() ) + RiuMainWindow::instance()->selectAsCurrentItem( gridCaseGroup->statisticsCaseCollection()->reservoirs[0] ); } return true; diff --git a/ApplicationLibCode/Application/Tools/RiaOptionItemFactory.cpp b/ApplicationLibCode/Application/Tools/RiaOptionItemFactory.cpp index 265efca9c4..35d3f9f61c 100644 --- a/ApplicationLibCode/Application/Tools/RiaOptionItemFactory.cpp +++ b/ApplicationLibCode/Application/Tools/RiaOptionItemFactory.cpp @@ -90,7 +90,7 @@ caf::PdmOptionItemInfo case RifEclipseSummaryAddress::SUMMARY_REGION_2_REGION: iconText = ":/summary/components/images/region-region.svg"; break; - case RifEclipseSummaryAddress::SUMMARY_WELL_GROUP: + case RifEclipseSummaryAddress::SUMMARY_GROUP: iconText = ":/summary/components/images/group.svg"; break; case RifEclipseSummaryAddress::SUMMARY_WELL: diff --git a/ApplicationLibCode/Application/Tools/RiaProjectModifier.cpp b/ApplicationLibCode/Application/Tools/RiaProjectModifier.cpp index 30df42387b..3316ec4acc 100644 --- a/ApplicationLibCode/Application/Tools/RiaProjectModifier.cpp +++ b/ApplicationLibCode/Application/Tools/RiaProjectModifier.cpp @@ -169,7 +169,7 @@ void RiaProjectModifier::replaceSourceCases( RimProject* project ) if ( groupIdToReplace == caseGroup->groupId() ) { RimCaseCollection* caseCollection = caseGroup->caseCollection; - caseCollection->reservoirs.deleteAllChildObjects(); + caseCollection->reservoirs.deleteChildren(); for ( QString fileName : item.second ) { diff --git a/ApplicationLibCode/Application/Tools/RiaQDateTimeTools.cpp b/ApplicationLibCode/Application/Tools/RiaQDateTimeTools.cpp index bf398267de..a3ed7e6d32 100644 --- a/ApplicationLibCode/Application/Tools/RiaQDateTimeTools.cpp +++ b/ApplicationLibCode/Application/Tools/RiaQDateTimeTools.cpp @@ -22,7 +22,6 @@ #include #include -#include "cafAppEnum.h" #include "cafPdmUiItem.h" #include @@ -41,47 +40,6 @@ const DateTimeSpan RiaQDateTimeTools::TIMESPAN_HALFYEAR = DateTimeSpan( 0, 6, 0 const DateTimeSpan RiaQDateTimeTools::TIMESPAN_YEAR = DateTimeSpan( 1, 0, 0 ); const DateTimeSpan RiaQDateTimeTools::TIMESPAN_DECADE = DateTimeSpan( 10, 0, 0 ); -namespace caf -{ -// clang-format off - -template <> -void caf::AppEnum::setUp() -{ - addItem( RiaQDateTimeTools::DATE_FORMAT_NONE, "NO_DATE", "No Date" ); - addItem( RiaQDateTimeTools::DATE_FORMAT_YEAR, "YEAR", "Year Only" ); - addItem( RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH, "YEAR_MONTH", "Year and Month" ); - addItem( RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH_DAY, "YEAR_MONTH_DAY", "Year, Month and Day" ); - setDefault( RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH_DAY ); -} - -template <> -void caf::AppEnum::setUp() -{ - addItem( RiaQDateTimeTools::TimeFormatComponents::TIME_FORMAT_NONE, "NO_TIME", "No Time of Day" ); - addItem( RiaQDateTimeTools::TimeFormatComponents::TIME_FORMAT_HOUR, "HOUR", "Hour Only" ); - addItem( RiaQDateTimeTools::TimeFormatComponents::TIME_FORMAT_HOUR_MINUTE, "HOUR_MINUTE", "Hour and Minute" ); - addItem( RiaQDateTimeTools::TimeFormatComponents::TIME_FORMAT_HOUR_MINUTE_SECOND, "HOUR_MINUTE_SECONDS", "Hour, Minutes and Seconds" ); - setDefault( RiaQDateTimeTools::TimeFormatComponents::TIME_FORMAT_NONE ); -} - -template <> -void caf::AppEnum::setUp() -{ - addItem( RiaQDateTimeTools::DateTimePeriod::NONE, "NONE", "None" ); - addItem( RiaQDateTimeTools::DateTimePeriod::DAY, "DAY", "Day" ); - addItem( RiaQDateTimeTools::DateTimePeriod::WEEK, "WEEK", "Week" ); - addItem( RiaQDateTimeTools::DateTimePeriod::MONTH, "MONTH", "Month" ); - addItem( RiaQDateTimeTools::DateTimePeriod::QUARTER, "QUARTER", "Quarter" ); - addItem( RiaQDateTimeTools::DateTimePeriod::HALFYEAR, "HALFYEAR", "Half Year" ); - addItem( RiaQDateTimeTools::DateTimePeriod::YEAR, "YEAR", "Year" ); - addItem( RiaQDateTimeTools::DateTimePeriod::DECADE, "DECADE", "Decade" ); - setDefault( RiaQDateTimeTools::DateTimePeriod::NONE ); -} - -// clang-format on -} // namespace caf - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -198,7 +156,7 @@ QDateTime RiaQDateTimeTools::subtractSpan( const QDateTime& dt, DateTimeSpan spa //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QDateTime RiaQDateTimeTools::addPeriod( const QDateTime& dt, RiaQDateTimeTools::DateTimePeriod period ) +QDateTime RiaQDateTimeTools::addPeriod( const QDateTime& dt, RiaDefines::DateTimePeriod period ) { return addSpan( dt, timeSpan( period ) ); } @@ -206,11 +164,23 @@ QDateTime RiaQDateTimeTools::addPeriod( const QDateTime& dt, RiaQDateTimeTools:: //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QDateTime RiaQDateTimeTools::subtractPeriod( const QDateTime& dt, RiaQDateTimeTools::DateTimePeriod period ) +QDateTime RiaQDateTimeTools::subtractPeriod( const QDateTime& dt, RiaDefines::DateTimePeriod period ) { return subtractSpan( dt, timeSpan( period ) ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QDateTime RiaQDateTimeTools::createDateTime( const QDate& date ) +{ +#if QT_VERSION >= QT_VERSION_CHECK( 5, 14, 0 ) + return date.startOfDay(); +#else + return QDateTime( date, QTime( 0, 0 ) ); +#endif +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -240,7 +210,7 @@ QDateTime RiaQDateTimeTools::createUtcDateTime() //-------------------------------------------------------------------------------------------------- QDateTime RiaQDateTimeTools::createUtcDateTime( const QDate& date ) { - auto qdt = QDateTime( date ); + auto qdt = createDateTime( date ); qdt.setTimeSpec( currentTimeSpec() ); return qdt; } @@ -276,23 +246,23 @@ bool RiaQDateTimeTools::lessThan( const QDateTime& dt1, const QDateTime& dt2 ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const DateTimeSpan RiaQDateTimeTools::timeSpan( RiaQDateTimeTools::DateTimePeriod period ) +const DateTimeSpan RiaQDateTimeTools::timeSpan( RiaDefines::DateTimePeriod period ) { switch ( period ) { - case RiaQDateTimeTools::DateTimePeriod::DAY: + case RiaDefines::DateTimePeriod::DAY: return TIMESPAN_DAY; - case RiaQDateTimeTools::DateTimePeriod::WEEK: + case RiaDefines::DateTimePeriod::WEEK: return TIMESPAN_WEEK; - case RiaQDateTimeTools::DateTimePeriod::MONTH: + case RiaDefines::DateTimePeriod::MONTH: return TIMESPAN_MONTH; - case RiaQDateTimeTools::DateTimePeriod::QUARTER: + case RiaDefines::DateTimePeriod::QUARTER: return TIMESPAN_QUARTER; - case RiaQDateTimeTools::DateTimePeriod::HALFYEAR: + case RiaDefines::DateTimePeriod::HALFYEAR: return TIMESPAN_HALFYEAR; - case RiaQDateTimeTools::DateTimePeriod::YEAR: + case RiaDefines::DateTimePeriod::YEAR: return TIMESPAN_YEAR; - case RiaQDateTimeTools::DateTimePeriod::DECADE: + case RiaDefines::DateTimePeriod::DECADE: return TIMESPAN_DECADE; } CVF_ASSERT( false ); @@ -302,7 +272,7 @@ const DateTimeSpan RiaQDateTimeTools::timeSpan( RiaQDateTimeTools::DateTimePerio //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QDateTime RiaQDateTimeTools::truncateTime( const QDateTime& dt, RiaQDateTimeTools::DateTimePeriod period ) +QDateTime RiaQDateTimeTools::truncateTime( const QDateTime& dt, RiaDefines::DateTimePeriod period ) { int y = dt.date().year(); int m = dt.date().month(); @@ -311,19 +281,19 @@ QDateTime RiaQDateTimeTools::truncateTime( const QDateTime& dt, RiaQDateTimeTool switch ( period ) { - case RiaQDateTimeTools::DateTimePeriod::DAY: + case RiaDefines::DateTimePeriod::DAY: return createUtcDateTime( QDate( y, m, d ) ); - case RiaQDateTimeTools::DateTimePeriod::WEEK: + case RiaDefines::DateTimePeriod::WEEK: return createUtcDateTime( QDate( y, m, d ).addDays( -dow + 1 ) ); - case RiaQDateTimeTools::DateTimePeriod::MONTH: + case RiaDefines::DateTimePeriod::MONTH: return createUtcDateTime( QDate( y, m, 1 ) ); - case RiaQDateTimeTools::DateTimePeriod::QUARTER: + case RiaDefines::DateTimePeriod::QUARTER: return createUtcDateTime( QDate( y, ( ( m - 1 ) / 3 ) * 3 + 1, 1 ) ); - case RiaQDateTimeTools::DateTimePeriod::HALFYEAR: + case RiaDefines::DateTimePeriod::HALFYEAR: return createUtcDateTime( QDate( y, ( ( m - 1 ) / 6 ) * 6 + 1, 1 ) ); - case RiaQDateTimeTools::DateTimePeriod::YEAR: + case RiaDefines::DateTimePeriod::YEAR: return createUtcDateTime( QDate( y, 1, 1 ) ); - case RiaQDateTimeTools::DateTimePeriod::DECADE: + case RiaDefines::DateTimePeriod::DECADE: return createUtcDateTime( QDate( ( y / 10 ) * 10, 1, 1 ) ); } CVF_ASSERT( false ); @@ -333,13 +303,13 @@ QDateTime RiaQDateTimeTools::truncateTime( const QDateTime& dt, RiaQDateTimeTool //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RiaQDateTimeTools::dateTimePeriods() +std::vector RiaQDateTimeTools::dateTimePeriods() { - std::vector allPeriods; + std::vector allPeriods; - for ( size_t i = 0; i < DateTimePeriodEnum::size(); i++ ) + for ( size_t i = 0; i < RiaDefines::DateTimePeriodEnum::size(); i++ ) { - allPeriods.push_back( DateTimePeriodEnum::fromIndex( i ) ); + allPeriods.push_back( RiaDefines::DateTimePeriodEnum::fromIndex( i ) ); } return allPeriods; @@ -348,9 +318,9 @@ std::vector RiaQDateTimeTools::dateTimePeriod //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RiaQDateTimeTools::dateTimePeriodName( RiaQDateTimeTools::DateTimePeriod period ) +QString RiaQDateTimeTools::dateTimePeriodName( RiaDefines::DateTimePeriod period ) { - return DateTimePeriodEnum::uiText( period ); + return RiaDefines::DateTimePeriodEnum::uiText( period ); } //-------------------------------------------------------------------------------------------------- @@ -471,14 +441,17 @@ std::vector RiaQDateTimeTools::supportedTimeFormats() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RiaQDateTimeTools::dateFormatString( const QString& fullDateFormat, DateFormatComponents dateComponents ) +QString RiaQDateTimeTools::dateFormatString( const QString& fullDateFormat, RiaDefines::DateFormatComponents dateComponents ) { - if ( dateComponents == DATE_FORMAT_NONE ) return ""; + if ( dateComponents == RiaDefines::DateFormatComponents::DATE_FORMAT_NONE ) return ""; + + auto enumValue = static_cast::type>( dateComponents ); + if ( enumValue < 0 ) return ""; QStringList allVariants = fullDateFormat.split( ";" ); - if ( static_cast( dateComponents ) < allVariants.size() ) + if ( enumValue < allVariants.size() ) { - return allVariants[dateComponents]; + return allVariants[enumValue]; } CVF_ASSERT( false && "Date format string is malformed" ); return ""; @@ -487,9 +460,9 @@ QString RiaQDateTimeTools::dateFormatString( const QString& fullDateFormat, Date //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RiaQDateTimeTools::timeFormatString( const QString& fullTimeFormat, TimeFormatComponents timeComponents ) +QString RiaQDateTimeTools::timeFormatString( const QString& fullTimeFormat, RiaDefines::TimeFormatComponents timeComponents ) { - if ( timeComponents == TimeFormatComponents::TIME_FORMAT_NONE ) return ""; + if ( timeComponents == RiaDefines::TimeFormatComponents::TIME_FORMAT_NONE ) return ""; QStringList allVariants = fullTimeFormat.split( ";" ); if ( static_cast( timeComponents ) < allVariants.size() ) diff --git a/ApplicationLibCode/Application/Tools/RiaQDateTimeTools.h b/ApplicationLibCode/Application/Tools/RiaQDateTimeTools.h index 9dd9f88b15..2da11175f4 100644 --- a/ApplicationLibCode/Application/Tools/RiaQDateTimeTools.h +++ b/ApplicationLibCode/Application/Tools/RiaQDateTimeTools.h @@ -18,17 +18,12 @@ #pragma once -#include "cafAppEnum.h" +#include "RiaDateTimeDefines.h" -#include -#include +#include "cafAppEnum.h" #include -#include -#include -#include -#include #include #include @@ -47,49 +42,7 @@ class PdmOptionItemInfo; //================================================================================================== class RiaQDateTimeTools { - static const DateTimeSpan TIMESPAN_DAY; - static const DateTimeSpan TIMESPAN_WEEK; - static const DateTimeSpan TIMESPAN_MONTH; - static const DateTimeSpan TIMESPAN_QUARTER; - static const DateTimeSpan TIMESPAN_HALFYEAR; - static const DateTimeSpan TIMESPAN_YEAR; - static const DateTimeSpan TIMESPAN_DECADE; - public: - enum DateFormatComponents - { - DATE_FORMAT_UNSPECIFIED = -2, - DATE_FORMAT_NONE = -1, - DATE_FORMAT_YEAR = 0, - DATE_FORMAT_YEAR_MONTH, - DATE_FORMAT_YEAR_MONTH_DAY, - DATE_FORMAT_SIZE - }; - - enum class TimeFormatComponents - { - TIME_FORMAT_UNSPECIFIED = -2, - TIME_FORMAT_NONE = -1, - TIME_FORMAT_HOUR, - TIME_FORMAT_HOUR_MINUTE, - TIME_FORMAT_HOUR_MINUTE_SECOND, - TIME_FORMAT_HOUR_MINUTE_SECOND_MILLISECOND, - TIME_FORMAT_SIZE - }; - - enum class DateTimePeriod - { - NONE = -1, - DAY, - WEEK, - MONTH, - QUARTER, - HALFYEAR, - YEAR, - DECADE - }; - using DateTimePeriodEnum = caf::AppEnum; - static Qt::TimeSpec currentTimeSpec(); static QDateTime fromString( const QString& dateString, const QString& format ); @@ -101,8 +54,10 @@ class RiaQDateTimeTools static QDateTime addYears( const QDateTime& dt, double years ); static QDateTime addSpan( const QDateTime& dt, DateTimeSpan span ); static QDateTime subtractSpan( const QDateTime& dt, DateTimeSpan span ); - static QDateTime addPeriod( const QDateTime& dt, RiaQDateTimeTools::DateTimePeriod period ); - static QDateTime subtractPeriod( const QDateTime& dt, RiaQDateTimeTools::DateTimePeriod period ); + static QDateTime addPeriod( const QDateTime& dt, RiaDefines::DateTimePeriod period ); + static QDateTime subtractPeriod( const QDateTime& dt, RiaDefines::DateTimePeriod period ); + + static QDateTime createDateTime( const QDate& date ); static QDateTime epoch(); @@ -113,11 +68,11 @@ class RiaQDateTimeTools static bool lessThan( const QDateTime& dt1, const QDateTime& dt2 ); - static const DateTimeSpan timeSpan( RiaQDateTimeTools::DateTimePeriod period ); - static QDateTime truncateTime( const QDateTime& dt, RiaQDateTimeTools::DateTimePeriod period ); + static const DateTimeSpan timeSpan( RiaDefines::DateTimePeriod period ); + static QDateTime truncateTime( const QDateTime& dt, RiaDefines::DateTimePeriod period ); - static std::vector dateTimePeriods(); - static QString dateTimePeriodName( RiaQDateTimeTools::DateTimePeriod period ); + static std::vector dateTimePeriods(); + static QString dateTimePeriodName( RiaDefines::DateTimePeriod period ); // This function uses C locale to make sure the text representation of a date is stable, independent of the locale // settings on local machine. Required for stable regression testing. @@ -129,16 +84,24 @@ class RiaQDateTimeTools static std::vector supportedDateFormats(); static std::vector supportedTimeFormats(); - static QString - dateFormatString( const QString& fullDateFormat, - DateFormatComponents dateComponents = DateFormatComponents::DATE_FORMAT_YEAR_MONTH_DAY ); - static QString - timeFormatString( const QString& fullTimeFormat, - TimeFormatComponents timeComponents = TimeFormatComponents::TIME_FORMAT_HOUR_MINUTE_SECOND ); + static QString dateFormatString( + const QString& fullDateFormat, + RiaDefines::DateFormatComponents dateComponents = RiaDefines::DateFormatComponents::DATE_FORMAT_YEAR_MONTH_DAY ); + static QString timeFormatString( const QString& fullTimeFormat, + RiaDefines::TimeFormatComponents timeComponents = + RiaDefines::TimeFormatComponents::TIME_FORMAT_HOUR_MINUTE_SECOND ); static QList createOptionItems( const std::vector& timeSteps ); private: + static const DateTimeSpan TIMESPAN_DAY; + static const DateTimeSpan TIMESPAN_WEEK; + static const DateTimeSpan TIMESPAN_MONTH; + static const DateTimeSpan TIMESPAN_QUARTER; + static const DateTimeSpan TIMESPAN_HALFYEAR; + static const DateTimeSpan TIMESPAN_YEAR; + static const DateTimeSpan TIMESPAN_DECADE; + static quint64 secondsInDay(); static quint64 secondsInYear(); }; diff --git a/ApplicationLibCode/Application/Tools/RiaRegressionTest.cpp b/ApplicationLibCode/Application/Tools/RiaRegressionTest.cpp index 1f588577b3..731e5a85aa 100644 --- a/ApplicationLibCode/Application/Tools/RiaRegressionTest.cpp +++ b/ApplicationLibCode/Application/Tools/RiaRegressionTest.cpp @@ -22,12 +22,21 @@ #include "cafPdmUiFilePathEditor.h" #include "cafPdmUiTextEditor.h" +template <> +void caf::AppEnum::setUp() +{ + addItem( RiaRegressionTest::PlotEngine::USE_QWT, "USE_QWT", "Use Qwt" ); + addItem( RiaRegressionTest::PlotEngine::USER_QTCHARTS, "USER_QTCHARTS", "Use QtCharts" ); + addItem( RiaRegressionTest::PlotEngine::NONE, "NONE", "None" ); + setDefault( RiaRegressionTest::PlotEngine::NONE ); +} + CAF_PDM_SOURCE_INIT( RiaRegressionTest, "RiaRegressionTest" ); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiaRegressionTest::RiaRegressionTest( void ) +RiaRegressionTest::RiaRegressionTest() { CAF_PDM_InitFieldNoDefault( &folderContainingCompareTool, "workingFolder", @@ -53,19 +62,13 @@ RiaRegressionTest::RiaRegressionTest( void ) "" ); folderContainingGitTool.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( ®ressionTestFolder, "regressionTestFolder", "Regression Test Folder", "", "", "" ); + CAF_PDM_InitFieldNoDefault( ®ressionTestFolder, "regressionTestFolder", "Regression Test Folder" ); regressionTestFolder.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &showInteractiveDiffImages, "showInteractiveDiffImages", false, "Interactive Diff Images", "", "", "" ); - CAF_PDM_InitField( &useOpenMPForGeometryCreation, - "useOpenMPForGeometryCreation", - true, - "Use OpenMP For Geometry Creation", - "", - "", - "" ); + CAF_PDM_InitField( &showInteractiveDiffImages, "showInteractiveDiffImages", false, "Interactive Diff Images" ); + CAF_PDM_InitField( &useOpenMPForGeometryCreation, "useOpenMPForGeometryCreation", true, "Use OpenMP For Geometry Creation" ); - CAF_PDM_InitField( &openReportInBrowser, "openReportInBrowser", false, "Open Generated Report in Browser", "", "", "" ); + CAF_PDM_InitField( &openReportInBrowser, "openReportInBrowser", false, "Open Generated Report in Browser" ); CAF_PDM_InitFieldNoDefault( &testFilter, "testFilter", @@ -76,27 +79,16 @@ RiaRegressionTest::RiaRegressionTest( void ) "" ); testFilter.uiCapability()->setUiEditorTypeName( caf::PdmUiTextEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &appendTestsAfterTestFilter, - "appendTestsAfterTestFilter", - false, - "Append All Tests After Test Filter", - "", - "", - "" ); - - CAF_PDM_InitField( &invalidateExternalFilePaths, - "invalidateExternalFilePaths", - false, - "Invalidate External File Paths", - "", - "", - "" ); + CAF_PDM_InitField( &appendTestsAfterTestFilter, "appendTestsAfterTestFilter", false, "Append All Tests After Test Filter" ); + + CAF_PDM_InitField( &invalidateExternalFilePaths, "invalidateExternalFilePaths", false, "Invalidate External File Paths" ); + CAF_PDM_InitFieldNoDefault( &overridePlotEngine, "forcePlotEngine", "Force Plot Engine" ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiaRegressionTest::~RiaRegressionTest( void ) +RiaRegressionTest::~RiaRegressionTest() { } @@ -126,7 +118,7 @@ void RiaRegressionTest::defineEditorAttribute( const caf::PdmFieldHandle* field, if ( field == &folderContainingDiffTool || field == &folderContainingCompareTool || field == ®ressionTestFolder || field == &folderContainingGitTool ) { - caf::PdmUiFilePathEditorAttribute* myAttr = dynamic_cast( attribute ); + auto* myAttr = dynamic_cast( attribute ); if ( myAttr ) { myAttr->m_selectDirectory = true; diff --git a/ApplicationLibCode/Application/Tools/RiaRegressionTest.h b/ApplicationLibCode/Application/Tools/RiaRegressionTest.h index 2c05962587..e99b3b0c8a 100644 --- a/ApplicationLibCode/Application/Tools/RiaRegressionTest.h +++ b/ApplicationLibCode/Application/Tools/RiaRegressionTest.h @@ -27,8 +27,16 @@ class RiaRegressionTest : public caf::PdmObject CAF_PDM_HEADER_INIT; public: - RiaRegressionTest( void ); - ~RiaRegressionTest( void ) override; + enum class PlotEngine + { + USE_QWT, + USER_QTCHARTS, + NONE + }; + +public: + RiaRegressionTest(); + ~RiaRegressionTest() override; void writeSettingsToApplicationStore() const; void readSettingsFromApplicationStore(); @@ -45,6 +53,8 @@ class RiaRegressionTest : public caf::PdmObject caf::PdmField appendTestsAfterTestFilter; caf::PdmField invalidateExternalFilePaths; + caf::PdmField> overridePlotEngine; + protected: void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, diff --git a/ApplicationLibCode/Application/Tools/RiaRegressionTestRunner.cpp b/ApplicationLibCode/Application/Tools/RiaRegressionTestRunner.cpp index f58d1249e7..f5285f52f4 100644 --- a/ApplicationLibCode/Application/Tools/RiaRegressionTestRunner.cpp +++ b/ApplicationLibCode/Application/Tools/RiaRegressionTestRunner.cpp @@ -26,6 +26,7 @@ #include "RiaProjectModifier.h" #include "RiaRegressionTest.h" #include "RiaTextFileCompare.h" +#include "RiaTextStringTools.h" #include "RicfCommandFileExecutor.h" @@ -42,6 +43,7 @@ #include "ExportCommands/RicSnapshotAllPlotsToFileFeature.h" #include "ExportCommands/RicSnapshotAllViewsToFileFeature.h" +#include "cafMemoryInspector.h" #include "cafUtils.h" #include @@ -69,6 +71,8 @@ const QString reportFileName = "ResInsightRegressionTestReport.html"; const QString commandFileFilter = "commandfile-*"; }; // namespace RegTestNames +RiaRegressionTestRunner* RiaRegressionTestRunner::sm_singleton = nullptr; + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -79,6 +83,7 @@ void logInfoTextWithTimeInSeconds( const QElapsedTimer& time, const QString& msg QString timeText = QString( "(%1 s) " ).arg( timeRunning, 0, 'f', 1 ); RiaLogging::info( timeText + msg ); + QApplication::processEvents(); } //-------------------------------------------------------------------------------------------------- @@ -95,8 +100,25 @@ RiaRegressionTestRunner::RiaRegressionTestRunner() //-------------------------------------------------------------------------------------------------- RiaRegressionTestRunner* RiaRegressionTestRunner::instance() { - static RiaRegressionTestRunner* singleton = new RiaRegressionTestRunner; - return singleton; + CAF_ASSERT( sm_singleton ); + return sm_singleton; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaRegressionTestRunner::createSingleton() +{ + if ( !sm_singleton ) sm_singleton = new RiaRegressionTestRunner; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaRegressionTestRunner::deleteSingleton() +{ + if ( sm_singleton ) delete sm_singleton; + sm_singleton = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -108,6 +130,8 @@ void RiaRegressionTestRunner::runRegressionTest() QString currentApplicationPath = QDir::currentPath(); + std::vector> memoryUsagePerTest; + RiaRegressionTest regressionTestConfig; regressionTestConfig.readSettingsFromApplicationStore(); if ( !regressionTestConfig.folderContainingCompareTool().isEmpty() ) @@ -195,6 +219,9 @@ void RiaRegressionTestRunner::runRegressionTest() if ( !projectFileName.isEmpty() ) { + QElapsedTimer timerForOneTest; + timerForOneTest.start(); + cvf::ref projectModifier; if ( regressionTestConfig.invalidateExternalFilePaths ) { @@ -220,7 +247,18 @@ void RiaRegressionTestRunner::runRegressionTest() RicSnapshotAllPlotsToFileFeature::exportSnapshotOfPlotsIntoFolder( fullPathGeneratedFolder ); + uint64_t usedMemoryBeforeClose = caf::MemoryInspector::getApplicationPhysicalMemoryUsageMiB(); + app->closeProject(); + + QApplication::processEvents(); + + auto testDuration = timerForOneTest.elapsed() / 1000.0; + + uint64_t usedMemoryAfterClose = caf::MemoryInspector::getApplicationPhysicalMemoryUsageMiB(); + + auto folderName = folderFileInfo.baseName(); + memoryUsagePerTest.push_back( { folderName, testDuration, usedMemoryBeforeClose, usedMemoryAfterClose } ); } else { @@ -255,6 +293,15 @@ void RiaRegressionTestRunner::runRegressionTest() logInfoTextWithTimeInSeconds( timeStamp, "Completed test :" + testCaseFolder.absolutePath() ); } + // Profiling logging + RiaLogging::info( "| Duration [sec] | Before Close [MB] | After Close [MB] | Name " ); + for ( const auto& [name, testDuration, beforeMemory, afterMemory] : memoryUsagePerTest ) + { + auto timeText = QString( "(%1 s) " ).arg( testDuration, 5, 'f', 1 ); + auto logInfo = QString( "%1 %2 %3 %4" ).arg( timeText ).arg( beforeMemory ).arg( afterMemory ).arg( name ); + RiaLogging::info( logInfo ); + } + // Invoke git diff { @@ -519,7 +566,7 @@ QString RiaRegressionTestRunner::diff2htmlHeaderText( const QString& testRootPat QString html; QString oldProjPath = QDir::fromNativeSeparators( testRootPath ); - QStringList pathFolders = oldProjPath.split( "/", QString::KeepEmptyParts ); + QStringList pathFolders = oldProjPath.split( "/" ); QString path; for ( const auto& f : pathFolders ) @@ -592,7 +639,7 @@ void RiaRegressionTestRunner::executeRegressionTests() testConfig.readSettingsFromApplicationStore(); QString testPath = testConfig.regressionTestFolder(); - QStringList testFilter = testConfig.testFilter().split( ";", QString::SkipEmptyParts ); + QStringList testFilter = RiaTextStringTools::splitSkipEmptyParts( testConfig.testFilter(), ";" ); if ( testConfig.appendTestsAfterTestFilter ) { @@ -643,6 +690,14 @@ bool RiaRegressionTestRunner::useOpenMPForGeometryCreation() const return m_regressionTestSettings.useOpenMPForGeometryCreation; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaRegressionTest::PlotEngine RiaRegressionTestRunner::overridePlotEngine() const +{ + return m_regressionTestSettings.overridePlotEngine(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/Tools/RiaRegressionTestRunner.h b/ApplicationLibCode/Application/Tools/RiaRegressionTestRunner.h index 0ee6005a8b..cf10faa09b 100644 --- a/ApplicationLibCode/Application/Tools/RiaRegressionTestRunner.h +++ b/ApplicationLibCode/Application/Tools/RiaRegressionTestRunner.h @@ -25,7 +25,6 @@ #include class QDir; -class RiaRegressionTest; //================================================================================================== // @@ -35,12 +34,17 @@ class RiaRegressionTestRunner public: static RiaRegressionTestRunner* instance(); + static void createSingleton(); + static void deleteSingleton(); + void executeRegressionTests( const QString& regressionTestPath, const QStringList& testFilter ); void executeRegressionTests(); bool isRunningRegressionTests() const; bool useOpenMPForGeometryCreation() const; + RiaRegressionTest::PlotEngine overridePlotEngine() const; + static void updateRegressionTest( const QString& testRootPath ); static void setDefaultSnapshotSizeFor3dViews(); @@ -72,4 +76,6 @@ class RiaRegressionTestRunner bool m_appendAllTestsAfterLastItemInFilter; bool m_runningRegressionTests; RiaRegressionTest m_regressionTestSettings; + + static RiaRegressionTestRunner* sm_singleton; }; diff --git a/ApplicationLibCode/Application/Tools/RiaSimWellBranchTools.cpp b/ApplicationLibCode/Application/Tools/RiaSimWellBranchTools.cpp index bf85d41f73..630d50d011 100644 --- a/ApplicationLibCode/Application/Tools/RiaSimWellBranchTools.cpp +++ b/ApplicationLibCode/Application/Tools/RiaSimWellBranchTools.cpp @@ -18,12 +18,10 @@ #include "RiaSimWellBranchTools.h" -#include "RiaApplication.h" - #include "RigEclipseCaseData.h" #include "RimEclipseCase.h" -#include "RimProject.h" +#include "RimEclipseCaseTools.h" #include "RimWellPlotTools.h" #include "cafPdmUiOrdering.h" @@ -34,12 +32,7 @@ std::vector RiaSimWellBranchTools::simulationWellBranches( const QString& simWellName, bool useAutoDetectionOfBranches ) { - RiaApplication* app = RiaApplication::instance(); - RimProject* proj = app->project(); - - // Find first case containing the specified simulation well - std::vector simCases; - proj->descendantsIncludingThisOfType( simCases ); + std::vector simCases = RimEclipseCaseTools::eclipseCases(); auto caseItr = std::find_if( simCases.begin(), simCases.end(), [&simWellName]( const RimEclipseCase* eclCase ) { const auto& eclData = eclCase->eclipseCaseData(); diff --git a/ApplicationLibCode/Application/Tools/RiaSummaryCurveAnalyzer.cpp b/ApplicationLibCode/Application/Tools/RiaSummaryAddressAnalyzer.cpp similarity index 55% rename from ApplicationLibCode/Application/Tools/RiaSummaryCurveAnalyzer.cpp rename to ApplicationLibCode/Application/Tools/RiaSummaryAddressAnalyzer.cpp index 7ce053bf96..ede8e17170 100644 --- a/ApplicationLibCode/Application/Tools/RiaSummaryCurveAnalyzer.cpp +++ b/ApplicationLibCode/Application/Tools/RiaSummaryAddressAnalyzer.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RiaSummaryCurveAnalyzer.h" +#include "RiaSummaryAddressAnalyzer.h" #include "RiaStdStringTools.h" #include "RiaSummaryCurveDefinition.h" @@ -29,14 +29,14 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiaSummaryCurveAnalyzer::RiaSummaryCurveAnalyzer() +RiaSummaryAddressAnalyzer::RiaSummaryAddressAnalyzer() { } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaSummaryCurveAnalyzer::appendAddresses( const std::vector& allAddresses ) +void RiaSummaryAddressAnalyzer::appendAddresses( const std::vector& allAddresses ) { for ( const auto& adr : allAddresses ) { @@ -47,7 +47,7 @@ void RiaSummaryCurveAnalyzer::appendAddresses( const std::vector& allAddresses ) +void RiaSummaryAddressAnalyzer::appendAddresses( const std::set& allAddresses ) { for ( const auto& adr : allAddresses ) { @@ -58,7 +58,7 @@ void RiaSummaryCurveAnalyzer::appendAddresses( const std::set RiaSummaryCurveAnalyzer::quantities() const +std::set RiaSummaryAddressAnalyzer::quantities() const { return m_quantities; } @@ -66,7 +66,7 @@ std::set RiaSummaryCurveAnalyzer::quantities() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::set RiaSummaryCurveAnalyzer::quantityNamesWithHistory() const +std::set RiaSummaryAddressAnalyzer::quantityNamesWithHistory() const { assignCategoryToQuantities(); @@ -76,7 +76,7 @@ std::set RiaSummaryCurveAnalyzer::quantityNamesWithHistory() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::set RiaSummaryCurveAnalyzer::quantityNamesNoHistory() const +std::set RiaSummaryAddressAnalyzer::quantityNamesNoHistory() const { assignCategoryToQuantities(); @@ -86,49 +86,49 @@ std::set RiaSummaryCurveAnalyzer::quantityNamesNoHistory() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::string RiaSummaryCurveAnalyzer::quantityNameForTitle() const +std::string RiaSummaryAddressAnalyzer::quantityNameForTitle() const { - if ( quantityNamesWithHistory().size() == 1 && quantityNamesNoHistory().empty() ) + if ( quantities().size() == 1 ) { - return *quantityNamesWithHistory().begin(); + return *quantities().begin(); } - if ( quantityNamesNoHistory().size() == 1 && quantityNamesWithHistory().empty() ) + if ( quantities().size() == 2 && quantityNamesWithHistory().size() == 1 ) { - return *quantityNamesNoHistory().begin(); + return *quantityNamesWithHistory().begin(); } - return std::string(); + return {}; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::set RiaSummaryCurveAnalyzer::wellNames() const +std::set RiaSummaryAddressAnalyzer::wellNames() const { - return m_wellNames; + return keysInMap( m_wellNames ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::set RiaSummaryCurveAnalyzer::wellGroupNames() const +std::set RiaSummaryAddressAnalyzer::groupNames() const { - return m_wellGroupNames; + return keysInMap( m_groupNames ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::set RiaSummaryCurveAnalyzer::regionNumbers() const +std::set RiaSummaryAddressAnalyzer::regionNumbers() const { - return m_regionNumbers; + return keysInMap( m_regionNumbers ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::set RiaSummaryCurveAnalyzer::wellCompletions( const std::string& wellName ) const +std::set RiaSummaryAddressAnalyzer::wellCompletions( const std::string& wellName ) const { std::set connections; @@ -146,7 +146,7 @@ std::set RiaSummaryCurveAnalyzer::wellCompletions( const std::strin //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::set RiaSummaryCurveAnalyzer::wellSegmentNumbers( const std::string& wellName ) const +std::set RiaSummaryAddressAnalyzer::wellSegmentNumbers( const std::string& wellName ) const { std::set segmentNumberForWell; @@ -164,61 +164,88 @@ std::set RiaSummaryCurveAnalyzer::wellSegmentNumbers( const std::string& we //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::set RiaSummaryCurveAnalyzer::blocks() const +std::set RiaSummaryAddressAnalyzer::blocks() const +{ + return keysInMap( m_blocks ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::set RiaSummaryAddressAnalyzer::aquifers() const { - return m_blocks; + return keysInMap( m_aquifers ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::set RiaSummaryCurveAnalyzer::aquifers() const +std::set RiaSummaryAddressAnalyzer::categories() const { - return m_aquifers; + return keysInMap( m_categories ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::set RiaSummaryCurveAnalyzer::categories() const +std::vector> RiaSummaryAddressAnalyzer::addressesGroupedByObject() const { - return m_categories; + auto wellAdr = valuesInMap( m_wellNames ); + auto groupAdr = valuesInMap( m_groupNames ); + auto regionAdr = valuesInMap( m_regionNumbers ); + auto blockAdr = valuesInMap( m_blocks ); + auto aquiferAdr = valuesInMap( m_aquifers ); + + std::vector> groupedByObject; + groupedByObject.insert( groupedByObject.end(), wellAdr.begin(), wellAdr.end() ); + groupedByObject.insert( groupedByObject.end(), groupAdr.begin(), groupAdr.end() ); + groupedByObject.insert( groupedByObject.end(), regionAdr.begin(), regionAdr.end() ); + groupedByObject.insert( groupedByObject.end(), blockAdr.begin(), blockAdr.end() ); + groupedByObject.insert( groupedByObject.end(), aquiferAdr.begin(), aquiferAdr.end() ); + + groupedByObject.push_back( m_otherCategory ); + + return groupedByObject; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RiaSummaryCurveAnalyzer::identifierTexts( RifEclipseSummaryAddress::SummaryVarCategory category, - const std::string& secondaryIdentifier ) const +std::vector RiaSummaryAddressAnalyzer::identifierTexts( RifEclipseSummaryAddress::SummaryVarCategory category, + const std::string& secondaryIdentifier ) const { std::vector identifierStrings; if ( category == RifEclipseSummaryAddress::SUMMARY_REGION ) { - for ( const auto& regionNumber : m_regionNumbers ) + auto keys = keysInMap( m_regionNumbers ); + for ( const auto& key : keys ) { - identifierStrings.push_back( QString::number( regionNumber ) ); + identifierStrings.push_back( QString::number( key ) ); } } else if ( category == RifEclipseSummaryAddress::SUMMARY_WELL ) { - for ( const auto& wellName : m_wellNames ) + auto keys = keysInMap( m_wellNames ); + for ( const auto& key : keys ) { - identifierStrings.push_back( QString::fromStdString( wellName ) ); + identifierStrings.push_back( QString::fromStdString( key ) ); } } - else if ( category == RifEclipseSummaryAddress::SUMMARY_WELL_GROUP ) + else if ( category == RifEclipseSummaryAddress::SUMMARY_GROUP ) { - for ( const auto& wellGroupName : m_wellGroupNames ) + auto keys = keysInMap( m_groupNames ); + for ( const auto& key : keys ) { - identifierStrings.push_back( QString::fromStdString( wellGroupName ) ); + identifierStrings.push_back( QString::fromStdString( key ) ); } } else if ( category == RifEclipseSummaryAddress::SUMMARY_BLOCK ) { - for ( const auto& ijkBlock : m_blocks ) + auto keys = keysInMap( m_blocks ); + for ( const auto& key : keys ) { - identifierStrings.push_back( QString::fromStdString( ijkBlock ) ); + identifierStrings.push_back( QString::fromStdString( key ) ); } } else if ( category == RifEclipseSummaryAddress::SUMMARY_WELL_SEGMENT ) @@ -239,9 +266,10 @@ std::vector RiaSummaryCurveAnalyzer::identifierTexts( RifEclipseSummary } else if ( category == RifEclipseSummaryAddress::SUMMARY_AQUIFER ) { - for ( const auto& aquifer : m_aquifers ) + auto keys = keysInMap( m_aquifers ); + for ( const auto& key : keys ) { - identifierStrings.push_back( QString::number( aquifer ) ); + identifierStrings.push_back( QString::number( key ) ); } } @@ -252,8 +280,8 @@ std::vector RiaSummaryCurveAnalyzer::identifierTexts( RifEclipseSummary /// //-------------------------------------------------------------------------------------------------- std::vector - RiaSummaryCurveAnalyzer::addressesForCategory( const std::set& addresses, - RifEclipseSummaryAddress::SummaryVarCategory category ) + RiaSummaryAddressAnalyzer::addressesForCategory( const std::set& addresses, + RifEclipseSummaryAddress::SummaryVarCategory category ) { std::vector filteredAddresses; @@ -271,7 +299,7 @@ std::vector //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::string RiaSummaryCurveAnalyzer::correspondingHistorySummaryCurveName( const std::string& curveName ) +std::string RiaSummaryAddressAnalyzer::correspondingHistorySummaryCurveName( const std::string& curveName ) { static std::string historyIdentifier = "H"; @@ -280,20 +308,30 @@ std::string RiaSummaryCurveAnalyzer::correspondingHistorySummaryCurveName( const std::string candidate = curveName.substr( 0, curveName.size() - 1 ); return candidate; } - else - { - return curveName + historyIdentifier; - } + + return curveName + historyIdentifier; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaSummaryCurveAnalyzer::clear() +std::set + RiaSummaryAddressAnalyzer::vectorNamesForCategory( RifEclipseSummaryAddress::SummaryVarCategory category ) +{ + auto it = m_categories.find( category ); + if ( it != m_categories.end() ) return it->second; + + return {}; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSummaryAddressAnalyzer::clear() { m_quantities.clear(); m_wellNames.clear(); - m_wellGroupNames.clear(); + m_groupNames.clear(); m_regionNumbers.clear(); m_categories.clear(); m_wellCompletions.clear(); @@ -308,7 +346,7 @@ void RiaSummaryCurveAnalyzer::clear() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaSummaryCurveAnalyzer::assignCategoryToQuantities() const +void RiaSummaryAddressAnalyzer::assignCategoryToQuantities() const { if ( !m_quantities.empty() ) { @@ -322,7 +360,7 @@ void RiaSummaryCurveAnalyzer::assignCategoryToQuantities() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaSummaryCurveAnalyzer::computeQuantityNamesWithHistory() const +void RiaSummaryAddressAnalyzer::computeQuantityNamesWithHistory() const { m_quantitiesNoMatchingHistory.clear(); m_quantitiesWithMatchingHistory.clear(); @@ -355,28 +393,28 @@ void RiaSummaryCurveAnalyzer::computeQuantityNamesWithHistory() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaSummaryCurveAnalyzer::analyzeSingleAddress( const RifEclipseSummaryAddress& address ) +void RiaSummaryAddressAnalyzer::analyzeSingleAddress( const RifEclipseSummaryAddress& address ) { const std::string& wellName = address.wellName(); if ( !wellName.empty() ) { - m_wellNames.insert( wellName ); + m_wellNames.insert( { wellName, address } ); } - if ( !address.quantityName().empty() ) + if ( !address.vectorName().empty() ) { - m_quantities.insert( address.quantityName() ); + m_quantities.insert( address.vectorName() ); } - if ( !address.wellGroupName().empty() ) + if ( !address.groupName().empty() ) { - m_wellGroupNames.insert( address.wellGroupName() ); + m_groupNames.insert( { address.groupName(), address } ); } if ( address.regionNumber() != -1 ) { - m_regionNumbers.insert( address.regionNumber() ); + m_regionNumbers.insert( { address.regionNumber(), address } ); } if ( address.category() == RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION ) @@ -392,15 +430,114 @@ void RiaSummaryCurveAnalyzer::analyzeSingleAddress( const RifEclipseSummaryAddre else if ( address.category() == RifEclipseSummaryAddress::SUMMARY_BLOCK ) { auto text = address.blockAsString(); - m_blocks.insert( text ); + + m_blocks.insert( { text, address } ); } else if ( address.category() == RifEclipseSummaryAddress::SUMMARY_AQUIFER ) { - m_aquifers.insert( address.aquiferNumber() ); + m_aquifers.insert( { address.aquiferNumber(), address } ); + } + else if ( address.category() == RifEclipseSummaryAddress::SUMMARY_FIELD || + address.category() == RifEclipseSummaryAddress::SUMMARY_MISC ) + { + m_otherCategory.push_back( address ); } if ( address.category() != RifEclipseSummaryAddress::SUMMARY_INVALID ) { - m_categories.insert( address.category() ); + if ( m_categories.count( address.category() ) == 0 ) + { + m_categories[address.category()] = { address.vectorName() }; + } + else + m_categories[address.category()].insert( address.vectorName() ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::set RiaSummaryAddressAnalyzer::keysInMap( const std::multimap& map ) +{ + std::set keys; + for ( const auto& [key, value] : map ) + { + keys.insert( key ); + } + return keys; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::set RiaSummaryAddressAnalyzer::keysInMap( const std::multimap& map ) +{ + std::set keys; + for ( const auto& [key, value] : map ) + { + keys.insert( key ); } + return keys; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::set RiaSummaryAddressAnalyzer::keysInMap( + const std::map>& map ) +{ + std::set keys; + for ( const auto& [key, value] : map ) + { + keys.insert( key ); + } + return keys; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector> + RiaSummaryAddressAnalyzer::valuesInMap( const std::multimap& map ) +{ + std::vector> groupedAddresses; + + auto uniqueKeys = keysInMap( map ); + for ( const auto& key : uniqueKeys ) + { + auto range = map.equal_range( key ); + + std::vector addresses; + for ( auto i = range.first; i != range.second; ++i ) + { + addresses.push_back( i->second ); + } + groupedAddresses.push_back( addresses ); + } + + return groupedAddresses; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector> + RiaSummaryAddressAnalyzer::valuesInMap( const std::multimap& map ) +{ + std::vector> groupedAddresses; + + auto uniqueKeys = keysInMap( map ); + for ( const auto& key : uniqueKeys ) + { + auto range = map.equal_range( key ); + + std::vector addresses; + for ( auto i = range.first; i != range.second; ++i ) + { + addresses.push_back( i->second ); + } + groupedAddresses.push_back( addresses ); + } + + return groupedAddresses; } diff --git a/ApplicationLibCode/Application/Tools/RiaSummaryCurveAnalyzer.h b/ApplicationLibCode/Application/Tools/RiaSummaryAddressAnalyzer.h similarity index 63% rename from ApplicationLibCode/Application/Tools/RiaSummaryCurveAnalyzer.h rename to ApplicationLibCode/Application/Tools/RiaSummaryAddressAnalyzer.h index 8f8595b9b9..685470a417 100644 --- a/ApplicationLibCode/Application/Tools/RiaSummaryCurveAnalyzer.h +++ b/ApplicationLibCode/Application/Tools/RiaSummaryAddressAnalyzer.h @@ -32,10 +32,10 @@ class QString; //================================================================================================== // //================================================================================================== -class RiaSummaryCurveAnalyzer +class RiaSummaryAddressAnalyzer { public: - RiaSummaryCurveAnalyzer(); + RiaSummaryAddressAnalyzer(); void appendAddresses( const std::set& allAddresses ); void appendAddresses( const std::vector& allAddresses ); @@ -49,7 +49,7 @@ class RiaSummaryCurveAnalyzer std::string quantityNameForTitle() const; std::set wellNames() const; - std::set wellGroupNames() const; + std::set groupNames() const; std::set regionNumbers() const; std::set wellCompletions( const std::string& wellName ) const; @@ -58,6 +58,7 @@ class RiaSummaryCurveAnalyzer std::set aquifers() const; std::set categories() const; + std::vector> addressesGroupedByObject() const; std::vector identifierTexts( RifEclipseSummaryAddress::SummaryVarCategory category, const std::string& secondaryIdentifier ) const; @@ -68,24 +69,38 @@ class RiaSummaryCurveAnalyzer static std::string correspondingHistorySummaryCurveName( const std::string& curveName ); + std::set vectorNamesForCategory( RifEclipseSummaryAddress::SummaryVarCategory category ); + private: void assignCategoryToQuantities() const; void computeQuantityNamesWithHistory() const; void analyzeSingleAddress( const RifEclipseSummaryAddress& address ); + static std::set keysInMap( const std::multimap& map ); + static std::set keysInMap( const std::multimap& map ); + static std::set + keysInMap( const std::map>& map ); + + static std::vector> + valuesInMap( const std::multimap& map ); + + static std::vector> + valuesInMap( const std::multimap& map ); + private: std::set m_quantities; mutable std::set m_quantitiesWithMatchingHistory; mutable std::set m_quantitiesNoMatchingHistory; - std::set m_wellNames; - std::set m_wellGroupNames; - std::set m_regionNumbers; - std::set> m_wellCompletions; - std::set> m_wellSegmentNumbers; - std::set m_blocks; - std::set m_aquifers; + std::vector m_otherCategory; + std::multimap m_wellNames; + std::multimap m_groupNames; + std::multimap m_regionNumbers; + std::set> m_wellCompletions; + std::set> m_wellSegmentNumbers; + std::multimap m_blocks; + std::multimap m_aquifers; - std::set m_categories; + std::map> m_categories; }; diff --git a/ApplicationLibCode/Application/Tools/RiaSummaryStringTools.cpp b/ApplicationLibCode/Application/Tools/RiaSummaryStringTools.cpp new file mode 100644 index 0000000000..b9ef6a9632 --- /dev/null +++ b/ApplicationLibCode/Application/Tools/RiaSummaryStringTools.cpp @@ -0,0 +1,271 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiaSummaryStringTools.h" + +#include "RiaLogging.h" +#include "RiaStdStringTools.h" +#include "RiaSummaryTools.h" +#include "RiaTextStringTools.h" + +#include "RifEclipseSummaryAddress.h" +#include "RifReaderEclipseSummary.h" +#include "RifSummaryReaderInterface.h" + +#include "RimMainPlotCollection.h" +#include "RimSummaryCase.h" +#include "RimSummaryCaseCollection.h" +#include "RimSummaryCaseMainCollection.h" + +#include "SummaryPlotCommands/RicSummaryPlotFeatureImpl.h" + +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSummaryStringTools::splitAddressFiltersInGridAndSummary( RimSummaryCase* summaryCase, + const QStringList& addressFilters, + QStringList* summaryAddressFilters, + QStringList* gridResultAddressFilters ) +{ + if ( summaryCase ) + { + const std::set& addrs = summaryCase->summaryReader()->allResultAddresses(); + + QRegularExpression gridAddressPattern( "^[A-Z]+:[0-9]+,[0-9]+,[0-9]+$" ); + + for ( int filterIdx = 0; filterIdx < addressFilters.size(); ++filterIdx ) + { + const QString& address = addressFilters[filterIdx]; + if ( hasFilterAnyMatch( address, addrs ) ) + { + summaryAddressFilters->push_back( address ); + } + else + { + if ( gridAddressPattern.match( address ).hasMatch() ) + { + gridResultAddressFilters->push_back( address ); + } + else + { + RiaLogging::warning( "No summary or restart vectors matched \"" + address + "\"" ); + } + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair RiaSummaryStringTools::splitIntoAddressAndDataSourceFilters( const QString& filter ) +{ + auto words = RiaSummaryStringTools::splitIntoWords( filter ); + auto [summaryCases, ensembles] = RiaSummaryStringTools::allDataSourcesInProject(); + auto dataSourceNames = RiaSummaryStringTools::dataSourceNames( summaryCases, ensembles ); + + QStringList addressFilters; + QStringList dataSourceFilters; + + RiaSummaryStringTools::splitUsingDataSourceNames( words, dataSourceNames, addressFilters, dataSourceFilters ); + + // If no filter on data source is specified, use wildcard to match all + if ( dataSourceFilters.empty() ) dataSourceFilters.push_back( "*" ); + + return { addressFilters, dataSourceFilters }; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaSummaryStringTools::hasFilterAnyMatch( const QString& curveFilter, + const std::set& summaryAddresses ) +{ + for ( const auto& addr : summaryAddresses ) + { + if ( addr.isUiTextMatchingFilterText( curveFilter ) ) return true; + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// Sort filters into curve and data source filters +//-------------------------------------------------------------------------------------------------- +void RiaSummaryStringTools::splitUsingDataSourceNames( const QStringList& filters, + const QStringList& dataSourceNames, + QStringList& addressFilters, + QStringList& dataSourceFilters ) +{ + for ( const auto& s : filters ) + { + // Strip off realization filter from ensemble search string + + QString pureDataSourceCandidate = s.left( s.indexOf( ':' ) ); + + bool foundDataSource = false; + + QRegExp searcher( pureDataSourceCandidate, Qt::CaseInsensitive, QRegExp::WildcardUnix ); + + for ( const auto& ds : dataSourceNames ) + { + if ( !foundDataSource && searcher.exactMatch( ds ) ) + { + dataSourceFilters.push_back( s ); + foundDataSource = true; + } + } + + if ( !foundDataSource ) + { + addressFilters.push_back( s ); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair, std::vector> + RiaSummaryStringTools::allDataSourcesInProject() +{ + auto sumCaseMainColl = RiaSummaryTools::summaryCaseMainCollection(); + if ( !sumCaseMainColl ) return { {}, {} }; + + auto summaryCases = sumCaseMainColl->topLevelSummaryCases(); + auto ensembles = sumCaseMainColl->summaryCaseCollections(); + + return { summaryCases, ensembles }; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair, std::vector> + RiaSummaryStringTools::dataSourcesMatchingFilters( const QStringList& dataSourceFilters ) +{ + std::vector matchingSummaryCases; + std::vector matchingEnsembles; + + auto [allSummaryCases, allEnsembles] = allDataSourcesInProject(); + + for ( const auto& dsFilter : dataSourceFilters ) + { + QString searchString = dsFilter.left( dsFilter.indexOf( ':' ) ); + QRegExp searcher( searchString, Qt::CaseInsensitive, QRegExp::WildcardUnix ); + + for ( const auto& ensemble : allEnsembles ) + { + auto ensembleName = ensemble->name(); + if ( searcher.exactMatch( ensembleName ) ) + { + if ( searchString == dsFilter ) + { + // Match on ensemble name without realization filter + + matchingEnsembles.push_back( ensemble ); + } + else + { + // Match on subset of realisations in ensemble + + QString realizationSearchString = dsFilter.right( dsFilter.size() - dsFilter.indexOf( ':' ) - 1 ); + QRegExp realizationSearcher( realizationSearchString, Qt::CaseInsensitive, QRegExp::WildcardUnix ); + + for ( const auto& summaryCase : ensemble->allSummaryCases() ) + { + auto realizationName = summaryCase->displayCaseName(); + if ( realizationSearcher.exactMatch( realizationName ) ) + { + matchingSummaryCases.push_back( summaryCase ); + } + } + } + } + } + + for ( const auto& summaryCase : allSummaryCases ) + { + auto summaryCaseName = summaryCase->displayCaseName(); + if ( searcher.exactMatch( summaryCaseName ) ) + { + matchingSummaryCases.push_back( summaryCase ); + } + } + } + + return { matchingSummaryCases, matchingEnsembles }; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RiaSummaryStringTools::splitIntoWords( const QString& text ) +{ + return RiaTextStringTools::splitSkipEmptyParts( text, QRegExp( "\\s+" ) ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RiaSummaryStringTools::dataSourceNames( const std::vector& summaryCases, + const std::vector& ensembles ) +{ + QStringList names; + for ( const auto& summaryCase : summaryCases ) + { + names.push_back( summaryCase->displayCaseName() ); + } + + for ( const auto& ensemble : ensembles ) + { + names.push_back( ensemble->name() ); + } + + return names; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::set + RiaSummaryStringTools::computeFilteredAddresses( const QStringList& textFilters, + const std::set& sourceAddresses, + bool includeDiffCurves ) +{ + std::set addresses; + + std::vector usedFilters; + RicSummaryPlotFeatureImpl::insertFilteredAddressesInSet( textFilters, sourceAddresses, &addresses, &usedFilters ); + + if ( includeDiffCurves ) return addresses; + + const auto diffText = RifReaderEclipseSummary::differenceIdentifier(); + + std::set addressesWithoutDiffVectors; + for ( const auto& adr : addresses ) + { + if ( RiaStdStringTools::endsWith( adr.vectorName(), diffText ) ) continue; + + addressesWithoutDiffVectors.insert( adr ); + } + + return addressesWithoutDiffVectors; +} diff --git a/ApplicationLibCode/Application/Tools/RiaSummaryStringTools.h b/ApplicationLibCode/Application/Tools/RiaSummaryStringTools.h new file mode 100644 index 0000000000..25031059c2 --- /dev/null +++ b/ApplicationLibCode/Application/Tools/RiaSummaryStringTools.h @@ -0,0 +1,66 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include + +class RimSummaryCase; +class RifEclipseSummaryAddress; +class RimSummaryCaseCollection; + +class QString; +class QStringList; + +//================================================================================================== +// +//================================================================================================== +class RiaSummaryStringTools +{ +public: + static void splitAddressFiltersInGridAndSummary( RimSummaryCase* summaryCase, + const QStringList& addressFilters, + QStringList* summaryAddressFilters, + QStringList* gridResultAddressFilters ); + + static std::pair splitIntoAddressAndDataSourceFilters( const QString& filter ); + + static std::pair, std::vector> allDataSourcesInProject(); + static std::pair, std::vector> + dataSourcesMatchingFilters( const QStringList& dataSourceFilters ); + + static QStringList splitIntoWords( const QString& text ); + + static QStringList dataSourceNames( const std::vector& summaryCases, + const std::vector& ensembles ); + + static std::set + computeFilteredAddresses( const QStringList& textFilters, + const std::set& sourceAddresses, + bool includeDiffCurves ); + + // Consider private, set public to be able to test + static void splitUsingDataSourceNames( const QStringList& filters, + const QStringList& dataSourceNames, + QStringList& addressFilters, + QStringList& dataSourceFilters ); + +private: + static bool hasFilterAnyMatch( const QString& curveFilter, const std::set& summaryAddresses ); +}; diff --git a/ApplicationLibCode/Application/Tools/RiaSummaryTools.cpp b/ApplicationLibCode/Application/Tools/RiaSummaryTools.cpp index f5a6c83acb..8c43701ea3 100644 --- a/ApplicationLibCode/Application/Tools/RiaSummaryTools.cpp +++ b/ApplicationLibCode/Application/Tools/RiaSummaryTools.cpp @@ -30,12 +30,15 @@ #include "RimSummaryCalculation.h" #include "RimSummaryCalculationCollection.h" #include "RimSummaryCalculationVariable.h" +#include "RimSummaryCase.h" +#include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" #include "RimSummaryCrossPlot.h" #include "RimSummaryCrossPlotCollection.h" #include "RimSummaryCurve.h" +#include "RimSummaryMultiPlot.h" +#include "RimSummaryMultiPlotCollection.h" #include "RimSummaryPlot.h" -#include "RimSummaryPlotCollection.h" #include "cafPdmObject.h" @@ -44,11 +47,11 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryPlotCollection* RiaSummaryTools::summaryPlotCollection() +RimSummaryMultiPlotCollection* RiaSummaryTools::summaryMultiPlotCollection() { RimProject* project = RimProject::current(); - return project->mainPlotCollection()->summaryPlotCollection(); + return project->mainPlotCollection()->summaryMultiPlotCollection(); } //-------------------------------------------------------------------------------------------------- @@ -77,18 +80,21 @@ RimSummaryCaseMainCollection* RiaSummaryTools::summaryCaseMainCollection() //-------------------------------------------------------------------------------------------------- void RiaSummaryTools::notifyCalculatedCurveNameHasChanged( int calculationId, const QString& currentCurveName ) { - RimSummaryPlotCollection* summaryPlotColl = RiaSummaryTools::summaryPlotCollection(); + RimSummaryMultiPlotCollection* summaryPlotColl = RiaSummaryTools::summaryMultiPlotCollection(); - for ( RimSummaryPlot* plot : summaryPlotColl->plots() ) + for ( RimSummaryMultiPlot* multiPlot : summaryPlotColl->multiPlots() ) { - for ( RimSummaryCurve* curve : plot->summaryCurves() ) + for ( RimSummaryPlot* plot : multiPlot->summaryPlots() ) { - RifEclipseSummaryAddress adr = curve->summaryAddressY(); - if ( adr.category() == RifEclipseSummaryAddress::SUMMARY_CALCULATED && adr.id() == calculationId ) + for ( RimSummaryCurve* curve : plot->summaryCurves() ) { - RifEclipseSummaryAddress updatedAdr = - RifEclipseSummaryAddress::calculatedAddress( currentCurveName.toStdString(), calculationId ); - curve->setSummaryAddressYAndApplyInterpolation( updatedAdr ); + RifEclipseSummaryAddress adr = curve->summaryAddressY(); + if ( adr.category() == RifEclipseSummaryAddress::SUMMARY_CALCULATED && adr.id() == calculationId ) + { + RifEclipseSummaryAddress updatedAdr = + RifEclipseSummaryAddress::calculatedAddress( currentCurveName.toStdString(), calculationId ); + curve->setSummaryAddressYAndApplyInterpolation( updatedAdr ); + } } } } @@ -117,9 +123,9 @@ RimSummaryPlot* RiaSummaryTools::parentSummaryPlot( caf::PdmObject* object ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryPlotCollection* RiaSummaryTools::parentSummaryPlotCollection( caf::PdmObject* object ) +RimSummaryMultiPlotCollection* RiaSummaryTools::parentSummaryPlotCollection( caf::PdmObject* object ) { - RimSummaryPlotCollection* summaryPlotColl = nullptr; + RimSummaryMultiPlotCollection* summaryPlotColl = nullptr; if ( object ) { @@ -129,6 +135,21 @@ RimSummaryPlotCollection* RiaSummaryTools::parentSummaryPlotCollection( caf::Pdm return summaryPlotColl; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryMultiPlot* RiaSummaryTools::parentSummaryMultiPlot( caf::PdmObject* object ) +{ + RimSummaryMultiPlot* multiPlot = nullptr; + + if ( object ) + { + object->firstAncestorOrThisOfType( multiPlot ); + } + + return multiPlot; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -205,13 +226,17 @@ void RiaSummaryTools::getSummaryCasesAndAddressesForCalculation( int RimSummaryCalculationCollection* calculationColl = proj->calculationCollection(); if ( !calculationColl ) return; - RimSummaryCalculation* calculation = calculationColl->findCalculationById( id ); + RimUserDefinedCalculation* calculation = calculationColl->findCalculationById( id ); if ( !calculation ) return; - for ( RimSummaryCalculationVariable* v : calculation->allVariables() ) + for ( RimUserDefinedCalculationVariable* v : calculation->allVariables() ) { - cases.push_back( v->summaryCase() ); - addresses.push_back( v->summaryAddress()->address() ); + RimSummaryCalculationVariable* scv = dynamic_cast( v ); + if ( scv ) + { + cases.push_back( scv->summaryCase() ); + addresses.push_back( scv->summaryAddress()->address() ); + } } } @@ -219,10 +244,10 @@ void RiaSummaryTools::getSummaryCasesAndAddressesForCalculation( int /// //-------------------------------------------------------------------------------------------------- std::pair, std::vector> - RiaSummaryTools::resampledValuesForPeriod( const RifEclipseSummaryAddress& address, - const std::vector& timeSteps, - std::vector& values, - RiaQDateTimeTools::DateTimePeriod period ) + RiaSummaryTools::resampledValuesForPeriod( const RifEclipseSummaryAddress& address, + const std::vector& timeSteps, + std::vector& values, + RiaDefines::DateTimePeriod period ) { RiaTimeHistoryCurveResampler resampler; resampler.setCurveData( values, timeSteps ); @@ -238,3 +263,62 @@ std::pair, std::vector> return { resampler.resampledTimeSteps(), resampler.resampledValues() }; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryCase* RiaSummaryTools::summaryCaseById( int caseId ) +{ + auto summaryCases = RimProject::current()->allSummaryCases(); + + for ( auto summaryCase : summaryCases ) + { + if ( summaryCase->caseId() == caseId ) + { + return summaryCase; + } + } + + return nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryCaseCollection* RiaSummaryTools::ensembleById( int ensembleId ) +{ + auto ensembles = RimProject::current()->summaryGroups(); + + for ( auto ensemble : ensembles ) + { + if ( ensemble->ensembleId() == ensembleId ) + { + return ensemble; + } + } + + return nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RiaSummaryTools::optionsForAllSummaryCases() +{ + return optionsForSummaryCases( RimProject::current()->allSummaryCases() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RiaSummaryTools::optionsForSummaryCases( const std::vector& cases ) +{ + QList options; + + for ( RimSummaryCase* c : cases ) + { + options.push_back( caf::PdmOptionItemInfo( c->displayCaseName(), c, false, c->uiIconProvider() ) ); + } + + return options; +} diff --git a/ApplicationLibCode/Application/Tools/RiaSummaryTools.h b/ApplicationLibCode/Application/Tools/RiaSummaryTools.h index 91072498b7..daaccdff7c 100644 --- a/ApplicationLibCode/Application/Tools/RiaSummaryTools.h +++ b/ApplicationLibCode/Application/Tools/RiaSummaryTools.h @@ -18,18 +18,20 @@ #pragma once -#include "RiaQDateTimeTools.h" +#include "RiaDateTimeDefines.h" #include #include -class RimSummaryPlotCollection; class RimSummaryPlot; +class RimSummaryMultiPlot; +class RimSummaryMultiPlotCollection; class RimSummaryCrossPlot; class RimSummaryCrossPlotCollection; class RimSummaryCaseMainCollection; class RimSummaryCase; +class RimSummaryCaseCollection; class RifEclipseSummaryAddress; @@ -38,7 +40,8 @@ class QStringList; namespace caf { class PdmObject; -} +class PdmOptionItemInfo; +} // namespace caf //================================================================================================== // @@ -46,14 +49,15 @@ class PdmObject; class RiaSummaryTools { public: - static RimSummaryPlotCollection* summaryPlotCollection(); static RimSummaryCrossPlotCollection* summaryCrossPlotCollection(); static RimSummaryCaseMainCollection* summaryCaseMainCollection(); + static RimSummaryMultiPlotCollection* summaryMultiPlotCollection(); static void notifyCalculatedCurveNameHasChanged( int calculationId, const QString& currentCurveName ); - static RimSummaryPlot* parentSummaryPlot( caf::PdmObject* object ); - static RimSummaryPlotCollection* parentSummaryPlotCollection( caf::PdmObject* object ); + static RimSummaryPlot* parentSummaryPlot( caf::PdmObject* object ); + static RimSummaryMultiPlot* parentSummaryMultiPlot( caf::PdmObject* object ); + static RimSummaryMultiPlotCollection* parentSummaryPlotCollection( caf::PdmObject* object ); static RimSummaryCrossPlot* parentCrossPlot( caf::PdmObject* object ); static RimSummaryCrossPlotCollection* parentCrossPlotCollection( caf::PdmObject* object ); @@ -65,8 +69,14 @@ class RiaSummaryTools std::vector& addresses ); static std::pair, std::vector> - resampledValuesForPeriod( const RifEclipseSummaryAddress& address, - const std::vector& timeSteps, - std::vector& values, - RiaQDateTimeTools::DateTimePeriod period ); + resampledValuesForPeriod( const RifEclipseSummaryAddress& address, + const std::vector& timeSteps, + std::vector& values, + RiaDefines::DateTimePeriod period ); + + static RimSummaryCase* summaryCaseById( int caseId ); + static RimSummaryCaseCollection* ensembleById( int ensembleId ); + + static QList optionsForAllSummaryCases(); + static QList optionsForSummaryCases( const std::vector& cases ); }; diff --git a/ApplicationLibCode/Application/Tools/RiaTextFileCompare.cpp b/ApplicationLibCode/Application/Tools/RiaTextFileCompare.cpp index b5e0a660ff..141af981c7 100644 --- a/ApplicationLibCode/Application/Tools/RiaTextFileCompare.cpp +++ b/ApplicationLibCode/Application/Tools/RiaTextFileCompare.cpp @@ -22,6 +22,11 @@ #include +// Disable deprecation warning for QProcess::start() +#ifdef _MSC_VER +#pragma warning( disable : 4996 ) +#endif + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/Tools/RiaTextStringTools.cpp b/ApplicationLibCode/Application/Tools/RiaTextStringTools.cpp index ba790d1cd0..9efda3fc7e 100644 --- a/ApplicationLibCode/Application/Tools/RiaTextStringTools.cpp +++ b/ApplicationLibCode/Application/Tools/RiaTextStringTools.cpp @@ -127,3 +127,27 @@ QString RiaTextStringTools::trimNonAlphaNumericCharacters( const QString& s ) trimmedString.replace( trimRe, "" ); return trimmedString; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RiaTextStringTools::splitSkipEmptyParts( const QString& text, const QString& sep /*= " " */ ) +{ +#if QT_VERSION >= QT_VERSION_CHECK( 5, 14, 0 ) + return text.split( sep, Qt::SkipEmptyParts, Qt::CaseInsensitive ); +#else + return text.split( sep, QString::SkipEmptyParts, Qt::CaseInsensitive ); +#endif +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RiaTextStringTools::splitSkipEmptyParts( const QString& text, const QRegExp& regExp ) +{ +#if QT_VERSION >= QT_VERSION_CHECK( 5, 14, 0 ) + return text.split( regExp, Qt::SkipEmptyParts ); +#else + return text.split( regExp, QString::SkipEmptyParts ); +#endif +} diff --git a/ApplicationLibCode/Application/Tools/RiaTextStringTools.h b/ApplicationLibCode/Application/Tools/RiaTextStringTools.h index 8e4a5ca95d..974b4789f6 100644 --- a/ApplicationLibCode/Application/Tools/RiaTextStringTools.h +++ b/ApplicationLibCode/Application/Tools/RiaTextStringTools.h @@ -18,7 +18,8 @@ #pragma once -class QString; +#include + class QStringList; //-------------------------------------------------------------------------------------------------- @@ -31,4 +32,8 @@ QString trimAndRemoveDoubleSpaces( const QString& s ); QString commonRoot( const QStringList& stringList ); QString commonSuffix( const QStringList& stringList ); QString trimNonAlphaNumericCharacters( const QString& s ); + +QStringList splitSkipEmptyParts( const QString& text, const QString& sep = " " ); +QStringList splitSkipEmptyParts( const QString& text, const QRegExp& regExp ); + } // namespace RiaTextStringTools diff --git a/ApplicationLibCode/Application/Tools/RiaTimeHistoryCurveResampler.cpp b/ApplicationLibCode/Application/Tools/RiaTimeHistoryCurveResampler.cpp index 88deb2a5ef..d88b9dffc6 100644 --- a/ApplicationLibCode/Application/Tools/RiaTimeHistoryCurveResampler.cpp +++ b/ApplicationLibCode/Application/Tools/RiaTimeHistoryCurveResampler.cpp @@ -19,6 +19,7 @@ #include #include +#include "RiaQDateTimeTools.h" #include "RiaTimeHistoryCurveResampler.h" #include @@ -67,7 +68,7 @@ void RiaTimeHistoryCurveResampler::setCurveData( const std::vector& valu //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaTimeHistoryCurveResampler::resampleAndComputePeriodEndValues( RiaQDateTimeTools::DateTimePeriod period ) +void RiaTimeHistoryCurveResampler::resampleAndComputePeriodEndValues( RiaDefines::DateTimePeriod period ) { computePeriodEndValues( period ); } @@ -75,7 +76,7 @@ void RiaTimeHistoryCurveResampler::resampleAndComputePeriodEndValues( RiaQDateTi //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaTimeHistoryCurveResampler::resampleAndComputeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod period ) +void RiaTimeHistoryCurveResampler::resampleAndComputeWeightedMeanValues( RiaDefines::DateTimePeriod period ) { computeWeightedMeanValues( period ); } @@ -99,22 +100,22 @@ const std::vector& RiaTimeHistoryCurveResampler::resampledValues() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RiaTimeHistoryCurveResampler::timeStepsFromTimeRange( RiaQDateTimeTools::DateTimePeriod period, - time_t minTime, - time_t maxTime ) +std::vector RiaTimeHistoryCurveResampler::timeStepsFromTimeRange( RiaDefines::DateTimePeriod period, + time_t minTime, + time_t maxTime ) { if ( minTime > maxTime ) return std::vector(); - auto firstOriginalTimeStep = QDT::fromTime_t( minTime ); - auto lastOriginalTimeStep = QDT::fromTime_t( maxTime ); + auto firstOriginalTimeStep = RiaQDateTimeTools::fromTime_t( minTime ); + auto lastOriginalTimeStep = RiaQDateTimeTools::fromTime_t( maxTime ); auto currTimeStep = firstResampledTimeStep( firstOriginalTimeStep, period ); std::vector timeSteps; - while ( QDT::lessThan( currTimeStep, lastOriginalTimeStep ) ) + while ( RiaQDateTimeTools::lessThan( currTimeStep, lastOriginalTimeStep ) ) { timeSteps.push_back( currTimeStep.toSecsSinceEpoch() ); - currTimeStep = QDT::addPeriod( currTimeStep, period ); + currTimeStep = RiaQDateTimeTools::addPeriod( currTimeStep, period ); } timeSteps.push_back( currTimeStep.toSecsSinceEpoch() ); @@ -124,7 +125,7 @@ std::vector RiaTimeHistoryCurveResampler::timeStepsFromTimeRange( RiaQDa //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaTimeHistoryCurveResampler::computeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod period ) +void RiaTimeHistoryCurveResampler::computeWeightedMeanValues( RiaDefines::DateTimePeriod period ) { size_t origDataSize = m_originalValues.second.size(); size_t oi = 0; @@ -141,9 +142,11 @@ void RiaTimeHistoryCurveResampler::computeWeightedMeanValues( RiaQDateTimeTools: m_values.reserve( m_timeSteps.size() ); for ( size_t i = 0; i < m_timeSteps.size(); i++ ) { - double wMean = 0.0; - time_t periodStart = i > 0 ? m_timeSteps[i - 1] - : QDT::subtractPeriod( QDT::fromTime_t( m_timeSteps[0] ), period ).toSecsSinceEpoch(); + double wMean = 0.0; + time_t periodStart = + i > 0 ? m_timeSteps[i - 1] + : RiaQDateTimeTools::subtractPeriod( RiaQDateTimeTools::fromTime_t( m_timeSteps[0] ), period ) + .toSecsSinceEpoch(); time_t periodEnd = m_timeSteps[i]; time_t periodLength = periodEnd - periodStart; @@ -197,7 +200,7 @@ void RiaTimeHistoryCurveResampler::computeWeightedMeanValues( RiaQDateTimeTools: //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaTimeHistoryCurveResampler::computePeriodEndValues( RiaQDateTimeTools::DateTimePeriod period ) +void RiaTimeHistoryCurveResampler::computePeriodEndValues( RiaDefines::DateTimePeriod period ) { size_t origDataSize = m_originalValues.second.size(); size_t oi = 0; @@ -246,20 +249,20 @@ void RiaTimeHistoryCurveResampler::clearData() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaTimeHistoryCurveResampler::computeResampledTimeSteps( RiaQDateTimeTools::DateTimePeriod period ) +void RiaTimeHistoryCurveResampler::computeResampledTimeSteps( RiaDefines::DateTimePeriod period ) { - CVF_ASSERT( period != RiaQDateTimeTools::DateTimePeriod::NONE && m_originalValues.second.size() > 0 ); + CVF_ASSERT( period != RiaDefines::DateTimePeriod::NONE && m_originalValues.second.size() > 0 ); - auto firstOriginalTimeStep = QDT::fromTime_t( m_originalValues.second.front() ); - auto lastOriginalTimeStep = QDT::fromTime_t( m_originalValues.second.back() ); + auto firstOriginalTimeStep = RiaQDateTimeTools::fromTime_t( m_originalValues.second.front() ); + auto lastOriginalTimeStep = RiaQDateTimeTools::fromTime_t( m_originalValues.second.back() ); clearData(); auto currTimeStep = firstResampledTimeStep( firstOriginalTimeStep, period ); - while ( QDT::lessThan( currTimeStep, lastOriginalTimeStep ) ) + while ( RiaQDateTimeTools::lessThan( currTimeStep, lastOriginalTimeStep ) ) { m_timeSteps.push_back( currTimeStep.toSecsSinceEpoch() ); - currTimeStep = QDT::addPeriod( currTimeStep, period ); + currTimeStep = RiaQDateTimeTools::addPeriod( currTimeStep, period ); } // Add last time step @@ -269,12 +272,13 @@ void RiaTimeHistoryCurveResampler::computeResampledTimeSteps( RiaQDateTimeTools: //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QDateTime RiaTimeHistoryCurveResampler::firstResampledTimeStep( const QDateTime& firstTimeStep, - RiaQDateTimeTools::DateTimePeriod period ) +QDateTime RiaTimeHistoryCurveResampler::firstResampledTimeStep( const QDateTime& firstTimeStep, + RiaDefines::DateTimePeriod period ) { - QDateTime truncatedTime = QDT::truncateTime( firstTimeStep, period ); + QDateTime truncatedTime = RiaQDateTimeTools::truncateTime( firstTimeStep, period ); - if ( QDT::lessThan( truncatedTime, firstTimeStep ) ) return QDT::addPeriod( truncatedTime, period ); + if ( RiaQDateTimeTools::lessThan( truncatedTime, firstTimeStep ) ) + return RiaQDateTimeTools::addPeriod( truncatedTime, period ); return truncatedTime; } diff --git a/ApplicationLibCode/Application/Tools/RiaTimeHistoryCurveResampler.h b/ApplicationLibCode/Application/Tools/RiaTimeHistoryCurveResampler.h index e917aadec7..d33ca73057 100644 --- a/ApplicationLibCode/Application/Tools/RiaTimeHistoryCurveResampler.h +++ b/ApplicationLibCode/Application/Tools/RiaTimeHistoryCurveResampler.h @@ -19,12 +19,10 @@ #pragma once #include "RiaCurveDataTools.h" -#include "RiaQDateTimeTools.h" +#include "RiaDateTimeDefines.h" #include -using QDT = RiaQDateTimeTools; - //================================================================================================== /// //================================================================================================== @@ -35,22 +33,21 @@ class RiaTimeHistoryCurveResampler void setCurveData( const std::vector& values, const std::vector& timeSteps ); - void resampleAndComputePeriodEndValues( RiaQDateTimeTools::DateTimePeriod period ); - void resampleAndComputeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod period ); + void resampleAndComputePeriodEndValues( RiaDefines::DateTimePeriod period ); + void resampleAndComputeWeightedMeanValues( RiaDefines::DateTimePeriod period ); const std::vector& resampledTimeSteps() const; const std::vector& resampledValues() const; - static std::vector - timeStepsFromTimeRange( RiaQDateTimeTools::DateTimePeriod period, time_t minTime, time_t maxTime ); + static std::vector timeStepsFromTimeRange( RiaDefines::DateTimePeriod period, time_t minTime, time_t maxTime ); private: - void computeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod period ); - void computePeriodEndValues( RiaQDateTimeTools::DateTimePeriod period ); + void computeWeightedMeanValues( RiaDefines::DateTimePeriod period ); + void computePeriodEndValues( RiaDefines::DateTimePeriod period ); void clearData(); - void computeResampledTimeSteps( RiaQDateTimeTools::DateTimePeriod period ); - static QDateTime firstResampledTimeStep( const QDateTime& firstTimestep, RiaQDateTimeTools::DateTimePeriod period ); + void computeResampledTimeSteps( RiaDefines::DateTimePeriod period ); + static QDateTime firstResampledTimeStep( const QDateTime& firstTimestep, RiaDefines::DateTimePeriod period ); inline double interpolatedValue( time_t t, time_t t1, double v1, time_t t2, double v2 ); private: diff --git a/ApplicationLibCode/Application/Tools/RiaWellLogUnitTools.inl b/ApplicationLibCode/Application/Tools/RiaWellLogUnitTools.inl index 97e0893743..45c345ca30 100644 --- a/ApplicationLibCode/Application/Tools/RiaWellLogUnitTools.inl +++ b/ApplicationLibCode/Application/Tools/RiaWellLogUnitTools.inl @@ -178,6 +178,8 @@ std::vector> RiaDefines::DepthUnitType unitsIn, RiaDefines::DepthUnitType unitsOut ) { + if ( depthsIn.empty() ) return {}; + std::vector> convertedDepths( depthsIn.size() ); double factor = 1.0; if ( unitsOut == RiaDefines::DepthUnitType::UNIT_METER && unitsIn == RiaDefines::DepthUnitType::UNIT_FEET ) @@ -335,6 +337,8 @@ template std::vector RiaWellLogUnitTools::tvdRKBs( const std::vector& measuredDepths, const RigWellPath* wellPath ) { + if ( measuredDepths.empty() ) return {}; + std::vector tvdRKBs( measuredDepths.size(), 0.0 ); for ( size_t i = 0; i < measuredDepths.size(); ++i ) { @@ -351,6 +355,8 @@ template std::vector RiaWellLogUnitTools::convertGpcm3ToBar( const std::vector& tvdRKBs, const std::vector& valuesInGpcm3 ) { + if ( tvdRKBs.empty() ) return {}; + CAF_ASSERT( tvdRKBs.size() == valuesInGpcm3.size() ); std::vector valuesInBar( valuesInGpcm3.size(), 0.0 ); @@ -378,6 +384,8 @@ template std::vector RiaWellLogUnitTools::convertBarToGpcm3( const std::vector& tvdRKBs, const std::vector& valuesInBar ) { + if ( tvdRKBs.empty() ) return {}; + CAF_ASSERT( tvdRKBs.size() == valuesInBar.size() ); std::vector valuesInGpcm3( valuesInBar.size(), 0.0 ); @@ -406,6 +414,8 @@ std::vector RiaWellLogUnitTools::convertNormalizedByPPToBar( const std::vector& tvdRKBs, const std::vector& normalizedValues ) { + if ( tvdRKBs.empty() ) return {}; + CAF_ASSERT( tvdRKBs.size() == normalizedValues.size() ); std::vector valuesInBar( tvdRKBs.size(), 0.0 ); @@ -424,6 +434,8 @@ std::vector RiaWellLogUnitTools::convertBarToNormalizedByPP( const std::vector& tvdRKBs, const std::vector& valuesInBar ) { + if ( tvdRKBs.empty() ) return {}; + CAF_ASSERT( tvdRKBs.size() == valuesInBar.size() ); std::vector normalizedValues( tvdRKBs.size(), 0.0 ); @@ -440,6 +452,8 @@ std::vector template std::vector RiaWellLogUnitTools::multiply( const std::vector& valuesIn, FloatType factor ) { + if ( valuesIn.empty() ) return {}; + std::vector valuesOut( valuesIn.size(), std::numeric_limits::infinity() ); for ( size_t i = 0; i < valuesIn.size(); ++i ) { diff --git a/ApplicationLibCode/Application/Tools/RiaWellNameComparer.cpp b/ApplicationLibCode/Application/Tools/RiaWellNameComparer.cpp index 9e7ad67150..82270e82c5 100644 --- a/ApplicationLibCode/Application/Tools/RiaWellNameComparer.cpp +++ b/ApplicationLibCode/Application/Tools/RiaWellNameComparer.cpp @@ -23,6 +23,9 @@ #include +std::map RiaWellNameComparer::sm_nameWithoutPrefix; +std::map RiaWellNameComparer::sm_matchedName; + //================================================================================================== // //================================================================================================== @@ -62,19 +65,41 @@ QString RiaWellNameComparer::tryFindMatchingWellPath( QString wellName ) //-------------------------------------------------------------------------------------------------- QString RiaWellNameComparer::tryMatchNameInList( QString searchName, const std::vector& nameList ) { + if ( sm_matchedName.count( searchName ) > 0 ) + { + return sm_matchedName[searchName]; + }; + // Try exact name match QString matchedName = tryMatchName( searchName, nameList ); if ( !matchedName.isEmpty() ) { + sm_matchedName[searchName] = matchedName; return matchedName; } // Try matching ignoring spaces, dashes and underscores - return tryMatchName( searchName, nameList, []( const QString& str ) { + matchedName = tryMatchName( searchName, nameList, []( const QString& str ) { QString s = str; s = removeWellNamePrefix( s ); return s.remove( ' ' ).remove( '-' ).remove( '_' ); } ); + + if ( !matchedName.isEmpty() ) + { + sm_matchedName[searchName] = matchedName; + } + + return matchedName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaWellNameComparer::clearCache() +{ + sm_nameWithoutPrefix.clear(); + sm_matchedName.clear(); } //-------------------------------------------------------------------------------------------------- @@ -111,8 +136,18 @@ QString RiaWellNameComparer::tryMatchName( QString sea //-------------------------------------------------------------------------------------------------- QString RiaWellNameComparer::removeWellNamePrefix( const QString& name ) { + if ( sm_nameWithoutPrefix.count( name ) > 0 ) + { + return sm_nameWithoutPrefix[name]; + }; + // Try to remove prefix on the format 'xx xxxx/xx-' std::regex pattern( "^.*\\d*[/]\\d*[-_]" ); - return QString::fromStdString( std::regex_replace( name.toStdString(), pattern, "" ) ); + auto withoutPrefix = std::regex_replace( name.toStdString(), pattern, "" ); + auto qWithoutPrefix = QString::fromStdString( withoutPrefix ); + + sm_nameWithoutPrefix[name] = qWithoutPrefix; + + return qWithoutPrefix; } diff --git a/ApplicationLibCode/Application/Tools/RiaWellNameComparer.h b/ApplicationLibCode/Application/Tools/RiaWellNameComparer.h index 22702c08b8..0a3c2a85d5 100644 --- a/ApplicationLibCode/Application/Tools/RiaWellNameComparer.h +++ b/ApplicationLibCode/Application/Tools/RiaWellNameComparer.h @@ -19,7 +19,9 @@ #pragma once #include + #include +#include #include //================================================================================================== @@ -32,13 +34,18 @@ class RiaWellNameComparer public: static QString tryFindMatchingSimWellName( QString searchName ); static QString tryFindMatchingWellPath( QString wellName ); - static QString tryMatchNameInList( QString searchName, const std::vector& nameList ); + static void clearCache(); + private: static QString tryMatchName( QString searchName, const std::vector& nameList, std::function stringFormatter = nullptr ); static QString removeWellNamePrefix( const QString& name ); + +private: + static std::map sm_nameWithoutPrefix; + static std::map sm_matchedName; }; diff --git a/ApplicationLibCode/Application/Tools/WellPathTools/RiaLineArcWellPathCalculator.cpp b/ApplicationLibCode/Application/Tools/WellPathTools/RiaLineArcWellPathCalculator.cpp index 3102720abf..4dcba331c0 100644 --- a/ApplicationLibCode/Application/Tools/WellPathTools/RiaLineArcWellPathCalculator.cpp +++ b/ApplicationLibCode/Application/Tools/WellPathTools/RiaLineArcWellPathCalculator.cpp @@ -43,8 +43,7 @@ RiaLineArcWellPathCalculator::RiaLineArcWellPathCalculator( const cvf::Vec3d& { m_lineArcEndpoints.push_back( activeWellPathTargets[0].targetPointXYZ + referencePointXyz ); m_targetStatuses.resize( activeWellPathTargets.size(), - { !activeWellPathTargets[0].isTangentConstrained, - 0.0, + { 0.0, 0.0, false, true, @@ -58,8 +57,7 @@ RiaLineArcWellPathCalculator::RiaLineArcWellPathCalculator( const cvf::Vec3d& } m_targetStatuses.resize( activeWellPathTargets.size(), - { false, - 0.0, + { 0.0, 0.0, false, false, @@ -76,20 +74,22 @@ RiaLineArcWellPathCalculator::RiaLineArcWellPathCalculator( const cvf::Vec3d& { for ( size_t tIdx = 0; tIdx < activeWellPathTargets.size() - 2; ++tIdx ) { - if ( !activeWellPathTargets[tIdx + 1].isTangentConstrained ) - { - cvf::Vec3d tangent = smootheningTargetTangent( activeWellPathTargets[tIdx].targetPointXYZ, - activeWellPathTargets[tIdx + 1].targetPointXYZ, - activeWellPathTargets[tIdx + 2].targetPointXYZ ); - RiaOffshoreSphericalCoords tangentSphCS( tangent ); - adjustedWellPathTargets[tIdx + 1].azimuth = tangentSphCS.azi(); - adjustedWellPathTargets[tIdx + 1].inclination = tangentSphCS.inc(); - adjustedWellPathTargets[tIdx + 1].isTangentConstrained = true; - - m_targetStatuses[tIdx + 1].hasDerivedTangent = true; - m_targetStatuses[tIdx + 1].resultAzimuth = tangentSphCS.azi(); - m_targetStatuses[tIdx + 1].resultInclination = tangentSphCS.inc(); - } + cvf::Vec3d tangent = smootheningTargetTangent( activeWellPathTargets[tIdx].targetPointXYZ, + activeWellPathTargets[tIdx + 1].targetPointXYZ, + activeWellPathTargets[tIdx + 2].targetPointXYZ ); + + RiaOffshoreSphericalCoords tangentSphCS( tangent ); + if ( !adjustedWellPathTargets[tIdx + 1].isAzimuthConstrained ) + adjustedWellPathTargets[tIdx + 1].azimuthRadians = tangentSphCS.azi(); + + if ( !adjustedWellPathTargets[tIdx + 1].isInclinationConstrained ) + adjustedWellPathTargets[tIdx + 1].inclinationRadians = tangentSphCS.inc(); + + adjustedWellPathTargets[tIdx + 1].isAzimuthConstrained = true; + adjustedWellPathTargets[tIdx + 1].isInclinationConstrained = true; + + m_targetStatuses[tIdx + 1].resultAzimuthRadians = adjustedWellPathTargets[tIdx + 1].azimuthRadians; + m_targetStatuses[tIdx + 1].resultInclinationRadians = adjustedWellPathTargets[tIdx + 1].inclinationRadians; } } @@ -100,7 +100,7 @@ RiaLineArcWellPathCalculator::RiaLineArcWellPathCalculator( const cvf::Vec3d& size_t startSSegmentIdx = 0; size_t endSSegementIdx = activeWellPathTargets.size() - 1; - if ( !adjustedWellPathTargets[0].isTangentConstrained ) + if ( !adjustedWellPathTargets[0].isAnyDirectionFixed() ) { startSSegmentIdx = 1; @@ -109,13 +109,13 @@ RiaLineArcWellPathCalculator::RiaLineArcWellPathCalculator( const cvf::Vec3d& WellTargetStatus& target1Status = m_targetStatuses[0]; WellTargetStatus& target2Status = m_targetStatuses[1]; - if ( adjustedWellPathTargets[1].isTangentConstrained ) + if ( adjustedWellPathTargets[1].isAnyDirectionFixed() ) { // Create an upside down J curve from target 2 back to 1 RiaJCurveCalculator jCurve( target2.targetPointXYZ, - target2.azimuth + M_PI, - M_PI - target2.inclination, + target2.azimuthRadians + M_PI, + M_PI - target2.inclinationRadians, target2.radius1, target1.targetPointXYZ ); @@ -126,14 +126,13 @@ RiaLineArcWellPathCalculator::RiaLineArcWellPathCalculator( const cvf::Vec3d& else if ( jCurve.curveStatus() == RiaJCurveCalculator::FAILED_RADIUS_TOO_LARGE ) { target2Status.hasOverriddenRadius1 = true; - target2Status.resultRadius1 = jCurve.radius(); } + target2Status.resultRadius1 = jCurve.radius(); m_lineArcEndpoints.push_back( target2.targetPointXYZ + referencePointXyz ); - target1Status.hasDerivedTangent = true; - target1Status.resultAzimuth = jCurve.endAzimuth() + M_PI; - target1Status.resultInclination = M_PI - jCurve.endInclination(); + target1Status.resultAzimuthRadians = jCurve.endAzimuth() + M_PI; + target1Status.resultInclinationRadians = M_PI - jCurve.endInclination(); target2Status.isRadius1Editable = true; } @@ -143,25 +142,23 @@ RiaLineArcWellPathCalculator::RiaLineArcWellPathCalculator( const cvf::Vec3d& cvf::Vec3d t12 = target2.targetPointXYZ - target1.targetPointXYZ; RiaOffshoreSphericalCoords t12Sph( t12 ); - target1Status.hasDerivedTangent = true; - target1Status.resultAzimuth = t12Sph.azi(); - target1Status.resultInclination = t12Sph.inc(); + target1Status.resultAzimuthRadians = t12Sph.azi(); + target1Status.resultInclinationRadians = t12Sph.inc(); - target2Status.hasDerivedTangent = true; - target2Status.resultAzimuth = t12Sph.azi(); - target2Status.resultInclination = t12Sph.inc(); + target2Status.resultAzimuthRadians = t12Sph.azi(); + target2Status.resultInclinationRadians = t12Sph.inc(); } - m_startTangent = RiaOffshoreSphericalCoords::unitVectorFromAziInc( target1Status.resultAzimuth, - target1Status.resultInclination ); + m_startTangent = RiaOffshoreSphericalCoords::unitVectorFromAziInc( target1Status.resultAzimuthRadians, + target1Status.resultInclinationRadians ); } else { - m_startTangent = RiaOffshoreSphericalCoords::unitVectorFromAziInc( activeWellPathTargets[0].azimuth, - activeWellPathTargets[0].inclination ); + m_startTangent = RiaOffshoreSphericalCoords::unitVectorFromAziInc( activeWellPathTargets[0].azimuthRadians, + activeWellPathTargets[0].inclinationRadians ); } - if ( !adjustedWellPathTargets.back().isTangentConstrained ) + if ( !adjustedWellPathTargets.back().isAnyDirectionFixed() ) { endSSegementIdx -= 1; } @@ -180,45 +177,44 @@ RiaLineArcWellPathCalculator::RiaLineArcWellPathCalculator( const cvf::Vec3d& // Ignore targets in the same place if ( ( target1.targetPointXYZ - target2.targetPointXYZ ).length() < 1e-6 ) continue; - if ( target1.isTangentConstrained && target2.isTangentConstrained ) + if ( target1.isAnyDirectionFixed() && target2.isAnyDirectionFixed() ) { RiaSCurveCalculator sCurveCalc( target1.targetPointXYZ, - target1.azimuth, - target1.inclination, + target1.azimuthRadians, + target1.inclinationRadians, target1.radius2, target2.targetPointXYZ, - target2.azimuth, - target2.inclination, + target2.azimuthRadians, + target2.inclinationRadians, target2.radius1 ); if ( sCurveCalc.solveStatus() != RiaSCurveCalculator::CONVERGED ) { double p1p2Length = ( target2.targetPointXYZ - target1.targetPointXYZ ).length(); sCurveCalc = RiaSCurveCalculator::fromTangentsAndLength( target1.targetPointXYZ, - target1.azimuth, - target1.inclination, + target1.azimuthRadians, + target1.inclinationRadians, 0.2 * p1p2Length, target2.targetPointXYZ, - target2.azimuth, - target2.inclination, + target2.azimuthRadians, + target2.inclinationRadians, 0.2 * p1p2Length ); // RiaLogging::warning("Using fall-back calculation of well path geometry between active target // number: " + QString::number(tIdx+1) + " and " + QString::number(tIdx+2)); target1Status.hasOverriddenRadius2 = true; - target1Status.resultRadius2 = sCurveCalc.firstRadius(); - target2Status.hasOverriddenRadius1 = true; - target2Status.resultRadius1 = sCurveCalc.secondRadius(); } + target2Status.resultRadius1 = sCurveCalc.secondRadius(); + target1Status.resultRadius2 = sCurveCalc.firstRadius(); + target2Status.isRadius1Editable = true; + target1Status.isRadius2Editable = true; + m_lineArcEndpoints.push_back( sCurveCalc.firstArcEndpoint() + referencePointXyz ); m_lineArcEndpoints.push_back( sCurveCalc.secondArcStartpoint() + referencePointXyz ); m_lineArcEndpoints.push_back( target2.targetPointXYZ + referencePointXyz ); - - target1Status.isRadius2Editable = true; - target2Status.isRadius1Editable = true; } } } @@ -236,8 +232,8 @@ RiaLineArcWellPathCalculator::RiaLineArcWellPathCalculator( const cvf::Vec3d& // Create an ordinary J curve RiaJCurveCalculator jCurve( target1.targetPointXYZ, - target1.azimuth, - target1.inclination, + target1.azimuthRadians, + target1.inclinationRadians, target1.radius2, target2.targetPointXYZ ); @@ -248,16 +244,15 @@ RiaLineArcWellPathCalculator::RiaLineArcWellPathCalculator( const cvf::Vec3d& else if ( jCurve.curveStatus() == RiaJCurveCalculator::FAILED_RADIUS_TOO_LARGE ) { target1Status.hasOverriddenRadius2 = true; - target1Status.resultRadius2 = jCurve.radius(); } - m_lineArcEndpoints.push_back( target2.targetPointXYZ + referencePointXyz ); - + target1Status.resultRadius2 = jCurve.radius(); target1Status.isRadius2Editable = true; - target2Status.hasDerivedTangent = true; - target2Status.resultAzimuth = jCurve.endAzimuth(); - target2Status.resultInclination = jCurve.endInclination(); + m_lineArcEndpoints.push_back( target2.targetPointXYZ + referencePointXyz ); + + target2Status.resultAzimuthRadians = jCurve.endAzimuth(); + target2Status.resultInclinationRadians = jCurve.endInclination(); } } diff --git a/ApplicationLibCode/Application/Tools/WellPathTools/RiaLineArcWellPathCalculator.h b/ApplicationLibCode/Application/Tools/WellPathTools/RiaLineArcWellPathCalculator.h index c5a8cdaf77..b9411aa3a0 100644 --- a/ApplicationLibCode/Application/Tools/WellPathTools/RiaLineArcWellPathCalculator.h +++ b/ApplicationLibCode/Application/Tools/WellPathTools/RiaLineArcWellPathCalculator.h @@ -27,10 +27,13 @@ class RiaLineArcWellPathCalculator public: struct WellTarget { + bool isAnyDirectionFixed() const { return isAzimuthConstrained || isInclinationConstrained; } + cvf::Vec3d targetPointXYZ; - bool isTangentConstrained; - double azimuth; - double inclination; + bool isAzimuthConstrained; + bool isInclinationConstrained; + double azimuthRadians; + double inclinationRadians; double radius1; double radius2; @@ -41,9 +44,8 @@ class RiaLineArcWellPathCalculator struct WellTargetStatus { - bool hasDerivedTangent; - double resultAzimuth; - double resultInclination; + double resultAzimuthRadians; + double resultInclinationRadians; bool isRadius1Editable; bool hasOverriddenRadius1; diff --git a/ApplicationLibCode/CMakeLists.txt b/ApplicationLibCode/CMakeLists.txt index 564ddf3e3b..7623a3eb23 100644 --- a/ApplicationLibCode/CMakeLists.txt +++ b/ApplicationLibCode/CMakeLists.txt @@ -25,15 +25,11 @@ option(RESINSIGHT_TREAT_WARNINGS_AS_ERRORS "Treat warnings as errors (stops build)" OFF ) -find_package( - Qt5 - COMPONENTS Core - QUIET -) +find_package(Qt5 ${RI_QT_MINIMUM_VERSION} COMPONENTS Core) if(Qt5Core_FOUND) find_package( - Qt5 + Qt5 ${RI_QT_MINIMUM_VERSION} COMPONENTS Core Gui OpenGL @@ -339,30 +335,42 @@ if(RESINSIGHT_ENABLE_PRECOMPILED_HEADERS) ) endif() -if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") - set_target_properties( - ${PROJECT_NAME} - PROPERTIES - COMPILE_FLAGS - "-Wall -Wno-unused-parameter -Wno-reorder -Wno-parentheses -Wno-switch" +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + target_compile_options( + ApplicationLibCode PRIVATE -Wall -Wno-unused-parameter -Wno-reorder + -Wno-parentheses -Wno-switch ) - # Treat warnings as errors if asked to do so - if(RESINSIGHT_TREAT_WARNINGS_AS_ERRORS) - set_target_properties( - ${PROJECT_NAME} - PROPERTIES - COMPILE_FLAGS - "-Wall -Wno-unused-parameter -Wno-reorder -Wno-parentheses -Wno-switch -Werror" - ) - endif() +endif() - if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - set_target_properties( - ${PROJECT_NAME} - PROPERTIES - COMPILE_FLAGS - "-Wall -Wno-unused-parameter -Wno-reorder -Wno-parentheses -Wno-switch -Wno-delete-abstract-non-virtual-dtor -Wno-undefined-var-template -Wno-invalid-source-encoding -Wno-enum-compare -Wno-call-to-pure-virtual-from-ctor-dtor -Wno-unused-variable -Wno-unused-private-field -Wno-unused-lambda-capture -Wno-delete-non-abstract-non-virtual-dtor -Wno-braced-scalar-init -Wno-tautological-constant-out-of-range-compare" - ) +if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + + target_compile_options( + ApplicationLibCode + PRIVATE -Wall + -Wno-unused-parameter + -Wno-reorder + -Wno-parentheses + -Wno-switch + -Wno-delete-abstract-non-virtual-dtor + -Wno-undefined-var-template + -Wno-invalid-source-encoding + -Wno-enum-compare + -Wno-call-to-pure-virtual-from-ctor-dtor + -Wno-unused-variable + -Wno-unused-private-field + -Wno-unused-lambda-capture + -Wno-delete-non-abstract-non-virtual-dtor + -Wno-braced-scalar-init + -Wno-tautological-constant-out-of-range-compare + -Wno-undefined-var-template + ) +endif() + +if(RESINSIGHT_TREAT_WARNINGS_AS_ERRORS) + if(MSVC) + target_compile_options(ApplicationLibCode PRIVATE /WX) + elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + target_compile_options(ApplicationLibCode PRIVATE -Werror) endif() endif() @@ -376,13 +384,7 @@ if(MSVC) # set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/W3 /wd4190 # /wd4100 /wd4127") - set(BUILD_FLAGS_FOR_MSVC "/wd4190 /wd4100 /wd4127 /wd4245 /wd4005") - - if(Qt5Core_VERSION_STRING GREATER_EQUAL 5.10) - # Disable warning for deprecated functions in newer versions of Qt - # https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4996?view=msvc-160 - set(BUILD_FLAGS_FOR_MSVC "${BUILD_FLAGS_FOR_MSVC} /wd4996") - endif() + set(BUILD_FLAGS_FOR_MSVC "/wd4190 /wd4100 /wd4127 /wd4245 /wd4005 /wd4251") if(CMAKE_CXX_COMPILER_VERSION LESS_EQUAL 19.14) # The following warning is generated over 800 times from a qwt header only diff --git a/ApplicationLibCode/CommandFileInterface/RicfCloneView.cpp b/ApplicationLibCode/CommandFileInterface/RicfCloneView.cpp index 71b4fe68b0..a489e495b7 100644 --- a/ApplicationLibCode/CommandFileInterface/RicfCloneView.cpp +++ b/ApplicationLibCode/CommandFileInterface/RicfCloneView.cpp @@ -25,7 +25,7 @@ CAF_PDM_SOURCE_INIT( RicfCloneView, "cloneView" ); //-------------------------------------------------------------------------------------------------- RicfCloneView::RicfCloneView() { - CAF_PDM_InitScriptableField( &m_viewId, "viewId", -1, "View Id", "", "", "" ); + CAF_PDM_InitScriptableField( &m_viewId, "viewId", -1, "View Id" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/CommandFileInterface/RicfComputeCaseGroupStatistics.cpp b/ApplicationLibCode/CommandFileInterface/RicfComputeCaseGroupStatistics.cpp index 39679c5387..87d317dd98 100644 --- a/ApplicationLibCode/CommandFileInterface/RicfComputeCaseGroupStatistics.cpp +++ b/ApplicationLibCode/CommandFileInterface/RicfComputeCaseGroupStatistics.cpp @@ -38,8 +38,8 @@ CAF_PDM_SOURCE_INIT( RicfComputeCaseGroupStatistics, "computeCaseGroupStatistics //-------------------------------------------------------------------------------------------------- RicfComputeCaseGroupStatistics::RicfComputeCaseGroupStatistics() { - CAF_PDM_InitScriptableField( &m_groupId, "caseGroupId", -1, "Case Group ID", "", "", "" ); - CAF_PDM_InitScriptableField( &m_caseIds, "caseIds", std::vector(), "Case IDs", "", "", "" ); + CAF_PDM_InitScriptableField( &m_groupId, "caseGroupId", -1, "Case Group ID" ); + CAF_PDM_InitScriptableField( &m_caseIds, "caseIds", std::vector(), "Case IDs" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/CommandFileInterface/RicfCreateGridCaseGroup.cpp b/ApplicationLibCode/CommandFileInterface/RicfCreateGridCaseGroup.cpp index 3e8c21bcd0..8782270d1a 100644 --- a/ApplicationLibCode/CommandFileInterface/RicfCreateGridCaseGroup.cpp +++ b/ApplicationLibCode/CommandFileInterface/RicfCreateGridCaseGroup.cpp @@ -37,9 +37,9 @@ CAF_PDM_SOURCE_INIT( RicfCreateGridCaseGroupResult, "createGridCaseGroupResult" RicfCreateGridCaseGroupResult::RicfCreateGridCaseGroupResult( int caseGroupId /*= -1*/, const QString& caseGroupName /*= ""*/ ) { - CAF_PDM_InitObject( "case_group_result", "", "", "" ); - CAF_PDM_InitField( &this->caseGroupId, "groupId", caseGroupId, "", "", "", "" ); - CAF_PDM_InitField( &this->caseGroupName, "groupName", caseGroupName, "", "", "", "" ); + CAF_PDM_InitObject( "case_group_result" ); + CAF_PDM_InitField( &this->caseGroupId, "groupId", caseGroupId, "" ); + CAF_PDM_InitField( &this->caseGroupName, "groupName", caseGroupName, "" ); } CAF_PDM_SOURCE_INIT( RicfCreateGridCaseGroup, "createGridCaseGroup" ); @@ -49,7 +49,7 @@ CAF_PDM_SOURCE_INIT( RicfCreateGridCaseGroup, "createGridCaseGroup" ); //-------------------------------------------------------------------------------------------------- RicfCreateGridCaseGroup::RicfCreateGridCaseGroup() { - CAF_PDM_InitScriptableFieldNoDefault( &m_casePaths, "casePaths", "List of Paths to Case Files", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_casePaths, "casePaths", "List of Paths to Case Files" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/CommandFileInterface/RicfCreateLgrForCompletions.cpp b/ApplicationLibCode/CommandFileInterface/RicfCreateLgrForCompletions.cpp index d55ab95501..fcceaf00c4 100644 --- a/ApplicationLibCode/CommandFileInterface/RicfCreateLgrForCompletions.cpp +++ b/ApplicationLibCode/CommandFileInterface/RicfCreateLgrForCompletions.cpp @@ -48,13 +48,13 @@ CAF_PDM_SOURCE_INIT( RicfCreateLgrForCompletions, "createLgrForCompletions" ); //-------------------------------------------------------------------------------------------------- RicfCreateLgrForCompletions::RicfCreateLgrForCompletions() { - CAF_PDM_InitScriptableField( &m_caseId, "caseId", -1, "Case ID", "", "", "" ); - CAF_PDM_InitScriptableField( &m_timeStep, "timeStep", 0, "Time Step Index", "", "", "" ); - CAF_PDM_InitScriptableField( &m_wellPathNames, "wellPathNames", std::vector(), "Well Path Names", "", "", "" ); - CAF_PDM_InitScriptableField( &m_refinementI, "refinementI", -1, "RefinementI", "", "", "" ); - CAF_PDM_InitScriptableField( &m_refinementJ, "refinementJ", -1, "RefinementJ", "", "", "" ); - CAF_PDM_InitScriptableField( &m_refinementK, "refinementK", -1, "RefinementK", "", "", "" ); - CAF_PDM_InitScriptableField( &m_splitType, "splitType", Lgr::SplitTypeEnum(), "SplitType", "", "", "" ); + CAF_PDM_InitScriptableField( &m_caseId, "caseId", -1, "Case ID" ); + CAF_PDM_InitScriptableField( &m_timeStep, "timeStep", 0, "Time Step Index" ); + CAF_PDM_InitScriptableField( &m_wellPathNames, "wellPathNames", std::vector(), "Well Path Names" ); + CAF_PDM_InitScriptableField( &m_refinementI, "refinementI", -1, "RefinementI" ); + CAF_PDM_InitScriptableField( &m_refinementJ, "refinementJ", -1, "RefinementJ" ); + CAF_PDM_InitScriptableField( &m_refinementK, "refinementK", -1, "RefinementK" ); + CAF_PDM_InitScriptableField( &m_splitType, "splitType", Lgr::SplitTypeEnum(), "SplitType" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/CommandFileInterface/RicfCreateMultipleFractures.cpp b/ApplicationLibCode/CommandFileInterface/RicfCreateMultipleFractures.cpp index 45393babd7..ac5b20381e 100644 --- a/ApplicationLibCode/CommandFileInterface/RicfCreateMultipleFractures.cpp +++ b/ApplicationLibCode/CommandFileInterface/RicfCreateMultipleFractures.cpp @@ -58,21 +58,18 @@ void AppEnum::setUp() //-------------------------------------------------------------------------------------------------- RicfCreateMultipleFractures::RicfCreateMultipleFractures() { - CAF_PDM_InitScriptableField( &m_caseId, "caseId", -1, "Case ID", "", "", "" ); - CAF_PDM_InitScriptableField( &m_wellPathNames, "wellPathNames", std::vector(), "Well Path Names", "", "", "" ); - CAF_PDM_InitScriptableField( &m_minDistFromWellTd, "minDistFromWellTd", 100.0, "Min Distance From Well TD", "", "", "" ); - CAF_PDM_InitScriptableField( &m_maxFracturesPerWell, "maxFracturesPerWell", 100, "Max Fractures per Well", "", "", "" ); - CAF_PDM_InitScriptableField( &m_templateId, "templateId", -1, "Template ID", "", "", "" ); - CAF_PDM_InitScriptableField( &m_topLayer, "topLayer", -1, "Top Layer", "", "", "" ); - CAF_PDM_InitScriptableField( &m_baseLayer, "baseLayer", -1, "Base Layer", "", "", "" ); - CAF_PDM_InitScriptableField( &m_spacing, "spacing", 300.0, "Spacing", "", "", "" ); + CAF_PDM_InitScriptableField( &m_caseId, "caseId", -1, "Case ID" ); + CAF_PDM_InitScriptableField( &m_wellPathNames, "wellPathNames", std::vector(), "Well Path Names" ); + CAF_PDM_InitScriptableField( &m_minDistFromWellTd, "minDistFromWellTd", 100.0, "Min Distance From Well TD" ); + CAF_PDM_InitScriptableField( &m_maxFracturesPerWell, "maxFracturesPerWell", 100, "Max Fractures per Well" ); + CAF_PDM_InitScriptableField( &m_templateId, "templateId", -1, "Template ID" ); + CAF_PDM_InitScriptableField( &m_topLayer, "topLayer", -1, "Top Layer" ); + CAF_PDM_InitScriptableField( &m_baseLayer, "baseLayer", -1, "Base Layer" ); + CAF_PDM_InitScriptableField( &m_spacing, "spacing", 300.0, "Spacing" ); CAF_PDM_InitScriptableField( &m_action, "action", caf::AppEnum( MultipleFractures::Action::APPEND_FRACTURES ), - "Action", - "", - "", - "" ); + "Action" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/CommandFileInterface/RicfCreateSaturationPressurePlots.cpp b/ApplicationLibCode/CommandFileInterface/RicfCreateSaturationPressurePlots.cpp index 1d000c51de..84db70096d 100644 --- a/ApplicationLibCode/CommandFileInterface/RicfCreateSaturationPressurePlots.cpp +++ b/ApplicationLibCode/CommandFileInterface/RicfCreateSaturationPressurePlots.cpp @@ -38,7 +38,7 @@ CAF_PDM_SOURCE_INIT( RicfCreateSaturationPressurePlots, "createSaturationPressur //-------------------------------------------------------------------------------------------------- RicfCreateSaturationPressurePlots::RicfCreateSaturationPressurePlots() { - CAF_PDM_InitScriptableField( &m_caseIds, "caseIds", std::vector(), "Case IDs", "", "", "" ); + CAF_PDM_InitScriptableField( &m_caseIds, "caseIds", std::vector(), "Case IDs" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/CommandFileInterface/RicfCreateStatisticsCase.cpp b/ApplicationLibCode/CommandFileInterface/RicfCreateStatisticsCase.cpp index 750fb6ef6c..77ed10669f 100644 --- a/ApplicationLibCode/CommandFileInterface/RicfCreateStatisticsCase.cpp +++ b/ApplicationLibCode/CommandFileInterface/RicfCreateStatisticsCase.cpp @@ -38,8 +38,8 @@ CAF_PDM_SOURCE_INIT( RicfCreateStatisticsCaseResult, "createStatisticsCaseResult //-------------------------------------------------------------------------------------------------- RicfCreateStatisticsCaseResult::RicfCreateStatisticsCaseResult( int caseId /*= -1*/ ) { - CAF_PDM_InitObject( "statistics_case_result", "", "", "" ); - CAF_PDM_InitField( &this->caseId, "caseId", caseId, "", "", "", "" ); + CAF_PDM_InitObject( "statistics_case_result" ); + CAF_PDM_InitField( &this->caseId, "caseId", caseId, "" ); } CAF_PDM_SOURCE_INIT( RicfCreateStatisticsCase, "createStatisticsCase" ); @@ -49,7 +49,7 @@ CAF_PDM_SOURCE_INIT( RicfCreateStatisticsCase, "createStatisticsCase" ); //-------------------------------------------------------------------------------------------------- RicfCreateStatisticsCase::RicfCreateStatisticsCase() { - CAF_PDM_InitScriptableField( &m_caseGroupId, "caseGroupId", -1, "Case Group Id", "", "", "" ); + CAF_PDM_InitScriptableField( &m_caseGroupId, "caseGroupId", -1, "Case Group Id" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/CommandFileInterface/RicfCreateView.cpp b/ApplicationLibCode/CommandFileInterface/RicfCreateView.cpp index af3e6f1796..1a518ef432 100644 --- a/ApplicationLibCode/CommandFileInterface/RicfCreateView.cpp +++ b/ApplicationLibCode/CommandFileInterface/RicfCreateView.cpp @@ -23,8 +23,8 @@ CAF_PDM_SOURCE_INIT( RicfCreateViewResult, "createViewResult" ); //-------------------------------------------------------------------------------------------------- RicfCreateViewResult::RicfCreateViewResult( int viewId /*= -1*/ ) { - CAF_PDM_InitObject( "view_result", "", "", "" ); - CAF_PDM_InitField( &this->viewId, "viewId", viewId, "", "", "", "" ); + CAF_PDM_InitObject( "view_result" ); + CAF_PDM_InitField( &this->viewId, "viewId", viewId, "" ); } CAF_PDM_SOURCE_INIT( RicfCreateView, "createView" ); @@ -34,7 +34,7 @@ CAF_PDM_SOURCE_INIT( RicfCreateView, "createView" ); //-------------------------------------------------------------------------------------------------- RicfCreateView::RicfCreateView() { - CAF_PDM_InitScriptableField( &m_caseId, "caseId", -1, "Case Id", "", "", "" ); + CAF_PDM_InitScriptableField( &m_caseId, "caseId", -1, "Case Id" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/CommandFileInterface/RicfCreateWellBoreStabilityPlotFeature.cpp b/ApplicationLibCode/CommandFileInterface/RicfCreateWellBoreStabilityPlotFeature.cpp index 758b9762b9..386d02286c 100644 --- a/ApplicationLibCode/CommandFileInterface/RicfCreateWellBoreStabilityPlotFeature.cpp +++ b/ApplicationLibCode/CommandFileInterface/RicfCreateWellBoreStabilityPlotFeature.cpp @@ -39,8 +39,8 @@ CAF_PDM_SOURCE_INIT( RicfCreateWbsPlotResult, "createWbsPlotResult" ); //-------------------------------------------------------------------------------------------------- RicfCreateWbsPlotResult::RicfCreateWbsPlotResult( int viewId /*= -1*/ ) { - CAF_PDM_InitObject( "wbs_result", "", "", "" ); - CAF_PDM_InitField( &this->viewId, "viewId", viewId, "", "", "", "" ); + CAF_PDM_InitObject( "wbs_result" ); + CAF_PDM_InitField( &this->viewId, "viewId", viewId, "" ); } CAF_PDM_SOURCE_INIT( RicfCreateWellBoreStabilityPlotFeature, "createWellBoreStabilityPlot" ); @@ -50,11 +50,11 @@ CAF_PDM_SOURCE_INIT( RicfCreateWellBoreStabilityPlotFeature, "createWellBoreStab //-------------------------------------------------------------------------------------------------- RicfCreateWellBoreStabilityPlotFeature::RicfCreateWellBoreStabilityPlotFeature() { - CAF_PDM_InitScriptableField( &m_caseId, "caseId", -1, "GeoMech Case Id", "", "", "" ); - CAF_PDM_InitScriptableField( &m_wellPath, "wellPath", QString( "" ), "Well Path", "", "", "" ); - CAF_PDM_InitScriptableField( &m_timeStep, "timeStep", -1, "Time Step", "", "", "" ); + CAF_PDM_InitScriptableField( &m_caseId, "caseId", -1, "GeoMech Case Id" ); + CAF_PDM_InitScriptableField( &m_wellPath, "wellPath", QString( "" ), "Well Path" ); + CAF_PDM_InitScriptableField( &m_timeStep, "timeStep", -1, "Time Step" ); - CAF_PDM_InitFieldNoDefault( &m_wbsParameters, "wbsParameters", "WbsParameters", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wbsParameters, "wbsParameters", "WbsParameters" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/CommandFileInterface/RicfExportFlowCharacteristics.cpp b/ApplicationLibCode/CommandFileInterface/RicfExportFlowCharacteristics.cpp index bdddec4424..954c246ff1 100644 --- a/ApplicationLibCode/CommandFileInterface/RicfExportFlowCharacteristics.cpp +++ b/ApplicationLibCode/CommandFileInterface/RicfExportFlowCharacteristics.cpp @@ -42,13 +42,13 @@ CAF_PDM_SOURCE_INIT( RicfExportFlowCharacteristics, "exportFlowCharacteristics" //-------------------------------------------------------------------------------------------------- RicfExportFlowCharacteristics::RicfExportFlowCharacteristics() { - CAF_PDM_InitScriptableField( &m_caseId, "caseId", -1, "Case ID", "", "", "" ); - CAF_PDM_InitScriptableField( &m_selectedTimeSteps, "timeSteps", std::vector(), "Selected Time Steps", "", "", "" ); - CAF_PDM_InitScriptableField( &m_injectors, "injectors", std::vector(), "Injectors", "", "", "" ); - CAF_PDM_InitScriptableField( &m_producers, "producers", std::vector(), "Producers", "", "", "" ); - CAF_PDM_InitScriptableField( &m_fileName, "fileName", QString(), "Export File Name", "", "", "" ); - CAF_PDM_InitScriptableField( &m_minCommunication, "minimumCommunication", 0.0, "Minimum Communication", "", "", "" ); - CAF_PDM_InitScriptableField( &m_maxPvFraction, "aquiferCellThreshold", 0.1, "Aquifer Cell Threshold", "", "", "" ); + CAF_PDM_InitScriptableField( &m_caseId, "caseId", -1, "Case ID" ); + CAF_PDM_InitScriptableField( &m_selectedTimeSteps, "timeSteps", std::vector(), "Selected Time Steps" ); + CAF_PDM_InitScriptableField( &m_injectors, "injectors", std::vector(), "Injectors" ); + CAF_PDM_InitScriptableField( &m_producers, "producers", std::vector(), "Producers" ); + CAF_PDM_InitScriptableField( &m_fileName, "fileName", QString(), "Export File Name" ); + CAF_PDM_InitScriptableField( &m_minCommunication, "minimumCommunication", 0.0, "Minimum Communication" ); + CAF_PDM_InitScriptableField( &m_maxPvFraction, "aquiferCellThreshold", 0.1, "Aquifer Cell Threshold" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/CommandFileInterface/RicfExportLgrForCompletions.cpp b/ApplicationLibCode/CommandFileInterface/RicfExportLgrForCompletions.cpp index 1e746d2c37..36edfc00cf 100644 --- a/ApplicationLibCode/CommandFileInterface/RicfExportLgrForCompletions.cpp +++ b/ApplicationLibCode/CommandFileInterface/RicfExportLgrForCompletions.cpp @@ -47,13 +47,13 @@ CAF_PDM_SOURCE_INIT( RicfExportLgrForCompletions, "exportLgrForCompletions" ); //-------------------------------------------------------------------------------------------------- RicfExportLgrForCompletions::RicfExportLgrForCompletions() { - CAF_PDM_InitScriptableField( &m_caseId, "caseId", -1, "Case ID", "", "", "" ); - CAF_PDM_InitScriptableField( &m_timeStep, "timeStep", -1, "Time Step Index", "", "", "" ); - CAF_PDM_InitScriptableField( &m_wellPathNames, "wellPathNames", std::vector(), "Well Path Names", "", "", "" ); - CAF_PDM_InitScriptableField( &m_refinementI, "refinementI", -1, "RefinementI", "", "", "" ); - CAF_PDM_InitScriptableField( &m_refinementJ, "refinementJ", -1, "RefinementJ", "", "", "" ); - CAF_PDM_InitScriptableField( &m_refinementK, "refinementK", -1, "RefinementK", "", "", "" ); - CAF_PDM_InitScriptableField( &m_splitType, "splitType", Lgr::SplitTypeEnum(), "SplitType", "", "", "" ); + CAF_PDM_InitScriptableField( &m_caseId, "caseId", -1, "Case ID" ); + CAF_PDM_InitScriptableField( &m_timeStep, "timeStep", -1, "Time Step Index" ); + CAF_PDM_InitScriptableField( &m_wellPathNames, "wellPathNames", std::vector(), "Well Path Names" ); + CAF_PDM_InitScriptableField( &m_refinementI, "refinementI", -1, "RefinementI" ); + CAF_PDM_InitScriptableField( &m_refinementJ, "refinementJ", -1, "RefinementJ" ); + CAF_PDM_InitScriptableField( &m_refinementK, "refinementK", -1, "RefinementK" ); + CAF_PDM_InitScriptableField( &m_splitType, "splitType", Lgr::SplitTypeEnum(), "SplitType" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/CommandFileInterface/RicfExportMsw.cpp b/ApplicationLibCode/CommandFileInterface/RicfExportMsw.cpp index 8b430a84e6..fe7a6f9572 100644 --- a/ApplicationLibCode/CommandFileInterface/RicfExportMsw.cpp +++ b/ApplicationLibCode/CommandFileInterface/RicfExportMsw.cpp @@ -45,18 +45,12 @@ CAF_PDM_SOURCE_INIT( RicfExportMsw, "exportMsw" ); //-------------------------------------------------------------------------------------------------- RicfExportMsw::RicfExportMsw() { - CAF_PDM_InitScriptableField( &m_caseId, "caseId", -1, "Case ID", "", "", "" ); - CAF_PDM_InitScriptableField( &m_wellPathName, "wellPath", QString(), "Well Path Name", "", "", "" ); - CAF_PDM_InitScriptableField( &m_includePerforations, "includePerforations", true, "Include Perforations", "", "", "" ); - CAF_PDM_InitScriptableField( &m_includeFishbones, "includeFishbones", true, "Include Fishbones", "", "", "" ); - CAF_PDM_InitScriptableField( &m_includeFractures, "includeFractures", true, "Include Fractures", "", "", "" ); - CAF_PDM_InitScriptableField( &m_fileSplit, - "fileSplit", - RicExportCompletionDataSettingsUi::ExportSplitType(), - "File Split", - "", - "", - "" ); + CAF_PDM_InitScriptableField( &m_caseId, "caseId", -1, "Case ID" ); + CAF_PDM_InitScriptableField( &m_wellPathName, "wellPath", QString(), "Well Path Name" ); + CAF_PDM_InitScriptableField( &m_includePerforations, "includePerforations", true, "Include Perforations" ); + CAF_PDM_InitScriptableField( &m_includeFishbones, "includeFishbones", true, "Include Fishbones" ); + CAF_PDM_InitScriptableField( &m_includeFractures, "includeFractures", true, "Include Fractures" ); + CAF_PDM_InitScriptableField( &m_fileSplit, "fileSplit", RicExportCompletionDataSettingsUi::ExportSplitType(), "File Split" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/CommandFileInterface/RicfExportMultiCaseSnapshots.cpp b/ApplicationLibCode/CommandFileInterface/RicfExportMultiCaseSnapshots.cpp index febd909ccb..ccac71abfb 100644 --- a/ApplicationLibCode/CommandFileInterface/RicfExportMultiCaseSnapshots.cpp +++ b/ApplicationLibCode/CommandFileInterface/RicfExportMultiCaseSnapshots.cpp @@ -33,7 +33,7 @@ CAF_PDM_SOURCE_INIT( RicfExportMultiCaseSnapshots, "exportMultiCaseSnapshots" ); //-------------------------------------------------------------------------------------------------- RicfExportMultiCaseSnapshots::RicfExportMultiCaseSnapshots() { - CAF_PDM_InitScriptableField( &m_gridListFile, "gridListFile", QString(), "Grid List File", "", "", "" ); + CAF_PDM_InitScriptableField( &m_gridListFile, "gridListFile", QString(), "Grid List File" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/CommandFileInterface/RicfExportProperty.cpp b/ApplicationLibCode/CommandFileInterface/RicfExportProperty.cpp index 1e3902c181..778b593672 100644 --- a/ApplicationLibCode/CommandFileInterface/RicfExportProperty.cpp +++ b/ApplicationLibCode/CommandFileInterface/RicfExportProperty.cpp @@ -47,12 +47,12 @@ CAF_PDM_SOURCE_INIT( RicfExportProperty, "exportProperty" ); RicfExportProperty::RicfExportProperty() { // clang-format off - CAF_PDM_InitScriptableField(&m_caseId, "caseId", -1, "Case ID", "", "", ""); - CAF_PDM_InitScriptableField(&m_timeStepIndex, "timeStep", -1, "Time Step Index", "", "", ""); - CAF_PDM_InitScriptableField(&m_propertyName, "property", QString(), "Property Name", "", "", ""); - CAF_PDM_InitScriptableField(&m_eclipseKeyword, "eclipseKeyword", QString(), "Eclipse Keyword", "", "", ""); - CAF_PDM_InitScriptableField(&m_undefinedValue, "undefinedValue", 0.0, "Undefined Value", "", "", ""); - CAF_PDM_InitScriptableField(&m_exportFileName, "exportFile", QString(), "Export FileName", "", "", ""); + CAF_PDM_InitScriptableField(&m_caseId, "caseId", -1, "Case ID"); + CAF_PDM_InitScriptableField(&m_timeStepIndex, "timeStep", -1, "Time Step Index"); + CAF_PDM_InitScriptableField(&m_propertyName, "property", QString(), "Property Name"); + CAF_PDM_InitScriptableField(&m_eclipseKeyword, "eclipseKeyword", QString(), "Eclipse Keyword"); + CAF_PDM_InitScriptableField(&m_undefinedValue, "undefinedValue", 0.0, "Undefined Value"); + CAF_PDM_InitScriptableField(&m_exportFileName, "exportFile", QString(), "Export FileName"); // clang-format on } diff --git a/ApplicationLibCode/CommandFileInterface/RicfExportPropertyInViews.cpp b/ApplicationLibCode/CommandFileInterface/RicfExportPropertyInViews.cpp index 4f02237214..eb62f8ae06 100644 --- a/ApplicationLibCode/CommandFileInterface/RicfExportPropertyInViews.cpp +++ b/ApplicationLibCode/CommandFileInterface/RicfExportPropertyInViews.cpp @@ -47,10 +47,10 @@ CAF_PDM_SOURCE_INIT( RicfExportPropertyInViews, "exportPropertyInViews" ); //-------------------------------------------------------------------------------------------------- RicfExportPropertyInViews::RicfExportPropertyInViews() { - CAF_PDM_InitScriptableField( &m_caseId, "caseId", -1, "Case ID", "", "", "" ); - CAF_PDM_InitScriptableField( &m_viewIds, "viewIds", std::vector(), "View IDs", "", "", "" ); - CAF_PDM_InitScriptableField( &m_viewNames, "viewNames", std::vector(), "View Names", "", "", "" ); - CAF_PDM_InitScriptableField( &m_undefinedValue, "undefinedValue", 0.0, "Undefined Value", "", "", "" ); + CAF_PDM_InitScriptableField( &m_caseId, "caseId", -1, "Case ID" ); + CAF_PDM_InitScriptableField( &m_viewIds, "viewIds", std::vector(), "View IDs" ); + CAF_PDM_InitScriptableField( &m_viewNames, "viewNames", std::vector(), "View Names" ); + CAF_PDM_InitScriptableField( &m_undefinedValue, "undefinedValue", 0.0, "Undefined Value" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/CommandFileInterface/RicfExportSimWellFractureCompletions.cpp b/ApplicationLibCode/CommandFileInterface/RicfExportSimWellFractureCompletions.cpp index 5ed162c483..393605dbad 100644 --- a/ApplicationLibCode/CommandFileInterface/RicfExportSimWellFractureCompletions.cpp +++ b/ApplicationLibCode/CommandFileInterface/RicfExportSimWellFractureCompletions.cpp @@ -46,31 +46,16 @@ CAF_PDM_SOURCE_INIT( RicfExportSimWellFractureCompletions, "exportSimWellFractur //-------------------------------------------------------------------------------------------------- RicfExportSimWellFractureCompletions::RicfExportSimWellFractureCompletions() { - CAF_PDM_InitScriptableField( &m_caseId, "caseId", -1, "Case ID", "", "", "" ); - CAF_PDM_InitScriptableField( &m_viewId, "viewId", -1, "View ID", "", "", "" ); - CAF_PDM_InitScriptableField( &m_viewName, "viewName", QString( "" ), "View Name", "", "", "" ); - CAF_PDM_InitScriptableField( &m_timeStep, "timeStep", -1, "Time Step Index", "", "", "" ); - CAF_PDM_InitScriptableField( &m_simWellNames, - "simulationWellNames", - std::vector(), - "Simulation Well Names", - "", - "", - "" ); - CAF_PDM_InitScriptableField( &m_fileSplit, - "fileSplit", - RicExportCompletionDataSettingsUi::ExportSplitType(), - "File Split", - "", - "", - "" ); + CAF_PDM_InitScriptableField( &m_caseId, "caseId", -1, "Case ID" ); + CAF_PDM_InitScriptableField( &m_viewId, "viewId", -1, "View ID" ); + CAF_PDM_InitScriptableField( &m_viewName, "viewName", QString( "" ), "View Name" ); + CAF_PDM_InitScriptableField( &m_timeStep, "timeStep", -1, "Time Step Index" ); + CAF_PDM_InitScriptableField( &m_simWellNames, "simulationWellNames", std::vector(), "Simulation Well Names" ); + CAF_PDM_InitScriptableField( &m_fileSplit, "fileSplit", RicExportCompletionDataSettingsUi::ExportSplitType(), "File Split" ); CAF_PDM_InitScriptableField( &m_compdatExport, "compdatExport", RicExportCompletionDataSettingsUi::CompdatExportType(), - "Compdat Export", - "", - "", - "" ); + "Compdat Export" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/CommandFileInterface/RicfExportSnapshots.cpp b/ApplicationLibCode/CommandFileInterface/RicfExportSnapshots.cpp index a5b7248243..137dab6268 100644 --- a/ApplicationLibCode/CommandFileInterface/RicfExportSnapshots.cpp +++ b/ApplicationLibCode/CommandFileInterface/RicfExportSnapshots.cpp @@ -60,12 +60,12 @@ void RicfExportSnapshots::SnapshotsTypeEnum::setUp() //-------------------------------------------------------------------------------------------------- RicfExportSnapshots::RicfExportSnapshots() { - CAF_PDM_InitScriptableField( &m_type, "type", RicfExportSnapshots::SnapshotsTypeEnum(), "Type", "", "", "" ); - CAF_PDM_InitScriptableField( &m_prefix, "prefix", QString(), "Prefix", "", "", "" ); - CAF_PDM_InitScriptableField( &m_caseId, "caseId", -1, "Case Id", "", "", "" ); - CAF_PDM_InitScriptableField( &m_viewId, "viewId", -1, "View Id", "", "", "" ); - CAF_PDM_InitScriptableField( &m_exportFolder, "exportFolder", QString(), "Export Folder", "", "", "" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_plotOutputFormat, "plotOutputFormat", "Output Format", "", "", "" ); + CAF_PDM_InitScriptableField( &m_type, "type", RicfExportSnapshots::SnapshotsTypeEnum(), "Type" ); + CAF_PDM_InitScriptableField( &m_prefix, "prefix", QString(), "Prefix" ); + CAF_PDM_InitScriptableField( &m_caseId, "caseId", -1, "Case Id" ); + CAF_PDM_InitScriptableField( &m_viewId, "viewId", -1, "View Id" ); + CAF_PDM_InitScriptableField( &m_exportFolder, "exportFolder", QString(), "Export Folder" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_plotOutputFormat, "plotOutputFormat", "Output Format" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/CommandFileInterface/RicfExportVisibleCells.cpp b/ApplicationLibCode/CommandFileInterface/RicfExportVisibleCells.cpp index 3d7b8f66e4..701dd7bc0e 100644 --- a/ApplicationLibCode/CommandFileInterface/RicfExportVisibleCells.cpp +++ b/ApplicationLibCode/CommandFileInterface/RicfExportVisibleCells.cpp @@ -63,25 +63,16 @@ void AppEnum::setUp() //-------------------------------------------------------------------------------------------------- RicfExportVisibleCells::RicfExportVisibleCells() { - CAF_PDM_InitScriptableField( &m_caseId, "caseId", -1, "Case ID", "", "", "" ); - CAF_PDM_InitScriptableField( &m_viewId, "viewId", -1, "View ID", "", "", "" ); - CAF_PDM_InitScriptableField( &m_viewName, "viewName", QString(), "View Name", "", "", "" ); + CAF_PDM_InitScriptableField( &m_caseId, "caseId", -1, "Case ID" ); + CAF_PDM_InitScriptableField( &m_viewId, "viewId", -1, "View ID" ); + CAF_PDM_InitScriptableField( &m_viewName, "viewName", QString(), "View Name" ); CAF_PDM_InitScriptableField( &m_exportKeyword, "exportKeyword", caf::AppEnum(), - "Export Keyword", - "", - "", - "" ); - CAF_PDM_InitScriptableField( &m_visibleActiveCellsValue, - "visibleActiveCellsValue", - 1, - "Visible Active Cells Value", - "", - "", - "" ); - CAF_PDM_InitScriptableField( &m_hiddenActiveCellsValue, "hiddenActiveCellsValue", 0, "Hidden Active Cells Value", "", "", "" ); - CAF_PDM_InitScriptableField( &m_inactiveCellsValue, "inactiveCellsValue", 0, "Inactive Cells Value", "", "", "" ); + "Export Keyword" ); + CAF_PDM_InitScriptableField( &m_visibleActiveCellsValue, "visibleActiveCellsValue", 1, "Visible Active Cells Value" ); + CAF_PDM_InitScriptableField( &m_hiddenActiveCellsValue, "hiddenActiveCellsValue", 0, "Hidden Active Cells Value" ); + CAF_PDM_InitScriptableField( &m_inactiveCellsValue, "inactiveCellsValue", 0, "Inactive Cells Value" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/CommandFileInterface/RicfExportWellLogPlotData.cpp b/ApplicationLibCode/CommandFileInterface/RicfExportWellLogPlotData.cpp index f6e0c2884e..1f070064b4 100644 --- a/ApplicationLibCode/CommandFileInterface/RicfExportWellLogPlotData.cpp +++ b/ApplicationLibCode/CommandFileInterface/RicfExportWellLogPlotData.cpp @@ -49,8 +49,8 @@ CAF_PDM_SOURCE_INIT( RicfExportWellLogPlotDataResult, "exportWellLogPlotDataResu //-------------------------------------------------------------------------------------------------- RicfExportWellLogPlotDataResult::RicfExportWellLogPlotDataResult() { - CAF_PDM_InitObject( "export_well_data_result", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &this->exportedFiles, "exportedFiles", "", "", "", "" ); + CAF_PDM_InitObject( "export_well_data_result" ); + CAF_PDM_InitFieldNoDefault( &this->exportedFiles, "exportedFiles", "" ); } CAF_PDM_SOURCE_INIT( RicfExportWellLogPlotData, "exportWellLogPlotData" ); @@ -60,14 +60,14 @@ CAF_PDM_SOURCE_INIT( RicfExportWellLogPlotData, "exportWellLogPlotData" ); //-------------------------------------------------------------------------------------------------- RicfExportWellLogPlotData::RicfExportWellLogPlotData() { - CAF_PDM_InitScriptableFieldNoDefault( &m_format, "exportFormat", "", "", "", "" ); - CAF_PDM_InitScriptableField( &m_viewId, "viewId", -1, "", "", "", "" ); - CAF_PDM_InitScriptableField( &m_folder, "exportFolder", QString(), "", "", "", "" ); - CAF_PDM_InitScriptableField( &m_filePrefix, "filePrefix", QString(), "", "", "", "" ); - CAF_PDM_InitScriptableField( &m_exportTvdRkb, "exportTvdRkb", false, "", "", "", "" ); - CAF_PDM_InitScriptableField( &m_capitalizeFileNames, "capitalizeFileNames", false, "", "", "", "" ); - CAF_PDM_InitScriptableField( &m_resampleInterval, "resampleInterval", 0.0, "", "", "", "" ); - CAF_PDM_InitScriptableField( &m_convertCurveUnits, "convertCurveUnits", false, "", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_format, "exportFormat", "" ); + CAF_PDM_InitScriptableField( &m_viewId, "viewId", -1, "" ); + CAF_PDM_InitScriptableField( &m_folder, "exportFolder", QString(), "" ); + CAF_PDM_InitScriptableField( &m_filePrefix, "filePrefix", QString(), "" ); + CAF_PDM_InitScriptableField( &m_exportTvdRkb, "exportTvdRkb", false, "" ); + CAF_PDM_InitScriptableField( &m_capitalizeFileNames, "capitalizeFileNames", false, "" ); + CAF_PDM_InitScriptableField( &m_resampleInterval, "resampleInterval", 0.0, "" ); + CAF_PDM_InitScriptableField( &m_convertCurveUnits, "convertCurveUnits", false, "" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/CommandFileInterface/RicfExportWellPathCompletions.cpp b/ApplicationLibCode/CommandFileInterface/RicfExportWellPathCompletions.cpp index 9ab16a08f4..35f319d2d0 100644 --- a/ApplicationLibCode/CommandFileInterface/RicfExportWellPathCompletions.cpp +++ b/ApplicationLibCode/CommandFileInterface/RicfExportWellPathCompletions.cpp @@ -43,84 +43,45 @@ CAF_PDM_SOURCE_INIT( RicfExportWellPathCompletions, "exportWellPathCompletions" //-------------------------------------------------------------------------------------------------- RicfExportWellPathCompletions::RicfExportWellPathCompletions() { - CAF_PDM_InitScriptableField( &m_caseId, "caseId", -1, "Case ID", "", "", "" ); - CAF_PDM_InitScriptableField( &m_timeStep, "timeStep", -1, "Time Step Index", "", "", "" ); - CAF_PDM_InitScriptableField( &m_wellPathNames, "wellPathNames", std::vector(), "Well Path Names", "", "", "" ); - - CAF_PDM_InitScriptableField( &m_fileSplit, - "fileSplit", - RicExportCompletionDataSettingsUi::ExportSplitType(), - "File Split", - "", - "", - "" ); + CAF_PDM_InitScriptableField( &m_caseId, "caseId", -1, "Case ID" ); + CAF_PDM_InitScriptableField( &m_timeStep, "timeStep", -1, "Time Step Index" ); + CAF_PDM_InitScriptableField( &m_wellPathNames, "wellPathNames", std::vector(), "Well Path Names" ); + + CAF_PDM_InitScriptableField( &m_fileSplit, "fileSplit", RicExportCompletionDataSettingsUi::ExportSplitType(), "File Split" ); CAF_PDM_InitScriptableField( &m_compdatExport, "compdatExport", RicExportCompletionDataSettingsUi::CompdatExportType(), - "Compdat Export", - "", - "", - "" ); + "Compdat Export" ); CAF_PDM_InitScriptableField( &m_combinationMode, "combinationMode", RicExportCompletionDataSettingsUi::CombinationModeType(), - "Combination Mode", - "", - "", - "" ); + "Combination Mode" ); - CAF_PDM_InitScriptableField( &m_includeMsw, "includeMsw", true, "Export Multi Segment Well Model", "", "", "" ); - CAF_PDM_InitScriptableField( &m_useLateralNTG, "useNtgHorizontally", false, "Use NTG Horizontally", "", "", "" ); - CAF_PDM_InitScriptableField( &m_includePerforations, "includePerforations", true, "Include Perforations", "", "", "" ); - CAF_PDM_InitScriptableField( &m_includeFishbones, "includeFishbones", true, "Include Fishbones", "", "", "" ); - CAF_PDM_InitScriptableField( &m_includeFractures, "includeFractures", true, "Include Fractures", "", "", "" ); + CAF_PDM_InitScriptableField( &m_includeMsw, "includeMsw", true, "Export Multi Segment Well Model" ); + CAF_PDM_InitScriptableField( &m_useLateralNTG, "useNtgHorizontally", false, "Use NTG Horizontally" ); + CAF_PDM_InitScriptableField( &m_includePerforations, "includePerforations", true, "Include Perforations" ); + CAF_PDM_InitScriptableField( &m_includeFishbones, "includeFishbones", true, "Include Fishbones" ); + CAF_PDM_InitScriptableField( &m_includeFractures, "includeFractures", true, "Include Fractures" ); CAF_PDM_InitScriptableField( &m_excludeMainBoreForFishbones, "excludeMainBoreForFishbones", false, - "Exclude Main Bore for Fishbones", - "", - "", - "" ); + "Exclude Main Bore for Fishbones" ); - CAF_PDM_InitScriptableField( &m_performTransScaling, - "performTransScaling", - false, - "Perform Transmissibility Scaling", - "", - "", - "" ); + CAF_PDM_InitScriptableField( &m_performTransScaling, "performTransScaling", false, "Perform Transmissibility Scaling" ); CAF_PDM_InitScriptableField( &m_transScalingTimeStep, "transScalingTimeStep", 0, - "Transmissibility Scaling Pressure Time Step", - "", - "", - "" ); + "Transmissibility Scaling Pressure Time Step" ); CAF_PDM_InitScriptableField( &m_transScalingInitialWBHP, "transScalingWBHPFromSummary", RicExportCompletionDataSettingsUi::TransScalingWBHPSource(), - "Transmissibility Scaling WBHP from summary", - "", - "", - "" ); - CAF_PDM_InitScriptableField( &m_transScalingWBHP, - "transScalingWBHP", - 200.0, - "Transmissibility Scaling Constant WBHP Value", - "", - "", - "" ); - - CAF_PDM_InitScriptableField( &m_exportDataSourceAsComments, - "exportComments", - true, - "Export Data Source as Comments", - "", - "", - "" ); - CAF_PDM_InitScriptableField( &m_exportWelspec, "exportWelspec", true, "Export WELSPEC keyword", "", "", "" ); - CAF_PDM_InitScriptableField( &m_customFileName, "customFileName", QString(), "Custom Filename", "", "", "" ); + "Transmissibility Scaling WBHP from summary" ); + CAF_PDM_InitScriptableField( &m_transScalingWBHP, "transScalingWBHP", 200.0, "Transmissibility Scaling Constant WBHP Value" ); + + CAF_PDM_InitScriptableField( &m_exportDataSourceAsComments, "exportComments", true, "Export Data Source as Comments" ); + CAF_PDM_InitScriptableField( &m_exportWelspec, "exportWelspec", true, "Export WELSPEC keyword" ); + CAF_PDM_InitScriptableField( &m_customFileName, "customFileName", QString(), "Custom Filename" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/CommandFileInterface/RicfExportWellPaths.cpp b/ApplicationLibCode/CommandFileInterface/RicfExportWellPaths.cpp index 34feb950f0..25ba65d6c3 100644 --- a/ApplicationLibCode/CommandFileInterface/RicfExportWellPaths.cpp +++ b/ApplicationLibCode/CommandFileInterface/RicfExportWellPaths.cpp @@ -45,8 +45,8 @@ CAF_PDM_SOURCE_INIT( RicfExportWellPaths, "exportWellPaths" ); //-------------------------------------------------------------------------------------------------- RicfExportWellPaths::RicfExportWellPaths() { - CAF_PDM_InitScriptableField( &m_wellPathNames, "wellPathNames", std::vector(), "Well Path Names", "", "", "" ); - CAF_PDM_InitScriptableField( &m_mdStepSize, "mdStepSize", 5.0, "MD Step Size", "", "", "" ); + CAF_PDM_InitScriptableField( &m_wellPathNames, "wellPathNames", std::vector(), "Well Path Names" ); + CAF_PDM_InitScriptableField( &m_mdStepSize, "mdStepSize", 5.0, "MD Step Size" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/CommandFileInterface/RicfImportFormationNames.cpp b/ApplicationLibCode/CommandFileInterface/RicfImportFormationNames.cpp index 092865cdf2..87f7348faf 100644 --- a/ApplicationLibCode/CommandFileInterface/RicfImportFormationNames.cpp +++ b/ApplicationLibCode/CommandFileInterface/RicfImportFormationNames.cpp @@ -34,8 +34,8 @@ CAF_PDM_SOURCE_INIT( RicfImportFormationNames, "importFormationNames" ); //-------------------------------------------------------------------------------------------------- RicfImportFormationNames::RicfImportFormationNames() { - CAF_PDM_InitScriptableFieldNoDefault( &m_formationFiles, "formationFiles", "", "", "", "" ); - CAF_PDM_InitScriptableField( &m_applyToCaseId, "applyToCaseId", -1, "", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_formationFiles, "formationFiles", "" ); + CAF_PDM_InitScriptableField( &m_applyToCaseId, "applyToCaseId", -1, "" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/CommandFileInterface/RicfImportWellLogFiles.cpp b/ApplicationLibCode/CommandFileInterface/RicfImportWellLogFiles.cpp index 6b92cfeff5..3e1ff49519 100644 --- a/ApplicationLibCode/CommandFileInterface/RicfImportWellLogFiles.cpp +++ b/ApplicationLibCode/CommandFileInterface/RicfImportWellLogFiles.cpp @@ -35,8 +35,8 @@ CAF_PDM_SOURCE_INIT( RicfImportWellLogFilesResult, "importWellLogFilesResult" ); //-------------------------------------------------------------------------------------------------- RicfImportWellLogFilesResult::RicfImportWellLogFilesResult() { - CAF_PDM_InitObject( "well_log_files_result", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &wellPathNames, "wellPathNames", "", "", "", "" ); + CAF_PDM_InitObject( "well_log_files_result" ); + CAF_PDM_InitFieldNoDefault( &wellPathNames, "wellPathNames", "" ); } CAF_PDM_SOURCE_INIT( RicfImportWellLogFiles, "importWellLogFiles" ); @@ -46,8 +46,8 @@ CAF_PDM_SOURCE_INIT( RicfImportWellLogFiles, "importWellLogFiles" ); //-------------------------------------------------------------------------------------------------- RicfImportWellLogFiles::RicfImportWellLogFiles() { - CAF_PDM_InitScriptableFieldNoDefault( &m_wellLogFileFolder, "wellLogFolder", "", "", "", "" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_wellLogFilePaths, "wellLogFiles", "", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_wellLogFileFolder, "wellLogFolder", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_wellLogFilePaths, "wellLogFiles", "" ); } caf::PdmScriptResponse RicfImportWellLogFiles::execute() diff --git a/ApplicationLibCode/CommandFileInterface/RicfLoadCase.cpp b/ApplicationLibCode/CommandFileInterface/RicfLoadCase.cpp index 6657a13dd2..86838f1c9e 100644 --- a/ApplicationLibCode/CommandFileInterface/RicfLoadCase.cpp +++ b/ApplicationLibCode/CommandFileInterface/RicfLoadCase.cpp @@ -37,8 +37,8 @@ CAF_PDM_SOURCE_INIT( RicfLoadCaseResult, "loadCaseResult" ); //-------------------------------------------------------------------------------------------------- RicfLoadCaseResult::RicfLoadCaseResult( int caseId ) { - CAF_PDM_InitObject( "case_result", "", "", "" ); - CAF_PDM_InitField( &this->caseId, "id", caseId, "", "", "", "" ); + CAF_PDM_InitObject( "case_result" ); + CAF_PDM_InitField( &this->caseId, "id", caseId, "" ); } CAF_PDM_SOURCE_INIT( RicfLoadCase, "loadCase" ); @@ -48,8 +48,8 @@ CAF_PDM_SOURCE_INIT( RicfLoadCase, "loadCase" ); //-------------------------------------------------------------------------------------------------- RicfLoadCase::RicfLoadCase() { - CAF_PDM_InitScriptableField( &m_path, "path", QString(), "Path to Case File", "", "", "" ); - CAF_PDM_InitScriptableField( &m_gridOnly, "gridOnly", false, "Load Grid Data Only", "", "", "" ); + CAF_PDM_InitScriptableField( &m_path, "path", QString(), "Path to Case File" ); + CAF_PDM_InitScriptableField( &m_gridOnly, "gridOnly", false, "Load Grid Data Only" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/CommandFileInterface/RicfOpenProject.cpp b/ApplicationLibCode/CommandFileInterface/RicfOpenProject.cpp index 53652df9a5..a8b8446517 100644 --- a/ApplicationLibCode/CommandFileInterface/RicfOpenProject.cpp +++ b/ApplicationLibCode/CommandFileInterface/RicfOpenProject.cpp @@ -35,7 +35,7 @@ CAF_PDM_SOURCE_INIT( RicfOpenProject, "openProject" ); //-------------------------------------------------------------------------------------------------- RicfOpenProject::RicfOpenProject() { - CAF_PDM_InitScriptableField( &m_path, "path", QString(), "Path", "", "", "" ); + CAF_PDM_InitScriptableField( &m_path, "path", QString(), "Path" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/CommandFileInterface/RicfReplaceCase.cpp b/ApplicationLibCode/CommandFileInterface/RicfReplaceCase.cpp index 1cd99cc4af..aa525b7ede 100644 --- a/ApplicationLibCode/CommandFileInterface/RicfReplaceCase.cpp +++ b/ApplicationLibCode/CommandFileInterface/RicfReplaceCase.cpp @@ -38,8 +38,8 @@ CAF_PDM_SOURCE_INIT( RicfSingleCaseReplace, "replaceCase" ); //-------------------------------------------------------------------------------------------------- RicfSingleCaseReplace::RicfSingleCaseReplace() { - CAF_PDM_InitScriptableField( &m_caseId, "caseId", -1, "Case ID", "", "", "" ); - CAF_PDM_InitScriptableField( &m_newGridFile, "newGridFile", QString(), "New Grid File", "", "", "" ); + CAF_PDM_InitScriptableField( &m_caseId, "caseId", -1, "Case ID" ); + CAF_PDM_InitScriptableField( &m_newGridFile, "newGridFile", QString(), "New Grid File" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/CommandFileInterface/RicfReplaceSourceCases.cpp b/ApplicationLibCode/CommandFileInterface/RicfReplaceSourceCases.cpp index 165b4214c1..8bcc09779a 100644 --- a/ApplicationLibCode/CommandFileInterface/RicfReplaceSourceCases.cpp +++ b/ApplicationLibCode/CommandFileInterface/RicfReplaceSourceCases.cpp @@ -33,8 +33,8 @@ CAF_PDM_SOURCE_INIT( RicfReplaceSourceCases, "replaceSourceCases" ); //-------------------------------------------------------------------------------------------------- RicfReplaceSourceCases::RicfReplaceSourceCases() { - CAF_PDM_InitScriptableField( &m_caseGroupId, "caseGroupId", -1, "Case Group ID", "", "", "" ); - CAF_PDM_InitScriptableField( &m_gridListFile, "gridListFile", QString(), "Grid List File", "", "", "" ); + CAF_PDM_InitScriptableField( &m_caseGroupId, "caseGroupId", -1, "Case Group ID" ); + CAF_PDM_InitScriptableField( &m_gridListFile, "gridListFile", QString(), "Grid List File" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/CommandFileInterface/RicfRunOctaveScript.cpp b/ApplicationLibCode/CommandFileInterface/RicfRunOctaveScript.cpp index 8a11e7bde0..09a8c1ac17 100644 --- a/ApplicationLibCode/CommandFileInterface/RicfRunOctaveScript.cpp +++ b/ApplicationLibCode/CommandFileInterface/RicfRunOctaveScript.cpp @@ -37,8 +37,8 @@ CAF_PDM_SOURCE_INIT( RicfRunOctaveScript, "runOctaveScript" ); //-------------------------------------------------------------------------------------------------- RicfRunOctaveScript::RicfRunOctaveScript() { - CAF_PDM_InitScriptableField( &m_path, "path", QString(), "Path", "", "", "" ); - CAF_PDM_InitScriptableField( &m_caseIds, "caseIds", std::vector(), "Case IDs", "", "", "" ); + CAF_PDM_InitScriptableField( &m_path, "path", QString(), "Path" ); + CAF_PDM_InitScriptableField( &m_caseIds, "caseIds", std::vector(), "Case IDs" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/CommandFileInterface/RicfScaleFractureTemplate.cpp b/ApplicationLibCode/CommandFileInterface/RicfScaleFractureTemplate.cpp index b1de06eb27..99f733de55 100644 --- a/ApplicationLibCode/CommandFileInterface/RicfScaleFractureTemplate.cpp +++ b/ApplicationLibCode/CommandFileInterface/RicfScaleFractureTemplate.cpp @@ -34,13 +34,13 @@ CAF_PDM_SOURCE_INIT( RicfScaleFractureTemplate, "scaleFractureTemplate" ); //-------------------------------------------------------------------------------------------------- RicfScaleFractureTemplate::RicfScaleFractureTemplate() { - CAF_PDM_InitScriptableField( &m_id, "id", -1, "Id", "", "", "" ); - CAF_PDM_InitScriptableField( &m_halfLengthScaleFactor, "halfLength", 1.0, "HalfLengthScaleFactor", "", "", "" ); - CAF_PDM_InitScriptableField( &m_heightScaleFactor, "height", 1.0, "HeightScaleFactor", "", "", "" ); - CAF_PDM_InitScriptableField( &m_dFactorScaleFactor, "dFactor", 1.0, "DFactorScaleFactor", "", "", "" ); - CAF_PDM_InitScriptableField( &m_conductivityScaleFactor, "conductivity", 1.0, "ConductivityScaleFactor", "", "", "" ); + CAF_PDM_InitScriptableField( &m_id, "id", -1, "Id" ); + CAF_PDM_InitScriptableField( &m_halfLengthScaleFactor, "halfLength", 1.0, "HalfLengthScaleFactor" ); + CAF_PDM_InitScriptableField( &m_heightScaleFactor, "height", 1.0, "HeightScaleFactor" ); + CAF_PDM_InitScriptableField( &m_dFactorScaleFactor, "dFactor", 1.0, "DFactorScaleFactor" ); + CAF_PDM_InitScriptableField( &m_conductivityScaleFactor, "conductivity", 1.0, "ConductivityScaleFactor" ); - CAF_PDM_InitScriptableField( &m_OBSOLETE_widthScaleFactor, "width", 1.0, "WidthScaleFactor", "", "", "" ); + CAF_PDM_InitScriptableField( &m_OBSOLETE_widthScaleFactor, "width", 1.0, "WidthScaleFactor" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/CommandFileInterface/RicfSetExportFolder.cpp b/ApplicationLibCode/CommandFileInterface/RicfSetExportFolder.cpp index ae6c4bb72e..42eddc3eac 100644 --- a/ApplicationLibCode/CommandFileInterface/RicfSetExportFolder.cpp +++ b/ApplicationLibCode/CommandFileInterface/RicfSetExportFolder.cpp @@ -32,9 +32,9 @@ CAF_PDM_SOURCE_INIT( RicfSetExportFolder, "setExportFolder" ); RicfSetExportFolder::RicfSetExportFolder() { // clang-format off - CAF_PDM_InitScriptableField(&m_type, "type", RicfCommandFileExecutor::ExportTypeEnum(RicfCommandFileExecutor::ExportType::COMPLETIONS), "Type", "", "", ""); - CAF_PDM_InitScriptableField(&m_path, "path", QString(), "Path", "", "", ""); - CAF_PDM_InitScriptableField(&m_createFolder, "createFolder", false, "Create Folder", "", "", ""); + CAF_PDM_InitScriptableField(&m_type, "type", RicfCommandFileExecutor::ExportTypeEnum(RicfCommandFileExecutor::ExportType::COMPLETIONS), "Type"); + CAF_PDM_InitScriptableField(&m_path, "path", QString(), "Path"); + CAF_PDM_InitScriptableField(&m_createFolder, "createFolder", false, "Create Folder"); // clang-format on } diff --git a/ApplicationLibCode/CommandFileInterface/RicfSetFractureContainment.cpp b/ApplicationLibCode/CommandFileInterface/RicfSetFractureContainment.cpp index c54f369280..d49633af4f 100644 --- a/ApplicationLibCode/CommandFileInterface/RicfSetFractureContainment.cpp +++ b/ApplicationLibCode/CommandFileInterface/RicfSetFractureContainment.cpp @@ -34,9 +34,9 @@ CAF_PDM_SOURCE_INIT( RicfSetFractureContainment, "setFractureContainment" ); //-------------------------------------------------------------------------------------------------- RicfSetFractureContainment::RicfSetFractureContainment() { - CAF_PDM_InitScriptableField( &m_id, "id", -1, "Id", "", "", "" ); - CAF_PDM_InitScriptableField( &m_topLayer, "topLayer", -1, "TopLayer", "", "", "" ); - CAF_PDM_InitScriptableField( &m_baseLayer, "baseLayer", -1, "BaseLayer", "", "", "" ); + CAF_PDM_InitScriptableField( &m_id, "id", -1, "Id" ); + CAF_PDM_InitScriptableField( &m_topLayer, "topLayer", -1, "TopLayer" ); + CAF_PDM_InitScriptableField( &m_baseLayer, "baseLayer", -1, "BaseLayer" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/CommandFileInterface/RicfSetMainWindowSize.cpp b/ApplicationLibCode/CommandFileInterface/RicfSetMainWindowSize.cpp index 6b3f894056..c7247f672d 100644 --- a/ApplicationLibCode/CommandFileInterface/RicfSetMainWindowSize.cpp +++ b/ApplicationLibCode/CommandFileInterface/RicfSetMainWindowSize.cpp @@ -30,8 +30,8 @@ CAF_PDM_SOURCE_INIT( RicfSetMainWindowSize, "setMainWindowSize" ); //-------------------------------------------------------------------------------------------------- RicfSetMainWindowSize::RicfSetMainWindowSize() { - CAF_PDM_InitScriptableField( &m_height, "height", -1, "Height", "", "", "" ); - CAF_PDM_InitScriptableField( &m_width, "width", -1, "Width", "", "", "" ); + CAF_PDM_InitScriptableField( &m_height, "height", -1, "Height" ); + CAF_PDM_InitScriptableField( &m_width, "width", -1, "Width" ); } //-------------------------------------------------------------------------------------------------- @@ -39,6 +39,6 @@ RicfSetMainWindowSize::RicfSetMainWindowSize() //-------------------------------------------------------------------------------------------------- caf::PdmScriptResponse RicfSetMainWindowSize::execute() { - RiuMainWindow::instance()->resize( m_width, m_height ); + if ( RiuMainWindow::instance() ) RiuMainWindow::instance()->resize( m_width, m_height ); return caf::PdmScriptResponse(); } diff --git a/ApplicationLibCode/CommandFileInterface/RicfSetPlotWindowSize.cpp b/ApplicationLibCode/CommandFileInterface/RicfSetPlotWindowSize.cpp index 0d8550dcf6..cfa4e22fe9 100644 --- a/ApplicationLibCode/CommandFileInterface/RicfSetPlotWindowSize.cpp +++ b/ApplicationLibCode/CommandFileInterface/RicfSetPlotWindowSize.cpp @@ -30,8 +30,8 @@ CAF_PDM_SOURCE_INIT( RicfSetPlotWindowSize, "setPlotWindowSize" ); //-------------------------------------------------------------------------------------------------- RicfSetPlotWindowSize::RicfSetPlotWindowSize() { - CAF_PDM_InitScriptableField( &m_height, "height", -1, "Height", "", "", "" ); - CAF_PDM_InitScriptableField( &m_width, "width", -1, "Width", "", "", "" ); + CAF_PDM_InitScriptableField( &m_height, "height", -1, "Height" ); + CAF_PDM_InitScriptableField( &m_width, "width", -1, "Width" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/CommandFileInterface/RicfSetStartDir.cpp b/ApplicationLibCode/CommandFileInterface/RicfSetStartDir.cpp index 7a2e9918ab..f432f99a22 100644 --- a/ApplicationLibCode/CommandFileInterface/RicfSetStartDir.cpp +++ b/ApplicationLibCode/CommandFileInterface/RicfSetStartDir.cpp @@ -32,7 +32,7 @@ CAF_PDM_SOURCE_INIT( RicfSetStartDir, "setStartDir" ); //-------------------------------------------------------------------------------------------------- RicfSetStartDir::RicfSetStartDir() { - CAF_PDM_InitScriptableField( &m_path, "path", QString(), "Path", "", "", "" ); + CAF_PDM_InitScriptableField( &m_path, "path", QString(), "Path" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/CommandFileInterface/RicfSetTimeStep.cpp b/ApplicationLibCode/CommandFileInterface/RicfSetTimeStep.cpp index 5ed9fae65f..b1214012a5 100644 --- a/ApplicationLibCode/CommandFileInterface/RicfSetTimeStep.cpp +++ b/ApplicationLibCode/CommandFileInterface/RicfSetTimeStep.cpp @@ -35,9 +35,9 @@ CAF_PDM_SOURCE_INIT( RicfSetTimeStep, "setTimeStep" ); //-------------------------------------------------------------------------------------------------- RicfSetTimeStep::RicfSetTimeStep() { - CAF_PDM_InitScriptableField( &m_caseId, "caseId", -1, "Case ID", "", "", "" ); - CAF_PDM_InitScriptableField( &m_viewId, "viewId", -1, "View ID", "", "", "" ); - CAF_PDM_InitScriptableField( &m_timeStepIndex, "timeStep", -1, "Time Step Index", "", "", "" ); + CAF_PDM_InitScriptableField( &m_caseId, "caseId", -1, "Case ID" ); + CAF_PDM_InitScriptableField( &m_viewId, "viewId", -1, "View ID" ); + CAF_PDM_InitScriptableField( &m_timeStepIndex, "timeStep", -1, "Time Step Index" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/AnalysisPlotCommands/RicNewAnalysisPlotFeature.h b/ApplicationLibCode/Commands/AnalysisPlotCommands/RicNewAnalysisPlotFeature.h index 2f3d532905..cce5271826 100644 --- a/ApplicationLibCode/Commands/AnalysisPlotCommands/RicNewAnalysisPlotFeature.h +++ b/ApplicationLibCode/Commands/AnalysisPlotCommands/RicNewAnalysisPlotFeature.h @@ -28,7 +28,6 @@ class RicNewAnalysisPlotFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/AnalysisPlotCommands/RicNewPlotDataFilterFeature.h b/ApplicationLibCode/Commands/AnalysisPlotCommands/RicNewPlotDataFilterFeature.h index c883f00a88..ba17f7d5d4 100644 --- a/ApplicationLibCode/Commands/AnalysisPlotCommands/RicNewPlotDataFilterFeature.h +++ b/ApplicationLibCode/Commands/AnalysisPlotCommands/RicNewPlotDataFilterFeature.h @@ -28,7 +28,6 @@ class RicNewPlotDataFilterFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/AnnotationCommands/RicCreateReachCircleAnnotationFeature.h b/ApplicationLibCode/Commands/AnnotationCommands/RicCreateReachCircleAnnotationFeature.h index 78f6765eee..7b822e3b6e 100644 --- a/ApplicationLibCode/Commands/AnnotationCommands/RicCreateReachCircleAnnotationFeature.h +++ b/ApplicationLibCode/Commands/AnnotationCommands/RicCreateReachCircleAnnotationFeature.h @@ -32,7 +32,6 @@ class RicCreateReachCircleAnnotationFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/AnnotationCommands/RicCreateTextAnnotationFeature.h b/ApplicationLibCode/Commands/AnnotationCommands/RicCreateTextAnnotationFeature.h index cc00423cc1..e9910a5c55 100644 --- a/ApplicationLibCode/Commands/AnnotationCommands/RicCreateTextAnnotationFeature.h +++ b/ApplicationLibCode/Commands/AnnotationCommands/RicCreateTextAnnotationFeature.h @@ -34,7 +34,6 @@ class RicCreateTextAnnotationFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/AnnotationCommands/RicCreateTextAnnotationIn3dViewFeature.h b/ApplicationLibCode/Commands/AnnotationCommands/RicCreateTextAnnotationIn3dViewFeature.h index 114c383ecb..1deff83c68 100644 --- a/ApplicationLibCode/Commands/AnnotationCommands/RicCreateTextAnnotationIn3dViewFeature.h +++ b/ApplicationLibCode/Commands/AnnotationCommands/RicCreateTextAnnotationIn3dViewFeature.h @@ -28,7 +28,6 @@ class RicCreateTextAnnotationIn3dViewFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/AnnotationCommands/RicCreateUserDefinedPolylinesAnnotationFeature.h b/ApplicationLibCode/Commands/AnnotationCommands/RicCreateUserDefinedPolylinesAnnotationFeature.h index 1691d566b8..f1563dc2bb 100644 --- a/ApplicationLibCode/Commands/AnnotationCommands/RicCreateUserDefinedPolylinesAnnotationFeature.h +++ b/ApplicationLibCode/Commands/AnnotationCommands/RicCreateUserDefinedPolylinesAnnotationFeature.h @@ -32,7 +32,6 @@ class RicCreateUserDefinedPolylinesAnnotationFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/AnnotationCommands/RicImportPolylinesAnnotationFeature.cpp b/ApplicationLibCode/Commands/AnnotationCommands/RicImportPolylinesAnnotationFeature.cpp index 55aaf7b928..cd783ca58c 100644 --- a/ApplicationLibCode/Commands/AnnotationCommands/RicImportPolylinesAnnotationFeature.cpp +++ b/ApplicationLibCode/Commands/AnnotationCommands/RicImportPolylinesAnnotationFeature.cpp @@ -82,7 +82,7 @@ void RicImportPolylinesAnnotationFeature::onActionTriggered( bool isChecked ) RimPolylinesFromFileAnnotation* lastCreatedOrUpdated = annotColl->importOrUpdatePolylinesFromFile( fileNames ); - proj->updateConnectedEditors(); + proj->activeOilField()->updateConnectedEditors(); if ( lastCreatedOrUpdated ) { diff --git a/ApplicationLibCode/Commands/AnnotationCommands/RicImportPolylinesAnnotationFeature.h b/ApplicationLibCode/Commands/AnnotationCommands/RicImportPolylinesAnnotationFeature.h index 44ccc39469..945cc864f9 100644 --- a/ApplicationLibCode/Commands/AnnotationCommands/RicImportPolylinesAnnotationFeature.h +++ b/ApplicationLibCode/Commands/AnnotationCommands/RicImportPolylinesAnnotationFeature.h @@ -28,7 +28,6 @@ class RicImportPolylinesAnnotationFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/ApplicationCommands/CMakeLists_files.cmake b/ApplicationLibCode/Commands/ApplicationCommands/CMakeLists_files.cmake index 9242df0179..e2d3a74038 100644 --- a/ApplicationLibCode/Commands/ApplicationCommands/CMakeLists_files.cmake +++ b/ApplicationLibCode/Commands/ApplicationCommands/CMakeLists_files.cmake @@ -19,6 +19,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RicDefaultDockConfigGeoMechFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicExportObjectAndFieldKeywordsFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicSaveProjectNoGlobalPathsFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicShowClassNamesFeature.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -42,6 +43,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RicDefaultDockConfigGeoMechFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicExportObjectAndFieldKeywordsFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicSaveProjectNoGlobalPathsFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicShowClassNamesFeature.cpp ) list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) diff --git a/ApplicationLibCode/Commands/ApplicationCommands/RicCloseProjectFeature.h b/ApplicationLibCode/Commands/ApplicationCommands/RicCloseProjectFeature.h index 4de7b64ad4..8b9cbf937a 100644 --- a/ApplicationLibCode/Commands/ApplicationCommands/RicCloseProjectFeature.h +++ b/ApplicationLibCode/Commands/ApplicationCommands/RicCloseProjectFeature.h @@ -28,7 +28,6 @@ class RicCloseProjectFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/ApplicationCommands/RicEditPreferencesFeature.h b/ApplicationLibCode/Commands/ApplicationCommands/RicEditPreferencesFeature.h index cbb9df9288..5beb6857e2 100644 --- a/ApplicationLibCode/Commands/ApplicationCommands/RicEditPreferencesFeature.h +++ b/ApplicationLibCode/Commands/ApplicationCommands/RicEditPreferencesFeature.h @@ -31,7 +31,6 @@ class RicEditPreferencesFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/ApplicationCommands/RicExitApplicationFeature.cpp b/ApplicationLibCode/Commands/ApplicationCommands/RicExitApplicationFeature.cpp index f9a3ab0796..88ae58e11c 100644 --- a/ApplicationLibCode/Commands/ApplicationCommands/RicExitApplicationFeature.cpp +++ b/ApplicationLibCode/Commands/ApplicationCommands/RicExitApplicationFeature.cpp @@ -60,8 +60,16 @@ void RicExitApplicationFeature::onActionTriggered( bool isChecked ) { topLevelWidget->hide(); } - // Close just the main window, it'll take care of closing the plot window - app->mainWindow()->close(); + + if ( app->mainWindow() ) + { + app->mainWindow()->close(); + } + + if ( app->mainPlotWindow() ) + { + app->mainPlotWindow()->close(); + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/ApplicationCommands/RicExitApplicationFeature.h b/ApplicationLibCode/Commands/ApplicationCommands/RicExitApplicationFeature.h index f35d305d2c..e436c474e7 100644 --- a/ApplicationLibCode/Commands/ApplicationCommands/RicExitApplicationFeature.h +++ b/ApplicationLibCode/Commands/ApplicationCommands/RicExitApplicationFeature.h @@ -28,7 +28,6 @@ class RicExitApplicationFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/ApplicationCommands/RicHelpFeatures.cpp b/ApplicationLibCode/Commands/ApplicationCommands/RicHelpFeatures.cpp index 0060f471be..62f84045f4 100644 --- a/ApplicationLibCode/Commands/ApplicationCommands/RicHelpFeatures.cpp +++ b/ApplicationLibCode/Commands/ApplicationCommands/RicHelpFeatures.cpp @@ -41,6 +41,8 @@ CAF_CMD_SOURCE_INIT( RicHelpCommandLineFeature, "RicHelpCommandLineFeature" ); CAF_CMD_SOURCE_INIT( RicHelpSummaryCommandLineFeature, "RicHelpSummaryCommandLineFeature" ); CAF_CMD_SOURCE_INIT( RicHelpOpenUsersGuideFeature, "RicHelpOpenUsersGuideFeature" ); CAF_CMD_SOURCE_INIT( RicSearchHelpFeature, "RicSearchHelpFeature" ); +CAF_CMD_SOURCE_INIT( RicSearchIssuesHelpFeature, "RicSearchIssuesHelpFeature" ); +CAF_CMD_SOURCE_INIT( RicCreateNewIssueHelpFeature, "RicCreateNewIssueHelpFeature" ); //-------------------------------------------------------------------------------------------------- /// @@ -308,3 +310,65 @@ void RicSearchHelpFeature::setupActionLook( QAction* actionToSetup ) applyShortcutWithHintToAction( actionToSetup, QKeySequence::HelpContents ); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicSearchIssuesHelpFeature::isCommandEnabled() +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSearchIssuesHelpFeature::onActionTriggered( bool isChecked ) +{ + QString usersGuideUrl = "https://github.com/OPM/ResInsight/issues"; + + if ( !QDesktopServices::openUrl( usersGuideUrl ) ) + { + QErrorMessage* errorHandler = QErrorMessage::qtHandler(); + errorHandler->showMessage( "Failed open browser with the following url\n\n" + usersGuideUrl ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSearchIssuesHelpFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setText( "Search Issues" ); + actionToSetup->setIcon( QIcon( ":/HelpCircle.svg" ) ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicCreateNewIssueHelpFeature::isCommandEnabled() +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicCreateNewIssueHelpFeature::onActionTriggered( bool isChecked ) +{ + QString usersGuideUrl = "https://github.com/OPM/ResInsight/issues/new"; + + if ( !QDesktopServices::openUrl( usersGuideUrl ) ) + { + QErrorMessage* errorHandler = QErrorMessage::qtHandler(); + errorHandler->showMessage( "Failed open browser with the following url\n\n" + usersGuideUrl ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicCreateNewIssueHelpFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setText( "Create New Issue" ); + actionToSetup->setIcon( QIcon( ":/HelpCircle.svg" ) ); +} diff --git a/ApplicationLibCode/Commands/ApplicationCommands/RicHelpFeatures.h b/ApplicationLibCode/Commands/ApplicationCommands/RicHelpFeatures.h index 3b7cfa5501..b15c338f6b 100644 --- a/ApplicationLibCode/Commands/ApplicationCommands/RicHelpFeatures.h +++ b/ApplicationLibCode/Commands/ApplicationCommands/RicHelpFeatures.h @@ -28,7 +28,6 @@ class RicHelpAboutFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; @@ -42,7 +41,6 @@ class RicHelpCommandLineFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; @@ -56,7 +54,6 @@ class RicHelpSummaryCommandLineFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; @@ -70,7 +67,6 @@ class RicHelpOpenUsersGuideFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; @@ -84,7 +80,32 @@ class RicSearchHelpFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides + bool isCommandEnabled() override; + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; +}; + +//================================================================================================== +/// +//================================================================================================== +class RicSearchIssuesHelpFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + bool isCommandEnabled() override; + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; +}; + +//================================================================================================== +/// +//================================================================================================== +class RicCreateNewIssueHelpFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/ApplicationCommands/RicLaunchRegressionTestsFeature.cpp b/ApplicationLibCode/Commands/ApplicationCommands/RicLaunchRegressionTestsFeature.cpp index 4a16a4407d..812bf6e0d8 100644 --- a/ApplicationLibCode/Commands/ApplicationCommands/RicLaunchRegressionTestsFeature.cpp +++ b/ApplicationLibCode/Commands/ApplicationCommands/RicLaunchRegressionTestsFeature.cpp @@ -20,6 +20,8 @@ #include "RiaRegressionTestRunner.h" +#include "cafPdmUiPropertyViewDialog.h" + #include #include @@ -46,5 +48,51 @@ void RicLaunchRegressionTestsFeature::onActionTriggered( bool isChecked ) //-------------------------------------------------------------------------------------------------- void RicLaunchRegressionTestsFeature::setupActionLook( QAction* actionToSetup ) { - actionToSetup->setText( "Launch Regression Tests" ); + actionToSetup->setText( "Regression Tests" ); +} + +CAF_CMD_SOURCE_INIT( RicLaunchRegressionTestDialogFeature, "RicLaunchRegressionTestDialogFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicLaunchRegressionTestDialogFeature::showRegressionTestDialog() +{ + RiaRegressionTest regTestConfig; + regTestConfig.readSettingsFromApplicationStore(); + + caf::PdmUiPropertyViewDialog regressionTestDialog( nullptr, ®TestConfig, "Regression Test", "" ); + regressionTestDialog.resize( QSize( 600, 350 ) ); + + if ( regressionTestDialog.exec() == QDialog::Accepted ) + { + // Write preferences using QSettings and apply them to the application + regTestConfig.writeSettingsToApplicationStore(); + + RiaRegressionTestRunner::instance()->executeRegressionTests(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicLaunchRegressionTestDialogFeature::isCommandEnabled() +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicLaunchRegressionTestDialogFeature::onActionTriggered( bool isChecked ) +{ + RicLaunchRegressionTestDialogFeature::showRegressionTestDialog(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicLaunchRegressionTestDialogFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setText( "Reg Test Dialog" ); } diff --git a/ApplicationLibCode/Commands/ApplicationCommands/RicLaunchRegressionTestsFeature.h b/ApplicationLibCode/Commands/ApplicationCommands/RicLaunchRegressionTestsFeature.h index 1662b590f8..d91b6675ee 100644 --- a/ApplicationLibCode/Commands/ApplicationCommands/RicLaunchRegressionTestsFeature.h +++ b/ApplicationLibCode/Commands/ApplicationCommands/RicLaunchRegressionTestsFeature.h @@ -32,3 +32,18 @@ class RicLaunchRegressionTestsFeature : public caf::CmdFeature void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; }; + +//================================================================================================== +/// +//================================================================================================== +class RicLaunchRegressionTestDialogFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + + static void showRegressionTestDialog(); + +private: + bool isCommandEnabled() override; + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; +}; diff --git a/ApplicationLibCode/Commands/ApplicationCommands/RicLaunchUnitTestsFeature.h b/ApplicationLibCode/Commands/ApplicationCommands/RicLaunchUnitTestsFeature.h index 4fd7277cde..33f6de842a 100644 --- a/ApplicationLibCode/Commands/ApplicationCommands/RicLaunchUnitTestsFeature.h +++ b/ApplicationLibCode/Commands/ApplicationCommands/RicLaunchUnitTestsFeature.h @@ -29,7 +29,6 @@ class RicLaunchUnitTestsFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/ApplicationCommands/RicOpenLastUsedFileFeature.h b/ApplicationLibCode/Commands/ApplicationCommands/RicOpenLastUsedFileFeature.h index 4a7ce64c7f..e092a0f4e4 100644 --- a/ApplicationLibCode/Commands/ApplicationCommands/RicOpenLastUsedFileFeature.h +++ b/ApplicationLibCode/Commands/ApplicationCommands/RicOpenLastUsedFileFeature.h @@ -28,7 +28,6 @@ class RicOpenLastUsedFileFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/ApplicationCommands/RicOpenProjectFeature.h b/ApplicationLibCode/Commands/ApplicationCommands/RicOpenProjectFeature.h index 2025485bc7..5832cd9e9e 100644 --- a/ApplicationLibCode/Commands/ApplicationCommands/RicOpenProjectFeature.h +++ b/ApplicationLibCode/Commands/ApplicationCommands/RicOpenProjectFeature.h @@ -28,7 +28,6 @@ class RicOpenProjectFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/ApplicationCommands/RicSaveProjectAsFeature.cpp b/ApplicationLibCode/Commands/ApplicationCommands/RicSaveProjectAsFeature.cpp index edde3def97..15ba3385d6 100644 --- a/ApplicationLibCode/Commands/ApplicationCommands/RicSaveProjectAsFeature.cpp +++ b/ApplicationLibCode/Commands/ApplicationCommands/RicSaveProjectAsFeature.cpp @@ -34,7 +34,7 @@ RICF_SOURCE_INIT( RicSaveProjectAsFeature, "RicSaveProjectAsFeature", "saveProje //-------------------------------------------------------------------------------------------------- RicSaveProjectAsFeature::RicSaveProjectAsFeature() { - CAF_PDM_InitScriptableFieldNoDefault( &m_filePath, "filePath", "", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_filePath, "filePath", "" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/ApplicationCommands/RicSaveProjectAsFeature.h b/ApplicationLibCode/Commands/ApplicationCommands/RicSaveProjectAsFeature.h index 974582a7c9..149c7d9143 100644 --- a/ApplicationLibCode/Commands/ApplicationCommands/RicSaveProjectAsFeature.h +++ b/ApplicationLibCode/Commands/ApplicationCommands/RicSaveProjectAsFeature.h @@ -35,7 +35,6 @@ class RicSaveProjectAsFeature : public caf::CmdFeature, public RicfCommandObject caf::PdmScriptResponse execute() override; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/ApplicationCommands/RicSaveProjectFeature.cpp b/ApplicationLibCode/Commands/ApplicationCommands/RicSaveProjectFeature.cpp index b82395c154..174014233a 100644 --- a/ApplicationLibCode/Commands/ApplicationCommands/RicSaveProjectFeature.cpp +++ b/ApplicationLibCode/Commands/ApplicationCommands/RicSaveProjectFeature.cpp @@ -31,7 +31,7 @@ RICF_SOURCE_INIT( RicSaveProjectFeature, "RicSaveProjectFeature", "saveProject" //-------------------------------------------------------------------------------------------------- RicSaveProjectFeature::RicSaveProjectFeature() { - CAF_PDM_InitFieldNoDefault( &m_filePath, "filePath", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_filePath, "filePath", "" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/ApplicationCommands/RicSaveProjectFeature.h b/ApplicationLibCode/Commands/ApplicationCommands/RicSaveProjectFeature.h index 94ef52564b..30fe1a49b6 100644 --- a/ApplicationLibCode/Commands/ApplicationCommands/RicSaveProjectFeature.h +++ b/ApplicationLibCode/Commands/ApplicationCommands/RicSaveProjectFeature.h @@ -35,7 +35,6 @@ class RicSaveProjectFeature : public caf::CmdFeature, public RicfCommandObject caf::PdmScriptResponse execute() override; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/ApplicationCommands/RicShowClassNamesFeature.cpp b/ApplicationLibCode/Commands/ApplicationCommands/RicShowClassNamesFeature.cpp new file mode 100644 index 0000000000..83e47b19d2 --- /dev/null +++ b/ApplicationLibCode/Commands/ApplicationCommands/RicShowClassNamesFeature.cpp @@ -0,0 +1,65 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicShowClassNamesFeature.h" + +#include "RiaApplication.h" +#include "RiaGuiApplication.h" +#include "RiaPreferences.h" +#include "RiaPreferencesSystem.h" + +#include + +CAF_CMD_SOURCE_INIT( RicShowClassNamesFeature, "RicShowClassNamesFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicShowClassNamesFeature::isCommandEnabled() +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicShowClassNamesFeature::onActionTriggered( bool isChecked ) +{ + RiaPreferences::current()->systemPreferences()->setAppendClassNameToUiText( isChecked ); + + RiaGuiApplication::instance()->applyPreferences(); + RiaGuiApplication::instance()->applyGuiPreferences(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicShowClassNamesFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setText( "Class Names" ); + actionToSetup->setCheckable( true ); + actionToSetup->setChecked( isCommandChecked() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicShowClassNamesFeature::isCommandChecked() +{ + return RiaPreferences::current()->systemPreferences()->appendClassNameToUiText(); +} diff --git a/ApplicationLibCode/Commands/ApplicationCommands/RicShowClassNamesFeature.h b/ApplicationLibCode/Commands/ApplicationCommands/RicShowClassNamesFeature.h new file mode 100644 index 0000000000..6584dad0a6 --- /dev/null +++ b/ApplicationLibCode/Commands/ApplicationCommands/RicShowClassNamesFeature.h @@ -0,0 +1,35 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +//================================================================================================== +/// +//================================================================================================== +class RicShowClassNamesFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + bool isCommandEnabled() override; + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; + bool isCommandChecked() override; +}; diff --git a/ApplicationLibCode/Commands/ApplicationCommands/RicShowMainWindowFeature.cpp b/ApplicationLibCode/Commands/ApplicationCommands/RicShowMainWindowFeature.cpp index e152f37ebd..5defd8c9ac 100644 --- a/ApplicationLibCode/Commands/ApplicationCommands/RicShowMainWindowFeature.cpp +++ b/ApplicationLibCode/Commands/ApplicationCommands/RicShowMainWindowFeature.cpp @@ -18,6 +18,8 @@ #include "RicShowMainWindowFeature.h" +#include "RiaGuiApplication.h" + #include "RiuMainWindow.h" #include @@ -31,19 +33,27 @@ void RicShowMainWindowFeature::showMainWindow() { RiuMainWindow* mainWnd = RiuMainWindow::instance(); - if ( mainWnd->isMinimized() ) + if ( mainWnd ) { - mainWnd->showNormal(); - mainWnd->update(); + if ( mainWnd->isMinimized() ) + { + mainWnd->showNormal(); + mainWnd->update(); + } + else + { + mainWnd->show(); + } + + mainWnd->raise(); + + mainWnd->restoreDockWidgetVisibilities(); } else { - mainWnd->show(); + RiaGuiApplication* app = RiaGuiApplication::instance(); + app->getOrCreateAndShowMainWindow(); } - - mainWnd->raise(); - - mainWnd->restoreDockWidgetVisibilities(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/ApplicationCommands/RicShowMainWindowFeature.h b/ApplicationLibCode/Commands/ApplicationCommands/RicShowMainWindowFeature.h index 3f22ff53e3..3b733b3f9c 100644 --- a/ApplicationLibCode/Commands/ApplicationCommands/RicShowMainWindowFeature.h +++ b/ApplicationLibCode/Commands/ApplicationCommands/RicShowMainWindowFeature.h @@ -31,7 +31,6 @@ class RicShowMainWindowFeature : public caf::CmdFeature static void showMainWindow(); protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/ApplicationCommands/RicShowMemoryCleanupDialogFeature.h b/ApplicationLibCode/Commands/ApplicationCommands/RicShowMemoryCleanupDialogFeature.h index 682d272d0a..776e877d26 100644 --- a/ApplicationLibCode/Commands/ApplicationCommands/RicShowMemoryCleanupDialogFeature.h +++ b/ApplicationLibCode/Commands/ApplicationCommands/RicShowMemoryCleanupDialogFeature.h @@ -28,7 +28,6 @@ class RicShowMemoryCleanupDialogFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/ApplicationCommands/RicShowPlotDataFeature.cpp b/ApplicationLibCode/Commands/ApplicationCommands/RicShowPlotDataFeature.cpp index b026ff5352..7d3dc74ed2 100644 --- a/ApplicationLibCode/Commands/ApplicationCommands/RicShowPlotDataFeature.cpp +++ b/ApplicationLibCode/Commands/ApplicationCommands/RicShowPlotDataFeature.cpp @@ -21,6 +21,7 @@ #include "RiaFeatureCommandContext.h" #include "RiaGuiApplication.h" #include "RiaPreferencesSummary.h" +#include "RiaQDateTimeTools.h" #include "RimGridCrossPlot.h" #include "RimGridCrossPlotCurve.h" @@ -64,8 +65,8 @@ class RiuTabbedSummaryPlotTextProvider : public RiuTabbedTextProvider { auto allTabs = tabs(); CVF_ASSERT( tabIndex < (int)allTabs.size() ); - RiaQDateTimeTools::DateTimePeriod timePeriod = allTabs[tabIndex]; - if ( timePeriod == RiaQDateTimeTools::DateTimePeriod::NONE ) + RiaDefines::DateTimePeriod timePeriod = allTabs[tabIndex]; + if ( timePeriod == RiaDefines::DateTimePeriod::NONE ) { return "No Resampling"; } @@ -79,7 +80,7 @@ class RiuTabbedSummaryPlotTextProvider : public RiuTabbedTextProvider { CVF_ASSERT( m_summaryPlot.notNull() && "Need to check that provider is valid" ); - RiaQDateTimeTools::DateTimePeriod timePeriod = indexToPeriod( tabIndex ); + RiaDefines::DateTimePeriod timePeriod = indexToPeriod( tabIndex ); if ( m_summaryPlot->containsResamplableCurves() ) { @@ -89,27 +90,25 @@ class RiuTabbedSummaryPlotTextProvider : public RiuTabbedTextProvider } else { - return m_summaryPlot->asciiDataForSummaryPlotExport( RiaQDateTimeTools::DateTimePeriod::NONE, true ); + return m_summaryPlot->asciiDataForSummaryPlotExport( RiaDefines::DateTimePeriod::NONE, true ); } } int tabCount() const override { return (int)tabs().size(); } private: - static RiaQDateTimeTools::DateTimePeriod indexToPeriod( int tabIndex ) + static RiaDefines::DateTimePeriod indexToPeriod( int tabIndex ) { auto allTabs = tabs(); CVF_ASSERT( tabIndex < (int)allTabs.size() ); - RiaQDateTimeTools::DateTimePeriod timePeriod = allTabs[tabIndex]; + RiaDefines::DateTimePeriod timePeriod = allTabs[tabIndex]; return timePeriod; } - static std::vector tabs() + static std::vector tabs() { - std::vector dateTimePeriods = RiaQDateTimeTools::dateTimePeriods(); - dateTimePeriods.erase( std::remove( dateTimePeriods.begin(), - dateTimePeriods.end(), - RiaQDateTimeTools::DateTimePeriod::DECADE ), + std::vector dateTimePeriods = RiaQDateTimeTools::dateTimePeriods(); + dateTimePeriods.erase( std::remove( dateTimePeriods.begin(), dateTimePeriods.end(), RiaDefines::DateTimePeriod::DECADE ), dateTimePeriods.end() ); return dateTimePeriods; } diff --git a/ApplicationLibCode/Commands/ApplicationCommands/RicShowPlotDataFeature.h b/ApplicationLibCode/Commands/ApplicationCommands/RicShowPlotDataFeature.h index 7e037387e9..3e3c4a36f8 100644 --- a/ApplicationLibCode/Commands/ApplicationCommands/RicShowPlotDataFeature.h +++ b/ApplicationLibCode/Commands/ApplicationCommands/RicShowPlotDataFeature.h @@ -18,8 +18,6 @@ #pragma once -#include "RiaQDateTimeTools.h" - #include "cafCmdFeature.h" #include @@ -34,7 +32,6 @@ class RicShowPlotDataFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/ApplicationCommands/RicShowPlotWindowFeature.h b/ApplicationLibCode/Commands/ApplicationCommands/RicShowPlotWindowFeature.h index ebb1dba462..bea243301a 100644 --- a/ApplicationLibCode/Commands/ApplicationCommands/RicShowPlotWindowFeature.h +++ b/ApplicationLibCode/Commands/ApplicationCommands/RicShowPlotWindowFeature.h @@ -28,7 +28,6 @@ class RicShowPlotWindowFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/ApplicationCommands/RicTileWindowsFeature.h b/ApplicationLibCode/Commands/ApplicationCommands/RicTileWindowsFeature.h index 7d335e9470..7218340699 100644 --- a/ApplicationLibCode/Commands/ApplicationCommands/RicTileWindowsFeature.h +++ b/ApplicationLibCode/Commands/ApplicationCommands/RicTileWindowsFeature.h @@ -29,7 +29,6 @@ class RicTileWindowsFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; @@ -44,7 +43,6 @@ class RicTilePlotWindowsFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/CMakeLists.txt b/ApplicationLibCode/Commands/CMakeLists.txt index 104491fae3..238341ac98 100644 --- a/ApplicationLibCode/Commands/CMakeLists.txt +++ b/ApplicationLibCode/Commands/CMakeLists.txt @@ -41,6 +41,7 @@ set(COMMAND_REFERENCED_CMAKE_FILES WellPathCommands/CMakeLists_files.cmake PlotTemplateCommands/CMakeLists_files.cmake FractureCommands/CMakeLists_files.cmake + PlotBuilderCommands/CMakeLists_files.cmake ) # Include source file lists from *.cmake files @@ -66,6 +67,37 @@ target_include_directories( ${CMAKE_SOURCE_DIR}/ThirdParty/custom-opm-common/opm-common ) +if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + target_compile_options( + Commands + PRIVATE -Wall + -Wno-unused-parameter + -Wno-reorder + -Wno-parentheses + -Wno-switch + -Wno-delete-abstract-non-virtual-dtor + -Wno-undefined-var-template + -Wno-invalid-source-encoding + -Wno-enum-compare + -Wno-call-to-pure-virtual-from-ctor-dtor + -Wno-unused-variable + -Wno-unused-private-field + -Wno-unused-lambda-capture + -Wno-delete-non-abstract-non-virtual-dtor + -Wno-braced-scalar-init + -Wno-tautological-constant-out-of-range-compare + -Wno-undefined-var-template + ) +endif() + +if(RESINSIGHT_TREAT_WARNINGS_AS_ERRORS) + if(MSVC) + target_compile_options(Commands PRIVATE /WX) + elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + target_compile_options(Commands PRIVATE -Werror) + endif() +endif() + if(MSVC) # The following warnings are supposed to be used in ResInsight, but # temporarily disabled to avoid too much noise warning C4245: 'return': @@ -76,13 +108,7 @@ if(MSVC) # set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/W3 /wd4190 # /wd4100 /wd4127") - set(BUILD_FLAGS_FOR_MSVC "/wd4190 /wd4100 /wd4127 /wd4245 /wd4005") - - if(Qt5Core_VERSION_STRING GREATER_EQUAL 5.10) - # Disable warning for deprecated functions in newer versions of Qt - # https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4996?view=msvc-160 - set(BUILD_FLAGS_FOR_MSVC "${BUILD_FLAGS_FOR_MSVC} /wd4996") - endif() + set(BUILD_FLAGS_FOR_MSVC "/wd4190 /wd4100 /wd4127 /wd4245 /wd4005 /wd4573") if(CMAKE_CXX_COMPILER_VERSION LESS_EQUAL 19.14) # The following warning is generated over 800 times from a qwt header only diff --git a/ApplicationLibCode/Commands/CMakeLists_files.cmake b/ApplicationLibCode/Commands/CMakeLists_files.cmake index a5a02c5e38..87bd2880c6 100644 --- a/ApplicationLibCode/Commands/CMakeLists_files.cmake +++ b/ApplicationLibCode/Commands/CMakeLists_files.cmake @@ -29,7 +29,6 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/Ric3dViewPickEventHandler.h ${CMAKE_CURRENT_LIST_DIR}/RicContourMapPickEventHandler.h ${CMAKE_CURRENT_LIST_DIR}/RicVec3dPickEventHandler.h - # General delete of any object in a child array field ${CMAKE_CURRENT_LIST_DIR}/RicDeleteItemExec.h ${CMAKE_CURRENT_LIST_DIR}/RicDeleteItemExecData.h ${CMAKE_CURRENT_LIST_DIR}/RicDeleteItemFeature.h @@ -61,7 +60,6 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RicDeleteTemporaryLgrsFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicExportContourMapToTextFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicExportContourMapToTextUi.h - ${CMAKE_CURRENT_LIST_DIR}/RicNewMultiPlotFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicExportStimPlanModelToFileFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicStackSelectedCurvesFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicUnstackSelectedCurvesFeature.h @@ -79,6 +77,14 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RicCreateEnsembleWellLogUi.h ${CMAKE_CURRENT_LIST_DIR}/RicCreateSurfaceIntersectionBandFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicCreateSurfaceIntersectionCurveFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicShowGridCalculatorFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicUserDefinedCalculatorDialog.h + ${CMAKE_CURRENT_LIST_DIR}/RicGridCalculatorDialog.h + ${CMAKE_CURRENT_LIST_DIR}/RicGridCalculatorUi.h + ${CMAKE_CURRENT_LIST_DIR}/RicCalculatorWidgetCreator.h + ${CMAKE_CURRENT_LIST_DIR}/RicUserDefinedCalculatorUi.h + ${CMAKE_CURRENT_LIST_DIR}/RicShowDataSourcesForRealization.h + ${CMAKE_CURRENT_LIST_DIR}/RicDeleteUncheckedSubItemsFeature.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -111,7 +117,6 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/Ric3dViewPickEventHandler.cpp ${CMAKE_CURRENT_LIST_DIR}/RicContourMapPickEventHandler.cpp ${CMAKE_CURRENT_LIST_DIR}/RicVec3dPickEventHandler.cpp - # General delete of any object in a child array field ${CMAKE_CURRENT_LIST_DIR}/RicDeleteItemExec.cpp ${CMAKE_CURRENT_LIST_DIR}/RicDeleteItemExecData.cpp ${CMAKE_CURRENT_LIST_DIR}/RicDeleteItemFeature.cpp @@ -143,7 +148,6 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RicDeleteTemporaryLgrsFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicExportContourMapToTextFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicExportContourMapToTextUi.cpp - ${CMAKE_CURRENT_LIST_DIR}/RicNewMultiPlotFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicExportStimPlanModelToFileFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicStackSelectedCurvesFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicUnstackSelectedCurvesFeature.cpp @@ -161,9 +165,17 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RicCreateEnsembleWellLogUi.cpp ${CMAKE_CURRENT_LIST_DIR}/RicCreateSurfaceIntersectionBandFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicCreateSurfaceIntersectionCurveFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicShowGridCalculatorFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicUserDefinedCalculatorDialog.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicGridCalculatorDialog.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicGridCalculatorUi.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicCalculatorWidgetCreator.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicUserDefinedCalculatorUi.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicShowDataSourcesForRealization.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicDeleteUncheckedSubItemsFeature.cpp ) -if(Qt5Charts_FOUND) +if(RESINSIGHT_USE_QT_CHARTS) list( APPEND SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RicCreateEnsembleFractureStatisticsPlotFeature.h @@ -187,6 +199,9 @@ list( ${CMAKE_CURRENT_LIST_DIR}/RicRecursiveFileSearchDialog.h ${CMAKE_CURRENT_LIST_DIR}/RicSummaryCaseRestartDialog.h ${CMAKE_CURRENT_LIST_DIR}/RicResampleDialog.h + ${CMAKE_CURRENT_LIST_DIR}/RicUserDefinedCalculatorDialog.h + ${CMAKE_CURRENT_LIST_DIR}/RicGridCalculatorDialog.h + ${CMAKE_CURRENT_LIST_DIR}/RicCalculatorWidgetCreator.h ) source_group( diff --git a/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.h b/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.h index dc4fec083b..588e163fc6 100644 --- a/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.h +++ b/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.h @@ -28,7 +28,6 @@ class RicNewPolygonFilterFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/CellFilterCommands/RicNewRangeFilterSlice3dviewFeature.h b/ApplicationLibCode/Commands/CellFilterCommands/RicNewRangeFilterSlice3dviewFeature.h index e2c2f87e14..b1769496ce 100644 --- a/ApplicationLibCode/Commands/CellFilterCommands/RicNewRangeFilterSlice3dviewFeature.h +++ b/ApplicationLibCode/Commands/CellFilterCommands/RicNewRangeFilterSlice3dviewFeature.h @@ -28,7 +28,6 @@ class RicNewRangeFilterSlice3dviewFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/CellFilterCommands/RicNewUserDefinedFilterFeature.h b/ApplicationLibCode/Commands/CellFilterCommands/RicNewUserDefinedFilterFeature.h index c0e83b69e9..41e0e84d62 100644 --- a/ApplicationLibCode/Commands/CellFilterCommands/RicNewUserDefinedFilterFeature.h +++ b/ApplicationLibCode/Commands/CellFilterCommands/RicNewUserDefinedFilterFeature.h @@ -28,7 +28,6 @@ class RicNewUserDefinedFilterFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/CompletionCommands/RicDeleteValveTemplateFeature.h b/ApplicationLibCode/Commands/CompletionCommands/RicDeleteValveTemplateFeature.h index 1a1d0d92fb..deed2540d9 100644 --- a/ApplicationLibCode/Commands/CompletionCommands/RicDeleteValveTemplateFeature.h +++ b/ApplicationLibCode/Commands/CompletionCommands/RicDeleteValveTemplateFeature.h @@ -28,7 +28,6 @@ class RicDeleteValveTemplateFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/CompletionCommands/RicImportEnsembleFractureStatisticsFeature.h b/ApplicationLibCode/Commands/CompletionCommands/RicImportEnsembleFractureStatisticsFeature.h index 4b6cb2f154..44f68061ac 100644 --- a/ApplicationLibCode/Commands/CompletionCommands/RicImportEnsembleFractureStatisticsFeature.h +++ b/ApplicationLibCode/Commands/CompletionCommands/RicImportEnsembleFractureStatisticsFeature.h @@ -40,7 +40,6 @@ class RicImportEnsembleFractureStatisticsFeature : public caf::CmdFeature protected: static void importSingleEnsembleFractureStatistics( const QStringList& fileNames ); - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/CompletionCommands/RicNewPerforationIntervalFeature.h b/ApplicationLibCode/Commands/CompletionCommands/RicNewPerforationIntervalFeature.h index d48ba2d75c..d74c680b6a 100644 --- a/ApplicationLibCode/Commands/CompletionCommands/RicNewPerforationIntervalFeature.h +++ b/ApplicationLibCode/Commands/CompletionCommands/RicNewPerforationIntervalFeature.h @@ -31,7 +31,6 @@ class RicNewPerforationIntervalFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/CompletionCommands/RicNewStimPlanModelPlotFeature.cpp b/ApplicationLibCode/Commands/CompletionCommands/RicNewStimPlanModelPlotFeature.cpp index 8dcd3badb9..1f7f89e54f 100644 --- a/ApplicationLibCode/Commands/CompletionCommands/RicNewStimPlanModelPlotFeature.cpp +++ b/ApplicationLibCode/Commands/CompletionCommands/RicNewStimPlanModelPlotFeature.cpp @@ -172,7 +172,7 @@ RimStimPlanModelPlot* RicNewStimPlanModelPlotFeature::createPlot( RimStimPlanMod plot->setLegendsVisible( true ); plot->setLegendsHorizontal( false ); plot->setDepthType( RiaDefines::DepthTypeEnum::TRUE_VERTICAL_DEPTH ); - plot->setAutoScaleDepthEnabled( true ); + plot->setAutoScaleDepthValuesEnabled( true ); } RiuPlotMainWindowTools::selectAsCurrentItem( plot ); @@ -224,15 +224,15 @@ void RicNewStimPlanModelPlotFeature::createFormationTrack( RimStimPlanModelPlot* formationTrack->setFormationWellPath( stimPlanModel->thicknessDirectionWellPath() ); formationTrack->setFormationCase( eclipseCase ); formationTrack->setAnnotationType( RiuPlotAnnotationTool::RegionAnnotationType::FORMATION_ANNOTATIONS ); - formationTrack->setXAxisGridVisibility( RimWellLogPlot::AxisGridVisibility::AXIS_GRID_NONE ); + formationTrack->setPropertyValueAxisGridVisibility( RimWellLogPlot::AxisGridVisibility::AXIS_GRID_NONE ); formationTrack->setShowWellPathAttributes( true ); formationTrack->setShowBothSidesOfWell( false ); formationTrack->setWellPathAttributesSource( stimPlanModel->thicknessDirectionWellPath() ); - formationTrack->setVisibleXRange( 0.0, 0.0 ); + formationTrack->setVisiblePropertyValueRange( 0.0, 0.0 ); formationTrack->setOverburdenHeight( stimPlanModel->overburdenHeight() ); formationTrack->setUnderburdenHeight( stimPlanModel->underburdenHeight() ); formationTrack->setColSpan( RimPlot::ONE ); - formationTrack->setXAxisTitle( stimPlanModel->unitForProperty( RiaDefines::CurveProperty::FORMATIONS ) ); + formationTrack->setPropertyValueAxisTitle( stimPlanModel->unitForProperty( RiaDefines::CurveProperty::FORMATIONS ) ); formationTrack->setLegendsVisible( true ); } @@ -260,18 +260,18 @@ void RicNewStimPlanModelPlotFeature::createFaciesTrack( RimStimPlanModelPlot* pl faciesTrack->setAnnotationDisplay( RiuPlotAnnotationTool::COLOR_SHADING ); faciesTrack->setOverburdenHeight( stimPlanModel->overburdenHeight() ); faciesTrack->setUnderburdenHeight( stimPlanModel->underburdenHeight() ); - faciesTrack->setXAxisTitle( stimPlanModel->unitForProperty( RiaDefines::CurveProperty::FACIES ) ); + faciesTrack->setPropertyValueAxisTitle( stimPlanModel->unitForProperty( RiaDefines::CurveProperty::FACIES ) ); faciesTrack->setLegendsVisible( false ); faciesTrack->setPlotTitleVisible( true ); RimColorLegend* faciesColors = faciesProperties->colorLegend(); if ( faciesColors ) faciesTrack->setColorShadingLegend( faciesColors ); - faciesTrack->setVisibleXRange( 0.0, 0.0 ); + faciesTrack->setVisiblePropertyValueRange( 0.0, 0.0 ); faciesTrack->setColSpan( RimPlot::ONE ); - faciesTrack->setAutoScaleXEnabled( false ); - faciesTrack->setVisibleXRange( 0.0, 0.0 ); - faciesTrack->setXAxisGridVisibility( RimWellLogPlot::AxisGridVisibility::AXIS_GRID_NONE ); + faciesTrack->setAutoScalePropertyValuesEnabled( false ); + faciesTrack->setVisiblePropertyValueRange( 0.0, 0.0 ); + faciesTrack->setPropertyValueAxisGridVisibility( RimWellLogPlot::AxisGridVisibility::AXIS_GRID_NONE ); caf::ColorTable colors = RiaColorTables::wellLogPlotPaletteColors(); @@ -292,8 +292,6 @@ void RicNewStimPlanModelPlotFeature::createFaciesTrack( RimStimPlanModelPlot* pl faciesTrack->updateConnectedEditors(); plot->updateConnectedEditors(); - RiaApplication::instance()->project()->updateConnectedEditors(); - RiaGuiApplication::instance()->getOrCreateMainPlotWindow(); RiuPlotMainWindowTools::showPlotMainWindow(); } @@ -320,7 +318,7 @@ void RicNewStimPlanModelPlotFeature::createLayersTrack( RimStimPlanModelPlot* pl RimColorLegend* faciesColors = faciesProperties->colorLegend(); if ( faciesColors ) faciesTrack->setColorShadingLegend( faciesColors ); - faciesTrack->setVisibleXRange( 0.0, 0.0 ); + faciesTrack->setVisiblePropertyValueRange( 0.0, 0.0 ); faciesTrack->setColSpan( RimPlot::ONE ); caf::ColorTable colors = RiaColorTables::wellLogPlotPaletteColors(); @@ -334,8 +332,8 @@ void RicNewStimPlanModelPlotFeature::createLayersTrack( RimStimPlanModelPlot* pl curve->setAutoNameComponents( false, true, false, false, false ); faciesTrack->addCurve( curve ); - faciesTrack->setAutoScaleXEnabled( true ); - faciesTrack->setXAxisTitle( stimPlanModel->unitForProperty( RiaDefines::CurveProperty::LAYERS ) ); + faciesTrack->setAutoScalePropertyValuesEnabled( true ); + faciesTrack->setPropertyValueAxisTitle( stimPlanModel->unitForProperty( RiaDefines::CurveProperty::LAYERS ) ); curve->loadDataAndUpdate( true ); @@ -343,8 +341,6 @@ void RicNewStimPlanModelPlotFeature::createLayersTrack( RimStimPlanModelPlot* pl faciesTrack->updateConnectedEditors(); plot->updateConnectedEditors(); - RiaApplication::instance()->project()->updateConnectedEditors(); - RiaGuiApplication::instance()->getOrCreateMainPlotWindow(); RiuPlotMainWindowTools::showPlotMainWindow(); } @@ -420,18 +416,16 @@ void RicNewStimPlanModelPlotFeature::createParametersTrack( RimStimPlanModelPlot colorIndex++; } - plotTrack->setXAxisGridVisibility( RimWellLogPlot::AXIS_GRID_MAJOR ); + plotTrack->setPropertyValueAxisGridVisibility( RimWellLogPlot::AXIS_GRID_MAJOR ); plotTrack->setShowRegionLabels( true ); plotTrack->setLogarithmicScale( isPlotLogarithmic ); - plotTrack->setAutoScaleXEnabled( true ); + plotTrack->setAutoScalePropertyValuesEnabled( true ); plotTrack->setMinAndMaxTicksOnly( useMinMaxTicksOnly( propertyTypes[0] ) ); - plotTrack->setXAxisTitle( stimPlanModel->unitForProperty( propertyTypes[0] ) ); + plotTrack->setPropertyValueAxisTitle( stimPlanModel->unitForProperty( propertyTypes[0] ) ); plotTrack->updateConnectedEditors(); plot->updateConnectedEditors(); - RiaApplication::instance()->project()->updateConnectedEditors(); - RiaGuiApplication::instance()->getOrCreateMainPlotWindow(); RiuPlotMainWindowTools::showPlotMainWindow(); } diff --git a/ApplicationLibCode/Commands/CompletionCommands/RicNewStimPlanModelPlotFeature.h b/ApplicationLibCode/Commands/CompletionCommands/RicNewStimPlanModelPlotFeature.h index 7ce5e66152..8d70aa19e8 100644 --- a/ApplicationLibCode/Commands/CompletionCommands/RicNewStimPlanModelPlotFeature.h +++ b/ApplicationLibCode/Commands/CompletionCommands/RicNewStimPlanModelPlotFeature.h @@ -43,7 +43,6 @@ class RicNewStimPlanModelPlotFeature : public caf::CmdFeature static RimStimPlanModelPlot* createPlot( RimStimPlanModel* stimPlanModel ); protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/CompletionCommands/RicNewValveFeature.h b/ApplicationLibCode/Commands/CompletionCommands/RicNewValveFeature.h index 91f8abb3a7..38663edfa6 100644 --- a/ApplicationLibCode/Commands/CompletionCommands/RicNewValveFeature.h +++ b/ApplicationLibCode/Commands/CompletionCommands/RicNewValveFeature.h @@ -28,7 +28,6 @@ class RicNewValveFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/CompletionCommands/RicWellPathImportPerforationIntervalsFeature.h b/ApplicationLibCode/Commands/CompletionCommands/RicWellPathImportPerforationIntervalsFeature.h index 98672f4625..88ea29f586 100644 --- a/ApplicationLibCode/Commands/CompletionCommands/RicWellPathImportPerforationIntervalsFeature.h +++ b/ApplicationLibCode/Commands/CompletionCommands/RicWellPathImportPerforationIntervalsFeature.h @@ -30,7 +30,6 @@ class RicWellPathImportPerforationIntervalsFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/CompletionExportCommands/RicCaseAndFileExportSettingsUi.cpp b/ApplicationLibCode/Commands/CompletionExportCommands/RicCaseAndFileExportSettingsUi.cpp index 6df38e4ff4..526187b76b 100644 --- a/ApplicationLibCode/Commands/CompletionExportCommands/RicCaseAndFileExportSettingsUi.cpp +++ b/ApplicationLibCode/Commands/CompletionExportCommands/RicCaseAndFileExportSettingsUi.cpp @@ -29,20 +29,19 @@ CAF_PDM_SOURCE_INIT( RicCaseAndFileExportSettingsUi, "RicCaseAndFileExportSettin //-------------------------------------------------------------------------------------------------- RicCaseAndFileExportSettingsUi::RicCaseAndFileExportSettingsUi() { - CAF_PDM_InitObject( "RimCaseAndFileExportSettings", "", "", "" ); + CAF_PDM_InitObject( "RimCaseAndFileExportSettings" ); - CAF_PDM_InitFieldNoDefault( &folder, "Folder", "Export Folder", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &folder, "Folder", "Export Folder" ); folder.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &caseToApply, "CaseToApply", "Case to Apply", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &caseToApply, "CaseToApply", "Case to Apply" ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- QList - RicCaseAndFileExportSettingsUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) + RicCaseAndFileExportSettingsUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; diff --git a/ApplicationLibCode/Commands/CompletionExportCommands/RicCaseAndFileExportSettingsUi.h b/ApplicationLibCode/Commands/CompletionExportCommands/RicCaseAndFileExportSettingsUi.h index ab1984ba7e..ba9591f7d9 100644 --- a/ApplicationLibCode/Commands/CompletionExportCommands/RicCaseAndFileExportSettingsUi.h +++ b/ApplicationLibCode/Commands/CompletionExportCommands/RicCaseAndFileExportSettingsUi.h @@ -38,8 +38,7 @@ class RicCaseAndFileExportSettingsUi : public caf::PdmObject caf::PdmField folder; caf::PdmPtrField caseToApply; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; protected: void defineEditorAttribute( const caf::PdmFieldHandle* field, diff --git a/ApplicationLibCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp b/ApplicationLibCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp index 3f774af6d6..a4314d6567 100644 --- a/ApplicationLibCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp +++ b/ApplicationLibCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp @@ -72,26 +72,26 @@ CAF_PDM_SOURCE_INIT( RicExportCompletionDataSettingsUi, "RicExportCompletionData //-------------------------------------------------------------------------------------------------- RicExportCompletionDataSettingsUi::RicExportCompletionDataSettingsUi() { - CAF_PDM_InitObject( "RimExportCompletionDataSettings", "", "", "" ); + CAF_PDM_InitObject( "RimExportCompletionDataSettings" ); - CAF_PDM_InitFieldNoDefault( &fileSplit, "FileSplit", "File Split", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &fileSplit, "FileSplit", "File Split" ); CAF_PDM_InitFieldNoDefault( &compdatExport, "compdatExport", "Export", "", " ", "" ); - CAF_PDM_InitField( &timeStep, "TimeStepIndex", 0, " Time Step", "", "", "" ); + CAF_PDM_InitField( &timeStep, "TimeStepIndex", 0, " Time Step" ); - CAF_PDM_InitField( &includeMsw, "IncludeMSW", true, "Multi Segment Well Model", "", "", "" ); + CAF_PDM_InitField( &includeMsw, "IncludeMSW", true, "Multi Segment Well Model" ); - CAF_PDM_InitField( &useLateralNTG, "UseLateralNTG", false, "Use NTG Horizontally", "", "", "" ); + CAF_PDM_InitField( &useLateralNTG, "UseLateralNTG", false, "Use NTG Horizontally" ); - CAF_PDM_InitField( &includePerforations, "IncludePerforations", true, "Perforations", "", "", "" ); - CAF_PDM_InitField( &includeFishbones, "IncludeFishbones", true, "Fishbones", "", "", "" ); - CAF_PDM_InitField( &includeFractures, "IncludeFractures", true, "Fractures", "", "", "" ); + CAF_PDM_InitField( &includePerforations, "IncludePerforations", true, "Perforations" ); + CAF_PDM_InitField( &includeFishbones, "IncludeFishbones", true, "Fishbones" ); + CAF_PDM_InitField( &includeFractures, "IncludeFractures", true, "Fractures" ); - CAF_PDM_InitField( &performTransScaling, "TransScalingType", false, "Perform Transmissibility Scaling", "", "", "" ); - CAF_PDM_InitField( &transScalingTimeStep, "TransScalingTimeStep", 0, "Current Time Step", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &transScalingWBHPSource, "TransScalingWBHPSource", "WBHP Selection", "", "", "" ); - CAF_PDM_InitField( &transScalingWBHP, "TransScalingWBHP", 200.0, "WBHP Before Production Start", "", "", "" ); + CAF_PDM_InitField( &performTransScaling, "TransScalingType", false, "Perform Transmissibility Scaling" ); + CAF_PDM_InitField( &transScalingTimeStep, "TransScalingTimeStep", 0, "Current Time Step" ); + CAF_PDM_InitFieldNoDefault( &transScalingWBHPSource, "TransScalingWBHPSource", "WBHP Selection" ); + CAF_PDM_InitField( &transScalingWBHP, "TransScalingWBHP", 200.0, "WBHP Before Production Start" ); CAF_PDM_InitField( &excludeMainBoreForFishbones, "ExcludeMainBoreForFishbones", @@ -104,24 +104,15 @@ RicExportCompletionDataSettingsUi::RicExportCompletionDataSettingsUi() CAF_PDM_InitFieldNoDefault( &m_reportCompletionTypesSeparately, "ReportCompletionTypesSeparately", - "Export Completion Types", - "", - "", - "" ); - - CAF_PDM_InitField( &m_exportDataSourceAsComment, "ExportDataSourceAsComment", true, "Comments", "", "", "" ); - - CAF_PDM_InitField( &m_exportWelspec, "ExportWelspec", true, "WELSPEC keyword", "", "", "" ); - CAF_PDM_InitField( &m_completionWelspecAfterMainBore, - "CompletionWelspecAfterMainBore", - true, - "WELSEGS per Completion Type", - "", - "", - "" ); + "Export Completion Types" ); + + CAF_PDM_InitField( &m_exportDataSourceAsComment, "ExportDataSourceAsComment", true, "Comments" ); + + CAF_PDM_InitField( &m_exportWelspec, "ExportWelspec", true, "WELSPEC keyword" ); + CAF_PDM_InitField( &m_completionWelspecAfterMainBore, "CompletionWelspecAfterMainBore", true, "WELSEGS per Completion Type" ); - CAF_PDM_InitField( &m_useCustomFileName, "UseCustomFileName", false, "Use Custom Filename", "", "", "" ); - CAF_PDM_InitField( &m_customFileName, "CustomFileName", {}, "Custom Filename", "", "", "" ); + CAF_PDM_InitField( &m_useCustomFileName, "UseCustomFileName", false, "Use Custom Filename" ); + CAF_PDM_InitField( &m_customFileName, "CustomFileName", {}, "Custom Filename" ); m_displayForSimWell = true; @@ -285,8 +276,7 @@ void RicExportCompletionDataSettingsUi::fieldChangedByUi( const caf::PdmFieldHan /// //-------------------------------------------------------------------------------------------------- QList - RicExportCompletionDataSettingsUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) + RicExportCompletionDataSettingsUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; if ( fieldNeedingOptions == &timeStep ) @@ -358,7 +348,7 @@ QList else { - options = RicCaseAndFileExportSettingsUi::calculateValueOptions( fieldNeedingOptions, useOptionsOnly ); + options = RicCaseAndFileExportSettingsUi::calculateValueOptions( fieldNeedingOptions ); } return options; } diff --git a/ApplicationLibCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h b/ApplicationLibCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h index 0bfade5059..bed9f47ee6 100644 --- a/ApplicationLibCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h +++ b/ApplicationLibCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h @@ -107,8 +107,7 @@ class RicExportCompletionDataSettingsUi : public RicCaseAndFileExportSettingsUi void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; protected: - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; std::map>> generateWellProductionStartStrings(); diff --git a/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp b/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp index 672c4bbfe1..e0506b957f 100644 --- a/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp +++ b/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp @@ -762,7 +762,7 @@ void RicWellPathExportCompletionDataFeatureImpl::exportWelspecsToFile( RimEclips auto ijIntersection = wellPathUpperGridIntersectionIJ( gridCase, wellPath ); formatter.add( completionSettings->wellNameForExport() ) - .add( completionSettings->wellGroupNameForExport() ) + .add( completionSettings->groupNameForExport() ) .addOneBasedCellIndex( ijIntersection.second.x() ) .addOneBasedCellIndex( ijIntersection.second.y() ) .add( completionSettings->referenceDepthForExport() ) @@ -853,7 +853,7 @@ void RicWellPathExportCompletionDataFeatureImpl::exportWelspeclToFile( auto completionSettings = wellPath->completionSettings(); formatter.add( completionSettings->wellNameForExport() ) - .add( completionSettings->wellGroupNameForExport() ) + .add( completionSettings->groupNameForExport() ) .add( lgrName ) .addOneBasedCellIndex( ijIntersection.x() ) .addOneBasedCellIndex( ijIntersection.y() ) diff --git a/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp b/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp index 34f0d1564d..39f1f55ec1 100644 --- a/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp +++ b/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp @@ -1126,13 +1126,24 @@ std::vector WellPathCellIntersectionInfo extraIntersection; - extraIntersection.globCellIndex = std::numeric_limits::max(); - extraIntersection.startPoint = intersectionPoint; - extraIntersection.endPoint = firstIntersection.startPoint; - extraIntersection.startMD = initialMD; - extraIntersection.endMD = firstIntersection.startMD; - extraIntersection.intersectedCellFaceIn = cvf::StructGridInterface::NO_FACE; - extraIntersection.intersectedCellFaceOut = firstIntersection.intersectedCellFaceOut; + extraIntersection.globCellIndex = std::numeric_limits::max(); + extraIntersection.startPoint = intersectionPoint; + extraIntersection.endPoint = firstIntersection.startPoint; + extraIntersection.startMD = initialMD; + extraIntersection.endMD = firstIntersection.startMD; + extraIntersection.intersectedCellFaceIn = cvf::StructGridInterface::NO_FACE; + + if ( firstIntersection.intersectedCellFaceIn != cvf::StructGridInterface::NO_FACE ) + + { + extraIntersection.intersectedCellFaceOut = + cvf::StructGridInterface::oppositeFace( firstIntersection.intersectedCellFaceIn ); + } + else if ( firstIntersection.intersectedCellFaceOut != cvf::StructGridInterface::NO_FACE ) + { + extraIntersection.intersectedCellFaceOut = firstIntersection.intersectedCellFaceOut; + } + extraIntersection.intersectionLengthsInCellCS = cvf::Vec3d::ZERO; filteredIntersections.push_back( extraIntersection ); diff --git a/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewCorrelationMatrixPlotFeature.h b/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewCorrelationMatrixPlotFeature.h index da9caa1ff0..ccefe65f41 100644 --- a/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewCorrelationMatrixPlotFeature.h +++ b/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewCorrelationMatrixPlotFeature.h @@ -28,7 +28,6 @@ class RicNewCorrelationMatrixPlotFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewCorrelationPlotFeature.h b/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewCorrelationPlotFeature.h index 72eda7591e..feca8d1215 100644 --- a/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewCorrelationPlotFeature.h +++ b/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewCorrelationPlotFeature.h @@ -53,7 +53,6 @@ class RicNewCorrelationPlotFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewCorrelationReportPlotFeature.h b/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewCorrelationReportPlotFeature.h index e0f720d934..7e907c54c7 100644 --- a/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewCorrelationReportPlotFeature.h +++ b/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewCorrelationReportPlotFeature.h @@ -28,7 +28,6 @@ class RicNewCorrelationReportPlotFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewParameterResultCrossPlotFeature.h b/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewParameterResultCrossPlotFeature.h index ca502f2bab..e602879035 100644 --- a/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewParameterResultCrossPlotFeature.h +++ b/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewParameterResultCrossPlotFeature.h @@ -28,7 +28,6 @@ class RicNewParameterResultCrossPlotFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/CrossSectionCommands/RicAppendIntersectionFeature.h b/ApplicationLibCode/Commands/CrossSectionCommands/RicAppendIntersectionFeature.h index 3c9f6fc8f6..d4d787b9a9 100644 --- a/ApplicationLibCode/Commands/CrossSectionCommands/RicAppendIntersectionFeature.h +++ b/ApplicationLibCode/Commands/CrossSectionCommands/RicAppendIntersectionFeature.h @@ -50,7 +50,6 @@ class RicAppendIntersectionFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/CrossSectionCommands/RicAppendSeparateIntersectionResultFeature.h b/ApplicationLibCode/Commands/CrossSectionCommands/RicAppendSeparateIntersectionResultFeature.h index 4023c5fdb9..c45b54aa48 100644 --- a/ApplicationLibCode/Commands/CrossSectionCommands/RicAppendSeparateIntersectionResultFeature.h +++ b/ApplicationLibCode/Commands/CrossSectionCommands/RicAppendSeparateIntersectionResultFeature.h @@ -49,7 +49,6 @@ class RicAppendSeparateIntersectionResultFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/CrossSectionCommands/RicCopyIntersectionsToAllViewsInCaseFeature.h b/ApplicationLibCode/Commands/CrossSectionCommands/RicCopyIntersectionsToAllViewsInCaseFeature.h index 54e548f774..dc24e0016a 100644 --- a/ApplicationLibCode/Commands/CrossSectionCommands/RicCopyIntersectionsToAllViewsInCaseFeature.h +++ b/ApplicationLibCode/Commands/CrossSectionCommands/RicCopyIntersectionsToAllViewsInCaseFeature.h @@ -36,7 +36,6 @@ class RicCopyIntersectionsToAllViewsInCaseFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/CrossSectionCommands/RicNewSimWellIntersectionFeature.cpp b/ApplicationLibCode/Commands/CrossSectionCommands/RicNewSimWellIntersectionFeature.cpp index 9a54a35d3e..4ec8b7d5ea 100644 --- a/ApplicationLibCode/Commands/CrossSectionCommands/RicNewSimWellIntersectionFeature.cpp +++ b/ApplicationLibCode/Commands/CrossSectionCommands/RicNewSimWellIntersectionFeature.cpp @@ -46,18 +46,18 @@ bool RicNewSimWellIntersectionFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicNewSimWellIntersectionFeature::onActionTriggered( bool isChecked ) { - std::vector collection; - caf::SelectionManager::instance()->objectsByType( &collection ); - CVF_ASSERT( collection.size() == 1 ); - - RimSimWellInView* simWell = collection[0]; - - RimEclipseView* eclView = nullptr; - simWell->firstAncestorOrThisOfType( eclView ); - CVF_ASSERT( eclView ); - - RicNewSimWellIntersectionCmd* cmd = new RicNewSimWellIntersectionCmd( eclView->intersectionCollection(), simWell ); - caf::CmdExecCommandManager::instance()->processExecuteCommand( cmd ); + std::vector simWells; + caf::SelectionManager::instance()->objectsByType( &simWells ); + + for ( auto simWell : simWells ) + { + RimEclipseView* eclView = nullptr; + simWell->firstAncestorOrThisOfType( eclView ); + CVF_ASSERT( eclView ); + + auto* cmd = new RicNewSimWellIntersectionCmd( eclView->intersectionCollection(), simWell ); + caf::CmdExecCommandManager::instance()->processExecuteCommand( cmd ); + } } //-------------------------------------------------------------------------------------------------- @@ -103,7 +103,7 @@ void RicNewSimWellIntersectionCmd::redo() CVF_ASSERT( m_intersectionCollection ); CVF_ASSERT( m_simWell ); - RimExtrudedCurveIntersection* intersection = new RimExtrudedCurveIntersection(); + auto* intersection = new RimExtrudedCurveIntersection(); intersection->setName( m_simWell->name ); intersection->configureForSimulationWell( m_simWell ); diff --git a/ApplicationLibCode/Commands/CrossSectionCommands/RicNewSimWellIntersectionFeature.h b/ApplicationLibCode/Commands/CrossSectionCommands/RicNewSimWellIntersectionFeature.h index 4828c5bb59..6c7e135764 100644 --- a/ApplicationLibCode/Commands/CrossSectionCommands/RicNewSimWellIntersectionFeature.h +++ b/ApplicationLibCode/Commands/CrossSectionCommands/RicNewSimWellIntersectionFeature.h @@ -52,7 +52,6 @@ class RicNewSimWellIntersectionFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/CrossSectionCommands/RicNewWellPathIntersectionFeature.h b/ApplicationLibCode/Commands/CrossSectionCommands/RicNewWellPathIntersectionFeature.h index ef472a201b..06a596b505 100644 --- a/ApplicationLibCode/Commands/CrossSectionCommands/RicNewWellPathIntersectionFeature.h +++ b/ApplicationLibCode/Commands/CrossSectionCommands/RicNewWellPathIntersectionFeature.h @@ -55,7 +55,6 @@ class RicNewWellPathIntersectionFeature : public caf::CmdFeature RicNewWellPathIntersectionFeature(); protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/EclipseCommands/RicAddEclipseInputPropertyFeature.h b/ApplicationLibCode/Commands/EclipseCommands/RicAddEclipseInputPropertyFeature.h index 09960eddf6..fd25216bf6 100644 --- a/ApplicationLibCode/Commands/EclipseCommands/RicAddEclipseInputPropertyFeature.h +++ b/ApplicationLibCode/Commands/EclipseCommands/RicAddEclipseInputPropertyFeature.h @@ -31,7 +31,6 @@ class RicAddEclipseInputPropertyFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/EclipseCommands/RicComputeStatisticsFeature.h b/ApplicationLibCode/Commands/EclipseCommands/RicComputeStatisticsFeature.h index c46e458c42..e8bfda31b2 100644 --- a/ApplicationLibCode/Commands/EclipseCommands/RicComputeStatisticsFeature.h +++ b/ApplicationLibCode/Commands/EclipseCommands/RicComputeStatisticsFeature.h @@ -33,7 +33,6 @@ class RicComputeStatisticsFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/EclipseCommands/RicCreateGridCaseGroupFromFilesFeature.h b/ApplicationLibCode/Commands/EclipseCommands/RicCreateGridCaseGroupFromFilesFeature.h index e09806fcc6..a95e8c5a81 100644 --- a/ApplicationLibCode/Commands/EclipseCommands/RicCreateGridCaseGroupFromFilesFeature.h +++ b/ApplicationLibCode/Commands/EclipseCommands/RicCreateGridCaseGroupFromFilesFeature.h @@ -37,7 +37,6 @@ class RicCreateGridCaseGroupFromFilesFeature : public caf::CmdFeature } protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/EclipseCommands/RicEclipseCaseNewGroupFeature.h b/ApplicationLibCode/Commands/EclipseCommands/RicEclipseCaseNewGroupFeature.h index 35252872e7..56eb99dbdc 100644 --- a/ApplicationLibCode/Commands/EclipseCommands/RicEclipseCaseNewGroupFeature.h +++ b/ApplicationLibCode/Commands/EclipseCommands/RicEclipseCaseNewGroupFeature.h @@ -29,7 +29,6 @@ class RicEclipseCaseNewGroupFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/EclipseCommands/RicEclipsePropertyFilterInsertExec.cpp b/ApplicationLibCode/Commands/EclipseCommands/RicEclipsePropertyFilterInsertExec.cpp index 725ad4a72c..d6b5f6ff4f 100644 --- a/ApplicationLibCode/Commands/EclipseCommands/RicEclipsePropertyFilterInsertExec.cpp +++ b/ApplicationLibCode/Commands/EclipseCommands/RicEclipsePropertyFilterInsertExec.cpp @@ -59,7 +59,7 @@ void RicEclipsePropertyFilterInsertExec::redo() RimEclipsePropertyFilterCollection* propertyFilterCollection = nullptr; m_propertyFilter->firstAncestorOrThisOfTypeAsserted( propertyFilterCollection ); - size_t index = propertyFilterCollection->propertyFilters.index( m_propertyFilter ); + size_t index = propertyFilterCollection->propertyFilters.indexOf( m_propertyFilter ); CVF_ASSERT( index < propertyFilterCollection->propertyFilters.size() ); RicEclipsePropertyFilterFeatureImpl::insertPropertyFilter( propertyFilterCollection, index ); diff --git a/ApplicationLibCode/Commands/EclipseCommands/RicEclipsePropertyFilterInsertFeature.h b/ApplicationLibCode/Commands/EclipseCommands/RicEclipsePropertyFilterInsertFeature.h index 871f50f3d4..50e239928a 100644 --- a/ApplicationLibCode/Commands/EclipseCommands/RicEclipsePropertyFilterInsertFeature.h +++ b/ApplicationLibCode/Commands/EclipseCommands/RicEclipsePropertyFilterInsertFeature.h @@ -29,7 +29,6 @@ class RicEclipsePropertyFilterInsertFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/EclipseCommands/RicEclipsePropertyFilterNewFeature.h b/ApplicationLibCode/Commands/EclipseCommands/RicEclipsePropertyFilterNewFeature.h index d4e0a22596..d9d6a43478 100644 --- a/ApplicationLibCode/Commands/EclipseCommands/RicEclipsePropertyFilterNewFeature.h +++ b/ApplicationLibCode/Commands/EclipseCommands/RicEclipsePropertyFilterNewFeature.h @@ -29,7 +29,6 @@ class RicEclipsePropertyFilterNewFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/EclipseCommands/RicEclipseShowOnlyFaultFeature.cpp b/ApplicationLibCode/Commands/EclipseCommands/RicEclipseShowOnlyFaultFeature.cpp index cdfaaca98c..c945f45743 100644 --- a/ApplicationLibCode/Commands/EclipseCommands/RicEclipseShowOnlyFaultFeature.cpp +++ b/ApplicationLibCode/Commands/EclipseCommands/RicEclipseShowOnlyFaultFeature.cpp @@ -77,7 +77,7 @@ void RicEclipseShowOnlyFaultFeature::onActionTriggered( bool isChecked ) if ( !rimFault->parentField() ) return; std::vector children; - rimFault->parentField()->childObjects( &children ); + rimFault->parentField()->children( &children ); for ( auto& child : children ) { diff --git a/ApplicationLibCode/Commands/EclipseCommands/RicImportEclipseCaseFeature.h b/ApplicationLibCode/Commands/EclipseCommands/RicImportEclipseCaseFeature.h index c102050c41..0297c3d365 100644 --- a/ApplicationLibCode/Commands/EclipseCommands/RicImportEclipseCaseFeature.h +++ b/ApplicationLibCode/Commands/EclipseCommands/RicImportEclipseCaseFeature.h @@ -33,7 +33,6 @@ class RicImportEclipseCaseFeature : public RicImportGeneralDataFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.h b/ApplicationLibCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.h index 7d2dd2a262..82a0e499df 100644 --- a/ApplicationLibCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.h +++ b/ApplicationLibCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.h @@ -38,7 +38,6 @@ class RicImportEclipseCasesFeature : public caf::CmdFeature } protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/EclipseCommands/RicImportInputEclipseCaseFeature.h b/ApplicationLibCode/Commands/EclipseCommands/RicImportInputEclipseCaseFeature.h index 3793ef5c32..54601ef289 100644 --- a/ApplicationLibCode/Commands/EclipseCommands/RicImportInputEclipseCaseFeature.h +++ b/ApplicationLibCode/Commands/EclipseCommands/RicImportInputEclipseCaseFeature.h @@ -35,7 +35,6 @@ class RicImportInputEclipseCaseFeature : public RicImportGeneralDataFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/EclipseCommands/RicNewStatisticsCaseFeature.h b/ApplicationLibCode/Commands/EclipseCommands/RicNewStatisticsCaseFeature.h index 600258eeaf..52901d14cc 100644 --- a/ApplicationLibCode/Commands/EclipseCommands/RicNewStatisticsCaseFeature.h +++ b/ApplicationLibCode/Commands/EclipseCommands/RicNewStatisticsCaseFeature.h @@ -38,7 +38,6 @@ class RicNewStatisticsCaseFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/ExportCommands/RicAdvancedSnapshotExportFeature.cpp b/ApplicationLibCode/Commands/ExportCommands/RicAdvancedSnapshotExportFeature.cpp index 2fc2cf3946..018afed07e 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicAdvancedSnapshotExportFeature.cpp +++ b/ApplicationLibCode/Commands/ExportCommands/RicAdvancedSnapshotExportFeature.cpp @@ -147,7 +147,7 @@ void RicAdvancedSnapshotExportFeature::exportMultipleSnapshots( const QString& f exportViewVariations( copyOfEclipseView, msd, folder ); - eclCase->reservoirViews().removeChildObject( copyOfEclipseView ); + eclCase->reservoirViews().removeChild( copyOfEclipseView ); delete copyOfEclipseView; } @@ -172,7 +172,7 @@ void RicAdvancedSnapshotExportFeature::exportMultipleSnapshots( const QString& f exportViewVariations( copyOfGeoMechView, msd, folder ); - geomCase->geoMechViews().removeChildObject( copyOfGeoMechView ); + geomCase->geoMechViews().removeChild( copyOfGeoMechView ); delete copyOfGeoMechView; } @@ -210,7 +210,7 @@ void RicAdvancedSnapshotExportFeature::exportViewVariations( Rim3dView* exportViewVariationsToFolder( copyOfView, msd, folder ); } - eclCase->reservoirViews().removeChildObject( copyOfView ); + eclCase->reservoirViews().removeChild( copyOfView ); delete copyOfView; } diff --git a/ApplicationLibCode/Commands/ExportCommands/RicCellRangeUi.cpp b/ApplicationLibCode/Commands/ExportCommands/RicCellRangeUi.cpp index d1342672cf..e90a971b36 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicCellRangeUi.cpp +++ b/ApplicationLibCode/Commands/ExportCommands/RicCellRangeUi.cpp @@ -40,20 +40,20 @@ CAF_PDM_SOURCE_INIT( RicCellRangeUi, "RicCellRangeUi" ); //-------------------------------------------------------------------------------------------------- RicCellRangeUi::RicCellRangeUi() { - CAF_PDM_InitObject( "Cell Range", "", "", "" ); + CAF_PDM_InitObject( "Cell Range" ); - CAF_PDM_InitFieldNoDefault( &m_case, "Case", "Case", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_case, "Case", "Case" ); m_case.uiCapability()->setUiHidden( true ); - CAF_PDM_InitField( &m_gridIndex, "GridIndex", 0, "Grid", "", "", "" ); + CAF_PDM_InitField( &m_gridIndex, "GridIndex", 0, "Grid" ); - CAF_PDM_InitField( &m_startIndexI, "StartIndexI", 1, "Start Index I", "", "", "" ); - CAF_PDM_InitField( &m_startIndexJ, "StartIndexJ", 1, "Start Index J", "", "", "" ); - CAF_PDM_InitField( &m_startIndexK, "StartIndexK", 1, "Start Index K", "", "", "" ); + CAF_PDM_InitField( &m_startIndexI, "StartIndexI", 1, "Start Index I" ); + CAF_PDM_InitField( &m_startIndexJ, "StartIndexJ", 1, "Start Index J" ); + CAF_PDM_InitField( &m_startIndexK, "StartIndexK", 1, "Start Index K" ); - CAF_PDM_InitField( &m_cellCountI, "CellCountI", 1, "Cell Count I", "", "", "" ); - CAF_PDM_InitField( &m_cellCountJ, "CellCountJ", 1, "Cell Count J", "", "", "" ); - CAF_PDM_InitField( &m_cellCountK, "CellCountK", 1, "Cell Count K", "", "", "" ); + CAF_PDM_InitField( &m_cellCountI, "CellCountI", 1, "Cell Count I" ); + CAF_PDM_InitField( &m_cellCountJ, "CellCountJ", 1, "Cell Count J" ); + CAF_PDM_InitField( &m_cellCountK, "CellCountK", 1, "Cell Count K" ); m_startIndexI.uiCapability()->setUiEditorTypeName( caf::PdmUiSliderEditor::uiEditorTypeName() ); m_startIndexJ.uiCapability()->setUiEditorTypeName( caf::PdmUiSliderEditor::uiEditorTypeName() ); @@ -139,13 +139,10 @@ void RicCellRangeUi::defineEditorAttribute( const caf::PdmFieldHandle* field, //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RicCellRangeUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RicCellRangeUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; - if ( useOptionsOnly ) ( *useOptionsOnly ) = true; - if ( &m_gridIndex == fieldNeedingOptions ) { for ( int gIdx = 0; gIdx < RigReservoirGridTools::gridCount( m_case ); ++gIdx ) diff --git a/ApplicationLibCode/Commands/ExportCommands/RicCellRangeUi.h b/ApplicationLibCode/Commands/ExportCommands/RicCellRangeUi.h index ac2fcc3167..7ea3a2f6ad 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicCellRangeUi.h +++ b/ApplicationLibCode/Commands/ExportCommands/RicCellRangeUi.h @@ -46,8 +46,7 @@ class RicCellRangeUi : public caf::PdmObject void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; diff --git a/ApplicationLibCode/Commands/ExportCommands/RicExportCarfin.h b/ApplicationLibCode/Commands/ExportCommands/RicExportCarfin.h index 3514b37b80..854fd2bdae 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicExportCarfin.h +++ b/ApplicationLibCode/Commands/ExportCommands/RicExportCarfin.h @@ -30,7 +30,6 @@ class RicExportCarfin : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/ExportCommands/RicExportCarfinUi.cpp b/ApplicationLibCode/Commands/ExportCommands/RicExportCarfinUi.cpp index 77f65dd1fe..394d8aa57a 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicExportCarfinUi.cpp +++ b/ApplicationLibCode/Commands/ExportCommands/RicExportCarfinUi.cpp @@ -33,20 +33,20 @@ CAF_PDM_SOURCE_INIT( RicExportCarfinUi, "RicExportCarfinUi" ); //-------------------------------------------------------------------------------------------------- RicExportCarfinUi::RicExportCarfinUi() { - CAF_PDM_InitObject( "Export CARFIN", "", "", "" ); + CAF_PDM_InitObject( "Export CARFIN" ); - CAF_PDM_InitFieldNoDefault( &m_cellRange, "CellRange", "Cell Range", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_cellRange, "CellRange", "Cell Range" ); m_cellRange = new RicCellRangeUi; - CAF_PDM_InitFieldNoDefault( &m_exportFileName, "ExportFileName", "Export Filename", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_exportFileName, "ExportFileName", "Export Filename" ); m_exportFileName.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_caseToApply, "CaseToApply", "Source Case", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_caseToApply, "CaseToApply", "Source Case" ); - CAF_PDM_InitField( &m_cellCountI, "CellCountI", 2, "Cell Count I", "", "", "" ); - CAF_PDM_InitField( &m_cellCountJ, "CellCountJ", 2, "Cell Count J", "", "", "" ); - CAF_PDM_InitField( &m_cellCountK, "CellCountK", 2, "Cell Count K", "", "", "" ); - CAF_PDM_InitField( &m_maxWellCount, "MaxWellCount", 8, "Max Well Count", "", "", "" ); + CAF_PDM_InitField( &m_cellCountI, "CellCountI", 2, "Cell Count I" ); + CAF_PDM_InitField( &m_cellCountJ, "CellCountJ", 2, "Cell Count J" ); + CAF_PDM_InitField( &m_cellCountK, "CellCountK", 2, "Cell Count K" ); + CAF_PDM_InitField( &m_maxWellCount, "MaxWellCount", 8, "Max Well Count" ); } //-------------------------------------------------------------------------------------------------- @@ -141,8 +141,7 @@ void RicExportCarfinUi::setDefaultValuesFromCase() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RicExportCarfinUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RicExportCarfinUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; diff --git a/ApplicationLibCode/Commands/ExportCommands/RicExportCarfinUi.h b/ApplicationLibCode/Commands/ExportCommands/RicExportCarfinUi.h index e0851bc063..8e2aceaeeb 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicExportCarfinUi.h +++ b/ApplicationLibCode/Commands/ExportCommands/RicExportCarfinUi.h @@ -54,8 +54,7 @@ class RicExportCarfinUi : public caf::PdmObject void setCasePointers( RimEclipseCase* rimCase ); void setDefaultValuesFromCase(); - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineEditorAttribute( const caf::PdmFieldHandle* field, diff --git a/ApplicationLibCode/Commands/ExportCommands/RicExportEclipseSectorModelUi.cpp b/ApplicationLibCode/Commands/ExportCommands/RicExportEclipseSectorModelUi.cpp index 96ad9179e3..11ab64cfa8 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicExportEclipseSectorModelUi.cpp +++ b/ApplicationLibCode/Commands/ExportCommands/RicExportEclipseSectorModelUi.cpp @@ -75,10 +75,10 @@ void RicExportEclipseSectorModelUi::GridBoxSelectionEnum::setUp() //-------------------------------------------------------------------------------------------------- RicExportEclipseSectorModelUi::RicExportEclipseSectorModelUi() { - CAF_PDM_InitObject( "Export Visible Cells as Eclipse Input Grid", "", "", "" ); + CAF_PDM_InitObject( "Export Visible Cells as Eclipse Input Grid" ); CAF_PDM_InitField( &exportGrid, "ExportGrid", true, "Export Grid Data", "", "Includes COORD, ZCORN and ACTNUM", "" ); - CAF_PDM_InitField( &exportGridFilename, "ExportGridFilename", QString(), "Grid File Name", "", "", "" ); + CAF_PDM_InitField( &exportGridFilename, "ExportGridFilename", QString(), "Grid File Name" ); exportGridFilename.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); CAF_PDM_InitField( &exportInLocalCoordinates, "ExportInLocalCoords", @@ -87,39 +87,39 @@ RicExportEclipseSectorModelUi::RicExportEclipseSectorModelUi() "", "Remove UTM location on export", "" ); - CAF_PDM_InitField( &makeInvisibleCellsInactive, "InvisibleCellActnum", false, "Make Invisible Cells Inactive", "", "", "" ); + CAF_PDM_InitField( &makeInvisibleCellsInactive, "InvisibleCellActnum", false, "Make Invisible Cells Inactive" ); - CAF_PDM_InitFieldNoDefault( &exportGridBox, "GridBoxSelection", "Cells to Export", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &exportGridBox, "GridBoxSelection", "Cells to Export" ); QString minIJKLabel = "Min I, J, K"; - CAF_PDM_InitField( &minI, "MinI", std::numeric_limits::max(), minIJKLabel, "", "", "" ); - CAF_PDM_InitField( &minJ, "MinJ", std::numeric_limits::max(), "", "", "", "" ); + CAF_PDM_InitField( &minI, "MinI", std::numeric_limits::max(), minIJKLabel ); + CAF_PDM_InitField( &minJ, "MinJ", std::numeric_limits::max(), "" ); minJ.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); - CAF_PDM_InitField( &minK, "MinK", std::numeric_limits::max(), "", "", "", "" ); + CAF_PDM_InitField( &minK, "MinK", std::numeric_limits::max(), "" ); minK.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); QString maxIJKLabel = "Max I, J, K"; - CAF_PDM_InitField( &maxI, "MaxI", -std::numeric_limits::max(), maxIJKLabel, "", "", "" ); - CAF_PDM_InitField( &maxJ, "MaxJ", -std::numeric_limits::max(), "", "", "", "" ); + CAF_PDM_InitField( &maxI, "MaxI", -std::numeric_limits::max(), maxIJKLabel ); + CAF_PDM_InitField( &maxJ, "MaxJ", -std::numeric_limits::max(), "" ); maxJ.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); - CAF_PDM_InitField( &maxK, "MaxK", -std::numeric_limits::max(), "", "", "", "" ); + CAF_PDM_InitField( &maxK, "MaxK", -std::numeric_limits::max(), "" ); maxK.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); - CAF_PDM_InitFieldNoDefault( &exportFaults, "ExportFaults", "Export Fault Data", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &exportFaults, "ExportFaults", "Export Fault Data" ); exportFaults = EXPORT_TO_SINGLE_SEPARATE_FILE; - CAF_PDM_InitField( &exportFaultsFilename, "ExportFaultsFilename", QString(), "Faults File Name", "", "", "" ); + CAF_PDM_InitField( &exportFaultsFilename, "ExportFaultsFilename", QString(), "Faults File Name" ); exportFaultsFilename.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); QString ijkLabel = "Cell Count I, J, K"; - CAF_PDM_InitField( &refinementCountI, "RefinementCountI", 1, ijkLabel, "", "", "" ); - CAF_PDM_InitField( &refinementCountJ, "RefinementCountJ", 1, "", "", "", "" ); - CAF_PDM_InitField( &refinementCountK, "RefinementCountK", 1, "", "", "", "" ); + CAF_PDM_InitField( &refinementCountI, "RefinementCountI", 1, ijkLabel ); + CAF_PDM_InitField( &refinementCountJ, "RefinementCountJ", 1, "" ); + CAF_PDM_InitField( &refinementCountK, "RefinementCountK", 1, "" ); - CAF_PDM_InitFieldNoDefault( &exportParameters, "ExportParams", "Export Parameters", "", "", "" ); - CAF_PDM_InitField( &exportParametersFilename, "ExportParamsFilename", QString(), "File Name", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &exportParameters, "ExportParams", "Export Parameters" ); + CAF_PDM_InitField( &exportParametersFilename, "ExportParamsFilename", QString(), "File Name" ); exportParametersFilename.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &selectedKeywords, "ExportMainKeywords", "Keywords to Export", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &selectedKeywords, "ExportMainKeywords", "Keywords to Export" ); exportGridFilename = defaultGridFileName(); exportParametersFilename = defaultResultsFileName(); @@ -436,8 +436,7 @@ void RicExportEclipseSectorModelUi::fieldChangedByUi( const caf::PdmFieldHandle* /// //-------------------------------------------------------------------------------------------------- QList - RicExportEclipseSectorModelUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) + RicExportEclipseSectorModelUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; if ( fieldNeedingOptions == &selectedKeywords ) diff --git a/ApplicationLibCode/Commands/ExportCommands/RicExportEclipseSectorModelUi.h b/ApplicationLibCode/Commands/ExportCommands/RicExportEclipseSectorModelUi.h index 49c077fea8..5661b43171 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicExportEclipseSectorModelUi.h +++ b/ApplicationLibCode/Commands/ExportCommands/RicExportEclipseSectorModelUi.h @@ -106,8 +106,7 @@ class RicExportEclipseSectorModelUi : public caf::PdmObject 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; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; static std::set mainKeywords(); QString defaultFolder() const; diff --git a/ApplicationLibCode/Commands/ExportCommands/RicExportFaultsFeature.h b/ApplicationLibCode/Commands/ExportCommands/RicExportFaultsFeature.h index 19350bec71..f998d1fdd2 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicExportFaultsFeature.h +++ b/ApplicationLibCode/Commands/ExportCommands/RicExportFaultsFeature.h @@ -35,7 +35,6 @@ class RicExportFaultsFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/ExportCommands/RicExportLgrUi.cpp b/ApplicationLibCode/Commands/ExportCommands/RicExportLgrUi.cpp index 05541d25ff..9abd37c15e 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicExportLgrUi.cpp +++ b/ApplicationLibCode/Commands/ExportCommands/RicExportLgrUi.cpp @@ -50,27 +50,27 @@ void Lgr::SplitTypeEnum::setUp() //-------------------------------------------------------------------------------------------------- RicExportLgrUi::RicExportLgrUi() { - CAF_PDM_InitObject( "Export CARFIN", "", "", "" ); + CAF_PDM_InitObject( "Export CARFIN" ); - CAF_PDM_InitFieldNoDefault( &m_exportFolder, "ExportFolder", "Export Folder", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_exportFolder, "ExportFolder", "Export Folder" ); m_exportFolder.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_caseToApply, "CaseToApply", "Source Case", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_timeStep, "TimeStepIndex", "Time Step", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_caseToApply, "CaseToApply", "Source Case" ); + CAF_PDM_InitFieldNoDefault( &m_timeStep, "TimeStepIndex", "Time Step" ); - CAF_PDM_InitField( &m_includePerforations, "IncludePerforations", true, "Perforations", "", "", "" ); - CAF_PDM_InitField( &m_includeFractures, "IncludeFractures", true, "Fractures", "", "", "" ); - CAF_PDM_InitField( &m_includeFishbones, "IncludeFishbones", true, "Fishbones", "", "", "" ); + CAF_PDM_InitField( &m_includePerforations, "IncludePerforations", true, "Perforations" ); + CAF_PDM_InitField( &m_includeFractures, "IncludeFractures", true, "Fractures" ); + CAF_PDM_InitField( &m_includeFishbones, "IncludeFishbones", true, "Fishbones" ); QString ijkLabel = "Cell Count I, J, K"; - CAF_PDM_InitField( &m_cellCountI, "CellCountI", 2, ijkLabel, "", "", "" ); - CAF_PDM_InitField( &m_cellCountJ, "CellCountJ", 2, "", "", "", "" ); - CAF_PDM_InitField( &m_cellCountK, "CellCountK", 2, "", "", "", "" ); + CAF_PDM_InitField( &m_cellCountI, "CellCountI", 2, ijkLabel ); + CAF_PDM_InitField( &m_cellCountJ, "CellCountJ", 2, "" ); + CAF_PDM_InitField( &m_cellCountK, "CellCountK", 2, "" ); m_cellCountJ.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); m_cellCountK.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); - CAF_PDM_InitField( &m_splitType, "SplitType", Lgr::SplitTypeEnum(), "Split Type", "", "", "" ); + CAF_PDM_InitField( &m_splitType, "SplitType", Lgr::SplitTypeEnum(), "Split Type" ); } //-------------------------------------------------------------------------------------------------- @@ -188,8 +188,7 @@ void RicExportLgrUi::setDefaultValuesFromCase() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RicExportLgrUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RicExportLgrUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; diff --git a/ApplicationLibCode/Commands/ExportCommands/RicExportLgrUi.h b/ApplicationLibCode/Commands/ExportCommands/RicExportLgrUi.h index 7ce9b59dfe..db93180ef7 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicExportLgrUi.h +++ b/ApplicationLibCode/Commands/ExportCommands/RicExportLgrUi.h @@ -66,8 +66,7 @@ class RicExportLgrUi : public caf::PdmObject private: void setDefaultValuesFromCase(); - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineEditorAttribute( const caf::PdmFieldHandle* field, diff --git a/ApplicationLibCode/Commands/ExportCommands/RicExportToLasFileFeature.cpp b/ApplicationLibCode/Commands/ExportCommands/RicExportToLasFileFeature.cpp index 61c6949ea2..70d8b30b7d 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicExportToLasFileFeature.cpp +++ b/ApplicationLibCode/Commands/ExportCommands/RicExportToLasFileFeature.cpp @@ -52,14 +52,13 @@ std::vector RicExportToLasFileFeature::exportToLasFiles( const QString& bool convertCurveUnits ) { std::vector allCurves; - std::vector plots = plotWindow->visiblePlots(); + auto plots = plotWindow->visiblePlots(); - for ( RimPlot* plot : plots ) + for ( auto plot : plots ) { - RimWellLogTrack* track = dynamic_cast( plot ); - if ( track ) + if ( plot ) { - std::vector curves = track->visibleCurves(); + std::vector curves = plot->visibleCurves(); allCurves.insert( allCurves.end(), curves.begin(), curves.end() ); } } diff --git a/ApplicationLibCode/Commands/ExportCommands/RicExportToLasFileFeature.h b/ApplicationLibCode/Commands/ExportCommands/RicExportToLasFileFeature.h index c14b304e0f..ce19639d20 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicExportToLasFileFeature.h +++ b/ApplicationLibCode/Commands/ExportCommands/RicExportToLasFileFeature.h @@ -56,7 +56,6 @@ class RicExportToLasFileFeature : public caf::CmdFeature bool convertCurveUnits ); protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/ExportCommands/RicExportToLasFileResampleUi.cpp b/ApplicationLibCode/Commands/ExportCommands/RicExportToLasFileResampleUi.cpp index 1490b1a4f6..d7a607ef5d 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicExportToLasFileResampleUi.cpp +++ b/ApplicationLibCode/Commands/ExportCommands/RicExportToLasFileResampleUi.cpp @@ -45,9 +45,9 @@ CAF_PDM_SOURCE_INIT( RicExportToLasFileObj, "RicExportToLasFileObj" ); //-------------------------------------------------------------------------------------------------- RicExportToLasFileObj::RicExportToLasFileObj( void ) { - CAF_PDM_InitObject( "RicExportToLasFileObj", "", "", "" ); + CAF_PDM_InitObject( "RicExportToLasFileObj" ); - CAF_PDM_InitField( &tvdrkbOffset, "tvdrkbOffset", QString( "" ), "TVDRKB offset (RKB - MSL) [m]", "", "", "" ); + CAF_PDM_InitField( &tvdrkbOffset, "tvdrkbOffset", QString( "" ), "TVDRKB offset (RKB - MSL) [m]" ); } CAF_PDM_SOURCE_INIT( RicExportToLasFileResampleUi, "RicExportToLasFileResampleUi" ); @@ -58,23 +58,23 @@ CAF_PDM_SOURCE_INIT( RicExportToLasFileResampleUi, "RicExportToLasFileResampleUi RicExportToLasFileResampleUi::RicExportToLasFileResampleUi( void ) : m_enableCurveUnitConversion( false ) { - CAF_PDM_InitObject( "Resample LAS curves for export", "", "", "" ); + CAF_PDM_InitObject( "Resample LAS curves for export" ); - CAF_PDM_InitField( &exportFolder, "ExportFolder", QString(), "Export Folder", "", "", "" ); + CAF_PDM_InitField( &exportFolder, "ExportFolder", QString(), "Export Folder" ); exportFolder.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &filePrefix, "FilePrefix", QString( "" ), "File Prefix", "", "", "" ); - CAF_PDM_InitField( &capitalizeFileName, "CapitalizeFileName", false, "Capitalize File Name", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &curveUnitConversion, "CurveUnitConversion", "Curve Units", "", "", "" ); + CAF_PDM_InitField( &filePrefix, "FilePrefix", QString( "" ), "File Prefix" ); + CAF_PDM_InitField( &capitalizeFileName, "CapitalizeFileName", false, "Capitalize File Name" ); + CAF_PDM_InitFieldNoDefault( &curveUnitConversion, "CurveUnitConversion", "Curve Units" ); - CAF_PDM_InitField( &activateResample, "ActivateResample", false, "Resample Curve Data", "", "", "" ); + CAF_PDM_InitField( &activateResample, "ActivateResample", false, "Resample Curve Data" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &activateResample ); - CAF_PDM_InitField( &resampleInterval, "ResampleInterval", 1.0, "Resample Interval [m]", "", "", "" ); + CAF_PDM_InitField( &resampleInterval, "ResampleInterval", 1.0, "Resample Interval [m]" ); - CAF_PDM_InitField( &exportTvdrkb, "ExportTvdrkb", false, "Export TVDRKB", "", "", "" ); + CAF_PDM_InitField( &exportTvdrkb, "ExportTvdrkb", false, "Export TVDRKB" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &exportTvdrkb ); - CAF_PDM_InitFieldNoDefault( &m_tvdrkbOffsets, "tvdrkbOffsets", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_tvdrkbOffsets, "tvdrkbOffsets", "" ); updateFieldVisibility(); } @@ -84,7 +84,7 @@ RicExportToLasFileResampleUi::RicExportToLasFileResampleUi( void ) //-------------------------------------------------------------------------------------------------- RicExportToLasFileResampleUi::~RicExportToLasFileResampleUi() { - m_tvdrkbOffsets.deleteAllChildObjects(); + m_tvdrkbOffsets.deleteChildren(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/ExportCommands/RicExportWellPathsUi.cpp b/ApplicationLibCode/Commands/ExportCommands/RicExportWellPathsUi.cpp index ba741a8085..978da4f46c 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicExportWellPathsUi.cpp +++ b/ApplicationLibCode/Commands/ExportCommands/RicExportWellPathsUi.cpp @@ -34,12 +34,12 @@ CAF_PDM_SOURCE_INIT( RicExportWellPathsUi, "RicExportWellPathsUi" ); //-------------------------------------------------------------------------------------------------- RicExportWellPathsUi::RicExportWellPathsUi() { - CAF_PDM_InitObject( "Resample LAS curves for export", "", "", "" ); + CAF_PDM_InitObject( "Resample LAS curves for export" ); - CAF_PDM_InitField( &m_exportFolder, "ExportFolder", QString(), "Export Folder", "", "", "" ); + CAF_PDM_InitField( &m_exportFolder, "ExportFolder", QString(), "Export Folder" ); m_exportFolder.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_mdStepSize, "MdStepSize", 5.0, "MD Step Size", "", "", "" ); + CAF_PDM_InitField( &m_mdStepSize, "MdStepSize", 5.0, "MD Step Size" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/ExportCommands/RicSaveEclipseInputPropertyFeature.h b/ApplicationLibCode/Commands/ExportCommands/RicSaveEclipseInputPropertyFeature.h index a37fde741d..5b2fed9b9f 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicSaveEclipseInputPropertyFeature.h +++ b/ApplicationLibCode/Commands/ExportCommands/RicSaveEclipseInputPropertyFeature.h @@ -31,7 +31,6 @@ class RicSaveEclipseInputPropertyFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/ExportCommands/RicSaveEclipseInputVisibleCellsUi.cpp b/ApplicationLibCode/Commands/ExportCommands/RicSaveEclipseInputVisibleCellsUi.cpp index ece728d1d8..b557f5d02f 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicSaveEclipseInputVisibleCellsUi.cpp +++ b/ApplicationLibCode/Commands/ExportCommands/RicSaveEclipseInputVisibleCellsUi.cpp @@ -45,14 +45,14 @@ CAF_PDM_SOURCE_INIT( RicSaveEclipseInputVisibleCellsUi, "RicSaveEclipseInputVisi RicSaveEclipseInputVisibleCellsUi::RicSaveEclipseInputVisibleCellsUi() : exportFilenameManuallyChanged( false ) { - CAF_PDM_InitObject( "Export Visible Cells FLUXNUM/MULTNUM/ACTNUM", "", "", "" ); + CAF_PDM_InitObject( "Export Visible Cells FLUXNUM/MULTNUM/ACTNUM" ); - CAF_PDM_InitField( &exportFilename, "ExportFilename", QString(), "Export Filename", "", "", "" ); + CAF_PDM_InitField( &exportFilename, "ExportFilename", QString(), "Export Filename" ); exportFilename.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &exportKeyword, "ExportKeyword", "Export Keyword", "", "", "" ); - CAF_PDM_InitField( &visibleActiveCellsValue, "VisibleActiveCellsValue", 1, "Visible Active Cells Value", "", "", "" ); - CAF_PDM_InitField( &hiddenActiveCellsValue, "HiddenActiveCellsValue", 0, "Hidden Active Cells Value", "", "", "" ); - CAF_PDM_InitField( &inactiveCellsValue, "InactiveCellsValue", 0, "Inactive Cells Value", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &exportKeyword, "ExportKeyword", "Export Keyword" ); + CAF_PDM_InitField( &visibleActiveCellsValue, "VisibleActiveCellsValue", 1, "Visible Active Cells Value" ); + CAF_PDM_InitField( &hiddenActiveCellsValue, "HiddenActiveCellsValue", 0, "Hidden Active Cells Value" ); + CAF_PDM_InitField( &inactiveCellsValue, "InactiveCellsValue", 0, "Inactive Cells Value" ); exportFilename = getDefaultExportPath(); } diff --git a/ApplicationLibCode/Commands/ExportCommands/RicSaveEclipseResultAsInputPropertyFeature.h b/ApplicationLibCode/Commands/ExportCommands/RicSaveEclipseResultAsInputPropertyFeature.h index 06336a3567..3fbe1c0c51 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicSaveEclipseResultAsInputPropertyFeature.h +++ b/ApplicationLibCode/Commands/ExportCommands/RicSaveEclipseResultAsInputPropertyFeature.h @@ -32,7 +32,6 @@ class RicSaveEclipseResultAsInputPropertyFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/ExportCommands/RicSnapshotAllPlotsToFileFeature.h b/ApplicationLibCode/Commands/ExportCommands/RicSnapshotAllPlotsToFileFeature.h index 158e8f7bc6..4fc2a47035 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicSnapshotAllPlotsToFileFeature.h +++ b/ApplicationLibCode/Commands/ExportCommands/RicSnapshotAllPlotsToFileFeature.h @@ -39,7 +39,6 @@ class RicSnapshotAllPlotsToFileFeature : public caf::CmdFeature const QString& preferredFileSuffix = ".png" ); protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.h b/ApplicationLibCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.h index 07e2f81dcb..837ce6f702 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.h +++ b/ApplicationLibCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.h @@ -35,7 +35,6 @@ class RicSnapshotAllViewsToFileFeature : public caf::CmdFeature int viewId = -1 ); protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/ExportCommands/RicSnapshotViewToClipboardFeature.h b/ApplicationLibCode/Commands/ExportCommands/RicSnapshotViewToClipboardFeature.h index 1c5eb770c9..997ca50e08 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicSnapshotViewToClipboardFeature.h +++ b/ApplicationLibCode/Commands/ExportCommands/RicSnapshotViewToClipboardFeature.h @@ -36,7 +36,6 @@ class RicSnapshotViewToClipboardFeature : public caf::CmdFeature static QString text(); protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/ExportCommands/RicSnapshotViewToFileFeature.cpp b/ApplicationLibCode/Commands/ExportCommands/RicSnapshotViewToFileFeature.cpp index 387357d4ad..031dc372e5 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicSnapshotViewToFileFeature.cpp +++ b/ApplicationLibCode/Commands/ExportCommands/RicSnapshotViewToFileFeature.cpp @@ -51,7 +51,7 @@ CAF_CMD_SOURCE_INIT( RicSnapshotViewToFileFeature, "RicSnapshotViewToFileFeature //-------------------------------------------------------------------------------------------------- void RicSnapshotViewToFileFeature::saveSnapshotAs( const QString& fileName, RimViewWindow* viewWindow ) { - RimPlotWindow* plotWindow = dynamic_cast( viewWindow ); + auto* plotWindow = dynamic_cast( viewWindow ); if ( plotWindow && fileName.endsWith( ".pdf" ) ) { savePlotPdfReportAs( fileName, plotWindow ); @@ -88,46 +88,35 @@ void RicSnapshotViewToFileFeature::savePlotPdfReportAs( const QString& fileName, { if ( !plot || !plot->viewWidget() ) return; + auto viewWidget = plot->viewWidget(); + RiaPlotWindowRedrawScheduler::instance()->performScheduledUpdatesAndReplots(); QCoreApplication::processEvents(); QFile pdfFile( fileName ); if ( pdfFile.open( QIODevice::WriteOnly ) ) { - int resolution = RiaGuiApplication::applicationResolution(); - int pageWidth = plot->pageLayout().fullRectPixels( resolution ).width(); - int widgetWidth = plot->viewWidget()->width(); - int deltaWidth = widgetWidth - pageWidth; - - while ( std::abs( deltaWidth ) > 1 ) - { - int newResolution = resolution + deltaWidth / std::abs( deltaWidth ); - pageWidth = plot->pageLayout().fullRectPixels( resolution ).width(); - int newDeltaWidth = widgetWidth - pageWidth; - if ( std::abs( newDeltaWidth ) > std::abs( deltaWidth ) ) break; + int resolution = RiaGuiApplication::applicationResolution(); - resolution = newResolution; - deltaWidth = newDeltaWidth; - } QPdfWriter pdfPrinter( fileName ); pdfPrinter.setPageLayout( plot->pageLayout() ); pdfPrinter.setCreator( QCoreApplication::applicationName() ); pdfPrinter.setResolution( resolution ); - QRect widgetRect = plot->viewWidget()->contentsRect(); + QRect widgetRect = viewWidget->contentsRect(); - RimMultiPlot* multiPlot = dynamic_cast( plot ); + auto* multiPlot = dynamic_cast( plot ); if ( multiPlot && multiPlot->previewModeEnabled() ) { QRect pageRect = pdfPrinter.pageLayout().fullRectPixels( resolution ); - plot->viewWidget()->resize( pageRect.size() ); + viewWidget->resize( pageRect.size() ); plot->renderWindowContent( &pdfPrinter ); - plot->viewWidget()->resize( widgetRect.size() ); + viewWidget->resize( widgetRect.size() ); } else { QRect pageRect = pdfPrinter.pageLayout().paintRectPixels( resolution ); - plot->viewWidget()->resize( pageRect.size() ); + viewWidget->resize( pageRect.size() ); plot->renderWindowContent( &pdfPrinter ); - plot->viewWidget()->resize( widgetRect.size() ); + viewWidget->resize( widgetRect.size() ); } } else @@ -142,7 +131,7 @@ void RicSnapshotViewToFileFeature::savePlotPdfReportAs( const QString& fileName, void RicSnapshotViewToFileFeature::saveViewWindowToFile( RimViewWindow* viewWindow, const QString& defaultFileBaseName /*= "image" */ ) { - RimPlotWindow* plotWindow = dynamic_cast( viewWindow ); + auto* plotWindow = dynamic_cast( viewWindow ); QString fileName = generateSaveFileName( defaultFileBaseName, plotWindow != nullptr ); if ( !fileName.isEmpty() ) diff --git a/ApplicationLibCode/Commands/ExportCommands/RicSnapshotViewToFileFeature.h b/ApplicationLibCode/Commands/ExportCommands/RicSnapshotViewToFileFeature.h index 9466a08040..23db2b0db7 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicSnapshotViewToFileFeature.h +++ b/ApplicationLibCode/Commands/ExportCommands/RicSnapshotViewToFileFeature.h @@ -45,7 +45,6 @@ class RicSnapshotViewToFileFeature : public caf::CmdFeature static QString text(); protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/ExportCommands/RicSnapshotViewToPdfFeature.cpp b/ApplicationLibCode/Commands/ExportCommands/RicSnapshotViewToPdfFeature.cpp index 38053bbce0..a7f954a735 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicSnapshotViewToPdfFeature.cpp +++ b/ApplicationLibCode/Commands/ExportCommands/RicSnapshotViewToPdfFeature.cpp @@ -21,6 +21,7 @@ #include "RiaGuiApplication.h" #include "RiaLogging.h" #include "RiaPreferences.h" +#include "RiaPreferencesSystem.h" #include "RicSnapshotFilenameGenerator.h" #include "RicSnapshotViewToFileFeature.h" @@ -58,16 +59,25 @@ void RicSnapshotViewToPdfFeature::onActionTriggered( bool isChecked ) return; } - RimPlotWindow* plotWindow = dynamic_cast( viewWindow ); + auto* plotWindow = dynamic_cast( viewWindow ); if ( plotWindow ) { QString fileExtension = "pdf"; QString defaultFileName = RicSnapshotFilenameGenerator::generateSnapshotFileName( viewWindow ); - QString fileName = RicSnapshotViewToFileFeature::generateSaveFileName( defaultFileName, true, fileExtension ); + QString fileName; + if ( RiaPreferencesSystem::current()->showPdfExportDialog() ) + { + fileName = RicSnapshotViewToFileFeature::generateSaveFileName( defaultFileName, true, fileExtension ); + } + else + { + fileName = defaultFileName + "." + fileExtension; + } + if ( !fileName.isEmpty() ) { - if ( plotWindow && fileName.endsWith( "PDF", Qt::CaseInsensitive ) ) + if ( plotWindow && fileName.endsWith( fileExtension, Qt::CaseInsensitive ) ) { RicSnapshotViewToFileFeature::savePlotPdfReportAs( fileName, plotWindow ); diff --git a/ApplicationLibCode/Commands/FlowCommands/RicAddStoredFlowCharacteristicsPlotFeature.h b/ApplicationLibCode/Commands/FlowCommands/RicAddStoredFlowCharacteristicsPlotFeature.h index ad8708a15a..0b06865f89 100644 --- a/ApplicationLibCode/Commands/FlowCommands/RicAddStoredFlowCharacteristicsPlotFeature.h +++ b/ApplicationLibCode/Commands/FlowCommands/RicAddStoredFlowCharacteristicsPlotFeature.h @@ -28,7 +28,6 @@ class RicAddStoredFlowCharacteristicsPlotFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/FlowCommands/RicAddStoredWellAllocationPlotFeature.h b/ApplicationLibCode/Commands/FlowCommands/RicAddStoredWellAllocationPlotFeature.h index dbe16e3e65..9fb82f09ad 100644 --- a/ApplicationLibCode/Commands/FlowCommands/RicAddStoredWellAllocationPlotFeature.h +++ b/ApplicationLibCode/Commands/FlowCommands/RicAddStoredWellAllocationPlotFeature.h @@ -28,7 +28,6 @@ class RicAddStoredWellAllocationPlotFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/FlowCommands/RicPlotProductionRateFeature.cpp b/ApplicationLibCode/Commands/FlowCommands/RicPlotProductionRateFeature.cpp index c5239638d9..aba7521954 100644 --- a/ApplicationLibCode/Commands/FlowCommands/RicPlotProductionRateFeature.cpp +++ b/ApplicationLibCode/Commands/FlowCommands/RicPlotProductionRateFeature.cpp @@ -20,6 +20,8 @@ #include "RiaGuiApplication.h" +#include "PlotBuilderCommands/RicSummaryPlotBuilder.h" + #include "RifEclipseSummaryAddress.h" #include "RifSummaryReaderInterface.h" @@ -37,8 +39,8 @@ #include "RimSummaryCaseMainCollection.h" #include "RimSummaryCurve.h" #include "RimSummaryCurveAppearanceCalculator.h" +#include "RimSummaryMultiPlot.h" #include "RimSummaryPlot.h" -#include "RimSummaryPlotCollection.h" #include "RiuPlotMainWindow.h" @@ -80,8 +82,6 @@ void RicPlotProductionRateFeature::onActionTriggered( bool isChecked ) project->activeOilField() ? project->activeOilField()->summaryCaseMainCollection() : nullptr; if ( !sumCaseColl ) return; - RimSummaryPlotCollection* summaryPlotColl = RiaSummaryTools::summaryPlotCollection(); - std::vector collection; caf::SelectionManager::instance()->objectsByType( &collection ); @@ -100,7 +100,9 @@ void RicPlotProductionRateFeature::onActionTriggered( bool isChecked ) } description += well->name(); - RimSummaryPlot* plot = summaryPlotColl->createNamedSummaryPlot( description ); + RimSummaryPlot* plot = new RimSummaryPlot(); + plot->setUiName( description ); + RimSummaryMultiPlot* multiPlot = RicSummaryPlotBuilder::createAndAppendSingleSummaryMultiPlot( plot ); if ( RimSimWellInViewTools::isInjector( well ) ) { @@ -210,7 +212,7 @@ void RicPlotProductionRateFeature::onActionTriggered( bool isChecked ) } } - summaryPlotColl->updateConnectedEditors(); + multiPlot->updateConnectedEditors(); plot->loadDataAndUpdate(); summaryPlotToSelect = plot; @@ -278,7 +280,7 @@ RimSummaryCurve* RicPlotProductionRateFeature::addSummaryCurve( RimSummaryPlot* newCurve->setSummaryCaseY( gridSummaryCase ); newCurve->setSummaryAddressYAndApplyInterpolation( addr ); newCurve->setColor( color ); - newCurve->setLeftOrRightAxisY( plotAxis ); + newCurve->setLeftOrRightAxisY( RiuPlotAxis( plotAxis ) ); newCurve->loadDataAndUpdate( true ); return newCurve; diff --git a/ApplicationLibCode/Commands/FlowCommands/RicPlotProductionRateFeature.h b/ApplicationLibCode/Commands/FlowCommands/RicPlotProductionRateFeature.h index adcccf5ca7..ffc7b517ab 100644 --- a/ApplicationLibCode/Commands/FlowCommands/RicPlotProductionRateFeature.h +++ b/ApplicationLibCode/Commands/FlowCommands/RicPlotProductionRateFeature.h @@ -20,7 +20,7 @@ #include "cafCmdFeature.h" -#include "RiaDefines.h" +#include "RiaPlotDefines.h" #include "RimFlowDiagSolution.h" class RimGridSummaryCase; @@ -36,7 +36,6 @@ class RicPlotProductionRateFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/FlowCommands/RicSelectViewUI.cpp b/ApplicationLibCode/Commands/FlowCommands/RicSelectViewUI.cpp index 76b8272145..6636b97e3c 100644 --- a/ApplicationLibCode/Commands/FlowCommands/RicSelectViewUI.cpp +++ b/ApplicationLibCode/Commands/FlowCommands/RicSelectViewUI.cpp @@ -28,11 +28,11 @@ CAF_PDM_SOURCE_INIT( RicSelectViewUI, "RicSelectViewUI" ); //-------------------------------------------------------------------------------------------------- RicSelectViewUI::RicSelectViewUI() { - CAF_PDM_InitObject( "RicSelectViewUI", "", "", "" ); + CAF_PDM_InitObject( "RicSelectViewUI" ); - CAF_PDM_InitFieldNoDefault( &m_selectedView, "MasterView", "Select view", "", "", "" ); - CAF_PDM_InitField( &m_createNewView, "CreateNewView", true, "Create New View", "", "", "" ); - CAF_PDM_InitField( &m_newViewName, "NewViewName", QString( "ShowContributingWells" ), "New View Name", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_selectedView, "MasterView", "Select view" ); + CAF_PDM_InitField( &m_createNewView, "CreateNewView", true, "Create New View" ); + CAF_PDM_InitField( &m_newViewName, "NewViewName", QString( "ShowContributingWells" ), "New View Name" ); m_currentView = nullptr; m_currentCase = nullptr; @@ -93,8 +93,7 @@ QString RicSelectViewUI::newViewName() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RicSelectViewUI::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RicSelectViewUI::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; diff --git a/ApplicationLibCode/Commands/FlowCommands/RicSelectViewUI.h b/ApplicationLibCode/Commands/FlowCommands/RicSelectViewUI.h index ad1d3570e9..bdafa28675 100644 --- a/ApplicationLibCode/Commands/FlowCommands/RicSelectViewUI.h +++ b/ApplicationLibCode/Commands/FlowCommands/RicSelectViewUI.h @@ -43,8 +43,7 @@ class RicSelectViewUI : public caf::PdmObject bool createNewView() const; QString newViewName() const; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; protected: void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; diff --git a/ApplicationLibCode/Commands/FlowCommands/RicShowContributingWellsFeature.h b/ApplicationLibCode/Commands/FlowCommands/RicShowContributingWellsFeature.h index 4f245e75aa..58bf8f5cc5 100644 --- a/ApplicationLibCode/Commands/FlowCommands/RicShowContributingWellsFeature.h +++ b/ApplicationLibCode/Commands/FlowCommands/RicShowContributingWellsFeature.h @@ -28,7 +28,6 @@ class RicShowContributingWellsFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/FlowCommands/RicShowCumulativePhasePlotFeature.h b/ApplicationLibCode/Commands/FlowCommands/RicShowCumulativePhasePlotFeature.h index 1aa438fe9a..4cd97eafea 100644 --- a/ApplicationLibCode/Commands/FlowCommands/RicShowCumulativePhasePlotFeature.h +++ b/ApplicationLibCode/Commands/FlowCommands/RicShowCumulativePhasePlotFeature.h @@ -32,7 +32,6 @@ class RicShowCumulativePhasePlotFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/FlowCommands/RicShowFlowCharacteristicsPlotFeature.h b/ApplicationLibCode/Commands/FlowCommands/RicShowFlowCharacteristicsPlotFeature.h index 17bb873ce6..496641b964 100644 --- a/ApplicationLibCode/Commands/FlowCommands/RicShowFlowCharacteristicsPlotFeature.h +++ b/ApplicationLibCode/Commands/FlowCommands/RicShowFlowCharacteristicsPlotFeature.h @@ -28,7 +28,6 @@ class RicShowFlowCharacteristicsPlotFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/FlowCommands/RicShowTotalAllocationDataFeature.h b/ApplicationLibCode/Commands/FlowCommands/RicShowTotalAllocationDataFeature.h index 33d48a59aa..6a67ca41a0 100644 --- a/ApplicationLibCode/Commands/FlowCommands/RicShowTotalAllocationDataFeature.h +++ b/ApplicationLibCode/Commands/FlowCommands/RicShowTotalAllocationDataFeature.h @@ -32,7 +32,6 @@ class RicShowTotalAllocationDataFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/FlowCommands/RicShowWellAllocationPlotFeature.h b/ApplicationLibCode/Commands/FlowCommands/RicShowWellAllocationPlotFeature.h index a098e5a7b4..ab138f6d35 100644 --- a/ApplicationLibCode/Commands/FlowCommands/RicShowWellAllocationPlotFeature.h +++ b/ApplicationLibCode/Commands/FlowCommands/RicShowWellAllocationPlotFeature.h @@ -28,7 +28,6 @@ class RicShowWellAllocationPlotFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/FractureCommands/RicCreateMultipleFracturesFeature.cpp b/ApplicationLibCode/Commands/FractureCommands/RicCreateMultipleFracturesFeature.cpp index d63a732990..fbd439c327 100644 --- a/ApplicationLibCode/Commands/FractureCommands/RicCreateMultipleFracturesFeature.cpp +++ b/ApplicationLibCode/Commands/FractureCommands/RicCreateMultipleFracturesFeature.cpp @@ -107,6 +107,8 @@ void RicCreateMultipleFracturesFeature::slotAppendFractures() RiuCreateMultipleFractionsUi* multipleFractionsUi = this->multipleFractionsUi(); if ( !multipleFractionsUi ) return; + std::set fractureCollectionToUpdate; + auto items = multipleFractionsUi->locationsForNewFractures(); for ( auto item : items ) { @@ -127,6 +129,7 @@ void RicCreateMultipleFracturesFeature::slotAppendFractures() RimWellPathFracture* fracture = new RimWellPathFracture(); fractureCollection->addFracture( fracture ); + fractureCollectionToUpdate.insert( fractureCollection ); fracture->setFractureUnit( item.wellPath->unitSystem() ); fracture->setMeasuredDepth( item.measuredDepth ); @@ -145,7 +148,11 @@ void RicCreateMultipleFracturesFeature::slotAppendFractures() RiaApplication* app = RiaApplication::instance(); RimProject* proj = app->project(); - proj->updateConnectedEditors(); + for ( auto coll : fractureCollectionToUpdate ) + { + coll->updateConnectedEditors(); + } + proj->reloadCompletionTypeResultsInAllViews(); } diff --git a/ApplicationLibCode/Commands/FractureCommands/RicCreateMultipleFracturesOptionItemUi.cpp b/ApplicationLibCode/Commands/FractureCommands/RicCreateMultipleFracturesOptionItemUi.cpp index de0187c052..861d1775c7 100644 --- a/ApplicationLibCode/Commands/FractureCommands/RicCreateMultipleFracturesOptionItemUi.cpp +++ b/ApplicationLibCode/Commands/FractureCommands/RicCreateMultipleFracturesOptionItemUi.cpp @@ -31,10 +31,10 @@ CAF_PDM_SOURCE_INIT( RicCreateMultipleFracturesOptionItemUi, "RiuMultipleFractio //-------------------------------------------------------------------------------------------------- RicCreateMultipleFracturesOptionItemUi::RicCreateMultipleFracturesOptionItemUi() { - CAF_PDM_InitField( &m_topKOneBased, "TopKLayer", 1, "Top K Layer", "", "", "" ); - CAF_PDM_InitField( &m_baseKOneBased, "BaseKLayer", 1, "Base K Layer", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_fractureTemplate, "Template", "Template", "", "", "" ); - CAF_PDM_InitField( &m_minSpacing, "MinSpacing", 300.0, "Spacing", "", "", "" ); + CAF_PDM_InitField( &m_topKOneBased, "TopKLayer", 1, "Top K Layer" ); + CAF_PDM_InitField( &m_baseKOneBased, "BaseKLayer", 1, "Base K Layer" ); + CAF_PDM_InitFieldNoDefault( &m_fractureTemplate, "Template", "Template" ); + CAF_PDM_InitField( &m_minSpacing, "MinSpacing", 300.0, "Spacing" ); } //-------------------------------------------------------------------------------------------------- @@ -125,8 +125,7 @@ void RicCreateMultipleFracturesOptionItemUi::fieldChangedByUi( const caf::PdmFie /// //-------------------------------------------------------------------------------------------------- QList - RicCreateMultipleFracturesOptionItemUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) + RicCreateMultipleFracturesOptionItemUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; diff --git a/ApplicationLibCode/Commands/FractureCommands/RicCreateMultipleFracturesOptionItemUi.h b/ApplicationLibCode/Commands/FractureCommands/RicCreateMultipleFracturesOptionItemUi.h index 1b30c54f8f..a84de6247d 100644 --- a/ApplicationLibCode/Commands/FractureCommands/RicCreateMultipleFracturesOptionItemUi.h +++ b/ApplicationLibCode/Commands/FractureCommands/RicCreateMultipleFracturesOptionItemUi.h @@ -46,8 +46,7 @@ class RicCreateMultipleFracturesOptionItemUi : public caf::PdmObject private: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; private: caf::PdmField m_topKOneBased; // Eclipse uses 1-based indexing diff --git a/ApplicationLibCode/Commands/FractureCommands/RicCreateMultipleFracturesUi.cpp b/ApplicationLibCode/Commands/FractureCommands/RicCreateMultipleFracturesUi.cpp index 54f3ebd7f4..c209c000e6 100644 --- a/ApplicationLibCode/Commands/FractureCommands/RicCreateMultipleFracturesUi.cpp +++ b/ApplicationLibCode/Commands/FractureCommands/RicCreateMultipleFracturesUi.cpp @@ -85,17 +85,17 @@ const QString RiuCreateMultipleFractionsUi::REPLACE_FRACTURES_BUTTON_TEXT = "Rep //-------------------------------------------------------------------------------------------------- RiuCreateMultipleFractionsUi::RiuCreateMultipleFractionsUi() { - CAF_PDM_InitFieldNoDefault( &m_sourceCase, "SourceCase", "Case", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_sourceCase, "SourceCase", "Case" ); - CAF_PDM_InitField( &m_minDistanceFromWellTd, "MinDistanceFromWellTd", 10.0, "Min Distance From Well TD", "", "", "" ); - CAF_PDM_InitField( &m_maxFracturesPerWell, "MaxFracturesPerWell", 10, "Max Fractures Per Well", "", "", "" ); + CAF_PDM_InitField( &m_minDistanceFromWellTd, "MinDistanceFromWellTd", 10.0, "Min Distance From Well TD" ); + CAF_PDM_InitField( &m_maxFracturesPerWell, "MaxFracturesPerWell", 10, "Max Fractures Per Well" ); - CAF_PDM_InitFieldNoDefault( &m_options, "Options", "Options", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_options, "Options", "Options" ); m_options.uiCapability()->setUiEditorTypeName( caf::PdmUiTableViewEditor::uiEditorTypeName() ); m_options.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); m_options.uiCapability()->setCustomContextMenuEnabled( true ); - CAF_PDM_InitFieldNoDefault( &m_fractureCreationSummary, "FractureCreationSummary", "Generated Fractures", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_fractureCreationSummary, "FractureCreationSummary", "Generated Fractures" ); m_fractureCreationSummary.registerGetMethod( this, &RiuCreateMultipleFractionsUi::summaryText ); m_fractureCreationSummary.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); m_fractureCreationSummary.uiCapability()->setUiEditorTypeName( caf::PdmUiTextEditor::uiEditorTypeName() ); @@ -127,7 +127,7 @@ void RiuCreateMultipleFractionsUi::setValues( RimEclipseCase* eclipseCase, void RiuCreateMultipleFractionsUi::resetValues() { m_sourceCase = nullptr; - m_options.deleteAllChildObjects(); + m_options.deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -135,7 +135,7 @@ void RiuCreateMultipleFractionsUi::resetValues() //-------------------------------------------------------------------------------------------------- std::vector RiuCreateMultipleFractionsUi::options() const { - return m_options.childObjects(); + return m_options.children(); } //-------------------------------------------------------------------------------------------------- @@ -144,7 +144,7 @@ std::vector RiuCreateMultipleFractionsU void RiuCreateMultipleFractionsUi::insertOptionItem( RicCreateMultipleFracturesOptionItemUi* insertAfterThisObject, RicCreateMultipleFracturesOptionItemUi* objectToInsert ) { - size_t index = m_options.index( insertAfterThisObject ); + size_t index = m_options.indexOf( insertAfterThisObject ); if ( index < m_options.size() - 1 ) { m_options.insert( index + 1, objectToInsert ); @@ -160,7 +160,7 @@ void RiuCreateMultipleFractionsUi::insertOptionItem( RicCreateMultipleFracturesO //-------------------------------------------------------------------------------------------------- void RiuCreateMultipleFractionsUi::deleteOptionItem( RicCreateMultipleFracturesOptionItemUi* optionsItem ) { - m_options.removeChildObject( optionsItem ); + m_options.removeChild( optionsItem ); delete optionsItem; } @@ -169,7 +169,7 @@ void RiuCreateMultipleFractionsUi::deleteOptionItem( RicCreateMultipleFracturesO //-------------------------------------------------------------------------------------------------- void RiuCreateMultipleFractionsUi::clearOptions() { - m_options.deleteAllChildObjects(); + m_options.deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -192,8 +192,7 @@ void RiuCreateMultipleFractionsUi::clearWellPaths() /// //-------------------------------------------------------------------------------------------------- QList - RiuCreateMultipleFractionsUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) + RiuCreateMultipleFractionsUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; diff --git a/ApplicationLibCode/Commands/FractureCommands/RicCreateMultipleFracturesUi.h b/ApplicationLibCode/Commands/FractureCommands/RicCreateMultipleFracturesUi.h index d15790faf6..31b0d84a87 100644 --- a/ApplicationLibCode/Commands/FractureCommands/RicCreateMultipleFracturesUi.h +++ b/ApplicationLibCode/Commands/FractureCommands/RicCreateMultipleFracturesUi.h @@ -91,8 +91,7 @@ class RiuCreateMultipleFractionsUi : public caf::PdmObject void updateButtonsEnableState(); private: - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineCustomContextMenu( const caf::PdmFieldHandle* fieldNeedingMenu, QMenu* menu, QWidget* fieldEditorWidget ) override; void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, diff --git a/ApplicationLibCode/Commands/FractureCommands/RicNewSimWellFractureAtPosFeature.cpp b/ApplicationLibCode/Commands/FractureCommands/RicNewSimWellFractureAtPosFeature.cpp index a9f76af66e..b9b7c74b3d 100644 --- a/ApplicationLibCode/Commands/FractureCommands/RicNewSimWellFractureAtPosFeature.cpp +++ b/ApplicationLibCode/Commands/FractureCommands/RicNewSimWellFractureAtPosFeature.cpp @@ -117,7 +117,7 @@ void RicNewSimWellFractureAtPosFeature::onActionTriggered( bool isChecked ) if ( eclipseCase ) { proj->reloadCompletionTypeResultsForEclipseCase( eclipseCase ); - proj->updateConnectedEditors(); + fractureCollection->updateConnectedEditors(); } Riu3DMainWindowTools::selectAsCurrentItem( fracture ); } diff --git a/ApplicationLibCode/Commands/FractureCommands/RicNewSimWellFractureFeature.cpp b/ApplicationLibCode/Commands/FractureCommands/RicNewSimWellFractureFeature.cpp index 85015a824d..2ada055df6 100644 --- a/ApplicationLibCode/Commands/FractureCommands/RicNewSimWellFractureFeature.cpp +++ b/ApplicationLibCode/Commands/FractureCommands/RicNewSimWellFractureFeature.cpp @@ -101,7 +101,7 @@ void RicNewSimWellFractureFeature::onActionTriggered( bool isChecked ) if ( eclipseCase ) { proj->reloadCompletionTypeResultsForEclipseCase( eclipseCase ); - proj->updateConnectedEditors(); + eclipseWell->simwellFractureCollection()->updateConnectedEditors(); } Riu3DMainWindowTools::selectAsCurrentItem( fracture ); } diff --git a/ApplicationLibCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.cpp b/ApplicationLibCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.cpp index 3831f42c2c..5bb0726c7d 100644 --- a/ApplicationLibCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.cpp +++ b/ApplicationLibCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.cpp @@ -85,7 +85,7 @@ std::vector RicNewStimPlanFractureTemplateFeature: defaultDir, "StimPlan XML File (*.xml);;All files(*.*)" ); - auto templates = createNewTemplatesFromFiles( fileNames.toVector().toStdVector() ); + auto templates = createNewTemplatesFromFiles( std::vector( fileNames.begin(), fileNames.end() ) ); if ( !fileNames.isEmpty() ) { diff --git a/ApplicationLibCode/Commands/FractureCommands/RicNewStimPlanModelFeature.cpp b/ApplicationLibCode/Commands/FractureCommands/RicNewStimPlanModelFeature.cpp index 642d076e21..4ecda0fb69 100644 --- a/ApplicationLibCode/Commands/FractureCommands/RicNewStimPlanModelFeature.cpp +++ b/ApplicationLibCode/Commands/FractureCommands/RicNewStimPlanModelFeature.cpp @@ -86,7 +86,7 @@ RimStimPlanModel* RicNewStimPlanModelFeature::addStimPlanModel( RimWellPath* if ( project ) { project->reloadCompletionTypeResultsInAllViews(); - project->updateAllRequiredEditors(); + stimPlanModelCollection->updateAllRequiredEditors(); } if ( measuredDepth > 0.0 ) diff --git a/ApplicationLibCode/Commands/FractureCommands/RicNewWellPathFractureFeature.cpp b/ApplicationLibCode/Commands/FractureCommands/RicNewWellPathFractureFeature.cpp index a5f84ffe5b..c56b28148e 100644 --- a/ApplicationLibCode/Commands/FractureCommands/RicNewWellPathFractureFeature.cpp +++ b/ApplicationLibCode/Commands/FractureCommands/RicNewWellPathFractureFeature.cpp @@ -101,7 +101,7 @@ RimWellPathFracture* RicNewWellPathFractureFeature::addFracture( gsl::not_nullreloadCompletionTypeResultsInAllViews(); - project->updateAllRequiredEditors(); + fractureCollection->updateAllRequiredEditors(); } Riu3DMainWindowTools::selectAsCurrentItem( fracture ); diff --git a/ApplicationLibCode/Commands/GeoMechCommands/RicGeoMechCopyCaseFeature.h b/ApplicationLibCode/Commands/GeoMechCommands/RicGeoMechCopyCaseFeature.h index e1f315c51b..1bd070e138 100644 --- a/ApplicationLibCode/Commands/GeoMechCommands/RicGeoMechCopyCaseFeature.h +++ b/ApplicationLibCode/Commands/GeoMechCommands/RicGeoMechCopyCaseFeature.h @@ -28,7 +28,6 @@ class RicGeoMechCopyCaseFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/GeoMechCommands/RicGeoMechPropertyFilterInsertExec.cpp b/ApplicationLibCode/Commands/GeoMechCommands/RicGeoMechPropertyFilterInsertExec.cpp index 00157e06cc..6187219de6 100644 --- a/ApplicationLibCode/Commands/GeoMechCommands/RicGeoMechPropertyFilterInsertExec.cpp +++ b/ApplicationLibCode/Commands/GeoMechCommands/RicGeoMechPropertyFilterInsertExec.cpp @@ -59,7 +59,7 @@ void RicGeoMechPropertyFilterInsertExec::redo() RimGeoMechPropertyFilterCollection* propertyFilterCollection = m_propertyFilter->parentContainer(); CVF_ASSERT( propertyFilterCollection ); - size_t index = propertyFilterCollection->propertyFilters.index( m_propertyFilter ); + size_t index = propertyFilterCollection->propertyFilters.indexOf( m_propertyFilter ); CVF_ASSERT( index < propertyFilterCollection->propertyFilters.size() ); RicGeoMechPropertyFilterFeatureImpl::insertPropertyFilter( propertyFilterCollection, index ); diff --git a/ApplicationLibCode/Commands/GeoMechCommands/RicGeoMechPropertyFilterInsertFeature.h b/ApplicationLibCode/Commands/GeoMechCommands/RicGeoMechPropertyFilterInsertFeature.h index a9f4503817..8e910c7329 100644 --- a/ApplicationLibCode/Commands/GeoMechCommands/RicGeoMechPropertyFilterInsertFeature.h +++ b/ApplicationLibCode/Commands/GeoMechCommands/RicGeoMechPropertyFilterInsertFeature.h @@ -29,7 +29,6 @@ class RicGeoMechPropertyFilterInsertFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/GeoMechCommands/RicGeoMechPropertyFilterNewFeature.h b/ApplicationLibCode/Commands/GeoMechCommands/RicGeoMechPropertyFilterNewFeature.h index bd18afa742..34cefe105c 100644 --- a/ApplicationLibCode/Commands/GeoMechCommands/RicGeoMechPropertyFilterNewFeature.h +++ b/ApplicationLibCode/Commands/GeoMechCommands/RicGeoMechPropertyFilterNewFeature.h @@ -29,7 +29,6 @@ class RicGeoMechPropertyFilterNewFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/GeoMechCommands/RicImportGeoMechCaseFeature.h b/ApplicationLibCode/Commands/GeoMechCommands/RicImportGeoMechCaseFeature.h index 98c67fb65f..f40d88af7e 100644 --- a/ApplicationLibCode/Commands/GeoMechCommands/RicImportGeoMechCaseFeature.h +++ b/ApplicationLibCode/Commands/GeoMechCommands/RicImportGeoMechCaseFeature.h @@ -28,7 +28,6 @@ class RicImportGeoMechCaseFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/GeoMechCommands/RicNewFaultReactAssessmentFeature.h b/ApplicationLibCode/Commands/GeoMechCommands/RicNewFaultReactAssessmentFeature.h index 9337e5c3ad..2761f9e364 100644 --- a/ApplicationLibCode/Commands/GeoMechCommands/RicNewFaultReactAssessmentFeature.h +++ b/ApplicationLibCode/Commands/GeoMechCommands/RicNewFaultReactAssessmentFeature.h @@ -32,7 +32,6 @@ class RicNewFaultReactAssessmentFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/GridCrossPlotCommands/RicCreateGridCrossPlotFeature.cpp b/ApplicationLibCode/Commands/GridCrossPlotCommands/RicCreateGridCrossPlotFeature.cpp index d504673a58..6164d3894e 100644 --- a/ApplicationLibCode/Commands/GridCrossPlotCommands/RicCreateGridCrossPlotFeature.cpp +++ b/ApplicationLibCode/Commands/GridCrossPlotCommands/RicCreateGridCrossPlotFeature.cpp @@ -68,8 +68,12 @@ void RicCreateGridCrossPlotFeature::onActionTriggered( bool isChecked ) } else { - // Triggered from context menu: get the selected view - // TODO: get the filter from somewhere + caf::PdmObject* selectedObject = dynamic_cast( caf::SelectionManager::instance()->selectedItem() ); + if ( !selectedObject ) return; + + RimGridView* cellFilterView = nullptr; + selectedObject->firstAncestorOrThisOfType( cellFilterView ); + if ( cellFilterView ) dataSet->setCellFilterView( cellFilterView ); } plot->loadDataAndUpdate(); diff --git a/ApplicationLibCode/Commands/GridCrossPlotCommands/RicSaturationPressureUi.cpp b/ApplicationLibCode/Commands/GridCrossPlotCommands/RicSaturationPressureUi.cpp index 06859a8fed..f1fddc2af3 100644 --- a/ApplicationLibCode/Commands/GridCrossPlotCommands/RicSaturationPressureUi.cpp +++ b/ApplicationLibCode/Commands/GridCrossPlotCommands/RicSaturationPressureUi.cpp @@ -29,10 +29,10 @@ CAF_PDM_SOURCE_INIT( RicSaturationPressureUi, "RicSaturationPressureUi" ); //-------------------------------------------------------------------------------------------------- RicSaturationPressureUi::RicSaturationPressureUi() { - CAF_PDM_InitObject( "RicSaturationPressureUi", "", "", "" ); + CAF_PDM_InitObject( "RicSaturationPressureUi" ); - CAF_PDM_InitFieldNoDefault( &m_caseToApply, "CaseToApply", "Case to Apply", "", "", "" ); - CAF_PDM_InitField( &m_timeStep, "TimeStep", 0, "Time Step", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_caseToApply, "CaseToApply", "Case to Apply" ); + CAF_PDM_InitField( &m_timeStep, "TimeStep", 0, "Time Step" ); } //-------------------------------------------------------------------------------------------------- @@ -62,8 +62,7 @@ int RicSaturationPressureUi::selectedTimeStep() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList - RicSaturationPressureUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) +QList RicSaturationPressureUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; diff --git a/ApplicationLibCode/Commands/GridCrossPlotCommands/RicSaturationPressureUi.h b/ApplicationLibCode/Commands/GridCrossPlotCommands/RicSaturationPressureUi.h index 9b287f39a3..107f717a53 100644 --- a/ApplicationLibCode/Commands/GridCrossPlotCommands/RicSaturationPressureUi.h +++ b/ApplicationLibCode/Commands/GridCrossPlotCommands/RicSaturationPressureUi.h @@ -40,8 +40,7 @@ class RicSaturationPressureUi : public caf::PdmObject int selectedTimeStep() const; protected: - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; private: caf::PdmPtrField m_caseToApply; diff --git a/ApplicationLibCode/Commands/HoloLensCommands/RicHoloLensCreateSessionUi.cpp b/ApplicationLibCode/Commands/HoloLensCommands/RicHoloLensCreateSessionUi.cpp index b34385e27f..80766ce294 100644 --- a/ApplicationLibCode/Commands/HoloLensCommands/RicHoloLensCreateSessionUi.cpp +++ b/ApplicationLibCode/Commands/HoloLensCommands/RicHoloLensCreateSessionUi.cpp @@ -35,12 +35,12 @@ CAF_PDM_SOURCE_INIT( RicHoloLensCreateSessionUi, "RicHoloLensCreateSessionUi" ); //-------------------------------------------------------------------------------------------------- RicHoloLensCreateSessionUi::RicHoloLensCreateSessionUi() { - CAF_PDM_InitObject( "HoloLens Create Session", "", "", "" ); + CAF_PDM_InitObject( "HoloLens Create Session" ); - CAF_PDM_InitField( &m_sessionName, "SessionName", QString( "DummySessionName" ), "Session Name", "", "", "" ); - CAF_PDM_InitField( &m_sessionPinCode, "SessionPinCode", QString( "1234" ), "Session Pin Code", "", "", "" ); + CAF_PDM_InitField( &m_sessionName, "SessionName", QString( "DummySessionName" ), "Session Name" ); + CAF_PDM_InitField( &m_sessionPinCode, "SessionPinCode", QString( "1234" ), "Session Pin Code" ); - CAF_PDM_InitFieldNoDefault( &m_serverSettings, "ServerSettings", "Server Settings", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_serverSettings, "ServerSettings", "Server Settings" ); m_serverSettings = new RicHoloLensServerSettings; caf::PdmSettings::readFieldsFromApplicationStore( m_serverSettings ); diff --git a/ApplicationLibCode/Commands/HoloLensCommands/RicHoloLensExportToFolderUi.cpp b/ApplicationLibCode/Commands/HoloLensCommands/RicHoloLensExportToFolderUi.cpp index 9092d59360..30d511fd7c 100644 --- a/ApplicationLibCode/Commands/HoloLensCommands/RicHoloLensExportToFolderUi.cpp +++ b/ApplicationLibCode/Commands/HoloLensCommands/RicHoloLensExportToFolderUi.cpp @@ -34,11 +34,11 @@ CAF_PDM_SOURCE_INIT( RicHoloLensExportToFolderUi, "RicHoloLensExportToFolderUi" //-------------------------------------------------------------------------------------------------- RicHoloLensExportToFolderUi::RicHoloLensExportToFolderUi() { - CAF_PDM_InitObject( "Resample LAS curves for export", "", "", "" ); + CAF_PDM_InitObject( "Resample LAS curves for export" ); - CAF_PDM_InitFieldNoDefault( &m_viewForExport, "ViewForExport", "View", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_viewForExport, "ViewForExport", "View" ); - CAF_PDM_InitField( &m_exportFolder, "ExportFolder", QString(), "Export Folder", "", "", "" ); + CAF_PDM_InitField( &m_exportFolder, "ExportFolder", QString(), "Export Folder" ); m_exportFolder.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); } @@ -70,7 +70,7 @@ RimGridView* RicHoloLensExportToFolderUi::viewForExport() const /// //-------------------------------------------------------------------------------------------------- QList - RicHoloLensExportToFolderUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) + RicHoloLensExportToFolderUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; diff --git a/ApplicationLibCode/Commands/HoloLensCommands/RicHoloLensExportToFolderUi.h b/ApplicationLibCode/Commands/HoloLensCommands/RicHoloLensExportToFolderUi.h index bb97f0b500..98dba9eb0b 100644 --- a/ApplicationLibCode/Commands/HoloLensCommands/RicHoloLensExportToFolderUi.h +++ b/ApplicationLibCode/Commands/HoloLensCommands/RicHoloLensExportToFolderUi.h @@ -40,8 +40,7 @@ class RicHoloLensExportToFolderUi : public caf::PdmObject RimGridView* viewForExport() const; private: - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; diff --git a/ApplicationLibCode/Commands/HoloLensCommands/RicHoloLensServerSettings.cpp b/ApplicationLibCode/Commands/HoloLensCommands/RicHoloLensServerSettings.cpp index 6399e30dbc..275d2464ed 100644 --- a/ApplicationLibCode/Commands/HoloLensCommands/RicHoloLensServerSettings.cpp +++ b/ApplicationLibCode/Commands/HoloLensCommands/RicHoloLensServerSettings.cpp @@ -25,9 +25,9 @@ CAF_PDM_SOURCE_INIT( RicHoloLensServerSettings, "RicHoloLensServerSettings" ); //-------------------------------------------------------------------------------------------------- RicHoloLensServerSettings::RicHoloLensServerSettings() { - CAF_PDM_InitObject( "HoloLens Server Settings", "", "", "" ); + CAF_PDM_InitObject( "HoloLens Server Settings" ); - CAF_PDM_InitField( &m_serverAddress, "ServerAddress", QString(), "Server Address", "", "", "" ); + CAF_PDM_InitField( &m_serverAddress, "ServerAddress", QString(), "Server Address" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/IntersectionBoxCommands/RicAppendIntersectionBoxFeature.h b/ApplicationLibCode/Commands/IntersectionBoxCommands/RicAppendIntersectionBoxFeature.h index 5e0d6d95d0..2387d8ccd6 100644 --- a/ApplicationLibCode/Commands/IntersectionBoxCommands/RicAppendIntersectionBoxFeature.h +++ b/ApplicationLibCode/Commands/IntersectionBoxCommands/RicAppendIntersectionBoxFeature.h @@ -32,7 +32,6 @@ class RicAppendIntersectionBoxFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/IntersectionBoxCommands/RicIntersectionBoxAtPosFeature.h b/ApplicationLibCode/Commands/IntersectionBoxCommands/RicIntersectionBoxAtPosFeature.h index 75ac598d38..bf1812911c 100644 --- a/ApplicationLibCode/Commands/IntersectionBoxCommands/RicIntersectionBoxAtPosFeature.h +++ b/ApplicationLibCode/Commands/IntersectionBoxCommands/RicIntersectionBoxAtPosFeature.h @@ -30,7 +30,6 @@ class RicIntersectionBoxAtPosFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/IntersectionBoxCommands/RicIntersectionBoxXSliceFeature.h b/ApplicationLibCode/Commands/IntersectionBoxCommands/RicIntersectionBoxXSliceFeature.h index ce357c67a8..57d3214ed3 100644 --- a/ApplicationLibCode/Commands/IntersectionBoxCommands/RicIntersectionBoxXSliceFeature.h +++ b/ApplicationLibCode/Commands/IntersectionBoxCommands/RicIntersectionBoxXSliceFeature.h @@ -30,7 +30,6 @@ class RicIntersectionBoxXSliceFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/IntersectionBoxCommands/RicIntersectionBoxYSliceFeature.h b/ApplicationLibCode/Commands/IntersectionBoxCommands/RicIntersectionBoxYSliceFeature.h index 54ca89e96d..265ed78cfb 100644 --- a/ApplicationLibCode/Commands/IntersectionBoxCommands/RicIntersectionBoxYSliceFeature.h +++ b/ApplicationLibCode/Commands/IntersectionBoxCommands/RicIntersectionBoxYSliceFeature.h @@ -30,7 +30,6 @@ class RicIntersectionBoxYSliceFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/IntersectionBoxCommands/RicIntersectionBoxZSliceFeature.h b/ApplicationLibCode/Commands/IntersectionBoxCommands/RicIntersectionBoxZSliceFeature.h index c8b7a54a39..5cf28ccb63 100644 --- a/ApplicationLibCode/Commands/IntersectionBoxCommands/RicIntersectionBoxZSliceFeature.h +++ b/ApplicationLibCode/Commands/IntersectionBoxCommands/RicIntersectionBoxZSliceFeature.h @@ -30,7 +30,6 @@ class RicIntersectionBoxZSliceFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/OctaveScriptCommands/RicAddScriptPathFeature.h b/ApplicationLibCode/Commands/OctaveScriptCommands/RicAddScriptPathFeature.h index 2089e817d4..a1c499d7cf 100644 --- a/ApplicationLibCode/Commands/OctaveScriptCommands/RicAddScriptPathFeature.h +++ b/ApplicationLibCode/Commands/OctaveScriptCommands/RicAddScriptPathFeature.h @@ -31,7 +31,6 @@ class RicAddScriptPathFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/OctaveScriptCommands/RicDeleteScriptPathFeature.cpp b/ApplicationLibCode/Commands/OctaveScriptCommands/RicDeleteScriptPathFeature.cpp index 919a2fcbd2..9c230fe3d0 100644 --- a/ApplicationLibCode/Commands/OctaveScriptCommands/RicDeleteScriptPathFeature.cpp +++ b/ApplicationLibCode/Commands/OctaveScriptCommands/RicDeleteScriptPathFeature.cpp @@ -41,6 +41,10 @@ CAF_CMD_SOURCE_INIT( RicDeleteScriptPathFeature, "RicDeleteScriptPathFeature" ); bool RicDeleteScriptPathFeature::isCommandEnabled() { std::vector selection = RicScriptFeatureImpl::selectedScriptCollections(); + if ( selection.size() == 1 ) + { + if ( selection.front()->directory().isEmpty() ) return false; + } return selection.size() > 0; } diff --git a/ApplicationLibCode/Commands/OctaveScriptCommands/RicDeleteScriptPathFeature.h b/ApplicationLibCode/Commands/OctaveScriptCommands/RicDeleteScriptPathFeature.h index 9d14a1b36d..4621b82084 100644 --- a/ApplicationLibCode/Commands/OctaveScriptCommands/RicDeleteScriptPathFeature.h +++ b/ApplicationLibCode/Commands/OctaveScriptCommands/RicDeleteScriptPathFeature.h @@ -31,7 +31,6 @@ class RicDeleteScriptPathFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/OctaveScriptCommands/RicEditScriptFeature.h b/ApplicationLibCode/Commands/OctaveScriptCommands/RicEditScriptFeature.h index d9ff2cf23f..57684fd899 100644 --- a/ApplicationLibCode/Commands/OctaveScriptCommands/RicEditScriptFeature.h +++ b/ApplicationLibCode/Commands/OctaveScriptCommands/RicEditScriptFeature.h @@ -31,7 +31,6 @@ class RicEditScriptFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/OctaveScriptCommands/RicExecuteScriptFeature.h b/ApplicationLibCode/Commands/OctaveScriptCommands/RicExecuteScriptFeature.h index 6db2b1ba09..d38317abc5 100644 --- a/ApplicationLibCode/Commands/OctaveScriptCommands/RicExecuteScriptFeature.h +++ b/ApplicationLibCode/Commands/OctaveScriptCommands/RicExecuteScriptFeature.h @@ -35,7 +35,6 @@ class RicExecuteScriptFeature : public caf::CmdFeature static void executeScript( RimCalcScript* calcScript ); protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/OctaveScriptCommands/RicExecuteScriptForCasesFeature.cpp b/ApplicationLibCode/Commands/OctaveScriptCommands/RicExecuteScriptForCasesFeature.cpp index b0ba4b71d1..a69854611c 100644 --- a/ApplicationLibCode/Commands/OctaveScriptCommands/RicExecuteScriptForCasesFeature.cpp +++ b/ApplicationLibCode/Commands/OctaveScriptCommands/RicExecuteScriptForCasesFeature.cpp @@ -59,8 +59,7 @@ void RicExecuteScriptForCasesFeature::onActionTriggered( bool isChecked ) { QString scriptAbsolutePath = userData().toString(); - RiuMainWindow* mainWindow = RiuMainWindow::instance(); - mainWindow->showProcessMonitorDockPanel(); + if ( RiuMainWindow::instance() ) RiuMainWindow::instance()->showProcessMonitorDockPanel(); RiaApplication* app = RiaApplication::instance(); diff --git a/ApplicationLibCode/Commands/OctaveScriptCommands/RicExecuteScriptForCasesFeature.h b/ApplicationLibCode/Commands/OctaveScriptCommands/RicExecuteScriptForCasesFeature.h index 039f9b5bb0..b9452f670c 100644 --- a/ApplicationLibCode/Commands/OctaveScriptCommands/RicExecuteScriptForCasesFeature.h +++ b/ApplicationLibCode/Commands/OctaveScriptCommands/RicExecuteScriptForCasesFeature.h @@ -30,7 +30,6 @@ class RicExecuteScriptForCasesFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/OctaveScriptCommands/RicNewOctaveScriptFeature.cpp b/ApplicationLibCode/Commands/OctaveScriptCommands/RicNewOctaveScriptFeature.cpp index 19daa9326a..bb650f963e 100644 --- a/ApplicationLibCode/Commands/OctaveScriptCommands/RicNewOctaveScriptFeature.cpp +++ b/ApplicationLibCode/Commands/OctaveScriptCommands/RicNewOctaveScriptFeature.cpp @@ -45,17 +45,9 @@ CAF_CMD_SOURCE_INIT( RicNewOctaveScriptFeature, "RicNewOctaveScriptFeature" ); //-------------------------------------------------------------------------------------------------- bool RicNewOctaveScriptFeature::isCommandEnabled() { - std::vector calcScripts = RicScriptFeatureImpl::selectedScripts(); std::vector calcScriptCollections = RicScriptFeatureImpl::selectedScriptCollections(); - if ( calcScripts.size() == 1u && calcScripts.front()->scriptType() == RimCalcScript::OCTAVE ) - { - return true; - } - else if ( calcScriptCollections.size() == 1u && !calcScriptCollections.front()->directory().isEmpty() ) - { - return true; - } - return false; + if ( calcScriptCollections.empty() ) return false; + return !calcScriptCollections.front()->directory().isEmpty(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/OctaveScriptCommands/RicNewOctaveScriptFeature.h b/ApplicationLibCode/Commands/OctaveScriptCommands/RicNewOctaveScriptFeature.h index 5a3c0ba125..5165e78e90 100644 --- a/ApplicationLibCode/Commands/OctaveScriptCommands/RicNewOctaveScriptFeature.h +++ b/ApplicationLibCode/Commands/OctaveScriptCommands/RicNewOctaveScriptFeature.h @@ -31,7 +31,6 @@ class RicNewOctaveScriptFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/OctaveScriptCommands/RicNewPythonScriptFeature.cpp b/ApplicationLibCode/Commands/OctaveScriptCommands/RicNewPythonScriptFeature.cpp index f829588820..f1d75cf5f7 100644 --- a/ApplicationLibCode/Commands/OctaveScriptCommands/RicNewPythonScriptFeature.cpp +++ b/ApplicationLibCode/Commands/OctaveScriptCommands/RicNewPythonScriptFeature.cpp @@ -21,6 +21,7 @@ #include "RiaApplication.h" #include "RiaLogging.h" +#include "RiaPreferences.h" #include "RicRefreshScriptsFeature.h" #include "RicScriptFeatureImpl.h" @@ -45,17 +46,9 @@ CAF_CMD_SOURCE_INIT( RicNewPythonScriptFeature, "RicNewPythonScriptFeature" ); //-------------------------------------------------------------------------------------------------- bool RicNewPythonScriptFeature::isCommandEnabled() { - std::vector calcScripts = RicScriptFeatureImpl::selectedScripts(); std::vector calcScriptCollections = RicScriptFeatureImpl::selectedScriptCollections(); - if ( calcScripts.size() == 1u && calcScripts.front()->scriptType() == RimCalcScript::PYTHON ) - { - return true; - } - else if ( calcScriptCollections.size() == 1u && !calcScriptCollections.front()->directory().isEmpty() ) - { - return true; - } - return false; + if ( calcScriptCollections.empty() ) return false; + return !calcScriptCollections.front()->directory().isEmpty(); } //-------------------------------------------------------------------------------------------------- @@ -124,7 +117,7 @@ void RicNewPythonScriptFeature::onActionTriggered( bool isChecked ) "resinsight.version_string())\n"; } - scriptColl->readContentFromDisc(); + scriptColl->readContentFromDisc( RiaPreferences::current()->maxScriptFoldersDepth() ); scriptColl->updateConnectedEditors(); if ( calcScript ) diff --git a/ApplicationLibCode/Commands/OctaveScriptCommands/RicNewPythonScriptFeature.h b/ApplicationLibCode/Commands/OctaveScriptCommands/RicNewPythonScriptFeature.h index 97f135d065..eddf6f7193 100644 --- a/ApplicationLibCode/Commands/OctaveScriptCommands/RicNewPythonScriptFeature.h +++ b/ApplicationLibCode/Commands/OctaveScriptCommands/RicNewPythonScriptFeature.h @@ -30,7 +30,6 @@ class RicNewPythonScriptFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/OctaveScriptCommands/RicRefreshScriptsFeature.cpp b/ApplicationLibCode/Commands/OctaveScriptCommands/RicRefreshScriptsFeature.cpp index 5026f02665..86bf9e8886 100644 --- a/ApplicationLibCode/Commands/OctaveScriptCommands/RicRefreshScriptsFeature.cpp +++ b/ApplicationLibCode/Commands/OctaveScriptCommands/RicRefreshScriptsFeature.cpp @@ -60,6 +60,6 @@ void RicRefreshScriptsFeature::refreshScriptFolders() RimProject* proj = RimProject::current(); RiaPreferences* prefs = RiaPreferences::current(); - proj->setScriptDirectories( prefs->scriptDirectories() ); + proj->setScriptDirectories( prefs->scriptDirectories(), prefs->maxScriptFoldersDepth() ); proj->scriptCollection()->updateConnectedEditors(); } diff --git a/ApplicationLibCode/Commands/OctaveScriptCommands/RicRefreshScriptsFeature.h b/ApplicationLibCode/Commands/OctaveScriptCommands/RicRefreshScriptsFeature.h index 773e6087df..662d9eff2a 100644 --- a/ApplicationLibCode/Commands/OctaveScriptCommands/RicRefreshScriptsFeature.h +++ b/ApplicationLibCode/Commands/OctaveScriptCommands/RicRefreshScriptsFeature.h @@ -33,7 +33,6 @@ class RicRefreshScriptsFeature : public caf::CmdFeature static void refreshScriptFolders(); protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.cpp b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.cpp index 5354c46ef8..b4f01600b6 100644 --- a/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.cpp +++ b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.cpp @@ -30,7 +30,7 @@ #include "RimGridCrossPlotDataSet.h" #include "RimMimeData.h" #include "RimModeledWellPath.h" -#include "RimSummaryCurveFilter.h" +#include "RimSummaryMultiPlot.h" #include "RimSummaryPlot.h" #include "RimWellAllocationPlot.h" #include "RimWellLogPlot.h" @@ -125,63 +125,37 @@ bool RicCopyReferencesToClipboardFeature::isAnyCopyableObjectSelected() //-------------------------------------------------------------------------------------------------- bool RicCopyReferencesToClipboardFeature::isCopyOfObjectSupported( caf::PdmObject* pdmObject ) { + // Copy support based on direct dynamic cast + if ( dynamic_cast( pdmObject ) ) return true; + if ( dynamic_cast( pdmObject ) ) return true; + if ( dynamic_cast( pdmObject ) ) return true; + if ( dynamic_cast( pdmObject ) ) return true; + if ( dynamic_cast( pdmObject ) ) return true; + if ( dynamic_cast( pdmObject ) ) return true; + if ( dynamic_cast( pdmObject ) ) return true; + if ( dynamic_cast( pdmObject ) ) return true; + if ( dynamic_cast( pdmObject ) ) return true; + if ( dynamic_cast( pdmObject ) ) return true; + if ( dynamic_cast( pdmObject ) ) return true; + + // Copy support based combined logic RimWellAllocationPlot* wellAllocPlot = nullptr; RimWellRftPlot* rftPlot = nullptr; pdmObject->firstAncestorOrThisOfType( wellAllocPlot ); pdmObject->firstAncestorOrThisOfType( rftPlot ); - if ( dynamic_cast( pdmObject ) ) - { - return true; - } - else if ( dynamic_cast( pdmObject ) ) - { - return true; - } - else if ( dynamic_cast( pdmObject ) ) - { - return true; - } - else if ( dynamic_cast( pdmObject ) ) - { - return true; - } - else if ( dynamic_cast( pdmObject ) ) - { - return true; - } - else if ( dynamic_cast( pdmObject ) ) - { - return true; - } - else if ( dynamic_cast( pdmObject ) && !dynamic_cast( pdmObject ) ) + if ( dynamic_cast( pdmObject ) && !dynamic_cast( pdmObject ) ) { if ( !rftPlot ) return true; } - else if ( dynamic_cast( pdmObject ) ) + if ( dynamic_cast( pdmObject ) ) { if ( !wellAllocPlot && !rftPlot ) return true; } - else if ( dynamic_cast( pdmObject ) ) + if ( dynamic_cast( pdmObject ) ) { if ( !wellAllocPlot && !rftPlot ) return true; } - else if ( dynamic_cast( pdmObject ) ) - { - return true; - } - else if ( dynamic_cast( pdmObject ) ) - { - return true; - } - else if ( dynamic_cast( pdmObject ) ) - { - return true; - } - else if ( dynamic_cast( pdmObject ) ) - { - return true; - } return false; } diff --git a/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.h b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.h index d73a60d61e..74820b74c9 100644 --- a/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.h +++ b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.h @@ -34,7 +34,6 @@ class RicCopyReferencesToClipboardFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteEclipseCasesFeature.h b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteEclipseCasesFeature.h index 7706889496..65b362fd06 100644 --- a/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteEclipseCasesFeature.h +++ b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteEclipseCasesFeature.h @@ -39,7 +39,6 @@ class RicPasteEclipseCasesFeature : public caf::CmdFeature static void addCasesToGridCaseGroup( caf::PdmObjectGroup& objectGroup, RimIdenticalGridCaseGroup* gridCaseGroup ); protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteEclipseViewsFeature.h b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteEclipseViewsFeature.h index 8b563f27c4..69b7775214 100644 --- a/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteEclipseViewsFeature.h +++ b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteEclipseViewsFeature.h @@ -29,7 +29,6 @@ class RicPasteEclipseViewsFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteGeoMechViewsFeature.h b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteGeoMechViewsFeature.h index f9a32623c0..4bcc72b7f8 100644 --- a/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteGeoMechViewsFeature.h +++ b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteGeoMechViewsFeature.h @@ -29,7 +29,6 @@ class RicPasteGeoMechViewsFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteIntersectionsFeature.h b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteIntersectionsFeature.h index 965098004e..22bf9755e2 100644 --- a/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteIntersectionsFeature.h +++ b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteIntersectionsFeature.h @@ -31,7 +31,6 @@ class RicPasteIntersectionsFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/CMakeLists_files.cmake b/ApplicationLibCode/Commands/PlotBuilderCommands/CMakeLists_files.cmake new file mode 100644 index 0000000000..e4a4ec7794 --- /dev/null +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/CMakeLists_files.cmake @@ -0,0 +1,43 @@ +set(SOURCE_GROUP_HEADER_FILES + ${CMAKE_CURRENT_LIST_DIR}/RicNewMultiPlotFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicSummaryPlotBuilder.h + ${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryMultiPlotFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryPlotFromDataVectorFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryMultiPlotFromDataVectorFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryPlotFromCurveFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicAppendSummaryPlotsForObjectsFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicAppendSummaryCurvesForObjectsFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicAppendSummaryPlotsForSummaryCasesFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicAppendSummaryCurvesForSummaryCasesFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicAppendSummaryPlotsForSummaryAddressesFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicAppendSummaryCurvesForSummaryAddressesFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicSplitMultiPlotFeature.h +) + +set(SOURCE_GROUP_SOURCE_FILES + ${CMAKE_CURRENT_LIST_DIR}/RicNewMultiPlotFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicSummaryPlotBuilder.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryMultiPlotFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryPlotFromDataVectorFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryMultiPlotFromDataVectorFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryPlotFromCurveFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicAppendSummaryPlotsForObjectsFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicAppendSummaryCurvesForObjectsFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicAppendSummaryPlotsForSummaryCasesFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicAppendSummaryCurvesForSummaryCasesFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicAppendSummaryPlotsForSummaryAddressesFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicAppendSummaryCurvesForSummaryAddressesFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicSplitMultiPlotFeature.cpp +) + +list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) + +list(APPEND COMMAND_CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES}) + +list(APPEND COMMAND_QT_MOC_HEADERS) + +source_group( + "CommandFeature\\PlotBuilder" + FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} + ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake +) diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryCurvesForObjectsFeature.cpp b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryCurvesForObjectsFeature.cpp new file mode 100644 index 0000000000..d76ed95680 --- /dev/null +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryCurvesForObjectsFeature.cpp @@ -0,0 +1,91 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicAppendSummaryCurvesForObjectsFeature.h" + +#include "RiaGuiApplication.h" +#include "RicAppendSummaryPlotsForObjectsFeature.h" + +#include "RimSummaryMultiPlot.h" +#include "RimSummaryPlot.h" + +#include + +CAF_CMD_SOURCE_INIT( RicAppendSummaryCurvesForObjectsFeature, "RicAppendSummaryCurvesForObjectsFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicAppendSummaryCurvesForObjectsFeature::isCommandEnabled() +{ + return !RicAppendSummaryPlotsForObjectsFeature::selectedCollections().empty(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicAppendSummaryCurvesForObjectsFeature::onActionTriggered( bool isChecked ) +{ + // - Select a set of objects in Data Source (wells, groups, regions, ..) + // - Use context menu to activate action + // - For each plots, append curves using handleDroppedObjects() on RimSummaryPlot + + auto sumAddressCollections = RicAppendSummaryPlotsForObjectsFeature::selectedCollections(); + if ( sumAddressCollections.empty() ) return; + + RiaGuiApplication* app = RiaGuiApplication::instance(); + + auto summaryMultiPlot = dynamic_cast( app->activePlotWindow() ); + if ( !summaryMultiPlot ) return; + + RicAppendSummaryPlotsForObjectsFeature::isSelectionCompatibleWithPlot( sumAddressCollections, summaryMultiPlot ); + + auto selectionType = sumAddressCollections.front()->contentType(); + auto sourcePlots = summaryMultiPlot->summaryPlots(); + + std::vector pdmObjects; + for ( auto summaryAdrCollection : sumAddressCollections ) + { + pdmObjects.push_back( summaryAdrCollection ); + } + + for ( auto plot : sourcePlots ) + { + plot->handleDroppedObjects( pdmObjects ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicAppendSummaryCurvesForObjectsFeature::setupActionLook( QAction* actionToSetup ) +{ + QString objectType = "Objects"; + + auto addresses = RicAppendSummaryPlotsForObjectsFeature::selectedCollections(); + + if ( !addresses.empty() ) + { + auto firstAdr = addresses.front(); + objectType = caf::AppEnum::uiText( firstAdr->contentType() ); + } + + auto text = QString( "Append Curves For " ) + objectType; + actionToSetup->setText( text ); + actionToSetup->setIcon( QIcon( ":/SummaryCurve16x16.png" ) ); +} diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicActivateCurveFilterInToolbarFeature.h b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryCurvesForObjectsFeature.h similarity index 91% rename from ApplicationLibCode/Commands/SummaryPlotCommands/RicActivateCurveFilterInToolbarFeature.h rename to ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryCurvesForObjectsFeature.h index 8352953ce0..a33b3e6e48 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicActivateCurveFilterInToolbarFeature.h +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryCurvesForObjectsFeature.h @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2019- Equinor ASA +// Copyright (C) 2022 Equinor ASA // // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -23,7 +23,7 @@ //================================================================================================== /// //================================================================================================== -class RicActivateCurveFilterInToolbarFeature : public caf::CmdFeature +class RicAppendSummaryCurvesForObjectsFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryCurvesForSummaryAddressesFeature.cpp b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryCurvesForSummaryAddressesFeature.cpp new file mode 100644 index 0000000000..b0009c0677 --- /dev/null +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryCurvesForSummaryAddressesFeature.cpp @@ -0,0 +1,87 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicAppendSummaryCurvesForSummaryAddressesFeature.h" + +#include "RiaGuiApplication.h" + +#include "RicAppendSummaryPlotsForObjectsFeature.h" + +#include "RimSummaryAddress.h" +#include "RimSummaryAddressCollection.h" +#include "RimSummaryCase.h" +#include "RimSummaryMultiPlot.h" +#include "RimSummaryPlot.h" + +#include "cafSelectionManager.h" + +#include + +CAF_CMD_SOURCE_INIT( RicAppendSummaryCurvesForSummaryAddressesFeature, "RicAppendSummaryCurvesForSummaryAddressesFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicAppendSummaryCurvesForSummaryAddressesFeature::isCommandEnabled() +{ + return !selectedAddresses().empty(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicAppendSummaryCurvesForSummaryAddressesFeature::onActionTriggered( bool isChecked ) +{ + RiaGuiApplication* app = RiaGuiApplication::instance(); + + auto summaryMultiPlot = dynamic_cast( app->activePlotWindow() ); + if ( !summaryMultiPlot ) return; + + auto addresses = selectedAddresses(); + if ( addresses.empty() ) return; + + for ( auto plot : summaryMultiPlot->summaryPlots() ) + { + plot->handleDroppedObjects( addresses ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicAppendSummaryCurvesForSummaryAddressesFeature::setupActionLook( QAction* actionToSetup ) +{ + auto text = QString( "Append Curves For Vector" ); + actionToSetup->setText( text ); + actionToSetup->setIcon( QIcon( ":/SummaryCurve16x16.png" ) ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RicAppendSummaryCurvesForSummaryAddressesFeature::selectedAddresses() +{ + std::vector objects; + caf::SelectionManager::instance()->objectsByType( &objects ); + + // Make the object type general to match the expected type for handleDroppedObjects(); + std::vector generalObjects; + generalObjects.insert( generalObjects.begin(), objects.begin(), objects.end() ); + + return generalObjects; +} diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryCurvesForSummaryAddressesFeature.h b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryCurvesForSummaryAddressesFeature.h new file mode 100644 index 0000000000..68c85cd90a --- /dev/null +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryCurvesForSummaryAddressesFeature.h @@ -0,0 +1,44 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +namespace caf +{ +class PdmObjectHandle; +} + +#include + +//================================================================================================== +/// +//================================================================================================== +class RicAppendSummaryCurvesForSummaryAddressesFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + bool isCommandEnabled() override; + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; + +private: + static std::vector selectedAddresses(); +}; diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryCurvesForSummaryCasesFeature.cpp b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryCurvesForSummaryCasesFeature.cpp new file mode 100644 index 0000000000..a40c7045a4 --- /dev/null +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryCurvesForSummaryCasesFeature.cpp @@ -0,0 +1,88 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicAppendSummaryCurvesForSummaryCasesFeature.h" + +#include "RiaGuiApplication.h" + +#include "RicAppendSummaryPlotsForObjectsFeature.h" + +#include "RimSummaryAddressCollection.h" +#include "RimSummaryCase.h" +#include "RimSummaryMultiPlot.h" +#include "RimSummaryPlot.h" + +#include "cafSelectionManager.h" + +#include + +CAF_CMD_SOURCE_INIT( RicAppendSummaryCurvesForSummaryCasesFeature, "RicAppendSummaryCurvesForSummaryCasesFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicAppendSummaryCurvesForSummaryCasesFeature::isCommandEnabled() +{ + return !selectedCases().empty(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicAppendSummaryCurvesForSummaryCasesFeature::onActionTriggered( bool isChecked ) +{ + RiaGuiApplication* app = RiaGuiApplication::instance(); + + auto summaryMultiPlot = dynamic_cast( app->activePlotWindow() ); + if ( !summaryMultiPlot ) return; + + auto cases = selectedCases(); + if ( cases.empty() ) return; + + for ( auto plot : summaryMultiPlot->summaryPlots() ) + { + plot->handleDroppedObjects( cases ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicAppendSummaryCurvesForSummaryCasesFeature::setupActionLook( QAction* actionToSetup ) +{ + QString objectType = "Cases"; + + auto text = QString( "Append Curves For " ) + objectType; + actionToSetup->setText( text ); + actionToSetup->setIcon( QIcon( ":/SummaryCurve16x16.png" ) ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RicAppendSummaryCurvesForSummaryCasesFeature::selectedCases() +{ + std::vector objects; + caf::SelectionManager::instance()->objectsByType( &objects ); + + // Make the object type general to match the expected type for handleDroppedObjects(); + std::vector generalObjects; + generalObjects.insert( generalObjects.begin(), objects.begin(), objects.end() ); + + return generalObjects; +} diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryCurvesForSummaryCasesFeature.h b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryCurvesForSummaryCasesFeature.h new file mode 100644 index 0000000000..6801526a69 --- /dev/null +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryCurvesForSummaryCasesFeature.h @@ -0,0 +1,44 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +namespace caf +{ +class PdmObjectHandle; +} + +#include + +//================================================================================================== +/// +//================================================================================================== +class RicAppendSummaryCurvesForSummaryCasesFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + bool isCommandEnabled() override; + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; + +private: + static std::vector selectedCases(); +}; diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForObjectsFeature.cpp b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForObjectsFeature.cpp new file mode 100644 index 0000000000..0793ec30a5 --- /dev/null +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForObjectsFeature.cpp @@ -0,0 +1,350 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicAppendSummaryPlotsForObjectsFeature.h" + +#include "RiaGuiApplication.h" +#include "RiaLogging.h" +#include "RiaStdStringTools.h" +#include "RiaSummaryAddressAnalyzer.h" +#include "RiaSummaryTools.h" + +#include "RicSummaryPlotBuilder.h" + +#include "RimEnsembleCurveSet.h" +#include "RimSummaryAddressCollection.h" +#include "RimSummaryAddressModifier.h" +#include "RimSummaryCurve.h" +#include "RimSummaryMultiPlot.h" +#include "RimSummaryMultiPlotCollection.h" +#include "RimSummaryPlot.h" + +#include "cafAssert.h" +#include "cafProgressInfo.h" +#include "cafSelectionManager.h" + +#include + +CAF_CMD_SOURCE_INIT( RicAppendSummaryPlotsForObjectsFeature, "RicAppendSummaryPlotsForObjectsFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicAppendSummaryPlotsForObjectsFeature::isCommandEnabled() +{ + return !selectedCollections().empty(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicAppendSummaryPlotsForObjectsFeature::appendPlots( RimSummaryMultiPlot* summaryMultiPlot, + const std::vector& sumAddressCollections ) +{ + if ( sumAddressCollections.empty() ) return; + + isSelectionCompatibleWithPlot( sumAddressCollections, summaryMultiPlot ); + + auto selectionType = sumAddressCollections.front()->contentType(); + auto sourcePlots = summaryMultiPlot->summaryPlots(); + auto plotsForOneInstance = plotsForOneInstanceOfObjectType( sourcePlots, selectionType ); + + caf::ProgressInfo info( sumAddressCollections.size(), "Appending plots..." ); + + for ( auto summaryAdrCollection : sumAddressCollections ) + { + auto duplicatedPlots = RicSummaryPlotBuilder::duplicateSummaryPlots( plotsForOneInstance ); + + for ( auto duplicatedPlot : duplicatedPlots ) + { + if ( summaryAdrCollection->contentType() == RimSummaryAddressCollection::CollectionContentType::SUMMARY_CASE ) + { + summaryMultiPlot->addPlot( duplicatedPlot ); + + auto summaryCase = RiaSummaryTools::summaryCaseById( summaryAdrCollection->caseId() ); + for ( auto c : duplicatedPlot->summaryCurves() ) + { + c->setSummaryCaseY( summaryCase ); + } + } + else + { + auto adrMods = RimSummaryAddressModifier::createAddressModifiersForPlot( duplicatedPlot ); + for ( auto adrMod : adrMods ) + { + auto sourceAddress = adrMod.address(); + auto modifiedAdr = modifyAddress( sourceAddress, summaryAdrCollection ); + + adrMod.setAddress( modifiedAdr ); + } + summaryMultiPlot->addPlot( duplicatedPlot ); + duplicatedPlot->resolveReferencesRecursively(); + } + + duplicatedPlot->loadDataAndUpdate(); + } + info.incrementProgress(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicAppendSummaryPlotsForObjectsFeature::onActionTriggered( bool isChecked ) +{ + // - Select a set of objects in Data Source (wells, groups, regions, ..) + // - Use context menu to activate action + // - For each plot in the current active plot, create a duplicate plot and replace the object name + + auto sumAddressCollections = selectedCollections(); + if ( sumAddressCollections.empty() ) return; + + RiaGuiApplication* app = RiaGuiApplication::instance(); + + auto summaryMultiPlot = dynamic_cast( app->activePlotWindow() ); + if ( !summaryMultiPlot ) return; + + appendPlots( summaryMultiPlot, sumAddressCollections ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicAppendSummaryPlotsForObjectsFeature::setupActionLook( QAction* actionToSetup ) +{ + QString objectType = "Objects"; + + auto addresses = selectedCollections(); + + if ( !addresses.empty() ) + { + auto firstAdr = addresses.front(); + objectType = caf::AppEnum::uiText( firstAdr->contentType() ); + } + + auto text = QString( "Append Plots For " ) + objectType; + actionToSetup->setText( text ); + actionToSetup->setIcon( QIcon( ":/SummaryPlotLight16x16.png" ) ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RicAppendSummaryPlotsForObjectsFeature::selectedCollections() +{ + std::vector sumAddressCollections; + caf::SelectionManager::instance()->objectsByType( &sumAddressCollections ); + + if ( sumAddressCollections.size() == 1 ) + { + auto coll = sumAddressCollections[0]; + if ( coll->isFolder() ) + { + // If a folder is selected, return all sub items in folder + auto childObjects = coll->subFolders(); + + return childObjects; + } + } + + return sumAddressCollections; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicAppendSummaryPlotsForObjectsFeature::isSelectionCompatibleWithPlot( + const std::vector& selection, + RimSummaryMultiPlot* summaryMultiPlot ) +{ + if ( !summaryMultiPlot ) return false; + if ( selection.empty() ) return false; + + auto selectionType = selection.front()->contentType(); + + RiaSummaryAddressAnalyzer analyzer; + + { + // Find all plots for one object type + auto sourcePlots = summaryMultiPlot->summaryPlots(); + + std::vector plotsForObjectType = + RicAppendSummaryPlotsForObjectsFeature::plotsForOneInstanceOfObjectType( sourcePlots, selectionType ); + + for ( auto plot : plotsForObjectType ) + { + auto addresses = RimSummaryAddressModifier::createEclipseSummaryAddress( plot ); + analyzer.appendAddresses( addresses ); + } + } + + QString errorText; + if ( selectionType == RimSummaryAddressCollection::CollectionContentType::WELL ) + { + if ( analyzer.wellNames().empty() ) + { + errorText = "Source plot must contain at least one well to be able to duplicate a selection of wells"; + } + } + else if ( selectionType == RimSummaryAddressCollection::CollectionContentType::GROUP ) + { + if ( analyzer.groupNames().empty() ) + { + errorText = "Source plot must contain at least one group to be able to duplicate a selection of groups"; + } + } + else if ( selectionType == RimSummaryAddressCollection::CollectionContentType::REGION ) + { + if ( analyzer.regionNumbers().empty() ) + { + errorText = "Source plot must contain at least one region to be able to duplicate a selection of regions"; + } + } + + if ( !errorText.isEmpty() ) + { + RiaLogging::error( errorText ); + return false; + } + + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifEclipseSummaryAddress + RicAppendSummaryPlotsForObjectsFeature::modifyAddress( const RifEclipseSummaryAddress& sourceAddress, + RimSummaryAddressCollection* summaryAddressCollection ) +{ + CAF_ASSERT( summaryAddressCollection ); + + auto adr = sourceAddress; + + auto objectName = summaryAddressCollection->name().toStdString(); + if ( summaryAddressCollection->contentType() == RimSummaryAddressCollection::CollectionContentType::WELL ) + { + adr.setWellName( objectName ); + } + else if ( summaryAddressCollection->contentType() == RimSummaryAddressCollection::CollectionContentType::GROUP ) + { + adr.setGroupName( objectName ); + } + else if ( summaryAddressCollection->contentType() == RimSummaryAddressCollection::CollectionContentType::REGION ) + { + int intValue = RiaStdStringTools::toInt( objectName ); + if ( intValue == -1 ) + { + QString errorText = QString( "Failed to convert region text to region integer value " + "for region text : " ) + + summaryAddressCollection->name(); + + RiaLogging::error( errorText ); + } + else + { + adr.setRegion( intValue ); + } + } + + return adr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RicAppendSummaryPlotsForObjectsFeature::plotsForOneInstanceOfObjectType( + const std::vector& sourcePlots, + RimSummaryAddressCollection::CollectionContentType objectType ) +{ + std::vector plotsForOneInstance; + + std::string wellNameToMatch; + std::string groupNameToMatch; + int regionToMatch = -1; + int caseIdToMatch = -1; + + RiaSummaryAddressAnalyzer myAnalyser; + for ( auto sourcePlot : sourcePlots ) + { + auto addresses = RimSummaryAddressModifier::createEclipseSummaryAddress( sourcePlot ); + myAnalyser.appendAddresses( addresses ); + } + + if ( objectType == RimSummaryAddressCollection::CollectionContentType::WELL ) + { + if ( !myAnalyser.wellNames().empty() ) wellNameToMatch = *( myAnalyser.wellNames().begin() ); + } + else if ( objectType == RimSummaryAddressCollection::CollectionContentType::GROUP ) + { + if ( !myAnalyser.groupNames().empty() ) groupNameToMatch = *( myAnalyser.groupNames().begin() ); + } + else if ( objectType == RimSummaryAddressCollection::CollectionContentType::REGION ) + { + if ( !myAnalyser.regionNumbers().empty() ) regionToMatch = *( myAnalyser.regionNumbers().begin() ); + } + else if ( objectType == RimSummaryAddressCollection::CollectionContentType::SUMMARY_CASE ) + { + if ( !sourcePlots.empty() ) + { + auto curves = sourcePlots.back()->summaryCurves(); + if ( !curves.empty() ) + { + caseIdToMatch = curves.front()->summaryCaseY()->caseId(); + } + } + } + + for ( auto sourcePlot : sourcePlots ) + { + bool isMatching = false; + + if ( caseIdToMatch != -1 ) + { + auto curves = sourcePlot->summaryCurves(); + for ( auto c : curves ) + { + if ( c->summaryCaseY()->caseId() == caseIdToMatch ) isMatching = true; + } + } + else + { + auto addresses = RimSummaryAddressModifier::createEclipseSummaryAddress( sourcePlot ); + + for ( const auto& a : addresses ) + { + if ( !wellNameToMatch.empty() && a.wellName() == wellNameToMatch ) + { + isMatching = true; + } + else if ( !groupNameToMatch.empty() && a.groupName() == groupNameToMatch ) + { + isMatching = true; + } + else if ( regionToMatch != -1 && a.regionNumber() == regionToMatch ) + { + isMatching = true; + } + } + } + + if ( isMatching ) plotsForOneInstance.push_back( sourcePlot ); + } + + return plotsForOneInstance; +} diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForObjectsFeature.h b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForObjectsFeature.h new file mode 100644 index 0000000000..6723f922ed --- /dev/null +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForObjectsFeature.h @@ -0,0 +1,59 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RimSummaryAddressCollection.h" + +#include "cafCmdFeature.h" + +#include +#include + +class RimSummaryAddressCollection; +class RimSummaryMultiPlot; +class RifEclipseSummaryAddress; +class RimSummaryPlot; + +//================================================================================================== +/// +//================================================================================================== +class RicAppendSummaryPlotsForObjectsFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +public: + static std::vector selectedCollections(); + static std::vector + plotsForOneInstanceOfObjectType( const std::vector& sourcePlots, + RimSummaryAddressCollection::CollectionContentType objectType ); + static bool isSelectionCompatibleWithPlot( const std::vector& selection, + RimSummaryMultiPlot* summaryMultiPlot ); + + static void appendPlots( RimSummaryMultiPlot* summaryMultiPlot, + const std::vector& selection ); + +protected: + bool isCommandEnabled() override; + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; + +private: + static RifEclipseSummaryAddress modifyAddress( const RifEclipseSummaryAddress& sourceAddress, + RimSummaryAddressCollection* summaryAddressCollection ); +}; diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForSummaryAddressesFeature.cpp b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForSummaryAddressesFeature.cpp new file mode 100644 index 0000000000..7d0b94eb34 --- /dev/null +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForSummaryAddressesFeature.cpp @@ -0,0 +1,104 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicAppendSummaryPlotsForSummaryAddressesFeature.h" + +#include "RiaGuiApplication.h" + +#include "RicAppendSummaryPlotsForObjectsFeature.h" + +#include "RimSummaryAddress.h" +#include "RimSummaryAddressCollection.h" +#include "RimSummaryCase.h" +#include "RimSummaryMultiPlot.h" +#include "RimSummaryPlot.h" + +#include "cafProgressInfo.h" +#include "cafSelectionManager.h" + +#include + +CAF_CMD_SOURCE_INIT( RicAppendSummaryPlotsForSummaryAddressesFeature, "RicAppendSummaryPlotsForSummaryAddressesFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicAppendSummaryPlotsForSummaryAddressesFeature::appendPlotsForAddresses( RimSummaryMultiPlot* summaryMultiPlot, + const std::vector& addresses ) +{ + if ( !summaryMultiPlot ) return; + if ( addresses.empty() ) return; + + caf::ProgressInfo info( addresses.size(), "Appending plots..." ); + + for ( auto adr : addresses ) + { + auto* plot = new RimSummaryPlot(); + plot->enableAutoPlotTitle( true ); + plot->handleDroppedObjects( { adr } ); + + summaryMultiPlot->addPlot( plot ); + + info.incrementProgress(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicAppendSummaryPlotsForSummaryAddressesFeature::isCommandEnabled() +{ + return !selectedAddresses().empty(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicAppendSummaryPlotsForSummaryAddressesFeature::onActionTriggered( bool isChecked ) +{ + RiaGuiApplication* app = RiaGuiApplication::instance(); + + auto summaryMultiPlot = dynamic_cast( app->activePlotWindow() ); + if ( !summaryMultiPlot ) return; + + auto addresses = selectedAddresses(); + if ( addresses.empty() ) return; + + appendPlotsForAddresses( summaryMultiPlot, addresses ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicAppendSummaryPlotsForSummaryAddressesFeature::setupActionLook( QAction* actionToSetup ) +{ + auto text = QString( "Append Plots For Vector" ); + actionToSetup->setText( text ); + actionToSetup->setIcon( QIcon( ":/SummaryPlotLight16x16.png" ) ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RicAppendSummaryPlotsForSummaryAddressesFeature::selectedAddresses() +{ + std::vector objects; + caf::SelectionManager::instance()->objectsByType( &objects ); + + return objects; +} diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForSummaryAddressesFeature.h b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForSummaryAddressesFeature.h new file mode 100644 index 0000000000..3067e13d86 --- /dev/null +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForSummaryAddressesFeature.h @@ -0,0 +1,46 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +#include + +class RimSummaryAddress; +class RimSummaryMultiPlot; + +//================================================================================================== +/// +//================================================================================================== +class RicAppendSummaryPlotsForSummaryAddressesFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +public: + static void appendPlotsForAddresses( RimSummaryMultiPlot* summaryMultiPlot, + const std::vector& addresses ); + +protected: + bool isCommandEnabled() override; + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; + +private: + static std::vector selectedAddresses(); +}; diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForSummaryCasesFeature.cpp b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForSummaryCasesFeature.cpp new file mode 100644 index 0000000000..364dcc799b --- /dev/null +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForSummaryCasesFeature.cpp @@ -0,0 +1,107 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicAppendSummaryPlotsForSummaryCasesFeature.h" + +#include "RiaGuiApplication.h" + +#include "RicAppendSummaryPlotsForObjectsFeature.h" + +#include "RimSummaryAddressCollection.h" +#include "RimSummaryCase.h" +#include "RimSummaryMultiPlot.h" + +#include "cafSelectionManager.h" + +#include + +CAF_CMD_SOURCE_INIT( RicAppendSummaryPlotsForSummaryCasesFeature, "RicAppendSummaryPlotsForSummaryCasesFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicAppendSummaryPlotsForSummaryCasesFeature::appendPlotsForCases( RimSummaryMultiPlot* summaryMultiPlot, + const std::vector& cases ) +{ + if ( !summaryMultiPlot ) return; + if ( cases.empty() ) return; + + std::vector tmp; + + for ( auto c : cases ) + { + auto myColl = new RimSummaryAddressCollection; + myColl->setContentType( RimSummaryAddressCollection::CollectionContentType::SUMMARY_CASE ); + myColl->setCaseId( c->caseId() ); + tmp.push_back( myColl ); + } + + RicAppendSummaryPlotsForObjectsFeature::appendPlots( summaryMultiPlot, tmp ); + + for ( auto obj : tmp ) + { + delete obj; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicAppendSummaryPlotsForSummaryCasesFeature::isCommandEnabled() +{ + return !selectedCases().empty(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicAppendSummaryPlotsForSummaryCasesFeature::onActionTriggered( bool isChecked ) +{ + RiaGuiApplication* app = RiaGuiApplication::instance(); + + auto summaryMultiPlot = dynamic_cast( app->activePlotWindow() ); + if ( !summaryMultiPlot ) return; + + auto cases = selectedCases(); + if ( cases.empty() ) return; + + appendPlotsForCases( summaryMultiPlot, cases ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicAppendSummaryPlotsForSummaryCasesFeature::setupActionLook( QAction* actionToSetup ) +{ + QString objectType = "Cases"; + + auto text = QString( "Append Plots For " ) + objectType; + actionToSetup->setText( text ); + actionToSetup->setIcon( QIcon( ":/SummaryPlotLight16x16.png" ) ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RicAppendSummaryPlotsForSummaryCasesFeature::selectedCases() +{ + std::vector objects; + caf::SelectionManager::instance()->objectsByType( &objects ); + + return objects; +} diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForSummaryCasesFeature.h b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForSummaryCasesFeature.h new file mode 100644 index 0000000000..ab1c6acd96 --- /dev/null +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForSummaryCasesFeature.h @@ -0,0 +1,45 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +#include + +class RimSummaryCase; +class RimSummaryMultiPlot; + +//================================================================================================== +/// +//================================================================================================== +class RicAppendSummaryPlotsForSummaryCasesFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +public: + static void appendPlotsForCases( RimSummaryMultiPlot* summaryMultiPlot, const std::vector& cases ); + +protected: + bool isCommandEnabled() override; + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; + +private: + static std::vector selectedCases(); +}; diff --git a/ApplicationLibCode/Commands/RicNewMultiPlotFeature.cpp b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewMultiPlotFeature.cpp similarity index 67% rename from ApplicationLibCode/Commands/RicNewMultiPlotFeature.cpp rename to ApplicationLibCode/Commands/PlotBuilderCommands/RicNewMultiPlotFeature.cpp index 2507bcf216..598c0cf606 100644 --- a/ApplicationLibCode/Commands/RicNewMultiPlotFeature.cpp +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewMultiPlotFeature.cpp @@ -19,21 +19,18 @@ #include "RicNewMultiPlotFeature.h" -#include "RimMainPlotCollection.h" -#include "RimMultiPlot.h" -#include "RimMultiPlotCollection.h" +#include "RicSummaryPlotBuilder.h" + #include "RimPlot.h" -#include "RimProject.h" -#include "RimSaturationPressurePlot.h" #include "RimWellLogTrack.h" #include "RiuPlotMainWindowTools.h" -#include #include "cafSelectionManager.h" - #include "cvfAssert.h" +#include + RICF_SOURCE_INIT( RicNewMultiPlotFeature, "RicNewMultiPlotFeature", "createMultiPlot" ); //-------------------------------------------------------------------------------------------------- @@ -41,7 +38,7 @@ RICF_SOURCE_INIT( RicNewMultiPlotFeature, "RicNewMultiPlotFeature", "createMulti //-------------------------------------------------------------------------------------------------- RicNewMultiPlotFeature::RicNewMultiPlotFeature() { - CAF_PDM_InitFieldNoDefault( &m_plots, "plots", "Plots", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_plots, "plots", "Plots" ); } //-------------------------------------------------------------------------------------------------- @@ -49,14 +46,6 @@ RicNewMultiPlotFeature::RicNewMultiPlotFeature() //-------------------------------------------------------------------------------------------------- caf::PdmScriptResponse RicNewMultiPlotFeature::execute() { - RimProject* project = RimProject::current(); - RimMultiPlotCollection* plotCollection = project->mainPlotCollection()->multiPlotCollection(); - - RimMultiPlot* plotWindow = new RimMultiPlot; - plotWindow->setMultiPlotTitle( QString( "Multi Plot %1" ).arg( plotCollection->multiPlots().size() + 1 ) ); - plotWindow->setAsPlotMdiWindow(); - plotCollection->addMultiPlot( plotWindow ); - if ( !m_plots().empty() ) { std::vector plots; @@ -65,40 +54,11 @@ caf::PdmScriptResponse RicNewMultiPlotFeature::execute() plots.push_back( reinterpret_cast( ptr ) ); } - for ( auto plot : plots ) - { - auto copy = dynamic_cast( plot->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); + auto copyOfPlots = RicSummaryPlotBuilder::duplicatePlots( plots ); - { - // TODO: Workaround for fixing the PdmPointer in RimEclipseResultDefinition - // caf::PdmPointer m_eclipseCase; - // This pdmpointer must be changed to a ptrField - - auto saturationPressurePlotOriginal = dynamic_cast( plot ); - auto saturationPressurePlotCopy = dynamic_cast( copy ); - if ( saturationPressurePlotCopy && saturationPressurePlotOriginal ) - { - RimSaturationPressurePlot::fixPointersAfterCopy( saturationPressurePlotOriginal, - saturationPressurePlotCopy ); - } - } - - plotWindow->addPlot( copy ); - - copy->resolveReferencesRecursively(); - copy->revokeMdiWindowStatus(); - copy->setShowWindow( true ); - - copy->loadDataAndUpdate(); - } + RicSummaryPlotBuilder::createAndAppendMultiPlot( copyOfPlots ); } - project->updateAllRequiredEditors(); - plotWindow->loadDataAndUpdate(); - - RiuPlotMainWindowTools::setExpanded( plotCollection, true ); - RiuPlotMainWindowTools::selectAsCurrentItem( plotWindow, true ); - return caf::PdmScriptResponse(); } diff --git a/ApplicationLibCode/Commands/RicNewMultiPlotFeature.h b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewMultiPlotFeature.h similarity index 98% rename from ApplicationLibCode/Commands/RicNewMultiPlotFeature.h rename to ApplicationLibCode/Commands/PlotBuilderCommands/RicNewMultiPlotFeature.h index e70ad56518..432459a18a 100644 --- a/ApplicationLibCode/Commands/RicNewMultiPlotFeature.h +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewMultiPlotFeature.h @@ -40,7 +40,6 @@ class RicNewMultiPlotFeature : public caf::CmdFeature, public RicfCommandObject caf::PdmScriptResponse execute() override; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryMultiPlotFeature.cpp b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryMultiPlotFeature.cpp new file mode 100644 index 0000000000..4091957c40 --- /dev/null +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryMultiPlotFeature.cpp @@ -0,0 +1,133 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicNewSummaryMultiPlotFeature.h" + +#include "RicSummaryPlotBuilder.h" + +#include "RimProject.h" +#include "RimSummaryCase.h" +#include "RimSummaryCaseCollection.h" +#include "RimSummaryMultiPlot.h" +#include "RimSummaryMultiPlotCollection.h" +#include "RimSummaryPlot.h" + +#include "RicSummaryPlotBuilder.h" + +#include "cafSelectionManager.h" +#include "cvfAssert.h" + +#include + +CAF_CMD_SOURCE_INIT( RicNewSummaryMultiPlotFeature, "RicNewSummaryMultiPlotFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicNewSummaryMultiPlotFeature::isCommandEnabled() +{ + std::vector selectedUiItems; + caf::SelectionManager::instance()->selectedItems( selectedUiItems ); + + if ( selectedCollection( selectedUiItems ) ) return true; + + std::vector selectedIndividualSummaryCases; + std::vector selectedEnsembles; + if ( selectedCases( &selectedIndividualSummaryCases, &selectedEnsembles ) ) return true; + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewSummaryMultiPlotFeature::onActionTriggered( bool isChecked ) +{ + std::vector selectedUiItems; + caf::SelectionManager::instance()->selectedItems( selectedUiItems ); + + std::vector selectedIndividualSummaryCases; + std::vector selectedEnsembles; + + RimSummaryMultiPlotCollection* coll = selectedCollection( selectedUiItems ); + if ( coll ) + { + auto ensembles = RimProject::current()->summaryGroups(); + if ( !ensembles.empty() ) + selectedEnsembles.push_back( ensembles.front() ); + else + { + auto summaryCases = RimProject::current()->allSummaryCases(); + if ( !summaryCases.empty() ) selectedIndividualSummaryCases.push_back( summaryCases.front() ); + } + } + else + { + selectedCases( &selectedIndividualSummaryCases, &selectedEnsembles ); + } + + bool skipCreationOfPlotBasedOnPreferences = false; + RicSummaryPlotBuilder::createAndAppendDefaultSummaryMultiPlot( selectedIndividualSummaryCases, + selectedEnsembles, + skipCreationOfPlotBasedOnPreferences ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewSummaryMultiPlotFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setText( "New Summary Plot" ); + actionToSetup->setIcon( QIcon( ":/MultiPlot16x16.png" ) ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryMultiPlotCollection* RicNewSummaryMultiPlotFeature::selectedCollection( std::vector& items ) +{ + for ( caf::PdmUiItem* uiItem : items ) + { + RimSummaryMultiPlotCollection* coll = dynamic_cast( uiItem ); + if ( coll ) return coll; + } + return nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicNewSummaryMultiPlotFeature::selectedCases( std::vector* selectedIndividualSummaryCases, + std::vector* selectedEnsembles ) +{ + CAF_ASSERT( selectedIndividualSummaryCases && selectedEnsembles ); + + caf::SelectionManager::instance()->objectsByTypeStrict( selectedEnsembles ); + if ( !selectedEnsembles->empty() ) + { + return true; + } + // Second try selected summary cases + caf::SelectionManager::instance()->objectsByTypeStrict( selectedIndividualSummaryCases ); + if ( !selectedIndividualSummaryCases->empty() ) + { + return true; + } + + return false; +} diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryMultiPlotFeature.h b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryMultiPlotFeature.h new file mode 100644 index 0000000000..bc16de116b --- /dev/null +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryMultiPlotFeature.h @@ -0,0 +1,48 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" +#include "cafPdmField.h" +#include "cafPdmUiItem.h" + +#include + +class RimSummaryMultiPlotCollection; +class RimSummaryCase; +class RimSummaryCaseCollection; + +//================================================================================================== +/// +//================================================================================================== +class RicNewSummaryMultiPlotFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + bool isCommandEnabled() override; + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; + +private: + RimSummaryMultiPlotCollection* selectedCollection( std::vector& items ); + + bool selectedCases( std::vector* selectedIndividualSummaryCases, + std::vector* selectedEnsembles ); +}; diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryMultiPlotFromDataVectorFeature.cpp b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryMultiPlotFromDataVectorFeature.cpp new file mode 100644 index 0000000000..02c9615748 --- /dev/null +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryMultiPlotFromDataVectorFeature.cpp @@ -0,0 +1,149 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicNewSummaryMultiPlotFromDataVectorFeature.h" + +#include "RiaPreferencesSummary.h" +#include "RiaSummaryTools.h" + +#include "RimSummaryAddress.h" +#include "RimSummaryCase.h" +#include "RimSummaryCaseCollection.h" +#include "RimSummaryPlot.h" + +#include "RicSummaryPlotBuilder.h" + +#include "RifEclipseSummaryAddress.h" +#include "RifReaderEclipseSummary.h" + +#include "cafSelectionManagerTools.h" +#include "cvfAssert.h" + +#include + +CAF_CMD_SOURCE_INIT( RicNewSummaryMultiPlotFromDataVectorFeature, "RicNewSummaryMultiPlotFromDataVectorFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicNewSummaryMultiPlotFromDataVectorFeature::isCommandEnabled() +{ + std::vector selectedItems; + caf::SelectionManager::instance()->selectedItems( selectedItems ); + + std::vector selectedAddressItems = caf::selectedObjectsByType(); + + unsigned int nEnsembles = 0; + + for ( auto adr : selectedAddressItems ) + { + if ( adr->isEnsemble() ) nEnsembles++; + } + + bool bOk = ( selectedAddressItems.size() > 0 ); + if ( nEnsembles > 0 ) + { + bOk = bOk && ( nEnsembles == selectedItems.size() ); + } + bOk = bOk && ( selectedAddressItems.size() == selectedItems.size() ); + + return bOk; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewSummaryMultiPlotFromDataVectorFeature::onActionTriggered( bool isChecked ) +{ + std::vector selectedAddressItems = caf::selectedObjectsByType(); + std::set caseIds; + std::set ensembleIds; + std::vector selectedCases; + std::set eclipseAddresses; + std::vector selectedEnsembles; + + bool isEnsemble = false; + + for ( auto adr : selectedAddressItems ) + { + eclipseAddresses.insert( adr->address() ); + caseIds.insert( adr->caseId() ); + ensembleIds.insert( adr->ensembleId() ); + isEnsemble = isEnsemble || adr->isEnsemble(); + } + + std::set availableAddresses; + + if ( isEnsemble ) + { + for ( auto id : ensembleIds ) + { + auto ensemble = RiaSummaryTools::ensembleById( id ); + if ( ensemble ) + { + selectedEnsembles.push_back( ensemble ); + + if ( availableAddresses.empty() ) availableAddresses = ensemble->ensembleSummaryAddresses(); + } + } + } + else + { + for ( auto id : caseIds ) + { + auto summaryCase = RiaSummaryTools::summaryCaseById( id ); + if ( summaryCase ) + { + selectedCases.push_back( summaryCase ); + if ( availableAddresses.empty() && summaryCase->summaryReader() ) + availableAddresses = summaryCase->summaryReader()->allResultAddresses(); + } + } + } + + if ( RiaPreferencesSummary::current()->appendHistoryVectors() ) + { + auto sourceAddresses = eclipseAddresses; + + for ( const auto& addr : sourceAddresses ) + { + if ( !addr.isHistoryVector() ) + { + auto historyAddr = addr; + historyAddr.setVectorName( addr.vectorName() + RifReaderEclipseSummary::historyIdentifier() ); + + if ( availableAddresses.count( historyAddr ) > 0 ) eclipseAddresses.insert( historyAddr ); + } + } + } + + auto newPlot = RicSummaryPlotBuilder::createPlot( eclipseAddresses, selectedCases, selectedEnsembles ); + + std::vector plots{ newPlot }; + + RicSummaryPlotBuilder::createAndAppendSummaryMultiPlot( plots ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewSummaryMultiPlotFromDataVectorFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setText( "New Summary Plot" ); + actionToSetup->setIcon( QIcon( ":/SummaryPlotLight16x16.png" ) ); +} diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryMultiPlotFromDataVectorFeature.h b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryMultiPlotFromDataVectorFeature.h new file mode 100644 index 0000000000..860eba06c2 --- /dev/null +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryMultiPlotFromDataVectorFeature.h @@ -0,0 +1,37 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RicfCommandObject.h" + +#include "cafCmdFeature.h" + +//================================================================================================== +/// +//================================================================================================== +class RicNewSummaryMultiPlotFromDataVectorFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + // Overrides + bool isCommandEnabled() override; + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; +}; diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryPlotFromCurveFeature.cpp b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryPlotFromCurveFeature.cpp new file mode 100644 index 0000000000..0c517fc5d0 --- /dev/null +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryPlotFromCurveFeature.cpp @@ -0,0 +1,69 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicNewSummaryPlotFromCurveFeature.h" + +#include "RimSummaryCurve.h" +#include "RimSummaryPlot.h" + +#include "RicSummaryPlotBuilder.h" + +#include +#include + +CAF_CMD_SOURCE_INIT( RicNewSummaryPlotFromCurveFeature, "RicNewSummaryPlotFromCurveFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicNewSummaryPlotFromCurveFeature::isCommandEnabled() +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewSummaryPlotFromCurveFeature::onActionTriggered( bool isChecked ) +{ + QVariant userData = this->userData(); + if ( !userData.isNull() && userData.canConvert() ) + { + RimSummaryCurve* curve = static_cast( userData.value() ); + + auto curveCopy = + dynamic_cast( curve->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); + + curveCopy->setShowInLegend( true ); + + RimSummaryPlot* plot = RicSummaryPlotBuilder::createPlot( { curveCopy } ); + + std::vector plots = { plot }; + + RicSummaryPlotBuilder::createAndAppendSummaryMultiPlot( plots ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewSummaryPlotFromCurveFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setText( "New Summary Plot from Curve" ); + actionToSetup->setIcon( QIcon( ":/SummaryPlotLight16x16.png" ) ); +} diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryPlotFromCurveFeature.h b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryPlotFromCurveFeature.h new file mode 100644 index 0000000000..31bdf6aa9e --- /dev/null +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryPlotFromCurveFeature.h @@ -0,0 +1,37 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RicfCommandObject.h" + +#include "cafCmdFeature.h" + +//================================================================================================== +/// +//================================================================================================== +class RicNewSummaryPlotFromCurveFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + // Overrides + bool isCommandEnabled() override; + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; +}; diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryPlotFromDataVectorFeature.cpp b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryPlotFromDataVectorFeature.cpp new file mode 100644 index 0000000000..3c1b52f5cf --- /dev/null +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryPlotFromDataVectorFeature.cpp @@ -0,0 +1,113 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicNewSummaryPlotFromDataVectorFeature.h" + +#include "RiaSummaryTools.h" +#include "RimSummaryAddress.h" +#include "RimSummaryPlot.h" + +#include "RicSummaryPlotBuilder.h" + +#include "RifEclipseSummaryAddress.h" + +#include "RiuPlotMainWindowTools.h" + +#include "cafSelectionManagerTools.h" +#include "cvfAssert.h" + +#include + +CAF_CMD_SOURCE_INIT( RicNewSummaryPlotFromDataVectorFeature, "RicNewSummaryPlotFromDataVectorFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicNewSummaryPlotFromDataVectorFeature::isCommandEnabled() +{ + std::vector selectedItems; + caf::SelectionManager::instance()->selectedItems( selectedItems ); + + std::vector selectedAddressItems = caf::selectedObjectsByType(); + + unsigned int nEnsembles = 0; + + for ( auto adr : selectedAddressItems ) + { + if ( adr->isEnsemble() ) nEnsembles++; + } + + bool bOk = ( selectedAddressItems.size() > 0 ); + if ( nEnsembles > 0 ) + { + bOk = bOk && ( nEnsembles == selectedItems.size() ); + } + bOk = bOk && ( selectedAddressItems.size() == selectedItems.size() ); + + return bOk; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewSummaryPlotFromDataVectorFeature::onActionTriggered( bool isChecked ) +{ + std::vector selectedAddressItems = caf::selectedObjectsByType(); + std::set caseIds; + std::set ensembleIds; + std::vector selectedCases; + std::set eclipseAddresses; + std::vector selectedEnsembles; + + bool isEnsemble = false; + + for ( auto adr : selectedAddressItems ) + { + eclipseAddresses.insert( adr->address() ); + caseIds.insert( adr->caseId() ); + ensembleIds.insert( adr->ensembleId() ); + isEnsemble = isEnsemble || adr->isEnsemble(); + } + + if ( isEnsemble ) + { + for ( auto id : ensembleIds ) + { + selectedEnsembles.push_back( RiaSummaryTools::ensembleById( id ) ); + } + } + else + { + for ( auto id : caseIds ) + { + selectedCases.push_back( RiaSummaryTools::summaryCaseById( id ) ); + } + } + + auto newPlot = RicSummaryPlotBuilder::createPlot( eclipseAddresses, selectedCases, selectedEnsembles ); + RicSummaryPlotBuilder::createAndAppendSingleSummaryMultiPlot( newPlot ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewSummaryPlotFromDataVectorFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setText( "New Summary Plot" ); + actionToSetup->setIcon( QIcon( ":/SummaryPlotLight16x16.png" ) ); +} diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryPlotFromDataVectorFeature.h b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryPlotFromDataVectorFeature.h new file mode 100644 index 0000000000..b9e65e2a45 --- /dev/null +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryPlotFromDataVectorFeature.h @@ -0,0 +1,36 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RicfCommandObject.h" + +#include "cafCmdFeature.h" + +//================================================================================================== +/// +//================================================================================================== +class RicNewSummaryPlotFromDataVectorFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + bool isCommandEnabled() override; + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; +}; diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicSplitMultiPlotFeature.cpp b/ApplicationLibCode/Commands/PlotBuilderCommands/RicSplitMultiPlotFeature.cpp new file mode 100644 index 0000000000..6bfa01c2d6 --- /dev/null +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicSplitMultiPlotFeature.cpp @@ -0,0 +1,117 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicSplitMultiPlotFeature.h" + +#include "RicSummaryPlotBuilder.h" + +#include "RimEnsembleCurveSet.h" +#include "RimSummaryAddress.h" +#include "RimSummaryCase.h" +#include "RimSummaryCurve.h" +#include "RimSummaryPlot.h" + +#include "RicSummaryPlotBuilder.h" + +#include "cafSelectionManager.h" +#include "cvfAssert.h" + +#include + +CAF_CMD_SOURCE_INIT( RicSplitMultiPlotFeature, "RicSplitMultiPlotFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicSplitMultiPlotFeature::isCommandEnabled() +{ + RimSummaryPlot* plot = getSelectedPlot(); + if ( plot ) + { + return ( ( plot->summaryCurves().size() > 1 ) || ( plot->curveSets().size() > 1 ) ); + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSplitMultiPlotFeature::onActionTriggered( bool isChecked ) +{ + RimSummaryPlot* plot = getSelectedPlot(); + if ( plot == nullptr ) return; + + std::vector objects = {}; + + for ( auto curve : plot->summaryCurves() ) + { + RimSummaryAddress* addr = RimSummaryAddress::wrapFileReaderAddress( curve->summaryAddressY() ); + addr->setCaseId( curve->summaryCaseY()->caseId() ); + objects.push_back( addr ); + } + + for ( auto curveSet : plot->curveSets() ) + { + RimSummaryAddress* addr = RimSummaryAddress::wrapFileReaderAddress( curveSet->summaryAddress() ); + addr->setEnsembleId( curveSet->ensembleId() ); + objects.push_back( addr ); + } + + RicSummaryPlotBuilder::createAndAppendSummaryMultiPlot( objects ); + + for ( auto object : objects ) + delete object; + + return; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSplitMultiPlotFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setText( "Split Into Single Curve Plots" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryPlot* RicSplitMultiPlotFeature::getSelectedPlot() +{ + RimSummaryPlot* plot = nullptr; + + if ( sender() ) + { + QVariant userData = this->userData(); + if ( !userData.isNull() && userData.canConvert() ) + { + plot = static_cast( userData.value() ); + } + } + + if ( plot == nullptr ) + { + std::vector selectedUiItems; + caf::SelectionManager::instance()->selectedItems( selectedUiItems ); + + if ( !selectedUiItems.empty() ) plot = dynamic_cast( selectedUiItems[0] ); + } + + return plot; +} diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicSplitMultiPlotFeature.h b/ApplicationLibCode/Commands/PlotBuilderCommands/RicSplitMultiPlotFeature.h new file mode 100644 index 0000000000..76a73aa853 --- /dev/null +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicSplitMultiPlotFeature.h @@ -0,0 +1,39 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +class RimSummaryPlot; + +//================================================================================================== +/// +//================================================================================================== +class RicSplitMultiPlotFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + bool isCommandEnabled() override; + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; + +private: + RimSummaryPlot* getSelectedPlot(); +}; diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicSummaryPlotBuilder.cpp b/ApplicationLibCode/Commands/PlotBuilderCommands/RicSummaryPlotBuilder.cpp new file mode 100644 index 0000000000..9e3dfcd53d --- /dev/null +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicSummaryPlotBuilder.cpp @@ -0,0 +1,656 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicSummaryPlotBuilder.h" + +#include "PlotTemplateCommands/RicSummaryPlotTemplateTools.h" +#include "SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.h" +#include "SummaryPlotCommands/RicSummaryPlotFeatureImpl.h" + +#include "RiaSummaryAddressAnalyzer.h" +#include "RiaSummaryTools.h" + +#include "RifEclipseSummaryAddress.h" +#include "RifReaderEclipseSummary.h" +#include "RifSummaryReaderInterface.h" + +#include "RiaPreferencesSummary.h" +#include "RimEnsembleCurveSet.h" +#include "RimEnsembleCurveSetCollection.h" +#include "RimMainPlotCollection.h" +#include "RimMultiPlot.h" +#include "RimMultiPlotCollection.h" +#include "RimPlot.h" +#include "RimProject.h" +#include "RimSaturationPressurePlot.h" +#include "RimSummaryCase.h" +#include "RimSummaryCaseCollection.h" +#include "RimSummaryCurve.h" +#include "RimSummaryMultiPlot.h" +#include "RimSummaryMultiPlotCollection.h" +#include "RimSummaryPlot.h" + +#include "RiuPlotMainWindowTools.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicSummaryPlotBuilder::RicSummaryPlotBuilder() + : m_individualPlotPerDataSource( false ) + , m_graphCurveGrouping( RicSummaryPlotBuilder::RicGraphCurveGrouping::NONE ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSummaryPlotBuilder::setDataSources( const std::vector& summaryCases, + const std::vector& ensembles ) +{ + m_summaryCases = summaryCases; + m_ensembles = ensembles; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSummaryPlotBuilder::setAddresses( const std::set& addresses ) +{ + m_addresses = addresses; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSummaryPlotBuilder::setIndividualPlotPerDataSource( bool enable ) +{ + m_individualPlotPerDataSource = enable; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSummaryPlotBuilder::setGrouping( RicGraphCurveGrouping groping ) +{ + m_graphCurveGrouping = groping; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RicSummaryPlotBuilder::createPlots() const +{ + std::vector plots; + + if ( m_individualPlotPerDataSource ) + { + if ( m_graphCurveGrouping == RicGraphCurveGrouping::SINGLE_CURVES ) + { + for ( const auto& adr : m_addresses ) + { + for ( auto summaryCase : m_summaryCases ) + { + auto plot = createPlot( { adr }, { summaryCase }, {} ); + plots.push_back( plot ); + } + + for ( auto ensemble : m_ensembles ) + { + auto plot = createPlot( { adr }, {}, { ensemble } ); + plots.push_back( plot ); + } + } + } + else if ( m_graphCurveGrouping == RicGraphCurveGrouping::CURVES_FOR_OBJECT ) + { + RiaSummaryAddressAnalyzer analyzer; + analyzer.appendAddresses( m_addresses ); + + auto groups = analyzer.addressesGroupedByObject(); + for ( const auto& group : groups ) + { + std::set addresses; + addresses.insert( group.begin(), group.end() ); + if ( addresses.empty() ) continue; + + for ( auto summaryCase : m_summaryCases ) + { + auto plot = createPlot( addresses, { summaryCase }, {} ); + plots.push_back( plot ); + } + + for ( auto ensemble : m_ensembles ) + { + auto plot = createPlot( addresses, {}, { ensemble } ); + plots.push_back( plot ); + } + } + } + else if ( m_graphCurveGrouping == RicGraphCurveGrouping::NONE ) + { + for ( auto summaryCase : m_summaryCases ) + { + auto plot = createPlot( m_addresses, { summaryCase }, {} ); + plots.push_back( plot ); + } + + for ( auto ensemble : m_ensembles ) + { + auto plot = createPlot( m_addresses, {}, { ensemble } ); + plots.push_back( plot ); + } + } + } + else // all data sources in same plot + { + if ( m_graphCurveGrouping == RicGraphCurveGrouping::SINGLE_CURVES ) + { + for ( const auto& adr : m_addresses ) + { + if ( !m_summaryCases.empty() ) + { + auto plot = createPlot( { adr }, m_summaryCases, {} ); + plots.push_back( plot ); + } + + if ( !m_ensembles.empty() ) + { + auto plot = createPlot( { adr }, {}, m_ensembles ); + plots.push_back( plot ); + } + } + } + else if ( m_graphCurveGrouping == RicGraphCurveGrouping::CURVES_FOR_OBJECT ) + { + RiaSummaryAddressAnalyzer analyzer; + analyzer.appendAddresses( m_addresses ); + + auto groups = analyzer.addressesGroupedByObject(); + for ( const auto& group : groups ) + { + std::set addresses; + addresses.insert( group.begin(), group.end() ); + if ( addresses.empty() ) continue; + + if ( !m_summaryCases.empty() ) + { + auto plot = createPlot( addresses, m_summaryCases, {} ); + plots.push_back( plot ); + } + + if ( !m_ensembles.empty() ) + { + auto plot = createPlot( addresses, {}, m_ensembles ); + plots.push_back( plot ); + } + } + } + else if ( m_graphCurveGrouping == RicGraphCurveGrouping::NONE ) + { + if ( !m_summaryCases.empty() ) + { + auto plot = createPlot( m_addresses, m_summaryCases, {} ); + plots.push_back( plot ); + } + + if ( !m_ensembles.empty() ) + { + auto plot = createPlot( m_addresses, {}, m_ensembles ); + plots.push_back( plot ); + } + } + } + + return plots; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::set RicSummaryPlotBuilder::addressesForSource( caf::PdmObject* summarySource ) +{ + auto ensemble = dynamic_cast( summarySource ); + if ( ensemble ) + { + return ensemble->ensembleSummaryAddresses(); + } + + auto sumCase = dynamic_cast( summarySource ); + if ( sumCase ) + { + auto reader = sumCase ? sumCase->summaryReader() : nullptr; + if ( reader ) + { + return reader->allResultAddresses(); + } + } + + return {}; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEnsembleCurveSet* RicSummaryPlotBuilder::createCurveSet( RimSummaryCaseCollection* ensemble, + const RifEclipseSummaryAddress& addr ) +{ + auto curveSet = new RimEnsembleCurveSet(); + + curveSet->setSummaryCaseCollection( ensemble ); + curveSet->setSummaryAddress( addr ); + + return curveSet; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryCurve* RicSummaryPlotBuilder::createCurve( RimSummaryCase* summaryCase, const RifEclipseSummaryAddress& addr ) +{ + auto curve = new RimSummaryCurve(); + + curve->setSummaryCaseY( summaryCase ); + curve->setSummaryAddressY( addr ); + + return curve; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RicSummaryPlotBuilder::duplicatePlots( const std::vector& sourcePlots ) +{ + std::vector plots; + + for ( auto plot : sourcePlots ) + { + auto copy = dynamic_cast( plot->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); + + { + // TODO: Workaround for fixing the PdmPointer in RimEclipseResultDefinition + // caf::PdmPointer m_eclipseCase; + // This pdmpointer must be changed to a ptrField + + auto saturationPressurePlotOriginal = dynamic_cast( plot ); + auto saturationPressurePlotCopy = dynamic_cast( copy ); + if ( saturationPressurePlotCopy && saturationPressurePlotOriginal ) + { + RimSaturationPressurePlot::fixPointersAfterCopy( saturationPressurePlotOriginal, + saturationPressurePlotCopy ); + } + } + + plots.push_back( copy ); + } + + return plots; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RicSummaryPlotBuilder::duplicateSummaryPlots( const std::vector& sourcePlots ) +{ + std::vector plots; + + for ( auto plot : sourcePlots ) + { + auto copy = + dynamic_cast( plot->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); + + if ( copy ) + { + plots.push_back( copy ); + } + } + + return plots; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimMultiPlot* RicSummaryPlotBuilder::createAndAppendMultiPlot( const std::vector& plots ) +{ + RimProject* project = RimProject::current(); + RimMultiPlotCollection* plotCollection = project->mainPlotCollection()->multiPlotCollection(); + + auto* plotWindow = new RimMultiPlot; + plotWindow->setMultiPlotTitle( QString( "Multi Plot %1" ).arg( plotCollection->multiPlots().size() + 1 ) ); + plotWindow->setAsPlotMdiWindow(); + plotCollection->addMultiPlot( plotWindow ); + + appendPlotsToMultiPlot( plotWindow, plots ); + + plotCollection->updateAllRequiredEditors(); + plotWindow->loadDataAndUpdate(); + + if ( !plots.empty() ) + { + RiuPlotMainWindowTools::selectAsCurrentItem( plots[0], true ); + } + else + { + RiuPlotMainWindowTools::selectAsCurrentItem( plotWindow, true ); + } + + return plotWindow; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryMultiPlot* + RicSummaryPlotBuilder::createAndAppendSummaryMultiPlot( const std::vector& objects ) +{ + RimProject* project = RimProject::current(); + RimSummaryMultiPlotCollection* plotCollection = project->mainPlotCollection()->summaryMultiPlotCollection(); + + auto* plotWindow = new RimSummaryMultiPlot; + plotWindow->setMultiPlotTitle( QString( "Multi Plot %1" ).arg( plotCollection->multiPlots().size() + 1 ) ); + plotWindow->setAsPlotMdiWindow(); + plotCollection->addSummaryMultiPlot( plotWindow ); + + plotWindow->handleDroppedObjects( objects ); + + plotCollection->updateAllRequiredEditors(); + plotWindow->loadDataAndUpdate(); + + if ( plotWindow->summaryPlots().size() == 1 ) + { + RiuPlotMainWindowTools::selectAsCurrentItem( plotWindow->summaryPlots()[0] ); + RiuPlotMainWindowTools::setExpanded( plotWindow->summaryPlots()[0], true ); + } + else + { + RiuPlotMainWindowTools::selectAsCurrentItem( plotWindow ); + RiuPlotMainWindowTools::setExpanded( plotWindow, true ); + } + + return plotWindow; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSummaryPlotBuilder::appendPlotsToMultiPlot( RimMultiPlot* multiPlot, const std::vector& plots ) +{ + for ( auto plot : plots ) + { + // Remove the current window controller, as this will be managed by the multi plot + // This must be done before adding the plot to the multi plot to ensure that the viewer widget is recreated + plot->revokeMdiWindowStatus(); + + multiPlot->addPlot( plot ); + + plot->resolveReferencesRecursively(); + plot->setShowWindow( true ); + + plot->loadDataAndUpdate(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryMultiPlot* + RicSummaryPlotBuilder::createAndAppendDefaultSummaryMultiPlot( const std::vector& cases, + const std::vector& ensembles, + bool skipCreationOfPlotBasedOnPreferences ) +{ + RiaPreferencesSummary* prefs = RiaPreferencesSummary::current(); + + if ( skipCreationOfPlotBasedOnPreferences && + prefs->defaultSummaryPlotType() == RiaPreferencesSummary::DefaultSummaryPlotType::NONE ) + return nullptr; + + if ( prefs->defaultSummaryPlotType() == RiaPreferencesSummary::DefaultSummaryPlotType::PLOT_TEMPLATES ) + { + RimSummaryMultiPlot* plotToSelect = nullptr; + bool ensembleTemplates = ( ensembles.size() > 0 ); + for ( auto& filename : prefs->defaultSummaryPlotTemplates( ensembleTemplates ) ) + { + plotToSelect = RicSummaryPlotTemplateTools::create( filename, cases, ensembles ); + } + + if ( plotToSelect ) return plotToSelect; + + if ( skipCreationOfPlotBasedOnPreferences ) + { + return plotToSelect; + } + } + + if ( skipCreationOfPlotBasedOnPreferences && prefs->defaultSummaryCurvesTextFilter().trimmed().isEmpty() ) + return nullptr; + + RimProject* project = RimProject::current(); + auto* plotCollection = project->mainPlotCollection()->summaryMultiPlotCollection(); + + auto* summaryMultiPlot = new RimSummaryMultiPlot(); + summaryMultiPlot->setAsPlotMdiWindow(); + plotCollection->addSummaryMultiPlot( summaryMultiPlot ); + + RimSummaryPlot* plot = new RimSummaryPlot(); + plot->setAsPlotMdiWindow(); + plot->enableAutoPlotTitle( true ); + + for ( auto sumCase : cases ) + { + RicSummaryPlotFeatureImpl::addDefaultCurvesToPlot( plot, sumCase ); + } + + for ( auto ensemble : ensembles ) + { + RicNewSummaryEnsembleCurveSetFeature::addDefaultCurveSets( plot, ensemble ); + } + + plot->applyDefaultCurveAppearances(); + plot->loadDataAndUpdate(); + + plotCollection->updateConnectedEditors(); + + appendPlotsToSummaryMultiPlot( summaryMultiPlot, { plot } ); + + summaryMultiPlot->setDefaultRangeAggregationSteppingDimension(); + + plotCollection->updateAllRequiredEditors(); + summaryMultiPlot->loadDataAndUpdate(); + summaryMultiPlot->updateAllRequiredEditors(); + + RiuPlotMainWindowTools::selectAsCurrentItem( plot ); + + return summaryMultiPlot; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryMultiPlot* RicSummaryPlotBuilder::createAndAppendSingleSummaryMultiPlotNoAutoSettings( RimSummaryPlot* plot ) +{ + RimProject* project = RimProject::current(); + auto* plotCollection = project->mainPlotCollection()->summaryMultiPlotCollection(); + + auto* summaryMultiPlot = new RimSummaryMultiPlot(); + summaryMultiPlot->setColumnCount( RiaDefines::ColumnCount::COLUMNS_1 ); + summaryMultiPlot->setRowCount( RiaDefines::RowCount::ROWS_1 ); + summaryMultiPlot->setAsPlotMdiWindow(); + + if ( !plot->autoPlotTitle() ) + { + // Move settings from the single summary plot to the multi plot, and disable auto titles + summaryMultiPlot->setAutoPlotTitle( false ); + summaryMultiPlot->setAutoSubPlotTitle( false ); + summaryMultiPlot->setMultiPlotTitleVisible( true ); + summaryMultiPlot->setMultiPlotTitle( plot->description() ); + + plot->setPlotTitleVisible( false ); + plot->setDescription( "" ); + } + + plotCollection->addSummaryMultiPlot( summaryMultiPlot ); + + appendPlotsToSummaryMultiPlot( summaryMultiPlot, { plot } ); + + plotCollection->updateAllRequiredEditors(); + summaryMultiPlot->loadDataAndUpdate(); + summaryMultiPlot->updateAllRequiredEditors(); + + RiuPlotMainWindowTools::selectAsCurrentItem( plot ); + + return summaryMultiPlot; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryMultiPlot* RicSummaryPlotBuilder::createAndAppendSummaryMultiPlot( const std::vector& plots ) +{ + RimProject* project = RimProject::current(); + auto* plotCollection = project->mainPlotCollection()->summaryMultiPlotCollection(); + + auto* summaryMultiPlot = new RimSummaryMultiPlot(); + summaryMultiPlot->setAsPlotMdiWindow(); + plotCollection->addSummaryMultiPlot( summaryMultiPlot ); + + appendPlotsToSummaryMultiPlot( summaryMultiPlot, plots ); + + summaryMultiPlot->setDefaultRangeAggregationSteppingDimension(); + + plotCollection->updateAllRequiredEditors(); + summaryMultiPlot->loadDataAndUpdate(); + summaryMultiPlot->updateAllRequiredEditors(); + summaryMultiPlot->zoomAll(); + + if ( !plots.empty() ) + { + RiuPlotMainWindowTools::selectAsCurrentItem( plots[0] ); + } + else + { + RiuPlotMainWindowTools::selectAsCurrentItem( summaryMultiPlot ); + } + + return summaryMultiPlot; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryMultiPlot* RicSummaryPlotBuilder::createAndAppendSingleSummaryMultiPlot( RimSummaryPlot* plot ) +{ + RimProject* project = RimProject::current(); + auto* plotCollection = project->mainPlotCollection()->summaryMultiPlotCollection(); + + auto* summaryMultiPlot = new RimSummaryMultiPlot(); + summaryMultiPlot->setColumnCount( RiaDefines::ColumnCount::COLUMNS_1 ); + summaryMultiPlot->setRowCount( RiaDefines::RowCount::ROWS_1 ); + summaryMultiPlot->setAsPlotMdiWindow(); + plotCollection->addSummaryMultiPlot( summaryMultiPlot ); + + appendPlotsToSummaryMultiPlot( summaryMultiPlot, { plot } ); + + summaryMultiPlot->setDefaultRangeAggregationSteppingDimension(); + + plotCollection->updateAllRequiredEditors(); + summaryMultiPlot->loadDataAndUpdate(); + summaryMultiPlot->updateAllRequiredEditors(); + + RiuPlotMainWindowTools::selectAsCurrentItem( plot ); + + return summaryMultiPlot; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSummaryPlotBuilder::appendPlotsToSummaryMultiPlot( RimSummaryMultiPlot* multiPlot, + const std::vector& plots ) +{ + multiPlot->startBatchAddOperation(); + for ( auto plot : plots ) + { + plot->revokeMdiWindowStatus(); + + multiPlot->addPlot( plot ); + + plot->resolveReferencesRecursively(); + plot->setShowWindow( true ); + } + multiPlot->endBatchAddOperation(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryPlot* RicSummaryPlotBuilder::createPlot( const std::vector& summaryCurves ) +{ + auto* plot = new RimSummaryPlot(); + plot->enableAutoPlotTitle( true ); + + for ( auto& curve : summaryCurves ) + { + plot->addCurveNoUpdate( curve ); + } + + plot->applyDefaultCurveAppearances(); + + return plot; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryPlot* RicSummaryPlotBuilder::createPlot( const std::set& addresses, + const std::vector& summaryCases, + const std::vector& ensembles ) +{ + auto* plot = new RimSummaryPlot(); + plot->enableAutoPlotTitle( true ); + + appendCurvesToPlot( plot, addresses, summaryCases, ensembles ); + + plot->applyDefaultCurveAppearances(); + + return plot; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSummaryPlotBuilder::appendCurvesToPlot( RimSummaryPlot* summaryPlot, + const std::set& addresses, + const std::vector& summaryCases, + const std::vector& ensembles ) +{ + for ( const auto& addr : addresses ) + { + for ( const auto ensemble : ensembles ) + { + auto curveSet = createCurveSet( ensemble, addr ); + summaryPlot->ensembleCurveSetCollection()->addCurveSet( curveSet ); + } + + for ( const auto summaryCase : summaryCases ) + { + auto curve = createCurve( summaryCase, addr ); + + summaryPlot->addCurveNoUpdate( curve ); + } + } +} diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicSummaryPlotBuilder.h b/ApplicationLibCode/Commands/PlotBuilderCommands/RicSummaryPlotBuilder.h new file mode 100644 index 0000000000..dba405e40a --- /dev/null +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicSummaryPlotBuilder.h @@ -0,0 +1,108 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +class RimPlot; +class RimMultiPlot; +class RifEclipseSummaryAddress; +class RimSummaryCase; +class RimSummaryCaseCollection; +class RimSummaryPlot; +class RimEnsembleCurveSet; +class RimSummaryCurve; +class RimSummaryMultiPlot; + +namespace caf +{ +class PdmObject; +class PdmObjectHandle; +} // namespace caf + +#include +#include + +//================================================================================================== +/// +//================================================================================================== +class RicSummaryPlotBuilder +{ +public: + enum class RicGraphCurveGrouping + { + SINGLE_CURVES, + CURVES_FOR_OBJECT, + NONE + }; + +public: + RicSummaryPlotBuilder(); + + void setDataSources( const std::vector& summaryCases, + const std::vector& ensembles ); + + void setAddresses( const std::set& addresses ); + + void setIndividualPlotPerDataSource( bool enable ); + void setGrouping( RicGraphCurveGrouping groping ); + + std::vector createPlots() const; + + // Static helper functions + static std::set addressesForSource( caf::PdmObject* summarySource ); + + static RimEnsembleCurveSet* createCurveSet( RimSummaryCaseCollection* ensemble, const RifEclipseSummaryAddress& addr ); + static RimSummaryCurve* createCurve( RimSummaryCase* summaryCase, const RifEclipseSummaryAddress& addr ); + + static std::vector duplicatePlots( const std::vector& plots ); + static std::vector duplicateSummaryPlots( const std::vector& plots ); + + static RimMultiPlot* createAndAppendMultiPlot( const std::vector& plots ); + static void appendPlotsToMultiPlot( RimMultiPlot* multiPlot, const std::vector& plots ); + + static RimSummaryMultiPlot* + createAndAppendDefaultSummaryMultiPlot( const std::vector& cases, + const std::vector& ensembles, + bool skipCreationOfPlotBasedOnPreferences = true ); + + static RimSummaryMultiPlot* createAndAppendSingleSummaryMultiPlotNoAutoSettings( RimSummaryPlot* plot ); + static RimSummaryMultiPlot* createAndAppendSingleSummaryMultiPlot( RimSummaryPlot* plot ); + static RimSummaryMultiPlot* createAndAppendSummaryMultiPlot( const std::vector& plots ); + static RimSummaryMultiPlot* createAndAppendSummaryMultiPlot( const std::vector& objects ); + static void appendPlotsToSummaryMultiPlot( RimSummaryMultiPlot* multiPlot, const std::vector& plots ); + + static RimSummaryPlot* createPlot( const std::vector& summaryCurves ); + + static RimSummaryPlot* createPlot( const std::set& addresses, + const std::vector& summaryCases, + const std::vector& ensembles ); + + static void appendCurvesToPlot( RimSummaryPlot* summaryPlot, + const std::set& addresses, + const std::vector& summaryCases, + const std::vector& ensembles ); + +private: + std::set m_addresses; + std::vector m_summaryCases; + std::vector m_ensembles; + + bool m_individualPlotPerDataSource; + + RicGraphCurveGrouping m_graphCurveGrouping; +}; diff --git a/ApplicationLibCode/Commands/PlotTemplateCommands/CMakeLists_files.cmake b/ApplicationLibCode/Commands/PlotTemplateCommands/CMakeLists_files.cmake index 82de557305..667b6c1e0d 100644 --- a/ApplicationLibCode/Commands/PlotTemplateCommands/CMakeLists_files.cmake +++ b/ApplicationLibCode/Commands/PlotTemplateCommands/CMakeLists_files.cmake @@ -1,21 +1,33 @@ set(SOURCE_GROUP_HEADER_FILES - ${CMAKE_CURRENT_LIST_DIR}/RicSavePlotTemplateFeature.h - ${CMAKE_CURRENT_LIST_DIR}/RicCreatePlotFromSelectionFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicSelectPlotTemplateUi.h ${CMAKE_CURRENT_LIST_DIR}/RicSummaryPlotTemplateTools.h ${CMAKE_CURRENT_LIST_DIR}/RicReloadPlotTemplatesFeature.h - ${CMAKE_CURRENT_LIST_DIR}/RicCreatePlotFromTemplateFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicCreatePlotFromTemplateByShortcutFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicSaveMultiPlotTemplateFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicSaveMultiPlotTemplateFeatureSettings.h + ${CMAKE_CURRENT_LIST_DIR}/RicCreateMultiPlotFromSelectionFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicRenamePlotTemplateFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicEditPlotTemplateFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicDeletePlotTemplateFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicSetAsDefaultTemplateFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicCreateNewPlotFromTemplateFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicSelectCaseOrEnsembleUi.h ) set(SOURCE_GROUP_SOURCE_FILES - ${CMAKE_CURRENT_LIST_DIR}/RicSavePlotTemplateFeature.cpp - ${CMAKE_CURRENT_LIST_DIR}/RicCreatePlotFromSelectionFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicSelectPlotTemplateUi.cpp ${CMAKE_CURRENT_LIST_DIR}/RicSummaryPlotTemplateTools.cpp ${CMAKE_CURRENT_LIST_DIR}/RicReloadPlotTemplatesFeature.cpp - ${CMAKE_CURRENT_LIST_DIR}/RicCreatePlotFromTemplateFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicCreatePlotFromTemplateByShortcutFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicSaveMultiPlotTemplateFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicSaveMultiPlotTemplateFeatureSettings.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicCreateMultiPlotFromSelectionFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicRenamePlotTemplateFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicEditPlotTemplateFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicDeletePlotTemplateFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicSetAsDefaultTemplateFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicCreateNewPlotFromTemplateFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicSelectCaseOrEnsembleUi.cpp ) list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) diff --git a/ApplicationLibCode/Commands/PlotTemplateCommands/RicCreatePlotFromTemplateFeature.cpp b/ApplicationLibCode/Commands/PlotTemplateCommands/RicCreateMultiPlotFromSelectionFeature.cpp similarity index 53% rename from ApplicationLibCode/Commands/PlotTemplateCommands/RicCreatePlotFromTemplateFeature.cpp rename to ApplicationLibCode/Commands/PlotTemplateCommands/RicCreateMultiPlotFromSelectionFeature.cpp index 0107fa75bc..7ee23337a1 100644 --- a/ApplicationLibCode/Commands/PlotTemplateCommands/RicCreatePlotFromTemplateFeature.cpp +++ b/ApplicationLibCode/Commands/PlotTemplateCommands/RicCreateMultiPlotFromSelectionFeature.cpp @@ -1,6 +1,6 @@ //////////////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2019- Equinor ASA +// Copyright (C) 2022 Equinor ASA // // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -16,48 +16,42 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RicCreatePlotFromTemplateFeature.h" +#include "RicCreateMultiPlotFromSelectionFeature.h" #include "RicSummaryPlotTemplateTools.h" -#include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" +#include "RimSummaryMultiPlot.h" -#include "cafSelectionManager.h" +#include "RiuPlotMainWindowTools.h" #include -CAF_CMD_SOURCE_INIT( RicCreatePlotFromTemplateFeature, "RicCreatePlotFromTemplateFeature" ); +CAF_CMD_SOURCE_INIT( RicCreateMultiPlotFromSelectionFeature, "RicCreateMultiPlotFromSelectionFeature" ); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RicCreatePlotFromTemplateFeature::isCommandEnabled() +bool RicCreateMultiPlotFromSelectionFeature::isCommandEnabled() { - bool anySummaryCases = !RicSummaryPlotTemplateTools::selectedSummaryCases().empty(); - bool anySummaryCaseCollections = !RicSummaryPlotTemplateTools::selectedSummaryCaseCollections().empty(); - - return ( anySummaryCases || anySummaryCaseCollections ); + return true; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicCreatePlotFromTemplateFeature::onActionTriggered( bool isChecked ) +void RicCreateMultiPlotFromSelectionFeature::onActionTriggered( bool isChecked ) { - QString fileName = userData().toString(); - auto sumCases = RicSummaryPlotTemplateTools::selectedSummaryCases(); - auto sumCaseCollections = RicSummaryPlotTemplateTools::selectedSummaryCaseCollections(); + QString fileName = RicSummaryPlotTemplateTools::selectPlotTemplatePath(); - RimSummaryPlot* newSummaryPlot = RicSummaryPlotTemplateTools::createPlotFromTemplateFile( fileName ); + auto newSummaryPlot = RicSummaryPlotTemplateTools::create( fileName ); - RicSummaryPlotTemplateTools::appendSummaryPlotToPlotCollection( newSummaryPlot, sumCases, sumCaseCollections ); + RiuPlotMainWindowTools::selectAsCurrentItem( newSummaryPlot ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicCreatePlotFromTemplateFeature::setupActionLook( QAction* actionToSetup ) +void RicCreateMultiPlotFromSelectionFeature::setupActionLook( QAction* actionToSetup ) { - actionToSetup->setText( "Create Plot from Template" ); + actionToSetup->setText( "Create Summary Plot from Template" ); actionToSetup->setIcon( QIcon( ":/SummaryTemplate16x16.png" ) ); } diff --git a/ApplicationLibCode/Commands/PlotTemplateCommands/RicCreatePlotFromSelectionFeature.h b/ApplicationLibCode/Commands/PlotTemplateCommands/RicCreateMultiPlotFromSelectionFeature.h similarity index 91% rename from ApplicationLibCode/Commands/PlotTemplateCommands/RicCreatePlotFromSelectionFeature.h rename to ApplicationLibCode/Commands/PlotTemplateCommands/RicCreateMultiPlotFromSelectionFeature.h index b8e17a84b9..13e98af48f 100644 --- a/ApplicationLibCode/Commands/PlotTemplateCommands/RicCreatePlotFromSelectionFeature.h +++ b/ApplicationLibCode/Commands/PlotTemplateCommands/RicCreateMultiPlotFromSelectionFeature.h @@ -1,6 +1,6 @@ //////////////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2019- Equinor ASA +// Copyright (C) 2022 Equinor ASA // // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -25,7 +25,7 @@ class RimSummaryCase; //================================================================================================== /// //================================================================================================== -class RicCreatePlotFromSelectionFeature : public caf::CmdFeature +class RicCreateMultiPlotFromSelectionFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; diff --git a/ApplicationLibCode/Commands/PlotTemplateCommands/RicCreateNewPlotFromTemplateFeature.cpp b/ApplicationLibCode/Commands/PlotTemplateCommands/RicCreateNewPlotFromTemplateFeature.cpp new file mode 100644 index 0000000000..659c2297ba --- /dev/null +++ b/ApplicationLibCode/Commands/PlotTemplateCommands/RicCreateNewPlotFromTemplateFeature.cpp @@ -0,0 +1,145 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicCreateNewPlotFromTemplateFeature.h" + +#include "PlotTemplates/RimPlotTemplateFileItem.h" + +#include "RiaGuiApplication.h" +#include "RiaPreferences.h" + +#include "RicSelectCaseOrEnsembleUi.h" +#include "RicSummaryPlotTemplateTools.h" + +#include "RimSummaryCase.h" +#include "RimSummaryCaseCollection.h" +#include "RimSummaryMultiPlot.h" + +#include "RiuPlotMainWindow.h" +#include "RiuPlotMainWindowTools.h" + +#include "cafPdmUiPropertyViewDialog.h" +#include "cafSelectionManager.h" + +#include +#include + +CAF_CMD_SOURCE_INIT( RicCreateNewPlotFromTemplateFeature, "RicCreateNewPlotFromTemplateFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicCreateNewPlotFromTemplateFeature::isCommandEnabled() +{ + std::vector uiItems; + caf::SelectionManager::instance()->selectedItems( uiItems ); + if ( uiItems.size() != 1 ) return false; + + RimPlotTemplateFileItem* file = dynamic_cast( uiItems[0] ); + return ( file != nullptr ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicCreateNewPlotFromTemplateFeature::onActionTriggered( bool isChecked ) +{ + std::vector uiItems; + caf::SelectionManager::instance()->selectedItems( uiItems ); + + if ( uiItems.size() != 1 ) return; + + RimPlotTemplateFileItem* file = dynamic_cast( uiItems[0] ); + if ( file == nullptr ) return; + + RimSummaryMultiPlot* plot = nullptr; + + if ( file->isEnsembleTemplate() ) + { + auto ensemble = selectEnsemble(); + if ( !ensemble ) return; + + plot = RicSummaryPlotTemplateTools::create( file->absoluteFilePath(), {}, { ensemble } ); + } + else + { + auto sumCase = selectSummaryCase(); + if ( !sumCase ) return; + + plot = RicSummaryPlotTemplateTools::create( file->absoluteFilePath(), { sumCase }, {} ); + } + + if ( plot != nullptr ) + { + RiaPreferences::current()->setLastUsedPlotTemplatePath( file->absoluteFilePath() ); + RiaPreferences::current()->writePreferencesToApplicationStore(); + } + + RiuPlotMainWindowTools::selectAsCurrentItem( plot ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicCreateNewPlotFromTemplateFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setText( "Create New Plot" ); + actionToSetup->setIcon( QIcon( ":/SummaryPlotLight16x16.png" ) ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryCase* RicCreateNewPlotFromTemplateFeature::selectSummaryCase() +{ + RiuPlotMainWindow* plotwindow = RiaGuiApplication::instance()->mainPlotWindow(); + RicSelectCaseOrEnsembleUi ui; + + ui.setEnsembleSelectionMode( false ); + + caf::PdmUiPropertyViewDialog propertyDialog( plotwindow, &ui, "Create New Plot - Select Summary Case", "" ); + propertyDialog.resize( QSize( 400, 200 ) ); + + if ( propertyDialog.exec() == QDialog::Accepted ) + { + return ui.selectedSummaryCase(); + } + + return nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryCaseCollection* RicCreateNewPlotFromTemplateFeature::selectEnsemble() +{ + RiuPlotMainWindow* plotwindow = RiaGuiApplication::instance()->mainPlotWindow(); + RicSelectCaseOrEnsembleUi ui; + + ui.setEnsembleSelectionMode( true ); + + caf::PdmUiPropertyViewDialog propertyDialog( plotwindow, &ui, "Create New Plot - Select Ensemble", "" ); + propertyDialog.resize( QSize( 400, 200 ) ); + + if ( propertyDialog.exec() == QDialog::Accepted ) + { + return ui.selectedEnsemble(); + } + + return nullptr; +} diff --git a/ApplicationLibCode/Commands/PlotTemplateCommands/RicSavePlotTemplateFeature.h b/ApplicationLibCode/Commands/PlotTemplateCommands/RicCreateNewPlotFromTemplateFeature.h similarity index 82% rename from ApplicationLibCode/Commands/PlotTemplateCommands/RicSavePlotTemplateFeature.h rename to ApplicationLibCode/Commands/PlotTemplateCommands/RicCreateNewPlotFromTemplateFeature.h index 35839b4b57..3712ec5be1 100644 --- a/ApplicationLibCode/Commands/PlotTemplateCommands/RicSavePlotTemplateFeature.h +++ b/ApplicationLibCode/Commands/PlotTemplateCommands/RicCreateNewPlotFromTemplateFeature.h @@ -1,6 +1,6 @@ //////////////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2019- Equinor ASA +// Copyright (C) 2022 Equinor ASA // // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -20,12 +20,13 @@ #include "cafCmdFeature.h" -class RimSummaryPlot; +class RimSummaryCase; +class RimSummaryCaseCollection; //================================================================================================== /// //================================================================================================== -class RicSavePlotTemplateFeature : public caf::CmdFeature +class RicCreateNewPlotFromTemplateFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; @@ -35,8 +36,6 @@ class RicSavePlotTemplateFeature : public caf::CmdFeature void setupActionLook( QAction* actionToSetup ) override; private: - static QString createTextFromObject( RimSummaryPlot* summaryPlot ); - -private: - RimSummaryPlot* selectedSummaryPlot() const; + RimSummaryCase* selectSummaryCase(); + RimSummaryCaseCollection* selectEnsemble(); }; diff --git a/ApplicationLibCode/Commands/PlotTemplateCommands/RicCreatePlotFromSelectionFeature.cpp b/ApplicationLibCode/Commands/PlotTemplateCommands/RicCreatePlotFromSelectionFeature.cpp deleted file mode 100644 index e16805e1ee..0000000000 --- a/ApplicationLibCode/Commands/PlotTemplateCommands/RicCreatePlotFromSelectionFeature.cpp +++ /dev/null @@ -1,68 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2019- 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 "RicCreatePlotFromSelectionFeature.h" - -#include "RiaGuiApplication.h" - -#include "RicSummaryPlotTemplateTools.h" - -#include "PlotTemplates/RimPlotTemplateFileItem.h" -#include "RimSummaryCase.h" - -#include "RiuPlotMainWindow.h" - -#include "cafPdmUiPropertyViewDialog.h" -#include "cafSelectionManager.h" - -#include - -CAF_CMD_SOURCE_INIT( RicCreatePlotFromSelectionFeature, "RicCreatePlotFromSelectionFeature" ); - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RicCreatePlotFromSelectionFeature::isCommandEnabled() -{ - bool anySummaryCases = !RicSummaryPlotTemplateTools::selectedSummaryCases().empty(); - bool anySummaryCaseCollections = !RicSummaryPlotTemplateTools::selectedSummaryCaseCollections().empty(); - - return ( anySummaryCases || anySummaryCaseCollections ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicCreatePlotFromSelectionFeature::onActionTriggered( bool isChecked ) -{ - QString fileName = RicSummaryPlotTemplateTools::selectPlotTemplatePath(); - auto sumCases = RicSummaryPlotTemplateTools::selectedSummaryCases(); - auto sumCaseCollections = RicSummaryPlotTemplateTools::selectedSummaryCaseCollections(); - - RimSummaryPlot* newSummaryPlot = RicSummaryPlotTemplateTools::createPlotFromTemplateFile( fileName ); - RicSummaryPlotTemplateTools::appendSummaryPlotToPlotCollection( newSummaryPlot, sumCases, sumCaseCollections ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicCreatePlotFromSelectionFeature::setupActionLook( QAction* actionToSetup ) -{ - actionToSetup->setText( "Create Plot from Template" ); - actionToSetup->setIcon( QIcon( ":/SummaryTemplate16x16.png" ) ); -} diff --git a/ApplicationLibCode/Commands/PlotTemplateCommands/RicCreatePlotFromTemplateByShortcutFeature.cpp b/ApplicationLibCode/Commands/PlotTemplateCommands/RicCreatePlotFromTemplateByShortcutFeature.cpp index 45f23e7789..1909f6e78d 100644 --- a/ApplicationLibCode/Commands/PlotTemplateCommands/RicCreatePlotFromTemplateByShortcutFeature.cpp +++ b/ApplicationLibCode/Commands/PlotTemplateCommands/RicCreatePlotFromTemplateByShortcutFeature.cpp @@ -23,11 +23,10 @@ #include "RicSummaryPlotTemplateTools.h" -#include "RimSummaryCase.h" +#include "RimSummaryMultiPlot.h" #include "RiuPlotMainWindow.h" - -#include "cafSelectionManager.h" +#include "RiuPlotMainWindowTools.h" #include #include @@ -40,10 +39,7 @@ CAF_CMD_SOURCE_INIT( RicCreatePlotFromTemplateByShortcutFeature, "RicCreatePlotF //-------------------------------------------------------------------------------------------------- bool RicCreatePlotFromTemplateByShortcutFeature::isCommandEnabled() { - bool anySummaryCases = !RicSummaryPlotTemplateTools::selectedSummaryCases().empty(); - bool anySummaryCaseCollections = !RicSummaryPlotTemplateTools::selectedSummaryCaseCollections().empty(); - - return ( anySummaryCases || anySummaryCaseCollections ); + return true; } //-------------------------------------------------------------------------------------------------- @@ -51,7 +47,7 @@ bool RicCreatePlotFromTemplateByShortcutFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicCreatePlotFromTemplateByShortcutFeature::onActionTriggered( bool isChecked ) { - QString fileName = RiaPreferences::current()->defaultPlotTemplateAbsolutePath(); + QString fileName = RiaPreferences::current()->lastUsedPlotTemplateAbsolutePath(); if ( !QFile::exists( fileName ) ) { @@ -70,11 +66,9 @@ void RicCreatePlotFromTemplateByShortcutFeature::onActionTriggered( bool isCheck fileName = fileNameSelectedInUi; } - auto sumCases = RicSummaryPlotTemplateTools::selectedSummaryCases(); - auto sumCaseCollections = RicSummaryPlotTemplateTools::selectedSummaryCaseCollections(); + auto newSummaryPlot = RicSummaryPlotTemplateTools::create( fileName ); - RimSummaryPlot* newSummaryPlot = RicSummaryPlotTemplateTools::createPlotFromTemplateFile( fileName ); - RicSummaryPlotTemplateTools::appendSummaryPlotToPlotCollection( newSummaryPlot, sumCases, sumCaseCollections ); + RiuPlotMainWindowTools::selectAsCurrentItem( newSummaryPlot ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/PlotTemplateCommands/RicDeletePlotTemplateFeature.cpp b/ApplicationLibCode/Commands/PlotTemplateCommands/RicDeletePlotTemplateFeature.cpp new file mode 100644 index 0000000000..b825ab508f --- /dev/null +++ b/ApplicationLibCode/Commands/PlotTemplateCommands/RicDeletePlotTemplateFeature.cpp @@ -0,0 +1,86 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicDeletePlotTemplateFeature.h" + +#include "PlotTemplates/RimPlotTemplateFileItem.h" + +#include "RicReloadPlotTemplatesFeature.h" + +#include "RiuPlotMainWindow.h" + +#include "cafSelectionManager.h" + +#include +#include +#include +#include +#include +#include + +CAF_CMD_SOURCE_INIT( RicDeletePlotTemplateFeature, "RicDeletePlotTemplateFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicDeletePlotTemplateFeature::isCommandEnabled() +{ + std::vector uiItems; + caf::SelectionManager::instance()->selectedItems( uiItems ); + if ( uiItems.size() != 1 ) return false; + + RimPlotTemplateFileItem* file = dynamic_cast( uiItems[0] ); + return ( file != nullptr ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicDeletePlotTemplateFeature::onActionTriggered( bool isChecked ) +{ + std::vector uiItems; + caf::SelectionManager::instance()->selectedItems( uiItems ); + + if ( uiItems.size() != 1 ) return; + + RimPlotTemplateFileItem* file = dynamic_cast( uiItems[0] ); + if ( file == nullptr ) return; + + QWidget* parent = RiuPlotMainWindow::instance(); + + QString question = "Do you want to delete the plot template file\n\n" + file->absoluteFilePath(); + + if ( QMessageBox::question( parent, "Delete Template File?", question ) == QMessageBox::No ) return; + + if ( !QFile::remove( file->absoluteFilePath() ) ) + { + QMessageBox::critical( parent, "Delete failed", "Unable to remove the selected plot template.", QMessageBox::Ok ); + return; + } + + RicReloadPlotTemplatesFeature::rebuildFromDisc(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicDeletePlotTemplateFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setText( "Delete" ); + actionToSetup->setIcon( QIcon( ":/Erase.png" ) ); +} diff --git a/ApplicationLibCode/Commands/PlotTemplateCommands/RicCreatePlotFromTemplateFeature.h b/ApplicationLibCode/Commands/PlotTemplateCommands/RicDeletePlotTemplateFeature.h similarity index 86% rename from ApplicationLibCode/Commands/PlotTemplateCommands/RicCreatePlotFromTemplateFeature.h rename to ApplicationLibCode/Commands/PlotTemplateCommands/RicDeletePlotTemplateFeature.h index e06ae25ab8..4a87f98d55 100644 --- a/ApplicationLibCode/Commands/PlotTemplateCommands/RicCreatePlotFromTemplateFeature.h +++ b/ApplicationLibCode/Commands/PlotTemplateCommands/RicDeletePlotTemplateFeature.h @@ -1,6 +1,6 @@ //////////////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2019- Equinor ASA +// Copyright (C) 2022 Equinor ASA // // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -20,15 +20,10 @@ #include "cafCmdFeature.h" -#include - -class RimSummaryCase; -class RimSummaryCaseCollection; - //================================================================================================== /// //================================================================================================== -class RicCreatePlotFromTemplateFeature : public caf::CmdFeature +class RicDeletePlotTemplateFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; diff --git a/ApplicationLibCode/Commands/PlotTemplateCommands/RicEditPlotTemplateFeature.cpp b/ApplicationLibCode/Commands/PlotTemplateCommands/RicEditPlotTemplateFeature.cpp new file mode 100644 index 0000000000..d83da0d050 --- /dev/null +++ b/ApplicationLibCode/Commands/PlotTemplateCommands/RicEditPlotTemplateFeature.cpp @@ -0,0 +1,91 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicEditPlotTemplateFeature.h" + +#include "RiaApplication.h" +#include "RiaLogging.h" + +#include "PlotTemplates/RimPlotTemplateFileItem.h" +#include "RimProject.h" + +#include "RiuPlotMainWindow.h" + +#include "cafSelectionManager.h" + +#include +#include +#include +#include +#include +#include + +CAF_CMD_SOURCE_INIT( RicEditPlotTemplateFeature, "RicEditPlotTemplateFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicEditPlotTemplateFeature::isCommandEnabled() +{ + std::vector uiItems; + caf::SelectionManager::instance()->selectedItems( uiItems ); + if ( uiItems.size() != 1 ) return false; + + RimPlotTemplateFileItem* file = dynamic_cast( uiItems[0] ); + return ( file != nullptr ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicEditPlotTemplateFeature::onActionTriggered( bool isChecked ) +{ + std::vector uiItems; + caf::SelectionManager::instance()->selectedItems( uiItems ); + + if ( uiItems.size() != 1 ) return; + + RimPlotTemplateFileItem* file = dynamic_cast( uiItems[0] ); + if ( file == nullptr ) return; + + RiaApplication* app = RiaApplication::instance(); + QString scriptEditor = app->scriptEditorPath(); + if ( !scriptEditor.isEmpty() ) + { + QStringList arguments; + arguments << file->absoluteFilePath(); + + QProcess* myProcess = new QProcess( this ); + myProcess->start( scriptEditor, arguments ); + + if ( !myProcess->waitForStarted( 1000 ) ) + { + RiaLogging::errorInMessageBox( RiuPlotMainWindow::instance(), + "Text editor", + "Failed to start text editor executable\n" + scriptEditor ); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicEditPlotTemplateFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setText( "Edit" ); +} diff --git a/ApplicationLibCode/Commands/PlotTemplateCommands/RicEditPlotTemplateFeature.h b/ApplicationLibCode/Commands/PlotTemplateCommands/RicEditPlotTemplateFeature.h new file mode 100644 index 0000000000..e348d29a27 --- /dev/null +++ b/ApplicationLibCode/Commands/PlotTemplateCommands/RicEditPlotTemplateFeature.h @@ -0,0 +1,34 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +//================================================================================================== +/// +//================================================================================================== +class RicEditPlotTemplateFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + bool isCommandEnabled() override; + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; +}; diff --git a/ApplicationLibCode/Commands/PlotTemplateCommands/RicReloadPlotTemplatesFeature.cpp b/ApplicationLibCode/Commands/PlotTemplateCommands/RicReloadPlotTemplatesFeature.cpp index 00fe5f571f..c23eaa11c5 100644 --- a/ApplicationLibCode/Commands/PlotTemplateCommands/RicReloadPlotTemplatesFeature.cpp +++ b/ApplicationLibCode/Commands/PlotTemplateCommands/RicReloadPlotTemplatesFeature.cpp @@ -36,7 +36,7 @@ void RicReloadPlotTemplatesFeature::rebuildFromDisc() RiaPreferences* prefs = RiaPreferences::current(); proj->setPlotTemplateFolders( prefs->plotTemplateFolders() ); - proj->rootPlotTemlateItem()->updateConnectedEditors(); + proj->rootPlotTemplateItem()->updateConnectedEditors(); } //-------------------------------------------------------------------------------------------------- @@ -61,5 +61,5 @@ void RicReloadPlotTemplatesFeature::onActionTriggered( bool isChecked ) void RicReloadPlotTemplatesFeature::setupActionLook( QAction* actionToSetup ) { actionToSetup->setText( "Reload Templates" ); - actionToSetup->setIcon( QIcon( ":/SummaryTemplate16x16.png" ) ); + actionToSetup->setIcon( QIcon( ":/Refresh.svg" ) ); } diff --git a/ApplicationLibCode/Commands/PlotTemplateCommands/RicReloadPlotTemplatesFeature.h b/ApplicationLibCode/Commands/PlotTemplateCommands/RicReloadPlotTemplatesFeature.h index c5c298de2d..4bb9f0c9e2 100644 --- a/ApplicationLibCode/Commands/PlotTemplateCommands/RicReloadPlotTemplatesFeature.h +++ b/ApplicationLibCode/Commands/PlotTemplateCommands/RicReloadPlotTemplatesFeature.h @@ -20,8 +20,6 @@ #include "cafCmdFeature.h" -class RimSummaryPlot; - //================================================================================================== /// //================================================================================================== diff --git a/ApplicationLibCode/Commands/PlotTemplateCommands/RicRenamePlotTemplateFeature.cpp b/ApplicationLibCode/Commands/PlotTemplateCommands/RicRenamePlotTemplateFeature.cpp new file mode 100644 index 0000000000..a180372d95 --- /dev/null +++ b/ApplicationLibCode/Commands/PlotTemplateCommands/RicRenamePlotTemplateFeature.cpp @@ -0,0 +1,98 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicRenamePlotTemplateFeature.h" + +#include "PlotTemplates/RimPlotTemplateFileItem.h" + +#include "RiuPlotMainWindow.h" + +#include "cafSelectionManager.h" + +#include +#include +#include +#include +#include +#include + +CAF_CMD_SOURCE_INIT( RicRenamePlotTemplateFeature, "RicRenamePlotTemplateFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicRenamePlotTemplateFeature::isCommandEnabled() +{ + std::vector uiItems; + caf::SelectionManager::instance()->selectedItems( uiItems ); + if ( uiItems.size() != 1 ) return false; + + RimPlotTemplateFileItem* file = dynamic_cast( uiItems[0] ); + return ( file != nullptr ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicRenamePlotTemplateFeature::onActionTriggered( bool isChecked ) +{ + std::vector uiItems; + caf::SelectionManager::instance()->selectedItems( uiItems ); + + if ( uiItems.size() != 1 ) return; + + RimPlotTemplateFileItem* file = dynamic_cast( uiItems[0] ); + if ( file == nullptr ) return; + + QFileInfo fi( file->absoluteFilePath() ); + + QWidget* parent = RiuPlotMainWindow::instance(); + + bool ok; + QString newname = + QInputDialog::getText( parent, "Rename Plot Template", "Enter new name:", QLineEdit::Normal, fi.baseName(), &ok ); + + if ( !ok ) return; + + newname = newname.trimmed(); + + if ( newname.isEmpty() || newname.contains( "/" ) || newname.contains( "\\" ) ) + { + QMessageBox::critical( parent, "Rename failed", "Invalid name given.", QMessageBox::Ok ); + return; + } + + QString newPath = fi.absolutePath() + "/" + newname + "." + fi.completeSuffix(); + + if ( !QFile::rename( file->absoluteFilePath(), newPath ) ) + { + QMessageBox::critical( parent, "Rename failed", "Unable to rename the selected plot template.", QMessageBox::Ok ); + return; + } + + file->setFilePath( newPath ); + file->updateConnectedEditors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicRenamePlotTemplateFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setText( "Rename" ); +} diff --git a/ApplicationLibCode/Commands/PlotTemplateCommands/RicRenamePlotTemplateFeature.h b/ApplicationLibCode/Commands/PlotTemplateCommands/RicRenamePlotTemplateFeature.h new file mode 100644 index 0000000000..ff978988ec --- /dev/null +++ b/ApplicationLibCode/Commands/PlotTemplateCommands/RicRenamePlotTemplateFeature.h @@ -0,0 +1,34 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +//================================================================================================== +/// +//================================================================================================== +class RicRenamePlotTemplateFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + bool isCommandEnabled() override; + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; +}; diff --git a/ApplicationLibCode/Commands/PlotTemplateCommands/RicSaveMultiPlotTemplateFeature.cpp b/ApplicationLibCode/Commands/PlotTemplateCommands/RicSaveMultiPlotTemplateFeature.cpp new file mode 100644 index 0000000000..57987ba5fc --- /dev/null +++ b/ApplicationLibCode/Commands/PlotTemplateCommands/RicSaveMultiPlotTemplateFeature.cpp @@ -0,0 +1,308 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicSaveMultiPlotTemplateFeature.h" + +#include "RicReloadPlotTemplatesFeature.h" +#include "RicSaveMultiPlotTemplateFeatureSettings.h" +#include "RicSummaryPlotTemplateTools.h" + +#include "RiaGuiApplication.h" +#include "RiaLogging.h" +#include "RiaPreferences.h" +#include "RiaSummaryAddressAnalyzer.h" +#include "RiaSummaryTools.h" + +#include "RimEnsembleCurveSet.h" +#include "RimEnsembleCurveSetCollection.h" +#include "RimProject.h" +#include "RimSummaryAddress.h" +#include "RimSummaryCurve.h" +#include "RimSummaryMultiPlot.h" +#include "RimSummaryPlot.h" + +#include "RiuFileDialogTools.h" +#include "RiuPlotMainWindow.h" + +#include "cafPdmObject.h" +#include "cafPdmUiPropertyViewDialog.h" +#include "cafSelectionManager.h" +#include "cafUtils.h" + +#include +#include +#include +#include + +CAF_CMD_SOURCE_INIT( RicSaveMultiPlotTemplateFeature, "RicSaveMultiPlotTemplateFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicSaveMultiPlotTemplateFeature::isCommandEnabled() +{ + if ( selectedSummaryPlot() ) return true; + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSaveMultiPlotTemplateFeature::onActionTriggered( bool isChecked ) +{ + if ( !selectedSummaryPlot() ) return; + + RiaGuiApplication* app = RiaGuiApplication::instance(); + + QString fallbackPath; + auto folders = app->preferences()->plotTemplateFolders(); + if ( !folders.empty() ) + { + // Use the last folder from preferences as the default fall back folder + fallbackPath = folders.back(); + } + + QString startPath = app->lastUsedDialogDirectoryWithFallback( "PLOT_TEMPLATE", fallbackPath ); + + QString templateCandidateName = caf::Utils::makeValidFileBasename( selectedSummaryPlot()->description() ); + + RicSaveMultiPlotTemplateFeatureSettings settings; + settings.setFilePath( startPath ); + settings.setName( templateCandidateName ); + + caf::PdmUiPropertyViewDialog propertyDialog( RiuPlotMainWindow::instance(), &settings, "Export Plot Template", "" ); + if ( propertyDialog.exec() != QDialog::Accepted ) return; + + auto plot = selectedSummaryPlot(); + if ( !plot ) return; + + plot->storeStepDimensionFromToolbar(); + + QString ext = ".rpt"; + if ( selectedSummaryPlot()->curveSets().size() > 0 ) ext = ".erpt"; + + QString fileName = settings.filePath() + "/" + settings.name() + ext; + if ( !fileName.isEmpty() ) + { + QFile exportFile( fileName ); + if ( !exportFile.open( QIODevice::WriteOnly | QIODevice::Text ) ) + { + RiaLogging::errorInMessageBox( nullptr, + "Save Plot Template", + QString( "Could not save to the file: %1" ).arg( fileName ) ); + return; + } + + QString objectAsText = createTextFromObject( selectedSummaryPlot(), settings ); + + QTextStream stream( &exportFile ); + stream << objectAsText; + + QString absPath = QFileInfo( fileName ).absolutePath(); + bool foundPathInPreferences = false; + for ( const auto& f : folders ) + { + if ( absPath.indexOf( f ) != -1 ) + { + foundPathInPreferences = true; + } + } + + if ( !foundPathInPreferences ) + { + QMessageBox msgBox; + msgBox.setIcon( QMessageBox::Question ); + + QString questionText; + questionText = QString( "The path is not part of the search path for templates.\n\nDo you want to append " + "the destination path to the search path?" ); + + msgBox.setText( questionText ); + msgBox.setStandardButtons( QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel ); + + int ret = msgBox.exec(); + if ( ret == QMessageBox::Yes ) + { + app->preferences()->appendPlotTemplateFolders( absPath ); + app->preferences()->writePreferencesToApplicationStore(); + } + } + + app->setLastUsedDialogDirectory( "PLOT_TEMPLATE", absPath ); + + RicReloadPlotTemplatesFeature::rebuildFromDisc(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicSaveMultiPlotTemplateFeature::createTextFromObject( RimSummaryMultiPlot* summaryPlot, + const RicSaveMultiPlotTemplateFeatureSettings& settings ) +{ + if ( !summaryPlot ) return {}; + + QString objectAsText = summaryPlot->writeObjectToXmlString(); + + RiaSummaryAddressAnalyzer analyzer; + + { + std::vector addresses; + { + std::set sourceStrings; + + const QString summaryFieldKeyword = RicSummaryPlotTemplateTools::summaryCaseFieldKeyword(); + for ( const auto& curve : summaryPlot->allCurves( RimSummaryDataSourceStepping::Axis::Y_AXIS ) ) + { + auto fieldHandle = curve->findField( summaryFieldKeyword ); + if ( fieldHandle ) + { + auto reference = + caf::PdmReferenceHelper::referenceFromFieldToObject( fieldHandle, curve->summaryCaseY() ); + + sourceStrings.insert( reference ); + } + + addresses.push_back( curve->summaryAddressY() ); + } + + replaceStrings( sourceStrings, + summaryFieldKeyword, + RicSummaryPlotTemplateTools::placeholderTextForSummaryCase(), + objectAsText ); + } + + { + std::set ensembleReferenceStrings; + + const QString summaryGroupFieldKeyword = RicSummaryPlotTemplateTools::summaryGroupFieldKeyword(); + + for ( const auto& curveSet : summaryPlot->curveSets() ) + { + auto fieldHandle = curveSet->findField( summaryGroupFieldKeyword ); + if ( fieldHandle ) + { + auto reference = + caf::PdmReferenceHelper::referenceFromFieldToObject( fieldHandle, + curveSet->summaryCaseCollection() ); + ensembleReferenceStrings.insert( reference ); + } + + addresses.push_back( curveSet->summaryAddress() ); + } + + replaceStrings( ensembleReferenceStrings, + summaryGroupFieldKeyword, + RicSummaryPlotTemplateTools::placeholderTextForSummaryGroup(), + objectAsText ); + } + + analyzer.appendAddresses( addresses ); + } + + RimSummaryAddress dummy; + + if ( settings.usePlacholderForWells() ) + { + std::set sourceStrings; + for ( const auto& wellName : analyzer.wellNames() ) + { + sourceStrings.insert( QString::fromStdString( wellName ) ); + } + + replaceStrings( sourceStrings, + dummy.keywordForCategory( RifEclipseSummaryAddress::SUMMARY_WELL ), + RicSummaryPlotTemplateTools::placeholderTextForWell(), + objectAsText ); + } + + if ( settings.usePlacholderForGroups() ) + { + std::set sourceStrings; + for ( const auto& groupName : analyzer.groupNames() ) + { + sourceStrings.insert( QString::fromStdString( groupName ) ); + } + + replaceStrings( sourceStrings, + dummy.keywordForCategory( RifEclipseSummaryAddress::SUMMARY_GROUP ), + RicSummaryPlotTemplateTools::placeholderTextForGroup(), + objectAsText ); + } + + if ( settings.usePlacholderForRegions() ) + { + std::vector regionNumbers; + for ( auto regNumber : analyzer.regionNumbers() ) + { + regionNumbers.push_back( regNumber ); + } + + for ( int i = 0; i < static_cast( regionNumbers.size() ); i++ ) + { + // Encode placeholder index. Use negative values below -1 to represent a placeholder index + int index = -( i + 2 ); + + QString fieldKeyword = dummy.keywordForCategory( RifEclipseSummaryAddress::SUMMARY_REGION ); + QString sourceString = QString( "<%1>%2" ).arg( fieldKeyword ).arg( regionNumbers[i] ); + QString replacementTextWithIndex = QString( "<%1>%2" ).arg( fieldKeyword ).arg( index ); + + objectAsText.replace( sourceString, replacementTextWithIndex ); + } + } + + return objectAsText; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSaveMultiPlotTemplateFeature::replaceStrings( const std::set& sourceStrings, + const QString& fieldKeyword, + const QString& placeholderText, + QString& objectAsText ) +{ + size_t index = 0; + for ( const auto& sourceString : sourceStrings ) + { + QString sourceTextWithTags = QString( "<%1>%2" ).arg( fieldKeyword ).arg( sourceString ); + + QString replacementTextWithIndex = + QString( "<%1>%2 %3" ).arg( fieldKeyword ).arg( placeholderText ).arg( index++ ); + + objectAsText.replace( sourceTextWithTags, replacementTextWithIndex ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSaveMultiPlotTemplateFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setText( "Save As Plot Template" ); + actionToSetup->setIcon( QIcon( ":/SummaryTemplate16x16.png" ) ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryMultiPlot* RicSaveMultiPlotTemplateFeature::selectedSummaryPlot() const +{ + return dynamic_cast( caf::SelectionManager::instance()->selectedItem() ); +} diff --git a/ApplicationLibCode/Commands/PlotTemplateCommands/RicSaveMultiPlotTemplateFeature.h b/ApplicationLibCode/Commands/PlotTemplateCommands/RicSaveMultiPlotTemplateFeature.h new file mode 100644 index 0000000000..0d4edbc861 --- /dev/null +++ b/ApplicationLibCode/Commands/PlotTemplateCommands/RicSaveMultiPlotTemplateFeature.h @@ -0,0 +1,51 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +#include + +class RimSummaryMultiPlot; +class RicSaveMultiPlotTemplateFeatureSettings; + +//================================================================================================== +/// +//================================================================================================== +class RicSaveMultiPlotTemplateFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + bool isCommandEnabled() override; + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; + +private: + static QString createTextFromObject( RimSummaryMultiPlot* summaryPlot, + const RicSaveMultiPlotTemplateFeatureSettings& settings ); + + static void replaceStrings( const std::set& sourceStrings, + const QString& fieldKeyword, + const QString& placeholderText, + QString& objectAsText ); + +private: + RimSummaryMultiPlot* selectedSummaryPlot() const; +}; diff --git a/ApplicationLibCode/Commands/PlotTemplateCommands/RicSaveMultiPlotTemplateFeatureSettings.cpp b/ApplicationLibCode/Commands/PlotTemplateCommands/RicSaveMultiPlotTemplateFeatureSettings.cpp new file mode 100644 index 0000000000..a0ce185a79 --- /dev/null +++ b/ApplicationLibCode/Commands/PlotTemplateCommands/RicSaveMultiPlotTemplateFeatureSettings.cpp @@ -0,0 +1,126 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// +#include "RicSaveMultiPlotTemplateFeatureSettings.h" +#include "cafPdmUiFilePathEditor.h" + +CAF_PDM_SOURCE_INIT( RicSaveMultiPlotTemplateFeatureSettings, "RicSaveMultiPlotTemplateFeatureSettings" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicSaveMultiPlotTemplateFeatureSettings::RicSaveMultiPlotTemplateFeatureSettings() +{ + CAF_PDM_InitObject( "Save Summary Plot", ":/CrossSection16x16.png" ); + + CAF_PDM_InitFieldNoDefault( &m_filePath, "FilePath", "File Path" ); + CAF_PDM_InitFieldNoDefault( &m_name, "Name", "Name" ); + + CAF_PDM_InitField( &m_persistObjectNameForWells, "PersistObjectNameWells", false, "Wells" ); + CAF_PDM_InitField( &m_persistObjectNameGroups, "PersistObjectNameGroups", false, "Groups" ); + CAF_PDM_InitField( &m_persistObjectNameRegions, "PersistObjectNameRegions", false, "Regions" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSaveMultiPlotTemplateFeatureSettings::setFilePath( const QString& filePath ) +{ + m_filePath = filePath; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicSaveMultiPlotTemplateFeatureSettings::filePath() const +{ + return m_filePath().path(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSaveMultiPlotTemplateFeatureSettings::setName( const QString& name ) +{ + m_name = name; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicSaveMultiPlotTemplateFeatureSettings::name() const +{ + return m_name(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicSaveMultiPlotTemplateFeatureSettings::usePlacholderForWells() const +{ + return !m_persistObjectNameForWells; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicSaveMultiPlotTemplateFeatureSettings::usePlacholderForGroups() const +{ + return !m_persistObjectNameGroups; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicSaveMultiPlotTemplateFeatureSettings::usePlacholderForRegions() const +{ + return !m_persistObjectNameRegions; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSaveMultiPlotTemplateFeatureSettings::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +{ + uiOrdering.add( &m_filePath ); + uiOrdering.add( &m_name ); + + { + auto group = uiOrdering.addNewGroup( "Persist Object Names" ); + group->setCollapsedByDefault( true ); + group->add( &m_persistObjectNameForWells ); + group->add( &m_persistObjectNameGroups ); + group->add( &m_persistObjectNameRegions ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSaveMultiPlotTemplateFeatureSettings::defineEditorAttribute( const caf::PdmFieldHandle* field, + QString uiConfigName, + caf::PdmUiEditorAttribute* attribute ) +{ + if ( field == &m_filePath ) + { + auto attr = dynamic_cast( attribute ); + if ( attr ) + { + attr->m_selectDirectory = true; + } + } +} diff --git a/ApplicationLibCode/Commands/PlotTemplateCommands/RicSaveMultiPlotTemplateFeatureSettings.h b/ApplicationLibCode/Commands/PlotTemplateCommands/RicSaveMultiPlotTemplateFeatureSettings.h new file mode 100644 index 0000000000..546a81fdb5 --- /dev/null +++ b/ApplicationLibCode/Commands/PlotTemplateCommands/RicSaveMultiPlotTemplateFeatureSettings.h @@ -0,0 +1,58 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafFilePath.h" +#include "cafPdmField.h" +#include "cafPdmObject.h" + +//================================================================================================== +/// +//================================================================================================== +class RicSaveMultiPlotTemplateFeatureSettings : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RicSaveMultiPlotTemplateFeatureSettings(); + + void setFilePath( const QString& filePath ); + QString filePath() const; + + void setName( const QString& name ); + QString name() const; + + bool usePlacholderForWells() const; + bool usePlacholderForGroups() const; + bool usePlacholderForRegions() const; + +private: + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + void defineEditorAttribute( const caf::PdmFieldHandle* field, + QString uiConfigName, + caf::PdmUiEditorAttribute* attribute ) override; + +private: + caf::PdmField m_filePath; + caf::PdmField m_name; + + caf::PdmField m_persistObjectNameForWells; + caf::PdmField m_persistObjectNameGroups; + caf::PdmField m_persistObjectNameRegions; +}; diff --git a/ApplicationLibCode/Commands/PlotTemplateCommands/RicSavePlotTemplateFeature.cpp b/ApplicationLibCode/Commands/PlotTemplateCommands/RicSavePlotTemplateFeature.cpp deleted file mode 100644 index 78947f3647..0000000000 --- a/ApplicationLibCode/Commands/PlotTemplateCommands/RicSavePlotTemplateFeature.cpp +++ /dev/null @@ -1,230 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2019- 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 "RicSavePlotTemplateFeature.h" - -#include "RicReloadPlotTemplatesFeature.h" -#include "RicSummaryPlotTemplateTools.h" - -#include "RiaGuiApplication.h" -#include "RiaLogging.h" -#include "RiaPreferences.h" -#include "RiaSummaryTools.h" - -#include "RimEnsembleCurveSet.h" -#include "RimEnsembleCurveSetCollection.h" -#include "RimProject.h" -#include "RimSummaryCurve.h" -#include "RimSummaryPlot.h" - -#include "RiuFileDialogTools.h" - -#include "cafPdmObject.h" -#include "cafSelectionManager.h" -#include "cafUtils.h" - -#include -#include -#include -#include - -CAF_CMD_SOURCE_INIT( RicSavePlotTemplateFeature, "RicSavePlotTemplateFeature" ); - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RicSavePlotTemplateFeature::isCommandEnabled() -{ - if ( selectedSummaryPlot() ) return true; - - return false; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicSavePlotTemplateFeature::onActionTriggered( bool isChecked ) -{ - if ( !selectedSummaryPlot() ) return; - - RiaGuiApplication* app = RiaGuiApplication::instance(); - - QString fallbackPath; - auto folders = app->preferences()->plotTemplateFolders(); - if ( !folders.empty() ) - { - // Use the last folder from preferences as the default fall back folder - fallbackPath = folders.back(); - } - - QString startPath = app->lastUsedDialogDirectoryWithFallback( "PLOT_TEMPLATE", fallbackPath ); - - QString templateCandidateName = caf::Utils::makeValidFileBasename( selectedSummaryPlot()->description() ); - - startPath = startPath + "/" + templateCandidateName + ".rpt"; - - QString fileName = RiuFileDialogTools::getSaveFileName( nullptr, - tr( "Save Plot Template To File" ), - startPath, - tr( "Plot Template Files (*.rpt);;All files(*.*)" ) ); - if ( !fileName.isEmpty() ) - { - QFile exportFile( fileName ); - if ( !exportFile.open( QIODevice::WriteOnly | QIODevice::Text ) ) - { - RiaLogging::error( QString( "Save Plot Template : Could not open the file: %1" ).arg( fileName ) ); - return; - } - - QString objectAsText = createTextFromObject( selectedSummaryPlot() ); - - QTextStream stream( &exportFile ); - stream << objectAsText; - - QString absPath = QFileInfo( fileName ).absolutePath(); - bool foundPathInPreferences = false; - for ( const auto& f : folders ) - { - if ( absPath.indexOf( f ) != -1 ) - { - foundPathInPreferences = true; - } - } - - if ( !foundPathInPreferences ) - { - QMessageBox msgBox; - msgBox.setIcon( QMessageBox::Question ); - - QString questionText; - questionText = QString( "The path is not part of the search path for templates.\n\nDo you want to append " - "the destination path to the search path?" ); - - msgBox.setText( questionText ); - msgBox.setStandardButtons( QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel ); - - int ret = msgBox.exec(); - if ( ret == QMessageBox::Yes ) - { - app->preferences()->appendPlotTemplateFolders( absPath ); - app->preferences()->writePreferencesToApplicationStore(); - } - } - - app->setLastUsedDialogDirectory( "PLOT_TEMPLATE", absPath ); - - RicReloadPlotTemplatesFeature::rebuildFromDisc(); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RicSavePlotTemplateFeature::createTextFromObject( RimSummaryPlot* summaryPlot ) -{ - if ( !summaryPlot ) return QString(); - - QString objectAsText = summaryPlot->writeObjectToXmlString(); - - caf::PdmObjectHandle* obj = - caf::PdmXmlObjectHandle::readUnknownObjectFromXmlString( objectAsText, - caf::PdmDefaultObjectFactory::instance(), - true ); - - RimSummaryPlot* newSummaryPlot = dynamic_cast( obj ); - if ( newSummaryPlot ) - { - { - std::set caseReferenceStrings; - - const QString summaryFieldKeyword = RicSummaryPlotTemplateTools::summaryCaseFieldKeyword(); - for ( const auto& curve : newSummaryPlot->summaryCurves() ) - { - auto fieldHandle = curve->findField( summaryFieldKeyword ); - if ( fieldHandle ) - { - auto reference = fieldHandle->xmlCapability()->referenceString(); - caseReferenceStrings.insert( reference ); - } - } - - size_t index = 0; - for ( const auto& s : caseReferenceStrings ) - { - QString placeholderText = RicSummaryPlotTemplateTools::placeholderTextForSummaryCase(); - QString caseName = QString( "%1 %2" ).arg( placeholderText ).arg( index++ ); - - objectAsText.replace( s, caseName ); - } - } - - { - std::set ensembleReferenceStrings; - - const QString summaryGroupFieldKeyword = RicSummaryPlotTemplateTools::summaryGroupFieldKeyword(); - - for ( const auto& curveSet : newSummaryPlot->ensembleCurveSetCollection()->curveSets() ) - { - auto fieldHandle = curveSet->findField( summaryGroupFieldKeyword ); - if ( fieldHandle ) - { - auto reference = fieldHandle->xmlCapability()->referenceString(); - ensembleReferenceStrings.insert( reference ); - } - } - - size_t index = 0; - for ( const auto& s : ensembleReferenceStrings ) - { - QString placeholderText = RicSummaryPlotTemplateTools::placeholderTextForSummaryGroup(); - QString ensembleName = QString( "%1 %2" ).arg( placeholderText ).arg( index++ ); - - objectAsText.replace( s, ensembleName ); - } - } - } - - delete obj; - - return objectAsText; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicSavePlotTemplateFeature::setupActionLook( QAction* actionToSetup ) -{ - actionToSetup->setText( "Save As Plot Template" ); - actionToSetup->setIcon( QIcon( ":/SummaryTemplate16x16.png" ) ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimSummaryPlot* RicSavePlotTemplateFeature::selectedSummaryPlot() const -{ - RimSummaryPlot* sumPlot = nullptr; - - caf::PdmObject* selObj = dynamic_cast( caf::SelectionManager::instance()->selectedItem() ); - if ( selObj ) - { - sumPlot = RiaSummaryTools::parentSummaryPlot( selObj ); - } - - return sumPlot; -} diff --git a/ApplicationLibCode/Commands/PlotTemplateCommands/RicSelectCaseOrEnsembleUi.cpp b/ApplicationLibCode/Commands/PlotTemplateCommands/RicSelectCaseOrEnsembleUi.cpp new file mode 100644 index 0000000000..f52619f36a --- /dev/null +++ b/ApplicationLibCode/Commands/PlotTemplateCommands/RicSelectCaseOrEnsembleUi.cpp @@ -0,0 +1,129 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicSelectCaseOrEnsembleUi.h" + +#include "RiaSummaryTools.h" + +#include "RimProject.h" +#include "RimSummaryCase.h" +#include "RimSummaryCaseCollection.h" + +CAF_PDM_SOURCE_INIT( RicSelectCaseOrEnsembleUi, "RicSelectCaseOrEnsembleUi" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicSelectCaseOrEnsembleUi::RicSelectCaseOrEnsembleUi() + : m_useEnsembleMode( false ) +{ + CAF_PDM_InitObject( "RicSelectCaseOrEnsembleUi" ); + + CAF_PDM_InitFieldNoDefault( &m_selectedSummaryCase, "SelectedSummaryCase", "Summary Case" ); + m_selectedSummaryCase.uiCapability()->setAutoAddingOptionFromValue( false ); + + CAF_PDM_InitFieldNoDefault( &m_selectedEnsemble, "SelectedEnsemble", "Ensemble" ); + m_selectedEnsemble.uiCapability()->setAutoAddingOptionFromValue( false ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSelectCaseOrEnsembleUi::setEnsembleSelectionMode( bool ensembleMode ) +{ + m_useEnsembleMode = ensembleMode; + + RimProject* proj = RimProject::current(); + + if ( ensembleMode ) + { + std::vector groups = proj->summaryGroups(); + + for ( RimSummaryCaseCollection* group : groups ) + { + if ( group->isEnsemble() ) + { + m_selectedEnsemble = group; + break; + } + } + } + else + { + std::vector cases = proj->allSummaryCases(); + if ( cases.size() > 0 ) m_selectedSummaryCase = cases.front(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList + RicSelectCaseOrEnsembleUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) +{ + QList options; + + if ( fieldNeedingOptions == &m_selectedSummaryCase ) + { + options = RiaSummaryTools::optionsForAllSummaryCases(); + } + else if ( fieldNeedingOptions == &m_selectedEnsemble ) + { + RimProject* proj = RimProject::current(); + std::vector groups = proj->summaryGroups(); + + for ( RimSummaryCaseCollection* group : groups ) + { + if ( group->isEnsemble() ) options.push_back( caf::PdmOptionItemInfo( group->name(), group ) ); + } + } + + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSelectCaseOrEnsembleUi::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +{ + if ( m_useEnsembleMode ) + uiOrdering.add( &m_selectedEnsemble ); + else + uiOrdering.add( &m_selectedSummaryCase ); + + uiOrdering.skipRemainingFields(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryCase* RicSelectCaseOrEnsembleUi::selectedSummaryCase() const +{ + if ( m_useEnsembleMode ) return nullptr; + + return m_selectedSummaryCase(); +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryCaseCollection* RicSelectCaseOrEnsembleUi::selectedEnsemble() const +{ + if ( !m_useEnsembleMode ) return nullptr; + + return m_selectedEnsemble(); +} diff --git a/ApplicationLibCode/Commands/PlotTemplateCommands/RicSelectCaseOrEnsembleUi.h b/ApplicationLibCode/Commands/PlotTemplateCommands/RicSelectCaseOrEnsembleUi.h new file mode 100644 index 0000000000..bbb77062e6 --- /dev/null +++ b/ApplicationLibCode/Commands/PlotTemplateCommands/RicSelectCaseOrEnsembleUi.h @@ -0,0 +1,56 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafPdmObject.h" +#include "cafPdmPtrField.h" + +#include +#include +#include + +class RimSummaryCase; +class RimSummaryCaseCollection; + +//================================================================================================== +/// +//================================================================================================== +class RicSelectCaseOrEnsembleUi : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RicSelectCaseOrEnsembleUi(); + + void setEnsembleSelectionMode( bool selectEnsemble ); + + RimSummaryCase* selectedSummaryCase() const; + RimSummaryCaseCollection* selectedEnsemble() const; + +protected: + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; + +private: + caf::PdmPtrField m_selectedSummaryCase; + caf::PdmPtrField m_selectedEnsemble; + + bool m_useEnsembleMode; +}; diff --git a/ApplicationLibCode/Commands/PlotTemplateCommands/RicSelectPlotTemplateUi.cpp b/ApplicationLibCode/Commands/PlotTemplateCommands/RicSelectPlotTemplateUi.cpp index 35a8dd5bbd..c471fdf4dd 100644 --- a/ApplicationLibCode/Commands/PlotTemplateCommands/RicSelectPlotTemplateUi.cpp +++ b/ApplicationLibCode/Commands/PlotTemplateCommands/RicSelectPlotTemplateUi.cpp @@ -27,7 +27,6 @@ #include "RimMainPlotCollection.h" #include "RimProject.h" #include "RimSummaryPlot.h" -#include "RimSummaryPlotCollection.h" #include "cafPdmUiTreeSelectionEditor.h" @@ -37,14 +36,30 @@ CAF_PDM_SOURCE_INIT( RicSelectPlotTemplateUi, "RicSelectPlotTemplateUi" ); /// //-------------------------------------------------------------------------------------------------- RicSelectPlotTemplateUi::RicSelectPlotTemplateUi() + : m_useMultiSelect( false ) { - CAF_PDM_InitObject( "RicSelectPlotTemplateUi", "", "", "" ); + CAF_PDM_InitObject( "RicSelectPlotTemplateUi" ); - CAF_PDM_InitFieldNoDefault( &m_selectedPlotTemplates, "SelectedPlotTemplates", "Plot Templates", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_selectedPlotTemplates, "SelectedPlotTemplates", "Plot Templates" ); m_selectedPlotTemplates.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); m_selectedPlotTemplates.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSelectPlotTemplateUi::setMultiSelectMode( bool multiSelect ) +{ + m_useMultiSelect = multiSelect; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSelectPlotTemplateUi::setInitialSelection( std::vector selectedTemplates ) +{ +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -66,14 +81,13 @@ std::vector RicSelectPlotTemplateUi::selectedPlotTempl //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList - RicSelectPlotTemplateUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) +QList RicSelectPlotTemplateUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; if ( fieldNeedingOptions == &m_selectedPlotTemplates ) { - auto plotTemplateRoot = RimProject::current()->rootPlotTemlateItem(); + auto plotTemplateRoot = RimProject::current()->rootPlotTemplateItem(); RimPlotTemplateFolderItem::appendOptionItemsForPlotTemplates( options, plotTemplateRoot ); } @@ -93,7 +107,7 @@ void RicSelectPlotTemplateUi::defineEditorAttribute( const caf::PdmFieldHandle* auto a = dynamic_cast( attribute ); if ( a ) { - a->singleSelectionMode = true; + a->singleSelectionMode = !m_useMultiSelect; } } } diff --git a/ApplicationLibCode/Commands/PlotTemplateCommands/RicSelectPlotTemplateUi.h b/ApplicationLibCode/Commands/PlotTemplateCommands/RicSelectPlotTemplateUi.h index c8ae4a1663..9b584027da 100644 --- a/ApplicationLibCode/Commands/PlotTemplateCommands/RicSelectPlotTemplateUi.h +++ b/ApplicationLibCode/Commands/PlotTemplateCommands/RicSelectPlotTemplateUi.h @@ -22,6 +22,9 @@ #include "cafPdmObject.h" #include "cafPdmPtrArrayField.h" +#include +#include + class RimPlotTemplateFileItem; class RimPlotTemplateFolderItem; @@ -35,11 +38,13 @@ class RicSelectPlotTemplateUi : public caf::PdmObject public: RicSelectPlotTemplateUi(); + void setMultiSelectMode( bool multiSelect ); + void setInitialSelection( std::vector selectedTemplates ); + std::vector selectedPlotTemplates(); private: - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, @@ -47,4 +52,5 @@ class RicSelectPlotTemplateUi : public caf::PdmObject private: caf::PdmPtrArrayField m_selectedPlotTemplates; + bool m_useMultiSelect; }; diff --git a/ApplicationLibCode/Commands/PlotTemplateCommands/RicSetAsDefaultTemplateFeature.cpp b/ApplicationLibCode/Commands/PlotTemplateCommands/RicSetAsDefaultTemplateFeature.cpp new file mode 100644 index 0000000000..b6a5b5b088 --- /dev/null +++ b/ApplicationLibCode/Commands/PlotTemplateCommands/RicSetAsDefaultTemplateFeature.cpp @@ -0,0 +1,87 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicSetAsDefaultTemplateFeature.h" + +#include "PlotTemplates/RimPlotTemplateFileItem.h" + +#include "RiaPreferencesSummary.h" + +#include "cafSelectionManager.h" + +#include +#include +#include +#include +#include +#include + +CAF_CMD_SOURCE_INIT( RicSetAsDefaultTemplateFeature, "RicSetAsDefaultTemplateFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicSetAsDefaultTemplateFeature::isCommandEnabled() +{ + return selectedTemplate() != nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSetAsDefaultTemplateFeature::onActionTriggered( bool isChecked ) +{ + RimPlotTemplateFileItem* file = selectedTemplate(); + if ( file == nullptr ) return; + + if ( isChecked ) + RiaPreferencesSummary::current()->addToDefaultPlotTemplates( file->absoluteFilePath() ); + else + RiaPreferencesSummary::current()->removeFromDefaultPlotTemplates( file->absoluteFilePath() ); + + file->updateIconState(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSetAsDefaultTemplateFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setText( "Default Template" ); + // actionToSetup->setIcon( QIcon( ":/SummaryTemplate16x16.png" ) ); + + RimPlotTemplateFileItem* file = selectedTemplate(); + if ( file != nullptr ) + { + actionToSetup->setCheckable( true ); + actionToSetup->setChecked( file->isDefaultTemplate() ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimPlotTemplateFileItem* RicSetAsDefaultTemplateFeature::selectedTemplate() +{ + std::vector uiItems; + caf::SelectionManager::instance()->selectedItems( uiItems ); + if ( uiItems.size() != 1 ) return nullptr; + + RimPlotTemplateFileItem* file = dynamic_cast( uiItems[0] ); + return file; +} diff --git a/ApplicationLibCode/Commands/PlotTemplateCommands/RicSetAsDefaultTemplateFeature.h b/ApplicationLibCode/Commands/PlotTemplateCommands/RicSetAsDefaultTemplateFeature.h new file mode 100644 index 0000000000..2aa56e6f33 --- /dev/null +++ b/ApplicationLibCode/Commands/PlotTemplateCommands/RicSetAsDefaultTemplateFeature.h @@ -0,0 +1,39 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +class RimPlotTemplateFileItem; + +//================================================================================================== +/// +//================================================================================================== +class RicSetAsDefaultTemplateFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + bool isCommandEnabled() override; + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; + +private: + RimPlotTemplateFileItem* selectedTemplate(); +}; diff --git a/ApplicationLibCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.cpp b/ApplicationLibCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.cpp index 6e526cc359..ef44991554 100644 --- a/ApplicationLibCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.cpp +++ b/ApplicationLibCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.cpp @@ -21,8 +21,10 @@ #include "RiaGuiApplication.h" #include "RiaLogging.h" #include "RiaPreferences.h" -#include "RiaSummaryCurveAnalyzer.h" +#include "RiaSummaryAddressAnalyzer.h" +#include "RiaSummaryTools.h" +#include "PlotBuilderCommands/RicSummaryPlotBuilder.h" #include "RicSelectPlotTemplateUi.h" #include "RifSummaryReaderInterface.h" @@ -33,10 +35,12 @@ #include "RimEnsembleCurveSetCollection.h" #include "RimMainPlotCollection.h" #include "RimProject.h" +#include "RimSummaryAddressCollection.h" #include "RimSummaryCase.h" #include "RimSummaryCurve.h" +#include "RimSummaryMultiPlot.h" +#include "RimSummaryMultiPlotCollection.h" #include "RimSummaryPlot.h" -#include "RimSummaryPlotCollection.h" #include "RiuPlotMainWindow.h" @@ -49,7 +53,7 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryPlot* RicSummaryPlotTemplateTools::createPlotFromTemplateFile( const QString& fileName ) +RimSummaryMultiPlot* RicSummaryPlotTemplateTools::createMultiPlotFromTemplateFile( const QString& fileName ) { QFile importFile( fileName ); if ( !importFile.open( QIODevice::ReadOnly | QIODevice::Text ) ) @@ -67,58 +71,212 @@ RimSummaryPlot* RicSummaryPlotTemplateTools::createPlotFromTemplateFile( const Q caf::PdmDefaultObjectFactory::instance(), true ); - auto* newSummaryPlot = dynamic_cast( obj ); - if ( newSummaryPlot ) + return dynamic_cast( obj ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryMultiPlot* RicSummaryPlotTemplateTools::create( const QString& fileName ) +{ + auto sumCases = RicSummaryPlotTemplateTools::selectedSummaryCases(); + auto sumCaseCollections = RicSummaryPlotTemplateTools::selectedSummaryCaseCollections(); + + auto summaryAddressCollections = RicSummaryPlotTemplateTools::selectedSummaryAddressCollections(); + + std::vector wellNames; + std::vector groupNames; + std::vector regions; + std::set caseSet; + std::set caseCollectionSet; + + if ( summaryAddressCollections.empty() ) + { + RiaSummaryAddressAnalyzer analyzer; + + if ( !sumCases.empty() ) + { + auto firstCase = sumCases.front(); + + analyzer.appendAddresses( firstCase->summaryReader()->allResultAddresses() ); + } + else if ( !sumCaseCollections.empty() ) + { + auto caseCollection = sumCaseCollections.front(); + + auto firstCase = caseCollection->firstSummaryCase(); + if ( firstCase != nullptr ) + { + analyzer.appendAddresses( firstCase->summaryReader()->allResultAddresses() ); + } + } + + if ( !analyzer.wellNames().empty() ) + wellNames.push_back( QString::fromStdString( *( analyzer.wellNames().begin() ) ) ); + if ( !analyzer.groupNames().empty() ) + groupNames.push_back( QString::fromStdString( *( analyzer.groupNames().begin() ) ) ); + if ( !analyzer.regionNumbers().empty() ) + regions.push_back( QString::number( *( analyzer.regionNumbers().begin() ) ) ); + } + else { - bool isTemplateBefore_2021_06 = !objectAsText.contains( "" ); - if ( isTemplateBefore_2021_06 ) + for ( auto a : summaryAddressCollections ) { - for ( auto c : newSummaryPlot->summaryAndEnsembleCurves() ) + if ( a->contentType() == RimSummaryAddressCollection::CollectionContentType::WELL ) { - // Special handling of appearance settings because we do not have any support for file version of - // plot templates - // https://github.com/OPM/ResInsight/issues/8257 - c->updateCurveAppearanceForFilesOlderThan_2021_06(); + wellNames.push_back( a->name() ); } + else if ( a->contentType() == RimSummaryAddressCollection::CollectionContentType::GROUP ) + { + groupNames.push_back( a->name() ); + } + else if ( a->contentType() == RimSummaryAddressCollection::CollectionContentType::REGION ) + { + regions.push_back( a->name() ); + } + + auto sumCase = RiaSummaryTools::summaryCaseById( a->caseId() ); + if ( sumCase ) caseSet.insert( sumCase ); + + auto ensemble = RiaSummaryTools::ensembleById( a->ensembleId() ); + if ( ensemble ) caseCollectionSet.insert( ensemble ); } + } - return newSummaryPlot; + for ( auto sumCase : caseSet ) + { + sumCases.push_back( sumCase ); + } + + for ( auto sumCaseCollection : caseCollectionSet ) + { + sumCaseCollections.push_back( sumCaseCollection ); } - delete obj; + auto proj = RimProject::current(); + auto collections = proj->mainPlotCollection()->summaryMultiPlotCollection(); - return nullptr; + auto newSummaryPlot = RicSummaryPlotTemplateTools::createMultiPlotFromTemplateFile( fileName ); + if ( !newSummaryPlot ) return nullptr; + + collections->addSummaryMultiPlot( newSummaryPlot ); + newSummaryPlot->resolveReferencesRecursively(); + + RicSummaryPlotTemplateTools::setValuesForPlaceholders( newSummaryPlot, + sumCases, + sumCaseCollections, + wellNames, + groupNames, + regions ); + newSummaryPlot->initAfterReadRecursively(); + newSummaryPlot->loadDataAndUpdate(); + + collections->updateConnectedEditors(); + + return newSummaryPlot; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicSummaryPlotTemplateTools::appendSummaryPlotToPlotCollection( - RimSummaryPlot* summaryPlot, - const std::vector& selectedSummaryCases, - const std::vector& selectedEnsembles ) +RimSummaryMultiPlot* RicSummaryPlotTemplateTools::create( const QString& fileName, + const std::vector& sumCases, + const std::vector& ensembles ) { - if ( !summaryPlot ) return; + std::vector wellNames; + std::vector groupNames; + std::vector regions; - if ( selectedSummaryCases.empty() && selectedEnsembles.empty() ) return; + RiaSummaryAddressAnalyzer analyzer; - RimSummaryPlotCollection* plotColl = RimProject::current()->mainPlotCollection()->summaryPlotCollection(); + if ( !sumCases.empty() ) + { + auto firstCase = sumCases.front(); - plotColl->addPlot( summaryPlot ); - summaryPlot->resolveReferencesRecursively(); - summaryPlot->initAfterReadRecursively(); + analyzer.appendAddresses( firstCase->summaryReader()->allResultAddresses() ); + } + else if ( !ensembles.empty() ) + { + auto caseCollection = ensembles.front(); + auto firstCase = caseCollection->firstSummaryCase(); + if ( firstCase != nullptr ) + { + analyzer.appendAddresses( firstCase->summaryReader()->allResultAddresses() ); + } + } + + if ( !analyzer.wellNames().empty() ) + wellNames.push_back( QString::fromStdString( *( analyzer.wellNames().begin() ) ) ); + if ( !analyzer.groupNames().empty() ) + groupNames.push_back( QString::fromStdString( *( analyzer.groupNames().begin() ) ) ); + if ( !analyzer.regionNumbers().empty() ) + regions.push_back( QString::number( *( analyzer.regionNumbers().begin() ) ) ); + + auto proj = RimProject::current(); + auto collections = proj->mainPlotCollection()->summaryMultiPlotCollection(); + + auto newSummaryPlot = RicSummaryPlotTemplateTools::createMultiPlotFromTemplateFile( fileName ); + if ( !newSummaryPlot ) return nullptr; + + collections->addSummaryMultiPlot( newSummaryPlot ); + newSummaryPlot->resolveReferencesRecursively(); + + RicSummaryPlotTemplateTools::setValuesForPlaceholders( newSummaryPlot, sumCases, ensembles, wellNames, groupNames, regions ); + newSummaryPlot->initAfterReadRecursively(); + newSummaryPlot->loadDataAndUpdate(); + collections->updateConnectedEditors(); + + return newSummaryPlot; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSummaryPlotTemplateTools::setValuesForPlaceholders( RimSummaryMultiPlot* summaryMultiPlot, + const std::vector& selectedSummaryCases, + const std::vector& selectedEnsembles, + const std::vector& wellNames, + const std::vector& groupNames, + const std::vector& regions ) + +{ + // Assumes this plot is inserted into the project. This is required when assigning the ptrFields + RimProject* proj = nullptr; + summaryMultiPlot->firstAncestorOfType( proj ); + CAF_ASSERT( proj ); + + auto plots = summaryMultiPlot->plots(); + for ( auto p : plots ) { - // Replace single summary curves data sources + auto summaryPlot = dynamic_cast( p ); + if ( summaryPlot ) + setValuesForPlaceholders( summaryPlot, selectedSummaryCases, selectedEnsembles, wellNames, groupNames, regions ); + } +} - auto summaryCurves = summaryPlot->summaryCurves(); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSummaryPlotTemplateTools::setValuesForPlaceholders( RimSummaryPlot* summaryPlot, + const std::vector& selectedSummaryCases, + const std::vector& selectedEnsembles, + const std::vector& wellNames, + const std::vector& groupNames, + const std::vector& regions ) +{ + // Assumes this plot is inserted into the project. This is required when assigning the ptrFields + RimProject* proj = nullptr; + summaryPlot->firstAncestorOfType( proj ); + CAF_ASSERT( proj ); - const QString summaryFieldKeyword = RicSummaryPlotTemplateTools::summaryCaseFieldKeyword(); + { + // Replace single summary curves data sources - int maximumIndexValue = -1; + auto summaryCurves = summaryPlot->allCurves( RimSummaryDataSourceStepping::Axis::Y_AXIS ); for ( const auto& curve : summaryCurves ) { - auto fieldHandle = curve->findField( summaryFieldKeyword ); + auto fieldHandle = curve->findField( RicSummaryPlotTemplateTools::summaryCaseFieldKeyword() ); if ( fieldHandle ) { bool conversionOk = false; @@ -128,62 +286,25 @@ void RicSummaryPlotTemplateTools::appendSummaryPlotToPlotCollection( int indexValue = RicSummaryPlotTemplateTools::findValueForKeyword( placeholderString, referenceString, &conversionOk ); - maximumIndexValue = std::max( maximumIndexValue, indexValue ); - if ( conversionOk && indexValue >= 0 && indexValue < static_cast( selectedSummaryCases.size() ) ) { auto summaryCaseY = selectedSummaryCases[static_cast( indexValue )]; curve->setSummaryCaseY( summaryCaseY ); - - auto currentAddressY = curve->summaryAddressY(); - if ( summaryCaseY->summaryReader() && !summaryCaseY->summaryReader()->hasAddress( currentAddressY ) ) - { - auto allAddresses = summaryCaseY->summaryReader()->allResultAddresses(); - - auto candidate = - RicSummaryPlotTemplateTools::firstAddressByQuantity( currentAddressY, allAddresses ); - if ( candidate.category() != RifEclipseSummaryAddress::SUMMARY_INVALID ) - { - curve->setSummaryAddressY( candidate ); - } - } } } - } - - if ( selectedSummaryCases.size() > static_cast( maximumIndexValue + 1 ) ) - { - // Use the curve style of the last curve in template, and duplicate this for remaining data sources - - if ( !summaryCurves.empty() ) - { - auto lastSummaryCurve = summaryCurves.back(); - - for ( size_t i = maximumIndexValue; i < selectedSummaryCases.size(); i++ ) - { - auto newCurve = - dynamic_cast( lastSummaryCurve->xmlCapability()->copyByXmlSerialization( - caf::PdmDefaultObjectFactory::instance() ) ); - auto summaryCaseY = selectedSummaryCases[i]; - newCurve->setSummaryCaseY( summaryCaseY ); - summaryPlot->addCurveAndUpdate( newCurve ); - } - } + // Replace placeholders with object names from selection + auto curveAdr = curve->summaryAddressY(); + setPlaceholderWellName( &curveAdr, wellNames ); + setPlaceholderGroupName( &curveAdr, groupNames ); + setPlaceholderRegion( &curveAdr, regions ); + curve->setSummaryAddressY( curveAdr ); } - } - - { - // Replace ensemble data sources - - auto summaryCurveSets = summaryPlot->ensembleCurveSetCollection()->curveSets(); - - const QString summaryGroupFieldKeyword = RicSummaryPlotTemplateTools::summaryGroupFieldKeyword(); - int maximumIndexValue = -1; - - for ( const auto& curveSet : summaryCurveSets ) + for ( const auto& curveSet : summaryPlot->curveSets() ) { + const QString summaryGroupFieldKeyword = RicSummaryPlotTemplateTools::summaryGroupFieldKeyword(); + auto fieldHandle = curveSet->findField( summaryGroupFieldKeyword ); if ( fieldHandle ) { @@ -194,42 +315,21 @@ void RicSummaryPlotTemplateTools::appendSummaryPlotToPlotCollection( int indexValue = RicSummaryPlotTemplateTools::findValueForKeyword( placeholderString, referenceString, &conversionOk ); - maximumIndexValue = std::max( maximumIndexValue, indexValue ); - - if ( conversionOk && indexValue < static_cast( selectedEnsembles.size() ) ) + if ( conversionOk && indexValue >= 0 && indexValue < static_cast( selectedEnsembles.size() ) ) { - auto summaryCaseY = selectedEnsembles[indexValue]; - curveSet->setSummaryCaseCollection( summaryCaseY ); + auto ensembleCase = selectedEnsembles[static_cast( indexValue )]; + curveSet->setSummaryCaseCollection( ensembleCase ); } } - } - - if ( selectedEnsembles.size() > static_cast( maximumIndexValue + 1 ) ) - { - // Use the curve style of the last curve in template, and duplicate this for remaining data sources - - if ( !summaryCurveSets.empty() ) - { - auto lastSummaryCurveSet = summaryCurveSets.back(); - for ( size_t i = maximumIndexValue; i < selectedEnsembles.size(); i++ ) - { - auto newCurveSet = - dynamic_cast( lastSummaryCurveSet->xmlCapability()->copyByXmlSerialization( - caf::PdmDefaultObjectFactory::instance() ) ); - - auto ensembleDataSource = selectedEnsembles[i]; - newCurveSet->setSummaryCaseCollection( ensembleDataSource ); - - summaryPlot->ensembleCurveSetCollection()->addCurveSet( newCurveSet ); - } - } + // Replace placeholders with object names from selection + auto curveAdr = curveSet->summaryAddress(); + setPlaceholderWellName( &curveAdr, wellNames ); + setPlaceholderGroupName( &curveAdr, groupNames ); + setPlaceholderRegion( &curveAdr, regions ); + curveSet->setSummaryAddress( curveAdr ); } } - - plotColl->updateConnectedEditors(); - - summaryPlot->loadDataAndUpdate(); } //-------------------------------------------------------------------------------------------------- @@ -241,14 +341,14 @@ QString RicSummaryPlotTemplateTools::htmlTextFromPlotAndSelection( const RimSumm { QString text; - RiaSummaryCurveAnalyzer selectionAnalyzer; + RiaSummaryAddressAnalyzer selectionAnalyzer; selectionAnalyzer.appendAddresses( selectedSummaryAddresses ); if ( templatePlot ) { - std::set templateSources; - RiaSummaryCurveAnalyzer templateAnalyzer; + std::set templateSources; + RiaSummaryAddressAnalyzer templateAnalyzer; { std::set templateAddresses; @@ -287,11 +387,11 @@ QString RicSummaryPlotTemplateTools::htmlTextFromPlotAndSelection( const RimSumm text += htmlTextFromCount( itemText, requiredCount, selectedCount ); } - if ( !templateAnalyzer.wellGroupNames().empty() ) + if ( !templateAnalyzer.groupNames().empty() ) { - QString itemText = "Well Groups"; - size_t requiredCount = templateAnalyzer.wellGroupNames().size(); - size_t selectedCount = selectionAnalyzer.wellGroupNames().size(); + QString itemText = "Groups"; + size_t requiredCount = templateAnalyzer.groupNames().size(); + size_t selectedCount = selectionAnalyzer.groupNames().size(); text += htmlTextFromCount( itemText, requiredCount, selectedCount ); } @@ -345,13 +445,39 @@ QString RicSummaryPlotTemplateTools::selectPlotTemplatePath() { QString fileName = ui.selectedPlotTemplates().front()->absoluteFilePath(); - RiaPreferences::current()->setDefaultPlotTemplatePath( fileName ); + RiaPreferences::current()->setLastUsedPlotTemplatePath( fileName ); RiaPreferences::current()->writePreferencesToApplicationStore(); return fileName; } - return QString(); + return {}; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RicSummaryPlotTemplateTools::selectDefaultPlotTemplates( std::vector currentSelection ) +{ + RiuPlotMainWindow* plotwindow = RiaGuiApplication::instance()->mainPlotWindow(); + RicSelectPlotTemplateUi ui; + ui.setMultiSelectMode( true ); + ui.setInitialSelection( currentSelection ); + + caf::PdmUiPropertyViewDialog propertyDialog( plotwindow, &ui, "Select Default Plot Templates", "" ); + propertyDialog.resize( QSize( 500, 600 ) ); + + std::vector selection; + + if ( propertyDialog.exec() == QDialog::Accepted && !ui.selectedPlotTemplates().empty() ) + { + for ( auto item : ui.selectedPlotTemplates() ) + { + selection.push_back( item->absoluteFilePath() ); + } + } + + return selection; } //-------------------------------------------------------------------------------------------------- @@ -376,6 +502,17 @@ std::vector RicSummaryPlotTemplateTools::selectedSumm return objects; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RicSummaryPlotTemplateTools::selectedSummaryAddressCollections() +{ + std::vector objects; + caf::SelectionManager::instance()->objectsByType( &objects ); + + return objects; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -397,7 +534,7 @@ QString RicSummaryPlotTemplateTools::summaryGroupFieldKeyword() //-------------------------------------------------------------------------------------------------- QString RicSummaryPlotTemplateTools::placeholderTextForSummaryCase() { - return "CASE_NAME"; + return "__CASE_NAME__"; } //-------------------------------------------------------------------------------------------------- @@ -405,7 +542,23 @@ QString RicSummaryPlotTemplateTools::placeholderTextForSummaryCase() //-------------------------------------------------------------------------------------------------- QString RicSummaryPlotTemplateTools::placeholderTextForSummaryGroup() { - return "ENSEMBLE_NAME"; + return "__ENSEMBLE_NAME__"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicSummaryPlotTemplateTools::placeholderTextForWell() +{ + return "__WELL_NAME__"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicSummaryPlotTemplateTools::placeholderTextForGroup() +{ + return "__GROUP__"; } //-------------------------------------------------------------------------------------------------- @@ -417,13 +570,13 @@ RifEclipseSummaryAddress { for ( const auto& a : allAddresses ) { - if ( sourceAddress.quantityName() == a.quantityName() ) + if ( sourceAddress.vectorName() == a.vectorName() ) { return a; } } - return RifEclipseSummaryAddress(); + return {}; } //-------------------------------------------------------------------------------------------------- @@ -461,3 +614,63 @@ int RicSummaryPlotTemplateTools::findValueForKeyword( const QString& keyword, co return -1; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSummaryPlotTemplateTools::setPlaceholderWellName( RifEclipseSummaryAddress* summaryAddress, + const std::vector& wellNames ) +{ + if ( wellNames.empty() ) return; + + auto sourceWellName = QString::fromStdString( summaryAddress->wellName() ); + bool conversionOk = false; + const QString placeholderString = RicSummaryPlotTemplateTools::placeholderTextForWell(); + + int indexValue = RicSummaryPlotTemplateTools::findValueForKeyword( placeholderString, sourceWellName, &conversionOk ); + if ( conversionOk && indexValue >= 0 && indexValue < static_cast( wellNames.size() ) ) + { + summaryAddress->setWellName( wellNames[indexValue].toStdString() ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSummaryPlotTemplateTools::setPlaceholderGroupName( RifEclipseSummaryAddress* summaryAddress, + const std::vector& groupNames ) +{ + if ( groupNames.empty() ) return; + + auto sourceGroupName = QString::fromStdString( summaryAddress->groupName() ); + bool conversionOk = false; + const QString placeholderString = RicSummaryPlotTemplateTools::placeholderTextForGroup(); + + int indexValue = RicSummaryPlotTemplateTools::findValueForKeyword( placeholderString, sourceGroupName, &conversionOk ); + if ( conversionOk && indexValue >= 0 && indexValue < static_cast( groupNames.size() ) ) + { + summaryAddress->setGroupName( groupNames[indexValue].toStdString() ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSummaryPlotTemplateTools::setPlaceholderRegion( RifEclipseSummaryAddress* summaryAddress, + const std::vector& regions ) +{ + CAF_ASSERT( summaryAddress ); + if ( regions.empty() ) return; + + int indexValue = summaryAddress->regionNumber(); + if ( indexValue < -1 ) + { + indexValue = -( indexValue - 2 ); + + bool conversionOk = false; + if ( conversionOk && indexValue >= 0 && indexValue < static_cast( regions.size() ) ) + { + summaryAddress->setRegion( regions[indexValue].toInt() ); + } + } +} diff --git a/ApplicationLibCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.h b/ApplicationLibCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.h index 93166a6039..b6038dbcf2 100644 --- a/ApplicationLibCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.h +++ b/ApplicationLibCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.h @@ -32,6 +32,9 @@ class RimSummaryPlot; class RimSummaryCase; class RimSummaryCaseCollection; class RifEclipseSummaryAddress; +class RimSummaryMultiPlot; +class RimSummaryAddressCollection; +class RimPlotTemplateFileItem; //================================================================================================== /// @@ -39,30 +42,57 @@ class RifEclipseSummaryAddress; class RicSummaryPlotTemplateTools { public: - static RimSummaryPlot* createPlotFromTemplateFile( const QString& fileName ); - static void appendSummaryPlotToPlotCollection( RimSummaryPlot* summaryPlot, - const std::vector& selectedSummaryCases, - const std::vector& selectedEnsembles ); + static RimSummaryMultiPlot* create( const QString& fileName ); - static QString htmlTextFromPlotAndSelection( const RimSummaryPlot* templatePlot, - const std::set& selectedSummaryAddresses, - const std::vector& selectedSources ); - - static QString htmlTextFromCount( const QString& itemText, size_t requiredItemCount, size_t selectionCount ); - - static QString selectPlotTemplatePath(); + static RimSummaryMultiPlot* create( const QString& fileName, + const std::vector& cases, + const std::vector& ensembles ); - static std::vector selectedSummaryCases(); - static std::vector selectedSummaryCaseCollections(); + static QString selectPlotTemplatePath(); + static std::vector selectDefaultPlotTemplates( std::vector currentSelection ); static QString summaryCaseFieldKeyword(); static QString summaryGroupFieldKeyword(); + static QString placeholderTextForSummaryCase(); static QString placeholderTextForSummaryGroup(); + static QString placeholderTextForWell(); + static QString placeholderTextForGroup(); private: + static RimSummaryMultiPlot* createMultiPlotFromTemplateFile( const QString& fileName ); + + static std::vector selectedSummaryCases(); + static std::vector selectedSummaryCaseCollections(); + static std::vector selectedSummaryAddressCollections(); + + static QString htmlTextFromPlotAndSelection( const RimSummaryPlot* templatePlot, + + const std::set& selectedSummaryAddresses, + const std::vector& selectedSources ); + + static QString htmlTextFromCount( const QString& itemText, size_t requiredItemCount, size_t selectionCount ); + + static void setValuesForPlaceholders( RimSummaryMultiPlot* summaryMultiPlot, + const std::vector& selectedSummaryCases, + const std::vector& selectedEnsembles, + const std::vector& wellNames, + const std::vector& groupNames, + const std::vector& regions ); + + static void setValuesForPlaceholders( RimSummaryPlot* summaryPlot, + const std::vector& selectedSummaryCases, + const std::vector& selectedEnsembles, + const std::vector& wellNames, + const std::vector& groupNames, + const std::vector& regions ); + static RifEclipseSummaryAddress firstAddressByQuantity( const RifEclipseSummaryAddress& sourceAddress, const std::set& allAddresses ); static int findValueForKeyword( const QString& keyword, const QString& valueString, bool* ok ); + + static void setPlaceholderWellName( RifEclipseSummaryAddress* summaryAddress, const std::vector& wellNames ); + static void setPlaceholderGroupName( RifEclipseSummaryAddress* summaryAddress, const std::vector& groupNames ); + static void setPlaceholderRegion( RifEclipseSummaryAddress* summaryAddress, const std::vector& regions ); }; diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryCurveCalculatorWidgetCreator.cpp b/ApplicationLibCode/Commands/RicCalculatorWidgetCreator.cpp similarity index 85% rename from ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryCurveCalculatorWidgetCreator.cpp rename to ApplicationLibCode/Commands/RicCalculatorWidgetCreator.cpp index 97a3bc6b6e..704f63c887 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryCurveCalculatorWidgetCreator.cpp +++ b/ApplicationLibCode/Commands/RicCalculatorWidgetCreator.cpp @@ -16,10 +16,11 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RicSummaryCurveCalculatorWidgetCreator.h" +#include "RicCalculatorWidgetCreator.h" -#include "RicSummaryCurveCalculatorUi.h" -#include "RimSummaryCalculation.h" +#include "RimUserDefinedCalculation.h" + +#include "RicUserDefinedCalculatorUi.h" #include "cafPdmUiTableView.h" @@ -34,18 +35,17 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RicSummaryCurveCalculatorWidgetCreator::RicSummaryCurveCalculatorWidgetCreator() +RicCalculatorWidgetCreator::RicCalculatorWidgetCreator( std::unique_ptr calculator ) : m_pdmTableView( nullptr ) { - m_calculator = std::unique_ptr( new RicSummaryCurveCalculatorUi ); - + m_calculator = std::move( calculator ); this->setPdmObject( m_calculator.get() ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RicSummaryCurveCalculatorWidgetCreator::~RicSummaryCurveCalculatorWidgetCreator() +RicCalculatorWidgetCreator::~RicCalculatorWidgetCreator() { if ( m_pdmTableView ) { @@ -61,9 +61,8 @@ RicSummaryCurveCalculatorWidgetCreator::~RicSummaryCurveCalculatorWidgetCreator( //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicSummaryCurveCalculatorWidgetCreator::recursivelyConfigureAndUpdateTopLevelUiOrdering( - const caf::PdmUiOrdering& topLevelUiOrdering, - const QString& uiConfigName ) +void RicCalculatorWidgetCreator::recursivelyConfigureAndUpdateTopLevelUiOrdering( const caf::PdmUiOrdering& topLevelUiOrdering, + const QString& uiConfigName ) { if ( !m_firstRowLeftLayout || !m_firstRowRightLayout ) return; @@ -79,11 +78,11 @@ void RicSummaryCurveCalculatorWidgetCreator::recursivelyConfigureAndUpdateTopLev caf::PdmUiGroup* group = static_cast( topLevelUiItems[i] ); auto groupBox = updateGroupBoxWithContent( group, uiConfigName ); - if ( group->keyword() == RicSummaryCurveCalculatorUi::calculatedSummariesGroupName() ) + if ( group->keyword() == m_calculator->calculationsGroupName() ) { m_firstRowLeftLayout->addWidget( groupBox ); } - else if ( group->keyword() == RicSummaryCurveCalculatorUi::calulationGroupName() ) + else if ( group->keyword() == m_calculator->calulationGroupName() ) { m_firstRowRightLayout->insertWidget( layoutItemIndex++, groupBox ); } @@ -117,7 +116,7 @@ void RicSummaryCurveCalculatorWidgetCreator::recursivelyConfigureAndUpdateTopLev //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QWidget* RicSummaryCurveCalculatorWidgetCreator::createWidget( QWidget* parent ) +QWidget* RicCalculatorWidgetCreator::createWidget( QWidget* parent ) { m_pdmTableView = new caf::PdmUiTableView( parent ); m_pdmTableView->tableView()->setSelectionMode( QAbstractItemView::ExtendedSelection ); @@ -182,8 +181,7 @@ QWidget* RicSummaryCurveCalculatorWidgetCreator::createWidget( QWidget* parent ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QMinimizePanel* RicSummaryCurveCalculatorWidgetCreator::updateGroupBoxWithContent( caf::PdmUiGroup* group, - const QString& uiConfigName ) +QMinimizePanel* RicCalculatorWidgetCreator::updateGroupBoxWithContent( caf::PdmUiGroup* group, const QString& uiConfigName ) { QMinimizePanel* groupBox = findOrCreateGroupBox( this->widget(), group, uiConfigName ); @@ -194,7 +192,7 @@ QMinimizePanel* RicSummaryCurveCalculatorWidgetCreator::updateGroupBoxWithConten //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RicSummaryCurveCalculatorUi* RicSummaryCurveCalculatorWidgetCreator::calculator() const +RicUserDefinedCalculatorUi* RicCalculatorWidgetCreator::calculator() const { return m_calculator.get(); } @@ -202,7 +200,7 @@ RicSummaryCurveCalculatorUi* RicSummaryCurveCalculatorWidgetCreator::calculator( //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicSummaryCurveCalculatorWidgetCreator::slotCalculate() +void RicCalculatorWidgetCreator::slotCalculate() { m_calculator->calculate(); @@ -212,7 +210,7 @@ void RicSummaryCurveCalculatorWidgetCreator::slotCalculate() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicSummaryCurveCalculatorWidgetCreator::slotParseExpression() +void RicCalculatorWidgetCreator::slotParseExpression() { m_calculator->parseExpression(); diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryCurveCalculatorWidgetCreator.h b/ApplicationLibCode/Commands/RicCalculatorWidgetCreator.h similarity index 84% rename from ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryCurveCalculatorWidgetCreator.h rename to ApplicationLibCode/Commands/RicCalculatorWidgetCreator.h index 6353b41d7d..a13f7676b2 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryCurveCalculatorWidgetCreator.h +++ b/ApplicationLibCode/Commands/RicCalculatorWidgetCreator.h @@ -23,7 +23,7 @@ #include #include -class RicSummaryCurveCalculatorUi; +class RicUserDefinedCalculatorUi; class QMinimizePanel; class QString; @@ -41,15 +41,15 @@ class PdmUiTableView; /// /// //================================================================================================== -class RicSummaryCurveCalculatorWidgetCreator : public caf::PdmUiFormLayoutObjectEditor +class RicCalculatorWidgetCreator : public caf::PdmUiFormLayoutObjectEditor { Q_OBJECT public: - RicSummaryCurveCalculatorWidgetCreator(); - ~RicSummaryCurveCalculatorWidgetCreator() override; + RicCalculatorWidgetCreator( std::unique_ptr calculator ); + ~RicCalculatorWidgetCreator() override; - RicSummaryCurveCalculatorUi* calculator() const; + RicUserDefinedCalculatorUi* calculator() const; private: void recursivelyConfigureAndUpdateTopLevelUiOrdering( const caf::PdmUiOrdering& topLevelUiItems, @@ -72,5 +72,5 @@ private slots: caf::PdmUiTableView* m_pdmTableView; - std::unique_ptr m_calculator; + std::unique_ptr m_calculator; }; diff --git a/ApplicationLibCode/Commands/RicCloseCaseFeature.cpp b/ApplicationLibCode/Commands/RicCloseCaseFeature.cpp index 2fd9ee292b..4765ec620a 100644 --- a/ApplicationLibCode/Commands/RicCloseCaseFeature.cpp +++ b/ApplicationLibCode/Commands/RicCloseCaseFeature.cpp @@ -86,7 +86,7 @@ void RicCloseCaseFeature::onActionTriggered( bool isChecked ) { deleteEclipseCase( eclipseCase ); } - RiuMainWindow::instance()->cleanupGuiCaseClose(); + if ( RiuMainWindow::instance() ) RiuMainWindow::instance()->cleanupGuiCaseClose(); } } @@ -96,7 +96,7 @@ void RicCloseCaseFeature::onActionTriggered( bool isChecked ) { deleteGeoMechCase( geoMechCase ); } - RiuMainWindow::instance()->cleanupGuiCaseClose(); + if ( RiuMainWindow::instance() ) RiuMainWindow::instance()->cleanupGuiCaseClose(); } } @@ -152,7 +152,7 @@ void RicCloseCaseFeature::deleteEclipseCase( RimEclipseCase* eclipseCase ) RimIdenticalGridCaseGroup* caseGroup = caseCollection->parentCaseGroup(); CVF_ASSERT( caseGroup ); - caseGroup->statisticsCaseCollection()->reservoirs.removeChildObject( eclipseCase ); + caseGroup->statisticsCaseCollection()->reservoirs.removeChild( eclipseCase ); caseGroup->updateConnectedEditors(); } else @@ -165,7 +165,7 @@ void RicCloseCaseFeature::deleteEclipseCase( RimEclipseCase* eclipseCase ) if ( caseGroup->caseCollection()->reservoirs.size() == 1 ) { std::vector children; - caseGroup->statisticsCaseCollection()->reservoirs.childObjects( &children ); + caseGroup->statisticsCaseCollection()->reservoirs.children( &children ); for ( size_t i = children.size(); i-- > 0; ) { @@ -213,7 +213,7 @@ void RicCloseCaseFeature::deleteEclipseCase( RimEclipseCase* eclipseCase ) if ( cases.empty() ) { - project->multiSnapshotDefinitions.deleteAllChildObjects(); + project->multiSnapshotDefinitions.deleteChildren(); } else { diff --git a/ApplicationLibCode/Commands/RicCloseCaseFeature.h b/ApplicationLibCode/Commands/RicCloseCaseFeature.h index fcfad065bd..df38052c4f 100644 --- a/ApplicationLibCode/Commands/RicCloseCaseFeature.h +++ b/ApplicationLibCode/Commands/RicCloseCaseFeature.h @@ -40,7 +40,6 @@ class RicCloseCaseFeature : public caf::CmdFeature static bool userConfirmedGridCaseGroupChange( const std::vector& casesToBeDeleted ); protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/RicCloseObservedDataFeature.cpp b/ApplicationLibCode/Commands/RicCloseObservedDataFeature.cpp index 93be515e67..0b0f0da643 100644 --- a/ApplicationLibCode/Commands/RicCloseObservedDataFeature.cpp +++ b/ApplicationLibCode/Commands/RicCloseObservedDataFeature.cpp @@ -26,8 +26,9 @@ #include "RimObservedSummaryData.h" #include "RimProject.h" #include "RimRftPlotCollection.h" +#include "RimSummaryMultiPlot.h" +#include "RimSummaryMultiPlotCollection.h" #include "RimSummaryPlot.h" -#include "RimSummaryPlotCollection.h" #include "RimWellRftPlot.h" #include "cafSelectionManager.h" @@ -52,15 +53,18 @@ void RicCloseObservedDataFeature::setupActionLook( QAction* actionToSetup ) //-------------------------------------------------------------------------------------------------- void RicCloseObservedDataFeature::deleteObservedSummaryData( const std::vector& data ) { - RimSummaryPlotCollection* summaryPlotColl = RiaSummaryTools::summaryPlotCollection(); + RimSummaryMultiPlotCollection* summaryPlotColl = RiaSummaryTools::summaryMultiPlotCollection(); for ( RimObservedSummaryData* observedData : data ) { - for ( RimSummaryPlot* summaryPlot : summaryPlotColl->plots() ) + for ( RimSummaryMultiPlot* multiPlot : summaryPlotColl->multiPlots() ) { - summaryPlot->deleteCurvesAssosiatedWithCase( observedData ); + for ( RimSummaryPlot* summaryPlot : multiPlot->summaryPlots() ) + { + summaryPlot->deleteCurvesAssosiatedWithCase( observedData ); + } + multiPlot->updateConnectedEditors(); } - summaryPlotColl->updateConnectedEditors(); RimObservedDataCollection* observedDataCollection = nullptr; observedData->firstAncestorOrThisOfTypeAsserted( observedDataCollection ); diff --git a/ApplicationLibCode/Commands/RicCloseObservedDataFeature.h b/ApplicationLibCode/Commands/RicCloseObservedDataFeature.h index 5a9aa54e7b..f9e89c09b7 100644 --- a/ApplicationLibCode/Commands/RicCloseObservedDataFeature.h +++ b/ApplicationLibCode/Commands/RicCloseObservedDataFeature.h @@ -37,7 +37,6 @@ class RicCloseObservedDataFeature : public caf::CmdFeature static void deleteObservedRmuRftData( const std::vector& data ); protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/RicCloseSourSimDataFeature.h b/ApplicationLibCode/Commands/RicCloseSourSimDataFeature.h index c10d569330..2090c7cc95 100644 --- a/ApplicationLibCode/Commands/RicCloseSourSimDataFeature.h +++ b/ApplicationLibCode/Commands/RicCloseSourSimDataFeature.h @@ -30,7 +30,6 @@ class RicCloseSourSimDataFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/RicCloseSummaryCaseFeature.cpp b/ApplicationLibCode/Commands/RicCloseSummaryCaseFeature.cpp index eb8b8c3a17..69a8f0dd1f 100644 --- a/ApplicationLibCode/Commands/RicCloseSummaryCaseFeature.cpp +++ b/ApplicationLibCode/Commands/RicCloseSummaryCaseFeature.cpp @@ -25,8 +25,9 @@ #include "RimProject.h" #include "RimSummaryCase.h" #include "RimSummaryCaseMainCollection.h" +#include "RimSummaryMultiPlot.h" +#include "RimSummaryMultiPlotCollection.h" #include "RimSummaryPlot.h" -#include "RimSummaryPlotCollection.h" #include "RiuPlotMainWindow.h" @@ -54,24 +55,34 @@ void RicCloseSummaryCaseFeature::setupActionLook( QAction* actionToSetup ) //-------------------------------------------------------------------------------------------------- void RicCloseSummaryCaseFeature::deleteSummaryCases( std::vector& cases ) { - RimSummaryPlotCollection* summaryPlotColl = RiaSummaryTools::summaryPlotCollection(); - RimSummaryCaseMainCollection* summaryCaseMainCollection = RiaSummaryTools::summaryCaseMainCollection(); + RimSummaryMultiPlotCollection* summaryPlotColl = RiaSummaryTools::summaryMultiPlotCollection(); + RimSummaryCaseMainCollection* summaryCaseMainCollection = RiaSummaryTools::summaryCaseMainCollection(); + + std::set plotsToUpdate; for ( RimSummaryCase* summaryCase : cases ) { - for ( RimSummaryPlot* summaryPlot : summaryPlotColl->plots() ) + for ( RimSummaryMultiPlot* multiPlot : summaryPlotColl->multiPlots() ) { - summaryPlot->deleteCurvesAssosiatedWithCase( summaryCase ); + for ( RimSummaryPlot* summaryPlot : multiPlot->summaryPlots() ) + { + summaryPlot->deleteCurvesAssosiatedWithCase( summaryCase ); + } + plotsToUpdate.insert( multiPlot ); } - summaryPlotColl->updateConnectedEditors(); + } - summaryCaseMainCollection->removeCase( summaryCase ); + summaryCaseMainCollection->removeCases( cases ); + + for ( auto plot : plotsToUpdate ) + { + plot->updateConnectedEditors(); } summaryCaseMainCollection->updateAllRequiredEditors(); RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow(); - mainPlotWindow->updateSummaryPlotToolBar(); + mainPlotWindow->updateMultiPlotToolBar(); caf::AsyncPdmObjectVectorDeleter summaryCaseDeleter( cases ); CAF_ASSERT( cases.empty() ); // vector should be empty immediately. diff --git a/ApplicationLibCode/Commands/RicCloseSummaryCaseFeature.h b/ApplicationLibCode/Commands/RicCloseSummaryCaseFeature.h index c3ae8644c3..141158a304 100644 --- a/ApplicationLibCode/Commands/RicCloseSummaryCaseFeature.h +++ b/ApplicationLibCode/Commands/RicCloseSummaryCaseFeature.h @@ -36,7 +36,6 @@ class RicCloseSummaryCaseFeature : public caf::CmdFeature static void deleteSummaryCases( std::vector& cases ); protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/RicCloseSummaryCaseInCollectionFeature.cpp b/ApplicationLibCode/Commands/RicCloseSummaryCaseInCollectionFeature.cpp index 8a687c126e..06fa3973d6 100644 --- a/ApplicationLibCode/Commands/RicCloseSummaryCaseInCollectionFeature.cpp +++ b/ApplicationLibCode/Commands/RicCloseSummaryCaseInCollectionFeature.cpp @@ -29,7 +29,6 @@ #include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" #include "RimSummaryPlot.h" -#include "RimSummaryPlotCollection.h" #include "RiuPlotMainWindow.h" @@ -97,5 +96,5 @@ void RicCloseSummaryCaseInCollectionFeature::onActionTriggered( bool isChecked ) } RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow(); - mainPlotWindow->updateSummaryPlotToolBar(); + mainPlotWindow->updateMultiPlotToolBar(); } diff --git a/ApplicationLibCode/Commands/RicConvertGroupToEnsembleFeature.cpp b/ApplicationLibCode/Commands/RicConvertGroupToEnsembleFeature.cpp index 76f5c55b9f..7e2a619e77 100644 --- a/ApplicationLibCode/Commands/RicConvertGroupToEnsembleFeature.cpp +++ b/ApplicationLibCode/Commands/RicConvertGroupToEnsembleFeature.cpp @@ -32,13 +32,10 @@ #include "RimSummaryCase.h" #include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" -#include "RimSummaryPlotCollection.h" #include "RiuMainWindow.h" #include "RiuPlotMainWindow.h" -#include "SummaryPlotCommands/RicNewSummaryPlotFeature.h" - #include "cafSelectionManagerTools.h" #include diff --git a/ApplicationLibCode/Commands/RicConvertGroupToEnsembleFeature.h b/ApplicationLibCode/Commands/RicConvertGroupToEnsembleFeature.h index 6589f36c3b..412f1adaa2 100644 --- a/ApplicationLibCode/Commands/RicConvertGroupToEnsembleFeature.h +++ b/ApplicationLibCode/Commands/RicConvertGroupToEnsembleFeature.h @@ -32,7 +32,6 @@ class RicConvertGroupToEnsembleFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/RicCreateEnsembleSurfaceFeature.cpp b/ApplicationLibCode/Commands/RicCreateEnsembleSurfaceFeature.cpp index 9b1c31c497..60964df995 100644 --- a/ApplicationLibCode/Commands/RicCreateEnsembleSurfaceFeature.cpp +++ b/ApplicationLibCode/Commands/RicCreateEnsembleSurfaceFeature.cpp @@ -84,7 +84,8 @@ void RicCreateEnsembleSurfaceFeature::openDialogAndExecuteCommand() if ( propertyDialog.exec() == QDialog::Accepted ) { - executeCommand( *ui, result.files.toVector().toStdVector() ); + auto stdVector = std::vector( result.files.begin(), result.files.end() ); + executeCommand( *ui, stdVector ); } } diff --git a/ApplicationLibCode/Commands/RicCreateEnsembleSurfaceUi.cpp b/ApplicationLibCode/Commands/RicCreateEnsembleSurfaceUi.cpp index 198229fbad..558ed1f3ae 100644 --- a/ApplicationLibCode/Commands/RicCreateEnsembleSurfaceUi.cpp +++ b/ApplicationLibCode/Commands/RicCreateEnsembleSurfaceUi.cpp @@ -32,20 +32,17 @@ CAF_PDM_SOURCE_INIT( RicCreateEnsembleSurfaceUi, "RicCreateEnsembleSurfaceUi" ); //-------------------------------------------------------------------------------------------------- RicCreateEnsembleSurfaceUi::RicCreateEnsembleSurfaceUi() { - CAF_PDM_InitObject( "Export Multiple Surfaces", "", "", "" ); + CAF_PDM_InitObject( "Export Multiple Surfaces" ); - CAF_PDM_InitFieldNoDefault( &m_layers, "Layers", "Layers", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_layers, "Layers", "Layers" ); CAF_PDM_InitField( &m_autoCreateEnsembleSurfaces, "AutoCreateEnsembleSurfaces", false, - "Create Ensemble Surfaces From Exported Files", - "", - "", - "" ); + "Create Ensemble Surfaces From Exported Files" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_autoCreateEnsembleSurfaces ); - CAF_PDM_InitFieldNoDefault( &m_minLayer, "MinLayer", "MinLayer", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_maxLayer, "MaxLayer", "MaxLayer", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_minLayer, "MinLayer", "MinLayer" ); + CAF_PDM_InitFieldNoDefault( &m_maxLayer, "MaxLayer", "MaxLayer" ); m_tabNames << "Configuration"; } @@ -108,7 +105,7 @@ void RicCreateEnsembleSurfaceUi::defineUiOrdering( QString uiConfigName, caf::Pd /// //-------------------------------------------------------------------------------------------------- QList - RicCreateEnsembleSurfaceUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) + RicCreateEnsembleSurfaceUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; if ( fieldNeedingOptions == &m_layers ) diff --git a/ApplicationLibCode/Commands/RicCreateEnsembleSurfaceUi.h b/ApplicationLibCode/Commands/RicCreateEnsembleSurfaceUi.h index 95bc6dd1ee..471ac9a7d9 100644 --- a/ApplicationLibCode/Commands/RicCreateEnsembleSurfaceUi.h +++ b/ApplicationLibCode/Commands/RicCreateEnsembleSurfaceUi.h @@ -50,8 +50,7 @@ class RicCreateEnsembleSurfaceUi : public caf::PdmObject caf::PdmUiEditorAttribute* attribute ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; caf::PdmField> m_layers; caf::PdmField m_autoCreateEnsembleSurfaces; diff --git a/ApplicationLibCode/Commands/RicCreateEnsembleWellLogFeature.cpp b/ApplicationLibCode/Commands/RicCreateEnsembleWellLogFeature.cpp index d9ab651e14..ee672001d4 100644 --- a/ApplicationLibCode/Commands/RicCreateEnsembleWellLogFeature.cpp +++ b/ApplicationLibCode/Commands/RicCreateEnsembleWellLogFeature.cpp @@ -106,7 +106,8 @@ void RicCreateEnsembleWellLogFeature::openDialogAndExecuteCommand() if ( propertyDialog.exec() == QDialog::Accepted && !ui->properties().empty() ) { - executeCommand( *ui, result.files.toStdList() ); + auto stdList = std::list( result.files.begin(), result.files.end() ); + executeCommand( *ui, stdList ); } } diff --git a/ApplicationLibCode/Commands/RicCreateEnsembleWellLogUi.cpp b/ApplicationLibCode/Commands/RicCreateEnsembleWellLogUi.cpp index 7a7cc052aa..5c0686474b 100644 --- a/ApplicationLibCode/Commands/RicCreateEnsembleWellLogUi.cpp +++ b/ApplicationLibCode/Commands/RicCreateEnsembleWellLogUi.cpp @@ -55,22 +55,19 @@ void caf::AppEnum::setUp() //-------------------------------------------------------------------------------------------------- RicCreateEnsembleWellLogUi::RicCreateEnsembleWellLogUi() { - CAF_PDM_InitObject( "Create Ensemble Well Log", "", "", "" ); + CAF_PDM_InitObject( "Create Ensemble Well Log" ); CAF_PDM_InitField( &m_autoCreateEnsembleWellLogs, "AutoCreateEnsembleWellLogs", true, - "Create Ensemble Well Logs From Exported Files", - "", - "", - "" ); + "Create Ensemble Well Logs From Exported Files" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_autoCreateEnsembleWellLogs ); - CAF_PDM_InitField( &m_timeStep, "TimeStep", 0, "Time Step", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_wellPathSource, "WellPathSource", "Well Path Source", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_wellPath, "WellPath", "Well Path", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_wellFilePath, "WellFilePath", "Well File Path", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_selectedKeywords, "SelectedProperties", "Selected Properties", "", "", "" ); + CAF_PDM_InitField( &m_timeStep, "TimeStep", 0, "Time Step" ); + CAF_PDM_InitFieldNoDefault( &m_wellPathSource, "WellPathSource", "Well Path Source" ); + CAF_PDM_InitFieldNoDefault( &m_wellPath, "WellPath", "Well Path" ); + CAF_PDM_InitFieldNoDefault( &m_wellFilePath, "WellFilePath", "Well File Path" ); + CAF_PDM_InitFieldNoDefault( &m_selectedKeywords, "SelectedProperties", "Selected Properties" ); m_selectedKeywords.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); m_tabNames << "Well" @@ -120,7 +117,7 @@ void RicCreateEnsembleWellLogUi::defineUiOrdering( QString uiConfigName, caf::Pd /// //-------------------------------------------------------------------------------------------------- QList - RicCreateEnsembleWellLogUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) + RicCreateEnsembleWellLogUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; diff --git a/ApplicationLibCode/Commands/RicCreateEnsembleWellLogUi.h b/ApplicationLibCode/Commands/RicCreateEnsembleWellLogUi.h index 3fa77a06ec..518aeb63a4 100644 --- a/ApplicationLibCode/Commands/RicCreateEnsembleWellLogUi.h +++ b/ApplicationLibCode/Commands/RicCreateEnsembleWellLogUi.h @@ -66,8 +66,7 @@ class RicCreateEnsembleWellLogUi : public caf::PdmObject protected: void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; diff --git a/ApplicationLibCode/Commands/RicCreateSummaryCaseCollectionFeature.cpp b/ApplicationLibCode/Commands/RicCreateSummaryCaseCollectionFeature.cpp index 0257a0174a..814194cefe 100644 --- a/ApplicationLibCode/Commands/RicCreateSummaryCaseCollectionFeature.cpp +++ b/ApplicationLibCode/Commands/RicCreateSummaryCaseCollectionFeature.cpp @@ -18,6 +18,8 @@ #include "RicCreateSummaryCaseCollectionFeature.h" +#include "RiaSummaryTools.h" + #include "RimSummaryCase.h" #include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" @@ -38,11 +40,9 @@ RimSummaryCaseCollection* RicCreateSummaryCaseCollectionFeature::groupSummaryCas const QString& groupName, bool isEnsemble ) { - RimSummaryCaseMainCollection* summaryCaseMainCollection = nullptr; + RimSummaryCaseMainCollection* summaryCaseMainCollection = RiaSummaryTools::summaryCaseMainCollection(); if ( !cases.empty() ) { - cases[0]->firstAncestorOrThisOfTypeAsserted( summaryCaseMainCollection ); - auto newGroup = summaryCaseMainCollection->addCaseCollection( cases, groupName, isEnsemble ); summaryCaseMainCollection->updateConnectedEditors(); @@ -84,7 +84,17 @@ void RicCreateSummaryCaseCollectionFeature::onActionTriggered( bool isChecked ) caf::SelectionManager::instance()->objectsByType( &selection ); if ( selection.size() == 0 ) return; - groupSummaryCases( selection, "" ); + std::vector duplicates; + + for ( const auto sumCase : selection ) + { + auto copy = + dynamic_cast( sumCase->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); + + duplicates.push_back( copy ); + } + + groupSummaryCases( duplicates, "" ); } //-------------------------------------------------------------------------------------------------- @@ -92,6 +102,6 @@ void RicCreateSummaryCaseCollectionFeature::onActionTriggered( bool isChecked ) //-------------------------------------------------------------------------------------------------- void RicCreateSummaryCaseCollectionFeature::setupActionLook( QAction* actionToSetup ) { - actionToSetup->setText( "Group Summary Cases" ); + actionToSetup->setText( "Create Summary Case Group" ); actionToSetup->setIcon( QIcon( ":/SummaryGroup16x16.png" ) ); } diff --git a/ApplicationLibCode/Commands/RicDeleteItemExec.cpp b/ApplicationLibCode/Commands/RicDeleteItemExec.cpp index 52863ed379..19f4a932c5 100644 --- a/ApplicationLibCode/Commands/RicDeleteItemExec.cpp +++ b/ApplicationLibCode/Commands/RicDeleteItemExec.cpp @@ -52,7 +52,7 @@ void RicDeleteItemExec::redo() if ( listField ) { std::vector children; - listField->childObjects( &children ); + listField->children( &children ); caf::PdmObjectHandle* obj = children[m_commandData.m_indexToObject]; caf::SelectionManager::instance()->removeObjectFromAllSelections( obj ); diff --git a/ApplicationLibCode/Commands/RicDeleteItemExecData.h b/ApplicationLibCode/Commands/RicDeleteItemExecData.h index 94b26d141c..6acc458f65 100644 --- a/ApplicationLibCode/Commands/RicDeleteItemExecData.h +++ b/ApplicationLibCode/Commands/RicDeleteItemExecData.h @@ -37,8 +37,8 @@ class RicDeleteItemExecData : public caf::PdmObject "CmdDeleteItemExecData tooltip", "CmdDeleteItemExecData whatsthis" ); - CAF_PDM_InitFieldNoDefault( &m_pathToField, "PathToField", "PathToField", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_description, "Description", "Description", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_pathToField, "PathToField", "PathToField" ); + CAF_PDM_InitFieldNoDefault( &m_description, "Description", "Description" ); CAF_PDM_InitField( &m_indexToObject, "indexToObject", -1, diff --git a/ApplicationLibCode/Commands/RicDeleteItemFeature.cpp b/ApplicationLibCode/Commands/RicDeleteItemFeature.cpp index 291446d649..3cd8a0076b 100644 --- a/ApplicationLibCode/Commands/RicDeleteItemFeature.cpp +++ b/ApplicationLibCode/Commands/RicDeleteItemFeature.cpp @@ -80,7 +80,7 @@ void RicDeleteItemFeature::onActionTriggered( bool isChecked ) int indexAfter = -1; std::vector childObjects; - childArrayFieldHandle->childObjects( &childObjects ); + childArrayFieldHandle->children( &childObjects ); for ( size_t i = 0; i < childObjects.size(); i++ ) { diff --git a/ApplicationLibCode/Commands/RicDeleteItemFeature.h b/ApplicationLibCode/Commands/RicDeleteItemFeature.h index 3456c9bfce..399b113ffe 100644 --- a/ApplicationLibCode/Commands/RicDeleteItemFeature.h +++ b/ApplicationLibCode/Commands/RicDeleteItemFeature.h @@ -29,7 +29,6 @@ class RicDeleteItemFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/RicDeletePressureTableItemFeature.h b/ApplicationLibCode/Commands/RicDeletePressureTableItemFeature.h index fde622c8c0..4e160bdd7a 100644 --- a/ApplicationLibCode/Commands/RicDeletePressureTableItemFeature.h +++ b/ApplicationLibCode/Commands/RicDeletePressureTableItemFeature.h @@ -28,7 +28,6 @@ class RicDeletePressureTableItemFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/RicDeleteSubItemsFeature.cpp b/ApplicationLibCode/Commands/RicDeleteSubItemsFeature.cpp index 46a35c26f8..2a0863de91 100644 --- a/ApplicationLibCode/Commands/RicDeleteSubItemsFeature.cpp +++ b/ApplicationLibCode/Commands/RicDeleteSubItemsFeature.cpp @@ -19,8 +19,11 @@ #include "RicDeleteSubItemsFeature.h" #include "RimProject.h" -#include "RimSummaryPlotCollection.h" +#include "RimSummaryMultiPlot.h" +#include "RimSummaryMultiPlotCollection.h" +#include "RimWellPath.h" #include "RimWellPathCollection.h" +#include "RimWellPathFracture.h" #include "RimWellPathFractureCollection.h" #include "cafPdmUiItem.h" @@ -34,6 +37,14 @@ CAF_CMD_SOURCE_INIT( RicDeleteSubItemsFeature, "RicDeleteSubItemsFeature" ); /// //-------------------------------------------------------------------------------------------------- bool RicDeleteSubItemsFeature::isCommandEnabled() +{ + return RicDeleteSubItemsFeature::canCommandBeEnabled(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicDeleteSubItemsFeature::canCommandBeEnabled() { std::vector items; caf::SelectionManager::instance()->selectedItems( items ); @@ -53,50 +64,8 @@ bool RicDeleteSubItemsFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicDeleteSubItemsFeature::onActionTriggered( bool isChecked ) { - std::vector items; - caf::SelectionManager::instance()->selectedItems( items ); - - CVF_ASSERT( items.size() > 0 ); - - for ( auto item : items ) - { - if ( !RicDeleteSubItemsFeature::hasDeletableSubItems( item ) ) continue; - - { - auto collection = dynamic_cast( item ); - if ( collection ) - { - collection->deleteAllPlots(); - - collection->updateConnectedEditors(); - } - } - - { - auto collection = dynamic_cast( item ); - if ( collection ) - { - collection->deleteAllWellPaths(); - - collection->updateConnectedEditors(); - collection->scheduleRedrawAffectedViews(); - } - } - - { - auto collection = dynamic_cast( item ); - if ( collection ) - { - collection->deleteFractures(); - - collection->updateConnectedEditors(); - - RimProject* proj = nullptr; - collection->firstAncestorOrThisOfType( proj ); - if ( proj ) proj->reloadCompletionTypeResultsInAllViews(); - } - } - } + bool onlyUnchecked = false; + RicDeleteSubItemsFeature::deleteSubItems( onlyUnchecked ); } //-------------------------------------------------------------------------------------------------- @@ -115,8 +84,16 @@ void RicDeleteSubItemsFeature::setupActionLook( QAction* actionToSetup ) bool RicDeleteSubItemsFeature::hasDeletableSubItems( caf::PdmUiItem* uiItem ) { { - auto collection = dynamic_cast( uiItem ); - if ( collection && !collection->plots().empty() ) + auto multiPlot = dynamic_cast( uiItem ); + if ( multiPlot && !multiPlot->summaryPlots().empty() ) + { + return true; + } + } + + { + auto collection = dynamic_cast( uiItem ); + if ( collection && !collection->multiPlots().empty() ) { return true; } @@ -140,3 +117,116 @@ bool RicDeleteSubItemsFeature::hasDeletableSubItems( caf::PdmUiItem* uiItem ) return false; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicDeleteSubItemsFeature::deleteSubItems( bool onlyDeleteUnchecked ) +{ + std::vector items; + caf::SelectionManager::instance()->selectedItems( items ); + + CVF_ASSERT( items.size() > 0 ); + + for ( auto item : items ) + { + if ( !RicDeleteSubItemsFeature::hasDeletableSubItems( item ) ) continue; + + { + auto multiPlot = dynamic_cast( item ); + if ( multiPlot ) + { + if ( onlyDeleteUnchecked ) + { + auto plots = multiPlot->plots(); + for ( auto plot : plots ) + { + if ( plot->showWindow() ) continue; + multiPlot->removePlotNoUpdate( plot ); + delete plot; + } + } + else + { + multiPlot->deleteAllPlots(); + } + + multiPlot->updateConnectedEditors(); + } + } + + { + auto collection = dynamic_cast( item ); + if ( collection ) + { + if ( onlyDeleteUnchecked ) + { + auto plots = collection->multiPlots(); + for ( auto plot : plots ) + { + if ( plot->showWindow() ) continue; + collection->removePlotNoUpdate( plot ); + delete plot; + } + } + else + { + collection->deleteAllPlots(); + } + + collection->updateConnectedEditors(); + } + } + + { + auto collection = dynamic_cast( item ); + if ( collection ) + { + if ( onlyDeleteUnchecked ) + { + auto paths = collection->allWellPaths(); + for ( auto path : paths ) + { + if ( path->showWellPath() ) continue; + collection->removeWellPath( path ); + delete path; + } + } + else + { + collection->deleteAllWellPaths(); + } + + collection->updateConnectedEditors(); + collection->scheduleRedrawAffectedViews(); + } + } + + { + auto collection = dynamic_cast( item ); + if ( collection ) + { + if ( onlyDeleteUnchecked ) + { + auto items = collection->allFractures(); + for ( auto item : items ) + { + if ( item->isChecked() ) continue; + collection->removeFracture( item ); + delete item; + } + } + else + { + collection->deleteFractures(); + } + + collection->updateConnectedEditors(); + + RimProject* proj = nullptr; + collection->firstAncestorOrThisOfType( proj ); + if ( proj ) proj->reloadCompletionTypeResultsInAllViews(); + } + } + } +} diff --git a/ApplicationLibCode/Commands/RicDeleteSubItemsFeature.h b/ApplicationLibCode/Commands/RicDeleteSubItemsFeature.h index 0d2d26643d..2ae8ffe806 100644 --- a/ApplicationLibCode/Commands/RicDeleteSubItemsFeature.h +++ b/ApplicationLibCode/Commands/RicDeleteSubItemsFeature.h @@ -32,12 +32,13 @@ class RicDeleteSubItemsFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; +public: + static bool hasDeletableSubItems( caf::PdmUiItem* uiItem ); + static void deleteSubItems( bool onlyDeleteUnchecked ); + static bool canCommandBeEnabled(); + protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; - -private: - static bool hasDeletableSubItems( caf::PdmUiItem* uiItem ); }; diff --git a/ApplicationLibCode/Commands/RicDeleteSummaryCaseCollectionFeature.cpp b/ApplicationLibCode/Commands/RicDeleteSummaryCaseCollectionFeature.cpp index b7af5220a8..54af08a059 100644 --- a/ApplicationLibCode/Commands/RicDeleteSummaryCaseCollectionFeature.cpp +++ b/ApplicationLibCode/Commands/RicDeleteSummaryCaseCollectionFeature.cpp @@ -26,8 +26,9 @@ #include "RimSummaryCase.h" #include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" +#include "RimSummaryMultiPlot.h" +#include "RimSummaryMultiPlotCollection.h" #include "RimSummaryPlot.h" -#include "RimSummaryPlotCollection.h" #include "cafPdmObject.h" #include "cafSelectionManager.h" @@ -44,17 +45,19 @@ CAF_CMD_SOURCE_INIT( RicDeleteSummaryCaseCollectionFeature, "RicDeleteSummaryCas //-------------------------------------------------------------------------------------------------- void RicDeleteSummaryCaseCollectionFeature::deleteSummaryCaseCollection( RimSummaryCaseCollection* caseCollection ) { - RimSummaryPlotCollection* summaryPlotColl = RiaSummaryTools::summaryPlotCollection(); + RimSummaryMultiPlotCollection* summaryPlotColl = RiaSummaryTools::summaryMultiPlotCollection(); for ( RimSummaryCase* summaryCase : caseCollection->allSummaryCases() ) { - for ( RimSummaryPlot* summaryPlot : summaryPlotColl->plots() ) + for ( RimSummaryMultiPlot* multiPlot : summaryPlotColl->multiPlots() ) { - summaryPlot->deleteCurvesAssosiatedWithCase( summaryCase ); + for ( RimSummaryPlot* summaryPlot : multiPlot->summaryPlots() ) + { + summaryPlot->deleteCurvesAssosiatedWithCase( summaryCase ); + } + multiPlot->updateConnectedEditors(); } } - - summaryPlotColl->updateConnectedEditors(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/UserInterface/RiuRimQwtPlotCurve.cpp b/ApplicationLibCode/Commands/RicDeleteUncheckedSubItemsFeature.cpp similarity index 63% rename from ApplicationLibCode/UserInterface/RiuRimQwtPlotCurve.cpp rename to ApplicationLibCode/Commands/RicDeleteUncheckedSubItemsFeature.cpp index 77fbe027b3..32da49d4b3 100644 --- a/ApplicationLibCode/UserInterface/RiuRimQwtPlotCurve.cpp +++ b/ApplicationLibCode/Commands/RicDeleteUncheckedSubItemsFeature.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2018- Equinor ASA +// Copyright (C) 2022 Equinor ASA // // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -16,30 +16,39 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RiuRimQwtPlotCurve.h" -#include "RimPlotCurve.h" +#include "RicDeleteUncheckedSubItemsFeature.h" + +#include "RicDeleteSubItemsFeature.h" + +#include "cafPdmUiItem.h" +#include "cafSelectionManager.h" + +#include + +CAF_CMD_SOURCE_INIT( RicDeleteUncheckedSubItemsFeature, "RicDeleteUncheckedSubItemsFeature" ); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuRimQwtPlotCurve::RiuRimQwtPlotCurve( RimPlotCurve* ownerRimCurve, const QString& title /*= QString()*/ ) - : RiuQwtPlotCurve( title ) - , m_ownerRimCurve( ownerRimCurve ) +bool RicDeleteUncheckedSubItemsFeature::isCommandEnabled() { + return RicDeleteSubItemsFeature::canCommandBeEnabled(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimPlotCurve* RiuRimQwtPlotCurve::ownerRimCurve() +void RicDeleteUncheckedSubItemsFeature::onActionTriggered( bool isChecked ) { - return m_ownerRimCurve; + bool onlyUnchecked = true; + RicDeleteSubItemsFeature::deleteSubItems( onlyUnchecked ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const RimPlotCurve* RiuRimQwtPlotCurve::ownerRimCurve() const +void RicDeleteUncheckedSubItemsFeature::setupActionLook( QAction* actionToSetup ) { - return m_ownerRimCurve; + actionToSetup->setText( "Delete Unchecked Sub Items" ); + actionToSetup->setIcon( QIcon( ":/Erase.svg" ) ); } diff --git a/ApplicationLibCode/Commands/RicDeleteUncheckedSubItemsFeature.h b/ApplicationLibCode/Commands/RicDeleteUncheckedSubItemsFeature.h new file mode 100644 index 0000000000..b046e4e5e7 --- /dev/null +++ b/ApplicationLibCode/Commands/RicDeleteUncheckedSubItemsFeature.h @@ -0,0 +1,39 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +namespace caf +{ +class PdmUiItem; +} + +//================================================================================================== +/// +//================================================================================================== +class RicDeleteUncheckedSubItemsFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + bool isCommandEnabled() override; + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; +}; diff --git a/ApplicationLibCode/Commands/RicDeleteWellMeasurementFilePathFeature.h b/ApplicationLibCode/Commands/RicDeleteWellMeasurementFilePathFeature.h index 089e104e4b..b526f1c64e 100644 --- a/ApplicationLibCode/Commands/RicDeleteWellMeasurementFilePathFeature.h +++ b/ApplicationLibCode/Commands/RicDeleteWellMeasurementFilePathFeature.h @@ -28,7 +28,6 @@ class RicDeleteWellMeasurementFilePathFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/RicElasticPropertiesImportTools.cpp b/ApplicationLibCode/Commands/RicElasticPropertiesImportTools.cpp index 1fba26238e..28bdf5a291 100644 --- a/ApplicationLibCode/Commands/RicElasticPropertiesImportTools.cpp +++ b/ApplicationLibCode/Commands/RicElasticPropertiesImportTools.cpp @@ -166,7 +166,7 @@ std::vector RicElasticPropertiesImportTools::getFormationNames() RimOilField* oilField = project->activeOilField(); RimFormationNamesCollection* formationNamesCollection = oilField->formationNamesCollection(); - for ( RimFormationNames* formationNames : formationNamesCollection->formationNamesList().childObjects() ) + for ( RimFormationNames* formationNames : formationNamesCollection->formationNamesList().children() ) { if ( formationNames && formationNames->formationNamesData() ) { diff --git a/ApplicationLibCode/Commands/RicExportContourMapToTextFeature.cpp b/ApplicationLibCode/Commands/RicExportContourMapToTextFeature.cpp index 67c66b1b13..4d54de5417 100644 --- a/ApplicationLibCode/Commands/RicExportContourMapToTextFeature.cpp +++ b/ApplicationLibCode/Commands/RicExportContourMapToTextFeature.cpp @@ -50,11 +50,11 @@ RICF_SOURCE_INIT( RicExportContourMapToTextFeature, "RicExportContourMapToTextFe RicExportContourMapToTextFeature::RicExportContourMapToTextFeature() { - CAF_PDM_InitScriptableFieldNoDefault( &m_exportFileName, "exportFileName", "", "", "", "" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_exportLocalCoordinates, "exportLocalCoordinates", "", "", "", "" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_undefinedValueLabel, "undefinedValueLabel", "", "", "", "" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_excludeUndefinedValues, "excludeUndefinedValues", "", "", "", "" ); - CAF_PDM_InitScriptableField( &m_viewId, "viewId", -1, "View Id", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_exportFileName, "exportFileName", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_exportLocalCoordinates, "exportLocalCoordinates", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_undefinedValueLabel, "undefinedValueLabel", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_excludeUndefinedValues, "excludeUndefinedValues", "" ); + CAF_PDM_InitScriptableField( &m_viewId, "viewId", -1, "View Id" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/RicExportContourMapToTextUi.cpp b/ApplicationLibCode/Commands/RicExportContourMapToTextUi.cpp index 2c7439559b..b9b9d28971 100644 --- a/ApplicationLibCode/Commands/RicExportContourMapToTextUi.cpp +++ b/ApplicationLibCode/Commands/RicExportContourMapToTextUi.cpp @@ -9,14 +9,14 @@ CAF_PDM_SOURCE_INIT( RicExportContourMapToTextUi, "RicExportContourMapToTextUi" //-------------------------------------------------------------------------------------------------- RicExportContourMapToTextUi::RicExportContourMapToTextUi() { - CAF_PDM_InitObject( "Export Contour Map to Text", "", "", "" ); + CAF_PDM_InitObject( "Export Contour Map to Text" ); - CAF_PDM_InitField( &m_exportFileName, "ExportFileName", QString(), "Export File Name", "", "", "" ); + CAF_PDM_InitField( &m_exportFileName, "ExportFileName", QString(), "Export File Name" ); m_exportFileName.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_exportLocalCoordinates, "ExportLocalCoordinates", false, "Export Local Coordinates", "", "", "" ); - CAF_PDM_InitField( &m_undefinedValueLabel, "UndefinedValueLabel", QString( "NaN" ), "Undefined Value Label", "", "", "" ); - CAF_PDM_InitField( &m_excludeUndefinedValues, "ExcludeUndefinedValues", false, "Exclude Undefined Values", "", "", "" ); + CAF_PDM_InitField( &m_exportLocalCoordinates, "ExportLocalCoordinates", false, "Export Local Coordinates" ); + CAF_PDM_InitField( &m_undefinedValueLabel, "UndefinedValueLabel", QString( "NaN" ), "Undefined Value Label" ); + CAF_PDM_InitField( &m_excludeUndefinedValues, "ExcludeUndefinedValues", false, "Exclude Undefined Values" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/RicExportStimPlanModelToFileFeature.h b/ApplicationLibCode/Commands/RicExportStimPlanModelToFileFeature.h index f7b0bc0db9..d71f48c42f 100644 --- a/ApplicationLibCode/Commands/RicExportStimPlanModelToFileFeature.h +++ b/ApplicationLibCode/Commands/RicExportStimPlanModelToFileFeature.h @@ -28,7 +28,6 @@ class RicExportStimPlanModelToFileFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/RicGridCalculatorDialog.cpp b/ApplicationLibCode/Commands/RicGridCalculatorDialog.cpp new file mode 100644 index 0000000000..5713ce7f21 --- /dev/null +++ b/ApplicationLibCode/Commands/RicGridCalculatorDialog.cpp @@ -0,0 +1,83 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicGridCalculatorDialog.h" + +#include "RicCalculatorWidgetCreator.h" +#include "RicGridCalculatorUi.h" + +#include "RimGridCalculation.h" +#include "RimGridCalculationCollection.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicGridCalculatorDialog::RicGridCalculatorDialog( QWidget* parent ) + : RicUserDefinedCalculatorDialog( parent, "Grid Property Calculator" ) +{ + setUp(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicGridCalculatorDialog::~RicGridCalculatorDialog() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicGridCalculatorDialog::setCalculationAndUpdateUi( RimUserDefinedCalculation* calculation ) +{ + CAF_ASSERT( m_calcEditor ); + m_calcEditor->calculator()->setCurrentCalculation( calculation ); + updateUi(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicGridCalculatorDialog::updateUi() +{ + CAF_ASSERT( m_calcEditor ); + m_calcEditor->updateUi(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimUserDefinedCalculationCollection* RicGridCalculatorDialog::calculationCollection() const +{ + CAF_ASSERT( m_calcEditor ); + return m_calcEditor->calculator()->calculationCollection(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QWidget* RicGridCalculatorDialog::getCalculatorWidget() +{ + if ( !m_calcEditor ) + { + m_calcEditor = std::unique_ptr( + new RicCalculatorWidgetCreator( std::make_unique() ) ); + } + + return m_calcEditor->getOrCreateWidget( this ); +} diff --git a/ApplicationLibCode/Commands/RicGridCalculatorDialog.h b/ApplicationLibCode/Commands/RicGridCalculatorDialog.h new file mode 100644 index 0000000000..843b2bf31d --- /dev/null +++ b/ApplicationLibCode/Commands/RicGridCalculatorDialog.h @@ -0,0 +1,46 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RicUserDefinedCalculatorDialog.h" + +#include + +class RicCalculatorWidgetCreator; + +//================================================================================================== +/// +/// +//================================================================================================== +class RicGridCalculatorDialog : public RicUserDefinedCalculatorDialog +{ + Q_OBJECT + +public: + RicGridCalculatorDialog( QWidget* parent ); + ~RicGridCalculatorDialog() override; + + void setCalculationAndUpdateUi( RimUserDefinedCalculation* calculation ) override; + QWidget* getCalculatorWidget() override; + void updateUi() override; + RimUserDefinedCalculationCollection* calculationCollection() const override; + +private: + std::unique_ptr m_calcEditor; +}; diff --git a/ApplicationLibCode/Commands/RicGridCalculatorUi.cpp b/ApplicationLibCode/Commands/RicGridCalculatorUi.cpp new file mode 100644 index 0000000000..de33f232cc --- /dev/null +++ b/ApplicationLibCode/Commands/RicGridCalculatorUi.cpp @@ -0,0 +1,64 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicGridCalculatorUi.h" + +#include "RimGridCalculationCollection.h" +#include "RimProject.h" +#include "RimUserDefinedCalculationCollection.h" + +CAF_PDM_SOURCE_INIT( RicGridCalculatorUi, "RicGridCalculator" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicGridCalculatorUi::RicGridCalculatorUi() +{ + CAF_PDM_InitObject( "RicGridCalculator" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicGridCalculatorUi::calculationsGroupName() const +{ + return "CalculationsGroupName"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicGridCalculatorUi::calulationGroupName() const +{ + return "CalulationGroupName"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicGridCalculatorUi::notifyCalculatedNameChanged( int id, const QString& newName ) const +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimUserDefinedCalculationCollection* RicGridCalculatorUi::calculationCollection() const +{ + return RimProject::current()->gridCalculationCollection(); +} diff --git a/ApplicationLibCode/Commands/RicGridCalculatorUi.h b/ApplicationLibCode/Commands/RicGridCalculatorUi.h new file mode 100644 index 0000000000..7798a8ee95 --- /dev/null +++ b/ApplicationLibCode/Commands/RicGridCalculatorUi.h @@ -0,0 +1,39 @@ +//////////////////////////// ///////////////////////////////////////////////////// +// +// Copyright (C) 2022- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RicUserDefinedCalculatorUi.h" + +class RimUserDefinedCalculationCollection; + +//================================================================================================== +/// +//================================================================================================== +class RicGridCalculatorUi : public RicUserDefinedCalculatorUi +{ + CAF_PDM_HEADER_INIT; + +public: + RicGridCalculatorUi(); + + QString calculationsGroupName() const override; + QString calulationGroupName() const override; + RimUserDefinedCalculationCollection* calculationCollection() const override; + void notifyCalculatedNameChanged( int id, const QString& newName ) const override; +}; diff --git a/ApplicationLibCode/Commands/RicGridStatisticsDialog.cpp b/ApplicationLibCode/Commands/RicGridStatisticsDialog.cpp index b918f0eff2..f54de99c3e 100644 --- a/ApplicationLibCode/Commands/RicGridStatisticsDialog.cpp +++ b/ApplicationLibCode/Commands/RicGridStatisticsDialog.cpp @@ -195,16 +195,16 @@ void RicGridStatisticsDialog::setHistogramData( RimGridView* view ) // Axis double xAxisSize = histogramData.max - histogramData.min; double xAxisExtension = xAxisSize * 0.02; - m_historgramPlot->setAxisScale( QwtPlot::xBottom, + m_historgramPlot->setAxisScale( QwtAxis::XBottom, histogramData.min - xAxisExtension, histogramData.max + xAxisExtension ); - m_aggregatedPlot->setAxisScale( QwtPlot::xBottom, + m_aggregatedPlot->setAxisScale( QwtAxis::XBottom, histogramData.min - xAxisExtension, histogramData.max + xAxisExtension ); // Set y axis label area width - m_historgramPlot->axisScaleDraw( QwtPlot::yLeft )->setMinimumExtent( 60 ); - m_aggregatedPlot->axisScaleDraw( QwtPlot::yLeft )->setMinimumExtent( 60 ); + m_historgramPlot->axisScaleDraw( QwtAxis::YLeft )->setMinimumExtent( 60 ); + m_aggregatedPlot->axisScaleDraw( QwtAxis::YLeft )->setMinimumExtent( 60 ); // Samples hist->setSamples( histSamples ); diff --git a/ApplicationLibCode/Commands/RicImportElasticPropertiesFeature.h b/ApplicationLibCode/Commands/RicImportElasticPropertiesFeature.h index 9ccece7b2b..70ecc360e6 100644 --- a/ApplicationLibCode/Commands/RicImportElasticPropertiesFeature.h +++ b/ApplicationLibCode/Commands/RicImportElasticPropertiesFeature.h @@ -28,7 +28,6 @@ class RicImportElasticPropertiesFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/RicImportEnsembleFeature.cpp b/ApplicationLibCode/Commands/RicImportEnsembleFeature.cpp index 8e5f05b181..c83f80d4cb 100644 --- a/ApplicationLibCode/Commands/RicImportEnsembleFeature.cpp +++ b/ApplicationLibCode/Commands/RicImportEnsembleFeature.cpp @@ -39,13 +39,12 @@ #include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" #include "RimSummaryPlot.h" -#include "RimSummaryPlotCollection.h" #include "RiuMainWindow.h" #include "RiuPlotMainWindow.h" +#include "PlotBuilderCommands/RicSummaryPlotBuilder.h" #include "SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.h" -#include "SummaryPlotCommands/RicNewSummaryPlotFeature.h" #include #include @@ -113,7 +112,6 @@ void RicImportEnsembleFeature::importSingleEnsemble( const QStringList& if ( cases.empty() ) return; - RicImportSummaryCasesFeature::addSummaryCases( cases ); RimSummaryCaseCollection* ensemble = RicCreateSummaryCaseCollectionFeature::groupSummaryCases( cases, ensembleName, true ); @@ -124,7 +122,7 @@ void RicImportEnsembleFeature::importSingleEnsemble( const QStringList& summaryCase->updateAutoShortName(); } - RicNewSummaryEnsembleCurveSetFeature::createPlotForCurveSetsAndUpdate( { ensemble } ); + RicSummaryPlotBuilder::createAndAppendDefaultSummaryMultiPlot( {}, { ensemble } ); } std::vector allCases; @@ -132,7 +130,7 @@ void RicImportEnsembleFeature::importSingleEnsemble( const QStringList& if ( allCases.size() == 0 ) { - RiuMainWindow::instance()->close(); + RiuMainWindow::closeIfOpen(); } } diff --git a/ApplicationLibCode/Commands/RicImportEnsembleFeature.h b/ApplicationLibCode/Commands/RicImportEnsembleFeature.h index 5400f3f19e..dc5e76027c 100644 --- a/ApplicationLibCode/Commands/RicImportEnsembleFeature.h +++ b/ApplicationLibCode/Commands/RicImportEnsembleFeature.h @@ -34,7 +34,6 @@ class RicImportEnsembleFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/RicImportEnsembleSurfaceFeature.h b/ApplicationLibCode/Commands/RicImportEnsembleSurfaceFeature.h index 0e458eb02d..80d6e673e2 100644 --- a/ApplicationLibCode/Commands/RicImportEnsembleSurfaceFeature.h +++ b/ApplicationLibCode/Commands/RicImportEnsembleSurfaceFeature.h @@ -38,7 +38,6 @@ class RicImportEnsembleSurfaceFeature : public caf::CmdFeature RiaEnsembleNameTools::EnsembleGroupingMode groupingMode ); protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/RicImportGeneralDataFeature.h b/ApplicationLibCode/Commands/RicImportGeneralDataFeature.h index 91d6c6847a..9e7cae44b9 100644 --- a/ApplicationLibCode/Commands/RicImportGeneralDataFeature.h +++ b/ApplicationLibCode/Commands/RicImportGeneralDataFeature.h @@ -59,7 +59,6 @@ class RicImportGeneralDataFeature : public caf::CmdFeature static QStringList getEclipseFileNamesWithDialog( RiaDefines::ImportFileType fileTypes ); protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/RicImportSummaryCaseFeature.cpp b/ApplicationLibCode/Commands/RicImportSummaryCaseFeature.cpp index 4aebc136b4..d43a020b53 100644 --- a/ApplicationLibCode/Commands/RicImportSummaryCaseFeature.cpp +++ b/ApplicationLibCode/Commands/RicImportSummaryCaseFeature.cpp @@ -27,7 +27,6 @@ #include "RimProject.h" #include "RimSummaryCase.h" #include "RimSummaryCaseMainCollection.h" -#include "RimSummaryPlotCollection.h" #include "RiuMainWindow.h" #include "RiuPlotMainWindow.h" diff --git a/ApplicationLibCode/Commands/RicImportSummaryCaseFeature.h b/ApplicationLibCode/Commands/RicImportSummaryCaseFeature.h index 1447d03034..a4353826d0 100644 --- a/ApplicationLibCode/Commands/RicImportSummaryCaseFeature.h +++ b/ApplicationLibCode/Commands/RicImportSummaryCaseFeature.h @@ -32,7 +32,6 @@ class RicImportSummaryCaseFeature : public RicImportGeneralDataFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/RicImportSummaryCasesFeature.cpp b/ApplicationLibCode/Commands/RicImportSummaryCasesFeature.cpp index 5830d65bbc..50e834532f 100644 --- a/ApplicationLibCode/Commands/RicImportSummaryCasesFeature.cpp +++ b/ApplicationLibCode/Commands/RicImportSummaryCasesFeature.cpp @@ -36,15 +36,15 @@ #include "RimSummaryCase.h" #include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" +#include "RimSummaryMultiPlot.h" #include "RimSummaryPlot.h" -#include "RimSummaryPlotCollection.h" #include "RiuMainWindow.h" #include "RiuPlotMainWindow.h" #include "RiuPlotMainWindowTools.h" +#include "PlotBuilderCommands/RicSummaryPlotBuilder.h" #include "SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.h" -#include "SummaryPlotCommands/RicNewSummaryPlotFeature.h" #include "SummaryPlotCommands/RicSummaryPlotFeatureImpl.h" #include "cafProgressInfo.h" @@ -84,11 +84,9 @@ void RicImportSummaryCasesFeature::onActionTriggered( bool isChecked ) addSummaryCases( cases ); if ( !cases.empty() ) { - auto objectToSelect = RicSummaryPlotFeatureImpl::createDefaultSummaryPlot( cases.front() ); - if ( objectToSelect ) + for ( auto sumcase : cases ) { - RiuPlotMainWindowTools::setExpanded( objectToSelect ); - RiuPlotMainWindowTools::selectAsCurrentItem( objectToSelect ); + RicSummaryPlotBuilder::createAndAppendDefaultSummaryMultiPlot( { sumcase }, {} ); } } @@ -100,7 +98,7 @@ void RicImportSummaryCasesFeature::onActionTriggered( bool isChecked ) RiuPlotMainWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow(); if ( mainPlotWindow && !cases.empty() ) { - mainPlotWindow->updateSummaryPlotToolBar(); + mainPlotWindow->updateMultiPlotToolBar(); } std::vector allCases; @@ -108,7 +106,7 @@ void RicImportSummaryCasesFeature::onActionTriggered( bool isChecked ) if ( allCases.size() == 0 ) { - RiuMainWindow::instance()->close(); + RiuMainWindow::closeIfOpen(); } } @@ -137,18 +135,23 @@ bool RicImportSummaryCasesFeature::createAndAddSummaryCasesFromFiles( const QStr addSummaryCases( *cases ); if ( !cases->empty() && doCreateDefaultPlot ) { - auto objectToSelect = RicSummaryPlotFeatureImpl::createDefaultSummaryPlot( cases->back() ); - if ( objectToSelect ) + RimSummaryMultiPlot* plotToSelect = nullptr; + for ( auto sumCase : *cases ) { - RiuPlotMainWindowTools::setExpanded( objectToSelect ); - RiuPlotMainWindowTools::selectAsCurrentItem( objectToSelect ); + plotToSelect = RicSummaryPlotBuilder::createAndAppendDefaultSummaryMultiPlot( { sumCase }, {} ); + } + + if ( plotToSelect ) + { + RiuPlotMainWindowTools::setExpanded( plotToSelect ); + RiuPlotMainWindowTools::selectAsCurrentItem( plotToSelect ); } } RiuPlotMainWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow(); if ( mainPlotWindow && !cases->empty() ) { - mainPlotWindow->updateSummaryPlotToolBar(); + mainPlotWindow->updateMultiPlotToolBar(); // Close main window if there are no eclipse cases imported std::vector allCases; @@ -156,7 +159,7 @@ bool RicImportSummaryCasesFeature::createAndAddSummaryCasesFromFiles( const QStr if ( allCases.size() == 0 ) { - RiuMainWindow::instance()->close(); + RiuMainWindow::closeIfOpen(); } } return true; diff --git a/ApplicationLibCode/Commands/RicImportSummaryCasesFeature.h b/ApplicationLibCode/Commands/RicImportSummaryCasesFeature.h index c5f170c29f..6128911919 100644 --- a/ApplicationLibCode/Commands/RicImportSummaryCasesFeature.h +++ b/ApplicationLibCode/Commands/RicImportSummaryCasesFeature.h @@ -54,7 +54,6 @@ class RicImportSummaryCasesFeature : public caf::CmdFeature runRecursiveSummaryCaseFileSearchDialogWithGrouping( const QString& dialogTitle, const QString& pathCacheName ); protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/RicImportSummaryGroupFeature.cpp b/ApplicationLibCode/Commands/RicImportSummaryGroupFeature.cpp index 3ef95e4bc0..b3842c5ebf 100644 --- a/ApplicationLibCode/Commands/RicImportSummaryGroupFeature.cpp +++ b/ApplicationLibCode/Commands/RicImportSummaryGroupFeature.cpp @@ -32,13 +32,10 @@ #include "RimProject.h" #include "RimSummaryCase.h" #include "RimSummaryCaseMainCollection.h" -#include "RimSummaryPlotCollection.h" #include "RiuMainWindow.h" #include "RiuPlotMainWindow.h" -#include "SummaryPlotCommands/RicNewSummaryPlotFeature.h" - #include #include @@ -74,8 +71,7 @@ void RicImportSummaryGroupFeature::onActionTriggered( bool isChecked ) if ( mainPlotWindow && !cases.empty() ) { mainPlotWindow->selectAsCurrentItem( cases.back() ); - - mainPlotWindow->updateSummaryPlotToolBar(); + mainPlotWindow->updateMultiPlotToolBar(); } std::vector allCases; @@ -83,7 +79,7 @@ void RicImportSummaryGroupFeature::onActionTriggered( bool isChecked ) if ( allCases.size() == 0 ) { - RiuMainWindow::instance()->close(); + RiuMainWindow::closeIfOpen(); } } diff --git a/ApplicationLibCode/Commands/RicImportSummaryGroupFeature.h b/ApplicationLibCode/Commands/RicImportSummaryGroupFeature.h index 8f10134c74..d40d838ff3 100644 --- a/ApplicationLibCode/Commands/RicImportSummaryGroupFeature.h +++ b/ApplicationLibCode/Commands/RicImportSummaryGroupFeature.h @@ -32,7 +32,6 @@ class RicImportSummaryGroupFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/RicNewContourMapViewFeature.h b/ApplicationLibCode/Commands/RicNewContourMapViewFeature.h index 16931ccd75..acf88f0880 100644 --- a/ApplicationLibCode/Commands/RicNewContourMapViewFeature.h +++ b/ApplicationLibCode/Commands/RicNewContourMapViewFeature.h @@ -36,7 +36,6 @@ class RicNewContourMapViewFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/RicNewCustomObjectiveFunctionFeature.h b/ApplicationLibCode/Commands/RicNewCustomObjectiveFunctionFeature.h index e8e80e1cc0..7e3f3a0d91 100644 --- a/ApplicationLibCode/Commands/RicNewCustomObjectiveFunctionFeature.h +++ b/ApplicationLibCode/Commands/RicNewCustomObjectiveFunctionFeature.h @@ -28,7 +28,6 @@ class RicNewCustomObjectiveFunctionFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/RicNewPressureTableItemFeature.h b/ApplicationLibCode/Commands/RicNewPressureTableItemFeature.h index 247fa0cdff..a48195f366 100644 --- a/ApplicationLibCode/Commands/RicNewPressureTableItemFeature.h +++ b/ApplicationLibCode/Commands/RicNewPressureTableItemFeature.h @@ -28,7 +28,6 @@ class RicNewPressureTableItemFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/RicNewViewFeature.h b/ApplicationLibCode/Commands/RicNewViewFeature.h index a15f2b1c87..d0b0a90407 100644 --- a/ApplicationLibCode/Commands/RicNewViewFeature.h +++ b/ApplicationLibCode/Commands/RicNewViewFeature.h @@ -38,7 +38,6 @@ class RicNewViewFeature : public caf::CmdFeature static void addReservoirView( RimEclipseCase* eclipseCase, RimGeoMechCase* geomCase ); protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/RicReloadFormationNamesFeature.h b/ApplicationLibCode/Commands/RicReloadFormationNamesFeature.h index 86cf3e61f5..743b2a35f7 100644 --- a/ApplicationLibCode/Commands/RicReloadFormationNamesFeature.h +++ b/ApplicationLibCode/Commands/RicReloadFormationNamesFeature.h @@ -28,7 +28,6 @@ class RicReloadFormationNamesFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/RicReloadSummaryCaseFeature.cpp b/ApplicationLibCode/Commands/RicReloadSummaryCaseFeature.cpp index 21918dc2b6..4e9b22e805 100644 --- a/ApplicationLibCode/Commands/RicReloadSummaryCaseFeature.cpp +++ b/ApplicationLibCode/Commands/RicReloadSummaryCaseFeature.cpp @@ -29,8 +29,9 @@ #include "RimSummaryCase.h" #include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" +#include "RimSummaryMultiPlot.h" +#include "RimSummaryMultiPlotCollection.h" #include "RimSummaryPlot.h" -#include "RimSummaryPlotCollection.h" #include "cafPdmObject.h" #include "cafSelectionManager.h" @@ -54,22 +55,26 @@ bool RicReloadSummaryCaseFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicReloadSummaryCaseFeature::onActionTriggered( bool isChecked ) { - RimSummaryPlotCollection* summaryPlotColl = RiaSummaryTools::summaryPlotCollection(); + RimSummaryMultiPlotCollection* summaryPlotColl = RiaSummaryTools::summaryMultiPlotCollection(); std::vector caseSelection = selectedSummaryCases(); for ( RimSummaryCase* summaryCase : caseSelection ) { summaryCase->createSummaryReaderInterface(); summaryCase->createRftReaderInterface(); + summaryCase->refreshMetaData(); RicReplaceSummaryCaseFeature::updateRequredCalculatedCurves( summaryCase ); RiaLogging::info( QString( "Reloaded data for %1" ).arg( summaryCase->summaryHeaderFilename() ) ); } - for ( RimSummaryPlot* summaryPlot : summaryPlotColl->plots() ) + for ( RimSummaryMultiPlot* multiPlot : summaryPlotColl->multiPlots() ) { - summaryPlot->loadDataAndUpdate(); + for ( RimSummaryPlot* summaryPlot : multiPlot->summaryPlots() ) + { + summaryPlot->loadDataAndUpdate(); + } } } diff --git a/ApplicationLibCode/Commands/RicReplaceCaseFeature.cpp b/ApplicationLibCode/Commands/RicReplaceCaseFeature.cpp index 3fe367eb48..1fb74c865c 100644 --- a/ApplicationLibCode/Commands/RicReplaceCaseFeature.cpp +++ b/ApplicationLibCode/Commands/RicReplaceCaseFeature.cpp @@ -30,8 +30,9 @@ #include "RimReloadCaseTools.h" #include "RimSummaryCase.h" #include "RimSummaryCaseMainCollection.h" +#include "RimSummaryMultiPlot.h" +#include "RimSummaryMultiPlotCollection.h" #include "RimSummaryPlot.h" -#include "RimSummaryPlotCollection.h" #include "RimTimeStepFilter.h" #include "Riu3dSelectionManager.h" @@ -110,10 +111,13 @@ void RicReplaceCaseFeature::onActionTriggered( bool isChecked ) gridSummaryCase->createSummaryReaderInterface(); gridSummaryCase->createRftReaderInterface(); - RimSummaryPlotCollection* summaryPlotColl = RiaSummaryTools::summaryPlotCollection(); - for ( RimSummaryPlot* summaryPlot : summaryPlotColl->plots() ) + RimSummaryMultiPlotCollection* summaryPlotColl = RiaSummaryTools::summaryMultiPlotCollection(); + for ( RimSummaryMultiPlot* multiPlot : summaryPlotColl->multiPlots() ) { - summaryPlot->loadDataAndUpdate(); + for ( RimSummaryPlot* summaryPlot : multiPlot->summaryPlots() ) + { + summaryPlot->loadDataAndUpdate(); + } } } } diff --git a/ApplicationLibCode/Commands/RicReplaceSummaryCaseFeature.cpp b/ApplicationLibCode/Commands/RicReplaceSummaryCaseFeature.cpp index dd39a039a9..ccf9682db9 100644 --- a/ApplicationLibCode/Commands/RicReplaceSummaryCaseFeature.cpp +++ b/ApplicationLibCode/Commands/RicReplaceSummaryCaseFeature.cpp @@ -36,8 +36,9 @@ #include "RimSummaryCrossPlot.h" #include "RimSummaryCrossPlotCollection.h" #include "RimSummaryCurve.h" +#include "RimSummaryMultiPlot.h" +#include "RimSummaryMultiPlotCollection.h" #include "RimSummaryPlot.h" -#include "RimSummaryPlotCollection.h" #include "cafPdmObject.h" #include "cafSelectionManager.h" @@ -53,7 +54,7 @@ void RicReplaceSummaryCaseFeature::updateRequredCalculatedCurves( RimSummaryCase { RimSummaryCalculationCollection* calcColl = RimProject::current()->calculationCollection(); - for ( RimSummaryCalculation* summaryCalculation : calcColl->calculations() ) + for ( RimUserDefinedCalculation* summaryCalculation : calcColl->calculations() ) { bool needsUpdate = RicReplaceSummaryCaseFeature::checkIfCalculationNeedsUpdate( summaryCalculation, sourceSummaryCase ); @@ -61,7 +62,7 @@ void RicReplaceSummaryCaseFeature::updateRequredCalculatedCurves( RimSummaryCase { summaryCalculation->parseExpression(); summaryCalculation->calculate(); - summaryCalculation->updateDependentCurvesAndPlots(); + summaryCalculation->updateDependentObjects(); } } } @@ -92,6 +93,8 @@ void RicReplaceSummaryCaseFeature::onActionTriggered( bool isChecked ) summaryCase->updateAutoShortName(); summaryCase->createSummaryReaderInterface(); summaryCase->createRftReaderInterface(); + summaryCase->refreshMetaData(); + RiaLogging::info( QString( "Replaced summary data for %1" ).arg( oldSummaryHeaderFilename ) ); RicReplaceSummaryCaseFeature::updateRequredCalculatedCurves( summaryCase ); @@ -99,7 +102,7 @@ void RicReplaceSummaryCaseFeature::onActionTriggered( bool isChecked ) // Find and update all changed calculations std::set ids; RimSummaryCalculationCollection* calcColl = RimProject::current()->calculationCollection(); - for ( RimSummaryCalculation* summaryCalculation : calcColl->calculations() ) + for ( RimUserDefinedCalculation* summaryCalculation : calcColl->calculations() ) { bool needsUpdate = checkIfCalculationNeedsUpdate( summaryCalculation, summaryCase ); if ( needsUpdate ) @@ -108,31 +111,34 @@ void RicReplaceSummaryCaseFeature::onActionTriggered( bool isChecked ) } } - RimSummaryPlotCollection* summaryPlotColl = RiaSummaryTools::summaryPlotCollection(); - for ( RimSummaryPlot* summaryPlot : summaryPlotColl->plots() ) + RimSummaryMultiPlotCollection* summaryPlotColl = RiaSummaryTools::summaryMultiPlotCollection(); + for ( RimSummaryMultiPlot* multiPlot : summaryPlotColl->multiPlots() ) { - // Update summary curves on calculated data - std::vector summaryCurves = summaryPlot->summaryCurves(); - for ( RimSummaryCurve* summaryCurve : summaryCurves ) + for ( RimSummaryPlot* summaryPlot : multiPlot->summaryPlots() ) { - RifEclipseSummaryAddress summaryAddressY = summaryCurve->summaryAddressY(); - if ( summaryAddressY.category() == RifEclipseSummaryAddress::SUMMARY_CALCULATED && - ids.find( summaryAddressY.id() ) != ids.end() ) + // Update summary curves on calculated data + std::vector summaryCurves = summaryPlot->summaryCurves(); + for ( RimSummaryCurve* summaryCurve : summaryCurves ) { - if ( calcColl ) + RifEclipseSummaryAddress summaryAddressY = summaryCurve->summaryAddressY(); + if ( summaryAddressY.category() == RifEclipseSummaryAddress::SUMMARY_CALCULATED && + ids.find( summaryAddressY.id() ) != ids.end() ) { - RimSummaryCalculation* calculation = calcColl->findCalculationById( summaryAddressY.id() ); - QString description = calculation->description(); - - RifEclipseSummaryAddress updatedAdr = - RifEclipseSummaryAddress::calculatedAddress( description.toStdString(), calculation->id() ); - summaryCurve->setSummaryAddressYAndApplyInterpolation( updatedAdr ); - summaryCurve->loadDataAndUpdate( true ); + if ( calcColl ) + { + RimUserDefinedCalculation* calculation = calcColl->findCalculationById( summaryAddressY.id() ); + QString description = calculation->description(); + + RifEclipseSummaryAddress updatedAdr = + RifEclipseSummaryAddress::calculatedAddress( description.toStdString(), calculation->id() ); + summaryCurve->setSummaryAddressYAndApplyInterpolation( updatedAdr ); + summaryCurve->loadDataAndUpdate( true ); + } } } - } - summaryPlot->loadDataAndUpdate(); + summaryPlot->loadDataAndUpdate(); + } } RimSummaryCrossPlotCollection* summaryCrossPlotColl = RiaSummaryTools::summaryCrossPlotCollection(); @@ -148,8 +154,8 @@ void RicReplaceSummaryCaseFeature::onActionTriggered( bool isChecked ) { if ( calcColl ) { - RimSummaryCalculation* calculation = calcColl->findCalculationById( summaryAddressX.id() ); - QString description = calculation->description(); + RimUserDefinedCalculation* calculation = calcColl->findCalculationById( summaryAddressX.id() ); + QString description = calculation->description(); RifEclipseSummaryAddress updatedAdr = RifEclipseSummaryAddress::calculatedAddress( description.toStdString(), calculation->id() ); @@ -164,8 +170,8 @@ void RicReplaceSummaryCaseFeature::onActionTriggered( bool isChecked ) { if ( calcColl ) { - RimSummaryCalculation* calculation = calcColl->findCalculationById( summaryAddressX.id() ); - QString description = calculation->description(); + RimUserDefinedCalculation* calculation = calcColl->findCalculationById( summaryAddressX.id() ); + QString description = calculation->description(); RifEclipseSummaryAddress updatedAdr = RifEclipseSummaryAddress::calculatedAddress( description.toStdString(), calculation->id() ); @@ -191,13 +197,14 @@ void RicReplaceSummaryCaseFeature::setupActionLook( QAction* actionToSetup ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RicReplaceSummaryCaseFeature::checkIfCalculationNeedsUpdate( const RimSummaryCalculation* summaryCalculation, - const RimSummaryCase* summaryCase ) +bool RicReplaceSummaryCaseFeature::checkIfCalculationNeedsUpdate( const RimUserDefinedCalculation* summaryCalculation, + const RimSummaryCase* summaryCase ) { - std::vector variables = summaryCalculation->allVariables(); - for ( RimSummaryCalculationVariable* variable : variables ) + std::vector variables = summaryCalculation->allVariables(); + for ( RimUserDefinedCalculationVariable* variable : variables ) { - if ( variable->summaryCase() == summaryCase ) + RimSummaryCalculationVariable* summaryVariable = dynamic_cast( variable ); + if ( summaryVariable->summaryCase() == summaryCase ) { return true; } diff --git a/ApplicationLibCode/Commands/RicReplaceSummaryCaseFeature.h b/ApplicationLibCode/Commands/RicReplaceSummaryCaseFeature.h index 5f16574a1e..085e23077f 100644 --- a/ApplicationLibCode/Commands/RicReplaceSummaryCaseFeature.h +++ b/ApplicationLibCode/Commands/RicReplaceSummaryCaseFeature.h @@ -20,7 +20,7 @@ #include "cafCmdFeature.h" -class RimSummaryCalculation; +class RimUserDefinedCalculation; class RimSummaryCase; class RicReplaceSummaryCaseFeature : public caf::CmdFeature @@ -35,6 +35,6 @@ class RicReplaceSummaryCaseFeature : public caf::CmdFeature void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; - static bool checkIfCalculationNeedsUpdate( const RimSummaryCalculation* summaryCalculation, - const RimSummaryCase* summaryCase ); + static bool checkIfCalculationNeedsUpdate( const RimUserDefinedCalculation* summaryCalculation, + const RimSummaryCase* summaryCase ); }; diff --git a/ApplicationLibCode/Commands/RicResampleDialog.cpp b/ApplicationLibCode/Commands/RicResampleDialog.cpp index f3e4b1b16c..7d153ec128 100644 --- a/ApplicationLibCode/Commands/RicResampleDialog.cpp +++ b/ApplicationLibCode/Commands/RicResampleDialog.cpp @@ -18,6 +18,8 @@ #include "RicResampleDialog.h" +#include "RiaQDateTimeTools.h" + #include "RiuTools.h" #include @@ -97,13 +99,13 @@ RicResampleDialogResult RicResampleDialog::openDialog( QWidget* parent /*= 0*/, //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicResampleDialog::setPeriodOptions( const std::vector& dateTimePeriods ) +void RicResampleDialog::setPeriodOptions( const std::vector& dateTimePeriods ) { QStringList s; for ( auto& period : dateTimePeriods ) { - QString text = period != RiaQDateTimeTools::DateTimePeriod::NONE ? RiaQDateTimeTools::dateTimePeriodName( period ) - : "No Resampling"; + QString text = period != RiaDefines::DateTimePeriod::NONE ? RiaQDateTimeTools::dateTimePeriodName( period ) + : "No Resampling"; m_timePeriodCombo->addItem( text, QVariant( (int)period ) ); } } @@ -111,10 +113,10 @@ void RicResampleDialog::setPeriodOptions( const std::vectorcurrentIndex(); - return (RiaQDateTimeTools::DateTimePeriod)m_timePeriodCombo->itemData( currIndex ).toInt(); + return (RiaDefines::DateTimePeriod)m_timePeriodCombo->itemData( currIndex ).toInt(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/RicResampleDialog.h b/ApplicationLibCode/Commands/RicResampleDialog.h index 8feb1068e7..ea68da6cb3 100644 --- a/ApplicationLibCode/Commands/RicResampleDialog.h +++ b/ApplicationLibCode/Commands/RicResampleDialog.h @@ -18,7 +18,7 @@ #pragma once -#include "RiaQDateTimeTools.h" +#include "RiaDateTimeDefines.h" #include "cafPdmPointer.h" @@ -49,8 +49,8 @@ class RicResampleDialog : public QDialog static RicResampleDialogResult openDialog( QWidget* parent = nullptr, const QString& caption = QString() ); private: - void setPeriodOptions( const std::vector& dateTimePeriods ); - RiaQDateTimeTools::DateTimePeriod selectedDateTimePeriod() const; + void setPeriodOptions( const std::vector& dateTimePeriods ); + RiaDefines::DateTimePeriod selectedDateTimePeriod() const; private slots: void slotDialogOkClicked(); @@ -69,12 +69,12 @@ private slots: class RicResampleDialogResult { public: - RicResampleDialogResult( bool ok, RiaQDateTimeTools::DateTimePeriod period ) + RicResampleDialogResult( bool ok, RiaDefines::DateTimePeriod period ) : ok( ok ) , period( period ) { } - bool ok; - RiaQDateTimeTools::DateTimePeriod period; + bool ok; + RiaDefines::DateTimePeriod period; }; diff --git a/ApplicationLibCode/Commands/RicShowDataSourcesForRealization.cpp b/ApplicationLibCode/Commands/RicShowDataSourcesForRealization.cpp new file mode 100644 index 0000000000..1aec5c9fa0 --- /dev/null +++ b/ApplicationLibCode/Commands/RicShowDataSourcesForRealization.cpp @@ -0,0 +1,89 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicShowDataSourcesForRealization.h" + +#include "RimSummaryCase.h" + +#include "cafSelectionManager.h" +#include + +CAF_CMD_SOURCE_INIT( RicShowDataSourcesForRealization, "RicShowDataSourcesForRealization" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicShowDataSourcesForRealization::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setText( "Show Data Sources" ); + + actionToSetup->setCheckable( true ); + actionToSetup->setChecked( isCommandChecked() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicShowDataSourcesForRealization::isCommandChecked() +{ + std::vector selection; + caf::SelectionManager::instance()->objectsByType( &selection ); + + if ( !selection.empty() ) + { + return selection.front()->showRealizationDataSources(); + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicShowDataSourcesForRealization::isCommandEnabled() +{ + std::vector selection; + caf::SelectionManager::instance()->objectsByType( &selection ); + + for ( RimSummaryCase* summaryCase : selection ) + { + if ( summaryCase->ensemble() ) + { + return true; + } + } + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicShowDataSourcesForRealization::onActionTriggered( bool isChecked ) +{ + std::vector selection; + caf::SelectionManager::instance()->objectsByType( &selection ); + + if ( selection.empty() ) return; + + bool enableDataSources = !selection.front()->showRealizationDataSources(); + + for ( auto summaryCase : selection ) + { + summaryCase->setShowRealizationDataSource( enableDataSources ); + } +} diff --git a/ApplicationLibCode/Commands/RicShowDataSourcesForRealization.h b/ApplicationLibCode/Commands/RicShowDataSourcesForRealization.h new file mode 100644 index 0000000000..87f425d58c --- /dev/null +++ b/ApplicationLibCode/Commands/RicShowDataSourcesForRealization.h @@ -0,0 +1,35 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +//================================================================================================== +/// +//================================================================================================== +class RicShowDataSourcesForRealization : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + bool isCommandEnabled() override; + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; + bool isCommandChecked() override; +}; diff --git a/ApplicationLibCode/Commands/RicShowGridCalculatorFeature.cpp b/ApplicationLibCode/Commands/RicShowGridCalculatorFeature.cpp new file mode 100644 index 0000000000..bdfb86c8c6 --- /dev/null +++ b/ApplicationLibCode/Commands/RicShowGridCalculatorFeature.cpp @@ -0,0 +1,94 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicShowGridCalculatorFeature.h" + +#include "RicGridCalculatorDialog.h" + +#include "RiaGuiApplication.h" + +#include "RimGridCalculationCollection.h" +#include "RimProject.h" +#include "RimSummaryCalculationCollection.h" + +#include "RiuMainWindow.h" + +#include + +CAF_CMD_SOURCE_INIT( RicShowGridCalculatorFeature, "RicShowGridCalculatorFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicGridCalculatorDialog* RicShowGridCalculatorFeature::gridCalculatorDialog( bool createIfNotPresent ) +{ + RiuMainWindow* mainWindow = RiaGuiApplication::instance()->mainWindow(); + + if ( mainWindow ) + { + return mainWindow->gridCalculatorDialog( createIfNotPresent ); + } + + return nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicShowGridCalculatorFeature::hideGridCalculatorDialog() +{ + auto dialog = RicShowGridCalculatorFeature::gridCalculatorDialog( false ); + if ( dialog ) dialog->hide(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicShowGridCalculatorFeature::isCommandEnabled() +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicShowGridCalculatorFeature::onActionTriggered( bool isChecked ) +{ + RicGridCalculatorDialog* dialog = RicShowGridCalculatorFeature::gridCalculatorDialog( true ); + + RimProject* proj = RimProject::current(); + RimGridCalculationCollection* calcColl = proj->gridCalculationCollection(); + if ( calcColl->calculations().empty() ) + { + calcColl->addCalculation(); + } + + dialog->setCalculationAndUpdateUi( calcColl->calculations()[0] ); + + dialog->show(); + dialog->raise(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicShowGridCalculatorFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setText( "Grid Property Calculator" ); + actionToSetup->setIcon( QIcon( ":/Calculator.svg" ) ); +} diff --git a/ApplicationLibCode/Commands/RicShowGridCalculatorFeature.h b/ApplicationLibCode/Commands/RicShowGridCalculatorFeature.h new file mode 100644 index 0000000000..5d0d977cf3 --- /dev/null +++ b/ApplicationLibCode/Commands/RicShowGridCalculatorFeature.h @@ -0,0 +1,40 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +class RicGridCalculatorDialog; + +//================================================================================================== +/// +//================================================================================================== +class RicShowGridCalculatorFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +public: + static RicGridCalculatorDialog* gridCalculatorDialog( bool createIfNotPresent ); + static void hideGridCalculatorDialog(); + +protected: + bool isCommandEnabled() override; + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; +}; diff --git a/ApplicationLibCode/Commands/RicStackSelectedCurvesFeature.cpp b/ApplicationLibCode/Commands/RicStackSelectedCurvesFeature.cpp index e863157054..b5812416c9 100644 --- a/ApplicationLibCode/Commands/RicStackSelectedCurvesFeature.cpp +++ b/ApplicationLibCode/Commands/RicStackSelectedCurvesFeature.cpp @@ -36,7 +36,7 @@ RICF_SOURCE_INIT( RicStackSelectedCurvesFeature, "RicStackSelectedCurvesFeature" //-------------------------------------------------------------------------------------------------- RicStackSelectedCurvesFeature::RicStackSelectedCurvesFeature() { - CAF_PDM_InitScriptableFieldNoDefault( &m_curves, "curves", "", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_curves, "curves", "" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/RicStackSelectedCurvesFeature.h b/ApplicationLibCode/Commands/RicStackSelectedCurvesFeature.h index 566836d1f9..4d3d058e6d 100644 --- a/ApplicationLibCode/Commands/RicStackSelectedCurvesFeature.h +++ b/ApplicationLibCode/Commands/RicStackSelectedCurvesFeature.h @@ -41,7 +41,6 @@ class RicStackSelectedCurvesFeature : public caf::CmdFeature, public RicfCommand subsetOfPlotCurvesFromStacking( const std::vector& plotCurves, bool isStacked ); protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/RicThemeColorEditorFeature.h b/ApplicationLibCode/Commands/RicThemeColorEditorFeature.h index 5e2b09478a..c18dbebdc0 100644 --- a/ApplicationLibCode/Commands/RicThemeColorEditorFeature.h +++ b/ApplicationLibCode/Commands/RicThemeColorEditorFeature.h @@ -28,7 +28,6 @@ class RicThemeColorEditorFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/RicTogglePerspectiveViewFeature.h b/ApplicationLibCode/Commands/RicTogglePerspectiveViewFeature.h index cd00339147..3c003590e6 100644 --- a/ApplicationLibCode/Commands/RicTogglePerspectiveViewFeature.h +++ b/ApplicationLibCode/Commands/RicTogglePerspectiveViewFeature.h @@ -29,7 +29,6 @@ class RicTogglePerspectiveViewFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/RicUnstackSelectedCurvesFeature.cpp b/ApplicationLibCode/Commands/RicUnstackSelectedCurvesFeature.cpp index 68b5b8d7ca..b363bf3658 100644 --- a/ApplicationLibCode/Commands/RicUnstackSelectedCurvesFeature.cpp +++ b/ApplicationLibCode/Commands/RicUnstackSelectedCurvesFeature.cpp @@ -36,7 +36,7 @@ RICF_SOURCE_INIT( RicUnstackSelectedCurvesFeature, "RicUnstackSelectedCurvesFeat //-------------------------------------------------------------------------------------------------- RicUnstackSelectedCurvesFeature::RicUnstackSelectedCurvesFeature() { - CAF_PDM_InitScriptableFieldNoDefault( &m_curves, "curves", "", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_curves, "curves", "" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/RicUnstackSelectedCurvesFeature.h b/ApplicationLibCode/Commands/RicUnstackSelectedCurvesFeature.h index 18bff2fc0c..6810157789 100644 --- a/ApplicationLibCode/Commands/RicUnstackSelectedCurvesFeature.h +++ b/ApplicationLibCode/Commands/RicUnstackSelectedCurvesFeature.h @@ -38,7 +38,6 @@ class RicUnstackSelectedCurvesFeature : public caf::CmdFeature, public RicfComma caf::PdmScriptResponse execute() override; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/RicUserDefinedCalculatorDialog.cpp b/ApplicationLibCode/Commands/RicUserDefinedCalculatorDialog.cpp new file mode 100644 index 0000000000..446030ea67 --- /dev/null +++ b/ApplicationLibCode/Commands/RicUserDefinedCalculatorDialog.cpp @@ -0,0 +1,131 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- Statoil 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 "RicUserDefinedCalculatorDialog.h" + +#include "RiuTools.h" + +#include "RimUserDefinedCalculation.h" +#include "RimUserDefinedCalculationCollection.h" + +#include +#include +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicUserDefinedCalculatorDialog::RicUserDefinedCalculatorDialog( QWidget* parent, const QString& title ) + : QDialog( parent, RiuTools::defaultDialogFlags() ) +{ + setWindowTitle( title ); + resize( 1200, 800 ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicUserDefinedCalculatorDialog::~RicUserDefinedCalculatorDialog() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicUserDefinedCalculatorDialog::slotTryCloseDialog() +{ + RimUserDefinedCalculationCollection* calcCollection = calculationCollection(); + + if ( dirtyCount() > 0 ) + { + QMessageBox msgBox( this ); + msgBox.setIcon( QMessageBox::Question ); + + QString questionText = QString( "Detected calculation expression text modifications." ); + + msgBox.setText( questionText ); + msgBox.setInformativeText( "Do you want to trigger calculation?" ); + msgBox.setStandardButtons( QMessageBox::Yes | QMessageBox::No ); + + int ret = msgBox.exec(); + if ( ret == QMessageBox::No ) + { + reject(); + } + else if ( ret == QMessageBox::Yes ) + { + for ( auto c : calcCollection->calculations() ) + { + if ( c->isDirty() ) + { + c->calculate(); + c->updateDependentObjects(); + } + } + + if ( dirtyCount() > 0 ) + { + return; + } + } + else + { + return; + } + } + + accept(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicUserDefinedCalculatorDialog::setUp() +{ + QVBoxLayout* mainLayout = new QVBoxLayout( this ); + mainLayout->setContentsMargins( 0, 0, 0, 0 ); + + QWidget* calcEditorWidget = getCalculatorWidget(); + mainLayout->addWidget( calcEditorWidget ); + + QDialogButtonBox* buttonBox = new QDialogButtonBox( QDialogButtonBox::Close ); + connect( buttonBox, SIGNAL( rejected() ), this, SLOT( slotTryCloseDialog() ) ); + + mainLayout->addWidget( buttonBox ); + + updateUi(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RicUserDefinedCalculatorDialog::dirtyCount() const +{ + size_t count = 0; + + RimUserDefinedCalculationCollection* calcCollection = calculationCollection(); + for ( auto c : calcCollection->calculations() ) + { + if ( c->isDirty() ) + { + count++; + } + } + + return count; +} diff --git a/ApplicationLibCode/Commands/RicUserDefinedCalculatorDialog.h b/ApplicationLibCode/Commands/RicUserDefinedCalculatorDialog.h new file mode 100644 index 0000000000..47a06795e1 --- /dev/null +++ b/ApplicationLibCode/Commands/RicUserDefinedCalculatorDialog.h @@ -0,0 +1,49 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- Statoil 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 + +class RimUserDefinedCalculation; +class RimUserDefinedCalculationCollection; + +//================================================================================================== +/// +/// +//================================================================================================== +class RicUserDefinedCalculatorDialog : public QDialog +{ + Q_OBJECT + +public: + RicUserDefinedCalculatorDialog( QWidget* parent, const QString& title ); + ~RicUserDefinedCalculatorDialog() override; + + virtual void setCalculationAndUpdateUi( RimUserDefinedCalculation* calculation ) = 0; + virtual RimUserDefinedCalculationCollection* calculationCollection() const = 0; + virtual QWidget* getCalculatorWidget() = 0; + virtual void updateUi() = 0; + +private slots: + void slotTryCloseDialog(); + +protected: + void setUp(); + size_t dirtyCount() const; +}; diff --git a/ApplicationLibCode/Commands/RicUserDefinedCalculatorUi.cpp b/ApplicationLibCode/Commands/RicUserDefinedCalculatorUi.cpp new file mode 100644 index 0000000000..fe38b4b4f1 --- /dev/null +++ b/ApplicationLibCode/Commands/RicUserDefinedCalculatorUi.cpp @@ -0,0 +1,260 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- Statoil 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 "RicUserDefinedCalculatorUi.h" + +#include "RimUserDefinedCalculation.h" +#include "RimUserDefinedCalculationCollection.h" + +#include "cafAssert.h" +#include "cafPdmUiListEditor.h" +#include "cafPdmUiObjectEditorHandle.h" +#include "cafPdmUiPushButtonEditor.h" +#include "cafPdmUiTreeSelectionEditor.h" + +CAF_PDM_ABSTRACT_SOURCE_INIT( RicUserDefinedCalculatorUi, "RicUserDefinedCalculator" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicUserDefinedCalculatorUi::RicUserDefinedCalculatorUi() +{ + CAF_PDM_InitObject( "RicUserDefinedCalculator" ); + + CAF_PDM_InitFieldNoDefault( &m_currentCalculation, "CurrentCalculation", "" ); + m_currentCalculation.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); + // m_currentCalculation.uiCapability()->setUiEditorTypeName(caf::PdmUiTreeSelectionEditor::uiEditorTypeName()); + m_currentCalculation.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() ); + + CAF_PDM_InitFieldNoDefault( &m_newCalculation, "NewCalculation", "New Calculation" ); + RicUserDefinedCalculatorUi::assignPushButtonEditor( &m_newCalculation ); + + CAF_PDM_InitFieldNoDefault( &m_deleteCalculation, "DeleteCalculation", "Delete Calculation" ); + RicUserDefinedCalculatorUi::assignPushButtonEditor( &m_deleteCalculation ); + + m_calcContextMenuMgr = std::unique_ptr( new RiuCalculationsContextMenuManager() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimUserDefinedCalculation* RicUserDefinedCalculatorUi::currentCalculation() const +{ + return m_currentCalculation(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicUserDefinedCalculatorUi::setCurrentCalculation( RimUserDefinedCalculation* calculation ) +{ + m_currentCalculation = calculation; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicUserDefinedCalculatorUi::parseExpression() const +{ + if ( m_currentCalculation() ) + { + QString previousCurveName = m_currentCalculation->description(); + if ( !m_currentCalculation()->parseExpression() ) + { + return false; + } + + QString currentCurveName = m_currentCalculation->description(); + if ( previousCurveName != currentCurveName ) + { + notifyCalculatedNameChanged( m_currentCalculation()->id(), currentCurveName ); + } + + m_currentCalculation()->updateDependentObjects(); + } + + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicUserDefinedCalculatorUi::fieldChangedByUi( const caf::PdmFieldHandle* changedField, + const QVariant& oldValue, + const QVariant& newValue ) +{ + if ( changedField == &m_newCalculation ) + { + m_newCalculation = false; + + m_currentCalculation = calculationCollection()->addCalculation(); + + this->updateConnectedEditors(); + } + else if ( changedField == &m_deleteCalculation ) + { + m_deleteCalculation = false; + + if ( m_currentCalculation() ) + { + calculationCollection()->deleteCalculation( m_currentCalculation() ); + m_currentCalculation = nullptr; + + this->updateConnectedEditors(); + caf::PdmUiObjectEditorHandle::updateUiAllObjectEditors(); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicUserDefinedCalculatorUi::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +{ + if ( !m_currentCalculation() && !calculationCollection()->calculations().empty() ) + { + m_currentCalculation = calculationCollection()->calculations()[0]; + } + + { + caf::PdmUiGroup* group = uiOrdering.addNewGroupWithKeyword( "Calculations", calculationsGroupName() ); + group->add( &m_currentCalculation ); + group->add( &m_newCalculation ); + group->add( &m_deleteCalculation ); + } + + { + caf::PdmUiGroup* group = uiOrdering.addNewGroupWithKeyword( "Calculation Settings", calulationGroupName() ); + if ( m_currentCalculation() ) + { + m_currentCalculation->uiOrdering( uiConfigName, *group ); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList + RicUserDefinedCalculatorUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) +{ + QList options; + if ( fieldNeedingOptions == &m_currentCalculation ) + { + for ( auto c : calculationCollection()->calculations() ) + { + options.push_back( caf::PdmOptionItemInfo( c->description(), c ) ); + } + } + + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicUserDefinedCalculatorUi::assignPushButtonEditor( caf::PdmFieldHandle* fieldHandle ) +{ + CAF_ASSERT( fieldHandle ); + CAF_ASSERT( fieldHandle->uiCapability() ); + + fieldHandle->uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); + fieldHandle->uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicUserDefinedCalculatorUi::assignPushButtonEditorText( caf::PdmUiEditorAttribute* attribute, const QString& text ) +{ + caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast( attribute ); + if ( attrib ) + { + attrib->m_buttonText = text; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicUserDefinedCalculatorUi::calculate() const +{ + if ( m_currentCalculation() ) + { + QString previousCurveName = m_currentCalculation->description(); + if ( !m_currentCalculation()->parseExpression() ) + { + return false; + } + + QString currentCurveName = m_currentCalculation->description(); + if ( previousCurveName != currentCurveName ) + { + notifyCalculatedNameChanged( m_currentCalculation()->id(), currentCurveName ); + } + + if ( !m_currentCalculation()->calculate() ) + { + return false; + } + + m_currentCalculation()->updateDependentObjects(); + caf::PdmUiObjectEditorHandle::updateUiAllObjectEditors(); + } + + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicUserDefinedCalculatorUi::defineEditorAttribute( const caf::PdmFieldHandle* field, + QString uiConfigName, + caf::PdmUiEditorAttribute* attribute ) +{ + if ( &m_newCalculation == field ) + { + RicUserDefinedCalculatorUi::assignPushButtonEditorText( attribute, "New Calculation" ); + } + else if ( &m_deleteCalculation == field ) + { + RicUserDefinedCalculatorUi::assignPushButtonEditorText( attribute, "Delete Calculation" ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicUserDefinedCalculatorUi::onEditorWidgetsCreated() +{ + if ( m_currentCalculation() != nullptr ) + { + m_currentCalculation->attachToWidget(); + } + + for ( const auto& e : m_currentCalculation.uiCapability()->connectedEditors() ) + { + caf::PdmUiListEditor* listEditor = dynamic_cast( e ); + if ( !listEditor ) continue; + + QWidget* widget = listEditor->editorWidget(); + if ( !widget ) continue; + + m_calcContextMenuMgr->attachWidget( widget, this ); + } +} diff --git a/ApplicationLibCode/Commands/RicUserDefinedCalculatorUi.h b/ApplicationLibCode/Commands/RicUserDefinedCalculatorUi.h new file mode 100644 index 0000000000..cae090f4ba --- /dev/null +++ b/ApplicationLibCode/Commands/RicUserDefinedCalculatorUi.h @@ -0,0 +1,72 @@ +//////////////////////////// ///////////////////////////////////////////////////// +// +// Copyright (C) 2017- Statoil 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 "RiuCalculationsContextMenuManager.h" +#include "cafPdmField.h" +#include "cafPdmObject.h" +#include "cafPdmPtrField.h" +#include + +class RimUserDefinedCalculationCollection; +class RimUserDefinedCalculation; + +//================================================================================================== +/// +//================================================================================================== +class RicUserDefinedCalculatorUi : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RicUserDefinedCalculatorUi(); + + RimUserDefinedCalculation* currentCalculation() const; + void setCurrentCalculation( RimUserDefinedCalculation* calculation ); + + bool parseExpression() const; + bool calculate() const; + + virtual QString calculationsGroupName() const = 0; + virtual QString calulationGroupName() const = 0; + virtual RimUserDefinedCalculationCollection* calculationCollection() const = 0; + virtual void notifyCalculatedNameChanged( int id, const QString& newName ) const = 0; + +private: + void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; + void defineEditorAttribute( const caf::PdmFieldHandle* field, + QString uiConfigName, + caf::PdmUiEditorAttribute* attribute ) override; + void onEditorWidgetsCreated() override; + +private: + // TODO : Move to a common caf helper class + static void assignPushButtonEditor( caf::PdmFieldHandle* fieldHandle ); + static void assignPushButtonEditorText( caf::PdmUiEditorAttribute* attribute, const QString& text ); + +private: + caf::PdmPtrField m_currentCalculation; + + caf::PdmField m_newCalculation; + caf::PdmField m_deleteCalculation; + + std::unique_ptr m_calcContextMenuMgr; +}; diff --git a/ApplicationLibCode/Commands/RicWellLogTools.cpp b/ApplicationLibCode/Commands/RicWellLogTools.cpp index 02ce78e04e..3632ed87a5 100644 --- a/ApplicationLibCode/Commands/RicWellLogTools.cpp +++ b/ApplicationLibCode/Commands/RicWellLogTools.cpp @@ -29,6 +29,7 @@ #include "RimEclipseResultCase.h" #include "RimProject.h" #include "RimSimWellInView.h" +#include "RimSummaryCase.h" #include "RimWellLogCurveCommonDataSource.h" #include "RimWellLogExtractionCurve.h" #include "RimWellLogFile.h" @@ -108,7 +109,11 @@ bool RicWellLogTools::hasRftDataForWell( const QString& wellName ) { if ( resultCase->rftReader() ) { - return resultCase->rftReader()->wellHasRftData( wellName ); + auto wellNames = resultCase->rftReader()->wellNames(); + for ( const auto& w : wellNames ) + { + if ( w == wellName ) return true; + } } } } @@ -321,7 +326,6 @@ ExtractionCurveType* RicWellLogTools::addExtractionCurve( RimWellLogTrack* plotTrack->updateConnectedEditors(); plot->updateConnectedEditors(); - RimProject::current()->updateConnectedEditors(); RiaGuiApplication::instance()->getOrCreateMainPlotWindow(); RiuPlotMainWindowTools::selectAsCurrentItem( curve ); @@ -364,6 +368,34 @@ RimWellLogRftCurve* plotTrack->setFormationCase( resultCase ); plotTrack->setFormationSimWellName( simWell->name() ); } + else if ( resultCase ) + { + curve->setEclipseResultCase( resultCase ); + + auto wellNames = resultCase->rftReader()->wellNames(); + if ( !wellNames.empty() ) + { + auto wellName = *( wellNames.begin() ); + curve->setDefaultAddress( wellName ); + } + } + else + { + auto sumCases = RimProject::current()->allSummaryCases(); + + for ( auto sc : sumCases ) + { + if ( sc->rftReader() ) + { + auto rftReader = sc->rftReader(); + + curve->setSummaryCase( sc ); + + auto addresses = rftReader->eclipseRftAddresses(); + if ( !addresses.empty() ) curve->setRftAddress( *addresses.begin() ); + } + } + } cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable( plotTrack->curveCount() ); curve->setColor( curveColor ); @@ -372,7 +404,6 @@ RimWellLogRftCurve* plotTrack->setFormationTrajectoryType( RimWellLogTrack::SIMULATION_WELL ); plotTrack->updateConnectedEditors(); - RimProject::current()->updateConnectedEditors(); RiaGuiApplication::instance()->getOrCreateMainPlotWindow(); RiuPlotMainWindowTools::selectAsCurrentItem( curve ); @@ -401,7 +432,6 @@ RimWellLogFileCurve* RicWellLogTools::addFileCurve( RimWellLogTrack* plotTrack, plotTrack->updateConnectedEditors(); - RimProject::current()->updateConnectedEditors(); RiaGuiApplication::instance()->getOrCreateMainPlotWindow(); RiuPlotMainWindowTools::selectAsCurrentItem( curve ); @@ -474,7 +504,6 @@ RimWellMeasurementCurve* RicWellLogTools::addWellMeasurementCurve( RimWellLogTra plotTrack->addCurve( curve ); plotTrack->updateConnectedEditors(); - RimProject::current()->updateConnectedEditors(); RiaGuiApplication::instance()->getOrCreateMainPlotWindow(); RiuPlotMainWindowTools::selectAsCurrentItem( curve ); diff --git a/ApplicationLibCode/Commands/SsiHubImportCommands/RicWellPathsImportSsihubFeature.h b/ApplicationLibCode/Commands/SsiHubImportCommands/RicWellPathsImportSsihubFeature.h index 6cdb86a22c..2dcf2a7d73 100644 --- a/ApplicationLibCode/Commands/SsiHubImportCommands/RicWellPathsImportSsihubFeature.h +++ b/ApplicationLibCode/Commands/SsiHubImportCommands/RicWellPathsImportSsihubFeature.h @@ -29,7 +29,6 @@ class RicWellPathsImportSsihubFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/SsiHubImportCommands/RimOilFieldEntry.cpp b/ApplicationLibCode/Commands/SsiHubImportCommands/RimOilFieldEntry.cpp index cb684c6ac0..fe23294674 100644 --- a/ApplicationLibCode/Commands/SsiHubImportCommands/RimOilFieldEntry.cpp +++ b/ApplicationLibCode/Commands/SsiHubImportCommands/RimOilFieldEntry.cpp @@ -35,15 +35,15 @@ CAF_PDM_SOURCE_INIT( RimOilFieldEntry, "RimOilFieldEntry" ); //-------------------------------------------------------------------------------------------------- RimOilFieldEntry::RimOilFieldEntry() { - CAF_PDM_InitObject( "OilFieldEntry", "", "", "" ); + CAF_PDM_InitObject( "OilFieldEntry" ); - CAF_PDM_InitFieldNoDefault( &name, "OilFieldName", "Oil Field Name", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &edmId, "EdmId", "Edm ID", "", "", "" ); - CAF_PDM_InitField( &selected, "Selected", false, "Selected", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &name, "OilFieldName", "Oil Field Name" ); + CAF_PDM_InitFieldNoDefault( &edmId, "EdmId", "Edm ID" ); + CAF_PDM_InitField( &selected, "Selected", false, "Selected" ); - CAF_PDM_InitFieldNoDefault( &wellsFilePath, "wellsFilePath", "Wells File Path", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &wellsFilePath, "wellsFilePath", "Wells File Path" ); - CAF_PDM_InitFieldNoDefault( &wells, "Wells", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &wells, "Wells", "" ); wells.uiCapability()->setUiTreeHidden( true ); wells.uiCapability()->setUiTreeChildrenHidden( true ); } @@ -53,7 +53,7 @@ RimOilFieldEntry::RimOilFieldEntry() //-------------------------------------------------------------------------------------------------- RimOilFieldEntry::~RimOilFieldEntry() { - wells.deleteAllChildObjects(); + wells.deleteChildren(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/SsiHubImportCommands/RimOilRegionEntry.cpp b/ApplicationLibCode/Commands/SsiHubImportCommands/RimOilRegionEntry.cpp index 0e44542c6a..f03bb5297a 100644 --- a/ApplicationLibCode/Commands/SsiHubImportCommands/RimOilRegionEntry.cpp +++ b/ApplicationLibCode/Commands/SsiHubImportCommands/RimOilRegionEntry.cpp @@ -26,14 +26,14 @@ CAF_PDM_SOURCE_INIT( RimOilRegionEntry, "RimOilRegionEntry" ); //-------------------------------------------------------------------------------------------------- RimOilRegionEntry::RimOilRegionEntry() { - CAF_PDM_InitObject( "OilRegionEntry", "", "", "" ); + CAF_PDM_InitObject( "OilRegionEntry" ); - CAF_PDM_InitFieldNoDefault( &name, "OilRegionEntry", "OilRegionEntry", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &name, "OilRegionEntry", "OilRegionEntry" ); - CAF_PDM_InitFieldNoDefault( &fields, "Fields", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &fields, "Fields", "" ); fields.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitField( &selected, "Selected", false, "Selected", "", "", "" ); + CAF_PDM_InitField( &selected, "Selected", false, "Selected" ); } //-------------------------------------------------------------------------------------------------- @@ -41,7 +41,7 @@ RimOilRegionEntry::RimOilRegionEntry() //-------------------------------------------------------------------------------------------------- RimOilRegionEntry::~RimOilRegionEntry() { - fields.deleteAllChildObjects(); + fields.deleteChildren(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/SsiHubImportCommands/RimWellPathImport.cpp b/ApplicationLibCode/Commands/SsiHubImportCommands/RimWellPathImport.cpp index bab5838747..e577c63364 100644 --- a/ApplicationLibCode/Commands/SsiHubImportCommands/RimWellPathImport.cpp +++ b/ApplicationLibCode/Commands/SsiHubImportCommands/RimWellPathImport.cpp @@ -25,6 +25,7 @@ #include "RimWellPath.h" #include "RimWellPathCollection.h" +#include "cafPdmUiTreeAttributes.h" #include "cafPdmUiTreeViewEditor.h" #include @@ -49,20 +50,20 @@ CAF_PDM_SOURCE_INIT( RimWellPathImport, "RimWellPathImport" ); //-------------------------------------------------------------------------------------------------- RimWellPathImport::RimWellPathImport() { - CAF_PDM_InitObject( "RimWellPathImport", "", "", "" ); + CAF_PDM_InitObject( "RimWellPathImport" ); - CAF_PDM_InitField( &wellTypeSurvey, "WellTypeSurvey", true, "Survey", "", "", "" ); - CAF_PDM_InitField( &wellTypePlans, "WellTypePlans", true, "Plans", "", "", "" ); + CAF_PDM_InitField( &wellTypeSurvey, "WellTypeSurvey", true, "Survey" ); + CAF_PDM_InitField( &wellTypePlans, "WellTypePlans", true, "Plans" ); caf::AppEnum defaultUtmMode = UTM_FILTER_OFF; - CAF_PDM_InitField( &utmFilterMode, "UtmMode", defaultUtmMode, "Utm Filter", "", "", "" ); + CAF_PDM_InitField( &utmFilterMode, "UtmMode", defaultUtmMode, "Utm Filter" ); - CAF_PDM_InitField( &north, "UtmNorth", 0.0, "North", "", "", "" ); - CAF_PDM_InitField( &south, "UtmSouth", 0.0, "South", "", "", "" ); - CAF_PDM_InitField( &east, "UtmEast", 0.0, "East", "", "", "" ); - CAF_PDM_InitField( &west, "UtmWest", 0.0, "West", "", "", "" ); + CAF_PDM_InitField( &north, "UtmNorth", 0.0, "North" ); + CAF_PDM_InitField( &south, "UtmSouth", 0.0, "South" ); + CAF_PDM_InitField( &east, "UtmEast", 0.0, "East" ); + CAF_PDM_InitField( &west, "UtmWest", 0.0, "West" ); - CAF_PDM_InitFieldNoDefault( ®ions, "Regions", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( ®ions, "Regions", "" ); regions.uiCapability()->setUiTreeHidden( true ); } @@ -98,7 +99,7 @@ void RimWellPathImport::updateRegions( const QStringList& regionStrings, for ( size_t i = 0; i < fieldsToRemove.size(); i++ ) { - this->regions[regionIdx]->fields.removeChildObject( fieldsToRemove[i] ); + this->regions[regionIdx]->fields.removeChild( fieldsToRemove[i] ); delete fieldsToRemove[i]; } @@ -107,7 +108,7 @@ void RimWellPathImport::updateRegions( const QStringList& regionStrings, for ( size_t i = 0; i < regionsToRemove.size(); i++ ) { - this->regions.removeChildObject( regionsToRemove[i] ); + this->regions.removeChild( regionsToRemove[i] ); delete regionsToRemove[i]; } @@ -217,7 +218,7 @@ void RimWellPathImport::defineObjectEditorAttribute( QString uiConfigName, caf:: //-------------------------------------------------------------------------------------------------- RimWellPathImport::~RimWellPathImport() { - regions.deleteAllChildObjects(); + regions.deleteChildren(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/SsiHubImportCommands/RimWellsEntry.cpp b/ApplicationLibCode/Commands/SsiHubImportCommands/RimWellsEntry.cpp index 87eb598479..4da94f883d 100644 --- a/ApplicationLibCode/Commands/SsiHubImportCommands/RimWellsEntry.cpp +++ b/ApplicationLibCode/Commands/SsiHubImportCommands/RimWellsEntry.cpp @@ -39,18 +39,18 @@ CAF_PDM_SOURCE_INIT( RimWellPathEntry, "RimWellPathEntry" ); //-------------------------------------------------------------------------------------------------- RimWellPathEntry::RimWellPathEntry() { - CAF_PDM_InitObject( "WellPathEntry", "", "", "" ); + CAF_PDM_InitObject( "WellPathEntry" ); - CAF_PDM_InitFieldNoDefault( &name, "Name", "Name", "", "", "" ); - CAF_PDM_InitField( &selected, "Selected", false, "Selected", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &name, "Name", "Name" ); + CAF_PDM_InitField( &selected, "Selected", false, "Selected" ); caf::AppEnum wellType = WELL_ALL; - CAF_PDM_InitField( &wellPathType, "WellPathType", wellType, "Well path type", "", "", "" ); + CAF_PDM_InitField( &wellPathType, "WellPathType", wellType, "Well path type" ); - CAF_PDM_InitFieldNoDefault( &surveyType, "surveyType", "surveyType", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &requestUrl, "requestUrl", "requestUrl", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &surveyType, "surveyType", "surveyType" ); + CAF_PDM_InitFieldNoDefault( &requestUrl, "requestUrl", "requestUrl" ); - CAF_PDM_InitFieldNoDefault( &wellPathFilePath, "wellPathFilePath", "wellPathFilePath", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &wellPathFilePath, "wellPathFilePath", "wellPathFilePath" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/SsiHubImportCommands/RiuWellImportWizard.cpp b/ApplicationLibCode/Commands/SsiHubImportCommands/RiuWellImportWizard.cpp index 17cb753607..eb43b93b88 100644 --- a/ApplicationLibCode/Commands/SsiHubImportCommands/RiuWellImportWizard.cpp +++ b/ApplicationLibCode/Commands/SsiHubImportCommands/RiuWellImportWizard.cpp @@ -32,6 +32,7 @@ #include "cafPdmObjectGroup.h" #include "cafPdmUiListView.h" #include "cafPdmUiPropertyView.h" +#include "cafPdmUiTreeAttributes.h" #include "cafPdmUiTreeView.h" #include "cafPdmUiTreeViewEditor.h" #include "cafUtils.h" @@ -727,7 +728,7 @@ void RiuWellImportWizard::parseWellsResponse( RimOilFieldEntry* oilFieldEntry ) for ( size_t i = 0; i < wellsToRemove.size(); i++ ) { - oilFieldEntry->wells.removeChildObject( wellsToRemove[i] ); + oilFieldEntry->wells.removeChild( wellsToRemove[i] ); delete wellsToRemove[i]; } @@ -901,7 +902,7 @@ void WellSelectionPage::buildWellTreeView() } // Delete all temporary pdm object groups - m_regionsWithVisibleWells->objects.deleteAllChildObjects(); + m_regionsWithVisibleWells->objects.deleteChildren(); for ( size_t rIdx = 0; rIdx < m_wellPathImportObject->regions.size(); rIdx++ ) { @@ -981,7 +982,7 @@ void WellSelectionPage::selectedWellPathEntries( std::vector& do for ( size_t i = 0; i < childFields.size(); i++ ) { std::vector childObjects; - childFields[i]->childObjects( &childObjects ); + childFields[i]->children( &childObjects ); for ( size_t j = 0; j < childObjects.size(); j++ ) { @@ -1116,7 +1117,7 @@ void WellSummaryPage::initializePage() //-------------------------------------------------------------------------------------------------- void WellSummaryPage::updateSummaryPage() { - m_objectGroup->objects.clear(); + m_objectGroup->objects.deleteChildren(); m_textEdit->setText( "Summary of imported wells\n\n" ); @@ -1198,9 +1199,9 @@ CAF_PDM_SOURCE_INIT( SummaryPageDownloadEntity, "SummaryPageDownloadEntity" ); //-------------------------------------------------------------------------------------------------- SummaryPageDownloadEntity::SummaryPageDownloadEntity() { - CAF_PDM_InitObject( "SummaryPageDownloadEntity", "", "", "" ); + CAF_PDM_InitObject( "SummaryPageDownloadEntity" ); - CAF_PDM_InitFieldNoDefault( &name, "Name", "", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &requestUrl, "RequestUrl", "", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &responseFilename, "ResponseFilename", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &name, "Name", "" ); + CAF_PDM_InitFieldNoDefault( &requestUrl, "RequestUrl", "" ); + CAF_PDM_InitFieldNoDefault( &responseFilename, "ResponseFilename", "" ); } diff --git a/ApplicationLibCode/Commands/SsiHubImportCommands/RiuWellImportWizard.h b/ApplicationLibCode/Commands/SsiHubImportCommands/RiuWellImportWizard.h index 6a5dce6ae5..16c841312f 100644 --- a/ApplicationLibCode/Commands/SsiHubImportCommands/RiuWellImportWizard.h +++ b/ApplicationLibCode/Commands/SsiHubImportCommands/RiuWellImportWizard.h @@ -86,9 +86,9 @@ class ObjectGroupWithHeaders : public caf::PdmObject public: ObjectGroupWithHeaders() { - CAF_PDM_InitFieldNoDefault( &objects, "PdmObjects", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &objects, "PdmObjects", "" ); - CAF_PDM_InitField( &m_isChecked, "IsChecked", true, "Active", "", "", "" ); + CAF_PDM_InitField( &m_isChecked, "IsChecked", true, "Active" ); m_isChecked.uiCapability()->setUiHidden( true ); }; @@ -228,7 +228,7 @@ public slots: int wellSelectionPageId(); -#if !defined(QT_NO_OPENSSL) && !defined(CVF_OSX) +#if !defined( QT_NO_OPENSSL ) && !defined( CVF_OSX ) void sslErrors( QNetworkReply*, const QList& errors ); #endif diff --git a/ApplicationLibCode/Commands/StreamlineCommands/RicNewStreamlineFeature.h b/ApplicationLibCode/Commands/StreamlineCommands/RicNewStreamlineFeature.h index 504c40c751..a85a088ab5 100644 --- a/ApplicationLibCode/Commands/StreamlineCommands/RicNewStreamlineFeature.h +++ b/ApplicationLibCode/Commands/StreamlineCommands/RicNewStreamlineFeature.h @@ -28,7 +28,6 @@ class RicNewStreamlineFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/CMakeLists_files.cmake b/ApplicationLibCode/Commands/SummaryPlotCommands/CMakeLists_files.cmake index 96ff126b96..fe183d08c8 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/CMakeLists_files.cmake +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/CMakeLists_files.cmake @@ -1,5 +1,5 @@ set(SOURCE_GROUP_HEADER_FILES - ${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryPlotFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicOpenSummaryPlotEditorFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicNewDefaultSummaryPlotFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryCrossPlotFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryCurveFeature.h @@ -30,7 +30,6 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RicShowSummaryCurveCalculatorFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicEditSummaryCurveCalculationFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculatorDialog.h - ${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculatorWidgetCreator.h ${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculatorUi.h ${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryCrossPlotCurveFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryEnsembleCurveSetFeature.h @@ -41,12 +40,14 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RicSetSourceSteppingSummaryCurveFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicClearSourceSteppingEnsembleCurveSetFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicSetSourceSteppingEnsembleCurveSetFeature.h - ${CMAKE_CURRENT_LIST_DIR}/RicActivateCurveFilterInToolbarFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicNewDerivedSummaryFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicNewPlotAxisPropertiesFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicShowSummaryPlotManagerFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicPasteSummaryMultiPlotFeature.h ) set(SOURCE_GROUP_SOURCE_FILES - ${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryPlotFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicOpenSummaryPlotEditorFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewDefaultSummaryPlotFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryCrossPlotFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryCurveFeature.cpp @@ -77,7 +78,6 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RicShowSummaryCurveCalculatorFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicEditSummaryCurveCalculationFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculatorDialog.cpp - ${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculatorWidgetCreator.cpp ${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculatorUi.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryCrossPlotCurveFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryEnsembleCurveSetFeature.cpp @@ -88,8 +88,10 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RicSetSourceSteppingSummaryCurveFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicClearSourceSteppingEnsembleCurveSetFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicSetSourceSteppingEnsembleCurveSetFeature.cpp - ${CMAKE_CURRENT_LIST_DIR}/RicActivateCurveFilterInToolbarFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewDerivedSummaryFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicNewPlotAxisPropertiesFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicShowSummaryPlotManagerFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicPasteSummaryMultiPlotFeature.cpp ) list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) @@ -101,7 +103,6 @@ list( COMMAND_QT_MOC_HEADERS ${CMAKE_CURRENT_LIST_DIR}/RicSummaryPlotEditorWidgetCreator.h ${CMAKE_CURRENT_LIST_DIR}/RicSummaryPlotEditorDialog.h - ${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculatorWidgetCreator.h ${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculatorDialog.h ) diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicAsciiExportSummaryPlotFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicAsciiExportSummaryPlotFeature.cpp index ca91b371f3..f92ee8c3c5 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicAsciiExportSummaryPlotFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicAsciiExportSummaryPlotFeature.cpp @@ -170,10 +170,10 @@ bool RicAsciiExportSummaryPlotFeature::exportTextToFile( const QString& fileName //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RicAsciiExportSummaryPlotFeature::exportAsciiForSummaryPlot( const QString& fileName, - const RimSummaryPlot* summaryPlot, - RiaQDateTimeTools::DateTimePeriod resamplingPeriod, - bool showTimeAsLongString ) +bool RicAsciiExportSummaryPlotFeature::exportAsciiForSummaryPlot( const QString& fileName, + const RimSummaryPlot* summaryPlot, + RiaDefines::DateTimePeriod resamplingPeriod, + bool showTimeAsLongString ) { QString text = summaryPlot->description(); text.append( summaryPlot->asciiDataForSummaryPlotExport( resamplingPeriod, showTimeAsLongString ) ); diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicAsciiExportSummaryPlotFeature.h b/ApplicationLibCode/Commands/SummaryPlotCommands/RicAsciiExportSummaryPlotFeature.h index 76a7078e62..77d021bb07 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicAsciiExportSummaryPlotFeature.h +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicAsciiExportSummaryPlotFeature.h @@ -18,8 +18,7 @@ #pragma once -#include "RiaQDateTimeTools.h" - +#include "RiaDateTimeDefines.h" #include "cafCmdFeature.h" class RimSummaryPlot; @@ -42,8 +41,8 @@ class RicAsciiExportSummaryPlotFeature : public caf::CmdFeature void setupActionLook( QAction* actionToSetup ) override; private: - static bool exportAsciiForSummaryPlot( const QString& fileName, - const RimSummaryPlot* selectedSummaryPlots, - RiaQDateTimeTools::DateTimePeriod resamplingPeriod, - bool showTimeAsLongString ); + static bool exportAsciiForSummaryPlot( const QString& fileName, + const RimSummaryPlot* selectedSummaryPlots, + RiaDefines::DateTimePeriod resamplingPeriod, + bool showTimeAsLongString ); }; diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotCurveFeature.h b/ApplicationLibCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotCurveFeature.h index 5777608823..9805775091 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotCurveFeature.h +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotCurveFeature.h @@ -34,7 +34,6 @@ class RicDuplicateSummaryCrossPlotCurveFeature : public RicDuplicateSummaryCurve CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void setupActionLook( QAction* actionToSetup ) override; }; diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotFeature.h b/ApplicationLibCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotFeature.h index d19ba63e7a..334819020c 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotFeature.h +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotFeature.h @@ -20,10 +20,6 @@ #include "cafCmdFeature.h" -class RimSummaryPlotCollection; -class RimSummaryCase; -class RimSummaryPlot; - //================================================================================================== /// //================================================================================================== @@ -32,7 +28,6 @@ class RicDuplicateSummaryCrossPlotFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCurveFeature.h b/ApplicationLibCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCurveFeature.h index 53761865f9..011ea04454 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCurveFeature.h +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCurveFeature.h @@ -32,7 +32,6 @@ class RicDuplicateSummaryCurveFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicDuplicateSummaryPlotFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicDuplicateSummaryPlotFeature.cpp index 12a31ba8dd..8d52433dfd 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicDuplicateSummaryPlotFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicDuplicateSummaryPlotFeature.cpp @@ -22,8 +22,8 @@ #include "RicPasteSummaryPlotFeature.h" +#include "RimSummaryMultiPlot.h" #include "RimSummaryPlot.h" -#include "RimSummaryPlotCollection.h" #include "cafSelectionManagerTools.h" #include "cvfAssert.h" @@ -37,15 +37,15 @@ CAF_CMD_SOURCE_INIT( RicDuplicateSummaryPlotFeature, "RicDuplicateSummaryPlotFea //-------------------------------------------------------------------------------------------------- bool RicDuplicateSummaryPlotFeature::isCommandEnabled() { - RimSummaryPlotCollection* sumPlotColl = nullptr; + RimSummaryMultiPlot* multiPlot = nullptr; caf::PdmObject* selObj = dynamic_cast( caf::SelectionManager::instance()->selectedItem() ); if ( selObj ) { - sumPlotColl = RiaSummaryTools::parentSummaryPlotCollection( selObj ); + multiPlot = RiaSummaryTools::parentSummaryMultiPlot( selObj ); } - if ( sumPlotColl ) return true; + if ( multiPlot ) return true; return false; } diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicDuplicateSummaryPlotFeature.h b/ApplicationLibCode/Commands/SummaryPlotCommands/RicDuplicateSummaryPlotFeature.h index f95cc11b61..4bd16223ba 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicDuplicateSummaryPlotFeature.h +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicDuplicateSummaryPlotFeature.h @@ -20,10 +20,6 @@ #include "cafCmdFeature.h" -class RimSummaryPlotCollection; -class RimSummaryCase; -class RimSummaryPlot; - //================================================================================================== /// //================================================================================================== @@ -32,7 +28,6 @@ class RicDuplicateSummaryPlotFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicEditSummaryCrossPlotFeature.h b/ApplicationLibCode/Commands/SummaryPlotCommands/RicEditSummaryCrossPlotFeature.h index eb1f98e365..69458e4090 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicEditSummaryCrossPlotFeature.h +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicEditSummaryCrossPlotFeature.h @@ -37,7 +37,6 @@ class RicEditSummaryCrossPlotFeature : public caf::CmdFeature static RicSummaryPlotEditorDialog* curveCreatorDialog(); protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicEditSummaryCurveCalculationFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicEditSummaryCurveCalculationFeature.cpp index 73c2d14213..8464c548bc 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicEditSummaryCurveCalculationFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicEditSummaryCurveCalculationFeature.cpp @@ -55,7 +55,7 @@ bool RicEditSummaryCurveCalculationFeature::isCommandEnabled() void RicEditSummaryCurveCalculationFeature::onActionTriggered( bool isChecked ) { std::vector selectedCurves = caf::selectedObjectsByType(); - RimSummaryCalculation* calculation = nullptr; + RimUserDefinedCalculation* calculation = nullptr; if ( selectedCurves.size() > 0 ) { @@ -70,7 +70,7 @@ void RicEditSummaryCurveCalculationFeature::onActionTriggered( bool isChecked ) } } - RicSummaryCurveCalculatorDialog* dialog = RicShowSummaryCurveCalculatorFeature::curveCalculatorDialog(); + RicSummaryCurveCalculatorDialog* dialog = RicShowSummaryCurveCalculatorFeature::curveCalculatorDialog( true ); dialog->setCalculationAndUpdateUi( calculation ); dialog->show(); dialog->raise(); diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicEditSummaryCurveCalculationFeature.h b/ApplicationLibCode/Commands/SummaryPlotCommands/RicEditSummaryCurveCalculationFeature.h index af597d66bb..61c61dab3a 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicEditSummaryCurveCalculationFeature.h +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicEditSummaryCurveCalculationFeature.h @@ -20,10 +20,6 @@ #include "cafCmdFeature.h" -class RimSummaryPlot; -class RimSummaryPlotCollection; -class RimSummaryCase; - //================================================================================================== /// //================================================================================================== diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicEditSummaryPlotFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicEditSummaryPlotFeature.cpp index 32f7b44038..1daab4da12 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicEditSummaryPlotFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicEditSummaryPlotFeature.cpp @@ -50,7 +50,7 @@ RicEditSummaryPlotFeature::RicEditSummaryPlotFeature() //-------------------------------------------------------------------------------------------------- void RicEditSummaryPlotFeature::closeDialogAndResetTargetPlot() { - auto dialog = RicEditSummaryPlotFeature::curveCreatorDialog(); + auto dialog = RicEditSummaryPlotFeature::curveCreatorDialog( false ); if ( dialog ) { @@ -65,13 +65,13 @@ void RicEditSummaryPlotFeature::closeDialogAndResetTargetPlot() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RicSummaryPlotEditorDialog* RicEditSummaryPlotFeature::curveCreatorDialog() +RicSummaryPlotEditorDialog* RicEditSummaryPlotFeature::curveCreatorDialog( bool createIfNotPresent ) { RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow(); if ( mainPlotWindow ) { - return mainPlotWindow->summaryCurveCreatorDialog(); + return mainPlotWindow->summaryCurveCreatorDialog( createIfNotPresent ); } return nullptr; @@ -82,7 +82,7 @@ RicSummaryPlotEditorDialog* RicEditSummaryPlotFeature::curveCreatorDialog() //-------------------------------------------------------------------------------------------------- void RicEditSummaryPlotFeature::editSummaryPlot( RimSummaryPlot* plot ) { - auto dialog = RicEditSummaryPlotFeature::curveCreatorDialog(); + auto dialog = RicEditSummaryPlotFeature::curveCreatorDialog( true ); if ( !dialog->isVisible() ) { diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicEditSummaryPlotFeature.h b/ApplicationLibCode/Commands/SummaryPlotCommands/RicEditSummaryPlotFeature.h index a51d6e3982..29dca7d6c0 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicEditSummaryPlotFeature.h +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicEditSummaryPlotFeature.h @@ -34,7 +34,7 @@ class RicEditSummaryPlotFeature : public caf::CmdFeature public: void closeDialogAndResetTargetPlot(); - static RicSummaryPlotEditorDialog* curveCreatorDialog(); + static RicSummaryPlotEditorDialog* curveCreatorDialog( bool createIfNotPresent ); static void editSummaryPlot( RimSummaryPlot* plot ); protected: diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewDefaultSummaryPlotFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewDefaultSummaryPlotFeature.cpp index 765f60595f..ae7509c5d7 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewDefaultSummaryPlotFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewDefaultSummaryPlotFeature.cpp @@ -20,6 +20,7 @@ #include "RiaSummaryTools.h" +#include "PlotBuilderCommands/RicSummaryPlotBuilder.h" #include "RicEditSummaryPlotFeature.h" #include "RicNewSummaryCurveFeature.h" #include "RicNewSummaryEnsembleCurveSetFeature.h" @@ -36,9 +37,8 @@ #include "RimSummaryCase.h" #include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" -#include "RimSummaryCurveFilter.h" +#include "RimSummaryMultiPlot.h" #include "RimSummaryPlot.h" -#include "RimSummaryPlotCollection.h" #include "RiuPlotMainWindow.h" #include "RiuPlotMainWindowTools.h" @@ -67,48 +67,15 @@ void extractPlotObjectsFromSelection( std::vector* se { return; } - - RimSummaryPlotCollection* sumPlotColl = - caf::SelectionManager::instance()->selectedItemAncestorOfType(); - - if ( sumPlotColl ) - { - RimSummaryCase* firstIndividualSummaryCase = nullptr; - RimSummaryCaseCollection* firstEnsemble = nullptr; - - auto sumCaseVector = RimProject::current()->allSummaryCases(); - for ( RimSummaryCase* summaryCase : sumCaseVector ) - { - RimSummaryCaseCollection* parentEnsemble = nullptr; - summaryCase->firstAncestorOrThisOfType( parentEnsemble ); - if ( !parentEnsemble && !firstIndividualSummaryCase ) - { - firstIndividualSummaryCase = summaryCase; - break; - } - else if ( parentEnsemble && !firstEnsemble ) - { - firstEnsemble = parentEnsemble; - } - } - if ( firstIndividualSummaryCase ) - { - selectedIndividualSummaryCases->push_back( firstIndividualSummaryCase ); - } - else if ( firstEnsemble ) - { - selectedEnsembles->push_back( firstEnsemble ); - } - } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryPlot* RicNewDefaultSummaryPlotFeature::createFromSummaryCases( RimSummaryPlotCollection* plotCollection, - const std::vector& summaryCases ) +RimSummaryPlot* RicNewDefaultSummaryPlotFeature::createFromSummaryCases( const std::vector& summaryCases ) { - RimSummaryPlot* newPlot = plotCollection->createSummaryPlotWithAutoTitle(); + RimSummaryPlot* newPlot = new RimSummaryPlot(); + newPlot->enableAutoPlotTitle( true ); for ( RimSummaryCase* sumCase : summaryCases ) { @@ -118,10 +85,8 @@ RimSummaryPlot* RicNewDefaultSummaryPlotFeature::createFromSummaryCases( RimSumm newPlot->applyDefaultCurveAppearances(); newPlot->loadDataAndUpdate(); - plotCollection->updateConnectedEditors(); + RicSummaryPlotBuilder::createAndAppendSingleSummaryMultiPlot( newPlot ); - RiuPlotMainWindowTools::setExpanded( newPlot ); - RiuPlotMainWindowTools::selectAsCurrentItem( newPlot ); return newPlot; } @@ -130,6 +95,13 @@ RimSummaryPlot* RicNewDefaultSummaryPlotFeature::createFromSummaryCases( RimSumm //-------------------------------------------------------------------------------------------------- bool RicNewDefaultSummaryPlotFeature::isCommandEnabled() { + RimSummaryMultiPlot* multiPlot = + dynamic_cast( caf::SelectionManager::instance()->selectedItem() ); + if ( multiPlot ) + { + return true; + } + std::vector selectedIndividualSummaryCases; std::vector selectedEnsembles; @@ -146,6 +118,8 @@ bool RicNewDefaultSummaryPlotFeature::isCommandEnabled() if ( customObjFuncCollection || curveFilter ) return false; return !( selectedIndividualSummaryCases.empty() && selectedEnsembles.empty() ); + + return false; } //-------------------------------------------------------------------------------------------------- @@ -153,14 +127,23 @@ bool RicNewDefaultSummaryPlotFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicNewDefaultSummaryPlotFeature::onActionTriggered( bool isChecked ) { + RimSummaryMultiPlot* multiPlot = + dynamic_cast( caf::SelectionManager::instance()->selectedItem() ); + if ( multiPlot ) + { + RimSummaryPlot* plot = new RimSummaryPlot(); + plot->enableAutoPlotTitle( true ); + RicSummaryPlotBuilder::appendPlotsToSummaryMultiPlot( multiPlot, { plot } ); + return; + } + std::vector selectedIndividualSummaryCases; std::vector selectedEnsembles; extractPlotObjectsFromSelection( &selectedIndividualSummaryCases, &selectedEnsembles ); if ( !selectedIndividualSummaryCases.empty() ) { - RimSummaryPlotCollection* sumPlotColl = RimProject::current()->mainPlotCollection()->summaryPlotCollection(); - createFromSummaryCases( sumPlotColl, selectedIndividualSummaryCases ); + createFromSummaryCases( selectedIndividualSummaryCases ); } else { @@ -179,13 +162,13 @@ void RicNewDefaultSummaryPlotFeature::setupActionLook( QAction* actionToSetup ) extractPlotObjectsFromSelection( &selectedIndividualSummaryCases, &selectedEnsembles ); - if ( !selectedIndividualSummaryCases.empty() ) + if ( !selectedEnsembles.empty() ) { - actionToSetup->setText( "New Summary Plot" ); + actionToSetup->setText( "Add Ensemble Summary Plot" ); } else { - actionToSetup->setText( "New Ensemble Summary Plot" ); + actionToSetup->setText( "Add Summary Plot" ); } actionToSetup->setIcon( QIcon( ":/SummaryPlotLight16x16.png" ) ); } diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewDefaultSummaryPlotFeature.h b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewDefaultSummaryPlotFeature.h index 9c49add0a5..5dba90a717 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewDefaultSummaryPlotFeature.h +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewDefaultSummaryPlotFeature.h @@ -22,7 +22,6 @@ #include "cafCmdFeature.h" -class RimSummaryPlotCollection; class RimSummaryCase; class RimSummaryPlot; @@ -34,8 +33,7 @@ class RicNewDefaultSummaryPlotFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; public: - static RimSummaryPlot* createFromSummaryCases( RimSummaryPlotCollection* plotCollection, - const std::vector& summaryCases ); + static RimSummaryPlot* createFromSummaryCases( const std::vector& summaryCases ); protected: bool isCommandEnabled() override; diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewDerivedEnsembleFeature.h b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewDerivedEnsembleFeature.h index f4fdaefc68..b56f98c1ef 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewDerivedEnsembleFeature.h +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewDerivedEnsembleFeature.h @@ -20,10 +20,6 @@ #include "cafCmdFeature.h" -class RimSummaryPlotCollection; -class RimSummaryCase; -class RimSummaryPlot; - //================================================================================================== /// //================================================================================================== @@ -36,7 +32,6 @@ class RicNewDerivedEnsembleFeature : public caf::CmdFeature static bool showWarningDialogWithQuestion(); protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewDerivedSummaryFeature.h b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewDerivedSummaryFeature.h index bd2be3a77a..8c6269de77 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewDerivedSummaryFeature.h +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewDerivedSummaryFeature.h @@ -31,7 +31,6 @@ class RicNewDerivedSummaryFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewEnsembleCurveFilterFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewEnsembleCurveFilterFeature.cpp index c922fccd22..bef34d598c 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewEnsembleCurveFilterFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewEnsembleCurveFilterFeature.cpp @@ -70,8 +70,8 @@ void RicNewEnsembleCurveFilterFeature::onActionTriggered( bool isChecked ) std::vector addresses; auto candidateAdr = newFilter->parentCurveSet()->summaryAddress(); - auto nativeQuantityName = RimObjectiveFunctionTools::nativeQuantityName( candidateAdr.quantityName() ); - candidateAdr.setQuantityName( nativeQuantityName ); + auto nativeQuantityName = RimObjectiveFunctionTools::nativeQuantityName( candidateAdr.vectorName() ); + candidateAdr.setVectorName( nativeQuantityName ); addresses.push_back( candidateAdr ); newFilter->setSummaryAddresses( addresses ); } diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewEnsembleCurveFilterFeature.h b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewEnsembleCurveFilterFeature.h index cc63bd43a4..438d9d8858 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewEnsembleCurveFilterFeature.h +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewEnsembleCurveFilterFeature.h @@ -20,10 +20,6 @@ #include "cafCmdFeature.h" -class RimSummaryPlotCollection; -class RimSummaryCase; -class RimSummaryPlot; - //================================================================================================== /// //================================================================================================== @@ -32,7 +28,6 @@ class RicNewEnsembleCurveFilterFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewGridTimeHistoryCurveFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewGridTimeHistoryCurveFeature.cpp index db6d312261..4529a9620a 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewGridTimeHistoryCurveFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewGridTimeHistoryCurveFeature.cpp @@ -23,6 +23,7 @@ #include "RigFemResultAddress.h" +#include "PlotBuilderCommands/RicSummaryPlotBuilder.h" #include "RicNewSummaryCurveFeature.h" #include "RicSelectSummaryPlotUI.h" #include "RicWellLogTools.h" @@ -35,8 +36,9 @@ #include "RimGeoMechView.h" #include "RimGridTimeHistoryCurve.h" #include "RimProject.h" +#include "RimSummaryMultiPlot.h" +#include "RimSummaryMultiPlotCollection.h" #include "RimSummaryPlot.h" -#include "RimSummaryPlotCollection.h" #include "Riu3dSelectionManager.h" #include "RiuPlotMainWindowTools.h" @@ -86,7 +88,7 @@ RimSummaryPlot* RicNewGridTimeHistoryCurveFeature::userSelectedSummaryPlot() const QString lastUsedSummaryPlotKey( "lastUsedSummaryPlotKey" ); - RimSummaryPlotCollection* summaryPlotColl = RiaSummaryTools::summaryPlotCollection(); + RimSummaryMultiPlotCollection* summaryPlotColl = RiaSummaryTools::summaryMultiPlotCollection(); RimSummaryPlot* defaultSelectedPlot = nullptr; { @@ -97,16 +99,6 @@ RimSummaryPlot* RicNewGridTimeHistoryCurveFeature::userSelectedSummaryPlot() { defaultSelectedPlot = lastUsedPlot; } - - if ( !defaultSelectedPlot ) - { - defaultSelectedPlot = dynamic_cast( app->activePlotWindow() ); - } - - if ( !defaultSelectedPlot && !summaryPlotColl->plots().empty() ) - { - defaultSelectedPlot = summaryPlotColl->plots().front(); - } } RicSelectSummaryPlotUI featureUi; @@ -126,10 +118,9 @@ RimSummaryPlot* RicNewGridTimeHistoryCurveFeature::userSelectedSummaryPlot() RimSummaryPlot* summaryPlot = nullptr; if ( featureUi.isCreateNewPlotChecked() ) { - RimSummaryPlot* plot = summaryPlotColl->createNamedSummaryPlot( featureUi.newPlotName() ); - - summaryPlotColl->updateConnectedEditors(); - + RimSummaryPlot* plot = new RimSummaryPlot(); + plot->setUiName( featureUi.newPlotName() ); + RicSummaryPlotBuilder::createAndAppendSingleSummaryMultiPlot( plot ); plot->loadDataAndUpdate(); summaryPlot = plot; diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewGridTimeHistoryCurveFeature.h b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewGridTimeHistoryCurveFeature.h index a291fba533..86c776ec10 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewGridTimeHistoryCurveFeature.h +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewGridTimeHistoryCurveFeature.h @@ -31,7 +31,6 @@ class RicNewGridTimeHistoryCurveFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewPlotAxisPropertiesFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewPlotAxisPropertiesFeature.cpp new file mode 100644 index 0000000000..90356804fe --- /dev/null +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewPlotAxisPropertiesFeature.cpp @@ -0,0 +1,67 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicNewPlotAxisPropertiesFeature.h" + +#include "RiaPlotDefines.h" + +#include "RimPlotAxisProperties.h" +#include "RimSummaryPlot.h" + +#include "RiuPlotMainWindowTools.h" + +#include "cafSelectionManagerTools.h" + +#include + +CAF_CMD_SOURCE_INIT( RicNewPlotAxisPropertiesFeature, "RicNewPlotAxisPropertiesFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicNewPlotAxisPropertiesFeature::isCommandEnabled() +{ + auto* summaryPlot = caf::firstAncestorOfTypeFromSelectedObject(); + return ( summaryPlot != nullptr ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewPlotAxisPropertiesFeature::onActionTriggered( bool isChecked ) +{ + auto* summaryPlot = caf::firstAncestorOfTypeFromSelectedObject(); + if ( !summaryPlot ) return; + + RimPlotAxisProperties* newPlotAxisProperties = + summaryPlot->addNewAxisProperties( RiaDefines::PlotAxis::PLOT_AXIS_LEFT, "New Axis" ); + summaryPlot->plotWidget()->ensureAxisIsCreated( newPlotAxisProperties->plotAxisType() ); + newPlotAxisProperties->setNameForUnusedAxis(); + + summaryPlot->updateConnectedEditors(); + RiuPlotMainWindowTools::selectAsCurrentItem( newPlotAxisProperties ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewPlotAxisPropertiesFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setText( "New Plot Axis" ); + actionToSetup->setIcon( QIcon( ":/LeftAxis16x16.png" ) ); +} diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewPlotAxisPropertiesFeature.h b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewPlotAxisPropertiesFeature.h new file mode 100644 index 0000000000..96044452ff --- /dev/null +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewPlotAxisPropertiesFeature.h @@ -0,0 +1,35 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +//================================================================================================== +/// +//================================================================================================== +class RicNewPlotAxisPropertiesFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + // Overrides + bool isCommandEnabled() override; + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; +}; diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotCurveFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotCurveFeature.cpp index b4c7f2f0a3..995fd126c7 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotCurveFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotCurveFeature.cpp @@ -28,7 +28,6 @@ #include "RimSummaryCrossPlot.h" #include "RimSummaryCrossPlotCollection.h" #include "RimSummaryCurve.h" -#include "RimSummaryPlotCollection.h" #include "RiuPlotMainWindow.h" @@ -78,7 +77,7 @@ void RicNewSummaryCrossPlotCurveFeature::onActionTriggered( bool isChecked ) RiaGuiApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem( newCurve ); RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow(); - mainPlotWindow->updateSummaryPlotToolBar(); + mainPlotWindow->updateMultiPlotToolBar(); } } diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotFeature.cpp index 7c41764cca..213fc8e49c 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotFeature.cpp @@ -29,7 +29,6 @@ #include "RimSummaryCase.h" #include "RimSummaryCaseCollection.h" #include "RimSummaryCrossPlotCollection.h" -#include "RimSummaryCurveFilter.h" #include "RimSummaryPlot.h" #include "RiuPlotMainWindowTools.h" diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotFeature.h b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotFeature.h index 9a6c79d100..e8b71e86eb 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotFeature.h +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotFeature.h @@ -32,7 +32,6 @@ class RicNewSummaryCrossPlotFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; private: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryCurveFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryCurveFeature.cpp index d77449b522..73a27ea346 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryCurveFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryCurveFeature.cpp @@ -29,8 +29,8 @@ #include "RimProject.h" #include "RimSummaryCaseMainCollection.h" #include "RimSummaryCurve.h" +#include "RimSummaryCurveCollection.h" #include "RimSummaryPlot.h" -#include "RimSummaryPlotCollection.h" #include "RiuPlotMainWindow.h" @@ -102,12 +102,12 @@ void RicNewSummaryCurveFeature::onActionTriggered( bool isChecked ) newCurve->setSummaryCaseY( defaultCase ); plot->loadDataAndUpdate(); - plot->updateConnectedEditors(); + plot->summaryCurveCollection()->updateAllRequiredEditors(); app->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem( newCurve ); RiuPlotMainWindow* mainPlotWindow = app->mainPlotWindow(); - mainPlotWindow->updateSummaryPlotToolBar(); + mainPlotWindow->updateMultiPlotToolBar(); } } diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryCurveFeature.h b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryCurveFeature.h index 8c64baf19b..12c401b901 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryCurveFeature.h +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryCurveFeature.h @@ -23,9 +23,6 @@ #include class RimSummaryPlot; -class RimSummaryCase; -class RimSummaryCurve; -class RimSummaryPlotCollection; //================================================================================================== /// @@ -36,7 +33,6 @@ class RicNewSummaryCurveFeature : public caf::CmdFeature public: protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp index bd3053fdf5..785ee478fb 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp @@ -21,8 +21,9 @@ #include "RiaColorTables.h" #include "RiaGuiApplication.h" #include "RiaPreferencesSummary.h" - #include "RiaSummaryTools.h" +#include "RiaTextStringTools.h" + #include "RimEnsembleCurveFilter.h" #include "RimEnsembleCurveFilterCollection.h" #include "RimEnsembleCurveSet.h" @@ -33,11 +34,14 @@ #include "RimProject.h" #include "RimSummaryCaseMainCollection.h" #include "RimSummaryCurve.h" +#include "RimSummaryCurveAppearanceCalculator.h" +#include "RimSummaryMultiPlot.h" +#include "RimSummaryMultiPlotCollection.h" #include "RimSummaryPlot.h" -#include "RimSummaryPlotCollection.h" #include "RiuPlotMainWindow.h" +#include "PlotBuilderCommands/RicSummaryPlotBuilder.h" #include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h" #include "cafSelectionManager.h" @@ -62,7 +66,7 @@ std::vector RiaPreferencesSummary* prefs = RiaPreferencesSummary::current(); QString curvesTextFilter = prefs->defaultSummaryCurvesTextFilter(); - QStringList curveFilters = curvesTextFilter.split( ";", QString::SkipEmptyParts ); + QStringList curveFilters = RiaTextStringTools::splitSkipEmptyParts( curvesTextFilter, ";" ); std::set addrs = ensemble->ensembleSummaryAddresses(); @@ -77,7 +81,10 @@ std::vector // Use same counting as RicNewSummaryCurveFeature::onActionTriggered auto colorIndex = plot->singleColorCurveCount(); - curveSet->setColor( RiaColorTables::summaryCurveDefaultPaletteColors().cycledColor3f( colorIndex ) ); + + curveSet->setColor( + RimSummaryCurveAppearanceCalculator::computeTintedCurveColorForAddress( addr, + static_cast( colorIndex ) ) ); curveSet->legendConfig()->setColorLegend( RimRegularLegendConfig::mapToColorLegend( RimEnsembleCurveSetColorManager::cycledEnsembleColorRange( static_cast( colorIndex ) ) ) ); @@ -108,8 +115,9 @@ RimSummaryPlot* if ( prefs->defaultSummaryCurvesTextFilter().isEmpty() ) return nullptr; - RimSummaryPlotCollection* summaryPlotCollection = proj->mainPlotCollection->summaryPlotCollection(); - RimSummaryPlot* plot = summaryPlotCollection->createSummaryPlotWithAutoTitle(); + RimSummaryPlot* plot = new RimSummaryPlot(); + plot->enableAutoPlotTitle( true ); + RimSummaryMultiPlot* multiPlot = RicSummaryPlotBuilder::createAndAppendSingleSummaryMultiPlot( plot ); RimEnsembleCurveSet* firstCurveSetCreated = nullptr; for ( RimSummaryCaseCollection* ensemble : ensembles ) @@ -120,13 +128,13 @@ RimSummaryPlot* } plot->loadDataAndUpdate(); - summaryPlotCollection->updateConnectedEditors(); + multiPlot->updateConnectedEditors(); RiuPlotMainWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow(); if ( mainPlotWindow ) { mainPlotWindow->selectAsCurrentItem( firstCurveSetCreated ); - mainPlotWindow->updateSummaryPlotToolBar(); + mainPlotWindow->updateMultiPlotToolBar(); } return plot; } @@ -172,14 +180,14 @@ void RicNewSummaryEnsembleCurveSetFeature::onActionTriggered( bool isChecked ) if ( !curveSets.empty() ) firstCurveSet = curveSets.front(); } plot->loadDataAndUpdate(); - plot->updateConnectedEditors(); + plot->ensembleCurveSetCollection()->updateAllRequiredEditors(); RiaGuiApplication* app = RiaGuiApplication::instance(); RiuPlotMainWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow(); if ( mainPlotWindow && firstCurveSet ) { mainPlotWindow->selectAsCurrentItem( firstCurveSet ); - mainPlotWindow->updateSummaryPlotToolBar(); + mainPlotWindow->updateMultiPlotToolBar(); } } } diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.h b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.h index f9166a06b4..8612987488 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.h +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.h @@ -35,16 +35,13 @@ class RicNewSummaryEnsembleCurveSetFeature : public caf::CmdFeature public: static RimSummaryPlot* createPlotForCurveSetsAndUpdate( std::vector ensembles ); + static std::vector addDefaultCurveSets( RimSummaryPlot* plot, RimSummaryCaseCollection* ensemble ); protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; -private: - static std::vector addDefaultCurveSets( RimSummaryPlot* plot, RimSummaryCaseCollection* ensemble ); - private: RimSummaryPlot* selectedSummaryPlot() const; }; diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryPlotFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicOpenSummaryPlotEditorFeature.cpp similarity index 83% rename from ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryPlotFeature.cpp rename to ApplicationLibCode/Commands/SummaryPlotCommands/RicOpenSummaryPlotEditorFeature.cpp index 75bbcc129d..a1c90e6c01 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryPlotFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicOpenSummaryPlotEditorFeature.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2016- Statoil ASA +// Copyright (C) 2022 Equinor ASA // // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RicNewSummaryPlotFeature.h" +#include "RicOpenSummaryPlotEditorFeature.h" #include "RiaSummaryTools.h" @@ -34,9 +34,7 @@ #include "RimSummaryCase.h" #include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" -#include "RimSummaryCurveFilter.h" #include "RimSummaryPlot.h" -#include "RimSummaryPlotCollection.h" #include "RiuPlotMainWindow.h" @@ -45,20 +43,20 @@ #include -CAF_CMD_SOURCE_INIT( RicNewSummaryPlotFeature, "RicNewSummaryPlotFeature" ); +CAF_CMD_SOURCE_INIT( RicOpenSummaryPlotEditorFeature, "RicOpenSummaryPlotEditorFeature" ); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RicNewSummaryPlotFeature::isCommandEnabled() +bool RicOpenSummaryPlotEditorFeature::isCommandEnabled() { - RimSummaryPlotCollection* sumPlotColl = nullptr; + RimSummaryMultiPlot* multiPlot = nullptr; RimCustomObjectiveFunctionCollection* customObjFuncCollection = nullptr; caf::PdmObject* selObj = dynamic_cast( caf::SelectionManager::instance()->selectedItem() ); if ( selObj ) { - sumPlotColl = RiaSummaryTools::parentSummaryPlotCollection( selObj ); + multiPlot = RiaSummaryTools::parentSummaryMultiPlot( selObj ); selObj->firstAncestorOrThisOfType( customObjFuncCollection ); } @@ -67,22 +65,15 @@ bool RicNewSummaryPlotFeature::isCommandEnabled() auto legendConfig = dynamic_cast( selObj ); if ( ensembleFilter || ensembleFilterColl || legendConfig || customObjFuncCollection ) return false; - if ( sumPlotColl ) return true; + if ( multiPlot ) return true; - // Multiple case selections - std::vector selectedItems = caf::selectedObjectsByTypeStrict(); - - for ( auto item : selectedItems ) - { - if ( !dynamic_cast( item ) && !dynamic_cast( item ) ) return false; - } return true; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicNewSummaryPlotFeature::onActionTriggered( bool isChecked ) +void RicOpenSummaryPlotEditorFeature::onActionTriggered( bool isChecked ) { RimProject* project = RimProject::current(); CVF_ASSERT( project ); @@ -124,7 +115,7 @@ void RicNewSummaryPlotFeature::onActionTriggered( bool isChecked ) } } - auto dialog = RicEditSummaryPlotFeature::curveCreatorDialog(); + auto dialog = RicEditSummaryPlotFeature::curveCreatorDialog( true ); if ( !dialog->isVisible() ) { @@ -141,7 +132,7 @@ void RicNewSummaryPlotFeature::onActionTriggered( bool isChecked ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicNewSummaryPlotFeature::setupActionLook( QAction* actionToSetup ) +void RicOpenSummaryPlotEditorFeature::setupActionLook( QAction* actionToSetup ) { actionToSetup->setText( "Open Summary Plot Editor" ); actionToSetup->setIcon( QIcon( ":/SummaryPlotLight16x16.png" ) ); diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryPlotFeature.h b/ApplicationLibCode/Commands/SummaryPlotCommands/RicOpenSummaryPlotEditorFeature.h similarity index 94% rename from ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryPlotFeature.h rename to ApplicationLibCode/Commands/SummaryPlotCommands/RicOpenSummaryPlotEditorFeature.h index fbffd769fe..c36c873c34 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryPlotFeature.h +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicOpenSummaryPlotEditorFeature.h @@ -25,12 +25,11 @@ //================================================================================================== /// //================================================================================================== -class RicNewSummaryPlotFeature : public caf::CmdFeature +class RicOpenSummaryPlotEditorFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteAsciiDataCurveFeature.h b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteAsciiDataCurveFeature.h index fb2a683b48..11b6575d10 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteAsciiDataCurveFeature.h +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteAsciiDataCurveFeature.h @@ -33,7 +33,6 @@ class RicPasteAsciiDataCurveFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeature.cpp index 8c27580406..c3e547a329 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeature.cpp @@ -19,15 +19,15 @@ #include "RicPasteAsciiDataToSummaryPlotFeature.h" #include "OperationsUsingObjReferences/RicPasteFeatureImpl.h" -#include "RicNewSummaryPlotFeature.h" +#include "PlotBuilderCommands/RicSummaryPlotBuilder.h" #include "RicPasteAsciiDataToSummaryPlotFeatureUi.h" #include "RiaLogging.h" #include "RimAsciiDataCurve.h" #include "RimSummaryCurveAppearanceCalculator.h" +#include "RimSummaryMultiPlot.h" #include "RimSummaryPlot.h" -#include "RimSummaryPlotCollection.h" #include "cafPdmDefaultObjectFactory.h" #include "cafPdmDocument.h" @@ -56,9 +56,9 @@ bool RicPasteAsciiDataToSummaryPlotFeature::isCommandEnabled() if ( !destinationObject ) return false; - RimSummaryPlotCollection* summaryPlotCollection = nullptr; - destinationObject->firstAncestorOrThisOfType( summaryPlotCollection ); - if ( !summaryPlotCollection ) + RimSummaryMultiPlot* multiPlot = nullptr; + destinationObject->firstAncestorOrThisOfType( multiPlot ); + if ( !multiPlot ) { return false; } @@ -80,7 +80,7 @@ void RicPasteAsciiDataToSummaryPlotFeature::onActionTriggered( bool isChecked ) RicPasteAsciiDataToSummaryPlotFeatureUi pasteOptions; caf::PdmSettings::readFieldsFromApplicationStore( &pasteOptions, pasteOptions.contextString() ); - if ( !summaryPlot ) pasteOptions.createNewPlot(); + if ( !summaryPlot ) pasteOptions.setCreateNewPlot(); pasteOptions.setUiModePasteText( text ); caf::PdmUiPropertyViewDialog propertyDialog( nullptr, &pasteOptions, "Set Paste Options", "" ); @@ -92,14 +92,10 @@ void RicPasteAsciiDataToSummaryPlotFeature::onActionTriggered( bool isChecked ) { if ( !summaryPlot ) { - RimSummaryPlotCollection* summaryPlotCollection = nullptr; - destinationObject->firstAncestorOrThisOfType( summaryPlotCollection ); - if ( !summaryPlotCollection ) - { - return; - } - summaryPlot = createSummaryPlotAndAddToPlotCollection( summaryPlotCollection ); - summaryPlotCollection->updateConnectedEditors(); + summaryPlot = new RimSummaryPlot(); + summaryPlot->enableAutoPlotTitle( true ); + + RicSummaryPlotBuilder::createAndAppendSingleSummaryMultiPlot( summaryPlot ); } caf::PdmSettings::writeFieldsToApplicationStore( &pasteOptions, pasteOptions.contextString() ); @@ -250,14 +246,3 @@ RicPasteAsciiDataToSummaryPlotFeature::CurveType } return CURVE_UNKNOWN; } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimSummaryPlot* - RicPasteAsciiDataToSummaryPlotFeature::createSummaryPlotAndAddToPlotCollection( RimSummaryPlotCollection* plotCollection ) -{ - QString name = QString( "Summary Plot %1" ).arg( plotCollection->plots().size() + 1 ); - - return plotCollection->createNamedSummaryPlot( name ); -} diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeature.h b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeature.h index 52403c3bc8..afe2c11589 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeature.h +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeature.h @@ -26,7 +26,6 @@ class RimSummaryCurve; class RimAsciiDataCurve; class RicPasteAsciiDataToSummaryPlotFeatureUi; -class RimSummaryPlotCollection; class RimSummaryPlot; //================================================================================================== @@ -46,7 +45,6 @@ class RicPasteAsciiDataToSummaryPlotFeature : public caf::CmdFeature }; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; @@ -59,6 +57,4 @@ class RicPasteAsciiDataToSummaryPlotFeature : public caf::CmdFeature const RicPasteAsciiDataToSummaryPlotFeatureUi& settings ); static CurveType guessCurveType( const QString& curveName ); - - static RimSummaryPlot* createSummaryPlotAndAddToPlotCollection( RimSummaryPlotCollection* plotCollection ); }; diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeatureUi.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeatureUi.cpp index 84fd423d14..885433a0c3 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeatureUi.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeatureUi.cpp @@ -18,6 +18,7 @@ #include "RicPasteAsciiDataToSummaryPlotFeatureUi.h" +#include "RiaTextStringTools.h" #include "RifCsvUserDataParser.h" #include "cafPdmUiItem.h" @@ -174,16 +175,16 @@ RicPasteAsciiDataToSummaryPlotFeatureUi::DecimalSeparator mapDecimalSeparator( c RicPasteAsciiDataToSummaryPlotFeatureUi::RicPasteAsciiDataToSummaryPlotFeatureUi() : m_createNewPlot( false ) { - CAF_PDM_InitObject( "RicPasteAsciiDataToSummaryPlotFeatureUi", "", "", "" ); + CAF_PDM_InitObject( "RicPasteAsciiDataToSummaryPlotFeatureUi" ); - CAF_PDM_InitField( &m_plotTitle, "PlotTitle", QString(), "Plot Title", "", "", "" ); - CAF_PDM_InitField( &m_curvePrefix, "CurvePrefix", QString(), "Curve Prefix", "", "", "" ); + CAF_PDM_InitField( &m_plotTitle, "PlotTitle", QString(), "Plot Title" ); + CAF_PDM_InitField( &m_curvePrefix, "CurvePrefix", QString(), "Curve Prefix" ); - CAF_PDM_InitFieldNoDefault( &m_decimalSeparator, "DecimalSeparator", "Decimal Separator", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_decimalSeparator, "DecimalSeparator", "Decimal Separator" ); - CAF_PDM_InitFieldNoDefault( &m_dateFormat, "DateFormat", "Date Format", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_timeFormat, "TimeFormat", "Time Format", "", "", "" ); - CAF_PDM_InitField( &m_useCustomDateFormat, "UseCustomDateFormat", false, "Use Custom Date Time Format", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_dateFormat, "DateFormat", "Date Format" ); + CAF_PDM_InitFieldNoDefault( &m_timeFormat, "TimeFormat", "Time Format" ); + CAF_PDM_InitField( &m_useCustomDateFormat, "UseCustomDateFormat", false, "Use Custom Date Time Format" ); CAF_PDM_InitField( &m_customDateTimeFormat, "CustomDateTimeFormat", QString(), @@ -196,24 +197,18 @@ RicPasteAsciiDataToSummaryPlotFeatureUi::RicPasteAsciiDataToSummaryPlotFeatureUi "LineStyle", caf::AppEnum( RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_NONE ), - "Line Style", - "", - "", - "" ); + "Line Style" ); CAF_PDM_InitField( &m_curveSymbol, "Symbol", - caf::AppEnum( RiuQwtSymbol::SYMBOL_ELLIPSE ), - "Symbol", - "", - "", - "" ); - CAF_PDM_InitField( &m_curveSymbolSkipDistance, "SymbolSkipDinstance", 0.0f, "Symbol Skip Distance", "", "", "" ); + caf::AppEnum( RiuQwtSymbol::SYMBOL_ELLIPSE ), + "Symbol" ); + CAF_PDM_InitField( &m_curveSymbolSkipDistance, "SymbolSkipDinstance", 0.0f, "Symbol Skip Distance" ); - CAF_PDM_InitFieldNoDefault( &m_cellSeparator, "CellSeparator", "Cell Separator", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_cellSeparator, "CellSeparator", "Cell Separator" ); - CAF_PDM_InitFieldNoDefault( &m_timeSeriesColumnName, "TimeColumnName", "Selected Time Column", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_timeSeriesColumnName, "TimeColumnName", "Selected Time Column" ); - CAF_PDM_InitFieldNoDefault( &m_previewText, "PreviewText", "Preview Text", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_previewText, "PreviewText", "Preview Text" ); m_previewText.uiCapability()->setUiEditorTypeName( caf::PdmUiTextEditor::uiEditorTypeName() ); m_previewText.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); m_previewText.uiCapability()->setUiReadOnly( true ); @@ -321,7 +316,7 @@ const AsciiDataParseOptions RicPasteAsciiDataToSummaryPlotFeatureUi::parseOption //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicPasteAsciiDataToSummaryPlotFeatureUi::createNewPlot() +void RicPasteAsciiDataToSummaryPlotFeatureUi::setCreateNewPlot() { m_createNewPlot = true; } @@ -335,7 +330,7 @@ RicPasteAsciiDataToSummaryPlotFeatureUi::DateFormat std::vector values; { - QStringList split = dateString.split( ".", QString::SkipEmptyParts ); + QStringList split = RiaTextStringTools::splitSkipEmptyParts( dateString, "." ); if ( split.size() == 3 ) { values.push_back( split.at( 0 ).toInt() ); @@ -348,7 +343,7 @@ RicPasteAsciiDataToSummaryPlotFeatureUi::DateFormat } { - QStringList split = dateString.split( "-", QString::SkipEmptyParts ); + QStringList split = RiaTextStringTools::splitSkipEmptyParts( dateString, "-" ); if ( split.size() == 3 ) { values.push_back( split.at( 0 ).toInt() ); @@ -361,7 +356,7 @@ RicPasteAsciiDataToSummaryPlotFeatureUi::DateFormat } { - QStringList split = dateString.split( "/", QString::SkipEmptyParts ); + QStringList split = RiaTextStringTools::splitSkipEmptyParts( dateString, "/" ); if ( split.size() == 3 ) { values.push_back( split.at( 0 ).toInt() ); @@ -457,8 +452,7 @@ void RicPasteAsciiDataToSummaryPlotFeatureUi::defineUiOrdering( QString uiConfig /// //-------------------------------------------------------------------------------------------------- QList - RicPasteAsciiDataToSummaryPlotFeatureUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) + RicPasteAsciiDataToSummaryPlotFeatureUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { CVF_ASSERT( m_uiMode != UI_MODE_NONE ); @@ -563,4 +557,4 @@ void RicPasteAsciiDataToSummaryPlotFeatureUi::updatePreviewTextAndDateFormat() QString RicPasteAsciiDataToSummaryPlotFeatureUi::contextString() const { return QString( "AsciiDataToSummarySettings" ); -} \ No newline at end of file +} diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeatureUi.h b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeatureUi.h index 83f1e851c1..a3fb14df93 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeatureUi.h +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeatureUi.h @@ -60,7 +60,7 @@ class AsciiDataParseOptions bool assumeNumericDataColumns; RiuQwtPlotCurveDefines::LineStyleEnum curveLineStyle; - RiuQwtSymbol::PointSymbolEnum curveSymbol; + RiuPlotCurveSymbol::PointSymbolEnum curveSymbol; float curveSymbolSkipDistance; }; @@ -129,7 +129,7 @@ class RicPasteAsciiDataToSummaryPlotFeatureUi : public caf::PdmObject UiMode uiModeImport() const; const AsciiDataParseOptions parseOptions() const; - void createNewPlot(); + void setCreateNewPlot(); QString contextString() const; @@ -137,8 +137,7 @@ class RicPasteAsciiDataToSummaryPlotFeatureUi : public caf::PdmObject protected: void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; @@ -162,7 +161,7 @@ class RicPasteAsciiDataToSummaryPlotFeatureUi : public caf::PdmObject caf::PdmField m_timeSeriesColumnName; caf::PdmField> m_curveLineStyle; - caf::PdmField> m_curveSymbol; + caf::PdmField> m_curveSymbol; caf::PdmField m_curveSymbolSkipDistance; bool m_createNewPlot; diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotCurveFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotCurveFeature.cpp index 9487ee44df..93bf7ebb2d 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotCurveFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotCurveFeature.cpp @@ -24,7 +24,6 @@ #include "RimSummaryCrossPlot.h" #include "RimSummaryCurve.h" -#include "RimSummaryCurveFilter.h" #include "cafPdmDefaultObjectFactory.h" #include "cafPdmDocument.h" diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotCurveFeature.h b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotCurveFeature.h index 185aa58c24..0c11bbb65a 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotCurveFeature.h +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotCurveFeature.h @@ -36,7 +36,6 @@ class RicPasteSummaryCrossPlotCurveFeature : public RicPasteSummaryCurveFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; // virtual void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotFeature.h b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotFeature.h index 1f90cb0fd0..6022c6a3c8 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotFeature.h +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotFeature.h @@ -36,7 +36,6 @@ class RicPasteSummaryCrossPlotFeature : public caf::CmdFeature static void copyPlotAndAddToCollection( RimSummaryCrossPlot* sourcePlot ); protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryCurveFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryCurveFeature.cpp index 16c3069f95..ec9177fa2c 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryCurveFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryCurveFeature.cpp @@ -24,7 +24,8 @@ #include "RimSummaryCrossPlot.h" #include "RimSummaryCurve.h" -#include "RimSummaryCurveFilter.h" +#include "RimSummaryCurveCollection.h" +#include "RimSummaryMultiPlot.h" #include "RimSummaryPlot.h" #include "cafPdmDefaultObjectFactory.h" @@ -63,7 +64,18 @@ RimSummaryCurve* RicPasteSummaryCurveFeature::copyCurveAndAddToPlot( RimSummaryC newCurve->loadDataAndUpdate( true ); newCurve->updateConnectedEditors(); - summaryPlot->updateConnectedEditors(); + RimSummaryMultiPlot* summaryMultiPlot = nullptr; + summaryPlot->firstAncestorOrThisOfType( summaryMultiPlot ); + if ( summaryMultiPlot ) + { + summaryMultiPlot->updatePlotWindowTitle(); + } + else + { + summaryPlot->updatePlotTitle(); + } + + summaryPlot->updateAllRequiredEditors(); return newCurve; } diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryCurveFeature.h b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryCurveFeature.h index da39b3121c..07da1abe2c 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryCurveFeature.h +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryCurveFeature.h @@ -37,7 +37,6 @@ class RicPasteSummaryCurveFeature : public caf::CmdFeature static RimSummaryCurve* copyCurveAndAddToPlot( RimSummaryCurve* sourceCurve ); protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryMultiPlotFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryMultiPlotFeature.cpp new file mode 100644 index 0000000000..0a899a86c5 --- /dev/null +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryMultiPlotFeature.cpp @@ -0,0 +1,82 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicPasteSummaryMultiPlotFeature.h" + +#include "OperationsUsingObjReferences/RicPasteFeatureImpl.h" +#include "PlotBuilderCommands/RicSummaryPlotBuilder.h" + +#include "RiaSummaryTools.h" +#include "RimSummaryMultiPlot.h" +#include "RimSummaryMultiPlotCollection.h" + +#include "cafPdmDefaultObjectFactory.h" +#include "cafPdmObjectGroup.h" +#include "cafSelectionManagerTools.h" + +#include "cvfAssert.h" + +#include + +CAF_CMD_SOURCE_INIT( RicPasteSummaryMultiPlotFeature, "RicPasteSummaryMultiPlotFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicPasteSummaryMultiPlotFeature::isCommandEnabled() +{ + auto multiPlots = caf::selectedObjectsByTypeStrict(); + return !multiPlots.empty(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicPasteSummaryMultiPlotFeature::onActionTriggered( bool isChecked ) +{ + auto sourceObjects = RicPasteSummaryMultiPlotFeature::summaryMultiPlots(); + + for ( const auto& sourceObject : sourceObjects ) + { + RiaSummaryTools::summaryMultiPlotCollection()->duplicatePlot( sourceObject ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicPasteSummaryMultiPlotFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setText( "Paste Summary Plot" ); + + RicPasteFeatureImpl::setIconAndShortcuts( actionToSetup ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector> RicPasteSummaryMultiPlotFeature::summaryMultiPlots() +{ + caf::PdmObjectGroup objectGroup; + RicPasteFeatureImpl::findObjectsFromClipboardRefs( &objectGroup ); + + std::vector> typedObjects; + objectGroup.objectsByType( &typedObjects ); + + return typedObjects; +} diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryMultiPlotFeature.h b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryMultiPlotFeature.h new file mode 100644 index 0000000000..092d8046c1 --- /dev/null +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryMultiPlotFeature.h @@ -0,0 +1,42 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" +#include "cafPdmPointer.h" + +#include + +class RimSummaryMultiPlot; + +//================================================================================================== +/// +//================================================================================================== +class RicPasteSummaryMultiPlotFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + bool isCommandEnabled() override; + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; + +private: + static std::vector> summaryMultiPlots(); +}; diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryPlotFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryPlotFeature.cpp index fac6d8be81..42d044e090 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryPlotFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryPlotFeature.cpp @@ -19,9 +19,12 @@ #include "RicPasteSummaryPlotFeature.h" #include "OperationsUsingObjReferences/RicPasteFeatureImpl.h" +#include "PlotBuilderCommands/RicSummaryPlotBuilder.h" +#include "RimMultiPlot.h" #include "RimSummaryPlot.h" -#include "RimSummaryPlotCollection.h" + +#include "RiuPlotMainWindowTools.h" #include "cafPdmDefaultObjectFactory.h" #include "cafPdmDocument.h" @@ -39,26 +42,18 @@ CAF_CMD_SOURCE_INIT( RicPasteSummaryPlotFeature, "RicPasteSummaryPlotFeature" ); //-------------------------------------------------------------------------------------------------- void RicPasteSummaryPlotFeature::copyPlotAndAddToCollection( RimSummaryPlot* sourcePlot ) { - RimSummaryPlotCollection* plotColl = caf::firstAncestorOfTypeFromSelectedObject(); - - if ( plotColl ) + auto multiPlot = caf::firstAncestorOfTypeFromSelectedObject(); + if ( multiPlot ) { - RimSummaryPlot* newSummaryPlot = dynamic_cast( - sourcePlot->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); - CVF_ASSERT( newSummaryPlot ); - - plotColl->addPlot( newSummaryPlot ); + auto plots = RicSummaryPlotBuilder::duplicatePlots( { sourcePlot } ); + RicSummaryPlotBuilder::appendPlotsToMultiPlot( multiPlot, plots ); - // Resolve references after object has been inserted into the data model - newSummaryPlot->resolveReferencesRecursively(); - newSummaryPlot->initAfterReadRecursively(); + multiPlot->loadDataAndUpdate(); - QString nameOfCopy = QString( "Copy of " ) + newSummaryPlot->description(); - newSummaryPlot->setDescription( nameOfCopy ); + // No main window has focus after paste operation, set focus to main plot window + RiuPlotMainWindowTools::showPlotMainWindow(); - plotColl->updateConnectedEditors(); - - newSummaryPlot->loadDataAndUpdate(); + return; } } @@ -72,12 +67,8 @@ bool RicPasteSummaryPlotFeature::isCommandEnabled() if ( !destinationObject ) return false; - RimSummaryPlotCollection* plotColl = nullptr; - destinationObject->firstAncestorOrThisOfType( plotColl ); - if ( !plotColl ) - { - return false; - } + auto multiPlot = caf::firstAncestorOfTypeFromSelectedObject(); + if ( !multiPlot ) return false; return RicPasteSummaryPlotFeature::summaryPlots().size() > 0; } diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryPlotFeature.h b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryPlotFeature.h index a4a4e81c2c..940f97131e 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryPlotFeature.h +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteSummaryPlotFeature.h @@ -36,7 +36,6 @@ class RicPasteSummaryPlotFeature : public caf::CmdFeature static void copyPlotAndAddToCollection( RimSummaryPlot* sourcePlot ); protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteTimeHistoryCurveFeature.h b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteTimeHistoryCurveFeature.h index c0cb6c74ec..29e4a9428f 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteTimeHistoryCurveFeature.h +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicPasteTimeHistoryCurveFeature.h @@ -33,7 +33,6 @@ class RicPasteTimeHistoryCurveFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSelectSummaryPlotUI.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSelectSummaryPlotUI.cpp index 5bfa492adf..fc4d75445f 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSelectSummaryPlotUI.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSelectSummaryPlotUI.cpp @@ -24,8 +24,8 @@ #include "RimEclipseView.h" #include "RimMainPlotCollection.h" #include "RimProject.h" +#include "RimSummaryMultiPlotCollection.h" #include "RimSummaryPlot.h" -#include "RimSummaryPlotCollection.h" CAF_PDM_SOURCE_INIT( RicSelectSummaryPlotUI, "RicSelectSummaryPlotUI" ); @@ -34,11 +34,11 @@ CAF_PDM_SOURCE_INIT( RicSelectSummaryPlotUI, "RicSelectSummaryPlotUI" ); //-------------------------------------------------------------------------------------------------- RicSelectSummaryPlotUI::RicSelectSummaryPlotUI() { - CAF_PDM_InitObject( "RicSelectSummaryPlotUI", "", "", "" ); + CAF_PDM_InitObject( "RicSelectSummaryPlotUI" ); - CAF_PDM_InitFieldNoDefault( &m_selectedSummaryPlot, "SelectedSummaryPlot", "Select Plot", "", "", "" ); - CAF_PDM_InitField( &m_createNewPlot, "CreateNewPlot", false, "Create New Plot", "", "", "" ); - CAF_PDM_InitField( &m_newSummaryPlotName, "NewViewName", QString( "Cell Results" ), "New Plot Name", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_selectedSummaryPlot, "SelectedSummaryPlot", "Select Plot" ); + CAF_PDM_InitField( &m_createNewPlot, "CreateNewPlot", false, "Create New Plot" ); + CAF_PDM_InitField( &m_newSummaryPlotName, "NewViewName", QString( "Cell Results" ), "New Plot Name" ); } //-------------------------------------------------------------------------------------------------- @@ -84,14 +84,13 @@ QString RicSelectSummaryPlotUI::newPlotName() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList - RicSelectSummaryPlotUI::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) +QList RicSelectSummaryPlotUI::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; if ( fieldNeedingOptions == &m_selectedSummaryPlot ) { - RimSummaryPlotCollection* summaryPlotColl = RiaSummaryTools::summaryPlotCollection(); + RimSummaryMultiPlotCollection* summaryPlotColl = RiaSummaryTools::summaryMultiPlotCollection(); summaryPlotColl->summaryPlotItemInfos( &options ); } @@ -104,7 +103,7 @@ QList //-------------------------------------------------------------------------------------------------- void RicSelectSummaryPlotUI::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { - if ( RiaSummaryTools::summaryPlotCollection()->plots().empty() ) + if ( RiaSummaryTools::summaryMultiPlotCollection()->multiPlots().empty() ) { m_createNewPlot = true; } diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSelectSummaryPlotUI.h b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSelectSummaryPlotUI.h index 1c42739f45..305e4daed1 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSelectSummaryPlotUI.h +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSelectSummaryPlotUI.h @@ -23,7 +23,6 @@ #include "cafPdmPtrField.h" class RimSummaryPlot; -class RimSummaryPlotCollection; //================================================================================================== /// @@ -42,8 +41,7 @@ class RicSelectSummaryPlotUI : public caf::PdmObject bool isCreateNewPlotChecked() const; QString newPlotName() const; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; protected: void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicShowSummaryCurveCalculatorFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicShowSummaryCurveCalculatorFeature.cpp index 8441df7ca2..375c222b73 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicShowSummaryCurveCalculatorFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicShowSummaryCurveCalculatorFeature.cpp @@ -34,13 +34,13 @@ CAF_CMD_SOURCE_INIT( RicShowSummaryCurveCalculatorFeature, "RicShowSummaryCurveC //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RicSummaryCurveCalculatorDialog* RicShowSummaryCurveCalculatorFeature::curveCalculatorDialog() +RicSummaryCurveCalculatorDialog* RicShowSummaryCurveCalculatorFeature::curveCalculatorDialog( bool createIfNotPresent ) { RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow(); if ( mainPlotWindow ) { - return mainPlotWindow->summaryCurveCalculatorDialog(); + return mainPlotWindow->summaryCurveCalculatorDialog( createIfNotPresent ); } return nullptr; @@ -51,9 +51,8 @@ RicSummaryCurveCalculatorDialog* RicShowSummaryCurveCalculatorFeature::curveCalc //-------------------------------------------------------------------------------------------------- void RicShowSummaryCurveCalculatorFeature::hideCurveCalculatorDialog() { - auto dialog = RicShowSummaryCurveCalculatorFeature::curveCalculatorDialog(); - - dialog->hide(); + auto dialog = RicShowSummaryCurveCalculatorFeature::curveCalculatorDialog( false ); + if ( dialog ) dialog->hide(); } //-------------------------------------------------------------------------------------------------- @@ -61,12 +60,7 @@ void RicShowSummaryCurveCalculatorFeature::hideCurveCalculatorDialog() //-------------------------------------------------------------------------------------------------- bool RicShowSummaryCurveCalculatorFeature::isCommandEnabled() { - RimProject* proj = RimProject::current(); - if ( !proj ) return false; - - const auto& allSumCases = proj->allSummaryCases(); - - return !allSumCases.empty(); + return true; } //-------------------------------------------------------------------------------------------------- @@ -74,11 +68,11 @@ bool RicShowSummaryCurveCalculatorFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicShowSummaryCurveCalculatorFeature::onActionTriggered( bool isChecked ) { - RicSummaryCurveCalculatorDialog* dialog = RicShowSummaryCurveCalculatorFeature::curveCalculatorDialog(); + RicSummaryCurveCalculatorDialog* dialog = RicShowSummaryCurveCalculatorFeature::curveCalculatorDialog( true ); RimProject* proj = RimProject::current(); RimSummaryCalculationCollection* calcColl = proj->calculationCollection(); - if ( calcColl->calculations().size() == 0 ) + if ( calcColl->calculations().empty() ) { calcColl->addCalculation(); } diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicShowSummaryCurveCalculatorFeature.h b/ApplicationLibCode/Commands/SummaryPlotCommands/RicShowSummaryCurveCalculatorFeature.h index a274865185..9d9d30e4a4 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicShowSummaryCurveCalculatorFeature.h +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicShowSummaryCurveCalculatorFeature.h @@ -30,7 +30,7 @@ class RicShowSummaryCurveCalculatorFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; public: - static RicSummaryCurveCalculatorDialog* curveCalculatorDialog(); + static RicSummaryCurveCalculatorDialog* curveCalculatorDialog( bool createIfNotPresent ); static void hideCurveCalculatorDialog(); protected: diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicActivateCurveFilterInToolbarFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicShowSummaryPlotManagerFeature.cpp similarity index 66% rename from ApplicationLibCode/Commands/SummaryPlotCommands/RicActivateCurveFilterInToolbarFeature.cpp rename to ApplicationLibCode/Commands/SummaryPlotCommands/RicShowSummaryPlotManagerFeature.cpp index 8e4ff89a6d..5a85dc6da4 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicActivateCurveFilterInToolbarFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicShowSummaryPlotManagerFeature.cpp @@ -1,6 +1,6 @@ -///////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2019- Equinor ASA +// Copyright (C) 2021- Equinor ASA // // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -16,19 +16,19 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RicActivateCurveFilterInToolbarFeature.h" +#include "RicShowSummaryPlotManagerFeature.h" #include "RiaGuiApplication.h" #include "RiuPlotMainWindow.h" #include -CAF_CMD_SOURCE_INIT( RicActivateCurveFilterInToolbarFeature, "RicActivateCurveFilterInToolbarFeature" ); +CAF_CMD_SOURCE_INIT( RicShowSummaryPlotManagerFeature, "RicShowSummaryPlotManagerFeature" ); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RicActivateCurveFilterInToolbarFeature::isCommandEnabled() +bool RicShowSummaryPlotManagerFeature::isCommandEnabled() { return true; } @@ -36,24 +36,20 @@ bool RicActivateCurveFilterInToolbarFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicActivateCurveFilterInToolbarFeature::onActionTriggered( bool isChecked ) +void RicShowSummaryPlotManagerFeature::onActionTriggered( bool isChecked ) { - if ( RiaGuiApplication::isRunning() ) + RiuPlotMainWindow* mpw = RiaGuiApplication::instance()->mainPlotWindow(); + if ( mpw ) { - auto plotWindow = RiaGuiApplication::instance()->mainPlotWindow(); - if ( plotWindow ) - { - plotWindow->setFocusToLineEditInSummaryToolBar(); - } + mpw->showAndSetKeyboardFocusToSummaryPlotManager(); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicActivateCurveFilterInToolbarFeature::setupActionLook( QAction* actionToSetup ) +void RicShowSummaryPlotManagerFeature::setupActionLook( QAction* actionToSetup ) { - actionToSetup->setText( "Activate Summary Curve Filter Editor" ); - - applyShortcutWithHintToAction( actionToSetup, QKeySequence( tr( "Ctrl+F" ) ) ); + actionToSetup->setText( "Show Summary Plot Manager" ); + applyShortcutWithHintToAction( actionToSetup, QKeySequence( tr( "Ctrl+K" ) ) ); } diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicShowSummaryPlotManagerFeature.h b/ApplicationLibCode/Commands/SummaryPlotCommands/RicShowSummaryPlotManagerFeature.h new file mode 100644 index 0000000000..20c91489da --- /dev/null +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicShowSummaryPlotManagerFeature.h @@ -0,0 +1,34 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +//================================================================================================== +/// +//================================================================================================== +class RicShowSummaryPlotManagerFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + bool isCommandEnabled() override; + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; +}; diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryCurveCalculatorDialog.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryCurveCalculatorDialog.cpp index dd7dae606e..2995fcdccc 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryCurveCalculatorDialog.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryCurveCalculatorDialog.cpp @@ -18,27 +18,18 @@ #include "RicSummaryCurveCalculatorDialog.h" +#include "RicCalculatorWidgetCreator.h" #include "RicSummaryCurveCalculatorUi.h" -#include "RicSummaryCurveCalculatorWidgetCreator.h" #include "RimSummaryCalculation.h" #include "RimSummaryCalculationCollection.h" -#include "RiuTools.h" - -#include -#include -#include - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RicSummaryCurveCalculatorDialog::RicSummaryCurveCalculatorDialog( QWidget* parent ) - : QDialog( parent, RiuTools::defaultDialogFlags() ) + : RicUserDefinedCalculatorDialog( parent, "Summary Curve Calculator" ) { - setWindowTitle( "Summary Curve Calculator" ); - resize( 1200, 800 ); - setUp(); } @@ -52,96 +43,41 @@ RicSummaryCurveCalculatorDialog::~RicSummaryCurveCalculatorDialog() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicSummaryCurveCalculatorDialog::setCalculationAndUpdateUi( RimSummaryCalculation* calculation ) +void RicSummaryCurveCalculatorDialog::setCalculationAndUpdateUi( RimUserDefinedCalculation* calculation ) { - m_summaryCalcEditor->calculator()->setCurrentCalculation( calculation ); - - m_summaryCalcEditor->updateUi(); + CAF_ASSERT( m_summaryCalcEditor ); + m_summaryCalcEditor->calculator()->setCurrentCalculation( dynamic_cast( calculation ) ); + updateUi(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicSummaryCurveCalculatorDialog::slotTryCloseDialog() +void RicSummaryCurveCalculatorDialog::updateUi() { - RimSummaryCalculationCollection* calculationCollection = RicSummaryCurveCalculatorUi::calculationCollection(); - - if ( dirtyCount() > 0 ) - { - QMessageBox msgBox( this ); - msgBox.setIcon( QMessageBox::Question ); - - QString questionText = QString( "Detected calculation expression text modifications." ); - - msgBox.setText( questionText ); - msgBox.setInformativeText( "Do you want to trigger calculation?" ); - msgBox.setStandardButtons( QMessageBox::Yes | QMessageBox::No ); - - int ret = msgBox.exec(); - if ( ret == QMessageBox::No ) - { - reject(); - } - else if ( ret == QMessageBox::Yes ) - { - for ( auto c : calculationCollection->calculations() ) - { - if ( c->isDirty() ) - { - c->calculate(); - c->updateDependentCurvesAndPlots(); - } - } - - if ( dirtyCount() > 0 ) - { - return; - } - } - else - { - return; - } - } - - accept(); + CAF_ASSERT( m_summaryCalcEditor ); + m_summaryCalcEditor->updateUi(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicSummaryCurveCalculatorDialog::setUp() +RimUserDefinedCalculationCollection* RicSummaryCurveCalculatorDialog::calculationCollection() const { - QVBoxLayout* mainLayout = new QVBoxLayout( this ); - mainLayout->setContentsMargins( 0, 0, 0, 0 ); - - m_summaryCalcEditor = - std::unique_ptr( new RicSummaryCurveCalculatorWidgetCreator() ); - mainLayout->addWidget( m_summaryCalcEditor->getOrCreateWidget( this ) ); - - QDialogButtonBox* buttonBox = new QDialogButtonBox( QDialogButtonBox::Close ); - connect( buttonBox, SIGNAL( rejected() ), this, SLOT( slotTryCloseDialog() ) ); - - mainLayout->addWidget( buttonBox ); - - m_summaryCalcEditor->updateUi(); + CAF_ASSERT( m_summaryCalcEditor ); + return m_summaryCalcEditor->calculator()->calculationCollection(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -size_t RicSummaryCurveCalculatorDialog::dirtyCount() const +QWidget* RicSummaryCurveCalculatorDialog::getCalculatorWidget() { - size_t count = 0; - - RimSummaryCalculationCollection* calculationCollection = RicSummaryCurveCalculatorUi::calculationCollection(); - for ( auto c : calculationCollection->calculations() ) + if ( !m_summaryCalcEditor ) { - if ( c->isDirty() ) - { - count++; - } + m_summaryCalcEditor = std::unique_ptr( + new RicCalculatorWidgetCreator( std::make_unique() ) ); } - return count; + return m_summaryCalcEditor->getOrCreateWidget( this ); } diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryCurveCalculatorDialog.h b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryCurveCalculatorDialog.h index 311ea12402..e8acbd2bd7 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryCurveCalculatorDialog.h +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryCurveCalculatorDialog.h @@ -18,17 +18,17 @@ #pragma once -#include +#include "RicUserDefinedCalculatorDialog.h" + #include -class RicSummaryCurveCalculatorWidgetCreator; -class RimSummaryCalculation; +class RicCalculatorWidgetCreator; //================================================================================================== /// /// //================================================================================================== -class RicSummaryCurveCalculatorDialog : public QDialog +class RicSummaryCurveCalculatorDialog : public RicUserDefinedCalculatorDialog { Q_OBJECT @@ -36,15 +36,11 @@ class RicSummaryCurveCalculatorDialog : public QDialog RicSummaryCurveCalculatorDialog( QWidget* parent ); ~RicSummaryCurveCalculatorDialog() override; - void setCalculationAndUpdateUi( RimSummaryCalculation* calculation ); - -private slots: - void slotTryCloseDialog(); - -private: - void setUp(); - size_t dirtyCount() const; + void setCalculationAndUpdateUi( RimUserDefinedCalculation* calculation ) override; + QWidget* getCalculatorWidget() override; + void updateUi() override; + RimUserDefinedCalculationCollection* calculationCollection() const override; private: - std::unique_ptr m_summaryCalcEditor; + std::unique_ptr m_summaryCalcEditor; }; diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryCurveCalculatorUi.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryCurveCalculatorUi.cpp index ce8267064a..acef817ca5 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryCurveCalculatorUi.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryCurveCalculatorUi.cpp @@ -21,13 +21,9 @@ #include "RiaSummaryTools.h" #include "RimProject.h" -#include "RimSummaryCalculation.h" #include "RimSummaryCalculationCollection.h" - -#include "cafPdmUiListEditor.h" -#include "cafPdmUiObjectEditorHandle.h" -#include "cafPdmUiPushButtonEditor.h" -#include "cafPdmUiTreeSelectionEditor.h" +#include "RimUserDefinedCalculation.h" +#include "RimUserDefinedCalculationCollection.h" CAF_PDM_SOURCE_INIT( RicSummaryCurveCalculatorUi, "RicSummaryCurveCalculator" ); @@ -36,26 +32,13 @@ CAF_PDM_SOURCE_INIT( RicSummaryCurveCalculatorUi, "RicSummaryCurveCalculator" ); //-------------------------------------------------------------------------------------------------- RicSummaryCurveCalculatorUi::RicSummaryCurveCalculatorUi() { - CAF_PDM_InitObject( "RicSummaryCurveCalculator", "", "", "" ); - - CAF_PDM_InitFieldNoDefault( &m_currentCalculation, "CurrentCalculation", "", "", "", "" ); - m_currentCalculation.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); - // m_currentCalculation.uiCapability()->setUiEditorTypeName(caf::PdmUiTreeSelectionEditor::uiEditorTypeName()); - m_currentCalculation.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() ); - - CAF_PDM_InitFieldNoDefault( &m_newCalculation, "NewCalculation", "New Calculation", "", "", "" ); - RicSummaryCurveCalculatorUi::assignPushButtonEditor( &m_newCalculation ); - - CAF_PDM_InitFieldNoDefault( &m_deleteCalculation, "DeleteCalculation", "Delete Calculation", "", "", "" ); - RicSummaryCurveCalculatorUi::assignPushButtonEditor( &m_deleteCalculation ); - - m_calcContextMenuMgr = std::unique_ptr( new RiuCalculationsContextMenuManager() ); + CAF_PDM_InitObject( "RicSummaryCurveCalculator" ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RicSummaryCurveCalculatorUi::calculatedSummariesGroupName() +QString RicSummaryCurveCalculatorUi::calculationsGroupName() const { return "CalculatedSummariesGroupName"; } @@ -63,7 +46,7 @@ QString RicSummaryCurveCalculatorUi::calculatedSummariesGroupName() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RicSummaryCurveCalculatorUi::calulationGroupName() +QString RicSummaryCurveCalculatorUi::calulationGroupName() const { return "CalulationGroupName"; } @@ -71,228 +54,15 @@ QString RicSummaryCurveCalculatorUi::calulationGroupName() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryCalculation* RicSummaryCurveCalculatorUi::currentCalculation() const -{ - return m_currentCalculation(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicSummaryCurveCalculatorUi::setCurrentCalculation( RimSummaryCalculation* calculation ) -{ - m_currentCalculation = calculation; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RicSummaryCurveCalculatorUi::parseExpression() const -{ - if ( m_currentCalculation() ) - { - QString previousCurveName = m_currentCalculation->description(); - if ( !m_currentCalculation()->parseExpression() ) - { - return false; - } - - QString currentCurveName = m_currentCalculation->description(); - if ( previousCurveName != currentCurveName ) - { - RiaSummaryTools::notifyCalculatedCurveNameHasChanged( m_currentCalculation()->id(), currentCurveName ); - } - - m_currentCalculation()->updateDependentCurvesAndPlots(); - } - - return true; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicSummaryCurveCalculatorUi::fieldChangedByUi( const caf::PdmFieldHandle* changedField, - const QVariant& oldValue, - const QVariant& newValue ) +void RicSummaryCurveCalculatorUi::notifyCalculatedNameChanged( int id, const QString& newName ) const { - if ( changedField == &m_newCalculation ) - { - m_newCalculation = false; - - m_currentCalculation = calculationCollection()->addCalculation(); - - this->updateConnectedEditors(); - } - else if ( changedField == &m_deleteCalculation ) - { - m_deleteCalculation = false; - - if ( m_currentCalculation() ) - { - calculationCollection()->deleteCalculation( m_currentCalculation() ); - m_currentCalculation = nullptr; - - this->updateConnectedEditors(); - caf::PdmUiObjectEditorHandle::updateUiAllObjectEditors(); - } - } + RiaSummaryTools::notifyCalculatedCurveNameHasChanged( id, newName ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicSummaryCurveCalculatorUi::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +RimUserDefinedCalculationCollection* RicSummaryCurveCalculatorUi::calculationCollection() const { - if ( !m_currentCalculation() ) - { - if ( calculationCollection()->calculations().size() > 0 ) - { - m_currentCalculation = calculationCollection()->calculations()[0]; - } - } - - { - caf::PdmUiGroup* group = - uiOrdering.addNewGroupWithKeyword( "Calculated Summaries", - RicSummaryCurveCalculatorUi::calculatedSummariesGroupName() ); - group->add( &m_currentCalculation ); - group->add( &m_newCalculation ); - group->add( &m_deleteCalculation ); - } - - { - caf::PdmUiGroup* group = uiOrdering.addNewGroupWithKeyword( "Calculation Settings", - RicSummaryCurveCalculatorUi::calulationGroupName() ); - if ( m_currentCalculation() ) - { - m_currentCalculation->uiOrdering( uiConfigName, *group ); - } - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QList - RicSummaryCurveCalculatorUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) -{ - QList options; - if ( fieldNeedingOptions == &m_currentCalculation ) - { - for ( auto c : calculationCollection()->calculations() ) - { - options.push_back( caf::PdmOptionItemInfo( c->description(), c ) ); - } - } - - return options; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimSummaryCalculationCollection* RicSummaryCurveCalculatorUi::calculationCollection() -{ - RimProject* proj = RimProject::current(); - if ( proj ) - { - return proj->calculationCollection(); - } - - return nullptr; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicSummaryCurveCalculatorUi::assignPushButtonEditor( caf::PdmFieldHandle* fieldHandle ) -{ - CVF_ASSERT( fieldHandle ); - CVF_ASSERT( fieldHandle->uiCapability() ); - - fieldHandle->uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); - fieldHandle->uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicSummaryCurveCalculatorUi::assignPushButtonEditorText( caf::PdmUiEditorAttribute* attribute, const QString& text ) -{ - caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast( attribute ); - if ( attrib ) - { - attrib->m_buttonText = text; - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RicSummaryCurveCalculatorUi::calculate() const -{ - if ( m_currentCalculation() ) - { - QString previousCurveName = m_currentCalculation->description(); - if ( !m_currentCalculation()->parseExpression() ) - { - return false; - } - - QString currentCurveName = m_currentCalculation->description(); - if ( previousCurveName != currentCurveName ) - { - RiaSummaryTools::notifyCalculatedCurveNameHasChanged( m_currentCalculation()->id(), currentCurveName ); - } - - if ( !m_currentCalculation()->calculate() ) - { - return false; - } - - m_currentCalculation()->updateDependentCurvesAndPlots(); - caf::PdmUiObjectEditorHandle::updateUiAllObjectEditors(); - } - - return true; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicSummaryCurveCalculatorUi::defineEditorAttribute( const caf::PdmFieldHandle* field, - QString uiConfigName, - caf::PdmUiEditorAttribute* attribute ) -{ - if ( &m_newCalculation == field ) - { - RicSummaryCurveCalculatorUi::assignPushButtonEditorText( attribute, "New Calculation" ); - } - else if ( &m_deleteCalculation == field ) - { - RicSummaryCurveCalculatorUi::assignPushButtonEditorText( attribute, "Delete Calculation" ); - } -} - -//-------------------------------------------------------------------------------------------------- -/// f -//-------------------------------------------------------------------------------------------------- -void RicSummaryCurveCalculatorUi::onEditorWidgetsCreated() -{ - if ( m_currentCalculation() != nullptr ) - { - m_currentCalculation->attachToWidget(); - } - - for ( const auto& e : m_currentCalculation.uiCapability()->connectedEditors() ) - { - caf::PdmUiListEditor* listEditor = dynamic_cast( e ); - if ( !listEditor ) continue; - - QWidget* widget = listEditor->editorWidget(); - if ( !widget ) continue; - - m_calcContextMenuMgr->attachWidget( widget, this ); - } + return RimProject::current()->calculationCollection(); } diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryCurveCalculatorUi.h b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryCurveCalculatorUi.h index 5731243be1..60f3728b24 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryCurveCalculatorUi.h +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryCurveCalculatorUi.h @@ -18,56 +18,22 @@ #pragma once -#include "RiuCalculationsContextMenuManager.h" -#include "cafPdmField.h" -#include "cafPdmObject.h" -#include "cafPdmPtrField.h" -#include +#include "RicUserDefinedCalculatorUi.h" -class RimSummaryCalculationCollection; -class RimSummaryCalculation; +class RimUserDefinedCalculationCollection; //================================================================================================== /// //================================================================================================== -class RicSummaryCurveCalculatorUi : public caf::PdmObject +class RicSummaryCurveCalculatorUi : public RicUserDefinedCalculatorUi { CAF_PDM_HEADER_INIT; public: RicSummaryCurveCalculatorUi(); - static QString calculatedSummariesGroupName(); - static QString calulationGroupName(); - - RimSummaryCalculation* currentCalculation() const; - void setCurrentCalculation( RimSummaryCalculation* calculation ); - - bool parseExpression() const; - bool calculate() const; - - static RimSummaryCalculationCollection* calculationCollection(); - -private: - void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; - void defineEditorAttribute( const caf::PdmFieldHandle* field, - QString uiConfigName, - caf::PdmUiEditorAttribute* attribute ) override; - void onEditorWidgetsCreated() override; - -private: - // TODO : Move to a common caf helper class - static void assignPushButtonEditor( caf::PdmFieldHandle* fieldHandle ); - static void assignPushButtonEditorText( caf::PdmUiEditorAttribute* attribute, const QString& text ); - -private: - caf::PdmPtrField m_currentCalculation; - - caf::PdmField m_newCalculation; - caf::PdmField m_deleteCalculation; - - std::unique_ptr m_calcContextMenuMgr; + QString calculationsGroupName() const override; + QString calulationGroupName() const override; + RimUserDefinedCalculationCollection* calculationCollection() const override; + void notifyCalculatedNameChanged( int id, const QString& newName ) const override; }; diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryCurveSwitchAxisFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryCurveSwitchAxisFeature.cpp index e1f6ddc5bc..02680d09dd 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryCurveSwitchAxisFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryCurveSwitchAxisFeature.cpp @@ -56,18 +56,18 @@ void RicSummaryCurveSwitchAxisFeature::onActionTriggered( bool isChecked ) for ( RimSummaryCurve* summaryCurve : summaryCurves ) { - RiaDefines::PlotAxis plotAxis = summaryCurve->axisY(); + RiaDefines::PlotAxis plotAxis = summaryCurve->axisY().axis(); if ( plotAxis == RiaDefines::PlotAxis::PLOT_AXIS_LEFT ) { - summaryCurve->setLeftOrRightAxisY( RiaDefines::PlotAxis::PLOT_AXIS_RIGHT ); + summaryCurve->setLeftOrRightAxisY( RiuPlotAxis( RiaDefines::PlotAxis::PLOT_AXIS_RIGHT ) ); } else { - summaryCurve->setLeftOrRightAxisY( RiaDefines::PlotAxis::PLOT_AXIS_LEFT ); + summaryCurve->setLeftOrRightAxisY( RiuPlotAxis( RiaDefines::PlotAxis::PLOT_AXIS_LEFT ) ); } - summaryCurve->updateQwtPlotAxis(); + summaryCurve->updatePlotAxis(); summaryCurve->updateConnectedEditors(); RimSummaryPlot* plot = nullptr; @@ -77,9 +77,9 @@ void RicSummaryCurveSwitchAxisFeature::onActionTriggered( bool isChecked ) for ( RimAsciiDataCurve* asciiCurve : asciiDataCurves ) { - RiaDefines::PlotAxis plotAxis = asciiCurve->yAxis(); + RiuPlotAxis plotAxis = asciiCurve->yAxis(); - if ( plotAxis == RiaDefines::PlotAxis::PLOT_AXIS_LEFT ) + if ( plotAxis.axis() == RiaDefines::PlotAxis::PLOT_AXIS_LEFT ) { asciiCurve->setYAxis( RiaDefines::PlotAxis::PLOT_AXIS_RIGHT ); } @@ -98,9 +98,9 @@ void RicSummaryCurveSwitchAxisFeature::onActionTriggered( bool isChecked ) for ( RimGridTimeHistoryCurve* timeHistoryCurve : gridTimeHistoryCurves ) { - RiaDefines::PlotAxis plotAxis = timeHistoryCurve->yAxis(); + RiuPlotAxis plotAxis = timeHistoryCurve->yAxis(); - if ( plotAxis == RiaDefines::PlotAxis::PLOT_AXIS_LEFT ) + if ( plotAxis.axis() == RiaDefines::PlotAxis::PLOT_AXIS_LEFT ) { timeHistoryCurve->setYAxis( RiaDefines::PlotAxis::PLOT_AXIS_RIGHT ); } diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryCurveSwitchAxisFeature.h b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryCurveSwitchAxisFeature.h index 268f4e628b..1fd902964f 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryCurveSwitchAxisFeature.h +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryCurveSwitchAxisFeature.h @@ -35,7 +35,6 @@ class RicSummaryCurveSwitchAxisFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotEditorDialog.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotEditorDialog.cpp index 00ba11274a..f25da5c11e 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotEditorDialog.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotEditorDialog.cpp @@ -55,6 +55,7 @@ RicSummaryPlotEditorDialog::RicSummaryPlotEditorDialog( QWidget* parent ) RicSummaryPlotEditorDialog::~RicSummaryPlotEditorDialog() { m_curveCreatorSplitterUi->setPdmObject( nullptr ); + delete m_curveCreatorSplitterUi; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotEditorUi.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotEditorUi.cpp index edb01800f5..77b6641c07 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotEditorUi.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotEditorUi.cpp @@ -23,7 +23,6 @@ #include "RiaGuiApplication.h" #include "RiaSummaryCurveDefinition.h" -#include "RicSelectSummaryPlotUI.h" #include "RiuSummaryCurveDefinitionKeywords.h" #include "RimDerivedEnsembleCaseCollection.h" @@ -42,8 +41,8 @@ #include "RimSummaryCurve.h" #include "RimSummaryCurveAutoName.h" #include "RimSummaryCurveCollection.h" +#include "RimSummaryMultiPlot.h" #include "RimSummaryPlot.h" -#include "RimSummaryPlotCollection.h" #include "RiuPlotMainWindow.h" #include "RiuPlotMainWindowTools.h" @@ -51,6 +50,8 @@ #include "RiuSummaryVectorSelectionUi.h" #include "RiuTools.h" +#include "PlotBuilderCommands/RicSummaryPlotBuilder.h" + #include "cafPdmUiComboBoxEditor.h" #include "cafPdmUiPushButtonEditor.h" @@ -83,34 +84,35 @@ std::vector toVector( const std::set& set ); /// //-------------------------------------------------------------------------------------------------- RicSummaryPlotEditorUi::RicSummaryPlotEditorUi() + : m_plotContainer( nullptr ) { - CAF_PDM_InitFieldNoDefault( &m_targetPlot, "TargetPlot", "Target Plot", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_targetPlot, "TargetPlot", "Target Plot" ); - CAF_PDM_InitField( &m_useAutoAppearanceAssignment, "UseAutoAppearanceAssignment", true, "Auto", "", "", "" ); - CAF_PDM_InitField( &m_appearanceApplyButton, "AppearanceApplyButton", false, "", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_caseAppearanceType, "CaseAppearanceType", "Case", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_variableAppearanceType, "VariableAppearanceType", "Vector", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_wellAppearanceType, "WellAppearanceType", "Well", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_groupAppearanceType, "GroupAppearanceType", "Group", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_regionAppearanceType, "RegionAppearanceType", "Region", "", "", "" ); + CAF_PDM_InitField( &m_useAutoAppearanceAssignment, "UseAutoAppearanceAssignment", true, "Auto" ); + CAF_PDM_InitField( &m_appearanceApplyButton, "AppearanceApplyButton", false, "" ); + CAF_PDM_InitFieldNoDefault( &m_caseAppearanceType, "CaseAppearanceType", "Case" ); + CAF_PDM_InitFieldNoDefault( &m_variableAppearanceType, "VariableAppearanceType", "Vector" ); + CAF_PDM_InitFieldNoDefault( &m_wellAppearanceType, "WellAppearanceType", "Well" ); + CAF_PDM_InitFieldNoDefault( &m_groupAppearanceType, "GroupAppearanceType", "Group" ); + CAF_PDM_InitFieldNoDefault( &m_regionAppearanceType, "RegionAppearanceType", "Region" ); - m_previewPlot.reset( new RimSummaryPlot() ); + m_previewPlot = std::make_unique(); - CAF_PDM_InitFieldNoDefault( &m_useAutoPlotTitleProxy, "UseAutoPlotTitle", "Auto Plot Title", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_useAutoPlotTitleProxy, "UseAutoPlotTitle", "Auto Plot Title" ); m_useAutoPlotTitleProxy.registerGetMethod( this, &RicSummaryPlotEditorUi::proxyPlotAutoTitle ); m_useAutoPlotTitleProxy.registerSetMethod( this, &RicSummaryPlotEditorUi::proxyEnablePlotAutoTitle ); - CAF_PDM_InitFieldNoDefault( &m_applyButtonField, "ApplySelection", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_applyButtonField, "ApplySelection", "" ); m_applyButtonField = false; m_applyButtonField.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); m_applyButtonField.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); - CAF_PDM_InitFieldNoDefault( &m_closeButtonField, "Close", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_closeButtonField, "Close", "" ); m_closeButtonField = false; m_closeButtonField.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); m_closeButtonField.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); - CAF_PDM_InitFieldNoDefault( &m_okButtonField, "OK", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_okButtonField, "OK", "" ); m_okButtonField = false; m_okButtonField.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); m_okButtonField.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); @@ -119,12 +121,12 @@ RicSummaryPlotEditorUi::RicSummaryPlotEditorUi() m_appearanceApplyButton.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); m_appearanceApplyButton.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LEFT ); - CAF_PDM_InitFieldNoDefault( &m_curveNameConfig, "SummaryCurveNameConfig", "SummaryCurveNameConfig", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_curveNameConfig, "SummaryCurveNameConfig", "SummaryCurveNameConfig" ); m_curveNameConfig = new RimSummaryCurveAutoName(); m_curveNameConfig.uiCapability()->setUiTreeHidden( true ); m_curveNameConfig.uiCapability()->setUiTreeChildrenHidden( true ); - m_summaryCurveSelectionEditor.reset( new RiuSummaryVectorSelectionWidgetCreator() ); + m_summaryCurveSelectionEditor = std::make_unique(); m_summaryCurveSelectionEditor->summaryAddressSelection()->setFieldChangedHandler( [this]() { this->selectionEditorFieldChanged(); } ); @@ -162,6 +164,7 @@ void RicSummaryPlotEditorUi::updateFromSummaryPlot( RimSummaryPlot* if ( m_targetPlot ) { + targetPlot->firstAncestorOfType( m_plotContainer ); populateCurveCreator( *m_targetPlot ); syncPreviewCurvesFromUiSelection(); setInitialCurveVisibility( targetPlot ); @@ -172,6 +175,7 @@ void RicSummaryPlotEditorUi::updateFromSummaryPlot( RimSummaryPlot* setDefaultCurveSelection( defaultSources ); m_previewPlot->enableAutoPlotTitle( true ); syncPreviewCurvesFromUiSelection(); + m_plotContainer = nullptr; } caf::PdmUiItem::updateConnectedEditors(); @@ -234,7 +238,7 @@ void RicSummaryPlotEditorUi::fieldChangedByUi( const caf::PdmFieldHandle* change field->setValueWithFieldChanged( true ); RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow(); - mainPlotWindow->updateSummaryPlotToolBar(); + mainPlotWindow->updateMultiPlotToolBar(); } else if ( changedField == &m_useAutoAppearanceAssignment && m_useAutoAppearanceAssignment ) { @@ -257,24 +261,19 @@ void RicSummaryPlotEditorUi::fieldChangedByUi( const caf::PdmFieldHandle* change //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList - RicSummaryPlotEditorUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) +QList RicSummaryPlotEditorUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; if ( fieldNeedingOptions == &m_targetPlot ) { - RimProject* proj = RimProject::current(); - - RimSummaryPlotCollection* summaryPlotColl = proj->mainPlotCollection()->summaryPlotCollection(); - // Create New Plot item QString displayName = "( New Plot )"; options.push_back( caf::PdmOptionItemInfo( displayName, nullptr ) ); - if ( summaryPlotColl ) + if ( m_plotContainer ) { - summaryPlotColl->summaryPlotItemInfos( &options ); + m_plotContainer->summaryPlotItemInfos( &options ); } } @@ -340,6 +339,13 @@ void RicSummaryPlotEditorUi::syncPreviewCurvesFromUiSelection() { std::vector allCurveDefinitionsVector = m_summaryCurveSelectionEditor->summaryAddressSelection()->allCurveDefinitionsFromSelection(); + + auto curveSetDefs = m_summaryCurveSelectionEditor->summaryAddressSelection()->allCurveSetDefinitionsFromSelections(); + for ( const auto& curveSet : curveSetDefs ) + { + allCurveDefinitionsVector.emplace_back( curveSet.ensemble(), curveSet.summaryAddress() ); + } + std::set allCurveDefinitions = std::set( allCurveDefinitionsVector.begin(), allCurveDefinitionsVector.end() ); @@ -463,18 +469,7 @@ void RicSummaryPlotEditorUi::updatePreviewCurvesFromCurveDefinitions( std::map> stashedErrorBarsAndLegendVisibility; for ( const auto& curveDef : curveDefsToAdd ) { - RimSummaryCase* currentCase = curveDef.summaryCase(); - RimSummaryCurve* curve = new RimSummaryCurve(); - if ( speedCheatsRequired ) - { - stashedErrorBarsAndLegendVisibility[curve] = std::make_pair( curve->errorBarsVisible(), curve->showInLegend() ); - curve->setErrorBarsVisible( false ); - curve->setShowInLegend( false ); - } - curve->setSummaryCaseY( currentCase ); - curve->setSummaryAddressYAndApplyInterpolation( curveDef.summaryAddress() ); - curve->applyCurveAutoNameSettings( *m_curveNameConfig() ); - if ( currentCase->isObservedData() ) curve->setSymbolSkipDistance( 0 ); + RimSummaryCase* currentCase = curveDef.summaryCase(); if ( curveDef.isEnsembleCurve() ) { @@ -524,10 +519,22 @@ void RicSummaryPlotEditorUi::updatePreviewCurvesFromCurveDefinitions( } } } - curveSet->addCurve( curve ); } else { + RimSummaryCurve* curve = new RimSummaryCurve(); + if ( speedCheatsRequired ) + { + stashedErrorBarsAndLegendVisibility[curve] = + std::make_pair( curve->errorBarsVisible(), curve->showInLegend() ); + curve->setErrorBarsVisible( false ); + curve->setShowInLegend( false ); + } + curve->setSummaryCaseY( currentCase ); + curve->setSummaryAddressYAndApplyInterpolation( curveDef.summaryAddress() ); + curve->applyCurveAutoNameSettings( *m_curveNameConfig() ); + if ( currentCase && currentCase->isObservedData() ) curve->setSymbolSkipDistance( 0 ); + m_previewPlot->addCurveNoUpdate( curve ); curveLookCalc.setupCurveLook( curve ); } @@ -627,10 +634,7 @@ void RicSummaryPlotEditorUi::populateCurveCreator( const RimSummaryPlot& sourceS previewCurveSetColl->addCurveSet( newCurveSet ); RimSummaryCaseCollection* ensemble = curveSet->summaryCaseCollection(); - for ( const auto& curve : curveSet->curves() ) - { - curveDefs.push_back( curve->curveDefinitionY() ); - } + curveDefs.emplace_back( ensemble, curveSet->summaryAddress() ); } m_previewPlot->copyAxisPropertiesFromOther( sourceSummaryPlot ); @@ -688,7 +692,7 @@ void RicSummaryPlotEditorUi::updateTargetPlot() copyEnsembleCurveAndAddToCurveSet( editedCurve, editedCurveSet ); } - newCurveSet->setParentQwtPlotNoReplot( m_targetPlot->viewer() ); + newCurveSet->setParentPlotNoReplot( m_targetPlot->plotWidget() ); } m_targetPlot->enableAutoPlotTitle( m_useAutoPlotTitleProxy() ); @@ -713,7 +717,8 @@ void RicSummaryPlotEditorUi::copyCurveAndAddToPlot( const RimSummaryCurve* curve curveCopy->setCurveVisibility( true ); } - plot->addCurveNoUpdate( curveCopy ); + plot->addCurveNoUpdate( curveCopy, false ); + curveCopy->setLeftOrRightAxisY( curve->axisY() ); // The curve creator is not a descendant of the project, and need to be set manually curveCopy->setSummaryCaseY( curve->summaryCaseY() ); @@ -840,52 +845,35 @@ void RicSummaryPlotEditorUi::createNewPlot() { RimProject* proj = RimProject::current(); - RimSummaryPlotCollection* summaryPlotColl = proj->mainPlotCollection()->summaryPlotCollection(); - if ( summaryPlotColl ) + RimSummaryPlot* newSummaryPlot = nullptr; + + if ( !m_plotContainer ) { - RimSummaryPlot* newSummaryPlot = nullptr; - if ( m_useAutoPlotTitleProxy() ) - { - newSummaryPlot = summaryPlotColl->createSummaryPlotWithAutoTitle(); - } - else - { - QString candidatePlotName; - if ( m_previewPlot ) - { - candidatePlotName = m_previewPlot->generatedPlotTitleFromAllCurves(); - } + std::vector plots; + m_plotContainer = RicSummaryPlotBuilder::createAndAppendSummaryMultiPlot( plots ); + } - { - bool ok = false; - candidatePlotName = QInputDialog::getText( nullptr, - "New Summary Plot Name", - "New Summary Plot Name", - QLineEdit::Normal, - candidatePlotName, - &ok, - RiuTools::defaultDialogFlags() ); - if ( !ok ) - { - return; - } + if ( m_plotContainer ) + { + newSummaryPlot = new RimSummaryPlot(); + newSummaryPlot->setAsPlotMdiWindow(); + newSummaryPlot->enableAutoPlotTitle( true ); + m_plotContainer->addPlot( newSummaryPlot ); + } - newSummaryPlot = summaryPlotColl->createNamedSummaryPlot( candidatePlotName ); - } - } + if ( newSummaryPlot ) + { + newSummaryPlot->loadDataAndUpdate(); - if ( newSummaryPlot ) + if ( m_plotContainer ) { - newSummaryPlot->loadDataAndUpdate(); - - summaryPlotColl->updateConnectedEditors(); + m_plotContainer->updateConnectedEditors(); + } - m_targetPlot = newSummaryPlot; - updateTargetPlot(); + m_targetPlot = newSummaryPlot; - RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow(); - mainPlotWindow->updateSummaryPlotToolBar(); - } + RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow(); + mainPlotWindow->updateMultiPlotToolBar(); } } @@ -900,7 +888,7 @@ void RicSummaryPlotEditorUi::updateCurveNames() curve->updateCurveNameNoLegendUpdate(); } - if ( m_previewPlot && m_previewPlot->viewer() ) m_previewPlot->viewer()->updateLegend(); + if ( m_previewPlot && m_previewPlot->plotWidget() ) m_previewPlot->updateLegend(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotEditorUi.h b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotEditorUi.h index 850d071660..f88b4df977 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotEditorUi.h +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotEditorUi.h @@ -41,6 +41,7 @@ class PdmObject; }; class RimSummaryCase; +class RimSummaryMultiPlot; class RimSummaryCurveAutoName; class RimSummaryPlot; class RiaSummaryCurveDefinition; @@ -76,8 +77,7 @@ class RicSummaryPlotEditorUi : public caf::PdmObject private: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, @@ -133,4 +133,6 @@ class RicSummaryPlotEditorUi : public caf::PdmObject caf::PdmField m_closeButtonField; std::unique_ptr m_summaryCurveSelectionEditor; + + RimSummaryMultiPlot* m_plotContainer; }; diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotFeatureImpl.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotFeatureImpl.cpp index 6fdfb61890..37b4fcbda3 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotFeatureImpl.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotFeatureImpl.cpp @@ -26,7 +26,10 @@ #include "RiaImportEclipseCaseTools.h" #include "RiaLogging.h" #include "RiaPreferencesSummary.h" +#include "RiaSummaryStringTools.h" +#include "RiaTextStringTools.h" +#include "PlotBuilderCommands/RicSummaryPlotBuilder.h" #include "RicCreateSummaryCaseCollectionFeature.h" #include "RicImportGeneralDataFeature.h" #include "RicImportSummaryCasesFeature.h" @@ -49,8 +52,8 @@ #include "RimProject.h" #include "RimSummaryCase.h" #include "RimSummaryCurve.h" +#include "RimSummaryMultiPlotCollection.h" #include "RimSummaryPlot.h" -#include "RimSummaryPlotCollection.h" #include "RiuMainWindow.h" #include "RiuPlotMainWindow.h" @@ -60,58 +63,6 @@ #include #include -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimSummaryCurve* RicSummaryPlotFeatureImpl::addDefaultCurveToPlot( RimSummaryPlot* plot, RimSummaryCase* summaryCase ) -{ - if ( plot && summaryCase && summaryCase->summaryReader() ) - { - RifEclipseSummaryAddress defaultAddressToUse; - - RiaPreferencesSummary* prefs = RiaPreferencesSummary::current(); - - QString curvesTextFilter = prefs->defaultSummaryCurvesTextFilter(); - QStringList curveFilters = curvesTextFilter.split( ";", QString::SkipEmptyParts ); - - if ( curveFilters.size() ) - { - const std::set& addrs = summaryCase->summaryReader()->allResultAddresses(); - - for ( const auto& addr : addrs ) - { - const QString& filter = curveFilters[0]; - { - if ( addr.isUiTextMatchingFilterText( filter ) ) - { - defaultAddressToUse = addr; - } - } - } - } - - RimSummaryCurve* newCurve = new RimSummaryCurve(); - - // Use same counting as RicNewSummaryEnsembleCurveSetFeature::onActionTriggered - cvf::Color3f curveColor = - RiaColorTables::summaryCurveDefaultPaletteColors().cycledColor3f( plot->singleColorCurveCount() ); - newCurve->setColor( curveColor ); - - plot->addCurveNoUpdate( newCurve ); - - if ( summaryCase ) - { - newCurve->setSummaryCaseY( summaryCase ); - } - - newCurve->setSummaryAddressYAndApplyInterpolation( defaultAddressToUse ); - - return newCurve; - } - - return nullptr; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -121,7 +72,7 @@ std::vector RicSummaryPlotFeatureImpl::addDefaultCurvesToPlot( RiaPreferencesSummary* prefs = RiaPreferencesSummary::current(); QString curvesTextFilter = prefs->defaultSummaryCurvesTextFilter(); - QStringList curveFilters = curvesTextFilter.split( ";", QString::SkipEmptyParts ); + QStringList curveFilters = RiaTextStringTools::splitSkipEmptyParts( curvesTextFilter, ";" ); bool addHistoryCurve = false; @@ -131,68 +82,14 @@ std::vector RicSummaryPlotFeatureImpl::addDefaultCurvesToPlot( //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicSummaryPlotFeatureImpl::ensureAtLeastOnePlot( RimSummaryPlotCollection* summaryPlotCollection, - RimSummaryCase* summaryCase ) -{ - if ( summaryPlotCollection && summaryCase ) - { - if ( summaryPlotCollection->plots().empty() ) - { - auto objectToSelect = createDefaultSummaryPlot( summaryCase ); - if ( objectToSelect ) - { - RiuPlotMainWindowTools::setExpanded( objectToSelect ); - RiuPlotMainWindowTools::selectAsCurrentItem( objectToSelect ); - } - } - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -caf::PdmObject* RicSummaryPlotFeatureImpl::createDefaultSummaryPlot( RimSummaryCase* summaryCase ) -{ - RimSummaryPlotCollection* summaryPlotCollection = RimProject::current()->mainPlotCollection->summaryPlotCollection(); - - RiaPreferencesSummary* prefs = RiaPreferencesSummary::current(); - - caf::PdmObject* itemToSelect = nullptr; - - if ( summaryPlotCollection && summaryCase && !prefs->defaultSummaryCurvesTextFilter().isEmpty() ) - { - auto plot = summaryPlotCollection->createSummaryPlotWithAutoTitle(); - - std::vector curves = RicSummaryPlotFeatureImpl::addDefaultCurvesToPlot( plot, summaryCase ); - - plot->applyDefaultCurveAppearances(); - plot->loadDataAndUpdate(); - - summaryPlotCollection->updateConnectedEditors(); - - if ( curves.size() ) - { - itemToSelect = curves[0]; - } - else - { - itemToSelect = plot; - } - } - - return itemToSelect; -} - -RimSummaryCurve* createHistoryCurve( const RifEclipseSummaryAddress& addr, RimSummaryCase* summaryCasesToUse ) +RimSummaryCurve* RicSummaryPlotFeatureImpl::createHistoryCurve( const RifEclipseSummaryAddress& addr, + RimSummaryCase* summaryCasesToUse ) { RifEclipseSummaryAddress historyAddr = addr; - historyAddr.setQuantityName( historyAddr.quantityName() + "H" ); + historyAddr.setVectorName( historyAddr.vectorName() + "H" ); if ( summaryCasesToUse->summaryReader()->allResultAddresses().count( historyAddr ) ) { - RimSummaryCurve* historyCurve = new RimSummaryCurve(); - historyCurve->setSummaryCaseY( summaryCasesToUse ); - historyCurve->setSummaryAddressYAndApplyInterpolation( historyAddr ); - return historyCurve; + return createCurve( summaryCasesToUse, historyAddr ); } return nullptr; @@ -400,12 +297,10 @@ void RicSummaryPlotFeatureImpl::createSummaryPlotsFromArgumentLine( const QStrin RimSummaryPlot* lastPlotCreated = nullptr; - RimSummaryPlotCollection* sumPlotColl = RimProject::current()->mainPlotCollection()->summaryPlotCollection(); - - splitAddressFiltersInGridAndSummary( summaryCasesToUse[0], - allCurveAddressFilters, - &summaryAddressFilters, - &gridResultAddressFilters ); + RiaSummaryStringTools::splitAddressFiltersInGridAndSummary( summaryCasesToUse[0], + allCurveAddressFilters, + &summaryAddressFilters, + &gridResultAddressFilters ); if ( summaryAddressFilters.size() ) { @@ -418,25 +313,33 @@ void RicSummaryPlotFeatureImpl::createSummaryPlotsFromArgumentLine( const QStrin if ( isSinglePlot ) { - RimSummaryPlot* newPlot = createSummaryPlotFromAddresses( sumPlotColl, - summaryCasesToUse, - ensemble, - summaryAddressFilters, - addHistoryCurves, - ensembleColoringStyle, - ensembleColoringParameter ); + RimSummaryPlot* newPlot = nullptr; + if ( ensemble ) + { + newPlot = createSummaryPlotForEnsemble( summaryCasesToUse, + ensemble, + summaryAddressFilters, + addHistoryCurves, + ensembleColoringStyle, + ensembleColoringParameter ); + } + else + { + newPlot = createSummaryPlotForCases( summaryCasesToUse, summaryAddressFilters, addHistoryCurves ); + } lastPlotCreated = newPlot; newPlot->setLegendsVisible( !hideLegend ); newPlot->setNormalizationEnabled( isNormalizedY ); newPlot->loadDataAndUpdate(); + + RicSummaryPlotBuilder::createAndAppendSingleSummaryMultiPlot( newPlot ); } - else // Multiplot, one for each separate summary address + else // Multiple plots, one for each separate summary address, put them all in a summary multiplot { std::vector summaryPlots = - createMultipleSummaryPlotsFromAddresses( sumPlotColl, - summaryCasesToUse, + createMultipleSummaryPlotsFromAddresses( summaryCasesToUse, ensemble, summaryAddressFilters, addHistoryCurves, @@ -451,6 +354,8 @@ void RicSummaryPlotFeatureImpl::createSummaryPlotsFromArgumentLine( const QStrin summaryPlot->setNormalizationEnabled( isNormalizedY ); summaryPlot->loadDataAndUpdate(); } + + RicSummaryPlotBuilder::createAndAppendSummaryMultiPlot( summaryPlots ); } } @@ -506,7 +411,9 @@ void RicSummaryPlotFeatureImpl::createSummaryPlotsFromArgumentLine( const QStrin if ( createdCurves.size() ) { - RimSummaryPlot* newPlot = sumPlotColl->createSummaryPlotWithAutoTitle(); + RimSummaryPlot* newPlot = new RimSummaryPlot(); + newPlot->enableAutoPlotTitle( true ); + for ( auto curve : createdCurves ) { newPlot->addGridTimeHistoryCurve( curve ); @@ -516,6 +423,8 @@ void RicSummaryPlotFeatureImpl::createSummaryPlotsFromArgumentLine( const QStrin newPlot->setNormalizationEnabled( isNormalizedY ); newPlot->loadDataAndUpdate(); lastPlotCreated = newPlot; + + RicSummaryPlotBuilder::createAndAppendSingleSummaryMultiPlot( newPlot ); } } else // Multiplot @@ -559,7 +468,8 @@ void RicSummaryPlotFeatureImpl::createSummaryPlotsFromArgumentLine( const QStrin if ( createdCurves.size() ) { - RimSummaryPlot* newPlot = sumPlotColl->createSummaryPlotWithAutoTitle(); + RimSummaryPlot* newPlot = new RimSummaryPlot(); + newPlot->enableAutoPlotTitle( true ); for ( auto newCurve : createdCurves ) { newPlot->addGridTimeHistoryCurve( newCurve ); @@ -568,6 +478,8 @@ void RicSummaryPlotFeatureImpl::createSummaryPlotsFromArgumentLine( const QStrin newPlot->setNormalizationEnabled( isNormalizedY ); newPlot->loadDataAndUpdate(); lastPlotCreated = newPlot; + + RicSummaryPlotBuilder::createAndAppendSingleSummaryMultiPlot( newPlot ); } } } @@ -576,7 +488,7 @@ void RicSummaryPlotFeatureImpl::createSummaryPlotsFromArgumentLine( const QStrin if ( lastPlotCreated ) { - sumPlotColl->updateConnectedEditors(); + RimProject::current()->mainPlotCollection()->summaryMultiPlotCollection()->updateConnectedEditors(); RiuPlotMainWindow* mpw = RiaGuiApplication::instance()->mainPlotWindow(); // Needed to avoid unnecessary activation of sub windows (plots) @@ -588,7 +500,7 @@ void RicSummaryPlotFeatureImpl::createSummaryPlotsFromArgumentLine( const QStrin RiuPlotMainWindowTools::setExpanded( lastPlotCreated ); RiuPlotMainWindowTools::selectAsCurrentItem( lastPlotCreated ); - RiuMainWindow::instance()->close(); + RiuMainWindow::closeIfOpen(); } } else @@ -597,16 +509,15 @@ void RicSummaryPlotFeatureImpl::createSummaryPlotsFromArgumentLine( const QStrin } } -RimSummaryPlot* - RicSummaryPlotFeatureImpl::createSummaryPlotFromAddresses( RimSummaryPlotCollection* sumPlotColl, - const std::vector& summaryCasesToUse, - RimSummaryCaseCollection* ensemble, - QStringList summaryAddressFilters, - bool addHistoryCurves, - EnsembleColoringType ensembleColoringStyle, - QString ensembleColoringParameter ) +RimSummaryPlot* RicSummaryPlotFeatureImpl::createSummaryPlotForEnsemble( const std::vector& summaryCasesToUse, + RimSummaryCaseCollection* ensemble, + QStringList summaryAddressFilters, + bool addHistoryCurves, + EnsembleColoringType ensembleColoringStyle, + QString ensembleColoringParameter ) { - RimSummaryPlot* newPlot = sumPlotColl->createSummaryPlotWithAutoTitle(); + RimSummaryPlot* newPlot = new RimSummaryPlot(); + newPlot->enableAutoPlotTitle( true ); if ( ensemble ) { @@ -615,25 +526,10 @@ RimSummaryPlot* for ( const auto& addr : filteredAdressesFromCases ) { - RimEnsembleCurveSet* curveSet = new RimEnsembleCurveSet(); - curveSet->setSummaryCaseCollection( ensemble ); - curveSet->setSummaryAddress( addr ); - - if ( ensembleColoringStyle == EnsembleColoringType::PARAMETER || - ensembleColoringStyle == EnsembleColoringType::LOG_PARAMETER ) - { - curveSet->setColorMode( RimEnsembleCurveSet::ColorMode::BY_ENSEMBLE_PARAM ); - curveSet->setEnsembleParameter( ensembleColoringParameter ); - - if ( ensembleColoringStyle == EnsembleColoringType::LOG_PARAMETER ) - { - curveSet->legendConfig()->setMappingMode( RimRegularLegendConfig::MappingType::LOG10_CONTINUOUS ); - } - } - + auto curveSet = createCurveSet( ensemble, addr, ensembleColoringStyle, ensembleColoringParameter ); newPlot->ensembleCurveSetCollection()->addCurveSet( curveSet ); - if ( addHistoryCurves ) + if ( addHistoryCurves && !summaryCasesToUse.empty() ) { RimSummaryCurve* historyCurve = createHistoryCurve( addr, summaryCasesToUse[0] ); @@ -641,18 +537,54 @@ RimSummaryPlot* } } } - else + newPlot->applyDefaultCurveAppearances(); + + return newPlot; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEnsembleCurveSet* RicSummaryPlotFeatureImpl::createCurveSet( RimSummaryCaseCollection* ensemble, + const RifEclipseSummaryAddress& addr, + EnsembleColoringType ensembleColoringStyle, + QString ensembleColoringParameter ) +{ + auto curveSet = new RimEnsembleCurveSet(); + + curveSet->setSummaryCaseCollection( ensemble ); + curveSet->setSummaryAddress( addr ); + + if ( ensembleColoringStyle == EnsembleColoringType::PARAMETER || + ensembleColoringStyle == EnsembleColoringType::LOG_PARAMETER ) { - for ( RimSummaryCase* sumCase : summaryCasesToUse ) + curveSet->setColorMode( RimEnsembleCurveSet::ColorMode::BY_ENSEMBLE_PARAM ); + curveSet->setEnsembleParameter( ensembleColoringParameter ); + + if ( ensembleColoringStyle == EnsembleColoringType::LOG_PARAMETER ) { - RicSummaryPlotFeatureImpl::addCurvesFromAddressFiltersToPlot( summaryAddressFilters, - newPlot, - sumCase, - addHistoryCurves ); - addHistoryCurves = false; + curveSet->legendConfig()->setMappingMode( RimRegularLegendConfig::MappingType::LOG10_CONTINUOUS ); } } + return curveSet; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryPlot* RicSummaryPlotFeatureImpl::createSummaryPlotForCases( const std::vector& summaryCasesToUse, + QStringList summaryAddressFilters, + bool addHistoryCurves /*= false */ ) +{ + RimSummaryPlot* newPlot = new RimSummaryPlot(); + newPlot->enableAutoPlotTitle( true ); + + for ( RimSummaryCase* sumCase : summaryCasesToUse ) + { + RicSummaryPlotFeatureImpl::addCurvesFromAddressFiltersToPlot( summaryAddressFilters, newPlot, sumCase, addHistoryCurves ); + } + newPlot->applyDefaultCurveAppearances(); return newPlot; @@ -662,7 +594,6 @@ RimSummaryPlot* /// //-------------------------------------------------------------------------------------------------- std::vector RicSummaryPlotFeatureImpl::createMultipleSummaryPlotsFromAddresses( - RimSummaryPlotCollection* sumPlotColl, const std::vector& summaryCasesToUse, RimSummaryCaseCollection* ensemble, QStringList summaryAddressFilters, @@ -681,20 +612,7 @@ std::vector RicSummaryPlotFeatureImpl::createMultipleSummaryPlo std::vector createdEnsembleCurveSets; if ( ensemble ) { - RimEnsembleCurveSet* curveSet = new RimEnsembleCurveSet(); - - curveSet->setSummaryCaseCollection( ensemble ); - curveSet->setSummaryAddress( addr ); - if ( ensembleColoringStyle == EnsembleColoringType::PARAMETER || - ensembleColoringStyle == EnsembleColoringType::LOG_PARAMETER ) - { - curveSet->setColorMode( RimEnsembleCurveSet::ColorMode::BY_ENSEMBLE_PARAM ); - curveSet->setEnsembleParameter( ensembleColoringParameter ); - if ( ensembleColoringStyle == EnsembleColoringType::LOG_PARAMETER ) - { - curveSet->legendConfig()->setMappingMode( RimRegularLegendConfig::MappingType::LOG10_CONTINUOUS ); - } - } + auto curveSet = createCurveSet( ensemble, addr, ensembleColoringStyle, ensembleColoringParameter ); createdEnsembleCurveSets.push_back( curveSet ); } else @@ -704,9 +622,7 @@ std::vector RicSummaryPlotFeatureImpl::createMultipleSummaryPlo const std::set& allAddrsInCase = sumCase->summaryReader()->allResultAddresses(); if ( allAddrsInCase.count( addr ) ) { - RimSummaryCurve* newCurve = new RimSummaryCurve(); - newCurve->setSummaryCaseY( sumCase ); - newCurve->setSummaryAddressYAndApplyInterpolation( addr ); + auto* newCurve = createCurve( sumCase, addr ); createdCurves.push_back( newCurve ); } } @@ -720,7 +636,8 @@ std::vector RicSummaryPlotFeatureImpl::createMultipleSummaryPlo if ( createdCurves.size() || createdEnsembleCurveSets.size() ) { - RimSummaryPlot* newPlot = sumPlotColl->createSummaryPlotWithAutoTitle(); + RimSummaryPlot* newPlot = new RimSummaryPlot(); + newPlot->enableAutoPlotTitle( true ); for ( auto curve : createdCurves ) { @@ -739,45 +656,6 @@ std::vector RicSummaryPlotFeatureImpl::createMultipleSummaryPlo return newSummaryPlots; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicSummaryPlotFeatureImpl::splitAddressFiltersInGridAndSummary( RimSummaryCase* summaryBaseCases, - const QStringList& allCurveAddressFilters, - QStringList* summaryAddressFilters, - QStringList* gridResultAddressFilters ) -{ - if ( summaryBaseCases ) - { - const std::set& addrs = summaryBaseCases->summaryReader()->allResultAddresses(); - std::vector usedFilters; - std::set setToInsertFilteredAddressesIn; - filteredSummaryAdressesFromCase( allCurveAddressFilters, addrs, &setToInsertFilteredAddressesIn, &usedFilters ); - - QRegularExpression gridAddressPattern( "^[A-Z]+:[0-9]+,[0-9]+,[0-9]+$" ); - - for ( int filterIdx = 0; filterIdx < allCurveAddressFilters.size(); ++filterIdx ) - { - const QString& address = allCurveAddressFilters[filterIdx]; - if ( usedFilters[filterIdx] ) - { - summaryAddressFilters->push_back( address ); - } - else - { - if ( gridAddressPattern.match( address ).hasMatch() ) - { - gridResultAddressFilters->push_back( address ); - } - else - { - RiaLogging::warning( "No summary or restart vectors matched \"" + address + "\"" ); - } - } - } - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -791,7 +669,7 @@ std::set const std::set& addrs = sumCase->summaryReader()->allResultAddresses(); std::vector usedFilters; - filteredSummaryAdressesFromCase( summaryAddressFilters, addrs, &filteredAdressesFromCases, &usedFilters ); + insertFilteredAddressesInSet( summaryAddressFilters, addrs, &filteredAdressesFromCases, &usedFilters ); for ( size_t cfIdx = 0; cfIdx < usedFilters.size(); ++cfIdx ) { @@ -805,6 +683,19 @@ std::set return filteredAdressesFromCases; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryCurve* RicSummaryPlotFeatureImpl::createCurve( RimSummaryCase* summaryCase, + const RifEclipseSummaryAddress& address ) +{ + auto curve = new RimSummaryCurve(); + curve->setSummaryCaseY( summaryCase ); + curve->setSummaryAddressYAndApplyInterpolation( address ); + + return curve; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -823,7 +714,7 @@ std::vector RicSummaryPlotFeatureImpl::addCurvesFromAddressFil const std::set& addrs = summaryCase->summaryReader()->allResultAddresses(); std::vector usedFilters; - filteredSummaryAdressesFromCase( curveFilters, addrs, &curveAddressesToUse, &usedFilters ); + insertFilteredAddressesInSet( curveFilters, addrs, &curveAddressesToUse, &usedFilters ); for ( size_t cfIdx = 0; cfIdx < usedFilters.size(); ++cfIdx ) { @@ -839,7 +730,7 @@ std::vector RicSummaryPlotFeatureImpl::addCurvesFromAddressFil std::vector historyAddressesToUse; for ( RifEclipseSummaryAddress historyAddr : curveAddressesToUse ) { - historyAddr.setQuantityName( historyAddr.quantityName() + "H" ); + historyAddr.setVectorName( historyAddr.vectorName() + "H" ); if ( addrs.count( historyAddr ) ) { historyAddressesToUse.push_back( historyAddr ); @@ -857,14 +748,10 @@ std::vector RicSummaryPlotFeatureImpl::addCurvesFromAddressFil for ( const auto& addr : curveAddressesToUse ) { - RimSummaryCurve* newCurve = new RimSummaryCurve(); - plot->addCurveNoUpdate( newCurve ); - if ( summaryCase ) - { - newCurve->setSummaryCaseY( summaryCase ); - } - newCurve->setSummaryAddressYAndApplyInterpolation( addr ); + auto* newCurve = createCurve( summaryCase, addr ); + createdCurves.push_back( newCurve ); + plot->addCurveNoUpdate( newCurve ); } return createdCurves; @@ -873,11 +760,10 @@ std::vector RicSummaryPlotFeatureImpl::addCurvesFromAddressFil //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicSummaryPlotFeatureImpl::filteredSummaryAdressesFromCase( - const QStringList& curveFilters, - const std::set& allAddressesInCase, - std::set* setToInsertFilteredAddressesIn, - std::vector* usedFilters ) +void RicSummaryPlotFeatureImpl::insertFilteredAddressesInSet( const QStringList& curveFilters, + const std::set& allAddressesInCase, + std::set* setToInsertFilteredAddressesIn, + std::vector* usedFilters ) { int curveFilterCount = curveFilters.size(); diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotFeatureImpl.h b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotFeatureImpl.h index aedd52e82f..fc6c09eeeb 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotFeatureImpl.h +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotFeatureImpl.h @@ -33,7 +33,7 @@ class RimSummaryCurve; class RimSummaryPlot; class RimSummaryCase; class RimSummaryCaseCollection; -class RimSummaryPlotCollection; +class RimEnsembleCurveSet; class QStringList; @@ -48,39 +48,48 @@ class RicSummaryPlotFeatureImpl NONE }; - static RimSummaryCurve* addDefaultCurveToPlot( RimSummaryPlot* plot, RimSummaryCase* summaryCase ); static std::vector addDefaultCurvesToPlot( RimSummaryPlot* plot, RimSummaryCase* summaryCase ); - static void ensureAtLeastOnePlot( RimSummaryPlotCollection* summaryPlotCollection, RimSummaryCase* summaryCase ); - static caf::PdmObject* createDefaultSummaryPlot( RimSummaryCase* summaryCase ); + static caf::PdmObject* createDefaultSummaryPlot( RimSummaryCase* summaryCase ); static void createSummaryPlotsFromArgumentLine( const QStringList& arguments ); static RimSummaryPlot* - createSummaryPlotFromAddresses( RimSummaryPlotCollection* sumPlotColl, - const std::vector& summaryCasesToUse, - RimSummaryCaseCollection* ensemble, - QStringList summaryAddressFilters, - bool addHistoryCurves = false, - EnsembleColoringType ensembleColoringStyle = EnsembleColoringType::NONE, - QString ensembleColoringParameter = "" ); + createSummaryPlotForEnsemble( const std::vector& summaryCasesToUse, + RimSummaryCaseCollection* ensemble, + QStringList summaryAddressFilters, + bool addHistoryCurves = false, + EnsembleColoringType ensembleColoringStyle = EnsembleColoringType::NONE, + QString ensembleColoringParameter = "" ); + + static RimSummaryPlot* createSummaryPlotForCases( const std::vector& summaryCasesToUse, + QStringList summaryAddressFilters, + bool addHistoryCurves = false ); static std::vector - createMultipleSummaryPlotsFromAddresses( RimSummaryPlotCollection* sumPlotColl, - const std::vector& summaryCasesToUse, + createMultipleSummaryPlotsFromAddresses( const std::vector& summaryCasesToUse, RimSummaryCaseCollection* ensemble, QStringList summaryAddressFilters, bool addHistoryCurves = false, EnsembleColoringType ensembleColoringStyle = EnsembleColoringType::NONE, QString ensembleColoringParameter = "" ); - static void filteredSummaryAdressesFromCase( const QStringList& curveFilters, - const std::set& allAddressesInCase, - std::set* setToInsertFilteredAddressesIn, - std::vector* usedFilters ); + static void insertFilteredAddressesInSet( const QStringList& curveFilters, + const std::set& allAddressesInCase, + std::set* setToInsertFilteredAddressesIn, + std::vector* usedFilters ); static QString summaryPlotCommandLineHelpText(); private: + static RimEnsembleCurveSet* createCurveSet( RimSummaryCaseCollection* ensemble, + const RifEclipseSummaryAddress& addr, + EnsembleColoringType ensembleColoringStyle, + QString ensembleColoringParameter ); + + static RimSummaryCurve* createCurve( RimSummaryCase* summaryCase, const RifEclipseSummaryAddress& address ); + + static RimSummaryCurve* createHistoryCurve( const RifEclipseSummaryAddress& addr, RimSummaryCase* summaryCasesToUse ); + static std::vector addCurvesFromAddressFiltersToPlot( const QStringList& curveFilters, RimSummaryPlot* plot, RimSummaryCase* summaryCase, @@ -89,11 +98,6 @@ class RicSummaryPlotFeatureImpl static std::set applySummaryAddressFiltersToCases( const std::vector& summaryCasesToUse, const QStringList& summaryAddressFilters ); - - static void splitAddressFiltersInGridAndSummary( RimSummaryCase* summaryBaseCases, - const QStringList& allCurveAddressFilters, - QStringList* summaryAddressFilters, - QStringList* gridResultAddressFilters ); }; #include "RigEclipseResultAddress.h" diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicViewZoomAllFeature.h b/ApplicationLibCode/Commands/SummaryPlotCommands/RicViewZoomAllFeature.h index 2c19b4ac1b..5807b55efd 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicViewZoomAllFeature.h +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicViewZoomAllFeature.h @@ -28,7 +28,6 @@ class RicViewZoomAllFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/SurfaceCommands/RicCopySurfaceFeature.h b/ApplicationLibCode/Commands/SurfaceCommands/RicCopySurfaceFeature.h index 8f42e53e3e..9a5be040c2 100644 --- a/ApplicationLibCode/Commands/SurfaceCommands/RicCopySurfaceFeature.h +++ b/ApplicationLibCode/Commands/SurfaceCommands/RicCopySurfaceFeature.h @@ -28,7 +28,6 @@ class RicCopySurfaceFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/SurfaceCommands/RicExportKLayerToPtlFeature.h b/ApplicationLibCode/Commands/SurfaceCommands/RicExportKLayerToPtlFeature.h index 119e3c58dc..6d75cec07a 100644 --- a/ApplicationLibCode/Commands/SurfaceCommands/RicExportKLayerToPtlFeature.h +++ b/ApplicationLibCode/Commands/SurfaceCommands/RicExportKLayerToPtlFeature.h @@ -32,7 +32,6 @@ class RicExportKLayerToPtlFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/SurfaceCommands/RicExportSurfaceToTsurfFeature.h b/ApplicationLibCode/Commands/SurfaceCommands/RicExportSurfaceToTsurfFeature.h index 4c57e74ec5..9bf4a17fd7 100644 --- a/ApplicationLibCode/Commands/SurfaceCommands/RicExportSurfaceToTsurfFeature.h +++ b/ApplicationLibCode/Commands/SurfaceCommands/RicExportSurfaceToTsurfFeature.h @@ -32,7 +32,6 @@ class RicExportSurfaceToTsurfFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/SurfaceCommands/RicImportSurfacesFeature.h b/ApplicationLibCode/Commands/SurfaceCommands/RicImportSurfacesFeature.h index 5dc920b845..b6bb33dd8b 100644 --- a/ApplicationLibCode/Commands/SurfaceCommands/RicImportSurfacesFeature.h +++ b/ApplicationLibCode/Commands/SurfaceCommands/RicImportSurfacesFeature.h @@ -28,7 +28,6 @@ class RicImportSurfacesFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/SurfaceCommands/RicNewGridCaseSurfaceFeature.h b/ApplicationLibCode/Commands/SurfaceCommands/RicNewGridCaseSurfaceFeature.h index a3bb029d0c..e5435fa1cd 100644 --- a/ApplicationLibCode/Commands/SurfaceCommands/RicNewGridCaseSurfaceFeature.h +++ b/ApplicationLibCode/Commands/SurfaceCommands/RicNewGridCaseSurfaceFeature.h @@ -28,7 +28,6 @@ class RicNewGridSurfaceFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/SurfaceCommands/RicNewSurfaceCollectionFeature.h b/ApplicationLibCode/Commands/SurfaceCommands/RicNewSurfaceCollectionFeature.h index 9754df5520..dc5c031481 100644 --- a/ApplicationLibCode/Commands/SurfaceCommands/RicNewSurfaceCollectionFeature.h +++ b/ApplicationLibCode/Commands/SurfaceCommands/RicNewSurfaceCollectionFeature.h @@ -28,7 +28,6 @@ class RicNewSurfaceCollectionFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/SurfaceCommands/RicReloadSurfaceFeature.h b/ApplicationLibCode/Commands/SurfaceCommands/RicReloadSurfaceFeature.h index e468c374e1..5f83d2725b 100644 --- a/ApplicationLibCode/Commands/SurfaceCommands/RicReloadSurfaceFeature.h +++ b/ApplicationLibCode/Commands/SurfaceCommands/RicReloadSurfaceFeature.h @@ -28,7 +28,6 @@ class RicReloadSurfaceFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/ToggleCommands/RicMoveItemsToTopFeature.cpp b/ApplicationLibCode/Commands/ToggleCommands/RicMoveItemsToTopFeature.cpp index 50f73fc464..d9d11e4549 100644 --- a/ApplicationLibCode/Commands/ToggleCommands/RicMoveItemsToTopFeature.cpp +++ b/ApplicationLibCode/Commands/ToggleCommands/RicMoveItemsToTopFeature.cpp @@ -31,6 +31,7 @@ #include "cafSelectionManager.h" #include +#include CAF_CMD_SOURCE_INIT( RicMoveItemsToTopFeature, "RicMoveItemsToTopFeature" ); @@ -113,17 +114,17 @@ void RicMoveItemsToTopFeature::onActionTriggered( bool isChecked ) constSelectedItems.push_back( s ); } - caf::PdmUiTreeView* uiTreeView = RiaGuiApplication::activeMainWindow()->projectTreeView(); - if ( !constSelectedItems.empty() ) { + caf::PdmUiTreeView* uiTreeView = + RiaGuiApplication::activeMainWindow()->getTreeViewWithItem( constSelectedItems[0] ); QModelIndex itemIndex = uiTreeView->findModelIndex( constSelectedItems[0] ); QModelIndex parentIndex = itemIndex.parent(); uiTreeView->updateSubTree( parentIndex ); - } - // Restore selection highlight after reordering - uiTreeView->selectItems( constSelectedItems ); + // Restore selection highlight after reordering + uiTreeView->selectItems( constSelectedItems ); + } } } } diff --git a/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsFeature.h b/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsFeature.h index 95f965cb77..b7afecd793 100644 --- a/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsFeature.h +++ b/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsFeature.h @@ -29,7 +29,6 @@ class RicToggleItemsFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsFeatureImpl.cpp b/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsFeatureImpl.cpp index bf65b0f534..878191d89d 100644 --- a/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsFeatureImpl.cpp +++ b/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsFeatureImpl.cpp @@ -67,10 +67,9 @@ bool RicToggleItemsFeatureImpl::isToggleCommandsAvailable() } else { - for ( size_t i = 0; i < selectedItems.size(); ++i ) + for ( auto& selectedItem : selectedItems ) { - caf::PdmUiObjectHandle* uiObjectHandle = dynamic_cast( selectedItems[i] ); - + auto* uiObjectHandle = dynamic_cast( selectedItem ); if ( uiObjectHandle && uiObjectHandle->objectToggleField() ) { return true; @@ -100,55 +99,26 @@ bool RicToggleItemsFeatureImpl::isToggleCommandsForSubItems() //-------------------------------------------------------------------------------------------------- void RicToggleItemsFeatureImpl::setObjectToggleStateForSelection( SelectionToggleType state ) { - std::vector selectedItems; - caf::SelectionManager::instance()->selectedItems( selectedItems ); - if ( state != TOGGLE && selectedItems.size() == 1 ) - { - // If only one item is selected, loop over its children, and toggle them instead of the - // selected item directly - - // We need to get the children through the tree view, because that is where the actually shown children is + auto fields = findToggleFieldsFromSelection( state ); + if ( fields.empty() ) return; - caf::PdmUiTreeOrdering* treeItem = findTreeItemFromSelectedUiItem( selectedItems[0] ); + auto lastField = fields.back(); + for ( auto field : fields ) + { + bool value = !( field->v() ); - if ( !treeItem ) return; + if ( state == TOGGLE_ON ) + value = true; + else if ( state == TOGGLE_OFF ) + value = false; - for ( int cIdx = 0; cIdx < treeItem->childCount(); ++cIdx ) + if ( field == lastField ) { - caf::PdmUiTreeOrdering* child = treeItem->child( cIdx ); - if ( !child ) continue; - if ( !child->isRepresentingObject() ) continue; - - caf::PdmObjectHandle* childObj = child->object(); - caf::PdmUiObjectHandle* uiObjectHandleChild = uiObj( childObj ); - - if ( uiObjectHandleChild && uiObjectHandleChild->objectToggleField() ) - { - caf::PdmField* field = dynamic_cast*>( uiObjectHandleChild->objectToggleField() ); - - if ( state == TOGGLE_ON ) field->setValueWithFieldChanged( true ); - if ( state == TOGGLE_OFF ) field->setValueWithFieldChanged( false ); - if ( state == TOGGLE_SUBITEMS ) field->setValueWithFieldChanged( !( field->v() ) ); - } + field->setValueWithFieldChanged( value ); } - } - else - { - for ( size_t i = 0; i < selectedItems.size(); ++i ) + else { - caf::PdmUiObjectHandle* uiObjectHandle = dynamic_cast( selectedItems[i] ); - - if ( uiObjectHandle && uiObjectHandle->objectToggleField() ) - { - caf::PdmField* field = dynamic_cast*>( uiObjectHandle->objectToggleField() ); - - if ( state == TOGGLE_ON ) field->setValueWithFieldChanged( true ); - if ( state == TOGGLE_OFF ) field->setValueWithFieldChanged( false ); - if ( state == TOGGLE_SUBITEMS || state == TOGGLE ) - { - field->setValueWithFieldChanged( !( field->v() ) ); - } - } + field->setValue( value ); } } } @@ -158,31 +128,28 @@ void RicToggleItemsFeatureImpl::setObjectToggleStateForSelection( SelectionToggl //-------------------------------------------------------------------------------------------------- caf::PdmUiTreeView* RicToggleItemsFeatureImpl::findTreeView( const caf::PdmUiItem* uiItem ) { - { - RiaFeatureCommandContext* context = RiaFeatureCommandContext::instance(); + RiaFeatureCommandContext* context = RiaFeatureCommandContext::instance(); - caf::PdmUiTreeView* customActiveTreeView = dynamic_cast( context->object() ); - if ( customActiveTreeView ) - { - return customActiveTreeView; - } + auto* customActiveTreeView = dynamic_cast( context->object() ); + if ( customActiveTreeView ) + { + return customActiveTreeView; } + auto* main3dWindow = RiaGuiApplication::instance()->mainWindow(); + if ( main3dWindow ) { - QModelIndex modIndex = RiuMainWindow::instance()->projectTreeView()->findModelIndex( uiItem ); - if ( modIndex.isValid() ) - { - return RiuMainWindow::instance()->projectTreeView(); - } + auto activeTree = main3dWindow->getTreeViewWithItem( uiItem ); + if ( activeTree ) return activeTree; } - RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow(); + auto* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow(); if ( mainPlotWindow ) { - QModelIndex modIndex = mainPlotWindow->projectTreeView()->findModelIndex( uiItem ); - if ( modIndex.isValid() ) + auto activeTree = mainPlotWindow->getTreeViewWithItem( uiItem ); + if ( activeTree ) { - return mainPlotWindow->projectTreeView(); + return activeTree; } } @@ -199,8 +166,66 @@ caf::PdmUiTreeOrdering* RicToggleItemsFeatureImpl::findTreeItemFromSelectedUiIte if ( pdmUiTreeView ) { QModelIndex modIndex = pdmUiTreeView->findModelIndex( uiItem ); - return static_cast( modIndex.internalPointer() ); + return pdmUiTreeView->uiTreeOrderingFromModelIndex( modIndex ); } return nullptr; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector*> RicToggleItemsFeatureImpl::findToggleFieldsFromSelection( SelectionToggleType state ) +{ + std::vector*> fields; + + std::vector selectedItems; + caf::SelectionManager::instance()->selectedItems( selectedItems ); + if ( state != TOGGLE && selectedItems.size() == 1 ) + { + // If only one item is selected, loop over its children, and toggle them instead of the + // selected item directly + + // We need to get the children through the tree view, because that is where the actually shown children is + + caf::PdmUiTreeOrdering* treeItem = findTreeItemFromSelectedUiItem( selectedItems[0] ); + + if ( !treeItem ) return {}; + + for ( int cIdx = 0; cIdx < treeItem->childCount(); ++cIdx ) + { + caf::PdmUiTreeOrdering* child = treeItem->child( cIdx ); + if ( !child ) continue; + if ( !child->isRepresentingObject() ) continue; + + caf::PdmObjectHandle* childObj = child->object(); + caf::PdmUiObjectHandle* uiObjectHandleChild = uiObj( childObj ); + + if ( uiObjectHandleChild && uiObjectHandleChild->objectToggleField() ) + { + auto* field = dynamic_cast*>( uiObjectHandleChild->objectToggleField() ); + if ( !field ) continue; + + if ( state == SelectionToggleType::TOGGLE_ON && field->value() ) continue; + if ( state == SelectionToggleType::TOGGLE_OFF && !field->value() ) continue; + + fields.emplace_back( field ); + } + } + } + else + { + for ( auto& selectedItem : selectedItems ) + { + auto* uiObjectHandle = dynamic_cast( selectedItem ); + if ( uiObjectHandle && uiObjectHandle->objectToggleField() ) + { + auto* field = dynamic_cast*>( uiObjectHandle->objectToggleField() ); + + fields.emplace_back( field ); + } + } + } + + return fields; +} diff --git a/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsFeatureImpl.h b/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsFeatureImpl.h index c1860b8587..1c99af4236 100644 --- a/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsFeatureImpl.h +++ b/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsFeatureImpl.h @@ -19,6 +19,10 @@ #pragma once +#include "cafPdmField.h" + +#include + namespace caf { class PdmUiItem; @@ -46,6 +50,7 @@ class RicToggleItemsFeatureImpl static void setObjectToggleStateForSelection( SelectionToggleType state ); private: - static caf::PdmUiTreeView* findTreeView( const caf::PdmUiItem* uiItem ); - static caf::PdmUiTreeOrdering* findTreeItemFromSelectedUiItem( const caf::PdmUiItem* uiItem ); + static caf::PdmUiTreeView* findTreeView( const caf::PdmUiItem* uiItem ); + static caf::PdmUiTreeOrdering* findTreeItemFromSelectedUiItem( const caf::PdmUiItem* uiItem ); + static std::vector*> findToggleFieldsFromSelection( SelectionToggleType state ); }; diff --git a/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsOffFeature.h b/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsOffFeature.h index 16ddc4c153..2e8ae44f76 100644 --- a/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsOffFeature.h +++ b/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsOffFeature.h @@ -29,7 +29,6 @@ class RicToggleItemsOffFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsOnFeature.h b/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsOnFeature.h index a587b2e804..db0e670343 100644 --- a/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsOnFeature.h +++ b/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsOnFeature.h @@ -29,7 +29,6 @@ class RicToggleItemsOnFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsOnOthersOffFeature.cpp b/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsOnOthersOffFeature.cpp index 6358105023..76d1086480 100644 --- a/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsOnOthersOffFeature.cpp +++ b/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsOnOthersOffFeature.cpp @@ -62,7 +62,9 @@ void RicToggleItemsOnOthersOffFeature::onActionTriggered( bool isChecked ) if ( field ) { - field->setValueWithFieldChanged( false ); + // Avoid calling setValueWithFieldChanged() here, as this potentially can trigger heavy computations. Assume + // that the update logic is sufficient when setting the selected objects. + field->setValue( false ); } } @@ -120,7 +122,7 @@ std::vector RicToggleItemsOnOthersOffFeature::childObject std::vector children; if ( parent ) { - parent->childObjects( &children ); + parent->children( &children ); } return children; } diff --git a/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsOnOthersOffFeature.h b/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsOnOthersOffFeature.h index 12686149ac..540f64e6fd 100644 --- a/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsOnOthersOffFeature.h +++ b/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsOnOthersOffFeature.h @@ -37,7 +37,6 @@ class RicToggleItemsOnOthersOffFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/ViewLink/RicCompareTo3dViewFeature.h b/ApplicationLibCode/Commands/ViewLink/RicCompareTo3dViewFeature.h index d1e70c9797..359a07e4d7 100644 --- a/ApplicationLibCode/Commands/ViewLink/RicCompareTo3dViewFeature.h +++ b/ApplicationLibCode/Commands/ViewLink/RicCompareTo3dViewFeature.h @@ -28,7 +28,6 @@ class RicCompareTo3dViewFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/ViewLink/RicDeleteAllLinkedViewsFeature.cpp b/ApplicationLibCode/Commands/ViewLink/RicDeleteAllLinkedViewsFeature.cpp index 4bddb6d8aa..fc60d154ce 100644 --- a/ApplicationLibCode/Commands/ViewLink/RicDeleteAllLinkedViewsFeature.cpp +++ b/ApplicationLibCode/Commands/ViewLink/RicDeleteAllLinkedViewsFeature.cpp @@ -42,7 +42,7 @@ class DeleteAllLinkedViewsImpl { // Remove the view linker object from the view linker collection // viewLinkerCollection->viewLinker is a PdmChildField containing one RimViewLinker child object - proj->viewLinkerCollection->viewLinker.removeChildObject( viewLinker ); + proj->viewLinkerCollection->viewLinker.removeChild( viewLinker ); viewLinker->applyCellFilterCollectionByUserChoice(); diff --git a/ApplicationLibCode/Commands/ViewLink/RicDeleteAllLinkedViewsFeature.h b/ApplicationLibCode/Commands/ViewLink/RicDeleteAllLinkedViewsFeature.h index 98aca6c909..214a1b46ab 100644 --- a/ApplicationLibCode/Commands/ViewLink/RicDeleteAllLinkedViewsFeature.h +++ b/ApplicationLibCode/Commands/ViewLink/RicDeleteAllLinkedViewsFeature.h @@ -31,7 +31,6 @@ class RicDeleteAllLinkedViewsFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/ViewLink/RicLinkViewFeature.h b/ApplicationLibCode/Commands/ViewLink/RicLinkViewFeature.h index a56def66ad..a9314815a2 100644 --- a/ApplicationLibCode/Commands/ViewLink/RicLinkViewFeature.h +++ b/ApplicationLibCode/Commands/ViewLink/RicLinkViewFeature.h @@ -31,7 +31,6 @@ class RicLinkViewFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/ViewLink/RicLinkVisibleViewsFeature.cpp b/ApplicationLibCode/Commands/ViewLink/RicLinkVisibleViewsFeature.cpp index 47a7e10c41..30d2d2e50a 100644 --- a/ApplicationLibCode/Commands/ViewLink/RicLinkVisibleViewsFeature.cpp +++ b/ApplicationLibCode/Commands/ViewLink/RicLinkVisibleViewsFeature.cpp @@ -164,7 +164,7 @@ void RicLinkVisibleViewsFeature::linkViews( std::vector& linkableV viewLinker->updateUiNameAndIcon(); proj->viewLinkerCollection.uiCapability()->updateConnectedEditors(); - proj->updateConnectedEditors(); + proj->viewLinkerCollection->updateConnectedEditors(); Riu3DMainWindowTools::setExpanded( proj->viewLinkerCollection() ); } diff --git a/ApplicationLibCode/Commands/ViewLink/RicLinkVisibleViewsFeature.h b/ApplicationLibCode/Commands/ViewLink/RicLinkVisibleViewsFeature.h index 5f94c6c7f9..32e29d854d 100644 --- a/ApplicationLibCode/Commands/ViewLink/RicLinkVisibleViewsFeature.h +++ b/ApplicationLibCode/Commands/ViewLink/RicLinkVisibleViewsFeature.h @@ -36,7 +36,6 @@ class RicLinkVisibleViewsFeature : public caf::CmdFeature static void linkViews( std::vector& views ); protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; diff --git a/ApplicationLibCode/Commands/ViewLink/RicLinkVisibleViewsFeatureUi.cpp b/ApplicationLibCode/Commands/ViewLink/RicLinkVisibleViewsFeatureUi.cpp index bc920a771c..d95b6fd42f 100644 --- a/ApplicationLibCode/Commands/ViewLink/RicLinkVisibleViewsFeatureUi.cpp +++ b/ApplicationLibCode/Commands/ViewLink/RicLinkVisibleViewsFeatureUi.cpp @@ -34,9 +34,9 @@ CAF_PDM_SOURCE_INIT( RicLinkVisibleViewsFeatureUi, "RicLinkVisibleViewsFeatureUi //-------------------------------------------------------------------------------------------------- RicLinkVisibleViewsFeatureUi::RicLinkVisibleViewsFeatureUi( void ) { - CAF_PDM_InitObject( "Link Visible Views Feature UI", ":/LinkView16x16.png", "", "" ); + CAF_PDM_InitObject( "Link Visible Views Feature UI", ":/LinkView.svg" ); - CAF_PDM_InitFieldNoDefault( &m_masterView, "MasterView", "Primary View", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_masterView, "MasterView", "Primary View" ); } //-------------------------------------------------------------------------------------------------- @@ -96,8 +96,7 @@ std::vector RicLinkVisibleViewsFeatureUi::masterViewCandidates() c /// //-------------------------------------------------------------------------------------------------- QList - RicLinkVisibleViewsFeatureUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) + RicLinkVisibleViewsFeatureUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; diff --git a/ApplicationLibCode/Commands/ViewLink/RicLinkVisibleViewsFeatureUi.h b/ApplicationLibCode/Commands/ViewLink/RicLinkVisibleViewsFeatureUi.h index 3fd24df8c3..ab65235bf3 100644 --- a/ApplicationLibCode/Commands/ViewLink/RicLinkVisibleViewsFeatureUi.h +++ b/ApplicationLibCode/Commands/ViewLink/RicLinkVisibleViewsFeatureUi.h @@ -42,8 +42,7 @@ class RicLinkVisibleViewsFeatureUi : public caf::PdmObject std::vector masterViewCandidates() const; protected: - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; private: caf::PdmPtrField m_masterView; diff --git a/ApplicationLibCode/Commands/ViewLink/RicRemoveComparison3dViewFeature.h b/ApplicationLibCode/Commands/ViewLink/RicRemoveComparison3dViewFeature.h index d5ce10a280..a7949503cb 100644 --- a/ApplicationLibCode/Commands/ViewLink/RicRemoveComparison3dViewFeature.h +++ b/ApplicationLibCode/Commands/ViewLink/RicRemoveComparison3dViewFeature.h @@ -28,7 +28,6 @@ class RicRemoveComparison3dViewFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/ViewLink/RicSetMasterViewFeature.cpp b/ApplicationLibCode/Commands/ViewLink/RicSetMasterViewFeature.cpp index 334fee2569..46370e18c2 100644 --- a/ApplicationLibCode/Commands/ViewLink/RicSetMasterViewFeature.cpp +++ b/ApplicationLibCode/Commands/ViewLink/RicSetMasterViewFeature.cpp @@ -75,7 +75,7 @@ void RicSetMasterViewFeature::onActionTriggered( bool isChecked ) viewLinker->addDependentView( previousMasterView ); proj->viewLinkerCollection.uiCapability()->updateConnectedEditors(); - proj->updateConnectedEditors(); + proj->viewLinkerCollection->updateConnectedEditors(); // Set managed view collection to selected and expanded in project tree Riu3DMainWindowTools::selectAsCurrentItem( viewLinker ); diff --git a/ApplicationLibCode/Commands/ViewLink/RicSetMasterViewFeature.h b/ApplicationLibCode/Commands/ViewLink/RicSetMasterViewFeature.h index 46b686441d..ad76867de2 100644 --- a/ApplicationLibCode/Commands/ViewLink/RicSetMasterViewFeature.h +++ b/ApplicationLibCode/Commands/ViewLink/RicSetMasterViewFeature.h @@ -31,7 +31,6 @@ class RicSetMasterViewFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/ViewLink/RicShowAllLinkedViewsFeature.h b/ApplicationLibCode/Commands/ViewLink/RicShowAllLinkedViewsFeature.h index 818dde4964..f8bacae4f3 100644 --- a/ApplicationLibCode/Commands/ViewLink/RicShowAllLinkedViewsFeature.h +++ b/ApplicationLibCode/Commands/ViewLink/RicShowAllLinkedViewsFeature.h @@ -31,7 +31,6 @@ class RicShowAllLinkedViewsFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/ViewLink/RicShowLinkOptionsFeature.h b/ApplicationLibCode/Commands/ViewLink/RicShowLinkOptionsFeature.h index 9c08520249..5cc341827c 100644 --- a/ApplicationLibCode/Commands/ViewLink/RicShowLinkOptionsFeature.h +++ b/ApplicationLibCode/Commands/ViewLink/RicShowLinkOptionsFeature.h @@ -31,7 +31,6 @@ class RicShowLinkOptionsFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/ViewLink/RicUnLinkViewFeature.cpp b/ApplicationLibCode/Commands/ViewLink/RicUnLinkViewFeature.cpp index 710c8f11fd..b399451539 100644 --- a/ApplicationLibCode/Commands/ViewLink/RicUnLinkViewFeature.cpp +++ b/ApplicationLibCode/Commands/ViewLink/RicUnLinkViewFeature.cpp @@ -87,7 +87,7 @@ void RicUnLinkViewFeature::onActionTriggered( bool isChecked ) { // Remove the view linker object from the view linker collection // viewLinkerCollection->viewLinker is a PdmChildField containing one RimViewLinker child object - RimProject::current()->viewLinkerCollection->viewLinker.removeChildObject( viewLinker ); + RimProject::current()->viewLinkerCollection->viewLinker.removeChild( viewLinker ); delete viewLinker; } diff --git a/ApplicationLibCode/Commands/ViewLink/RicUnLinkViewFeature.h b/ApplicationLibCode/Commands/ViewLink/RicUnLinkViewFeature.h index 9a957871c1..7fdaab7a50 100644 --- a/ApplicationLibCode/Commands/ViewLink/RicUnLinkViewFeature.h +++ b/ApplicationLibCode/Commands/ViewLink/RicUnLinkViewFeature.h @@ -31,7 +31,6 @@ class RicUnLinkViewFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/WellLogCommands/Ric3dWellLogCurveDeleteFeature.h b/ApplicationLibCode/Commands/WellLogCommands/Ric3dWellLogCurveDeleteFeature.h index 1a83bda32c..c9b4f19c15 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/Ric3dWellLogCurveDeleteFeature.h +++ b/ApplicationLibCode/Commands/WellLogCommands/Ric3dWellLogCurveDeleteFeature.h @@ -29,7 +29,6 @@ class Ric3dWellLogCurveDeleteFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicAdd3dWellLogCurveFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicAdd3dWellLogCurveFeature.cpp index 6e6f6327a4..3cbd78644c 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicAdd3dWellLogCurveFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicAdd3dWellLogCurveFeature.cpp @@ -68,8 +68,6 @@ void RicAdd3dWellLogCurveFeature::onActionTriggered( bool isChecked ) RimProject::current()->scheduleCreateDisplayModelAndRedrawAllViews(); - RimProject::current()->updateConnectedEditors(); - Riu3DMainWindowTools::selectAsCurrentItem( rim3dWellLogExtractionCurve ); Riu3DMainWindowTools::setExpanded( selectedWellPath ); diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicAdd3dWellLogFileCurveFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicAdd3dWellLogFileCurveFeature.cpp index 14151cc6e4..534a474039 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicAdd3dWellLogFileCurveFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicAdd3dWellLogFileCurveFeature.cpp @@ -56,7 +56,6 @@ void RicAdd3dWellLogFileCurveFeature::onActionTriggered( bool isChecked ) rim3dWellLogFileCurve->setDefaultFileCurveDataInfo(); RimProject::current()->scheduleCreateDisplayModelAndRedrawAllViews(); - RimProject::current()->updateConnectedEditors(); Riu3DMainWindowTools::selectAsCurrentItem( rim3dWellLogFileCurve ); Riu3DMainWindowTools::setExpanded( selectedWellPath ); diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicAdd3dWellLogRftCurveFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicAdd3dWellLogRftCurveFeature.cpp index dea217328d..8ccabcd309 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicAdd3dWellLogRftCurveFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicAdd3dWellLogRftCurveFeature.cpp @@ -63,7 +63,6 @@ void RicAdd3dWellLogRftCurveFeature::onActionTriggered( bool isChecked ) selectedWellPath->add3dWellLogCurve( rim3dWellLogRftCurve ); RimProject::current()->scheduleCreateDisplayModelAndRedrawAllViews(); - RimProject::current()->updateConnectedEditors(); Riu3DMainWindowTools::selectAsCurrentItem( rim3dWellLogRftCurve ); Riu3DMainWindowTools::setExpanded( selectedWellPath ); diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp index bf41e15b3a..eab9e8c98e 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp @@ -104,8 +104,6 @@ void RicAddWellLogToPlotFeature::onActionTriggered( bool isChecked ) } plot->updateLayout(); - RimProject::current()->updateConnectedEditors(); - RiuPlotMainWindowTools::showPlotMainWindow(); RiuPlotMainWindowTools::selectAsCurrentItem( plot ); RiuPlotMainWindowTools::setExpanded( plotTrack ); diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.h b/ApplicationLibCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.h index 23868d205a..388272cdc4 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.h +++ b/ApplicationLibCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.h @@ -36,7 +36,6 @@ class RicAddWellLogToPlotFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicChangeDataSourceFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicChangeDataSourceFeature.cpp index 789a246023..439c57409d 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicChangeDataSourceFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicChangeDataSourceFeature.cpp @@ -66,14 +66,14 @@ void RicChangeDataSourceFeature::onActionTriggered( bool isChecked ) if ( selectedTracksAndCurves( &curves, &tracks ) ) { RimWellLogCurveCommonDataSource featureUi; - featureUi.updateDefaultOptions( curves, tracks ); + featureUi.analyseCurvesAndTracks( curves, tracks ); caf::PdmUiPropertyViewDialog propertyDialog( nullptr, &featureUi, "Change Data Source for Multiple Curves", "" ); propertyDialog.resize( QSize( 500, 200 ) ); if ( propertyDialog.exec() == QDialog::Accepted ) { - featureUi.updateCurvesAndTracks( curves, tracks ); + featureUi.applyDataSourceChanges( curves, tracks ); } } } diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicDeleteSubPlotFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicDeleteSubPlotFeature.cpp index 46e328c56c..571c5c92c5 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicDeleteSubPlotFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicDeleteSubPlotFeature.cpp @@ -26,6 +26,7 @@ #include "RiuQwtPlotWidget.h" #include "RimMultiPlot.h" +#include "RimPlot.h" #include "RimPlotWindow.h" #include "RimWellLogPlot.h" #include "RimWellLogTrack.h" @@ -48,6 +49,8 @@ bool RicDeleteSubPlotFeature::isCommandEnabled() if ( selection.size() > 0 ) { + if ( dynamic_cast( selection.front() ) ) return false; + size_t plotsSelected = 0; for ( caf::PdmObject* object : selection ) { @@ -74,8 +77,15 @@ void RicDeleteSubPlotFeature::onActionTriggered( bool isChecked ) if ( RicWellLogPlotCurveFeatureImpl::parentWellAllocationPlot() ) return; std::vector selection; - caf::SelectionManager::instance()->objectsByType( &selection ); - std::set alteredPlotWindows; + getSelection( selection ); + + std::set alteredPlotWindows; + + for ( RimPlot* plot : selection ) + { + if ( !plot ) continue; + caf::SelectionManager::instance()->removeObjectFromAllSelections( plot ); + } for ( RimPlot* plot : selection ) { @@ -88,22 +98,22 @@ void RicDeleteSubPlotFeature::onActionTriggered( bool isChecked ) if ( multiPlot ) { alteredPlotWindows.insert( multiPlot ); - multiPlot->removePlot( plot ); - caf::SelectionManager::instance()->removeObjectFromAllSelections( plot ); - + multiPlot->removePlotNoUpdate( plot ); multiPlot->updateConnectedEditors(); delete plot; } else if ( wellLogPlot ) { - alteredPlotWindows.insert( wellLogPlot ); wellLogPlot->removePlot( plot ); - caf::SelectionManager::instance()->removeObjectFromAllSelections( plot ); - wellLogPlot->updateConnectedEditors(); delete plot; } } + + for ( auto mainplot : alteredPlotWindows ) + { + mainplot->updateAfterPlotRemove(); + } } //-------------------------------------------------------------------------------------------------- @@ -111,12 +121,12 @@ void RicDeleteSubPlotFeature::onActionTriggered( bool isChecked ) //-------------------------------------------------------------------------------------------------- void RicDeleteSubPlotFeature::setupActionLook( QAction* actionToSetup ) { - QString actionText; - std::vector selection; - caf::SelectionManager::instance()->objectsByType( &selection ); + QString actionText; + std::vector selection; + getSelection( selection ); size_t tracksSelected = 0u; - for ( caf::PdmObject* object : selection ) + for ( RimPlot* object : selection ) { if ( dynamic_cast( object ) ) { @@ -140,3 +150,24 @@ void RicDeleteSubPlotFeature::setupActionLook( QAction* actionToSetup ) actionToSetup->setIcon( QIcon( ":/Erase.svg" ) ); applyShortcutWithHintToAction( actionToSetup, QKeySequence::Delete ); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicDeleteSubPlotFeature::getSelection( std::vector& selection ) +{ + if ( sender() ) + { + QVariant userData = this->userData(); + if ( !userData.isNull() && userData.canConvert() ) + { + RimPlot* plot = static_cast( userData.value() ); + if ( plot ) selection.push_back( plot ); + } + } + + if ( selection.empty() ) + { + caf::SelectionManager::instance()->objectsByType( &selection ); + } +} diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicDeleteSubPlotFeature.h b/ApplicationLibCode/Commands/WellLogCommands/RicDeleteSubPlotFeature.h index f6b1daacf7..67f050d60d 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicDeleteSubPlotFeature.h +++ b/ApplicationLibCode/Commands/WellLogCommands/RicDeleteSubPlotFeature.h @@ -21,6 +21,10 @@ #include "cafCmdFeature.h" +class RimPlot; + +#include + //================================================================================================== /// //================================================================================================== @@ -29,8 +33,10 @@ class RicDeleteSubPlotFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; + +private: + void getSelection( std::vector& selection ); }; diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicMoveWellLogFilesFeature.h b/ApplicationLibCode/Commands/WellLogCommands/RicMoveWellLogFilesFeature.h index ac61ef4009..af741473e5 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicMoveWellLogFilesFeature.h +++ b/ApplicationLibCode/Commands/WellLogCommands/RicMoveWellLogFilesFeature.h @@ -29,7 +29,6 @@ class RicMoveWellLogFilesFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicNewPltPlotFeature.h b/ApplicationLibCode/Commands/WellLogCommands/RicNewPltPlotFeature.h index 5ca91dafd5..9220b09d76 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicNewPltPlotFeature.h +++ b/ApplicationLibCode/Commands/WellLogCommands/RicNewPltPlotFeature.h @@ -37,7 +37,6 @@ class RicNewPltPlotFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp index 8dfc783b5b..0fa87faedf 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp @@ -114,7 +114,7 @@ RimWellBoreStabilityPlot* plot->setLegendsVisible( true ); plot->setLegendsHorizontal( true ); plot->setDepthType( RiaDefines::DepthTypeEnum::TRUE_VERTICAL_DEPTH_RKB ); - plot->setAutoScaleDepthEnabled( true ); + plot->setAutoScaleDepthValuesEnabled( true ); RicNewWellLogPlotFeatureImpl::updateAfterCreation( plot ); } @@ -220,7 +220,7 @@ void RicNewWellBoreStabilityPlotFeature::createFormationTrack( RimWellBoreStabil formationTrack->setFormationWellPath( wellPath ); formationTrack->setFormationCase( geoMechCase ); formationTrack->setAnnotationType( RiuPlotAnnotationTool::RegionAnnotationType::FORMATION_ANNOTATIONS ); - formationTrack->setVisibleXRange( 0.0, 0.0 ); + formationTrack->setVisiblePropertyValueRange( 0.0, 0.0 ); formationTrack->setColSpan( RimPlot::ONE ); } @@ -242,8 +242,8 @@ void RicNewWellBoreStabilityPlotFeature::createCasingShoeTrack( RimWellBoreStabi casingShoeTrack->setShowBothSidesOfWell( false ); casingShoeTrack->setAnnotationTransparency( 90 ); casingShoeTrack->setWellPathAttributesSource( wellPath ); - casingShoeTrack->setVisibleXRange( 0.0, 0.0 ); - casingShoeTrack->setAutoScaleXEnabled( true ); + casingShoeTrack->setVisiblePropertyValueRange( 0.0, 0.0 ); + casingShoeTrack->setAutoScalePropertyValuesEnabled( true ); casingShoeTrack->loadDataAndUpdate(); } @@ -258,10 +258,10 @@ void RicNewWellBoreStabilityPlotFeature::createParametersTrack( RimWellBoreStabi RimWellLogTrack* paramCurvesTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack( false, "WBS Parameters", plot ); paramCurvesTrack->setColSpan( RimPlot::TWO ); - paramCurvesTrack->setVisibleXRange( 0.0, 2.0 ); - paramCurvesTrack->setAutoScaleXEnabled( true ); + paramCurvesTrack->setVisiblePropertyValueRange( 0.0, 2.0 ); + paramCurvesTrack->setAutoScalePropertyValuesEnabled( true ); paramCurvesTrack->setTickIntervals( 1.0, 0.2 ); - paramCurvesTrack->setXAxisGridVisibility( RimWellLogPlot::AXIS_GRID_MAJOR_AND_MINOR ); + paramCurvesTrack->setPropertyValueAxisGridVisibility( RimWellLogPlot::AXIS_GRID_MAJOR_AND_MINOR ); paramCurvesTrack->setFormationWellPath( wellPath ); paramCurvesTrack->setFormationCase( geoMechCase ); paramCurvesTrack->setShowRegionLabels( true ); @@ -290,7 +290,7 @@ void RicNewWellBoreStabilityPlotFeature::createParametersTrack( RimWellBoreStabi curve->setCustomName( param.name() ); i++; } - paramCurvesTrack->setAutoScaleXEnabled( true ); + paramCurvesTrack->setAutoScalePropertyValuesEnabled( true ); } //-------------------------------------------------------------------------------------------------- @@ -305,11 +305,11 @@ void RicNewWellBoreStabilityPlotFeature::createStabilityCurvesTrack( RimWellBore "Stability Curves", plot ); - stabilityCurvesTrack->setVisibleXRange( 0.0, 2.5 ); + stabilityCurvesTrack->setVisiblePropertyValueRange( 0.0, 2.5 ); stabilityCurvesTrack->setColSpan( RimPlot::THREE ); - stabilityCurvesTrack->setAutoScaleXEnabled( true ); + stabilityCurvesTrack->setAutoScalePropertyValuesEnabled( true ); stabilityCurvesTrack->setTickIntervals( 1.0, 0.2 ); - stabilityCurvesTrack->setXAxisGridVisibility( RimWellLogPlot::AXIS_GRID_MAJOR_AND_MINOR ); + stabilityCurvesTrack->setPropertyValueAxisGridVisibility( RimWellLogPlot::AXIS_GRID_MAJOR_AND_MINOR ); stabilityCurvesTrack->setFormationWellPath( wellPath ); stabilityCurvesTrack->setFormationCase( geoMechCase ); stabilityCurvesTrack->setAnnotationType( RiuPlotAnnotationTool::RegionAnnotationType::FORMATION_ANNOTATIONS ); @@ -368,7 +368,7 @@ void RicNewWellBoreStabilityPlotFeature::createStabilityCurvesTrack( RimWellBore } } - stabilityCurvesTrack->setAutoScaleXEnabled( true ); + stabilityCurvesTrack->setAutoScalePropertyValuesEnabled( true ); } //-------------------------------------------------------------------------------------------------- @@ -413,7 +413,7 @@ void RicNewWellBoreStabilityPlotFeature::createAnglesTrack( RimWellBoreStability curve->loadDataAndUpdate( false ); double actualMinValue = minValue, actualMaxValue = maxValue; - curve->xValueRangeInQwt( &actualMinValue, &actualMaxValue ); + curve->xValueRange( &actualMinValue, &actualMaxValue ); while ( maxValue < actualMaxValue ) { maxValue += angleIncrement; @@ -426,9 +426,9 @@ void RicNewWellBoreStabilityPlotFeature::createAnglesTrack( RimWellBoreStability minValue = cvf::Math::clamp( minValue, 0.0, maxValue - 90.0 ); } wellPathAnglesTrack->setColSpan( RimPlot::TWO ); - wellPathAnglesTrack->setVisibleXRange( minValue, maxValue ); + wellPathAnglesTrack->setVisiblePropertyValueRange( minValue, maxValue ); wellPathAnglesTrack->setTickIntervals( 180.0, 45.0 ); - wellPathAnglesTrack->setXAxisGridVisibility( RimWellLogPlot::AXIS_GRID_MAJOR_AND_MINOR ); + wellPathAnglesTrack->setPropertyValueAxisGridVisibility( RimWellLogPlot::AXIS_GRID_MAJOR_AND_MINOR ); wellPathAnglesTrack->setFormationWellPath( wellPath ); wellPathAnglesTrack->setFormationCase( geoMechCase ); wellPathAnglesTrack->setAnnotationType( RiuPlotAnnotationTool::RegionAnnotationType::FORMATION_ANNOTATIONS ); diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.h b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.h index e0242ecd11..58a92ca926 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.h +++ b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.h @@ -40,7 +40,6 @@ class RicNewWellBoreStabilityPlotFeature : public caf::CmdFeature const RimWbsParameters* parameters = nullptr ); protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogPlotFeature.h b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogPlotFeature.h index a4e07ebcb2..ae20b68218 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogPlotFeature.h +++ b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogPlotFeature.h @@ -29,7 +29,6 @@ class RicNewWellLogPlotFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogPlotFeatureImpl.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogPlotFeatureImpl.cpp index c67ee0fd10..30f90889ae 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogPlotFeatureImpl.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogPlotFeatureImpl.cpp @@ -106,6 +106,8 @@ RimWellLogPlot* RicNewWellLogPlotFeatureImpl::createWellLogPlot( bool showAfterC QString( "Well Log Plot %1" ).arg( wellLogPlotCollection()->wellLogPlots().size() ) ); } + wellLogPlotColl->updateConnectedEditors(); + if ( showAfterCreation ) { RiaGuiApplication::instance()->getOrCreateAndShowMainPlotWindow(); diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogPlotTrackFeature.h b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogPlotTrackFeature.h index ac93027c1e..8ae342e129 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogPlotTrackFeature.h +++ b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogPlotTrackFeature.h @@ -31,7 +31,6 @@ class RicNewWellLogPlotTrackFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicPasteWellLogCurveFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicPasteWellLogCurveFeature.cpp index 13885dc809..7cebe4fbcf 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicPasteWellLogCurveFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicPasteWellLogCurveFeature.cpp @@ -25,6 +25,7 @@ #include "RimWellLogCurve.h" #include "RimWellLogExtractionCurve.h" #include "RimWellLogFileCurve.h" +#include "RimWellLogRftCurve.h" #include "RimWellLogTrack.h" #include "RimWellMeasurementCurve.h" @@ -46,8 +47,7 @@ bool RicPasteWellLogCurveFeature::isCommandEnabled() if ( RicWellLogPlotCurveFeatureImpl::parentWellAllocationPlot() ) return false; if ( RicWellLogPlotCurveFeatureImpl::parentWellRftPlot() ) return false; - caf::PdmObjectHandle* destinationObject = - dynamic_cast( caf::SelectionManager::instance()->selectedItem() ); + auto* destinationObject = dynamic_cast( caf::SelectionManager::instance()->selectedItem() ); if ( !destinationObject ) return false; RimWellLogTrack* wellLogTrack = nullptr; @@ -62,16 +62,16 @@ bool RicPasteWellLogCurveFeature::isCommandEnabled() std::vector> sourceObjects = RicPasteWellLogCurveFeature::curves(); - for ( size_t i = 0; i < sourceObjects.size(); i++ ) + for ( const auto& sourceObject : sourceObjects ) { RimWellBoreStabilityPlot* originalWbsPlot = nullptr; - sourceObjects[i]->firstAncestorOrThisOfType( originalWbsPlot ); + sourceObject->firstAncestorOrThisOfType( originalWbsPlot ); if ( originalWbsPlot && originalWbsPlot != wbsPlotToPasteInto ) { return false; } } - return RicPasteWellLogCurveFeature::curves().size() > 0; + return !RicPasteWellLogCurveFeature::curves().empty(); } //-------------------------------------------------------------------------------------------------- @@ -81,8 +81,7 @@ void RicPasteWellLogCurveFeature::onActionTriggered( bool isChecked ) { if ( RicWellLogPlotCurveFeatureImpl::parentWellAllocationPlot() ) return; - caf::PdmObjectHandle* destinationObject = - dynamic_cast( caf::SelectionManager::instance()->selectedItem() ); + auto* destinationObject = dynamic_cast( caf::SelectionManager::instance()->selectedItem() ); if ( !destinationObject ) return; RimWellLogTrack* wellLogTrack = nullptr; @@ -97,39 +96,23 @@ void RicPasteWellLogCurveFeature::onActionTriggered( bool isChecked ) std::vector> sourceObjects = RicPasteWellLogCurveFeature::curves(); - for ( size_t i = 0; i < sourceObjects.size(); i++ ) + for ( const auto& sourceObject : sourceObjects ) { RimWellBoreStabilityPlot* originalWbsPlot = nullptr; - sourceObjects[i]->firstAncestorOrThisOfType( originalWbsPlot ); + sourceObject->firstAncestorOrThisOfType( originalWbsPlot ); if ( originalWbsPlot && originalWbsPlot != wbsPlotToPasteInto ) { continue; } - RimWellLogFileCurve* fileCurve = dynamic_cast( sourceObjects[i].p() ); - RimWellMeasurementCurve* measurementCurve = dynamic_cast( sourceObjects[i].p() ); - if ( fileCurve || measurementCurve ) + auto* fileCurve = dynamic_cast( sourceObject.p() ); + auto* measurementCurve = dynamic_cast( sourceObject.p() ); + auto* extractionCurve = dynamic_cast( sourceObject.p() ); + auto* rftCurve = dynamic_cast( sourceObject.p() ); + if ( fileCurve || measurementCurve || extractionCurve || rftCurve ) { - RimWellLogFileCurve* newObject = dynamic_cast( - sourceObjects[i]->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); - CVF_ASSERT( newObject ); - - wellLogTrack->addCurve( newObject ); - - // Resolve references after object has been inserted into the project data model - newObject->resolveReferencesRecursively(); - newObject->initAfterReadRecursively(); - - newObject->loadDataAndUpdate( true ); - - wellLogTrack->updateConnectedEditors(); - } - - RimWellLogExtractionCurve* extractionCurve = dynamic_cast( sourceObjects[i].p() ); - if ( extractionCurve ) - { - RimWellLogExtractionCurve* newObject = dynamic_cast( - sourceObjects[i]->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); + auto* newObject = dynamic_cast( + sourceObject->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); CVF_ASSERT( newObject ); wellLogTrack->addCurve( newObject ); diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicPasteWellLogCurveFeature.h b/ApplicationLibCode/Commands/WellLogCommands/RicPasteWellLogCurveFeature.h index d6358e8bef..464d0a4589 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicPasteWellLogCurveFeature.h +++ b/ApplicationLibCode/Commands/WellLogCommands/RicPasteWellLogCurveFeature.h @@ -33,7 +33,6 @@ class RicPasteWellLogCurveFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicPasteWellLogPlotFeature.h b/ApplicationLibCode/Commands/WellLogCommands/RicPasteWellLogPlotFeature.h index 6fb8464941..3e486c56d5 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicPasteWellLogPlotFeature.h +++ b/ApplicationLibCode/Commands/WellLogCommands/RicPasteWellLogPlotFeature.h @@ -33,7 +33,6 @@ class RicPasteWellLogPlotFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicPasteWellLogTrackFeature.h b/ApplicationLibCode/Commands/WellLogCommands/RicPasteWellLogTrackFeature.h index 404be8d850..893215c540 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicPasteWellLogTrackFeature.h +++ b/ApplicationLibCode/Commands/WellLogCommands/RicPasteWellLogTrackFeature.h @@ -33,7 +33,6 @@ class RicPasteWellLogTrackFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicWellLogFileCloseFeature.h b/ApplicationLibCode/Commands/WellLogCommands/RicWellLogFileCloseFeature.h index be951ec239..eea2effd59 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicWellLogFileCloseFeature.h +++ b/ApplicationLibCode/Commands/WellLogCommands/RicWellLogFileCloseFeature.h @@ -33,7 +33,6 @@ class RicWellLogFileCloseFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicWellLogPlotTrackFeatureImpl.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicWellLogPlotTrackFeatureImpl.cpp index c940cdaa7e..a09e17fb77 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicWellLogPlotTrackFeatureImpl.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicWellLogPlotTrackFeatureImpl.cpp @@ -73,7 +73,7 @@ void RicWellLogPlotTrackFeatureImpl::moveCurvesToWellLogPlotTrack( RimWellLogTra for ( auto track : srcTracks ) { - track->setAutoScaleXEnabled( true ); + track->setAutoScalePropertyValuesEnabled( true ); track->updateParentPlotZoom(); track->updateStackedCurveData(); track->updateConnectedEditors(); @@ -86,7 +86,7 @@ void RicWellLogPlotTrackFeatureImpl::moveCurvesToWellLogPlotTrack( RimWellLogTra destTrack->loadDataAndUpdate(); destTrack->updateStackedCurveData(); - destTrack->setAutoScaleXEnabled( true ); + destTrack->setAutoScalePropertyValuesEnabled( true ); destTrack->updateParentPlotZoom(); destTrack->updateConnectedEditors(); } diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicWellLogsImportFileFeature.h b/ApplicationLibCode/Commands/WellLogCommands/RicWellLogsImportFileFeature.h index b1a09252f1..175012465b 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicWellLogsImportFileFeature.h +++ b/ApplicationLibCode/Commands/WellLogCommands/RicWellLogsImportFileFeature.h @@ -36,7 +36,6 @@ class RicWellLogsImportFileFeature : public caf::CmdFeature static QStringList wellLogFileNameFilters(); protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicAppendPointsToPolygonFilterFeature.cpp b/ApplicationLibCode/Commands/WellPathCommands/RicAppendPointsToPolygonFilterFeature.cpp index 2b986fd7f5..bcd6d48837 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicAppendPointsToPolygonFilterFeature.cpp +++ b/ApplicationLibCode/Commands/WellPathCommands/RicAppendPointsToPolygonFilterFeature.cpp @@ -18,7 +18,7 @@ #include "RicAppendPointsToPolygonFilterFeature.h" -CAF_CMD_SOURCE_INIT( RicAppendPointsToPolygonFilterFeature, "RicAppendPointsToPolygonFilterFeature" ); +#include "RiaTextStringTools.h" #include "RimPolygonFilter.h" #include "RimPolylineTarget.h" @@ -30,6 +30,8 @@ CAF_CMD_SOURCE_INIT( RicAppendPointsToPolygonFilterFeature, "RicAppendPointsToPo #include #include +CAF_CMD_SOURCE_INIT( RicAppendPointsToPolygonFilterFeature, "RicAppendPointsToPolygonFilterFeature" ); + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -62,7 +64,7 @@ void RicAppendPointsToPolygonFilterFeature::onActionTriggered( bool isChecked ) if ( clipboard ) { QString content = clipboard->text(); - listOfThreeDoubles = content.split( "\n", QString::SkipEmptyParts ); + listOfThreeDoubles = RiaTextStringTools::splitSkipEmptyParts( content, "\n" ); } std::vector points; diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicCreateMultipleWellPathLateralsUi.cpp b/ApplicationLibCode/Commands/WellPathCommands/RicCreateMultipleWellPathLateralsUi.cpp index 3e216b7d0b..3bf37dc222 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicCreateMultipleWellPathLateralsUi.cpp +++ b/ApplicationLibCode/Commands/WellPathCommands/RicCreateMultipleWellPathLateralsUi.cpp @@ -45,12 +45,12 @@ CAF_PDM_SOURCE_INIT( RicCreateMultipleWellPathLateralsUi, "RicCreateMultipleWell //-------------------------------------------------------------------------------------------------- RicCreateMultipleWellPathLateralsUi::RicCreateMultipleWellPathLateralsUi() { - CAF_PDM_InitFieldNoDefault( &m_sourceLateral, "SourceLaterals", "Source Well Path Lateral", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_sourceLateral, "SourceLaterals", "Source Well Path Lateral" ); - CAF_PDM_InitFieldNoDefault( &m_topLevelWellPath, "TopLevelWellPath", "Top Level Well Path", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_topLevelWellPath, "TopLevelWellPath", "Top Level Well Path" ); m_topLevelWellPath.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_locations, "Locations", "Locations", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_locations, "Locations", "Locations" ); m_locations = new RimMultipleLocations; } @@ -108,8 +108,7 @@ void RicCreateMultipleWellPathLateralsUi::defineUiOrdering( QString uiConfigName /// //-------------------------------------------------------------------------------------------------- QList - RicCreateMultipleWellPathLateralsUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) + RicCreateMultipleWellPathLateralsUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicCreateMultipleWellPathLateralsUi.h b/ApplicationLibCode/Commands/WellPathCommands/RicCreateMultipleWellPathLateralsUi.h index 9378a756ca..d10eaf2b65 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicCreateMultipleWellPathLateralsUi.h +++ b/ApplicationLibCode/Commands/WellPathCommands/RicCreateMultipleWellPathLateralsUi.h @@ -56,8 +56,7 @@ class RicCreateMultipleWellPathLateralsUi : public caf::PdmObject private: void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; private: caf::PdmPtrField m_sourceLateral; diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicDeleteWellPathAttributeFeature.h b/ApplicationLibCode/Commands/WellPathCommands/RicDeleteWellPathAttributeFeature.h index a9120b3929..60cda7b577 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicDeleteWellPathAttributeFeature.h +++ b/ApplicationLibCode/Commands/WellPathCommands/RicDeleteWellPathAttributeFeature.h @@ -28,7 +28,6 @@ class RicDeleteWellPathAttributeFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicDeleteWellPathFeature.cpp b/ApplicationLibCode/Commands/WellPathCommands/RicDeleteWellPathFeature.cpp index 8adc133bd0..dce970d968 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicDeleteWellPathFeature.cpp +++ b/ApplicationLibCode/Commands/WellPathCommands/RicDeleteWellPathFeature.cpp @@ -72,4 +72,5 @@ void RicDeleteWellPathFeature::setupActionLook( QAction* actionToSetup ) { actionToSetup->setText( "Delete Well Path" ); actionToSetup->setIcon( QIcon( ":/Erase.svg" ) ); + actionToSetup->setShortcut( Qt::Key_Delete ); } diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicDeleteWellPathTargetFeature.h b/ApplicationLibCode/Commands/WellPathCommands/RicDeleteWellPathTargetFeature.h index b31b2462fd..1197da19c9 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicDeleteWellPathTargetFeature.h +++ b/ApplicationLibCode/Commands/WellPathCommands/RicDeleteWellPathTargetFeature.h @@ -28,7 +28,6 @@ class RicDeleteWellPathTargetFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicImportWellMeasurementsFeature.h b/ApplicationLibCode/Commands/WellPathCommands/RicImportWellMeasurementsFeature.h index a73e0dc463..54ed5a6b40 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicImportWellMeasurementsFeature.h +++ b/ApplicationLibCode/Commands/WellPathCommands/RicImportWellMeasurementsFeature.h @@ -28,7 +28,6 @@ class RicImportWellMeasurementsFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicImportWellPaths.cpp b/ApplicationLibCode/Commands/WellPathCommands/RicImportWellPaths.cpp index 1eacb7b706..81db7cc48c 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicImportWellPaths.cpp +++ b/ApplicationLibCode/Commands/WellPathCommands/RicImportWellPaths.cpp @@ -48,8 +48,8 @@ class RicImportWellPathsResult : public caf::PdmObject public: RicImportWellPathsResult() { - CAF_PDM_InitObject( "well_path_result", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &wellPathNames, "wellPathNames", "", "", "", "" ); + CAF_PDM_InitObject( "well_path_result" ); + CAF_PDM_InitFieldNoDefault( &wellPathNames, "wellPathNames", "" ); } public: @@ -64,9 +64,9 @@ RICF_SOURCE_INIT( RicImportWellPaths, "RicWellPathsImportFileFeature", "importWe //-------------------------------------------------------------------------------------------------- RicImportWellPaths::RicImportWellPaths() { - CAF_PDM_InitScriptableFieldNoDefault( &m_wellPathFolder, "wellPathFolder", "", "", "", "" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_wellPathFiles, "wellPathFiles", "", "", "", "" ); - CAF_PDM_InitScriptableField( &m_importGrouped, "importGrouped", false, "", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_wellPathFolder, "wellPathFolder", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_wellPathFiles, "wellPathFiles", "" ); + CAF_PDM_InitScriptableField( &m_importGrouped, "importGrouped", false, "" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicNewEditableWellPathFeature.h b/ApplicationLibCode/Commands/WellPathCommands/RicNewEditableWellPathFeature.h index 984e54e9ac..06470accf1 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicNewEditableWellPathFeature.h +++ b/ApplicationLibCode/Commands/WellPathCommands/RicNewEditableWellPathFeature.h @@ -28,7 +28,6 @@ class RicNewEditableWellPathFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicNewPolylineTargetFeature.h b/ApplicationLibCode/Commands/WellPathCommands/RicNewPolylineTargetFeature.h index 242e504dae..4466fbc078 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicNewPolylineTargetFeature.h +++ b/ApplicationLibCode/Commands/WellPathCommands/RicNewPolylineTargetFeature.h @@ -28,7 +28,6 @@ class RicNewPolylineTargetFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicNewWellPathAttributeFeature.h b/ApplicationLibCode/Commands/WellPathCommands/RicNewWellPathAttributeFeature.h index 528d5c3ec5..72a27e7ab7 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicNewWellPathAttributeFeature.h +++ b/ApplicationLibCode/Commands/WellPathCommands/RicNewWellPathAttributeFeature.h @@ -28,7 +28,6 @@ class RicNewWellPathAttributeFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicNewWellPathListTargetFeature.h b/ApplicationLibCode/Commands/WellPathCommands/RicNewWellPathListTargetFeature.h index 17842d7320..b3eb4e97b0 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicNewWellPathListTargetFeature.h +++ b/ApplicationLibCode/Commands/WellPathCommands/RicNewWellPathListTargetFeature.h @@ -28,7 +28,6 @@ class RicNewWellPathListTargetFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicShowWellPlanFeature.h b/ApplicationLibCode/Commands/WellPathCommands/RicShowWellPlanFeature.h index dd3e43ff4c..9fb5c62fdb 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicShowWellPlanFeature.h +++ b/ApplicationLibCode/Commands/WellPathCommands/RicShowWellPlanFeature.h @@ -28,7 +28,6 @@ class RicShowWellPlanFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: - // Overrides bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicWellPathsUnitSystemSettingsUi.cpp b/ApplicationLibCode/Commands/WellPathCommands/RicWellPathsUnitSystemSettingsUi.cpp index 165caff678..e108c8eb33 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicWellPathsUnitSystemSettingsUi.cpp +++ b/ApplicationLibCode/Commands/WellPathCommands/RicWellPathsUnitSystemSettingsUi.cpp @@ -25,17 +25,16 @@ CAF_PDM_SOURCE_INIT( RicWellPathsUnitSystemSettingsUi, "RicWellPathsUnitSystemSe //-------------------------------------------------------------------------------------------------- RicWellPathsUnitSystemSettingsUi::RicWellPathsUnitSystemSettingsUi() { - CAF_PDM_InitObject( "RimWellPathsUnitSystemSettings", "", "", "" ); + CAF_PDM_InitObject( "RimWellPathsUnitSystemSettings" ); - CAF_PDM_InitFieldNoDefault( &unitSystem, "UnitSystem", "Unit System", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &unitSystem, "UnitSystem", "Unit System" ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- QList - RicWellPathsUnitSystemSettingsUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) + RicWellPathsUnitSystemSettingsUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; if ( fieldNeedingOptions == &unitSystem ) diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicWellPathsUnitSystemSettingsUi.h b/ApplicationLibCode/Commands/WellPathCommands/RicWellPathsUnitSystemSettingsUi.h index 8082511889..a90d6039c8 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/RicWellPathsUnitSystemSettingsUi.h +++ b/ApplicationLibCode/Commands/WellPathCommands/RicWellPathsUnitSystemSettingsUi.h @@ -37,6 +37,5 @@ class RicWellPathsUnitSystemSettingsUi : public caf::PdmObject caf::PdmField> unitSystem; protected: - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; }; diff --git a/ApplicationLibCode/FileInterface/CMakeLists_files.cmake b/ApplicationLibCode/FileInterface/CMakeLists_files.cmake index a45e86fc81..5da763a486 100644 --- a/ApplicationLibCode/FileInterface/CMakeLists_files.cmake +++ b/ApplicationLibCode/FileInterface/CMakeLists_files.cmake @@ -71,6 +71,8 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RifEclipseKeywordContent.h ${CMAKE_CURRENT_LIST_DIR}/RifMultipleSummaryReaders.h ${CMAKE_CURRENT_LIST_DIR}/RifProjectSummaryDataWriter.h + ${CMAKE_CURRENT_LIST_DIR}/RifReaderOpmRft.h + ${CMAKE_CURRENT_LIST_DIR}/RifRftSegment.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -143,6 +145,8 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RifEclipseTextFileReader.cpp ${CMAKE_CURRENT_LIST_DIR}/RifMultipleSummaryReaders.cpp ${CMAKE_CURRENT_LIST_DIR}/RifProjectSummaryDataWriter.cpp + ${CMAKE_CURRENT_LIST_DIR}/RifReaderOpmRft.cpp + ${CMAKE_CURRENT_LIST_DIR}/RifRftSegment.cpp ) list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) diff --git a/ApplicationLibCode/FileInterface/RifColorLegendData.cpp b/ApplicationLibCode/FileInterface/RifColorLegendData.cpp index f5af7a30d4..f2342c811b 100644 --- a/ApplicationLibCode/FileInterface/RifColorLegendData.cpp +++ b/ApplicationLibCode/FileInterface/RifColorLegendData.cpp @@ -18,6 +18,7 @@ #include "RifColorLegendData.h" +#include "RiaTextStringTools.h" #include "RigFormationNames.h" #include "cafAssert.h" @@ -66,7 +67,7 @@ cvf::ref RifColorLegendData::readLyrFormationNameFile( const while ( !stream.atEnd() ) { QString line = stream.readLine(); - QStringList lineSegs = line.split( "'", QString::KeepEmptyParts ); + QStringList lineSegs = line.split( "'" ); if ( lineSegs.size() == 0 ) continue; // Empty line if ( lineSegs.size() == 1 ) continue; // No name present. Comment line ? @@ -84,16 +85,14 @@ cvf::ref RifColorLegendData::readLyrFormationNameFile( const QString numberString = lineSegs[2]; if ( commentMarkPos >= 0 ) numberString.truncate( commentMarkPos ); - QString colorWord = numberString.split( " ", QString::SkipEmptyParts ).last(); // extract last word which may - // contain formation color + // extract last word which may contain formation color + QString colorWord = RiaTextStringTools::splitSkipEmptyParts( numberString ).last(); if ( QColor::isValidColor( colorWord ) ) numberString.remove( colorWord ); // remove color if present as last word on line - QStringList numberWords = numberString.split( QRegExp( "-" ), QString::SkipEmptyParts ); // extract words - // containing - // formation - // number(s) + // extract words containing formation number(s) + QStringList numberWords = RiaTextStringTools::splitSkipEmptyParts( numberString, QRegExp( "-" ) ); if ( numberWords.size() == 2 ) // formation range with or without color at end of line { diff --git a/ApplicationLibCode/FileInterface/RifColumnBasedUserData.cpp b/ApplicationLibCode/FileInterface/RifColumnBasedUserData.cpp index b52d3108fc..470931ff42 100644 --- a/ApplicationLibCode/FileInterface/RifColumnBasedUserData.cpp +++ b/ApplicationLibCode/FileInterface/RifColumnBasedUserData.cpp @@ -196,27 +196,27 @@ std::vector RifColumnBasedUserData::createTimeSteps( const TableData& ta const Column& ci = tableData.columnInfos()[columIndex]; if ( dateColumnIndex == tableData.columnInfos().size() && - RifEclipseUserDataKeywordTools::isDate( ci.summaryAddress.quantityName() ) ) + RifEclipseUserDataKeywordTools::isDate( ci.summaryAddress.vectorName() ) ) { dateColumnIndex = columIndex; } if ( daysColumnIndex == tableData.columnInfos().size() && - RifEclipseUserDataKeywordTools::isTime( ci.summaryAddress.quantityName() ) && + RifEclipseUserDataKeywordTools::isTime( ci.summaryAddress.vectorName() ) && RifEclipseUserDataKeywordTools::isDays( ci.unitName ) ) { daysColumnIndex = columIndex; } if ( yearsColumnIndex == tableData.columnInfos().size() && - RifEclipseUserDataKeywordTools::isYears( ci.summaryAddress.quantityName() ) && + RifEclipseUserDataKeywordTools::isYears( ci.summaryAddress.vectorName() ) && RifEclipseUserDataKeywordTools::isYears( ci.unitName ) ) { yearsColumnIndex = columIndex; } if ( yearXColumnIndex == tableData.columnInfos().size() && - RifEclipseUserDataKeywordTools::isYearX( ci.summaryAddress.quantityName() ) && + RifEclipseUserDataKeywordTools::isYearX( ci.summaryAddress.vectorName() ) && RifEclipseUserDataKeywordTools::isYears( ci.unitName ) ) { yearXColumnIndex = columIndex; diff --git a/ApplicationLibCode/FileInterface/RifColumnBasedUserDataParser.cpp b/ApplicationLibCode/FileInterface/RifColumnBasedUserDataParser.cpp index 2a34731bd5..7b3e6de120 100644 --- a/ApplicationLibCode/FileInterface/RifColumnBasedUserDataParser.cpp +++ b/ApplicationLibCode/FileInterface/RifColumnBasedUserDataParser.cpp @@ -23,6 +23,7 @@ #include "RiaDateStringParser.h" #include "RiaLogging.h" +#include "RiaTextStringTools.h" #include "cvfAssert.h" @@ -104,7 +105,7 @@ void RifColumnBasedUserDataParser::parseTableData( const QString& data ) int stepTypeIndex = -1; for ( size_t i = 0; i < columnInfos.size(); i++ ) { - if ( RifEclipseUserDataKeywordTools::isStepType( columnInfos[i].summaryAddress.quantityName() ) ) + if ( RifEclipseUserDataKeywordTools::isStepType( columnInfos[i].summaryAddress.vectorName() ) ) { stepTypeIndex = static_cast( i ); } @@ -116,7 +117,7 @@ void RifColumnBasedUserDataParser::parseTableData( const QString& data ) do { QString qLine = QString::fromStdString( line ); - QStringList entries = qLine.split( " ", QString::SkipEmptyParts ); + QStringList entries = RiaTextStringTools::splitSkipEmptyParts( qLine ); if ( stepTypeIndex > -1 && (unsigned int)entries.size() < columnInfos.size() ) { diff --git a/ApplicationLibCode/FileInterface/RifCsvUserDataParser.cpp b/ApplicationLibCode/FileInterface/RifCsvUserDataParser.cpp index 6fe91ff015..175c1c2ef2 100644 --- a/ApplicationLibCode/FileInterface/RifCsvUserDataParser.cpp +++ b/ApplicationLibCode/FileInterface/RifCsvUserDataParser.cpp @@ -30,6 +30,7 @@ #include "SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeatureUi.h" +#include "caf.h" #include "cvfAssert.h" #include @@ -378,7 +379,7 @@ bool RifCsvUserDataParser::parseColumnBasedData( const AsciiDataParseOptions& pa // Determine column data type if ( col.dataType == Column::NONE ) { - if ( QString::fromStdString( col.summaryAddress.quantityName() ) == parseOptions.timeSeriesColumnName ) + if ( QString::fromStdString( col.summaryAddress.vectorName() ) == parseOptions.timeSeriesColumnName ) { col.dataType = Column::DATETIME; } @@ -733,7 +734,7 @@ QLocale RifCsvUserDataParser::localeFromDecimalSeparator( const QString& decimal { if ( decimalSeparator == "," ) { - return QLocale::Norwegian; + return caf::norwegianLocale(); } return QLocale::c(); } diff --git a/ApplicationLibCode/FileInterface/RifDataSourceForRftPlt.cpp b/ApplicationLibCode/FileInterface/RifDataSourceForRftPlt.cpp index b500e6ddd3..aa2ebdd264 100644 --- a/ApplicationLibCode/FileInterface/RifDataSourceForRftPlt.cpp +++ b/ApplicationLibCode/FileInterface/RifDataSourceForRftPlt.cpp @@ -17,15 +17,19 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RifDataSourceForRftPlt.h" + +#include "RifReaderEclipseRft.h" + #include "RimEclipseCase.h" +#include "RimEclipseResultCase.h" #include "RimObservedFmuRftData.h" #include "RimSummaryCase.h" #include "RimSummaryCaseCollection.h" #include "RimWellLogFile.h" -#include "RimEclipseResultCase.h" #include "cafAppEnum.h" #include "cvfAssert.h" + #include #include diff --git a/ApplicationLibCode/FileInterface/RifEclEclipseSummary.cpp b/ApplicationLibCode/FileInterface/RifEclEclipseSummary.cpp index 7a3e1ef0c0..228e2b3a65 100644 --- a/ApplicationLibCode/FileInterface/RifEclEclipseSummary.cpp +++ b/ApplicationLibCode/FileInterface/RifEclEclipseSummary.cpp @@ -111,7 +111,7 @@ RifEclipseSummaryAddress addressFromErtSmSpecNode( const ecl::smspec_node& ertSu std::string quantityName; int regionNumber( -1 ); int regionNumber2( -1 ); - std::string wellGroupName; + std::string groupName; std::string wellName; int wellSegmentNumber( -1 ); std::string lgrName; @@ -151,8 +151,8 @@ RifEclipseSummaryAddress addressFromErtSmSpecNode( const ecl::smspec_node& ertSu break; case ECL_SMSPEC_GROUP_VAR: { - sumCategory = RifEclipseSummaryAddress::SUMMARY_WELL_GROUP; - wellGroupName = stringFromPointer( ertSumVarNode.get_wgname() ); + sumCategory = RifEclipseSummaryAddress::SUMMARY_GROUP; + groupName = stringFromPointer( ertSumVarNode.get_wgname() ); } break; case ECL_SMSPEC_BLOCK_VAR: @@ -239,7 +239,7 @@ RifEclipseSummaryAddress addressFromErtSmSpecNode( const ecl::smspec_node& ertSu quantityName, regionNumber, regionNumber2, - wellGroupName, + groupName, wellName, wellSegmentNumber, lgrName, diff --git a/ApplicationLibCode/FileInterface/RifEclipseInputFileTools.cpp b/ApplicationLibCode/FileInterface/RifEclipseInputFileTools.cpp index 95a9da6c0a..ad889028ec 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseInputFileTools.cpp +++ b/ApplicationLibCode/FileInterface/RifEclipseInputFileTools.cpp @@ -48,6 +48,7 @@ #include #include +#include "RiaTextStringTools.h" #include "ert/ecl/ecl_box.hpp" #include "ert/ecl/ecl_grid.hpp" #include "ert/ecl/ecl_kw.h" @@ -813,7 +814,7 @@ void RifEclipseInputFileTools::parseAndReadPathAliasKeyword( const QString& // definition; 'I+' line.remove( "'" ); - QStringList entries = line.split( " ", QString::SkipEmptyParts ); + QStringList entries = RiaTextStringTools::splitSkipEmptyParts( line ); if ( entries.size() < 2 ) { continue; diff --git a/ApplicationLibCode/FileInterface/RifEclipseInputPropertyLoader.cpp b/ApplicationLibCode/FileInterface/RifEclipseInputPropertyLoader.cpp index 581ab2c71f..1e541d6334 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseInputPropertyLoader.cpp +++ b/ApplicationLibCode/FileInterface/RifEclipseInputPropertyLoader.cpp @@ -45,7 +45,7 @@ void RifEclipseInputPropertyLoader::loadAndSyncronizeInputProperties( RimEclipse const std::vector& filenames, bool allowImportOfFaults ) { - std::vector existingProperties = inputPropertyCollection->inputProperties.childObjects(); + std::vector existingProperties = inputPropertyCollection->inputProperties.children(); caf::ProgressInfo progInfo( static_cast( filenames.size() ), "Reading Input properties" ); diff --git a/ApplicationLibCode/FileInterface/RifEclipseOutputFileTools.cpp b/ApplicationLibCode/FileInterface/RifEclipseOutputFileTools.cpp index 3880e7d296..fafa451292 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseOutputFileTools.cpp +++ b/ApplicationLibCode/FileInterface/RifEclipseOutputFileTools.cpp @@ -673,7 +673,7 @@ void RifEclipseOutputFileTools::createReportStepsMetaData( std::vectoryear, restart_header->month, restart_header->day ) ); reportStep.dateTime = reportDateTime; } diff --git a/ApplicationLibCode/FileInterface/RifEclipseRftAddress.cpp b/ApplicationLibCode/FileInterface/RifEclipseRftAddress.cpp index 1c2f7041ee..7ab3d925cd 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseRftAddress.cpp +++ b/ApplicationLibCode/FileInterface/RifEclipseRftAddress.cpp @@ -21,11 +21,111 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RifEclipseRftAddress::RifEclipseRftAddress( QString wellName, QDateTime timeStep, RftWellLogChannelType wellLogChannelName ) +RifEclipseRftAddress::RifEclipseRftAddress( const QString& wellName, + const QDateTime& timeStep, + RftWellLogChannelType wellLogChannelName, + const QString& segmentResultName, + int segmentBranchNumber ) : m_wellName( wellName ) + , m_timeStep( timeStep ) , m_wellLogChannel( wellLogChannelName ) + , m_segmentResultName( segmentResultName ) + , m_segmentBranchNumber( segmentBranchNumber ) { - m_timeStep = timeStep; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifEclipseRftAddress RifEclipseRftAddress::createAddress( const QString& wellName, + const QDateTime& timeStep, + RftWellLogChannelType wellLogChannel ) +{ + auto segmentResultName = ""; + auto segmentBranchNumber = -1; + auto adr = RifEclipseRftAddress( wellName, timeStep, wellLogChannel, segmentResultName, segmentBranchNumber ); + + return adr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifEclipseRftAddress RifEclipseRftAddress::createSegmentAddress( const QString& wellName, + const QDateTime& dateTime, + const QString& resultName, + int segmentBranchNumber ) +{ + auto adr = RifEclipseRftAddress( wellName, + dateTime, + RifEclipseRftAddress::RftWellLogChannelType::SEGMENT_VALUES, + resultName, + segmentBranchNumber ); + + return adr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RifEclipseRftAddress::segmentResultName() const +{ + return m_segmentResultName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RifEclipseRftAddress::segmentBranchNumber() const +{ + return m_segmentBranchNumber; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const QString& RifEclipseRftAddress::wellName() const +{ + return m_wellName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QDateTime RifEclipseRftAddress::timeStep() const +{ + return m_timeStep; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RifEclipseRftAddress::RifEclipseRftAddress::RftWellLogChannelType& RifEclipseRftAddress::wellLogChannel() const +{ + return m_wellLogChannel; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::set RifEclipseRftAddress::rftPlotChannelTypes() +{ + return { RifEclipseRftAddress::RftWellLogChannelType::PRESSURE, + RifEclipseRftAddress::RftWellLogChannelType::PRESSURE_ERROR, + RifEclipseRftAddress::RftWellLogChannelType::PRESSURE_MEAN, + RifEclipseRftAddress::RftWellLogChannelType::PRESSURE_P10, + RifEclipseRftAddress::RftWellLogChannelType::PRESSURE_P50, + RifEclipseRftAddress::RftWellLogChannelType::PRESSURE_P90 }; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::set RifEclipseRftAddress::pltPlotChannelTypes() +{ + return { RifEclipseRftAddress::RftWellLogChannelType::ORAT, + RifEclipseRftAddress::RftWellLogChannelType::WRAT, + RifEclipseRftAddress::RftWellLogChannelType::GRAT }; } //-------------------------------------------------------------------------------------------------- @@ -36,6 +136,8 @@ bool operator==( const RifEclipseRftAddress& first, const RifEclipseRftAddress& if ( first.wellName() != second.wellName() ) return false; if ( first.timeStep() != second.timeStep() ) return false; if ( first.wellLogChannel() != second.wellLogChannel() ) return false; + if ( first.segmentResultName() != second.segmentResultName() ) return false; + if ( first.segmentBranchNumber() != second.segmentBranchNumber() ) return false; return true; } @@ -49,6 +151,10 @@ bool operator<( const RifEclipseRftAddress& first, const RifEclipseRftAddress& s if ( first.timeStep() != second.timeStep() ) return ( first.timeStep() < second.timeStep() ); if ( first.wellLogChannel() != second.wellLogChannel() ) return ( first.wellLogChannel() < second.wellLogChannel() ); + if ( first.segmentResultName() != second.segmentResultName() ) + return first.segmentResultName() < second.segmentResultName(); + if ( first.segmentBranchNumber() != second.segmentBranchNumber() ) + return first.segmentBranchNumber() < second.segmentBranchNumber(); return false; } diff --git a/ApplicationLibCode/FileInterface/RifEclipseRftAddress.h b/ApplicationLibCode/FileInterface/RifEclipseRftAddress.h index ed0e610b5e..92e5ac1903 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseRftAddress.h +++ b/ApplicationLibCode/FileInterface/RifEclipseRftAddress.h @@ -31,7 +31,7 @@ class RifEclipseRftAddress { public: - enum RftWellLogChannelType + enum class RftWellLogChannelType { NONE, TVD, @@ -47,35 +47,43 @@ class RifEclipseRftAddress PRESSURE_P50, PRESSURE_P90, PRESSURE_MEAN, - PRESSURE_ERROR + PRESSURE_ERROR, + SEGMENT_VALUES }; public: - RifEclipseRftAddress( QString wellName, QDateTime timeStep, RftWellLogChannelType wellLogChannel ); + static RifEclipseRftAddress + createAddress( const QString& wellName, const QDateTime& timeStep, RftWellLogChannelType wellLogChannel ); - const QString& wellName() const { return m_wellName; } - QDateTime timeStep() const { return m_timeStep; } - const RftWellLogChannelType& wellLogChannel() const { return m_wellLogChannel; } + static RifEclipseRftAddress createSegmentAddress( const QString& wellName, + const QDateTime& dateTime, + const QString& resultName, + int segmentBranchNumber ); - static std::set rftPlotChannelTypes() - { - return {RifEclipseRftAddress::PRESSURE, - RifEclipseRftAddress::PRESSURE_ERROR, - RifEclipseRftAddress::PRESSURE_MEAN, - RifEclipseRftAddress::PRESSURE_P10, - RifEclipseRftAddress::PRESSURE_P50, - RifEclipseRftAddress::PRESSURE_P90}; - } + QString segmentResultName() const; + int segmentBranchNumber() const; - static std::set pltPlotChannelTypes() - { - return {RifEclipseRftAddress::ORAT, RifEclipseRftAddress::WRAT, RifEclipseRftAddress::GRAT}; - } + const QString& wellName() const; + QDateTime timeStep() const; + const RftWellLogChannelType& wellLogChannel() const; + + static std::set rftPlotChannelTypes(); + static std::set pltPlotChannelTypes(); + +private: + RifEclipseRftAddress( const QString& wellName, + const QDateTime& timeStep, + RftWellLogChannelType wellLogChannel, + const QString& segmentResultName, + int segmentBranchNumber ); private: QString m_wellName; QDateTime m_timeStep; RftWellLogChannelType m_wellLogChannel; + + QString m_segmentResultName; + int m_segmentBranchNumber; }; bool operator==( const RifEclipseRftAddress& first, const RifEclipseRftAddress& second ); diff --git a/ApplicationLibCode/FileInterface/RifEclipseSummaryAddress.cpp b/ApplicationLibCode/FileInterface/RifEclipseSummaryAddress.cpp index c512389c25..697c33bdab 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseSummaryAddress.cpp +++ b/ApplicationLibCode/FileInterface/RifEclipseSummaryAddress.cpp @@ -55,8 +55,8 @@ RifEclipseSummaryAddress::RifEclipseSummaryAddress( SummaryVarCategory m_regionNumber = reg2regPair.first; m_regionNumber2 = reg2regPair.second; break; - case SUMMARY_WELL_GROUP: - m_wellGroupName = identifiers[INPUT_WELL_GROUP_NAME]; + case SUMMARY_GROUP: + m_groupName = identifiers[INPUT_GROUP_NAME]; break; case SUMMARY_WELL: m_wellName = identifiers[INPUT_WELL_NAME]; @@ -105,8 +105,7 @@ RifEclipseSummaryAddress::RifEclipseSummaryAddress( SummaryVarCategory break; } - // Set quantity for all categories - m_quantityName = identifiers[INPUT_VECTOR_NAME]; + m_vectorName = identifiers[INPUT_VECTOR_NAME]; } //-------------------------------------------------------------------------------------------------- @@ -134,7 +133,7 @@ RifEclipseSummaryAddress RifEclipseSummaryAddress::fromEclipseTextAddressParseEr if ( address.category() == SUMMARY_INVALID || address.category() == SUMMARY_IMPORTED ) { - // Address category not recognized, use incoming text string without error prefix as quantity name + // Address category not recognized, use incoming text string without error prefix as vector name auto text = RiaStdStringTools::joinStrings( tokens, ':' ); address = importedAddress( text ); } @@ -156,46 +155,22 @@ RifEclipseSummaryAddress RifEclipseSummaryAddress::fromEclipseTextAddress( const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RifEclipseSummaryAddress::SummaryVarCategory RifEclipseSummaryAddress::identifyCategory( const std::string& quantityName ) -{ - if ( quantityName.size() < 3 || quantityName.size() > 8 ) return SUMMARY_INVALID; - - auto strippedQuantityName = baseQuantityName( quantityName ); - - // First, try to lookup vector in vector table - auto category = RiuSummaryQuantityNameInfoProvider::instance()->categoryFromQuantityName( strippedQuantityName ); - if ( category != SUMMARY_INVALID ) return category; - - // Then check LGR categories - std::string firstTwoLetters = strippedQuantityName.substr( 0, 2 ); - - if ( firstTwoLetters == "LB" ) return SUMMARY_BLOCK_LGR; - if ( firstTwoLetters == "LC" ) return SUMMARY_WELL_COMPLETION_LGR; - if ( firstTwoLetters == "LW" ) return SUMMARY_WELL_LGR; - - if ( strippedQuantityName[0] == 'N' ) return SUMMARY_NETWORK; - return SUMMARY_INVALID; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RifEclipseSummaryAddress RifEclipseSummaryAddress::fieldAddress( const std::string& quantityName ) +RifEclipseSummaryAddress RifEclipseSummaryAddress::fieldAddress( const std::string& vectorName ) { RifEclipseSummaryAddress addr; addr.m_variableCategory = SUMMARY_FIELD; - addr.m_quantityName = quantityName; + addr.m_vectorName = vectorName; return addr; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RifEclipseSummaryAddress RifEclipseSummaryAddress::aquiferAddress( const std::string& quantityName, int aquiferNumber ) +RifEclipseSummaryAddress RifEclipseSummaryAddress::aquiferAddress( const std::string& vectorName, int aquiferNumber ) { RifEclipseSummaryAddress addr; addr.m_variableCategory = SUMMARY_AQUIFER; - addr.m_quantityName = quantityName; + addr.m_vectorName = vectorName; addr.m_aquiferNumber = aquiferNumber; return addr; } @@ -203,33 +178,33 @@ RifEclipseSummaryAddress RifEclipseSummaryAddress::aquiferAddress( const std::st //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RifEclipseSummaryAddress RifEclipseSummaryAddress::networkAddress( const std::string& quantityName ) +RifEclipseSummaryAddress RifEclipseSummaryAddress::networkAddress( const std::string& vectorName ) { RifEclipseSummaryAddress addr; addr.m_variableCategory = SUMMARY_NETWORK; - addr.m_quantityName = quantityName; + addr.m_vectorName = vectorName; return addr; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RifEclipseSummaryAddress RifEclipseSummaryAddress::miscAddress( const std::string& quantityName ) +RifEclipseSummaryAddress RifEclipseSummaryAddress::miscAddress( const std::string& vectorName ) { RifEclipseSummaryAddress addr; addr.m_variableCategory = SUMMARY_MISC; - addr.m_quantityName = quantityName; + addr.m_vectorName = vectorName; return addr; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RifEclipseSummaryAddress RifEclipseSummaryAddress::regionAddress( const std::string& quantityName, int regionNumber ) +RifEclipseSummaryAddress RifEclipseSummaryAddress::regionAddress( const std::string& vectorName, int regionNumber ) { RifEclipseSummaryAddress addr; addr.m_variableCategory = SUMMARY_REGION; - addr.m_quantityName = quantityName; + addr.m_vectorName = vectorName; addr.m_regionNumber = regionNumber; return addr; } @@ -238,11 +213,11 @@ RifEclipseSummaryAddress RifEclipseSummaryAddress::regionAddress( const std::str /// //-------------------------------------------------------------------------------------------------- RifEclipseSummaryAddress - RifEclipseSummaryAddress::regionToRegionAddress( const std::string& quantityName, int regionNumber, int region2Number ) + RifEclipseSummaryAddress::regionToRegionAddress( const std::string& vectorName, int regionNumber, int region2Number ) { RifEclipseSummaryAddress addr; addr.m_variableCategory = SUMMARY_REGION_2_REGION; - addr.m_quantityName = quantityName; + addr.m_vectorName = vectorName; addr.m_regionNumber = regionNumber; addr.m_regionNumber2 = region2Number; return addr; @@ -251,24 +226,23 @@ RifEclipseSummaryAddress //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RifEclipseSummaryAddress RifEclipseSummaryAddress::wellGroupAddress( const std::string& quantityName, - const std::string& wellGroupName ) +RifEclipseSummaryAddress RifEclipseSummaryAddress::groupAddress( const std::string& vectorName, const std::string& groupName ) { RifEclipseSummaryAddress addr; - addr.m_variableCategory = SUMMARY_WELL_GROUP; - addr.m_quantityName = quantityName; - addr.m_wellGroupName = wellGroupName; + addr.m_variableCategory = SUMMARY_GROUP; + addr.m_vectorName = vectorName; + addr.m_groupName = groupName; return addr; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RifEclipseSummaryAddress RifEclipseSummaryAddress::wellAddress( const std::string& quantityName, const std::string& wellName ) +RifEclipseSummaryAddress RifEclipseSummaryAddress::wellAddress( const std::string& vectorName, const std::string& wellName ) { RifEclipseSummaryAddress addr; addr.m_variableCategory = SUMMARY_WELL; - addr.m_quantityName = quantityName; + addr.m_vectorName = vectorName; addr.m_wellName = wellName; return addr; } @@ -276,7 +250,7 @@ RifEclipseSummaryAddress RifEclipseSummaryAddress::wellAddress( const std::strin //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RifEclipseSummaryAddress RifEclipseSummaryAddress::wellCompletionAddress( const std::string& quantityName, +RifEclipseSummaryAddress RifEclipseSummaryAddress::wellCompletionAddress( const std::string& vectorName, const std::string& wellName, int i, int j, @@ -284,7 +258,7 @@ RifEclipseSummaryAddress RifEclipseSummaryAddress::wellCompletionAddress( const { RifEclipseSummaryAddress addr; addr.m_variableCategory = SUMMARY_WELL_COMPLETION; - addr.m_quantityName = quantityName; + addr.m_vectorName = vectorName; addr.m_wellName = wellName; addr.m_cellI = i; addr.m_cellJ = j; @@ -295,13 +269,13 @@ RifEclipseSummaryAddress RifEclipseSummaryAddress::wellCompletionAddress( const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RifEclipseSummaryAddress RifEclipseSummaryAddress::wellLgrAddress( const std::string& quantityName, +RifEclipseSummaryAddress RifEclipseSummaryAddress::wellLgrAddress( const std::string& vectorName, const std::string& lgrName, const std::string& wellName ) { RifEclipseSummaryAddress addr; addr.m_variableCategory = SUMMARY_WELL_LGR; - addr.m_quantityName = quantityName; + addr.m_vectorName = vectorName; addr.m_lgrName = lgrName; addr.m_wellName = wellName; return addr; @@ -310,7 +284,7 @@ RifEclipseSummaryAddress RifEclipseSummaryAddress::wellLgrAddress( const std::st //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RifEclipseSummaryAddress RifEclipseSummaryAddress::wellCompletionLgrAddress( const std::string& quantityName, +RifEclipseSummaryAddress RifEclipseSummaryAddress::wellCompletionLgrAddress( const std::string& vectorName, const std::string& lgrName, const std::string& wellName, int i, @@ -319,7 +293,7 @@ RifEclipseSummaryAddress RifEclipseSummaryAddress::wellCompletionLgrAddress( con { RifEclipseSummaryAddress addr; addr.m_variableCategory = SUMMARY_WELL_COMPLETION_LGR; - addr.m_quantityName = quantityName; + addr.m_vectorName = vectorName; addr.m_lgrName = lgrName; addr.m_wellName = wellName; addr.m_cellI = i; @@ -331,13 +305,13 @@ RifEclipseSummaryAddress RifEclipseSummaryAddress::wellCompletionLgrAddress( con //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RifEclipseSummaryAddress RifEclipseSummaryAddress::wellSegmentAddress( const std::string& quantityName, +RifEclipseSummaryAddress RifEclipseSummaryAddress::wellSegmentAddress( const std::string& vectorName, const std::string& wellName, int segmentNumber ) { RifEclipseSummaryAddress addr; addr.m_variableCategory = SUMMARY_WELL_SEGMENT; - addr.m_quantityName = quantityName; + addr.m_vectorName = vectorName; addr.m_wellName = wellName; addr.m_wellSegmentNumber = segmentNumber; return addr; @@ -346,11 +320,11 @@ RifEclipseSummaryAddress RifEclipseSummaryAddress::wellSegmentAddress( const std //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RifEclipseSummaryAddress RifEclipseSummaryAddress::blockAddress( const std::string& quantityName, int i, int j, int k ) +RifEclipseSummaryAddress RifEclipseSummaryAddress::blockAddress( const std::string& vectorName, int i, int j, int k ) { RifEclipseSummaryAddress addr; addr.m_variableCategory = SUMMARY_BLOCK; - addr.m_quantityName = quantityName; + addr.m_vectorName = vectorName; addr.m_cellI = i; addr.m_cellJ = j; addr.m_cellK = k; @@ -361,11 +335,11 @@ RifEclipseSummaryAddress RifEclipseSummaryAddress::blockAddress( const std::stri /// //-------------------------------------------------------------------------------------------------- RifEclipseSummaryAddress - RifEclipseSummaryAddress::blockLgrAddress( const std::string& quantityName, const std::string& lgrName, int i, int j, int k ) + RifEclipseSummaryAddress::blockLgrAddress( const std::string& vectorName, const std::string& lgrName, int i, int j, int k ) { RifEclipseSummaryAddress addr; addr.m_variableCategory = SUMMARY_BLOCK_LGR; - addr.m_quantityName = quantityName; + addr.m_vectorName = vectorName; addr.m_lgrName = lgrName; addr.m_cellI = i; addr.m_cellJ = j; @@ -376,11 +350,11 @@ RifEclipseSummaryAddress //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RifEclipseSummaryAddress RifEclipseSummaryAddress::calculatedAddress( const std::string& quantityName, int id ) +RifEclipseSummaryAddress RifEclipseSummaryAddress::calculatedAddress( const std::string& vectorName, int id ) { RifEclipseSummaryAddress addr; addr.m_variableCategory = SUMMARY_CALCULATED; - addr.m_quantityName = quantityName; + addr.m_vectorName = vectorName; addr.m_id = id; return addr; } @@ -388,23 +362,23 @@ RifEclipseSummaryAddress RifEclipseSummaryAddress::calculatedAddress( const std: //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RifEclipseSummaryAddress RifEclipseSummaryAddress::importedAddress( const std::string& quantityName ) +RifEclipseSummaryAddress RifEclipseSummaryAddress::importedAddress( const std::string& vectorName ) { RifEclipseSummaryAddress addr; addr.m_variableCategory = SUMMARY_IMPORTED; - addr.m_quantityName = quantityName; + addr.m_vectorName = vectorName; return addr; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RifEclipseSummaryAddress RifEclipseSummaryAddress::ensembleStatisticsAddress( const std::string& quantityName, +RifEclipseSummaryAddress RifEclipseSummaryAddress::ensembleStatisticsAddress( const std::string& vectorName, const std::string& dataQuantityName ) { RifEclipseSummaryAddress addr; addr.m_variableCategory = SUMMARY_ENSEMBLE_STATISTICS; - addr.m_quantityName = quantityName + ":" + dataQuantityName; + addr.m_vectorName = vectorName + ":" + dataQuantityName; return addr; } @@ -454,19 +428,19 @@ bool RifEclipseSummaryAddress::isDependentOnWellName( SummaryVarCategory categor //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RifEclipseSummaryAddress::isHistoryQuantity() const +bool RifEclipseSummaryAddress::isHistoryVector() const { const std::string historyIdentifier = "H"; - return RiaStdStringTools::endsWith( m_quantityName, historyIdentifier ); + return RiaStdStringTools::endsWith( m_vectorName, historyIdentifier ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const std::string RifEclipseSummaryAddress::ensembleStatisticsQuantityName() const +const std::string RifEclipseSummaryAddress::ensembleStatisticsVectorName() const { - QString qName = QString::fromStdString( m_quantityName ); + QString qName = QString::fromStdString( m_vectorName ); return qName.split( ":" )[0].toStdString(); } @@ -479,7 +453,7 @@ std::string RifEclipseSummaryAddress::uiText() const if ( m_isErrorResult ) text += "ERR:"; - text += m_quantityName; + text += m_vectorName; std::string itemText = itemUiText(); if ( !itemText.empty() ) @@ -509,9 +483,9 @@ std::string RifEclipseSummaryAddress::itemUiText() const text += formatUiTextRegionToRegion(); } break; - case SUMMARY_WELL_GROUP: + case SUMMARY_GROUP: { - text += this->wellGroupName(); + text += this->groupName(); } break; case SUMMARY_WELL: @@ -565,6 +539,11 @@ std::string RifEclipseSummaryAddress::itemUiText() const text += std::to_string( this->id() ); } break; + case SUMMARY_IMPORTED: + { + text += this->vectorName(); + } + break; } return text; @@ -584,8 +563,8 @@ std::string return formatUiTextRegionToRegion(); case INPUT_WELL_NAME: return wellName(); - case INPUT_WELL_GROUP_NAME: - return wellGroupName(); + case INPUT_GROUP_NAME: + return groupName(); case INPUT_CELL_IJK: return blockAsString(); case INPUT_LGR_NAME: @@ -595,7 +574,7 @@ std::string case INPUT_AQUIFER_NUMBER: return std::to_string( aquiferNumber() ); case INPUT_VECTOR_NAME: - return quantityName(); + return vectorName(); case INPUT_ID: return std::to_string( id() ); } @@ -627,7 +606,7 @@ bool RifEclipseSummaryAddress::isUiTextMatchingFilterText( const QString& filter //-------------------------------------------------------------------------------------------------- bool RifEclipseSummaryAddress::isValid() const { - if ( m_quantityName.empty() ) return false; + if ( m_vectorName.empty() ) return false; switch ( category() ) { @@ -643,8 +622,8 @@ bool RifEclipseSummaryAddress::isValid() const if ( m_regionNumber2 == -1 ) return false; return true; - case SUMMARY_WELL_GROUP: - if ( m_wellGroupName.size() == 0 ) return false; + case SUMMARY_GROUP: + if ( m_groupName.size() == 0 ) return false; return true; case SUMMARY_WELL: @@ -716,14 +695,14 @@ bool RifEclipseSummaryAddress::hasAccumulatedData() const { if ( !isValidEclipseCategory() ) return false; - QString quantityForInspection = QString::fromStdString( quantityName() ); + QString quantityForInspection = QString::fromStdString( vectorName() ); if ( category() == SUMMARY_ENSEMBLE_STATISTICS ) { // Remove statistics text prefix quantityForInspection = quantityForInspection.mid( quantityForInspection.indexOf( ":" ) + 1 ); } - QString qBaseName = QString::fromStdString( baseQuantityName( quantityForInspection.toStdString() ) ); + QString qBaseName = QString::fromStdString( baseVectorName( quantityForInspection.toStdString() ) ); if ( qBaseName.endsWith( "WCT" ) || qBaseName.endsWith( "WCTH" ) ) { @@ -744,36 +723,48 @@ RifEclipseSummaryAddress RifEclipseSummaryAddress::fromTokens( const std::vector return RifEclipseSummaryAddress(); } - std::string quantityName; + std::string vectorName; std::string token1; std::string token2; - quantityName = tokens[0]; + int intValue0 = 0; + int intValue1 = 0; + int intValue2 = 0; + + vectorName = tokens[0]; if ( tokens.size() > 1 ) token1 = tokens[1]; if ( tokens.size() > 2 ) token2 = tokens[2]; - SummaryVarCategory category = identifyCategory( quantityName ); + SummaryVarCategory category = RiuSummaryQuantityNameInfoProvider::instance()->identifyCategory( vectorName ); switch ( category ) { case SUMMARY_FIELD: - return fieldAddress( quantityName ); + return fieldAddress( vectorName ); case SUMMARY_AQUIFER: - if ( !token1.empty() ) return aquiferAddress( quantityName, RiaStdStringTools::toInt( token1 ) ); + if ( !token1.empty() ) + { + RiaStdStringTools::toInt( token1, intValue0 ); + return aquiferAddress( vectorName, intValue0 ); + } break; case SUMMARY_NETWORK: - return networkAddress( quantityName ); + return networkAddress( vectorName ); break; case SUMMARY_MISC: - return miscAddress( quantityName ); + return miscAddress( vectorName ); break; case SUMMARY_REGION: - if ( !token1.empty() ) return regionAddress( quantityName, RiaStdStringTools::toInt( token1 ) ); + if ( !token1.empty() ) + { + RiaStdStringTools::toInt( token1, intValue0 ); + return regionAddress( vectorName, intValue0 ); + } break; case SUMMARY_REGION_2_REGION: @@ -782,19 +773,20 @@ RifEclipseSummaryAddress RifEclipseSummaryAddress::fromTokens( const std::vector auto regions = RiaStdStringTools::splitString( token1, '-' ); if ( regions.size() == 2 ) { - return regionToRegionAddress( quantityName, - RiaStdStringTools::toInt( regions[0] ), - RiaStdStringTools::toInt( regions[1] ) ); + RiaStdStringTools::toInt( regions[0], intValue0 ); + RiaStdStringTools::toInt( regions[1], intValue1 ); + + return regionToRegionAddress( vectorName, intValue0, intValue1 ); } } break; - case SUMMARY_WELL_GROUP: - if ( !token1.empty() ) return wellGroupAddress( quantityName, token1 ); + case SUMMARY_GROUP: + if ( !token1.empty() ) return groupAddress( vectorName, token1 ); break; case SUMMARY_WELL: - if ( !token1.empty() ) return wellAddress( quantityName, token1 ); + if ( !token1.empty() ) return wellAddress( vectorName, token1 ); break; case SUMMARY_WELL_COMPLETION: @@ -803,17 +795,17 @@ RifEclipseSummaryAddress RifEclipseSummaryAddress::fromTokens( const std::vector auto ijk = RiaStdStringTools::splitString( token2, ',' ); if ( ijk.size() == 3 ) { - return wellCompletionAddress( quantityName, - token1, - RiaStdStringTools::toInt( ijk[0] ), - RiaStdStringTools::toInt( ijk[1] ), - RiaStdStringTools::toInt( ijk[2] ) ); + RiaStdStringTools::toInt( ijk[0], intValue0 ); + RiaStdStringTools::toInt( ijk[1], intValue1 ); + RiaStdStringTools::toInt( ijk[2], intValue2 ); + + return wellCompletionAddress( vectorName, token1, intValue0, intValue1, intValue2 ); } } break; case SUMMARY_WELL_LGR: - if ( !token1.empty() && !token2.empty() ) return wellLgrAddress( quantityName, token1, token2 ); + if ( !token1.empty() && !token2.empty() ) return wellLgrAddress( vectorName, token1, token2 ); break; case SUMMARY_WELL_COMPLETION_LGR: @@ -823,19 +815,23 @@ RifEclipseSummaryAddress RifEclipseSummaryAddress::fromTokens( const std::vector auto ijk = RiaStdStringTools::splitString( token3, ',' ); if ( ijk.size() == 3 ) { - return wellCompletionLgrAddress( quantityName, - token1, - token2, - RiaStdStringTools::toInt( ijk[0] ), - RiaStdStringTools::toInt( ijk[1] ), - RiaStdStringTools::toInt( ijk[2] ) ); + RiaStdStringTools::toInt( ijk[0], intValue0 ); + RiaStdStringTools::toInt( ijk[1], intValue1 ); + RiaStdStringTools::toInt( ijk[2], intValue2 ); + + return wellCompletionLgrAddress( vectorName, token1, token2, intValue0, intValue1, intValue2 ); } } break; case SUMMARY_WELL_SEGMENT: + if ( !token2.empty() ) - return wellSegmentAddress( quantityName, token1, RiaStdStringTools::toInt( token2 ) ); + { + RiaStdStringTools::toInt( token2, intValue0 ); + + return wellSegmentAddress( vectorName, token1, intValue0 ); + } break; case SUMMARY_BLOCK: @@ -844,10 +840,11 @@ RifEclipseSummaryAddress RifEclipseSummaryAddress::fromTokens( const std::vector auto ijk = RiaStdStringTools::splitString( token1, ',' ); if ( ijk.size() == 3 ) { - return blockAddress( quantityName, - RiaStdStringTools::toInt( ijk[0] ), - RiaStdStringTools::toInt( ijk[1] ), - RiaStdStringTools::toInt( ijk[2] ) ); + RiaStdStringTools::toInt( ijk[0], intValue0 ); + RiaStdStringTools::toInt( ijk[1], intValue1 ); + RiaStdStringTools::toInt( ijk[2], intValue2 ); + + return blockAddress( vectorName, intValue0, intValue1, intValue2 ); } } break; @@ -858,11 +855,11 @@ RifEclipseSummaryAddress RifEclipseSummaryAddress::fromTokens( const std::vector auto ijk = RiaStdStringTools::splitString( token2, ',' ); if ( ijk.size() == 3 ) { - return blockLgrAddress( quantityName, - token1, - RiaStdStringTools::toInt( ijk[0] ), - RiaStdStringTools::toInt( ijk[1] ), - RiaStdStringTools::toInt( ijk[2] ) ); + RiaStdStringTools::toInt( ijk[0], intValue0 ); + RiaStdStringTools::toInt( ijk[1], intValue1 ); + RiaStdStringTools::toInt( ijk[2], intValue2 ); + + return blockLgrAddress( vectorName, token1, intValue0, intValue1, intValue2 ); } } break; @@ -889,7 +886,7 @@ bool RifEclipseSummaryAddress::isValidEclipseCategory() const case SUMMARY_MISC: case SUMMARY_REGION: case SUMMARY_REGION_2_REGION: - case SUMMARY_WELL_GROUP: + case SUMMARY_GROUP: case SUMMARY_WELL: case SUMMARY_WELL_COMPLETION: case SUMMARY_WELL_LGR: @@ -906,9 +903,9 @@ bool RifEclipseSummaryAddress::isValidEclipseCategory() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::string RifEclipseSummaryAddress::baseQuantityName( const std::string& quantityName ) +std::string RifEclipseSummaryAddress::baseVectorName( const std::string& vectorName ) { - auto tmpString = quantityName; + auto tmpString = vectorName; if ( tmpString.size() == 8 ) tmpString = tmpString.substr( 0, 5 ); @@ -971,7 +968,7 @@ std::pair RifEclipseSummaryAddress::regionToRegionPairFromUiTe bool operator==( const RifEclipseSummaryAddress& first, const RifEclipseSummaryAddress& second ) { if ( first.category() != second.category() ) return false; - if ( first.quantityName() != second.quantityName() ) return false; + if ( first.vectorName() != second.vectorName() ) return false; switch ( first.category() ) { case RifEclipseSummaryAddress::SUMMARY_REGION: @@ -985,9 +982,9 @@ bool operator==( const RifEclipseSummaryAddress& first, const RifEclipseSummaryA if ( first.regionNumber2() != second.regionNumber2() ) return false; } break; - case RifEclipseSummaryAddress::SUMMARY_WELL_GROUP: + case RifEclipseSummaryAddress::SUMMARY_GROUP: { - if ( first.wellGroupName() != second.wellGroupName() ) return false; + if ( first.groupName() != second.groupName() ) return false; } break; case RifEclipseSummaryAddress::SUMMARY_WELL: @@ -1067,7 +1064,7 @@ bool operator!=( const RifEclipseSummaryAddress& first, const RifEclipseSummaryA //-------------------------------------------------------------------------------------------------- bool operator<( const RifEclipseSummaryAddress& first, const RifEclipseSummaryAddress& second ) { - if ( first.quantityName() != second.quantityName() ) return first.quantityName() < second.quantityName(); + if ( first.vectorName() != second.vectorName() ) return first.vectorName() < second.vectorName(); switch ( first.category() ) { @@ -1083,10 +1080,9 @@ bool operator<( const RifEclipseSummaryAddress& first, const RifEclipseSummaryAd return first.regionNumber2() < second.regionNumber2(); } break; - case RifEclipseSummaryAddress::SUMMARY_WELL_GROUP: + case RifEclipseSummaryAddress::SUMMARY_GROUP: { - if ( first.wellGroupName() != second.wellGroupName() ) - return first.wellGroupName() < second.wellGroupName(); + if ( first.groupName() != second.groupName() ) return first.groupName() < second.groupName(); } break; case RifEclipseSummaryAddress::SUMMARY_WELL: diff --git a/ApplicationLibCode/FileInterface/RifEclipseSummaryAddress.h b/ApplicationLibCode/FileInterface/RifEclipseSummaryAddress.h index b26940c641..c85579d2b2 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseSummaryAddress.h +++ b/ApplicationLibCode/FileInterface/RifEclipseSummaryAddress.h @@ -47,7 +47,7 @@ class RifEclipseSummaryAddress SUMMARY_MISC, SUMMARY_REGION, SUMMARY_REGION_2_REGION, - SUMMARY_WELL_GROUP, + SUMMARY_GROUP, SUMMARY_WELL, SUMMARY_WELL_COMPLETION, SUMMARY_WELL_LGR, @@ -65,7 +65,7 @@ class RifEclipseSummaryAddress INPUT_REGION_NUMBER, INPUT_REGION_2_REGION, INPUT_WELL_NAME, - INPUT_WELL_GROUP_NAME, + INPUT_GROUP_NAME, INPUT_CELL_IJK, INPUT_LGR_NAME, INPUT_SEGMENT_NUMBER, @@ -90,10 +90,10 @@ class RifEclipseSummaryAddress } RifEclipseSummaryAddress( SummaryVarCategory category, - const std::string& quantityName, + const std::string& vectorName, int16_t regionNumber, int16_t regionNumber2, - const std::string& wellGroupName, + const std::string& groupName, const std::string& wellName, int16_t wellSegmentNumber, const std::string& lgrName, @@ -104,10 +104,10 @@ class RifEclipseSummaryAddress bool isErrorResult, int32_t id ) : m_variableCategory( category ) - , m_quantityName( quantityName ) + , m_vectorName( vectorName ) , m_regionNumber( regionNumber ) , m_regionNumber2( regionNumber2 ) - , m_wellGroupName( wellGroupName ) + , m_groupName( groupName ) , m_wellName( wellName ) , m_wellSegmentNumber( wellSegmentNumber ) , m_lgrName( lgrName ) @@ -127,36 +127,34 @@ class RifEclipseSummaryAddress static RifEclipseSummaryAddress fromEclipseTextAddress( const std::string& textAddress ); static RifEclipseSummaryAddress fromEclipseTextAddressParseErrorTokens( const std::string& textAddress ); - static SummaryVarCategory identifyCategory( const std::string& quantityName ); - - static RifEclipseSummaryAddress fieldAddress( const std::string& quantityName ); - static RifEclipseSummaryAddress aquiferAddress( const std::string& quantityName, int aquiferNumber ); - static RifEclipseSummaryAddress networkAddress( const std::string& quantityName ); - static RifEclipseSummaryAddress miscAddress( const std::string& quantityName ); - static RifEclipseSummaryAddress regionAddress( const std::string& quantityName, int regionNumber ); + static RifEclipseSummaryAddress fieldAddress( const std::string& vectorName ); + static RifEclipseSummaryAddress aquiferAddress( const std::string& vectorName, int aquiferNumber ); + static RifEclipseSummaryAddress networkAddress( const std::string& vectorName ); + static RifEclipseSummaryAddress miscAddress( const std::string& vectorName ); + static RifEclipseSummaryAddress regionAddress( const std::string& vectorName, int regionNumber ); static RifEclipseSummaryAddress - regionToRegionAddress( const std::string& quantityName, int regionNumber, int region2Number ); - static RifEclipseSummaryAddress wellGroupAddress( const std::string& quantityName, const std::string& wellGroupName ); - static RifEclipseSummaryAddress wellAddress( const std::string& quantityName, const std::string& wellName ); + regionToRegionAddress( const std::string& vectorName, int regionNumber, int region2Number ); + static RifEclipseSummaryAddress groupAddress( const std::string& vectorName, const std::string& groupName ); + static RifEclipseSummaryAddress wellAddress( const std::string& vectorName, const std::string& wellName ); static RifEclipseSummaryAddress - wellCompletionAddress( const std::string& quantityName, const std::string& wellName, int i, int j, int k ); + wellCompletionAddress( const std::string& vectorName, const std::string& wellName, int i, int j, int k ); static RifEclipseSummaryAddress - wellLgrAddress( const std::string& quantityName, const std::string& lgrName, const std::string& wellName ); - static RifEclipseSummaryAddress wellCompletionLgrAddress( const std::string& quantityName, + wellLgrAddress( const std::string& vectorName, const std::string& lgrName, const std::string& wellName ); + static RifEclipseSummaryAddress wellCompletionLgrAddress( const std::string& vectorName, const std::string& lgrName, const std::string& wellName, int i, int j, int k ); static RifEclipseSummaryAddress - wellSegmentAddress( const std::string& quantityName, const std::string& wellName, int segmentNumber ); - static RifEclipseSummaryAddress blockAddress( const std::string& quantityName, int i, int j, int k ); + wellSegmentAddress( const std::string& vectorName, const std::string& wellName, int segmentNumber ); + static RifEclipseSummaryAddress blockAddress( const std::string& vectorName, int i, int j, int k ); static RifEclipseSummaryAddress - blockLgrAddress( const std::string& quantityName, const std::string& lgrName, int i, int j, int k ); - static RifEclipseSummaryAddress calculatedAddress( const std::string& quantityName, int id ); - static RifEclipseSummaryAddress importedAddress( const std::string& quantityName ); - static RifEclipseSummaryAddress ensembleStatisticsAddress( const std::string& quantityName, - const std::string& dataQuantityName ); + blockLgrAddress( const std::string& vectorName, const std::string& lgrName, int i, int j, int k ); + static RifEclipseSummaryAddress calculatedAddress( const std::string& vectorName, int id ); + static RifEclipseSummaryAddress importedAddress( const std::string& vectorName ); + static RifEclipseSummaryAddress ensembleStatisticsAddress( const std::string& vectorName, + const std::string& datavectorName ); static std::string generateStringFromAddresses( const std::vector& addressVector, const std::string jointString = "; " ); @@ -166,13 +164,13 @@ class RifEclipseSummaryAddress // Access methods SummaryVarCategory category() const { return m_variableCategory; } - const std::string& quantityName() const { return m_quantityName; } - bool isHistoryQuantity() const; + const std::string& vectorName() const { return m_vectorName; } + bool isHistoryVector() const; int regionNumber() const { return m_regionNumber; } int regionNumber2() const { return m_regionNumber2; } - const std::string& wellGroupName() const { return m_wellGroupName; } + const std::string& groupName() const { return m_groupName; } const std::string& wellName() const { return m_wellName; } int wellSegmentNumber() const { return m_wellSegmentNumber; } const std::string& lgrName() const { return m_lgrName; } @@ -183,7 +181,7 @@ class RifEclipseSummaryAddress int id() const { return m_id; } std::string blockAsString() const; - const std::string ensembleStatisticsQuantityName() const; + const std::string ensembleStatisticsVectorName() const; // Derived properties @@ -193,9 +191,9 @@ class RifEclipseSummaryAddress bool isUiTextMatchingFilterText( const QString& filterString ) const; bool isValid() const; - void setQuantityName( const std::string& quantity ) { m_quantityName = quantity; } + void setVectorName( const std::string& vectorName ) { m_vectorName = vectorName; } void setWellName( const std::string& wellName ) { m_wellName = wellName; } - void setWellGroupName( const std::string& wellGroupName ) { m_wellGroupName = wellGroupName; } + void setGroupName( const std::string& groupName ) { m_groupName = groupName; } void setRegion( int region ) { m_regionNumber = (int16_t)region; } void setAquiferNumber( int aquiferNumber ) { m_aquiferNumber = (int16_t)aquiferNumber; } void setCellIjk( const std::string& uiText ); @@ -208,7 +206,7 @@ class RifEclipseSummaryAddress bool hasAccumulatedData() const; - static std::string baseQuantityName( const std::string& quantityName ); + static std::string baseVectorName( const std::string& vectorName ); private: static RifEclipseSummaryAddress fromTokens( const std::vector& tokens ); @@ -218,8 +216,8 @@ class RifEclipseSummaryAddress std::string formatUiTextRegionToRegion() const; std::pair regionToRegionPairFromUiText( const std::string& s ); - std::string m_quantityName; - std::string m_wellGroupName; + std::string m_vectorName; + std::string m_groupName; std::string m_wellName; std::string m_lgrName; int32_t m_cellI; diff --git a/ApplicationLibCode/FileInterface/RifEclipseSummaryTools.cpp b/ApplicationLibCode/FileInterface/RifEclipseSummaryTools.cpp index f51ad56962..d414f37d10 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseSummaryTools.cpp +++ b/ApplicationLibCode/FileInterface/RifEclipseSummaryTools.cpp @@ -20,7 +20,7 @@ #include "RiaFilePathTools.h" #include "RiaStringEncodingTools.h" -#include "RiaSummaryCurveAnalyzer.h" +#include "RiaSummaryAddressAnalyzer.h" #include "RifSummaryReaderInterface.h" #include "cafAppEnum.h" @@ -142,7 +142,7 @@ void RifEclipseSummaryTools::dumpMetaData( RifSummaryReaderInterface* readerEcli RifEclipseSummaryAddress::SummaryVarCategory( category ); std::vector catAddresses = - RiaSummaryCurveAnalyzer::addressesForCategory( addresses, categoryEnum ); + RiaSummaryAddressAnalyzer::addressesForCategory( addresses, categoryEnum ); if ( !catAddresses.empty() ) { @@ -151,8 +151,8 @@ void RifEclipseSummaryTools::dumpMetaData( RifSummaryReaderInterface* readerEcli for ( const auto& catAddresse : catAddresses ) { - std::cout << catAddresse.quantityName() << " " << catAddresse.regionNumber() << " " - << catAddresse.regionNumber2() << " " << catAddresse.wellGroupName() << " " + std::cout << catAddresse.vectorName() << " " << catAddresse.regionNumber() << " " + << catAddresse.regionNumber2() << " " << catAddresse.groupName() << " " << catAddresse.wellName() << " " << catAddresse.wellSegmentNumber() << " " << catAddresse.lgrName() << " " << catAddresse.cellI() << " " << catAddresse.cellJ() << " " << catAddresse.cellK() << std::endl; diff --git a/ApplicationLibCode/FileInterface/RifEclipseTextFileReader.cpp b/ApplicationLibCode/FileInterface/RifEclipseTextFileReader.cpp index d42d186349..a9e3ce0525 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseTextFileReader.cpp +++ b/ApplicationLibCode/FileInterface/RifEclipseTextFileReader.cpp @@ -88,6 +88,11 @@ std::pair> { std::vector values; + auto isKeywordWithoutData = []( const std::string& keyword ) { + std::vector keywords = { "ECHO", "NOECHO" }; + return std::find( keywords.begin(), keywords.end(), keyword ) != keywords.end(); + }; + const auto commentChar = '-'; const auto commentString = "--"; @@ -133,7 +138,9 @@ std::pair> { keywordName = line; if ( keywordName == "FAULTS" ) isFaultKeyword = true; + if ( isKeywordWithoutData( keywordName ) ) isEndTokenKeywordRead = true; } + continue; } diff --git a/ApplicationLibCode/FileInterface/RifEclipseUserDataKeywordTools.cpp b/ApplicationLibCode/FileInterface/RifEclipseUserDataKeywordTools.cpp index 36912a1381..f73b1303c1 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseUserDataKeywordTools.cpp +++ b/ApplicationLibCode/FileInterface/RifEclipseUserDataKeywordTools.cpp @@ -23,6 +23,8 @@ #include "RifEclipseUserDataParserTools.h" +#include "RiuSummaryQuantityNameInfoProvider.h" + #include //-------------------------------------------------------------------------------------------------- @@ -164,7 +166,8 @@ bool RifEclipseUserDataKeywordTools::isYearX( const std::string& identifier ) RifEclipseSummaryAddress RifEclipseUserDataKeywordTools::makeAndFillAddress( const std::string quantityName, const std::vector& columnHeaderText ) { - RifEclipseSummaryAddress::SummaryVarCategory category = RifEclipseSummaryAddress::identifyCategory( quantityName ); + RifEclipseSummaryAddress::SummaryVarCategory category = + RiuSummaryQuantityNameInfoProvider::instance()->identifyCategory( quantityName ); if ( category == RifEclipseSummaryAddress::SUMMARY_INVALID ) { @@ -173,7 +176,7 @@ RifEclipseSummaryAddress RifEclipseUserDataKeywordTools::makeAndFillAddress( con int regionNumber = -1; int regionNumber2 = -1; - std::string wellGroupName = ""; + std::string groupName = ""; std::string wellName = ""; int wellSegmentNumber = -1; std::string lgrName = ""; @@ -210,11 +213,11 @@ RifEclipseSummaryAddress RifEclipseUserDataKeywordTools::makeAndFillAddress( con } case RifEclipseSummaryAddress::SUMMARY_REGION_2_REGION: break; - case RifEclipseSummaryAddress::SUMMARY_WELL_GROUP: + case RifEclipseSummaryAddress::SUMMARY_GROUP: { if ( columnHeaderText.size() > 0 ) { - wellGroupName = columnHeaderText[0]; + groupName = columnHeaderText[0]; } break; } @@ -284,7 +287,7 @@ RifEclipseSummaryAddress RifEclipseUserDataKeywordTools::makeAndFillAddress( con quantityName, regionNumber, regionNumber2, - wellGroupName, + groupName, wellName, wellSegmentNumber, lgrName, @@ -322,7 +325,7 @@ size_t RifEclipseUserDataKeywordTools::computeRequiredHeaderLineCount( const std } } - // Quantity and unit, scaling is optional + // Vector name and unit, scaling is optional return 1 + maxHeaderLinesFromKeywords; } diff --git a/ApplicationLibCode/FileInterface/RifEclipseUserDataParserTools.cpp b/ApplicationLibCode/FileInterface/RifEclipseUserDataParserTools.cpp index 6b3f620d6e..9e7eae7e5e 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseUserDataParserTools.cpp +++ b/ApplicationLibCode/FileInterface/RifEclipseUserDataParserTools.cpp @@ -32,6 +32,7 @@ #include #include +#include #include //-------------------------------------------------------------------------------------------------- @@ -186,7 +187,9 @@ bool RifEclipseUserDataParserTools::isANumber( const std::string& line ) { try { - std::stod( line ); + auto value = std::stod( line ); + if ( std::isinf( value ) || std::isnan( value ) ) return false; + return true; } catch ( ... ) { @@ -427,17 +430,17 @@ TableData RifEclipseUserDataParserTools::tableDataFromText( std::stringstream& continue; } - std::string quantity = columnText[0]; - std::string unit = unitNames[i]; + std::string vectorName = columnText[0]; + std::string unit = unitNames[i]; std::vector columnHeader; if ( columnText.size() > 1 ) columnHeader.insert( columnHeader.begin(), columnText.begin() + 1, columnText.end() ); - RifEclipseSummaryAddress adr = RifEclipseUserDataKeywordTools::makeAndFillAddress( quantity, columnHeader ); + RifEclipseSummaryAddress adr = RifEclipseUserDataKeywordTools::makeAndFillAddress( vectorName, columnHeader ); - Column ci = Column::createColumnInfoFromRsmData( quantity, unit, adr ); + Column ci = Column::createColumnInfoFromRsmData( vectorName, unit, adr ); columnInfos.push_back( ci ); } @@ -664,7 +667,7 @@ std::vector { if ( columnLines.size() == 0 ) continue; - std::string quantity = columnLines[0]; + std::string vectorName = columnLines[0]; std::string unit; size_t startIndex = 1; @@ -689,9 +692,9 @@ std::vector restOfHeader.push_back( columnLines[i] ); } - RifEclipseSummaryAddress adr = RifEclipseUserDataKeywordTools::makeAndFillAddress( quantity, restOfHeader ); + RifEclipseSummaryAddress adr = RifEclipseUserDataKeywordTools::makeAndFillAddress( vectorName, restOfHeader ); - Column ci = Column::createColumnInfoFromRsmData( quantity, unit, adr ); + Column ci = Column::createColumnInfoFromRsmData( vectorName, unit, adr ); table.push_back( ci ); } @@ -733,7 +736,7 @@ std::vector RifEclipseUserDataParserTools::mergeEqualTimeSteps( const QDateTime firstTableStartTime; for ( auto c : tables[0].columnInfos() ) { - if ( c.summaryAddress.quantityName() == "DATE" ) + if ( c.summaryAddress.vectorName() == "DATE" ) { if ( c.itemCount() > 0 ) { @@ -763,7 +766,7 @@ std::vector RifEclipseUserDataParserTools::mergeEqualTimeSteps( const QDateTime tableFirstTime; for ( auto& c : tables[i].columnInfos() ) { - if ( c.summaryAddress.quantityName() == "DATE" ) + if ( c.summaryAddress.vectorName() == "DATE" ) { if ( c.itemCount() > 0 ) { @@ -783,7 +786,7 @@ std::vector RifEclipseUserDataParserTools::mergeEqualTimeSteps( const { for ( auto& c : tables[i].columnInfos() ) { - if ( c.summaryAddress.quantityName() != "DATE" ) + if ( c.summaryAddress.vectorName() != "DATE" ) { firstTable.columnInfos().push_back( c ); } @@ -863,17 +866,17 @@ size_t Column::itemCount() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -Column Column::createColumnInfoFromRsmData( const std::string& quantity, +Column Column::createColumnInfoFromRsmData( const std::string& vectorName, const std::string& unit, const RifEclipseSummaryAddress& addr ) { Column ci( addr, unit ); - if ( RifEclipseUserDataKeywordTools::isDate( quantity ) ) + if ( RifEclipseUserDataKeywordTools::isDate( vectorName ) ) { ci.dataType = TEXT; } - else if ( RifEclipseUserDataKeywordTools::isStepType( quantity ) ) + else if ( RifEclipseUserDataKeywordTools::isStepType( vectorName ) ) { ci.dataType = TEXT; } @@ -921,7 +924,7 @@ QDateTime TableData::findFirstDate() const for ( auto ci : m_columnInfos ) { - if ( RifEclipseUserDataKeywordTools::isDate( ci.summaryAddress.quantityName() ) ) + if ( RifEclipseUserDataKeywordTools::isDate( ci.summaryAddress.vectorName() ) ) { if ( ci.itemCount() > 0 ) { diff --git a/ApplicationLibCode/FileInterface/RifEclipseUserDataParserTools.h b/ApplicationLibCode/FileInterface/RifEclipseUserDataParserTools.h index cf0d52bda5..8f1685b256 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseUserDataParserTools.h +++ b/ApplicationLibCode/FileInterface/RifEclipseUserDataParserTools.h @@ -60,7 +60,7 @@ class Column size_t itemCount() const; public: - static Column createColumnInfoFromRsmData( const std::string& quantity, + static Column createColumnInfoFromRsmData( const std::string& vectorName, const std::string& unit, const RifEclipseSummaryAddress& addr ); static Column createColumnInfoFromCsvData( const RifEclipseSummaryAddress& addr, const std::string& unit ); diff --git a/ApplicationLibCode/FileInterface/RifEnsembleFractureStatisticsExporter.cpp b/ApplicationLibCode/FileInterface/RifEnsembleFractureStatisticsExporter.cpp index a220691015..878bd10c3e 100644 --- a/ApplicationLibCode/FileInterface/RifEnsembleFractureStatisticsExporter.cpp +++ b/ApplicationLibCode/FileInterface/RifEnsembleFractureStatisticsExporter.cpp @@ -18,11 +18,10 @@ #include "RifEnsembleFractureStatisticsExporter.h" -// #include "RiaEclipseUnitTools.h" - -// #include "RimStimPlanModel.h" #include "RiaDefines.h" #include "RigSlice2D.h" + +#include "caf.h" #include "cafAssert.h" #include @@ -61,7 +60,7 @@ bool RifEnsembleFractureStatisticsExporter::writeAsStimPlanXml( const std::vecto //-------------------------------------------------------------------------------------------------- void RifEnsembleFractureStatisticsExporter::appendHeaderToStream( QTextStream& stream ) { - stream << "" << endl << "" << endl; + stream << "" << caf::endl << "" << caf::endl; } //-------------------------------------------------------------------------------------------------- @@ -76,15 +75,15 @@ void RifEnsembleFractureStatisticsExporter::appendPropertiesToStream( { CAF_ASSERT( statistics.size() == properties.size() ); - stream << "" << endl; + stream << "" << caf::endl; for ( size_t s = 0; s < statistics.size(); s++ ) { QString propertyName = properties[s].first; QString propertyUnit = properties[s].second; - stream << QString( "" ).arg( propertyName ).arg( propertyUnit ) << endl; - stream << QString( "" << caf::endl; + stream << "" << caf::endl; } - stream << "" << endl; + stream << "" << caf::endl; } //-------------------------------------------------------------------------------------------------- @@ -116,7 +115,7 @@ void RifEnsembleFractureStatisticsExporter::appendOrientationToStream( QTextStre if ( orientation != RigStimPlanFractureDefinition::Orientation::UNDEFINED ) { QString orientationString = getStringForOrientation( orientation ); - stream << QString( "%1" ).arg( orientationString ) << endl; + stream << QString( "%1" ).arg( orientationString ) << caf::endl; } } @@ -130,19 +129,19 @@ void RifEnsembleFractureStatisticsExporter::appendGridDimensionsToStream( QTextS { QString unitString = getStringForUnitSystem( unitSystem ); stream << QString( "" ).arg( gridXs.size() ).arg( gridYs.size() ).arg( unitString ) - << endl; + << caf::endl; stream << "["; for ( auto x : gridXs ) stream << x << " "; - stream << "]" << endl; + stream << "]" << caf::endl; stream << "["; for ( auto y : gridYs ) stream << y << " "; - stream << "]" << endl; + stream << "]" << caf::endl; - stream << "" << endl; + stream << "" << caf::endl; } //-------------------------------------------------------------------------------------------------- @@ -150,7 +149,7 @@ void RifEnsembleFractureStatisticsExporter::appendGridDimensionsToStream( QTextS //-------------------------------------------------------------------------------------------------- void RifEnsembleFractureStatisticsExporter::appendFooterToStream( QTextStream& stream ) { - stream << "" << endl; + stream << "" << caf::endl; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/FileInterface/RifEnsembleStatisticsReader.cpp b/ApplicationLibCode/FileInterface/RifEnsembleStatisticsReader.cpp index f3a88870a7..e70c9fe7ff 100644 --- a/ApplicationLibCode/FileInterface/RifEnsembleStatisticsReader.cpp +++ b/ApplicationLibCode/FileInterface/RifEnsembleStatisticsReader.cpp @@ -57,7 +57,7 @@ bool RifEnsembleStatisticsReader::values( const RifEclipseSummaryAddress& result if ( !validateAddress( resultAddress ) ) return false; const std::vector* sourceData = nullptr; - auto quantityName = resultAddress.ensembleStatisticsQuantityName(); + auto quantityName = resultAddress.ensembleStatisticsVectorName(); if ( quantityName == ENSEMBLE_STAT_P10_QUANTITY_NAME ) sourceData = &m_ensembleStatCase->p10(); @@ -88,12 +88,11 @@ std::string RifEnsembleStatisticsReader::unitName( const RifEclipseSummaryAddres auto cases = m_ensembleStatCase->curveSet()->summaryCaseCollection()->allSummaryCases(); if ( cases.size() > 0 ) { - // get rid of the stats part of the quantity name - QString qName = QString::fromStdString( resultAddress.quantityName() ); + QString qName = QString::fromStdString( resultAddress.vectorName() ); std::string orgQName = qName.split( ":" )[1].toStdString(); RifEclipseSummaryAddress address = RifEclipseSummaryAddress( resultAddress ); - address.setQuantityName( orgQName ); + address.setVectorName( orgQName ); retval = cases[0]->summaryReader()->unitName( address ); } @@ -114,5 +113,5 @@ RiaDefines::EclipseUnitSystem RifEnsembleStatisticsReader::unitSystem() const //-------------------------------------------------------------------------------------------------- bool RifEnsembleStatisticsReader::validateAddress( const RifEclipseSummaryAddress& address ) const { - return address.category() == RifEclipseSummaryAddress::SUMMARY_ENSEMBLE_STATISTICS && !address.quantityName().empty(); + return address.category() == RifEclipseSummaryAddress::SUMMARY_ENSEMBLE_STATISTICS && !address.vectorName().empty(); } diff --git a/ApplicationLibCode/FileInterface/RifFaultRAJsonWriter.cpp b/ApplicationLibCode/FileInterface/RifFaultRAJsonWriter.cpp index 23630bcf28..712f3b9407 100644 --- a/ApplicationLibCode/FileInterface/RifFaultRAJsonWriter.cpp +++ b/ApplicationLibCode/FileInterface/RifFaultRAJsonWriter.cpp @@ -23,6 +23,8 @@ #include "RimGenericParameter.h" #include "RimParameterGroup.h" +#include "caf.h" + #include #include @@ -40,12 +42,12 @@ bool RifFaultRAJSonWriter::writeToPreprocFile( RimFaultRAPreprocSettings& settin { QTextStream stream( &file ); - stream << "{" << endl; - stream << "\"odb_path\": \"" + settings.geomechCaseFilename() + "\"," << endl; - stream << "\"time_start\": \"" + settings.startTimeStepGeoMech() + "\"," << endl; - stream << "\"time_end\": \"" + settings.endTimeStepGeoMech() + "\"," << endl; - stream << "\"out_path\": \"" + settings.outputAbaqusDirectory() + "\"" << endl; - stream << "}" << endl; + stream << "{" << caf::endl; + stream << "\"odb_path\": \"" + settings.geomechCaseFilename() + "\"," << caf::endl; + stream << "\"time_start\": \"" + settings.startTimeStepGeoMech() + "\"," << caf::endl; + stream << "\"time_end\": \"" + settings.endTimeStepGeoMech() + "\"," << caf::endl; + stream << "\"out_path\": \"" + settings.outputAbaqusDirectory() + "\"" << caf::endl; + stream << "}" << caf::endl; file.close(); } @@ -73,26 +75,26 @@ bool RifFaultRAJSonWriter::writeToPostprocFile( int faultID, RimFaultRAPostprocS { QTextStream stream( &file ); - stream << "{" << endl; + stream << "{" << caf::endl; if ( settings->geomechEnabled() ) { if ( QFile::exists( settings->advancedMacrisDatabase() ) ) - stream << "\"MacrisCalcCalibration_path\": \"" + settings->advancedMacrisDatabase() + "\"," << endl; + stream << "\"MacrisCalcCalibration_path\": \"" + settings->advancedMacrisDatabase() + "\"," << caf::endl; } if ( QFile::exists( settings->basicMacrisDatabase() ) ) - stream << "\"MacrisCalc_path\": \"" + settings->basicMacrisDatabase() + "\"," << endl; + stream << "\"MacrisCalc_path\": \"" + settings->basicMacrisDatabase() + "\"," << caf::endl; - stream << "\"base_directory_path\": \"" + settings->outputBaseDirectory() + "\"," << endl; + stream << "\"base_directory_path\": \"" + settings->outputBaseDirectory() + "\"," << caf::endl; for ( auto p : settings->parameters()->parameters() ) { - stream << "\"" + p->name() + "\" : " + p->stringValue() + "," << endl; + stream << "\"" + p->name() + "\" : " + p->stringValue() + "," << caf::endl; } - stream << "\"tsurf_loadsteps\": [ " + settings->stepsToLoad().join( ',' ) + " ]" << endl; - stream << "}" << endl; + stream << "\"tsurf_loadsteps\": [ " + settings->stepsToLoad().join( ',' ) + " ]" << caf::endl; + stream << "}" << caf::endl; file.close(); } diff --git a/ApplicationLibCode/FileInterface/RifFaultRAXmlWriter.cpp b/ApplicationLibCode/FileInterface/RifFaultRAXmlWriter.cpp index 282b3ace13..801a067e29 100644 --- a/ApplicationLibCode/FileInterface/RifFaultRAXmlWriter.cpp +++ b/ApplicationLibCode/FileInterface/RifFaultRAXmlWriter.cpp @@ -21,6 +21,8 @@ #include "RimFaultRASettings.h" #include "RimGenericParameter.h" +#include "caf.h" + #include #include @@ -56,15 +58,15 @@ bool RifFaultRAXmlWriter::writeParametersToXML( QString filename, std::list" << endl; - stream << "" << endl; + stream << "" << caf::endl; + stream << "" << caf::endl; for ( auto& p : params ) { QString tmpStr = QString( "<%1>%2" ).arg( p->name(), p->stringValue() ); - stream << tmpStr << endl; + stream << tmpStr << caf::endl; } - stream << "" << endl; + stream << "" << caf::endl; bResult = true; } diff --git a/ApplicationLibCode/FileInterface/RifFileParseTools.cpp b/ApplicationLibCode/FileInterface/RifFileParseTools.cpp index ca7d4e6884..c355bb6f24 100644 --- a/ApplicationLibCode/FileInterface/RifFileParseTools.cpp +++ b/ApplicationLibCode/FileInterface/RifFileParseTools.cpp @@ -18,6 +18,10 @@ #include "RifFileParseTools.h" +// Disable deprecation warning for QString::SkipEmptyParts +#ifdef _MSC_VER +#pragma warning( disable : 4996 ) +#endif //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/FileInterface/RifHdf5SummaryReader.cpp b/ApplicationLibCode/FileInterface/RifHdf5SummaryReader.cpp index 42ecef91ac..d7f558f089 100644 --- a/ApplicationLibCode/FileInterface/RifHdf5SummaryReader.cpp +++ b/ApplicationLibCode/FileInterface/RifHdf5SummaryReader.cpp @@ -90,24 +90,24 @@ std::vector RifHdf5SummaryReader::timeSteps() const double time_unit = 24 * 3600; using namespace std::chrono; - using TP = time_point; using DoubSec = duration; + using TP = time_point; auto timeDeltasInDays = values( "TIME" ); - std::vector timePoints; + // Add custom method to convert from time_point to time_t. The usual implementation of + // chrono::system_clock::to_time_t() uses nanoseconds which will overflow on data with + // long time spans. + auto convertTimePointToTimeT = []( const TP& value ) { + return std::chrono::duration_cast( value.time_since_epoch() ).count(); + }; - TP startDat = std::chrono::system_clock::from_time_t( startDate() ); + auto startDat = std::chrono::system_clock::from_time_t( startDate() ); - timePoints.reserve( timeDeltasInDays.size() ); for ( const auto& t : timeDeltasInDays ) { - timePoints.push_back( startDat + duration_cast( DoubSec( t * time_unit ) ) ); - } - - for ( const auto& d : timePoints ) - { - auto timeAsTimeT = std::chrono::system_clock::to_time_t( d ); + TP timePoint = startDat + duration_cast( DoubSec( t * time_unit ) ); + std::time_t timeAsTimeT = convertTimePointToTimeT( timePoint ); times.push_back( timeAsTimeT ); } diff --git a/ApplicationLibCode/FileInterface/RifOpmCommonSummary.cpp b/ApplicationLibCode/FileInterface/RifOpmCommonSummary.cpp index e58a1495fb..f4548c79e0 100644 --- a/ApplicationLibCode/FileInterface/RifOpmCommonSummary.cpp +++ b/ApplicationLibCode/FileInterface/RifOpmCommonSummary.cpp @@ -19,6 +19,7 @@ #include "RifOpmCommonSummary.h" #include "RiaLogging.h" +#include "RiaStdStringTools.h" #include "opm/io/eclipse/ESmry.hpp" #include "opm/io/eclipse/ExtESmry.hpp" @@ -156,22 +157,22 @@ bool RifOpmCommonEclipseSummary::values( const RifEclipseSummaryAddress& resultA //-------------------------------------------------------------------------------------------------- std::string RifOpmCommonEclipseSummary::unitName( const RifEclipseSummaryAddress& resultAddress ) const { - auto it = m_summaryAddressToKeywordMap.find( resultAddress ); + std::string nameString; + auto it = m_summaryAddressToKeywordMap.find( resultAddress ); if ( it != m_summaryAddressToKeywordMap.end() ) { auto keyword = it->second; if ( m_enhancedReader ) { - return m_enhancedReader->get_unit( keyword ); + nameString = m_enhancedReader->get_unit( keyword ); } - - if ( m_standardReader ) + else if ( m_standardReader ) { - return m_standardReader->get_unit( keyword ); + nameString = m_standardReader->get_unit( keyword ); } } - return {}; + return RiaStdStringTools::trimString( nameString ); } //-------------------------------------------------------------------------------------------------- @@ -291,7 +292,7 @@ RifEclipseSummaryAddress RifOpmCommonSummaryTools::createAddressFromSummaryNode( return RifEclipseSummaryAddress::wellAddress( summaryNode.keyword, summaryNode.wgname ); break; case Opm::EclIO::SummaryNode::Category::Group: - return RifEclipseSummaryAddress::wellGroupAddress( summaryNode.keyword, summaryNode.wgname ); + return RifEclipseSummaryAddress::groupAddress( summaryNode.keyword, summaryNode.wgname ); break; case Opm::EclIO::SummaryNode::Category::Field: return RifEclipseSummaryAddress::fieldAddress( summaryNode.keyword ); @@ -327,7 +328,7 @@ RifEclipseSummaryAddress RifOpmCommonSummaryTools::createAddressFromSummaryNode( // The vector "GPR" is defined as Node // The behavior in libecl is to use the category Group // https://github.com/OPM/ResInsight/issues/7838 - return RifEclipseSummaryAddress::wellGroupAddress( summaryNode.keyword, summaryNode.wgname ); + return RifEclipseSummaryAddress::groupAddress( summaryNode.keyword, summaryNode.wgname ); break; case Opm::EclIO::SummaryNode::Category::Network: return RifEclipseSummaryAddress::networkAddress( summaryNode.keyword ); @@ -394,32 +395,49 @@ std::pair, std::map invalidKeywords; - for ( const auto& keyword : keywords ) +#pragma omp parallel { - auto eclAdr = RifEclipseSummaryAddress::fromEclipseTextAddress( keyword ); - if ( !eclAdr.isValid() ) + std::set threadAddresses; + std::map threadAddressToNodeIndexMap; + std::vector threadInvalidKeywords; + +#pragma omp for + for ( int index = 0; index < (int)keywords.size(); index++ ) { - invalidKeywords.push_back( keyword ); + auto keyword = keywords[index]; - // If a category is not found, use the MISC category - eclAdr = RifEclipseSummaryAddress::miscAddress( keyword ); - } + auto eclAdr = RifEclipseSummaryAddress::fromEclipseTextAddress( keyword ); + if ( !eclAdr.isValid() ) + { + threadInvalidKeywords.push_back( keyword ); - if ( eclAdr.isValid() ) - { - addresses.insert( eclAdr ); - addressToNodeIndexMap[eclAdr] = keyword; + // If a category is not found, use the MISC category + eclAdr = RifEclipseSummaryAddress::miscAddress( keyword ); + } + + if ( eclAdr.isValid() ) + { + threadAddresses.insert( eclAdr ); + threadAddressToNodeIndexMap[eclAdr] = keyword; + } } - } - // DEBUG code - // Used to print keywords not being categorized correctly - /* - for ( const auto& kw : invalidKeywords ) +#pragma omp critical { - RiaLogging::warning( QString::fromStdString( kw ) ); + addresses.insert( threadAddresses.begin(), threadAddresses.end() ); + addressToNodeIndexMap.insert( threadAddressToNodeIndexMap.begin(), threadAddressToNodeIndexMap.end() ); + invalidKeywords.insert( invalidKeywords.end(), threadInvalidKeywords.begin(), threadInvalidKeywords.end() ); } - */ + + // DEBUG code + // Used to print keywords not being categorized correctly + /* + for ( const auto& kw : invalidKeywords ) + { + RiaLogging::warning( QString::fromStdString( kw ) ); + } + */ + } return { addresses, addressToNodeIndexMap }; } diff --git a/ApplicationLibCode/FileInterface/RifOpmHdf5Summary.cpp b/ApplicationLibCode/FileInterface/RifOpmHdf5Summary.cpp index 369e02c351..216e6291c4 100644 --- a/ApplicationLibCode/FileInterface/RifOpmHdf5Summary.cpp +++ b/ApplicationLibCode/FileInterface/RifOpmHdf5Summary.cpp @@ -19,6 +19,7 @@ #include "RifOpmHdf5Summary.h" #include "RiaLogging.h" +#include "RiaStdStringTools.h" #include "RifHdf5SummaryReader.h" #include "RifOpmCommonSummary.h" @@ -101,7 +102,7 @@ bool RifOpmHdf5Summary::values( const RifEclipseSummaryAddress& resultAddress, s auto node = m_eSmry->summaryNodeList()[index]; int smspecIndex = static_cast( node.smspecKeywordIndex ); - const auto& vectorName = resultAddress.quantityName(); + const auto& vectorName = resultAddress.vectorName(); *values = m_hdf5Reader->values( vectorName, smspecIndex ); @@ -125,10 +126,8 @@ std::string RifOpmHdf5Summary::unitName( const RifEclipseSummaryAddress& resultA auto index = it->second; auto node = m_eSmry->summaryNodeList()[index]; - if ( m_eSmry->hasKey( node.keyword ) ) - { - return m_eSmry->get_unit( node ); - } + auto stringFromFileReader = m_eSmry->get_unit( node ); + return RiaStdStringTools::trimString( stringFromFileReader ); } } diff --git a/ApplicationLibCode/FileInterface/RifOpmHdf5Summary.h b/ApplicationLibCode/FileInterface/RifOpmHdf5Summary.h index 366eb78e8a..0e819d0756 100644 --- a/ApplicationLibCode/FileInterface/RifOpmHdf5Summary.h +++ b/ApplicationLibCode/FileInterface/RifOpmHdf5Summary.h @@ -67,7 +67,6 @@ class RifOpmHdf5Summary : public RifSummaryReaderInterface private: std::unique_ptr m_eSmry; - std::vector m_eSmryKeywords; std::map m_adrToSummaryNodeIndex; std::vector m_timeSteps; diff --git a/ApplicationLibCode/FileInterface/RifPerforationIntervalReader.cpp b/ApplicationLibCode/FileInterface/RifPerforationIntervalReader.cpp index aa807ad5a5..c52bdb53e9 100644 --- a/ApplicationLibCode/FileInterface/RifPerforationIntervalReader.cpp +++ b/ApplicationLibCode/FileInterface/RifPerforationIntervalReader.cpp @@ -18,6 +18,8 @@ #include "RifPerforationIntervalReader.h" +#include "RiaTextStringTools.h" + #include #include @@ -79,7 +81,7 @@ void RifPerforationIntervalReader::readFileIntoMap( const QString& // Replace any tabs with spaces to enable splitting on spaces line.replace( "\t", " " ); - QStringList parts = line.split( " ", QString::SkipEmptyParts ); + QStringList parts = RiaTextStringTools::splitSkipEmptyParts( line ); if ( line.startsWith( "WELLNAME" ) ) { diff --git a/ApplicationLibCode/FileInterface/RifReaderEclipseRft.cpp b/ApplicationLibCode/FileInterface/RifReaderEclipseRft.cpp index 152e43c26b..54873a3cd1 100644 --- a/ApplicationLibCode/FileInterface/RifReaderEclipseRft.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderEclipseRft.cpp @@ -89,39 +89,47 @@ void RifReaderEclipseRft::open() QDateTime timeStep = RiaQDateTimeTools::createUtcDateTime(); timeStep.setTime_t( timeStepTime_t ); - RifEclipseRftAddress addressPressure( wellName, timeStep, RifEclipseRftAddress::PRESSURE ); + RifEclipseRftAddress addressPressure = + RifEclipseRftAddress::createAddress( wellName, timeStep, RifEclipseRftAddress::RftWellLogChannelType::PRESSURE ); m_eclipseRftAddresses.insert( addressPressure ); m_rftAddressToLibeclNodeIdx[addressPressure] = i; - RifEclipseRftAddress addressDepth( wellName, timeStep, RifEclipseRftAddress::TVD ); + RifEclipseRftAddress addressDepth = + RifEclipseRftAddress::createAddress( wellName, timeStep, RifEclipseRftAddress::RftWellLogChannelType::TVD ); m_eclipseRftAddresses.insert( addressDepth ); m_rftAddressToLibeclNodeIdx[addressDepth] = i; if ( ecl_rft_node_is_RFT( node ) ) { - RifEclipseRftAddress addressSwat( wellName, timeStep, RifEclipseRftAddress::SWAT ); + RifEclipseRftAddress addressSwat = + RifEclipseRftAddress::createAddress( wellName, timeStep, RifEclipseRftAddress::RftWellLogChannelType::SWAT ); m_eclipseRftAddresses.insert( addressSwat ); m_rftAddressToLibeclNodeIdx[addressSwat] = i; - RifEclipseRftAddress addressSoil( wellName, timeStep, RifEclipseRftAddress::SOIL ); + RifEclipseRftAddress addressSoil = + RifEclipseRftAddress::createAddress( wellName, timeStep, RifEclipseRftAddress::RftWellLogChannelType::SOIL ); m_eclipseRftAddresses.insert( addressSoil ); m_rftAddressToLibeclNodeIdx[addressSoil] = i; - RifEclipseRftAddress addressSgas( wellName, timeStep, RifEclipseRftAddress::SGAS ); + RifEclipseRftAddress addressSgas = + RifEclipseRftAddress::createAddress( wellName, timeStep, RifEclipseRftAddress::RftWellLogChannelType::SGAS ); m_eclipseRftAddresses.insert( addressSgas ); m_rftAddressToLibeclNodeIdx[addressSgas] = i; } else if ( ecl_rft_node_is_PLT( node ) ) { - RifEclipseRftAddress addressWrat( wellName, timeStep, RifEclipseRftAddress::WRAT ); + RifEclipseRftAddress addressWrat = + RifEclipseRftAddress::createAddress( wellName, timeStep, RifEclipseRftAddress::RftWellLogChannelType::WRAT ); m_eclipseRftAddresses.insert( addressWrat ); m_rftAddressToLibeclNodeIdx[addressWrat] = i; - RifEclipseRftAddress addressOrat( wellName, timeStep, RifEclipseRftAddress::ORAT ); + RifEclipseRftAddress addressOrat = + RifEclipseRftAddress::createAddress( wellName, timeStep, RifEclipseRftAddress::RftWellLogChannelType::ORAT ); m_eclipseRftAddresses.insert( addressOrat ); m_rftAddressToLibeclNodeIdx[addressOrat] = i; - RifEclipseRftAddress addressGrat( wellName, timeStep, RifEclipseRftAddress::GRAT ); + RifEclipseRftAddress addressGrat = + RifEclipseRftAddress::createAddress( wellName, timeStep, RifEclipseRftAddress::RftWellLogChannelType::GRAT ); m_eclipseRftAddresses.insert( addressGrat ); m_rftAddressToLibeclNodeIdx[addressGrat] = i; } @@ -166,7 +174,7 @@ void RifReaderEclipseRft::values( const RifEclipseRftAddress& rftAddress, std::v switch ( wellLogChannelName ) { - case RifEclipseRftAddress::TVD: + case RifEclipseRftAddress::RftWellLogChannelType::TVD: { for ( int i = 0; i < ecl_rft_node_get_size( node ); i++ ) { @@ -174,7 +182,7 @@ void RifReaderEclipseRft::values( const RifEclipseRftAddress& rftAddress, std::v } break; } - case RifEclipseRftAddress::PRESSURE: + case RifEclipseRftAddress::RftWellLogChannelType::PRESSURE: { for ( int i = 0; i < ecl_rft_node_get_size( node ); i++ ) { @@ -182,7 +190,7 @@ void RifReaderEclipseRft::values( const RifEclipseRftAddress& rftAddress, std::v } break; } - case RifEclipseRftAddress::SWAT: + case RifEclipseRftAddress::RftWellLogChannelType::SWAT: { for ( int i = 0; i < ecl_rft_node_get_size( node ); i++ ) { @@ -190,7 +198,7 @@ void RifReaderEclipseRft::values( const RifEclipseRftAddress& rftAddress, std::v } break; } - case RifEclipseRftAddress::SOIL: + case RifEclipseRftAddress::RftWellLogChannelType::SOIL: { for ( int i = 0; i < ecl_rft_node_get_size( node ); i++ ) { @@ -198,7 +206,7 @@ void RifReaderEclipseRft::values( const RifEclipseRftAddress& rftAddress, std::v } break; } - case RifEclipseRftAddress::SGAS: + case RifEclipseRftAddress::RftWellLogChannelType::SGAS: { for ( int i = 0; i < ecl_rft_node_get_size( node ); i++ ) { @@ -206,7 +214,7 @@ void RifReaderEclipseRft::values( const RifEclipseRftAddress& rftAddress, std::v } break; } - case RifEclipseRftAddress::WRAT: + case RifEclipseRftAddress::RftWellLogChannelType::WRAT: { for ( int i = 0; i < ecl_rft_node_get_size( node ); i++ ) { @@ -214,7 +222,7 @@ void RifReaderEclipseRft::values( const RifEclipseRftAddress& rftAddress, std::v } break; } - case RifEclipseRftAddress::ORAT: + case RifEclipseRftAddress::RftWellLogChannelType::ORAT: { for ( int i = 0; i < ecl_rft_node_get_size( node ); i++ ) { @@ -222,7 +230,7 @@ void RifReaderEclipseRft::values( const RifEclipseRftAddress& rftAddress, std::v } break; } - case RifEclipseRftAddress::GRAT: + case RifEclipseRftAddress::RftWellLogChannelType::GRAT: { for ( int i = 0; i < ecl_rft_node_get_size( node ); i++ ) { @@ -351,7 +359,7 @@ std::set RifReaderEclipseRft::avail if ( !pressureFound ) { - if ( name == RifEclipseRftAddress::PRESSURE ) + if ( name == RifEclipseRftAddress::RftWellLogChannelType::PRESSURE ) { pressureFound = true; if ( rftFound && pltFound ) break; @@ -381,7 +389,7 @@ std::set RifReaderEclipseRft::avail if ( pressureFound ) { - wellLogChannelNames.insert( RifEclipseRftAddress::PRESSURE ); + wellLogChannelNames.insert( RifEclipseRftAddress::RftWellLogChannelType::PRESSURE ); } if ( rftFound ) { diff --git a/ApplicationLibCode/FileInterface/RifReaderEclipseRft.h b/ApplicationLibCode/FileInterface/RifReaderEclipseRft.h index 11352f874b..931ebaa0dd 100644 --- a/ApplicationLibCode/FileInterface/RifReaderEclipseRft.h +++ b/ApplicationLibCode/FileInterface/RifReaderEclipseRft.h @@ -45,7 +45,7 @@ class RifReaderEclipseRft : public RifReaderRftInterface, public cvf::Object std::set eclipseRftAddresses() override; void values( const RifEclipseRftAddress& rftAddress, std::vector* values ) override; - void cellIndices( const RifEclipseRftAddress& rftAddress, std::vector* indices ); + void cellIndices( const RifEclipseRftAddress& rftAddress, std::vector* indices ) override; std::set availableTimeSteps( const QString& wellName ) override; std::set diff --git a/ApplicationLibCode/FileInterface/RifReaderEclipseSummary.cpp b/ApplicationLibCode/FileInterface/RifReaderEclipseSummary.cpp index d27eaf034c..42af9effd9 100644 --- a/ApplicationLibCode/FileInterface/RifReaderEclipseSummary.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderEclipseSummary.cpp @@ -180,16 +180,16 @@ bool RifReaderEclipseSummary::values( const RifEclipseSummaryAddress& resultAddr if ( m_differenceAddresses.count( resultAddress ) ) { - const std::string& quantityName = resultAddress.quantityName(); + const std::string& quantityName = resultAddress.vectorName(); auto historyQuantity = quantityName.substr( 0, quantityName.size() - differenceIdentifier().size() ) + historyIdentifier(); RifEclipseSummaryAddress nativeAdrNoHistory = resultAddress; - nativeAdrNoHistory.setQuantityName( historyQuantity ); + nativeAdrNoHistory.setVectorName( historyQuantity ); auto quantityNoHistory = quantityName.substr( 0, historyQuantity.size() - 1 ); RifEclipseSummaryAddress nativeAdrHistory = resultAddress; - nativeAdrHistory.setQuantityName( quantityNoHistory ); + nativeAdrHistory.setVectorName( quantityNoHistory ); std::vector nativeValues; std::vector historyValues; @@ -259,11 +259,11 @@ void RifReaderEclipseSummary::buildMetaData() RifEclipseSummaryAddress adrWithoutHistory; { - const std::string& s = adr.quantityName(); + const std::string& s = adr.vectorName(); if ( !RiaStdStringTools::endsWith( s, historyIdentifier() ) ) { RifEclipseSummaryAddress candidate = adr; - candidate.setQuantityName( s + historyIdentifier() ); + candidate.setVectorName( s + historyIdentifier() ); if ( m_allResultAddresses.count( candidate ) ) { adrWithHistory = candidate; @@ -276,8 +276,8 @@ void RifReaderEclipseSummary::buildMetaData() { RifEclipseSummaryAddress candidate = adr; - std::string s = candidate.quantityName() + differenceIdentifier(); - candidate.setQuantityName( s ); + std::string s = candidate.vectorName() + differenceIdentifier(); + candidate.setVectorName( s ); m_allResultAddresses.insert( candidate ); m_differenceAddresses.insert( candidate ); @@ -302,8 +302,20 @@ RifSummaryReaderInterface* RifReaderEclipseSummary::currentSummaryReader() const std::string RifReaderEclipseSummary::unitName( const RifEclipseSummaryAddress& resultAddress ) const { auto reader = currentSummaryReader(); + if ( reader ) + { + auto nativeName = resultAddress.vectorName(); + auto stringToRemove = RifReaderEclipseSummary::differenceIdentifier(); + if ( RiaStdStringTools::endsWith( nativeName, stringToRemove ) ) + { + nativeName = nativeName.substr( 0, nativeName.size() - stringToRemove.size() ); + } + + RifEclipseSummaryAddress adr( resultAddress ); + adr.setVectorName( nativeName ); - if ( reader ) return reader->unitName( resultAddress ); + return reader->unitName( adr ); + } return ""; } diff --git a/ApplicationLibCode/FileInterface/RifReaderEnsembleStatisticsRft.cpp b/ApplicationLibCode/FileInterface/RifReaderEnsembleStatisticsRft.cpp index b47c0ef84d..427bab8558 100644 --- a/ApplicationLibCode/FileInterface/RifReaderEnsembleStatisticsRft.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderEnsembleStatisticsRft.cpp @@ -53,20 +53,21 @@ std::set RifReaderEnsembleStatisticsRft::eclipseRftAddress std::set statisticsAddresses; for ( const RifEclipseRftAddress& regularAddress : allAddresses ) { - if ( regularAddress.wellLogChannel() == RifEclipseRftAddress::TVD ) + if ( regularAddress.wellLogChannel() == RifEclipseRftAddress::RftWellLogChannelType::TVD ) { statisticsAddresses.insert( regularAddress ); } - else if ( regularAddress.wellLogChannel() == RifEclipseRftAddress::PRESSURE ) + else if ( regularAddress.wellLogChannel() == RifEclipseRftAddress::RftWellLogChannelType::PRESSURE ) { - std::set statChannels = { RifEclipseRftAddress::PRESSURE_P10, - RifEclipseRftAddress::PRESSURE_P50, - RifEclipseRftAddress::PRESSURE_P90, - RifEclipseRftAddress::PRESSURE_MEAN }; + std::set statChannels = + { RifEclipseRftAddress::RftWellLogChannelType::PRESSURE_P10, + RifEclipseRftAddress::RftWellLogChannelType::PRESSURE_P50, + RifEclipseRftAddress::RftWellLogChannelType::PRESSURE_P90, + RifEclipseRftAddress::RftWellLogChannelType::PRESSURE_MEAN }; for ( auto channel : statChannels ) { statisticsAddresses.insert( - RifEclipseRftAddress( regularAddress.wellName(), regularAddress.timeStep(), channel ) ); + RifEclipseRftAddress::createAddress( regularAddress.wellName(), regularAddress.timeStep(), channel ) ); } } } @@ -78,12 +79,12 @@ std::set RifReaderEnsembleStatisticsRft::eclipseRftAddress //-------------------------------------------------------------------------------------------------- void RifReaderEnsembleStatisticsRft::values( const RifEclipseRftAddress& rftAddress, std::vector* values ) { - CAF_ASSERT( rftAddress.wellLogChannel() == RifEclipseRftAddress::TVD || - rftAddress.wellLogChannel() == RifEclipseRftAddress::PRESSURE_MEAN || - rftAddress.wellLogChannel() == RifEclipseRftAddress::PRESSURE_P10 || - rftAddress.wellLogChannel() == RifEclipseRftAddress::PRESSURE_P50 || - rftAddress.wellLogChannel() == RifEclipseRftAddress::PRESSURE_P90 || - rftAddress.wellLogChannel() == RifEclipseRftAddress::PRESSURE_ERROR ); + CAF_ASSERT( rftAddress.wellLogChannel() == RifEclipseRftAddress::RftWellLogChannelType::TVD || + rftAddress.wellLogChannel() == RifEclipseRftAddress::RftWellLogChannelType::PRESSURE_MEAN || + rftAddress.wellLogChannel() == RifEclipseRftAddress::RftWellLogChannelType::PRESSURE_P10 || + rftAddress.wellLogChannel() == RifEclipseRftAddress::RftWellLogChannelType::PRESSURE_P50 || + rftAddress.wellLogChannel() == RifEclipseRftAddress::RftWellLogChannelType::PRESSURE_P90 || + rftAddress.wellLogChannel() == RifEclipseRftAddress::RftWellLogChannelType::PRESSURE_ERROR ); auto it = m_cachedValues.find( rftAddress ); if ( it == m_cachedValues.end() ) @@ -191,13 +192,19 @@ void RifReaderEnsembleStatisticsRft::calculateStatistics( const RifEclipseRftAdd { const QString& wellName = rftAddress.wellName(); const QDateTime& timeStep = rftAddress.timeStep(); - RifEclipseRftAddress depthAddress( wellName, timeStep, RifEclipseRftAddress::TVD ); - RifEclipseRftAddress pressAddress( wellName, timeStep, RifEclipseRftAddress::PRESSURE ); + RifEclipseRftAddress depthAddress = + RifEclipseRftAddress::createAddress( wellName, timeStep, RifEclipseRftAddress::RftWellLogChannelType::TVD ); + RifEclipseRftAddress pressAddress = + RifEclipseRftAddress::createAddress( wellName, timeStep, RifEclipseRftAddress::RftWellLogChannelType::PRESSURE ); - RifEclipseRftAddress p10Address( wellName, timeStep, RifEclipseRftAddress::PRESSURE_P10 ); - RifEclipseRftAddress p50Address( wellName, timeStep, RifEclipseRftAddress::PRESSURE_P50 ); - RifEclipseRftAddress p90Address( wellName, timeStep, RifEclipseRftAddress::PRESSURE_P90 ); - RifEclipseRftAddress meanAddress( wellName, timeStep, RifEclipseRftAddress::PRESSURE_MEAN ); + RifEclipseRftAddress p10Address = + RifEclipseRftAddress::createAddress( wellName, timeStep, RifEclipseRftAddress::RftWellLogChannelType::PRESSURE_P10 ); + RifEclipseRftAddress p50Address = + RifEclipseRftAddress::createAddress( wellName, timeStep, RifEclipseRftAddress::RftWellLogChannelType::PRESSURE_P50 ); + RifEclipseRftAddress p90Address = + RifEclipseRftAddress::createAddress( wellName, timeStep, RifEclipseRftAddress::RftWellLogChannelType::PRESSURE_P90 ); + RifEclipseRftAddress meanAddress = + RifEclipseRftAddress::createAddress( wellName, timeStep, RifEclipseRftAddress::RftWellLogChannelType::PRESSURE_MEAN ); RiaCurveMerger curveMerger; diff --git a/ApplicationLibCode/FileInterface/RifReaderFmuRft.cpp b/ApplicationLibCode/FileInterface/RifReaderFmuRft.cpp index dfc9bc6314..eedc034379 100644 --- a/ApplicationLibCode/FileInterface/RifReaderFmuRft.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderFmuRft.cpp @@ -18,6 +18,7 @@ #include "RifReaderFmuRft.h" #include "RiaLogging.h" +#include "RiaQDateTimeTools.h" #include "cafAssert.h" @@ -194,10 +195,20 @@ std::set RifReaderFmuRft::eclipseRftAddresses() { if ( observation.valid() ) { - RifEclipseRftAddress tvdAddress( wellName, dateTime, RifEclipseRftAddress::TVD ); - RifEclipseRftAddress mdAddress( wellName, dateTime, RifEclipseRftAddress::MD ); - RifEclipseRftAddress pressureAddress( wellName, dateTime, RifEclipseRftAddress::PRESSURE ); - RifEclipseRftAddress pressureErrorAddress( wellName, dateTime, RifEclipseRftAddress::PRESSURE_ERROR ); + RifEclipseRftAddress tvdAddress = + RifEclipseRftAddress::createAddress( wellName, + dateTime, + RifEclipseRftAddress::RftWellLogChannelType::TVD ); + RifEclipseRftAddress mdAddress = + RifEclipseRftAddress::createAddress( wellName, dateTime, RifEclipseRftAddress::RftWellLogChannelType::MD ); + RifEclipseRftAddress pressureAddress = + RifEclipseRftAddress::createAddress( wellName, + dateTime, + RifEclipseRftAddress::RftWellLogChannelType::PRESSURE ); + RifEclipseRftAddress pressureErrorAddress = + RifEclipseRftAddress::createAddress( wellName, + dateTime, + RifEclipseRftAddress::RftWellLogChannelType::PRESSURE_ERROR ); allAddresses.insert( tvdAddress ); allAddresses.insert( mdAddress ); allAddresses.insert( pressureAddress ); @@ -230,16 +241,16 @@ void RifReaderFmuRft::values( const RifEclipseRftAddress& rftAddress, std::vecto { switch ( rftAddress.wellLogChannel() ) { - case RifEclipseRftAddress::TVD: + case RifEclipseRftAddress::RftWellLogChannelType::TVD: values->push_back( observation.tvdmsl ); break; - case RifEclipseRftAddress::MD: + case RifEclipseRftAddress::RftWellLogChannelType::MD: values->push_back( observation.mdrkb ); break; - case RifEclipseRftAddress::PRESSURE: + case RifEclipseRftAddress::RftWellLogChannelType::PRESSURE: values->push_back( observation.pressure ); break; - case RifEclipseRftAddress::PRESSURE_ERROR: + case RifEclipseRftAddress::RftWellLogChannelType::PRESSURE_ERROR: values->push_back( observation.pressureError ); break; default: @@ -309,8 +320,9 @@ std::set RifReaderFmuRft::availableTimeSteps( const QString& wellName, const RifEclipseRftAddress::RftWellLogChannelType& wellLogChannelName ) { - if ( wellLogChannelName == RifEclipseRftAddress::TVD || wellLogChannelName == RifEclipseRftAddress::MD || - wellLogChannelName == RifEclipseRftAddress::PRESSURE ) + if ( wellLogChannelName == RifEclipseRftAddress::RftWellLogChannelType::TVD || + wellLogChannelName == RifEclipseRftAddress::RftWellLogChannelType::MD || + wellLogChannelName == RifEclipseRftAddress::RftWellLogChannelType::PRESSURE ) { return availableTimeSteps( wellName ); } @@ -342,8 +354,9 @@ std::set RifReaderFmuRft::availableTimeSteps( const QString& wellName, const std::set& relevantChannels ) { - if ( relevantChannels.count( RifEclipseRftAddress::TVD ) || relevantChannels.count( RifEclipseRftAddress::MD ) || - relevantChannels.count( RifEclipseRftAddress::PRESSURE ) ) + if ( relevantChannels.count( RifEclipseRftAddress::RftWellLogChannelType::TVD ) || + relevantChannels.count( RifEclipseRftAddress::RftWellLogChannelType::MD ) || + relevantChannels.count( RifEclipseRftAddress::RftWellLogChannelType::PRESSURE ) ) { return availableTimeSteps( wellName ); } @@ -362,7 +375,9 @@ std::set RifReaderFmuRft::available if ( !m_allWellObservations.empty() ) { - return { RifEclipseRftAddress::TVD, RifEclipseRftAddress::MD, RifEclipseRftAddress::PRESSURE }; + return { RifEclipseRftAddress::RftWellLogChannelType::TVD, + RifEclipseRftAddress::RftWellLogChannelType::MD, + RifEclipseRftAddress::RftWellLogChannelType::PRESSURE }; } return {}; } @@ -409,32 +424,32 @@ RifReaderFmuRft::WellObservationMap RifReaderFmuRft::loadWellDates( QDir& dir, Q return WellObservationMap(); } QTextStream fileStream( &wellDateFile ); - while ( true ) + while ( !fileStream.atEnd() ) { QString line = fileStream.readLine(); - if ( line.isNull() ) + + line = line.simplified(); + if ( line.isNull() || line.isEmpty() ) { - break; + continue; } - else + + QTextStream lineStream( &line ); + + QString wellName; + int day, month, year, measurementIndex; + + lineStream >> wellName >> day >> month >> year >> measurementIndex; + if ( lineStream.status() != QTextStream::Ok ) { - QTextStream lineStream( &line ); - - QString wellName; - int day, month, year, measurementIndex; - - lineStream >> wellName >> day >> month >> year >> measurementIndex; - if ( lineStream.status() != QTextStream::Ok ) - { - *errorMsg = QString( "Failed to parse '%1'" ).arg( wellDateFileInfo.absoluteFilePath() ); - return WellObservationMap(); - } - - QDateTime dateTime( QDate( year, month, day ) ); - dateTime.setTimeSpec( Qt::UTC ); - WellObservationSet observationSet( dateTime, measurementIndex ); - validObservations.insert( std::make_pair( wellName, observationSet ) ); + *errorMsg = QString( "Failed to parse '%1'" ).arg( wellDateFileInfo.absoluteFilePath() ); + return WellObservationMap(); } + + QDateTime dateTime = RiaQDateTimeTools::createDateTime( QDate( year, month, day ) ); + dateTime.setTimeSpec( Qt::UTC ); + WellObservationSet observationSet( dateTime, measurementIndex ); + validObservations.insert( std::make_pair( wellName, observationSet ) ); } } diff --git a/ApplicationLibCode/FileInterface/RifReaderMockModel.cpp b/ApplicationLibCode/FileInterface/RifReaderMockModel.cpp index 2598adef9b..420fa204ca 100644 --- a/ApplicationLibCode/FileInterface/RifReaderMockModel.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderMockModel.cpp @@ -20,6 +20,8 @@ #include "RifReaderMockModel.h" +#include "RiaQDateTimeTools.h" + #include "RigCaseCellResultsData.h" #include "RigEclipseCaseData.h" #include "RigEclipseResultInfo.h" @@ -43,7 +45,7 @@ bool RifReaderMockModel::open( const QString& fileName, RigEclipseCaseData* ecli for ( int i = 0; i < static_cast( m_reservoirBuilder.timeStepCount() ); i++ ) { - dates.push_back( QDateTime( QDate( 2012 + i, 6, 1 ) ) ); + dates.push_back( RiaQDateTimeTools::createDateTime( QDate( 2012 + i, 6, 1 ) ) ); days.push_back( i ); repNumbers.push_back( i ); } diff --git a/ApplicationLibCode/FileInterface/RifReaderObservedData.cpp b/ApplicationLibCode/FileInterface/RifReaderObservedData.cpp index 41d3a8446a..b790f31e36 100644 --- a/ApplicationLibCode/FileInterface/RifReaderObservedData.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderObservedData.cpp @@ -18,6 +18,8 @@ #include "RifReaderObservedData.h" +#include "caf.h" + #include "RifCsvUserDataParser.h" #include "RifEclipseSummaryAddress.h" @@ -50,7 +52,7 @@ bool RifReaderObservedData::open( const QString& h AsciiDataParseOptions parseOptions; parseOptions.dateFormat = "yyyy-MM-dd"; parseOptions.cellSeparator = "\t"; - parseOptions.locale = QLocale::Norwegian; + parseOptions.locale = caf::norwegianLocale(); QString data; QTextStream out( &data ); @@ -152,14 +154,14 @@ const std::vector& RifReaderObservedData::timeSteps( const RifEclipseSum //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RifEclipseSummaryAddress RifReaderObservedData::address( const QString& quantity, +RifEclipseSummaryAddress RifReaderObservedData::address( const QString& vectorName, const QString& identifierName, RifEclipseSummaryAddress::SummaryVarCategory summaryCategory ) { - std::string quantityName = quantity.toStdString(); + std::string stdVectorName = vectorName.toStdString(); int regionNumber( -1 ); int regionNumber2( -1 ); - std::string wellGroupName; + std::string groupName; std::string wellName; int wellSegmentNumber( -1 ); std::string lgrName; @@ -172,8 +174,8 @@ RifEclipseSummaryAddress RifReaderObservedData::address( const QString& switch ( summaryCategory ) { - case RifEclipseSummaryAddress::SUMMARY_WELL_GROUP: - wellGroupName = identifierName.toStdString(); + case RifEclipseSummaryAddress::SUMMARY_GROUP: + groupName = identifierName.toStdString(); break; case RifEclipseSummaryAddress::SUMMARY_WELL: wellName = identifierName.toStdString(); @@ -186,10 +188,10 @@ RifEclipseSummaryAddress RifReaderObservedData::address( const QString& } return RifEclipseSummaryAddress( summaryCategory, - quantityName, + stdVectorName, regionNumber, regionNumber2, - wellGroupName, + groupName, wellName, wellSegmentNumber, lgrName, diff --git a/ApplicationLibCode/FileInterface/RifReaderObservedData.h b/ApplicationLibCode/FileInterface/RifReaderObservedData.h index 3385bf057f..c45545ab05 100644 --- a/ApplicationLibCode/FileInterface/RifReaderObservedData.h +++ b/ApplicationLibCode/FileInterface/RifReaderObservedData.h @@ -54,7 +54,7 @@ class RifReaderObservedData : public RifSummaryReaderInterface RiaDefines::EclipseUnitSystem unitSystem() const override; private: - RifEclipseSummaryAddress address( const QString& quantity, + RifEclipseSummaryAddress address( const QString& vectorName, const QString& identifierName, RifEclipseSummaryAddress::SummaryVarCategory summaryCategory ); diff --git a/ApplicationLibCode/FileInterface/RifReaderOpmRft.cpp b/ApplicationLibCode/FileInterface/RifReaderOpmRft.cpp new file mode 100644 index 0000000000..ad1dabf252 --- /dev/null +++ b/ApplicationLibCode/FileInterface/RifReaderOpmRft.cpp @@ -0,0 +1,575 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RifReaderOpmRft.h" + +#include "RiaLogging.h" +#include "RiaQDateTimeTools.h" +#include "RiaRftDefines.h" +#include "RiaStdStringTools.h" + +#include "opm/io/eclipse/ERft.hpp" + +#include "cafAssert.h" +#include "cafVecIjk.h" + +#include +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifReaderOpmRft::RifReaderOpmRft( const QString& fileName ) +{ + try + { + m_opm_rft = std::make_unique( fileName.toStdString() ); + + buildMetaData(); + } + catch ( const std::exception& e ) + { + RiaLogging::error( QString( "Failed to open RFT file %1\n%2" ).arg( fileName ).arg( e.what() ) ); + } + catch ( ... ) + { + RiaLogging::error( QString( "Failed to open RFT file %1" ).arg( fileName ) ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::set RifReaderOpmRft::eclipseRftAddresses() +{ + return m_addresses; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifReaderOpmRft::values( const RifEclipseRftAddress& rftAddress, std::vector* values ) +{ + auto wellName = rftAddress.wellName().toStdString(); + auto resultName = rftAddress.segmentResultName().toStdString(); + + auto qDate = rftAddress.timeStep().date(); + int y = qDate.year(); + int m = qDate.month(); + int d = qDate.day(); + + if ( rftAddress.wellLogChannel() == RifEclipseRftAddress::RftWellLogChannelType::SEGMENT_VALUES ) + { + auto key = std::make_pair( wellName, RftDate{ y, m, d } ); + auto segment = m_rftWellDateSegments[key]; + + if ( rftAddress.segmentResultName() == RiaDefines::segmentNumberResultName() ) + { + auto data = segment.topology(); + + auto indices = segment.indicesForBranchNumber( rftAddress.segmentBranchNumber() ); + for ( const auto& i : indices ) + { + CAF_ASSERT( i < data.size() ); + values->push_back( data[i].segNo() ); + } + } + else if ( rftAddress.segmentResultName() == RiaDefines::segmentBranchNumberResultName() ) + { + auto branchNumbers = segment.tubingBranchIds(); + for ( const auto& branchNumber : branchNumbers ) + { + values->push_back( branchNumber ); + } + } + } + + if ( resultName.empty() ) + { + resultName = RifReaderOpmRft::resultNameFromChannelType( rftAddress.wellLogChannel() ); + } + + try + { + auto data = m_opm_rft->getRft( resultName, wellName, y, m, d ); + if ( !data.empty() ) + { + if ( rftAddress.wellLogChannel() == RifEclipseRftAddress::RftWellLogChannelType::SEGMENT_VALUES ) + { + auto key = std::make_pair( wellName, RftDate{ y, m, d } ); + auto segment = m_rftWellDateSegments[key]; + + auto indices = segment.indicesForBranchNumber( rftAddress.segmentBranchNumber() ); + for ( const auto& i : indices ) + { + CAF_ASSERT( i < data.size() ); + values->push_back( data[i] ); + } + } + else + { + values->insert( values->end(), data.begin(), data.end() ); + } + } + } + catch ( ... ) + { + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::set RifReaderOpmRft::availableTimeSteps( const QString& wellName ) +{ + std::set timeSteps; + + for ( const auto& address : m_addresses ) + { + if ( address.wellName() == wellName ) + { + timeSteps.insert( address.timeStep() ); + } + } + return timeSteps; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::set + RifReaderOpmRft::availableTimeSteps( const QString& wellName, + const RifEclipseRftAddress::RftWellLogChannelType& wellLogChannelName ) +{ + if ( wellLogChannelName == RifEclipseRftAddress::RftWellLogChannelType::SEGMENT_VALUES ) + return m_rftSegmentTimeSteps; + + std::set timeSteps; + + for ( const auto& address : m_addresses ) + { + if ( address.wellName() == wellName && address.wellLogChannel() == wellLogChannelName ) + { + timeSteps.insert( address.timeStep() ); + } + } + return timeSteps; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::set + RifReaderOpmRft::availableTimeSteps( const QString& wellName, + const std::set& relevantChannels ) +{ + std::set timeSteps; + + for ( const auto& address : m_addresses ) + { + if ( address.wellName() == wellName && relevantChannels.count( address.wellLogChannel() ) ) + { + timeSteps.insert( address.timeStep() ); + } + } + return timeSteps; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::set RifReaderOpmRft::availableWellLogChannels( const QString& wellName ) +{ + std::set types; + + for ( const auto& a : m_addresses ) + { + if ( ( a.wellName() == wellName ) && ( a.wellLogChannel() != RifEclipseRftAddress::RftWellLogChannelType::NONE ) ) + { + types.insert( a.wellLogChannel() ); + } + } + + return types; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::set RifReaderOpmRft::wellNames() +{ + return m_wellNames; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifReaderOpmRft::cellIndices( const RifEclipseRftAddress& rftAddress, std::vector* indices ) +{ + auto wellName = rftAddress.wellName().toStdString(); + + auto date = rftAddress.timeStep().date(); + int y = date.year(); + int m = date.month(); + int d = date.day(); + + try + { + auto resultNameI = "CONIPOS"; + auto dataI = m_opm_rft->getRft( resultNameI, wellName, y, m, d ); + + auto resultNameJ = "CONJPOS"; + auto dataJ = m_opm_rft->getRft( resultNameJ, wellName, y, m, d ); + + auto resultNameK = "CONKPOS"; + auto dataK = m_opm_rft->getRft( resultNameK, wellName, y, m, d ); + + if ( !dataI.empty() && ( dataI.size() == dataJ.size() ) && ( dataI.size() == dataK.size() ) ) + { + for ( size_t n = 0; n < dataI.size(); n++ ) + { + // NB: Transform to zero-based cell indices + indices->push_back( caf::VecIjk( dataI[n] - 1, dataJ[n] - 1, dataK[n] - 1 ) ); + } + } + } + catch ( ... ) + { + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifReaderOpmRft::buildMetaData() +{ + // TODO: Assert better than return? + if ( !isOpen() ) return; + + importWellNames(); + + auto reports = m_opm_rft->listOfRftReports(); + for ( const auto& report : reports ) + { + auto [wellName, reportDate, reportTime] = report; + auto rftVectors = m_opm_rft->listOfRftArrays( wellName, reportDate ); + + for ( const auto& rftVec : rftVectors ) + { + auto [resultDataName, arrType, itemCount] = rftVec; + + int y = std::get<0>( reportDate ); + int m = std::get<1>( reportDate ); + int d = std::get<2>( reportDate ); + + auto dt = RiaQDateTimeTools::createUtcDateTime( QDate( y, m, d ) ); + + auto channelType = identifyChannelType( resultDataName ); + if ( channelType != RifEclipseRftAddress::RftWellLogChannelType::NONE ) + { + auto adr = RifEclipseRftAddress::createAddress( QString::fromStdString( wellName ), dt, channelType ); + m_addresses.insert( adr ); + } + } + } + + buildSegmentData(); + + // Create segment result addresses + for ( const auto& segmentWellData : m_rftWellDateSegments ) + { + auto [wellName, reportDate] = segmentWellData.first; + auto segmentData = segmentWellData.second; + + auto resultNameAndSizes = segmentData.resultNameAndSize(); + + int y = std::get<0>( reportDate ); + int m = std::get<1>( reportDate ); + int d = std::get<2>( reportDate ); + + auto dt = RiaQDateTimeTools::createUtcDateTime( QDate( y, m, d ) ); + + m_rftSegmentTimeSteps.insert( dt ); + + auto segmentCount = segmentData.topology().size(); + + for ( const auto& resultNameAndSize : resultNameAndSizes ) + { + auto resultValueCount = std::get<2>( resultNameAndSize ); + + if ( static_cast( resultValueCount ) != segmentCount ) continue; + + auto resultName = std::get<0>( resultNameAndSize ); + auto adr = RifEclipseRftAddress::createSegmentAddress( QString::fromStdString( wellName ), + dt, + QString::fromStdString( resultName ), + -1 ); + + m_addresses.insert( adr ); + } + + auto adr = RifEclipseRftAddress::createSegmentAddress( QString::fromStdString( wellName ), + dt, + RiaDefines::segmentNumberResultName(), + -1 ); + + m_addresses.insert( adr ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifReaderOpmRft::buildSegmentData() +{ + m_rftWellDateSegments.clear(); + + auto wellNames = m_opm_rft->listOfWells(); + auto dates = m_opm_rft->listOfdates(); + + for ( const auto& wellName : wellNames ) + { + for ( const auto& date : dates ) + { + std::vector segmentsForWellDate; + + std::vector segnxt = importWellData( wellName, "SEGNXT", date ); + std::vector segbrno = importWellData( wellName, "SEGBRNO", date ); + std::vector brnstValues = importWellData( wellName, "BRNST", date ); + std::vector brnenValues = importWellData( wellName, "BRNEN", date ); + + if ( segnxt.empty() ) continue; + if ( segnxt.size() != segbrno.size() ) continue; + if ( brnenValues.empty() || brnstValues.empty() ) continue; + + std::vector segNo; + for ( size_t i = 0; i < segnxt.size(); i++ ) + { + int branchIndex = segbrno[i] - 1; + int nextBranchIndex = -1; + if ( i + 1 < segbrno.size() ) nextBranchIndex = segbrno[i + 1] - 1; + + bool isLastSegmentOnBranch = branchIndex != nextBranchIndex; + + int brnst = brnstValues[branchIndex]; + int brnen = brnenValues[branchIndex]; + + int segmentId = -1; + if ( !isLastSegmentOnBranch ) + { + if ( i + 1 < segnxt.size() ) segmentId = segnxt[i + 1]; + } + else + { + segmentId = brnen; + } + + segNo.push_back( segmentId ); + + segmentsForWellDate.emplace_back( RifRftSegmentData( segnxt[i], segbrno[i], brnst, brnen, segmentId ) ); + } + + if ( segmentsForWellDate.empty() ) continue; + + RifRftSegment segment; + segment.setSegmentData( segmentsForWellDate ); + + auto arraysAtWellDate = m_opm_rft->listOfRftArrays( wellName, date ); + for ( const auto& rftResultMetaData : arraysAtWellDate ) + { + auto [name, arrayType, size] = rftResultMetaData; + if ( name.find( "SEG" ) == 0 ) + { + segment.addResultNameAndSize( rftResultMetaData ); + } + } + + auto wellDateKey = std::make_pair( wellName, date ); + m_rftWellDateSegments[wellDateKey] = segment; + + buildSegmentBranchTypes( wellDateKey ); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifReaderOpmRft::segmentDataDebugLog() const +{ + for ( const auto& a : m_rftWellDateSegments ) + { + auto [wellName, date] = a.first; + auto segmentData = a.second; + + std::cout << "\nWell: " << wellName << "Date : " << std::get<0>( date ) << " " << std::get<1>( date ) << " " + << std::get<2>( date ) << " \n"; + + for ( const auto& r : segmentData.topology() ) + { + std::cout << "SEGNXT " << std::setw( 2 ) << r.segNext() << ", "; + std::cout << "SEGBRNO " << std::setw( 2 ) << r.segBrno() << ", "; + std::cout << "BNRST " << std::setw( 2 ) << r.segBrnst() << ", "; + std::cout << "BRNEN " << std::setw( 2 ) << r.segBrnen() << ", "; + std::cout << "SEGNO " << std::setw( 2 ) << r.segNo() << "\n"; + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifReaderOpmRft::isOpen() const +{ + return m_opm_rft != nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifReaderOpmRft::importWellNames() +{ + auto names = m_opm_rft->listOfWells(); + for ( const auto& w : names ) + { + m_wellNames.insert( QString::fromStdString( w ) ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifReaderOpmRft::buildSegmentBranchTypes( const RftSegmentKey& segmentKey ) +{ + auto wellName = segmentKey.first; + auto date = segmentKey.second; + RifRftSegment& segmentRef = m_rftWellDateSegments[segmentKey]; + + int y = std::get<0>( date ); + int m = std::get<1>( date ); + int d = std::get<2>( date ); + + auto dt = RiaQDateTimeTools::createUtcDateTime( QDate( y, m, d ) ); + + std::vector seglenstValues; + std::vector seglenenValues; + { + auto resultName = + RifEclipseRftAddress::createSegmentAddress( QString::fromStdString( wellName ), dt, "SEGLENST", -1 ); + + values( resultName, &seglenstValues ); + + if ( seglenstValues.size() > 2 ) + { + seglenstValues[0] = seglenstValues[1]; + } + } + { + auto resultName = + RifEclipseRftAddress::createSegmentAddress( QString::fromStdString( wellName ), dt, "SEGLENEN", -1 ); + + values( resultName, &seglenenValues ); + } + + if ( !seglenenValues.empty() && !seglenstValues.empty() ) + { + auto branchIds = segmentRef.branchIds(); + for ( auto id : branchIds ) + { + double minimumMD = std::numeric_limits::max(); + double maximumMD = std::numeric_limits::min(); + + auto indices = segmentRef.indicesForBranchNumber( id ); + for ( auto i : indices ) + { + minimumMD = std::min( minimumMD, seglenstValues[i] ); + maximumMD = std::max( maximumMD, seglenenValues[i] ); + } + + double length = maximumMD - minimumMD; + + segmentRef.setBranchLength( id, length ); + + const double tubingThreshold = 1.0; + RiaDefines::RftBranchType branchType = RiaDefines::RftBranchType::RFT_UNKNOWN; + if ( length > tubingThreshold ) branchType = RiaDefines::RftBranchType::RFT_TUBING; + + segmentRef.setBranchType( id, branchType ); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector + RifReaderOpmRft::importWellData( const std::string& wellName, const std::string& propertyName, const RftDate& date ) const +{ + // PERFORMANCE NOTE + // Use method hasRft() that do not throw exception if RFT data is not available. Using this method and avoid + // try/catch and exceptions is way faster. + if ( !m_opm_rft->hasRft( wellName, date ) ) return {}; + + try + { + // The hasArray method can throw, so we must use a try/catch block here + if ( m_opm_rft->hasArray( propertyName, wellName, date ) ) + { + return m_opm_rft->getRft( propertyName, wellName, date ); + } + } + catch ( ... ) + { + } + + return {}; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifEclipseRftAddress::RftWellLogChannelType RifReaderOpmRft::identifyChannelType( const std::string& resultName ) +{ + if ( resultName == "DEPTH" ) return RifEclipseRftAddress::RftWellLogChannelType::TVD; + if ( resultName == "PRESSURE" ) return RifEclipseRftAddress::RftWellLogChannelType::PRESSURE; + if ( resultName == "SWAT" ) return RifEclipseRftAddress::RftWellLogChannelType::SWAT; + if ( resultName == "SOIL" ) return RifEclipseRftAddress::RftWellLogChannelType::SOIL; + if ( resultName == "SGAS" ) return RifEclipseRftAddress::RftWellLogChannelType::SGAS; + if ( resultName == "WRAT" ) return RifEclipseRftAddress::RftWellLogChannelType::WRAT; + if ( resultName == "ORAT" ) return RifEclipseRftAddress::RftWellLogChannelType::ORAT; + if ( resultName == "GRAT" ) return RifEclipseRftAddress::RftWellLogChannelType::GRAT; + + return RifEclipseRftAddress::RftWellLogChannelType::NONE; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::string RifReaderOpmRft::resultNameFromChannelType( RifEclipseRftAddress::RftWellLogChannelType channelType ) +{ + if ( channelType == RifEclipseRftAddress::RftWellLogChannelType::TVD ) return "DEPTH"; + if ( channelType == RifEclipseRftAddress::RftWellLogChannelType::PRESSURE ) return "PRESSURE"; + if ( channelType == RifEclipseRftAddress::RftWellLogChannelType::SWAT ) return "SWAT"; + if ( channelType == RifEclipseRftAddress::RftWellLogChannelType::SOIL ) return "SOIL"; + if ( channelType == RifEclipseRftAddress::RftWellLogChannelType::SGAS ) return "SGAS"; + if ( channelType == RifEclipseRftAddress::RftWellLogChannelType::WRAT ) return "WRAT"; + if ( channelType == RifEclipseRftAddress::RftWellLogChannelType::ORAT ) return "ORAT"; + if ( channelType == RifEclipseRftAddress::RftWellLogChannelType::GRAT ) return "GRAT"; + + return {}; +} diff --git a/ApplicationLibCode/FileInterface/RifReaderOpmRft.h b/ApplicationLibCode/FileInterface/RifReaderOpmRft.h new file mode 100644 index 0000000000..bdfac4ceb7 --- /dev/null +++ b/ApplicationLibCode/FileInterface/RifReaderOpmRft.h @@ -0,0 +1,82 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RifReaderEclipseRft.h" +#include "RifRftSegment.h" + +#include "cvfObject.h" + +#include + +namespace Opm +{ +namespace EclIO +{ + class ERft; +} // namespace EclIO +} // namespace Opm + +class RifReaderOpmRft : public RifReaderRftInterface, public cvf::Object +{ +public: + RifReaderOpmRft( const QString& fileName ); + + std::set eclipseRftAddresses() override; + void values( const RifEclipseRftAddress& rftAddress, std::vector* values ) override; + + std::set availableTimeSteps( const QString& wellName ) override; + std::set availableTimeSteps( const QString& wellName, + const RifEclipseRftAddress::RftWellLogChannelType& wellLogChannelName ) override; + std::set + availableTimeSteps( const QString& wellName, + const std::set& relevantChannels ) override; + std::set availableWellLogChannels( const QString& wellName ) override; + std::set wellNames() override; + + void cellIndices( const RifEclipseRftAddress& rftAddress, std::vector* indices ) override; + +private: + // Segment data + // RftDate must be synced with definition in Opm::EclIO::ERft::RftDate + using RftDate = std::tuple; + using RftSegmentKey = std::pair; + + void buildMetaData(); + void buildSegmentData(); + void segmentDataDebugLog() const; + bool isOpen() const; + void importWellNames(); + void buildSegmentBranchTypes( const RftSegmentKey& segmentKey ); + + std::vector importWellData( const std::string& wellName, const std::string& propertyName, const RftDate& date ) const; + + static RifEclipseRftAddress::RftWellLogChannelType identifyChannelType( const std::string& resultName ); + static std::string resultNameFromChannelType( RifEclipseRftAddress::RftWellLogChannelType channelType ); + +private: + std::unique_ptr m_opm_rft; + + // RFT and PLT addresses + std::set m_addresses; + std::set m_wellNames; + + std::map m_rftWellDateSegments; + std::set m_rftSegmentTimeSteps; +}; diff --git a/ApplicationLibCode/FileInterface/RifReaderRftInterface.cpp b/ApplicationLibCode/FileInterface/RifReaderRftInterface.cpp index bfb6838d25..b84861c2b8 100644 --- a/ApplicationLibCode/FileInterface/RifReaderRftInterface.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderRftInterface.cpp @@ -34,3 +34,10 @@ std::set RifReaderRftInterface::eclipseRftAddresses( const } return matchingAddresses; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifReaderRftInterface::cellIndices( const RifEclipseRftAddress& rftAddress, std::vector* indices ) +{ +} diff --git a/ApplicationLibCode/FileInterface/RifReaderRftInterface.h b/ApplicationLibCode/FileInterface/RifReaderRftInterface.h index 3fe405fb1e..790109ebae 100644 --- a/ApplicationLibCode/FileInterface/RifReaderRftInterface.h +++ b/ApplicationLibCode/FileInterface/RifReaderRftInterface.h @@ -26,6 +26,11 @@ #include #include +namespace caf +{ +class VecIjk; +}; + class RifReaderRftInterface { public: @@ -42,4 +47,6 @@ class RifReaderRftInterface const RifEclipseRftAddress::RftWellLogChannelType& wellLogChannelName ) = 0; virtual std::set availableWellLogChannels( const QString& wellName ) = 0; virtual std::set wellNames() = 0; + + virtual void cellIndices( const RifEclipseRftAddress& rftAddress, std::vector* indices ); }; diff --git a/ApplicationLibCode/FileInterface/RifReaderSettings.cpp b/ApplicationLibCode/FileInterface/RifReaderSettings.cpp index f105900974..d2e649b660 100644 --- a/ApplicationLibCode/FileInterface/RifReaderSettings.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderSettings.cpp @@ -28,24 +28,21 @@ CAF_PDM_SOURCE_INIT( RifReaderSettings, "RifReaderSettings" ); //-------------------------------------------------------------------------------------------------- RifReaderSettings::RifReaderSettings() { - CAF_PDM_InitObject( "RifReaderSettings", "", "", "" ); + CAF_PDM_InitObject( "RifReaderSettings" ); - CAF_PDM_InitField( &importFaults, "importFaults", true, "Import Faults", "", "", "" ); + CAF_PDM_InitField( &importFaults, "importFaults", true, "Import Faults" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &importFaults ); - CAF_PDM_InitField( &importNNCs, "importSimulationNNCs", true, "Import NNCs", "", "", "" ); + CAF_PDM_InitField( &importNNCs, "importSimulationNNCs", true, "Import NNCs" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &importNNCs ); CAF_PDM_InitField( &includeInactiveCellsInFaultGeometry, "includeInactiveCellsInFaultGeometry", false, - "Include Inactive Cells", - "", - "", - "" ); + "Include Inactive Cells" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &includeInactiveCellsInFaultGeometry ); - CAF_PDM_InitField( &importAdvancedMswData, "importAdvancedMswData", false, "Import Advanced MSW Data", "", "", "" ); + CAF_PDM_InitField( &importAdvancedMswData, "importAdvancedMswData", false, "Import Advanced MSW Data" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &importAdvancedMswData ); CAF_PDM_InitField( &useResultIndexFile, @@ -61,7 +58,7 @@ RifReaderSettings::RifReaderSettings() caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &useResultIndexFile ); - CAF_PDM_InitField( &skipWellData, "skipWellData", false, "Skip Import of Simulation Well Data", "", "", "" ); + CAF_PDM_InitField( &skipWellData, "skipWellData", false, "Skip Import of Simulation Well Data" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &skipWellData ); CAF_PDM_InitField( &includeFileAbsolutePathPrefix, @@ -73,7 +70,7 @@ RifReaderSettings::RifReaderSettings() "for FAULTS and EQUIL", "" ); - CAF_PDM_InitField( &importSummaryData, "importSummaryData", true, "Import summary data", "", "", "" ); + CAF_PDM_InitField( &importSummaryData, "importSummaryData", true, "Import summary data" ); importSummaryData.uiCapability()->setUiHidden( true ); } diff --git a/ApplicationLibCode/FileInterface/RifRftSegment.cpp b/ApplicationLibCode/FileInterface/RifRftSegment.cpp new file mode 100644 index 0000000000..3cdad97006 --- /dev/null +++ b/ApplicationLibCode/FileInterface/RifRftSegment.cpp @@ -0,0 +1,184 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RifRftSegment.h" + +#include +#include + +//-------------------------------------------------------------------------------------------------- +/// segnxt : Int ID for the next segment +/// brno : Branch ID number +/// brnst : Branch ID number for start of segment +/// brnen : Branch ID number for end of segment +/// segNo : Segment ID number +/// +//-------------------------------------------------------------------------------------------------- +RifRftSegmentData::RifRftSegmentData( int segnxt, int brno, int brnst, int brnen, int segNo ) + : m_segNext( segnxt ) + , m_segbrno( brno ) + , m_brnst( brnst ) + , m_brnen( brnen ) + , m_segmentNo( segNo ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RifRftSegmentData::segNext() const +{ + return m_segNext; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RifRftSegmentData::segBrno() const +{ + return m_segbrno; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RifRftSegmentData::segBrnst() const +{ + return m_brnst; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RifRftSegmentData::segBrnen() const +{ + return m_brnen; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RifRftSegmentData::segNo() const +{ + return m_segmentNo; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifRftSegment::setSegmentData( std::vector segmentData ) +{ + m_topology = segmentData; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RifRftSegment::topology() const +{ + return m_topology; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifRftSegment::addResultNameAndSize( const Opm::EclIO::EclFile::EclEntry& resultNameAndSize ) +{ + m_resultNameAndSize.push_back( resultNameAndSize ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RifRftSegment::resultNameAndSize() const +{ + return m_resultNameAndSize; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RifRftSegment::tubingBranchIds() const +{ + std::vector filteredBranchIds; + + for ( auto branchId : branchIds() ) + { + if ( m_branchType.count( branchId ) ) + { + if ( m_branchType.at( branchId ) == RiaDefines::RftBranchType::RFT_TUBING ) + { + filteredBranchIds.push_back( branchId ); + } + } + } + + return filteredBranchIds; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RifRftSegment::branchIds() const +{ + std::unordered_set s; + for ( const auto& segData : m_topology ) + { + s.insert( segData.segBrno() ); + } + + std::vector v; + v.assign( s.begin(), s.end() ); + std::sort( v.begin(), v.end() ); + + return v; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifRftSegment::setBranchLength( int branchId, double length ) +{ + m_branchLength[branchId] = length; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifRftSegment::setBranchType( int branchId, RiaDefines::RftBranchType branchType ) +{ + m_branchType[branchId] = branchType; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RifRftSegment::indicesForBranchNumber( int branchNumber ) const +{ + std::vector v; + for ( size_t i = 0; i < m_topology.size(); i++ ) + { + auto segment = m_topology[i]; + if ( branchNumber <= 0 || segment.segBrno() == branchNumber ) + { + v.push_back( i ); + } + } + + return v; +} diff --git a/ApplicationLibCode/FileInterface/RifRftSegment.h b/ApplicationLibCode/FileInterface/RifRftSegment.h new file mode 100644 index 0000000000..6093ec89b0 --- /dev/null +++ b/ApplicationLibCode/FileInterface/RifRftSegment.h @@ -0,0 +1,70 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include +#include + +#include "RiaRftDefines.h" +#include "opm/io/eclipse/EclFile.hpp" + +class RifRftSegmentData +{ +public: + RifRftSegmentData( int segnxt, int brno, int brnst, int brnen, int segNo ); + + int segNext() const; + int segBrno() const; + int segBrnst() const; + int segBrnen() const; + int segNo() const; + +private: + int m_segNext; + int m_segbrno; + int m_brnst; + int m_brnen; + int m_segmentNo; +}; + +class RifRftSegment +{ +public: + void setSegmentData( std::vector segmentData ); + std::vector topology() const; + + void addResultNameAndSize( const Opm::EclIO::EclFile::EclEntry& resultNameAndSize ); + std::vector resultNameAndSize() const; + + std::vector tubingBranchIds() const; + std::vector branchIds() const; + + void setBranchLength( int branchId, double length ); + void setBranchType( int branchId, RiaDefines::RftBranchType branchType ); + + std::vector indicesForBranchNumber( int branchNumber ) const; + +private: + std::vector m_topology; + std::vector m_resultNameAndSize; + + std::map m_branchLength; + std::map m_branchType; +}; diff --git a/ApplicationLibCode/FileInterface/RifStimPlanModelGeologicalFrkExporter.cpp b/ApplicationLibCode/FileInterface/RifStimPlanModelGeologicalFrkExporter.cpp index cb921fa19f..655b50fd55 100644 --- a/ApplicationLibCode/FileInterface/RifStimPlanModelGeologicalFrkExporter.cpp +++ b/ApplicationLibCode/FileInterface/RifStimPlanModelGeologicalFrkExporter.cpp @@ -29,6 +29,8 @@ #include "RimStimPlanModel.h" #include "RimStimPlanModelCalculator.h" +#include "caf.h" + #include #include #include @@ -273,7 +275,7 @@ bool RifStimPlanModelGeologicalFrkExporter::writeToCsvFile( const QString& //-------------------------------------------------------------------------------------------------- void RifStimPlanModelGeologicalFrkExporter::appendHeaderToStream( QTextStream& stream ) { - stream << "" << '\n' << "" << endl; + stream << "" << '\n' << "" << caf::endl; } //-------------------------------------------------------------------------------------------------- @@ -283,23 +285,23 @@ void RifStimPlanModelGeologicalFrkExporter::appendToStream( QTextStream& const QString& label, const std::vector& values ) { - stream << "" << endl - << "" << endl - << label << endl - << "" << endl - << "" << endl - << 1 << endl - << "" << endl - << "" << endl - << values.size() << endl - << "" << endl - << "" << endl; + stream << "" << caf::endl + << "" << caf::endl + << label << caf::endl + << "" << caf::endl + << "" << caf::endl + << 1 << caf::endl + << "" << caf::endl + << "" << caf::endl + << values.size() << caf::endl + << "" << caf::endl + << "" << caf::endl; for ( auto val : values ) { - stream << val << endl; + stream << val << caf::endl; } - stream << "" << '\n' << "" << endl; + stream << "" << '\n' << "" << caf::endl; } //-------------------------------------------------------------------------------------------------- @@ -307,7 +309,7 @@ void RifStimPlanModelGeologicalFrkExporter::appendToStream( QTextStream& //-------------------------------------------------------------------------------------------------- void RifStimPlanModelGeologicalFrkExporter::appendFooterToStream( QTextStream& stream ) { - stream << "" << endl; + stream << "" << caf::endl; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/FileInterface/RifStimPlanModelPerfsFrkExporter.cpp b/ApplicationLibCode/FileInterface/RifStimPlanModelPerfsFrkExporter.cpp index 901ca11efb..0658f50b73 100644 --- a/ApplicationLibCode/FileInterface/RifStimPlanModelPerfsFrkExporter.cpp +++ b/ApplicationLibCode/FileInterface/RifStimPlanModelPerfsFrkExporter.cpp @@ -27,6 +27,8 @@ #include "RigWellPath.h" #include "RigWellPathGeometryTools.h" +#include "caf.h" + #include #include @@ -75,7 +77,7 @@ bool RifStimPlanModelPerfsFrkExporter::writeToFile( RimStimPlanModel* stimPlanMo //-------------------------------------------------------------------------------------------------- void RifStimPlanModelPerfsFrkExporter::appendHeaderToStream( QTextStream& stream ) { - stream << "" << '\n' << "" << endl; + stream << "" << '\n' << "" << caf::endl; } //-------------------------------------------------------------------------------------------------- @@ -83,7 +85,7 @@ void RifStimPlanModelPerfsFrkExporter::appendHeaderToStream( QTextStream& stream //-------------------------------------------------------------------------------------------------- void RifStimPlanModelPerfsFrkExporter::appendFractureOrientationToStream( QTextStream& stream, bool isTransverse ) { - stream << "" << '\n' << static_cast( isTransverse ) << '\n' << "" << endl; + stream << "" << '\n' << static_cast( isTransverse ) << '\n' << "" << caf::endl; } //-------------------------------------------------------------------------------------------------- @@ -91,14 +93,14 @@ void RifStimPlanModelPerfsFrkExporter::appendFractureOrientationToStream( QTextS //-------------------------------------------------------------------------------------------------- void RifStimPlanModelPerfsFrkExporter::appendPerforationToStream( QTextStream& stream, int index, double topMD, double bottomMD ) { - stream << "" << endl - << "" << endl - << topMD << endl - << "" << endl - << "" << endl - << bottomMD << endl - << "" << endl - << "" << endl; + stream << "" << caf::endl + << "" << caf::endl + << topMD << caf::endl + << "" << caf::endl + << "" << caf::endl + << bottomMD << caf::endl + << "" << caf::endl + << "" << caf::endl; } //-------------------------------------------------------------------------------------------------- @@ -106,7 +108,7 @@ void RifStimPlanModelPerfsFrkExporter::appendPerforationToStream( QTextStream& s //-------------------------------------------------------------------------------------------------- void RifStimPlanModelPerfsFrkExporter::appendFooterToStream( QTextStream& stream ) { - stream << "" << endl; + stream << "" << caf::endl; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/FileInterface/RifStimPlanXmlReader.cpp b/ApplicationLibCode/FileInterface/RifStimPlanXmlReader.cpp index 2c08b87ee2..72a5aa8a0d 100644 --- a/ApplicationLibCode/FileInterface/RifStimPlanXmlReader.cpp +++ b/ApplicationLibCode/FileInterface/RifStimPlanXmlReader.cpp @@ -22,6 +22,8 @@ #include "RiaEclipseUnitTools.h" #include "RiaFractureDefines.h" #include "RiaLogging.h" +#include "RiaTextStringTools.h" + #include "RigStimPlanFractureDefinition.h" #include @@ -474,7 +476,7 @@ void RifStimPlanXmlReader::getGriddingValues( QXmlStreamReader& xmlStream, QString gridValuesString = xmlStream.readElementText().replace( '\n', ' ' ); gridValuesString = gridValuesString.replace( '[', ' ' ).replace( ']', ' ' ); - for ( const QString& value : gridValuesString.split( ' ', QString::SkipEmptyParts ) ) + for ( const QString& value : RiaTextStringTools::splitSkipEmptyParts( gridValuesString ) ) { if ( value.size() > 0 ) { diff --git a/ApplicationLibCode/FileInterface/RifSummaryReaderInterface.cpp b/ApplicationLibCode/FileInterface/RifSummaryReaderInterface.cpp index e0a6d57a3a..599ab33b0e 100644 --- a/ApplicationLibCode/FileInterface/RifSummaryReaderInterface.cpp +++ b/ApplicationLibCode/FileInterface/RifSummaryReaderInterface.cpp @@ -54,13 +54,8 @@ RifEclipseSummaryAddress RifSummaryReaderInterface::errorAddress( const RifEclip //-------------------------------------------------------------------------------------------------- bool RifSummaryReaderInterface::hasAddress( const RifEclipseSummaryAddress& resultAddress ) const { - for ( const RifEclipseSummaryAddress& summaryAddress : m_allResultAddresses ) - { - if ( summaryAddress == resultAddress ) - { - return true; - } - } + static const RifEclipseSummaryAddress defaultAdr = RifEclipseSummaryAddress(); + if ( resultAddress == defaultAdr ) return true; - return false; + return ( m_allResultAddresses.count( resultAddress ) > 0 ); } diff --git a/ApplicationLibCode/FileInterface/RifWellIAFileWriter.cpp b/ApplicationLibCode/FileInterface/RifWellIAFileWriter.cpp index 41436e7ac7..059ea44095 100644 --- a/ApplicationLibCode/FileInterface/RifWellIAFileWriter.cpp +++ b/ApplicationLibCode/FileInterface/RifWellIAFileWriter.cpp @@ -24,6 +24,8 @@ #include "RimWellIAModelData.h" #include "RimWellIASettings.h" +#include "caf.h" + #include #include @@ -41,11 +43,11 @@ bool RifWellIAFileWriter::writeToJsonFile( RimWellIASettings& settings, QString& { QTextStream stream( &file ); - stream << "{" << endl; + stream << "{" << caf::endl; stream << "\"comments\": \"All units are SI unless mentioned otherwise; temperature is in Celcius; use forward " "slash (/) in 'directory' definition\"," - << endl; - stream << "\"directory\": \"" + settings.outputBaseDirectory() + "\"," << endl; + << caf::endl; + stream << "\"directory\": \"" + settings.outputBaseDirectory() + "\"," << caf::endl; stream << "\"output_name\": \"" + settings.name() + "\""; RimParameterGroups mergedGroups; @@ -63,9 +65,9 @@ bool RifWellIAFileWriter::writeToJsonFile( RimWellIASettings& settings, QString& for ( auto& group : mergedGroups.groups() ) { - stream << "," << endl; + stream << "," << caf::endl; - stream << "\"" + group->name() + "\": {" << endl; + stream << "\"" + group->name() + "\": {" << caf::endl; const auto& parameters = group->parameters(); @@ -78,13 +80,13 @@ bool RifWellIAFileWriter::writeToJsonFile( RimWellIASettings& settings, QString& { stream << ","; } - stream << endl; + stream << caf::endl; } stream << " }"; } - stream << endl << "}" << endl; + stream << caf::endl << "}" << caf::endl; file.close(); } else @@ -114,7 +116,7 @@ bool RifWellIAFileWriter::writeToCSVFile( RimWellIASettings& settings, QString& stream << "Time_days, Pcasing_Pa, P_form_Pa, Temp_C," "U1-1,U2,U3,U1-2,U2,U3,U1-3,U2,U3,U1-4,U2,U3,U1-5,U2,U3,U1-6,U2,U3,U1-7,U2,U3,U1-8,U2,U3," "X,Y,Z,X2,Y,Z,X3,Y,Z,X4,Y,Z,X5,Y,Z,X6,Y,Z,X7,Y,Z,X8,Y,Z"; - stream << endl; + stream << caf::endl; for ( auto& modeldata : settings.modelData() ) { @@ -145,7 +147,7 @@ bool RifWellIAFileWriter::writeToCSVFile( RimWellIASettings& settings, QString& stream << ","; stream << pos.z(); } - stream << endl; + stream << caf::endl; } } else diff --git a/ApplicationLibCode/FileInterface/RifWellPathFormationReader.cpp b/ApplicationLibCode/FileInterface/RifWellPathFormationReader.cpp index bc488c18d7..c4bce7b0d1 100644 --- a/ApplicationLibCode/FileInterface/RifWellPathFormationReader.cpp +++ b/ApplicationLibCode/FileInterface/RifWellPathFormationReader.cpp @@ -155,7 +155,7 @@ void RifWellPathFormationReader::readFile( const QString& filePath, QString line = data.readLine().toLower(); removeWhiteSpaces( &line ); - header = line.split( ';', QString::KeepEmptyParts ); + header = line.split( ';' ); } static const QString wellNameText = "wellname"; @@ -172,7 +172,7 @@ void RifWellPathFormationReader::readFile( const QString& filePath, { QString line = data.readLine(); - QStringList dataLine = line.split( ';', QString::KeepEmptyParts ); + QStringList dataLine = line.split( ';' ); if ( dataLine.size() != header.size() ) continue; bool conversionOk; @@ -224,7 +224,7 @@ void RifWellPathFormationReader::readFile( const QString& filePath, { QString line = data.readLine(); - QStringList dataLine = line.split( ';', QString::KeepEmptyParts ); + QStringList dataLine = line.split( ';' ); if ( dataLine.size() != header.size() ) continue; QString wellName = dataLine[wellNameIndex]; diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RimGeoMechGeometrySelectionItem.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RimGeoMechGeometrySelectionItem.cpp index b7923f287d..e51c9d9a32 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RimGeoMechGeometrySelectionItem.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RimGeoMechGeometrySelectionItem.cpp @@ -31,18 +31,18 @@ CAF_PDM_SOURCE_INIT( RimGeoMechGeometrySelectionItem, "GeoMechGeometrySelectionI //-------------------------------------------------------------------------------------------------- RimGeoMechGeometrySelectionItem::RimGeoMechGeometrySelectionItem() { - CAF_PDM_InitObject( "GeoMech Topology Item", "", "", "" ); - - CAF_PDM_InitFieldNoDefault( &m_geoMechCase, "GeoMechCase", "Geo Mech Case", "", "", "" ); - - CAF_PDM_InitFieldNoDefault( &m_gridIndex, "m_gridIndex", "GridIndex", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_cellIndex, "m_cellIndex", "CellIndex", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_elementFace, "m_elementFace", "ElementFace", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_hasIntersectionTriangle, "m_hasIntersectionTriangle", "HasIntersectionTriangle", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_intersectionTriangle_0, "m_intersectionTriangle_0", "IntersectionTriangle_0", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_intersectionTriangle_1, "m_intersectionTriangle_1", "IntersectionTriangle_1", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_intersectionTriangle_2, "m_intersectionTriangle_2", "IntersectionTriangle_2", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_localIntersectionPoint, "m_localIntersectionPoint", "LocalIntersectionPoint", "", "", "" ); + CAF_PDM_InitObject( "GeoMech Topology Item" ); + + CAF_PDM_InitFieldNoDefault( &m_geoMechCase, "GeoMechCase", "Geo Mech Case" ); + + CAF_PDM_InitFieldNoDefault( &m_gridIndex, "m_gridIndex", "GridIndex" ); + CAF_PDM_InitFieldNoDefault( &m_cellIndex, "m_cellIndex", "CellIndex" ); + CAF_PDM_InitFieldNoDefault( &m_elementFace, "m_elementFace", "ElementFace" ); + CAF_PDM_InitFieldNoDefault( &m_hasIntersectionTriangle, "m_hasIntersectionTriangle", "HasIntersectionTriangle" ); + CAF_PDM_InitFieldNoDefault( &m_intersectionTriangle_0, "m_intersectionTriangle_0", "IntersectionTriangle_0" ); + CAF_PDM_InitFieldNoDefault( &m_intersectionTriangle_1, "m_intersectionTriangle_1", "IntersectionTriangle_1" ); + CAF_PDM_InitFieldNoDefault( &m_intersectionTriangle_2, "m_intersectionTriangle_2", "IntersectionTriangle_2" ); + CAF_PDM_InitFieldNoDefault( &m_localIntersectionPoint, "m_localIntersectionPoint", "LocalIntersectionPoint" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionPartMgr.cpp b/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionPartMgr.cpp index 237ab76f87..42b00f7241 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionPartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionPartMgr.cpp @@ -32,7 +32,6 @@ #include "RimGeoMechCase.h" #include "RimGeoMechCellColors.h" #include "RimGeoMechView.h" -#include "RimIntersectionResultDefinition.h" #include "RivBoxIntersectionSourceInfo.h" #include "RivExtrudedCurveIntersectionPartMgr.h" diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionGeometryGenerator.cpp b/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionGeometryGenerator.cpp index 4627beed3b..cfc11611b9 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionGeometryGenerator.cpp +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionGeometryGenerator.cpp @@ -145,7 +145,7 @@ void RivExtrudedCurveIntersectionGeometryGenerator::calculateLineSegementTransfo //-------------------------------------------------------------------------------------------------- void RivExtrudedCurveIntersectionGeometryGenerator::calculateTransformedPolyline() { - CVF_ASSERT( m_lineSegmentTransforms.size() == m_polylines.size() ); + if ( m_lineSegmentTransforms.size() != m_polylines.size() ) return; for ( size_t lineIdx = 0; lineIdx < m_polylines.size(); ++lineIdx ) { @@ -291,6 +291,30 @@ void RivExtrudedCurveIntersectionGeometryGenerator::calculateArrays() calculateLineSegementTransforms(); calculateTransformedPolyline(); + const double gridRadius = gridBBox.radius(); + + // set up our horizontal cut planes + const double topDepth = -1.0 * m_intersection->upperFilterDepth( gridRadius ); + const double bottomDepth = -1.0 * m_intersection->lowerFilterDepth( gridRadius ); + + std::array corners; + gridBBox.cornerVertices( corners.data() ); + + cvf::Vec3d p1_low( corners[0].x(), corners[0].y(), bottomDepth ); + cvf::Vec3d p2_low( corners[1].x(), corners[1].y(), bottomDepth ); + cvf::Vec3d p3_low( corners[2].x(), corners[2].y(), bottomDepth ); + + cvf::Plane lowPlane; + lowPlane.setFromPoints( p1_low, p2_low, p3_low ); + + cvf::Vec3d p1_high( p1_low.x(), p1_low.y(), topDepth ); + cvf::Vec3d p2_high( p2_low.x(), p2_low.y(), topDepth ); + cvf::Vec3d p3_high( p3_low.x(), p3_low.y(), topDepth ); + + cvf::Plane highPlane; + highPlane.setFromPoints( p1_high, p2_high, p3_high ); + highPlane.flip(); + for ( size_t pLineIdx = 0; pLineIdx < m_polylines.size(); ++pLineIdx ) { const std::vector& polyLine = m_polylines[pLineIdx]; @@ -347,6 +371,9 @@ void RivExtrudedCurveIntersectionGeometryGenerator::calculateArrays() sectionBBox.add( p2 - maxHeightVec ); } + sectionBBox.cutBelow( bottomDepth ); + sectionBBox.cutAbove( topDepth ); + std::vector columnCellCandidates; m_hexGrid->findIntersectingCells( sectionBBox, &columnCellCandidates ); @@ -412,16 +439,32 @@ void RivExtrudedCurveIntersectionGeometryGenerator::calculateArrays() } } - std::vector clippedTriangleVxes; - std::vector cellFaceForEachClippedTriangleEdge; + std::vector clippedTriangleVxes_stage1; + std::vector cellFaceForEachClippedTriangleEdge_stage1; caf::HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes( hexPlaneCutTriangleVxes, cellFaceForEachTriangleEdge, p1Plane, p2Plane, + &clippedTriangleVxes_stage1, + &cellFaceForEachClippedTriangleEdge_stage1 ); + + for ( caf::HexGridIntersectionTools::ClipVx& clvx : clippedTriangleVxes_stage1 ) + if ( !clvx.isVxIdsNative ) clvx.derivedVxLevel = 0; + + std::vector clippedTriangleVxes; + std::vector cellFaceForEachClippedTriangleEdge; + + caf::HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes( clippedTriangleVxes_stage1, + cellFaceForEachClippedTriangleEdge_stage1, + lowPlane, + highPlane, &clippedTriangleVxes, &cellFaceForEachClippedTriangleEdge ); + for ( caf::HexGridIntersectionTools::ClipVx& clvx : clippedTriangleVxes ) + if ( !clvx.isVxIdsNative && clvx.derivedVxLevel == -1 ) clvx.derivedVxLevel = 1; + size_t clippedTriangleCount = clippedTriangleVxes.size() / 3; for ( uint tIdx = 0; tIdx < clippedTriangleCount; ++tIdx ) @@ -429,7 +472,6 @@ void RivExtrudedCurveIntersectionGeometryGenerator::calculateArrays() uint triVxIdx = tIdx * 3; // Accumulate triangle vertices - cvf::Vec3d point0( clippedTriangleVxes[triVxIdx + 0].vx ); cvf::Vec3d point1( clippedTriangleVxes[triVxIdx + 1].vx ); cvf::Vec3d point2( clippedTriangleVxes[triVxIdx + 2].vx ); @@ -452,13 +494,11 @@ void RivExtrudedCurveIntersectionGeometryGenerator::calculateArrays() triangleVertices.emplace_back( point2 ); // Accumulate mesh lines - meshAcc.accumulateMeshLines( cellFaceForEachClippedTriangleEdge, triVxIdx + 0, globalCellIdx, point0, point1 ); meshAcc.accumulateMeshLines( cellFaceForEachClippedTriangleEdge, triVxIdx + 1, globalCellIdx, point1, point2 ); meshAcc.accumulateMeshLines( cellFaceForEachClippedTriangleEdge, triVxIdx + 2, globalCellIdx, point2, point0 ); // Mapping to cell index - m_triangleToCellIdxMap.push_back( globalCellIdx ); // Interpolation from nodes @@ -473,16 +513,100 @@ void RivExtrudedCurveIntersectionGeometryGenerator::calculateArrays() } else { - caf::HexGridIntersectionTools::ClipVx cvx1 = hexPlaneCutTriangleVxes[cvx.clippedEdgeVx1Id]; - caf::HexGridIntersectionTools::ClipVx cvx2 = hexPlaneCutTriangleVxes[cvx.clippedEdgeVx2Id]; - - m_triVxToCellCornerWeights.emplace_back( cvx1.clippedEdgeVx1Id, - cvx1.clippedEdgeVx2Id, - cvx1.normDistFromEdgeVx1, - cvx2.clippedEdgeVx1Id, - cvx2.clippedEdgeVx2Id, - cvx2.normDistFromEdgeVx1, - cvx.normDistFromEdgeVx1 ); + caf::HexGridIntersectionTools::ClipVx cvx1; + caf::HexGridIntersectionTools::ClipVx cvx2; + + if ( cvx.derivedVxLevel == 0 ) + { + cvx1 = hexPlaneCutTriangleVxes[cvx.clippedEdgeVx1Id]; + cvx2 = hexPlaneCutTriangleVxes[cvx.clippedEdgeVx2Id]; + } + else if ( cvx.derivedVxLevel == 1 ) + { + cvx1 = clippedTriangleVxes_stage1[cvx.clippedEdgeVx1Id]; + cvx2 = clippedTriangleVxes_stage1[cvx.clippedEdgeVx2Id]; + } + else + { + CVF_ASSERT( false ); + } + + if ( cvx1.isVxIdsNative && cvx2.isVxIdsNative ) + { + m_triVxToCellCornerWeights.emplace_back( cvx1.clippedEdgeVx1Id, + cvx1.clippedEdgeVx2Id, + cvx1.normDistFromEdgeVx1, + cvx2.clippedEdgeVx1Id, + cvx2.clippedEdgeVx2Id, + cvx2.normDistFromEdgeVx1, + cvx.normDistFromEdgeVx1 ); + } + else + { + caf::HexGridIntersectionTools::ClipVx cvx11; + caf::HexGridIntersectionTools::ClipVx cvx12; + caf::HexGridIntersectionTools::ClipVx cvx21; + caf::HexGridIntersectionTools::ClipVx cvx22; + + if ( cvx1.isVxIdsNative ) + { + cvx11 = cvx1; + cvx12 = cvx1; + } + else if ( cvx1.derivedVxLevel == 0 ) + { + cvx11 = hexPlaneCutTriangleVxes[cvx1.clippedEdgeVx1Id]; + cvx12 = hexPlaneCutTriangleVxes[cvx1.clippedEdgeVx2Id]; + } + else if ( cvx2.derivedVxLevel == 1 ) + { + cvx11 = clippedTriangleVxes_stage1[cvx1.clippedEdgeVx1Id]; + cvx12 = clippedTriangleVxes_stage1[cvx1.clippedEdgeVx2Id]; + } + else + { + CVF_ASSERT( false ); + } + + if ( cvx2.isVxIdsNative ) + { + cvx21 = cvx2; + cvx22 = cvx2; + } + else if ( cvx2.derivedVxLevel == 0 ) + { + cvx21 = hexPlaneCutTriangleVxes[cvx2.clippedEdgeVx1Id]; + cvx22 = hexPlaneCutTriangleVxes[cvx2.clippedEdgeVx2Id]; + } + else if ( cvx2.derivedVxLevel == 1 ) + { + cvx21 = clippedTriangleVxes_stage1[cvx2.clippedEdgeVx1Id]; + cvx22 = clippedTriangleVxes_stage1[cvx2.clippedEdgeVx2Id]; + } + else + { + CVF_ASSERT( false ); + } + + CVF_TIGHT_ASSERT( cvx11.isVxIdsNative && cvx12.isVxIdsNative && cvx21.isVxIdsNative && + cvx22.isVxIdsNative ); + + m_triVxToCellCornerWeights.emplace_back( cvx11.clippedEdgeVx1Id, + cvx11.clippedEdgeVx2Id, + cvx11.normDistFromEdgeVx1, + cvx12.clippedEdgeVx1Id, + cvx12.clippedEdgeVx2Id, + cvx2.normDistFromEdgeVx1, + cvx21.clippedEdgeVx1Id, + cvx21.clippedEdgeVx2Id, + cvx21.normDistFromEdgeVx1, + cvx22.clippedEdgeVx1Id, + cvx22.clippedEdgeVx2Id, + cvx22.normDistFromEdgeVx1, + cvx1.normDistFromEdgeVx1, + cvx2.normDistFromEdgeVx1, + cvx.normDistFromEdgeVx1 ); + } } } } diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.cpp b/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.cpp index a3126df53e..cd65d860c6 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.cpp @@ -236,6 +236,10 @@ void RivExtrudedCurveIntersectionPartMgr::generatePartGeometry() { if ( m_intersectionGenerator.isNull() ) return; + if ( m_rimIntersection->depthFilterType() == RimIntersectionFilterEnum::INTERSECT_FILTER_BETWEEN && + ( m_rimIntersection->lowerFilterDepth( 1.0 ) <= m_rimIntersection->upperFilterDepth( 1.0 ) ) ) + return; + bool useBufferObjects = true; // Surface geometry { diff --git a/ApplicationLibCode/ModelVisualization/RivContourMapProjectionPartMgr.cpp b/ApplicationLibCode/ModelVisualization/RivContourMapProjectionPartMgr.cpp index 7077117ce4..33fa5efd27 100644 --- a/ApplicationLibCode/ModelVisualization/RivContourMapProjectionPartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/RivContourMapProjectionPartMgr.cpp @@ -10,6 +10,7 @@ #include "RimContourMapProjection.h" #include "RimGridView.h" +#include "RimRegularLegendConfig.h" #include "cafCategoryMapper.h" #include "cafEffectGenerator.h" diff --git a/ApplicationLibCode/ModelVisualization/RivElementVectorResultPartMgr.cpp b/ApplicationLibCode/ModelVisualization/RivElementVectorResultPartMgr.cpp index b06dd55172..976b34d312 100644 --- a/ApplicationLibCode/ModelVisualization/RivElementVectorResultPartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/RivElementVectorResultPartMgr.cpp @@ -191,12 +191,21 @@ void RivElementVectorResultPartMgr::appendDynamicGeometryPartsToModel( cvf::Mode getFaceCenterAndNormal( static_cast( gcIdx ), directions[dir], faceCenter, faceNormal ); faceNormal *= std::abs( resultValue ); + bool centerArrow = false; + if ( result->vectorSuraceCrossingLocation() == + RimElementVectorResult::VectorSurfaceCrossingLocation::VECTOR_CENTER && + result->vectorView() == RimElementVectorResult::VectorView::PER_FACE ) + { + centerArrow = true; + } + #pragma omp critical( critical_section_RivElementVectorResultPartMgr_add_1 ) tensorVisualizations.push_back( ElementVectorResultVisualization( faceCenter, faceNormal, resultValue, - std::cbrt( cells[gcIdx].volume() / 3.0 ) ) ); + std::cbrt( cells[gcIdx].volume() / 3.0 ), + centerArrow ) ); } } } @@ -223,12 +232,20 @@ void RivElementVectorResultPartMgr::appendDynamicGeometryPartsToModel( cvf::Mode } if ( aggregatedResult.length() >= result->threshold() ) { + bool centerArrow = false; + if ( result->vectorSuraceCrossingLocation() == + RimElementVectorResult::VectorSurfaceCrossingLocation::VECTOR_CENTER ) + { + centerArrow = true; + } + #pragma omp critical( critical_section_RivElementVectorResultPartMgr_add_2 ) tensorVisualizations.push_back( ElementVectorResultVisualization( displayCordXf->transformToDisplayCoord( cells[gcIdx].center() ), aggregatedVector, aggregatedResult.length(), - std::cbrt( cells[gcIdx].volume() / 3.0 ) ) ); + std::cbrt( cells[gcIdx].volume() / 3.0 ), + centerArrow ) ); } } } @@ -280,12 +297,25 @@ void RivElementVectorResultPartMgr::appendDynamicGeometryPartsToModel( cvf::Mode if ( std::abs( resultValue ) >= result->threshold() ) { + bool centerArrow = false; + if ( result->vectorView() == RimElementVectorResult::VectorView::CELL_CENTER_TOTAL ) + { + centerArrow = true; + } + else if ( result->vectorView() == RimElementVectorResult::VectorView::PER_FACE ) + { + if ( result->vectorSuraceCrossingLocation() == + RimElementVectorResult::VectorSurfaceCrossingLocation::VECTOR_CENTER ) + centerArrow = true; + } + #pragma omp critical( critical_section_RivElementVectorResultPartMgr_add_nnc ) tensorVisualizations.push_back( ElementVectorResultVisualization( displayCordXf->transformToDisplayCoord( connCenter ), connNormal, resultValue, - std::cbrt( cells[conn.c1GlobIdx()].volume() / 3.0 ) ) ); + std::cbrt( cells[conn.c1GlobIdx()].volume() / 3.0 ), + centerArrow ) ); } } } @@ -430,8 +460,7 @@ std::array cvf::Vec3f headTop = evrViz.faceCenter + evrViz.faceNormal; cvf::Vec3f shaftStart = evrViz.faceCenter; - if ( result->vectorSuraceCrossingLocation() == RimElementVectorResult::VectorSurfaceCrossingLocation::VECTOR_CENTER && - result->vectorView() == RimElementVectorResult::VectorView::PER_FACE ) + if ( evrViz.centerArrow ) { headTop = evrViz.faceCenter + evrViz.faceNormal / 2.0; shaftStart = evrViz.faceCenter - evrViz.faceNormal / 2.0; @@ -439,7 +468,7 @@ std::array // Flip arrow for negative results and if the vector is not aggregated (in which case we do not have any negative // result) - if ( evrViz.result < 0 && result->vectorView() != RimElementVectorResult::VectorView::CELL_CENTER_TOTAL ) + if ( evrViz.result < 0 ) { std::swap( headTop, shaftStart ); } diff --git a/ApplicationLibCode/ModelVisualization/RivElementVectorResultPartMgr.h b/ApplicationLibCode/ModelVisualization/RivElementVectorResultPartMgr.h index 7739b10f9a..66a0b86f9f 100644 --- a/ApplicationLibCode/ModelVisualization/RivElementVectorResultPartMgr.h +++ b/ApplicationLibCode/ModelVisualization/RivElementVectorResultPartMgr.h @@ -54,11 +54,16 @@ class RivElementVectorResultPartMgr : public cvf::Object private: struct ElementVectorResultVisualization { - ElementVectorResultVisualization( cvf::Vec3d faceCenter, cvf::Vec3d faceNormal, double result, double approximateCellLength ) + ElementVectorResultVisualization( cvf::Vec3d faceCenter, + cvf::Vec3d faceNormal, + double result, + double approximateCellLength, + bool centerArrow ) : faceCenter( faceCenter ) , faceNormal( faceNormal ) , result( result ) , approximateCellLength( approximateCellLength ) + , centerArrow( centerArrow ) { } @@ -66,6 +71,7 @@ class RivElementVectorResultPartMgr : public cvf::Object cvf::Vec3f faceNormal; double result; double approximateCellLength; + bool centerArrow; }; private: diff --git a/ApplicationLibCode/ModelVisualization/RivTernaryTextureCoordsCreator.cpp b/ApplicationLibCode/ModelVisualization/RivTernaryTextureCoordsCreator.cpp index 5341294bfa..76038fbd4f 100644 --- a/ApplicationLibCode/ModelVisualization/RivTernaryTextureCoordsCreator.cpp +++ b/ApplicationLibCode/ModelVisualization/RivTernaryTextureCoordsCreator.cpp @@ -62,19 +62,19 @@ RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator( const RimEclipse gridIndex, porosityModel, resTimeStepIdx, - RigEclipseResultAddress( "SOIL" ) ); + RigEclipseResultAddress( RiaResultNames::soil() ) ); cvf::ref sgas = RigResultAccessorFactory::createFromResultAddress( eclipseCase, gridIndex, porosityModel, resTimeStepIdx, - RigEclipseResultAddress( "SGAS" ) ); + RigEclipseResultAddress( RiaResultNames::sgas() ) ); cvf::ref swat = RigResultAccessorFactory::createFromResultAddress( eclipseCase, gridIndex, porosityModel, resTimeStepIdx, - RigEclipseResultAddress( "SWAT" ) ); + RigEclipseResultAddress( RiaResultNames::swat() ) ); m_resultAccessor = new RigTernaryResultAccessor(); m_resultAccessor->setTernaryResultAccessors( soil.p(), sgas.p(), swat.p() ); @@ -111,19 +111,19 @@ RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator( const RimEclipse gridIndex, porosityModel, resTimeStepIdx, - RigEclipseResultAddress( "SOIL" ) ); + RigEclipseResultAddress( RiaResultNames::soil() ) ); cvf::ref sgas = RigResultAccessorFactory::createFromResultAddress( eclipseCase, gridIndex, porosityModel, resTimeStepIdx, - RigEclipseResultAddress( "SGAS" ) ); + RigEclipseResultAddress( RiaResultNames::sgas() ) ); cvf::ref swat = RigResultAccessorFactory::createFromResultAddress( eclipseCase, gridIndex, porosityModel, resTimeStepIdx, - RigEclipseResultAddress( "SWAT" ) ); + RigEclipseResultAddress( RiaResultNames::swat() ) ); m_resultAccessor = new RigTernaryResultAccessor(); m_resultAccessor->setTernaryResultAccessors( soil.p(), sgas.p(), swat.p() ); diff --git a/ApplicationLibCode/ModelVisualization/RivWellFracturePartMgr.cpp b/ApplicationLibCode/ModelVisualization/RivWellFracturePartMgr.cpp index bbc73d17ee..6727c7b6db 100644 --- a/ApplicationLibCode/ModelVisualization/RivWellFracturePartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/RivWellFracturePartMgr.cpp @@ -99,6 +99,8 @@ void RivWellFracturePartMgr::appendGeometryPartsToModel( cvf::ModelBasicList* mo if ( stimPlanFracTemplate ) { + createVisibleFracturePolygons( stimPlanFracTemplate, eclView ); + if ( eclView.fractureColors()->stimPlanResultColorType() == RimStimPlanColors::SINGLE_ELEMENT_COLOR ) { auto part = createStimPlanElementColorSurfacePart( eclView ); @@ -1025,6 +1027,36 @@ cvf::ref RivWellFracturePartMgr::createStimPlanMeshPart( const RimEcl return nullptr; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWellFracturePartMgr::createVisibleFracturePolygons( RimStimPlanFractureTemplate* stimPlanFracTemplate, + const RimEclipseView& activeView ) +{ + if ( !m_rimFracture->fractureGrid() ) return; + + std::vector stimPlanCells = m_rimFracture->fractureGrid()->fractureCells(); + + QString resultNameFromColors = activeView.fractureColors()->uiResultName(); + QString resultUnitFromColors = activeView.fractureColors()->unit(); + + std::vector prCellResults = + stimPlanFracTemplate->fractureGridResults( resultNameFromColors, + resultUnitFromColors, + stimPlanFracTemplate->activeTimeStepIndex() ); + + m_visibleFracturePolygons.clear(); + for ( size_t cIdx = 0; cIdx < stimPlanCells.size(); ++cIdx ) + { + if ( prCellResults[cIdx] > 1e-7 ) + { + const RigFractureCell& stimPlanCell = stimPlanCells[cIdx]; + std::vector stimPlanCellPolygon = stimPlanCell.getPolygon(); + m_visibleFracturePolygons.push_back( stimPlanCellPolygon ); + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1048,7 +1080,6 @@ cvf::ref resultUnitFromColors, stimPlanFracTemplate->activeTimeStepIndex() ); - m_visibleFracturePolygons.clear(); for ( size_t cIdx = 0; cIdx < stimPlanCells.size(); ++cIdx ) { if ( prCellResults[cIdx] > 1e-7 ) @@ -1059,7 +1090,6 @@ cvf::ref { stimPlanMeshVertices.push_back( static_cast( cellCorner ) ); } - m_visibleFracturePolygons.push_back( stimPlanCellPolygon ); } } diff --git a/ApplicationLibCode/ModelVisualization/RivWellFracturePartMgr.h b/ApplicationLibCode/ModelVisualization/RivWellFracturePartMgr.h index 410368c945..ac9206c4ce 100644 --- a/ApplicationLibCode/ModelVisualization/RivWellFracturePartMgr.h +++ b/ApplicationLibCode/ModelVisualization/RivWellFracturePartMgr.h @@ -82,6 +82,9 @@ class RivWellFracturePartMgr : public cvf::Object cvf::ref createStimPlanMeshDrawable( RimStimPlanFractureTemplate* stimPlanFracTemplate, const RimEclipseView& activeView ); + void createVisibleFracturePolygons( RimStimPlanFractureTemplate* stimPlanFracTemplate, + const RimEclipseView& activeView ); + std::vector fractureBorderPolygon(); static cvf::ref createScalarMapperPart( cvf::DrawableGeo* drawableGeo, diff --git a/ApplicationLibCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationLibCode/ModelVisualization/RivWellPathPartMgr.cpp index 152c05a8f6..9361179d29 100644 --- a/ApplicationLibCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -810,7 +810,7 @@ void RivWellPathPartMgr::buildWellPathParts( const caf::DisplayCoordTransform* d double cellRadius = 15.0; auto eclipseView = dynamic_cast( m_rimView.p() ); - if ( eclipseView ) + if ( eclipseView && eclipseView->mainGrid() ) { double characteristicCellSize = eclipseView->mainGrid()->characteristicIJCellSize(); cellRadius = sphereRadiusFactor * characteristicCellSize; diff --git a/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlot.cpp b/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlot.cpp index 65048e9f08..9d178e8386 100644 --- a/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlot.cpp @@ -18,12 +18,16 @@ #include "RimAnalysisPlot.h" +#include "RiaDefines.h" +#include "RiaPlotDefines.h" #include "RiaPreferences.h" +#include "RiaQDateTimeTools.h" #include "RiaSummaryCurveDefinition.h" #include "RiaTextStringTools.h" #include "RiuGroupedBarChartBuilder.h" #include "RiuPlotMainWindowTools.h" +#include "RiuQwtPlotTools.h" #include "RiuSummaryQwtPlot.h" #include "RiuSummaryVectorSelectionDialog.h" @@ -53,6 +57,7 @@ #include "cafPdmUiListEditor.h" #include "cafPdmUiTreeSelectionEditor.h" +#include #include #include @@ -63,7 +68,7 @@ void caf::AppEnum::setUp() { addItem( RimAnalysisPlot::NONE, "NONE", "None" ); addItem( RimAnalysisPlot::SUMMARY_ITEM, "SUMMARY_ITEM", "Summary Item" ); - addItem( RimAnalysisPlot::QUANTITY, "QUANTITY", "Quantity" ); + addItem( RimAnalysisPlot::VECTOR, "VECTOR", "Vector" ); addItem( RimAnalysisPlot::CASE, "CASE", "Case" ); addItem( RimAnalysisPlot::ENSEMBLE, "ENSEMBLE", "Ensemble" ); addItem( RimAnalysisPlot::VALUE, "VALUE", "Value" ); @@ -91,78 +96,78 @@ CAF_PDM_SOURCE_INIT( RimAnalysisPlot, "AnalysisPlot" ); RimAnalysisPlot::RimAnalysisPlot() : RimPlot() { - CAF_PDM_InitObject( "Analysis Plot", ":/AnalysisPlot16x16.png", "", "" ); + CAF_PDM_InitObject( "Analysis Plot", ":/AnalysisPlot16x16.png" ); // Variable selection - CAF_PDM_InitFieldNoDefault( &m_selectedVarsUiField, "selectedVarsUiField", "Selected Vectors", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_selectedVarsUiField, "selectedVarsUiField", "Selected Vectors" ); m_selectedVarsUiField.xmlCapability()->disableIO(); m_selectedVarsUiField.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); m_selectedVarsUiField.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitField( &m_selectVariablesButtonField, "BrowseButton", false, "...", "", "", "" ); + CAF_PDM_InitField( &m_selectVariablesButtonField, "BrowseButton", false, "..." ); caf::PdmUiActionPushButtonEditor::configureEditorForField( &m_selectVariablesButtonField ); - CAF_PDM_InitFieldNoDefault( &m_analysisPlotDataSelection, "AnalysisPlotData", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_analysisPlotDataSelection, "AnalysisPlotData", "" ); m_analysisPlotDataSelection.uiCapability()->setUiTreeChildrenHidden( true ); m_analysisPlotDataSelection.uiCapability()->setUiTreeHidden( true ); // Time Step Selection - CAF_PDM_InitFieldNoDefault( &m_timeStepFilter, "TimeStepFilter", "Available Time Steps", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_selectedTimeSteps, "TimeSteps", "Select Time Steps", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_timeStepFilter, "TimeStepFilter", "Available Time Steps" ); + CAF_PDM_InitFieldNoDefault( &m_selectedTimeSteps, "TimeSteps", "Select Time Steps" ); m_selectedTimeSteps.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); m_selectedTimeSteps.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); // Options - CAF_PDM_InitFieldNoDefault( &m_referenceCase, "ReferenceCase", "Reference Case", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_referenceCase, "ReferenceCase", "Reference Case" ); - CAF_PDM_InitField( &m_useAutoPlotTitle, "IsUsingAutoName", true, "Auto", "", "", "" ); + CAF_PDM_InitField( &m_useAutoPlotTitle, "IsUsingAutoName", true, "Auto" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_useAutoPlotTitle ); - CAF_PDM_InitField( &m_description, "PlotDescription", QString( "Analysis Plot" ), "Title", "", "", "" ); + CAF_PDM_InitField( &m_description, "PlotDescription", QString( "Analysis Plot" ), "Title" ); m_description.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); - CAF_PDM_InitFieldNoDefault( &m_barOrientation, "BarOrientation", "Bar Orientation", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_barOrientation, "BarOrientation", "Bar Orientation" ); // Grouping - CAF_PDM_InitFieldNoDefault( &m_majorGroupType, "MajorGroupType", "Major Grouping", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_mediumGroupType, "MediumGroupType", "Medium Grouping", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_minorGroupType, "MinorGroupType", "Minor Grouping", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_majorGroupType, "MajorGroupType", "Major Grouping" ); + CAF_PDM_InitFieldNoDefault( &m_mediumGroupType, "MediumGroupType", "Medium Grouping" ); + CAF_PDM_InitFieldNoDefault( &m_minorGroupType, "MinorGroupType", "Minor Grouping" ); - CAF_PDM_InitFieldNoDefault( &m_valueSortOperation, "ValueSortOperation", "Sort by Value", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_valueSortOperation, "ValueSortOperation", "Sort by Value" ); - CAF_PDM_InitFieldNoDefault( &m_sortGroupForColors, "groupForColors", "Coloring Using", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_sortGroupForColors, "groupForColors", "Coloring Using" ); m_sortGroupForColors = RimAnalysisPlot::CASE; m_showPlotLegends = false; - CAF_PDM_InitField( &m_useTopBarsFilter, "UseTopBarsFilter", false, "Show Only Top", "", "", "" ); + CAF_PDM_InitField( &m_useTopBarsFilter, "UseTopBarsFilter", false, "Show Only Top" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_useTopBarsFilter ); - CAF_PDM_InitField( &m_maxBarCount, "MaxBarCount", 20, "Bar Count", "", "", "" ); + CAF_PDM_InitField( &m_maxBarCount, "MaxBarCount", 20, "Bar Count" ); m_maxBarCount.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); // Bar text - CAF_PDM_InitField( &m_useBarText, "UseBarText", true, "Activate Bar Labels", "", "", "" ); + CAF_PDM_InitField( &m_useBarText, "UseBarText", true, "Activate Bar Labels" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_useBarText ); - CAF_PDM_InitField( &m_useCaseInBarText, "UseCaseInBarText", true, "Case Name", "", "", "" ); - CAF_PDM_InitField( &m_useEnsembleInBarText, "UseEnsembleInBarText", false, "Ensemble", "", "", "" ); - CAF_PDM_InitField( &m_useSummaryItemInBarText, "UseSummaryItemInBarText", false, "Summary Item", "", "", "" ); - CAF_PDM_InitField( &m_useTimeStepInBarText, "UseTimeStepInBarText", false, "Time Step", "", "", "" ); - CAF_PDM_InitField( &m_useQuantityInBarText, "UseQuantityInBarText", false, "Quantity", "", "", "" ); + CAF_PDM_InitField( &m_useCaseInBarText, "UseCaseInBarText", true, "Case Name" ); + CAF_PDM_InitField( &m_useEnsembleInBarText, "UseEnsembleInBarText", false, "Ensemble" ); + CAF_PDM_InitField( &m_useSummaryItemInBarText, "UseSummaryItemInBarText", false, "Summary Item" ); + CAF_PDM_InitField( &m_useTimeStepInBarText, "UseTimeStepInBarText", false, "Time Step" ); + CAF_PDM_InitField( &m_useVectorNameInBarText, "UseQuantityInBarText", false, "Vector" ); - CAF_PDM_InitFieldNoDefault( &m_barTextFontSize, "BarTextFontSize", "Font Size", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_barTextFontSize, "BarTextFontSize", "Font Size" ); - CAF_PDM_InitFieldNoDefault( &m_valueAxisProperties, "ValueAxisProperties", "ValueAxisProperties", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_valueAxisProperties, "ValueAxisProperties", "ValueAxisProperties" ); m_valueAxisProperties.uiCapability()->setUiTreeHidden( true ); m_valueAxisProperties = new RimPlotAxisProperties; - m_valueAxisProperties->setNameAndAxis( "Value-Axis", QwtPlot::yLeft ); + m_valueAxisProperties->setNameAndAxis( "Value-Axis", "Value-Axis", RiuQwtPlotTools::fromQwtPlotAxis( QwtAxis::YLeft ) ); m_valueAxisProperties->enableRangeSettings( false ); - CAF_PDM_InitFieldNoDefault( &m_plotDataFilterCollection, "PlotDataFilterCollection", "PlotDataFilterCollection", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_plotDataFilterCollection, "PlotDataFilterCollection", "PlotDataFilterCollection" ); m_plotDataFilterCollection.uiCapability()->setUiTreeHidden( true ); m_plotDataFilterCollection = new RimPlotDataFilterCollection; @@ -201,7 +206,7 @@ RimPlotDataFilterCollection* RimAnalysisPlot::plotDataFilterCollection() const //-------------------------------------------------------------------------------------------------- void RimAnalysisPlot::setCurveDefinitions( const std::vector& curveDefinitions ) { - m_analysisPlotDataSelection.deleteAllChildObjects(); + m_analysisPlotDataSelection.deleteChildren(); for ( auto curveDef : curveDefinitions ) { auto dataEntry = new RimAnalysisPlotDataEntry(); @@ -386,7 +391,7 @@ void RimAnalysisPlot::maxMinValueFromAddress( const RifEclipseSummaryAddress& { RifEclipseSummaryAddress historyAddr = address; - if ( !historyAddr.isHistoryQuantity() ) historyAddr.setQuantityName( address.quantityName() + "H" ); + if ( !historyAddr.isHistoryVector() ) historyAddr.setVectorName( address.vectorName() + "H" ); const std::vector& historyTimesteps = reader->timeSteps( historyAddr ); if ( historyTimesteps.size() ) @@ -458,7 +463,7 @@ void RimAnalysisPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField, { std::vector summaryVectorDefinitions = dlg.curveSelection(); - m_analysisPlotDataSelection.deleteAllChildObjects(); + m_analysisPlotDataSelection.deleteChildren(); for ( const RiaSummaryCurveDefinition& vectorDef : summaryVectorDefinitions ) { auto dataEntry = new RimAnalysisPlotDataEntry(); @@ -493,9 +498,9 @@ void RimAnalysisPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering QString vectorNames; if ( getOrCreateSelectedCurveDefAnalyser() ) { - for ( const std::string& quantityName : getOrCreateSelectedCurveDefAnalyser()->m_quantityNames ) + for ( const std::string& vectorName : getOrCreateSelectedCurveDefAnalyser()->m_vectorNames ) { - vectorNames += QString::fromStdString( quantityName ) + ", "; + vectorNames += QString::fromStdString( vectorName ) + ", "; } if ( !vectorNames.isEmpty() ) @@ -541,14 +546,14 @@ void RimAnalysisPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering caf::PdmUiGroup* barLabelGrp = uiOrdering.addNewGroup( "Bar Labels" ); barLabelGrp->add( &m_useBarText ); barLabelGrp->add( &m_barTextFontSize ); - barLabelGrp->add( &m_useQuantityInBarText ); + barLabelGrp->add( &m_useVectorNameInBarText ); barLabelGrp->add( &m_useSummaryItemInBarText ); barLabelGrp->add( &m_useCaseInBarText ); barLabelGrp->add( &m_useEnsembleInBarText ); barLabelGrp->add( &m_useTimeStepInBarText ); m_barTextFontSize.uiCapability()->setUiReadOnly( !m_useBarText ); - m_useQuantityInBarText.uiCapability()->setUiReadOnly( !m_useBarText ); + m_useVectorNameInBarText.uiCapability()->setUiReadOnly( !m_useBarText ); m_useSummaryItemInBarText.uiCapability()->setUiReadOnly( !m_useBarText ); m_useCaseInBarText.uiCapability()->setUiReadOnly( !m_useBarText ); m_useEnsembleInBarText.uiCapability()->setUiReadOnly( !m_useBarText ); @@ -568,10 +573,9 @@ caf::PdmFieldHandle* RimAnalysisPlot::userDescriptionField() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimAnalysisPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RimAnalysisPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { - QList options = RimPlot::calculateValueOptions( fieldNeedingOptions, useOptionsOnly ); + QList options = RimPlot::calculateValueOptions( fieldNeedingOptions ); if ( !options.isEmpty() ) return options; @@ -608,11 +612,12 @@ QList RimAnalysisPlot::calculateValueOptions( const caf: filteredTimeStepIndices.erase( std::unique( filteredTimeStepIndices.begin(), filteredTimeStepIndices.end() ), filteredTimeStepIndices.end() ); - QString dateFormatString = RiaQDateTimeTools::dateFormatString( RiaPreferences::current()->dateFormat(), - RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH_DAY ); + QString dateFormatString = + RiaQDateTimeTools::dateFormatString( RiaPreferences::current()->dateFormat(), + RiaDefines::DateFormatComponents::DATE_FORMAT_YEAR_MONTH_DAY ); QString timeFormatString = RiaQDateTimeTools::timeFormatString( RiaPreferences::current()->timeFormat(), - RiaQDateTimeTools::TimeFormatComponents::TIME_FORMAT_HOUR_MINUTE ); + RiaDefines::TimeFormatComponents::TIME_FORMAT_HOUR_MINUTE ); QString dateTimeFormatString = QString( "%1 %2" ).arg( dateFormatString ).arg( timeFormatString ); bool showTime = m_timeStepFilter() == RimTimeStepFilter::TS_ALL || @@ -665,7 +670,7 @@ QList RimAnalysisPlot::calculateValueOptions( const caf: QString( "%1 (%2)" ).arg( SortGroupAppEnum::uiText( SUMMARY_ITEM ) ).arg( exampleString ); options.push_back( caf::PdmOptionItemInfo( summaryItemText, SUMMARY_ITEM ) ); } - options.push_back( caf::PdmOptionItemInfo( SortGroupAppEnum::uiText( QUANTITY ), QUANTITY ) ); + options.push_back( caf::PdmOptionItemInfo( SortGroupAppEnum::uiText( VECTOR ), VECTOR ) ); options.push_back( caf::PdmOptionItemInfo( SortGroupAppEnum::uiText( CASE ), CASE ) ); options.push_back( caf::PdmOptionItemInfo( SortGroupAppEnum::uiText( ENSEMBLE ), ENSEMBLE ) ); options.push_back( caf::PdmOptionItemInfo( SortGroupAppEnum::uiText( TIME_STEP ), TIME_STEP ) ); @@ -772,26 +777,26 @@ void RimAnalysisPlot::onLoadDataAndUpdate() if ( m_plotWidget ) { - m_plotWidget->detachItems( QwtPlotItem::Rtti_PlotBarChart ); - m_plotWidget->detachItems( QwtPlotItem::Rtti_PlotScale ); + m_plotWidget->qwtPlot()->detachItems( QwtPlotItem::Rtti_PlotBarChart ); + m_plotWidget->qwtPlot()->detachItems( QwtPlotItem::Rtti_PlotScale ); RiuGroupedBarChartBuilder chartBuilder; chartBuilder.setLabelFontSize( barTextFontSize() ); // buildTestPlot( chartBuilder ); addDataToChartBuilder( chartBuilder ); - chartBuilder.addBarChartToPlot( m_plotWidget, + chartBuilder.addBarChartToPlot( m_plotWidget->qwtPlot(), m_barOrientation == BARS_HORIZONTAL ? Qt::Horizontal : Qt::Vertical, m_useTopBarsFilter() ? m_maxBarCount : -1 ); - if ( m_showPlotLegends && m_plotWidget->legend() == nullptr ) + if ( m_showPlotLegends && m_plotWidget->qwtPlot()->legend() == nullptr ) { QwtLegend* legend = new QwtLegend( m_plotWidget ); - m_plotWidget->insertLegend( legend, QwtPlot::RightLegend ); + m_plotWidget->qwtPlot()->insertLegend( legend, QwtPlot::RightLegend ); } else if ( !m_showPlotLegends ) { - m_plotWidget->insertLegend( nullptr ); + m_plotWidget->qwtPlot()->insertLegend( nullptr ); } m_plotWidget->setLegendFontSize( legendFontSize() ); @@ -829,7 +834,7 @@ QString RimAnalysisPlot::description() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuQwtPlotWidget* RimAnalysisPlot::doCreatePlotViewWidget( QWidget* mainWindowParent /*= nullptr */ ) +RiuPlotWidget* RimAnalysisPlot::doCreatePlotViewWidget( QWidget* mainWindowParent /*= nullptr */ ) { if ( !m_plotWidget ) { @@ -847,12 +852,20 @@ RiuQwtPlotWidget* RimAnalysisPlot::viewer() return m_plotWidget; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuPlotWidget* RimAnalysisPlot::plotWidget() +{ + return m_plotWidget; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimAnalysisPlot::detachAllCurves() { - if ( m_plotWidget ) m_plotWidget->detachItems(); + if ( m_plotWidget ) m_plotWidget->qwtPlot()->detachItems(); } //-------------------------------------------------------------------------------------------------- @@ -862,41 +875,41 @@ void RimAnalysisPlot::updateAxes() { if ( !m_plotWidget ) return; - QwtPlot::Axis qwtAxis = QwtPlot::yLeft; + RiuPlotAxis axis = RiuPlotAxis::defaultLeft(); if ( m_barOrientation == BARS_HORIZONTAL ) { - qwtAxis = QwtPlot::xBottom; - m_plotWidget->setAxisTitleEnabled( QwtPlot::yLeft, false ); + axis = RiuPlotAxis::defaultBottom(); + m_plotWidget->setAxisTitleEnabled( RiuPlotAxis::defaultLeft(), false ); } else { - m_plotWidget->setAxisTitleEnabled( QwtPlot::xBottom, false ); + m_plotWidget->setAxisTitleEnabled( RiuPlotAxis::defaultBottom(), false ); } RimPlotAxisProperties* valAxisProperties = m_valueAxisProperties(); if ( valAxisProperties->isActive() ) { - m_plotWidget->enableAxis( qwtAxis, true ); - m_valueAxisProperties->setNameAndAxis( "Value-Axis", qwtAxis ); + m_plotWidget->enableAxis( axis, true ); + m_valueAxisProperties->setNameAndAxis( "Value-Axis", "Value-Axis", axis.axis() ); RimSummaryPlotAxisFormatter calc( valAxisProperties, {}, curveDefinitions(), {}, {} ); calc.applyAxisPropertiesToPlot( m_plotWidget ); } else { - m_plotWidget->enableAxis( qwtAxis, false ); + m_plotWidget->enableAxis( axis, false ); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimAnalysisPlot::onAxisSelected( int axis, bool toggle ) +void RimAnalysisPlot::onAxisSelected( RiuPlotAxis axis, bool toggle ) { RiuPlotMainWindowTools::showPlotMainWindow(); caf::PdmObject* itemToSelect = nullptr; - if ( axis == QwtPlot::yLeft ) + if ( axis.axis() == RiaDefines::PlotAxis::PLOT_AXIS_LEFT ) { if ( m_barOrientation == BARS_VERTICAL ) { @@ -907,7 +920,7 @@ void RimAnalysisPlot::onAxisSelected( int axis, bool toggle ) itemToSelect = this; } } - else if ( axis == QwtPlot::xBottom ) + else if ( axis.axis() == RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM ) { if ( m_barOrientation == BARS_HORIZONTAL ) { @@ -919,14 +932,7 @@ void RimAnalysisPlot::onAxisSelected( int axis, bool toggle ) } } - if ( toggle ) - { - RiuPlotMainWindowTools::toggleItemInSelection( itemToSelect ); - } - else - { - RiuPlotMainWindowTools::selectAsCurrentItem( itemToSelect ); - } + RiuPlotMainWindowTools::selectOrToggleObject( itemToSelect, toggle ); } //-------------------------------------------------------------------------------------------------- @@ -977,11 +983,11 @@ QString RimAnalysisPlot::assignGroupingText( RimAnalysisPlot::SortGroupType sor } } break; - case RimAnalysisPlot::QUANTITY: + case RimAnalysisPlot::VECTOR: { RifEclipseSummaryAddress addr = dataEntry.summaryAddress(); - groupingText = QString::fromStdString( addr.quantityName() ); + groupingText = QString::fromStdString( addr.vectorName() ); } break; case RimAnalysisPlot::TIME_STEP: @@ -1042,7 +1048,7 @@ std::vector RimAnalysisPlot::filteredCurveDefs() RifEclipseSummaryAddress address = curveDef.summaryAddress(); - address.setQuantityName( "" ); // Quantity name set to "" in order to store only unique summary items + address.setVectorName( "" ); // Vector name set to "" in order to store only unique summary items filteredSummaryItems.insert( address ); } } @@ -1062,7 +1068,7 @@ std::vector RimAnalysisPlot::filteredCurveDefs() { RimSummaryCase* sumCase = curveDefCandidate.summaryCase(); RifEclipseSummaryAddress addr = curveDefCandidate.summaryAddress(); - addr.setQuantityName( "" ); + addr.setVectorName( "" ); if ( filteredSumCases.count( sumCase ) && filteredSummaryItems.count( addr ) ) { @@ -1216,8 +1222,8 @@ void RimAnalysisPlot::applyFilter( const RimPlotDataFilterItem* filter, { RifEclipseSummaryAddress historyAddr = addrToFilterValue; - if ( !historyAddr.isHistoryQuantity() ) - historyAddr.setQuantityName( addrToFilterValue.quantityName() + "H" ); + if ( !historyAddr.isHistoryVector() ) + historyAddr.setVectorName( addrToFilterValue.vectorName() + "H" ); const std::vector& historyTimesteps = reader->timeSteps( historyAddr ); if ( historyTimesteps.size() ) @@ -1300,13 +1306,13 @@ void RimAnalysisPlot::applyFilter( const RimPlotDataFilterItem* filter, { RifEclipseSummaryAddress addrToFilterValue = filter->summaryAddress(); - quantityName = addrToFilterValue.quantityName(); + quantityName = addrToFilterValue.vectorName(); } for ( auto sumItem : *filteredSummaryItems ) { RifEclipseSummaryAddress addrToFilterValue = sumItem; - addrToFilterValue.setQuantityName( quantityName ); + addrToFilterValue.setVectorName( quantityName ); if ( filter->filterOperation() == RimPlotDataFilterItem::RANGE ) { @@ -1527,9 +1533,9 @@ void RimAnalysisPlot::addDataToChartBuilder( RiuGroupedBarChartBuilder& chartBui if ( m_useBarText() ) { QStringList barTextComponents; - if ( m_useQuantityInBarText ) + if ( m_useVectorNameInBarText ) { - barTextComponents += QString::fromStdString( curveDef.summaryAddress().quantityName() ); + barTextComponents += QString::fromStdString( curveDef.summaryAddress().vectorName() ); } if ( m_useSummaryItemInBarText ) @@ -1611,7 +1617,7 @@ void RimAnalysisPlot::updatePlotTitle() QString::fromStdString( getOrCreateSelectedCurveDefAnalyser()->m_summaryAdresses.begin()->itemUiText() ); } - for ( std::string quantName : getOrCreateSelectedCurveDefAnalyser()->m_quantityNames ) + for ( std::string quantName : getOrCreateSelectedCurveDefAnalyser()->m_vectorNames ) { if ( !autoTitle.isEmpty() ) autoTitle += separator; autoTitle += QString::fromStdString( quantName ); @@ -1634,8 +1640,8 @@ void RimAnalysisPlot::updatePlotTitle() if ( !autoTitle.isEmpty() ) autoTitle += " @ "; QString formatString = - RiaPreferences::current()->dateTimeFormat( RiaQDateTimeTools::DateFormatComponents::DATE_FORMAT_YEAR_MONTH_DAY, - RiaQDateTimeTools::TimeFormatComponents::TIME_FORMAT_NONE ); + RiaPreferences::current()->dateTimeFormat( RiaDefines::DateFormatComponents::DATE_FORMAT_YEAR_MONTH_DAY, + RiaDefines::TimeFormatComponents::TIME_FORMAT_NONE ); autoTitle += m_selectedTimeSteps()[0].toString( formatString ); } @@ -1788,7 +1794,7 @@ void RimAnalysisPlot::onCaseRemoved( const SignalEmitter* emitter, RimSummaryCas { if ( existingEntry->summaryCase() == summaryCase ) { - m_analysisPlotDataSelection.removeChildObject( existingEntry ); + m_analysisPlotDataSelection.removeChild( existingEntry ); delete existingEntry; break; } diff --git a/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlot.h b/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlot.h index 31cdff91d5..e113fc0538 100644 --- a/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlot.h +++ b/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlot.h @@ -58,7 +58,7 @@ class RimAnalysisPlot : public RimPlot { NONE, SUMMARY_ITEM, - QUANTITY, + VECTOR, CASE, ENSEMBLE, VALUE, @@ -102,8 +102,7 @@ class RimAnalysisPlot : public RimPlot void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; caf::PdmFieldHandle* userDescriptionField() override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; std::set allAvailableTimeSteps(); @@ -127,22 +126,20 @@ class RimAnalysisPlot : public RimPlot // RimPlot Overrides - RiuQwtPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent = nullptr ) override; - RiuQwtPlotWidget* viewer() override; + RiuPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent = nullptr ) override; + RiuQwtPlotWidget* viewer(); + RiuPlotWidget* plotWidget() override; void detachAllCurves() override; void reattachAllCurves() override {} void updateAxes() override; - void onAxisSelected( int axis, bool toggle ) override; - void updateZoomInQwt() override {} - void updateZoomFromQwt() override {} + void onAxisSelected( RiuPlotAxis axis, bool toggle ) override; void setAutoScaleXEnabled( bool enabled ) override {} void setAutoScaleYEnabled( bool enabled ) override {} void updateLegend() override{}; - QString asciiDataForPlotExport() const override { return ""; } - caf::PdmObject* findPdmObjectFromQwtCurve( const QwtPlotCurve* curve ) const override { return nullptr; } + QString asciiDataForPlotExport() const override { return ""; } // Private methods @@ -216,7 +213,7 @@ class RimAnalysisPlot : public RimPlot caf::PdmField m_useEnsembleInBarText; caf::PdmField m_useSummaryItemInBarText; caf::PdmField m_useTimeStepInBarText; - caf::PdmField m_useQuantityInBarText; + caf::PdmField m_useVectorNameInBarText; caf::PdmField m_barTextFontSize; caf::PdmChildField m_valueAxisProperties; diff --git a/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlotCollection.cpp b/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlotCollection.cpp index 394fe93dec..d65e226c06 100644 --- a/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlotCollection.cpp @@ -32,9 +32,9 @@ CAF_PDM_SOURCE_INIT( RimAnalysisPlotCollection, "AnalysisPlotCollection" ); //-------------------------------------------------------------------------------------------------- RimAnalysisPlotCollection::RimAnalysisPlotCollection() { - CAF_PDM_InitObject( "Analysis Plots", ":/AnalysisPlots16x16.png", "", "" ); + CAF_PDM_InitObject( "Analysis Plots", ":/AnalysisPlots16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_analysisPlots, "AnalysisPlots", "Analysis Plots", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_analysisPlots, "AnalysisPlots", "Analysis Plots" ); m_analysisPlots.uiCapability()->setUiTreeHidden( true ); } @@ -123,7 +123,7 @@ void RimAnalysisPlotCollection::updateSummaryNameHasChanged() //-------------------------------------------------------------------------------------------------- std::vector RimAnalysisPlotCollection::plots() const { - return m_analysisPlots.childObjects(); + return m_analysisPlots.children(); } //-------------------------------------------------------------------------------------------------- @@ -209,7 +209,7 @@ void RimAnalysisPlotCollection::applySummaryCaseCollectionAndFieldAddressToPlot( { if ( address.category() == RifEclipseSummaryAddress::SUMMARY_FIELD ) { - if ( quantityName.empty() || quantityName == address.quantityName() ) + if ( quantityName.empty() || quantityName == address.vectorName() ) { for ( auto summaryCase : summaryCaseCollection->allSummaryCases() ) { @@ -263,6 +263,6 @@ void RimAnalysisPlotCollection::insertPlot( RimAnalysisPlot* analysisPlot, size_ //-------------------------------------------------------------------------------------------------- void RimAnalysisPlotCollection::removePlot( RimAnalysisPlot* analysisPlot ) { - m_analysisPlots.removeChildObject( analysisPlot ); + m_analysisPlots.removeChild( analysisPlot ); updateAllRequiredEditors(); } diff --git a/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlotDataEntry.cpp b/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlotDataEntry.cpp index 35e75f1e50..eeb94c7c79 100644 --- a/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlotDataEntry.cpp +++ b/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlotDataEntry.cpp @@ -33,22 +33,22 @@ CAF_PDM_SOURCE_INIT( RimAnalysisPlotDataEntry, "AnalysisPlotDataEntry" ); //-------------------------------------------------------------------------------------------------- RimAnalysisPlotDataEntry::RimAnalysisPlotDataEntry() { - CAF_PDM_InitObject( "Data Entry", "", "", "" ); + CAF_PDM_InitObject( "Data Entry" ); - CAF_PDM_InitFieldNoDefault( &m_summaryCase, "SummaryCase", "Case", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_summaryCase, "SummaryCase", "Case" ); m_summaryCase.uiCapability()->setUiTreeChildrenHidden( true ); m_summaryCase.uiCapability()->setAutoAddingOptionFromValue( false ); - CAF_PDM_InitFieldNoDefault( &m_ensemble, "Ensemble", "Ensemble", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_ensemble, "Ensemble", "Ensemble" ); m_ensemble.uiCapability()->setUiTreeChildrenHidden( true ); m_ensemble.uiCapability()->setAutoAddingOptionFromValue( false ); - CAF_PDM_InitFieldNoDefault( &m_summaryAddress, "SummaryAddress", "Summary Address", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_summaryAddress, "SummaryAddress", "Summary Address" ); m_summaryAddress.uiCapability()->setUiTreeHidden( true ); m_summaryAddress.uiCapability()->setUiTreeChildrenHidden( true ); m_summaryAddress = new RimSummaryAddress; - CAF_PDM_InitField( &m_isEnsembleCurve, "IsEnsembleCurve", false, "Is Ensemble Curve", "", "", "" ); + CAF_PDM_InitField( &m_isEnsembleCurve, "IsEnsembleCurve", false, "Is Ensemble Curve" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimPlotDataFilterCollection.cpp b/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimPlotDataFilterCollection.cpp index 7b7fdedb01..1292b49321 100644 --- a/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimPlotDataFilterCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimPlotDataFilterCollection.cpp @@ -27,11 +27,11 @@ CAF_PDM_SOURCE_INIT( RimPlotDataFilterCollection, "PlotDataFilterCollection" ); RimPlotDataFilterCollection::RimPlotDataFilterCollection() : filtersChanged( this ) { - CAF_PDM_InitObject( "Plot Data Filters", ":/AnalysisPlotFilter16x16.png", "", "" ); + CAF_PDM_InitObject( "Plot Data Filters", ":/AnalysisPlotFilter16x16.png" ); - CAF_PDM_InitField( &m_isActive, "IsActive", true, "IsActive", "", "", "" ); + CAF_PDM_InitField( &m_isActive, "IsActive", true, "IsActive" ); m_isActive.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_filters, "PlotDataFiltersField", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_filters, "PlotDataFiltersField", "" ); m_filters.uiCapability()->setUiTreeHidden( true ); } @@ -56,7 +56,7 @@ RimPlotDataFilterItem* RimPlotDataFilterCollection::addFilter() //-------------------------------------------------------------------------------------------------- void RimPlotDataFilterCollection::removeFilter( RimPlotDataFilterItem* filter ) { - m_filters.removeChildObject( filter ); + m_filters.removeChild( filter ); delete filter; filtersChanged.send(); @@ -67,7 +67,7 @@ void RimPlotDataFilterCollection::removeFilter( RimPlotDataFilterItem* filter ) //-------------------------------------------------------------------------------------------------- std::vector RimPlotDataFilterCollection::filters() const { - return m_filters.childObjects(); + return m_filters.children(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimPlotDataFilterItem.cpp b/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimPlotDataFilterItem.cpp index 2b7d382f7b..c0528617cd 100644 --- a/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimPlotDataFilterItem.cpp +++ b/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimPlotDataFilterItem.cpp @@ -83,39 +83,39 @@ RimPlotDataFilterItem::RimPlotDataFilterItem() , m_upperLimit( std::numeric_limits::infinity() ) , filterChanged( this ) { - CAF_PDM_InitObject( "Plot Data Filter", ":/AnalysisPlotFilter16x16.png", "", "" ); + CAF_PDM_InitObject( "Plot Data Filter", ":/AnalysisPlotFilter16x16.png" ); - CAF_PDM_InitField( &m_isActive, "IsActive", true, "Active", "", "", "" ); + CAF_PDM_InitField( &m_isActive, "IsActive", true, "Active" ); m_isActive.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_filterTarget, "FilterTarget", "Use only the", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_filterTarget, "FilterTarget", "Use only the" ); - CAF_PDM_InitFieldNoDefault( &m_filterAddress, "FilterAddressField", "Filter Address", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_filterAddress, "FilterAddressField", "Filter Address" ); m_filterAddress.uiCapability()->setUiTreeHidden( true ); m_filterAddress.uiCapability()->setUiTreeChildrenHidden( true ); m_filterAddress = new RimSummaryAddress(); - CAF_PDM_InitField( &m_filterEnsembleParameter, "QuantityText", QString( "" ), "where", "", "", "" ); + CAF_PDM_InitField( &m_filterEnsembleParameter, "QuantityText", QString( "" ), "where" ); - CAF_PDM_InitFieldNoDefault( &m_filterQuantityUiField, "SelectedVariableDisplayVar", "where", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_filterQuantityUiField, "SelectedVariableDisplayVar", "where" ); m_filterQuantityUiField.xmlCapability()->disableIO(); m_filterQuantityUiField.uiCapability()->setUiEditorTypeName( caf::PdmUiLineEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_filterQuantitySelectButton, "SelectAddress", false, "...", "", "", "" ); + CAF_PDM_InitField( &m_filterQuantitySelectButton, "SelectAddress", false, "..." ); caf::PdmUiActionPushButtonEditor::configureEditorForField( &m_filterQuantitySelectButton ); - CAF_PDM_InitFieldNoDefault( &m_filterOperation, "FilterOperation", "is", "", "", "" ); - CAF_PDM_InitField( &m_topBottomN, "MinTopN", 20, "N", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_filterOperation, "FilterOperation", "is" ); + CAF_PDM_InitField( &m_topBottomN, "MinTopN", 20, "N" ); m_topBottomN.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); - CAF_PDM_InitField( &m_max, "Max", m_upperLimit, "Max", "", "", "" ); + CAF_PDM_InitField( &m_max, "Max", m_upperLimit, "Max" ); m_max.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_min, "Min", m_lowerLimit, "Min", "", "", "" ); + CAF_PDM_InitField( &m_min, "Min", m_lowerLimit, "Min" ); m_min.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_ensembleParameterValueCategories, "EnsembleParameterValueCategories", "one of", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_consideredTimestepsType, "ConsideredTimestepsType", "at the", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_explicitlySelectedTimeSteps, "ExplicitlySelectedTimeSteps", "TimeSteps", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_ensembleParameterValueCategories, "EnsembleParameterValueCategories", "one of" ); + CAF_PDM_InitFieldNoDefault( &m_consideredTimestepsType, "ConsideredTimestepsType", "at the" ); + CAF_PDM_InitFieldNoDefault( &m_explicitlySelectedTimeSteps, "ExplicitlySelectedTimeSteps", "TimeSteps" ); m_explicitlySelectedTimeSteps.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() ); m_explicitlySelectedTimeSteps.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); @@ -269,8 +269,7 @@ void RimPlotDataFilterItem::fieldChangedByUi( const caf::PdmFieldHandle* changed //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList - RimPlotDataFilterItem::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) +QList RimPlotDataFilterItem::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; RimAnalysisPlot* parentPlot; @@ -365,7 +364,7 @@ void RimPlotDataFilterItem::defineUiOrdering( QString uiConfigName, caf::PdmUiOr eParm = selectedEnsembleParameter(); } - if ( m_filterTarget() == ENSEMBLE_CASE && eParm.isText() ) // Ensemble Quantity is a category value + if ( m_filterTarget() == ENSEMBLE_CASE && eParm.isText() ) // Ensemble vector is a category value { uiOrdering.add( &m_ensembleParameterValueCategories ); } diff --git a/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimPlotDataFilterItem.h b/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimPlotDataFilterItem.h index a145ebf03a..d80c4c8bdd 100644 --- a/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimPlotDataFilterItem.h +++ b/ApplicationLibCode/ProjectDataModel/AnalysisPlots/RimPlotDataFilterItem.h @@ -41,7 +41,7 @@ class RimPlotAxisProperties; class RimSummaryAddress; // Filter of type : -// Only [Cases/SummaryItem/Case by ensemble param] where the [Quantity] +// Only [Cases/SummaryItem/Case by ensemble param] where the [Vector] // is [within range/top N/min N] // considering the [Plot Source/Last/First/Last with History/all] timestep(s) [range/1,2..] @@ -113,8 +113,7 @@ class RimPlotDataFilterItem : public caf::PdmObject caf::PdmUiEditorAttribute* attribute ) override; caf::PdmFieldHandle* objectToggleField() override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; RigEnsembleParameter selectedEnsembleParameter() const; @@ -122,9 +121,7 @@ class RimPlotDataFilterItem : public caf::PdmObject caf::PdmField> m_filterTarget; - // Quantity - - // Complete address or quantity name only + // Complete address or vector name only caf::PdmChildField m_filterAddress; caf::PdmField m_filterEnsembleParameter; caf::PdmField m_filterQuantityUiField; diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationCollection.cpp b/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationCollection.cpp index c97eb9aaa8..7361fa7ebb 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationCollection.cpp @@ -41,16 +41,13 @@ CAF_PDM_SOURCE_INIT( RimAnnotationCollection, "RimAnnotationCollection" ); //-------------------------------------------------------------------------------------------------- RimAnnotationCollection::RimAnnotationCollection() { - CAF_PDM_InitObject( "Annotations", ":/Annotations16x16.png", "", "" ); + CAF_PDM_InitObject( "Annotations", ":/Annotations16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_reachCircleAnnotations, "ReachCircleAnnotations", "Reach Circle Annotations", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_reachCircleAnnotations, "ReachCircleAnnotations", "Reach Circle Annotations" ); CAF_PDM_InitFieldNoDefault( &m_userDefinedPolylineAnnotations, "UserDefinedPolylineAnnotations", - "User Defined Polyline Annotations", - "", - "", - "" ); - CAF_PDM_InitFieldNoDefault( &m_polylineFromFileAnnotations, "PolylineFromFileAnnotations", "Polylines From File", "", "", "" ); + "User Defined Polyline Annotations" ); + CAF_PDM_InitFieldNoDefault( &m_polylineFromFileAnnotations, "PolylineFromFileAnnotations", "Polylines From File" ); m_reachCircleAnnotations.uiCapability()->setUiTreeHidden( true ); m_userDefinedPolylineAnnotations.uiCapability()->setUiTreeHidden( true ); diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationCollectionBase.cpp b/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationCollectionBase.cpp index 141f9c30b8..5be5b6c3f4 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationCollectionBase.cpp +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationCollectionBase.cpp @@ -36,12 +36,12 @@ CAF_PDM_SOURCE_INIT( RimAnnotationCollectionBase, "RimAnnotationCollectionBase" //-------------------------------------------------------------------------------------------------- RimAnnotationCollectionBase::RimAnnotationCollectionBase() { - CAF_PDM_InitObject( "Annotations", ":/WellCollection.png", "", "" ); + CAF_PDM_InitObject( "Annotations", ":/WellCollection.png" ); - CAF_PDM_InitField( &m_isActive, "IsActive", true, "Is Active", "", "", "" ); + CAF_PDM_InitField( &m_isActive, "IsActive", true, "Is Active" ); m_isActive.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_textAnnotations, "TextAnnotations", "Text Annotations", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_textAnnotations, "TextAnnotations", "Text Annotations" ); m_textAnnotations.uiCapability()->setUiTreeHidden( true ); m_textAnnotations = new RimAnnotationGroupCollection(); diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationGroupCollection.cpp b/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationGroupCollection.cpp index 7b261a9d24..7e6ba9cb74 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationGroupCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationGroupCollection.cpp @@ -44,10 +44,10 @@ const QString RimAnnotationGroupCollection::POLYLINE_FROM_FILE_ANNOTATION_UI_NAM //-------------------------------------------------------------------------------------------------- RimAnnotationGroupCollection::RimAnnotationGroupCollection() { - CAF_PDM_InitObject( "Annotations", ":/WellCollection.png", "", "" ); + CAF_PDM_InitObject( "Annotations", ":/WellCollection.png" ); - CAF_PDM_InitField( &m_isActive, "IsActive", true, "Is Active", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_annotations, "Annotations", "Annotations", "", "", "" ); + CAF_PDM_InitField( &m_isActive, "IsActive", true, "Is Active" ); + CAF_PDM_InitFieldNoDefault( &m_annotations, "Annotations", "Annotations" ); m_isActive.uiCapability()->setUiHidden( true ); m_annotations.uiCapability()->setUiTreeHidden( true ); @@ -95,7 +95,7 @@ void RimAnnotationGroupCollection::addAnnotation( caf::PdmObject* annotation ) //-------------------------------------------------------------------------------------------------- void RimAnnotationGroupCollection::removeAnnotation( caf::PdmObject* annotation ) { - m_annotations.removeChildObject( annotation ); + m_annotations.removeChild( annotation ); } //-------------------------------------------------------------------------------------------------- @@ -103,7 +103,7 @@ void RimAnnotationGroupCollection::removeAnnotation( caf::PdmObject* annotation //-------------------------------------------------------------------------------------------------- std::vector RimAnnotationGroupCollection::annotations() const { - return m_annotations.childObjects(); + return m_annotations.children(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationInViewCollection.cpp b/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationInViewCollection.cpp index 47229d8f1e..7ac97848f7 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationInViewCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationInViewCollection.cpp @@ -78,35 +78,26 @@ CAF_PDM_SOURCE_INIT( RimAnnotationInViewCollection, "Annotations" ); //-------------------------------------------------------------------------------------------------- RimAnnotationInViewCollection::RimAnnotationInViewCollection() { - CAF_PDM_InitObject( "Annotations", ":/Annotations16x16.png", "", "" ); + CAF_PDM_InitObject( "Annotations", ":/Annotations16x16.png" ); - CAF_PDM_InitField( &m_annotationPlaneDepth, "AnnotationPlaneDepth", 0.0, "Annotation Plane Depth", "", "", "" ); - CAF_PDM_InitField( &m_snapAnnotations, "SnapAnnotations", false, "Snap Annotations to Plane", "", "", "" ); + CAF_PDM_InitField( &m_annotationPlaneDepth, "AnnotationPlaneDepth", 0.0, "Annotation Plane Depth" ); + CAF_PDM_InitField( &m_snapAnnotations, "SnapAnnotations", false, "Snap Annotations to Plane" ); m_annotationPlaneDepth.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); m_annotationPlaneDepth.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosType::TOP ); - CAF_PDM_InitFieldNoDefault( &m_globalTextAnnotations, "TextAnnotationsInView", "Global Text Annotations", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_globalTextAnnotations, "TextAnnotationsInView", "Global Text Annotations" ); CAF_PDM_InitFieldNoDefault( &m_globalReachCircleAnnotations, "ReachCircleAnnotationsInView", - "Global Reach Circle Annotations", - "", - "", - "" ); + "Global Reach Circle Annotations" ); CAF_PDM_InitFieldNoDefault( &m_globalUserDefinedPolylineAnnotations, "UserDefinedPolylinesAnnotationsInView", - "Global User Defined Polylines Annotations", - "", - "", - "" ); + "Global User Defined Polylines Annotations" ); CAF_PDM_InitFieldNoDefault( &m_globalPolylineFromFileAnnotations, "PolylinesFromFileAnnotationsInView", - "Global Polylines From File Annotations", - "", - "", - "" ); + "Global Polylines From File Annotations" ); - CAF_PDM_InitFieldNoDefault( &m_annotationFontSize, "AnnotationFontSize", "Default Font Size", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_annotationFontSize, "AnnotationFontSize", "Default Font Size" ); m_globalTextAnnotations.uiCapability()->setUiTreeHidden( true ); m_globalReachCircleAnnotations.uiCapability()->setUiTreeHidden( true ); diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationLineAppearance.cpp b/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationLineAppearance.cpp index 1f3b55dde6..c759ff1f57 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationLineAppearance.cpp +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationLineAppearance.cpp @@ -63,14 +63,14 @@ CAF_PDM_SOURCE_INIT( RimAnnotationLineAppearance, "RimAnnotationLineAppearance" RimAnnotationLineAppearance::RimAnnotationLineAppearance() : objectChanged( this ) { - CAF_PDM_InitObject( "AnnotationLineAppearance", ":/WellCollection.png", "", "" ); + CAF_PDM_InitObject( "AnnotationLineAppearance", ":/WellCollection.png" ); - CAF_PDM_InitField( &m_lineFieldsHidden, "LineFieldsHidden", false, "Line Fields Hidden", "", "", "" ); - CAF_PDM_InitField( &m_color, "Color", cvf::Color3f( cvf::Color3f::BLACK ), "Line Color", "", "", "" ); - CAF_PDM_InitField( &m_thickness, "Thickness", 2, "Line Thickness", "", "", "" ); + CAF_PDM_InitField( &m_lineFieldsHidden, "LineFieldsHidden", false, "Line Fields Hidden" ); + CAF_PDM_InitField( &m_color, "Color", cvf::Color3f( cvf::Color3f::BLACK ), "Line Color" ); + CAF_PDM_InitField( &m_thickness, "Thickness", 2, "Line Thickness" ); // Stippling not yet supported. Needs new stuff in VizFwk - CAF_PDM_InitField( &m_style, "Style", LineStyle(), "Style", "", "", "" ); + CAF_PDM_InitField( &m_style, "Style", LineStyle(), "Style" ); m_style.uiCapability()->setUiHidden( true ); m_style.xmlCapability()->disableIO(); @@ -170,11 +170,11 @@ CAF_PDM_SOURCE_INIT( RimPolylineAppearance, "RimPolylineAppearance" ); //-------------------------------------------------------------------------------------------------- RimPolylineAppearance::RimPolylineAppearance() { - CAF_PDM_InitObject( "PolylineAppearance", ":/WellCollection.png", "", "" ); + CAF_PDM_InitObject( "PolylineAppearance", ":/WellCollection.png" ); - CAF_PDM_InitField( &m_sphereFieldsHidden, "SphereFieldsHidden", false, "Sphere Fields Hidden", "", "", "" ); - CAF_PDM_InitField( &m_sphereColor, "SphereColor", cvf::Color3f( cvf::Color3f::BLACK ), "Sphere Color", "", "", "" ); - CAF_PDM_InitField( &m_sphereRadiusFactor, "SphereRadiusFactor", 0.1, "Sphere Radius Factor", "", "", "" ); + CAF_PDM_InitField( &m_sphereFieldsHidden, "SphereFieldsHidden", false, "Sphere Fields Hidden" ); + CAF_PDM_InitField( &m_sphereColor, "SphereColor", cvf::Color3f( cvf::Color3f::BLACK ), "Sphere Color" ); + CAF_PDM_InitField( &m_sphereRadiusFactor, "SphereRadiusFactor", 0.1, "Sphere Radius Factor" ); m_sphereFieldsHidden.uiCapability()->setUiHidden( true ); } diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationTextAppearance.cpp b/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationTextAppearance.cpp index 3e1fa1514c..0ec4b02224 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationTextAppearance.cpp +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimAnnotationTextAppearance.cpp @@ -30,23 +30,17 @@ CAF_PDM_SOURCE_INIT( RimAnnotationTextAppearance, "RimAnnotationTextAppearance" //-------------------------------------------------------------------------------------------------- RimAnnotationTextAppearance::RimAnnotationTextAppearance() { - CAF_PDM_InitObject( "TextAnnotation", ":/WellCollection.png", "", "" ); + CAF_PDM_InitObject( "TextAnnotation", ":/WellCollection.png" ); auto prefs = RiaPreferences::current(); auto defaultBackgroundColor = prefs->defaultViewerBackgroundColor(); - CAF_PDM_InitFieldNoDefault( &m_fontSize, "FontSize", "Font Size", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_fontSize, "FontSize", "Font Size" ); m_fontSize = prefs->defaultAnnotationFontSize(); - CAF_PDM_InitField( &m_fontColor, "FontColor", cvf::Color3f( cvf::Color3f::BLACK ), "Font Color", "", "", "" ); - CAF_PDM_InitField( &m_backgroundColor, "BackgroundColor", defaultBackgroundColor, "Background Color", "", "", "" ); - CAF_PDM_InitField( &m_anchorLineColor, - "AnchorLineColor", - cvf::Color3f( cvf::Color3f::BLACK ), - "Anchor Line Color", - "", - "", - "" ); + CAF_PDM_InitField( &m_fontColor, "FontColor", cvf::Color3f( cvf::Color3f::BLACK ), "Font Color" ); + CAF_PDM_InitField( &m_backgroundColor, "BackgroundColor", defaultBackgroundColor, "Background Color" ); + CAF_PDM_InitField( &m_anchorLineColor, "AnchorLineColor", cvf::Color3f( cvf::Color3f::BLACK ), "Anchor Line Color" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylineTarget.cpp b/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylineTarget.cpp index 435d332b39..2fd27bce05 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylineTarget.cpp +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylineTarget.cpp @@ -31,8 +31,8 @@ CAF_PDM_SOURCE_INIT( RimPolylineTarget, "PolylineTarget" ); RimPolylineTarget::RimPolylineTarget() : m_isFullUpdateEnabled( true ) { - CAF_PDM_InitField( &m_isEnabled, "IsEnabled", true, "", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_targetPointXyd, "TargetPointXyd", "Point", "", "", "" ); + CAF_PDM_InitField( &m_isEnabled, "IsEnabled", true, "" ); + CAF_PDM_InitFieldNoDefault( &m_targetPointXyd, "TargetPointXyd", "Point" ); } //-------------------------------------------------------------------------------------------------- @@ -95,8 +95,7 @@ void RimPolylineTarget::enableFullUpdate( bool enable ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimPolylineTarget::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RimPolylineTarget::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; return options; diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylineTarget.h b/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylineTarget.h index a094c6e9ba..91b22baed8 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylineTarget.h +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylineTarget.h @@ -50,8 +50,7 @@ class RimPolylineTarget : public caf::PdmObject void triggerVisualizationUpdate() const; private: - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; private: diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesAnnotation.cpp b/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesAnnotation.cpp index 5287b7bcf3..49c5ab77ca 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesAnnotation.cpp +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesAnnotation.cpp @@ -35,16 +35,16 @@ CAF_PDM_ABSTRACT_SOURCE_INIT( RimPolylinesAnnotation, "RimPolylinesAnnotation" ) //-------------------------------------------------------------------------------------------------- RimPolylinesAnnotation::RimPolylinesAnnotation() { - CAF_PDM_InitObject( "PolylineAnnotation", ":/WellCollection.png", "", "" ); + CAF_PDM_InitObject( "PolylineAnnotation", ":/WellCollection.png" ); - CAF_PDM_InitField( &m_isActive, "IsActive", true, "Is Active", "", "", "" ); + CAF_PDM_InitField( &m_isActive, "IsActive", true, "Is Active" ); m_isActive.uiCapability()->setUiHidden( true ); - CAF_PDM_InitField( &m_closePolyline, "ClosePolyline", false, "Close Polyline", "", "", "" ); - CAF_PDM_InitField( &m_showLines, "ShowLines", true, "Show Lines", "", "", "" ); - CAF_PDM_InitField( &m_showSpheres, "ShowSpheres", false, "Show Spheres", "", "", "" ); + CAF_PDM_InitField( &m_closePolyline, "ClosePolyline", false, "Close Polyline" ); + CAF_PDM_InitField( &m_showLines, "ShowLines", true, "Show Lines" ); + CAF_PDM_InitField( &m_showSpheres, "ShowSpheres", false, "Show Spheres" ); - CAF_PDM_InitFieldNoDefault( &m_appearance, "Appearance", "Appearance", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_appearance, "Appearance", "Appearance" ); m_appearance = new RimPolylineAppearance(); m_appearance.uiCapability()->setUiTreeHidden( true ); diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesAnnotationInView.cpp b/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesAnnotationInView.cpp index a2dda86312..53a2825a04 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesAnnotationInView.cpp +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesAnnotationInView.cpp @@ -31,10 +31,10 @@ CAF_PDM_SOURCE_INIT( RimPolylinesAnnotationInView, "RimPolylinesAnnotationInView //-------------------------------------------------------------------------------------------------- RimPolylinesAnnotationInView::RimPolylinesAnnotationInView() { - CAF_PDM_InitObject( "PolyLinesAnnotationInView", ":/WellCollection.png", "", "" ); + CAF_PDM_InitObject( "PolyLinesAnnotationInView", ":/WellCollection.png" ); - CAF_PDM_InitField( &m_isActive, "IsActive", true, "Is Active", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_sourceAnnotation, "SourceAnnotation", "Source Annotation", "", "", "" ); + CAF_PDM_InitField( &m_isActive, "IsActive", true, "Is Active" ); + CAF_PDM_InitFieldNoDefault( &m_sourceAnnotation, "SourceAnnotation", "Source Annotation" ); m_isActive.uiCapability()->setUiHidden( true ); m_sourceAnnotation.uiCapability()->setUiHidden( true ); diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesFromFileAnnotation.cpp b/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesFromFileAnnotation.cpp index 9c35c70fa7..0a42c0587f 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesFromFileAnnotation.cpp +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesFromFileAnnotation.cpp @@ -19,7 +19,9 @@ #include "RimPolylinesFromFileAnnotation.h" #include "RiaLogging.h" +#include "RiaTextStringTools.h" #include "RigPolyLinesData.h" + #include "RimAnnotationCollection.h" #include "RimAnnotationLineAppearance.h" @@ -35,10 +37,10 @@ CAF_PDM_SOURCE_INIT( RimPolylinesFromFileAnnotation, "PolylinesFromFileAnnotatio //-------------------------------------------------------------------------------------------------- RimPolylinesFromFileAnnotation::RimPolylinesFromFileAnnotation() { - CAF_PDM_InitObject( "PolyLines Annotation", ":/PolylinesFromFile16x16.png", "", "" ); + CAF_PDM_InitObject( "PolyLines Annotation", ":/PolylinesFromFile16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_polyLinesFileName, "PolyLineFilePath", "File", "", "", "" ); - CAF_PDM_InitField( &m_userDescription, "PolyLineDescription", QString( "" ), "Name", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_polyLinesFileName, "PolyLineFilePath", "File" ); + CAF_PDM_InitField( &m_userDescription, "PolyLineDescription", QString( "" ), "Name" ); } //-------------------------------------------------------------------------------------------------- @@ -86,10 +88,10 @@ void RimPolylinesFromFileAnnotation::readPolyLinesFile( QString* errorMessage ) while ( !stream.atEnd() ) { QString line = stream.readLine(); - QStringList commentLineSegs = line.split( "#", QString::KeepEmptyParts ); + QStringList commentLineSegs = line.split( "#" ); if ( commentLineSegs.empty() ) continue; // Empty line - QStringList lineSegs = commentLineSegs[0].split( QRegExp( "\\s+" ), QString::SkipEmptyParts ); + QStringList lineSegs = RiaTextStringTools::splitSkipEmptyParts( commentLineSegs[0], QRegExp( "\\s+" ) ); if ( lineSegs.empty() ) continue; // No data diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesFromFileAnnotationInView.cpp b/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesFromFileAnnotationInView.cpp index 16cbb8ff86..4905bd91a7 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesFromFileAnnotationInView.cpp +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesFromFileAnnotationInView.cpp @@ -26,7 +26,7 @@ CAF_PDM_SOURCE_INIT( RimPolylinesFromFileAnnotationInView, "RimPolylinesFromFile //-------------------------------------------------------------------------------------------------- RimPolylinesFromFileAnnotationInView::RimPolylinesFromFileAnnotationInView() { - CAF_PDM_InitObject( "PolyLines Annotation", ":/PolylinesFromFile16x16.png", "", "" ); + CAF_PDM_InitObject( "PolyLines Annotation", ":/PolylinesFromFile16x16.png" ); } //-------------------------------------------------------------------------------------------------- @@ -35,5 +35,5 @@ RimPolylinesFromFileAnnotationInView::RimPolylinesFromFileAnnotationInView() RimPolylinesFromFileAnnotationInView::RimPolylinesFromFileAnnotationInView( RimPolylinesFromFileAnnotation* sourceAnnotation ) : RimPolylinesAnnotationInView( sourceAnnotation ) { - CAF_PDM_InitObject( "PolyLines Annotation", ":/PolylinesFromFile16x16.png", "", "" ); + CAF_PDM_InitObject( "PolyLines Annotation", ":/PolylinesFromFile16x16.png" ); } diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimReachCircleAnnotation.cpp b/ApplicationLibCode/ProjectDataModel/Annotations/RimReachCircleAnnotation.cpp index eb648d7191..37a9ef3d59 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimReachCircleAnnotation.cpp +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimReachCircleAnnotation.cpp @@ -36,21 +36,21 @@ CAF_PDM_SOURCE_INIT( RimReachCircleAnnotation, "RimReachCircleAnnotation" ); //-------------------------------------------------------------------------------------------------- RimReachCircleAnnotation::RimReachCircleAnnotation() { - CAF_PDM_InitObject( "CircleAnnotation", ":/ReachCircle16x16.png", "", "" ); + CAF_PDM_InitObject( "CircleAnnotation", ":/ReachCircle16x16.png" ); - CAF_PDM_InitField( &m_isActive, "IsActive", true, "Is Active", "", "", "" ); + CAF_PDM_InitField( &m_isActive, "IsActive", true, "Is Active" ); m_isActive.uiCapability()->setUiHidden( true ); - CAF_PDM_InitField( &m_centerPointXyd, "CenterPointXyd", Vec3d::ZERO, "Center Point", "", "", "" ); + CAF_PDM_InitField( &m_centerPointXyd, "CenterPointXyd", Vec3d::ZERO, "Center Point" ); m_centerPointXyd.uiCapability()->setUiEditorTypeName( caf::PdmUiPickableLineEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_centerPointPickEnabled, "AnchorPointPick", false, "", "", "", "" ); + CAF_PDM_InitField( &m_centerPointPickEnabled, "AnchorPointPick", false, "" ); caf::PdmUiPushButtonEditor::configureEditorForField( &m_centerPointPickEnabled ); m_centerPointPickEnabled.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosType::HIDDEN ); - CAF_PDM_InitField( &m_radius, "Radius", 100.0, "Radius", "", "", "" ); - CAF_PDM_InitField( &m_name, "Name", QString( "Circle Annotation" ), "Name", "", "", "" ); + CAF_PDM_InitField( &m_radius, "Radius", 100.0, "Radius" ); + CAF_PDM_InitField( &m_name, "Name", QString( "Circle Annotation" ), "Name" ); - CAF_PDM_InitFieldNoDefault( &m_appearance, "Appearance", "Appearance", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_appearance, "Appearance", "Appearance" ); m_appearance = new RimReachCircleLineAppearance(); m_appearance.uiCapability()->setUiTreeHidden( true ); diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimReachCircleAnnotationInView.cpp b/ApplicationLibCode/ProjectDataModel/Annotations/RimReachCircleAnnotationInView.cpp index ec8f49c0cd..b18f59782d 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimReachCircleAnnotationInView.cpp +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimReachCircleAnnotationInView.cpp @@ -28,10 +28,10 @@ CAF_PDM_SOURCE_INIT( RimReachCircleAnnotationInView, "RimReachCircleAnnotationIn //-------------------------------------------------------------------------------------------------- RimReachCircleAnnotationInView::RimReachCircleAnnotationInView() { - CAF_PDM_InitObject( "ReachCircleAnnotationInView", ":/ReachCircle16x16.png", "", "" ); + CAF_PDM_InitObject( "ReachCircleAnnotationInView", ":/ReachCircle16x16.png" ); - CAF_PDM_InitField( &m_isActive, "IsActive", true, "Is Active", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_sourceAnnotation, "SourceAnnotation", "Source Annotation", "", "", "" ); + CAF_PDM_InitField( &m_isActive, "IsActive", true, "Is Active" ); + CAF_PDM_InitFieldNoDefault( &m_sourceAnnotation, "SourceAnnotation", "Source Annotation" ); m_isActive.uiCapability()->setUiHidden( true ); m_sourceAnnotation.uiCapability()->setUiHidden( true ); diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimTextAnnotation.cpp b/ApplicationLibCode/ProjectDataModel/Annotations/RimTextAnnotation.cpp index 4912c4b77c..fad0366e2e 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimTextAnnotation.cpp +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimTextAnnotation.cpp @@ -44,33 +44,33 @@ CAF_PDM_SOURCE_INIT( RimTextAnnotation, "RimTextAnnotation" ); //-------------------------------------------------------------------------------------------------- RimTextAnnotation::RimTextAnnotation() { - CAF_PDM_InitObject( "TextAnnotation", ":/TextAnnotation16x16.png", "", "" ); + CAF_PDM_InitObject( "TextAnnotation", ":/TextAnnotation16x16.png" ); this->setUi3dEditorTypeName( RicTextAnnotation3dEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_anchorPointXyd, "AnchorPointXyd", Vec3d::ZERO, "Anchor Point", "", "", "" ); + CAF_PDM_InitField( &m_anchorPointXyd, "AnchorPointXyd", Vec3d::ZERO, "Anchor Point" ); m_anchorPointXyd.uiCapability()->setUiEditorTypeName( caf::PdmUiPickableLineEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_anchorPointPickEnabledButtonField, "AnchorPointPick", false, "", "", "", "" ); + CAF_PDM_InitField( &m_anchorPointPickEnabledButtonField, "AnchorPointPick", false, "" ); caf::PdmUiPushButtonEditor::configureEditorForField( &m_anchorPointPickEnabledButtonField ); m_anchorPointPickEnabledButtonField.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosType::HIDDEN ); - CAF_PDM_InitField( &m_labelPointXyd, "LabelPointXyd", Vec3d::ZERO, "Label Point", "", "", "" ); + CAF_PDM_InitField( &m_labelPointXyd, "LabelPointXyd", Vec3d::ZERO, "Label Point" ); m_labelPointXyd.uiCapability()->setUiEditorTypeName( caf::PdmUiPickableLineEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_labelPointPickEnabledButtonField, "LabelPointPick", false, "", "", "", "" ); + CAF_PDM_InitField( &m_labelPointPickEnabledButtonField, "LabelPointPick", false, "" ); caf::PdmUiPushButtonEditor::configureEditorForField( &m_labelPointPickEnabledButtonField ); m_labelPointPickEnabledButtonField.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosType::HIDDEN ); - CAF_PDM_InitField( &m_text, "Text", QString( "(New text)" ), "Text", "", "", "" ); + CAF_PDM_InitField( &m_text, "Text", QString( "(New text)" ), "Text" ); m_text.uiCapability()->setUiEditorTypeName( caf::PdmUiTextEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_isActive, "IsActive", true, "Is Active", "", "", "" ); + CAF_PDM_InitField( &m_isActive, "IsActive", true, "Is Active" ); m_isActive.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_textAppearance, "TextAppearance", "Text Appearance", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_textAppearance, "TextAppearance", "Text Appearance" ); m_textAppearance = new RimAnnotationTextAppearance(); m_textAppearance.uiCapability()->setUiTreeHidden( true ); m_textAppearance.uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_nameProxy, "NameProxy", "Name Proxy", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_nameProxy, "NameProxy", "Name Proxy" ); m_nameProxy.registerGetMethod( this, &RimTextAnnotation::extractNameFromText ); m_nameProxy.uiCapability()->setUiReadOnly( true ); m_nameProxy.xmlCapability()->disableIO(); diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimTextAnnotationInView.cpp b/ApplicationLibCode/ProjectDataModel/Annotations/RimTextAnnotationInView.cpp index 3b8f6a80e8..47a7cccf01 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimTextAnnotationInView.cpp +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimTextAnnotationInView.cpp @@ -28,10 +28,10 @@ CAF_PDM_SOURCE_INIT( RimTextAnnotationInView, "RimTextAnnotationInView" ); //-------------------------------------------------------------------------------------------------- RimTextAnnotationInView::RimTextAnnotationInView() { - CAF_PDM_InitObject( "TextAnnotationInView", ":/TextAnnotation16x16.png", "", "" ); + CAF_PDM_InitObject( "TextAnnotationInView", ":/TextAnnotation16x16.png" ); - CAF_PDM_InitField( &m_isActive, "IsActive", true, "Is Active", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_sourceAnnotation, "SourceAnnotation", "Source Annotation", "", "", "" ); + CAF_PDM_InitField( &m_isActive, "IsActive", true, "Is Active" ); + CAF_PDM_InitFieldNoDefault( &m_sourceAnnotation, "SourceAnnotation", "Source Annotation" ); m_isActive.uiCapability()->setUiHidden( true ); m_sourceAnnotation.uiCapability()->setUiHidden( true ); diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimUserDefinedPolylinesAnnotation.cpp b/ApplicationLibCode/ProjectDataModel/Annotations/RimUserDefinedPolylinesAnnotation.cpp index 4b32332d56..15065996a4 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimUserDefinedPolylinesAnnotation.cpp +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimUserDefinedPolylinesAnnotation.cpp @@ -44,15 +44,15 @@ CAF_PDM_SOURCE_INIT( RimUserDefinedPolylinesAnnotation, "UserDefinedPolylinesAnn RimUserDefinedPolylinesAnnotation::RimUserDefinedPolylinesAnnotation() : m_pickTargetsEventHandler( new RicPolylineTargetsPickEventHandler( this ) ) { - CAF_PDM_InitObject( "PolyLines Annotation", ":/PolylinesFromFile16x16.png", "", "" ); + CAF_PDM_InitObject( "PolyLines Annotation", ":/PolylinesFromFile16x16.png" ); - CAF_PDM_InitField( &m_name, "Name", QString( "User Defined Polyline" ), "Name", "", "", "" ); + CAF_PDM_InitField( &m_name, "Name", QString( "User Defined Polyline" ), "Name" ); - CAF_PDM_InitField( &m_enablePicking, "EnablePicking", false, "", "", "", "" ); + CAF_PDM_InitField( &m_enablePicking, "EnablePicking", false, "" ); caf::PdmUiPushButtonEditor::configureEditorForField( &m_enablePicking ); m_enablePicking.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosType::HIDDEN ); - CAF_PDM_InitFieldNoDefault( &m_targets, "Targets", "Targets", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_targets, "Targets", "Targets" ); m_targets.uiCapability()->setUiEditorTypeName( caf::PdmUiTableViewEditor::uiEditorTypeName() ); // m_targets.uiCapability()->setUiTreeHidden(true); m_targets.uiCapability()->setUiTreeChildrenHidden( true ); @@ -95,7 +95,7 @@ cvf::ref RimUserDefinedPolylinesAnnotation::polyLinesData() //-------------------------------------------------------------------------------------------------- std::vector RimUserDefinedPolylinesAnnotation::activeTargets() const { - return m_targets.childObjects(); + return m_targets.children(); } //-------------------------------------------------------------------------------------------------- @@ -113,7 +113,7 @@ void RimUserDefinedPolylinesAnnotation::appendTarget( const cvf::Vec3d& defaultP { RimPolylineTarget* target = nullptr; - auto targets = m_targets.childObjects(); + auto targets = m_targets.children(); if ( targets.empty() ) { target = new RimPolylineTarget(); @@ -137,7 +137,7 @@ void RimUserDefinedPolylinesAnnotation::appendTarget( const cvf::Vec3d& defaultP void RimUserDefinedPolylinesAnnotation::insertTarget( const RimPolylineTarget* targetToInsertBefore, RimPolylineTarget* targetToInsert ) { - size_t index = m_targets.index( targetToInsertBefore ); + size_t index = m_targets.indexOf( targetToInsertBefore ); if ( index < m_targets.size() ) m_targets.insert( index, targetToInsert ); else @@ -149,7 +149,7 @@ void RimUserDefinedPolylinesAnnotation::insertTarget( const RimPolylineTarget* t //-------------------------------------------------------------------------------------------------- void RimUserDefinedPolylinesAnnotation::deleteTarget( RimPolylineTarget* targetToDelete ) { - m_targets.removeChildObject( targetToDelete ); + m_targets.removeChild( targetToDelete ); delete targetToDelete; } diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimUserDefinedPolylinesAnnotationInView.cpp b/ApplicationLibCode/ProjectDataModel/Annotations/RimUserDefinedPolylinesAnnotationInView.cpp index 4b99291243..cf35f05cf1 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimUserDefinedPolylinesAnnotationInView.cpp +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimUserDefinedPolylinesAnnotationInView.cpp @@ -26,7 +26,7 @@ CAF_PDM_SOURCE_INIT( RimUserDefinedPolylinesAnnotationInView, "RimUserDefinedPol //-------------------------------------------------------------------------------------------------- RimUserDefinedPolylinesAnnotationInView::RimUserDefinedPolylinesAnnotationInView() { - CAF_PDM_InitObject( "PolyLinesAnnotationInView", ":/WellCollection.png", "", "" ); + CAF_PDM_InitObject( "PolyLinesAnnotationInView", ":/WellCollection.png" ); } //-------------------------------------------------------------------------------------------------- @@ -35,5 +35,5 @@ RimUserDefinedPolylinesAnnotationInView::RimUserDefinedPolylinesAnnotationInView RimUserDefinedPolylinesAnnotationInView::RimUserDefinedPolylinesAnnotationInView( RimUserDefinedPolylinesAnnotation* sourceAnnotation ) : RimPolylinesAnnotationInView( sourceAnnotation ) { - CAF_PDM_InitObject( "PolyLinesAnnotationInView", ":/WellCollection.png", "", "" ); + CAF_PDM_InitObject( "PolyLinesAnnotationInView", ":/WellCollection.png" ); } diff --git a/ApplicationLibCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/CMakeLists_files.cmake index 0cbdbde466..f782207f5e 100644 --- a/ApplicationLibCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationLibCode/ProjectDataModel/CMakeLists_files.cmake @@ -74,9 +74,15 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RimEclipseGeometrySelectionItem.h ${CMAKE_CURRENT_LIST_DIR}/RimDialogData.h ${CMAKE_CURRENT_LIST_DIR}/RimTimeStepFilter.h + ${CMAKE_CURRENT_LIST_DIR}/RimUserDefinedCalculation.h + ${CMAKE_CURRENT_LIST_DIR}/RimUserDefinedCalculationCollection.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimUserDefinedCalculationVariable.h ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCalculation.h ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCalculationCollection.h ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCalculationVariable.h + ${CMAKE_CURRENT_LIST_DIR}/RimGridCalculation.h + ${CMAKE_CURRENT_LIST_DIR}/RimGridCalculationCollection.h + ${CMAKE_CURRENT_LIST_DIR}/RimGridCalculationVariable.h ${CMAKE_CURRENT_LIST_DIR}/RimStimPlanLegendConfig.h ${CMAKE_CURRENT_LIST_DIR}/RimStimPlanColors.h ${CMAKE_CURRENT_LIST_DIR}/RimVirtualPerforationResults.h @@ -93,6 +99,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RimPlotAxisPropertiesInterface.h ${CMAKE_CURRENT_LIST_DIR}/RimPlotAxisProperties.h ${CMAKE_CURRENT_LIST_DIR}/RimPlotAxisAnnotation.h + ${CMAKE_CURRENT_LIST_DIR}/RimPlotAxisLogRangeCalculator.h ${CMAKE_CURRENT_LIST_DIR}/RimObservedDataCollection.h ${CMAKE_CURRENT_LIST_DIR}/RimObservedFmuRftData.h ${CMAKE_CURRENT_LIST_DIR}/RimMultiPlotCollection.h @@ -117,6 +124,9 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RimSurfaceIntersectionBand.h ${CMAKE_CURRENT_LIST_DIR}/RimSurfaceIntersectionCurve.h ${CMAKE_CURRENT_LIST_DIR}/RimSurfaceIntersectionCollection.h + ${CMAKE_CURRENT_LIST_DIR}/RimEclipseResultAddress.h + ${CMAKE_CURRENT_LIST_DIR}/RimEclipseResultAddressCollection.h + ${CMAKE_CURRENT_LIST_DIR}/RimEclipseCaseTools.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -195,9 +205,15 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RimEclipseGeometrySelectionItem.cpp ${CMAKE_CURRENT_LIST_DIR}/RimDialogData.cpp ${CMAKE_CURRENT_LIST_DIR}/RimTimeStepFilter.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimUserDefinedCalculation.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimUserDefinedCalculationCollection.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimUserDefinedCalculationVariable.cpp ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCalculation.cpp ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCalculationCollection.cpp ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCalculationVariable.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimGridCalculation.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimGridCalculationCollection.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimGridCalculationVariable.cpp ${CMAKE_CURRENT_LIST_DIR}/RimStimPlanLegendConfig.cpp ${CMAKE_CURRENT_LIST_DIR}/RimStimPlanColors.cpp ${CMAKE_CURRENT_LIST_DIR}/RimVirtualPerforationResults.cpp @@ -213,6 +229,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RimPlotAxisPropertiesInterface.cpp ${CMAKE_CURRENT_LIST_DIR}/RimPlotAxisProperties.cpp ${CMAKE_CURRENT_LIST_DIR}/RimPlotAxisAnnotation.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimPlotAxisLogRangeCalculator.cpp ${CMAKE_CURRENT_LIST_DIR}/RimObservedDataCollection.cpp ${CMAKE_CURRENT_LIST_DIR}/RimObservedFmuRftData.cpp ${CMAKE_CURRENT_LIST_DIR}/RimMultiPlotCollection.cpp @@ -233,9 +250,12 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RimSurfaceIntersectionBand.cpp ${CMAKE_CURRENT_LIST_DIR}/RimSurfaceIntersectionCurve.cpp ${CMAKE_CURRENT_LIST_DIR}/RimSurfaceIntersectionCollection.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimEclipseResultAddress.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimEclipseResultAddressCollection.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimEclipseCaseTools.cpp ) -if(Qt5Charts_FOUND) +if(RESINSIGHT_USE_QT_CHARTS) list( APPEND SOURCE_GROUP_HEADER_FILES diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilter.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilter.cpp index d213bd93a7..d79ca6f840 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilter.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilter.cpp @@ -45,18 +45,18 @@ CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimCellFilter, "CellFilter", "CellFilter" ); / RimCellFilter::RimCellFilter() : filterChanged( this ) { - CAF_PDM_InitObject( "Cell Filter", "", "", "" ); + CAF_PDM_InitObject( "Cell Filter" ); - CAF_PDM_InitField( &m_name, "UserDescription", QString( "New filter" ), "Name", "", "", "" ); - CAF_PDM_InitField( &m_isActive, "Active", true, "Active", "", "", "" ); + CAF_PDM_InitField( &m_name, "UserDescription", QString( "New filter" ), "Name" ); + CAF_PDM_InitField( &m_isActive, "Active", true, "Active" ); m_isActive.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_filterMode, "FilterType", "Filter Type", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_filterMode, "FilterType", "Filter Type" ); - CAF_PDM_InitField( &m_gridIndex, "GridIndex", 0, "Grid", "", "", "" ); - CAF_PDM_InitField( &m_propagateToSubGrids, "PropagateToSubGrids", true, "Apply to Subgrids", "", "", "" ); + CAF_PDM_InitField( &m_gridIndex, "GridIndex", 0, "Grid" ); + CAF_PDM_InitField( &m_propagateToSubGrids, "PropagateToSubGrids", true, "Apply to Subgrids" ); - CAF_PDM_InitFieldNoDefault( &m_nameProxy, "NameProxy", "Name Proxy", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_nameProxy, "NameProxy", "Name Proxy" ); m_nameProxy.registerGetMethod( this, &RimCellFilter::fullName ); m_nameProxy.uiCapability()->setUiReadOnly( true ); m_nameProxy.uiCapability()->setUiHidden( true ); @@ -250,13 +250,10 @@ const cvf::StructGridInterface* RimCellFilter::selectedGrid() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimCellFilter::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RimCellFilter::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; - if ( useOptionsOnly ) ( *useOptionsOnly ) = true; - if ( &m_gridIndex == fieldNeedingOptions ) { RimCase* rimCase = nullptr; diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilter.h b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilter.h index 3760c30ad0..f03b83ccc2 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilter.h +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilter.h @@ -80,8 +80,7 @@ class RimCellFilter : public caf::PdmObject const cvf::StructGridInterface* selectedGrid() const; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; caf::PdmField m_name; caf::PdmProxyValueField m_nameProxy; diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp index bd6f7a7852..ef0357f0f0 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp @@ -39,17 +39,17 @@ CAF_PDM_SOURCE_INIT( RimCellFilterCollection, "CellFilterCollection", "RimCellFi //-------------------------------------------------------------------------------------------------- RimCellFilterCollection::RimCellFilterCollection() { - CAF_PDM_InitScriptableObject( "Cell Filters", ":/CellFilter.png", "", "" ); + CAF_PDM_InitScriptableObject( "Cell Filters", ":/CellFilter.png" ); - CAF_PDM_InitScriptableField( &m_isActive, "Active", true, "Active", "", "", "" ); + CAF_PDM_InitScriptableField( &m_isActive, "Active", true, "Active" ); m_isActive.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_cellFilters, "CellFilters", "Filters", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_cellFilters, "CellFilters", "Filters" ); m_cellFilters.uiCapability()->setUiTreeHidden( true ); caf::PdmFieldReorderCapability::addToField( &m_cellFilters ); // for backwards project file compatibility with old CellRangeFilterCollection - CAF_PDM_InitFieldNoDefault( &m_rangeFilters_OBSOLETE, "RangeFilters", "Range Filters", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_rangeFilters_OBSOLETE, "RangeFilters", "Range Filters" ); m_rangeFilters_OBSOLETE.uiCapability()->setUiTreeHidden( true ); m_rangeFilters_OBSOLETE.xmlCapability()->setIOWritable( false ); } @@ -103,7 +103,7 @@ void RimCellFilterCollection::setCase( RimCase* theCase ) //-------------------------------------------------------------------------------------------------- std::vector RimCellFilterCollection::filters() const { - return m_cellFilters.childObjects(); + return m_cellFilters.children(); } //-------------------------------------------------------------------------------------------------- @@ -120,7 +120,7 @@ void RimCellFilterCollection::initAfterRead() } for ( auto& filter : filters ) { - m_rangeFilters_OBSOLETE.removeChildObject( filter ); + m_rangeFilters_OBSOLETE.removeChild( filter ); m_cellFilters.push_back( filter ); } @@ -328,7 +328,7 @@ void RimCellFilterCollection::onChildDeleted( caf::PdmChildArrayFieldHandle* //-------------------------------------------------------------------------------------------------- void RimCellFilterCollection::removeFilter( RimCellFilter* filter ) { - m_cellFilters.removeChildObject( filter ); + m_cellFilters.removeChild( filter ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterIntervalTool.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterIntervalTool.cpp index e552a1b029..1bcd9a2405 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterIntervalTool.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterIntervalTool.cpp @@ -18,6 +18,8 @@ #include "RimCellFilterIntervalTool.h" +#include "RiaTextStringTools.h" + #include //-------------------------------------------------------------------------------------------------- @@ -104,11 +106,11 @@ void RimCellFilterIntervalTool::setInterval( bool enabled, QString intervalText if ( !enabled ) return; - QStringList parts = intervalText.split( ',', QString::SkipEmptyParts ); + QStringList parts = RiaTextStringTools::splitSkipEmptyParts( intervalText, "," ); for ( auto& part : parts ) { - QStringList minmax = part.split( '-', QString::SkipEmptyParts ); + QStringList minmax = RiaTextStringTools::splitSkipEmptyParts( part, "-" ); switch ( minmax.size() ) { case 1: diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellRangeFilter.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellRangeFilter.cpp index daa3bbecb5..d5b1df8fd2 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellRangeFilter.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellRangeFilter.cpp @@ -38,24 +38,24 @@ CAF_PDM_SOURCE_INIT( RimCellRangeFilter, "CellRangeFilter" ); //-------------------------------------------------------------------------------------------------- RimCellRangeFilter::RimCellRangeFilter() { - CAF_PDM_InitObject( "Cell Range Filter", ":/CellFilter_Range.png", "", "" ); + CAF_PDM_InitObject( "Cell Range Filter", ":/CellFilter_Range.png" ); - CAF_PDM_InitField( &startIndexI, "StartIndexI", 1, "Start Index I", "", "", "" ); + CAF_PDM_InitField( &startIndexI, "StartIndexI", 1, "Start Index I" ); startIndexI.uiCapability()->setUiEditorTypeName( caf::PdmUiSliderEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &cellCountI, "CellCountI", 1, "Cell Count I", "", "", "" ); + CAF_PDM_InitField( &cellCountI, "CellCountI", 1, "Cell Count I" ); cellCountI.uiCapability()->setUiEditorTypeName( caf::PdmUiSliderEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &startIndexJ, "StartIndexJ", 1, "Start Index J", "", "", "" ); + CAF_PDM_InitField( &startIndexJ, "StartIndexJ", 1, "Start Index J" ); startIndexJ.uiCapability()->setUiEditorTypeName( caf::PdmUiSliderEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &cellCountJ, "CellCountJ", 1, "Cell Count J", "", "", "" ); + CAF_PDM_InitField( &cellCountJ, "CellCountJ", 1, "Cell Count J" ); cellCountJ.uiCapability()->setUiEditorTypeName( caf::PdmUiSliderEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &startIndexK, "StartIndexK", 1, "Start Index K", "", "", "" ); + CAF_PDM_InitField( &startIndexK, "StartIndexK", 1, "Start Index K" ); startIndexK.uiCapability()->setUiEditorTypeName( caf::PdmUiSliderEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &cellCountK, "CellCountK", 1, "Cell Count K", "", "", "" ); + CAF_PDM_InitField( &cellCountK, "CellCountK", 1, "Cell Count K" ); cellCountK.uiCapability()->setUiEditorTypeName( caf::PdmUiSliderEditor::uiEditorTypeName() ); m_propagateToSubGrids = true; diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimEclipsePropertyFilter.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimEclipsePropertyFilter.cpp index 6cc4919c72..172d9e1949 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimEclipsePropertyFilter.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimEclipsePropertyFilter.cpp @@ -52,9 +52,9 @@ CAF_PDM_SOURCE_INIT( RimEclipsePropertyFilter, "CellPropertyFilter" ); //-------------------------------------------------------------------------------------------------- RimEclipsePropertyFilter::RimEclipsePropertyFilter() { - CAF_PDM_InitObject( "Cell Property Filter", ":/CellFilter_Values.png", "", "" ); + CAF_PDM_InitObject( "Cell Property Filter", ":/CellFilter_Values.png" ); - CAF_PDM_InitFieldNoDefault( &m_resultDefinition, "ResultDefinition", "Result Definition", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_resultDefinition, "ResultDefinition", "Result Definition" ); m_resultDefinition = new RimEclipseResultDefinition(); m_resultDefinition->enableDeltaResults( true ); @@ -63,17 +63,17 @@ RimEclipsePropertyFilter::RimEclipsePropertyFilter() m_resultDefinition.uiCapability()->setUiTreeHidden( true ); m_resultDefinition.uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitField( &m_rangeLabelText, "Dummy_keyword", QString( "Range Type" ), "Range Type", "", "", "" ); + CAF_PDM_InitField( &m_rangeLabelText, "Dummy_keyword", QString( "Range Type" ), "Range Type" ); m_rangeLabelText.xmlCapability()->disableIO(); m_rangeLabelText.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitField( &m_lowerBound, "LowerBound", 0.0, "Min", "", "", "" ); + CAF_PDM_InitField( &m_lowerBound, "LowerBound", 0.0, "Min" ); m_lowerBound.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_upperBound, "UpperBound", 0.0, "Max", "", "", "" ); + CAF_PDM_InitField( &m_upperBound, "UpperBound", 0.0, "Max" ); m_upperBound.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_useCategorySelection, "CategorySelection", false, "Category Selection", "", "", "" ); + CAF_PDM_InitField( &m_useCategorySelection, "CategorySelection", false, "Category Selection" ); m_upperBound.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); // HEADLESS HACK diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimEclipsePropertyFilterCollection.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimEclipsePropertyFilterCollection.cpp index abc71541b2..857c378294 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimEclipsePropertyFilterCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimEclipsePropertyFilterCollection.cpp @@ -36,9 +36,9 @@ CAF_PDM_SOURCE_INIT( RimEclipsePropertyFilterCollection, "CellPropertyFilters" ) //-------------------------------------------------------------------------------------------------- RimEclipsePropertyFilterCollection::RimEclipsePropertyFilterCollection() { - CAF_PDM_InitObject( "Property Filters", ":/CellFilter_Values.png", "", "" ); + CAF_PDM_InitObject( "Property Filters", ":/CellFilter_Values.png" ); - CAF_PDM_InitFieldNoDefault( &propertyFilters, "PropertyFilters", "Property Filters", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &propertyFilters, "PropertyFilters", "Property Filters" ); propertyFilters.uiCapability()->setUiTreeHidden( true ); } @@ -47,7 +47,7 @@ RimEclipsePropertyFilterCollection::RimEclipsePropertyFilterCollection() //-------------------------------------------------------------------------------------------------- RimEclipsePropertyFilterCollection::~RimEclipsePropertyFilterCollection() { - propertyFilters.deleteAllChildObjects(); + propertyFilters.deleteChildren(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimGeoMechPropertyFilter.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimGeoMechPropertyFilter.cpp index 1158810d24..3300e5651a 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimGeoMechPropertyFilter.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimGeoMechPropertyFilter.cpp @@ -42,9 +42,9 @@ CAF_PDM_SOURCE_INIT( RimGeoMechPropertyFilter, "GeoMechPropertyFilter" ); RimGeoMechPropertyFilter::RimGeoMechPropertyFilter() : m_parentContainer( nullptr ) { - CAF_PDM_InitObject( "Property Filter", ":/CellFilter_Values.png", "", "" ); + CAF_PDM_InitObject( "Property Filter", ":/CellFilter_Values.png" ); - CAF_PDM_InitFieldNoDefault( &resultDefinition, "ResultDefinition", "Result Definition", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &resultDefinition, "ResultDefinition", "Result Definition" ); resultDefinition = new RimGeoMechResultDefinition(); // Set to hidden to avoid this item to been displayed as a child item @@ -52,10 +52,10 @@ RimGeoMechPropertyFilter::RimGeoMechPropertyFilter() resultDefinition.uiCapability()->setUiTreeHidden( true ); resultDefinition.uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitField( &lowerBound, "LowerBound", 0.0, "Min", "", "", "" ); + CAF_PDM_InitField( &lowerBound, "LowerBound", 0.0, "Min" ); lowerBound.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &upperBound, "UpperBound", 0.0, "Max", "", "", "" ); + CAF_PDM_InitField( &upperBound, "UpperBound", 0.0, "Max" ); upperBound.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); updateIconState(); diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimGeoMechPropertyFilterCollection.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimGeoMechPropertyFilterCollection.cpp index a1ae588e36..7077ea9f95 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimGeoMechPropertyFilterCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimGeoMechPropertyFilterCollection.cpp @@ -34,9 +34,9 @@ CAF_PDM_SOURCE_INIT( RimGeoMechPropertyFilterCollection, "GeoMechPropertyFilters //-------------------------------------------------------------------------------------------------- RimGeoMechPropertyFilterCollection::RimGeoMechPropertyFilterCollection() { - CAF_PDM_InitObject( "Property Filters", ":/CellFilter_Values.png", "", "" ); + CAF_PDM_InitObject( "Property Filters", ":/CellFilter_Values.png" ); - CAF_PDM_InitFieldNoDefault( &propertyFilters, "PropertyFilters", "Property Filters", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &propertyFilters, "PropertyFilters", "Property Filters" ); propertyFilters.uiCapability()->setUiTreeHidden( true ); } @@ -45,7 +45,7 @@ RimGeoMechPropertyFilterCollection::RimGeoMechPropertyFilterCollection() //-------------------------------------------------------------------------------------------------- RimGeoMechPropertyFilterCollection::~RimGeoMechPropertyFilterCollection() { - propertyFilters.deleteAllChildObjects(); + propertyFilters.deleteChildren(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp index baf82305aa..b6a3dffbfc 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp @@ -54,6 +54,8 @@ #include +#include + namespace caf { template <> @@ -120,41 +122,41 @@ RimPolygonFilter::RimPolygonFilter() : m_pickTargetsEventHandler( new RicPolylineTargetsPickEventHandler( this ) ) , m_intervalTool( true ) { - CAF_PDM_InitObject( "Polyline Filter", ":/CellFilter_Polygon.png", "", "" ); + CAF_PDM_InitObject( "Polyline Filter", ":/CellFilter_Polygon.png" ); - CAF_PDM_InitFieldNoDefault( &m_polyFilterMode, "PolygonFilterType", "Vertical Filter", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_polyFilterMode, "PolygonFilterType", "Vertical Filter" ); - CAF_PDM_InitFieldNoDefault( &m_polyIncludeType, "PolyIncludeType", "Cells to include", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_polyIncludeType, "PolyIncludeType", "Cells to include" ); - CAF_PDM_InitField( &m_enablePicking, "EnablePicking", false, "", "", "", "" ); + CAF_PDM_InitField( &m_enablePicking, "EnablePicking", false, "" ); caf::PdmUiPushButtonEditor::configureEditorForField( &m_enablePicking ); m_enablePicking.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosType::HIDDEN ); - CAF_PDM_InitFieldNoDefault( &m_targets, "Targets", "Targets", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_targets, "Targets", "Targets" ); m_targets.uiCapability()->setUiEditorTypeName( caf::PdmUiTableViewEditor::uiEditorTypeName() ); m_targets.uiCapability()->setUiTreeChildrenHidden( true ); m_targets.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); m_targets.uiCapability()->setCustomContextMenuEnabled( true ); - CAF_PDM_InitFieldNoDefault( &m_srcCase, "Case", "Case", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_srcCase, "Case", "Case" ); m_srcCase.uiCapability()->setUiHidden( true ); - CAF_PDM_InitField( &m_showLines, "ShowLines", true, "Show Lines", "", "", "" ); - CAF_PDM_InitField( &m_showSpheres, "ShowSpheres", false, "Show Spheres", "", "", "" ); + CAF_PDM_InitField( &m_showLines, "ShowLines", true, "Show Lines" ); + CAF_PDM_InitField( &m_showSpheres, "ShowSpheres", false, "Show Spheres" ); - CAF_PDM_InitField( &m_lineThickness, "LineThickness", 3, "Line Thickness", "", "", "" ); - CAF_PDM_InitField( &m_sphereRadiusFactor, "SphereRadiusFactor", 0.15, "Sphere Radius Factor", "", "", "" ); + CAF_PDM_InitField( &m_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::WHITE ), "Line Color" ); + CAF_PDM_InitField( &m_sphereColor, "SphereColor", cvf::Color3f( cvf::Color3f::WHITE ), "Sphere Color" ); - CAF_PDM_InitField( &m_enableFiltering, "EnableFiltering", false, "Enable Filter", "", "", "" ); + CAF_PDM_InitField( &m_enableFiltering, "EnableFiltering", false, "Enable Filter" ); - CAF_PDM_InitField( &m_enableKFilter, "EnableKFilter", false, "Enable K Range Filter", "", "", "" ); + CAF_PDM_InitField( &m_enableKFilter, "EnableKFilter", false, "Enable K Range Filter" ); CAF_PDM_InitFieldNoDefault( &m_kFilterStr, "KRangeFilter", "K Range Filter", "", "Example: 2,4,10-20,31", "" ); - CAF_PDM_InitField( &m_polygonPlaneDepth, "PolygonPlaneDepth", 0.0, "Polygon Plane Depth", "", "", "" ); - CAF_PDM_InitField( &m_lockPolygonToPlane, "LockPolygon", false, "Lock Polygon to Plane", "", "", "" ); + CAF_PDM_InitField( &m_polygonPlaneDepth, "PolygonPlaneDepth", 0.0, "Polygon Plane Depth" ); + CAF_PDM_InitField( &m_lockPolygonToPlane, "LockPolygon", false, "Lock Polygon to Plane" ); m_polygonPlaneDepth.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); m_polygonPlaneDepth.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosType::TOP ); @@ -255,7 +257,7 @@ QString RimPolygonFilter::fullName() const //-------------------------------------------------------------------------------------------------- std::vector RimPolygonFilter::activeTargets() const { - return m_targets.childObjects(); + return m_targets.children(); } //-------------------------------------------------------------------------------------------------- @@ -263,7 +265,7 @@ std::vector RimPolygonFilter::activeTargets() const //-------------------------------------------------------------------------------------------------- void RimPolygonFilter::insertTarget( const RimPolylineTarget* targetToInsertBefore, RimPolylineTarget* targetToInsert ) { - size_t index = m_targets.index( targetToInsertBefore ); + size_t index = m_targets.indexOf( targetToInsertBefore ); if ( index < m_targets.size() ) m_targets.insert( index, targetToInsert ); else @@ -277,7 +279,7 @@ void RimPolygonFilter::insertTarget( const RimPolylineTarget* targetToInsertBefo //-------------------------------------------------------------------------------------------------- void RimPolygonFilter::deleteTarget( RimPolylineTarget* targetToDelete ) { - m_targets.removeChildObject( targetToDelete ); + m_targets.removeChild( targetToDelete ); delete targetToDelete; } @@ -902,6 +904,45 @@ int RimPolygonFilter::findEclipseKLayer( const std::vector& points, } } + auto findKLayerBelowPoint = []( const cvf::Vec3d& point, RigMainGrid* mainGrid ) { + // Create a bounding box (ie a ray) from the point down to minimum of grid + cvf::Vec3d lowestPoint( point.x(), point.y(), mainGrid->boundingBox().min().z() ); + + cvf::BoundingBox rayBBox; + rayBBox.add( point ); + rayBBox.add( lowestPoint ); + + // Find the cells intersecting the ray + std::vector allCellIndices; + mainGrid->findIntersectingCells( rayBBox, &allCellIndices ); + + // Get the minimum K layer index + int minK = std::numeric_limits::max(); + bool anyHits = false; + for ( size_t cIdx : allCellIndices ) + { + if ( cIdx != cvf::UNDEFINED_SIZE_T ) + { + size_t ni, nj, nk; + mainGrid->ijkFromCellIndexUnguarded( cIdx, &ni, &nj, &nk ); + if ( mainGrid->isCellValid( ni, nj, nk ) ) + { + anyHits = true; + minK = std::min( minK, static_cast( nk ) ); + } + } + } + + return anyHits ? minK : -1; + }; + + // shoot a ray down from each point to try to find a valid hit there + for ( size_t p = 0; p < points.size() - 1; p++ ) + { + int k = findKLayerBelowPoint( points[p], data->mainGrid() ); + if ( k != -1 ) return k; + } + // loop over all sub-grids to find one with a cell hit in case main grid search failed for ( size_t gridIndex = 1; gridIndex < data->gridCount(); gridIndex++ ) { diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPropertyFilter.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPropertyFilter.cpp index 1e1bcfb088..63d33c1834 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPropertyFilter.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPropertyFilter.cpp @@ -27,9 +27,9 @@ CAF_PDM_SOURCE_INIT( RimPropertyFilter, "PropertyFilter" ); //-------------------------------------------------------------------------------------------------- RimPropertyFilter::RimPropertyFilter() { - CAF_PDM_InitObject( "Property Filter", "", "", "" ); + CAF_PDM_InitObject( "Property Filter" ); - CAF_PDM_InitFieldNoDefault( &m_selectedCategoryValues, "SelectedValues", "Values", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_selectedCategoryValues, "SelectedValues", "Values" ); setDeletable( true ); } @@ -52,15 +52,12 @@ std::vector RimPropertyFilter::selectedCategoryValues() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimPropertyFilter::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RimPropertyFilter::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; if ( &m_selectedCategoryValues == fieldNeedingOptions ) { - if ( useOptionsOnly ) *useOptionsOnly = true; - if ( m_categoryValues.size() == m_categoryNames.size() ) { for ( size_t i = 0; i < m_categoryValues.size(); i++ ) diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPropertyFilter.h b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPropertyFilter.h index 4210a2eba0..0776f56127 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPropertyFilter.h +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPropertyFilter.h @@ -42,8 +42,7 @@ class RimPropertyFilter : public RimCellFilter void setCategoryNamesAndValues( const std::vector>& categoryNamesAndValues ); void clearCategories(); - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; protected: caf::PdmField> m_selectedCategoryValues; diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPropertyFilterCollection.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPropertyFilterCollection.cpp index f490c86292..4dd78b44c4 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPropertyFilterCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPropertyFilterCollection.cpp @@ -30,7 +30,7 @@ CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimPropertyFilterCollection, "RimPropertyFilte //-------------------------------------------------------------------------------------------------- RimPropertyFilterCollection::RimPropertyFilterCollection() { - CAF_PDM_InitField( &isActive, "Active", true, "Active", "", "", "" ); + CAF_PDM_InitField( &isActive, "Active", true, "Active" ); isActive.uiCapability()->setUiHidden( true ); } diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimUserDefinedFilter.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimUserDefinedFilter.cpp index ee4c303716..0952512883 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimUserDefinedFilter.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimUserDefinedFilter.cpp @@ -27,7 +27,7 @@ CAF_PDM_SOURCE_INIT( RimUserDefinedFilter, "UserDefinedFilter" ); //-------------------------------------------------------------------------------------------------- RimUserDefinedFilter::RimUserDefinedFilter() { - CAF_PDM_InitObject( "User Defined Filter", ":/CellFilter_UserDefined.png", "", "" ); + CAF_PDM_InitObject( "User Defined Filter", ":/CellFilter_UserDefined.png" ); CAF_PDM_InitFieldNoDefault( &m_individualCellIndices, "IndividualCellIndices", "Cells", diff --git a/ApplicationLibCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp b/ApplicationLibCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp index e21fe7ef4c..561ed9a4d9 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp @@ -32,16 +32,16 @@ CAF_PDM_SOURCE_INIT( Rim3dWellLogCurveCollection, "Rim3dWellLogCurveCollection" //-------------------------------------------------------------------------------------------------- Rim3dWellLogCurveCollection::Rim3dWellLogCurveCollection() { - CAF_PDM_InitObject( "3D Track", ":/WellLogCurve16x16.png", "", "" ); + CAF_PDM_InitObject( "3D Track", ":/WellLogCurve16x16.png" ); - CAF_PDM_InitField( &m_showPlot, "Show3dWellLogCurves", true, "Show 3d Well Log Curves", "", "", "" ); + CAF_PDM_InitField( &m_showPlot, "Show3dWellLogCurves", true, "Show 3d Well Log Curves" ); m_showPlot.uiCapability()->setUiHidden( true ); - CAF_PDM_InitField( &m_planeWidthScaling, "PlaneWidthScaling", 1.0f, "Width Scaling", "", "", "" ); + CAF_PDM_InitField( &m_planeWidthScaling, "PlaneWidthScaling", 1.0f, "Width Scaling" ); m_planeWidthScaling.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_showGrid, "Show3dWellLogGrid", true, "Show Grid", "", "", "" ); - CAF_PDM_InitField( &m_showBackground, "Show3dWellLogBackground", false, "Show Background", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_3dWellLogCurves, "ArrayOf3dWellLogCurves", "", "", "", "" ); + CAF_PDM_InitField( &m_showGrid, "Show3dWellLogGrid", true, "Show Grid" ); + CAF_PDM_InitField( &m_showBackground, "Show3dWellLogBackground", false, "Show Background" ); + CAF_PDM_InitFieldNoDefault( &m_3dWellLogCurves, "ArrayOf3dWellLogCurves", "" ); m_3dWellLogCurves.uiCapability()->setUiTreeHidden( true ); } @@ -50,7 +50,7 @@ Rim3dWellLogCurveCollection::Rim3dWellLogCurveCollection() //-------------------------------------------------------------------------------------------------- Rim3dWellLogCurveCollection::~Rim3dWellLogCurveCollection() { - m_3dWellLogCurves.deleteAllChildObjects(); + m_3dWellLogCurves.deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -80,7 +80,7 @@ void Rim3dWellLogCurveCollection::add3dWellLogCurve( Rim3dWellLogCurve* curve ) //-------------------------------------------------------------------------------------------------- void Rim3dWellLogCurveCollection::remove3dWellLogCurve( Rim3dWellLogCurve* curve ) { - m_3dWellLogCurves.removeChildObject( curve ); + m_3dWellLogCurves.removeChild( curve ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimCompletionTemplateCollection.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimCompletionTemplateCollection.cpp index 0df5e53e38..585ef32f90 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimCompletionTemplateCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimCompletionTemplateCollection.cpp @@ -34,19 +34,19 @@ CAF_PDM_SOURCE_INIT( RimCompletionTemplateCollection, "CompletionTemplateCollect //-------------------------------------------------------------------------------------------------- RimCompletionTemplateCollection::RimCompletionTemplateCollection() { - CAF_PDM_InitObject( "Completion Templates", ":/CompletionsSymbol16x16.png", "", "" ); + CAF_PDM_InitObject( "Completion Templates", ":/CompletionsSymbol16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_fractureTemplates, "FractureTemplates", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_fractureTemplates, "FractureTemplates", "" ); m_fractureTemplates = new RimFractureTemplateCollection; m_fractureTemplates->addDefaultEllipseTemplate(); - CAF_PDM_InitFieldNoDefault( &m_stimPlanModelTemplates, "StimPlanModelTemplates", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_stimPlanModelTemplates, "StimPlanModelTemplates", "" ); m_stimPlanModelTemplates = new RimStimPlanModelTemplateCollection; - CAF_PDM_InitFieldNoDefault( &m_valveTemplates, "ValveTemplates", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_valveTemplates, "ValveTemplates", "" ); m_valveTemplates = new RimValveTemplateCollection; - CAF_PDM_InitFieldNoDefault( &m_fractureGroupStatisticsCollection, "FractureGroupStatisticsCollection", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_fractureGroupStatisticsCollection, "FractureGroupStatisticsCollection", "" ); m_fractureGroupStatisticsCollection = new RimEnsembleFractureStatisticsCollection; } diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp index 9a3fb5073a..dd96d7ae5e 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp @@ -50,12 +50,12 @@ CAF_PDM_SOURCE_INIT( RimEllipseFractureTemplate, "RimEllipseFractureTemplate" ); //-------------------------------------------------------------------------------------------------- RimEllipseFractureTemplate::RimEllipseFractureTemplate() { - CAF_PDM_InitObject( "Fracture Template", ":/FractureTemplate16x16.png", "", "" ); + CAF_PDM_InitObject( "Fracture Template", ":/FractureTemplate16x16.png" ); - CAF_PDM_InitField( &m_halfLength, "HalfLength", 0.0, "Half Length Xf", "", "", "" ); - CAF_PDM_InitField( &m_height, "Height", 0.0, "Height", "", "", "" ); - CAF_PDM_InitField( &m_width, "Width", 0.0, "Width", "", "", "" ); - CAF_PDM_InitField( &m_permeability, "Permeability", 0.0, "Permeability [mD]", "", "", "" ); + CAF_PDM_InitField( &m_halfLength, "HalfLength", 0.0, "Half Length Xf" ); + CAF_PDM_InitField( &m_height, "Height", 0.0, "Height" ); + CAF_PDM_InitField( &m_width, "Width", 0.0, "Width" ); + CAF_PDM_InitField( &m_permeability, "Permeability", 0.0, "Permeability [mD]" ); setDeletable( true ); } @@ -260,7 +260,7 @@ WellFractureIntersectionData /// //-------------------------------------------------------------------------------------------------- QList - RimEllipseFractureTemplate::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) + RimEllipseFractureTemplate::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h b/ApplicationLibCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h index 94cbadfe95..0bb762581a 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h @@ -76,8 +76,7 @@ class RimEllipseFractureTemplate : public RimFractureTemplate private: void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void initAfterRead() override; diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimEnsembleFractureStatistics.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimEnsembleFractureStatistics.cpp index 4871961b0d..5ba3812704 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimEnsembleFractureStatistics.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimEnsembleFractureStatistics.cpp @@ -121,50 +121,44 @@ CAF_PDM_SOURCE_INIT( RimEnsembleFractureStatistics, "EnsembleFractureStatistics" //-------------------------------------------------------------------------------------------------- RimEnsembleFractureStatistics::RimEnsembleFractureStatistics() { - CAF_PDM_InitObject( "Ensemble Fracture Statistics", ":/FractureTemplate16x16.png", "", "" ); + CAF_PDM_InitObject( "Ensemble Fracture Statistics", ":/FractureTemplate16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_filePaths, "FilePaths", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_filePaths, "FilePaths", "" ); - CAF_PDM_InitFieldNoDefault( &m_filePathsTable, "FilePathsTable", "File Paths Table", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_filePathsTable, "FilePathsTable", "File Paths Table" ); m_filePathsTable.uiCapability()->setUiEditorTypeName( caf::PdmUiTextEditor::uiEditorTypeName() ); m_filePathsTable.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); m_filePathsTable.uiCapability()->setUiReadOnly( true ); m_filePathsTable.xmlCapability()->disableIO(); - CAF_PDM_InitField( &m_excludeZeroWidthFractures, - "ExcludeZeroWidthFractures", - true, - "Exclude Zero Width Fractures", - "", - "", - "" ); + CAF_PDM_InitField( &m_excludeZeroWidthFractures, "ExcludeZeroWidthFractures", true, "Exclude Zero Width Fractures" ); - CAF_PDM_InitFieldNoDefault( &m_statisticsTable, "StatisticsTable", "Statistics Table", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_statisticsTable, "StatisticsTable", "Statistics Table" ); m_statisticsTable.uiCapability()->setUiEditorTypeName( caf::PdmUiTextEditor::uiEditorTypeName() ); m_statisticsTable.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); m_statisticsTable.uiCapability()->setUiReadOnly( true ); m_statisticsTable.xmlCapability()->disableIO(); - CAF_PDM_InitFieldNoDefault( &m_meshAlignmentType, "MeshAlignmentType", "Mesh Alignment", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_meshType, "MeshType", "Mesh Type", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_meshAlignmentType, "MeshAlignmentType", "Mesh Alignment" ); + CAF_PDM_InitFieldNoDefault( &m_meshType, "MeshType", "Mesh Type" ); // Uniform sampling - CAF_PDM_InitField( &m_numSamplesX, "NumberOfSamplesX", 100, "X", "", "", "" ); - CAF_PDM_InitField( &m_numSamplesY, "NumberOfSamplesY", 200, "Y", "", "", "" ); + CAF_PDM_InitField( &m_numSamplesX, "NumberOfSamplesX", 100, "X" ); + CAF_PDM_InitField( &m_numSamplesY, "NumberOfSamplesY", 200, "Y" ); // Adaptive sampling - CAF_PDM_InitFieldNoDefault( &m_adaptiveMeanType, "AdaptiveMeanType", "Mean Type", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_adaptiveNumLayersType, "AdaptiveNumLayersType", "Number of Layers", "", "", "" ); - CAF_PDM_InitField( &m_adaptiveNumLayers, "AdaptiveNumLayers", 30, "Number of Layers Y", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_adaptiveMeanType, "AdaptiveMeanType", "Mean Type" ); + CAF_PDM_InitFieldNoDefault( &m_adaptiveNumLayersType, "AdaptiveNumLayersType", "Number of Layers" ); + CAF_PDM_InitField( &m_adaptiveNumLayers, "AdaptiveNumLayers", 30, "Number of Layers Y" ); std::vector> defaultStatisticsTypes = { caf::AppEnum( RimEnsembleFractureStatistics::StatisticsType::MEAN ) }; - CAF_PDM_InitField( &m_selectedStatisticsType, "SelectedStatisticsType", defaultStatisticsTypes, "Statistics Type", "", "", "" ); + CAF_PDM_InitField( &m_selectedStatisticsType, "SelectedStatisticsType", defaultStatisticsTypes, "Statistics Type" ); m_selectedStatisticsType.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); m_selectedStatisticsType.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); - CAF_PDM_InitFieldNoDefault( &m_computeStatistics, "ComputeStatistics", "Compute Templates", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_computeStatistics, "ComputeStatistics", "Compute Templates" ); m_computeStatistics.uiCapability()->setUiEditorTypeName( caf::PdmUiToolButtonEditor::uiEditorTypeName() ); m_computeStatistics.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); @@ -204,8 +198,7 @@ QString RimEnsembleFractureStatistics::generateFilePathsTable() /// //-------------------------------------------------------------------------------------------------- QList - RimEnsembleFractureStatistics::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) + RimEnsembleFractureStatistics::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; if ( fieldNeedingOptions == &m_selectedStatisticsType ) diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimEnsembleFractureStatistics.h b/ApplicationLibCode/ProjectDataModel/Completions/RimEnsembleFractureStatistics.h index 82974a5ced..c1208587df 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimEnsembleFractureStatistics.h +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimEnsembleFractureStatistics.h @@ -114,8 +114,7 @@ class RimEnsembleFractureStatistics : public RimNamedObject void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; QString generateFilePathsTable(); diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimEnsembleFractureStatisticsCollection.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimEnsembleFractureStatisticsCollection.cpp index b47cd33a1e..bf71d7cfe4 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimEnsembleFractureStatisticsCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimEnsembleFractureStatisticsCollection.cpp @@ -27,9 +27,9 @@ CAF_PDM_SOURCE_INIT( RimEnsembleFractureStatisticsCollection, "FractureGroupStat //-------------------------------------------------------------------------------------------------- RimEnsembleFractureStatisticsCollection::RimEnsembleFractureStatisticsCollection() { - CAF_PDM_InitObject( "Ensemble Fracture Statistics", ":/FractureTemplates16x16.png", "", "" ); + CAF_PDM_InitObject( "Ensemble Fracture Statistics", ":/FractureTemplates16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_fractureGroupStatistics, "FractureGroupStatistics", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_fractureGroupStatistics, "FractureGroupStatistics", "" ); m_fractureGroupStatistics.uiCapability()->setUiTreeHidden( true ); } @@ -46,7 +46,7 @@ void RimEnsembleFractureStatisticsCollection::addFractureGroupStatistics( RimEns //-------------------------------------------------------------------------------------------------- void RimEnsembleFractureStatisticsCollection::loadAndUpdateData() { - for ( auto f : m_fractureGroupStatistics.childObjects() ) + for ( auto f : m_fractureGroupStatistics.children() ) { f->loadAndUpdateData(); } diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimFishbones.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimFishbones.cpp index 9ba0198e99..ac44a05850 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimFishbones.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimFishbones.cpp @@ -69,20 +69,20 @@ void AppEnum::setUp() //-------------------------------------------------------------------------------------------------- RimFishbones::RimFishbones() { - CAF_PDM_InitObject( "FishbonesMultipleSubs", ":/FishBoneGroup16x16.png", "", "" ); + CAF_PDM_InitObject( "FishbonesMultipleSubs", ":/FishBoneGroup16x16.png" ); - CAF_PDM_InitField( &m_isActive, "Active", true, "Active", "", "", "" ); + CAF_PDM_InitField( &m_isActive, "Active", true, "Active" ); m_isActive.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_name, "Name", "Name", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_name, "Name", "Name" ); m_name.registerGetMethod( this, &RimFishbones::generatedName ); m_name.uiCapability()->setUiReadOnly( true ); m_name.xmlCapability()->setIOWritable( false ); cvf::Color3f defaultColor = RiaColorTables::wellPathComponentColors()[RiaDefines::WellPathComponentType::FISHBONES]; - CAF_PDM_InitField( &fishbonesColor, "Color", defaultColor, "Fishbones Color", "", "", "" ); + CAF_PDM_InitField( &fishbonesColor, "Color", defaultColor, "Fishbones Color" ); - CAF_PDM_InitField( &m_lateralCountPerSub, "LateralCountPerSub", 3, "Laterals Per Sub", "", "", "" ); + CAF_PDM_InitField( &m_lateralCountPerSub, "LateralCountPerSub", 3, "Laterals Per Sub" ); CAF_PDM_InitField( &m_lateralLength, "LateralLength", QString( "11.0" ), @@ -91,40 +91,25 @@ RimFishbones::RimFishbones() "Specify multiple length values if the sub lengths differ", "" ); - CAF_PDM_InitField( &m_lateralExitAngle, "LateralExitAngle", 35.0, "Exit Angle [deg]", "", "", "" ); - CAF_PDM_InitField( &m_lateralBuildAngle, "LateralBuildAngle", 6.0, "Build Angle [deg/m]", "", "", "" ); + CAF_PDM_InitField( &m_lateralExitAngle, "LateralExitAngle", 35.0, "Exit Angle [deg]" ); + CAF_PDM_InitField( &m_lateralBuildAngle, "LateralBuildAngle", 6.0, "Build Angle [deg/m]" ); - CAF_PDM_InitField( &m_lateralTubingDiameter, "LateralTubingDiameter", 8.0, "Tubing Diameter [mm]", "", "", "" ); + CAF_PDM_InitField( &m_lateralTubingDiameter, "LateralTubingDiameter", 8.0, "Tubing Diameter [mm]" ); CAF_PDM_InitField( &m_lateralOpenHoleRoghnessFactor, "LateralOpenHoleRoghnessFactor", 0.001, - "Open Hole Roghness Factor [m]", - "", - "", - "" ); - CAF_PDM_InitField( &m_lateralTubingRoghnessFactor, - "LateralTubingRoghnessFactor", - 1e-5, - "Tubing Roghness Factor [m]", - "", - "", - "" ); + "Open Hole Roghness Factor [m]" ); + CAF_PDM_InitField( &m_lateralTubingRoghnessFactor, "LateralTubingRoghnessFactor", 1e-5, "Tubing Roghness Factor [m]" ); - CAF_PDM_InitField( &m_lateralInstallSuccessFraction, - "LateralInstallSuccessFraction", - 1.0, - "Install Success Rate [0..1]", - "", - "", - "" ); + CAF_PDM_InitField( &m_lateralInstallSuccessFraction, "LateralInstallSuccessFraction", 1.0, "Install Success Rate [0..1]" ); - CAF_PDM_InitField( &m_icdCount, "IcdCount", 2, "ICDs per Sub", "", "", "" ); - CAF_PDM_InitField( &m_icdOrificeDiameter, "IcdOrificeDiameter", 7.0, "ICD Orifice Diameter [mm]", "", "", "" ); - CAF_PDM_InitField( &m_icdFlowCoefficient, "IcdFlowCoefficient", 1.5, "ICD Flow Coefficient", "", "", "" ); + CAF_PDM_InitField( &m_icdCount, "IcdCount", 2, "ICDs per Sub" ); + CAF_PDM_InitField( &m_icdOrificeDiameter, "IcdOrificeDiameter", 7.0, "ICD Orifice Diameter [mm]" ); + CAF_PDM_InitField( &m_icdFlowCoefficient, "IcdFlowCoefficient", 1.5, "ICD Flow Coefficient" ); initialiseObsoleteFields(); - CAF_PDM_InitFieldNoDefault( &m_valveLocations, "ValveLocations", "Valve Locations", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_valveLocations, "ValveLocations", "Valve Locations" ); m_valveLocations = new RimMultipleValveLocations(); m_valveLocations->findField( "RangeValveCount" )->uiCapability()->setUiName( "Number of Subs" ); m_valveLocations.uiCapability()->setUiTreeHidden( true ); @@ -133,27 +118,15 @@ RimFishbones::RimFishbones() CAF_PDM_InitField( &m_subsOrientationMode, "SubsOrientationMode", caf::AppEnum( FB_LATERAL_ORIENTATION_RANDOM ), - "Orientation", - "", - "", - "" ); + "Orientation" ); CAF_PDM_InitFieldNoDefault( &m_installationRotationAngles, "InstallationRotationAngles", - "Installation Rotation Angles [deg]", - "", - "", - "" ); + "Installation Rotation Angles [deg]" ); m_installationRotationAngles.uiCapability()->setUiHidden( true ); - CAF_PDM_InitField( &m_fixedInstallationRotationAngle, - "FixedInstallationRotationAngle", - 0.0, - " Fixed Angle [deg]", - "", - "", - "" ); + CAF_PDM_InitField( &m_fixedInstallationRotationAngle, "FixedInstallationRotationAngle", 0.0, " Fixed Angle [deg]" ); - CAF_PDM_InitFieldNoDefault( &m_pipeProperties, "PipeProperties", "Pipe Properties", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_pipeProperties, "PipeProperties", "Pipe Properties" ); m_pipeProperties.uiCapability()->setUiTreeHidden( true ); m_pipeProperties.uiCapability()->setUiTreeChildrenHidden( true ); @@ -187,7 +160,7 @@ QString RimFishbones::generatedName() const dynamic_cast*>( this->parentField() ); CVF_ASSERT( container ); - size_t index = container->index( this ) + 1; + size_t index = container->indexOf( this ) + 1; return QString( "Fishbone %1" ).arg( index ); } @@ -761,31 +734,22 @@ void RimFishbones::initialiseObsoleteFields() CAF_PDM_InitField( &m_subsLocationMode_OBSOLETE, "SubsLocationMode", caf::AppEnum( FB_SUB_UNDEFINED ), - "Location Defined By", - "", - "", - "" ); + "Location Defined By" ); m_subsLocationMode_OBSOLETE.xmlCapability()->setIOWritable( false ); - CAF_PDM_InitField( &m_rangeStart_OBSOLETE, "RangeStart", std::numeric_limits::infinity(), "Start MD [m]", "", "", "" ); + CAF_PDM_InitField( &m_rangeStart_OBSOLETE, "RangeStart", std::numeric_limits::infinity(), "Start MD [m]" ); m_rangeStart_OBSOLETE.xmlCapability()->setIOWritable( false ); - CAF_PDM_InitField( &m_rangeEnd_OBSOLETE, "RangeEnd", std::numeric_limits::infinity(), "End MD [m]", "", "", "" ); + CAF_PDM_InitField( &m_rangeEnd_OBSOLETE, "RangeEnd", std::numeric_limits::infinity(), "End MD [m]" ); m_rangeEnd_OBSOLETE.xmlCapability()->setIOWritable( false ); - CAF_PDM_InitField( &m_rangeSubSpacing_OBSOLETE, - "RangeSubSpacing", - std::numeric_limits::infinity(), - "Spacing [m]", - "", - "", - "" ); + CAF_PDM_InitField( &m_rangeSubSpacing_OBSOLETE, "RangeSubSpacing", std::numeric_limits::infinity(), "Spacing [m]" ); m_rangeSubSpacing_OBSOLETE.xmlCapability()->setIOWritable( false ); - CAF_PDM_InitField( &m_rangeSubCount_OBSOLETE, "RangeSubCount", -1, "Number of Subs", "", "", "" ); + CAF_PDM_InitField( &m_rangeSubCount_OBSOLETE, "RangeSubCount", -1, "Number of Subs" ); m_rangeSubCount_OBSOLETE.xmlCapability()->setIOWritable( false ); - CAF_PDM_InitFieldNoDefault( &m_locationOfSubs_OBSOLETE, "LocationOfSubs", "Measured Depths [m]", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_locationOfSubs_OBSOLETE, "LocationOfSubs", "Measured Depths [m]" ); m_locationOfSubs_OBSOLETE.xmlCapability()->setIOWritable( false ); } diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimFishbonesCollection.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimFishbonesCollection.cpp index c2ded89a79..b1a1c5d74c 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimFishbonesCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimFishbonesCollection.cpp @@ -40,17 +40,17 @@ CAF_PDM_SOURCE_INIT( RimFishbonesCollection, "FishbonesCollection" ); //-------------------------------------------------------------------------------------------------- RimFishbonesCollection::RimFishbonesCollection() { - CAF_PDM_InitObject( "Fishbones", ":/FishBones16x16.png", "", "" ); + CAF_PDM_InitObject( "Fishbones", ":/FishBones16x16.png" ); nameField()->uiCapability()->setUiHidden( true ); this->setName( "Fishbones" ); - CAF_PDM_InitFieldNoDefault( &m_fishbones, "FishbonesSubs", "fishbonesSubs", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_fishbones, "FishbonesSubs", "fishbonesSubs" ); m_fishbones.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitField( &m_startMD, "StartMD", HUGE_VAL, "Start MD", "", "", "" ); - CAF_PDM_InitField( &m_mainBoreDiameter, "MainBoreDiameter", 0.216, "Main Bore Diameter", "", "", "" ); - CAF_PDM_InitField( &m_skinFactor, "MainBoreSkinFactor", 0., "Main Bore Skin Factor [0..1]", "", "", "" ); + CAF_PDM_InitField( &m_startMD, "StartMD", HUGE_VAL, "Start MD" ); + CAF_PDM_InitField( &m_mainBoreDiameter, "MainBoreDiameter", 0.216, "Main Bore Diameter" ); + CAF_PDM_InitField( &m_skinFactor, "MainBoreSkinFactor", 0., "Main Bore Skin Factor [0..1]" ); manuallyModifiedStartMD = false; } @@ -155,7 +155,7 @@ std::vector RimFishbonesCollection::activeFishbonesSubs() const //-------------------------------------------------------------------------------------------------- std::vector RimFishbonesCollection::allFishbonesSubs() const { - return m_fishbones.childObjects(); + return m_fishbones.children(); } //-------------------------------------------------------------------------------------------------- @@ -228,7 +228,7 @@ double RimFishbonesCollection::endMD() const double endMD = m_startMD; if ( !m_fishbones.empty() ) { - auto lastFishbone = m_fishbones.childObjects().back(); + auto lastFishbone = m_fishbones.children().back(); CVF_ASSERT( lastFishbone ); endMD = lastFishbone->endMD(); } diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimFishbonesPipeProperties.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimFishbonesPipeProperties.cpp index cd762a403c..bc9dead59e 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimFishbonesPipeProperties.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimFishbonesPipeProperties.cpp @@ -31,10 +31,10 @@ CAF_PDM_SOURCE_INIT( RimFishbonesPipeProperties, "FishbonesPipeProperties" ); //-------------------------------------------------------------------------------------------------- RimFishbonesPipeProperties::RimFishbonesPipeProperties() { - CAF_PDM_InitObject( "FishbonesPipeProperties", "", "", "" ); + CAF_PDM_InitObject( "FishbonesPipeProperties" ); - CAF_PDM_InitField( &m_lateralHoleDiameter, "LateralHoleDiameter", 12.5, "Hole Diameter [mm]", "", "", "" ); - CAF_PDM_InitField( &m_skinFactor, "SkinFactor", 0.0, "Skin Factor [0..1]", "", "", "" ); + CAF_PDM_InitField( &m_lateralHoleDiameter, "LateralHoleDiameter", 12.5, "Hole Diameter [mm]" ); + CAF_PDM_InitField( &m_skinFactor, "SkinFactor", 0.0, "Skin Factor [0..1]" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimFracture.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimFracture.cpp index b8e0f83817..56219f337a 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimFracture.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimFracture.cpp @@ -95,80 +95,65 @@ void setDefaultFractureColorResult() //-------------------------------------------------------------------------------------------------- RimFracture::RimFracture() { - CAF_PDM_InitObject( "Fracture", "", "", "" ); + CAF_PDM_InitObject( "Fracture" ); - CAF_PDM_InitFieldNoDefault( &m_fractureTemplate, "FractureDef", "Fracture Template", "", "", "" ); - CAF_PDM_InitField( &m_editFractureTemplate, "EditTemplate", false, "Edit", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_fractureTemplate, "FractureDef", "Fracture Template" ); + CAF_PDM_InitField( &m_editFractureTemplate, "EditTemplate", false, "Edit" ); m_editFractureTemplate.uiCapability()->setUiEditorTypeName( caf::PdmUiToolButtonEditor::uiEditorTypeName() ); m_editFractureTemplate.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); - CAF_PDM_InitField( &m_createEllipseFractureTemplate, - "CreateEllipseTemplate", - false, - "No Fracture Templates Found.", - "", - "", - "" ); + CAF_PDM_InitField( &m_createEllipseFractureTemplate, "CreateEllipseTemplate", false, "No Fracture Templates Found." ); m_createEllipseFractureTemplate.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); m_createEllipseFractureTemplate.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); - CAF_PDM_InitField( &m_createStimPlanFractureTemplate, "CreateStimPlanTemplate", false, "Create New Template?", "", "", "" ); + CAF_PDM_InitField( &m_createStimPlanFractureTemplate, "CreateStimPlanTemplate", false, "Create New Template?" ); m_createStimPlanFractureTemplate.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); m_createStimPlanFractureTemplate.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); CAF_PDM_InitField( &m_autoUpdateWellPathDepthAtFractureFromTemplate, "AutoUpdateWellPathDepthAtFractureFromTemplate", true, - "Auto-Update From Template", - "", - "", - "" ); + "Auto-Update From Template" ); - CAF_PDM_InitField( &m_wellPathDepthAtFracture, "WellPathDepthAtFracture", 0.0, "Well/Fracture Intersection Depth", "", "", "" ); + CAF_PDM_InitField( &m_wellPathDepthAtFracture, "WellPathDepthAtFracture", 0.0, "Well/Fracture Intersection Depth" ); m_wellPathDepthAtFracture.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_anchorPosition, "AnchorPosition", "Anchor Position", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_anchorPosition, "AnchorPosition", "Anchor Position" ); m_anchorPosition.uiCapability()->setUiHidden( true ); m_anchorPosition.xmlCapability()->disableIO(); - CAF_PDM_InitFieldNoDefault( &m_uiAnchorPosition, "ui_positionAtWellpath", "Fracture Position", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_uiAnchorPosition, "ui_positionAtWellpath", "Fracture Position" ); m_uiAnchorPosition.registerGetMethod( this, &RimFracture::fracturePositionForUi ); m_uiAnchorPosition.uiCapability()->setUiReadOnly( true ); m_uiAnchorPosition.xmlCapability()->disableIO(); - CAF_PDM_InitField( &m_azimuth, "Azimuth", 0.0, "Azimuth", "", "", "" ); + CAF_PDM_InitField( &m_azimuth, "Azimuth", 0.0, "Azimuth" ); m_azimuth.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_perforationLength, "PerforationLength", 1.0, "Perforation Length", "", "", "" ); - CAF_PDM_InitField( &m_perforationEfficiency, "PerforationEfficiency", 1.0, "Perforation Efficiency", "", "", "" ); + CAF_PDM_InitField( &m_perforationLength, "PerforationLength", 1.0, "Perforation Length" ); + CAF_PDM_InitField( &m_perforationEfficiency, "PerforationEfficiency", 1.0, "Perforation Efficiency" ); m_perforationEfficiency.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_wellDiameter, "WellDiameter", 0.216, "Well Diameter at Fracture", "", "", "" ); - CAF_PDM_InitField( &m_dip, "Dip", 0.0, "Dip", "", "", "" ); - CAF_PDM_InitField( &m_tilt, "Tilt", 0.0, "Tilt", "", "", "" ); + CAF_PDM_InitField( &m_wellDiameter, "WellDiameter", 0.216, "Well Diameter at Fracture" ); + CAF_PDM_InitField( &m_dip, "Dip", 0.0, "Dip" ); + CAF_PDM_InitField( &m_tilt, "Tilt", 0.0, "Tilt" ); CAF_PDM_InitField( &m_fractureUnit, "FractureUnit", caf::AppEnum( RiaDefines::EclipseUnitSystem::UNITS_METRIC ), - "Fracture Unit System", - "", - "", - "" ); + "Fracture Unit System" ); m_fractureUnit.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitField( &m_stimPlanTimeIndexToPlot, "TimeIndexToPlot", 0, "StimPlan Time Step", "", "", "" ); + CAF_PDM_InitField( &m_stimPlanTimeIndexToPlot, "TimeIndexToPlot", 0, "StimPlan Time Step" ); - CAF_PDM_InitFieldNoDefault( &m_uiWellPathAzimuth, "WellPathAzimuth", "Well Path Azimuth", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_uiWellPathAzimuth, "WellPathAzimuth", "Well Path Azimuth" ); m_uiWellPathAzimuth.registerGetMethod( this, &RimFracture::wellAzimuthAtFracturePositionText ); m_uiWellPathAzimuth.uiCapability()->setUiReadOnly( true ); m_uiWellPathAzimuth.xmlCapability()->disableIO(); CAF_PDM_InitFieldNoDefault( &m_uiWellFractureAzimuthDiff, "WellFractureAzimuthDiff", - "Azimuth Difference Between\nFracture and Well", - "", - "", - "" ); + "Azimuth Difference Between\nFracture and Well" ); m_uiWellFractureAzimuthDiff.registerGetMethod( this, &RimFracture::wellFractureAzimuthDiffText ); m_uiWellFractureAzimuthDiff.uiCapability()->setUiReadOnly( true ); m_uiWellFractureAzimuthDiff.xmlCapability()->disableIO(); @@ -176,9 +161,6 @@ RimFracture::RimFracture() CAF_PDM_InitField( &m_wellFractureAzimuthAngleWarning, "WellFractureAzimithAngleWarning", QString( "Difference is below 10 degrees. Consider longitudinal fracture" ), - "", - "", - "", "" ); m_wellFractureAzimuthAngleWarning.uiCapability()->setUiReadOnly( true ); m_wellFractureAzimuthAngleWarning.xmlCapability()->disableIO(); @@ -545,6 +527,14 @@ double RimFracture::dip() const return m_dip(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFracture::setDip( double dip ) +{ + m_dip = dip; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -637,8 +627,7 @@ cvf::Vec3d RimFracture::fracturePositionForUi() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimFracture::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RimFracture::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimFracture.h b/ApplicationLibCode/ProjectDataModel/Completions/RimFracture.h index 77778cf545..34d8585f7d 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimFracture.h +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimFracture.h @@ -95,6 +95,7 @@ class RimFracture : public RimCheckableNamedObject, public Rim3dPropertiesInterf size_t globalCellIndex ) const; cvf::Mat4d transformMatrix() const; + void setDip( double dip ); double dip() const; double tilt() const; @@ -137,8 +138,7 @@ class RimFracture : public RimCheckableNamedObject, public Rim3dPropertiesInterf double endMD() const override; protected: - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimFractureContainment.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimFractureContainment.cpp index 60b706d065..78ac9829f9 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimFractureContainment.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimFractureContainment.cpp @@ -30,9 +30,9 @@ CAF_PDM_SOURCE_INIT( RimFractureContainment, "FractureContainment" ); //-------------------------------------------------------------------------------------------------- RimFractureContainment::RimFractureContainment() { - CAF_PDM_InitObject( "Fracture Containment", "", "", "" ); + CAF_PDM_InitObject( "Fracture Containment" ); - CAF_PDM_InitField( &m_useContainment, "IsUsingFractureContainment", false, "Use Containment", "", "", "" ); + CAF_PDM_InitField( &m_useContainment, "IsUsingFractureContainment", false, "Use Containment" ); CAF_PDM_InitField( &m_topKLayer, "TopKLayer", 0, " Top Layer", "", "Do not allow fracture to grow into this layer", "" ); CAF_PDM_InitField( &m_baseKLayer, "BaseKLayer", 0, " Base Layer", "", "Do not allow fracture to grow into this layer", "" ); diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimFractureExportSettings.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimFractureExportSettings.cpp index 4d666c3a91..b58eefcd26 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimFractureExportSettings.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimFractureExportSettings.cpp @@ -30,19 +30,19 @@ CAF_PDM_SOURCE_INIT( RimFractureExportSettings, "RimFractureExportSettings" ); //-------------------------------------------------------------------------------------------------- RimFractureExportSettings::RimFractureExportSettings() { - CAF_PDM_InitObject( "RimFractureExportSettings", "", "", "" ); + CAF_PDM_InitObject( "RimFractureExportSettings" ); - CAF_PDM_InitFieldNoDefault( &fileName, "Filename", "Export Filename", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &fileName, "Filename", "Export Filename" ); fileName.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &caseToApply, "CaseToApply", "Case to Apply", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &caseToApply, "CaseToApply", "Case to Apply" ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- QList - RimFractureExportSettings::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) + RimFractureExportSettings::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimFractureExportSettings.h b/ApplicationLibCode/ProjectDataModel/Completions/RimFractureExportSettings.h index b421ab49d8..230b2d2e2a 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimFractureExportSettings.h +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimFractureExportSettings.h @@ -39,8 +39,7 @@ class RimFractureExportSettings : public caf::PdmObject caf::PdmField fileName; caf::PdmPtrField caseToApply; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; protected: void defineEditorAttribute( const caf::PdmFieldHandle* field, diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimFractureTemplate.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimFractureTemplate.cpp index 2963c303db..d9947f2c6b 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimFractureTemplate.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimFractureTemplate.cpp @@ -102,10 +102,6 @@ void caf::AppEnum::setUp() } // namespace caf -// TODO Move to cafPdmObject.h -#define CAF_PDM_InitField_Basic( field, keyword, default, uiName ) \ - CAF_PDM_InitField( field, keyword, default, uiName, "", "", "" ) - CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimFractureTemplate, "FractureTemplate", "RimFractureTemplate" ); //-------------------------------------------------------------------------------------------------- @@ -114,14 +110,14 @@ CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimFractureTemplate, "FractureTemplate", "RimF RimFractureTemplate::RimFractureTemplate() : wellPathDepthAtFractureChanged( this ) { - CAF_PDM_InitScriptableObject( "Fracture Template", ":/FractureTemplate16x16.png", "", "" ); + CAF_PDM_InitScriptableObject( "Fracture Template", ":/FractureTemplate16x16.png" ); - CAF_PDM_InitField( &m_id, "Id", -1, "ID", "", "", "" ); + CAF_PDM_InitField( &m_id, "Id", -1, "ID" ); m_id.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitField( &m_name, "UserDescription", QString( "Fracture Template" ), "Name", "", "", "" ); + CAF_PDM_InitField( &m_name, "UserDescription", QString( "Fracture Template" ), "Name" ); - CAF_PDM_InitFieldNoDefault( &m_nameAndUnit, "NameAndUnit", "NameAndUnit", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_nameAndUnit, "NameAndUnit", "NameAndUnit" ); m_nameAndUnit.registerGetMethod( this, &RimFractureTemplate::nameAndUnit ); m_nameAndUnit.uiCapability()->setUiHidden( true ); m_nameAndUnit.xmlCapability()->disableIO(); @@ -129,69 +125,54 @@ RimFractureTemplate::RimFractureTemplate() CAF_PDM_InitField( &m_fractureTemplateUnit, "UnitSystem", caf::AppEnum( RiaDefines::EclipseUnitSystem::UNITS_UNKNOWN ), - "Units System", - "", - "", - "" ); + "Units System" ); m_fractureTemplateUnit.uiCapability()->setUiReadOnly( true ); CAF_PDM_InitScriptableField( &m_orientationType, "Orientation", caf::AppEnum( TRANSVERSE_WELL_PATH ), - "Fracture Orientation", - "", - "", - "" ); + "Fracture Orientation" ); - CAF_PDM_InitScriptableField( &m_azimuthAngle, "AzimuthAngle", 0.0f, "Azimuth Angle", "", "", "" ); + CAF_PDM_InitScriptableField( &m_azimuthAngle, "AzimuthAngle", 0.0f, "Azimuth Angle" ); - CAF_PDM_InitField( &m_skinFactor, "SkinFactor", 0.0f, "Skin Factor", "", "", "" ); + CAF_PDM_InitField( &m_skinFactor, "SkinFactor", 0.0f, "Skin Factor" ); - CAF_PDM_InitField( &m_perforationLength, "PerforationLength", 1.0, "Perforation Length", "", "", "" ); + CAF_PDM_InitField( &m_perforationLength, "PerforationLength", 1.0, "Perforation Length" ); - CAF_PDM_InitField( &m_perforationEfficiency, "PerforationEfficiency", 1.0, "Perforation Efficiency", "", "", "" ); + CAF_PDM_InitField( &m_perforationEfficiency, "PerforationEfficiency", 1.0, "Perforation Efficiency" ); m_perforationEfficiency.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_wellDiameter, "WellDiameter", 0.216, "Well Diameter at Fracture", "", "", "" ); + CAF_PDM_InitField( &m_wellDiameter, "WellDiameter", 0.216, "Well Diameter at Fracture" ); CAF_PDM_InitField( &m_conductivityType, "ConductivityType", caf::AppEnum( FINITE_CONDUCTIVITY ), - "Conductivity in Fracture", - "", - "", - "" ); + "Conductivity in Fracture" ); - CAF_PDM_InitField( &m_wellPathDepthAtFracture, "WellPathDepthAtFracture", 0.0, "Well/Fracture Intersection Depth", "", "", "" ); + CAF_PDM_InitField( &m_wellPathDepthAtFracture, "WellPathDepthAtFracture", 0.0, "Well/Fracture Intersection Depth" ); m_wellPathDepthAtFracture.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_fractureContainment, "FractureContainmentField", "Fracture Containment", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_fractureContainment, "FractureContainmentField", "Fracture Containment" ); m_fractureContainment = new RimFractureContainment(); m_fractureContainment.uiCapability()->setUiTreeHidden( true ); m_fractureContainment.uiCapability()->setUiTreeChildrenHidden( true ); // Non-Darcy Flow options - CAF_PDM_InitFieldNoDefault( &m_nonDarcyFlowType, "NonDarcyFlowType", "Non-Darcy Flow", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_nonDarcyFlowType, "NonDarcyFlowType", "Non-Darcy Flow" ); - CAF_PDM_InitField( &m_userDefinedDFactor, "UserDefinedDFactor", 1.0, "D Factor", "", "", "" ); + CAF_PDM_InitField( &m_userDefinedDFactor, "UserDefinedDFactor", 1.0, "D Factor" ); - CAF_PDM_InitFieldNoDefault( &m_fractureWidthType, "FractureWidthType", "Type", "", "", "" ); - CAF_PDM_InitField_Basic( &m_fractureWidth, "FractureWidth", 0.01, "Fracture Width (h)" ); + CAF_PDM_InitFieldNoDefault( &m_fractureWidthType, "FractureWidthType", "Type" ); + CAF_PDM_InitField( &m_fractureWidth, "FractureWidth", 0.01, "Fracture Width (h)" ); - CAF_PDM_InitFieldNoDefault( &m_betaFactorType, "BetaFactorType", "Type", "", "", "" ); - CAF_PDM_InitField_Basic( &m_inertialCoefficient, - "InertialCoefficient", - 0.006083236, - "Inertial Coefficient (β) [Forch. unit]" ); + CAF_PDM_InitFieldNoDefault( &m_betaFactorType, "BetaFactorType", "Type" ); + CAF_PDM_InitField( &m_inertialCoefficient, + "InertialCoefficient", + 0.006083236, + "Inertial Coefficient (β) [Forch. unit]" ); - CAF_PDM_InitFieldNoDefault( &m_permeabilityType, "PermeabilityType", "Type", "", "", "" ); - CAF_PDM_InitField_Basic( &m_relativePermeability, "RelativePermeability", 1.0, "Relative Permeability" ); - CAF_PDM_InitField( &m_userDefinedEffectivePermeability, - "EffectivePermeability", - 0.0, - "Effective Permeability (Ke) [mD]", - "", - "", - "" ); + CAF_PDM_InitFieldNoDefault( &m_permeabilityType, "PermeabilityType", "Type" ); + CAF_PDM_InitField( &m_relativePermeability, "RelativePermeability", 1.0, "Relative Permeability" ); + CAF_PDM_InitField( &m_userDefinedEffectivePermeability, "EffectivePermeability", 0.0, "Effective Permeability (Ke) [mD]" ); CAF_PDM_InitField( &m_relativeGasDensity, "RelativeGasDensity", @@ -208,22 +189,22 @@ RimFractureTemplate::RimFractureTemplate() "Gas viscosity at bottom hole pressure", "" ); - CAF_PDM_InitFieldNoDefault( &m_dFactorDisplayField, "dFactorDisplayField", "D Factor", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_dFactorDisplayField, "dFactorDisplayField", "D Factor" ); m_dFactorDisplayField.registerGetMethod( this, &RimFractureTemplate::dFactorForTemplate ); m_dFactorDisplayField.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); m_dFactorDisplayField.uiCapability()->setUiReadOnly( true ); m_dFactorDisplayField.xmlCapability()->disableIO(); - CAF_PDM_InitFieldNoDefault( &m_dFactorSummaryText, "dFactorSummaryText", "D Factor Summary", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_dFactorSummaryText, "dFactorSummaryText", "D Factor Summary" ); m_dFactorSummaryText.registerGetMethod( this, &RimFractureTemplate::dFactorSummary ); m_dFactorSummaryText.uiCapability()->setUiReadOnly( true ); m_dFactorSummaryText.uiCapability()->setUiEditorTypeName( caf::PdmUiTextEditor::uiEditorTypeName() ); m_dFactorSummaryText.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosType::TOP ); m_dFactorSummaryText.xmlCapability()->disableIO(); - CAF_PDM_InitField( &m_heightScaleFactor, "HeightScaleFactor", 1.0, "Height", "", "", "" ); - CAF_PDM_InitField( &m_halfLengthScaleFactor, "WidthScaleFactor", 1.0, "Half Length", "", "", "" ); - CAF_PDM_InitField( &m_dFactorScaleFactor, "DFactorScaleFactor", 1.0, "D-factor", "", "", "" ); + CAF_PDM_InitField( &m_heightScaleFactor, "HeightScaleFactor", 1.0, "Height" ); + CAF_PDM_InitField( &m_halfLengthScaleFactor, "WidthScaleFactor", 1.0, "Half Length" ); + CAF_PDM_InitField( &m_dFactorScaleFactor, "DFactorScaleFactor", 1.0, "D-factor" ); CAF_PDM_InitField( &m_conductivityScaleFactor, "ConductivityFactor", 1.0, @@ -231,7 +212,7 @@ RimFractureTemplate::RimFractureTemplate() "", "The conductivity values read from file will be scaled with this parameters", "" ); - CAF_PDM_InitField( &m_scaleApplyButton, "ScaleApplyButton", false, "Apply", "", "", "" ); + CAF_PDM_InitField( &m_scaleApplyButton, "ScaleApplyButton", false, "Apply" ); m_scaleApplyButton.xmlCapability()->disableIO(); m_scaleApplyButton.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp index 1401552e57..ab2084eea7 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp @@ -22,7 +22,6 @@ #include "RigStatisticsMath.h" -#include "RigEclipseCaseData.h" #include "RimCase.h" #include "RimEclipseCase.h" #include "RimEclipseView.h" @@ -30,21 +29,11 @@ #include "RimFracture.h" #include "RimFractureTemplate.h" #include "RimProject.h" -#include "RimSimWellInViewCollection.h" -#include "RimStimPlanColors.h" #include "RimStimPlanFractureTemplate.h" -#include "RimTools.h" -#include "RimWellPath.h" -#include "RimWellPathCollection.h" -#include "RimWellPathFracture.h" -#include "RimWellPathFractureCollection.h" -#include "cafPdmFieldScriptingCapability.h" #include "cafPdmObject.h" #include "cafPdmObjectScriptingCapability.h" -#include - CAF_PDM_SOURCE_INIT( RimFractureTemplateCollection, "FractureTemplateCollection", "FractureDefinitionCollection" ); //-------------------------------------------------------------------------------------------------- @@ -52,20 +41,17 @@ CAF_PDM_SOURCE_INIT( RimFractureTemplateCollection, "FractureTemplateCollection" //-------------------------------------------------------------------------------------------------- RimFractureTemplateCollection::RimFractureTemplateCollection() { - CAF_PDM_InitScriptableObject( "Fracture Templates", ":/FractureTemplates16x16.png", "", "" ); + CAF_PDM_InitScriptableObject( "Fracture Templates", ":/FractureTemplates16x16.png" ); CAF_PDM_InitField( &m_defaultUnitsForFracTemplates, "DefaultUnitForTemplates", caf::AppEnum( RiaDefines::EclipseUnitSystem::UNITS_METRIC ), - "Default unit system for fracture templates", - "", - "", - "" ); + "Default unit system for fracture templates" ); - CAF_PDM_InitFieldNoDefault( &m_fractureDefinitions, "FractureDefinitions", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_fractureDefinitions, "FractureDefinitions", "" ); m_fractureDefinitions.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitField( &m_nextValidFractureTemplateId, "NextValidFractureTemplateId", 0, "", "", "", "" ); + CAF_PDM_InitField( &m_nextValidFractureTemplateId, "NextValidFractureTemplateId", 0, "" ); m_nextValidFractureTemplateId.uiCapability()->setUiHidden( true ); } @@ -74,7 +60,7 @@ RimFractureTemplateCollection::RimFractureTemplateCollection() //-------------------------------------------------------------------------------------------------- RimFractureTemplateCollection::~RimFractureTemplateCollection() { - m_fractureDefinitions.deleteAllChildObjects(); + m_fractureDefinitions.deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -302,12 +288,6 @@ void RimFractureTemplateCollection::updateFilePathsFromProjectPath( const QStrin { for ( RimFractureTemplate* f : m_fractureDefinitions() ) { - RimStimPlanFractureTemplate* stimPlanFracture = dynamic_cast( f ); - if ( stimPlanFracture ) - { - stimPlanFracture->updateFilePathsFromProjectPath( newProjectPath, oldProjectPath ); - } - RimEllipseFractureTemplate* ellipseFracture = dynamic_cast( f ); if ( ellipseFracture ) { @@ -326,106 +306,6 @@ void RimFractureTemplateCollection::initAfterRead() { if ( templ->id() < 0 ) templ->setId( nextFractureTemplateId() ); } - - RimProject* proj = nullptr; - this->firstAncestorOrThisOfType( proj ); - if ( proj && proj->isProjectFileVersionEqualOrOlderThan( "2018.1.0.103" ) ) - { - bool setAllShowMeshToFalseOnAllEclipseViews = false; - - std::vector wellPathFractures; - RimWellPathCollection* wellPathCollection = RimTools::wellPathCollection(); - wellPathCollection->descendantsIncludingThisOfType( wellPathFractures ); - - for ( RimWellPathFracture* fracture : wellPathFractures ) - { - RimStimPlanFractureTemplate* stimPlanFractureTemplate = - dynamic_cast( fracture->fractureTemplate() ); - if ( stimPlanFractureTemplate ) - { - if ( stimPlanFractureTemplate->showStimPlanMesh() == false ) - { - setAllShowMeshToFalseOnAllEclipseViews = true; - break; - } - } - } - - std::vector eclipseViews; - - std::vector rimCases; - proj->allCases( rimCases ); - - for ( RimCase* rimCase : rimCases ) - { - for ( Rim3dView* view : rimCase->views() ) - { - RimEclipseView* eclView = dynamic_cast( view ); - if ( eclView ) - { - eclipseViews.push_back( eclView ); - } - } - } - - for ( RimEclipseView* eclipseView : eclipseViews ) - { - if ( setAllShowMeshToFalseOnAllEclipseViews ) - { - eclipseView->fractureColors()->setShowStimPlanMesh( false ); - continue; - } - - // Find all fractures in all simWells - std::map stimPlanFractureTemplatesInView; - - std::vector fractures; - if ( eclipseView->wellCollection() ) - { - eclipseView->wellCollection()->descendantsIncludingThisOfType( fractures ); - } - if ( fractures.empty() ) continue; - - for ( RimFracture* fracture : fractures ) - { - RimStimPlanFractureTemplate* stimPlanFractureTemplate = - dynamic_cast( fracture->fractureTemplate() ); - if ( stimPlanFractureTemplate ) - { - stimPlanFractureTemplatesInView[stimPlanFractureTemplate]; - } - } - - if ( stimPlanFractureTemplatesInView.empty() ) continue; - - auto templateIt = stimPlanFractureTemplatesInView.begin(); - - if ( stimPlanFractureTemplatesInView.size() == 1 ) - { - eclipseView->fractureColors()->setShowStimPlanMesh( templateIt->first->showStimPlanMesh() ); - } - else - { - bool anySetShowStimPlanMeshIsSetToFalse = false; - for ( ; templateIt != stimPlanFractureTemplatesInView.end(); templateIt++ ) - { - if ( templateIt->first->showStimPlanMesh() == false ) - { - anySetShowStimPlanMeshIsSetToFalse = true; - break; - } - } - if ( anySetShowStimPlanMeshIsSetToFalse ) - { - eclipseView->fractureColors()->setShowStimPlanMesh( false ); - } - else - { - eclipseView->fractureColors()->setShowStimPlanMesh( true ); - } - } - } - } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimMswCompletionParameters.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimMswCompletionParameters.cpp index ef5a9d53d2..9f31e1261b 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimMswCompletionParameters.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimMswCompletionParameters.cpp @@ -63,32 +63,20 @@ CAF_PDM_SOURCE_INIT( RimMswCompletionParameters, "RimMswCompletionParameters" ); //-------------------------------------------------------------------------------------------------- RimMswCompletionParameters::RimMswCompletionParameters() { - CAF_PDM_InitObject( "MSW Completion Parameters", ":/CompletionsSymbol16x16.png", "", "" ); - - CAF_PDM_InitFieldNoDefault( &m_refMDType, "RefMDType", "Reference MD", "", "", "" ); - CAF_PDM_InitField( &m_refMD, "RefMD", 0.0, "", "", "", "" ); - - CAF_PDM_InitField( &m_customValuesForLateral, "CustomValuesForLateral", false, "Custom Values for Lateral", "", "", "" ); - CAF_PDM_InitField( &m_linerDiameter, - "LinerDiameter", - std::numeric_limits::infinity(), - "Liner Inner Diameter", - "", - "", - "" ); - CAF_PDM_InitField( &m_roughnessFactor, - "RoughnessFactor", - std::numeric_limits::infinity(), - "Roughness Factor", - "", - "", - "" ); - - CAF_PDM_InitFieldNoDefault( &m_pressureDrop, "PressureDrop", "Pressure Drop", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_lengthAndDepth, "LengthAndDepth", "Length and Depth", "", "", "" ); - - CAF_PDM_InitField( &m_enforceMaxSegmentLength, "EnforceMaxSegmentLength", false, "Enforce Max Segment Length", "", "", "" ); - CAF_PDM_InitField( &m_maxSegmentLength, "MaxSegmentLength", 200.0, "Max Segment Length", "", "", "" ); + CAF_PDM_InitObject( "MSW Completion Parameters", ":/CompletionsSymbol16x16.png" ); + + CAF_PDM_InitFieldNoDefault( &m_refMDType, "RefMDType", "Reference MD" ); + CAF_PDM_InitField( &m_refMD, "RefMD", 0.0, "" ); + + CAF_PDM_InitField( &m_customValuesForLateral, "CustomValuesForLateral", false, "Custom Values for Lateral" ); + CAF_PDM_InitField( &m_linerDiameter, "LinerDiameter", std::numeric_limits::infinity(), "Liner Inner Diameter" ); + CAF_PDM_InitField( &m_roughnessFactor, "RoughnessFactor", std::numeric_limits::infinity(), "Roughness Factor" ); + + CAF_PDM_InitFieldNoDefault( &m_pressureDrop, "PressureDrop", "Pressure Drop" ); + CAF_PDM_InitFieldNoDefault( &m_lengthAndDepth, "LengthAndDepth", "Length and Depth" ); + + CAF_PDM_InitField( &m_enforceMaxSegmentLength, "EnforceMaxSegmentLength", false, "Enforce Max Segment Length" ); + CAF_PDM_InitField( &m_maxSegmentLength, "MaxSegmentLength", 200.0, "Max Segment Length" ); m_maxSegmentLength.uiCapability()->setUiHidden( true ); } diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimMultipleValveLocations.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimMultipleValveLocations.cpp index db382fd77c..37f39349d6 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimMultipleValveLocations.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimMultipleValveLocations.cpp @@ -51,27 +51,21 @@ void AppEnum::setUp() //-------------------------------------------------------------------------------------------------- RimMultipleValveLocations::RimMultipleValveLocations() { - CAF_PDM_InitObject( "RimMultipleValveLocations", ":/FishBoneGroup16x16.png", "", "" ); - - CAF_PDM_InitField( &m_locationType, - "LocationMode", - caf::AppEnum( VALVE_COUNT ), - "Location Defined By", - "", - "", - "" ); - CAF_PDM_InitField( &m_rangeStart, "RangeStart", 100.0, "Start MD [m]", "", "", "" ); + CAF_PDM_InitObject( "RimMultipleValveLocations", ":/FishBoneGroup16x16.png" ); + + CAF_PDM_InitField( &m_locationType, "LocationMode", caf::AppEnum( VALVE_COUNT ), "Location Defined By" ); + CAF_PDM_InitField( &m_rangeStart, "RangeStart", 100.0, "Start MD [m]" ); m_rangeStart.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_rangeEnd, "RangeEnd", 250.0, "End MD [m]", "", "", "" ); + CAF_PDM_InitField( &m_rangeEnd, "RangeEnd", 250.0, "End MD [m]" ); m_rangeEnd.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_rangeValveSpacing, "ValveSpacing", "Spacing [m]", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_rangeValveSpacing, "ValveSpacing", "Spacing [m]" ); m_rangeValveSpacing.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_rangeValveCount, "RangeValveCount", 13, "Number of Valves", "", "", "" ); + CAF_PDM_InitField( &m_rangeValveCount, "RangeValveCount", 13, "Number of Valves" ); - CAF_PDM_InitFieldNoDefault( &m_locationOfValves, "LocationOfValves", "Measured Depths [m]", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_locationOfValves, "LocationOfValves", "Measured Depths [m]" ); m_locationOfValves.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() ); } diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimNonDarcyPerforationParameters.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimNonDarcyPerforationParameters.cpp index 08fd1d89db..c0dcc45eca 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimNonDarcyPerforationParameters.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimNonDarcyPerforationParameters.cpp @@ -43,21 +43,18 @@ CAF_PDM_SOURCE_INIT( RimNonDarcyPerforationParameters, "RimNonDarcyPerforationPa //-------------------------------------------------------------------------------------------------- RimNonDarcyPerforationParameters::RimNonDarcyPerforationParameters() { - CAF_PDM_InitObject( "NonDarcyPerforationParameters", ":/CompletionsSymbol16x16.png", "", "" ); + CAF_PDM_InitObject( "NonDarcyPerforationParameters", ":/CompletionsSymbol16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_nonDarcyFlowType, "NonDarcyFlowType", "Non-Darcy Flow", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_nonDarcyFlowType, "NonDarcyFlowType", "Non-Darcy Flow" ); - CAF_PDM_InitField( &m_userDefinedDFactor, "UserDefinedDFactor", 1.0, "D Factor", "", "", "" ); + CAF_PDM_InitField( &m_userDefinedDFactor, "UserDefinedDFactor", 1.0, "D Factor" ); CAF_PDM_InitField( &m_gridPermeabilityScalingFactor, "GridPermeabilityScalingFactor", 1.0, - "Grid Permeability Scaling Factor (Kr) [0..1]", - "", - "", - "" ); + "Grid Permeability Scaling Factor (Kr) [0..1]" ); - CAF_PDM_InitField( &m_wellRadius, "WellRadius", 0.108, "Well Radius (rw) [m]", "", "", "" ); + CAF_PDM_InitField( &m_wellRadius, "WellRadius", 0.108, "Well Radius (rw) [m]" ); CAF_PDM_InitField( &m_relativeGasDensity, "RelativeGasDensity", @@ -78,19 +75,10 @@ RimNonDarcyPerforationParameters::RimNonDarcyPerforationParameters() CAF_PDM_InitField( &m_inertialCoefficientBeta0, "InertialCoefficientBeta0", 883.90, - "Inertial Coefficient (β0) [Forch. unit]", - "", - "", - "" ); - CAF_PDM_InitField( &m_permeabilityScalingFactor, - "PermeabilityScalingFactor", - -1.1045, - "Permeability Scaling Factor (B)", - "", - "", - "" ); + "Inertial Coefficient (β0) [Forch. unit]" ); + CAF_PDM_InitField( &m_permeabilityScalingFactor, "PermeabilityScalingFactor", -1.1045, "Permeability Scaling Factor (B)" ); - CAF_PDM_InitField( &m_porosityScalingFactor, "PorosityScalingFactor", 0.0, "Porosity Scaling Factor (C)", "", "", "" ); + CAF_PDM_InitField( &m_porosityScalingFactor, "PorosityScalingFactor", 0.0, "Porosity Scaling Factor (C)" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimPerforationCollection.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimPerforationCollection.cpp index d7d1b88003..f35aa426a6 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimPerforationCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimPerforationCollection.cpp @@ -40,15 +40,15 @@ CAF_PDM_SOURCE_INIT( RimPerforationCollection, "PerforationCollection" ); //-------------------------------------------------------------------------------------------------- RimPerforationCollection::RimPerforationCollection() { - CAF_PDM_InitObject( "Perforations", ":/PerforationIntervals16x16.png", "", "" ); + CAF_PDM_InitObject( "Perforations", ":/PerforationIntervals16x16.png" ); nameField()->uiCapability()->setUiHidden( true ); this->setName( "Perforations" ); - CAF_PDM_InitFieldNoDefault( &m_perforations, "Perforations", "Perforations", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_perforations, "Perforations", "Perforations" ); m_perforations.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_nonDarcyParameters, "NonDarcyParameters", "Non-Darcy Parameters", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_nonDarcyParameters, "NonDarcyParameters", "Non-Darcy Parameters" ); m_nonDarcyParameters = new RimNonDarcyPerforationParameters(); m_nonDarcyParameters.uiCapability()->setUiTreeHidden( true ); m_nonDarcyParameters.uiCapability()->setUiTreeChildrenHidden( true ); @@ -59,7 +59,7 @@ RimPerforationCollection::RimPerforationCollection() //-------------------------------------------------------------------------------------------------- RimPerforationCollection::~RimPerforationCollection() { - m_perforations.deleteAllChildObjects(); + m_perforations.deleteChildren(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimPerforationInterval.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimPerforationInterval.cpp index e7345dad17..07aa19f75c 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimPerforationInterval.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimPerforationInterval.cpp @@ -21,6 +21,7 @@ #include "RiaColorTables.h" #include "RiaEclipseUnitTools.h" +#include "RiaQDateTimeTools.h" #include "RigCaseCellResultsData.h" #include "RigWellPath.h" @@ -41,23 +42,23 @@ CAF_PDM_SOURCE_INIT( RimPerforationInterval, "Perforation" ); //-------------------------------------------------------------------------------------------------- RimPerforationInterval::RimPerforationInterval() { - CAF_PDM_InitObject( "Perforation", ":/PerforationInterval16x16.png", "", "" ); + CAF_PDM_InitObject( "Perforation", ":/PerforationInterval16x16.png" ); - CAF_PDM_InitField( &m_startMD, "StartMeasuredDepth", 0.0, "Start MD", "", "", "" ); - CAF_PDM_InitField( &m_endMD, "EndMeasuredDepth", 0.0, "End MD", "", "", "" ); - CAF_PDM_InitField( &m_diameter, "Diameter", 0.216, "Diameter", "", "", "" ); - CAF_PDM_InitField( &m_skinFactor, "SkinFactor", 0.0, "Skin Factor", "", "", "" ); + CAF_PDM_InitField( &m_startMD, "StartMeasuredDepth", 0.0, "Start MD" ); + CAF_PDM_InitField( &m_endMD, "EndMeasuredDepth", 0.0, "End MD" ); + CAF_PDM_InitField( &m_diameter, "Diameter", 0.216, "Diameter" ); + CAF_PDM_InitField( &m_skinFactor, "SkinFactor", 0.0, "Skin Factor" ); - CAF_PDM_InitField( &m_startOfHistory_OBSOLETE, "StartOfHistory", true, "All Timesteps", "", "", "" ); + CAF_PDM_InitField( &m_startOfHistory_OBSOLETE, "StartOfHistory", true, "All Timesteps" ); m_startOfHistory_OBSOLETE.xmlCapability()->setIOWritable( false ); - CAF_PDM_InitField( &m_useCustomStartDate, "UseCustomStartDate", false, "Custom Start Date", "", "", "" ); - CAF_PDM_InitField( &m_startDate, "StartDate", QDateTime::currentDateTime(), "Start Date", "", "", "" ); + CAF_PDM_InitField( &m_useCustomStartDate, "UseCustomStartDate", false, "Custom Start Date" ); + CAF_PDM_InitField( &m_startDate, "StartDate", QDateTime::currentDateTime(), "Start Date" ); - CAF_PDM_InitField( &m_useCustomEndDate, "UseCustomEndDate", false, "Custom End Date", "", "", "" ); - CAF_PDM_InitField( &m_endDate, "EndDate", QDateTime::currentDateTime(), "End Date", "", "", "" ); + CAF_PDM_InitField( &m_useCustomEndDate, "UseCustomEndDate", false, "Custom End Date" ); + CAF_PDM_InitField( &m_endDate, "EndDate", QDateTime::currentDateTime(), "End Date" ); - CAF_PDM_InitFieldNoDefault( &m_valves, "Valves", "Valves", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_valves, "Valves", "Valves" ); m_valves.uiCapability()->setUiTreeHidden( true ); nameField()->uiCapability()->setUiReadOnly( true ); @@ -99,7 +100,7 @@ void RimPerforationInterval::setCustomStartDate( const QDate& date ) { if ( date.isValid() ) { - m_startDate = QDateTime( date ); + m_startDate = RiaQDateTimeTools::createDateTime( date ); } } @@ -110,7 +111,7 @@ void RimPerforationInterval::setCustomEndDate( const QDate& date ) { if ( date.isValid() ) { - m_endDate = QDateTime( date ); + m_endDate = RiaQDateTimeTools::createDateTime( date ); } } diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimSimWellFracture.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimSimWellFracture.cpp index 23b92f0f4f..32a1e98e96 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimSimWellFracture.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimSimWellFracture.cpp @@ -40,17 +40,17 @@ CAF_PDM_SOURCE_INIT( RimSimWellFracture, "SimWellFracture" ); //-------------------------------------------------------------------------------------------------- RimSimWellFracture::RimSimWellFracture( void ) { - CAF_PDM_InitObject( "SimWellFracture", ":/FractureSymbol16x16.png", "", "" ); + CAF_PDM_InitObject( "SimWellFracture", ":/FractureSymbol16x16.png" ); - CAF_PDM_InitField( &m_location, "MeasuredDepth", 0.0f, "Pseudo Length Location", "", "", "" ); + CAF_PDM_InitField( &m_location, "MeasuredDepth", 0.0f, "Pseudo Length Location" ); m_location.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_displayIJK, "Cell_IJK", "Cell IJK", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_displayIJK, "Cell_IJK", "Cell IJK" ); m_displayIJK.registerGetMethod( this, &RimSimWellFracture::createOneBasedIJKText ); m_displayIJK.uiCapability()->setUiReadOnly( true ); m_displayIJK.xmlCapability()->disableIO(); - CAF_PDM_InitField( &m_branchIndex, "Branch", 0, "Branch", "", "", "" ); + CAF_PDM_InitField( &m_branchIndex, "Branch", 0, "Branch" ); setDeletable( true ); } @@ -286,10 +286,9 @@ void RimSimWellFracture::defineEditorAttribute( const caf::PdmFieldHandle* field //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimSimWellFracture::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RimSimWellFracture::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { - QList options = RimFracture::calculateValueOptions( fieldNeedingOptions, useOptionsOnly ); + QList options = RimFracture::calculateValueOptions( fieldNeedingOptions ); if ( fieldNeedingOptions == &m_branchIndex ) { diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimSimWellFracture.h b/ApplicationLibCode/ProjectDataModel/Completions/RimSimWellFracture.h index 194cc07500..39dabcf450 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimSimWellFracture.h +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimSimWellFracture.h @@ -60,8 +60,7 @@ class RimSimWellFracture : public RimFracture void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; private: RigMainGrid* ownerCaseMainGrid() const; diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimSimWellFractureCollection.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimSimWellFractureCollection.cpp index ed3f50dfdb..6fe6f2d766 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimSimWellFractureCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimSimWellFractureCollection.cpp @@ -28,9 +28,9 @@ CAF_PDM_SOURCE_INIT( RimSimWellFractureCollection, "SimWellFractureCollection" ) //-------------------------------------------------------------------------------------------------- RimSimWellFractureCollection::RimSimWellFractureCollection( void ) { - CAF_PDM_InitObject( "Fractures", ":/FractureLayout16x16.png", "", "" ); + CAF_PDM_InitObject( "Fractures", ":/FractureLayout16x16.png" ); - CAF_PDM_InitFieldNoDefault( &simwellFractures, "Fractures", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &simwellFractures, "Fractures", "" ); simwellFractures.uiCapability()->setUiTreeHidden( true ); setDeletable( true ); @@ -41,7 +41,7 @@ RimSimWellFractureCollection::RimSimWellFractureCollection( void ) //-------------------------------------------------------------------------------------------------- RimSimWellFractureCollection::~RimSimWellFractureCollection() { - simwellFractures.deleteAllChildObjects(); + simwellFractures.deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -49,7 +49,7 @@ RimSimWellFractureCollection::~RimSimWellFractureCollection() //-------------------------------------------------------------------------------------------------- void RimSimWellFractureCollection::deleteFractures() { - simwellFractures.deleteAllChildObjects(); + simwellFractures.deleteChildren(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index 0c6db6a6dc..bca9c76949 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -72,39 +72,34 @@ CAF_PDM_SOURCE_INIT( RimStimPlanFractureTemplate, "StimPlanFractureTemplate", "R //-------------------------------------------------------------------------------------------------- RimStimPlanFractureTemplate::RimStimPlanFractureTemplate() { - CAF_PDM_InitScriptableObject( "Fracture Template", ":/FractureTemplate16x16.png", "", "" ); + CAF_PDM_InitScriptableObject( "Fracture Template", ":/FractureTemplate16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_stimPlanFileName, "StimPlanFileName", "File Name", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_stimPlanFileName, "StimPlanFileName", "File Name" ); m_stimPlanFileName.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); CAF_PDM_InitField( &m_userDefinedWellPathDepthAtFracture, "UserDefinedWellPathDepthAtFracture", false, - "User-Defined Well/Fracture Intersection Depth", - "", - "", - "" ); + "User-Defined Well/Fracture Intersection Depth" ); - CAF_PDM_InitField( &m_borderPolygonResultName, "BorderPolygonResultName", QString( "" ), "Parameter", "", "", "" ); + CAF_PDM_InitField( &m_borderPolygonResultName, "BorderPolygonResultName", QString( "" ), "Parameter" ); m_borderPolygonResultName.uiCapability()->setUiHidden( true ); - CAF_PDM_InitField( &m_activeTimeStepIndex, "ActiveTimeStepIndex", 0, "Active TimeStep Index", "", "", "" ); + CAF_PDM_InitField( &m_activeTimeStepIndex, "ActiveTimeStepIndex", 0, "Active TimeStep Index" ); CAF_PDM_InitField( &m_conductivityResultNameOnFile, "ConductivityResultName", QString( "" ), - "Active Conductivity Result Name", - "", - "", - "" ); + "Active Conductivity Result Name" ); - CAF_PDM_InitFieldNoDefault( &m_propertiesTable, "PropertiesTable", "Properties Table", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_propertiesTable, "PropertiesTable", "Properties Table" ); m_propertiesTable.uiCapability()->setUiEditorTypeName( caf::PdmUiTextEditor::uiEditorTypeName() ); m_propertiesTable.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); m_propertiesTable.uiCapability()->setUiReadOnly( true ); m_propertiesTable.xmlCapability()->disableIO(); - CAF_PDM_InitField( &m_showStimPlanMesh_OBSOLETE, "ShowStimPlanMesh", true, "", "", "", "" ); + CAF_PDM_InitField( &m_showStimPlanMesh_OBSOLETE, "ShowStimPlanMesh", true, "" ); m_showStimPlanMesh_OBSOLETE.uiCapability()->setUiHidden( true ); + m_showStimPlanMesh_OBSOLETE.xmlCapability()->setIOWritable( false ); m_readError = false; @@ -198,16 +193,6 @@ QString RimStimPlanFractureTemplate::fileName() return m_stimPlanFileName().path(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimStimPlanFractureTemplate::updateFilePathsFromProjectPath( const QString& newProjectPath, - const QString& oldProjectPath ) -{ - // m_stimPlanFileName = RimTools::relocateFile( m_stimPlanFileName(), newProjectPath, oldProjectPath, nullptr, - // nullptr ); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -340,7 +325,7 @@ void RimStimPlanFractureTemplate::loadDataAndUpdate() /// //-------------------------------------------------------------------------------------------------- QList - RimStimPlanFractureTemplate::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) + RimStimPlanFractureTemplate::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; @@ -798,14 +783,6 @@ QString RimStimPlanFractureTemplate::mapUiResultNameToFileResultName( const QStr return fileResultName; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RimStimPlanFractureTemplate::showStimPlanMesh() const -{ - return m_showStimPlanMesh_OBSOLETE(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h b/ApplicationLibCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h index 65ba2bc874..f1290b2e62 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h @@ -61,8 +61,6 @@ class RimStimPlanFractureTemplate : public RimFractureTemplate void setFileName( const QString& fileName ); QString fileName(); - void updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ); - std::pair wellPathDepthAtFractureRange() const override; QString wellPathDepthAtFractureUiName() const override; @@ -97,8 +95,6 @@ class RimStimPlanFractureTemplate : public RimFractureTemplate QString mapUiResultNameToFileResultName( const QString& uiResultName ) const; - bool showStimPlanMesh() const; - void convertToUnitSystem( RiaDefines::EclipseUnitSystem neededUnit ) override; double formationDip() const; @@ -110,8 +106,7 @@ class RimStimPlanFractureTemplate : public RimFractureTemplate private: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimValveTemplate.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimValveTemplate.cpp index 9e57033c1b..f456aca62a 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimValveTemplate.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimValveTemplate.cpp @@ -30,27 +30,24 @@ CAF_PDM_SOURCE_INIT( RimValveTemplate, "ValveTemplate" ); //-------------------------------------------------------------------------------------------------- RimValveTemplate::RimValveTemplate() { - CAF_PDM_InitObject( "Valve Template", ":/ICDValve16x16.png", "", "" ); + CAF_PDM_InitObject( "Valve Template", ":/ICDValve16x16.png" ); CAF_PDM_InitField( &m_valveTemplateUnit, "UnitSystem", caf::AppEnum( RiaDefines::EclipseUnitSystem::UNITS_UNKNOWN ), - "Units System", - "", - "", - "" ); + "Units System" ); m_valveTemplateUnit.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitFieldNoDefault( &m_type, "CompletionType", "Type", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_type, "CompletionType", "Type" ); m_type = RiaDefines::WellPathComponentType::ICD; - CAF_PDM_InitField( &m_userLabel, "UserLabel", QString( "Template" ), "Name", "", "", "" ); + CAF_PDM_InitField( &m_userLabel, "UserLabel", QString( "Template" ), "Name" ); this->setName( fullLabel() ); - CAF_PDM_InitField( &m_orificeDiameter, "OrificeDiameter", 8.0, "Orifice Diameter [mm]", "", "", "" ); - CAF_PDM_InitField( &m_flowCoefficient, "FlowCoefficient", 0.7, "Flow Coefficient", "", "", "" ); + CAF_PDM_InitField( &m_orificeDiameter, "OrificeDiameter", 8.0, "Orifice Diameter [mm]" ); + CAF_PDM_InitField( &m_flowCoefficient, "FlowCoefficient", 0.7, "Flow Coefficient" ); - CAF_PDM_InitFieldNoDefault( &m_aicdParameters, "AICDParameters", "AICD Parameters", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_aicdParameters, "AICDParameters", "AICD Parameters" ); m_aicdParameters = new RimWellPathAicdParameters; m_aicdParameters.uiCapability()->setUiTreeHidden( true ); m_aicdParameters.uiCapability()->setUiTreeChildrenHidden( true ); @@ -172,8 +169,7 @@ void RimValveTemplate::setUserLabel( const QString& userLabel ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimValveTemplate::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RimValveTemplate::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimValveTemplate.h b/ApplicationLibCode/ProjectDataModel/Completions/RimValveTemplate.h index a1713e4e0f..23d530cede 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimValveTemplate.h +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimValveTemplate.h @@ -49,8 +49,7 @@ class RimValveTemplate : public RimNamedObject void setUserLabel( const QString& userLabel ); protected: - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimValveTemplateCollection.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimValveTemplateCollection.cpp index 087d3b336b..144863bbd0 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimValveTemplateCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimValveTemplateCollection.cpp @@ -28,14 +28,9 @@ CAF_PDM_SOURCE_INIT( RimValveTemplateCollection, "ValveTemplateCollection" ); //-------------------------------------------------------------------------------------------------- RimValveTemplateCollection::RimValveTemplateCollection() { - CAF_PDM_InitObject( "Valve Templates", ":/ICDValve16x16.png", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_valveDefinitions, "ValveDefinitions", "", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_defaultUnitsForValveTemplates, - "ValveUnits", - "Default unit system for valve templates", - "", - "", - "" ); + CAF_PDM_InitObject( "Valve Templates", ":/ICDValve16x16.png" ); + CAF_PDM_InitFieldNoDefault( &m_valveDefinitions, "ValveDefinitions", "" ); + CAF_PDM_InitFieldNoDefault( &m_defaultUnitsForValveTemplates, "ValveUnits", "Default unit system for valve templates" ); m_defaultUnitsForValveTemplates = RiaDefines::EclipseUnitSystem::UNITS_METRIC; m_valveDefinitions.uiCapability()->setUiTreeHidden( true ); addDefaultValveTemplates(); @@ -74,7 +69,7 @@ void RimValveTemplateCollection::addValveTemplate( RimValveTemplate* valveTempla //-------------------------------------------------------------------------------------------------- void RimValveTemplateCollection::removeAndDeleteValveTemplate( RimValveTemplate* valveTemplate ) { - m_valveDefinitions.removeChildObject( valveTemplate ); + m_valveDefinitions.removeChild( valveTemplate ); delete valveTemplate; } diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathAicdParameters.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathAicdParameters.cpp index 2f32516afb..f1b578ab9b 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathAicdParameters.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathAicdParameters.cpp @@ -35,106 +35,64 @@ CAF_PDM_SOURCE_INIT( RimWellPathAicdParameters, "WellPathAicdParameters" ); //-------------------------------------------------------------------------------------------------- RimWellPathAicdParameters::RimWellPathAicdParameters() { - CAF_PDM_InitObject( "RimWellPathAicdParameters", "", "", "" ); + CAF_PDM_InitObject( "RimWellPathAicdParameters" ); - CAF_PDM_InitField( &m_deviceOpen, "DeviceOpen", true, "Device Open?", "", "", "" ); + CAF_PDM_InitField( &m_deviceOpen, "DeviceOpen", true, "Device Open?" ); - CAF_PDM_InitFieldNoDefault( &m_aicdParameterFields[AICD_STRENGTH], "StrengthAICD", "Strength of AICD", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_aicdParameterFields[AICD_STRENGTH], "StrengthAICD", "Strength of AICD" ); CAF_PDM_InitFieldNoDefault( &m_aicdParameterFields[AICD_DENSITY_CALIB_FLUID], "DensityCalibrationFluid", - "Calibration Fluid Density (kg/m^3)", - "", - "", - "" ); + "Calibration Fluid Density (kg/m^3)" ); CAF_PDM_InitFieldNoDefault( &m_aicdParameterFields[AICD_VISCOSITY_CALIB_FLUID], "ViscosityCalibrationFluid", - "Calibration Fluid Viscosity (cP)", - "", - "", - "" ); + "Calibration Fluid Viscosity (cP)" ); CAF_PDM_InitFieldNoDefault( &m_aicdParameterFields[AICD_VOL_FLOW_EXP], "VolumeFlowRateExponent", - "Volume Flow Rate Exponent", - "", - "", - "" ); + "Volume Flow Rate Exponent" ); CAF_PDM_InitFieldNoDefault( &m_aicdParameterFields[AICD_VISOSITY_FUNC_EXP], "ViscosityFunctionExponent", - "Viscosity Function Exponent", - "", - "", - "" ); + "Viscosity Function Exponent" ); CAF_PDM_InitField( &m_aicdParameterFields[AICD_CRITICAL_WATER_IN_LIQUID_FRAC], "CriticalWaterLiquidFractionEmul", QString( "1*" ), - "Critical Water in Liquid Fraction for emulsions", - "", - "", - "" ); + "Critical Water in Liquid Fraction for emulsions" ); CAF_PDM_InitField( &m_aicdParameterFields[AICD_EMULSION_VISC_TRANS_REGION], "ViscosityTransitionRegionEmul", QString( "1*" ), - "Emulsion Viscosity Transition Region", - "", - "", - "" ); + "Emulsion Viscosity Transition Region" ); CAF_PDM_InitField( &m_aicdParameterFields[AICD_MAX_RATIO_EMULSION_VISC], "MaxRatioOfEmulsionVisc", QString( "1*" ), - "Max Ratio of Emulsion to Continuous Viscosity", - "", - "", - "" ); + "Max Ratio of Emulsion to Continuous Viscosity" ); CAF_PDM_InitField( &m_aicdParameterFields[AICD_MAX_FLOW_RATE], "MaxFlowRate", QString( "1*" ), - "Max Flow Rate for AICD Device (m^3 / day)", - "", - "", - "" ); + "Max Flow Rate for AICD Device (m^3 / day)" ); CAF_PDM_InitField( &m_aicdParameterFields[AICD_EXP_OIL_FRAC_DENSITY], "ExponentOilDensity", QString( "1*" ), - "Density Exponent of Oil Fraction", - "", - "", - "" ); + "Density Exponent of Oil Fraction" ); CAF_PDM_InitField( &m_aicdParameterFields[AICD_EXP_WATER_FRAC_DENSITY], "ExponentWaterDensity", QString( "1*" ), - "Density Exponent of Water Fraction", - "", - "", - "" ); + "Density Exponent of Water Fraction" ); CAF_PDM_InitField( &m_aicdParameterFields[AICD_EXP_GAS_FRAC_DENSITY], "ExponentGasDensity", QString( "1*" ), - "Density Exponent of Gas Fraction", - "", - "", - "" ); + "Density Exponent of Gas Fraction" ); CAF_PDM_InitField( &m_aicdParameterFields[AICD_EXP_OIL_FRAC_VISCOSITY], "ExponentOilViscosity", QString( "1*" ), - "Viscosity Exponent of Oil Fraction", - "", - "", - "" ); + "Viscosity Exponent of Oil Fraction" ); CAF_PDM_InitField( &m_aicdParameterFields[AICD_EXP_WATER_FRAC_VISCOSITY], "ExponentWaterViscosity", QString( "1*" ), - "Viscosity Exponent of Water Fraction", - "", - "", - "" ); + "Viscosity Exponent of Water Fraction" ); CAF_PDM_InitField( &m_aicdParameterFields[AICD_EXP_GAS_FRAC_VISCOSITY], "ExponentGasViscosity", QString( "1*" ), - "Viscosity Exponent of Gas Fraction", - "", - "", - "" ); + "Viscosity Exponent of Gas Fraction" ); std::vector allFields; this->fields( allFields ); diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathCompletionSettings.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathCompletionSettings.cpp index 0a3ea14c80..ce1fc8fdca 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathCompletionSettings.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathCompletionSettings.cpp @@ -77,22 +77,22 @@ CAF_PDM_SOURCE_INIT( RimWellPathCompletionSettings, "WellPathCompletionSettings" //-------------------------------------------------------------------------------------------------- RimWellPathCompletionSettings::RimWellPathCompletionSettings() { - CAF_PDM_InitObject( "Completion Settings", ":/CompletionsSymbol16x16.png", "", "" ); - CAF_PDM_InitField( &m_wellNameForExport, "WellNameForExport", QString(), "Well Name", "", "", "" ); + CAF_PDM_InitObject( "Completion Settings", ":/CompletionsSymbol16x16.png" ); + CAF_PDM_InitField( &m_wellNameForExport, "WellNameForExport", QString(), "Well Name" ); m_wellNameForExport.uiCapability()->setUiEditorTypeName( caf::PdmUiLineEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_wellGroupName, "WellGroupNameForExport", QString(), "Well Group Name", "", "", "" ); - CAF_PDM_InitField( &m_referenceDepth, "ReferenceDepthForExport", QString(), "Reference Depth for BHP", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_preferredFluidPhase, "WellTypeForExport", "Preferred Fluid Phase", "", "", "" ); - CAF_PDM_InitField( &m_drainageRadiusForPI, "DrainageRadiusForPI", QString( "0.0" ), "Drainage Radius for PI", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_gasInflowEquation, "GasInflowEq", "Gas Inflow Equation", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_automaticWellShutIn, "AutoWellShutIn", "Automatic well shut-in", "", "", "" ); - CAF_PDM_InitField( &m_allowWellCrossFlow, "AllowWellCrossFlow", true, "Allow Well Cross-Flow", "", "", "" ); - CAF_PDM_InitField( &m_wellBoreFluidPVTTable, "WellBoreFluidPVTTable", 0, "Wellbore Fluid PVT table", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_hydrostaticDensity, "HydrostaticDensity", "Hydrostatic Density", "", "", "" ); - CAF_PDM_InitField( &m_fluidInPlaceRegion, "FluidInPlaceRegion", 0, "Fluid In-Place Region", "", "", "" ); - - CAF_PDM_InitFieldNoDefault( &m_mswParameters, "MswParameters", "Multi Segment Well Parameters", "", "", "" ); + CAF_PDM_InitField( &m_groupName, "WellGroupNameForExport", QString(), "Group Name" ); + CAF_PDM_InitField( &m_referenceDepth, "ReferenceDepthForExport", QString(), "Reference Depth for BHP" ); + CAF_PDM_InitFieldNoDefault( &m_preferredFluidPhase, "WellTypeForExport", "Preferred Fluid Phase" ); + CAF_PDM_InitField( &m_drainageRadiusForPI, "DrainageRadiusForPI", QString( "0.0" ), "Drainage Radius for PI" ); + CAF_PDM_InitFieldNoDefault( &m_gasInflowEquation, "GasInflowEq", "Gas Inflow Equation" ); + CAF_PDM_InitFieldNoDefault( &m_automaticWellShutIn, "AutoWellShutIn", "Automatic well shut-in" ); + CAF_PDM_InitField( &m_allowWellCrossFlow, "AllowWellCrossFlow", true, "Allow Well Cross-Flow" ); + CAF_PDM_InitField( &m_wellBoreFluidPVTTable, "WellBoreFluidPVTTable", 0, "Wellbore Fluid PVT table" ); + CAF_PDM_InitFieldNoDefault( &m_hydrostaticDensity, "HydrostaticDensity", "Hydrostatic Density" ); + CAF_PDM_InitField( &m_fluidInPlaceRegion, "FluidInPlaceRegion", 0, "Fluid In-Place Region" ); + + CAF_PDM_InitFieldNoDefault( &m_mswParameters, "MswParameters", "Multi Segment Well Parameters" ); m_mswParameters = new RimMswCompletionParameters; m_mswParameters.uiCapability()->setUiTreeHidden( true ); m_mswParameters.uiCapability()->setUiTreeChildrenHidden( true ); @@ -113,7 +113,7 @@ RimWellPathCompletionSettings::RimWellPathCompletionSettings( const RimWellPathC RimWellPathCompletionSettings& RimWellPathCompletionSettings::operator=( const RimWellPathCompletionSettings& rhs ) { m_wellNameForExport = rhs.m_wellNameForExport; - m_wellGroupName = rhs.m_wellGroupName; + m_groupName = rhs.m_groupName; m_referenceDepth = rhs.m_referenceDepth; m_preferredFluidPhase = rhs.m_preferredFluidPhase; m_drainageRadiusForPI = rhs.m_drainageRadiusForPI; @@ -158,9 +158,9 @@ QString RimWellPathCompletionSettings::wellNameForExport() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimWellPathCompletionSettings::wellGroupNameForExport() const +QString RimWellPathCompletionSettings::groupNameForExport() const { - return formatStringForExport( m_wellGroupName, "1*" ); + return formatStringForExport( m_groupName, "1*" ); } //-------------------------------------------------------------------------------------------------- @@ -280,7 +280,7 @@ void RimWellPathCompletionSettings::defineUiOrdering( QString uiConfigName, caf: { caf::PdmUiGroup* compExportGroup = uiOrdering.addNewGroup( "Completion Export Parameters" ); compExportGroup->add( &m_wellNameForExport ); - compExportGroup->add( &m_wellGroupName ); + compExportGroup->add( &m_groupName ); compExportGroup->add( &m_referenceDepth ); compExportGroup->add( &m_preferredFluidPhase ); compExportGroup->add( &m_drainageRadiusForPI ); diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathCompletionSettings.h b/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathCompletionSettings.h index b8d1b66588..07f4c1a25d 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathCompletionSettings.h +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathCompletionSettings.h @@ -69,7 +69,7 @@ class RimWellPathCompletionSettings : public caf::PdmObject void setWellNameForExport( const QString& name ); void updateWellPathNameHasChanged( const QString& newWellPathName, const QString& previousWellPathName ); QString wellNameForExport() const; - QString wellGroupNameForExport() const; + QString groupNameForExport() const; QString referenceDepthForExport() const; QString wellTypeNameForExport() const; @@ -99,7 +99,7 @@ class RimWellPathCompletionSettings : public caf::PdmObject friend class RimWellPathCompletions; caf::PdmField m_wellNameForExport; - caf::PdmField m_wellGroupName; + caf::PdmField m_groupName; caf::PdmField m_referenceDepth; caf::PdmField m_preferredFluidPhase; diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathCompletions.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathCompletions.cpp index 7cd6bada20..8ad50eb8df 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathCompletions.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathCompletions.cpp @@ -49,51 +49,45 @@ CAF_PDM_SOURCE_INIT( RimWellPathCompletions, "WellPathCompletions" ); //-------------------------------------------------------------------------------------------------- RimWellPathCompletions::RimWellPathCompletions() { - CAF_PDM_InitObject( "Completions", ":/CompletionsSymbol16x16.png", "", "" ); + CAF_PDM_InitObject( "Completions", ":/CompletionsSymbol16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_perforationCollection, "Perforations", "Perforations", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_perforationCollection, "Perforations", "Perforations" ); m_perforationCollection = new RimPerforationCollection; m_perforationCollection.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_fishbonesCollection, "Fishbones", "Fishbones", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_fishbonesCollection, "Fishbones", "Fishbones" ); m_fishbonesCollection = new RimFishbonesCollection; m_fishbonesCollection.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_fractureCollection, "Fractures", "Fractures", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_fractureCollection, "Fractures", "Fractures" ); m_fractureCollection = new RimWellPathFractureCollection; m_fractureCollection.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_stimPlanModelCollection, "StimPlanModels", "StimPlan Models", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_stimPlanModelCollection, "StimPlanModels", "StimPlan Models" ); m_stimPlanModelCollection = new RimStimPlanModelCollection; m_stimPlanModelCollection.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitField( &m_wellNameForExport_OBSOLETE, "WellNameForExport", QString(), "Well Name", "", "", "" ); + CAF_PDM_InitField( &m_wellNameForExport_OBSOLETE, "WellNameForExport", QString(), "Well Name" ); m_wellNameForExport_OBSOLETE.xmlCapability()->setIOWritable( false ); - CAF_PDM_InitField( &m_wellGroupName_OBSOLETE, "WellGroupNameForExport", QString(), "Well Group Name", "", "", "" ); + CAF_PDM_InitField( &m_wellGroupName_OBSOLETE, "WellGroupNameForExport", QString(), "Well Group Name" ); m_wellGroupName_OBSOLETE.xmlCapability()->setIOWritable( false ); - CAF_PDM_InitField( &m_referenceDepth_OBSOLETE, "ReferenceDepthForExport", QString(), "Reference Depth for BHP", "", "", "" ); + CAF_PDM_InitField( &m_referenceDepth_OBSOLETE, "ReferenceDepthForExport", QString(), "Reference Depth for BHP" ); m_referenceDepth_OBSOLETE.xmlCapability()->setIOWritable( false ); - CAF_PDM_InitFieldNoDefault( &m_preferredFluidPhase_OBSOLETE, "WellTypeForExport", "Preferred Fluid Phase", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_preferredFluidPhase_OBSOLETE, "WellTypeForExport", "Preferred Fluid Phase" ); m_preferredFluidPhase_OBSOLETE.xmlCapability()->setIOWritable( false ); - CAF_PDM_InitField( &m_drainageRadiusForPI_OBSOLETE, - "DrainageRadiusForPI", - QString( "0.0" ), - "Drainage Radius for PI", - "", - "", - "" ); + CAF_PDM_InitField( &m_drainageRadiusForPI_OBSOLETE, "DrainageRadiusForPI", QString( "0.0" ), "Drainage Radius for PI" ); m_drainageRadiusForPI_OBSOLETE.xmlCapability()->setIOWritable( false ); - CAF_PDM_InitFieldNoDefault( &m_gasInflowEquation_OBSOLETE, "GasInflowEq", "Gas Inflow Equation", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_gasInflowEquation_OBSOLETE, "GasInflowEq", "Gas Inflow Equation" ); m_gasInflowEquation_OBSOLETE.xmlCapability()->setIOWritable( false ); - CAF_PDM_InitFieldNoDefault( &m_automaticWellShutIn_OBSOLETE, "AutoWellShutIn", "Automatic well shut-in", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_automaticWellShutIn_OBSOLETE, "AutoWellShutIn", "Automatic well shut-in" ); m_automaticWellShutIn_OBSOLETE.xmlCapability()->setIOWritable( false ); - CAF_PDM_InitField( &m_allowWellCrossFlow_OBSOLETE, "AllowWellCrossFlow", true, "Allow Well Cross-Flow", "", "", "" ); + CAF_PDM_InitField( &m_allowWellCrossFlow_OBSOLETE, "AllowWellCrossFlow", true, "Allow Well Cross-Flow" ); m_allowWellCrossFlow_OBSOLETE.xmlCapability()->setIOWritable( false ); - CAF_PDM_InitField( &m_wellBoreFluidPVTTable_OBSOLETE, "WellBoreFluidPVTTable", 0, "Wellbore Fluid PVT table", "", "", "" ); + CAF_PDM_InitField( &m_wellBoreFluidPVTTable_OBSOLETE, "WellBoreFluidPVTTable", 0, "Wellbore Fluid PVT table" ); m_wellBoreFluidPVTTable_OBSOLETE.xmlCapability()->setIOWritable( false ); - CAF_PDM_InitFieldNoDefault( &m_hydrostaticDensity_OBSOLETE, "HydrostaticDensity", "Hydrostatic Density", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_hydrostaticDensity_OBSOLETE, "HydrostaticDensity", "Hydrostatic Density" ); m_hydrostaticDensity_OBSOLETE.xmlCapability()->setIOWritable( false ); - CAF_PDM_InitField( &m_fluidInPlaceRegion_OBSOLETE, "FluidInPlaceRegion", 0, "Fluid In-Place Region", "", "", "" ); + CAF_PDM_InitField( &m_fluidInPlaceRegion_OBSOLETE, "FluidInPlaceRegion", 0, "Fluid In-Place Region" ); m_fluidInPlaceRegion_OBSOLETE.xmlCapability()->setIOWritable( false ); } diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathFracture.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathFracture.cpp index 8fe6f71d90..48d4cf7945 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathFracture.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathFracture.cpp @@ -35,9 +35,9 @@ CAF_PDM_SOURCE_INIT( RimWellPathFracture, "WellPathFracture" ); //-------------------------------------------------------------------------------------------------- RimWellPathFracture::RimWellPathFracture( void ) { - CAF_PDM_InitObject( "Fracture", ":/FractureSymbol16x16.png", "", "" ); + CAF_PDM_InitObject( "Fracture", ":/FractureSymbol16x16.png" ); - CAF_PDM_InitField( &m_measuredDepth, "MeasuredDepth", 0.0f, "Measured Depth Location", "", "", "" ); + CAF_PDM_InitField( &m_measuredDepth, "MeasuredDepth", 0.0f, "Measured Depth Location" ); m_measuredDepth.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); setDeletable( true ); @@ -134,6 +134,43 @@ double RimWellPathFracture::wellAzimuthAtFracturePosition() const return wellPathAzimuth; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec3d RimWellPathFracture::computeFractureDirectionNormal() const +{ + RimWellPath* wellPath = nullptr; + this->firstAncestorOrThisOfType( wellPath ); + if ( !wellPath ) return cvf::Vec3d::UNDEFINED; + + RigWellPath* wellPathGeometry = wellPath->wellPathGeometry(); + + // Find the well path points closest to the anchor position + cvf::Vec3d p1; + cvf::Vec3d p2; + wellPathGeometry->twoClosestPoints( fracturePosition(), &p1, &p2 ); + + // Create a well direction based on the two points + cvf::Vec3d wellDirection = ( p2 - p1 ).getNormalized(); + + cvf::Vec3d fractureDirectionNormal = wellDirection; + if ( fractureTemplate()->orientationType() == RimFractureTemplate::ALONG_WELL_PATH ) + { + cvf::Mat3d azimuthRotation = cvf::Mat3d::fromRotation( cvf::Vec3d::Z_AXIS, cvf::Math::toRadians( 90.0 ) ); + fractureDirectionNormal.transformVector( azimuthRotation ); + } + else if ( fractureTemplate()->orientationType() == RimFractureTemplate::AZIMUTH ) + { + // Azimuth angle of fracture is relative to north. + double wellAzimuth = wellPathGeometry->wellPathAzimuthAngle( fracturePosition() ); + cvf::Mat3d azimuthRotation = + cvf::Mat3d::fromRotation( cvf::Vec3d::Z_AXIS, cvf::Math::toRadians( wellAzimuth - m_azimuth - 90.0 ) ); + fractureDirectionNormal.transformVector( azimuthRotation ); + } + + return fractureDirectionNormal; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathFracture.h b/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathFracture.h index b90a1b8ca9..30b95ea0fa 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathFracture.h +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathFracture.h @@ -42,8 +42,9 @@ class RimWellPathFracture : public RimFracture double fractureMD() const override; void setMeasuredDepth( double mdValue ); - void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - void updateAzimuthBasedOnWellAzimuthAngle() override; + void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; + void updateAzimuthBasedOnWellAzimuthAngle() override; + cvf::Vec3d computeFractureDirectionNormal() const; double wellAzimuthAtFracturePosition() const override; diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathFractureCollection.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathFractureCollection.cpp index e1cd281aea..faf3eaefb3 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathFractureCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathFractureCollection.cpp @@ -30,9 +30,9 @@ CAF_PDM_SOURCE_INIT( RimWellPathFractureCollection, "WellPathFractureCollection" //-------------------------------------------------------------------------------------------------- RimWellPathFractureCollection::RimWellPathFractureCollection( void ) { - CAF_PDM_InitObject( "Fractures", ":/FractureLayout16x16.png", "", "" ); + CAF_PDM_InitObject( "Fractures", ":/FractureLayout16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_fractures, "Fractures", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_fractures, "Fractures", "" ); m_fractures.uiCapability()->setUiTreeHidden( true ); setName( "Fractures" ); @@ -64,12 +64,20 @@ void RimWellPathFractureCollection::addFracture( RimWellPathFracture* fracture ) m_fractures.push_back( fracture ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellPathFractureCollection::removeFracture( RimWellPathFracture* fracture ) +{ + m_fractures.removeChild( fracture ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimWellPathFractureCollection::deleteFractures() { - m_fractures.deleteAllChildObjects(); + m_fractures.deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -77,7 +85,7 @@ void RimWellPathFractureCollection::deleteFractures() //-------------------------------------------------------------------------------------------------- std::vector RimWellPathFractureCollection::allFractures() const { - return m_fractures.childObjects(); + return m_fractures.children(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathFractureCollection.h b/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathFractureCollection.h index 054e484b7b..10fdc4783a 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathFractureCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathFractureCollection.h @@ -43,6 +43,7 @@ class RimWellPathFractureCollection : public RimCheckableNamedObject bool hasFractures() const; void addFracture( RimWellPathFracture* fracture ); + void removeFracture( RimWellPathFracture* fracture ); void deleteFractures(); std::vector allFractures() const; diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathValve.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathValve.cpp index 4ec0e90752..350abf8678 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathValve.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathValve.cpp @@ -44,13 +44,13 @@ CAF_PDM_SOURCE_INIT( RimWellPathValve, "WellPathValve" ); //-------------------------------------------------------------------------------------------------- RimWellPathValve::RimWellPathValve() { - CAF_PDM_InitObject( "WellPathValve", ":/ICDValve16x16.png", "", "" ); + CAF_PDM_InitObject( "WellPathValve", ":/ICDValve16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_valveTemplate, "ValveTemplate", "Valve Template", "", "", "" ); - CAF_PDM_InitField( &m_measuredDepth, "StartMeasuredDepth", 0.0, "Start MD", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_multipleValveLocations, "ValveLocations", "Valve Locations", "", "", "" ); - CAF_PDM_InitField( &m_editValveTemplate, "EditTemplate", false, "Edit", "", "", "" ); - CAF_PDM_InitField( &m_createValveTemplate, "CreateTemplate", false, "Create", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_valveTemplate, "ValveTemplate", "Valve Template" ); + CAF_PDM_InitField( &m_measuredDepth, "StartMeasuredDepth", 0.0, "Start MD" ); + CAF_PDM_InitFieldNoDefault( &m_multipleValveLocations, "ValveLocations", "Valve Locations" ); + CAF_PDM_InitField( &m_editValveTemplate, "EditTemplate", false, "Edit" ); + CAF_PDM_InitField( &m_createValveTemplate, "CreateTemplate", false, "Create" ); m_measuredDepth.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); m_multipleValveLocations = new RimMultipleValveLocations; @@ -461,8 +461,7 @@ void RimWellPathValve::templateUpdated() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimWellPathValve::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RimWellPathValve::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathValve.h b/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathValve.h index 3b8dc9cc62..bbb7f5f7e4 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathValve.h +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathValve.h @@ -80,8 +80,7 @@ class RimWellPathValve : public RimCheckableNamedObject, public RimWellPathCompo void templateUpdated(); private: - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineEditorAttribute( const caf::PdmFieldHandle* field, diff --git a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimAbstractCorrelationPlot.cpp b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimAbstractCorrelationPlot.cpp index fa23d13bbd..3f7ebbb600 100644 --- a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimAbstractCorrelationPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimAbstractCorrelationPlot.cpp @@ -42,6 +42,8 @@ #include "cafPdmUiPushButtonEditor.h" #include "cafPdmUiToolButtonEditor.h" +#include "qwt_plot.h" + CAF_PDM_ABSTRACT_SOURCE_INIT( RimAbstractCorrelationPlot, "AbstractCorrelationPlot" ); //-------------------------------------------------------------------------------------------------- @@ -50,43 +52,43 @@ CAF_PDM_ABSTRACT_SOURCE_INIT( RimAbstractCorrelationPlot, "AbstractCorrelationPl RimAbstractCorrelationPlot::RimAbstractCorrelationPlot() : m_selectMultipleVectors( false ) { - CAF_PDM_InitObject( "Abstract Correlation Plot", ":/CorrelationPlot16x16.png", "", "" ); + CAF_PDM_InitObject( "Abstract Correlation Plot", ":/CorrelationPlot16x16.png" ); this->setDeletable( true ); - CAF_PDM_InitFieldNoDefault( &m_selectedVarsUiField, "SelectedVariableDisplayVar", "Vector", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_selectedVarsUiField, "SelectedVariableDisplayVar", "Vector" ); m_selectedVarsUiField.xmlCapability()->disableIO(); m_selectedVarsUiField.uiCapability()->setUiReadOnly( true ); m_selectedVarsUiField.uiCapability()->setUiEditorTypeName( caf::PdmUiLineEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_dataSources, "AnalysisPlotData", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_dataSources, "AnalysisPlotData", "" ); m_dataSources.uiCapability()->setUiTreeChildrenHidden( true ); m_dataSources.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_pushButtonSelectSummaryAddress, "SelectAddress", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_pushButtonSelectSummaryAddress, "SelectAddress", "" ); caf::PdmUiPushButtonEditor::configureEditorForField( &m_pushButtonSelectSummaryAddress ); m_pushButtonSelectSummaryAddress.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); m_pushButtonSelectSummaryAddress = false; - CAF_PDM_InitFieldNoDefault( &m_timeStepFilter, "TimeStepFilter", "Available Time Steps", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_timeStepFilter, "TimeStepFilter", "Available Time Steps" ); - CAF_PDM_InitFieldNoDefault( &m_timeStep, "TimeStep", "Time Step", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_timeStep, "TimeStep", "Time Step" ); m_timeStep.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_useAutoPlotTitle, "AutoTitle", true, "Automatic Plot Title", "", "", "" ); - CAF_PDM_InitField( &m_description, "PlotTitle", QString( "Correlation Plot" ), "Custom Plot Title", "", "", "" ); + CAF_PDM_InitField( &m_useAutoPlotTitle, "AutoTitle", true, "Automatic Plot Title" ); + CAF_PDM_InitField( &m_description, "PlotTitle", QString( "Correlation Plot" ), "Custom Plot Title" ); - CAF_PDM_InitFieldNoDefault( &m_labelFontSize, "LabelFontSize", "Label Font Size", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_labelFontSize, "LabelFontSize", "Label Font Size" ); m_labelFontSize = caf::FontTools::RelativeSize::XSmall; - CAF_PDM_InitFieldNoDefault( &m_axisTitleFontSize, "AxisTitleFontSize", "Axis Title Font Size", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_axisValueFontSize, "AxisValueFontSize", "Axis Value Font Size", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_axisTitleFontSize, "AxisTitleFontSize", "Axis Title Font Size" ); + CAF_PDM_InitFieldNoDefault( &m_axisValueFontSize, "AxisValueFontSize", "Axis Value Font Size" ); m_axisValueFontSize = caf::FontTools::RelativeSize::XSmall; m_legendFontSize = caf::FontTools::RelativeSize::XSmall; - CAF_PDM_InitField( &m_useCaseFilter, "UseCaseFilter", false, "Use Ensemble Filter", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_curveSetForFiltering, "CurveSetForFiltering", " Ensemble Filter", "", "", "" ); - CAF_PDM_InitField( &m_editCaseFilter, "EditCaseFilter", false, "Edit", "", "", "" ); + CAF_PDM_InitField( &m_useCaseFilter, "UseCaseFilter", false, "Use Ensemble Filter" ); + CAF_PDM_InitFieldNoDefault( &m_curveSetForFiltering, "CurveSetForFiltering", " Ensemble Filter" ); + CAF_PDM_InitField( &m_editCaseFilter, "EditCaseFilter", false, "Edit" ); m_editCaseFilter.uiCapability()->setUiEditorTypeName( caf::PdmUiToolButtonEditor::uiEditorTypeName() ); m_editCaseFilter.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); } @@ -103,7 +105,7 @@ RimAbstractCorrelationPlot::~RimAbstractCorrelationPlot() //-------------------------------------------------------------------------------------------------- void RimAbstractCorrelationPlot::setCurveDefinitions( const std::vector& curveDefinitions ) { - m_dataSources.deleteAllChildObjects(); + m_dataSources.deleteChildren(); for ( auto curveDef : curveDefinitions ) { auto dataEntry = new RimAnalysisPlotDataEntry(); @@ -153,7 +155,7 @@ void RimAbstractCorrelationPlot::fieldChangedByUi( const caf::PdmFieldHandle* ch if ( !curveSelection.empty() ) { std::vector summaryVectorDefinitions = dlg.curveSelection(); - m_dataSources.deleteAllChildObjects(); + m_dataSources.deleteChildren(); for ( const RiaSummaryCurveDefinition& vectorDef : summaryVectorDefinitions ) { auto plotEntry = new RimAnalysisPlotDataEntry(); @@ -251,9 +253,9 @@ caf::PdmFieldHandle* RimAbstractCorrelationPlot::userDescriptionField() /// //-------------------------------------------------------------------------------------------------- QList - RimAbstractCorrelationPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) + RimAbstractCorrelationPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { - QList options = RimPlot::calculateValueOptions( fieldNeedingOptions, useOptionsOnly ); + QList options = RimPlot::calculateValueOptions( fieldNeedingOptions ); if ( fieldNeedingOptions == &m_timeStep ) { @@ -273,11 +275,12 @@ QList std::vector filteredTimeStepIndices = RimTimeStepFilter::filteredTimeStepIndices( allDateTimes, 0, (int)allDateTimes.size() - 1, m_timeStepFilter(), 1 ); - QString dateFormatString = RiaQDateTimeTools::dateFormatString( RiaPreferences::current()->dateFormat(), - RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH_DAY ); + QString dateFormatString = + RiaQDateTimeTools::dateFormatString( RiaPreferences::current()->dateFormat(), + RiaDefines::DateFormatComponents::DATE_FORMAT_YEAR_MONTH_DAY ); QString timeFormatString = RiaQDateTimeTools::timeFormatString( RiaPreferences::current()->timeFormat(), - RiaQDateTimeTools::TimeFormatComponents::TIME_FORMAT_HOUR_MINUTE ); + RiaDefines::TimeFormatComponents::TIME_FORMAT_HOUR_MINUTE ); QString dateTimeFormatString = QString( "%1 %2" ).arg( dateFormatString ).arg( timeFormatString ); bool showTime = m_timeStepFilter == RimTimeStepFilter::TS_ALL || RimTimeStepFilter::TS_INTERVAL_DAYS; @@ -557,7 +560,7 @@ QString RimAbstractCorrelationPlot::description() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuQwtPlotWidget* RimAbstractCorrelationPlot::doCreatePlotViewWidget( QWidget* mainWindowParent /*= nullptr */ ) +RiuPlotWidget* RimAbstractCorrelationPlot::doCreatePlotViewWidget( QWidget* mainWindowParent /*= nullptr */ ) { if ( !m_plotWidget ) { @@ -576,12 +579,20 @@ RiuQwtPlotWidget* RimAbstractCorrelationPlot::viewer() return m_plotWidget; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuPlotWidget* RimAbstractCorrelationPlot::plotWidget() +{ + return m_plotWidget; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimAbstractCorrelationPlot::detachAllCurves() { - if ( m_plotWidget ) m_plotWidget->detachItems(); + if ( m_plotWidget ) m_plotWidget->qwtPlot()->detachItems(); } //-------------------------------------------------------------------------------------------------- @@ -597,11 +608,12 @@ QDateTime RimAbstractCorrelationPlot::timeStep() const //-------------------------------------------------------------------------------------------------- QString RimAbstractCorrelationPlot::timeStepString() const { - QString dateFormatString = RiaQDateTimeTools::dateFormatString( RiaPreferences::current()->dateFormat(), - RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH_DAY ); + QString dateFormatString = + RiaQDateTimeTools::dateFormatString( RiaPreferences::current()->dateFormat(), + RiaDefines::DateFormatComponents::DATE_FORMAT_YEAR_MONTH_DAY ); QString timeFormatString = RiaQDateTimeTools::timeFormatString( RiaPreferences::current()->timeFormat(), - RiaQDateTimeTools::TimeFormatComponents::TIME_FORMAT_HOUR_MINUTE ); + RiaDefines::TimeFormatComponents::TIME_FORMAT_HOUR_MINUTE ); return timeStep().toString( dateFormatString ) + " " + timeStep().toString( timeFormatString ); } @@ -661,7 +673,7 @@ void RimAbstractCorrelationPlot::updateLegend() { if ( m_plotWidget ) { - m_plotWidget->insertLegend( nullptr ); + m_plotWidget->qwtPlot()->insertLegend( nullptr ); } } @@ -695,10 +707,10 @@ time_t RimAbstractCorrelationPlot::timeDiff( time_t lhs, time_t rhs ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimAbstractCorrelationPlot::selectedQuantitiesText() +QString RimAbstractCorrelationPlot::selectedVectorNamesText() { QString vectorNames; - for ( const std::string& quantityName : getOrCreateSelectedCurveDefAnalyser()->m_quantityNames ) + for ( const std::string& quantityName : getOrCreateSelectedCurveDefAnalyser()->m_vectorNames ) { vectorNames += QString::fromStdString( quantityName ) + ", "; } @@ -746,7 +758,7 @@ void RimAbstractCorrelationPlot::appendDataSourceFields( QString uiConfigName, c { caf::PdmUiGroup* curveDataGroup = uiOrdering.addNewGroup( "Summary Vector" ); - m_selectedVarsUiField = selectedQuantitiesText(); + m_selectedVarsUiField = selectedVectorNamesText(); curveDataGroup->add( &m_selectedVarsUiField ); curveDataGroup->add( &m_pushButtonSelectSummaryAddress, { false, 1, 0 } ); diff --git a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimAbstractCorrelationPlot.h b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimAbstractCorrelationPlot.h index 665ac9920e..98b18f687a 100644 --- a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimAbstractCorrelationPlot.h +++ b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimAbstractCorrelationPlot.h @@ -61,7 +61,8 @@ class RimAbstractCorrelationPlot : public RimPlot RimEnsembleCurveSet* caseFilterDataSource() const; void setCaseFilterDataSource( RimEnsembleCurveSet* ensemble ); - RiuQwtPlotWidget* viewer() override; + RiuQwtPlotWidget* viewer(); + RiuPlotWidget* plotWidget() override; void detachAllCurves() override; QDateTime timeStep() const; QString timeStepString() const; @@ -84,8 +85,7 @@ class RimAbstractCorrelationPlot : public RimPlot caf::PdmUiEditorAttribute* attribute ) override; caf::PdmFieldHandle* userDescriptionField() override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; std::set addresses(); std::set ensembleParameters(); @@ -103,24 +103,21 @@ class RimAbstractCorrelationPlot : public RimPlot void doUpdateLayout() override {} // RimPlot Overrides - RiuQwtPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent = nullptr ) override; + RiuPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent = nullptr ) override; void reattachAllCurves() override {} - void updateZoomInQwt() override {} - void updateZoomFromQwt() override {} void setAutoScaleXEnabled( bool enabled ) override {} void setAutoScaleYEnabled( bool enabled ) override {} void updateLegend() override; - QString asciiDataForPlotExport() const override { return ""; } - caf::PdmObject* findPdmObjectFromQwtCurve( const QwtPlotCurve* curve ) const override { return nullptr; } + QString asciiDataForPlotExport() const override { return ""; } void cleanupBeforeClose(); virtual void updatePlotTitle() = 0; static time_t timeDiff( time_t lhs, time_t rhs ); - QString selectedQuantitiesText(); + QString selectedVectorNamesText(); QString completeAddressText(); void initAfterRead() final; diff --git a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationMatrixPlot.cpp b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationMatrixPlot.cpp index c18f39d799..f0782faaaf 100644 --- a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationMatrixPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationMatrixPlot.cpp @@ -25,6 +25,7 @@ #include "RiaSummaryCurveDefinition.h" #include "RiuPlotMainWindowTools.h" #include "RiuQwtLinearScaleEngine.h" +#include "RiuQwtPlotItem.h" #include "RiuQwtPlotTools.h" #include "RiuQwtPlotWidget.h" @@ -153,22 +154,19 @@ RimCorrelationMatrixPlot::RimCorrelationMatrixPlot() : RimAbstractCorrelationPlot() , matrixCellSelected( this ) { - CAF_PDM_InitObject( "Correlation Plot", ":/CorrelationMatrixPlot16x16.png", "", "" ); + CAF_PDM_InitObject( "Correlation Plot", ":/CorrelationMatrixPlot16x16.png" ); - CAF_PDM_InitField( &m_showAbsoluteValues, "CorrelationAbsValues", false, "Show Absolute Values", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_sortByValues, "CorrelationSorting", "Sort Matrix by Values", "", "", "" ); - CAF_PDM_InitField( &m_sortByAbsoluteValues, "CorrelationAbsSorting", true, "Sort by Absolute Values", "", "", "" ); + CAF_PDM_InitField( &m_showAbsoluteValues, "CorrelationAbsValues", false, "Show Absolute Values" ); + CAF_PDM_InitFieldNoDefault( &m_sortByValues, "CorrelationSorting", "Sort Matrix by Values" ); + CAF_PDM_InitField( &m_sortByAbsoluteValues, "CorrelationAbsSorting", true, "Sort by Absolute Values" ); CAF_PDM_InitField( &m_excludeParametersWithoutVariation, "ExcludeParamsWithoutVariation", true, - "Exclude Parameters Without Variation", - "", - "", - "" ); - CAF_PDM_InitField( &m_showOnlyTopNCorrelations, "ShowOnlyTopNCorrelations", true, "Show Only Top Correlations", "", "", "" ); - CAF_PDM_InitField( &m_topNFilterCount, "TopNFilterCount", 20, "Number rows/columns", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_legendConfig, "LegendConfig", "", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_selectedParametersList, "SelectedParameters", "Select Parameters", "", "", "" ); + "Exclude Parameters Without Variation" ); + CAF_PDM_InitField( &m_showOnlyTopNCorrelations, "ShowOnlyTopNCorrelations", true, "Show Only Top Correlations" ); + CAF_PDM_InitField( &m_topNFilterCount, "TopNFilterCount", 20, "Number rows/columns" ); + CAF_PDM_InitFieldNoDefault( &m_legendConfig, "LegendConfig", "" ); + CAF_PDM_InitFieldNoDefault( &m_selectedParametersList, "SelectedParameters", "Select Parameters" ); m_selectedParametersList.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); m_selectedParametersList.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); @@ -341,11 +339,9 @@ void RimCorrelationMatrixPlot::defineUiOrdering( QString uiConfigName, caf::PdmU //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList - RimCorrelationMatrixPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) +QList RimCorrelationMatrixPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { - QList options = - RimAbstractCorrelationPlot::calculateValueOptions( fieldNeedingOptions, useOptionsOnly ); + QList options = RimAbstractCorrelationPlot::calculateValueOptions( fieldNeedingOptions ); if ( fieldNeedingOptions == &m_selectedParametersList ) { @@ -368,18 +364,18 @@ void RimCorrelationMatrixPlot::onLoadDataAndUpdate() { updateMdiWindowVisibility(); - m_selectedVarsUiField = selectedQuantitiesText(); + m_selectedVarsUiField = selectedVectorNamesText(); if ( m_plotWidget ) { - m_plotWidget->detachItems( QwtPlotItem::Rtti_PlotBarChart ); - m_plotWidget->detachItems( QwtPlotItem::Rtti_PlotScale ); - m_plotWidget->detachItems( QwtPlotItem::Rtti_PlotItem ); + m_plotWidget->qwtPlot()->detachItems( QwtPlotItem::Rtti_PlotBarChart ); + m_plotWidget->qwtPlot()->detachItems( QwtPlotItem::Rtti_PlotScale ); + m_plotWidget->qwtPlot()->detachItems( QwtPlotItem::Rtti_PlotItem ); updateLegend(); createMatrix(); - m_plotWidget->insertLegend( nullptr ); + m_plotWidget->qwtPlot()->insertLegend( nullptr ); this->updateAxes(); this->updatePlotTitle(); @@ -402,14 +398,18 @@ void RimCorrelationMatrixPlot::updateAxes() { if ( !m_plotWidget ) return; - m_plotWidget->setAxisScaleDraw( QwtPlot::yLeft, new TextScaleDraw( m_resultLabels ) ); - m_plotWidget->setAxisScaleEngine( QwtPlot::yLeft, new RiuQwtLinearScaleEngine ); - m_plotWidget->setAxisTitleText( QwtPlot::yLeft, "Result Vector" ); - m_plotWidget->setAxisTitleEnabled( QwtPlot::yLeft, true ); - m_plotWidget->setAxisFontsAndAlignment( QwtPlot::yLeft, axisTitleFontSize(), axisValueFontSize(), false, Qt::AlignCenter ); - m_plotWidget->setAxisLabelsAndTicksEnabled( QwtPlot::yLeft, true, false ); - m_plotWidget->setAxisRange( QwtPlot::yLeft, 0.0, (double)m_resultLabels.size() + 1 ); - m_plotWidget->setMajorAndMinorTickIntervalsAndRange( QwtPlot::yLeft, + m_plotWidget->qwtPlot()->setAxisScaleDraw( QwtAxis::YLeft, new TextScaleDraw( m_resultLabels ) ); + m_plotWidget->qwtPlot()->setAxisScaleEngine( QwtAxis::YLeft, new RiuQwtLinearScaleEngine ); + m_plotWidget->setAxisTitleText( RiuPlotAxis::defaultLeft(), "Result Vector" ); + m_plotWidget->setAxisTitleEnabled( RiuPlotAxis::defaultLeft(), true ); + m_plotWidget->setAxisFontsAndAlignment( RiuPlotAxis::defaultLeft(), + axisTitleFontSize(), + axisValueFontSize(), + false, + Qt::AlignCenter ); + m_plotWidget->setAxisLabelsAndTicksEnabled( RiuPlotAxis::defaultLeft(), true, false ); + m_plotWidget->setAxisRange( RiuPlotAxis::defaultLeft(), 0.0, (double)m_resultLabels.size() + 1 ); + m_plotWidget->setMajorAndMinorTickIntervalsAndRange( RiuPlotAxis::defaultLeft(), 1.0, 0.0, 0.5, @@ -419,19 +419,18 @@ void RimCorrelationMatrixPlot::updateAxes() auto scaleDraw = new TextScaleDraw( m_paramLabels ); scaleDraw->setLabelRotation( 30.0 ); - m_plotWidget->setAxisScaleDraw( QwtPlot::xBottom, scaleDraw ); - - m_plotWidget->setAxisScaleEngine( QwtPlot::xBottom, new RiuQwtLinearScaleEngine ); - m_plotWidget->setAxisTitleText( QwtPlot::xBottom, "Ensemble Parameter" ); - m_plotWidget->setAxisTitleEnabled( QwtPlot::xBottom, true ); - m_plotWidget->setAxisFontsAndAlignment( QwtPlot::xBottom, + m_plotWidget->qwtPlot()->setAxisScaleDraw( QwtAxis::XBottom, scaleDraw ); + m_plotWidget->qwtPlot()->setAxisScaleEngine( QwtAxis::XBottom, new RiuQwtLinearScaleEngine ); + m_plotWidget->setAxisTitleText( RiuPlotAxis::defaultBottom(), "Ensemble Parameter" ); + m_plotWidget->setAxisTitleEnabled( RiuPlotAxis::defaultBottom(), true ); + m_plotWidget->setAxisFontsAndAlignment( RiuPlotAxis::defaultBottom(), axisTitleFontSize(), axisValueFontSize(), false, Qt::AlignCenter | Qt::AlignTop ); - m_plotWidget->setAxisLabelsAndTicksEnabled( QwtPlot::xBottom, true, false ); - m_plotWidget->setAxisRange( QwtPlot::xBottom, 0.0, (double)m_paramLabels.size() + 1 ); - m_plotWidget->setMajorAndMinorTickIntervalsAndRange( QwtPlot::xBottom, + m_plotWidget->setAxisLabelsAndTicksEnabled( RiuPlotAxis::defaultBottom(), true, false ); + m_plotWidget->setAxisRange( RiuPlotAxis::defaultBottom(), 0.0, (double)m_paramLabels.size() + 1 ); + m_plotWidget->setMajorAndMinorTickIntervalsAndRange( RiuPlotAxis::defaultBottom(), 1.0, 0.0, 0.5, @@ -439,7 +438,7 @@ void RimCorrelationMatrixPlot::updateAxes() 0.0, (double)m_paramLabels.size() ); - m_plotWidget->setAxisLabelAlignment( QwtPlot::xBottom, Qt::AlignRight ); + m_plotWidget->qwtPlot()->setAxisLabelAlignment( QwtAxis::XBottom, Qt::AlignRight ); } template @@ -639,8 +638,8 @@ void RimCorrelationMatrixPlot::createMatrix() marker->setLabel( textLabel ); marker->setXValue( colIdx + 0.5 ); marker->setYValue( rowIdx + 0.5 ); - rectangle->attach( m_plotWidget ); - marker->attach( m_plotWidget ); + rectangle->attach( m_plotWidget->qwtPlot() ); + marker->attach( m_plotWidget->qwtPlot() ); m_paramLabels[colIdx] = correlationMatrixRows[rowIdx].m_values[colIdx]; } @@ -685,9 +684,12 @@ void RimCorrelationMatrixPlot::updateLegend() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimCorrelationMatrixPlot::onPlotItemSelected( QwtPlotItem* plotItem, bool toggle, int sampleIndex ) +void RimCorrelationMatrixPlot::onPlotItemSelected( std::shared_ptr plotItem, bool toggle, int sampleIndex ) { - CorrelationMatrixShapeItem* matrixItem = dynamic_cast( plotItem ); + RiuQwtPlotItem* qwtPlotItem = dynamic_cast( plotItem.get() ); + if ( !qwtPlotItem ) return; + + CorrelationMatrixShapeItem* matrixItem = dynamic_cast( qwtPlotItem->qwtPlotItem() ); if ( matrixItem ) { matrixCellSelected.send( std::make_pair( matrixItem->parameter, matrixItem->curveDef ) ); diff --git a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationMatrixPlot.h b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationMatrixPlot.h index 1c4a68dba0..1ea5bbd69c 100644 --- a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationMatrixPlot.h +++ b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationMatrixPlot.h @@ -22,11 +22,11 @@ #include "cafAppEnum.h" -#include - class RimRegularLegendConfig; class RimSummaryAddress; + class RiuGroupedBarChartBuilder; +class RiuPlotItem; //================================================================================================== /// @@ -66,8 +66,7 @@ class RimCorrelationMatrixPlot : public RimAbstractCorrelationPlot void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void onLoadDataAndUpdate() override; @@ -79,7 +78,7 @@ class RimCorrelationMatrixPlot : public RimAbstractCorrelationPlot void createMatrix(); void updatePlotTitle() override; void updateLegend() override; - void onPlotItemSelected( QwtPlotItem* plotItem, bool toggle, int sampleIndex ) override; + void onPlotItemSelected( std::shared_ptr plotItem, bool toggle, int sampleIndex ) override; private: caf::PdmField m_showAbsoluteValues; diff --git a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationPlot.cpp b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationPlot.cpp index 00cb8e2063..d6c97737a8 100644 --- a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationPlot.cpp @@ -22,6 +22,7 @@ #include "RiaQDateTimeTools.h" #include "RiuGroupedBarChartBuilder.h" #include "RiuPlotMainWindowTools.h" +#include "RiuQwtPlotItem.h" #include "RiuQwtPlotWidget.h" #include "RifSummaryReaderInterface.h" @@ -40,7 +41,9 @@ #include "cafPdmUiComboBoxEditor.h" #include "cafPdmUiTreeSelectionEditor.h" +#include "qwt_plot.h" #include "qwt_plot_barchart.h" +#include "qwt_text.h" #include #include @@ -55,21 +58,18 @@ RimCorrelationPlot::RimCorrelationPlot() : RimAbstractCorrelationPlot() , tornadoItemSelected( this ) { - CAF_PDM_InitObject( "Correlation Tornado Plot", ":/CorrelationTornadoPlot16x16.png", "", "" ); + CAF_PDM_InitObject( "Correlation Tornado Plot", ":/CorrelationTornadoPlot16x16.png" ); - CAF_PDM_InitField( &m_showAbsoluteValues, "CorrelationAbsValues", false, "Show Absolute Values", "", "", "" ); - CAF_PDM_InitField( &m_sortByAbsoluteValues, "CorrelationAbsSorting", true, "Sort by Absolute Values", "", "", "" ); + CAF_PDM_InitField( &m_showAbsoluteValues, "CorrelationAbsValues", false, "Show Absolute Values" ); + CAF_PDM_InitField( &m_sortByAbsoluteValues, "CorrelationAbsSorting", true, "Sort by Absolute Values" ); CAF_PDM_InitField( &m_excludeParametersWithoutVariation, "ExcludeParamsWithoutVariation", true, - "Exclude Parameters Without Variation", - "", - "", - "" ); - CAF_PDM_InitField( &m_showOnlyTopNCorrelations, "ShowOnlyTopNCorrelations", true, "Show Only Top Correlations", "", "", "" ); - CAF_PDM_InitField( &m_topNFilterCount, "TopNFilterCount", 20, "Number rows/columns", "", "", "" ); - - CAF_PDM_InitFieldNoDefault( &m_selectedParametersList, "SelectedParameters", "Select Parameters", "", "", "" ); + "Exclude Parameters Without Variation" ); + CAF_PDM_InitField( &m_showOnlyTopNCorrelations, "ShowOnlyTopNCorrelations", true, "Show Only Top Correlations" ); + CAF_PDM_InitField( &m_topNFilterCount, "TopNFilterCount", 20, "Number rows/columns" ); + + CAF_PDM_InitFieldNoDefault( &m_selectedParametersList, "SelectedParameters", "Select Parameters" ); m_selectedParametersList.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); m_selectedParametersList.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); @@ -147,11 +147,9 @@ void RimCorrelationPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrder //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimCorrelationPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RimCorrelationPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { - QList options = - RimAbstractCorrelationPlot::calculateValueOptions( fieldNeedingOptions, useOptionsOnly ); + QList options = RimAbstractCorrelationPlot::calculateValueOptions( fieldNeedingOptions ); if ( fieldNeedingOptions == &m_selectedParametersList ) { @@ -175,23 +173,23 @@ void RimCorrelationPlot::onLoadDataAndUpdate() { updateMdiWindowVisibility(); - m_selectedVarsUiField = selectedQuantitiesText(); + m_selectedVarsUiField = selectedVectorNamesText(); if ( m_plotWidget && m_analyserOfSelectedCurveDefs ) { - m_plotWidget->detachItems( QwtPlotItem::Rtti_PlotBarChart ); - m_plotWidget->detachItems( QwtPlotItem::Rtti_PlotScale ); + m_plotWidget->qwtPlot()->detachItems( QwtPlotItem::Rtti_PlotBarChart ); + m_plotWidget->qwtPlot()->detachItems( QwtPlotItem::Rtti_PlotScale ); RiuGroupedBarChartBuilder chartBuilder; addDataToChartBuilder( chartBuilder ); - chartBuilder.addBarChartToPlot( m_plotWidget, + chartBuilder.addBarChartToPlot( m_plotWidget->qwtPlot(), Qt::Horizontal, m_showOnlyTopNCorrelations() ? m_topNFilterCount() : -1 ); chartBuilder.setLabelFontSize( labelFontSize() ); - m_plotWidget->insertLegend( nullptr ); + m_plotWidget->qwtPlot()->insertLegend( nullptr ); m_plotWidget->updateLegend(); this->updateAxes(); @@ -207,22 +205,30 @@ void RimCorrelationPlot::updateAxes() { if ( !m_plotWidget ) return; - m_plotWidget->setAxisTitleText( QwtPlot::yLeft, "Parameter" ); - m_plotWidget->setAxisTitleEnabled( QwtPlot::yLeft, true ); - m_plotWidget->setAxisFontsAndAlignment( QwtPlot::yLeft, axisTitleFontSize(), axisValueFontSize(), false, Qt::AlignCenter ); - - m_plotWidget->setAxisTitleText( QwtPlot::xBottom, "Pearson Correlation Coefficient" ); - m_plotWidget->setAxisTitleEnabled( QwtPlot::xBottom, true ); - m_plotWidget->setAxisFontsAndAlignment( QwtPlot::xBottom, axisTitleFontSize(), axisValueFontSize(), false, Qt::AlignCenter ); + m_plotWidget->setAxisTitleText( RiuPlotAxis::defaultLeft(), "Parameter" ); + m_plotWidget->setAxisTitleEnabled( RiuPlotAxis::defaultLeft(), true ); + m_plotWidget->setAxisFontsAndAlignment( RiuPlotAxis::defaultLeft(), + axisTitleFontSize(), + axisValueFontSize(), + false, + Qt::AlignCenter ); + + m_plotWidget->setAxisTitleText( RiuPlotAxis::defaultBottom(), "Pearson Correlation Coefficient" ); + m_plotWidget->setAxisTitleEnabled( RiuPlotAxis::defaultBottom(), true ); + m_plotWidget->setAxisFontsAndAlignment( RiuPlotAxis::defaultBottom(), + axisTitleFontSize(), + axisValueFontSize(), + false, + Qt::AlignCenter ); if ( m_showAbsoluteValues ) { - m_plotWidget->setAxisTitleText( QwtPlot::xBottom, "Pearson Correlation Coefficient ABS" ); - m_plotWidget->setAxisRange( QwtPlot::xBottom, 0.0, 1.0 ); + m_plotWidget->setAxisTitleText( RiuPlotAxis::defaultBottom(), "Pearson Correlation Coefficient ABS" ); + m_plotWidget->setAxisRange( RiuPlotAxis::defaultBottom(), 0.0, 1.0 ); } else { - m_plotWidget->setAxisTitleText( QwtPlot::xBottom, "Pearson Correlation Coefficient" ); - m_plotWidget->setAxisRange( QwtPlot::xBottom, -1.0, 1.0 ); + m_plotWidget->setAxisTitleText( RiuPlotAxis::defaultBottom(), "Pearson Correlation Coefficient" ); + m_plotWidget->setAxisRange( RiuPlotAxis::defaultBottom(), -1.0, 1.0 ); } } @@ -276,9 +282,12 @@ void RimCorrelationPlot::updatePlotTitle() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimCorrelationPlot::onPlotItemSelected( QwtPlotItem* plotItem, bool toggle, int sampleIndex ) +void RimCorrelationPlot::onPlotItemSelected( std::shared_ptr plotItem, bool toggle, int sampleIndex ) { - QwtPlotBarChart* barChart = dynamic_cast( plotItem ); + RiuQwtPlotItem* qwtPlotItem = dynamic_cast( plotItem.get() ); + if ( !qwtPlotItem ) return; + + QwtPlotBarChart* barChart = dynamic_cast( qwtPlotItem->qwtPlotItem() ); if ( barChart && !curveDefinitions().empty() ) { auto curveDef = curveDefinitions().front(); diff --git a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationPlot.h b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationPlot.h index bee98e0569..e7eacfc2a9 100644 --- a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationPlot.h +++ b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationPlot.h @@ -28,6 +28,7 @@ class RimSummaryAddress; class RiuGroupedBarChartBuilder; +class RiuPlotItem; //================================================================================================== /// @@ -60,8 +61,7 @@ class RimCorrelationPlot : public RimAbstractCorrelationPlot void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void onLoadDataAndUpdate() override; @@ -70,7 +70,7 @@ class RimCorrelationPlot : public RimAbstractCorrelationPlot // Private methods void addDataToChartBuilder( RiuGroupedBarChartBuilder& chartBuilder ); void updatePlotTitle() override; - void onPlotItemSelected( QwtPlotItem* plotItem, bool toggle, int sampleIndex ) override; + void onPlotItemSelected( std::shared_ptr plotItem, bool toggle, int sampleIndex ) override; private: caf::PdmField m_showAbsoluteValues; diff --git a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationPlotCollection.cpp b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationPlotCollection.cpp index d2397fa512..3570687983 100644 --- a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationPlotCollection.cpp @@ -34,10 +34,10 @@ CAF_PDM_SOURCE_INIT( RimCorrelationPlotCollection, "CorrelationPlotCollection" ) //-------------------------------------------------------------------------------------------------- RimCorrelationPlotCollection::RimCorrelationPlotCollection() { - CAF_PDM_InitObject( "Ensemble Correlation Plots", ":/CorrelationPlots16x16.png", "", "" ); + CAF_PDM_InitObject( "Ensemble Correlation Plots", ":/CorrelationPlots16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_correlationPlots, "CorrelationPlots", "Correlation Plots", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_correlationReports, "CorrelationReports", "Correlation Reports", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_correlationPlots, "CorrelationPlots", "Correlation Plots" ); + CAF_PDM_InitFieldNoDefault( &m_correlationReports, "CorrelationReports", "Correlation Reports" ); m_correlationPlots.uiCapability()->setUiTreeHidden( true ); m_correlationReports.uiCapability()->setUiTreeHidden( true ); @@ -193,7 +193,7 @@ void RimCorrelationPlotCollection::insertPlot( RimAbstractCorrelationPlot* plot, //-------------------------------------------------------------------------------------------------- void RimCorrelationPlotCollection::removePlot( RimAbstractCorrelationPlot* plot ) { - m_correlationPlots.removeChildObject( plot ); + m_correlationPlots.removeChild( plot ); updateAllRequiredEditors(); } @@ -202,7 +202,7 @@ void RimCorrelationPlotCollection::removePlot( RimAbstractCorrelationPlot* plot //-------------------------------------------------------------------------------------------------- std::vector RimCorrelationPlotCollection::plots() const { - return m_correlationPlots.childObjects(); + return m_correlationPlots.children(); } //-------------------------------------------------------------------------------------------------- @@ -218,7 +218,7 @@ size_t RimCorrelationPlotCollection::plotCount() const //-------------------------------------------------------------------------------------------------- std::vector RimCorrelationPlotCollection::reports() const { - return m_correlationReports.childObjects(); + return m_correlationReports.children(); } //-------------------------------------------------------------------------------------------------- @@ -227,7 +227,7 @@ std::vector RimCorrelationPlotCollection::reports() c void RimCorrelationPlotCollection::deleteAllPlots() { RimTypedPlotCollection::deleteAllPlots(); - m_correlationReports.deleteAllChildObjects(); + m_correlationReports.deleteChildren(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationReportPlot.cpp b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationReportPlot.cpp index a8fde71a64..8ca5fdd027 100644 --- a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationReportPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationReportPlot.cpp @@ -29,6 +29,8 @@ #include "RimSummaryCaseCollection.h" #include "RiuMultiPlotPage.h" +#include "RiuPlotWidget.h" +#include "RiuQwtPlotWidget.h" #include "cafAssert.h" #include "cafPdmUiOrdering.h" @@ -51,21 +53,21 @@ CAF_PDM_SOURCE_INIT( RimCorrelationReportPlot, "CorrelationReportPlot" ); //-------------------------------------------------------------------------------------------------- RimCorrelationReportPlot::RimCorrelationReportPlot() { - CAF_PDM_InitObject( "Correlation Report Plot", ":/CorrelationReportPlot16x16.png", "", "" ); + CAF_PDM_InitObject( "Correlation Report Plot", ":/CorrelationReportPlot16x16.png" ); this->setDeletable( true ); - CAF_PDM_InitFieldNoDefault( &m_plotWindowTitle, "PlotWindowTitle", "Title", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_plotWindowTitle, "PlotWindowTitle", "Title" ); m_plotWindowTitle.registerGetMethod( this, &RimCorrelationReportPlot::createPlotWindowTitle ); - CAF_PDM_InitFieldNoDefault( &m_correlationMatrixPlot, "MatrixPlot", "Matrix Plot", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_correlationPlot, "CorrelationPlot", "Correlation Plot", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_parameterResultCrossPlot, "CrossPlot", "Cross Plot", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_correlationMatrixPlot, "MatrixPlot", "Matrix Plot" ); + CAF_PDM_InitFieldNoDefault( &m_correlationPlot, "CorrelationPlot", "Correlation Plot" ); + CAF_PDM_InitFieldNoDefault( &m_parameterResultCrossPlot, "CrossPlot", "Cross Plot" ); - CAF_PDM_InitFieldNoDefault( &m_subTitleFontSize, "SubTitleFontSize", "Sub Plot Title Font Size", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_labelFontSize, "LabelFontSize", "Label Font Size", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_subTitleFontSize, "SubTitleFontSize", "Sub Plot Title Font Size" ); + CAF_PDM_InitFieldNoDefault( &m_labelFontSize, "LabelFontSize", "Label Font Size" ); - CAF_PDM_InitFieldNoDefault( &m_axisTitleFontSize, "AxisTitleFontSize", "Axis Title Font Size", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_axisValueFontSize, "AxisValueFontSize", "Axis Value Font Size", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_axisTitleFontSize, "AxisTitleFontSize", "Axis Title Font Size" ); + CAF_PDM_InitFieldNoDefault( &m_axisValueFontSize, "AxisValueFontSize", "Axis Value Font Size" ); setAsPlotMdiWindow(); @@ -394,10 +396,9 @@ void RimCorrelationReportPlot::doUpdateLayout() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList - RimCorrelationReportPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) +QList RimCorrelationReportPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { - QList options = RimPlotWindow::calculateValueOptions( fieldNeedingOptions, useOptionsOnly ); + QList options = RimPlotWindow::calculateValueOptions( fieldNeedingOptions ); if ( fieldNeedingOptions == &m_subTitleFontSize || fieldNeedingOptions == &m_labelFontSize || fieldNeedingOptions == &m_axisTitleFontSize || fieldNeedingOptions == &m_axisValueFontSize ) diff --git a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationReportPlot.h b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationReportPlot.h index 18bace8c09..d5b4642567 100644 --- a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationReportPlot.h +++ b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationReportPlot.h @@ -32,7 +32,7 @@ class RimCorrelationMatrixPlot; class RimParameterResultCrossPlot; class RimSummaryCaseCollection; class RimCorrelationPlot; -class RiaSummaryCurveDefinition; +class RiaSummaryCurveDefinition; class RiuMultiPlotPage; @@ -74,8 +74,7 @@ class RimCorrelationReportPlot : public QObject, public RimPlotWindow void childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) override; void doUpdateLayout() override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void onDataSelection( const caf::SignalEmitter* emitter, std::pair parameterAndCurveDef ); diff --git a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimParameterResultCrossPlot.cpp b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimParameterResultCrossPlot.cpp index 84d8dd3ef3..2edd1f9be0 100644 --- a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimParameterResultCrossPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimParameterResultCrossPlot.cpp @@ -39,6 +39,7 @@ #include "RimSummaryCaseCollection.h" #include "RimSummaryPlotAxisFormatter.h" +#include "RiuPlotCurve.h" #include "RiuPlotMainWindowTools.h" #include "RiuQwtPlotCurve.h" #include "RiuSummaryQwtPlot.h" @@ -49,6 +50,7 @@ #include "cafPdmUiPushButtonEditor.h" #include "qwt_legend.h" +#include "qwt_plot.h" #include "qwt_plot_curve.h" #include "qwt_scale_engine.h" @@ -66,9 +68,9 @@ CAF_PDM_SOURCE_INIT( RimParameterResultCrossPlot, "ParameterResultCrossPlot" ); RimParameterResultCrossPlot::RimParameterResultCrossPlot() : RimAbstractCorrelationPlot() { - CAF_PDM_InitObject( "ParameterResultCross Plot", ":/CorrelationCrossPlot16x16.png", "", "" ); + CAF_PDM_InitObject( "ParameterResultCross Plot", ":/CorrelationCrossPlot16x16.png" ); - CAF_PDM_InitField( &m_ensembleParameter, "EnsembleParameter", QString( "" ), "Ensemble Parameter", "", "", "" ); + CAF_PDM_InitField( &m_ensembleParameter, "EnsembleParameter", QString( "" ), "Ensemble Parameter" ); m_ensembleParameter.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); m_selectMultipleVectors = true; @@ -139,10 +141,9 @@ void RimParameterResultCrossPlot::defineUiOrdering( QString uiConfigName, caf::P /// //-------------------------------------------------------------------------------------------------- QList - RimParameterResultCrossPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) + RimParameterResultCrossPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { - QList options = - RimAbstractCorrelationPlot::calculateValueOptions( fieldNeedingOptions, useOptionsOnly ); + QList options = RimAbstractCorrelationPlot::calculateValueOptions( fieldNeedingOptions ); if ( fieldNeedingOptions == &m_ensembleParameter ) { for ( const auto& param : ensembleParameters() ) @@ -160,7 +161,7 @@ void RimParameterResultCrossPlot::onLoadDataAndUpdate() { updateMdiWindowVisibility(); - m_selectedVarsUiField = selectedQuantitiesText(); + m_selectedVarsUiField = selectedVectorNamesText(); if ( m_plotWidget && m_analyserOfSelectedCurveDefs ) { @@ -168,7 +169,7 @@ void RimParameterResultCrossPlot::onLoadDataAndUpdate() if ( m_showPlotLegends && !isSubPlot() ) { QwtLegend* legend = new QwtLegend( m_plotWidget ); - m_plotWidget->insertLegend( legend, QwtPlot::RightLegend ); + m_plotWidget->qwtPlot()->insertLegend( legend, QwtPlot::RightLegend ); m_plotWidget->setLegendFontSize( legendFontSize() ); m_plotWidget->updateLegend(); } @@ -186,19 +187,31 @@ void RimParameterResultCrossPlot::updateAxes() { if ( !m_plotWidget ) return; - m_plotWidget->setAxisTitleText( QwtPlot::yLeft, completeAddressText() ); - m_plotWidget->setAxisTitleEnabled( QwtPlot::yLeft, true ); - m_plotWidget->setAxisFontsAndAlignment( QwtPlot::yLeft, axisTitleFontSize(), axisValueFontSize(), false, Qt::AlignCenter ); + m_plotWidget->setAxisTitleText( RiuPlotAxis::defaultLeft(), completeAddressText() ); + m_plotWidget->setAxisTitleEnabled( RiuPlotAxis::defaultLeft(), true ); + m_plotWidget->setAxisFontsAndAlignment( RiuPlotAxis::defaultLeft(), + axisTitleFontSize(), + axisValueFontSize(), + false, + Qt::AlignCenter ); double yRangeWidth = m_yRange.second - m_yRange.first; - m_plotWidget->setAxisRange( QwtPlot::yLeft, m_yRange.first - yRangeWidth * 0.1, m_yRange.second + yRangeWidth * 0.1 ); - - m_plotWidget->setAxisTitleText( QwtPlot::xBottom, m_ensembleParameter ); - m_plotWidget->setAxisTitleEnabled( QwtPlot::xBottom, true ); - m_plotWidget->setAxisFontsAndAlignment( QwtPlot::xBottom, axisTitleFontSize(), axisValueFontSize(), false, Qt::AlignCenter ); + m_plotWidget->setAxisRange( RiuPlotAxis::defaultLeft(), + m_yRange.first - yRangeWidth * 0.1, + m_yRange.second + yRangeWidth * 0.1 ); + + m_plotWidget->setAxisTitleText( RiuPlotAxis::defaultBottom(), m_ensembleParameter ); + m_plotWidget->setAxisTitleEnabled( RiuPlotAxis::defaultBottom(), true ); + m_plotWidget->setAxisFontsAndAlignment( RiuPlotAxis::defaultBottom(), + axisTitleFontSize(), + axisValueFontSize(), + false, + Qt::AlignCenter ); double xRangeWidth = m_xRange.second - m_xRange.first; - m_plotWidget->setAxisRange( QwtPlot::xBottom, m_xRange.first - xRangeWidth * 0.1, m_xRange.second + xRangeWidth * 0.1 ); + m_plotWidget->setAxisRange( RiuPlotAxis::defaultBottom(), + m_xRange.first - xRangeWidth * 0.1, + m_xRange.second + xRangeWidth * 0.1 ); } //-------------------------------------------------------------------------------------------------- @@ -295,10 +308,10 @@ void RimParameterResultCrossPlot::createPoints() m_yRange.second = std::max( m_yRange.second, closestValue ); RiuQwtPlotCurve* plotCurve = new RiuQwtPlotCurve; - plotCurve->setSamples( parameterValues.data(), caseValuesAtTimestep.data(), (int)parameterValues.size() ); + plotCurve->setSamplesValues( parameterValues, caseValuesAtTimestep ); plotCurve->setStyle( QwtPlotCurve::NoCurve ); RiuQwtSymbol* symbol = - new RiuQwtSymbol( RiuQwtSymbol::cycledSymbolStyle( ensembleIdx, addressIdx ), "" ); + new RiuQwtSymbol( RiuPlotCurveSymbol::cycledSymbolStyle( ensembleIdx, addressIdx ), "" ); symbol->setSize( legendFontSize(), legendFontSize() ); symbol->setColor( colorTable.cycledQColor( caseIdx ) ); plotCurve->setSymbol( symbol ); @@ -309,7 +322,7 @@ void RimParameterResultCrossPlot::createPoints() plotCurve->setTitle( curveName.join( " - " ) ); - plotCurve->attach( m_plotWidget ); + plotCurve->attach( m_plotWidget->qwtPlot() ); } } addressIdx++; diff --git a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimParameterResultCrossPlot.h b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimParameterResultCrossPlot.h index 46faac5f0b..291256497c 100644 --- a/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimParameterResultCrossPlot.h +++ b/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimParameterResultCrossPlot.h @@ -39,8 +39,7 @@ class RimParameterResultCrossPlot : public RimAbstractCorrelationPlot void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void onLoadDataAndUpdate() override; diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInView.cpp b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInView.cpp index d94eea6e7a..264558bb7d 100644 --- a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInView.cpp +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInView.cpp @@ -31,16 +31,16 @@ CAF_PDM_SOURCE_INIT( RimFaultInView, "Fault" ); //-------------------------------------------------------------------------------------------------- RimFaultInView::RimFaultInView() { - CAF_PDM_InitObject( "RimFault", ":/draw_style_faults_24x24.png", "", "" ); + CAF_PDM_InitObject( "RimFault", ":/draw_style_faults_24x24.png" ); - CAF_PDM_InitFieldNoDefault( &name, "FaultName", "Name", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &name, "FaultName", "Name" ); name.uiCapability()->setUiHidden( true ); name.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitField( &showFault, "ShowFault", true, "Show Fault", "", "", "" ); + CAF_PDM_InitField( &showFault, "ShowFault", true, "Show Fault" ); showFault.uiCapability()->setUiHidden( true ); - CAF_PDM_InitField( &faultColor, "Color", cvf::Color3f( 0.588f, 0.588f, 0.804f ), "Fault Color", "", "", "" ); + CAF_PDM_InitField( &faultColor, "Color", cvf::Color3f( 0.588f, 0.588f, 0.804f ), "Fault Color" ); m_rigFault = nullptr; } diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.cpp b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.cpp index ce8acbd451..5e26badf1a 100644 --- a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.cpp @@ -61,9 +61,9 @@ CAF_PDM_SOURCE_INIT( RimFaultInViewCollection, "Faults" ); //-------------------------------------------------------------------------------------------------- RimFaultInViewCollection::RimFaultInViewCollection() { - CAF_PDM_InitObject( "Faults", ":/draw_style_faults_24x24.png", "", "" ); + CAF_PDM_InitObject( "Faults", ":/draw_style_faults_24x24.png" ); - CAF_PDM_InitField( &showFaultCollection, "Active", true, "Active", "", "", "" ); + CAF_PDM_InitField( &showFaultCollection, "Active", true, "Active" ); showFaultCollection.uiCapability()->setUiHidden( true ); CAF_PDM_InitField( &showFaultFaces, "ShowFaultFaces", true, "Show Defined faces" ); @@ -75,7 +75,7 @@ RimFaultInViewCollection::RimFaultInViewCollection() CAF_PDM_InitField( &m_showFaultsOutsideFilters, "ShowFaultsOutsideFilters", true, "Show Faults Outside Filters" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_showFaultsOutsideFilters ); - CAF_PDM_InitField( &m_onlyShowWithNeighbor, "OnlyShowWithDefNeighbor", false, "Only Show Faces With Defined Cell Neighbor" ); + CAF_PDM_InitField( &m_onlyShowWithNeighbor, "OnlyShowWithDefNeighbor", false, "Show Only Faces with Juxtaposition" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_onlyShowWithNeighbor ); CAF_PDM_InitField( &faultResult, @@ -88,7 +88,7 @@ RimFaultInViewCollection::RimFaultInViewCollection() caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &showFaultLabel ); cvf::Color3f defWellLabelColor = RiaPreferences::current()->defaultWellLabelColor(); - CAF_PDM_InitField( &faultLabelColor, "FaultLabelColor", defWellLabelColor, "Label Color", "", "", "" ); + CAF_PDM_InitField( &faultLabelColor, "FaultLabelColor", defWellLabelColor, "Label Color" ); CAF_PDM_InitField( &showNNCs, "ShowNNCs", true, "Show NNCs" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &showNNCs ); @@ -99,14 +99,14 @@ RimFaultInViewCollection::RimFaultInViewCollection() "Hide NNC Geometry if No NNC Result is Available" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &hideNncsWhenNoResultIsAvailable ); - CAF_PDM_InitFieldNoDefault( &faults, "Faults", "Faults", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &faults, "Faults", "Faults" ); faults.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitField( &m_enableFaultRA, "EnableFaultRA", false, "Enable Fault RA", "", "", "" ); + CAF_PDM_InitField( &m_enableFaultRA, "EnableFaultRA", false, "Enable Fault RA" ); m_enableFaultRA.uiCapability()->setUiReadOnly( true ); m_enableFaultRA.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_faultRASettings, "FaultRASettings", "Reactivation Assessment Settings", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_faultRASettings, "FaultRASettings", "Reactivation Assessment Settings" ); m_faultRASettings = new RimFaultRASettings(); m_faultRASettings.uiCapability()->setUiHidden( true ); m_faultRASettings.uiCapability()->setUiTreeHidden( true ); @@ -117,7 +117,7 @@ RimFaultInViewCollection::RimFaultInViewCollection() //-------------------------------------------------------------------------------------------------- RimFaultInViewCollection::~RimFaultInViewCollection() { - faults.deleteAllChildObjects(); + faults.deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -269,7 +269,7 @@ void RimFaultInViewCollection::syncronizeFaults() newFaults.push_back( rimFault ); } - this->faults().clear(); + this->faults().clearWithoutDelete(); this->faults().insert( 0, newFaults ); QString toolTip = QString( "Fault count (%1)" ).arg( newFaults.size() ); diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultRAPostprocSettings.cpp b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultRAPostprocSettings.cpp index ae7f05efcc..c2f1ff8d53 100644 --- a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultRAPostprocSettings.cpp +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultRAPostprocSettings.cpp @@ -30,15 +30,15 @@ //-------------------------------------------------------------------------------------------------- RimFaultRAPostprocSettings::RimFaultRAPostprocSettings() { - CAF_PDM_InitObject( "Reactivation Assessment Postproc Settings", ":/fault_react_24x24.png", "", "" ); - - CAF_PDM_InitField( &m_baseDir, "BaseDir", QString( "" ), "Working Directory", "", "", "" ); - CAF_PDM_InitField( &m_startTimestepEclipse, "StartTimeStepEclipse", 0, "Start Time Step", "", "", "" ); - CAF_PDM_InitField( &m_endTimestepEclipse, "EndTimeStepEclipse", 0, "End Time Step", "", "", "" ); - CAF_PDM_InitField( &m_geomechEnabled, "GeomechEnabled", false, "GeoMechanical Input Available", "", "", "" ); - CAF_PDM_InitField( &m_basicMacrisDatabase, "BasicMacrisDatabase", QString( "" ), "Basic Macris Database", "", "", "" ); - CAF_PDM_InitField( &m_advancedMacrisDatabase, "AdvancedMacrisDatabase", QString( "" ), "Advanced Macris Database", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_postprocParameters, "PostprocParameters", "Post-Processing Parameters", "", "", "" ); + CAF_PDM_InitObject( "Reactivation Assessment Postproc Settings", ":/fault_react_24x24.png" ); + + CAF_PDM_InitField( &m_baseDir, "BaseDir", QString( "" ), "Working Directory" ); + CAF_PDM_InitField( &m_startTimestepEclipse, "StartTimeStepEclipse", 0, "Start Time Step" ); + CAF_PDM_InitField( &m_endTimestepEclipse, "EndTimeStepEclipse", 0, "End Time Step" ); + CAF_PDM_InitField( &m_geomechEnabled, "GeomechEnabled", false, "GeoMechanical Input Available" ); + CAF_PDM_InitField( &m_basicMacrisDatabase, "BasicMacrisDatabase", QString( "" ), "Basic Macris Database" ); + CAF_PDM_InitField( &m_advancedMacrisDatabase, "AdvancedMacrisDatabase", QString( "" ), "Advanced Macris Database" ); + CAF_PDM_InitFieldNoDefault( &m_postprocParameters, "PostprocParameters", "Post-Processing Parameters" ); m_postprocParameters = new RimParameterGroup(); } diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultRAPreprocSettings.cpp b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultRAPreprocSettings.cpp index cf3d80ea48..c3bc65f25a 100644 --- a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultRAPreprocSettings.cpp +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultRAPreprocSettings.cpp @@ -40,31 +40,31 @@ CAF_PDM_SOURCE_INIT( RimFaultRAPreprocSettings, "RimFaultRAPreprocSettings" ); //-------------------------------------------------------------------------------------------------- RimFaultRAPreprocSettings::RimFaultRAPreprocSettings() { - CAF_PDM_InitObject( "Fault RA Preproc Settings", ":/fault_react_24x24.png", "", "" ); + CAF_PDM_InitObject( "Fault RA Preproc Settings", ":/fault_react_24x24.png" ); - CAF_PDM_InitField( &m_startTimestepEclipse, "StartTimeStepEclipse", 0, "Start Time Step", "", "", "" ); + CAF_PDM_InitField( &m_startTimestepEclipse, "StartTimeStepEclipse", 0, "Start Time Step" ); m_startTimestepEclipse.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_endTimestepEclipse, "EndTimeStepEclipse", 0, "End Time Step", "", "", "" ); + CAF_PDM_InitField( &m_endTimestepEclipse, "EndTimeStepEclipse", 0, "End Time Step" ); m_endTimestepEclipse.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_startTimestepGeoMech, "StartTimeStepGeoMech", 0, "Start Time Step", "", "", "" ); + CAF_PDM_InitField( &m_startTimestepGeoMech, "StartTimeStepGeoMech", 0, "Start Time Step" ); m_startTimestepGeoMech.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_endTimestepGeoMech, "EndTimeStepGeoMech", 0, "End Time Step", "", "", "" ); + CAF_PDM_InitField( &m_endTimestepGeoMech, "EndTimeStepGeoMech", 0, "End Time Step" ); m_endTimestepGeoMech.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_eclipseCase, "EclipseCase", "Eclipse Case", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_eclipseCase, "EclipseCase", "Eclipse Case" ); m_eclipseCase.setValue( nullptr ); - CAF_PDM_InitFieldNoDefault( &m_geomechCase, "GeomechCase", "GeoMech Case", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_geomechCase, "GeomechCase", "GeoMech Case" ); m_geomechCase.setValue( nullptr ); - CAF_PDM_InitFieldNoDefault( &m_baseDir, "BaseDir", "Output Directory", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_baseDir, "BaseDir", "Output Directory" ); m_baseDir.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitField( &m_cleanBaseDir, "CleanBaseDir", false, "Clean Output Directory", "", "", "" ); - CAF_PDM_InitField( &m_smoothEclipseData, "SmoothEclipseData", true, "Smooth Eclipse Data", "", "", "" ); + CAF_PDM_InitField( &m_cleanBaseDir, "CleanBaseDir", false, "Clean Output Directory" ); + CAF_PDM_InitField( &m_smoothEclipseData, "SmoothEclipseData", true, "Smooth Eclipse Data" ); - CAF_PDM_InitField( &m_elasticTableFilename, "ElasticTableFilename", QString( "" ), "Elastic Table", "", "", "" ); + CAF_PDM_InitField( &m_elasticTableFilename, "ElasticTableFilename", QString( "" ), "Elastic Table" ); m_elasticTableFilename.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); m_elasticTableFilename.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); } @@ -131,7 +131,7 @@ void RimFaultRAPreprocSettings::defineUiOrdering( QString uiConfigName, caf::Pdm /// //-------------------------------------------------------------------------------------------------- QList - RimFaultRAPreprocSettings::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) + RimFaultRAPreprocSettings::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultRAPreprocSettings.h b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultRAPreprocSettings.h index e54147c015..743575dca7 100644 --- a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultRAPreprocSettings.h +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultRAPreprocSettings.h @@ -79,8 +79,7 @@ class RimFaultRAPreprocSettings : public caf::PdmObject QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; RimCase* startCase() const; diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultRASettings.cpp b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultRASettings.cpp index 76c71e509a..9fb828c5c7 100644 --- a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultRASettings.cpp +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultRASettings.cpp @@ -53,46 +53,41 @@ CAF_PDM_SOURCE_INIT( RimFaultRASettings, "RimFaultRASettings" ); //-------------------------------------------------------------------------------------------------- RimFaultRASettings::RimFaultRASettings() { - CAF_PDM_InitObject( "Reactivation Assessment Settings", ":/fault_react_24x24.png", "", "" ); + CAF_PDM_InitObject( "Reactivation Assessment Settings", ":/fault_react_24x24.png" ); - CAF_PDM_InitFieldNoDefault( &m_eclipseCase, "EclipseCase", "Eclipse Case", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_eclipseCase, "EclipseCase", "Eclipse Case" ); m_eclipseCase.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitFieldNoDefault( &m_geomechCase, "GeomechCase", "GeoMech Case", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_geomechCase, "GeomechCase", "GeoMech Case" ); m_geomechCase.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitFieldNoDefault( &m_eclipseFRAGeneratedCase, "EclipseFRACase", "Eclipse FRA Case", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_eclipseFRAGeneratedCase, "EclipseFRACase", "Eclipse FRA Case" ); m_eclipseFRAGeneratedCase.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitFieldNoDefault( &m_baseDir, "BaseDir", "Working Directory", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_baseDir, "BaseDir", "Working Directory" ); m_baseDir.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitField( &m_elasticTableFilename, "ElasticTableFilename", QString( "" ), "Elastic Table", "", "", "" ); + CAF_PDM_InitField( &m_elasticTableFilename, "ElasticTableFilename", QString( "" ), "Elastic Table" ); m_elasticTableFilename.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); m_elasticTableFilename.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); - CAF_PDM_InitField( &m_startTimestepEclipse, "StartTimeStepEclipse", 0, "Start Time Step", "", "", "" ); + CAF_PDM_InitField( &m_startTimestepEclipse, "StartTimeStepEclipse", 0, "Start Time Step" ); m_startTimestepEclipse.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_endTimestepEclipse, "EndTimeStepEclipse", 0, "End Time Step", "", "", "" ); + CAF_PDM_InitField( &m_endTimestepEclipse, "EndTimeStepEclipse", 0, "End Time Step" ); m_endTimestepEclipse.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_startTimestepGeoMech, "StartTimeStepGeoMech", 0, "Start Time Step", "", "", "" ); + CAF_PDM_InitField( &m_startTimestepGeoMech, "StartTimeStepGeoMech", 0, "Start Time Step" ); m_startTimestepGeoMech.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); m_startTimestepGeoMech.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitField( &m_endTimestepGeoMech, "EndTimeStepGeoMech", 0, "End Time Step", "", "", "" ); + CAF_PDM_InitField( &m_endTimestepGeoMech, "EndTimeStepGeoMech", 0, "End Time Step" ); m_endTimestepGeoMech.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); m_endTimestepGeoMech.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitFieldNoDefault( &m_basicParameters, "BasicParameters", "Basic Processing Parameters", ":/Bullet.png", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_advancedParameters, - "AdvancedParameters", - "Advanced Processing Parameters", - ":/Bullet.png", - "", - "" ); + CAF_PDM_InitFieldNoDefault( &m_basicParameters, "BasicParameters", "Basic Processing Parameters", ":/Bullet.png" ); + CAF_PDM_InitFieldNoDefault( &m_advancedParameters, "AdvancedParameters", "Advanced Processing Parameters", ":/Bullet.png" ); - CAF_PDM_InitFieldNoDefault( &m_basicParametersRI, "BasicParametersRI", "Basic ResInsight Parameters", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_advancedParametersRI, "AdvancedParametersRI", "Advanced ResInsight Parameters", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_basicParametersRI, "BasicParametersRI", "Basic ResInsight Parameters" ); + CAF_PDM_InitFieldNoDefault( &m_advancedParametersRI, "AdvancedParametersRI", "Advanced ResInsight Parameters" ); setupResInsightParameters(); } @@ -107,8 +102,7 @@ RimFaultRASettings::~RimFaultRASettings() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimFaultRASettings::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RimFaultRASettings::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; @@ -276,7 +270,7 @@ void RimFaultRASettings::initFromPreprocSettings( RimFaultRAPreprocSettings* pre RifParameterXmlReader basicreader( RiaPreferencesGeoMech::current()->geomechFRADefaultBasicXML() ); if ( !basicreader.parseFile( errorText ) ) return; - m_basicParameters.clear(); + m_basicParameters.deleteChildren(); for ( auto group : basicreader.parameterGroups() ) { m_basicParameters.push_back( group ); @@ -287,7 +281,7 @@ void RimFaultRASettings::initFromPreprocSettings( RimFaultRAPreprocSettings* pre RifParameterXmlReader advreader( RiaPreferencesGeoMech::current()->geomechFRADefaultAdvXML() ); if ( !advreader.parseFile( errorText ) ) return; - m_advancedParameters.clear(); + m_advancedParameters.deleteChildren(); for ( auto group : advreader.parameterGroups() ) { m_advancedParameters.push_back( group ); @@ -412,7 +406,7 @@ std::list RimFaultRASettings::basicParameters( int faultID retlist.push_back( p ); } - for ( auto& group : m_basicParameters.childObjects() ) + for ( auto& group : m_basicParameters.children() ) { for ( auto& p : group->parameters() ) { @@ -443,7 +437,7 @@ std::list RimFaultRASettings::advancedParameters( int faul retlist.push_back( p ); } - for ( auto& group : m_advancedParameters.childObjects() ) + for ( auto& group : m_advancedParameters.children() ) { for ( auto& p : group->parameters() ) { @@ -617,13 +611,13 @@ RimGenericParameter* RimFaultRASettings::getInputParameter( QString name ) const { RimGenericParameter* retval = nullptr; - for ( auto group : m_basicParameters.childObjects() ) + for ( auto group : m_basicParameters.children() ) { retval = group->parameter( name ); if ( retval != nullptr ) return retval; } - for ( auto group : m_advancedParameters.childObjects() ) + for ( auto group : m_advancedParameters.children() ) { retval = group->parameter( name ); if ( retval != nullptr ) return retval; diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultRASettings.h b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultRASettings.h index 94d7b96225..0dd279581f 100644 --- a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultRASettings.h +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultRASettings.h @@ -18,6 +18,7 @@ #pragma once #include "cafPdmChildArrayField.h" +#include "cafPdmChildField.h" #include "cafPdmField.h" #include "cafPdmObject.h" #include "cafPdmPtrField.h" @@ -92,8 +93,7 @@ class RimFaultRASettings : public caf::PdmObject void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; private: void setupResInsightParameters(); @@ -113,6 +113,6 @@ class RimFaultRASettings : public caf::PdmObject caf::PdmChildArrayField m_basicParameters; caf::PdmChildArrayField m_advancedParameters; - caf::PdmPtrField m_basicParametersRI; - caf::PdmPtrField m_advancedParametersRI; + caf::PdmChildField m_basicParametersRI; + caf::PdmChildField m_advancedParametersRI; }; diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimDataSourceForRftPlt.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimDataSourceForRftPlt.cpp index f2ddf34450..7a8c33f53f 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimDataSourceForRftPlt.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimDataSourceForRftPlt.cpp @@ -102,11 +102,11 @@ RifDataSourceForRftPlt RimDataSourceForRftPlt::address() const //-------------------------------------------------------------------------------------------------- void RimDataSourceForRftPlt::InitPdmObject() { - CAF_PDM_InitFieldNoDefault( &m_sourceType, "SourceType", "Source Type", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_eclCase, "EclipseCase", "Eclipse Case", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_wellLogFile, "WellLogFile", "Well Log File", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_ensemble, "Ensemble", "Ensemble", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_observedFmuRftData, "ObservedFmuRftData", "Observed FMU Data", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_sourceType, "SourceType", "Source Type" ); + CAF_PDM_InitFieldNoDefault( &m_eclCase, "EclipseCase", "Eclipse Case" ); + CAF_PDM_InitFieldNoDefault( &m_wellLogFile, "WellLogFile", "Well Log File" ); + CAF_PDM_InitFieldNoDefault( &m_ensemble, "Ensemble", "Ensemble" ); + CAF_PDM_InitFieldNoDefault( &m_observedFmuRftData, "ObservedFmuRftData", "Observed FMU Data" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimFlowCharacteristicsPlot.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimFlowCharacteristicsPlot.cpp index 65e556d5a5..a07b7036a8 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimFlowCharacteristicsPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimFlowCharacteristicsPlot.cpp @@ -26,6 +26,7 @@ #include "RigEclipseCaseData.h" #include "RigFlowDiagResults.h" +#include "RimEclipseCaseTools.h" #include "RimEclipseCellColors.h" #include "RimEclipsePropertyFilter.h" #include "RimEclipsePropertyFilterCollection.h" @@ -33,7 +34,6 @@ #include "RimEclipseView.h" #include "RimFaultInViewCollection.h" #include "RimFlowDiagSolution.h" -#include "RimProject.h" #include "RicEclipsePropertyFilterFeatureImpl.h" #include "RicSelectOrCreateViewFeatureImpl.h" @@ -68,17 +68,17 @@ CAF_PDM_SOURCE_INIT( RimFlowCharacteristicsPlot, "FlowCharacteristicsPlot" ); //-------------------------------------------------------------------------------------------------- RimFlowCharacteristicsPlot::RimFlowCharacteristicsPlot() { - CAF_PDM_InitObject( "Flow Characteristics", ":/FlowCharPlot16x16.png", "", "" ); + CAF_PDM_InitObject( "Flow Characteristics", ":/FlowCharPlot16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_case, "FlowCase", "Case", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_flowDiagSolution, "FlowDiagSolution", "Flow Diag Solution", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_case, "FlowCase", "Case" ); + CAF_PDM_InitFieldNoDefault( &m_flowDiagSolution, "FlowDiagSolution", "Flow Diag Solution" ); m_flowDiagSolution.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_timeStepSelectionType, "TimeSelectionType", "Time Steps", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_selectedTimeSteps, "SelectedTimeSteps", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_timeStepSelectionType, "TimeSelectionType", "Time Steps" ); + CAF_PDM_InitFieldNoDefault( &m_selectedTimeSteps, "SelectedTimeSteps", "" ); m_selectedTimeSteps.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_selectedTimeStepsUi, "SelectedTimeStepsUi", "", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_applyTimeSteps, "ApplyTimeSteps", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_selectedTimeStepsUi, "SelectedTimeStepsUi", "" ); + CAF_PDM_InitFieldNoDefault( &m_applyTimeSteps, "ApplyTimeSteps", "" ); caf::PdmUiPushButtonEditor::configureEditorForField( &m_applyTimeSteps ); CAF_PDM_InitField( &m_maxPvFraction, @@ -90,19 +90,19 @@ RimFlowCharacteristicsPlot::RimFlowCharacteristicsPlot() "Volume.", "" ); - CAF_PDM_InitField( &m_showLegend, "ShowLegend", true, "Legend", "", "", "" ); + CAF_PDM_InitField( &m_showLegend, "ShowLegend", true, "Legend" ); // Region group - CAF_PDM_InitFieldNoDefault( &m_cellFilter, "CellFilter", "Cell Filter", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_cellFilterView, "CellFilterView", "View", "", "", "" ); - CAF_PDM_InitField( &m_tracerFilter, "TracerFilter", QString(), "Tracer Filter", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_selectedTracerNames, "SelectedTracerNames", " ", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_cellFilter, "CellFilter", "Cell Filter" ); + CAF_PDM_InitFieldNoDefault( &m_cellFilterView, "CellFilterView", "View" ); + CAF_PDM_InitField( &m_tracerFilter, "TracerFilter", QString(), "Tracer Filter" ); + CAF_PDM_InitFieldNoDefault( &m_selectedTracerNames, "SelectedTracerNames", " " ); m_selectedTracerNames.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_showRegion, "ShowRegion", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_showRegion, "ShowRegion", "" ); caf::PdmUiPushButtonEditor::configureEditorForField( &m_showRegion ); - CAF_PDM_InitField( &m_minCommunication, "MinCommunication", 0.0, "Min Communication", "", "", "" ); - CAF_PDM_InitField( &m_maxTof, "MaxTof", 146000, "Max Time of Flight [days]", "", "", "" ); + CAF_PDM_InitField( &m_minCommunication, "MinCommunication", 0.0, "Min Communication" ); + CAF_PDM_InitField( &m_maxTof, "MaxTof", 146000, "Max Time of Flight [days]" ); this->m_showWindow = false; setAsPlotMdiWindow(); @@ -262,24 +262,18 @@ void RimFlowCharacteristicsPlot::updateFonts() /// //-------------------------------------------------------------------------------------------------- QList - RimFlowCharacteristicsPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) + RimFlowCharacteristicsPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; if ( fieldNeedingOptions == &m_case ) { - RimProject* proj = nullptr; - this->firstAncestorOrThisOfType( proj ); - if ( proj ) + auto resultCases = RimEclipseCaseTools::eclipseResultCases(); + for ( RimEclipseResultCase* c : resultCases ) { - std::vector cases; - proj->descendantsIncludingThisOfType( cases ); - for ( RimEclipseResultCase* c : cases ) + if ( c->defaultFlowDiagSolution() ) { - if ( c->defaultFlowDiagSolution() ) - { - options.push_back( caf::PdmOptionItemInfo( c->caseUserDescription(), c, false, c->uiIconProvider() ) ); - } + options.push_back( caf::PdmOptionItemInfo( c->caseUserDescription(), c, false, c->uiIconProvider() ) ); } } } @@ -399,29 +393,23 @@ QList void RimFlowCharacteristicsPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { { - // Ensure a case is selected if one is available - RimProject* proj = nullptr; - this->firstAncestorOrThisOfType( proj ); - if ( proj ) + RimEclipseResultCase* defaultCase = nullptr; + + auto resultCases = RimEclipseCaseTools::eclipseResultCases(); + for ( RimEclipseResultCase* c : resultCases ) { - std::vector cases; - proj->descendantsIncludingThisOfType( cases ); - RimEclipseResultCase* defaultCase = nullptr; - for ( RimEclipseResultCase* c : cases ) + if ( c->defaultFlowDiagSolution() ) { - if ( c->defaultFlowDiagSolution() ) - { - if ( !defaultCase ) defaultCase = c; // Select first - } + if ( !defaultCase ) defaultCase = c; // Select first } - if ( !m_case() && defaultCase ) + } + if ( !m_case() && defaultCase ) + { + m_case = defaultCase; + m_flowDiagSolution = m_case->defaultFlowDiagSolution(); + if ( !m_case()->reservoirViews.empty() ) { - m_case = defaultCase; - m_flowDiagSolution = m_case->defaultFlowDiagSolution(); - if ( !m_case()->reservoirViews.empty() ) - { - m_cellFilterView = m_case()->reservoirViews()[0]; - } + m_cellFilterView = m_case()->reservoirViews()[0]; } } } diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimFlowCharacteristicsPlot.h b/ApplicationLibCode/ProjectDataModel/Flow/RimFlowCharacteristicsPlot.h index e296c80c29..4443a70859 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimFlowCharacteristicsPlot.h +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimFlowCharacteristicsPlot.h @@ -92,8 +92,7 @@ class RimFlowCharacteristicsPlot : public RimViewWindow // Overridden PDM methods void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimFlowDiagSolution.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimFlowDiagSolution.cpp index 7c0069572b..9ffe5931f6 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimFlowDiagSolution.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimFlowDiagSolution.cpp @@ -70,8 +70,8 @@ QString RimFlowDiagSolution::addCrossFlowEnding( const QString& wellName ) //-------------------------------------------------------------------------------------------------- RimFlowDiagSolution::RimFlowDiagSolution( void ) { - CAF_PDM_InitObject( "Flow Diagnostics Solution", "", "", "" ); - CAF_PDM_InitField( &m_userDescription, "UserDescription", QString( "All Wells" ), "Description", "", "", "" ); + CAF_PDM_InitObject( "Flow Diagnostics Solution" ); + CAF_PDM_InitField( &m_userDescription, "UserDescription", QString( "All Wells" ), "Description" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimFlowPlotCollection.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimFlowPlotCollection.cpp index 251ee0ed3b..3c7153ac5f 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimFlowPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimFlowPlotCollection.cpp @@ -33,27 +33,24 @@ CAF_PDM_SOURCE_INIT( RimFlowPlotCollection, "FlowPlotCollection" ); //-------------------------------------------------------------------------------------------------- RimFlowPlotCollection::RimFlowPlotCollection() { - CAF_PDM_InitObject( "Flow Diagnostics Plots", ":/WellAllocPlots16x16.png", "", "" ); + CAF_PDM_InitObject( "Flow Diagnostics Plots", ":/WellAllocPlots16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_flowCharacteristicsPlot, "FlowCharacteristicsPlot", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_flowCharacteristicsPlot, "FlowCharacteristicsPlot", "" ); m_flowCharacteristicsPlot.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_defaultWellAllocPlot, "DefaultWellAllocationPlot", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_defaultWellAllocPlot, "DefaultWellAllocationPlot", "" ); m_defaultWellAllocPlot.uiCapability()->setUiTreeHidden( true ); - // CAF_PDM_InitFieldNoDefault( &m_dbgWellDistributionPlot, "DbgWellDistributionPlot", "", "", "", "" ); + // CAF_PDM_InitFieldNoDefault( &m_dbgWellDistributionPlot, "DbgWellDistributionPlot", ""); // m_dbgWellDistributionPlot.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_wellDistributionPlotCollection, "WellDistributionPlotCollection", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wellDistributionPlotCollection, "WellDistributionPlotCollection", "" ); m_wellDistributionPlotCollection.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_storedWellAllocPlots, "StoredWellAllocationPlots", "Stored Well Allocation Plots", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_storedWellAllocPlots, "StoredWellAllocationPlots", "Stored Well Allocation Plots" ); CAF_PDM_InitFieldNoDefault( &m_storedFlowCharacteristicsPlots, "StoredFlowCharacteristicsPlots", - "Stored Flow Characteristics Plots", - "", - "", - "" ); + "Stored Flow Characteristics Plots" ); } //-------------------------------------------------------------------------------------------------- @@ -63,7 +60,7 @@ RimFlowPlotCollection::~RimFlowPlotCollection() { delete m_defaultWellAllocPlot(); - m_storedWellAllocPlots.deleteAllChildObjects(); + m_storedWellAllocPlots.deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -81,8 +78,8 @@ void RimFlowPlotCollection::deleteAllPlots() // delete m_dbgWellDistributionPlot; delete m_wellDistributionPlotCollection; - m_storedWellAllocPlots.deleteAllChildObjects(); - m_storedFlowCharacteristicsPlots.deleteAllChildObjects(); + m_storedWellAllocPlots.deleteChildren(); + m_storedFlowCharacteristicsPlots.deleteChildren(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimTofAccumulatedPhaseFractionsPlot.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimTofAccumulatedPhaseFractionsPlot.cpp index a9967e0e49..293f875dfa 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimTofAccumulatedPhaseFractionsPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimTofAccumulatedPhaseFractionsPlot.cpp @@ -44,15 +44,15 @@ CAF_PDM_SOURCE_INIT( RimTofAccumulatedPhaseFractionsPlot, "TofAccumulatedPhaseFr //-------------------------------------------------------------------------------------------------- RimTofAccumulatedPhaseFractionsPlot::RimTofAccumulatedPhaseFractionsPlot() { - CAF_PDM_InitObject( "Cumulative Saturation by Time of Flight", ":/TOFAccSatPlot16x16.png", "", "" ); + CAF_PDM_InitObject( "Cumulative Saturation by Time of Flight", ":/TOFAccSatPlot16x16.png" ); - CAF_PDM_InitField( &m_userName, "PlotDescription", QString( "Cumulative Saturation by Time of Flight" ), "Name", "", "", "" ); + CAF_PDM_InitField( &m_userName, "PlotDescription", QString( "Cumulative Saturation by Time of Flight" ), "Name" ); m_userName.uiCapability()->setUiHidden( true ); - CAF_PDM_InitField( &m_showPlotTitle, "ShowPlotTitle", true, "Show Plot Title", "", "", "" ); + CAF_PDM_InitField( &m_showPlotTitle, "ShowPlotTitle", true, "Show Plot Title" ); m_showPlotTitle.uiCapability()->setUiHidden( true ); - CAF_PDM_InitField( &m_maxTof, "MaxTof", 50, "Max Time of Flight [year]", "", "", "" ); + CAF_PDM_InitField( &m_maxTof, "MaxTof", 50, "Max Time of Flight [year]" ); m_showWindow = false; } diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimTotalWellAllocationPlot.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimTotalWellAllocationPlot.cpp index 3551837b03..6442981c97 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimTotalWellAllocationPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimTotalWellAllocationPlot.cpp @@ -42,12 +42,12 @@ CAF_PDM_SOURCE_INIT( RimTotalWellAllocationPlot, "TotalWellAllocationPlot" ); //-------------------------------------------------------------------------------------------------- RimTotalWellAllocationPlot::RimTotalWellAllocationPlot() { - CAF_PDM_InitObject( "Total Allocation", ":/WellAllocPie16x16.png", "", "" ); + CAF_PDM_InitObject( "Total Allocation", ":/WellAllocPie16x16.png" ); - CAF_PDM_InitField( &m_userName, "PlotDescription", QString( "Total Allocation" ), "Name", "", "", "" ); + CAF_PDM_InitField( &m_userName, "PlotDescription", QString( "Total Allocation" ), "Name" ); m_userName.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitField( &m_showPlotTitle, "ShowPlotTitle", true, "Show Plot Title", "", "", "" ); + CAF_PDM_InitField( &m_showPlotTitle, "ShowPlotTitle", true, "Show Plot Title" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp index 54c262279e..f217257975 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp @@ -30,11 +30,11 @@ #include "RigWellResultPoint.h" #include "RimEclipseCase.h" +#include "RimEclipseCaseTools.h" #include "RimEclipseCellColors.h" #include "RimEclipseResultCase.h" #include "RimEclipseView.h" #include "RimFlowDiagSolution.h" -#include "RimProject.h" #include "RimSimWellInView.h" #include "RimSimWellInViewCollection.h" #include "RimTofAccumulatedPhaseFractionsPlot.h" @@ -43,11 +43,11 @@ #include "RimWellAllocationPlotLegend.h" #include "RimWellFlowRateCurve.h" #include "RimWellLogCurveCommonDataSource.h" +#include "RimWellLogFile.h" #include "RimWellLogPlot.h" #include "RimWellLogTrack.h" - -#include "RimWellLogFile.h" #include "RimWellPlotTools.h" + #include "RiuPlotMainWindow.h" #include "RiuQwtPlotWidget.h" #include "RiuWellAllocationPlot.h" @@ -74,12 +74,12 @@ void AppEnum::setUp() //-------------------------------------------------------------------------------------------------- RimWellAllocationPlot::RimWellAllocationPlot() { - CAF_PDM_InitObject( "Well Allocation Plot", ":/WellAllocPlot16x16.png", "", "" ); + CAF_PDM_InitObject( "Well Allocation Plot", ":/WellAllocPlot16x16.png" ); - CAF_PDM_InitField( &m_userName, "PlotDescription", QString( "Flow Diagnostics Plot" ), "Name", "", "", "" ); + CAF_PDM_InitField( &m_userName, "PlotDescription", QString( "Flow Diagnostics Plot" ), "Name" ); m_userName.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitField( &m_showPlotTitle, "ShowPlotTitle", true, "Show Plot Title", "", "", "" ); + CAF_PDM_InitField( &m_showPlotTitle, "ShowPlotTitle", true, "Show Plot Title" ); CAF_PDM_InitField( &m_branchDetection, "BranchDetection", @@ -89,16 +89,16 @@ RimWellAllocationPlot::RimWellAllocationPlot() "Compute branches based on how simulation well cells are organized", "" ); - CAF_PDM_InitFieldNoDefault( &m_case, "CurveCase", "Case", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_case, "CurveCase", "Case" ); m_case.uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitField( &m_timeStep, "PlotTimeStep", 0, "Time Step", "", "", "" ); - CAF_PDM_InitField( &m_wellName, "WellName", QString( "None" ), "Well", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_flowDiagSolution, "FlowDiagSolution", "Plot Type", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_flowType, "FlowType", "Flow Type", "", "", "" ); - CAF_PDM_InitField( &m_groupSmallContributions, "GroupSmallContributions", true, "Group Small Contributions", "", "", "" ); - CAF_PDM_InitField( &m_smallContributionsThreshold, "SmallContributionsThreshold", 0.005, "Threshold", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_accumulatedWellFlowPlot, "AccumulatedWellFlowPlot", "Accumulated Well Flow", "", "", "" ); + CAF_PDM_InitField( &m_timeStep, "PlotTimeStep", 0, "Time Step" ); + CAF_PDM_InitField( &m_wellName, "WellName", QString( "None" ), "Well" ); + CAF_PDM_InitFieldNoDefault( &m_flowDiagSolution, "FlowDiagSolution", "Plot Type" ); + CAF_PDM_InitFieldNoDefault( &m_flowType, "FlowType", "Flow Type" ); + CAF_PDM_InitField( &m_groupSmallContributions, "GroupSmallContributions", true, "Group Small Contributions" ); + CAF_PDM_InitField( &m_smallContributionsThreshold, "SmallContributionsThreshold", 0.005, "Threshold" ); + CAF_PDM_InitFieldNoDefault( &m_accumulatedWellFlowPlot, "AccumulatedWellFlowPlot", "Accumulated Well Flow" ); m_accumulatedWellFlowPlot.uiCapability()->setUiTreeHidden( true ); m_accumulatedWellFlowPlot = new RimWellLogPlot; m_accumulatedWellFlowPlot->setDepthUnit( RiaDefines::DepthUnitType::UNIT_NONE ); @@ -106,20 +106,17 @@ RimWellAllocationPlot::RimWellAllocationPlot() m_accumulatedWellFlowPlot->setLegendsVisible( false ); m_accumulatedWellFlowPlot->uiCapability()->setUiIconFromResourceString( ":/WellFlowPlot16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_totalWellAllocationPlot, "TotalWellFlowPlot", "Total Well Flow", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_totalWellAllocationPlot, "TotalWellFlowPlot", "Total Well Flow" ); m_totalWellAllocationPlot.uiCapability()->setUiTreeHidden( true ); m_totalWellAllocationPlot = new RimTotalWellAllocationPlot; - CAF_PDM_InitFieldNoDefault( &m_wellAllocationPlotLegend, "WellAllocLegend", "Legend", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wellAllocationPlotLegend, "WellAllocLegend", "Legend" ); m_wellAllocationPlotLegend.uiCapability()->setUiTreeHidden( true ); m_wellAllocationPlotLegend = new RimWellAllocationPlotLegend; CAF_PDM_InitFieldNoDefault( &m_tofAccumulatedPhaseFractionsPlot, "TofAccumulatedPhaseFractionsPlot", - "TOF Accumulated Phase Fractions", - "", - "", - "" ); + "TOF Accumulated Phase Fractions" ); m_tofAccumulatedPhaseFractionsPlot.uiCapability()->setUiTreeHidden( true ); m_tofAccumulatedPhaseFractionsPlot = new RimTofAccumulatedPhaseFractionsPlot; @@ -484,7 +481,7 @@ void RimWellAllocationPlot::updateWellFlowPlotXAxisTitle( RimWellLogTrack* plotT : RimWellLogFile::WELL_FLOW_COND_STANDARD; QString axisTitle = RimWellPlotTools::flowPlotAxisTitle( condition, unitSet ); - plotTrack->setXAxisTitle( axisTitle ); + plotTrack->setPropertyValueAxisTitle( axisTitle ); #if 0 if (m_flowDiagSolution) @@ -705,8 +702,7 @@ RimWellAllocationPlot::FlowType RimWellAllocationPlot::flowType() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList - RimWellAllocationPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) +QList RimWellAllocationPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; @@ -736,17 +732,10 @@ QList } else if ( fieldNeedingOptions == &m_case ) { - RimProject* proj = nullptr; - this->firstAncestorOrThisOfType( proj ); - if ( proj ) + auto resultCases = RimEclipseCaseTools::eclipseResultCases(); + for ( RimEclipseResultCase* c : resultCases ) { - std::vector cases; - proj->descendantsIncludingThisOfType( cases ); - - for ( RimEclipseResultCase* c : cases ) - { - options.push_back( caf::PdmOptionItemInfo( c->caseUserDescription(), c, false, c->uiIconProvider() ) ); - } + options.push_back( caf::PdmOptionItemInfo( c->caseUserDescription(), c, false, c->uiIconProvider() ) ); } } else if ( fieldNeedingOptions == &m_flowDiagSolution ) @@ -954,6 +943,9 @@ void RimWellAllocationPlot::onLoadDataAndUpdate() return; } + // Other plot functions depend on a valid plot widget, early reject to avoid a lot of testing on valid widget + if ( !m_wellAllocationPlotWidget ) return; + updateFromWell(); m_accumulatedWellFlowPlot->loadDataAndUpdate(); updateFormationNamesData(); diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellAllocationPlot.h b/ApplicationLibCode/ProjectDataModel/Flow/RimWellAllocationPlot.h index 8b3f02bd43..3b5f3cd2d5 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellAllocationPlot.h +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellAllocationPlot.h @@ -99,8 +99,7 @@ class RimWellAllocationPlot : public RimViewWindow std::set findSortedWellNames(); - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; QImage snapshotWindowContent() override; diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellAllocationPlotLegend.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimWellAllocationPlotLegend.cpp index 479752b735..ecf96e9600 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellAllocationPlotLegend.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellAllocationPlotLegend.cpp @@ -26,8 +26,8 @@ CAF_PDM_SOURCE_INIT( RimWellAllocationPlotLegend, "WellAllocationPlotLegend" ); //-------------------------------------------------------------------------------------------------- RimWellAllocationPlotLegend::RimWellAllocationPlotLegend() { - CAF_PDM_InitObject( "Legend", ":/WellAllocLegend16x16.png", "", "" ); - CAF_PDM_InitField( &m_showLegend, "ShowPlotLegend", true, "Show Plot Legend", "", "", "" ); + CAF_PDM_InitObject( "Legend", ":/WellAllocLegend16x16.png" ); + CAF_PDM_InitField( &m_showLegend, "ShowPlotLegend", true, "Show Plot Legend" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellDistributionPlot.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimWellDistributionPlot.cpp index e3d8aa4402..363404e5f8 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellDistributionPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellDistributionPlot.cpp @@ -17,9 +17,10 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RimWellDistributionPlot.h" + +#include "RimEclipseCaseTools.h" #include "RimEclipseResultCase.h" #include "RimFlowDiagSolution.h" -#include "RimProject.h" #include "RimTools.h" #include "RigEclipseCaseData.h" @@ -38,10 +39,6 @@ #include #include -//#include "cvfBase.h" -//#include "cvfTrace.h" -//#include "cvfDebugTimer.h" - #include //================================================================================================== @@ -59,22 +56,19 @@ RimWellDistributionPlot::RimWellDistributionPlot( RiaDefines::PhaseType phase ) { // cvf::Trace::show("RimWellDistributionPlot::RimWellDistributionPlot()"); - CAF_PDM_InitObject( "Cumulative Phase Distribution Plot", "", "", "" ); + CAF_PDM_InitObject( "Cumulative Phase Distribution Plot" ); - CAF_PDM_InitFieldNoDefault( &m_case, "Case", "Case", "", "", "" ); - CAF_PDM_InitField( &m_timeStepIndex, "TimeStepIndex", -1, "Time Step", "", "", "" ); - CAF_PDM_InitField( &m_wellName, "WellName", QString( "None" ), "Well", "", "", "" ); - CAF_PDM_InitField( &m_phase, "Phase", caf::AppEnum( phase ), "Phase", "", "", "" ); - CAF_PDM_InitField( &m_groupSmallContributions, "GroupSmallContributions", true, "Group Small Contributions", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_case, "Case", "Case" ); + CAF_PDM_InitField( &m_timeStepIndex, "TimeStepIndex", -1, "Time Step" ); + CAF_PDM_InitField( &m_wellName, "WellName", QString( "None" ), "Well" ); + CAF_PDM_InitField( &m_phase, "Phase", caf::AppEnum( phase ), "Phase" ); + CAF_PDM_InitField( &m_groupSmallContributions, "GroupSmallContributions", true, "Group Small Contributions" ); CAF_PDM_InitField( &m_smallContributionsRelativeThreshold, "SmallContributionsRelativeThreshold", 0.005, - "Relative Threshold [0, 1]", - "", - "", - "" ); + "Relative Threshold [0, 1]" ); - CAF_PDM_InitField( &m_maximumTof, "MaximumTOF", 20.0, "Maximum Time of Flight [0, 200]", "", "", "" ); + CAF_PDM_InitField( &m_maximumTof, "MaximumTOF", 20.0, "Maximum Time of Flight [0, 200]" ); m_showWindow = false; m_showPlotLegends = true; @@ -122,7 +116,7 @@ RiaDefines::PhaseType RimWellDistributionPlot::phase() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuQwtPlotWidget* RimWellDistributionPlot::viewer() +RiuPlotWidget* RimWellDistributionPlot::plotWidget() { return m_plotWidget; } @@ -173,28 +167,28 @@ void RimWellDistributionPlot::updateLegend() if ( doShowLegend ) { QwtLegend* legend = new QwtLegend( m_plotWidget ); - m_plotWidget->insertLegend( legend, QwtPlot::BottomLegend ); + m_plotWidget->qwtPlot()->insertLegend( legend, QwtPlot::BottomLegend ); } else { - m_plotWidget->insertLegend( nullptr ); + m_plotWidget->qwtPlot()->insertLegend( nullptr ); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellDistributionPlot::updateZoomInQwt() +void RimWellDistributionPlot::updateZoomInParentPlot() { - // cvf::Trace::show("RimWellDistributionPlot::updateZoomInQwt()"); + // cvf::Trace::show("RimWellDistributionPlot::updateZoomInParentPlot()"); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellDistributionPlot::updateZoomFromQwt() +void RimWellDistributionPlot::updateZoomFromParentPlot() { - // cvf::Trace::show("RimWellDistributionPlot::updateZoomFromQwt()"); + // cvf::Trace::show("RimWellDistributionPlot::updateZoomFromParentPlot()"); } //-------------------------------------------------------------------------------------------------- @@ -225,7 +219,7 @@ void RimWellDistributionPlot::detachAllCurves() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObject* RimWellDistributionPlot::findPdmObjectFromQwtCurve( const QwtPlotCurve* /*curve*/ ) const +caf::PdmObject* RimWellDistributionPlot::findPdmObjectFromPlotCurve( const RiuPlotCurve* /*curve*/ ) const { // cvf::Trace::show("RimWellDistributionPlot::findPdmObjectFromQwtCurve()"); return nullptr; @@ -234,7 +228,7 @@ caf::PdmObject* RimWellDistributionPlot::findPdmObjectFromQwtCurve( const QwtPlo //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellDistributionPlot::onAxisSelected( int /*axis*/, bool /*toggle*/ ) +void RimWellDistributionPlot::onAxisSelected( RiuPlotAxis /*axis*/, bool /*toggle*/ ) { // cvf::Trace::show("RimWellDistributionPlot::onAxisSelected()"); } @@ -285,7 +279,7 @@ void RimWellDistributionPlot::zoomAll() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuQwtPlotWidget* RimWellDistributionPlot::doCreatePlotViewWidget( QWidget* mainWindowParent ) +RiuPlotWidget* RimWellDistributionPlot::doCreatePlotViewWidget( QWidget* mainWindowParent ) { // cvf::Trace::show("RimWellDistributionPlot::createViewWidget()"); @@ -297,7 +291,7 @@ RiuQwtPlotWidget* RimWellDistributionPlot::doCreatePlotViewWidget( QWidget* main m_plotWidget = new RiuQwtPlotWidget( this, mainWindowParent ); - m_plotWidget->setAutoReplot( false ); + m_plotWidget->qwtPlot()->setAutoReplot( false ); updateLegend(); onLoadDataAndUpdate(); @@ -342,7 +336,7 @@ void RimWellDistributionPlot::onLoadDataAndUpdate() return; } - m_plotWidget->detachItems( QwtPlotItem::Rtti_PlotCurve ); + m_plotWidget->qwtPlot()->detachItems( QwtPlotItem::Rtti_PlotCurve ); updateLegend(); @@ -377,12 +371,12 @@ void RimWellDistributionPlot::onLoadDataAndUpdate() const QString plotTitleStr = QString( "%1 Distribution: %2, %3" ).arg( phaseString ).arg( m_wellName ).arg( timeStepName ); - m_plotWidget->setTitle( plotTitleStr ); + m_plotWidget->setPlotTitle( plotTitleStr ); - m_plotWidget->setAxisTitleText( QwtPlot::xBottom, "TOF [years]" ); - m_plotWidget->setAxisTitleText( QwtPlot::yLeft, "Reservoir Volume [m3]" ); - m_plotWidget->setAxisTitleEnabled( QwtPlot::xBottom, true ); - m_plotWidget->setAxisTitleEnabled( QwtPlot::yLeft, true ); + m_plotWidget->setAxisTitleText( RiuPlotAxis::defaultBottom(), "TOF [years]" ); + m_plotWidget->setAxisTitleText( RiuPlotAxis::defaultLeft(), "Reservoir Volume [m3]" ); + m_plotWidget->setAxisTitleEnabled( RiuPlotAxis::defaultBottom(), true ); + m_plotWidget->setAxisTitleEnabled( RiuPlotAxis::defaultLeft(), true ); m_plotWidget->scheduleReplot(); } @@ -400,11 +394,11 @@ void RimWellDistributionPlot::populatePlotWidgetWithCurveData( const RigTofWellD // Currently select this value so that the grid appears on top of the curves const double baseCurveZValue = 9.5; - plotWidget->detachItems( QwtPlotItem::Rtti_PlotCurve ); - plotWidget->setAxisScale( QwtPlot::xBottom, 0, 1 ); - plotWidget->setAxisScale( QwtPlot::yLeft, 0, 1 ); - plotWidget->setAxisAutoScale( QwtPlot::xBottom, true ); - plotWidget->setAxisAutoScale( QwtPlot::yLeft, true ); + plotWidget->qwtPlot()->detachItems( QwtPlotItem::Rtti_PlotCurve ); + plotWidget->setAxisScale( RiuPlotAxis::defaultBottom(), 0, 1 ); + plotWidget->setAxisScale( RiuPlotAxis::defaultLeft(), 0, 1 ); + plotWidget->setAxisAutoScale( RiuPlotAxis::defaultBottom(), true ); + plotWidget->setAxisAutoScale( RiuPlotAxis::defaultLeft(), true ); const std::vector& tofValuesDays = calculator.sortedUniqueTofValues(); if ( tofValuesDays.size() == 0 ) @@ -452,7 +446,7 @@ void RimWellDistributionPlot::populatePlotWidgetWithCurveData( const RigTofWellD curve->setBrush( qtClr ); curve->setZ( baseCurveZValue - i * 0.0001 ); curve->setSamples( tofValuesYears.data(), yVals.data(), static_cast( tofValuesYears.size() ) ); - curve->attach( plotWidget ); + curve->attach( plotWidget->qwtPlot() ); } } @@ -477,23 +471,16 @@ void RimWellDistributionPlot::defineUiOrdering( QString uiConfigName, caf::PdmUi //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList - RimWellDistributionPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) +QList RimWellDistributionPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { - QList options = RimPlot::calculateValueOptions( fieldNeedingOptions, useOptionsOnly ); + QList options = RimPlot::calculateValueOptions( fieldNeedingOptions ); if ( fieldNeedingOptions == &m_case ) { - RimProject* ownerProj = nullptr; - firstAncestorOrThisOfType( ownerProj ); - if ( ownerProj ) + auto resultCases = RimEclipseCaseTools::eclipseResultCases(); + for ( RimEclipseResultCase* c : resultCases ) { - std::vector caseArr; - ownerProj->descendantsIncludingThisOfType( caseArr ); - for ( RimEclipseResultCase* c : caseArr ) - { - options.push_back( caf::PdmOptionItemInfo( c->caseUserDescription(), c, true, c->uiIconProvider() ) ); - } + options.push_back( caf::PdmOptionItemInfo( c->caseUserDescription(), c, true, c->uiIconProvider() ) ); } } diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellDistributionPlot.h b/ApplicationLibCode/ProjectDataModel/Flow/RimWellDistributionPlot.h index f3e05d96ae..5637b1410b 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellDistributionPlot.h +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellDistributionPlot.h @@ -49,18 +49,18 @@ class RimWellDistributionPlot : public RimPlot RiaDefines::PhaseType phase() const; // RimPlot implementations - RiuQwtPlotWidget* viewer() override; - void setAutoScaleXEnabled( bool enabled ) override; - void setAutoScaleYEnabled( bool enabled ) override; - void updateAxes() override; - void updateLegend() override; - void updateZoomInQwt() override; - void updateZoomFromQwt() override; - QString asciiDataForPlotExport() const override; - void reattachAllCurves() override; - void detachAllCurves() override; - caf::PdmObject* findPdmObjectFromQwtCurve( const QwtPlotCurve* curve ) const override; - void onAxisSelected( int axis, bool toggle ) override; + RiuPlotWidget* plotWidget() override; + void setAutoScaleXEnabled( bool enabled ) override; + void setAutoScaleYEnabled( bool enabled ) override; + void updateAxes() override; + void updateLegend() override; + void updateZoomInParentPlot() override; + void updateZoomFromParentPlot() override; + QString asciiDataForPlotExport() const override; + void reattachAllCurves() override; + void detachAllCurves() override; + caf::PdmObject* findPdmObjectFromPlotCurve( const RiuPlotCurve* curve ) const override; + void onAxisSelected( RiuPlotAxis axis, bool toggle ) override; // RimPlotWindow implementations QString description() const override; @@ -76,7 +76,7 @@ class RimWellDistributionPlot : public RimPlot void onLoadDataAndUpdate() override; private: - RiuQwtPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent ) override; + RiuPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent ) override; void fixupDependentFieldsAfterCaseChange(); static void populatePlotWidgetWithCurveData( const RigTofWellDistributionCalculator& calculator, @@ -87,8 +87,7 @@ class RimWellDistributionPlot : public RimPlot void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; private: caf::PdmPtrField m_case; diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellDistributionPlotCollection.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimWellDistributionPlotCollection.cpp index 68d47b1e6a..38974363b0 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellDistributionPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellDistributionPlotCollection.cpp @@ -17,10 +17,11 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RimWellDistributionPlotCollection.h" + +#include "RimEclipseCaseTools.h" #include "RimEclipseResultCase.h" #include "RimFlowDiagSolution.h" #include "RimPlot.h" -#include "RimProject.h" #include "RimTools.h" #include "RimWellDistributionPlot.h" @@ -30,7 +31,9 @@ #include "RiaColorTools.h" #include "RiuMultiPlotPage.h" +#include "RiuPlotWidget.h" #include "RiuQwtPlotTools.h" +#include "RiuQwtPlotWidget.h" #include "qwt_legend.h" #include "qwt_plot.h" @@ -40,10 +43,6 @@ #include #include -//#include "cvfBase.h" -//#include "cvfTrace.h" -//#include "cvfDebugTimer.h" - //================================================================================================== // // @@ -59,37 +58,28 @@ RimWellDistributionPlotCollection::RimWellDistributionPlotCollection() { // cvf::Trace::show("RimWellDistributionPlotCollection::RimWellDistributionPlotCollection()"); - CAF_PDM_InitObject( "Cumulative Phase Distribution Plot", ":/CumulativePhaseDist16x16.png", "", "" ); + CAF_PDM_InitObject( "Cumulative Phase Distribution Plot", ":/CumulativePhaseDist16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_case, "Case", "Case", "", "", "" ); - CAF_PDM_InitField( &m_timeStepIndex, "TimeStepIndex", -1, "Time Step", "", "", "" ); - CAF_PDM_InitField( &m_wellName, "WellName", QString( "None" ), "Well", "", "", "" ); - CAF_PDM_InitField( &m_groupSmallContributions, "GroupSmallContributions", true, "Group Small Contributions", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_case, "Case", "Case" ); + CAF_PDM_InitField( &m_timeStepIndex, "TimeStepIndex", -1, "Time Step" ); + CAF_PDM_InitField( &m_wellName, "WellName", QString( "None" ), "Well" ); + CAF_PDM_InitField( &m_groupSmallContributions, "GroupSmallContributions", true, "Group Small Contributions" ); CAF_PDM_InitField( &m_smallContributionsRelativeThreshold, "SmallContributionsRelativeThreshold", 0.005, - "Relative Threshold [0, 1]", - "", - "", - "" ); + "Relative Threshold [0, 1]" ); - CAF_PDM_InitField( &m_maximumTof, "MaximumTOF", 20.0, "Maximum Time of Flight [0, 200]", "", "", "" ); + CAF_PDM_InitField( &m_maximumTof, "MaximumTOF", 20.0, "Maximum Time of Flight [0, 200]" ); - CAF_PDM_InitFieldNoDefault( &m_plots, "Plots", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_plots, "Plots", "" ); m_plots.uiCapability()->setUiTreeHidden( true ); m_plots.uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitField( &m_showOil, "ShowOil", true, "Show Oil", "", "", "" ); - CAF_PDM_InitField( &m_showGas, "ShowGas", true, "Show Gas", "", "", "" ); - CAF_PDM_InitField( &m_showWater, "ShowWater", true, "Show Water", "", "", "" ); + CAF_PDM_InitField( &m_showOil, "ShowOil", true, "Show Oil" ); + CAF_PDM_InitField( &m_showGas, "ShowGas", true, "Show Gas" ); + CAF_PDM_InitField( &m_showWater, "ShowWater", true, "Show Water" ); - CAF_PDM_InitField( &m_plotWindowTitle, - "PlotDescription", - QString( "Cumulative Phase Distribution Plots" ), - "Name", - "", - "", - "" ); + CAF_PDM_InitField( &m_plotWindowTitle, "PlotDescription", QString( "Cumulative Phase Distribution Plots" ), "Name" ); m_showWindow = false; @@ -106,7 +96,7 @@ RimWellDistributionPlotCollection::RimWellDistributionPlotCollection() RimWellDistributionPlotCollection::~RimWellDistributionPlotCollection() { removeMdiWindowFromMdiArea(); - m_plots.deleteAllChildObjects(); + m_plots.deleteChildren(); cleanupBeforeClose(); } @@ -226,7 +216,7 @@ void RimWellDistributionPlotCollection::addPlot( RimPlot* plot ) if ( m_viewer ) { plot->createPlotWidget(); - m_viewer->insertPlot( plot->viewer(), index ); + m_viewer->insertPlot( plot->plotWidget(), index ); } plot->setShowWindow( true ); plot->setLegendsVisible( false ); @@ -259,23 +249,16 @@ void RimWellDistributionPlotCollection::defineUiOrdering( QString uiConfigName, /// //-------------------------------------------------------------------------------------------------- QList - RimWellDistributionPlotCollection::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) + RimWellDistributionPlotCollection::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { - QList options = RimPlotWindow::calculateValueOptions( fieldNeedingOptions, useOptionsOnly ); + QList options = RimPlotWindow::calculateValueOptions( fieldNeedingOptions ); if ( fieldNeedingOptions == &m_case ) { - RimProject* ownerProj = nullptr; - firstAncestorOrThisOfType( ownerProj ); - if ( ownerProj ) + auto resultCases = RimEclipseCaseTools::eclipseResultCases(); + for ( RimEclipseResultCase* c : resultCases ) { - std::vector caseArr; - ownerProj->descendantsIncludingThisOfType( caseArr ); - for ( RimEclipseResultCase* c : caseArr ) - { - options.push_back( caf::PdmOptionItemInfo( c->caseUserDescription(), c, true, c->uiIconProvider() ) ); - } + options.push_back( caf::PdmOptionItemInfo( c->caseUserDescription(), c, true, c->uiIconProvider() ) ); } } @@ -382,7 +365,7 @@ void RimWellDistributionPlotCollection::updatePlots() for ( RimPlot* plot : m_plots() ) { plot->loadDataAndUpdate(); - plot->updateZoomInQwt(); + plot->updateZoomInParentPlot(); } } } @@ -392,7 +375,7 @@ void RimWellDistributionPlotCollection::updatePlots() //-------------------------------------------------------------------------------------------------- void RimWellDistributionPlotCollection::cleanupBeforeClose() { - auto plotVector = m_plots.childObjects(); + auto plotVector = m_plots.children(); for ( size_t tIdx = 0; tIdx < plotVector.size(); ++tIdx ) { plotVector[tIdx]->detachAllCurves(); @@ -416,7 +399,7 @@ void RimWellDistributionPlotCollection::recreatePlotWidgets() for ( auto plot : m_plots() ) { plot->createPlotWidget(); - m_viewer->addPlot( plot->viewer() ); + m_viewer->addPlot( plot->plotWidget() ); } } diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellDistributionPlotCollection.h b/ApplicationLibCode/ProjectDataModel/Flow/RimWellDistributionPlotCollection.h index d3184e5f06..840addfaee 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellDistributionPlotCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellDistributionPlotCollection.h @@ -62,8 +62,7 @@ class RimWellDistributionPlotCollection : public RimPlotWindow private: // RimPlotWindow overrides - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void onLoadDataAndUpdate() override; diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellFlowRateCurve.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimWellFlowRateCurve.cpp index 71c8b784ba..83d18d5af3 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellFlowRateCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellFlowRateCurve.cpp @@ -46,7 +46,7 @@ CAF_PDM_SOURCE_INIT( RimWellFlowRateCurve, "WellFlowRateCurve" ); //-------------------------------------------------------------------------------------------------- RimWellFlowRateCurve::RimWellFlowRateCurve() { - CAF_PDM_InitObject( "Flow Rate Curve", "", "", "" ); + CAF_PDM_InitObject( "Flow Rate Curve" ); m_groupId = 0; m_doFillCurve = true; } @@ -161,7 +161,7 @@ void RimWellFlowRateCurve::onLoadDataAndUpdate( bool updateParentPlot ) { this->RimPlotCurve::updateCurvePresentation( updateParentPlot ); - m_qwtPlotCurve->setTitle( createCurveAutoName() ); + m_plotCurve->setTitle( createCurveAutoName() ); if ( updateParentPlot ) { @@ -172,7 +172,7 @@ void RimWellFlowRateCurve::onLoadDataAndUpdate( bool updateParentPlot ) updateZoomInParentPlot(); } - if ( m_parentQwtPlot ) m_parentQwtPlot->replot(); + if ( hasParentPlot() ) m_parentPlot->replot(); } //-------------------------------------------------------------------------------------------------- @@ -195,9 +195,11 @@ void RimWellFlowRateCurve::updateCurveAppearance() } } - if ( isUsingConnectionNumberDepthType() ) + QwtPlotCurve* qwtPlotCurve = dynamic_cast( m_plotCurve ); + if ( isUsingConnectionNumberDepthType() && qwtPlotCurve ) { - m_qwtPlotCurve->setStyle( QwtPlotCurve::Steps ); + // Steps style only for Qwt. + qwtPlotCurve->setStyle( QwtPlotCurve::Steps ); } if ( m_doFillCurve || isLastCurveInGroup ) // Fill the last curve in group with a transparent color to "tie" the @@ -222,14 +224,19 @@ void RimWellFlowRateCurve::updateCurveAppearance() gradient.setColorAt( 0.6, fillColor ); gradient.setColorAt( 0.8, fillColor.darker( 110 ) ); gradient.setColorAt( 1, fillColor ); - m_qwtPlotCurve->setBrush( gradient ); - - QPen curvePen = m_qwtPlotCurve->pen(); - curvePen.setColor( lineColor ); - m_qwtPlotCurve->setPen( curvePen ); - m_qwtPlotCurve->setOrientation( Qt::Horizontal ); - m_qwtPlotCurve->setBaseline( 0.0 ); - m_qwtPlotCurve->setCurveAttribute( QwtPlotCurve::Inverted, true ); + m_plotCurve->setBrush( gradient ); + + if ( qwtPlotCurve ) + { + // Baseline and orientation only available for Qwt. + QPen curvePen = qwtPlotCurve->pen(); + curvePen.setColor( lineColor ); + qwtPlotCurve->setPen( curvePen ); + qwtPlotCurve->setOrientation( Qt::Horizontal ); + qwtPlotCurve->setBaseline( 0.0 ); + + qwtPlotCurve->setCurveAttribute( QwtPlotCurve::Inverted, true ); + } } } @@ -293,7 +300,14 @@ void RimWellFlowRateCurve::setFlowValuesPrDepthValue( const QString& const std::vector& depthValues, const std::vector& flowRates ) { - this->setValuesAndDepths( flowRates, depthValues, depthType, 0.0, RiaDefines::DepthUnitType::UNIT_NONE, false ); + bool useLogarithmicScale = false; + this->setPropertyValuesAndDepths( flowRates, + depthValues, + depthType, + 0.0, + RiaDefines::DepthUnitType::UNIT_NONE, + false, + useLogarithmicScale ); m_curveAutoName = curveName; } diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.cpp index 2f334984b3..8468462101 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.cpp @@ -550,13 +550,16 @@ std::set RimWellPlotTools::availableSimWellTimesteps( RimEclipseCase* const QString& simWellName, bool addFirstReportTimestep ) { + if ( !eclCase || !eclCase->eclipseCaseData() ) return {}; + std::set availebleTimeSteps; - if ( eclCase && eclCase->eclipseCaseData() ) + const RigSimWellData* simWell = eclCase->eclipseCaseData()->findSimWellData( simWellName ); + + if ( simWell ) { std::vector allTimeSteps = eclCase->eclipseCaseData()->results( RiaDefines::PorosityModelType::MATRIX_MODEL )->timeStepDates(); - const RigSimWellData* simWell = eclCase->eclipseCaseData()->findSimWellData( simWellName ); for ( size_t tsIdx = 0; tsIdx < allTimeSteps.size(); ++tsIdx ) { @@ -950,7 +953,7 @@ std::map> RimWellPlotTools::calculat const std::vector& selSources, const std::set& interestingRFTResults ) { - bool addFirstTimestep = ( interestingRFTResults.count( RifEclipseRftAddress::PRESSURE ) == 1 ); + bool addFirstTimestep = ( interestingRFTResults.count( RifEclipseRftAddress::RftWellLogChannelType::PRESSURE ) == 1 ); const QString simWellName = RimWellPlotTools::simWellName( wellPathNameOrSimWellName ); diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellPltPlot.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimWellPltPlot.cpp index 77e866a49f..f07a0a66d1 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellPltPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellPltPlot.cpp @@ -98,32 +98,32 @@ const char RimWellPltPlot::PLOT_NAME_QFORMAT_STRING[] = "PLT: %1"; RimWellPltPlot::RimWellPltPlot() : RimWellLogPlot() { - CAF_PDM_InitObject( "Well Allocation Plot", ":/WellFlowPlot16x16.png", "", "" ); + CAF_PDM_InitObject( "Well Allocation Plot", ":/WellFlowPlot16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_wellLogPlot_OBSOLETE, "WellLog", "WellLog", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wellLogPlot_OBSOLETE, "WellLog", "WellLog" ); m_wellLogPlot_OBSOLETE.uiCapability()->setUiTreeHidden( true ); m_wellLogPlot_OBSOLETE.xmlCapability()->setIOWritable( false ); - CAF_PDM_InitFieldNoDefault( &m_wellPathName, "WellName", "Well Name", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wellPathName, "WellName", "Well Name" ); - CAF_PDM_InitFieldNoDefault( &m_selectedSources, "SourcesInternal", "Sources Internal", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_selectedSources, "SourcesInternal", "Sources Internal" ); m_selectedSources.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); m_selectedSources.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); m_selectedSources.uiCapability()->setAutoAddingOptionFromValue( false ); m_selectedSources.xmlCapability()->disableIO(); - CAF_PDM_InitFieldNoDefault( &m_selectedSourcesForIo, "Sources", "Sources", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_selectedSourcesForIo, "Sources", "Sources" ); m_selectedSourcesForIo.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_selectedTimeSteps, "TimeSteps", "Time Steps", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_selectedTimeSteps, "TimeSteps", "Time Steps" ); m_selectedTimeSteps.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); m_selectedTimeSteps.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); m_selectedTimeSteps.uiCapability()->setAutoAddingOptionFromValue( false ); - CAF_PDM_InitField( &m_useStandardConditionCurves, "UseStandardConditionCurves", true, "Standard Volume", "", "", "" ); - CAF_PDM_InitField( &m_useReservoirConditionCurves, "UseReservoirConditionCurves", true, "Reservoir Volume", "", "", "" ); + CAF_PDM_InitField( &m_useStandardConditionCurves, "UseStandardConditionCurves", true, "Standard Volume" ); + CAF_PDM_InitField( &m_useReservoirConditionCurves, "UseReservoirConditionCurves", true, "Reservoir Volume" ); - CAF_PDM_InitFieldNoDefault( &m_phases, "Phases", "Phases", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_phases, "Phases", "Phases" ); m_phases.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); m_phases = std::vector>( { FLOW_PHASE_OIL, FLOW_PHASE_GAS, FLOW_PHASE_WATER } ); m_phases.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); @@ -188,7 +188,7 @@ void RimWellPltPlot::setPlotXAxisTitles( RimWellLogTrack* plotTrack ) if ( m_useStandardConditionCurves ) axisTitle += RimWellPlotTools::flowPlotAxisTitle( RimWellLogFile::WELL_FLOW_COND_STANDARD, unitSet ); - plotTrack->setXAxisTitle( axisTitle ); + plotTrack->setPropertyValueAxisTitle( axisTitle ); #if 0 QString unitText; @@ -300,15 +300,18 @@ class RigRftResultPointCalculator : public RigResultPointCalculator public: RigRftResultPointCalculator( const QString& wellPathName, RimEclipseResultCase* eclCase, QDateTime m_timeStep ) { - RifEclipseRftAddress gasRateAddress( RimWellPlotTools::simWellName( wellPathName ), - m_timeStep, - RifEclipseRftAddress::GRAT ); - RifEclipseRftAddress oilRateAddress( RimWellPlotTools::simWellName( wellPathName ), - m_timeStep, - RifEclipseRftAddress::ORAT ); - RifEclipseRftAddress watRateAddress( RimWellPlotTools::simWellName( wellPathName ), - m_timeStep, - RifEclipseRftAddress::WRAT ); + RifEclipseRftAddress gasRateAddress = + RifEclipseRftAddress::createAddress( RimWellPlotTools::simWellName( wellPathName ), + m_timeStep, + RifEclipseRftAddress::RftWellLogChannelType::GRAT ); + RifEclipseRftAddress oilRateAddress = + RifEclipseRftAddress::createAddress( RimWellPlotTools::simWellName( wellPathName ), + m_timeStep, + RifEclipseRftAddress::RftWellLogChannelType::ORAT ); + RifEclipseRftAddress watRateAddress = + RifEclipseRftAddress::createAddress( RimWellPlotTools::simWellName( wellPathName ), + m_timeStep, + RifEclipseRftAddress::RftWellLogChannelType::WRAT ); std::vector rftIndices; eclCase->rftReader()->cellIndices( gasRateAddress, &rftIndices ); @@ -685,7 +688,7 @@ void RimWellPltPlot::syncCurvesFromUiSelection() curveGroupId++; } - plotTrack->setAutoScaleXEnabled( true ); + plotTrack->setAutoScalePropertyValuesEnabled( true ); RimWellLogPlot::onLoadDataAndUpdate(); } @@ -709,7 +712,7 @@ void RimWellPltPlot::addStackedCurve( const QString& curveName, if ( curveGroupId == 0 ) { curve->setDoFillCurve( true ); - curve->setSymbol( RiuQwtSymbol::SYMBOL_NONE ); + curve->setSymbol( RiuPlotCurveSymbol::SYMBOL_NONE ); } else { @@ -761,10 +764,9 @@ const char* RimWellPltPlot::plotNameFormatString() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimWellPltPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RimWellPltPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { - QList options = RimWellLogPlot::calculateValueOptions( fieldNeedingOptions, useOptionsOnly ); + QList options = RimWellLogPlot::calculateValueOptions( fieldNeedingOptions ); const QString simWellName = RimWellPlotTools::simWellName( m_wellPathName ); @@ -918,7 +920,7 @@ void RimWellPltPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField, RimWellLogTrack* const plotTrack = dynamic_cast( plotByIndex( 0 ) ); if ( plotTrack ) { - plotTrack->setAutoScaleXEnabled( true ); + plotTrack->setAutoScalePropertyValuesEnabled( true ); } updateZoom(); } @@ -931,7 +933,7 @@ void RimWellPltPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField, RimWellLogTrack* const plotTrack = dynamic_cast( plotByIndex( 0 ) ); if ( plotTrack ) { - plotTrack->setAutoScaleXEnabled( true ); + plotTrack->setAutoScalePropertyValuesEnabled( true ); } updateZoom(); } @@ -1046,7 +1048,7 @@ void RimWellPltPlot::initAfterLoad() //-------------------------------------------------------------------------------------------------- void RimWellPltPlot::syncSourcesIoFieldFromGuiField() { - m_selectedSourcesForIo.clear(); + m_selectedSourcesForIo.deleteChildren(); for ( const RifDataSourceForRftPlt& addr : m_selectedSources() ) { diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellPltPlot.h b/ApplicationLibCode/ProjectDataModel/Flow/RimWellPltPlot.h index e8ec7c4b74..3f8d3f07f3 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellPltPlot.h +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellPltPlot.h @@ -78,8 +78,7 @@ class RimWellPltPlot : public RimWellLogPlot void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void calculateValueOptionsForWells( QList& options ); void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftEnsembleCurveSet.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftEnsembleCurveSet.cpp index 6a66cdb702..e43294fbbb 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftEnsembleCurveSet.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftEnsembleCurveSet.cpp @@ -38,22 +38,22 @@ CAF_PDM_SOURCE_INIT( RimWellRftEnsembleCurveSet, "WellRftEnsembleCurveSet" ); //-------------------------------------------------------------------------------------------------- RimWellRftEnsembleCurveSet::RimWellRftEnsembleCurveSet() { - CAF_PDM_InitObject( "Ensemble Curve Set", ":/EnsembleCurveSet16x16.png", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_ensemble, "Ensemble", "Ensemble", "", "", "" ); + CAF_PDM_InitObject( "Ensemble Curve Set", ":/EnsembleCurveSet16x16.png" ); + CAF_PDM_InitFieldNoDefault( &m_ensemble, "Ensemble", "Ensemble" ); m_ensemble.uiCapability()->setUiTreeChildrenHidden( true ); m_ensemble.uiCapability()->setAutoAddingOptionFromValue( false ); - CAF_PDM_InitFieldNoDefault( &m_ensembleName, "NameAndUnit", "NameAndUnit", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_ensembleName, "NameAndUnit", "NameAndUnit" ); m_ensembleName.registerGetMethod( this, &RimWellRftEnsembleCurveSet::ensembleName ); m_ensembleName.uiCapability()->setUiHidden( true ); m_ensembleName.xmlCapability()->disableIO(); - CAF_PDM_InitField( &m_ensembleColorMode, "ColorMode", ColorModeEnum( ColorMode::SINGLE_COLOR ), "Coloring Mode", "", "", "" ); + CAF_PDM_InitField( &m_ensembleColorMode, "ColorMode", ColorModeEnum( ColorMode::SINGLE_COLOR ), "Coloring Mode" ); - CAF_PDM_InitField( &m_ensembleParameter, "EnsembleParameter", QString( "" ), "Ensemble Parameter", "", "", "" ); + CAF_PDM_InitField( &m_ensembleParameter, "EnsembleParameter", QString( "" ), "Ensemble Parameter" ); m_ensembleParameter.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_ensembleLegendConfig, "LegendConfig", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_ensembleLegendConfig, "LegendConfig", "" ); m_ensembleLegendConfig = new RimRegularLegendConfig(); m_ensembleLegendConfig->setColorLegend( RimRegularLegendConfig::mapToColorLegend( RimEnsembleCurveSetColorManager::DEFAULT_ENSEMBLE_COLOR_RANGE ) ); @@ -195,7 +195,7 @@ void RimWellRftEnsembleCurveSet::fieldChangedByUi( const caf::PdmFieldHandle* ch /// //-------------------------------------------------------------------------------------------------- QList - RimWellRftEnsembleCurveSet::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) + RimWellRftEnsembleCurveSet::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; if ( fieldNeedingOptions == &m_ensembleParameter ) diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftEnsembleCurveSet.h b/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftEnsembleCurveSet.h index b50f2a7136..51d2ac6647 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftEnsembleCurveSet.h +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftEnsembleCurveSet.h @@ -60,8 +60,7 @@ class RimWellRftEnsembleCurveSet : public caf::PdmObject protected: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.cpp index b3d1838b28..6da96b0eaf 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.cpp @@ -82,20 +82,20 @@ const char RimWellRftPlot::PLOT_NAME_QFORMAT_STRING[] = "RFT: %1"; RimWellRftPlot::RimWellRftPlot() : RimWellLogPlot() { - CAF_PDM_InitObject( "RFT Plot", ":/RFTPlot16x16.png", "", "" ); + CAF_PDM_InitObject( "RFT Plot", ":/RFTPlot16x16.png" ); - CAF_PDM_InitField( &m_showStatisticsCurves, "ShowStatisticsCurves", true, "Show Statistics Curves", "", "", "" ); - CAF_PDM_InitField( &m_showEnsembleCurves, "ShowEnsembleCurves", true, "Show Ensemble Curves", "", "", "" ); - CAF_PDM_InitField( &m_showErrorInObservedData, "ShowErrorObserved", true, "Show Observed Data Error", "", "", "" ); + CAF_PDM_InitField( &m_showStatisticsCurves, "ShowStatisticsCurves", true, "Show Statistics Curves" ); + CAF_PDM_InitField( &m_showEnsembleCurves, "ShowEnsembleCurves", true, "Show Ensemble Curves" ); + CAF_PDM_InitField( &m_showErrorInObservedData, "ShowErrorObserved", true, "Show Observed Data Error" ); - CAF_PDM_InitFieldNoDefault( &m_wellLogPlot_OBSOLETE, "WellLog", "Well Log", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wellLogPlot_OBSOLETE, "WellLog", "Well Log" ); m_wellLogPlot_OBSOLETE.uiCapability()->setUiTreeHidden( true ); m_wellLogPlot_OBSOLETE.xmlCapability()->setIOWritable( false ); m_depthType = RiaDefines::DepthTypeEnum::TRUE_VERTICAL_DEPTH; - CAF_PDM_InitFieldNoDefault( &m_wellPathNameOrSimWellName, "WellName", "Well Name", "", "", "" ); - CAF_PDM_InitField( &m_branchIndex, "BranchIndex", 0, "Branch Index", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wellPathNameOrSimWellName, "WellName", "Well Name" ); + CAF_PDM_InitField( &m_branchIndex, "BranchIndex", 0, "Branch Index" ); CAF_PDM_InitField( &m_branchDetection, "BranchDetection", true, @@ -104,24 +104,24 @@ RimWellRftPlot::RimWellRftPlot() "Compute branches based on how simulation well cells are organized", "" ); - CAF_PDM_InitFieldNoDefault( &m_selectedSources, "Sources", "Sources", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_selectedSources, "Sources", "Sources" ); m_selectedSources.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); m_selectedSources.xmlCapability()->disableIO(); m_selectedSources.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); m_selectedSources.uiCapability()->setAutoAddingOptionFromValue( false ); - CAF_PDM_InitFieldNoDefault( &m_selectedTimeSteps, "TimeSteps", "Time Steps", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_selectedTimeSteps, "TimeSteps", "Time Steps" ); m_selectedTimeSteps.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); m_selectedTimeSteps.xmlCapability()->disableIO(); m_selectedTimeSteps.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); m_selectedTimeSteps.uiCapability()->setAutoAddingOptionFromValue( false ); - CAF_PDM_InitFieldNoDefault( &m_wellPathCollection, "WellPathCollection", "Well Path Collection", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wellPathCollection, "WellPathCollection", "Well Path Collection" ); m_wellPathCollection.uiCapability()->setUiHidden( true ); m_wellPathCollection.xmlCapability()->disableIO(); m_wellPathCollection = RimProject::current()->activeOilField()->wellPathCollection(); - CAF_PDM_InitFieldNoDefault( &m_ensembleCurveSets, "EnsembleCurveSets", "Ensemble Curve Sets", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_ensembleCurveSets, "EnsembleCurveSets", "Ensemble Curve Sets" ); // TODO: may want to support TRUE_VERTICAL_DEPTH_RKB in the future // It was developed for regular well log plots and requires some more work for RFT plots. @@ -156,7 +156,7 @@ void RimWellRftPlot::applyCurveAppearance( RimWellLogCurve* curve ) RiaRftPltCurveDefinition curveDef = RimWellPlotTools::curveDefFromCurve( curve ); RiuQwtPlotCurveDefines::LineStyleEnum lineStyle = RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID; - RiuQwtSymbol::PointSymbolEnum currentSymbol = RiuQwtSymbol::SYMBOL_NONE; + RiuPlotCurveSymbol::PointSymbolEnum currentSymbol = RiuPlotCurveSymbol::SYMBOL_NONE; if ( curveDef.address().sourceType() != RifDataSourceForRftPlt::ENSEMBLE_RFT ) { currentSymbol = m_timeStepSymbols[curveDef.timeStep()]; @@ -327,8 +327,7 @@ void RimWellRftPlot::updateEditorsFromPreviousSelection() m_selectedSources.v().clear(); m_selectedTimeSteps.v().clear(); - bool dummy = false; - auto dataSourceOptions = calculateValueOptions( &m_selectedSources, &dummy ); + auto dataSourceOptions = calculateValueOptions( &m_selectedSources ); for ( const auto& dataSourceOption : dataSourceOptions ) { if ( dataSourceOption.level() == 1 ) @@ -343,7 +342,7 @@ void RimWellRftPlot::updateEditorsFromPreviousSelection() // This has to happen after the m_selectedSources is filled // because the available time steps is dependent on the selected sources. - auto timeStepOptions = calculateValueOptions( &m_selectedTimeSteps, &dummy ); + auto timeStepOptions = calculateValueOptions( &m_selectedTimeSteps ); for ( const auto& timeStepOption : timeStepOptions ) { QDateTime timeStep = timeStepOption.value().toDateTime(); @@ -500,7 +499,10 @@ void RimWellRftPlot::updateCurvesInPlot( const std::setsetEclipseResultCase( dynamic_cast( rftCase ) ); - RifEclipseRftAddress address( simWellName, curveDefToAdd.timeStep(), RifEclipseRftAddress::PRESSURE ); + RifEclipseRftAddress address = + RifEclipseRftAddress::createAddress( simWellName, + curveDefToAdd.timeStep(), + RifEclipseRftAddress::RftWellLogChannelType::PRESSURE ); curve->setRftAddress( address ); curve->setZOrder( 1 ); curve->setSimWellBranchData( m_branchDetection, m_branchIndex ); @@ -514,9 +516,10 @@ void RimWellRftPlot::updateCurvesInPlot( const std::setsetObservedFmuRftData( observedFmuRftData ); - RifEclipseRftAddress address( m_wellPathNameOrSimWellName, - curveDefToAdd.timeStep(), - RifEclipseRftAddress::PRESSURE ); + RifEclipseRftAddress address = + RifEclipseRftAddress::createAddress( m_wellPathNameOrSimWellName, + curveDefToAdd.timeStep(), + RifEclipseRftAddress::RftWellLogChannelType::PRESSURE ); curve->setRftAddress( address ); curve->setZOrder( RiuQwtPlotCurveDefines::zDepthForIndex( RiuQwtPlotCurveDefines::ZIndex::Z_SINGLE_CURVE_OBSERVED ) ); @@ -531,9 +534,10 @@ void RimWellRftPlot::updateCurvesInPlot( const std::setsetEnsemble( curveDefToAdd.address().ensemble() ); curve->setObservedFmuRftData( this->findObservedFmuData( m_wellPathNameOrSimWellName, curveDefToAdd.timeStep() ) ); - RifEclipseRftAddress address( m_wellPathNameOrSimWellName, - curveDefToAdd.timeStep(), - RifEclipseRftAddress::PRESSURE ); + RifEclipseRftAddress address = + RifEclipseRftAddress::createAddress( m_wellPathNameOrSimWellName, + curveDefToAdd.timeStep(), + RifEclipseRftAddress::RftWellLogChannelType::PRESSURE ); curve->setRftAddress( address ); curve->setZOrder( 1 ); applyCurveAppearance( curve ); @@ -551,7 +555,7 @@ void RimWellRftPlot::updateCurvesInPlot( const std::setaddCurve( curve ); @@ -571,8 +575,8 @@ void RimWellRftPlot::updateCurvesInPlot( const std::setsetZOrder( RiuQwtPlotCurveDefines::zDepthForIndex( RiuQwtPlotCurveDefines::ZIndex::Z_ENSEMBLE_STAT_CURVE ) ); applyCurveAppearance( curve ); - auto symbol = statisticsCurveSymbolFromAddress( rftAddress ); - RiuQwtSymbol::LabelPosition labelPos = statisticsLabelPosFromAddress( rftAddress ); + auto symbol = statisticsCurveSymbolFromAddress( rftAddress ); + RiuPlotCurveSymbol::LabelPosition labelPos = statisticsLabelPosFromAddress( rftAddress ); curve->setSymbol( symbol ); curve->setSymbolLabelPosition( labelPos ); curve->setSymbolSize( curve->symbolSize() + 3 ); @@ -741,10 +745,9 @@ void RimWellRftPlot::deleteCurvesAssosicatedWithObservedData( const RimObservedF //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimWellRftPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RimWellRftPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { - QList options = RimWellLogPlot::calculateValueOptions( fieldNeedingOptions, useOptionsOnly ); + QList options = RimWellLogPlot::calculateValueOptions( fieldNeedingOptions ); const QString simWellName = associatedSimWellName(); @@ -974,6 +977,7 @@ void RimWellRftPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& plotLayoutGroup->setCollapsedByDefault( true ); RimWellLogPlot::uiOrderingForAutoName( uiConfigName, *plotLayoutGroup ); RimWellLogPlot::uiOrderingForPlotLayout( uiConfigName, *plotLayoutGroup ); + plotLayoutGroup->add( &m_depthOrientation ); } } @@ -1159,39 +1163,39 @@ void RimWellRftPlot::assignWellPathToExtractionCurves() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuQwtSymbol::PointSymbolEnum RimWellRftPlot::statisticsCurveSymbolFromAddress( const RifEclipseRftAddress& address ) +RiuPlotCurveSymbol::PointSymbolEnum RimWellRftPlot::statisticsCurveSymbolFromAddress( const RifEclipseRftAddress& address ) { switch ( address.wellLogChannel() ) { - case RifEclipseRftAddress::PRESSURE_P10: - return RiuQwtSymbol::SYMBOL_TRIANGLE; - case RifEclipseRftAddress::PRESSURE_P50: - return RiuQwtSymbol::SYMBOL_DOWN_TRIANGLE; - case RifEclipseRftAddress::PRESSURE_P90: - return RiuQwtSymbol::SYMBOL_LEFT_TRIANGLE; - case RifEclipseRftAddress::PRESSURE_MEAN: - return RiuQwtSymbol::SYMBOL_RIGHT_TRIANGLE; + case RifEclipseRftAddress::RftWellLogChannelType::PRESSURE_P10: + return RiuPlotCurveSymbol::SYMBOL_TRIANGLE; + case RifEclipseRftAddress::RftWellLogChannelType::PRESSURE_P50: + return RiuPlotCurveSymbol::SYMBOL_DOWN_TRIANGLE; + case RifEclipseRftAddress::RftWellLogChannelType::PRESSURE_P90: + return RiuPlotCurveSymbol::SYMBOL_LEFT_TRIANGLE; + case RifEclipseRftAddress::RftWellLogChannelType::PRESSURE_MEAN: + return RiuPlotCurveSymbol::SYMBOL_RIGHT_TRIANGLE; } - return RiuQwtSymbol::SYMBOL_RIGHT_TRIANGLE; + return RiuPlotCurveSymbol::SYMBOL_RIGHT_TRIANGLE; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuQwtSymbol::LabelPosition RimWellRftPlot::statisticsLabelPosFromAddress( const RifEclipseRftAddress& address ) +RiuPlotCurveSymbol::LabelPosition RimWellRftPlot::statisticsLabelPosFromAddress( const RifEclipseRftAddress& address ) { switch ( address.wellLogChannel() ) { - case RifEclipseRftAddress::PRESSURE_P10: - return RiuQwtSymbol::LabelLeftOfSymbol; - case RifEclipseRftAddress::PRESSURE_P50: - return RiuQwtSymbol::LabelAboveSymbol; - case RifEclipseRftAddress::PRESSURE_P90: - return RiuQwtSymbol::LabelRightOfSymbol; - case RifEclipseRftAddress::PRESSURE_MEAN: - return RiuQwtSymbol::LabelBelowSymbol; + case RifEclipseRftAddress::RftWellLogChannelType::PRESSURE_P10: + return RiuPlotCurveSymbol::LabelLeftOfSymbol; + case RifEclipseRftAddress::RftWellLogChannelType::PRESSURE_P50: + return RiuPlotCurveSymbol::LabelAboveSymbol; + case RifEclipseRftAddress::RftWellLogChannelType::PRESSURE_P90: + return RiuPlotCurveSymbol::LabelRightOfSymbol; + case RifEclipseRftAddress::RftWellLogChannelType::PRESSURE_MEAN: + return RiuPlotCurveSymbol::LabelBelowSymbol; } - return RiuQwtSymbol::LabelAboveSymbol; + return RiuPlotCurveSymbol::LabelAboveSymbol; } //-------------------------------------------------------------------------------------------------- @@ -1217,10 +1221,10 @@ cvf::Color3f RimWellRftPlot::findCurveColor( RimWellLogCurve* curve ) if ( m_showStatisticsCurves ) { - if ( plotByIndex( 0 ) && plotByIndex( 0 )->viewer() ) + if ( plotByIndex( 0 ) && plotByIndex( 0 )->plotWidget() ) { cvf::Color3f backgroundColor = - RiaColorTools::fromQColorTo3f( plotByIndex( 0 )->viewer()->canvasBackground().color() ); + RiaColorTools::fromQColorTo3f( plotByIndex( 0 )->plotWidget()->backgroundColor() ); curveColor = RiaColorTools::blendCvfColors( backgroundColor, curveColor, 1, 2 ); } } @@ -1272,7 +1276,7 @@ void RimWellRftPlot::defineCurveColorsAndSymbols( const std::setcanvas(), viewer->overlayMargins() ); + auto m = new RiuDraggableOverlayFrame( viewer->getParentForOverlay(), viewer->overlayMargins() ); m->setContentFrame( curveSet->legendConfig()->makeLegendFrame() ); m_ensembleLegendFrames[curveSet] = m; @@ -1286,12 +1290,12 @@ void RimWellRftPlot::defineCurveColorsAndSymbols( const std::set colorTable; RiaColorTables::summaryCurveDefaultPaletteColors().color3fArray().toStdVector( &colorTable ); - std::vector symbolTable = { RiuQwtSymbol::SYMBOL_ELLIPSE, - RiuQwtSymbol::SYMBOL_RECT, - RiuQwtSymbol::SYMBOL_DIAMOND, - RiuQwtSymbol::SYMBOL_CROSS, - RiuQwtSymbol::SYMBOL_XCROSS, - RiuQwtSymbol::SYMBOL_STAR1 }; + std::vector symbolTable = { RiuPlotCurveSymbol::SYMBOL_ELLIPSE, + RiuPlotCurveSymbol::SYMBOL_RECT, + RiuPlotCurveSymbol::SYMBOL_DIAMOND, + RiuPlotCurveSymbol::SYMBOL_CROSS, + RiuPlotCurveSymbol::SYMBOL_XCROSS, + RiuPlotCurveSymbol::SYMBOL_STAR1 }; // Add new curves for ( const RiaRftPltCurveDefinition& curveDefToAdd : allCurveDefs ) @@ -1359,7 +1363,7 @@ void RimWellRftPlot::createEnsembleCurveSets() for ( RimWellRftEnsembleCurveSet* curveSet : curveSetsToDelete ) { - m_ensembleCurveSets.removeChildObject( curveSet ); + m_ensembleCurveSets.removeChild( curveSet ); delete curveSet; } diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.h b/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.h index 0e10d3acdd..21d206fa16 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.h +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.h @@ -24,7 +24,7 @@ #include "RimWellRftEnsembleCurveSet.h" #include "RifDataSourceForRftPltQMetaType.h" -#include "RiuQwtSymbol.h" +#include "RiuPlotCurveSymbol.h" #include "cafPdmField.h" #include "cafPdmObject.h" @@ -96,8 +96,7 @@ class RimWellRftPlot : public RimWellLogPlot void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void onLoadDataAndUpdate() override; @@ -130,8 +129,8 @@ class RimWellRftPlot : public RimWellLogPlot void updateFormationsOnPlot() const; QString associatedSimWellName() const; - static RiuQwtSymbol::PointSymbolEnum statisticsCurveSymbolFromAddress( const RifEclipseRftAddress& address ); - static RiuQwtSymbol::LabelPosition statisticsLabelPosFromAddress( const RifEclipseRftAddress& address ); + static RiuPlotCurveSymbol::PointSymbolEnum statisticsCurveSymbolFromAddress( const RifEclipseRftAddress& address ); + static RiuPlotCurveSymbol::LabelPosition statisticsLabelPosFromAddress( const RifEclipseRftAddress& address ); cvf::Color3f findCurveColor( RimWellLogCurve* curve ); void defineCurveColorsAndSymbols( const std::set& allCurveDefs ); @@ -158,9 +157,9 @@ class RimWellRftPlot : public RimWellLogPlot caf::PdmChildArrayField m_ensembleCurveSets; std::map> m_ensembleLegendFrames; - std::map m_dataSourceColors; - std::map m_timeStepSymbols; - bool m_isOnLoad; + std::map m_dataSourceColors; + std::map m_timeStepSymbols; + bool m_isOnLoad; caf::PdmChildField m_wellLogPlot_OBSOLETE; }; diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCase.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCase.cpp index 3d4e414d33..9f0b361be2 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCase.cpp @@ -126,31 +126,26 @@ RimGeoMechCase::RimGeoMechCase( void ) "Used to calculate the SE:SFI result", "" ); - CAF_PDM_InitFieldNoDefault( &m_elementPropertyFileNames, "ElementPropertyFileNames", "Element Property Files", "", "", "" ); - - CAF_PDM_InitFieldNoDefault( &m_elementPropertyFileNameIndexUiSelection, - "ElementPropertyFileNameIndexUiSelection", - "", - "", - "", - "" ); + CAF_PDM_InitFieldNoDefault( &m_elementPropertyFileNames, "ElementPropertyFileNames", "Element Property Files" ); + + CAF_PDM_InitFieldNoDefault( &m_elementPropertyFileNameIndexUiSelection, "ElementPropertyFileNameIndexUiSelection", "" ); m_elementPropertyFileNameIndexUiSelection.xmlCapability()->disableIO(); - CAF_PDM_InitField( &m_importElementPropertyFileCommand, "importElementPropertyFileCommad", false, "", "", "", "" ); + CAF_PDM_InitField( &m_importElementPropertyFileCommand, "importElementPropertyFileCommad", false, "" ); caf::PdmUiPushButtonEditor::configureEditorForField( &m_importElementPropertyFileCommand ); - CAF_PDM_InitField( &m_closeElementPropertyFileCommand, "closeElementPropertyFileCommad", false, "", "", "", "" ); + CAF_PDM_InitField( &m_closeElementPropertyFileCommand, "closeElementPropertyFileCommad", false, "" ); caf::PdmUiPushButtonEditor::configureEditorForField( &m_closeElementPropertyFileCommand ); - CAF_PDM_InitField( &m_reloadElementPropertyFileCommand, "reloadElementPropertyFileCommand", false, "", "", "", "" ); + CAF_PDM_InitField( &m_reloadElementPropertyFileCommand, "reloadElementPropertyFileCommand", false, "" ); caf::PdmUiPushButtonEditor::configureEditorForField( &m_reloadElementPropertyFileCommand ); caf::AppEnum defaultBiotCoefficientType = RimGeoMechCase::BiotCoefficientType::BIOT_NONE; - CAF_PDM_InitField( &m_biotCoefficientType, "BiotCoefficientType", defaultBiotCoefficientType, "Biot Coefficient", "", "", "" ); - CAF_PDM_InitField( &m_biotFixedCoefficient, "BiotFixedCoefficient", 1.0, "Fixed Coefficient", "", "", "" ); + CAF_PDM_InitField( &m_biotCoefficientType, "BiotCoefficientType", defaultBiotCoefficientType, "Biot Coefficient" ); + CAF_PDM_InitField( &m_biotFixedCoefficient, "BiotFixedCoefficient", 1.0, "Fixed Coefficient" ); m_biotFixedCoefficient.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_biotResultAddress, "BiotResultAddress", QString( "" ), "Value", "", "", "" ); + CAF_PDM_InitField( &m_biotResultAddress, "BiotResultAddress", QString( "" ), "Value" ); m_biotResultAddress.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() ); caf::AppEnum defaultInitialPermeabilityType = @@ -158,38 +153,24 @@ RimGeoMechCase::RimGeoMechCase( void ) CAF_PDM_InitField( &m_initialPermeabilityType, "InitialPermeabilityType", defaultInitialPermeabilityType, - "Initial Permeability", - "", - "", - "" ); - CAF_PDM_InitField( &m_initialPermeabilityFixed, - "InitialPermeabilityFixed", - 1.0, - "Fixed Initial Permeability [mD]", - "", - "", - "" ); + "Initial Permeability" ); + CAF_PDM_InitField( &m_initialPermeabilityFixed, "InitialPermeabilityFixed", 1.0, "Fixed Initial Permeability [mD]" ); m_initialPermeabilityFixed.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_initialPermeabilityResultAddress, "InitialPermeabilityAddress", QString( "" ), "Value", "", "", "" ); + CAF_PDM_InitField( &m_initialPermeabilityResultAddress, "InitialPermeabilityAddress", QString( "" ), "Value" ); m_initialPermeabilityResultAddress.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_permeabilityExponent, "PermeabilityExponent", 1.0, "Permeability Exponent", "", "", "" ); + CAF_PDM_InitField( &m_permeabilityExponent, "PermeabilityExponent", 1.0, "Permeability Exponent" ); m_permeabilityExponent.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_waterDensityShearSlipIndicator, "WaterDensityShearSlipIndicator", 1.03, "Water Density", "", "", "" ); + CAF_PDM_InitField( &m_waterDensityShearSlipIndicator, "WaterDensityShearSlipIndicator", 1.03, "Water Density" ); m_waterDensityShearSlipIndicator.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_contourMapCollection, "ContourMaps", "2d Contour Maps", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_contourMapCollection, "ContourMaps", "2d Contour Maps" ); m_contourMapCollection = new RimGeoMechContourMapViewCollection; m_contourMapCollection.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_mudWeightWindowParameters, - "MudWeightWindowParameters", - "Mud Weight Window Parameters", - "", - "", - "" ); + CAF_PDM_InitFieldNoDefault( &m_mudWeightWindowParameters, "MudWeightWindowParameters", "Mud Weight Window Parameters" ); m_mudWeightWindowParameters = new RimMudWeightWindowParameters; m_mudWeightWindowParameters.uiCapability()->setUiTreeHidden( true ); @@ -202,7 +183,7 @@ RimGeoMechCase::RimGeoMechCase( void ) //-------------------------------------------------------------------------------------------------- RimGeoMechCase::~RimGeoMechCase( void ) { - geoMechViews.deleteAllChildObjects(); + geoMechViews.deleteChildren(); RimProject* project = RimProject::current(); if ( project ) @@ -412,14 +393,6 @@ RimGeoMechCase::CaseOpenStatus RimGeoMechCase::openGeoMechCase( std::string* err return CASE_OPEN_OK; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimGeoMechCase::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) -{ - // No longer in use. Filepaths are now of type caf::FilePath, and updated in RimProject on load. -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -445,7 +418,7 @@ std::vector RimGeoMechCase::allSpecialViews() const void RimGeoMechCase::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/ ) { std::vector children; - geoMechViews.childObjects( &children ); + geoMechViews.children( &children ); for ( auto child : children ) uiTreeOrdering.add( child ); @@ -1205,12 +1178,11 @@ void RimGeoMechCase::defineEditorAttribute( const caf::PdmFieldHandle* field, //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimGeoMechCase::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RimGeoMechCase::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; - options = RimCase::calculateValueOptions( fieldNeedingOptions, useOptionsOnly ); + options = RimCase::calculateValueOptions( fieldNeedingOptions ); if ( fieldNeedingOptions == &m_elementPropertyFileNameIndexUiSelection ) { diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCase.h b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCase.h index 588e790bd5..2e9f6d496b 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCase.h +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCase.h @@ -84,8 +84,6 @@ class RimGeoMechCase : public RimCase RimGeoMechView* createAndAddReservoirView(); RimGeoMechView* createCopyAndAddView( const RimGeoMechView* sourceView ); - void updateFilePathsFromProjectPath( const QString& projectPath, const QString& oldProjectPath ) override; - std::vector timeStepDates() const override; QStringList timeStepStrings() const override; QString timeStepName( int frameIdx ) const override; @@ -133,8 +131,7 @@ class RimGeoMechCase : public RimCase void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void updateFormationNamesData() override; diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCellColors.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCellColors.cpp index 52ff1fb461..54b29c9636 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCellColors.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCellColors.cpp @@ -32,7 +32,7 @@ CAF_PDM_SOURCE_INIT( RimGeoMechCellColors, "GeoMechResultSlot" ); RimGeoMechCellColors::RimGeoMechCellColors( void ) : legendConfigChanged( this ) { - CAF_PDM_InitFieldNoDefault( &legendConfig, "LegendDefinition", "Color Legend", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &legendConfig, "LegendDefinition", "Color Legend" ); this->legendConfig = new RimRegularLegendConfig(); legendConfig.uiCapability()->setUiTreeHidden( true ); legendConfig->changed.connect( this, &RimGeoMechCellColors::onLegendConfigChanged ); diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapProjection.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapProjection.cpp index c4bb67d966..9fc50d7566 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapProjection.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapProjection.cpp @@ -34,6 +34,7 @@ #include "RimGeoMechCellColors.h" #include "RimGeoMechContourMapView.h" #include "RimGeoMechPropertyFilterCollection.h" +#include "RimRegularLegendConfig.h" #include "RivFemElmVisibilityCalculator.h" @@ -59,16 +60,13 @@ CAF_PDM_SOURCE_INIT( RimGeoMechContourMapProjection, "RimGeoMechContourMapProjec RimGeoMechContourMapProjection::RimGeoMechContourMapProjection() : m_kLayers( 0u ) { - CAF_PDM_InitObject( "RimContourMapProjection", ":/2DMapProjection16x16.png", "", "" ); - CAF_PDM_InitField( &m_limitToPorePressureRegions, "LimitToPorRegion", true, "Limit to Pore Pressure regions", "", "", "" ); - CAF_PDM_InitField( &m_applyPPRegionLimitVertically, "VerticalLimit", false, "Apply Limit Vertically", "", "", "" ); + CAF_PDM_InitObject( "RimContourMapProjection", ":/2DMapProjection16x16.png" ); + CAF_PDM_InitField( &m_limitToPorePressureRegions, "LimitToPorRegion", true, "Limit to Pore Pressure regions" ); + CAF_PDM_InitField( &m_applyPPRegionLimitVertically, "VerticalLimit", false, "Apply Limit Vertically" ); CAF_PDM_InitField( &m_paddingAroundPorePressureRegion, "PaddingAroundPorRegion", 0.0, - "Horizontal Padding around PP regions", - "", - "", - "" ); + "Horizontal Padding around PP regions" ); m_paddingAroundPorePressureRegion.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); setName( "Map Projection" ); @@ -617,8 +615,7 @@ void RimGeoMechContourMapProjection::fieldChangedByUi( const caf::PdmFieldHandle /// //-------------------------------------------------------------------------------------------------- QList - RimGeoMechContourMapProjection::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) + RimGeoMechContourMapProjection::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapProjection.h b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapProjection.h index 1b1ec697af..c20c60eb62 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapProjection.h +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapProjection.h @@ -24,7 +24,6 @@ #include "RimCheckableNamedObject.h" #include "RimContourMapProjection.h" #include "RimGeoMechCase.h" -#include "RimRegularLegendConfig.h" #include "cafDisplayCoordTransform.h" #include "cafPdmChildField.h" @@ -91,8 +90,7 @@ class RimGeoMechContourMapProjection : public RimContourMapProjection protected: // Framework overrides void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapView.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapView.cpp index 90e6987738..bcf3feaf23 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapView.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapView.cpp @@ -58,11 +58,11 @@ RimGeoMechContourMapView::RimGeoMechContourMapView() "GeoMechContourMap", "A contour map for GeoMech cases" ); - CAF_PDM_InitFieldNoDefault( &m_contourMapProjection, "ContourMapProjection", "Contour Map Projection", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_contourMapProjection, "ContourMapProjection", "Contour Map Projection" ); m_contourMapProjection = new RimGeoMechContourMapProjection(); - CAF_PDM_InitField( &m_showAxisLines, "ShowAxisLines", true, "Show Axis Lines", "", "", "" ); - CAF_PDM_InitField( &m_showScaleLegend, "ShowScaleLegend", true, "Show Scale Legend", "", "", "" ); + CAF_PDM_InitField( &m_showAxisLines, "ShowAxisLines", true, "Show Axis Lines" ); + CAF_PDM_InitField( &m_showScaleLegend, "ShowScaleLegend", true, "Show Scale Legend" ); m_gridCollection->setActive( false ); // This is also not added to the tree view, so cannot be enabled. diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapViewCollection.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapViewCollection.cpp index 9a585ec95b..37dfae92dc 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapViewCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapViewCollection.cpp @@ -10,9 +10,9 @@ CAF_PDM_SOURCE_INIT( RimGeoMechContourMapViewCollection, "GeoMech2dViewCollectio //-------------------------------------------------------------------------------------------------- RimGeoMechContourMapViewCollection::RimGeoMechContourMapViewCollection() { - CAF_PDM_InitObject( "GeoMech Contour Maps", ":/2DMaps16x16.png", "", "" ); + CAF_PDM_InitObject( "GeoMech Contour Maps", ":/2DMaps16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_contourMapViews, "GeoMechViews", "Contour Maps", ":/CrossSection16x16.png", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_contourMapViews, "GeoMechViews", "Contour Maps", ":/CrossSection16x16.png" ); m_contourMapViews.uiCapability()->setUiTreeHidden( true ); } @@ -28,7 +28,7 @@ RimGeoMechContourMapViewCollection::~RimGeoMechContourMapViewCollection() //-------------------------------------------------------------------------------------------------- std::vector RimGeoMechContourMapViewCollection::views() { - return m_contourMapViews.childObjects(); + return m_contourMapViews.children(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechModels.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechModels.cpp index 7489dd88cd..05b3a3c34d 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechModels.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechModels.cpp @@ -34,9 +34,9 @@ CAF_PDM_SOURCE_INIT( RimGeoMechModels, "ResInsightGeoMechModels" ); //-------------------------------------------------------------------------------------------------- RimGeoMechModels::RimGeoMechModels( void ) { - CAF_PDM_InitObject( "Geomechanical Models", ":/GeoMechCases48x48.png", "", "" ); + CAF_PDM_InitObject( "Geomechanical Models", ":/GeoMechCases48x48.png" ); - CAF_PDM_InitFieldNoDefault( &m_cases, "Cases", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_cases, "Cases", "" ); m_cases.uiCapability()->setUiTreeHidden( true ); } @@ -52,7 +52,7 @@ RimGeoMechModels::~RimGeoMechModels( void ) //-------------------------------------------------------------------------------------------------- std::vector RimGeoMechModels::cases() const { - return m_cases.childObjects(); + return m_cases.children(); } //-------------------------------------------------------------------------------------------------- @@ -68,7 +68,7 @@ void RimGeoMechModels::addCase( RimGeoMechCase* thecase ) //-------------------------------------------------------------------------------------------------- void RimGeoMechModels::removeCase( RimGeoMechCase* thecase ) { - m_cases.removeChildObject( thecase ); + m_cases.removeChild( thecase ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechPart.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechPart.cpp index ab35aa23d6..45b41a8439 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechPart.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechPart.cpp @@ -30,9 +30,9 @@ CAF_PDM_SOURCE_INIT( RimGeoMechPart, "GeoMechPart" ); //-------------------------------------------------------------------------------------------------- RimGeoMechPart::RimGeoMechPart() { - CAF_PDM_InitScriptableObject( "GeoMechPart", ":/GeoMechCase24x24.png", "", "" ); + CAF_PDM_InitScriptableObject( "GeoMechPart", ":/GeoMechCase24x24.png" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_partId, "PartId", "Part Id", "", "", "" ); + CAF_PDM_InitScriptableField( &m_partId, "PartId", -1, "Part Id" ); m_partId.uiCapability()->setUiReadOnly( true ); nameField()->uiCapability()->setUiReadOnly( true ); diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechPartCollection.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechPartCollection.cpp index f26cd94e5b..3a3e43691f 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechPartCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechPartCollection.cpp @@ -41,9 +41,9 @@ RimGeoMechPartCollection::RimGeoMechPartCollection() , m_currentScaleFactor( 1.0 ) , m_noDisplacements() { - CAF_PDM_InitScriptableObject( "Parts", ":/GeoMechCase24x24.png", "", "" ); + CAF_PDM_InitScriptableObject( "Parts", ":/GeoMechCase24x24.png" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_parts, "Parts", "Parts", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_parts, "Parts", "Parts" ); m_parts.uiCapability()->setUiTreeHidden( true ); setDeletable( false ); @@ -69,7 +69,7 @@ void RimGeoMechPartCollection::syncWithCase( RimGeoMechCase* geoCase ) if ( count != (int)m_parts.size() ) { - m_parts.clear(); + m_parts.deleteChildren(); for ( int i = 0; i < count; i++ ) { @@ -91,7 +91,7 @@ void RimGeoMechPartCollection::syncWithCase( RimGeoMechCase* geoCase ) //-------------------------------------------------------------------------------------------------- std::vector RimGeoMechPartCollection::parts() const { - return m_parts.childObjects(); + return m_parts.children(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechResultDefinition.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechResultDefinition.cpp index 07841aba05..cab5b4be93 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechResultDefinition.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechResultDefinition.cpp @@ -76,46 +76,37 @@ CAF_PDM_SOURCE_INIT( RimGeoMechResultDefinition, "GeoMechResultDefinition" ); //-------------------------------------------------------------------------------------------------- RimGeoMechResultDefinition::RimGeoMechResultDefinition( void ) { - CAF_PDM_InitObject( "Color Result", ":/CellResult.png", "", "" ); + CAF_PDM_InitObject( "Color Result", ":/CellResult.png" ); - CAF_PDM_InitFieldNoDefault( &m_resultPositionType, "ResultPositionType", "Result Position", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_resultPositionType, "ResultPositionType", "Result Position" ); m_resultPositionType.uiCapability()->setUiHidden( true ); - CAF_PDM_InitField( &m_resultFieldName, "ResultFieldName", QString( "" ), "Field Name", "", "", "" ); + CAF_PDM_InitField( &m_resultFieldName, "ResultFieldName", QString( "" ), "Field Name" ); m_resultFieldName.uiCapability()->setUiHidden( true ); - CAF_PDM_InitField( &m_resultComponentName, "ResultComponentName", QString( "" ), "Component", "", "", "" ); + CAF_PDM_InitField( &m_resultComponentName, "ResultComponentName", QString( "" ), "Component" ); m_resultComponentName.uiCapability()->setUiHidden( true ); CAF_PDM_InitField( &m_timeLapseBaseTimestep, "TimeLapseBaseTimeStep", RigFemResultAddress::noTimeLapseValue(), - "Base Time Step", - "", - "", - "" ); - CAF_PDM_InitField( &m_referenceTimeStep, "ReferenceTimeStep", 0, "Reference Time Step", "", "", "" ); + "Base Time Step" ); + CAF_PDM_InitField( &m_referenceTimeStep, "ReferenceTimeStep", 0, "Reference Time Step" ); - CAF_PDM_InitField( &m_compactionRefLayer, "CompactionRefLayer", 0, "Compaction Ref Layer", "", "", "" ); + CAF_PDM_InitField( &m_compactionRefLayer, "CompactionRefLayer", 0, "Compaction Ref Layer" ); m_compactionRefLayer.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_resultPositionTypeUiField, "ResultPositionTypeUi", "Result Position", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_resultPositionTypeUiField, "ResultPositionTypeUi", "Result Position" ); m_resultPositionTypeUiField.xmlCapability()->disableIO(); - CAF_PDM_InitField( &m_resultVariableUiField, "ResultVariableUI", QString( "" ), "Value", "", "", "" ); + CAF_PDM_InitField( &m_resultVariableUiField, "ResultVariableUI", QString( "" ), "Value" ); m_resultVariableUiField.xmlCapability()->disableIO(); m_resultVariableUiField.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() ); m_resultVariableUiField.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); - CAF_PDM_InitField( &m_normalizeByHydrostaticPressure, - "NormalizeByHSP", - false, - "Normalize by Hydrostatic Pressure", - "", - "", - "" ); - CAF_PDM_InitField( &m_normalizationAirGap, "NormalizationAirGap", 0.0, "Air Gap", "", "", "" ); + CAF_PDM_InitField( &m_normalizeByHydrostaticPressure, "NormalizeByHSP", false, "Normalize by Hydrostatic Pressure" ); + CAF_PDM_InitField( &m_normalizationAirGap, "NormalizationAirGap", 0.0, "Air Gap" ); m_normalizationAirGap.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); CAF_PDM_InitField( &m_compactionRefLayerUiField, @@ -214,10 +205,9 @@ void RimGeoMechResultDefinition::defineUiOrdering( QString uiConfigName, caf::Pd /// //-------------------------------------------------------------------------------------------------- QList - RimGeoMechResultDefinition::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) + RimGeoMechResultDefinition::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; - *useOptionsOnly = true; if ( m_geomCase ) { diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechResultDefinition.h b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechResultDefinition.h index aa3a1dd3dd..ad794dc2f2 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechResultDefinition.h +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechResultDefinition.h @@ -94,8 +94,7 @@ class RimGeoMechResultDefinition : public RimFemResultObserver, public RimChecka private: // Overridden PDM methods - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void calculateNormalizationAirGapDefault(); diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp index c9c94b6228..dc0b729851 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp @@ -86,24 +86,24 @@ RimGeoMechView::RimGeoMechView( void ) { CAF_PDM_InitScriptableObject( "Geomechanical View", ":/3DViewGeoMech16x16.png", "", "The Geomechanical 3d View" ); - CAF_PDM_InitFieldNoDefault( &cellResult, "GridCellResult", "Color Result", ":/CellResult.png", "", "" ); + CAF_PDM_InitFieldNoDefault( &cellResult, "GridCellResult", "Color Result", ":/CellResult.png" ); cellResult = new RimGeoMechCellColors(); cellResult.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_tensorResults, "TensorResults", "Tensor Results", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_tensorResults, "TensorResults", "Tensor Results" ); m_tensorResults = new RimTensorResults(); m_tensorResults.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_propertyFilterCollection, "PropertyFilters", "Property Filters", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_propertyFilterCollection, "PropertyFilters", "Property Filters" ); m_propertyFilterCollection = new RimGeoMechPropertyFilterCollection(); m_propertyFilterCollection.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_partsCollection, "Parts", "Parts", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_partsCollection, "Parts", "Parts" ); m_partsCollection = new RimGeoMechPartCollection(); m_partsCollection.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitField( &m_showDisplacement, "ShowDisplacement", false, "Show Displacement", "", "", "" ); - CAF_PDM_InitField( &m_displacementScaling, "DisplacementScaling", 1.0, "Scaling Factor", "", "", "" ); + CAF_PDM_InitField( &m_showDisplacement, "ShowDisplacement", false, "Show Displacement" ); + CAF_PDM_InitField( &m_displacementScaling, "DisplacementScaling", 1.0, "Scaling Factor" ); m_scaleTransform = new cvf::Transform(); m_vizLogic = new RivGeoMechVizLogic( this ); diff --git a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/CellFilters/RimPlotCellFilter.cpp b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/CellFilters/RimPlotCellFilter.cpp index 8c726f2fe8..cda69b2991 100644 --- a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/CellFilters/RimPlotCellFilter.cpp +++ b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/CellFilters/RimPlotCellFilter.cpp @@ -36,7 +36,7 @@ CAF_PDM_ABSTRACT_SOURCE_INIT( RimPlotCellFilter, "RimPlotCellFilter" ); //-------------------------------------------------------------------------------------------------- RimPlotCellFilter::RimPlotCellFilter() { - CAF_PDM_InitFieldNoDefault( &m_filterMode, "FilterMode", "Filter Mode", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_filterMode, "FilterMode", "Filter Mode" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/CellFilters/RimPlotCellFilterCollection.cpp b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/CellFilters/RimPlotCellFilterCollection.cpp index e0d44b0b8d..e6b1d1c52c 100644 --- a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/CellFilters/RimPlotCellFilterCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/CellFilters/RimPlotCellFilterCollection.cpp @@ -28,9 +28,9 @@ CAF_PDM_SOURCE_INIT( RimPlotCellFilterCollection, "RimPlotCellFilterCollection" //-------------------------------------------------------------------------------------------------- RimPlotCellFilterCollection::RimPlotCellFilterCollection() { - CAF_PDM_InitObject( "Plot Cell Filters", "", "", "" ); + CAF_PDM_InitObject( "Plot Cell Filters" ); - CAF_PDM_InitFieldNoDefault( &m_cellFilters, "CellFilters", "Cell Filters", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_cellFilters, "CellFilters", "Cell Filters" ); m_cellFilters.uiCapability()->setUiTreeHidden( true ); setName( "Filter Collection" ); diff --git a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/CellFilters/RimPlotCellPropertyFilter.cpp b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/CellFilters/RimPlotCellPropertyFilter.cpp index c4848cd2b1..d95393144f 100644 --- a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/CellFilters/RimPlotCellPropertyFilter.cpp +++ b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/CellFilters/RimPlotCellPropertyFilter.cpp @@ -39,19 +39,19 @@ CAF_PDM_SOURCE_INIT( RimPlotCellPropertyFilter, "RimPlotCellPropertyFilter" ); //-------------------------------------------------------------------------------------------------- RimPlotCellPropertyFilter::RimPlotCellPropertyFilter() { - CAF_PDM_InitObject( "Plot Cell Property Filter", "", "", "" ); + CAF_PDM_InitObject( "Plot Cell Property Filter" ); - CAF_PDM_InitFieldNoDefault( &m_resultDefinition, "ResultDefinition", "Result Definition", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_resultDefinition, "ResultDefinition", "Result Definition" ); // Set to hidden to avoid this item to been displayed as a child item // Fields in this object are displayed using defineUiOrdering() m_resultDefinition.uiCapability()->setUiTreeHidden( true ); m_resultDefinition.uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitField( &m_lowerBound, "LowerBound", 0.0, "Min", "", "", "" ); + CAF_PDM_InitField( &m_lowerBound, "LowerBound", 0.0, "Min" ); m_lowerBound.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_upperBound, "UpperBound", 0.0, "Max", "", "", "" ); + CAF_PDM_InitField( &m_upperBound, "UpperBound", 0.0, "Max" ); m_upperBound.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); } diff --git a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.cpp b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.cpp index c65369fcfa..1151b0c0d7 100644 --- a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.cpp @@ -17,6 +17,7 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RimGridCrossPlot.h" +#include "RiaDefines.h" #include "RiaFontCache.h" #include "RiaPreferences.h" @@ -30,6 +31,7 @@ #include "RimGridCrossPlotCurve.h" #include "RimGridCrossPlotDataSet.h" #include "RimMultiPlot.h" +#include "RimPlotAxisLogRangeCalculator.h" #include "RimPlotAxisProperties.h" #include "cafPdmUiCheckBoxEditor.h" @@ -41,7 +43,6 @@ #include "qwt_legend.h" #include "qwt_plot.h" #include "qwt_plot_curve.h" -#include "qwt_scale_engine.h" #include @@ -52,31 +53,31 @@ CAF_PDM_SOURCE_INIT( RimGridCrossPlot, "RimGridCrossPlot" ); //-------------------------------------------------------------------------------------------------- RimGridCrossPlot::RimGridCrossPlot() { - CAF_PDM_InitObject( "Grid Cross Plot", ":/SummaryXPlotLight16x16.png", "", "" ); + CAF_PDM_InitObject( "Grid Cross Plot", ":/SummaryXPlotLight16x16.png" ); - CAF_PDM_InitField( &m_showInfoBox, "ShowInfoBox", true, "Show Info Box", "", "", "" ); + CAF_PDM_InitField( &m_showInfoBox, "ShowInfoBox", true, "Show Info Box" ); - CAF_PDM_InitFieldNoDefault( &m_nameConfig, "NameConfig", "Name Config", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_nameConfig, "NameConfig", "Name Config" ); m_nameConfig.uiCapability()->setUiTreeHidden( true ); m_nameConfig.uiCapability()->setUiTreeChildrenHidden( true ); m_nameConfig = new RimGridCrossPlotNameConfig(); - CAF_PDM_InitFieldNoDefault( &m_xAxisProperties, "xAxisProperties", "X Axis", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_xAxisProperties, "xAxisProperties", "X Axis" ); m_xAxisProperties.uiCapability()->setUiTreeHidden( true ); m_xAxisProperties = new RimPlotAxisProperties; - m_xAxisProperties->setNameAndAxis( "X-Axis", QwtPlot::xBottom ); + m_xAxisProperties->setNameAndAxis( "X-Axis", "X-Axis", RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM ); m_xAxisProperties->setEnableTitleTextSettings( false ); - CAF_PDM_InitFieldNoDefault( &m_yAxisProperties, "yAxisProperties", "Y Axis", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_yAxisProperties, "yAxisProperties", "Y Axis" ); m_yAxisProperties.uiCapability()->setUiTreeHidden( true ); m_yAxisProperties = new RimPlotAxisProperties; - m_yAxisProperties->setNameAndAxis( "Y-Axis", QwtPlot::yLeft ); + m_yAxisProperties->setNameAndAxis( "Y-Axis", "Y-Axis", RiaDefines::PlotAxis::PLOT_AXIS_LEFT ); m_yAxisProperties->setEnableTitleTextSettings( false ); connectAxisSignals( m_xAxisProperties() ); connectAxisSignals( m_yAxisProperties() ); - CAF_PDM_InitFieldNoDefault( &m_crossPlotDataSets, "CrossPlotCurve", "Cross Plot Data Set", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_crossPlotDataSets, "CrossPlotCurve", "Cross Plot Data Set" ); m_crossPlotDataSets.uiCapability()->setUiTreeHidden( true ); setDeletable( true ); @@ -142,7 +143,7 @@ void RimGridCrossPlot::addDataSet( RimGridCrossPlotDataSet* dataSet ) //-------------------------------------------------------------------------------------------------- std::vector RimGridCrossPlot::dataSets() const { - return m_crossPlotDataSets.childObjects(); + return m_crossPlotDataSets.children(); } //-------------------------------------------------------------------------------------------------- @@ -156,7 +157,7 @@ QWidget* RimGridCrossPlot::viewWidget() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuQwtPlotWidget* RimGridCrossPlot::viewer() +RiuPlotWidget* RimGridCrossPlot::plotWidget() { return m_plotWidget; } @@ -185,7 +186,7 @@ void RimGridCrossPlot::zoomAll() setAutoScaleXEnabled( true ); setAutoScaleYEnabled( true ); - updateZoomInQwt(); + updateZoomInParentPlot(); } //-------------------------------------------------------------------------------------------------- @@ -211,10 +212,13 @@ void RimGridCrossPlot::reattachAllCurves() dataSet->detachAllCurves(); if ( dataSet->isChecked() ) { - dataSet->setParentQwtPlotNoReplot( m_plotWidget ); + dataSet->setParentPlotNoReplot( m_plotWidget ); + dataSet->loadDataAndUpdate( false ); } } - updateZoomInQwt(); + updateCurveNamesAndPlotTitle(); + updateLegend(); + updateZoomInParentPlot(); } } @@ -291,7 +295,8 @@ void RimGridCrossPlot::updateInfoBox() { if ( !m_infoBox ) { - m_infoBox = new RiuDraggableOverlayFrame( m_plotWidget->canvas(), m_plotWidget->overlayMargins() ); + m_infoBox = + new RiuDraggableOverlayFrame( m_plotWidget->getParentForOverlay(), m_plotWidget->overlayMargins() ); m_infoBox->setAnchorCorner( RiuDraggableOverlayFrame::AnchorCorner::TopRight ); RiuTextOverlayContentFrame* textFrame = new RiuTextOverlayContentFrame( m_infoBox ); textFrame->setText( generateInfoBoxText() ); @@ -349,13 +354,13 @@ void RimGridCrossPlot::setAutoScaleYEnabled( bool enabled ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObject* RimGridCrossPlot::findPdmObjectFromQwtCurve( const QwtPlotCurve* qwtCurve ) const +caf::PdmObject* RimGridCrossPlot::findPdmObjectFromPlotCurve( const RiuPlotCurve* plotCurve ) const { for ( auto dataSet : m_crossPlotDataSets ) { for ( auto curve : dataSet->curves() ) { - if ( curve->qwtPlotCurve() == qwtCurve ) + if ( curve->isSameCurve( plotCurve ) ) { return curve; } @@ -367,27 +372,20 @@ caf::PdmObject* RimGridCrossPlot::findPdmObjectFromQwtCurve( const QwtPlotCurve* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimGridCrossPlot::onAxisSelected( int axis, bool toggle ) +void RimGridCrossPlot::onAxisSelected( RiuPlotAxis axis, bool toggle ) { RiuPlotMainWindowTools::showPlotMainWindow(); RimPlotAxisProperties* properties = nullptr; - if ( axis == QwtPlot::yLeft ) + if ( axis.axis() == RiaDefines::PlotAxis::PLOT_AXIS_LEFT ) { properties = m_yAxisProperties; } - else if ( axis == QwtPlot::xBottom ) + else if ( axis.axis() == RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM ) { properties = m_xAxisProperties; } - if ( toggle ) - { - RiuPlotMainWindowTools::toggleItemInSelection( properties ); - } - else - { - RiuPlotMainWindowTools::selectAsCurrentItem( properties ); - } + RiuPlotMainWindowTools::selectOrToggleObject( properties, toggle ); } //-------------------------------------------------------------------------------------------------- @@ -454,13 +452,13 @@ void RimGridCrossPlot::onPlotZoomed() { setAutoScaleXEnabled( false ); setAutoScaleYEnabled( false ); - updateZoomFromQwt(); + updateZoomFromParentPlot(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuQwtPlotWidget* RimGridCrossPlot::doCreatePlotViewWidget( QWidget* mainWindowParent ) +RiuPlotWidget* RimGridCrossPlot::doCreatePlotViewWidget( QWidget* mainWindowParent ) { if ( !m_plotWidget ) { @@ -468,7 +466,7 @@ RiuQwtPlotWidget* RimGridCrossPlot::doCreatePlotViewWidget( QWidget* mainWindowP for ( auto dataSet : m_crossPlotDataSets ) { - dataSet->setParentQwtPlotNoReplot( m_plotWidget ); + dataSet->setParentPlotNoReplot( m_plotWidget ); } updateCurveNamesAndPlotTitle(); @@ -592,15 +590,16 @@ void RimGridCrossPlot::updatePlot() { if ( m_plotWidget ) { - RiuQwtPlotTools::setCommonPlotBehaviour( m_plotWidget ); - RiuQwtPlotTools::setDefaultAxes( m_plotWidget ); + RiuQwtPlotTools::setCommonPlotBehaviour( m_plotWidget->qwtPlot() ); + RiuQwtPlotTools::setDefaultAxes( m_plotWidget->qwtPlot() ); updateFonts(); updateAxes(); for ( auto dataSet : m_crossPlotDataSets ) { - dataSet->setParentQwtPlotNoReplot( m_plotWidget ); + dataSet->setParentPlotNoReplot( m_plotWidget ); + dataSet->loadDataAndUpdate( false ); } updateLegend(); @@ -635,13 +634,16 @@ void RimGridCrossPlot::swapAxes() RimPlotAxisProperties* xAxisProperties = m_xAxisProperties(); RimPlotAxisProperties* yAxisProperties = m_yAxisProperties(); - QString tmpName = xAxisProperties->name(); - QwtPlot::Axis tmpAxis = xAxisProperties->qwtPlotAxisType(); - xAxisProperties->setNameAndAxis( yAxisProperties->name(), yAxisProperties->qwtPlotAxisType() ); - yAxisProperties->setNameAndAxis( tmpName, tmpAxis ); + QString tmpName = xAxisProperties->objectName(); + QString tmpTitle = xAxisProperties->axisTitleText(); + RiuPlotAxis tmpAxis = xAxisProperties->plotAxisType(); + xAxisProperties->setNameAndAxis( yAxisProperties->objectName(), + yAxisProperties->axisTitleText(), + yAxisProperties->plotAxisType().axis() ); + yAxisProperties->setNameAndAxis( tmpName, tmpTitle, tmpAxis.axis() ); - m_xAxisProperties.removeChildObject( xAxisProperties ); - m_yAxisProperties.removeChildObject( yAxisProperties ); + m_xAxisProperties.removeChild( xAxisProperties ); + m_yAxisProperties.removeChild( yAxisProperties ); m_yAxisProperties = xAxisProperties; m_xAxisProperties = yAxisProperties; @@ -760,14 +762,14 @@ void RimGridCrossPlot::updateLegend() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimGridCrossPlot::updateZoomInQwt() +void RimGridCrossPlot::updateZoomInParentPlot() { if ( m_plotWidget ) { updateAxisInQwt( RiaDefines::PlotAxis::PLOT_AXIS_LEFT ); updateAxisInQwt( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM ); - m_plotWidget->updateAxes(); - updateZoomFromQwt(); + m_plotWidget->qwtPlot()->updateAxes(); + updateZoomFromParentPlot(); m_plotWidget->scheduleReplot(); } } @@ -775,7 +777,7 @@ void RimGridCrossPlot::updateZoomInQwt() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimGridCrossPlot::updateZoomFromQwt() +void RimGridCrossPlot::updateZoomFromParentPlot() { updateAxisFromQwt( RiaDefines::PlotAxis::PLOT_AXIS_LEFT ); updateAxisFromQwt( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM ); @@ -845,42 +847,39 @@ void RimGridCrossPlot::updateAxisInQwt( RiaDefines::PlotAxis axisType ) axisParameterString = yAxisParameterString(); } - QwtPlot::Axis qwtAxisId = axisProperties->qwtPlotAxisType(); - + RiuPlotAxis axis = axisProperties->plotAxisType(); if ( axisProperties->isActive() ) { - m_plotWidget->enableAxis( qwtAxisId, true ); + m_plotWidget->enableAxis( axis, true ); Qt::AlignmentFlag alignment = Qt::AlignCenter; if ( axisProperties->titlePosition() == RimPlotAxisPropertiesInterface::AXIS_TITLE_END ) { alignment = Qt::AlignRight; } - m_plotWidget->setAxisFontsAndAlignment( qwtAxisId, + m_plotWidget->setAxisFontsAndAlignment( axis, caf::FontTools::pointSizeToPixelSize( axisProperties->titleFontSize() ), caf::FontTools::pointSizeToPixelSize( axisProperties->valuesFontSize() ), true, alignment ); - m_plotWidget->setAxisTitleText( qwtAxisId, axisParameterString ); - m_plotWidget->setAxisTitleEnabled( qwtAxisId, true ); + m_plotWidget->setAxisTitleText( axis, axisParameterString ); + m_plotWidget->setAxisTitleEnabled( axis, true ); - if ( axisProperties->isLogarithmicScaleEnabled ) + if ( axisProperties->isLogarithmicScaleEnabled() ) { - QwtLogScaleEngine* currentScaleEngine = - dynamic_cast( m_plotWidget->axisScaleEngine( axisProperties->qwtPlotAxisType() ) ); - if ( !currentScaleEngine ) + bool isLogScale = m_plotWidget->axisScaleType( axis ) == RiuQwtPlotWidget::AxisScaleType::LOGARITHMIC; + if ( !isLogScale ) { - m_plotWidget->setAxisScaleEngine( axisProperties->qwtPlotAxisType(), new QwtLogScaleEngine ); - m_plotWidget->setAxisMaxMinor( axisProperties->qwtPlotAxisType(), 5 ); + m_plotWidget->setAxisScaleType( axis, RiuQwtPlotWidget::AxisScaleType::LOGARITHMIC ); + m_plotWidget->setAxisMaxMinor( axis, 5 ); } - double min = axisProperties->visibleRangeMin; - double max = axisProperties->visibleRangeMax; + double min = axisProperties->visibleRangeMin(); + double max = axisProperties->visibleRangeMax(); if ( axisProperties->isAutoZoom() ) { - std::vector plotCurves = visibleQwtCurves(); - - RimPlotAxisLogRangeCalculator logRangeCalculator( qwtAxisId, plotCurves ); + std::vector plotCurves = visibleCurves(); + RimPlotAxisLogRangeCalculator logRangeCalculator( axis.axis(), plotCurves ); logRangeCalculator.computeAxisRange( &min, &max ); } @@ -888,40 +887,38 @@ void RimGridCrossPlot::updateAxisInQwt( RiaDefines::PlotAxis axisType ) { std::swap( min, max ); } - m_plotWidget->setAxisScale( qwtAxisId, min, max ); + m_plotWidget->setAxisScale( axis, min, max ); } else { - QwtLinearScaleEngine* currentScaleEngine = - dynamic_cast( m_plotWidget->axisScaleEngine( axisProperties->qwtPlotAxisType() ) ); - if ( !currentScaleEngine ) + bool isLinearScale = m_plotWidget->axisScaleType( axis ) == RiuQwtPlotWidget::AxisScaleType::LINEAR; + if ( !isLinearScale ) { - m_plotWidget->setAxisScaleEngine( axisProperties->qwtPlotAxisType(), new QwtLinearScaleEngine ); - m_plotWidget->setAxisMaxMinor( axisProperties->qwtPlotAxisType(), 3 ); + m_plotWidget->setAxisScaleType( axis, RiuQwtPlotWidget::AxisScaleType::LINEAR ); + m_plotWidget->setAxisMaxMinor( axis, 3 ); } if ( axisProperties->isAutoZoom() ) { - m_plotWidget->setAxisAutoScale( qwtAxisId ); - m_plotWidget->axisScaleEngine( axisProperties->qwtPlotAxisType() ) - ->setAttribute( QwtScaleEngine::Inverted, axisProperties->isAxisInverted() ); + m_plotWidget->setAxisAutoScale( axis, true ); + m_plotWidget->setAxisInverted( axis, axisProperties->isAxisInverted() ); } else { - double min = axisProperties->visibleRangeMin; - double max = axisProperties->visibleRangeMax; + double min = axisProperties->visibleRangeMin(); + double max = axisProperties->visibleRangeMax(); if ( axisProperties->isAxisInverted() ) { std::swap( min, max ); } - m_plotWidget->setAxisScale( qwtAxisId, min, max ); + m_plotWidget->setAxisScale( axis, min, max ); } } } else { - m_plotWidget->enableAxis( qwtAxisId, false ); + m_plotWidget->enableAxis( axis, false ); } } @@ -932,20 +929,23 @@ void RimGridCrossPlot::updateAxisFromQwt( RiaDefines::PlotAxis axisType ) { if ( !m_plotWidget ) return; - QwtInterval xAxisRange = m_plotWidget->axisRange( QwtPlot::xBottom ); - QwtInterval yAxisRange = m_plotWidget->axisRange( QwtPlot::yLeft ); + auto [xAxisRangeMin, xAxisRangeMax] = m_plotWidget->axisRange( RiuPlotAxis::defaultBottom() ); RimPlotAxisProperties* axisProperties = m_xAxisProperties(); - QwtInterval axisRange = xAxisRange; + double axisRangeMin = xAxisRangeMin; + double axisRangeMax = xAxisRangeMax; if ( axisType == RiaDefines::PlotAxis::PLOT_AXIS_LEFT ) { - axisProperties = m_yAxisProperties(); - axisRange = yAxisRange; + axisProperties = m_yAxisProperties(); + auto [yAxisRangeMin, yAxisRangeMax] = m_plotWidget->axisRange( RiuPlotAxis::defaultLeft() ); + + axisRangeMin = yAxisRangeMin; + axisRangeMax = yAxisRangeMax; } - axisProperties->visibleRangeMin = std::min( axisRange.minValue(), axisRange.maxValue() ); - axisProperties->visibleRangeMax = std::max( axisRange.minValue(), axisRange.maxValue() ); + axisProperties->setVisibleRangeMin( std::min( axisRangeMin, axisRangeMax ) ); + axisProperties->setVisibleRangeMax( std::max( axisRangeMin, axisRangeMax ) ); axisProperties->updateConnectedEditors(); } @@ -953,9 +953,9 @@ void RimGridCrossPlot::updateAxisFromQwt( RiaDefines::PlotAxis axisType ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimGridCrossPlot::visibleQwtCurves() const +std::vector RimGridCrossPlot::visibleCurves() const { - std::vector plotCurves; + std::vector plotCurves; for ( auto dataSet : m_crossPlotDataSets ) { if ( dataSet->isChecked() ) @@ -964,7 +964,7 @@ std::vector RimGridCrossPlot::visibleQwtCurves() const { if ( curve->isCurveVisible() ) { - plotCurves.push_back( curve->qwtPlotCurve() ); + plotCurves.push_back( curve ); } } } @@ -1053,9 +1053,9 @@ CAF_PDM_SOURCE_INIT( RimGridCrossPlotNameConfig, "RimGridCrossPlotNameConfig" ); RimGridCrossPlotNameConfig::RimGridCrossPlotNameConfig() : RimNameConfig( "Cross Plot" ) { - CAF_PDM_InitObject( "Cross Plot Name Generator", "", "", "" ); + CAF_PDM_InitObject( "Cross Plot Name Generator" ); - CAF_PDM_InitField( &addDataSetNames, "AddDataSetNames", true, "Add Data Set Names", "", "", "" ); + CAF_PDM_InitField( &addDataSetNames, "AddDataSetNames", true, "Add Data Set Names" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.h b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.h index 11509e415c..38259d11dc 100644 --- a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.h +++ b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.h @@ -21,7 +21,7 @@ #include "cafPdmChildField.h" #include "cafPdmObject.h" -#include "RiaDefines.h" +#include "RiaPlotDefines.h" #include "RimNameConfig.h" #include "RimPlot.h" @@ -34,6 +34,7 @@ class RimPlotAxisProperties; class RimGridCrossPlotDataSet; class RiuDraggableOverlayFrame; class RiuGridCrossQwtPlot; +class RimPlotCurve; class RimGridCrossPlotNameConfig : public RimNameConfig { @@ -69,8 +70,8 @@ class RimGridCrossPlot : public RimPlot, public RimNameConfigHolderInterface std::vector dataSets() const; - QWidget* viewWidget() override; - RiuQwtPlotWidget* viewer() override; + QWidget* viewWidget() override; + RiuPlotWidget* plotWidget() override; QImage snapshotWindowContent() override; void zoomAll() override; @@ -98,13 +99,13 @@ class RimGridCrossPlot : public RimPlot, public RimNameConfigHolderInterface void updateLegend() override; - void updateZoomInQwt() override; - void updateZoomFromQwt() override; + void updateZoomInParentPlot() override; + void updateZoomFromParentPlot() override; void setAutoScaleXEnabled( bool enabled ) override; void setAutoScaleYEnabled( bool enabled ) override; - caf::PdmObject* findPdmObjectFromQwtCurve( const QwtPlotCurve* curve ) const override; - void onAxisSelected( int axis, bool toggle ) override; + caf::PdmObject* findPdmObjectFromPlotCurve( const RiuPlotCurve* curve ) const override; + void onAxisSelected( RiuPlotAxis axis, bool toggle ) override; bool isDeletable() const override; @@ -124,7 +125,7 @@ class RimGridCrossPlot : public RimPlot, public RimNameConfigHolderInterface void updateAxisInQwt( RiaDefines::PlotAxis axisType ); void updateAxisFromQwt( RiaDefines::PlotAxis axisType ); - std::vector visibleQwtCurves() const; + std::vector visibleCurves() const; RimPlotAxisProperties* xAxisProperties(); RimPlotAxisProperties* yAxisProperties(); @@ -135,7 +136,7 @@ class RimGridCrossPlot : public RimPlot, public RimNameConfigHolderInterface std::set allPlotAxes() const; private: - RiuQwtPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent = nullptr ) override; + RiuPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent = nullptr ) override; void doUpdateLayout() override; void cleanupBeforeClose(); diff --git a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotCollection.cpp b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotCollection.cpp index 7543aa02fe..2342240f13 100644 --- a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotCollection.cpp @@ -27,9 +27,9 @@ CAF_PDM_SOURCE_INIT( RimGridCrossPlotCollection, "RimGridCrossPlotCollection" ); //-------------------------------------------------------------------------------------------------- RimGridCrossPlotCollection::RimGridCrossPlotCollection() { - CAF_PDM_InitObject( "Grid Cross Plots", ":/SummaryXPlotsLight16x16.png", "", "" ); + CAF_PDM_InitObject( "Grid Cross Plots", ":/SummaryXPlotsLight16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_gridCrossPlots, "GridCrossPlots", "Grid Cross Plots", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_gridCrossPlots, "GridCrossPlots", "Grid Cross Plots" ); m_gridCrossPlots.uiCapability()->setUiTreeHidden( true ); } @@ -45,7 +45,7 @@ RimGridCrossPlotCollection::~RimGridCrossPlotCollection() //-------------------------------------------------------------------------------------------------- std::vector RimGridCrossPlotCollection::plots() const { - return m_gridCrossPlots.childObjects(); + return m_gridCrossPlots.children(); } //-------------------------------------------------------------------------------------------------- @@ -82,6 +82,6 @@ void RimGridCrossPlotCollection::insertPlot( RimGridCrossPlot* plot, size_t inde //-------------------------------------------------------------------------------------------------- void RimGridCrossPlotCollection::removePlot( RimGridCrossPlot* plot ) { - m_gridCrossPlots.removeChildObject( plot ); + m_gridCrossPlots.removeChild( plot ); updateAllRequiredEditors(); } diff --git a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotCurve.cpp b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotCurve.cpp index aa6d669828..6c079924c3 100644 --- a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotCurve.cpp @@ -18,28 +18,10 @@ #include "RimGridCrossPlotCurve.h" -#include "RigCaseCellResultCalculator.h" - -#include "RimCase.h" -#include "RimEclipseCase.h" -#include "RimEclipseResultDefinition.h" #include "RimGridCrossPlot.h" -#include "RimTools.h" - -#include "RiuQwtPlotCurve.h" -#include "RiuQwtSymbol.h" - -#include "cafPdmUiComboBoxEditor.h" - -#include -#include -#include -#include "qwt_graphic.h" -#include "qwt_plot.h" -#include "qwt_plot_curve.h" - -#include +#include "RiuPlotCurve.h" +#include "RiuPlotWidget.h" CAF_PDM_SOURCE_INIT( RimGridCrossPlotCurve, "GridCrossPlotCurve" ); @@ -50,10 +32,10 @@ RimGridCrossPlotCurve::RimGridCrossPlotCurve() : m_dataSetIndex( 0 ) , m_groupIndex( 0 ) { - CAF_PDM_InitObject( "Cross Plot Points", ":/WellLogCurve16x16.png", "", "" ); + CAF_PDM_InitObject( "Cross Plot Points", ":/WellLogCurve16x16.png" ); setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_NONE ); - setSymbol( RiuQwtSymbol::SYMBOL_NONE ); + setSymbol( RiuPlotCurveSymbol::SYMBOL_NONE ); setSymbolSize( 4 ); } @@ -73,9 +55,10 @@ void RimGridCrossPlotCurve::setSamples( const std::vector& xValues, cons { CVF_ASSERT( xValues.size() == yValues.size() ); - if ( xValues.empty() || yValues.empty() || !m_qwtPlotCurve ) return; + if ( xValues.empty() || yValues.empty() || !m_plotCurve ) return; - m_qwtPlotCurve->setSamples( &xValues[0], &yValues[0], static_cast( xValues.size() ) ); + bool useLogarithmicScale = false; + m_plotCurve->setSamplesFromXValuesAndYValues( xValues, yValues, useLogarithmicScale ); } //-------------------------------------------------------------------------------------------------- @@ -100,7 +83,7 @@ int RimGridCrossPlotCurve::groupIndex() const //-------------------------------------------------------------------------------------------------- size_t RimGridCrossPlotCurve::sampleCount() const { - return m_qwtPlotCurve ? m_qwtPlotCurve->dataSize() : 0; + return m_plotCurve ? m_plotCurve->numSamples() : 0; } //-------------------------------------------------------------------------------------------------- @@ -108,12 +91,12 @@ size_t RimGridCrossPlotCurve::sampleCount() const //-------------------------------------------------------------------------------------------------- void RimGridCrossPlotCurve::determineLegendIcon() { - if ( !m_qwtPlotCurve ) return; + if ( !m_plotCurve ) return; RimGridCrossPlot* plot = nullptr; firstAncestorOrThisOfTypeAsserted( plot ); int fontSize = plot->legendFontSize(); - m_qwtPlotCurve->setLegendIconSize( QSize( fontSize, fontSize ) ); + m_plotCurve->setLegendIconSize( QSize( fontSize, fontSize ) ); } //-------------------------------------------------------------------------------------------------- @@ -121,9 +104,9 @@ void RimGridCrossPlotCurve::determineLegendIcon() //-------------------------------------------------------------------------------------------------- void RimGridCrossPlotCurve::setBlackAndWhiteLegendIcons( bool blackAndWhite ) { - if ( m_qwtPlotCurve ) + if ( m_plotCurve ) { - m_qwtPlotCurve->setBlackAndWhiteLegendIcon( blackAndWhite ); + m_plotCurve->setBlackAndWhiteLegendIcon( blackAndWhite ); } } @@ -132,7 +115,7 @@ void RimGridCrossPlotCurve::setBlackAndWhiteLegendIcons( bool blackAndWhite ) //-------------------------------------------------------------------------------------------------- void RimGridCrossPlotCurve::determineSymbol() { - RiuQwtSymbol::PointSymbolEnum symbol = RiuQwtSymbol::cycledSymbolStyle( m_dataSetIndex ); + RiuPlotCurveSymbol::PointSymbolEnum symbol = RiuPlotCurveSymbol::cycledSymbolStyle( m_dataSetIndex ); setSymbol( symbol ); } @@ -146,20 +129,6 @@ void RimGridCrossPlotCurve::updateZoomInParentPlot() plot->calculateZoomRangeAndUpdateQwt(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimGridCrossPlotCurve::updateLegendsInPlot() -{ - RimGridCrossPlot* plot = nullptr; - this->firstAncestorOrThisOfType( plot ); - if ( plot ) - { - plot->reattachAllCurves(); - } - RimPlotCurve::updateLegendsInPlot(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -175,7 +144,7 @@ void RimGridCrossPlotCurve::onLoadDataAndUpdate( bool updateParentPlot ) { if ( updateParentPlot ) { - m_parentQwtPlot->replot(); + m_parentPlot->replot(); } } diff --git a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotCurve.h b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotCurve.h index dc580fa302..bfc7ce940c 100644 --- a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotCurve.h +++ b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotCurve.h @@ -19,16 +19,6 @@ #include "RimPlotCurve.h" -#include "cafPdmChildField.h" -#include "cafPdmPtrField.h" - -#include -#include - -class RimCase; -class RimEclipseResultDefinition; -class QwtPlotCurve; - //================================================================================================== /// /// @@ -52,7 +42,6 @@ class RimGridCrossPlotCurve : public RimPlotCurve protected: void determineSymbol(); void updateZoomInParentPlot() override; - void updateLegendsInPlot() override; QString createCurveAutoName() override; void onLoadDataAndUpdate( bool updateParentPlot ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; diff --git a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotDataSet.cpp b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotDataSet.cpp index cf1f73583a..063c11398b 100644 --- a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotDataSet.cpp +++ b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotDataSet.cpp @@ -34,6 +34,7 @@ #include "RiuDraggableOverlayFrame.h" #include "RiuGridCrossQwtPlot.h" +#include "RiuPlotWidget.h" #include "RiuScalarMapperLegendFrame.h" #include "RimCase.h" @@ -62,6 +63,8 @@ #include "cvfScalarMapper.h" #include "cvfqtUtils.h" +#include "qwt_plot.h" + #include CAF_PDM_SOURCE_INIT( RimGridCrossPlotDataSet, "GridCrossPlotCurveSet" ); @@ -84,31 +87,31 @@ void RimGridCrossPlotDataSet::CurveGroupingEnum::setUp() //-------------------------------------------------------------------------------------------------- RimGridCrossPlotDataSet::RimGridCrossPlotDataSet() { - CAF_PDM_InitObject( "Cross Plot Data Set", ":/WellLogCurve16x16.png", "", "" ); + CAF_PDM_InitObject( "Cross Plot Data Set", ":/WellLogCurve16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_case, "Case", "Case", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_case, "Case", "Case" ); m_case.uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitField( &m_timeStep, "TimeStep", -1, "Time Step", "", "", "" ); + CAF_PDM_InitField( &m_timeStep, "TimeStep", -1, "Time Step" ); m_timeStep.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_cellFilterView, "VisibleCellView", "Filter by 3d View Visibility", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_cellFilterView, "VisibleCellView", "Filter by 3d View Visibility" ); - CAF_PDM_InitFieldNoDefault( &m_grouping, "Grouping", "Group Data by", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_grouping, "Grouping", "Group Data by" ); - CAF_PDM_InitFieldNoDefault( &m_xAxisProperty, "XAxisProperty", "X-Axis Property", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_xAxisProperty, "XAxisProperty", "X-Axis Property" ); m_xAxisProperty = new RimEclipseResultDefinition( caf::PdmUiItemInfo::TOP ); m_xAxisProperty.uiCapability()->setUiTreeHidden( true ); m_xAxisProperty.uiCapability()->setUiTreeChildrenHidden( true ); m_xAxisProperty->setTernaryEnabled( false ); - CAF_PDM_InitFieldNoDefault( &m_yAxisProperty, "YAxisProperty", "Y-Axis Property", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_yAxisProperty, "YAxisProperty", "Y-Axis Property" ); m_yAxisProperty = new RimEclipseResultDefinition( caf::PdmUiItemInfo::TOP ); m_yAxisProperty.uiCapability()->setUiTreeHidden( true ); m_yAxisProperty.uiCapability()->setUiTreeChildrenHidden( true ); m_yAxisProperty->setTernaryEnabled( false ); - CAF_PDM_InitFieldNoDefault( &m_groupingProperty, "GroupingProperty", "Data Grouping Property", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_groupingProperty, "GroupingProperty", "Data Grouping Property" ); m_groupingProperty = new RimEclipseCellColors; m_groupingProperty->useDiscreteLogLevels( true ); m_groupingProperty.uiCapability()->setUiTreeHidden( true ); @@ -116,18 +119,18 @@ RimGridCrossPlotDataSet::RimGridCrossPlotDataSet() m_groupingProperty->legendConfig()->setMappingMode( RimRegularLegendConfig::MappingType::CATEGORY_INTEGER ); m_groupingProperty->setTernaryEnabled( false ); - CAF_PDM_InitFieldNoDefault( &m_nameConfig, "NameConfig", "Name", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_nameConfig, "NameConfig", "Name" ); m_nameConfig = new RimGridCrossPlotDataSetNameConfig(); m_nameConfig.uiCapability()->setUiTreeHidden( true ); m_nameConfig.uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_crossPlotCurves, "CrossPlotCurves", "Curves", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_crossPlotCurves, "CrossPlotCurves", "Curves" ); m_crossPlotCurves.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitField( &m_useCustomColor, "UseCustomColor", false, "Use Custom Color", "", "", "" ); - CAF_PDM_InitField( &m_customColor, "CustomColor", cvf::Color3f( cvf::Color3f::BLACK ), "Custom Color", "", "", "" ); + CAF_PDM_InitField( &m_useCustomColor, "UseCustomColor", false, "Use Custom Color" ); + CAF_PDM_InitField( &m_customColor, "CustomColor", cvf::Color3f( cvf::Color3f::BLACK ), "Custom Color" ); - CAF_PDM_InitFieldNoDefault( &m_plotCellFilterCollection, "PlotCellFilterCollection", "Cell Filters", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_plotCellFilterCollection, "PlotCellFilterCollection", "Cell Filters" ); m_plotCellFilterCollection.uiCapability()->setUiTreeHidden( true ); m_plotCellFilterCollection.uiCapability()->setUiTreeChildrenHidden( true ); m_plotCellFilterCollection = new RimPlotCellFilterCollection; @@ -162,18 +165,29 @@ void RimGridCrossPlotDataSet::setCellFilterView( RimGridView* cellFilterView ) RigEclipseResultAddress resAddr = eclipseView->cellResult()->eclipseResultAddress(); if ( resAddr.isValid() ) { + m_grouping = NO_GROUPING; + + RimEclipseCase* eclipseCase = eclipseView->eclipseCase(); + if ( eclipseCase ) + { + m_case = eclipseCase; + m_xAxisProperty->setEclipseCase( eclipseCase ); + m_yAxisProperty->setEclipseCase( eclipseCase ); + m_groupingProperty->setEclipseCase( eclipseCase ); + + if ( eclipseCase->activeFormationNames() ) + { + m_grouping = GROUP_BY_FORMATION; + m_groupingProperty->legendConfig()->setColorLegend( + RimRegularLegendConfig::mapToColorLegend( RimRegularLegendConfig::ColorRangesType::CATEGORY ) ); + } + } + m_xAxisProperty->setResultType( resAddr.resultCatType() ); m_xAxisProperty->setResultVariable( resAddr.resultName() ); m_yAxisProperty->setResultType( RiaDefines::ResultCatType::STATIC_NATIVE ); m_yAxisProperty->setResultVariable( "DEPTH" ); m_timeStep = eclipseView->currentTimeStep(); - m_grouping = NO_GROUPING; - if ( eclipseView->eclipseCase() && eclipseView->eclipseCase()->activeFormationNames() ) - { - m_grouping = GROUP_BY_FORMATION; - m_groupingProperty->legendConfig()->setColorLegend( - RimRegularLegendConfig::mapToColorLegend( RimRegularLegendConfig::ColorRangesType::CATEGORY ) ); - } RimGridCrossPlot* parentPlot = nullptr; firstAncestorOrThisOfType( parentPlot ); @@ -196,11 +210,11 @@ void RimGridCrossPlotDataSet::loadDataAndUpdate( bool updateParentPlot ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimGridCrossPlotDataSet::setParentQwtPlotNoReplot( QwtPlot* parent ) +void RimGridCrossPlotDataSet::setParentPlotNoReplot( RiuPlotWidget* parent ) { for ( auto& curve : m_crossPlotCurves() ) { - curve->setParentQwtPlotNoReplot( m_isChecked() ? parent : nullptr ); + curve->setParentPlotNoReplot( m_isChecked() ? parent : nullptr ); } } @@ -341,7 +355,7 @@ void RimGridCrossPlotDataSet::detachAllCurves() { for ( auto curve : m_crossPlotCurves() ) { - curve->detachQwtCurve(); + curve->detach(); } } @@ -369,7 +383,7 @@ RimRegularLegendConfig* RimGridCrossPlotDataSet::legendConfig() const //-------------------------------------------------------------------------------------------------- std::vector RimGridCrossPlotDataSet::curves() const { - return m_crossPlotCurves.childObjects(); + return m_crossPlotCurves.children(); } //-------------------------------------------------------------------------------------------------- @@ -652,8 +666,9 @@ void RimGridCrossPlotDataSet::fillCurveDataInExistingCurves( const RigEclipseCro { CVF_ASSERT( m_crossPlotCurves.size() == 1u ); RimGridCrossPlotCurve* curve = m_crossPlotCurves[0]; - curve->setSamples( result.xValues, result.yValues ); curve->setGroupingInformation( indexInPlot(), 0 ); + curve->updateCurveVisibility(); + curve->setSamples( result.xValues, result.yValues ); curve->updateCurveAppearance(); curve->updateUiIconFromPlotSymbol(); } @@ -665,8 +680,9 @@ void RimGridCrossPlotDataSet::fillCurveDataInExistingCurves( const RigEclipseCro for ( ; curveIt != m_crossPlotCurves.end() && groupIt != m_groupedResults.rend(); ++curveIt, ++groupIt ) { RimGridCrossPlotCurve* curve = *curveIt; - curve->setSamples( groupIt->second.xValues, groupIt->second.yValues ); curve->setGroupingInformation( indexInPlot(), groupIt->first ); + curve->updateCurveVisibility(); + curve->setSamples( groupIt->second.xValues, groupIt->second.yValues ); curve->updateCurveAppearance(); curve->updateUiIconFromPlotSymbol(); } @@ -679,7 +695,7 @@ void RimGridCrossPlotDataSet::fillCurveDataInExistingCurves( const RigEclipseCro void RimGridCrossPlotDataSet::destroyCurves() { detachAllCurves(); - m_crossPlotCurves.deleteAllChildObjects(); + m_crossPlotCurves.deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -941,8 +957,7 @@ void RimGridCrossPlotDataSet::childFieldChangedByUi( const caf::PdmFieldHandle* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList - RimGridCrossPlotDataSet::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) +QList RimGridCrossPlotDataSet::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; @@ -966,7 +981,7 @@ QList if ( eclipseCase ) { options.push_back( caf::PdmOptionItemInfo( "Disabled", nullptr ) ); - for ( RimEclipseView* view : eclipseCase->reservoirViews.childObjects() ) + for ( RimEclipseView* view : eclipseCase->reservoirViews.children() ) { CVF_ASSERT( view && "Really always should have a valid view pointer in ReservoirViews" ); options.push_back( caf::PdmOptionItemInfo( view->name(), view, false, view->uiIconProvider() ) ); @@ -1009,7 +1024,7 @@ void RimGridCrossPlotDataSet::updateLegendRange() RimGridCrossPlot* parent; this->firstAncestorOrThisOfTypeAsserted( parent ); - if ( parent->viewer() ) + if ( parent->plotWidget() ) { if ( groupingEnabled() && m_case() && isChecked() && legendConfig()->showLegend() ) { @@ -1050,17 +1065,17 @@ void RimGridCrossPlotDataSet::updateLegendRange() } if ( !m_legendOverlayFrame ) { - m_legendOverlayFrame = - new RiuDraggableOverlayFrame( parent->viewer()->canvas(), parent->viewer()->overlayMargins() ); + m_legendOverlayFrame = new RiuDraggableOverlayFrame( parent->plotWidget()->getParentForOverlay(), + parent->plotWidget()->overlayMargins() ); } m_legendOverlayFrame->setContentFrame( legendConfig()->makeLegendFrame() ); - parent->viewer()->addOverlayFrame( m_legendOverlayFrame ); + parent->plotWidget()->addOverlayFrame( m_legendOverlayFrame ); } else { if ( m_legendOverlayFrame ) { - parent->viewer()->removeOverlayFrame( m_legendOverlayFrame ); + parent->plotWidget()->removeOverlayFrame( m_legendOverlayFrame ); } } } @@ -1118,8 +1133,8 @@ void RimGridCrossPlotDataSet::swapAxisProperties( bool updatePlot ) RimEclipseResultDefinition* xAxisProperties = m_xAxisProperty(); RimEclipseResultDefinition* yAxisProperties = m_yAxisProperty(); - m_xAxisProperty.removeChildObject( xAxisProperties ); - m_yAxisProperty.removeChildObject( yAxisProperties ); + m_xAxisProperty.removeChild( xAxisProperties ); + m_yAxisProperty.removeChild( yAxisProperties ); m_yAxisProperty = xAxisProperties; m_xAxisProperty = yAxisProperties; @@ -1422,12 +1437,12 @@ CAF_PDM_SOURCE_INIT( RimGridCrossPlotDataSetNameConfig, "RimGridCrossPlotCurveSe RimGridCrossPlotDataSetNameConfig::RimGridCrossPlotDataSetNameConfig() : RimNameConfig( "" ) { - CAF_PDM_InitObject( "Cross Plot Data Set NameGenerator", "", "", "" ); + CAF_PDM_InitObject( "Cross Plot Data Set NameGenerator" ); - CAF_PDM_InitField( &addCaseName, "AddCaseName", true, "Add Case Name", "", "", "" ); - CAF_PDM_InitField( &addAxisVariables, "AddAxisVariables", true, "Add Axis Variables", "", "", "" ); - CAF_PDM_InitField( &addTimestep, "AddTimeStep", true, "Add Time Step", "", "", "" ); - CAF_PDM_InitField( &addGrouping, "AddGrouping", true, "Add Data Group", "", "", "" ); + CAF_PDM_InitField( &addCaseName, "AddCaseName", true, "Add Case Name" ); + CAF_PDM_InitField( &addAxisVariables, "AddAxisVariables", true, "Add Axis Variables" ); + CAF_PDM_InitField( &addTimestep, "AddTimeStep", true, "Add Time Step" ); + CAF_PDM_InitField( &addGrouping, "AddGrouping", true, "Add Data Group" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotDataSet.h b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotDataSet.h index 8c2a877ca1..6483a33806 100644 --- a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotDataSet.h +++ b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotDataSet.h @@ -54,6 +54,7 @@ class RiuDraggableOverlayFrame; class QwtPlot; class QwtPlotCurve; class QString; +class RiuPlotWidget; class RimGridCrossPlotDataSetNameConfig : public RimNameConfig { @@ -99,7 +100,7 @@ class RimGridCrossPlotDataSet : public RimCheckableNamedObject, public RimNameCo void setCellFilterView( RimGridView* cellFilterView ); void loadDataAndUpdate( bool updateParentPlot ); - void setParentQwtPlotNoReplot( QwtPlot* parent ); + void setParentPlotNoReplot( RiuPlotWidget* parent ); QString xAxisName() const; QString yAxisName() const; QString infoText() const; @@ -157,8 +158,7 @@ class RimGridCrossPlotDataSet : public RimCheckableNamedObject, public RimNameCo void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void triggerPlotNameUpdateAndReplot(); void updateDataSetName(); void performAutoNameUpdate() override; diff --git a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimSaturationPressurePlot.cpp b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimSaturationPressurePlot.cpp index b8016fa861..dcf050ed69 100644 --- a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimSaturationPressurePlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimSaturationPressurePlot.cpp @@ -40,7 +40,7 @@ CAF_PDM_SOURCE_INIT( RimSaturationPressurePlot, "RimSaturationPressurePlot" ); //-------------------------------------------------------------------------------------------------- RimSaturationPressurePlot::RimSaturationPressurePlot() { - CAF_PDM_InitObject( "Saturation Pressure Plot", ":/SummaryXPlotLight16x16.png", "", "" ); + CAF_PDM_InitObject( "Saturation Pressure Plot", ":/SummaryXPlotLight16x16.png" ); } //-------------------------------------------------------------------------------------------------- @@ -169,7 +169,7 @@ void RimSaturationPressurePlot::assignCaseAndEquilibriumRegion( RiaDefines::Poro } RimPlotAxisProperties* yAxisProps = yAxisProperties(); - yAxisProps->setInvertedAxis( true ); + yAxisProps->setAxisInverted( true ); { RimEquilibriumAxisAnnotation* annotation = new RimEquilibriumAxisAnnotation; diff --git a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimSaturationPressurePlotCollection.cpp b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimSaturationPressurePlotCollection.cpp index 50349469b8..da80d9b90f 100644 --- a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimSaturationPressurePlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimSaturationPressurePlotCollection.cpp @@ -34,9 +34,9 @@ CAF_PDM_SOURCE_INIT( RimSaturationPressurePlotCollection, "RimSaturationPressure //-------------------------------------------------------------------------------------------------- RimSaturationPressurePlotCollection::RimSaturationPressurePlotCollection() { - CAF_PDM_InitObject( "Saturation Pressure Plots", ":/SummaryXPlotsLight16x16.png", "", "" ); + CAF_PDM_InitObject( "Saturation Pressure Plots", ":/SummaryXPlotsLight16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_saturationPressurePlots, "SaturationPressurePlots", "Saturation Pressure Plots", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_saturationPressurePlots, "SaturationPressurePlots", "Saturation Pressure Plots" ); m_saturationPressurePlots.uiCapability()->setUiTreeHidden( true ); } @@ -110,7 +110,7 @@ std::vector //-------------------------------------------------------------------------------------------------- std::vector RimSaturationPressurePlotCollection::plots() const { - return m_saturationPressurePlots.childObjects(); + return m_saturationPressurePlots.children(); } //-------------------------------------------------------------------------------------------------- @@ -126,7 +126,7 @@ size_t RimSaturationPressurePlotCollection::plotCount() const //-------------------------------------------------------------------------------------------------- void RimSaturationPressurePlotCollection::deleteAllPlots() { - m_saturationPressurePlots.deleteAllChildObjects(); + m_saturationPressurePlots.deleteChildren(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/Intersections/CMakeLists_files.cmake index 51adff8c51..35100c285e 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/CMakeLists_files.cmake +++ b/ApplicationLibCode/ProjectDataModel/Intersections/CMakeLists_files.cmake @@ -5,6 +5,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RimIntersectionCollection.h ${CMAKE_CURRENT_LIST_DIR}/RimIntersectionResultDefinition.h ${CMAKE_CURRENT_LIST_DIR}/RimIntersectionResultsDefinitionCollection.h + ${CMAKE_CURRENT_LIST_DIR}/RimIntersectionEnums.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -14,6 +15,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RimIntersectionResultDefinition.cpp ${CMAKE_CURRENT_LIST_DIR}/RimIntersectionResultsDefinitionCollection.cpp ${CMAKE_CURRENT_LIST_DIR}/RimBoxIntersection.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimIntersectionEnums.cpp ) list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimBoxIntersection.cpp b/ApplicationLibCode/ProjectDataModel/Intersections/RimBoxIntersection.cpp index ea6c0bd8b0..6f009a2f1c 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimBoxIntersection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimBoxIntersection.cpp @@ -63,40 +63,37 @@ const RivIntersectionGeometryGeneratorInterface* RimBoxIntersection::intersectio //-------------------------------------------------------------------------------------------------- RimBoxIntersection::RimBoxIntersection() { - CAF_PDM_InitObject( "Intersection Box", ":/IntersectionBox16x16.png", "", "" ); + CAF_PDM_InitObject( "Intersection Box", ":/IntersectionBox16x16.png" ); - CAF_PDM_InitField( &m_name, "UserDescription", QString( "Intersection Name" ), "Name", "", "", "" ); + CAF_PDM_InitField( &m_name, "UserDescription", QString( "Intersection Name" ), "Name" ); CAF_PDM_InitField( &m_singlePlaneState, "singlePlaneState", caf::AppEnum( SinglePlaneState::PLANE_STATE_NONE ), - "Box Type", - "", - "", - "" ); + "Box Type" ); - CAF_PDM_InitField( &m_minXCoord, "MinXCoord", 0.0, "Min", "", "", "" ); + CAF_PDM_InitField( &m_minXCoord, "MinXCoord", 0.0, "Min" ); m_minXCoord.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_maxXCoord, "MaxXCoord", 0.0, "Max", "", "", "" ); + CAF_PDM_InitField( &m_maxXCoord, "MaxXCoord", 0.0, "Max" ); m_maxXCoord.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_minYCoord, "MinYCoord", 0.0, "Min", "", "", "" ); + CAF_PDM_InitField( &m_minYCoord, "MinYCoord", 0.0, "Min" ); m_minYCoord.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_maxYCoord, "MaxYCoord", 0.0, "Max", "", "", "" ); + CAF_PDM_InitField( &m_maxYCoord, "MaxYCoord", 0.0, "Max" ); m_maxYCoord.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_minDepth, "MinDepth", 0.0, "Min", "", "", "" ); + CAF_PDM_InitField( &m_minDepth, "MinDepth", 0.0, "Min" ); m_minDepth.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_maxDepth, "MaxDepth", 0.0, "Max", "", "", "" ); + CAF_PDM_InitField( &m_maxDepth, "MaxDepth", 0.0, "Max" ); m_maxDepth.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_xySliderStepSize, "xySliderStepSize", 1.0, "XY Slider Step Size", "", "", "" ); - CAF_PDM_InitField( &m_depthSliderStepSize, "DepthSliderStepSize", 0.5, "Depth Slider Step Size", "", "", "" ); + CAF_PDM_InitField( &m_xySliderStepSize, "xySliderStepSize", 1.0, "XY Slider Step Size" ); + CAF_PDM_InitField( &m_depthSliderStepSize, "DepthSliderStepSize", 0.5, "Depth Slider Step Size" ); - CAF_PDM_InitFieldNoDefault( &m_show3DManipulator, "show3DManipulator", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_show3DManipulator, "show3DManipulator", "" ); caf::PdmUiPushButtonEditor::configureEditorForField( &m_show3DManipulator ); m_show3DManipulator = false; diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp b/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp index 018d2b7b1b..25760249b8 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp @@ -22,6 +22,7 @@ #include "RiaVec3Tools.h" #include "RigEclipseCaseData.h" +#include "RigMainGrid.h" #include "RigWellPath.h" #include "Rim2dIntersectionView.h" @@ -46,6 +47,7 @@ #include "RimWellPath.h" #include "RiuViewer.h" + #include "RivExtrudedCurveIntersectionPartMgr.h" #include "cafCmdFeature.h" @@ -214,13 +216,13 @@ RimExtrudedCurveIntersection::RimExtrudedCurveIntersection() m_userPolylineXydForUi.registerSetMethod( this, &RimExtrudedCurveIntersection::setPointsFromXYD ); m_userPolylineXydForUi.registerGetMethod( this, &RimExtrudedCurveIntersection::pointsXYD ); - CAF_PDM_InitField( &m_azimuthAngle, "AzimuthAngle", 0.0, "Azimuth", "", "", "" ); + CAF_PDM_InitField( &m_azimuthAngle, "AzimuthAngle", 0.0, "Azimuth" ); m_azimuthAngle.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_dipAngle, "DipAngle", 90.0, "Dip", "", "", "" ); + CAF_PDM_InitField( &m_dipAngle, "DipAngle", 90.0, "Dip" ); m_dipAngle.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_customExtrusionPoints, "CustomExtrusionPoints", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_customExtrusionPoints, "CustomExtrusionPoints", "" ); CAF_PDM_InitFieldNoDefault( &m_twoAzimuthPoints, "TwoAzimuthPoints", "Points", @@ -228,37 +230,52 @@ RimExtrudedCurveIntersection::RimExtrudedCurveIntersection() "Pick two points to define a line.\nUse Ctrl-C for copy and Ctrl-V for paste", "" ); - CAF_PDM_InitField( &m_branchIndex, "Branch", -1, "Branch", "", "", "" ); - CAF_PDM_InitField( &m_extentLength, "ExtentLength", 200.0, "Extent Length", "", "", "" ); - CAF_PDM_InitField( &m_lengthUp, "lengthUp", 1000.0, "Length Up", "", "", "" ); - CAF_PDM_InitField( &m_lengthDown, "lengthDown", 1000.0, "Length Down", "", "", "" ); + CAF_PDM_InitField( &m_branchIndex, "Branch", -1, "Branch" ); + CAF_PDM_InitField( &m_extentLength, "ExtentLength", 200.0, "Extent Length" ); + CAF_PDM_InitField( &m_lengthUp, "lengthUp", 1000.0, "Length Up" ); + CAF_PDM_InitField( &m_lengthDown, "lengthDown", 1000.0, "Length Down" ); - CAF_PDM_InitFieldNoDefault( &m_inputPolylineFromViewerEnabled, "m_activateUiAppendPointsCommand", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_inputPolylineFromViewerEnabled, "m_activateUiAppendPointsCommand", "" ); caf::PdmUiPushButtonEditor::configureEditorForField( &m_inputPolylineFromViewerEnabled ); m_inputPolylineFromViewerEnabled = false; - CAF_PDM_InitFieldNoDefault( &m_inputExtrusionPointsFromViewerEnabled, - "inputExtrusionPointsFromViewerEnabled", - "", - "", - "", - "" ); + CAF_PDM_InitFieldNoDefault( &m_inputExtrusionPointsFromViewerEnabled, "inputExtrusionPointsFromViewerEnabled", "" ); caf::PdmUiPushButtonEditor::configureEditorForField( &m_inputExtrusionPointsFromViewerEnabled ); m_inputExtrusionPointsFromViewerEnabled = false; - CAF_PDM_InitFieldNoDefault( &m_inputTwoAzimuthPointsFromViewerEnabled, - "inputTwoAzimuthPointsFromViewerEnabled", - "", - "", - "", - "" ); + CAF_PDM_InitFieldNoDefault( &m_inputTwoAzimuthPointsFromViewerEnabled, "inputTwoAzimuthPointsFromViewerEnabled", "" ); caf::PdmUiPushButtonEditor::configureEditorForField( &m_inputTwoAzimuthPointsFromViewerEnabled ); m_inputTwoAzimuthPointsFromViewerEnabled = false; - CAF_PDM_InitFieldNoDefault( &m_surfaceIntersections, "SurfaceIntersections", "Surface Intersections", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_surfaceIntersections, "SurfaceIntersections", "Surface Intersections" ); m_surfaceIntersections = new RimSurfaceIntersectionCollection; m_surfaceIntersections->objectChanged.connect( this, &RimExtrudedCurveIntersection::onSurfaceIntersectionsChanged ); + CAF_PDM_InitField( &m_depthUpperThreshold, "UpperThreshold", 2000.0, "Upper Threshold" ); + m_depthUpperThreshold.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); + + CAF_PDM_InitField( &m_depthLowerThreshold, "LowerThreshold", 3000.0, "Lower Threshold" ); + m_depthLowerThreshold.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); + + CAF_PDM_InitFieldNoDefault( &m_depthFilterType, "DepthFilter", "Depth Filter" ); + + CAF_PDM_InitFieldNoDefault( &m_collectionUpperThreshold, "CollectionUpperThreshold", "Collection Upper Threshold" ); + m_collectionUpperThreshold.uiCapability()->setUiHidden( true ); + + CAF_PDM_InitFieldNoDefault( &m_collectionLowerThreshold, "CollectionLowerThreshold", "Collection Lower Threshold" ); + m_collectionLowerThreshold.uiCapability()->setUiHidden( true ); + + CAF_PDM_InitField( &m_depthThresholdOverridden, + "ThresholdOverridden", + false, + "Depth Filter is Controlled by Intersection Collection" ); + caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_depthThresholdOverridden ); + + CAF_PDM_InitFieldNoDefault( &m_collectionDepthFilterType, + "CollectionDepthFilterType", + "Collection Controlled Filter Type" ); + m_collectionDepthFilterType.uiCapability()->setUiHidden( true ); + setDeletable( true ); } @@ -293,6 +310,104 @@ void RimExtrudedCurveIntersection::setName( const QString& newName ) m_name = newName; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimExtrudedCurveIntersection::upperFilterDepth( double sceneRadius ) const +{ + if ( m_depthThresholdOverridden ) + { + switch ( m_collectionDepthFilterType() ) + { + case RimIntersectionFilterEnum::INTERSECT_FILTER_BELOW: + case RimIntersectionFilterEnum::INTERSECT_FILTER_BETWEEN: + return m_collectionUpperThreshold; + + case RimIntersectionFilterEnum::INTERSECT_FILTER_ABOVE: + case RimIntersectionFilterEnum::INTERSECT_FILTER_NONE: + default: + return -sceneRadius; + } + } + + switch ( m_depthFilterType() ) + { + case RimIntersectionFilterEnum::INTERSECT_FILTER_BELOW: + case RimIntersectionFilterEnum::INTERSECT_FILTER_BETWEEN: + return m_depthUpperThreshold; + + case RimIntersectionFilterEnum::INTERSECT_FILTER_ABOVE: + case RimIntersectionFilterEnum::INTERSECT_FILTER_NONE: + default: + return -sceneRadius; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimIntersectionFilterEnum RimExtrudedCurveIntersection::depthFilterType() const +{ + if ( m_depthThresholdOverridden ) + { + return m_collectionDepthFilterType(); + } + return m_depthFilterType(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimExtrudedCurveIntersection::lowerFilterDepth( double sceneRadius ) const +{ + if ( m_depthThresholdOverridden ) + { + switch ( m_collectionDepthFilterType() ) + { + case RimIntersectionFilterEnum::INTERSECT_FILTER_ABOVE: + case RimIntersectionFilterEnum::INTERSECT_FILTER_BETWEEN: + return m_collectionLowerThreshold; + + case RimIntersectionFilterEnum::INTERSECT_FILTER_BELOW: + case RimIntersectionFilterEnum::INTERSECT_FILTER_NONE: + default: + return sceneRadius; + } + } + + switch ( m_depthFilterType() ) + { + case RimIntersectionFilterEnum::INTERSECT_FILTER_ABOVE: + case RimIntersectionFilterEnum::INTERSECT_FILTER_BETWEEN: + return m_depthLowerThreshold; + + case RimIntersectionFilterEnum::INTERSECT_FILTER_BELOW: + case RimIntersectionFilterEnum::INTERSECT_FILTER_NONE: + default: + return sceneRadius; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimExtrudedCurveIntersection::setDepthOverride( bool collectionOverride ) +{ + m_depthThresholdOverridden = collectionOverride; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimExtrudedCurveIntersection::setDepthOverrideParameters( double upperThreshold, + double lowerThreshold, + RimIntersectionFilterEnum filterType ) +{ + m_collectionUpperThreshold = upperThreshold; + m_collectionLowerThreshold = lowerThreshold; + m_collectionDepthFilterType = filterType; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -304,7 +419,9 @@ void RimExtrudedCurveIntersection::fieldChangedByUi( const caf::PdmFieldHandle* changedField == &m_wellPath || changedField == &m_simulationWell || changedField == &m_branchIndex || changedField == &m_extentLength || changedField == &m_lengthUp || changedField == &m_lengthDown || changedField == &m_showInactiveCells || changedField == &m_useSeparateDataSource || - changedField == &m_separateDataSource ) + changedField == &m_separateDataSource || changedField == &m_depthUpperThreshold || + changedField == &m_depthLowerThreshold || changedField == &m_depthThresholdOverridden || + changedField == &m_depthFilterType ) { rebuildGeometryAndScheduleCreateDisplayModel(); } @@ -411,6 +528,7 @@ void RimExtrudedCurveIntersection::defineUiOrdering( QString uiConfigName, caf:: } caf::PdmUiGroup* optionsGroup = uiOrdering.addNewGroup( "Options" ); + optionsGroup->setCollapsedByDefault( true ); if ( type() == CrossSectionEnum::CS_AZIMUTHLINE ) { @@ -440,6 +558,43 @@ void RimExtrudedCurveIntersection::defineUiOrdering( QString uiConfigName, caf:: m_extentLength.uiCapability()->setUiReadOnly( false ); } + if ( eclipseView() ) + { + auto filterGroup = uiOrdering.addNewGroup( "Depth Filter" ); + if ( m_depthThresholdOverridden() ) + { + filterGroup->add( &m_depthThresholdOverridden ); + } + else + { + filterGroup->add( &m_depthFilterType ); + + switch ( m_depthFilterType() ) + { + case RimIntersectionFilterEnum::INTERSECT_FILTER_BELOW: + m_depthUpperThreshold.uiCapability()->setUiName( "Depth" ); + filterGroup->add( &m_depthUpperThreshold ); + break; + + case RimIntersectionFilterEnum::INTERSECT_FILTER_BETWEEN: + m_depthUpperThreshold.uiCapability()->setUiName( "Upper Depth" ); + filterGroup->add( &m_depthUpperThreshold ); + m_depthLowerThreshold.uiCapability()->setUiName( "Lower Depth" ); + filterGroup->add( &m_depthLowerThreshold ); + break; + + case RimIntersectionFilterEnum::INTERSECT_FILTER_ABOVE: + m_depthLowerThreshold.uiCapability()->setUiName( "Depth" ); + filterGroup->add( &m_depthLowerThreshold ); + break; + + case RimIntersectionFilterEnum::INTERSECT_FILTER_NONE: + default: + break; + } + } + } + this->defineSeparateDataSourceUi( uiConfigName, uiOrdering ); uiOrdering.skipRemainingFields( true ); @@ -449,8 +604,7 @@ void RimExtrudedCurveIntersection::defineUiOrdering( QString uiConfigName, caf:: /// //-------------------------------------------------------------------------------------------------- QList - RimExtrudedCurveIntersection::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) + RimExtrudedCurveIntersection::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; @@ -497,7 +651,7 @@ QList } else { - options = RimIntersection::calculateValueOptions( fieldNeedingOptions, useOptionsOnly ); + options = RimIntersection::calculateValueOptions( fieldNeedingOptions ); } return options; @@ -525,12 +679,11 @@ void RimExtrudedCurveIntersection::defineUiTreeOrdering( caf::PdmUiTreeOrdering& //-------------------------------------------------------------------------------------------------- RimSimWellInViewCollection* RimExtrudedCurveIntersection::simulationWellCollection() const { - RimEclipseView* eclipseView = nullptr; - firstAncestorOrThisOfType( eclipseView ); + RimEclipseView* eclView = eclipseView(); - if ( eclipseView ) + if ( eclView ) { - return eclipseView->wellCollection(); + return eclView->wellCollection(); } return nullptr; @@ -822,11 +975,9 @@ void RimExtrudedCurveIntersection::setPushButtonText( bool buttonEnable, caf::Pd //-------------------------------------------------------------------------------------------------- void RimExtrudedCurveIntersection::setBaseColor( bool enable, caf::PdmUiListEditorAttribute* attribute ) { - // if ( attribute && enable ) if ( attribute ) { attribute->m_qssState = enable ? "ExternalInput" : QString(); - // attribute->m_baseColor.setRgb( 255, 220, 255 ); } } @@ -852,6 +1003,18 @@ void RimExtrudedCurveIntersection::defineEditorAttribute( const caf::PdmFieldHan doubleSliderAttrib->m_maximum = 180; doubleSliderAttrib->m_sliderTickCount = 180; } + else if ( ( field == &m_depthUpperThreshold ) || ( field == &m_depthLowerThreshold ) ) + { + RimEclipseView* eclView = eclipseView(); + + if ( eclView ) + { + const cvf::BoundingBox bb = eclView->mainGrid()->boundingBox(); + + doubleSliderAttrib->m_minimum = -1.0 * bb.max().z(); + doubleSliderAttrib->m_maximum = -1.0 * bb.min().z(); + } + } } else if ( field == &m_inputPolylineFromViewerEnabled ) { @@ -1168,3 +1331,13 @@ void RimExtrudedCurveIntersection::setPointsFromXYD( const std::vector calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; @@ -151,9 +160,20 @@ class RimExtrudedCurveIntersection : public RimIntersection std::vector pointsXYD() const; void setPointsFromXYD( const std::vector& pointsXYD ); + RimEclipseView* eclipseView() const; + private: caf::PdmField m_name; + caf::PdmField> m_depthFilterType; + caf::PdmField m_depthUpperThreshold; + caf::PdmField m_depthLowerThreshold; + + caf::PdmField m_depthThresholdOverridden; + caf::PdmField m_collectionUpperThreshold; + caf::PdmField m_collectionLowerThreshold; + caf::PdmField> m_collectionDepthFilterType; + caf::PdmField> m_type; caf::PdmField> m_direction; diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersection.cpp b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersection.cpp index 78544f6fa7..6cc38af465 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersection.cpp @@ -33,6 +33,8 @@ #include "RivEclipseIntersectionGrid.h" #include "RivFemIntersectionGrid.h" +#include "cafPdmUiCheckBoxEditor.h" + CAF_PDM_ABSTRACT_SOURCE_INIT( RimIntersection, "RimIntersectionHandle" ); //-------------------------------------------------------------------------------------------------- @@ -40,11 +42,14 @@ CAF_PDM_ABSTRACT_SOURCE_INIT( RimIntersection, "RimIntersectionHandle" ); //-------------------------------------------------------------------------------------------------- RimIntersection::RimIntersection() { - CAF_PDM_InitField( &m_isActive, "Active", true, "Active", "", "", "" ); + CAF_PDM_InitField( &m_isActive, "Active", true, "Active" ); m_isActive.uiCapability()->setUiHidden( true ); - CAF_PDM_InitField( &m_showInactiveCells, "ShowInactiveCells", false, "Show Inactive Cells", "", "", "" ); - CAF_PDM_InitField( &m_useSeparateDataSource, "UseSeparateIntersectionDataSource", true, "Enable", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_separateDataSource, "SeparateIntersectionDataSource", "Source", "", "", "" ); + + CAF_PDM_InitField( &m_showInactiveCells, "ShowInactiveCells", false, "Show Inactive Cells" ); + caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_showInactiveCells ); + + CAF_PDM_InitField( &m_useSeparateDataSource, "UseSeparateIntersectionDataSource", true, "Enable" ); + CAF_PDM_InitFieldNoDefault( &m_separateDataSource, "SeparateIntersectionDataSource", "Source" ); } //-------------------------------------------------------------------------------------------------- @@ -101,8 +106,7 @@ RimIntersectionResultDefinition* RimIntersection::activeSeparateResultDefinition //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimIntersection::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RimIntersection::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersection.h b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersection.h index bb8258f08a..e94d2ff776 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersection.h +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersection.h @@ -52,8 +52,7 @@ class RimIntersection : public caf::PdmObject virtual RimIntersectionResultsDefinitionCollection* findSeparateResultsCollection(); caf::PdmFieldHandle* objectToggleField() final; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineSeparateDataSourceUi( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ); void updateDefaultSeparateDataSource(); diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.cpp b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.cpp index 370f501648..af6b931d30 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.cpp @@ -19,11 +19,14 @@ #include "RimIntersectionCollection.h" +#include "RigMainGrid.h" + #include "Rim2dIntersectionView.h" #include "Rim2dIntersectionViewCollection.h" #include "Rim3dView.h" #include "RimBoxIntersection.h" #include "RimCase.h" +#include "RimEclipseView.h" #include "RimExtrudedCurveIntersection.h" #include "RimGridView.h" #include "RimIntersectionResultDefinition.h" @@ -50,14 +53,25 @@ RimIntersectionCollection::RimIntersectionCollection() { CAF_PDM_InitScriptableObject( "Intersections", ":/CrossSections16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_intersections, "CrossSections", "Intersections", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_intersections, "CrossSections", "Intersections" ); m_intersections.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_intersectionBoxes, "IntersectionBoxes", "IntersectionBoxes", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_intersectionBoxes, "IntersectionBoxes", "IntersectionBoxes" ); m_intersectionBoxes.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitField( &isActive, "Active", true, "Active", "", "", "" ); + CAF_PDM_InitField( &isActive, "Active", true, "Active" ); isActive.uiCapability()->setUiHidden( true ); + + CAF_PDM_InitFieldNoDefault( &m_depthUpperThreshold, "UpperDepthThreshold", "Upper Threshold" ); + m_depthUpperThreshold.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); + + CAF_PDM_InitFieldNoDefault( &m_depthLowerThreshold, "LowerDepthThreshold", "Lower Threshold" ); + m_depthLowerThreshold.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); + + CAF_PDM_InitField( &m_depthThresholdOverridden, "DepthFilterOverride", false, "Override Intersection Depth Filters" ); + caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_depthThresholdOverridden ); + + CAF_PDM_InitFieldNoDefault( &m_depthFilterType, "CollectionDepthFilterType", "Depth Filter Type" ); } //-------------------------------------------------------------------------------------------------- @@ -65,8 +79,8 @@ RimIntersectionCollection::RimIntersectionCollection() //-------------------------------------------------------------------------------------------------- RimIntersectionCollection::~RimIntersectionCollection() { - m_intersections.deleteAllChildObjects(); - m_intersectionBoxes.deleteAllChildObjects(); + m_intersections.deleteChildren(); + m_intersectionBoxes.deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -240,7 +254,7 @@ void RimIntersectionCollection::rebuildGeometry() //-------------------------------------------------------------------------------------------------- std::vector RimIntersectionCollection::intersections() const { - return m_intersections.childObjects(); + return m_intersections.children(); } //-------------------------------------------------------------------------------------------------- @@ -248,7 +262,7 @@ std::vector RimIntersectionCollection::intersecti //-------------------------------------------------------------------------------------------------- std::vector RimIntersectionCollection::intersectionBoxes() const { - return m_intersectionBoxes.childObjects(); + return m_intersectionBoxes.children(); } //-------------------------------------------------------------------------------------------------- @@ -270,17 +284,15 @@ void RimIntersectionCollection::appendIntersectionAndUpdate( RimExtrudedCurveInt { m_intersections.push_back( intersection ); + intersection->setDepthOverride( m_depthThresholdOverridden ); + intersection->setDepthOverrideParameters( m_depthUpperThreshold, m_depthLowerThreshold, m_depthFilterType() ); + syncronize2dIntersectionViews(); updateConnectedEditors(); Riu3DMainWindowTools::selectAsCurrentItem( intersection, allowActiveViewChange ); - Rim3dView* rimView = nullptr; - firstAncestorOrThisOfType( rimView ); - if ( rimView ) - { - rimView->scheduleCreateDisplayModelAndRedraw(); - } + rebuild3dView(); } //-------------------------------------------------------------------------------------------------- @@ -288,6 +300,8 @@ void RimIntersectionCollection::appendIntersectionAndUpdate( RimExtrudedCurveInt //-------------------------------------------------------------------------------------------------- void RimIntersectionCollection::appendIntersectionNoUpdate( RimExtrudedCurveIntersection* intersection ) { + intersection->setDepthOverride( m_depthThresholdOverridden ); + intersection->setDepthOverrideParameters( m_depthUpperThreshold, m_depthLowerThreshold, m_depthFilterType() ); m_intersections.push_back( intersection ); } @@ -325,12 +339,7 @@ void RimIntersectionCollection::appendIntersectionBoxAndUpdate( RimBoxIntersecti updateConnectedEditors(); Riu3DMainWindowTools::selectAsCurrentItem( intersectionBox, false ); - Rim3dView* rimView = nullptr; - firstAncestorOrThisOfType( rimView ); - if ( rimView ) - { - rimView->scheduleCreateDisplayModelAndRedraw(); - } + rebuild3dView(); } //-------------------------------------------------------------------------------------------------- @@ -348,16 +357,41 @@ void RimIntersectionCollection::fieldChangedByUi( const caf::PdmFieldHandle* cha const QVariant& oldValue, const QVariant& newValue ) { + bool rebuildView = false; + if ( changedField == &isActive ) { updateUiIconFromToggleField(); + rebuildView = true; + } + if ( changedField == &m_depthThresholdOverridden ) + { + for ( RimExtrudedCurveIntersection* cs : m_intersections ) + { + cs->setDepthOverride( m_depthThresholdOverridden ); + if ( m_depthThresholdOverridden() ) + { + cs->setDepthOverrideParameters( m_depthUpperThreshold, m_depthLowerThreshold, m_depthFilterType() ); + } + cs->rebuildGeometryAndScheduleCreateDisplayModel(); + } + rebuildView = true; + } - Rim3dView* rimView = nullptr; - firstAncestorOrThisOfType( rimView ); - if ( rimView ) + if ( ( changedField == &m_depthUpperThreshold ) || ( changedField == &m_depthLowerThreshold ) || + ( changedField == &m_depthFilterType ) ) + { + for ( RimExtrudedCurveIntersection* cs : m_intersections ) { - rimView->scheduleCreateDisplayModelAndRedraw(); + cs->setDepthOverrideParameters( m_depthUpperThreshold, m_depthLowerThreshold, m_depthFilterType() ); + cs->rebuildGeometryAndScheduleCreateDisplayModel(); } + rebuildView = true; + } + + if ( rebuildView ) + { + rebuild3dView(); } } @@ -368,13 +402,7 @@ void RimIntersectionCollection::onChildDeleted( caf::PdmChildArrayFieldHandle* std::vector& referringObjects ) { syncronize2dIntersectionViews(); - - Rim3dView* rimView = nullptr; - firstAncestorOrThisOfType( rimView ); - if ( rimView ) - { - rimView->scheduleCreateDisplayModelAndRedraw(); - } + rebuild3dView(); } //-------------------------------------------------------------------------------------------------- @@ -383,6 +411,7 @@ void RimIntersectionCollection::onChildDeleted( caf::PdmChildArrayFieldHandle* void RimIntersectionCollection::onChildAdded( caf::PdmFieldHandle* containerForNewObject ) { syncronize2dIntersectionViews(); + rebuild3dView(); } //-------------------------------------------------------------------------------------------------- @@ -414,3 +443,95 @@ void RimIntersectionCollection::updateIntersectionBoxGeometry() intersectionBox->updateBoxManipulatorGeometry(); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimIntersectionCollection::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +{ + if ( eclipseView() ) + { + caf::PdmUiGroup* filterGroup = uiOrdering.addNewGroup( "Depth Filter - Curve Intersections" ); + + m_depthFilterType.uiCapability()->setUiReadOnly( !m_depthThresholdOverridden() ); + m_depthUpperThreshold.uiCapability()->setUiReadOnly( !m_depthThresholdOverridden() ); + m_depthLowerThreshold.uiCapability()->setUiReadOnly( !m_depthThresholdOverridden() ); + + filterGroup->add( &m_depthThresholdOverridden ); + filterGroup->add( &m_depthFilterType ); + + switch ( m_depthFilterType() ) + { + case RimIntersectionFilterEnum::INTERSECT_FILTER_BELOW: + m_depthUpperThreshold.uiCapability()->setUiName( "Depth" ); + filterGroup->add( &m_depthUpperThreshold ); + break; + + case RimIntersectionFilterEnum::INTERSECT_FILTER_BETWEEN: + m_depthUpperThreshold.uiCapability()->setUiName( "Upper Depth" ); + filterGroup->add( &m_depthUpperThreshold ); + m_depthLowerThreshold.uiCapability()->setUiName( "Lower Depth" ); + filterGroup->add( &m_depthLowerThreshold ); + break; + + case RimIntersectionFilterEnum::INTERSECT_FILTER_ABOVE: + m_depthLowerThreshold.uiCapability()->setUiName( "Depth" ); + filterGroup->add( &m_depthLowerThreshold ); + break; + + case RimIntersectionFilterEnum::INTERSECT_FILTER_NONE: + default: + break; + } + } + + uiOrdering.skipRemainingFields( true ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimIntersectionCollection::defineEditorAttribute( const caf::PdmFieldHandle* field, + QString uiConfigName, + caf::PdmUiEditorAttribute* attribute ) +{ + auto* doubleSliderAttrib = dynamic_cast( attribute ); + if ( doubleSliderAttrib ) + { + if ( ( field == &m_depthUpperThreshold ) || ( field == &m_depthLowerThreshold ) ) + { + RimEclipseView* eclView = eclipseView(); + + if ( eclView ) + { + const cvf::BoundingBox bb = eclView->mainGrid()->boundingBox(); + + doubleSliderAttrib->m_minimum = -1.0 * bb.max().z(); + doubleSliderAttrib->m_maximum = -1.0 * bb.min().z(); + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseView* RimIntersectionCollection::eclipseView() const +{ + RimEclipseView* eclipseView = nullptr; + firstAncestorOrThisOfType( eclipseView ); + return eclipseView; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimIntersectionCollection::rebuild3dView() const +{ + Rim3dView* rimView = nullptr; + firstAncestorOrThisOfType( rimView ); + if ( rimView ) + { + rimView->scheduleCreateDisplayModelAndRedraw(); + } +} diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.h b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.h index 1aa7aff22a..cb48b86ecc 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.h @@ -23,7 +23,10 @@ #include "cafPdmField.h" #include "cafPdmObject.h" +#include "RimIntersectionEnums.h" + class Rim3dView; +class RimEclipseView; class RimExtrudedCurveIntersection; class RimBoxIntersection; class RimEclipseCellColors; @@ -85,9 +88,22 @@ class RimIntersectionCollection : public caf::PdmObject protected: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; caf::PdmFieldHandle* objectToggleField() override; + void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + void defineEditorAttribute( const caf::PdmFieldHandle* field, + QString uiConfigName, + caf::PdmUiEditorAttribute* attribute ) override; private: + RimEclipseView* eclipseView() const; + void rebuild3dView() const; + caf::PdmChildArrayField m_intersections; caf::PdmChildArrayField m_intersectionBoxes; + + caf::PdmField m_depthThresholdOverridden; + caf::PdmField m_depthUpperThreshold; + caf::PdmField m_depthLowerThreshold; + caf::PdmField> m_depthFilterType; }; diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionEnums.cpp b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionEnums.cpp new file mode 100644 index 0000000000..3c57dcf5db --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionEnums.cpp @@ -0,0 +1,35 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimIntersectionEnums.h" + +#include "cafAppEnum.h" + +namespace caf +{ +template <> +void caf::AppEnum::setUp() +{ + addItem( RimIntersectionFilterEnum::INTERSECT_FILTER_NONE, "INTERSECT_SHOW_ALL", "None" ); + addItem( RimIntersectionFilterEnum::INTERSECT_FILTER_ABOVE, "INTERSECT_SHOW_ABOVE", "Above" ); + addItem( RimIntersectionFilterEnum::INTERSECT_FILTER_BELOW, "INTERSECT_SHOW_BELOW", "Below" ); + addItem( RimIntersectionFilterEnum::INTERSECT_FILTER_BETWEEN, "INTERSECT_SHOW_BELOW", "Between" ); + setDefault( RimIntersectionFilterEnum::INTERSECT_FILTER_NONE ); +} + +} // namespace caf diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionEnums.h b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionEnums.h new file mode 100644 index 0000000000..b23e462297 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionEnums.h @@ -0,0 +1,27 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +enum class RimIntersectionFilterEnum +{ + INTERSECT_FILTER_NONE, + INTERSECT_FILTER_ABOVE, + INTERSECT_FILTER_BELOW, + INTERSECT_FILTER_BETWEEN +}; diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionResultDefinition.cpp b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionResultDefinition.cpp index e4edc62bce..8ca4308f28 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionResultDefinition.cpp +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionResultDefinition.cpp @@ -42,36 +42,36 @@ CAF_PDM_SOURCE_INIT( RimIntersectionResultDefinition, "IntersectionResultDefinit //-------------------------------------------------------------------------------------------------- RimIntersectionResultDefinition::RimIntersectionResultDefinition() { - CAF_PDM_InitObject( "Intersection Result Definition", ":/CellResult.png", "", "" ); + CAF_PDM_InitObject( "Intersection Result Definition", ":/CellResult.png" ); - CAF_PDM_InitField( &m_isActive, "IsActive", true, "Active", "", "", "" ); + CAF_PDM_InitField( &m_isActive, "IsActive", true, "Active" ); m_isActive.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_case, "Case", "Case", "", "", "" ); - CAF_PDM_InitField( &m_timeStep, "TimeStep", 0, "Time Step", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_case, "Case", "Case" ); + CAF_PDM_InitField( &m_timeStep, "TimeStep", 0, "Time Step" ); - CAF_PDM_InitFieldNoDefault( &m_autoName, "IntersectionResultDefinitionDescription", "Description", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_autoName, "IntersectionResultDefinitionDescription", "Description" ); m_autoName.registerGetMethod( this, &RimIntersectionResultDefinition::autoName ); m_autoName.uiCapability()->setUiHidden( true ); m_autoName.uiCapability()->setUiReadOnly( true ); m_autoName.xmlCapability()->setIOWritable( false ); - CAF_PDM_InitFieldNoDefault( &m_eclipseResultDefinition, "EclipseResultDef", "EclipseResultDef", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_eclipseResultDefinition, "EclipseResultDef", "EclipseResultDef" ); m_eclipseResultDefinition.uiCapability()->setUiTreeHidden( true ); m_eclipseResultDefinition.uiCapability()->setUiTreeChildrenHidden( true ); m_eclipseResultDefinition = new RimEclipseResultDefinition; - CAF_PDM_InitFieldNoDefault( &m_geomResultDefinition, "GeoMechResultDef", "GeoMechResultDef", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_geomResultDefinition, "GeoMechResultDef", "GeoMechResultDef" ); m_geomResultDefinition.uiCapability()->setUiTreeHidden( true ); m_geomResultDefinition.uiCapability()->setUiTreeChildrenHidden( true ); m_geomResultDefinition = new RimGeoMechResultDefinition; - CAF_PDM_InitFieldNoDefault( &m_legendConfig, "LegendConfig", "Legend", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_legendConfig, "LegendConfig", "Legend" ); m_legendConfig.uiCapability()->setUiTreeHidden( true ); m_legendConfig.uiCapability()->setUiTreeChildrenHidden( false ); m_legendConfig = new RimRegularLegendConfig; - CAF_PDM_InitFieldNoDefault( &m_ternaryLegendConfig, "TernaryLegendConfig", "Legend", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_ternaryLegendConfig, "TernaryLegendConfig", "Legend" ); m_ternaryLegendConfig.uiCapability()->setUiTreeHidden( true ); m_ternaryLegendConfig.uiCapability()->setUiTreeChildrenHidden( false ); m_ternaryLegendConfig = new RimTernaryLegendConfig; @@ -387,12 +387,29 @@ void RimIntersectionResultDefinition::update2dIntersectionViews() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimIntersectionResultDefinition::setDefaultEclipseLegendConfig() +{ + bool useDiscreteLogLevels = false; + bool isCategoryResult = m_eclipseResultDefinition->hasCategoryResult(); + + auto eclResultDef = this->eclipseResultDefinition(); + eclResultDef->updateRangesForExplicitLegends( this->regularLegendConfig(), + this->ternaryLegendConfig(), + this->timeStep() ); + + m_legendConfig->setDefaultConfigForResultName( m_eclipseResultDefinition->resultVariable(), + useDiscreteLogLevels, + isCategoryResult ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- QList - RimIntersectionResultDefinition::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) + RimIntersectionResultDefinition::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionResultDefinition.h b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionResultDefinition.h index 706c3a9ce6..bf5c55df21 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionResultDefinition.h +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionResultDefinition.h @@ -59,18 +59,16 @@ class RimIntersectionResultDefinition : public caf::PdmObject bool isUsingOverrideViewer ); void update2dIntersectionViews(); + void setDefaultEclipseLegendConfig(); protected: caf::PdmFieldHandle* userDescriptionField() override; caf::PdmFieldHandle* objectToggleField() override; - void fieldChangedByUi( const caf::PdmFieldHandle* changedField, - const QVariant& oldValue, - const QVariant& newValue ) override; + void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; - void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; void initAfterRead() override; diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionResultsDefinitionCollection.cpp b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionResultsDefinitionCollection.cpp index 157b1b26b2..26275e1ba2 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionResultsDefinitionCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionResultsDefinitionCollection.cpp @@ -30,12 +30,12 @@ CAF_PDM_SOURCE_INIT( RimIntersectionResultsDefinitionCollection, "RimIntersectio //-------------------------------------------------------------------------------------------------- RimIntersectionResultsDefinitionCollection::RimIntersectionResultsDefinitionCollection() { - CAF_PDM_InitObject( "Intersection Results", ":/CrossSections16x16.png", "", "" ); + CAF_PDM_InitObject( "Intersection Results", ":/CrossSections16x16.png" ); - CAF_PDM_InitField( &m_isActive, "isActive", false, "Active", "", "", "" ); + CAF_PDM_InitField( &m_isActive, "isActive", false, "Active" ); m_isActive.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_intersectionResultsDefs, "IntersectionResultDefinitions", "Data Sources", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_intersectionResultsDefs, "IntersectionResultDefinitions", "Data Sources" ); m_intersectionResultsDefs.uiCapability()->setUiTreeHidden( true ); m_intersectionResultsDefs.push_back( new RimIntersectionResultDefinition ); // Add the default result definition @@ -61,7 +61,7 @@ bool RimIntersectionResultsDefinitionCollection::isActive() const //-------------------------------------------------------------------------------------------------- std::vector RimIntersectionResultsDefinitionCollection::intersectionResultsDefinitions() const { - return m_intersectionResultsDefs.childObjects(); + return m_intersectionResultsDefs.children(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Measurement/RimMeasurement.cpp b/ApplicationLibCode/ProjectDataModel/Measurement/RimMeasurement.cpp index 73bad806b1..00bf13dca7 100644 --- a/ApplicationLibCode/ProjectDataModel/Measurement/RimMeasurement.cpp +++ b/ApplicationLibCode/ProjectDataModel/Measurement/RimMeasurement.cpp @@ -39,7 +39,7 @@ CAF_PDM_SOURCE_INIT( RimMeasurement, "RimMeasurement" ); RimMeasurement::RimMeasurement() : m_measurementMode( MEASURE_DISABLED ) { - CAF_PDM_InitObject( "Measurement", ":/TextAnnotation16x16.png", "", "" ); + CAF_PDM_InitObject( "Measurement", ":/TextAnnotation16x16.png" ); } //-------------------------------------------------------------------------------------------------- @@ -76,7 +76,7 @@ void RimMeasurement::setMeasurementMode( MeasurementMode measurementMode ) } } - RiuMainWindow::instance()->refreshViewActions(); + if ( RiuMainWindow::instance() ) RiuMainWindow::instance()->refreshViewActions(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Parameters/RimDoubleParameter.cpp b/ApplicationLibCode/ProjectDataModel/Parameters/RimDoubleParameter.cpp index b0d0fdbae8..9c74f2f12f 100644 --- a/ApplicationLibCode/ProjectDataModel/Parameters/RimDoubleParameter.cpp +++ b/ApplicationLibCode/ProjectDataModel/Parameters/RimDoubleParameter.cpp @@ -32,7 +32,7 @@ CAF_PDM_SOURCE_INIT( RimDoubleParameter, "DoubleParameter" ); //-------------------------------------------------------------------------------------------------- RimDoubleParameter::RimDoubleParameter() { - CAF_PDM_InitField( &m_value, "Value", 0.0, "Value", "", "", "" ); + CAF_PDM_InitField( &m_value, "Value", 0.0, "Value" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Parameters/RimGenericParameter.cpp b/ApplicationLibCode/ProjectDataModel/Parameters/RimGenericParameter.cpp index 91a24850fa..8f9dd4f1a7 100644 --- a/ApplicationLibCode/ProjectDataModel/Parameters/RimGenericParameter.cpp +++ b/ApplicationLibCode/ProjectDataModel/Parameters/RimGenericParameter.cpp @@ -34,25 +34,25 @@ CAF_PDM_ABSTRACT_SOURCE_INIT( RimGenericParameter, "GenericParameter" ); //-------------------------------------------------------------------------------------------------- RimGenericParameter::RimGenericParameter() { - CAF_PDM_InitObject( "Parameter", ":/Bullet.png", "", "" ); + CAF_PDM_InitObject( "Parameter", ":/Bullet.png" ); - CAF_PDM_InitField( &m_name, "Name", QString(), "Name", "", "", "" ); + CAF_PDM_InitField( &m_name, "Name", QString(), "Name" ); m_name.uiCapability()->setUiReadOnly( true ); m_name.uiCapability()->setUiHidden( true ); - CAF_PDM_InitField( &m_label, "Label", QString(), "Name", "", "", "" ); + CAF_PDM_InitField( &m_label, "Label", QString(), "Name" ); m_label.uiCapability()->setUiReadOnly( true ); m_label.uiCapability()->setUiContentTextColor( RiuGuiTheme::getColorByVariableName( "textColor" ) ); - CAF_PDM_InitField( &m_description, "Description", QString(), "Description", "", "", "" ); + CAF_PDM_InitField( &m_description, "Description", QString(), "Description" ); m_description.uiCapability()->setUiReadOnly( true ); m_description.uiCapability()->setUiHidden( true ); - CAF_PDM_InitField( &m_advanced, "Advanced", false, "Advanced", "", "", "" ); + CAF_PDM_InitField( &m_advanced, "Advanced", false, "Advanced" ); m_advanced.uiCapability()->setUiReadOnly( true ); m_advanced.uiCapability()->setUiHidden( true ); - CAF_PDM_InitField( &m_valid, "Valid", false, "Valid", "", "", "" ); + CAF_PDM_InitField( &m_valid, "Valid", false, "Valid" ); m_valid.uiCapability()->setUiReadOnly( true ); m_valid.uiCapability()->setUiHidden( true ); } diff --git a/ApplicationLibCode/ProjectDataModel/Parameters/RimIntegerParameter.cpp b/ApplicationLibCode/ProjectDataModel/Parameters/RimIntegerParameter.cpp index 97c2dc1c84..90adaca711 100644 --- a/ApplicationLibCode/ProjectDataModel/Parameters/RimIntegerParameter.cpp +++ b/ApplicationLibCode/ProjectDataModel/Parameters/RimIntegerParameter.cpp @@ -32,7 +32,7 @@ CAF_PDM_SOURCE_INIT( RimIntegerParameter, "IntegerParameter" ); //-------------------------------------------------------------------------------------------------- RimIntegerParameter::RimIntegerParameter() { - CAF_PDM_InitField( &m_value, "Value", 0, "Value", "", "", "" ); + CAF_PDM_InitField( &m_value, "Value", 0, "Value" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Parameters/RimParameterGroup.cpp b/ApplicationLibCode/ProjectDataModel/Parameters/RimParameterGroup.cpp index feeaadc807..590e2f1b89 100644 --- a/ApplicationLibCode/ProjectDataModel/Parameters/RimParameterGroup.cpp +++ b/ApplicationLibCode/ProjectDataModel/Parameters/RimParameterGroup.cpp @@ -38,39 +38,39 @@ CAF_PDM_SOURCE_INIT( RimParameterGroup, "ParameterGroup" ); //-------------------------------------------------------------------------------------------------- RimParameterGroup::RimParameterGroup() { - CAF_PDM_InitObject( "Parameter Group", ":/Bullet.png", "", "" ); + CAF_PDM_InitObject( "Parameter Group", ":/Bullet.png" ); uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_parameters, "Parameters", "Parameters", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_parameters, "Parameters", "Parameters" ); m_parameters.uiCapability()->setUiEditorTypeName( caf::PdmUiTableViewEditor::uiEditorTypeName() ); m_parameters.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); m_parameters.uiCapability()->setCustomContextMenuEnabled( true ); m_parameters.uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_name, "Name", "Name", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_name, "Name", "Name" ); m_name.uiCapability()->setUiHidden( true ); m_name.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitFieldNoDefault( &m_label, "Label", "Label", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_label, "Label", "Label" ); m_label.uiCapability()->setUiHidden( true ); m_label.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitFieldNoDefault( &m_comment, "Comment", "Comment", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_comment, "Comment", "Comment" ); m_comment.uiCapability()->setUiHidden( true ); m_comment.uiCapability()->setUiReadOnly( true ); m_comment.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); - CAF_PDM_InitFieldNoDefault( &m_showExpanded, "Expanded", "Expanded", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_showExpanded, "Expanded", "Expanded" ); m_showExpanded.uiCapability()->setUiHidden( true ); m_showExpanded.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitFieldNoDefault( &m_labelProxy, "LabelProxy", "Label Proxy", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_labelProxy, "LabelProxy", "Label Proxy" ); m_labelProxy.registerGetMethod( this, &RimParameterGroup::labelOrName ); m_labelProxy.uiCapability()->setUiReadOnly( true ); m_labelProxy.uiCapability()->setUiHidden( true ); m_labelProxy.xmlCapability()->disableIO(); - CAF_PDM_InitFieldNoDefault( &m_lists, "ParameterLists", "Parameter Lists", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_lists, "ParameterLists", "Parameter Lists" ); m_lists.uiCapability()->setUiHidden( true ); m_lists.uiCapability()->setUiTreeHidden( true ); m_lists.uiCapability()->setUiTreeChildrenHidden( true ); @@ -280,7 +280,7 @@ std::vector RimParameterGroup::parameters() const { std::vector retParams; - for ( const auto& p : m_parameters.childObjects() ) + for ( const auto& p : m_parameters.children() ) { if ( isListParameter( p->name() ) ) continue; retParams.push_back( p ); @@ -288,7 +288,7 @@ std::vector RimParameterGroup::parameters() const for ( const auto& list : m_lists ) { - retParams.push_back( list->getAsListParameter( m_parameters.childObjects() ) ); + retParams.push_back( list->getAsListParameter( m_parameters.children() ) ); } return retParams; @@ -324,7 +324,7 @@ void RimParameterGroup::setParameterValue( QString name, QString value ) //-------------------------------------------------------------------------------------------------- RimGenericParameter* RimParameterGroup::parameter( QString name ) const { - for ( auto& p : m_parameters.childObjects() ) + for ( auto& p : m_parameters.children() ) { if ( p->name() == name ) { diff --git a/ApplicationLibCode/ProjectDataModel/Parameters/RimParameterList.cpp b/ApplicationLibCode/ProjectDataModel/Parameters/RimParameterList.cpp index 1b3a0d9560..174b6012cd 100644 --- a/ApplicationLibCode/ProjectDataModel/Parameters/RimParameterList.cpp +++ b/ApplicationLibCode/ProjectDataModel/Parameters/RimParameterList.cpp @@ -29,18 +29,18 @@ CAF_PDM_SOURCE_INIT( RimParameterList, "ParameterList" ); //-------------------------------------------------------------------------------------------------- RimParameterList::RimParameterList() { - CAF_PDM_InitObject( "Parameter List", ":/Bullet.png", "", "" ); + CAF_PDM_InitObject( "Parameter List", ":/Bullet.png" ); uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_parameterNames, "ParameterNames", "Parameters", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_parameterNames, "ParameterNames", "Parameters" ); m_parameterNames.uiCapability()->setUiHidden( true ); m_parameterNames.uiCapability()->setUiTreeHidden( true ); m_parameterNames.uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitField( &m_name, "Name", QString(), "Name", "", "", "" ); + CAF_PDM_InitField( &m_name, "Name", QString(), "Name" ); m_name.uiCapability()->setUiHidden( true ); - CAF_PDM_InitField( &m_label, "Label", QString(), "Name", "", "", "" ); + CAF_PDM_InitField( &m_label, "Label", QString(), "Name" ); m_label.uiCapability()->setUiHidden( true ); } diff --git a/ApplicationLibCode/ProjectDataModel/Parameters/RimStringParameter.cpp b/ApplicationLibCode/ProjectDataModel/Parameters/RimStringParameter.cpp index cff206b900..5d7e1c90ea 100644 --- a/ApplicationLibCode/ProjectDataModel/Parameters/RimStringParameter.cpp +++ b/ApplicationLibCode/ProjectDataModel/Parameters/RimStringParameter.cpp @@ -32,7 +32,7 @@ CAF_PDM_SOURCE_INIT( RimStringParameter, "StringParameter" ); //-------------------------------------------------------------------------------------------------- RimStringParameter::RimStringParameter() { - CAF_PDM_InitField( &m_value, "Value", QString(), "Value", "", "", "" ); + CAF_PDM_InitField( &m_value, "Value", QString(), "Value" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/PlotTemplates/RimPlotTemplateFileItem.cpp b/ApplicationLibCode/ProjectDataModel/PlotTemplates/RimPlotTemplateFileItem.cpp index 231249df9d..78b4bd43ca 100644 --- a/ApplicationLibCode/ProjectDataModel/PlotTemplates/RimPlotTemplateFileItem.cpp +++ b/ApplicationLibCode/ProjectDataModel/PlotTemplates/RimPlotTemplateFileItem.cpp @@ -20,6 +20,7 @@ #include "RiaFieldHandleTools.h" #include "RiaLogging.h" +#include "RiaPreferencesSummary.h" #include "cafPdmField.h" #include "cafPdmUiFilePathEditor.h" @@ -35,7 +36,7 @@ RimPlotTemplateFileItem::RimPlotTemplateFileItem() { CAF_PDM_InitObject( "PlotTemplateFileItem", ":/SummaryTemplate16x16.png", "Plot Template", "" ); - CAF_PDM_InitField( &m_absoluteFileName, "AbsolutePath", QString(), "Location", "", "", "" ); + CAF_PDM_InitField( &m_absoluteFileName, "AbsolutePath", QString(), "Location" ); m_absoluteFileName.uiCapability()->setUiReadOnly( true ); } @@ -55,6 +56,9 @@ void RimPlotTemplateFileItem::setFilePath( const QString& filePath ) this->uiCapability()->setUiName( fi.baseName() ); m_absoluteFileName = filePath; + + if ( isEnsembleTemplate() ) + this->uiCapability()->setUiIcon( caf::IconProvider( ":/SummaryEnsembleTemplate16x16.png" ) ); } //-------------------------------------------------------------------------------------------------- @@ -64,3 +68,39 @@ QString RimPlotTemplateFileItem::absoluteFilePath() const { return m_absoluteFileName(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimPlotTemplateFileItem::isEnsembleTemplate() const +{ + return m_absoluteFileName().toLower().endsWith( ".erpt" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotTemplateFileItem::updateIconState() +{ + caf::IconProvider iconProvider = this->uiIconProvider(); + if ( !iconProvider.valid() ) return; + + if ( isDefaultTemplate() ) + { + iconProvider.setOverlayResourceString( ":/CheckOverlay16x16.png" ); + } + else + { + iconProvider.setOverlayResourceString( "" ); + } + + this->setUiIcon( iconProvider ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimPlotTemplateFileItem::isDefaultTemplate() const +{ + return RiaPreferencesSummary::current()->isDefaultSummaryPlotTemplate( absoluteFilePath() ); +} diff --git a/ApplicationLibCode/ProjectDataModel/PlotTemplates/RimPlotTemplateFileItem.h b/ApplicationLibCode/ProjectDataModel/PlotTemplates/RimPlotTemplateFileItem.h index 6e5d59e15d..ae84a2af8a 100644 --- a/ApplicationLibCode/ProjectDataModel/PlotTemplates/RimPlotTemplateFileItem.h +++ b/ApplicationLibCode/ProjectDataModel/PlotTemplates/RimPlotTemplateFileItem.h @@ -36,6 +36,12 @@ class RimPlotTemplateFileItem : public caf::PdmObject void setFilePath( const QString& filePath ); QString absoluteFilePath() const; + bool isEnsembleTemplate() const; + + bool isDefaultTemplate() const; + + void updateIconState(); + private: caf::PdmField m_absoluteFileName; }; diff --git a/ApplicationLibCode/ProjectDataModel/PlotTemplates/RimPlotTemplateFolderItem.cpp b/ApplicationLibCode/ProjectDataModel/PlotTemplates/RimPlotTemplateFolderItem.cpp index a5811a5e6b..6dcd38add2 100644 --- a/ApplicationLibCode/ProjectDataModel/PlotTemplates/RimPlotTemplateFolderItem.cpp +++ b/ApplicationLibCode/ProjectDataModel/PlotTemplates/RimPlotTemplateFolderItem.cpp @@ -35,12 +35,13 @@ CAF_PDM_SOURCE_INIT( RimPlotTemplateFolderItem, "PlotTemplateCollection" ); //-------------------------------------------------------------------------------------------------- RimPlotTemplateFolderItem::RimPlotTemplateFolderItem() { - CAF_PDM_InitObject( "PlotTemplateCollection", ":/Folder.png", "", "" ); + CAF_PDM_InitObject( "Plot Templates", ":/Folder.png" ); - CAF_PDM_InitFieldNoDefault( &m_folderName, "FolderName", "Folder", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_fileNames, "FileNames", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_folderName, "FolderName", "Folder" ); + m_folderName.uiCapability()->setUiReadOnly( true ); + CAF_PDM_InitFieldNoDefault( &m_fileNames, "FileNames", "" ); m_fileNames.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_subFolders, "SubFolders", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_subFolders, "SubFolders", "" ); m_subFolders.uiCapability()->setUiTreeHidden( true ); } @@ -56,10 +57,27 @@ RimPlotTemplateFolderItem::~RimPlotTemplateFolderItem() //-------------------------------------------------------------------------------------------------- void RimPlotTemplateFolderItem::createRootFolderItemsFromFolderPaths( const QStringList& folderPaths ) { - m_fileNames.deleteAllChildObjects(); - m_subFolders.deleteAllChildObjects(); + m_fileNames.deleteChildren(); + m_subFolders.deleteChildren(); - createSubFolderItemsFromFolderPaths( folderPaths ); + createSubFolderItemsFromFolderPaths( folderPaths, RiaPreferences::current()->maxPlotTemplateFoldersDepth() ); + updateIconState(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotTemplateFolderItem::updateIconState() const +{ + for ( auto& folder : m_subFolders() ) + { + folder->updateIconState(); + } + + for ( auto& item : m_fileNames() ) + { + item->updateIconState(); + } } //-------------------------------------------------------------------------------------------------- @@ -67,7 +85,7 @@ void RimPlotTemplateFolderItem::createRootFolderItemsFromFolderPaths( const QStr //-------------------------------------------------------------------------------------------------- std::vector RimPlotTemplateFolderItem::fileNames() const { - return m_fileNames.childObjects(); + return m_fileNames.children(); } //-------------------------------------------------------------------------------------------------- @@ -75,7 +93,7 @@ std::vector RimPlotTemplateFolderItem::fileNames() con //-------------------------------------------------------------------------------------------------- std::vector RimPlotTemplateFolderItem::subFolders() const { - return m_subFolders.childObjects(); + return m_subFolders.children(); } //-------------------------------------------------------------------------------------------------- @@ -101,16 +119,19 @@ void RimPlotTemplateFolderItem::setFolderPath( const QString& path ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimPlotTemplateFolderItem::searchForFileAndFolderNames() +void RimPlotTemplateFolderItem::searchForFileAndFolderNames( int levelsLeft ) { - m_fileNames.deleteAllChildObjects(); - m_subFolders.deleteAllChildObjects(); + m_fileNames.deleteChildren(); + m_subFolders.deleteChildren(); + + levelsLeft--; + if ( levelsLeft < 0 ) return; if ( m_folderName().path().isEmpty() ) { for ( size_t i = 0; i < m_subFolders.size(); ++i ) { - if ( m_subFolders[i] ) m_subFolders[i]->searchForFileAndFolderNames(); + if ( m_subFolders[i] ) m_subFolders[i]->searchForFileAndFolderNames( levelsLeft ); } return; } @@ -121,10 +142,11 @@ void RimPlotTemplateFolderItem::searchForFileAndFolderNames() return; } - // Build a list of all scripts in the specified directory + // Build a list of all templates in the specified directory { QStringList nameFilters; nameFilters << "*.rpt"; + nameFilters << "*.erpt"; QStringList fileList = caf::Utils::getFilesInDirectory( m_folderName().path(), nameFilters, true ); for ( int i = 0; i < fileList.size(); i++ ) @@ -140,7 +162,7 @@ void RimPlotTemplateFolderItem::searchForFileAndFolderNames() } } - if ( searchSubFoldersRecursively() ) + if ( levelsLeft > 0 ) { QStringList folderPaths; @@ -152,23 +174,7 @@ void RimPlotTemplateFolderItem::searchForFileAndFolderNames() folderPaths.push_back( fi.absoluteFilePath() ); } - createSubFolderItemsFromFolderPaths( folderPaths ); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimPlotTemplateFolderItem::fieldChangedByUi( const caf::PdmFieldHandle* changedField, - const QVariant& oldValue, - const QVariant& newValue ) -{ - if ( &m_folderName == changedField ) - { - QFileInfo fi( m_folderName().path() ); - this->setUiName( fi.baseName() ); - - this->searchForFileAndFolderNames(); + createSubFolderItemsFromFolderPaths( folderPaths, levelsLeft ); } } @@ -189,6 +195,19 @@ void RimPlotTemplateFolderItem::defineEditorAttribute( const caf::PdmFieldHandle } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotTemplateFolderItem::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +{ + if ( !m_folderName().path().isEmpty() ) + { + uiOrdering.add( &m_folderName ); + } + + uiOrdering.skipRemainingFields( true ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -209,11 +228,15 @@ void RimPlotTemplateFolderItem::appendOptionItemsForPlotTemplatesRecursively( QL } caf::IconProvider templateIcon( ":/SummaryTemplate16x16.png" ); + caf::IconProvider ensTemplateIcon( ":/SummaryEnsembleTemplate16x16.png" ); auto files = templateFolderItem->fileNames(); for ( auto file : files ) { - caf::PdmOptionItemInfo optionInfo( file->uiName(), file, false, templateIcon ); + caf::IconProvider icon = templateIcon; + if ( file->isEnsembleTemplate() ) icon = ensTemplateIcon; + + caf::PdmOptionItemInfo optionInfo( file->uiName(), file, false, icon ); optionInfo.setLevel( menuLevel ); @@ -224,22 +247,14 @@ void RimPlotTemplateFolderItem::appendOptionItemsForPlotTemplatesRecursively( QL //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimPlotTemplateFolderItem::createSubFolderItemsFromFolderPaths( const QStringList& folderPaths ) +void RimPlotTemplateFolderItem::createSubFolderItemsFromFolderPaths( const QStringList& folderPaths, int levelsLeft ) { for ( const auto& path : folderPaths ) { - RimPlotTemplateFolderItem* scriptLocation = new RimPlotTemplateFolderItem(); - scriptLocation->setFolderPath( path ); - scriptLocation->searchForFileAndFolderNames(); + RimPlotTemplateFolderItem* templateLocation = new RimPlotTemplateFolderItem(); + templateLocation->setFolderPath( path ); + templateLocation->searchForFileAndFolderNames( levelsLeft ); - m_subFolders.push_back( scriptLocation ); + m_subFolders.push_back( templateLocation ); } } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RimPlotTemplateFolderItem::searchSubFoldersRecursively() const -{ - return RiaPreferences::current()->searchPlotTemplateFoldersRecursively(); -} diff --git a/ApplicationLibCode/ProjectDataModel/PlotTemplates/RimPlotTemplateFolderItem.h b/ApplicationLibCode/ProjectDataModel/PlotTemplates/RimPlotTemplateFolderItem.h index 069685bf92..35a61283ef 100644 --- a/ApplicationLibCode/ProjectDataModel/PlotTemplates/RimPlotTemplateFolderItem.h +++ b/ApplicationLibCode/ProjectDataModel/PlotTemplates/RimPlotTemplateFolderItem.h @@ -48,18 +48,17 @@ class RimPlotTemplateFolderItem : public caf::PdmObject static void appendOptionItemsForPlotTemplates( QList& options, RimPlotTemplateFolderItem* templateFolderItem ); + void updateIconState() const; private: - void searchForFileAndFolderNames(); + void searchForFileAndFolderNames( int levelsLeft ); void setFolderPath( const QString& path ); - void createSubFolderItemsFromFolderPaths( const QStringList& folderPaths ); + void createSubFolderItemsFromFolderPaths( const QStringList& folderPaths, int levelsLeft ); - bool searchSubFoldersRecursively() const; - - void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; static void appendOptionItemsForPlotTemplatesRecursively( QList& options, RimPlotTemplateFolderItem* templateFolderItem, diff --git a/ApplicationLibCode/ProjectDataModel/ProcessControl/RimProcess.cpp b/ApplicationLibCode/ProjectDataModel/ProcessControl/RimProcess.cpp index d5f6e93dd6..815ead8a87 100644 --- a/ApplicationLibCode/ProjectDataModel/ProcessControl/RimProcess.cpp +++ b/ApplicationLibCode/ProjectDataModel/ProcessControl/RimProcess.cpp @@ -25,6 +25,11 @@ #include +// Disable deprecation warning for QProcess::start() +#ifdef _MSC_VER +#pragma warning( disable : 4996 ) +#endif + CAF_PDM_SOURCE_INIT( RimProcess, "RimProcess" ); int RimProcess::m_nextProcessId = 1; @@ -37,15 +42,15 @@ RimProcess::RimProcess() int defId = m_nextProcessId++; m_monitor = new RimProcessMonitor( defId ); - CAF_PDM_InitObject( "ResInsight Process", ":/Erase.png", "", "" ); + CAF_PDM_InitObject( "ResInsight Process", ":/Erase.png" ); - CAF_PDM_InitFieldNoDefault( &m_command, "Command", "Command", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_command, "Command", "Command" ); m_command.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitFieldNoDefault( &m_description, "Description", "Description", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_description, "Description", "Description" ); m_description.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitField( &m_id, "ID", defId, "ID", "", "", "" ); + CAF_PDM_InitField( &m_id, "ID", defId, "ID" ); m_id.uiCapability()->setUiReadOnly( true ); } diff --git a/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.cpp index e47e03910f..cd904fcbc3 100644 --- a/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -63,27 +63,27 @@ const cvf::Mat4d Rim2dIntersectionView::sm_defaultViewMatrix = //-------------------------------------------------------------------------------------------------- Rim2dIntersectionView::Rim2dIntersectionView( void ) { - CAF_PDM_InitObject( "Intersection View", ":/CrossSection16x16.png", "", "" ); + CAF_PDM_InitObject( "Intersection View", ":/CrossSection16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_intersection, "Intersection", "Intersection", ":/CrossSection16x16.png", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_intersection, "Intersection", "Intersection", ":/CrossSection16x16.png" ); m_intersection.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_legendConfig, "LegendDefinition", "Color Legend", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_legendConfig, "LegendDefinition", "Color Legend" ); m_legendConfig.uiCapability()->setUiTreeHidden( true ); m_legendConfig.uiCapability()->setUiTreeChildrenHidden( true ); m_legendConfig.xmlCapability()->disableIO(); m_legendConfig = new RimRegularLegendConfig(); - CAF_PDM_InitFieldNoDefault( &m_ternaryLegendConfig, "TernaryLegendDefinition", "Ternary Color Legend", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_ternaryLegendConfig, "TernaryLegendDefinition", "Ternary Color Legend" ); m_ternaryLegendConfig.uiCapability()->setUiTreeHidden( true ); m_ternaryLegendConfig.uiCapability()->setUiTreeChildrenHidden( true ); m_ternaryLegendConfig.xmlCapability()->disableIO(); m_ternaryLegendConfig = new RimTernaryLegendConfig(); - CAF_PDM_InitField( &m_showDefiningPoints, "ShowDefiningPoints", true, "Show Points", "", "", "" ); - CAF_PDM_InitField( &m_showAxisLines, "ShowAxisLines", false, "Show Axis Lines", "", "", "" ); + CAF_PDM_InitField( &m_showDefiningPoints, "ShowDefiningPoints", true, "Show Points" ); + CAF_PDM_InitField( &m_showAxisLines, "ShowAxisLines", false, "Show Axis Lines" ); - CAF_PDM_InitFieldNoDefault( &m_nameProxy, "NameProxy", "Name", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_nameProxy, "NameProxy", "Name" ); m_nameProxy.xmlCapability()->disableIO(); m_nameProxy.registerGetMethod( this, &Rim2dIntersectionView::getName ); m_nameProxy.registerSetMethod( this, &Rim2dIntersectionView::setName ); @@ -419,7 +419,7 @@ bool Rim2dIntersectionView::handleOverlayItemPicked( const cvf::OverlayItem* pic { if ( m_legendObjectToSelect ) { - RiuMainWindow::instance()->selectAsCurrentItem( m_legendObjectToSelect ); + if ( RiuMainWindow::instance() ) RiuMainWindow::instance()->selectAsCurrentItem( m_legendObjectToSelect ); return true; } @@ -430,8 +430,7 @@ bool Rim2dIntersectionView::handleOverlayItemPicked( const cvf::OverlayItem* pic //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList - Rim2dIntersectionView::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) +QList Rim2dIntersectionView::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; diff --git a/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.h b/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.h index 839111a482..8270fdd021 100644 --- a/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.h +++ b/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.h @@ -94,8 +94,7 @@ class Rim2dIntersectionView : public Rim3dView void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; bool hasResults(); diff --git a/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionViewCollection.cpp b/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionViewCollection.cpp index 7550347646..6680d03536 100644 --- a/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionViewCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionViewCollection.cpp @@ -29,14 +29,9 @@ CAF_PDM_SOURCE_INIT( Rim2dIntersectionViewCollection, "Intersection2dViewCollect //-------------------------------------------------------------------------------------------------- Rim2dIntersectionViewCollection::Rim2dIntersectionViewCollection() { - CAF_PDM_InitObject( "2D Intersection Views", ":/CrossSection16x16.png", "", "" ); - - CAF_PDM_InitFieldNoDefault( &m_intersectionViews, - "IntersectionViews", - "Intersection Views", - ":/CrossSection16x16.png", - "", - "" ); + CAF_PDM_InitObject( "2D Intersection Views", ":/CrossSection16x16.png" ); + + CAF_PDM_InitFieldNoDefault( &m_intersectionViews, "IntersectionViews", "Intersection Views", ":/CrossSection16x16.png" ); m_intersectionViews.uiCapability()->setUiTreeHidden( true ); } @@ -52,7 +47,7 @@ Rim2dIntersectionViewCollection::~Rim2dIntersectionViewCollection() //-------------------------------------------------------------------------------------------------- std::vector Rim2dIntersectionViewCollection::views() { - return m_intersectionViews.childObjects(); + return m_intersectionViews.children(); } //-------------------------------------------------------------------------------------------------- @@ -78,7 +73,7 @@ void Rim2dIntersectionViewCollection::syncFromExistingIntersections( bool doUpda // Clean up the container by removing nullptr's - m_intersectionViews.removeChildObject( nullptr ); + m_intersectionViews.removeChild( nullptr ); // Build map from intersection to view @@ -89,7 +84,7 @@ void Rim2dIntersectionViewCollection::syncFromExistingIntersections( bool doUpda intersectionToViewMap[iv->intersection()] = iv; } - m_intersectionViews.clear(); // Not deleting the views. The are managed by the map + m_intersectionViews.clearWithoutDelete(); // Not deleting the views. The are managed by the map // Insert the old views in correct order, and create new views as we go diff --git a/ApplicationLibCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp b/ApplicationLibCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp index c77c69eade..fb825d6450 100644 --- a/ApplicationLibCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp +++ b/ApplicationLibCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp @@ -29,14 +29,10 @@ #include "RigActiveCellInfo.h" #include "RigCaseCellResultsData.h" #include "RigEclipseCaseData.h" -// #include "RigEclipseMultiPropertyStatCalc.h" -// #include "RigEclipseNativeVisibleCellsStatCalc.h" -// #include "RigFemNativeVisibleCellsStatCalc.h" #include "RigFemPartCollection.h" #include "RigFemPartResultsCollection.h" #include "RigFemResultAddress.h" #include "RigFlowDiagResults.h" -// #include "RigFlowDiagVisibleCellsStatCalc.h" #include "RigGeoMechCaseData.h" #include "RigMainGrid.h" @@ -64,6 +60,8 @@ #include "RiuViewer.h" +#include "caf.h" + #include CAF_PDM_SOURCE_INIT( Rim3dOverlayInfoConfig, "View3dOverlayInfoConfig" ); @@ -76,26 +74,26 @@ CAF_PDM_SOURCE_INIT( Rim3dOverlayInfoConfig, "View3dOverlayInfoConfig" ); //-------------------------------------------------------------------------------------------------- Rim3dOverlayInfoConfig::Rim3dOverlayInfoConfig() { - CAF_PDM_InitObject( "Info Box", ":/InfoBox16x16.png", "", "" ); + CAF_PDM_InitObject( "Info Box", ":/InfoBox16x16.png" ); - CAF_PDM_InitField( &m_active, "Active", true, "Active", "", "", "" ); + CAF_PDM_InitField( &m_active, "Active", true, "Active" ); m_active.uiCapability()->setUiHidden( true ); m_active = RiaPreferences::current()->showInfoBox(); - CAF_PDM_InitField( &m_showAnimProgress, "ShowAnimProgress", true, "Animation progress", "", "", "" ); - CAF_PDM_InitField( &m_showCaseInfo, "ShowInfoText", true, "Case Info", "", "", "" ); - CAF_PDM_InitField( &m_showResultInfo, "ShowResultInfo", true, "Result Info", "", "", "" ); - CAF_PDM_InitField( &m_showHistogram, "ShowHistogram", true, "Histogram", "", "", "" ); - CAF_PDM_InitField( &m_showVolumeWeightedMean, "ShowVolumeWeightedMean", true, "Mobile Volume Weighted Mean", "", "", "" ); - CAF_PDM_InitField( &m_showVersionInfo, "ShowVersionInfo", true, "Version Info", "", "", "" ); + CAF_PDM_InitField( &m_showAnimProgress, "ShowAnimProgress", true, "Animation progress" ); + CAF_PDM_InitField( &m_showCaseInfo, "ShowInfoText", true, "Case Info" ); + CAF_PDM_InitField( &m_showResultInfo, "ShowResultInfo", true, "Result Info" ); + CAF_PDM_InitField( &m_showHistogram, "ShowHistogram", true, "Histogram" ); + CAF_PDM_InitField( &m_showVolumeWeightedMean, "ShowVolumeWeightedMean", true, "Mobile Volume Weighted Mean" ); + CAF_PDM_InitField( &m_showVersionInfo, "ShowVersionInfo", true, "Version Info" ); caf::AppEnum defaultTimeRange = RimHistogramCalculator::StatisticsTimeRangeType::CURRENT_TIMESTEP; - CAF_PDM_InitField( &m_statisticsTimeRange, "StatisticsTimeRange", defaultTimeRange, "Statistics Time Range", "", "", "" ); + CAF_PDM_InitField( &m_statisticsTimeRange, "StatisticsTimeRange", defaultTimeRange, "Statistics Time Range" ); caf::AppEnum defaultCellRange = RimHistogramCalculator::StatisticsCellRangeType::VISIBLE_CELLS; - CAF_PDM_InitField( &m_statisticsCellRange, "StatisticsCellRange", defaultCellRange, "Statistics Cell Range", "", "", "" ); + CAF_PDM_InitField( &m_statisticsCellRange, "StatisticsCellRange", defaultCellRange, "Statistics Cell Range" ); m_histogramCalculator.reset( new RimHistogramCalculator ); } @@ -289,7 +287,7 @@ QString Rim3dOverlayInfoConfig::caseInfoText( RimEclipseView* eclipseView ) { QString caseName = eclipseView->eclipseCase()->caseUserDescription(); - QLocale localeWithSpaceAsGroupSeparator( QLocale::Norwegian ); + QLocale localeWithSpaceAsGroupSeparator( caf::norwegianLocale() ); RimEclipseContourMapView* contourMap = dynamic_cast( eclipseView ); if ( contourMap && contourMap->contourMapProjection() ) diff --git a/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp b/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp index bdf88964c9..f27b3361fd 100644 --- a/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp +++ b/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp @@ -94,25 +94,25 @@ Rim3dView::Rim3dView() RiaPreferences* preferences = RiaPreferences::current(); CVF_ASSERT( preferences ); - CAF_PDM_InitObject( "3d View", "", "", "" ); + CAF_PDM_InitObject( "3d View" ); - CAF_PDM_InitScriptableField( &m_id, "Id", -1, "View ID", "", "", "" ); + CAF_PDM_InitScriptableField( &m_id, "Id", -1, "View ID" ); m_id.registerKeywordAlias( "ViewId" ); m_id.uiCapability()->setUiReadOnly( true ); m_id.uiCapability()->setUiHidden( true ); m_id.capability()->setIOWriteable( false ); m_id.xmlCapability()->setCopyable( false ); - CAF_PDM_InitFieldNoDefault( &m_nameConfig, "NameConfig", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_nameConfig, "NameConfig", "" ); m_nameConfig = new RimViewNameConfig(); - CAF_PDM_InitField( &m_cameraPosition, "CameraPosition", cvf::Mat4d::IDENTITY, "", "", "", "" ); + CAF_PDM_InitField( &m_cameraPosition, "CameraPosition", cvf::Mat4d::IDENTITY, "" ); m_cameraPosition.uiCapability()->setUiHidden( true ); - CAF_PDM_InitField( &m_cameraPointOfInterest, "CameraPointOfInterest", cvf::Vec3d::ZERO, "", "", "", "" ); + CAF_PDM_InitField( &m_cameraPointOfInterest, "CameraPointOfInterest", cvf::Vec3d::ZERO, "" ); m_cameraPointOfInterest.uiCapability()->setUiHidden( true ); - CAF_PDM_InitScriptableField( &isPerspectiveView, "PerspectiveProjection", true, "Perspective Projection", "", "", "" ); + CAF_PDM_InitScriptableField( &isPerspectiveView, "PerspectiveProjection", true, "Perspective Projection" ); double defaultScaleFactor = preferences->defaultScaleFactorZ(); CAF_PDM_InitScriptableField( &scaleZ, @@ -124,26 +124,20 @@ Rim3dView::Rim3dView() "" ); cvf::Color3f defBackgColor = preferences->defaultViewerBackgroundColor(); - CAF_PDM_InitScriptableField( &m_backgroundColor, "BackgroundColor", defBackgColor, "Background", "", "", "" ); + CAF_PDM_InitScriptableField( &m_backgroundColor, "BackgroundColor", defBackgColor, "Background" ); m_backgroundColor.registerKeywordAlias( "ViewBackgroundColor" ); - CAF_PDM_InitField( &maximumFrameRate, "MaximumFrameRate", 10, "Maximum Frame Rate", "", "", "" ); + CAF_PDM_InitField( &maximumFrameRate, "MaximumFrameRate", 10, "Maximum Frame Rate" ); maximumFrameRate.uiCapability()->setUiHidden( true ); - CAF_PDM_InitScriptableField( &m_currentTimeStep, "CurrentTimeStep", 0, "Current Time Step", "", "", "" ); + CAF_PDM_InitScriptableField( &m_currentTimeStep, "CurrentTimeStep", 0, "Current Time Step" ); m_currentTimeStep.uiCapability()->setUiHidden( true ); caf::AppEnum defaultMeshType = preferences->defaultMeshModeType(); - CAF_PDM_InitField( &meshMode, "MeshMode", defaultMeshType, "Grid Lines", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &surfaceMode, "SurfaceMode", "Grid Surface", "", "", "" ); + CAF_PDM_InitField( &meshMode, "MeshMode", defaultMeshType, "Grid Lines" ); + CAF_PDM_InitFieldNoDefault( &surfaceMode, "SurfaceMode", "Grid Surface" ); - CAF_PDM_InitScriptableField( &m_showGridBox, - "ShowGridBox", - RiaPreferences::current()->showGridBox(), - "Show Grid Box", - "", - "", - "" ); + CAF_PDM_InitScriptableField( &m_showGridBox, "ShowGridBox", RiaPreferences::current()->showGridBox(), "Show Grid Box" ); CAF_PDM_InitScriptableField( &m_disableLighting, "DisableLighting", @@ -153,11 +147,11 @@ Rim3dView::Rim3dView() "Disable light model for scalar result colors", "" ); - CAF_PDM_InitScriptableField( &m_showZScaleLabel, "ShowZScale", true, "Show Z Scale Label", "", "", "" ); + CAF_PDM_InitScriptableField( &m_showZScaleLabel, "ShowZScale", true, "Show Z Scale Label" ); - CAF_PDM_InitFieldNoDefault( &m_comparisonView, "ComparisonView", "Comparison View", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_comparisonView, "ComparisonView", "Comparison View" ); - CAF_PDM_InitFieldNoDefault( &m_fontSize, "FontSize", "Font Size", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_fontSize, "FontSize", "Font Size" ); m_intersectionVizModel = new cvf::ModelBasicList; m_intersectionVizModel->setName( "CrossSectionModel" ); @@ -1392,8 +1386,7 @@ cvf::ref Rim3dView::displayCoordTransform() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList Rim3dView::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList Rim3dView::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; @@ -1500,7 +1493,7 @@ void Rim3dView::disableGridBoxField() { m_showGridBox = false; - RiaFieldhandleTools::disableWriteAndSetFieldHidden( &m_showGridBox ); + RiaFieldHandleTools::disableWriteAndSetFieldHidden( &m_showGridBox ); } //-------------------------------------------------------------------------------------------------- @@ -1510,7 +1503,7 @@ void Rim3dView::disablePerspectiveProjectionField() { isPerspectiveView = false; - RiaFieldhandleTools::disableWriteAndSetFieldHidden( &isPerspectiveView ); + RiaFieldHandleTools::disableWriteAndSetFieldHidden( &isPerspectiveView ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Rim3dView.h b/ApplicationLibCode/ProjectDataModel/Rim3dView.h index c0e3b3fee3..99c59c7d19 100644 --- a/ApplicationLibCode/ProjectDataModel/Rim3dView.h +++ b/ApplicationLibCode/ProjectDataModel/Rim3dView.h @@ -236,8 +236,7 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface, public void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void setupBeforeSave() override; diff --git a/ApplicationLibCode/ProjectDataModel/RimAbstractPlotCollection.h b/ApplicationLibCode/ProjectDataModel/RimAbstractPlotCollection.h index 4e5cca6fa7..1f7d15e226 100644 --- a/ApplicationLibCode/ProjectDataModel/RimAbstractPlotCollection.h +++ b/ApplicationLibCode/ProjectDataModel/RimAbstractPlotCollection.h @@ -68,7 +68,7 @@ class RimTypedPlotCollection : public RimAbstractPlotCollection } } - void addPlot( RimPlotType* plot ) { insertPlot( plot, plotCount() ); } + virtual void addPlot( RimPlotType* plot ) { insertPlot( plot, plotCount() ); } virtual void insertPlot( RimPlotType* plot, size_t index ) = 0; virtual void removePlot( RimPlotType* plot ) = 0; void removeRimPlot( RimPlot* rimPlot ) override diff --git a/ApplicationLibCode/ProjectDataModel/RimAdvancedSnapshotExportDefinition.cpp b/ApplicationLibCode/ProjectDataModel/RimAdvancedSnapshotExportDefinition.cpp index 17d7dc7729..661aedb642 100644 --- a/ApplicationLibCode/ProjectDataModel/RimAdvancedSnapshotExportDefinition.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimAdvancedSnapshotExportDefinition.cpp @@ -40,31 +40,28 @@ CAF_PDM_SOURCE_INIT( RimAdvancedSnapshotExportDefinition, "MultiSnapshotDefiniti //-------------------------------------------------------------------------------------------------- RimAdvancedSnapshotExportDefinition::RimAdvancedSnapshotExportDefinition() { - // CAF_PDM_InitObject("MultiSnapshotDefinition", ":/Well.svg", "", ""); - CAF_PDM_InitObject( "MultiSnapshotDefinition", "", "", "" ); + // CAF_PDM_InitObject("MultiSnapshotDefinition", ":/Well.svg"); + CAF_PDM_InitObject( "MultiSnapshotDefinition" ); - CAF_PDM_InitField( &isActive, "IsActive", true, "Active", "", "", "" ); + CAF_PDM_InitField( &isActive, "IsActive", true, "Active" ); - CAF_PDM_InitFieldNoDefault( &view, "View", "View", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &view, "View", "View" ); - CAF_PDM_InitFieldNoDefault( &eclipseResultType, "EclipseResultType", "Result Type", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &selectedEclipseResults, "SelectedEclipseResults", "Properties", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &eclipseResultType, "EclipseResultType", "Result Type" ); + CAF_PDM_InitFieldNoDefault( &selectedEclipseResults, "SelectedEclipseResults", "Properties" ); - CAF_PDM_InitField( &timeStepStart, "TimeStepStart", 0, "Start Time", "", "", "" ); - CAF_PDM_InitField( &timeStepEnd, "TimeStepEnd", 0, "End Time", "", "", "" ); + CAF_PDM_InitField( &timeStepStart, "TimeStepStart", 0, "Start Time" ); + CAF_PDM_InitField( &timeStepEnd, "TimeStepEnd", 0, "End Time" ); CAF_PDM_InitField( &sliceDirection, "SnapShotDirection", caf::AppEnum( RiaDefines::GridCaseAxis::UNDEFINED_AXIS ), - "Range Filter Slice", - "", - "", - "" ); + "Range Filter Slice" ); - CAF_PDM_InitField( &startSliceIndex, "RangeFilterStart", 1, "Range Start", "", "", "" ); - CAF_PDM_InitField( &endSliceIndex, "RangeFilterEnd", 1, "Range End", "", "", "" ); + CAF_PDM_InitField( &startSliceIndex, "RangeFilterStart", 1, "Range Start" ); + CAF_PDM_InitField( &endSliceIndex, "RangeFilterEnd", 1, "Range End" ); - CAF_PDM_InitFieldNoDefault( &additionalCases, "AdditionalCases", "Cases", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &additionalCases, "AdditionalCases", "Cases" ); } //-------------------------------------------------------------------------------------------------- @@ -78,8 +75,7 @@ RimAdvancedSnapshotExportDefinition::~RimAdvancedSnapshotExportDefinition() /// //-------------------------------------------------------------------------------------------------- QList - RimAdvancedSnapshotExportDefinition::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) + RimAdvancedSnapshotExportDefinition::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; @@ -139,8 +135,6 @@ QList RimTools::caseOptionItems( &options ); } - if ( useOptionsOnly ) *useOptionsOnly = true; - return options; } diff --git a/ApplicationLibCode/ProjectDataModel/RimAdvancedSnapshotExportDefinition.h b/ApplicationLibCode/ProjectDataModel/RimAdvancedSnapshotExportDefinition.h index 189f6b3c4c..666b61cff5 100644 --- a/ApplicationLibCode/ProjectDataModel/RimAdvancedSnapshotExportDefinition.h +++ b/ApplicationLibCode/ProjectDataModel/RimAdvancedSnapshotExportDefinition.h @@ -61,8 +61,7 @@ class RimAdvancedSnapshotExportDefinition : public caf::PdmObject void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; private: - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void getTimeStepStrings( QList& options ); diff --git a/ApplicationLibCode/ProjectDataModel/RimBinaryExportSettings.cpp b/ApplicationLibCode/ProjectDataModel/RimBinaryExportSettings.cpp index 6c84bf4f5f..cdcde94ed8 100644 --- a/ApplicationLibCode/ProjectDataModel/RimBinaryExportSettings.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimBinaryExportSettings.cpp @@ -26,12 +26,12 @@ CAF_PDM_SOURCE_INIT( RimBinaryExportSettings, "RimBinaryExportSettings" ); //-------------------------------------------------------------------------------------------------- RimBinaryExportSettings::RimBinaryExportSettings() { - CAF_PDM_InitObject( "RimBinaryExportSettings", "", "", "" ); + CAF_PDM_InitObject( "RimBinaryExportSettings" ); - CAF_PDM_InitFieldNoDefault( &fileName, "Filename", "Export Filename", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &fileName, "Filename", "Export Filename" ); fileName.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &eclipseKeyword, "EclipseKeyword", "Eclipse Keyword", "", "", "" ); - CAF_PDM_InitField( &undefinedValue, "UndefinedValue", 0.0, "Undefined Value", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &eclipseKeyword, "EclipseKeyword", "Eclipse Keyword" ); + CAF_PDM_InitField( &undefinedValue, "UndefinedValue", 0.0, "Undefined Value" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimCalcScript.cpp b/ApplicationLibCode/ProjectDataModel/RimCalcScript.cpp index d87393d9ae..712f824b70 100644 --- a/ApplicationLibCode/ProjectDataModel/RimCalcScript.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimCalcScript.cpp @@ -36,8 +36,8 @@ RimCalcScript::RimCalcScript() { CAF_PDM_InitObject( "CalcScript", ":/OctaveScriptFile16x16.png", "Calc Script", "" ); - CAF_PDM_InitField( &absoluteFileName, "AbsolutePath", QString(), "Location", "", "", "" ); - + CAF_PDM_InitField( &absoluteFileName, "AbsolutePath", QString(), "Location" ); + absoluteFileName.uiCapability()->setUiReadOnly( true ); absoluteFileName.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); } diff --git a/ApplicationLibCode/ProjectDataModel/RimCase.cpp b/ApplicationLibCode/ProjectDataModel/RimCase.cpp index 138d6b0e21..47662a94f7 100644 --- a/ApplicationLibCode/ProjectDataModel/RimCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimCase.cpp @@ -49,24 +49,24 @@ RimCase::RimCase() { CAF_PDM_InitScriptableObjectWithNameAndComment( "Case", ":/Case48x48.png", "", "", "Case", "The ResInsight base class for Cases" ); - CAF_PDM_InitScriptableField( &caseUserDescription, "Name", QString(), "Case Name", "", "", "" ); + CAF_PDM_InitScriptableField( &caseUserDescription, "Name", QString(), "Case Name" ); caseUserDescription.registerKeywordAlias( "CaseUserDescription" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_displayNameOption, "NameSetting", "Name Setting", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_displayNameOption, "NameSetting", "Name Setting" ); - CAF_PDM_InitScriptableField( &caseId, "Id", -1, "Case ID", "", "", "" ); + CAF_PDM_InitScriptableField( &caseId, "Id", -1, "Case ID" ); caseId.registerKeywordAlias( "CaseId" ); caseId.uiCapability()->setUiReadOnly( true ); caseId.capability()->setIOWriteable( false ); - CAF_PDM_InitScriptableFieldNoDefault( &m_caseFileName, "FilePath", "Case File Name", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_caseFileName, "FilePath", "Case File Name" ); m_caseFileName.registerKeywordAlias( "CaseFileName" ); m_caseFileName.registerKeywordAlias( "GridFileName" ); m_caseFileName.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitFieldNoDefault( &m_activeFormationNames, "DefaultFormationNames", "Formation Names File", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_activeFormationNames, "DefaultFormationNames", "Formation Names File" ); - CAF_PDM_InitFieldNoDefault( &m_timeStepFilter, "TimeStepFilter", "Time Step Filter", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_timeStepFilter, "TimeStepFilter", "Time Step Filter" ); m_timeStepFilter.uiCapability()->setUiTreeHidden( true ); m_timeStepFilter.uiCapability()->setUiTreeChildrenHidden( true ); m_timeStepFilter = new RimTimeStepFilter; @@ -74,9 +74,7 @@ RimCase::RimCase() CAF_PDM_InitFieldNoDefault( &m_2dIntersectionViewCollection, "IntersectionViewCollection", "2D Intersection Views", - ":/CrossSections16x16.png", - "", - "" ); + ":/CrossSections16x16.png" ); m_2dIntersectionViewCollection.uiCapability()->setUiTreeHidden( true ); m_2dIntersectionViewCollection = new Rim2dIntersectionViewCollection(); } @@ -208,8 +206,7 @@ void RimCase::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const Q //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimCase::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RimCase::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; diff --git a/ApplicationLibCode/ProjectDataModel/RimCase.h b/ApplicationLibCode/ProjectDataModel/RimCase.h index b0ee0d9074..7cc4675de7 100644 --- a/ApplicationLibCode/ProjectDataModel/RimCase.h +++ b/ApplicationLibCode/ProjectDataModel/RimCase.h @@ -67,8 +67,6 @@ class RimCase : public caf::PdmObject std::vector views() const; std::vector gridViews() const; - virtual void updateFilePathsFromProjectPath( const QString& projectPath, const QString& oldProjectPath ) = 0; - virtual std::vector timeStepDates() const = 0; virtual QStringList timeStepStrings() const = 0; virtual QString timeStepName( int frameIdx ) const = 0; @@ -92,8 +90,7 @@ class RimCase : public caf::PdmObject caf::Signal<> settingsChanged; protected: - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; virtual std::vector allSpecialViews() const = 0; diff --git a/ApplicationLibCode/ProjectDataModel/RimCaseCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimCaseCollection.cpp index 954e08c5a5..fc53bd0bcc 100644 --- a/ApplicationLibCode/ProjectDataModel/RimCaseCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimCaseCollection.cpp @@ -30,9 +30,9 @@ CAF_PDM_SOURCE_INIT( RimCaseCollection, "RimCaseCollection" ); //-------------------------------------------------------------------------------------------------- RimCaseCollection::RimCaseCollection() { - CAF_PDM_InitObject( "Derived Statistics", "", "", "" ); + CAF_PDM_InitObject( "Derived Statistics" ); - CAF_PDM_InitFieldNoDefault( &reservoirs, "Reservoirs", "Reservoirs ChildArrayField", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &reservoirs, "Reservoirs", "Reservoirs ChildArrayField" ); reservoirs.uiCapability()->setUiTreeHidden( true ); } @@ -41,7 +41,7 @@ RimCaseCollection::RimCaseCollection() //-------------------------------------------------------------------------------------------------- RimCaseCollection::~RimCaseCollection() { - reservoirs.deleteAllChildObjects(); + reservoirs.deleteChildren(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimCellEdgeColors.cpp b/ApplicationLibCode/ProjectDataModel/RimCellEdgeColors.cpp index 3abba416ec..1aceb4f3d4 100644 --- a/ApplicationLibCode/ProjectDataModel/RimCellEdgeColors.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimCellEdgeColors.cpp @@ -52,25 +52,20 @@ CAF_PDM_SOURCE_INIT( RimCellEdgeColors, "CellEdgeResultSlot" ); //-------------------------------------------------------------------------------------------------- RimCellEdgeColors::RimCellEdgeColors() { - CAF_PDM_InitObject( "Cell Edge Result", ":/EdgeResult_1.png", "", "" ); + CAF_PDM_InitObject( "Cell Edge Result", ":/EdgeResult_1.png" ); - CAF_PDM_InitField( &m_enableCellEdgeColors, "EnableCellEdgeColors", true, "Enable Cell Edge Results", "", "", "" ); + CAF_PDM_InitField( &m_enableCellEdgeColors, "EnableCellEdgeColors", true, "Enable Cell Edge Results" ); - CAF_PDM_InitFieldNoDefault( &m_propertyType, "propertyType", "Property Type", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_propertyType, "propertyType", "Property Type" ); - CAF_PDM_InitFieldNoDefault( &m_resultVariable, "CellEdgeVariable", "Result property", "", "", "" ); - CAF_PDM_InitField( &useXVariable, "UseXVariable", true, "Use X Values", "", "", "" ); - CAF_PDM_InitField( &useYVariable, "UseYVariable", true, "Use Y Values", "", "", "" ); - CAF_PDM_InitField( &useZVariable, "UseZVariable", true, "Use Z Values", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_resultVariable, "CellEdgeVariable", "Result property" ); + CAF_PDM_InitField( &useXVariable, "UseXVariable", true, "Use X Values" ); + CAF_PDM_InitField( &useYVariable, "UseYVariable", true, "Use Y Values" ); + CAF_PDM_InitField( &useZVariable, "UseZVariable", true, "Use Z Values" ); - CAF_PDM_InitFieldNoDefault( &m_legendConfig, "LegendDefinition", "Color Legend", ":/Legend.png", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_legendConfig, "LegendDefinition", "Color Legend", ":/Legend.png" ); - CAF_PDM_InitFieldNoDefault( &m_singleVarEdgeResultColors, - "SingleVarEdgeResult", - "Result Property", - ":/CellResult.png", - "", - "" ); + CAF_PDM_InitFieldNoDefault( &m_singleVarEdgeResultColors, "SingleVarEdgeResult", "Result Property", ":/CellResult.png" ); m_singleVarEdgeResultColors = new RimEclipseCellColors(); m_resultVariable.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() ); @@ -195,8 +190,7 @@ void RimCellEdgeColors::EdgeFaceEnum::setUp() /// //-------------------------------------------------------------------------------------------------- -QList RimCellEdgeColors::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RimCellEdgeColors::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { if ( fieldNeedingOptions == &m_resultVariable ) { @@ -260,8 +254,6 @@ QList RimCellEdgeColors::calculateValueOptions( const ca options.push_front( caf::PdmOptionItemInfo( RiaResultNames::undefinedResultName(), "" ) ); - if ( useOptionsOnly ) *useOptionsOnly = true; - return options; } } diff --git a/ApplicationLibCode/ProjectDataModel/RimCellEdgeColors.h b/ApplicationLibCode/ProjectDataModel/RimCellEdgeColors.h index 75ec0f0c6b..e58adccb6d 100644 --- a/ApplicationLibCode/ProjectDataModel/RimCellEdgeColors.h +++ b/ApplicationLibCode/ProjectDataModel/RimCellEdgeColors.h @@ -104,8 +104,7 @@ class RimCellEdgeColors : public caf::PdmObject protected: void initAfterRead() override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; diff --git a/ApplicationLibCode/ProjectDataModel/RimCheckableNamedObject.cpp b/ApplicationLibCode/ProjectDataModel/RimCheckableNamedObject.cpp index f1afe25100..367ae92fb7 100644 --- a/ApplicationLibCode/ProjectDataModel/RimCheckableNamedObject.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimCheckableNamedObject.cpp @@ -28,8 +28,8 @@ CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimCheckableNamedObject, "CheckableNamedObject //-------------------------------------------------------------------------------------------------- RimCheckableNamedObject::RimCheckableNamedObject( void ) { - CAF_PDM_InitScriptableObject( "Checkable object", "", "", "" ); - CAF_PDM_InitScriptableField( &m_isChecked, "IsChecked", true, "Active", "", "", "" ); + CAF_PDM_InitScriptableObject( "Checkable object" ); + CAF_PDM_InitScriptableField( &m_isChecked, "IsChecked", true, "Active" ); m_isChecked.uiCapability()->setUiHidden( true ); } diff --git a/ApplicationLibCode/ProjectDataModel/RimCheckableObject.cpp b/ApplicationLibCode/ProjectDataModel/RimCheckableObject.cpp index c3b90cca31..ec2f6a17f7 100644 --- a/ApplicationLibCode/ProjectDataModel/RimCheckableObject.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimCheckableObject.cpp @@ -25,7 +25,7 @@ CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimCheckableObject, "RimCheckableObject" ); // //-------------------------------------------------------------------------------------------------- RimCheckableObject::RimCheckableObject( void ) { - CAF_PDM_InitField( &m_isChecked, "IsChecked", true, "Active", "", "", "" ); + CAF_PDM_InitField( &m_isChecked, "IsChecked", true, "Active" ); m_isChecked.uiCapability()->setUiHidden( true ); } diff --git a/ApplicationLibCode/ProjectDataModel/RimColorLegend.cpp b/ApplicationLibCode/ProjectDataModel/RimColorLegend.cpp index 004ef242b8..da747e72ac 100644 --- a/ApplicationLibCode/ProjectDataModel/RimColorLegend.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimColorLegend.cpp @@ -34,11 +34,11 @@ CAF_PDM_SOURCE_INIT( RimColorLegend, "ColorLegend" ); //-------------------------------------------------------------------------------------------------- RimColorLegend::RimColorLegend() { - CAF_PDM_InitObject( "ColorLegend", ":/Legend.png", "", "" ); + CAF_PDM_InitObject( "ColorLegend", ":/Legend.png" ); - CAF_PDM_InitField( &m_colorLegendName, "ColorLegendName", QString( "" ), "Color Legend Name", "", "", "" ); + CAF_PDM_InitField( &m_colorLegendName, "ColorLegendName", QString( "" ), "Color Legend Name" ); - CAF_PDM_InitFieldNoDefault( &m_colorLegendItems, "ColorLegendItems", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_colorLegendItems, "ColorLegendItems", "" ); m_colorLegendItems.uiCapability()->setUiTreeHidden( true ); setDeletable( true ); @@ -104,7 +104,7 @@ void RimColorLegend::appendColorLegendItem( RimColorLegendItem* colorLegendItem //-------------------------------------------------------------------------------------------------- std::vector RimColorLegend::colorLegendItems() const { - return m_colorLegendItems.childObjects(); + return m_colorLegendItems.children(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimColorLegendCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimColorLegendCollection.cpp index dde9304590..c2bd9e2f76 100644 --- a/ApplicationLibCode/ProjectDataModel/RimColorLegendCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimColorLegendCollection.cpp @@ -34,17 +34,12 @@ CAF_PDM_SOURCE_INIT( RimColorLegendCollection, "ColorLegendCollection" ); //-------------------------------------------------------------------------------------------------- RimColorLegendCollection::RimColorLegendCollection() { - CAF_PDM_InitObject( "Color Legends", ":/Legend.png", "", "" ); - - CAF_PDM_InitFieldNoDefault( &m_standardColorLegends, - "StandardColorLegends", - "Standard Color Legends", - ":/Legend.png", - "", - "" ); + CAF_PDM_InitObject( "Color Legends", ":/Legend.png" ); + + CAF_PDM_InitFieldNoDefault( &m_standardColorLegends, "StandardColorLegends", "Standard Color Legends", ":/Legend.png" ); m_standardColorLegends.xmlCapability()->disableIO(); - CAF_PDM_InitFieldNoDefault( &m_customColorLegends, "CustomColorLegends", "Custom Color Legends", ":/Legend.png", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_customColorLegends, "CustomColorLegends", "Custom Color Legends", ":/Legend.png" ); } //-------------------------------------------------------------------------------------------------- @@ -81,7 +76,7 @@ bool RimColorLegendCollection::isStandardColorLegend( RimColorLegend* legend ) //-------------------------------------------------------------------------------------------------- void RimColorLegendCollection::deleteCustomColorLegends() { - m_customColorLegends.deleteAllChildObjects(); + m_customColorLegends.deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -143,13 +138,13 @@ std::vector RimColorLegendCollection::allColorLegends() const { std::vector allLegends; - auto standardLegends = m_standardColorLegends.childObjects(); + auto standardLegends = m_standardColorLegends.children(); for ( auto l : standardLegends ) { allLegends.push_back( l ); } - auto customLegends = m_customColorLegends.childObjects(); + auto customLegends = m_customColorLegends.children(); for ( auto l : customLegends ) { allLegends.push_back( l ); diff --git a/ApplicationLibCode/ProjectDataModel/RimColorLegendItem.cpp b/ApplicationLibCode/ProjectDataModel/RimColorLegendItem.cpp index f49a4692cc..c736bc89e5 100644 --- a/ApplicationLibCode/ProjectDataModel/RimColorLegendItem.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimColorLegendItem.cpp @@ -33,17 +33,17 @@ CAF_PDM_SOURCE_INIT( RimColorLegendItem, "ColorLegendItem" ); //-------------------------------------------------------------------------------------------------- RimColorLegendItem::RimColorLegendItem() { - CAF_PDM_InitObject( "ColorLegendItem", "", "", "" ); + CAF_PDM_InitObject( "ColorLegendItem" ); - CAF_PDM_InitFieldNoDefault( &m_color, "Color", "Color", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_color, "Color", "Color" ); m_color = cvf::Color3f( cvf::Color3::ColorIdent::BLACK ); - CAF_PDM_InitField( &m_categoryValue, "CategoryValue", 0, "Category Number", "", "", "" ); + CAF_PDM_InitField( &m_categoryValue, "CategoryValue", 0, "Category Number" ); m_categoryValue.uiCapability()->setUiEditorTypeName( caf::PdmUiSliderEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_categoryName, "CategoryName", QString( "" ), "Category Name", "", "", "" ); + CAF_PDM_InitField( &m_categoryName, "CategoryName", QString( "" ), "Category Name" ); - CAF_PDM_InitFieldNoDefault( &m_nameProxy, "NameProxy", "Name Proxy", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_nameProxy, "NameProxy", "Name Proxy" ); m_nameProxy.registerGetMethod( this, &RimColorLegendItem::itemName ); m_nameProxy.uiCapability()->setUiHidden( true ); m_nameProxy.xmlCapability()->disableIO(); diff --git a/ApplicationLibCode/ProjectDataModel/RimCommandObject.cpp b/ApplicationLibCode/ProjectDataModel/RimCommandObject.cpp index c2d6a5ad3e..f732baccb9 100644 --- a/ApplicationLibCode/ProjectDataModel/RimCommandObject.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimCommandObject.cpp @@ -55,14 +55,14 @@ RimCommandObject::~RimCommandObject() //-------------------------------------------------------------------------------------------------- RimCommandExecuteScript::RimCommandExecuteScript() { - CAF_PDM_InitFieldNoDefault( &name, "Name", "Name", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &name, "Name", "Name" ); - CAF_PDM_InitField( &scriptText, "ScriptText", QString(), "Script Text", "", "", "" ); + CAF_PDM_InitField( &scriptText, "ScriptText", QString(), "Script Text" ); scriptText.uiCapability()->setUiEditorTypeName( caf::PdmUiTextEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &isEnabled, "IsEnabled", true, "Enabled ", "", "", "" ); + CAF_PDM_InitField( &isEnabled, "IsEnabled", true, "Enabled " ); - CAF_PDM_InitField( &execute, "Execute", true, "Execute", "", "", "" ); + CAF_PDM_InitField( &execute, "Execute", true, "Execute" ); execute.xmlCapability()->disableIO(); execute.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); execute.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); @@ -193,11 +193,11 @@ void RimCommandFactory::createCommandObjects( const caf::PdmObjectGroup& se //-------------------------------------------------------------------------------------------------- RimCommandIssueFieldChanged::RimCommandIssueFieldChanged() { - CAF_PDM_InitFieldNoDefault( &commandName, "CommandName", "CommandName", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &commandName, "CommandName", "CommandName" ); - CAF_PDM_InitField( &objectName, "ObjectName", QString(), "ObjectName", "", "", "" ); - CAF_PDM_InitField( &fieldName, "FieldName", QString(), "FieldName", "", "", "" ); - CAF_PDM_InitField( &fieldValueToApply, "FieldValueToApply", QString(), "FieldValueToApply", "", "", "" ); + CAF_PDM_InitField( &objectName, "ObjectName", QString(), "ObjectName" ); + CAF_PDM_InitField( &fieldName, "FieldName", QString(), "FieldName" ); + CAF_PDM_InitField( &fieldValueToApply, "FieldValueToApply", QString(), "FieldValueToApply" ); } //-------------------------------------------------------------------------------------------------- @@ -265,7 +265,7 @@ void RimCommandIssueFieldChanged::childObjects( caf::PdmObject* pdmObject, std:: size_t fIdx; for ( fIdx = 0; fIdx < fields.size(); ++fIdx ) { - if ( fields[fIdx] ) fields[fIdx]->childObjects( &children ); + if ( fields[fIdx] ) fields[fIdx]->children( &children ); } } @@ -289,7 +289,7 @@ caf::PdmObjectHandle* RimCommandIssueFieldChanged::findObjectByName( caf::PdmObj if ( fields[fIdx] ) { std::vector children; - fields[fIdx]->childObjects( &children ); + fields[fIdx]->children( &children ); for ( size_t cIdx = 0; cIdx < children.size(); cIdx++ ) { diff --git a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp index cdebd35895..2663b6a066 100644 --- a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -100,6 +100,7 @@ #include "RimParameterResultCrossPlot.h" #include "RimPerforationCollection.h" #include "RimPerforationInterval.h" +#include "RimPlotAxisPropertiesInterface.h" #include "RimPlotDataFilterCollection.h" #include "RimPlotDataFilterItem.h" #include "RimPltPlotCollection.h" @@ -118,6 +119,8 @@ #include "RimStimPlanModelTemplate.h" #include "RimStimPlanModelTemplateCollection.h" #include "RimStreamlineInViewCollection.h" +#include "RimSummaryAddress.h" +#include "RimSummaryAddressCollection.h" #include "RimSummaryCase.h" #include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" @@ -125,8 +128,9 @@ #include "RimSummaryCrossPlotCollection.h" #include "RimSummaryCurve.h" #include "RimSummaryCurveCollection.h" +#include "RimSummaryMultiPlot.h" +#include "RimSummaryMultiPlotCollection.h" #include "RimSummaryPlot.h" -#include "RimSummaryPlotCollection.h" #include "RimSurface.h" #include "RimSurfaceCollection.h" #include "RimValveTemplate.h" @@ -314,6 +318,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicSaveEclipseInputVisibleCellsFeature"; menuBuilder << "RicCreateGridCrossPlotFeature"; menuBuilder << "RicAddEclipseInputPropertyFeature"; + menuBuilder << "RicShowGridCalculatorFeature"; } else if ( dynamic_cast( firstUiItem ) ) { @@ -553,13 +558,14 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() { menuBuilder << "RicNewVfpPlotFeature"; } - else if ( dynamic_cast( firstUiItem ) ) + else if ( dynamic_cast( firstUiItem ) ) { + menuBuilder << "RicNewSummaryMultiPlotFeature"; + menuBuilder << "RicOpenSummaryPlotEditorFeature"; + menuBuilder << "Separator"; menuBuilder << "RicPasteSummaryPlotFeature"; menuBuilder << "RicPasteAsciiDataToSummaryPlotFeature"; - menuBuilder << "Separator"; - menuBuilder << "RicNewSummaryPlotFeature"; - menuBuilder << "RicNewDefaultSummaryPlotFeature"; + menuBuilder << "RicPasteSummaryMultiPlotFeature"; menuBuilder << "Separator"; menuBuilder << "RicShowSummaryCurveCalculatorFeature"; } @@ -673,11 +679,12 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "Separator"; menuBuilder << "RicEditSummaryPlotFeature"; menuBuilder << "RicDuplicateSummaryPlotFeature"; + menuBuilder << "RicSplitMultiPlotFeature"; menuBuilder << "RicNewSummaryEnsembleCurveSetFeature"; menuBuilder << "RicDuplicateSummaryCrossPlotFeature"; menuBuilder << "RicNewSummaryCrossPlotCurveFeature"; + menuBuilder << "RicNewPlotAxisPropertiesFeature"; menuBuilder << "Separator"; - menuBuilder << "RicSavePlotTemplateFeature"; // Export is not supported for cross plot if ( !summaryCrossPlot ) menuBuilder << "RicAsciiExportSummaryPlotFeature"; @@ -766,9 +773,9 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicImportEnsembleFeature"; menuBuilder.subMenuEnd(); menuBuilder.addSeparator(); + menuBuilder << "RicNewSummaryMultiPlotFeature"; menuBuilder << "RicNewDerivedEnsembleFeature"; - menuBuilder << "RicNewSummaryPlotFeature"; - menuBuilder << "RicNewDefaultSummaryPlotFeature"; + menuBuilder << "RicOpenSummaryPlotEditorFeature"; menuBuilder << "RicNewSummaryCrossPlotFeature"; menuBuilder.addSeparator(); menuBuilder << "RicConvertGroupToEnsembleFeature"; @@ -776,6 +783,9 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() } else if ( dynamic_cast( firstUiItem ) ) { + menuBuilder << "RicShowDataSourcesForRealization"; + menuBuilder.addSeparator(); + menuBuilder.subMenuStart( "Import" ); menuBuilder << "RicImportSummaryCaseFeature"; menuBuilder << "RicImportSummaryCasesFeature"; @@ -783,16 +793,17 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicImportEnsembleFeature"; menuBuilder.subMenuEnd(); menuBuilder.addSeparator(); - menuBuilder << "RicNewSummaryPlotFeature"; - menuBuilder << "RicNewDefaultSummaryPlotFeature"; + menuBuilder << "RicNewSummaryMultiPlotFeature"; + menuBuilder << "RicOpenSummaryPlotEditorFeature"; menuBuilder << "RicNewSummaryCrossPlotFeature"; + menuBuilder << "RicAppendSummaryCurvesForSummaryCasesFeature"; + menuBuilder << "RicAppendSummaryPlotsForSummaryCasesFeature"; menuBuilder.addSeparator(); menuBuilder << "RicImportGridModelFromSummaryCaseFeature"; if ( !dynamic_cast( firstUiItem ) ) { menuBuilder << "RicShowSummaryCurveCalculatorFeature"; - // menuBuilder << "RicNewSummaryPlotFeature"; } } else if ( dynamic_cast( firstUiItem ) ) @@ -1019,8 +1030,24 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() else if ( dynamic_cast( firstUiItem ) || dynamic_cast( firstUiItem ) ) { + menuBuilder << "RicCreateNewPlotFromTemplateFeature"; + menuBuilder << "Separator"; + menuBuilder << "RicRenamePlotTemplateFeature"; + menuBuilder << "RicDeletePlotTemplateFeature"; + menuBuilder << "RicEditPlotTemplateFeature"; + menuBuilder << "Separator"; + menuBuilder << "RicSetAsDefaultTemplateFeature"; + menuBuilder << "Separator"; menuBuilder << "RicReloadPlotTemplatesFeature"; } + else if ( dynamic_cast( firstUiItem ) ) + { + menuBuilder << "RicNewDefaultSummaryPlotFeature"; + menuBuilder << "Separator"; + menuBuilder << "RicSnapshotViewToPdfFeature"; + menuBuilder << "RicSaveMultiPlotTemplateFeature"; + menuBuilder << "RicPasteSummaryMultiPlotFeature"; + } else if ( dynamic_cast( firstUiItem ) ) { menuBuilder << "RicSnapshotViewToPdfFeature"; @@ -1029,6 +1056,15 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() { menuBuilder << "RicNewStreamlineFeature"; } + else if ( dynamic_cast( firstUiItem ) ) + { + menuBuilder << "RicCreateMultiPlotFromSelectionFeature"; + menuBuilder << "RicCreatePlotFromTemplateByShortcutFeature"; + } + else if ( dynamic_cast( firstUiItem ) ) + { + menuBuilder << "RicNewPlotAxisPropertiesFeature"; + } if ( dynamic_cast( firstUiItem ) ) { @@ -1060,9 +1096,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicShowPlotDataFeature"; menuBuilder << "RicShowTotalAllocationDataFeature"; + menuBuilder << "RicNewSummaryMultiPlotFeature"; menuBuilder << "RicNewDerivedEnsembleFeature"; - menuBuilder << "RicNewSummaryPlotFeature"; - menuBuilder << "RicNewDefaultSummaryPlotFeature"; menuBuilder << "RicNewSummaryCrossPlotFeature"; menuBuilder << "RicSummaryCurveSwitchAxisFeature"; menuBuilder << "RicNewDerivedSummaryFeature"; @@ -1091,7 +1126,9 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() if ( dynamic_cast( firstUiItem ) || dynamic_cast( firstUiItem ) ) { - menuBuilder << "RicCreatePlotFromSelectionFeature"; + menuBuilder << "RicAppendSummaryCurvesForSummaryCasesFeature"; + menuBuilder << "RicAppendSummaryPlotsForSummaryCasesFeature"; + menuBuilder << "RicCreateMultiPlotFromSelectionFeature"; menuBuilder << "RicCreatePlotFromTemplateByShortcutFeature"; } @@ -1100,8 +1137,11 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicCloseSummaryCaseInCollectionFeature"; menuBuilder << "RicDeleteSummaryCaseCollectionFeature"; menuBuilder << "RicCloseObservedDataFeature"; + menuBuilder << "RicDeleteSubPlotFeature"; menuBuilder << "RicNewMultiPlotFeature"; + menuBuilder << "RicAppendSummaryPlotsForObjectsFeature"; + menuBuilder << "RicAppendSummaryCurvesForObjectsFeature"; // Work in progress -- End @@ -1123,6 +1163,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() } else if ( dynamic_cast( firstUiItem ) ) { + menuBuilder << "RicShowGridCalculatorFeature"; menuBuilder << "RicAddEclipseInputPropertyFeature"; menuBuilder << "RicReloadCaseFeature"; menuBuilder << "RicReplaceCaseFeature"; @@ -1181,6 +1222,13 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicEclipseWellShowWellCellFenceFeature"; menuBuilder << "Separator"; menuBuilder << "RicNewSimWellFractureFeature"; + menuBuilder << "RicNewSimWellIntersectionFeature"; + } + else if ( dynamic_cast( firstUiItem ) ) + { + menuBuilder << "RicNewSummaryMultiPlotFromDataVectorFeature"; + menuBuilder << "RicAppendSummaryCurvesForSummaryAddressesFeature"; + menuBuilder << "RicAppendSummaryPlotsForSummaryAddressesFeature"; } #ifdef USE_ODB_API else if ( dynamic_cast( firstUiItem ) ) @@ -1263,6 +1311,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() if ( caf::CmdFeatureManager::instance()->getCommandFeature( "RicDeleteSubItemsFeature" )->canFeatureBeExecuted() ) { menuBuilder << "Separator"; + menuBuilder << "RicDeleteUncheckedSubItemsFeature"; menuBuilder << "RicDeleteSubItemsFeature"; } diff --git a/ApplicationLibCode/ProjectDataModel/RimContourMapProjection.cpp b/ApplicationLibCode/ProjectDataModel/RimContourMapProjection.cpp index 3dbdb1ec68..0f9448cbe5 100644 --- a/ApplicationLibCode/ProjectDataModel/RimContourMapProjection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimContourMapProjection.cpp @@ -83,16 +83,16 @@ RimContourMapProjection::RimContourMapProjection() , m_minResultAllTimeSteps( std::numeric_limits::infinity() ) , m_maxResultAllTimeSteps( -std::numeric_limits::infinity() ) { - CAF_PDM_InitObject( "RimContourMapProjection", ":/2DMapProjection16x16.png", "", "" ); + CAF_PDM_InitObject( "RimContourMapProjection", ":/2DMapProjection16x16.png" ); - CAF_PDM_InitField( &m_relativeSampleSpacing, "SampleSpacing", 0.9, "Sample Spacing Factor", "", "", "" ); + CAF_PDM_InitField( &m_relativeSampleSpacing, "SampleSpacing", 0.9, "Sample Spacing Factor" ); m_relativeSampleSpacing.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_resultAggregation, "ResultAggregation", "Result Aggregation", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_resultAggregation, "ResultAggregation", "Result Aggregation" ); - CAF_PDM_InitField( &m_showContourLines, "ContourLines", true, "Show Contour Lines", "", "", "" ); - CAF_PDM_InitField( &m_showContourLabels, "ContourLabels", true, "Show Contour Labels", "", "", "" ); - CAF_PDM_InitField( &m_smoothContourLines, "SmoothContourLines", true, "Smooth Contour Lines", "", "", "" ); + CAF_PDM_InitField( &m_showContourLines, "ContourLines", true, "Show Contour Lines" ); + CAF_PDM_InitField( &m_showContourLabels, "ContourLabels", true, "Show Contour Labels" ); + CAF_PDM_InitField( &m_smoothContourLines, "SmoothContourLines", true, "Smooth Contour Lines" ); setName( "Map Projection" ); nameField()->uiCapability()->setUiReadOnly( true ); diff --git a/ApplicationLibCode/ProjectDataModel/RimContourMapProjection.h b/ApplicationLibCode/ProjectDataModel/RimContourMapProjection.h index 383af027a0..ae08b77e8f 100644 --- a/ApplicationLibCode/ProjectDataModel/RimContourMapProjection.h +++ b/ApplicationLibCode/ProjectDataModel/RimContourMapProjection.h @@ -19,7 +19,6 @@ #pragma once #include "RimCheckableNamedObject.h" -#include "RimRegularLegendConfig.h" #include "cafContourLines.h" #include "cafDisplayCoordTransform.h" @@ -35,6 +34,7 @@ #include "cvfVector2.h" class RimGridView; +class RimRegularLegendConfig; //================================================================================================== /// diff --git a/ApplicationLibCode/ProjectDataModel/RimCustomObjectiveFunction.cpp b/ApplicationLibCode/ProjectDataModel/RimCustomObjectiveFunction.cpp index 89c44328f5..87b1c1617a 100644 --- a/ApplicationLibCode/ProjectDataModel/RimCustomObjectiveFunction.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimCustomObjectiveFunction.cpp @@ -35,17 +35,17 @@ CAF_PDM_SOURCE_INIT( RimCustomObjectiveFunction, "RimCustomObjectiveFunction" ); //-------------------------------------------------------------------------------------------------- RimCustomObjectiveFunction::RimCustomObjectiveFunction() { - CAF_PDM_InitObject( "Objective Function", ":/ObjectiveFunction.svg", "", "" ); + CAF_PDM_InitObject( "Objective Function", ":/ObjectiveFunction.svg" ); - CAF_PDM_InitFieldNoDefault( &m_functionTitle, "FunctionTitle", "Title", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_functionTitle, "FunctionTitle", "Title" ); m_functionTitle.registerGetMethod( this, &RimCustomObjectiveFunction::title ); m_functionTitle.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_customFunctionTitle, "CustomFunctionTitle", "Title", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_customFunctionTitle, "CustomFunctionTitle", "Title" ); - CAF_PDM_InitFieldNoDefault( &m_weights, "Weights", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_weights, "Weights", "" ); - CAF_PDM_InitFieldNoDefault( &m_objectiveFunctions, "ObjectiveFunctions", "Objective Functions", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_objectiveFunctions, "ObjectiveFunctions", "Objective Functions" ); { auto objFunc1 = new RimObjectiveFunction(); @@ -80,7 +80,7 @@ RimCustomObjectiveFunctionWeight* RimCustomObjectiveFunction::addWeight() //-------------------------------------------------------------------------------------------------- std::vector RimCustomObjectiveFunction::weights() const { - return m_weights.childObjects(); + return m_weights.children(); } //-------------------------------------------------------------------------------------------------- @@ -350,7 +350,7 @@ RimCustomObjectiveFunctionCollection* RimCustomObjectiveFunction::parentCollecti //-------------------------------------------------------------------------------------------------- RimObjectiveFunction* RimCustomObjectiveFunction::objectiveFunction( RimObjectiveFunction::FunctionType functionType ) const { - for ( auto objectiveFunc : m_objectiveFunctions.childObjects() ) + for ( auto objectiveFunc : m_objectiveFunctions.children() ) { if ( objectiveFunc->functionType() == functionType ) { diff --git a/ApplicationLibCode/ProjectDataModel/RimCustomObjectiveFunctionCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimCustomObjectiveFunctionCollection.cpp index c782de6794..2826d0aa38 100644 --- a/ApplicationLibCode/ProjectDataModel/RimCustomObjectiveFunctionCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimCustomObjectiveFunctionCollection.cpp @@ -30,9 +30,9 @@ CAF_PDM_SOURCE_INIT( RimCustomObjectiveFunctionCollection, "RimCustomObjectiveFu RimCustomObjectiveFunctionCollection::RimCustomObjectiveFunctionCollection() : objectiveFunctionChanged( this ) { - CAF_PDM_InitObject( "Custom Objective Functions", ":/ObjectiveFunctionCollection.svg", "", "" ); + CAF_PDM_InitObject( "Custom Objective Functions", ":/ObjectiveFunctionCollection.svg" ); - CAF_PDM_InitFieldNoDefault( &m_objectiveFunctions, "ObjectiveFunctions", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_objectiveFunctions, "ObjectiveFunctions", "" ); } //-------------------------------------------------------------------------------------------------- @@ -58,7 +58,7 @@ void RimCustomObjectiveFunctionCollection::onObjectiveFunctionChanged( RimCustom //-------------------------------------------------------------------------------------------------- std::vector RimCustomObjectiveFunctionCollection::objectiveFunctions() const { - return m_objectiveFunctions.childObjects(); + return m_objectiveFunctions.children(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimCustomObjectiveFunctionWeight.cpp b/ApplicationLibCode/ProjectDataModel/RimCustomObjectiveFunctionWeight.cpp index a08f6e2fdf..43015b7f96 100644 --- a/ApplicationLibCode/ProjectDataModel/RimCustomObjectiveFunctionWeight.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimCustomObjectiveFunctionWeight.cpp @@ -40,33 +40,28 @@ CAF_PDM_SOURCE_INIT( RimCustomObjectiveFunctionWeight, "RimCustomObjectiveFuncti //-------------------------------------------------------------------------------------------------- RimCustomObjectiveFunctionWeight::RimCustomObjectiveFunctionWeight() { - CAF_PDM_InitObject( "Custom Objective Function Weight", ":/ObjectiveFunctionWeight.svg", "", "" ); + CAF_PDM_InitObject( "Custom Objective Function Weight", ":/ObjectiveFunctionWeight.svg" ); - CAF_PDM_InitFieldNoDefault( &m_title, "WeightTitle", "Title", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_title, "WeightTitle", "Title" ); m_title.registerGetMethod( this, &RimCustomObjectiveFunctionWeight::title ); - CAF_PDM_InitFieldNoDefault( &m_objectiveValuesSummaryAddressesUiField, "SelectedObjectiveSummaryVar", "Vector", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_objectiveValuesSummaryAddressesUiField, "SelectedObjectiveSummaryVar", "Vector" ); m_objectiveValuesSummaryAddressesUiField.xmlCapability()->disableIO(); m_objectiveValuesSummaryAddressesUiField.uiCapability()->setUiEditorTypeName( caf::PdmUiLineEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_objectiveValuesSummaryAddresses, "ObjectiveSummaryAddress", "Summary Address", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_objectiveValuesSummaryAddresses, "ObjectiveSummaryAddress", "Summary Address" ); m_objectiveValuesSummaryAddresses.uiCapability()->setUiTreeHidden( true ); m_objectiveValuesSummaryAddresses.uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_objectiveValuesSelectSummaryAddressPushButton, - "SelectObjectiveSummaryAddress", - "", - "", - "", - "" ); + CAF_PDM_InitFieldNoDefault( &m_objectiveValuesSelectSummaryAddressPushButton, "SelectObjectiveSummaryAddress", "" ); caf::PdmUiPushButtonEditor::configureEditorForField( &m_objectiveValuesSelectSummaryAddressPushButton ); m_objectiveValuesSelectSummaryAddressPushButton.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); m_objectiveValuesSelectSummaryAddressPushButton = false; - CAF_PDM_InitField( &m_weightValue, "WeightValue", 1.0, "Weight", "", "", "" ); + CAF_PDM_InitField( &m_weightValue, "WeightValue", 1.0, "Weight" ); m_weightValue.uiCapability()->setUiEditorTypeName( caf::PdmUiLineEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_objectiveFunction, "ObjectiveFunction", "Objective Function", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_objectiveFunction, "ObjectiveFunction", "Objective Function" ); m_objectiveFunction.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() ); setDeletable( true ); @@ -135,8 +130,7 @@ double RimCustomObjectiveFunctionWeight::weightValue() const /// //-------------------------------------------------------------------------------------------------- QList - RimCustomObjectiveFunctionWeight::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) + RimCustomObjectiveFunctionWeight::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; @@ -161,7 +155,7 @@ void RimCustomObjectiveFunctionWeight::fieldChangedByUi( const caf::PdmFieldHand RimSummaryCaseCollection* candidateEnsemble = parentCurveSet()->summaryCaseCollection(); std::vector candidateAddresses; - for ( auto address : m_objectiveValuesSummaryAddresses().childObjects() ) + for ( auto address : m_objectiveValuesSummaryAddresses().children() ) { candidateAddresses.push_back( address->address() ); } @@ -173,7 +167,7 @@ void RimCustomObjectiveFunctionWeight::fieldChangedByUi( const caf::PdmFieldHand auto curveSelection = dlg.curveSelection(); if ( !curveSelection.empty() ) { - m_objectiveValuesSummaryAddresses.clear(); + m_objectiveValuesSummaryAddresses.deleteChildren(); for ( auto address : curveSelection ) { RimSummaryAddress* summaryAddress = new RimSummaryAddress(); diff --git a/ApplicationLibCode/ProjectDataModel/RimCustomObjectiveFunctionWeight.h b/ApplicationLibCode/ProjectDataModel/RimCustomObjectiveFunctionWeight.h index b69b14e016..e64e698821 100644 --- a/ApplicationLibCode/ProjectDataModel/RimCustomObjectiveFunctionWeight.h +++ b/ApplicationLibCode/ProjectDataModel/RimCustomObjectiveFunctionWeight.h @@ -58,8 +58,7 @@ class RimCustomObjectiveFunctionWeight : public caf::PdmObject private: caf::PdmFieldHandle* userDescriptionField() override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineEditorAttribute( const caf::PdmFieldHandle* field, diff --git a/ApplicationLibCode/ProjectDataModel/RimDataSourceSteppingTools.cpp b/ApplicationLibCode/ProjectDataModel/RimDataSourceSteppingTools.cpp index 8289703d9a..28952e4db9 100644 --- a/ApplicationLibCode/ProjectDataModel/RimDataSourceSteppingTools.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimDataSourceSteppingTools.cpp @@ -1,5 +1,27 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016 Statoil 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 "RimDataSourceSteppingTools.h" +#include "RiaSummaryAddressAnalyzer.h" + +#include "cafPdmUiFieldHandle.h" + #include "cvfAssert.h" //-------------------------------------------------------------------------------------------------- @@ -7,7 +29,8 @@ //-------------------------------------------------------------------------------------------------- void RimDataSourceSteppingTools::modifyCurrentIndex( caf::PdmValueField* valueField, const QList& options, - int indexOffset ) + int indexOffset, + bool notifyChange ) { if ( valueField && !options.isEmpty() ) { @@ -43,7 +66,146 @@ void RimDataSourceSteppingTools::modifyCurrentIndex( caf::PdmValueField* { QVariant newValue = options[nextIndex].value(); valueField->setFromQVariant( newValue ); - valueField->uiCapability()->notifyFieldChanged( currentValue, newValue ); + if ( notifyChange ) valueField->uiCapability()->notifyFieldChanged( currentValue, newValue ); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimDataSourceSteppingTools::updateAddressIfMatching( const QVariant& oldValue, + const QVariant& newValue, + RifEclipseSummaryAddress::SummaryVarCategory category, + RifEclipseSummaryAddress* adr ) +{ + if ( !adr ) return false; + + if ( category == RifEclipseSummaryAddress::SUMMARY_REGION ) + { + int oldInt = oldValue.toInt(); + int newInt = newValue.toInt(); + + if ( adr->regionNumber() == oldInt ) + { + adr->setRegion( newInt ); + + return true; + } + } + else if ( category == RifEclipseSummaryAddress::SUMMARY_AQUIFER ) + { + int oldInt = oldValue.toInt(); + int newInt = newValue.toInt(); + + if ( adr->aquiferNumber() == oldInt ) + { + adr->setAquiferNumber( newInt ); + + return true; + } + } + else if ( category == RifEclipseSummaryAddress::SUMMARY_GROUP ) + { + std::string oldString = oldValue.toString().toStdString(); + std::string newString = newValue.toString().toStdString(); + + if ( adr->groupName() == oldString ) + { + adr->setGroupName( newString ); + + return true; + } + } + else if ( category == RifEclipseSummaryAddress::SUMMARY_WELL ) + { + std::string oldString = oldValue.toString().toStdString(); + std::string newString = newValue.toString().toStdString(); + + if ( adr->wellName() == oldString ) + { + adr->setWellName( newString ); + + return true; + } + } + else if ( category == RifEclipseSummaryAddress::SUMMARY_BLOCK || + category == RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION ) + { + std::string oldString = oldValue.toString().toStdString(); + std::string newString = newValue.toString().toStdString(); + if ( adr->blockAsString() == oldString ) + { + adr->setCellIjk( newString ); + + return true; + } + } + else if ( category == RifEclipseSummaryAddress::SUMMARY_WELL_SEGMENT ) + { + int oldInt = oldValue.toInt(); + int newInt = newValue.toInt(); + if ( adr->wellSegmentNumber() == oldInt ) + { + adr->setWellSegmentNumber( newInt ); + + return true; } } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimDataSourceSteppingTools::updateHistoryAndSummaryQuantityIfMatching( const QVariant& oldValue, + const QVariant& newValue, + RifEclipseSummaryAddress* adr ) +{ + if ( !adr ) return false; + + std::string oldString = oldValue.toString().toStdString(); + std::string newString = newValue.toString().toStdString(); + + if ( adr->vectorName() == oldString ) + { + adr->setVectorName( newString ); + + return true; + } + + std::string correspondingOldString = RiaSummaryAddressAnalyzer::correspondingHistorySummaryCurveName( oldString ); + std::string correspondingNewString = RiaSummaryAddressAnalyzer::correspondingHistorySummaryCurveName( newString ); + + if ( adr->vectorName() == correspondingOldString ) + { + adr->setVectorName( correspondingNewString ); + + return true; + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimDataSourceSteppingTools::updateQuantityIfMatching( const QVariant& oldValue, + const QVariant& newValue, + RifEclipseSummaryAddress* adr ) +{ + if ( !adr ) return false; + + std::string oldString = oldValue.toString().toStdString(); + std::string newString = newValue.toString().toStdString(); + + if ( adr->vectorName() == oldString ) + { + adr->setVectorName( newString ); + + return true; + } + + return false; } diff --git a/ApplicationLibCode/ProjectDataModel/RimDataSourceSteppingTools.h b/ApplicationLibCode/ProjectDataModel/RimDataSourceSteppingTools.h index 8a3fbf01ff..cf38740123 100644 --- a/ApplicationLibCode/ProjectDataModel/RimDataSourceSteppingTools.h +++ b/ApplicationLibCode/ProjectDataModel/RimDataSourceSteppingTools.h @@ -18,8 +18,10 @@ #pragma once -#include "cafPdmField.h" -#include "cafPdmObject.h" +#include "RifEclipseSummaryAddress.h" + +#include "cafPdmUiItem.h" +#include "cafPdmValueField.h" //================================================================================================== /// @@ -29,5 +31,18 @@ class RimDataSourceSteppingTools public: static void modifyCurrentIndex( caf::PdmValueField* valueField, const QList& options, - int indexOffset ); + int indexOffset, + bool notifyChange = true ); + + static bool updateAddressIfMatching( const QVariant& oldValue, + const QVariant& newValue, + RifEclipseSummaryAddress::SummaryVarCategory category, + RifEclipseSummaryAddress* adr ); + + static bool updateHistoryAndSummaryQuantityIfMatching( const QVariant& oldValue, + const QVariant& newValue, + RifEclipseSummaryAddress* adr ); + + static bool + updateQuantityIfMatching( const QVariant& oldValue, const QVariant& newValue, RifEclipseSummaryAddress* adr ); }; diff --git a/ApplicationLibCode/ProjectDataModel/RimDepthTrackPlot.cpp b/ApplicationLibCode/ProjectDataModel/RimDepthTrackPlot.cpp index ef46fdc3a1..59045f5ac8 100644 --- a/ApplicationLibCode/ProjectDataModel/RimDepthTrackPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimDepthTrackPlot.cpp @@ -36,6 +36,7 @@ #include "RimMainPlotCollection.h" #include "RimOilField.h" #include "RimPlot.h" +#include "RimPlotWindow.h" #include "RimProject.h" #include "RimWellAllocationPlot.h" #include "RimWellLogCurve.h" @@ -74,6 +75,14 @@ void RimDepthTrackPlot::AxisGridEnum::setUp() setDefault( RimDepthTrackPlot::AXIS_GRID_MAJOR ); } +template <> +void caf::AppEnum::setUp() +{ + addItem( RimDepthTrackPlot::DepthOrientation::HORIZONTAL, "HORIZONTAL", "Horizontal" ); + addItem( RimDepthTrackPlot::DepthOrientation::VERTICAL, "VERTICAL", "Vertical" ); + setDefault( RimDepthTrackPlot::DepthOrientation::VERTICAL ); +} + } // End namespace caf CAF_PDM_SOURCE_INIT( RimDepthTrackPlot, "DepthTrackPlot" ); @@ -96,41 +105,43 @@ RimDepthTrackPlot::RimDepthTrackPlot() m_commonDataSource.xmlCapability()->disableIO(); m_commonDataSource = new RimWellLogCurveCommonDataSource; - CAF_PDM_InitField( &m_plotWindowTitle, "PlotDescription", QString( "" ), "Name", "", "", "" ); + CAF_PDM_InitField( &m_plotWindowTitle, "PlotDescription", QString( "" ), "Name" ); m_plotWindowTitle.xmlCapability()->setIOWritable( false ); caf::AppEnum depthType = RiaDefines::DepthTypeEnum::MEASURED_DEPTH; - CAF_PDM_InitScriptableField( &m_depthType, "DepthType", depthType, "Type", "", "", "" ); + CAF_PDM_InitScriptableField( &m_depthType, "DepthType", depthType, "Type" ); caf::AppEnum depthUnit = RiaDefines::DepthUnitType::UNIT_METER; - CAF_PDM_InitScriptableField( &m_depthUnit, "DepthUnit", depthUnit, "Unit", "", "", "" ); + CAF_PDM_InitScriptableField( &m_depthUnit, "DepthUnit", depthUnit, "Unit" ); - CAF_PDM_InitScriptableField( &m_minVisibleDepth, "MinimumDepth", 0.0, "Min", "", "", "" ); - CAF_PDM_InitScriptableField( &m_maxVisibleDepth, "MaximumDepth", 1000.0, "Max", "", "", "" ); + CAF_PDM_InitScriptableField( &m_minVisibleDepth, "MinimumDepth", 0.0, "Min" ); + CAF_PDM_InitScriptableField( &m_maxVisibleDepth, "MaximumDepth", 1000.0, "Max" ); m_minVisibleDepth.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); m_maxVisibleDepth.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); - CAF_PDM_InitScriptableFieldNoDefault( &m_depthAxisGridVisibility, "ShowDepthGridLines", "Show Grid Lines", "", "", "" ); - CAF_PDM_InitScriptableField( &m_isAutoScaleDepthEnabled, "AutoScaleDepthEnabled", true, "Auto Scale", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_depthAxisGridVisibility, "ShowDepthGridLines", "Show Grid Lines" ); + CAF_PDM_InitScriptableField( &m_isAutoScaleDepthEnabled, "AutoScaleDepthEnabled", true, "Auto Scale" ); m_isAutoScaleDepthEnabled.uiCapability()->setUiHidden( true ); - CAF_PDM_InitScriptableFieldNoDefault( &m_subTitleFontSize, "SubTitleFontSize", "Track Title Font Size", "", "", "" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_axisTitleFontSize, "AxisTitleFontSize", "Axis Title Font Size", "", "", "" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_axisValueFontSize, "AxisValueFontSize", "Axis Value Font Size", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_subTitleFontSize, "SubTitleFontSize", "Track Title Font Size" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_axisTitleFontSize, "AxisTitleFontSize", "Axis Title Font Size" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_axisValueFontSize, "AxisValueFontSize", "Axis Value Font Size" ); - CAF_PDM_InitFieldNoDefault( &m_nameConfig, "NameConfig", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_nameConfig, "NameConfig", "" ); m_nameConfig.uiCapability()->setUiTreeHidden( true ); m_nameConfig.uiCapability()->setUiTreeChildrenHidden( true ); m_nameConfig = new RimWellLogPlotNameConfig(); - CAF_PDM_InitFieldNoDefault( &m_ensembleCurveSet, "FilterEnsembleCurveSet", "Filter by Ensemble Curve Set", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_depthEqualization, "DepthEqualization", "Depth Equalization", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_ensembleCurveSet, "FilterEnsembleCurveSet", "Filter by Ensemble Curve Set" ); + CAF_PDM_InitFieldNoDefault( &m_depthEqualization, "DepthEqualization", "Depth Equalization" ); - CAF_PDM_InitFieldNoDefault( &m_plots, "Tracks", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_plots, "Tracks", "" ); m_plots.uiCapability()->setUiTreeHidden( true ); auto reorderability = caf::PdmFieldReorderCapability::addToField( &m_plots ); reorderability->orderChanged.connect( this, &RimDepthTrackPlot::onPlotsReordered ); + CAF_PDM_InitFieldNoDefault( &m_depthOrientation, "DepthOrientation", "Orientation" ); + m_availableDepthUnits = { RiaDefines::DepthUnitType::UNIT_METER, RiaDefines::DepthUnitType::UNIT_FEET }; m_availableDepthTypes = { RiaDefines::DepthTypeEnum::MEASURED_DEPTH, RiaDefines::DepthTypeEnum::TRUE_VERTICAL_DEPTH, @@ -154,7 +165,7 @@ RimDepthTrackPlot::~RimDepthTrackPlot() delete m_nameConfig; removeMdiWindowFromMdiArea(); - m_plots.deleteAllChildObjects(); + m_plots.deleteChildren(); cleanupBeforeClose(); } @@ -167,9 +178,9 @@ RimDepthTrackPlot& RimDepthTrackPlot::operator=( RimDepthTrackPlot&& rhs ) RimPlotWindow::operator=( std::move( rhs ) ); // Move all tracks - std::vector plots = rhs.m_plots.childObjects(); - rhs.m_plots.clear(); - for ( RimPlot* plot : plots ) + auto plots = rhs.m_plots.children(); + rhs.m_plots.clearWithoutDelete(); + for ( auto plot : plots ) { m_plots.push_back( plot ); } @@ -179,7 +190,7 @@ RimDepthTrackPlot& RimDepthTrackPlot::operator=( RimDepthTrackPlot&& rhs ) // They had their own description at top level which we don't want to overwrite. auto dataSource = rhs.m_commonDataSource(); - rhs.m_commonDataSource.removeChildObject( dataSource ); + rhs.m_commonDataSource.removeChild( dataSource ); m_commonDataSource = dataSource; m_commonDataSourceEnabled = rhs.m_commonDataSourceEnabled; @@ -234,9 +245,9 @@ size_t RimDepthTrackPlot::plotCount() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -size_t RimDepthTrackPlot::plotIndex( const RimPlot* plot ) const +size_t RimDepthTrackPlot::plotIndex( const RimWellLogTrack* plot ) const { - return m_plots.index( plot ); + return m_plots.indexOf( plot ); } //-------------------------------------------------------------------------------------------------- @@ -257,16 +268,23 @@ RimPlot* RimDepthTrackPlot::plotByIndex( size_t index ) const //-------------------------------------------------------------------------------------------------- std::vector RimDepthTrackPlot::plots() const { - return m_plots.childObjects(); + std::vector baseClassPlots; + + for ( auto p : m_plots.children() ) + { + baseClassPlots.push_back( p ); + } + + return baseClassPlots; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimDepthTrackPlot::visiblePlots() const +std::vector RimDepthTrackPlot::visiblePlots() const { - std::vector allVisiblePlots; - for ( RimPlot* plot : m_plots() ) + std::vector allVisiblePlots; + for ( auto plot : m_plots() ) { if ( plot->showWindow() ) { @@ -276,6 +294,17 @@ std::vector RimDepthTrackPlot::visiblePlots() const return allVisiblePlots; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimDepthTrackPlot::columnCount() const +{ + if ( depthOrientation() == DepthOrientation::VERTICAL ) + return RimPlotWindow::columnCount(); + else + return 1; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -293,8 +322,8 @@ void RimDepthTrackPlot::updateZoom() for ( RimPlot* plot : plots() ) { - static_cast( plot )->setVisibleYRange( m_minVisibleDepth(), m_maxVisibleDepth() ); - plot->updateZoomInQwt(); + static_cast( plot )->setVisibleDepthRange( m_minVisibleDepth(), m_maxVisibleDepth() ); + plot->updateZoomInParentPlot(); } if ( m_viewer ) @@ -334,7 +363,7 @@ void RimDepthTrackPlot::setDepthAxisRange( double minimumDepth, double maximumDe m_minVisibleDepth.uiCapability()->updateConnectedEditors(); m_maxVisibleDepth.uiCapability()->updateConnectedEditors(); - setAutoScaleDepthEnabled( false ); + setAutoScaleDepthValuesEnabled( false ); updateZoom(); } @@ -588,7 +617,7 @@ void RimDepthTrackPlot::recreatePlotWidgets() for ( size_t tIdx = 0; tIdx < plotVector.size(); ++tIdx ) { plotVector[tIdx]->createPlotWidget(); - m_viewer->addPlot( plotVector[tIdx]->viewer() ); + m_viewer->addPlot( plotVector[tIdx]->plotWidget() ); } } @@ -648,7 +677,7 @@ RimWellLogCurveCommonDataSource* RimDepthTrackPlot::commonDataSource() const //-------------------------------------------------------------------------------------------------- void RimDepthTrackPlot::updateCommonDataSource() { - m_commonDataSource->updateDefaultOptions(); + m_commonDataSource->analyseCurvesAndTracks(); } //-------------------------------------------------------------------------------------------------- @@ -829,6 +858,10 @@ void RimDepthTrackPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedFiel m_isAutoScaleDepthEnabled = true; onLoadDataAndUpdate(); } + else if ( changedField == &m_depthOrientation ) + { + onLoadDataAndUpdate(); + } else if ( changedField == &m_subTitleFontSize || changedField == &m_axisTitleFontSize || changedField == &m_axisValueFontSize ) { @@ -883,6 +916,7 @@ void RimDepthTrackPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderi plotLayoutGroup->add( &m_subTitleFontSize ); plotLayoutGroup->add( &m_axisTitleFontSize ); plotLayoutGroup->add( &m_axisValueFontSize ); + plotLayoutGroup->add( &m_depthOrientation ); std::vector ensembleWellLogCurveSets; descendantsOfType( ensembleWellLogCurveSets ); @@ -906,10 +940,9 @@ void RimDepthTrackPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderi //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimDepthTrackPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RimDepthTrackPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { - QList options = RimPlotWindow::calculateValueOptions( fieldNeedingOptions, useOptionsOnly ); + QList options = RimPlotWindow::calculateValueOptions( fieldNeedingOptions ); if ( fieldNeedingOptions == &m_depthType ) { @@ -942,7 +975,6 @@ QList RimDepthTrackPlot::calculateValueOptions( const ca RiaOptionItemFactory::appendOptionItemsForEnsembleCurveSets( &options ); } - ( *useOptionsOnly ) = true; return options; } @@ -1022,16 +1054,19 @@ caf::PdmFieldHandle* RimDepthTrackPlot::userDescriptionField() //-------------------------------------------------------------------------------------------------- void RimDepthTrackPlot::insertPlot( RimPlot* plot, size_t index ) { - if ( plot ) + auto wellLogTrack = dynamic_cast( plot ); + CVF_ASSERT( wellLogTrack && "Only type RimWellLogTrack is supported in RimDepthTrackPlot" ); + + if ( wellLogTrack ) { - m_plots.insert( index, plot ); + m_plots.insert( index, wellLogTrack ); if ( m_viewer ) { - plot->createPlotWidget(); - m_viewer->insertPlot( plot->viewer(), index ); + wellLogTrack->createPlotWidget(); + m_viewer->insertPlot( wellLogTrack->plotWidget(), index ); } - plot->setShowWindow( true ); + wellLogTrack->setShowWindow( true ); onPlotAdditionOrRemoval(); } } @@ -1045,9 +1080,9 @@ void RimDepthTrackPlot::removePlot( RimPlot* plot ) { if ( m_viewer ) { - m_viewer->removePlot( plot->viewer() ); + m_viewer->removePlot( plot->plotWidget() ); } - m_plots.removeChildObject( plot ); + m_plots.removeChild( plot ); onPlotAdditionOrRemoval(); } @@ -1144,18 +1179,48 @@ RimDepthTrackPlot::AxisGridVisibility RimDepthTrackPlot::depthAxisGridLinesEnabl //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimDepthTrackPlot::setAutoScaleXEnabled( bool enabled ) +RimDepthTrackPlot::DepthOrientation RimDepthTrackPlot::depthOrientation() const { - for ( RimPlot* plot : plots() ) + return m_depthOrientation(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuPlotAxis RimDepthTrackPlot::depthAxis() const +{ + if ( m_depthOrientation() == RimDepthTrackPlot::DepthOrientation::VERTICAL ) + return RiuPlotAxis::defaultLeft(); + else + return RiuPlotAxis::defaultBottom(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuPlotAxis RimDepthTrackPlot::valueAxis() const +{ + if ( m_depthOrientation() == RimDepthTrackPlot::DepthOrientation::VERTICAL ) + return RiuPlotAxis::defaultTop(); + else + return RiuPlotAxis::defaultLeft(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimDepthTrackPlot::setAutoScalePropertyValuesEnabled( bool enabled ) +{ + for ( auto plot : m_plots.children() ) { - plot->setAutoScaleXEnabled( enabled ); + plot->setAutoScalePropertyValuesEnabled( enabled ); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimDepthTrackPlot::setAutoScaleDepthEnabled( bool enabled ) +void RimDepthTrackPlot::setAutoScaleDepthValuesEnabled( bool enabled ) { m_isAutoScaleDepthEnabled = enabled; m_isAutoScaleDepthEnabled.uiCapability()->updateConnectedEditors(); @@ -1166,8 +1231,8 @@ void RimDepthTrackPlot::setAutoScaleDepthEnabled( bool enabled ) //-------------------------------------------------------------------------------------------------- void RimDepthTrackPlot::zoomAll() { - setAutoScaleXEnabled( true ); - setAutoScaleDepthEnabled( true ); + setAutoScalePropertyValuesEnabled( true ); + setAutoScaleDepthValuesEnabled( true ); updateZoom(); } diff --git a/ApplicationLibCode/ProjectDataModel/RimDepthTrackPlot.h b/ApplicationLibCode/ProjectDataModel/RimDepthTrackPlot.h index af772f2aff..2c86032c84 100644 --- a/ApplicationLibCode/ProjectDataModel/RimDepthTrackPlot.h +++ b/ApplicationLibCode/ProjectDataModel/RimDepthTrackPlot.h @@ -22,6 +22,7 @@ #include "RiaDefines.h" #include "RimAbstractPlotCollection.h" #include "RimEnsembleWellLogStatistics.h" +#include "RimPlot.h" #include "RimPlotWindow.h" #include "RimWellLogPlotNameConfig.h" @@ -41,6 +42,8 @@ class RimWellLogCurveCommonDataSource; class RiuWellLogPlot; class RimPlot; class RimEnsembleCurveSet; +class RiuPlotAxis; +class RimWellLogTrack; class QKeyEvent; @@ -64,6 +67,12 @@ class RimDepthTrackPlot : public RimTypedPlotCollection, public RimPlot typedef caf::AppEnum AxisGridEnum; using DepthTypeEnum = RiaDefines::DepthTypeEnum; + enum class DepthOrientation + { + HORIZONTAL, + VERTICAL + }; + public: RimDepthTrackPlot(); ~RimDepthTrackPlot() override; @@ -75,13 +84,15 @@ class RimDepthTrackPlot : public RimTypedPlotCollection, public RimPlot QString description() const override; size_t plotCount() const override; - size_t plotIndex( const RimPlot* plot ) const; + size_t plotIndex( const RimWellLogTrack* plot ) const; RimPlot* plotByIndex( size_t index ) const; - std::vector plots() const override; - std::vector visiblePlots() const; - void insertPlot( RimPlot* plot, size_t index ) final; - void removePlot( RimPlot* plot ) final; + int columnCount() const override; + + std::vector plots() const override; + std::vector visiblePlots() const; + void insertPlot( RimPlot* plot, size_t index ) final; + void removePlot( RimPlot* plot ) final; DepthTypeEnum depthType() const; void setDepthType( DepthTypeEnum depthType ); @@ -93,8 +104,12 @@ class RimDepthTrackPlot : public RimTypedPlotCollection, public RimPlot void enableDepthAxisGridLines( AxisGridVisibility gridVisibility ); AxisGridVisibility depthAxisGridLinesEnabled() const; - void setAutoScaleXEnabled( bool enabled ); - void setAutoScaleDepthEnabled( bool enabled ); + RimDepthTrackPlot::DepthOrientation depthOrientation() const; + RiuPlotAxis depthAxis() const; + RiuPlotAxis valueAxis() const; + + void setAutoScalePropertyValuesEnabled( bool enabled ); + void setAutoScaleDepthValuesEnabled( bool enabled ); void zoomAll() override; void updateZoom(); @@ -142,8 +157,7 @@ class RimDepthTrackPlot : public RimTypedPlotCollection, public RimPlot // Overridden PDM methods void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void initAfterRead() override; void defineEditorAttribute( const caf::PdmFieldHandle* field, @@ -177,11 +191,13 @@ class RimDepthTrackPlot : public RimTypedPlotCollection, public RimPlot caf::PdmField m_axisValueFontSize; caf::PdmChildField m_nameConfig; - caf::PdmChildArrayField m_plots; + caf::PdmChildArrayField m_plots; caf::PdmField> m_depthEqualization; caf::PdmPtrField m_ensembleCurveSet; + caf::PdmField> m_depthOrientation; + QPointer m_viewer; std::set m_availableDepthUnits; std::set m_availableDepthTypes; diff --git a/ApplicationLibCode/ProjectDataModel/RimDialogData.cpp b/ApplicationLibCode/ProjectDataModel/RimDialogData.cpp index 9a6d6b2f05..ff9154f9e6 100644 --- a/ApplicationLibCode/ProjectDataModel/RimDialogData.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimDialogData.cpp @@ -37,41 +37,38 @@ CAF_PDM_SOURCE_INIT( RimDialogData, "RimDialogData" ); //-------------------------------------------------------------------------------------------------- RimDialogData::RimDialogData() { - CAF_PDM_InitObject( "Dialog Data", "", "", "" ); + CAF_PDM_InitObject( "Dialog Data" ); - CAF_PDM_InitFieldNoDefault( &m_exportCarfin, "ExportCarfin", "Export Carfin", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_exportCarfin, "ExportCarfin", "Export Carfin" ); m_exportCarfin = new RicExportCarfinUi; - CAF_PDM_InitFieldNoDefault( &m_exportCompletionData, "ExportCompletionData", "Export Completion Data", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_exportCompletionData, "ExportCompletionData", "Export Completion Data" ); m_exportCompletionData = new RicExportCompletionDataSettingsUi(); - CAF_PDM_InitFieldNoDefault( &m_multipleFractionsData, "MultipleFractionsData", "Multiple Fractures Data", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_multipleFractionsData, "MultipleFractionsData", "Multiple Fractures Data" ); m_multipleFractionsData = new RiuCreateMultipleFractionsUi(); CAF_PDM_InitFieldNoDefault( &m_holoLenseExportToFolderData, "HoloLenseExportToFolderData", - "Holo Lens Export To Folder Data", - "", - "", - "" ); + "Holo Lens Export To Folder Data" ); m_holoLenseExportToFolderData = new RicHoloLensExportToFolderUi(); - CAF_PDM_InitFieldNoDefault( &m_exportWellPathsData, "ExportwellPathsData", "Export Well Paths Data", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_exportWellPathsData, "ExportwellPathsData", "Export Well Paths Data" ); m_exportWellPathsData = new RicExportWellPathsUi(); - CAF_PDM_InitFieldNoDefault( &m_exportLgrData, "ExportLgr", "LGR Export", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_exportLgrData, "ExportLgr", "LGR Export" ); m_exportLgrData = new RicExportLgrUi(); - CAF_PDM_InitFieldNoDefault( &m_exportSectorModelData, "ExportSectorModel", "Export Sector Model", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_exportSectorModelData, "ExportSectorModel", "Export Sector Model" ); m_exportSectorModelData = new RicExportEclipseSectorModelUi(); - CAF_PDM_InitFieldNoDefault( &m_mockModelSettings, "MockModelSettings", "Mock Model Settings", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_mockModelSettings, "MockModelSettings", "Mock Model Settings" ); m_mockModelSettings = new RimMockModelSettings(); - CAF_PDM_InitFieldNoDefault( &m_createEnsembleSurfaceUi, "CreateEnsembleSurfaceUi", "Create Ensmeble Surface Ui", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_createEnsembleSurfaceUi, "CreateEnsembleSurfaceUi", "Create Ensmeble Surface Ui" ); m_createEnsembleSurfaceUi = new RicCreateEnsembleSurfaceUi(); - CAF_PDM_InitFieldNoDefault( &m_createEnsembleWellLogUi, "CreateEnsembleWellLogUi", "Create Ensemble Well Log Ui", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_createEnsembleWellLogUi, "CreateEnsembleWellLogUi", "Create Ensemble Well Log Ui" ); m_createEnsembleWellLogUi = new RicCreateEnsembleWellLogUi(); } diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp index d5ebd48a79..e82478abc6 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp @@ -21,7 +21,9 @@ #include "RimEclipseCase.h" #include "RiaColorTables.h" +#include "RiaDefines.h" #include "RiaFieldHandleTools.h" +#include "RiaLogging.h" #include "RiaPreferences.h" #include "RiaQDateTimeTools.h" @@ -50,6 +52,8 @@ #include "RimEclipseInputPropertyCollection.h" #include "RimEclipsePropertyFilter.h" #include "RimEclipsePropertyFilterCollection.h" +#include "RimEclipseResultAddress.h" +#include "RimEclipseResultAddressCollection.h" #include "RimEclipseStatisticsCase.h" #include "RimEclipseView.h" #include "RimFaultInViewCollection.h" @@ -99,26 +103,31 @@ RimEclipseCase::RimEclipseCase() "All Eclipse Views in the case" ); reservoirViews.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_matrixModelResults, "MatrixModelResults", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_matrixModelResults, "MatrixModelResults", "" ); m_matrixModelResults.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_fractureModelResults, "FractureModelResults", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_fractureModelResults, "FractureModelResults", "" ); m_fractureModelResults.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitField( &m_flipXAxis, "FlipXAxis", false, "Flip X Axis", "", "", "" ); - CAF_PDM_InitField( &m_flipYAxis, "FlipYAxis", false, "Flip Y Axis", "", "", "" ); + CAF_PDM_InitField( &m_flipXAxis, "FlipXAxis", false, "Flip X Axis" ); + CAF_PDM_InitField( &m_flipYAxis, "FlipYAxis", false, "Flip Y Axis" ); - CAF_PDM_InitFieldNoDefault( &m_filesContainingFaults_OBSOLETE, "CachedFileNamesContainingFaults", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_filesContainingFaults_OBSOLETE, "CachedFileNamesContainingFaults", "" ); m_filesContainingFaults_OBSOLETE.uiCapability()->setUiHidden( true ); m_filesContainingFaults_OBSOLETE.xmlCapability()->disableIO(); - CAF_PDM_InitFieldNoDefault( &m_contourMapCollection, "ContourMaps", "2d Contour Maps", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_contourMapCollection, "ContourMaps", "2d Contour Maps" ); m_contourMapCollection = new RimEclipseContourMapViewCollection; m_contourMapCollection.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_inputPropertyCollection, "InputPropertyCollection", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_inputPropertyCollection, "InputPropertyCollection", "" ); m_inputPropertyCollection = new RimEclipseInputPropertyCollection; m_inputPropertyCollection->parentField()->uiCapability()->setUiTreeHidden( true ); + CAF_PDM_InitFieldNoDefault( &m_resultAddressCollections, "ResultAddressCollections", "Result Addresses" ); + m_resultAddressCollections.uiCapability()->setUiHidden( true ); + m_resultAddressCollections.uiCapability()->setUiTreeHidden( true ); + m_resultAddressCollections.xmlCapability()->disableIO(); + // Init m_matrixModelResults = new RimReservoirCellResultsStorage; @@ -137,7 +146,7 @@ RimEclipseCase::RimEclipseCase() //-------------------------------------------------------------------------------------------------- RimEclipseCase::~RimEclipseCase() { - reservoirViews.deleteAllChildObjects(); + reservoirViews.deleteChildren(); delete m_matrixModelResults(); delete m_fractureModelResults(); @@ -298,7 +307,7 @@ RimEclipseView* RimEclipseCase::createAndAddReservoirView() auto prefs = RiaPreferences::current(); if ( prefs->loadAndShowSoil ) { - rimEclipseView->cellResult()->setResultVariable( "SOIL" ); + rimEclipseView->cellResult()->setResultVariable( RiaResultNames::soil() ); } rimEclipseView->faultCollection()->showFaultCollection = prefs->enableFaultsByDefault(); @@ -559,27 +568,67 @@ void RimEclipseCase::updateFormationNamesData() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEclipseCase::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/ ) +void RimEclipseCase::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName ) { - std::vector children; - reservoirViews.childObjects( &children ); + if ( uiConfigName == "MainWindow.ProjectTree" ) + { + std::vector children; + reservoirViews.children( &children ); - for ( auto child : children ) - uiTreeOrdering.add( child ); + for ( auto child : children ) + uiTreeOrdering.add( child ); - if ( !m_2dIntersectionViewCollection->views().empty() ) - { - uiTreeOrdering.add( &m_2dIntersectionViewCollection ); - } + if ( !m_2dIntersectionViewCollection->views().empty() ) + { + uiTreeOrdering.add( &m_2dIntersectionViewCollection ); + } - if ( !m_contourMapCollection->views().empty() ) + if ( !m_contourMapCollection->views().empty() ) + { + uiTreeOrdering.add( &m_contourMapCollection ); + } + } + else if ( uiConfigName == "MainWindow.DataSources" ) { - uiTreeOrdering.add( &m_contourMapCollection ); + if ( m_resultAddressCollections.empty() ) buildChildNodes(); + uiTreeOrdering.add( &m_resultAddressCollections ); } uiTreeOrdering.skipRemainingChildren( true ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseCase::buildChildNodes() +{ + m_resultAddressCollections.deleteChildren(); + + std::vector resultTypes = { RiaDefines::ResultCatType::STATIC_NATIVE, + RiaDefines::ResultCatType::DYNAMIC_NATIVE, + RiaDefines::ResultCatType::INPUT_PROPERTY, + RiaDefines::ResultCatType::GENERATED }; + for ( auto resultType : resultTypes ) + { + auto resultAddressCollection = new RimEclipseResultAddressCollection; + resultAddressCollection->setResultType( resultType ); + QString name = caf::AppEnum::uiText( resultType ); + resultAddressCollection->setName( name ); + + auto cellResultData = results( RiaDefines::PorosityModelType::MATRIX_MODEL ); + if ( cellResultData ) + { + QStringList resultNames = cellResultData->resultNames( resultType ); + for ( auto resultName : resultNames ) + { + resultAddressCollection->addAddress( resultName, resultType, this ); + } + } + + m_resultAddressCollections.push_back( resultAddressCollection ); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.h b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.h index 1d9846e148..d7b08daa5e 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.h +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.h @@ -50,6 +50,7 @@ class RimEclipseInputPropertyCollection; class RimEclipseView; class RimIdenticalGridCaseGroup; class RimReservoirCellResultsStorage; +class RimEclipseResultAddressCollection; class RifReaderSettings; //================================================================================================== @@ -139,6 +140,7 @@ class RimEclipseCase : public RimCase private: void createTimeStepFormatString(); std::vector allSpecialViews() const override; + void buildChildNodes(); protected: caf::PdmField m_flipXAxis; @@ -156,6 +158,8 @@ class RimEclipseCase : public RimCase QString m_timeStepFormatString; std::map m_wellToColorMap; + caf::PdmChildArrayField m_resultAddressCollections; + caf::PdmChildField m_matrixModelResults; caf::PdmChildField m_fractureModelResults; diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCaseCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseCaseCollection.cpp index 524c453aec..ab21c3210c 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseCaseCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCaseCollection.cpp @@ -41,12 +41,12 @@ CAF_PDM_SOURCE_INIT( RimEclipseCaseCollection, "ResInsightAnalysisModels" ); //-------------------------------------------------------------------------------------------------- RimEclipseCaseCollection::RimEclipseCaseCollection( void ) { - CAF_PDM_InitObject( "Grid Models", ":/Cases16x16.png", "", "" ); + CAF_PDM_InitObject( "Grid Models", ":/Cases16x16.png" ); - CAF_PDM_InitFieldNoDefault( &cases, "Reservoirs", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &cases, "Reservoirs", "" ); cases.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &caseGroups, "CaseGroups", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &caseGroups, "CaseGroups", "" ); caseGroups.uiCapability()->setUiTreeHidden( true ); m_gridCollection = new RigGridManager; @@ -67,8 +67,8 @@ void RimEclipseCaseCollection::close() { m_gridCollection->clear(); - cases.deleteAllChildObjects(); - caseGroups.deleteAllChildObjects(); + cases.deleteChildren(); + caseGroups.deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -109,7 +109,7 @@ void RimEclipseCaseCollection::removeCaseFromAllGroups( RimEclipseCase* reservoi cg->removeCase( reservoir ); } - cases().removeChildObject( reservoir ); + cases().removeChild( reservoir ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCaseTools.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseCaseTools.cpp new file mode 100644 index 0000000000..2c8ee8740a --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCaseTools.cpp @@ -0,0 +1,55 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimEclipseCaseTools.h" + +#include "RimEclipseResultCase.h" +#include "RimProject.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimEclipseCaseTools::eclipseCases() +{ + if ( RimProject::current() ) + { + return RimProject::current()->eclipseCases(); + } + + return {}; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimEclipseCaseTools::eclipseResultCases() +{ + std::vector resultCases; + + auto eclipseCases = RimEclipseCaseTools::eclipseCases(); + for ( auto ec : eclipseCases ) + { + auto resultCase = dynamic_cast( ec ); + if ( resultCase != nullptr ) + { + resultCases.push_back( resultCase ); + } + } + + return resultCases; +} diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCaseTools.h b/ApplicationLibCode/ProjectDataModel/RimEclipseCaseTools.h new file mode 100644 index 0000000000..751460bb4b --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCaseTools.h @@ -0,0 +1,34 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include + +class RimEclipseCase; +class RimEclipseResultCase; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +class RimEclipseCaseTools +{ +public: + static std::vector eclipseCases(); + static std::vector eclipseResultCases(); +}; diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCellColors.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseCellColors.cpp index 2073a237ae..cc09ddac0f 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseCellColors.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCellColors.cpp @@ -58,15 +58,15 @@ RimEclipseCellColors::RimEclipseCellColors() "CellColors", "Eclipse Cell Colors class" ); - CAF_PDM_InitFieldNoDefault( &obsoleteField_legendConfig, "LegendDefinition", "Color Legend", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &obsoleteField_legendConfig, "LegendDefinition", "Color Legend" ); this->obsoleteField_legendConfig.xmlCapability()->setIOWritable( false ); - CAF_PDM_InitFieldNoDefault( &m_legendConfigData, "ResultVarLegendDefinitionList", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_legendConfigData, "ResultVarLegendDefinitionList", "" ); - CAF_PDM_InitFieldNoDefault( &m_ternaryLegendConfig, "TernaryLegendDefinition", "Ternary Color Legend", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_ternaryLegendConfig, "TernaryLegendDefinition", "Ternary Color Legend" ); this->m_ternaryLegendConfig = new RimTernaryLegendConfig(); - CAF_PDM_InitFieldNoDefault( &m_legendConfigPtrField, "LegendDefinitionPtrField", "Color Legend PtrField", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_legendConfigPtrField, "LegendDefinitionPtrField", "Color Legend PtrField" ); // Make sure we have a created legend for the default/undefined result variable changeLegendConfig( this->resultVariable() ); @@ -81,7 +81,7 @@ RimEclipseCellColors::~RimEclipseCellColors() { CVF_ASSERT( obsoleteField_legendConfig() == nullptr ); - m_legendConfigData.deleteAllChildObjects(); + m_legendConfigData.deleteChildren(); delete m_ternaryLegendConfig(); } @@ -153,17 +153,14 @@ void RimEclipseCellColors::changeLegendConfig( QString resultVarNameOfNewLegend this->m_useDiscreteLogLevels, this->hasCategoryResult() ); + newLegend->changed.connect( this, &RimEclipseCellColors::onLegendConfigChanged ); + m_legendConfigData.push_back( newLegend ); this->m_legendConfigPtrField = newLegend; } } } - - for ( auto legendConfig : m_legendConfigData ) - { - legendConfig->changed.connect( this, &RimEclipseCellColors::onLegendConfigChanged ); - } } //-------------------------------------------------------------------------------------------------- @@ -181,43 +178,10 @@ RimRegularLegendConfig* RimEclipseCellColors::createLegendForResult( const QStri bool useDiscreteLogLevels, bool isCategoryResult ) { - bool useLog = RiaResultNames::isLogarithmicResult( resultName ); + auto* newLegend = new RimRegularLegendConfig; + newLegend->resultVariableName = resultName; - RimRegularLegendConfig::ColorRangesType colorRangeType = RimRegularLegendConfig::ColorRangesType::UNDEFINED; - if ( isCategoryResult ) - { - colorRangeType = RimRegularLegendConfig::ColorRangesType::CATEGORY; - } - else if ( resultName == "SWAT" ) - { - colorRangeType = RimRegularLegendConfig::ColorRangesType::OPPOSITE_NORMAL; - } - - RimRegularLegendConfig* newLegend = new RimRegularLegendConfig; - newLegend->resultVariableName = resultName; - - if ( useLog ) - { - if ( useDiscreteLogLevels ) - newLegend->setMappingMode( RimRegularLegendConfig::MappingType::LOG10_DISCRETE ); - else - newLegend->setMappingMode( RimRegularLegendConfig::MappingType::LOG10_CONTINUOUS ); - - newLegend->setTickNumberFormat( RiaNumberFormat::NumberFormatType::AUTO ); - newLegend->setRangeMode( RimLegendConfig::RangeModeType::USER_DEFINED ); - newLegend->resetUserDefinedValues(); - } - - if ( colorRangeType != RimRegularLegendConfig::ColorRangesType::UNDEFINED ) - { - RimColorLegend* colorLegend = RimRegularLegendConfig::mapToColorLegend( colorRangeType ); - if ( isCategoryResult ) - { - newLegend->setMappingMode( RimRegularLegendConfig::MappingType::CATEGORY_INTEGER ); - } - - newLegend->setColorLegend( colorLegend ); - } + newLegend->setDefaultConfigForResultName( resultName, useDiscreteLogLevels, isCategoryResult ); return newLegend; } @@ -242,7 +206,9 @@ void RimEclipseCellColors::initAfterRead() // set to nullptr before pushing into container obsoleteField_legendConfig = nullptr; + obsoleteLegend->changed.connect( this, &RimEclipseCellColors::onLegendConfigChanged ); m_legendConfigData.push_back( obsoleteLegend ); + m_legendConfigPtrField = obsoleteLegend; } diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapProjection.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapProjection.cpp index fafe369fc9..9fedcb3128 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapProjection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapProjection.cpp @@ -62,10 +62,10 @@ RimEclipseContourMapProjection::RimEclipseContourMapProjection() , m_kLayers( 0u ) , m_useActiveCellInfo( true ) { - CAF_PDM_InitObject( "RimEclipseContourMapProjection", ":/2DMapProjection16x16.png", "", "" ); + CAF_PDM_InitObject( "RimEclipseContourMapProjection", ":/2DMapProjection16x16.png" ); - CAF_PDM_InitField( &m_weightByParameter, "WeightByParameter", false, "Weight by Result Parameter", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_weightingResult, "WeightingResult", "", "", "", "" ); + CAF_PDM_InitField( &m_weightByParameter, "WeightByParameter", false, "Weight by Result Parameter" ); + CAF_PDM_InitFieldNoDefault( &m_weightingResult, "WeightingResult", "" ); m_weightingResult.uiCapability()->setUiTreeHidden( true ); m_weightingResult.uiCapability()->setUiTreeChildrenHidden( true ); m_weightingResult = new RimEclipseResultDefinition; @@ -210,12 +210,12 @@ std::vector RimEclipseContourMapProjection::generateResults( int timeSte if ( m_resultAggregation == RESULTS_OIL_COLUMN || m_resultAggregation == RESULTS_HC_COLUMN ) { gridCellResult->ensureKnownResultLoaded( - RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "SOIL" ) ); + RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, RiaResultNames::soil() ) ); } if ( m_resultAggregation == RESULTS_GAS_COLUMN || m_resultAggregation == RESULTS_HC_COLUMN ) { gridCellResult->ensureKnownResultLoaded( - RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "SGAS" ) ); + RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, RiaResultNames::sgas() ) ); } gridResultValues = calculateColumnResult( m_resultAggregation() ); } @@ -306,7 +306,8 @@ std::vector RimEclipseContourMapProjection::calculateColumnResult( Resul if ( resultAggregation == RESULTS_OIL_COLUMN || resultAggregation == RESULTS_HC_COLUMN ) { const std::vector& soilResults = - resultData->cellScalarResults( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "SOIL" ), + resultData->cellScalarResults( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, + RiaResultNames::soil() ), timeStep ); for ( size_t cellResultIdx = 0; cellResultIdx < resultValues.size(); ++cellResultIdx ) { @@ -316,12 +317,13 @@ std::vector RimEclipseContourMapProjection::calculateColumnResult( Resul if ( resultAggregation == RESULTS_GAS_COLUMN || resultAggregation == RESULTS_HC_COLUMN ) { - bool hasGasResult = - resultData->hasResultEntry( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "SGAS" ) ); + bool hasGasResult = resultData->hasResultEntry( + RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, RiaResultNames::sgas() ) ); if ( hasGasResult ) { const std::vector& sgasResults = - resultData->cellScalarResults( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "SGAS" ), + resultData->cellScalarResults( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, + RiaResultNames::sgas() ), timeStep ); for ( size_t cellResultIdx = 0; cellResultIdx < resultValues.size(); ++cellResultIdx ) { diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapProjection.h b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapProjection.h index 9bbedbbca8..8cb131ed85 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapProjection.h +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapProjection.h @@ -20,7 +20,6 @@ #include "RimCheckableNamedObject.h" #include "RimContourMapProjection.h" -#include "RimRegularLegendConfig.h" #include "cafDisplayCoordTransform.h" #include "cafPdmChildField.h" diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapView.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapView.cpp index 56c36a678f..08069213de 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapView.cpp @@ -60,11 +60,11 @@ RimEclipseContourMapView::RimEclipseContourMapView() "EclipseContourMap", "A contour map for Eclipse cases" ); - CAF_PDM_InitFieldNoDefault( &m_contourMapProjection, "ContourMapProjection", "Contour Map Projection", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_contourMapProjection, "ContourMapProjection", "Contour Map Projection" ); m_contourMapProjection = new RimEclipseContourMapProjection(); - CAF_PDM_InitField( &m_showAxisLines, "ShowAxisLines", true, "Show Axis Lines", "", "", "" ); - CAF_PDM_InitField( &m_showScaleLegend, "ShowScaleLegend", true, "Show Scale Legend", "", "", "" ); + CAF_PDM_InitField( &m_showAxisLines, "ShowAxisLines", true, "Show Axis Lines" ); + CAF_PDM_InitField( &m_showScaleLegend, "ShowScaleLegend", true, "Show Scale Legend" ); setFaultVisParameters(); diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapViewCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapViewCollection.cpp index 7f17166296..d806f069be 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapViewCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapViewCollection.cpp @@ -10,9 +10,9 @@ CAF_PDM_SOURCE_INIT( RimEclipseContourMapViewCollection, "Eclipse2dViewCollectio //-------------------------------------------------------------------------------------------------- RimEclipseContourMapViewCollection::RimEclipseContourMapViewCollection() { - CAF_PDM_InitObject( "Contour Maps", ":/2DMaps16x16.png", "", "" ); + CAF_PDM_InitObject( "Contour Maps", ":/2DMaps16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_contourMapViews, "EclipseViews", "Contour Maps", ":/CrossSection16x16.png", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_contourMapViews, "EclipseViews", "Contour Maps", ":/CrossSection16x16.png" ); m_contourMapViews.uiCapability()->setUiTreeHidden( true ); } @@ -28,7 +28,7 @@ RimEclipseContourMapViewCollection::~RimEclipseContourMapViewCollection() //-------------------------------------------------------------------------------------------------- std::vector RimEclipseContourMapViewCollection::views() { - return m_contourMapViews.childObjects(); + return m_contourMapViews.children(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseFaultColors.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseFaultColors.cpp index 5659ef0dcd..d770d51fd2 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseFaultColors.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseFaultColors.cpp @@ -35,17 +35,12 @@ CAF_PDM_SOURCE_INIT( RimEclipseFaultColors, "RimFaultResultSlot" ); //-------------------------------------------------------------------------------------------------- RimEclipseFaultColors::RimEclipseFaultColors() { - CAF_PDM_InitObject( "Fault Result", ":/draw_style_faults_24x24.png", "", "" ); + CAF_PDM_InitObject( "Fault Result", ":/draw_style_faults_24x24.png" ); - CAF_PDM_InitField( &showCustomFaultResult, "ShowCustomFaultResult", false, "Show Custom Fault Result", "", "", "" ); + CAF_PDM_InitField( &showCustomFaultResult, "ShowCustomFaultResult", false, "Show Custom Fault Result" ); showCustomFaultResult.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_customFaultResultColors, - "CustomResultSlot", - "Custom Fault Result", - ":/CellResult.png", - "", - "" ); + CAF_PDM_InitFieldNoDefault( &m_customFaultResultColors, "CustomResultSlot", "Custom Fault Result", ":/CellResult.png" ); m_customFaultResultColors = new RimEclipseCellColors(); m_customFaultResultColors.uiCapability()->setUiTreeHidden( true ); m_customFaultResultColors->enableDeltaResults( true ); diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseGeometrySelectionItem.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseGeometrySelectionItem.cpp index 10390aa13f..eaf7f83c60 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseGeometrySelectionItem.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseGeometrySelectionItem.cpp @@ -35,17 +35,12 @@ CAF_PDM_SOURCE_INIT( RimEclipseGeometrySelectionItem, "EclipseGeometrySelectionI //-------------------------------------------------------------------------------------------------- RimEclipseGeometrySelectionItem::RimEclipseGeometrySelectionItem() { - CAF_PDM_InitObject( "Eclipse Geometry Selection Item", "", "", "" ); - - CAF_PDM_InitFieldNoDefault( &m_eclipseCase, "EclipseCase", "Eclipse Case", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_gridIndex, "GridIndex", "Grid Index", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_cellIndex, "CellIndex", "Cell Index", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_localIntersectionPointInDisplay, - "LocalIntersectionPoint", - "local Intersection Point", - "", - "", - "" ); + CAF_PDM_InitObject( "Eclipse Geometry Selection Item" ); + + CAF_PDM_InitFieldNoDefault( &m_eclipseCase, "EclipseCase", "Eclipse Case" ); + CAF_PDM_InitFieldNoDefault( &m_gridIndex, "GridIndex", "Grid Index" ); + CAF_PDM_InitFieldNoDefault( &m_cellIndex, "CellIndex", "Cell Index" ); + CAF_PDM_InitFieldNoDefault( &m_localIntersectionPointInDisplay, "LocalIntersectionPoint", "local Intersection Point" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseInputCase.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseInputCase.cpp index 5641d7641c..07ede4cb78 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseInputCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseInputCase.cpp @@ -54,9 +54,9 @@ CAF_PDM_SOURCE_INIT( RimEclipseInputCase, "RimInputReservoir" ); RimEclipseInputCase::RimEclipseInputCase() : RimEclipseCase() { - CAF_PDM_InitObject( "RimInputCase", ":/EclipseInput48x48.png", "", "" ); + CAF_PDM_InitObject( "RimInputCase", ":/EclipseInput48x48.png" ); - CAF_PDM_InitFieldNoDefault( &m_additionalFiles, "AdditionalFileNamesProxy", "Additional Files", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_additionalFiles, "AdditionalFileNamesProxy", "Additional Files" ); m_additionalFiles.registerGetMethod( this, &RimEclipseInputCase::additionalFiles ); m_additionalFiles.uiCapability()->setUiReadOnly( true ); m_additionalFiles.xmlCapability()->setIOWritable( false ); @@ -322,27 +322,6 @@ QString RimEclipseInputCase::locationOnDisc() const return fi.absolutePath(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimEclipseInputCase::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) -{ - // bool foundFile = false; - // std::vector searchedPaths; - - // m_gridFileName = RimTools::relocateFile( m_gridFileName().path(), newProjectPath, oldProjectPath, &foundFile, - // &searchedPaths ); - - // for ( RimEclipseInputProperty* inputProperty : m_inputPropertyCollection()->inputProperties() ) - //{ - // inputProperty->fileName = RimTools::relocateFile( inputProperty->fileName, - // newProjectPath, - // oldProjectPath, - // &foundFile, - // &searchedPaths ); - //} -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseInputCase.h b/ApplicationLibCode/ProjectDataModel/RimEclipseInputCase.h index 4d45c92067..20f97edb05 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseInputCase.h +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseInputCase.h @@ -55,8 +55,6 @@ class RimEclipseInputCase : public RimEclipseCase // Overrides from RimCase QString locationOnDisc() const override; - void updateFilePathsFromProjectPath( const QString& projectPath, const QString& oldProjectPath ) override; - void updateAdditionalFileFolder( const QString& newFolder ); protected: diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseInputProperty.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseInputProperty.cpp index cd1d110948..d1295659a3 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseInputProperty.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseInputProperty.cpp @@ -52,12 +52,12 @@ CAF_PDM_SOURCE_INIT( RimEclipseInputProperty, "RimInputProperty" ); //-------------------------------------------------------------------------------------------------- RimEclipseInputProperty::RimEclipseInputProperty() { - CAF_PDM_InitObject( "Input Property", ":/EclipseInput48x48.png", "", "" ); + CAF_PDM_InitObject( "Input Property", ":/EclipseInput48x48.png" ); - CAF_PDM_InitField( &resultName, "ResultName", QString(), "Result Name", "", "", "" ); - CAF_PDM_InitField( &eclipseKeyword, "EclipseKeyword", QString(), "Eclipse Keyword", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &fileName, "FileName", "Filename", "", "", "" ); - CAF_PDM_InitField( &resolvedState, "ResolvedState", (ResolveStateEnum)UNKNOWN, "Data State", "", "", "" ); + CAF_PDM_InitField( &resultName, "ResultName", QString(), "Result Name" ); + CAF_PDM_InitField( &eclipseKeyword, "EclipseKeyword", QString(), "Eclipse Keyword" ); + CAF_PDM_InitFieldNoDefault( &fileName, "FileName", "Filename" ); + CAF_PDM_InitField( &resolvedState, "ResolvedState", (ResolveStateEnum)UNKNOWN, "Data State" ); resolvedState.uiCapability()->setUiReadOnly( true ); resolvedState.xmlCapability()->disableIO(); diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseInputPropertyCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseInputPropertyCollection.cpp index 97d19a2db1..ce479cf7e4 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseInputPropertyCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseInputPropertyCollection.cpp @@ -31,9 +31,9 @@ CAF_PDM_SOURCE_INIT( RimEclipseInputPropertyCollection, "RimInputPropertyCollect //-------------------------------------------------------------------------------------------------- RimEclipseInputPropertyCollection::RimEclipseInputPropertyCollection() { - CAF_PDM_InitObject( "Input Properties", ":/EclipseInput48x48.png", "", "" ); + CAF_PDM_InitObject( "Input Properties", ":/EclipseInput48x48.png" ); - CAF_PDM_InitFieldNoDefault( &inputProperties, "InputProperties", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &inputProperties, "InputProperties", "" ); inputProperties.uiCapability()->setUiTreeHidden( true ); } @@ -42,7 +42,7 @@ RimEclipseInputPropertyCollection::RimEclipseInputPropertyCollection() //-------------------------------------------------------------------------------------------------- RimEclipseInputPropertyCollection::~RimEclipseInputPropertyCollection() { - inputProperties.deleteAllChildObjects(); + inputProperties.deleteChildren(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseResultAddress.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseResultAddress.cpp new file mode 100644 index 0000000000..062e94478f --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseResultAddress.cpp @@ -0,0 +1,115 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimEclipseResultAddress.h" + +#include "RimEclipseCase.h" +#include "RimEclipseCaseTools.h" + +CAF_PDM_SOURCE_INIT( RimEclipseResultAddress, "EclipseResultAddress" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseResultAddress::RimEclipseResultAddress() +{ + CAF_PDM_InitObject( "EclipseResultAddress", ":/DataVector.png", "", "" ); + + CAF_PDM_InitFieldNoDefault( &m_resultName, "ResultName", "Result Name" ); + m_resultName.uiCapability()->setUiReadOnly( true ); + + CAF_PDM_InitFieldNoDefault( &m_resultType, "ResultType", "Type" ); + m_resultType.uiCapability()->setUiReadOnly( true ); + + CAF_PDM_InitFieldNoDefault( &m_eclipseCase, "EclipseCase", "Eclipse Case" ); + m_eclipseCase.uiCapability()->setUiReadOnly( true ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseResultAddress::~RimEclipseResultAddress() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimEclipseResultAddress::resultName() const +{ + return m_resultName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseResultAddress::setResultName( const QString& resultName ) +{ + m_resultName = resultName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseResultAddress::setResultType( RiaDefines::ResultCatType val ) +{ + m_resultType = val; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaDefines::ResultCatType RimEclipseResultAddress::resultType() const +{ + return m_resultType(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseResultAddress::setEclipseCase( RimEclipseCase* eclipseCase ) +{ + m_eclipseCase = eclipseCase; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseCase* RimEclipseResultAddress::eclipseCase() const +{ + return m_eclipseCase; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimEclipseResultAddress::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) +{ + QList options; + + if ( fieldNeedingOptions == &m_eclipseCase ) + { + auto cases = RimEclipseCaseTools::eclipseCases(); + for ( auto* c : cases ) + { + options.push_back( caf::PdmOptionItemInfo( c->caseUserDescription(), c, false, c->uiIconProvider() ) ); + } + } + + return options; +} diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseResultAddress.h b/ApplicationLibCode/ProjectDataModel/RimEclipseResultAddress.h new file mode 100644 index 0000000000..30a2e8c1c7 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseResultAddress.h @@ -0,0 +1,53 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafPdmField.h" +#include "cafPdmObject.h" +#include "cafPdmPtrField.h" + +#include "RiaDefines.h" + +class RimEclipseCase; + +class RimEclipseResultAddress : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimEclipseResultAddress(); + ~RimEclipseResultAddress() override; + + void setResultName( const QString& resultName ); + QString resultName() const; + + void setResultType( RiaDefines::ResultCatType val ); + RiaDefines::ResultCatType resultType() const; + + void setEclipseCase( RimEclipseCase* eclipseCase ); + RimEclipseCase* eclipseCase() const; + +private: + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; + +private: + caf::PdmField m_resultName; + caf::PdmField> m_resultType; + caf::PdmPtrField m_eclipseCase; +}; diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseResultAddressCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseResultAddressCollection.cpp new file mode 100644 index 0000000000..eb9015c25b --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseResultAddressCollection.cpp @@ -0,0 +1,79 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimEclipseResultAddressCollection.h" + +#include "RimEclipseResultAddress.h" + +#include "cafPdmUiTreeOrdering.h" + +CAF_PDM_SOURCE_INIT( RimEclipseResultAddressCollection, "RimEclipseResultAddressCollection" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseResultAddressCollection::RimEclipseResultAddressCollection() +{ + CAF_PDM_InitObject( "Folder", ":/Folder.png", "", "" ); + + CAF_PDM_InitFieldNoDefault( &m_adresses, "Addresses", "Addresses" ); + m_adresses.uiCapability()->setUiTreeHidden( true ); + + CAF_PDM_InitFieldNoDefault( &m_resultType, "ResultType", "Type" ); + m_resultType.uiCapability()->setUiHidden( true ); + + nameField()->uiCapability()->setUiHidden( true ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseResultAddressCollection::~RimEclipseResultAddressCollection() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseResultAddressCollection::setResultType( RiaDefines::ResultCatType val ) +{ + m_resultType = val; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseResultAddressCollection::addAddress( const QString& resultName, + RiaDefines::ResultCatType resultType, + RimEclipseCase* eclipseCase ) +{ + auto addr = new RimEclipseResultAddress; + addr->setUiName( resultName ); + addr->setResultName( resultName ); + addr->setResultType( resultType ); + addr->setEclipseCase( eclipseCase ); + m_adresses.push_back( addr ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimEclipseResultAddressCollection::isEmpty() const +{ + return m_adresses.empty(); +} diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseResultAddressCollection.h b/ApplicationLibCode/ProjectDataModel/RimEclipseResultAddressCollection.h new file mode 100644 index 0000000000..feaacd5b49 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseResultAddressCollection.h @@ -0,0 +1,49 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// +#pragma once + +#include "RiaDefines.h" +#include "RimNamedObject.h" + +#include "cafPdmChildArrayField.h" +#include "cafPdmPtrField.h" + +#include + +class RimEclipseResultAddress; +class RimEclipseCase; + +class RimEclipseResultAddressCollection : public RimNamedObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimEclipseResultAddressCollection(); + ~RimEclipseResultAddressCollection() override; + + void setResultType( RiaDefines::ResultCatType val ); + + void addAddress( const QString& resultName, RiaDefines::ResultCatType resultType, RimEclipseCase* eclipseCase ); + + bool isEmpty() const; + +private: + caf::PdmChildArrayField m_adresses; + caf::PdmField> m_resultType; + caf::PdmPtrField m_eclipseCase; +}; diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.cpp index 47ddd6a334..a6f8b85b38 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.cpp @@ -33,6 +33,7 @@ #include "RifReaderEclipseOutput.h" #include "RifReaderEclipseRft.h" #include "RifReaderMockModel.h" +#include "RifReaderOpmRft.h" #include "RifReaderSettings.h" #include "RigCaseCellResultsData.h" @@ -68,15 +69,18 @@ CAF_PDM_SOURCE_INIT( RimEclipseResultCase, "EclipseCase" ); /// //-------------------------------------------------------------------------------------------------- RimEclipseResultCase::RimEclipseResultCase() - : RimEclipseCase() + : m_gridAndWellDataIsReadFromFile( false ) + , m_activeCellInfoIsReadFromFile( false ) + , m_useOpmRftReader( true ) + , m_rftDataIsReadFromFile( false ) { CAF_PDM_InitScriptableObject( "Eclipse Case", ":/Case48x48.png", "", "The Regular Eclipse Results Case" ); - CAF_PDM_InitFieldNoDefault( &m_unitSystem, "UnitSystem", "Unit System", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_unitSystem, "UnitSystem", "Unit System" ); m_unitSystem.registerGetMethod( RimProject::current(), &RimProject::commonUnitSystemForAllCases ); m_unitSystem.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitFieldNoDefault( &m_flowDiagSolutions, "FlowDiagSolutions", "Flow Diagnostics Solutions", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_flowDiagSolutions, "FlowDiagSolutions", "Flow Diagnostics Solutions" ); m_flowDiagSolutions.uiCapability()->setUiTreeHidden( true ); m_flowDiagSolutions.uiCapability()->setUiTreeChildrenHidden( true ); @@ -85,14 +89,11 @@ RimEclipseResultCase::RimEclipseResultCase() m_flipYAxis.xmlCapability()->setIOWritable( true ); // flipYAxis.uiCapability()->setUiHidden(true); - CAF_PDM_InitFieldNoDefault( &m_sourSimFileName, "SourSimFileName", "SourSim File Name", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_sourSimFileName, "SourSimFileName", "SourSim File Name" ); m_sourSimFileName.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); #ifndef USE_HDF5 m_sourSimFileName.uiCapability()->setUiHidden( true ); #endif - - m_activeCellInfoIsReadFromFile = false; - m_gridAndWellDataIsReadFromFile = false; } //-------------------------------------------------------------------------------------------------- @@ -205,24 +206,16 @@ bool RimEclipseResultCase::importGridAndResultMetaData( bool showTimeStepFilter m_gridAndWellDataIsReadFromFile = true; m_activeCellInfoIsReadFromFile = true; - QFileInfo eclipseCaseFileInfo( gridFileName() ); - QString rftFileName = eclipseCaseFileInfo.path() + "/" + eclipseCaseFileInfo.completeBaseName() + ".RFT"; - QFileInfo rftFileInfo( rftFileName ); - - if ( rftFileInfo.exists() ) - { - RiaLogging::info( QString( "RFT file found" ) ); - m_readerEclipseRft = new RifReaderEclipseRft( rftFileInfo.filePath() ); - } + ensureRftDataIsImported(); - if ( m_flowDiagSolutions.size() == 0 ) + if ( m_flowDiagSolutions.empty() ) { m_flowDiagSolutions.push_back( new RimFlowDiagSolution() ); } if ( !m_sourSimFileName().path().isEmpty() ) { - RifReaderEclipseOutput* outReader = dynamic_cast( readerInterface.p() ); + auto* outReader = dynamic_cast( readerInterface.p() ); outReader->setHdf5FileName( m_sourSimFileName().path() ); } @@ -336,13 +329,13 @@ void RimEclipseResultCase::loadAndUpdateSourSimData() // Deselect SourSimRL cell results for ( Rim3dView* view : views() ) { - RimEclipseView* eclipseView = dynamic_cast( view ); + auto* eclipseView = dynamic_cast( view ); if ( eclipseView != nullptr ) { if ( eclipseView->cellResult()->resultType() == RiaDefines::ResultCatType::SOURSIMRL ) { eclipseView->cellResult()->setResultType( RiaDefines::ResultCatType::DYNAMIC_NATIVE ); - eclipseView->cellResult()->setResultVariable( "SOIL" ); + eclipseView->cellResult()->setResultVariable( RiaResultNames::soil() ); eclipseView->loadDataAndUpdate(); } } @@ -350,6 +343,34 @@ void RimEclipseResultCase::loadAndUpdateSourSimData() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseResultCase::ensureRftDataIsImported() +{ + if ( m_rftDataIsReadFromFile ) return; + + QFileInfo eclipseCaseFileInfo( gridFileName() ); + QString rftFileName = eclipseCaseFileInfo.path() + "/" + eclipseCaseFileInfo.completeBaseName() + ".RFT"; + QFileInfo rftFileInfo( rftFileName ); + + if ( rftFileInfo.exists() ) + { + RiaLogging::info( QString( "RFT file found" ) ); + + if ( m_useOpmRftReader ) + { + m_readerOpmRft = new RifReaderOpmRft( rftFileInfo.filePath() ); + } + else + { + m_readerEclipseRft = new RifReaderEclipseRft( rftFileInfo.filePath() ); + } + } + + m_rftDataIsReadFromFile = true; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -466,8 +487,8 @@ cvf::ref RimEclipseResultCase::createMockModel( QString mode //-------------------------------------------------------------------------------------------------- RimEclipseResultCase::~RimEclipseResultCase() { - reservoirViews.deleteAllChildObjects(); - m_flowDiagSolutions.deleteAllChildObjects(); + reservoirViews.deleteChildren(); + m_flowDiagSolutions.deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -487,41 +508,12 @@ void RimEclipseResultCase::readGridDimensions( std::vector>& gr RifEclipseOutputFileTools::readGridDimensions( gridFileName(), gridDimensions ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimEclipseResultCase::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) -{ - // bool foundFile = false; - // std::vector searchedPaths; - - // Update filename and folder paths when opening project from a different file location - // caseFileName = RimTools::relocateFile( caseFileName(), newProjectPath, oldProjectPath, &foundFile, - // &searchedPaths ); - - // std::vector relocatedFaultFiles; - // const std::vector& orgFilesContainingFaults = filesContainingFaults(); - // for ( auto faultFileName : orgFilesContainingFaults ) - // { - // QString relocatedFaultFile = - // RimTools::relocateFile( faultFileName, newProjectPath, oldProjectPath, &foundFile, &searchedPaths ); - // relocatedFaultFiles.push_back( relocatedFaultFile ); - // } - // - // setFilesContainingFaults( relocatedFaultFiles ); - -#if 0 // Output the search path for debugging - for (size_t i = 0; i < searchedPaths.size(); ++i) - qDebug() << searchedPaths[i]; -#endif -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RimFlowDiagSolution* RimEclipseResultCase::defaultFlowDiagSolution() { - if ( m_flowDiagSolutions.size() > 0 ) + if ( !m_flowDiagSolutions.empty() ) { return m_flowDiagSolutions[0]; } @@ -554,8 +546,12 @@ RigFlowDiagSolverInterface* RimEclipseResultCase::flowDiagSolverInterface() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RifReaderEclipseRft* RimEclipseResultCase::rftReader() +RifReaderRftInterface* RimEclipseResultCase::rftReader() { + ensureRftDataIsImported(); + + if ( m_useOpmRftReader ) return m_readerOpmRft.p(); + return m_readerEclipseRft.p(); } @@ -638,7 +634,7 @@ void RimEclipseResultCase::defineEditorAttribute( const caf::PdmFieldHandle* fie { if ( field == &m_sourSimFileName ) { - caf::PdmUiFilePathEditorAttribute* myAttr = dynamic_cast( attribute ); + auto* myAttr = dynamic_cast( attribute ); if ( myAttr ) { myAttr->m_fileSelectionFilter = "SourSim (*.sourres)"; diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.h b/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.h index cc3bdfc319..0c1b77bc89 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.h +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.h @@ -25,9 +25,11 @@ #include "RimEclipseCase.h" #include "cafFilePath.h" -#include +#include "cafPdmProxyValueField.h" +class RifReaderRftInterface; class RifReaderEclipseRft; +class RifReaderOpmRft; class RifReaderInterface; class RigFlowDiagSolverInterface; class RigMainGrid; @@ -63,15 +65,13 @@ class RimEclipseResultCase : public RimEclipseCase caf::AppEnum unitSystem(); - // Overrides from RimCase QString locationOnDisc() const override; - void updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) override; RimFlowDiagSolution* defaultFlowDiagSolution(); std::vector flowDiagSolutions(); RigFlowDiagSolverInterface* flowDiagSolverInterface(); - RifReaderEclipseRft* rftReader(); + RifReaderRftInterface* rftReader(); protected: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; @@ -81,6 +81,7 @@ class RimEclipseResultCase : public RimEclipseCase private: void loadAndUpdateSourSimData(); + void ensureRftDataIsImported(); private: cvf::ref createMockModel( QString modelName ); @@ -90,6 +91,7 @@ class RimEclipseResultCase : public RimEclipseCase cvf::ref m_flowDagSolverInterface; cvf::ref m_readerEclipseRft; + cvf::ref m_readerOpmRft; // Fields: caf::PdmProxyValueField> m_unitSystem; @@ -98,4 +100,6 @@ class RimEclipseResultCase : public RimEclipseCase bool m_gridAndWellDataIsReadFromFile; bool m_activeCellInfoIsReadFromFile; + bool m_useOpmRftReader; + bool m_rftDataIsReadFromFile; }; diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseResultDefinition.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseResultDefinition.cpp index ae47bac7df..32a6ee546e 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseResultDefinition.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseResultDefinition.cpp @@ -61,6 +61,7 @@ #include "RimIntersectionResultDefinition.h" #include "RimPlotCurve.h" #include "RimProject.h" +#include "RimRegularLegendConfig.h" #include "RimReservoirCellResultsStorage.h" #include "RimSimWellInView.h" #include "RimSimWellInViewCollection.h" @@ -108,105 +109,87 @@ RimEclipseResultDefinition::RimEclipseResultDefinition( caf::PdmUiItemInfo::Labe { CAF_PDM_InitScriptableObjectWithNameAndComment( "Result Definition", "", "", "", "EclipseResult", "An eclipse result definition" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_resultType, "ResultType", "Type", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_resultType, "ResultType", "Type" ); m_resultType.uiCapability()->setUiHidden( true ); - CAF_PDM_InitScriptableFieldNoDefault( &m_porosityModel, "PorosityModelType", "Porosity", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_porosityModel, "PorosityModelType", "Porosity" ); m_porosityModel.uiCapability()->setUiHidden( true ); - CAF_PDM_InitScriptableField( &m_resultVariable, - "ResultVariable", - RiaResultNames::undefinedResultName(), - "Variable", - "", - "", - "" ); + CAF_PDM_InitScriptableField( &m_resultVariable, "ResultVariable", RiaResultNames::undefinedResultName(), "Variable" ); m_resultVariable.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_flowSolution, "FlowDiagSolution", "Solution", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_flowSolution, "FlowDiagSolution", "Solution" ); m_flowSolution.uiCapability()->setUiHidden( true ); CAF_PDM_InitField( &m_timeLapseBaseTimestep, "TimeLapseBaseTimeStep", RigEclipseResultAddress::noTimeLapseValue(), - "Base Time Step", - "", - "", - "" ); + "Base Time Step" ); - CAF_PDM_InitFieldNoDefault( &m_differenceCase, "DifferenceCase", "Difference Case", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_differenceCase, "DifferenceCase", "Difference Case" ); - CAF_PDM_InitField( &m_divideByCellFaceArea, "DivideByCellFaceArea", false, "Divide By Area", "", "", "" ); + CAF_PDM_InitField( &m_divideByCellFaceArea, "DivideByCellFaceArea", false, "Divide By Area" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_selectedInjectorTracers, "SelectedInjectorTracers", "Injector Tracers", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_selectedInjectorTracers, "SelectedInjectorTracers", "Injector Tracers" ); m_selectedInjectorTracers.uiCapability()->setUiHidden( true ); - CAF_PDM_InitScriptableFieldNoDefault( &m_selectedProducerTracers, "SelectedProducerTracers", "Producer Tracers", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_selectedProducerTracers, "SelectedProducerTracers", "Producer Tracers" ); m_selectedProducerTracers.uiCapability()->setUiHidden( true ); - CAF_PDM_InitScriptableFieldNoDefault( &m_selectedSouringTracers, "SelectedSouringTracers", "Tracers", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_selectedSouringTracers, "SelectedSouringTracers", "Tracers" ); m_selectedSouringTracers.uiCapability()->setUiHidden( true ); - CAF_PDM_InitScriptableFieldNoDefault( &m_flowTracerSelectionMode, "FlowTracerSelectionMode", "Tracers", "", "", "" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_phaseSelection, "PhaseSelection", "Phases", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_flowTracerSelectionMode, "FlowTracerSelectionMode", "Tracers" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_phaseSelection, "PhaseSelection", "Phases" ); m_phaseSelection.uiCapability()->setUiLabelPosition( m_labelPosition ); CAF_PDM_InitScriptableField( &m_showOnlyVisibleCategoriesInLegend, "ShowOnlyVisibleCategoriesInLegend", true, - "Show Only Visible Categories In Legend", - "", - "", - "" ); + "Show Only Visible Categories In Legend" ); // Ui only fields - CAF_PDM_InitFieldNoDefault( &m_resultTypeUiField, "MResultType", "Type", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_resultTypeUiField, "MResultType", "Type" ); m_resultTypeUiField.xmlCapability()->disableIO(); m_resultTypeUiField.uiCapability()->setUiLabelPosition( m_labelPosition ); - CAF_PDM_InitFieldNoDefault( &m_porosityModelUiField, "MPorosityModelType", "Porosity", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_porosityModelUiField, "MPorosityModelType", "Porosity" ); m_porosityModelUiField.xmlCapability()->disableIO(); m_porosityModelUiField.uiCapability()->setUiLabelPosition( m_labelPosition ); - CAF_PDM_InitField( &m_resultVariableUiField, - "MResultVariable", - RiaResultNames::undefinedResultName(), - "Result Property", - "", - "", - "" ); + CAF_PDM_InitField( &m_resultVariableUiField, "MResultVariable", RiaResultNames::undefinedResultName(), "Result Property" ); m_resultVariableUiField.xmlCapability()->disableIO(); m_resultVariableUiField.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() ); m_resultVariableUiField.uiCapability()->setUiLabelPosition( m_labelPosition ); - CAF_PDM_InitFieldNoDefault( &m_inputPropertyFileName, "InputPropertyFileName", "File Name", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_inputPropertyFileName, "InputPropertyFileName", "File Name" ); m_inputPropertyFileName.xmlCapability()->disableIO(); m_inputPropertyFileName.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitFieldNoDefault( &m_flowSolutionUiField, "MFlowDiagSolution", "Solution", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_flowSolutionUiField, "MFlowDiagSolution", "Solution" ); m_flowSolutionUiField.xmlCapability()->disableIO(); m_flowSolutionUiField.uiCapability()->setUiHidden( true ); // For now since there are only one to choose from - CAF_PDM_InitField( &m_syncInjectorToProducerSelection, "MSyncSelectedInjProd", false, "Add Communicators ->", "", "", "" ); + CAF_PDM_InitField( &m_syncInjectorToProducerSelection, "MSyncSelectedInjProd", false, "Add Communicators ->" ); m_syncInjectorToProducerSelection.uiCapability()->setUiEditorTypeName( caf::PdmUiToolButtonEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_syncProducerToInjectorSelection, "MSyncSelectedProdInj", false, "<- Add Communicators", "", "", "" ); + CAF_PDM_InitField( &m_syncProducerToInjectorSelection, "MSyncSelectedProdInj", false, "<- Add Communicators" ); m_syncProducerToInjectorSelection.uiCapability()->setUiEditorTypeName( caf::PdmUiToolButtonEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_selectedInjectorTracersUiField, "MSelectedInjectorTracers", "Injector Tracers", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_selectedInjectorTracersUiField, "MSelectedInjectorTracers", "Injector Tracers" ); m_selectedInjectorTracersUiField.xmlCapability()->disableIO(); m_selectedInjectorTracersUiField.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); m_selectedInjectorTracersUiField.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); - CAF_PDM_InitFieldNoDefault( &m_selectedProducerTracersUiField, "MSelectedProducerTracers", "Producer Tracers", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_selectedProducerTracersUiField, "MSelectedProducerTracers", "Producer Tracers" ); m_selectedProducerTracersUiField.xmlCapability()->disableIO(); m_selectedProducerTracersUiField.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); m_selectedProducerTracersUiField.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); - CAF_PDM_InitFieldNoDefault( &m_selectedSouringTracersUiField, "MSelectedSouringTracers", "Tracers", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_selectedSouringTracersUiField, "MSelectedSouringTracers", "Tracers" ); m_selectedSouringTracersUiField.xmlCapability()->disableIO(); m_selectedSouringTracersUiField.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() ); m_selectedSouringTracersUiField.uiCapability()->setUiLabelPosition( m_labelPosition ); @@ -496,6 +479,7 @@ void RimEclipseResultDefinition::updateAnyFieldHasChanged() this->firstAncestorOrThisOfType( intersectResDef ); if ( intersectResDef ) { + intersectResDef->setDefaultEclipseLegendConfig(); intersectResDef->updateConnectedEditors(); } @@ -670,7 +654,7 @@ void RimEclipseResultDefinition::loadDataAndUpdate() /// //-------------------------------------------------------------------------------------------------- QList - RimEclipseResultDefinition::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) + RimEclipseResultDefinition::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; @@ -876,8 +860,6 @@ QList } } - ( *useOptionsOnly ) = true; - return options; } @@ -1835,11 +1817,11 @@ QList if ( ternaryEnabled ) { bool hasAtLeastOneTernaryComponent = false; - if ( cellCenterResultNames.contains( "SOIL" ) ) + if ( cellCenterResultNames.contains( RiaResultNames::soil() ) ) hasAtLeastOneTernaryComponent = true; - else if ( cellCenterResultNames.contains( "SGAS" ) ) + else if ( cellCenterResultNames.contains( RiaResultNames::sgas() ) ) hasAtLeastOneTernaryComponent = true; - else if ( cellCenterResultNames.contains( "SWAT" ) ) + else if ( cellCenterResultNames.contains( RiaResultNames::swat() ) ) hasAtLeastOneTernaryComponent = true; if ( resultCatType == RiaDefines::ResultCatType::DYNAMIC_NATIVE && hasAtLeastOneTernaryComponent ) @@ -2226,7 +2208,7 @@ void RimEclipseResultDefinition::updateRangesForExplicitLegends( RimRegularLegen { RigCaseCellResultsData* gridCellResults = this->currentGridCellResults(); { - RigEclipseResultAddress resAddr( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "SOIL" ); + RigEclipseResultAddress resAddr( RiaDefines::ResultCatType::DYNAMIC_NATIVE, RiaResultNames::soil() ); if ( gridCellResults->ensureKnownResultLoaded( resAddr ) ) { @@ -2247,7 +2229,7 @@ void RimEclipseResultDefinition::updateRangesForExplicitLegends( RimRegularLegen } { - RigEclipseResultAddress resAddr( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "SGAS" ); + RigEclipseResultAddress resAddr( RiaDefines::ResultCatType::DYNAMIC_NATIVE, RiaResultNames::sgas() ); if ( gridCellResults->ensureKnownResultLoaded( resAddr ) ) { @@ -2268,7 +2250,7 @@ void RimEclipseResultDefinition::updateRangesForExplicitLegends( RimRegularLegen } { - RigEclipseResultAddress resAddr( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "SWAT" ); + RigEclipseResultAddress resAddr( RiaDefines::ResultCatType::DYNAMIC_NATIVE, RiaResultNames::swat() ); if ( gridCellResults->ensureKnownResultLoaded( resAddr ) ) { diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseResultDefinition.h b/ApplicationLibCode/ProjectDataModel/RimEclipseResultDefinition.h index ab31a9b1b1..296cda0784 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseResultDefinition.h +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseResultDefinition.h @@ -144,8 +144,7 @@ class RimEclipseResultDefinition : public RimCheckableObject protected: virtual void updateLegendCategorySettings(){}; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void initAfterRead() override; diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCase.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCase.cpp index d908c7ce37..586a7b9058 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCase.cpp @@ -65,52 +65,34 @@ CAF_PDM_SOURCE_INIT( RimEclipseStatisticsCase, "RimStatisticalCalculation" ); RimEclipseStatisticsCase::RimEclipseStatisticsCase() : RimEclipseCase() { - CAF_PDM_InitObject( "Case Group Statistics", ":/Histogram16x16.png", "", "" ); + CAF_PDM_InitObject( "Case Group Statistics", ":/Histogram16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_calculateEditCommand, "m_editingAllowed", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_calculateEditCommand, "m_editingAllowed", "" ); caf::PdmUiPushButtonEditor::configureEditorForField( &m_calculateEditCommand ); m_calculateEditCommand = false; - CAF_PDM_InitField( &m_selectionSummary, "SelectionSummary", QString( "" ), "Summary of Calculation Setup", "", "", "" ); + CAF_PDM_InitField( &m_selectionSummary, "SelectionSummary", QString( "" ), "Summary of Calculation Setup" ); m_selectionSummary.xmlCapability()->disableIO(); m_selectionSummary.uiCapability()->setUiReadOnly( true ); m_selectionSummary.uiCapability()->setUiEditorTypeName( caf::PdmUiTextEditor::uiEditorTypeName() ); m_selectionSummary.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); - CAF_PDM_InitScriptableFieldNoDefault( &m_resultType, "ResultType", "Result Type", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_resultType, "ResultType", "Result Type" ); m_resultType.xmlCapability()->setIOWritable( false ); - CAF_PDM_InitScriptableFieldNoDefault( &m_porosityModel, "PorosityModel", "Porosity Model", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_porosityModel, "PorosityModel", "Porosity Model" ); m_porosityModel.xmlCapability()->setIOWritable( false ); - CAF_PDM_InitScriptableFieldNoDefault( &m_selectedDynamicProperties, "DynamicPropertiesToCalculate", "Dyn Prop", "", "", "" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_selectedStaticProperties, "StaticPropertiesToCalculate", "Stat Prop", "", "", "" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_selectedGeneratedProperties, "GeneratedPropertiesToCalculate", "", "", "", "" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_selectedInputProperties, "InputPropertiesToCalculate", "", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_selectedDynamicProperties, "DynamicPropertiesToCalculate", "Dyn Prop" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_selectedStaticProperties, "StaticPropertiesToCalculate", "Stat Prop" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_selectedGeneratedProperties, "GeneratedPropertiesToCalculate", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_selectedInputProperties, "InputPropertiesToCalculate", "" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_selectedFractureDynamicProperties, - "FractureDynamicPropertiesToCalculate", - "", - "", - "", - "" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_selectedFractureStaticProperties, - "FractureStaticPropertiesToCalculate", - "", - "", - "", - "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_selectedFractureDynamicProperties, "FractureDynamicPropertiesToCalculate", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_selectedFractureStaticProperties, "FractureStaticPropertiesToCalculate", "" ); CAF_PDM_InitScriptableFieldNoDefault( &m_selectedFractureGeneratedProperties, "FractureGeneratedPropertiesToCalculate", - "", - "", - "", - "" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_selectedFractureInputProperties, - "FractureInputPropertiesToCalculate", - "", - "", - "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_selectedFractureInputProperties, "FractureInputPropertiesToCalculate", "" ); m_selectedDynamicProperties.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); m_selectedStaticProperties.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); @@ -122,28 +104,22 @@ RimEclipseStatisticsCase::RimEclipseStatisticsCase() m_selectedFractureGeneratedProperties.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); m_selectedFractureInputProperties.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); - CAF_PDM_InitScriptableField( &m_calculatePercentiles, "CalculatePercentiles", true, "Calculate Percentiles", "", "", "" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_percentileCalculationType, "PercentileCalculationType", "Method", "", "", "" ); + CAF_PDM_InitScriptableField( &m_calculatePercentiles, "CalculatePercentiles", true, "Calculate Percentiles" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_percentileCalculationType, "PercentileCalculationType", "Method" ); - CAF_PDM_InitScriptableField( &m_lowPercentile, "LowPercentile", 10.0, "Low", "", "", "" ); - CAF_PDM_InitScriptableField( &m_midPercentile, "MidPercentile", 50.0, "Mid", "", "", "" ); - CAF_PDM_InitScriptableField( &m_highPercentile, "HighPercentile", 90.0, "High", "", "", "" ); + CAF_PDM_InitScriptableField( &m_lowPercentile, "LowPercentile", 10.0, "Low" ); + CAF_PDM_InitScriptableField( &m_midPercentile, "MidPercentile", 50.0, "Mid" ); + CAF_PDM_InitScriptableField( &m_highPercentile, "HighPercentile", 90.0, "High" ); CAF_PDM_InitScriptableField( &m_wellDataSourceCase, "WellDataSourceCase", RiaResultNames::undefinedResultName(), - "Well Data Source Case", - "", - "", - "" ); + "Well Data Source Case" ); CAF_PDM_InitScriptableField( &m_useZeroAsInactiveCellValue, "UseZeroAsInactiveCellValue", false, - "Use Zero as Inactive Cell Value", - "", - "", - "" ); + "Use Zero as Inactive Cell Value" ); m_populateSelectionAfterLoadingGrid = false; @@ -463,11 +439,9 @@ QList toOptionList( const QStringList& varList ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList - RimEclipseStatisticsCase::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) +QList RimEclipseStatisticsCase::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; - if ( useOptionsOnly ) *useOptionsOnly = true; RimIdenticalGridCaseGroup* idgcg = caseGroup(); if ( !( caseGroup() && caseGroup()->mainCase() && caseGroup()->mainCase()->eclipseCaseData() ) ) @@ -539,7 +513,7 @@ QList return toOptionList( sourceCaseNames ); } - if ( !options.size() ) options = RimEclipseCase::calculateValueOptions( fieldNeedingOptions, useOptionsOnly ); + if ( !options.size() ) options = RimEclipseCase::calculateValueOptions( fieldNeedingOptions ); return options; } @@ -582,7 +556,7 @@ void RimEclipseStatisticsCase::fieldChangedByUi( const caf::PdmFieldHandle* chan RimEclipseView* reservoirView = reservoirViews()[i]; CVF_ASSERT( reservoirView ); - reservoirView->wellCollection()->wells.deleteAllChildObjects(); + reservoirView->wellCollection()->wells.deleteChildren(); reservoirView->updateDisplayModelForWellResults(); reservoirView->wellCollection()->updateConnectedEditors(); @@ -845,7 +819,8 @@ void RimEclipseStatisticsCase::populateResultSelection() { QStringList varList = caseData->results( RiaDefines::PorosityModelType::MATRIX_MODEL ) ->resultNames( RiaDefines::ResultCatType::DYNAMIC_NATIVE ); - if ( varList.contains( "SOIL" ) ) m_selectedDynamicProperties.v().push_back( "SOIL" ); + if ( varList.contains( RiaResultNames::soil() ) ) + m_selectedDynamicProperties.v().push_back( RiaResultNames::soil() ); if ( varList.contains( "PRESSURE" ) ) m_selectedDynamicProperties.v().push_back( "PRESSURE" ); } @@ -861,7 +836,8 @@ void RimEclipseStatisticsCase::populateResultSelection() { QStringList varList = caseData->results( RiaDefines::PorosityModelType::FRACTURE_MODEL ) ->resultNames( RiaDefines::ResultCatType::DYNAMIC_NATIVE ); - if ( varList.contains( "SOIL" ) ) m_selectedFractureDynamicProperties.v().push_back( "SOIL" ); + if ( varList.contains( RiaResultNames::soil() ) ) + m_selectedFractureDynamicProperties.v().push_back( RiaResultNames::soil() ); if ( varList.contains( "PRESSURE" ) ) m_selectedFractureDynamicProperties.v().push_back( "PRESSURE" ); } diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCase.h b/ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCase.h index adc5015186..97e55e6fbd 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCase.h +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCase.h @@ -71,7 +71,6 @@ class RimEclipseStatisticsCase : public RimEclipseCase }; caf::PdmField m_calculateEditCommand; - void updateFilePathsFromProjectPath( const QString& projectPath, const QString& oldProjectPath ) override {} void populateResultSelectionAfterLoadingGrid(); @@ -88,8 +87,7 @@ class RimEclipseStatisticsCase : public RimEclipseCase void updatePercentileUiVisibility(); void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void loadSimulationWellDataFromSourceCase(); diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCaseCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCaseCollection.cpp index 6281cac4cb..1237dde0b0 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCaseCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCaseCollection.cpp @@ -31,9 +31,9 @@ CAF_PDM_SOURCE_INIT( RimEclipseStatisticsCaseCollection, "RimStatisticalCollecti RimEclipseStatisticsCaseCollection::RimEclipseStatisticsCaseCollection() : PdmObject() { - CAF_PDM_InitObject( "Derived Statistics", "", "", "" ); + CAF_PDM_InitObject( "Derived Statistics" ); - CAF_PDM_InitFieldNoDefault( &cases, "Reservoirs", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &cases, "Reservoirs", "" ); cases.uiCapability()->setUiTreeHidden( true ); } @@ -42,7 +42,7 @@ RimEclipseStatisticsCaseCollection::RimEclipseStatisticsCaseCollection() //-------------------------------------------------------------------------------------------------- RimEclipseStatisticsCaseCollection::~RimEclipseStatisticsCaseCollection() { - cases.deleteAllChildObjects(); + cases.deleteChildren(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp index 4c2f766310..f403c5f8c8 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp @@ -139,61 +139,54 @@ RimEclipseView::RimEclipseView() "GridCellResult", "CellResult", "Cell Result", - ":/CellResult.png", - "", - "" ); + ":/CellResult.png" ); m_cellResult = new RimEclipseCellColors(); m_cellResult.uiCapability()->setUiTreeHidden( true ); m_cellResult->enableDeltaResults( true ); - CAF_PDM_InitFieldNoDefault( &m_cellEdgeResult, "GridCellEdgeResult", "Cell Edge Result", ":/EdgeResult_1.png", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_cellEdgeResult, "GridCellEdgeResult", "Cell Edge Result", ":/EdgeResult_1.png" ); m_cellEdgeResult = new RimCellEdgeColors(); m_cellEdgeResult.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_elementVectorResult, - "ElementVectorResult", - "Element Vector Result", - ":/CellResult.png", - "", - "" ); + CAF_PDM_InitFieldNoDefault( &m_elementVectorResult, "ElementVectorResult", "Vector Result", ":/CellResult.png" ); m_elementVectorResult = new RimElementVectorResult; m_elementVectorResult.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_faultResultSettings, "FaultResultSettings", "Fault Result", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_faultResultSettings, "FaultResultSettings", "Fault Result" ); m_faultResultSettings = new RimEclipseFaultColors(); m_faultResultSettings.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_fractureColors, "StimPlanColors", "Fracture", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_fractureColors, "StimPlanColors", "Fracture" ); m_fractureColors = new RimStimPlanColors(); m_fractureColors.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_virtualPerforationResult, "VirtualPerforationResult", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_virtualPerforationResult, "VirtualPerforationResult", "" ); m_virtualPerforationResult = new RimVirtualPerforationResults(); m_virtualPerforationResult.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_wellCollection, "WellCollection", "Simulation Wells", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wellCollection, "WellCollection", "Simulation Wells" ); m_wellCollection = new RimSimWellInViewCollection; m_wellCollection.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_faultCollection, "FaultCollection", "Faults", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_faultCollection, "FaultCollection", "Faults" ); m_faultCollection = new RimFaultInViewCollection; m_faultCollection.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_annotationCollection, "AnnotationCollection", "Annotations", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_annotationCollection, "AnnotationCollection", "Annotations" ); m_annotationCollection = new RimAnnotationInViewCollection; m_annotationCollection.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_streamlineCollection, "StreamlineCollection", "Streamlines", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_streamlineCollection, "StreamlineCollection", "Streamlines" ); m_streamlineCollection = new RimStreamlineInViewCollection(); m_streamlineCollection.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_propertyFilterCollection, "PropertyFilters", "Property Filters", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_propertyFilterCollection, "PropertyFilters", "Property Filters" ); m_propertyFilterCollection = new RimEclipsePropertyFilterCollection(); m_propertyFilterCollection.uiCapability()->setUiTreeHidden( true ); // Visualization fields - CAF_PDM_InitField( &m_showInactiveCells, "ShowInactiveCells", false, "Show Inactive Cells", "", "", "" ); - CAF_PDM_InitField( &m_showInvalidCells, "ShowInvalidCells", false, "Show Invalid Cells", "", "", "" ); + CAF_PDM_InitField( &m_showInactiveCells, "ShowInactiveCells", false, "Show Inactive Cells" ); + CAF_PDM_InitField( &m_showInvalidCells, "ShowInvalidCells", false, "Show Invalid Cells" ); CAF_PDM_InitScriptableFieldNoDefault( &m_cellResultData, "CellResultData", "", "", "", "Current Eclipse Cell Result" ); m_cellResultData.xmlCapability()->disableIO(); @@ -1634,7 +1627,7 @@ void RimEclipseView::syncronizeWellsWithResults() delete well; } } - this->wellCollection()->wells().clear(); + this->wellCollection()->wells().clearWithoutDelete(); // Set the new wells into the field. this->wellCollection()->wells().insert( 0, newWells ); diff --git a/ApplicationLibCode/ProjectDataModel/RimElementVectorResult.cpp b/ApplicationLibCode/ProjectDataModel/RimElementVectorResult.cpp index 979109d89b..3a8abd3d20 100644 --- a/ApplicationLibCode/ProjectDataModel/RimElementVectorResult.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimElementVectorResult.cpp @@ -15,6 +15,7 @@ // for more details. // ///////////////////////////////////////////////////////////////////////////////// + #include "RimElementVectorResult.h" #include "RigCaseCellResultsData.h" @@ -26,6 +27,7 @@ #include "Rim3dView.h" #include "RimEclipseCase.h" #include "RimEclipseView.h" +#include "RimRegularLegendConfig.h" #include "RiuViewer.h" @@ -70,26 +72,23 @@ void AppEnum::setUp() //-------------------------------------------------------------------------------------------------- RimElementVectorResult::RimElementVectorResult() { - CAF_PDM_InitObject( "Flow Vector Result", ":/CellResult.png", "", "" ); + CAF_PDM_InitObject( "Flow Vector Result", ":/CellResult.png" ); - CAF_PDM_InitFieldNoDefault( &m_legendConfig, "LegendDefinition", "Color Legend", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_legendConfig, "LegendDefinition", "Color Legend" ); m_legendConfig = new RimRegularLegendConfig(); m_legendConfig.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitField( &m_showOil, "ShowOil", true, "Oil", "", "", "" ); - CAF_PDM_InitField( &m_showGas, "ShowGas", true, "Gas", "", "", "" ); - CAF_PDM_InitField( &m_showWater, "ShowWater", true, "Water", "", "", "" ); + CAF_PDM_InitField( &m_showOil, "ShowOil", true, "Oil" ); + CAF_PDM_InitField( &m_showGas, "ShowGas", true, "Gas" ); + CAF_PDM_InitField( &m_showWater, "ShowWater", true, "Water" ); - CAF_PDM_InitField( &m_showResult, "ShowResult", false, "", "", "", "" ); + CAF_PDM_InitField( &m_showResult, "ShowResult", false, "" ); - CAF_PDM_InitFieldNoDefault( &m_vectorView, "VectorView", "View Vectors", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_vectorView, "VectorView", "View Vectors" ); CAF_PDM_InitFieldNoDefault( &m_vectorSurfaceCrossingLocation, "VectorSurfaceCrossingLocation", - "Vectors Touching Surface", - "", - "", - "" ); + "Vectors Touching Surface" ); m_vectorSurfaceCrossingLocation.uiCapability()->setUiReadOnly( m_vectorView() == RimElementVectorResult::VectorView::CELL_CENTER_TOTAL ); @@ -99,9 +98,9 @@ RimElementVectorResult::RimElementVectorResult() CAF_PDM_InitField( &m_showNncData, "ShowNncData", true, "Show NNC Data" ); CAF_PDM_InitField( &m_threshold, "Threshold", 0.0, "Threshold" ); - CAF_PDM_InitFieldNoDefault( &m_vectorColor, "VectorColor", "Color", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_vectorColor, "VectorColor", "Color" ); cvf::Color3f defaultUniformColor = cvf::Color3f::BLACK; - CAF_PDM_InitField( &m_uniformVectorColor, "UniformVectorColor", defaultUniformColor, "Uniform Vector Color", "", "", "" ); + CAF_PDM_InitField( &m_uniformVectorColor, "UniformVectorColor", defaultUniformColor, "Uniform Vector Color" ); CAF_PDM_InitField( &m_sizeScale, "SizeScale", 1.0, "Size Scale" ); } @@ -442,7 +441,7 @@ void RimElementVectorResult::updateLegendRangesTextAndVisibility( RiuViewer* nat resultNames << QString( "Water" ); } - m_legendConfig->setTitle( QString( "Element Vector Result: \n" ) + resultNames.join( ", " ) ); + m_legendConfig->setTitle( QString( "Vector Result: \n" ) + resultNames.join( ", " ) ); double minResultValue; double maxResultValue; diff --git a/ApplicationLibCode/ProjectDataModel/RimElementVectorResult.h b/ApplicationLibCode/ProjectDataModel/RimElementVectorResult.h index 024a347354..ecdaaeef63 100644 --- a/ApplicationLibCode/ProjectDataModel/RimElementVectorResult.h +++ b/ApplicationLibCode/ProjectDataModel/RimElementVectorResult.h @@ -18,6 +18,8 @@ #pragma once +#include "RimLegendConfig.h" + #include "cafPdmChildField.h" #include "cafPdmField.h" #include "cafPdmFieldCvfColor.h" // Include to make Pdm work for cvf::Color @@ -25,8 +27,6 @@ #include "RigEclipseResultAddress.h" -#include "RimRegularLegendConfig.h" - #include #include @@ -112,6 +112,6 @@ class RimElementVectorResult : public caf::PdmObject caf::PdmField> m_vectorColor; caf::PdmField m_uniformVectorColor; caf::PdmField m_sizeScale; - caf::PdmField m_rangeMode; + caf::PdmField m_rangeMode; caf::PdmChildField m_legendConfig; }; diff --git a/ApplicationLibCode/ProjectDataModel/RimEnsembleFractureStatisticsPlot.cpp b/ApplicationLibCode/ProjectDataModel/RimEnsembleFractureStatisticsPlot.cpp index 9fa5af8421..5071a6bbd3 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEnsembleFractureStatisticsPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEnsembleFractureStatisticsPlot.cpp @@ -42,15 +42,10 @@ RimEnsembleFractureStatisticsPlot::RimEnsembleFractureStatisticsPlot() { CAF_PDM_InitObject( "Ensemble Fracture Statistics Plot", "", "", "A Plot of Ensemble Fracture Statistics" ); - CAF_PDM_InitFieldNoDefault( &m_ensembleFractureStatistics, - "EnsembleFractureStatistics", - "Ensemble Fracture Statistics", - "", - "", - "" ); + CAF_PDM_InitFieldNoDefault( &m_ensembleFractureStatistics, "EnsembleFractureStatistics", "Ensemble Fracture Statistics" ); m_ensembleFractureStatistics.uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_property, "Property", "Property", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_property, "Property", "Property" ); m_plotLegendsHorizontal.uiCapability()->setUiHidden( true ); @@ -109,10 +104,9 @@ void RimEnsembleFractureStatisticsPlot::defineUiOrdering( QString uiConfigName, /// //-------------------------------------------------------------------------------------------------- QList - RimEnsembleFractureStatisticsPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) + RimEnsembleFractureStatisticsPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { - QList options = RimStatisticsPlot::calculateValueOptions( fieldNeedingOptions, useOptionsOnly ); + QList options = RimStatisticsPlot::calculateValueOptions( fieldNeedingOptions ); if ( fieldNeedingOptions == &m_ensembleFractureStatistics ) { diff --git a/ApplicationLibCode/ProjectDataModel/RimEnsembleFractureStatisticsPlot.h b/ApplicationLibCode/ProjectDataModel/RimEnsembleFractureStatisticsPlot.h index 4a04d912fb..06634561ad 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEnsembleFractureStatisticsPlot.h +++ b/ApplicationLibCode/ProjectDataModel/RimEnsembleFractureStatisticsPlot.h @@ -47,8 +47,7 @@ class RimEnsembleFractureStatisticsPlot : public RimStatisticsPlot // Overridden PDM methods void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; QString createAutoName() const override; QString createXAxisTitle() const override; diff --git a/ApplicationLibCode/ProjectDataModel/RimEnsembleFractureStatisticsPlotCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimEnsembleFractureStatisticsPlotCollection.cpp index 2d251988c2..ee31a31207 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEnsembleFractureStatisticsPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEnsembleFractureStatisticsPlotCollection.cpp @@ -30,9 +30,9 @@ CAF_PDM_SOURCE_INIT( RimEnsembleFractureStatisticsPlotCollection, "EnsembleFract //-------------------------------------------------------------------------------------------------- RimEnsembleFractureStatisticsPlotCollection::RimEnsembleFractureStatisticsPlotCollection() { - CAF_PDM_InitObject( "Ensemble Fracture Statistics Plots", ":/WellLogPlots16x16.png", "", "" ); + CAF_PDM_InitObject( "Ensemble Fracture Statistics Plots", ":/WellLogPlots16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_ensembleFractureStatisticsPlots, "EnsembleFractureStatisticsPlots", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_ensembleFractureStatisticsPlots, "EnsembleFractureStatisticsPlots", "" ); m_ensembleFractureStatisticsPlots.uiCapability()->setUiTreeHidden( true ); } @@ -69,7 +69,7 @@ void RimEnsembleFractureStatisticsPlotCollection::addEnsembleFractureStatisticsP std::vector RimEnsembleFractureStatisticsPlotCollection::ensembleFractureStatisticsPlots() const { - return m_ensembleFractureStatisticsPlots.childObjects(); + return m_ensembleFractureStatisticsPlots.children(); } //-------------------------------------------------------------------------------------------------- @@ -77,5 +77,5 @@ std::vector //-------------------------------------------------------------------------------------------------- void RimEnsembleFractureStatisticsPlotCollection::deleteAllPlots() { - m_ensembleFractureStatisticsPlots.deleteAllChildObjects(); + m_ensembleFractureStatisticsPlots.deleteChildren(); } diff --git a/ApplicationLibCode/ProjectDataModel/RimEquilibriumAxisAnnotation.cpp b/ApplicationLibCode/ProjectDataModel/RimEquilibriumAxisAnnotation.cpp index ff71169aa7..12845cfc4f 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEquilibriumAxisAnnotation.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEquilibriumAxisAnnotation.cpp @@ -52,12 +52,12 @@ CAF_PDM_SOURCE_INIT( RimEquilibriumAxisAnnotation, "RimEquilibriumAxisAnnotation RimEquilibriumAxisAnnotation::RimEquilibriumAxisAnnotation() : RimPlotAxisAnnotation() { - CAF_PDM_InitObject( "Equilibrium Annotation", ":/LeftAxis16x16.png", "", "" ); + CAF_PDM_InitObject( "Equilibrium Annotation", ":/LeftAxis16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_annotationType, "AnnotationType", "AnnotationType", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_annotationType, "AnnotationType", "AnnotationType" ); - CAF_PDM_InitFieldNoDefault( &m_sourceCase, "Associated3DCase", "Eclipse Case", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_equilNum, "m_equilNum", "equil Num", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_sourceCase, "Associated3DCase", "Eclipse Case" ); + CAF_PDM_InitFieldNoDefault( &m_equilNum, "m_equilNum", "equil Num" ); } //-------------------------------------------------------------------------------------------------- @@ -112,8 +112,7 @@ QColor RimEquilibriumAxisAnnotation::color() const /// //-------------------------------------------------------------------------------------------------- QList - RimEquilibriumAxisAnnotation::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) + RimEquilibriumAxisAnnotation::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; diff --git a/ApplicationLibCode/ProjectDataModel/RimEquilibriumAxisAnnotation.h b/ApplicationLibCode/ProjectDataModel/RimEquilibriumAxisAnnotation.h index 5f09f7d24d..e1b354c386 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEquilibriumAxisAnnotation.h +++ b/ApplicationLibCode/ProjectDataModel/RimEquilibriumAxisAnnotation.h @@ -56,8 +56,7 @@ class RimEquilibriumAxisAnnotation : public RimPlotAxisAnnotation double value() const override; QColor color() const override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; protected: void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; diff --git a/ApplicationLibCode/ProjectDataModel/RimExportInputPropertySettings.cpp b/ApplicationLibCode/ProjectDataModel/RimExportInputPropertySettings.cpp index 5cebce1788..92f3445004 100644 --- a/ApplicationLibCode/ProjectDataModel/RimExportInputPropertySettings.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimExportInputPropertySettings.cpp @@ -26,11 +26,11 @@ CAF_PDM_SOURCE_INIT( RimExportInputSettings, "RimExportInputSettings" ); //-------------------------------------------------------------------------------------------------- RimExportInputSettings::RimExportInputSettings() { - CAF_PDM_InitObject( "RimExportInputSettings", "", "", "" ); + CAF_PDM_InitObject( "RimExportInputSettings" ); - CAF_PDM_InitFieldNoDefault( &fileName, "Filename", "Export Filename", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &fileName, "Filename", "Export Filename" ); fileName.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &eclipseKeyword, "Keyword", "Eclipse Keyword", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &eclipseKeyword, "Keyword", "Eclipse Keyword" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimFormationNames.cpp b/ApplicationLibCode/ProjectDataModel/RimFormationNames.cpp index 3b7aa49e9c..27ed52ecfb 100644 --- a/ApplicationLibCode/ProjectDataModel/RimFormationNames.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimFormationNames.cpp @@ -42,9 +42,9 @@ CAF_PDM_SOURCE_INIT( RimFormationNames, "FormationNames" ); //-------------------------------------------------------------------------------------------------- RimFormationNames::RimFormationNames() { - CAF_PDM_InitObject( "Formation Names", ":/Formations16x16.png", "", "" ); + CAF_PDM_InitObject( "Formation Names", ":/Formations16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_formationNamesFileName, "FormationNamesFileName", "File Name", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_formationNamesFileName, "FormationNamesFileName", "File Name" ); m_formationNamesFileName.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); diff --git a/ApplicationLibCode/ProjectDataModel/RimFormationNamesCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimFormationNamesCollection.cpp index c9b7f26609..166be30358 100644 --- a/ApplicationLibCode/ProjectDataModel/RimFormationNamesCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimFormationNamesCollection.cpp @@ -29,9 +29,9 @@ CAF_PDM_SOURCE_INIT( RimFormationNamesCollection, "FormationNamesCollectionObjec //-------------------------------------------------------------------------------------------------- RimFormationNamesCollection::RimFormationNamesCollection() { - CAF_PDM_InitObject( "Formations", ":/FormationCollection16x16.png", "", "" ); + CAF_PDM_InitObject( "Formations", ":/FormationCollection16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_formationNamesList, "FormationNamesList", "Formations", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_formationNamesList, "FormationNamesList", "Formations" ); m_formationNamesList.uiCapability()->setUiTreeHidden( true ); setDeletable( true ); @@ -42,7 +42,7 @@ RimFormationNamesCollection::RimFormationNamesCollection() //-------------------------------------------------------------------------------------------------- RimFormationNamesCollection::~RimFormationNamesCollection() { - m_formationNamesList.deleteAllChildObjects(); + m_formationNamesList.deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -109,7 +109,7 @@ std::vector RimFormationNamesCollection::importFiles( const RiaLogging::errorInMessageBox( nullptr, "Import Formation Names", totalErrorMessage ); } - return m_formationNamesList.childObjects(); + return m_formationNamesList.children(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimGridCalculation.cpp b/ApplicationLibCode/ProjectDataModel/RimGridCalculation.cpp new file mode 100644 index 0000000000..fbea9d7dee --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/RimGridCalculation.cpp @@ -0,0 +1,405 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimGridCalculation.h" + +#include "RiaDefines.h" +#include "RiaLogging.h" +#include "RiaPorosityModel.h" + +#include "RimEclipseCase.h" +#include "RimEclipseCellColors.h" +#include "RimEclipseView.h" +#include "RimGridCalculationVariable.h" +#include "RimReloadCaseTools.h" + +#include "RigCaseCellResultsData.h" +#include "RigEclipseResultAddress.h" +#include "RigMainGrid.h" +#include "RigResultAccessor.h" +#include "RigResultAccessorFactory.h" + +#include "expressionparser/ExpressionParser.h" + +CAF_PDM_SOURCE_INIT( RimGridCalculation, "RimGridCalculation" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGridCalculation::RimGridCalculation() +{ + CAF_PDM_InitObject( "RimGridCalculation", ":/octave.png", "Calculation", "" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGridCalculationVariable* RimGridCalculation::createVariable() const +{ + return new RimGridCalculationVariable; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimGridCalculation::calculate() +{ + QString leftHandSideVariableName = RimGridCalculation::findLeftHandSide( m_expression ); + + RimEclipseCase* eclipseCase = findEclipseCaseFromVariables(); + if ( !eclipseCase ) + { + RiaLogging::errorInMessageBox( nullptr, + "Grid Property Calculator", + QString( "No case found for calculation : %1" ).arg( leftHandSideVariableName ) ); + return false; + } + + auto [isOk, errorMessage] = validateVariables(); + if ( !isOk ) + { + RiaLogging::errorInMessageBox( nullptr, "Grid Property Calculator", errorMessage ); + return false; + } + + auto porosityModel = RiaDefines::PorosityModelType::MATRIX_MODEL; + + RigEclipseResultAddress resAddr( RiaDefines::ResultCatType::GENERATED, leftHandSideVariableName ); + + if ( !eclipseCase->results( porosityModel )->ensureKnownResultLoaded( resAddr ) ) + { + eclipseCase->results( porosityModel )->createResultEntry( resAddr, true ); + } + + eclipseCase->results( porosityModel )->clearScalarResult( resAddr ); + + const size_t timeStepCount = eclipseCase->results( porosityModel )->maxTimeStepCount(); + + std::vector>* scalarResultFrames = + eclipseCase->results( porosityModel )->modifiableCellScalarResultTimesteps( resAddr ); + scalarResultFrames->resize( timeStepCount ); + + for ( size_t tsId = 0; tsId < timeStepCount; tsId++ ) + { + std::vector> values; + for ( size_t i = 0; i < m_variables.size(); i++ ) + { + RimGridCalculationVariable* v = dynamic_cast( m_variables[i] ); + CAF_ASSERT( v != nullptr ); + values.push_back( getInputVectorForVariable( v, tsId, porosityModel ) ); + } + + ExpressionParser parser; + for ( size_t i = 0; i < m_variables.size(); i++ ) + { + RimGridCalculationVariable* v = dynamic_cast( m_variables[i] ); + CAF_ASSERT( v != nullptr ); + parser.assignVector( v->name(), values[i] ); + } + + std::vector resultValues; + resultValues.resize( values[0].size() ); + parser.assignVector( leftHandSideVariableName, resultValues ); + + QString errorText; + bool evaluatedOk = parser.expandIfStatementsAndEvaluate( m_expression, &errorText ); + + if ( evaluatedOk ) + { + auto [cellFilterView, defaultValueConfig] = findFilterValuesFromVariables(); + + if ( cellFilterView ) + { + auto [defaultValueType, defaultValue] = defaultValueConfig; + filterResults( cellFilterView, values, defaultValueType, defaultValue, resultValues ); + } + + scalarResultFrames->at( tsId ) = resultValues; + + m_isDirty = false; + } + else + { + QString s = "The following error message was received from the parser library : \n\n"; + s += errorText; + + RiaLogging::errorInMessageBox( nullptr, "Grid Property Calculator", s ); + return false; + } + } + + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseCase* RimGridCalculation::findEclipseCaseFromVariables() const +{ + for ( auto variable : m_variables ) + { + RimGridCalculationVariable* v = dynamic_cast( variable.p() ); + CAF_ASSERT( v != nullptr ); + + if ( v->eclipseCase() ) return v->eclipseCase(); + } + + return nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair + RimGridCalculation::findFilterValuesFromVariables() const +{ + for ( auto variable : m_variables ) + { + RimGridCalculationVariable* v = dynamic_cast( variable.p() ); + CAF_ASSERT( v != nullptr ); + + if ( v->cellFilterView() ) return std::make_pair( v->cellFilterView(), v->defaultValueConfiguration() ); + } + + return std::pair( nullptr, std::make_pair( RimGridCalculationVariable::DefaultValueType::POSITIVE_INFINITY, HUGE_VAL ) ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimGridCalculation::findFilterVariableIndex() const +{ + for ( size_t i = 0; i < m_variables.size(); i++ ) + { + auto variable = m_variables[i]; + RimGridCalculationVariable* v = dynamic_cast( variable ); + CAF_ASSERT( v != nullptr ); + + if ( v->cellFilterView() ) return static_cast( i ); + } + + return -1; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimGridCalculation::getInputVectorForVariable( RimGridCalculationVariable* v, + size_t tsId, + RiaDefines::PorosityModelType porosityModel ) const +{ + int timeStep = v->timeStep(); + + auto resultCategoryType = v->resultCategoryType(); + + // General case is to use the data from the given time step + size_t timeStepToUse = tsId; + + if ( resultCategoryType == RiaDefines::ResultCatType::STATIC_NATIVE ) + { + // Use the first time step for static data for all time steps + timeStepToUse = 0; + } + else if ( timeStep != RimGridCalculationVariable::allTimeStepsValue() ) + { + // Use data from a specific time step for this variable for all result time steps + timeStepToUse = timeStep; + } + + RigEclipseResultAddress resAddr( resultCategoryType, v->resultVariable() ); + + auto mainGrid = v->eclipseCase()->mainGrid(); + size_t maxGridCount = mainGrid->gridCount(); + + size_t cellCount = mainGrid->globalCellArray().size(); + std::vector inputValues( cellCount ); + for ( size_t gridIdx = 0; gridIdx < maxGridCount; ++gridIdx ) + { + auto grid = mainGrid->gridByIndex( gridIdx ); + + cvf::ref sourceResultAccessor = + RigResultAccessorFactory::createFromResultAddress( v->eclipseCase()->eclipseCaseData(), + gridIdx, + porosityModel, + timeStepToUse, + resAddr ); + +#pragma omp parallel for + for ( int localGridCellIdx = 0; localGridCellIdx < static_cast( grid->cellCount() ); localGridCellIdx++ ) + { + const size_t reservoirCellIndex = grid->reservoirCellIndex( localGridCellIdx ); + inputValues[reservoirCellIndex] = sourceResultAccessor->cellScalar( localGridCellIdx ); + } + } + + return inputValues; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridCalculation::replaceFilteredValuesWithVector( const std::vector& inputValues, + cvf::ref visibility, + std::vector& resultValues ) +{ +#pragma omp parallel for + for ( int i = 0; i < static_cast( resultValues.size() ); i++ ) + { + if ( !visibility->val( i ) ) + { + resultValues[i] = inputValues[i]; + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridCalculation::replaceFilteredValuesWithDefaultValue( double defaultValue, + cvf::ref visibility, + std::vector& resultValues ) +{ +#pragma omp parallel for + for ( int i = 0; i < static_cast( resultValues.size() ); i++ ) + { + if ( !visibility->val( i ) ) + { + resultValues[i] = defaultValue; + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridCalculation::filterResults( RimGridView* cellFilterView, + const std::vector>& values, + RimGridCalculationVariable::DefaultValueType defaultValueType, + double defaultValue, + std::vector& resultValues ) const +{ + auto visibility = cellFilterView->currentTotalCellVisibility(); + + if ( defaultValueType == RimGridCalculationVariable::DefaultValueType::FROM_PROPERTY ) + { + int filterVariableIndex = findFilterVariableIndex(); + replaceFilteredValuesWithVector( values[filterVariableIndex], visibility, resultValues ); + } + else + { + replaceFilteredValuesWithDefaultValue( defaultValue, visibility, resultValues ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridCalculation::updateDependentObjects() +{ + RimEclipseCase* eclipseCase = findEclipseCaseFromVariables(); + if ( eclipseCase ) + { + RimReloadCaseTools::updateAll3dViews( eclipseCase ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridCalculation::removeDependentObjects() +{ + QString leftHandSideVariableName = RimGridCalculation::findLeftHandSide( m_expression ); + + auto porosityModel = RiaDefines::PorosityModelType::MATRIX_MODEL; + + RigEclipseResultAddress resAddr( RiaDefines::ResultCatType::GENERATED, leftHandSideVariableName ); + + RimEclipseCase* eclipseCase = findEclipseCaseFromVariables(); + if ( eclipseCase ) + { + // Select "None" result if the result that is being removed were displayed in a view. + for ( auto v : eclipseCase->reservoirViews() ) + { + if ( v->cellResult()->resultType() == resAddr.resultCatType() && + v->cellResult()->resultVariable() == resAddr.resultName() ) + { + v->cellResult()->setResultType( RiaDefines::ResultCatType::GENERATED ); + v->cellResult()->setResultVariable( "None" ); + } + } + + eclipseCase->results( porosityModel )->clearScalarResult( resAddr ); + eclipseCase->results( porosityModel )->setRemovedTagOnGeneratedResult( resAddr ); + + RimReloadCaseTools::updateAll3dViews( eclipseCase ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair RimGridCalculation::validateVariables() +{ + auto porosityModel = RiaDefines::PorosityModelType::MATRIX_MODEL; + + for ( size_t i = 0; i < m_variables.size(); i++ ) + { + RimGridCalculationVariable* v = dynamic_cast( m_variables[i] ); + CAF_ASSERT( v != nullptr ); + + if ( !v->eclipseCase() ) + { + QString errorMessage = QString( "No case defined for variable : %1" ).arg( v->name() ); + return std::make_pair( false, errorMessage ); + } + + if ( v->resultVariable().isEmpty() ) + { + QString errorMessage = QString( "No result variable defined for variable : %1" ).arg( v->name() ); + return std::make_pair( false, errorMessage ); + } + + auto resultCategoryType = v->resultCategoryType(); + RigEclipseResultAddress resAddr( resultCategoryType, v->resultVariable() ); + if ( !v->eclipseCase()->results( porosityModel )->ensureKnownResultLoaded( resAddr ) ) + { + QString errorMessage = QString( "Unable to load result for variable : %1" ).arg( v->name() ); + return std::make_pair( false, errorMessage ); + } + } + + return std::make_pair( true, "" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridCalculation::onChildrenUpdated( caf::PdmChildArrayFieldHandle* childArray, + std::vector& updatedObjects ) +{ + if ( childArray == &m_variables ) + { + // Update the editors of all the variables if a variable changes. + // This makes the read-only state of the filter parameters consistent: + // only one filter is allowed at a time. + for ( auto v : m_variables ) + { + v->updateConnectedEditors(); + } + } +} diff --git a/ApplicationLibCode/ProjectDataModel/RimGridCalculation.h b/ApplicationLibCode/ProjectDataModel/RimGridCalculation.h new file mode 100644 index 0000000000..9d4b559791 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/RimGridCalculation.h @@ -0,0 +1,75 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RiaPorosityModel.h" +#include "RimGridCalculationVariable.h" +#include "RimUserDefinedCalculation.h" + +#include "cvfArray.h" + +class RimEclipseCase; +class RimGridView; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimGridCalculation : public RimUserDefinedCalculation +{ + CAF_PDM_HEADER_INIT; + +public: + RimGridCalculation(); + + bool calculate() override; + void updateDependentObjects() override; + void removeDependentObjects() override; + +protected: + void onChildrenUpdated( caf::PdmChildArrayFieldHandle* childArray, + std::vector& updatedObjects ) override; + + RimGridCalculationVariable* createVariable() const override; + std::pair validateVariables(); + + RimEclipseCase* findEclipseCaseFromVariables() const; + + std::vector getInputVectorForVariable( RimGridCalculationVariable* v, + size_t tsId, + RiaDefines::PorosityModelType porosityModel ) const; + + void filterResults( RimGridView* cellFilterView, + const std::vector>& values, + RimGridCalculationVariable::DefaultValueType defaultValueType, + double defaultValue, + std::vector& resultValues ) const; + + static void replaceFilteredValuesWithVector( const std::vector& inputValues, + cvf::ref visibility, + std::vector& resultValues ); + + static void replaceFilteredValuesWithDefaultValue( double defaultValue, + cvf::ref visibility, + std::vector& resultValues ); + + int findFilterVariableIndex() const; + + std::pair findFilterValuesFromVariables() const; +}; diff --git a/ApplicationLibCode/ProjectDataModel/RimGridCalculationCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimGridCalculationCollection.cpp new file mode 100644 index 0000000000..4dd394ad60 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/RimGridCalculationCollection.cpp @@ -0,0 +1,57 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimGridCalculationCollection.h" + +#include "RimGridCalculation.h" + +#include "cafPdmUiGroup.h" +#include "cafPdmUiTreeSelectionEditor.h" + +CAF_PDM_SOURCE_INIT( RimGridCalculationCollection, "RimGridCalculationCollection" ); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGridCalculationCollection::RimGridCalculationCollection() +{ + CAF_PDM_InitObject( "Calculation Collection", ":/chain.png" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGridCalculation* RimGridCalculationCollection::createCalculation() const +{ + return new RimGridCalculation; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridCalculationCollection::rebuildCaseMetaData() +{ + ensureValidCalculationIds(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridCalculationCollection::initAfterRead() +{ + rebuildCaseMetaData(); +} diff --git a/ApplicationLibCode/ProjectDataModel/RimGridCalculationCollection.h b/ApplicationLibCode/ProjectDataModel/RimGridCalculationCollection.h new file mode 100644 index 0000000000..e5bc424e37 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/RimGridCalculationCollection.h @@ -0,0 +1,41 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RimGridCalculation.h" +#include "RimUserDefinedCalculationCollection.h" + +//================================================================================================== +/// +/// +//================================================================================================== +class RimGridCalculationCollection : public RimUserDefinedCalculationCollection +{ + CAF_PDM_HEADER_INIT; + +public: + RimGridCalculationCollection(); + + void rebuildCaseMetaData() override; + + RimGridCalculation* createCalculation() const override; + +private: + void initAfterRead() override; +}; diff --git a/ApplicationLibCode/ProjectDataModel/RimGridCalculationVariable.cpp b/ApplicationLibCode/ProjectDataModel/RimGridCalculationVariable.cpp new file mode 100644 index 0000000000..6a6144a3e6 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/RimGridCalculationVariable.cpp @@ -0,0 +1,296 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimGridCalculationVariable.h" + +#include "RiaApplication.h" +#include "RiaDefines.h" +#include "RiaPorosityModel.h" +#include "RiaResultNames.h" + +#include "RimGridCalculation.h" +#include "RiuDragDrop.h" + +#include "RigCaseCellResultsData.h" + +#include "RimEclipseCase.h" +#include "RimEclipseResultAddress.h" +#include "RimEclipseView.h" +#include "RimTools.h" + +CAF_PDM_SOURCE_INIT( RimGridCalculationVariable, "RimGridCalculationVariable" ); + +namespace caf +{ +template <> +void caf::AppEnum::setUp() +{ + addItem( RimGridCalculationVariable::DefaultValueType::POSITIVE_INFINITY, "POSITIVE_INFINITY", "Inf" ); + addItem( RimGridCalculationVariable::DefaultValueType::FROM_PROPERTY, "FROM_PROPERTY", "Property Value" ); + addItem( RimGridCalculationVariable::DefaultValueType::USER_DEFINED, "USER_DEFINED", "User Defined" ); + setDefault( RimGridCalculationVariable::DefaultValueType::POSITIVE_INFINITY ); +} +}; // namespace caf + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGridCalculationVariable::RimGridCalculationVariable() +{ + CAF_PDM_InitObject( "RimGridCalculationVariable", ":/octave.png" ); + + CAF_PDM_InitFieldNoDefault( &m_resultType, "ResultType", "Type" ); + CAF_PDM_InitField( &m_resultVariable, "ResultVariable", RiaResultNames::undefinedResultName(), "Variable" ); + CAF_PDM_InitFieldNoDefault( &m_eclipseCase, "EclipseGridCase", "Grid Case" ); + CAF_PDM_InitField( &m_timeStep, "TimeStep", allTimeStepsValue(), "Time Step" ); + CAF_PDM_InitFieldNoDefault( &m_cellFilterView, "VisibleCellView", "Filter by 3d View Visibility" ); + CAF_PDM_InitFieldNoDefault( &m_defaultValueType, "DefaultValueType", "Default Value Type" ); + CAF_PDM_InitField( &m_defaultValue, "DefaultValue", 0.0, "Default Value" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimGridCalculationVariable::displayString() const +{ + QStringList nameComponents; + + if ( m_eclipseCase() ) nameComponents.append( m_eclipseCase()->uiName() ); + + nameComponents.append( m_resultVariable() ); + return nameComponents.join( " - " ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridCalculationVariable::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +{ + uiOrdering.add( &m_name ); + uiOrdering.add( &m_eclipseCase ); + uiOrdering.add( &m_resultType ); + uiOrdering.add( &m_resultVariable ); + uiOrdering.add( &m_timeStep ); + uiOrdering.add( &m_cellFilterView ); + uiOrdering.add( &m_defaultValueType ); + uiOrdering.add( &m_defaultValue ); + + uiOrdering.skipRemainingFields(); + + m_resultType.uiCapability()->setUiReadOnly( m_eclipseCase == nullptr ); + m_timeStep.uiCapability()->setUiReadOnly( m_resultType == RiaDefines::ResultCatType::STATIC_NATIVE ); + + // Can have only one variable with cell filter at a time. + // Set read-only state based on the state of the sibling variables. + RimGridCalculation* calculation = nullptr; + firstAncestorOfType( calculation ); + + bool hasOtherVariableWithFilter = false; + for ( auto variable : calculation->allVariables() ) + { + auto v = dynamic_cast( variable ); + if ( variable != this && v->cellFilterView() ) + { + hasOtherVariableWithFilter = true; + } + } + + m_cellFilterView.uiCapability()->setUiReadOnly( m_eclipseCase == nullptr || hasOtherVariableWithFilter ); + m_defaultValueType.uiCapability()->setUiReadOnly( m_cellFilterView == nullptr || hasOtherVariableWithFilter ); + m_defaultValue.uiCapability()->setUiReadOnly( + m_cellFilterView == nullptr || + defaultValueType() != RimGridCalculationVariable::DefaultValueType::USER_DEFINED || hasOtherVariableWithFilter ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList + RimGridCalculationVariable::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) +{ + QList options; + + if ( fieldNeedingOptions == &m_resultType ) + { + std::vector resultCategories = { RiaDefines::ResultCatType::STATIC_NATIVE, + RiaDefines::ResultCatType::DYNAMIC_NATIVE, + RiaDefines::ResultCatType::INPUT_PROPERTY, + RiaDefines::ResultCatType::GENERATED }; + + for ( auto c : resultCategories ) + { + options.push_back( caf::PdmOptionItemInfo( caf::AppEnum( c ).uiText(), c ) ); + } + } + else if ( fieldNeedingOptions == &m_resultVariable ) + { + auto results = currentGridCellResults(); + if ( results ) + { + for ( const QString& s : getResultNamesForResultType( m_resultType(), results ) ) + { + options.push_back( caf::PdmOptionItemInfo( s, s ) ); + } + } + } + else if ( fieldNeedingOptions == &m_eclipseCase ) + { + RimTools::eclipseCaseOptionItems( &options ); + } + else if ( fieldNeedingOptions == &m_timeStep ) + { + options.push_back( caf::PdmOptionItemInfo( "All timesteps", allTimeStepsValue() ) ); + + RimTools::timeStepsForCase( m_eclipseCase(), &options ); + } + else if ( fieldNeedingOptions == &m_cellFilterView ) + { + if ( m_eclipseCase ) + { + options.push_back( caf::PdmOptionItemInfo( "Disabled", nullptr ) ); + for ( RimEclipseView* view : m_eclipseCase->reservoirViews.children() ) + { + CVF_ASSERT( view && "Really always should have a valid view pointer in ReservoirViews" ); + options.push_back( caf::PdmOptionItemInfo( view->name(), view, false, view->uiIconProvider() ) ); + } + } + } + + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigCaseCellResultsData* RimGridCalculationVariable::currentGridCellResults() const +{ + if ( !m_eclipseCase ) return nullptr; + + return m_eclipseCase->results( RiaDefines::PorosityModelType::MATRIX_MODEL ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RimGridCalculationVariable::getResultNamesForResultType( RiaDefines::ResultCatType resultCatType, + const RigCaseCellResultsData* results ) +{ + if ( !results ) return QStringList(); + return results->resultNames( resultCatType ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseCase* RimGridCalculationVariable::eclipseCase() const +{ + return m_eclipseCase; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaDefines::ResultCatType RimGridCalculationVariable::resultCategoryType() const +{ + return m_resultType(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimGridCalculationVariable::resultVariable() const +{ + return m_resultVariable; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimGridCalculationVariable::timeStep() const +{ + return m_timeStep; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimGridCalculationVariable::allTimeStepsValue() +{ + return -1; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGridView* RimGridCalculationVariable::cellFilterView() const +{ + return m_cellFilterView; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimGridCalculationVariable::defaultValue() const +{ + return m_defaultValue; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGridCalculationVariable::DefaultValueType RimGridCalculationVariable::defaultValueType() const +{ + return m_defaultValueType(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGridCalculationVariable::DefaultValueConfig RimGridCalculationVariable::defaultValueConfiguration() const +{ + if ( m_defaultValueType() == RimGridCalculationVariable::DefaultValueType::USER_DEFINED ) + return std::make_pair( m_defaultValueType(), m_defaultValue() ); + + return std::make_pair( m_defaultValueType(), HUGE_VAL ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridCalculationVariable::handleDroppedMimeData( const QMimeData* data, + Qt::DropAction action, + caf::PdmFieldHandle* destinationField ) +{ + auto objects = RiuDragDrop::convertToObjects( data ); + if ( !objects.empty() ) + { + auto address = dynamic_cast( objects.front() ); + if ( address ) setEclipseResultAddress( *address ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridCalculationVariable::setEclipseResultAddress( const RimEclipseResultAddress& address ) +{ + m_resultVariable = address.resultName(); + m_resultType = address.resultType(); + m_eclipseCase = address.eclipseCase(); + updateConnectedEditors(); +} diff --git a/ApplicationLibCode/ProjectDataModel/RimGridCalculationVariable.h b/ApplicationLibCode/ProjectDataModel/RimGridCalculationVariable.h new file mode 100644 index 0000000000..59e3f9e20b --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/RimGridCalculationVariable.h @@ -0,0 +1,87 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RimUserDefinedCalculationVariable.h" + +#include "RiaDefines.h" + +#include "cafPdmField.h" +#include "cafPdmObject.h" +#include "cafPdmPtrField.h" + +class RimEclipseCase; +class RimEclipseResultAddress; +class RimGridView; +class RigCaseCellResultsData; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimGridCalculationVariable : public RimUserDefinedCalculationVariable +{ + CAF_PDM_HEADER_INIT; + +public: + enum class DefaultValueType + { + POSITIVE_INFINITY, + FROM_PROPERTY, + USER_DEFINED + }; + + RimGridCalculationVariable(); + + QString displayString() const override; + + RimEclipseCase* eclipseCase() const; + RiaDefines::ResultCatType resultCategoryType() const; + QString resultVariable() const; + int timeStep() const; + RimGridView* cellFilterView() const; + double defaultValue() const; + DefaultValueType defaultValueType() const; + + using DefaultValueConfig = std::pair; + DefaultValueConfig defaultValueConfiguration() const; + + static int allTimeStepsValue(); + + void handleDroppedMimeData( const QMimeData* data, Qt::DropAction action, caf::PdmFieldHandle* destinationField ) override; + + void setEclipseResultAddress( const RimEclipseResultAddress& address ); + +private: + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; + RigCaseCellResultsData* currentGridCellResults() const; + QStringList getResultNamesForResultType( RiaDefines::ResultCatType resultCatType, + const RigCaseCellResultsData* results ); + +private: + caf::PdmPtrField m_eclipseCase; + caf::PdmField> m_resultType; + caf::PdmField m_resultVariable; + caf::PdmField m_timeStep; + caf::PdmPtrField m_cellFilterView; + caf::PdmField> m_defaultValueType; + caf::PdmField m_defaultValue; +}; diff --git a/ApplicationLibCode/ProjectDataModel/RimGridCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimGridCollection.cpp index 0e3c4bfe9d..e5a35b2085 100644 --- a/ApplicationLibCode/ProjectDataModel/RimGridCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimGridCollection.cpp @@ -47,13 +47,13 @@ CAF_PDM_SOURCE_INIT( RimGridInfo, "GridInfo" ); //-------------------------------------------------------------------------------------------------- RimGridInfo::RimGridInfo() { - CAF_PDM_InitObject( "GridInfo", ":/draw_style_meshlines_24x24.png", "", "" ); + CAF_PDM_InitObject( "GridInfo", ":/draw_style_meshlines_24x24.png" ); - CAF_PDM_InitField( &m_isActive, "IsActive", true, "Show Grid Cells", "", "", "" ); - CAF_PDM_InitField( &m_gridName, "GridName", QString(), "Grid Name", "", "", "" ); + CAF_PDM_InitField( &m_isActive, "IsActive", true, "Show Grid Cells" ); + CAF_PDM_InitField( &m_gridName, "GridName", QString(), "Grid Name" ); m_gridName.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitField( &m_eclipseGridIndex, "GridIndex", 0, "Grid Index", "", "", "" ); + CAF_PDM_InitField( &m_eclipseGridIndex, "GridIndex", 0, "Grid Index" ); m_eclipseGridIndex.uiCapability()->setUiReadOnly( true ); } @@ -151,12 +151,12 @@ CAF_PDM_SOURCE_INIT( RimGridInfoCollection, "GridInfoCollection" ); //-------------------------------------------------------------------------------------------------- RimGridInfoCollection::RimGridInfoCollection() { - CAF_PDM_InitObject( "GridInfoCollection", ":/draw_style_meshlines_24x24.png", "", "" ); + CAF_PDM_InitObject( "GridInfoCollection", ":/draw_style_meshlines_24x24.png" ); - CAF_PDM_InitField( &m_isActive, "IsActive", true, "Show Grid Cells", "", "", "" ); + CAF_PDM_InitField( &m_isActive, "IsActive", true, "Show Grid Cells" ); m_isActive.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_gridInfos, "GridInfos", "Grid Infos", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_gridInfos, "GridInfos", "Grid Infos" ); m_gridInfos.uiCapability()->setUiTreeHidden( true ); } @@ -182,7 +182,7 @@ void RimGridInfoCollection::addGridInfo( RimGridInfo* gridInfo ) //-------------------------------------------------------------------------------------------------- void RimGridInfoCollection::clear() { - m_gridInfos.deleteAllChildObjects(); + m_gridInfos.deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -219,7 +219,7 @@ void RimGridInfoCollection::deleteGridInfo( const QString& gridName ) //-------------------------------------------------------------------------------------------------- std::vector RimGridInfoCollection::gridInfos() const { - return m_gridInfos.childObjects(); + return m_gridInfos.children(); } //-------------------------------------------------------------------------------------------------- @@ -250,23 +250,23 @@ CAF_PDM_SOURCE_INIT( RimGridCollection, "GridCollection" ); //-------------------------------------------------------------------------------------------------- RimGridCollection::RimGridCollection() { - CAF_PDM_InitObject( "Grids", ":/draw_style_meshlines_24x24.png", "", "" ); + CAF_PDM_InitObject( "Grids", ":/draw_style_meshlines_24x24.png" ); - CAF_PDM_InitField( &m_isActive, "IsActive", true, "Show Grid Cells", "", "", "" ); + CAF_PDM_InitField( &m_isActive, "IsActive", true, "Show Grid Cells" ); m_isActive.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_mainGrid, "MainGrid", "Main Grid", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_mainGrid, "MainGrid", "Main Grid" ); m_mainGrid = new RimGridInfo(); m_mainGrid->setUiName( "Main Grid" ); m_mainGrid->uiCapability()->setUiTreeHidden( true ); m_mainGrid->setUiIconFromResourceString( ":/MainGrid16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_persistentLgrs, "PersistentLgrs", "Persistent LGRs", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_persistentLgrs, "PersistentLgrs", "Persistent LGRs" ); m_persistentLgrs = new RimGridInfoCollection(); m_persistentLgrs->setUiName( persistentGridUiName() ); m_persistentLgrs->setUiIconFromResourceString( ":/LGR16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_temporaryLgrs, "TemporaryLgrs", "Temporary LGRs", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_temporaryLgrs, "TemporaryLgrs", "Temporary LGRs" ); m_temporaryLgrs.xmlCapability()->disableIO(); m_temporaryLgrs = new RimGridInfoCollection(); m_temporaryLgrs->setUiName( temporaryGridUiName() ); diff --git a/ApplicationLibCode/ProjectDataModel/RimGridStatisticsPlot.cpp b/ApplicationLibCode/ProjectDataModel/RimGridStatisticsPlot.cpp index 13a9ea8672..2298cf558c 100644 --- a/ApplicationLibCode/ProjectDataModel/RimGridStatisticsPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimGridStatisticsPlot.cpp @@ -53,14 +53,14 @@ RimGridStatisticsPlot::RimGridStatisticsPlot() { CAF_PDM_InitObject( "Grid Statistics Plot", ":/statistics.png", "", "A Plot of Grid Statistics" ); - CAF_PDM_InitFieldNoDefault( &m_case, "Case", "Case", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_case, "Case", "Case" ); m_case.uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitField( &m_timeStep, "TimeStep", -1, "Time Step", "", "", "" ); + CAF_PDM_InitField( &m_timeStep, "TimeStep", -1, "Time Step" ); m_timeStep.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_cellFilterView, "VisibleCellView", "Filter by 3d View Visibility", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_cellFilterView, "VisibleCellView", "Filter by 3d View Visibility" ); - CAF_PDM_InitFieldNoDefault( &m_property, "Property", "Property", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_property, "Property", "Property" ); m_property = new RimEclipseResultDefinition( caf::PdmUiItemInfo::TOP ); m_property.uiCapability()->setUiTreeHidden( true ); m_property.uiCapability()->setUiTreeChildrenHidden( true ); @@ -169,10 +169,9 @@ void RimGridStatisticsPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOr //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList - RimGridStatisticsPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) +QList RimGridStatisticsPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { - QList options = RimStatisticsPlot::calculateValueOptions( fieldNeedingOptions, useOptionsOnly ); + QList options = RimStatisticsPlot::calculateValueOptions( fieldNeedingOptions ); if ( fieldNeedingOptions == &m_case ) { @@ -194,7 +193,7 @@ QList if ( eclipseCase ) { options.push_back( caf::PdmOptionItemInfo( "Disabled", nullptr ) ); - for ( RimEclipseView* view : eclipseCase->reservoirViews.childObjects() ) + for ( RimEclipseView* view : eclipseCase->reservoirViews.children() ) { CVF_ASSERT( view && "Really always should have a valid view pointer in ReservoirViews" ); options.push_back( caf::PdmOptionItemInfo( view->name(), view, false, view->uiIconProvider() ) ); @@ -202,7 +201,6 @@ QList } } - ( *useOptionsOnly ) = true; return options; } diff --git a/ApplicationLibCode/ProjectDataModel/RimGridStatisticsPlot.h b/ApplicationLibCode/ProjectDataModel/RimGridStatisticsPlot.h index 0e60a92a32..d2c6ed1334 100644 --- a/ApplicationLibCode/ProjectDataModel/RimGridStatisticsPlot.h +++ b/ApplicationLibCode/ProjectDataModel/RimGridStatisticsPlot.h @@ -54,8 +54,7 @@ class RimGridStatisticsPlot : public RimStatisticsPlot // Overridden PDM methods void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void initAfterRead() override; diff --git a/ApplicationLibCode/ProjectDataModel/RimGridStatisticsPlotCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimGridStatisticsPlotCollection.cpp index 189289375e..801271794c 100644 --- a/ApplicationLibCode/ProjectDataModel/RimGridStatisticsPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimGridStatisticsPlotCollection.cpp @@ -30,9 +30,9 @@ CAF_PDM_SOURCE_INIT( RimGridStatisticsPlotCollection, "GridStatisticsPlotCollect //-------------------------------------------------------------------------------------------------- RimGridStatisticsPlotCollection::RimGridStatisticsPlotCollection() { - CAF_PDM_InitObject( "Grid Statistics Plots", ":/WellLogPlots16x16.png", "", "" ); + CAF_PDM_InitObject( "Grid Statistics Plots", ":/WellLogPlots16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_gridStatisticsPlots, "GridStatisticsPlots", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_gridStatisticsPlots, "GridStatisticsPlots", "" ); m_gridStatisticsPlots.uiCapability()->setUiTreeHidden( true ); } @@ -68,7 +68,7 @@ void RimGridStatisticsPlotCollection::addGridStatisticsPlot( RimGridStatisticsPl //-------------------------------------------------------------------------------------------------- std::vector RimGridStatisticsPlotCollection::gridStatisticsPlots() const { - return m_gridStatisticsPlots.childObjects(); + return m_gridStatisticsPlots.children(); } //-------------------------------------------------------------------------------------------------- @@ -76,5 +76,5 @@ std::vector RimGridStatisticsPlotCollection::gridStatist //-------------------------------------------------------------------------------------------------- void RimGridStatisticsPlotCollection::deleteAllPlots() { - m_gridStatisticsPlots.deleteAllChildObjects(); + m_gridStatisticsPlots.deleteChildren(); } diff --git a/ApplicationLibCode/ProjectDataModel/RimGridTimeHistoryCurve.cpp b/ApplicationLibCode/ProjectDataModel/RimGridTimeHistoryCurve.cpp index a60e1bd5cc..40fae50a12 100644 --- a/ApplicationLibCode/ProjectDataModel/RimGridTimeHistoryCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimGridTimeHistoryCurve.cpp @@ -52,31 +52,28 @@ CAF_PDM_SOURCE_INIT( RimGridTimeHistoryCurve, "GridTimeHistoryCurve" ); //-------------------------------------------------------------------------------------------------- RimGridTimeHistoryCurve::RimGridTimeHistoryCurve() { - CAF_PDM_InitObject( "Grid Time History Curve", ":/SummaryCurve16x16.png", "", "" ); + CAF_PDM_InitObject( "Grid Time History Curve", ":/SummaryCurve16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_geometrySelectionText, "GeometrySelectionText", "Cell Reference", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_geometrySelectionText, "GeometrySelectionText", "Cell Reference" ); m_geometrySelectionText.registerGetMethod( this, &RimGridTimeHistoryCurve::geometrySelectionText ); m_geometrySelectionText.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitFieldNoDefault( &m_eclipseResultDefinition, "EclipseResultDefinition", "Eclipse Result Definition", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_eclipseResultDefinition, "EclipseResultDefinition", "Eclipse Result Definition" ); m_eclipseResultDefinition.uiCapability()->setUiTreeHidden( true ); m_eclipseResultDefinition.uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_geoMechResultDefinition, "GeoMechResultDefinition", "GeoMech Result Definition", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_geoMechResultDefinition, "GeoMechResultDefinition", "GeoMech Result Definition" ); m_geoMechResultDefinition.uiCapability()->setUiTreeHidden( true ); m_geoMechResultDefinition.uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_geometrySelectionItem, "GeometrySelectionItem", "Geometry Selection", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_geometrySelectionItem, "GeometrySelectionItem", "Geometry Selection" ); m_geometrySelectionItem.uiCapability()->setUiTreeHidden( true ); m_geometrySelectionItem.uiCapability()->setUiTreeChildrenHidden( true ); CAF_PDM_InitField( &m_plotAxis, "PlotAxis", caf::AppEnum( RiaDefines::PlotAxis::PLOT_AXIS_LEFT ), - "Axis", - "", - "", - "" ); + "Axis" ); setDeletable( true ); } @@ -192,9 +189,9 @@ RigGridCellResultAddress RimGridTimeHistoryCurve::resultAddress() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiaDefines::PlotAxis RimGridTimeHistoryCurve::yAxis() const +RiuPlotAxis RimGridTimeHistoryCurve::yAxis() const { - return m_plotAxis(); + return RiuPlotAxis( m_plotAxis() ); } //-------------------------------------------------------------------------------------------------- @@ -381,7 +378,7 @@ void RimGridTimeHistoryCurve::updateZoomInParentPlot() RimSummaryPlot* plot = nullptr; firstAncestorOrThisOfType( plot ); - plot->updateZoomInQwt(); + plot->updateZoomInParentPlot(); } //-------------------------------------------------------------------------------------------------- @@ -391,7 +388,7 @@ void RimGridTimeHistoryCurve::onLoadDataAndUpdate( bool updateParentPlot ) { this->RimPlotCurve::updateCurvePresentation( updateParentPlot ); - if ( isCurveVisible() ) + if ( isCurveVisible() && m_plotCurve ) { std::vector values; @@ -411,18 +408,20 @@ void RimGridTimeHistoryCurve::onLoadDataAndUpdate( bool updateParentPlot ) RimSummaryPlot* plot = nullptr; firstAncestorOrThisOfType( plot ); - bool isLogCurve = plot->isLogarithmicScaleEnabled( this->yAxis() ); + bool useLogarithmicScale = plot->isLogarithmicScaleEnabled( yAxis() ); if ( plot->timeAxisProperties()->timeMode() == RimSummaryTimeAxisProperties::DATE ) { std::vector dateTimes = timeStepValues(); if ( dateTimes.size() > 0 && dateTimes.size() == values.size() ) { - m_qwtPlotCurve->setSamplesFromTimeTAndYValues( dateTimes, values, isLogCurve ); + m_plotCurve->setSamplesFromTimeTAndYValues( dateTimes, values, useLogarithmicScale ); } else { - m_qwtPlotCurve->setSamplesFromTimeTAndYValues( std::vector(), std::vector(), isLogCurve ); + m_plotCurve->setSamplesFromTimeTAndYValues( std::vector(), + std::vector(), + useLogarithmicScale ); } } else @@ -438,17 +437,19 @@ void RimGridTimeHistoryCurve::onLoadDataAndUpdate( bool updateParentPlot ) times.push_back( timeScale * day ); } - m_qwtPlotCurve->setSamplesFromXValuesAndYValues( times, values, isLogCurve ); + m_plotCurve->setSamplesFromXValuesAndYValues( times, values, useLogarithmicScale ); } else { - m_qwtPlotCurve->setSamplesFromTimeTAndYValues( std::vector(), std::vector(), isLogCurve ); + m_plotCurve->setSamplesFromTimeTAndYValues( std::vector(), + std::vector(), + useLogarithmicScale ); } } updateZoomInParentPlot(); - if ( m_parentQwtPlot ) m_parentQwtPlot->replot(); + if ( m_parentPlot ) m_parentPlot->replot(); updateQwtPlotAxis(); plot->updateAxes(); @@ -711,17 +712,7 @@ QString RimGridTimeHistoryCurve::geometrySelectionText() const //-------------------------------------------------------------------------------------------------- void RimGridTimeHistoryCurve::updateQwtPlotAxis() { - if ( m_qwtPlotCurve ) - { - if ( this->yAxis() == RiaDefines::PlotAxis::PLOT_AXIS_LEFT ) - { - m_qwtPlotCurve->setYAxis( QwtPlot::yLeft ); - } - else - { - m_qwtPlotCurve->setYAxis( QwtPlot::yRight ); - } - } + if ( m_plotCurve ) updateAxisInPlot( yAxis() ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimGridTimeHistoryCurve.h b/ApplicationLibCode/ProjectDataModel/RimGridTimeHistoryCurve.h index e6a4f3622b..88c68b9f35 100644 --- a/ApplicationLibCode/ProjectDataModel/RimGridTimeHistoryCurve.h +++ b/ApplicationLibCode/ProjectDataModel/RimGridTimeHistoryCurve.h @@ -53,15 +53,15 @@ class RimGridTimeHistoryCurve : public RimPlotCurve RimGridTimeHistoryCurve(); ~RimGridTimeHistoryCurve() override; - void setFromSelectionItem( const RiuSelectionItem* selectionItem ); - void setFromEclipseCellAndResult( RimEclipseCase* eclCase, - size_t gridIdx, - size_t i, - size_t j, - size_t k, - const RigEclipseResultAddress& resAddr ); - RiaDefines::PlotAxis yAxis() const; - void setYAxis( RiaDefines::PlotAxis plotAxis ); + void setFromSelectionItem( const RiuSelectionItem* selectionItem ); + void setFromEclipseCellAndResult( RimEclipseCase* eclCase, + size_t gridIdx, + size_t i, + size_t j, + size_t k, + const RigEclipseResultAddress& resAddr ); + RiuPlotAxis yAxis() const; + void setYAxis( RiaDefines::PlotAxis plotAxis ); std::vector yValues() const; std::vector timeStepValues() const; diff --git a/ApplicationLibCode/ProjectDataModel/RimGridView.cpp b/ApplicationLibCode/ProjectDataModel/RimGridView.cpp index 3ee1080ac2..3301ded5e8 100644 --- a/ApplicationLibCode/ProjectDataModel/RimGridView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimGridView.cpp @@ -66,53 +66,43 @@ CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimGridView, "GenericGridView" ); // Do not us //-------------------------------------------------------------------------------------------------- RimGridView::RimGridView() { - CAF_PDM_InitFieldNoDefault( &m_overrideCellFilterCollection, - "CellFiltersControlled", - "Cell Filters (controlled)", - "", - "", - "" ); + CAF_PDM_InitFieldNoDefault( &m_overrideCellFilterCollection, "CellFiltersControlled", "Cell Filters (controlled)" ); m_overrideCellFilterCollection.uiCapability()->setUiTreeHidden( true ); m_overrideCellFilterCollection.xmlCapability()->disableIO(); - CAF_PDM_InitFieldNoDefault( &m_intersectionCollection, "CrossSections", "Intersections", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_intersectionCollection, "CrossSections", "Intersections" ); m_intersectionCollection.uiCapability()->setUiTreeHidden( true ); m_intersectionCollection = new RimIntersectionCollection(); - CAF_PDM_InitFieldNoDefault( &m_intersectionResultDefCollection, - "IntersectionResultDefColl", - "Intersection Results", - "", - "", - "" ); + CAF_PDM_InitFieldNoDefault( &m_intersectionResultDefCollection, "IntersectionResultDefColl", "Intersection Results" ); m_intersectionResultDefCollection.uiCapability()->setUiTreeHidden( true ); m_intersectionResultDefCollection = new RimIntersectionResultsDefinitionCollection; - CAF_PDM_InitFieldNoDefault( &m_surfaceResultDefCollection, "ReservoirSurfaceResultDefColl", "Surface Results", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_surfaceResultDefCollection, "ReservoirSurfaceResultDefColl", "Surface Results" ); m_surfaceResultDefCollection.uiCapability()->setUiTreeHidden( true ); m_surfaceResultDefCollection = new RimIntersectionResultsDefinitionCollection; m_surfaceResultDefCollection->uiCapability()->setUiName( "Surface Results" ); m_surfaceResultDefCollection->uiCapability()->setUiIcon( caf::IconProvider( ":/ReservoirSurface16x16.png" ) ); - CAF_PDM_InitFieldNoDefault( &m_gridCollection, "GridCollection", "GridCollection", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_gridCollection, "GridCollection", "GridCollection" ); m_gridCollection.uiCapability()->setUiTreeHidden( true ); m_gridCollection = new RimGridCollection(); m_previousGridModeMeshLinesWasFaults = false; - CAF_PDM_InitFieldNoDefault( &m_overlayInfoConfig, "OverlayInfoConfig", "Info Box", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_overlayInfoConfig, "OverlayInfoConfig", "Info Box" ); m_overlayInfoConfig = new Rim3dOverlayInfoConfig(); m_overlayInfoConfig->setReservoirView( this ); m_overlayInfoConfig.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_wellMeasurementCollection, "WellMeasurements", "Well Measurements", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wellMeasurementCollection, "WellMeasurements", "Well Measurements" ); m_wellMeasurementCollection = new RimWellMeasurementInViewCollection; m_wellMeasurementCollection.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_surfaceCollection, "SurfaceInViewCollection", "Surface Collection Field", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_surfaceCollection, "SurfaceInViewCollection", "Surface Collection Field" ); m_surfaceCollection.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_cellFilterCollection, "RangeFilters", "Cell Filter Collection Field", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_cellFilterCollection, "RangeFilters", "Cell Filter Collection Field" ); m_cellFilterCollection = new RimCellFilterCollection(); m_cellFilterCollection.uiCapability()->setUiTreeHidden( true ); @@ -309,7 +299,7 @@ void RimGridView::replaceCellFilterCollectionWithOverride() // Must call removeChildObject() to make sure the object has no parent // No parent is required when assigning a object into a field - m_overrideCellFilterCollection.removeChildObject( overrideRfc ); + m_overrideCellFilterCollection.removeChild( overrideRfc ); m_cellFilterCollection = overrideRfc; diff --git a/ApplicationLibCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationLibCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index f497df464d..63836de8b0 100644 --- a/ApplicationLibCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -61,21 +61,18 @@ RimIdenticalGridCaseGroup::RimIdenticalGridCaseGroup() "GridCaseGroup", "A statistics case group" ); - CAF_PDM_InitScriptableField( &name, "UserDescription", QString( "Grid Case Group" ), "Name", "", "", "" ); + CAF_PDM_InitScriptableField( &name, "UserDescription", QString( "Grid Case Group" ), "Name" ); - CAF_PDM_InitScriptableField( &groupId, "GroupId", -1, "Case Group ID", "", "", "" ); + CAF_PDM_InitScriptableField( &groupId, "GroupId", -1, "Case Group ID" ); groupId.uiCapability()->setUiReadOnly( true ); groupId.capability()->setIOWriteable( false ); CAF_PDM_InitFieldNoDefault( &statisticsCaseCollection, "StatisticsCaseCollection", - "statisticsCaseCollection ChildArrayField", - "", - "", - "" ); + "statisticsCaseCollection ChildArrayField" ); statisticsCaseCollection.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &caseCollection, "CaseCollection", "Source Cases ChildArrayField", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &caseCollection, "CaseCollection", "Source Cases ChildArrayField" ); caseCollection.uiCapability()->setUiTreeHidden( true ); caseCollection = new RimCaseCollection; @@ -143,7 +140,7 @@ void RimIdenticalGridCaseGroup::removeCase( RimEclipseCase* reservoir ) return; } - caseCollection()->reservoirs().removeChildObject( reservoir ); + caseCollection()->reservoirs().removeChild( reservoir ); if ( caseCollection()->reservoirs().size() == 0 ) { @@ -247,9 +244,7 @@ void RimIdenticalGridCaseGroup::loadMainCaseAndActiveCellInfo() computeUnionOfActiveCells(); } - RigCaseCellResultsData::copyResultsMetaDataFromMainCase( rigCaseData, - poroModel, - caseCollection->reservoirs.childObjects() ); + RigCaseCellResultsData::copyResultsMetaDataFromMainCase( rigCaseData, poroModel, caseCollection->reservoirs.children() ); // "Load" the statistical cases diff --git a/ApplicationLibCode/ProjectDataModel/RimMainPlotCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimMainPlotCollection.cpp index b7362f57ad..9f6e42d5c4 100644 --- a/ApplicationLibCode/ProjectDataModel/RimMainPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimMainPlotCollection.cpp @@ -19,6 +19,10 @@ #include "RimMainPlotCollection.h" +#include "RiaPlotCollectionScheduler.h" + +#include "PlotBuilderCommands/RicSummaryPlotBuilder.h" + #include "RimAbstractPlotCollection.h" #include "RimAnalysisPlotCollection.h" #include "RimCorrelationPlotCollection.h" @@ -38,6 +42,7 @@ #include "RimStimPlanModelPlotCollection.h" #include "RimSummaryAddress.h" #include "RimSummaryCrossPlotCollection.h" +#include "RimSummaryMultiPlotCollection.h" #include "RimSummaryPlotCollection.h" #include "RimVfpPlotCollection.h" #include "RimViewWindow.h" @@ -65,71 +70,63 @@ CAF_PDM_SOURCE_INIT( RimMainPlotCollection, "MainPlotCollection" ); //-------------------------------------------------------------------------------------------------- RimMainPlotCollection::RimMainPlotCollection() { - CAF_PDM_InitObject( "Plots", "", "", "" ); + CAF_PDM_InitObject( "Plots" ); - CAF_PDM_InitField( &m_show, "Show", true, "Show 2D Plot Window", "", "", "" ); + CAF_PDM_InitField( &m_show, "Show", true, "Show 2D Plot Window" ); m_show.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_wellLogPlotCollection, "WellLogPlotCollection", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wellLogPlotCollection, "WellLogPlotCollection", "" ); m_wellLogPlotCollection.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_rftPlotCollection, "RftPlotCollection", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_rftPlotCollection, "RftPlotCollection", "" ); m_rftPlotCollection.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_pltPlotCollection, "PltPlotCollection", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_pltPlotCollection, "PltPlotCollection", "" ); m_pltPlotCollection.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_summaryPlotCollection, "SummaryPlotCollection", "Summary Plots", "", "", "" ); - m_summaryPlotCollection.uiCapability()->setUiTreeHidden( true ); + CAF_PDM_InitFieldNoDefault( &m_summaryMultiPlotCollection, "SummaryMultiPlotCollection", "Multi Summary Plots" ); + m_summaryMultiPlotCollection.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_analysisPlotCollection, "AnalysisPlotCollection", "Analysis Plots", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_analysisPlotCollection, "AnalysisPlotCollection", "Analysis Plots" ); m_analysisPlotCollection.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_correlationPlotCollection, "CorrelationPlotCollection", "Correlation Plots", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_correlationPlotCollection, "CorrelationPlotCollection", "Correlation Plots" ); m_correlationPlotCollection.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_summaryCrossPlotCollection, "SummaryCrossPlotCollection", "Summary Cross Plots", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_summaryCrossPlotCollection, "SummaryCrossPlotCollection", "Summary Cross Plots" ); m_summaryCrossPlotCollection.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_flowPlotCollection, "FlowPlotCollection", "Flow Diagnostics Plots", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_flowPlotCollection, "FlowPlotCollection", "Flow Diagnostics Plots" ); m_flowPlotCollection.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_gridCrossPlotCollection, "Rim3dCrossPlotCollection", "3d Cross Plots", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_gridCrossPlotCollection, "Rim3dCrossPlotCollection", "3d Cross Plots" ); m_gridCrossPlotCollection.uiCapability()->setUiTreeHidden( true ); CAF_PDM_InitFieldNoDefault( &m_saturationPressurePlotCollection, "RimSaturationPressurePlotCollection", - "Saturation Pressure Plots", - "", - "", - "" ); + "Saturation Pressure Plots" ); m_saturationPressurePlotCollection.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_multiPlotCollection, "RimMultiPlotCollection", "Multi Plots", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_multiPlotCollection, "RimMultiPlotCollection", "Multi Plots" ); m_multiPlotCollection.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_stimPlanModelPlotCollection, "StimPlanModelPlotCollection", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_stimPlanModelPlotCollection, "StimPlanModelPlotCollection", "" ); m_stimPlanModelPlotCollection.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_vfpPlotCollection, "VfpPlotCollection", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_vfpPlotCollection, "VfpPlotCollection", "" ); m_vfpPlotCollection.uiCapability()->setUiTreeHidden( true ); #ifdef USE_QTCHARTS - CAF_PDM_InitFieldNoDefault( &m_gridStatisticsPlotCollection, "GridStatisticsPlotCollection", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_gridStatisticsPlotCollection, "GridStatisticsPlotCollection", "" ); m_gridStatisticsPlotCollection.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_ensembleFractureStatisticsPlotCollection, - "EnsembleFractureStatisticsPlotCollection", - "", - "", - "", - "" ); + CAF_PDM_InitFieldNoDefault( &m_ensembleFractureStatisticsPlotCollection, "EnsembleFractureStatisticsPlotCollection", "" ); m_ensembleFractureStatisticsPlotCollection.uiCapability()->setUiTreeHidden( true ); #endif m_wellLogPlotCollection = new RimWellLogPlotCollection(); m_rftPlotCollection = new RimRftPlotCollection(); m_pltPlotCollection = new RimPltPlotCollection(); - m_summaryPlotCollection = new RimSummaryPlotCollection(); + m_summaryMultiPlotCollection = new RimSummaryMultiPlotCollection(); m_summaryCrossPlotCollection = new RimSummaryCrossPlotCollection(); m_flowPlotCollection = new RimFlowPlotCollection(); m_gridCrossPlotCollection = new RimGridCrossPlotCollection; @@ -143,6 +140,11 @@ RimMainPlotCollection::RimMainPlotCollection() m_gridStatisticsPlotCollection = new RimGridStatisticsPlotCollection; m_ensembleFractureStatisticsPlotCollection = new RimEnsembleFractureStatisticsPlotCollection; #endif + + CAF_PDM_InitFieldNoDefault( &m_summaryPlotCollection_OBSOLETE, "SummaryPlotCollection", "Summary Plots" ); + m_summaryPlotCollection_OBSOLETE.uiCapability()->setUiTreeHidden( true ); + m_summaryPlotCollection_OBSOLETE.xmlCapability()->setIOWritable( false ); + m_summaryPlotCollection_OBSOLETE = new RimSummaryPlotCollection(); } //-------------------------------------------------------------------------------------------------- @@ -152,6 +154,25 @@ RimMainPlotCollection::~RimMainPlotCollection() { } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimMainPlotCollection::initAfterRead() +{ + std::vector plotsToMove; + for ( auto singlePlot : m_summaryPlotCollection_OBSOLETE()->plots() ) + { + plotsToMove.push_back( singlePlot ); + } + + for ( auto singlePlot : plotsToMove ) + { + m_summaryPlotCollection_OBSOLETE()->removePlot( singlePlot ); + + RicSummaryPlotBuilder::createAndAppendSingleSummaryMultiPlotNoAutoSettings( singlePlot ); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -196,9 +217,9 @@ RimPltPlotCollection* RimMainPlotCollection::pltPlotCollection() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryPlotCollection* RimMainPlotCollection::summaryPlotCollection() const +RimSummaryMultiPlotCollection* RimMainPlotCollection::summaryMultiPlotCollection() const { - return m_summaryPlotCollection(); + return m_summaryMultiPlotCollection(); } //-------------------------------------------------------------------------------------------------- @@ -321,10 +342,11 @@ void RimMainPlotCollection::updatePlotsWithFormations() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimMainPlotCollection::updatePlotsWithCompletions() +void RimMainPlotCollection::scheduleUpdatePlotsWithCompletions() { std::vector plotCollections = plotCollectionsWithCompletions(); - loadDataAndUpdatePlotCollections( plotCollections ); + + RiaPlotCollectionScheduler::instance()->schedulePlotCollectionUpdate( plotCollections ); } //-------------------------------------------------------------------------------------------------- @@ -355,7 +377,7 @@ void RimMainPlotCollection::ensureCalculationIdsAreAssigned() for ( RimSummaryAddress* adr : allAddresses ) { - adr->ensureIdIsAssigned(); + adr->ensureCalculationIdIsAssigned(); } } @@ -410,7 +432,7 @@ std::vector RimMainPlotCollection::allPlotCollections() cons { std::vector plotCollections; plotCollections.push_back( wellLogPlotCollection() ); - plotCollections.push_back( summaryPlotCollection() ); + plotCollections.push_back( summaryMultiPlotCollection() ); plotCollections.push_back( summaryCrossPlotCollection() ); plotCollections.push_back( gridCrossPlotCollection() ); plotCollections.push_back( analysisPlotCollection() ); diff --git a/ApplicationLibCode/ProjectDataModel/RimMainPlotCollection.h b/ApplicationLibCode/ProjectDataModel/RimMainPlotCollection.h index 8dcf15bcda..9114c8da08 100644 --- a/ApplicationLibCode/ProjectDataModel/RimMainPlotCollection.h +++ b/ApplicationLibCode/ProjectDataModel/RimMainPlotCollection.h @@ -33,9 +33,10 @@ class RimRftPlotCollection; class RimPltPlotCollection; class RimGridCrossPlotCollection; class RimMultiPlotCollection; -class RimSummaryPlotCollection; +class RimSummaryMultiPlotCollection; class RimSummaryCrossPlotCollection; class RimSummaryPlot; +class RimSummaryPlotCollection; class RifReaderEclipseSummary; class RimEclipseResultCase; class RimFlowPlotCollection; @@ -64,7 +65,7 @@ class RimMainPlotCollection : public caf::PdmObject RimWellLogPlotCollection* wellLogPlotCollection() const; RimRftPlotCollection* rftPlotCollection() const; RimPltPlotCollection* pltPlotCollection() const; - RimSummaryPlotCollection* summaryPlotCollection() const; + RimSummaryMultiPlotCollection* summaryMultiPlotCollection() const; RimSummaryCrossPlotCollection* summaryCrossPlotCollection() const; RimAnalysisPlotCollection* analysisPlotCollection() const; RimCorrelationPlotCollection* correlationPlotCollection() const; @@ -83,12 +84,15 @@ class RimMainPlotCollection : public caf::PdmObject void deleteAllContainedObjects(); void updateCurrentTimeStepInPlots(); void updatePlotsWithFormations(); - void updatePlotsWithCompletions(); + void scheduleUpdatePlotsWithCompletions(); void deleteAllCachedData(); void ensureDefaultFlowPlotsAreCreated(); void ensureCalculationIdsAreAssigned(); void loadDataAndUpdateAllPlots(); +protected: + void initAfterRead() override; + private: // Overridden PDM methods caf::PdmFieldHandle* objectToggleField() override; @@ -104,7 +108,7 @@ class RimMainPlotCollection : public caf::PdmObject caf::PdmChildField m_wellLogPlotCollection; caf::PdmChildField m_rftPlotCollection; caf::PdmChildField m_pltPlotCollection; - caf::PdmChildField m_summaryPlotCollection; + caf::PdmChildField m_summaryMultiPlotCollection; caf::PdmChildField m_summaryCrossPlotCollection; caf::PdmChildField m_analysisPlotCollection; caf::PdmChildField m_correlationPlotCollection; @@ -120,4 +124,6 @@ class RimMainPlotCollection : public caf::PdmObject #endif caf::PdmField m_show; + + caf::PdmChildField m_summaryPlotCollection_OBSOLETE; }; diff --git a/ApplicationLibCode/ProjectDataModel/RimMdiWindowController.cpp b/ApplicationLibCode/ProjectDataModel/RimMdiWindowController.cpp index 1f17416736..3dc1efc4fe 100644 --- a/ApplicationLibCode/ProjectDataModel/RimMdiWindowController.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimMdiWindowController.cpp @@ -32,12 +32,12 @@ CAF_PDM_XML_SOURCE_INIT( RimMdiWindowController, "MdiWindowController" ); //-------------------------------------------------------------------------------------------------- RimMdiWindowController::RimMdiWindowController() { - CAF_PDM_InitField( &m_mainWindowID, "MainWindowID", -1, "", "", "", "" ); - CAF_PDM_InitField( &m_x, "xPos", -1, "", "", "", "" ); - CAF_PDM_InitField( &m_y, "yPos", -1, "", "", "", "" ); - CAF_PDM_InitField( &m_width, "Width", -1, "", "", "", "" ); - CAF_PDM_InitField( &m_height, "Height", -1, "", "", "", "" ); - CAF_PDM_InitField( &m_isMaximized, "IsMaximized", false, "", "", "", "" ); + CAF_PDM_InitField( &m_mainWindowID, "MainWindowID", -1, "" ); + CAF_PDM_InitField( &m_x, "xPos", -1, "" ); + CAF_PDM_InitField( &m_y, "yPos", -1, "" ); + CAF_PDM_InitField( &m_width, "Width", -1, "" ); + CAF_PDM_InitField( &m_height, "Height", -1, "" ); + CAF_PDM_InitField( &m_isMaximized, "IsMaximized", false, "" ); } //-------------------------------------------------------------------------------------------------- @@ -100,6 +100,7 @@ void RimMdiWindowController::removeWindowFromMDI() if ( mainWin && viewWidget() ) { mainWin->removeViewer( viewWidget() ); + viewPdmObject()->deleteViewWidget(); } } diff --git a/ApplicationLibCode/ProjectDataModel/RimMockModelSettings.cpp b/ApplicationLibCode/ProjectDataModel/RimMockModelSettings.cpp index c49bae505a..3c91978278 100644 --- a/ApplicationLibCode/ProjectDataModel/RimMockModelSettings.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimMockModelSettings.cpp @@ -26,17 +26,17 @@ CAF_PDM_SOURCE_INIT( RimMockModelSettings, "MockModelSettings" ); //-------------------------------------------------------------------------------------------------- RimMockModelSettings::RimMockModelSettings() { - CAF_PDM_InitObject( "Mock Model Settings", "", "", "" ); + CAF_PDM_InitObject( "Mock Model Settings" ); - CAF_PDM_InitField( &cellCountX, "CellCountX", quint64( 100 ), "Cell Count X", "", "", "" ); - CAF_PDM_InitField( &cellCountY, "CellCountY", quint64( 100 ), "Cell Count Y", "", "", "" ); - CAF_PDM_InitField( &cellCountZ, "CellCountZ", quint64( 10 ), "Cell Count Z", "", "", "" ); + CAF_PDM_InitField( &cellCountX, "CellCountX", quint64( 100 ), "Cell Count X" ); + CAF_PDM_InitField( &cellCountY, "CellCountY", quint64( 100 ), "Cell Count Y" ); + CAF_PDM_InitField( &cellCountZ, "CellCountZ", quint64( 10 ), "Cell Count Z" ); - CAF_PDM_InitFieldNoDefault( &totalCellCount, "TotalCellCount", "Total Cell Count", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &totalCellCount, "TotalCellCount", "Total Cell Count" ); totalCellCount.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitField( &resultCount, "ResultCount", quint64( 3 ), "Result Count", "", "", "" ); - CAF_PDM_InitField( &timeStepCount, "TimeStepCount", quint64( 10 ), "Time Step Count", "", "", "" ); + CAF_PDM_InitField( &resultCount, "ResultCount", quint64( 3 ), "Result Count" ); + CAF_PDM_InitField( &timeStepCount, "TimeStepCount", quint64( 10 ), "Time Step Count" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimMudWeightWindowParameters.cpp b/ApplicationLibCode/ProjectDataModel/RimMudWeightWindowParameters.cpp index b0f29e0d6a..6edae132a8 100644 --- a/ApplicationLibCode/ProjectDataModel/RimMudWeightWindowParameters.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimMudWeightWindowParameters.cpp @@ -115,47 +115,47 @@ RimMudWeightWindowParameters::RimMudWeightWindowParameters( void ) caf::AppEnum defaultSourceType = RimMudWeightWindowParameters::SourceType::FIXED; - CAF_PDM_InitField( &m_wellDeviationType, "WellDeviationSourceType", defaultSourceType, "Well Deviation", "", "", "" ); - CAF_PDM_InitField( &m_wellDeviationFixed, "WellDeviationFixed", 0.0, "Fixed Well Deviation", "", "", "" ); + CAF_PDM_InitField( &m_wellDeviationType, "WellDeviationSourceType", defaultSourceType, "Well Deviation" ); + CAF_PDM_InitField( &m_wellDeviationFixed, "WellDeviationFixed", 0.0, "Fixed Well Deviation" ); m_wellDeviationFixed.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_wellDeviationAddress, "WellDeviationAddress", QString( "" ), "Value", "", "", "" ); + CAF_PDM_InitField( &m_wellDeviationAddress, "WellDeviationAddress", QString( "" ), "Value" ); m_wellDeviationAddress.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_wellAzimuthType, "WellAzimuthSourceType", defaultSourceType, "Well Azimuth", "", "", "" ); - CAF_PDM_InitField( &m_wellAzimuthFixed, "WellAzimuthFixed", 0.0, "Fixed Well Azimuth", "", "", "" ); + CAF_PDM_InitField( &m_wellAzimuthType, "WellAzimuthSourceType", defaultSourceType, "Well Azimuth" ); + CAF_PDM_InitField( &m_wellAzimuthFixed, "WellAzimuthFixed", 0.0, "Fixed Well Azimuth" ); m_wellAzimuthFixed.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_wellAzimuthAddress, "WellAzimuthAddress", QString( "" ), "Value", "", "", "" ); + CAF_PDM_InitField( &m_wellAzimuthAddress, "WellAzimuthAddress", QString( "" ), "Value" ); m_wellAzimuthAddress.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_UCSType, "UCSSourceType", defaultSourceType, "UCS [Bar]", "", "", "" ); - CAF_PDM_InitField( &m_UCSFixed, "UCSFixed", 100.0, "Fixed UCS [Bar]", "", "", "" ); + CAF_PDM_InitField( &m_UCSType, "UCSSourceType", defaultSourceType, "UCS [Bar]" ); + CAF_PDM_InitField( &m_UCSFixed, "UCSFixed", 100.0, "Fixed UCS [Bar]" ); m_UCSFixed.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_UCSAddress, "UCSAddress", QString( "" ), "Value", "", "", "" ); + CAF_PDM_InitField( &m_UCSAddress, "UCSAddress", QString( "" ), "Value" ); m_UCSAddress.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_poissonsRatioType, "PoissonsRatioSourceType", defaultSourceType, "Poisson's Ratio", "", "", "" ); - CAF_PDM_InitField( &m_poissonsRatioFixed, "PoissonsRatioFixed", 0.35, "Fixed Possion's Ratio", "", "", "" ); + CAF_PDM_InitField( &m_poissonsRatioType, "PoissonsRatioSourceType", defaultSourceType, "Poisson's Ratio" ); + CAF_PDM_InitField( &m_poissonsRatioFixed, "PoissonsRatioFixed", 0.35, "Fixed Possion's Ratio" ); m_poissonsRatioFixed.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_poissonsRatioAddress, "PoissonsRatioAddress", QString( "" ), "Value", "", "", "" ); + CAF_PDM_InitField( &m_poissonsRatioAddress, "PoissonsRatioAddress", QString( "" ), "Value" ); m_poissonsRatioAddress.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_K0_FGType, "K0_FGSourceType", defaultSourceType, "K0 FG", "", "", "" ); - CAF_PDM_InitField( &m_K0_FGFixed, "K0_FGFixed", 0.75, "Fixed K0_FG", "", "", "" ); + CAF_PDM_InitField( &m_K0_FGType, "K0_FGSourceType", defaultSourceType, "K0 FG" ); + CAF_PDM_InitField( &m_K0_FGFixed, "K0_FGFixed", 0.75, "Fixed K0_FG" ); m_K0_FGFixed.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_K0_FGAddress, "K0_FGAddress", QString( "" ), "Value", "", "", "" ); + CAF_PDM_InitField( &m_K0_FGAddress, "K0_FGAddress", QString( "" ), "Value" ); m_K0_FGAddress.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() ); caf::AppEnum defaultOBG0SourceType = RimMudWeightWindowParameters::SourceType::GRID; - CAF_PDM_InitField( &m_obg0Type, "obg0SourceType", defaultOBG0SourceType, "Initial Overburden Gradient", "", "", "" ); - CAF_PDM_InitField( &m_obg0Fixed, "obg0Fixed", 0.75, "Fixed Initial Overburden Gradient", "", "", "" ); + CAF_PDM_InitField( &m_obg0Type, "obg0SourceType", defaultOBG0SourceType, "Initial Overburden Gradient" ); + CAF_PDM_InitField( &m_obg0Fixed, "obg0Fixed", 0.75, "Fixed Initial Overburden Gradient" ); m_obg0Fixed.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_obg0Address, "obg0Address", QString( "" ), "Value", "", "", "" ); + CAF_PDM_InitField( &m_obg0Address, "obg0Address", QString( "" ), "Value" ); m_obg0Address.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() ); m_parameterFields[RimMudWeightWindowParameters::ParameterType::WELL_DEVIATION] = @@ -171,26 +171,23 @@ RimMudWeightWindowParameters::RimMudWeightWindowParameters( void ) m_parameterFields[RimMudWeightWindowParameters::ParameterType::OBG0] = std::make_tuple( &m_obg0Type, &m_obg0Fixed, &m_obg0Address ); - CAF_PDM_InitField( &m_airGap, "AirGap", 0.0, "Air Gap", "", "", "" ); + CAF_PDM_InitField( &m_airGap, "AirGap", 0.0, "Air Gap" ); - CAF_PDM_InitField( &m_shMultiplier, "SHMultiplier", 1.05, "SH Multplier for FG in Shale", "", "", "" ); + CAF_PDM_InitField( &m_shMultiplier, "SHMultiplier", 1.05, "SH Multplier for FG in Shale" ); caf::AppEnum defaultUpperLimitType = RimMudWeightWindowParameters::UpperLimitType::FG; - CAF_PDM_InitField( &m_upperLimitType, "UpperLimitType", defaultUpperLimitType, "Upper Limit Type", "", "", "" ); + CAF_PDM_InitField( &m_upperLimitType, "UpperLimitType", defaultUpperLimitType, "Upper Limit Type" ); caf::AppEnum defaultLowerLimitType = RimMudWeightWindowParameters::LowerLimitType::MAX_OF_PORE_PRESSURE_AND_SFG; - CAF_PDM_InitField( &m_lowerLimitType, "LowerLimitType", defaultLowerLimitType, "Lower Limit Type", "", "", "" ); + CAF_PDM_InitField( &m_lowerLimitType, "LowerLimitType", defaultLowerLimitType, "Lower Limit Type" ); caf::AppEnum defaultFractureGradientCalculationType = RimMudWeightWindowParameters::FractureGradientCalculationType::DERIVED_FROM_K0FG; CAF_PDM_InitField( &m_fractureGradientCalculationType, "FractureGradientCalculationType", defaultFractureGradientCalculationType, - "FG in Shale Calculation", - "", - "", - "" ); + "FG in Shale Calculation" ); caf::AppEnum defaultNonReservoirPorePressureType = RimMudWeightWindowParameters::NonReservoirPorePressureType::HYDROSTATIC; @@ -201,11 +198,11 @@ RimMudWeightWindowParameters::RimMudWeightWindowParameters( void ) "", "Data source for Non-Reservoir Pore Pressure", "" ); - CAF_PDM_InitField( &m_userDefinedPPNonReservoir, "UserPPNonReservoir", 1.0, " Multiplier of hydrostatic PP", "", "", "" ); - CAF_PDM_InitField( &m_porePressureNonReservoirAddress, "PPNonReservoirAddress", QString( "" ), "Value", "", "", "" ); + CAF_PDM_InitField( &m_userDefinedPPNonReservoir, "UserPPNonReservoir", 1.0, " Multiplier of hydrostatic PP" ); + CAF_PDM_InitField( &m_porePressureNonReservoirAddress, "PPNonReservoirAddress", QString( "" ), "Value" ); m_porePressureNonReservoirAddress.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_referenceLayer, "ReferenceLayer", -1, "Reference Layer", "", "", "" ); + CAF_PDM_InitField( &m_referenceLayer, "ReferenceLayer", -1, "Reference Layer" ); } //-------------------------------------------------------------------------------------------------- @@ -567,8 +564,7 @@ void RimMudWeightWindowParameters::defineEditorAttribute( const caf::PdmFieldHan /// //-------------------------------------------------------------------------------------------------- QList - RimMudWeightWindowParameters::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) + RimMudWeightWindowParameters::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; diff --git a/ApplicationLibCode/ProjectDataModel/RimMudWeightWindowParameters.h b/ApplicationLibCode/ProjectDataModel/RimMudWeightWindowParameters.h index 496cab3f5e..64135fd99c 100644 --- a/ApplicationLibCode/ProjectDataModel/RimMudWeightWindowParameters.h +++ b/ApplicationLibCode/ProjectDataModel/RimMudWeightWindowParameters.h @@ -109,8 +109,7 @@ class RimMudWeightWindowParameters : public caf::PdmObject QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineGroup( caf::PdmUiOrdering& uiOrdering, const QString& title, diff --git a/ApplicationLibCode/ProjectDataModel/RimMultiPlot.cpp b/ApplicationLibCode/ProjectDataModel/RimMultiPlot.cpp index 385a7fd703..aac63f88a2 100644 --- a/ApplicationLibCode/ProjectDataModel/RimMultiPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimMultiPlot.cpp @@ -19,6 +19,8 @@ #include "RimMultiPlot.h" #include "RiaPreferences.h" +#include "RiaPreferencesSummary.h" +#include "RiaVersionInfo.h" #include "RimPlot.h" #include "RimProject.h" @@ -37,57 +39,41 @@ #include -namespace caf -{ -template <> -void RimMultiPlot::ColumnCountEnum::setUp() -{ - addItem( RimMultiPlot::ColumnCount::COLUMNS_1, "1", "1 Column" ); - addItem( RimMultiPlot::ColumnCount::COLUMNS_2, "2", "2 Columns" ); - addItem( RimMultiPlot::ColumnCount::COLUMNS_3, "3", "3 Columns" ); - addItem( RimMultiPlot::ColumnCount::COLUMNS_4, "4", "4 Columns" ); - addItem( RimMultiPlot::ColumnCount::COLUMNS_UNLIMITED, "UNLIMITED", "Unlimited" ); - setDefault( RimMultiPlot::ColumnCount::COLUMNS_2 ); -} -template <> -void RimMultiPlot::RowCountEnum::setUp() -{ - addItem( RimMultiPlot::ROWS_1, "1", "1 Row" ); - addItem( RimMultiPlot::ROWS_2, "2", "2 Rows" ); - addItem( RimMultiPlot::ROWS_3, "3", "3 Rows" ); - addItem( RimMultiPlot::ROWS_4, "4", "4 Rows" ); - setDefault( RimMultiPlot::ROWS_2 ); -} - -} // namespace caf - CAF_PDM_SOURCE_INIT( RimMultiPlot, "MultiPlot" ); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RimMultiPlot::RimMultiPlot() + : m_isValid( true ) + , m_delayPlotUpdatesDuringBatchAdd( false ) { - CAF_PDM_InitObject( "Multi Plot", ":/MultiPlot16x16.png", "", "" ); + CAF_PDM_InitObject( "Multi Plot", ":/MultiPlot16x16.png" ); - CAF_PDM_InitField( &m_showPlotWindowTitle, "ShowTitleInPlot", true, "Show Title", "", "", "" ); - CAF_PDM_InitField( &m_plotWindowTitle, "PlotDescription", QString( "" ), "Name", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_projectFileVersionString, "ProjectFileVersionString", "" ); + m_projectFileVersionString.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_plots, "Plots", "", "", "", "" ); + CAF_PDM_InitField( &m_showPlotWindowTitle, "ShowTitleInPlot", true, "Show Title" ); + CAF_PDM_InitField( &m_plotWindowTitle, "PlotDescription", QString( "" ), "Name" ); + + CAF_PDM_InitFieldNoDefault( &m_plots, "Plots", "" ); m_plots.uiCapability()->setUiTreeHidden( true ); auto reorderability = caf::PdmFieldReorderCapability::addToField( &m_plots ); reorderability->orderChanged.connect( this, &RimMultiPlot::onPlotsReordered ); - CAF_PDM_InitFieldNoDefault( &m_columnCount, "NumberOfColumns", "Number of Columns", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_rowsPerPage, "RowsPerPage", "Rows per Page", "", "", "" ); + RiaPreferencesSummary* sumPrefs = RiaPreferencesSummary::current(); + CAF_PDM_InitFieldNoDefault( &m_columnCount, "NumberOfColumns", "Number of Columns" ); + m_columnCount = sumPrefs->defaultMultiPlotColumnCount(); + CAF_PDM_InitFieldNoDefault( &m_rowsPerPage, "RowsPerPage", "Rows per Page" ); + m_rowsPerPage = sumPrefs->defaultMultiPlotRowCount(); - CAF_PDM_InitField( &m_showIndividualPlotTitles, "ShowPlotTitles", true, "Show Sub Plot Titles", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_majorTickmarkCount, "MajorTickmarkCount", "Major Tickmark Count", "", "", "" ); + CAF_PDM_InitField( &m_showIndividualPlotTitles, "ShowPlotTitles", true, "Show Sub Plot Titles" ); + CAF_PDM_InitFieldNoDefault( &m_majorTickmarkCount, "MajorTickmarkCount", "Major Tickmark Count" ); - CAF_PDM_InitFieldNoDefault( &m_subTitleFontSize, "SubTitleFontSize", "Sub Plot Title Font Size", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_subTitleFontSize, "SubTitleFontSize", "Sub Plot Title Font Size" ); m_subTitleFontSize = caf::FontTools::RelativeSize::Large; - CAF_PDM_InitField( &m_pagePreviewMode, "PagePreviewMode", false, "Page Preview Mode", "", "", "" ); + CAF_PDM_InitField( &m_pagePreviewMode, "PagePreviewMode", false, "Page Preview Mode", "", "Page Preview" ); m_pagePreviewMode.uiCapability()->setUiEditorTypeName( caf::PdmUiToolButtonEditor::uiEditorTypeName() ); m_pagePreviewMode.uiCapability()->setUiIconFromResourceString( ":/PagePreview16x16.png" ); m_viewer = nullptr; @@ -100,8 +86,10 @@ RimMultiPlot::RimMultiPlot() //-------------------------------------------------------------------------------------------------- RimMultiPlot::~RimMultiPlot() { + m_isValid = false; + removeMdiWindowFromMdiArea(); - m_plots.deleteAllChildObjects(); + m_plots.deleteChildren(); cleanupBeforeClose(); } @@ -114,8 +102,8 @@ RimMultiPlot& RimMultiPlot::operator=( RimMultiPlot&& rhs ) RimPlotWindow::operator=( std::move( rhs ) ); // Move all tracks - std::vector plots = rhs.m_plots.childObjects(); - rhs.m_plots.clear(); + std::vector plots = rhs.m_plots.children(); + rhs.m_plots.clearWithoutDelete(); for ( RimPlot* plot : plots ) { m_plots.push_back( plot ); @@ -151,6 +139,14 @@ QString RimMultiPlot::description() const return multiPlotTitle(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimMultiPlot::projectFileVersionString() const +{ + return m_projectFileVersionString(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -181,6 +177,7 @@ QString RimMultiPlot::multiPlotTitle() const void RimMultiPlot::setMultiPlotTitle( const QString& title ) { m_plotWindowTitle = title; + if ( !m_viewer.isNull() ) m_viewer->setPlotTitle( title ); } //-------------------------------------------------------------------------------------------------- @@ -190,17 +187,23 @@ void RimMultiPlot::insertPlot( RimPlot* plot, size_t index ) { if ( plot ) { + setTickmarkCount( plot, m_majorTickmarkCount() ); + + if ( index > m_plots.size() ) index = m_plots.size(); + m_plots.insert( index, plot ); if ( m_viewer ) { - plot->createPlotWidget(); - m_viewer->insertPlot( plot->viewer(), index ); + plot->createPlotWidget( m_viewer ); + m_viewer->insertPlot( plot->plotWidget(), index ); } - plot->setShowWindow( true ); - plot->updateAfterInsertingIntoMultiPlot(); - onPlotAdditionOrRemoval(); + if ( !m_delayPlotUpdatesDuringBatchAdd ) + { + plot->updateAfterInsertingIntoMultiPlot(); + onPlotAdditionOrRemoval(); + } } } @@ -213,14 +216,37 @@ void RimMultiPlot::removePlot( RimPlot* plot ) { if ( m_viewer ) { - m_viewer->removePlot( plot->viewer() ); + m_viewer->removePlot( plot->plotWidget() ); } - m_plots.removeChildObject( plot ); + m_plots.removeChild( plot ); onPlotAdditionOrRemoval(); } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimMultiPlot::removePlotNoUpdate( RimPlot* plot ) +{ + if ( plot ) + { + if ( m_viewer ) + { + m_viewer->removePlotNoUpdate( plot->plotWidget() ); + } + m_plots.removeChild( plot ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimMultiPlot::updateAfterPlotRemove() +{ + onPlotAdditionOrRemoval(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -256,6 +282,23 @@ void RimMultiPlot::movePlotsToThis( const std::vector& plotsToMove, in this->updateAllRequiredEditors(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimMultiPlot::deleteAllPlots() +{ + for ( auto plot : m_plots() ) + { + if ( plot && m_viewer ) + { + m_viewer->removePlot( plot->plotWidget() ); + } + } + + m_plots.deleteChildren(); + onPlotAdditionOrRemoval(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -269,7 +312,7 @@ size_t RimMultiPlot::plotCount() const //-------------------------------------------------------------------------------------------------- size_t RimMultiPlot::plotIndex( const RimPlot* plot ) const { - return m_plots.index( plot ); + return m_plots.indexOf( plot ); } //-------------------------------------------------------------------------------------------------- @@ -277,7 +320,7 @@ size_t RimMultiPlot::plotIndex( const RimPlot* plot ) const //-------------------------------------------------------------------------------------------------- std::vector RimMultiPlot::plots() const { - return m_plots.childObjects(); + return m_plots.children(); } //-------------------------------------------------------------------------------------------------- @@ -348,8 +391,8 @@ void RimMultiPlot::doRenderWindowContent( QPaintDevice* paintDevice ) void RimMultiPlot::updatePlotOrderFromGridWidget() { std::sort( m_plots.begin(), m_plots.end(), [this]( RimPlot* lhs, RimPlot* rhs ) { - auto indexLhs = m_viewer->indexOfPlotWidget( lhs->viewer() ); - auto indexRhs = m_viewer->indexOfPlotWidget( rhs->viewer() ); + auto indexLhs = m_viewer->indexOfPlotWidget( lhs->plotWidget() ); + auto indexRhs = m_viewer->indexOfPlotWidget( rhs->plotWidget() ); return indexLhs < indexRhs; } ); updateSubPlotNames(); @@ -381,45 +424,88 @@ void RimMultiPlot::setAutoScaleYEnabled( bool enabled ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -int RimMultiPlot::columnCount() const +void RimMultiPlot::setColumnCount( RiaDefines::ColumnCount columnCount ) { - if ( m_columnCount() == ColumnCount::COLUMNS_UNLIMITED ) - { - return std::numeric_limits::max(); - } - return static_cast( m_columnCount().value() ); + m_columnCount = columnCount; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -int RimMultiPlot::rowsPerPage() const +void RimMultiPlot::setRowCount( RiaDefines::RowCount rowCount ) { - return static_cast( m_rowsPerPage() ); + m_rowsPerPage = rowCount; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmFieldHandle* RimMultiPlot::columnCountField() +void RimMultiPlot::setTickmarkCount( RimPlotAxisPropertiesInterface::LegendTickmarkCountEnum tickmarkCount ) { - return &m_columnCount; + m_majorTickmarkCount = tickmarkCount; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmFieldHandle* RimMultiPlot::rowsPerPageField() +void RimMultiPlot::setTickmarkCount( RimPlot* plot, RimPlotAxisPropertiesInterface::LegendTickmarkCountEnum tickmarkCount ) { - return &m_rowsPerPage; + std::vector timeAxisProps; + plot->descendantsIncludingThisOfType( timeAxisProps ); + for ( auto tap : timeAxisProps ) + { + tap->setMajorTickmarkCount( tickmarkCount ); + } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmFieldHandle* RimMultiPlot::pagePreviewField() +int RimMultiPlot::columnCount() const { - return &m_pagePreviewMode; + if ( m_columnCount() == RiaDefines::ColumnCount::COLUMNS_UNLIMITED ) + { + return std::numeric_limits::max(); + } + return static_cast( m_columnCount().value() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimMultiPlot::rowsPerPage() const +{ + RiaDefines::RowCount rowEnum = m_rowsPerPage().value(); + + int rowCount = 2; + + switch ( rowEnum ) + { + case RiaDefines::RowCount::ROWS_1: + rowCount = 1; + break; + case RiaDefines::RowCount::ROWS_2: + rowCount = 2; + break; + case RiaDefines::RowCount::ROWS_3: + rowCount = 3; + break; + case RiaDefines::RowCount::ROWS_4: + rowCount = 4; + break; + default: + break; + } + + return rowCount; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimMultiPlot::setShowPlotTitles( bool enable ) +{ + m_showIndividualPlotTitles = enable; } //-------------------------------------------------------------------------------------------------- @@ -440,6 +526,15 @@ void RimMultiPlot::zoomAll() updateZoom(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimMultiPlot::zoomAllYAxes() +{ + setAutoScaleYEnabled( true ); + updateZoom(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -604,12 +699,7 @@ void RimMultiPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField, co { for ( RimPlot* plot : plots() ) { - std::vector timeAxisProps; - plot->descendantsIncludingThisOfType( timeAxisProps ); - for ( auto tap : timeAxisProps ) - { - tap->setMajorTickmarkCount( m_majorTickmarkCount() ); - } + setTickmarkCount( plot, m_majorTickmarkCount() ); } updatePlots(); @@ -652,8 +742,9 @@ void RimMultiPlot::uiOrderingForMultiPlotLayout( QString uiConfigName, caf::PdmU uiOrdering.add( &m_showPlotWindowTitle ); uiOrdering.add( &m_plotWindowTitle ); uiOrdering.add( &m_showIndividualPlotTitles ); - RimPlotWindow::uiOrderingForPlotLayout( uiConfigName, uiOrdering ); uiOrdering.add( &m_subTitleFontSize ); + + RimPlotWindow::uiOrderingForPlotLayout( uiConfigName, uiOrdering ); uiOrdering.add( &m_columnCount ); uiOrdering.add( &m_rowsPerPage ); uiOrdering.add( &m_majorTickmarkCount ); @@ -662,17 +753,16 @@ void RimMultiPlot::uiOrderingForMultiPlotLayout( QString uiConfigName, caf::PdmU //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimMultiPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RimMultiPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { - QList options = RimPlotWindow::calculateValueOptions( fieldNeedingOptions, useOptionsOnly ); + QList options = RimPlotWindow::calculateValueOptions( fieldNeedingOptions ); if ( fieldNeedingOptions == &m_columnCount ) { for ( size_t i = 0; i < ColumnCountEnum::size(); ++i ) { - ColumnCount enumVal = ColumnCountEnum::fromIndex( i ); - QString columnCountString = ( enumVal == ColumnCount::COLUMNS_UNLIMITED ) + RiaDefines::ColumnCount enumVal = ColumnCountEnum::fromIndex( i ); + QString columnCountString = ( enumVal == RiaDefines::ColumnCount::COLUMNS_UNLIMITED ) ? "Unlimited" : QString( "%1" ).arg( static_cast( enumVal ) ); QString iconPath = QString( ":/Columns%1.png" ).arg( columnCountString ); @@ -686,8 +776,8 @@ QList RimMultiPlot::calculateValueOptions( const caf::Pd { for ( size_t i = 0; i < RowCountEnum::size(); ++i ) { - RowCount enumVal = RowCountEnum::fromIndex( i ); - QString iconPath = QString( ":/Rows%1.png" ).arg( static_cast( enumVal ) ); + RiaDefines::RowCount enumVal = RowCountEnum::fromIndex( i ); + QString iconPath = QString( ":/Rows%1.png" ).arg( static_cast( enumVal ) ); options.push_back( caf::PdmOptionItemInfo( RowCountEnum::uiText( enumVal ), enumVal, false, @@ -707,12 +797,21 @@ QList RimMultiPlot::calculateValueOptions( const caf::Pd //-------------------------------------------------------------------------------------------------- void RimMultiPlot::onLoadDataAndUpdate() { + // PERFORMANCE NOTE + // Creation and update of the legend widgets is expensive. Disable display of legends during construction of the + // multi plot and creation of widgets. The legends will be made visible due to redraw operations always scheduled + // after this method. + bool originalShowState = m_showPlotLegends(); + m_showPlotLegends = false; + updateMdiWindowVisibility(); updatePlotWindowTitle(); applyPlotWindowTitleToWidgets(); updatePlots(); updateLayout(); RiuPlotMainWindowTools::refreshToolbars(); + + m_showPlotLegends = originalShowState; } //-------------------------------------------------------------------------------------------------- @@ -758,7 +857,7 @@ void RimMultiPlot::updateZoom() { for ( RimPlot* plot : plots() ) { - plot->updateZoomInQwt(); + plot->updateZoomInParentPlot(); } } @@ -775,8 +874,8 @@ void RimMultiPlot::recreatePlotWidgets() for ( size_t tIdx = 0; tIdx < plotVector.size(); ++tIdx ) { - plotVector[tIdx]->createPlotWidget(); - m_viewer->addPlot( plotVector[tIdx]->viewer() ); + plotVector[tIdx]->createPlotWidget( m_viewer ); + m_viewer->addPlot( plotVector[tIdx]->plotWidget() ); } } @@ -798,3 +897,61 @@ void RimMultiPlot::cleanupBeforeClose() m_viewer = nullptr; } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimMultiPlot::setupBeforeSave() +{ + m_projectFileVersionString = STRPRODUCTVER; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimMultiPlot::isMouseCursorInsidePlot() +{ + if ( !m_viewer ) return false; + return m_viewer->underMouse(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimMultiPlot::fieldsToShowInToolbar() +{ + return {}; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimMultiPlot::fieldsToShowInLayoutToolbar() +{ + return { &m_columnCount, &m_rowsPerPage, &m_pagePreviewMode }; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimMultiPlot::isValid() const +{ + return m_isValid; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimMultiPlot::startBatchAddOperation() +{ + m_delayPlotUpdatesDuringBatchAdd = true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimMultiPlot::endBatchAddOperation() +{ + m_delayPlotUpdatesDuringBatchAdd = false; + onPlotAdditionOrRemoval(); +} diff --git a/ApplicationLibCode/ProjectDataModel/RimMultiPlot.h b/ApplicationLibCode/ProjectDataModel/RimMultiPlot.h index ed420014ae..727c2e486a 100644 --- a/ApplicationLibCode/ProjectDataModel/RimMultiPlot.h +++ b/ApplicationLibCode/ProjectDataModel/RimMultiPlot.h @@ -18,7 +18,10 @@ #pragma once +#include "RiaDefines.h" + #include "RimAbstractPlotCollection.h" +#include "RimPlot.h" #include "RimPlotAxisPropertiesInterface.h" #include "RimPlotWindow.h" @@ -43,17 +46,8 @@ class RimMultiPlot : public RimPlotWindow, public RimTypedPlotCollection; - - enum RowCount - { - ROWS_1 = 1, - ROWS_2 = 2, - ROWS_3 = 3, - ROWS_4 = 4, - }; - using RowCountEnum = caf::AppEnum; + using ColumnCountEnum = caf::AppEnum; + using RowCountEnum = caf::AppEnum; public: RimMultiPlot(); @@ -64,6 +58,7 @@ class RimMultiPlot : public RimPlotWindow, public RimTypedPlotCollection& plots, int insertAtPosition ); + virtual void startBatchAddOperation(); + virtual void endBatchAddOperation(); + + virtual void removePlotNoUpdate( RimPlot* plot ); + virtual void updateAfterPlotRemove(); + + void deleteAllPlots() override; + void updatePlots(); + virtual void updatePlotWindowTitle(); + size_t plotCount() const override; size_t plotIndex( const RimPlot* plot ) const; @@ -85,14 +90,18 @@ class RimMultiPlot : public RimPlotWindow, public RimTypedPlotCollection fieldsToShowInToolbar(); + virtual std::vector fieldsToShowInLayoutToolbar(); + + bool isValid() const; + protected: QImage snapshotWindowContent() override; @@ -117,28 +131,33 @@ class RimMultiPlot : public RimPlotWindow, public RimTypedPlotCollection calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; - void onLoadDataAndUpdate() override; - void initAfterRead() override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; + + void onLoadDataAndUpdate() override; + void initAfterRead() override; void applyPlotWindowTitleToWidgets(); - void updatePlots(); void updateZoom(); void recreatePlotWidgets(); + void onPlotAdditionOrRemoval(); + + bool isMouseCursorInsidePlot(); + private: void cleanupBeforeClose(); + void setupBeforeSave() override; void doUpdateLayout() override; void updateSubPlotNames(); - void updatePlotWindowTitle(); void doRenderWindowContent( QPaintDevice* paintDevice ) override; - void onPlotAdditionOrRemoval(); void onPlotsReordered( const caf::SignalEmitter* emitter ); void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, std::vector& referringObjects ) override; + static void setTickmarkCount( RimPlot* plot, RimPlotAxisPropertiesInterface::LegendTickmarkCountEnum tickmarkCount ); + protected: + caf::PdmField m_projectFileVersionString; caf::PdmField m_showPlotWindowTitle; caf::PdmField m_plotWindowTitle; caf::PdmField m_columnCount; @@ -154,6 +173,10 @@ class RimMultiPlot : public RimPlotWindow, public RimTypedPlotCollection m_viewer; + bool m_delayPlotUpdatesDuringBatchAdd; + private: caf::PdmChildArrayField m_plots; + + bool m_isValid; }; diff --git a/ApplicationLibCode/ProjectDataModel/RimMultiPlotCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimMultiPlotCollection.cpp index 100a35af56..02cf7e86ff 100644 --- a/ApplicationLibCode/ProjectDataModel/RimMultiPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimMultiPlotCollection.cpp @@ -29,9 +29,9 @@ CAF_PDM_SOURCE_INIT( RimMultiPlotCollection, "RimMultiPlotCollection" ); //-------------------------------------------------------------------------------------------------- RimMultiPlotCollection::RimMultiPlotCollection() { - CAF_PDM_InitObject( "Multi Plots", ":/MultiPlot16x16.png", "", "" ); + CAF_PDM_InitObject( "Multi Plots", ":/MultiPlot16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_multiPlots, "MultiPlots", "Plots Reports", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_multiPlots, "MultiPlots", "Plots Reports" ); m_multiPlots.uiCapability()->setUiTreeHidden( true ); caf::PdmFieldReorderCapability::addToField( &m_multiPlots ); } @@ -48,7 +48,7 @@ RimMultiPlotCollection::~RimMultiPlotCollection() //-------------------------------------------------------------------------------------------------- void RimMultiPlotCollection::deleteAllPlots() { - m_multiPlots.deleteAllChildObjects(); + m_multiPlots.deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -56,19 +56,7 @@ void RimMultiPlotCollection::deleteAllPlots() //-------------------------------------------------------------------------------------------------- std::vector RimMultiPlotCollection::multiPlots() const { - return m_multiPlots.childObjects(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimMultiPlot* RimMultiPlotCollection::createMultiPlot() -{ - RimMultiPlot* plot = new RimMultiPlot(); - plot->setAsPlotMdiWindow(); - - addMultiPlot( plot ); - return plot; + return m_multiPlots.children(); } //-------------------------------------------------------------------------------------------------- @@ -84,7 +72,7 @@ void RimMultiPlotCollection::addMultiPlot( RimMultiPlot* plot ) //-------------------------------------------------------------------------------------------------- void RimMultiPlotCollection::loadDataAndUpdateAllPlots() { - for ( const auto& p : m_multiPlots.childObjects() ) + for ( const auto& p : m_multiPlots.children() ) p->loadDataAndUpdate(); } diff --git a/ApplicationLibCode/ProjectDataModel/RimMultiPlotCollection.h b/ApplicationLibCode/ProjectDataModel/RimMultiPlotCollection.h index 21c60b2b5b..74226c5681 100644 --- a/ApplicationLibCode/ProjectDataModel/RimMultiPlotCollection.h +++ b/ApplicationLibCode/ProjectDataModel/RimMultiPlotCollection.h @@ -41,8 +41,8 @@ class RimMultiPlotCollection : public caf::PdmObject, public RimPlotCollection size_t plotCount() const override; std::vector multiPlots() const; - RimMultiPlot* createMultiPlot(); - void addMultiPlot( RimMultiPlot* plot ); + + void addMultiPlot( RimMultiPlot* plot ); private: caf::PdmChildArrayField m_multiPlots; diff --git a/ApplicationLibCode/ProjectDataModel/RimMultipleLocations.cpp b/ApplicationLibCode/ProjectDataModel/RimMultipleLocations.cpp index add52a678a..9288cce217 100644 --- a/ApplicationLibCode/ProjectDataModel/RimMultipleLocations.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimMultipleLocations.cpp @@ -42,27 +42,24 @@ void AppEnum::setUp() //-------------------------------------------------------------------------------------------------- RimMultipleLocations::RimMultipleLocations() { - CAF_PDM_InitObject( "RimMultipleLocations", ":/FishBoneGroup16x16.png", "", "" ); + CAF_PDM_InitObject( "RimMultipleLocations", ":/FishBoneGroup16x16.png" ); CAF_PDM_InitField( &m_locationType, "LocationMode", caf::AppEnum( LocationType::COUNT ), - "Location Defined By", - "", - "", - "" ); - CAF_PDM_InitField( &m_rangeStart, "RangeStart", 100.0, "Start MD", "", "", "" ); + "Location Defined By" ); + CAF_PDM_InitField( &m_rangeStart, "RangeStart", 100.0, "Start MD" ); m_rangeStart.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_rangeEnd, "RangeEnd", 250.0, "End MD", "", "", "" ); + CAF_PDM_InitField( &m_rangeEnd, "RangeEnd", 250.0, "End MD" ); m_rangeEnd.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_rangeSpacing, "Spacing", "Spacing", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_rangeSpacing, "Spacing", "Spacing" ); m_rangeSpacing.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_rangeCount, "RangeValveCount", 10, "Number of Items", "", "", "" ); + CAF_PDM_InitField( &m_rangeCount, "RangeValveCount", 10, "Number of Items" ); - CAF_PDM_InitFieldNoDefault( &m_locations, "Locations", "Measured Depths", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_locations, "Locations", "Measured Depths" ); m_locations.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() ); } diff --git a/ApplicationLibCode/ProjectDataModel/RimNameConfig.cpp b/ApplicationLibCode/ProjectDataModel/RimNameConfig.cpp index 81808817f8..fd8baa7bcf 100644 --- a/ApplicationLibCode/ProjectDataModel/RimNameConfig.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimNameConfig.cpp @@ -33,10 +33,10 @@ CAF_PDM_ABSTRACT_SOURCE_INIT( RimNameConfig, "RimCurveNameConfig" ); //-------------------------------------------------------------------------------------------------- RimNameConfig::RimNameConfig( const QString& customName ) { - CAF_PDM_InitObject( "Curve Name Generator", "", "", "" ); + CAF_PDM_InitObject( "Curve Name Generator" ); - CAF_PDM_InitFieldNoDefault( &m_customName, "CustomCurveName", "Custom Name Part", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_autoName, "AutoCurveName", "Full Name", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_customName, "CustomCurveName", "Custom Name Part" ); + CAF_PDM_InitFieldNoDefault( &m_autoName, "AutoCurveName", "Full Name" ); m_autoName.registerGetMethod( this, &RimNameConfig::autoName ); m_autoName.xmlCapability()->disableIO(); m_autoName.uiCapability()->setUiReadOnly( true ); diff --git a/ApplicationLibCode/ProjectDataModel/RimNamedObject.cpp b/ApplicationLibCode/ProjectDataModel/RimNamedObject.cpp index e3d06db636..46819d1939 100644 --- a/ApplicationLibCode/ProjectDataModel/RimNamedObject.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimNamedObject.cpp @@ -28,8 +28,8 @@ CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimNamedObject, "NamedObject" ); // Do not use //-------------------------------------------------------------------------------------------------- RimNamedObject::RimNamedObject( void ) { - CAF_PDM_InitScriptableObject( "Named object", "", "", "" ); - CAF_PDM_InitScriptableField( &m_name, "Name", QString(), "Name", "", "", "" ); + CAF_PDM_InitScriptableObject( "Named object" ); + CAF_PDM_InitScriptableField( &m_name, "Name", QString(), "Name" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimObservedDataCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimObservedDataCollection.cpp index 79fa3bdc25..7b7bc9d88d 100644 --- a/ApplicationLibCode/ProjectDataModel/RimObservedDataCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimObservedDataCollection.cpp @@ -48,10 +48,10 @@ CAF_PDM_SOURCE_INIT( RimObservedDataCollection, "ObservedDataCollection" ); //-------------------------------------------------------------------------------------------------- RimObservedDataCollection::RimObservedDataCollection() { - CAF_PDM_InitObject( "Observed Data", ":/Folder.png", "", "" ); + CAF_PDM_InitObject( "Observed Data", ":/Folder.png" ); - CAF_PDM_InitFieldNoDefault( &m_observedDataArray, "ObservedDataArray", "", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_observedFmuRftArray, "ObservedFmuRftDataArray", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_observedDataArray, "ObservedDataArray", "" ); + CAF_PDM_InitFieldNoDefault( &m_observedFmuRftArray, "ObservedFmuRftDataArray", "" ); m_observedDataArray.uiCapability()->setUiTreeHidden( true ); m_observedFmuRftArray.uiCapability()->setUiTreeHidden( true ); } @@ -61,8 +61,8 @@ RimObservedDataCollection::RimObservedDataCollection() //-------------------------------------------------------------------------------------------------- RimObservedDataCollection::~RimObservedDataCollection() { - m_observedDataArray.deleteAllChildObjects(); - m_observedFmuRftArray.deleteAllChildObjects(); + m_observedDataArray.deleteChildren(); + m_observedFmuRftArray.deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -70,7 +70,7 @@ RimObservedDataCollection::~RimObservedDataCollection() //-------------------------------------------------------------------------------------------------- void RimObservedDataCollection::removeObservedSummaryData( RimObservedSummaryData* observedData ) { - m_observedDataArray.removeChildObject( observedData ); + m_observedDataArray.removeChild( observedData ); caf::PdmUiObjectEditorHandle::updateUiAllObjectEditors(); } @@ -79,7 +79,7 @@ void RimObservedDataCollection::removeObservedSummaryData( RimObservedSummaryDat //-------------------------------------------------------------------------------------------------- void RimObservedDataCollection::removeObservedFmuRftData( RimObservedFmuRftData* observedFmuRftData ) { - m_observedFmuRftArray.removeChildObject( observedFmuRftData ); + m_observedFmuRftArray.removeChild( observedFmuRftData ); caf::PdmUiObjectEditorHandle::updateUiAllObjectEditors(); } @@ -88,7 +88,7 @@ void RimObservedDataCollection::removeObservedFmuRftData( RimObservedFmuRftData* //-------------------------------------------------------------------------------------------------- std::vector RimObservedDataCollection::allObservedSummaryData() const { - return m_observedDataArray.childObjects(); + return m_observedDataArray.children(); } //-------------------------------------------------------------------------------------------------- @@ -96,7 +96,7 @@ std::vector RimObservedDataCollection::allObservedSumma //-------------------------------------------------------------------------------------------------- std::vector RimObservedDataCollection::allObservedFmuRftData() const { - return m_observedFmuRftArray.childObjects(); + return m_observedFmuRftArray.children(); } //-------------------------------------------------------------------------------------------------- @@ -128,7 +128,7 @@ void updateNewObservedDataCreated( caf::PdmObject* object ) caf::PdmUiObjectEditorHandle::updateUiAllObjectEditors(); RiuPlotMainWindow* mpw = RiaGuiApplication::instance()->mainPlotWindow(); - if ( mpw ) mpw->updateSummaryPlotToolBar(); + if ( mpw ) mpw->updateMultiPlotToolBar(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimObservedFmuRftData.cpp b/ApplicationLibCode/ProjectDataModel/RimObservedFmuRftData.cpp index 05682de84c..ae1d8b6cdd 100644 --- a/ApplicationLibCode/ProjectDataModel/RimObservedFmuRftData.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimObservedFmuRftData.cpp @@ -29,11 +29,11 @@ CAF_PDM_SOURCE_INIT( RimObservedFmuRftData, "ObservedFmuRftData" ); //-------------------------------------------------------------------------------------------------- RimObservedFmuRftData::RimObservedFmuRftData() { - CAF_PDM_InitObject( "Observed FMU Data", ":/ObservedRFTDataFile16x16.png", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_directoryPath, "Directory", "Directory", "", "", "" ); + CAF_PDM_InitObject( "Observed FMU Data", ":/ObservedRFTDataFile16x16.png" ); + CAF_PDM_InitFieldNoDefault( &m_directoryPath, "Directory", "Directory" ); m_directoryPath.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitFieldNoDefault( &m_wells, "Wells", "Wells", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wells, "Wells", "Wells" ); m_wells.xmlCapability()->disableIO(); m_wells.uiCapability()->setUiReadOnly( true ); m_wells.registerGetMethod( this, &RimObservedFmuRftData::wells ); diff --git a/ApplicationLibCode/ProjectDataModel/RimOilField.cpp b/ApplicationLibCode/ProjectDataModel/RimOilField.cpp index 73ac144baf..df23c0b9ba 100644 --- a/ApplicationLibCode/ProjectDataModel/RimOilField.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimOilField.cpp @@ -39,33 +39,30 @@ CAF_PDM_SOURCE_INIT( RimOilField, "ResInsightOilField" ); //-------------------------------------------------------------------------------------------------- RimOilField::RimOilField( void ) { - CAF_PDM_InitObject( "Oil Field", "", "", "" ); + CAF_PDM_InitObject( "Oil Field" ); - CAF_PDM_InitFieldNoDefault( &analysisModels, "AnalysisModels", "Grid Models", ":/GridModels.png", "", "" ); - CAF_PDM_InitFieldNoDefault( &geoMechModels, "GeoMechModels", "Geo Mech Models", ":/GridModels.png", "", "" ); - CAF_PDM_InitFieldNoDefault( &wellPathCollection, "WellPathCollection", "Well Paths", ":/WellCollection.png", "", "" ); + CAF_PDM_InitFieldNoDefault( &analysisModels, "AnalysisModels", "Grid Models", ":/GridModels.png" ); + CAF_PDM_InitFieldNoDefault( &geoMechModels, "GeoMechModels", "Geo Mech Models", ":/GridModels.png" ); + CAF_PDM_InitFieldNoDefault( &wellPathCollection, "WellPathCollection", "Well Paths", ":/WellCollection.png" ); - CAF_PDM_InitFieldNoDefault( &completionTemplateCollection, "CompletionTemplateCollection", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &completionTemplateCollection, "CompletionTemplateCollection", "" ); - CAF_PDM_InitFieldNoDefault( &summaryCaseMainCollection, "SummaryCaseCollection", "Summary Cases", ":/GridModels.png", "", "" ); - CAF_PDM_InitFieldNoDefault( &formationNamesCollection, "FormationNamesCollection", "Formations", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &observedDataCollection, "ObservedDataCollection", "Observed Data", ":/Cases16x16.png", "", "" ); + CAF_PDM_InitFieldNoDefault( &summaryCaseMainCollection, "SummaryCaseCollection", "Summary Cases", ":/GridModels.png" ); + CAF_PDM_InitFieldNoDefault( &formationNamesCollection, "FormationNamesCollection", "Formations" ); + CAF_PDM_InitFieldNoDefault( &observedDataCollection, "ObservedDataCollection", "Observed Data", ":/Cases16x16.png" ); - CAF_PDM_InitFieldNoDefault( &annotationCollection, "AnnotationCollection", "Annotations", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &ensembleWellLogsCollection, "EnsembleWellLogsCollection", "Ensemble Well Logs", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &annotationCollection, "AnnotationCollection", "Annotations" ); + CAF_PDM_InitFieldNoDefault( &ensembleWellLogsCollection, "EnsembleWellLogsCollection", "Ensemble Well Logs" ); CAF_PDM_InitFieldNoDefault( &m_fractureTemplateCollection_OBSOLETE, "FractureDefinitionCollection", - "Defenition of Fractures", - "", - "", - "" ); + "Defenition of Fractures" ); - CAF_PDM_InitFieldNoDefault( &measurement, "Measurement", "Measurement", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &measurement, "Measurement", "Measurement" ); measurement = new RimMeasurement(); measurement.xmlCapability()->disableIO(); - CAF_PDM_InitFieldNoDefault( &surfaceCollection, "SurfaceCollection", "Surfaces", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &surfaceCollection, "SurfaceCollection", "Surfaces" ); surfaceCollection = new RimSurfaceCollection(); surfaceCollection->setAsTopmostFolder(); @@ -129,7 +126,7 @@ void RimOilField::initAfterRead() RimFractureTemplateCollection* fractureTemplateCollection = m_fractureTemplateCollection_OBSOLETE.value(); if ( !fractureTemplateCollection->fractureTemplates().empty() ) { - m_fractureTemplateCollection_OBSOLETE.removeChildObject( fractureTemplateCollection ); + m_fractureTemplateCollection_OBSOLETE.removeChild( fractureTemplateCollection ); completionTemplateCollection->setFractureTemplateCollection( fractureTemplateCollection ); } } diff --git a/ApplicationLibCode/ProjectDataModel/RimPlot.cpp b/ApplicationLibCode/ProjectDataModel/RimPlot.cpp index f581360da8..02d557d66c 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimPlot.cpp @@ -26,11 +26,11 @@ #include "RimPlotWindow.h" #include "RiuPlotMainWindowTools.h" -#include "RiuQwtPlotWidget.h" +#include "RiuPlotWidget.h" #include "cafPdmObject.h" -#include "qwt_plot_curve.h" +#include "qwt_legend_data.h" namespace caf { @@ -57,8 +57,8 @@ RimPlot::RimPlot() { CAF_PDM_InitScriptableObjectWithNameAndComment( "Plot", "", "", "", "Plot", "The Abstract Base Class for all Plot Objects" ); - CAF_PDM_InitFieldNoDefault( &m_rowSpan, "RowSpan", "Row Span", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_colSpan, "ColSpan", "Col Span", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_rowSpan, "RowSpan", "Row Span" ); + CAF_PDM_InitFieldNoDefault( &m_colSpan, "ColSpan", "Col Span" ); } //-------------------------------------------------------------------------------------------------- @@ -73,12 +73,10 @@ RimPlot::~RimPlot() //-------------------------------------------------------------------------------------------------- QWidget* RimPlot::createViewWidget( QWidget* parent /*= nullptr */ ) { - RiuQwtPlotWidget* plotWidget = doCreatePlotViewWidget( parent ); - - RimPlot::attachPlotWidgetSignals( this, plotWidget ); + RiuPlotWidget* plotWidget = doCreatePlotViewWidget( parent ); updateWindowVisibility(); - plotWidget->scheduleReplot(); + if ( showWindow() ) plotWidget->scheduleReplot(); return plotWidget; } @@ -88,10 +86,10 @@ QWidget* RimPlot::createViewWidget( QWidget* parent /*= nullptr */ ) //-------------------------------------------------------------------------------------------------- void RimPlot::updateFonts() { - if ( viewer() ) + if ( plotWidget() ) { - viewer()->setPlotTitleFontSize( titleFontSize() ); - viewer()->setLegendFontSize( legendFontSize() ); + plotWidget()->setPlotTitleFontSize( titleFontSize() ); + plotWidget()->setLegendFontSize( legendFontSize() ); } } @@ -161,9 +159,6 @@ void RimPlot::removeFromMdiAreaAndCollection() void RimPlot::updateAfterInsertingIntoMultiPlot() { loadDataAndUpdate(); - /* updateLegend(); - updateAxes(); - updateLayout(); */ } //-------------------------------------------------------------------------------------------------- @@ -195,30 +190,14 @@ void RimPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const Q } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimPlot::attachPlotWidgetSignals( RimPlot* plot, RiuQwtPlotWidget* plotWidget ) -{ - CAF_ASSERT( plot && plotWidget ); - plot->connect( plotWidget, SIGNAL( plotSelected( bool ) ), SLOT( onPlotSelected( bool ) ) ); - plot->connect( plotWidget, SIGNAL( axisSelected( int, bool ) ), SLOT( onAxisSelected( int, bool ) ) ); - plot->connect( plotWidget, - SIGNAL( plotItemSelected( QwtPlotItem*, bool, int ) ), - SLOT( onPlotItemSelected( QwtPlotItem*, bool, int ) ) ); - plot->connect( plotWidget, SIGNAL( onKeyPressEvent( QKeyEvent* ) ), SLOT( onKeyPressEvent( QKeyEvent* ) ) ); - plot->connect( plotWidget, SIGNAL( onWheelEvent( QWheelEvent* ) ), SLOT( onWheelEvent( QWheelEvent* ) ) ); - plot->connect( plotWidget, SIGNAL( destroyed() ), SLOT( onViewerDestroyed() ) ); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimPlot::doRenderWindowContent( QPaintDevice* paintDevice ) { - if ( viewer() ) + if ( plotWidget() ) { - viewer()->renderTo( paintDevice, viewer()->frameGeometry() ); + plotWidget()->renderTo( paintDevice, plotWidget()->frameGeometry() ); } } @@ -227,37 +206,7 @@ void RimPlot::doRenderWindowContent( QPaintDevice* paintDevice ) //-------------------------------------------------------------------------------------------------- void RimPlot::onPlotSelected( bool toggle ) { - if ( toggle ) - { - RiuPlotMainWindowTools::toggleItemInSelection( this ); - } - else - { - RiuPlotMainWindowTools::selectAsCurrentItem( this ); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimPlot::onPlotItemSelected( QwtPlotItem* plotItem, bool toggle, int sampleIndex ) -{ - QwtPlotCurve* curve = dynamic_cast( plotItem ); - if ( curve ) - { - RimPlotCurve* selectedCurve = dynamic_cast( this->findPdmObjectFromQwtCurve( curve ) ); - if ( selectedCurve ) - { - if ( toggle ) - { - RiuPlotMainWindowTools::toggleItemInSelection( selectedCurve ); - } - else - { - RiuPlotMainWindowTools::selectAsCurrentItem( selectedCurve ); - } - } - } + RiuPlotMainWindowTools::selectOrToggleObject( this, toggle ); } //-------------------------------------------------------------------------------------------------- @@ -302,3 +251,68 @@ void RimPlot::onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, { loadDataAndUpdate(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlot::updateZoomInParentPlot() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlot::updateZoomFromParentPlot() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmObject* RimPlot::findPdmObjectFromPlotCurve( const RiuPlotCurve* curve ) const +{ + return nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlot::handleDroppedObjects( const std::vector& objects ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimPlot::visibleCurvesForLegend() +{ + return {}; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlot::handleKeyPressEvent( QKeyEvent* event ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlot::handleWheelEvent( QWheelEvent* event ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlot::onPlotItemSelected( std::shared_ptr, bool, int ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlot::onAxisSelected( RiuPlotAxis axis, bool toggle ) +{ +} diff --git a/ApplicationLibCode/ProjectDataModel/RimPlot.h b/ApplicationLibCode/ProjectDataModel/RimPlot.h index d792ffe481..a2395c04af 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPlot.h +++ b/ApplicationLibCode/ProjectDataModel/RimPlot.h @@ -22,6 +22,8 @@ #include "RimPlotWindow.h" +#include "RiuPlotAxis.h" + #include "cafAppEnum.h" #include "cafPdmChildArrayField.h" #include "cafPdmField.h" @@ -30,13 +32,12 @@ #include #include -class RiuQwtPlotWidget; -class RimPlotCurve; -class QwtPlotCurve; -class QwtPlotItem; - class QPaintDevice; class QWheelEvent; +class RiuPlotWidget; +class RiuPlotCurve; +class RiuPlotItem; +class RimPlotCurve; //================================================================================================== /// @@ -73,21 +74,16 @@ class RimPlot : public QObject, public RimPlotWindow void updateAfterInsertingIntoMultiPlot(); // Pure virtual interface methods - virtual RiuQwtPlotWidget* viewer() = 0; - virtual void setAutoScaleXEnabled( bool enabled ) = 0; virtual void setAutoScaleYEnabled( bool enabled ) = 0; virtual void updateAxes() = 0; - virtual void updateLegend() = 0; - virtual void updateZoomInQwt() = 0; - virtual void updateZoomFromQwt() = 0; + virtual void updateLegend() = 0; virtual QString asciiDataForPlotExport() const = 0; - virtual void reattachAllCurves() = 0; - virtual void detachAllCurves() = 0; - virtual caf::PdmObject* findPdmObjectFromQwtCurve( const QwtPlotCurve* curve ) const = 0; + virtual void reattachAllCurves() = 0; + virtual void detachAllCurves() = 0; void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, std::vector& referringObjects ) override; @@ -100,25 +96,34 @@ class RimPlot : public QObject, public RimPlotWindow return parentPlotWindow != nullptr; } + virtual RiuPlotWidget* plotWidget() = 0; + + virtual void updateZoomInParentPlot(); + virtual void updateZoomFromParentPlot(); + + virtual caf::PdmObject* findPdmObjectFromPlotCurve( const RiuPlotCurve* curve ) const; + virtual void handleDroppedObjects( const std::vector& objects ); + + virtual std::vector visibleCurvesForLegend(); + protected: + virtual RiuPlotWidget* doCreatePlotViewWidget( QWidget* parent ) = 0; + + QWidget* createViewWidget( QWidget* parent = nullptr ) override; + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - static void attachPlotWidgetSignals( RimPlot* plot, RiuQwtPlotWidget* plotWidget ); - QWidget* createViewWidget( QWidget* parent = nullptr ) final; - void updateFonts() override; + void doRenderWindowContent( QPaintDevice* paintDevice ) override; -private: - void doRenderWindowContent( QPaintDevice* paintDevice ) override; - virtual void handleKeyPressEvent( QKeyEvent* event ) {} - virtual void handleWheelEvent( QWheelEvent* event ) {} - virtual RiuQwtPlotWidget* doCreatePlotViewWidget( QWidget* parent ) = 0; + virtual void handleKeyPressEvent( QKeyEvent* event ); + virtual void handleWheelEvent( QWheelEvent* event ); private slots: + virtual void onAxisSelected( RiuPlotAxis axis, bool toggle ); + virtual void onPlotItemSelected( std::shared_ptr selectedItem, bool toggleItem, int sampleIndex ); void onPlotSelected( bool toggle ); - virtual void onAxisSelected( int axis, bool toggle ) {} - virtual void onPlotItemSelected( QwtPlotItem* plotItem, bool toggle, int sampleIndex ); void onViewerDestroyed(); void onKeyPressEvent( QKeyEvent* event ); void onWheelEvent( QWheelEvent* event ); diff --git a/ApplicationLibCode/ProjectDataModel/RimPlotAxisAnnotation.cpp b/ApplicationLibCode/ProjectDataModel/RimPlotAxisAnnotation.cpp index 1fc49e0e27..b6f577e501 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPlotAxisAnnotation.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimPlotAxisAnnotation.cpp @@ -36,16 +36,16 @@ CAF_PDM_SOURCE_INIT( RimPlotAxisAnnotation, "RimPlotAxisAnnotation" ); RimPlotAxisAnnotation::RimPlotAxisAnnotation() { m_annotationType = AnnotationType::LINE; - CAF_PDM_InitObject( "Plot Axis Annotation", ":/LeftAxis16x16.png", "", "" ); + CAF_PDM_InitObject( "Plot Axis Annotation", ":/LeftAxis16x16.png" ); - CAF_PDM_InitField( &m_isActive, "Active", true, "Active", "", "", "" ); + CAF_PDM_InitField( &m_isActive, "Active", true, "Active" ); m_isActive.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_name, "Name", "Name", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_value, "Value", "Value", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_name, "Name", "Name" ); + CAF_PDM_InitFieldNoDefault( &m_value, "Value", "Value" ); - CAF_PDM_InitFieldNoDefault( &m_rangeStart, "RangeStart", "Range Start", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_rangeEnd, "RangeEnd", "Range End", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_rangeStart, "RangeStart", "Range Start" ); + CAF_PDM_InitFieldNoDefault( &m_rangeEnd, "RangeEnd", "Range End" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimPlotAxisLogRangeCalculator.cpp b/ApplicationLibCode/ProjectDataModel/RimPlotAxisLogRangeCalculator.cpp new file mode 100644 index 0000000000..b10d648262 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/RimPlotAxisLogRangeCalculator.cpp @@ -0,0 +1,116 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimPlotAxisLogRangeCalculator.h" + +#include "RiaPlotDefines.h" + +#include "RimPlotCurve.h" + +#include "cvfVector2.h" + +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimPlotAxisLogRangeCalculator::RimPlotAxisLogRangeCalculator( RiaDefines::PlotAxis axis, + const std::vector& curves ) + : m_axis( axis ) + , m_curves( curves ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotAxisLogRangeCalculator::computeAxisRange( double* minPositive, double* max ) const +{ + double minPosValue = HUGE_VAL; + double maxValue = -HUGE_VAL; + + for ( const RimPlotCurve* curve : m_curves ) + { + double minPosCurveValue = HUGE_VAL; + double maxCurveValue = -HUGE_VAL; + + if ( curveValueRange( curve, &minPosCurveValue, &maxCurveValue ) ) + { + if ( minPosCurveValue < minPosValue ) + { + CVF_ASSERT( minPosCurveValue > 0.0 ); + minPosValue = minPosCurveValue; + } + + if ( maxCurveValue > maxValue ) + { + maxValue = maxCurveValue; + } + } + } + + if ( minPosValue == HUGE_VAL ) + { + minPosValue = RiaDefines::minimumDefaultLogValuePlot(); + maxValue = RiaDefines::maximumDefaultValuePlot(); + } + + *minPositive = minPosValue; + *max = maxValue; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimPlotAxisLogRangeCalculator::curveValueRange( const RimPlotCurve* curve, double* minPositive, double* max ) const +{ + if ( !curve ) return false; + + if ( curve->dataSize() < 1 ) + { + return false; + } + + float minPosF = std::numeric_limits::infinity(); + float maxF = -std::numeric_limits::infinity(); + + int axisValueIndex = 0; + if ( RiaDefines::isVertical( m_axis ) ) + { + axisValueIndex = 1; + } + + for ( int i = 0; i < curve->dataSize(); ++i ) + { + auto [x, y] = curve->sample( i ); + cvf::Vec2f vec( x, y ); + float value = vec[axisValueIndex]; + if ( value == HUGE_VALF ) continue; + + maxF = std::max( maxF, value ); + if ( value > 0.0f && value < minPosF ) + { + minPosF = value; + } + } + + *minPositive = minPosF; + *max = maxF; + + return true; +} diff --git a/ApplicationLibCode/ProjectDataModel/RimPlotAxisLogRangeCalculator.h b/ApplicationLibCode/ProjectDataModel/RimPlotAxisLogRangeCalculator.h new file mode 100644 index 0000000000..9bfb9164b9 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/RimPlotAxisLogRangeCalculator.h @@ -0,0 +1,44 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RiaPlotDefines.h" + +#include + +class RimPlotCurve; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimPlotAxisLogRangeCalculator +{ +public: + RimPlotAxisLogRangeCalculator( RiaDefines::PlotAxis axis, const std::vector& curves ); + + void computeAxisRange( double* minPositive, double* max ) const; + +private: + bool curveValueRange( const RimPlotCurve* curve, double* minPositive, double* max ) const; + +private: + RiaDefines::PlotAxis m_axis; + const std::vector m_curves; +}; diff --git a/ApplicationLibCode/ProjectDataModel/RimPlotAxisProperties.cpp b/ApplicationLibCode/ProjectDataModel/RimPlotAxisProperties.cpp index e7573e4c73..24f8b8ab60 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPlotAxisProperties.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimPlotAxisProperties.cpp @@ -19,89 +19,112 @@ #include "RimPlotAxisProperties.h" -#include "RiaApplication.h" #include "RiaDefines.h" -#include "RiaFontCache.h" +#include "RiaFieldHandleTools.h" +#include "RiaPlotDefines.h" #include "RiaPreferences.h" -#include "RigStatisticsCalculator.h" -#include "RimPlot.h" #include "RimPlotAxisAnnotation.h" +#include "RimSummaryMultiPlot.h" #include "cafPdmUiSliderEditor.h" +#include "cafPdmUiTreeAttributes.h" #include "cvfVector2.h" #include -#include - -// clang-format off namespace caf { -template<> +template <> void caf::AppEnum::setUp() { - addItem(RimPlotAxisProperties::NUMBER_FORMAT_AUTO, "NUMBER_FORMAT_AUTO", "Auto"); - addItem(RimPlotAxisProperties::NUMBER_FORMAT_DECIMAL, "NUMBER_FORMAT_DECIMAL", "Decimal"); - addItem(RimPlotAxisProperties::NUMBER_FORMAT_SCIENTIFIC, "NUMBER_FORMAT_SCIENTIFIC", "Scientific"); + addItem( RimPlotAxisProperties::NUMBER_FORMAT_AUTO, "NUMBER_FORMAT_AUTO", "Auto" ); + addItem( RimPlotAxisProperties::NUMBER_FORMAT_DECIMAL, "NUMBER_FORMAT_DECIMAL", "Decimal" ); + addItem( RimPlotAxisProperties::NUMBER_FORMAT_SCIENTIFIC, "NUMBER_FORMAT_SCIENTIFIC", "Scientific" ); - setDefault(RimPlotAxisProperties::NUMBER_FORMAT_AUTO); + setDefault( RimPlotAxisProperties::NUMBER_FORMAT_AUTO ); } } // namespace caf -CAF_PDM_SOURCE_INIT(RimPlotAxisProperties, "SummaryYAxisProperties"); +CAF_PDM_SOURCE_INIT( RimPlotAxisProperties, "SummaryYAxisProperties" ); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RimPlotAxisProperties::RimPlotAxisProperties() - : settingsChanged(this) - , logarithmicChanged(this) - , m_enableTitleTextSettings(true) - , m_isRangeSettingsEnabled(true) + : logarithmicChanged( this ) + , axisPositionChanged( this ) + , m_enableTitleTextSettings( true ) + , m_isRangeSettingsEnabled( true ) + , m_isAlwaysRequired( false ) { - CAF_PDM_InitObject("Axis Properties", ":/LeftAxis16x16.png", "", ""); + CAF_PDM_InitObject( "Axis Properties", ":/LeftAxis16x16.png" ); + + CAF_PDM_InitField( &m_isActive, "Active", true, "Active" ); + m_isActive.uiCapability()->setUiHidden( true ); + + CAF_PDM_InitField( &m_isMinMaxOverridden, "IsMinMaxOverridden", false, "IsMinMaxOverridden" ); + m_isMinMaxOverridden.uiCapability()->setUiHidden( true ); + + CAF_PDM_InitFieldNoDefault( &m_objectName, "Name", "Name" ); + m_objectName.uiCapability()->setUiHidden( true ); - CAF_PDM_InitField(&m_isActive, "Active", true, "Active", "", "", ""); - m_isActive.uiCapability()->setUiHidden(true); + CAF_PDM_InitFieldNoDefault( &m_axisTitle, "AxisTitle", "Axis Title" ); + m_objectName.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitFieldNoDefault(&m_name, "Name", "Name", "", "", ""); - m_name.uiCapability()->setUiHidden(true); + CAF_PDM_InitField( &isAutoTitle, "AutoTitle", true, "Auto Title" ); - CAF_PDM_InitField(&isAutoTitle, "AutoTitle", true, "Auto Title", "", "", ""); - - CAF_PDM_InitField(&m_displayLongName, "DisplayLongName", true, " Names", "", "", ""); - CAF_PDM_InitField(&m_displayShortName, "DisplayShortName", false, " Acronyms", "", "", ""); - CAF_PDM_InitField(&m_displayUnitText, "DisplayUnitText", true, " Units", "", "", ""); + CAF_PDM_InitField( &m_displayLongName, "DisplayLongName", true, " Names" ); + CAF_PDM_InitField( &m_displayShortName, "DisplayShortName", false, " Acronyms" ); + CAF_PDM_InitField( &m_displayUnitText, "DisplayUnitText", true, " Units" ); - CAF_PDM_InitFieldNoDefault(&customTitle, "CustomTitle", "Title", "", "", ""); + CAF_PDM_InitFieldNoDefault( &m_customTitle, "CustomTitle", "Title" ); - CAF_PDM_InitField(&visibleRangeMax, "VisibleRangeMax", RiaDefines::maximumDefaultValuePlot(), "Max", "", "", ""); - CAF_PDM_InitField(&visibleRangeMin, "VisibleRangeMin", RiaDefines::minimumDefaultValuePlot(), "Min", "", "", ""); + CAF_PDM_InitField( &m_visibleRangeMax, "VisibleRangeMax", RiaDefines::maximumDefaultValuePlot(), "Max" ); + CAF_PDM_InitField( &m_visibleRangeMin, "VisibleRangeMin", RiaDefines::minimumDefaultValuePlot(), "Min" ); - CAF_PDM_InitFieldNoDefault(&numberFormat, "NumberFormat", "Number Format", "", "", ""); - CAF_PDM_InitField(&numberOfDecimals, "Decimals", 2, "Number of Decimals", "", "", ""); - CAF_PDM_InitField(&scaleFactor, "ScaleFactor", 1.0, "Scale Factor", "", "", ""); + CAF_PDM_InitFieldNoDefault( &m_numberFormat, "NumberFormat", "Number Format" ); + CAF_PDM_InitField( &m_numberOfDecimals, "Decimals", 2, "Number of Decimals" ); + CAF_PDM_InitField( &m_scaleFactor, "ScaleFactor", 1.0, "Scale Factor" ); - numberOfDecimals.uiCapability()->setUiEditorTypeName(caf::PdmUiSliderEditor::uiEditorTypeName()); + CAF_PDM_InitField( &m_isAutoZoom, "AutoZoom", true, "Set Range Automatically" ); + CAF_PDM_InitField( &m_isLogarithmicScaleEnabled, "LogarithmicScale", false, "Logarithmic Scale" ); + CAF_PDM_InitField( &m_isAxisInverted, "AxisInverted", false, "Invert Axis" ); + CAF_PDM_InitField( &m_showNumbers, "ShowNumbers", true, "Show Numbers" ); - CAF_PDM_InitField(&m_isAutoZoom, "AutoZoom", true, "Set Range Automatically", "", "", ""); - CAF_PDM_InitField(&isLogarithmicScaleEnabled, "LogarithmicScale", false, "Logarithmic Scale", "", "", ""); - CAF_PDM_InitField(&m_isAxisInverted, "AxisInverted", false, "Invert Axis", "", "", ""); + auto defaultPlotAxis = caf::AppEnum( RiaDefines::PlotAxis::PLOT_AXIS_LEFT ); + CAF_PDM_InitField( &m_plotAxis, "PlotAxis", defaultPlotAxis, "Plot Axis" ); + CAF_PDM_InitField( &m_plotAxisIndex, "PlotAxisIndex", 0, "Plot Axis Index" ); - CAF_PDM_InitFieldNoDefault(&m_titlePositionEnum, "TitlePosition", "Title Position", "", "", ""); + CAF_PDM_InitFieldNoDefault( &m_titlePositionEnum, "TitlePosition", "Title Position" ); - CAF_PDM_InitFieldNoDefault(&m_titleFontSize, "TitleDeltaFontSize", "Font Size", "", "", ""); - CAF_PDM_InitFieldNoDefault(&m_valuesFontSize, "ValueDeltaFontSize", "Font Size", "", "", ""); + CAF_PDM_InitFieldNoDefault( &m_titleFontSize, "TitleDeltaFontSize", "Font Size" ); + CAF_PDM_InitFieldNoDefault( &m_valuesFontSize, "ValueDeltaFontSize", "Font Size" ); - CAF_PDM_InitFieldNoDefault(&m_annotations, "Annotations", "", "", "", ""); - m_annotations.uiCapability()->setUiTreeHidden(true); -// m_annotations.uiCapability()->setUiTreeChildrenHidden(true); + CAF_PDM_InitFieldNoDefault( &m_annotations, "Annotations", "" ); + m_annotations.uiCapability()->setUiTreeHidden( true ); + + CAF_PDM_InitFieldNoDefault( &m_majorTickmarkCount, "MajorTickmarkCount", "Major Tickmark Count" ); updateOptionSensitivity(); } -// clang-format on + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotAxisProperties::setAlwaysRequired( bool enable ) +{ + m_isAlwaysRequired = enable; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimPlotAxisProperties::isDeletable() const +{ + return !m_isAlwaysRequired; +} //-------------------------------------------------------------------------------------------------- /// @@ -119,24 +142,37 @@ void RimPlotAxisProperties::enableRangeSettings( bool enable ) m_isRangeSettingsEnabled = enable; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotAxisProperties::setNameForUnusedAxis() +{ + QString name = "Unused "; + + if ( m_plotAxis() == RiaDefines::PlotAxis::PLOT_AXIS_LEFT ) + name += "Left"; + else if ( m_plotAxis() == RiaDefines::PlotAxis::PLOT_AXIS_RIGHT ) + name += "Right"; + + m_objectName = name; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- caf::PdmFieldHandle* RimPlotAxisProperties::userDescriptionField() { - return &m_name; + return &m_objectName; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList - RimPlotAxisProperties::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) +QList RimPlotAxisProperties::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; - *useOptionsOnly = true; - if ( fieldNeedingOptions == &scaleFactor ) + if ( fieldNeedingOptions == &m_scaleFactor ) { for ( int exp = -12; exp <= 12; exp += 3 ) { @@ -150,6 +186,19 @@ QList { options = caf::FontTools::relativeSizeValueOptions( RiaPreferences::current()->defaultPlotFontSize() ); } + else if ( fieldNeedingOptions == &m_plotAxis ) + { + std::vector plotAxes = { RiaDefines::PlotAxis::PLOT_AXIS_LEFT, + RiaDefines::PlotAxis::PLOT_AXIS_RIGHT }; + + for ( auto plotAxis : plotAxes ) + { + auto plotAxisEnum = caf::AppEnum( plotAxis ); + + QString uiText = plotAxisEnum.uiText(); + options.push_back( caf::PdmOptionItemInfo( uiText, plotAxisEnum.value() ) ); + } + } return options; } @@ -171,12 +220,12 @@ void RimPlotAxisProperties::defineUiOrdering( QString uiConfigName, caf::PdmUiOr titleTextGroup->add( &m_displayShortName ); titleTextGroup->add( &m_displayUnitText ); - customTitle.uiCapability()->setUiReadOnly( true ); + m_customTitle.uiCapability()->setUiReadOnly( true ); } else { - titleTextGroup->add( &customTitle ); - customTitle.uiCapability()->setUiReadOnly( false ); + titleTextGroup->add( &m_customTitle ); + m_customTitle.uiCapability()->setUiReadOnly( false ); } } @@ -189,36 +238,50 @@ void RimPlotAxisProperties::defineUiOrdering( QString uiConfigName, caf::PdmUiOr caf::PdmUiGroup& scaleGroup = *( uiOrdering.addNewGroup( "Axis Values" ) ); if ( m_isRangeSettingsEnabled ) { - scaleGroup.add( &isLogarithmicScaleEnabled ); + scaleGroup.add( &m_isLogarithmicScaleEnabled ); scaleGroup.add( &m_isAxisInverted ); + scaleGroup.add( &m_showNumbers ); } - scaleGroup.add( &numberFormat ); + scaleGroup.add( &m_numberFormat ); - if ( numberFormat() != NUMBER_FORMAT_AUTO ) + if ( m_numberFormat() != NUMBER_FORMAT_AUTO ) { - scaleGroup.add( &numberOfDecimals ); + scaleGroup.add( &m_numberOfDecimals ); } - scaleGroup.add( &scaleFactor ); + scaleGroup.add( &m_scaleFactor ); if ( m_isRangeSettingsEnabled ) { - scaleGroup.add( &visibleRangeMin ); - scaleGroup.add( &visibleRangeMax ); + scaleGroup.add( &m_visibleRangeMin ); + scaleGroup.add( &m_visibleRangeMax ); } + scaleGroup.add( &m_valuesFontSize ); + scaleGroup.add( &m_majorTickmarkCount ); + scaleGroup.add( &m_plotAxis ); + m_plotAxis.uiCapability()->setUiReadOnly( m_isAlwaysRequired ); uiOrdering.skipRemainingFields( true ); + + updateOverriddenLabelAndReadOnlyState(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimPlotAxisProperties::setNameAndAxis( const QString& name, QwtPlot::Axis axis ) +void RimPlotAxisProperties::setNameAndAxis( const QString& objectName, + const QString& axistTitle, + RiaDefines::PlotAxis axis, + int axisIndex ) { - m_name = name; - m_axis = axis; + m_objectName = objectName; + m_axisTitle = axistTitle; + m_plotAxis = axis; + m_plotAxisIndex = axisIndex; - if ( axis == QwtPlot::yRight ) this->setUiIconFromResourceString( ":/RightAxis16x16.png" ); - if ( axis == QwtPlot::xBottom ) this->setUiIconFromResourceString( ":/BottomAxis16x16.png" ); + if ( axis == RiaDefines::PlotAxis::PLOT_AXIS_LEFT ) this->setUiIconFromResourceString( ":/LeftAxis16x16.png" ); + if ( axis == RiaDefines::PlotAxis::PLOT_AXIS_RIGHT ) this->setUiIconFromResourceString( ":/RightAxis16x16.png" ); + if ( axis == RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM ) this->setUiIconFromResourceString( ":/BottomAxis16x16.png" ); + if ( axis == RiaDefines::PlotAxis::PLOT_AXIS_TOP ) this->setUiIconFromResourceString( ":/TopAxis16x16.png" ); } //-------------------------------------------------------------------------------------------------- @@ -229,6 +292,14 @@ RimPlotAxisPropertiesInterface::AxisTitlePositionType RimPlotAxisProperties::tit return m_titlePositionEnum(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimPlotAxisProperties::customTitle() const +{ + return m_customTitle(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -248,28 +319,25 @@ int RimPlotAxisProperties::valuesFontSize() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QwtPlot::Axis RimPlotAxisProperties::qwtPlotAxisType() const +const QString RimPlotAxisProperties::objectName() const { - return m_axis; + return m_objectName; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimPlotAxisProperties::name() const +const QString RimPlotAxisProperties::axisTitleText() const { - return m_name; + return m_axisTitle; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiaDefines::PlotAxis RimPlotAxisProperties::plotAxisType() const +RiuPlotAxis RimPlotAxisProperties::plotAxisType() const { - if ( m_axis == QwtPlot::yRight ) return RiaDefines::PlotAxis::PLOT_AXIS_RIGHT; - if ( m_axis == QwtPlot::xBottom ) return RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM; - - return RiaDefines::PlotAxis::PLOT_AXIS_LEFT; + return RiuPlotAxis( m_plotAxis.value(), m_plotAxisIndex ); } //-------------------------------------------------------------------------------------------------- @@ -280,6 +348,14 @@ bool RimPlotAxisProperties::useAutoTitle() const return isAutoTitle(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotAxisProperties::setShowDescription( bool enable ) +{ + m_displayLongName = enable; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -288,6 +364,14 @@ bool RimPlotAxisProperties::showDescription() const return m_displayLongName(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotAxisProperties::setShowAcronym( bool enable ) +{ + m_displayShortName = enable; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -296,6 +380,14 @@ bool RimPlotAxisProperties::showAcronym() const return m_displayShortName(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotAxisProperties::setShowUnitText( bool enable ) +{ + m_displayUnitText = enable; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -333,7 +425,7 @@ bool RimPlotAxisProperties::isAxisInverted() const //-------------------------------------------------------------------------------------------------- std::vector RimPlotAxisProperties::annotations() const { - return m_annotations.childObjects(); + return m_annotations.children(); } //-------------------------------------------------------------------------------------------------- @@ -349,7 +441,7 @@ void RimPlotAxisProperties::appendAnnotation( RimPlotAxisAnnotation* annotation //-------------------------------------------------------------------------------------------------- void RimPlotAxisProperties::removeAllAnnotations() { - m_annotations.clear(); + m_annotations.deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -363,178 +455,278 @@ void RimPlotAxisProperties::setAxisInverted( bool inverted ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimPlotAxisProperties::isActive() const +bool RimPlotAxisProperties::showNumbers() const { - return m_isActive; + return m_showNumbers; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimPlotAxisProperties::setInvertedAxis( bool enable ) +void RimPlotAxisProperties::setShowNumbers( bool enable ) { - m_isAxisInverted = enable; + m_showNumbers = enable; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimPlotAxisProperties::showAnnotationObjectsInProjectTree() +RimPlotAxisProperties::NumberFormatType RimPlotAxisProperties::numberFormat() const { - m_annotations.uiCapability()->setUiTreeChildrenHidden( false ); + return m_numberFormat(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimPlotAxisProperties::fieldChangedByUi( const caf::PdmFieldHandle* changedField, - const QVariant& oldValue, - const QVariant& newValue ) +int RimPlotAxisProperties::decimalCount() const { - if ( changedField == &isAutoTitle ) + return m_numberOfDecimals(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimPlotAxisProperties::scaleFactor() const +{ + return m_scaleFactor(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotAxisProperties::setVisible( bool visible ) +{ + m_isActive = visible; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotAxisProperties::computeAndSetScaleFactor() +{ + auto maxAbsValue = std::max( std::fabs( visibleRangeMax() ), std::fabs( visibleRangeMin() ) ); + + if ( maxAbsValue < 1.0 && maxAbsValue > 1e-6 ) { - updateOptionSensitivity(); + // Do not use scale factor for small values above 1e-6 + m_scaleFactor = 1.0; + return; } - else if ( changedField == &visibleRangeMax ) - { - if ( visibleRangeMin > visibleRangeMax ) visibleRangeMax = oldValue.toDouble(); - m_isAutoZoom = false; - } - else if ( changedField == &visibleRangeMin ) + if ( maxAbsValue > 1.0 && maxAbsValue < 1e6 ) { - if ( visibleRangeMin > visibleRangeMax ) visibleRangeMin = oldValue.toDouble(); - - m_isAutoZoom = false; + // Do not use scale factor for values above 1 and below 1e-6 + m_scaleFactor = 1.0; + return; } - if ( changedField == &isLogarithmicScaleEnabled ) + int exponent = std::floor( std::log10( maxAbsValue ) ); + if ( exponent > 0 ) { - logarithmicChanged.send( isLogarithmicScaleEnabled() ); + while ( exponent > -20 && ( exponent % 3 ) != 0 ) + { + exponent--; + } } else { - settingsChanged.send(); + while ( exponent < 1 && ( exponent % 3 ) != 0 ) + { + exponent++; + } } + + m_scaleFactor = std::pow( 10, exponent ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimPlotAxisProperties::updateOptionSensitivity() +bool RimPlotAxisProperties::isActive() const { - customTitle.uiCapability()->setUiReadOnly( isAutoTitle ); + return m_isActive; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::FontTools::FontSize RimPlotAxisProperties::plotFontSize() const +double RimPlotAxisProperties::visibleRangeMin() const { - return RiaPreferences::current()->defaultPlotFontSize(); + return m_visibleRangeMin; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimPlotAxisProperties::initAfterRead() +double RimPlotAxisProperties::visibleRangeMax() const { - updateOptionSensitivity(); + return m_visibleRangeMax; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmFieldHandle* RimPlotAxisProperties::objectToggleField() +void RimPlotAxisProperties::setMinMaxOverridden( bool isOverridden ) { - return &m_isActive; + m_isMinMaxOverridden = isOverridden; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimPlotAxisLogRangeCalculator::RimPlotAxisLogRangeCalculator( QwtPlot::Axis axis, - const std::vector& qwtCurves ) - : m_axis( axis ) - , m_curves( qwtCurves ) +void RimPlotAxisProperties::setVisibleRangeMin( double value ) { + m_visibleRangeMin = value; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimPlotAxisLogRangeCalculator::computeAxisRange( double* minPositive, double* max ) const +void RimPlotAxisProperties::setVisibleRangeMax( double value ) { - double minPosValue = HUGE_VAL; - double maxValue = -HUGE_VAL; + m_visibleRangeMax = value; +} - for ( const QwtPlotCurve* curve : m_curves ) +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimPlotAxisPropertiesInterface::LegendTickmarkCount RimPlotAxisProperties::majorTickmarkCount() const +{ + return m_majorTickmarkCount(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotAxisProperties::setMajorTickmarkCount( LegendTickmarkCount count ) +{ + m_majorTickmarkCount = count; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotAxisProperties::showAnnotationObjectsInProjectTree() +{ + m_annotations.uiCapability()->setUiTreeChildrenHidden( false ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotAxisProperties::fieldChangedByUi( const caf::PdmFieldHandle* changedField, + const QVariant& oldValue, + const QVariant& newValue ) +{ + if ( changedField == &isAutoTitle ) { - double minPosCurveValue = HUGE_VAL; - double maxCurveValue = -HUGE_VAL; + updateOptionSensitivity(); + } + else if ( changedField == &m_visibleRangeMax ) + { + if ( m_visibleRangeMin > m_visibleRangeMax ) m_visibleRangeMax = oldValue.toDouble(); - if ( curveValueRange( curve, &minPosCurveValue, &maxCurveValue ) ) - { - if ( minPosCurveValue < minPosValue ) - { - CVF_ASSERT( minPosCurveValue > 0.0 ); - minPosValue = minPosCurveValue; - } - - if ( maxCurveValue > maxValue ) - { - maxValue = maxCurveValue; - } - } + m_isAutoZoom = false; + } + else if ( changedField == &m_visibleRangeMin ) + { + if ( m_visibleRangeMin > m_visibleRangeMax ) m_visibleRangeMin = oldValue.toDouble(); + + m_isAutoZoom = false; } - if ( minPosValue == HUGE_VAL ) + if ( changedField == &m_isLogarithmicScaleEnabled ) + { + logarithmicChanged.send( m_isLogarithmicScaleEnabled() ); + } + else if ( changedField == &m_plotAxis ) { - minPosValue = RiaDefines::minimumDefaultLogValuePlot(); - maxValue = RiaDefines::maximumDefaultValuePlot(); + RiuPlotAxis oldPlotAxis = RiuPlotAxis( (RiaDefines::PlotAxis)oldValue.toInt(), m_plotAxisIndex ); + axisPositionChanged.send( this, oldPlotAxis, plotAxisType() ); } + else + { + settingsChanged.send(); + } +} - *minPositive = minPosValue; - *max = maxValue; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotAxisProperties::updateOptionSensitivity() +{ + m_customTitle.uiCapability()->setUiReadOnly( isAutoTitle ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimPlotAxisLogRangeCalculator::curveValueRange( const QwtPlotCurve* qwtCurve, double* minPositive, double* max ) const +void RimPlotAxisProperties::updateOverriddenLabelAndReadOnlyState() { - if ( !qwtCurve ) return false; + // Auto Appearance is defined in RimSummaryMultiPlot::analyzePlotsAndAdjustAppearanceSettings() + QString axisRangeToolTip = "Controlled by Axis Range Control"; - if ( qwtCurve->data()->size() < 1 ) - { - return false; - } + RiaFieldHandleTools::updateOverrideStateAndLabel( &m_visibleRangeMin, m_isMinMaxOverridden, axisRangeToolTip ); + RiaFieldHandleTools::updateOverrideStateAndLabel( &m_visibleRangeMax, m_isMinMaxOverridden, axisRangeToolTip ); - float minPosF = std::numeric_limits::infinity(); - float maxF = -std::numeric_limits::infinity(); + QString autoAppearanceToolTip = "Controlled by Auto Adjust Appearance"; + RiaFieldHandleTools::updateOverrideStateAndLabel( &m_majorTickmarkCount, isAppearanceOverridden(), autoAppearanceToolTip ); + RiaFieldHandleTools::updateOverrideStateAndLabel( &m_scaleFactor, isAppearanceOverridden(), autoAppearanceToolTip ); + RiaFieldHandleTools::updateOverrideStateAndLabel( &m_displayLongName, isAppearanceOverridden(), autoAppearanceToolTip ); +} - int axisValueIndex = 0; - if ( m_axis == QwtPlot::yLeft || m_axis == QwtPlot::yRight ) - { - axisValueIndex = 1; - } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::FontTools::FontSize RimPlotAxisProperties::plotFontSize() const +{ + return RiaPreferences::current()->defaultPlotFontSize(); +} - for ( size_t i = 0; i < qwtCurve->dataSize(); ++i ) - { - QPointF sample = qwtCurve->sample( (int)i ); - cvf::Vec2f vec( sample.x(), sample.y() ); - float value = vec[axisValueIndex]; - if ( value == HUGE_VALF ) continue; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotAxisProperties::defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) +{ + RimSummaryMultiPlot* summaryMultiPlot = nullptr; + firstAncestorOfType( summaryMultiPlot ); - maxF = std::max( maxF, value ); - if ( value > 0.0f && value < minPosF ) + if ( summaryMultiPlot && summaryMultiPlot->isSubPlotAxesLinked() ) + { + auto* treeItemAttribute = dynamic_cast( attribute ); + if ( treeItemAttribute ) { - minPosF = value; + treeItemAttribute->tags.clear(); + auto tag = caf::PdmUiTreeViewItemAttribute::Tag::create(); + tag->icon = caf::IconProvider( ":/chain.png" ); + + treeItemAttribute->tags.push_back( std::move( tag ) ); } } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotAxisProperties::initAfterRead() +{ + updateOptionSensitivity(); + m_isAlwaysRequired = m_plotAxisIndex == 0; +} - *minPositive = minPosF; - *max = maxF; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* RimPlotAxisProperties::objectToggleField() +{ + return &m_isActive; +} - return true; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimPlotAxisProperties::isLogarithmicScaleEnabled() const +{ + return m_isLogarithmicScaleEnabled; } diff --git a/ApplicationLibCode/ProjectDataModel/RimPlotAxisProperties.h b/ApplicationLibCode/ProjectDataModel/RimPlotAxisProperties.h index cb3d6d5002..96a5f62b04 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPlotAxisProperties.h +++ b/ApplicationLibCode/ProjectDataModel/RimPlotAxisProperties.h @@ -22,14 +22,14 @@ #include "RiaDefines.h" #include "RimPlotAxisPropertiesInterface.h" +#include "RiuPlotAxis.h" + #include "cafAppEnum.h" #include "cafFontTools.h" #include "cafPdmChildArrayField.h" #include "cafPdmField.h" #include "cafPdmObject.h" -#include "qwt_plot.h" - #include class RimPlotAxisAnnotation; @@ -38,7 +38,7 @@ class RimPlotAxisAnnotation; /// /// //================================================================================================== -class RimPlotAxisProperties : public caf::PdmObject, public RimPlotAxisPropertiesInterface +class RimPlotAxisProperties : public RimPlotAxisPropertiesInterface { CAF_PDM_HEADER_INIT; @@ -51,50 +51,74 @@ class RimPlotAxisProperties : public caf::PdmObject, public RimPlotAxisPropertie }; public: - caf::Signal<> settingsChanged; - caf::Signal logarithmicChanged; + caf::Signal logarithmicChanged; + caf::Signal axisPositionChanged; public: RimPlotAxisProperties(); - void setEnableTitleTextSettings( bool enable ); - void enableRangeSettings( bool enable ); - void setNameAndAxis( const QString& name, QwtPlot::Axis axis ); + void setAlwaysRequired( bool enable ); + + void setEnableTitleTextSettings( bool enable ); + void enableRangeSettings( bool enable ); + void setNameForUnusedAxis(); + void setNameAndAxis( const QString& objectName, const QString& axistTitle, RiaDefines::PlotAxis axis, int axisIndex = 0 ); AxisTitlePositionType titlePosition() const override; + QString customTitle() const; + int titleFontSize() const override; int valuesFontSize() const override; - QwtPlot::Axis qwtPlotAxisType() const; - QString name() const; - RiaDefines::PlotAxis plotAxisType() const override; - bool useAutoTitle() const; - bool showDescription() const; - bool showAcronym() const; - bool showUnitText() const; - bool isAutoZoom() const; - void setAutoZoom( bool enableAutoZoom ); - bool isAxisInverted() const; - void setAxisInverted( bool inverted ); + const QString objectName() const override; + const QString axisTitleText() const override; + + RiuPlotAxis plotAxisType() const override; + bool useAutoTitle() const; + + void setShowDescription( bool enable ); + bool showDescription() const; + + void setShowAcronym( bool enable ); + bool showAcronym() const; + + void setShowUnitText( bool enable ); + bool showUnitText() const; + + bool isAutoZoom() const override; + void setAutoZoom( bool enableAutoZoom ) override; + bool isAxisInverted() const override; + void setAxisInverted( bool inverted ); + bool showNumbers() const; + void setShowNumbers( bool enable ); + + NumberFormatType numberFormat() const; + int decimalCount() const; + double scaleFactor() const; + + void setVisible( bool visible ); + void computeAndSetScaleFactor(); + + bool isDeletable() const override; std::vector annotations() const override; void appendAnnotation( RimPlotAxisAnnotation* annotation ) override; void removeAllAnnotations() override; - caf::PdmField customTitle; + bool isLogarithmicScaleEnabled() const override; + bool isActive() const override; - caf::PdmField visibleRangeMin; - caf::PdmField visibleRangeMax; + void showAnnotationObjectsInProjectTree(); - caf::PdmField> numberFormat; - caf::PdmField numberOfDecimals; - caf::PdmField scaleFactor; - caf::PdmField isLogarithmicScaleEnabled; + double visibleRangeMin() const override; + double visibleRangeMax() const override; - bool isActive() const; + void setMinMaxOverridden( bool isOverridden ); + void setVisibleRangeMin( double value ) override; + void setVisibleRangeMax( double value ) override; - void setInvertedAxis( bool enable ); - void showAnnotationObjectsInProjectTree(); + LegendTickmarkCount majorTickmarkCount() const override; + void setMajorTickmarkCount( LegendTickmarkCount count ) override; protected: void initAfterRead() override; @@ -103,52 +127,51 @@ class RimPlotAxisProperties : public caf::PdmObject, public RimPlotAxisPropertie void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; private: void updateOptionSensitivity(); + void updateOverriddenLabelAndReadOnlyState(); caf::FontTools::FontSize plotFontSize() const; + void defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; private: caf::PdmField m_isActive; + caf::PdmField m_isMinMaxOverridden; + caf::PdmField isAutoTitle; caf::PdmField m_displayShortName; caf::PdmField m_displayLongName; caf::PdmField m_displayUnitText; caf::PdmField m_isAutoZoom; caf::PdmField m_isAxisInverted; + caf::PdmField m_showNumbers; + + caf::PdmField m_visibleRangeMin; + caf::PdmField m_visibleRangeMax; + + caf::PdmField m_objectName; + caf::PdmField m_axisTitle; - caf::PdmField m_name; - QwtPlot::Axis m_axis; + caf::PdmField> m_plotAxis; + caf::PdmField m_plotAxisIndex; + caf::PdmField m_majorTickmarkCount; + + caf::PdmField m_customTitle; + + caf::PdmField> m_numberFormat; + caf::PdmField m_numberOfDecimals; + caf::PdmField m_scaleFactor; + + caf::PdmField m_isLogarithmicScaleEnabled; bool m_enableTitleTextSettings; bool m_isRangeSettingsEnabled; + bool m_isAlwaysRequired; caf::PdmField m_titleFontSize; caf::PdmField> m_titlePositionEnum; caf::PdmField m_valuesFontSize; caf::PdmChildArrayField m_annotations; }; - -class QwtPlotCurve; - -//================================================================================================== -/// -/// -//================================================================================================== -class RimPlotAxisLogRangeCalculator -{ -public: - RimPlotAxisLogRangeCalculator( QwtPlot::Axis axis, const std::vector& qwtCurves ); - - void computeAxisRange( double* minPositive, double* max ) const; - -private: - bool curveValueRange( const QwtPlotCurve* qwtCurve, double* minPositive, double* max ) const; - -private: - QwtPlot::Axis m_axis; - const std::vector m_curves; -}; diff --git a/ApplicationLibCode/ProjectDataModel/RimPlotAxisPropertiesInterface.cpp b/ApplicationLibCode/ProjectDataModel/RimPlotAxisPropertiesInterface.cpp index 8b9d56ae93..7172d61b09 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPlotAxisPropertiesInterface.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimPlotAxisPropertiesInterface.cpp @@ -15,28 +15,105 @@ // for more details. // ///////////////////////////////////////////////////////////////////////////////// + #include "RimPlotAxisPropertiesInterface.h" #include "cafAppEnum.h" -// clang-format off +CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimPlotAxisPropertiesInterface, + "PlotAxisPropertiesInterface", + "RimPlotAxisPropertiesInterface" ); + namespace caf { -template<> +template <> void caf::AppEnum::setUp() { - addItem(RimPlotAxisPropertiesInterface::AXIS_TITLE_CENTER, "AXIS_TITLE_CENTER", "Center"); - addItem(RimPlotAxisPropertiesInterface::AXIS_TITLE_END, "AXIS_TITLE_END", "At End"); + addItem( RimPlotAxisPropertiesInterface::AXIS_TITLE_CENTER, "AXIS_TITLE_CENTER", "Center" ); + addItem( RimPlotAxisPropertiesInterface::AXIS_TITLE_END, "AXIS_TITLE_END", "At End" ); - setDefault(RimPlotAxisPropertiesInterface::AXIS_TITLE_CENTER); + setDefault( RimPlotAxisPropertiesInterface::AXIS_TITLE_CENTER ); } template <> void RimPlotAxisPropertiesInterface::LegendTickmarkCountEnum::setUp() { + addItem( RimPlotAxisPropertiesInterface::LegendTickmarkCount::TICKMARK_VERY_FEW, "VERY_FEW", "Very Few" ); addItem( RimPlotAxisPropertiesInterface::LegendTickmarkCount::TICKMARK_FEW, "Few", "Few" ); addItem( RimPlotAxisPropertiesInterface::LegendTickmarkCount::TICKMARK_DEFAULT, "Default", "Default" ); addItem( RimPlotAxisPropertiesInterface::LegendTickmarkCount::TICKMARK_MANY, "Many", "Many" ); setDefault( RimPlotAxisPropertiesInterface::LegendTickmarkCount::TICKMARK_DEFAULT ); } } // namespace caf + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimPlotAxisPropertiesInterface::RimPlotAxisPropertiesInterface() + : settingsChanged( this ) +{ + CAF_PDM_InitObject( "Plot Axis Properties Interface" ); + + CAF_PDM_InitField( &m_isAppearanceOverridden, "IsAppearanceOverridden", false, "IsAppearanceOverridden" ); + m_isAppearanceOverridden.uiCapability()->setUiHidden( true ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimPlotAxisPropertiesInterface::isAxisInverted() const +{ + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimPlotAxisPropertiesInterface::isLogarithmicScaleEnabled() const +{ + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotAxisPropertiesInterface::setAppearanceOverridden( bool isOverridden ) +{ + m_isAppearanceOverridden = isOverridden; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimPlotAxisPropertiesInterface::tickmarkCountFromEnum( LegendTickmarkCount count ) +{ + int maxTickmarkCount = 8; + + switch ( count ) + { + case LegendTickmarkCount::TICKMARK_VERY_FEW: + maxTickmarkCount = 2; + break; + case LegendTickmarkCount::TICKMARK_FEW: + maxTickmarkCount = 4; + break; + case LegendTickmarkCount::TICKMARK_DEFAULT: + maxTickmarkCount = 8; // Taken from QwtPlot::initAxesData() + break; + case LegendTickmarkCount::TICKMARK_MANY: + maxTickmarkCount = 10; + break; + default: + break; + } + + return maxTickmarkCount; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimPlotAxisPropertiesInterface::isAppearanceOverridden() const +{ + return m_isAppearanceOverridden(); +} diff --git a/ApplicationLibCode/ProjectDataModel/RimPlotAxisPropertiesInterface.h b/ApplicationLibCode/ProjectDataModel/RimPlotAxisPropertiesInterface.h index 223980a8be..9ec8bc4983 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPlotAxisPropertiesInterface.h +++ b/ApplicationLibCode/ProjectDataModel/RimPlotAxisPropertiesInterface.h @@ -18,14 +18,20 @@ #pragma once -#include "RiaDefines.h" +#include "RiaPlotDefines.h" + +#include "RiuPlotAxis.h" #include "cafAppEnum.h" +#include "cafPdmField.h" +#include "cafPdmObject.h" class RimPlotAxisAnnotation; -class RimPlotAxisPropertiesInterface +class RimPlotAxisPropertiesInterface : public caf::PdmObject { + CAF_PDM_HEADER_INIT; + public: enum AxisTitlePositionType { @@ -35,19 +41,55 @@ class RimPlotAxisPropertiesInterface enum class LegendTickmarkCount { + TICKMARK_VERY_FEW, TICKMARK_FEW, TICKMARK_DEFAULT, TICKMARK_MANY, }; using LegendTickmarkCountEnum = caf::AppEnum; + caf::Signal<> settingsChanged; + +public: + RimPlotAxisPropertiesInterface(); + virtual std::vector annotations() const = 0; virtual void appendAnnotation( RimPlotAxisAnnotation* annotation ) = 0; virtual void removeAllAnnotations() = 0; - virtual RiaDefines::PlotAxis plotAxisType() const = 0; + virtual RiuPlotAxis plotAxisType() const = 0; + + virtual double visibleRangeMin() const = 0; + virtual double visibleRangeMax() const = 0; + + virtual void setVisibleRangeMin( double value ) = 0; + virtual void setVisibleRangeMax( double value ) = 0; + + virtual bool isAutoZoom() const = 0; + virtual void setAutoZoom( bool enableAutoZoom ) = 0; + + virtual bool isActive() const = 0; + + virtual const QString objectName() const = 0; + virtual const QString axisTitleText() const = 0; + + virtual bool isAxisInverted() const; + + virtual bool isLogarithmicScaleEnabled() const; + + virtual LegendTickmarkCount majorTickmarkCount() const = 0; + virtual void setMajorTickmarkCount( LegendTickmarkCount count ) = 0; + void setAppearanceOverridden( bool isOverridden ); + + static int tickmarkCountFromEnum( LegendTickmarkCount count ); public: virtual AxisTitlePositionType titlePosition() const = 0; virtual int titleFontSize() const = 0; virtual int valuesFontSize() const = 0; + +protected: + bool isAppearanceOverridden() const; + +private: + caf::PdmField m_isAppearanceOverridden; }; diff --git a/ApplicationLibCode/ProjectDataModel/RimPlotCurve.cpp b/ApplicationLibCode/ProjectDataModel/RimPlotCurve.cpp index 1956fceb95..eab9ecba4b 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPlotCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimPlotCurve.cpp @@ -18,7 +18,6 @@ #include "RimPlotCurve.h" -#include "RiaColorTables.h" #include "RiaColorTools.h" #include "RiaCurveDataTools.h" #include "RiaGuiApplication.h" @@ -31,26 +30,21 @@ #include "RimSummaryCrossPlot.h" #include "RimSummaryCurve.h" #include "RimSummaryCurveCollection.h" -#include "RimSummaryCurveFilter.h" #include "RimSummaryPlot.h" +#include "RiuPlotCurve.h" +#include "RiuPlotCurveSymbol.h" #include "RiuPlotMainWindowTools.h" -#include "RiuRimQwtPlotCurve.h" +#include "RiuPlotWidget.h" +#include "cafAssert.h" #include "cafPdmUiComboBoxEditor.h" -#include "cvfAssert.h" - -#include "qwt_date.h" -#include "qwt_interval_symbol.h" -#include "qwt_plot.h" -#include "qwt_symbol.h" +#include // NB! Special macro for pure virtual class CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimPlotCurve, "PlotCurve" ); -#define DOUBLE_INF std::numeric_limits::infinity() - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -60,51 +54,45 @@ RimPlotCurve::RimPlotCurve() , dataChanged( this ) , nameChanged( this ) { - CAF_PDM_InitObject( "Curve", ":/WellLogCurve16x16.png", "", "" ); + CAF_PDM_InitObject( "Curve", ":/WellLogCurve16x16.png" ); - CAF_PDM_InitField( &m_showCurve, "Show", true, "Show curve", "", "", "" ); + CAF_PDM_InitField( &m_showCurve, "Show", true, "Show curve" ); m_showCurve.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_curveName, "CurveName", "Curve Name", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_customCurveName, "CurveDescription", "Custom Name", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_curveName, "CurveName", "Curve Name" ); + CAF_PDM_InitFieldNoDefault( &m_customCurveName, "CurveDescription", "Custom Name" ); m_customCurveName.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_legendEntryText, "LegendDescription", "Legend Name", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_legendEntryText, "LegendDescription", "Legend Name" ); m_legendEntryText.uiCapability()->setUiHidden( true ); - CAF_PDM_InitField( &m_isUsingAutoName, "AutoName", true, "Auto Name", "", "", "" ); - CAF_PDM_InitField( &m_showLegend, "ShowLegend", true, "Contribute To Legend", "", "", "" ); - CAF_PDM_InitField( &m_showErrorBars, "ShowErrorBars", true, "Show Error Bars", "", "", "" ); + CAF_PDM_InitField( &m_isUsingAutoName, "AutoName", true, "Auto Name" ); + CAF_PDM_InitField( &m_showLegend, "ShowLegend", true, "Contribute To Legend" ); + CAF_PDM_InitField( &m_showErrorBars, "ShowErrorBars", true, "Show Error Bars" ); // Obsolete field: appearance configuration is moved to RimPlotCurveAppearance - CAF_PDM_InitField( &m_curveColor_OBSOLETE, "Color", RiaColorTools::textColor3f(), "Color", "", "", "" ); + CAF_PDM_InitField( &m_curveColor_OBSOLETE, "Color", RiaColorTools::textColor3f(), "Color" ); m_curveColor_OBSOLETE.xmlCapability()->setIOWritable( false ); - CAF_PDM_InitField( &m_fillColor_OBSOLETE, "FillColor", cvf::Color3f( -1.0, -1.0, -1.0 ), "Fill Color", "", "", "" ); + CAF_PDM_InitField( &m_fillColor_OBSOLETE, "FillColor", cvf::Color3f( -1.0, -1.0, -1.0 ), "Fill Color" ); m_fillColor_OBSOLETE.xmlCapability()->setIOWritable( false ); - CAF_PDM_InitField( &m_curveThickness_OBSOLETE, "Thickness", 1, "Line Thickness", "", "", "" ); + CAF_PDM_InitField( &m_curveThickness_OBSOLETE, "Thickness", 1, "Line Thickness" ); m_curveThickness_OBSOLETE.xmlCapability()->setIOWritable( false ); - CAF_PDM_InitFieldNoDefault( &m_curveInterpolation_OBSOLETE, "CurveInterpolation", "Interpolation", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_curveInterpolation_OBSOLETE, "CurveInterpolation", "Interpolation" ); m_curveInterpolation_OBSOLETE.xmlCapability()->setIOWritable( false ); - CAF_PDM_InitFieldNoDefault( &m_lineStyle_OBSOLETE, "LineStyle", "Line Style", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_lineStyle_OBSOLETE, "LineStyle", "Line Style" ); m_lineStyle_OBSOLETE.xmlCapability()->setIOWritable( false ); - CAF_PDM_InitFieldNoDefault( &m_fillStyle_OBSOLETE, "FillStyle", "Area Fill Style", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_fillStyle_OBSOLETE, "FillStyle", "Area Fill Style" ); m_fillStyle_OBSOLETE.xmlCapability()->setIOWritable( false ); - CAF_PDM_InitFieldNoDefault( &m_pointSymbol_OBSOLETE, "PointSymbol", "Symbol", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_pointSymbol_OBSOLETE, "PointSymbol", "Symbol" ); m_pointSymbol_OBSOLETE.xmlCapability()->setIOWritable( false ); - CAF_PDM_InitField( &m_symbolEdgeColor_OBSOLETE, - "SymbolEdgeColor", - RiaColorTools::textColor3f(), - "Symbol Edge Color", - "", - "", - "" ); + CAF_PDM_InitField( &m_symbolEdgeColor_OBSOLETE, "SymbolEdgeColor", RiaColorTools::textColor3f(), "Symbol Edge Color" ); m_symbolEdgeColor_OBSOLETE.xmlCapability()->setIOWritable( false ); CAF_PDM_InitField( &m_symbolSkipPixelDistance_OBSOLETE, @@ -116,30 +104,24 @@ RimPlotCurve::RimPlotCurve() "" ); m_symbolSkipPixelDistance_OBSOLETE.xmlCapability()->setIOWritable( false ); - CAF_PDM_InitFieldNoDefault( &m_symbolLabel_OBSOLETE, "SymbolLabel", "Symbol Label", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_symbolLabel_OBSOLETE, "SymbolLabel", "Symbol Label" ); m_symbolLabel_OBSOLETE.xmlCapability()->setIOWritable( false ); - CAF_PDM_InitField( &m_symbolSize_OBSOLETE, "SymbolSize", 6, "Symbol Size", "", "", "" ); + CAF_PDM_InitField( &m_symbolSize_OBSOLETE, "SymbolSize", 6, "Symbol Size" ); m_symbolSize_OBSOLETE.xmlCapability()->setIOWritable( false ); - CAF_PDM_InitFieldNoDefault( &m_symbolLabelPosition_OBSOLETE, "SymbolLabelPosition", "Symbol Label Position", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_symbolLabelPosition_OBSOLETE, "SymbolLabelPosition", "Symbol Label Position" ); m_symbolLabelPosition_OBSOLETE.xmlCapability()->setIOWritable( false ); - CAF_PDM_InitFieldNoDefault( &m_curveAppearance, "PlotCurveAppearance", "PlotCurveAppearance", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_curveAppearance, "PlotCurveAppearance", "PlotCurveAppearance" ); m_curveAppearance = new RimPlotCurveAppearance; m_curveAppearance.uiCapability()->setUiTreeHidden( true ); m_curveAppearance.uiCapability()->setUiTreeChildrenHidden( true ); m_curveAppearance->appearanceChanged.connect( this, &RimPlotCurve::onCurveAppearanceChanged ); - m_curveAppearance->appearanceChanged.connect( this, &RimPlotCurve::onFillColorChanged ); - - m_qwtPlotCurve = new RiuRimQwtPlotCurve( this ); - m_qwtCurveErrorBars = new QwtPlotIntervalCurve(); - m_qwtCurveErrorBars->setStyle( QwtPlotIntervalCurve::CurveStyle::NoCurve ); - m_qwtCurveErrorBars->setSymbol( new QwtIntervalSymbol( QwtIntervalSymbol::Bar ) ); - m_qwtCurveErrorBars->setItemAttribute( QwtPlotItem::Legend, false ); - m_qwtCurveErrorBars->setZ( RiuQwtPlotCurveDefines::zDepthForIndex( RiuQwtPlotCurveDefines::ZIndex::Z_ERROR_BARS ) ); + m_curveAppearance->fillColorChanged.connect( this, &RimPlotCurve::onFillColorChanged ); - m_parentQwtPlot = nullptr; + m_plotCurve = nullptr; + m_parentPlot = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -147,18 +129,11 @@ RimPlotCurve::RimPlotCurve() //-------------------------------------------------------------------------------------------------- RimPlotCurve::~RimPlotCurve() { - if ( m_qwtPlotCurve ) - { - m_qwtPlotCurve->detach(); - delete m_qwtPlotCurve; - m_qwtPlotCurve = nullptr; - } - - if ( m_qwtCurveErrorBars ) + if ( m_plotCurve ) { - m_qwtCurveErrorBars->detach(); - delete m_qwtCurveErrorBars; - m_qwtCurveErrorBars = nullptr; + m_plotCurve->detach(); + delete m_plotCurve; + m_plotCurve = nullptr; } } @@ -198,7 +173,7 @@ void RimPlotCurve::fieldChangedByUi( const caf::PdmFieldHandle* changedField, co } RiuPlotMainWindowTools::refreshToolbars(); - if ( m_parentQwtPlot ) m_parentQwtPlot->replot(); + replotParentPlot(); } //-------------------------------------------------------------------------------------------------- @@ -244,22 +219,7 @@ void RimPlotCurve::setLegendEntryText( const QString& legendEntryText ) void RimPlotCurve::setErrorBarsVisible( bool isVisible ) { m_showErrorBars = isVisible; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimPlotCurve::updateCurveVisibility() -{ - if ( canCurveBeAttached() ) - { - attachCurveAndErrorBars(); - } - else - { - m_qwtPlotCurve->detach(); - m_qwtCurveErrorBars->detach(); - } + updateCurveAppearance(); } //-------------------------------------------------------------------------------------------------- @@ -293,37 +253,6 @@ void RimPlotCurve::updateCurvePresentation( bool updatePlotLegendAndTitle ) updateCurveAppearance(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimPlotCurve::setParentQwtPlotAndReplot( QwtPlot* plot ) -{ - m_parentQwtPlot = plot; - if ( canCurveBeAttached() ) - { - attachCurveAndErrorBars(); - - m_parentQwtPlot->replot(); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimPlotCurve::setParentQwtPlotNoReplot( QwtPlot* plot ) -{ - m_parentQwtPlot = plot; - if ( canCurveBeAttached() ) - { - attachCurveAndErrorBars(); - } - else - { - m_qwtPlotCurve->detach(); - m_qwtCurveErrorBars->detach(); - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -349,35 +278,6 @@ cvf::Color3f RimPlotCurve::color() const return m_curveAppearance->color(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimPlotCurve::detachQwtCurve() -{ - m_qwtPlotCurve->detach(); - m_qwtCurveErrorBars->detach(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimPlotCurve::reattachQwtCurve() -{ - detachQwtCurve(); - if ( canCurveBeAttached() ) - { - attachCurveAndErrorBars(); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QwtPlotCurve* RimPlotCurve::qwtPlotCurve() const -{ - return m_qwtPlotCurve; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -408,16 +308,13 @@ void RimPlotCurve::updateCurveName() m_curveName = m_customCurveName; } - if ( m_qwtPlotCurve ) + if ( !m_legendEntryText().isEmpty() ) { - if ( !m_legendEntryText().isEmpty() ) - { - m_qwtPlotCurve->setTitle( m_legendEntryText ); - } - else - { - m_qwtPlotCurve->setTitle( m_curveName ); - } + setTitle( m_legendEntryText ); + } + else + { + setTitle( m_curveName ); } } @@ -460,126 +357,6 @@ void RimPlotCurve::updatePlotTitle() } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimPlotCurve::updateLegendsInPlot() -{ - nameChanged.send( curveName() ); - if ( m_parentQwtPlot != nullptr ) - { - m_parentQwtPlot->updateLegend(); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimPlotCurve::setSamplesFromXYErrorValues( - const std::vector& xValues, - const std::vector& yValues, - const std::vector& errorValues, - bool keepOnlyPositiveValues, - RiaCurveDataTools::ErrorAxis errorAxis /*= RiuQwtPlotCurve::ERROR_ALONG_Y_AXIS */ ) -{ - CVF_ASSERT( xValues.size() == yValues.size() ); - CVF_ASSERT( xValues.size() == errorValues.size() ); - - auto intervalsOfValidValues = RiaCurveDataTools::calculateIntervalsOfValidValues( yValues, keepOnlyPositiveValues ); - std::vector filteredYValues; - std::vector filteredXValues; - - RiaCurveDataTools::getValuesByIntervals( yValues, intervalsOfValidValues, &filteredYValues ); - RiaCurveDataTools::getValuesByIntervals( xValues, intervalsOfValidValues, &filteredXValues ); - - std::vector filteredErrorValues; - RiaCurveDataTools::getValuesByIntervals( errorValues, intervalsOfValidValues, &filteredErrorValues ); - - QVector errorIntervals; - - errorIntervals.reserve( static_cast( filteredXValues.size() ) ); - - for ( size_t i = 0; i < filteredXValues.size(); i++ ) - { - if ( filteredYValues[i] != DOUBLE_INF && filteredErrorValues[i] != DOUBLE_INF ) - { - if ( errorAxis == RiaCurveDataTools::ErrorAxis::ERROR_ALONG_Y_AXIS ) - { - errorIntervals << QwtIntervalSample( filteredXValues[i], - filteredYValues[i] - filteredErrorValues[i], - filteredYValues[i] + filteredErrorValues[i] ); - } - else - { - errorIntervals << QwtIntervalSample( filteredYValues[i], - filteredXValues[i] - filteredErrorValues[i], - filteredXValues[i] + filteredErrorValues[i] ); - } - } - } - - if ( m_qwtPlotCurve ) - { - m_qwtPlotCurve->setSamples( filteredXValues.data(), - filteredYValues.data(), - static_cast( filteredXValues.size() ) ); - - m_qwtPlotCurve->setLineSegmentStartStopIndices( intervalsOfValidValues ); - } - - if ( m_qwtCurveErrorBars ) - { - m_qwtCurveErrorBars->setSamples( errorIntervals ); - if ( errorAxis == RiaCurveDataTools::ErrorAxis::ERROR_ALONG_Y_AXIS ) - { - m_qwtCurveErrorBars->setOrientation( Qt::Vertical ); - } - else - { - m_qwtCurveErrorBars->setOrientation( Qt::Horizontal ); - } - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimPlotCurve::setSamplesFromXYValues( const std::vector& xValues, - const std::vector& yValues, - bool keepOnlyPositiveValues ) -{ - if ( m_qwtPlotCurve ) - { - m_qwtPlotCurve->setSamplesFromXValuesAndYValues( xValues, yValues, keepOnlyPositiveValues ); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimPlotCurve::setSamplesFromDatesAndYValues( const std::vector& dateTimes, - const std::vector& yValues, - bool keepOnlyPositiveValues ) -{ - if ( m_qwtPlotCurve ) - { - m_qwtPlotCurve->setSamplesFromDatesAndYValues( dateTimes, yValues, keepOnlyPositiveValues ); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimPlotCurve::setSamplesFromTimeTAndYValues( const std::vector& dateTimes, - const std::vector& yValues, - bool keepOnlyPositiveValues ) -{ - if ( m_qwtPlotCurve ) - { - m_qwtPlotCurve->setSamplesFromTimeTAndYValues( dateTimes, yValues, keepOnlyPositiveValues ); - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -598,21 +375,6 @@ void RimPlotCurve::curveNameUiOrdering( caf::PdmUiOrdering& uiOrdering ) uiOrdering.add( &m_curveName ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimPlotCurve::updateUiIconFromPlotSymbol() -{ - if ( m_curveAppearance->symbol() != RiuQwtSymbol::SYMBOL_NONE && m_qwtPlotCurve ) - { - CVF_ASSERT( RiaGuiApplication::isRunning() ); - QSizeF iconSize( 24, 24 ); - QwtGraphic graphic = m_qwtPlotCurve->legendIcon( 0, iconSize ); - QPixmap pixmap = graphic.toPixmap(); - setUiIcon( caf::IconProvider( pixmap ) ); - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -638,7 +400,7 @@ void RimPlotCurve::updateCurveAppearanceForFilesOlderThan_2021_06() //-------------------------------------------------------------------------------------------------- bool RimPlotCurve::canCurveBeAttached() const { - if ( !m_parentQwtPlot ) + if ( !hasParentPlot() ) { return false; } @@ -663,19 +425,6 @@ bool RimPlotCurve::canCurveBeAttached() const return isVisibleInPossibleParent; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimPlotCurve::attachCurveAndErrorBars() -{ - m_qwtPlotCurve->attach( m_parentQwtPlot ); - - if ( m_showErrorBars ) - { - m_qwtCurveErrorBars->attach( m_parentQwtPlot ); - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -687,88 +436,6 @@ void RimPlotCurve::checkAndApplyDefaultFillColor() // } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimPlotCurve::updateCurveAppearance() -{ - QColor curveColor = RiaColorTools::toQColor( m_curveAppearance->color() ); - QwtSymbol* symbol = nullptr; - - if ( m_curveAppearance->symbol() != RiuQwtSymbol::SYMBOL_NONE ) - { - int legendFontSize = caf::FontTools::absolutePointSize( RiaPreferences::current()->defaultPlotFontSize(), - caf::FontTools::RelativeSize::Small ); - RimPlotWindow* plotWindow = nullptr; - this->firstAncestorOrThisOfType( plotWindow ); - if ( plotWindow ) - { - legendFontSize = plotWindow->legendFontSize(); - } - - // QwtPlotCurve will take ownership of the symbol - symbol = new RiuQwtSymbol( m_curveAppearance->symbol(), - m_curveAppearance->symbolLabel(), - m_curveAppearance->symbolLabelPosition(), - legendFontSize ); - symbol->setSize( m_curveAppearance->symbolSize(), m_curveAppearance->symbolSize() ); - symbol->setColor( curveColor ); - - // If the symbol is a "filled" symbol, we can have a different edge color - // Otherwise we'll have to use the curve color. - if ( RiuQwtSymbol::isFilledSymbol( m_curveAppearance->symbol() ) ) - { - QColor symbolEdgeColor = RiaColorTools::toQColor( m_curveAppearance->symbolEdgeColor() ); - symbol->setPen( symbolEdgeColor ); - } - else - { - symbol->setPen( curveColor ); - } - } - - if ( m_qwtCurveErrorBars ) - { - QwtIntervalSymbol* newSymbol = new QwtIntervalSymbol( QwtIntervalSymbol::Bar ); - newSymbol->setPen( QPen( curveColor ) ); - m_qwtCurveErrorBars->setSymbol( newSymbol ); - } - - if ( m_qwtPlotCurve ) - { - QColor fillColor = RiaColorTools::toQColor( m_curveAppearance->fillColor() ); - - fillColor = RiaColorTools::blendQColors( fillColor, QColor( Qt::white ), 3, 1 ); - QBrush fillBrush( fillColor, m_curveAppearance->fillStyle() ); - m_qwtPlotCurve->setAppearance( m_curveAppearance->lineStyle(), - m_curveAppearance->interpolation(), - m_curveAppearance->lineThickness(), - curveColor, - fillBrush ); - m_qwtPlotCurve->setSymbol( symbol ); - m_qwtPlotCurve->setSymbolSkipPixelDistance( m_curveAppearance->symbolSkipDistance() ); - - // Make sure the legend lines are long enough to distinguish between line types. - // Standard width in Qwt is 8 which is too short. - // Use 10 and scale this by curve thickness + add space for displaying symbol. - if ( m_curveAppearance->lineStyle() != RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_NONE ) - { - QSize legendIconSize = m_qwtPlotCurve->legendIconSize(); - - int symbolWidth = 0; - if ( symbol ) - { - symbolWidth = symbol->boundingRect().size().width() + 2; - } - - int width = std::max( 10 * m_curveAppearance->lineThickness(), ( symbolWidth * 3 ) / 2 ); - - legendIconSize.setWidth( width ); - m_qwtPlotCurve->setLegendIconSize( legendIconSize ); - } - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -793,44 +460,6 @@ void RimPlotCurve::loadDataAndUpdate( bool updateParentPlot ) } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RimPlotCurve::xValueRangeInQwt( double* minimumValue, double* maximumValue ) const -{ - CVF_ASSERT( minimumValue && maximumValue ); - CVF_ASSERT( m_qwtPlotCurve ); - - if ( m_qwtPlotCurve->data()->size() < 1 ) - { - return false; - } - - *minimumValue = m_qwtPlotCurve->minXValue(); - *maximumValue = m_qwtPlotCurve->maxXValue(); - - return true; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RimPlotCurve::yValueRangeInQwt( double* minimumValue, double* maximumValue ) const -{ - CVF_ASSERT( minimumValue && maximumValue ); - CVF_ASSERT( m_qwtPlotCurve ); - - if ( m_qwtPlotCurve->data()->size() < 1 ) - { - return false; - } - - *minimumValue = m_qwtPlotCurve->minYValue(); - *maximumValue = m_qwtPlotCurve->maxYValue(); - - return true; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -842,7 +471,7 @@ void RimPlotCurve::setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum lineStyle //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimPlotCurve::setSymbol( RiuQwtSymbol::PointSymbolEnum symbolStyle ) +void RimPlotCurve::setSymbol( RiuPlotCurveSymbol::PointSymbolEnum symbolStyle ) { m_curveAppearance->setSymbol( symbolStyle ); } @@ -858,7 +487,7 @@ void RimPlotCurve::setInterpolation( RiuQwtPlotCurveDefines::CurveInterpolationE //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuQwtSymbol::PointSymbolEnum RimPlotCurve::symbol() +RiuPlotCurveSymbol::PointSymbolEnum RimPlotCurve::symbol() { return m_curveAppearance->symbol(); } @@ -906,7 +535,7 @@ void RimPlotCurve::setSymbolLabel( const QString& label ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimPlotCurve::setSymbolLabelPosition( RiuQwtSymbol::LabelPosition labelPosition ) +void RimPlotCurve::setSymbolLabelPosition( RiuPlotCurveSymbol::LabelPosition labelPosition ) { m_curveAppearance->setSymbolLabelPosition( labelPosition ); } @@ -936,7 +565,7 @@ void RimPlotCurve::resetAppearance() setSymbolEdgeColor( RiaColorTools::textColor3f() ); setLineThickness( 2 ); setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID ); - setSymbol( RiuQwtSymbol::SYMBOL_NONE ); + setSymbol( RiuPlotCurveSymbol::SYMBOL_NONE ); setSymbolSkipDistance( 10 ); } @@ -986,27 +615,138 @@ bool RimPlotCurve::errorBarsVisible() const void RimPlotCurve::setShowInLegend( bool show ) { m_showLegend = show; + if ( m_plotCurve ) m_plotCurve->setVisibleInLegend( show ); + updateLegendEntryVisibilityNoPlotUpdate(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimPlotCurve::setZOrder( double z ) +void RimPlotCurve::updateLegendEntryVisibilityAndPlotLegend() { - if ( m_qwtPlotCurve != nullptr ) + updateLegendEntryVisibilityNoPlotUpdate(); + updateLegendsInPlot(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotCurve::onCurveAppearanceChanged( const caf::SignalEmitter* emitter ) +{ + checkAndApplyDefaultFillColor(); + updateCurveAppearance(); + appearanceChanged.send(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotCurve::onFillColorChanged( const caf::SignalEmitter* emitter ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotCurve::updateLegendsInPlot() +{ + nameChanged.send( curveName() ); + if ( m_parentPlot != nullptr ) { - m_qwtPlotCurve->setZ( z ); + m_parentPlot->updateLegend(); } } +void RimPlotCurve::setTitle( const QString& title ) +{ + if ( m_plotCurve ) m_plotCurve->setTitle( title ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimPlotCurve::updateLegendEntryVisibilityAndPlotLegend() +void RimPlotCurve::replotParentPlot() { - updateLegendEntryVisibilityNoPlotUpdate(); - updateLegendsInPlot(); + if ( m_parentPlot ) m_parentPlot->replot(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimPlotCurve::hasParentPlot() const +{ + return ( m_parentPlot != nullptr ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotCurve::setSamplesFromXYValues( const std::vector& xValues, + const std::vector& yValues, + bool useLogarithmicScale ) +{ + if ( m_plotCurve ) + { + m_plotCurve->setSamplesFromXValuesAndYValues( xValues, yValues, useLogarithmicScale ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotCurve::setSamplesFromDatesAndYValues( const std::vector& dateTimes, + const std::vector& yValues, + bool useLogarithmicScale ) +{ + if ( m_plotCurve ) + { + m_plotCurve->setSamplesFromDatesAndYValues( dateTimes, yValues, useLogarithmicScale ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotCurve::setSamplesFromTimeTAndYValues( const std::vector& dateTimes, + const std::vector& yValues, + bool useLogarithmicScale ) +{ + if ( m_plotCurve ) + { + m_plotCurve->setSamplesFromTimeTAndYValues( dateTimes, yValues, useLogarithmicScale ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimPlotCurve::computeCurveZValue() +{ + return 1.0; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotCurve::setSamplesFromXYErrorValues( const std::vector& xValues, + const std::vector& yValues, + const std::vector& errorValues, + bool useLogarithmicScale, + RiaCurveDataTools::ErrorAxis errorAxis ) +{ + if ( m_plotCurve ) + { + m_plotCurve->setSamplesFromXYErrorValues( xValues, yValues, errorValues, useLogarithmicScale, errorAxis ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotCurve::updateAxisInPlot( RiuPlotAxis plotAxis ) +{ + if ( m_plotCurve ) m_plotCurve->setYAxis( plotAxis ); } //-------------------------------------------------------------------------------------------------- @@ -1014,7 +754,7 @@ void RimPlotCurve::updateLegendEntryVisibilityAndPlotLegend() //-------------------------------------------------------------------------------------------------- void RimPlotCurve::updateLegendEntryVisibilityNoPlotUpdate() { - if ( !m_qwtPlotCurve ) return; + if ( !m_plotCurve ) return; RimEnsembleCurveSet* ensembleCurveSet = nullptr; this->firstAncestorOrThisOfType( ensembleCurveSet ); @@ -1023,7 +763,7 @@ void RimPlotCurve::updateLegendEntryVisibilityNoPlotUpdate() return; } - bool showLegendInQwt = m_showLegend(); + bool showLegendInPlot = m_showLegend(); RimSummaryPlot* summaryPlot = nullptr; this->firstAncestorOrThisOfType( summaryPlot ); @@ -1044,25 +784,312 @@ void RimPlotCurve::updateLegendEntryVisibilityNoPlotUpdate() summaryPlot->curveCount() == 1 ) { // Disable display of legend if the summary plot has only one single curve - showLegendInQwt = false; + showLegendInPlot = false; } } - m_qwtPlotCurve->setItemAttribute( QwtPlotItem::Legend, showLegendInQwt ); + + m_plotCurve->setVisibleInLegend( showLegendInPlot ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimPlotCurve::onCurveAppearanceChanged( const caf::SignalEmitter* emitter ) +bool RimPlotCurve::xValueRange( double* minimumValue, double* maximumValue ) const { - checkAndApplyDefaultFillColor(); - updateCurveAppearance(); - appearanceChanged.send(); + CAF_ASSERT( minimumValue && maximumValue ); + CAF_ASSERT( m_plotCurve ); + + if ( m_plotCurve->numSamples() < 1 ) + { + return false; + } + + auto [min, max] = m_plotCurve->xDataRange(); + *minimumValue = min; + *maximumValue = max; + + return true; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimPlotCurve::onFillColorChanged( const caf::SignalEmitter* emitter ) +bool RimPlotCurve::yValueRange( double* minimumValue, double* maximumValue ) const +{ + CAF_ASSERT( minimumValue && maximumValue ); + CAF_ASSERT( m_plotCurve ); + + if ( m_plotCurve->numSamples() < 1 ) + { + return false; + } + + auto [min, max] = m_plotCurve->yDataRange(); + *minimumValue = min; + *maximumValue = max; + + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotCurve::setZOrder( double z ) +{ + if ( m_plotCurve != nullptr ) + { + m_plotCurve->setZ( z ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotCurve::updateCurveAppearance() +{ + QColor curveColor = RiaColorTools::toQColor( m_curveAppearance->color() ); + + if ( !m_plotCurve ) return; + + RiuPlotCurveSymbol* symbol = nullptr; + if ( m_curveAppearance->symbol() != RiuPlotCurveSymbol::SYMBOL_NONE ) + { + int legendFontSize = caf::FontTools::absolutePointSize( RiaPreferences::current()->defaultPlotFontSize(), + caf::FontTools::RelativeSize::Small ); + + RimPlotWindow* plotWindow = nullptr; + this->firstAncestorOrThisOfType( plotWindow ); + if ( plotWindow ) + { + legendFontSize = plotWindow->legendFontSize(); + } + + // Plot curve will take ownership of the symbol + symbol = m_plotCurve->createSymbol( m_curveAppearance->symbol() ); + + if ( symbol ) + { + symbol->setLabelPosition( m_curveAppearance->symbolLabelPosition() ); + symbol->setGlobalLabel( m_curveAppearance->symbolLabel() ); + symbol->setSize( m_curveAppearance->symbolSize(), m_curveAppearance->symbolSize() ); + symbol->setColor( curveColor ); + symbol->setLabelFontSize( legendFontSize ); + + // If the symbol is a "filled" symbol, we can have a different edge color + // Otherwise we'll have to use the curve color. + if ( RiuPlotCurveSymbol::isFilledSymbol( m_curveAppearance->symbol() ) ) + { + QColor symbolEdgeColor = RiaColorTools::toQColor( m_curveAppearance->symbolEdgeColor() ); + symbol->setPen( symbolEdgeColor ); + } + else + { + symbol->setPen( curveColor ); + } + } + } + + m_plotCurve->updateErrorBarsAppearance( m_showErrorBars, curveColor ); + + QColor fillColor = RiaColorTools::toQColor( m_curveAppearance->fillColor() ); + + fillColor = RiaColorTools::blendQColors( fillColor, QColor( Qt::white ), 3, 1 ); + QBrush fillBrush( fillColor, m_curveAppearance->fillStyle() ); + m_plotCurve->setAppearance( m_curveAppearance->lineStyle(), + m_curveAppearance->interpolation(), + m_curveAppearance->lineThickness(), + curveColor, + fillBrush ); + + m_plotCurve->setSymbolSkipPixelDistance( m_curveAppearance->symbolSkipDistance() ); + m_plotCurve->setSymbol( symbol ); + + // Make sure the legend lines are long enough to distinguish between line types. + // Standard width in Qwt is 8 which is too short. + // Use 10 and scale this by curve thickness + add space for displaying symbol. + if ( m_curveAppearance->lineStyle() != RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_NONE ) + { + QSize legendIconSize = m_plotCurve->legendIconSize(); + + int symbolWidth = 0; + if ( symbol ) + { + symbolWidth = symbol->boundingRect().size().width() + 2; + } + + int width = std::max( 10 * m_curveAppearance->lineThickness(), ( symbolWidth * 3 ) / 2 ); + + legendIconSize.setWidth( width ); + m_plotCurve->setLegendIconSize( legendIconSize ); + } + + double tolerance = 0.0; + if ( m_curveAppearance->lineStyle() != RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID ) + { + tolerance = m_curveAppearance->curveFittingTolerance(); + } + m_plotCurve->setCurveFittingTolerance( tolerance ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotCurve::clearErrorBars() +{ + if ( m_plotCurve ) m_plotCurve->clearErrorBars(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotCurve::updateUiIconFromPlotSymbol() +{ + if ( m_curveAppearance->symbol() != RiuPlotCurveSymbol::SYMBOL_NONE && m_plotCurve ) + { + CAF_ASSERT( RiaGuiApplication::isRunning() ); + QSizeF iconSize( 24, 24 ); + QPixmap pixmap = m_plotCurve->legendIcon( iconSize ); + setUiIcon( caf::IconProvider( pixmap ) ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotCurve::updateCurveVisibility() +{ + if ( canCurveBeAttached() ) + { + reattach(); + } + else + { + detach(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimPlotCurve::dataSize() const +{ + if ( m_plotCurve ) + return m_plotCurve->numSamples(); + else + return 0; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair RimPlotCurve::sample( int index ) const +{ + CAF_ASSERT( m_plotCurve ); + CAF_ASSERT( index >= 0 && index <= dataSize() ); + return m_plotCurve->sample( index ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotCurve::setParentPlotNoReplot( RiuPlotWidget* plotWidget ) +{ + if ( !plotWidget ) return; + + m_parentPlot = plotWidget; + if ( m_plotCurve ) + { + m_plotCurve->attachToPlot( plotWidget ); + return; + } + + m_plotCurve = m_parentPlot->createPlotCurve( this, "", RiaColorTools::toQColor( m_curveAppearance->color() ) ); + + // PERFORMANCE NOTE + // When the z-value of a curve is changed, several update calls are made to the plot. Make sure that the default + // z-value is correct to avoid these calls. + m_plotCurve->setZ( computeCurveZValue() ); + + m_plotCurve->attachToPlot( plotWidget ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotCurve::setParentPlotAndReplot( RiuPlotWidget* plotWidget ) +{ + CAF_ASSERT( plotWidget ); + + setParentPlotNoReplot( plotWidget ); + plotWidget->replot(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotCurve::attach( RiuPlotWidget* plotWidget ) +{ + setParentPlotAndReplot( plotWidget ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotCurve::detach( bool deletePlotCurve ) +{ + if ( m_plotCurve ) + { + if ( deletePlotCurve ) + { + delete m_plotCurve; + m_plotCurve = nullptr; + } + else + { + m_plotCurve->detach(); + } + } + + m_parentPlot->scheduleReplot(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotCurve::reattach() +{ + if ( m_parentPlot && canCurveBeAttached() ) attach( m_parentPlot ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimPlotCurve::isSameCurve( const RiuPlotCurve* plotCurve ) const +{ + return m_plotCurve == plotCurve; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotCurve::deletePlotCurve() +{ + delete m_plotCurve; + m_plotCurve = nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimPlotCurve::curveName() const +{ + return m_curveName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimPlotCurve::curveExportDescription( const RifEclipseSummaryAddress& address ) const { + return m_curveName; } diff --git a/ApplicationLibCode/ProjectDataModel/RimPlotCurve.h b/ApplicationLibCode/ProjectDataModel/RimPlotCurve.h index 8ba949857f..c8a98d55cb 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPlotCurve.h +++ b/ApplicationLibCode/ProjectDataModel/RimPlotCurve.h @@ -22,8 +22,9 @@ #include "RimPlotCurveAppearance.h" #include "RiaCurveDataTools.h" -#include "RiaDefines.h" +#include "RiaPlotDefines.h" +#include "RiuPlotAxis.h" #include "RiuQwtPlotCurveDefines.h" #include "RiuQwtSymbol.h" @@ -35,10 +36,8 @@ #include #include -class QwtPlot; -class QwtPlotCurve; -class QwtPlotIntervalCurve; -class RiuQwtPlotCurve; +class RiuPlotCurve; +class RiuPlotWidget; //================================================================================================== /// @@ -60,33 +59,24 @@ class RimPlotCurve : public caf::PdmObject void loadDataAndUpdate( bool updateParentPlot ); - virtual bool xValueRangeInQwt( double* minimumValue, double* maximumValue ) const; - virtual bool yValueRangeInQwt( double* minimumValue, double* maximumValue ) const; - - void setParentQwtPlotAndReplot( QwtPlot* plot ); - void setParentQwtPlotNoReplot( QwtPlot* plot ); - void detachQwtCurve(); - void reattachQwtCurve(); - QwtPlotCurve* qwtPlotCurve() const; - - void setColor( const cvf::Color3f& color ); - cvf::Color3f color() const; - void setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum lineStyle ); - void setSymbol( RiuQwtSymbol::PointSymbolEnum symbolStyle ); - void setInterpolation( RiuQwtPlotCurveDefines::CurveInterpolationEnum ); - RiuQwtSymbol::PointSymbolEnum symbol(); - int symbolSize() const; - cvf::Color3f symbolEdgeColor() const; - void setSymbolEdgeColor( const cvf::Color3f& edgeColor ); - void setSymbolSkipDistance( float distance ); - void setSymbolLabel( const QString& label ); - void setSymbolLabelPosition( RiuQwtSymbol::LabelPosition labelPosition ); - void setSymbolSize( int sizeInPixels ); - void setLineThickness( int thickness ); - void resetAppearance(); - Qt::BrushStyle fillStyle() const; - void setFillStyle( Qt::BrushStyle brushStyle ); - void setFillColor( const cvf::Color3f& fillColor ); + void setColor( const cvf::Color3f& color ); + cvf::Color3f color() const; + void setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum lineStyle ); + void setSymbol( RiuPlotCurveSymbol::PointSymbolEnum symbolStyle ); + void setInterpolation( RiuQwtPlotCurveDefines::CurveInterpolationEnum ); + RiuPlotCurveSymbol::PointSymbolEnum symbol(); + int symbolSize() const; + cvf::Color3f symbolEdgeColor() const; + void setSymbolEdgeColor( const cvf::Color3f& edgeColor ); + void setSymbolSkipDistance( float distance ); + void setSymbolLabel( const QString& label ); + void setSymbolLabelPosition( RiuPlotCurveSymbol::LabelPosition labelPosition ); + void setSymbolSize( int sizeInPixels ); + void setLineThickness( int thickness ); + void resetAppearance(); + Qt::BrushStyle fillStyle() const; + void setFillStyle( Qt::BrushStyle brushStyle ); + void setFillColor( const cvf::Color3f& fillColor ); bool isCurveVisible() const; void setCurveVisibility( bool visible ); @@ -95,32 +85,49 @@ class RimPlotCurve : public caf::PdmObject void updateCurveNameAndUpdatePlotLegendAndTitle(); void updateCurveNameNoLegendUpdate(); - QString curveName() const { return m_curveName; } - virtual QString curveExportDescription( const RifEclipseSummaryAddress& address = RifEclipseSummaryAddress() ) const - { - return m_curveName; - } + QString curveName() const; + virtual QString curveExportDescription( const RifEclipseSummaryAddress& address = RifEclipseSummaryAddress() ) const; + void setCustomName( const QString& customName ); QString legendEntryText() const; void setLegendEntryText( const QString& legendEntryText ); - void updateCurveVisibility(); - void updateLegendEntryVisibilityAndPlotLegend(); - void updateLegendEntryVisibilityNoPlotUpdate(); + virtual void updateCurveVisibility(); + void updateLegendEntryVisibilityAndPlotLegend(); + void updateLegendEntryVisibilityNoPlotUpdate(); + virtual void replotParentPlot(); bool showInLegend() const; bool errorBarsVisible() const; - void setShowInLegend( bool show ); - void setZOrder( double z ); - void setErrorBarsVisible( bool isVisible ); + void setShowInLegend( bool show ); + virtual void setZOrder( double z ); + void setErrorBarsVisible( bool isVisible ); virtual void updateCurveAppearance(); bool isCrossPlotCurve() const; - void updateUiIconFromPlotSymbol(); + virtual void updateUiIconFromPlotSymbol(); + virtual bool hasParentPlot() const; void updateCurveAppearanceForFilesOlderThan_2021_06(); + virtual bool xValueRange( double* minimumValue, double* maximumValue ) const; + virtual bool yValueRange( double* minimumValue, double* maximumValue ) const; + + virtual void setTitle( const QString& title ); + + int dataSize() const; + std::pair sample( int index ) const; + + void setParentPlotNoReplot( RiuPlotWidget* ); + void setParentPlotAndReplot( RiuPlotWidget* ); + + void attach( RiuPlotWidget* ); + void detach( bool deletePlotCurve = false ); + void reattach(); + bool isSameCurve( const RiuPlotCurve* plotCurve ) const; + void deletePlotCurve(); + protected: virtual QString createCurveAutoName() = 0; virtual void updateZoomInParentPlot() = 0; @@ -135,18 +142,22 @@ class RimPlotCurve : public caf::PdmObject void setSamplesFromXYErrorValues( const std::vector& xValues, const std::vector& yValues, const std::vector& errorValues, - bool keepOnlyPositiveValues, + bool useLogarithmicScale, RiaCurveDataTools::ErrorAxis errorAxis = RiaCurveDataTools::ErrorAxis::ERROR_ALONG_Y_AXIS ); + void setSamplesFromXYValues( const std::vector& xValues, const std::vector& yValues, - bool keepOnlyPositiveValues ); + bool useLogarithmicScale ); + void setSamplesFromDatesAndYValues( const std::vector& dateTimes, const std::vector& yValues, - bool keepOnlyPositiveValues ); + bool useLogarithmicScale ); void setSamplesFromTimeTAndYValues( const std::vector& dateTimes, const std::vector& yValues, - bool keepOnlyPositiveValues ); + bool useLogarithmicScale ); + + virtual double computeCurveZValue(); protected: // Overridden PDM methods @@ -156,20 +167,16 @@ class RimPlotCurve : public caf::PdmObject void appearanceUiOrdering( caf::PdmUiOrdering& uiOrdering ); void curveNameUiOrdering( caf::PdmUiOrdering& uiOrdering ); - virtual void onCurveAppearanceChanged( const caf::SignalEmitter* emitter ); + void onCurveAppearanceChanged( const caf::SignalEmitter* emitter ); virtual void onFillColorChanged( const caf::SignalEmitter* emitter ); -private: - bool canCurveBeAttached() const; - void attachCurveAndErrorBars(); - void checkAndApplyDefaultFillColor(); - -protected: - QPointer m_parentQwtPlot; + bool canCurveBeAttached() const; + virtual void clearErrorBars(); + void checkAndApplyDefaultFillColor(); - RiuQwtPlotCurve* m_qwtPlotCurve; - QwtPlotIntervalCurve* m_qwtCurveErrorBars; + virtual void updateAxisInPlot( RiuPlotAxis plotAxis ); +protected: caf::PdmField m_showCurve; caf::PdmField m_curveName; caf::PdmField m_customCurveName; @@ -180,6 +187,9 @@ class RimPlotCurve : public caf::PdmObject caf::PdmChildField m_curveAppearance; + QPointer m_parentPlot; + RiuPlotCurve* m_plotCurve; + caf::PdmField m_symbolLabel_OBSOLETE; caf::PdmField m_symbolSize_OBSOLETE; caf::PdmField m_curveColor_OBSOLETE; diff --git a/ApplicationLibCode/ProjectDataModel/RimPlotCurveAppearance.cpp b/ApplicationLibCode/ProjectDataModel/RimPlotCurveAppearance.cpp index 104c9165fa..760199cc86 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPlotCurveAppearance.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimPlotCurveAppearance.cpp @@ -31,30 +31,30 @@ namespace caf template <> void RimPlotCurveAppearance::PointSymbol::setUp() { - addItem( RiuQwtSymbol::SYMBOL_NONE, "SYMBOL_NONE", "None" ); - addItem( RiuQwtSymbol::SYMBOL_ELLIPSE, "SYMBOL_ELLIPSE", "Ellipse" ); - addItem( RiuQwtSymbol::SYMBOL_RECT, "SYMBOL_RECT", "Rect" ); - addItem( RiuQwtSymbol::SYMBOL_DIAMOND, "SYMBOL_DIAMOND", "Diamond" ); - addItem( RiuQwtSymbol::SYMBOL_TRIANGLE, "SYMBOL_TRIANGLE", "Triangle" ); - addItem( RiuQwtSymbol::SYMBOL_DOWN_TRIANGLE, "SYMBOL_DOWN_TRIANGLE", "Down Triangle" ); - addItem( RiuQwtSymbol::SYMBOL_CROSS, "SYMBOL_CROSS", "Cross" ); - addItem( RiuQwtSymbol::SYMBOL_XCROSS, "SYMBOL_XCROSS", "X Cross" ); - addItem( RiuQwtSymbol::SYMBOL_STAR1, "SYMBOL_STAR1", "Star 1" ); - addItem( RiuQwtSymbol::SYMBOL_STAR2, "SYMBOL_STAR2", "Star 2" ); - addItem( RiuQwtSymbol::SYMBOL_HEXAGON, "SYMBOL_HEXAGON", "Hexagon" ); - addItem( RiuQwtSymbol::SYMBOL_LEFT_TRIANGLE, "SYMBOL_LEFT_TRIANGLE", "Left Triangle" ); - addItem( RiuQwtSymbol::SYMBOL_RIGHT_TRIANGLE, "SYMBOL_RIGHT_TRIANGLE", "Right Triangle" ); - setDefault( RiuQwtSymbol::SYMBOL_NONE ); + addItem( RiuPlotCurveSymbol::SYMBOL_NONE, "SYMBOL_NONE", "None" ); + addItem( RiuPlotCurveSymbol::SYMBOL_ELLIPSE, "SYMBOL_ELLIPSE", "Ellipse" ); + addItem( RiuPlotCurveSymbol::SYMBOL_RECT, "SYMBOL_RECT", "Rect" ); + addItem( RiuPlotCurveSymbol::SYMBOL_DIAMOND, "SYMBOL_DIAMOND", "Diamond" ); + addItem( RiuPlotCurveSymbol::SYMBOL_TRIANGLE, "SYMBOL_TRIANGLE", "Triangle" ); + addItem( RiuPlotCurveSymbol::SYMBOL_DOWN_TRIANGLE, "SYMBOL_DOWN_TRIANGLE", "Down Triangle" ); + addItem( RiuPlotCurveSymbol::SYMBOL_CROSS, "SYMBOL_CROSS", "Cross" ); + addItem( RiuPlotCurveSymbol::SYMBOL_XCROSS, "SYMBOL_XCROSS", "X Cross" ); + addItem( RiuPlotCurveSymbol::SYMBOL_STAR1, "SYMBOL_STAR1", "Star 1" ); + addItem( RiuPlotCurveSymbol::SYMBOL_STAR2, "SYMBOL_STAR2", "Star 2" ); + addItem( RiuPlotCurveSymbol::SYMBOL_HEXAGON, "SYMBOL_HEXAGON", "Hexagon" ); + addItem( RiuPlotCurveSymbol::SYMBOL_LEFT_TRIANGLE, "SYMBOL_LEFT_TRIANGLE", "Left Triangle" ); + addItem( RiuPlotCurveSymbol::SYMBOL_RIGHT_TRIANGLE, "SYMBOL_RIGHT_TRIANGLE", "Right Triangle" ); + setDefault( RiuPlotCurveSymbol::SYMBOL_NONE ); } template <> void RimPlotCurveAppearance::LabelPosition::setUp() { - addItem( RiuQwtSymbol::LabelAboveSymbol, "LABEL_ABOVE_SYMBOL", "Label above Symbol" ); - addItem( RiuQwtSymbol::LabelBelowSymbol, "LABEL_BELOW_SYMBOL", "Label below Symbol" ); - addItem( RiuQwtSymbol::LabelLeftOfSymbol, "LABEL_LEFT_OF_SYMBOL", "Label left of Symbol" ); - addItem( RiuQwtSymbol::LabelRightOfSymbol, "LABEL_RIGHT_OF_SYMBOL", "Label right of Symbol" ); - setDefault( RiuQwtSymbol::LabelAboveSymbol ); + addItem( RiuPlotCurveSymbol::LabelAboveSymbol, "LABEL_ABOVE_SYMBOL", "Label above Symbol" ); + addItem( RiuPlotCurveSymbol::LabelBelowSymbol, "LABEL_BELOW_SYMBOL", "Label below Symbol" ); + addItem( RiuPlotCurveSymbol::LabelLeftOfSymbol, "LABEL_LEFT_OF_SYMBOL", "Label left of Symbol" ); + addItem( RiuPlotCurveSymbol::LabelRightOfSymbol, "LABEL_RIGHT_OF_SYMBOL", "Label right of Symbol" ); + setDefault( RiuPlotCurveSymbol::LabelAboveSymbol ); } template <> @@ -69,6 +69,7 @@ void RimPlotCurveAppearance::FillStyle::setUp() addItem( Qt::BDiagPattern, "DIAG_FILL", "Diagonal Lines" ); addItem( Qt::CrossPattern, "CROSS_FILL", "Mesh" ); addItem( Qt::DiagCrossPattern, "DIAG_CROSS_FILL", "Diagonal Mesh" ); + setDefault( Qt::NoBrush ); } } // namespace caf @@ -83,19 +84,19 @@ RimPlotCurveAppearance::RimPlotCurveAppearance() , m_interpolationVisible( true ) , m_fillOptionsVisible( true ) { - CAF_PDM_InitObject( "Curve Apperance", "", "", "" ); + CAF_PDM_InitObject( "Curve Apperance" ); - CAF_PDM_InitField( &m_curveColor, "Color", RiaColorTools::textColor3f(), "Color", "", "", "" ); - CAF_PDM_InitField( &m_fillColor, "FillColor", cvf::Color3f( -1.0, -1.0, -1.0 ), "Fill Color", "", "", "" ); + CAF_PDM_InitField( &m_curveColor, "Color", RiaColorTools::textColor3f(), "Color" ); + CAF_PDM_InitField( &m_fillColor, "FillColor", cvf::Color3f( -1.0, -1.0, -1.0 ), "Fill Color" ); - CAF_PDM_InitField( &m_curveThickness, "Thickness", 1, "Line Thickness", "", "", "" ); + CAF_PDM_InitField( &m_curveThickness, "Thickness", 1, "Line Thickness" ); m_curveThickness.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_curveInterpolation, "CurveInterpolation", "Interpolation", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_lineStyle, "LineStyle", "Line Style", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_fillStyle, "FillStyle", "Area Fill Style", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_pointSymbol, "PointSymbol", "Symbol", "", "", "" ); - CAF_PDM_InitField( &m_symbolEdgeColor, "SymbolEdgeColor", RiaColorTools::textColor3f(), "Symbol Edge Color", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_curveInterpolation, "CurveInterpolation", "Interpolation" ); + CAF_PDM_InitFieldNoDefault( &m_lineStyle, "LineStyle", "Line Style" ); + CAF_PDM_InitFieldNoDefault( &m_fillStyle, "FillStyle", "Area Fill Style" ); + CAF_PDM_InitFieldNoDefault( &m_pointSymbol, "PointSymbol", "Symbol" ); + CAF_PDM_InitField( &m_symbolEdgeColor, "SymbolEdgeColor", RiaColorTools::textColor3f(), "Symbol Edge Color" ); CAF_PDM_InitField( &m_symbolSkipPixelDistance, "SymbolSkipPxDist", @@ -105,10 +106,17 @@ RimPlotCurveAppearance::RimPlotCurveAppearance() "Minimum pixel distance between symbols", "" ); - CAF_PDM_InitFieldNoDefault( &m_symbolLabel, "SymbolLabel", "Symbol Label", "", "", "" ); - CAF_PDM_InitField( &m_symbolSize, "SymbolSize", 6, "Symbol Size", "", "", "" ); + CAF_PDM_InitField( &m_curveFittingTolerance, + "CurveFittingTolerance", + 1.0f, + "Curve Fitting Tolerance", + "", + "Value above 0 : Curve fitting tolerance (default 1.0), 0 : disable curve fitting" ); + + CAF_PDM_InitFieldNoDefault( &m_symbolLabel, "SymbolLabel", "Symbol Label" ); + CAF_PDM_InitField( &m_symbolSize, "SymbolSize", 6, "Symbol Size" ); - CAF_PDM_InitFieldNoDefault( &m_symbolLabelPosition, "SymbolLabelPosition", "Symbol Label Position", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_symbolLabelPosition, "SymbolLabelPosition", "Symbol Label Position" ); } //-------------------------------------------------------------------------------------------------- @@ -125,30 +133,23 @@ void RimPlotCurveAppearance::fieldChangedByUi( const caf::PdmFieldHandle* change const QVariant& oldValue, const QVariant& newValue ) { - if ( &m_curveColor == changedField || &m_curveThickness == changedField || &m_pointSymbol == changedField || - &m_lineStyle == changedField || &m_symbolSkipPixelDistance == changedField || - &m_curveInterpolation == changedField || &m_symbolSize == changedField || &m_symbolEdgeColor == changedField || - &m_fillStyle == changedField || &m_fillColor == changedField ) + if ( &m_pointSymbol == changedField ) { - if ( &m_pointSymbol == changedField ) - { - m_symbolSize.uiCapability()->setUiReadOnly( m_pointSymbol() == RiuQwtSymbol::SYMBOL_NONE ); - m_symbolSkipPixelDistance.uiCapability()->setUiReadOnly( m_pointSymbol() == RiuQwtSymbol::SYMBOL_NONE ); - } - else if ( &m_lineStyle == changedField ) - { - m_curveThickness.uiCapability()->setUiReadOnly( m_lineStyle() == + m_symbolSize.uiCapability()->setUiReadOnly( m_pointSymbol() == RiuPlotCurveSymbol::SYMBOL_NONE ); + m_symbolSkipPixelDistance.uiCapability()->setUiReadOnly( m_pointSymbol() == RiuPlotCurveSymbol::SYMBOL_NONE ); + } + else if ( &m_lineStyle == changedField ) + { + m_curveThickness.uiCapability()->setUiReadOnly( m_lineStyle() == RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_NONE ); + m_curveInterpolation.uiCapability()->setUiReadOnly( m_lineStyle() == RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_NONE ); - m_curveInterpolation.uiCapability()->setUiReadOnly( m_lineStyle() == - RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_NONE ); - } - else if ( &m_fillColor == changedField ) - { - fillColorChanged.send(); - } - - appearanceChanged.send(); } + else if ( &m_fillColor == changedField ) + { + fillColorChanged.send(); + } + + appearanceChanged.send(); } //-------------------------------------------------------------------------------------------------- @@ -156,8 +157,8 @@ void RimPlotCurveAppearance::fieldChangedByUi( const caf::PdmFieldHandle* change //-------------------------------------------------------------------------------------------------- void RimPlotCurveAppearance::initAfterRead() { - m_symbolSize.uiCapability()->setUiReadOnly( m_pointSymbol() == RiuQwtSymbol::SYMBOL_NONE ); - m_symbolSkipPixelDistance.uiCapability()->setUiReadOnly( m_pointSymbol() == RiuQwtSymbol::SYMBOL_NONE ); + m_symbolSize.uiCapability()->setUiReadOnly( m_pointSymbol() == RiuPlotCurveSymbol::SYMBOL_NONE ); + m_symbolSkipPixelDistance.uiCapability()->setUiReadOnly( m_pointSymbol() == RiuPlotCurveSymbol::SYMBOL_NONE ); m_curveThickness.uiCapability()->setUiReadOnly( m_lineStyle() == RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_NONE ); m_curveInterpolation.uiCapability()->setUiReadOnly( m_lineStyle() == RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_NONE ); } @@ -188,7 +189,7 @@ void RimPlotCurveAppearance::defineUiOrdering( QString uiConfigName, caf::PdmUiO m_curveColor.uiCapability()->setUiHidden( !m_colorVisible ); uiOrdering.add( &m_pointSymbol ); - if ( RiuQwtSymbol::isFilledSymbol( m_pointSymbol() ) ) + if ( RiuPlotCurveSymbol::isFilledSymbol( m_pointSymbol() ) ) { uiOrdering.add( &m_symbolEdgeColor ); } @@ -197,6 +198,9 @@ void RimPlotCurveAppearance::defineUiOrdering( QString uiConfigName, caf::PdmUiO uiOrdering.add( &m_lineStyle ); uiOrdering.add( &m_curveThickness ); + uiOrdering.add( &m_curveFittingTolerance ); + m_curveFittingTolerance.uiCapability()->setUiReadOnly( m_lineStyle() == + RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID ); uiOrdering.add( &m_fillStyle ); m_fillStyle.uiCapability()->setUiHidden( !m_fillOptionsVisible ); @@ -208,13 +212,14 @@ void RimPlotCurveAppearance::defineUiOrdering( QString uiConfigName, caf::PdmUiO uiOrdering.add( &m_curveInterpolation ); m_curveInterpolation.uiCapability()->setUiHidden( !m_interpolationVisible ); + + uiOrdering.skipRemainingFields(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList - RimPlotCurveAppearance::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) +QList RimPlotCurveAppearance::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; @@ -240,7 +245,7 @@ void RimPlotCurveAppearance::setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimPlotCurveAppearance::setSymbol( RiuQwtSymbol::PointSymbolEnum symbolStyle ) +void RimPlotCurveAppearance::setSymbol( RiuPlotCurveSymbol::PointSymbolEnum symbolStyle ) { m_pointSymbol = symbolStyle; } @@ -272,7 +277,7 @@ RiuQwtPlotCurveDefines::LineStyleEnum RimPlotCurveAppearance::lineStyle() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuQwtSymbol::PointSymbolEnum RimPlotCurveAppearance::symbol() const +RiuPlotCurveSymbol::PointSymbolEnum RimPlotCurveAppearance::symbol() const { return m_pointSymbol(); } @@ -336,7 +341,7 @@ QString RimPlotCurveAppearance::symbolLabel() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimPlotCurveAppearance::setSymbolLabelPosition( RiuQwtSymbol::LabelPosition labelPosition ) +void RimPlotCurveAppearance::setSymbolLabelPosition( RiuPlotCurveSymbol::LabelPosition labelPosition ) { m_symbolLabelPosition = labelPosition; } @@ -344,7 +349,7 @@ void RimPlotCurveAppearance::setSymbolLabelPosition( RiuQwtSymbol::LabelPosition //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuQwtSymbol::LabelPosition RimPlotCurveAppearance::symbolLabelPosition() const +RiuPlotCurveSymbol::LabelPosition RimPlotCurveAppearance::symbolLabelPosition() const { return m_symbolLabelPosition.value(); } @@ -382,8 +387,9 @@ void RimPlotCurveAppearance::resetAppearance() setSymbolEdgeColor( RiaColorTools::textColor3f() ); setLineThickness( 2 ); setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID ); - setSymbol( RiuQwtSymbol::SYMBOL_NONE ); + setSymbol( RiuPlotCurveSymbol::SYMBOL_NONE ); setSymbolSkipDistance( 10 ); + setFillStyle( Qt::NoBrush ); } //-------------------------------------------------------------------------------------------------- @@ -418,6 +424,14 @@ cvf::Color3f RimPlotCurveAppearance::fillColor() const return m_fillColor; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +float RimPlotCurveAppearance::curveFittingTolerance() const +{ + return m_curveFittingTolerance(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimPlotCurveAppearance.h b/ApplicationLibCode/ProjectDataModel/RimPlotCurveAppearance.h index e986988c59..445dac52b8 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPlotCurveAppearance.h +++ b/ApplicationLibCode/ProjectDataModel/RimPlotCurveAppearance.h @@ -20,8 +20,8 @@ #include "RiaCurveDataTools.h" #include "RiaDefines.h" +#include "RiuPlotCurveSymbol.h" #include "RiuQwtPlotCurveDefines.h" -#include "RiuQwtSymbol.h" #include "cafPdmField.h" #include "cafPdmFieldCvfColor.h" @@ -42,8 +42,8 @@ class RimPlotCurveAppearance : public caf::PdmObject public: typedef caf::AppEnum CurveInterpolation; typedef caf::AppEnum LineStyle; - typedef caf::AppEnum PointSymbol; - typedef caf::AppEnum LabelPosition; + typedef caf::AppEnum PointSymbol; + typedef caf::AppEnum LabelPosition; typedef caf::AppEnum FillStyle; public: @@ -59,8 +59,8 @@ class RimPlotCurveAppearance : public caf::PdmObject void setLineThickness( int thickness ); int lineThickness() const; - void setSymbol( RiuQwtSymbol::PointSymbolEnum symbolStyle ); - RiuQwtSymbol::PointSymbolEnum symbol() const; + void setSymbol( RiuPlotCurveSymbol::PointSymbolEnum symbolStyle ); + RiuPlotCurveSymbol::PointSymbolEnum symbol() const; void setSymbolSize( int sizeInPixels ); int symbolSize() const; @@ -74,8 +74,8 @@ class RimPlotCurveAppearance : public caf::PdmObject void setSymbolLabel( const QString& label ); QString symbolLabel() const; - void setSymbolLabelPosition( RiuQwtSymbol::LabelPosition labelPosition ); - RiuQwtSymbol::LabelPosition symbolLabelPosition() const; + void setSymbolLabelPosition( RiuPlotCurveSymbol::LabelPosition labelPosition ); + RiuPlotCurveSymbol::LabelPosition symbolLabelPosition() const; void resetAppearance(); Qt::BrushStyle fillStyle() const; @@ -84,6 +84,8 @@ class RimPlotCurveAppearance : public caf::PdmObject void setFillColor( const cvf::Color3f& fillColor ); cvf::Color3f fillColor() const; + float curveFittingTolerance() const; + void setInterpolation( RiuQwtPlotCurveDefines::CurveInterpolationEnum ); RiuQwtPlotCurveDefines::CurveInterpolationEnum interpolation() const; @@ -96,8 +98,7 @@ class RimPlotCurveAppearance : public caf::PdmObject protected: // Overridden PDM methods void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void initAfterRead() override; protected: @@ -109,6 +110,8 @@ class RimPlotCurveAppearance : public caf::PdmObject caf::PdmField m_curveThickness; caf::PdmField m_symbolSkipPixelDistance; + caf::PdmField m_curveFittingTolerance; + caf::PdmField m_pointSymbol; caf::PdmField m_lineStyle; caf::PdmField m_fillStyle; diff --git a/ApplicationLibCode/ProjectDataModel/RimPlotWindow.cpp b/ApplicationLibCode/ProjectDataModel/RimPlotWindow.cpp index 6eac612696..17b33e746b 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPlotWindow.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimPlotWindow.cpp @@ -45,20 +45,20 @@ RimPlotWindow::RimPlotWindow() "PlotWindow", "The Abstract base class for all MDI Windows in the Plot Window" ); - CAF_PDM_InitScriptableField( &m_id, "Id", -1, "View ID", "", "", "" ); + CAF_PDM_InitScriptableField( &m_id, "Id", -1, "View ID" ); m_id.registerKeywordAlias( "ViewId" ); m_id.uiCapability()->setUiReadOnly( true ); m_id.uiCapability()->setUiHidden( true ); m_id.capability()->setIOWriteable( false ); m_id.xmlCapability()->setCopyable( false ); - CAF_PDM_InitField( &m_showPlotTitle, "ShowPlotTitle", true, "Show Plot Title", "", "", "" ); - CAF_PDM_InitField( &m_showPlotLegends, "ShowTrackLegends", true, "Show Legends", "", "", "" ); - CAF_PDM_InitField( &m_plotLegendsHorizontal, "TrackLegendsHorizontal", true, "Legend Orientation", "", "", "" ); + CAF_PDM_InitField( &m_showPlotTitle, "ShowPlotTitle", true, "Show Plot Title" ); + CAF_PDM_InitField( &m_showPlotLegends, "ShowTrackLegends", true, "Show Legends" ); + CAF_PDM_InitField( &m_plotLegendsHorizontal, "TrackLegendsHorizontal", true, "Legend Orientation" ); m_plotLegendsHorizontal.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_titleFontSize, "TitleFontSize", "Title Font Size", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_legendFontSize, "LegendDeltaFontSize", "Legend Font Size", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_titleFontSize, "TitleFontSize", "Title Font Size" ); + CAF_PDM_InitFieldNoDefault( &m_legendFontSize, "LegendDeltaFontSize", "Legend Font Size" ); m_titleFontSize = caf::FontTools::RelativeSize::XXLarge; m_legendFontSize = caf::FontTools::RelativeSize::Large; @@ -211,7 +211,7 @@ void RimPlotWindow::updateParentLayout() //-------------------------------------------------------------------------------------------------- int RimPlotWindow::columnCount() const { - return static_cast( RiuMultiPlotPage::ColumnCount::COLUMNS_UNLIMITED ); + return static_cast( RiaDefines::ColumnCount::COLUMNS_UNLIMITED ); } //-------------------------------------------------------------------------------------------------- @@ -265,8 +265,7 @@ void RimPlotWindow::fieldChangedByUi( const caf::PdmFieldHandle* changedField, //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimPlotWindow::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RimPlotWindow::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; if ( fieldNeedingOptions == &m_plotLegendsHorizontal ) @@ -336,3 +335,19 @@ void RimPlotWindow::assignIdIfNecessary() RimProject::current()->assignPlotIdToPlotWindow( this ); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimPlotWindow::handleGlobalKeyEvent( QKeyEvent* keyEvent ) +{ + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimPlotWindow::handleGlobalWheelEvent( QWheelEvent* wheelEvent ) +{ + return false; +} diff --git a/ApplicationLibCode/ProjectDataModel/RimPlotWindow.h b/ApplicationLibCode/ProjectDataModel/RimPlotWindow.h index db99ed9968..304c0e8bfa 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPlotWindow.h +++ b/ApplicationLibCode/ProjectDataModel/RimPlotWindow.h @@ -32,6 +32,7 @@ class RiuQwtPlotWidget; class QwtPlotCurve; class QKeyEvent; +class QWheelEvent; class QPaintDevice; //================================================================================================== @@ -75,13 +76,16 @@ class RimPlotWindow : public RimViewWindow void renderWindowContent( QPaintDevice* painter ); QPageLayout pageLayout() const; + virtual bool handleGlobalKeyEvent( QKeyEvent* keyEvent ); + virtual bool handleGlobalWheelEvent( QWheelEvent* wheelEvent ); + protected: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void uiOrderingForPlotLayout( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ); + void updateWindowVisibility(); private: diff --git a/ApplicationLibCode/ProjectDataModel/RimPltPlotCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimPltPlotCollection.cpp index 83e1a32c62..b095f8edcc 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPltPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimPltPlotCollection.cpp @@ -39,9 +39,9 @@ CAF_PDM_SOURCE_INIT( RimPltPlotCollection, "WellPltPlotCollection" ); //-------------------------------------------------------------------------------------------------- RimPltPlotCollection::RimPltPlotCollection() { - CAF_PDM_InitObject( "PLT Plots", ":/WellAllocPlots16x16.png", "", "" ); + CAF_PDM_InitObject( "PLT Plots", ":/WellAllocPlots16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_pltPlots, "PltPlots", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_pltPlots, "PltPlots", "" ); m_pltPlots.uiCapability()->setUiTreeHidden( true ); } @@ -50,7 +50,7 @@ RimPltPlotCollection::RimPltPlotCollection() //-------------------------------------------------------------------------------------------------- RimPltPlotCollection::~RimPltPlotCollection() { - m_pltPlots.deleteAllChildObjects(); + m_pltPlots.deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -246,7 +246,7 @@ void RimPltPlotCollection::addPlot( gsl::not_null newPlot ) //-------------------------------------------------------------------------------------------------- void RimPltPlotCollection::removePlot( gsl::not_null plot ) { - m_pltPlots.removeChildObject( plot ); + m_pltPlots.removeChild( plot ); updateAllRequiredEditors(); } @@ -255,5 +255,5 @@ void RimPltPlotCollection::removePlot( gsl::not_null plot ) //-------------------------------------------------------------------------------------------------- void RimPltPlotCollection::deleteAllPlots() { - m_pltPlots.deleteAllChildObjects(); + m_pltPlots.deleteChildren(); } diff --git a/ApplicationLibCode/ProjectDataModel/RimProject.cpp b/ApplicationLibCode/ProjectDataModel/RimProject.cpp index f664695598..8d374b85e1 100644 --- a/ApplicationLibCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimProject.cpp @@ -25,6 +25,7 @@ #include "RiaFilePathTools.h" #include "RiaGuiApplication.h" #include "RiaProjectFileVersionTools.h" +#include "RiaTextStringTools.h" #include "RiaVersionInfo.h" #include "RicfCommandObject.h" @@ -54,6 +55,7 @@ #include "RimFractureTemplateCollection.h" #include "RimGeoMechCase.h" #include "RimGeoMechModels.h" +#include "RimGridCalculationCollection.h" #include "RimGridCrossPlotCollection.h" #include "RimGridSummaryCase.h" #include "RimGridView.h" @@ -76,7 +78,7 @@ #include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" #include "RimSummaryCrossPlotCollection.h" -#include "RimSummaryPlotCollection.h" +#include "RimSummaryMultiPlotCollection.h" #include "RimSurfaceCollection.h" #include "RimTools.h" #include "RimUserDefinedPolylinesAnnotation.h" @@ -123,89 +125,85 @@ CAF_PDM_SOURCE_INIT( RimProject, "ResInsightProject" ); RimProject::RimProject( void ) : m_nextValidCaseId( 0 ) , m_nextValidCaseGroupId( 0 ) - , m_nextValidViewId( 1 ) - , m_nextValidPlotId( 1 ) - , m_nextValidCalculationId( 1 ) + , m_nextValidViewId( -1 ) + , m_nextValidPlotId( -1 ) , m_nextValidSummaryCaseId( 1 ) , m_nextValidEnsembleId( 1 ) { CAF_PDM_InitScriptableObjectWithNameAndComment( "Project", "", "", "", "Project", "The ResInsight Project" ); - CAF_PDM_InitField( &m_projectFileVersionString, "ProjectFileVersionString", QString( STRPRODUCTVER ), "", "", "", "" ); + CAF_PDM_InitField( &m_projectFileVersionString, "ProjectFileVersionString", QString( STRPRODUCTVER ), "" ); m_projectFileVersionString.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_globalPathList, "ReferencedExternalFiles", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_globalPathList, "ReferencedExternalFiles", "" ); m_globalPathList.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &oilFields, "OilFields", "Oil Fields", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &oilFields, "OilFields", "Oil Fields" ); oilFields.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &colorLegendCollection, "ColorLegendCollection", "Color Legend Collection", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &colorLegendCollection, "ColorLegendCollection", "Color Legend Collection" ); colorLegendCollection = new RimColorLegendCollection(); colorLegendCollection->createStandardColorLegends(); - CAF_PDM_InitFieldNoDefault( &scriptCollection, "ScriptCollection", "Octave Scripts", ":/octave.png", "", "" ); + CAF_PDM_InitFieldNoDefault( &scriptCollection, "ScriptCollection", "Octave Scripts", ":/octave.png" ); scriptCollection.uiCapability()->setUiTreeHidden( true ); scriptCollection.xmlCapability()->disableIO(); - CAF_PDM_InitFieldNoDefault( &wellPathImport, "WellPathImport", "WellPathImport", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &wellPathImport, "WellPathImport", "WellPathImport" ); wellPathImport = new RimWellPathImport(); wellPathImport.uiCapability()->setUiTreeHidden( true ); wellPathImport.uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitFieldNoDefault( &mainPlotCollection, "MainPlotCollection", "Plots", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &mainPlotCollection, "MainPlotCollection", "Plots" ); mainPlotCollection.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &viewLinkerCollection, - "LinkedViews", - "Linked Views (field in RimProject", - ":/LinkView16x16.png", - "", - "" ); + CAF_PDM_InitFieldNoDefault( &viewLinkerCollection, "LinkedViews", "Linked Views", ":/LinkView.svg" ); viewLinkerCollection.uiCapability()->setUiTreeHidden( true ); viewLinkerCollection = new RimViewLinkerCollection; - CAF_PDM_InitFieldNoDefault( &calculationCollection, "CalculationCollection", "Calculation Collection", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &calculationCollection, "CalculationCollection", "Calculation Collection" ); calculationCollection = new RimSummaryCalculationCollection; - CAF_PDM_InitFieldNoDefault( &commandObjects, "CommandObjects", "Command Objects", "", "", "" ); - // wellPathImport.uiCapability()->setUiHidden(true); + CAF_PDM_InitFieldNoDefault( &gridCalculationCollection, "GridCalculationCollection", "Grid Calculation Collection" ); + gridCalculationCollection = new RimGridCalculationCollection; - CAF_PDM_InitFieldNoDefault( &multiSnapshotDefinitions, "MultiSnapshotDefinitions", "Multi Snapshot Definitions", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &commandObjects, "CommandObjects", "Command Objects" ); - CAF_PDM_InitFieldNoDefault( &mainWindowTreeViewState, "TreeViewState", "", "", "", "" ); - mainWindowTreeViewState.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &mainWindowCurrentModelIndexPath, "TreeViewCurrentModelIndexPath", "", "", "", "" ); - mainWindowCurrentModelIndexPath.uiCapability()->setUiHidden( true ); + CAF_PDM_InitFieldNoDefault( &multiSnapshotDefinitions, "MultiSnapshotDefinitions", "Multi Snapshot Definitions" ); - CAF_PDM_InitFieldNoDefault( &plotWindowTreeViewState, "PlotWindowTreeViewState", "", "", "", "" ); - plotWindowTreeViewState.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &plotWindowCurrentModelIndexPath, "PlotWindowTreeViewCurrentModelIndexPath", "", "", "", "" ); - plotWindowCurrentModelIndexPath.uiCapability()->setUiHidden( true ); + CAF_PDM_InitFieldNoDefault( &mainWindowTreeViewStates, "TreeViewStates", "" ); + mainWindowTreeViewStates.uiCapability()->setUiHidden( true ); + CAF_PDM_InitFieldNoDefault( &mainWindowCurrentModelIndexPaths, "TreeViewCurrentModelIndexPaths", "" ); + mainWindowCurrentModelIndexPaths.uiCapability()->setUiHidden( true ); - CAF_PDM_InitField( &m_show3DWindow, "show3DWindow", true, "Show 3D Window", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &plotWindowTreeViewStates, "PlotWindowTreeViewStates", "" ); + plotWindowTreeViewStates.uiCapability()->setUiHidden( true ); + CAF_PDM_InitFieldNoDefault( &plotWindowCurrentModelIndexPaths, "PlotWindowTreeViewCurrentModelIndexPaths", "" ); + plotWindowCurrentModelIndexPaths.uiCapability()->setUiHidden( true ); + + CAF_PDM_InitField( &m_show3DWindow, "show3DWindow", true, "Show 3D Window" ); m_show3DWindow.uiCapability()->setUiHidden( true ); - CAF_PDM_InitField( &m_showPlotWindow, "showPlotWindow", false, "Show Plot Window", "", "", "" ); + CAF_PDM_InitField( &m_showPlotWindow, "showPlotWindow", false, "Show Plot Window" ); m_showPlotWindow.uiCapability()->setUiHidden( true ); - CAF_PDM_InitField( &m_subWindowsTiled3DWindow, "tiled3DWindow", false, "Tile 3D Window", "", "", "" ); + CAF_PDM_InitField( &m_subWindowsTiled3DWindow, "tiled3DWindow", false, "Tile 3D Window" ); m_subWindowsTiled3DWindow.uiCapability()->setUiHidden( true ); - CAF_PDM_InitField( &m_subWindowsTiledPlotWindow, "tiledPlotWindow", false, "Tile Plot Window", "", "", "" ); + CAF_PDM_InitField( &m_subWindowsTiledPlotWindow, "tiledPlotWindow", false, "Tile Plot Window" ); m_subWindowsTiledPlotWindow.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_dialogData, "DialogData", "DialogData", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_dialogData, "DialogData", "DialogData" ); m_dialogData = new RimDialogData(); m_dialogData.uiCapability()->setUiTreeHidden( true ); m_dialogData.uiCapability()->setUiTreeChildrenHidden( true ); // Obsolete fields. The content is moved to OilFields and friends - CAF_PDM_InitFieldNoDefault( &casesObsolete, "Reservoirs", "", "", "", "" ); - RiaFieldhandleTools::disableWriteAndSetFieldHidden( &casesObsolete ); + CAF_PDM_InitFieldNoDefault( &casesObsolete, "Reservoirs", "" ); + RiaFieldHandleTools::disableWriteAndSetFieldHidden( &casesObsolete ); - CAF_PDM_InitFieldNoDefault( &caseGroupsObsolete, "CaseGroups", "", "", "", "" ); - RiaFieldhandleTools::disableWriteAndSetFieldHidden( &caseGroupsObsolete ); + CAF_PDM_InitFieldNoDefault( &caseGroupsObsolete, "CaseGroups", "" ); + RiaFieldHandleTools::disableWriteAndSetFieldHidden( &caseGroupsObsolete ); // Initialization @@ -216,9 +214,9 @@ RimProject::RimProject( void ) mainPlotCollection = new RimMainPlotCollection(); - CAF_PDM_InitFieldNoDefault( &m_plotTemplateFolderItem, "PlotTemplateCollection", "Plot Templates", "", "", "" ); - m_plotTemplateFolderItem = new RimPlotTemplateFolderItem(); - m_plotTemplateFolderItem.xmlCapability()->disableIO(); + CAF_PDM_InitFieldNoDefault( &m_plotTemplateTopFolder, "PlotTemplateCollection", "Plot Templates" ); + m_plotTemplateTopFolder = new RimPlotTemplateFolderItem(); + m_plotTemplateTopFolder.xmlCapability()->disableIO(); // For now, create a default first oilfield that contains the rest of the project oilFields.push_back( new RimOilField ); @@ -251,21 +249,22 @@ void RimProject::close() mainPlotCollection()->deleteAllContainedObjects(); } - oilFields.deleteAllChildObjects(); + oilFields.deleteChildren(); oilFields.push_back( new RimOilField ); - casesObsolete.deleteAllChildObjects(); - caseGroupsObsolete.deleteAllChildObjects(); + casesObsolete.deleteChildren(); + caseGroupsObsolete.deleteChildren(); - wellPathImport->regions().deleteAllChildObjects(); + wellPathImport->regions().deleteChildren(); - commandObjects.deleteAllChildObjects(); + commandObjects.deleteChildren(); - multiSnapshotDefinitions.deleteAllChildObjects(); + multiSnapshotDefinitions.deleteChildren(); m_dialogData->clearProjectSpecificData(); calculationCollection->deleteAllContainedObjects(); + gridCalculationCollection->deleteAllContainedObjects(); colorLegendCollection->deleteCustomColorLegends(); delete viewLinkerCollection->viewLinker(); @@ -273,16 +272,15 @@ void RimProject::close() fileName = ""; - mainWindowCurrentModelIndexPath = ""; - mainWindowTreeViewState = ""; - plotWindowCurrentModelIndexPath = ""; - plotWindowTreeViewState = ""; + mainWindowCurrentModelIndexPaths = ""; + mainWindowTreeViewStates = ""; + plotWindowCurrentModelIndexPaths = ""; + plotWindowTreeViewStates = ""; m_nextValidCaseId = 0; m_nextValidCaseGroupId = 0; - m_nextValidViewId = 1; - m_nextValidPlotId = 1; - m_nextValidCalculationId = 1; + m_nextValidViewId = -1; + m_nextValidPlotId = -1; m_nextValidSummaryCaseId = 1; m_nextValidEnsembleId = 1; } @@ -310,14 +308,13 @@ void RimProject::initAfterRead() if ( analysisModels ) { analysisModels->caseGroups.push_back( sourceCaseGroup ); - // printf("Moved m_project->caseGroupsObsolete[%i] to first oil fields analysis models\n", cgIdx); movedOneRimIdenticalGridCaseGroup = true; // moved at least one so assume the others will be moved too... } } if ( movedOneRimIdenticalGridCaseGroup ) { - caseGroupsObsolete.clear(); + caseGroupsObsolete.clearWithoutDelete(); } bool movedOneRimCase = false; @@ -328,21 +325,13 @@ void RimProject::initAfterRead() RimEclipseCase* sourceCase = casesObsolete[cIdx]; casesObsolete.set( cIdx, nullptr ); analysisModels->cases.push_back( sourceCase ); - // printf("Moved m_project->casesObsolete[%i] to first oil fields analysis models\n", cIdx); movedOneRimCase = true; // moved at least one so assume the others will be moved too... } } if ( movedOneRimCase ) { - casesObsolete.clear(); - } - - if ( casesObsolete().size() > 0 || caseGroupsObsolete.size() > 0 ) - { - // printf("RimProject::initAfterRead: Was not able to move all cases (%i left) or caseGroups (%i left) from - // Project to analysisModels", - // casesObsolete().size(), caseGroupsObsolete.size()); + casesObsolete.clearWithoutDelete(); } // Set project pointer to each well path @@ -364,8 +353,8 @@ void RimProject::setupBeforeSave() if ( guiApp ) { - m_show3DWindow = guiApp->mainWindow()->isVisible(); - m_showPlotWindow = guiApp->mainPlotWindow() && guiApp->mainPlotWindow()->isVisible(); + m_show3DWindow = guiApp->isMain3dWindowVisible(); + m_showPlotWindow = guiApp->isMainPlotWindowVisible(); } } @@ -387,10 +376,10 @@ bool RimProject::writeProjectFile() //-------------------------------------------------------------------------------------------------- /// Support list of multiple script paths divided by ';' //-------------------------------------------------------------------------------------------------- -void RimProject::setScriptDirectories( const QString& scriptDirectories ) +void RimProject::setScriptDirectories( const QString& scriptDirectories, int maxFolderDepth ) { - scriptCollection->calcScripts().deleteAllChildObjects(); - scriptCollection->subDirectories().deleteAllChildObjects(); + scriptCollection->calcScripts().deleteChildren(); + scriptCollection->subDirectories().deleteChildren(); QStringList pathList = scriptDirectories.split( ';' ); foreach ( QString path, pathList ) @@ -402,7 +391,7 @@ void RimProject::setScriptDirectories( const QString& scriptDirectories ) sharedScriptLocation->directory = path; sharedScriptLocation->setUiName( dir.dirName() ); - sharedScriptLocation->readContentFromDisc(); + sharedScriptLocation->readContentFromDisc( maxFolderDepth ); scriptCollection->subDirectories.push_back( sharedScriptLocation ); } @@ -414,12 +403,12 @@ void RimProject::setScriptDirectories( const QString& scriptDirectories ) //-------------------------------------------------------------------------------------------------- void RimProject::setPlotTemplateFolders( const QStringList& plotTemplateFolders ) { - if ( !m_plotTemplateFolderItem() ) + if ( !m_plotTemplateTopFolder() ) { - m_plotTemplateFolderItem = new RimPlotTemplateFolderItem(); + m_plotTemplateTopFolder = new RimPlotTemplateFolderItem(); } - m_plotTemplateFolderItem->createRootFolderItemsFromFolderPaths( plotTemplateFolders ); + m_plotTemplateTopFolder->createRootFolderItemsFromFolderPaths( plotTemplateFolders ); } //-------------------------------------------------------------------------------------------------- @@ -468,20 +457,6 @@ void RimProject::setProjectFileNameAndUpdateDependencies( const QString& project filePath->setPath( newFilePath ); } - // Loop over all cases and update file path - - std::vector cases; - allCases( cases ); - for ( size_t i = 0; i < cases.size(); i++ ) - { - cases[i]->updateFilePathsFromProjectPath( newProjectPath, oldProjectPath ); - } - - for ( RimSummaryCase* summaryCase : allSummaryCases() ) - { - summaryCase->updateFilePathsFromProjectPath( newProjectPath, oldProjectPath ); - } - // Update path to well path file cache for ( RimOilField* oilField : oilFields ) { @@ -494,10 +469,6 @@ void RimProject::setProjectFileNameAndUpdateDependencies( const QString& project { oilField->formationNamesCollection()->updateFilePathsFromProjectPath( newProjectPath, oldProjectPath ); } - if ( oilField->summaryCaseMainCollection() != nullptr ) - { - oilField->summaryCaseMainCollection()->updateFilePathsFromProjectPath( newProjectPath, oldProjectPath ); - } CVF_ASSERT( oilField->fractureDefinitionCollection() ); oilField->fractureDefinitionCollection()->updateFilePathsFromProjectPath( newProjectPath, oldProjectPath ); @@ -608,12 +579,15 @@ void RimProject::assignViewIdToView( Rim3dView* view ) { if ( view ) { - std::vector views; - this->descendantsIncludingThisOfType( views ); - - for ( Rim3dView* existingView : views ) + if ( m_nextValidViewId < 0 ) { - m_nextValidViewId = std::max( m_nextValidViewId, existingView->id() + 1 ); + std::vector views; + this->descendantsIncludingThisOfType( views ); + + for ( Rim3dView* existingView : views ) + { + m_nextValidViewId = std::max( m_nextValidViewId, existingView->id() + 1 ); + } } view->setId( m_nextValidViewId++ ); @@ -627,31 +601,18 @@ void RimProject::assignPlotIdToPlotWindow( RimPlotWindow* plotWindow ) { if ( plotWindow ) { - std::vector plotWindows; - this->descendantsIncludingThisOfType( plotWindows ); - - for ( RimPlotWindow* existingPlotWindow : plotWindows ) + if ( m_nextValidPlotId < 0 ) { - m_nextValidPlotId = std::max( m_nextValidPlotId, existingPlotWindow->id() + 1 ); - } + std::vector plotWindows; + this->descendantsIncludingThisOfType( plotWindows ); - plotWindow->setId( m_nextValidPlotId++ ); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimProject::assignCalculationIdToCalculation( RimSummaryCalculation* calculation ) -{ - if ( calculation ) - { - for ( RimSummaryCalculation* existingCalculation : calculationCollection->calculations() ) - { - m_nextValidCalculationId = std::max( m_nextValidCalculationId, existingCalculation->id() + 1 ); + for ( RimPlotWindow* existingPlotWindow : plotWindows ) + { + m_nextValidPlotId = std::max( m_nextValidPlotId, existingPlotWindow->id() + 1 ); + } } - calculation->setId( m_nextValidCalculationId++ ); + plotWindow->setId( m_nextValidPlotId++ ); } } @@ -720,10 +681,13 @@ std::vector RimProject::allSummaryCases() const if ( sumCaseMainColl ) { std::vector allSummaryCases = sumCaseMainColl->allSummaryCases(); - sumCases.insert( sumCases.end(), allSummaryCases.begin(), allSummaryCases.end() ); + if ( !allSummaryCases.empty() ) + { + sumCases.insert( sumCases.end(), allSummaryCases.begin(), allSummaryCases.end() ); + } } - auto observedDataColl = oilField->observedDataCollection(); + auto& observedDataColl = oilField->observedDataCollection(); if ( observedDataColl != nullptr && observedDataColl->allObservedSummaryData().size() > 0 ) { auto observedData = observedDataColl->allObservedSummaryData(); @@ -1031,10 +995,10 @@ void RimProject::setSubWindowsTiledInPlotWindow( bool tiled ) //-------------------------------------------------------------------------------------------------- void RimProject::reloadCompletionTypeResultsInAllViews() { + RiaCompletionTypeCalculationScheduler::instance()->clearCompletionTypeResultsInAllCases(); scheduleCreateDisplayModelAndRedrawAllViews(); - RiaCompletionTypeCalculationScheduler::instance()->scheduleRecalculateCompletionTypeAndRedrawAllViews(); - this->mainPlotCollection()->updatePlotsWithCompletions(); + mainPlotCollection()->scheduleUpdatePlotsWithCompletions(); } //-------------------------------------------------------------------------------------------------- @@ -1362,9 +1326,9 @@ RimMeasurement* RimProject::measurement() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimPlotTemplateFolderItem* RimProject::rootPlotTemlateItem() const +RimPlotTemplateFolderItem* RimProject::rootPlotTemplateItem() const { - return m_plotTemplateFolderItem; + return m_plotTemplateTopFolder; } //-------------------------------------------------------------------------------------------------- @@ -1398,102 +1362,79 @@ void RimProject::reloadCompletionTypeResultsForEclipseCase( RimEclipseCase* ecli //-------------------------------------------------------------------------------------------------- void RimProject::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/ ) { - if ( uiConfigName == "PlotWindow" ) + if ( uiConfigName == "PlotWindow.Plots" ) { - { - auto itemCollection = uiTreeOrdering.add( "Cases and Data", ":/Folder.png" ); - - RimOilField* oilField = activeOilField(); - if ( oilField ) - { - if ( oilField->summaryCaseMainCollection() ) - { - itemCollection->add( oilField->summaryCaseMainCollection() ); - } - if ( oilField->observedDataCollection() ) - { - itemCollection->add( oilField->observedDataCollection() ); - } - if ( oilField->ensembleWellLogsCollection() ) - { - itemCollection->add( oilField->ensembleWellLogsCollection() ); - } - } - } - if ( mainPlotCollection ) { - auto itemCollection = uiTreeOrdering.add( "Plots", ":/Folder.png" ); - if ( mainPlotCollection->summaryPlotCollection() ) + if ( mainPlotCollection->summaryMultiPlotCollection() ) { - itemCollection->add( mainPlotCollection->summaryPlotCollection() ); + uiTreeOrdering.add( mainPlotCollection->summaryMultiPlotCollection() ); } if ( mainPlotCollection->analysisPlotCollection() ) { - itemCollection->add( mainPlotCollection->analysisPlotCollection() ); + uiTreeOrdering.add( mainPlotCollection->analysisPlotCollection() ); } if ( mainPlotCollection->correlationPlotCollection() ) { - itemCollection->add( mainPlotCollection->correlationPlotCollection() ); + uiTreeOrdering.add( mainPlotCollection->correlationPlotCollection() ); } if ( mainPlotCollection->summaryCrossPlotCollection() ) { - itemCollection->add( mainPlotCollection->summaryCrossPlotCollection() ); + uiTreeOrdering.add( mainPlotCollection->summaryCrossPlotCollection() ); } if ( mainPlotCollection->wellLogPlotCollection() ) { - itemCollection->add( mainPlotCollection->wellLogPlotCollection() ); + uiTreeOrdering.add( mainPlotCollection->wellLogPlotCollection() ); } if ( mainPlotCollection->rftPlotCollection() ) { - itemCollection->add( mainPlotCollection->rftPlotCollection() ); + uiTreeOrdering.add( mainPlotCollection->rftPlotCollection() ); } if ( mainPlotCollection->pltPlotCollection() ) { - itemCollection->add( mainPlotCollection->pltPlotCollection() ); + uiTreeOrdering.add( mainPlotCollection->pltPlotCollection() ); } if ( mainPlotCollection->flowPlotCollection() ) { - itemCollection->add( mainPlotCollection->flowPlotCollection() ); + uiTreeOrdering.add( mainPlotCollection->flowPlotCollection() ); } if ( mainPlotCollection->gridCrossPlotCollection() ) { - itemCollection->add( mainPlotCollection->gridCrossPlotCollection() ); + uiTreeOrdering.add( mainPlotCollection->gridCrossPlotCollection() ); } if ( mainPlotCollection->saturationPressurePlotCollection() ) { - itemCollection->add( mainPlotCollection->saturationPressurePlotCollection() ); + uiTreeOrdering.add( mainPlotCollection->saturationPressurePlotCollection() ); } - if ( mainPlotCollection->multiPlotCollection() && - !mainPlotCollection->multiPlotCollection()->multiPlots().empty() ) + if ( mainPlotCollection->multiPlotCollection() ) { - itemCollection->add( mainPlotCollection->multiPlotCollection() ); + uiTreeOrdering.add( mainPlotCollection->multiPlotCollection() ); } if ( mainPlotCollection->stimPlanModelPlotCollection() ) { - itemCollection->add( mainPlotCollection->stimPlanModelPlotCollection() ); + uiTreeOrdering.add( mainPlotCollection->stimPlanModelPlotCollection() ); } if ( mainPlotCollection->vfpPlotCollection() ) { - itemCollection->add( mainPlotCollection->vfpPlotCollection() ); + uiTreeOrdering.add( mainPlotCollection->vfpPlotCollection() ); } #ifdef USE_QTCHARTS if ( mainPlotCollection->gridStatisticsPlotCollection() || mainPlotCollection->ensembleFractureStatisticsPlotCollection() ) { - auto statisticsItemCollection = itemCollection->add( "Statistics Plots", ":/Folder.png" ); + auto statisticsItemCollection = uiTreeOrdering.add( "Statistics Plots", ":/Folder.png" ); if ( mainPlotCollection->gridStatisticsPlotCollection() ) statisticsItemCollection->add( mainPlotCollection->gridStatisticsPlotCollection() ); @@ -1502,16 +1443,46 @@ void RimProject::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, Q } #endif } - + } + else if ( uiConfigName == "PlotWindow.DataSources" ) + { + RimOilField* oilField = activeOilField(); + if ( oilField ) + { + if ( oilField->summaryCaseMainCollection() ) + { + uiTreeOrdering.add( oilField->summaryCaseMainCollection() ); + } + if ( oilField->observedDataCollection() ) + { + uiTreeOrdering.add( oilField->observedDataCollection() ); + } + if ( oilField->ensembleWellLogsCollection() ) + { + uiTreeOrdering.add( oilField->ensembleWellLogsCollection() ); + } + } + } + else if ( uiConfigName == "PlotWindow.Scripts" || uiConfigName == "MainWindow.Scripts" ) + { uiTreeOrdering.add( scriptCollection() ); } - else + else if ( uiConfigName == "PlotWindow.Templates" ) { - if ( viewLinkerCollection()->viewLinker() ) + uiTreeOrdering.add( m_plotTemplateTopFolder ); + } + else if ( uiConfigName == "MainWindow.DataSources" ) + { + RimOilField* oilField = activeOilField(); + if ( oilField ) { - // Use object instead of field to avoid duplicate entries in the tree view - uiTreeOrdering.add( viewLinkerCollection() ); + if ( oilField->analysisModels() ) uiTreeOrdering.add( oilField->analysisModels() ); } + } + else + { + // Use object instead of field to avoid duplicate entries in the tree view + uiTreeOrdering.add( viewLinkerCollection() ); RimOilField* oilField = activeOilField(); if ( oilField ) @@ -1527,7 +1498,6 @@ void RimProject::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, Q } uiTreeOrdering.add( colorLegendCollection() ); - uiTreeOrdering.add( scriptCollection() ); } uiTreeOrdering.skipRemainingChildren( true ); @@ -1543,7 +1513,7 @@ class GlobalPathListMapper GlobalPathListMapper( const QString& globalPathListTable ) { m_maxUsedIdNumber = 0; - QStringList pathPairs = globalPathListTable.split( ";", QString::SkipEmptyParts ); + QStringList pathPairs = RiaTextStringTools::splitSkipEmptyParts( globalPathListTable, ";" ); for ( const QString& pathIdPathPair : pathPairs ) { diff --git a/ApplicationLibCode/ProjectDataModel/RimProject.h b/ApplicationLibCode/ProjectDataModel/RimProject.h index dff2e37f00..89d64e4651 100644 --- a/ApplicationLibCode/ProjectDataModel/RimProject.h +++ b/ApplicationLibCode/ProjectDataModel/RimProject.h @@ -70,6 +70,7 @@ class RimValveTemplateCollection; class RimValveTemplate; class RimCompletionTemplateCollection; class RimPlotTemplateFolderItem; +class RimGridCalculationCollection; namespace caf { @@ -99,19 +100,20 @@ class RimProject : public caf::PdmDocument caf::PdmChildField mainPlotCollection; caf::PdmChildField viewLinkerCollection; caf::PdmChildField calculationCollection; + caf::PdmChildField gridCalculationCollection; caf::PdmChildArrayField commandObjects; caf::PdmChildArrayField multiSnapshotDefinitions; - caf::PdmField mainWindowTreeViewState; - caf::PdmField mainWindowCurrentModelIndexPath; + caf::PdmField mainWindowTreeViewStates; + caf::PdmField mainWindowCurrentModelIndexPaths; - caf::PdmField plotWindowTreeViewState; - caf::PdmField plotWindowCurrentModelIndexPath; + caf::PdmField plotWindowTreeViewStates; + caf::PdmField plotWindowCurrentModelIndexPaths; bool writeProjectFile(); - void setScriptDirectories( const QString& scriptDirectories ); + void setScriptDirectories( const QString& scriptDirectories, int maxFolderDepth ); void setPlotTemplateFolders( const QStringList& plotTemplateFolders ); QString projectFileVersionString() const; @@ -124,7 +126,6 @@ class RimProject : public caf::PdmDocument void assignIdToCaseGroup( RimIdenticalGridCaseGroup* caseGroup ); void assignViewIdToView( Rim3dView* view ); void assignPlotIdToPlotWindow( RimPlotWindow* plotWindow ); - void assignCalculationIdToCalculation( RimSummaryCalculation* calculation ); void assignCaseIdToSummaryCase( RimSummaryCase* summaryCase ); void assignIdToEnsemble( RimSummaryCaseCollection* summaryCaseCollection ); @@ -188,7 +189,7 @@ class RimProject : public caf::PdmDocument caf::AppEnum commonUnitSystemForAllCases() const; RimMeasurement* measurement() const; - RimPlotTemplateFolderItem* rootPlotTemlateItem() const; + RimPlotTemplateFolderItem* rootPlotTemplateItem() const; std::vector allFilePaths() const; @@ -211,7 +212,7 @@ class RimProject : public caf::PdmDocument caf::PdmField m_projectFileVersionString; caf::PdmChildField m_dialogData; - caf::PdmChildField m_plotTemplateFolderItem; + caf::PdmChildField m_plotTemplateTopFolder; caf::PdmField m_show3DWindow; caf::PdmField m_showPlotWindow; @@ -223,7 +224,6 @@ class RimProject : public caf::PdmDocument int m_nextValidCaseGroupId; int m_nextValidViewId; int m_nextValidPlotId; - int m_nextValidCalculationId; int m_nextValidSummaryCaseId; int m_nextValidEnsembleId; @@ -261,7 +261,7 @@ void RimProject::fieldContentsByType( const caf::PdmObjectHandle* object, std::v } } - field->childObjects( &children ); + field->children( &children ); } for ( const auto& child : children ) diff --git a/ApplicationLibCode/ProjectDataModel/RimRegularLegendConfig.cpp b/ApplicationLibCode/ProjectDataModel/RimRegularLegendConfig.cpp index d4d2d722a4..7dd2f753eb 100644 --- a/ApplicationLibCode/ProjectDataModel/RimRegularLegendConfig.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimRegularLegendConfig.cpp @@ -145,8 +145,8 @@ RimRegularLegendConfig::RimRegularLegendConfig() , m_isAllTimeStepsRangeDisabled( false ) , m_resetUserDefinedValues( false ) { - CAF_PDM_InitObject( "Color Legend", ":/Legend.png", "", "" ); - CAF_PDM_InitField( &m_showLegend, "ShowLegend", true, "Show Legend", "", "", "" ); + CAF_PDM_InitObject( "Color Legend", ":/Legend.png" ); + CAF_PDM_InitField( &m_showLegend, "ShowLegend", true, "Show Legend" ); m_showLegend.uiCapability()->setUiHidden( true ); CAF_PDM_InitField( &m_numLevels, "NumberOfLevels", 8, "Number of Levels", "", "A hint on how many tick marks you whish.", "" ); CAF_PDM_InitField( &m_precision, @@ -160,29 +160,20 @@ RimRegularLegendConfig::RimRegularLegendConfig() CAF_PDM_InitField( &m_tickNumberFormat, "TickNumberFormat", caf::AppEnum( RiaNumberFormat::NumberFormatType::FIXED ), - "Number format", - "", - "", - "" ); + "Number format" ); - CAF_PDM_InitField( &m_colorRangeMode_OBSOLETE, - "ColorRangeMode", - ColorRangeEnum( ColorRangesType::UNDEFINED ), - "Colors", - "", - "", - "" ); + CAF_PDM_InitField( &m_colorRangeMode_OBSOLETE, "ColorRangeMode", ColorRangeEnum( ColorRangesType::UNDEFINED ), "Colors" ); m_colorRangeMode_OBSOLETE.uiCapability()->setUiHidden( true ); m_colorRangeMode_OBSOLETE.xmlCapability()->setIOWritable( false ); - CAF_PDM_InitFieldNoDefault( &m_colorLegend, "ColorLegend", "Colors", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_colorLegend, "ColorLegend", "Colors" ); m_colorLegend = mapToColorLegend( ColorRangeEnum( ColorRangesType::NORMAL ) ); - CAF_PDM_InitField( &m_selectColorLegendButton, "selectColorLegendButton", false, "Edit", "", "", "" ); + CAF_PDM_InitField( &m_selectColorLegendButton, "selectColorLegendButton", false, "Edit" ); m_selectColorLegendButton.uiCapability()->setUiEditorTypeName( caf::PdmUiToolButtonEditor::uiEditorTypeName() ); m_selectColorLegendButton.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); m_selectColorLegendButton.xmlCapability()->disableIO(); - CAF_PDM_InitField( &m_mappingMode, "MappingMode", MappingEnum( MappingType::LINEAR_CONTINUOUS ), "Mapping", "", "", "" ); + CAF_PDM_InitField( &m_mappingMode, "MappingMode", MappingEnum( MappingType::LINEAR_CONTINUOUS ), "Mapping" ); CAF_PDM_InitField( &m_rangeMode, "RangeType", RangeModeEnum( RangeModeType::AUTOMATIC_ALLTIMESTEPS ), @@ -199,9 +190,9 @@ RimRegularLegendConfig::RimRegularLegendConfig() "Min value of the legend (if mapping is logarithmic only positive values are valid)", "" ); - CAF_PDM_InitFieldNoDefault( &m_categoryColorMode, "CategoryColorMode", "Category Mode", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_categoryColorMode, "CategoryColorMode", "Category Mode" ); - CAF_PDM_InitField( &resultVariableName, "ResultVariableUsage", QString( "" ), "", "", "", "" ); + CAF_PDM_InitField( &resultVariableName, "ResultVariableUsage", QString( "" ), "" ); resultVariableName.uiCapability()->setUiHidden( true ); m_linDiscreteScalarMapper = new cvf::ScalarMapperDiscreteLinear; @@ -217,10 +208,12 @@ RimRegularLegendConfig::RimRegularLegendConfig() m_scalarMapperLegend = new caf::OverlayScalarMapperLegend( standardFont ); m_categoryLegend = new caf::CategoryLegend( standardFont, m_categoryMapper.p() ); - CAF_PDM_InitField( &m_resetUserDefinedValuesButton, "ResetDefaultValues", false, "Reset Default Values", "", "", "" ); + CAF_PDM_InitField( &m_resetUserDefinedValuesButton, "ResetDefaultValues", false, "Reset Default Values" ); m_resetUserDefinedValuesButton.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); m_resetUserDefinedValuesButton.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); + CAF_PDM_InitField( &m_centerLegendAroundZero, "CenterLegendAroundZero", false, "Center Legend Around Zero" ); + updateFieldVisibility(); updateLegend(); } @@ -411,25 +404,7 @@ void RimRegularLegendConfig::updateLegend() if ( m_resetUserDefinedValues && m_globalAutoMax != cvf::UNDEFINED_DOUBLE ) { - if ( m_mappingMode() == MappingType::LOG10_CONTINUOUS || m_mappingMode() == MappingType::LOG10_DISCRETE ) - { - double exponentMax = computeTenExponentCeil( m_globalAutoMax ); - double exponentMin = computeTenExponentFloor( m_globalAutoPosClosestToZero ); - - m_userDefinedMaxValue = pow( 10, exponentMax ); - m_userDefinedMinValue = pow( 10, exponentMin ); - - int numLevels = exponentMax - exponentMin; - if ( numLevels > 0 ) - { - m_numLevels = numLevels; - } - } - else if ( m_mappingMode() == MappingType::LINEAR_CONTINUOUS || m_mappingMode() == MappingType::LINEAR_DISCRETE ) - { - m_userDefinedMaxValue = m_globalAutoMax; - m_userDefinedMinValue = m_globalAutoMin; - } + updateTickCountAndUserDefinedRange(); m_resetUserDefinedValues = false; } @@ -465,6 +440,13 @@ void RimRegularLegendConfig::updateLegend() negClosestToZero = m_globalAutoNegClosestToZero; } + if ( m_centerLegendAroundZero ) + { + auto maxValue = std::max( std::abs( adjustedMax ), std::abs( adjustedMin ) ); + adjustedMax = maxValue; + adjustedMin = -maxValue; + } + m_linDiscreteScalarMapper->setRange( adjustedMin, adjustedMax ); m_linSmoothScalarMapper->setRange( adjustedMin, adjustedMax ); @@ -622,6 +604,14 @@ void RimRegularLegendConfig::resetUserDefinedValues() m_resetUserDefinedValues = true; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimRegularLegendConfig::setCenterLegendAroundZero( bool enable ) +{ + m_centerLegendAroundZero = enable; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -873,6 +863,36 @@ void RimRegularLegendConfig::configureCategoryMapper() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimRegularLegendConfig::updateTickCountAndUserDefinedRange() +{ + if ( m_globalAutoMax != cvf::UNDEFINED_DOUBLE ) + { + if ( m_mappingMode() == MappingType::LOG10_CONTINUOUS || m_mappingMode() == MappingType::LOG10_DISCRETE ) + { + double exponentMax = computeTenExponentCeil( m_globalAutoMax ); + double exponentMin = computeTenExponentFloor( m_globalAutoPosClosestToZero ); + + m_userDefinedMaxValue = pow( 10, exponentMax ); + m_userDefinedMinValue = pow( 10, exponentMin ); + + int numLevels = exponentMax - exponentMin; + if ( numLevels > 0 ) + { + m_numLevels = numLevels; + } + } + else if ( m_mappingMode() == MappingType::LINEAR_CONTINUOUS || m_mappingMode() == MappingType::LINEAR_DISCRETE ) + { + m_userDefinedMaxValue = m_globalAutoMax; + m_userDefinedMinValue = m_globalAutoMin; + m_numLevels = 8; + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1198,6 +1218,67 @@ QString RimRegularLegendConfig::valueToText( double value ) const return RiaNumberFormat::valueToText( value, m_tickNumberFormat(), m_significantDigitsInData ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimRegularLegendConfig::setDefaultConfigForResultName( const QString& resultName, + bool useDiscreteLogLevels, + bool isCategoryResult ) +{ + bool useLog = RiaResultNames::isLogarithmicResult( resultName ); + + RimRegularLegendConfig::MappingType mappingType = MappingType::LINEAR_CONTINUOUS; + RimLegendConfig::RangeModeType rangeType = RimLegendConfig::RangeModeType::AUTOMATIC_ALLTIMESTEPS; + RiaNumberFormat::NumberFormatType numberFormat = RiaNumberFormat::NumberFormatType::FIXED; + + if ( useLog ) + { + if ( useDiscreteLogLevels ) + mappingType = RimRegularLegendConfig::MappingType::LOG10_DISCRETE; + else + mappingType = RimRegularLegendConfig::MappingType::LOG10_CONTINUOUS; + + numberFormat = RiaNumberFormat::NumberFormatType::AUTO; + rangeType = RimLegendConfig::RangeModeType::USER_DEFINED; + } + + bool centerLegendAroundZero = false; + RimRegularLegendConfig::ColorRangesType colorRangeType = RimRegularLegendConfig::ColorRangesType::UNDEFINED; + + if ( isCategoryResult ) + { + colorRangeType = RimRegularLegendConfig::ColorRangesType::CATEGORY; + mappingType = RimRegularLegendConfig::MappingType::CATEGORY_INTEGER; + } + else if ( resultName == RiaResultNames::swat() ) + { + colorRangeType = RimRegularLegendConfig::ColorRangesType::OPPOSITE_NORMAL; + } + else if ( RiaResultNames::isFlowResultWithBothPosAndNegValues( resultName ) ) + { + colorRangeType = RimRegularLegendConfig::ColorRangesType::BLUE_WHITE_RED; + centerLegendAroundZero = true; + } + else if ( resultName != RiaResultNames::undefinedResultName() ) + { + colorRangeType = RimRegularLegendConfig::ColorRangesType::NORMAL; + } + + resetUserDefinedValues(); + setRangeMode( rangeType ); + setMappingMode( mappingType ); + setCenterLegendAroundZero( centerLegendAroundZero ); + setTickNumberFormat( numberFormat ); + updateTickCountAndUserDefinedRange(); + + if ( colorRangeType != RimRegularLegendConfig::ColorRangesType::UNDEFINED ) + { + RimColorLegend* colorLegend = RimRegularLegendConfig::mapToColorLegend( colorRangeType ); + + setColorLegend( colorLegend ); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1235,6 +1316,8 @@ void RimRegularLegendConfig::defineUiOrdering( QString uiConfigName, caf::PdmUiO mappingGr->add( &m_userDefinedMaxValue ); mappingGr->add( &m_userDefinedMinValue ); mappingGr->add( &m_categoryColorMode ); + mappingGr->add( &m_centerLegendAroundZero ); + uiOrdering.add( &m_resetUserDefinedValuesButton ); } @@ -1244,8 +1327,7 @@ void RimRegularLegendConfig::defineUiOrdering( QString uiConfigName, caf::PdmUiO //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList - RimRegularLegendConfig::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) +QList RimRegularLegendConfig::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { bool hasStimPlanParent = false; bool hasEnsembleCurveSetParent = false; diff --git a/ApplicationLibCode/ProjectDataModel/RimRegularLegendConfig.h b/ApplicationLibCode/ProjectDataModel/RimRegularLegendConfig.h index 99448d951c..19cbb1fbcc 100644 --- a/ApplicationLibCode/ProjectDataModel/RimRegularLegendConfig.h +++ b/ApplicationLibCode/ProjectDataModel/RimRegularLegendConfig.h @@ -127,6 +127,7 @@ class RimRegularLegendConfig : public RimLegendConfig MappingType mappingMode() { return m_mappingMode(); } void setTickNumberFormat( RiaNumberFormat::NumberFormatType numberFormat ); void resetUserDefinedValues(); + void setCenterLegendAroundZero( bool enable ); void disableAllTimeStepsRange( bool doDisable ); @@ -169,6 +170,8 @@ class RimRegularLegendConfig : public RimLegendConfig QString valueToText( double value ) const; + void setDefaultConfigForResultName( const QString& resultName, bool useDiscreteLogLevels, bool isCategoryResult ); + private: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void sendChangedSignal( const caf::PdmFieldHandle* changedField ); @@ -179,8 +182,7 @@ class RimRegularLegendConfig : public RimLegendConfig caf::PdmUiEditorAttribute* attribute ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void updateLegend(); void updateFieldVisibility(); @@ -188,6 +190,7 @@ class RimRegularLegendConfig : public RimLegendConfig void updateCategoryItems(); void configureCategoryMapper(); + void updateTickCountAndUserDefinedRange(); friend class RimViewLinker; @@ -231,6 +234,7 @@ class RimRegularLegendConfig : public RimLegendConfig caf::PdmField> m_mappingMode; caf::PdmField> m_categoryColorMode; caf::PdmField m_resetUserDefinedValuesButton; + caf::PdmField m_centerLegendAroundZero; caf::PdmPtrField m_colorLegend; caf::PdmField m_selectColorLegendButton; diff --git a/ApplicationLibCode/ProjectDataModel/RimReloadCaseTools.cpp b/ApplicationLibCode/ProjectDataModel/RimReloadCaseTools.cpp index 8a57a9901c..be0c9ea10b 100644 --- a/ApplicationLibCode/ProjectDataModel/RimReloadCaseTools.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimReloadCaseTools.cpp @@ -38,8 +38,8 @@ #include "RimMultiPlotCollection.h" #include "RimProject.h" #include "RimSummaryCaseMainCollection.h" -#include "RimSummaryPlot.h" -#include "RimSummaryPlotCollection.h" +#include "RimSummaryMultiPlot.h" +#include "RimSummaryMultiPlotCollection.h" #include "RimWellLogPlot.h" #include "RimWellLogPlotCollection.h" @@ -156,10 +156,11 @@ void RimReloadCaseTools::updateAllPlots() } } - RimSummaryPlotCollection* summaryPlotCollection = project->mainPlotCollection()->summaryPlotCollection(); - if ( summaryPlotCollection ) + RimSummaryMultiPlotCollection* summaryMultiPlotCollection = + project->mainPlotCollection()->summaryMultiPlotCollection(); + if ( summaryMultiPlotCollection ) { - for ( RimSummaryPlot* summaryPlot : summaryPlotCollection->plots() ) + for ( RimSummaryMultiPlot* summaryPlot : summaryMultiPlotCollection->multiPlots() ) { summaryPlot->loadDataAndUpdate(); } diff --git a/ApplicationLibCode/ProjectDataModel/RimReloadCaseTools.h b/ApplicationLibCode/ProjectDataModel/RimReloadCaseTools.h index f0f3b13123..37a2ae81dc 100644 --- a/ApplicationLibCode/ProjectDataModel/RimReloadCaseTools.h +++ b/ApplicationLibCode/ProjectDataModel/RimReloadCaseTools.h @@ -33,9 +33,10 @@ class RimReloadCaseTools // Reload grid data, but not summary static void reloadAllEclipseGridData( RimEclipseCase* eclipseCase ); + static void updateAll3dViews( RimEclipseCase* eclipseCase ); + private: static void reloadAllEclipseData( RimEclipseCase* eclipseCase, bool reloadSummaryData ); static void clearAllGridData( RigEclipseCaseData* eclipseCaseData ); - static void updateAll3dViews( RimEclipseCase* eclipseCase ); static void updateAllPlots(); }; diff --git a/ApplicationLibCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp b/ApplicationLibCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp index e323ea17f7..c6adfbe8a6 100644 --- a/ApplicationLibCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp @@ -51,11 +51,11 @@ CAF_PDM_SOURCE_INIT( RimReservoirCellResultsStorage, "ReservoirCellResultStorage RimReservoirCellResultsStorage::RimReservoirCellResultsStorage() : m_cellResults( nullptr ) { - CAF_PDM_InitObject( "Cacher", "", "", "" ); + CAF_PDM_InitObject( "Cacher" ); - CAF_PDM_InitField( &m_resultCacheFileName, "ResultCacheFileName", QString(), "UiDummyname", "", "", "" ); + CAF_PDM_InitField( &m_resultCacheFileName, "ResultCacheFileName", QString(), "UiDummyname" ); m_resultCacheFileName.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_resultCacheMetaData, "ResultCacheEntries", "UiDummyname", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_resultCacheMetaData, "ResultCacheEntries", "UiDummyname" ); m_resultCacheMetaData.uiCapability()->setUiTreeHidden( true ); } @@ -64,7 +64,7 @@ RimReservoirCellResultsStorage::RimReservoirCellResultsStorage() //-------------------------------------------------------------------------------------------------- RimReservoirCellResultsStorage::~RimReservoirCellResultsStorage() { - m_resultCacheMetaData.deleteAllChildObjects(); + m_resultCacheMetaData.deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -77,7 +77,7 @@ RimReservoirCellResultsStorage::~RimReservoirCellResultsStorage() //-------------------------------------------------------------------------------------------------- void RimReservoirCellResultsStorage::setupBeforeSave() { - m_resultCacheMetaData.deleteAllChildObjects(); + m_resultCacheMetaData.deleteChildren(); QString newValidCacheFileName = getValidCacheFileName(); // Delete the storage file @@ -317,19 +317,16 @@ CAF_PDM_SOURCE_INIT( RimReservoirCellResultsStorageEntryInfo, "ResultStorageEntr //-------------------------------------------------------------------------------------------------- RimReservoirCellResultsStorageEntryInfo::RimReservoirCellResultsStorageEntryInfo() { - CAF_PDM_InitObject( "Cache Entry", "", "", "" ); + CAF_PDM_InitObject( "Cache Entry" ); CAF_PDM_InitField( &m_resultType, "ResultType", caf::AppEnum( RiaDefines::ResultCatType::REMOVED ), - "ResultType", - "", - "", - "" ); - CAF_PDM_InitField( &m_resultName, "ResultName", QString(), "ResultName", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_timeStepDates, "TimeSteps", "TimeSteps", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_daysSinceSimulationStart, "DaysSinceSimulationStart", "DaysSinceSimulationStart", "", "", "" ); - CAF_PDM_InitField( &m_filePosition, "FilePositionDataStart", qint64( -1 ), "FilePositionDataStart", "", "", "" ); + "ResultType" ); + CAF_PDM_InitField( &m_resultName, "ResultName", QString(), "ResultName" ); + CAF_PDM_InitFieldNoDefault( &m_timeStepDates, "TimeSteps", "TimeSteps" ); + CAF_PDM_InitFieldNoDefault( &m_daysSinceSimulationStart, "DaysSinceSimulationStart", "DaysSinceSimulationStart" ); + CAF_PDM_InitField( &m_filePosition, "FilePositionDataStart", qint64( -1 ), "FilePositionDataStart" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimRftPlotCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimRftPlotCollection.cpp index 4031611248..39e9a51bcd 100644 --- a/ApplicationLibCode/ProjectDataModel/RimRftPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimRftPlotCollection.cpp @@ -39,9 +39,9 @@ CAF_PDM_SOURCE_INIT( RimRftPlotCollection, "WellRftPlotCollection" ); //-------------------------------------------------------------------------------------------------- RimRftPlotCollection::RimRftPlotCollection() { - CAF_PDM_InitObject( "RFT Plots", ":/RFTPlots16x16.png", "", "" ); + CAF_PDM_InitObject( "RFT Plots", ":/RFTPlots16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_rftPlots, "RftPlots", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_rftPlots, "RftPlots", "" ); m_rftPlots.uiCapability()->setUiTreeHidden( true ); } @@ -50,7 +50,7 @@ RimRftPlotCollection::RimRftPlotCollection() //-------------------------------------------------------------------------------------------------- RimRftPlotCollection::~RimRftPlotCollection() { - m_rftPlots.deleteAllChildObjects(); + m_rftPlots.deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -246,7 +246,7 @@ void RimRftPlotCollection::addPlot( gsl::not_null newPlot ) //-------------------------------------------------------------------------------------------------- void RimRftPlotCollection::removePlot( gsl::not_null plot ) { - m_rftPlots.removeChildObject( plot ); + m_rftPlots.removeChild( plot ); updateAllRequiredEditors(); } @@ -255,5 +255,5 @@ void RimRftPlotCollection::removePlot( gsl::not_null plot ) //-------------------------------------------------------------------------------------------------- void RimRftPlotCollection::deleteAllPlots() { - m_rftPlots.deleteAllChildObjects(); + m_rftPlots.deleteChildren(); } diff --git a/ApplicationLibCode/ProjectDataModel/RimScriptCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimScriptCollection.cpp index 12d1f15695..679795298b 100644 --- a/ApplicationLibCode/ProjectDataModel/RimScriptCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimScriptCollection.cpp @@ -35,17 +35,16 @@ CAF_PDM_SOURCE_INIT( RimScriptCollection, "ScriptLocation" ); //-------------------------------------------------------------------------------------------------- RimScriptCollection::RimScriptCollection() { - CAF_PDM_InitObject( "ScriptLocation", ":/Folder.png", "", "" ); + CAF_PDM_InitObject( "ScriptLocation", ":/Folder.png" ); - CAF_PDM_InitFieldNoDefault( &directory, "ScriptDirectory", "Folder", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &calcScripts, "CalcScripts", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &directory, "ScriptDirectory", "Folder" ); + directory.uiCapability()->setUiReadOnly( true ); + directory.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); + + CAF_PDM_InitFieldNoDefault( &calcScripts, "CalcScripts", "" ); calcScripts.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &subDirectories, "SubDirectories", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &subDirectories, "SubDirectories", "" ); subDirectories.uiCapability()->setUiTreeHidden( true ); - - CAF_PDM_InitField( &m_searchSubFolders, "SearchSubFolders", false, "Add Subfolders", "", "", "" ); - - directory.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); } //-------------------------------------------------------------------------------------------------- @@ -53,22 +52,26 @@ RimScriptCollection::RimScriptCollection() //-------------------------------------------------------------------------------------------------- RimScriptCollection::~RimScriptCollection() { - calcScripts.deleteAllChildObjects(); - subDirectories.deleteAllChildObjects(); + calcScripts.deleteChildren(); + subDirectories.deleteChildren(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimScriptCollection::readContentFromDisc() +void RimScriptCollection::readContentFromDisc( int folderLevelsLeft ) { - calcScripts.deleteAllChildObjects(); + calcScripts.deleteChildren(); + subDirectories.deleteChildren(); + + folderLevelsLeft--; + if ( folderLevelsLeft < 0 ) return; if ( directory().isEmpty() ) { for ( size_t i = 0; i < subDirectories.size(); ++i ) { - if ( subDirectories[i] ) subDirectories[i]->readContentFromDisc(); + if ( subDirectories[i] ) subDirectories[i]->readContentFromDisc( folderLevelsLeft ); } return; } @@ -104,9 +107,7 @@ void RimScriptCollection::readContentFromDisc() } } - subDirectories.deleteAllChildObjects(); - - if ( m_searchSubFolders() ) + if ( folderLevelsLeft > 0 ) { QDir dir( directory ); QFileInfoList fileInfoList = dir.entryInfoList( QDir::AllDirs | QDir::NoDotAndDotDot | QDir::Readable ); @@ -120,7 +121,7 @@ void RimScriptCollection::readContentFromDisc() RimScriptCollection* scriptLocation = new RimScriptCollection; scriptLocation->directory = fi.absoluteFilePath(); scriptLocation->setUiName( fi.baseName() ); - scriptLocation->readContentFromDisc(); + scriptLocation->readContentFromDisc( folderLevelsLeft ); subDirectories.push_back( scriptLocation ); } @@ -128,25 +129,6 @@ void RimScriptCollection::readContentFromDisc() } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimScriptCollection::fieldChangedByUi( const caf::PdmFieldHandle* changedField, - const QVariant& oldValue, - const QVariant& newValue ) -{ - if ( &directory == changedField ) - { - QFileInfo fi( directory ); - this->setUiName( fi.baseName() ); - this->readContentFromDisc(); - } - else if ( &m_searchSubFolders == changedField ) - { - this->readContentFromDisc(); - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimScriptCollection.h b/ApplicationLibCode/ProjectDataModel/RimScriptCollection.h index afa24804a7..a71529612a 100644 --- a/ApplicationLibCode/ProjectDataModel/RimScriptCollection.h +++ b/ApplicationLibCode/ProjectDataModel/RimScriptCollection.h @@ -43,23 +43,17 @@ class RimScriptCollection : public caf::PdmObject RimScriptCollection(); ~RimScriptCollection() override; -public: // Pdm Fields +public: caf::PdmField directory; caf::PdmChildArrayField calcScripts; caf::PdmChildArrayField subDirectories; -public: // Methods - void readContentFromDisc(); - - // Overrides from PdmObject - void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; +public: + void readContentFromDisc( int folderLevelsLeft ); protected: void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; - -private: - caf::PdmField m_searchSubFolders; }; diff --git a/ApplicationLibCode/ProjectDataModel/RimSimWellInView.cpp b/ApplicationLibCode/ProjectDataModel/RimSimWellInView.cpp index 6e4305cdc9..caa6eda0aa 100644 --- a/ApplicationLibCode/ProjectDataModel/RimSimWellInView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimSimWellInView.cpp @@ -70,28 +70,28 @@ RimSimWellInView::RimSimWellInView() "SimulationWell", "An Eclipse Simulation Well" ); - CAF_PDM_InitScriptableFieldNoDefault( &name, "Name", "Name", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &name, "Name", "Name" ); name.registerKeywordAlias( "WellName" ); - CAF_PDM_InitField( &showWell, "ShowWell", true, "Show well ", "", "", "" ); + CAF_PDM_InitField( &showWell, "ShowWell", true, "Show well " ); - CAF_PDM_InitField( &showWellLabel, "ShowWellLabel", true, "Label", "", "", "" ); - CAF_PDM_InitField( &showWellHead, "ShowWellHead", true, "Well Head", "", "", "" ); - CAF_PDM_InitField( &showWellPipe, "ShowWellPipe", true, "Pipe", "", "", "" ); - CAF_PDM_InitField( &showWellSpheres, "ShowWellSpheres", false, "Spheres", "", "", "" ); - CAF_PDM_InitField( &showWellDisks, "ShowWellDisks", false, "Disks", "", "", "" ); + CAF_PDM_InitField( &showWellLabel, "ShowWellLabel", true, "Label" ); + CAF_PDM_InitField( &showWellHead, "ShowWellHead", true, "Well Head" ); + CAF_PDM_InitField( &showWellPipe, "ShowWellPipe", true, "Pipe" ); + CAF_PDM_InitField( &showWellSpheres, "ShowWellSpheres", false, "Spheres" ); + CAF_PDM_InitField( &showWellDisks, "ShowWellDisks", false, "Disks" ); - CAF_PDM_InitField( &wellHeadScaleFactor, "WellHeadScaleFactor", 1.0, "Well Head Scale", "", "", "" ); - CAF_PDM_InitField( &pipeScaleFactor, "WellPipeRadiusScale", 1.0, "Pipe Radius Scale", "", "", "" ); - CAF_PDM_InitField( &wellPipeColor, "WellPipeColor", cvf::Color3f( 0.588f, 0.588f, 0.804f ), "Pipe Color", "", "", "" ); + CAF_PDM_InitField( &wellHeadScaleFactor, "WellHeadScaleFactor", 1.0, "Well Head Scale" ); + CAF_PDM_InitField( &pipeScaleFactor, "WellPipeRadiusScale", 1.0, "Pipe Radius Scale" ); + CAF_PDM_InitField( &wellPipeColor, "WellPipeColor", cvf::Color3f( 0.588f, 0.588f, 0.804f ), "Pipe Color" ); cvf::Color3f defaultWellDiskColor = cvf::Color3::OLIVE; - CAF_PDM_InitField( &wellDiskColor, "WellDiskColor", defaultWellDiskColor, "Disk Color", "", "", "" ); + CAF_PDM_InitField( &wellDiskColor, "WellDiskColor", defaultWellDiskColor, "Disk Color" ); - CAF_PDM_InitField( &showWellCells, "ShowWellCells", false, "Well Cells", "", "", "" ); - CAF_PDM_InitField( &showWellCellFence, "ShowWellCellFence", false, "Well Cell Fence", "", "", "" ); + CAF_PDM_InitField( &showWellCells, "ShowWellCells", false, "Well Cells" ); + CAF_PDM_InitField( &showWellCellFence, "ShowWellCellFence", false, "Well Cell Fence" ); - CAF_PDM_InitFieldNoDefault( &simwellFractureCollection, "FractureCollection", "Fractures", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &simwellFractureCollection, "FractureCollection", "Fractures" ); name.uiCapability()->setUiHidden( true ); name.uiCapability()->setUiReadOnly( true ); diff --git a/ApplicationLibCode/ProjectDataModel/RimSimWellInViewCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimSimWellInViewCollection.cpp index 86b01ca493..c428dfae2f 100644 --- a/ApplicationLibCode/ProjectDataModel/RimSimWellInViewCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimSimWellInViewCollection.cpp @@ -138,29 +138,26 @@ CAF_PDM_SOURCE_INIT( RimSimWellInViewCollection, "Wells" ); //-------------------------------------------------------------------------------------------------- RimSimWellInViewCollection::RimSimWellInViewCollection() { - CAF_PDM_InitObject( "Simulation Wells", ":/WellCollection.png", "", "" ); + CAF_PDM_InitObject( "Simulation Wells", ":/WellCollection.png" ); - CAF_PDM_InitField( &isActive, "Active", true, "Active", "", "", "" ); + CAF_PDM_InitField( &isActive, "Active", true, "Active" ); isActive.uiCapability()->setUiHidden( true ); // CAF_PDM_InitField(&showWellsIntersectingVisibleCells, "ShowWellsIntersectingVisibleCells", false, "Hide Wells Not - // Intersecting Filtered Cells", "", "", ""); + // Intersecting Filtered Cells"); CAF_PDM_InitField( &showWellsIntersectingVisibleCells, "ShowWellsIntersectingVisibleCells", false, - "Wells Through Visible Cells Only", - "", - "", - "" ); + "Wells Through Visible Cells Only" ); // CAF_PDM_InitField(&showWellsIntersectingVisibleCells, "ShowWellsIntersectingVisibleCells", false, "Hide Wells - // Missing Visible Cells", "", "", ""); + // Missing Visible Cells"); // Appearance - CAF_PDM_InitFieldNoDefault( &m_showWellHead, "ShowWellHeadTristate", "Well Head", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_showWellLabel, "ShowWellLabelTristate", "Label", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_showWellPipe, "ShowWellPipe", "Pipe", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_showWellSpheres, "ShowWellSpheres", "Spheres", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_showWellDisks, "ShowWellDisks", "Disks", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_showWellHead, "ShowWellHeadTristate", "Well Head" ); + CAF_PDM_InitFieldNoDefault( &m_showWellLabel, "ShowWellLabelTristate", "Label" ); + CAF_PDM_InitFieldNoDefault( &m_showWellPipe, "ShowWellPipe", "Pipe" ); + CAF_PDM_InitFieldNoDefault( &m_showWellSpheres, "ShowWellSpheres", "Spheres" ); + CAF_PDM_InitFieldNoDefault( &m_showWellDisks, "ShowWellDisks", "Disks" ); m_showWellHead.uiCapability()->setUiEditorTypeName( caf::PdmUiCheckBoxTristateEditor::uiEditorTypeName() ); m_showWellHead.xmlCapability()->disableIO(); @@ -178,37 +175,31 @@ RimSimWellInViewCollection::RimSimWellInViewCollection() m_showWellDisks.xmlCapability()->disableIO(); // Scaling - CAF_PDM_InitField( &wellHeadScaleFactor, "WellHeadScale", 1.0, "Well Head Scale", "", "", "" ); - CAF_PDM_InitField( &pipeScaleFactor, "WellPipeRadiusScale", 0.1, "Pipe Radius Scale ", "", "", "" ); - CAF_PDM_InitField( &spheresScaleFactor, "CellCenterSphereScale", 0.2, "Sphere Radius Scale", "", "", "" ); + CAF_PDM_InitField( &wellHeadScaleFactor, "WellHeadScale", 1.0, "Well Head Scale" ); + CAF_PDM_InitField( &pipeScaleFactor, "WellPipeRadiusScale", 0.1, "Pipe Radius Scale " ); + CAF_PDM_InitField( &spheresScaleFactor, "CellCenterSphereScale", 0.2, "Sphere Radius Scale" ); // Color cvf::Color3f defWellLabelColor = RiaPreferences::current()->defaultWellLabelColor(); - CAF_PDM_InitField( &wellLabelColor, "WellLabelColor", defWellLabelColor, "Label Color", "", "", "" ); + CAF_PDM_InitField( &wellLabelColor, "WellLabelColor", defWellLabelColor, "Label Color" ); - CAF_PDM_InitField( &showConnectionStatusColors, "ShowConnectionStatusColors", true, "Color Pipe Connections", "", "", "" ); + CAF_PDM_InitField( &showConnectionStatusColors, "ShowConnectionStatusColors", true, "Color Pipe Connections" ); cvf::Color3f defaultApplyColor = cvf::Color3f::YELLOW; - CAF_PDM_InitField( &m_defaultWellPipeColor, "WellColorForApply", defaultApplyColor, "Uniform Well Color", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_wellPipeColors, "WellPipeColors", "Individual Pipe Colors", "", "", "" ); + CAF_PDM_InitField( &m_defaultWellPipeColor, "WellColorForApply", defaultApplyColor, "Uniform Well Color" ); + CAF_PDM_InitFieldNoDefault( &m_wellPipeColors, "WellPipeColors", "Individual Pipe Colors" ); - CAF_PDM_InitField( &pipeCrossSectionVertexCount, "WellPipeVertexCount", 12, "Pipe Vertex Count", "", "", "" ); + CAF_PDM_InitField( &pipeCrossSectionVertexCount, "WellPipeVertexCount", 12, "Pipe Vertex Count" ); pipeCrossSectionVertexCount.uiCapability()->setUiHidden( true ); - CAF_PDM_InitField( &wellPipeCoordType, "WellPipeCoordType", WellPipeCoordEnum( WELLPIPE_INTERPOLATED ), "Type", "", "", "" ); + CAF_PDM_InitField( &wellPipeCoordType, "WellPipeCoordType", WellPipeCoordEnum( WELLPIPE_INTERPOLATED ), "Type" ); - CAF_PDM_InitFieldNoDefault( &m_showWellCells, "ShowWellCellsTristate", "Show Well Cells", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_showWellCells, "ShowWellCellsTristate", "Show Well Cells" ); m_showWellCells.uiCapability()->setUiEditorTypeName( caf::PdmUiCheckBoxTristateEditor::uiEditorTypeName() ); m_showWellCells.xmlCapability()->disableIO(); - CAF_PDM_InitField( &wellCellFenceType, - "DefaultWellFenceDirection", - WellFenceEnum( K_DIRECTION ), - "Well Fence Direction", - "", - "", - "" ); + CAF_PDM_InitField( &wellCellFenceType, "DefaultWellFenceDirection", WellFenceEnum( K_DIRECTION ), "Well Fence Direction" ); - CAF_PDM_InitField( &wellCellTransparencyLevel, "WellCellTransparency", 0.5, "Well Cell Transparency", "", "", "" ); + CAF_PDM_InitField( &wellCellTransparencyLevel, "WellCellTransparency", 0.5, "Well Cell Transparency" ); CAF_PDM_InitField( &isAutoDetectingBranches, "IsAutoDetectingBranches", true, @@ -220,40 +211,31 @@ RimSimWellInViewCollection::RimSimWellInViewCollection() CAF_PDM_InitField( &wellHeadPosition, "WellHeadPosition", WellHeadPositionEnum( WELLHEAD_POS_TOP_COLUMN ), - "Well Head Position", - "", - "", - "" ); + "Well Head Position" ); - CAF_PDM_InitFieldNoDefault( &wells, "Wells", "Wells", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &wells, "Wells", "Wells" ); wells.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_showWellCellFence, "ShowWellCellFenceTristate", "Show Well Cell Fence", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_showWellCellFence, "ShowWellCellFenceTristate", "Show Well Cell Fence" ); m_showWellCellFence.uiCapability()->setUiEditorTypeName( caf::PdmUiCheckBoxTristateEditor::uiEditorTypeName() ); m_showWellCellFence.xmlCapability()->disableIO(); - CAF_PDM_InitFieldNoDefault( &m_wellDiskSummaryCase, "WellDiskSummaryCase", "Summary Case", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wellDiskSummaryCase, "WellDiskSummaryCase", "Summary Case" ); - CAF_PDM_InitField( &m_wellDiskQuantity, "WellDiskQuantity", QString( "WOPT" ), "Disk Quantity", "", "", "" ); + CAF_PDM_InitField( &m_wellDiskQuantity, "WellDiskQuantity", QString( "WOPT" ), "Disk Quantity" ); m_wellDiskQuantity.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() ); m_wellDiskQuantity.uiCapability()->setAutoAddingOptionFromValue( false ); - CAF_PDM_InitFieldNoDefault( &m_wellDiskPropertyType, "WellDiskPropertyType", "Property Type", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_wellDiskPropertyConfigType, "WellDiskPropertyConfigType", "Property Config Type", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wellDiskPropertyType, "WellDiskPropertyType", "Property Type" ); + CAF_PDM_InitFieldNoDefault( &m_wellDiskPropertyConfigType, "WellDiskPropertyConfigType", "Property Config Type" ); - CAF_PDM_InitField( &m_wellDiskShowQuantityLabels, "WellDiskShowQuantityLabels", true, "Show Quantity Labels", "", "", "" ); - CAF_PDM_InitField( &m_wellDiskshowLabelsBackground, - "WellDiskShowLabelsBackground", - false, - "Show Label Background", - "", - "", - "" ); - CAF_PDM_InitField( &m_wellDiskScaleFactor, "WellDiskScaleFactor", 1.0, "Scale Factor", "", "", "" ); + CAF_PDM_InitField( &m_wellDiskShowQuantityLabels, "WellDiskShowQuantityLabels", true, "Show Quantity Labels" ); + CAF_PDM_InitField( &m_wellDiskshowLabelsBackground, "WellDiskShowLabelsBackground", false, "Show Label Background" ); + CAF_PDM_InitField( &m_wellDiskScaleFactor, "WellDiskScaleFactor", 1.0, "Scale Factor" ); cvf::Color3f defaultWellDiskColor = cvf::Color3::OLIVE; - CAF_PDM_InitField( &wellDiskColor, "WellDiskColor", defaultWellDiskColor, "Well Disk Color", "", "", "" ); + CAF_PDM_InitField( &wellDiskColor, "WellDiskColor", defaultWellDiskColor, "Well Disk Color" ); - CAF_PDM_InitField( &m_showWellCommunicationLines, "ShowWellCommunicationLines", false, "Communication Lines", "", "", "" ); + CAF_PDM_InitField( &m_showWellCommunicationLines, "ShowWellCommunicationLines", false, "Communication Lines" ); m_reservoirView = nullptr; } @@ -263,7 +245,7 @@ RimSimWellInViewCollection::RimSimWellInViewCollection() //-------------------------------------------------------------------------------------------------- RimSimWellInViewCollection::~RimSimWellInViewCollection() { - wells.deleteAllChildObjects(); + wells.deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -534,7 +516,7 @@ void RimSimWellInViewCollection::fieldChangedByUi( const caf::PdmFieldHandle* ch /// //-------------------------------------------------------------------------------------------------- QList - RimSimWellInViewCollection::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) + RimSimWellInViewCollection::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; @@ -551,7 +533,7 @@ QList { if ( addr.category() == RifEclipseSummaryAddress::SUMMARY_WELL ) { - summaries.insert( addr.quantityName() ); + summaries.insert( addr.vectorName() ); } } } @@ -561,7 +543,7 @@ QList QString displayName; std::string longVectorName = - RiuSummaryQuantityNameInfoProvider::instance()->longNameFromQuantityName( itemName ); + RiuSummaryQuantityNameInfoProvider::instance()->longNameFromVectorName( itemName ); if ( longVectorName.empty() ) { @@ -577,8 +559,6 @@ QList options.push_back( optionItem ); } } - - if ( useOptionsOnly ) *useOptionsOnly = true; } else if ( fieldNeedingOptions == &m_wellDiskSummaryCase ) { diff --git a/ApplicationLibCode/ProjectDataModel/RimSimWellInViewCollection.h b/ApplicationLibCode/ProjectDataModel/RimSimWellInViewCollection.h index 44eb6ead02..5028af65a7 100644 --- a/ApplicationLibCode/ProjectDataModel/RimSimWellInViewCollection.h +++ b/ApplicationLibCode/ProjectDataModel/RimSimWellInViewCollection.h @@ -168,8 +168,7 @@ class RimSimWellInViewCollection : public caf::PdmObject void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; diff --git a/ApplicationLibCode/ProjectDataModel/RimSimWellInViewTools.cpp b/ApplicationLibCode/ProjectDataModel/RimSimWellInViewTools.cpp index 6c69e11233..18a903ff73 100644 --- a/ApplicationLibCode/ProjectDataModel/RimSimWellInViewTools.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimSimWellInViewTools.cpp @@ -168,7 +168,7 @@ double RimSimWellInViewTools::extractValueForTimeStep( RifSummaryReaderInterface } auto [resampledTimeSteps, resampledValues] = - RiaSummaryTools::resampledValuesForPeriod( addr, timeSteps, values, RiaQDateTimeTools::DateTimePeriod::DAY ); + RiaSummaryTools::resampledValuesForPeriod( addr, timeSteps, values, RiaDefines::DateTimePeriod::DAY ); time_t currentTime_t = currentDate.toSecsSinceEpoch(); diff --git a/ApplicationLibCode/ProjectDataModel/RimStackablePlotCurve.cpp b/ApplicationLibCode/ProjectDataModel/RimStackablePlotCurve.cpp index c63229c8fe..f6bf53e6bb 100644 --- a/ApplicationLibCode/ProjectDataModel/RimStackablePlotCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimStackablePlotCurve.cpp @@ -28,10 +28,17 @@ RimStackablePlotCurve::RimStackablePlotCurve() , stackingColorsChanged( this ) { - CAF_PDM_InitObject( "StackableCurve", ":/WellLogCurve16x16.png", "", "" ); + CAF_PDM_InitObject( "StackableCurve", ":/WellLogCurve16x16.png" ); - CAF_PDM_InitField( &m_isStacked, "StackCurve", false, "Stack Curve", "", "", "" ); - CAF_PDM_InitField( &m_isStackedWithPhaseColors, "StackPhaseColors", false, " with Phase Colors", "", "", "" ); + CAF_PDM_InitField( &m_isStacked, "StackCurve", false, "Stack Curve" ); + CAF_PDM_InitField( &m_isStackedWithPhaseColors, "StackPhaseColors", false, " with Phase Colors" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimStackablePlotCurve::~RimStackablePlotCurve() +{ } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimStackablePlotCurve.h b/ApplicationLibCode/ProjectDataModel/RimStackablePlotCurve.h index a15b593ebc..735ab524f0 100644 --- a/ApplicationLibCode/ProjectDataModel/RimStackablePlotCurve.h +++ b/ApplicationLibCode/ProjectDataModel/RimStackablePlotCurve.h @@ -27,6 +27,7 @@ class RimStackablePlotCurve : public RimPlotCurve public: RimStackablePlotCurve(); + ~RimStackablePlotCurve() override; virtual RiaDefines::PhaseType phaseType() const; void assignStackColor( size_t index, size_t count ); diff --git a/ApplicationLibCode/ProjectDataModel/RimStatisticsPlot.cpp b/ApplicationLibCode/ProjectDataModel/RimStatisticsPlot.cpp index 2092f656dd..298d90f73c 100644 --- a/ApplicationLibCode/ProjectDataModel/RimStatisticsPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimStatisticsPlot.cpp @@ -80,18 +80,18 @@ CAF_PDM_ABSTRACT_SOURCE_INIT( RimStatisticsPlot, "StatisticsPlot" ); //-------------------------------------------------------------------------------------------------- RimStatisticsPlot::RimStatisticsPlot() { - CAF_PDM_InitField( &m_plotWindowTitle, "PlotDescription", QString( "" ), "Name", "", "", "" ); + CAF_PDM_InitField( &m_plotWindowTitle, "PlotDescription", QString( "" ), "Name" ); m_plotWindowTitle.xmlCapability()->setIOWritable( false ); - CAF_PDM_InitField( &m_numHistogramBins, "NumHistogramBins", 50, "Number of Bins", "", "", "" ); + CAF_PDM_InitField( &m_numHistogramBins, "NumHistogramBins", 50, "Number of Bins" ); m_numHistogramBins.uiCapability()->setUiEditorTypeName( caf::PdmUiLineEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_histogramBarColor, "HistogramBarColor", cvf::Color3f( cvf::Color3f::SKY_BLUE ), "Color", "", "", "" ); + CAF_PDM_InitField( &m_histogramBarColor, "HistogramBarColor", cvf::Color3f( cvf::Color3f::SKY_BLUE ), "Color" ); - CAF_PDM_InitField( &m_histogramGapWidth, "HistogramGapWidth", 0.0, "Gap Width [%]", "", "", "" ); + CAF_PDM_InitField( &m_histogramGapWidth, "HistogramGapWidth", 0.0, "Gap Width [%]" ); m_histogramGapWidth.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_histogramFrequencyType, "HistogramFrequencyType", "Frequency", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_histogramFrequencyType, "HistogramFrequencyType", "Frequency" ); CAF_PDM_InitField( &m_precision, "Precision", @@ -103,12 +103,9 @@ RimStatisticsPlot::RimStatisticsPlot() CAF_PDM_InitField( &m_tickNumberFormat, "TickNumberFormat", caf::AppEnum( RiaNumberFormat::NumberFormatType::AUTO ), - "Number format", - "", - "", - "" ); + "Number format" ); - CAF_PDM_InitFieldNoDefault( &m_graphType, "GraphType", "Graph Type", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_graphType, "GraphType", "Graph Type" ); m_plotLegendsHorizontal.uiCapability()->setUiHidden( true ); diff --git a/ApplicationLibCode/ProjectDataModel/RimStimPlanColors.cpp b/ApplicationLibCode/ProjectDataModel/RimStimPlanColors.cpp index 848eb4d79e..df1592856a 100644 --- a/ApplicationLibCode/ProjectDataModel/RimStimPlanColors.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimStimPlanColors.cpp @@ -62,18 +62,18 @@ static QString toString( const std::pair& resultNameAndUnit ); //-------------------------------------------------------------------------------------------------- RimStimPlanColors::RimStimPlanColors() { - CAF_PDM_InitObject( "Fractures", ":/FractureSymbol16x16.png", "", "" ); + CAF_PDM_InitObject( "Fractures", ":/FractureSymbol16x16.png" ); - CAF_PDM_InitField( &m_resultNameAndUnit, "ResultName", QString( "" ), "Result Variable", "", "", "" ); + CAF_PDM_InitField( &m_resultNameAndUnit, "ResultName", QString( "" ), "Result Variable" ); - CAF_PDM_InitField( &m_defaultColor, "DefaultColor", cvf::Color3f( cvf::Color3::BROWN ), "Default Color", "", "", "" ); + CAF_PDM_InitField( &m_defaultColor, "DefaultColor", cvf::Color3f( cvf::Color3::BROWN ), "Default Color" ); - CAF_PDM_InitFieldNoDefault( &m_legendConfigurations, "LegendConfigurations", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_legendConfigurations, "LegendConfigurations", "" ); m_legendConfigurations.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitField( &m_showStimPlanMesh, "ShowStimPlanMesh", true, "Show Mesh", "", "", "" ); + CAF_PDM_InitField( &m_showStimPlanMesh, "ShowStimPlanMesh", true, "Show Mesh" ); - CAF_PDM_InitFieldNoDefault( &m_stimPlanCellVizMode, "StimPlanCellVizMode", "Color Interpolation", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_stimPlanCellVizMode, "StimPlanCellVizMode", "Color Interpolation" ); } //-------------------------------------------------------------------------------------------------- @@ -125,7 +125,7 @@ void RimStimPlanColors::loadDataAndUpdate() for ( auto legend : toBeDeleted ) { - m_legendConfigurations.removeChildObject( legend ); + m_legendConfigurations.removeChild( legend ); delete legend; } @@ -163,8 +163,7 @@ void RimStimPlanColors::loadDataAndUpdate() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimStimPlanColors::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RimStimPlanColors::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; diff --git a/ApplicationLibCode/ProjectDataModel/RimStimPlanColors.h b/ApplicationLibCode/ProjectDataModel/RimStimPlanColors.h index 0b488eab60..94c288b1ce 100644 --- a/ApplicationLibCode/ProjectDataModel/RimStimPlanColors.h +++ b/ApplicationLibCode/ProjectDataModel/RimStimPlanColors.h @@ -72,8 +72,7 @@ class RimStimPlanColors : public RimCheckableObject void updateConductivityResultName(); protected: - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; diff --git a/ApplicationLibCode/ProjectDataModel/RimStimPlanLegendConfig.cpp b/ApplicationLibCode/ProjectDataModel/RimStimPlanLegendConfig.cpp index 147c683c91..93cf19c2d3 100644 --- a/ApplicationLibCode/ProjectDataModel/RimStimPlanLegendConfig.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimStimPlanLegendConfig.cpp @@ -30,12 +30,12 @@ CAF_PDM_SOURCE_INIT( RimStimPlanLegendConfig, "RimStimPlanLegendConfig" ); //-------------------------------------------------------------------------------------------------- RimStimPlanLegendConfig::RimStimPlanLegendConfig() { - CAF_PDM_InitObject( "StimPlan Color Legend", ":/Legend.png", "", "" ); + CAF_PDM_InitObject( "StimPlan Color Legend", ":/Legend.png" ); - CAF_PDM_InitField( &m_name, "Name", QString( "StimPlan Legend" ), "Name", "", "", "" ); + CAF_PDM_InitField( &m_name, "Name", QString( "StimPlan Legend" ), "Name" ); m_name.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitFieldNoDefault( &m_legend, "Legend", "Legend", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_legend, "Legend", "Legend" ); m_legend = new RimRegularLegendConfig; } diff --git a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculation.cpp b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculation.cpp index 9f0ff3c035..255312d0a9 100644 --- a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculation.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculation.cpp @@ -25,17 +25,18 @@ #include "RiaSummaryCurveDefinition.h" #include "RiaSummaryTools.h" -#include "RimProject.h" #include "RimSummaryAddress.h" #include "RimSummaryCalculationCollection.h" #include "RimSummaryCalculationVariable.h" #include "RimSummaryCurve.h" +#include "RimSummaryMultiPlot.h" +#include "RimSummaryMultiPlotCollection.h" #include "RimSummaryPlot.h" -#include "RimSummaryPlotCollection.h" #include "RiuExpressionContextMenuManager.h" #include "cafPdmUiLineEditor.h" +#include "cafPdmUiTableViewEditor.h" #include "cafPdmUiTextEditor.h" #include @@ -48,204 +49,14 @@ CAF_PDM_SOURCE_INIT( RimSummaryCalculation, "RimSummaryCalculation" ); RimSummaryCalculation::RimSummaryCalculation() { CAF_PDM_InitObject( "RimSummaryCalculation", ":/octave.png", "Calculation", "" ); - - CAF_PDM_InitFieldNoDefault( &m_description, "Description", "Description", "", "", "" ); - m_description.uiCapability()->setUiReadOnly( true ); - - CAF_PDM_InitField( &m_expression, "Expression", QString( "" ), "Expression", "", "", "" ); - m_expression.uiCapability()->setUiEditorTypeName( caf::PdmUiTextEditor::uiEditorTypeName() ); - - CAF_PDM_InitField( &m_unit, "Unit", QString( "" ), "Unit", "", "", "" ); - m_unit.uiCapability()->setUiEditorTypeName( caf::PdmUiLineEditor::uiEditorTypeName() ); - - CAF_PDM_InitFieldNoDefault( &m_variables, "Variables", "Variables", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_calculatedValues, "CalculatedValues", "Calculated Values", "", "", "" ); - - CAF_PDM_InitFieldNoDefault( &m_timesteps, "TimeSteps", "Time Steps", "", "", "" ); - CAF_PDM_InitField( &m_id, "Id", -1, "Id", "", "", "" ); - m_id.uiCapability()->setUiHidden( true ); - - m_exprContextMenuMgr = std::unique_ptr( new RiuExpressionContextMenuManager() ); - - m_isDirty = false; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimSummaryCalculation::setDescription( const QString& description ) -{ - m_description = description; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RimSummaryCalculation::description() const -{ - return m_description; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimSummaryCalculation::setId( int id ) -{ - m_id = id; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -int RimSummaryCalculation::id() const -{ - return m_id; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RimSummaryCalculation::isDirty() const -{ - return m_isDirty; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -caf::PdmChildArrayFieldHandle* RimSummaryCalculation::variables() -{ - return &m_variables; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimSummaryCalculationVariable* RimSummaryCalculation::addVariable( const QString& name ) -{ - RimSummaryCalculationVariable* v = new RimSummaryCalculationVariable; - v->setName( name ); - - m_variables.push_back( v ); - - return v; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCalculation::deleteVariable( RimSummaryCalculationVariable* calcVariable ) +RimSummaryCalculationVariable* RimSummaryCalculation::createVariable() const { - m_variables.removeChildObject( calcVariable ); - - delete calcVariable; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -const std::vector& RimSummaryCalculation::values() const -{ - return m_calculatedValues(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -const std::vector& RimSummaryCalculation::timeSteps() const -{ - return m_timesteps(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimSummaryCalculation::setExpression( const QString& expr ) -{ - m_expression = expr; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RimSummaryCalculation::expression() const -{ - return m_expression; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RimSummaryCalculation::unitName() const -{ - return m_unit; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -caf::PdmFieldHandle* RimSummaryCalculation::userDescriptionField() -{ - return &m_description; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RimSummaryCalculation::parseExpression() -{ - QString leftHandSideVariableName = RimSummaryCalculation::findLeftHandSide( m_expression ); - if ( leftHandSideVariableName.isEmpty() ) - { - RiaLogging::errorInMessageBox( nullptr, "Expression Parser", "Failed to detect left hand side of equation" ); - - return false; - } - - std::vector variableNames = ExpressionParser::detectReferencedVariables( m_expression ); - if ( variableNames.size() < 1 ) - { - RiaLogging::errorInMessageBox( nullptr, "Expression Parser", "Failed to detect any variable names" ); - - return false; - } - - // Remove variables not present in expression - { - std::vector toBeDeleted; - for ( RimSummaryCalculationVariable* v : m_variables ) - { - if ( std::find( variableNames.begin(), variableNames.end(), v->name() ) == variableNames.end() ) - { - toBeDeleted.push_back( v ); - } - - if ( leftHandSideVariableName == v->name() ) - { - toBeDeleted.push_back( v ); - } - } - - for ( RimSummaryCalculationVariable* v : toBeDeleted ) - { - deleteVariable( v ); - } - } - - for ( auto variableName : variableNames ) - { - if ( leftHandSideVariableName != variableName ) - { - if ( !findByName( variableName ) ) - { - this->addVariable( variableName ); - } - } - } - - m_description = buildCalculationName(); - - return true; + return new RimSummaryCalculationVariable; } //-------------------------------------------------------------------------------------------------- @@ -259,7 +70,8 @@ bool RimSummaryCalculation::calculate() for ( size_t i = 0; i < m_variables.size(); i++ ) { - RimSummaryCalculationVariable* v = m_variables[i]; + RimSummaryCalculationVariable* v = dynamic_cast( m_variables[i] ); + CAF_ASSERT( v != nullptr ); if ( !v->summaryCase() ) { @@ -297,7 +109,8 @@ bool RimSummaryCalculation::calculate() ExpressionParser parser; for ( size_t i = 0; i < m_variables.size(); i++ ) { - RimSummaryCalculationVariable* v = m_variables[i]; + RimSummaryCalculationVariable* v = dynamic_cast( m_variables[i] ); + CAF_ASSERT( v != nullptr ); parser.assignVector( v->name(), timeHistoryCurveMerger.interpolatedYValuesForAllXValues( i ) ); } @@ -346,153 +159,36 @@ bool RimSummaryCalculation::calculate() return evaluatedOk; } -//-------------------------------------------------------------------------------------------------- -/// Find the last assignment using := and interpret the text before the := as LHS -//-------------------------------------------------------------------------------------------------- -QString RimSummaryCalculation::findLeftHandSide( const QString& expression ) -{ - int index = expression.lastIndexOf( ":=" ); - if ( index > 0 ) - { - QString s = expression.left( index ).simplified(); - - QStringList words = s.split( " " ); - - if ( words.size() > 0 ) - { - return words.back(); - } - } - - return ""; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCalculation::attachToWidget() -{ - for ( auto e : m_expression.uiCapability()->connectedEditors() ) - { - caf::PdmUiTextEditor* textEditor = dynamic_cast( e ); - if ( !textEditor ) continue; - - QWidget* containerWidget = textEditor->editorWidget(); - if ( !containerWidget ) continue; - - for ( auto qObj : containerWidget->children() ) - { - QTextEdit* textEdit = dynamic_cast( qObj ); - if ( textEdit ) - { - m_exprContextMenuMgr->attachTextEdit( textEdit ); - } - } - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimSummaryCalculation::fieldChangedByUi( const caf::PdmFieldHandle* changedField, - const QVariant& oldValue, - const QVariant& newValue ) -{ - m_isDirty = true; - - PdmObject::fieldChangedByUi( changedField, oldValue, newValue ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimSummaryCalculationVariable* RimSummaryCalculation::findByName( const QString& name ) const -{ - for ( RimSummaryCalculationVariable* v : m_variables ) - { - if ( v->name() == name ) - { - return v; - } - } - - return nullptr; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RimSummaryCalculation::buildCalculationName() const -{ - QString name = "Default Calculation Name"; - - QString lhs = RimSummaryCalculation::findLeftHandSide( m_expression ); - if ( !lhs.isEmpty() ) - { - name = lhs; - - name += " ( "; - - for ( RimSummaryCalculationVariable* v : m_variables ) - { - name += v->summaryAddressDisplayString(); - - if ( v != m_variables[m_variables.size() - 1] ) - { - name += ", "; - } - } - - name += " )"; - } - - return name; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimSummaryCalculation::defineEditorAttribute( const caf::PdmFieldHandle* field, - QString uiConfigName, - caf::PdmUiEditorAttribute* attribute ) -{ - if ( field == &m_expression ) - { - caf::PdmUiTextEditorAttribute* myAttr = dynamic_cast( attribute ); - if ( myAttr ) - { - myAttr->heightHint = -1; - } - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimSummaryCalculation::updateDependentCurvesAndPlots() +void RimSummaryCalculation::updateDependentObjects() { RimSummaryCalculationCollection* calcColl = nullptr; this->firstAncestorOrThisOfTypeAsserted( calcColl ); calcColl->rebuildCaseMetaData(); - RimSummaryPlotCollection* summaryPlotCollection = RiaSummaryTools::summaryPlotCollection(); - for ( RimSummaryPlot* sumPlot : summaryPlotCollection->plots() ) + RimSummaryMultiPlotCollection* summaryPlotCollection = RiaSummaryTools::summaryMultiPlotCollection(); + for ( auto multiPlot : summaryPlotCollection->multiPlots() ) { - bool plotContainsCalculatedCurves = false; - - for ( RimSummaryCurve* sumCurve : sumPlot->summaryCurves() ) + for ( RimSummaryPlot* sumPlot : multiPlot->summaryPlots() ) { - if ( sumCurve->summaryAddressY().category() == RifEclipseSummaryAddress::SUMMARY_CALCULATED ) + bool plotContainsCalculatedCurves = false; + + for ( RimSummaryCurve* sumCurve : sumPlot->summaryCurves() ) { - sumCurve->updateConnectedEditors(); + if ( sumCurve->summaryAddressY().category() == RifEclipseSummaryAddress::SUMMARY_CALCULATED ) + { + sumCurve->updateConnectedEditors(); - plotContainsCalculatedCurves = true; + plotContainsCalculatedCurves = true; + } } - } - if ( plotContainsCalculatedCurves ) - { - sumPlot->loadDataAndUpdate(); + if ( plotContainsCalculatedCurves ) + { + sumPlot->loadDataAndUpdate(); + } } } } @@ -500,11 +196,6 @@ void RimSummaryCalculation::updateDependentCurvesAndPlots() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimSummaryCalculation::allVariables() const +void RimSummaryCalculation::removeDependentObjects() { - std::vector outVariables; - for ( RimSummaryCalculationVariable* v : m_variables ) - outVariables.push_back( v ); - - return outVariables; } diff --git a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculation.h b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculation.h index ee560a3fee..5869fc5087 100644 --- a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculation.h +++ b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculation.h @@ -18,79 +18,24 @@ #pragma once -#include "RiuExpressionContextMenuManager.h" -#include "cafPdmChildArrayField.h" -#include "cafPdmField.h" -#include "cafPdmObject.h" -#include -#include - -class RimSummaryCalculationVariable; -class QTextEdit; +#include "RimSummaryCalculationVariable.h" +#include "RimUserDefinedCalculation.h" //================================================================================================== /// /// //================================================================================================== -class RimSummaryCalculation : public caf::PdmObject +class RimSummaryCalculation : public RimUserDefinedCalculation { CAF_PDM_HEADER_INIT; public: RimSummaryCalculation(); - void setDescription( const QString& description ); - QString description() const; - - void setId( int id ); - int id() const; - - bool isDirty() const; - - caf::PdmChildArrayFieldHandle* variables(); - - std::vector allVariables() const; - - const std::vector& values() const; - const std::vector& timeSteps() const; - - void setExpression( const QString& expr ); - QString expression() const; - QString unitName() const; - - bool parseExpression(); - bool calculate(); - void updateDependentCurvesAndPlots(); - - caf::PdmFieldHandle* userDescriptionField() override; - - static QString findLeftHandSide( const QString& expression ); - void attachToWidget(); - -private: - void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - - void defineEditorAttribute( const caf::PdmFieldHandle* field, - QString uiConfigName, - caf::PdmUiEditorAttribute* attribute ) override; - RimSummaryCalculationVariable* findByName( const QString& name ) const; - RimSummaryCalculationVariable* addVariable( const QString& name ); - void deleteVariable( RimSummaryCalculationVariable* calcVariable ); - - QString buildCalculationName() const; - -private: - caf::PdmField m_description; - caf::PdmField m_expression; - caf::PdmField m_unit; - - caf::PdmChildArrayField m_variables; - - caf::PdmField> m_calculatedValues; - caf::PdmField> m_timesteps; - caf::PdmField m_id; - - std::unique_ptr m_exprContextMenuMgr; + bool calculate() override; + void updateDependentObjects() override; + void removeDependentObjects() override; - bool m_isDirty; +protected: + RimSummaryCalculationVariable* createVariable() const override; }; diff --git a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationCollection.cpp index 9eea83a04d..d1e87b98a5 100644 --- a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationCollection.cpp @@ -31,12 +31,9 @@ CAF_PDM_SOURCE_INIT( RimSummaryCalculationCollection, "RimSummaryCalculationColl //-------------------------------------------------------------------------------------------------- RimSummaryCalculationCollection::RimSummaryCalculationCollection() { - CAF_PDM_InitObject( "Calculation Collection", ":/chain.png", "", "" ); + CAF_PDM_InitObject( "Calculation Collection", ":/chain.png" ); - CAF_PDM_InitFieldNoDefault( &m_calculations, "Calculations", "Calculations", "", "", "" ); - m_calculations.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); - - CAF_PDM_InitFieldNoDefault( &m_calcuationSummaryCase, "CalculationsSummaryCase", "Calculations Summary Case", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_calcuationSummaryCase, "CalculationsSummaryCase", "Calculations Summary Case" ); m_calcuationSummaryCase.xmlCapability()->disableIO(); m_calcuationSummaryCase = new RimCalculatedSummaryCase; } @@ -44,95 +41,9 @@ RimSummaryCalculationCollection::RimSummaryCalculationCollection() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryCalculation* RimSummaryCalculationCollection::addCalculation() -{ - RimSummaryCalculation* calculation = new RimSummaryCalculation; - RimProject::current()->assignCalculationIdToCalculation( calculation ); - - QString varName = QString( "Calculation_%1" ).arg( calculation->id() ); - calculation->setDescription( varName ); - calculation->setExpression( varName + " := x + y" ); - calculation->parseExpression(); - - m_calculations.push_back( calculation ); - - rebuildCaseMetaData(); - - return calculation; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimSummaryCalculation* RimSummaryCalculationCollection::addCalculationCopy( const RimSummaryCalculation* sourceCalculation ) -{ - RimSummaryCalculation* calcCopy = dynamic_cast( - sourceCalculation->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); - CVF_ASSERT( calcCopy ); - - std::set calcNames; - for ( const auto& calc : m_calculations ) - { - calcNames.insert( calc->findLeftHandSide( calc->expression() ) ); - } - - QString expression = calcCopy->expression(); - QString currVarName = calcCopy->findLeftHandSide( expression ); - - QString newVarName = currVarName; - while ( calcNames.count( newVarName ) > 0 ) - { - newVarName += "_copy"; - } - - expression.replace( currVarName, newVarName ); - calcCopy->setExpression( expression ); - - RimProject::current()->assignCalculationIdToCalculation( calcCopy ); - - m_calculations.push_back( calcCopy ); - - calcCopy->resolveReferencesRecursively(); - rebuildCaseMetaData(); - calcCopy->parseExpression(); - - return calcCopy; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimSummaryCalculationCollection::deleteCalculation( RimSummaryCalculation* calculation ) -{ - m_calculations.removeChildObject( calculation ); - - rebuildCaseMetaData(); - - delete calculation; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RimSummaryCalculationCollection::calculations() const -{ - return m_calculations.childObjects(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimSummaryCalculation* RimSummaryCalculationCollection::findCalculationById( int id ) const +RimSummaryCalculation* RimSummaryCalculationCollection::createCalculation() const { - for ( RimSummaryCalculation* calc : m_calculations ) - { - if ( calc->id() == id ) - { - return calc; - } - } - - return nullptr; + return new RimSummaryCalculation; } //-------------------------------------------------------------------------------------------------- @@ -143,29 +54,12 @@ RimSummaryCase* RimSummaryCalculationCollection::calculationSummaryCase() return m_calcuationSummaryCase(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimSummaryCalculationCollection::deleteAllContainedObjects() -{ - m_calculations.deleteAllChildObjects(); - - rebuildCaseMetaData(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimSummaryCalculationCollection::rebuildCaseMetaData() { - for ( RimSummaryCalculation* calculation : m_calculations ) - { - if ( calculation->id() == -1 ) - { - RimProject::current()->assignCalculationIdToCalculation( calculation ); - } - } - + ensureValidCalculationIds(); m_calcuationSummaryCase->buildMetaData(); } diff --git a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationCollection.h b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationCollection.h index b6b47baf65..3d245d7ffb 100644 --- a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationCollection.h +++ b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationCollection.h @@ -18,11 +18,13 @@ #pragma once +#include "RimSummaryCalculation.h" +#include "RimUserDefinedCalculationCollection.h" + #include "cafPdmChildArrayField.h" #include "cafPdmChildField.h" #include "cafPdmObject.h" -class RimSummaryCalculation; class RimSummaryCase; class RimCalculatedSummaryCase; @@ -30,28 +32,22 @@ class RimCalculatedSummaryCase; /// /// //================================================================================================== -class RimSummaryCalculationCollection : public caf::PdmObject +class RimSummaryCalculationCollection : public RimUserDefinedCalculationCollection { CAF_PDM_HEADER_INIT; public: RimSummaryCalculationCollection(); - RimSummaryCalculation* addCalculation(); - RimSummaryCalculation* addCalculationCopy( const RimSummaryCalculation* sourceCalculation ); - void deleteCalculation( RimSummaryCalculation* calculation ); - std::vector calculations() const; - RimSummaryCalculation* findCalculationById( int id ) const; - RimSummaryCase* calculationSummaryCase(); - void deleteAllContainedObjects(); - void rebuildCaseMetaData(); + void rebuildCaseMetaData() override; + + RimSummaryCalculation* createCalculation() const override; private: void initAfterRead() override; private: - caf::PdmChildArrayField m_calculations; - caf::PdmChildField m_calcuationSummaryCase; + caf::PdmChildField m_calcuationSummaryCase; }; diff --git a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationVariable.cpp b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationVariable.cpp index 4edc08575e..94583d8be9 100644 --- a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationVariable.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationVariable.cpp @@ -20,6 +20,7 @@ #include "RiaApplication.h" #include "RiaSummaryCurveDefinition.h" +#include "RiaSummaryTools.h" #include "RifEclipseSummaryAddressQMetaType.h" @@ -29,6 +30,7 @@ #include "RimSummaryCase.h" #include "RimSummaryCurve.h" +#include "RiuDragDrop.h" #include "RiuSummaryVectorSelectionDialog.h" #include "cafPdmUiPushButtonEditor.h" @@ -41,42 +43,18 @@ CAF_PDM_SOURCE_INIT( RimSummaryCalculationVariable, "RimSummaryCalculationVariab //-------------------------------------------------------------------------------------------------- RimSummaryCalculationVariable::RimSummaryCalculationVariable() { - CAF_PDM_InitObject( "RimSummaryCalculationVariable", ":/octave.png", "", "" ); + CAF_PDM_InitObject( "RimSummaryCalculationVariable", ":/octave.png" ); - CAF_PDM_InitFieldNoDefault( &m_name, "VariableName", "Variable Name", "", "", "" ); - m_name.uiCapability()->setUiReadOnly( true ); - - CAF_PDM_InitFieldNoDefault( &m_button, "PushButton", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_button, "PushButton", "" ); m_button.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); m_button.xmlCapability()->disableIO(); - CAF_PDM_InitFieldNoDefault( &m_summaryAddressUi, "SummaryAddressUi", "Summary Address", "", "", "" ); - m_summaryAddressUi.registerGetMethod( this, &RimSummaryCalculationVariable::summaryAddressDisplayString ); - m_summaryAddressUi.xmlCapability()->disableIO(); - m_summaryAddressUi.uiCapability()->setUiReadOnly( true ); - - CAF_PDM_InitFieldNoDefault( &m_case, "SummaryCase", "Summary Case", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_summaryAddress, "SummaryAddress", "Summary Address", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_case, "SummaryCase", "Summary Case" ); + CAF_PDM_InitFieldNoDefault( &m_summaryAddress, "SummaryAddress", "Summary Address" ); m_summaryAddress = new RimSummaryAddress; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RimSummaryCalculationVariable::name() const -{ - return m_name; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimSummaryCalculationVariable::setName( const QString& name ) -{ - m_name = name; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -129,7 +107,7 @@ void RimSummaryCalculationVariable::fieldChangedByUi( const caf::PdmFieldHandle* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimSummaryCalculationVariable::summaryAddressDisplayString() const +QString RimSummaryCalculationVariable::displayString() const { QString caseName; if ( m_case() ) caseName = m_case()->displayCaseName(); @@ -153,13 +131,40 @@ RimSummaryAddress* RimSummaryCalculationVariable::summaryAddress() return m_summaryAddress(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCalculationVariable::setSummaryAddress( const RimSummaryAddress& address ) +{ + m_summaryAddress()->setAddress( address.address() ); + + auto summaryCase = RiaSummaryTools::summaryCaseById( address.caseId() ); + + if ( summaryCase ) m_case = summaryCase; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCalculationVariable::handleDroppedMimeData( const QMimeData* data, + Qt::DropAction action, + caf::PdmFieldHandle* destinationField ) +{ + auto objects = RiuDragDrop::convertToObjects( data ); + if ( !objects.empty() ) + { + auto address = dynamic_cast( objects.front() ); + if ( address ) setSummaryAddress( *address ); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimSummaryCalculationVariable::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { uiOrdering.add( &m_name ); - uiOrdering.add( &m_summaryAddressUi ); + uiOrdering.add( &m_addressUi ); uiOrdering.add( &m_button ); uiOrdering.skipRemainingFields(); diff --git a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationVariable.h b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationVariable.h index 4ab6c8c91d..4a72fe8793 100644 --- a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationVariable.h +++ b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationVariable.h @@ -18,13 +18,15 @@ #pragma once +#include "RimUserDefinedCalculationVariable.h" + +#include "cafPdmChildField.h" #include "cafPdmField.h" #include "cafPdmObject.h" #include "cafPdmProxyValueField.h" #include "cafPdmPtrField.h" #include "RifEclipseSummaryAddressQMetaType.h" -#include "cafPdmChildField.h" class RimSummaryCase; class RimSummaryAddress; @@ -34,21 +36,22 @@ class RiuSummaryVectorSelectionDialog; /// /// //================================================================================================== -class RimSummaryCalculationVariable : public caf::PdmObject +class RimSummaryCalculationVariable : public RimUserDefinedCalculationVariable { CAF_PDM_HEADER_INIT; public: RimSummaryCalculationVariable(); - QString name() const; - void setName( const QString& name ); - - QString summaryAddressDisplayString() const; + QString displayString() const override; RimSummaryCase* summaryCase(); RimSummaryAddress* summaryAddress(); + void setSummaryAddress( const RimSummaryAddress& address ); + + void handleDroppedMimeData( const QMimeData* data, Qt::DropAction action, caf::PdmFieldHandle* destinationField ) override; + private: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; @@ -58,9 +61,6 @@ class RimSummaryCalculationVariable : public caf::PdmObject void writeDataToApplicationStore() const; private: - caf::PdmField m_name; - caf::PdmProxyValueField m_summaryAddressUi; - caf::PdmField m_button; caf::PdmPtrField m_case; diff --git a/ApplicationLibCode/ProjectDataModel/RimSurfaceIntersectionBand.cpp b/ApplicationLibCode/ProjectDataModel/RimSurfaceIntersectionBand.cpp index 9aea996cff..8948c55391 100644 --- a/ApplicationLibCode/ProjectDataModel/RimSurfaceIntersectionBand.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimSurfaceIntersectionBand.cpp @@ -44,15 +44,15 @@ caf::PdmFieldHandle* RimSurfaceIntersectionBand::userDescriptionField() RimSurfaceIntersectionBand::RimSurfaceIntersectionBand() : objectChanged( this ) { - CAF_PDM_InitObject( "SurfaceIntersectionBand", ":/ReservoirSurface16x16.png", "", "" ); + CAF_PDM_InitObject( "SurfaceIntersectionBand", ":/ReservoirSurface16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_lineAppearance, "LineAppearance", "Line Appearance", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_lineAppearance, "LineAppearance", "Line Appearance" ); m_lineAppearance = new RimAnnotationLineAppearance; m_lineAppearance->objectChanged.connect( this, &RimSurfaceIntersectionBand::onObjectChanged ); uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitField( &m_bandColor, "BandColor", cvf::Color3f( cvf::Color3f::BLACK ), "Band Color", "", "", "" ); - CAF_PDM_InitField( &m_bandOpacity, "BandOpacity", 0.8, "Band Opacity", "", "", "" ); + CAF_PDM_InitField( &m_bandColor, "BandColor", cvf::Color3f( cvf::Color3f::BLACK ), "Band Color" ); + CAF_PDM_InitField( &m_bandOpacity, "BandOpacity", 0.8, "Band Opacity" ); m_bandOpacity.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); CAF_PDM_InitField( &m_bandPolygonOffsetUnit, @@ -64,10 +64,10 @@ RimSurfaceIntersectionBand::RimSurfaceIntersectionBand() "" ); m_bandPolygonOffsetUnit.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_surfaces, "Surfaces", "Band Surfaces", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_surfaces, "Surfaces", "Band Surfaces" ); m_surfaces.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_nameProxy, "NameProxy", "Name", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_nameProxy, "NameProxy", "Name" ); m_nameProxy.registerGetMethod( this, &RimSurfaceIntersectionBand::objectName ); m_nameProxy.uiCapability()->setUiHidden( true ); @@ -79,7 +79,7 @@ RimSurfaceIntersectionBand::RimSurfaceIntersectionBand() //-------------------------------------------------------------------------------------------------- void RimSurfaceIntersectionBand::setSurfaces( RimSurface* surface1, RimSurface* surface2 ) { - m_surfaces.clear(); + m_surfaces.clearWithoutDelete(); m_surfaces.push_back( surface1 ); m_surfaces.push_back( surface2 ); @@ -197,7 +197,7 @@ void RimSurfaceIntersectionBand::fieldChangedByUi( const caf::PdmFieldHandle* ch /// //-------------------------------------------------------------------------------------------------- QList - RimSurfaceIntersectionBand::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) + RimSurfaceIntersectionBand::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; diff --git a/ApplicationLibCode/ProjectDataModel/RimSurfaceIntersectionBand.h b/ApplicationLibCode/ProjectDataModel/RimSurfaceIntersectionBand.h index ebebb43695..76415e12ef 100644 --- a/ApplicationLibCode/ProjectDataModel/RimSurfaceIntersectionBand.h +++ b/ApplicationLibCode/ProjectDataModel/RimSurfaceIntersectionBand.h @@ -61,8 +61,7 @@ class RimSurfaceIntersectionBand : public RimCheckableObject caf::PdmFieldHandle* userDescriptionField() override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, diff --git a/ApplicationLibCode/ProjectDataModel/RimSurfaceIntersectionCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimSurfaceIntersectionCollection.cpp index a81d302369..259a053e2b 100644 --- a/ApplicationLibCode/ProjectDataModel/RimSurfaceIntersectionCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimSurfaceIntersectionCollection.cpp @@ -29,10 +29,10 @@ CAF_PDM_SOURCE_INIT( RimSurfaceIntersectionCollection, "RimSurfaceIntersectionCo RimSurfaceIntersectionCollection::RimSurfaceIntersectionCollection() : objectChanged( this ) { - CAF_PDM_InitObject( "SurfaceIntersectionCollection_msj", "", "", "" ); + CAF_PDM_InitObject( "SurfaceIntersectionCollection_msj" ); - CAF_PDM_InitFieldNoDefault( &m_intersectionBands, "IntersectionBands", "Intersection Bands", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_intersectionCurves, "IntersectionCurves", "Intersection Curves", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_intersectionBands, "IntersectionBands", "Intersection Bands" ); + CAF_PDM_InitFieldNoDefault( &m_intersectionCurves, "IntersectionCurves", "Intersection Curves" ); } //-------------------------------------------------------------------------------------------------- @@ -64,7 +64,7 @@ RimSurfaceIntersectionBand* RimSurfaceIntersectionCollection::addIntersectionBan //-------------------------------------------------------------------------------------------------- std::vector RimSurfaceIntersectionCollection::surfaceIntersectionCurves() const { - return m_intersectionCurves.childObjects(); + return m_intersectionCurves.children(); } //-------------------------------------------------------------------------------------------------- @@ -72,7 +72,7 @@ std::vector RimSurfaceIntersectionCollection::surf //-------------------------------------------------------------------------------------------------- std::vector RimSurfaceIntersectionCollection::surfaceIntersectionBands() const { - return m_intersectionBands.childObjects(); + return m_intersectionBands.children(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimSurfaceIntersectionCurve.cpp b/ApplicationLibCode/ProjectDataModel/RimSurfaceIntersectionCurve.cpp index b9e9b1db83..826f39d9ca 100644 --- a/ApplicationLibCode/ProjectDataModel/RimSurfaceIntersectionCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimSurfaceIntersectionCurve.cpp @@ -35,17 +35,17 @@ CAF_PDM_SOURCE_INIT( RimSurfaceIntersectionCurve, "RimSurfaceIntersectionCurve" RimSurfaceIntersectionCurve::RimSurfaceIntersectionCurve() : objectChanged( this ) { - CAF_PDM_InitObject( "SurfaceIntersectionCurve", ":/SummaryCurve16x16.png", "", "" ); + CAF_PDM_InitObject( "SurfaceIntersectionCurve", ":/SummaryCurve16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_lineAppearance, "LineAppearance", "Line Appearance", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_lineAppearance, "LineAppearance", "Line Appearance" ); m_lineAppearance = new RimAnnotationLineAppearance; m_lineAppearance->objectChanged.connect( this, &RimSurfaceIntersectionCurve::onObjectChanged ); uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_surface1, "Surface1", "Surface 1", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_surface1, "Surface1", "Surface 1" ); m_surface1.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_nameProxy, "NameProxy", "Name", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_nameProxy, "NameProxy", "Name" ); m_nameProxy.registerGetMethod( this, &RimSurfaceIntersectionCurve::objectName ); m_nameProxy.uiCapability()->setUiHidden( true ); @@ -90,7 +90,7 @@ void RimSurfaceIntersectionCurve::fieldChangedByUi( const caf::PdmFieldHandle* c /// //-------------------------------------------------------------------------------------------------- QList - RimSurfaceIntersectionCurve::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) + RimSurfaceIntersectionCurve::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; diff --git a/ApplicationLibCode/ProjectDataModel/RimSurfaceIntersectionCurve.h b/ApplicationLibCode/ProjectDataModel/RimSurfaceIntersectionCurve.h index a111217845..d8bbbcaabd 100644 --- a/ApplicationLibCode/ProjectDataModel/RimSurfaceIntersectionCurve.h +++ b/ApplicationLibCode/ProjectDataModel/RimSurfaceIntersectionCurve.h @@ -54,8 +54,7 @@ class RimSurfaceIntersectionCurve : public RimCheckableObject caf::PdmFieldHandle* userDescriptionField() override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; diff --git a/ApplicationLibCode/ProjectDataModel/RimTensorResults.cpp b/ApplicationLibCode/ProjectDataModel/RimTensorResults.cpp index b03276b12d..088f09b077 100644 --- a/ApplicationLibCode/ProjectDataModel/RimTensorResults.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimTensorResults.cpp @@ -22,6 +22,7 @@ #include "RimGeoMechCase.h" #include "RimGeoMechResultDefinition.h" #include "RimGeoMechView.h" +#include "RimRegularLegendConfig.h" #include "RigFemPartResultsCollection.h" #include "RigGeoMechCaseData.h" @@ -60,29 +61,29 @@ void AppEnum::setUp() //-------------------------------------------------------------------------------------------------- RimTensorResults::RimTensorResults() { - CAF_PDM_InitObject( "Element Tensor Results", ":/CellResult.png", "", "" ); + CAF_PDM_InitObject( "Element Tensor Results", ":/CellResult.png" ); - CAF_PDM_InitFieldNoDefault( &arrowColorLegendConfig, "LegendDefinition", "Color Legend", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &arrowColorLegendConfig, "LegendDefinition", "Color Legend" ); this->arrowColorLegendConfig = new RimRegularLegendConfig(); arrowColorLegendConfig.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitField( &m_resultFieldName, "ResultVariable", QString( "ST" ), "Value", "", "", "" ); + CAF_PDM_InitField( &m_resultFieldName, "ResultVariable", QString( "ST" ), "Value" ); m_resultFieldName.uiCapability()->setUiHidden( true ); - CAF_PDM_InitField( &m_resultFieldNameUiField, "ResultVariableUI", QString( "ST" ), "Value", "", "", "" ); + CAF_PDM_InitField( &m_resultFieldNameUiField, "ResultVariableUI", QString( "ST" ), "Value" ); m_resultFieldNameUiField.xmlCapability()->disableIO(); - CAF_PDM_InitField( &m_showTensors, "ShowTensors", false, "", "", "", "" ); + CAF_PDM_InitField( &m_showTensors, "ShowTensors", false, "" ); - CAF_PDM_InitField( &m_principal1, "Principal1", true, "Principal 1", "", "", "" ); - CAF_PDM_InitField( &m_principal2, "Principal2", true, "Principal 2", "", "", "" ); - CAF_PDM_InitField( &m_principal3, "Principal3", true, "Principal 3", "", "", "" ); + CAF_PDM_InitField( &m_principal1, "Principal1", true, "Principal 1" ); + CAF_PDM_InitField( &m_principal2, "Principal2", true, "Principal 2" ); + CAF_PDM_InitField( &m_principal3, "Principal3", true, "Principal 3" ); - CAF_PDM_InitField( &m_threshold, "Threshold", 0.0f, "Threshold", "", "", "" ); + CAF_PDM_InitField( &m_threshold, "Threshold", 0.0f, "Threshold" ); - CAF_PDM_InitFieldNoDefault( &m_vectorColor, "VectorColor", "Color", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_scaleMethod, "ScaleMethod", "Scale Method", "", "", "" ); - CAF_PDM_InitField( &m_sizeScale, "SizeScale", 1.0f, "Size Scale", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_vectorColor, "VectorColor", "Color" ); + CAF_PDM_InitFieldNoDefault( &m_scaleMethod, "ScaleMethod", "Scale Method" ); + CAF_PDM_InitField( &m_sizeScale, "SizeScale", 1.0f, "Size Scale" ); CAF_PDM_InitField( &m_rangeMode, "RangeType", RimRegularLegendConfig::RangeModeEnum( RimRegularLegendConfig::RangeModeType::AUTOMATIC_ALLTIMESTEPS ), @@ -289,11 +290,9 @@ caf::PdmFieldHandle* RimTensorResults::objectToggleField() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimTensorResults::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RimTensorResults::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; - *useOptionsOnly = true; if ( fieldNeedingOptions == &m_resultFieldNameUiField ) { diff --git a/ApplicationLibCode/ProjectDataModel/RimTensorResults.h b/ApplicationLibCode/ProjectDataModel/RimTensorResults.h index 8010b8f8c2..ba414b3896 100644 --- a/ApplicationLibCode/ProjectDataModel/RimTensorResults.h +++ b/ApplicationLibCode/ProjectDataModel/RimTensorResults.h @@ -18,13 +18,14 @@ #pragma once +#include "RimLegendConfig.h" + #include "cafPdmChildField.h" #include "cafPdmField.h" #include "cafPdmObject.h" #include "RigFemResultPosEnum.h" #include "RimFemResultObserver.h" -#include "RimRegularLegendConfig.h" #include @@ -84,8 +85,7 @@ class RimTensorResults : public RimFemResultObserver, public caf::PdmObject std::vector getResultMetaDataForUIFieldSetting(); void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; caf::PdmFieldHandle* objectToggleField() override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void initAfterRead() override; void defineEditorAttribute( const caf::PdmFieldHandle* field, @@ -110,7 +110,7 @@ class RimTensorResults : public RimFemResultObserver, public caf::PdmObject caf::PdmField> m_vectorColor; - caf::PdmField> m_scaleMethod; - caf::PdmField m_sizeScale; - caf::PdmField m_rangeMode; + caf::PdmField> m_scaleMethod; + caf::PdmField m_sizeScale; + caf::PdmField m_rangeMode; }; diff --git a/ApplicationLibCode/ProjectDataModel/RimTernaryLegendConfig.cpp b/ApplicationLibCode/ProjectDataModel/RimTernaryLegendConfig.cpp index 029c394caf..9c05d725fe 100644 --- a/ApplicationLibCode/ProjectDataModel/RimTernaryLegendConfig.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimTernaryLegendConfig.cpp @@ -22,6 +22,7 @@ #include "RiaApplication.h" #include "RiaColorTables.h" #include "RiaPreferences.h" +#include "RiaResultNames.h" #include "RimEclipseView.h" #include "RimIntersectionCollection.h" @@ -44,8 +45,8 @@ CAF_PDM_SOURCE_INIT( RimTernaryLegendConfig, "RimTernaryLegendConfig" ); //-------------------------------------------------------------------------------------------------- RimTernaryLegendConfig::RimTernaryLegendConfig() { - CAF_PDM_InitObject( "Ternary Color Legend", ":/Legend.png", "", "" ); - CAF_PDM_InitField( &m_showLegend, "ShowTernaryLegend", true, "Show Ternary Legend", "", "", "" ); + CAF_PDM_InitObject( "Ternary Color Legend", ":/Legend.png" ); + CAF_PDM_InitField( &m_showLegend, "ShowTernaryLegend", true, "Show Ternary Legend" ); m_showLegend.uiCapability()->setUiHidden( true ); CAF_PDM_InitField( &precision, "Precision", @@ -62,19 +63,19 @@ RimTernaryLegendConfig::RimTernaryLegendConfig() "Switches between automatic and user defined range on the legend", "" ); - CAF_PDM_InitFieldNoDefault( &applyLocalMinMax, "m_applyLocalMinMax", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &applyLocalMinMax, "m_applyLocalMinMax", "" ); caf::PdmUiPushButtonEditor::configureEditorForField( &applyLocalMinMax ); applyLocalMinMax = false; - CAF_PDM_InitFieldNoDefault( &applyGlobalMinMax, "m_applyGlobalMinMax", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &applyGlobalMinMax, "m_applyGlobalMinMax", "" ); caf::PdmUiPushButtonEditor::configureEditorForField( &applyGlobalMinMax ); applyGlobalMinMax = false; - CAF_PDM_InitFieldNoDefault( &applyFullRangeMinMax, "m_applyFullRangeMinMax", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &applyFullRangeMinMax, "m_applyFullRangeMinMax", "" ); caf::PdmUiPushButtonEditor::configureEditorForField( &applyFullRangeMinMax ); applyFullRangeMinMax = false; - CAF_PDM_InitFieldNoDefault( &ternaryRangeSummary, "ternaryRangeSummary", "Range summary", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &ternaryRangeSummary, "ternaryRangeSummary", "Range summary" ); ternaryRangeSummary.uiCapability()->setUiEditorTypeName( caf::PdmUiTextEditor::uiEditorTypeName() ); ternaryRangeSummary.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); @@ -301,19 +302,19 @@ void RimTernaryLegendConfig::defineUiOrdering( QString uiConfigName, caf::PdmUiO { caf::PdmUiOrdering* ternaryGroupContainer = uiOrdering.addNewGroup( "Ternary " ); { - caf::PdmUiOrdering* ternaryGroup = ternaryGroupContainer->addNewGroup( "SGAS" ); + caf::PdmUiOrdering* ternaryGroup = ternaryGroupContainer->addNewGroup( RiaResultNames::sgas() ); ternaryGroup->add( &userDefinedMinValueSgas ); ternaryGroup->add( &userDefinedMaxValueSgas ); } { - caf::PdmUiOrdering* ternaryGroup = ternaryGroupContainer->addNewGroup( "SWAT" ); + caf::PdmUiOrdering* ternaryGroup = ternaryGroupContainer->addNewGroup( RiaResultNames::swat() ); ternaryGroup->add( &userDefinedMinValueSwat ); ternaryGroup->add( &userDefinedMaxValueSwat ); } { - caf::PdmUiOrdering* ternaryGroup = ternaryGroupContainer->addNewGroup( "SOIL" ); + caf::PdmUiOrdering* ternaryGroup = ternaryGroupContainer->addNewGroup( RiaResultNames::soil() ); ternaryGroup->add( &userDefinedMinValueSoil ); ternaryGroup->add( &userDefinedMaxValueSoil ); } diff --git a/ApplicationLibCode/ProjectDataModel/RimTimeAxisAnnotation.cpp b/ApplicationLibCode/ProjectDataModel/RimTimeAxisAnnotation.cpp index f63df778d1..dd0fc474d4 100644 --- a/ApplicationLibCode/ProjectDataModel/RimTimeAxisAnnotation.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimTimeAxisAnnotation.cpp @@ -45,7 +45,7 @@ CAF_PDM_SOURCE_INIT( RimTimeAxisAnnotation, "RimTimeAxisAnnotation" ); RimTimeAxisAnnotation::RimTimeAxisAnnotation() : RimPlotAxisAnnotation() { - CAF_PDM_InitObject( "Time Axis Annotation", ":/LeftAxis16x16.png", "", "" ); + CAF_PDM_InitObject( "Time Axis Annotation", ":/LeftAxis16x16.png" ); m_value.uiCapability()->setUiHidden( true ); } @@ -57,12 +57,13 @@ void RimTimeAxisAnnotation::setTime( time_t time ) { m_value = RiaTimeTTools::toDouble( time ); - QString dateFormatString = RiaQDateTimeTools::dateFormatString( RiaPreferences::current()->dateFormat(), - RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH_DAY ); + QString dateFormatString = + RiaQDateTimeTools::dateFormatString( RiaPreferences::current()->dateFormat(), + RiaDefines::DateFormatComponents::DATE_FORMAT_YEAR_MONTH_DAY ); QString timeFormatString = RiaQDateTimeTools::timeFormatString( RiaPreferences::current()->timeFormat(), - RiaQDateTimeTools::TimeFormatComponents::TIME_FORMAT_HOUR_MINUTE ); + RiaDefines::TimeFormatComponents::TIME_FORMAT_HOUR_MINUTE ); QString dateTimeFormatString = QString( "%1 %2" ).arg( dateFormatString ).arg( timeFormatString ); @@ -80,12 +81,13 @@ void RimTimeAxisAnnotation::setTimeRange( time_t startTime, time_t endTime ) m_rangeStart = RiaTimeTTools::toDouble( startTime ); m_rangeEnd = RiaTimeTTools::toDouble( endTime ); - QString dateFormatString = RiaQDateTimeTools::dateFormatString( RiaPreferences::current()->dateFormat(), - RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH_DAY ); + QString dateFormatString = + RiaQDateTimeTools::dateFormatString( RiaPreferences::current()->dateFormat(), + RiaDefines::DateFormatComponents::DATE_FORMAT_YEAR_MONTH_DAY ); QString timeFormatString = RiaQDateTimeTools::timeFormatString( RiaPreferences::current()->timeFormat(), - RiaQDateTimeTools::TimeFormatComponents::TIME_FORMAT_HOUR_MINUTE ); + RiaDefines::TimeFormatComponents::TIME_FORMAT_HOUR_MINUTE ); QString dateTimeFormatString = QString( "%1 %2" ).arg( dateFormatString ).arg( timeFormatString ); diff --git a/ApplicationLibCode/ProjectDataModel/RimTimeStepFilter.cpp b/ApplicationLibCode/ProjectDataModel/RimTimeStepFilter.cpp index de724c9923..a667d6fa1f 100644 --- a/ApplicationLibCode/ProjectDataModel/RimTimeStepFilter.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimTimeStepFilter.cpp @@ -61,30 +61,30 @@ CAF_PDM_SOURCE_INIT( RimTimeStepFilter, "RimTimeStepFilter" ); //-------------------------------------------------------------------------------------------------- RimTimeStepFilter::RimTimeStepFilter() { - CAF_PDM_InitObject( "Time Step Filter", "", "", "" ); + CAF_PDM_InitObject( "Time Step Filter" ); caf::AppEnum filterType = TS_ALL; - CAF_PDM_InitField( &m_filterType, "FilterType", filterType, "Filter Type", "", "", "" ); + CAF_PDM_InitField( &m_filterType, "FilterType", filterType, "Filter Type" ); - CAF_PDM_InitField( &m_firstTimeStep, "FirstTimeStep", 0, "First Time Step", "", "", "" ); - CAF_PDM_InitField( &m_lastTimeStep, "LastTimeStep", 0, "Last Time Step", "", "", "" ); + CAF_PDM_InitField( &m_firstTimeStep, "FirstTimeStep", 0, "First Time Step" ); + CAF_PDM_InitField( &m_lastTimeStep, "LastTimeStep", 0, "Last Time Step" ); - CAF_PDM_InitField( &m_interval, "Interval", 1, "Interval", "", "", "" ); + CAF_PDM_InitField( &m_interval, "Interval", 1, "Interval" ); m_interval.uiCapability()->setUiEditorTypeName( caf::PdmUiLineEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_timeStepNamesFromFile, "TimeStepsFromFile", std::vector(), "TimeSteps From File", "", "", "" ); + CAF_PDM_InitField( &m_timeStepNamesFromFile, "TimeStepsFromFile", std::vector(), "TimeSteps From File" ); m_timeStepNamesFromFile.xmlCapability()->disableIO(); - CAF_PDM_InitField( &m_dateFormat, "DateFormat", QString( "yyyy-MM-dd" ), "Date Format", "", "", "" ); + CAF_PDM_InitField( &m_dateFormat, "DateFormat", QString( "yyyy-MM-dd" ), "Date Format" ); - CAF_PDM_InitFieldNoDefault( &m_filteredTimeSteps, "TimeStepIndicesToImport", "Select From Time Steps", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_filteredTimeSteps, "TimeStepIndicesToImport", "Select From Time Steps" ); m_filteredTimeSteps.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitFieldNoDefault( &m_filteredTimeStepsUi, "TimeStepIndicesUi", "Select From TimeSteps", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_filteredTimeStepsUi, "TimeStepIndicesUi", "Select From TimeSteps" ); m_filteredTimeStepsUi.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); m_filteredTimeStepsUi.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() ); m_filteredTimeStepsUi.xmlCapability()->disableIO(); - CAF_PDM_InitFieldNoDefault( &m_applyReloadOfCase, "ApplyReloadOfCase", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_applyReloadOfCase, "ApplyReloadOfCase", "" ); caf::PdmUiPushButtonEditor::configureEditorForField( &m_applyReloadOfCase ); } @@ -306,8 +306,7 @@ void RimTimeStepFilter::fieldChangedByUi( const caf::PdmFieldHandle* changedFiel //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimTimeStepFilter::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RimTimeStepFilter::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList optionItems; diff --git a/ApplicationLibCode/ProjectDataModel/RimTimeStepFilter.h b/ApplicationLibCode/ProjectDataModel/RimTimeStepFilter.h index 2beb8dcc87..a5612c91a5 100644 --- a/ApplicationLibCode/ProjectDataModel/RimTimeStepFilter.h +++ b/ApplicationLibCode/ProjectDataModel/RimTimeStepFilter.h @@ -73,8 +73,7 @@ class RimTimeStepFilter : public caf::PdmObject // PDM overrides void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; diff --git a/ApplicationLibCode/ProjectDataModel/RimTools.cpp b/ApplicationLibCode/ProjectDataModel/RimTools.cpp index 305aebc686..dffce8d8a3 100644 --- a/ApplicationLibCode/ProjectDataModel/RimTools.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimTools.cpp @@ -125,13 +125,13 @@ QString RimTools::relocateFile( const QString& originalFileName, QFileInfo fileNameFileInfo( QDir::fromNativeSeparators( fileName ) ); QString fileNamePath = fileNameFileInfo.path(); QString fileNameWithoutPath = fileNameFileInfo.fileName(); - QStringList fileNamePathElements = fileNamePath.split( "/", QString::KeepEmptyParts ); + QStringList fileNamePathElements = fileNamePath.split( "/" ); QString oldProjPath = QDir::fromNativeSeparators( oldProjectPath ); - QStringList oldProjPathElements = oldProjPath.split( "/", QString::KeepEmptyParts ); + QStringList oldProjPathElements = oldProjPath.split( "/" ); QString newProjPath = QDir::fromNativeSeparators( newProjectPath ); - QStringList newProjPathElements = newProjPath.split( "/", QString::KeepEmptyParts ); + QStringList newProjPathElements = newProjPath.split( "/" ); // Find the possible equal start of the old project path, and the referenced file diff --git a/ApplicationLibCode/ProjectDataModel/RimUserDefinedCalculation.cpp b/ApplicationLibCode/ProjectDataModel/RimUserDefinedCalculation.cpp new file mode 100644 index 0000000000..ed65791696 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/RimUserDefinedCalculation.cpp @@ -0,0 +1,378 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimUserDefinedCalculation.h" + +#include "expressionparser/ExpressionParser.h" + +#include "RiaLogging.h" + +#include "RimProject.h" +#include "RimUserDefinedCalculationVariable.h" + +#include "RiuExpressionContextMenuManager.h" + +#include "cafPdmUiLineEditor.h" +#include "cafPdmUiTableViewEditor.h" +#include "cafPdmUiTextEditor.h" + +#include + +CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimUserDefinedCalculation, "RimUserDefinedCalculation" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimUserDefinedCalculation::RimUserDefinedCalculation() +{ + CAF_PDM_InitObject( "RimUserDefinedCalculation", ":/octave.png", "Calculation", "" ); + + CAF_PDM_InitFieldNoDefault( &m_description, "Description", "Description" ); + m_description.uiCapability()->setUiReadOnly( true ); + + CAF_PDM_InitField( &m_expression, "Expression", QString( "" ), "Expression" ); + m_expression.uiCapability()->setUiEditorTypeName( caf::PdmUiTextEditor::uiEditorTypeName() ); + + CAF_PDM_InitField( &m_unit, "Unit", QString( "" ), "Unit" ); + m_unit.uiCapability()->setUiEditorTypeName( caf::PdmUiLineEditor::uiEditorTypeName() ); + + CAF_PDM_InitFieldNoDefault( &m_variables, "Variables", "Variables" ); + CAF_PDM_InitFieldNoDefault( &m_calculatedValues, "CalculatedValues", "Calculated Values" ); + + CAF_PDM_InitFieldNoDefault( &m_timesteps, "TimeSteps", "Time Steps" ); + CAF_PDM_InitField( &m_id, "Id", -1, "Id" ); + m_id.uiCapability()->setUiHidden( true ); + + m_exprContextMenuMgr = std::unique_ptr( new RiuExpressionContextMenuManager() ); + + m_isDirty = false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimUserDefinedCalculation::setDescription( const QString& description ) +{ + m_description = description; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimUserDefinedCalculation::description() const +{ + return m_description; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimUserDefinedCalculation::setId( int id ) +{ + m_id = id; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimUserDefinedCalculation::id() const +{ + return m_id; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimUserDefinedCalculation::isDirty() const +{ + return m_isDirty; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmChildArrayFieldHandle* RimUserDefinedCalculation::variables() +{ + return &m_variables; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimUserDefinedCalculationVariable* RimUserDefinedCalculation::addVariable( const QString& name ) +{ + RimUserDefinedCalculationVariable* v = createVariable(); + v->setName( name ); + + m_variables.push_back( v ); + + return v; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimUserDefinedCalculation::deleteVariable( RimUserDefinedCalculationVariable* calcVariable ) +{ + m_variables.removeChild( calcVariable ); + + delete calcVariable; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::vector& RimUserDefinedCalculation::values() const +{ + return m_calculatedValues(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::vector& RimUserDefinedCalculation::timeSteps() const +{ + return m_timesteps(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimUserDefinedCalculation::setExpression( const QString& expr ) +{ + m_expression = expr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimUserDefinedCalculation::expression() const +{ + return m_expression; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimUserDefinedCalculation::unitName() const +{ + return m_unit; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* RimUserDefinedCalculation::userDescriptionField() +{ + return &m_description; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimUserDefinedCalculation::parseExpression() +{ + QString leftHandSideVariableName = RimUserDefinedCalculation::findLeftHandSide( m_expression ); + if ( leftHandSideVariableName.isEmpty() ) + { + RiaLogging::errorInMessageBox( nullptr, "Expression Parser", "Failed to detect left hand side of equation" ); + + return false; + } + + std::vector variableNames = ExpressionParser::detectReferencedVariables( m_expression ); + if ( variableNames.size() < 1 ) + { + RiaLogging::errorInMessageBox( nullptr, "Expression Parser", "Failed to detect any variable names" ); + + return false; + } + + // Remove variables not present in expression + { + std::vector toBeDeleted; + for ( RimUserDefinedCalculationVariable* v : m_variables ) + { + if ( std::find( variableNames.begin(), variableNames.end(), v->name() ) == variableNames.end() ) + { + toBeDeleted.push_back( v ); + } + + if ( leftHandSideVariableName == v->name() ) + { + toBeDeleted.push_back( v ); + } + } + + for ( RimUserDefinedCalculationVariable* v : toBeDeleted ) + { + deleteVariable( v ); + } + } + + for ( auto variableName : variableNames ) + { + if ( leftHandSideVariableName != variableName ) + { + if ( !findByName( variableName ) ) + { + this->addVariable( variableName ); + } + } + } + + m_description = buildCalculationName(); + + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// Find the last assignment using := and interpret the text before the := as LHS +//-------------------------------------------------------------------------------------------------- +QString RimUserDefinedCalculation::findLeftHandSide( const QString& expression ) +{ + int index = expression.lastIndexOf( ":=" ); + if ( index > 0 ) + { + QString s = expression.left( index ).simplified(); + + QStringList words = s.split( " " ); + + if ( words.size() > 0 ) + { + return words.back(); + } + } + + return ""; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimUserDefinedCalculation::attachToWidget() +{ + for ( auto e : m_expression.uiCapability()->connectedEditors() ) + { + caf::PdmUiTextEditor* textEditor = dynamic_cast( e ); + if ( !textEditor ) continue; + + QWidget* containerWidget = textEditor->editorWidget(); + if ( !containerWidget ) continue; + + for ( auto qObj : containerWidget->children() ) + { + QTextEdit* textEdit = dynamic_cast( qObj ); + if ( textEdit ) + { + m_exprContextMenuMgr->attachTextEdit( textEdit ); + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimUserDefinedCalculation::fieldChangedByUi( const caf::PdmFieldHandle* changedField, + const QVariant& oldValue, + const QVariant& newValue ) +{ + m_isDirty = true; + + PdmObject::fieldChangedByUi( changedField, oldValue, newValue ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimUserDefinedCalculationVariable* RimUserDefinedCalculation::findByName( const QString& name ) const +{ + for ( RimUserDefinedCalculationVariable* v : m_variables ) + { + if ( v->name() == name ) + { + return v; + } + } + + return nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimUserDefinedCalculation::buildCalculationName() const +{ + QString name = "Default Calculation Name"; + + QString lhs = RimUserDefinedCalculation::findLeftHandSide( m_expression ); + if ( !lhs.isEmpty() ) + { + name = lhs; + + name += " ( "; + + for ( RimUserDefinedCalculationVariable* v : m_variables ) + { + name += v->displayString(); + + if ( v != m_variables[m_variables.size() - 1] ) + { + name += ", "; + } + } + + name += " )"; + } + + return name; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimUserDefinedCalculation::defineEditorAttribute( const caf::PdmFieldHandle* field, + QString uiConfigName, + caf::PdmUiEditorAttribute* attribute ) +{ + if ( field == &m_expression ) + { + auto* myAttr = dynamic_cast( attribute ); + if ( myAttr ) + { + myAttr->heightHint = -1; + } + } + else if ( field == &m_variables ) + { + auto* myAttr = dynamic_cast( attribute ); + if ( myAttr ) + { + myAttr->enableDropTarget = true; + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimUserDefinedCalculation::allVariables() const +{ + return m_variables.children(); +} diff --git a/ApplicationLibCode/ProjectDataModel/RimUserDefinedCalculation.h b/ApplicationLibCode/ProjectDataModel/RimUserDefinedCalculation.h new file mode 100644 index 0000000000..6fdfc0b864 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/RimUserDefinedCalculation.h @@ -0,0 +1,99 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RiuExpressionContextMenuManager.h" + +#include "cafPdmChildArrayField.h" +#include "cafPdmField.h" +#include "cafPdmObject.h" + +#include + +class RimUserDefinedCalculationVariable; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimUserDefinedCalculation : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimUserDefinedCalculation(); + + void setDescription( const QString& description ); + QString description() const; + + void setId( int id ); + int id() const; + + bool isDirty() const; + + caf::PdmChildArrayFieldHandle* variables(); + + std::vector allVariables() const; + + const std::vector& values() const; + const std::vector& timeSteps() const; + + void setExpression( const QString& expr ); + QString expression() const; + QString unitName() const; + + bool parseExpression(); + virtual bool calculate() = 0; + virtual void updateDependentObjects() = 0; + virtual void removeDependentObjects() = 0; + + caf::PdmFieldHandle* userDescriptionField() override; + + static QString findLeftHandSide( const QString& expression ); + void attachToWidget(); + +protected: + virtual RimUserDefinedCalculationVariable* createVariable() const = 0; + + void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; + + void defineEditorAttribute( const caf::PdmFieldHandle* field, + QString uiConfigName, + caf::PdmUiEditorAttribute* attribute ) override; + RimUserDefinedCalculationVariable* findByName( const QString& name ) const; + RimUserDefinedCalculationVariable* addVariable( const QString& name ); + void deleteVariable( RimUserDefinedCalculationVariable* calcVariable ); + + QString buildCalculationName() const; + +protected: + caf::PdmField m_description; + caf::PdmField m_expression; + caf::PdmField m_unit; + + caf::PdmChildArrayField m_variables; + + caf::PdmField> m_calculatedValues; + caf::PdmField> m_timesteps; + caf::PdmField m_id; + + std::unique_ptr m_exprContextMenuMgr; + + bool m_isDirty; +}; diff --git a/ApplicationLibCode/ProjectDataModel/RimUserDefinedCalculationCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimUserDefinedCalculationCollection.cpp new file mode 100644 index 0000000000..c22ec8a02d --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/RimUserDefinedCalculationCollection.cpp @@ -0,0 +1,173 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimUserDefinedCalculationCollection.h" + +#include "RimCalculatedSummaryCase.h" +#include "RimProject.h" +#include "RimUserDefinedCalculation.h" + +#include "cafPdmUiGroup.h" +#include "cafPdmUiTreeSelectionEditor.h" + +CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimUserDefinedCalculationCollection, "RimUserDefinedCalculationCollection" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimUserDefinedCalculationCollection::RimUserDefinedCalculationCollection() +{ + CAF_PDM_InitObject( "Calculation Collection", ":/chain.png" ); + + CAF_PDM_InitFieldNoDefault( &m_calculations, "Calculations", "Calculations" ); + m_calculations.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimUserDefinedCalculation* RimUserDefinedCalculationCollection::addCalculation() +{ + RimUserDefinedCalculation* calculation = createCalculation(); + assignCalculationIdToCalculation( calculation ); + + QString varName = QString( "Calculation_%1" ).arg( calculation->id() ); + calculation->setDescription( varName ); + calculation->setExpression( varName + " := x + y" ); + calculation->parseExpression(); + + m_calculations.push_back( calculation ); + + rebuildCaseMetaData(); + + return calculation; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimUserDefinedCalculation* + RimUserDefinedCalculationCollection::addCalculationCopy( const RimUserDefinedCalculation* sourceCalculation ) +{ + RimUserDefinedCalculation* calcCopy = dynamic_cast( + sourceCalculation->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); + CVF_ASSERT( calcCopy ); + + std::set calcNames; + for ( const auto& calc : m_calculations ) + { + calcNames.insert( calc->findLeftHandSide( calc->expression() ) ); + } + + QString expression = calcCopy->expression(); + QString currVarName = calcCopy->findLeftHandSide( expression ); + + QString newVarName = currVarName; + while ( calcNames.count( newVarName ) > 0 ) + { + newVarName += "_copy"; + } + + expression.replace( currVarName, newVarName ); + calcCopy->setExpression( expression ); + + assignCalculationIdToCalculation( calcCopy ); + + m_calculations.push_back( calcCopy ); + + calcCopy->resolveReferencesRecursively(); + rebuildCaseMetaData(); + calcCopy->parseExpression(); + + return calcCopy; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimUserDefinedCalculationCollection::deleteCalculation( RimUserDefinedCalculation* calculation ) +{ + calculation->removeDependentObjects(); + m_calculations.removeChild( calculation ); + + rebuildCaseMetaData(); + + delete calculation; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimUserDefinedCalculationCollection::calculations() const +{ + return m_calculations.children(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimUserDefinedCalculation* RimUserDefinedCalculationCollection::findCalculationById( int id ) const +{ + for ( RimUserDefinedCalculation* calc : m_calculations ) + { + if ( calc->id() == id ) + { + return calc; + } + } + + return nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimUserDefinedCalculationCollection::deleteAllContainedObjects() +{ + m_calculations.deleteChildren(); + + rebuildCaseMetaData(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimUserDefinedCalculationCollection::ensureValidCalculationIds() +{ + for ( RimUserDefinedCalculation* calculation : m_calculations ) + { + if ( calculation->id() == -1 ) + { + assignCalculationIdToCalculation( calculation ); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimUserDefinedCalculationCollection::assignCalculationIdToCalculation( RimUserDefinedCalculation* calculation ) const +{ + int nextValidCalculationId = 1; + for ( RimUserDefinedCalculation* existingCalculation : calculations() ) + { + nextValidCalculationId = std::max( nextValidCalculationId, existingCalculation->id() + 1 ); + } + + calculation->setId( nextValidCalculationId++ ); +} diff --git a/ApplicationLibCode/ProjectDataModel/RimUserDefinedCalculationCollection.h b/ApplicationLibCode/ProjectDataModel/RimUserDefinedCalculationCollection.h new file mode 100644 index 0000000000..66698e9f24 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/RimUserDefinedCalculationCollection.h @@ -0,0 +1,56 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafPdmChildArrayField.h" +#include "cafPdmChildField.h" +#include "cafPdmObject.h" + +class RimUserDefinedCalculation; +class RimUserDefinedCase; +class RimCalculatedSummaryCase; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimUserDefinedCalculationCollection : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimUserDefinedCalculationCollection(); + + RimUserDefinedCalculation* addCalculation(); + RimUserDefinedCalculation* addCalculationCopy( const RimUserDefinedCalculation* sourceCalculation ); + void deleteCalculation( RimUserDefinedCalculation* calculation ); + std::vector calculations() const; + RimUserDefinedCalculation* findCalculationById( int id ) const; + + void deleteAllContainedObjects(); + + virtual RimUserDefinedCalculation* createCalculation() const = 0; + virtual void rebuildCaseMetaData() = 0; + + void ensureValidCalculationIds(); + void assignCalculationIdToCalculation( RimUserDefinedCalculation* calculation ) const; + +private: + caf::PdmChildArrayField m_calculations; +}; diff --git a/ApplicationLibCode/ProjectDataModel/RimUserDefinedCalculationVariable.cpp b/ApplicationLibCode/ProjectDataModel/RimUserDefinedCalculationVariable.cpp new file mode 100644 index 0000000000..5c0f3ae545 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/RimUserDefinedCalculationVariable.cpp @@ -0,0 +1,53 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 Statoil 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 "RimUserDefinedCalculationVariable.h" + +CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimUserDefinedCalculationVariable, "RimUserDefinedCalculationVariable" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimUserDefinedCalculationVariable::RimUserDefinedCalculationVariable() +{ + CAF_PDM_InitObject( "RimUserDefinedCalculationVariable", ":/octave.png" ); + + CAF_PDM_InitFieldNoDefault( &m_name, "VariableName", "Variable Name" ); + m_name.uiCapability()->setUiReadOnly( true ); + + CAF_PDM_InitFieldNoDefault( &m_addressUi, "AddressUi", "Address" ); + m_addressUi.registerGetMethod( this, &RimUserDefinedCalculationVariable::displayString ); + m_addressUi.xmlCapability()->disableIO(); + m_addressUi.uiCapability()->setUiReadOnly( true ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimUserDefinedCalculationVariable::name() const +{ + return m_name; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimUserDefinedCalculationVariable::setName( const QString& name ) +{ + m_name = name; +} diff --git a/ApplicationLibCode/ProjectDataModel/RimUserDefinedCalculationVariable.h b/ApplicationLibCode/ProjectDataModel/RimUserDefinedCalculationVariable.h new file mode 100644 index 0000000000..5bd5bf81f2 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/RimUserDefinedCalculationVariable.h @@ -0,0 +1,46 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafPdmField.h" +#include "cafPdmObject.h" +#include "cafPdmProxyValueField.h" + +class RimUserDefinedCase; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimUserDefinedCalculationVariable : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimUserDefinedCalculationVariable(); + + QString name() const; + void setName( const QString& name ); + + virtual QString displayString() const = 0; + +protected: + caf::PdmField m_name; + caf::PdmProxyValueField m_addressUi; +}; diff --git a/ApplicationLibCode/ProjectDataModel/RimVfpPlot.cpp b/ApplicationLibCode/ProjectDataModel/RimVfpPlot.cpp index 224324052c..ccf8afe931 100644 --- a/ApplicationLibCode/ProjectDataModel/RimVfpPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimVfpPlot.cpp @@ -18,6 +18,7 @@ #include "RimVfpPlot.h" +#include "RiaDefines.h" #include "RimVfpDefines.h" #include "RimVfpTableExtractor.h" @@ -25,18 +26,15 @@ #include "RiaEclipseUnitTools.h" #include "RiuContextMenuLauncher.h" -#include "RiuQwtPlotTools.h" +#include "RiuPlotCurve.h" +#include "RiuPlotWidget.h" +#include "RiuQwtPlotCurveDefines.h" #include "RiuQwtPlotWidget.h" +#include "RiuQwtSymbol.h" #include "cafCmdFeatureMenuBuilder.h" #include "cafPdmUiComboBoxEditor.h" -#include "qwt_legend.h" -#include "qwt_legend_label.h" -#include "qwt_plot.h" -#include "qwt_plot_curve.h" -#include "qwt_symbol.h" - #include #include @@ -88,63 +86,57 @@ CAF_PDM_SOURCE_INIT( RimVfpPlot, "VfpPlot" ); RimVfpPlot::RimVfpPlot() { // TODO: add icon - CAF_PDM_InitObject( "VFP Plot", ":/VfpPlot.svg", "", "" ); + CAF_PDM_InitObject( "VFP Plot", ":/VfpPlot.svg" ); - CAF_PDM_InitField( &m_plotTitle, "PlotTitle", QString( "VFP Plot" ), "Plot Title", "", "", "" ); + CAF_PDM_InitField( &m_plotTitle, "PlotTitle", QString( "VFP Plot" ), "Plot Title" ); m_plotTitle.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_filePath, "FilePath", "File Path", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_filePath, "FilePath", "File Path" ); caf::AppEnum defaultTableType = RimVfpDefines::TableType::INJECTION; - CAF_PDM_InitField( &m_tableType, "TableType", defaultTableType, "Table Type", "", "", "" ); + CAF_PDM_InitField( &m_tableType, "TableType", defaultTableType, "Table Type" ); m_tableType.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitField( &m_tableNumber, "TableNumber", -1, "Table Number", "", "", "" ); + CAF_PDM_InitField( &m_tableNumber, "TableNumber", -1, "Table Number" ); m_tableNumber.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitField( &m_referenceDepth, "ReferenceDepth", 0.0, "Reference Depth", "", "", "" ); + CAF_PDM_InitField( &m_referenceDepth, "ReferenceDepth", 0.0, "Reference Depth" ); m_referenceDepth.uiCapability()->setUiReadOnly( true ); caf::AppEnum defaultFlowingPhase = RimVfpDefines::FlowingPhaseType::WATER; - CAF_PDM_InitField( &m_flowingPhase, "FlowingPhase", defaultFlowingPhase, "Flowing Phase", "", "", "" ); + CAF_PDM_InitField( &m_flowingPhase, "FlowingPhase", defaultFlowingPhase, "Flowing Phase" ); m_flowingPhase.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitFieldNoDefault( &m_flowingWaterFraction, "FlowingWaterFraction", "Flowing Water Fraction", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_flowingWaterFraction, "FlowingWaterFraction", "Flowing Water Fraction" ); m_flowingWaterFraction.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitFieldNoDefault( &m_flowingGasFraction, "FlowingGasFraction", "Flowing Gas Fraction", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_flowingGasFraction, "FlowingGasFraction", "Flowing Gas Fraction" ); m_flowingGasFraction.uiCapability()->setUiReadOnly( true ); caf::AppEnum defaultInterpolatedVariable = RimVfpDefines::InterpolatedVariableType::BHP; - CAF_PDM_InitField( &m_interpolatedVariable, - "InterpolatedVariable", - defaultInterpolatedVariable, - "Interpolated Variable", - "", - "", - "" ); + CAF_PDM_InitField( &m_interpolatedVariable, "InterpolatedVariable", defaultInterpolatedVariable, "Interpolated Variable" ); caf::AppEnum defaultPrimaryVariable = RimVfpDefines::ProductionVariableType::LIQUID_FLOW_RATE; - CAF_PDM_InitField( &m_primaryVariable, "PrimaryVariable", defaultPrimaryVariable, "Primary Variable", "", "", "" ); + CAF_PDM_InitField( &m_primaryVariable, "PrimaryVariable", defaultPrimaryVariable, "Primary Variable" ); caf::AppEnum defaultFamilyVariable = RimVfpDefines::ProductionVariableType::THP; - CAF_PDM_InitField( &m_familyVariable, "FamilyVariable", defaultFamilyVariable, "Family Variable", "", "", "" ); + CAF_PDM_InitField( &m_familyVariable, "FamilyVariable", defaultFamilyVariable, "Family Variable" ); - CAF_PDM_InitField( &m_liquidFlowRateIdx, "LiquidFlowRateIdx", 0, "Liquid Flow Rate", "", "", "" ); + CAF_PDM_InitField( &m_liquidFlowRateIdx, "LiquidFlowRateIdx", 0, "Liquid Flow Rate" ); m_liquidFlowRateIdx.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_thpIdx, "THPIdx", 0, "THP", "", "", "" ); + CAF_PDM_InitField( &m_thpIdx, "THPIdx", 0, "THP" ); m_thpIdx.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_articifialLiftQuantityIdx, "ArtificialLiftQuantityIdx", 0, "Artificial Lift Quantity", "", "", "" ); + CAF_PDM_InitField( &m_articifialLiftQuantityIdx, "ArtificialLiftQuantityIdx", 0, "Artificial Lift Quantity" ); m_articifialLiftQuantityIdx.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_waterCutIdx, "WaterCutIdx", 0, "Water Cut", "", "", "" ); + CAF_PDM_InitField( &m_waterCutIdx, "WaterCutIdx", 0, "Water Cut" ); m_waterCutIdx.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_gasLiquidRatioIdx, "GasLiquidRatioIdx", 0, "Gas Liquid Ratio", "", "", "" ); + CAF_PDM_InitField( &m_gasLiquidRatioIdx, "GasLiquidRatioIdx", 0, "Gas Liquid Ratio" ); m_gasLiquidRatioIdx.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); m_showWindow = true; @@ -175,7 +167,7 @@ void RimVfpPlot::setFileName( const QString& filename ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuQwtPlotWidget* RimVfpPlot::viewer() +RiuPlotWidget* RimVfpPlot::plotWidget() { return m_plotWidget; } @@ -220,29 +212,14 @@ void RimVfpPlot::updateLegend() if ( doShowLegend ) { - QwtLegend* legend = new QwtLegend( m_plotWidget ); - m_plotWidget->insertLegend( legend, QwtPlot::BottomLegend ); + m_plotWidget->insertLegend( RiuPlotWidget::Legend::BOTTOM ); } else { - m_plotWidget->insertLegend( nullptr ); + m_plotWidget->clearLegend(); } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimVfpPlot::updateZoomInQwt() -{ -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimVfpPlot::updateZoomFromQwt() -{ -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -334,21 +311,6 @@ void RimVfpPlot::detachAllCurves() { } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -caf::PdmObject* RimVfpPlot::findPdmObjectFromQwtCurve( const QwtPlotCurve* /*curve*/ ) const -{ - return nullptr; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimVfpPlot::onAxisSelected( int /*axis*/, bool /*toggle*/ ) -{ -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -398,7 +360,7 @@ void RimVfpPlot::doRemoveFromCollection() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuQwtPlotWidget* RimVfpPlot::doCreatePlotViewWidget( QWidget* mainWindowParent ) +RiuPlotWidget* RimVfpPlot::doCreatePlotViewWidget( QWidget* mainWindowParent ) { // It seems we risk being called multiple times if ( m_plotWidget ) @@ -407,13 +369,10 @@ RiuQwtPlotWidget* RimVfpPlot::doCreatePlotViewWidget( QWidget* mainWindowParent } { - auto plotWidget = new RiuQwtPlotWidget( this, mainWindowParent ); + RiuPlotWidget* plotWidget = new RiuQwtPlotWidget( this, mainWindowParent ); // Remove event filter to disable unwanted highlighting on left click in plot. - plotWidget->removeEventFilter( plotWidget ); - plotWidget->canvas()->removeEventFilter( plotWidget ); - - RiuQwtPlotTools::setCommonPlotBehaviour( plotWidget ); + plotWidget->removeEventFilter(); caf::CmdFeatureMenuBuilder menuBuilder; menuBuilder << "RicShowPlotDataFeature"; @@ -460,7 +419,7 @@ void RimVfpPlot::onLoadDataAndUpdate() return; } - m_plotWidget->detachItems( QwtPlotItem::Rtti_PlotCurve ); + m_plotWidget->detachItems( RiuPlotWidget::PlotItemType::CURVE ); updateLegend(); @@ -506,8 +465,8 @@ void RimVfpPlot::onLoadDataAndUpdate() m_primaryVariable(), m_familyVariable() ) ); - m_plotWidget->setAxisTitleEnabled( QwtPlot::xBottom, true ); - m_plotWidget->setAxisTitleEnabled( QwtPlot::yLeft, true ); + m_plotWidget->setAxisTitleEnabled( RiuPlotAxis::defaultBottom(), true ); + m_plotWidget->setAxisTitleEnabled( RiuPlotAxis::defaultLeft(), true ); } m_plotWidget->scheduleReplot(); @@ -516,7 +475,7 @@ void RimVfpPlot::onLoadDataAndUpdate() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::populatePlotWidgetWithCurveData( RiuQwtPlotWidget* plotWidget, const Opm::VFPInjTable& table ) +void RimVfpPlot::populatePlotWidgetWithCurveData( RiuPlotWidget* plotWidget, const Opm::VFPInjTable& table ) { VfpPlotData plotData; populatePlotData( table, m_interpolatedVariable(), plotData ); @@ -576,7 +535,7 @@ void RimVfpPlot::populatePlotData( const Opm::VFPInjTable& table //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::populatePlotWidgetWithCurveData( RiuQwtPlotWidget* plotWidget, +void RimVfpPlot::populatePlotWidgetWithCurveData( RiuPlotWidget* plotWidget, const Opm::VFPProdTable& table, RimVfpDefines::ProductionVariableType primaryVariable, RimVfpDefines::ProductionVariableType familyVariable ) @@ -589,25 +548,35 @@ void RimVfpPlot::populatePlotWidgetWithCurveData( RiuQwtPlotWidget* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlot::populatePlotWidgetWithPlotData( RiuQwtPlotWidget* plotWidget, const VfpPlotData& plotData ) +void RimVfpPlot::populatePlotWidgetWithPlotData( RiuPlotWidget* plotWidget, const VfpPlotData& plotData ) { - plotWidget->detachItems( QwtPlotItem::Rtti_PlotCurve ); - plotWidget->setAxisScale( QwtPlot::xBottom, 0, 1 ); - plotWidget->setAxisScale( QwtPlot::yLeft, 0, 1 ); - plotWidget->setAxisAutoScale( QwtPlot::xBottom, true ); - plotWidget->setAxisAutoScale( QwtPlot::yLeft, true ); - plotWidget->setAxisTitleText( QwtPlot::xBottom, plotData.xAxisTitle() ); - plotWidget->setAxisTitleText( QwtPlot::yLeft, plotData.yAxisTitle() ); + plotWidget->detachItems( RiuPlotWidget::PlotItemType::CURVE ); + plotWidget->setAxisScale( RiuPlotAxis::defaultBottom(), 0, 1 ); + plotWidget->setAxisScale( RiuPlotAxis::defaultLeft(), 0, 1 ); + plotWidget->setAxisAutoScale( RiuPlotAxis::defaultBottom(), true ); + plotWidget->setAxisAutoScale( RiuPlotAxis::defaultLeft(), true ); + plotWidget->setAxisTitleText( RiuPlotAxis::defaultBottom(), plotData.xAxisTitle() ); + plotWidget->setAxisTitleText( RiuPlotAxis::defaultLeft(), plotData.yAxisTitle() ); for ( auto idx = 0u; idx < plotData.size(); idx++ ) { QColor qtClr = RiaColorTables::summaryCurveDefaultPaletteColors().cycledQColor( idx ); - QwtPlotCurve* curve = createPlotCurve( plotData.curveTitle( idx ), qtClr ); - curve->setSamples( plotData.xData( idx ).data(), - plotData.yData( idx ).data(), - static_cast( plotData.curveSize( idx ) ) ); - curve->attach( plotWidget ); - curve->show(); + RiuPlotCurve* curve = m_plotWidget->createPlotCurve( nullptr, plotData.curveTitle( idx ), qtClr ); + + curve->setAppearance( RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID, + RiuQwtPlotCurveDefines::CurveInterpolationEnum::INTERPOLATION_POINT_TO_POINT, + 2, + qtClr ); + + RiuPlotCurveSymbol* symbol = curve->createSymbol( RiuPlotCurveSymbol::PointSymbolEnum::SYMBOL_ELLIPSE ); + symbol->setColor( qtClr ); + symbol->setSize( 6, 6 ); + curve->setSymbol( symbol ); + + bool useLogarithmicScale = false; + curve->setSamplesFromXValuesAndYValues( plotData.xData( idx ), plotData.yData( idx ), useLogarithmicScale ); + curve->attachToPlot( plotWidget ); + curve->showInPlot(); } } @@ -693,27 +662,6 @@ void RimVfpPlot::populatePlotData( const Opm::VFPProdTable& table } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QwtPlotCurve* RimVfpPlot::createPlotCurve( const QString title, const QColor& color ) -{ - QwtPlotCurve* curve = new QwtPlotCurve; - curve->setTitle( title ); - curve->setPen( QPen( color, 2 ) ); - curve->setLegendAttribute( QwtPlotCurve::LegendShowLine, true ); - curve->setLegendAttribute( QwtPlotCurve::LegendShowSymbol, true ); - curve->setLegendAttribute( QwtPlotCurve::LegendShowBrush, true ); - curve->setRenderHint( QwtPlotItem::RenderAntialiased, true ); - - QwtSymbol* symbol = new QwtSymbol( QwtSymbol::Ellipse ); - symbol->setSize( 6 ); - symbol->setColor( color ); - curve->setSymbol( symbol ); - - return curve; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -896,10 +844,9 @@ void RimVfpPlot::setFixedVariableUiEditability( caf::PdmField& //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimVfpPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RimVfpPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { - QList options = RimPlot::calculateValueOptions( fieldNeedingOptions, useOptionsOnly ); + QList options = RimPlot::calculateValueOptions( fieldNeedingOptions ); if ( fieldNeedingOptions == &m_liquidFlowRateIdx ) { @@ -1042,7 +989,7 @@ void RimVfpPlot::updatePlotTitle( const QString& plotTitle ) if ( m_plotWidget ) { - m_plotWidget->setTitle( plotTitle ); + m_plotWidget->setPlotTitle( plotTitle ); } } diff --git a/ApplicationLibCode/ProjectDataModel/RimVfpPlot.h b/ApplicationLibCode/ProjectDataModel/RimVfpPlot.h index f73241115c..981623ac0c 100644 --- a/ApplicationLibCode/ProjectDataModel/RimVfpPlot.h +++ b/ApplicationLibCode/ProjectDataModel/RimVfpPlot.h @@ -29,7 +29,7 @@ #include "opm/parser/eclipse/EclipseState/Schedule/VFPInjTable.hpp" #include "opm/parser/eclipse/EclipseState/Schedule/VFPProdTable.hpp" -class RiuQwtPlotWidget; +class RiuPlotWidget; class VfpPlotData; //-------------------------------------------------------------------------------------------------- @@ -46,18 +46,15 @@ class RimVfpPlot : public RimPlot void setFileName( const QString& filename ); // RimPlot implementations - RiuQwtPlotWidget* viewer() override; - void setAutoScaleXEnabled( bool enabled ) override; - void setAutoScaleYEnabled( bool enabled ) override; - void updateAxes() override; - void updateLegend() override; - void updateZoomInQwt() override; - void updateZoomFromQwt() override; - QString asciiDataForPlotExport() const override; - void reattachAllCurves() override; - void detachAllCurves() override; - caf::PdmObject* findPdmObjectFromQwtCurve( const QwtPlotCurve* curve ) const override; - void onAxisSelected( int axis, bool toggle ) override; + RiuPlotWidget* plotWidget() override; + + void setAutoScaleXEnabled( bool enabled ) override; + void setAutoScaleYEnabled( bool enabled ) override; + void updateAxes() override; + void updateLegend() override; + QString asciiDataForPlotExport() const override; + void reattachAllCurves() override; + void detachAllCurves() override; // RimPlotWindow implementations QString description() const override; @@ -79,10 +76,10 @@ class RimVfpPlot : public RimPlot caf::PdmFieldHandle* userDescriptionField() override; private: - RiuQwtPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent ) override; + RiuPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent ) override; - void populatePlotWidgetWithCurveData( RiuQwtPlotWidget* plotWidget, const Opm::VFPInjTable& table ); - void populatePlotWidgetWithCurveData( RiuQwtPlotWidget* plotWidget, + void populatePlotWidgetWithCurveData( RiuPlotWidget* plotWidget, const Opm::VFPInjTable& table ); + void populatePlotWidgetWithCurveData( RiuPlotWidget* plotWidget, const Opm::VFPProdTable& table, RimVfpDefines::ProductionVariableType primaryVariable, RimVfpDefines::ProductionVariableType familyVariable ); @@ -98,8 +95,7 @@ class RimVfpPlot : public RimPlot void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void calculateTableValueOptions( RimVfpDefines::ProductionVariableType variableType, QList& options ); @@ -114,8 +110,7 @@ class RimVfpPlot : public RimPlot RimVfpDefines::ProductionVariableType primaryVariable, RimVfpDefines::ProductionVariableType familyVariable ); - static QwtPlotCurve* createPlotCurve( const QString title, const QColor& color ); - static double convertToDisplayUnit( double value, RimVfpDefines::ProductionVariableType variableType ); + static double convertToDisplayUnit( double value, RimVfpDefines::ProductionVariableType variableType ); static void convertToDisplayUnit( std::vector& values, RimVfpDefines::ProductionVariableType variableType ); static QString getDisplayUnit( RimVfpDefines::ProductionVariableType variableType ); @@ -137,7 +132,7 @@ class RimVfpPlot : public RimPlot RimVfpDefines::InterpolatedVariableType interpolatedVariable, VfpPlotData& plotData ) const; - void populatePlotWidgetWithPlotData( RiuQwtPlotWidget* plotWidget, const VfpPlotData& plotData ); + void populatePlotWidgetWithPlotData( RiuPlotWidget* plotWidget, const VfpPlotData& plotData ); private: caf::PdmField m_plotTitle; @@ -159,7 +154,7 @@ class RimVfpPlot : public RimPlot caf::PdmField m_waterCutIdx; caf::PdmField m_gasLiquidRatioIdx; - QPointer m_plotWidget; + QPointer m_plotWidget; std::unique_ptr m_prodTable; std::unique_ptr m_injectionTable; }; diff --git a/ApplicationLibCode/ProjectDataModel/RimVfpPlotCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimVfpPlotCollection.cpp index aa01154ee4..fbfe6757c6 100644 --- a/ApplicationLibCode/ProjectDataModel/RimVfpPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimVfpPlotCollection.cpp @@ -36,9 +36,9 @@ CAF_PDM_SOURCE_INIT( RimVfpPlotCollection, "RimVfpPlotCollection" ); //-------------------------------------------------------------------------------------------------- RimVfpPlotCollection::RimVfpPlotCollection() { - CAF_PDM_InitObject( "VFP Plots", ":/VfpPlotCollection.svg", "", "" ); + CAF_PDM_InitObject( "VFP Plots", ":/VfpPlotCollection.svg" ); - CAF_PDM_InitFieldNoDefault( &m_vfpPlots, "VfpPlots", "Vertical Flow Performance Plots", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_vfpPlots, "VfpPlots", "Vertical Flow Performance Plots" ); m_vfpPlots.uiCapability()->setUiTreeHidden( true ); } @@ -70,15 +70,15 @@ void RimVfpPlotCollection::insertPlot( RimVfpPlot* vfpPlot, size_t index ) //-------------------------------------------------------------------------------------------------- std::vector RimVfpPlotCollection::plots() const { - return m_vfpPlots.childObjects(); + return m_vfpPlots.children(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimVfpPlotCollection::deleteAllChildObjects() +void RimVfpPlotCollection::deleteChildren() { - m_vfpPlots.deleteAllChildObjects(); + m_vfpPlots.deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -94,6 +94,6 @@ size_t RimVfpPlotCollection::plotCount() const //-------------------------------------------------------------------------------------------------- void RimVfpPlotCollection::removePlot( RimVfpPlot* vfpPlot ) { - m_vfpPlots.removeChildObject( vfpPlot ); + m_vfpPlots.removeChild( vfpPlot ); updateAllRequiredEditors(); } diff --git a/ApplicationLibCode/ProjectDataModel/RimVfpPlotCollection.h b/ApplicationLibCode/ProjectDataModel/RimVfpPlotCollection.h index 61334f224f..b8dda7b337 100644 --- a/ApplicationLibCode/ProjectDataModel/RimVfpPlotCollection.h +++ b/ApplicationLibCode/ProjectDataModel/RimVfpPlotCollection.h @@ -35,9 +35,9 @@ class RimVfpPlotCollection : public caf::PdmObject, public RimTypedPlotCollectio RimVfpPlotCollection(); ~RimVfpPlotCollection() override; - void addPlot( RimVfpPlot* newPlot ); + void addPlot( RimVfpPlot* newPlot ) override; std::vector plots() const override; - void deleteAllChildObjects(); + void deleteChildren(); size_t plotCount() const final; void insertPlot( RimVfpPlot* vfpPlot, size_t index ) final; diff --git a/ApplicationLibCode/ProjectDataModel/RimViewController.cpp b/ApplicationLibCode/ProjectDataModel/RimViewController.cpp index 4706b45617..f9ee4ccda0 100644 --- a/ApplicationLibCode/ProjectDataModel/RimViewController.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimViewController.cpp @@ -62,31 +62,31 @@ RimViewController::RimViewController() { // clang-format off - CAF_PDM_InitObject("View Link", "", "", ""); + CAF_PDM_InitObject("View Link"); - CAF_PDM_InitField(&m_isActive, "Active", true, "Active", "", "", ""); + CAF_PDM_InitField(&m_isActive, "Active", true, "Active"); m_isActive.uiCapability()->setUiHidden(true); QString defaultName = "View Config: Empty view"; - CAF_PDM_InitField(&m_name, "Name", defaultName, "Managed View Name", "", "", ""); + CAF_PDM_InitField(&m_name, "Name", defaultName, "Managed View Name"); m_name.uiCapability()->setUiHidden(true); - CAF_PDM_InitFieldNoDefault(&m_managedView, "ManagedView", "Linked View", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_managedView, "ManagedView", "Linked View"); m_managedView.uiCapability()->setUiTreeChildrenHidden(true); - CAF_PDM_InitField(&m_syncCamera, "SyncCamera", true, "Camera", "", "", ""); - CAF_PDM_InitField(&m_showCursor, "ShowCursor", true, " Show Cursor", "", "", ""); - CAF_PDM_InitField(&m_syncTimeStep, "SyncTimeStep", true, "Time Step", "", "", ""); - CAF_PDM_InitField(&m_syncCellResult, "SyncCellResult", false, "Cell Result", "", "", ""); - CAF_PDM_InitField(&m_syncLegendDefinitions, "SyncLegendDefinitions", true, " Color Legend", "", "", ""); + CAF_PDM_InitField(&m_syncCamera, "SyncCamera", true, "Camera"); + CAF_PDM_InitField(&m_showCursor, "ShowCursor", true, " Show Cursor"); + CAF_PDM_InitField(&m_syncTimeStep, "SyncTimeStep", true, "Time Step"); + CAF_PDM_InitField(&m_syncCellResult, "SyncCellResult", false, "Cell Result"); + CAF_PDM_InitField(&m_syncLegendDefinitions, "SyncLegendDefinitions", true, " Color Legend"); - CAF_PDM_InitField(&m_syncVisibleCells, "SyncVisibleCells", false, "Visible Cells", "", "", ""); + CAF_PDM_InitField(&m_syncVisibleCells, "SyncVisibleCells", false, "Visible Cells"); /// We do not support this. Consider to remove sometime m_syncVisibleCells.uiCapability()->setUiHidden(true); m_syncVisibleCells.xmlCapability()->disableIO(); - CAF_PDM_InitField(&m_syncCellFilters, "SyncRangeFilters", false, "Cell Filters", "", "", ""); - CAF_PDM_InitField(&m_syncPropertyFilters, "SyncPropertyFilters", false,"Property Filters", "", "", ""); + CAF_PDM_InitField(&m_syncCellFilters, "SyncRangeFilters", false, "Cell Filters"); + CAF_PDM_InitField(&m_syncPropertyFilters, "SyncPropertyFilters", false,"Property Filters"); // clang-format on setDeletable( true ); @@ -107,8 +107,7 @@ RimViewController::~RimViewController() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimViewController::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RimViewController::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; diff --git a/ApplicationLibCode/ProjectDataModel/RimViewController.h b/ApplicationLibCode/ProjectDataModel/RimViewController.h index 2008459091..5e65cf8e0f 100644 --- a/ApplicationLibCode/ProjectDataModel/RimViewController.h +++ b/ApplicationLibCode/ProjectDataModel/RimViewController.h @@ -82,8 +82,7 @@ class RimViewController : public caf::PdmObject protected: // Pdm overridden methods void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; diff --git a/ApplicationLibCode/ProjectDataModel/RimViewLinker.cpp b/ApplicationLibCode/ProjectDataModel/RimViewLinker.cpp index 24fe576046..dc31bc5b50 100644 --- a/ApplicationLibCode/ProjectDataModel/RimViewLinker.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimViewLinker.cpp @@ -57,21 +57,21 @@ CAF_PDM_SOURCE_INIT( RimViewLinker, "ViewLinker" ); RimViewLinker::RimViewLinker() { // clang-format off - CAF_PDM_InitObject("Linked Views", "", "", ""); + CAF_PDM_InitObject("Linked Views"); - CAF_PDM_InitField(&m_name, "Name", QString("View Group Name"), "View Group Name", "", "", ""); + CAF_PDM_InitField(&m_name, "Name", QString("View Group Name"), "View Group Name"); m_name.uiCapability()->setUiHidden(true); - CAF_PDM_InitFieldNoDefault(&m_masterView, "MainView", "Main View", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_masterView, "MainView", "Main View"); m_masterView.uiCapability()->setUiTreeChildrenHidden(true); m_masterView.uiCapability()->setUiTreeHidden(true); m_masterView.uiCapability()->setUiHidden(true); - CAF_PDM_InitFieldNoDefault(&m_viewControllers, "ManagedViews", "Managed Views", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_viewControllers, "ManagedViews", "Managed Views"); m_viewControllers.uiCapability()->setUiTreeHidden(true); m_viewControllers.uiCapability()->setUiTreeChildrenHidden(true); - CAF_PDM_InitFieldNoDefault(&m_comparisonView, "LinkedComparisonView", "Comparison View", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_comparisonView, "LinkedComparisonView", "Comparison View"); m_comparisonView.xmlCapability()->disableIO(); // clang-format on @@ -84,7 +84,7 @@ RimViewLinker::~RimViewLinker() { removeOverrides(); - m_viewControllers.deleteAllChildObjects(); + m_viewControllers.deleteChildren(); RimGridView* masterView = m_masterView; m_masterView = nullptr; if ( masterView ) masterView->updateAutoName(); @@ -313,7 +313,7 @@ void RimViewLinker::setMasterView( RimGridView* view ) if ( previousViewController ) { delete previousViewController; - this->m_viewControllers.removeChildObject( nullptr ); + this->m_viewControllers.removeChild( nullptr ); } this->removeOverrides(); @@ -514,8 +514,7 @@ void RimViewLinker::notifyManagedViewChange( RimGridView* oldManagedView, RimGri //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimViewLinker::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RimViewLinker::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; @@ -674,7 +673,7 @@ void RimViewLinker::updatePropertyFilters( RimPropertyFilter* changedPropertyFil //-------------------------------------------------------------------------------------------------- void RimViewLinker::removeViewController( RimViewController* viewController ) { - m_viewControllers.removeChildObject( viewController ); + m_viewControllers.removeChild( viewController ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimViewLinker.h b/ApplicationLibCode/ProjectDataModel/RimViewLinker.h index bd03e069c5..dacd1fc0e8 100644 --- a/ApplicationLibCode/ProjectDataModel/RimViewLinker.h +++ b/ApplicationLibCode/ProjectDataModel/RimViewLinker.h @@ -100,8 +100,7 @@ class RimViewLinker : public caf::PdmObject void initAfterRead() override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; diff --git a/ApplicationLibCode/ProjectDataModel/RimViewLinkerCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimViewLinkerCollection.cpp index 4996ab89ba..fd9f4d2021 100644 --- a/ApplicationLibCode/ProjectDataModel/RimViewLinkerCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimViewLinkerCollection.cpp @@ -31,12 +31,12 @@ CAF_PDM_SOURCE_INIT( RimViewLinkerCollection, "RimViewLinkerCollection" ); //-------------------------------------------------------------------------------------------------- RimViewLinkerCollection::RimViewLinkerCollection( void ) { - CAF_PDM_InitObject( "Linked Views", ":/LinkView16x16.png", "", "" ); + CAF_PDM_InitObject( "Linked Views", ":/LinkView.svg" ); - CAF_PDM_InitField( &isActive, "Active", true, "Active", "", "", "" ); + CAF_PDM_InitField( &isActive, "Active", true, "Active" ); isActive.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &viewLinker, "ViewLinkers", "View Linkers", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &viewLinker, "ViewLinkers", "View Linkers" ); viewLinker.uiCapability()->setUiTreeHidden( true ); } diff --git a/ApplicationLibCode/ProjectDataModel/RimViewNameConfig.cpp b/ApplicationLibCode/ProjectDataModel/RimViewNameConfig.cpp index b3f7378496..3b0b97fae0 100644 --- a/ApplicationLibCode/ProjectDataModel/RimViewNameConfig.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimViewNameConfig.cpp @@ -35,12 +35,12 @@ RimViewNameConfig::RimViewNameConfig() , m_hidePropertyField( false ) , m_hideSampleSpacingField( false ) { - CAF_PDM_InitObject( "View Name Generator", "", "", "" ); + CAF_PDM_InitObject( "View Name Generator" ); - CAF_PDM_InitField( &m_addCaseName, "AddCaseName", false, "Add Case Name", "", "", "" ); - CAF_PDM_InitField( &m_addAggregationType, "AddAggregationType", true, "Add Aggregation Type", "", "", "" ); - CAF_PDM_InitField( &m_addProperty, "AddProperty", true, "Add Property Type", "", "", "" ); - CAF_PDM_InitField( &m_addSampleSpacing, "AddSampleSpacing", false, "Add Sample Spacing", "", "", "" ); + CAF_PDM_InitField( &m_addCaseName, "AddCaseName", false, "Add Case Name" ); + CAF_PDM_InitField( &m_addAggregationType, "AddAggregationType", true, "Add Aggregation Type" ); + CAF_PDM_InitField( &m_addProperty, "AddProperty", true, "Add Property Type" ); + CAF_PDM_InitField( &m_addSampleSpacing, "AddSampleSpacing", false, "Add Sample Spacing" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimViewWindow.cpp b/ApplicationLibCode/ProjectDataModel/RimViewWindow.cpp index d0c05bb239..3740a4444e 100644 --- a/ApplicationLibCode/ProjectDataModel/RimViewWindow.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimViewWindow.cpp @@ -29,6 +29,7 @@ #include "RimMdiWindowController.h" #include "RimProject.h" +#include "cafPdmUiTreeAttributes.h" #include "cafPdmUiTreeViewEditor.h" #include @@ -48,16 +49,16 @@ RimViewWindow::RimViewWindow( void ) "ViewWindow", "The Base Class for all Views and Plots in ResInsight" ); - CAF_PDM_InitFieldNoDefault( &m_windowController, "WindowController", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_windowController, "WindowController", "" ); m_windowController.uiCapability()->setUiTreeHidden( true ); m_windowController.uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitField( &m_showWindow, "ShowWindow", true, "Show Window", "", "", "" ); + CAF_PDM_InitField( &m_showWindow, "ShowWindow", true, "Show Window" ); m_showWindow.uiCapability()->setUiHidden( true ); // Obsolete field - CAF_PDM_InitFieldNoDefault( &obsoleteField_windowGeometry, "WindowGeometry", "", "", "", "" ); - RiaFieldhandleTools::disableWriteAndSetFieldHidden( &obsoleteField_windowGeometry ); + CAF_PDM_InitFieldNoDefault( &obsoleteField_windowGeometry, "WindowGeometry", "" ); + RiaFieldHandleTools::disableWriteAndSetFieldHidden( &obsoleteField_windowGeometry ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimVirtualPerforationResults.cpp b/ApplicationLibCode/ProjectDataModel/RimVirtualPerforationResults.cpp index b1f4499e98..c4209905ff 100644 --- a/ApplicationLibCode/ProjectDataModel/RimVirtualPerforationResults.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimVirtualPerforationResults.cpp @@ -29,13 +29,13 @@ CAF_PDM_SOURCE_INIT( RimVirtualPerforationResults, "RimVirtualPerforationResults //-------------------------------------------------------------------------------------------------- RimVirtualPerforationResults::RimVirtualPerforationResults() { - CAF_PDM_InitObject( "Well Connection Factors", ":/WellCF16x16.png", "", "" ); + CAF_PDM_InitObject( "Well Connection Factors", ":/WellCF16x16.png" ); - CAF_PDM_InitField( &m_isActive, "ShowConnectionFactors", false, "", "", "", "" ); - CAF_PDM_InitField( &m_showClosedConnections, "ShowClosedConnections", true, "Show On Closed Connections", "", "", "" ); - CAF_PDM_InitField( &m_geometryScaleFactor, "GeometryScaleFactor", 2.0, "Geometry Scale Factor", "", "", "" ); + CAF_PDM_InitField( &m_isActive, "ShowConnectionFactors", false, "" ); + CAF_PDM_InitField( &m_showClosedConnections, "ShowClosedConnections", true, "Show On Closed Connections" ); + CAF_PDM_InitField( &m_geometryScaleFactor, "GeometryScaleFactor", 2.0, "Geometry Scale Factor" ); - CAF_PDM_InitFieldNoDefault( &m_legendConfig, "LegendDefinition", "Color Legend", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_legendConfig, "LegendDefinition", "Color Legend" ); m_legendConfig.uiCapability()->setUiTreeHidden( true ); m_legendConfig = new RimRegularLegendConfig(); diff --git a/ApplicationLibCode/ProjectDataModel/RimWbsParameters.cpp b/ApplicationLibCode/ProjectDataModel/RimWbsParameters.cpp index c3d5097ef1..843ad0a902 100644 --- a/ApplicationLibCode/ProjectDataModel/RimWbsParameters.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimWbsParameters.cpp @@ -35,7 +35,7 @@ CAF_PDM_SOURCE_INIT( RimWbsParameters, "WbsParameters" ); //-------------------------------------------------------------------------------------------------- RimWbsParameters::RimWbsParameters() { - CAF_PDM_InitScriptableObject( "Well Bore Stability Parameters", ":/WellLogPlot16x16.png", "", "" ); + CAF_PDM_InitScriptableObject( "Well Bore Stability Parameters", ":/WellLogPlot16x16.png" ); CAF_PDM_InitScriptableFieldNoDefault( &m_porePressureSource, "PorePressureReservoirSource", @@ -50,7 +50,7 @@ RimWbsParameters::RimWbsParameters() "", "Data source for Non-Reservoir Pore Pressure", "" ); - CAF_PDM_InitScriptableField( &m_userDefinedPPShale, "UserPPNonReservoir", 1.0, " Multiplier of hydrostatic PP", "", "", "" ); + CAF_PDM_InitScriptableField( &m_userDefinedPPShale, "UserPPNonReservoir", 1.0, " Multiplier of hydrostatic PP" ); CAF_PDM_InitScriptableFieldNoDefault( &m_poissonRatioSource, "PoissionRatioSource", @@ -88,7 +88,7 @@ RimWbsParameters::RimWbsParameters() "(SH - PP)/(OBG-PP)", "" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_FGShaleSource, "FGShaleSource", "FG in Shale Calculation", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_FGShaleSource, "FGShaleSource", "FG in Shale Calculation" ); CAF_PDM_InitScriptableFieldNoDefault( &m_K0FGSource, "K0FGSource", "K0_FG", @@ -96,7 +96,7 @@ RimWbsParameters::RimWbsParameters() "FG in shale = K0_FG * (OBG0-PP0)\nK0_FG = (FG-PP)/(OBG-PP)", "" ); - CAF_PDM_InitFieldNoDefault( &m_waterDensitySource, "WaterDensitySource", "Water Density", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_waterDensitySource, "WaterDensitySource", "Water Density" ); m_waterDensitySource.uiCapability()->setUiHidden( true ); CAF_PDM_InitScriptableField( &m_userDefinedPoissionRatio, @@ -111,8 +111,8 @@ RimWbsParameters::RimWbsParameters() CAF_PDM_InitScriptableField( &m_userDefinedUcs, "UserUcs", 100.0, "User Defined UCS [bar]", "", "User Defined UCS [bar]", "" ); CAF_PDM_InitScriptableField( &m_userDefinedDF, "UserDF", 0.7, "User Defined DF", "", "User Defined Depletion Factor", "" ); - CAF_PDM_InitScriptableField( &m_userDefinedK0FG, "UserK0FG", 0.75, "User Defined K0_FG", "", "", "" ); - CAF_PDM_InitScriptableField( &m_userDefinedK0SH, "UserK0SH", 0.65, "User Defined K0_SH", "", "", "" ); + CAF_PDM_InitScriptableField( &m_userDefinedK0FG, "UserK0FG", 0.75, "User Defined K0_FG" ); + CAF_PDM_InitScriptableField( &m_userDefinedK0SH, "UserK0SH", 0.65, "User Defined K0_SH" ); CAF_PDM_InitScriptableField( &m_FGShaleMultiplier, "FGMultiplier", 1.05, @@ -129,11 +129,11 @@ RimWbsParameters::RimWbsParameters() "Units: g/cm^3", "" ); - CAF_PDM_InitFieldNoDefault( &m_geoMechCase, "GeoMechCase", "GeoMechCase", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_geoMechCase, "GeoMechCase", "GeoMechCase" ); m_geoMechCase.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_wellPath, "WellPath", "WellPath", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wellPath, "WellPath", "WellPath" ); m_wellPath.uiCapability()->setUiHidden( true ); - CAF_PDM_InitField( &m_timeStep, "TimeStep", -1, "TimeStep", "", "", "" ); + CAF_PDM_InitField( &m_timeStep, "TimeStep", -1, "TimeStep" ); m_timeStep.uiCapability()->setUiHidden( true ); m_parameterSourceFields = { { RigWbsParameter::PP_Reservoir(), &m_porePressureSource }, @@ -311,8 +311,7 @@ caf::PdmField* RimWbsParameters::sourceFi //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimWbsParameters::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RimWbsParameters::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; diff --git a/ApplicationLibCode/ProjectDataModel/RimWbsParameters.h b/ApplicationLibCode/ProjectDataModel/RimWbsParameters.h index 08e2e612a0..d3df743bf2 100644 --- a/ApplicationLibCode/ProjectDataModel/RimWbsParameters.h +++ b/ApplicationLibCode/ProjectDataModel/RimWbsParameters.h @@ -58,8 +58,7 @@ class RimWbsParameters : public caf::PdmObject caf::PdmField* sourceField( const RigWbsParameter& parameter ) const; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void loadDataAndUpdate(); diff --git a/ApplicationLibCode/ProjectDataModel/RimWellBoreStabilityPlot.cpp b/ApplicationLibCode/ProjectDataModel/RimWellBoreStabilityPlot.cpp index 9bbc76faed..7b43a813c1 100644 --- a/ApplicationLibCode/ProjectDataModel/RimWellBoreStabilityPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimWellBoreStabilityPlot.cpp @@ -52,10 +52,7 @@ RimWellBoreStabilityPlot::RimWellBoreStabilityPlot() CAF_PDM_InitScriptableFieldWithScriptKeywordNoDefault( &m_wbsParameters, "WbsParameters", "Parameters", - "Well Bore Stability Parameters", - "", - "", - "" ); + "Well Bore Stability Parameters" ); m_wbsParameters = new RimWbsParameters; m_wbsParameters.uiCapability()->setUiTreeHidden( true ); m_wbsParameters.uiCapability()->setUiTreeChildrenHidden( true ); diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimElasticProperties.cpp b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimElasticProperties.cpp index 7c4699e2b7..f465226a80 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimElasticProperties.cpp +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimElasticProperties.cpp @@ -36,21 +36,21 @@ CAF_PDM_SOURCE_INIT( RimElasticProperties, "ElasticProperties" ); RimElasticProperties::RimElasticProperties() : changed( this ) { - CAF_PDM_InitScriptableObject( "RimElasticProperties", "", "", "" ); + CAF_PDM_InitScriptableObject( "RimElasticProperties" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_filePath, "FilePath", "File Path", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_filePath, "FilePath", "File Path" ); m_filePath.uiCapability()->setUiReadOnly( true ); m_filePath.uiCapability()->setUiEditorTypeName( caf::PdmUiLineEditor::uiEditorTypeName() ); - CAF_PDM_InitScriptableFieldNoDefault( &m_propertiesTable, "PropertiesTable", "Properties Table", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_propertiesTable, "PropertiesTable", "Properties Table" ); m_propertiesTable.uiCapability()->setUiEditorTypeName( caf::PdmUiTextEditor::uiEditorTypeName() ); m_propertiesTable.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); m_propertiesTable.uiCapability()->setUiReadOnly( true ); m_propertiesTable.xmlCapability()->disableIO(); - CAF_PDM_InitScriptableField( &m_showScaledProperties, "ShowScaledProperties", true, "Show Scaled Properties", "", "", "" ); + CAF_PDM_InitScriptableField( &m_showScaledProperties, "ShowScaledProperties", true, "Show Scaled Properties" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_scalings, "PropertyScalingCollection", "PropertyScalingCollection", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_scalings, "PropertyScalingCollection", "PropertyScalingCollection" ); m_scalings.uiCapability()->setUiTreeHidden( true ); m_scalings = new RimElasticPropertyScalingCollection; m_scalings->changed.connect( this, &RimElasticProperties::elasticPropertyScalingCollectionChanged ); diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimElasticPropertyScaling.cpp b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimElasticPropertyScaling.cpp index ffcca93033..d24692fc93 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimElasticPropertyScaling.cpp +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimElasticPropertyScaling.cpp @@ -40,13 +40,13 @@ CAF_PDM_SOURCE_INIT( RimElasticPropertyScaling, "ElasticPropertyScaling" ); RimElasticPropertyScaling::RimElasticPropertyScaling() : changed( this ) { - CAF_PDM_InitScriptableObject( "ElasticPropertyScaling", "", "", "" ); + CAF_PDM_InitScriptableObject( "ElasticPropertyScaling" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_formation, "Formation", "Formation", "", "", "" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_facies, "Facies", "Facies", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_formation, "Formation", "Formation" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_facies, "Facies", "Facies" ); caf::AppEnum defaultProperty = RiaDefines::CurveProperty::YOUNGS_MODULUS; - CAF_PDM_InitScriptableField( &m_property, "Property", defaultProperty, "Property", "", "", "" ); - CAF_PDM_InitScriptableField( &m_scale, "Scale", 1.0, "Scale", "", "", "" ); + CAF_PDM_InitScriptableField( &m_property, "Property", defaultProperty, "Property" ); + CAF_PDM_InitScriptableField( &m_scale, "Scale", 1.0, "Scale" ); nameField()->uiCapability()->setUiReadOnly( true ); @@ -65,7 +65,7 @@ RimElasticPropertyScaling::~RimElasticPropertyScaling() /// //-------------------------------------------------------------------------------------------------- QList - RimElasticPropertyScaling::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) + RimElasticPropertyScaling::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; if ( fieldNeedingOptions == &m_formation ) @@ -96,8 +96,6 @@ QList } } - if ( useOptionsOnly ) *useOptionsOnly = true; - return options; } diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimElasticPropertyScaling.h b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimElasticPropertyScaling.h index 2d6c5a4a1f..bce621a588 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimElasticPropertyScaling.h +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimElasticPropertyScaling.h @@ -56,8 +56,7 @@ class RimElasticPropertyScaling : public RimCheckableNamedObject caf::Signal<> changed; protected: - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; static RimEclipseCase* getEclipseCase(); diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimElasticPropertyScalingCollection.cpp b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimElasticPropertyScalingCollection.cpp index 0a01f64e6d..0374784fc5 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimElasticPropertyScalingCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimElasticPropertyScalingCollection.cpp @@ -32,14 +32,9 @@ CAF_PDM_SOURCE_INIT( RimElasticPropertyScalingCollection, "ElasticPropertyScalin RimElasticPropertyScalingCollection::RimElasticPropertyScalingCollection() : changed( this ) { - CAF_PDM_InitScriptableObject( "Elastic Property Scalings", "", "", "" ); + CAF_PDM_InitScriptableObject( "Elastic Property Scalings" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_elasticPropertyScalings, - "ElasticPropertyScalings", - "Elastic Property Scalings", - "", - "", - "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_elasticPropertyScalings, "ElasticPropertyScalings", "Elastic Property Scalings" ); m_elasticPropertyScalings.uiCapability()->setUiTreeHidden( true ); } @@ -48,7 +43,7 @@ RimElasticPropertyScalingCollection::RimElasticPropertyScalingCollection() //-------------------------------------------------------------------------------------------------- RimElasticPropertyScalingCollection::~RimElasticPropertyScalingCollection() { - m_elasticPropertyScalings.deleteAllChildObjects(); + m_elasticPropertyScalings.deleteChildren(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimFaciesInitialPressureConfig.cpp b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimFaciesInitialPressureConfig.cpp index 2e509aaed8..c61850f65b 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimFaciesInitialPressureConfig.cpp +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimFaciesInitialPressureConfig.cpp @@ -31,14 +31,14 @@ CAF_PDM_SOURCE_INIT( RimFaciesInitialPressureConfig, "FaciesInitialPressureConfi RimFaciesInitialPressureConfig::RimFaciesInitialPressureConfig() : changed( this ) { - CAF_PDM_InitScriptableObject( "Facies Initial Pressure Config", "", "", "" ); + CAF_PDM_InitScriptableObject( "Facies Initial Pressure Config" ); m_isChecked.uiCapability()->setUiHidden( false ); - CAF_PDM_InitScriptableFieldNoDefault( &m_faciesName, "FaciesName", "Facies", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_faciesName, "FaciesName", "Facies" ); m_faciesName.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitScriptableField( &m_faciesValue, "FaciesValue", -1, "Value", "", "", "" ); + CAF_PDM_InitScriptableField( &m_faciesValue, "FaciesValue", -1, "Value" ); m_faciesValue.uiCapability()->setUiHidden( true ); // Use unicode for delta letter @@ -48,7 +48,7 @@ RimFaciesInitialPressureConfig::RimFaciesInitialPressureConfig() QString deltaPressureFractionString = QString::fromUtf8( "\u0394 Pressure Fraction" ); #endif - CAF_PDM_InitScriptableField( &m_fraction, "Fraction", 0.0, deltaPressureFractionString, "", "", "" ); + CAF_PDM_InitScriptableField( &m_fraction, "Fraction", 0.0, deltaPressureFractionString ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimFaciesProperties.cpp b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimFaciesProperties.cpp index 36aa36aad8..a21cb9e707 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimFaciesProperties.cpp +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimFaciesProperties.cpp @@ -40,25 +40,25 @@ CAF_PDM_SOURCE_INIT( RimFaciesProperties, "FaciesProperties" ); RimFaciesProperties::RimFaciesProperties() : changed( this ) { - CAF_PDM_InitScriptableObject( "RimFaciesProperties", "", "", "" ); + CAF_PDM_InitScriptableObject( "RimFaciesProperties" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_filePath, "FilePath", "File Path", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_filePath, "FilePath", "File Path" ); m_filePath.uiCapability()->setUiReadOnly( true ); m_filePath.uiCapability()->setUiEditorTypeName( caf::PdmUiLineEditor::uiEditorTypeName() ); - CAF_PDM_InitScriptableFieldNoDefault( &m_propertiesTable, "PropertiesTable", "Properties Table", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_propertiesTable, "PropertiesTable", "Properties Table" ); m_propertiesTable.uiCapability()->setUiEditorTypeName( caf::PdmUiTextEditor::uiEditorTypeName() ); m_propertiesTable.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); m_propertiesTable.uiCapability()->setUiReadOnly( true ); m_propertiesTable.xmlCapability()->disableIO(); - CAF_PDM_InitScriptableFieldNoDefault( &m_faciesDefinition, "FaciesDefinition", "", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_faciesDefinition, "FaciesDefinition", "" ); m_faciesDefinition.uiCapability()->setUiTreeHidden( true ); m_faciesDefinition.uiCapability()->setUiTreeChildrenHidden( true ); m_faciesDefinition = new RimEclipseResultDefinition; m_faciesDefinition->findField( "MResultType" )->uiCapability()->setUiName( "Facies Definiton" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_colorLegend, "ColorLegend", "Colors", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_colorLegend, "ColorLegend", "Colors" ); m_colorLegend = RimRegularLegendConfig::mapToColorLegend( RimRegularLegendConfig::ColorRangesType::NORMAL ); setUiName( "Facies Properties" ); @@ -108,8 +108,7 @@ void RimFaciesProperties::clearFaciesCodeNames() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimFaciesProperties::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RimFaciesProperties::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; if ( fieldNeedingOptions == &m_colorLegend ) diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimFaciesProperties.h b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimFaciesProperties.h index 75a29ff728..d92f878664 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimFaciesProperties.h +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimFaciesProperties.h @@ -63,8 +63,7 @@ class RimFaciesProperties : public caf::PdmObject QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; private: diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimNonNetLayers.cpp b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimNonNetLayers.cpp index 2b6f89982a..b36de9ac50 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimNonNetLayers.cpp +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimNonNetLayers.cpp @@ -42,14 +42,14 @@ CAF_PDM_SOURCE_INIT( RimNonNetLayers, "NonNetLayers" ); RimNonNetLayers::RimNonNetLayers() : changed( this ) { - CAF_PDM_InitScriptableObject( "RimNonNetLayers", "", "", "" ); + CAF_PDM_InitScriptableObject( "RimNonNetLayers" ); - CAF_PDM_InitScriptableField( &m_cutOff, "Cutoff", 0.0, "Cutoff", "", "", "" ); + CAF_PDM_InitScriptableField( &m_cutOff, "Cutoff", 0.0, "Cutoff" ); m_cutOff.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); - CAF_PDM_InitScriptableFieldNoDefault( &m_facies, "Facies", "Facies", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_facies, "Facies", "Facies" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_resultDefinition, "FaciesDefinition", "", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_resultDefinition, "FaciesDefinition", "" ); m_resultDefinition.uiCapability()->setUiTreeHidden( true ); m_resultDefinition.uiCapability()->setUiTreeChildrenHidden( true ); m_resultDefinition = new RimEclipseResultDefinition; @@ -70,8 +70,7 @@ RimNonNetLayers::~RimNonNetLayers() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimNonNetLayers::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RimNonNetLayers::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; if ( fieldNeedingOptions == &m_facies ) diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimNonNetLayers.h b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimNonNetLayers.h index 76f0ed2110..d89e7f9842 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimNonNetLayers.h +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimNonNetLayers.h @@ -54,8 +54,7 @@ class RimNonNetLayers : public RimCheckableObject protected: void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimPressureTable.cpp b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimPressureTable.cpp index af8a836048..b2af83afab 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimPressureTable.cpp +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimPressureTable.cpp @@ -34,14 +34,14 @@ CAF_PDM_SOURCE_INIT( RimPressureTable, "PressureTable" ); RimPressureTable::RimPressureTable() : changed( this ) { - CAF_PDM_InitScriptableObject( "Pressure Table", "", "", "" ); + CAF_PDM_InitScriptableObject( "Pressure Table" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_pressureTableItems, "Items", "Pressure Table Items", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_pressureTableItems, "Items", "Pressure Table Items" ); m_pressureTableItems.uiCapability()->setUiEditorTypeName( caf::PdmUiTableViewEditor::uiEditorTypeName() ); m_pressureTableItems.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); m_pressureTableItems.uiCapability()->setCustomContextMenuEnabled( true ); - CAF_PDM_InitScriptableFieldNoDefault( &m_pressureDate, "PressureDate", "Pressure Date", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_pressureDate, "PressureDate", "Pressure Date" ); } //-------------------------------------------------------------------------------------------------- @@ -56,7 +56,7 @@ RimPressureTable::~RimPressureTable() //-------------------------------------------------------------------------------------------------- std::vector RimPressureTable::items() const { - std::vector pressureTableItems = m_pressureTableItems.childObjects(); + std::vector pressureTableItems = m_pressureTableItems.children(); // Sort by depth std::sort( pressureTableItems.begin(), pressureTableItems.end(), []( auto const& a, auto const& b ) { @@ -71,7 +71,7 @@ std::vector RimPressureTable::items() const //-------------------------------------------------------------------------------------------------- void RimPressureTable::insertItem( RimPressureTableItem* insertBefore, RimPressureTableItem* item ) { - size_t index = m_pressureTableItems.index( insertBefore ); + size_t index = m_pressureTableItems.indexOf( insertBefore ); item->changed.connect( this, &RimPressureTable::onTableChanged ); if ( index < m_pressureTableItems.size() ) m_pressureTableItems.insert( index, item ); @@ -86,7 +86,7 @@ void RimPressureTable::insertItem( RimPressureTableItem* insertBefore, RimPressu //-------------------------------------------------------------------------------------------------- void RimPressureTable::deleteItem( RimPressureTableItem* itemToDelete ) { - m_pressureTableItems.removeChildObject( itemToDelete ); + m_pressureTableItems.removeChild( itemToDelete ); delete itemToDelete; onTableChanged(); } @@ -96,7 +96,7 @@ void RimPressureTable::deleteItem( RimPressureTableItem* itemToDelete ) //-------------------------------------------------------------------------------------------------- void RimPressureTable::deleteAllItems() { - m_pressureTableItems.deleteAllChildObjects(); + m_pressureTableItems.deleteChildren(); onTableChanged(); } diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimPressureTableItem.cpp b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimPressureTableItem.cpp index 7b7b3ca71b..4dfaace373 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimPressureTableItem.cpp +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimPressureTableItem.cpp @@ -31,11 +31,11 @@ CAF_PDM_SOURCE_INIT( RimPressureTableItem, "PressureTableItem" ); RimPressureTableItem::RimPressureTableItem() : changed( this ) { - CAF_PDM_InitScriptableObject( "Pressure Table Item", "", "", "" ); + CAF_PDM_InitScriptableObject( "Pressure Table Item" ); - CAF_PDM_InitScriptableField( &m_depth, "Depth", 0.0, "Depth TVDMSL [m]", "", "", "" ); - CAF_PDM_InitScriptableField( &m_initialPressure, "InitialPressure", 0.0, "Initial Pressure [Bar]", "", "", "" ); - CAF_PDM_InitScriptableField( &m_pressure, "Pressure", 0.0, "Pressure [Bar]", "", "", "" ); + CAF_PDM_InitScriptableField( &m_depth, "Depth", 0.0, "Depth TVDMSL [m]" ); + CAF_PDM_InitScriptableField( &m_initialPressure, "InitialPressure", 0.0, "Initial Pressure [Bar]" ); + CAF_PDM_InitScriptableField( &m_pressure, "Pressure", 0.0, "Pressure [Bar]" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModel.cpp b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModel.cpp index 9e2607eae4..30017ee785 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModel.cpp +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModel.cpp @@ -134,137 +134,120 @@ void caf::AppEnum::setUp() //-------------------------------------------------------------------------------------------------- RimStimPlanModel::RimStimPlanModel() { - CAF_PDM_InitScriptableObject( "StimPlanModel", "", "", "" ); + CAF_PDM_InitScriptableObject( "StimPlanModel" ); - CAF_PDM_InitFieldNoDefault( &m_stimPlanModelTemplate, "StimPlanModelTemplate", "StimPlan Model Template", "", "", "" ); - CAF_PDM_InitField( &m_editStimPlanModelTemplate, "EditModelTemplate", false, "Edit", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_stimPlanModelTemplate, "StimPlanModelTemplate", "StimPlan Model Template" ); + CAF_PDM_InitField( &m_editStimPlanModelTemplate, "EditModelTemplate", false, "Edit" ); m_editStimPlanModelTemplate.uiCapability()->setUiEditorTypeName( caf::PdmUiToolButtonEditor::uiEditorTypeName() ); m_editStimPlanModelTemplate.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); - CAF_PDM_InitScriptableFieldNoDefault( &m_eclipseCase, "EclipseCase", "Dynamic Case", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_eclipseCase, "EclipseCase", "Dynamic Case" ); m_eclipseCase.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitScriptableField( &m_timeStep, "TimeStep", 0, "Time Step", "", "", "" ); + CAF_PDM_InitScriptableField( &m_timeStep, "TimeStep", 0, "Time Step" ); m_timeStep.uiCapability()->setUiReadOnly( true ); CAF_PDM_InitScriptableFieldNoDefault( &m_initialPressureEclipseCase, "InitialPressureEclipseCase", - "Initial Pressure Case", - "", - "", - "" ); + "Initial Pressure Case" ); m_initialPressureEclipseCase.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitScriptableFieldNoDefault( &m_staticEclipseCase, "StaticEclipseCase", "Static Case", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_staticEclipseCase, "StaticEclipseCase", "Static Case" ); m_staticEclipseCase.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitScriptableField( &m_MD, "MeasuredDepth", 0.0, "Measured Depth", "", "", "" ); + CAF_PDM_InitScriptableField( &m_MD, "MeasuredDepth", 0.0, "Measured Depth" ); m_MD.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); - CAF_PDM_InitScriptableField( &m_extractionOffsetTop, "ExtractionOffsetTop", -1.0, "Top Offset", "", "", "" ); + CAF_PDM_InitScriptableField( &m_extractionOffsetTop, "ExtractionOffsetTop", -1.0, "Top Offset" ); m_extractionOffsetTop.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); - CAF_PDM_InitScriptableField( &m_extractionOffsetBottom, "ExtractionOffsetBottom", -1.0, "Bottom Offset", "", "", "" ); + CAF_PDM_InitScriptableField( &m_extractionOffsetBottom, "ExtractionOffsetBottom", -1.0, "Bottom Offset" ); m_extractionOffsetBottom.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); - CAF_PDM_InitScriptableField( &m_extractionDepthTop, "ExtractionDepthTop", -1.0, "Depth", "", "", "" ); + CAF_PDM_InitScriptableField( &m_extractionDepthTop, "ExtractionDepthTop", -1.0, "Depth" ); m_extractionDepthTop.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); m_extractionDepthTop.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitScriptableField( &m_extractionDepthBottom, "ExtractionDepthBottom", -1.0, "Depth", "", "", "" ); + CAF_PDM_InitScriptableField( &m_extractionDepthBottom, "ExtractionDepthBottom", -1.0, "Depth" ); m_extractionDepthBottom.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); m_extractionDepthBottom.uiCapability()->setUiReadOnly( true ); CAF_PDM_InitScriptableField( &m_extractionType, "ExtractionType", caf::AppEnum( ExtractionType::TRUE_STRATIGRAPHIC_THICKNESS ), - "Extraction Type", - "", - "", - "" ); + "Extraction Type" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_anchorPosition, "AnchorPosition", "Anchor Position", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_anchorPosition, "AnchorPosition", "Anchor Position" ); m_anchorPosition.uiCapability()->setUiReadOnly( true ); m_anchorPosition.xmlCapability()->disableIO(); - CAF_PDM_InitFieldNoDefault( &m_anchorPositionForUi, "AnchorPositionForUi", "Anchor Position", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_anchorPositionForUi, "AnchorPositionForUi", "Anchor Position" ); m_anchorPositionForUi.registerGetMethod( this, &RimStimPlanModel::anchorPositionForUi ); m_anchorPositionForUi.uiCapability()->setUiReadOnly( true ); m_anchorPositionForUi.xmlCapability()->disableIO(); - CAF_PDM_InitScriptableFieldNoDefault( &m_thicknessDirection, "ThicknessDirection", "Thickness Direction", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_thicknessDirection, "ThicknessDirection", "Thickness Direction" ); m_thicknessDirection.uiCapability()->setUiReadOnly( true ); m_thicknessDirection.xmlCapability()->disableIO(); + CAF_PDM_InitScriptableFieldNoDefault( &m_originalThicknessDirection, + "OriginalThicknessDirection", + "Original Thickness Direction" ); + m_originalThicknessDirection.uiCapability()->setUiReadOnly( true ); + m_originalThicknessDirection.xmlCapability()->disableIO(); + CAF_PDM_InitScriptableFieldNoDefault( &m_thicknessDirectionWellPath, "ThicknessDirectionWellPath", - "Thickness Direction Well Path", - "", - "", - "" ); + "Thickness Direction Well Path" ); - CAF_PDM_InitScriptableField( &m_boundingBoxHorizontal, "BoundingBoxHorizontal", 50.0, "Bounding Box Horizontal", "", "", "" ); - CAF_PDM_InitScriptableField( &m_boundingBoxVertical, "BoundingBoxVertical", 100.0, "Bounding Box Vertical", "", "", "" ); + CAF_PDM_InitScriptableField( &m_boundingBoxHorizontal, "BoundingBoxHorizontal", 50.0, "Bounding Box Horizontal" ); + CAF_PDM_InitScriptableField( &m_boundingBoxVertical, "BoundingBoxVertical", 100.0, "Bounding Box Vertical" ); - CAF_PDM_InitScriptableField( &m_useDetailedFluidLoss, "UseDetailedFluidLoss", true, "Use Detailed Fluid Loss", "", "", "" ); + CAF_PDM_InitScriptableField( &m_useDetailedFluidLoss, "UseDetailedFluidLoss", true, "Use Detailed Fluid Loss" ); CAF_PDM_InitScriptableField( &m_relativePermeabilityFactorDefault, "RelativePermeabilityFactor", 0.5, - "Relative Permeability Factor", - "", - "", - "" ); - CAF_PDM_InitScriptableField( &m_poroElasticConstantDefault, "PoroElasticConstant", 0.0, "Poro-Elastic Constant", "", "", "" ); + "Relative Permeability Factor" ); + CAF_PDM_InitScriptableField( &m_poroElasticConstantDefault, "PoroElasticConstant", 0.0, "Poro-Elastic Constant" ); CAF_PDM_InitScriptableField( &m_thermalExpansionCoeffientDefault, "ThermalExpansionCoefficient", 0.0, - "Thermal Expansion Coefficient [1/C]", - "", - "", - "" ); + "Thermal Expansion Coefficient [1/C]" ); - CAF_PDM_InitScriptableField( &m_perforationLength, "PerforationLength", 10.0, "Perforation Length [m]", "", "", "" ); + CAF_PDM_InitScriptableField( &m_perforationLength, "PerforationLength", 10.0, "Perforation Length [m]" ); CAF_PDM_InitScriptableField( &m_fractureOrientation, "FractureOrientation", caf::AppEnum( FractureOrientation::ALONG_WELL_PATH ), - "Fracture Orientation", - "", - "", - "" ); - CAF_PDM_InitScriptableField( &m_azimuthAngle, "AzimuthAngle", 0.0, "Azimuth Angle", "", "", "" ); + "Fracture Orientation" ); + CAF_PDM_InitScriptableField( &m_azimuthAngle, "AzimuthAngle", 0.0, "Azimuth Angle" ); - CAF_PDM_InitScriptableField( &m_formationDip, "FormationDip", 0.0, "Formation Dip", "", "", "" ); + CAF_PDM_InitScriptableField( &m_formationDip, "FormationDip", 0.0, "Formation Dip" ); m_formationDip.uiCapability()->setUiReadOnly( true ); m_formationDip.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); - CAF_PDM_InitScriptableField( &m_autoComputeBarrier, "AutoComputeBarrier", true, "Auto Compute Barrier", "", "", "" ); - CAF_PDM_InitScriptableField( &m_hasBarrier, "Barrier", true, "Barrier", "", "", "" ); - CAF_PDM_InitScriptableField( &m_distanceToBarrier, "DistanceToBarrier", 0.0, "Distance To Barrier [m]", "", "", "" ); + CAF_PDM_InitScriptableField( &m_autoComputeBarrier, "AutoComputeBarrier", true, "Auto Compute Barrier" ); + CAF_PDM_InitScriptableField( &m_hasBarrier, "Barrier", true, "Barrier" ); + CAF_PDM_InitScriptableField( &m_distanceToBarrier, "DistanceToBarrier", 0.0, "Distance To Barrier [m]" ); m_distanceToBarrier.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); m_distanceToBarrier.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitScriptableField( &m_barrierDip, "BarrierDip", 0.0, "Barrier Dip", "", "", "" ); + CAF_PDM_InitScriptableField( &m_barrierDip, "BarrierDip", 0.0, "Barrier Dip" ); m_barrierDip.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); m_barrierDip.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitScriptableField( &m_wellPenetrationLayer, "WellPenetrationLayer", 2, "Well Penetration Layer", "", "", "" ); + CAF_PDM_InitScriptableField( &m_wellPenetrationLayer, "WellPenetrationLayer", 2, "Well Penetration Layer" ); - CAF_PDM_InitScriptableField( &m_showOnlyBarrierFault, "ShowOnlyBarrierFault", false, "Show Only Barrier Fault", "", "", "" ); - CAF_PDM_InitScriptableField( &m_showAllFaults, "ShowAllFaults", false, "Show All Faults", "", "", "" ); + CAF_PDM_InitScriptableField( &m_showOnlyBarrierFault, "ShowOnlyBarrierFault", false, "Show Only Barrier Fault" ); + CAF_PDM_InitScriptableField( &m_showAllFaults, "ShowAllFaults", false, "Show All Faults" ); m_showAllFaults.uiCapability()->setUiEditorTypeName( caf::PdmUiToolButtonEditor::uiEditorTypeName() ); m_showAllFaults.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); - CAF_PDM_InitScriptableField( &m_barrierFaultName, "BarrierFaultName", QString( "" ), "Barrier Fault", "", "", "" ); + CAF_PDM_InitScriptableField( &m_barrierFaultName, "BarrierFaultName", QString( "" ), "Barrier Fault" ); m_barrierFaultName.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitScriptableFieldNoDefault( &m_barrierTextAnnotation, - "BarrierTextAnnotation", - "Barrier Text Annotation", - "", - "", - "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_barrierTextAnnotation, "BarrierTextAnnotation", "Barrier Text Annotation" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_perforationInterval, "PerforationInterval", "Perforation Interval", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_perforationInterval, "PerforationInterval", "Perforation Interval" ); m_calculator = std::shared_ptr( new RimStimPlanModelCalculator ); m_calculator->setStimPlanModel( this ); @@ -416,8 +399,7 @@ void RimStimPlanModel::fieldChangedByUi( const caf::PdmFieldHandle* changedField //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimStimPlanModel::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RimStimPlanModel::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; @@ -560,18 +542,26 @@ void RimStimPlanModel::updatePositionFromMeasuredDepth() //-------------------------------------------------------------------------------------------------- void RimStimPlanModel::updateThicknessDirection() { - // True vertical thickness: just point straight up - cvf::Vec3d direction( 0.0, 0.0, -1.0 ); + cvf::Vec3d defaultDirection( 0.0, 0.0, -1.0 ); if ( m_extractionType() == ExtractionType::TRUE_STRATIGRAPHIC_THICKNESS ) { - direction = RigStimPlanModelTools::calculateTSTDirection( getEclipseCaseData(), - m_anchorPosition(), - m_boundingBoxHorizontal, - m_boundingBoxVertical ); - } + cvf::Vec3d direction = RigStimPlanModelTools::calculateTSTDirection( getEclipseCaseData(), + m_anchorPosition(), + m_boundingBoxHorizontal, + m_boundingBoxVertical ); - m_thicknessDirection = direction; + // Calculate an adjusted TST direction to improve the zone thickness in the well log plot. + // Using average of TST and TVD (default direction) in 3D. + m_thicknessDirection = ( direction + defaultDirection ) / 2.0; + m_originalThicknessDirection = direction; + } + else + { + // True vertical thickness: just point straight up + m_thicknessDirection = defaultDirection; + m_originalThicknessDirection = defaultDirection; + } if ( m_thicknessDirectionWellPath ) { @@ -665,7 +655,62 @@ void RimStimPlanModel::updateDistanceToBarrierAndDip() RiaLogging::info( "Computing distance to barrier." ); RiaLogging::info( QString( "Anchor position: %1" ).arg( RigStimPlanModelTools::vecToString( position ) ) ); - RigWellPath* wellPathGeometry = wellPath()->wellPathGeometry(); + cvf::Vec3d fractureDirectionNormal = computeFractureDirectionNormal( wellPath(), position ); + + // Update formation dip. The direction for the barrier search follows the + // inclination of the formation, and is in effect the formation dip in the + // fracture plane. -90 to convert from horizontal to vertical. + cvf::Vec3d formationDirection = + projectVectorIntoFracturePlane( position, fractureDirectionNormal, m_originalThicknessDirection ); + if ( formationDirection.isUndefined() ) return; + m_formationDip = std::abs( RigStimPlanModelTools::calculateFormationDip( formationDirection ) - 90.0 ); + + cvf::Vec3d directionToBarrier = + projectVectorIntoFracturePlane( position, fractureDirectionNormal, m_thicknessDirection ); + if ( directionToBarrier.isUndefined() ) return; + + RiaLogging::info( + QString( "Direction to barrier: %1" ).arg( RigStimPlanModelTools::vecToString( directionToBarrier ) ) ); + + auto [foundFault, shortestDistance, barrierPosition, barrierDip] = + RigStimPlanModelTools::findClosestFaultBarrier( eclipseCaseData, position, directionToBarrier ); + + if ( foundFault ) + { + RiaLogging::info( QString( "Found barrier distance: %1. Dip: %2. Fault: %3" ) + .arg( shortestDistance ) + .arg( barrierDip ) + .arg( foundFault->name() ) ); + QString barrierText = + QString( "Barrier Fault for %1\nFault: %2\nDistance: %3m" ).arg( name() ).arg( foundFault->name() ).arg( shortestDistance ); + + clearBarrierAnnotation(); + addBarrierAnnotation( position, barrierPosition, barrierText ); + + m_hasBarrier = true; + m_barrierDip = barrierDip; + m_distanceToBarrier = shortestDistance; + m_barrierFaultName = foundFault->name(); + } + else + { + RiaLogging::info( "No barrier found." ); + clearBarrierAnnotation(); + m_hasBarrier = false; + m_barrierDip = 0.0; + m_distanceToBarrier = 0.0; + m_barrierFaultName = ""; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec3d RimStimPlanModel::computeFractureDirectionNormal( RimWellPath* wellPath, const cvf::Vec3d& position ) const +{ + CAF_ASSERT( wellPath ); + RigWellPath* wellPathGeometry = wellPath->wellPathGeometry(); + CAF_ASSERT( wellPathGeometry ); // Find the well path points closest to the anchor position cvf::Vec3d p1; @@ -694,66 +739,35 @@ void RimStimPlanModel::updateDistanceToBarrierAndDip() fractureDirectionNormal.transformVector( azimuthRotation ); } + return fractureDirectionNormal; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec3d RimStimPlanModel::projectVectorIntoFracturePlane( const cvf::Vec3d& position, + const cvf::Vec3d& fractureDirectionNormal, + const cvf::Vec3d& direction ) +{ // Create a fracture plane cvf::Plane fracturePlane; if ( !fracturePlane.setFromPointAndNormal( position, fractureDirectionNormal ) ) { RiaLogging::error( "Unable to create fracture plane" ); - return; + return cvf::Vec3d::UNDEFINED; } - // The direction to the barrier must be in the fracture plane. - // Project the TST onto the fracture plane. + // Project the direction onto the fracture plane. cvf::Vec3d tstInPlane; - if ( !fracturePlane.projectVector( thicknessDirection(), &tstInPlane ) ) + if ( !fracturePlane.projectVector( direction, &tstInPlane ) ) { RiaLogging::error( "Unable to project thickess vector into fracture plane" ); - return; + return cvf::Vec3d::UNDEFINED; } - RiaLogging::info( - QString( "Thickness direction: %1" ).arg( RigStimPlanModelTools::vecToString( thicknessDirection() ) ) ); - RiaLogging::info( - QString( "Thickness direction in fracture plane: %1" ).arg( RigStimPlanModelTools::vecToString( tstInPlane ) ) ); // The direction to the barrier is normal to the TST project into the fracture plane - cvf::Vec3d directionToBarrier = ( tstInPlane ^ fractureDirectionNormal ).getNormalized(); - RiaLogging::info( - QString( "Direction to barrier: %1" ).arg( RigStimPlanModelTools::vecToString( directionToBarrier ) ) ); - - // Update formation dip. The direction for the barrier search follows the - // inclination of the formation, and is in effect the formation dip in the - // fracture plane. -90 to convert from horizontal to vertical. - m_formationDip = std::abs( RigStimPlanModelTools::calculateFormationDip( directionToBarrier ) - 90.0 ); - - auto [foundFault, shortestDistance, barrierPosition, barrierDip] = - RigStimPlanModelTools::findClosestFaultBarrier( eclipseCaseData, position, directionToBarrier ); - - if ( foundFault ) - { - RiaLogging::info( QString( "Found barrier distance: %1. Dip: %2. Fault: %3" ) - .arg( shortestDistance ) - .arg( barrierDip ) - .arg( foundFault->name() ) ); - QString barrierText = - QString( "Barrier Fault for %1\nFault: %2\nDistance: %3m" ).arg( name() ).arg( foundFault->name() ).arg( shortestDistance ); - - clearBarrierAnnotation(); - addBarrierAnnotation( position, barrierPosition, barrierText ); - - m_hasBarrier = true; - m_barrierDip = barrierDip; - m_distanceToBarrier = shortestDistance; - m_barrierFaultName = foundFault->name(); - } - else - { - RiaLogging::info( "No barrier found." ); - clearBarrierAnnotation(); - m_hasBarrier = false; - m_barrierDip = 0.0; - m_distanceToBarrier = 0.0; - m_barrierFaultName = ""; - } + cvf::Vec3d directionInPlane = ( tstInPlane ^ fractureDirectionNormal ).getNormalized(); + return directionInPlane; } //-------------------------------------------------------------------------------------------------- @@ -818,8 +832,20 @@ void RimStimPlanModel::updatePerforationInterval() m_thicknessDirectionWellPath->perforationIntervalCollection()->appendPerforation( m_perforationInterval ); } + double halfPerforationLength = m_perforationLength() * 0.5; + if ( m_fractureOrientation == FractureOrientation::ALONG_WELL_PATH ) + { + // Adjust perforation interval for longitudinal fractures to correct TVD depth + CAF_ASSERT( wellPath() ); + CAF_ASSERT( wellPath()->wellPathGeometry() ); + + cvf::Vec3d wellPathTangent = wellPath()->wellPathGeometry()->tangentAlongWellPath( m_MD() ); + halfPerforationLength = + RigStimPlanModelTools::calculatePerforationLength( wellPathTangent, m_perforationLength() ) * 0.5; + } + double closestMd = m_thicknessDirectionWellPath->wellPathGeometry()->closestMeasuredDepth( m_anchorPosition ); - m_perforationInterval->setStartAndEndMD( closestMd - perforationLength(), closestMd + perforationLength() ); + m_perforationInterval->setStartAndEndMD( closestMd - halfPerforationLength, closestMd + halfPerforationLength ); m_perforationInterval->updateConnectedEditors(); updateViewsAndPlots(); } @@ -884,6 +910,8 @@ void RimStimPlanModel::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin asymmetricGroup->add( &m_showAllFaults, { false, 1, 0 } ); asymmetricGroup->add( &m_wellPenetrationLayer ); + + uiOrdering.skipRemainingFields(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModel.h b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModel.h index b894418b40..c3d1c44119 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModel.h +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModel.h @@ -192,10 +192,13 @@ class RimStimPlanModel : public RimCheckableNamedObject, public RimWellPathCompo QString unitForProperty( RiaDefines::CurveProperty curveProperty ) const; + static cvf::Vec3d projectVectorIntoFracturePlane( const cvf::Vec3d& position, + const cvf::Vec3d& fractureDirectionNormal, + const cvf::Vec3d& direction ); + protected: void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; @@ -208,6 +211,8 @@ class RimStimPlanModel : public RimCheckableNamedObject, public RimWellPathCompo void updateThicknessDirectionWellPathName(); void updatePerforationInterval(); + cvf::Vec3d computeFractureDirectionNormal( RimWellPath* wellPath, const cvf::Vec3d& position ) const; + RigEclipseCaseData* getEclipseCaseData() const; void updateBarrierProperties(); @@ -242,6 +247,7 @@ class RimStimPlanModel : public RimCheckableNamedObject, public RimWellPathCompo caf::PdmField m_anchorPosition; caf::PdmProxyValueField m_anchorPositionForUi; caf::PdmField m_thicknessDirection; + caf::PdmField m_originalThicknessDirection; caf::PdmField m_boundingBoxVertical; caf::PdmField m_boundingBoxHorizontal; caf::PdmPtrField m_thicknessDirectionWellPath; diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelCollection.cpp b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelCollection.cpp index e45625c461..0411185e9f 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelCollection.cpp @@ -32,9 +32,9 @@ CAF_PDM_SOURCE_INIT( RimStimPlanModelCollection, "StimPlanModelCollection" ); //-------------------------------------------------------------------------------------------------- RimStimPlanModelCollection::RimStimPlanModelCollection( void ) { - CAF_PDM_InitScriptableObject( "StimPlan Models", "", "", "" ); + CAF_PDM_InitScriptableObject( "StimPlan Models" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_stimPlanModels, "StimPlanModels", "", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_stimPlanModels, "StimPlanModels", "" ); m_stimPlanModels.uiCapability()->setUiTreeHidden( true ); setName( "StimPlan Models" ); @@ -69,7 +69,7 @@ void RimStimPlanModelCollection::addStimPlanModel( RimStimPlanModel* fracture ) //-------------------------------------------------------------------------------------------------- void RimStimPlanModelCollection::deleteStimPlanModels() { - m_stimPlanModels.deleteAllChildObjects(); + m_stimPlanModels.deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -77,7 +77,7 @@ void RimStimPlanModelCollection::deleteStimPlanModels() //-------------------------------------------------------------------------------------------------- std::vector RimStimPlanModelCollection::allStimPlanModels() const { - return m_stimPlanModels.childObjects(); + return m_stimPlanModels.children(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelCurve.cpp b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelCurve.cpp index e73891f001..c4ccf87eb8 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelCurve.cpp @@ -46,13 +46,13 @@ CAF_PDM_SOURCE_INIT( RimStimPlanModelCurve, "StimPlanModelCurve" ); //-------------------------------------------------------------------------------------------------- RimStimPlanModelCurve::RimStimPlanModelCurve() { - CAF_PDM_InitObject( "StimPlan Model Curve", "", "", "" ); + CAF_PDM_InitObject( "StimPlan Model Curve" ); - CAF_PDM_InitFieldNoDefault( &m_stimPlanModel, "StimPlanModel", "StimPlan Model", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_stimPlanModel, "StimPlanModel", "StimPlan Model" ); m_stimPlanModel.uiCapability()->setUiTreeChildrenHidden( true ); m_stimPlanModel.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_curveProperty, "CurveProperty", "Curve Property", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_curveProperty, "CurveProperty", "Curve Property" ); m_curveProperty.uiCapability()->setUiHidden( true ); m_wellPath = nullptr; @@ -158,7 +158,17 @@ void RimStimPlanModelCurve::performDataExtraction( bool* isUsingPseudoLength ) filterInvalidValuesForLogarithmicScale( values ); } - this->setValuesWithMdAndTVD( values, measuredDepthValues, tvDepthValues, rkbDiff, depthUnit, !performDataSmoothing, xUnits ); + // TOOD: Consider rewrite, as RigWellLogCurveData can do logarithmic filtering + + bool useLogarithmicScale = false; + this->setPropertyValuesWithMdAndTVD( values, + measuredDepthValues, + tvDepthValues, + rkbDiff, + depthUnit, + !performDataSmoothing, + useLogarithmicScale, + xUnits ); } } diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelPlot.cpp b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelPlot.cpp index 8dd6551cef..f493ff0bcb 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelPlot.cpp @@ -45,15 +45,15 @@ RimStimPlanModelPlot::RimStimPlanModelPlot() { CAF_PDM_InitScriptableObject( "StimPlan Model Plot", "", "", "A fracture model plot" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_stimPlanModel, "StimPlanModel", "StimPlan Model", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_stimPlanModel, "StimPlanModel", "StimPlan Model" ); m_stimPlanModel.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitField( &m_editStimPlanModel, "EditModel", false, "Edit", "", "", "" ); + CAF_PDM_InitField( &m_editStimPlanModel, "EditModel", false, "Edit" ); m_editStimPlanModel.uiCapability()->setUiEditorTypeName( caf::PdmUiToolButtonEditor::uiEditorTypeName() ); m_editStimPlanModel.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); - CAF_PDM_InitScriptableFieldNoDefault( &m_eclipseCase, "EclipseCase", "Case", "", "", "" ); - CAF_PDM_InitScriptableField( &m_timeStep, "TimeStep", 0, "Time Step", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_eclipseCase, "EclipseCase", "Case" ); + CAF_PDM_InitScriptableField( &m_timeStep, "TimeStep", 0, "Time Step" ); setLegendsVisible( true ); setDeletable( true ); @@ -104,8 +104,7 @@ void RimStimPlanModelPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrd //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList - RimStimPlanModelPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) +QList RimStimPlanModelPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelPlot.h b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelPlot.h index 30180f013a..a2b20374ea 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelPlot.h +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelPlot.h @@ -41,8 +41,7 @@ class RimStimPlanModelPlot : public RimDepthTrackPlot RimWellLogExtractionCurve* findCurveByProperty( RiaDefines::CurveProperty curveProperty ) const; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void onLoadDataAndUpdate() override; diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelPlotCollection.cpp b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelPlotCollection.cpp index ed7db855b1..a8803038bf 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelPlotCollection.cpp @@ -30,9 +30,9 @@ CAF_PDM_SOURCE_INIT( RimStimPlanModelPlotCollection, "StimPlanModelPlotCollectio //-------------------------------------------------------------------------------------------------- RimStimPlanModelPlotCollection::RimStimPlanModelPlotCollection() { - CAF_PDM_InitScriptableObject( "StimPlan Model Plots", ":/WellLogPlots16x16.png", "", "" ); + CAF_PDM_InitScriptableObject( "StimPlan Model Plots", ":/WellLogPlots16x16.png" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_stimPlanModelPlots, "StimPlanModelPlots", "", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_stimPlanModelPlots, "StimPlanModelPlots", "" ); m_stimPlanModelPlots.uiCapability()->setUiTreeHidden( true ); } @@ -41,7 +41,7 @@ RimStimPlanModelPlotCollection::RimStimPlanModelPlotCollection() //-------------------------------------------------------------------------------------------------- RimStimPlanModelPlotCollection::~RimStimPlanModelPlotCollection() { - m_stimPlanModelPlots.deleteAllChildObjects(); + m_stimPlanModelPlots.deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -76,7 +76,7 @@ void RimStimPlanModelPlotCollection::addStimPlanModelPlot( RimStimPlanModelPlot* //-------------------------------------------------------------------------------------------------- std::vector RimStimPlanModelPlotCollection::stimPlanModelPlots() const { - return m_stimPlanModelPlots.childObjects(); + return m_stimPlanModelPlots.children(); } //-------------------------------------------------------------------------------------------------- @@ -84,5 +84,5 @@ std::vector RimStimPlanModelPlotCollection::stimPlanModel //-------------------------------------------------------------------------------------------------- void RimStimPlanModelPlotCollection::deleteAllPlots() { - m_stimPlanModelPlots.deleteAllChildObjects(); + m_stimPlanModelPlots.deleteChildren(); } diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelTemplate.cpp b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelTemplate.cpp index 31ef5343b6..8f220d694d 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelTemplate.cpp +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelTemplate.cpp @@ -67,56 +67,35 @@ CAF_PDM_SOURCE_INIT( RimStimPlanModelTemplate, "StimPlanModelTemplate" ); RimStimPlanModelTemplate::RimStimPlanModelTemplate() : changed( this ) { - CAF_PDM_InitScriptableObject( "StimPlanModelTemplate", "", "", "" ); + CAF_PDM_InitScriptableObject( "StimPlanModelTemplate" ); - CAF_PDM_InitScriptableField( &m_id, "Id", -1, "ID", "", "", "" ); + CAF_PDM_InitScriptableField( &m_id, "Id", -1, "ID" ); m_id.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitScriptableFieldNoDefault( &m_dynamicEclipseCase, "DynamicEclipseCase", "Dynamic Case", "", "", "" ); - CAF_PDM_InitScriptableField( &m_timeStep, "TimeStep", 0, "Time Step", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_dynamicEclipseCase, "DynamicEclipseCase", "Dynamic Case" ); + CAF_PDM_InitScriptableField( &m_timeStep, "TimeStep", 0, "Time Step" ); CAF_PDM_InitScriptableFieldNoDefault( &m_initialPressureEclipseCase, "InitialPressureEclipseCase", - "Initial Pressure Case", - "", - "", - "" ); - CAF_PDM_InitField( &m_useTableForInitialPressure, - "UseForInitialPressure", - false, - "Use Pressure Table For Initial Pressure", - "", - "", - "" ); - CAF_PDM_InitField( &m_useTableForPressure, "UseForPressure", false, "Use Pressure Table For Pressure", "", "", "" ); - CAF_PDM_InitField( &m_editPressureTable, "EditPressureTable", false, "Edit", "", "", "" ); + "Initial Pressure Case" ); + CAF_PDM_InitField( &m_useTableForInitialPressure, "UseForInitialPressure", false, "Use Pressure Table For Initial Pressure" ); + CAF_PDM_InitField( &m_useTableForPressure, "UseForPressure", false, "Use Pressure Table For Pressure" ); + CAF_PDM_InitField( &m_editPressureTable, "EditPressureTable", false, "Edit" ); m_editPressureTable.uiCapability()->setUiEditorTypeName( caf::PdmUiToolButtonEditor::uiEditorTypeName() ); m_editPressureTable.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); - CAF_PDM_InitScriptableFieldNoDefault( &m_staticEclipseCase, "StaticEclipseCase", "Static Case", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_staticEclipseCase, "StaticEclipseCase", "Static Case" ); CAF_PDM_InitField( &m_useEqlnumForPressureInterpolation, "UseEqlNumForPressureInterpolation", true, - "Use EQLNUM For Pressure Interpolation", - "", - "", - "" ); - - CAF_PDM_InitScriptableField( &m_defaultPorosity, - "DefaultPorosity", - RiaDefines::defaultPorosity(), - "Default Porosity", - "", - "", - "" ); + "Use EQLNUM For Pressure Interpolation" ); + + CAF_PDM_InitScriptableField( &m_defaultPorosity, "DefaultPorosity", RiaDefines::defaultPorosity(), "Default Porosity" ); CAF_PDM_InitScriptableField( &m_defaultPermeability, "DefaultPermeability", RiaDefines::defaultPermeability(), - "Default Permeability", - "", - "", - "" ); + "Default Permeability" ); // Stress unit: bar // Stress gradient unit: bar/m @@ -125,93 +104,57 @@ RimStimPlanModelTemplate::RimStimPlanModelTemplate() double defaultStressDepth = computeDefaultStressDepth(); double defaultStress = defaultStressDepth * defaultStressGradient; - CAF_PDM_InitScriptableField( &m_verticalStress, "VerticalStress", defaultStress, "Vertical Stress", "", "", "" ); + CAF_PDM_InitScriptableField( &m_verticalStress, "VerticalStress", defaultStress, "Vertical Stress" ); m_verticalStress.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); CAF_PDM_InitScriptableField( &m_verticalStressGradient, "VerticalStressGradient", defaultStressGradient, - "Vertical Stress Gradient", - "", - "", - "" ); - CAF_PDM_InitScriptableField( &m_stressDepth, "StressDepth", defaultStressDepth, "Stress Depth", "", "", "" ); + "Vertical Stress Gradient" ); + CAF_PDM_InitScriptableField( &m_stressDepth, "StressDepth", defaultStressDepth, "Stress Depth" ); m_stressDepth.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); - CAF_PDM_InitScriptableField( &m_referenceTemperature, "ReferenceTemperature", 70.0, "Temperature [C]", "", "", "" ); + CAF_PDM_InitScriptableField( &m_referenceTemperature, "ReferenceTemperature", 70.0, "Temperature [C]" ); CAF_PDM_InitScriptableField( &m_referenceTemperatureGradient, "ReferenceTemperatureGradient", 0.025, - "Temperature Gradient [C/m]", - "", - "", - "" ); - CAF_PDM_InitScriptableField( &m_referenceTemperatureDepth, - "ReferenceTemperatureDepth", - 2500.0, - "Temperature Depth [m]", - "", - "", - "" ); - - CAF_PDM_InitScriptableField( &m_overburdenHeight, "OverburdenHeight", 50.0, "Overburden Height", "", "", "" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_overburdenFormation, "OverburdenFormation", "Overburden Formation", "", "", "" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_overburdenFacies, "OverburdenFacies", "Overburden Facies", "", "", "" ); - CAF_PDM_InitScriptableField( &m_overburdenPorosity, "OverburdenPorosity", 0.0, "Overburden Porosity", "", "", "" ); - CAF_PDM_InitScriptableField( &m_overburdenPermeability, - "OverburdenPermeability", - 10.0e-6, - "Overburden Permeability", - "", - "", - "" ); - CAF_PDM_InitScriptableField( &m_overburdenFluidDensity, - "OverburdenFluidDensity", - 1.03, - "Overburden Fluid Density [g/cm^3]", - "", - "", - "" ); - - CAF_PDM_InitScriptableField( &m_underburdenHeight, "UnderburdenHeight", 50.0, "Underburden Height", "", "", "" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_underburdenFormation, "UnderburdenFormation", "Underburden Formation", "", "", "" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_underburdenFacies, "UnderburdenFacies", "Underburden Facies", "", "", "" ); - CAF_PDM_InitScriptableField( &m_underburdenPorosity, "UnderburdenPorosity", 0.0, "Underburden Porosity", "", "", "" ); - CAF_PDM_InitScriptableField( &m_underburdenPermeability, - "UnderburdenPermeability", - 10.0e-6, - "Underburden Permeability", - "", - "", - "" ); + "Temperature Gradient [C/m]" ); + CAF_PDM_InitScriptableField( &m_referenceTemperatureDepth, "ReferenceTemperatureDepth", 2500.0, "Temperature Depth [m]" ); + + CAF_PDM_InitScriptableField( &m_overburdenHeight, "OverburdenHeight", 50.0, "Overburden Height" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_overburdenFormation, "OverburdenFormation", "Overburden Formation" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_overburdenFacies, "OverburdenFacies", "Overburden Facies" ); + CAF_PDM_InitScriptableField( &m_overburdenPorosity, "OverburdenPorosity", 0.0, "Overburden Porosity" ); + CAF_PDM_InitScriptableField( &m_overburdenPermeability, "OverburdenPermeability", 10.0e-6, "Overburden Permeability" ); + CAF_PDM_InitScriptableField( &m_overburdenFluidDensity, "OverburdenFluidDensity", 1.03, "Overburden Fluid Density [g/cm^3]" ); + + CAF_PDM_InitScriptableField( &m_underburdenHeight, "UnderburdenHeight", 50.0, "Underburden Height" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_underburdenFormation, "UnderburdenFormation", "Underburden Formation" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_underburdenFacies, "UnderburdenFacies", "Underburden Facies" ); + CAF_PDM_InitScriptableField( &m_underburdenPorosity, "UnderburdenPorosity", 0.0, "Underburden Porosity" ); + CAF_PDM_InitScriptableField( &m_underburdenPermeability, "UnderburdenPermeability", 10.0e-6, "Underburden Permeability" ); CAF_PDM_InitScriptableField( &m_underburdenFluidDensity, "UnderburdenFluidDensity", 1.03, - "Underburden Fluid Density [g/cm^3]", - "", - "", - "" ); + "Underburden Fluid Density [g/cm^3]" ); CAF_PDM_InitScriptableFieldNoDefault( &m_faciesInitialPressureConfigs, "FaciesInitialPressureConfigs", - "Facies Initial Pressure Configs", - "", - "", - "" ); + "Facies Initial Pressure Configs" ); m_faciesInitialPressureConfigs.uiCapability()->setUiEditorTypeName( caf::PdmUiTableViewEditor::uiEditorTypeName() ); m_faciesInitialPressureConfigs.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); m_faciesInitialPressureConfigs.uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitScriptableFieldNoDefault( &m_pressureTable, "PressureTable", "Pressure Table", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_pressureTable, "PressureTable", "Pressure Table" ); m_pressureTable.uiCapability()->setUiTreeHidden( true ); setPressureTable( new RimPressureTable ); - CAF_PDM_InitScriptableFieldNoDefault( &m_elasticProperties, "ElasticProperties", "Elastic Properties", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_elasticProperties, "ElasticProperties", "Elastic Properties" ); m_elasticProperties.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitScriptableFieldNoDefault( &m_faciesProperties, "FaciesProperties", "Facies Properties", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_faciesProperties, "FaciesProperties", "Facies Properties" ); m_faciesProperties.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitScriptableFieldNoDefault( &m_nonNetLayers, "NonNetLayers", "Non-Net Layers", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_nonNetLayers, "NonNetLayers", "Non-Net Layers" ); m_nonNetLayers.uiCapability()->setUiTreeHidden( true ); setNonNetLayers( new RimNonNetLayers ); @@ -257,8 +200,7 @@ void RimStimPlanModelTemplate::fieldChangedByUi( const caf::PdmFieldHandle* chan //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList - RimStimPlanModelTemplate::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) +QList RimStimPlanModelTemplate::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; @@ -569,7 +511,7 @@ void RimStimPlanModelTemplate::initAfterRead() m_faciesProperties->setEclipseCase( eclipseCase ); } - for ( auto& fipConfig : m_faciesInitialPressureConfigs.childObjects() ) + for ( auto& fipConfig : m_faciesInitialPressureConfigs.children() ) { fipConfig->changed.connect( this, &RimStimPlanModelTemplate::faciesPropertiesChanged ); } @@ -895,7 +837,7 @@ RimEclipseCase* RimStimPlanModelTemplate::initialPressureEclipseCase() const std::map RimStimPlanModelTemplate::faciesWithInitialPressure() const { std::map valueFractionMap; - for ( const RimFaciesInitialPressureConfig* c : m_faciesInitialPressureConfigs.childObjects() ) + for ( const RimFaciesInitialPressureConfig* c : m_faciesInitialPressureConfigs.children() ) { if ( c->isEnabled() ) valueFractionMap[c->faciesValue()] = c->fraction(); } diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelTemplate.h b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelTemplate.h index 250947215a..964ccbe80b 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelTemplate.h +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelTemplate.h @@ -125,8 +125,7 @@ class RimStimPlanModelTemplate : public RimNamedObject void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/ ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void initAfterRead() override; void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelTemplateCollection.cpp b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelTemplateCollection.cpp index b2d24160aa..b695e5f0d0 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelTemplateCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelTemplateCollection.cpp @@ -36,17 +36,12 @@ CAF_PDM_SOURCE_INIT( RimStimPlanModelTemplateCollection, "StimPlanModelTemplateC //-------------------------------------------------------------------------------------------------- RimStimPlanModelTemplateCollection::RimStimPlanModelTemplateCollection() { - CAF_PDM_InitScriptableObject( "StimPlan Model Templates", ":/FractureTemplates16x16.png", "", "" ); - - CAF_PDM_InitScriptableFieldNoDefault( &m_stimPlanModelTemplates, - "StimPlanModelTemplates", - "StimPlan Model Templates", - "", - "", - "" ); + CAF_PDM_InitScriptableObject( "StimPlan Model Templates", ":/FractureTemplates16x16.png" ); + + CAF_PDM_InitScriptableFieldNoDefault( &m_stimPlanModelTemplates, "StimPlanModelTemplates", "StimPlan Model Templates" ); m_stimPlanModelTemplates.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitField( &m_nextValidId, "NextValidId", 0, "", "", "", "" ); + CAF_PDM_InitField( &m_nextValidId, "NextValidId", 0, "" ); m_nextValidId.uiCapability()->setUiHidden( true ); } @@ -55,7 +50,7 @@ RimStimPlanModelTemplateCollection::RimStimPlanModelTemplateCollection() //-------------------------------------------------------------------------------------------------- RimStimPlanModelTemplateCollection::~RimStimPlanModelTemplateCollection() { - m_stimPlanModelTemplates.deleteAllChildObjects(); + m_stimPlanModelTemplates.deleteChildren(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Streamlines/RimStreamline.cpp b/ApplicationLibCode/ProjectDataModel/Streamlines/RimStreamline.cpp index 0bb14ef628..8fc8c9378d 100644 --- a/ApplicationLibCode/ProjectDataModel/Streamlines/RimStreamline.cpp +++ b/ApplicationLibCode/ProjectDataModel/Streamlines/RimStreamline.cpp @@ -28,9 +28,9 @@ CAF_PDM_ABSTRACT_SOURCE_INIT( RimStreamline, "Streamline" ); //-------------------------------------------------------------------------------------------------- RimStreamline::RimStreamline( QString simWellName ) { - CAF_PDM_InitScriptableObject( "Streamline", ":/Erase.png", "", "" ); + CAF_PDM_InitScriptableObject( "Streamline", ":/Erase.png" ); - CAF_PDM_InitScriptableField( &m_simWellName, "Name", simWellName, "Name", "", "", "" ); + CAF_PDM_InitScriptableField( &m_simWellName, "Name", simWellName, "Name" ); m_simWellName.uiCapability()->setUiReadOnly( true ); m_simWellName.uiCapability()->setUiHidden( true ); diff --git a/ApplicationLibCode/ProjectDataModel/Streamlines/RimStreamlineInViewCollection.cpp b/ApplicationLibCode/ProjectDataModel/Streamlines/RimStreamlineInViewCollection.cpp index 90f7a1b382..86351e8f00 100644 --- a/ApplicationLibCode/ProjectDataModel/Streamlines/RimStreamlineInViewCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Streamlines/RimStreamlineInViewCollection.cpp @@ -95,61 +95,61 @@ RimStreamlineInViewCollection::RimStreamlineInViewCollection() : m_shouldGenerateTracers( false ) , m_currentTimestep( -1 ) { - CAF_PDM_InitObject( "Streamlines", ":/Erase.png", "", "" ); + CAF_PDM_InitObject( "Streamlines", ":/Erase.png" ); - CAF_PDM_InitFieldNoDefault( &m_legendConfig, "LegendDefinition", "Color Legend", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_legendConfig, "LegendDefinition", "Color Legend" ); m_legendConfig = new RimRegularLegendConfig(); m_legendConfig->setMappingMode( RimRegularLegendConfig::MappingType::LOG10_CONTINUOUS ); m_legendConfig.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_collectionName, "Name", "Name", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_collectionName, "Name", "Name" ); m_collectionName = "Streamlines"; m_collectionName.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitFieldNoDefault( &m_flowThreshold, "FlowThreshold", "Flow Threshold [m/day]", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_flowThreshold, "FlowThreshold", "Flow Threshold [m/day]" ); m_flowThreshold = 0.01; - CAF_PDM_InitFieldNoDefault( &m_lengthThreshold, "LengthThreshold", "Minimum Length [m]", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_lengthThreshold, "LengthThreshold", "Minimum Length [m]" ); m_lengthThreshold = 100.0; - CAF_PDM_InitFieldNoDefault( &m_resolution, "Resolution", "Resolution [days]", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_resolution, "Resolution", "Resolution [days]" ); m_resolution = 20.0; - CAF_PDM_InitFieldNoDefault( &m_maxDays, "MaxDays", "Max Days", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_maxDays, "MaxDays", "Max Days" ); m_maxDays = 5000; - CAF_PDM_InitFieldNoDefault( &m_useProducers, "UseProducers", "Producer Wells", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_useProducers, "UseProducers", "Producer Wells" ); m_useProducers = true; - CAF_PDM_InitFieldNoDefault( &m_useInjectors, "UseInjectors", "Injector Wells", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_useInjectors, "UseInjectors", "Injector Wells" ); m_useInjectors = true; - CAF_PDM_InitFieldNoDefault( &m_phases, "Phase", "Phase", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_phases, "Phase", "Phase" ); - CAF_PDM_InitField( &m_isActive, "isActive", false, "Active", "", "", "" ); + CAF_PDM_InitField( &m_isActive, "isActive", false, "Active" ); m_isActive.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_visualizationMode, "VisualizationMode", "Visualization Mode", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_colorMode, "ColorMode", "Colors", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_visualizationMode, "VisualizationMode", "Visualization Mode" ); + CAF_PDM_InitFieldNoDefault( &m_colorMode, "ColorMode", "Colors" ); - CAF_PDM_InitFieldNoDefault( &m_animationSpeed, "AnimationSpeed", "Animation Speed", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_animationSpeed, "AnimationSpeed", "Animation Speed" ); m_animationSpeed.uiCapability()->setUiEditorTypeName( caf::PdmUiSliderEditor::uiEditorTypeName() ); m_animationSpeed = 10; - CAF_PDM_InitFieldNoDefault( &m_animationIndex, "AnimationIndex", "Animation Index", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_animationIndex, "AnimationIndex", "Animation Index" ); m_animationIndex.uiCapability()->setUiEditorTypeName( caf::PdmUiSliderEditor::uiEditorTypeName() ); m_animationIndex = 0; m_maxAnimationIndex = 0; - CAF_PDM_InitFieldNoDefault( &m_scaleFactor, "ScaleFactor", "Scale Factor", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_scaleFactor, "ScaleFactor", "Scale Factor" ); m_scaleFactor.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); m_scaleFactor = 100.0; - CAF_PDM_InitFieldNoDefault( &m_tracerLength, "TracerLength", "Tracer Length", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_tracerLength, "TracerLength", "Tracer Length" ); m_tracerLength.uiCapability()->setUiEditorTypeName( caf::PdmUiSliderEditor::uiEditorTypeName() ); m_tracerLength = 100; - CAF_PDM_InitFieldNoDefault( &m_streamlines, "Streamlines", "Streamlines", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_streamlines, "Streamlines", "Streamlines" ); m_streamlines.uiCapability()->setUiTreeHidden( true ); m_streamlines.xmlCapability()->disableIO(); @@ -441,7 +441,7 @@ void RimStreamlineInViewCollection::updateStreamlines() if ( m_shouldGenerateTracers && isActive() ) { // reset generated streamlines - m_streamlines().clear(); + m_streamlines.deleteChildren(); m_wellCellIds.clear(); // get current simulation timestep diff --git a/ApplicationLibCode/ProjectDataModel/Summary/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/Summary/CMakeLists_files.cmake index a3d2865cd9..01c73aeea1 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/CMakeLists_files.cmake +++ b/ApplicationLibCode/ProjectDataModel/Summary/CMakeLists_files.cmake @@ -6,11 +6,10 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCaseMainCollection.h ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCaseCollection.h ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurve.h + ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurvesData.h ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurveAppearanceCalculator.h ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurveAutoName.h - ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurveFilter.h ${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotAxisFormatter.h - ${CMAKE_CURRENT_LIST_DIR}/RimSummaryFilter.h ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurveCollection.h ${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlot.h ${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotCollection.h @@ -38,6 +37,16 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotFilterTextCurveSetEditor.h ${CMAKE_CURRENT_LIST_DIR}/RimObjectiveFunction.h ${CMAKE_CURRENT_LIST_DIR}/RimObjectiveFunctionTools.h + ${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotManager.h + ${CMAKE_CURRENT_LIST_DIR}/RimSummaryMultiPlot.h + ${CMAKE_CURRENT_LIST_DIR}/RimSummaryDataSourceStepping.h + ${CMAKE_CURRENT_LIST_DIR}/RimSummaryNameHelper.h + ${CMAKE_CURRENT_LIST_DIR}/RimMultipleSummaryPlotNameHelper.h + ${CMAKE_CURRENT_LIST_DIR}/RimSummaryAddressCollection.h + ${CMAKE_CURRENT_LIST_DIR}/RimSummaryMultiPlotCollection.h + ${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotControls.h + ${CMAKE_CURRENT_LIST_DIR}/RimEnsembleCurveInfoTextProvider.h + ${CMAKE_CURRENT_LIST_DIR}/RimSummaryAddressModifier.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -48,11 +57,10 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCaseMainCollection.cpp ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCaseCollection.cpp ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurve.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurvesData.cpp ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurveAppearanceCalculator.cpp ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurveAutoName.cpp - ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurveFilter.cpp ${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotAxisFormatter.cpp - ${CMAKE_CURRENT_LIST_DIR}/RimSummaryFilter.cpp ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurveCollection.cpp ${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlot.cpp ${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotCollection.cpp @@ -80,13 +88,25 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotFilterTextCurveSetEditor.cpp ${CMAKE_CURRENT_LIST_DIR}/RimObjectiveFunction.cpp ${CMAKE_CURRENT_LIST_DIR}/RimObjectiveFunctionTools.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotManager.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimSummaryMultiPlot.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimSummaryDataSourceStepping.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimSummaryNameHelper.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimMultipleSummaryPlotNameHelper.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimSummaryAddressCollection.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimSummaryMultiPlotCollection.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotControls.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimEnsembleCurveInfoTextProvider.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimSummaryAddressModifier.cpp ) list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES}) -list(APPEND QT_MOC_HEADERS ${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlot.h) +list(APPEND QT_MOC_HEADERS ${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlot.h + ${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotManager.h +) source_group( "ProjectDataModel\\Summary" diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimAsciiDataCurve.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimAsciiDataCurve.cpp index e54a0d5c3b..993a2280ae 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimAsciiDataCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimAsciiDataCurve.cpp @@ -22,7 +22,6 @@ #include "RimEclipseResultCase.h" #include "RimProject.h" #include "RimSummaryCase.h" -#include "RimSummaryFilter.h" #include "RimSummaryPlot.h" #include "RimSummaryTimeAxisProperties.h" @@ -42,12 +41,12 @@ CAF_PDM_SOURCE_INIT( RimAsciiDataCurve, "AsciiDataCurve" ); //-------------------------------------------------------------------------------------------------- RimAsciiDataCurve::RimAsciiDataCurve() { - CAF_PDM_InitObject( "ASCII Data Curve", ":/SummaryCurve16x16.png", "", "" ); + CAF_PDM_InitObject( "ASCII Data Curve", ":/SummaryCurve16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_plotAxis, "PlotAxis", "Axis", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_timeSteps, "TimeSteps", "Time Steps", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_values, "Values", "Values", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_title, "Title", "Title", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_plotAxis, "PlotAxis", "Axis" ); + CAF_PDM_InitFieldNoDefault( &m_timeSteps, "TimeSteps", "Time Steps" ); + CAF_PDM_InitFieldNoDefault( &m_values, "Values", "Values" ); + CAF_PDM_InitFieldNoDefault( &m_title, "Title", "Title" ); setSymbolSkipDistance( 10.0f ); setLineThickness( 2 ); @@ -97,9 +96,9 @@ void RimAsciiDataCurve::setYAxis( RiaDefines::PlotAxis plotAxis ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiaDefines::PlotAxis RimAsciiDataCurve::yAxis() const +RiuPlotAxis RimAsciiDataCurve::yAxis() const { - return m_plotAxis(); + return RiuPlotAxis( m_plotAxis() ); } //-------------------------------------------------------------------------------------------------- @@ -118,7 +117,7 @@ void RimAsciiDataCurve::updateZoomInParentPlot() RimSummaryPlot* plot = nullptr; firstAncestorOrThisOfType( plot ); - plot->updateZoomInQwt(); + plot->updateZoomInParentPlot(); } //-------------------------------------------------------------------------------------------------- @@ -135,13 +134,13 @@ void RimAsciiDataCurve::onLoadDataAndUpdate( bool updateParentPlot ) RimSummaryPlot* plot = nullptr; firstAncestorOrThisOfType( plot ); - bool isLogCurve = plot->isLogarithmicScaleEnabled( this->yAxis() ); + bool useLogarithmicScale = plot->isLogarithmicScaleEnabled( this->yAxis() ); if ( dateTimes.size() > 0 && dateTimes.size() == values.size() ) { if ( plot->timeAxisProperties()->timeMode() == RimSummaryTimeAxisProperties::DATE ) { - m_qwtPlotCurve->setSamplesFromTimeTAndYValues( dateTimes, values, isLogCurve ); + m_plotCurve->setSamplesFromTimeTAndYValues( dateTimes, values, useLogarithmicScale ); } else { @@ -157,17 +156,17 @@ void RimAsciiDataCurve::onLoadDataAndUpdate( bool updateParentPlot ) } } - m_qwtPlotCurve->setSamplesFromXValuesAndYValues( times, values, isLogCurve ); + m_plotCurve->setSamplesFromXValuesAndYValues( times, values, useLogarithmicScale ); } } else { - m_qwtPlotCurve->setSamplesFromTimeTAndYValues( std::vector(), std::vector(), isLogCurve ); + m_plotCurve->setSamplesFromTimeTAndYValues( std::vector(), std::vector(), useLogarithmicScale ); } updateZoomInParentPlot(); - if ( m_parentQwtPlot ) m_parentQwtPlot->replot(); + if ( m_parentPlot ) m_parentPlot->replot(); } updateQwtPlotAxis(); @@ -198,17 +197,7 @@ void RimAsciiDataCurve::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderi //-------------------------------------------------------------------------------------------------- void RimAsciiDataCurve::updateQwtPlotAxis() { - if ( m_qwtPlotCurve ) - { - if ( this->yAxis() == RiaDefines::PlotAxis::PLOT_AXIS_LEFT ) - { - m_qwtPlotCurve->setYAxis( QwtPlot::yLeft ); - } - else - { - m_qwtPlotCurve->setYAxis( QwtPlot::yRight ); - } - } + if ( m_plotCurve ) updateAxisInPlot( this->yAxis() ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimAsciiDataCurve.h b/ApplicationLibCode/ProjectDataModel/Summary/RimAsciiDataCurve.h index 9a61b06ed9..8ad41e539d 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimAsciiDataCurve.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimAsciiDataCurve.h @@ -52,13 +52,13 @@ class RimAsciiDataCurve : public RimPlotCurve std::vector yValues() const; const std::vector& timeSteps() const; - void setYAxis( RiaDefines::PlotAxis plotAxis ); - RiaDefines::PlotAxis yAxis() const; - void updateQwtPlotAxis(); + void setYAxis( RiaDefines::PlotAxis plotAxis ); + RiuPlotAxis yAxis() const; + void updateQwtPlotAxis(); void setTimeSteps( const std::vector& timeSteps ); void setValues( const std::vector& values ); - void setTitle( const QString& title ); + void setTitle( const QString& title ) override; protected: // RimPlotCurve overrides diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimCalculatedSummaryCase.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimCalculatedSummaryCase.cpp index 4123054e31..3cd314794e 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimCalculatedSummaryCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimCalculatedSummaryCase.cpp @@ -28,7 +28,7 @@ CAF_PDM_SOURCE_INIT( RimCalculatedSummaryCase, "CalculatedSummaryCase" ); //-------------------------------------------------------------------------------------------------- RimCalculatedSummaryCase::RimCalculatedSummaryCase() { - CAF_PDM_InitObject( "Calculated", ":/SummaryCase.svg", "", "" ); + CAF_PDM_InitObject( "Calculated", ":/SummaryCase.svg" ); m_calculatedCurveReader = nullptr; m_displayName = "Calculated"; @@ -75,14 +75,6 @@ RifSummaryReaderInterface* RimCalculatedSummaryCase::summaryReader() return m_calculatedCurveReader.get(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimCalculatedSummaryCase::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) -{ - // Nothing to do here -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimCalculatedSummaryCase.h b/ApplicationLibCode/ProjectDataModel/Summary/RimCalculatedSummaryCase.h index 955e127a6f..613f115d49 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimCalculatedSummaryCase.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimCalculatedSummaryCase.h @@ -42,7 +42,6 @@ class RimCalculatedSummaryCase : public RimSummaryCase QString caseName() const override; void createSummaryReaderInterface() override; RifSummaryReaderInterface* summaryReader() override; - void updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) override; void buildMetaData(); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimCalculatedSummaryCurveReader.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimCalculatedSummaryCurveReader.cpp index d926e8765e..422a20837d 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimCalculatedSummaryCurveReader.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimCalculatedSummaryCurveReader.cpp @@ -82,7 +82,7 @@ void RifCalculatedSummaryCurveReader::buildMetaData() { m_allResultAddresses.clear(); - for ( RimSummaryCalculation* calc : m_calculationCollection->calculations() ) + for ( RimUserDefinedCalculation* calc : m_calculationCollection->calculations() ) { m_allResultAddresses.insert( RifEclipseSummaryAddress::calculatedAddress( calc->description().toStdString(), calc->id() ) ); @@ -97,7 +97,7 @@ RimSummaryCalculation* { if ( m_calculationCollection && resultAddress.category() == RifEclipseSummaryAddress::SUMMARY_CALCULATED ) { - return m_calculationCollection->findCalculationById( resultAddress.id() ); + return dynamic_cast( m_calculationCollection->findCalculationById( resultAddress.id() ) ); } return nullptr; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimCsvUserData.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimCsvUserData.cpp index 3e20111ae2..c0098ac569 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimCsvUserData.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimCsvUserData.cpp @@ -36,10 +36,10 @@ CAF_PDM_SOURCE_INIT( RimCsvUserData, "RimCsvUserData" ); //-------------------------------------------------------------------------------------------------- RimCsvUserData::RimCsvUserData() { - CAF_PDM_InitObject( "Observed CSV Data File", ":/ObservedCSVDataFile16x16.png", "", "" ); + CAF_PDM_InitObject( "Observed CSV Data File", ":/ObservedCSVDataFile16x16.png" ); m_summaryHeaderFilename.uiCapability()->setUiName( "File" ); - CAF_PDM_InitFieldNoDefault( &m_parseOptions, "ParseOptions", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_parseOptions, "ParseOptions", "" ); m_parseOptions = new RicPasteAsciiDataToSummaryPlotFeatureUi(); m_parseOptions.uiCapability()->setUiTreeChildrenHidden( true ); m_parseOptions.uiCapability()->setUiTreeHidden( true ); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimDerivedEnsembleCaseCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimDerivedEnsembleCaseCollection.cpp index bbdf392470..e04384781b 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimDerivedEnsembleCaseCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimDerivedEnsembleCaseCollection.cpp @@ -31,6 +31,8 @@ #include "cafPdmUiPushButtonEditor.h" #include "cafPdmUiTreeSelectionEditor.h" +#include + #include namespace caf @@ -56,30 +58,30 @@ CAF_PDM_SOURCE_INIT( RimDerivedEnsembleCaseCollection, "RimDerivedEnsembleCaseCo //-------------------------------------------------------------------------------------------------- RimDerivedEnsembleCaseCollection::RimDerivedEnsembleCaseCollection() { - CAF_PDM_InitObject( "Delta Ensemble", ":/SummaryEnsemble.svg", "", "" ); + CAF_PDM_InitObject( "Delta Ensemble", ":/SummaryEnsemble.svg" ); - CAF_PDM_InitFieldNoDefault( &m_ensemble1, "Ensemble1", "Ensemble 1", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_ensemble1, "Ensemble1", "Ensemble 1" ); m_ensemble1.uiCapability()->setUiTreeChildrenHidden( true ); m_ensemble1.uiCapability()->setAutoAddingOptionFromValue( false ); - CAF_PDM_InitFieldNoDefault( &m_ensemble2, "Ensemble2", "Ensemble 2", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_ensemble2, "Ensemble2", "Ensemble 2" ); m_ensemble1.uiCapability()->setUiTreeChildrenHidden( true ); m_ensemble2.uiCapability()->setAutoAddingOptionFromValue( false ); - CAF_PDM_InitFieldNoDefault( &m_operator, "Operator", "Operator", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_operator, "Operator", "Operator" ); - CAF_PDM_InitField( &m_swapEnsemblesButton, "SwapEnsembles", false, "SwapEnsembles", "", "", "" ); + CAF_PDM_InitField( &m_swapEnsemblesButton, "SwapEnsembles", false, "SwapEnsembles" ); m_swapEnsemblesButton.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); m_swapEnsemblesButton.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); m_swapEnsemblesButton.xmlCapability()->disableIO(); - CAF_PDM_InitField( &m_caseCount, "CaseCount", QString( "" ), "Matching Cases", "", "", "" ); + CAF_PDM_InitField( &m_caseCount, "CaseCount", QString( "" ), "Matching Cases" ); m_caseCount.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitField( &m_matchOnParameters, "MatchOnParameters", false, "Match On Parameters", "", "", "" ); + CAF_PDM_InitField( &m_matchOnParameters, "MatchOnParameters", false, "Match On Parameters" ); - CAF_PDM_InitFieldNoDefault( &m_useFixedTimeStep, "UseFixedTimeStep", "Use Fixed Time Step", "", "", "" ); - CAF_PDM_InitField( &m_fixedTimeStepIndex, "FixedTimeStepIndex", 0, "Time Step", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_useFixedTimeStep, "UseFixedTimeStep", "Use Fixed Time Step" ); + CAF_PDM_InitField( &m_fixedTimeStepIndex, "FixedTimeStepIndex", 0, "Time Step" ); m_fixedTimeStepIndex.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); m_fixedTimeStepIndex.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); @@ -238,8 +240,7 @@ void RimDerivedEnsembleCaseCollection::onLoadDataAndUpdate() /// //-------------------------------------------------------------------------------------------------- QList - RimDerivedEnsembleCaseCollection::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) + RimDerivedEnsembleCaseCollection::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimDerivedEnsembleCaseCollection.h b/ApplicationLibCode/ProjectDataModel/Summary/RimDerivedEnsembleCaseCollection.h index 26b5dfec29..abfe910270 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimDerivedEnsembleCaseCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimDerivedEnsembleCaseCollection.h @@ -70,8 +70,7 @@ class RimDerivedEnsembleCaseCollection : public RimSummaryCaseCollection void onLoadDataAndUpdate() override; private: - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void defineEditorAttribute( const caf::PdmFieldHandle* field, diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimDerivedSummaryCase.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimDerivedSummaryCase.cpp index e64cab9f84..abd637bf21 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimDerivedSummaryCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimDerivedSummaryCase.cpp @@ -20,6 +20,7 @@ #include "RiaCurveMerger.h" #include "RiaLogging.h" +#include "RiaQDateTimeTools.h" #include "RifDerivedEnsembleReader.h" @@ -62,16 +63,16 @@ RimDerivedSummaryCase::RimDerivedSummaryCase() : m_summaryCase1( nullptr ) , m_summaryCase2( nullptr ) { - CAF_PDM_InitObject( "Summary Case", ":/SummaryCase.svg", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_summaryCase1, "SummaryCase1", "Summary Case 1", "", "", "" ); + CAF_PDM_InitObject( "Summary Case", ":/SummaryCase.svg" ); + CAF_PDM_InitFieldNoDefault( &m_summaryCase1, "SummaryCase1", "Summary Case 1" ); - CAF_PDM_InitFieldNoDefault( &m_operator, "Operator", "Operator", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_operator, "Operator", "Operator" ); - CAF_PDM_InitFieldNoDefault( &m_summaryCase2, "SummaryCase2", "Summary Case 2", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_summaryCase2, "SummaryCase2", "Summary Case 2" ); - CAF_PDM_InitFieldNoDefault( &m_useFixedTimeStep, "UseFixedTimeStep", "Use Fixed Time Step", "", "", "" ); - CAF_PDM_InitField( &m_fixedTimeStepIndex, "FixedTimeStepIndex", 0, "Time Step", "", "", "" ); - CAF_PDM_InitField( &m_inUse, "InUse", false, "In Use", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_useFixedTimeStep, "UseFixedTimeStep", "Use Fixed Time Step" ); + CAF_PDM_InitField( &m_fixedTimeStepIndex, "FixedTimeStepIndex", 0, "Time Step" ); + CAF_PDM_InitField( &m_inUse, "InUse", false, "In Use" ); m_fixedTimeStepIndex.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); m_fixedTimeStepIndex.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); } @@ -320,14 +321,6 @@ RifSummaryReaderInterface* RimDerivedSummaryCase::summaryReader() return m_reader.get(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimDerivedSummaryCase::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) -{ - // NOP -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -475,8 +468,7 @@ void RimDerivedSummaryCase::defineUiOrdering( QString uiConfigName, caf::PdmUiOr //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList - RimDerivedSummaryCase::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) +QList RimDerivedSummaryCase::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimDerivedSummaryCase.h b/ApplicationLibCode/ProjectDataModel/Summary/RimDerivedSummaryCase.h index 41bf519121..0b06112ad9 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimDerivedSummaryCase.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimDerivedSummaryCase.h @@ -79,7 +79,6 @@ class RimDerivedSummaryCase : public RimSummaryCase void createSummaryReaderInterface() override; RifSummaryReaderInterface* summaryReader() override; - void updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) override; void updateDisplayNameFromCases(); @@ -91,8 +90,7 @@ class RimDerivedSummaryCase : public RimSummaryCase private: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineEditorAttribute( const caf::PdmFieldHandle* field, diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveFilter.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveFilter.cpp index 629eae46db..ceaef0e107 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveFilter.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveFilter.cpp @@ -66,54 +66,49 @@ RimEnsembleCurveFilter::RimEnsembleCurveFilter() : m_lowerLimit( -DOUBLE_INF ) , m_upperLimit( DOUBLE_INF ) { - CAF_PDM_InitObject( "Ensemble Curve Filter", ":/Filter.svg", "", "" ); + CAF_PDM_InitObject( "Ensemble Curve Filter", ":/Filter.svg" ); - CAF_PDM_InitFieldNoDefault( &m_filterTitle, "FilterTitle", "Title", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_filterTitle, "FilterTitle", "Title" ); m_filterTitle.registerGetMethod( this, &RimEnsembleCurveFilter::description ); m_filterTitle.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitFieldNoDefault( &m_active, "Active", "Active", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_active, "Active", "Active" ); m_active = true; - CAF_PDM_InitFieldNoDefault( &m_filterMode, "FilterMode", "Filter Mode", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_filterMode, "FilterMode", "Filter Mode" ); - CAF_PDM_InitFieldNoDefault( &m_ensembleParameterName, "EnsembleParameter", "Ensemble Parameter", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_ensembleParameterName, "EnsembleParameter", "Ensemble Parameter" ); m_ensembleParameterName.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_objectiveValuesSummaryAddressesUiField, "SelectedObjectiveSummaryVar", "Vector", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_objectiveValuesSummaryAddressesUiField, "SelectedObjectiveSummaryVar", "Vector" ); m_objectiveValuesSummaryAddressesUiField.xmlCapability()->disableIO(); m_objectiveValuesSummaryAddressesUiField.uiCapability()->setUiEditorTypeName( caf::PdmUiLineEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_objectiveValuesSummaryAddresses, "ObjectiveSummaryAddress", "Summary Address", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_objectiveValuesSummaryAddresses, "ObjectiveSummaryAddress", "Summary Address" ); m_objectiveValuesSummaryAddresses.uiCapability()->setUiTreeHidden( true ); m_objectiveValuesSummaryAddresses.uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_objectiveValuesSelectSummaryAddressPushButton, - "SelectObjectiveSummaryAddress", - "", - "", - "", - "" ); + CAF_PDM_InitFieldNoDefault( &m_objectiveValuesSelectSummaryAddressPushButton, "SelectObjectiveSummaryAddress", "" ); caf::PdmUiPushButtonEditor::configureEditorForField( &m_objectiveValuesSelectSummaryAddressPushButton ); m_objectiveValuesSelectSummaryAddressPushButton.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); m_objectiveValuesSelectSummaryAddressPushButton = false; - CAF_PDM_InitFieldNoDefault( &m_objectiveFunction, "ObjectiveFunction", "Objective Function", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_objectiveFunction, "ObjectiveFunction", "Objective Function" ); m_objectiveFunction = new RimObjectiveFunction(); m_objectiveFunction.uiCapability()->setUiTreeHidden( true ); m_objectiveFunction.uiCapability()->setUiTreeChildrenHidden( true ); m_objectiveFunction->changed.connect( this, &RimEnsembleCurveFilter::onObjectionFunctionChanged ); - CAF_PDM_InitFieldNoDefault( &m_customObjectiveFunction, "CustomObjectiveFunction", "Custom Objective Function", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_customObjectiveFunction, "CustomObjectiveFunction", "Custom Objective Function" ); m_customObjectiveFunction.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_minValue, "MinValue", m_lowerLimit, "Min", "", "", "" ); + CAF_PDM_InitField( &m_minValue, "MinValue", m_lowerLimit, "Min" ); m_minValue.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_maxValue, "MaxValue", m_upperLimit, "Max", "", "", "" ); + CAF_PDM_InitField( &m_maxValue, "MaxValue", m_upperLimit, "Max" ); m_maxValue.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_categories, "Categories", "Categories", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_categories, "Categories", "Categories" ); setDeletable( true ); } @@ -243,7 +238,7 @@ std::vector RimEnsembleCurveFilter::summaryAddresses() //-------------------------------------------------------------------------------------------------- void RimEnsembleCurveFilter::setSummaryAddresses( std::vector addresses ) { - m_objectiveValuesSummaryAddresses.clear(); + m_objectiveValuesSummaryAddresses.deleteChildren(); for ( auto address : addresses ) { RimSummaryAddress* summaryAddress = new RimSummaryAddress(); @@ -255,8 +250,7 @@ void RimEnsembleCurveFilter::setSummaryAddresses( std::vector - RimEnsembleCurveFilter::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) +QList RimEnsembleCurveFilter::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; @@ -366,8 +360,8 @@ void RimEnsembleCurveFilter::fieldChangedByUi( const caf::PdmFieldHandle* change RifEclipseSummaryAddress candidateAdr = parentCurveSet()->summaryAddress(); - auto nativeQuantityName = RimObjectiveFunctionTools::nativeQuantityName( candidateAdr.quantityName() ); - candidateAdr.setQuantityName( nativeQuantityName ); + auto nativeQuantityName = RimObjectiveFunctionTools::nativeQuantityName( candidateAdr.vectorName() ); + candidateAdr.setVectorName( nativeQuantityName ); summaryAddress->setAddress( candidateAdr ); m_objectiveValuesSummaryAddresses.push_back( summaryAddress ); updateAddressesUiField(); @@ -390,7 +384,7 @@ void RimEnsembleCurveFilter::fieldChangedByUi( const caf::PdmFieldHandle* change RimSummaryCaseCollection* candidateEnsemble = parentCurveSet()->summaryCaseCollection(); std::vector candidateAddresses; - for ( auto address : m_objectiveValuesSummaryAddresses().childObjects() ) + for ( auto address : m_objectiveValuesSummaryAddresses().children() ) { candidateAddresses.push_back( address->address() ); } @@ -402,7 +396,7 @@ void RimEnsembleCurveFilter::fieldChangedByUi( const caf::PdmFieldHandle* change auto curveSelection = dlg.curveSelection(); if ( !curveSelection.empty() ) { - m_objectiveValuesSummaryAddresses.clear(); + m_objectiveValuesSummaryAddresses.deleteChildren(); for ( auto address : curveSelection ) { RimSummaryAddress* summaryAddress = new RimSummaryAddress(); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveFilter.h b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveFilter.h index 7ef9186092..95e6ae074b 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveFilter.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveFilter.h @@ -67,8 +67,7 @@ class RimEnsembleCurveFilter : public caf::PdmObject std::vector summaryAddresses() const; void setSummaryAddresses( std::vector addresses ); - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void updateAddressesUiField(); void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; caf::PdmFieldHandle* userDescriptionField() override; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveFilterCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveFilterCollection.cpp index 4fe1d65411..d62229c6c6 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveFilterCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveFilterCollection.cpp @@ -37,16 +37,16 @@ CAF_PDM_SOURCE_INIT( RimEnsembleCurveFilterCollection, "RimEnsembleCurveFilterCo //-------------------------------------------------------------------------------------------------- RimEnsembleCurveFilterCollection::RimEnsembleCurveFilterCollection() { - CAF_PDM_InitObject( "Curve Filters", ":/FilterCollection.svg", "", "" ); + CAF_PDM_InitObject( "Curve Filters", ":/FilterCollection.svg" ); - CAF_PDM_InitField( &m_active, "Active", true, "Active", "", "", "" ); + CAF_PDM_InitField( &m_active, "Active", true, "Active" ); - CAF_PDM_InitFieldNoDefault( &m_filters, "CurveFilters", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_filters, "CurveFilters", "" ); m_filters.uiCapability()->setUiTreeChildrenHidden( true ); // m_filters.uiCapability()->setUiEditorTypeName(caf::PdmUiTableViewEditor::uiEditorTypeName()); m_filters.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); - CAF_PDM_InitFieldNoDefault( &m_newFilterButton, "NewEnsembleFilter", "New Filter", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_newFilterButton, "NewEnsembleFilter", "New Filter" ); m_newFilterButton = false; m_newFilterButton.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); m_newFilterButton.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); @@ -67,7 +67,7 @@ RimEnsembleCurveFilter* RimEnsembleCurveFilterCollection::addFilter( const QStri //-------------------------------------------------------------------------------------------------- std::vector RimEnsembleCurveFilterCollection::filters() const { - return m_filters.childObjects(); + return m_filters.children(); } //-------------------------------------------------------------------------------------------------- @@ -98,8 +98,7 @@ int RimEnsembleCurveFilterCollection::countActiveFilters() const /// //-------------------------------------------------------------------------------------------------- QList - RimEnsembleCurveFilterCollection::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) + RimEnsembleCurveFilterCollection::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveFilterCollection.h b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveFilterCollection.h index 82a189b1ea..d072dbd191 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveFilterCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveFilterCollection.h @@ -48,8 +48,7 @@ class RimEnsembleCurveFilterCollection : public caf::PdmObject RiuTextContentFrame* makeFilterDescriptionFrame() const; private: - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; 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; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveInfoTextProvider.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveInfoTextProvider.cpp new file mode 100644 index 0000000000..f023f4835b --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveInfoTextProvider.cpp @@ -0,0 +1,39 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimEnsembleCurveInfoTextProvider.h" + +#include "RimSummaryCase.h" +#include "RimSummaryCurve.h" + +#include "RiuPlotCurve.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimEnsembleCurveInfoTextProvider::curveInfoText( RiuPlotCurve* riuCurve ) const +{ + // RiuPlotCurve* riuCurve = dynamic_cast( curve ); + RimSummaryCurve* sumCurve = nullptr; + if ( riuCurve ) + { + sumCurve = dynamic_cast( riuCurve->ownerRimCurve() ); + } + + return sumCurve && sumCurve->summaryCaseY() ? sumCurve->summaryCaseY()->displayCaseName() : ""; +} diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveInfoTextProvider.h b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveInfoTextProvider.h new file mode 100644 index 0000000000..12ce1ab84d --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveInfoTextProvider.h @@ -0,0 +1,32 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RiuPlotCurveInfoTextProvider.h" + +#include + +//================================================================================================== +// +//================================================================================================== +class RimEnsembleCurveInfoTextProvider : public RiuPlotCurveInfoTextProvider +{ +public: + QString curveInfoText( RiuPlotCurve* ) const override; +}; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 0b7d7573e8..249b215956 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -21,8 +21,9 @@ #include "RiaColorTools.h" #include "RiaGuiApplication.h" #include "RiaPreferences.h" +#include "RiaQDateTimeTools.h" #include "RiaResultNames.h" -#include "RiaSummaryCurveAnalyzer.h" +#include "RiaSummaryAddressAnalyzer.h" #include "RiaSummaryCurveDefinition.h" #include "RiaTimeTTools.h" @@ -41,6 +42,7 @@ #include "RimEnsembleStatisticsCase.h" #include "RimObjectiveFunction.h" #include "RimObjectiveFunctionTools.h" +#include "RimPlotAxisPropertiesInterface.h" #include "RimProject.h" #include "RimRegularLegendConfig.h" #include "RimSummaryAddress.h" @@ -48,15 +50,14 @@ #include "RimSummaryCaseCollection.h" #include "RimSummaryCurve.h" #include "RimSummaryCurveAutoName.h" -#include "RimSummaryFilter.h" #include "RimSummaryPlot.h" #include "RimTimeStepFilter.h" #include "RiuAbstractLegendFrame.h" #include "RiuDraggableOverlayFrame.h" +#include "RiuPlotCurve.h" +#include "RiuPlotCurveSymbol.h" #include "RiuPlotMainWindow.h" -#include "RiuQwtPlotCurve.h" -#include "RiuSummaryQwtPlot.h" #include "RiuSummaryVectorSelectionDialog.h" #include "RiuTextContentFrame.h" @@ -71,23 +72,13 @@ #include "cafPdmUiTreeSelectionEditor.h" #include "cafTitledOverlayFrame.h" -#include "cvfScalarMapper.h" - -#include "qwt_plot_curve.h" -#include "qwt_symbol.h" - #include -//-------------------------------------------------------------------------------------------------- -/// Internal constants -//-------------------------------------------------------------------------------------------------- -#define DOUBLE_INF std::numeric_limits::infinity() - //-------------------------------------------------------------------------------------------------- /// Internal functions //-------------------------------------------------------------------------------------------------- -RiuQwtSymbol::PointSymbolEnum statisticsCurveSymbolFromAddress( const RifEclipseSummaryAddress& address ); -int statisticsCurveSymbolSize( RiuQwtSymbol::PointSymbolEnum symbol ); +RiuPlotCurveSymbol::PointSymbolEnum statisticsCurveSymbolFromAddress( const RifEclipseSummaryAddress& address ); +int statisticsCurveSymbolSize( RiuPlotCurveSymbol::PointSymbolEnum symbol ); CAF_PDM_SOURCE_INIT( RimEnsembleCurveSet, "RimEnsembleCurveSet" ); @@ -98,131 +89,123 @@ RimEnsembleCurveSet::RimEnsembleCurveSet() : filterChanged( this ) { - CAF_PDM_InitObject( "Ensemble Curve Set", ":/EnsembleCurveSet16x16.png", "", "" ); + CAF_PDM_InitObject( "Ensemble Curve Set", ":/EnsembleCurveSet16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_curves, "EnsembleCurveSet", "Ensemble Curve Set", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_curves, "EnsembleCurveSet", "Ensemble Curve Set" ); m_curves.uiCapability()->setUiTreeHidden( true ); m_curves.uiCapability()->setUiTreeChildrenHidden( false ); - CAF_PDM_InitField( &m_showCurves, "IsActive", true, "Show Curves", "", "", "" ); + CAF_PDM_InitField( &m_showCurves, "IsActive", true, "Show Curves" ); m_showCurves.uiCapability()->setUiHidden( true ); // Y Values - CAF_PDM_InitFieldNoDefault( &m_yValuesSummaryCaseCollection, "SummaryGroup", "Ensemble", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_yValuesSummaryCaseCollection, "SummaryGroup", "Ensemble" ); m_yValuesSummaryCaseCollection.uiCapability()->setUiTreeChildrenHidden( true ); m_yValuesSummaryCaseCollection.uiCapability()->setAutoAddingOptionFromValue( false ); - CAF_PDM_InitFieldNoDefault( &m_yValuesSummaryAddressUiField, "SelectedVariableDisplayVar", "Vector", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_yValuesSummaryAddressUiField, "SelectedVariableDisplayVar", "Vector" ); m_yValuesSummaryAddressUiField.xmlCapability()->disableIO(); m_yValuesSummaryAddressUiField.uiCapability()->setUiEditorTypeName( caf::PdmUiLineEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_yValuesSummaryAddress, "SummaryAddress", "Summary Address", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_yValuesSummaryAddress, "SummaryAddress", "Summary Address" ); m_yValuesSummaryAddress.uiCapability()->setUiTreeHidden( true ); m_yValuesSummaryAddress.uiCapability()->setUiTreeChildrenHidden( true ); m_yValuesSummaryAddress = new RimSummaryAddress; - CAF_PDM_InitFieldNoDefault( &m_yPushButtonSelectSummaryAddress, "SelectAddress", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_yPushButtonSelectSummaryAddress, "SelectAddress", "" ); caf::PdmUiPushButtonEditor::configureEditorForField( &m_yPushButtonSelectSummaryAddress ); m_yPushButtonSelectSummaryAddress.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); m_yPushButtonSelectSummaryAddress = false; - CAF_PDM_InitFieldNoDefault( &m_resampling, "Resampling", "Resampling", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_resampling, "Resampling", "Resampling" ); - CAF_PDM_InitField( &m_colorMode, "ColorMode", caf::AppEnum( ColorMode::SINGLE_COLOR ), "Coloring Mode", "", "", "" ); + CAF_PDM_InitField( &m_colorMode, "ColorMode", caf::AppEnum( ColorMode::SINGLE_COLOR ), "Coloring Mode" ); - CAF_PDM_InitField( &m_color, "Color", RiaColorTools::textColor3f(), "Color", "", "", "" ); + CAF_PDM_InitField( &m_color, "Color", RiaColorTools::textColor3f(), "Color" ); - CAF_PDM_InitField( &m_ensembleParameter, "EnsembleParameter", QString( "" ), "Ensemble Parameter", "", "", "" ); + CAF_PDM_InitField( &m_ensembleParameter, "EnsembleParameter", QString( "" ), "Ensemble Parameter" ); m_ensembleParameter.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_objectiveValuesSummaryAddressesUiField, "SelectedObjectiveSummaryVar", "Vector", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_objectiveValuesSummaryAddressesUiField, "SelectedObjectiveSummaryVar", "Vector" ); m_objectiveValuesSummaryAddressesUiField.xmlCapability()->disableIO(); m_objectiveValuesSummaryAddressesUiField.uiCapability()->setUiEditorTypeName( caf::PdmUiLineEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_objectiveValuesSummaryAddresses, "ObjectiveSummaryAddress", "Summary Address", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_objectiveValuesSummaryAddresses, "ObjectiveSummaryAddress", "Summary Address" ); m_objectiveValuesSummaryAddresses.uiCapability()->setUiTreeHidden( true ); m_objectiveValuesSummaryAddresses.uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_objectiveValuesSelectSummaryAddressPushButton, - "SelectObjectiveSummaryAddress", - "", - "", - "", - "" ); + CAF_PDM_InitFieldNoDefault( &m_objectiveValuesSelectSummaryAddressPushButton, "SelectObjectiveSummaryAddress", "" ); caf::PdmUiPushButtonEditor::configureEditorForField( &m_objectiveValuesSelectSummaryAddressPushButton ); m_objectiveValuesSelectSummaryAddressPushButton.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); m_objectiveValuesSelectSummaryAddressPushButton = false; - CAF_PDM_InitFieldNoDefault( &m_customObjectiveFunction, "CustomObjectiveFunction", "Objective Function", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_customObjectiveFunction, "CustomObjectiveFunction", "Objective Function" ); m_customObjectiveFunction.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_showObjectiveFunctionFormula, "ShowObjectiveFunctionFormula", true, "Show Text Box in Plot", "", "", "" ); + CAF_PDM_InitField( &m_showObjectiveFunctionFormula, "ShowObjectiveFunctionFormula", true, "Show Text Box in Plot" ); - CAF_PDM_InitFieldNoDefault( &m_minDateRange, "MinDateRange", "From", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_minDateRange, "MinDateRange", "From" ); m_minDateRange.uiCapability()->setUiEditorTypeName( caf::PdmUiDateEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_minTimeStep, "MinTimeStep", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_minTimeStep, "MinTimeStep", "" ); m_minTimeStep.uiCapability()->setUiEditorTypeName( caf::PdmUiSliderEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_maxDateRange, "MaxDateRange", "To", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_maxDateRange, "MaxDateRange", "To" ); m_maxDateRange.uiCapability()->setUiEditorTypeName( caf::PdmUiDateEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_maxTimeStep, "MaxTimeStep", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_maxTimeStep, "MaxTimeStep", "" ); m_maxTimeStep.uiCapability()->setUiEditorTypeName( caf::PdmUiSliderEditor::uiEditorTypeName() ); // Time Step Selection - CAF_PDM_InitFieldNoDefault( &m_timeStepFilter, "TimeStepFilter", "Available Time Steps", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_selectedTimeSteps, "TimeSteps", "Select Time Steps", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_timeStepFilter, "TimeStepFilter", "Available Time Steps" ); + CAF_PDM_InitFieldNoDefault( &m_selectedTimeSteps, "TimeSteps", "Select Time Steps" ); m_selectedTimeSteps.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); m_selectedTimeSteps.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); - CAF_PDM_InitFieldNoDefault( &m_plotAxis, "PlotAxis", "Axis", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_plotAxis_OBSOLETE, "PlotAxis", "Axis" ); + m_plotAxis_OBSOLETE.xmlCapability()->setIOWritable( false ); + + CAF_PDM_InitFieldNoDefault( &m_plotAxisProperties, "Axis", "Axis" ); - CAF_PDM_InitFieldNoDefault( &m_legendConfig, "LegendConfig", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_legendConfig, "LegendConfig", "" ); m_legendConfig = new RimRegularLegendConfig(); m_legendConfig->setColorLegend( RimRegularLegendConfig::mapToColorLegend( RimEnsembleCurveSetColorManager::DEFAULT_ENSEMBLE_COLOR_RANGE ) ); - CAF_PDM_InitFieldNoDefault( &m_curveFilters, "CurveFilters", "Curve Filters", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_curveFilters, "CurveFilters", "Curve Filters" ); m_curveFilters = new RimEnsembleCurveFilterCollection(); m_curveFilters->setUiTreeHidden( true ); m_curveFilters->uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_customObjectiveFunctions, - "CustomObjectiveFunctions", - "Custom Objective Functions", - "", - "", - "" ); + CAF_PDM_InitFieldNoDefault( &m_customObjectiveFunctions, "CustomObjectiveFunctions", "Custom Objective Functions" ); m_customObjectiveFunctions = new RimCustomObjectiveFunctionCollection(); m_customObjectiveFunctions->objectiveFunctionChanged.connect( this, &RimEnsembleCurveSet::onCustomObjectiveFunctionChanged ); - CAF_PDM_InitFieldNoDefault( &m_objectiveFunction, "ObjectiveFunction", "Objective Function", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_objectiveFunction, "ObjectiveFunction", "Objective Function" ); m_objectiveFunction = new RimObjectiveFunction(); m_objectiveFunction.uiCapability()->setUiTreeHidden( true ); m_objectiveFunction->changed.connect( this, &RimEnsembleCurveSet::onObjectiveFunctionChanged ); - CAF_PDM_InitFieldNoDefault( &m_statistics, "Statistics", "Statistics", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_statistics, "Statistics", "Statistics" ); m_statistics = new RimEnsembleStatistics( this ); m_statistics.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitField( &m_userDefinedName, "UserDefinedName", QString( "Ensemble Curve Set" ), "Curve Set Name", "", "", "" ); + CAF_PDM_InitField( &m_userDefinedName, "UserDefinedName", QString( "Ensemble Curve Set" ), "Curve Set Name" ); - CAF_PDM_InitFieldNoDefault( &m_autoGeneratedName, "AutoGeneratedName", "Curve Set Name", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_autoGeneratedName, "AutoGeneratedName", "Curve Set Name" ); m_autoGeneratedName.registerGetMethod( this, &RimEnsembleCurveSet::createAutoName ); m_autoGeneratedName.uiCapability()->setUiReadOnly( true ); m_autoGeneratedName.xmlCapability()->disableIO(); - CAF_PDM_InitField( &m_isUsingAutoName, "AutoName", true, "Auto Name", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_summaryAddressNameTools, "SummaryAddressNameTools", "SummaryAddressNameTools", "", "", "" ); + CAF_PDM_InitField( &m_isUsingAutoName, "AutoName", true, "Auto Name" ); + CAF_PDM_InitFieldNoDefault( &m_summaryAddressNameTools, "SummaryAddressNameTools", "SummaryAddressNameTools" ); m_summaryAddressNameTools.uiCapability()->setUiTreeHidden( true ); m_summaryAddressNameTools.uiCapability()->setUiTreeChildrenHidden( true ); m_summaryAddressNameTools = new RimSummaryCurveAutoName; - m_qwtPlotCurveForLegendText = new QwtPlotCurve; - m_qwtPlotCurveForLegendText->setLegendAttribute( QwtPlotCurve::LegendShowSymbol, true ); + m_plotCurveForLegendText = nullptr; m_ensembleStatCase.reset( new RimEnsembleStatisticsCase( this ) ); m_ensembleStatCase->createSummaryReaderInterface(); @@ -231,14 +214,6 @@ RimEnsembleCurveSet::RimEnsembleCurveSet() m_disableStatisticCurves = false; m_isCurveSetFiltered = false; - // Obsolete fields - - CAF_PDM_InitFieldNoDefault( &m_yValuesSummaryFilter_OBSOLETE, "VarListFilter", "Filter", "", "", "" ); - m_yValuesSummaryFilter_OBSOLETE.uiCapability()->setUiTreeChildrenHidden( true ); - m_yValuesSummaryFilter_OBSOLETE.uiCapability()->setUiTreeHidden( true ); - m_yValuesSummaryFilter_OBSOLETE.xmlCapability()->setIOWritable( false ); - m_yValuesSummaryFilter_OBSOLETE = new RimSummaryFilter_OBSOLETE; - setDeletable( true ); } @@ -247,16 +222,16 @@ RimEnsembleCurveSet::RimEnsembleCurveSet() //-------------------------------------------------------------------------------------------------- RimEnsembleCurveSet::~RimEnsembleCurveSet() { - m_curves.deleteAllChildObjects(); + m_curves.deleteChildren(); RimSummaryPlot* parentPlot; firstAncestorOrThisOfType( parentPlot ); - if ( parentPlot && parentPlot->viewer() ) + if ( parentPlot && parentPlot->plotWidget() ) { - m_qwtPlotCurveForLegendText->detach(); + if ( m_plotCurveForLegendText ) m_plotCurveForLegendText->detach(); if ( m_legendOverlayFrame ) { - parentPlot->viewer()->removeOverlayFrame( m_legendOverlayFrame ); + parentPlot->plotWidget()->removeOverlayFrame( m_legendOverlayFrame ); } } if ( m_legendOverlayFrame ) @@ -275,7 +250,7 @@ RimEnsembleCurveSet::~RimEnsembleCurveSet() delete m_objectiveFunctionOverlayFrame; } - delete m_qwtPlotCurveForLegendText; + delete m_plotCurveForLegendText; } //-------------------------------------------------------------------------------------------------- @@ -323,44 +298,40 @@ void RimEnsembleCurveSet::loadDataAndUpdate( bool updateParentPlot ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsembleCurveSet::setParentQwtPlotNoReplot( QwtPlot* plot ) +void RimEnsembleCurveSet::setParentPlotNoReplot( RiuPlotWidget* plot ) { for ( RimSummaryCurve* curve : m_curves ) { - curve->setParentQwtPlotNoReplot( plot ); + curve->setParentPlotNoReplot( plot ); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsembleCurveSet::detachQwtCurves() +void RimEnsembleCurveSet::deletePlotCurves() { for ( RimSummaryCurve* curve : m_curves ) { - curve->detachQwtCurve(); + curve->deletePlotCurve(); } - m_qwtPlotCurveForLegendText->detach(); + if ( m_plotCurveForLegendText ) + { + m_plotCurveForLegendText->detach(); + delete m_plotCurveForLegendText; + m_plotCurveForLegendText = nullptr; + } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsembleCurveSet::reattachQwtCurves() +void RimEnsembleCurveSet::reattachPlotCurves() { for ( RimSummaryCurve* curve : m_curves ) { - curve->reattachQwtCurve(); - } - - m_qwtPlotCurveForLegendText->detach(); - - RimSummaryPlot* plot = nullptr; - firstAncestorOrThisOfType( plot ); - if ( plot ) - { - m_qwtPlotCurveForLegendText->attach( plot->viewer() ); + curve->reattach(); } } @@ -373,7 +344,7 @@ void RimEnsembleCurveSet::addCurve( RimSummaryCurve* curve ) { RimSummaryPlot* plot; firstAncestorOrThisOfType( plot ); - if ( plot ) curve->setParentQwtPlotNoReplot( plot->viewer() ); + if ( plot && plot->plotWidget() ) curve->setParentPlotNoReplot( plot->plotWidget() ); curve->setColor( m_color ); m_curves.push_back( curve ); @@ -387,7 +358,7 @@ void RimEnsembleCurveSet::deleteCurve( RimSummaryCurve* curve ) { if ( curve ) { - m_curves.removeChildObject( curve ); + m_curves.removeChild( curve ); delete curve; } } @@ -401,6 +372,8 @@ void RimEnsembleCurveSet::setSummaryAddress( RifEclipseSummaryAddress address ) RimSummaryAddress* summaryAddress = new RimSummaryAddress(); summaryAddress->setAddress( address ); m_objectiveValuesSummaryAddresses.push_back( summaryAddress ); + + m_statistics->setShowStatisticsCurves( !address.isHistoryVector() ); } //-------------------------------------------------------------------------------------------------- @@ -416,7 +389,7 @@ RifEclipseSummaryAddress RimEnsembleCurveSet::summaryAddress() const //-------------------------------------------------------------------------------------------------- std::vector RimEnsembleCurveSet::curves() const { - return m_curves.childObjects(); + return m_curves.children(); } //-------------------------------------------------------------------------------------------------- @@ -642,10 +615,6 @@ void RimEnsembleCurveSet::fieldChangedByUi( const caf::PdmFieldHandle* changedFi updateConnectedEditors(); - RimSummaryPlot* summaryPlot = nullptr; - this->firstAncestorOrThisOfTypeAsserted( summaryPlot ); - summaryPlot->updateConnectedEditors(); - updateTextInPlot = true; } else if ( changedField == &m_yValuesSummaryAddressUiField ) @@ -749,20 +718,21 @@ void RimEnsembleCurveSet::fieldChangedByUi( const caf::PdmFieldHandle* changedFi } else if ( changedField == &m_minDateRange || changedField == &m_maxDateRange ) { - m_minTimeStep = RiaTimeTTools::fromQDateTime( QDateTime( m_minDateRange() ) ); - m_maxTimeStep = RiaTimeTTools::fromQDateTime( QDateTime( m_maxDateRange() ) ); + m_minTimeStep = RiaTimeTTools::fromQDateTime( RiaQDateTimeTools::createDateTime( m_minDateRange() ) ); + m_maxTimeStep = RiaTimeTTools::fromQDateTime( RiaQDateTimeTools::createDateTime( m_maxDateRange() ) ); updateCurveColors(); updateTimeAnnotations(); } - else if ( changedField == &m_plotAxis ) + else if ( changedField == &m_plotAxisProperties ) { for ( RimSummaryCurve* curve : curves() ) { - curve->setLeftOrRightAxisY( m_plotAxis() ); + curve->setLeftOrRightAxisY( axisY() ); } - updateQwtPlotAxis(); + updatePlotAxis(); plot->updateAxes(); + plot->updateAll(); updateTextInPlot = true; } @@ -803,7 +773,7 @@ void RimEnsembleCurveSet::fieldChangedByUi( const caf::PdmFieldHandle* changedFi plot->updateConnectedEditors(); RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow(); - mainPlotWindow->updateSummaryPlotToolBar(); + mainPlotWindow->updateMultiPlotToolBar(); } } @@ -816,7 +786,7 @@ void RimEnsembleCurveSet::fieldChangedByUi( const caf::PdmFieldHandle* changedFi RimSummaryCaseCollection* candidateEnsemble = m_yValuesSummaryCaseCollection(); std::vector candidateAddresses; - for ( auto address : m_objectiveValuesSummaryAddresses().childObjects() ) + for ( auto address : m_objectiveValuesSummaryAddresses().children() ) { candidateAddresses.push_back( address->address() ); } @@ -828,7 +798,7 @@ void RimEnsembleCurveSet::fieldChangedByUi( const caf::PdmFieldHandle* changedFi auto curveSelection = dlg.curveSelection(); if ( !curveSelection.empty() ) { - m_objectiveValuesSummaryAddresses.clear(); + m_objectiveValuesSummaryAddresses.deleteChildren(); for ( auto address : curveSelection ) { RimSummaryAddress* summaryAddress = new RimSummaryAddress(); @@ -879,7 +849,7 @@ void RimEnsembleCurveSet::defineUiOrdering( QString uiConfigName, caf::PdmUiOrde curveDataGroup->add( &m_yValuesSummaryAddressUiField ); curveDataGroup->add( &m_yPushButtonSelectSummaryAddress, { false, 1, 0 } ); curveDataGroup->add( &m_resampling ); - curveDataGroup->add( &m_plotAxis ); + curveDataGroup->add( &m_plotAxisProperties ); } appendColorGroup( uiOrdering ); @@ -1101,8 +1071,7 @@ void RimEnsembleCurveSet::defineEditorAttribute( const caf::PdmFieldHandle* fiel //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimEnsembleCurveSet::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RimEnsembleCurveSet::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; @@ -1184,11 +1153,12 @@ QList RimEnsembleCurveSet::calculateValueOptions( const filteredTimeStepIndices.erase( std::unique( filteredTimeStepIndices.begin(), filteredTimeStepIndices.end() ), filteredTimeStepIndices.end() ); - QString dateFormatString = RiaQDateTimeTools::dateFormatString( RiaPreferences::current()->dateFormat(), - RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH_DAY ); + QString dateFormatString = + RiaQDateTimeTools::dateFormatString( RiaPreferences::current()->dateFormat(), + RiaDefines::DateFormatComponents::DATE_FORMAT_YEAR_MONTH_DAY ); QString timeFormatString = RiaQDateTimeTools::timeFormatString( RiaPreferences::current()->timeFormat(), - RiaQDateTimeTools::TimeFormatComponents::TIME_FORMAT_HOUR_MINUTE ); + RiaDefines::TimeFormatComponents::TIME_FORMAT_HOUR_MINUTE ); QString dateTimeFormatString = QString( "%1 %2" ).arg( dateFormatString ).arg( timeFormatString ); bool showTime = m_timeStepFilter() == RimTimeStepFilter::TS_ALL || @@ -1222,6 +1192,16 @@ QList RimEnsembleCurveSet::calculateValueOptions( const options.push_back( caf::PdmOptionItemInfo( name, objFunc ) ); } } + else if ( fieldNeedingOptions == &m_plotAxisProperties ) + { + RimSummaryPlot* plot = nullptr; + firstAncestorOrThisOfTypeAsserted( plot ); + + for ( auto axis : plot->plotAxes() ) + { + options.push_back( caf::PdmOptionItemInfo( axis->objectName(), axis ) ); + } + } return options; } @@ -1338,26 +1318,26 @@ void RimEnsembleCurveSet::updateFilterLegend() { RimSummaryPlot* plot; firstAncestorOrThisOfType( plot ); - if ( plot && plot->viewer() ) + if ( plot && plot->plotWidget() ) { if ( m_curveFilters()->isActive() && m_curveFilters()->countActiveFilters() > 0 ) { if ( !m_filterOverlayFrame ) { m_filterOverlayFrame = - new RiuDraggableOverlayFrame( plot->viewer()->canvas(), plot->viewer()->overlayMargins() ); + new RiuDraggableOverlayFrame( plot->plotWidget(), plot->plotWidget()->overlayMargins() ); } m_filterOverlayFrame->setContentFrame( m_curveFilters()->makeFilterDescriptionFrame() ); - plot->viewer()->addOverlayFrame( m_filterOverlayFrame ); + plot->plotWidget()->addOverlayFrame( m_filterOverlayFrame ); } else { if ( m_filterOverlayFrame ) { - plot->viewer()->removeOverlayFrame( m_filterOverlayFrame ); + plot->plotWidget()->removeOverlayFrame( m_filterOverlayFrame ); } } - plot->viewer()->scheduleReplot(); + plot->scheduleReplotIfVisible(); } } @@ -1368,7 +1348,7 @@ void RimEnsembleCurveSet::updateObjectiveFunctionLegend() { RimSummaryPlot* plot; firstAncestorOrThisOfType( plot ); - if ( plot && plot->viewer() ) + if ( plot && plot->plotWidget() ) { if ( ( m_colorMode == ColorMode::BY_OBJECTIVE_FUNCTION || m_colorMode == ColorMode::BY_CUSTOM_OBJECTIVE_FUNCTION ) && m_showObjectiveFunctionFormula() ) @@ -1376,14 +1356,14 @@ void RimEnsembleCurveSet::updateObjectiveFunctionLegend() if ( !m_objectiveFunctionOverlayFrame ) { m_objectiveFunctionOverlayFrame = - new RiuDraggableOverlayFrame( plot->viewer()->canvas(), plot->viewer()->overlayMargins() ); + new RiuDraggableOverlayFrame( plot->plotWidget(), plot->plotWidget()->overlayMargins() ); } QString title; QString description; if ( m_colorMode() == ColorMode::BY_OBJECTIVE_FUNCTION ) { std::vector addresses; - for ( auto address : m_objectiveValuesSummaryAddresses().childObjects() ) + for ( auto address : m_objectiveValuesSummaryAddresses().children() ) { addresses.push_back( address->address() ); } @@ -1396,7 +1376,7 @@ void RimEnsembleCurveSet::updateObjectiveFunctionLegend() else if ( m_colorMode() == ColorMode::BY_CUSTOM_OBJECTIVE_FUNCTION && m_customObjectiveFunction() ) { std::vector addresses; - for ( auto address : m_objectiveValuesSummaryAddresses().childObjects() ) + for ( auto address : m_objectiveValuesSummaryAddresses().children() ) { addresses.push_back( address->address() ); } @@ -1408,18 +1388,18 @@ void RimEnsembleCurveSet::updateObjectiveFunctionLegend() { m_objectiveFunctionOverlayFrame->setContentFrame( new RiuTextContentFrame( nullptr, title, description ) ); m_objectiveFunctionOverlayFrame->setMaximumWidth( 10000 ); - plot->viewer()->addOverlayFrame( m_objectiveFunctionOverlayFrame ); + plot->plotWidget()->addOverlayFrame( m_objectiveFunctionOverlayFrame ); } } else { if ( m_objectiveFunctionOverlayFrame ) { - plot->viewer()->removeOverlayFrame( m_objectiveFunctionOverlayFrame ); + plot->plotWidget()->removeOverlayFrame( m_objectiveFunctionOverlayFrame ); } } } - plot->viewer()->scheduleReplot(); + plot->scheduleReplotIfVisible(); } //-------------------------------------------------------------------------------------------------- @@ -1586,29 +1566,34 @@ void RimEnsembleCurveSet::updateCurveColors() curvesToColor[i]->updateCurveAppearance(); } + if ( m_plotCurveForLegendText ) + { + m_plotCurveForLegendText->setColor( RiaColorTools::toQColor( m_color ) ); + } + RimSummaryPlot* plot; firstAncestorOrThisOfType( plot ); - if ( plot && plot->viewer() ) + if ( plot && plot->plotWidget() ) { if ( m_yValuesSummaryCaseCollection() && isCurvesVisible() && m_colorMode != ColorMode::SINGLE_COLOR && m_legendConfig->showLegend() ) { if ( !m_legendOverlayFrame ) { - m_legendOverlayFrame = - new RiuDraggableOverlayFrame( plot->viewer()->canvas(), plot->viewer()->overlayMargins() ); + m_legendOverlayFrame = new RiuDraggableOverlayFrame( plot->plotWidget()->getParentForOverlay(), + plot->plotWidget()->overlayMargins() ); } m_legendOverlayFrame->setContentFrame( m_legendConfig->makeLegendFrame() ); - plot->viewer()->addOverlayFrame( m_legendOverlayFrame ); + plot->plotWidget()->addOverlayFrame( m_legendOverlayFrame ); } else { if ( m_legendOverlayFrame ) { - plot->viewer()->removeOverlayFrame( m_legendOverlayFrame ); + plot->plotWidget()->removeOverlayFrame( m_legendOverlayFrame ); } } - plot->viewer()->scheduleReplot(); + plot->scheduleReplotIfVisible(); } } @@ -1661,11 +1646,11 @@ void RimEnsembleCurveSet::updateAddressesUiField() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsembleCurveSet::updateQwtPlotAxis() +void RimEnsembleCurveSet::updatePlotAxis() { for ( RimSummaryCurve* curve : curves() ) { - curve->updateQwtPlotAxis(); + curve->updatePlotAxis(); } } @@ -1679,11 +1664,13 @@ void RimEnsembleCurveSet::updateEnsembleCurves( const std::vectordetach(); + if ( m_plotCurveForLegendText ) m_plotCurveForLegendText->detach(); deleteStatisticsCurves(); if ( m_statistics->hideEnsembleCurves() ) return; + setLeftOrRightAxisY( axisY() ); + RimSummaryAddress* addr = m_yValuesSummaryAddress(); if ( plot && addr->address().category() != RifEclipseSummaryAddress::SUMMARY_INVALID ) { @@ -1696,12 +1683,19 @@ void RimEnsembleCurveSet::updateEnsembleCurves( const std::vectorsetSummaryCaseY( sumCase ); curve->setSummaryAddressYAndApplyInterpolation( addr->address() ); - curve->setLeftOrRightAxisY( m_plotAxis() ); curve->setResampling( m_resampling() ); + int lineThickness = 1; + if ( addr->address().isHistoryVector() ) + { + lineThickness = 2; + curve->setCurveAppearanceFromCaseType(); + } + curve->setLineThickness( lineThickness ); + addCurve( curve ); - curve->updateCurveVisibility(); + curve->setLeftOrRightAxisY( axisY() ); newSummaryCurves.push_back( curve ); } @@ -1715,22 +1709,25 @@ void RimEnsembleCurveSet::updateEnsembleCurves( const std::vectorloadDataAndUpdate( false ); - newSummaryCurves[i]->updateQwtPlotAxis(); - if ( newSummaryCurves[i]->qwtPlotCurve() ) - { - newSummaryCurves[i]->qwtPlotCurve()->setItemAttribute( QwtPlotItem::Legend, false ); - } + newSummaryCurves[i]->updatePlotAxis(); + newSummaryCurves[i]->setShowInLegend( false ); } - - if ( plot->viewer() ) m_qwtPlotCurveForLegendText->attach( plot->viewer() ); } - if ( plot->viewer() ) + if ( plot->plotWidget() ) { - if ( plot->legendsVisible() ) plot->viewer()->updateLegend(); - plot->viewer()->scheduleReplot(); + if ( plot->legendsVisible() ) plot->plotWidget()->updateLegend(); + plot->scheduleReplotIfVisible(); plot->updateAxes(); plot->updatePlotInfoLabel(); + + if ( !m_plotCurveForLegendText ) + { + m_plotCurveForLegendText = + plot->plotWidget()->createPlotCurve( nullptr, "", RiaColorTools::toQColor( m_color ) ); + } + m_plotCurveForLegendText->attachToPlot( plot->plotWidget() ); + updateEnsembleLegendItem(); } } updateCurveColors(); @@ -1774,48 +1771,49 @@ void RimEnsembleCurveSet::updateStatisticsCurves( const std::vectorshowP10Curve() && m_ensembleStatCase->hasP10Data() ) addresses.push_back( - SAddr::ensembleStatisticsAddress( ENSEMBLE_STAT_P10_QUANTITY_NAME, dataAddress.quantityName() ) ); + SAddr::ensembleStatisticsAddress( ENSEMBLE_STAT_P10_QUANTITY_NAME, dataAddress.vectorName() ) ); if ( m_statistics->showP50Curve() && m_ensembleStatCase->hasP50Data() ) addresses.push_back( - SAddr::ensembleStatisticsAddress( ENSEMBLE_STAT_P50_QUANTITY_NAME, dataAddress.quantityName() ) ); + SAddr::ensembleStatisticsAddress( ENSEMBLE_STAT_P50_QUANTITY_NAME, dataAddress.vectorName() ) ); if ( m_statistics->showP90Curve() && m_ensembleStatCase->hasP90Data() ) addresses.push_back( - SAddr::ensembleStatisticsAddress( ENSEMBLE_STAT_P90_QUANTITY_NAME, dataAddress.quantityName() ) ); + SAddr::ensembleStatisticsAddress( ENSEMBLE_STAT_P90_QUANTITY_NAME, dataAddress.vectorName() ) ); if ( m_statistics->showMeanCurve() && m_ensembleStatCase->hasMeanData() ) addresses.push_back( - SAddr::ensembleStatisticsAddress( ENSEMBLE_STAT_MEAN_QUANTITY_NAME, dataAddress.quantityName() ) ); + SAddr::ensembleStatisticsAddress( ENSEMBLE_STAT_MEAN_QUANTITY_NAME, dataAddress.vectorName() ) ); } deleteStatisticsCurves(); - for ( auto address : addresses ) + + if ( plot->plotWidget() ) { - auto curve = new RimSummaryCurve(); - curve->setParentQwtPlotNoReplot( plot->viewer() ); - m_curves.push_back( curve ); - curve->setColor( m_statistics->color() ); - curve->setResampling( m_resampling() ); - - auto symbol = statisticsCurveSymbolFromAddress( address ); - curve->setSymbol( symbol ); - curve->setSymbolSize( statisticsCurveSymbolSize( symbol ) ); - curve->setSymbolSkipDistance( 150 ); - if ( m_statistics->showCurveLabels() ) + for ( auto address : addresses ) { - curve->setSymbolLabel( QString::fromStdString( address.ensembleStatisticsQuantityName() ) ); + auto curve = new RimSummaryCurve(); + curve->setParentPlotNoReplot( plot->plotWidget() ); + m_curves.push_back( curve ); + curve->setColor( m_statistics->color() ); + curve->setResampling( m_resampling() ); + + auto symbol = statisticsCurveSymbolFromAddress( address ); + curve->setSymbol( symbol ); + curve->setSymbolSize( statisticsCurveSymbolSize( symbol ) ); + curve->setSymbolSkipDistance( 150 ); + if ( m_statistics->showCurveLabels() ) + { + curve->setSymbolLabel( QString::fromStdString( address.ensembleStatisticsVectorName() ) ); + } + curve->setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID ); + curve->setSummaryCaseY( m_ensembleStatCase.get() ); + curve->setSummaryAddressYAndApplyInterpolation( address ); + curve->setLeftOrRightAxisY( axisY() ); + + curve->updateCurveVisibility(); + curve->loadDataAndUpdate( false ); + curve->updatePlotAxis(); } - curve->setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID ); - curve->setSummaryCaseY( m_ensembleStatCase.get() ); - curve->setSummaryAddressYAndApplyInterpolation( address ); - curve->setLeftOrRightAxisY( m_plotAxis() ); - - curve->updateCurveVisibility(); - curve->loadDataAndUpdate( false ); - curve->updateQwtPlotAxis(); - } - if ( plot->viewer() ) - { - plot->viewer()->updateLegend(); + plot->plotWidget()->updateLegend(); plot->updateAxes(); } } @@ -1862,7 +1860,7 @@ void RimEnsembleCurveSet::updateAllTextInPlot() RimSummaryPlot* summaryPlot = nullptr; this->firstAncestorOrThisOfTypeAsserted( summaryPlot ); - if ( summaryPlot->viewer() ) + if ( summaryPlot->plotWidget() ) { summaryPlot->updatePlotTitle(); } @@ -1967,16 +1965,16 @@ bool RimEnsembleCurveSet::hasMeanData() const //-------------------------------------------------------------------------------------------------- void RimEnsembleCurveSet::updateEnsembleLegendItem() { - m_qwtPlotCurveForLegendText->setTitle( name() ); + if ( !m_plotCurveForLegendText ) return; + + m_plotCurveForLegendText->setTitle( name() ); { - QwtSymbol* symbol = nullptr; + RiuPlotCurveSymbol* symbol = m_plotCurveForLegendText->createSymbol( RiuPlotCurveSymbol::SYMBOL_CROSS ); if ( m_colorMode == ColorMode::SINGLE_COLOR ) { - symbol = new QwtSymbol( QwtSymbol::HLine ); - - QColor curveColor( m_color.value().rByte(), m_color.value().gByte(), m_color.value().bByte() ); + QColor curveColor = RiaColorTools::toQColor( m_color ); QPen curvePen( curveColor ); curvePen.setWidth( 2 ); @@ -1986,17 +1984,25 @@ void RimEnsembleCurveSet::updateEnsembleLegendItem() else if ( m_colorMode == ColorMode::BY_ENSEMBLE_PARAM ) { QPixmap p = QPixmap( ":/Legend.png" ); - - symbol = new QwtSymbol; symbol->setPixmap( p ); symbol->setSize( 8, 8 ); } - m_qwtPlotCurveForLegendText->setSymbol( symbol ); + m_plotCurveForLegendText->setSymbol( symbol ); } bool showLegendItem = isCurvesVisible(); - m_qwtPlotCurveForLegendText->setItemAttribute( QwtPlotItem::Legend, showLegendItem ); + m_plotCurveForLegendText->setVisibleInLegend( showLegendItem ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimEnsembleCurveSet::ensembleId() const +{ + if ( m_yValuesSummaryCaseCollection() != nullptr ) return m_yValuesSummaryCaseCollection()->ensembleId(); + + return -1; } //-------------------------------------------------------------------------------------------------- @@ -2025,8 +2031,8 @@ QString RimEnsembleCurveSet::createAutoName() const RimSummaryPlot* plot = nullptr; firstAncestorOrThisOfTypeAsserted( plot ); - QString curveSetName = m_summaryAddressNameTools->curveNameY( m_yValuesSummaryAddress->address(), - plot->activePlotTitleHelperAllCurves() ); + QString curveSetName = + m_summaryAddressNameTools->curveNameY( m_yValuesSummaryAddress->address(), plot->plotTitleHelper() ); if ( curveSetName.isEmpty() ) { curveSetName = m_summaryAddressNameTools->curveNameY( m_yValuesSummaryAddress->address(), nullptr ); @@ -2062,23 +2068,65 @@ void RimEnsembleCurveSet::updateLegendMappingMode() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuQwtSymbol::PointSymbolEnum statisticsCurveSymbolFromAddress( const RifEclipseSummaryAddress& address ) +RiuPlotCurveSymbol::PointSymbolEnum statisticsCurveSymbolFromAddress( const RifEclipseSummaryAddress& address ) { - auto qName = QString::fromStdString( address.quantityName() ); + auto qName = QString::fromStdString( address.vectorName() ); - if ( qName.contains( ENSEMBLE_STAT_P10_QUANTITY_NAME ) ) return RiuQwtSymbol::SYMBOL_TRIANGLE; - if ( qName.contains( ENSEMBLE_STAT_P90_QUANTITY_NAME ) ) return RiuQwtSymbol::SYMBOL_DOWN_TRIANGLE; - if ( qName.contains( ENSEMBLE_STAT_P50_QUANTITY_NAME ) ) return RiuQwtSymbol::SYMBOL_DIAMOND; - return RiuQwtSymbol::SYMBOL_ELLIPSE; + if ( qName.contains( ENSEMBLE_STAT_P10_QUANTITY_NAME ) ) return RiuPlotCurveSymbol::SYMBOL_TRIANGLE; + if ( qName.contains( ENSEMBLE_STAT_P90_QUANTITY_NAME ) ) return RiuPlotCurveSymbol::SYMBOL_DOWN_TRIANGLE; + if ( qName.contains( ENSEMBLE_STAT_P50_QUANTITY_NAME ) ) return RiuPlotCurveSymbol::SYMBOL_DIAMOND; + return RiuPlotCurveSymbol::SYMBOL_ELLIPSE; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -int statisticsCurveSymbolSize( RiuQwtSymbol::PointSymbolEnum symbol ) +int statisticsCurveSymbolSize( RiuPlotCurveSymbol::PointSymbolEnum symbol ) { - if ( symbol == RiuQwtSymbol::SYMBOL_DIAMOND ) return 8; - if ( symbol == RiuQwtSymbol::SYMBOL_TRIANGLE ) return 7; - if ( symbol == RiuQwtSymbol::SYMBOL_DOWN_TRIANGLE ) return 7; + if ( symbol == RiuPlotCurveSymbol::SYMBOL_DIAMOND ) return 8; + if ( symbol == RiuPlotCurveSymbol::SYMBOL_TRIANGLE ) return 7; + if ( symbol == RiuPlotCurveSymbol::SYMBOL_DOWN_TRIANGLE ) return 7; return 6; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuPlotAxis RimEnsembleCurveSet::axisY() const +{ + if ( m_plotAxisProperties ) + return m_plotAxisProperties->plotAxisType(); + else + return RiuPlotAxis::defaultLeft(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSet::setLeftOrRightAxisY( RiuPlotAxis plotAxis ) +{ + RimSummaryPlot* plot = nullptr; + firstAncestorOrThisOfTypeAsserted( plot ); + m_plotAxisProperties = plot->axisPropertiesForPlotAxis( plotAxis ); + + for ( RimSummaryCurve* curve : curves() ) + { + curve->setLeftOrRightAxisY( axisY() ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSet::initAfterRead() +{ + if ( m_plotAxisProperties.value() == nullptr ) + { + RimSummaryPlot* plot = nullptr; + firstAncestorOrThisOfType( plot ); + if ( plot ) + { + m_plotAxisProperties = plot->axisPropertiesForPlotAxis( RiuPlotAxis( m_plotAxis_OBSOLETE() ) ); + } + } +} diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h index ace38eb714..27056ab436 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h @@ -22,19 +22,20 @@ #include "RifEclipseSummaryAddressQMetaType.h" #include "RifSummaryReaderInterface.h" -#include "RiaDefines.h" -#include "RiaQDateTimeTools.h" +#include "RiaDateTimeDefines.h" +#include "RiaPlotDefines.h" #include "RimEnsembleCurveSetColorManager.h" #include "RimEnsembleCurveSetInterface.h" #include "RimObjectiveFunction.h" -#include "RimRegularLegendConfig.h" #include "RimSummaryCase.h" #include "RimSummaryCaseCollection.h" #include "RimTimeStepFilter.h" #include "RigEnsembleParameter.h" +#include "RiuPlotAxis.h" + #include "cafAppEnum.h" #include "cafPdmChildArrayField.h" #include "cafPdmChildField.h" @@ -45,13 +46,13 @@ #include "cafPdmPtrArrayField.h" #include "cafPdmPtrField.h" +#include #include class RimSummaryCase; class RimSummaryCaseCollection; class RimSummaryCurve; class RimSummaryAddress; -class RimSummaryFilter_OBSOLETE; class RimSummaryPlotSourceStepping; class RimSummaryCurveAutoName; class RimEnsembleCurveFilterCollection; @@ -63,12 +64,14 @@ class RiuDraggableOverlayFrame; class RiaSummaryCurveDefinitionAnalyser; class RiaSummaryCurveDefinition; class RiuSummaryVectorSelectionDialog; +class RiuPlotWidget; +class RiuPlotCurve; +class RimPlotAxisPropertiesInterface; class QwtPlot; class QwtPlotCurve; class QKeyEvent; class QFrame; -class QDate; //================================================================================================== /// @@ -94,9 +97,9 @@ class RimEnsembleCurveSet : public caf::PdmObject, public RimEnsembleCurveSetInt void setColor( cvf::Color3f color ); void loadDataAndUpdate( bool updateParentPlot ); - void setParentQwtPlotNoReplot( QwtPlot* plot ); - void detachQwtCurves(); - void reattachQwtCurves(); + void setParentPlotNoReplot( RiuPlotWidget* plot ); + void deletePlotCurves(); + void reattachPlotCurves(); void addCurve( RimSummaryCurve* curve ); void deleteCurve( RimSummaryCurve* curve ); @@ -105,6 +108,8 @@ class RimEnsembleCurveSet : public caf::PdmObject, public RimEnsembleCurveSetInt RifEclipseSummaryAddress summaryAddress() const; std::vector curves() const; + int ensembleId() const; + RimCustomObjectiveFunctionCollection* customObjectiveFunctionCollection(); void deleteEnsembleCurves(); @@ -164,6 +169,12 @@ class RimEnsembleCurveSet : public caf::PdmObject, public RimEnsembleCurveSetInt std::vector generateColorsForCases( const std::vector& summaryCases ) const; + RiuPlotAxis axisY() const; + void setLeftOrRightAxisY( RiuPlotAxis plotAxis ); + +protected: + void initAfterRead() override; + private: void updateEnsembleCurves( const std::vector& sumCases ); void updateStatisticsCurves( const std::vector& sumCases ); @@ -174,11 +185,10 @@ class RimEnsembleCurveSet : public caf::PdmObject, public RimEnsembleCurveSetInt QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; - std::set allAvailableTimeSteps(); - std::set timestepDefiningSourceCases(); - RiaSummaryCurveDefinitionAnalyser* getOrCreateSelectedCurveDefAnalyser(); + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; + std::set allAvailableTimeSteps(); + std::set timestepDefiningSourceCases(); + RiaSummaryCurveDefinitionAnalyser* getOrCreateSelectedCurveDefAnalyser(); std::vector curveDefinitions() const; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; @@ -186,7 +196,7 @@ class RimEnsembleCurveSet : public caf::PdmObject, public RimEnsembleCurveSetInt void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - void updateQwtPlotAxis(); + void updatePlotAxis(); QString createAutoName() const; @@ -207,11 +217,11 @@ class RimEnsembleCurveSet : public caf::PdmObject, public RimEnsembleCurveSetInt caf::PdmPointer m_currentSummaryCurve; - caf::PdmPtrField m_yValuesSummaryCaseCollection; - caf::PdmChildField m_yValuesSummaryAddress; - caf::PdmField m_yValuesSummaryAddressUiField; - caf::PdmField m_yPushButtonSelectSummaryAddress; - caf::PdmField m_resampling; + caf::PdmPtrField m_yValuesSummaryCaseCollection; + caf::PdmChildField m_yValuesSummaryAddress; + caf::PdmField m_yValuesSummaryAddressUiField; + caf::PdmField m_yPushButtonSelectSummaryAddress; + caf::PdmField m_resampling; caf::PdmField m_colorMode; caf::PdmField m_color; @@ -228,7 +238,8 @@ class RimEnsembleCurveSet : public caf::PdmObject, public RimEnsembleCurveSetInt caf::PdmField m_timeStepFilter; caf::PdmField> m_selectedTimeSteps; - caf::PdmField> m_plotAxis; + caf::PdmField> m_plotAxis_OBSOLETE; + caf::PdmPtrField m_plotAxisProperties; caf::PdmChildField m_legendConfig; caf::PdmChildField m_curveFilters; @@ -243,7 +254,7 @@ class RimEnsembleCurveSet : public caf::PdmObject, public RimEnsembleCurveSetInt caf::PdmProxyValueField m_autoGeneratedName; caf::PdmChildField m_summaryAddressNameTools; - QwtPlotCurve* m_qwtPlotCurveForLegendText; + RiuPlotCurve* m_plotCurveForLegendText; QPointer m_legendOverlayFrame; QPointer m_filterOverlayFrame; QPointer m_objectiveFunctionOverlayFrame; @@ -254,7 +265,4 @@ class RimEnsembleCurveSet : public caf::PdmObject, public RimEnsembleCurveSetInt bool m_disableStatisticCurves; bool m_isCurveSetFiltered; - - // Obsolete fields - caf::PdmChildField m_yValuesSummaryFilter_OBSOLETE; }; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp index c192a531d9..ad5ac9c921 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp @@ -29,9 +29,7 @@ #include "RimSummaryPlot.h" #include "RimSummaryPlotSourceStepping.h" -#include "RiuQwtPlotCurve.h" - -#include "qwt_plot.h" +#include "RiuPlotCurve.h" CAF_PDM_SOURCE_INIT( RimEnsembleCurveSetCollection, "RimEnsembleCurveSetCollection" ); @@ -40,18 +38,18 @@ CAF_PDM_SOURCE_INIT( RimEnsembleCurveSetCollection, "RimEnsembleCurveSetCollecti //-------------------------------------------------------------------------------------------------- RimEnsembleCurveSetCollection::RimEnsembleCurveSetCollection() { - CAF_PDM_InitObject( "Ensemble Curve Sets", ":/EnsembleCurveSets16x16.png", "", "" ); + CAF_PDM_InitObject( "Ensemble Curve Sets", ":/EnsembleCurveSets16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_curveSets, "EnsembleCurveSets", "Ensemble Curve Sets", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_curveSets, "EnsembleCurveSets", "Ensemble Curve Sets" ); m_curveSets.uiCapability()->setUiTreeHidden( true ); m_curveSets.uiCapability()->setUiTreeChildrenHidden( false ); - CAF_PDM_InitField( &m_showCurves, "IsActive", true, "Show Curves", "", "", "" ); + CAF_PDM_InitField( &m_showCurves, "IsActive", true, "Show Curves" ); m_showCurves.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_ySourceStepping, "YSourceStepping", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_ySourceStepping, "YSourceStepping", "" ); m_ySourceStepping = new RimSummaryPlotSourceStepping; - m_ySourceStepping->setSourceSteppingType( RimSummaryPlotSourceStepping::Y_AXIS ); + m_ySourceStepping->setSourceSteppingType( RimSummaryDataSourceStepping::Axis::Y_AXIS ); m_ySourceStepping.uiCapability()->setUiTreeHidden( true ); m_ySourceStepping.uiCapability()->setUiTreeChildrenHidden( true ); m_ySourceStepping.xmlCapability()->disableIO(); @@ -62,7 +60,7 @@ RimEnsembleCurveSetCollection::RimEnsembleCurveSetCollection() //-------------------------------------------------------------------------------------------------- RimEnsembleCurveSetCollection::~RimEnsembleCurveSetCollection() { - m_curveSets.deleteAllChildObjects(); + m_curveSets.deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -94,48 +92,56 @@ void RimEnsembleCurveSetCollection::loadDataAndUpdate( bool updateParentPlot ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsembleCurveSetCollection::setParentQwtPlotAndReplot( QwtPlot* plot ) +void RimEnsembleCurveSetCollection::setParentPlotAndReplot( RiuPlotWidget* plot ) +{ + setParentPlotNoReplot( plot ); + + if ( plot ) plot->replot(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSetCollection::setParentPlotNoReplot( RiuPlotWidget* plot ) { for ( RimEnsembleCurveSet* curveSet : m_curveSets ) { - curveSet->setParentQwtPlotNoReplot( plot ); + curveSet->setParentPlotNoReplot( plot ); } - - if ( plot ) plot->replot(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsembleCurveSetCollection::detachQwtCurves() +void RimEnsembleCurveSetCollection::detachPlotCurves() { for ( const auto& curveSet : m_curveSets ) { - curveSet->detachQwtCurves(); + curveSet->deletePlotCurves(); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsembleCurveSetCollection::reattachQwtCurves() +void RimEnsembleCurveSetCollection::reattachPlotCurves() { for ( const auto& curveSet : m_curveSets ) { - curveSet->reattachQwtCurves(); + curveSet->reattachPlotCurves(); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryCurve* RimEnsembleCurveSetCollection::findRimCurveFromQwtCurve( const QwtPlotCurve* qwtCurve ) const +RimSummaryCurve* RimEnsembleCurveSetCollection::findRimCurveFromPlotCurve( const RiuPlotCurve* curve ) const { for ( RimEnsembleCurveSet* curveSet : m_curveSets ) { for ( RimSummaryCurve* rimCurve : curveSet->curves() ) { - if ( rimCurve->qwtPlotCurve() == qwtCurve ) + if ( rimCurve->isSameCurve( curve ) ) { return rimCurve; } @@ -148,13 +154,13 @@ RimSummaryCurve* RimEnsembleCurveSetCollection::findRimCurveFromQwtCurve( const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimEnsembleCurveSet* RimEnsembleCurveSetCollection::findRimCurveSetFromQwtCurve( const QwtPlotCurve* qwtCurve ) const +RimEnsembleCurveSet* RimEnsembleCurveSetCollection::findCurveSetFromPlotCurve( const RiuPlotCurve* curve ) const { for ( RimEnsembleCurveSet* curveSet : m_curveSets ) { for ( RimSummaryCurve* rimCurve : curveSet->curves() ) { - if ( rimCurve->qwtPlotCurve() == qwtCurve ) + if ( rimCurve->isSameCurve( curve ) ) { return curveSet; } @@ -190,7 +196,7 @@ void RimEnsembleCurveSetCollection::deleteCurveSets( const std::vector RimEnsembleCurveSetCollection::curveSets() const { - return m_curveSets.childObjects(); + return m_curveSets.children(); } //-------------------------------------------------------------------------------------------------- @@ -254,21 +260,21 @@ std::vector RimEnsembleCurveSetCollection::curveSetsForSou { // Add corresponding history/summary curve with or without H - std::string quantity = m_curveSetForSourceStepping->summaryAddress().quantityName(); + std::string vectorName = m_curveSetForSourceStepping->summaryAddress().vectorName(); std::string candidateName; - if ( m_curveSetForSourceStepping->summaryAddress().isHistoryQuantity() ) + if ( m_curveSetForSourceStepping->summaryAddress().isHistoryVector() ) { - candidateName = quantity.substr( 0, quantity.size() - 1 ); + candidateName = vectorName.substr( 0, vectorName.size() - 1 ); } else { - candidateName = quantity + "H"; + candidateName = vectorName + "H"; } for ( const auto& c : curveSets() ) { - if ( c->summaryAddress().quantityName() == candidateName ) + if ( c->summaryAddress().vectorName() == candidateName ) { steppingCurveSets.push_back( c ); } @@ -296,7 +302,7 @@ RimSummaryPlotSourceStepping* RimEnsembleCurveSetCollection::sourceSteppingObjec //-------------------------------------------------------------------------------------------------- void RimEnsembleCurveSetCollection::deleteAllCurveSets() { - m_curveSets.deleteAllChildObjects(); + m_curveSets.deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -309,10 +315,6 @@ void RimEnsembleCurveSetCollection::fieldChangedByUi( const caf::PdmFieldHandle* if ( changedField == &m_showCurves ) { loadDataAndUpdate( true ); - - RimSummaryPlot* summaryPlot = nullptr; - this->firstAncestorOrThisOfTypeAsserted( summaryPlot ); - summaryPlot->updateConnectedEditors(); } } @@ -321,9 +323,6 @@ void RimEnsembleCurveSetCollection::fieldChangedByUi( const caf::PdmFieldHandle* //-------------------------------------------------------------------------------------------------- void RimEnsembleCurveSetCollection::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { - auto group = uiOrdering.addNewGroup( "Data Source" ); - - m_ySourceStepping()->uiOrdering( uiConfigName, *group ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.h b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.h index f5253bdbb6..34c17d89c0 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.h @@ -18,6 +18,7 @@ #pragma once +#include "RiuPlotWidget.h" #include "cafPdmChildArrayField.h" #include "cafPdmChildField.h" #include "cafPdmField.h" @@ -26,8 +27,7 @@ class RimEnsembleCurveSet; class RimSummaryPlotSourceStepping; class RimSummaryCurve; -class QwtPlot; -class QwtPlotCurve; +class RiuPlotCurve; //================================================================================================== /// @@ -43,12 +43,13 @@ class RimEnsembleCurveSetCollection : public caf::PdmObject bool isCurveSetsVisible(); void loadDataAndUpdate( bool updateParentPlot ); - void setParentQwtPlotAndReplot( QwtPlot* plot ); - void detachQwtCurves(); - void reattachQwtCurves(); + void setParentPlotAndReplot( RiuPlotWidget* plot ); + void setParentPlotNoReplot( RiuPlotWidget* plot ); + void detachPlotCurves(); + void reattachPlotCurves(); - RimSummaryCurve* findRimCurveFromQwtCurve( const QwtPlotCurve* qwtCurve ) const; - RimEnsembleCurveSet* findRimCurveSetFromQwtCurve( const QwtPlotCurve* qwtCurve ) const; + RimSummaryCurve* findRimCurveFromPlotCurve( const RiuPlotCurve* qwtCurve ) const; + RimEnsembleCurveSet* findCurveSetFromPlotCurve( const RiuPlotCurve* qwtCurve ) const; void addCurveSet( RimEnsembleCurveSet* curveSet ); void deleteCurveSet( RimEnsembleCurveSet* curveSet ); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleStatistics.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleStatistics.cpp index 76b04bc47b..58f564146b 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleStatistics.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleStatistics.cpp @@ -30,23 +30,23 @@ CAF_PDM_SOURCE_INIT( RimEnsembleStatistics, "RimEnsembleStatistics" ); //-------------------------------------------------------------------------------------------------- RimEnsembleStatistics::RimEnsembleStatistics( RimEnsembleCurveSetInterface* parentCurveSet ) { - CAF_PDM_InitObject( "Ensemble Curve Filter", ":/EnsembleCurveSet16x16.png", "", "" ); + CAF_PDM_InitObject( "Ensemble Curve Filter", ":/EnsembleCurveSet16x16.png" ); m_parentCurveSet = parentCurveSet; - CAF_PDM_InitField( &m_active, "Active", true, "Show Statistics Curves", "", "", "" ); - CAF_PDM_InitField( &m_hideEnsembleCurves, "HideEnsembleCurves", false, "Hide Ensemble Curves", "", "", "" ); - CAF_PDM_InitField( &m_basedOnFilteredCases, "BasedOnFilteredCases", false, "Based on Filtered Cases", "", "", "" ); - CAF_PDM_InitField( &m_showP10Curve, "ShowP10Curve", true, "P10", "", "", "" ); - CAF_PDM_InitField( &m_showP50Curve, "ShowP50Curve", false, "P50", "", "", "" ); - CAF_PDM_InitField( &m_showP90Curve, "ShowP90Curve", true, "P90", "", "", "" ); - CAF_PDM_InitField( &m_showMeanCurve, "ShowMeanCurve", true, "Mean", "", "", "" ); - CAF_PDM_InitField( &m_showCurveLabels, "ShowCurveLabels", true, "Show Curve Labels", "", "", "" ); - CAF_PDM_InitField( &m_includeIncompleteCurves, "IncludeIncompleteCurves", false, "Include Incomplete Curves", "", "", "" ); + CAF_PDM_InitField( &m_active, "Active", true, "Show Statistics Curves" ); + CAF_PDM_InitField( &m_hideEnsembleCurves, "HideEnsembleCurves", false, "Hide Ensemble Curves" ); + CAF_PDM_InitField( &m_basedOnFilteredCases, "BasedOnFilteredCases", false, "Based on Filtered Cases" ); + CAF_PDM_InitField( &m_showP10Curve, "ShowP10Curve", true, "P10" ); + CAF_PDM_InitField( &m_showP50Curve, "ShowP50Curve", false, "P50" ); + CAF_PDM_InitField( &m_showP90Curve, "ShowP90Curve", true, "P90" ); + CAF_PDM_InitField( &m_showMeanCurve, "ShowMeanCurve", true, "Mean" ); + CAF_PDM_InitField( &m_showCurveLabels, "ShowCurveLabels", true, "Show Curve Labels" ); + CAF_PDM_InitField( &m_includeIncompleteCurves, "IncludeIncompleteCurves", false, "Include Incomplete Curves" ); - CAF_PDM_InitField( &m_warningLabel, "WarningLabel", QString( "Warning: Ensemble time range mismatch" ), "", "", "", "" ); + CAF_PDM_InitField( &m_warningLabel, "WarningLabel", QString( "Warning: Ensemble time range mismatch" ), "" ); - CAF_PDM_InitField( &m_color, "Color", RiaColorTools::textColor3f(), "Color", "", "", "" ); + CAF_PDM_InitField( &m_color, "Color", RiaColorTools::textColor3f(), "Color" ); m_warningLabel.xmlCapability()->disableIO(); m_warningLabel.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); @@ -61,6 +61,14 @@ bool RimEnsembleStatistics::isActive() const return m_active; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleStatistics::setShowStatisticsCurves( bool show ) +{ + m_active = show; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleStatistics.h b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleStatistics.h index b8ab31fae6..2fb8bed8c2 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleStatistics.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleStatistics.h @@ -35,6 +35,7 @@ class RimEnsembleStatistics : public caf::PdmObject RimEnsembleStatistics( RimEnsembleCurveSetInterface* parentCurveSet = nullptr ); bool isActive() const; + void setShowStatisticsCurves( bool show ); bool hideEnsembleCurves() const { return m_hideEnsembleCurves; } bool basedOnFilteredCases() const { return m_basedOnFilteredCases; } bool showP10Curve() const { return m_showP10Curve; } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleStatisticsCase.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleStatisticsCase.cpp index 30113951f4..9b1614291b 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleStatisticsCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleStatisticsCase.cpp @@ -161,10 +161,7 @@ void RimEnsembleStatisticsCase::calculate( const std::vector su if ( !includeIncompleteCurves && timeSteps.size() != values.size() ) continue; auto [resampledTimeSteps, resampledValues] = - RiaSummaryTools::resampledValuesForPeriod( inputAddress, - timeSteps, - values, - RiaQDateTimeTools::DateTimePeriod::DAY ); + RiaSummaryTools::resampledValuesForPeriod( inputAddress, timeSteps, values, RiaDefines::DateTimePeriod::DAY ); if ( allTimeSteps.empty() ) allTimeSteps = resampledTimeSteps; caseAndTimeStepValues.push_back( resampledValues ); @@ -253,7 +250,7 @@ std::vector RimEnsembleStatisticsCase::validSummaryCases( const } } - for ( const auto [sumCase, lastTimeStep] : times ) + for ( const auto& [sumCase, lastTimeStep] : times ) { // Previous versions tested on identical first time step, this test is now removed. For large simulations with // numerical issues the first time step can be slightly different diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleStatisticsCase.h b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleStatisticsCase.h index e5579e8257..20b53581ac 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleStatisticsCase.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleStatisticsCase.h @@ -49,8 +49,6 @@ class RimEnsembleStatisticsCase : public RimSummaryCase void createSummaryReaderInterface() override; RifSummaryReaderInterface* summaryReader() override; - void updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) override {} - const RimEnsembleCurveSet* curveSet() const; void calculate( const std::vector& sumCases, bool includeIncompleteCurves ); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimFileSummaryCase.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimFileSummaryCase.cpp index 1a23d89cf4..3906ebbffc 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimFileSummaryCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimFileSummaryCase.cpp @@ -29,6 +29,7 @@ #include "RifProjectSummaryDataWriter.h" #include "RifReaderEclipseRft.h" #include "RifReaderEclipseSummary.h" +#include "RifReaderOpmRft.h" #include "RifSummaryReaderMultipleFiles.h" #include "RimProject.h" @@ -89,15 +90,6 @@ QString RimFileSummaryCase::caseName() const return caseFileName.completeBaseName(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimFileSummaryCase::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) -{ - // m_summaryHeaderFilename = - // RimTools::relocateFile( m_summaryHeaderFilename().path(), newProjectPath, oldProjectPath, nullptr, nullptr ); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -194,7 +186,7 @@ RifSummaryReaderInterface* RimFileSummaryCase::findRelatedFilesAndCreateReader( //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RifReaderEclipseRft* RimFileSummaryCase::findRftDataAndCreateReader( const QString& headerFileName ) +RifReaderOpmRft* RimFileSummaryCase::findRftDataAndCreateReader( const QString& headerFileName ) { QFileInfo fileInfo( headerFileName ); QString folder = fileInfo.absolutePath(); @@ -204,8 +196,7 @@ RifReaderEclipseRft* RimFileSummaryCase::findRftDataAndCreateReader( const QStri if ( rftFileInfo.exists() ) { - std::unique_ptr rftReader( new RifReaderEclipseRft( rftFileInfo.filePath() ) ); - return rftReader.release(); + return new RifReaderOpmRft( rftFileInfo.filePath() ); } return nullptr; @@ -220,7 +211,7 @@ void RimFileSummaryCase::defineEditorAttribute( const caf::PdmFieldHandle* field { if ( field == &m_additionalSummaryFilePath ) { - caf::PdmUiFilePathEditorAttribute* myAttr = dynamic_cast( attribute ); + auto* myAttr = dynamic_cast( attribute ); if ( myAttr ) { myAttr->m_selectSaveFileName = true; @@ -234,6 +225,7 @@ void RimFileSummaryCase::defineEditorAttribute( const caf::PdmFieldHandle* field void RimFileSummaryCase::openAndAttachAdditionalReader() { QString additionalSummaryFilePath = m_additionalSummaryFilePath().path(); + if ( additionalSummaryFilePath.isEmpty() ) return; cvf::ref opmCommonReader = new RifOpmCommonEclipseSummary; opmCommonReader->useEnhancedSummaryFiles( true ); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimFileSummaryCase.h b/ApplicationLibCode/ProjectDataModel/Summary/RimFileSummaryCase.h index ef6e595666..a7daa01d71 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimFileSummaryCase.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimFileSummaryCase.h @@ -23,7 +23,7 @@ #include "cvfObject.h" class RifReaderRftInterface; -class RifReaderEclipseRft; +class RifReaderOpmRft; class RifReaderEclipseSummary; class RiaThreadSafeLogger; class RifOpmCommonEclipseSummary; @@ -45,7 +45,6 @@ class RimFileSummaryCase : public RimSummaryCase QString summaryHeaderFilename() const override; QString caseName() const override; - void updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) override; void createSummaryReaderInterfaceThreadSafe( RiaThreadSafeLogger* threadSafeLogger ); void createSummaryReaderInterface() override; @@ -62,8 +61,6 @@ class RimFileSummaryCase : public RimSummaryCase bool includeRestartFiles, RiaThreadSafeLogger* threadSafeLogger ); - static RifReaderEclipseRft* findRftDataAndCreateReader( const QString& headerFileName ); - protected: void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, @@ -74,10 +71,12 @@ class RimFileSummaryCase : public RimSummaryCase QString additionalSummaryDataFilePath() const; static QString createAdditionalSummaryFileName(); + static RifReaderOpmRft* findRftDataAndCreateReader( const QString& headerFileName ); + private: cvf::ref m_fileSummaryReader; cvf::ref m_multiSummaryReader; - cvf::ref m_summaryEclipseRftReader; + cvf::ref m_summaryEclipseRftReader; caf::PdmField m_includeRestartFiles; caf::PdmField m_additionalSummaryFilePath; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimGridSummaryCase.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimGridSummaryCase.cpp index 8b2adcbee9..473a106470 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimGridSummaryCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimGridSummaryCase.cpp @@ -47,18 +47,18 @@ RimGridSummaryCase::RimGridSummaryCase() ":/SummaryCases16x16.png", "", "A Summary Case based on extracting grid data." ); - CAF_PDM_InitFieldNoDefault( &m_eclipseCase, "Associated3DCase", "Eclipse Case", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_eclipseCase, "Associated3DCase", "Eclipse Case" ); m_eclipseCase.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_cachedCaseName, "CachedCasename", "Case Name", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_cachedCaseName, "CachedCasename", "Case Name" ); m_cachedCaseName.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_eclipseGridFileName, "Associated3DCaseGridFileName", "Grid File Name", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_eclipseGridFileName, "Associated3DCaseGridFileName", "Grid File Name" ); m_eclipseGridFileName.registerGetMethod( this, &RimGridSummaryCase::eclipseGridFileName ); m_eclipseGridFileName.uiCapability()->setUiReadOnly( true ); m_eclipseGridFileName.xmlCapability()->setIOWritable( false ); - CAF_PDM_InitField( &m_includeRestartFiles, "IncludeRestartFiles", false, "Include Restart Files", "", "", "" ); + CAF_PDM_InitField( &m_includeRestartFiles, "IncludeRestartFiles", false, "Include Restart Files" ); m_includeRestartFiles.uiCapability()->setUiHidden( true ); } @@ -174,14 +174,6 @@ QString RimGridSummaryCase::eclipseGridFileName() const return m_eclipseCase()->gridFileName(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimGridSummaryCase::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) -{ - // Shouldn't have to do anything -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimGridSummaryCase.h b/ApplicationLibCode/ProjectDataModel/Summary/RimGridSummaryCase.h index 355a3996fd..8787af8f8a 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimGridSummaryCase.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimGridSummaryCase.h @@ -47,7 +47,6 @@ class RimGridSummaryCase : public RimSummaryCase QString summaryHeaderFilename() const override; QString caseName() const override; - void updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) override; void createSummaryReaderInterface() override; RifSummaryReaderInterface* summaryReader() override; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimMultipleSummaryPlotNameHelper.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimMultipleSummaryPlotNameHelper.cpp new file mode 100644 index 0000000000..854d107a74 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimMultipleSummaryPlotNameHelper.cpp @@ -0,0 +1,237 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 Statoil 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 "RimMultipleSummaryPlotNameHelper.h" + +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimMultiSummaryPlotNameHelper::RimMultiSummaryPlotNameHelper( std::vector nameHelpers ) + : m_nameHelpers( nameHelpers ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimMultiSummaryPlotNameHelper::plotTitle() const +{ + if ( m_nameHelpers.size() == 1 ) return m_nameHelpers.front()->plotTitle(); + + if ( m_nameHelpers.size() == 2 ) + { + auto first = m_nameHelpers[0]; + auto second = m_nameHelpers[1]; + + return first->aggregatedPlotTitle( *second ); + } + + return "Plot Title"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimMultiSummaryPlotNameHelper::isPlotDisplayingSingleVectorName() const +{ + int plotCountWithSingleQuantity = 0; + for ( auto nameHelper : m_nameHelpers ) + { + if ( nameHelper->isPlotDisplayingSingleVectorName() ) plotCountWithSingleQuantity++; + } + + if ( plotCountWithSingleQuantity == 1 ) return true; + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimMultiSummaryPlotNameHelper::isWellNameInTitle() const +{ + return std::any_of( m_nameHelpers.begin(), m_nameHelpers.end(), []( auto nameHelper ) { + return nameHelper->isWellNameInTitle(); + } ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimMultiSummaryPlotNameHelper::isGroupNameInTitle() const +{ + return std::any_of( m_nameHelpers.begin(), m_nameHelpers.end(), []( auto nameHelper ) { + return nameHelper->isGroupNameInTitle(); + } ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimMultiSummaryPlotNameHelper::isRegionInTitle() const +{ + return std::any_of( m_nameHelpers.begin(), m_nameHelpers.end(), []( auto nameHelper ) { + return nameHelper->isRegionInTitle(); + } ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimMultiSummaryPlotNameHelper::isCaseInTitle() const +{ + return std::any_of( m_nameHelpers.begin(), m_nameHelpers.end(), []( auto nameHelper ) { + return nameHelper->isCaseInTitle(); + } ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimMultiSummaryPlotNameHelper::isBlockInTitle() const +{ + return std::any_of( m_nameHelpers.begin(), m_nameHelpers.end(), []( auto nameHelper ) { + return nameHelper->isBlockInTitle(); + } ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimMultiSummaryPlotNameHelper::isSegmentInTitle() const +{ + return std::any_of( m_nameHelpers.begin(), m_nameHelpers.end(), []( auto nameHelper ) { + return nameHelper->isSegmentInTitle(); + } ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimMultiSummaryPlotNameHelper::isCompletionInTitle() const +{ + return std::any_of( m_nameHelpers.begin(), m_nameHelpers.end(), []( auto nameHelper ) { + return nameHelper->isCompletionInTitle(); + } ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimMultiSummaryPlotNameHelper::caseName() const +{ + for ( auto nameHelper : m_nameHelpers ) + { + if ( nameHelper->isCaseInTitle() ) return nameHelper->caseName(); + } + + return ""; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::string RimMultiSummaryPlotNameHelper::titleVectorName() const +{ + for ( auto nameHelper : m_nameHelpers ) + { + if ( nameHelper->isPlotDisplayingSingleVectorName() ) return nameHelper->titleVectorName(); + } + + return ""; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::string RimMultiSummaryPlotNameHelper::titleWellName() const +{ + for ( auto nameHelper : m_nameHelpers ) + { + if ( nameHelper->isWellNameInTitle() ) return nameHelper->titleWellName(); + } + + return ""; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::string RimMultiSummaryPlotNameHelper::titleGroupName() const +{ + for ( auto nameHelper : m_nameHelpers ) + { + if ( nameHelper->isGroupNameInTitle() ) return nameHelper->titleGroupName(); + } + + return ""; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::string RimMultiSummaryPlotNameHelper::titleRegion() const +{ + for ( auto nameHelper : m_nameHelpers ) + { + if ( nameHelper->isRegionInTitle() ) return nameHelper->titleRegion(); + } + + return ""; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::string RimMultiSummaryPlotNameHelper::titleBlock() const +{ + for ( auto nameHelper : m_nameHelpers ) + { + if ( nameHelper->isBlockInTitle() ) return nameHelper->titleBlock(); + } + + return ""; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::string RimMultiSummaryPlotNameHelper::titleSegment() const +{ + for ( auto nameHelper : m_nameHelpers ) + { + if ( nameHelper->isSegmentInTitle() ) return nameHelper->titleSegment(); + } + + return ""; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::string RimMultiSummaryPlotNameHelper::titleCompletion() const +{ + for ( auto nameHelper : m_nameHelpers ) + { + if ( nameHelper->isCompletionInTitle() ) return nameHelper->titleCompletion(); + } + + return ""; +} diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimMultipleSummaryPlotNameHelper.h b/ApplicationLibCode/ProjectDataModel/Summary/RimMultipleSummaryPlotNameHelper.h new file mode 100644 index 0000000000..1ac675e2b8 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimMultipleSummaryPlotNameHelper.h @@ -0,0 +1,54 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 Statoil 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 "RimSummaryNameHelper.h" + +//================================================================================================== +// +//================================================================================================== +class RimMultiSummaryPlotNameHelper : public RimSummaryNameHelper +{ +public: + explicit RimMultiSummaryPlotNameHelper( std::vector nameHelpers ); + + QString plotTitle() const override; + + bool isPlotDisplayingSingleVectorName() const override; + bool isWellNameInTitle() const override; + bool isGroupNameInTitle() const override; + bool isRegionInTitle() const override; + bool isCaseInTitle() const override; + bool isBlockInTitle() const override; + bool isSegmentInTitle() const override; + bool isCompletionInTitle() const override; + + QString caseName() const override; + + std::string titleVectorName() const override; + std::string titleWellName() const override; + std::string titleGroupName() const override; + std::string titleRegion() const override; + std::string titleBlock() const override; + std::string titleSegment() const override; + std::string titleCompletion() const override; + +private: + std::vector m_nameHelpers; +}; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimObjectiveFunction.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimObjectiveFunction.cpp index 869157c923..41d567e544 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimObjectiveFunction.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimObjectiveFunction.cpp @@ -53,29 +53,20 @@ RimObjectiveFunction::RimObjectiveFunction() : changed( this ) { - CAF_PDM_InitObject( "Objective Function", "", "", "" ); + CAF_PDM_InitObject( "Objective Function" ); - CAF_PDM_InitFieldNoDefault( &m_functionType, "FunctionType", "Function Type", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_functionType, "FunctionType", "Function Type" ); CAF_PDM_InitField( &m_normalizeByNumberOfObservations, "NormalizeByNumberOfObservations", true, - "Normalize by Number of Observations", - "", - "", - "" ); + "Normalize by Number of Observations" ); - CAF_PDM_InitField( &m_normalizeByNumberOfVectors, - "NormalizeByNumberOfVectors", - true, - "Normalize by Number of Vectors", - "", - "", - "" ); + CAF_PDM_InitField( &m_normalizeByNumberOfVectors, "NormalizeByNumberOfVectors", true, "Normalize by Number of Vectors" ); - CAF_PDM_InitField( &m_errorEstimatePercentage, "ErrorEstimatePercentage", 100.0, "Error Estimate [0..100 %]", "", "", "" ); + CAF_PDM_InitField( &m_errorEstimatePercentage, "ErrorEstimatePercentage", 100.0, "Error Estimate [0..100 %]" ); - CAF_PDM_InitField( &m_useSquaredError, "UseSquaredError", true, "Use Squared Error Term", "", "", "" ); + CAF_PDM_InitField( &m_useSquaredError, "UseSquaredError", true, "Use Squared Error Term" ); } //-------------------------------------------------------------------------------------------------- @@ -117,20 +108,20 @@ double RimObjectiveFunction::value( RimSummaryCase* for ( auto vectorSummaryAddress : vectorSummaryAddresses ) { - std::string s = vectorSummaryAddress.quantityName() + RifReaderEclipseSummary::differenceIdentifier(); - if ( !vectorSummaryAddress.quantityName().empty() ) + std::string s = vectorSummaryAddress.vectorName() + RifReaderEclipseSummary::differenceIdentifier(); + if ( !vectorSummaryAddress.vectorName().empty() ) { - if ( vectorSummaryAddress.quantityName().find( RifReaderEclipseSummary::differenceIdentifier() ) != + if ( vectorSummaryAddress.vectorName().find( RifReaderEclipseSummary::differenceIdentifier() ) != std::string::npos ) { - s = vectorSummaryAddress.quantityName(); + s = vectorSummaryAddress.vectorName(); } RifEclipseSummaryAddress vectorSummaryAddressDiff = vectorSummaryAddress; - vectorSummaryAddressDiff.setQuantityName( s ); + vectorSummaryAddressDiff.setVectorName( s ); RifEclipseSummaryAddress vectorSummaryAddressHistory = vectorSummaryAddress; - vectorSummaryAddressHistory.setQuantityName( vectorSummaryAddress.quantityName() + - RifReaderEclipseSummary::historyIdentifier() ); + vectorSummaryAddressHistory.setVectorName( vectorSummaryAddress.vectorName() + + RifReaderEclipseSummary::historyIdentifier() ); if ( readerInterface->allResultAddresses().count( vectorSummaryAddressDiff ) ) { diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimObjectiveFunctionTools.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimObjectiveFunctionTools.cpp index 8f462fd6b1..477b966af1 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimObjectiveFunctionTools.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimObjectiveFunctionTools.cpp @@ -46,9 +46,9 @@ RimCustomObjectiveFunctionWeight* RimObjectiveFunctionTools::addWeight( RimCusto candidateAdr = newWeight->parentCurveSet()->summaryAddress(); } - auto nativeQuantityName = RimObjectiveFunctionTools::nativeQuantityName( candidateAdr.quantityName() ); + auto nativeQuantityName = RimObjectiveFunctionTools::nativeQuantityName( candidateAdr.vectorName() ); - candidateAdr.setQuantityName( nativeQuantityName ); + candidateAdr.setVectorName( nativeQuantityName ); newWeight->setSummaryAddress( candidateAdr ); return newWeight; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimObservedEclipseUserData.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimObservedEclipseUserData.cpp index 394a7fd832..c56306c372 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimObservedEclipseUserData.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimObservedEclipseUserData.cpp @@ -37,7 +37,7 @@ CAF_PDM_SOURCE_INIT( RimObservedEclipseUserData, "RimObservedEclipseUserData" ); //-------------------------------------------------------------------------------------------------- RimObservedEclipseUserData::RimObservedEclipseUserData() { - CAF_PDM_InitObject( "Observed RSMSPEC Column Based Data File", ":/ObservedRSMDataFile16x16.png", "", "" ); + CAF_PDM_InitObject( "Observed RSMSPEC Column Based Data File", ":/ObservedRSMDataFile16x16.png" ); m_summaryHeaderFilename.uiCapability()->setUiName( "File" ); } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimObservedSummaryData.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimObservedSummaryData.cpp index bd402becd1..2751593b50 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimObservedSummaryData.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimObservedSummaryData.cpp @@ -34,22 +34,19 @@ RimObservedSummaryData::RimObservedSummaryData() { m_isObservedData = true; - CAF_PDM_InitFieldNoDefault( &m_importedSummaryData, "ImportedSummaryData", "Imported Summary Data", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_importedSummaryData, "ImportedSummaryData", "Imported Summary Data" ); m_importedSummaryData.uiCapability()->setUiEditorTypeName( caf::PdmUiTextEditor::uiEditorTypeName() ); m_importedSummaryData.uiCapability()->setUiReadOnly( true ); m_importedSummaryData.xmlCapability()->disableIO(); - CAF_PDM_InitField( &m_useCustomIdentifier, "UseCustomIdentifier", false, "Use Custom Identifier", "", "", "" ); + CAF_PDM_InitField( &m_useCustomIdentifier, "UseCustomIdentifier", false, "Use Custom Identifier" ); m_useCustomIdentifier.uiCapability()->setUiHidden( true ); CAF_PDM_InitField( &m_summaryCategory, "SummaryType", caf::AppEnum( RifEclipseSummaryAddress::SUMMARY_WELL ), - "Summary Type", - "", - "", - "" ); + "Summary Type" ); m_summaryCategory.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_identifierName, "IdentifierName", "Identifier Name", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_identifierName, "IdentifierName", "Identifier Name" ); m_identifierName.uiCapability()->setUiHidden( true ); } @@ -63,15 +60,6 @@ QString RimObservedSummaryData::caseName() const return caseFileName.completeBaseName(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimObservedSummaryData::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) -{ - // m_summaryHeaderFilename = - // RimTools::relocateFile( m_summaryHeaderFilename(), newProjectPath, oldProjectPath, nullptr, nullptr ); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -124,8 +112,7 @@ QString RimObservedSummaryData::customWellName() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList - RimObservedSummaryData::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) +QList RimObservedSummaryData::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { if ( fieldNeedingOptions == &m_summaryCategory ) { @@ -134,13 +121,13 @@ QList using AddressAppEnum = caf::AppEnum; options.push_back( caf::PdmOptionItemInfo( AddressAppEnum::uiText( RifEclipseSummaryAddress::SUMMARY_WELL ), RifEclipseSummaryAddress::SUMMARY_WELL ) ); - options.push_back( caf::PdmOptionItemInfo( AddressAppEnum::uiText( RifEclipseSummaryAddress::SUMMARY_WELL_GROUP ), - RifEclipseSummaryAddress::SUMMARY_WELL_GROUP ) ); + options.push_back( caf::PdmOptionItemInfo( AddressAppEnum::uiText( RifEclipseSummaryAddress::SUMMARY_GROUP ), + RifEclipseSummaryAddress::SUMMARY_GROUP ) ); return options; } - return RimSummaryCase::calculateValueOptions( fieldNeedingOptions, useOptionsOnly ); + return RimSummaryCase::calculateValueOptions( fieldNeedingOptions ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimObservedSummaryData.h b/ApplicationLibCode/ProjectDataModel/Summary/RimObservedSummaryData.h index fbdf69e977..c01bac46c3 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimObservedSummaryData.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimObservedSummaryData.h @@ -37,7 +37,6 @@ class RimObservedSummaryData : public RimSummaryCase RimObservedSummaryData(); QString caseName() const override; - void updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) override; QString identifierName() const; RifEclipseSummaryAddress::SummaryVarCategory summaryCategory() const; @@ -48,8 +47,7 @@ class RimObservedSummaryData : public RimSummaryCase QString customWellName() const; private: - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; private: diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddress.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddress.cpp index 4fd02de976..49146f452c 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddress.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddress.cpp @@ -35,7 +35,7 @@ void caf::AppEnum::setUp() addItem( RifEclipseSummaryAddress::SUMMARY_MISC, "SUMMARY_MISC", "Misc" ); addItem( RifEclipseSummaryAddress::SUMMARY_REGION, "SUMMARY_REGION", "Region" ); addItem( RifEclipseSummaryAddress::SUMMARY_REGION_2_REGION, "SUMMARY_REGION_2_REGION", "Region-Region" ); - addItem( RifEclipseSummaryAddress::SUMMARY_WELL_GROUP, "SUMMARY_WELL_GROUP", "Group" ); + addItem( RifEclipseSummaryAddress::SUMMARY_GROUP, "SUMMARY_WELL_GROUP", "Group" ); addItem( RifEclipseSummaryAddress::SUMMARY_WELL, "SUMMARY_WELL", "Well" ); addItem( RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION, "SUMMARY_WELL_COMPLETION", "Completion" ); addItem( RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION_LGR, "SUMMARY_WELL_COMPLETION_LGR", "Lgr-Completion" ); @@ -58,20 +58,25 @@ CAF_PDM_SOURCE_INIT( RimSummaryAddress, "SummaryAddress" ); //-------------------------------------------------------------------------------------------------- RimSummaryAddress::RimSummaryAddress() { - CAF_PDM_InitFieldNoDefault( &m_category, "SummaryVarType", "Type", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_quantityName, "SummaryQuantityName", "Quantity", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_regionNumber, "SummaryRegion", "Region", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_regionNumber2, "SummaryRegion2", "Region2", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_wellGroupName, "SummaryWellGroup", "Group", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_wellName, "SummaryWell", "Well", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_wellSegmentNumber, "SummaryWellSegment", "Well Segment", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_lgrName, "SummaryLgr", "Grid", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_cellI, "SummaryCellI", "I", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_cellJ, "SummaryCellJ", "J", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_cellK, "SummaryCellK", "K", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_aquiferNumber, "SummaryAquifer", "Aquifer", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_isErrorResult, "IsErrorResult", "Is Error Result", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_calculationId, "CalculationId", "Calculation Id", "", "", "" ); + CAF_PDM_InitObject( "SummaryAddress", ":/DataVector.png", "", "" ); + + CAF_PDM_InitFieldNoDefault( &m_category, "SummaryVarType", "Type" ); + CAF_PDM_InitFieldNoDefault( &m_vectorName, "SummaryQuantityName", "Vector" ); + CAF_PDM_InitFieldNoDefault( &m_regionNumber, "SummaryRegion", "Region" ); + CAF_PDM_InitFieldNoDefault( &m_regionNumber2, "SummaryRegion2", "Region2" ); + CAF_PDM_InitFieldNoDefault( &m_groupName, "SummaryWellGroup", "Group" ); + CAF_PDM_InitFieldNoDefault( &m_wellName, "SummaryWell", "Well" ); + CAF_PDM_InitFieldNoDefault( &m_wellSegmentNumber, "SummaryWellSegment", "Well Segment" ); + CAF_PDM_InitFieldNoDefault( &m_lgrName, "SummaryLgr", "Grid" ); + CAF_PDM_InitFieldNoDefault( &m_cellI, "SummaryCellI", "I" ); + CAF_PDM_InitFieldNoDefault( &m_cellJ, "SummaryCellJ", "J" ); + CAF_PDM_InitFieldNoDefault( &m_cellK, "SummaryCellK", "K" ); + CAF_PDM_InitFieldNoDefault( &m_aquiferNumber, "SummaryAquifer", "Aquifer" ); + CAF_PDM_InitFieldNoDefault( &m_isErrorResult, "IsErrorResult", "Is Error Result" ); + CAF_PDM_InitFieldNoDefault( &m_calculationId, "CalculationId", "Calculation Id" ); + + CAF_PDM_InitField( &m_caseId, "CaseId", -1, "CaseId" ); + CAF_PDM_InitField( &m_ensembleId, "EnsembleId", -1, "EnsembleId" ); m_category = RifEclipseSummaryAddress::SUMMARY_INVALID; m_regionNumber = -1; @@ -92,16 +97,30 @@ RimSummaryAddress::~RimSummaryAddress() { } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryAddress* RimSummaryAddress::wrapFileReaderAddress( const RifEclipseSummaryAddress& addr, + int caseId /* = -1 */, + int ensembleId /* = -1 */ ) +{ + RimSummaryAddress* newAddress = new RimSummaryAddress(); + newAddress->setAddress( addr ); + newAddress->setCaseId( caseId ); + newAddress->setEnsembleId( ensembleId ); + return newAddress; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimSummaryAddress::setAddress( const RifEclipseSummaryAddress& addr ) { m_category = addr.category(); - m_quantityName = addr.quantityName().c_str(); + m_vectorName = addr.vectorName().c_str(); m_regionNumber = addr.regionNumber(); m_regionNumber2 = addr.regionNumber2(); - m_wellGroupName = addr.wellGroupName().c_str(); + m_groupName = addr.groupName().c_str(); m_wellName = addr.wellName().c_str(); m_wellSegmentNumber = addr.wellSegmentNumber(); m_lgrName = addr.lgrName().c_str(); @@ -112,18 +131,20 @@ void RimSummaryAddress::setAddress( const RifEclipseSummaryAddress& addr ) m_cellJ = addr.cellJ(); m_cellK = addr.cellK(); m_calculationId = addr.id(); + + setUiName( m_vectorName ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RifEclipseSummaryAddress RimSummaryAddress::address() +RifEclipseSummaryAddress RimSummaryAddress::address() const { return RifEclipseSummaryAddress( m_category(), - m_quantityName().toStdString(), + m_vectorName().toStdString(), m_regionNumber(), m_regionNumber2(), - m_wellGroupName().toStdString(), + m_groupName().toStdString(), m_wellName().toStdString(), m_wellSegmentNumber(), m_lgrName().toStdString(), @@ -138,17 +159,17 @@ RifEclipseSummaryAddress RimSummaryAddress::address() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryAddress::ensureIdIsAssigned() +void RimSummaryAddress::ensureCalculationIdIsAssigned() { if ( m_category == RifEclipseSummaryAddress::SUMMARY_CALCULATED && m_calculationId == -1 ) { RimSummaryCalculationCollection* calcColl = RimProject::current()->calculationCollection(); - for ( const RimSummaryCalculation* c : calcColl->calculations() ) + for ( const RimUserDefinedCalculation* c : calcColl->calculations() ) { QString description = c->description(); - if ( description == m_quantityName ) + if ( description == m_vectorName ) { m_calculationId = c->id(); } @@ -162,17 +183,87 @@ void RimSummaryAddress::ensureIdIsAssigned() //-------------------------------------------------------------------------------------------------- RiaDefines::PhaseType RimSummaryAddress::addressPhaseType() const { - if ( QRegularExpression( "^.OP" ).match( m_quantityName ).hasMatch() ) + if ( QRegularExpression( "^.OP" ).match( m_vectorName ).hasMatch() ) { return RiaDefines::PhaseType::OIL_PHASE; } - else if ( QRegularExpression( "^.GP" ).match( m_quantityName ).hasMatch() ) + else if ( QRegularExpression( "^.GP" ).match( m_vectorName ).hasMatch() ) { return RiaDefines::PhaseType::GAS_PHASE; } - else if ( QRegularExpression( "^.WP" ).match( m_quantityName ).hasMatch() ) + else if ( QRegularExpression( "^.WP" ).match( m_vectorName ).hasMatch() ) { return RiaDefines::PhaseType::WATER_PHASE; } return RiaDefines::PhaseType::PHASE_NOT_APPLICABLE; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimSummaryAddress::keywordForCategory( RifEclipseSummaryAddress::SummaryVarCategory category ) const +{ + // Return the keyword text for supported field replacement in plot templates + + if ( category == RifEclipseSummaryAddress::SUMMARY_WELL ) return m_wellName.keyword(); + if ( category == RifEclipseSummaryAddress::SUMMARY_GROUP ) return m_groupName.keyword(); + if ( category == RifEclipseSummaryAddress::SUMMARY_REGION ) return m_regionNumber.keyword(); + + return {}; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryAddress::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +{ + uiOrdering.skipRemainingFields( true ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryAddress::setCaseId( int caseId ) +{ + m_caseId = caseId; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimSummaryAddress::caseId() const +{ + return m_caseId; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimSummaryAddress::quantityName() const +{ + return m_vectorName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryAddress::setEnsembleId( int ensembleId ) +{ + m_ensembleId = ensembleId; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimSummaryAddress::ensembleId() const +{ + return m_ensembleId; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryAddress::isEnsemble() const +{ + return m_ensembleId >= 0; +} diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddress.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddress.h index 7b54ba07ae..b6a2f735a8 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddress.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddress.h @@ -44,26 +44,46 @@ class RimSummaryAddress : public caf::PdmObject RimSummaryAddress(); ~RimSummaryAddress() override; + static RimSummaryAddress* + wrapFileReaderAddress( const RifEclipseSummaryAddress& addr, int caseId = -1, int ensembleId = -1 ); + void setAddress( const RifEclipseSummaryAddress& addr ); - RifEclipseSummaryAddress address(); + RifEclipseSummaryAddress address() const; + + void setCaseId( int caseId ); + int caseId() const; + + void setEnsembleId( int ensembleId ); + int ensembleId() const; + bool isEnsemble() const; + + QString quantityName() const; - void ensureIdIsAssigned(); + void ensureCalculationIdIsAssigned(); RiaDefines::PhaseType addressPhaseType() const; + QString keywordForCategory( RifEclipseSummaryAddress::SummaryVarCategory category ) const; + +protected: + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + private: caf::PdmField> m_category; - caf::PdmField m_quantityName; - caf::PdmField m_regionNumber; - caf::PdmField m_regionNumber2; - caf::PdmField m_wellGroupName; - caf::PdmField m_wellName; - caf::PdmField m_wellSegmentNumber; - caf::PdmField m_lgrName; - caf::PdmField m_cellI; - caf::PdmField m_cellJ; - caf::PdmField m_cellK; - caf::PdmField m_aquiferNumber; - caf::PdmField m_isErrorResult; - caf::PdmField m_calculationId; + + caf::PdmField m_vectorName; + caf::PdmField m_regionNumber; + caf::PdmField m_regionNumber2; + caf::PdmField m_groupName; + caf::PdmField m_wellName; + caf::PdmField m_wellSegmentNumber; + caf::PdmField m_lgrName; + caf::PdmField m_cellI; + caf::PdmField m_cellJ; + caf::PdmField m_cellK; + caf::PdmField m_aquiferNumber; + caf::PdmField m_isErrorResult; + caf::PdmField m_calculationId; + caf::PdmField m_caseId; + caf::PdmField m_ensembleId; }; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.cpp new file mode 100644 index 0000000000..304a23c616 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.cpp @@ -0,0 +1,511 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimSummaryAddressCollection.h" + +#include "RifEclipseSummaryAddress.h" + +#include "RimSummaryAddress.h" + +#include "cafPdmUiTreeOrdering.h" + +template <> +void caf::AppEnum::setUp() +{ + addItem( RimSummaryAddressCollection::CollectionContentType::NOT_DEFINED, "NOT_DEFINED", "Not Defined" ); + addItem( RimSummaryAddressCollection::CollectionContentType::FIELD, "FIELD", "Field" ); + addItem( RimSummaryAddressCollection::CollectionContentType::AQUIFER, "AQUIFER", "Aquifer" ); + addItem( RimSummaryAddressCollection::CollectionContentType::NETWORK, "NETWORK", "Network" ); + addItem( RimSummaryAddressCollection::CollectionContentType::MISC, "MISC", "Miscellaneous" ); + addItem( RimSummaryAddressCollection::CollectionContentType::REGION, "REGION", "Region" ); + addItem( RimSummaryAddressCollection::CollectionContentType::REGION_2_REGION, "REGION_2_REGION", "Region-Region" ); + addItem( RimSummaryAddressCollection::CollectionContentType::GROUP, "GROUP", "Group" ); + addItem( RimSummaryAddressCollection::CollectionContentType::WELL, "WELL", "Well" ); + addItem( RimSummaryAddressCollection::CollectionContentType::WELL_COMPLETION, "WELL_COMPLETION", "Completion" ); + addItem( RimSummaryAddressCollection::CollectionContentType::WELL_SEGMENT, "WELL_SEGMENT", "Segment" ); + addItem( RimSummaryAddressCollection::CollectionContentType::BLOCK, "BLOCK", "Block" ); + addItem( RimSummaryAddressCollection::CollectionContentType::WELL_LGR, "WELL_LGR", "Lgr-Well" ); + addItem( RimSummaryAddressCollection::CollectionContentType::WELL_COMPLETION_LGR, + "WELL_COMPLETION_LGR", + "Lgr Completion" ); + addItem( RimSummaryAddressCollection::CollectionContentType::BLOCK_LGR, "BLOCK_LGR", "Lgr-Block" ); + addItem( RimSummaryAddressCollection::CollectionContentType::CALCULATED, "CALCULATED", "Calculated" ); + addItem( RimSummaryAddressCollection::CollectionContentType::IMPORTED, "IMPORTED", "Imported" ); + setDefault( RimSummaryAddressCollection::CollectionContentType::NOT_DEFINED ); +} + +CAF_PDM_SOURCE_INIT( RimSummaryAddressCollection, "RimSummaryAddressCollection" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryAddressCollection::RimSummaryAddressCollection() +{ + CAF_PDM_InitObject( "Folder", ":/Folder.png", "", "" ); + + CAF_PDM_InitFieldNoDefault( &m_contentType, "ContentsType", "Contents" ); + m_contentType = RimSummaryAddressCollection::CollectionContentType::NOT_DEFINED; + m_contentType.uiCapability()->setUiReadOnly( true ); + m_contentType.uiCapability()->setUiHidden( true ); + + CAF_PDM_InitFieldNoDefault( &m_adresses, "SummaryAddresses", "Addresses" ); + m_adresses.uiCapability()->setUiTreeHidden( true ); + + CAF_PDM_InitFieldNoDefault( &m_subfolders, "AddressSubfolders", "Subfolders" ); + m_subfolders.uiCapability()->setUiTreeHidden( true ); + + CAF_PDM_InitField( &m_caseId, "CaseId", -1, "CaseId" ); + m_caseId.uiCapability()->setUiHidden( true ); + + CAF_PDM_InitField( &m_ensembleId, "EnsembleId", -1, "EnsembleId" ); + m_ensembleId.uiCapability()->setUiHidden( true ); + + nameField()->uiCapability()->setUiHidden( true ); + nameField()->uiCapability()->setUiReadOnly( true ); + + setUiIconFromResourceString( iconResourceText() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryAddressCollection::~RimSummaryAddressCollection() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryAddressCollection::hasDataVector( const QString quantityName ) const +{ + for ( auto& address : m_adresses ) + { + if ( address->quantityName() == quantityName ) return true; + } + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryAddressCollection::hasDataVector( const std::string quantityName ) const +{ + return hasDataVector( QString::fromStdString( quantityName ) ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryAddressCollection::addAddress( const RifEclipseSummaryAddress& address, int caseId, int ensembleId ) +{ + if ( !hasDataVector( address.vectorName() ) ) + { + m_adresses.push_back( RimSummaryAddress::wrapFileReaderAddress( address, caseId, ensembleId ) ); + if ( m_caseId == -1 ) m_caseId = caseId; + if ( m_ensembleId == -1 ) m_ensembleId = ensembleId; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryAddressCollection::addToSubfolder( QString foldername, + CollectionContentType folderType, + const RifEclipseSummaryAddress& address, + int caseId, + int ensembleId ) +{ + RimSummaryAddressCollection* folder = getOrCreateSubfolder( foldername, folderType ); + folder->addAddress( address, caseId, ensembleId ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryAddressCollection::addToSubfolderTree( std::vector folders, + CollectionContentType folderType, + const RifEclipseSummaryAddress& address, + int caseId, + int ensembleId ) +{ + RimSummaryAddressCollection* thefolder = this; + for ( auto& subfoldername : folders ) + { + thefolder = thefolder->getOrCreateSubfolder( subfoldername, folderType ); + } + thefolder->setContentType( folderType ); + thefolder->addAddress( address, caseId, ensembleId ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryAddressCollection::updateFolderStructure( const std::set& addresses, + int caseId, + int ensembleId ) +{ + if ( addresses.size() == 0 ) return; + + auto* fields = getOrCreateSubfolder( "Field", CollectionContentType::FIELD ); + auto* aquifer = getOrCreateSubfolder( "Aquifer", CollectionContentType::AQUIFER ); + auto* network = getOrCreateSubfolder( "Network", CollectionContentType::NETWORK ); + auto* misc = getOrCreateSubfolder( "Miscellaneous", CollectionContentType::MISC ); + auto* regions = getOrCreateSubfolder( "Region", CollectionContentType::REGION_FOLDER ); + auto* region2region = getOrCreateSubfolder( "Region-Region", CollectionContentType::REGION_2_REGION ); + auto* groups = getOrCreateSubfolder( "Group", CollectionContentType::GROUP_FOLDER ); + auto* wells = getOrCreateSubfolder( "Well", CollectionContentType::WELL_FOLDER ); + auto* completion = getOrCreateSubfolder( "Completion", CollectionContentType::WELL_COMPLETION ); + auto* segment = getOrCreateSubfolder( "Segment", CollectionContentType::WELL_SEGMENT ); + auto* blocks = getOrCreateSubfolder( "Block", CollectionContentType::BLOCK ); + auto* lgrwell = getOrCreateSubfolder( "Lgr-Well", CollectionContentType::WELL_LGR ); + auto* lgrcompletion = getOrCreateSubfolder( "Lgr-Completion", CollectionContentType::WELL_COMPLETION_LGR ); + auto* lgrblock = getOrCreateSubfolder( "Lgr-Block", CollectionContentType::BLOCK_LGR ); + auto* calculated = getOrCreateSubfolder( "Calculated", CollectionContentType::CALCULATED ); + auto* imported = getOrCreateSubfolder( "Imported", CollectionContentType::IMPORTED ); + + for ( const auto& address : addresses ) + { + switch ( address.category() ) + { + case RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_FIELD: + fields->addAddress( address, caseId, ensembleId ); + break; + + case RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_AQUIFER: + aquifer->addToSubfolder( QString::number( address.aquiferNumber() ), + CollectionContentType::AQUIFER, + address, + caseId, + ensembleId ); + break; + + case RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_NETWORK: + network->addAddress( address, caseId, ensembleId ); + break; + + case RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_MISC: + misc->addAddress( address, caseId, ensembleId ); + break; + + case RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_REGION: + regions->addToSubfolder( QString::number( address.regionNumber() ), + CollectionContentType::REGION, + address, + caseId, + ensembleId ); + break; + + case RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_REGION_2_REGION: + region2region->addToSubfolder( QString::fromStdString( address.itemUiText() ), + CollectionContentType::REGION_2_REGION, + address, + caseId, + ensembleId ); + break; + + case RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_GROUP: + groups->addToSubfolder( QString::fromStdString( address.groupName() ), + CollectionContentType::GROUP, + address, + caseId, + ensembleId ); + break; + + case RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL: + wells->addToSubfolder( QString::fromStdString( address.wellName() ), + CollectionContentType::WELL, + address, + caseId, + ensembleId ); + break; + + case RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL_COMPLETION: + completion->addToSubfolderTree( { QString::fromStdString( address.wellName() ), + QString::fromStdString( address.blockAsString() ) }, + CollectionContentType::WELL_COMPLETION, + address, + caseId, + ensembleId ); + break; + + case RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL_SEGMENT: + segment->addToSubfolderTree( { QString::fromStdString( address.wellName() ), + QString::number( address.wellSegmentNumber() ) }, + CollectionContentType::WELL_SEGMENT, + address, + caseId, + ensembleId ); + break; + + case RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_BLOCK: + blocks->addToSubfolder( QString::fromStdString( address.blockAsString() ), + CollectionContentType::BLOCK, + address, + caseId, + ensembleId ); + break; + + case RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL_LGR: + lgrwell->addToSubfolderTree( { QString::fromStdString( address.lgrName() ), + QString::fromStdString( address.wellName() ) }, + CollectionContentType::WELL_LGR, + address, + caseId, + ensembleId ); + break; + + case RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL_COMPLETION_LGR: + lgrcompletion->addToSubfolderTree( { QString::fromStdString( address.lgrName() ), + QString::fromStdString( address.wellName() ), + QString::fromStdString( address.blockAsString() ) }, + CollectionContentType::WELL_COMPLETION_LGR, + address, + caseId, + ensembleId ); + break; + + case RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_BLOCK_LGR: + lgrblock->addToSubfolderTree( { QString::fromStdString( address.lgrName() ), + QString::fromStdString( address.blockAsString() ) }, + CollectionContentType::BLOCK_LGR, + address, + caseId, + ensembleId ); + break; + + case RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_IMPORTED: + imported->addToSubfolder( QString::fromStdString( address.itemUiText() ), + CollectionContentType::IMPORTED, + address, + caseId, + ensembleId ); + break; + + case RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_CALCULATED: + calculated->addToSubfolder( QString::fromStdString( address.itemUiText() ), + CollectionContentType::CALCULATED, + address, + caseId, + ensembleId ); + break; + + default: + continue; + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryAddressCollection* RimSummaryAddressCollection::getOrCreateSubfolder( const QString folderName, + CollectionContentType createFolderType ) +{ + for ( auto& folder : m_subfolders ) + { + if ( folder->name() == folderName ) + { + return folder; + } + } + + RimSummaryAddressCollection* newFolder = new RimSummaryAddressCollection(); + newFolder->setName( folderName ); + newFolder->setContentType( createFolderType ); + m_subfolders.push_back( newFolder ); + return newFolder; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryAddressCollection::deleteChildren() +{ + m_adresses.deleteChildren(); + m_subfolders.deleteChildren(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryAddressCollection::isEmpty() const +{ + return ( ( m_adresses.size() == 0 ) && ( m_subfolders.size() == 0 ) ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryAddressCollection::canBeDragged() const +{ + bool ok = m_subfolders.size() == 0; + + ok = ok && ( m_contentType == CollectionContentType::WELL || m_contentType == CollectionContentType::GROUP || + m_contentType == CollectionContentType::REGION ); + + return ok || isFolder(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryAddressCollection::updateUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering ) const +{ + for ( auto& folder : m_subfolders() ) + { + if ( !folder->isEmpty() ) uiTreeOrdering.add( folder ); + } + + for ( auto& address : m_adresses() ) + { + uiTreeOrdering.add( address ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryAddressCollection::setContentType( CollectionContentType content ) +{ + m_contentType = content; + setUiIconFromResourceString( iconResourceText() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryAddressCollection::CollectionContentType RimSummaryAddressCollection::contentType() const +{ + return m_contentType(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryAddressCollection::setEnsembleId( int ensembleId ) +{ + m_ensembleId = ensembleId; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryAddressCollection::setCaseId( int caseId ) +{ + m_caseId = caseId; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryAddressCollection::isEnsemble() const +{ + return m_ensembleId >= 0; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryAddressCollection::isFolder() const +{ + if ( contentType() == CollectionContentType::WELL_FOLDER || contentType() == CollectionContentType::GROUP_FOLDER || + contentType() == CollectionContentType::REGION_FOLDER ) + { + return true; + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimSummaryAddressCollection::ensembleId() const +{ + return m_ensembleId; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimSummaryAddressCollection::subFolders() const +{ + return m_subfolders.children(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimSummaryAddressCollection::caseId() const +{ + return m_caseId; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimSummaryAddressCollection::iconResourceText() const +{ + switch ( m_contentType() ) + { + case RimSummaryAddressCollection::CollectionContentType::WELL: + return ":/summary/components/images/well.svg"; + case RimSummaryAddressCollection::CollectionContentType::GROUP: + return ":/summary/components/images/group.svg"; + case RimSummaryAddressCollection::CollectionContentType::REGION: + return ":/summary/components/images/region.svg"; + case RimSummaryAddressCollection::CollectionContentType::FIELD: + return ":/summary/components/images/field.svg"; + case RimSummaryAddressCollection::CollectionContentType::MISC: + return ":/summary/components/images/misc.svg"; + case RimSummaryAddressCollection::CollectionContentType::WELL_FOLDER: + return ":/summary/components/images/well.svg"; + case RimSummaryAddressCollection::CollectionContentType::GROUP_FOLDER: + return ":/summary/components/images/group.svg"; + case RimSummaryAddressCollection::CollectionContentType::REGION_FOLDER: + return ":/summary/components/images/region.svg"; + case RimSummaryAddressCollection::CollectionContentType::BLOCK: + return ":/summary/components/images/block.svg"; + case RimSummaryAddressCollection::CollectionContentType::SUMMARY_CASE: + return ":/SummaryCase.svg"; + case RimSummaryAddressCollection::CollectionContentType::AQUIFER: + return ":/summary/components/images/aquifer.svg"; + case RimSummaryAddressCollection::CollectionContentType::NETWORK: + return ":/summary/components/images/network.svg"; + case RimSummaryAddressCollection::CollectionContentType::REGION_2_REGION: + return ":/summary/components/images/region-region.svg"; + case RimSummaryAddressCollection::CollectionContentType::WELL_COMPLETION: + return ":/summary/components/images/well-completion.svg"; + case RimSummaryAddressCollection::CollectionContentType::WELL_LGR: + return ":/summary/components/images/well.svg"; + case RimSummaryAddressCollection::CollectionContentType::WELL_COMPLETION_LGR: + return ":/summary/components/images/well-completion.svg"; + case RimSummaryAddressCollection::CollectionContentType::WELL_SEGMENT: + return ":/summary/components/images/segment.svg"; + case RimSummaryAddressCollection::CollectionContentType::BLOCK_LGR: + return ":/summary/components/images/block.svg"; + case RimSummaryAddressCollection::CollectionContentType::CALCULATED: + return ":/summary/components/images/calculated.svg"; + case RimSummaryAddressCollection::CollectionContentType::IMPORTED: + return ":/summary/components/images/others.svg"; + case RimSummaryAddressCollection::CollectionContentType::NOT_DEFINED: + default: + break; + } + return ":/Folder.png"; +} diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.h new file mode 100644 index 0000000000..168131f088 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.h @@ -0,0 +1,116 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// +#pragma once + +#include "RimNamedObject.h" + +#include "cafPdmChildArrayField.h" + +#include +#include +#include + +class RimSummaryAddress; +class RifEclipseSummaryAddress; + +class RimSummaryAddressCollection : public RimNamedObject +{ + CAF_PDM_HEADER_INIT; + +public: + enum class CollectionContentType + { + NOT_DEFINED, + WELL, + GROUP, + REGION, + FIELD, + MISC, + WELL_FOLDER, + GROUP_FOLDER, + REGION_FOLDER, + BLOCK, + SUMMARY_CASE, + AQUIFER, + NETWORK, + REGION_2_REGION, + WELL_COMPLETION, + WELL_LGR, + WELL_COMPLETION_LGR, + WELL_SEGMENT, + BLOCK_LGR, + CALCULATED, + IMPORTED + }; + +public: + RimSummaryAddressCollection(); + ~RimSummaryAddressCollection() override; + + void updateFolderStructure( const std::set& addresses, int caseId, int ensembleId = -1 ); + + void deleteChildren(); + + bool isEmpty() const; + bool isEnsemble() const; + bool isFolder() const; + + bool canBeDragged() const; + + void updateUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering ) const; + + void setContentType( CollectionContentType content ); + CollectionContentType contentType() const; + + void setCaseId( int caseId ); + int caseId() const; + void setEnsembleId( int ensembleId ); + int ensembleId() const; + + std::vector subFolders() const; + +private: + RimSummaryAddressCollection* + getOrCreateSubfolder( const QString folderName, + CollectionContentType createFolderType = CollectionContentType::NOT_DEFINED ); + + bool hasDataVector( const QString quantityName ) const; + bool hasDataVector( const std::string quantityName ) const; + + void addAddress( const RifEclipseSummaryAddress& address, int caseId, int ensembleId = -1 ); + void addToSubfolder( QString foldername, + CollectionContentType folderType, + const RifEclipseSummaryAddress& address, + int caseId, + int ensembleId = -1 ); + + void addToSubfolderTree( std::vector folders, + CollectionContentType folderType, + const RifEclipseSummaryAddress& address, + int caseId, + int ensembleId = -1 ); + + QString iconResourceText() const; + +private: + caf::PdmChildArrayField m_adresses; + caf::PdmChildArrayField m_subfolders; + caf::PdmField> m_contentType; + caf::PdmField m_caseId; + caf::PdmField m_ensembleId; +}; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressModifier.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressModifier.cpp new file mode 100644 index 0000000000..9865bdc4e2 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressModifier.cpp @@ -0,0 +1,111 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimSummaryAddressModifier.h" + +#include "RifEclipseSummaryAddress.h" + +#include "RimEnsembleCurveSet.h" +#include "RimSummaryCurve.h" +#include "RimSummaryPlot.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryAddressModifier::RimSummaryAddressModifier( RimSummaryCurve* curve ) + : m_curve( curve ) + , m_curveSet( nullptr ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryAddressModifier::RimSummaryAddressModifier( RimEnsembleCurveSet* curveSet ) + : m_curve( nullptr ) + , m_curveSet( curveSet ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimSummaryAddressModifier::createAddressModifiersForPlot( RimSummaryPlot* summaryPlot ) +{ + std::vector mods; + if ( summaryPlot ) + { + auto curveSets = summaryPlot->curveSets(); + for ( auto curveSet : curveSets ) + { + mods.emplace_back( RimSummaryAddressModifier( curveSet ) ); + } + + auto curves = summaryPlot->allCurves( RimSummaryDataSourceStepping::Axis::Y_AXIS ); + for ( auto c : curves ) + { + mods.emplace_back( RimSummaryAddressModifier( c ) ); + } + } + + return mods; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimSummaryAddressModifier::createEclipseSummaryAddress( RimSummaryPlot* summaryPlot ) +{ + auto mods = createAddressModifiersForPlot( summaryPlot ); + return convertToEclipseSummaryAddress( mods ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifEclipseSummaryAddress RimSummaryAddressModifier::address() const +{ + if ( m_curve ) return m_curve->summaryAddressY(); + if ( m_curveSet ) return m_curveSet->summaryAddress(); + + return {}; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryAddressModifier::setAddress( const RifEclipseSummaryAddress& address ) +{ + if ( m_curve ) m_curve->setSummaryAddressY( address ); + if ( m_curveSet ) m_curveSet->setSummaryAddress( address ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector + RimSummaryAddressModifier::convertToEclipseSummaryAddress( const std::vector& modifiers ) +{ + std::vector tmp; + tmp.reserve( modifiers.size() ); + for ( const auto& m : modifiers ) + { + tmp.emplace_back( m.address() ); + } + return tmp; +} diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressModifier.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressModifier.h new file mode 100644 index 0000000000..4646561929 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressModifier.h @@ -0,0 +1,47 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +class RimSummaryCurve; +class RimEnsembleCurveSet; +class RimSummaryPlot; +class RifEclipseSummaryAddress; + +#include + +class RimSummaryAddressModifier +{ +public: + RimSummaryAddressModifier( RimSummaryCurve* curve ); + RimSummaryAddressModifier( RimEnsembleCurveSet* curveSet ); + + static std::vector createAddressModifiersForPlot( RimSummaryPlot* summaryPlot ); + static std::vector createEclipseSummaryAddress( RimSummaryPlot* summaryPlot ); + + RifEclipseSummaryAddress address() const; + void setAddress( const RifEclipseSummaryAddress& address ); + +private: + static std::vector + convertToEclipseSummaryAddress( const std::vector& modifiers ); + +private: + RimSummaryCurve* m_curve; + RimEnsembleCurveSet* m_curveSet; +}; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.cpp index 7a544f8564..882a16c6f4 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.cpp @@ -24,12 +24,17 @@ #include "RicfCommandObject.h" #include "RifSummaryReaderInterface.h" +#include "RifEclipseSummaryAddress.h" + #include "RimMainPlotCollection.h" #include "RimProject.h" +#include "RimSummaryAddress.h" +#include "RimSummaryAddressCollection.h" #include "RimSummaryCaseCollection.h" -#include "RimSummaryPlotCollection.h" #include "cafPdmFieldScriptingCapability.h" +#include "cafPdmUiCheckBoxEditor.h" +#include "cafPdmUiTreeOrdering.h" #include "cvfAssert.h" @@ -47,21 +52,29 @@ RimSummaryCase::RimSummaryCase() { CAF_PDM_InitScriptableObject( "Summary Case", ":/SummaryCase.svg", "", "The Base Class for all Summary Cases" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_displayName, "ShortName", "Display Name", "", "", "" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_displayNameOption, "NameSetting", "Name Setting", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_displayName, "ShortName", "Display Name" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_displayNameOption, "NameSetting", "Name Setting" ); + + CAF_PDM_InitScriptableField( &m_showSubNodesInTree, "ShowSubNodesInTree", false, "Show Summary Data Sub-Tree" ); + caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_showSubNodesInTree ); - CAF_PDM_InitScriptableField( &m_useAutoShortName_OBSOLETE, "AutoShortyName", false, "Use Auto Display Name", "", "", "" ); + CAF_PDM_InitScriptableField( &m_useAutoShortName_OBSOLETE, "AutoShortyName", false, "Use Auto Display Name" ); m_useAutoShortName_OBSOLETE.xmlCapability()->setIOWritable( false ); m_useAutoShortName_OBSOLETE.uiCapability()->setUiHidden( true ); - CAF_PDM_InitScriptableFieldNoDefault( &m_summaryHeaderFilename, "SummaryHeaderFilename", "Summary Header File", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_summaryHeaderFilename, "SummaryHeaderFilename", "Summary Header File" ); m_summaryHeaderFilename.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitScriptableField( &m_caseId, "Id", -1, "Case ID", "", "", "" ); + CAF_PDM_InitScriptableField( &m_caseId, "Id", -1, "Case ID" ); m_caseId.registerKeywordAlias( "CaseId" ); m_caseId.uiCapability()->setUiReadOnly( true ); m_caseId.capability()->setIOWriteable( false ); + CAF_PDM_InitFieldNoDefault( &m_dataVectorFolders, "DataVectorFolders", "Data Folders" ); + m_dataVectorFolders = new RimSummaryAddressCollection(); + m_dataVectorFolders.uiCapability()->setUiHidden( true ); + m_dataVectorFolders.xmlCapability()->disableIO(); + m_isObservedData = false; } @@ -99,6 +112,23 @@ bool RimSummaryCase::isObservedData() const return m_isObservedData; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryCase::showRealizationDataSources() const +{ + return m_showSubNodesInTree(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCase::setShowRealizationDataSource( bool enable ) +{ + m_showSubNodesInTree = enable; + updateConnectedEditors(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -172,6 +202,10 @@ void RimSummaryCase::fieldChangedByUi( const caf::PdmFieldHandle* changedField, updateTreeItemName(); nameChanged.send(); } + else if ( changedField == &m_showSubNodesInTree ) + { + updateConnectedEditors(); + } updateOptionSensitivity(); } @@ -200,11 +234,47 @@ QString RimSummaryCase::errorMessagesFromReader() return QString(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCase::buildChildNodes() +{ + m_dataVectorFolders->deleteChildren(); + + RifSummaryReaderInterface* reader = summaryReader(); + if ( !reader ) return; + + m_dataVectorFolders->updateFolderStructure( reader->allResultAddresses(), m_caseId ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCase::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +{ + uiOrdering.add( &m_displayName ); + uiOrdering.add( &m_displayNameOption ); + uiOrdering.add( &m_summaryHeaderFilename ); + uiOrdering.add( &m_caseId ); + + if ( ensemble() ) uiOrdering.add( &m_showSubNodesInTree ); + + uiOrdering.skipRemainingFields( true ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimSummaryCase::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/ ) { + if ( !ensemble() || m_showSubNodesInTree() ) + { + if ( m_dataVectorFolders->isEmpty() ) buildChildNodes(); + m_dataVectorFolders->updateUiTreeOrdering( uiTreeOrdering ); + } + + uiTreeOrdering.skipRemainingChildren( true ); + updateTreeItemName(); } @@ -271,58 +341,6 @@ void RimSummaryCase::initAfterRead() updateOptionSensitivity(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RimSummaryCase::uniqueShortNameForEnsembleCase( RimSummaryCase* summaryCase ) -{ - CAF_ASSERT( summaryCase && summaryCase->ensemble() ); - - QString ensembleCaseName = summaryCase->caseName(); - - auto ensemble = summaryCase->ensemble(); - - std::vector summaryCases = ensemble->allSummaryCases(); - - QRegularExpression trimRe( "^[^a-zA-Z0-9]+" ); - - QStringList summaryFilePaths; - summaryFilePaths.push_back( summaryCase->summaryHeaderFilename() ); - - for ( auto otherSummaryCase : summaryCases ) - { - if ( otherSummaryCase != summaryCase ) - { - summaryFilePaths.push_back( otherSummaryCase->summaryHeaderFilename() ); - } - } - - return RiaEnsembleNameTools::uniqueShortName( summaryCase->summaryHeaderFilename(), summaryFilePaths, ensembleCaseName ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RimSummaryCase::uniqueShortNameForSummaryCase( RimSummaryCase* summaryCase ) -{ - std::set allAutoShortNames; - - std::vector allCases; - RimProject::current()->descendantsOfType( allCases ); - - for ( RimSummaryCase* sumCase : allCases ) - { - if ( sumCase && sumCase != summaryCase ) - { - allAutoShortNames.insert( sumCase->displayCaseName() ); - } - } - - return RimCaseDisplayNameTools::uniqueShortName( summaryCase->caseName(), - allAutoShortNames, - RimCaseDisplayNameTools::CASE_SHORT_NAME_LENGTH ); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -336,11 +354,11 @@ void RimSummaryCase::updateAutoShortName() { if ( ensemble() ) { - m_displayName = RimSummaryCase::uniqueShortNameForEnsembleCase( this ); + m_displayName = RiaEnsembleNameTools::uniqueShortNameForEnsembleCase( this ); } else { - m_displayName = RimSummaryCase::uniqueShortNameForSummaryCase( this ); + m_displayName = RiaEnsembleNameTools::uniqueShortNameForSummaryCase( this ); } } updateTreeItemName(); @@ -361,3 +379,12 @@ int RimSummaryCase::caseId() const { return m_caseId(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCase::refreshMetaData() +{ + buildChildNodes(); + updateConnectedEditors(); +} diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.h index 4101956284..8728d2dea8 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.h @@ -23,6 +23,8 @@ #include "RimCaseDisplayNameTools.h" #include "cafFilePath.h" +#include "cafPdmChildArrayField.h" +#include "cafPdmChildField.h" #include "cafPdmField.h" #include "cafPdmObject.h" @@ -31,6 +33,7 @@ class RifReaderRftInterface; class RifSummaryReaderInterface; class RimSummaryCaseCollection; +class RimSummaryAddressCollection; //================================================================================================== // @@ -63,18 +66,21 @@ class RimSummaryCase : public caf::PdmObject void updateAutoShortName(); void updateOptionSensitivity(); + void refreshMetaData(); + virtual void createSummaryReaderInterface() = 0; virtual void createRftReaderInterface() {} virtual RifSummaryReaderInterface* summaryReader() = 0; virtual RifReaderRftInterface* rftReader(); virtual QString errorMessagesFromReader(); - virtual void updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) = 0; - void setSummaryHeaderFileName( const QString& fileName ); bool isObservedData() const; + bool showRealizationDataSources() const; + void setShowRealizationDataSource( bool enable ); + void setCaseRealizationParameters( const std::shared_ptr& crlParameters ); std::shared_ptr caseRealizationParameters() const; bool hasCaseRealizationParameters() const; @@ -83,6 +89,7 @@ class RimSummaryCase : public caf::PdmObject bool operator<( const RimSummaryCase& rhs ) const; protected: + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; void updateTreeItemName(); @@ -92,14 +99,17 @@ class RimSummaryCase : public caf::PdmObject void initAfterRead() override; private: - static QString uniqueShortNameForEnsembleCase( RimSummaryCase* summaryCase ); - static QString uniqueShortNameForSummaryCase( RimSummaryCase* summaryCase ); + void buildChildNodes(); protected: caf::PdmField m_displayName; caf::PdmField m_displayNameOption; caf::PdmField m_summaryHeaderFilename; + caf::PdmField m_showSubNodesInTree; + + caf::PdmChildField m_dataVectorFolders; + bool m_isObservedData; caf::PdmField m_caseId; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp index 879c99fa7d..c4327abba6 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp @@ -22,6 +22,7 @@ #include "RiaLogging.h" #include "RiaStatisticsTools.h" #include "RiaStdStringTools.h" +#include "RiaSummaryAddressAnalyzer.h" #include "RiaWeightedMeanCalculator.h" #include "RicfCommandObject.h" @@ -31,6 +32,7 @@ #include "RimEnsembleCurveSet.h" #include "RimGridSummaryCase.h" #include "RimProject.h" +#include "RimSummaryAddressCollection.h" #include "RimSummaryCase.h" #include "RifReaderEclipseRft.h" @@ -38,7 +40,9 @@ #include "RifSummaryReaderInterface.h" #include "cafPdmFieldScriptingCapability.h" +#include "cafPdmUiTreeOrdering.h" +#include #include #include @@ -105,25 +109,32 @@ RimSummaryCaseCollection::RimSummaryCaseCollection() : caseNameChanged( this ) , caseRemoved( this ) { - CAF_PDM_InitScriptableObject( "Summary Case Group", ":/SummaryGroup16x16.png", "", "" ); + CAF_PDM_InitScriptableObject( "Summary Case Group", ":/SummaryGroup16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_cases, "SummaryCases", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_cases, "SummaryCases", "" ); m_cases.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitScriptableField( &m_name, "SummaryCollectionName", QString( "Group" ), "Name", "", "", "" ); + CAF_PDM_InitScriptableField( &m_name, "SummaryCollectionName", QString( "Group" ), "Name" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_nameAndItemCount, "NameCount", "Name", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_nameAndItemCount, "NameCount", "Name" ); m_nameAndItemCount.registerGetMethod( this, &RimSummaryCaseCollection::nameAndItemCount ); - RiaFieldhandleTools::disableWriteAndSetFieldHidden( &m_nameAndItemCount ); + RiaFieldHandleTools::disableWriteAndSetFieldHidden( &m_nameAndItemCount ); - CAF_PDM_InitScriptableField( &m_isEnsemble, "IsEnsemble", false, "Is Ensemble", "", "", "" ); + CAF_PDM_InitScriptableField( &m_isEnsemble, "IsEnsemble", false, "Is Ensemble" ); m_isEnsemble.uiCapability()->setUiHidden( true ); - CAF_PDM_InitScriptableField( &m_ensembleId, "Id", -1, "Ensemble ID", "", "", "" ); + CAF_PDM_InitScriptableField( &m_ensembleId, "Id", -1, "Ensemble ID" ); m_ensembleId.registerKeywordAlias( "EnsembleId" ); m_ensembleId.uiCapability()->setUiReadOnly( true ); m_ensembleId.capability()->setIOWriteable( false ); + CAF_PDM_InitFieldNoDefault( &m_dataVectorFolders, "DataVectorFolders", "Data Folders" ); + m_dataVectorFolders = new RimSummaryAddressCollection(); + m_dataVectorFolders.uiCapability()->setUiHidden( true ); + m_dataVectorFolders.uiCapability()->setUiTreeHidden( true ); + m_dataVectorFolders->uiCapability()->setUiTreeHidden( true ); + m_dataVectorFolders.xmlCapability()->disableIO(); + m_statisticsEclipseRftReader = new RifReaderEnsembleStatisticsRft( this ); m_commonAddressCount = 0; @@ -134,30 +145,36 @@ RimSummaryCaseCollection::RimSummaryCaseCollection() //-------------------------------------------------------------------------------------------------- RimSummaryCaseCollection::~RimSummaryCaseCollection() { - m_cases.deleteAllChildObjectsAsync(); + m_cases.deleteChildrenAsync(); updateReferringCurveSets(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCaseCollection::removeCase( RimSummaryCase* summaryCase ) +void RimSummaryCaseCollection::removeCase( RimSummaryCase* summaryCase, bool notifyChange ) { size_t caseCountBeforeRemove = m_cases.size(); - m_cases.removeChildObject( summaryCase ); + m_cases.removeChild( summaryCase ); m_cachedSortedEnsembleParameters.clear(); + m_analyzer.reset(); caseRemoved.send( summaryCase ); - updateReferringCurveSets(); + if ( notifyChange ) + { + updateReferringCurveSets(); + } if ( m_isEnsemble && m_cases.size() != caseCountBeforeRemove ) { if ( dynamic_cast( summaryCase ) == nullptr ) calculateEnsembleParametersIntersectionHash(); } + + clearChildNodes(); } //-------------------------------------------------------------------------------------------------- @@ -167,8 +184,11 @@ void RimSummaryCaseCollection::addCase( RimSummaryCase* summaryCase ) { summaryCase->nameChanged.connect( this, &RimSummaryCaseCollection::onCaseNameChanged ); + if ( m_cases.empty() ) summaryCase->setShowRealizationDataSource( true ); + m_cases.push_back( summaryCase ); m_cachedSortedEnsembleParameters.clear(); + m_analyzer.reset(); // Update derived ensemble cases (if any) std::vector referringObjects; @@ -188,6 +208,8 @@ void RimSummaryCaseCollection::addCase( RimSummaryCase* summaryCase ) } updateReferringCurveSets(); + + clearChildNodes(); } //-------------------------------------------------------------------------------------------------- @@ -195,7 +217,17 @@ void RimSummaryCaseCollection::addCase( RimSummaryCase* summaryCase ) //-------------------------------------------------------------------------------------------------- std::vector RimSummaryCaseCollection::allSummaryCases() const { - return m_cases.childObjects(); + return m_cases.children(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryCase* RimSummaryCaseCollection::firstSummaryCase() const +{ + if ( !m_cases.empty() ) return m_cases[0]; + + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -237,6 +269,8 @@ void RimSummaryCaseCollection::setAsEnsemble( bool isEnsemble ) validateEnsembleCases( allSummaryCases() ); calculateEnsembleParametersIntersectionHash(); } + + refreshMetaData(); } } @@ -315,6 +349,7 @@ std::set RimSummaryCaseCollection::ensembleTimeSteps() const } return allTimeSteps; } + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -872,7 +907,11 @@ caf::PdmFieldHandle* RimSummaryCaseCollection::userDescriptionField() //-------------------------------------------------------------------------------------------------- void RimSummaryCaseCollection::onLoadDataAndUpdate() { - if ( m_isEnsemble ) calculateEnsembleParametersIntersectionHash(); + if ( m_isEnsemble ) + { + calculateEnsembleParametersIntersectionHash(); + clearChildNodes(); + } } //-------------------------------------------------------------------------------------------------- @@ -896,6 +935,70 @@ void RimSummaryCaseCollection::updateReferringCurveSets() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaSummaryAddressAnalyzer* RimSummaryCaseCollection::addressAnalyzer() +{ + if ( !m_analyzer ) + { + m_analyzer = std::make_unique(); + + m_analyzer->appendAddresses( ensembleSummaryAddresses() ); + } + + return m_analyzer.get(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCaseCollection::computeMinMax( const RifEclipseSummaryAddress& address ) +{ + if ( m_minMaxValues.count( address ) > 0 ) return; + + double minimumValue( std::numeric_limits::infinity() ); + double maximumValue( -std::numeric_limits::infinity() ); + + std::vector values; + for ( const auto& s : m_cases() ) + { + if ( !s->summaryReader() ) continue; + + s->summaryReader()->values( address, &values ); + if ( values.empty() ) continue; + + const auto [min, max] = std::minmax_element( values.begin(), values.end() ); + + minimumValue = std::min( *min, minimumValue ); + maximumValue = std::max( *max, maximumValue ); + } + + if ( minimumValue != std::numeric_limits::infinity() && + maximumValue != -std::numeric_limits::infinity() ) + { + setMinMax( address, minimumValue, maximumValue ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCaseCollection::setMinMax( const RifEclipseSummaryAddress& address, double min, double max ) +{ + m_minMaxValues[address] = std::pair( min, max ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair RimSummaryCaseCollection::minMax( const RifEclipseSummaryAddress& address ) +{ + computeMinMax( address ); + + return m_minMaxValues[address]; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -969,6 +1072,31 @@ void RimSummaryCaseCollection::defineUiOrdering( QString uiConfigName, caf::PdmU uiOrdering.skipRemainingFields( true ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCaseCollection::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, + QString uiConfigName /*= ""*/ ) +{ + if ( m_isEnsemble() ) + { + buildChildNodes(); + + m_dataVectorFolders->updateUiTreeOrdering( uiTreeOrdering ); + + if ( !m_cases.empty() ) + { + auto subnode = uiTreeOrdering.add( "Realizations", ":/Folder.png" ); + for ( auto& smcase : m_cases ) + { + subnode->add( smcase ); + } + } + + uiTreeOrdering.skipRemainingChildren( true ); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1008,3 +1136,32 @@ bool RimSummaryCaseCollection::hasEnsembleParameters() const return false; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCaseCollection::buildChildNodes() +{ + if ( m_dataVectorFolders->isEmpty() ) + { + m_dataVectorFolders->updateFolderStructure( ensembleSummaryAddresses(), -1, m_ensembleId ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCaseCollection::refreshMetaData() +{ + clearChildNodes(); + buildChildNodes(); + updateConnectedEditors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCaseCollection::clearChildNodes() +{ + m_dataVectorFolders->deleteChildren(); +} diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h index d5c389cfcc..56457714b5 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h @@ -19,27 +19,31 @@ #pragma once #include "RiaDefines.h" -#include "RifEclipseRftAddress.h" #include "RifEclipseSummaryAddress.h" -#include "RifReaderEnsembleStatisticsRft.h" #include "RigEnsembleParameter.h" #include "RimObjectiveFunction.h" #include "cafPdmChildArrayField.h" +#include "cafPdmChildField.h" #include "cafPdmField.h" #include "cafPdmObject.h" #include "cafPdmProxyValueField.h" +#include "cvfObject.h" + #include +#include #include #include class RifReaderRftInterface; class RifReaderEnsembleStatisticsRft; class RimSummaryCase; +class RimSummaryAddressCollection; +class RiaSummaryAddressAnalyzer; //================================================================================================== /// @@ -56,21 +60,25 @@ class RimSummaryCaseCollection : public caf::PdmObject RimSummaryCaseCollection(); ~RimSummaryCaseCollection() override; - void removeCase( RimSummaryCase* summaryCase ); - void addCase( RimSummaryCase* summaryCase ); - virtual std::vector allSummaryCases() const; - void setName( const QString& name ); - QString name() const; + void removeCase( RimSummaryCase* summaryCase, bool notifyChange = true ); + void addCase( RimSummaryCase* summaryCase ); + virtual std::vector allSummaryCases() const; + RimSummaryCase* firstSummaryCase() const; + + void setName( const QString& name ); + QString name() const; + bool isEnsemble() const; void setAsEnsemble( bool isEnsemble ); virtual std::set ensembleSummaryAddresses() const; virtual std::set ensembleTimeSteps() const; - std::set wellsWithRftData() const; - std::set rftTimeStepsForWell( const QString& wellName ) const; - RifReaderRftInterface* rftStatisticsReader(); - void setEnsembleId( int ensembleId ); - int ensembleId() const; - bool hasEnsembleParameters() const; + + std::set wellsWithRftData() const; + std::set rftTimeStepsForWell( const QString& wellName ) const; + RifReaderRftInterface* rftStatisticsReader(); + void setEnsembleId( int ensembleId ); + int ensembleId() const; + bool hasEnsembleParameters() const; std::vector variationSortedEnsembleParameters( bool excludeNoVariation = false ) const; std::vector> @@ -100,6 +108,16 @@ class RimSummaryCaseCollection : public caf::PdmObject RiaDefines::EclipseUnitSystem unitSystem() const; + void refreshMetaData(); + + void updateReferringCurveSets(); + + RiaSummaryAddressAnalyzer* addressAnalyzer(); + + void computeMinMax( const RifEclipseSummaryAddress& address ); + void setMinMax( const RifEclipseSummaryAddress& address, double min, double max ); + std::pair minMax( const RifEclipseSummaryAddress& address ); + private: RigEnsembleParameter createEnsembleParameter( const QString& paramName ) const; static void sortByBinnedVariation( std::vector& parameterVector ); @@ -114,23 +132,30 @@ class RimSummaryCaseCollection : public caf::PdmObject void onCaseNameChanged( const SignalEmitter* emitter ); + void buildChildNodes(); + void clearChildNodes(); + protected: virtual void onLoadDataAndUpdate(); - void updateReferringCurveSets(); void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; void setNameAsReadOnly(); caf::PdmChildArrayField m_cases; private: - caf::PdmField m_name; - caf::PdmProxyValueField m_nameAndItemCount; - caf::PdmField m_isEnsemble; + caf::PdmField m_name; + caf::PdmProxyValueField m_nameAndItemCount; + caf::PdmField m_isEnsemble; + caf::PdmChildField m_dataVectorFolders; cvf::ref m_statisticsEclipseRftReader; caf::PdmField m_ensembleId; size_t m_commonAddressCount; // if different address count among cases, set to 0 - mutable std::vector m_cachedSortedEnsembleParameters; + mutable std::vector m_cachedSortedEnsembleParameters; + std::unique_ptr m_analyzer; + + std::map> m_minMaxValues; }; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp index b7bf0ff4e0..99ed50a838 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp @@ -42,8 +42,8 @@ #include "RimSummaryCase.h" #include "RimSummaryCaseCollection.h" #include "RimSummaryCurve.h" +#include "RimSummaryMultiPlotCollection.h" #include "RimSummaryPlot.h" -#include "RimSummaryPlotCollection.h" #include "cafProgressInfo.h" @@ -94,11 +94,12 @@ void addCaseRealizationParametersIfFound( RimSummaryCase& sumCase, const QString /// //-------------------------------------------------------------------------------------------------- RimSummaryCaseMainCollection::RimSummaryCaseMainCollection() + : dataSourceHasChanged( this ) { - CAF_PDM_InitObject( "Summary Cases", ":/SummaryCases16x16.png", "", "" ); + CAF_PDM_InitObject( "Summary Cases", ":/SummaryCases16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_cases, "SummaryCases", "", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_caseCollections, "SummaryCaseCollections", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_cases, "SummaryCases", "" ); + CAF_PDM_InitFieldNoDefault( &m_caseCollections, "SummaryCaseCollections", "" ); m_cases.uiCapability()->setUiTreeHidden( true ); m_caseCollections.uiCapability()->setUiTreeHidden( true ); @@ -109,8 +110,8 @@ RimSummaryCaseMainCollection::RimSummaryCaseMainCollection() //-------------------------------------------------------------------------------------------------- RimSummaryCaseMainCollection::~RimSummaryCaseMainCollection() { - m_cases.deleteAllChildObjectsAsync(); - m_caseCollections.deleteAllChildObjectsAsync(); + m_cases.deleteChildrenAsync(); + m_caseCollections.deleteChildrenAsync(); } //-------------------------------------------------------------------------------------------------- @@ -222,8 +223,10 @@ void RimSummaryCaseMainCollection::addCases( const std::vector { for ( RimSummaryCase* sumCase : cases ) { - addCase( sumCase ); + m_cases.push_back( sumCase ); + sumCase->nameChanged.connect( this, &RimSummaryCaseMainCollection::onCaseNameChanged ); } + dataSourceHasChanged.send(); } //-------------------------------------------------------------------------------------------------- @@ -233,12 +236,14 @@ void RimSummaryCaseMainCollection::addCase( RimSummaryCase* summaryCase ) { m_cases.push_back( summaryCase ); summaryCase->nameChanged.connect( this, &RimSummaryCaseMainCollection::onCaseNameChanged ); + + dataSourceHasChanged.send(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCaseMainCollection::removeCase( RimSummaryCase* summaryCase ) +void RimSummaryCaseMainCollection::removeCase( RimSummaryCase* summaryCase, bool notifyChange ) { std::vector derivedEnsembles; @@ -255,11 +260,11 @@ void RimSummaryCaseMainCollection::removeCase( RimSummaryCase* summaryCase ) } } - m_cases.removeChildObject( summaryCase ); + m_cases.removeChild( summaryCase ); for ( RimSummaryCaseCollection* summaryCaseCollection : m_caseCollections ) { - summaryCaseCollection->removeCase( summaryCase ); + summaryCaseCollection->removeCase( summaryCase, notifyChange ); } // Update derived ensemble cases (if any) @@ -267,6 +272,26 @@ void RimSummaryCaseMainCollection::removeCase( RimSummaryCase* summaryCase ) { derEnsemble->createDerivedEnsembleCases(); } + + if ( notifyChange ) dataSourceHasChanged.send(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCaseMainCollection::removeCases( std::vector& cases ) +{ + for ( auto sumCase : cases ) + { + removeCase( sumCase, false ); + } + + for ( RimSummaryCaseCollection* summaryCaseCollection : m_caseCollections ) + { + summaryCaseCollection->updateReferringCurveSets(); + } + + dataSourceHasChanged.send(); } //-------------------------------------------------------------------------------------------------- @@ -298,7 +323,7 @@ RimSummaryCaseCollection* } else { - m_cases.removeChildObject( summaryCase ); + m_cases.removeChild( summaryCase ); } summaryCaseCollection->addCase( summaryCase ); @@ -313,6 +338,8 @@ RimSummaryCaseCollection* summaryCaseCollection->caseNameChanged.connect( this, &RimSummaryCaseMainCollection::onCaseNameChanged ); m_caseCollections.push_back( summaryCaseCollection ); + dataSourceHasChanged.send(); + return summaryCaseCollection; } @@ -321,7 +348,9 @@ RimSummaryCaseCollection* //-------------------------------------------------------------------------------------------------- void RimSummaryCaseMainCollection::removeCaseCollection( RimSummaryCaseCollection* caseCollection ) { - m_caseCollections.removeChildObject( caseCollection ); + m_caseCollections.removeChild( caseCollection ); + + dataSourceHasChanged.send(); } //-------------------------------------------------------------------------------------------------- @@ -346,7 +375,15 @@ size_t RimSummaryCaseMainCollection::summaryCaseCount() const std::vector RimSummaryCaseMainCollection::allSummaryCases() const { std::vector cases; - this->descendantsIncludingThisOfType( cases ); + + if ( !m_cases.empty() ) cases.insert( cases.end(), m_cases.begin(), m_cases.end() ); + + for ( auto& coll : m_caseCollections ) + { + auto collCases = coll->allSummaryCases(); + if ( collCases.empty() ) continue; + cases.insert( cases.end(), collCases.begin(), collCases.end() ); + } return cases; } @@ -572,7 +609,7 @@ RimSummaryCaseCollection* RimSummaryCaseMainCollection::defaultAllocator() //-------------------------------------------------------------------------------------------------- void RimSummaryCaseMainCollection::onCaseNameChanged( const SignalEmitter* emitter ) { - RimSummaryPlotCollection* summaryPlotColl = RiaSummaryTools::summaryPlotCollection(); + RimSummaryMultiPlotCollection* summaryPlotColl = RiaSummaryTools::summaryMultiPlotCollection(); summaryPlotColl->updateSummaryNameHasChanged(); } @@ -711,18 +748,6 @@ QString RimSummaryCaseMainCollection::uniqueShortNameForCase( RimSummaryCase* su return shortName; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimSummaryCaseMainCollection::updateFilePathsFromProjectPath( const QString& newProjectPath, - const QString& oldProjectPath ) -{ - for ( auto summaryCase : m_cases ) - { - summaryCase->updateFilePathsFromProjectPath( newProjectPath, oldProjectPath ); - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h index 12c7fea9b7..74d76a2465 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h @@ -19,6 +19,7 @@ #include "cafPdmChildArrayField.h" #include "cafPdmObject.h" +#include "cafSignal.h" #include #include @@ -37,6 +38,9 @@ class RimSummaryCaseMainCollection : public caf::PdmObject { CAF_PDM_HEADER_INIT; +public: + caf::Signal<> dataSourceHasChanged; + public: RimSummaryCaseMainCollection(); ~RimSummaryCaseMainCollection() override; @@ -58,7 +62,8 @@ class RimSummaryCaseMainCollection : public caf::PdmObject void addCases( const std::vector cases ); void addCase( RimSummaryCase* summaryCase ); - void removeCase( RimSummaryCase* summaryCase ); + void removeCase( RimSummaryCase* summaryCase, bool notifyChange = true ); + void removeCases( std::vector& cases ); RimSummaryCaseCollection* addCaseCollection( std::vector summaryCases, const QString& coolectionName, @@ -70,8 +75,6 @@ class RimSummaryCaseMainCollection : public caf::PdmObject QString uniqueShortNameForCase( RimSummaryCase* summaryCase ); - void updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ); - void updateAutoShortName(); void onProjectBeingSaved(); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCrossPlot.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCrossPlot.cpp index f7414397fa..6abeb75401 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCrossPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCrossPlot.cpp @@ -27,10 +27,9 @@ CAF_PDM_SOURCE_INIT( RimSummaryCrossPlot, "SummaryCrossPlot" ); /// //-------------------------------------------------------------------------------------------------- RimSummaryCrossPlot::RimSummaryCrossPlot() + : RimSummaryPlot( true ) { - CAF_PDM_InitObject( "Summary Cross Plot", ":/SummaryXPlotLight16x16.png", "", "" ); - - setAsCrossPlot(); + CAF_PDM_InitObject( "Summary Cross Plot", ":/SummaryXPlotLight16x16.png" ); } //-------------------------------------------------------------------------------------------------- @@ -38,5 +37,5 @@ RimSummaryCrossPlot::RimSummaryCrossPlot() //-------------------------------------------------------------------------------------------------- RimSummaryPlotSourceStepping* RimSummaryCrossPlot::sourceSteppingObjectForKeyEventHandling() const { - return summaryCurveCollection()->sourceSteppingObject( RimSummaryPlotSourceStepping::UNION_X_Y_AXIS ); + return summaryCurveCollection()->sourceSteppingObject( RimSummaryDataSourceStepping::Axis::UNION_X_Y_AXIS ); } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCrossPlotCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCrossPlotCollection.cpp index 0f5fb8842a..4b4baa23b9 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCrossPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCrossPlotCollection.cpp @@ -31,9 +31,9 @@ CAF_PDM_SOURCE_INIT( RimSummaryCrossPlotCollection, "SummaryCrossPlotCollection" //-------------------------------------------------------------------------------------------------- RimSummaryCrossPlotCollection::RimSummaryCrossPlotCollection() { - CAF_PDM_InitObject( "Summary Cross Plots", ":/SummaryXPlotsLight16x16.png", "", "" ); + CAF_PDM_InitObject( "Summary Cross Plots", ":/SummaryXPlotsLight16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_summaryCrossPlots, "SummaryCrossPlots", "Summary Cross Plots", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_summaryCrossPlots, "SummaryCrossPlots", "Summary Cross Plots" ); m_summaryCrossPlots.uiCapability()->setUiTreeHidden( true ); caf::PdmFieldReorderCapability::addToField( &m_summaryCrossPlots ); } @@ -50,7 +50,7 @@ RimSummaryCrossPlotCollection::~RimSummaryCrossPlotCollection() //-------------------------------------------------------------------------------------------------- void RimSummaryCrossPlotCollection::deleteAllPlots() { - m_summaryCrossPlots.deleteAllChildObjects(); + m_summaryCrossPlots.deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -58,7 +58,7 @@ void RimSummaryCrossPlotCollection::deleteAllPlots() //-------------------------------------------------------------------------------------------------- std::vector RimSummaryCrossPlotCollection::plots() const { - return m_summaryCrossPlots.childObjects(); + return m_summaryCrossPlots.children(); } //-------------------------------------------------------------------------------------------------- @@ -107,7 +107,7 @@ void RimSummaryCrossPlotCollection::insertPlot( RimSummaryPlot* plot, size_t ind //-------------------------------------------------------------------------------------------------- void RimSummaryCrossPlotCollection::removePlot( RimSummaryPlot* plot ) { - m_summaryCrossPlots.removeChildObject( plot ); + m_summaryCrossPlots.removeChild( plot ); updateAllRequiredEditors(); } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp index f2db0bec13..d151c45714 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp @@ -22,7 +22,9 @@ #include "RiaCurveMerger.h" #include "RiaGuiApplication.h" #include "RiaLogging.h" +#include "RiaPlotDefines.h" #include "RiaPreferencesSummary.h" +#include "RiaQDateTimeTools.h" #include "RiaResultNames.h" #include "RiaSummaryCurveDefinition.h" #include "RiaSummaryTools.h" @@ -30,6 +32,8 @@ #include "RimEclipseResultCase.h" #include "RimEnsembleCurveSet.h" #include "RimEnsembleCurveSetCollection.h" +#include "RimMultipleSummaryPlotNameHelper.h" +#include "RimPlotAxisProperties.h" #include "RimProject.h" #include "RimSummaryAddress.h" #include "RimSummaryCalculationCollection.h" @@ -38,26 +42,22 @@ #include "RimSummaryCrossPlot.h" #include "RimSummaryCurveAutoName.h" #include "RimSummaryCurveCollection.h" -#include "RimSummaryFilter.h" +#include "RimSummaryMultiPlot.h" #include "RimSummaryPlot.h" -#include "RimSummaryPlotCollection.h" #include "RimSummaryTimeAxisProperties.h" #include "RimTools.h" +#include "RiuPlotAxis.h" #include "RiuPlotMainWindow.h" #include "RiuQwtPlotCurve.h" #include "RiuSummaryVectorSelectionDialog.h" #include "cafPdmUiComboBoxEditor.h" +#include "cafPdmUiLineEditor.h" #include "cafPdmUiListEditor.h" #include "cafPdmUiPushButtonEditor.h" #include "cafPdmUiTreeOrdering.h" -#include "qwt_date.h" -#include "qwt_plot.h" - -#include "cafPdmUiLineEditor.h" - CAF_PDM_SOURCE_INIT( RimSummaryCurve, "SummaryCurve" ); //-------------------------------------------------------------------------------------------------- @@ -65,44 +65,44 @@ CAF_PDM_SOURCE_INIT( RimSummaryCurve, "SummaryCurve" ); //-------------------------------------------------------------------------------------------------- RimSummaryCurve::RimSummaryCurve() { - CAF_PDM_InitObject( "Summary Curve", ":/SummaryCurve16x16.png", "", "" ); + CAF_PDM_InitObject( "Summary Curve", ":/SummaryCurve16x16.png" ); // Y Values - CAF_PDM_InitFieldNoDefault( &m_yValuesSummaryCase, "SummaryCase", "Case", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_yValuesSummaryCase, "SummaryCase", "Case" ); m_yValuesSummaryCase.uiCapability()->setUiTreeChildrenHidden( true ); m_yValuesSummaryCase.uiCapability()->setAutoAddingOptionFromValue( false ); - CAF_PDM_InitFieldNoDefault( &m_yValuesSummaryAddressUiField, "SelectedVariableDisplayVar", "Vector", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_yValuesSummaryAddressUiField, "SelectedVariableDisplayVar", "Vector" ); m_yValuesSummaryAddressUiField.xmlCapability()->disableIO(); m_yValuesSummaryAddressUiField.uiCapability()->setUiEditorTypeName( caf::PdmUiLineEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_yValuesSummaryAddress, "SummaryAddress", "Summary Address", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_yValuesSummaryAddress, "SummaryAddress", "Summary Address" ); m_yValuesSummaryAddress.uiCapability()->setUiTreeHidden( true ); m_yValuesSummaryAddress.uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_yPushButtonSelectSummaryAddress, "SelectAddress", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_yPushButtonSelectSummaryAddress, "SelectAddress", "" ); caf::PdmUiPushButtonEditor::configureEditorForField( &m_yPushButtonSelectSummaryAddress ); m_yPushButtonSelectSummaryAddress.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); m_yPushButtonSelectSummaryAddress = false; m_yValuesSummaryAddress = new RimSummaryAddress; - CAF_PDM_InitFieldNoDefault( &m_resampling, "Resampling", "Resampling", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_resampling, "Resampling", "Resampling" ); // X Values - CAF_PDM_InitFieldNoDefault( &m_xValuesSummaryCase, "SummaryCaseX", "Case", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_xValuesSummaryCase, "SummaryCaseX", "Case" ); m_xValuesSummaryCase.uiCapability()->setUiTreeChildrenHidden( true ); m_xValuesSummaryCase.uiCapability()->setAutoAddingOptionFromValue( false ); - CAF_PDM_InitFieldNoDefault( &m_xValuesSummaryAddressUiField, "SelectedVariableDisplayVarX", "Vector", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_xValuesSummaryAddressUiField, "SelectedVariableDisplayVarX", "Vector" ); m_xValuesSummaryAddressUiField.xmlCapability()->disableIO(); m_xValuesSummaryAddressUiField.uiCapability()->setUiEditorTypeName( caf::PdmUiLineEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_xValuesSummaryAddress, "SummaryAddressX", "Summary Address", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_xValuesSummaryAddress, "SummaryAddressX", "Summary Address" ); m_xValuesSummaryAddress.uiCapability()->setUiTreeHidden( true ); m_xValuesSummaryAddress.uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_xPushButtonSelectSummaryAddress, "SelectAddressX", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_xPushButtonSelectSummaryAddress, "SelectAddressX", "" ); caf::PdmUiPushButtonEditor::configureEditorForField( &m_xPushButtonSelectSummaryAddress ); m_xPushButtonSelectSummaryAddress.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); @@ -111,35 +111,26 @@ RimSummaryCurve::RimSummaryCurve() m_xValuesSummaryAddress = new RimSummaryAddress; // Other members - CAF_PDM_InitFieldNoDefault( &m_isEnsembleCurve, "IsEnsembleCurve", "Ensemble Curve", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_isEnsembleCurve, "IsEnsembleCurve", "Ensemble Curve" ); m_isEnsembleCurve.v() = caf::Tristate::State::PartiallyTrue; - CAF_PDM_InitFieldNoDefault( &m_plotAxis, "PlotAxis", "Axis", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_plotAxis_OBSOLETE, "PlotAxis", "Axis" ); + m_plotAxis_OBSOLETE.xmlCapability()->setIOWritable( false ); - CAF_PDM_InitFieldNoDefault( &m_curveNameConfig, "SummaryCurveNameConfig", "SummaryCurveNameConfig", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_plotAxisProperties, "Axis", "Axis" ); + + CAF_PDM_InitFieldNoDefault( &m_curveNameConfig, "SummaryCurveNameConfig", "SummaryCurveNameConfig" ); m_curveNameConfig.uiCapability()->setUiTreeHidden( true ); m_curveNameConfig.uiCapability()->setUiTreeChildrenHidden( true ); m_curveNameConfig = new RimSummaryCurveAutoName; - CAF_PDM_InitField( &m_isTopZWithinCategory, "isTopZWithinCategory", false, "", "", "", "" ); + CAF_PDM_InitField( &m_isTopZWithinCategory, "isTopZWithinCategory", false, "" ); m_isTopZWithinCategory.uiCapability()->setUiHidden( true ); setSymbolSkipDistance( 10.0f ); setLineThickness( 2 ); - CAF_PDM_InitFieldNoDefault( &m_yValuesSummaryFilter_OBSOLETE, "VarListFilter", "Filter", "", "", "" ); - m_yValuesSummaryFilter_OBSOLETE.uiCapability()->setUiTreeChildrenHidden( true ); - m_yValuesSummaryFilter_OBSOLETE.uiCapability()->setUiTreeHidden( true ); - m_yValuesSummaryFilter_OBSOLETE.xmlCapability()->setIOWritable( false ); - m_yValuesSummaryFilter_OBSOLETE = new RimSummaryFilter_OBSOLETE; - - CAF_PDM_InitFieldNoDefault( &m_xValuesSummaryFilter_OBSOLETE, "VarListFilterX", "Filter", "", "", "" ); - m_xValuesSummaryFilter_OBSOLETE.uiCapability()->setUiTreeChildrenHidden( true ); - m_xValuesSummaryFilter_OBSOLETE.uiCapability()->setUiTreeHidden( true ); - m_xValuesSummaryFilter_OBSOLETE.xmlCapability()->setIOWritable( false ); - m_xValuesSummaryFilter_OBSOLETE = new RimSummaryFilter_OBSOLETE; - setDeletable( true ); } @@ -165,7 +156,7 @@ void RimSummaryCurve::setSummaryCaseY( RimSummaryCase* sumCase ) { if ( m_yValuesSummaryCase != sumCase ) { - m_qwtCurveErrorBars->setSamples( nullptr ); + clearErrorBars(); } bool isEnsembleCurve = false; @@ -227,7 +218,7 @@ void RimSummaryCurve::setSummaryAddressY( const RifEclipseSummaryAddress& addres { if ( m_yValuesSummaryAddress->address() != address ) { - m_qwtCurveErrorBars->setSamples( nullptr ); + clearErrorBars(); } m_yValuesSummaryAddress->setAddress( address ); @@ -269,6 +260,8 @@ std::vector RimSummaryCurve::valuesY() const RifEclipseSummaryAddress addr = m_yValuesSummaryAddress()->address(); reader->values( addr, &values ); + if ( values.empty() ) return values; + RimSummaryPlot* plot = nullptr; firstAncestorOrThisOfTypeAsserted( plot ); bool isNormalized = plot->isNormalizationEnabled(); @@ -404,10 +397,7 @@ double RimSummaryCurve::yValueAtTimeT( time_t time ) const //-------------------------------------------------------------------------------------------------- void RimSummaryCurve::setOverrideCurveDataY( const std::vector& dateTimes, const std::vector& yValues ) { - if ( m_qwtPlotCurve ) - { - m_qwtPlotCurve->setSamplesFromTimeTAndYValues( dateTimes, yValues, true ); - } + setSamplesFromTimeTAndYValues( dateTimes, yValues, true ); } //-------------------------------------------------------------------------------------------------- @@ -442,17 +432,24 @@ RimSummaryCase* RimSummaryCurve::summaryCaseX() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCurve::setLeftOrRightAxisY( RiaDefines::PlotAxis plotAxis ) +void RimSummaryCurve::setLeftOrRightAxisY( RiuPlotAxis plotAxis ) { - m_plotAxis = plotAxis; + m_plotAxis_OBSOLETE = plotAxis.axis(); + + RimSummaryPlot* plot = nullptr; + firstAncestorOrThisOfTypeAsserted( plot ); + m_plotAxisProperties = plot->axisPropertiesForPlotAxis( plotAxis ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiaDefines::PlotAxis RimSummaryCurve::axisY() const +RiuPlotAxis RimSummaryCurve::axisY() const { - return m_plotAxis(); + if ( m_plotAxisProperties ) + return m_plotAxisProperties->plotAxisType(); + else + return RiuPlotAxis::defaultLeft(); } //-------------------------------------------------------------------------------------------------- @@ -474,11 +471,9 @@ void RimSummaryCurve::setIsEnsembleCurve( bool isEnsembleCurve ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimSummaryCurve::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RimSummaryCurve::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { - QList options = - this->RimPlotCurve::calculateValueOptions( fieldNeedingOptions, useOptionsOnly ); + QList options = this->RimPlotCurve::calculateValueOptions( fieldNeedingOptions ); if ( !options.isEmpty() ) return options; if ( fieldNeedingOptions == &m_yValuesSummaryCase || fieldNeedingOptions == &m_xValuesSummaryCase ) @@ -489,10 +484,7 @@ QList RimSummaryCurve::calculateValueOptions( const caf: cases.push_back( proj->calculationCollection->calculationSummaryCase() ); - for ( RimSummaryCase* rimCase : cases ) - { - options.push_back( caf::PdmOptionItemInfo( rimCase->displayCaseName(), rimCase ) ); - } + options = RiaSummaryTools::optionsForSummaryCases( cases ); if ( options.size() > 0 ) { @@ -507,6 +499,20 @@ QList RimSummaryCurve::calculateValueOptions( const caf: { appendOptionItemsForSummaryAddresses( &options, m_xValuesSummaryCase() ); } + else if ( fieldNeedingOptions == &m_plotAxisProperties ) + { + RimSummaryPlot* plot = nullptr; + firstAncestorOrThisOfTypeAsserted( plot ); + + for ( auto axis : plot->plotAxes() ) + { + if ( dynamic_cast( axis ) ) + { + options.push_back( caf::PdmOptionItemInfo( axis->objectName(), axis ) ); + } + } + } + return options; } @@ -515,11 +521,28 @@ QList RimSummaryCurve::calculateValueOptions( const caf: //-------------------------------------------------------------------------------------------------- QString RimSummaryCurve::createCurveAutoName() { - RimSummaryPlot* plot = nullptr; - firstAncestorOrThisOfTypeAsserted( plot ); + std::vector nameHelpers; + { + RimSummaryPlot* plot = nullptr; + firstAncestorOrThisOfType( plot ); + if ( plot ) + { + auto nameHelper = plot->plotTitleHelper(); + if ( nameHelper ) nameHelpers.push_back( nameHelper ); + } + } + { + RimSummaryMultiPlot* summaryMultiPlot = nullptr; + firstAncestorOrThisOfType( summaryMultiPlot ); + if ( summaryMultiPlot ) + { + auto nameHelper = summaryMultiPlot->nameHelper(); + if ( nameHelper ) nameHelpers.push_back( nameHelper ); + } + } - const RimSummaryPlotNameHelper* nameHelper = plot->activePlotTitleHelperAllCurves(); - QString curveName = m_curveNameConfig->curveNameY( m_yValuesSummaryAddress->address(), nameHelper ); + RimMultiSummaryPlotNameHelper multiNameHelper( nameHelpers ); + QString curveName = m_curveNameConfig->curveNameY( m_yValuesSummaryAddress->address(), &multiNameHelper ); if ( curveName.isEmpty() ) { curveName = m_curveNameConfig->curveNameY( m_yValuesSummaryAddress->address(), nullptr ); @@ -527,7 +550,7 @@ QString RimSummaryCurve::createCurveAutoName() if ( isCrossPlotCurve() ) { - QString curveNameX = m_curveNameConfig->curveNameX( m_xValuesSummaryAddress->address(), nameHelper ); + QString curveNameX = m_curveNameConfig->curveNameX( m_xValuesSummaryAddress->address(), &multiNameHelper ); if ( curveNameX.isEmpty() ) { curveNameX = m_curveNameConfig->curveNameX( m_xValuesSummaryAddress->address(), nullptr ); @@ -555,7 +578,7 @@ void RimSummaryCurve::updateZoomInParentPlot() RimSummaryPlot* plot = nullptr; firstAncestorOrThisOfTypeAsserted( plot ); - plot->updateZoomInQwt(); + plot->updateZoomInParentPlot(); } //-------------------------------------------------------------------------------------------------- @@ -578,7 +601,7 @@ void RimSummaryCurve::onLoadDataAndUpdate( bool updateParentPlot ) RimSummaryPlot* plot = nullptr; firstAncestorOrThisOfTypeAsserted( plot ); - bool isLogCurve = plot->isLogarithmicScaleEnabled( this->axisY() ); + bool useLogarithmicScale = plot->isLogarithmicScaleEnabled( this->axisY() ); bool shouldPopulateViewWithEmptyData = false; @@ -604,7 +627,7 @@ void RimSummaryCurve::onLoadDataAndUpdate( bool updateParentPlot ) { this->setSamplesFromXYValues( curveMerger.interpolatedYValuesForAllXValues( 0 ), curveMerger.interpolatedYValuesForAllXValues( 1 ), - isLogCurve ); + useLogarithmicScale ); } else { @@ -632,16 +655,16 @@ void RimSummaryCurve::onLoadDataAndUpdate( bool updateParentPlot ) if ( !errValues.empty() ) { - this->setSamplesFromXYErrorValues( timeSteps, curveValuesY, errValues, isLogCurve ); + this->setSamplesFromXYErrorValues( timeSteps, curveValuesY, errValues, useLogarithmicScale ); } else { - this->setSamplesFromXYValues( timeSteps, curveValuesY, isLogCurve ); + this->setSamplesFromXYValues( timeSteps, curveValuesY, useLogarithmicScale ); } } else { - if ( m_resampling() != RiaQDateTimeTools::DateTimePeriod::NONE ) + if ( m_resampling() != RiaDefines::DateTimePeriod::NONE ) { auto [resampledTimeSteps, resampledValues] = RiaSummaryTools::resampledValuesForPeriod( m_yValuesSummaryAddress->address(), @@ -658,12 +681,14 @@ void RimSummaryCurve::onLoadDataAndUpdate( bool updateParentPlot ) resampledTimeSteps.insert( resampledTimeSteps.begin(), curveTimeStepsY.front() ); resampledValues.insert( resampledValues.begin(), resampledValues.front() ); - this->setSamplesFromTimeTAndYValues( resampledTimeSteps, resampledValues, isLogCurve ); + this->setSamplesFromTimeTAndYValues( resampledTimeSteps, + resampledValues, + useLogarithmicScale ); } } else { - this->setSamplesFromTimeTAndYValues( curveTimeStepsY, curveValuesY, isLogCurve ); + this->setSamplesFromTimeTAndYValues( curveTimeStepsY, curveValuesY, useLogarithmicScale ); } } } @@ -682,7 +707,7 @@ void RimSummaryCurve::onLoadDataAndUpdate( bool updateParentPlot ) } } - this->setSamplesFromXYValues( timeFromSimulationStart, curveValuesY, isLogCurve ); + this->setSamplesFromXYValues( timeFromSimulationStart, curveValuesY, useLogarithmicScale ); } } else @@ -693,17 +718,17 @@ void RimSummaryCurve::onLoadDataAndUpdate( bool updateParentPlot ) if ( shouldPopulateViewWithEmptyData ) { - this->setSamplesFromXYValues( std::vector(), std::vector(), isLogCurve ); + this->setSamplesFromXYValues( std::vector(), std::vector(), useLogarithmicScale ); } - if ( updateParentPlot && m_parentQwtPlot ) + if ( updateParentPlot && hasParentPlot() ) { updateZoomInParentPlot(); - m_parentQwtPlot->replot(); + replotParentPlot(); } } - if ( updateParentPlot ) updateQwtPlotAxis(); + if ( updateParentPlot ) updateAxisInPlot( axisY() ); } //-------------------------------------------------------------------------------------------------- @@ -747,6 +772,13 @@ void RimSummaryCurve::initAfterRead() { RimStackablePlotCurve::initAfterRead(); + if ( m_plotAxisProperties.value() == nullptr ) + { + RimSummaryPlot* plot = nullptr; + firstAncestorOrThisOfType( plot ); + if ( plot ) m_plotAxisProperties = plot->axisPropertiesForPlotAxis( RiuPlotAxis( m_plotAxis_OBSOLETE() ) ); + } + if ( m_isEnsembleCurve().isPartiallyTrue() ) { m_isEnsembleCurve.v() = ( summaryCaseY() && summaryCaseY()->ensemble() ) ? caf::Tristate::State::True @@ -754,6 +786,44 @@ void RimSummaryCurve::initAfterRead() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimSummaryCurve::computeCurveZValue() +{ + auto sumAddr = summaryAddressY(); + auto sumCase = summaryCaseY(); + + double zOrder = 0.0; + + if ( sumCase && sumAddr.isValid() ) + { + if ( sumCase->isObservedData() ) + { + zOrder = RiuQwtPlotCurveDefines::zDepthForIndex( RiuQwtPlotCurveDefines::ZIndex::Z_SINGLE_CURVE_OBSERVED ); + } + else if ( sumAddr.category() == RifEclipseSummaryAddress::SUMMARY_ENSEMBLE_STATISTICS ) + { + zOrder = RiuQwtPlotCurveDefines::zDepthForIndex( RiuQwtPlotCurveDefines::ZIndex::Z_ENSEMBLE_STAT_CURVE ); + } + else if ( sumCase->ensemble() ) + { + zOrder = RiuQwtPlotCurveDefines::zDepthForIndex( RiuQwtPlotCurveDefines::ZIndex::Z_ENSEMBLE_CURVE ); + } + else + { + zOrder = RiuQwtPlotCurveDefines::zDepthForIndex( RiuQwtPlotCurveDefines::ZIndex::Z_SINGLE_CURVE_NON_OBSERVED ); + } + } + + if ( m_isTopZWithinCategory ) + { + zOrder += 1.0; + } + + return zOrder; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -786,7 +856,7 @@ void RimSummaryCurve::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering curveDataGroup->add( &m_yValuesSummaryAddressUiField, { true, 2, 1 } ); curveDataGroup->add( &m_yPushButtonSelectSummaryAddress, { false, 1, 0 } ); curveDataGroup->add( &m_resampling, { true, 3, 1 } ); - curveDataGroup->add( &m_plotAxis, { true, 3, 1 } ); + curveDataGroup->add( &m_plotAxisProperties, { true, 3, 1 } ); if ( isCrossPlotCurve() ) m_showErrorBars = false; @@ -852,7 +922,7 @@ void RimSummaryCurve::appendOptionItemsForSummaryAddresses( QListisObservedData() ) - { - zOrder = RiuQwtPlotCurveDefines::zDepthForIndex( RiuQwtPlotCurveDefines::ZIndex::Z_SINGLE_CURVE_OBSERVED ); - } - else if ( sumAddr.category() == RifEclipseSummaryAddress::SUMMARY_ENSEMBLE_STATISTICS ) - { - zOrder = RiuQwtPlotCurveDefines::zDepthForIndex( RiuQwtPlotCurveDefines::ZIndex::Z_ENSEMBLE_STAT_CURVE ); - } - else if ( sumCase->ensemble() ) - { - zOrder = RiuQwtPlotCurveDefines::zDepthForIndex( RiuQwtPlotCurveDefines::ZIndex::Z_ENSEMBLE_CURVE ); - } - else - { - zOrder = RiuQwtPlotCurveDefines::zDepthForIndex( RiuQwtPlotCurveDefines::ZIndex::Z_SINGLE_CURVE_NON_OBSERVED ); - } - } - - if ( m_isTopZWithinCategory ) - { - zOrder += 1.0; - } - - setZOrder( zOrder ); + setZOrder( zValue ); } //-------------------------------------------------------------------------------------------------- @@ -906,19 +948,9 @@ RiaDefines::PhaseType RimSummaryCurve::phaseType() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCurve::updateQwtPlotAxis() +void RimSummaryCurve::updatePlotAxis() { - if ( m_qwtPlotCurve ) - { - if ( this->axisY() == RiaDefines::PlotAxis::PLOT_AXIS_LEFT ) - { - m_qwtPlotCurve->setYAxis( QwtPlot::yLeft ); - } - else - { - m_qwtPlotCurve->setYAxis( QwtPlot::yRight ); - } - } + updateAxisInPlot( axisY() ); } //-------------------------------------------------------------------------------------------------- @@ -939,7 +971,7 @@ QString RimSummaryCurve::curveExportDescription( const RifEclipseSummaryAddress& RimEnsembleCurveSetCollection* coll; firstAncestorOrThisOfType( coll ); - auto curveSet = coll ? coll->findRimCurveSetFromQwtCurve( m_qwtPlotCurve ) : nullptr; + auto curveSet = coll ? coll->findCurveSetFromPlotCurve( m_plotCurve ) : nullptr; auto group = curveSet ? curveSet->summaryCaseCollection() : nullptr; auto addressUiText = addr.uiText(); @@ -967,13 +999,13 @@ void RimSummaryCurve::setCurveAppearanceFromCaseType() if ( m_yValuesSummaryCase->isObservedData() ) { setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_NONE ); - setSymbol( RiuQwtSymbol::SYMBOL_XCROSS ); + setSymbol( RiuPlotCurveSymbol::SYMBOL_XCROSS ); return; } } - if ( m_yValuesSummaryAddress && m_yValuesSummaryAddress->address().isHistoryQuantity() ) + if ( m_yValuesSummaryAddress && m_yValuesSummaryAddress->address().isHistoryVector() ) { RiaPreferencesSummary* prefs = RiaPreferencesSummary::current(); @@ -981,7 +1013,7 @@ void RimSummaryCurve::setCurveAppearanceFromCaseType() { setSymbolEdgeColor( m_curveAppearance->color() ); - setSymbol( RiuQwtSymbol::SYMBOL_XCROSS ); + setSymbol( RiuPlotCurveSymbol::SYMBOL_XCROSS ); setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_NONE ); } else if ( prefs->defaultSummaryHistoryCurveStyle() == @@ -989,12 +1021,12 @@ void RimSummaryCurve::setCurveAppearanceFromCaseType() { setSymbolEdgeColor( m_curveAppearance->color() ); - setSymbol( RiuQwtSymbol::SYMBOL_XCROSS ); + setSymbol( RiuPlotCurveSymbol::SYMBOL_XCROSS ); setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID ); } else if ( prefs->defaultSummaryHistoryCurveStyle() == RiaPreferencesSummary::SummaryHistoryCurveStyleMode::LINES ) { - setSymbol( RiuQwtSymbol::SYMBOL_NONE ); + setSymbol( RiuPlotCurveSymbol::SYMBOL_NONE ); setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID ); } @@ -1002,6 +1034,16 @@ void RimSummaryCurve::setCurveAppearanceFromCaseType() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCurve::setDefaultCurveAppearance() +{ + RimSummaryPlot* plot = nullptr; + firstAncestorOrThisOfType( plot ); + if ( plot ) plot->applyDefaultCurveAppearances( { this } ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1050,19 +1092,17 @@ void RimSummaryCurve::fieldChangedByUi( const caf::PdmFieldHandle* changedField, { plot->updateAxes(); plot->updatePlotTitle(); - plot->updateConnectedEditors(); RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow(); - mainPlotWindow->updateSummaryPlotToolBar(); + mainPlotWindow->updateMultiPlotToolBar(); // If no plot collection is found, we assume that we are inside a curve creator // Update the summary curve collection to make sure the curve names are updated in curve creator UI visibilityChanged.send( m_showCurve() ); } - else if ( changedField == &m_plotAxis ) + else if ( changedField == &m_plotAxisProperties ) { - updateQwtPlotAxis(); - + updateAxisInPlot( axisY() ); plot->updateAxes(); dataChanged.send(); } @@ -1073,7 +1113,7 @@ void RimSummaryCurve::fieldChangedByUi( const caf::PdmFieldHandle* changedField, { // If no previous case selected and observed data, use symbols to indicate observed data curve setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_NONE ); - setSymbol( RiuQwtSymbol::SYMBOL_XCROSS ); + setSymbol( RiuPlotCurveSymbol::SYMBOL_XCROSS ); } plot->updateCaseNameHasChanged(); @@ -1214,7 +1254,7 @@ void RimSummaryCurve::fieldChangedByUi( const caf::PdmFieldHandle* changedField, plot->updateConnectedEditors(); RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow(); - mainPlotWindow->updateSummaryPlotToolBar(); + mainPlotWindow->updateMultiPlotToolBar(); dataChanged.send(); } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.h index 8c6c2bbd04..27e403ae77 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.h @@ -24,8 +24,8 @@ #include "cafPdmPointer.h" #include "cafPdmPtrField.h" +#include "RiaDateTimeDefines.h" #include "RiaDefines.h" -#include "RiaQDateTimeTools.h" #include "RifEclipseSummaryAddressQMetaType.h" #include "RimStackablePlotCurve.h" @@ -35,11 +35,10 @@ class RifSummaryReaderInterface; class RimSummaryCase; -class RimSummaryFilter_OBSOLETE; -class RiuQwtPlotCurve; class RimSummaryCurveAutoName; class RimSummaryAddress; class RiaSummaryCurveDefinition; +class RimPlotAxisPropertiesInterface; //================================================================================================== /// @@ -64,12 +63,12 @@ class RimSummaryCurve : public RimStackablePlotCurve void setSummaryCaseY( RimSummaryCase* sumCase ); void setSummaryAddressYAndApplyInterpolation( const RifEclipseSummaryAddress& address ); void setSummaryAddressY( const RifEclipseSummaryAddress& address ); - void setResampling( RiaQDateTimeTools::DateTimePeriodEnum resampling ); + void setResampling( RiaDefines::DateTimePeriodEnum resampling ); RifEclipseSummaryAddress errorSummaryAddressY() const; std::vector errorValuesY() const; - void setLeftOrRightAxisY( RiaDefines::PlotAxis plotAxis ); - RiaDefines::PlotAxis axisY() const; + void setLeftOrRightAxisY( RiuPlotAxis plotAxis ); + RiuPlotAxis axisY() const; const std::vector& timeStepsY() const; double yValueAtTimeT( time_t time ) const; void setOverrideCurveDataY( const std::vector& xValues, const std::vector& yValues ); @@ -88,11 +87,12 @@ class RimSummaryCurve : public RimStackablePlotCurve bool isEnsembleCurve() const; void setIsEnsembleCurve( bool isEnsembleCurve ); - void updateQwtPlotAxis(); + void updatePlotAxis(); void applyCurveAutoNameSettings( const RimSummaryCurveAutoName& autoNameSettings ); QString curveExportDescription( const RifEclipseSummaryAddress& address = RifEclipseSummaryAddress() ) const override; void setCurveAppearanceFromCaseType(); + void setDefaultCurveAppearance(); void setAsTopZWithinCategory( bool enable ); void setZIndexFromCurveInfo(); @@ -107,8 +107,9 @@ class RimSummaryCurve : public RimStackablePlotCurve void updateLegendsInPlot() override; - void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; - void initAfterRead() override; + void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; + void initAfterRead() override; + double computeCurveZValue() override; private: RifSummaryReaderInterface* valuesSummaryReaderX() const; @@ -119,8 +120,7 @@ class RimSummaryCurve : public RimStackablePlotCurve // Overridden PDM methods void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, @@ -135,7 +135,7 @@ class RimSummaryCurve : public RimStackablePlotCurve caf::PdmField m_yValuesSummaryAddressUiField; caf::PdmField m_yPushButtonSelectSummaryAddress; - caf::PdmField m_resampling; + caf::PdmField m_resampling; // X values caf::PdmPtrField m_xValuesSummaryCase; @@ -146,10 +146,7 @@ class RimSummaryCurve : public RimStackablePlotCurve caf::PdmField m_isEnsembleCurve; caf::PdmChildField m_curveNameConfig; - caf::PdmField> m_plotAxis; + caf::PdmField> m_plotAxis_OBSOLETE; + caf::PdmPtrField m_plotAxisProperties; caf::PdmField m_isTopZWithinCategory; - - // Obsolete fields - caf::PdmChildField m_yValuesSummaryFilter_OBSOLETE; - caf::PdmChildField m_xValuesSummaryFilter_OBSOLETE; }; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.cpp index 99cfc2ae63..6539a32574 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.cpp @@ -19,6 +19,8 @@ #include "RimSummaryCurveAppearanceCalculator.h" #include "RiaColorTables.h" +#include "RiaColorTools.h" +#include "RiaPreferencesSummary.h" #include "RiaSummaryCurveDefinition.h" #include "RiuQwtPlotCurve.h" @@ -62,99 +64,28 @@ bool isExcplicitHandled( char secondChar ) return false; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryCurveAppearanceCalculator::RimSummaryCurveAppearanceCalculator( + const std::vector& curveDefinitions ) +{ + init( curveDefinitions ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RimSummaryCurveAppearanceCalculator::RimSummaryCurveAppearanceCalculator( const std::set& curveDefinitions ) { - m_allSummaryCaseNames = getAllSummaryCaseNames(); - m_allSummaryWellNames = getAllSummaryWellNames(); + std::vector curveDefVector; - for ( const RiaSummaryCurveDefinition& curveDef : curveDefinitions ) + for ( auto c : curveDefinitions ) { - if ( curveDef.summaryCase() ) m_caseToAppearanceIdxMap[curveDef.summaryCase()] = -1; - if ( !curveDef.summaryAddress().wellName().empty() ) - m_welToAppearanceIdxMap[curveDef.summaryAddress().wellName()] = -1; - if ( !curveDef.summaryAddress().wellGroupName().empty() ) - m_grpToAppearanceIdxMap[curveDef.summaryAddress().wellGroupName()] = -1; - if ( !( curveDef.summaryAddress().regionNumber() == -1 ) ) - m_regToAppearanceIdxMap[curveDef.summaryAddress().regionNumber()] = -1; - - if ( !curveDef.summaryAddress().quantityName().empty() ) - { - std::string varname = curveDef.summaryAddress().quantityName(); - - if ( curveDef.summaryAddress().isHistoryQuantity() ) - { - varname = varname.substr( 0, varname.size() - 1 ); - } - - m_varToAppearanceIdxMap[varname] = -1; - - // Indexes for sub color ranges - char secondChar = 0; - if ( varname.size() > 1 ) - { - secondChar = varname[1]; - if ( !isExcplicitHandled( secondChar ) ) - { - secondChar = 0; // Consider all others as one group for coloring - } - } - m_secondCharToVarToAppearanceIdxMap[secondChar][varname] = -1; - } + curveDefVector.emplace_back( c ); } - // Select the default appearance type for each data "dimension" - m_caseAppearanceType = NONE; - m_varAppearanceType = NONE; - m_wellAppearanceType = NONE; - m_groupAppearanceType = NONE; - m_regionAppearanceType = NONE; - - std::set unusedAppearTypes; - unusedAppearTypes.insert( COLOR ); - unusedAppearTypes.insert( GRADIENT ); - unusedAppearTypes.insert( LINE_STYLE ); - unusedAppearTypes.insert( SYMBOL ); - unusedAppearTypes.insert( LINE_THICKNESS ); - m_currentCurveGradient = 0.0f; - - m_dimensionCount = 0; - if ( m_varToAppearanceIdxMap.size() > 1 ) - { - m_varAppearanceType = *( unusedAppearTypes.begin() ); - unusedAppearTypes.erase( unusedAppearTypes.begin() ); - m_dimensionCount++; - } - if ( m_caseToAppearanceIdxMap.size() > 1 ) - { - m_caseAppearanceType = *( unusedAppearTypes.begin() ); - unusedAppearTypes.erase( unusedAppearTypes.begin() ); - m_dimensionCount++; - } - if ( m_welToAppearanceIdxMap.size() > 1 ) - { - m_wellAppearanceType = *( unusedAppearTypes.begin() ); - unusedAppearTypes.erase( unusedAppearTypes.begin() ); - m_dimensionCount++; - } - if ( m_grpToAppearanceIdxMap.size() > 1 ) - { - m_groupAppearanceType = *( unusedAppearTypes.begin() ); - unusedAppearTypes.erase( unusedAppearTypes.begin() ); - m_dimensionCount++; - } - if ( m_regToAppearanceIdxMap.size() > 1 ) - { - m_regionAppearanceType = *( unusedAppearTypes.begin() ); - unusedAppearTypes.erase( unusedAppearTypes.begin() ); - m_dimensionCount++; - } - - if ( m_dimensionCount == 0 ) m_varAppearanceType = COLOR; // basically one curve - - updateApperanceIndices(); + init( curveDefVector ); } //-------------------------------------------------------------------------------------------------- @@ -245,8 +176,8 @@ std::map } else if ( appearance == CurveAppearanceType::SYMBOL ) { - numOptions = caf::AppEnum::size() - 1; // -1 since the No symbol option is not - // counted see cycledSymbol() + numOptions = caf::AppEnum::size() - 1; // -1 since the No symbol option is + // not counted see cycledSymbol() } else if ( appearance == CurveAppearanceType::LINE_STYLE ) { @@ -347,15 +278,21 @@ void RimSummaryCurveAppearanceCalculator::setupCurveLook( RimSummaryCurve* curve m_currentCurveBaseColor = cvf::Color3f( 0.5f, 0.5f, 0.5f ); m_currentCurveGradient = 0.0f; + std::string quantityName = curve->summaryAddressY().vectorName(); + if ( curve->summaryAddressY().isHistoryVector() ) + { + quantityName = quantityName.substr( 0, quantityName.size() - 1 ); + } + + int varAppearanceIdx = m_varToAppearanceIdxMap[quantityName]; int caseAppearanceIdx = m_caseToAppearanceIdxMap[curve->summaryCaseY()]; - int varAppearanceIdx = m_varToAppearanceIdxMap[curve->summaryAddressY().quantityName()]; int welAppearanceIdx = m_welToAppearanceIdxMap[curve->summaryAddressY().wellName()]; - int grpAppearanceIdx = m_grpToAppearanceIdxMap[curve->summaryAddressY().wellGroupName()]; + int grpAppearanceIdx = m_grpToAppearanceIdxMap[curve->summaryAddressY().groupName()]; int regAppearanceIdx = m_regToAppearanceIdxMap[curve->summaryAddressY().regionNumber()]; // Remove index for curves without value at the specific dimension if ( curve->summaryAddressY().wellName().empty() ) welAppearanceIdx = -1; - if ( curve->summaryAddressY().wellGroupName().empty() ) grpAppearanceIdx = -1; + if ( curve->summaryAddressY().groupName().empty() ) grpAppearanceIdx = -1; if ( curve->summaryAddressY().regionNumber() < 0 ) regAppearanceIdx = -1; setOneCurveAppearance( m_caseAppearanceType, m_allSummaryCaseNames.size(), caseAppearanceIdx, curve ); @@ -363,61 +300,210 @@ void RimSummaryCurveAppearanceCalculator::setupCurveLook( RimSummaryCurve* curve setOneCurveAppearance( m_groupAppearanceType, m_grpToAppearanceIdxMap.size(), grpAppearanceIdx, curve ); setOneCurveAppearance( m_regionAppearanceType, m_regToAppearanceIdxMap.size(), regAppearanceIdx, curve ); - if ( m_varAppearanceType == COLOR && m_secondCharToVarToAppearanceIdxMap.size() > 1 ) + bool assignByPhase = false; + if ( RiaPreferencesSummary::current()->colorCurvesByPhase() ) { - int subColorIndex = -1; - char secondChar = 0; - std::string varname = curve->summaryAddressY().quantityName(); + assignByPhase = ( m_varAppearanceType == COLOR ); + } - if ( curve->summaryAddressY().isHistoryQuantity() ) - { - varname = varname.substr( 0, varname.size() - 1 ); - } + if ( assignByPhase ) + { + assignColorByPhase( curve, varAppearanceIdx ); + } + else + { + setOneCurveAppearance( m_varAppearanceType, m_varToAppearanceIdxMap.size(), varAppearanceIdx, curve ); + } - if ( varname.size() > 1 ) - { - secondChar = varname[1]; - if ( !isExcplicitHandled( secondChar ) ) - { - secondChar = 0; // Consider all others as one group for coloring - } - } + curve->setColor( gradeColor( m_currentCurveBaseColor, m_currentCurveGradient ) ); - subColorIndex = m_secondCharToVarToAppearanceIdxMap[secondChar][varname]; + curve->setCurveAppearanceFromCaseType(); +} - if ( secondChar == 'W' ) - { - // Pick blue - m_currentCurveBaseColor = cycledBlueColor( subColorIndex ); - } - else if ( secondChar == 'O' ) - { - // Pick Green - m_currentCurveBaseColor = cycledGreenColor( subColorIndex ); - } - else if ( secondChar == 'G' ) +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCurveAppearanceCalculator::assignColorByPhase( RimSummaryCurve* curve, int colorIndex ) +{ + char secondChar = 0; + std::string varname = curve->summaryAddressY().vectorName(); + + if ( varname.size() > 1 ) + { + secondChar = varname[1]; + if ( !isExcplicitHandled( secondChar ) ) { - // Pick Red - m_currentCurveBaseColor = cycledRedColor( subColorIndex ); + secondChar = 0; // Consider all others as one group for coloring } - else if ( secondChar == 'V' ) + } + + if ( secondChar == 'W' ) + { + // Pick blue + m_currentCurveBaseColor = cycledBlueColor( colorIndex ); + } + else if ( secondChar == 'O' ) + { + // Pick Green + m_currentCurveBaseColor = cycledGreenColor( colorIndex ); + } + else if ( secondChar == 'G' ) + { + // Pick Red + m_currentCurveBaseColor = cycledRedColor( colorIndex ); + } + else if ( secondChar == 'V' ) + { + // Pick Brown + m_currentCurveBaseColor = cycledBrownColor( colorIndex ); + } + else + { + m_currentCurveBaseColor = cycledNoneRGBBrColor( colorIndex ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Color3f RimSummaryCurveAppearanceCalculator::assignColorByPhase( const RifEclipseSummaryAddress& address ) +{ + char secondChar = 0; + std::string vectorName = address.vectorName(); + + if ( vectorName.size() > 1 ) + { + secondChar = vectorName[1]; + if ( !isExcplicitHandled( secondChar ) ) { - // Pick Brown - m_currentCurveBaseColor = cycledBrownColor( subColorIndex ); + secondChar = 0; // Consider all others as one group for coloring } - else + } + + if ( secondChar == 'W' ) return cycledBlueColor( 0 ); + if ( secondChar == 'O' ) return cycledGreenColor( 0 ); + if ( secondChar == 'G' ) return cycledRedColor( 0 ); + if ( secondChar == 'V' ) return cycledBrownColor( 0 ); + + return cycledNoneRGBBrColor( 0 ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Color3f RimSummaryCurveAppearanceCalculator::computeTintedCurveColorForAddress( const RifEclipseSummaryAddress& address, + int colorIndex ) +{ + bool usePhaseColor = RiaPreferencesSummary::current()->colorCurvesByPhase(); + + cvf::Color3f curveColor; + if ( usePhaseColor ) + { + curveColor = RimSummaryCurveAppearanceCalculator::assignColorByPhase( address ); + } + else + { + curveColor = RiaColorTables::summaryCurveDefaultPaletteColors().cycledColor3f( colorIndex ); + } + + float scalingFactor = 0.25; + curveColor = RiaColorTools::makeLighter( curveColor, scalingFactor ); + return curveColor; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCurveAppearanceCalculator::init( const std::vector& curveDefinitions ) +{ + m_allSummaryCaseNames = getAllSummaryCaseNames(); + m_allSummaryWellNames = getAllSummaryWellNames(); + + for ( const RiaSummaryCurveDefinition& curveDef : curveDefinitions ) + { + if ( curveDef.summaryCase() ) m_caseToAppearanceIdxMap[curveDef.summaryCase()] = -1; + if ( !curveDef.summaryAddress().wellName().empty() ) + m_welToAppearanceIdxMap[curveDef.summaryAddress().wellName()] = -1; + if ( !curveDef.summaryAddress().groupName().empty() ) + m_grpToAppearanceIdxMap[curveDef.summaryAddress().groupName()] = -1; + if ( !( curveDef.summaryAddress().regionNumber() == -1 ) ) + m_regToAppearanceIdxMap[curveDef.summaryAddress().regionNumber()] = -1; + + if ( !curveDef.summaryAddress().vectorName().empty() ) { - m_currentCurveBaseColor = cycledNoneRGBBrColor( subColorIndex ); + std::string varname = curveDef.summaryAddress().vectorName(); + + if ( curveDef.summaryAddress().isHistoryVector() ) + { + varname = varname.substr( 0, varname.size() - 1 ); + } + + m_varToAppearanceIdxMap[varname] = -1; + + // Indexes for sub color ranges + char secondChar = 0; + if ( varname.size() > 1 ) + { + secondChar = varname[1]; + if ( !isExcplicitHandled( secondChar ) ) + { + secondChar = 0; // Consider all others as one group for coloring + } + } + m_secondCharToVarToAppearanceIdxMap[secondChar][varname] = -1; } } - else + + // Select the default appearance type for each data "dimension" + m_caseAppearanceType = NONE; + m_varAppearanceType = NONE; + m_wellAppearanceType = NONE; + m_groupAppearanceType = NONE; + m_regionAppearanceType = NONE; + + std::set unusedAppearTypes; + unusedAppearTypes.insert( COLOR ); + unusedAppearTypes.insert( GRADIENT ); + unusedAppearTypes.insert( LINE_STYLE ); + unusedAppearTypes.insert( SYMBOL ); + unusedAppearTypes.insert( LINE_THICKNESS ); + m_currentCurveGradient = 0.0f; + + m_dimensionCount = 0; + if ( m_varToAppearanceIdxMap.size() > 1 ) { - setOneCurveAppearance( m_varAppearanceType, m_varToAppearanceIdxMap.size(), varAppearanceIdx, curve ); + m_varAppearanceType = *( unusedAppearTypes.begin() ); + unusedAppearTypes.erase( unusedAppearTypes.begin() ); + m_dimensionCount++; + } + if ( m_caseToAppearanceIdxMap.size() > 1 ) + { + m_caseAppearanceType = *( unusedAppearTypes.begin() ); + unusedAppearTypes.erase( unusedAppearTypes.begin() ); + m_dimensionCount++; + } + if ( m_welToAppearanceIdxMap.size() > 1 ) + { + m_wellAppearanceType = *( unusedAppearTypes.begin() ); + unusedAppearTypes.erase( unusedAppearTypes.begin() ); + m_dimensionCount++; + } + if ( m_grpToAppearanceIdxMap.size() > 1 ) + { + m_groupAppearanceType = *( unusedAppearTypes.begin() ); + unusedAppearTypes.erase( unusedAppearTypes.begin() ); + m_dimensionCount++; + } + if ( m_regToAppearanceIdxMap.size() > 1 ) + { + m_regionAppearanceType = *( unusedAppearTypes.begin() ); + unusedAppearTypes.erase( unusedAppearTypes.begin() ); + m_dimensionCount++; } - curve->setColor( gradeColor( m_currentCurveBaseColor, m_currentCurveGradient ) ); + if ( m_dimensionCount == 0 ) m_varAppearanceType = COLOR; // basically one curve - curve->setCurveAppearanceFromCaseType(); + updateApperanceIndices(); } //-------------------------------------------------------------------------------------------------- @@ -524,12 +610,12 @@ RiuQwtPlotCurveDefines::LineStyleEnum RimSummaryCurveAppearanceCalculator::cycle //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuQwtSymbol::PointSymbolEnum RimSummaryCurveAppearanceCalculator::cycledSymbol( int index ) +RiuPlotCurveSymbol::PointSymbolEnum RimSummaryCurveAppearanceCalculator::cycledSymbol( int index ) { - if ( index < 0 ) return RiuQwtSymbol::SYMBOL_NONE; + if ( index < 0 ) return RiuPlotCurveSymbol::SYMBOL_NONE; - return caf::AppEnum::fromIndex( - 1 + ( index % ( caf::AppEnum::size() - 1 ) ) ); + return caf::AppEnum::fromIndex( + 1 + ( index % ( caf::AppEnum::size() - 1 ) ) ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.h index 9ee0f47232..61592713b5 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.h @@ -17,13 +17,15 @@ ///////////////////////////////////////////////////////////////////////////////// #pragma once +#include "RiuPlotCurveSymbol.h" #include "RiuQwtPlotCurveDefines.h" -#include "RiuQwtSymbol.h" #include "cvfColor3.h" #include #include +#include +#include class RimSummaryCurve; class RimSummaryCase; @@ -34,6 +36,7 @@ class RimSummaryCurveAppearanceCalculator { public: explicit RimSummaryCurveAppearanceCalculator( const std::set& curveDefinitions ); + explicit RimSummaryCurveAppearanceCalculator( const std::vector& curveDefinitions ); enum CurveAppearanceType { NONE, @@ -57,15 +60,19 @@ class RimSummaryCurveAppearanceCalculator void setupCurveLook( RimSummaryCurve* curve ); - static cvf::Color3f cycledPaletteColor( int colorIndex ); - static cvf::Color3f cycledNoneRGBBrColor( int colorIndex ); - static cvf::Color3f cycledGreenColor( int colorIndex ); - static cvf::Color3f cycledBlueColor( int colorIndex ); - static cvf::Color3f cycledRedColor( int colorIndex ); - static cvf::Color3f cycledBrownColor( int colorIndex ); - static RiuQwtSymbol::PointSymbolEnum cycledSymbol( int index ); + static cvf::Color3f assignColorByPhase( const RifEclipseSummaryAddress& address ); + static cvf::Color3f computeTintedCurveColorForAddress( const RifEclipseSummaryAddress& address, int colorIndex ); + + static cvf::Color3f cycledPaletteColor( int colorIndex ); + static cvf::Color3f cycledNoneRGBBrColor( int colorIndex ); + static cvf::Color3f cycledGreenColor( int colorIndex ); + static cvf::Color3f cycledBlueColor( int colorIndex ); + static cvf::Color3f cycledRedColor( int colorIndex ); + static cvf::Color3f cycledBrownColor( int colorIndex ); + static RiuPlotCurveSymbol::PointSymbolEnum cycledSymbol( int index ); private: + void init( const std::vector& curveDefinitions ); void setOneCurveAppearance( CurveAppearanceType appeaType, size_t totalCount, int appeaIdx, RimSummaryCurve* curve ); void updateApperanceIndices(); std::map mapNameToAppearanceIndex( CurveAppearanceType& appearance, @@ -76,6 +83,7 @@ class RimSummaryCurveAppearanceCalculator float gradient( size_t totalCount, int index ); cvf::Color3f gradeColor( const cvf::Color3f& color, float factor ); + void assignColorByPhase( RimSummaryCurve* curve, int colorIndex ); static std::set getAllSummaryCaseNames(); static std::set getAllSummaryWellNames(); @@ -91,11 +99,11 @@ class RimSummaryCurveAppearanceCalculator CurveAppearanceType m_groupAppearanceType; CurveAppearanceType m_regionAppearanceType; - std::map m_caseToAppearanceIdxMap; - std::map m_varToAppearanceIdxMap; - std::map m_welToAppearanceIdxMap; - std::map m_grpToAppearanceIdxMap; - std::map m_regToAppearanceIdxMap; + std::map m_caseToAppearanceIdxMap; + std::unordered_map m_varToAppearanceIdxMap; + std::unordered_map m_welToAppearanceIdxMap; + std::unordered_map m_grpToAppearanceIdxMap; + std::unordered_map m_regToAppearanceIdxMap; std::map> m_secondCharToVarToAppearanceIdxMap; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp index ac6459e6df..390306632a 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp @@ -27,10 +27,12 @@ #include "RimSummaryCase.h" #include "RimSummaryCaseCollection.h" #include "RimSummaryCurve.h" -#include "RimSummaryPlotNameHelper.h" +#include "RimSummaryNameHelper.h" #include "SummaryPlotCommands/RicSummaryPlotEditorUi.h" +#include "RiuSummaryQuantityNameInfoProvider.h" + #include "cafPdmUiPushButtonEditor.h" CAF_PDM_SOURCE_INIT( RimSummaryCurveAutoName, "SummaryCurveAutoName" ); @@ -41,19 +43,20 @@ CAF_PDM_SOURCE_INIT( RimSummaryCurveAutoName, "SummaryCurveAutoName" ); RimSummaryCurveAutoName::RimSummaryCurveAutoName() { // clang-format off - CAF_PDM_InitObject("RimSummaryCurveAutoName", "", "", ""); - - CAF_PDM_InitField(&m_vectorName, "VectorName", true, "Vector Name", "", "", ""); - CAF_PDM_InitField(&m_unit, "Unit", false,"Unit", "", "", ""); - CAF_PDM_InitField(&m_regionNumber, "RegionNumber", true, "Region Number", "", "", ""); - CAF_PDM_InitField(&m_wellGroupName, "WellGroupName", true, "Group Name", "", "", ""); - CAF_PDM_InitField(&m_wellName, "WellName", true, "Well Name", "", "", ""); - CAF_PDM_InitField(&m_wellSegmentNumber, "WellSegmentNumber", true, "Well Segment Number", "", "", ""); - CAF_PDM_InitField(&m_lgrName, "LgrName", true, "Lgr Name", "", "", ""); - CAF_PDM_InitField(&m_completion, "Completion", true, "I, J, K", "", "", ""); - CAF_PDM_InitField(&m_aquiferNumber, "Aquifer", true, "Aquifer Number", "", "", ""); + CAF_PDM_InitObject("RimSummaryCurveAutoName"); + + CAF_PDM_InitField( &m_longVectorName, "LongVectorName", false, "Long Vector Name"); + CAF_PDM_InitField( &m_vectorName, "VectorName", true, "Vector Name"); + CAF_PDM_InitField( &m_unit, "Unit", false, "Unit"); + CAF_PDM_InitField( &m_regionNumber, "RegionNumber", true, "Region Number"); + CAF_PDM_InitField( &m_groupName, "WellGroupName", true, "Group Name"); + CAF_PDM_InitField( &m_wellName, "WellName", true, "Well Name"); + CAF_PDM_InitField(&m_wellSegmentNumber, "WellSegmentNumber", true, "Well Segment Number"); + CAF_PDM_InitField( &m_lgrName, "LgrName", true, "Lgr Name"); + CAF_PDM_InitField( &m_completion, "Completion", true, "I, J, K"); + CAF_PDM_InitField( &m_aquiferNumber, "Aquifer", true, "Aquifer Number"); - CAF_PDM_InitField(&m_caseName, "CaseName", true, "Case/Ensemble Name", "", "", ""); + CAF_PDM_InitField(&m_caseName, "CaseName", true, "Case/Ensemble Name"); // clang-format on } @@ -62,7 +65,7 @@ RimSummaryCurveAutoName::RimSummaryCurveAutoName() /// //-------------------------------------------------------------------------------------------------- QString RimSummaryCurveAutoName::curveNameY( const RifEclipseSummaryAddress& summaryAddress, - const RimSummaryPlotNameHelper* nameHelper ) const + const RimSummaryNameHelper* nameHelper ) const { RimSummaryCurve* summaryCurve = nullptr; this->firstAncestorOrThisOfType( summaryCurve ); @@ -97,7 +100,7 @@ QString RimSummaryCurveAutoName::curveNameY( const RifEclipseSummaryAddress& sum /// //-------------------------------------------------------------------------------------------------- QString RimSummaryCurveAutoName::curveNameX( const RifEclipseSummaryAddress& summaryAddress, - const RimSummaryPlotNameHelper* nameHelper ) const + const RimSummaryNameHelper* nameHelper ) const { RimSummaryCurve* summaryCurve = nullptr; this->firstAncestorOrThisOfType( summaryCurve ); @@ -135,9 +138,10 @@ void RimSummaryCurveAutoName::applySettings( const RimSummaryCurveAutoName& othe { m_caseName = other.m_caseName; m_vectorName = other.m_vectorName; + m_longVectorName = other.m_longVectorName; m_unit = other.m_unit; m_regionNumber = other.m_regionNumber; - m_wellGroupName = other.m_wellGroupName; + m_groupName = other.m_groupName; m_wellName = other.m_wellName; m_wellSegmentNumber = other.m_wellSegmentNumber; m_lgrName = other.m_lgrName; @@ -150,7 +154,7 @@ void RimSummaryCurveAutoName::applySettings( const RimSummaryCurveAutoName& othe //-------------------------------------------------------------------------------------------------- void RimSummaryCurveAutoName::appendWellName( std::string& text, const RifEclipseSummaryAddress& summaryAddress, - const RimSummaryPlotNameHelper* nameHelper ) const + const RimSummaryNameHelper* nameHelper ) const { bool skipSubString = nameHelper && nameHelper->isWellNameInTitle(); if ( skipSubString ) return; @@ -178,7 +182,7 @@ void RimSummaryCurveAutoName::appendLgrName( std::string& text, const RifEclipse /// //-------------------------------------------------------------------------------------------------- QString RimSummaryCurveAutoName::buildCurveName( const RifEclipseSummaryAddress& summaryAddress, - const RimSummaryPlotNameHelper* nameHelper, + const RimSummaryNameHelper* nameHelper, const std::string& unitText, const std::string& caseName ) const { @@ -186,15 +190,26 @@ QString RimSummaryCurveAutoName::buildCurveName( const RifEclipseSummaryAddress& if ( m_vectorName ) { - bool skipSubString = nameHelper && nameHelper->isPlotDisplayingSingleQuantity(); + bool skipSubString = nameHelper && nameHelper->isPlotDisplayingSingleVectorName(); if ( !skipSubString ) { - text = summaryAddress.quantityName(); + if ( m_longVectorName() ) + { + auto quantityName = summaryAddress.vectorName(); + if ( summaryAddress.isHistoryVector() ) + quantityName = quantityName.substr( 0, quantityName.size() - 1 ); + + text = RiuSummaryQuantityNameInfoProvider::instance()->longNameFromVectorName( quantityName ); + } + else + { + text = summaryAddress.vectorName(); + } } if ( summaryAddress.category() == RifEclipseSummaryAddress::SUMMARY_ENSEMBLE_STATISTICS ) { - text = summaryAddress.quantityName(); + text = summaryAddress.vectorName(); } else if ( summaryAddress.category() == RifEclipseSummaryAddress::SUMMARY_CALCULATED ) { @@ -202,7 +217,7 @@ QString RimSummaryCurveAutoName::buildCurveName( const RifEclipseSummaryAddress& RimProject* proj = RimProject::current(); RimSummaryCalculationCollection* calcColl = proj->calculationCollection(); - RimSummaryCalculation* calculation = calcColl->findCalculationById( summaryAddress.id() ); + RimUserDefinedCalculation* calculation = calcColl->findCalculationById( summaryAddress.id() ); if ( calculation ) { text = calculation->description().toStdString(); @@ -228,6 +243,8 @@ QString RimSummaryCurveAutoName::buildCurveName( const RifEclipseSummaryAddress& } } + if ( text.empty() ) text = summaryAddress.vectorName(); + return QString::fromStdString( text ); } @@ -236,7 +253,7 @@ QString RimSummaryCurveAutoName::buildCurveName( const RifEclipseSummaryAddress& //-------------------------------------------------------------------------------------------------- void RimSummaryCurveAutoName::appendAddressDetails( std::string& text, const RifEclipseSummaryAddress& summaryAddress, - const RimSummaryPlotNameHelper* nameHelper ) const + const RimSummaryNameHelper* nameHelper ) const { switch ( summaryAddress.category() ) { @@ -272,15 +289,15 @@ void RimSummaryCurveAutoName::appendAddressDetails( std::string& } } break; - case RifEclipseSummaryAddress::SUMMARY_WELL_GROUP: + case RifEclipseSummaryAddress::SUMMARY_GROUP: { - if ( m_wellGroupName ) + if ( m_groupName ) { - bool skipSubString = nameHelper && nameHelper->isWellGroupNameInTitle(); + bool skipSubString = nameHelper && nameHelper->isGroupNameInTitle(); if ( !skipSubString ) { if ( !text.empty() ) text += ":"; - text += summaryAddress.wellGroupName(); + text += summaryAddress.groupName(); } } } @@ -424,7 +441,8 @@ void RimSummaryCurveAutoName::defineUiOrdering( QString uiConfigName, caf::PdmUi { uiOrdering.add( &m_caseName ); uiOrdering.add( &m_vectorName ); - uiOrdering.add( &m_wellGroupName ); + uiOrdering.add( &m_longVectorName ); + uiOrdering.add( &m_groupName ); uiOrdering.add( &m_wellName ); caf::PdmUiGroup& advanced = *( uiOrdering.addNewGroup( "Advanced" ) ); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.h index d776db64cb..786320caf1 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.h @@ -22,7 +22,7 @@ #include "cafPdmObject.h" class RifEclipseSummaryAddress; -class RimSummaryPlotNameHelper; +class RimSummaryNameHelper; class RimSummaryCurveAutoName : public caf::PdmObject { @@ -31,8 +31,8 @@ class RimSummaryCurveAutoName : public caf::PdmObject public: RimSummaryCurveAutoName(); - QString curveNameY( const RifEclipseSummaryAddress& summaryAddress, const RimSummaryPlotNameHelper* nameHelper ) const; - QString curveNameX( const RifEclipseSummaryAddress& summaryAddress, const RimSummaryPlotNameHelper* nameHelper ) const; + QString curveNameY( const RifEclipseSummaryAddress& summaryAddress, const RimSummaryNameHelper* nameHelper ) const; + QString curveNameX( const RifEclipseSummaryAddress& summaryAddress, const RimSummaryNameHelper* nameHelper ) const; void applySettings( const RimSummaryCurveAutoName& other ); @@ -44,22 +44,23 @@ class RimSummaryCurveAutoName : public caf::PdmObject void appendAddressDetails( std::string& text, const RifEclipseSummaryAddress& summaryAddress, - const RimSummaryPlotNameHelper* nameHelper ) const; + const RimSummaryNameHelper* nameHelper ) const; void appendWellName( std::string& text, const RifEclipseSummaryAddress& summaryAddress, - const RimSummaryPlotNameHelper* nameHelper ) const; + const RimSummaryNameHelper* nameHelper ) const; void appendLgrName( std::string& text, const RifEclipseSummaryAddress& summaryAddress ) const; QString buildCurveName( const RifEclipseSummaryAddress& summaryAddress, - const RimSummaryPlotNameHelper* nameHelper, + const RimSummaryNameHelper* nameHelper, const std::string& unitText, const std::string& caseName ) const; private: caf::PdmField m_vectorName; + caf::PdmField m_longVectorName; caf::PdmField m_unit; caf::PdmField m_regionNumber; - caf::PdmField m_wellGroupName; + caf::PdmField m_groupName; caf::PdmField m_wellName; caf::PdmField m_wellSegmentNumber; caf::PdmField m_lgrName; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp index 531d7e7800..553c045716 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp @@ -34,6 +34,7 @@ #include "cafPdmFieldReorderCapability.h" #include "cafPdmUiPushButtonEditor.h" +#include "cafPdmUiTreeAttributes.h" #include "cafPdmUiTreeViewEditor.h" #include "qwt_plot.h" @@ -48,38 +49,38 @@ CAF_PDM_SOURCE_INIT( RimSummaryCurveCollection, "RimSummaryCurveCollection" ); RimSummaryCurveCollection::RimSummaryCurveCollection() : curvesChanged( this ) { - CAF_PDM_InitObject( "Summary Curves", ":/SummaryCurveFilter16x16.png", "", "" ); + CAF_PDM_InitObject( "Summary Curves", ":/SummaryCurveFilter16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_curves, "CollectionCurves", "Collection Curves", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_curves, "CollectionCurves", "Collection Curves" ); m_curves.uiCapability()->setUiTreeHidden( true ); m_curves.uiCapability()->setUiTreeChildrenHidden( false ); caf::PdmFieldReorderCapability::addToFieldWithCallback( &m_curves, this, &RimSummaryCurveCollection::onCurvesReordered ); - CAF_PDM_InitField( &m_showCurves, "IsActive", true, "Show Curves", "", "", "" ); + CAF_PDM_InitField( &m_showCurves, "IsActive", true, "Show Curves" ); m_showCurves.uiCapability()->setUiHidden( true ); m_showCurves.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitField( &m_editPlot, "EditPlot", false, "", "", "", "" ); + CAF_PDM_InitField( &m_editPlot, "EditPlot", false, "" ); m_editPlot.xmlCapability()->disableIO(); m_editPlot.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_ySourceStepping, "YSourceStepping", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_ySourceStepping, "YSourceStepping", "" ); m_ySourceStepping = new RimSummaryPlotSourceStepping; - m_ySourceStepping->setSourceSteppingType( RimSummaryPlotSourceStepping::Y_AXIS ); + m_ySourceStepping->setSourceSteppingType( RimSummaryDataSourceStepping::Axis::Y_AXIS ); m_ySourceStepping.uiCapability()->setUiTreeHidden( true ); m_ySourceStepping.uiCapability()->setUiTreeChildrenHidden( true ); m_ySourceStepping.xmlCapability()->disableIO(); - CAF_PDM_InitFieldNoDefault( &m_xSourceStepping, "XSourceStepping", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_xSourceStepping, "XSourceStepping", "" ); m_xSourceStepping = new RimSummaryPlotSourceStepping; - m_xSourceStepping->setSourceSteppingType( RimSummaryPlotSourceStepping::X_AXIS ); + m_xSourceStepping->setSourceSteppingType( RimSummaryDataSourceStepping::Axis::X_AXIS ); m_xSourceStepping.uiCapability()->setUiTreeHidden( true ); m_xSourceStepping.uiCapability()->setUiTreeChildrenHidden( true ); m_xSourceStepping.xmlCapability()->disableIO(); - CAF_PDM_InitFieldNoDefault( &m_unionSourceStepping, "UnionSourceStepping", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_unionSourceStepping, "UnionSourceStepping", "" ); m_unionSourceStepping = new RimSummaryPlotSourceStepping; - m_unionSourceStepping->setSourceSteppingType( RimSummaryPlotSourceStepping::UNION_X_Y_AXIS ); + m_unionSourceStepping->setSourceSteppingType( RimSummaryDataSourceStepping::Axis::UNION_X_Y_AXIS ); m_unionSourceStepping.uiCapability()->setUiTreeHidden( true ); m_unionSourceStepping.uiCapability()->setUiTreeChildrenHidden( true ); m_unionSourceStepping.xmlCapability()->disableIO(); @@ -90,7 +91,7 @@ RimSummaryCurveCollection::RimSummaryCurveCollection() //-------------------------------------------------------------------------------------------------- RimSummaryCurveCollection::~RimSummaryCurveCollection() { - m_curves.deleteAllChildObjects(); + m_curves.deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -109,7 +110,7 @@ void RimSummaryCurveCollection::loadDataAndUpdate( bool updateParentPlot ) for ( RimSummaryCurve* curve : m_curves ) { curve->loadDataAndUpdate( false ); - curve->updateQwtPlotAxis(); + curve->updatePlotAxis(); } if ( updateParentPlot ) @@ -123,12 +124,28 @@ void RimSummaryCurveCollection::loadDataAndUpdate( bool updateParentPlot ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCurveCollection::setParentQwtPlotAndReplot( QwtPlot* plot ) +void RimSummaryCurveCollection::onChildrenUpdated( caf::PdmChildArrayFieldHandle* childArray, + std::vector& updatedObjects ) { - for ( RimSummaryCurve* curve : m_curves ) + if ( childArray == &m_curves ) { - curve->setParentQwtPlotNoReplot( plot ); + for ( RimSummaryCurve* curve : m_curves ) + { + curve->updateCurveAppearance(); + } + + RimSummaryPlot* parentPlot; + firstAncestorOrThisOfTypeAsserted( parentPlot ); + parentPlot->plotWidget()->scheduleReplot(); } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCurveCollection::setParentPlotAndReplot( RiuPlotWidget* plot ) +{ + setParentPlotNoReplot( plot ); if ( plot ) plot->replot(); } @@ -136,33 +153,44 @@ void RimSummaryCurveCollection::setParentQwtPlotAndReplot( QwtPlot* plot ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCurveCollection::detachQwtCurves() +void RimSummaryCurveCollection::setParentPlotNoReplot( RiuPlotWidget* plot ) +{ + for ( RimSummaryCurve* curve : m_curves ) + { + curve->setParentPlotNoReplot( plot ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCurveCollection::detachPlotCurves() { for ( RimSummaryCurve* curve : m_curves ) { - curve->detachQwtCurve(); + curve->detach(); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCurveCollection::reattachQwtCurves() +void RimSummaryCurveCollection::reattachPlotCurves() { for ( RimSummaryCurve* curve : m_curves ) { - curve->reattachQwtCurve(); + if ( curve->isCurveVisible() ) curve->reattach(); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryCurve* RimSummaryCurveCollection::findRimCurveFromQwtCurve( const QwtPlotCurve* qwtCurve ) const +RimSummaryCurve* RimSummaryCurveCollection::findRimCurveFromPlotCurve( const RiuPlotCurve* curve ) const { for ( RimSummaryCurve* rimCurve : m_curves ) { - if ( rimCurve->qwtPlotCurve() == qwtCurve ) + if ( rimCurve->isSameCurve( curve ) ) { return rimCurve; } @@ -216,7 +244,7 @@ void RimSummaryCurveCollection::removeCurve( RimSummaryCurve* curve ) { if ( curve ) { - m_curves.removeChildObject( curve ); + m_curves.removeChild( curve ); } } @@ -225,14 +253,14 @@ void RimSummaryCurveCollection::removeCurve( RimSummaryCurve* curve ) //-------------------------------------------------------------------------------------------------- std::vector RimSummaryCurveCollection::curves() const { - return m_curves.childObjects(); + return m_curves.children(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- std::vector - RimSummaryCurveCollection::curvesForSourceStepping( RimSummaryPlotSourceStepping::SourceSteppingType steppingType ) const + RimSummaryCurveCollection::curvesForSourceStepping( RimSummaryDataSourceStepping::Axis steppingType ) const { std::vector stepCurves; @@ -245,41 +273,41 @@ std::vector const std::string historyIdentifier = "H"; - std::string quantity; + std::string vectorName; - if ( steppingType == RimSummaryPlotSourceStepping::X_AXIS ) + if ( steppingType == RimSummaryDataSourceStepping::Axis::X_AXIS ) { - quantity = m_curveForSourceStepping->summaryAddressX().quantityName(); + vectorName = m_curveForSourceStepping->summaryAddressX().vectorName(); } - else if ( steppingType == RimSummaryPlotSourceStepping::Y_AXIS ) + else if ( steppingType == RimSummaryDataSourceStepping::Axis::Y_AXIS ) { - quantity = m_curveForSourceStepping->summaryAddressY().quantityName(); + vectorName = m_curveForSourceStepping->summaryAddressY().vectorName(); } std::string candidateName; - if ( RiaStdStringTools::endsWith( quantity, historyIdentifier ) ) + if ( RiaStdStringTools::endsWith( vectorName, historyIdentifier ) ) { - candidateName = quantity.substr( 0, quantity.size() - 1 ); + candidateName = vectorName.substr( 0, vectorName.size() - 1 ); } else { - candidateName = quantity + historyIdentifier; + candidateName = vectorName + historyIdentifier; } for ( const auto& c : curves() ) { - if ( steppingType == RimSummaryPlotSourceStepping::X_AXIS ) + if ( steppingType == RimSummaryDataSourceStepping::Axis::X_AXIS ) { if ( c->summaryCaseX() == m_curveForSourceStepping->summaryCaseX() && - c->summaryAddressX().quantityName() == candidateName ) + c->summaryAddressX().vectorName() == candidateName ) { stepCurves.push_back( c ); } } - else if ( steppingType == RimSummaryPlotSourceStepping::Y_AXIS ) + else if ( steppingType == RimSummaryDataSourceStepping::Axis::Y_AXIS ) { if ( c->summaryCaseY() == m_curveForSourceStepping->summaryCaseY() && - c->summaryAddressY().quantityName() == candidateName ) + c->summaryAddressY().vectorName() == candidateName ) { stepCurves.push_back( c ); } @@ -314,7 +342,7 @@ void RimSummaryCurveCollection::deleteCurvesAssosiatedWithCase( RimSummaryCase* } for ( RimSummaryCurve* summaryCurve : summaryCurvesToDelete ) { - m_curves.removeChildObject( summaryCurve ); + m_curves.removeChild( summaryCurve ); delete summaryCurve; } } @@ -324,7 +352,7 @@ void RimSummaryCurveCollection::deleteCurvesAssosiatedWithCase( RimSummaryCase* //-------------------------------------------------------------------------------------------------- void RimSummaryCurveCollection::deleteAllCurves() { - m_curves.deleteAllChildObjects(); + m_curves.deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -342,7 +370,7 @@ void RimSummaryCurveCollection::updateCaseNameHasChanged() firstAncestorOrThisOfTypeAsserted( parentPlot ); parentPlot->updatePlotTitle(); - if ( parentPlot->viewer() ) parentPlot->viewer()->updateLegend(); + if ( parentPlot->plotWidget() ) parentPlot->plotWidget()->updateLegend(); } //-------------------------------------------------------------------------------------------------- @@ -411,17 +439,17 @@ RimSummaryCurve* RimSummaryCurveCollection::curveForSourceStepping() const /// //-------------------------------------------------------------------------------------------------- RimSummaryPlotSourceStepping* - RimSummaryCurveCollection::sourceSteppingObject( RimSummaryPlotSourceStepping::SourceSteppingType sourceSteppingType ) const + RimSummaryCurveCollection::sourceSteppingObject( RimSummaryDataSourceStepping::Axis sourceSteppingType ) const { - if ( sourceSteppingType == RimSummaryPlotSourceStepping::X_AXIS ) + if ( sourceSteppingType == RimSummaryDataSourceStepping::Axis::X_AXIS ) { return m_xSourceStepping(); } - else if ( sourceSteppingType == RimSummaryPlotSourceStepping::Y_AXIS ) + else if ( sourceSteppingType == RimSummaryDataSourceStepping::Axis::Y_AXIS ) { return m_ySourceStepping(); } - if ( sourceSteppingType == RimSummaryPlotSourceStepping::UNION_X_Y_AXIS ) + if ( sourceSteppingType == RimSummaryDataSourceStepping::Axis::UNION_X_Y_AXIS ) { return m_unionSourceStepping(); } @@ -491,35 +519,6 @@ void RimSummaryCurveCollection::onChildDeleted( caf::PdmChildArrayFieldHandle* //-------------------------------------------------------------------------------------------------- void RimSummaryCurveCollection::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { - RimSummaryCrossPlot* parentCrossPlot; - firstAncestorOrThisOfType( parentCrossPlot ); - - if ( parentCrossPlot ) - { - { - auto group = uiOrdering.addNewGroup( "Y Source Stepping" ); - - m_ySourceStepping()->uiOrdering( uiConfigName, *group ); - } - - { - auto group = uiOrdering.addNewGroup( "X Source Stepping" ); - - m_xSourceStepping()->uiOrdering( uiConfigName, *group ); - } - - { - auto group = uiOrdering.addNewGroup( "XY Union Source Stepping" ); - - m_unionSourceStepping()->uiOrdering( uiConfigName, *group ); - } - } - else - { - auto group = uiOrdering.addNewGroup( "Data Source" ); - - m_ySourceStepping()->uiOrdering( uiConfigName, *group ); - } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveCollection.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveCollection.h index fe52f9857b..988aea3e02 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveCollection.h @@ -26,12 +26,12 @@ #include "cafPdmObject.h" #include "cafPdmPtrArrayField.h" -class QwtPlot; -class QwtPlotCurve; class RimSummaryCase; class RimSummaryCurve; class RimSummaryCrossPlot; class RimSummaryPlot; +class RiuPlotWidget; +class RiuPlotCurve; class QKeyEvent; //================================================================================================== @@ -53,23 +53,22 @@ class RimSummaryCurveCollection : public caf::PdmObject void setCurveForSourceStepping( RimSummaryCurve* curve ); RimSummaryCurve* curveForSourceStepping() const; - RimSummaryPlotSourceStepping* - sourceSteppingObject( RimSummaryPlotSourceStepping::SourceSteppingType sourceSteppingType ) const; + RimSummaryPlotSourceStepping* sourceSteppingObject( RimSummaryDataSourceStepping::Axis sourceSteppingType ) const; std::vector curves() const; - std::vector - curvesForSourceStepping( RimSummaryPlotSourceStepping::SourceSteppingType steppingType ) const; + std::vector curvesForSourceStepping( RimSummaryDataSourceStepping::Axis steppingType ) const; void setCurveAsTopZWithinCategory( RimSummaryCurve* curve ); void loadDataAndUpdate( bool updateParentPlot ); private: - void setParentQwtPlotAndReplot( QwtPlot* plot ); - void detachQwtCurves(); - void reattachQwtCurves(); + void setParentPlotAndReplot( RiuPlotWidget* plot ); + void setParentPlotNoReplot( RiuPlotWidget* plot ); + void detachPlotCurves(); + void reattachPlotCurves(); - RimSummaryCurve* findRimCurveFromQwtCurve( const QwtPlotCurve* qwtCurve ) const; + RimSummaryCurve* findRimCurveFromPlotCurve( const RiuPlotCurve* curve ) const; void addCurve( RimSummaryCurve* curve ); void insertCurve( RimSummaryCurve* curve, size_t index ); @@ -100,6 +99,9 @@ class RimSummaryCurveCollection : public caf::PdmObject void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, std::vector& referringObjects ) override; + void onChildrenUpdated( caf::PdmChildArrayFieldHandle* childArray, + std::vector& updatedObjects ) override; + private: friend class RimSummaryCrossPlot; friend class RimSummaryPlot; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveFilter.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveFilter.cpp deleted file mode 100644 index 3f0f094ef1..0000000000 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveFilter.cpp +++ /dev/null @@ -1,136 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2016 Statoil 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 "RimSummaryCurveFilter.h" - -#include "RimSummaryCase.h" -#include "RimSummaryCurve.h" -#include "RimSummaryCurveAutoName.h" -#include "RimSummaryFilter.h" -#include "cafPdmUiListEditor.h" -#include "cafPdmUiPushButtonEditor.h" - -// See also corresponding fake implementations in RimSummaryCurve - -QTextStream& operator<<( QTextStream& str, const std::vector& sobj ) -{ - CVF_ASSERT( false ); - return str; -} - -QTextStream& operator>>( QTextStream& str, std::vector& sobj ) -{ - CVF_ASSERT( false ); - return str; -} - -CAF_PDM_SOURCE_INIT( RimSummaryCurveFilter_OBSOLETE, "SummaryCurveFilter" ); - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimSummaryCurveFilter_OBSOLETE::RimSummaryCurveFilter_OBSOLETE() -{ - CAF_PDM_InitObject( "Curve Filter", ":/SummaryCurveFilter16x16.png", "", "" ); - - CAF_PDM_InitFieldNoDefault( &m_selectedSummaryCases, "SummaryCases", "Cases", "", "", "" ); - m_selectedSummaryCases.uiCapability()->setUiTreeChildrenHidden( true ); - m_selectedSummaryCases.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() ); - m_selectedSummaryCases.uiCapability()->setAutoAddingOptionFromValue( false ); - m_selectedSummaryCases.xmlCapability()->disableIO(); - m_selectedSummaryCases.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); - - CAF_PDM_InitFieldNoDefault( &m_summaryFilter, "VarListFilter", "Filter", "", "", "" ); - m_summaryFilter.uiCapability()->setUiTreeChildrenHidden( true ); - m_summaryFilter.uiCapability()->setUiTreeHidden( true ); - - m_summaryFilter = new RimSummaryFilter_OBSOLETE; - - CAF_PDM_InitFieldNoDefault( &m_uiFilterResultMultiSelection, - "FilterResultSelection", - "Filter Result", - "", - "Ctrl-A : Select All", - "" ); - m_uiFilterResultMultiSelection.xmlCapability()->disableIO(); - m_uiFilterResultMultiSelection.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() ); - m_uiFilterResultMultiSelection.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); - m_uiFilterResultMultiSelection.uiCapability()->setAutoAddingOptionFromValue( false ); - - CAF_PDM_InitFieldNoDefault( &m_curves, "FilteredCurves", "Filtered Curves", "", "", "" ); - m_curves.uiCapability()->setUiTreeHidden( true ); - m_curves.uiCapability()->setUiTreeChildrenHidden( false ); - - CAF_PDM_InitFieldNoDefault( &m_applyButtonField, "ApplySelection", "", "", "", "" ); - m_applyButtonField.xmlCapability()->disableIO(); - m_applyButtonField = false; - m_applyButtonField.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); - m_applyButtonField.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LEFT ); - - CAF_PDM_InitField( &m_autoApplyChangesToPlot, "AutoApplyFilterChanges", true, "Auto Apply Changes", "", "", "" ); - - CAF_PDM_InitField( &m_showCurves, "IsActive", true, "Show Curves", "", "", "" ); - m_showCurves.uiCapability()->setUiHidden( true ); - - CAF_PDM_InitField( &m_useAutoAppearanceAssignment, "UseAutoAppearanceAssignment", true, "Auto", "", "", "" ); - - CAF_PDM_InitFieldNoDefault( &m_caseAppearanceType, "CaseAppearanceType", "Case", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_variableAppearanceType, "VariableAppearanceType", "Vector", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_wellAppearanceType, "WellAppearanceType", "Well", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_groupAppearanceType, "GroupAppearanceType", "Group", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_regionAppearanceType, "RegionAppearanceType", "Region", "", "", "" ); - - CAF_PDM_InitFieldNoDefault( &m_plotAxis, "PlotAxis", "Axis", "", "", "" ); - CAF_PDM_InitField( &m_showLegend, "ShowLegend", true, "Contribute To Legend", "", "", "" ); - - CAF_PDM_InitFieldNoDefault( &m_curveNameConfig, "SummaryCurveNameConfig", "SummaryCurveNameConfig", "", "", "" ); - m_curveNameConfig.uiCapability()->setUiTreeHidden( true ); - m_curveNameConfig.uiCapability()->setUiTreeChildrenHidden( true ); - - m_curveNameConfig = new RimSummaryCurveAutoName; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimSummaryCurveFilter_OBSOLETE::~RimSummaryCurveFilter_OBSOLETE() -{ - m_curves.deleteAllChildObjects(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RimSummaryCurveFilter_OBSOLETE::curves() -{ - std::vector myCurves; - for ( RimSummaryCurve* curve : m_curves ) - { - myCurves.push_back( curve ); - } - - return myCurves; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimSummaryCurveFilter_OBSOLETE::clearCurvesWithoutDelete() -{ - m_curves.clear(); -} diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveFilter.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveFilter.h deleted file mode 100644 index 7ce6a75e54..0000000000 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveFilter.h +++ /dev/null @@ -1,82 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2016 Statoil 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 "cafAppEnum.h" -#include "cafPdmChildArrayField.h" -#include "cafPdmChildField.h" -#include "cafPdmField.h" -#include "cafPdmObject.h" -#include "cafPdmPointer.h" -#include "cafPdmPtrArrayField.h" -#include "cafPdmPtrField.h" - -#include "RifEclipseSummaryAddressQMetaType.h" - -#include "RiaDefines.h" -#include "RimSummaryCurveAppearanceCalculator.h" - -class RimSummaryFilter_OBSOLETE; -class RimSummaryCurveAutoName; - -//================================================================================================== -/// -/// -//================================================================================================== -class RimSummaryCurveFilter_OBSOLETE : public caf::PdmObject -{ - CAF_PDM_HEADER_INIT; - -public: - RimSummaryCurveFilter_OBSOLETE(); - ~RimSummaryCurveFilter_OBSOLETE() override; - - std::vector curves(); - void clearCurvesWithoutDelete(); - -private: - // QPointer m_parentQwtPlot; - - // Fields - caf::PdmField m_showCurves; - caf::PdmPtrArrayField m_selectedSummaryCases; - caf::PdmChildArrayField m_curves; - - caf::PdmField> m_plotAxis; - caf::PdmField m_showLegend; - - // Filter fields - caf::PdmChildField m_summaryFilter; - caf::PdmField> m_uiFilterResultMultiSelection; - - caf::PdmChildField m_curveNameConfig; - - caf::PdmField m_autoApplyChangesToPlot; - caf::PdmField m_applyButtonField; - - caf::PdmField m_useAutoAppearanceAssignment; - typedef caf::AppEnum AppearanceTypeAppEnum; - caf::PdmField m_caseAppearanceType; - caf::PdmField m_variableAppearanceType; - caf::PdmField m_wellAppearanceType; - caf::PdmField m_groupAppearanceType; - caf::PdmField m_regionAppearanceType; - - std::vector> m_selectionCache; -}; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurvesData.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurvesData.cpp new file mode 100644 index 0000000000..daf51ac1a2 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurvesData.cpp @@ -0,0 +1,524 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor +// +// 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 "RimSummaryCurvesData.h" + +#include "RiaSummaryCurveDefinition.h" +#include "RiaSummaryTools.h" +#include "RiaTimeHistoryCurveResampler.h" + +#include "RimAsciiDataCurve.h" +#include "RimGridTimeHistoryCurve.h" +#include "RimSummaryCase.h" +#include "RimSummaryCaseCollection.h" +#include "RimSummaryCurve.h" +#include "RimSummaryPlot.h" + +#include "cvfAssert.h" +#include "cvfMath.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCurvesData::populateTimeHistoryCurvesData( std::vector curves, + RimSummaryCurvesData* curvesData ) +{ + CVF_ASSERT( curvesData ); + + curvesData->clear(); + + for ( RimGridTimeHistoryCurve* curve : curves ) + { + if ( !curve->isCurveVisible() ) continue; + QString curveCaseName = curve->caseName(); + + CurveData curveData = { curve->curveExportDescription(), RifEclipseSummaryAddress(), curve->yValues() }; + + curvesData->addCurveData( curveCaseName, "", curve->timeStepValues(), curveData ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCurvesData::populateAsciiDataCurvesData( std::vector curves, + RimSummaryCurvesData* curvesData ) +{ + CVF_ASSERT( curvesData ); + + curvesData->clear(); + + for ( RimAsciiDataCurve* curve : curves ) + { + if ( !curve->isCurveVisible() ) continue; + + CurveData curveData = { curve->curveExportDescription(), RifEclipseSummaryAddress(), curve->yValues() }; + + curvesData->addCurveDataNoSearch( "", "", curve->timeSteps(), { curveData } ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryCurvesData::RimSummaryCurvesData() + : resamplePeriod( RiaDefines::DateTimePeriod::NONE ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCurvesData::clear() +{ + caseIds.clear(); + timeSteps.clear(); + allCurveData.clear(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCurvesData::addCurveData( const QString& caseName, + const QString& ensembleName, + const std::vector& curvetimeSteps, + const CurveData& curveData ) +{ + QString caseId = createCaseId( caseName, ensembleName ); + size_t existingCaseIndex = findCaseIndexForCaseId( caseId, curvetimeSteps.size() ); + + if ( existingCaseIndex == cvf::UNDEFINED_SIZE_T ) + { + caseIds.push_back( caseId ); + timeSteps.push_back( curvetimeSteps ); + allCurveData.push_back( { curveData } ); + } + else + { + CVF_ASSERT( timeSteps[existingCaseIndex].size() == curveData.values.size() ); + + allCurveData[existingCaseIndex].push_back( curveData ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCurvesData::addCurveDataNoSearch( const QString& caseName, + const QString& ensembleName, + const std::vector& curvetimeSteps, + const std::vector& curveDataVector ) +{ + QString caseId = createCaseId( caseName, ensembleName ); + + caseIds.push_back( caseId ); + timeSteps.push_back( curvetimeSteps ); + allCurveData.push_back( curveDataVector ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimSummaryCurvesData::createTextForExport( const std::vector& curves, + const std::vector& asciiCurves, + const std::vector& gridCurves, + RiaDefines::DateTimePeriod resamplingPeriod, + bool showTimeAsLongString ) +{ + QString out; + + RimSummaryCurvesData summaryCurvesGridData; + RimSummaryCurvesData summaryCurvesObsData; + RimSummaryCurvesData::populateSummaryCurvesData( curves, SummaryCurveType::CURVE_TYPE_GRID, &summaryCurvesGridData ); + RimSummaryCurvesData::populateSummaryCurvesData( curves, SummaryCurveType::CURVE_TYPE_OBSERVED, &summaryCurvesObsData ); + + RimSummaryCurvesData timeHistoryCurvesData; + RimSummaryCurvesData::populateTimeHistoryCurvesData( gridCurves, &timeHistoryCurvesData ); + + // Export observed data + RimSummaryCurvesData::appendToExportData( out, { summaryCurvesObsData }, showTimeAsLongString ); + + std::vector exportData( 2 ); + + // Summary grid data for export + RimSummaryCurvesData::prepareCaseCurvesForExport( resamplingPeriod, + ResampleAlgorithm::DATA_DECIDES, + summaryCurvesGridData, + &exportData[0] ); + + // Time history data for export + RimSummaryCurvesData::prepareCaseCurvesForExport( resamplingPeriod, + ResampleAlgorithm::PERIOD_END, + timeHistoryCurvesData, + &exportData[1] ); + + // Export resampled summary and time history data + RimSummaryCurvesData::appendToExportData( out, exportData, showTimeAsLongString ); + + // Pasted observed data + { + RimSummaryCurvesData asciiCurvesData; + RimSummaryCurvesData::populateAsciiDataCurvesData( asciiCurves, &asciiCurvesData ); + + RimSummaryCurvesData::appendToExportData( out, { asciiCurvesData }, showTimeAsLongString ); + } + + return out; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCurvesData::populateSummaryCurvesData( std::vector curves, + SummaryCurveType curveType, + RimSummaryCurvesData* curvesData ) +{ + CVF_ASSERT( curvesData ); + + curvesData->clear(); + + for ( RimSummaryCurve* curve : curves ) + { + bool isObservedCurve = curve->summaryCaseY() ? curve->summaryCaseY()->isObservedData() : false; + + if ( !curve->isCurveVisible() ) continue; + if ( isObservedCurve && ( curveType != SummaryCurveType::CURVE_TYPE_OBSERVED ) ) continue; + if ( !isObservedCurve && ( curveType != SummaryCurveType::CURVE_TYPE_GRID ) ) continue; + if ( !curve->summaryCaseY() ) continue; + + QString curveCaseName = curve->summaryCaseY()->displayCaseName(); + QString ensembleName; + if ( curve->curveDefinitionY().ensemble() ) + { + ensembleName = curve->curveDefinitionY().ensemble()->name(); + } + + CurveData curveData = { curve->curveExportDescription(), curve->summaryAddressY(), curve->valuesY() }; + CurveData errorCurveData; + + // Error data + auto errorValues = curve->errorValuesY(); + bool hasErrorData = !errorValues.empty(); + + if ( hasErrorData ) + { + errorCurveData.name = curve->curveExportDescription( curve->errorSummaryAddressY() ); + errorCurveData.address = curve->errorSummaryAddressY(); + errorCurveData.values = errorValues; + } + + auto curveDataList = std::vector( { curveData } ); + if ( hasErrorData ) curveDataList.push_back( errorCurveData ); + if ( curve->summaryAddressY().category() == RifEclipseSummaryAddress::SUMMARY_CALCULATED ) + { + // We have calculated data, and it we cannot assume identical time axis + curvesData->addCurveDataNoSearch( curveCaseName, ensembleName, curve->timeStepsY(), curveDataList ); + } + else + { + for ( const auto& cd : curveDataList ) + { + curvesData->addCurveData( curveCaseName, ensembleName, curve->timeStepsY(), cd ); + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCurvesData::prepareCaseCurvesForExport( RiaDefines::DateTimePeriod period, + ResampleAlgorithm algorithm, + const RimSummaryCurvesData& inputCurvesData, + RimSummaryCurvesData* resultCurvesData ) +{ + RiaTimeHistoryCurveResampler resampler; + + resultCurvesData->clear(); + + if ( period != RiaDefines::DateTimePeriod::NONE ) + { + // Prepare result data + resultCurvesData->resamplePeriod = period; + + for ( size_t i = 0; i < inputCurvesData.caseIds.size(); i++ ) + { + // Shortcuts to input data + auto& caseId = inputCurvesData.caseIds[i]; + auto& caseTimeSteps = inputCurvesData.timeSteps[i]; + auto& caseCurveData = inputCurvesData.allCurveData[i]; + + // Prepare result data + + for ( auto& curveDataItem : caseCurveData ) + { + resampler.setCurveData( curveDataItem.values, caseTimeSteps ); + + if ( RiaSummaryTools::hasAccumulatedData( curveDataItem.address ) || + algorithm == ResampleAlgorithm::PERIOD_END ) + { + resampler.resampleAndComputePeriodEndValues( period ); + } + else + { + resampler.resampleAndComputeWeightedMeanValues( period ); + } + + auto cd = curveDataItem; + cd.values = resampler.resampledValues(); + + resultCurvesData->addCurveData( caseId, "", resampler.resampledTimeSteps(), cd ); + } + } + } + else + { + *resultCurvesData = inputCurvesData; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCurvesData::appendToExportDataForCase( QString& out, + const std::vector& timeSteps, + const std::vector& curveData ) +{ + for ( size_t j = 0; j < timeSteps.size(); j++ ) // time steps & data points + { + if ( j == 0 ) + { + out += "Date and time"; + for ( const auto& k : curveData ) // curves + { + out += "\t" + ( k.name ); + } + } + out += "\n"; + out += QDateTime::fromSecsSinceEpoch( timeSteps[j] ).toUTC().toString( "yyyy-MM-dd hh:mm:ss " ); + + for ( const auto& k : curveData ) // curves + { + QString valueText; + if ( j < k.values.size() ) + { + valueText = QString::number( k.values[j], 'g', RimSummaryPlot::precision() ); + } + out += "\t" + valueText.rightJustified( 13 ); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCurvesData::appendToExportData( QString& out, + const std::vector& curvesData, + bool showTimeAsLongString ) +{ + RimSummaryCurvesData data = RimSummaryCurvesData::concatCurvesData( curvesData ); + + if ( data.resamplePeriod != RiaDefines::DateTimePeriod::NONE ) + { + time_t minTimeStep = std::numeric_limits::max(); + time_t maxTimeStep = 0; + + for ( auto& timeSteps : data.timeSteps ) + { + if ( !timeSteps.empty() ) + { + if ( timeSteps.front() < minTimeStep ) minTimeStep = timeSteps.front(); + if ( timeSteps.back() > maxTimeStep ) maxTimeStep = timeSteps.back(); + } + } + + auto allTimeSteps = + RiaTimeHistoryCurveResampler::timeStepsFromTimeRange( data.resamplePeriod, minTimeStep, maxTimeStep ); + + out += "\n\n"; + out += "Date and time"; + for ( size_t i = 0; i < data.caseIds.size(); i++ ) + { + for ( auto& j : data.allCurveData[i] ) + { + out += "\t" + j.name; + } + } + out += "\n"; + + std::vector currIndexes( data.caseIds.size() ); + for ( auto& i : currIndexes ) + i = 0; + + for ( auto timeStep : allTimeSteps ) + { + QDateTime timseStepUtc = QDateTime::fromSecsSinceEpoch( timeStep ).toUTC(); + QString timeText; + + if ( showTimeAsLongString ) + { + timeText = timseStepUtc.toString( "yyyy-MM-dd hh:mm:ss " ); + } + else + { + // Subtract one day to make sure the period is reported using the previous period as label + QDateTime oneDayEarlier = timseStepUtc.addDays( -1 ); + + QChar zeroChar( 48 ); + + switch ( data.resamplePeriod ) + { + default: + // Fall through to NONE + case RiaDefines::DateTimePeriod::NONE: + timeText = timseStepUtc.toString( "yyyy-MM-dd hh:mm:ss " ); + break; + case RiaDefines::DateTimePeriod::DAY: + timeText = oneDayEarlier.toString( "yyyy-MM-dd " ); + break; + case RiaDefines::DateTimePeriod::WEEK: + { + timeText = oneDayEarlier.toString( "yyyy" ); + int weekNumber = oneDayEarlier.date().weekNumber(); + timeText += QString( "-W%1" ).arg( weekNumber, 2, 10, zeroChar ); + break; + } + case RiaDefines::DateTimePeriod::MONTH: + timeText = oneDayEarlier.toString( "yyyy-MM" ); + break; + case RiaDefines::DateTimePeriod::QUARTER: + { + int quarterNumber = oneDayEarlier.date().month() / 3; + timeText = oneDayEarlier.toString( "yyyy" ); + timeText += QString( "-Q%1" ).arg( quarterNumber ); + break; + } + case RiaDefines::DateTimePeriod::HALFYEAR: + { + int halfYearNumber = oneDayEarlier.date().month() / 6; + timeText = oneDayEarlier.toString( "yyyy" ); + timeText += QString( "-H%1" ).arg( halfYearNumber ); + break; + } + case RiaDefines::DateTimePeriod::YEAR: + timeText = oneDayEarlier.toString( "yyyy" ); + break; + case RiaDefines::DateTimePeriod::DECADE: + timeText = oneDayEarlier.toString( "yyyy" ); + break; + } + } + out += timeText; + + for ( size_t i = 0; i < data.caseIds.size(); i++ ) // cases + { + // Check is time step exists in curr case + size_t& currIndex = currIndexes[i]; + bool timeStepExists = currIndex < data.timeSteps[i].size() && timeStep == data.timeSteps[i][currIndex]; + + for ( auto& j : data.allCurveData[i] ) // vectors + { + QString valueText; + if ( timeStepExists ) + { + valueText = QString::number( j.values[currIndex], 'g', RimSummaryPlot::precision() ); + } + else + { + valueText = "NULL"; + } + out += "\t" + valueText.rightJustified( 13 ); + } + + if ( timeStepExists && currIndex < data.timeSteps[i].size() ) currIndex++; + } + out += "\n"; + } + } + else + { + for ( size_t i = 0; i < data.caseIds.size(); i++ ) + { + out += "\n\n"; + if ( !data.caseIds[i].isEmpty() ) + { + out += "Case: " + data.caseIds[i]; + out += "\n"; + } + + appendToExportDataForCase( out, data.timeSteps[i], data.allCurveData[i] ); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryCurvesData RimSummaryCurvesData::concatCurvesData( const std::vector& curvesData ) +{ + CVF_ASSERT( !curvesData.empty() ); + + RiaDefines::DateTimePeriod period = curvesData.front().resamplePeriod; + RimSummaryCurvesData resultCurvesData; + + resultCurvesData.resamplePeriod = period; + + for ( auto curvesDataItem : curvesData ) + { + if ( curvesDataItem.caseIds.empty() ) continue; + + CVF_ASSERT( curvesDataItem.resamplePeriod == period ); + + resultCurvesData.caseIds.insert( resultCurvesData.caseIds.end(), + curvesDataItem.caseIds.begin(), + curvesDataItem.caseIds.end() ); + resultCurvesData.timeSteps.insert( resultCurvesData.timeSteps.end(), + curvesDataItem.timeSteps.begin(), + curvesDataItem.timeSteps.end() ); + resultCurvesData.allCurveData.insert( resultCurvesData.allCurveData.end(), + curvesDataItem.allCurveData.begin(), + curvesDataItem.allCurveData.end() ); + } + return resultCurvesData; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RimSummaryCurvesData::findCaseIndexForCaseId( const QString& caseId, size_t timeStepCount ) +{ + size_t casePosInList = cvf::UNDEFINED_SIZE_T; + + for ( size_t i = 0; i < caseIds.size(); i++ ) + { + if ( caseId == caseIds[i] && timeSteps[i].size() == timeStepCount ) casePosInList = i; + } + + return casePosInList; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimSummaryCurvesData::createCaseId( const QString& caseName, const QString& ensembleName ) +{ + QString caseId = caseName; + if ( !ensembleName.isEmpty() ) caseId += QString( " (%1)" ).arg( ensembleName ); + + return caseId; +} diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurvesData.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurvesData.h new file mode 100644 index 0000000000..0d40ff52ff --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurvesData.h @@ -0,0 +1,102 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor +// +// 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 "RiaDateTimeDefines.h" +#include "RifEclipseSummaryAddress.h" + +#include + +class RimSummaryCurve; +class RimGridTimeHistoryCurve; +class RimAsciiDataCurve; + +struct CurveData +{ + QString name; + RifEclipseSummaryAddress address; + std::vector values; +}; + +enum class SummaryCurveType +{ + CURVE_TYPE_GRID = 0x1, + CURVE_TYPE_OBSERVED = 0x2 +}; + +enum class ResampleAlgorithm +{ + NONE, + DATA_DECIDES, + PERIOD_END +}; + +class RimSummaryCurvesData +{ +public: + RimSummaryCurvesData(); + void clear(); + + void addCurveData( const QString& caseName, + const QString& ensembleName, + const std::vector& curvetimeSteps, + const CurveData& curveData ); + + void addCurveDataNoSearch( const QString& caseName, + const QString& ensembleName, + const std::vector& curvetimeSteps, + const std::vector& curveDataVector ); + + static QString createTextForExport( const std::vector& curves, + const std::vector& asciiCurves, + const std::vector& gridCurves, + RiaDefines::DateTimePeriod resamplingPeriod, + bool showTimeAsLongString ); + +private: + static void populateSummaryCurvesData( std::vector curves, + SummaryCurveType curveType, + RimSummaryCurvesData* curvesData ); + static void populateTimeHistoryCurvesData( std::vector curves, + RimSummaryCurvesData* curvesData ); + static void populateAsciiDataCurvesData( std::vector curves, RimSummaryCurvesData* curvesData ); + + static void prepareCaseCurvesForExport( RiaDefines::DateTimePeriod period, + ResampleAlgorithm algorithm, + const RimSummaryCurvesData& inputCurvesData, + RimSummaryCurvesData* resultCurvesData ); + + static void appendToExportDataForCase( QString& out, + const std::vector& timeSteps, + const std::vector& curveData ); + static void + appendToExportData( QString& out, const std::vector& curvesData, bool showTimeAsLongString ); + RimSummaryCurvesData static concatCurvesData( const std::vector& curvesData ); + +private: + size_t findCaseIndexForCaseId( const QString& caseId, size_t timeStepCount ); + + QString createCaseId( const QString& caseName, const QString& ensembleName ); + +public: + RiaDefines::DateTimePeriod resamplePeriod; + std::vector caseIds; + std::vector> timeSteps; + std::vector> allCurveData; +}; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryDataSourceStepping.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryDataSourceStepping.cpp new file mode 100644 index 0000000000..b5490334ab --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryDataSourceStepping.cpp @@ -0,0 +1,38 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimSummaryDataSourceStepping.h" + +#include "cafAppEnum.h" + +namespace caf +{ +template <> +void AppEnum::setUp() +{ + addItem( RimSummaryDataSourceStepping::SourceSteppingDimension::VECTOR, "VECTOR", "Vector" ); + addItem( RimSummaryDataSourceStepping::SourceSteppingDimension::WELL, "WELL", "Well" ); + addItem( RimSummaryDataSourceStepping::SourceSteppingDimension::SUMMARY_CASE, "SUMMARY_CASE", "Summary Case" ); + addItem( RimSummaryDataSourceStepping::SourceSteppingDimension::ENSEMBLE, "ENSEMBLE", "Ensemble" ); + addItem( RimSummaryDataSourceStepping::SourceSteppingDimension::GROUP, "GROUP", "Group" ); + addItem( RimSummaryDataSourceStepping::SourceSteppingDimension::REGION, "REGION", "Region" ); + addItem( RimSummaryDataSourceStepping::SourceSteppingDimension::BLOCK, "BLOCK", "Block" ); + addItem( RimSummaryDataSourceStepping::SourceSteppingDimension::AQUIFER, "AQUIFER", "Aquifer" ); + setDefault( RimSummaryDataSourceStepping::SourceSteppingDimension::VECTOR ); +} +} // namespace caf diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryDataSourceStepping.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryDataSourceStepping.h new file mode 100644 index 0000000000..3927844db8 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryDataSourceStepping.h @@ -0,0 +1,53 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include + +class RimSummaryCurve; +class RimEnsembleCurveSet; + +class RimSummaryDataSourceStepping +{ +public: + enum class Axis + { + Y_AXIS, + X_AXIS, + UNION_X_Y_AXIS + }; + + enum class SourceSteppingDimension + { + SUMMARY_CASE, + ENSEMBLE, + WELL, + GROUP, + REGION, + VECTOR, + BLOCK, + AQUIFER + }; + +public: + virtual std::vector availableAxes() const = 0; + virtual std::vector curvesForStepping( RimSummaryDataSourceStepping::Axis axis ) const = 0; + virtual std::vector allCurves( RimSummaryDataSourceStepping::Axis axis ) const = 0; + virtual std::vector curveSets() const = 0; +}; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryFilter.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryFilter.cpp deleted file mode 100644 index 7f13056a00..0000000000 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryFilter.cpp +++ /dev/null @@ -1,519 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2016 Statoil 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 "RimSummaryFilter.h" - -#include "RimSummaryCurve.h" -#include "RimSummaryCurveFilter.h" - -namespace caf -{ -template <> -void caf::AppEnum::setUp() -{ - addItem( RimSummaryFilter_OBSOLETE::SUM_FILTER_VAR_STRING, "SUM_FILTER_VAR_STRING", "All" ); - addItem( RimSummaryFilter_OBSOLETE::SUM_FILTER_FIELD, "SUM_FILTER_FIELD", "Field" ); - addItem( RimSummaryFilter_OBSOLETE::SUM_FILTER_WELL, "SUM_FILTER_WELL", "Well" ); - addItem( RimSummaryFilter_OBSOLETE::SUM_FILTER_WELL_GROUP, "SUM_FILTER_WELL_GROUP", "Group" ); - addItem( RimSummaryFilter_OBSOLETE::SUM_FILTER_WELL_COMPLETION, "SUM_FILTER_WELL_COMPLETION", "Completion" ); - addItem( RimSummaryFilter_OBSOLETE::SUM_FILTER_WELL_SEGMENT, "SUM_FILTER_SEGMENT", "Segment" ); - addItem( RimSummaryFilter_OBSOLETE::SUM_FILTER_BLOCK, "SUM_FILTER_BLOCK", "Block" ); - addItem( RimSummaryFilter_OBSOLETE::SUM_FILTER_REGION, "SUM_FILTER_REGION", "Region" ); - addItem( RimSummaryFilter_OBSOLETE::SUM_FILTER_REGION_2_REGION, "SUM_FILTER_REGION_2_REGION", "Region-Region" ); - addItem( RimSummaryFilter_OBSOLETE::SUM_FILTER_WELL_LGR, "SUM_FILTER_WELL_LGR", "Lgr-Well" ); - addItem( RimSummaryFilter_OBSOLETE::SUM_FILTER_WELL_COMPLETION_LGR, "SUM_FILTER_WELL_COMPLETION_LGR", "Lgr-Completion" ); - addItem( RimSummaryFilter_OBSOLETE::SUM_FILTER_BLOCK_LGR, "SUM_FILTER_BLOCK_LGR", "Lgr-Block" ); - addItem( RimSummaryFilter_OBSOLETE::SUM_FILTER_MISC, "SUM_FILTER_MISC", "Misc" ); - addItem( RimSummaryFilter_OBSOLETE::SUM_FILTER_AQUIFER, "SUM_FILTER_AQUIFER", "Aquifer" ); - addItem( RimSummaryFilter_OBSOLETE::SUM_FILTER_NETWORK, "SUM_FILTER_NETWORK", "Network" ); - addItem( RimSummaryFilter_OBSOLETE::SUM_FILTER_ANY, "SUM_FILTER_ANY", "All (Advanced)" ); - setDefault( RimSummaryFilter_OBSOLETE::SUM_FILTER_VAR_STRING ); -} - -} // namespace caf - -CAF_PDM_SOURCE_INIT( RimSummaryFilter_OBSOLETE, "SummaryFilterSettings" ); - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimSummaryFilter_OBSOLETE::RimSummaryFilter_OBSOLETE() -{ - CAF_PDM_InitObject( "Summary Filter", "", "", "" ); - - CAF_PDM_InitFieldNoDefault( &m_filterType, "SummaryFilterType", "Search", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_completeVarStringFilter, "SummaryCompleteVarStringFilter", "Filter", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_filterQuantityName, "SummaryVarQuantityFilter", "Vector name", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_regionNumberFilter, "SummaryRegionNumberFilter", "Region number", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_regionNumber2Filter, "SummaryRegionNumber2Filter", "2. Region number", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_wellGroupNameFilter, "SummaryWellGroupNameFilter", "Group name", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_wellNameFilter, "SummaryWellNameFilter", "Well name", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_wellSegmentNumberFilter, "SummaryWellSegmentNumberFilter", "Segment number", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_lgrNameFilter, "SummaryLgrNameFilter", "LGR Name", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_cellIJKFilter, "SummaryCellIJKFilter", "I, J, K", "", "", "" ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimSummaryFilter_OBSOLETE::~RimSummaryFilter_OBSOLETE() -{ -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString cellIJKString( int cellI, int cellJ, int cellK ) -{ - QString ijkString; - if ( cellI >= 0 && cellJ >= 0 && cellK >= 0 ) - { - ijkString = QString::number( cellI ) + ", " + QString::number( cellJ ) + ", " + QString::number( cellK ); - } - - return ijkString; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimSummaryFilter_OBSOLETE::updateFromAddress( const RifEclipseSummaryAddress& address ) -{ - RifEclipseSummaryAddress::SummaryVarCategory category = address.category(); - - m_filterQuantityName = QString::fromStdString( address.quantityName() ); - - switch ( category ) - { - case RifEclipseSummaryAddress::SUMMARY_INVALID: - m_filterType = SUM_FILTER_VAR_STRING; - break; - - case RifEclipseSummaryAddress::SUMMARY_FIELD: - m_filterType = SUM_FILTER_FIELD; - break; - - case RifEclipseSummaryAddress::SUMMARY_AQUIFER: - m_filterType = SUM_FILTER_AQUIFER; - break; - - case RifEclipseSummaryAddress::SUMMARY_NETWORK: - m_filterType = SUM_FILTER_NETWORK; - break; - - case RifEclipseSummaryAddress::SUMMARY_MISC: - m_filterType = SUM_FILTER_MISC; - break; - - case RifEclipseSummaryAddress::SUMMARY_REGION: - m_filterType = SUM_FILTER_REGION; - m_regionNumberFilter = QString( "%1" ).arg( address.regionNumber() ); - break; - - case RifEclipseSummaryAddress::SUMMARY_REGION_2_REGION: - m_filterType = SUM_FILTER_REGION_2_REGION; - m_regionNumberFilter = QString( "%1" ).arg( address.regionNumber() ); - m_regionNumber2Filter = QString( "%1" ).arg( address.regionNumber2() ); - break; - - case RifEclipseSummaryAddress::SUMMARY_WELL_GROUP: - m_filterType = SUM_FILTER_WELL_GROUP; - m_wellGroupNameFilter = QString::fromStdString( address.wellGroupName() ); - break; - - case RifEclipseSummaryAddress::SUMMARY_WELL: - m_filterType = SUM_FILTER_WELL; - m_wellNameFilter = QString::fromStdString( address.wellName() ); - break; - - case RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION: - m_filterType = SUM_FILTER_WELL_COMPLETION; - m_wellNameFilter = QString::fromStdString( address.wellName() ); - m_cellIJKFilter = cellIJKString( address.cellI(), address.cellJ(), address.cellK() ); - break; - - case RifEclipseSummaryAddress::SUMMARY_WELL_LGR: - m_filterType = SUM_FILTER_WELL_LGR; - m_wellNameFilter = QString::fromStdString( address.wellName() ); - m_lgrNameFilter = QString::fromStdString( address.lgrName() ); - break; - - case RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION_LGR: - m_filterType = SUM_FILTER_WELL_COMPLETION_LGR; - m_wellNameFilter = QString::fromStdString( address.wellName() ); - m_lgrNameFilter = QString::fromStdString( address.lgrName() ); - m_cellIJKFilter = cellIJKString( address.cellI(), address.cellJ(), address.cellK() ); - break; - - case RifEclipseSummaryAddress::SUMMARY_WELL_SEGMENT: - m_filterType = SUM_FILTER_WELL_SEGMENT; - m_wellNameFilter = QString::fromStdString( address.wellName() ); - m_wellSegmentNumberFilter = QString( "%1" ).arg( address.wellSegmentNumber() ); - break; - - case RifEclipseSummaryAddress::SUMMARY_BLOCK: - m_filterType = SUM_FILTER_BLOCK; - m_cellIJKFilter = cellIJKString( address.cellI(), address.cellJ(), address.cellK() ); - break; - - case RifEclipseSummaryAddress::SUMMARY_BLOCK_LGR: - m_filterType = SUM_FILTER_BLOCK_LGR; - m_lgrNameFilter = QString::fromStdString( address.lgrName() ); - m_cellIJKFilter = cellIJKString( address.cellI(), address.cellJ(), address.cellK() ); - break; - - default: - break; - } -} - -bool isNumberMatch( QString numericalFilterString, int number ) -{ - if ( numericalFilterString.isEmpty() ) return true; - - if ( numericalFilterString.trimmed() == "*" ) - { - if ( number >= 0 ) - return true; - else - return false; - } - - // Todo: Ranges, and lists - int filterNumber = numericalFilterString.toInt(); - return number == filterNumber; -} - -bool isStringMatch( QString filterString, std::string value ) -{ - if ( filterString.isEmpty() ) return true; - if ( filterString.trimmed() == "*" ) - { - if ( !value.empty() ) - return true; - else - return false; - } - - QRegExp searcher( filterString, Qt::CaseInsensitive, QRegExp::WildcardUnix ); - QString qstrValue = QString::fromStdString( value ); - return searcher.exactMatch( qstrValue ); -} - -bool isIJKMatch( QString filterString, int cellI, int cellJ, int cellK ) -{ - if ( filterString.isEmpty() ) return true; - if ( filterString.trimmed() == "*" ) - { - if ( cellI >= 0 && cellJ >= 0 && cellK >= 0 ) - return true; - else - return false; - } - - QString ijkString = cellIJKString( cellI, cellJ, cellK ); - - // Todo: Ranges, and lists - QRegExp searcher( filterString, Qt::CaseInsensitive, QRegExp::WildcardUnix ); - - return searcher.exactMatch( ijkString ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RimSummaryFilter_OBSOLETE::isIncludedByFilter( const RifEclipseSummaryAddress& addr ) const -{ - if ( !isSumVarTypeMatchingFilterType( m_filterType(), addr.category() ) ) return false; - - if ( m_filterType() == SUM_FILTER_VAR_STRING ) - { - return addr.isUiTextMatchingFilterText( m_completeVarStringFilter() ); - } - - if ( !isStringMatch( m_filterQuantityName(), addr.quantityName() ) ) return false; - - if ( m_filterType() == SUM_FILTER_ANY ) - { - return ( isNumberMatch( m_regionNumberFilter(), addr.regionNumber() ) && - isNumberMatch( m_regionNumber2Filter(), addr.regionNumber2() ) && - isStringMatch( m_wellGroupNameFilter(), addr.wellGroupName() ) && - isStringMatch( m_wellNameFilter(), addr.wellName() ) && - isStringMatch( m_lgrNameFilter(), addr.lgrName() ) && - isNumberMatch( m_wellSegmentNumberFilter(), addr.wellSegmentNumber() ) && - isIJKMatch( m_cellIJKFilter(), addr.cellI(), addr.cellJ(), addr.cellK() ) ); - } - - switch ( addr.category() ) - { - case RifEclipseSummaryAddress::SUMMARY_REGION: - { - return isNumberMatch( m_regionNumberFilter(), addr.regionNumber() ); - } - break; - case RifEclipseSummaryAddress::SUMMARY_REGION_2_REGION: - { - return isNumberMatch( m_regionNumberFilter(), addr.regionNumber() ) && - isNumberMatch( m_regionNumber2Filter(), addr.regionNumber2() ); - } - break; - case RifEclipseSummaryAddress::SUMMARY_WELL_GROUP: - { - return isStringMatch( m_wellGroupNameFilter(), addr.wellGroupName() ); - } - break; - case RifEclipseSummaryAddress::SUMMARY_WELL: - { - return isStringMatch( m_wellNameFilter(), addr.wellName() ); - } - break; - case RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION: - { - return isStringMatch( m_wellNameFilter(), addr.wellName() ) && - isIJKMatch( m_cellIJKFilter(), addr.cellI(), addr.cellJ(), addr.cellK() ); - } - break; - case RifEclipseSummaryAddress::SUMMARY_WELL_LGR: - { - return isStringMatch( m_wellNameFilter(), addr.wellName() ) && - isStringMatch( m_lgrNameFilter(), addr.lgrName() ); - } - break; - - case RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION_LGR: - { - return isStringMatch( m_wellNameFilter(), addr.wellName() ) && - isStringMatch( m_lgrNameFilter(), addr.lgrName() ) && - isIJKMatch( m_cellIJKFilter(), addr.cellI(), addr.cellJ(), addr.cellK() ); - } - break; - case RifEclipseSummaryAddress::SUMMARY_WELL_SEGMENT: - { - return isStringMatch( m_wellNameFilter(), addr.wellName() ) && - isNumberMatch( m_wellSegmentNumberFilter(), addr.wellSegmentNumber() ); - } - break; - case RifEclipseSummaryAddress::SUMMARY_BLOCK: - { - return isIJKMatch( m_cellIJKFilter(), addr.cellI(), addr.cellJ(), addr.cellK() ); - } - break; - case RifEclipseSummaryAddress::SUMMARY_BLOCK_LGR: - { - return isStringMatch( m_lgrNameFilter(), addr.lgrName() ) && - isIJKMatch( m_cellIJKFilter(), addr.cellI(), addr.cellJ(), addr.cellK() ); - } - break; - } - - return true; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RimSummaryFilter_OBSOLETE::isSumVarTypeMatchingFilterType( SummaryFilterType sumFilterType, - RifEclipseSummaryAddress::SummaryVarCategory sumVarType ) -{ - if ( sumVarType == RifEclipseSummaryAddress::SUMMARY_INVALID ) return false; - if ( sumFilterType == SUM_FILTER_ANY || sumFilterType == SUM_FILTER_VAR_STRING ) return true; - - switch ( sumVarType ) - { - case RifEclipseSummaryAddress::SUMMARY_FIELD: - { - return ( sumFilterType == SUM_FILTER_FIELD ); - } - break; - case RifEclipseSummaryAddress::SUMMARY_AQUIFER: - { - return ( sumFilterType == SUM_FILTER_AQUIFER ); - } - break; - case RifEclipseSummaryAddress::SUMMARY_NETWORK: - { - return ( sumFilterType == SUM_FILTER_NETWORK ); - } - break; - case RifEclipseSummaryAddress::SUMMARY_MISC: - { - return ( sumFilterType == SUM_FILTER_MISC ); - } - break; - case RifEclipseSummaryAddress::SUMMARY_REGION: - { - return ( sumFilterType == SUM_FILTER_REGION ); - } - break; - case RifEclipseSummaryAddress::SUMMARY_REGION_2_REGION: - { - return ( sumFilterType == SUM_FILTER_REGION_2_REGION ); - } - break; - case RifEclipseSummaryAddress::SUMMARY_WELL_GROUP: - { - return ( sumFilterType == SUM_FILTER_WELL_GROUP ); - } - break; - case RifEclipseSummaryAddress::SUMMARY_WELL: - { - return ( sumFilterType == SUM_FILTER_WELL ); - } - break; - case RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION: - { - return ( sumFilterType == SUM_FILTER_WELL_COMPLETION ); - } - break; - case RifEclipseSummaryAddress::SUMMARY_WELL_LGR: - { - return ( sumFilterType == SUM_FILTER_WELL_LGR ); - } - break; - case RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION_LGR: - { - return ( sumFilterType == SUM_FILTER_WELL_COMPLETION_LGR ); - } - break; - case RifEclipseSummaryAddress::SUMMARY_WELL_SEGMENT: - { - return ( sumFilterType == SUM_FILTER_WELL_SEGMENT ); - } - break; - case RifEclipseSummaryAddress::SUMMARY_BLOCK: - { - return ( sumFilterType == SUM_FILTER_BLOCK ); - } - break; - case RifEclipseSummaryAddress::SUMMARY_BLOCK_LGR: - { - return ( sumFilterType == SUM_FILTER_BLOCK_LGR ); - } - break; - } - - return false; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimSummaryFilter_OBSOLETE::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) -{ - uiOrdering.add( &m_filterType ); - - if ( m_filterType() == SUM_FILTER_VAR_STRING ) - { - uiOrdering.add( &m_completeVarStringFilter ); - } - else - { - caf::PdmUiOrdering* curveVarFilterGroup = &uiOrdering; // uiOrdering.addNewGroup("Search Options"); - - curveVarFilterGroup->add( &m_filterQuantityName ); - - switch ( m_filterType() ) - { - case SUM_FILTER_ANY: - { - curveVarFilterGroup->add( &m_wellNameFilter ); - curveVarFilterGroup->add( &m_wellGroupNameFilter ); - curveVarFilterGroup->add( &m_regionNumberFilter ); - curveVarFilterGroup->add( &m_regionNumber2Filter ); - curveVarFilterGroup->add( &m_wellSegmentNumberFilter ); - curveVarFilterGroup->add( &m_lgrNameFilter ); - curveVarFilterGroup->add( &m_cellIJKFilter ); - } - break; - case SUM_FILTER_REGION: - { - curveVarFilterGroup->add( &m_regionNumberFilter ); - } - break; - case SUM_FILTER_REGION_2_REGION: - { - curveVarFilterGroup->add( &m_regionNumberFilter ); - curveVarFilterGroup->add( &m_regionNumber2Filter ); - } - break; - case SUM_FILTER_WELL_GROUP: - { - curveVarFilterGroup->add( &m_wellGroupNameFilter ); - } - break; - case SUM_FILTER_WELL: - { - curveVarFilterGroup->add( &m_wellNameFilter ); - } - break; - case SUM_FILTER_WELL_COMPLETION: - { - curveVarFilterGroup->add( &m_wellNameFilter ); - curveVarFilterGroup->add( &m_cellIJKFilter ); - } - break; - case SUM_FILTER_WELL_LGR: - { - curveVarFilterGroup->add( &m_wellNameFilter ); - curveVarFilterGroup->add( &m_lgrNameFilter ); - } - break; - case SUM_FILTER_WELL_COMPLETION_LGR: - { - curveVarFilterGroup->add( &m_wellNameFilter ); - curveVarFilterGroup->add( &m_lgrNameFilter ); - curveVarFilterGroup->add( &m_cellIJKFilter ); - } - break; - case SUM_FILTER_WELL_SEGMENT: - { - curveVarFilterGroup->add( &m_wellNameFilter ); - curveVarFilterGroup->add( &m_wellSegmentNumberFilter ); - } - break; - case SUM_FILTER_BLOCK: - { - curveVarFilterGroup->add( &m_cellIJKFilter ); - } - break; - case SUM_FILTER_BLOCK_LGR: - { - curveVarFilterGroup->add( &m_lgrNameFilter ); - curveVarFilterGroup->add( &m_cellIJKFilter ); - } - break; - } - } - - uiOrdering.skipRemainingFields(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimSummaryFilter_OBSOLETE::fieldChangedByUi( const caf::PdmFieldHandle* changedField, - const QVariant& oldValue, - const QVariant& newValue ) -{ - caf::PdmObject* parent = dynamic_cast( this->parentField()->ownerObject() ); - - if ( parent ) - { - parent->updateConnectedEditors(); - } -} diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryFilter.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryFilter.h deleted file mode 100644 index 2acea02749..0000000000 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryFilter.h +++ /dev/null @@ -1,80 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2016 Statoil 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 "RifEclipseSummaryAddress.h" - -#include "cafPdmField.h" -#include "cafPdmObject.h" - -class RimSummaryFilter_OBSOLETE : public caf::PdmObject -{ - CAF_PDM_HEADER_INIT; - -public: - enum SummaryFilterType - { - SUM_FILTER_VAR_STRING, - SUM_FILTER_ANY, - SUM_FILTER_FIELD, - SUM_FILTER_AQUIFER, - SUM_FILTER_NETWORK, - SUM_FILTER_MISC, - SUM_FILTER_REGION, - SUM_FILTER_REGION_2_REGION, - SUM_FILTER_WELL_GROUP, - SUM_FILTER_WELL, - SUM_FILTER_WELL_COMPLETION, - SUM_FILTER_WELL_COMPLETION_LGR, - SUM_FILTER_WELL_LGR, - SUM_FILTER_WELL_SEGMENT, - SUM_FILTER_BLOCK, - SUM_FILTER_BLOCK_LGR, - }; - - RimSummaryFilter_OBSOLETE(); - ~RimSummaryFilter_OBSOLETE() override; - - void updateFromAddress( const RifEclipseSummaryAddress& address ); - - bool isIncludedByFilter( const RifEclipseSummaryAddress& addr ) const; - - void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - -private: - friend class RimSummaryCurve; - - static bool isSumVarTypeMatchingFilterType( SummaryFilterType sumFilterType, - RifEclipseSummaryAddress::SummaryVarCategory sumVarType ); - - void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; - -private: - caf::PdmField> m_filterType; - caf::PdmField m_completeVarStringFilter; - - caf::PdmField m_filterQuantityName; - caf::PdmField m_regionNumberFilter; - caf::PdmField m_regionNumber2Filter; - caf::PdmField m_wellGroupNameFilter; - caf::PdmField m_wellNameFilter; - caf::PdmField m_wellSegmentNumberFilter; - caf::PdmField m_lgrNameFilter; - caf::PdmField m_cellIJKFilter; -}; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.cpp new file mode 100644 index 0000000000..056c310ad1 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.cpp @@ -0,0 +1,1484 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimSummaryMultiPlot.h" + +#include "RiaApplication.h" +#include "RiaPlotDefines.h" +#include "RiaSummaryAddressAnalyzer.h" +#include "RiaSummaryStringTools.h" + +#include "PlotBuilderCommands/RicAppendSummaryPlotsForObjectsFeature.h" +#include "PlotBuilderCommands/RicAppendSummaryPlotsForSummaryAddressesFeature.h" +#include "PlotBuilderCommands/RicAppendSummaryPlotsForSummaryCasesFeature.h" +#include "PlotBuilderCommands/RicSummaryPlotBuilder.h" + +#include "PlotBuilderCommands/RicSummaryPlotBuilder.h" + +#include "RifEclEclipseSummary.h" +#include "RifEclipseRftAddress.h" +#include "RifEclipseSummaryAddress.h" + +#include "RimEnsembleCurveSet.h" +#include "RimMainPlotCollection.h" +#include "RimMultiPlotCollection.h" +#include "RimMultipleSummaryPlotNameHelper.h" +#include "RimPlotAxisProperties.h" +#include "RimProject.h" +#include "RimSummaryAddress.h" +#include "RimSummaryAddressCollection.h" +#include "RimSummaryAddressModifier.h" +#include "RimSummaryCase.h" +#include "RimSummaryCaseCollection.h" +#include "RimSummaryCurve.h" +#include "RimSummaryMultiPlotCollection.h" +#include "RimSummaryPlot.h" +#include "RimSummaryPlotControls.h" +#include "RimSummaryPlotNameHelper.h" +#include "RimSummaryPlotSourceStepping.h" +#include "RimSummaryTimeAxisProperties.h" + +#include "RiuPlotMainWindowTools.h" +#include "RiuSummaryMultiPlotBook.h" +#include "RiuSummaryVectorSelectionUi.h" + +#include "cafPdmUiComboBoxEditor.h" +#include "cafPdmUiPushButtonEditor.h" +#include "cafPdmUiTreeOrdering.h" +#include "cafPdmUiTreeSelectionEditor.h" + +#include "qwt_scale_engine.h" + +#include + +#include + +namespace caf +{ +template <> +void AppEnum::setUp() +{ + addItem( RimSummaryMultiPlot::AxisRangeAggregation::NONE, "NONE", "None" ); + addItem( RimSummaryMultiPlot::AxisRangeAggregation::SUB_PLOTS, "SUB_PLOTS", "All Sub Plots" ); + addItem( RimSummaryMultiPlot::AxisRangeAggregation::WELLS, "WELLS", "All Wells" ); + addItem( RimSummaryMultiPlot::AxisRangeAggregation::REGIONS, "REGIONS", "All Regions" ); + addItem( RimSummaryMultiPlot::AxisRangeAggregation::REALIZATIONS, "REALIZATIONS", "All Realizations" ); + setDefault( RimSummaryMultiPlot::AxisRangeAggregation::NONE ); +} +} // namespace caf + +CAF_PDM_SOURCE_INIT( RimSummaryMultiPlot, "MultiSummaryPlot" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlot::setLayoutInfo( RimSummaryPlot* summaryPlot, int row, int col ) +{ + m_gridLayoutInfo[summaryPlot] = std::make_pair( row, col ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlot::clearLayoutInfo() +{ + m_gridLayoutInfo.clear(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryMultiPlot::RimSummaryMultiPlot() + : duplicatePlot( this ) +{ + CAF_PDM_InitObject( "Multi Summary Plot", ":/SummaryPlotLight16x16.png" ); + this->setDeletable( true ); + + CAF_PDM_InitField( &m_autoPlotTitle, "AutoPlotTitle", true, "Auto Plot Title" ); + CAF_PDM_InitField( &m_autoSubPlotTitle, "AutoSubPlotTitle", true, "Auto Sub Plot Title" ); + + CAF_PDM_InitField( &m_createPlotDuplicate, "DuplicatePlot", false, "", "", "Duplicate Plot" ); + m_createPlotDuplicate.xmlCapability()->disableIO(); + m_createPlotDuplicate.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); + m_createPlotDuplicate.uiCapability()->setUiIconFromResourceString( ":/Copy.svg" ); + + CAF_PDM_InitField( &m_disableWheelZoom, "DisableWheelZoom", true, "", "", "Disable Mouse Wheel Zooming in Multi Summary Plot" ); + m_disableWheelZoom.xmlCapability()->disableIO(); + m_disableWheelZoom.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); + m_disableWheelZoom.uiCapability()->setUiIconFromResourceString( ":/DisableZoom.png" ); + + CAF_PDM_InitField( &m_appendNextPlot, "AppendNextPlot", false, "", "", "Step Next and Add to New Plot" ); + m_appendNextPlot.xmlCapability()->disableIO(); + m_appendNextPlot.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); + m_appendNextPlot.uiCapability()->setUiIconFromResourceString( ":/AppendNext.png" ); + + CAF_PDM_InitField( &m_appendPrevPlot, "AppendPrevPlot", false, "", "", "Step Previous and Add to New Plot" ); + m_appendPrevPlot.xmlCapability()->disableIO(); + m_appendPrevPlot.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); + m_appendPrevPlot.uiCapability()->setUiIconFromResourceString( ":/AppendPrev.png" ); + + CAF_PDM_InitField( &m_appendNextCurve, "AppendNextCurve", false, "", "", "Step Next and Add Curve to Plot" ); + m_appendNextCurve.xmlCapability()->disableIO(); + m_appendNextCurve.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); + m_appendNextCurve.uiCapability()->setUiIconFromResourceString( ":/AppendNextCurve.png" ); + + CAF_PDM_InitField( &m_appendPrevCurve, "AppendPrevCurve", false, "", "", "Step Previous and Add Curve to Plot" ); + m_appendPrevCurve.xmlCapability()->disableIO(); + m_appendPrevCurve.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); + m_appendPrevCurve.uiCapability()->setUiIconFromResourceString( ":/AppendPrevCurve.png" ); + + CAF_PDM_InitField( &m_linkSubPlotAxes, "LinkSubPlotAxes", true, "Link Sub Plot Axes" ); + CAF_PDM_InitField( &m_linkTimeAxis, "LinkTimeAxis", true, "Link Time Axis" ); + CAF_PDM_InitField( &m_autoAdjustAppearance, "AutoAdjustAppearance", true, "Auto Adjust Appearance" ); + + CAF_PDM_InitFieldNoDefault( &m_axisRangeAggregation, "AxisRangeAggregation", "Axis Range Control" ); + + CAF_PDM_InitField( &m_hidePlotsWithValuesBelow, "HidePlotsWithValuesBelow", false, "" ); + m_hidePlotsWithValuesBelow.xmlCapability()->disableIO(); + m_hidePlotsWithValuesBelow.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); + + CAF_PDM_InitField( &m_plotFilterYAxisThreshold, "PlotFilterYAxisThreshold", 0.0, "Y-Axis Filter Threshold" ); + + CAF_PDM_InitFieldNoDefault( &m_sourceStepping, "SourceStepping", "" ); + + m_sourceStepping = new RimSummaryPlotSourceStepping; + m_sourceStepping->setSourceSteppingType( RimSummaryDataSourceStepping::Axis::Y_AXIS ); + m_sourceStepping->setSourceSteppingObject( this ); + m_sourceStepping.uiCapability()->setUiTreeHidden( true ); + m_sourceStepping.uiCapability()->setUiTreeChildrenHidden( true ); + m_sourceStepping.xmlCapability()->disableIO(); + + CAF_PDM_InitFieldNoDefault( &m_defaultStepDimension, "DefaultStepDimension", "Default Step Dimension" ); + m_defaultStepDimension = RimSummaryDataSourceStepping::SourceSteppingDimension::VECTOR; + m_defaultStepDimension.uiCapability()->setUiHidden( true ); + + m_nameHelper = std::make_unique(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryMultiPlot::~RimSummaryMultiPlot() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlot::addPlot( RimPlot* plot ) +{ + auto* sumPlot = dynamic_cast( plot ); + CVF_ASSERT( sumPlot != nullptr ); + if ( sumPlot ) + { + RimMultiPlot::addPlot( plot ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlot::insertPlot( RimPlot* plot, size_t index ) +{ + auto* sumPlot = dynamic_cast( plot ); + CVF_ASSERT( sumPlot != nullptr ); + if ( sumPlot ) + { + sumPlot->axisChanged.connect( this, &RimSummaryMultiPlot::onSubPlotAxisChanged ); + sumPlot->curvesChanged.connect( this, &RimSummaryMultiPlot::onSubPlotChanged ); + + bool isMinMaxOverridden = m_axisRangeAggregation() != AxisRangeAggregation::NONE; + setOverriddenFlagsForPlot( sumPlot, isMinMaxOverridden, m_autoAdjustAppearance() ); + + RimMultiPlot::insertPlot( plot, index ); + } + + if ( summaryPlots().size() == 1 ) m_disableWheelZoom = false; + if ( summaryPlots().size() == 2 ) m_disableWheelZoom = true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlot::handleDroppedObjects( const std::vector& objects ) +{ + if ( objects.empty() ) return; + + std::vector addresses; + std::vector addressCollections; + std::vector cases; + + for ( auto o : objects ) + { + auto address = dynamic_cast( o ); + if ( address ) addresses.push_back( address ); + + auto adrColl = dynamic_cast( o ); + if ( adrColl ) + { + if ( objects.size() == 1 && adrColl->isFolder() ) + { + // If a folder is selected, return all sub items in folder + auto childObjects = adrColl->subFolders(); + addressCollections.insert( addressCollections.end(), childObjects.begin(), childObjects.end() ); + } + else + addressCollections.push_back( adrColl ); + } + + auto summaryCase = dynamic_cast( o ); + if ( summaryCase ) cases.push_back( summaryCase ); + } + + RicAppendSummaryPlotsForSummaryAddressesFeature::appendPlotsForAddresses( this, addresses ); + RicAppendSummaryPlotsForObjectsFeature::appendPlots( this, addressCollections ); + RicAppendSummaryPlotsForSummaryCasesFeature::appendPlotsForCases( this, cases ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlot::removePlot( RimPlot* plot ) +{ + auto* sumPlot = dynamic_cast( plot ); + CVF_ASSERT( sumPlot != nullptr ); + if ( sumPlot ) + { + RimMultiPlot::removePlot( plot ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlot::removePlotNoUpdate( RimPlot* plot ) +{ + auto* sumPlot = dynamic_cast( plot ); + CVF_ASSERT( sumPlot != nullptr ); + if ( sumPlot ) + { + RimMultiPlot::removePlotNoUpdate( plot ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlot::updateAfterPlotRemove() +{ + onPlotAdditionOrRemoval(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimSummaryMultiPlot::availableAxes() const +{ + return { RimSummaryDataSourceStepping::Axis::X_AXIS }; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimSummaryMultiPlot::curvesForStepping( RimSummaryDataSourceStepping::Axis axis ) const +{ + std::vector curves; + + for ( auto summaryPlot : summaryPlots() ) + { + for ( auto curve : summaryPlot->curvesForStepping( axis ) ) + { + curves.push_back( curve ); + } + } + + return curves; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimSummaryMultiPlot::curveSets() const +{ + std::vector curveSets; + + for ( auto summaryPlot : summaryPlots() ) + { + for ( auto curveSet : summaryPlot->curveSets() ) + { + curveSets.push_back( curveSet ); + } + } + + return curveSets; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimSummaryMultiPlot::allCurves( RimSummaryDataSourceStepping::Axis axis ) const +{ + std::vector curves; + + for ( auto summaryPlot : summaryPlots() ) + { + for ( auto curve : summaryPlot->allCurves( axis ) ) + { + curves.push_back( curve ); + } + } + + return curves; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlot::populateNameHelper( RimSummaryPlotNameHelper* nameHelper ) +{ + nameHelper->clear(); + + std::vector addresses; + std::vector sumCases; + std::vector ensembleCases; + + for ( RimSummaryCurve* curve : allCurves( RimSummaryDataSourceStepping::Axis::Y_AXIS ) ) + { + addresses.push_back( curve->summaryAddressY() ); + sumCases.push_back( curve->summaryCaseY() ); + } + + for ( auto curveSet : curveSets() ) + { + addresses.push_back( curveSet->summaryAddress() ); + ensembleCases.push_back( curveSet->summaryCaseCollection() ); + } + + nameHelper->appendAddresses( addresses ); + nameHelper->setSummaryCases( sumCases ); + nameHelper->setEnsembleCases( ensembleCases ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +{ + auto axesGroup = uiOrdering.addNewGroup( "Axes" ); + axesGroup->add( &m_axisRangeAggregation ); + axesGroup->add( &m_linkSubPlotAxes ); + axesGroup->add( &m_linkTimeAxis ); + axesGroup->add( &m_autoAdjustAppearance ); + + m_linkSubPlotAxes.uiCapability()->setUiReadOnly( m_autoAdjustAppearance() ); + if ( m_autoAdjustAppearance() ) m_linkSubPlotAxes = false; + + auto plotVisibilityFilterGroup = uiOrdering.addNewGroup( "Plot Visibility Filter" ); + plotVisibilityFilterGroup->add( &m_plotFilterYAxisThreshold ); + plotVisibilityFilterGroup->add( &m_hidePlotsWithValuesBelow ); + + auto dataSourceGroup = uiOrdering.addNewGroup( "Data Source" ); + dataSourceGroup->setCollapsedByDefault( true ); + m_sourceStepping()->uiOrdering( uiConfigName, *dataSourceGroup ); + + auto titlesGroup = uiOrdering.addNewGroup( "Main Plot Settings" ); + titlesGroup->setCollapsedByDefault( true ); + titlesGroup->add( &m_autoPlotTitle ); + titlesGroup->add( &m_showPlotWindowTitle ); + titlesGroup->add( &m_plotWindowTitle ); + titlesGroup->add( &m_titleFontSize ); + + auto subPlotSettingsGroup = uiOrdering.addNewGroup( "Sub Plot Settings" ); + subPlotSettingsGroup->setCollapsedByDefault( true ); + subPlotSettingsGroup->add( &m_autoSubPlotTitle ); + subPlotSettingsGroup->add( &m_showIndividualPlotTitles ); + subPlotSettingsGroup->add( &m_subTitleFontSize ); + + auto legendsGroup = uiOrdering.addNewGroup( "Legends" ); + legendsGroup->setCollapsedByDefault( true ); + legendsGroup->add( &m_showPlotLegends ); + legendsGroup->add( &m_plotLegendsHorizontal ); + legendsGroup->add( &m_legendFontSize ); + + uiOrdering.skipRemainingFields( true ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField, + const QVariant& oldValue, + const QVariant& newValue ) +{ + if ( changedField == &m_autoPlotTitle || changedField == &m_autoSubPlotTitle ) + { + onLoadDataAndUpdate(); + updateLayout(); + } + else if ( changedField == &m_linkTimeAxis ) + { + auto plots = summaryPlots(); + if ( !plots.empty() ) + { + syncTimeAxisRanges( plots.front() ); + } + } + else if ( changedField == &m_linkSubPlotAxes || changedField == &m_axisRangeAggregation || + changedField == &m_linkTimeAxis ) + { + syncAxisRanges(); + + setOverriddenFlag(); + } + else if ( changedField == &m_hidePlotsWithValuesBelow ) + { + m_hidePlotsWithValuesBelow = false; + updatePlotVisibility(); + } + else if ( changedField == &m_createPlotDuplicate ) + { + m_createPlotDuplicate = false; + duplicate(); + } + else if ( changedField == &m_appendNextPlot ) + { + m_appendNextPlot = false; + int stepDirection = 1; + appendSubPlotByStepping( stepDirection ); + } + else if ( changedField == &m_appendPrevPlot ) + { + m_appendPrevPlot = false; + int stepDirection = -1; + appendSubPlotByStepping( stepDirection ); + } + else if ( changedField == &m_appendNextCurve ) + { + m_appendNextCurve = false; + int stepDirection = 1; + appendCurveByStepping( stepDirection ); + } + else if ( changedField == &m_appendPrevCurve ) + { + m_appendPrevCurve = false; + int stepDirection = -1; + appendCurveByStepping( stepDirection ); + } + else if ( changedField == &m_autoAdjustAppearance ) + { + checkAndApplyAutoAppearance(); + setOverriddenFlag(); + } + else + { + RimMultiPlot::fieldChangedByUi( changedField, oldValue, newValue ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlot::defineEditorAttribute( const caf::PdmFieldHandle* field, + QString uiConfigName, + caf::PdmUiEditorAttribute* attribute ) +{ + if ( &m_hidePlotsWithValuesBelow == field ) + { + auto attrib = dynamic_cast( attribute ); + if ( attrib ) + { + attrib->m_buttonText = "Apply Filter"; + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlot::updatePlotWindowTitle() +{ + if ( m_autoPlotTitle ) + { + populateNameHelper( m_nameHelper.get() ); + + auto title = m_nameHelper->plotTitle(); + + if ( title.isEmpty() ) + { + auto proj = RimProject::current(); + auto collections = proj->mainPlotCollection()->summaryMultiPlotCollection(); + + size_t index = 0; + for ( auto p : collections->multiPlots() ) + { + index++; + if ( p == this ) break; + } + + title = QString( "Plot %1" ).arg( index ); + } + + setMultiPlotTitle( title ); + } + + if ( m_autoSubPlotTitle ) + { + for ( auto plot : summaryPlots() ) + { + auto subPlotNameHelper = plot->plotTitleHelper(); + + // Disable auto plot title, as this is required to be able to include the information in the multi plot + // title + plot->enableAutoPlotTitle( false ); + + auto plotName = subPlotNameHelper->aggregatedPlotTitle( *m_nameHelper ); + plot->setPlotTitleVisible( true ); + plot->setDescription( plotName ); + plot->updatePlotTitle(); + } + + if ( !m_viewer.isNull() ) m_viewer->scheduleTitleUpdate(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RimSummaryNameHelper* RimSummaryMultiPlot::nameHelper() const +{ + return m_nameHelper.get(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlot::setAutoPlotTitle( bool enable ) +{ + m_autoPlotTitle = enable; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlot::setAutoSubPlotTitle( bool enable ) +{ + m_autoSubPlotTitle = enable; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimSummaryMultiPlot::summaryPlots() const +{ + std::vector typedPlots; + + for ( auto plot : plots() ) + { + auto summaryPlot = dynamic_cast( plot ); + if ( summaryPlot ) typedPlots.push_back( summaryPlot ); + } + + return typedPlots; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimSummaryMultiPlot::visibleSummaryPlots() const +{ + std::vector visiblePlots; + + for ( auto plot : summaryPlots() ) + { + if ( plot->showWindow() ) visiblePlots.push_back( plot ); + } + + return visiblePlots; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimSummaryMultiPlot::fieldsToShowInToolbar() +{ + std::vector toolBarFields; + + toolBarFields.push_back( &m_disableWheelZoom ); + + auto& sourceObject = m_sourceStepping(); + if ( sourceObject ) + { + auto fields = sourceObject->fieldsToShowInToolbar(); + toolBarFields.insert( std::end( toolBarFields ), std::begin( fields ), std::end( fields ) ); + } + + toolBarFields.push_back( &m_appendPrevPlot ); + toolBarFields.push_back( &m_appendNextPlot ); + + toolBarFields.push_back( &m_appendPrevCurve ); + toolBarFields.push_back( &m_appendNextCurve ); + + toolBarFields.push_back( &m_createPlotDuplicate ); + + auto multiFields = RimMultiPlot::fieldsToShowInToolbar(); + toolBarFields.insert( std::end( toolBarFields ), std::begin( multiFields ), std::end( multiFields ) ); + + return toolBarFields; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryMultiPlot::handleGlobalKeyEvent( QKeyEvent* keyEvent ) +{ + if ( !RimSummaryPlotControls::handleKeyEvents( m_sourceStepping(), keyEvent ) ) + { + if ( isMouseCursorInsidePlot() ) + { + if ( keyEvent->key() == Qt::Key_PageUp ) + { + m_viewer->goToPrevPage(); + return true; + } + else if ( keyEvent->key() == Qt::Key_PageDown ) + { + m_viewer->goToNextPage(); + return true; + } + } + } + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryMultiPlot::handleGlobalWheelEvent( QWheelEvent* wheelEvent ) +{ + if ( m_disableWheelZoom ) + { + if ( isMouseCursorInsidePlot() ) + { + if ( wheelEvent->angleDelta().y() > 0 ) + { + m_viewer->goToPrevPage(); + } + else if ( wheelEvent->angleDelta().y() < 0 ) + { + m_viewer->goToNextPage(); + } + + return true; + } + } + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlot::initAfterRead() +{ + RimMultiPlot::initAfterRead(); + + for ( auto plot : summaryPlots() ) + { + plot->axisChanged.connect( this, &RimSummaryMultiPlot::onSubPlotAxisChanged ); + plot->curvesChanged.connect( this, &RimSummaryMultiPlot::onSubPlotChanged ); + } + updateStepDimensionFromDefault(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlot::onLoadDataAndUpdate() +{ + RimMultiPlot::onLoadDataAndUpdate(); + updatePlotWindowTitle(); + + checkAndApplyAutoAppearance(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlot::zoomAll() +{ + // Reset zoom to make sure the complete range for min/max is available + RimMultiPlot::zoomAll(); + + syncAxisRanges(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlot::setDefaultRangeAggregationSteppingDimension() +{ + RiaSummaryAddressAnalyzer analyzer; + + for ( auto p : summaryPlots() ) + { + auto addresses = RimSummaryAddressModifier::createEclipseSummaryAddress( p ); + analyzer.appendAddresses( addresses ); + } + + auto rangeAggregation = AxisRangeAggregation::NONE; + if ( analyzer.quantities().size() == 1 && summaryPlots().size() > 1 ) + { + // Many plots, single summary vector + rangeAggregation = AxisRangeAggregation::SUB_PLOTS; + } + + if ( !analyzer.wellNames().empty() ) + { + rangeAggregation = AxisRangeAggregation::WELLS; + } + else if ( !analyzer.regionNumbers().empty() ) + { + rangeAggregation = AxisRangeAggregation::REGIONS; + } + + auto stepDimension = RimSummaryDataSourceStepping::SourceSteppingDimension::VECTOR; + if ( analyzer.wellNames().size() == 1 ) + { + stepDimension = RimSummaryDataSourceStepping::SourceSteppingDimension::WELL; + } + else if ( analyzer.groupNames().size() == 1 ) + { + stepDimension = RimSummaryDataSourceStepping::SourceSteppingDimension::GROUP; + } + else if ( analyzer.regionNumbers().size() == 1 ) + { + stepDimension = RimSummaryDataSourceStepping::SourceSteppingDimension::REGION; + } + else if ( analyzer.aquifers().size() == 1 ) + { + stepDimension = RimSummaryDataSourceStepping::SourceSteppingDimension::AQUIFER; + } + else if ( analyzer.blocks().size() == 1 ) + { + stepDimension = RimSummaryDataSourceStepping::SourceSteppingDimension::BLOCK; + } + + m_axisRangeAggregation = rangeAggregation; + m_sourceStepping->setStepDimension( stepDimension ); + + setOverriddenFlag(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlot::checkAndApplyAutoAppearance() +{ + if ( m_autoAdjustAppearance ) + { + analyzePlotsAndAdjustAppearanceSettings(); + syncAxisRanges(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlot::syncAxisRanges() +{ + if ( m_axisRangeAggregation() == AxisRangeAggregation::NONE ) + { + return; + } + + // Reset zoom to make sure the complete range for min/max is available + RimMultiPlot::zoomAllYAxes(); + + if ( m_axisRangeAggregation() == AxisRangeAggregation::SUB_PLOTS ) + { + std::map> axisRanges; + + // gather current min/max values for each category (axis label) + for ( auto plot : summaryPlots() ) + { + for ( auto axis : plot->plotYAxes() ) + { + double minVal = axis->visibleRangeMin(); + double maxVal = axis->visibleRangeMax(); + if ( axis->isAxisInverted() ) std::swap( minVal, maxVal ); + + if ( axisRanges.count( axis->plotAxisType() ) == 0 ) + { + axisRanges[axis->plotAxisType()] = std::make_pair( minVal, maxVal ); + } + else + { + auto& [currentMin, currentMax] = axisRanges[axis->plotAxisType()]; + axisRanges[axis->plotAxisType()] = + std::make_pair( std::min( currentMin, minVal ), std::max( currentMax, maxVal ) ); + } + } + } + + // set all plots to use the global min/max values for each category + for ( auto plot : summaryPlots() ) + { + for ( auto axis : plot->plotYAxes() ) + { + auto [minVal, maxVal] = axisRanges[axis->plotAxisType()]; + if ( axis->isAxisInverted() ) std::swap( minVal, maxVal ); + axis->setAutoZoom( false ); + axis->setVisibleRangeMin( minVal ); + axis->setVisibleRangeMax( maxVal ); + } + + plot->updateAxes(); + } + } + else + { + computeAggregatedAxisRange(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlot::syncTimeAxisRanges( RimSummaryPlot* summaryPlot ) +{ + if ( m_linkTimeAxis ) + { + for ( auto plot : summaryPlots() ) + { + if ( plot != summaryPlot ) + { + plot->copyAxisPropertiesFromOther( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, *summaryPlot ); + plot->updateAll(); + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlot::computeAggregatedAxisRange() +{ + auto readValues = []( RimSummaryCase* summaryCase, RifEclipseSummaryAddress addr ) { + std::vector values; + if ( summaryCase && summaryCase->summaryReader() ) + { + RifSummaryReaderInterface* reader = summaryCase->summaryReader(); + reader->values( addr, &values ); + } + + return values; + }; + + auto findMinMaxForSummaryCase = [readValues]( RimSummaryCase* summaryCase, RifEclipseSummaryAddress addr ) { + auto values = readValues( summaryCase, addr ); + if ( values.empty() ) return std::make_pair( HUGE_VAL, -HUGE_VAL ); + + auto minMaxPair = std::minmax_element( values.begin(), values.end() ); + double caseMinimum = *minMaxPair.first; + double caseMaximum = *minMaxPair.second; + + return std::make_pair( caseMinimum, caseMaximum ); + }; + + auto summaryCasesForCurve = []( RimSummaryCurve* curve, AxisRangeAggregation axisRangeAggregation ) { + std::vector summaryCases; + + if ( axisRangeAggregation == AxisRangeAggregation::REALIZATIONS ) + { + if ( curve->summaryCaseY() ) + { + auto ensemble = curve->summaryCaseY()->ensemble(); + if ( ensemble ) + { + summaryCases = ensemble->allSummaryCases(); + } + else + { + summaryCases.push_back( curve->summaryCaseY() ); + } + } + } + else if ( axisRangeAggregation == AxisRangeAggregation::WELLS || + axisRangeAggregation == AxisRangeAggregation::REGIONS ) + { + // Use only the current summary case when aggregation across wells/regions + summaryCases.push_back( curve->summaryCaseY() ); + } + + return summaryCases; + }; + + auto addressesForCurve = []( RimSummaryCurve* curve, AxisRangeAggregation axisRangeAggregation ) { + std::vector addresses; + + if ( axisRangeAggregation == AxisRangeAggregation::REALIZATIONS ) + { + RifEclipseSummaryAddress addr = RifEclipseSummaryAddress::fieldAddress( curve->summaryAddressY().vectorName() ); + addresses = { addr }; + } + else if ( axisRangeAggregation == AxisRangeAggregation::WELLS || + axisRangeAggregation == AxisRangeAggregation::REGIONS ) + { + RiaSummaryAddressAnalyzer fallbackAnalyzer; + RiaSummaryAddressAnalyzer* analyzer = nullptr; + + if ( curve->summaryCaseY() ) + { + auto ensemble = curve->summaryCaseY()->ensemble(); + if ( ensemble ) + { + analyzer = ensemble->addressAnalyzer(); + } + else + { + fallbackAnalyzer.appendAddresses( curve->summaryCaseY()->summaryReader()->allResultAddresses() ); + analyzer = &fallbackAnalyzer; + } + } + + if ( analyzer ) + { + if ( axisRangeAggregation == AxisRangeAggregation::WELLS ) + { + for ( const auto& wellName : analyzer->wellNames() ) + { + addresses.push_back( + RifEclipseSummaryAddress::wellAddress( curve->summaryAddressY().vectorName(), wellName ) ); + } + } + + if ( axisRangeAggregation == AxisRangeAggregation::REGIONS ) + { + for ( auto regionNumber : analyzer->regionNumbers() ) + { + addresses.push_back( RifEclipseSummaryAddress::regionAddress( curve->summaryAddressY().vectorName(), + regionNumber ) ); + } + } + } + } + + return addresses; + }; + + auto findMinMaxForAddressesInSummaryCases = + [findMinMaxForSummaryCase]( const std::vector& addresses, + const std::vector& summaryCases ) { + double minimum = HUGE_VAL; + double maximum = -HUGE_VAL; + for ( auto summaryCase : summaryCases ) + { + for ( const auto& addr : addresses ) + { + auto [caseMinimum, caseMaximum] = findMinMaxForSummaryCase( summaryCase, addr ); + minimum = std::min( minimum, caseMinimum ); + maximum = std::max( maximum, caseMaximum ); + } + } + + return std::make_pair( minimum, maximum ); + }; + + // gather current min/max values for each category (axis label) + for ( auto plot : summaryPlots() ) + { + std::map> axisRanges; + + for ( auto axis : plot->plotYAxes() ) + { + for ( auto curve : plot->summaryCurves() ) + { + if ( curve->axisY() == axis->plotAxisType() ) + { + std::vector summaryCases = summaryCasesForCurve( curve, m_axisRangeAggregation() ); + std::vector addresses = addressesForCurve( curve, m_axisRangeAggregation() ); + + auto [minimum, maximum] = findMinMaxForAddressesInSummaryCases( addresses, summaryCases ); + + if ( axisRanges.count( axis->plotAxisType() ) == 0 ) + { + axisRanges[axis->plotAxisType()] = std::make_pair( minimum, maximum ); + } + else + { + auto& [currentMin, currentMax] = axisRanges[axis->plotAxisType()]; + axisRanges[axis->plotAxisType()] = + std::make_pair( std::min( currentMin, minimum ), std::max( currentMax, maximum ) ); + } + } + } + + for ( auto curveSet : plot->curveSets() ) + { + if ( !curveSet->summaryCaseCollection() ) continue; + + if ( curveSet->axisY() == axis->plotAxisType() ) + { + double minimum( std::numeric_limits::infinity() ); + double maximum( -std::numeric_limits::infinity() ); + + auto curves = curveSet->curves(); + if ( !curves.empty() ) + { + // TODO: Use analyzer as input to addressesForCurve instead of curve + + auto curve = curves.front(); + + std::vector addresses = + addressesForCurve( curve, m_axisRangeAggregation() ); + + for ( const auto& adr : addresses ) + { + auto [min, max] = curveSet->summaryCaseCollection()->minMax( adr ); + + minimum = std::min( min, minimum ); + maximum = std::max( max, maximum ); + } + } + + if ( axisRanges.count( axis->plotAxisType() ) == 0 ) + { + axisRanges[axis->plotAxisType()] = std::make_pair( minimum, maximum ); + } + else + { + auto& [currentMin, currentMax] = axisRanges[axis->plotAxisType()]; + axisRanges[axis->plotAxisType()] = + std::make_pair( std::min( currentMin, minimum ), std::max( currentMax, maximum ) ); + } + } + } + } + + // set all plots to use the global min/max values for each category + for ( auto axis : plot->plotYAxes() ) + { + auto [minVal, maxVal] = axisRanges[axis->plotAxisType()]; + if ( RiaDefines::isVertical( axis->plotAxisType().axis() ) && !std::isinf( minVal ) && !std::isinf( maxVal ) ) + { + axis->setAutoZoom( false ); + + if ( axis->isAxisInverted() ) std::swap( minVal, maxVal ); + + if ( !axis->isLogarithmicScaleEnabled() ) + { + int maxMajorTickIntervalCount = 8; + double stepSize = 0.0; + QwtLinearScaleEngine scaleEngine; + scaleEngine.autoScale( maxMajorTickIntervalCount, minVal, maxVal, stepSize ); + } + + axis->setVisibleRangeMin( minVal ); + axis->setVisibleRangeMax( maxVal ); + } + } + + plot->updateAxes(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlot::updatePlotVisibility() +{ + auto hasValuesAboveLimit = []( RimSummaryPlot* plot, double limit ) { + for ( auto curve : plot->summaryAndEnsembleCurves() ) + { + auto address = curve->valuesY(); + auto maxValue = std::max_element( address.begin(), address.end() ); + + if ( *maxValue > limit ) return true; + } + + return false; + }; + + for ( auto plot : summaryPlots() ) + { + bool hasValueAboveLimit = hasValuesAboveLimit( plot, m_plotFilterYAxisThreshold ); + plot->setShowWindow( hasValueAboveLimit ); + } + + updateLayout(); + + if ( !m_viewer.isNull() ) m_viewer->scheduleUpdate(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlot::setOverriddenFlag() +{ + bool isMinMaxOverridden = m_axisRangeAggregation() != AxisRangeAggregation::NONE; + for ( auto p : summaryPlots() ) + { + setOverriddenFlagsForPlot( p, isMinMaxOverridden, m_autoAdjustAppearance() ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlot::setOverriddenFlagsForPlot( RimSummaryPlot* summaryPlot, + bool isMinMaxOverridden, + bool isAppearanceOverridden ) +{ + for ( auto plotAxis : summaryPlot->plotAxes() ) + { + plotAxis->setAppearanceOverridden( isAppearanceOverridden ); + auto plotAxProp = dynamic_cast( plotAxis ); + if ( plotAxProp ) + { + plotAxProp->setMinMaxOverridden( isMinMaxOverridden ); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlot::summaryPlotItemInfos( QList* optionInfos ) const +{ + for ( RimSummaryPlot* plot : summaryPlots() ) + { + QString displayName; + + if ( plot && plot->userDescriptionField() && plot->userDescriptionField() ) + { + displayName = plot->userDescriptionField()->uiCapability()->uiValue().toString(); + } + + optionInfos->push_back( caf::PdmOptionItemInfo( displayName, plot, false, plot->uiCapability()->uiIconProvider() ) ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlot::duplicate() +{ + duplicatePlot.send( this ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlot::analyzePlotsAndAdjustAppearanceSettings() +{ + RiaSummaryAddressAnalyzer analyzer; + + for ( auto p : summaryPlots() ) + { + auto addresses = RimSummaryAddressModifier::createEclipseSummaryAddress( p ); + analyzer.appendAddresses( addresses ); + } + + bool hasOnlyOneQuantity = analyzer.quantities().size() == 1; + + for ( auto p : summaryPlots() ) + { + auto timeAxisProp = p->timeAxisProperties(); + + if ( columnCount() < 3 ) + timeAxisProp->setMajorTickmarkCount( RimPlotAxisProperties::LegendTickmarkCount::TICKMARK_DEFAULT ); + else + timeAxisProp->setMajorTickmarkCount( RimPlotAxisProperties::LegendTickmarkCount::TICKMARK_FEW ); + + for ( RimPlotAxisPropertiesInterface* axisInterface : p->plotYAxes() ) + { + auto axisProp = dynamic_cast( axisInterface ); + + if ( !axisProp ) continue; + + if ( rowsPerPage() == 1 ) + axisProp->setMajorTickmarkCount( RimPlotAxisPropertiesInterface::LegendTickmarkCount::TICKMARK_DEFAULT ); + else + axisProp->setMajorTickmarkCount( RimPlotAxisPropertiesInterface::LegendTickmarkCount::TICKMARK_FEW ); + + axisProp->computeAndSetScaleFactor(); + + if ( hasOnlyOneQuantity ) + { + // Disable sub plot linking to be able to configure individually + setSubPlotAxesLinked( false ); + + auto [row, col] = gridLayoutInfoForSubPlot( p ); + if ( col == 0 ) + axisProp->setShowUnitText( true ); + else + axisProp->setShowUnitText( false ); + } + } + + p->updateAxes(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlot::makeSureIsVisible( RimSummaryPlot* summaryPlot ) +{ + if ( summaryPlot->plotWidget() && !m_viewer.isNull() ) m_viewer->scrollToPlot( summaryPlot->plotWidget() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlot::setSubPlotAxesLinked( bool enable ) +{ + m_linkSubPlotAxes = enable; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryMultiPlot::isSubPlotAxesLinked() const +{ + return m_linkSubPlotAxes(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryMultiPlot::isTimeAxisLinked() const +{ + return m_linkTimeAxis(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair RimSummaryMultiPlot::gridLayoutInfoForSubPlot( RimSummaryPlot* summaryPlot ) const +{ + auto it = m_gridLayoutInfo.find( summaryPlot ); + if ( it != m_gridLayoutInfo.end() ) return it->second; + + return { -1, -1 }; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlot::onSubPlotChanged( const caf::SignalEmitter* emitter ) +{ + updatePlotWindowTitle(); + applyPlotWindowTitleToWidgets(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlot::onSubPlotAxisChanged( const caf::SignalEmitter* emitter, RimSummaryPlot* summaryPlot ) +{ + syncTimeAxisRanges( summaryPlot ); + + if ( !m_linkSubPlotAxes() ) + { + syncAxisRanges(); + return; + } + + for ( auto plot : summaryPlots() ) + { + if ( plot != summaryPlot ) + { + plot->copyMatchingAxisPropertiesFromOther( *summaryPlot ); + plot->updateAll(); + } + } + + syncAxisRanges(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QWidget* RimSummaryMultiPlot::createViewWidget( QWidget* mainWindowParent ) +{ + if ( m_viewer.isNull() ) + { + m_viewer = new RiuSummaryMultiPlotBook( this, mainWindowParent ); + } + recreatePlotWidgets(); + + return m_viewer; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlot::appendSubPlotByStepping( int direction ) +{ + if ( summaryPlots().empty() ) return; + + // find matching plots + std::vector plots = m_sourceStepping->plotsMatchingStepSettings( summaryPlots() ); + if ( plots.empty() ) return; + + // duplicate them + auto newPlots = RicSummaryPlotBuilder::duplicatePlots( plots ); + if ( newPlots.empty() ) return; + + for ( auto plot : newPlots ) + { + RimSummaryPlot* newPlot = dynamic_cast( plot ); + if ( newPlot == nullptr ) continue; + + addPlot( newPlot ); + newPlot->resolveReferencesRecursively(); + + if ( m_sourceStepping()->stepDimension() == RimSummaryDataSourceStepping::SourceSteppingDimension::SUMMARY_CASE ) + { + RimSummaryCase* newCase = m_sourceStepping()->stepCase( direction ); + for ( auto curve : newPlot->allCurves( RimSummaryDataSourceStepping::Axis::Y_AXIS ) ) + { + curve->setSummaryCaseX( newCase ); + curve->setSummaryCaseY( newCase ); + } + } + else if ( m_sourceStepping()->stepDimension() == RimSummaryDataSourceStepping::SourceSteppingDimension::ENSEMBLE ) + { + RimSummaryCaseCollection* newEnsemble = m_sourceStepping()->stepEnsemble( direction ); + for ( auto curveSet : newPlot->curveSets() ) + { + curveSet->setSummaryCaseCollection( newEnsemble ); + } + } + else + { + auto mods = RimSummaryAddressModifier::createAddressModifiersForPlot( newPlot ); + for ( auto& mod : mods ) + { + auto modifiedAdr = m_sourceStepping()->stepAddress( mod.address(), direction ); + mod.setAddress( modifiedAdr ); + } + } + } + + loadDataAndUpdate(); + updateConnectedEditors(); + + RiuPlotMainWindowTools::selectAsCurrentItem( newPlots.back(), true ); + + updateSourceStepper(); + RiuPlotMainWindowTools::refreshToolbars(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlot::appendCurveByStepping( int direction ) +{ + for ( auto plot : summaryPlots() ) + { + std::vector addresses; + + for ( auto curve : plot->allCurves( RimSummaryDataSourceStepping::Axis::Y_AXIS ) ) + { + auto address = curve->summaryAddressY(); + auto sumCase = curve->summaryCaseY(); + int sumCaseId = sumCase->caseId(); + if ( m_sourceStepping()->stepDimension() == RimSummaryDataSourceStepping::SourceSteppingDimension::SUMMARY_CASE ) + { + auto nextSumCase = m_sourceStepping->stepCase( direction ); + if ( nextSumCase ) sumCaseId = nextSumCase->caseId(); + } + else + { + address = m_sourceStepping->stepAddress( address, direction ); + } + addresses.push_back( RimSummaryAddress::wrapFileReaderAddress( address, sumCaseId ) ); + } + + for ( auto curveSet : plot->curveSets() ) + { + auto address = curveSet->summaryAddress(); + auto sumEns = curveSet->summaryCaseCollection(); + int sumEnsId = sumEns->ensembleId(); + if ( m_sourceStepping()->stepDimension() == RimSummaryDataSourceStepping::SourceSteppingDimension::ENSEMBLE ) + { + auto nextEns = m_sourceStepping->stepEnsemble( direction ); + if ( nextEns ) sumEnsId = nextEns->ensembleId(); + } + else + { + address = m_sourceStepping->stepAddress( address, direction ); + } + addresses.push_back( RimSummaryAddress::wrapFileReaderAddress( address, -1, sumEnsId ) ); + } + + plot->handleDroppedObjects( addresses ); + + for ( auto adr : addresses ) + { + delete adr; + } + } + + m_sourceStepping->updateStepIndex( direction ); + + RiuPlotMainWindowTools::refreshToolbars(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlot::updateSourceStepper() +{ + if ( summaryPlots().empty() ) return; + + RimSummaryPlot* plot = summaryPlots().back(); + + auto sourceStepper = plot->sourceStepper(); + if ( sourceStepper == nullptr ) return; + + m_sourceStepping->syncWithStepper( sourceStepper ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlot::keepVisiblePageAfterUpdate( bool keepPage ) +{ + if ( !m_viewer ) return; + + if ( keepPage ) m_viewer->keepCurrentPageAfterUpdate(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlot::storeStepDimensionFromToolbar() +{ + m_defaultStepDimension = m_sourceStepping->stepDimension(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlot::updateStepDimensionFromDefault() +{ + m_sourceStepping->setStepDimension( m_defaultStepDimension() ); +} diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.h new file mode 100644 index 0000000000..5871d3851e --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.h @@ -0,0 +1,176 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RimMultiPlot.h" +#include "RimSummaryDataSourceStepping.h" + +#include "cafPdmChildField.h" +#include "cafPdmObject.h" +#include "cafPdmPtrArrayField.h" +#include "cafPdmUiItem.h" +#include "cafSignal.h" + +#include + +#include + +class RimSummaryPlot; +class RimSummaryPlotSourceStepping; +class RimSummaryPlotNameHelper; +class RimSummaryNameHelper; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimSummaryMultiPlot : public RimMultiPlot, public RimSummaryDataSourceStepping +{ + CAF_PDM_HEADER_INIT; + +public: + caf::Signal duplicatePlot; + +public: + enum class AxisRangeAggregation + { + NONE, + SUB_PLOTS, + REGIONS, + WELLS, + REALIZATIONS + }; + + RimSummaryMultiPlot(); + ~RimSummaryMultiPlot() override; + + const RimSummaryNameHelper* nameHelper() const; + + void setLayoutInfo( RimSummaryPlot* summaryPlot, int row, int col ); + void clearLayoutInfo(); + + void setAutoPlotTitle( bool enable ); + void setAutoSubPlotTitle( bool enable ); + + std::vector availableAxes() const override; + std::vector curvesForStepping( RimSummaryDataSourceStepping::Axis axis ) const override; + std::vector curveSets() const override; + std::vector allCurves( RimSummaryDataSourceStepping::Axis axis ) const override; + + void addPlot( RimPlot* plot ) override; + void insertPlot( RimPlot* plot, size_t index ) override; + void removePlot( RimPlot* plot ) override; + + void removePlotNoUpdate( RimPlot* plot ) override; + void updateAfterPlotRemove() override; + void updatePlotWindowTitle() override; + + std::vector fieldsToShowInToolbar() override; + + void syncAxisRanges(); + void syncTimeAxisRanges( RimSummaryPlot* summaryPlot ); + + void handleDroppedObjects( const std::vector& objects ); + + void summaryPlotItemInfos( QList* optionInfos ) const; + + std::vector summaryPlots() const; + std::vector visibleSummaryPlots() const; + + void makeSureIsVisible( RimSummaryPlot* plot ); + + void setSubPlotAxesLinked( bool enable ); + bool isSubPlotAxesLinked() const; + bool isTimeAxisLinked() const; + + std::pair gridLayoutInfoForSubPlot( RimSummaryPlot* summaryPlot ) const; + + void zoomAll() override; + + void setDefaultRangeAggregationSteppingDimension(); + void checkAndApplyAutoAppearance(); + + void keepVisiblePageAfterUpdate( bool keepPage ); + + void storeStepDimensionFromToolbar(); + void updateStepDimensionFromDefault(); + +protected: + bool handleGlobalKeyEvent( QKeyEvent* keyEvent ) override; + bool handleGlobalWheelEvent( QWheelEvent* wheelEvent ) override; + + void initAfterRead() override; + void onLoadDataAndUpdate() override; + + QWidget* createViewWidget( QWidget* mainWindowParent ) override; + +private: + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + void defineEditorAttribute( const caf::PdmFieldHandle* field, + QString uiConfigName, + caf::PdmUiEditorAttribute* attribute ) override; + + void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; + void populateNameHelper( RimSummaryPlotNameHelper* nameHelper ); + + void computeAggregatedAxisRange(); + void updateSourceStepper(); + + void updatePlotVisibility(); + void setOverriddenFlag(); + void setOverriddenFlagsForPlot( RimSummaryPlot* summaryPlot, bool isMinMaxOverridden, bool isAppearanceOverridden ); + + void duplicate(); + + void appendSubPlotByStepping( int direction ); + void appendCurveByStepping( int direction ); + + void analyzePlotsAndAdjustAppearanceSettings(); + + void onSubPlotChanged( const caf::SignalEmitter* emitter ); + void onSubPlotAxisChanged( const caf::SignalEmitter* emitter, RimSummaryPlot* summaryPlot ); + +private: + caf::PdmField m_autoPlotTitle; + caf::PdmField m_autoSubPlotTitle; + caf::PdmField m_disableWheelZoom; + caf::PdmField m_createPlotDuplicate; + caf::PdmField m_linkSubPlotAxes; + caf::PdmField m_linkTimeAxis; + caf::PdmField m_autoAdjustAppearance; + + caf::PdmField m_hidePlotsWithValuesBelow; + caf::PdmField m_plotFilterYAxisThreshold; + + caf::PdmField m_appendNextPlot; + caf::PdmField m_appendPrevPlot; + + caf::PdmField m_appendNextCurve; + caf::PdmField m_appendPrevCurve; + + caf::PdmField> m_defaultStepDimension; + + caf::PdmField> m_axisRangeAggregation; + + caf::PdmChildField m_sourceStepping; + + std::unique_ptr m_nameHelper; + + std::map> m_gridLayoutInfo; +}; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlotCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlotCollection.cpp new file mode 100644 index 0000000000..018e4fe6d4 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlotCollection.cpp @@ -0,0 +1,192 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// +#include "RimSummaryMultiPlotCollection.h" + +#include "RimProject.h" +#include "RimSummaryMultiPlot.h" +#include "RimSummaryPlot.h" + +#include "RiuPlotMainWindowTools.h" + +#include "cafPdmFieldReorderCapability.h" +#include "cafPdmUiTreeOrdering.h" + +CAF_PDM_SOURCE_INIT( RimSummaryMultiPlotCollection, "RimSummaryMultiPlotCollection" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryMultiPlotCollection::RimSummaryMultiPlotCollection() +{ + CAF_PDM_InitObject( "Summary Plots", ":/MultiPlot16x16.png" ); + + CAF_PDM_InitFieldNoDefault( &m_summaryMultiPlots, "MultiSummaryPlots", "Summary Plots" ); + m_summaryMultiPlots.uiCapability()->setUiTreeHidden( true ); + caf::PdmFieldReorderCapability::addToField( &m_summaryMultiPlots ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryMultiPlotCollection::~RimSummaryMultiPlotCollection() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlotCollection::initAfterRead() +{ + for ( auto& plot : m_summaryMultiPlots ) + { + plot->duplicatePlot.connect( this, &RimSummaryMultiPlotCollection::onDuplicatePlot ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlotCollection::deleteAllPlots() +{ + m_summaryMultiPlots.deleteChildren(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimSummaryMultiPlotCollection::multiPlots() const +{ + return m_summaryMultiPlots.children(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlotCollection::addSummaryMultiPlot( RimSummaryMultiPlot* plot ) +{ + m_summaryMultiPlots().push_back( plot ); + plot->duplicatePlot.connect( this, &RimSummaryMultiPlotCollection::onDuplicatePlot ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlotCollection::removePlotNoUpdate( RimSummaryMultiPlot* plot ) +{ + if ( plot == nullptr ) return; + m_summaryMultiPlots().removeChild( plot ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlotCollection::loadDataAndUpdateAllPlots() +{ + for ( const auto& p : m_summaryMultiPlots.children() ) + p->loadDataAndUpdate(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RimSummaryMultiPlotCollection::plotCount() const +{ + return m_summaryMultiPlots.size(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlotCollection::onDuplicatePlot( const caf::SignalEmitter* emitter, RimSummaryMultiPlot* plotToDuplicate ) +{ + duplicatePlot( plotToDuplicate ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlotCollection::onRefreshTree( const caf::SignalEmitter* emitter, RimSummaryMultiPlot* plotRequesting ) +{ + if ( !plotRequesting ) return; + updateConnectedEditors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlotCollection::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, + QString uiConfigName /*= ""*/ ) +{ + for ( auto& plot : m_summaryMultiPlots() ) + { + uiTreeOrdering.add( plot ); + } + uiTreeOrdering.skipRemainingChildren( true ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlotCollection::summaryPlotItemInfos( QList* optionInfos ) const +{ + for ( RimSummaryMultiPlot* multiPlot : multiPlots() ) + { + for ( RimSummaryPlot* plot : multiPlot->summaryPlots() ) + { + QString displayName = plot->userDescriptionField()->uiCapability()->uiValue().toString(); + optionInfos->push_back( + caf::PdmOptionItemInfo( displayName, plot, false, plot->uiCapability()->uiIconProvider() ) ); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlotCollection::duplicatePlot( RimSummaryMultiPlot* plotToDuplicate ) +{ + if ( !plotToDuplicate ) return; + + auto plotCopy = dynamic_cast( + plotToDuplicate->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); + + addSummaryMultiPlot( plotCopy ); + + plotCopy->resolveReferencesRecursively(); + plotCopy->initAfterReadRecursively(); + plotCopy->updateAllRequiredEditors(); + plotCopy->loadDataAndUpdate(); + + updateConnectedEditors(); + + RiuPlotMainWindowTools::selectAsCurrentItem( plotCopy, true ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlotCollection::updateSummaryNameHasChanged() +{ + for ( RimSummaryMultiPlot* multiPlot : multiPlots() ) + { + for ( RimSummaryPlot* plot : multiPlot->summaryPlots() ) + { + plot->updateCaseNameHasChanged(); + } + } +} diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlotCollection.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlotCollection.h new file mode 100644 index 0000000000..b207d09a6f --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlotCollection.h @@ -0,0 +1,65 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// +#pragma once + +#include "RimAbstractPlotCollection.h" + +#include "cafPdmChildArrayField.h" +#include "cafPdmObject.h" +#include "cafPdmUiItem.h" + +#include + +class RimSummaryMultiPlot; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimSummaryMultiPlotCollection : public caf::PdmObject, public RimPlotCollection +{ + CAF_PDM_HEADER_INIT; + +public: + RimSummaryMultiPlotCollection(); + ~RimSummaryMultiPlotCollection() override; + + void deleteAllPlots() override; + void loadDataAndUpdateAllPlots() override; + size_t plotCount() const override; + + std::vector multiPlots() const; + + void addSummaryMultiPlot( RimSummaryMultiPlot* plot ); + void summaryPlotItemInfos( QList* optionInfos ) const; + void duplicatePlot( RimSummaryMultiPlot* plotToDuplicate ); + void removePlotNoUpdate( RimSummaryMultiPlot* plotToRemove ); + + void updateSummaryNameHasChanged(); + +protected: + void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; + + void onDuplicatePlot( const caf::SignalEmitter* emitter, RimSummaryMultiPlot* plotToDuplicate ); + void onRefreshTree( const caf::SignalEmitter* emitter, RimSummaryMultiPlot* plotRequesting ); + + void initAfterRead() override; + +private: + caf::PdmChildArrayField m_summaryMultiPlots; +}; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryNameHelper.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryNameHelper.cpp new file mode 100644 index 0000000000..9a68079002 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryNameHelper.cpp @@ -0,0 +1,90 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimSummaryNameHelper.h" + +#include "RiuSummaryQuantityNameInfoProvider.h" +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimSummaryNameHelper::aggregatedPlotTitle( const RimSummaryNameHelper& other ) const +{ + QString title; + + auto titleCaseName = this->caseName(); + if ( !other.isCaseInTitle() && !titleCaseName.isEmpty() ) + { + if ( !title.isEmpty() ) title += ", "; + + title += titleCaseName; + } + + auto wellName = this->titleWellName(); + if ( !other.isWellNameInTitle() && !wellName.empty() ) + { + if ( !title.isEmpty() ) title += ", "; + title += QString::fromStdString( wellName ); + } + + auto groupName = this->titleGroupName(); + if ( !other.isGroupNameInTitle() && !groupName.empty() ) + { + if ( !title.isEmpty() ) title += ", "; + title += QString::fromStdString( groupName ); + } + + auto region = this->titleRegion(); + if ( !other.isRegionInTitle() && !region.empty() ) + { + if ( !title.isEmpty() ) title += ", "; + title += "Region : " + QString::fromStdString( region ); + } + + auto block = this->titleBlock(); + if ( !other.isBlockInTitle() && !block.empty() ) + { + if ( !title.isEmpty() ) title += ", "; + title += "Block : " + QString::fromStdString( block ); + } + + auto segment = this->titleSegment(); + if ( !other.isSegmentInTitle() && !segment.empty() ) + { + if ( !title.isEmpty() ) title += ", "; + title += "Segment : " + QString::fromStdString( segment ); + } + + auto completion = this->titleCompletion(); + if ( !other.isCompletionInTitle() && !completion.empty() ) + { + if ( !title.isEmpty() ) title += ", "; + title += "Completion : " + QString::fromStdString( completion ); + } + + auto vectorName = this->titleVectorName(); + if ( ( other.titleVectorName() != this->titleVectorName() ) && ( !vectorName.empty() ) ) + { + if ( !title.isEmpty() ) title += ", "; + title += QString::fromStdString( + RiuSummaryQuantityNameInfoProvider::instance()->longNameFromVectorName( vectorName, true ) ); + } + + return title; +} diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryNameHelper.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryNameHelper.h new file mode 100644 index 0000000000..9343c23ba2 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryNameHelper.h @@ -0,0 +1,58 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include + +class QString; + +class RimSummaryCase; +class RimSummaryCaseCollection; +class RifEclipseSummaryAddress; + +//================================================================================================== +// +//================================================================================================== +class RimSummaryNameHelper +{ +public: + virtual QString plotTitle() const = 0; + + QString aggregatedPlotTitle( const RimSummaryNameHelper& summaryMultiPlotNameHelper ) const; + + virtual bool isPlotDisplayingSingleVectorName() const = 0; + virtual bool isWellNameInTitle() const = 0; + virtual bool isGroupNameInTitle() const = 0; + virtual bool isRegionInTitle() const = 0; + virtual bool isCaseInTitle() const = 0; + virtual bool isBlockInTitle() const = 0; + virtual bool isSegmentInTitle() const = 0; + virtual bool isCompletionInTitle() const = 0; + + virtual QString caseName() const = 0; + + virtual std::string titleVectorName() const = 0; + virtual std::string titleWellName() const = 0; + virtual std::string titleGroupName() const = 0; + virtual std::string titleRegion() const = 0; + virtual std::string titleBlock() const = 0; + virtual std::string titleSegment() const = 0; + virtual std::string titleCompletion() const = 0; +}; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryObservedDataFile.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryObservedDataFile.cpp index 7d79aa3bee..48e443e367 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryObservedDataFile.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryObservedDataFile.cpp @@ -31,7 +31,7 @@ CAF_PDM_SOURCE_INIT( RimSummaryObservedDataFile, "SummaryObservedDataFile" ); //-------------------------------------------------------------------------------------------------- RimSummaryObservedDataFile::RimSummaryObservedDataFile() { - CAF_PDM_InitObject( "Observed data file", ":/ObservedDataFile16x16.png", "", "" ); + CAF_PDM_InitObject( "Observed data file", ":/ObservedDataFile16x16.png" ); m_summaryHeaderFilename.uiCapability()->setUiName( "File" ); } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index 23ce5e6053..e8c9f5805d 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -19,11 +19,21 @@ #include "RimSummaryPlot.h" #include "RiaColorTables.h" +#include "RiaColorTools.h" +#include "RiaDefines.h" #include "RiaFieldHandleTools.h" -#include "RiaSummaryCurveAnalyzer.h" +#include "RiaPlotDefines.h" +#include "RiaPreferences.h" +#include "RiaPreferencesSummary.h" +#include "RiaRegressionTestRunner.h" +#include "RiaStdStringTools.h" +#include "RiaSummaryAddressAnalyzer.h" #include "RiaSummaryCurveDefinition.h" #include "RiaSummaryTools.h" #include "RiaTimeHistoryCurveResampler.h" + +#include "RifReaderEclipseSummary.h" + #include "RicfCommandObject.h" #include "SummaryPlotCommands/RicSummaryPlotEditorUi.h" @@ -35,22 +45,32 @@ #include "RimEnsembleCurveSetCollection.h" #include "RimGridTimeHistoryCurve.h" #include "RimMultiPlot.h" +#include "RimPlotAxisLogRangeCalculator.h" #include "RimPlotAxisProperties.h" #include "RimProject.h" +#include "RimSummaryAddress.h" +#include "RimSummaryAddressCollection.h" #include "RimSummaryCase.h" #include "RimSummaryCurve.h" #include "RimSummaryCurveCollection.h" -#include "RimSummaryCurveFilter.h" +#include "RimSummaryCurvesData.h" #include "RimSummaryPlotAxisFormatter.h" -#include "RimSummaryPlotCollection.h" +#include "RimSummaryPlotControls.h" #include "RimSummaryPlotFilterTextCurveSetEditor.h" #include "RimSummaryPlotNameHelper.h" #include "RimSummaryTimeAxisProperties.h" +#include "RiuPlotAxis.h" #include "RiuPlotMainWindowTools.h" +#include "RiuQwtPlotCurve.h" +#include "RiuQwtPlotItem.h" #include "RiuSummaryQwtPlot.h" #include "RiuTreeViewEventFilter.h" +#ifdef USE_QTCHARTS +#include "RiuSummaryQtChartsPlot.h" +#endif + #include "cvfColor3.h" #include "cafPdmFieldScriptingCapability.h" @@ -58,12 +78,10 @@ #include "cafPdmUiTreeOrdering.h" #include "cafSelectionManager.h" -#include "qwt_abstract_legend.h" -#include "qwt_legend.h" +#include "qwt_plot.h" #include "qwt_plot_curve.h" -#include "qwt_plot_renderer.h" #include "qwt_plot_textlabel.h" -#include "qwt_scale_engine.h" +#include "qwt_text.h" #include #include @@ -79,184 +97,101 @@ CAF_PDM_SOURCE_INIT( RimSummaryPlot, "SummaryPlot" ); //-------------------------------------------------------------------------------------------------- -/// Internal types +/// //-------------------------------------------------------------------------------------------------- -enum class ResampleAlgorithm -{ - NONE, - DATA_DECIDES, - PERIOD_END -}; - -struct CurveData -{ - QString name; - RifEclipseSummaryAddress address; - std::vector values; -}; - -class CurvesData +RimSummaryPlot::RimSummaryPlot( bool isCrossPlot ) + : RimPlot() + , m_isCrossPlot( isCrossPlot ) + , curvesChanged( this ) + , axisChanged( this ) + , m_isValid( true ) { -public: - CurvesData() - : resamplePeriod( RiaQDateTimeTools::DateTimePeriod::NONE ) - { - } - void clear() - { - caseIds.clear(); - timeSteps.clear(); - allCurveData.clear(); - } + CAF_PDM_InitScriptableObject( "Summary Plot", ":/SummaryPlotLight16x16.png", "", "A Summary Plot" ); - void addCurveData( const QString& caseName, - const QString& ensembleName, - const std::vector& curvetimeSteps, - const CurveData& curveData ) - { - QString caseId = createCaseId( caseName, ensembleName ); - size_t existingCaseIndex = findCaseIndexForCaseId( caseId, curvetimeSteps.size() ); + CAF_PDM_InitScriptableField( &m_useAutoPlotTitle, "IsUsingAutoName", true, "Auto Title" ); + CAF_PDM_InitScriptableField( &m_description, "PlotDescription", QString( "Summary Plot" ), "Name" ); + CAF_PDM_InitScriptableField( &m_normalizeCurveYValues, "normalizeCurveYValues", false, "Normalize all curves" ); +#ifdef USE_QTCHARTS + bool useQtChart = RiaPreferences::current()->useQtChartsAsDefaultPlotType(); + CAF_PDM_InitScriptableField( &m_useQtChartsPlot, "useQtChartsPlot", useQtChart, "Use Qt Charts" ); + m_useQtChartsPlot.uiCapability()->setUiHidden( true ); +#endif + CAF_PDM_InitFieldNoDefault( &m_summaryCurveCollection, "SummaryCurveCollection", "" ); + m_summaryCurveCollection.uiCapability()->setUiTreeHidden( true ); + m_summaryCurveCollection = new RimSummaryCurveCollection; + m_summaryCurveCollection->curvesChanged.connect( this, &RimSummaryPlot::onCurveCollectionChanged ); - if ( existingCaseIndex == cvf::UNDEFINED_SIZE_T ) - { - caseIds.push_back( caseId ); - timeSteps.push_back( curvetimeSteps ); - allCurveData.push_back( { curveData } ); - } - else - { - CVF_ASSERT( timeSteps[existingCaseIndex].size() == curveData.values.size() ); + CAF_PDM_InitFieldNoDefault( &m_ensembleCurveSetCollection, "EnsembleCurveSetCollection", "" ); + m_ensembleCurveSetCollection.uiCapability()->setUiTreeHidden( true ); + m_ensembleCurveSetCollection = new RimEnsembleCurveSetCollection(); - allCurveData[existingCaseIndex].push_back( curveData ); - } - } + CAF_PDM_InitFieldNoDefault( &m_gridTimeHistoryCurves, "GridTimeHistoryCurves", "" ); + m_gridTimeHistoryCurves.uiCapability()->setUiTreeHidden( true ); - void addCurveDataNoSearch( const QString& caseName, - const QString& ensembleName, - const std::vector& curvetimeSteps, - const std::vector& curveDataVector ) - { - QString caseId = createCaseId( caseName, ensembleName ); + CAF_PDM_InitFieldNoDefault( &m_asciiDataCurves, "AsciiDataCurves", "" ); + m_asciiDataCurves.uiCapability()->setUiTreeHidden( true ); - caseIds.push_back( caseId ); - timeSteps.push_back( curvetimeSteps ); - allCurveData.push_back( curveDataVector ); - } + CAF_PDM_InitFieldNoDefault( &m_axisProperties, "AxisProperties", "Axes", ":/Axes16x16.png" ); -private: - size_t findCaseIndexForCaseId( const QString& caseId, size_t timeStepCount ) + if ( m_isCrossPlot ) { - size_t casePosInList = cvf::UNDEFINED_SIZE_T; - - for ( size_t i = 0; i < caseIds.size(); i++ ) - { - if ( caseId == caseIds[i] && timeSteps[i].size() == timeStepCount ) casePosInList = i; - } - - return casePosInList; + addNewAxisProperties( RiuPlotAxis::defaultBottom(), "Bottom" ); } - - QString createCaseId( const QString& caseName, const QString& ensembleName ) + else { - QString caseId = caseName; - if ( !ensembleName.isEmpty() ) caseId += QString( " (%1)" ).arg( ensembleName ); + auto* timeAxisProperties = new RimSummaryTimeAxisProperties; + timeAxisProperties->settingsChanged.connect( this, &RimSummaryPlot::axisSettingsChanged ); - return caseId; + m_axisProperties.push_back( timeAxisProperties ); } -public: - RiaQDateTimeTools::DateTimePeriod resamplePeriod; - std::vector caseIds; - std::vector> timeSteps; - std::vector> allCurveData; -}; - -//-------------------------------------------------------------------------------------------------- -/// Internal functions -//-------------------------------------------------------------------------------------------------- -enum SummaryCurveType -{ - CURVE_TYPE_GRID = 0x1, - CURVE_TYPE_OBSERVED = 0x2 -}; - -void populateSummaryCurvesData( std::vector curves, SummaryCurveType curveType, CurvesData* curvesData ); -void populateTimeHistoryCurvesData( std::vector curves, CurvesData* curvesData ); -void populateAsciiDataCurvesData( std::vector curves, CurvesData* curvesData ); - -void prepareCaseCurvesForExport( RiaQDateTimeTools::DateTimePeriod period, - ResampleAlgorithm algorithm, - const CurvesData& inputCurvesData, - CurvesData* resultCurvesData ); - -void appendToExportDataForCase( QString& out, const std::vector& timeSteps, const std::vector& curveData ); -void appendToExportData( QString& out, const std::vector& curvesData, bool showTimeAsLongString ); -CurvesData concatCurvesData( const std::vector& curvesData ); + auto leftAxis = addNewAxisProperties( RiuPlotAxis::defaultLeft(), "Left" ); + leftAxis->setAlwaysRequired( true ); -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimSummaryPlot::RimSummaryPlot() - : RimPlot() -{ - CAF_PDM_InitScriptableObject( "Summary Plot", ":/SummaryPlotLight16x16.png", "", "A Summary Plot" ); + auto rightAxis = addNewAxisProperties( RiuPlotAxis::defaultRight(), "Right" ); + rightAxis->setAlwaysRequired( true ); - CAF_PDM_InitScriptableField( &m_useAutoPlotTitle, "IsUsingAutoName", true, "Auto Title", "", "", "" ); - CAF_PDM_InitScriptableField( &m_description, "PlotDescription", QString( "Summary Plot" ), "Name", "", "", "" ); - CAF_PDM_InitScriptableField( &m_normalizeCurveYValues, "normalizeCurveYValues", false, "Normalize all curves", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_textCurveSetEditor, "SummaryPlotFilterTextCurveSetEditor", "Text Filter Curve Creator" ); + m_textCurveSetEditor.uiCapability()->setUiTreeHidden( true ); + m_textCurveSetEditor = new RimSummaryPlotFilterTextCurveSetEditor; - CAF_PDM_InitFieldNoDefault( &m_summaryCurveCollection, "SummaryCurveCollection", "", "", "", "" ); - m_summaryCurveCollection.uiCapability()->setUiTreeHidden( true ); - m_summaryCurveCollection = new RimSummaryCurveCollection; - m_summaryCurveCollection->curvesChanged.connect( this, &RimSummaryPlot::onCurveCollectionChanged ); + m_nameHelperAllCurves = std::make_unique(); - CAF_PDM_InitFieldNoDefault( &m_ensembleCurveSetCollection, "EnsembleCurveSetCollection", "", "", "", "" ); - m_ensembleCurveSetCollection.uiCapability()->setUiTreeHidden( true ); - m_ensembleCurveSetCollection = new RimEnsembleCurveSetCollection(); + CAF_PDM_InitFieldNoDefault( &m_sourceStepping, "SourceStepping", "" ); + m_sourceStepping = new RimSummaryPlotSourceStepping; + m_sourceStepping->setSourceSteppingType( RimSummaryDataSourceStepping::Axis::Y_AXIS ); + m_sourceStepping->setSourceSteppingObject( this ); + m_sourceStepping.uiCapability()->setUiTreeHidden( true ); + m_sourceStepping.uiCapability()->setUiTreeChildrenHidden( true ); + m_sourceStepping.xmlCapability()->disableIO(); - CAF_PDM_InitFieldNoDefault( &m_gridTimeHistoryCurves, "GridTimeHistoryCurves", "", "", "", "" ); - m_gridTimeHistoryCurves.uiCapability()->setUiTreeHidden( true ); + CAF_PDM_InitFieldNoDefault( &m_fallbackPlotName, "AlternateName", "AlternateName" ); + m_fallbackPlotName.uiCapability()->setUiReadOnly( true ); + m_fallbackPlotName.uiCapability()->setUiHidden( true ); + m_fallbackPlotName.xmlCapability()->disableIO(); - CAF_PDM_InitFieldNoDefault( &m_asciiDataCurves, "AsciiDataCurves", "", "", "", "" ); - m_asciiDataCurves.uiCapability()->setUiTreeHidden( true ); + setPlotInfoLabel( "Filters Active" ); - CAF_PDM_InitFieldNoDefault( &m_leftYAxisProperties, "LeftYAxisProperties", "Left Y Axis", "", "", "" ); - m_leftYAxisProperties.uiCapability()->setUiTreeHidden( true ); - m_leftYAxisProperties = new RimPlotAxisProperties; - m_leftYAxisProperties->setNameAndAxis( "Left Y-Axis", QwtPlot::yLeft ); - - CAF_PDM_InitFieldNoDefault( &m_rightYAxisProperties, "RightYAxisProperties", "Right Y Axis", "", "", "" ); - m_rightYAxisProperties.uiCapability()->setUiTreeHidden( true ); - m_rightYAxisProperties = new RimPlotAxisProperties; - m_rightYAxisProperties->setNameAndAxis( "Right Y-Axis", QwtPlot::yRight ); - - CAF_PDM_InitFieldNoDefault( &m_bottomAxisProperties, "BottomAxisProperties", "Bottom X Axis", "", "", "" ); - m_bottomAxisProperties.uiCapability()->setUiTreeHidden( true ); - m_bottomAxisProperties = new RimPlotAxisProperties; - m_bottomAxisProperties->setNameAndAxis( "Bottom X-Axis", QwtPlot::xBottom ); - - connectAxisSignals( m_leftYAxisProperties() ); - connectAxisSignals( m_rightYAxisProperties() ); - connectAxisSignals( m_bottomAxisProperties() ); - - CAF_PDM_InitFieldNoDefault( &m_timeAxisProperties, "TimeAxisProperties", "Time Axis", "", "", "" ); - m_timeAxisProperties.uiCapability()->setUiTreeHidden( true ); - m_timeAxisProperties = new RimSummaryTimeAxisProperties; - - CAF_PDM_InitFieldNoDefault( &m_textCurveSetEditor, - "SummaryPlotFilterTextCurveSetEditor", - "Text Filter Curve Creator", - "", - "", - "" ); - m_textCurveSetEditor.uiCapability()->setUiTreeHidden( true ); - m_textCurveSetEditor = new RimSummaryPlotFilterTextCurveSetEditor; + // Obsolete axis fields + CAF_PDM_InitFieldNoDefault( &m_leftYAxisProperties_OBSOLETE, "LeftYAxisProperties", "Left Y Axis" ); + m_leftYAxisProperties_OBSOLETE.uiCapability()->setUiTreeHidden( true ); + m_leftYAxisProperties_OBSOLETE.xmlCapability()->setIOWritable( false ); + m_leftYAxisProperties_OBSOLETE = new RimPlotAxisProperties; - m_isCrossPlot = false; + CAF_PDM_InitFieldNoDefault( &m_rightYAxisProperties_OBSOLETE, "RightYAxisProperties", "Right Y Axis" ); + m_rightYAxisProperties_OBSOLETE.uiCapability()->setUiTreeHidden( true ); + m_rightYAxisProperties_OBSOLETE.xmlCapability()->setIOWritable( false ); + m_rightYAxisProperties_OBSOLETE = new RimPlotAxisProperties; - m_nameHelperAllCurves.reset( new RimSummaryPlotNameHelper ); + CAF_PDM_InitFieldNoDefault( &m_bottomAxisProperties_OBSOLETE, "BottomAxisProperties", "Bottom X Axis" ); + m_bottomAxisProperties_OBSOLETE.uiCapability()->setUiTreeHidden( true ); + m_bottomAxisProperties_OBSOLETE.xmlCapability()->setIOWritable( false ); + m_bottomAxisProperties_OBSOLETE = new RimPlotAxisProperties; - setPlotInfoLabel( "Filters Active" ); + CAF_PDM_InitFieldNoDefault( &m_timeAxisProperties_OBSOLETE, "TimeAxisProperties", "Time Axis" ); + m_timeAxisProperties_OBSOLETE.uiCapability()->setUiTreeHidden( true ); + m_timeAxisProperties_OBSOLETE.xmlCapability()->setIOWritable( false ); + m_timeAxisProperties_OBSOLETE = new RimSummaryTimeAxisProperties; } //-------------------------------------------------------------------------------------------------- @@ -264,9 +199,11 @@ RimSummaryPlot::RimSummaryPlot() //-------------------------------------------------------------------------------------------------- RimSummaryPlot::~RimSummaryPlot() { + m_isValid = false; + removeMdiWindowFromMdiArea(); - cleanupBeforeClose(); + deletePlotCurvesAndPlotWidget(); delete m_summaryCurveCollection; delete m_ensembleCurveSetCollection; @@ -277,38 +214,41 @@ RimSummaryPlot::~RimSummaryPlot() //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::updateAxes() { - updateYAxis( RiaDefines::PlotAxis::PLOT_AXIS_LEFT ); - updateYAxis( RiaDefines::PlotAxis::PLOT_AXIS_RIGHT ); + updateAxis( RiaDefines::PlotAxis::PLOT_AXIS_LEFT ); + updateAxis( RiaDefines::PlotAxis::PLOT_AXIS_RIGHT ); - if ( m_timeAxisProperties() && m_plotWidget ) + if ( timeAxisProperties() && plotWidget() ) { - m_plotWidget->updateAnnotationObjects( m_timeAxisProperties() ); + m_summaryPlot->updateAnnotationObjects( timeAxisProperties() ); } - if ( m_leftYAxisProperties() && m_plotWidget ) + + RimPlotAxisPropertiesInterface* leftYAxisProperties = axisPropertiesForPlotAxis( RiuPlotAxis::defaultLeft() ); + if ( leftYAxisProperties && plotWidget() ) { - m_plotWidget->updateAnnotationObjects( m_leftYAxisProperties() ); + m_summaryPlot->updateAnnotationObjects( leftYAxisProperties ); } if ( m_isCrossPlot ) { - updateBottomXAxis(); + updateAxis( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM ); } else { - updateTimeAxis(); + updateTimeAxis( timeAxisProperties() ); } - m_plotWidget->scheduleReplot(); - - updateZoomInQwt(); + updateZoomInParentPlot(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimSummaryPlot::isLogarithmicScaleEnabled( RiaDefines::PlotAxis plotAxis ) const +bool RimSummaryPlot::isLogarithmicScaleEnabled( RiuPlotAxis plotAxis ) const { - return yAxisPropertiesLeftOrRight( plotAxis )->isLogarithmicScaleEnabled(); + auto axisProperties = axisPropertiesForPlotAxis( plotAxis ); + if ( !axisProperties ) return false; + + return axisProperties->isLogarithmicScaleEnabled(); } //-------------------------------------------------------------------------------------------------- @@ -316,7 +256,14 @@ bool RimSummaryPlot::isLogarithmicScaleEnabled( RiaDefines::PlotAxis plotAxis ) //-------------------------------------------------------------------------------------------------- RimSummaryTimeAxisProperties* RimSummaryPlot::timeAxisProperties() { - return m_timeAxisProperties(); + // Find the first time axis (which is correct since there is only one). + for ( const auto& ap : m_axisProperties ) + { + auto* timeAxis = dynamic_cast( ap.p() ); + if ( timeAxis ) return timeAxis; + } + + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -337,12 +284,11 @@ time_t RimSummaryPlot::firstTimeStepOfFirstCurve() } } - if ( firstCurve && firstCurve->timeStepsY().size() > 0 ) + if ( firstCurve && !firstCurve->timeStepsY().empty() ) { return firstCurve->timeStepsY()[0]; } - else - return time_t( 0 ); + return time_t( 0 ); } //-------------------------------------------------------------------------------------------------- @@ -350,15 +296,17 @@ time_t RimSummaryPlot::firstTimeStepOfFirstCurve() //-------------------------------------------------------------------------------------------------- QWidget* RimSummaryPlot::viewWidget() { - return m_plotWidget; + return plotWidget(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuQwtPlotWidget* RimSummaryPlot::viewer() +RiuPlotWidget* RimSummaryPlot::plotWidget() { - return m_plotWidget; + if ( !m_summaryPlot ) return nullptr; + + return m_summaryPlot->plotWidget(); } //-------------------------------------------------------------------------------------------------- @@ -366,64 +314,35 @@ RiuQwtPlotWidget* RimSummaryPlot::viewer() //-------------------------------------------------------------------------------------------------- QString RimSummaryPlot::asciiDataForPlotExport() const { - return asciiDataForSummaryPlotExport( RiaQDateTimeTools::DateTimePeriod::YEAR, false ); + return asciiDataForSummaryPlotExport( RiaDefines::DateTimePeriod::YEAR, false ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimSummaryPlot::asciiDataForSummaryPlotExport( RiaQDateTimeTools::DateTimePeriod resamplingPeriod, - bool showTimeAsLongString ) const +QString RimSummaryPlot::asciiDataForSummaryPlotExport( RiaDefines::DateTimePeriod resamplingPeriod, + bool showTimeAsLongString ) const { - QString out; - - // Summary and time history (from grid) curves - { - std::vector curves; - this->descendantsIncludingThisOfType( curves ); - - CurvesData summaryCurvesGridData; - CurvesData summaryCurvesObsData; - populateSummaryCurvesData( curves, CURVE_TYPE_GRID, &summaryCurvesGridData ); - populateSummaryCurvesData( curves, CURVE_TYPE_OBSERVED, &summaryCurvesObsData ); - - CurvesData timeHistoryCurvesData; - populateTimeHistoryCurvesData( m_gridTimeHistoryCurves.childObjects(), &timeHistoryCurvesData ); - - // Export observed data - appendToExportData( out, { summaryCurvesObsData }, showTimeAsLongString ); - - std::vector exportData( 2 ); - - // Summary grid data for export - prepareCaseCurvesForExport( resamplingPeriod, ResampleAlgorithm::DATA_DECIDES, summaryCurvesGridData, &exportData[0] ); - - // Time history data for export - prepareCaseCurvesForExport( resamplingPeriod, ResampleAlgorithm::PERIOD_END, timeHistoryCurvesData, &exportData[1] ); - - // Export resampled summary and time history data - appendToExportData( out, exportData, showTimeAsLongString ); - } + std::vector curves; + this->descendantsIncludingThisOfType( curves ); - // Pasted observed data - { - CurvesData asciiCurvesData; - populateAsciiDataCurvesData( m_asciiDataCurves.childObjects(), &asciiCurvesData ); + auto gridCurves = m_gridTimeHistoryCurves.children(); + auto asciiCurves = m_asciiDataCurves.children(); - appendToExportData( out, { asciiCurvesData }, showTimeAsLongString ); - } + QString text = + RimSummaryCurvesData::createTextForExport( curves, asciiCurves, gridCurves, resamplingPeriod, showTimeAsLongString ); - return out; + return text; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObject* RimSummaryPlot::findPdmObjectFromQwtCurve( const QwtPlotCurve* qwtCurve ) const +caf::PdmObject* RimSummaryPlot::findPdmObjectFromPlotCurve( const RiuPlotCurve* plotCurve ) const { for ( RimGridTimeHistoryCurve* curve : m_gridTimeHistoryCurves ) { - if ( curve->qwtPlotCurve() == qwtCurve ) + if ( curve->isSameCurve( plotCurve ) ) { return curve; } @@ -431,7 +350,7 @@ caf::PdmObject* RimSummaryPlot::findPdmObjectFromQwtCurve( const QwtPlotCurve* q for ( RimAsciiDataCurve* curve : m_asciiDataCurves ) { - if ( curve->qwtPlotCurve() == qwtCurve ) + if ( curve->isSameCurve( plotCurve ) ) { return curve; } @@ -439,7 +358,7 @@ caf::PdmObject* RimSummaryPlot::findPdmObjectFromQwtCurve( const QwtPlotCurve* q if ( m_summaryCurveCollection ) { - RimSummaryCurve* foundCurve = m_summaryCurveCollection->findRimCurveFromQwtCurve( qwtCurve ); + RimSummaryCurve* foundCurve = m_summaryCurveCollection->findRimCurveFromPlotCurve( plotCurve ); if ( foundCurve ) { @@ -451,7 +370,7 @@ caf::PdmObject* RimSummaryPlot::findPdmObjectFromQwtCurve( const QwtPlotCurve* q if ( m_ensembleCurveSetCollection ) { - RimSummaryCurve* foundCurve = m_ensembleCurveSetCollection->findRimCurveFromQwtCurve( qwtCurve ); + RimSummaryCurve* foundCurve = m_ensembleCurveSetCollection->findRimCurveFromPlotCurve( plotCurve ); if ( foundCurve ) { @@ -464,39 +383,13 @@ caf::PdmObject* RimSummaryPlot::findPdmObjectFromQwtCurve( const QwtPlotCurve* q //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryPlot::onAxisSelected( int axis, bool toggle ) +void RimSummaryPlot::onAxisSelected( RiuPlotAxis axis, bool toggle ) { RiuPlotMainWindowTools::showPlotMainWindow(); - caf::PdmObject* itemToSelect = nullptr; - if ( axis == QwtPlot::yLeft ) - { - itemToSelect = m_leftYAxisProperties; - } - else if ( axis == QwtPlot::yRight ) - { - itemToSelect = m_rightYAxisProperties; - } - else if ( axis == QwtPlot::xBottom ) - { - if ( m_isCrossPlot ) - { - itemToSelect = m_bottomAxisProperties; - } - else - { - itemToSelect = m_timeAxisProperties; - } - } + caf::PdmObject* itemToSelect = axisPropertiesForPlotAxis( axis ); - if ( toggle ) - { - RiuPlotMainWindowTools::toggleItemInSelection( itemToSelect ); - } - else - { - RiuPlotMainWindowTools::selectAsCurrentItem( itemToSelect ); - } + RiuPlotMainWindowTools::selectOrToggleObject( itemToSelect, toggle ); } //-------------------------------------------------------------------------------------------------- @@ -540,6 +433,47 @@ void RimSummaryPlot::moveCurvesToPlot( RimSummaryPlot* plot, const std::vectorupdateStackedCurveData(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimSummaryPlot::curvesForStepping( RimSummaryDataSourceStepping::Axis axis ) const +{ + auto curveForStepping = summaryCurveCollection()->curveForSourceStepping(); + if ( curveForStepping ) + { + return { curveForStepping }; + } + + return summaryCurves(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimSummaryPlot::curveSets() const +{ + return ensembleCurveSetCollection()->curveSets(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimSummaryPlot::allCurves( RimSummaryDataSourceStepping::Axis axis ) const +{ + return summaryCurves(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimSummaryPlot::availableAxes() const +{ + if ( m_isCrossPlot ) + return { RimSummaryDataSourceStepping::Axis::X_AXIS, RimSummaryDataSourceStepping::Axis::Y_AXIS }; + + return { RimSummaryDataSourceStepping::Axis::X_AXIS }; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -599,7 +533,7 @@ RimSummaryCurveCollection* RimSummaryPlot::summaryCurveCollection() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimSummaryPlot::visibleStackedSummaryCurvesForAxis( RiaDefines::PlotAxis plotAxis ) +std::vector RimSummaryPlot::visibleStackedSummaryCurvesForAxis( RiuPlotAxis plotAxis ) { auto visibleCurves = visibleSummaryCurvesForAxis( plotAxis ); @@ -613,42 +547,46 @@ std::vector RimSummaryPlot::visibleStackedSummaryCurvesForAxis return visibleStackedCurves; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RimSummaryPlot::curveSets() const -{ - return ensembleCurveSetCollection()->curveSets(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::updatePlotTitle() { + m_nameHelperAllCurves->clear(); updateNameHelperWithCurveData( m_nameHelperAllCurves.get() ); - if ( m_useAutoPlotTitle ) { m_description = m_nameHelperAllCurves->plotTitle(); } + if ( m_description().isEmpty() ) + { + RimMultiPlot* plotWindow = nullptr; + firstAncestorOrThisOfType( plotWindow ); + + size_t index = 0; + if ( plotWindow ) index = plotWindow->plotIndex( this ); + + QString title = QString( "Sub Plot %1" ).arg( index + 1 ); + m_fallbackPlotName = title; + } + updateCurveNames(); updateMdiWindowTitle(); - if ( m_plotWidget ) + if ( plotWidget() ) { QString plotTitle = description(); - m_plotWidget->setPlotTitle( plotTitle ); - m_plotWidget->setPlotTitleEnabled( m_showPlotTitle && !isSubPlot() ); - m_plotWidget->scheduleReplot(); + plotWidget()->setPlotTitle( plotTitle ); + plotWidget()->setPlotTitleEnabled( m_showPlotTitle && !isSubPlot() ); + scheduleReplotIfVisible(); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const RimSummaryPlotNameHelper* RimSummaryPlot::activePlotTitleHelperAllCurves() const +const RimSummaryNameHelper* RimSummaryPlot::activePlotTitleHelperAllCurves() const { if ( m_useAutoPlotTitle() ) { @@ -661,11 +599,9 @@ const RimSummaryPlotNameHelper* RimSummaryPlot::activePlotTitleHelperAllCurves() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimSummaryPlot::generatedPlotTitleFromAllCurves() const +const RimSummaryNameHelper* RimSummaryPlot::plotTitleHelper() const { - RimSummaryPlotNameHelper nameHelper; - updateNameHelperWithCurveData( &nameHelper ); - return nameHelper.plotTitle(); + return m_nameHelperAllCurves.get(); } //-------------------------------------------------------------------------------------------------- @@ -673,30 +609,58 @@ QString RimSummaryPlot::generatedPlotTitleFromAllCurves() const //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::copyAxisPropertiesFromOther( const RimSummaryPlot& sourceSummaryPlot ) { + for ( auto ap : sourceSummaryPlot.plotAxes() ) { - QString data = - sourceSummaryPlot.yAxisPropertiesLeftOrRight( RiaDefines::PlotAxis::PLOT_AXIS_LEFT )->writeObjectToXmlString(); - yAxisPropertiesLeftOrRight( RiaDefines::PlotAxis::PLOT_AXIS_LEFT ) + QString data = ap->writeObjectToXmlString(); + + axisPropertiesForPlotAxis( ap->plotAxisType() ) ->readObjectFromXmlString( data, caf::PdmDefaultObjectFactory::instance() ); } +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlot::copyAxisPropertiesFromOther( RiaDefines::PlotAxis plotAxisType, const RimSummaryPlot& sourceSummaryPlot ) +{ + for ( auto ap : sourceSummaryPlot.plotAxes() ) { - QString data = - sourceSummaryPlot.yAxisPropertiesLeftOrRight( RiaDefines::PlotAxis::PLOT_AXIS_RIGHT )->writeObjectToXmlString(); - yAxisPropertiesLeftOrRight( RiaDefines::PlotAxis::PLOT_AXIS_RIGHT ) + if ( ap->plotAxisType().axis() != plotAxisType ) continue; + + QString data = ap->writeObjectToXmlString(); + + axisPropertiesForPlotAxis( ap->plotAxisType() ) ->readObjectFromXmlString( data, caf::PdmDefaultObjectFactory::instance() ); } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlot::copyMatchingAxisPropertiesFromOther( const RimSummaryPlot& summaryPlot ) +{ + for ( auto apToCopy : summaryPlot.plotAxes() ) + { + for ( auto ap : plotAxes() ) + { + if ( ap->objectName().compare( apToCopy->objectName() ) == 0 ) + { + QString data = apToCopy->writeObjectToXmlString(); + ap->readObjectFromXmlString( data, caf::PdmDefaultObjectFactory::instance() ); + } + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::updateAll() { - if ( m_plotWidget ) + if ( plotWidget() ) { updatePlotTitle(); - m_plotWidget->updateLegend(); + plotWidget()->updateLegend(); updateAxes(); } } @@ -706,15 +670,20 @@ void RimSummaryPlot::updateAll() //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::updateLegend() { - if ( m_plotWidget ) + if ( plotWidget() ) { - m_plotWidget->setInternalLegendVisible( m_showPlotLegends && !isSubPlot() ); + plotWidget()->setInternalLegendVisible( m_showPlotLegends && !isSubPlot() ); + + for ( auto c : summaryCurves() ) + { + c->updateLegendEntryVisibilityNoPlotUpdate(); + } } reattachAllCurves(); - if ( m_plotWidget ) + if ( plotWidget() ) { - m_plotWidget->updateLegend(); + plotWidget()->updateLegend(); } } @@ -730,7 +699,7 @@ void RimSummaryPlot::setPlotInfoLabel( const QString& label ) font.setBold( true ); qwtText.setFont( font ); - m_plotInfoLabel.reset( new QwtPlotTextLabel() ); + m_plotInfoLabel = std::make_unique(); m_plotInfoLabel->setText( qwtText ); m_plotInfoLabel->setMargin( 10 ); } @@ -740,8 +709,11 @@ void RimSummaryPlot::setPlotInfoLabel( const QString& label ) //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::showPlotInfoLabel( bool show ) { + auto* qwtPlotWidget = dynamic_cast( plotWidget() ); + if ( !qwtPlotWidget ) return; + if ( show ) - m_plotInfoLabel->attach( m_plotWidget ); + m_plotInfoLabel->attach( qwtPlotWidget->qwtPlot() ); else m_plotInfoLabel->detach(); } @@ -797,23 +769,37 @@ size_t RimSummaryPlot::singleColorCurveCount() const //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::applyDefaultCurveAppearances() { - std::set allCurveDefs = this->summaryAndEnsembleCurveDefinitions(); - - RimSummaryCurveAppearanceCalculator curveLookCalc( allCurveDefs ); - - // Summary curves - for ( auto& curve : this->summaryCurves() ) - { - curve->resetAppearance(); - curveLookCalc.setupCurveLook( curve ); - } + applyDefaultCurveAppearances( summaryCurves() ); // Ensemble curve sets int colorIndex = 0; for ( auto& curveSet : this->ensembleCurveSetCollection()->curveSets() ) { if ( curveSet->colorMode() != RimEnsembleCurveSet::ColorMode::SINGLE_COLOR ) continue; - curveSet->setColor( RiaColorTables::summaryCurveDefaultPaletteColors().cycledColor3f( colorIndex++ ) ); + + cvf::Color3f curveColor = + RimSummaryCurveAppearanceCalculator::computeTintedCurveColorForAddress( curveSet->summaryAddress(), + colorIndex++ ); + + auto adr = curveSet->summaryAddress(); + if ( adr.isHistoryVector() ) curveColor = RiaPreferencesSummary::current()->historyCurveContrastColor(); + + curveSet->setColor( curveColor ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlot::applyDefaultCurveAppearances( std::vector curvesToUpdate ) +{ + std::set allCurveDefs = this->summaryAndEnsembleCurveDefinitions(); + RimSummaryCurveAppearanceCalculator curveLookCalc( allCurveDefs ); + + for ( auto& curve : curvesToUpdate ) + { + curve->resetAppearance(); + curveLookCalc.setupCurveLook( curve ); } } @@ -836,142 +822,175 @@ bool RimSummaryPlot::isNormalizationEnabled() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryPlot::updateYAxis( RiaDefines::PlotAxis plotAxis ) +void RimSummaryPlot::updateAxis( RiaDefines::PlotAxis plotAxis ) { - if ( !m_plotWidget ) return; + if ( !plotWidget() ) return; - QwtPlot::Axis qwtAxis = QwtPlot::yLeft; - if ( plotAxis == RiaDefines::PlotAxis::PLOT_AXIS_LEFT ) - { - qwtAxis = QwtPlot::yLeft; - } - else + for ( RimPlotAxisPropertiesInterface* yAxisProperties : m_axisProperties ) { - qwtAxis = QwtPlot::yRight; - } + RiuPlotAxis riuPlotAxis = yAxisProperties->plotAxisType(); + if ( riuPlotAxis.axis() == plotAxis ) + { + auto* axisProperties = dynamic_cast( yAxisProperties ); + if ( axisProperties ) + { + if ( yAxisProperties->isActive() && hasVisibleCurvesForAxis( riuPlotAxis ) ) + { + plotWidget()->enableAxis( riuPlotAxis, true ); + } + else + { + plotWidget()->enableAxis( riuPlotAxis, false ); + } - RimPlotAxisProperties* yAxisProperties = yAxisPropertiesLeftOrRight( plotAxis ); - if ( yAxisProperties->isActive() && hasVisibleCurvesForAxis( plotAxis ) ) - { - m_plotWidget->enableAxis( qwtAxis, true ); + if ( !hasVisibleCurvesForAxis( riuPlotAxis ) ) + { + axisProperties->setNameForUnusedAxis(); + } + else + { + std::set timeHistoryQuantities; - std::set timeHistoryQuantities; + for ( auto c : visibleTimeHistoryCurvesForAxis( riuPlotAxis ) ) + { + timeHistoryQuantities.insert( c->quantityName() ); + } - for ( auto c : visibleTimeHistoryCurvesForAxis( plotAxis ) ) - { - timeHistoryQuantities.insert( c->quantityName() ); - } + std::vector curveDefs; + for ( auto summaryCurve : summaryCurves() ) + { + if ( summaryCurve->axisY() != riuPlotAxis ) continue; - RimSummaryPlotAxisFormatter calc( yAxisProperties, - visibleSummaryCurvesForAxis( plotAxis ), - {}, - visibleAsciiDataCurvesForAxis( plotAxis ), - timeHistoryQuantities ); - calc.applyAxisPropertiesToPlot( m_plotWidget ); - } - else - { - m_plotWidget->enableAxis( qwtAxis, false ); + curveDefs.push_back( summaryCurve->curveDefinitionY() ); + } + + for ( auto curveSet : ensembleCurveSetCollection()->curveSets() ) + { + if ( curveSet->axisY() != riuPlotAxis ) continue; + + RiaSummaryCurveDefinition def( curveSet->summaryCaseCollection(), curveSet->summaryAddress() ); + curveDefs.push_back( def ); + } + + RimSummaryPlotAxisFormatter calc( axisProperties, + {}, + curveDefs, + visibleAsciiDataCurvesForAxis( riuPlotAxis ), + timeHistoryQuantities ); + + calc.applyAxisPropertiesToPlot( plotWidget() ); + } + } + + plotWidget()->enableAxisNumberLabels( riuPlotAxis, axisProperties->showNumbers() ); + + RimSummaryTimeAxisProperties::LegendTickmarkCount tickmarkCountEnum = axisProperties->majorTickmarkCount(); + int maxTickmarkCount = RimPlotAxisPropertiesInterface::tickmarkCountFromEnum( tickmarkCountEnum ); + + plotWidget()->setAutoTickIntervalCounts( riuPlotAxis, maxTickmarkCount, maxTickmarkCount ); + } } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryPlot::updateZoomForAxis( RiaDefines::PlotAxis plotAxis ) +void RimSummaryPlot::updateZoomForAxis( RiuPlotAxis plotAxis ) { - if ( plotAxis == RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM ) + RimPlotAxisPropertiesInterface* yAxisProps = axisPropertiesForPlotAxis( plotAxis ); + if ( !yAxisProps ) return; + + if ( yAxisProps->isAutoZoom() ) { - if ( m_isCrossPlot ) + if ( yAxisProps->isLogarithmicScaleEnabled() ) { - if ( m_bottomAxisProperties->isAutoZoom() ) + plotWidget()->setAxisScaleType( yAxisProps->plotAxisType(), RiuQwtPlotWidget::AxisScaleType::LOGARITHMIC ); + + std::vector plotCurves; + + for ( RimSummaryCurve* c : visibleSummaryCurvesForAxis( plotAxis ) ) { - m_plotWidget->setAxisAutoScale( QwtPlot::xBottom, true ); + plotCurves.push_back( c ); } - else + + for ( RimGridTimeHistoryCurve* c : visibleTimeHistoryCurvesForAxis( plotAxis ) ) { - m_plotWidget->setAxisScale( QwtPlot::xBottom, - m_bottomAxisProperties->visibleRangeMin(), - m_bottomAxisProperties->visibleRangeMax() ); + plotCurves.push_back( c ); } - } - else - { - if ( m_timeAxisProperties->isAutoZoom() ) + + for ( RimAsciiDataCurve* c : visibleAsciiDataCurvesForAxis( plotAxis ) ) { - m_plotWidget->setAxisAutoScale( QwtPlot::xBottom, true ); + plotCurves.push_back( c ); } - else + + double min, max; + RimPlotAxisLogRangeCalculator calc( plotAxis.axis(), plotCurves ); + calc.computeAxisRange( &min, &max ); + + if ( yAxisProps->isAxisInverted() ) { - m_plotWidget->setAxisScale( QwtPlot::xBottom, - m_timeAxisProperties->visibleRangeMin(), - m_timeAxisProperties->visibleRangeMax() ); + std::swap( min, max ); } + + plotWidget()->setAxisScale( yAxisProps->plotAxisType(), min, max ); + } + else if ( ( plotAxis.axis() == RiaDefines::PlotAxis::PLOT_AXIS_LEFT || + plotAxis.axis() == RiaDefines::PlotAxis::PLOT_AXIS_RIGHT ) && + isOnlyWaterCutCurvesVisible( plotAxis ) ) + { + plotWidget()->setAxisScale( yAxisProps->plotAxisType(), 0.0, 1.0 ); + } + else + { + plotWidget()->setAxisAutoScale( yAxisProps->plotAxisType(), true ); } } else { - RimPlotAxisProperties* yAxisProps = yAxisPropertiesLeftOrRight( plotAxis ); + double min = yAxisProps->visibleRangeMin(); + double max = yAxisProps->visibleRangeMax(); + if ( yAxisProps->isAxisInverted() ) std::swap( min, max ); + plotWidget()->setAxisScale( yAxisProps->plotAxisType(), min, max ); + } - if ( yAxisProps->isAutoZoom() ) - { - m_plotWidget->setAxisIsLogarithmic( yAxisProps->qwtPlotAxisType(), yAxisProps->isLogarithmicScaleEnabled ); + plotWidget()->setAxisInverted( yAxisProps->plotAxisType(), yAxisProps->isAxisInverted() ); +} - if ( yAxisProps->isLogarithmicScaleEnabled ) - { - std::vector plotCurves; - - for ( RimSummaryCurve* c : visibleSummaryCurvesForAxis( plotAxis ) ) - { - plotCurves.push_back( c->qwtPlotCurve() ); - } - - for ( RimGridTimeHistoryCurve* c : visibleTimeHistoryCurvesForAxis( plotAxis ) ) - { - plotCurves.push_back( c->qwtPlotCurve() ); - } - - for ( RimAsciiDataCurve* c : visibleAsciiDataCurvesForAxis( plotAxis ) ) - { - plotCurves.push_back( c->qwtPlotCurve() ); - } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryPlot::isOnlyWaterCutCurvesVisible( RiuPlotAxis plotAxis ) +{ + auto curves = visibleSummaryCurvesForAxis( plotAxis ); + if ( curves.empty() ) return false; - double min, max; - RimPlotAxisLogRangeCalculator calc( QwtPlot::yLeft, plotCurves ); - calc.computeAxisRange( &min, &max ); + size_t waterCutCurveCount = 0; + for ( auto c : curves ) + { + auto quantityName = c->summaryAddressY().vectorName(); - if ( yAxisProps->isAxisInverted() ) - { - std::swap( min, max ); - } + if ( RiaStdStringTools::endsWith( quantityName, "WCT" ) ) waterCutCurveCount++; + } - m_plotWidget->setAxisScale( yAxisProps->qwtPlotAxisType(), min, max ); - } - else - { - m_plotWidget->setAxisAutoScale( yAxisProps->qwtPlotAxisType(), true ); - } - } - else - { - m_plotWidget->setAxisScale( yAxisProps->qwtPlotAxisType(), - yAxisProps->visibleRangeMin(), - yAxisProps->visibleRangeMax() ); - } + return ( waterCutCurveCount == curves.size() ); +} - m_plotWidget->axisScaleEngine( yAxisProps->qwtPlotAxisType() ) - ->setAttribute( QwtScaleEngine::Inverted, yAxisProps->isAxisInverted() ); - } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlot::scheduleReplotIfVisible() +{ + if ( showWindow() && plotWidget() ) plotWidget()->scheduleReplot(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimSummaryPlot::visibleSummaryCurvesForAxis( RiaDefines::PlotAxis plotAxis ) const +std::vector RimSummaryPlot::visibleSummaryCurvesForAxis( RiuPlotAxis plotAxis ) const { std::vector curves; - if ( plotAxis == RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM ) + if ( plotAxis.axis() == RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM ) { if ( m_summaryCurveCollection && m_summaryCurveCollection->isCurvesVisible() ) { @@ -1018,19 +1037,19 @@ std::vector RimSummaryPlot::visibleSummaryCurvesForAxis( RiaDe //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimSummaryPlot::hasVisibleCurvesForAxis( RiaDefines::PlotAxis plotAxis ) const +bool RimSummaryPlot::hasVisibleCurvesForAxis( RiuPlotAxis plotAxis ) const { - if ( visibleSummaryCurvesForAxis( plotAxis ).size() > 0 ) + if ( !visibleSummaryCurvesForAxis( plotAxis ).empty() ) { return true; } - if ( visibleTimeHistoryCurvesForAxis( plotAxis ).size() > 0 ) + if ( !visibleTimeHistoryCurvesForAxis( plotAxis ).empty() ) { return true; } - if ( visibleAsciiDataCurvesForAxis( plotAxis ).size() > 0 ) + if ( !visibleAsciiDataCurvesForAxis( plotAxis ).empty() ) { return true; } @@ -1041,36 +1060,28 @@ bool RimSummaryPlot::hasVisibleCurvesForAxis( RiaDefines::PlotAxis plotAxis ) co //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimPlotAxisProperties* RimSummaryPlot::yAxisPropertiesLeftOrRight( RiaDefines::PlotAxis leftOrRightPlotAxis ) const +RimPlotAxisPropertiesInterface* RimSummaryPlot::axisPropertiesForPlotAxis( RiuPlotAxis plotAxis ) const { - RimPlotAxisProperties* yAxisProps = nullptr; - - if ( leftOrRightPlotAxis == RiaDefines::PlotAxis::PLOT_AXIS_LEFT ) - { - yAxisProps = m_leftYAxisProperties(); - } - else + for ( RimPlotAxisPropertiesInterface* axisProperties : m_axisProperties ) { - yAxisProps = m_rightYAxisProperties(); + if ( axisProperties->plotAxisType() == plotAxis ) return axisProperties; } - CVF_ASSERT( yAxisProps ); - - return yAxisProps; + return nullptr; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimSummaryPlot::visibleTimeHistoryCurvesForAxis( RiaDefines::PlotAxis plotAxis ) const +std::vector RimSummaryPlot::visibleTimeHistoryCurvesForAxis( RiuPlotAxis plotAxis ) const { std::vector curves; - for ( auto c : m_gridTimeHistoryCurves ) + for ( const auto& c : m_gridTimeHistoryCurves ) { if ( c->isCurveVisible() ) { - if ( c->yAxis() == plotAxis || plotAxis == RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM ) + if ( c->yAxis() == plotAxis || plotAxis.axis() == RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM ) { curves.push_back( c ); } @@ -1083,15 +1094,15 @@ std::vector RimSummaryPlot::visibleTimeHistoryCurvesFo //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimSummaryPlot::visibleAsciiDataCurvesForAxis( RiaDefines::PlotAxis plotAxis ) const +std::vector RimSummaryPlot::visibleAsciiDataCurvesForAxis( RiuPlotAxis plotAxis ) const { std::vector curves; - for ( auto c : m_asciiDataCurves ) + for ( const auto& c : m_asciiDataCurves ) { if ( c->isCurveVisible() ) { - if ( c->yAxis() == plotAxis || plotAxis == RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM ) + if ( c->yAxis() == plotAxis || plotAxis.axis() == RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM ) { curves.push_back( c ); } @@ -1104,105 +1115,58 @@ std::vector RimSummaryPlot::visibleAsciiDataCurvesForAxis( R //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryPlot::updateTimeAxis() +void RimSummaryPlot::updateTimeAxis( RimSummaryTimeAxisProperties* timeAxisProperties ) { - if ( !m_plotWidget ) return; + if ( !plotWidget() ) return; - if ( !m_timeAxisProperties->isActive() ) + if ( !timeAxisProperties->isActive() ) { - m_plotWidget->enableAxis( QwtPlot::xBottom, false ); + plotWidget()->enableAxis( RiuPlotAxis::defaultBottom(), false ); return; } - if ( m_timeAxisProperties->timeMode() == RimSummaryTimeAxisProperties::DATE ) + if ( timeAxisProperties->timeMode() == RimSummaryTimeAxisProperties::DATE ) { - RiaQDateTimeTools::DateFormatComponents dateComponents = m_timeAxisProperties->dateComponents(); - RiaQDateTimeTools::TimeFormatComponents timeComponents = m_timeAxisProperties->timeComponents(); + RiaDefines::DateFormatComponents dateComponents = timeAxisProperties->dateComponents(); + RiaDefines::TimeFormatComponents timeComponents = timeAxisProperties->timeComponents(); - QString dateFormat = m_timeAxisProperties->dateFormat(); - QString timeFormat = m_timeAxisProperties->timeFormat(); + const QString& dateFormat = timeAxisProperties->dateFormat(); + const QString& timeFormat = timeAxisProperties->timeFormat(); - m_plotWidget->useDateBasedTimeAxis( dateFormat, timeFormat, dateComponents, timeComponents ); + m_summaryPlot->useDateBasedTimeAxis( dateFormat, timeFormat, dateComponents, timeComponents ); } else { - m_plotWidget->useTimeBasedTimeAxis(); + m_summaryPlot->useTimeBasedTimeAxis(); } - m_plotWidget->enableAxis( QwtPlot::xBottom, true ); + plotWidget()->enableAxis( RiuPlotAxis::defaultBottom(), true ); { Qt::AlignmentFlag alignment = Qt::AlignCenter; - if ( m_timeAxisProperties->titlePosition() == RimPlotAxisPropertiesInterface::AXIS_TITLE_END ) + if ( timeAxisProperties->titlePosition() == RimPlotAxisPropertiesInterface::AXIS_TITLE_END ) { alignment = Qt::AlignRight; } - m_plotWidget->setAxisFontsAndAlignment( QwtPlot::xBottom, - m_timeAxisProperties->titleFontSize(), - m_timeAxisProperties->valuesFontSize(), + plotWidget()->setAxisFontsAndAlignment( RiuPlotAxis::defaultBottom(), + timeAxisProperties->titleFontSize(), + timeAxisProperties->valuesFontSize(), true, alignment ); - m_plotWidget->setAxisTitleText( QwtPlot::xBottom, m_timeAxisProperties->title() ); - m_plotWidget->setAxisTitleEnabled( QwtPlot::xBottom, m_timeAxisProperties->showTitle ); + plotWidget()->setAxisTitleText( RiuPlotAxis::defaultBottom(), timeAxisProperties->title() ); + plotWidget()->setAxisTitleEnabled( RiuPlotAxis::defaultBottom(), timeAxisProperties->showTitle ); { - RimSummaryTimeAxisProperties::LegendTickmarkCount tickmarkCountEnum = - m_timeAxisProperties->majorTickmarkCount(); - - int maxTickmarkCount = 8; - - switch ( tickmarkCountEnum ) - { - case RimSummaryTimeAxisProperties::LegendTickmarkCount::TICKMARK_FEW: - maxTickmarkCount = 4; - break; - case RimSummaryTimeAxisProperties::LegendTickmarkCount::TICKMARK_DEFAULT: - maxTickmarkCount = 8; // Taken from QwtPlot::initAxesData() - break; - case RimSummaryTimeAxisProperties::LegendTickmarkCount::TICKMARK_MANY: - maxTickmarkCount = 10; - break; - default: - break; - } + RimSummaryTimeAxisProperties::LegendTickmarkCount tickmarkCountEnum = timeAxisProperties->majorTickmarkCount(); + int maxTickmarkCount = RimPlotAxisPropertiesInterface::tickmarkCountFromEnum( tickmarkCountEnum ); - m_plotWidget->setAxisMaxMajor( QwtPlot::xBottom, maxTickmarkCount ); + plotWidget()->setAxisMaxMajor( RiuPlotAxis::defaultBottom(), maxTickmarkCount ); } } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimSummaryPlot::updateBottomXAxis() -{ - if ( !m_plotWidget ) return; - - QwtPlot::Axis qwtAxis = QwtPlot::xBottom; - - RimPlotAxisProperties* bottomAxisProperties = m_bottomAxisProperties(); - - if ( bottomAxisProperties->isActive() ) - { - m_plotWidget->enableAxis( qwtAxis, true ); - - std::set timeHistoryQuantities; - - RimSummaryPlotAxisFormatter calc( bottomAxisProperties, - visibleSummaryCurvesForAxis( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM ), - {}, - visibleAsciiDataCurvesForAxis( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM ), - timeHistoryQuantities ); - calc.applyAxisPropertiesToPlot( m_plotWidget ); - } - else - { - m_plotWidget->enableAxis( qwtAxis, false ); - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1221,7 +1185,7 @@ void RimSummaryPlot::addTimeAnnotation( time_t time ) { RimSummaryTimeAxisProperties* axisProps = timeAxisProperties(); { - RimTimeAxisAnnotation* annotation = new RimTimeAxisAnnotation; + auto* annotation = new RimTimeAxisAnnotation; annotation->setTime( time ); axisProps->appendAnnotation( annotation ); @@ -1235,7 +1199,7 @@ void RimSummaryPlot::addTimeRangeAnnotation( time_t startTime, time_t endTime ) { RimSummaryTimeAxisProperties* axisProps = timeAxisProperties(); { - RimTimeAxisAnnotation* annotation = new RimTimeAxisAnnotation; + auto* annotation = new RimTimeAxisAnnotation; annotation->setTimeRange( startTime, endTime ); axisProps->appendAnnotation( annotation ); @@ -1248,9 +1212,7 @@ void RimSummaryPlot::addTimeRangeAnnotation( time_t startTime, time_t endTime ) void RimSummaryPlot::removeAllTimeAnnotations() { RimSummaryTimeAxisProperties* axisProps = timeAxisProperties(); - { - axisProps->removeAllAnnotations(); - } + axisProps->removeAllAnnotations(); } //-------------------------------------------------------------------------------------------------- @@ -1260,39 +1222,32 @@ void RimSummaryPlot::zoomAll() { setAutoScaleXEnabled( true ); setAutoScaleYEnabled( true ); - updateZoomInQwt(); + updateZoomInParentPlot(); + + axisChanged.send( this ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryPlot::addCurveAndUpdate( RimSummaryCurve* curve ) +void RimSummaryPlot::addCurveAndUpdate( RimSummaryCurve* curve, bool autoAssignPlotAxis ) { if ( curve ) { m_summaryCurveCollection->addCurve( curve ); - connectCurveSignals( curve ); - if ( m_plotWidget ) - { - curve->setParentQwtPlotAndReplot( m_plotWidget ); - this->updateAxes(); - } + connectCurveToPlot( curve, true, autoAssignPlotAxis ); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryPlot::addCurveNoUpdate( RimSummaryCurve* curve ) +void RimSummaryPlot::addCurveNoUpdate( RimSummaryCurve* curve, bool autoAssignPlotAxis ) { if ( curve ) { m_summaryCurveCollection->addCurve( curve ); - connectCurveSignals( curve ); - if ( m_plotWidget ) - { - curve->setParentQwtPlotNoReplot( m_plotWidget ); - } + connectCurveToPlot( curve, false, autoAssignPlotAxis ); } } @@ -1304,10 +1259,30 @@ void RimSummaryPlot::insertCurve( RimSummaryCurve* curve, size_t insertAtPositio if ( curve ) { m_summaryCurveCollection->insertCurve( curve, insertAtPosition ); - connectCurveSignals( curve ); - if ( m_plotWidget ) + connectCurveToPlot( curve, false, true ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlot::connectCurveToPlot( RimSummaryCurve* curve, bool update, bool autoAssignPlotAxis ) +{ + if ( autoAssignPlotAxis ) assignPlotAxis( curve ); + + connectCurveSignals( curve ); + if ( plotWidget() ) + { + plotWidget()->ensureAxisIsCreated( curve->axisY() ); + + if ( update ) + { + curve->setParentPlotAndReplot( plotWidget() ); + this->updateAxes(); + } + else { - curve->setParentQwtPlotNoReplot( m_plotWidget ); + curve->setParentPlotNoReplot( plotWidget() ); } } } @@ -1359,9 +1334,9 @@ void RimSummaryPlot::deleteCurves( const std::vector& curves ) if ( curveSet->curves().empty() ) { if ( curveSet->colorMode() == RimEnsembleCurveSet::ColorMode::BY_ENSEMBLE_PARAM && - m_plotWidget && curveSet->legendFrame() ) + plotWidget() && curveSet->legendFrame() ) { - m_plotWidget->removeOverlayFrame( curveSet->legendFrame() ); + plotWidget()->removeOverlayFrame( curveSet->legendFrame() ); } m_ensembleCurveSetCollection->deleteCurveSet( curveSet ); } @@ -1375,6 +1350,8 @@ void RimSummaryPlot::deleteCurves( const std::vector& curves ) RiuPlotMainWindowTools::refreshToolbars(); updateCaseNameHasChanged(); + + curvesChanged.send(); } //-------------------------------------------------------------------------------------------------- @@ -1404,9 +1381,9 @@ void RimSummaryPlot::addGridTimeHistoryCurve( RimGridTimeHistoryCurve* curve ) CVF_ASSERT( curve ); m_gridTimeHistoryCurves.push_back( curve ); - if ( m_plotWidget ) + if ( plotWidget() ) { - curve->setParentQwtPlotAndReplot( m_plotWidget ); + curve->setParentPlotAndReplot( plotWidget() ); this->updateAxes(); } } @@ -1419,9 +1396,9 @@ void RimSummaryPlot::addGridTimeHistoryCurveNoUpdate( RimGridTimeHistoryCurve* c CVF_ASSERT( curve ); m_gridTimeHistoryCurves.push_back( curve ); - if ( m_plotWidget ) + if ( plotWidget() ) { - curve->setParentQwtPlotNoReplot( m_plotWidget ); + curve->setParentPlotNoReplot( plotWidget() ); } } @@ -1430,7 +1407,7 @@ void RimSummaryPlot::addGridTimeHistoryCurveNoUpdate( RimGridTimeHistoryCurve* c //-------------------------------------------------------------------------------------------------- std::vector RimSummaryPlot::gridTimeHistoryCurves() const { - return m_gridTimeHistoryCurves.childObjects(); + return m_gridTimeHistoryCurves.children(); } //-------------------------------------------------------------------------------------------------- @@ -1441,10 +1418,9 @@ void RimSummaryPlot::addAsciiDataCruve( RimAsciiDataCurve* curve ) CVF_ASSERT( curve ); m_asciiDataCurves.push_back( curve ); - if ( m_plotWidget ) + if ( plotWidget() ) { - curve->setParentQwtPlotAndReplot( m_plotWidget ); - this->updateAxes(); + curve->setParentPlotAndReplot( plotWidget() ); } } @@ -1453,6 +1429,10 @@ void RimSummaryPlot::addAsciiDataCruve( RimAsciiDataCurve* curve ) //-------------------------------------------------------------------------------------------------- caf::PdmFieldHandle* RimSummaryPlot::userDescriptionField() { + if ( m_description().isEmpty() ) + { + return &m_fallbackPlotName; + } return &m_description; } @@ -1481,6 +1461,31 @@ void RimSummaryPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField, } } + if ( changedField == &m_showPlotLegends ) updateLegend(); + +#ifdef USE_QTCHARTS + if ( changedField == &m_useQtChartsPlot ) + { + // Hide window + setShowWindow( false ); + + // Detach and destroy plot curves + for ( auto c : summaryCurves() ) + { + c->detach( true ); + } + + for ( auto& curveSet : this->ensembleCurveSetCollection()->curveSets() ) + { + curveSet->deletePlotCurves(); + } + + // Destroy viewer + removeMdiWindowFromMdiArea(); + deletePlotCurvesAndPlotWidget(); + } +#endif + if ( changedField == &m_normalizeCurveYValues ) { this->loadDataAndUpdate(); @@ -1500,26 +1505,42 @@ void RimSummaryPlot::childFieldChangedByUi( const caf::PdmFieldHandle* changedCh //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::updateStackedCurveData() { - updateStackedCurveDataForAxis( RiaDefines::PlotAxis::PLOT_AXIS_LEFT ); - updateStackedCurveDataForAxis( RiaDefines::PlotAxis::PLOT_AXIS_RIGHT ); + auto anyStackedCurvesPresent = updateStackedCurveDataForRelevantAxes(); - if ( m_plotWidget ) + if ( plotWidget() && anyStackedCurvesPresent ) { reattachAllCurves(); - m_plotWidget->scheduleReplot(); + scheduleReplotIfVisible(); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryPlot::updateStackedCurveDataForAxis( RiaDefines::PlotAxis plotAxis ) +bool RimSummaryPlot::updateStackedCurveDataForRelevantAxes() { - std::map curvePhaseCount; + bool anyStackedCurvesPresent = false; + for ( RimPlotAxisPropertiesInterface* axisProperties : m_axisProperties ) + { + if ( axisProperties->plotAxisType().axis() == RiaDefines::PlotAxis::PLOT_AXIS_LEFT || + axisProperties->plotAxisType().axis() == RiaDefines::PlotAxis::PLOT_AXIS_RIGHT ) + { + anyStackedCurvesPresent |= updateStackedCurveDataForAxis( axisProperties->plotAxisType() ); + } + } + return anyStackedCurvesPresent; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryPlot::updateStackedCurveDataForAxis( RiuPlotAxis plotAxis ) +{ auto stackedCurves = visibleStackedSummaryCurvesForAxis( plotAxis ); + if ( stackedCurves.empty() ) return false; - // Reset all curves + std::map curvePhaseCount; for ( RimSummaryCurve* curve : stackedCurves ) { // Apply a area filled style if it isn't already set @@ -1568,7 +1589,10 @@ void RimSummaryPlot::updateStackedCurveDataForAxis( RiaDefines::PlotAxis plotAxi zPos -= 1.0; } } + + return true; } + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1576,9 +1600,9 @@ QImage RimSummaryPlot::snapshotWindowContent() { QImage image; - if ( m_plotWidget ) + if ( plotWidget() ) { - QPixmap pix = m_plotWidget->grab(); + QPixmap pix = plotWidget()->grab(); image = pix.toImage(); } @@ -1590,34 +1614,27 @@ QImage RimSummaryPlot::snapshotWindowContent() //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/ ) { - if ( uiConfigName == RicSummaryPlotEditorUi::CONFIGURATION_NAME ) + if ( !m_isValid ) return; + + bool isPlotEditor = ( uiConfigName == RicSummaryPlotEditorUi::CONFIGURATION_NAME ); + + if ( !isPlotEditor ) uiTreeOrdering.add( &m_axisProperties ); + + for ( auto& curve : m_summaryCurveCollection->curves() ) { - uiTreeOrdering.add( &m_summaryCurveCollection ); - if ( !m_isCrossPlot ) - { - uiTreeOrdering.add( &m_ensembleCurveSetCollection ); - } + uiTreeOrdering.add( curve ); } - else - { - caf::PdmUiTreeOrdering* axisFolder = uiTreeOrdering.add( "Axes", ":/Axes16x16.png" ); - if ( m_isCrossPlot ) - { - axisFolder->add( &m_bottomAxisProperties ); - } - else + if ( !m_isCrossPlot ) + { + for ( auto& curveSet : m_ensembleCurveSetCollection->curveSets() ) { - axisFolder->add( &m_timeAxisProperties ); + uiTreeOrdering.add( curveSet ); } - axisFolder->add( &m_leftYAxisProperties ); - axisFolder->add( &m_rightYAxisProperties ); + } - uiTreeOrdering.add( &m_summaryCurveCollection ); - if ( !m_isCrossPlot ) - { - uiTreeOrdering.add( &m_ensembleCurveSetCollection ); - } + if ( !isPlotEditor ) + { uiTreeOrdering.add( &m_gridTimeHistoryCurves ); uiTreeOrdering.add( &m_asciiDataCurves ); } @@ -1631,7 +1648,10 @@ void RimSummaryPlot::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrderin void RimSummaryPlot::onLoadDataAndUpdate() { updatePlotTitle(); - updateMdiWindowVisibility(); + + RimMultiPlot* plotWindow = nullptr; + firstAncestorOrThisOfType( plotWindow ); + if ( plotWindow == nullptr ) updateMdiWindowVisibility(); if ( m_summaryCurveCollection ) { @@ -1650,11 +1670,11 @@ void RimSummaryPlot::onLoadDataAndUpdate() curve->loadDataAndUpdate( false ); } - if ( m_plotWidget ) + if ( plotWidget() ) { - m_plotWidget->setInternalLegendVisible( m_showPlotLegends && !isSubPlot() ); - m_plotWidget->setLegendFontSize( legendFontSize() ); - m_plotWidget->updateLegend(); + plotWidget()->setInternalLegendVisible( m_showPlotLegends && !isSubPlot() ); + plotWidget()->setLegendFontSize( legendFontSize() ); + plotWidget()->updateLegend(); } this->updateAxes(); @@ -1666,73 +1686,59 @@ void RimSummaryPlot::onLoadDataAndUpdate() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryPlot::updateZoomInQwt() +void RimSummaryPlot::updateZoomInParentPlot() { - if ( m_plotWidget ) - { - updateZoomForAxis( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM ); - updateZoomForAxis( RiaDefines::PlotAxis::PLOT_AXIS_LEFT ); - updateZoomForAxis( RiaDefines::PlotAxis::PLOT_AXIS_RIGHT ); + if ( !plotWidget() ) return; - m_plotWidget->updateAxes(); - updateZoomFromQwt(); - m_plotWidget->scheduleReplot(); + for ( const auto& axisProperty : m_axisProperties ) + { + updateZoomForAxis( axisProperty->plotAxisType() ); } + + plotWidget()->updateAxes(); + updateZoomFromParentPlot(); + plotWidget()->updateZoomDependentCurveProperties(); + scheduleReplotIfVisible(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryPlot::updateZoomFromQwt() +void RimSummaryPlot::updateZoomFromParentPlot() { - if ( !m_plotWidget ) return; + if ( !plotWidget() ) return; - QwtInterval leftAxis = m_plotWidget->axisRange( QwtPlot::yLeft ); - QwtInterval rightAxis = m_plotWidget->axisRange( QwtPlot::yRight ); - QwtInterval timeAxis = m_plotWidget->axisRange( QwtPlot::xBottom ); - - m_leftYAxisProperties->visibleRangeMax = leftAxis.maxValue(); - m_leftYAxisProperties->visibleRangeMin = leftAxis.minValue(); - m_leftYAxisProperties->updateConnectedEditors(); - - m_rightYAxisProperties->visibleRangeMax = rightAxis.maxValue(); - m_rightYAxisProperties->visibleRangeMin = rightAxis.minValue(); - m_rightYAxisProperties->updateConnectedEditors(); - - if ( m_isCrossPlot ) + for ( RimPlotAxisPropertiesInterface* axisProperties : m_axisProperties ) { - m_bottomAxisProperties->visibleRangeMax = timeAxis.maxValue(); - m_bottomAxisProperties->visibleRangeMin = timeAxis.minValue(); - m_bottomAxisProperties->updateConnectedEditors(); - } - else - { - m_timeAxisProperties->setVisibleRangeMin( timeAxis.minValue() ); - m_timeAxisProperties->setVisibleRangeMax( timeAxis.maxValue() ); - m_timeAxisProperties->updateConnectedEditors(); + auto [axisMin, axisMax] = plotWidget()->axisRange( axisProperties->plotAxisType() ); + if ( axisProperties->isAxisInverted() ) std::swap( axisMin, axisMax ); + + axisProperties->setVisibleRangeMax( axisMax ); + axisProperties->setVisibleRangeMin( axisMin ); + axisProperties->updateConnectedEditors(); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::set RimSummaryPlot::allPlotAxes() const +void RimSummaryPlot::deletePlotCurvesAndPlotWidget() { - return { m_timeAxisProperties, m_bottomAxisProperties, m_leftYAxisProperties, m_rightYAxisProperties }; -} + if ( isDeletable() ) + { + detachAllPlotItems(); -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimSummaryPlot::cleanupBeforeClose() -{ - detachAllPlotItems(); + if ( plotWidget() ) + { + plotWidget()->setParent( nullptr ); + } - if ( m_plotWidget ) - { - m_plotWidget->setParent( nullptr ); - delete m_plotWidget; - m_plotWidget = nullptr; + deleteAllPlotCurves(); + + if ( m_summaryPlot ) + { + m_summaryPlot.reset(); + } } } @@ -1781,10 +1787,7 @@ void RimSummaryPlot::curveVisibilityChanged( const caf::SignalEmitter* emitter, //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::curveAppearanceChanged( const caf::SignalEmitter* emitter ) { - if ( m_plotWidget ) - { - m_plotWidget->scheduleReplot(); - } + scheduleReplotIfVisible(); } //-------------------------------------------------------------------------------------------------- @@ -1810,6 +1813,7 @@ void RimSummaryPlot::connectAxisSignals( RimPlotAxisProperties* axis ) { axis->settingsChanged.connect( this, &RimSummaryPlot::axisSettingsChanged ); axis->logarithmicChanged.connect( this, &RimSummaryPlot::axisLogarithmicChanged ); + axis->axisPositionChanged.connect( this, &RimSummaryPlot::axisPositionChanged ); } //-------------------------------------------------------------------------------------------------- @@ -1817,6 +1821,7 @@ void RimSummaryPlot::connectAxisSignals( RimPlotAxisProperties* axis ) //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::axisSettingsChanged( const caf::SignalEmitter* emitter ) { + axisChanged.send( this ); updateAxes(); } @@ -1825,144 +1830,588 @@ void RimSummaryPlot::axisSettingsChanged( const caf::SignalEmitter* emitter ) //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::axisLogarithmicChanged( const caf::SignalEmitter* emitter, bool isLogarithmic ) { + axisChanged.send( this ); loadDataAndUpdate(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryPlot::deleteAllGridTimeHistoryCurves() +RimPlotAxisProperties* RimSummaryPlot::addNewAxisProperties( RiaDefines::PlotAxis plotAxis, const QString& name ) { - m_gridTimeHistoryCurves.deleteAllChildObjects(); + RiuPlotAxis newPlotAxis = plotWidget()->createNextPlotAxis( plotAxis ); + return addNewAxisProperties( newPlotAxis, name ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryPlot::setDescription( const QString& description ) +RimPlotAxisProperties* RimSummaryPlot::addNewAxisProperties( RiuPlotAxis plotAxis, const QString& name ) { - m_description = description; + auto* axisProperties = new RimPlotAxisProperties; + axisProperties->setNameAndAxis( name, name, plotAxis.axis(), plotAxis.index() ); + m_axisProperties.push_back( axisProperties ); + connectAxisSignals( axisProperties ); + + return axisProperties; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimSummaryPlot::description() const +std::vector RimSummaryPlot::visibleCurvesForLegend() { - return m_description(); + std::vector curves; + + for ( auto c : summaryCurves() ) + { + if ( !c->isCurveVisible() ) continue; + if ( !c->showInLegend() ) continue; + curves.push_back( c ); + } + + for ( auto curveSet : curveSets() ) + { + if ( !curveSet->isCurvesVisible() ) continue; + if ( curveSet->colorMode() == RimEnsembleCurveSetColorManager::ColorMode::SINGLE_COLOR ) + { + auto curveSetCurves = curveSet->curves(); + + if ( !curveSetCurves.empty() ) curves.push_back( curveSetCurves.front() ); + } + } + + return curves; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryPlot::enableAutoPlotTitle( bool enable ) +void RimSummaryPlot::axisPositionChanged( const caf::SignalEmitter* emitter, + RimPlotAxisProperties* axisProperties, + RiuPlotAxis oldPlotAxis, + RiuPlotAxis newPlotAxis ) { - m_useAutoPlotTitle = enable; + if ( !axisProperties ) return; + + if ( plotWidget() && plotWidget()->isMultiAxisSupported() ) + { + // Make sure the new axis on the correct side exists. + RiuPlotAxis fixedUpPlotAxis = plotWidget()->createNextPlotAxis( newPlotAxis.axis() ); + // The index can change so need to update. + axisProperties->setNameAndAxis( axisProperties->objectName(), + axisProperties->axisTitleText(), + fixedUpPlotAxis.axis(), + fixedUpPlotAxis.index() ); + + // Move all attached curves + for ( auto curve : summaryCurves() ) + { + if ( curve->axisY() == oldPlotAxis ) curve->setLeftOrRightAxisY( fixedUpPlotAxis ); + } + + for ( auto curveSet : ensembleCurveSetCollection()->curveSets() ) + { + if ( curveSet->axisY() == oldPlotAxis ) curveSet->setLeftOrRightAxisY( fixedUpPlotAxis ); + } + + // Remove the now unused axis (but keep the default axis) + if ( oldPlotAxis != RiuPlotAxis::defaultLeft() && oldPlotAxis != RiuPlotAxis::defaultRight() ) + { + auto oldAxisProperties = axisPropertiesForPlotAxis( oldPlotAxis ); + if ( oldAxisProperties ) m_axisProperties.removeChild( oldAxisProperties ); + plotWidget()->moveAxis( oldPlotAxis, newPlotAxis ); + } + + updateAxes(); + } + + // This is probably to much, but difficult to find the required updates + loadDataAndUpdate(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimSummaryPlot::autoPlotTitle() const +void RimSummaryPlot::deleteAllGridTimeHistoryCurves() { - return m_useAutoPlotTitle; + m_gridTimeHistoryCurves.deleteChildren(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryPlot::setAsCrossPlot() +void RimSummaryPlot::setDescription( const QString& description ) { - m_isCrossPlot = true; + m_description = description; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryPlot::onPlotZoomed() +QString RimSummaryPlot::description() const { - setAutoScaleXEnabled( false ); - setAutoScaleYEnabled( false ); - updateZoomFromQwt(); + return m_description(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +void RimSummaryPlot::enableAutoPlotTitle( bool enable ) { - if ( !m_isCrossPlot ) - { - caf::PdmUiGroup* textCurveFilterGroup = uiOrdering.addNewGroup( "Text-Based Curve Creation" ); - m_textCurveSetEditor->uiOrdering( uiConfigName, *textCurveFilterGroup ); - } + m_useAutoPlotTitle = enable; +} - caf::PdmUiGroup* mainOptions = uiOrdering.addNewGroup( "General Plot Options" ); - mainOptions->setCollapsedByDefault( true ); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryPlot::autoPlotTitle() const +{ + return m_useAutoPlotTitle; +} - if ( isMdiWindow() ) - { - mainOptions->add( &m_showPlotTitle ); - if ( m_showPlotTitle ) - { - mainOptions->add( &m_useAutoPlotTitle ); - mainOptions->add( &m_description ); - } - } - else +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair> RimSummaryPlot::handleSummaryCaseDrop( RimSummaryCase* summaryCase ) +{ + int newCurves = 0; + std::vector curves; + + std::map> dataVectorMap; + + for ( auto& curve : summaryCurves() ) { - mainOptions->add( &m_useAutoPlotTitle ); - mainOptions->add( &m_description ); - mainOptions->add( &m_rowSpan ); - mainOptions->add( &m_colSpan ); + const auto addr = curve->summaryAddressY(); + dataVectorMap[addr].insert( curve->summaryCaseY() ); } - m_description.uiCapability()->setUiReadOnly( m_useAutoPlotTitle ); - if ( isMdiWindow() ) + for ( const auto& [addr, cases] : dataVectorMap ) { - uiOrderingForPlotLayout( uiConfigName, *mainOptions ); - } + if ( cases.count( summaryCase ) > 0 ) continue; - mainOptions->add( &m_normalizeCurveYValues ); + curves.push_back( addNewCurveY( addr, summaryCase ) ); + newCurves++; + } - uiOrdering.skipRemainingFields( true ); + return { newCurves, curves }; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuQwtPlotWidget* RimSummaryPlot::doCreatePlotViewWidget( QWidget* mainWindowParent ) +std::pair> + RimSummaryPlot::handleAddressCollectionDrop( RimSummaryAddressCollection* addressCollection ) { - if ( !m_plotWidget ) - { - m_plotWidget = new RiuSummaryQwtPlot( this, mainWindowParent ); + int newCurves = 0; + std::vector curves; - for ( RimGridTimeHistoryCurve* curve : m_gridTimeHistoryCurves ) + auto droppedName = addressCollection->name().toStdString(); + + auto summaryCase = RiaSummaryTools::summaryCaseById( addressCollection->caseId() ); + auto ensembleCase = RiaSummaryTools::ensembleById( addressCollection->ensembleId() ); + + std::vector sourceCurveDefs; + std::map> newCurveDefsWithObjectNames; + + if ( summaryCase && !ensembleCase ) + { + for ( auto& curve : summaryCurves() ) { - curve->setParentQwtPlotNoReplot( m_plotWidget ); + sourceCurveDefs.push_back( curve->curveDefinitionY() ); } + } - for ( RimAsciiDataCurve* curve : m_asciiDataCurves ) + if ( ensembleCase ) + { + auto curveSets = m_ensembleCurveSetCollection->curveSets(); + for ( auto curveSet : curveSets ) { - curve->setParentQwtPlotNoReplot( m_plotWidget ); + sourceCurveDefs.push_back( RiaSummaryCurveDefinition( ensembleCase, curveSet->summaryAddress() ) ); + } + } + + for ( auto& curveDef : sourceCurveDefs ) + { + auto newCurveDef = curveDef; + auto curveAdr = newCurveDef.summaryAddress(); + std::string objectIdentifierString; + if ( ( curveAdr.category() == RifEclipseSummaryAddress::SUMMARY_WELL ) && + ( addressCollection->contentType() == RimSummaryAddressCollection::CollectionContentType::WELL ) ) + { + objectIdentifierString = curveAdr.wellName(); + curveAdr.setWellName( droppedName ); + newCurveDef.setSummaryAddress( curveAdr ); + } + else if ( ( curveAdr.category() == RifEclipseSummaryAddress::SUMMARY_GROUP ) && + ( addressCollection->contentType() == RimSummaryAddressCollection::CollectionContentType::GROUP ) ) + { + objectIdentifierString = curveAdr.groupName(); + curveAdr.setGroupName( droppedName ); + newCurveDef.setSummaryAddress( curveAdr ); + } + else if ( ( curveAdr.category() == RifEclipseSummaryAddress::SUMMARY_REGION ) && + ( addressCollection->contentType() == RimSummaryAddressCollection::CollectionContentType::REGION ) ) + { + objectIdentifierString = std::to_string( curveAdr.regionNumber() ); + + int droppedRegion = std::stoi( droppedName ); + + curveAdr.setRegion( droppedRegion ); + newCurveDef.setSummaryAddress( curveAdr ); + } + + if ( !objectIdentifierString.empty() ) + { + newCurveDefsWithObjectNames[newCurveDef].insert( objectIdentifierString ); + const auto& addr = curveDef.summaryAddress(); + if ( !addr.isHistoryVector() && RiaPreferencesSummary::current()->appendHistoryVectors() ) + { + auto historyAddr = addr; + historyAddr.setVectorName( addr.vectorName() + RifReaderEclipseSummary::historyIdentifier() ); + + auto historyCurveDef = newCurveDef; + historyCurveDef.setSummaryAddress( historyAddr ); + newCurveDefsWithObjectNames[historyCurveDef].insert( objectIdentifierString ); + } + } + } + + for ( auto& [curveDef, objectNames] : newCurveDefsWithObjectNames ) + { + // Skip adding new curves if the object name is already present for the curve definition + if ( objectNames.count( droppedName ) > 0 ) continue; + + if ( curveDef.ensemble() ) + { + auto addresses = curveDef.ensemble()->ensembleSummaryAddresses(); + if ( addresses.find( curveDef.summaryAddress() ) != addresses.end() ) + { + addNewEnsembleCurveY( curveDef.summaryAddress(), curveDef.ensemble() ); + newCurves++; + } + } + else if ( curveDef.summaryCase() ) + { + if ( curveDef.summaryCase()->summaryReader() && + curveDef.summaryCase()->summaryReader()->hasAddress( curveDef.summaryAddress() ) ) + { + curves.push_back( addNewCurveY( curveDef.summaryAddress(), curveDef.summaryCase() ) ); + newCurves++; + } + } + } + + return { newCurves, curves }; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair> RimSummaryPlot::handleSummaryAddressDrop( RimSummaryAddress* summaryAddr ) +{ + int newCurves = 0; + std::vector curves; + + std::vector newCurveAddresses; + newCurveAddresses.push_back( summaryAddr->address() ); + if ( !summaryAddr->address().isHistoryVector() && RiaPreferencesSummary::current()->appendHistoryVectors() ) + { + auto historyAddr = summaryAddr->address(); + historyAddr.setVectorName( summaryAddr->address().vectorName() + RifReaderEclipseSummary::historyIdentifier() ); + newCurveAddresses.push_back( historyAddr ); + } + + if ( summaryAddr->isEnsemble() ) + { + std::map> dataVectorMap; + + for ( auto& curve : curveSets() ) + { + const auto addr = curve->summaryAddress(); + dataVectorMap[addr].insert( curve->summaryCaseCollection() ); + } + + auto ensemble = RiaSummaryTools::ensembleById( summaryAddr->ensembleId() ); + if ( ensemble ) + { + for ( const auto& droppedAddress : newCurveAddresses ) + { + auto addresses = ensemble->ensembleSummaryAddresses(); + if ( addresses.find( droppedAddress ) == addresses.end() ) continue; + + bool skipAddress = false; + if ( dataVectorMap.count( droppedAddress ) > 0 ) + { + skipAddress = ( dataVectorMap[droppedAddress].count( ensemble ) > 0 ); + } + + if ( !skipAddress ) + { + addNewEnsembleCurveY( droppedAddress, ensemble ); + newCurves++; + } + } + } + } + else + { + std::map> dataVectorMap; + + for ( auto& curve : summaryCurves() ) + { + const auto addr = curve->summaryAddressY(); + dataVectorMap[addr].insert( curve->summaryCaseY() ); + } + + auto summaryCase = RiaSummaryTools::summaryCaseById( summaryAddr->caseId() ); + if ( summaryCase ) + { + for ( const auto& droppedAddress : newCurveAddresses ) + { + if ( !summaryCase->summaryReader() || !summaryCase->summaryReader()->hasAddress( droppedAddress ) ) + continue; + + bool skipAddress = false; + + if ( dataVectorMap.count( droppedAddress ) > 0 ) + { + skipAddress = ( dataVectorMap[droppedAddress].count( summaryCase ) > 0 ); + } + + if ( !skipAddress ) + { + curves.push_back( addNewCurveY( droppedAddress, summaryCase ) ); + newCurves++; + } + } + } + } + return { newCurves, curves }; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlot::handleDroppedObjects( const std::vector& objects ) +{ + int accumulatedCurveCount = 0; + std::vector curvesToUpdate; + + for ( auto obj : objects ) + { + auto summaryCase = dynamic_cast( obj ); + if ( summaryCase ) + { + auto [curveCount, curvesCreated] = handleSummaryCaseDrop( summaryCase ); + accumulatedCurveCount += curveCount; + curvesToUpdate.insert( curvesToUpdate.end(), curvesCreated.begin(), curvesCreated.end() ); + continue; + } + + auto summaryAddr = dynamic_cast( obj ); + if ( summaryAddr ) + { + auto [curveCount, curvesCreated] = handleSummaryAddressDrop( summaryAddr ); + accumulatedCurveCount += curveCount; + curvesToUpdate.insert( curvesToUpdate.end(), curvesCreated.begin(), curvesCreated.end() ); + continue; + } + + auto addressCollection = dynamic_cast( obj ); + if ( addressCollection ) + { + if ( addressCollection->isFolder() ) + { + for ( auto coll : addressCollection->subFolders() ) + { + auto [curveCount, curvesCreated] = handleAddressCollectionDrop( coll ); + accumulatedCurveCount += curveCount; + curvesToUpdate.insert( curvesToUpdate.end(), curvesCreated.begin(), curvesCreated.end() ); + } + continue; + } + else + { + auto [curveCount, curvesCreated] = handleAddressCollectionDrop( addressCollection ); + accumulatedCurveCount += curveCount; + curvesToUpdate.insert( curvesToUpdate.end(), curvesCreated.begin(), curvesCreated.end() ); + continue; + } + } + } + + if ( accumulatedCurveCount > 0 ) + { + applyDefaultCurveAppearances( curvesToUpdate ); + + loadDataAndUpdate(); + + curvesChanged.send(); + } + + updateConnectedEditors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryCurve* RimSummaryPlot::addNewCurveY( const RifEclipseSummaryAddress& address, RimSummaryCase* summaryCase ) +{ + auto* newCurve = new RimSummaryCurve(); + newCurve->setSummaryCaseY( summaryCase ); + newCurve->setSummaryAddressYAndApplyInterpolation( address ); + addCurveNoUpdate( newCurve ); + + return newCurve; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlot::addNewEnsembleCurveY( const RifEclipseSummaryAddress& address, RimSummaryCaseCollection* ensemble ) +{ + auto* curveSet = new RimEnsembleCurveSet(); + + curveSet->setSummaryCaseCollection( ensemble ); + curveSet->setSummaryAddress( address ); + + cvf::Color3f curveColor = + RimSummaryCurveAppearanceCalculator::computeTintedCurveColorForAddress( curveSet->summaryAddress(), + static_cast( + ensembleCurveSetCollection() + ->curveSetCount() ) ); + + auto adr = curveSet->summaryAddress(); + if ( adr.isHistoryVector() ) curveColor = RiaPreferencesSummary::current()->historyCurveContrastColor(); + + curveSet->setColor( curveColor ); + + ensembleCurveSetCollection()->addCurveSet( curveSet ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlot::onPlotZoomed() +{ + setAutoScaleXEnabled( false ); + setAutoScaleYEnabled( false ); + updateZoomFromParentPlot(); + + axisChanged.send( this ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +{ + { + auto group = uiOrdering.addNewGroup( "Data Source" ); + m_sourceStepping()->uiOrdering( uiConfigName, *group ); + } + + caf::PdmUiGroup* mainOptions = uiOrdering.addNewGroup( "General Plot Options" ); +#ifdef USE_QTCHARTS + mainOptions->add( &m_useQtChartsPlot ); +#endif + if ( isMdiWindow() ) + { + mainOptions->add( &m_showPlotTitle ); + if ( m_showPlotTitle ) + { + mainOptions->add( &m_useAutoPlotTitle ); + mainOptions->add( &m_description ); + } + } + else + { + mainOptions->add( &m_useAutoPlotTitle ); + mainOptions->add( &m_description ); + mainOptions->add( &m_colSpan ); + } + m_description.uiCapability()->setUiReadOnly( m_useAutoPlotTitle ); + + if ( isMdiWindow() ) + { + uiOrderingForPlotLayout( uiConfigName, *mainOptions ); + } + + mainOptions->add( &m_normalizeCurveYValues ); + + uiOrdering.skipRemainingFields( true ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuPlotWidget* RimSummaryPlot::doCreatePlotViewWidget( QWidget* mainWindowParent ) +{ + if ( !plotWidget() ) + { +#ifdef USE_QTCHARTS + bool useQtCharts = m_useQtChartsPlot; + + auto regTestRunner = RiaRegressionTestRunner::instance(); + if ( regTestRunner->isRunningRegressionTests() ) + { + if ( regTestRunner->overridePlotEngine() == RiaRegressionTest::PlotEngine::USE_QWT ) + useQtCharts = false; + else if ( regTestRunner->overridePlotEngine() == RiaRegressionTest::PlotEngine::USER_QTCHARTS ) + useQtCharts = true; + } + + // Disable all use of QtCharts for now. If a plot was created using QtCharts during the period this flag was + // active, the use of QtCharts was stored in the project file or template file. Set flag to false to force use + // of Qwt + useQtCharts = false; + + if ( useQtCharts ) + { + m_summaryPlot = std::make_unique( this, mainWindowParent ); + } + else + { + m_summaryPlot = std::make_unique( this, mainWindowParent ); + } +#else + m_summaryPlot = std::make_unique( this, mainWindowParent ); +#endif + + for ( const auto& axisProperties : m_axisProperties ) + { + plotWidget()->ensureAxisIsCreated( axisProperties->plotAxisType() ); + } + + for ( RimGridTimeHistoryCurve* curve : m_gridTimeHistoryCurves ) + { + curve->setParentPlotNoReplot( plotWidget() ); + } + + for ( RimAsciiDataCurve* curve : m_asciiDataCurves ) + { + curve->setParentPlotNoReplot( plotWidget() ); } if ( m_summaryCurveCollection ) { - m_summaryCurveCollection->setParentQwtPlotAndReplot( m_plotWidget ); + m_summaryCurveCollection->setParentPlotNoReplot( plotWidget() ); } if ( m_ensembleCurveSetCollection ) { - m_ensembleCurveSetCollection->setParentQwtPlotAndReplot( m_plotWidget ); + m_ensembleCurveSetCollection->setParentPlotNoReplot( plotWidget() ); } - this->connect( m_plotWidget, SIGNAL( plotZoomed() ), SLOT( onPlotZoomed() ) ); + this->connect( plotWidget(), SIGNAL( plotZoomed() ), SLOT( onPlotZoomed() ) ); updatePlotTitle(); } - return m_plotWidget; + plotWidget()->setParent( mainWindowParent ); + + return plotWidget(); } //-------------------------------------------------------------------------------------------------- @@ -1970,7 +2419,7 @@ RiuQwtPlotWidget* RimSummaryPlot::doCreatePlotViewWidget( QWidget* mainWindowPar //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::deleteViewWidget() { - cleanupBeforeClose(); + deletePlotCurvesAndPlotWidget(); } //-------------------------------------------------------------------------------------------------- @@ -1980,6 +2429,52 @@ void RimSummaryPlot::initAfterRead() { RimViewWindow::initAfterRead(); + if ( RimProject::current()->isProjectFileVersionEqualOrOlderThan( "2021.10.2" ) ) + { + auto copyAxis = [this]( RiuPlotAxis axis, auto sourceObject ) { + auto axisProperties = axisPropertiesForPlotAxis( axis ); + if ( axisProperties ) + { + QString data = sourceObject->writeObjectToXmlString(); + + // This operation will overwrite the plot axis side, default is left + axisProperties->readObjectFromXmlString( data, caf::PdmDefaultObjectFactory::instance() ); + + auto plotAxisProperties = dynamic_cast( axisProperties ); + if ( plotAxisProperties ) + { + // Reset the plot axis for the axis property + plotAxisProperties->setNameAndAxis( axisProperties->objectName(), + axisProperties->axisTitleText(), + axis.axis(), + 0 ); + } + } + }; + + copyAxis( RiuPlotAxis::defaultLeft(), m_leftYAxisProperties_OBSOLETE.v() ); + copyAxis( RiuPlotAxis::defaultRight(), m_rightYAxisProperties_OBSOLETE.v() ); + + if ( m_isCrossPlot ) + copyAxis( RiuPlotAxis::defaultBottom(), m_bottomAxisProperties_OBSOLETE.v() ); + else + copyAxis( RiuPlotAxis::defaultBottom(), m_timeAxisProperties_OBSOLETE.v() ); + } + + for ( const auto& axisProperties : m_axisProperties ) + { + auto plotAxisProperties = dynamic_cast( axisProperties.p() ); + if ( plotAxisProperties ) + { + connectAxisSignals( plotAxisProperties ); + } + auto* timeAxis = dynamic_cast( axisProperties.p() ); + if ( timeAxis ) + { + timeAxis->settingsChanged.connect( this, &RimSummaryPlot::axisSettingsChanged ); + } + } + for ( auto curve : summaryCurves() ) { connectCurveSignals( curve ); @@ -2057,24 +2552,38 @@ void RimSummaryPlot::detachAllPlotItems() { if ( m_summaryCurveCollection ) { - m_summaryCurveCollection->detachQwtCurves(); + m_summaryCurveCollection->detachPlotCurves(); } - m_ensembleCurveSetCollection->detachQwtCurves(); + if ( m_ensembleCurveSetCollection ) + { + m_ensembleCurveSetCollection->detachPlotCurves(); + } for ( RimGridTimeHistoryCurve* curve : m_gridTimeHistoryCurves ) { - curve->detachQwtCurve(); + curve->detach(); } for ( RimAsciiDataCurve* curve : m_asciiDataCurves ) { - curve->detachQwtCurve(); + curve->detach(); } m_plotInfoLabel->detach(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlot::deleteAllPlotCurves() +{ + for ( auto* c : summaryCurves() ) + { + c->deletePlotCurve(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -2084,7 +2593,10 @@ void RimSummaryPlot::updateCurveNames() { for ( auto c : summaryCurves() ) { - c->updateCurveNameNoLegendUpdate(); + if ( c->isCurveVisible() ) + { + c->updateCurveNameNoLegendUpdate(); + } } } @@ -2109,79 +2621,28 @@ void RimSummaryPlot::reattachAllCurves() { if ( m_summaryCurveCollection ) { - m_summaryCurveCollection->reattachQwtCurves(); + m_summaryCurveCollection->reattachPlotCurves(); } - m_ensembleCurveSetCollection->reattachQwtCurves(); + m_ensembleCurveSetCollection->reattachPlotCurves(); for ( RimGridTimeHistoryCurve* curve : m_gridTimeHistoryCurves ) { - curve->reattachQwtCurve(); + curve->reattach(); } for ( RimAsciiDataCurve* curve : m_asciiDataCurves ) { - curve->reattachQwtCurve(); + curve->reattach(); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryPlot::handleKeyPressEvent( QKeyEvent* keyEvent ) +bool RimSummaryPlot::handleGlobalKeyEvent( QKeyEvent* keyEvent ) { - if ( !keyEvent ) return; - - if ( RiuTreeViewEventFilter::activateFeatureFromKeyEvent( keyEvent ) ) - { - return; - } - - RimSummaryPlotSourceStepping* sourceStepping = sourceSteppingObjectForKeyEventHandling(); - if ( !sourceStepping ) return; - - if ( keyEvent->key() == Qt::Key_PageUp ) - { - if ( keyEvent->modifiers() & Qt::ShiftModifier ) - { - sourceStepping->applyPrevCase(); - - keyEvent->accept(); - } - else if ( keyEvent->modifiers() & Qt::ControlModifier ) - { - sourceStepping->applyPrevOtherIdentifier(); - - keyEvent->accept(); - } - else - { - sourceStepping->applyPrevQuantity(); - - keyEvent->accept(); - } - } - else if ( keyEvent->key() == Qt::Key_PageDown ) - { - if ( keyEvent->modifiers() & Qt::ShiftModifier ) - { - sourceStepping->applyNextCase(); - - keyEvent->accept(); - } - else if ( keyEvent->modifiers() & Qt::ControlModifier ) - { - sourceStepping->applyNextOtherIdentifier(); - - keyEvent->accept(); - } - else - { - sourceStepping->applyNextQuantity(); - - keyEvent->accept(); - } - } + return RimSummaryPlotControls::handleKeyEvents( sourceSteppingObjectForKeyEventHandling(), keyEvent ); } //-------------------------------------------------------------------------------------------------- @@ -2190,27 +2651,36 @@ void RimSummaryPlot::handleKeyPressEvent( QKeyEvent* keyEvent ) void RimSummaryPlot::onCurveCollectionChanged( const SignalEmitter* emitter ) { updateStackedCurveData(); + scheduleReplotIfVisible(); + + updateAllRequiredEditors(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryPlotSourceStepping* RimSummaryPlot::sourceSteppingObjectForKeyEventHandling() const +void RimSummaryPlot::onPlotItemSelected( std::shared_ptr plotItem, bool toggle, int sampleIndex ) { - caf::PdmObjectHandle* selectedObj = - dynamic_cast( caf::SelectionManager::instance()->selectedItem() ); - if ( selectedObj ) - { - RimEnsembleCurveSetCollection* ensembleCurveSetColl = nullptr; - selectedObj->firstAncestorOrThisOfType( ensembleCurveSetColl ); + auto wrapper = dynamic_cast( plotItem.get() ); + if ( !wrapper ) return; - if ( ensembleCurveSetColl ) - { - return ensembleCurveSetCollection()->sourceSteppingObject(); - } - } + auto qwtPlotItem = wrapper->qwtPlotItem(); + if ( !qwtPlotItem ) return; + + auto riuPlotCurve = dynamic_cast( qwtPlotItem ); + if ( !riuPlotCurve ) return; + + auto rimPlotCurve = riuPlotCurve->ownerRimCurve(); - return summaryCurveCollection()->sourceSteppingObject( RimSummaryPlotSourceStepping::Y_AXIS ); + RiuPlotMainWindowTools::selectOrToggleObject( rimPlotCurve, toggle ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryPlotSourceStepping* RimSummaryPlot::sourceSteppingObjectForKeyEventHandling() const +{ + return m_sourceStepping; } //-------------------------------------------------------------------------------------------------- @@ -2251,13 +2721,13 @@ std::vector RimSummaryPlot::fieldsToShowInToolbar() //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::setAutoScaleXEnabled( bool enabled ) { - if ( m_isCrossPlot ) + for ( const auto& ap : m_axisProperties ) { - m_bottomAxisProperties->setAutoZoom( enabled ); - } - else - { - m_timeAxisProperties->setAutoZoom( enabled ); + if ( ap->plotAxisType().axis() == RiaDefines::PlotAxis::PLOT_AXIS_TOP || + ap->plotAxisType().axis() == RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM ) + { + ap->setAutoZoom( enabled ); + } } } @@ -2266,8 +2736,14 @@ void RimSummaryPlot::setAutoScaleXEnabled( bool enabled ) //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::setAutoScaleYEnabled( bool enabled ) { - m_leftYAxisProperties->setAutoZoom( enabled ); - m_rightYAxisProperties->setAutoZoom( enabled ); + for ( const auto& ap : m_axisProperties ) + { + if ( ap->plotAxisType().axis() == RiaDefines::PlotAxis::PLOT_AXIS_LEFT || + ap->plotAxisType().axis() == RiaDefines::PlotAxis::PLOT_AXIS_RIGHT ) + { + ap->setAutoZoom( enabled ); + } + } } //-------------------------------------------------------------------------------------------------- @@ -2291,318 +2767,163 @@ bool RimSummaryPlot::isDeletable() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void populateTimeHistoryCurvesData( std::vector curves, CurvesData* curvesData ) +std::vector RimSummaryPlot::plotAxes() const { - CVF_ASSERT( curvesData ); - - curvesData->clear(); - - for ( RimGridTimeHistoryCurve* curve : curves ) + std::vector axisProps; + for ( const auto& ap : m_axisProperties ) { - if ( !curve->isCurveVisible() ) continue; - QString curveCaseName = curve->caseName(); - - CurveData curveData = { curve->curveExportDescription(), RifEclipseSummaryAddress(), curve->yValues() }; - - curvesData->addCurveData( curveCaseName, "", curve->timeStepValues(), curveData ); + axisProps.push_back( ap ); } + + return axisProps; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void populateAsciiDataCurvesData( std::vector curves, CurvesData* curvesData ) +std::vector RimSummaryPlot::plotYAxes() const { - CVF_ASSERT( curvesData ); - - curvesData->clear(); - - for ( RimAsciiDataCurve* curve : curves ) + std::vector axisProps; + for ( const auto& ap : m_axisProperties ) { - if ( !curve->isCurveVisible() ) continue; - - CurveData curveData = { curve->curveExportDescription(), RifEclipseSummaryAddress(), curve->yValues() }; - - curvesData->addCurveDataNoSearch( "", "", curve->timeSteps(), { curveData } ); + if ( RiaDefines::isVertical( ap->plotAxisType().axis() ) ) axisProps.push_back( ap ); } + + return axisProps; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void populateSummaryCurvesData( std::vector curves, SummaryCurveType curveType, CurvesData* curvesData ) +void RimSummaryPlot::assignPlotAxis( RimSummaryCurve* destinationCurve ) { - CVF_ASSERT( curvesData ); + enum class AxisAssignmentStrategy + { + ALL_TO_LEFT, + ALL_TO_RIGHT, + ALTERNATING, + USE_MATCHING_UNIT + }; - curvesData->clear(); + RiaDefines::PlotAxis plotAxis = RiaDefines::PlotAxis::PLOT_AXIS_LEFT; - for ( RimSummaryCurve* curve : curves ) + auto strategy = AxisAssignmentStrategy::USE_MATCHING_UNIT; + if ( strategy == AxisAssignmentStrategy::USE_MATCHING_UNIT ) { - bool isObservedCurve = curve->summaryCaseY() ? curve->summaryCaseY()->isObservedData() : false; + auto destinationUnit = destinationCurve->unitNameY(); - if ( !curve->isCurveVisible() ) continue; - if ( isObservedCurve && ( curveType & CURVE_TYPE_OBSERVED ) == 0 ) continue; - if ( !isObservedCurve && ( curveType & CURVE_TYPE_GRID ) == 0 ) continue; - if ( !curve->summaryCaseY() ) continue; + bool isLeftUsed = false; + bool isRightUsed = false; - QString curveCaseName = curve->summaryCaseY()->displayCaseName(); - QString ensembleName; - if ( curve->curveDefinitionY().ensemble() ) + for ( auto c : summaryCurves() ) { - ensembleName = curve->curveDefinitionY().ensemble()->name(); - } + if ( c == destinationCurve ) continue; - CurveData curveData = { curve->curveExportDescription(), curve->summaryAddressY(), curve->valuesY() }; - CurveData errorCurveData; + if ( c->axisY() == RiuPlotAxis::defaultLeft() ) isLeftUsed = true; + if ( c->axisY() == RiuPlotAxis::defaultRight() ) isRightUsed = true; - // Error data - auto errorValues = curve->errorValuesY(); - bool hasErrorData = !errorValues.empty(); + auto currentUnit = c->unitNameY(); - if ( hasErrorData ) - { - errorCurveData.name = curve->curveExportDescription( curve->errorSummaryAddressY() ); - errorCurveData.address = curve->errorSummaryAddressY(); - errorCurveData.values = errorValues; + if ( currentUnit == destinationUnit ) + { + for ( RimPlotAxisPropertiesInterface* axisProperties : m_axisProperties ) + { + if ( axisProperties->plotAxisType().axis() == RiaDefines::PlotAxis::PLOT_AXIS_LEFT || + axisProperties->plotAxisType().axis() == RiaDefines::PlotAxis::PLOT_AXIS_RIGHT ) + { + destinationCurve->setLeftOrRightAxisY( c->axisY() ); + + return; + } + } + } } - auto curveDataList = std::vector( { curveData } ); - if ( hasErrorData ) curveDataList.push_back( errorCurveData ); - if ( curve->summaryAddressY().category() == RifEclipseSummaryAddress::SUMMARY_CALCULATED ) + if ( !isLeftUsed ) { - // We have calculated data, and it we cannot assume identical time axis - curvesData->addCurveDataNoSearch( curveCaseName, ensembleName, curve->timeStepsY(), curveDataList ); + destinationCurve->setLeftOrRightAxisY( RiuPlotAxis::defaultLeft() ); + return; } - else + + if ( !isRightUsed ) { - for ( auto cd : curveDataList ) - { - curvesData->addCurveData( curveCaseName, ensembleName, curve->timeStepsY(), cd ); - } + destinationCurve->setLeftOrRightAxisY( RiuPlotAxis::defaultRight() ); + return; } - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void prepareCaseCurvesForExport( RiaQDateTimeTools::DateTimePeriod period, - ResampleAlgorithm algorithm, - const CurvesData& inputCurvesData, - CurvesData* resultCurvesData ) -{ - RiaTimeHistoryCurveResampler resampler; - resultCurvesData->clear(); + strategy = AxisAssignmentStrategy::ALTERNATING; + } - if ( period != RiaQDateTimeTools::DateTimePeriod::NONE ) + if ( strategy == AxisAssignmentStrategy::ALTERNATING ) { - // Prepare result data - resultCurvesData->resamplePeriod = period; - - for ( size_t i = 0; i < inputCurvesData.caseIds.size(); i++ ) + size_t axisCountLeft = 0; + size_t axisCountRight = 0; + for ( const auto& ap : m_axisProperties ) { - // Shortcuts to input data - auto& caseId = inputCurvesData.caseIds[i]; - auto& caseTimeSteps = inputCurvesData.timeSteps[i]; - auto& caseCurveData = inputCurvesData.allCurveData[i]; - - // Prepare result data - - for ( auto& curveDataItem : caseCurveData ) - { - resampler.setCurveData( curveDataItem.values, caseTimeSteps ); - - if ( RiaSummaryTools::hasAccumulatedData( curveDataItem.address ) || - algorithm == ResampleAlgorithm::PERIOD_END ) - { - resampler.resampleAndComputePeriodEndValues( period ); - } - else - { - resampler.resampleAndComputeWeightedMeanValues( period ); - } - - auto cd = curveDataItem; - cd.values = resampler.resampledValues(); - - resultCurvesData->addCurveData( caseId, "", resampler.resampledTimeSteps(), cd ); - } + if ( ap->plotAxisType().axis() == RiaDefines::PlotAxis::PLOT_AXIS_LEFT ) + axisCountLeft++; + else if ( ap->plotAxisType().axis() == RiaDefines::PlotAxis::PLOT_AXIS_RIGHT ) + axisCountRight++; } + + if ( axisCountLeft > axisCountRight ) plotAxis = RiaDefines::PlotAxis::PLOT_AXIS_RIGHT; } - else + else if ( strategy == AxisAssignmentStrategy::ALL_TO_LEFT ) { - *resultCurvesData = inputCurvesData; + plotAxis = RiaDefines::PlotAxis::PLOT_AXIS_LEFT; + } + else if ( strategy == AxisAssignmentStrategy::ALL_TO_RIGHT ) + { + plotAxis = RiaDefines::PlotAxis::PLOT_AXIS_RIGHT; } -} -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void appendToExportDataForCase( QString& out, const std::vector& timeSteps, const std::vector& curveData ) -{ - for ( size_t j = 0; j < timeSteps.size(); j++ ) // time steps & data points + RiuPlotAxis newPlotAxis = RiuPlotAxis::defaultLeft(); + if ( plotWidget() && plotWidget()->isMultiAxisSupported() ) { - if ( j == 0 ) - { - out += "Date and time"; - for ( size_t k = 0; k < curveData.size(); k++ ) // curves - { - out += "\t" + ( curveData[k].name ); - } - } - out += "\n"; - out += QDateTime::fromSecsSinceEpoch( timeSteps[j] ).toUTC().toString( "yyyy-MM-dd hh:mm:ss " ); + QString axisObjectName = "New Axis"; + if ( !destinationCurve->summaryAddressY().uiText().empty() ) + axisObjectName = QString::fromStdString( destinationCurve->summaryAddressY().uiText() ); - for ( size_t k = 0; k < curveData.size(); k++ ) // curves - { - QString valueText; - if ( j < curveData[k].values.size() ) - { - valueText = QString::number( curveData[k].values[j], 'g', RimSummaryPlot::precision() ); - } - out += "\t" + valueText.rightJustified( 13 ); - } + newPlotAxis = plotWidget()->createNextPlotAxis( plotAxis ); + addNewAxisProperties( newPlotAxis, axisObjectName ); } + + destinationCurve->setLeftOrRightAxisY( newPlotAxis ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void appendToExportData( QString& out, const std::vector& curvesData, bool showTimeAsLongString ) +void RimSummaryPlot::onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, + std::vector& referringObjects ) { - CurvesData data = concatCurvesData( curvesData ); - - if ( data.resamplePeriod != RiaQDateTimeTools::DateTimePeriod::NONE ) + if ( childArray == &m_axisProperties ) { - time_t minTimeStep = std::numeric_limits::max(); - time_t maxTimeStep = 0; - - for ( auto& timeSteps : data.timeSteps ) + for ( caf::PdmObjectHandle* reffingObj : referringObjects ) { - if ( !timeSteps.empty() ) + auto* curve = dynamic_cast( reffingObj ); + auto* curveSet = dynamic_cast( reffingObj ); + if ( curve ) { - if ( timeSteps.front() < minTimeStep ) minTimeStep = timeSteps.front(); - if ( timeSteps.back() > maxTimeStep ) maxTimeStep = timeSteps.back(); + curve->setLeftOrRightAxisY( RiuPlotAxis::defaultLeft() ); } - } - - auto allTimeSteps = - RiaTimeHistoryCurveResampler::timeStepsFromTimeRange( data.resamplePeriod, minTimeStep, maxTimeStep ); - - out += "\n\n"; - out += "Date and time"; - for ( size_t i = 0; i < data.caseIds.size(); i++ ) - { - for ( size_t j = 0; j < data.allCurveData[i].size(); j++ ) + else if ( curveSet ) { - out += "\t" + data.allCurveData[i][j].name; + curveSet->setLeftOrRightAxisY( RiuPlotAxis::defaultLeft() ); } } - out += "\n"; - - std::vector currIndexes( data.caseIds.size() ); - for ( auto& i : currIndexes ) - i = 0; - for ( auto timeStep : allTimeSteps ) + if ( plotWidget() ) { - QDateTime timseStepUtc = QDateTime::fromSecsSinceEpoch( timeStep ).toUTC(); - QString timeText; - - if ( showTimeAsLongString ) + std::set usedPlotAxis; + for ( const auto& axisProperties : m_axisProperties ) { - timeText = timseStepUtc.toString( "yyyy-MM-dd hh:mm:ss " ); + usedPlotAxis.insert( axisProperties->plotAxisType() ); } - else - { - // Subtract one day to make sure the period is reported using the previous period as label - QDateTime oneDayEarlier = timseStepUtc.addDays( -1 ); - QChar zeroChar( 48 ); - - switch ( data.resamplePeriod ) - { - default: - // Fall through to NONE - case RiaQDateTimeTools::DateTimePeriod::NONE: - timeText = timseStepUtc.toString( "yyyy-MM-dd hh:mm:ss " ); - break; - case RiaQDateTimeTools::DateTimePeriod::DAY: - timeText = oneDayEarlier.toString( "yyyy-MM-dd " ); - break; - case RiaQDateTimeTools::DateTimePeriod::WEEK: - { - timeText = oneDayEarlier.toString( "yyyy" ); - int weekNumber = oneDayEarlier.date().weekNumber(); - timeText += QString( "-W%1" ).arg( weekNumber, 2, 10, zeroChar ); - break; - } - case RiaQDateTimeTools::DateTimePeriod::MONTH: - timeText = oneDayEarlier.toString( "yyyy-MM" ); - break; - case RiaQDateTimeTools::DateTimePeriod::QUARTER: - { - int quarterNumber = oneDayEarlier.date().month() / 3; - timeText = oneDayEarlier.toString( "yyyy" ); - timeText += QString( "-Q%1" ).arg( quarterNumber ); - break; - } - case RiaQDateTimeTools::DateTimePeriod::HALFYEAR: - { - int halfYearNumber = oneDayEarlier.date().month() / 6; - timeText = oneDayEarlier.toString( "yyyy" ); - timeText += QString( "-H%1" ).arg( halfYearNumber ); - break; - } - case RiaQDateTimeTools::DateTimePeriod::YEAR: - timeText = oneDayEarlier.toString( "yyyy" ); - break; - case RiaQDateTimeTools::DateTimePeriod::DECADE: - timeText = oneDayEarlier.toString( "yyyy" ); - break; - } - } - out += timeText; - - for ( size_t i = 0; i < data.caseIds.size(); i++ ) // cases - { - // Check is time step exists in curr case - size_t& currIndex = currIndexes[i]; - bool timeStepExists = currIndex < data.timeSteps[i].size() && timeStep == data.timeSteps[i][currIndex]; - - for ( size_t j = 0; j < data.allCurveData[i].size(); j++ ) // vectors - { - QString valueText; - if ( timeStepExists ) - { - valueText = - QString::number( data.allCurveData[i][j].values[currIndex], 'g', RimSummaryPlot::precision() ); - } - else - { - valueText = "NULL"; - } - out += "\t" + valueText.rightJustified( 13 ); - } - - if ( timeStepExists && currIndex < data.timeSteps[i].size() ) currIndex++; - } - out += "\n"; - } - } - else - { - for ( size_t i = 0; i < data.caseIds.size(); i++ ) - { - out += "\n\n"; - if ( !data.caseIds[i].isEmpty() ) - { - out += "Case: " + data.caseIds[i]; - out += "\n"; - } - - appendToExportDataForCase( out, data.timeSteps[i], data.allCurveData[i] ); + plotWidget()->pruneAxes( usedPlotAxis ); + updateAxes(); + scheduleReplotIfVisible(); } } } @@ -2610,30 +2931,7 @@ void appendToExportData( QString& out, const std::vector& curvesData //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -CurvesData concatCurvesData( const std::vector& curvesData ) +RimSummaryPlotSourceStepping* RimSummaryPlot::sourceStepper() { - CVF_ASSERT( !curvesData.empty() ); - - RiaQDateTimeTools::DateTimePeriod period = curvesData.front().resamplePeriod; - CurvesData resultCurvesData; - - resultCurvesData.resamplePeriod = period; - - for ( auto curvesDataItem : curvesData ) - { - if ( curvesDataItem.caseIds.empty() ) continue; - - CVF_ASSERT( curvesDataItem.resamplePeriod == period ); - - resultCurvesData.caseIds.insert( resultCurvesData.caseIds.end(), - curvesDataItem.caseIds.begin(), - curvesDataItem.caseIds.end() ); - resultCurvesData.timeSteps.insert( resultCurvesData.timeSteps.end(), - curvesDataItem.timeSteps.begin(), - curvesDataItem.timeSteps.end() ); - resultCurvesData.allCurveData.insert( resultCurvesData.allCurveData.end(), - curvesDataItem.allCurveData.begin(), - curvesDataItem.allCurveData.end() ); - } - return resultCurvesData; + return m_sourceStepping(); } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.h index 240581972c..b22152d220 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.h @@ -18,16 +18,20 @@ #pragma once -#include "RiaDefines.h" -#include "RiaQDateTimeTools.h" +#include "RiaDateTimeDefines.h" +#include "RiaPlotDefines.h" #include "RifEclipseSummaryAddress.h" #include "RimPlot.h" +#include "RimSummaryDataSourceStepping.h" -#include "qwt_plot_textlabel.h" +#include "RiuQwtPlotWidget.h" +#include "RiuSummaryPlot.h" #include "cafPdmChildArrayField.h" +#include "cafPdmObjectHandle.h" +#include "cafPdmProxyValueField.h" #include "cafPdmPtrArrayField.h" #include "cafPdmPtrField.h" @@ -35,11 +39,15 @@ #include #include +#include class PdmUiTreeOrdering; class RimAsciiDataCurve; class RimGridTimeHistoryCurve; +class RimSummaryAddress; +class RimSummaryAddressCollection; class RimSummaryCase; +class RimSummaryCaseCollection; class RimSummaryCurve; class RimSummaryCurveCollection; class RimEnsembleCurveSet; @@ -49,6 +57,7 @@ class RimSummaryTimeAxisProperties; class RimPlotAxisPropertiesInterface; class RimPlotAxisProperties; class RiuSummaryQwtPlot; +class RimSummaryNameHelper; class RimSummaryPlotNameHelper; class RimPlotTemplateFileItem; class RimSummaryPlotFilterTextCurveSetEditor; @@ -57,6 +66,7 @@ class RiaSummaryCurveDefinition; class QwtInterval; class QwtPlotCurve; +class QwtPlotTextLabel; class QKeyEvent; @@ -64,13 +74,17 @@ class QKeyEvent; /// /// //================================================================================================== -class RimSummaryPlot : public RimPlot +class RimSummaryPlot : public RimPlot, public RimSummaryDataSourceStepping { Q_OBJECT; CAF_PDM_HEADER_INIT; public: - RimSummaryPlot(); + caf::Signal<> curvesChanged; + caf::Signal axisChanged; + +public: + RimSummaryPlot( bool isCrossPlot = false ); ~RimSummaryPlot() override; void setDescription( const QString& description ); @@ -79,8 +93,8 @@ class RimSummaryPlot : public RimPlot void enableAutoPlotTitle( bool enable ); bool autoPlotTitle() const; - void addCurveAndUpdate( RimSummaryCurve* curve ); - void addCurveNoUpdate( RimSummaryCurve* curve ); + void addCurveAndUpdate( RimSummaryCurve* curve, bool autoAssignPlotAxis = true ); + void addCurveNoUpdate( RimSummaryCurve* curve, bool autoAssignPlotAxis = true ); void insertCurve( RimSummaryCurve* curve, size_t insertAtPosition ); @@ -113,17 +127,15 @@ class RimSummaryPlot : public RimPlot void updateAxes() override; - bool isLogarithmicScaleEnabled( RiaDefines::PlotAxis plotAxis ) const; + bool isLogarithmicScaleEnabled( RiuPlotAxis plotAxis ) const; RimSummaryTimeAxisProperties* timeAxisProperties(); time_t firstTimeStepOfFirstCurve(); - QWidget* viewWidget() override; - RiuQwtPlotWidget* viewer() override; + QWidget* viewWidget() override; QString asciiDataForPlotExport() const override; - QString asciiDataForSummaryPlotExport( RiaQDateTimeTools::DateTimePeriod resamplingPeriod, - bool showTimeAsLongString ) const; + QString asciiDataForSummaryPlotExport( RiaDefines::DateTimePeriod resamplingPeriod, bool showTimeAsLongString ) const; std::vector summaryAndEnsembleCurves() const; std::set summaryAndEnsembleCurveDefinitions() const; @@ -131,15 +143,15 @@ class RimSummaryPlot : public RimPlot void deleteAllSummaryCurves(); RimSummaryCurveCollection* summaryCurveCollection() const; - std::vector curveSets() const; - void updatePlotTitle(); - const RimSummaryPlotNameHelper* activePlotTitleHelperAllCurves() const; - void updateCurveNames(); - QString generatedPlotTitleFromAllCurves() const; + const RimSummaryNameHelper* activePlotTitleHelperAllCurves() const; + const RimSummaryNameHelper* plotTitleHelper() const; + void updateCurveNames(); void copyAxisPropertiesFromOther( const RimSummaryPlot& sourceSummaryPlot ); + void copyAxisPropertiesFromOther( RiaDefines::PlotAxis plotAxisType, const RimSummaryPlot& sourceSummaryPlot ); + void copyMatchingAxisPropertiesFromOther( const RimSummaryPlot& sourceSummaryPlot ); void updateAll(); void updateLegend() override; @@ -152,6 +164,7 @@ class RimSummaryPlot : public RimPlot size_t singleColorCurveCount() const; void applyDefaultCurveAppearances(); + void applyDefaultCurveAppearances( std::vector curvesToUpdate ); void setNormalizationEnabled( bool enable ); bool isNormalizationEnabled(); @@ -159,16 +172,16 @@ class RimSummaryPlot : public RimPlot virtual RimSummaryPlotSourceStepping* sourceSteppingObjectForKeyEventHandling() const; virtual std::vector fieldsToShowInToolbar(); - void setAutoScaleXEnabled( bool enabled ) override; - void setAutoScaleYEnabled( bool enabled ) override; - - void zoomAll() override; - void updateZoomInQwt() override; - void updateZoomFromQwt() override; + void setAutoScaleXEnabled( bool enabled ) override; + void setAutoScaleYEnabled( bool enabled ) override; + RiuPlotWidget* plotWidget() override; + void zoomAll() override; + void updateZoomInParentPlot() override; + void updateZoomFromParentPlot() override; - caf::PdmObject* findPdmObjectFromQwtCurve( const QwtPlotCurve* curve ) const override; + caf::PdmObject* findPdmObjectFromPlotCurve( const RiuPlotCurve* curve ) const override; - void onAxisSelected( int axis, bool toggle ) override; + void onAxisSelected( RiuPlotAxis axis, bool toggle ) override; static constexpr int precision() { @@ -178,6 +191,23 @@ class RimSummaryPlot : public RimPlot static void moveCurvesToPlot( RimSummaryPlot* plot, const std::vector curves, int insertAtPosition ); + std::vector availableAxes() const override; + std::vector curvesForStepping( RimSummaryDataSourceStepping::Axis axis ) const override; + std::vector curveSets() const override; + std::vector allCurves( RimSummaryDataSourceStepping::Axis axis ) const override; + + std::vector plotAxes() const; + std::vector plotYAxes() const; + + RimPlotAxisPropertiesInterface* axisPropertiesForPlotAxis( RiuPlotAxis plotAxis ) const; + + RimPlotAxisProperties* addNewAxisProperties( RiaDefines::PlotAxis, const QString& name ); + + std::vector visibleCurvesForLegend() override; + + RimSummaryPlotSourceStepping* sourceStepper(); + void scheduleReplotIfVisible(); + public: // RimViewWindow overrides void deleteViewWidget() override; @@ -185,26 +215,32 @@ class RimSummaryPlot : public RimPlot bool isDeletable() const override; + void handleDroppedObjects( const std::vector& objects ) override; + + caf::PdmFieldHandle* userDescriptionField() override; + private: - RiuQwtPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent = nullptr ) override; + RiuPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent = nullptr ) override; void updateNameHelperWithCurveData( RimSummaryPlotNameHelper* nameHelper ) const; void doUpdateLayout() override; void detachAllPlotItems(); - - void handleKeyPressEvent( QKeyEvent* keyEvent ) override; + void deleteAllPlotCurves(); void onCurveCollectionChanged( const SignalEmitter* emitter ); + void onPlotItemSelected( std::shared_ptr plotItem, bool toggle, int sampleIndex ) override; + + void connectCurveToPlot( RimSummaryCurve* curve, bool update, bool autoAssignPlotAxis ); + + RimPlotAxisProperties* addNewAxisProperties( RiuPlotAxis plotAxis, const QString& name ); protected: - // Overridden PDM methods - caf::PdmFieldHandle* userDescriptionField() override; - void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - void childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) override; - void updateStackedCurveData(); - void updateStackedCurveDataForAxis( RiaDefines::PlotAxis plotAxis ); + void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; + void childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) override; + void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, + std::vector& referringObjects ) override; void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; @@ -212,29 +248,25 @@ class RimSummaryPlot : public RimPlot QImage snapshotWindowContent() override; - void setAsCrossPlot(); + bool handleGlobalKeyEvent( QKeyEvent* keyEvent ) override; private slots: void onPlotZoomed(); private: - std::vector visibleSummaryCurvesForAxis( RiaDefines::PlotAxis plotAxis ) const; - std::vector visibleTimeHistoryCurvesForAxis( RiaDefines::PlotAxis plotAxis ) const; - std::vector visibleAsciiDataCurvesForAxis( RiaDefines::PlotAxis plotAxis ) const; - bool hasVisibleCurvesForAxis( RiaDefines::PlotAxis plotAxis ) const; - std::vector visibleStackedSummaryCurvesForAxis( RiaDefines::PlotAxis plotAxis ); - - RimPlotAxisProperties* yAxisPropertiesLeftOrRight( RiaDefines::PlotAxis leftOrRightPlotAxis ) const; - void updateYAxis( RiaDefines::PlotAxis plotAxis ); + std::vector visibleSummaryCurvesForAxis( RiuPlotAxis plotAxis ) const; + std::vector visibleTimeHistoryCurvesForAxis( RiuPlotAxis plotAxis ) const; + std::vector visibleAsciiDataCurvesForAxis( RiuPlotAxis plotAxis ) const; + bool hasVisibleCurvesForAxis( RiuPlotAxis plotAxis ) const; + std::vector visibleStackedSummaryCurvesForAxis( RiuPlotAxis plotAxis ); - void updateZoomForAxis( RiaDefines::PlotAxis plotAxis ); + void updateAxis( RiaDefines::PlotAxis plotAxis ); - void updateTimeAxis(); - void updateBottomXAxis(); + void updateZoomForAxis( RiuPlotAxis plotAxis ); - std::set allPlotAxes() const; + void updateTimeAxis( RimSummaryTimeAxisProperties* timeAxisProperties ); - void cleanupBeforeClose(); + void deletePlotCurvesAndPlotWidget(); void connectCurveSignals( RimSummaryCurve* curve ); void disconnectCurveSignals( RimSummaryCurve* curve ); @@ -248,12 +280,35 @@ private slots: void connectAxisSignals( RimPlotAxisProperties* axis ); void axisSettingsChanged( const caf::SignalEmitter* emitter ); void axisLogarithmicChanged( const caf::SignalEmitter* emitter, bool isLogarithmic ); + void axisPositionChanged( const caf::SignalEmitter* emitter, + RimPlotAxisProperties* axisProperties, + RiuPlotAxis oldPlotAxis, + RiuPlotAxis newPlotAxis ); + + void assignPlotAxis( RimSummaryCurve* curve ); + + RimSummaryCurve* addNewCurveY( const RifEclipseSummaryAddress& address, RimSummaryCase* summaryCase ); + void addNewEnsembleCurveY( const RifEclipseSummaryAddress& address, RimSummaryCaseCollection* ensemble ); + + void updateStackedCurveData(); + bool updateStackedCurveDataForAxis( RiuPlotAxis plotAxis ); + bool updateStackedCurveDataForRelevantAxes(); + + std::pair> handleSummaryCaseDrop( RimSummaryCase* summaryCase ); + std::pair> handleAddressCollectionDrop( RimSummaryAddressCollection* addrColl ); + std::pair> handleSummaryAddressDrop( RimSummaryAddress* summaryAddr ); + + bool isOnlyWaterCutCurvesVisible( RiuPlotAxis plotAxis ); private: +#ifdef USE_QTCHARTS + caf::PdmField m_useQtChartsPlot; +#endif caf::PdmField m_normalizeCurveYValues; caf::PdmField m_useAutoPlotTitle; caf::PdmField m_description; + caf::PdmField m_fallbackPlotName; caf::PdmChildArrayField m_gridTimeHistoryCurves; caf::PdmChildField m_summaryCurveCollection; @@ -261,18 +316,23 @@ private slots: caf::PdmChildArrayField m_asciiDataCurves; - caf::PdmChildField m_leftYAxisProperties; - caf::PdmChildField m_rightYAxisProperties; + caf::PdmChildField m_leftYAxisProperties_OBSOLETE; + caf::PdmChildField m_rightYAxisProperties_OBSOLETE; + + caf::PdmChildField m_bottomAxisProperties_OBSOLETE; + caf::PdmChildField m_timeAxisProperties_OBSOLETE; - caf::PdmChildField m_bottomAxisProperties; - caf::PdmChildField m_timeAxisProperties; + caf::PdmChildArrayField m_axisProperties; caf::PdmChildField m_textCurveSetEditor; - QPointer m_plotWidget; + std::unique_ptr m_summaryPlot; std::unique_ptr m_plotInfoLabel; bool m_isCrossPlot; - std::unique_ptr m_nameHelperAllCurves; + std::unique_ptr m_nameHelperAllCurves; + caf::PdmChildField m_sourceStepping; + + bool m_isValid; }; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotAxisFormatter.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotAxisFormatter.cpp index f1552e11fe..560741ad03 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotAxisFormatter.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotAxisFormatter.cpp @@ -19,6 +19,7 @@ #include "RimSummaryPlotAxisFormatter.h" #include "RiaDefines.h" +#include "RiaNumberFormat.h" #include "RiaSummaryCurveDefinition.h" #include "RifSummaryReaderInterface.h" @@ -29,13 +30,16 @@ #include "RimSummaryCaseCollection.h" #include "RimSummaryCurve.h" +#include "RiuQtChartsPlotWidget.h" +#include "RiuQwtPlotTools.h" #include "RiuSummaryQuantityNameInfoProvider.h" #include "RiuSummaryQwtPlot.h" #include "qwt_date_scale_engine.h" +#include "qwt_plot.h" #include "qwt_plot_curve.h" #include "qwt_scale_draw.h" -#include "qwt_scale_engine.h" +#include "qwt_text.h" #include #include @@ -111,12 +115,13 @@ RimSummaryPlotAxisFormatter::RimSummaryPlotAxisFormatter( RimPlotAxisProperties* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryPlotAxisFormatter::applyAxisPropertiesToPlot( RiuQwtPlotWidget* qwtPlot ) +void RimSummaryPlotAxisFormatter::applyAxisPropertiesToPlot( RiuPlotWidget* plotWidget ) { - if ( !qwtPlot ) return; + if ( !plotWidget ) return; + RiuPlotAxis axis = m_axisProperties->plotAxisType(); { - QString axisTitle = m_axisProperties->customTitle; + QString axisTitle = m_axisProperties->customTitle(); if ( m_axisProperties->useAutoTitle() ) axisTitle = autoAxisTitle(); Qt::AlignmentFlag titleAlignment = Qt::AlignCenter; @@ -124,51 +129,77 @@ void RimSummaryPlotAxisFormatter::applyAxisPropertiesToPlot( RiuQwtPlotWidget* q { titleAlignment = Qt::AlignRight; } - qwtPlot->setAxisTitleText( m_axisProperties->qwtPlotAxisType(), axisTitle ); - qwtPlot->setAxisFontsAndAlignment( m_axisProperties->qwtPlotAxisType(), - m_axisProperties->titleFontSize(), - m_axisProperties->valuesFontSize(), - true, - titleAlignment ); - qwtPlot->setAxisTitleEnabled( m_axisProperties->qwtPlotAxisType(), true ); + + QString objectName = createAxisObjectName(); + m_axisProperties->setNameAndAxis( objectName, axisTitle, axis.axis(), axis.index() ); + plotWidget->setAxisTitleText( axis, axisTitle ); + + bool titleBold = false; + plotWidget->setAxisFontsAndAlignment( axis, + m_axisProperties->titleFontSize(), + m_axisProperties->valuesFontSize(), + titleBold, + titleAlignment ); + plotWidget->setAxisTitleEnabled( axis, true ); } + auto qwtPlotWidget = dynamic_cast( plotWidget ); + if ( qwtPlotWidget ) { - if ( m_axisProperties->numberFormat == RimPlotAxisProperties::NUMBER_FORMAT_AUTO && + auto qwtAxisId = qwtPlotWidget->toQwtPlotAxis( axis ); + + if ( m_axisProperties->numberFormat() == RimPlotAxisProperties::NUMBER_FORMAT_AUTO && m_axisProperties->scaleFactor() == 1.0 ) { // Default to Qwt's own scale draw to avoid changing too much for default values - qwtPlot->setAxisScaleDraw( m_axisProperties->qwtPlotAxisType(), new QwtScaleDraw ); + qwtPlotWidget->qwtPlot()->setAxisScaleDraw( qwtAxisId, new QwtScaleDraw ); } else { - qwtPlot->setAxisScaleDraw( m_axisProperties->qwtPlotAxisType(), - new SummaryScaleDraw( m_axisProperties->scaleFactor(), - m_axisProperties->numberOfDecimals(), - m_axisProperties->numberFormat() ) ); + qwtPlotWidget->qwtPlot()->setAxisScaleDraw( qwtAxisId, + new SummaryScaleDraw( m_axisProperties->scaleFactor(), + m_axisProperties->decimalCount(), + m_axisProperties->numberFormat() ) ); } } +#ifdef USE_QTCHARTS + auto qtChartsPlotWidget = dynamic_cast( plotWidget ); + if ( qtChartsPlotWidget ) + { + auto mapToRiaNumberFormatType = []( RimPlotAxisProperties::NumberFormatType formatType ) { + if ( formatType == RimPlotAxisProperties::NumberFormatType::NUMBER_FORMAT_DECIMAL ) + return RiaNumberFormat::NumberFormatType::FIXED; + + if ( formatType == RimPlotAxisProperties::NumberFormatType::NUMBER_FORMAT_SCIENTIFIC ) + return RiaNumberFormat::NumberFormatType::SCIENTIFIC; + + return RiaNumberFormat::NumberFormatType::AUTO; + }; + + auto formatType = mapToRiaNumberFormatType( m_axisProperties->numberFormat() ); + QString format = RiaNumberFormat::sprintfFormat( formatType, m_axisProperties->decimalCount() ); + qtChartsPlotWidget->setAxisFormat( axis, format ); + } +#endif + { - if ( m_axisProperties->isLogarithmicScaleEnabled ) + if ( m_axisProperties->isLogarithmicScaleEnabled() ) { - QwtLogScaleEngine* currentScaleEngine = - dynamic_cast( qwtPlot->axisScaleEngine( m_axisProperties->qwtPlotAxisType() ) ); - if ( !currentScaleEngine ) + bool isLogScale = plotWidget->axisScaleType( axis ) == RiuQwtPlotWidget::AxisScaleType::LOGARITHMIC; + if ( !isLogScale ) { - qwtPlot->setAxisScaleEngine( m_axisProperties->qwtPlotAxisType(), new QwtLogScaleEngine ); - qwtPlot->setAxisMaxMinor( m_axisProperties->qwtPlotAxisType(), 5 ); + plotWidget->setAxisScaleType( axis, RiuQwtPlotWidget::AxisScaleType::LOGARITHMIC ); + plotWidget->setAxisMaxMinor( axis, 5 ); } } else { - QwtLinearScaleEngine* currentScaleEngine = - dynamic_cast( qwtPlot->axisScaleEngine( m_axisProperties->qwtPlotAxisType() ) ); - QwtDateScaleEngine* dateScaleEngine = dynamic_cast( currentScaleEngine ); - if ( !currentScaleEngine || dateScaleEngine ) + bool isLinearScale = plotWidget->axisScaleType( axis ) == RiuQwtPlotWidget::AxisScaleType::LINEAR; + if ( !isLinearScale ) { - qwtPlot->setAxisScaleEngine( m_axisProperties->qwtPlotAxisType(), new QwtLinearScaleEngine ); - qwtPlot->setAxisMaxMinor( m_axisProperties->qwtPlotAxisType(), 3 ); + plotWidget->setAxisScaleType( axis, RiuQwtPlotWidget::AxisScaleType::LINEAR ); + plotWidget->setAxisMaxMinor( axis, 3 ); } } } @@ -181,56 +212,52 @@ QString RimSummaryPlotAxisFormatter::autoAxisTitle() const { std::map> unitToQuantityNameMap; - // clang-format off - auto addToUnitToQuantityMap =[&]( const std::string& unitText, - const RifEclipseSummaryAddress& sumAddress ) - { - // remove any stats prefix from the quantity name - size_t cutPos = sumAddress.quantityName().find(':'); - if (cutPos == std::string::npos) cutPos = -1; + auto addToUnitToQuantityMap = [&]( const std::string& unitText, const RifEclipseSummaryAddress& sumAddress ) { + size_t cutPos = sumAddress.vectorName().find( ':' ); + if ( cutPos == std::string::npos ) cutPos = -1; - std::string quantityNameForDisplay; - const std::string& quantityName = sumAddress.quantityName().substr(cutPos+1); + std::string titleText; + const std::string& quantityName = sumAddress.vectorName().substr( cutPos + 1 ); if ( sumAddress.category() == RifEclipseSummaryAddress::SUMMARY_CALCULATED ) { - quantityNameForDisplay = shortCalculationName( quantityName ); + titleText = shortCalculationName( quantityName ); } else { if ( m_axisProperties->showDescription() ) { - quantityNameForDisplay = - RiuSummaryQuantityNameInfoProvider::instance()->longNameFromQuantityName( quantityName ); + auto candidateName = quantityName; + + if ( sumAddress.isHistoryVector() ) candidateName = quantityName.substr( 0, quantityName.size() - 1 ); + + titleText = RiuSummaryQuantityNameInfoProvider::instance()->longNameFromVectorName( candidateName ); } if ( m_axisProperties->showAcronym() ) { - if ( !quantityNameForDisplay.empty() ) + if ( !titleText.empty() ) { - quantityNameForDisplay += " ("; - quantityNameForDisplay += quantityName; - quantityNameForDisplay += ")"; + titleText += " ("; + titleText += quantityName; + titleText += ")"; + } + else + { + titleText += quantityName; } - } - - if ( quantityNameForDisplay.empty() ) - { - quantityNameForDisplay = quantityName; } } - unitToQuantityNameMap[unitText].insert( quantityNameForDisplay ); + unitToQuantityNameMap[unitText].insert( titleText ); }; - // clang-format on - for ( RimSummaryCurve* rimCurve : m_summaryCurves ) { RifEclipseSummaryAddress sumAddress; std::string unitText; - if ( m_axisProperties->plotAxisType() == RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM ) + if ( m_axisProperties->plotAxisType().axis() == RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM ) { sumAddress = rimCurve->summaryAddressX(); unitText = rimCurve->unitNameX(); @@ -250,8 +277,8 @@ QString RimSummaryPlotAxisFormatter::autoAxisTitle() const for ( const RiaSummaryCurveDefinition& curveDef : m_curveDefinitions ) { - RifEclipseSummaryAddress sumAddress = curveDef.summaryAddress(); - std::string unitText; + const RifEclipseSummaryAddress& sumAddress = curveDef.summaryAddress(); + std::string unitText; if ( curveDef.summaryCase() && curveDef.summaryCase()->summaryReader() ) { unitText = curveDef.summaryCase()->summaryReader()->unitName( sumAddress ); @@ -259,7 +286,7 @@ QString RimSummaryPlotAxisFormatter::autoAxisTitle() const else if ( curveDef.ensemble() ) { std::vector sumCases = curveDef.ensemble()->allSummaryCases(); - if ( sumCases.size() && sumCases[0] && sumCases[0]->summaryReader() ) + if ( !sumCases.empty() && sumCases[0] && sumCases[0]->summaryReader() ) { unitText = sumCases[0]->summaryReader()->unitName( sumAddress ); } @@ -277,7 +304,7 @@ QString RimSummaryPlotAxisFormatter::autoAxisTitle() const scaleFactorText = QString( " x 10%1 " ).arg( QString::number( exponent ) ); } - for ( auto unitIt : unitToQuantityNameMap ) + for ( const auto& unitIt : unitToQuantityNameMap ) { for ( const auto& quantIt : unitIt.second ) { @@ -311,6 +338,86 @@ QString RimSummaryPlotAxisFormatter::autoAxisTitle() const return assembledYAxisText; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimSummaryPlotAxisFormatter::createAxisObjectName() const +{ + std::set vectorNames; + + auto addVectorNames = [&]( const RifEclipseSummaryAddress& sumAddress ) { + size_t cutPos = sumAddress.vectorName().find( ':' ); + if ( cutPos == std::string::npos ) cutPos = -1; + + std::string name; + const std::string& quantityName = sumAddress.vectorName().substr( cutPos + 1 ); + + if ( sumAddress.category() == RifEclipseSummaryAddress::SUMMARY_CALCULATED ) + { + name = shortCalculationName( quantityName ); + } + else + { + name = quantityName; + } + vectorNames.insert( name ); + }; + + for ( RimSummaryCurve* rimCurve : m_summaryCurves ) + { + RifEclipseSummaryAddress sumAddress; + + if ( m_axisProperties->plotAxisType().axis() == RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM ) + { + sumAddress = rimCurve->summaryAddressX(); + } + else if ( rimCurve->axisY() == this->m_axisProperties->plotAxisType() ) + { + sumAddress = rimCurve->summaryAddressY(); + } + else + { + continue; + } + + addVectorNames( sumAddress ); + } + + for ( const RiaSummaryCurveDefinition& curveDef : m_curveDefinitions ) + { + const RifEclipseSummaryAddress& sumAddress = curveDef.summaryAddress(); + + addVectorNames( sumAddress ); + } + + QString assembledAxisObjectName; + + for ( const auto& vectorName : vectorNames ) + { + assembledAxisObjectName += QString::fromStdString( vectorName ) + " "; + } + + if ( !m_timeHistoryCurveQuantities.empty() ) + { + if ( !assembledAxisObjectName.isEmpty() ) + { + assembledAxisObjectName += " : "; + } + + for ( const auto& timeQuantity : m_timeHistoryCurveQuantities ) + { + assembledAxisObjectName += timeQuantity + " "; + } + } + + const int maxChars = 100; + QFont font; + QFontMetrics fm( font ); + assembledAxisObjectName = fm.elidedText( assembledAxisObjectName, Qt::ElideRight, maxChars ); + + return assembledAxisObjectName; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotAxisFormatter.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotAxisFormatter.h index be45af8018..32d452e074 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotAxisFormatter.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotAxisFormatter.h @@ -22,16 +22,12 @@ #include #include -#include - class RimAsciiDataCurve; class RimSummaryCurve; class RimPlotAxisProperties; class RiaSummaryCurveDefinition; -class RiuQwtPlotWidget; - -class QwtPlotCurve; +class RiuPlotWidget; class RimSummaryPlotAxisFormatter { @@ -42,10 +38,11 @@ class RimSummaryPlotAxisFormatter const std::vector& asciiCurves, const std::set& timeHistoryCurveQuantities ); - void applyAxisPropertiesToPlot( RiuQwtPlotWidget* qwtPlot ); + void applyAxisPropertiesToPlot( RiuPlotWidget* qwtPlot ); private: QString autoAxisTitle() const; + QString createAxisObjectName() const; static std::string shortCalculationName( const std::string& calculationName ); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotCollection.cpp index c34ba3b365..b0f48e2e33 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotCollection.cpp @@ -37,9 +37,9 @@ CAF_PDM_SOURCE_INIT( RimSummaryPlotCollection, "SummaryPlotCollection" ); //-------------------------------------------------------------------------------------------------- RimSummaryPlotCollection::RimSummaryPlotCollection() { - CAF_PDM_InitScriptableObject( "Summary Plots", ":/SummaryPlotsLight16x16.png", "", "" ); + CAF_PDM_InitScriptableObject( "Single Summary Plots", ":/SummaryPlotsLight16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_summaryPlots, "SummaryPlots", "Summary Plots", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_summaryPlots, "SummaryPlots", "Single Summary Plots" ); m_summaryPlots.uiCapability()->setUiTreeHidden( true ); caf::PdmFieldReorderCapability::addToField( &m_summaryPlots ); } @@ -112,7 +112,7 @@ void RimSummaryPlotCollection::onChildDeleted( caf::PdmChildArrayFieldHandle* { updateSummaryNameHasChanged(); RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow(); - mainPlotWindow->updateSummaryPlotToolBar(); + mainPlotWindow->updateMultiPlotToolBar(); } //-------------------------------------------------------------------------------------------------- @@ -120,7 +120,7 @@ void RimSummaryPlotCollection::onChildDeleted( caf::PdmChildArrayFieldHandle* //-------------------------------------------------------------------------------------------------- std::vector RimSummaryPlotCollection::plots() const { - return m_summaryPlots.childObjects(); + return m_summaryPlots.children(); } //-------------------------------------------------------------------------------------------------- @@ -144,6 +144,6 @@ void RimSummaryPlotCollection::insertPlot( RimSummaryPlot* summaryPlot, size_t i //-------------------------------------------------------------------------------------------------- void RimSummaryPlotCollection::removePlot( RimSummaryPlot* summaryPlot ) { - m_summaryPlots.removeChildObject( summaryPlot ); + m_summaryPlots.removeChild( summaryPlot ); updateAllRequiredEditors(); } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotControls.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotControls.cpp new file mode 100644 index 0000000000..7b5482798b --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotControls.cpp @@ -0,0 +1,67 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimSummaryPlotControls.h" + +#include "RimSummaryPlotSourceStepping.h" + +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryPlotControls::handleKeyEvents( RimSummaryPlotSourceStepping* srcStepping, QKeyEvent* keyEvent ) +{ + if ( !keyEvent ) return false; + if ( !srcStepping ) return false; + + if ( !( keyEvent->modifiers() & Qt::ControlModifier ) ) return false; + + bool bHandled = false; + + if ( keyEvent->key() == Qt::Key_Up ) + { + srcStepping->applyPrevStep(); + keyEvent->accept(); + bHandled = true; + } + else if ( keyEvent->key() == Qt::Key_Down ) + { + srcStepping->applyNextStep(); + keyEvent->accept(); + bHandled = true; + } + + return bHandled; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimSummaryPlotControls::nextStepKeyText() +{ + return QString( "Ctrl-Down" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimSummaryPlotControls::prevStepKeyText() +{ + return QString( "Ctrl-Up" ); +} diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotControls.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotControls.h new file mode 100644 index 0000000000..3d36431cc4 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotControls.h @@ -0,0 +1,36 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +class RimSummaryPlotSourceStepping; +class QKeyEvent; + +#include + +class RimSummaryPlotControls +{ +public: + static bool handleKeyEvents( RimSummaryPlotSourceStepping* srcStepping, QKeyEvent* keyEvent ); + + static QString nextStepKeyText(); + static QString prevStepKeyText(); + +private: + RimSummaryPlotControls() = default; +}; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotFilterTextCurveSetEditor.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotFilterTextCurveSetEditor.cpp index 937f223403..a787a8a2a1 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotFilterTextCurveSetEditor.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotFilterTextCurveSetEditor.cpp @@ -20,9 +20,12 @@ #include "RiaGuiApplication.h" #include "RiaLogging.h" +#include "RiaStdStringTools.h" #include "RiaStringListSerializer.h" #include "RiaSummaryCurveDefinition.h" +#include "RiaTextStringTools.h" +#include "RifReaderEclipseSummary.h" #include "RifSummaryReaderInterface.h" #include "RigCaseCellResultsData.h" #include "RigEclipseCaseData.h" @@ -68,7 +71,7 @@ CAF_PDM_SOURCE_INIT( RimSummaryPlotFilterTextCurveSetEditor, "SummaryPlotFilterT RimSummaryPlotFilterTextCurveSetEditor::RimSummaryPlotFilterTextCurveSetEditor() : m_isFieldRecentlyChangedFromGui( false ) { - CAF_PDM_InitObject( "Curve Set Filter Text", "", "", "" ); + CAF_PDM_InitObject( "Curve Set Filter Text" ); // clang-format off QString filterTextHeading = "Create Summary Curves from Text"; @@ -85,7 +88,7 @@ RimSummaryPlotFilterTextCurveSetEditor::RimSummaryPlotFilterTextCurveSetEditor() QString toolTipPropertyEditor = filterTextHeading + "\n\n" + filterTextToolTip; QString toolTipToolbar = filterTextHeading + filterTextShortcut + "\n\n" + filterTextToolTip; - CAF_PDM_InitFieldNoDefault( &m_curveFilterLabelText, "Summary", "Summary", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_curveFilterLabelText, "Summary", "Summary" ); m_curveFilterLabelText.uiCapability()->setUiEditorTypeName( caf::PdmUiLabelEditor::uiEditorTypeName() ); m_curveFilterLabelText.xmlCapability()->disableIO(); @@ -96,7 +99,7 @@ RimSummaryPlotFilterTextCurveSetEditor::RimSummaryPlotFilterTextCurveSetEditor() // Special tool tip for toolbar m_curveFilterText.uiCapability()->setUiToolTip( toolTipToolbar, caf::PdmUiToolBarEditor::uiEditorConfigName() ); - CAF_PDM_InitFieldNoDefault( &m_selectedSources, "SummaryCases", "Sources", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_selectedSources, "SummaryCases", "Sources" ); m_selectedSources.uiCapability()->setAutoAddingOptionFromValue( false ); m_selectedSources.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); m_selectedSources.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); @@ -173,7 +176,7 @@ void RimSummaryPlotFilterTextCurveSetEditor::updateTextFilter() if ( !usedSources.empty() ) { - m_selectedSources.clear(); + m_selectedSources.clearWithoutDelete(); m_selectedSources.setValue( usedSources ); } @@ -181,14 +184,14 @@ void RimSummaryPlotFilterTextCurveSetEditor::updateTextFilter() // Todo: possibly check grid time history curves also QStringList allCurveAddressFilters = - curveFilterTextWithoutOutdatedLabel().split( QRegExp( "\\s+" ), QString::SkipEmptyParts ); + RiaTextStringTools::splitSkipEmptyParts( curveFilterTextWithoutOutdatedLabel(), QRegExp( "\\s+" ) ); std::vector usedFilters; std::set filteredAddressesFromSource; - RicSummaryPlotFeatureImpl::filteredSummaryAdressesFromCase( allCurveAddressFilters, - addressesInUse, - &filteredAddressesFromSource, - &usedFilters ); + RicSummaryPlotFeatureImpl::insertFilteredAddressesInSet( allCurveAddressFilters, + addressesInUse, + &filteredAddressesFromSource, + &usedFilters ); if ( filteredAddressesFromSource != addressesInUse ) { @@ -209,6 +212,219 @@ void RimSummaryPlotFilterTextCurveSetEditor::updateTextFilter() void RimSummaryPlotFilterTextCurveSetEditor::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) +{ + updateParentPlot(); + + if ( changedField == &m_curveFilterText ) + { + m_curveFilterText = curveFilterTextWithoutOutdatedLabel(); + + { + RiaStringListSerializer stringListSerializer( curveFilterRecentlyUsedRegistryKey() ); + + int maxItemCount = 10; + stringListSerializer.addString( m_curveFilterText, maxItemCount ); + } + + m_curveFilterText.uiCapability()->updateConnectedEditors(); + } + + m_isFieldRecentlyChangedFromGui = true; + + if ( RiaGuiApplication::isRunning() ) + { + RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow(); + if ( mainPlotWindow ) + { + mainPlotWindow->updateMultiPlotToolBar(); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlotFilterTextCurveSetEditor::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +{ + uiOrdering.add( &m_curveFilterText ); + uiOrdering.add( &m_selectedSources ); + uiOrdering.skipRemainingFields(); + + if ( !m_isFieldRecentlyChangedFromGui ) + { + updateTextFilter(); + } + + m_isFieldRecentlyChangedFromGui = false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlotFilterTextCurveSetEditor::setupBeforeSave() +{ + m_curveFilterText = curveFilterTextWithoutOutdatedLabel(); + + // If a source case has been deleted, make sure null pointers are removed + m_selectedSources.removePtr( nullptr ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlotFilterTextCurveSetEditor::defineEditorAttribute( const caf::PdmFieldHandle* field, + QString uiConfigName, + caf::PdmUiEditorAttribute* attribute ) +{ + if ( field == &m_curveFilterText ) + { + auto attr = dynamic_cast( attribute ); + if ( attr ) + { + attr->enableEditableContent = true; + attr->adjustWidthToContents = true; + attr->placeholderText = "Click to edit curves"; + + if ( uiConfigName == caf::PdmUiToolBarEditor::uiEditorConfigName() ) + { + attr->minimumWidth = 140; + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList + RimSummaryPlotFilterTextCurveSetEditor::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) +{ + QList options; + if ( fieldNeedingOptions == &m_selectedSources ) + { + appendOptionItemsForSources( options ); + } + + if ( fieldNeedingOptions == &m_curveFilterText ) + { + RiaStringListSerializer stringListSerializer( curveFilterRecentlyUsedRegistryKey() ); + + for ( const auto& s : stringListSerializer.textStrings() ) + { + options.push_back( caf::PdmOptionItemInfo( s, s ) ); + } + } + + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlotFilterTextCurveSetEditor::appendOptionItemsForSources( QList& options ) +{ + RimProject* proj = RimProject::current(); + + std::vector oilFields; + + proj->allOilFields( oilFields ); + for ( RimOilField* oilField : oilFields ) + { + RimSummaryCaseMainCollection* sumCaseMainColl = oilField->summaryCaseMainCollection(); + if ( sumCaseMainColl ) + { + // Top level cases + for ( const auto& sumCase : sumCaseMainColl->topLevelSummaryCases() ) + { + options.push_back( caf::PdmOptionItemInfo( sumCase->displayCaseName(), sumCase ) ); + } + + // Ensembles + bool ensembleHeaderCreated = false; + for ( const auto& sumCaseColl : sumCaseMainColl->summaryCaseCollections() ) + { + if ( !sumCaseColl->isEnsemble() ) continue; + + if ( !ensembleHeaderCreated ) + { + options.push_back( caf::PdmOptionItemInfo::createHeader( "Ensembles", true ) ); + ensembleHeaderCreated = true; + } + + auto optionItem = caf::PdmOptionItemInfo( sumCaseColl->name(), sumCaseColl ); + optionItem.setLevel( 1 ); + options.push_back( optionItem ); + } + + // Grouped cases + for ( const auto& sumCaseColl : sumCaseMainColl->summaryCaseCollections() ) + { + if ( sumCaseColl->isEnsemble() ) continue; + + options.push_back( caf::PdmOptionItemInfo::createHeader( sumCaseColl->name(), true ) ); + + for ( const auto& sumCase : sumCaseColl->allSummaryCases() ) + { + auto optionItem = caf::PdmOptionItemInfo( sumCase->displayCaseName(), sumCase ); + optionItem.setLevel( 1 ); + options.push_back( optionItem ); + } + } + + // Observed data + auto observedDataColl = oilField->observedDataCollection(); + if ( observedDataColl->allObservedSummaryData().size() > 0 ) + { + options.push_back( caf::PdmOptionItemInfo::createHeader( "Observed Data", true ) ); + + for ( const auto& obsData : observedDataColl->allObservedSummaryData() ) + { + auto optionItem = caf::PdmOptionItemInfo( obsData->caseName(), obsData ); + optionItem.setLevel( 1 ); + options.push_back( optionItem ); + } + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimSummaryPlotFilterTextCurveSetEditor::selectedSummarySources() const +{ + std::vector sources; + + for ( const auto& source : m_selectedSources ) + { + sources.push_back( source ); + } + + // Always add the summary case for calculated curves as this case is not displayed in UI + sources.push_back( RimProject::current()->calculationCollection()->calculationSummaryCase() ); + + return sources; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimSummaryPlotFilterTextCurveSetEditor::curveFilterTextWithoutOutdatedLabel() const +{ + QString filterText = m_curveFilterText(); + + if ( filterText.startsWith( FILTER_TEXT_OUTDATED_TEXT ) ) + { + return filterText.right( filterText.length() - QString( FILTER_TEXT_OUTDATED_TEXT ).length() ); + } + + return filterText; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlotFilterTextCurveSetEditor::updateParentPlot() { RimSummaryPlot* parentPlot; this->firstAncestorOrThisOfType( parentPlot ); @@ -224,43 +440,28 @@ void RimSummaryPlotFilterTextCurveSetEditor::fieldChangedByUi( const caf::PdmFie std::set curveDefinitions; QStringList allCurveAddressFilters = - curveFilterTextWithoutOutdatedLabel().split( QRegExp( "\\s+" ), QString::SkipEmptyParts ); + RiaTextStringTools::splitSkipEmptyParts( curveFilterTextWithoutOutdatedLabel(), QRegExp( "\\s+" ) ); std::vector accumulatedUsedFilters( allCurveAddressFilters.size(), false ); for ( SummarySource* currSource : selectedSummarySources() ) { - RimSummaryCaseCollection* ensemble = dynamic_cast( currSource ); - RimSummaryCase* sumCase = dynamic_cast( currSource ); - - std::set allAddressesFromSource; - - if ( ensemble ) - { - auto addresses = ensemble->ensembleSummaryAddresses(); - allAddressesFromSource.insert( addresses.begin(), addresses.end() ); - } - else if ( sumCase ) - { - RifSummaryReaderInterface* reader = sumCase ? sumCase->summaryReader() : nullptr; - if ( reader ) - { - allAddressesFromSource.insert( reader->allResultAddresses().begin(), - reader->allResultAddresses().end() ); - } - } + std::set allAddressesFromSource = addressesForSource( currSource ); std::vector usedFilters; std::set filteredAddressesFromSource; - RicSummaryPlotFeatureImpl::filteredSummaryAdressesFromCase( allCurveAddressFilters, - allAddressesFromSource, - &filteredAddressesFromSource, - &usedFilters ); + insertFilteredAddressesInSet( allCurveAddressFilters, + allAddressesFromSource, + &filteredAddressesFromSource, + &usedFilters ); for ( size_t fIdx = 0; fIdx < accumulatedUsedFilters.size(); ++fIdx ) { accumulatedUsedFilters[fIdx] = accumulatedUsedFilters[fIdx] || usedFilters[fIdx]; } + auto sumCase = dynamic_cast( currSource ); + auto ensemble = dynamic_cast( currSource ); + for ( const auto& filteredAddress : filteredAddressesFromSource ) { if ( sumCase ) @@ -386,223 +587,62 @@ void RimSummaryPlotFilterTextCurveSetEditor::fieldChangedByUi( const caf::PdmFie parentPlot->updateConnectedEditors(); } - - if ( changedField == &m_curveFilterText ) - { - m_curveFilterText = curveFilterTextWithoutOutdatedLabel(); - - { - RiaStringListSerializer stringListSerializer( curveFilterRecentlyUsedRegistryKey() ); - - int maxItemCount = 10; - stringListSerializer.addString( m_curveFilterText, maxItemCount ); - } - - m_curveFilterText.uiCapability()->updateConnectedEditors(); - } - - m_isFieldRecentlyChangedFromGui = true; - - if ( RiaGuiApplication::isRunning() ) - { - RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow(); - if ( mainPlotWindow ) - { - mainPlotWindow->updateSummaryPlotToolBar(); - } - } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryPlotFilterTextCurveSetEditor::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +std::set RimSummaryPlotFilterTextCurveSetEditor::addressesForSource( SummarySource* summarySource ) { - uiOrdering.add( &m_curveFilterText ); - uiOrdering.add( &m_selectedSources ); - uiOrdering.skipRemainingFields(); - - if ( !m_isFieldRecentlyChangedFromGui ) + auto* ensemble = dynamic_cast( summarySource ); + if ( ensemble ) { - updateTextFilter(); - } - - m_isFieldRecentlyChangedFromGui = false; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimSummaryPlotFilterTextCurveSetEditor::setupBeforeSave() -{ - m_curveFilterText = curveFilterTextWithoutOutdatedLabel(); - - // If a source case has been deleted, make sure null pointers are removed - m_selectedSources.removePtr( nullptr ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimSummaryPlotFilterTextCurveSetEditor::defineEditorAttribute( const caf::PdmFieldHandle* field, - QString uiConfigName, - caf::PdmUiEditorAttribute* attribute ) -{ - if ( field == &m_curveFilterText ) - { - auto attr = dynamic_cast( attribute ); - if ( attr ) - { - attr->enableEditableContent = true; - attr->adjustWidthToContents = true; - attr->placeholderText = "Click to edit curves"; - - if ( uiConfigName == caf::PdmUiToolBarEditor::uiEditorConfigName() ) - { - attr->minimumWidth = 140; - } - } + return ensemble->ensembleSummaryAddresses(); } -} -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QList - RimSummaryPlotFilterTextCurveSetEditor::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) -{ - QList options; - if ( fieldNeedingOptions == &m_selectedSources ) - { - appendOptionItemsForSources( options, false, false ); - } + auto* sumCase = dynamic_cast( summarySource ); - if ( fieldNeedingOptions == &m_curveFilterText ) + if ( sumCase ) { - RiaStringListSerializer stringListSerializer( curveFilterRecentlyUsedRegistryKey() ); - - for ( const auto& s : stringListSerializer.textStrings() ) + RifSummaryReaderInterface* reader = sumCase ? sumCase->summaryReader() : nullptr; + if ( reader ) { - options.push_back( caf::PdmOptionItemInfo( s, s ) ); + return reader->allResultAddresses(); } } - return options; + return {}; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryPlotFilterTextCurveSetEditor::appendOptionItemsForSources( QList& options, - bool hideSummaryCases, - bool hideEnsembles ) +void RimSummaryPlotFilterTextCurveSetEditor::insertFilteredAddressesInSet( + const QStringList& curveFilters, + const std::set& allAddressesInCase, + std::set* setToInsertFilteredAddressesIn, + std::vector* usedFilters ) { - RimProject* proj = RimProject::current(); + std::set candidateAddresses; + RicSummaryPlotFeatureImpl::insertFilteredAddressesInSet( curveFilters, allAddressesInCase, &candidateAddresses, usedFilters ); - std::vector oilFields; - - proj->allOilFields( oilFields ); - for ( RimOilField* oilField : oilFields ) + if ( !m_includeDiffCurves ) { - RimSummaryCaseMainCollection* sumCaseMainColl = oilField->summaryCaseMainCollection(); - if ( sumCaseMainColl ) - { - if ( !hideSummaryCases ) - { - // Top level cases - for ( const auto& sumCase : sumCaseMainColl->topLevelSummaryCases() ) - { - options.push_back( caf::PdmOptionItemInfo( sumCase->displayCaseName(), sumCase ) ); - } - } - - // Ensembles - if ( !hideEnsembles ) - { - bool ensembleHeaderCreated = false; - for ( const auto& sumCaseColl : sumCaseMainColl->summaryCaseCollections() ) - { - if ( !sumCaseColl->isEnsemble() ) continue; - - if ( !ensembleHeaderCreated ) - { - options.push_back( caf::PdmOptionItemInfo::createHeader( "Ensembles", true ) ); - ensembleHeaderCreated = true; - } - - auto optionItem = caf::PdmOptionItemInfo( sumCaseColl->name(), sumCaseColl ); - optionItem.setLevel( 1 ); - options.push_back( optionItem ); - } - } - - if ( !hideSummaryCases ) - { - // Grouped cases - for ( const auto& sumCaseColl : sumCaseMainColl->summaryCaseCollections() ) - { - if ( sumCaseColl->isEnsemble() ) continue; - - options.push_back( caf::PdmOptionItemInfo::createHeader( sumCaseColl->name(), true ) ); + std::set tmp; - for ( const auto& sumCase : sumCaseColl->allSummaryCases() ) - { - auto optionItem = caf::PdmOptionItemInfo( sumCase->displayCaseName(), sumCase ); - optionItem.setLevel( 1 ); - options.push_back( optionItem ); - } - } + const auto diffText = RifReaderEclipseSummary::differenceIdentifier(); - // Observed data - auto observedDataColl = oilField->observedDataCollection(); - if ( observedDataColl->allObservedSummaryData().size() > 0 ) - { - options.push_back( caf::PdmOptionItemInfo::createHeader( "Observed Data", true ) ); + for ( const auto& adr : candidateAddresses ) + { + if ( RiaStdStringTools::endsWith( adr.vectorName(), diffText ) ) continue; - for ( const auto& obsData : observedDataColl->allObservedSummaryData() ) - { - auto optionItem = caf::PdmOptionItemInfo( obsData->caseName(), obsData ); - optionItem.setLevel( 1 ); - options.push_back( optionItem ); - } - } - } + tmp.insert( adr ); } - } -} -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RimSummaryPlotFilterTextCurveSetEditor::selectedSummarySources() const -{ - std::vector sources; - - for ( const auto& source : m_selectedSources ) - { - sources.push_back( source ); + std::swap( tmp, candidateAddresses ); } - // Always add the summary case for calculated curves as this case is not displayed in UI - sources.push_back( RimProject::current()->calculationCollection()->calculationSummaryCase() ); - - return sources; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RimSummaryPlotFilterTextCurveSetEditor::curveFilterTextWithoutOutdatedLabel() const -{ - QString filterText = m_curveFilterText(); - - if ( filterText.startsWith( FILTER_TEXT_OUTDATED_TEXT ) ) - { - return filterText.right( filterText.length() - QString( FILTER_TEXT_OUTDATED_TEXT ).length() ); - } - - return filterText; + setToInsertFilteredAddressesIn->insert( candidateAddresses.begin(), candidateAddresses.end() ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotFilterTextCurveSetEditor.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotFilterTextCurveSetEditor.h index 794e5d2d2d..2a0f6f7850 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotFilterTextCurveSetEditor.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotFilterTextCurveSetEditor.h @@ -21,6 +21,7 @@ #include "cafPdmPtrArrayField.h" using SummarySource = caf::PdmObject; +class RifEclipseSummaryAddress; class RimSummaryPlotFilterTextCurveSetEditor : public caf::PdmObject { @@ -36,8 +37,7 @@ class RimSummaryPlotFilterTextCurveSetEditor : public caf::PdmObject void updateTextFilter(); protected: - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; @@ -47,12 +47,20 @@ class RimSummaryPlotFilterTextCurveSetEditor : public caf::PdmObject caf::PdmUiEditorAttribute* attribute ) override; private: - static void - appendOptionItemsForSources( QList& options, bool hideSummaryCases, bool hideEnsembles ); + static void appendOptionItemsForSources( QList& options ); std::vector selectedSummarySources() const; QString curveFilterTextWithoutOutdatedLabel() const; + void updateParentPlot(); + + static std::set addressesForSource( SummarySource* summarySource ); + + void insertFilteredAddressesInSet( const QStringList& curveFilters, + const std::set& allAddressesInCase, + std::set* setToInsertFilteredAddressesIn, + std::vector* usedFilters ); + static QString curveFilterRecentlyUsedRegistryKey(); private: @@ -60,6 +68,7 @@ class RimSummaryPlotFilterTextCurveSetEditor : public caf::PdmObject caf::PdmField m_curveFilterLabelText; caf::PdmField m_curveFilterText; + caf::PdmField m_includeDiffCurves; bool m_isFieldRecentlyChangedFromGui; }; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotManager.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotManager.cpp new file mode 100644 index 0000000000..3b263fe4e5 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotManager.cpp @@ -0,0 +1,628 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimSummaryPlotManager.h" + +#include "RiaStdStringTools.h" +#include "RiaStringListSerializer.h" +#include "RiaSummaryStringTools.h" +#include "RiaSummaryTools.h" +#include "RiaTextStringTools.h" + +#include "RifReaderEclipseSummary.h" +#include "RifSummaryReaderInterface.h" + +#include "RimEnsembleCurveSet.h" +#include "RimEnsembleCurveSetCollection.h" +#include "RimMainPlotCollection.h" +#include "RimMultiPlotCollection.h" +#include "RimProject.h" +#include "RimSummaryCase.h" +#include "RimSummaryCaseCollection.h" +#include "RimSummaryCaseMainCollection.h" +#include "RimSummaryCurve.h" +#include "RimSummaryMultiPlotCollection.h" +#include "RimSummaryPlot.h" + +#include "PlotBuilderCommands/RicSummaryPlotBuilder.h" +#include "SummaryPlotCommands/RicSummaryPlotFeatureImpl.h" + +#include "RiuPlotMainWindowTools.h" + +#include "cafPdmObjectHandle.h" +#include "cafPdmUiCheckBoxEditor.h" +#include "cafPdmUiComboBoxEditor.h" +#include "cafPdmUiLabelEditor.h" +#include "cafPdmUiLineEditor.h" +#include "cafPdmUiPushButtonEditor.h" +#include "cafPdmUiTextEditor.h" +#include "cafPdmUiTreeSelectionEditor.h" +#include "cafSelectionManager.h" + +// Multi plot +#include "RimMainPlotCollection.h" +#include "RimMultiPlotCollection.h" +#include "RimProject.h" +#include "RimSummaryMultiPlot.h" + +#include + +CAF_PDM_SOURCE_INIT( RimSummaryPlotManager, "RimSummaryPlotManager" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryPlotManager::RimSummaryPlotManager() +{ + CAF_PDM_InitObject( "Summary Plot Manager" ); + + CAF_PDM_InitFieldNoDefault( &m_summaryPlot, "SummaryPlot", "Summary Plot" ); + CAF_PDM_InitFieldNoDefault( &m_filterText, "FilterText", "Filter Text" ); + m_filterText.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); + + CAF_PDM_InitFieldNoDefault( &m_addressCandidates, "AddressCandidates", "Vectors" ); + m_addressCandidates.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); + m_addressCandidates.uiCapability()->setUiReadOnly( true ); + + CAF_PDM_InitFieldNoDefault( &m_selectedDataSources, "SelectedDataSources", "Data Sources" ); + m_selectedDataSources.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); + m_selectedDataSources.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); + + CAF_PDM_InitField( &m_includeDiffCurves, + "IncludeDiffCurves", + false, + "Include Difference Vectors", + "", + "Difference between simulated and observed(history) curve", + "" ); + m_includeDiffCurves.uiCapability()->setUiEditorTypeName( caf::PdmUiNativeCheckBoxEditor::uiEditorTypeName() ); + + CAF_PDM_InitFieldNoDefault( &m_pushButtonReplace, "PushButtonReplace", "Replace (CTRL + Enter)" ); + m_pushButtonReplace.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); + m_pushButtonReplace.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); + + CAF_PDM_InitFieldNoDefault( &m_pushButtonNewPlot, "PushButtonNewPlot", "New (Alt + Enter)" ); + m_pushButtonNewPlot.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); + m_pushButtonNewPlot.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); + + CAF_PDM_InitFieldNoDefault( &m_pushButtonAppend, "PushButtonAppend", "Append (Shift + Enter)" ); + m_pushButtonAppend.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); + m_pushButtonAppend.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); + + CAF_PDM_InitFieldNoDefault( &m_labelA, "LabelA", "" ); + m_labelA.uiCapability()->setUiEditorTypeName( caf::PdmUiLabelEditor::uiEditorTypeName() ); + m_labelA.xmlCapability()->disableIO(); + m_labelA.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); + + CAF_PDM_InitFieldNoDefault( &m_labelB, "LabelB", "" ); + m_labelB.uiCapability()->setUiEditorTypeName( caf::PdmUiLabelEditor::uiEditorTypeName() ); + m_labelB.xmlCapability()->disableIO(); + + CAF_PDM_InitField( &m_individualPlotPerObject, "IndividualPlotPerObject", true, "One plot per Object" ); + caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_individualPlotPerObject ); + + CAF_PDM_InitField( &m_individualPlotPerVector, "IndividualPlotPerVector", false, "One plot per Vector" ); + caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_individualPlotPerVector ); + + CAF_PDM_InitField( &m_individualPlotPerDataSource, "IndividualPlotPerDataSource", false, "One plot per Data Source" ); + caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_individualPlotPerDataSource ); + + CAF_PDM_InitField( &m_createMultiPlot, "CreateMultiPlot", true, "Create Multiple Plots in One Window" ); + caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_createMultiPlot ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlotManager::setFocusToFilterText() +{ + setFocusToEditorWidget( m_filterText.uiCapability() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlotManager::resetDataSourceSelection() +{ + m_previousDataSourceText.clear(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlotManager::onSelectionManagerSelectionChanged( const std::set& changedSelectionLevels ) +{ + updateUiFromSelection(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlotManager::fieldChangedByUi( const caf::PdmFieldHandle* changedField, + const QVariant& oldValue, + const QVariant& newValue ) +{ + if ( changedField == &m_summaryPlot || changedField == &m_filterText || changedField == &m_includeDiffCurves || + changedField == &m_selectedDataSources ) + { + updateSelectionFromUiChange(); + updateCurveCandidates(); + } + else if ( changedField == &m_pushButtonReplace ) + { + replaceCurves(); + m_pushButtonReplace = false; + updateFilterTextHistory(); + } + else if ( changedField == &m_pushButtonNewPlot ) + { + createNewPlot(); + m_pushButtonNewPlot = false; + updateFilterTextHistory(); + } + else if ( changedField == &m_pushButtonAppend ) + { + appendCurves(); + m_pushButtonAppend = false; + updateFilterTextHistory(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimSummaryPlotManager::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) +{ + QList options; + if ( fieldNeedingOptions == &m_summaryPlot ) + { + auto coll = RiaSummaryTools::summaryMultiPlotCollection(); + coll->summaryPlotItemInfos( &options ); + } + else if ( fieldNeedingOptions == &m_filterText ) + { + RiaStringListSerializer stringListSerializer( curveFilterRecentlyUsedRegistryKey() ); + + for ( const auto& s : stringListSerializer.textStrings() ) + { + options.push_back( caf::PdmOptionItemInfo( s, s ) ); + } + } + else if ( fieldNeedingOptions == &m_selectedDataSources ) + { + for ( const auto& displayName : dataSourceDisplayNames() ) + { + options.push_back( caf::PdmOptionItemInfo( displayName, displayName ) ); + } + + updateSelectionFromUiChange(); + } + + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlotManager::updateCurveCandidates() +{ + std::vector curveCandidates; + + auto addresses = filteredAddresses(); + + for ( const auto& adr : addresses ) + { + curveCandidates.push_back( QString::fromStdString( adr.uiText() ) ); + } + + m_addressCandidates = curveCandidates; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector> RimSummaryPlotManager::findDataSourceCandidates() const +{ + std::vector> candidates; + + QStringList dataSourceFilters = extractDataSourceFilters(); + + auto [summaryCases, ensembles] = RiaSummaryStringTools::dataSourcesMatchingFilters( dataSourceFilters ); + + for ( auto ensemble : ensembles ) + { + auto ensembleName = ensemble->name(); + + candidates.push_back( std::make_pair( ensembleName, ensemble ) ); + } + + for ( const auto& summaryCase : summaryCases ) + { + auto summaryCaseName = summaryCase->displayCaseName(); + + QString displayName; + auto ensemble = summaryCase->ensemble(); + if ( ensemble ) + { + displayName = ensemble->name() + ":" + summaryCaseName; + } + else + { + displayName = summaryCaseName; + } + + candidates.push_back( std::make_pair( displayName, summaryCase ) ); + } + + return candidates; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimSummaryPlotManager::dataSourceDisplayNames() const +{ + std::vector displayNames; + std::vector> dataSources = findDataSourceCandidates(); + for ( const auto& dataSource : dataSources ) + { + auto displayName = dataSource.first; + displayNames.push_back( displayName ); + } + + return displayNames; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlotManager::defineEditorAttribute( const caf::PdmFieldHandle* field, + QString uiConfigName, + caf::PdmUiEditorAttribute* attribute ) +{ + { + auto attr = dynamic_cast( attribute ); + if ( attr ) + { + if ( field == &m_pushButtonReplace ) + { + attr->m_buttonText = "Replace Curves \n(Ctrl + Enter)"; + } + if ( field == &m_pushButtonNewPlot ) + { + attr->m_buttonText = "Create New Plot \n(Enter)"; + } + if ( field == &m_pushButtonAppend ) + { + attr->m_buttonText = "Append Curves \n(Shift + Enter)"; + } + } + } + + if ( field == &m_filterText ) + { + auto attr = dynamic_cast( attribute ); + if ( attr ) + { + attr->enableEditableContent = true; + attr->enableAutoComplete = false; + attr->adjustWidthToContents = true; + attr->notifyWhenTextIsEdited = true; + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlotManager::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +{ + uiOrdering.add( &m_summaryPlot ); + + uiOrdering.add( &m_includeDiffCurves ); + + uiOrdering.add( &m_filterText ); + uiOrdering.add( &m_addressCandidates ); + uiOrdering.add( &m_selectedDataSources, false ); + + uiOrdering.add( &m_individualPlotPerVector ); + uiOrdering.add( &m_individualPlotPerDataSource, false ); + uiOrdering.add( &m_individualPlotPerObject ); + uiOrdering.add( &m_createMultiPlot, false ); + + uiOrdering.add( &m_pushButtonAppend ); + uiOrdering.add( &m_pushButtonReplace, { false } ); + uiOrdering.add( &m_labelB, { false } ); + uiOrdering.add( &m_pushButtonNewPlot, { false } ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlotManager::appendCurves() +{ + if ( !m_summaryPlot ) return; + + appendCurvesToPlot( m_summaryPlot ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlotManager::replaceCurves() +{ + if ( !m_summaryPlot ) return; + + RimSummaryPlot* destinationPlot = m_summaryPlot; + destinationPlot->deleteAllSummaryCurves(); + destinationPlot->ensembleCurveSetCollection()->deleteAllCurveSets(); + + RiuPlotMainWindowTools::selectAsCurrentItem( destinationPlot ); + + appendCurvesToPlot( destinationPlot ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlotManager::createNewPlot() +{ + if ( m_filterText().trimmed().isEmpty() ) return; + + std::vector summaryCases; + std::vector ensembles; + findFilteredSummaryCasesAndEnsembles( summaryCases, ensembles ); + + std::set filteredAddressesFromSource = filteredAddresses(); + + RicSummaryPlotBuilder plotBuilder; + plotBuilder.setAddresses( filteredAddressesFromSource ); + plotBuilder.setDataSources( summaryCases, ensembles ); + + RicSummaryPlotBuilder::RicGraphCurveGrouping groping = RicSummaryPlotBuilder::RicGraphCurveGrouping::NONE; + if ( m_individualPlotPerVector ) groping = RicSummaryPlotBuilder::RicGraphCurveGrouping::SINGLE_CURVES; + if ( m_individualPlotPerObject ) groping = RicSummaryPlotBuilder::RicGraphCurveGrouping::CURVES_FOR_OBJECT; + plotBuilder.setGrouping( groping ); + + auto plots = plotBuilder.createPlots(); + if ( m_createMultiPlot ) + { + auto summaryPlots = plotBuilder.createPlots(); + RicSummaryPlotBuilder::createAndAppendSummaryMultiPlot( summaryPlots ); + } + else + { + for ( auto plot : plots ) + { + RicSummaryPlotBuilder::createAndAppendSingleSummaryMultiPlot( plot ); + plot->loadDataAndUpdate(); + } + } + + updateProjectTreeAndRefresUi(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryPlotManager::eventFilter( QObject* obj, QEvent* event ) +{ + if ( event->type() == QEvent::KeyPress ) + { + QKeyEvent* keyEvent = static_cast( event ); + + if ( keyEvent && ( keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Return ) ) + { + auto mods = keyEvent->modifiers(); + + if ( mods & Qt::ShiftModifier ) + appendCurves(); + else if ( mods & Qt::ControlModifier ) + replaceCurves(); + else if ( mods == Qt::NoModifier ) + createNewPlot(); + } + } + + return QObject::eventFilter( obj, event ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlotManager::updateUiFromSelection() +{ + auto destinationObject = dynamic_cast( caf::SelectionManager::instance()->selectedItem() ); + + RimSummaryPlot* summaryPlot = nullptr; + if ( destinationObject ) destinationObject->firstAncestorOrThisOfType( summaryPlot ); + + if ( summaryPlot && ( m_summaryPlot() != summaryPlot ) ) + { + m_summaryPlot = summaryPlot; + + updateSelectionFromUiChange(); + updateCurveCandidates(); + } + + updateConnectedEditors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::set RimSummaryPlotManager::filteredAddresses() +{ + std::vector summaryCases; + std::vector ensembles; + findFilteredSummaryCasesAndEnsembles( summaryCases, ensembles ); + + std::set nativeAddresses; + if ( !summaryCases.empty() ) + { + nativeAddresses = RicSummaryPlotBuilder::addressesForSource( summaryCases.front() ); + } + else if ( !ensembles.empty() ) + { + nativeAddresses = RicSummaryPlotBuilder::addressesForSource( ensembles.front() ); + } + + if ( nativeAddresses.empty() ) return {}; + + QStringList allCurveAddressFilters = RiaTextStringTools::splitSkipEmptyParts( m_filterText(), QRegExp( "\\s+" ) ); + + return RiaSummaryStringTools::computeFilteredAddresses( allCurveAddressFilters, nativeAddresses, m_includeDiffCurves ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlotManager::appendCurvesToPlot( RimSummaryPlot* destinationPlot ) +{ + CAF_ASSERT( destinationPlot ); + + std::vector summaryCases; + std::vector ensembles; + findFilteredSummaryCasesAndEnsembles( summaryCases, ensembles ); + + std::set filteredAddressesFromSource = filteredAddresses(); + RicSummaryPlotBuilder::appendCurvesToPlot( destinationPlot, filteredAddressesFromSource, summaryCases, ensembles ); + + destinationPlot->applyDefaultCurveAppearances(); + destinationPlot->loadDataAndUpdate(); + + updateProjectTreeAndRefresUi(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlotManager::updateFilterTextHistory() +{ + RiaStringListSerializer stringListSerializer( curveFilterRecentlyUsedRegistryKey() ); + + int maxItemCount = 10; + stringListSerializer.addString( m_filterText, maxItemCount ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlotManager::updateProjectTreeAndRefresUi() +{ + RiaSummaryTools::summaryMultiPlotCollection()->updateConnectedEditors(); + + updateFilterTextHistory(); + m_filterText.uiCapability()->updateConnectedEditors(); + + setFocusToFilterText(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlotManager::updateSelectionFromUiChange() +{ + QStringList dataSourceFilters = extractDataSourceFilters(); + if ( m_previousDataSourceText != dataSourceFilters ) + { + m_selectedDataSources = dataSourceDisplayNames(); + + m_previousDataSourceText = dataSourceFilters; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlotManager::setFocusToEditorWidget( caf::PdmUiFieldHandle* uiFieldHandle ) +{ + CAF_ASSERT( uiFieldHandle ); + + auto editors = uiFieldHandle->connectedEditors(); + if ( !editors.empty() ) + { + auto fieldEditorHandle = dynamic_cast( editors.front() ); + if ( fieldEditorHandle && fieldEditorHandle->editorWidget() ) + { + auto widget = fieldEditorHandle->editorWidget(); + + // If the dock widget is floating, activateWindow() must be called to make sure the top level widget has + // focus before the editor widget is given focus + widget->activateWindow(); + widget->setFocus(); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RimSummaryPlotManager::extractDataSourceFilters() const +{ + auto [addressFilters, dataSourceFilters] = + RiaSummaryStringTools::splitIntoAddressAndDataSourceFilters( m_filterText() ); + + return dataSourceFilters; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlotManager::findFilteredSummaryCasesAndEnsembles( std::vector& summaryCases, + std::vector& ensembles ) const +{ + auto filteredDataSources = findDataSourceCandidates(); + for ( const auto& [dataSourceName, dataSource] : filteredDataSources ) + { + auto selectedDataSources = m_selectedDataSources(); + + if ( std::find( selectedDataSources.begin(), selectedDataSources.end(), dataSourceName ) == + std::end( selectedDataSources ) ) + continue; + + auto summaryCase = dynamic_cast( dataSource ); + if ( summaryCase ) + { + summaryCases.push_back( summaryCase ); + } + + auto ensemble = dynamic_cast( dataSource ); + if ( ensemble ) + { + ensembles.push_back( ensemble ); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimSummaryPlotManager::curveFilterRecentlyUsedRegistryKey() +{ + return "SummaryPlotManagerCurveFilterStrings"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlotManager::onSummaryDataSourceHasChanged( const caf::SignalEmitter* emitter ) +{ + resetDataSourceSelection(); + updateSelectionFromUiChange(); +} diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotManager.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotManager.h new file mode 100644 index 0000000000..913f3d7dda --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotManager.h @@ -0,0 +1,110 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafPdmField.h" +#include "cafPdmObject.h" +#include "cafPdmPtrField.h" +#include "cafSelectionChangedReceiver.h" + +class RifEclipseSummaryAddress; +class RimSummaryPlot; +class RimSummaryCase; +class RimSummaryCaseCollection; +class RimEnsembleCurveSet; +class RimSummaryCurve; +class RimMultiPlot; +class RimPlot; + +class RimSummaryPlotManager : public QObject, public caf::PdmObject, public caf::SelectionChangedReceiver + +{ + Q_OBJECT; + CAF_PDM_HEADER_INIT; + +public: + RimSummaryPlotManager(); + + void setFocusToFilterText(); + void resetDataSourceSelection(); + void onSummaryDataSourceHasChanged( const caf::SignalEmitter* emitter ); + +private: + void appendCurves(); + void replaceCurves(); + void createNewPlot(); + + void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; + + void defineEditorAttribute( const caf::PdmFieldHandle* field, + QString uiConfigName, + caf::PdmUiEditorAttribute* attribute ) override; + + void onSelectionManagerSelectionChanged( const std::set& changedSelectionLevels ) override; + + // Override eventFilter to be able to track key events from QDockWidget + bool eventFilter( QObject* obj, QEvent* event ) override; + + void updateCurveCandidates(); + + std::vector> findDataSourceCandidates() const; + std::vector dataSourceDisplayNames() const; + + std::set filteredAddresses(); + + void updateUiFromSelection(); + void appendCurvesToPlot( RimSummaryPlot* destinationPlot ); + void updateFilterTextHistory(); + void updateProjectTreeAndRefresUi(); + void updateSelectionFromUiChange(); + + QStringList extractDataSourceFilters() const; + + void findFilteredSummaryCasesAndEnsembles( std::vector& summaryCases, + std::vector& ensembles ) const; + + static void setFocusToEditorWidget( caf::PdmUiFieldHandle* uiFieldHandle ); + static QString curveFilterRecentlyUsedRegistryKey(); + +private: + caf::PdmPtrField m_summaryPlot; + + caf::PdmField m_filterText; + caf::PdmField> m_addressCandidates; + caf::PdmField> m_selectedDataSources; + + caf::PdmField m_includeDiffCurves; + + caf::PdmField m_pushButtonReplace; + caf::PdmField m_pushButtonNewPlot; + caf::PdmField m_pushButtonAppend; + + caf::PdmField m_individualPlotPerVector; + caf::PdmField m_individualPlotPerDataSource; + caf::PdmField m_individualPlotPerObject; + caf::PdmField m_createMultiPlot; + + caf::PdmField m_labelA; + caf::PdmField m_labelB; + + QStringList m_previousDataSourceText; +}; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp index 079c7d63b7..1e4fe2fe24 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp @@ -18,18 +18,19 @@ #include "RimSummaryPlotNameHelper.h" +#include "RiaSummaryAddressAnalyzer.h" #include "RifEclipseSummaryAddress.h" +#include "RimObjectiveFunctionTools.h" #include "RimSummaryCase.h" #include "RimSummaryCaseCollection.h" -#include "RiuSummaryQuantityNameInfoProvider.h" - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RimSummaryPlotNameHelper::RimSummaryPlotNameHelper() { + m_analyzer = std::make_unique(); } //-------------------------------------------------------------------------------------------------- @@ -39,7 +40,7 @@ void RimSummaryPlotNameHelper::clear() { m_summaryCases.clear(); m_ensembleCases.clear(); - m_analyzer.clear(); + m_analyzer->clear(); clearTitleSubStrings(); } @@ -49,7 +50,7 @@ void RimSummaryPlotNameHelper::clear() //-------------------------------------------------------------------------------------------------- void RimSummaryPlotNameHelper::appendAddresses( const std::vector& addresses ) { - m_analyzer.appendAddresses( addresses ); + m_analyzer->appendAddresses( addresses ); extractPlotTitleSubStrings(); } @@ -93,71 +94,29 @@ void RimSummaryPlotNameHelper::setEnsembleCases( const std::vectorlongNameFromQuantityName( m_titleQuantity, true ) ); - } - - if ( title.isEmpty() ) - { - title = "Composed Plot"; - } - - return title; + return aggregatedPlotTitle( empty ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimSummaryPlotNameHelper::isPlotDisplayingSingleQuantity() const +bool RimSummaryPlotNameHelper::isPlotDisplayingSingleVectorName() const { - return m_analyzer.quantities().size() == 1; + if ( m_analyzer->quantities().size() == 2 ) + { + std::vector strings; + for ( const auto& q : m_analyzer->quantities() ) + strings.push_back( q ); + + auto first = RimObjectiveFunctionTools::nativeQuantityName( strings[0] ); + auto second = RimObjectiveFunctionTools::nativeQuantityName( strings[1] ); + + if ( first == second ) return true; + } + + return m_analyzer->quantities().size() == 1; } //-------------------------------------------------------------------------------------------------- @@ -171,9 +130,9 @@ bool RimSummaryPlotNameHelper::isWellNameInTitle() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimSummaryPlotNameHelper::isWellGroupNameInTitle() const +bool RimSummaryPlotNameHelper::isGroupNameInTitle() const { - return !m_titleWellGroupName.empty(); + return !m_titleGroupName.empty(); } //-------------------------------------------------------------------------------------------------- @@ -216,6 +175,70 @@ bool RimSummaryPlotNameHelper::isCompletionInTitle() const return !m_titleCompletion.empty(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimSummaryPlotNameHelper::caseName() const +{ + return m_titleCaseName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::string RimSummaryPlotNameHelper::titleVectorName() const +{ + return m_titleQuantity; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::string RimSummaryPlotNameHelper::titleWellName() const +{ + return m_titleWellName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::string RimSummaryPlotNameHelper::titleGroupName() const +{ + return m_titleGroupName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::string RimSummaryPlotNameHelper::titleRegion() const +{ + return m_titleRegion; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::string RimSummaryPlotNameHelper::titleBlock() const +{ + return m_titleBlock; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::string RimSummaryPlotNameHelper::titleSegment() const +{ + return m_titleSegment; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::string RimSummaryPlotNameHelper::titleCompletion() const +{ + return m_titleCompletion; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -239,22 +262,22 @@ void RimSummaryPlotNameHelper::extractPlotTitleSubStrings() { clearTitleSubStrings(); - auto wellNames = m_analyzer.wellNames(); - auto wellGroupNames = m_analyzer.wellGroupNames(); - auto regions = m_analyzer.regionNumbers(); - auto blocks = m_analyzer.blocks(); - auto categories = m_analyzer.categories(); + auto wellNames = m_analyzer->wellNames(); + auto groupNames = m_analyzer->groupNames(); + auto regions = m_analyzer->regionNumbers(); + auto blocks = m_analyzer->blocks(); + auto categories = m_analyzer->categories(); if ( categories.size() == 1 ) { - m_titleQuantity = m_analyzer.quantityNameForTitle(); + m_titleQuantity = m_analyzer->quantityNameForTitle(); if ( wellNames.size() == 1 ) { m_titleWellName = *( wellNames.begin() ); { - auto segments = m_analyzer.wellSegmentNumbers( m_titleWellName ); + auto segments = m_analyzer->wellSegmentNumbers( m_titleWellName ); if ( segments.size() == 1 ) { m_titleSegment = std::to_string( *( segments.begin() ) ); @@ -262,7 +285,7 @@ void RimSummaryPlotNameHelper::extractPlotTitleSubStrings() } { - auto completions = m_analyzer.wellCompletions( m_titleWellName ); + auto completions = m_analyzer->wellCompletions( m_titleWellName ); if ( completions.size() == 1 ) { m_titleCompletion = *( completions.begin() ); @@ -270,9 +293,9 @@ void RimSummaryPlotNameHelper::extractPlotTitleSubStrings() } } - if ( wellGroupNames.size() == 1 ) + if ( groupNames.size() == 1 ) { - m_titleWellGroupName = *( wellGroupNames.begin() ); + m_titleGroupName = *( groupNames.begin() ); } if ( regions.size() == 1 ) diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.h index 59499acdd2..514b127398 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.h @@ -18,7 +18,7 @@ #pragma once -#include "RiaSummaryCurveAnalyzer.h" +#include "RimSummaryNameHelper.h" #include "RifEclipseSummaryAddress.h" @@ -26,17 +26,19 @@ #include +#include #include #include class RimSummaryCurve; class RimSummaryCase; class RimSummaryCaseCollection; +class RiaSummaryAddressAnalyzer; //================================================================================================== // //================================================================================================== -class RimSummaryPlotNameHelper +class RimSummaryPlotNameHelper : public RimSummaryNameHelper { public: RimSummaryPlotNameHelper(); @@ -47,16 +49,26 @@ class RimSummaryPlotNameHelper void setSummaryCases( const std::vector& summaryCases ); void setEnsembleCases( const std::vector& ensembleCases ); - QString plotTitle() const; + QString plotTitle() const override; - bool isPlotDisplayingSingleQuantity() const; - bool isWellNameInTitle() const; - bool isWellGroupNameInTitle() const; - bool isRegionInTitle() const; - bool isCaseInTitle() const; - bool isBlockInTitle() const; - bool isSegmentInTitle() const; - bool isCompletionInTitle() const; + bool isPlotDisplayingSingleVectorName() const override; + bool isWellNameInTitle() const override; + bool isGroupNameInTitle() const override; + bool isRegionInTitle() const override; + bool isCaseInTitle() const override; + bool isBlockInTitle() const override; + bool isSegmentInTitle() const override; + bool isCompletionInTitle() const override; + + QString caseName() const override; + + std::string titleVectorName() const override; + std::string titleWellName() const override; + std::string titleGroupName() const override; + std::string titleRegion() const override; + std::string titleBlock() const override; + std::string titleSegment() const override; + std::string titleCompletion() const override; private: void clearTitleSubStrings(); @@ -66,14 +78,14 @@ class RimSummaryPlotNameHelper std::set setOfEnsembleCases() const; private: - RiaSummaryCurveAnalyzer m_analyzer; + std::unique_ptr m_analyzer; std::vector> m_summaryCases; std::vector> m_ensembleCases; std::string m_titleQuantity; std::string m_titleWellName; - std::string m_titleWellGroupName; + std::string m_titleGroupName; std::string m_titleRegion; std::string m_titleBlock; std::string m_titleSegment; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp index c56ced5314..0eb550b7a5 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp @@ -18,119 +18,103 @@ #include "RimSummaryPlotSourceStepping.h" +#include "RiaEnsembleNameTools.h" #include "RiaGuiApplication.h" #include "RiaStdStringTools.h" -#include "RiaSummaryCurveAnalyzer.h" +#include "RiaSummaryAddressAnalyzer.h" #include "RiaSummaryCurveDefinition.h" -#include "RifSummaryReaderInterface.h" - #include "RimDataSourceSteppingTools.h" #include "RimEnsembleCurveSet.h" #include "RimEnsembleCurveSetCollection.h" #include "RimProject.h" +#include "RimSummaryAddressModifier.h" #include "RimSummaryCase.h" #include "RimSummaryCaseMainCollection.h" #include "RimSummaryCrossPlot.h" #include "RimSummaryCurve.h" #include "RimSummaryCurveCollection.h" +#include "RimSummaryDataSourceStepping.h" +#include "RimSummaryMultiPlot.h" #include "RimSummaryPlot.h" +#include "RimSummaryPlotControls.h" #include "RiuPlotMainWindow.h" #include "cafPdmUiComboBoxEditor.h" #include "cafPdmUiItem.h" +#include "cafPdmUiLabelEditor.h" #include "cafPdmUiListEditor.h" #include "cafPdmUiToolBarEditor.h" +#include + +#include +#include + CAF_PDM_SOURCE_INIT( RimSummaryPlotSourceStepping, "RimSummaryCurveCollectionModifier" ); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RimSummaryPlotSourceStepping::RimSummaryPlotSourceStepping() - : m_sourceSteppingType( Y_AXIS ) + : m_sourceSteppingType( RimSummaryDataSourceStepping::Axis::Y_AXIS ) { - CAF_PDM_InitObject( "Summary Curves Modifier", "", "", "" ); + CAF_PDM_InitObject( "Summary Curves Modifier" ); + + setNotifyAllFieldsInMultiFieldChangedEvents( true ); - CAF_PDM_InitFieldNoDefault( &m_summaryCase, "CurveCase", "Case", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_stepDimension, "StepDimension", "Step Dimension" ); + + CAF_PDM_InitFieldNoDefault( &m_summaryCase, "CurveCase", "Case" ); CAF_PDM_InitField( &m_includeEnsembleCasesForCaseStepping, "IncludeEnsembleCasesForCaseStepping", - false, - "Allow Stepping on Ensemble cases", - "", - "", - "" ); + true, + "Include Ensemble Cases in Case List" ); - CAF_PDM_InitFieldNoDefault( &m_wellName, "WellName", "Well Name", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_wellGroupName, "GroupName", "Group Name", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_region, "Region", "Region", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_quantity, "Quantities", "Quantity", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wellName, "WellName", "Well Name" ); + CAF_PDM_InitFieldNoDefault( &m_groupName, "GroupName", "Group Name" ); + CAF_PDM_InitFieldNoDefault( &m_region, "Region", "Region" ); + CAF_PDM_InitFieldNoDefault( &m_vectorName, "VectorName", "Vector" ); - CAF_PDM_InitFieldNoDefault( &m_cellBlock, "CellBlock", "Block", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_segment, "Segment", "Segment", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_completion, "Completion", "Completion", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_aquifer, "Aquifer", "Aquifer", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_cellBlock, "CellBlock", "Block" ); + CAF_PDM_InitFieldNoDefault( &m_segment, "Segment", "Segment" ); + CAF_PDM_InitFieldNoDefault( &m_completion, "Completion", "Completion" ); + CAF_PDM_InitFieldNoDefault( &m_aquifer, "Aquifer", "Aquifer" ); - CAF_PDM_InitFieldNoDefault( &m_ensemble, "Ensemble", "Ensemble", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_ensemble, "Ensemble", "Ensemble" ); - CAF_PDM_InitFieldNoDefault( &m_placeholderForLabel, "Placeholder", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_placeholderForLabel, "Placeholder", "" ); m_placeholderForLabel = "No common identifiers detected"; m_placeholderForLabel.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); m_placeholderForLabel.uiCapability()->setUiReadOnly( true ); -} -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimSummaryPlotSourceStepping::setSourceSteppingType( SourceSteppingType sourceSteppingType ) -{ - m_sourceSteppingType = sourceSteppingType; + CAF_PDM_InitField( &m_indexLabel, "IndexLabel", QString( "Step By" ), "Step By" ); + m_indexLabel.uiCapability()->setUiEditorTypeName( caf::PdmUiLabelEditor::uiEditorTypeName() ); + m_indexLabel.xmlCapability()->disableIO(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryPlotSourceStepping::applyNextCase() +void RimSummaryPlotSourceStepping::setSourceSteppingType( RimSummaryDataSourceStepping::Axis sourceSteppingType ) { - modifyCurrentIndex( &m_summaryCase, 1 ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimSummaryPlotSourceStepping::applyPrevCase() -{ - modifyCurrentIndex( &m_summaryCase, -1 ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimSummaryPlotSourceStepping::applyNextQuantity() -{ - if ( !m_quantity.uiCapability()->isUiHidden() ) - { - modifyCurrentIndex( &m_quantity, 1 ); - } + m_sourceSteppingType = sourceSteppingType; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryPlotSourceStepping::applyPrevQuantity() +void RimSummaryPlotSourceStepping::setSourceSteppingObject( caf::PdmObject* sourceObject ) { - if ( !m_quantity.uiCapability()->isUiHidden() ) - { - modifyCurrentIndex( &m_quantity, -1 ); - } + m_objectForSourceStepping = sourceObject; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryPlotSourceStepping::applyNextOtherIdentifier() +void RimSummaryPlotSourceStepping::applyNextStep() { caf::PdmValueField* valueField = fieldToModify(); if ( !valueField ) return; @@ -141,7 +125,7 @@ void RimSummaryPlotSourceStepping::applyNextOtherIdentifier() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryPlotSourceStepping::applyPrevOtherIdentifier() +void RimSummaryPlotSourceStepping::applyPrevStep() { caf::PdmValueField* valueField = fieldToModify(); if ( !valueField ) return; @@ -154,7 +138,7 @@ void RimSummaryPlotSourceStepping::applyPrevOtherIdentifier() //-------------------------------------------------------------------------------------------------- std::vector RimSummaryPlotSourceStepping::fieldsToShowInToolbar() { - return computeVisibleFieldsAndSetFieldVisibility(); + return toolbarFieldsForDataSourceStepping(); } //-------------------------------------------------------------------------------------------------- @@ -162,45 +146,61 @@ std::vector RimSummaryPlotSourceStepping::fieldsToShowInTo //-------------------------------------------------------------------------------------------------- void RimSummaryPlotSourceStepping::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { - auto visible = computeVisibleFieldsAndSetFieldVisibility(); + auto visible = activeFieldsForDataSourceStepping(); if ( visible.empty() ) { - m_placeholderForLabel.uiCapability()->setUiHidden( false ); + uiOrdering.add( &m_placeholderForLabel ); } - else + + for ( auto f : visible ) { - m_placeholderForLabel.uiCapability()->setUiHidden( true ); + uiOrdering.add( f ); } + + uiOrdering.skipRemainingFields(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- QList - RimSummaryPlotSourceStepping::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) + RimSummaryPlotSourceStepping::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; - if ( fieldNeedingOptions == &m_includeEnsembleCasesForCaseStepping ) + if ( ( fieldNeedingOptions == &m_includeEnsembleCasesForCaseStepping ) || ( fieldNeedingOptions == &m_stepDimension ) ) { - return caf::PdmObject::calculateValueOptions( fieldNeedingOptions, useOptionsOnly ); + return caf::PdmObject::calculateValueOptions( fieldNeedingOptions ); } - else if ( fieldNeedingOptions == &m_placeholderForLabel ) + + if ( ( fieldNeedingOptions == &m_placeholderForLabel ) || ( fieldNeedingOptions == &m_indexLabel ) ) { return options; } - else if ( fieldNeedingOptions == &m_summaryCase ) + + if ( fieldNeedingOptions == &m_summaryCase ) { auto summaryCases = RimSummaryPlotSourceStepping::summaryCasesForSourceStepping(); for ( auto sumCase : summaryCases ) { - options.append( caf::PdmOptionItemInfo( sumCase->displayCaseName(), sumCase ) ); + if ( sumCase->ensemble() ) + { + if ( m_includeEnsembleCasesForCaseStepping() ) + { + auto name = sumCase->ensemble()->name() + " : " + sumCase->displayCaseName(); + options.append( caf::PdmOptionItemInfo( name, sumCase ) ); + } + } + else + { + options.append( caf::PdmOptionItemInfo( sumCase->displayCaseName(), sumCase ) ); + } } return options; } - else if ( fieldNeedingOptions == &m_ensemble ) + + if ( fieldNeedingOptions == &m_ensemble ) { RimProject* proj = RimProject::current(); for ( auto ensemble : proj->summaryGroups() ) @@ -214,63 +214,32 @@ QList return options; } - auto addresses = adressesForSourceStepping(); - if ( !addresses.empty() ) + RiaSummaryAddressAnalyzer fallbackAnalyzer; + RiaSummaryAddressAnalyzer* analyzer = nullptr; + if ( !dataSourceSteppingObject()->curveSets().empty() ) { - if ( fieldNeedingOptions == &m_quantity ) + auto first = dataSourceSteppingObject()->curveSets().front(); + if ( first->summaryCaseCollection() ) { - RifEclipseSummaryAddress::SummaryVarCategory category = RifEclipseSummaryAddress::SUMMARY_FIELD; - - auto visibleCurveAddresses = addressesForCurvesInPlot(); - if ( !visibleCurveAddresses.empty() ) - { - category = visibleCurveAddresses.begin()->category(); - } - - std::map displayAndValueStrings; - - { - RiaSummaryCurveAnalyzer quantityAnalyzer; - - auto subset = RiaSummaryCurveAnalyzer::addressesForCategory( addresses, category ); - quantityAnalyzer.appendAddresses( subset ); - - RiaSummaryCurveAnalyzer analyzerForVisibleCurves; - analyzerForVisibleCurves.appendAddresses( visibleCurveAddresses ); - - if ( analyzerForVisibleCurves.quantityNamesWithHistory().empty() ) - { - auto quantities = quantityAnalyzer.quantities(); - for ( const auto& s : quantities ) - { - QString valueString = QString::fromStdString( s ); - - displayAndValueStrings[valueString] = valueString; - } - } - else - { - // The plot displays a mix of simulated and observed vectors - // Create a combined item for source stepping - - auto quantitiesWithHistory = quantityAnalyzer.quantityNamesWithHistory(); - for ( const auto& s : quantitiesWithHistory ) - { - QString valueString = QString::fromStdString( s ); - QString displayString = valueString + " (H)"; + analyzer = first->summaryCaseCollection()->addressAnalyzer(); + } + } - displayAndValueStrings[displayString] = valueString; - } + if ( !analyzer ) + { + // No cached analyzer found. Fallback to population of a local analyzer. Try to avoid this, as the analysis + // operation is quite expensive. - auto quantitiesNoHistory = quantityAnalyzer.quantityNamesNoHistory(); - for ( const auto& s : quantitiesNoHistory ) - { - QString valueString = QString::fromStdString( s ); + auto addresses = adressesForSourceStepping(); + fallbackAnalyzer.appendAddresses( addresses ); + analyzer = &fallbackAnalyzer; + } - displayAndValueStrings[valueString] = valueString; - } - } - } + if ( analyzer ) + { + if ( fieldNeedingOptions == &m_vectorName ) + { + auto displayAndValueStrings = optionsForQuantity( analyzer ); for ( const auto& displayAndValue : displayAndValueStrings ) { @@ -295,9 +264,9 @@ QList { category = RifEclipseSummaryAddress::SUMMARY_REGION; } - else if ( fieldNeedingOptions == &m_wellGroupName ) + else if ( fieldNeedingOptions == &m_groupName ) { - category = RifEclipseSummaryAddress::SUMMARY_WELL_GROUP; + category = RifEclipseSummaryAddress::SUMMARY_GROUP; } else if ( fieldNeedingOptions == &m_cellBlock ) { @@ -322,10 +291,7 @@ QList if ( category != RifEclipseSummaryAddress::SUMMARY_INVALID ) { - RiaSummaryCurveAnalyzer analyzer; - analyzer.appendAddresses( addresses ); - - identifierTexts = analyzer.identifierTexts( category, secondaryIdentifier ); + identifierTexts = analyzer->identifierTexts( category, secondaryIdentifier ); } if ( !identifierTexts.empty() ) @@ -353,32 +319,35 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi( const caf::PdmFieldHandle* const QVariant& newValue ) { std::vector curves; + if ( dataSourceSteppingObject() ) curves = dataSourceSteppingObject()->allCurves( m_sourceSteppingType ); - RimSummaryCurveCollection* curveCollection = nullptr; - this->firstAncestorOrThisOfType( curveCollection ); - if ( curveCollection ) + if ( changedField == &m_stepDimension ) { - curves = curveCollection->curves(); + RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->getOrCreateMainPlotWindow(); + mainPlotWindow->updateMultiPlotToolBar(); + RimSummaryMultiPlot* plot = dynamic_cast( m_objectForSourceStepping.p() ); + if ( plot ) plot->storeStepDimensionFromToolbar(); + return; } - RimEnsembleCurveSetCollection* ensembleCurveColl = nullptr; - this->firstAncestorOrThisOfType( ensembleCurveColl ); - if ( changedField == &m_includeEnsembleCasesForCaseStepping ) { + RimSummaryCurveCollection* curveCollection = nullptr; + this->firstAncestorOrThisOfType( curveCollection ); if ( curveCollection ) { curveCollection->updateConnectedEditors(); } + RimEnsembleCurveSetCollection* ensembleCurveColl = nullptr; + this->firstAncestorOrThisOfType( ensembleCurveColl ); if ( ensembleCurveColl ) { ensembleCurveColl->updateConnectedEditors(); } - RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->getOrCreateMainPlotWindow(); - bool forceUpdateOfFieldsInToolbar = true; - mainPlotWindow->updateSummaryPlotToolBar( forceUpdateOfFieldsInToolbar ); + RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->getOrCreateMainPlotWindow(); + mainPlotWindow->updateMultiPlotToolBar(); return; } @@ -416,18 +385,18 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi( const caf::PdmFieldHandle* } m_wellName.uiCapability()->updateConnectedEditors(); - m_wellGroupName.uiCapability()->updateConnectedEditors(); + m_groupName.uiCapability()->updateConnectedEditors(); m_region.uiCapability()->updateConnectedEditors(); - m_quantity.uiCapability()->updateConnectedEditors(); + m_vectorName.uiCapability()->updateConnectedEditors(); } else if ( changedField == &m_ensemble ) { - if ( m_ensemble() && ensembleCurveColl ) + if ( m_ensemble() && dataSourceSteppingObject() ) { caf::PdmPointer variantHandle = oldValue.value>(); RimSummaryCaseCollection* previousCollection = dynamic_cast( variantHandle.p() ); - for ( auto curveSet : ensembleCurveColl->curveSets() ) + for ( auto curveSet : dataSourceSteppingObject()->curveSets() ) { if ( curveSet->summaryCaseCollection() == previousCollection ) { @@ -439,42 +408,45 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi( const caf::PdmFieldHandle* } m_wellName.uiCapability()->updateConnectedEditors(); - m_wellGroupName.uiCapability()->updateConnectedEditors(); + m_groupName.uiCapability()->updateConnectedEditors(); m_region.uiCapability()->updateConnectedEditors(); - m_quantity.uiCapability()->updateConnectedEditors(); + m_vectorName.uiCapability()->updateConnectedEditors(); } - else if ( changedField == &m_quantity ) + else if ( changedField == &m_vectorName ) { for ( auto curve : curves ) { if ( isYAxisStepping() ) { auto adr = curve->summaryAddressY(); - updateHistoryAndSummaryQuantityIfMatching( oldValue, newValue, &adr ); - curve->setSummaryAddressY( adr ); + if ( RimDataSourceSteppingTools::updateQuantityIfMatching( oldValue, newValue, &adr ) ) + curve->setSummaryAddressY( adr ); } if ( isXAxisStepping() ) { auto adr = curve->summaryAddressX(); - updateHistoryAndSummaryQuantityIfMatching( oldValue, newValue, &adr ); - curve->setSummaryAddressX( adr ); + if ( RimDataSourceSteppingTools::updateQuantityIfMatching( oldValue, newValue, &adr ) ) + curve->setSummaryAddressX( adr ); } + + curve->setDefaultCurveAppearance(); } - if ( ensembleCurveColl ) + if ( dataSourceSteppingObject() ) { - for ( auto curveSet : ensembleCurveColl->curveSets() ) + for ( auto curveSet : dataSourceSteppingObject()->curveSets() ) { auto adr = curveSet->summaryAddress(); - updateHistoryAndSummaryQuantityIfMatching( oldValue, newValue, &adr ); - curveSet->setSummaryAddress( adr ); + if ( RimDataSourceSteppingTools::updateQuantityIfMatching( oldValue, newValue, &adr ) ) + curveSet->setSummaryAddress( adr ); } } - + m_vectorName.uiCapability()->updateConnectedEditors(); triggerLoadDataAndUpdate = true; } + if ( changedField != &m_vectorName ) { RifEclipseSummaryAddress::SummaryVarCategory summaryCategoryToModify = RifEclipseSummaryAddress::SUMMARY_INVALID; if ( changedField == &m_wellName ) @@ -485,9 +457,9 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi( const caf::PdmFieldHandle* { summaryCategoryToModify = RifEclipseSummaryAddress::SUMMARY_REGION; } - else if ( changedField == &m_wellGroupName ) + else if ( changedField == &m_groupName ) { - summaryCategoryToModify = RifEclipseSummaryAddress::SUMMARY_WELL_GROUP; + summaryCategoryToModify = RifEclipseSummaryAddress::SUMMARY_GROUP; } else if ( changedField == &m_cellBlock ) { @@ -513,24 +485,24 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi( const caf::PdmFieldHandle* if ( isYAxisStepping() ) { RifEclipseSummaryAddress adr = curve->summaryAddressY(); - updateAddressIfMatching( oldValue, newValue, summaryCategoryToModify, &adr ); + RimDataSourceSteppingTools::updateAddressIfMatching( oldValue, newValue, summaryCategoryToModify, &adr ); curve->setSummaryAddressY( adr ); } if ( isXAxisStepping() ) { RifEclipseSummaryAddress adr = curve->summaryAddressX(); - updateAddressIfMatching( oldValue, newValue, summaryCategoryToModify, &adr ); + RimDataSourceSteppingTools::updateAddressIfMatching( oldValue, newValue, summaryCategoryToModify, &adr ); curve->setSummaryAddressX( adr ); } } - if ( ensembleCurveColl ) + if ( dataSourceSteppingObject() ) { - for ( auto curveSet : ensembleCurveColl->curveSets() ) + for ( auto curveSet : dataSourceSteppingObject()->curveSets() ) { auto adr = curveSet->summaryAddress(); - updateAddressIfMatching( oldValue, newValue, summaryCategoryToModify, &adr ); + RimDataSourceSteppingTools::updateAddressIfMatching( oldValue, newValue, summaryCategoryToModify, &adr ); curveSet->setSummaryAddress( adr ); } } @@ -542,12 +514,27 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi( const caf::PdmFieldHandle* if ( triggerLoadDataAndUpdate ) { RimSummaryPlot* summaryPlot = nullptr; - this->firstAncestorOrThisOfTypeAsserted( summaryPlot ); + this->firstAncestorOrThisOfType( summaryPlot ); - summaryPlot->updatePlotTitle(); - summaryPlot->loadDataAndUpdate(); - summaryPlot->updateConnectedEditors(); + RimSummaryMultiPlot* summaryMultiPlot = dynamic_cast( m_objectForSourceStepping.p() ); + if ( summaryMultiPlot ) + { + summaryMultiPlot->updatePlots(); + summaryMultiPlot->updatePlotWindowTitle(); + summaryMultiPlot->zoomAllYAxes(); + RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow(); + mainPlotWindow->updateMultiPlotToolBar(); + } + else + { + summaryPlot->updatePlotTitle(); + summaryPlot->loadDataAndUpdate(); + summaryPlot->updateConnectedEditors(); + summaryPlot->curvesChanged.send(); + } + RimEnsembleCurveSetCollection* ensembleCurveColl = nullptr; + this->firstAncestorOrThisOfType( ensembleCurveColl ); if ( ensembleCurveColl ) { ensembleCurveColl->updateConnectedEditors(); @@ -558,13 +545,15 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi( const caf::PdmFieldHandle* { // Trigger update of curve collection (and summary toolbar in main window), as the visibility of combo // boxes might have been changed due to the updates in this function + RimSummaryCurveCollection* curveCollection = nullptr; + this->firstAncestorOrThisOfType( curveCollection ); if ( curveCollection ) { curveCollection->updateConnectedEditors(); } RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow(); - mainPlotWindow->updateSummaryPlotToolBar(); + mainPlotWindow->updateMultiPlotToolBar(); } } } @@ -574,37 +563,35 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi( const caf::PdmFieldHandle* //-------------------------------------------------------------------------------------------------- caf::PdmValueField* RimSummaryPlotSourceStepping::fieldToModify() { - RiaSummaryCurveAnalyzer analyzer; - analyzer.appendAddresses( addressesForCurvesInPlot() ); - - if ( analyzer.wellNames().size() == 1 ) + switch ( m_stepDimension() ) { - return &m_wellName; - } + case RimSummaryDataSourceStepping::SourceSteppingDimension::SUMMARY_CASE: + return &m_summaryCase; + break; - if ( analyzer.wellGroupNames().size() == 1 ) - { - return &m_wellGroupName; - } + case RimSummaryDataSourceStepping::SourceSteppingDimension::ENSEMBLE: + return &m_ensemble; - if ( analyzer.regionNumbers().size() == 1 ) - { - return &m_region; - } + case RimSummaryDataSourceStepping::SourceSteppingDimension::WELL: + return &m_wellName; - if ( analyzer.blocks().size() == 1 ) - { - return &m_cellBlock; - } + case RimSummaryDataSourceStepping::SourceSteppingDimension::GROUP: + return &m_groupName; - if ( analyzer.wellNames().size() == 1 ) - { - auto wellName = *( analyzer.wellNames().begin() ); + case RimSummaryDataSourceStepping::SourceSteppingDimension::REGION: + return &m_region; - if ( analyzer.wellSegmentNumbers( wellName ).size() == 1 ) - { - return &m_segment; - } + case RimSummaryDataSourceStepping::SourceSteppingDimension::VECTOR: + return &m_vectorName; + + case RimSummaryDataSourceStepping::SourceSteppingDimension::BLOCK: + return &m_cellBlock; + + case RimSummaryDataSourceStepping::SourceSteppingDimension::AQUIFER: + return &m_aquifer; + + default: + break; } return nullptr; @@ -617,43 +604,35 @@ std::set RimSummaryPlotSourceStepping::adressesForSour { std::set addressSet; + if ( dataSourceSteppingObject() ) { - RimEnsembleCurveSetCollection* ensembleCollection = nullptr; - this->firstAncestorOrThisOfType( ensembleCollection ); - if ( ensembleCollection ) + for ( auto curveSet : dataSourceSteppingObject()->curveSets() ) { - auto curveSets = ensembleCollection->curveSetsForSourceStepping(); - for ( const RimEnsembleCurveSet* curveSet : curveSets ) + if ( curveSet && curveSet->summaryCaseCollection() ) { - if ( curveSet && curveSet->summaryCaseCollection() ) - { - auto addresses = curveSet->summaryCaseCollection()->ensembleSummaryAddresses(); - addressSet.insert( addresses.begin(), addresses.end() ); - } + auto addresses = curveSet->summaryCaseCollection()->ensembleSummaryAddresses(); + addressSet.insert( addresses.begin(), addresses.end() ); } } - } - { - RimSummaryCurveCollection* curveCollection = nullptr; - this->firstAncestorOrThisOfType( curveCollection ); - if ( curveCollection ) + std::vector curves; + if ( dataSourceSteppingObject() ) + curves = dataSourceSteppingObject()->curvesForStepping( m_sourceSteppingType ); + + for ( auto curve : curves ) { - for ( auto curve : curveCollection->curvesForSourceStepping( m_sourceSteppingType ) ) - { - if ( !curve ) continue; + if ( !curve ) continue; - if ( isYAxisStepping() && curve->summaryCaseY() && curve->summaryCaseY()->summaryReader() ) - { - auto addresses = curve->summaryCaseY()->summaryReader()->allResultAddresses(); - addressSet.insert( addresses.begin(), addresses.end() ); - } + if ( isYAxisStepping() && curve->summaryCaseY() && curve->summaryCaseY()->summaryReader() ) + { + auto addresses = curve->summaryCaseY()->summaryReader()->allResultAddresses(); + addressSet.insert( addresses.begin(), addresses.end() ); + } - if ( isXAxisStepping() && curve->summaryCaseX() && curve->summaryCaseX()->summaryReader() ) - { - auto addresses = curve->summaryCaseX()->summaryReader()->allResultAddresses(); - addressSet.insert( addresses.begin(), addresses.end() ); - } + if ( isXAxisStepping() && curve->summaryCaseX() && curve->summaryCaseX()->summaryReader() ) + { + auto addresses = curve->summaryCaseX()->summaryReader()->allResultAddresses(); + addressSet.insert( addresses.begin(), addresses.end() ); } } } @@ -668,32 +647,27 @@ std::set RimSummaryPlotSourceStepping::addressesForCur { std::set addresses; - RimEnsembleCurveSetCollection* ensembleCollection = nullptr; - this->firstAncestorOrThisOfType( ensembleCollection ); - if ( ensembleCollection ) + if ( dataSourceSteppingObject() ) { - auto curveSets = ensembleCollection->curveSetsForSourceStepping(); - for ( const RimEnsembleCurveSet* curveSet : curveSets ) + for ( auto curveSet : dataSourceSteppingObject()->curveSets() ) { addresses.insert( curveSet->summaryAddress() ); } - } - RimSummaryCurveCollection* curveCollection = nullptr; - this->firstAncestorOrThisOfType( curveCollection ); - if ( curveCollection ) - { - auto curves = curveCollection->curvesForSourceStepping( m_sourceSteppingType ); - for ( auto c : curves ) + std::vector curves; + if ( dataSourceSteppingObject() ) + curves = dataSourceSteppingObject()->curvesForStepping( m_sourceSteppingType ); + + for ( auto curve : curves ) { if ( isYAxisStepping() ) { - addresses.insert( c->summaryAddressY() ); + addresses.insert( curve->summaryAddressY() ); } if ( isXAxisStepping() ) { - addresses.insert( c->summaryAddressX() ); + addresses.insert( curve->summaryAddressX() ); } } } @@ -708,12 +682,8 @@ std::set RimSummaryPlotSourceStepping::summaryCasesCurveCollect { std::set sumCases; - RimSummaryCurveCollection* curveCollection = nullptr; - this->firstAncestorOrThisOfType( curveCollection ); - - if ( !curveCollection ) return sumCases; - - auto curves = curveCollection->curvesForSourceStepping( m_sourceSteppingType ); + std::vector curves; + if ( dataSourceSteppingObject() ) curves = dataSourceSteppingObject()->curvesForStepping( m_sourceSteppingType ); for ( auto c : curves ) { if ( isYAxisStepping() ) @@ -733,50 +703,34 @@ std::set RimSummaryPlotSourceStepping::summaryCasesCurveCollect //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimSummaryPlotSourceStepping::computeVisibleFieldsAndSetFieldVisibility() +std::vector RimSummaryPlotSourceStepping::activeFieldsForDataSourceStepping() { - // Required to set all stepping controls hidden, as they show up in the property editor when selecting a plot - m_summaryCase.uiCapability()->setUiHidden( true ); - m_includeEnsembleCasesForCaseStepping.uiCapability()->setUiHidden( true ); - m_wellName.uiCapability()->setUiHidden( true ); - m_wellGroupName.uiCapability()->setUiHidden( true ); - m_region.uiCapability()->setUiHidden( true ); - m_quantity.uiCapability()->setUiHidden( true ); - m_ensemble.uiCapability()->setUiHidden( true ); - m_cellBlock.uiCapability()->setUiHidden( true ); - m_segment.uiCapability()->setUiHidden( true ); - m_completion.uiCapability()->setUiHidden( true ); - m_aquifer.uiCapability()->setUiHidden( true ); + RimProject* proj = RimProject::current(); + if ( !proj ) return {}; std::vector fields; + fields.push_back( &m_stepDimension ); + auto sumCases = summaryCasesCurveCollection(); if ( sumCases.size() == 1 ) { - RimProject* proj = RimProject::current(); if ( proj->allSummaryCases().size() > 1 ) { m_summaryCase = *( sumCases.begin() ); - m_summaryCase.uiCapability()->setUiHidden( false ); - fields.push_back( &m_summaryCase ); - - m_includeEnsembleCasesForCaseStepping.uiCapability()->setUiHidden( false ); + fields.push_back( &m_includeEnsembleCasesForCaseStepping ); } } auto ensembleColl = ensembleCollection(); if ( ensembleColl.size() == 1 ) { - RimProject* proj = RimProject::current(); - if ( proj->summaryGroups().size() > 1 ) { m_ensemble = *( ensembleColl.begin() ); - m_ensemble.uiCapability()->setUiHidden( false ); - fields.push_back( &m_ensemble ); } } @@ -784,7 +738,7 @@ std::vector RimSummaryPlotSourceStepping::computeVisibleFi std::vector fieldsCommonForAllCurves; { - RiaSummaryCurveAnalyzer analyzer; + RiaSummaryAddressAnalyzer analyzer; analyzer.appendAddresses( addressesForCurvesInPlot() ); RifEclipseSummaryAddress::SummaryVarCategory category = RifEclipseSummaryAddress::SUMMARY_INVALID; @@ -819,24 +773,21 @@ std::vector RimSummaryPlotSourceStepping::computeVisibleFi { QString txt = QString::fromStdString( *( analyzer.wellNames().begin() ) ); m_wellName = txt; - m_wellName.uiCapability()->setUiHidden( false ); fieldsCommonForAllCurves.push_back( &m_wellName ); } - if ( analyzer.wellGroupNames().size() == 1 ) + if ( analyzer.groupNames().size() == 1 ) { - QString txt = QString::fromStdString( *( analyzer.wellGroupNames().begin() ) ); - m_wellGroupName = txt; - m_wellGroupName.uiCapability()->setUiHidden( false ); + QString txt = QString::fromStdString( *( analyzer.groupNames().begin() ) ); + m_groupName = txt; - fieldsCommonForAllCurves.push_back( &m_wellGroupName ); + fieldsCommonForAllCurves.push_back( &m_groupName ); } if ( analyzer.regionNumbers().size() == 1 ) { m_region = *( analyzer.regionNumbers().begin() ); - m_region.uiCapability()->setUiHidden( false ); fieldsCommonForAllCurves.push_back( &m_region ); } @@ -845,7 +796,6 @@ std::vector RimSummaryPlotSourceStepping::computeVisibleFi { QString txt = QString::number( *( analyzer.wellSegmentNumbers( m_wellName().toStdString() ).begin() ) ); m_segment = txt; - m_segment.uiCapability()->setUiHidden( false ); fieldsCommonForAllCurves.push_back( &m_segment ); } @@ -854,7 +804,6 @@ std::vector RimSummaryPlotSourceStepping::computeVisibleFi { QString txt = QString::fromStdString( *( analyzer.blocks().begin() ) ); m_cellBlock = txt; - m_cellBlock.uiCapability()->setUiHidden( false ); fieldsCommonForAllCurves.push_back( &m_cellBlock ); } @@ -863,7 +812,6 @@ std::vector RimSummaryPlotSourceStepping::computeVisibleFi { QString txt = QString::fromStdString( *( analyzer.wellCompletions( m_wellName().toStdString() ).begin() ) ); m_completion = txt; - m_completion.uiCapability()->setUiHidden( false ); fieldsCommonForAllCurves.push_back( &m_completion ); } @@ -871,18 +819,16 @@ std::vector RimSummaryPlotSourceStepping::computeVisibleFi if ( analyzer.aquifers().size() == 1 ) { m_aquifer = *( analyzer.aquifers().begin() ); - m_aquifer.uiCapability()->setUiHidden( false ); fieldsCommonForAllCurves.push_back( &m_aquifer ); } if ( !analyzer.quantityNameForTitle().empty() ) { - QString txt = QString::fromStdString( analyzer.quantityNameForTitle() ); - m_quantity = txt; - m_quantity.uiCapability()->setUiHidden( false ); + QString txt = QString::fromStdString( analyzer.quantityNameForTitle() ); + m_vectorName = txt; - fieldsCommonForAllCurves.push_back( &m_quantity ); + fieldsCommonForAllCurves.push_back( &m_vectorName ); } } } @@ -900,20 +846,20 @@ std::vector RimSummaryPlotSourceStepping::computeVisibleFi //-------------------------------------------------------------------------------------------------- std::set RimSummaryPlotSourceStepping::ensembleCollection() const { - std::set sumCases; - - RimEnsembleCurveSetCollection* curveCollection = nullptr; - this->firstAncestorOrThisOfType( curveCollection ); - - if ( !curveCollection ) return sumCases; + std::set summaryCaseCollections; - auto curves = curveCollection->curveSets(); - for ( auto c : curves ) + if ( dataSourceSteppingObject() ) { - sumCases.insert( c->summaryCaseCollection() ); + for ( auto curveSet : dataSourceSteppingObject()->curveSets() ) + { + if ( curveSet && curveSet->summaryCaseCollection() ) + { + summaryCaseCollections.insert( curveSet->summaryCaseCollection() ); + } + } } - return sumCases; + return summaryCaseCollections; } //-------------------------------------------------------------------------------------------------- @@ -921,9 +867,9 @@ std::set RimSummaryPlotSourceStepping::ensembleCollec //-------------------------------------------------------------------------------------------------- bool RimSummaryPlotSourceStepping::isXAxisStepping() const { - if ( m_sourceSteppingType == UNION_X_Y_AXIS ) return true; + if ( m_sourceSteppingType == RimSummaryDataSourceStepping::Axis::UNION_X_Y_AXIS ) return true; - if ( m_sourceSteppingType == X_AXIS ) return true; + if ( m_sourceSteppingType == RimSummaryDataSourceStepping::Axis::X_AXIS ) return true; return false; } @@ -933,9 +879,9 @@ bool RimSummaryPlotSourceStepping::isXAxisStepping() const //-------------------------------------------------------------------------------------------------- bool RimSummaryPlotSourceStepping::isYAxisStepping() const { - if ( m_sourceSteppingType == UNION_X_Y_AXIS ) return true; + if ( m_sourceSteppingType == RimSummaryDataSourceStepping::Axis::UNION_X_Y_AXIS ) return true; - if ( m_sourceSteppingType == Y_AXIS ) return true; + if ( m_sourceSteppingType == RimSummaryDataSourceStepping::Axis::Y_AXIS ) return true; return false; } @@ -943,164 +889,381 @@ bool RimSummaryPlotSourceStepping::isYAxisStepping() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiaSummaryCurveAnalyzer* RimSummaryPlotSourceStepping::analyzerForReader( RifSummaryReaderInterface* reader ) +void RimSummaryPlotSourceStepping::modifyCurrentIndex( caf::PdmValueField* valueField, int indexOffset, bool notifyChange ) +{ + QList options = calculateValueOptions( valueField ); + RimDataSourceSteppingTools::modifyCurrentIndex( valueField, options, indexOffset, notifyChange ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimSummaryPlotSourceStepping::summaryCasesForSourceStepping() { - if ( !reader ) return nullptr; + std::vector cases; - if ( m_curveAnalyzerForReader.first != reader ) + RimProject* proj = RimProject::current(); + for ( auto sumCase : proj->allSummaryCases() ) { - RiaSummaryCurveAnalyzer analyzer; - m_curveAnalyzerForReader = std::make_pair( reader, analyzer ); - } + if ( sumCase->isObservedData() ) continue; - m_curveAnalyzerForReader.second.appendAddresses( reader->allResultAddresses() ); + RimSummaryCaseCollection* sumCaseColl = nullptr; + sumCase->firstAncestorOrThisOfType( sumCaseColl ); - return &m_curveAnalyzerForReader.second; + if ( sumCaseColl && sumCaseColl->isEnsemble() ) + { + if ( m_includeEnsembleCasesForCaseStepping() ) + { + cases.push_back( sumCase ); + } + } + else + { + cases.push_back( sumCase ); + } + } + + return cases; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryPlotSourceStepping::modifyCurrentIndex( caf::PdmValueField* valueField, int indexOffset ) +RimSummaryDataSourceStepping* RimSummaryPlotSourceStepping::dataSourceSteppingObject() const { - bool useOptionsOnly; - QList options = calculateValueOptions( valueField, &useOptionsOnly ); - RimDataSourceSteppingTools::modifyCurrentIndex( valueField, options, indexOffset ); + return dynamic_cast( m_objectForSourceStepping.p() ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimSummaryPlotSourceStepping::updateAddressIfMatching( const QVariant& oldValue, - const QVariant& newValue, - RifEclipseSummaryAddress::SummaryVarCategory category, - RifEclipseSummaryAddress* adr ) +void RimSummaryPlotSourceStepping::defineEditorAttribute( const caf::PdmFieldHandle* field, + QString uiConfigName, + caf::PdmUiEditorAttribute* attribute ) { - if ( !adr ) return false; - - if ( category == RifEclipseSummaryAddress::SUMMARY_REGION ) + caf::PdmUiComboBoxEditorAttribute* myAttr = dynamic_cast( attribute ); + if ( myAttr ) { - int oldInt = oldValue.toInt(); - int newInt = newValue.toInt(); - - if ( adr->regionNumber() == oldInt ) + if ( field == &m_stepDimension ) + { + myAttr->showPreviousAndNextButtons = false; + } + else { - adr->setRegion( newInt ); + QString nextText = RimSummaryPlotControls::nextStepKeyText(); + QString prevText = RimSummaryPlotControls::prevStepKeyText(); + myAttr->nextButtonText = "Next (" + nextText + ")"; + myAttr->prevButtonText = "Previous (" + prevText + ")"; + + myAttr->nextIcon = QIcon( ":/ComboBoxDown.svg" ); + myAttr->previousIcon = QIcon( ":/ComboBoxUp.svg" ); - return true; + myAttr->showPreviousAndNextButtons = true; } } - else if ( category == RifEclipseSummaryAddress::SUMMARY_AQUIFER ) + + if ( myAttr && ( uiConfigName == caf::PdmUiToolBarEditor::uiEditorConfigName() ) ) { - int oldInt = oldValue.toInt(); - int newInt = newValue.toInt(); + myAttr->minimumWidth = 120; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimSummaryPlotSourceStepping::toolbarFieldsForDataSourceStepping() +{ + std::vector fields; + fields.push_back( &m_indexLabel ); + fields.push_back( &m_stepDimension ); + + caf::PdmFieldHandle* field = fieldToModify(); + if ( field != nullptr ) fields.push_back( field ); + + return fields; +} - if ( adr->aquiferNumber() == oldInt ) +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifEclipseSummaryAddress RimSummaryPlotSourceStepping::stepAddress( RifEclipseSummaryAddress addr, int direction ) +{ + auto addresses = adressesForSourceStepping(); + RiaSummaryAddressAnalyzer analyzer; + analyzer.appendAddresses( addresses ); + + switch ( m_stepDimension() ) + { + case RimSummaryDataSourceStepping::SourceSteppingDimension::WELL: { - adr->setAquiferNumber( newInt ); + auto ids = analyzer.identifierTexts( RifEclipseSummaryAddress::SUMMARY_WELL, "" ); + auto& curName = addr.wellName(); + auto found = std::find( ids.begin(), ids.end(), QString::fromStdString( curName ) ); + if ( found != ids.end() ) + { + if ( direction > 0 ) + { + found++; + } + else + { + if ( found != ids.begin() ) found--; + } + if ( found != ids.end() ) addr.setWellName( ( *found ).toStdString() ); + } + } + break; - return true; + case RimSummaryDataSourceStepping::SourceSteppingDimension::GROUP: + { + auto ids = analyzer.identifierTexts( RifEclipseSummaryAddress::SUMMARY_GROUP, "" ); + auto& curName = addr.groupName(); + auto found = std::find( ids.begin(), ids.end(), QString::fromStdString( curName ) ); + if ( found != ids.end() ) + { + if ( direction > 0 ) + { + found++; + } + else + { + if ( found != ids.begin() ) found--; + } + if ( found != ids.end() ) addr.setGroupName( ( *found ).toStdString() ); + } } - } - else if ( category == RifEclipseSummaryAddress::SUMMARY_WELL_GROUP ) - { - std::string oldString = oldValue.toString().toStdString(); - std::string newString = newValue.toString().toStdString(); + break; + + case RimSummaryDataSourceStepping::SourceSteppingDimension::REGION: + { + auto ids = analyzer.identifierTexts( RifEclipseSummaryAddress::SUMMARY_REGION, "" ); + QString curRegion = QString::number( addr.regionNumber() ); + auto found = std::find( ids.begin(), ids.end(), curRegion ); + if ( found != ids.end() ) + { + if ( direction > 0 ) + { + found++; + } + else + { + if ( found != ids.begin() ) found--; + } + if ( found != ids.end() ) addr.setRegion( ( *found ).toInt() ); + } + } + break; - if ( adr->wellGroupName() == oldString ) + case RimSummaryDataSourceStepping::SourceSteppingDimension::VECTOR: { - adr->setWellGroupName( newString ); + auto options = optionsForQuantity( addresses ); - return true; + std::vector values; + for ( auto it = options.begin(); it != options.end(); it++ ) + { + values.push_back( it->second ); + } + + QString qName = QString::fromStdString( addr.vectorName() ); + auto found = std::find( values.begin(), values.end(), qName ); + if ( found != values.end() ) + { + if ( direction > 0 ) + { + found++; + } + else + { + if ( found != values.begin() ) found--; + } + if ( found != values.end() ) addr.setVectorName( ( *found ).toStdString() ); + } } - } - else if ( category == RifEclipseSummaryAddress::SUMMARY_WELL ) - { - std::string oldString = oldValue.toString().toStdString(); - std::string newString = newValue.toString().toStdString(); + break; - if ( adr->wellName() == oldString ) + case RimSummaryDataSourceStepping::SourceSteppingDimension::BLOCK: { - adr->setWellName( newString ); + auto ids = analyzer.identifierTexts( RifEclipseSummaryAddress::SUMMARY_BLOCK, "" ); + auto curName = addr.blockAsString(); + auto found = std::find( ids.begin(), ids.end(), QString::fromStdString( curName ) ); + if ( found != ids.end() ) + { + if ( direction > 0 ) + { + found++; + } + else + { + if ( found != ids.begin() ) found--; + } + if ( found != ids.end() ) + { + addr.setCellIjk( ( *found ).toStdString() ); + } + } + } + break; - return true; + case RimSummaryDataSourceStepping::SourceSteppingDimension::AQUIFER: + { + auto ids = analyzer.identifierTexts( RifEclipseSummaryAddress::SUMMARY_AQUIFER, "" ); + QString curAq = QString::number( addr.aquiferNumber() ); + auto found = std::find( ids.begin(), ids.end(), curAq ); + if ( found != ids.end() ) + { + if ( direction > 0 ) + { + found++; + } + else + { + if ( found != ids.begin() ) found--; + } + if ( found != ids.end() ) addr.setAquiferNumber( ( *found ).toInt() ); + } } + break; + + default: + break; } - else if ( category == RifEclipseSummaryAddress::SUMMARY_BLOCK || - category == RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION ) + return addr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlotSourceStepping::syncWithStepper( RimSummaryPlotSourceStepping* other ) +{ + switch ( m_stepDimension() ) { - std::string oldString = oldValue.toString().toStdString(); - std::string newString = newValue.toString().toStdString(); - if ( adr->blockAsString() == oldString ) - { - adr->setCellIjk( newString ); + case RimSummaryDataSourceStepping::SourceSteppingDimension::SUMMARY_CASE: + m_summaryCase = other->m_summaryCase(); + break; - return true; - } + case RimSummaryDataSourceStepping::SourceSteppingDimension::ENSEMBLE: + m_ensemble = other->m_ensemble(); + break; + + case RimSummaryDataSourceStepping::SourceSteppingDimension::WELL: + m_wellName = other->m_wellName(); + break; + + case RimSummaryDataSourceStepping::SourceSteppingDimension::GROUP: + m_groupName = other->m_groupName(); + break; + + case RimSummaryDataSourceStepping::SourceSteppingDimension::REGION: + m_region = other->m_region(); + break; + + case RimSummaryDataSourceStepping::SourceSteppingDimension::VECTOR: + m_vectorName = other->m_vectorName(); + break; + + case RimSummaryDataSourceStepping::SourceSteppingDimension::BLOCK: + m_cellBlock = other->m_cellBlock(); + break; + + case RimSummaryDataSourceStepping::SourceSteppingDimension::AQUIFER: + m_aquifer = other->m_aquifer(); + break; + + default: + break; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::map RimSummaryPlotSourceStepping::optionsForQuantity( std::set addresses ) +{ + RifEclipseSummaryAddress::SummaryVarCategory category = RifEclipseSummaryAddress::SUMMARY_FIELD; + + auto visibleCurveAddresses = addressesForCurvesInPlot(); + if ( !visibleCurveAddresses.empty() ) + { + category = visibleCurveAddresses.begin()->category(); } - else if ( category == RifEclipseSummaryAddress::SUMMARY_WELL_SEGMENT ) + + std::map displayAndValueStrings; + { - int oldInt = oldValue.toInt(); - int newInt = newValue.toInt(); - if ( adr->wellSegmentNumber() == oldInt ) + RiaSummaryAddressAnalyzer quantityAnalyzer; + + auto subset = RiaSummaryAddressAnalyzer::addressesForCategory( addresses, category ); + quantityAnalyzer.appendAddresses( subset ); + + auto quantities = quantityAnalyzer.quantities(); + for ( const auto& s : quantities ) { - adr->setWellSegmentNumber( newInt ); + QString valueString = QString::fromStdString( s ); - return true; + displayAndValueStrings[valueString] = valueString; } } - return false; + return displayAndValueStrings; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimSummaryPlotSourceStepping::updateHistoryAndSummaryQuantityIfMatching( const QVariant& oldValue, - const QVariant& newValue, - RifEclipseSummaryAddress* adr ) +std::map RimSummaryPlotSourceStepping::optionsForQuantity( RiaSummaryAddressAnalyzer* analyzser ) { - if ( !adr ) return false; + RifEclipseSummaryAddress::SummaryVarCategory category = RifEclipseSummaryAddress::SUMMARY_FIELD; - std::string oldString = oldValue.toString().toStdString(); - std::string newString = newValue.toString().toStdString(); - - if ( adr->quantityName() == oldString ) + auto visibleCurveAddresses = addressesForCurvesInPlot(); + if ( !visibleCurveAddresses.empty() ) { - adr->setQuantityName( newString ); - - return true; + category = visibleCurveAddresses.begin()->category(); } - std::string correspondingOldString = RiaSummaryCurveAnalyzer::correspondingHistorySummaryCurveName( oldString ); - std::string correspondingNewString = RiaSummaryCurveAnalyzer::correspondingHistorySummaryCurveName( newString ); + std::map displayAndValueStrings; - if ( adr->quantityName() == correspondingOldString ) + if ( analyzser ) { - adr->setQuantityName( correspondingNewString ); + auto vectorNames = analyzser->vectorNamesForCategory( category ); + + for ( const auto& s : vectorNames ) + { + QString valueString = QString::fromStdString( s ); - return true; + displayAndValueStrings[valueString] = valueString; + } } - return false; + return displayAndValueStrings; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimSummaryPlotSourceStepping::summaryCasesForSourceStepping() +RimSummaryDataSourceStepping::SourceSteppingDimension RimSummaryPlotSourceStepping::stepDimension() const { - std::vector cases; + return m_stepDimension(); +} - RimProject* proj = RimProject::current(); - for ( auto sumCase : proj->allSummaryCases() ) - { - if ( sumCase->isObservedData() ) continue; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlotSourceStepping::setStepDimension( RimSummaryDataSourceStepping::SourceSteppingDimension dimension ) +{ + m_stepDimension = dimension; +} - RimSummaryCaseCollection* sumCaseColl = nullptr; - sumCase->firstAncestorOrThisOfType( sumCaseColl ); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryCase* RimSummaryPlotSourceStepping::stepCase( int direction ) +{ + std::vector cases; - if ( sumCaseColl && sumCaseColl->isEnsemble() ) + auto summaryCases = RimSummaryPlotSourceStepping::summaryCasesForSourceStepping(); + for ( auto sumCase : summaryCases ) + { + if ( sumCase->ensemble() ) { if ( m_includeEnsembleCasesForCaseStepping() ) { @@ -1113,47 +1276,177 @@ std::vector RimSummaryPlotSourceStepping::summaryCasesForSource } } - return cases; + auto found = std::find( cases.begin(), cases.end(), m_summaryCase() ); + if ( found != cases.end() ) + { + if ( direction > 0 ) + { + found++; + } + else + { + if ( found != cases.begin() ) found--; + } + if ( found != cases.end() ) return *found; + } + + return m_summaryCase; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryPlotSourceStepping::defineEditorAttribute( const caf::PdmFieldHandle* field, - QString uiConfigName, - caf::PdmUiEditorAttribute* attribute ) +RimSummaryCaseCollection* RimSummaryPlotSourceStepping::stepEnsemble( int direction ) { - caf::PdmUiComboBoxEditorAttribute* myAttr = dynamic_cast( attribute ); - if ( myAttr ) - { - myAttr->showPreviousAndNextButtons = true; - myAttr->nextIcon = QIcon( ":/ComboBoxDown.svg" ); - myAttr->previousIcon = QIcon( ":/ComboBoxUp.svg" ); - - QString modifierText; + std::vector ensembles; - if ( field == &m_summaryCase ) + RimProject* proj = RimProject::current(); + for ( auto ensemble : proj->summaryGroups() ) + { + if ( ensemble->isEnsemble() ) { - modifierText = ( "(Shift+" ); + ensembles.push_back( ensemble ); } - else if ( field == &m_wellName || field == &m_wellGroupName || field == &m_region ) + } + + auto found = std::find( ensembles.begin(), ensembles.end(), m_ensemble() ); + if ( found != ensembles.end() ) + { + if ( direction > 0 ) { - modifierText = ( "(Ctrl+" ); + found++; } - else if ( field == &m_quantity ) + else { - modifierText = ( "(" ); + if ( found != ensembles.begin() ) found--; } + if ( found != ensembles.end() ) return *found; + } - if ( !modifierText.isEmpty() ) - { - myAttr->nextButtonText = "Next " + modifierText + "PgDown)"; - myAttr->prevButtonText = "Previous " + modifierText + "PgUp)"; - } + return m_ensemble; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlotSourceStepping::updateStepIndex( int direction ) +{ + caf::PdmValueField* valueField = fieldToModify(); + if ( !valueField ) return; + + bool notifyChange = false; + modifyCurrentIndex( valueField, direction, notifyChange ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimSummaryPlotSourceStepping::plotsMatchingStepSettings( std::vector plots ) +{ + std::vector matchingPlots; + + int caseIdToMatch = -1; + int ensembleIdToMatch = -1; + std::string wellNameToMatch; + std::string groupNameToMatch; + int regionToMatch = -1; + std::string vectorToMatch; + std::string blockToMatch; + int aquiferToMatch = -1; + + switch ( m_stepDimension() ) + { + case RimSummaryDataSourceStepping::SourceSteppingDimension::SUMMARY_CASE: + if ( m_summaryCase() ) caseIdToMatch = m_summaryCase()->caseId(); + break; + + case RimSummaryDataSourceStepping::SourceSteppingDimension::ENSEMBLE: + if ( m_ensemble() ) ensembleIdToMatch = m_ensemble()->ensembleId(); + break; + + case RimSummaryDataSourceStepping::SourceSteppingDimension::WELL: + wellNameToMatch = m_wellName().toStdString(); + break; + + case RimSummaryDataSourceStepping::SourceSteppingDimension::GROUP: + groupNameToMatch = m_groupName().toStdString(); + break; + + case RimSummaryDataSourceStepping::SourceSteppingDimension::REGION: + regionToMatch = m_region(); + break; + + case RimSummaryDataSourceStepping::SourceSteppingDimension::VECTOR: + vectorToMatch = m_vectorName().toStdString(); + break; + + case RimSummaryDataSourceStepping::SourceSteppingDimension::BLOCK: + blockToMatch = m_cellBlock().toStdString(); + break; + + case RimSummaryDataSourceStepping::SourceSteppingDimension::AQUIFER: + aquiferToMatch = m_aquifer(); + break; + + default: + break; } - if ( myAttr && ( uiConfigName == caf::PdmUiToolBarEditor::uiEditorConfigName() ) ) + for ( auto plot : plots ) { - myAttr->minimumWidth = 120; + bool isMatching = false; + + if ( caseIdToMatch != -1 ) + { + auto curves = plot->summaryCurves(); + for ( auto c : curves ) + { + if ( c->summaryCaseY()->caseId() == caseIdToMatch ) isMatching = true; + } + } + else if ( ensembleIdToMatch != -1 ) + { + auto curves = plot->curveSets(); + for ( auto c : curves ) + { + if ( c->ensembleId() == ensembleIdToMatch ) isMatching = true; + } + } + else + { + auto addresses = RimSummaryAddressModifier::createEclipseSummaryAddress( plot ); + + for ( const auto& a : addresses ) + { + if ( !wellNameToMatch.empty() && a.wellName() == wellNameToMatch ) + { + isMatching = true; + } + else if ( !vectorToMatch.empty() && a.vectorName() == vectorToMatch ) + { + isMatching = true; + } + else if ( !groupNameToMatch.empty() && a.groupName() == groupNameToMatch ) + { + isMatching = true; + } + else if ( regionToMatch != -1 && a.regionNumber() == regionToMatch ) + { + isMatching = true; + } + else if ( !blockToMatch.empty() && a.blockAsString() == blockToMatch ) + { + isMatching = true; + } + else if ( aquiferToMatch != -1 && a.aquiferNumber() == aquiferToMatch ) + { + isMatching = true; + } + } + } + + if ( isMatching ) matchingPlots.push_back( plot ); } + + return matchingPlots; } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.h index f9bde2f3c5..9ce872bcc7 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.h @@ -18,8 +18,7 @@ #pragma once -#include "RiaSummaryCurveAnalyzer.h" -#include "RifEclipseSummaryAddress.h" +#include "RimSummaryDataSourceStepping.h" #include "cafPdmField.h" #include "cafPdmObject.h" @@ -28,12 +27,17 @@ #include +#include #include class RimSummaryCase; class RimSummaryCurve; class RifSummaryReaderInterface; class RimSummaryCaseCollection; +class RifEclipseSummaryAddress; +class RiaSummaryAddressAnalyzer; +class RimSummaryPlot; +class RimPlot; //================================================================================================== /// @@ -42,35 +46,34 @@ class RimSummaryPlotSourceStepping : public caf::PdmObject { CAF_PDM_HEADER_INIT; -public: - enum SourceSteppingType - { - Y_AXIS, - X_AXIS, - UNION_X_Y_AXIS - }; - public: RimSummaryPlotSourceStepping(); - void setSourceSteppingType( SourceSteppingType sourceSteppingType ); + void setSourceSteppingType( RimSummaryDataSourceStepping::Axis sourceSteppingType ); + void setSourceSteppingObject( caf::PdmObject* sourceObject ); - void applyNextCase(); - void applyPrevCase(); + void applyNextStep(); + void applyPrevStep(); - void applyNextQuantity(); - void applyPrevQuantity(); + std::vector fieldsToShowInToolbar(); - void applyNextOtherIdentifier(); - void applyPrevOtherIdentifier(); + RifEclipseSummaryAddress stepAddress( RifEclipseSummaryAddress addr, int direction ); + RimSummaryCase* stepCase( int direction ); + RimSummaryCaseCollection* stepEnsemble( int direction ); - std::vector fieldsToShowInToolbar(); + void syncWithStepper( RimSummaryPlotSourceStepping* other ); + + RimSummaryDataSourceStepping::SourceSteppingDimension stepDimension() const; + void setStepDimension( RimSummaryDataSourceStepping::SourceSteppingDimension dimension ); + + void updateStepIndex( int direction ); + + std::vector plotsMatchingStepSettings( std::vector plots ); private: void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; @@ -85,35 +88,37 @@ class RimSummaryPlotSourceStepping : public caf::PdmObject std::set addressesForCurvesInPlot() const; std::set summaryCasesCurveCollection() const; - std::vector computeVisibleFieldsAndSetFieldVisibility(); std::set ensembleCollection() const; + std::vector activeFieldsForDataSourceStepping(); + std::vector toolbarFieldsForDataSourceStepping(); + bool isXAxisStepping() const; bool isYAxisStepping() const; - RiaSummaryCurveAnalyzer* analyzerForReader( RifSummaryReaderInterface* reader ); + void modifyCurrentIndex( caf::PdmValueField* valueField, int indexOffset, bool notifyChange = true ); - void modifyCurrentIndex( caf::PdmValueField* valueField, int indexOffset ); - - static bool updateAddressIfMatching( const QVariant& oldValue, - const QVariant& newValue, - RifEclipseSummaryAddress::SummaryVarCategory category, - RifEclipseSummaryAddress* adr ); + std::vector summaryCasesForSourceStepping(); - static bool updateHistoryAndSummaryQuantityIfMatching( const QVariant& oldValue, - const QVariant& newValue, - RifEclipseSummaryAddress* adr ); + RimSummaryDataSourceStepping* dataSourceSteppingObject() const; - std::vector summaryCasesForSourceStepping(); + std::map optionsForQuantity( std::set addresses ); + std::map optionsForQuantity( RiaSummaryAddressAnalyzer* analyzser ); private: + caf::PdmPointer m_objectForSourceStepping; + + caf::PdmField m_indexLabel; + + caf::PdmField> m_stepDimension; + caf::PdmPtrField m_summaryCase; caf::PdmPtrField m_ensemble; caf::PdmField m_wellName; - caf::PdmField m_wellGroupName; + caf::PdmField m_groupName; caf::PdmField m_region; - caf::PdmField m_quantity; + caf::PdmField m_vectorName; caf::PdmField m_placeholderForLabel; caf::PdmField m_cellBlock; @@ -124,7 +129,5 @@ class RimSummaryPlotSourceStepping : public caf::PdmObject caf::PdmField m_includeEnsembleCasesForCaseStepping; - SourceSteppingType m_sourceSteppingType; - - std::pair m_curveAnalyzerForReader; + RimSummaryDataSourceStepping::Axis m_sourceSteppingType; }; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryTimeAxisProperties.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryTimeAxisProperties.cpp index 44f3305d12..9c6525c699 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryTimeAxisProperties.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryTimeAxisProperties.cpp @@ -19,15 +19,19 @@ #include "RimSummaryTimeAxisProperties.h" #include "RiaApplication.h" +#include "RiaFieldHandleTools.h" #include "RiaFontCache.h" #include "RiaPreferences.h" +#include "RiaQDateTimeTools.h" +#include "RimSummaryMultiPlot.h" #include "RimSummaryPlot.h" #include "cafPdmUiComboBoxEditor.h" #include "cafPdmUiDateEditor.h" #include "cafPdmUiLineEditor.h" #include "cafPdmUiTimeEditor.h" +#include "cafPdmUiTreeAttributes.h" #include "cvfAssert.h" @@ -68,56 +72,56 @@ CAF_PDM_SOURCE_INIT( RimSummaryTimeAxisProperties, "SummaryTimeAxisProperties" ) //-------------------------------------------------------------------------------------------------- RimSummaryTimeAxisProperties::RimSummaryTimeAxisProperties() { - CAF_PDM_InitObject( "Time Axis", ":/BottomAxis16x16.png", "", "" ); + CAF_PDM_InitObject( "Time Axis", ":/BottomAxis16x16.png" ); - CAF_PDM_InitField( &m_isActive, "Active", true, "Active", "", "", "" ); + CAF_PDM_InitField( &m_isActive, "Active", true, "Active" ); m_isActive.uiCapability()->setUiHidden( true ); - CAF_PDM_InitField( &showTitle, "ShowTitle", false, "Show Title ", "", "", "" ); - CAF_PDM_InitField( &title, "Title", QString( "Time" ), "Title ", "", "", "" ); + CAF_PDM_InitField( &showTitle, "ShowTitle", false, "Show Title " ); + CAF_PDM_InitField( &title, "Title", QString( "Time" ), "Title " ); - CAF_PDM_InitField( &m_isAutoZoom, "AutoZoom", true, "Set Range Automatically", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_timeMode, "TimeMode", "Time Mode", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_timeUnit, "TimeUnit", "Time Unit", "", "", "" ); + CAF_PDM_InitField( &m_isAutoZoom, "AutoZoom", true, "Set Range Automatically" ); + CAF_PDM_InitFieldNoDefault( &m_timeMode, "TimeMode", "Time Mode" ); + CAF_PDM_InitFieldNoDefault( &m_timeUnit, "TimeUnit", "Time Unit" ); - CAF_PDM_InitFieldNoDefault( &m_visibleDateRangeMax, "VisibleDateRangeMax", "Max Date", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_visibleDateRangeMax, "VisibleDateRangeMax", "Max Date" ); m_visibleDateRangeMax.uiCapability()->setUiEditorTypeName( caf::PdmUiDateEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_visibleDateRangeMin, "VisibleDateRangeMin", "Min Date", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_visibleDateRangeMin, "VisibleDateRangeMin", "Min Date" ); m_visibleDateRangeMin.uiCapability()->setUiEditorTypeName( caf::PdmUiDateEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_visibleTimeRangeMax, "VisibleTimeRangeMax", "MaxTime", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_visibleTimeRangeMax, "VisibleTimeRangeMax", "MaxTime" ); m_visibleTimeRangeMax.uiCapability()->setUiEditorTypeName( caf::PdmUiTimeEditor::uiEditorTypeName() ); m_visibleTimeRangeMax.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); - CAF_PDM_InitFieldNoDefault( &m_visibleTimeRangeMin, "VisibleTimeRangeMin", "Min Time", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_visibleTimeRangeMin, "VisibleTimeRangeMin", "Min Time" ); m_visibleTimeRangeMin.uiCapability()->setUiEditorTypeName( caf::PdmUiTimeEditor::uiEditorTypeName() ); m_visibleTimeRangeMin.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); - CAF_PDM_InitFieldNoDefault( &m_visibleTimeSinceStartRangeMax, "VisibleTimeModeRangeMax", "Max", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_visibleTimeSinceStartRangeMax, "VisibleTimeModeRangeMax", "Max" ); m_visibleTimeSinceStartRangeMax.uiCapability()->setUiEditorTypeName( caf::PdmUiLineEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_visibleTimeSinceStartRangeMin, "VisibleTimeModeRangeMin", "Min", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_visibleTimeSinceStartRangeMin, "VisibleTimeModeRangeMin", "Min" ); m_visibleTimeSinceStartRangeMin.uiCapability()->setUiEditorTypeName( caf::PdmUiLineEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_titlePositionEnum, "TitlePosition", "Title Position", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_titleFontSize, "FontSize", "Font Size", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_valuesFontSize, "ValuesFontSize", "Font Size", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_titlePositionEnum, "TitlePosition", "Title Position" ); + CAF_PDM_InitFieldNoDefault( &m_titleFontSize, "FontSize", "Font Size" ); + CAF_PDM_InitFieldNoDefault( &m_valuesFontSize, "ValuesFontSize", "Font Size" ); - CAF_PDM_InitField( &m_automaticDateComponents, "AutoDate", true, "Automatic Date/Time Labels", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_dateComponents, "DateComponents", "Set Date Label", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_timeComponents, "TimeComponents", "Set Time Label", "", "", "" ); + CAF_PDM_InitField( &m_automaticDateComponents, "AutoDate", true, "Automatic Date/Time Labels" ); + CAF_PDM_InitFieldNoDefault( &m_dateComponents, "DateComponents", "Set Date Label" ); + CAF_PDM_InitFieldNoDefault( &m_timeComponents, "TimeComponents", "Set Time Label" ); - CAF_PDM_InitFieldNoDefault( &m_dateFormat, "DateFormat", "Date Label Format", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_dateFormat, "DateFormat", "Date Label Format" ); m_dateFormat.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); m_dateFormat = RiaPreferences::current()->dateFormat(); - CAF_PDM_InitFieldNoDefault( &m_timeFormat, "TimeFormat", "Time Label Format", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_timeFormat, "TimeFormat", "Time Label Format" ); m_timeFormat.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); m_timeFormat = RiaPreferences::current()->timeFormat(); - CAF_PDM_InitFieldNoDefault( &m_majorTickmarkCount, "MajorTickmarkCount", "Major Tickmark Count", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_majorTickmarkCount, "MajorTickmarkCount", "Major Tickmark Count" ); - CAF_PDM_InitFieldNoDefault( &m_annotations, "Annotations", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_annotations, "Annotations", "" ); m_annotations.uiCapability()->setUiTreeHidden( true ); } @@ -132,9 +136,9 @@ RimPlotAxisPropertiesInterface::AxisTitlePositionType RimSummaryTimeAxisProperti //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiaDefines::PlotAxis RimSummaryTimeAxisProperties::plotAxisType() const +RiuPlotAxis RimSummaryTimeAxisProperties::plotAxisType() const { - return RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM; + return RiuPlotAxis::defaultBottom(); } //-------------------------------------------------------------------------------------------------- @@ -161,6 +165,28 @@ caf::FontTools::FontSize RimSummaryTimeAxisProperties::plotFontSize() const return RiaPreferences::current()->defaultPlotFontSize(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryTimeAxisProperties::defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) +{ + RimSummaryMultiPlot* summaryMultiPlot = nullptr; + firstAncestorOfType( summaryMultiPlot ); + + if ( summaryMultiPlot && summaryMultiPlot->isTimeAxisLinked() ) + { + auto* treeItemAttribute = dynamic_cast( attribute ); + if ( treeItemAttribute ) + { + treeItemAttribute->tags.clear(); + auto tag = caf::PdmUiTreeViewItemAttribute::Tag::create(); + tag->icon = caf::IconProvider( ":/chain.png" ); + + treeItemAttribute->tags.push_back( std::move( tag ) ); + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -347,15 +373,29 @@ void RimSummaryTimeAxisProperties::setMajorTickmarkCount( LegendTickmarkCount co m_majorTickmarkCount = count; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const QString RimSummaryTimeAxisProperties::objectName() const +{ + return title(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const QString RimSummaryTimeAxisProperties::axisTitleText() const +{ + return title(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- QList - RimSummaryTimeAxisProperties::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) + RimSummaryTimeAxisProperties::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; - *useOptionsOnly = true; if ( fieldNeedingOptions == &m_dateFormat ) { @@ -364,7 +404,8 @@ QList QDate exampleDate = QDate( 2019, 8, 16 ); QString fullDateFormat = RiaQDateTimeTools::dateFormatString( dateFormat, - dateComponents( RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH_DAY ) ); + dateComponents( + RiaDefines::DateFormatComponents::DATE_FORMAT_YEAR_MONTH_DAY ) ); QString uiText = QString( "%1 (%2)" ).arg( fullDateFormat ).arg( exampleDate.toString( fullDateFormat ) ); uiText.replace( "AP", "AM/PM" ); options.push_back( caf::PdmOptionItemInfo( uiText, QVariant::fromValue( dateFormat ) ) ); @@ -378,7 +419,7 @@ QList QString timeFormatString = RiaQDateTimeTools::timeFormatString( timeFormat, timeComponents( - RiaQDateTimeTools::TimeFormatComponents::TIME_FORMAT_HOUR_MINUTE_SECOND ) ); + RiaDefines::TimeFormatComponents::TIME_FORMAT_HOUR_MINUTE_SECOND ) ); QString uiText = QString( "%1 (%2)" ).arg( timeFormatString ).arg( exampleTime.toString( timeFormatString ) ); uiText.replace( "AP", "AM/PM" ); options.push_back( caf::PdmOptionItemInfo( uiText, QVariant::fromValue( timeFormat ) ) ); @@ -474,12 +515,11 @@ double RimSummaryTimeAxisProperties::fromDaysToDisplayUnitScale() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiaQDateTimeTools::DateFormatComponents - RimSummaryTimeAxisProperties::dateComponents( RiaQDateTimeTools::DateFormatComponents fallback ) const +RiaDefines::DateFormatComponents RimSummaryTimeAxisProperties::dateComponents( RiaDefines::DateFormatComponents fallback ) const { if ( m_automaticDateComponents() ) return fallback; - RiaQDateTimeTools::DateFormatComponents components = m_dateComponents(); + RiaDefines::DateFormatComponents components = m_dateComponents(); return components; } @@ -487,12 +527,11 @@ RiaQDateTimeTools::DateFormatComponents //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiaQDateTimeTools::TimeFormatComponents - RimSummaryTimeAxisProperties::timeComponents( RiaQDateTimeTools::TimeFormatComponents fallback ) const +RiaDefines::TimeFormatComponents RimSummaryTimeAxisProperties::timeComponents( RiaDefines::TimeFormatComponents fallback ) const { if ( m_automaticDateComponents() ) return fallback; - RiaQDateTimeTools::TimeFormatComponents components = m_timeComponents(); + RiaDefines::TimeFormatComponents components = m_timeComponents(); return components; } @@ -502,7 +541,7 @@ RiaQDateTimeTools::TimeFormatComponents //-------------------------------------------------------------------------------------------------- std::vector RimSummaryTimeAxisProperties::annotations() const { - return m_annotations.childObjects(); + return m_annotations.children(); } //-------------------------------------------------------------------------------------------------- @@ -518,7 +557,7 @@ void RimSummaryTimeAxisProperties::appendAnnotation( RimPlotAxisAnnotation* anno //-------------------------------------------------------------------------------------------------- void RimSummaryTimeAxisProperties::removeAllAnnotations() { - m_annotations.clear(); + m_annotations.deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -573,16 +612,23 @@ void RimSummaryTimeAxisProperties::defineUiOrdering( QString uiConfigName, caf:: timeGroup->add( &m_visibleTimeSinceStartRangeMax ); timeGroup->add( &m_visibleTimeSinceStartRangeMin ); } + timeGroup->add( &m_valuesFontSize ); + timeGroup->add( &m_majorTickmarkCount ); + + // Auto Appearance is defined in RimSummaryMultiPlot::analyzePlotsAndAdjustAppearanceSettings() + QString autoAppearanceToolTip = "Controlled by Auto Adjust Appearance"; + RiaFieldHandleTools::updateOverrideStateAndLabel( &m_majorTickmarkCount, isAppearanceOverridden(), autoAppearanceToolTip ); + if ( m_timeMode() == DATE ) { caf::PdmUiGroup* advancedGroup = timeGroup->addNewGroup( "Date/Time Label Format" ); advancedGroup->setCollapsedByDefault( true ); - if ( m_automaticDateComponents() || m_dateComponents() != RiaQDateTimeTools::DATE_FORMAT_NONE ) + if ( m_automaticDateComponents() || m_dateComponents() != RiaDefines::DateFormatComponents::DATE_FORMAT_NONE ) { advancedGroup->add( &m_dateFormat ); } - if ( m_automaticDateComponents() || m_timeComponents() != RiaQDateTimeTools::TimeFormatComponents::TIME_FORMAT_NONE ) + if ( m_automaticDateComponents() || m_timeComponents() != RiaDefines::TimeFormatComponents::TIME_FORMAT_NONE ) { advancedGroup->add( &m_timeFormat ); } @@ -669,6 +715,8 @@ void RimSummaryTimeAxisProperties::fieldChangedByUi( const caf::PdmFieldHandle* } rimSummaryPlot->updateAxes(); + + settingsChanged.send(); } //-------------------------------------------------------------------------------------------------- @@ -684,7 +732,8 @@ void RimSummaryTimeAxisProperties::defineEditorAttribute( const caf::PdmFieldHan if ( dateAttrib ) { dateAttrib->dateFormat = - RiaQDateTimeTools::dateFormatString( m_dateFormat(), RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH_DAY ); + RiaQDateTimeTools::dateFormatString( m_dateFormat(), + RiaDefines::DateFormatComponents::DATE_FORMAT_YEAR_MONTH_DAY ); } } else if ( field == &m_visibleTimeRangeMin || field == &m_visibleTimeRangeMax ) @@ -694,7 +743,7 @@ void RimSummaryTimeAxisProperties::defineEditorAttribute( const caf::PdmFieldHan { timeAttrib->timeFormat = RiaQDateTimeTools::timeFormatString( m_timeFormat(), - RiaQDateTimeTools::TimeFormatComponents::TIME_FORMAT_HOUR_MINUTE_SECOND ); + RiaDefines::TimeFormatComponents::TIME_FORMAT_HOUR_MINUTE_SECOND ); } } } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryTimeAxisProperties.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryTimeAxisProperties.h index ca592ab561..41e908a922 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryTimeAxisProperties.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryTimeAxisProperties.h @@ -18,7 +18,7 @@ #pragma once -#include "RiaQDateTimeTools.h" +#include "RiaDateTimeDefines.h" #include "RimPlotAxisPropertiesInterface.h" #include "RimTimeAxisAnnotation.h" @@ -36,7 +36,7 @@ /// /// //================================================================================================== -class RimSummaryTimeAxisProperties : public caf::PdmObject, public RimPlotAxisPropertiesInterface +class RimSummaryTimeAxisProperties : public RimPlotAxisPropertiesInterface { CAF_PDM_HEADER_INIT; @@ -57,8 +57,8 @@ class RimSummaryTimeAxisProperties : public caf::PdmObject, public RimPlotAxisPr YEARS }; - typedef caf::AppEnum DateFormatEnum; - typedef caf::AppEnum TimeFormatEnum; + typedef caf::AppEnum DateFormatEnum; + typedef caf::AppEnum TimeFormatEnum; public: RimSummaryTimeAxisProperties(); @@ -66,7 +66,7 @@ class RimSummaryTimeAxisProperties : public caf::PdmObject, public RimPlotAxisPr caf::PdmField title; caf::PdmField showTitle; - RiaDefines::PlotAxis plotAxisType() const override; + RiuPlotAxis plotAxisType() const override; AxisTitlePositionType titlePosition() const override; int titleFontSize() const override; int valuesFontSize() const override; @@ -75,11 +75,10 @@ class RimSummaryTimeAxisProperties : public caf::PdmObject, public RimPlotAxisPr double fromTimeTToDisplayUnitScale(); double fromDaysToDisplayUnitScale(); - RiaQDateTimeTools::DateFormatComponents - dateComponents( RiaQDateTimeTools::DateFormatComponents fallback = RiaQDateTimeTools::DATE_FORMAT_UNSPECIFIED ) const; - RiaQDateTimeTools::TimeFormatComponents - timeComponents( RiaQDateTimeTools::TimeFormatComponents fallback = - RiaQDateTimeTools::TimeFormatComponents::TIME_FORMAT_UNSPECIFIED ) const; + RiaDefines::DateFormatComponents dateComponents( + RiaDefines::DateFormatComponents fallback = RiaDefines::DateFormatComponents::DATE_FORMAT_UNSPECIFIED ) const; + RiaDefines::TimeFormatComponents timeComponents( + RiaDefines::TimeFormatComponents fallback = RiaDefines::TimeFormatComponents::TIME_FORMAT_UNSPECIFIED ) const; std::vector annotations() const override; void appendAnnotation( RimPlotAxisAnnotation* annotation ) override; @@ -88,16 +87,16 @@ class RimSummaryTimeAxisProperties : public caf::PdmObject, public RimPlotAxisPr const QString& dateFormat() const; const QString& timeFormat() const; - double visibleRangeMin() const; - double visibleRangeMax() const; + double visibleRangeMin() const override; + double visibleRangeMax() const override; - void setVisibleRangeMin( double value ); - void setVisibleRangeMax( double value ); + void setVisibleRangeMin( double value ) override; + void setVisibleRangeMax( double value ) override; - bool isAutoZoom() const; - void setAutoZoom( bool enableAutoZoom ); + bool isAutoZoom() const override; + void setAutoZoom( bool enableAutoZoom ) override; - bool isActive() const; + bool isActive() const override; QDateTime visibleDateTimeMin() const; QDateTime visibleDateTimeMax() const; @@ -105,13 +104,15 @@ class RimSummaryTimeAxisProperties : public caf::PdmObject, public RimPlotAxisPr void setVisibleDateTimeMin( const QDateTime& dateTime ); void setVisibleDateTimeMax( const QDateTime& dateTime ); - LegendTickmarkCount majorTickmarkCount() const; - void setMajorTickmarkCount( LegendTickmarkCount count ); + LegendTickmarkCount majorTickmarkCount() const override; + void setMajorTickmarkCount( LegendTickmarkCount count ) override; + + const QString objectName() const override; + const QString axisTitleText() const override; protected: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; caf::PdmFieldHandle* objectToggleField() override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineEditorAttribute( const caf::PdmFieldHandle* field, @@ -124,6 +125,9 @@ class RimSummaryTimeAxisProperties : public caf::PdmObject, public RimPlotAxisPr void updateDateVisibleRange(); caf::FontTools::FontSize plotFontSize() const; +private: + void defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; + private: caf::PdmField> m_timeMode; caf::PdmField> m_timeUnit; diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimEnsembleStatisticsSurface.cpp b/ApplicationLibCode/ProjectDataModel/Surfaces/RimEnsembleStatisticsSurface.cpp index d7f45e9301..b13bfe97ec 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimEnsembleStatisticsSurface.cpp +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimEnsembleStatisticsSurface.cpp @@ -35,9 +35,9 @@ CAF_PDM_SOURCE_INIT( RimEnsembleStatisticsSurface, "EnsembleStatisticsSurface" ) //-------------------------------------------------------------------------------------------------- RimEnsembleStatisticsSurface::RimEnsembleStatisticsSurface() { - CAF_PDM_InitScriptableObject( "Surface", ":/ReservoirSurface16x16.png", "", "" ); + CAF_PDM_InitScriptableObject( "Surface", ":/ReservoirSurface16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_statisticsType, "StatisticsType", "StatisticsType", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_statisticsType, "StatisticsType", "StatisticsType" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimEnsembleSurface.cpp b/ApplicationLibCode/ProjectDataModel/Surfaces/RimEnsembleSurface.cpp index 9c0d73058c..0f3e974448 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimEnsembleSurface.cpp +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimEnsembleSurface.cpp @@ -42,9 +42,9 @@ CAF_PDM_SOURCE_INIT( RimEnsembleSurface, "EnsembleSurface" ); //-------------------------------------------------------------------------------------------------- RimEnsembleSurface::RimEnsembleSurface() { - CAF_PDM_InitScriptableObject( "Ensemble Surface", ":/ReservoirSurfaces16x16.png", "", "" ); + CAF_PDM_InitScriptableObject( "Ensemble Surface", ":/ReservoirSurfaces16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_ensembleCurveSet, "FilterEnsembleCurveSet", "Filter by Ensemble Curve Set", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_ensembleCurveSet, "FilterEnsembleCurveSet", "Filter by Ensemble Curve Set" ); std::vector statisticsTypes = { RigSurfaceStatisticsCalculator::StatisticsType::MIN, @@ -229,8 +229,7 @@ const RigSurface* RimEnsembleSurface::statisticsSurface() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimEnsembleSurface::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RimEnsembleSurface::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimEnsembleSurface.h b/ApplicationLibCode/ProjectDataModel/Surfaces/RimEnsembleSurface.h index 495474920c..493f78b7f4 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimEnsembleSurface.h +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimEnsembleSurface.h @@ -55,8 +55,7 @@ class RimEnsembleSurface : public RimSurfaceCollection RimSurface* findStatisticsSurface( RigSurfaceStatisticsCalculator::StatisticsType statisticsType ); protected: - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void initAfterRead() override; diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimFileSurface.cpp b/ApplicationLibCode/ProjectDataModel/Surfaces/RimFileSurface.cpp index 19cff0309f..8e58667746 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimFileSurface.cpp +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimFileSurface.cpp @@ -38,9 +38,9 @@ CAF_PDM_SOURCE_INIT( RimFileSurface, "Surface", "FileSurface" ); //-------------------------------------------------------------------------------------------------- RimFileSurface::RimFileSurface() { - CAF_PDM_InitScriptableObject( "Surface", ":/ReservoirSurface16x16.png", "", "" ); + CAF_PDM_InitScriptableObject( "Surface", ":/ReservoirSurface16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_surfaceDefinitionFilePath, "SurfaceFilePath", "File", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_surfaceDefinitionFilePath, "SurfaceFilePath", "File" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimGridCaseSurface.cpp b/ApplicationLibCode/ProjectDataModel/Surfaces/RimGridCaseSurface.cpp index 6f8d1da5c4..2fab377fce 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimGridCaseSurface.cpp +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimGridCaseSurface.cpp @@ -40,14 +40,14 @@ CAF_PDM_SOURCE_INIT( RimGridCaseSurface, "GridCaseSurface" ); //-------------------------------------------------------------------------------------------------- RimGridCaseSurface::RimGridCaseSurface() { - CAF_PDM_InitScriptableObject( "Surface", ":/ReservoirSurface16x16.png", "", "" ); + CAF_PDM_InitScriptableObject( "Surface", ":/ReservoirSurface16x16.png" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_case, "SourceCase", "Source Case", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_case, "SourceCase", "Source Case" ); - CAF_PDM_InitScriptableField( &m_oneBasedSliceIndex, "SliceIndex", 1, "Slice Index (K)", "", "", "" ); + CAF_PDM_InitScriptableField( &m_oneBasedSliceIndex, "SliceIndex", 1, "Slice Index (K)" ); m_oneBasedSliceIndex.uiCapability()->setUiEditorTypeName( caf::PdmUiSliderEditor::uiEditorTypeName() ); - CAF_PDM_InitScriptableField( &m_watertight, "Watertight", false, "Watertight Surface (fill gaps)", "", "", "" ); + CAF_PDM_InitScriptableField( &m_watertight, "Watertight", false, "Watertight Surface (fill gaps)" ); } //-------------------------------------------------------------------------------------------------- @@ -102,8 +102,7 @@ RimSurface* RimGridCaseSurface::createCopy() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimGridCaseSurface::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RimGridCaseSurface::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimGridCaseSurface.h b/ApplicationLibCode/ProjectDataModel/Surfaces/RimGridCaseSurface.h index 22980b6e28..3626e1894d 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimGridCaseSurface.h +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimGridCaseSurface.h @@ -48,8 +48,7 @@ class RimGridCaseSurface : public RimSurface std::vector>* structGridVertexIndices ); protected: - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurface.cpp b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurface.cpp index cc1bea4c4f..dc7c979412 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurface.cpp +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurface.cpp @@ -53,16 +53,16 @@ void caf::AppEnum::setUp() //-------------------------------------------------------------------------------------------------- RimSurface::RimSurface() { - CAF_PDM_InitScriptableObject( "Surface", ":/ReservoirSurface16x16.png", "", "" ); + CAF_PDM_InitScriptableObject( "Surface", ":/ReservoirSurface16x16.png" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_userDescription, "SurfaceUserDecription", "Name", "", "", "" ); - CAF_PDM_InitField( &m_color, "SurfaceColor", cvf::Color3f( 0.5f, 0.3f, 0.2f ), "Color", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_userDescription, "SurfaceUserDecription", "Name" ); + CAF_PDM_InitField( &m_color, "SurfaceColor", cvf::Color3f( 0.5f, 0.3f, 0.2f ), "Color" ); - CAF_PDM_InitScriptableField( &m_depthOffset, "DepthOffset", 0.0, "Depth Offset", "", "", "" ); + CAF_PDM_InitScriptableField( &m_depthOffset, "DepthOffset", 0.0, "Depth Offset" ); m_depthOffset.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); m_depthOffset.capability()->setIOWriteable( true ); - CAF_PDM_InitFieldNoDefault( &m_nameProxy, "NameProxy", "Name Proxy", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_nameProxy, "NameProxy", "Name Proxy" ); m_nameProxy.registerGetMethod( this, &RimSurface::fullName ); m_nameProxy.uiCapability()->setUiReadOnly( true ); m_nameProxy.uiCapability()->setUiHidden( true ); diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceCollection.cpp b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceCollection.cpp index 26b2734666..c94cbf2d31 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceCollection.cpp @@ -49,17 +49,17 @@ CAF_PDM_SOURCE_INIT( RimSurfaceCollection, "SurfaceCollection" ); //-------------------------------------------------------------------------------------------------- RimSurfaceCollection::RimSurfaceCollection() { - CAF_PDM_InitScriptableObject( "Surfaces", ":/ReservoirSurfaces16x16.png", "", "" ); + CAF_PDM_InitScriptableObject( "Surfaces", ":/ReservoirSurfaces16x16.png" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_collectionName, "SurfaceUserDecription", "Name", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_collectionName, "SurfaceUserDecription", "Name" ); m_collectionName = "Surfaces"; - CAF_PDM_InitScriptableFieldNoDefault( &m_subCollections, "SubCollections", "Surfaces", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_subCollections, "SubCollections", "Surfaces" ); m_subCollections.uiCapability()->setUiTreeHidden( true ); auto reorderability = caf::PdmFieldReorderCapability::addToField( &m_subCollections ); reorderability->orderChanged.connect( this, &RimSurfaceCollection::orderChanged ); - CAF_PDM_InitScriptableFieldNoDefault( &m_surfaces, "SurfacesField", "Surfaces", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_surfaces, "SurfacesField", "Surfaces" ); m_surfaces.uiCapability()->setUiTreeHidden( true ); setDeletable( true ); @@ -269,7 +269,7 @@ RimSurface* RimSurfaceCollection::addGridCaseSurface( RimCase* sourceCase, int o //-------------------------------------------------------------------------------------------------- std::vector RimSurfaceCollection::surfaces() const { - return m_surfaces.childObjects(); + return m_surfaces.children(); } //-------------------------------------------------------------------------------------------------- @@ -277,7 +277,7 @@ std::vector RimSurfaceCollection::surfaces() const //-------------------------------------------------------------------------------------------------- std::vector RimSurfaceCollection::subCollections() const { - return m_subCollections.childObjects(); + return m_subCollections.children(); } //-------------------------------------------------------------------------------------------------- @@ -392,7 +392,7 @@ void RimSurfaceCollection::orderChanged( const caf::SignalEmitter* emitter ) //-------------------------------------------------------------------------------------------------- void RimSurfaceCollection::removeSurface( RimSurface* surface ) { - m_surfaces.removeChildObject( surface ); + m_surfaces.removeChild( surface ); } //-------------------------------------------------------------------------------------------------- @@ -466,7 +466,7 @@ RimSurface* RimSurfaceCollection::addSurfacesAtIndex( int position, std::vector< } // reset the surface collection and use the new order - m_surfaces.clear(); + m_surfaces.clearWithoutDelete(); for ( auto surf : orderedSurfs ) { m_surfaces.push_back( surf ); @@ -513,7 +513,7 @@ void RimSurfaceCollection::deleteSubCollection( const QString& name ) auto coll = getSubCollection( name ); if ( coll ) { - auto index = m_subCollections.index( coll ); + auto index = m_subCollections.indexOf( coll ); m_subCollections.erase( index ); } } diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceInView.cpp b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceInView.cpp index 6086bcbd72..e3bfb3e386 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceInView.cpp +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceInView.cpp @@ -41,17 +41,17 @@ CAF_PDM_SOURCE_INIT( RimSurfaceInView, "SurfaceInView" ); //-------------------------------------------------------------------------------------------------- RimSurfaceInView::RimSurfaceInView() { - CAF_PDM_InitObject( "Surface", ":/ReservoirSurface16x16.png", "", "" ); + CAF_PDM_InitObject( "Surface", ":/ReservoirSurface16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_name, "Name", "Name", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_name, "Name", "Name" ); m_name.registerGetMethod( this, &RimSurfaceInView::name ); m_name.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitFieldNoDefault( &m_surface, "SurfaceRef", "Surface", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_surface, "SurfaceRef", "Surface" ); m_surface.uiCapability()->setUiHidden( true ); m_surface.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_resultDefinition, "ResultDefinition", "Result Definition", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_resultDefinition, "ResultDefinition", "Result Definition" ); m_resultDefinition.uiCapability()->setUiTreeHidden( true ); m_resultDefinition.uiCapability()->setUiTreeChildrenHidden( true ); m_resultDefinition = new RimSurfaceResultDefinition; diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceInViewCollection.cpp b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceInViewCollection.cpp index 96e5ba59d1..7107800e88 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceInViewCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceInViewCollection.cpp @@ -41,25 +41,20 @@ CAF_PDM_SOURCE_INIT( RimSurfaceInViewCollection, "SurfaceInViewCollection" ); //-------------------------------------------------------------------------------------------------- RimSurfaceInViewCollection::RimSurfaceInViewCollection() { - CAF_PDM_InitObject( "Surfaces", ":/ReservoirSurfaces16x16.png", "", "" ); + CAF_PDM_InitObject( "Surfaces", ":/ReservoirSurfaces16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_collectionName, "CollectionName", "Name", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_collectionName, "CollectionName", "Name" ); m_collectionName.registerGetMethod( this, &RimSurfaceInViewCollection::name ); m_collectionName.uiCapability()->setUiReadOnly( true ); m_collectionName.xmlCapability()->disableIO(); - CAF_PDM_InitFieldNoDefault( &m_collectionsInView, - "SurfacesInViewFieldCollections", - "SurfacesInViewFieldCollections", - "", - "", - "" ); + CAF_PDM_InitFieldNoDefault( &m_collectionsInView, "SurfacesInViewFieldCollections", "SurfacesInViewFieldCollections" ); m_collectionsInView.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_surfacesInView, "SurfacesInViewField", "SurfacesInViewField", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_surfacesInView, "SurfacesInViewField", "SurfacesInViewField" ); m_surfacesInView.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_surfaceCollection, "SurfaceCollectionRef", "SurfaceCollection", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_surfaceCollection, "SurfaceCollectionRef", "SurfaceCollection" ); m_surfaceCollection.uiCapability()->setUiHidden( true ); nameField()->uiCapability()->setUiHidden( true ); @@ -142,13 +137,13 @@ void RimSurfaceInViewCollection::updateAllViewItems() void RimSurfaceInViewCollection::syncCollectionsWithView() { // check that we have surface in view collections for all sub-collections - std::vector colls = m_collectionsInView.childObjects(); + std::vector colls = m_collectionsInView.children(); for ( auto surfcoll : colls ) { if ( !surfcoll->surfaceCollection() ) { - m_collectionsInView.removeChildObject( surfcoll ); + m_collectionsInView.removeChild( surfcoll ); delete surfcoll; } } @@ -177,7 +172,7 @@ void RimSurfaceInViewCollection::syncCollectionsWithView() } // make sure our view surfaces have the same order as the source surface collection - m_collectionsInView.clear(); + m_collectionsInView.clearWithoutDelete(); for ( auto viewColl : orderedColls ) { m_collectionsInView.push_back( viewColl ); @@ -193,13 +188,13 @@ void RimSurfaceInViewCollection::syncSurfacesWithView() { // Delete surfaceInView without any real Surface connection - std::vector surfsInView = m_surfacesInView.childObjects(); + std::vector surfsInView = m_surfacesInView.children(); for ( auto surf : surfsInView ) { if ( !surf->surface() ) { - m_surfacesInView.removeChildObject( surf ); + m_surfacesInView.removeChild( surf ); delete surf; } } @@ -234,7 +229,7 @@ void RimSurfaceInViewCollection::syncSurfacesWithView() } // make sure our view surfaces have the same order as the source surface collection - m_surfacesInView.clear(); + m_surfacesInView.clearWithoutDelete(); for ( auto viewSurf : orderedSurfs ) { m_surfacesInView.push_back( viewSurf ); diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceResultDefinition.cpp b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceResultDefinition.cpp index 6ecd9154db..55f00712f7 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceResultDefinition.cpp +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceResultDefinition.cpp @@ -36,18 +36,18 @@ CAF_PDM_SOURCE_INIT( RimSurfaceResultDefinition, "SurfaceResultDefinition" ); //-------------------------------------------------------------------------------------------------- RimSurfaceResultDefinition::RimSurfaceResultDefinition() { - CAF_PDM_InitObject( "Surface", ":/ReservoirSurface16x16.png", "", "" ); + CAF_PDM_InitObject( "Surface", ":/ReservoirSurface16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_propertyName, "PropertyName", "Property Name", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_propertyName, "PropertyName", "Property Name" ); - CAF_PDM_InitFieldNoDefault( &m_legendConfig, "LegendConfig", "Legend", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_legendConfig, "LegendConfig", "Legend" ); m_legendConfig.uiCapability()->setUiTreeHidden( true ); m_legendConfig.uiCapability()->setUiTreeChildrenHidden( false ); m_legendConfig = new RimRegularLegendConfig; setName( "Surface Result" ); - CAF_PDM_InitFieldNoDefault( &m_surfaceInView, "SurfaceInView", "Surface In View", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_surfaceInView, "SurfaceInView", "Surface In View" ); m_surfaceInView.uiCapability()->setUiHidden( true ); m_surfaceInView.uiCapability()->setUiTreeChildrenHidden( true ); } @@ -171,7 +171,7 @@ void RimSurfaceResultDefinition::defineUiOrdering( QString uiConfigName, caf::Pd /// //-------------------------------------------------------------------------------------------------- QList - RimSurfaceResultDefinition::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) + RimSurfaceResultDefinition::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceResultDefinition.h b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceResultDefinition.h index 0dbaff678e..c572cbd6f2 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceResultDefinition.h +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceResultDefinition.h @@ -50,10 +50,9 @@ class RimSurfaceResultDefinition : public RimCheckableNamedObject void assignDefaultProperty(); private: - void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; RigSurface* surfaceData(); diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/WellLog/CMakeLists_files.cmake index 861abfda47..334773ffc9 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/CMakeLists_files.cmake +++ b/ApplicationLibCode/ProjectDataModel/WellLog/CMakeLists_files.cmake @@ -23,6 +23,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RimWellLogFileCurve.h ${CMAKE_CURRENT_LIST_DIR}/RimWellLogRftCurve.h ${CMAKE_CURRENT_LIST_DIR}/RimWellLogWbsCurve.h + ${CMAKE_CURRENT_LIST_DIR}/RimRftTools.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -50,6 +51,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RimEnsembleWellLogCurveSet.cpp ${CMAKE_CURRENT_LIST_DIR}/RimEnsembleWellLogStatistics.cpp ${CMAKE_CURRENT_LIST_DIR}/RimEnsembleWellLogStatisticsCurve.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimRftTools.cpp ) list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogCurve.cpp index e8b57132ef..2e64283d16 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogCurve.cpp @@ -60,9 +60,9 @@ Rim3dWellLogCurve::Rim3dWellLogCurve() : m_minCurveDataValue( -std::numeric_limits::infinity() ) , m_maxCurveDataValue( std::numeric_limits::infinity() ) { - CAF_PDM_InitObject( "3d Well Log Curve", ":/WellLogCurve16x16.png", "", "" ); + CAF_PDM_InitObject( "3d Well Log Curve", ":/WellLogCurve16x16.png" ); - CAF_PDM_InitField( &m_showCurve, "Show3dWellLogCurve", true, "Show 3d Well Log Curve", "", "", "" ); + CAF_PDM_InitField( &m_showCurve, "Show3dWellLogCurve", true, "Show 3d Well Log Curve" ); m_showCurve.uiCapability()->setUiHidden( true ); CAF_PDM_InitField( &m_minCurveUIValue, "MinCurveValue", @@ -79,8 +79,8 @@ Rim3dWellLogCurve::Rim3dWellLogCurve() "Clip curve values above this.", "" ); - CAF_PDM_InitField( &m_drawPlane, "DrawPlane", DrawPlaneEnum( VERTICAL_ABOVE ), "Draw Plane", "", "", "" ); - CAF_PDM_InitField( &m_color, "CurveColor", cvf::Color3f( 0.0f, 0.0f, 0.0f ), "Curve Color", "", "", "" ); + CAF_PDM_InitField( &m_drawPlane, "DrawPlane", DrawPlaneEnum( VERTICAL_ABOVE ), "Draw Plane" ); + CAF_PDM_InitField( &m_color, "CurveColor", cvf::Color3f( 0.0f, 0.0f, 0.0f ), "Curve Color" ); this->uiCapability()->setUiTreeChildrenHidden( true ); } diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogExtractionCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogExtractionCurve.cpp index 679b21743d..d703adc36c 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogExtractionCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogExtractionCurve.cpp @@ -64,27 +64,27 @@ CAF_PDM_SOURCE_INIT( Rim3dWellLogExtractionCurve, "Rim3dWellLogExtractionCurve" //-------------------------------------------------------------------------------------------------- Rim3dWellLogExtractionCurve::Rim3dWellLogExtractionCurve() { - CAF_PDM_InitObject( "3d Well Log Extraction Curve", ":/WellLogCurve16x16.png", "", "" ); + CAF_PDM_InitObject( "3d Well Log Extraction Curve", ":/WellLogCurve16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_case, "CurveCase", "Case", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_case, "CurveCase", "Case" ); m_case.uiCapability()->setUiTreeChildrenHidden( true ); m_case = nullptr; - CAF_PDM_InitField( &m_timeStep, "CurveTimeStep", -1, "Time Step", "", "", "" ); + CAF_PDM_InitField( &m_timeStep, "CurveTimeStep", -1, "Time Step" ); - CAF_PDM_InitFieldNoDefault( &m_eclipseResultDefinition, "CurveEclipseResult", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_eclipseResultDefinition, "CurveEclipseResult", "" ); m_eclipseResultDefinition.uiCapability()->setUiTreeHidden( true ); m_eclipseResultDefinition.uiCapability()->setUiTreeChildrenHidden( true ); m_eclipseResultDefinition = new RimEclipseResultDefinition; m_eclipseResultDefinition->findField( "MResultType" )->uiCapability()->setUiName( "Result Type" ); - CAF_PDM_InitFieldNoDefault( &m_geomResultDefinition, "CurveGeomechResult", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_geomResultDefinition, "CurveGeomechResult", "" ); m_geomResultDefinition.uiCapability()->setUiTreeHidden( true ); m_geomResultDefinition.uiCapability()->setUiTreeChildrenHidden( true ); m_geomResultDefinition = new RimGeoMechResultDefinition; m_geomResultDefinition->setAddWellPathDerivedResults( true ); - CAF_PDM_InitFieldNoDefault( &m_nameConfig, "NameConfig", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_nameConfig, "NameConfig", "" ); m_nameConfig = new RimWellLogExtractionCurveNameConfig(); } @@ -457,11 +457,11 @@ void Rim3dWellLogExtractionCurve::fieldChangedByUi( const caf::PdmFieldHandle* c /// //-------------------------------------------------------------------------------------------------- QList - Rim3dWellLogExtractionCurve::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) + Rim3dWellLogExtractionCurve::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; - options = Rim3dWellLogCurve::calculateValueOptions( fieldNeedingOptions, useOptionsOnly ); + options = Rim3dWellLogCurve::calculateValueOptions( fieldNeedingOptions ); if ( fieldNeedingOptions == &m_case ) { diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogExtractionCurve.h b/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogExtractionCurve.h index f6511d0af5..00a710e36a 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogExtractionCurve.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogExtractionCurve.h @@ -65,8 +65,7 @@ class Rim3dWellLogExtractionCurve : public Rim3dWellLogCurve void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; private: - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void initAfterRead() override; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogFileCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogFileCurve.cpp index 7111dbd879..fa524bab52 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogFileCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogFileCurve.cpp @@ -39,13 +39,13 @@ CAF_PDM_SOURCE_INIT( Rim3dWellLogFileCurve, "Rim3dWellLogFileCurve" ); //-------------------------------------------------------------------------------------------------- Rim3dWellLogFileCurve::Rim3dWellLogFileCurve() { - CAF_PDM_InitObject( "3d Well Log File Curve", ":/WellLogCurve16x16.png", "", "" ); + CAF_PDM_InitObject( "3d Well Log File Curve", ":/WellLogCurve16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_wellLogChannelName, "CurveWellLogChannel", "Well Log Channel", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wellLogChannelName, "CurveWellLogChannel", "Well Log Channel" ); - CAF_PDM_InitFieldNoDefault( &m_wellLogFile, "WellLogFile", "Well Log File", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wellLogFile, "WellLogFile", "Well Log File" ); - CAF_PDM_InitFieldNoDefault( &m_nameConfig, "NameConfig", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_nameConfig, "NameConfig", "" ); m_nameConfig = new RimWellLogFileCurveNameConfig(); } @@ -195,12 +195,11 @@ void Rim3dWellLogFileCurve::fieldChangedByUi( const caf::PdmFieldHandle* changed //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList - Rim3dWellLogFileCurve::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) +QList Rim3dWellLogFileCurve::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; - options = Rim3dWellLogCurve::calculateValueOptions( fieldNeedingOptions, useOptionsOnly ); + options = Rim3dWellLogCurve::calculateValueOptions( fieldNeedingOptions ); if ( !options.empty() ) return options; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogFileCurve.h b/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogFileCurve.h index 08e4dbd669..9e356e59f0 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogFileCurve.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogFileCurve.h @@ -50,8 +50,7 @@ class Rim3dWellLogFileCurve : public Rim3dWellLogCurve void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; private: - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogRftCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogRftCurve.cpp index fb67f8bdea..fe2dabd084 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogRftCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogRftCurve.cpp @@ -25,8 +25,10 @@ #include "RigWellLogCurveData.h" #include "RimEclipseResultCase.h" +#include "RimRftTools.h" #include "RimTools.h" #include "RimWellLogCurve.h" +#include "RimWellLogRftCurve.h" #include "RimWellLogRftCurveNameConfig.h" #include "RimWellPath.h" @@ -42,19 +44,19 @@ CAF_PDM_SOURCE_INIT( Rim3dWellLogRftCurve, "Rim3dWellLogRftCurve" ); //-------------------------------------------------------------------------------------------------- Rim3dWellLogRftCurve::Rim3dWellLogRftCurve() { - CAF_PDM_InitObject( "3d Well Log RFT Curve", ":/WellLogCurve16x16.png", "", "" ); + CAF_PDM_InitObject( "3d Well Log RFT Curve", ":/WellLogCurve16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_eclipseResultCase, "eclipseResultCase", "", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_timeStep, "timeStep", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_eclipseResultCase, "eclipseResultCase", "" ); + CAF_PDM_InitFieldNoDefault( &m_timeStep, "timeStep", "" ); - CAF_PDM_InitFieldNoDefault( &m_wellLogChannelName, "wellLogChannelName", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wellLogChannelName, "wellLogChannelName", "" ); - CAF_PDM_InitFieldNoDefault( &m_2dWellLogRftCurve, "my2dWellLogRftCurve", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_2dWellLogRftCurve, "my2dWellLogRftCurve", "" ); m_2dWellLogRftCurve = new RimWellLogRftCurve(); m_2dWellLogRftCurve.xmlCapability()->disableIO(); - CAF_PDM_InitFieldNoDefault( &m_nameConfig, "NameConfig", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_nameConfig, "NameConfig", "" ); m_nameConfig = new RimWellLogRftCurveNameConfig(); } @@ -79,7 +81,7 @@ void Rim3dWellLogRftCurve::curveValuesAndMds( std::vector* values, std:: const RigWellLogCurveData* curveData = m_2dWellLogRftCurve->curveData(); // These values are for a simulation well - *values = curveData->xValues(); + *values = curveData->propertyValues(); *measuredDepthValues = curveData->depths( RiaDefines::DepthTypeEnum::MEASURED_DEPTH ); } @@ -117,8 +119,8 @@ QString Rim3dWellLogRftCurve::createAutoName() const { name.push_back( m_eclipseResultCase->caseUserDescription() ); } - if ( m_wellLogChannelName().text() != - caf::AppEnum::text( RifEclipseRftAddress::NONE ) ) + if ( m_wellLogChannelName().text() != caf::AppEnum::text( + RifEclipseRftAddress::RftWellLogChannelType::NONE ) ) { RifEclipseRftAddress::RftWellLogChannelType channelNameEnum = m_wellLogChannelName(); name.push_back( caf::AppEnum::uiText( channelNameEnum ) ); @@ -157,8 +159,7 @@ void Rim3dWellLogRftCurve::fieldChangedByUi( const caf::PdmFieldHandle* changedF //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList - Rim3dWellLogRftCurve::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) +QList Rim3dWellLogRftCurve::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; @@ -172,44 +173,19 @@ QList { if ( m_eclipseResultCase ) { - RifReaderEclipseRft* reader = m_eclipseResultCase()->rftReader(); - if ( reader ) - { - for ( const RifEclipseRftAddress::RftWellLogChannelType& channelName : - reader->availableWellLogChannels( wellName() ) ) - { - options.push_back( - caf::PdmOptionItemInfo( caf::AppEnum::uiText( - channelName ), - channelName ) ); - } - } - if ( options.empty() ) - { - options.push_back( caf::PdmOptionItemInfo( caf::AppEnum::uiText( - RifEclipseRftAddress::NONE ), - RifEclipseRftAddress::NONE ) ); - } + RifReaderRftInterface* reader = m_eclipseResultCase()->rftReader(); + options = RimRftTools::wellLogChannelsOptions( reader, wellName() ); } } else if ( fieldNeedingOptions == &m_timeStep ) { if ( m_eclipseResultCase ) { - RifReaderEclipseRft* reader = m_eclipseResultCase()->rftReader(); + RifReaderRftInterface* reader = m_eclipseResultCase()->rftReader(); if ( reader ) { - QString dateFormat = "dd MMM yyyy"; - std::set timeStamps = reader->availableTimeSteps( wellName(), m_wellLogChannelName() ); - for ( const QDateTime& dt : timeStamps ) - { - QString dateString = RiaQDateTimeTools::toStringUsingApplicationLocale( dt, dateFormat ); - - options.push_back( caf::PdmOptionItemInfo( dateString, dt ) ); - } + options = RimRftTools::timeStepOptions( reader, wellName(), m_wellLogChannelName() ); } - - options.push_back( caf::PdmOptionItemInfo( "None", QDateTime() ) ); } } return options; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogRftCurve.h b/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogRftCurve.h index 5dee8b1c78..6083f57458 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogRftCurve.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogRftCurve.h @@ -25,10 +25,10 @@ #include "cafPdmPtrField.h" #include "RifEclipseRftAddress.h" -#include "RimWellLogRftCurve.h" class RimEclipseResultCase; class RimWellLogRftCurveNameConfig; +class RimWellLogRftCurve; class QString; //================================================================================================== @@ -55,8 +55,7 @@ class Rim3dWellLogRftCurve : public Rim3dWellLogCurve void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; private: - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogCurveSet.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogCurveSet.cpp index 82b8524397..758d7e30ba 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogCurveSet.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogCurveSet.cpp @@ -61,6 +61,7 @@ #include "cvfObject.h" +#include "qwt_plot.h" #include "qwt_plot_curve.h" #include "qwt_symbol.h" @@ -70,7 +71,7 @@ //-------------------------------------------------------------------------------------------------- /// Internal functions //-------------------------------------------------------------------------------------------------- -int statisticsCurveSymbolSize( RiuQwtSymbol::PointSymbolEnum symbol ); +int statisticsCurveSymbolSize( RiuPlotCurveSymbol::PointSymbolEnum symbol ); namespace caf { @@ -94,48 +95,48 @@ RimEnsembleWellLogCurveSet::RimEnsembleWellLogCurveSet() : filterChanged( this ) { - CAF_PDM_InitObject( "Ensemble Curve Set", ":/EnsembleCurveSet16x16.png", "", "" ); + CAF_PDM_InitObject( "Ensemble Curve Set", ":/EnsembleCurveSet16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_curves, "EnsembleCurveSet", "Ensemble Curve Set", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_curves, "EnsembleCurveSet", "Ensemble Curve Set" ); m_curves.uiCapability()->setUiHidden( true ); m_curves.uiCapability()->setUiTreeChildrenHidden( false ); - CAF_PDM_InitField( &m_showCurves, "IsActive", true, "Show Curves", "", "", "" ); + CAF_PDM_InitField( &m_showCurves, "IsActive", true, "Show Curves" ); m_showCurves.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_ensembleWellLogs, "EnsembleWellLogs", "Ensemble Well Logs", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_ensembleWellLogs, "EnsembleWellLogs", "Ensemble Well Logs" ); m_ensembleWellLogs.uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitField( &m_wellLogChannelName, "WellLogChannelName", QString( "None" ), "Well Log Channel Name", "", "", "" ); + CAF_PDM_InitField( &m_wellLogChannelName, "WellLogChannelName", QString( "None" ), "Well Log Channel Name" ); - CAF_PDM_InitFieldNoDefault( &m_ensembleCurveSet, "FilterEnsembleCurveSet", "Filter by Ensemble Curve Set", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_depthEqualization, "DepthEqualization", "Depth Equalization", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_ensembleCurveSet, "FilterEnsembleCurveSet", "Filter by Ensemble Curve Set" ); + CAF_PDM_InitFieldNoDefault( &m_depthEqualization, "DepthEqualization", "Depth Equalization" ); - CAF_PDM_InitField( &m_colorMode, "ColorMode", caf::AppEnum( ColorMode::SINGLE_COLOR ), "Coloring Mode", "", "", "" ); + CAF_PDM_InitField( &m_colorMode, "ColorMode", caf::AppEnum( ColorMode::SINGLE_COLOR ), "Coloring Mode" ); - CAF_PDM_InitField( &m_color, "Color", RiaColorTools::textColor3f(), "Color", "", "", "" ); + CAF_PDM_InitField( &m_color, "Color", RiaColorTools::textColor3f(), "Color" ); - CAF_PDM_InitFieldNoDefault( &m_statistics, "Statistics", "Statistics", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_statistics, "Statistics", "Statistics" ); m_statistics = new RimEnsembleStatistics( this ); m_statistics.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitField( &m_userDefinedName, "UserDefinedName", QString( "Ensemble Curve Set" ), "Curve Set Name", "", "", "" ); + CAF_PDM_InitField( &m_userDefinedName, "UserDefinedName", QString( "Ensemble Curve Set" ), "Curve Set Name" ); - CAF_PDM_InitFieldNoDefault( &m_autoGeneratedName, "AutoGeneratedName", "Curve Set Name", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_autoGeneratedName, "AutoGeneratedName", "Curve Set Name" ); m_autoGeneratedName.registerGetMethod( this, &RimEnsembleWellLogCurveSet::createAutoName ); m_autoGeneratedName.uiCapability()->setUiReadOnly( true ); m_autoGeneratedName.xmlCapability()->disableIO(); - CAF_PDM_InitField( &m_isUsingAutoName, "AutoName", true, "Auto Name", "", "", "" ); + CAF_PDM_InitField( &m_isUsingAutoName, "AutoName", true, "Auto Name" ); - CAF_PDM_InitFieldNoDefault( &m_curveAppearance, "PlotCurveAppearance", "PlotCurveAppearance", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_curveAppearance, "PlotCurveAppearance", "PlotCurveAppearance" ); m_curveAppearance = new RimPlotCurveAppearance; m_curveAppearance.uiCapability()->setUiTreeHidden( true ); m_curveAppearance->setInterpolationVisible( false ); m_curveAppearance->setColorVisible( false ); m_curveAppearance->setFillOptionsVisible( false ); - m_curveAppearance->setSymbol( RiuQwtSymbol::PointSymbolEnum::SYMBOL_ELLIPSE ); + m_curveAppearance->setSymbol( RiuPlotCurveSymbol::PointSymbolEnum::SYMBOL_ELLIPSE ); m_curveAppearance->setSymbolSize( 5 ); m_curveAppearance->setLineStyle( RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_NONE ); m_curveAppearance->setSymbolEdgeColor( cvf::Color3f::BLACK ); @@ -218,22 +219,22 @@ void RimEnsembleWellLogCurveSet::loadDataAndUpdate( bool updateParentPlot ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsembleWellLogCurveSet::setParentQwtPlotNoReplot( QwtPlot* plot ) +void RimEnsembleWellLogCurveSet::setParentPlotNoReplot( RiuPlotWidget* plot ) { for ( RimWellLogCurve* curve : m_curves ) { - curve->setParentQwtPlotNoReplot( plot ); + curve->setParentPlotNoReplot( plot ); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsembleWellLogCurveSet::detachQwtCurves() +void RimEnsembleWellLogCurveSet::detachPlotCurves() { for ( RimWellLogCurve* curve : m_curves ) { - curve->detachQwtCurve(); + curve->detach(); } m_qwtPlotCurveForLegendText->detach(); @@ -242,11 +243,11 @@ void RimEnsembleWellLogCurveSet::detachQwtCurves() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsembleWellLogCurveSet::reattachQwtCurves() +void RimEnsembleWellLogCurveSet::reattachPlotCurves() { for ( RimWellLogCurve* curve : m_curves ) { - curve->reattachQwtCurve(); + curve->reattach(); } m_qwtPlotCurveForLegendText->detach(); @@ -255,7 +256,7 @@ void RimEnsembleWellLogCurveSet::reattachQwtCurves() firstAncestorOrThisOfType( plot ); if ( plot ) { - m_qwtPlotCurveForLegendText->attach( plot->viewer() ); + m_qwtPlotCurveForLegendText->attach( plot->viewer()->qwtPlot() ); } } @@ -560,7 +561,7 @@ caf::PdmFieldHandle* RimEnsembleWellLogCurveSet::objectToggleField() /// //-------------------------------------------------------------------------------------------------- QList - RimEnsembleWellLogCurveSet::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) + RimEnsembleWellLogCurveSet::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; @@ -637,8 +638,8 @@ void RimEnsembleWellLogCurveSet::updateFilterLegend() { if ( !m_filterOverlayFrame ) { - m_filterOverlayFrame = - new RiuDraggableOverlayFrame( plotTrack->viewer()->canvas(), plotTrack->viewer()->overlayMargins() ); + m_filterOverlayFrame = new RiuDraggableOverlayFrame( plotTrack->viewer()->qwtPlot()->canvas(), + plotTrack->viewer()->overlayMargins() ); } m_filterOverlayFrame->setContentFrame( m_ensembleCurveSet->curveFilters()->makeFilterDescriptionFrame() ); plotTrack->viewer()->addOverlayFrame( m_filterOverlayFrame ); @@ -735,8 +736,8 @@ void RimEnsembleWellLogCurveSet::updateCurveColors() { if ( !m_legendOverlayFrame ) { - m_legendOverlayFrame = - new RiuDraggableOverlayFrame( plotTrack->viewer()->canvas(), plotTrack->viewer()->overlayMargins() ); + m_legendOverlayFrame = new RiuDraggableOverlayFrame( plotTrack->viewer()->getParentForOverlay(), + plotTrack->viewer()->overlayMargins() ); } m_legendOverlayFrame->setContentFrame( m_ensembleCurveSet->legendConfig()->makeLegendFrame() ); plotTrack->viewer()->addOverlayFrame( m_legendOverlayFrame ); @@ -780,7 +781,7 @@ void RimEnsembleWellLogCurveSet::updateEnsembleCurves( const std::vectorattach( plotTrack->viewer() ); + m_qwtPlotCurveForLegendText->attach( plotTrack->viewer()->qwtPlot() ); QString wellLogChannelName = m_wellLogChannelName(); if ( plotTrack && wellLogChannelName != "None" ) @@ -920,11 +921,13 @@ void RimEnsembleWellLogCurveSet::updateStatisticsCurves( const std::vector curves() const; @@ -137,8 +138,7 @@ class RimEnsembleWellLogCurveSet : public caf::PdmObject, public RimEnsembleCurv caf::PdmFieldHandle* objectToggleField() override; void initAfterRead() override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogStatisticsCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogStatisticsCurve.cpp index ca1b996876..c35d643e78 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogStatisticsCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogStatisticsCurve.cpp @@ -39,13 +39,13 @@ CAF_PDM_SOURCE_INIT( RimEnsembleWellLogStatisticsCurve, "EnsembleWellLogStatisti //-------------------------------------------------------------------------------------------------- RimEnsembleWellLogStatisticsCurve::RimEnsembleWellLogStatisticsCurve() { - CAF_PDM_InitObject( "Ensemble Well Log Statistics Curve", "", "", "" ); + CAF_PDM_InitObject( "Ensemble Well Log Statistics Curve" ); - CAF_PDM_InitFieldNoDefault( &m_ensembleWellLogCurveSet, "EnsembleWellLogCurveSet", "Ensemble Well Log Curve Set", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_ensembleWellLogCurveSet, "EnsembleWellLogCurveSet", "Ensemble Well Log Curve Set" ); m_ensembleWellLogCurveSet.uiCapability()->setUiTreeChildrenHidden( true ); m_ensembleWellLogCurveSet.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_statisticsType, "StatisticsType", "Statistics Type", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_statisticsType, "StatisticsType", "Statistics Type" ); m_statisticsType.uiCapability()->setUiHidden( true ); m_wellPath = nullptr; @@ -150,7 +150,8 @@ void RimEnsembleWellLogStatisticsCurve::performDataExtraction( bool* isUsingPseu validDepths.insert( std::make_pair( RiaDefines::DepthTypeEnum::TRUE_VERTICAL_DEPTH_RKB, tvDepthValues ) ); } - this->setValuesAndDepths( values, validDepths, rkbDiff, depthUnit, false ); + bool useLogarithmicScale = false; + this->setPropertyValuesAndDepths( values, validDepths, rkbDiff, depthUnit, false, useLogarithmicScale ); } } } diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogs.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogs.cpp index 8e13ad98ff..00651b2bb3 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogs.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogs.cpp @@ -32,9 +32,9 @@ CAF_PDM_SOURCE_INIT( RimEnsembleWellLogs, "EnsembleWellLogs" ); //-------------------------------------------------------------------------------------------------- RimEnsembleWellLogs::RimEnsembleWellLogs() { - CAF_PDM_InitScriptableObject( "Ensemble Well Logs", "", "", "" ); + CAF_PDM_InitScriptableObject( "Ensemble Well Logs" ); - CAF_PDM_InitFieldNoDefault( &m_wellLogFiles, "WellLogFiles", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wellLogFiles, "WellLogFiles", "" ); m_wellLogFiles.uiCapability()->setUiTreeHidden( true ); } @@ -43,7 +43,7 @@ RimEnsembleWellLogs::RimEnsembleWellLogs() //-------------------------------------------------------------------------------------------------- void RimEnsembleWellLogs::removeWellLogFile( RimWellLogFile* summaryCase ) { - m_wellLogFiles.removeChildObject( summaryCase ); + m_wellLogFiles.removeChild( summaryCase ); } //-------------------------------------------------------------------------------------------------- @@ -59,7 +59,7 @@ void RimEnsembleWellLogs::addWellLogFile( RimWellLogFile* summaryCase ) //-------------------------------------------------------------------------------------------------- std::vector RimEnsembleWellLogs::wellLogFiles() const { - return m_wellLogFiles().childObjects(); + return m_wellLogFiles().children(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogsCollection.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogsCollection.cpp index 4d350cedd7..88eebd918a 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogsCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogsCollection.cpp @@ -29,9 +29,9 @@ CAF_PDM_SOURCE_INIT( RimEnsembleWellLogsCollection, "EnsembleWellLogsCollection" //-------------------------------------------------------------------------------------------------- RimEnsembleWellLogsCollection::RimEnsembleWellLogsCollection() { - CAF_PDM_InitObject( "Ensemble Well Logs", ":/LasFile16x16.png", "", "" ); + CAF_PDM_InitObject( "Ensemble Well Logs", ":/LasFile16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_ensembleWellLogs, "EnsembleWellLogsCollection", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_ensembleWellLogs, "EnsembleWellLogsCollection", "" ); m_ensembleWellLogs.uiCapability()->setUiTreeHidden( true ); } @@ -40,7 +40,7 @@ RimEnsembleWellLogsCollection::RimEnsembleWellLogsCollection() //-------------------------------------------------------------------------------------------------- RimEnsembleWellLogsCollection::~RimEnsembleWellLogsCollection() { - m_ensembleWellLogs.deleteAllChildObjects(); + m_ensembleWellLogs.deleteChildren(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTools.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTools.cpp new file mode 100644 index 0000000000..0d51edc996 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTools.cpp @@ -0,0 +1,168 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimRftTools.h" + +#include "RiaQDateTimeTools.h" +#include "RiaResultNames.h" +#include "RiaRftDefines.h" + +#include "RifReaderRftInterface.h" + +#include "cafPdmUiItem.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimRftTools::wellLogChannelsOptions( RifReaderRftInterface* readerRft, const QString& wellName ) +{ + QList options; + + if ( readerRft ) + { + for ( const RifEclipseRftAddress::RftWellLogChannelType& channelName : + readerRft->availableWellLogChannels( wellName ) ) + { + options.push_back( + caf::PdmOptionItemInfo( caf::AppEnum::uiText( channelName ), + channelName ) ); + } + } + + if ( options.empty() ) + { + options.push_back( caf::PdmOptionItemInfo( caf::AppEnum::uiText( + RifEclipseRftAddress::RftWellLogChannelType::NONE ), + RifEclipseRftAddress::RftWellLogChannelType::NONE ) ); + } + + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimRftTools::wellNameOptions( RifReaderRftInterface* readerRft ) +{ + QList options; + + options.push_back( caf::PdmOptionItemInfo( "None", "" ) ); + if ( readerRft ) + { + std::set wellNames = readerRft->wellNames(); + for ( const QString& name : wellNames ) + { + options.push_back( caf::PdmOptionItemInfo( name, name, false, caf::IconProvider( ":/Well.svg" ) ) ); + } + } + + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimRftTools::timeStepOptions( RifReaderRftInterface* readerRft, + const QString& wellName, + RifEclipseRftAddress::RftWellLogChannelType channelType ) +{ + QList options; + + if ( readerRft ) + { + QString dateFormat = "dd MMM yyyy"; + std::set timeStamps = readerRft->availableTimeSteps( wellName, channelType ); + for ( const QDateTime& dt : timeStamps ) + { + QString dateString = RiaQDateTimeTools::toStringUsingApplicationLocale( dt, dateFormat ); + + options.push_back( caf::PdmOptionItemInfo( dateString, dt ) ); + } + } + + options.push_back( caf::PdmOptionItemInfo( "None", QDateTime() ) ); + + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimRftTools::segmentTimeStepOptions( RifReaderRftInterface* readerRft, const QString& wellName ) +{ + return timeStepOptions( readerRft, wellName, RifEclipseRftAddress::RftWellLogChannelType::SEGMENT_VALUES ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimRftTools::segmentResultNameOptions( RifReaderRftInterface* readerRft, + const QString& wellName, + const QDateTime& timeStep ) +{ + QList options; + + options.push_front( + caf::PdmOptionItemInfo( RiaResultNames::undefinedResultName(), RiaResultNames::undefinedResultName() ) ); + + if ( readerRft ) + { + options.push_back( + caf::PdmOptionItemInfo( RiaDefines::segmentNumberResultName(), RiaDefines::segmentNumberResultName() ) ); + + for ( const auto& resultAdr : readerRft->eclipseRftAddresses( wellName, timeStep ) ) + { + if ( resultAdr.wellLogChannel() == RifEclipseRftAddress::RftWellLogChannelType::SEGMENT_VALUES ) + { + options.push_back( caf::PdmOptionItemInfo( resultAdr.segmentResultName(), resultAdr.segmentResultName() ) ); + } + } + } + + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimRftTools::segmentBranchIdOptions( RifReaderRftInterface* readerRft, + const QString& wellName, + const QDateTime& timeStep ) +{ + QList options; + + options.push_front( caf::PdmOptionItemInfo( RiaDefines::allBranches(), -1 ) ); + + if ( readerRft ) + { + std::vector values; + + auto adr = + RifEclipseRftAddress::createSegmentAddress( wellName, timeStep, RiaDefines::segmentBranchNumberResultName(), -1 ); + + readerRft->values( adr, &values ); + for ( const auto& v : values ) + { + int intValue = v; + auto txt = QString::number( intValue ); + options.push_back( caf::PdmOptionItemInfo( txt, intValue ) ); + } + } + + return options; +} diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTools.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTools.h new file mode 100644 index 0000000000..fdc1e48f08 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTools.h @@ -0,0 +1,46 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RifEclipseRftAddress.h" + +#include + +namespace caf +{ +class PdmOptionItemInfo; +} +class RifReaderRftInterface; + +class RimRftTools +{ +public: + static QList wellLogChannelsOptions( RifReaderRftInterface* readerRft, const QString& wellName ); + static QList wellNameOptions( RifReaderRftInterface* readerRft ); + static QList timeStepOptions( RifReaderRftInterface* readerRft, + const QString& wellName, + RifEclipseRftAddress::RftWellLogChannelType channelType ); + + static QList segmentTimeStepOptions( RifReaderRftInterface* readerRft, const QString& wellName ); + + static QList + segmentResultNameOptions( RifReaderRftInterface* readerRft, const QString& wellName, const QDateTime& timeStep ); + static QList + segmentBranchIdOptions( RifReaderRftInterface* readerRft, const QString& wellName, const QDateTime& timeStep ); +}; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurve.cpp index 8662c7c6e2..7f2510c472 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurve.cpp @@ -20,6 +20,7 @@ #include "RimWellLogCurve.h" #include "RiaCurveDataTools.h" +#include "RiaPlotDefines.h" #include "RigWellLogCurveData.h" #include "RimDepthTrackPlot.h" @@ -44,15 +45,12 @@ CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimWellLogCurve, "WellLogPlotCurve" ); //-------------------------------------------------------------------------------------------------- RimWellLogCurve::RimWellLogCurve() { - CAF_PDM_InitObject( "WellLogCurve", ":/WellLogCurve16x16.png", "", "" ); - - m_qwtPlotCurve->setXAxis( QwtPlot::xTop ); - m_qwtCurveErrorBars->setXAxis( QwtPlot::xTop ); - m_qwtPlotCurve->setYAxis( QwtPlot::yLeft ); + CAF_PDM_InitObject( "WellLogCurve", ":/WellLogCurve16x16.png" ); m_curveData = new RigWellLogCurveData; - m_curveDataXRange = std::make_pair( std::numeric_limits::infinity(), -std::numeric_limits::infinity() ); + m_curveDataPropertyValueRange = + std::make_pair( std::numeric_limits::infinity(), -std::numeric_limits::infinity() ); setDeletable( true ); } @@ -75,7 +73,7 @@ void RimWellLogCurve::setDepthUnit( RiaDefines::DepthUnitType depthUnit ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimWellLogCurve::xValueRangeInData( double* minimumValue, double* maximumValue ) const +bool RimWellLogCurve::propertyValueRangeInData( double* minimumValue, double* maximumValue ) const { CAF_ASSERT( minimumValue && maximumValue ); @@ -84,14 +82,14 @@ bool RimWellLogCurve::xValueRangeInData( double* minimumValue, double* maximumVa return false; } - if ( m_curveDataXRange.first == -std::numeric_limits::infinity() || - m_curveDataXRange.second == std::numeric_limits::infinity() ) + if ( m_curveDataPropertyValueRange.first == -std::numeric_limits::infinity() || + m_curveDataPropertyValueRange.second == std::numeric_limits::infinity() ) { return false; } - *minimumValue = m_curveDataXRange.first; - *maximumValue = m_curveDataXRange.second; + *minimumValue = m_curveDataPropertyValueRange.first; + *maximumValue = m_curveDataPropertyValueRange.second; return true; } @@ -99,7 +97,7 @@ bool RimWellLogCurve::xValueRangeInData( double* minimumValue, double* maximumVa //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimWellLogCurve::yValueRangeInData( double* minimumValue, double* maximumValue ) const +bool RimWellLogCurve::depthValueRangeInData( double* minimumValue, double* maximumValue ) const { CAF_ASSERT( minimumValue && maximumValue ); @@ -119,50 +117,99 @@ bool RimWellLogCurve::yValueRangeInData( double* minimumValue, double* maximumVa //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogCurve::setValuesAndDepths( const std::vector& xValues, - const std::vector& depths, - RiaDefines::DepthTypeEnum depthType, - double rkbDiff, - RiaDefines::DepthUnitType depthUnit, - bool isExtractionCurve, - const QString& xUnits ) +void RimWellLogCurve::setPropertyValuesAndDepths( const std::vector& propertyValues, + const std::vector& depths, + RiaDefines::DepthTypeEnum depthType, + double rkbDiff, + RiaDefines::DepthUnitType depthUnit, + bool isExtractionCurve, + bool useLogarithmicScale, + const QString& propertyUnit ) { - m_curveData->setValuesAndDepths( xValues, depths, depthType, rkbDiff, depthUnit, isExtractionCurve ); - m_curveData->setXUnits( xUnits ); - calculateCurveDataXRange(); + m_curveData->setValuesAndDepths( propertyValues, depths, depthType, rkbDiff, depthUnit, isExtractionCurve, useLogarithmicScale ); + m_curveData->setPropertyValueUnit( propertyUnit ); + calculateCurveDataPropertyValueRange(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogCurve::setValuesAndDepths( const std::vector& xValues, - const std::map>& depths, - double rkbDiff, - RiaDefines::DepthUnitType depthUnit, - bool isExtractionCurve, - const QString& xUnits ) +void RimWellLogCurve::setPropertyValuesAndDepths( const std::vector& propertyValues, + const std::map>& depths, + double rkbDiff, + RiaDefines::DepthUnitType depthUnit, + bool isExtractionCurve, + bool useLogarithmicScale, + + const QString& propertyUnit ) { - m_curveData->setValuesAndDepths( xValues, depths, rkbDiff, depthUnit, isExtractionCurve ); - m_curveData->setXUnits( xUnits ); - calculateCurveDataXRange(); + m_curveData->setValuesAndDepths( propertyValues, depths, rkbDiff, depthUnit, isExtractionCurve, useLogarithmicScale ); + m_curveData->setPropertyValueUnit( propertyUnit ); + calculateCurveDataPropertyValueRange(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogCurve::setPropertyAndDepthsAndErrors( const std::vector& propertyValues, + const std::vector& depthValues, + const std::vector& errorValues ) +{ + bool useLogarithmicScale = false; + + if ( isVerticalCurve() ) + { + this->setSamplesFromXYErrorValues( propertyValues, + depthValues, + errorValues, + useLogarithmicScale, + RiaCurveDataTools::ErrorAxis::ERROR_ALONG_X_AXIS ); + } + else + { + this->setSamplesFromXYErrorValues( depthValues, + propertyValues, + errorValues, + useLogarithmicScale, + RiaCurveDataTools::ErrorAxis::ERROR_ALONG_Y_AXIS ); + } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogCurve::setValuesWithMdAndTVD( const std::vector& xValues, - const std::vector& measuredDepths, - const std::vector& tvdMSL, - double rkbDiff, - RiaDefines::DepthUnitType depthUnit, - bool isExtractionCurve, - const QString& xUnits ) +void RimWellLogCurve::setPropertyAndDepthValuesToPlotCurve( const std::vector& propertyValues, + const std::vector& depthValues ) +{ + if ( !m_plotCurve ) return; + + if ( isVerticalCurve() ) + { + m_plotCurve->setSamplesValues( propertyValues, depthValues ); + } + else + { + m_plotCurve->setSamplesValues( depthValues, propertyValues ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogCurve::setPropertyValuesWithMdAndTVD( const std::vector& propertyValues, + const std::vector& measuredDepths, + const std::vector& tvdMSL, + double rkbDiff, + RiaDefines::DepthUnitType depthUnit, + bool isExtractionCurve, + bool useLogarithmicScale, + const QString& propertyUnit ) { std::map> depths = { { RiaDefines::DepthTypeEnum::MEASURED_DEPTH, measuredDepths }, { RiaDefines::DepthTypeEnum::TRUE_VERTICAL_DEPTH, tvdMSL } }; - setValuesAndDepths( xValues, depths, rkbDiff, depthUnit, isExtractionCurve, xUnits ); + setPropertyValuesAndDepths( propertyValues, depths, rkbDiff, depthUnit, isExtractionCurve, useLogarithmicScale, propertyUnit ); } //-------------------------------------------------------------------------------------------------- @@ -179,11 +226,35 @@ const RigWellLogCurveData* RimWellLogCurve::curveData() const void RimWellLogCurve::updateCurveAppearance() { RimPlotCurve::updateCurveAppearance(); + + RimDepthTrackPlot::DepthOrientation orientation = RimDepthTrackPlot::DepthOrientation::VERTICAL; + + RimDepthTrackPlot* wellLogPlot = nullptr; + firstAncestorOrThisOfType( wellLogPlot ); + if ( wellLogPlot ) orientation = wellLogPlot->depthOrientation(); + + if ( m_plotCurve ) + { + m_plotCurve->setXAxis( RiuPlotAxis::defaultTop() ); + m_plotCurve->setYAxis( RiuPlotAxis::defaultLeft() ); + } + if ( fillStyle() != Qt::BrushStyle::NoBrush ) { - m_qwtPlotCurve->setOrientation( Qt::Horizontal ); - m_qwtPlotCurve->setBaseline( -std::numeric_limits::infinity() ); - m_qwtPlotCurve->setCurveAttribute( QwtPlotCurve::Inverted, true ); + RiuQwtPlotCurve* qwtPlotCurve = dynamic_cast( m_plotCurve ); + if ( qwtPlotCurve ) + { + if ( orientation == RimDepthTrackPlot::DepthOrientation::VERTICAL ) + { + qwtPlotCurve->setOrientation( Qt::Horizontal ); + qwtPlotCurve->setBaseline( -std::numeric_limits::infinity() ); + } + else + { + qwtPlotCurve->setOrientation( Qt::Vertical ); + qwtPlotCurve->setBaseline( 0.0 ); + } + } } } @@ -206,25 +277,19 @@ QString RimWellLogCurve::wellLogCurveIconName() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogCurve::setOverrideCurveData( const std::vector& xValues, +void RimWellLogCurve::setOverrideCurveData( const std::vector& propertyValues, const std::vector& depthValues, const RiaCurveDataTools::CurveIntervals& curveIntervals ) { - auto minmax_it = std::minmax_element( xValues.begin(), xValues.end() ); - this->setOverrideCurveDataXRange( *( minmax_it.first ), *( minmax_it.second ) ); - if ( m_qwtPlotCurve ) + auto minmax_it = std::minmax_element( propertyValues.begin(), propertyValues.end() ); + this->setOverrideCurveDataPropertyValueRange( *( minmax_it.first ), *( minmax_it.second ) ); + + if ( m_plotCurve ) { - m_qwtPlotCurve->setSamples( xValues.data(), depthValues.data(), static_cast( depthValues.size() ) ); - m_qwtPlotCurve->setLineSegmentStartStopIndices( curveIntervals ); - } -} + setPropertyAndDepthValuesToPlotCurve( propertyValues, depthValues ); -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RiaDefines::PhaseType RimWellLogCurve::resultPhase() const -{ - return RiaDefines::PhaseType::PHASE_NOT_APPLICABLE; + m_plotCurve->setLineSegmentStartStopIndices( curveIntervals ); + } } //-------------------------------------------------------------------------------------------------- @@ -239,7 +304,7 @@ void RimWellLogCurve::updateZoomInParentPlot() if ( wellLogTrack ) { - wellLogTrack->setAutoScaleXIfNecessary(); + wellLogTrack->setAutoScalePropertyValuesIfNecessary(); RimDepthTrackPlot* wellLogPlot; wellLogTrack->firstAncestorOrThisOfType( wellLogPlot ); @@ -268,7 +333,7 @@ void RimWellLogCurve::updateZoomInParentPlot() } if ( updateDepthZoom ) { - wellLogPlot->setAutoScaleDepthEnabled( true ); + wellLogPlot->setAutoScaleDepthValuesEnabled( true ); } wellLogPlot->updateZoom(); } @@ -291,24 +356,25 @@ void RimWellLogCurve::updateLegendsInPlot() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogCurve::setOverrideCurveDataXRange( double minimumValue, double maximumValue ) +void RimWellLogCurve::setOverrideCurveDataPropertyValueRange( double minimumValue, double maximumValue ) { - m_curveDataXRange = std::make_pair( minimumValue, maximumValue ); + m_curveDataPropertyValueRange = std::make_pair( minimumValue, maximumValue ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogCurve::calculateCurveDataXRange() +void RimWellLogCurve::calculateCurveDataPropertyValueRange() { // Invalidate range first - m_curveDataXRange = std::make_pair( std::numeric_limits::infinity(), -std::numeric_limits::infinity() ); - for ( double xValue : m_curveData->xValues() ) + m_curveDataPropertyValueRange = + std::make_pair( std::numeric_limits::infinity(), -std::numeric_limits::infinity() ); + for ( double xValue : m_curveData->propertyValues() ) { if ( RiaCurveDataTools::isValidValue( xValue, false ) ) { - m_curveDataXRange.first = std::min( m_curveDataXRange.first, xValue ); - m_curveDataXRange.second = std::max( m_curveDataXRange.second, xValue ); + m_curveDataPropertyValueRange.first = std::min( m_curveDataPropertyValueRange.first, xValue ); + m_curveDataPropertyValueRange.second = std::max( m_curveDataPropertyValueRange.second, xValue ); } } } @@ -322,9 +388,12 @@ void RimWellLogCurve::fieldChangedByUi( const caf::PdmFieldHandle* changedField, { RimStackablePlotCurve::fieldChangedByUi( changedField, oldValue, newValue ); - if ( changedField == &m_showCurve && m_showCurve() ) + if ( changedField == &m_showCurve ) { - updateZoomInParentPlot(); + if ( m_isStacked() || m_showCurve() ) + { + updateZoomInParentPlot(); + } } if ( changedField == &m_isStacked ) @@ -332,3 +401,39 @@ void RimWellLogCurve::fieldChangedByUi( const caf::PdmFieldHandle* changedField, loadDataAndUpdate( true ); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimWellLogCurve::isVerticalCurve() const +{ + RimDepthTrackPlot::DepthOrientation orientation = RimDepthTrackPlot::DepthOrientation::VERTICAL; + + RimDepthTrackPlot* depthTrackPlot = nullptr; + firstAncestorOrThisOfType( depthTrackPlot ); + if ( depthTrackPlot ) orientation = depthTrackPlot->depthOrientation(); + + return orientation == RimDepthTrackPlot::DepthOrientation::VERTICAL; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuPlotAxis RimWellLogCurve::depthAxis() const +{ + RimDepthTrackPlot* depthTrackPlot; + this->firstAncestorOrThisOfTypeAsserted( depthTrackPlot ); + + return depthTrackPlot->depthAxis(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuPlotAxis RimWellLogCurve::valueAxis() const +{ + RimDepthTrackPlot* depthTrackPlot; + this->firstAncestorOrThisOfTypeAsserted( depthTrackPlot ); + + return depthTrackPlot->valueAxis(); +} diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurve.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurve.h index 578a4641a3..19618f0a5d 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurve.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurve.h @@ -42,29 +42,8 @@ class RimWellLogCurve : public RimStackablePlotCurve void setDepthUnit( RiaDefines::DepthUnitType depthUnit ); - bool xValueRangeInData( double* minimumValue, double* maximumValue ) const; - bool yValueRangeInData( double* minimumValue, double* maximumValue ) const; - - void setValuesAndDepths( const std::vector& xValues, - const std::vector& depths, - RiaDefines::DepthTypeEnum depthType, - double rkbDiff, - RiaDefines::DepthUnitType depthUnit, - bool isExtractionCurve, - const QString& xUnits = RiaWellLogUnitTools::noUnitString() ); - void setValuesWithMdAndTVD( const std::vector& xValues, - const std::vector& measuredDepths, - const std::vector& tvDepths, - double rkbDiff, - RiaDefines::DepthUnitType depthUnit, - bool isExtractionCurve, - const QString& xUnits = RiaWellLogUnitTools::noUnitString() ); - void setValuesAndDepths( const std::vector& xValues, - const std::map>& depths, - double rkbDiff, - RiaDefines::DepthUnitType depthUnit, - bool isExtractionCurve, - const QString& xUnits = RiaWellLogUnitTools::noUnitString() ); + bool propertyValueRangeInData( double* minimumValue, double* maximumValue ) const; + bool depthValueRangeInData( double* minimumValue, double* maximumValue ) const; const RigWellLogCurveData* curveData() const; @@ -78,20 +57,56 @@ class RimWellLogCurve : public RimStackablePlotCurve static QString wellLogCurveIconName(); - void setOverrideCurveData( const std::vector& xValues, + void setOverrideCurveData( const std::vector& propertyValues, const std::vector& depthValues, const RiaCurveDataTools::CurveIntervals& curveIntervals ); - virtual RiaDefines::PhaseType resultPhase() const; - protected: void updateZoomInParentPlot() override; void updateLegendsInPlot() override; - void setOverrideCurveDataXRange( double minimumValue, double maximumValue ); - void calculateCurveDataXRange(); + void setOverrideCurveDataPropertyValueRange( double minimumValue, double maximumValue ); + void calculateCurveDataPropertyValueRange(); + void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; + void setPropertyValuesAndDepths( const std::vector& propertyValues, + const std::vector& depths, + RiaDefines::DepthTypeEnum depthType, + double rkbDiff, + RiaDefines::DepthUnitType depthUnit, + bool isExtractionCurve, + bool useLogarithmicScale, + const QString& propertyUnit = RiaWellLogUnitTools::noUnitString() ); + + void setPropertyValuesWithMdAndTVD( const std::vector& propertyValues, + const std::vector& measuredDepths, + const std::vector& tvDepths, + double rkbDiff, + RiaDefines::DepthUnitType depthUnit, + bool isExtractionCurve, + bool useLogarithmicScale, + const QString& propertyUnit = RiaWellLogUnitTools::noUnitString() ); + + void setPropertyAndDepthValuesToPlotCurve( const std::vector& propertyValues, + const std::vector& depthValues ); + + void setPropertyValuesAndDepths( const std::vector& propertyValues, + const std::map>& depths, + double rkbDiff, + RiaDefines::DepthUnitType depthUnit, + bool isExtractionCurve, + bool useLogarithmicScale, + const QString& propertyUnit = RiaWellLogUnitTools::noUnitString() ); + + void setPropertyAndDepthsAndErrors( const std::vector& propertyValues, + const std::vector& depthValues, + const std::vector& errorValues ); + + bool isVerticalCurve() const; + RiuPlotAxis depthAxis() const; + RiuPlotAxis valueAxis() const; + private: cvf::ref m_curveData; - std::pair m_curveDataXRange; + std::pair m_curveDataPropertyValueRange; }; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.cpp index 7a0a2da962..ae5efde4fd 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.cpp @@ -18,6 +18,9 @@ #include "RimWellLogCurveCommonDataSource.h" +#include "RiaSimWellBranchTools.h" +#include "RiaSummaryTools.h" + #include "RimCase.h" #include "RimDataSourceSteppingTools.h" #include "RimEclipseCase.h" @@ -25,20 +28,21 @@ #include "RimGeoMechCase.h" #include "RimOilField.h" #include "RimProject.h" +#include "RimRftTools.h" +#include "RimSummaryCase.h" #include "RimTools.h" #include "RimWellFlowRateCurve.h" #include "RimWellLogExtractionCurve.h" #include "RimWellLogFileCurve.h" #include "RimWellLogPlot.h" #include "RimWellLogPlotCollection.h" +#include "RimWellLogRftCurve.h" #include "RimWellLogTrack.h" #include "RimWellLogWbsCurve.h" #include "RimWellMeasurementCurve.h" #include "RimWellPath.h" #include "RimWellPathCollection.h" -#include "RiaSimWellBranchTools.h" - #include "cafPdmUiCheckBoxTristateEditor.h" #include "cafPdmUiComboBoxEditor.h" #include "cafPdmUiLineEditor.h" @@ -70,14 +74,15 @@ bool RimWellLogCurveCommonDataSource::DoubleComparator::operator()( const double RimWellLogCurveCommonDataSource::RimWellLogCurveCommonDataSource() : m_caseType( RiaDefines::CaseType::UNDEFINED_CASE ) { - CAF_PDM_InitObject( "Change Data Source", "", "", "" ); + CAF_PDM_InitObject( "Change Data Source" ); - CAF_PDM_InitFieldNoDefault( &m_case, "CurveCase", "Case", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_trajectoryType, "TrajectoryType", "Trajectory Type", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_case, "CurveCase", "Case" ); + CAF_PDM_InitFieldNoDefault( &m_summaryCase, "SummaryCase", "Summary Case" ); + CAF_PDM_InitFieldNoDefault( &m_trajectoryType, "TrajectoryType", "Trajectory Type" ); - CAF_PDM_InitFieldNoDefault( &m_wellPath, "CurveWellPath", "Well Name", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wellPath, "CurveWellPath", "Well Path" ); - CAF_PDM_InitFieldNoDefault( &m_simWellName, "SimulationWellName", "Well Name", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_simWellName, "SimulationWellName", "Well Name" ); CAF_PDM_InitFieldNoDefault( &m_branchDetection, "BranchDetection", "Branch Detection", @@ -86,15 +91,19 @@ RimWellLogCurveCommonDataSource::RimWellLogCurveCommonDataSource() "" ); m_branchDetection.v() = caf::Tristate::State::PartiallyTrue; m_branchDetection.uiCapability()->setUiEditorTypeName( caf::PdmUiCheckBoxTristateEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_branchIndex, "Branch", -1, "Branch Index", "", "", "" ); + CAF_PDM_InitField( &m_branchIndex, "Branch", -1, "Branch Index" ); - CAF_PDM_InitField( &m_timeStep, "CurveTimeStep", -1, "Time Step", "", "", "" ); + CAF_PDM_InitField( &m_timeStep, "CurveTimeStep", -1, "Time Step" ); - CAF_PDM_InitFieldNoDefault( &m_wbsSmoothing, "WBSSmoothing", "Smooth Curves", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wbsSmoothing, "WBSSmoothing", "Smooth Curves" ); m_wbsSmoothing.uiCapability()->setUiEditorTypeName( caf::PdmUiCheckBoxTristateEditor::uiEditorTypeName() ); m_wbsSmoothing.v() = caf::Tristate::State::PartiallyTrue; - CAF_PDM_InitField( &m_wbsSmoothingThreshold, "WBSSmoothingThreshold", -1.0, "Smoothing Threshold", "", "", "" ); + CAF_PDM_InitField( &m_wbsSmoothingThreshold, "WBSSmoothingThreshold", -1.0, "Smoothing Threshold" ); + + CAF_PDM_InitFieldNoDefault( &m_rftTimeStep, "RftTimeStep", "RFT Time Step" ); + CAF_PDM_InitFieldNoDefault( &m_rftWellName, "RftWellName", "RFT Well Name" ); + CAF_PDM_InitFieldNoDefault( &m_rftSegmentBranchId, "SegmentBranchId", "RFT Segment Branch" ); m_case = nullptr; m_wellPath = nullptr; @@ -116,6 +125,14 @@ RimCase* RimWellLogCurveCommonDataSource::caseToApply() const return m_case; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogCurveCommonDataSource::setSummaryCaseToApply( RimSummaryCase* val ) +{ + m_summaryCase = val; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -124,6 +141,14 @@ void RimWellLogCurveCommonDataSource::setCaseToApply( RimCase* val ) m_case = val; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryCase* RimWellLogCurveCommonDataSource::summaryCaseToApply() const +{ + return m_summaryCase(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -258,6 +283,7 @@ void RimWellLogCurveCommonDataSource::setTimeStepToApply( int val ) void RimWellLogCurveCommonDataSource::resetDefaultOptions() { setCaseToApply( nullptr ); + setSummaryCaseToApply( nullptr ); setTrajectoryTypeToApply( -1 ); setWellPathToApply( nullptr ); setBranchIndexToApply( -1 ); @@ -268,6 +294,7 @@ void RimWellLogCurveCommonDataSource::resetDefaultOptions() setWbsSmoothingThreshold( -1.0 ); m_uniqueCases.clear(); + m_uniqueSummaryCases.clear(); m_uniqueTrajectoryTypes.clear(); m_uniqueWellPaths.clear(); m_uniqueWellNames.clear(); @@ -276,13 +303,17 @@ void RimWellLogCurveCommonDataSource::resetDefaultOptions() m_uniqueBranchDetection.clear(); m_uniqueWbsSmoothing.clear(); m_uniqueWbsSmoothingThreshold.clear(); + + m_uniqueRftTimeSteps.clear(); + m_uniqueRftWellNames.clear(); + m_uniqueRftBranchIds.clear(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogCurveCommonDataSource::updateDefaultOptions( const std::vector& curves, - const std::vector& tracks ) +void RimWellLogCurveCommonDataSource::analyseCurvesAndTracks( const std::vector& curves, + const std::vector& tracks ) { // Reset all options in the UI resetDefaultOptions(); @@ -294,12 +325,14 @@ void RimWellLogCurveCommonDataSource::updateDefaultOptions( const std::vector( curve ); - RimWellLogFileCurve* fileCurve = dynamic_cast( curve ); - RimWellFlowRateCurve* flowRateCurve = dynamic_cast( curve ); + auto* extractionCurve = dynamic_cast( curve ); + auto* fileCurve = dynamic_cast( curve ); + auto* flowRateCurve = dynamic_cast( curve ); + auto* rftCurve = dynamic_cast( curve ); + if ( extractionCurve ) { - RimWellLogWbsCurve* wbsCurve = dynamic_cast( extractionCurve ); + auto* wbsCurve = dynamic_cast( extractionCurve ); if ( wbsCurve ) { m_uniqueWbsSmoothing.insert( wbsCurve->smoothCurve() ); @@ -341,6 +374,21 @@ void RimWellLogCurveCommonDataSource::updateDefaultOptions( const std::vectorrimCase() ); m_uniqueTimeSteps.insert( flowRateCurve->timeStep() ); } + else if ( rftCurve ) + { + if ( rftCurve->summaryCase() ) m_uniqueSummaryCases.insert( rftCurve->summaryCase() ); + if ( rftCurve->eclipseResultCase() ) m_uniqueCases.insert( rftCurve->eclipseResultCase() ); + m_uniqueWellNames.insert( rftCurve->wellName() ); + + auto adr = rftCurve->rftAddress(); + if ( adr.wellLogChannel() == RifEclipseRftAddress::RftWellLogChannelType::SEGMENT_VALUES && + adr.segmentResultName() != "None" ) + { + m_uniqueRftWellNames.insert( adr.wellName() ); + m_uniqueRftTimeSteps.insert( adr.timeStep() ); + m_uniqueRftBranchIds.insert( adr.segmentBranchNumber() ); + } + } } for ( RimWellLogTrack* track : tracks ) { @@ -373,6 +421,11 @@ void RimWellLogCurveCommonDataSource::updateDefaultOptions( const std::vectorfirstAncestorOrThisOfType( parentPlot ); @@ -428,15 +496,15 @@ void RimWellLogCurveCommonDataSource::updateDefaultOptions() std::vector tracks; parentPlot->descendantsIncludingThisOfType( tracks ); - this->updateDefaultOptions( curves, tracks ); + this->analyseCurvesAndTracks( curves, tracks ); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogCurveCommonDataSource::updateCurvesAndTracks( const std::vector& curves, - const std::vector& tracks ) +void RimWellLogCurveCommonDataSource::applyDataSourceChanges( const std::vector& curves, + const std::vector& tracks ) { std::set plots; for ( RimWellLogCurve* curve : curves ) @@ -445,9 +513,10 @@ void RimWellLogCurveCommonDataSource::updateCurvesAndTracks( const std::vector( curve ); - RimWellLogExtractionCurve* extractionCurve = dynamic_cast( curve ); - RimWellMeasurementCurve* measurementCurve = dynamic_cast( curve ); + auto* fileCurve = dynamic_cast( curve ); + auto* extractionCurve = dynamic_cast( curve ); + auto* measurementCurve = dynamic_cast( curve ); + auto* rftCurve = dynamic_cast( curve ); if ( fileCurve ) { if ( wellPathToApply() != nullptr ) @@ -512,7 +581,7 @@ void RimWellLogCurveCommonDataSource::updateCurvesAndTracks( const std::vector( extractionCurve ); + auto* wbsCurve = dynamic_cast( extractionCurve ); if ( wbsCurve ) { if ( !wbsSmoothingToApply().isPartiallyTrue() ) @@ -532,7 +601,6 @@ void RimWellLogCurveCommonDataSource::updateCurvesAndTracks( const std::vectorfirstAncestorOrThisOfTypeAsserted( parentPlot ); plots.insert( parentPlot ); - curve->updateConnectedEditors(); } } else if ( measurementCurve ) @@ -542,6 +610,18 @@ void RimWellLogCurveCommonDataSource::updateCurvesAndTracks( const std::vectorsetWellPath( wellPathToApply() ); } } + else if ( rftCurve ) + { + rftCurve->setTimeStep( m_rftTimeStep() ); + rftCurve->setWellName( m_rftWellName() ); + rftCurve->setSegmentBranchId( m_rftSegmentBranchId() ); + + RimWellLogPlot* parentPlot = nullptr; + rftCurve->firstAncestorOrThisOfTypeAsserted( parentPlot ); + plots.insert( parentPlot ); + } + + curve->updateConnectedEditors(); } for ( RimWellLogTrack* track : tracks ) @@ -607,7 +687,7 @@ void RimWellLogCurveCommonDataSource::updateCurvesAndTracks( const std::vectorfirstAncestorOrThisOfType( parentPlot ); @@ -619,7 +699,7 @@ void RimWellLogCurveCommonDataSource::updateCurvesAndTracks() std::vector tracks; parentPlot->descendantsIncludingThisOfType( tracks ); - this->updateCurvesAndTracks( curves, tracks ); + this->applyDataSourceChanges( curves, tracks ); } } @@ -690,19 +770,28 @@ void RimWellLogCurveCommonDataSource::applyNextTimeStep() //-------------------------------------------------------------------------------------------------- std::vector RimWellLogCurveCommonDataSource::fieldsToShowInToolbar() { - updateDefaultOptions(); + analyseCurvesAndTracks(); std::vector fieldsToDisplay; - fieldsToDisplay.push_back( &m_case ); - if ( trajectoryTypeToApply() == RimWellLogExtractionCurve::WELL_PATH ) - { - fieldsToDisplay.push_back( &m_wellPath ); - } - else if ( trajectoryTypeToApply() == RimWellLogExtractionCurve::SIMULATION_WELL ) + + if ( !m_uniqueCases.empty() ) { - fieldsToDisplay.push_back( &m_simWellName ); + fieldsToDisplay.push_back( &m_case ); + if ( trajectoryTypeToApply() == RimWellLogExtractionCurve::WELL_PATH ) + { + fieldsToDisplay.push_back( &m_wellPath ); + } + else if ( trajectoryTypeToApply() == RimWellLogExtractionCurve::SIMULATION_WELL ) + { + fieldsToDisplay.push_back( &m_simWellName ); + } } - fieldsToDisplay.push_back( &m_timeStep ); + + if ( m_uniqueRftWellNames.size() == 1u ) fieldsToDisplay.push_back( &m_rftWellName ); + if ( m_uniqueTimeSteps.size() == 1u ) fieldsToDisplay.push_back( &m_timeStep ); + if ( m_uniqueRftTimeSteps.size() == 1u ) fieldsToDisplay.push_back( &m_rftTimeStep ); + if ( m_uniqueRftBranchIds.size() == 1u ) fieldsToDisplay.push_back( &m_rftSegmentBranchId ); + return fieldsToDisplay; } @@ -741,19 +830,18 @@ void RimWellLogCurveCommonDataSource::fieldChangedByUi( const caf::PdmFieldHandl } } - this->updateCurvesAndTracks(); + this->applyDataSourceChanges(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- QList - RimWellLogCurveCommonDataSource::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) + RimWellLogCurveCommonDataSource::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; - this->updateDefaultOptions(); + this->analyseCurvesAndTracks(); if ( fieldNeedingOptions == &m_case ) { @@ -773,17 +861,11 @@ QList RimTools::caseOptionItems( &options ); } - if ( caseToApply() == nullptr ) - { - if ( !m_uniqueCases.empty() ) - { - options.push_front( caf::PdmOptionItemInfo( "Mixed Cases", nullptr ) ); - } - else - { - options.push_front( caf::PdmOptionItemInfo( "None", nullptr ) ); - } - } + options.push_front( caf::PdmOptionItemInfo( "None", nullptr ) ); + } + if ( fieldNeedingOptions == &m_summaryCase ) + { + options = RiaSummaryTools::optionsForAllSummaryCases(); } else if ( fieldNeedingOptions == &m_trajectoryType ) { @@ -824,23 +906,26 @@ QList } else if ( fieldNeedingOptions == &m_timeStep ) { - RimTools::timeStepsForCase( m_case, &options ); - - if ( timeStepToApply() == -1 ) + if ( m_case() ) { - if ( !m_uniqueTimeSteps.empty() ) - { - options.push_front( caf::PdmOptionItemInfo( "Mixed Time Steps", -1 ) ); - } - else + RimTools::timeStepsForCase( m_case, &options ); + + if ( timeStepToApply() == -1 ) { - options.push_front( caf::PdmOptionItemInfo( "No Time Steps", -1 ) ); + if ( !m_uniqueTimeSteps.empty() ) + { + options.push_front( caf::PdmOptionItemInfo( "Mixed Time Steps", -1 ) ); + } + else + { + options.push_front( caf::PdmOptionItemInfo( "No Time Steps", -1 ) ); + } } } } else if ( fieldNeedingOptions == &m_simWellName ) { - RimEclipseCase* eclipseCase = dynamic_cast( m_case() ); + auto* eclipseCase = dynamic_cast( m_case() ); if ( eclipseCase ) { std::set sortedWellNames = eclipseCase->sortedSimWellNames(); @@ -887,6 +972,19 @@ QList } } } + else if ( fieldNeedingOptions == &m_rftTimeStep ) + { + if ( !m_uniqueRftWellNames.empty() ) + options = RimRftTools::segmentTimeStepOptions( rftReader(), *( m_uniqueRftWellNames.begin() ) ); + } + else if ( fieldNeedingOptions == &m_rftWellName ) + { + options = RimRftTools::wellNameOptions( rftReader() ); + } + else if ( fieldNeedingOptions == &m_rftSegmentBranchId ) + { + options = RimRftTools::segmentBranchIdOptions( rftReader(), m_rftWellName(), m_rftTimeStep() ); + } return options; } @@ -896,12 +994,13 @@ QList //-------------------------------------------------------------------------------------------------- void RimWellLogCurveCommonDataSource::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { - updateDefaultOptions(); + analyseCurvesAndTracks(); caf::PdmUiGroup* group = uiOrdering.addNewGroup( "Data Source" ); - group->add( &m_case ); + if ( m_case() ) group->add( &m_case ); + if ( m_summaryCase() ) group->add( &m_summaryCase ); - RimEclipseCase* eclipseCase = dynamic_cast( m_case() ); + auto* eclipseCase = dynamic_cast( m_case() ); if ( eclipseCase ) { group->add( &m_trajectoryType ); @@ -926,12 +1025,13 @@ void RimWellLogCurveCommonDataSource::defineUiOrdering( QString uiConfigName, ca } } } + + group->add( &m_timeStep ); } else { - group->add( &m_wellPath ); + if ( m_wellPath() ) group->add( &m_wellPath ); } - group->add( &m_timeStep ); if ( uiConfigName == smoothingUiOrderinglabel() ) { @@ -939,6 +1039,10 @@ void RimWellLogCurveCommonDataSource::defineUiOrdering( QString uiConfigName, ca group->add( &m_wbsSmoothingThreshold ); } + if ( !m_uniqueRftTimeSteps.empty() ) group->add( &m_rftTimeStep ); + if ( !m_uniqueRftWellNames.empty() ) group->add( &m_rftWellName ); + if ( !m_uniqueRftBranchIds.empty() ) group->add( &m_rftSegmentBranchId ); + uiOrdering.skipRemainingFields( true ); } @@ -949,10 +1053,11 @@ void RimWellLogCurveCommonDataSource::defineEditorAttribute( const caf::PdmField QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) { - caf::PdmUiComboBoxEditorAttribute* myAttr = dynamic_cast( attribute ); + auto* myAttr = dynamic_cast( attribute ); if ( myAttr ) { - if ( field == &m_case || field == &m_simWellName || field == &m_wellPath || field == &m_timeStep ) + if ( field == &m_case || field == &m_simWellName || field == &m_wellPath || field == &m_timeStep || + field == &m_rftTimeStep || field == &m_rftSegmentBranchId || field == &m_rftWellName ) { myAttr->showPreviousAndNextButtons = true; myAttr->nextIcon = QIcon( ":/ComboBoxDown.svg" ); @@ -982,8 +1087,7 @@ void RimWellLogCurveCommonDataSource::defineEditorAttribute( const caf::PdmField myAttr->prevButtonText = "Previous " + modifierText + "PgUp)"; } } - caf::PdmUiLineEditorAttributeUiDisplayString* uiDisplayStringAttr = - dynamic_cast( attribute ); + auto* uiDisplayStringAttr = dynamic_cast( attribute ); if ( uiDisplayStringAttr && wbsSmoothingThreshold() == -1.0 ) { QString displayString = "Mixed"; @@ -1004,7 +1108,19 @@ void RimWellLogCurveCommonDataSource::defineEditorAttribute( const caf::PdmField //-------------------------------------------------------------------------------------------------- void RimWellLogCurveCommonDataSource::modifyCurrentIndex( caf::PdmValueField* field, int indexOffset ) { - bool useOptionsOnly; - QList options = calculateValueOptions( field, &useOptionsOnly ); + QList options = calculateValueOptions( field ); RimDataSourceSteppingTools::modifyCurrentIndex( field, options, indexOffset ); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifReaderRftInterface* RimWellLogCurveCommonDataSource::rftReader() +{ + auto eclipseCase = dynamic_cast( m_case() ); + if ( eclipseCase && eclipseCase->rftReader() ) return eclipseCase->rftReader(); + + if ( m_summaryCase() && m_summaryCase()->rftReader() ) return m_summaryCase->rftReader(); + + return nullptr; +} diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.h index 5af6ba4f29..28c1a490e9 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.h @@ -26,11 +26,15 @@ #include "cafPdmUiOrdering.h" #include "cafTristate.h" +#include + class RimCase; class RimWellLogCurve; class RimWellLogPlot; class RimWellLogTrack; class RimWellPath; +class RimSummaryCase; +class RifReaderRftInterface; //================================================================================================== /// @@ -54,20 +58,22 @@ class RimWellLogCurveCommonDataSource : public caf::PdmObject void setCaseType( RiaDefines::CaseType caseType ); - RimCase* caseToApply() const; - void setCaseToApply( RimCase* val ); - int trajectoryTypeToApply() const; - void setTrajectoryTypeToApply( int val ); - RimWellPath* wellPathToApply() const; - void setWellPathToApply( RimWellPath* val ); - int branchIndexToApply() const; - void setBranchIndexToApply( int val ); - caf::Tristate branchDetectionToApply() const; - void setBranchDetectionToApply( caf::Tristate::State val ); - caf::Tristate wbsSmoothingToApply() const; - void setWbsSmoothingToApply( caf::Tristate::State val ); - double wbsSmoothingThreshold() const; - void setWbsSmoothingThreshold( double smoothingThreshold ); + RimCase* caseToApply() const; + void setCaseToApply( RimCase* val ); + RimSummaryCase* summaryCaseToApply() const; + void setSummaryCaseToApply( RimSummaryCase* val ); + int trajectoryTypeToApply() const; + void setTrajectoryTypeToApply( int val ); + RimWellPath* wellPathToApply() const; + void setWellPathToApply( RimWellPath* val ); + int branchIndexToApply() const; + void setBranchIndexToApply( int val ); + caf::Tristate branchDetectionToApply() const; + void setBranchDetectionToApply( caf::Tristate::State val ); + caf::Tristate wbsSmoothingToApply() const; + void setWbsSmoothingToApply( caf::Tristate::State val ); + double wbsSmoothingThreshold() const; + void setWbsSmoothingThreshold( double smoothingThreshold ); QString simWellNameToApply() const; void setSimWellNameToApply( const QString& val ); @@ -75,10 +81,10 @@ class RimWellLogCurveCommonDataSource : public caf::PdmObject void setTimeStepToApply( int val ); void resetDefaultOptions(); - void updateDefaultOptions( const std::vector& curves, const std::vector& tracks ); - void updateDefaultOptions(); - void updateCurvesAndTracks( const std::vector& curves, const std::vector& tracks ); - void updateCurvesAndTracks(); + void analyseCurvesAndTracks( const std::vector& curves, const std::vector& tracks ); + void analyseCurvesAndTracks(); + void applyDataSourceChanges( const std::vector& curves, const std::vector& tracks ); + void applyDataSourceChanges(); void applyPrevCase(); void applyNextCase(); @@ -91,30 +97,37 @@ class RimWellLogCurveCommonDataSource : public caf::PdmObject static QString smoothingUiOrderinglabel(); -protected: +private: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; void modifyCurrentIndex( caf::PdmValueField* field, int indexOffset ); + RifReaderRftInterface* rftReader(); + private: RiaDefines::CaseType m_caseType; - caf::PdmPtrField m_case; - caf::PdmField m_trajectoryType; - caf::PdmPtrField m_wellPath; - caf::PdmField m_simWellName; - caf::PdmField m_branchIndex; - caf::PdmField m_branchDetection; - caf::PdmField m_timeStep; - caf::PdmField m_wbsSmoothing; - caf::PdmField m_wbsSmoothingThreshold; + caf::PdmPtrField m_case; + caf::PdmPtrField m_summaryCase; + caf::PdmField m_trajectoryType; + caf::PdmPtrField m_wellPath; + caf::PdmField m_simWellName; + caf::PdmField m_branchIndex; + caf::PdmField m_branchDetection; + caf::PdmField m_timeStep; + caf::PdmField m_wbsSmoothing; + caf::PdmField m_wbsSmoothingThreshold; + + caf::PdmField m_rftTimeStep; + caf::PdmField m_rftWellName; + caf::PdmField m_rftSegmentBranchId; std::set m_uniqueCases; + std::set m_uniqueSummaryCases; std::set m_uniqueTrajectoryTypes; std::set m_uniqueWellPaths; std::set m_uniqueWellNames; @@ -123,4 +136,8 @@ class RimWellLogCurveCommonDataSource : public caf::PdmObject std::set m_uniqueBranchIndices; std::set m_uniqueWbsSmoothing; std::set m_uniqueWbsSmoothingThreshold; + + std::set m_uniqueRftTimeSteps; + std::set m_uniqueRftWellNames; + std::set m_uniqueRftBranchIds; }; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogExtractionCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogExtractionCurve.cpp index 271dfb91a5..307999ac3d 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogExtractionCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogExtractionCurve.cpp @@ -94,14 +94,14 @@ void AppEnum::setUp() //-------------------------------------------------------------------------------------------------- RimWellLogExtractionCurve::RimWellLogExtractionCurve() { - CAF_PDM_InitScriptableObject( "Well Log Curve", RimWellLogCurve::wellLogCurveIconName(), "", "" ); + CAF_PDM_InitScriptableObject( "Well Log Curve", RimWellLogCurve::wellLogCurveIconName() ); - CAF_PDM_InitFieldNoDefault( &m_trajectoryType, "TrajectoryType", "Trajectory Type", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_trajectoryType, "TrajectoryType", "Trajectory Type" ); - CAF_PDM_InitFieldNoDefault( &m_wellPath, "CurveWellPath", "Well Name", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wellPath, "CurveWellPath", "Well Name" ); m_wellPath.uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitField( &m_simWellName, "SimulationWellName", QString( "" ), "Well Name", "", "", "" ); + CAF_PDM_InitField( &m_simWellName, "SimulationWellName", QString( "" ), "Well Name" ); CAF_PDM_InitField( &m_branchDetection, "BranchDetection", true, @@ -109,31 +109,31 @@ RimWellLogExtractionCurve::RimWellLogExtractionCurve() "", "Compute branches based on how simulation well cells are organized", "" ); - CAF_PDM_InitField( &m_branchIndex, "Branch", 0, "Branch Index", "", "", "" ); + CAF_PDM_InitField( &m_branchIndex, "Branch", 0, "Branch Index" ); - CAF_PDM_InitFieldNoDefault( &m_case, "CurveCase", "Case", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_case, "CurveCase", "Case" ); m_case.uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_eclipseResultDefinition, "CurveEclipseResult", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_eclipseResultDefinition, "CurveEclipseResult", "" ); m_eclipseResultDefinition.uiCapability()->setUiTreeHidden( true ); m_eclipseResultDefinition.uiCapability()->setUiTreeChildrenHidden( true ); m_eclipseResultDefinition = new RimEclipseResultDefinition; m_eclipseResultDefinition->findField( "MResultType" )->uiCapability()->setUiName( "Result Type" ); - CAF_PDM_InitFieldNoDefault( &m_geomResultDefinition, "CurveGeomechResult", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_geomResultDefinition, "CurveGeomechResult", "" ); m_geomResultDefinition.uiCapability()->setUiTreeHidden( true ); m_geomResultDefinition.uiCapability()->setUiTreeChildrenHidden( true ); m_geomResultDefinition = new RimGeoMechResultDefinition; m_geomResultDefinition->setAddWellPathDerivedResults( true ); - CAF_PDM_InitField( &m_timeStep, "CurveTimeStep", 0, "Time Step", "", "", "" ); + CAF_PDM_InitField( &m_timeStep, "CurveTimeStep", 0, "Time Step" ); // Add some space before name to indicate these belong to the Auto Name field - CAF_PDM_InitField( &m_addCaseNameToCurveName, "AddCaseNameToCurveName", true, " Case Name", "", "", "" ); - CAF_PDM_InitField( &m_addPropertyToCurveName, "AddPropertyToCurveName", true, " Property", "", "", "" ); - CAF_PDM_InitField( &m_addWellNameToCurveName, "AddWellNameToCurveName", true, " Well Name", "", "", "" ); - CAF_PDM_InitField( &m_addTimestepToCurveName, "AddTimestepToCurveName", false, " Timestep", "", "", "" ); - CAF_PDM_InitField( &m_addDateToCurveName, "AddDateToCurveName", true, " Date", "", "", "" ); + CAF_PDM_InitField( &m_addCaseNameToCurveName, "AddCaseNameToCurveName", true, " Case Name" ); + CAF_PDM_InitField( &m_addPropertyToCurveName, "AddPropertyToCurveName", true, " Property" ); + CAF_PDM_InitField( &m_addWellNameToCurveName, "AddWellNameToCurveName", true, " Well Name" ); + CAF_PDM_InitField( &m_addTimestepToCurveName, "AddTimestepToCurveName", false, " Timestep" ); + CAF_PDM_InitField( &m_addDateToCurveName, "AddDateToCurveName", true, " Date" ); } //-------------------------------------------------------------------------------------------------- @@ -345,50 +345,70 @@ void RimWellLogExtractionCurve::onLoadDataAndUpdate( bool updateParentPlot ) bool isUsingPseudoLength = false; performDataExtraction( &isUsingPseudoLength ); - RimDepthTrackPlot* wellLogPlot; - firstAncestorOrThisOfType( wellLogPlot ); - if ( !wellLogPlot ) return; - - RiaDefines::DepthTypeEnum depthType = wellLogPlot->depthType(); - RiaDefines::DepthUnitType displayUnit = wellLogPlot->depthUnit(); - if ( depthType == RiaDefines::DepthTypeEnum::TRUE_VERTICAL_DEPTH || - depthType == RiaDefines::DepthTypeEnum::TRUE_VERTICAL_DEPTH_RKB ) + if ( m_plotCurve ) { - isUsingPseudoLength = false; - } + bool isUsingPseudoLength = false; + performDataExtraction( &isUsingPseudoLength ); - std::vector xPlotValues = curveData()->xPlotValues(); - std::vector depthPlotValues = curveData()->depthPlotValues( depthType, displayUnit ); - CAF_ASSERT( xPlotValues.size() == depthPlotValues.size() ); - m_qwtPlotCurve->setSamples( xPlotValues.data(), depthPlotValues.data(), static_cast( xPlotValues.size() ) ); + RimDepthTrackPlot* wellLogPlot; + firstAncestorOrThisOfType( wellLogPlot ); + if ( !wellLogPlot ) return; + + RiaDefines::DepthTypeEnum depthType = wellLogPlot->depthType(); + RiaDefines::DepthUnitType displayUnit = wellLogPlot->depthUnit(); + if ( depthType == RiaDefines::DepthTypeEnum::TRUE_VERTICAL_DEPTH || + depthType == RiaDefines::DepthTypeEnum::TRUE_VERTICAL_DEPTH_RKB ) + { + isUsingPseudoLength = false; + } - m_qwtPlotCurve->setLineSegmentStartStopIndices( curveData()->polylineStartStopIndices() ); + bool useLogarithmicScale = false; - this->RimPlotCurve::updateCurvePresentation( updateParentPlot ); + RimWellLogTrack* track = nullptr; + firstAncestorOfType( track ); + if ( track ) + { + useLogarithmicScale = track->isLogarithmicScale(); + } - if ( isUsingPseudoLength ) - { - RimWellLogTrack* wellLogTrack; - firstAncestorOrThisOfType( wellLogTrack ); - CVF_ASSERT( wellLogTrack ); + std::vector xPlotValues = curveData()->propertyValuesByIntervals(); + std::vector depthPlotValues = curveData()->depthValuesByIntervals( depthType, displayUnit ); + CAF_ASSERT( xPlotValues.size() == depthPlotValues.size() ); - RiuQwtPlotWidget* viewer = wellLogTrack->viewer(); - if ( viewer ) + if ( wellLogPlot->depthOrientation() == RimDepthTrackPlot::DepthOrientation::HORIZONTAL ) + m_plotCurve->setSamplesFromXValuesAndYValues( depthPlotValues, xPlotValues, useLogarithmicScale ); + + else + m_plotCurve->setSamplesFromXValuesAndYValues( xPlotValues, depthPlotValues, useLogarithmicScale ); + + m_plotCurve->setLineSegmentStartStopIndices( curveData()->polylineStartStopIndices() ); + + this->RimPlotCurve::updateCurvePresentation( updateParentPlot ); + + if ( isUsingPseudoLength ) { - viewer->setAxisTitleText( QwtPlot::yLeft, "PL/" + wellLogPlot->depthAxisTitle() ); + RimWellLogTrack* wellLogTrack; + firstAncestorOrThisOfType( wellLogTrack ); + CVF_ASSERT( wellLogTrack ); + + RiuQwtPlotWidget* viewer = wellLogTrack->viewer(); + if ( viewer ) + { + viewer->setAxisTitleText( RiuPlotAxis::defaultLeft(), "PL/" + wellLogPlot->depthAxisTitle() ); + } } - } - if ( updateParentPlot ) - { - updateZoomInParentPlot(); - } + if ( updateParentPlot ) + { + updateZoomInParentPlot(); + } - setLogScaleFromSelectedResult(); + setLogScaleFromSelectedResult(); - if ( m_parentQwtPlot ) - { - m_parentQwtPlot->replot(); + if ( m_parentPlot ) + { + m_parentPlot->replot(); + } } } } @@ -525,25 +545,36 @@ void RimWellLogExtractionCurve::extractData( bool* isUsingPseudoLength, if ( !values.empty() && !measuredDepthValues.empty() ) { + bool useLogarithmicScale = false; + + RimWellLogTrack* track = nullptr; + firstAncestorOfType( track ); + if ( track ) + { + useLogarithmicScale = track->isLogarithmicScale(); + } + if ( tvDepthValues.empty() ) { - this->setValuesAndDepths( values, - measuredDepthValues, - RiaDefines::DepthTypeEnum::MEASURED_DEPTH, - 0.0, - depthUnit, - !performDataSmoothing, - xUnits ); + this->setPropertyValuesAndDepths( values, + measuredDepthValues, + RiaDefines::DepthTypeEnum::MEASURED_DEPTH, + 0.0, + depthUnit, + !performDataSmoothing, + useLogarithmicScale, + xUnits ); } else { - this->setValuesWithMdAndTVD( values, - measuredDepthValues, - tvDepthValues, - rkbDiff, - depthUnit, - !performDataSmoothing, - xUnits ); + this->setPropertyValuesWithMdAndTVD( values, + measuredDepthValues, + tvDepthValues, + rkbDiff, + depthUnit, + !performDataSmoothing, + useLogarithmicScale, + xUnits ); } } } @@ -667,7 +698,8 @@ void RimWellLogExtractionCurve::clearGeneratedSimWellPaths() { RimWellLogPlotCollection* wellLogCollection = nullptr; - // Need to use this approach, and not firstAnchestor because the curve might not be inside the hierarchy when deleted. + // Need to use this approach, and not firstAnchestor because the curve might not be inside the hierarchy when + // deleted. RimProject* proj = RimProject::current(); if ( proj && proj->mainPlotCollection() ) wellLogCollection = proj->mainPlotCollection()->wellLogPlotCollection(); @@ -686,11 +718,11 @@ void RimWellLogExtractionCurve::clearGeneratedSimWellPaths() /// //-------------------------------------------------------------------------------------------------- QList - RimWellLogExtractionCurve::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) + RimWellLogExtractionCurve::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; - options = RimWellLogCurve::calculateValueOptions( fieldNeedingOptions, useOptionsOnly ); + options = RimWellLogCurve::calculateValueOptions( fieldNeedingOptions ); if ( options.size() > 0 ) return options; if ( fieldNeedingOptions == &m_wellPath ) diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogExtractionCurve.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogExtractionCurve.h index 42129a11a1..fd96d8af1f 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogExtractionCurve.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogExtractionCurve.h @@ -108,8 +108,7 @@ class RimWellLogExtractionCurve : public RimWellLogCurve void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void initAfterRead() override; static QString dataSourceGroupKeyword(); diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogExtractionCurveNameConfig.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogExtractionCurveNameConfig.cpp index 903fbf0ff3..d5027af8c3 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogExtractionCurveNameConfig.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogExtractionCurveNameConfig.cpp @@ -31,13 +31,13 @@ CAF_PDM_SOURCE_INIT( RimWellLogExtractionCurveNameConfig, "RimWellLogExtractionC RimWellLogExtractionCurveNameConfig::RimWellLogExtractionCurveNameConfig() : RimNameConfig( "Log Extraction" ) { - CAF_PDM_InitObject( "Well Log Extraction Curve Name Generator", "", "", "" ); + CAF_PDM_InitObject( "Well Log Extraction Curve Name Generator" ); - CAF_PDM_InitField( &m_addCaseName, "AddCaseName", true, "Add Case Name", "", "", "" ); - CAF_PDM_InitField( &m_addProperty, "AddProperty", true, "Add Property Type", "", "", "" ); - CAF_PDM_InitField( &m_addWellName, "AddWellName", true, "Add Well Name", "", "", "" ); - CAF_PDM_InitField( &m_addTimestep, "AddTimeStep", true, "Add Time Step", "", "", "" ); - CAF_PDM_InitField( &m_addDate, "AddDate", true, "Add Date", "", "", "" ); + CAF_PDM_InitField( &m_addCaseName, "AddCaseName", true, "Add Case Name" ); + CAF_PDM_InitField( &m_addProperty, "AddProperty", true, "Add Property Type" ); + CAF_PDM_InitField( &m_addWellName, "AddWellName", true, "Add Well Name" ); + CAF_PDM_InitField( &m_addTimestep, "AddTimeStep", true, "Add Time Step" ); + CAF_PDM_InitField( &m_addDate, "AddDate", true, "Add Date" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFile.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFile.cpp index c2547c3aff..498c409ee2 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFile.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFile.cpp @@ -64,34 +64,31 @@ const QDateTime RimWellLogFile::DEFAULT_DATE_TIME = RiaQDateTimeTools::createUtc //-------------------------------------------------------------------------------------------------- RimWellLogFile::RimWellLogFile() { - CAF_PDM_InitObject( "Well LAS File Info", ":/LasFile16x16.png", "", "" ); + CAF_PDM_InitObject( "Well LAS File Info", ":/LasFile16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_wellName, "WellName", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wellName, "WellName", "" ); m_wellName.uiCapability()->setUiReadOnly( true ); - RiaFieldhandleTools::disableWriteAndSetFieldHidden( &m_wellName ); + RiaFieldHandleTools::disableWriteAndSetFieldHidden( &m_wellName ); - CAF_PDM_InitFieldNoDefault( &m_date, "Date", "Date", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_date, "Date", "Date" ); m_date.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitFieldNoDefault( &m_fileName, "FileName", "Filename", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_fileName, "FileName", "Filename" ); m_fileName.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitFieldNoDefault( &m_name, "Name", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_name, "Name", "" ); m_name.uiCapability()->setUiReadOnly( true ); - RiaFieldhandleTools::disableWriteAndSetFieldHidden( &m_name ); + RiaFieldHandleTools::disableWriteAndSetFieldHidden( &m_name ); - CAF_PDM_InitFieldNoDefault( &m_wellLogChannelNames, "WellLogFileChannels", "", "", "", "" ); - RiaFieldhandleTools::disableWriteAndSetFieldHidden( &m_wellLogChannelNames ); + CAF_PDM_InitFieldNoDefault( &m_wellLogChannelNames, "WellLogFileChannels", "" ); + RiaFieldHandleTools::disableWriteAndSetFieldHidden( &m_wellLogChannelNames ); CAF_PDM_InitField( &m_wellFlowCondition, "WellFlowCondition", caf::AppEnum( RimWellLogFile::WELL_FLOW_COND_STANDARD ), - "Well Flow Rates", - "", - "", - "" ); + "Well Flow Rates" ); - CAF_PDM_InitField( &m_invalidDateMessage, "InvalidDateMessage", QString( "Invalid or no date" ), "", "", "", "" ); + CAF_PDM_InitField( &m_invalidDateMessage, "InvalidDateMessage", QString( "Invalid or no date" ), "" ); m_invalidDateMessage.uiCapability()->setUiReadOnly( true ); m_invalidDateMessage.xmlCapability()->disableIO(); @@ -104,7 +101,7 @@ RimWellLogFile::RimWellLogFile() //-------------------------------------------------------------------------------------------------- RimWellLogFile::~RimWellLogFile() { - m_wellLogChannelNames.deleteAllChildObjects(); + m_wellLogChannelNames.deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -175,7 +172,7 @@ bool RimWellLogFile::readFile( QString* errorMessage ) m_date = DEFAULT_DATE_TIME; } - m_wellLogChannelNames.deleteAllChildObjects(); + m_wellLogChannelNames.deleteChildren(); QStringList wellLogNames = m_wellLogDataFile->wellLogChannelNames(); for ( int logIdx = 0; logIdx < wellLogNames.size(); logIdx++ ) diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileChannel.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileChannel.cpp index c1ea680c0e..6371138944 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileChannel.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileChannel.cpp @@ -30,10 +30,10 @@ CAF_PDM_SOURCE_INIT( RimWellLogFileChannel, "WellLogFileChannel" ); //-------------------------------------------------------------------------------------------------- RimWellLogFileChannel::RimWellLogFileChannel() { - CAF_PDM_InitObject( "Well Log File Channel", "", "", "" ); + CAF_PDM_InitObject( "Well Log File Channel" ); - CAF_PDM_InitFieldNoDefault( &m_name, "Name", "", "", "", "" ); - RiaFieldhandleTools::disableWriteAndSetFieldHidden( &m_name ); + CAF_PDM_InitFieldNoDefault( &m_name, "Name", "" ); + RiaFieldHandleTools::disableWriteAndSetFieldHidden( &m_name ); } //-------------------------------------------------------------------------------------------------- @@ -42,4 +42,4 @@ RimWellLogFileChannel::RimWellLogFileChannel() void RimWellLogFileChannel::setName( const QString& name ) { m_name = name; -} \ No newline at end of file +} diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileCurve.cpp index df7daccfe2..133d580578 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileCurve.cpp @@ -52,14 +52,14 @@ CAF_PDM_SOURCE_INIT( RimWellLogFileCurve, "WellLogFileCurve" ); //-------------------------------------------------------------------------------------------------- RimWellLogFileCurve::RimWellLogFileCurve() { - CAF_PDM_InitObject( "Well Log File Curve", RimWellLogCurve::wellLogCurveIconName(), "", "" ); + CAF_PDM_InitObject( "Well Log File Curve", RimWellLogCurve::wellLogCurveIconName() ); - CAF_PDM_InitFieldNoDefault( &m_wellPath, "CurveWellPath", "Well Path", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wellPath, "CurveWellPath", "Well Path" ); m_wellPath.uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_wellLogChannelName, "CurveWellLogChannel", "Well Log Channel", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wellLogChannelName, "CurveWellLogChannel", "Well Log Channel" ); - CAF_PDM_InitFieldNoDefault( &m_wellLogFile, "WellLogFile", "Well Log File", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wellLogFile, "WellLogFile", "Well Log File" ); m_wellPath = nullptr; } @@ -150,7 +150,15 @@ void RimWellLogFileCurve::onLoadDataAndUpdate( bool updateParentPlot ) validDepths.insert( std::make_pair( RiaDefines::DepthTypeEnum::TRUE_VERTICAL_DEPTH_RKB, tvdRkbValues ) ); } - this->setValuesAndDepths( values, validDepths, rkbDiff, wellLogFile->depthUnit(), false ); + bool useLogarithmicScale = false; + RimWellLogTrack* track = nullptr; + firstAncestorOfType( track ); + if ( track ) + { + useLogarithmicScale = track->isLogarithmicScale(); + } + + this->setPropertyValuesAndDepths( values, validDepths, rkbDiff, wellLogFile->depthUnit(), false, useLogarithmicScale ); QString errMsg; if ( wellLogPlot && !this->curveData()->availableDepthTypes().count( wellLogPlot->depthType() ) ) @@ -172,7 +180,7 @@ void RimWellLogFileCurve::onLoadDataAndUpdate( bool updateParentPlot ) if ( m_isUsingAutoName ) { - m_qwtPlotCurve->setTitle( createCurveAutoName() ); + m_plotCurve->setTitle( createCurveAutoName() ); } } @@ -188,19 +196,18 @@ void RimWellLogFileCurve::onLoadDataAndUpdate( bool updateParentPlot ) depthType = wellLogPlot->depthType(); } - m_qwtPlotCurve->setSamples( this->curveData()->xPlotValues().data(), - this->curveData()->depthPlotValues( depthType, displayUnit ).data(), - static_cast( this->curveData()->xPlotValues().size() ) ); - m_qwtPlotCurve->setLineSegmentStartStopIndices( this->curveData()->polylineStartStopIndices() ); + m_plotCurve->setSamplesValues( this->curveData()->propertyValuesByIntervals(), + this->curveData()->depthValuesByIntervals( depthType, displayUnit ) ); + m_plotCurve->setLineSegmentStartStopIndices( this->curveData()->polylineStartStopIndices() ); if ( updateParentPlot ) { updateZoomInParentPlot(); } - if ( m_parentQwtPlot ) + if ( m_parentPlot ) { - m_parentQwtPlot->replot(); + m_parentPlot->replot(); } } } @@ -315,7 +322,7 @@ void RimWellLogFileCurve::fieldChangedByUi( const caf::PdmFieldHandle* changedFi { this->loadDataAndUpdate( true ); } - if ( m_parentQwtPlot ) m_parentQwtPlot->replot(); + if ( m_parentPlot ) m_parentPlot->replot(); } //-------------------------------------------------------------------------------------------------- @@ -352,12 +359,11 @@ void RimWellLogFileCurve::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOr //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimWellLogFileCurve::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RimWellLogFileCurve::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; - options = RimWellLogCurve::calculateValueOptions( fieldNeedingOptions, useOptionsOnly ); + options = RimWellLogCurve::calculateValueOptions( fieldNeedingOptions ); if ( options.size() > 0 ) return options; if ( fieldNeedingOptions == &m_wellPath ) diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileCurve.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileCurve.h index 302e4d4496..73416cd47a 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileCurve.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileCurve.h @@ -65,8 +65,7 @@ class RimWellLogFileCurve : public RimWellLogCurve void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void initAfterRead() override; bool isRftPlotChild() const; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileCurveNameConfig.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileCurveNameConfig.cpp index bf0a78fed6..0196e579c2 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileCurveNameConfig.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileCurveNameConfig.cpp @@ -31,7 +31,7 @@ CAF_PDM_SOURCE_INIT( RimWellLogFileCurveNameConfig, "RimWellLogFileCurveNameConf RimWellLogFileCurveNameConfig::RimWellLogFileCurveNameConfig() : RimNameConfig( "Las Curve" ) { - CAF_PDM_InitObject( "Well Log File Curve Name Generator", "", "", "" ); + CAF_PDM_InitObject( "Well Log File Curve Name Generator" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogPlotCollection.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogPlotCollection.cpp index 0be5aad571..bf5b9cf690 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogPlotCollection.cpp @@ -46,9 +46,9 @@ CAF_PDM_SOURCE_INIT( RimWellLogPlotCollection, "WellLogPlotCollection" ); //-------------------------------------------------------------------------------------------------- RimWellLogPlotCollection::RimWellLogPlotCollection() { - CAF_PDM_InitScriptableObject( "Well Log Plots", ":/WellLogPlots16x16.png", "", "" ); + CAF_PDM_InitScriptableObject( "Well Log Plots", ":/WellLogPlots16x16.png" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_wellLogPlots, "WellLogPlots", "", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_wellLogPlots, "WellLogPlots", "" ); m_wellLogPlots.uiCapability()->setUiTreeHidden( true ); } @@ -147,7 +147,7 @@ RigGeoMechWellLogExtractor* RimWellLogPlotCollection::findOrCreateExtractor( Rim //-------------------------------------------------------------------------------------------------- std::vector RimWellLogPlotCollection::wellLogPlots() const { - return m_wellLogPlots.childObjects(); + return m_wellLogPlots.children(); } //-------------------------------------------------------------------------------------------------- @@ -163,7 +163,7 @@ void RimWellLogPlotCollection::addWellLogPlot( gsl::not_null we //-------------------------------------------------------------------------------------------------- void RimWellLogPlotCollection::deleteAllPlots() { - m_wellLogPlots.deleteAllChildObjects(); + m_wellLogPlots.deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -171,7 +171,7 @@ void RimWellLogPlotCollection::deleteAllPlots() //-------------------------------------------------------------------------------------------------- void RimWellLogPlotCollection::removePlot( gsl::not_null plot ) { - m_wellLogPlots.removeChildObject( plot ); + m_wellLogPlots.removeChild( plot ); updateAllRequiredEditors(); } @@ -251,15 +251,7 @@ void RimWellLogPlotCollection::removeExtractors( const RigGeoMechCaseData* caseD void RimWellLogPlotCollection::onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, std::vector& referringObjects ) { - // Make sure the plot collection disappears with the last plot - if ( m_wellLogPlots().empty() ) - { - RimProject* project = RimProject::current(); - if ( project ) - { - project->updateConnectedEditors(); - } - } + updateConnectedEditors(); RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow(); mainPlotWindow->updateWellLogPlotToolBar(); diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogPlotNameConfig.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogPlotNameConfig.cpp index 65bb5e2523..b41cc6dadb 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogPlotNameConfig.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogPlotNameConfig.cpp @@ -31,13 +31,13 @@ CAF_PDM_SOURCE_INIT( RimWellLogPlotNameConfig, "RimWellLogPlotNameConfig" ); RimWellLogPlotNameConfig::RimWellLogPlotNameConfig() : RimNameConfig( "Well Log Plot" ) { - CAF_PDM_InitObject( "Well Log Plot Name Generator", "", "", "" ); + CAF_PDM_InitObject( "Well Log Plot Name Generator" ); - CAF_PDM_InitField( &m_addCaseName, "AddCaseName", false, "Show Case Name", "", "", "" ); - CAF_PDM_InitField( &m_addWellName, "AddWellName", false, "Show Well Name", "", "", "" ); - CAF_PDM_InitField( &m_addTimestep, "AddTimeStep", false, "Show Time Step", "", "", "" ); - CAF_PDM_InitField( &m_addAirGap, "AddAirGap", false, "Show Air Gap", "", "", "" ); - CAF_PDM_InitField( &m_addWaterDepth, "AddWaterDepth", false, "Show Water Depth", "", "", "" ); + CAF_PDM_InitField( &m_addCaseName, "AddCaseName", false, "Show Case Name" ); + CAF_PDM_InitField( &m_addWellName, "AddWellName", false, "Show Well Name" ); + CAF_PDM_InitField( &m_addTimestep, "AddTimeStep", false, "Show Time Step" ); + CAF_PDM_InitField( &m_addAirGap, "AddAirGap", false, "Show Air Gap" ); + CAF_PDM_InitField( &m_addWaterDepth, "AddWaterDepth", false, "Show Water Depth" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurve.cpp index 491e77398b..8ee4b02003 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurve.cpp @@ -21,7 +21,10 @@ #include "RiaDefines.h" #include "RiaEclipseUnitTools.h" #include "RiaQDateTimeTools.h" +#include "RiaResultNames.h" +#include "RiaRftDefines.h" #include "RiaSimWellBranchTools.h" +#include "RiaSummaryTools.h" #include "RifEclipseRftAddress.h" #include "RifReaderEclipseRft.h" @@ -39,6 +42,7 @@ #include "RimMainPlotCollection.h" #include "RimObservedFmuRftData.h" #include "RimProject.h" +#include "RimRftTools.h" #include "RimSummaryCase.h" #include "RimSummaryCaseCollection.h" #include "RimTools.h" @@ -68,50 +72,96 @@ namespace caf template <> void caf::AppEnum::setUp() { - addItem( RifEclipseRftAddress::NONE, "NONE", "None" ); - addItem( RifEclipseRftAddress::TVD, "DEPTH", "Depth" ); - addItem( RifEclipseRftAddress::PRESSURE, "PRESSURE", "Pressure" ); - addItem( RifEclipseRftAddress::SWAT, "SWAT", "Water Saturation" ); - addItem( RifEclipseRftAddress::SOIL, "SOIL", "Oil Saturation" ); - addItem( RifEclipseRftAddress::SGAS, "SGAS", "Gas Saturation" ); - addItem( RifEclipseRftAddress::WRAT, "WRAT", "Water Flow" ); - addItem( RifEclipseRftAddress::ORAT, "ORAT", "Oil Flow" ); - addItem( RifEclipseRftAddress::GRAT, "GRAT", "Gas flow" ); - addItem( RifEclipseRftAddress::MD, "MD", "Measured Depth" ); - addItem( RifEclipseRftAddress::PRESSURE_P10, "PRESSURE_P10", "P10: Pressure" ); - addItem( RifEclipseRftAddress::PRESSURE_P50, "PRESSURE_P50", "P50: Pressure" ); - addItem( RifEclipseRftAddress::PRESSURE_P90, "PRESSURE_P90", "P90: Pressure" ); - addItem( RifEclipseRftAddress::PRESSURE_MEAN, "PRESSURE_MEAN", "Mean: Pressure" ); - addItem( RifEclipseRftAddress::PRESSURE_ERROR, "PRESSURE_ERROR", "Error: Pressure" ); - setDefault( RifEclipseRftAddress::NONE ); + addItem( RifEclipseRftAddress::RftWellLogChannelType::NONE, "NONE", "None" ); + addItem( RifEclipseRftAddress::RftWellLogChannelType::TVD, "DEPTH", "Depth" ); + addItem( RifEclipseRftAddress::RftWellLogChannelType::PRESSURE, "PRESSURE", "Pressure" ); + addItem( RifEclipseRftAddress::RftWellLogChannelType::SWAT, RiaResultNames::swat(), "Water Saturation" ); + addItem( RifEclipseRftAddress::RftWellLogChannelType::SOIL, RiaResultNames::soil(), "Oil Saturation" ); + addItem( RifEclipseRftAddress::RftWellLogChannelType::SGAS, RiaResultNames::sgas(), "Gas Saturation" ); + addItem( RifEclipseRftAddress::RftWellLogChannelType::WRAT, "WRAT", "Water Flow" ); + addItem( RifEclipseRftAddress::RftWellLogChannelType::ORAT, "ORAT", "Oil Flow" ); + addItem( RifEclipseRftAddress::RftWellLogChannelType::GRAT, "GRAT", "Gas flow" ); + addItem( RifEclipseRftAddress::RftWellLogChannelType::MD, "MD", "Measured Depth" ); + addItem( RifEclipseRftAddress::RftWellLogChannelType::PRESSURE_P10, "PRESSURE_P10", "P10: Pressure" ); + addItem( RifEclipseRftAddress::RftWellLogChannelType::PRESSURE_P50, "PRESSURE_P50", "P50: Pressure" ); + addItem( RifEclipseRftAddress::RftWellLogChannelType::PRESSURE_P90, "PRESSURE_P90", "P90: Pressure" ); + addItem( RifEclipseRftAddress::RftWellLogChannelType::PRESSURE_MEAN, "PRESSURE_MEAN", "Mean: Pressure" ); + addItem( RifEclipseRftAddress::RftWellLogChannelType::PRESSURE_ERROR, "PRESSURE_ERROR", "Error: Pressure" ); + setDefault( RifEclipseRftAddress::RftWellLogChannelType::NONE ); +} +} // namespace caf + +namespace caf +{ +template <> +void caf::AppEnum::setUp() +{ + addItem( RimWellLogRftCurve::RftDataType::RFT_DATA, "RFT_DATA", "RFT" ); + addItem( RimWellLogRftCurve::RftDataType::RFT_SEGMENT_DATA, "RFT_SEGMENT_DATA", "RFT Segment" ); + setDefault( RimWellLogRftCurve::RftDataType::RFT_DATA ); } } // namespace caf CAF_PDM_SOURCE_INIT( RimWellLogRftCurve, "WellLogRftCurve" ); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaDefines::PhaseType RimWellLogRftCurve::phaseType() const +{ + if ( m_rftDataType() == RimWellLogRftCurve::RftDataType::RFT_DATA ) + { + if ( m_wellLogChannelName() == RifEclipseRftAddress::RftWellLogChannelType::SWAT || + m_wellLogChannelName() == RifEclipseRftAddress::RftWellLogChannelType::WRAT ) + { + return RiaDefines::PhaseType::WATER_PHASE; + } + + if ( m_wellLogChannelName() == RifEclipseRftAddress::RftWellLogChannelType::SGAS || + m_wellLogChannelName() == RifEclipseRftAddress::RftWellLogChannelType::GRAT ) + { + return RiaDefines::PhaseType::GAS_PHASE; + } + + if ( m_wellLogChannelName() == RifEclipseRftAddress::RftWellLogChannelType::SOIL || + m_wellLogChannelName() == RifEclipseRftAddress::RftWellLogChannelType::ORAT ) + { + return RiaDefines::PhaseType::OIL_PHASE; + } + } + else if ( m_rftDataType() == RimWellLogRftCurve::RftDataType::RFT_SEGMENT_DATA ) + { + if ( m_segmentResultName().startsWith( "SEGO" ) ) return RiaDefines::PhaseType::OIL_PHASE; + if ( m_segmentResultName().startsWith( "SEGW" ) ) return RiaDefines::PhaseType::WATER_PHASE; + if ( m_segmentResultName().startsWith( "SEGG" ) ) return RiaDefines::PhaseType::GAS_PHASE; + } + + return RiaDefines::PhaseType::PHASE_NOT_APPLICABLE; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RimWellLogRftCurve::RimWellLogRftCurve() { - CAF_PDM_InitObject( "Well Log RFT Curve", RimWellLogCurve::wellLogCurveIconName(), "", "" ); + CAF_PDM_InitObject( "Well Log RFT Curve", RimWellLogCurve::wellLogCurveIconName() ); - CAF_PDM_InitFieldNoDefault( &m_eclipseResultCase, "CurveEclipseResultCase", "Eclipse Result Case", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_eclipseResultCase, "CurveEclipseResultCase", "Eclipse Result Case" ); m_eclipseResultCase.uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_summaryCase, "CurveSummaryCase", "Summary Case", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_summaryCase, "CurveSummaryCase", "Summary Case" ); m_summaryCase.uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_ensemble, "CurveEnsemble", "Ensemble", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_ensemble, "CurveEnsemble", "Ensemble" ); m_ensemble.uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_observedFmuRftData, "ObservedFmuRftData", "Observed FMU RFT Data", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_observedFmuRftData, "ObservedFmuRftData", "Observed FMU RFT Data" ); m_observedFmuRftData.uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_timeStep, "TimeStep", "Time Step", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_timeStep, "TimeStep", "Time Step" ); - CAF_PDM_InitFieldNoDefault( &m_wellName, "WellName", "Well Name", "", "", "" ); - CAF_PDM_InitField( &m_branchIndex, "BranchIndex", 0, "Branch Index", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wellName, "WellName", "Well Name" ); + CAF_PDM_InitField( &m_branchIndex, "BranchIndex", 0, "Branch Index" ); CAF_PDM_InitField( &m_branchDetection, "BranchDetection", true, @@ -120,7 +170,11 @@ RimWellLogRftCurve::RimWellLogRftCurve() "Compute branches based on how simulation well cells are organized", "" ); - CAF_PDM_InitFieldNoDefault( &m_wellLogChannelName, "WellLogChannelName", "Well Property", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wellLogChannelName, "WellLogChannelName", "Well Property" ); + CAF_PDM_InitFieldNoDefault( &m_rftDataType, "RftDataType", "Data Type" ); + + CAF_PDM_InitField( &m_segmentResultName, "SegmentResultName", RiaResultNames::undefinedResultName(), "Segment Result Name" ); + CAF_PDM_InitField( &m_segmentBranchId, "SegmentBranchId", -1, "Segment Branch" ); } //-------------------------------------------------------------------------------------------------- @@ -130,6 +184,14 @@ RimWellLogRftCurve::~RimWellLogRftCurve() { } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogRftCurve::setWellName( const QString& wellName ) +{ + m_wellName = wellName; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -154,6 +216,30 @@ QString RimWellLogRftCurve::wellLogChannelUnits() const return RiaWellLogUnitTools::noUnitString(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogRftCurve::setTimeStep( const QDateTime& dateTime ) +{ + m_timeStep = dateTime; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QDateTime RimWellLogRftCurve::timeStep() const +{ + return m_timeStep(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogRftCurve::setSegmentBranchId( int branchId ) +{ + m_segmentBranchId = branchId; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -226,6 +312,17 @@ void RimWellLogRftCurve::setRftAddress( RifEclipseRftAddress address ) m_timeStep = address.timeStep(); m_wellName = address.wellName(); m_wellLogChannelName = address.wellLogChannel(); + + if ( address.wellLogChannel() == RifEclipseRftAddress::RftWellLogChannelType::SEGMENT_VALUES ) + { + m_rftDataType = RftDataType::RFT_SEGMENT_DATA; + m_segmentResultName = address.segmentResultName(); + m_segmentBranchId = address.segmentBranchNumber(); + } + else + { + m_rftDataType = RftDataType::RFT_DATA; + } } //-------------------------------------------------------------------------------------------------- @@ -233,7 +330,12 @@ void RimWellLogRftCurve::setRftAddress( RifEclipseRftAddress address ) //-------------------------------------------------------------------------------------------------- RifEclipseRftAddress RimWellLogRftCurve::rftAddress() const { - return RifEclipseRftAddress( m_wellName, m_timeStep, m_wellLogChannelName() ); + if ( m_rftDataType == RftDataType::RFT_SEGMENT_DATA ) + { + return RifEclipseRftAddress::createSegmentAddress( m_wellName, m_timeStep, m_segmentResultName(), m_segmentBranchId() ); + } + + return RifEclipseRftAddress::createAddress( m_wellName, m_timeStep, m_wellLogChannelName() ); } //-------------------------------------------------------------------------------------------------- @@ -258,12 +360,12 @@ void RimWellLogRftCurve::setDefaultAddress( QString wellName ) if ( !wellNameHasRftData ) { - m_wellLogChannelName = RifEclipseRftAddress::NONE; + m_wellLogChannelName = RifEclipseRftAddress::RftWellLogChannelType::NONE; m_timeStep = QDateTime(); return; } - m_wellLogChannelName = RifEclipseRftAddress::PRESSURE; + m_wellLogChannelName = RifEclipseRftAddress::RftWellLogChannelType::PRESSURE; std::set timeSteps = reader->availableTimeSteps( m_wellName, m_wellLogChannelName() ); if ( !timeSteps.empty() ) @@ -281,7 +383,7 @@ void RimWellLogRftCurve::setDefaultAddress( QString wellName ) //-------------------------------------------------------------------------------------------------- void RimWellLogRftCurve::updateWellChannelNameAndTimeStep() { - if ( !m_timeStep().isValid() || m_wellLogChannelName() == RifEclipseRftAddress::NONE ) + if ( !m_timeStep().isValid() || m_wellLogChannelName() == RifEclipseRftAddress::RftWellLogChannelType::NONE ) { setDefaultAddress( m_wellName ); return; @@ -294,11 +396,11 @@ void RimWellLogRftCurve::updateWellChannelNameAndTimeStep() if ( channelNames.empty() ) { - m_wellLogChannelName = RifEclipseRftAddress::NONE; + m_wellLogChannelName = RifEclipseRftAddress::RftWellLogChannelType::NONE; } else if ( !channelNames.count( m_wellLogChannelName() ) ) { - m_wellLogChannelName = RifEclipseRftAddress::PRESSURE; + m_wellLogChannelName = RifEclipseRftAddress::RftWellLogChannelType::PRESSURE; } std::set timeSteps = reader->availableTimeSteps( m_wellName, m_wellLogChannelName() ); @@ -352,14 +454,26 @@ QString RimWellLogRftCurve::createCurveAutoName() { name.push_back( m_observedFmuRftData->name() ); } - if ( wellLogChannelUiName() != - caf::AppEnum::text( RifEclipseRftAddress::NONE ) ) + + if ( m_rftDataType() == RftDataType::RFT_DATA ) { - RifEclipseRftAddress::RftWellLogChannelType channelNameEnum = - caf::AppEnum::fromText( wellLogChannelUiName() ); - QString channelName = caf::AppEnum::uiText( channelNameEnum ); - name.push_back( channelName ); + if ( wellLogChannelUiName() != caf::AppEnum::text( + RifEclipseRftAddress::RftWellLogChannelType::NONE ) ) + { + RifEclipseRftAddress::RftWellLogChannelType channelNameEnum = + caf::AppEnum::fromText( wellLogChannelUiName() ); + QString channelName = caf::AppEnum::uiText( channelNameEnum ); + name.push_back( channelName ); + } } + else if ( m_rftDataType() == RftDataType::RFT_SEGMENT_DATA ) + { + name.push_back( m_segmentResultName ); + + QString branchText = QString( "Branch %1" ).arg( m_segmentBranchId() ); + name.push_back( branchText ); + } + if ( !m_timeStep().isNull() ) { name.push_back( m_timeStep().toString( RiaQDateTimeTools::dateFormatString() ) ); @@ -375,7 +489,7 @@ void RimWellLogRftCurve::onLoadDataAndUpdate( bool updateParentPlot ) { this->RimPlotCurve::updateCurvePresentation( updateParentPlot ); - DerivedMDSource derivedMDSource = NO_SOURCE; + DerivedMDSource derivedMDSource = DerivedMDSource::NO_SOURCE; if ( isCurveVisible() ) { @@ -383,9 +497,9 @@ void RimWellLogRftCurve::onLoadDataAndUpdate( bool updateParentPlot ) firstAncestorOrThisOfType( wellLogPlot ); CVF_ASSERT( wellLogPlot ); - RimWellRftPlot* rftPlot = dynamic_cast( wellLogPlot ); - bool showErrorBarsInObservedData = rftPlot ? rftPlot->showErrorBarsForObservedData() : false; - m_showErrorBars = showErrorBarsInObservedData; + auto* rftPlot = dynamic_cast( wellLogPlot ); + bool showErrorBarsInObservedData = rftPlot ? rftPlot->showErrorBarsForObservedData() : false; + m_showErrorBars = showErrorBarsInObservedData; std::vector measuredDepthVector = measuredDepthValues(); std::vector tvDepthVector = tvDepthValues(); @@ -395,14 +509,19 @@ void RimWellLogRftCurve::onLoadDataAndUpdate( bool updateParentPlot ) if ( values.empty() || values.size() != tvDepthVector.size() ) { - this->detachQwtCurve(); + this->detach( true ); return; } RiaDefines::EclipseUnitSystem unitSystem = RiaDefines::EclipseUnitSystem::UNITS_METRIC; if ( m_eclipseResultCase ) { - unitSystem = m_eclipseResultCase->eclipseCaseData()->unitsType(); + // TODO: If no grid data, but only RFT data is loaded, we do not have any way to + // detect unit + if ( m_eclipseResultCase->eclipseCaseData() ) + { + unitSystem = m_eclipseResultCase->eclipseCaseData()->unitsType(); + } } else if ( m_summaryCase ) { @@ -427,17 +546,17 @@ void RimWellLogRftCurve::onLoadDataAndUpdate( bool updateParentPlot ) { if ( deriveMeasuredDepthValuesFromWellPath( tvDepthVector, measuredDepthVector ) ) { - derivedMDSource = WELL_PATH; + derivedMDSource = DerivedMDSource::WELL_PATH; } else if ( deriveMeasuredDepthFromObservedData( tvDepthVector, measuredDepthVector ) ) { - derivedMDSource = OBSERVED_DATA; + derivedMDSource = DerivedMDSource::OBSERVED_DATA; } } if ( tvDepthVector.size() != measuredDepthVector.size() ) { - derivedMDSource = NO_SOURCE; + derivedMDSource = DerivedMDSource::NO_SOURCE; measuredDepthVector = tvDepthVector; } @@ -450,12 +569,14 @@ void RimWellLogRftCurve::onLoadDataAndUpdate( bool updateParentPlot ) rkbDiff = wellPath->wellPathGeometry()->rkbDiff(); } - this->setValuesWithMdAndTVD( values, - measuredDepthVector, - tvDepthVector, - rkbDiff, - RiaDefines::fromEclipseUnit( unitSystem ), - false ); + bool useLogarithmicScale = false; + this->setPropertyValuesWithMdAndTVD( values, + measuredDepthVector, + tvDepthVector, + rkbDiff, + RiaDefines::fromEclipseUnit( unitSystem ), + false, + useLogarithmicScale ); RiaDefines::DepthUnitType displayUnit = RiaDefines::DepthUnitType::UNIT_METER; if ( wellLogPlot ) @@ -465,23 +586,18 @@ void RimWellLogRftCurve::onLoadDataAndUpdate( bool updateParentPlot ) if ( wellLogPlot->depthType() == RiaDefines::DepthTypeEnum::MEASURED_DEPTH ) { - m_qwtPlotCurve->setPerPointLabels( perPointLabels ); + m_plotCurve->setPerPointLabels( perPointLabels ); - auto xValues = this->curveData()->xPlotValues(); - auto yValues = this->curveData()->depthPlotValues( RiaDefines::DepthTypeEnum::MEASURED_DEPTH, displayUnit ); - bool keepOnlyPositiveValues = false; + auto propertyValues = this->curveData()->propertyValues(); + auto depthValues = this->curveData()->depths( RiaDefines::DepthTypeEnum::MEASURED_DEPTH, displayUnit ); if ( !errors.empty() ) { - this->setSamplesFromXYErrorValues( xValues, - yValues, - errors, - keepOnlyPositiveValues, - RiaCurveDataTools::ErrorAxis::ERROR_ALONG_X_AXIS ); + setPropertyAndDepthsAndErrors( propertyValues, depthValues, errors ); } else { - m_qwtPlotCurve->setSamplesFromXValuesAndYValues( xValues, yValues, keepOnlyPositiveValues ); + setPropertyAndDepthValuesToPlotCurve( propertyValues, depthValues ); } RimWellLogTrack* wellLogTrack; @@ -491,56 +607,63 @@ void RimWellLogRftCurve::onLoadDataAndUpdate( bool updateParentPlot ) RiuQwtPlotWidget* viewer = wellLogTrack->viewer(); if ( viewer ) { - if ( derivedMDSource != NO_SOURCE ) + QString text; + + if ( derivedMDSource != DerivedMDSource::NO_SOURCE ) { - if ( derivedMDSource == WELL_PATH ) + if ( derivedMDSource == DerivedMDSource::WELL_PATH ) { - viewer->setAxisTitleText( QwtPlot::yLeft, "WELL/" + wellLogPlot->depthAxisTitle() ); + text = "WELL/" + wellLogPlot->depthAxisTitle(); } else { - viewer->setAxisTitleText( QwtPlot::yLeft, "OBS/" + wellLogPlot->depthAxisTitle() ); + text = "OBS/" + wellLogPlot->depthAxisTitle(); } } else // Standard depth title set from plot { - viewer->setAxisTitleText( QwtPlot::yLeft, wellLogPlot->depthAxisTitle() ); + text = wellLogPlot->depthAxisTitle(); } + + viewer->setAxisTitleText( wellLogPlot->depthAxis(), text ); } } else { - m_qwtPlotCurve->setPerPointLabels( perPointLabels ); + m_plotCurve->setPerPointLabels( perPointLabels ); - auto xValues = this->curveData()->xPlotValues(); - auto yValues = - this->curveData()->depthPlotValues( RiaDefines::DepthTypeEnum::TRUE_VERTICAL_DEPTH, displayUnit ); - bool isLogCurve = false; + auto propertyValues = this->curveData()->propertyValuesByIntervals(); + auto depthValues = + this->curveData()->depthValuesByIntervals( RiaDefines::DepthTypeEnum::TRUE_VERTICAL_DEPTH, displayUnit ); + bool useLogarithmicScale = false; if ( !errors.empty() ) { - this->setSamplesFromXYErrorValues( xValues, - yValues, - errors, - isLogCurve, - RiaCurveDataTools::ErrorAxis::ERROR_ALONG_X_AXIS ); + setPropertyAndDepthsAndErrors( propertyValues, depthValues, errors ); } else { - m_qwtPlotCurve->setSamplesFromXValuesAndYValues( xValues, yValues, isLogCurve ); + if ( isVerticalCurve() ) + { + m_plotCurve->setSamplesFromXValuesAndYValues( propertyValues, depthValues, useLogarithmicScale ); + } + else + { + m_plotCurve->setSamplesFromXValuesAndYValues( depthValues, propertyValues, useLogarithmicScale ); + } } } - m_qwtPlotCurve->setLineSegmentStartStopIndices( this->curveData()->polylineStartStopIndices() ); + m_plotCurve->setLineSegmentStartStopIndices( this->curveData()->polylineStartStopIndices() ); if ( updateParentPlot ) { updateZoomInParentPlot(); } - if ( m_parentQwtPlot ) + if ( m_parentPlot ) { - m_parentQwtPlot->replot(); + m_parentPlot->replot(); } } } @@ -554,15 +677,25 @@ void RimWellLogRftCurve::defineUiOrdering( QString uiConfigName, caf::PdmUiOrder caf::PdmUiGroup* curveDataGroup = uiOrdering.addNewGroup( "Curve Data" ); curveDataGroup->add( &m_eclipseResultCase ); + curveDataGroup->add( &m_summaryCase ); curveDataGroup->add( &m_wellName ); + curveDataGroup->add( &m_timeStep ); + curveDataGroup->add( &m_rftDataType ); - RiaSimWellBranchTools::appendSimWellBranchFieldsIfRequiredFromWellName( curveDataGroup, - m_wellName, - m_branchDetection, - m_branchIndex ); + if ( m_rftDataType() == RimWellLogRftCurve::RftDataType::RFT_DATA ) + { + curveDataGroup->add( &m_wellLogChannelName ); - curveDataGroup->add( &m_wellLogChannelName ); - curveDataGroup->add( &m_timeStep ); + RiaSimWellBranchTools::appendSimWellBranchFieldsIfRequiredFromWellName( curveDataGroup, + m_wellName, + m_branchDetection, + m_branchIndex ); + } + else + { + curveDataGroup->add( &m_segmentResultName ); + curveDataGroup->add( &m_segmentBranchId ); + } caf::PdmUiGroup* stackingGroup = uiOrdering.addNewGroup( "Stacking" ); RimStackablePlotCurve::stackingUiOrdering( *stackingGroup ); @@ -580,70 +713,40 @@ void RimWellLogRftCurve::defineUiOrdering( QString uiConfigName, caf::PdmUiOrder //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimWellLogRftCurve::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RimWellLogRftCurve::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; - options = RimWellLogCurve::calculateValueOptions( fieldNeedingOptions, useOptionsOnly ); + options = RimWellLogCurve::calculateValueOptions( fieldNeedingOptions ); - if ( options.size() > 0 ) return options; + if ( !options.empty() ) return options; + RifReaderRftInterface* reader = rftReader(); if ( fieldNeedingOptions == &m_eclipseResultCase ) { RimTools::caseOptionItems( &options ); options.push_front( caf::PdmOptionItemInfo( "None", nullptr ) ); } + else if ( fieldNeedingOptions == &m_summaryCase ) + { + options = RiaSummaryTools::optionsForSummaryCases( RimProject::current()->allSummaryCases() ); + options.push_front( caf::PdmOptionItemInfo( "None", nullptr ) ); + } else if ( fieldNeedingOptions == &m_wellName ) { - options.push_back( caf::PdmOptionItemInfo( "None", "" ) ); - RifReaderRftInterface* reader = rftReader(); - if ( reader ) - { - std::set wellNames = reader->wellNames(); - for ( const QString& name : wellNames ) - { - options.push_back( caf::PdmOptionItemInfo( name, name, false, caf::IconProvider( ":/Well.svg" ) ) ); - } - } + options = RimRftTools::wellNameOptions( reader ); } else if ( fieldNeedingOptions == &m_wellLogChannelName ) { - RifReaderRftInterface* reader = rftReader(); - if ( reader ) - { - for ( const RifEclipseRftAddress::RftWellLogChannelType& channelName : - reader->availableWellLogChannels( m_wellName ) ) - { - options.push_back( - caf::PdmOptionItemInfo( caf::AppEnum::uiText( channelName ), - channelName ) ); - } - } - if ( options.empty() ) - { - options.push_back( caf::PdmOptionItemInfo( caf::AppEnum::uiText( - RifEclipseRftAddress::NONE ), - RifEclipseRftAddress::NONE ) ); - } + options = RimRftTools::wellLogChannelsOptions( reader, m_wellName() ); } else if ( fieldNeedingOptions == &m_timeStep ) { - RifReaderRftInterface* reader = rftReader(); - if ( reader ) - { - QString dateFormat = "dd MMM yyyy"; - std::set timeStamps = reader->availableTimeSteps( m_wellName, m_wellLogChannelName() ); - for ( const QDateTime& dt : timeStamps ) - { - QString dateString = RiaQDateTimeTools::toStringUsingApplicationLocale( dt, dateFormat ); - - options.push_back( caf::PdmOptionItemInfo( dateString, dt ) ); - } - } - - options.push_back( caf::PdmOptionItemInfo( "None", QDateTime() ) ); + if ( m_rftDataType == RimWellLogRftCurve::RftDataType::RFT_SEGMENT_DATA ) + options = RimRftTools::segmentTimeStepOptions( reader, m_wellName ); + else + options = RimRftTools::timeStepOptions( reader, m_wellName, m_wellLogChannelName() ); } else if ( fieldNeedingOptions == &m_branchIndex ) { @@ -652,6 +755,14 @@ QList RimWellLogRftCurve::calculateValueOptions( const c options = RiaSimWellBranchTools::valueOptionsForBranchIndexField( simulationWellBranches ); } + else if ( fieldNeedingOptions == &m_segmentResultName ) + { + options = RimRftTools::segmentResultNameOptions( reader, m_wellName(), m_timeStep() ); + } + else if ( fieldNeedingOptions == &m_segmentBranchId ) + { + options = RimRftTools::segmentBranchIdOptions( reader, m_wellName(), m_timeStep() ); + } return options; } @@ -665,21 +776,23 @@ void RimWellLogRftCurve::fieldChangedByUi( const caf::PdmFieldHandle* changedFie { m_idxInWellPathToIdxInRftFile.clear(); + bool loadData = false; + RimWellLogCurve::fieldChangedByUi( changedField, oldValue, newValue ); if ( changedField == &m_eclipseResultCase ) { m_timeStep = QDateTime(); m_wellName = ""; - m_wellLogChannelName = RifEclipseRftAddress::NONE; + m_wellLogChannelName = RifEclipseRftAddress::RftWellLogChannelType::NONE; - this->loadDataAndUpdate( true ); + loadData = true; } else if ( changedField == &m_wellName ) { m_branchIndex = 0; updateWellChannelNameAndTimeStep(); - this->loadDataAndUpdate( true ); + loadData = true; } else if ( changedField == &m_branchDetection || changedField == &m_branchIndex ) { @@ -688,20 +801,23 @@ void RimWellLogRftCurve::fieldChangedByUi( const caf::PdmFieldHandle* changedFie m_branchIndex = RiaSimWellBranchTools::clampBranchIndex( simWellName, m_branchIndex, m_branchDetection ); updateWellChannelNameAndTimeStep(); - this->loadDataAndUpdate( true ); + loadData = true; } else if ( changedField == &m_wellLogChannelName ) { - if ( m_wellLogChannelName == RifEclipseRftAddress::NONE ) + if ( m_wellLogChannelName == RifEclipseRftAddress::RftWellLogChannelType::NONE ) { m_timeStep = QDateTime(); } - this->loadDataAndUpdate( true ); + loadData = true; } - else if ( changedField == &m_timeStep ) + else if ( changedField == &m_timeStep || changedField == &m_segmentResultName || + changedField == &m_segmentBranchId || changedField == &m_rftDataType ) { - this->loadDataAndUpdate( true ); + loadData = true; } + + if ( loadData ) this->loadDataAndUpdate( true ); } //-------------------------------------------------------------------------------------------------- @@ -711,7 +827,9 @@ std::vector RimWellLogRftCurve::perPointLabels() const { if ( m_observedFmuRftData() ) { - RifEclipseRftAddress address( m_wellName(), m_timeStep, RifEclipseRftAddress::PRESSURE ); + auto address = RifEclipseRftAddress::createAddress( m_wellName(), + m_timeStep, + RifEclipseRftAddress::RftWellLogChannelType::PRESSURE ); return m_observedFmuRftData()->labels( address ); } return {}; @@ -726,18 +844,22 @@ RifReaderRftInterface* RimWellLogRftCurve::rftReader() const { return m_eclipseResultCase()->rftReader(); } - else if ( m_summaryCase() ) // Summary RFT curves have both summary and ensemble set. Prioritize summary for reader. + + if ( m_summaryCase() ) // Summary RFT curves have both summary and ensemble set. Prioritize summary for reader. { return m_summaryCase()->rftReader(); } - else if ( m_ensemble() ) + + if ( m_ensemble() ) { return m_ensemble()->rftStatisticsReader(); } - else if ( m_observedFmuRftData() ) + + if ( m_observedFmuRftData() ) { return m_observedFmuRftData()->rftReader(); } + return nullptr; } @@ -766,7 +888,7 @@ RigEclipseWellLogExtractor* RimWellLogRftCurve::extractor() QString simWellName = RimWellPlotTools::simWellName( m_wellName ); std::vector wellPaths = RiaSimWellBranchTools::simulationWellBranches( simWellName, m_branchDetection ); - if ( wellPaths.size() == 0 ) return nullptr; + if ( wellPaths.empty() ) return nullptr; m_branchIndex = RiaSimWellBranchTools::clampBranchIndex( simWellName, m_branchIndex, m_branchDetection ); @@ -805,12 +927,12 @@ bool RimWellLogRftCurve::createWellPathIdxToRftFileIdxMapping() globCellIndicesToIndexInWell[intersections[idx].globCellIndex] = idx; } - RifEclipseRftAddress depthAddress( m_wellName(), m_timeStep, RifEclipseRftAddress::TVD ); + RifEclipseRftAddress depthAddress = + RifEclipseRftAddress::createAddress( m_wellName(), m_timeStep, RifEclipseRftAddress::RftWellLogChannelType::TVD ); std::vector rftIndices; - RifReaderEclipseRft* eclipseRftReader = dynamic_cast( rftReader() ); - if ( !eclipseRftReader ) return false; + if ( !rftReader() ) return false; - eclipseRftReader->cellIndices( depthAddress, &rftIndices ); + rftReader()->cellIndices( depthAddress, &rftIndices ); const RigMainGrid* mainGrid = eclExtractor->caseData()->mainGrid(); @@ -857,9 +979,9 @@ std::vector RimWellLogRftCurve::sortedIndicesInRftFile() } std::vector indices; - for ( auto it = m_idxInWellPathToIdxInRftFile.begin(); it != m_idxInWellPathToIdxInRftFile.end(); it++ ) + for ( auto& it : m_idxInWellPathToIdxInRftFile ) { - indices.push_back( it->second ); + indices.push_back( it.second ); } return indices; @@ -875,7 +997,17 @@ std::vector RimWellLogRftCurve::xValues() if ( !reader ) return values; - RifEclipseRftAddress address( m_wellName(), m_timeStep, m_wellLogChannelName() ); + if ( m_rftDataType() == RftDataType::RFT_SEGMENT_DATA ) + { + auto depthAddress = + RifEclipseRftAddress::createSegmentAddress( m_wellName(), m_timeStep, m_segmentResultName(), segmentBranchId() ); + + reader->values( depthAddress, &values ); + + return values; + } + + auto address = RifEclipseRftAddress::createAddress( m_wellName(), m_timeStep, m_wellLogChannelName() ); reader->values( address, &values ); @@ -895,10 +1027,8 @@ std::vector RimWellLogRftCurve::xValues() return valuesSorted; } - else - { - return values; - } + + return values; } //-------------------------------------------------------------------------------------------------- @@ -909,11 +1039,15 @@ std::vector RimWellLogRftCurve::errorValues() RifReaderRftInterface* reader = rftReader(); std::vector errorValues; - if ( reader ) + if ( reader && m_rftDataType() == RftDataType::RFT_DATA ) { - RifEclipseRftAddress errorAddress( m_wellName(), m_timeStep, RifEclipseRftAddress::PRESSURE_ERROR ); + RifEclipseRftAddress errorAddress = + RifEclipseRftAddress::createAddress( m_wellName(), + m_timeStep, + RifEclipseRftAddress::RftWellLogChannelType::PRESSURE_ERROR ); reader->values( errorAddress, &errorValues ); } + return errorValues; } @@ -927,7 +1061,19 @@ std::vector RimWellLogRftCurve::tvDepthValues() if ( !reader ) return values; - RifEclipseRftAddress depthAddress( m_wellName(), m_timeStep, RifEclipseRftAddress::TVD ); + if ( m_rftDataType() == RftDataType::RFT_SEGMENT_DATA ) + { + auto depthAddress = RifEclipseRftAddress::createSegmentAddress( m_wellName(), + m_timeStep, + RiaDefines::segmentTvdDepthResultName(), + segmentBranchId() ); + + reader->values( depthAddress, &values ); + return values; + } + + auto depthAddress = + RifEclipseRftAddress::createAddress( m_wellName(), m_timeStep, RifEclipseRftAddress::RftWellLogChannelType::TVD ); reader->values( depthAddress, &values ); bool wellPathExists = createWellPathIdxToRftFileIdxMapping(); @@ -946,10 +1092,8 @@ std::vector RimWellLogRftCurve::tvDepthValues() return valuesSorted; } - else - { - return values; - } + + return values; } //-------------------------------------------------------------------------------------------------- @@ -957,6 +1101,29 @@ std::vector RimWellLogRftCurve::tvDepthValues() //-------------------------------------------------------------------------------------------------- std::vector RimWellLogRftCurve::measuredDepthValues() { + if ( m_rftDataType() == RftDataType::RFT_SEGMENT_DATA ) + { + std::vector values; + + RifReaderRftInterface* reader = rftReader(); + if ( reader ) + { + auto depthAddress = RifEclipseRftAddress::createSegmentAddress( m_wellName(), + m_timeStep, + RiaDefines::segmentStartDepthResultName(), + segmentBranchId() ); + + reader->values( depthAddress, &values ); + + // Special handling of first segment + if ( values.size() > 2 && values.front() < 0.001 ) + { + values[0] = values[1]; + } + } + return values; + } + if ( m_observedFmuRftData && !m_ensemble && !m_summaryCase ) { RifReaderRftInterface* reader = rftReader(); @@ -964,7 +1131,8 @@ std::vector RimWellLogRftCurve::measuredDepthValues() if ( !reader ) return values; - RifEclipseRftAddress depthAddress( m_wellName(), m_timeStep, RifEclipseRftAddress::MD ); + RifEclipseRftAddress depthAddress = + RifEclipseRftAddress::createAddress( m_wellName(), m_timeStep, RifEclipseRftAddress::RftWellLogChannelType::MD ); reader->values( depthAddress, &values ); return values; } @@ -1013,7 +1181,7 @@ bool RimWellLogRftCurve::deriveMeasuredDepthValuesFromWellPath( const std::vecto RimProject* proj = RimProject::current(); RimWellPath* wellPath = proj->wellPathByName( m_wellName ); - if ( wellPath ) + if ( wellPath && wellPath->wellPathGeometry() ) { const std::vector& mdValuesOfWellPath = wellPath->wellPathGeometry()->measuredDepths(); const std::vector& tvdValuesOfWellPath = wellPath->wellPathGeometry()->trueVerticalDepths(); @@ -1040,8 +1208,14 @@ bool RimWellLogRftCurve::deriveMeasuredDepthFromObservedData( const std::vector< std::vector tvdValuesOfObservedData; std::vector mdValuesOfObservedData; - RifEclipseRftAddress tvdAddress( m_wellName(), m_timeStep, RifEclipseRftAddress::TVD ); - RifEclipseRftAddress mdAddress( m_wellName(), m_timeStep, RifEclipseRftAddress::MD ); + RifEclipseRftAddress tvdAddress = + RifEclipseRftAddress::createAddress( m_wellName(), + m_timeStep, + RifEclipseRftAddress::RftWellLogChannelType::TVD ); + RifEclipseRftAddress mdAddress = + RifEclipseRftAddress::createAddress( m_wellName(), + m_timeStep, + RifEclipseRftAddress::RftWellLogChannelType::MD ); reader->values( tvdAddress, &tvdValuesOfObservedData ); reader->values( mdAddress, &mdValuesOfObservedData ); @@ -1058,3 +1232,11 @@ bool RimWellLogRftCurve::deriveMeasuredDepthFromObservedData( const std::vector< } return false; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimWellLogRftCurve::segmentBranchId() const +{ + return m_segmentBranchId(); +} diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurve.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurve.h index fc37b7b697..73ddae2aee 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurve.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurve.h @@ -28,6 +28,7 @@ #include "cvfObject.h" +#include #include class RifReaderRftInterface; @@ -47,10 +48,18 @@ class RimWellLogRftCurve : public RimWellLogCurve CAF_PDM_HEADER_INIT; public: - enum DerivedMDSource + enum class RftDataType + { + RFT_DATA, + RFT_SEGMENT_DATA + }; + +private: + enum class DerivedMDSource { NO_SOURCE, WELL_PATH, + SEGMENT, OBSERVED_DATA }; @@ -58,10 +67,17 @@ class RimWellLogRftCurve : public RimWellLogCurve RimWellLogRftCurve(); ~RimWellLogRftCurve() override; + void setWellName( const QString& wellName ); QString wellName() const override; + QString wellLogChannelUiName() const override; QString wellLogChannelUnits() const override; + void setTimeStep( const QDateTime& dateTime ); + QDateTime timeStep() const; + + void setSegmentBranchId( int branchId ); + void setEclipseResultCase( RimEclipseResultCase* eclipseResultCase ); RimEclipseResultCase* eclipseResultCase() const; @@ -78,19 +94,18 @@ class RimWellLogRftCurve : public RimWellLogCurve RifEclipseRftAddress rftAddress() const; void setDefaultAddress( QString wellName ); - void updateWellChannelNameAndTimeStep(); void setSimWellBranchData( bool branchDetection, int branchIndex ); protected: // Overrides from RimWellLogPlotCurve - QString createCurveAutoName() override; - void onLoadDataAndUpdate( bool updateParentPlot ) override; + QString createCurveAutoName() override; + void onLoadDataAndUpdate( bool updateParentPlot ) override; + RiaDefines::PhaseType phaseType() const override; // Pdm overrrides void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; std::vector perPointLabels() const; @@ -103,6 +118,7 @@ class RimWellLogRftCurve : public RimWellLogCurve bool createWellPathIdxToRftFileIdxMapping(); size_t rftFileIndex( size_t wellPathIndex ); std::vector sortedIndicesInRftFile(); + void updateWellChannelNameAndTimeStep(); std::vector xValues(); std::vector errorValues(); @@ -114,6 +130,8 @@ class RimWellLogRftCurve : public RimWellLogCurve bool deriveMeasuredDepthFromObservedData( const std::vector& tvDepthValues, std::vector& derivedMDValues ); + int segmentBranchId() const; + private: caf::PdmPtrField m_eclipseResultCase; caf::PdmPtrField m_summaryCase; @@ -124,6 +142,11 @@ class RimWellLogRftCurve : public RimWellLogCurve caf::PdmField m_branchIndex; caf::PdmField m_branchDetection; + caf::PdmField> m_rftDataType; + + caf::PdmField m_segmentResultName; + caf::PdmField m_segmentBranchId; + std::map m_idxInWellPathToIdxInRftFile; caf::PdmField> m_wellLogChannelName; }; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurveNameConfig.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurveNameConfig.cpp index cabb7ceeab..338885cab1 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurveNameConfig.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurveNameConfig.cpp @@ -31,7 +31,7 @@ CAF_PDM_SOURCE_INIT( RimWellLogRftCurveNameConfig, "RimWellLogRftCurveNameConfig RimWellLogRftCurveNameConfig::RimWellLogRftCurveNameConfig() : RimNameConfig( "Rft Curve" ) { - CAF_PDM_InitObject( "Well Log Rft Curve Name Generator", "", "", "" ); + CAF_PDM_InitObject( "Well Log Rft Curve Name Generator" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogTrack.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogTrack.cpp index 9b8eac313d..0fc0aa01c5 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogTrack.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogTrack.cpp @@ -23,6 +23,7 @@ #include "RiaExtractionTools.h" #include "RiaGuiApplication.h" #include "RiaLogging.h" +#include "RiaPlotDefines.h" #include "RiaPreferences.h" #include "RiaSimWellBranchTools.h" #include "RiaWellLogCurveMerger.h" @@ -77,6 +78,7 @@ #include "RiuMainWindow.h" #include "RiuPlotAnnotationTool.h" +#include "RiuPlotAxis.h" #include "RiuPlotMainWindow.h" #include "RiuPlotMainWindowTools.h" #include "RiuQwtLinearScaleEngine.h" @@ -87,11 +89,15 @@ #include "cafPdmFieldReorderCapability.h" #include "cafPdmFieldScriptingCapability.h" #include "cafPdmObjectScriptingCapability.h" +#include "cafPdmUiDoubleValueEditor.h" #include "cafPdmUiSliderEditor.h" #include "cafSelectionManager.h" +#include "caf.h" #include "cvfAssert.h" +#include "qwt_scale_map.h" + #include #include @@ -117,9 +123,9 @@ void AppEnum::setUp() template <> void AppEnum::setUp() { - addItem( RimWellLogTrack::CASE, "CASE", "Case" ); - addItem( RimWellLogTrack::WELL_PICK_FILTER, "WELL_PICK_FILTER", "Well Picks for Well Path" ); - setDefault( RimWellLogTrack::CASE ); + addItem( RimWellLogTrack::FormationSource::CASE, "CASE", "Case" ); + addItem( RimWellLogTrack::FormationSource::WELL_PICK_FILTER, "WELL_PICK_FILTER", "Well Picks for Well Path" ); + setDefault( RimWellLogTrack::FormationSource::CASE ); } template <> @@ -168,79 +174,78 @@ void AppEnum::setUp() /// //-------------------------------------------------------------------------------------------------- RimWellLogTrack::RimWellLogTrack() - : m_availableXRangeMin( RI_LOGPLOTTRACK_MINX_DEFAULT ) - , m_availableXRangeMax( RI_LOGPLOTTRACK_MAXX_DEFAULT ) + : m_availablePropertyValueRangeMin( RI_LOGPLOTTRACK_MINX_DEFAULT ) + , m_availablePropertyValueRangeMax( RI_LOGPLOTTRACK_MAXX_DEFAULT ) , m_availableDepthRangeMin( RI_LOGPLOTTRACK_MINX_DEFAULT ) , m_availableDepthRangeMax( RI_LOGPLOTTRACK_MAXX_DEFAULT ) { - CAF_PDM_InitScriptableObject( "Track", ":/WellLogTrack16x16.png", "", "" ); + CAF_PDM_InitScriptableObject( "Track", ":/WellLogTrack16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_description, "TrackDescription", "Name", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_description, "TrackDescription", "Name" ); m_description.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitFieldNoDefault( &m_curves, "Curves", "", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_curves, "Curves", "" ); m_curves.uiCapability()->setUiTreeHidden( true ); auto reorderability = caf::PdmFieldReorderCapability::addToField( &m_curves ); reorderability->orderChanged.connect( this, &RimWellLogTrack::curveDataChanged ); - CAF_PDM_InitField( &m_visibleXRangeMin, "VisibleXRangeMin", RI_LOGPLOTTRACK_MINX_DEFAULT, "Min", "", "", "" ); - CAF_PDM_InitField( &m_visibleXRangeMax, "VisibleXRangeMax", RI_LOGPLOTTRACK_MAXX_DEFAULT, "Max", "", "", "" ); - CAF_PDM_InitField( &m_visibleDepthRangeMin, "VisibleYRangeMin", RI_LOGPLOTTRACK_MINX_DEFAULT, "Min", "", "", "" ); - CAF_PDM_InitField( &m_visibleDepthRangeMax, "VisibleYRangeMax", RI_LOGPLOTTRACK_MAXX_DEFAULT, "Max", "", "", "" ); + CAF_PDM_InitField( &m_visiblePropertyValueRangeMin, "VisibleXRangeMin", RI_LOGPLOTTRACK_MINX_DEFAULT, "Min" ); + m_visiblePropertyValueRangeMin.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); + CAF_PDM_InitField( &m_visiblePropertyValueRangeMax, "VisibleXRangeMax", RI_LOGPLOTTRACK_MAXX_DEFAULT, "Max" ); + m_visiblePropertyValueRangeMax.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); + + CAF_PDM_InitField( &m_visibleDepthRangeMin, "VisibleYRangeMin", RI_LOGPLOTTRACK_MINX_DEFAULT, "Min" ); + CAF_PDM_InitField( &m_visibleDepthRangeMax, "VisibleYRangeMax", RI_LOGPLOTTRACK_MAXX_DEFAULT, "Max" ); m_visibleDepthRangeMin.uiCapability()->setUiHidden( true ); m_visibleDepthRangeMin.xmlCapability()->disableIO(); m_visibleDepthRangeMax.uiCapability()->setUiHidden( true ); m_visibleDepthRangeMax.xmlCapability()->disableIO(); - CAF_PDM_InitField( &m_isAutoScaleXEnabled, "AutoScaleX", true, "Auto Scale", "", "", "" ); - m_isAutoScaleXEnabled.uiCapability()->setUiHidden( true ); + CAF_PDM_InitField( &m_isAutoScalePropertyValuesEnabled, "AutoScaleX", true, "Auto Scale" ); + m_isAutoScalePropertyValuesEnabled.uiCapability()->setUiHidden( true ); - CAF_PDM_InitField( &m_isLogarithmicScaleEnabled, "LogarithmicScaleX", false, "Logarithmic Scale", "", "", "" ); + CAF_PDM_InitField( &m_isLogarithmicScaleEnabled, "LogarithmicScaleX", false, "Logarithmic Scale" ); + CAF_PDM_InitField( &m_invertPropertyValueAxis, "InvertPropertyValueAxis", false, "Invert Axis Range" ); - CAF_PDM_InitFieldNoDefault( &m_xAxisGridVisibility, "ShowXGridLines", "Show Grid Lines", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_propertyValueAxisGridVisibility, "ShowXGridLines", "Show Grid Lines" ); - CAF_PDM_InitField( &m_explicitTickIntervals, "ExplicitTickIntervals", false, "Manually Set Tick Intervals", "", "", "" ); - CAF_PDM_InitField( &m_minAndMaxTicksOnly, "MinAndMaxTicksOnly", false, "Show Ticks at Min and Max", "", "", "" ); - CAF_PDM_InitField( &m_majorTickInterval, "MajorTickIntervals", 0.0, "Major Tick Interval", "", "", "" ); - CAF_PDM_InitField( &m_minorTickInterval, "MinorTickIntervals", 0.0, "Minor Tick Interval", "", "", "" ); + CAF_PDM_InitField( &m_explicitTickIntervals, "ExplicitTickIntervals", false, "Manually Set Tick Intervals" ); + CAF_PDM_InitField( &m_minAndMaxTicksOnly, "MinAndMaxTicksOnly", false, "Show Ticks at Min and Max" ); + CAF_PDM_InitField( &m_majorTickInterval, "MajorTickIntervals", 0.0, "Major Tick Interval" ); + CAF_PDM_InitField( &m_minorTickInterval, "MinorTickIntervals", 0.0, "Minor Tick Interval" ); m_majorTickInterval.uiCapability()->setUiHidden( true ); m_minorTickInterval.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_axisFontSize, "AxisFontSize", "Axis Font Size", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_axisFontSize, "AxisFontSize", "Axis Font Size" ); - CAF_PDM_InitFieldNoDefault( &m_regionAnnotationType, "AnnotationType", "Region Annotations", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_regionAnnotationDisplay, "RegionDisplay", "Region Display", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_regionAnnotationType, "AnnotationType", "Region Annotations" ); + CAF_PDM_InitFieldNoDefault( &m_regionAnnotationDisplay, "RegionDisplay", "Region Display" ); - CAF_PDM_InitFieldNoDefault( &m_colorShadingLegend, "ColorShadingLegend", "Colors", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_colorShadingLegend, "ColorShadingLegend", "Colors" ); m_colorShadingLegend = RimRegularLegendConfig::mapToColorLegend( RimRegularLegendConfig::ColorRangesType::NORMAL ); - CAF_PDM_InitField( &m_colorShadingTransparency, "ColorShadingTransparency", 50, "Color Transparency", "", "", "" ); + CAF_PDM_InitField( &m_colorShadingTransparency, "ColorShadingTransparency", 50, "Color Transparency" ); m_colorShadingTransparency.uiCapability()->setUiEditorTypeName( caf::PdmUiSliderEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_showRegionLabels, "ShowFormationLabels", true, "Show Labels", "", "", "" ); + CAF_PDM_InitField( &m_showRegionLabels, "ShowFormationLabels", true, "Show Labels" ); caf::FontTools::RelativeSizeEnum regionLabelFontSizeDefault = caf::FontTools::RelativeSize::XSmall; - CAF_PDM_InitField( &m_regionLabelFontSize, "RegionLabelFontSize", regionLabelFontSizeDefault, "Font Size", "", "", "" ); + CAF_PDM_InitField( &m_regionLabelFontSize, "RegionLabelFontSize", regionLabelFontSizeDefault, "Font Size" ); - CAF_PDM_InitFieldNoDefault( &m_formationSource, "FormationSource", "Source", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_formationSource, "FormationSource", "Source" ); - CAF_PDM_InitFieldNoDefault( &m_formationTrajectoryType, "FormationTrajectoryType", "Trajectory", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_formationTrajectoryType, "FormationTrajectoryType", "Trajectory" ); - CAF_PDM_InitFieldNoDefault( &m_formationWellPathForSourceCase, "FormationWellPath", "Well Path", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_formationWellPathForSourceCase, "FormationWellPath", "Well Path" ); m_formationWellPathForSourceCase.uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_formationWellPathForSourceWellPath, - "FormationWellPathForSourceWellPath", - "Well Path", - "", - "", - "" ); + CAF_PDM_InitFieldNoDefault( &m_formationWellPathForSourceWellPath, "FormationWellPathForSourceWellPath", "Well Path" ); m_formationWellPathForSourceWellPath.uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitField( &m_formationSimWellName, "FormationSimulationWellName", QString( "None" ), "Simulation Well", "", "", "" ); - CAF_PDM_InitField( &m_formationBranchIndex, "FormationBranchIndex", 0, " ", "", "", "" ); + CAF_PDM_InitField( &m_formationSimWellName, "FormationSimulationWellName", QString( "None" ), "Simulation Well" ); + CAF_PDM_InitField( &m_formationBranchIndex, "FormationBranchIndex", 0, " " ); CAF_PDM_InitField( &m_formationBranchDetection, "FormationBranchDetection", true, @@ -249,38 +254,33 @@ RimWellLogTrack::RimWellLogTrack() "Compute branches based on how simulation well cells are organized", "" ); - CAF_PDM_InitFieldNoDefault( &m_formationCase, "FormationCase", "Formation Case", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_formationCase, "FormationCase", "Formation Case" ); m_formationCase.uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_formationLevel, "FormationLevel", "Well Pick Filter", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_formationLevel, "FormationLevel", "Well Pick Filter" ); - CAF_PDM_InitField( &m_showformationFluids, "ShowFormationFluids", false, "Show Fluids", "", "", "" ); + CAF_PDM_InitField( &m_showformationFluids, "ShowFormationFluids", false, "Show Fluids" ); - CAF_PDM_InitField( &m_showWellPathAttributes, "ShowWellPathAttributes", false, "Show Well Attributes", "", "", "" ); - CAF_PDM_InitField( &m_wellPathAttributesInLegend, "WellPathAttributesInLegend", true, "Attributes in Legend", "", "", "" ); - CAF_PDM_InitField( &m_showWellPathCompletions, "ShowWellPathCompletions", true, "Show Well Completions", "", "", "" ); - CAF_PDM_InitField( &m_wellPathCompletionsInLegend, "WellPathCompletionsInLegend", true, "Completions in Legend", "", "", "" ); - CAF_PDM_InitField( &m_showWellPathComponentsBothSides, "ShowWellPathAttrBothSides", true, "Show Both Sides", "", "", "" ); - CAF_PDM_InitField( &m_showWellPathComponentLabels, "ShowWellPathAttrLabels", false, "Show Labels", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_wellPathComponentSource, "AttributesWellPathSource", "Well Path", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_wellPathAttributeCollection, "AttributesCollection", "Well Attributes", "", "", "" ); + CAF_PDM_InitField( &m_showWellPathAttributes, "ShowWellPathAttributes", false, "Show Well Attributes" ); + CAF_PDM_InitField( &m_wellPathAttributesInLegend, "WellPathAttributesInLegend", true, "Attributes in Legend" ); + CAF_PDM_InitField( &m_showWellPathCompletions, "ShowWellPathCompletions", true, "Show Well Completions" ); + CAF_PDM_InitField( &m_wellPathCompletionsInLegend, "WellPathCompletionsInLegend", true, "Completions in Legend" ); + CAF_PDM_InitField( &m_showWellPathComponentsBothSides, "ShowWellPathAttrBothSides", true, "Show Both Sides" ); + CAF_PDM_InitField( &m_showWellPathComponentLabels, "ShowWellPathAttrLabels", false, "Show Labels" ); + CAF_PDM_InitFieldNoDefault( &m_wellPathComponentSource, "AttributesWellPathSource", "Well Path" ); + CAF_PDM_InitFieldNoDefault( &m_wellPathAttributeCollection, "AttributesCollection", "Well Attributes" ); - CAF_PDM_InitField( &m_overburdenHeight, "OverburdenHeight", 0.0, "Overburden Height", "", "", "" ); + CAF_PDM_InitField( &m_overburdenHeight, "OverburdenHeight", 0.0, "Overburden Height" ); m_overburdenHeight.uiCapability()->setUiHidden( true ); - CAF_PDM_InitField( &m_underburdenHeight, "UnderburdenHeight", 0.0, "Underburden Height", "", "", "" ); + CAF_PDM_InitField( &m_underburdenHeight, "UnderburdenHeight", 0.0, "Underburden Height" ); m_underburdenHeight.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_resultDefinition, "ResultDefinition", "Result Definition", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_resultDefinition, "ResultDefinition", "Result Definition" ); m_resultDefinition.uiCapability()->setUiTreeHidden( true ); m_resultDefinition.uiCapability()->setUiTreeChildrenHidden( true ); m_resultDefinition = new RimEclipseResultDefinition; - CAF_PDM_InitFieldNoDefault( &m_ensembleWellLogCurveSet, - "EnsembleWellLogCurveSet", - "Ensemble Well Logs Curve Set", - "", - "", - "" ); + CAF_PDM_InitFieldNoDefault( &m_ensembleWellLogCurveSet, "EnsembleWellLogCurveSet", "Ensemble Well Logs Curve Set" ); m_ensembleWellLogCurveSet.uiCapability()->setUiTreeHidden( true ); m_formationsForCaseWithSimWellOnly = false; @@ -291,7 +291,7 @@ RimWellLogTrack::RimWellLogTrack() //-------------------------------------------------------------------------------------------------- RimWellLogTrack::~RimWellLogTrack() { - m_curves.deleteAllChildObjects(); + m_curves.deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -354,7 +354,7 @@ void RimWellLogTrack::detachAllPlotItems() { for ( RimPlotCurve* curve : m_curves ) { - curve->detachQwtCurve(); + curve->detach(); } for ( auto& plotObjects : m_wellPathAttributePlotObjects ) { @@ -365,7 +365,7 @@ void RimWellLogTrack::detachAllPlotItems() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogTrack::calculateXZoomRange() +void RimWellLogTrack::calculatePropertyValueZoomRange() { updateStackedCurveData(); @@ -381,7 +381,7 @@ void RimWellLogTrack::calculateXZoomRange() if ( curve->isCurveVisible() ) { visibleCurves++; - if ( curve->xValueRangeInData( &minCurveValue, &maxCurveValue ) ) + if ( curve->propertyValueRangeInData( &minCurveValue, &maxCurveValue ) ) { if ( minCurveValue < minValue ) { @@ -406,15 +406,23 @@ void RimWellLogTrack::calculateXZoomRange() { std::tie( minValue, maxValue ) = adjustXRange( minValue, maxValue, m_minorTickInterval() ); } + else + { + double adjustmentFactor = 0.1; + auto [adjustedMin, adjustedMax] = extendMinMaxRange( minValue, maxValue, adjustmentFactor ); - m_availableXRangeMin = minValue; - m_availableXRangeMax = maxValue; + minValue = adjustedMin; + maxValue = adjustedMax; + } + + m_availablePropertyValueRangeMin = minValue; + m_availablePropertyValueRangeMax = maxValue; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogTrack::calculateYZoomRange() +void RimWellLogTrack::calculateDepthZoomRange() { double minDepth = HUGE_VAL; double maxDepth = -HUGE_VAL; @@ -424,7 +432,7 @@ void RimWellLogTrack::calculateYZoomRange() double minCurveDepth = HUGE_VAL; double maxCurveDepth = -HUGE_VAL; - if ( curve->isCurveVisible() && curve->yValueRangeInData( &minCurveDepth, &maxCurveDepth ) ) + if ( curve->isCurveVisible() && curve->depthValueRangeInData( &minCurveDepth, &maxCurveDepth ) ) { if ( minCurveDepth < minDepth ) { @@ -459,35 +467,38 @@ void RimWellLogTrack::calculateYZoomRange() } } - m_availableDepthRangeMin = minDepth; - m_availableDepthRangeMax = maxDepth; + double adjustmentFactor = 0.02; + auto [adjustedMin, adjustedMax] = extendMinMaxRange( minDepth, maxDepth, adjustmentFactor ); + + m_availableDepthRangeMin = adjustedMin; + m_availableDepthRangeMax = adjustedMax; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogTrack::updateXZoom() +void RimWellLogTrack::updatePropertyValueZoom() { if ( !m_plotWidget ) return; - calculateXZoomRange(); + calculatePropertyValueZoomRange(); - if ( m_isAutoScaleXEnabled ) + if ( m_isAutoScalePropertyValuesEnabled ) { - m_visibleXRangeMin = m_availableXRangeMin; - m_visibleXRangeMax = m_availableXRangeMax; + m_visiblePropertyValueRangeMin = m_availablePropertyValueRangeMin; + m_visiblePropertyValueRangeMax = m_availablePropertyValueRangeMax; if ( !visibleStackedCurves().empty() && !m_isLogarithmicScaleEnabled ) { // Try to ensure we include the base line whether the values are negative or positive. - m_visibleXRangeMin = std::min( m_visibleXRangeMin(), 0.0 ); - m_visibleXRangeMax = std::max( m_visibleXRangeMax(), 0.0 ); + m_visiblePropertyValueRangeMin = std::min( m_visiblePropertyValueRangeMin(), 0.0 ); + m_visiblePropertyValueRangeMax = std::max( m_visiblePropertyValueRangeMax(), 0.0 ); } - computeAndSetXRangeMinForLogarithmicScale(); + computeAndSetPropertyValueRangeMinForLogarithmicScale(); updateEditors(); } - updateXAxisAndGridTickIntervals(); + updatePropertyValueAxisAndGridTickIntervals(); // Attribute range. Fixed range where well components are positioned [-1, 1]. // Set an extended range here to allow for some label space. @@ -503,17 +514,39 @@ void RimWellLogTrack::updateXZoom() componentRangeMax *= 1.5; } - m_plotWidget->setAxisRange( QwtPlot::xBottom, componentRangeMin, componentRangeMax ); + RimDepthTrackPlot* wellLogPlot; + this->firstAncestorOrThisOfTypeAsserted( wellLogPlot ); + + // Attribute components use the opposite axis to the property values + if ( wellLogPlot->depthOrientation() == RimDepthTrackPlot::DepthOrientation::VERTICAL ) + { + m_plotWidget->setAxisRange( RiuPlotAxis::defaultBottom(), componentRangeMin, componentRangeMax ); + } + else if ( wellLogPlot->depthOrientation() == RimDepthTrackPlot::DepthOrientation::VERTICAL ) + { + m_plotWidget->setAxisRange( RiuPlotAxis::defaultRight(), componentRangeMin, componentRangeMax ); + } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogTrack::updateYZoom() +void RimWellLogTrack::updateDepthZoom() { if ( !m_plotWidget ) return; - m_plotWidget->setAxisRange( QwtPlot::yLeft, m_visibleDepthRangeMin(), m_visibleDepthRangeMax() ); + RimDepthTrackPlot* wellLogPlot; + this->firstAncestorOrThisOfTypeAsserted( wellLogPlot ); + + if ( wellLogPlot->depthOrientation() == RimDepthTrackPlot::DepthOrientation::VERTICAL ) + { + m_plotWidget->setAxisRange( depthAxis(), m_visibleDepthRangeMin(), m_visibleDepthRangeMax() ); + } + else + { + m_plotWidget->setAxisRange( RiuPlotAxis::defaultTop(), m_visibleDepthRangeMin(), m_visibleDepthRangeMax() ); + m_plotWidget->setAxisRange( RiuPlotAxis::defaultBottom(), m_visibleDepthRangeMin(), m_visibleDepthRangeMax() ); + } } //-------------------------------------------------------------------------------------------------- @@ -550,39 +583,40 @@ void RimWellLogTrack::fieldChangedByUi( const caf::PdmFieldHandle* changedField, { if ( m_plotWidget ) { - m_majorTickInterval = m_plotWidget->majorTickInterval( QwtPlot::xTop ); - m_minorTickInterval = m_plotWidget->minorTickInterval( QwtPlot::xTop ); + m_majorTickInterval = m_plotWidget->majorTickInterval( valueAxis() ); + m_minorTickInterval = m_plotWidget->minorTickInterval( valueAxis() ); } m_majorTickInterval.uiCapability()->setUiHidden( !m_explicitTickIntervals() ); m_minorTickInterval.uiCapability()->setUiHidden( !m_explicitTickIntervals() ); if ( !m_explicitTickIntervals() ) { - updateXAxisAndGridTickIntervals(); + updatePropertyValueAxisAndGridTickIntervals(); } } - else if ( changedField == &m_xAxisGridVisibility || changedField == &m_majorTickInterval || - changedField == &m_minorTickInterval || changedField == &m_minAndMaxTicksOnly ) + else if ( changedField == &m_propertyValueAxisGridVisibility || changedField == &m_majorTickInterval || + changedField == &m_minorTickInterval || changedField == &m_minAndMaxTicksOnly || + changedField == &m_invertPropertyValueAxis ) { - updateXAxisAndGridTickIntervals(); + updatePropertyValueAxisAndGridTickIntervals(); } - else if ( changedField == &m_visibleXRangeMin || changedField == &m_visibleXRangeMax ) + else if ( changedField == &m_visiblePropertyValueRangeMin || changedField == &m_visiblePropertyValueRangeMax ) { - bool emptyRange = isEmptyVisibleXRange(); + bool emptyRange = isEmptyVisiblePropertyRange(); m_explicitTickIntervals.uiCapability()->setUiReadOnly( emptyRange ); - m_xAxisGridVisibility.uiCapability()->setUiReadOnly( emptyRange ); + m_propertyValueAxisGridVisibility.uiCapability()->setUiReadOnly( emptyRange ); - m_isAutoScaleXEnabled = false; + m_isAutoScalePropertyValuesEnabled = false; - updateXZoom(); + updatePropertyValueZoom(); m_plotWidget->scheduleReplot(); updateEditors(); } - else if ( changedField == &m_isAutoScaleXEnabled ) + else if ( changedField == &m_isAutoScalePropertyValuesEnabled ) { - if ( m_isAutoScaleXEnabled() ) + if ( m_isAutoScalePropertyValuesEnabled() ) { - updateXZoom(); + updatePropertyValueZoom(); m_plotWidget->scheduleReplot(); } } @@ -595,14 +629,14 @@ void RimWellLogTrack::fieldChangedByUi( const caf::PdmFieldHandle* changedField, } m_explicitTickIntervals.uiCapability()->setUiHidden( m_isLogarithmicScaleEnabled() ); - updateXZoom(); + updatePropertyValueZoom(); loadDataAndUpdate(); } else if ( changedField == &m_regionAnnotationType || changedField == &m_regionAnnotationDisplay || changedField == &m_formationSource || changedField == &m_colorShadingTransparency || changedField == &m_colorShadingLegend ) { - if ( changedField == &m_formationSource && m_formationSource == WELL_PICK_FILTER ) + if ( changedField == &m_formationSource && m_formationSource == FormationSource::WELL_PICK_FILTER ) { std::vector wellPaths; RimTools::wellPathWithFormations( &wellPaths ); @@ -757,28 +791,33 @@ void RimWellLogTrack::curveStackingChanged( const caf::SignalEmitter* emitter, b { updateStackedCurveData(); - m_isAutoScaleXEnabled = true; - updateXZoom(); + m_isAutoScalePropertyValuesEnabled = true; + updatePropertyValueZoom(); m_plotWidget->scheduleReplot(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogTrack::updateXAxisAndGridTickIntervals() +void RimWellLogTrack::updatePropertyValueAxisAndGridTickIntervals() { if ( !m_plotWidget ) return; - bool emptyRange = isEmptyVisibleXRange(); + bool emptyRange = isEmptyVisiblePropertyRange(); if ( emptyRange ) { - m_plotWidget->enableGridLines( QwtPlot::xTop, false, false ); - m_plotWidget->setAxisRange( QwtPlot::xTop, 0.0, 1.0 ); - m_plotWidget->setAxisLabelsAndTicksEnabled( QwtPlot::xTop, false, false ); + m_plotWidget->enableGridLines( valueAxis(), false, false ); + m_plotWidget->setAxisRange( valueAxis(), 0.0, 1.0 ); + m_plotWidget->setAxisLabelsAndTicksEnabled( valueAxis(), false, false ); } else { - m_plotWidget->setAxisLabelsAndTicksEnabled( QwtPlot::xTop, true, true ); + m_plotWidget->setAxisLabelsAndTicksEnabled( valueAxis(), true, true ); + + auto rangeBoundaryA = m_visiblePropertyValueRangeMin(); + auto rangeBoundaryB = m_visiblePropertyValueRangeMax(); + if ( m_invertPropertyValueAxis() ) std::swap( rangeBoundaryA, rangeBoundaryB ); + if ( m_minAndMaxTicksOnly ) { auto roundToDigits = []( double value, int numberOfDigits, bool useFloor ) { @@ -796,16 +835,16 @@ void RimWellLogTrack::updateXAxisAndGridTickIntervals() return std::ceil( value * factor ) / factor; }; - auto div = QwtScaleDiv( m_visibleXRangeMin(), m_visibleXRangeMax() ); + auto div = QwtScaleDiv( rangeBoundaryA, rangeBoundaryB ); QList majorTicks; - auto min = roundToDigits( m_visibleXRangeMin(), 2, false ); - auto max = roundToDigits( m_visibleXRangeMax(), 2, true ); + auto min = roundToDigits( rangeBoundaryA, 2, false ); + auto max = roundToDigits( rangeBoundaryB, 2, true ); if ( min == max ) { - min = roundToDigits( m_visibleXRangeMin(), 3, false ); - max = roundToDigits( m_visibleXRangeMax(), 3, true ); + min = roundToDigits( rangeBoundaryA, 3, false ); + max = roundToDigits( rangeBoundaryB, 3, true ); } majorTicks.push_back( min ); @@ -813,34 +852,43 @@ void RimWellLogTrack::updateXAxisAndGridTickIntervals() div.setTicks( QwtScaleDiv::TickType::MajorTick, majorTicks ); - m_plotWidget->setAxisScaleDiv( QwtPlot::xTop, div ); + RimDepthTrackPlot* wellLogPlot; + this->firstAncestorOrThisOfTypeAsserted( wellLogPlot ); + if ( wellLogPlot->depthOrientation() == RimDepthTrackPlot::DepthOrientation::VERTICAL ) + { + m_plotWidget->qwtPlot()->setAxisScaleDiv( QwtAxis::XTop, div ); + } + else + { + m_plotWidget->qwtPlot()->setAxisScaleDiv( QwtAxis::YLeft, div ); + } } else if ( m_explicitTickIntervals ) { - m_plotWidget->setMajorAndMinorTickIntervals( QwtPlot::xTop, + m_plotWidget->setMajorAndMinorTickIntervals( valueAxis(), m_majorTickInterval(), m_minorTickInterval(), - m_visibleXRangeMin(), - m_visibleXRangeMax() ); + rangeBoundaryA, + rangeBoundaryB ); } else { int majorTickIntervals = 5; int minorTickIntervals = 10; - m_plotWidget->setAutoTickIntervalCounts( QwtPlot::xTop, majorTickIntervals, minorTickIntervals ); - m_plotWidget->setAxisRange( QwtPlot::xTop, m_visibleXRangeMin, m_visibleXRangeMax ); + m_plotWidget->setAutoTickIntervalCounts( valueAxis(), majorTickIntervals, minorTickIntervals ); + m_plotWidget->setAxisRange( valueAxis(), rangeBoundaryA, rangeBoundaryB ); } - m_plotWidget->enableGridLines( QwtPlot::xTop, - m_xAxisGridVisibility() & RimWellLogPlot::AXIS_GRID_MAJOR, - m_xAxisGridVisibility() & RimWellLogPlot::AXIS_GRID_MINOR ); + m_plotWidget->enableGridLines( valueAxis(), + m_propertyValueAxisGridVisibility() & RimWellLogPlot::AXIS_GRID_MAJOR, + m_propertyValueAxisGridVisibility() & RimWellLogPlot::AXIS_GRID_MINOR ); } RimDepthTrackPlot* wellLogPlot = nullptr; this->firstAncestorOrThisOfType( wellLogPlot ); if ( wellLogPlot ) { - m_plotWidget->enableGridLines( QwtPlot::yLeft, + m_plotWidget->enableGridLines( depthAxis(), wellLogPlot->depthAxisGridLinesEnabled() & RimWellLogPlot::AXIS_GRID_MAJOR, wellLogPlot->depthAxisGridLinesEnabled() & RimWellLogPlot::AXIS_GRID_MINOR ); } @@ -895,10 +943,10 @@ QString RimWellLogTrack::asciiDataForPlotExport() const if ( curveNames.size() == 1 ) { - curveDepths = curveData->depthPlotValues( depthType, depthUnit ); + curveDepths = curveData->depthValuesByIntervals( depthType, depthUnit ); } - std::vector xPlotValues = curveData->xPlotValues(); + std::vector xPlotValues = curveData->propertyValuesByIntervals(); if ( xPlotValues.empty() ) { curveNames.pop_back(); @@ -915,7 +963,7 @@ QString RimWellLogTrack::asciiDataForPlotExport() const foundNonMatchingDepths = true; } - std::vector depths = curveData->depthPlotValues( depthType, depthUnit ); + std::vector depths = curveData->depthValuesByIntervals( depthType, depthUnit ); curveMerger.addCurveData( depths, xPlotValues ); curvesPlotXValues.push_back( xPlotValues ); @@ -960,13 +1008,10 @@ QString RimWellLogTrack::asciiDataForPlotExport() const const std::vector& allDepths = curveMerger.allXValues(); curveDepths = allDepths; - for ( size_t depthIdx = 0; depthIdx < allDepths.size(); depthIdx++ ) + for ( size_t curveIdx = 0; curveIdx < curveMerger.curveCount(); ++curveIdx ) { - for ( size_t curveIdx = 0; curveIdx < curveMerger.curveCount(); ++curveIdx ) - { - const std::vector& curveValues = curveMerger.lookupYValuesForAllXValues( curveIdx ); - curvesPlotXValues.push_back( curveValues ); - } + const std::vector& curveValues = curveMerger.lookupYValuesForAllXValues( curveIdx ); + curvesPlotXValues.push_back( curveValues ); } } @@ -1014,30 +1059,23 @@ QString RimWellLogTrack::asciiDataForPlotExport() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogTrack::updateZoomFromQwt() +void RimWellLogTrack::updateZoomFromParentPlot() { - QwtInterval xInterval = m_plotWidget->axisRange( QwtPlot::xTop ); - QwtInterval depthInterval = m_plotWidget->axisRange( QwtPlot::yLeft ); + auto [xIntervalMin, xIntervalMax] = m_plotWidget->axisRange( valueAxis() ); + auto [depthIntervalMin, depthIntervalMax] = m_plotWidget->axisRange( depthAxis() ); - m_visibleXRangeMin = xInterval.minValue(); - m_visibleXRangeMax = xInterval.maxValue(); - m_visibleDepthRangeMin = depthInterval.minValue(); - m_visibleDepthRangeMax = depthInterval.maxValue(); + m_visiblePropertyValueRangeMin = xIntervalMin; + m_visiblePropertyValueRangeMax = xIntervalMax; + m_visibleDepthRangeMin = depthIntervalMin; + m_visibleDepthRangeMax = depthIntervalMax; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogTrack::onAxisSelected( int axis, bool toggle ) +void RimWellLogTrack::onAxisSelected( RiuPlotAxis axis, bool toggle ) { - if ( toggle ) - { - RiuPlotMainWindowTools::toggleItemInSelection( this ); - } - else - { - RiuPlotMainWindowTools::selectAsCurrentItem( this ); - } + RiuPlotMainWindowTools::selectOrToggleObject( this, toggle ); } //-------------------------------------------------------------------------------------------------- @@ -1045,14 +1083,13 @@ void RimWellLogTrack::onAxisSelected( int axis, bool toggle ) //-------------------------------------------------------------------------------------------------- void RimWellLogTrack::updateAxes() { - updateXZoom(); + updatePropertyValueZoom(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimWellLogTrack::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RimWellLogTrack::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; @@ -1130,7 +1167,7 @@ void RimWellLogTrack::addCurve( RimWellLogCurve* curve ) if ( m_plotWidget ) { - curve->setParentQwtPlotAndReplot( m_plotWidget ); + curve->setParentPlotAndReplot( m_plotWidget ); } } @@ -1151,7 +1188,7 @@ void RimWellLogTrack::insertCurve( RimWellLogCurve* curve, size_t index ) if ( m_plotWidget ) { - curve->setParentQwtPlotAndReplot( m_plotWidget ); + curve->setParentPlotAndReplot( m_plotWidget ); } } } @@ -1161,11 +1198,11 @@ void RimWellLogTrack::insertCurve( RimWellLogCurve* curve, size_t index ) //-------------------------------------------------------------------------------------------------- void RimWellLogTrack::removeCurve( RimWellLogCurve* curve ) { - size_t index = m_curves.index( curve ); + size_t index = m_curves.indexOf( curve ); if ( index < m_curves.size() ) { - m_curves[index]->detachQwtCurve(); - m_curves.removeChildObject( curve ); + m_curves[index]->detach(); + m_curves.removeChild( curve ); } } @@ -1174,17 +1211,17 @@ void RimWellLogTrack::removeCurve( RimWellLogCurve* curve ) //-------------------------------------------------------------------------------------------------- void RimWellLogTrack::deleteAllCurves() { - m_curves.deleteAllChildObjects(); + m_curves.deleteChildren(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogTrack::availableXAxisRange( double* minX, double* maxX ) +void RimWellLogTrack::availablePropertyValueRange( double* minX, double* maxX ) { - calculateXZoomRange(); - *minX = m_availableXRangeMin; - *maxX = m_availableXRangeMax; + calculatePropertyValueZoomRange(); + *minX = m_availablePropertyValueRangeMin; + *maxX = m_availablePropertyValueRangeMax; } //-------------------------------------------------------------------------------------------------- @@ -1192,7 +1229,7 @@ void RimWellLogTrack::availableXAxisRange( double* minX, double* maxX ) //-------------------------------------------------------------------------------------------------- void RimWellLogTrack::availableDepthRange( double* minimumDepth, double* maximumDepth ) { - calculateYZoomRange(); + calculateDepthZoomRange(); *minimumDepth = m_availableDepthRangeMin; *maximumDepth = m_availableDepthRangeMax; } @@ -1200,11 +1237,11 @@ void RimWellLogTrack::availableDepthRange( double* minimumDepth, double* maximum //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogTrack::visibleXAxisRange( double* minX, double* maxX ) +void RimWellLogTrack::visiblePropertyValueRange( double* minX, double* maxX ) { CAF_ASSERT( minX && maxX ); - *minX = m_visibleXRangeMin; - *maxX = m_visibleXRangeMax; + *minX = m_visiblePropertyValueRangeMin; + *maxX = m_visiblePropertyValueRangeMax; } //-------------------------------------------------------------------------------------------------- @@ -1220,10 +1257,22 @@ void RimWellLogTrack::visibleDepthRange( double* minDepth, double* maxDepth ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimWellLogTrack::isEmptyVisibleXRange() const +bool RimWellLogTrack::isEmptyVisiblePropertyRange() const { - return std::abs( m_visibleXRangeMax() - m_visibleXRangeMin ) < - 1.0e-6 * std::max( 1.0, std::max( m_visibleXRangeMax(), m_visibleXRangeMin() ) ); + return std::abs( m_visiblePropertyValueRangeMax() - m_visiblePropertyValueRangeMin ) < + 1.0e-6 * std::max( 1.0, std::max( m_visiblePropertyValueRangeMax(), m_visiblePropertyValueRangeMin() ) ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogTrack::onChildrenUpdated( caf::PdmChildArrayFieldHandle* childArray, + std::vector& updatedObjects ) +{ + if ( childArray == &m_curves ) + { + loadDataAndUpdate(); + } } //-------------------------------------------------------------------------------------------------- @@ -1236,8 +1285,19 @@ void RimWellLogTrack::onLoadDataAndUpdate() if ( wellLogPlot && m_plotWidget ) { - m_plotWidget->setAxisTitleText( QwtPlot::xTop, m_xAxisTitle ); - m_plotWidget->setAxisTitleText( QwtPlot::yLeft, wellLogPlot->depthAxisTitle() ); + m_plotWidget->setAxisTitleText( valueAxis(), m_propertyValueAxisTitle ); + m_plotWidget->setAxisTitleText( depthAxis(), wellLogPlot->depthAxisTitle() ); + + if ( wellLogPlot->depthOrientation() == RimDepthTrackPlot::DepthOrientation::VERTICAL ) + { + m_plotWidget->setAxisEnabled( QwtAxis::XTop, true ); + m_plotWidget->setAxisEnabled( QwtAxis::XBottom, false ); + } + else + { + m_plotWidget->setAxisEnabled( QwtAxis::XTop, false ); + m_plotWidget->setAxisEnabled( QwtAxis::XBottom, true ); + } } for ( size_t cIdx = 0; cIdx < m_curves.size(); ++cIdx ) @@ -1267,16 +1327,18 @@ void RimWellLogTrack::onLoadDataAndUpdate() this->updateAxisScaleEngine(); this->updateRegionAnnotationsOnPlot(); - this->updateXZoom(); + this->updatePropertyValueZoom(); } - this->updateXAxisAndGridTickIntervals(); + this->updatePropertyValueAxisAndGridTickIntervals(); m_majorTickInterval.uiCapability()->setUiHidden( !m_explicitTickIntervals() ); m_minorTickInterval.uiCapability()->setUiHidden( !m_explicitTickIntervals() ); - bool emptyRange = isEmptyVisibleXRange(); + bool emptyRange = isEmptyVisiblePropertyRange(); m_explicitTickIntervals.uiCapability()->setUiReadOnly( emptyRange ); - m_xAxisGridVisibility.uiCapability()->setUiReadOnly( emptyRange ); + m_propertyValueAxisGridVisibility.uiCapability()->setUiReadOnly( emptyRange ); + + updateDepthZoom(); updateLegend(); } @@ -1337,13 +1399,29 @@ void RimWellLogTrack::setAndUpdateSimWellFormationNamesData( RimCase* rimCase, c //-------------------------------------------------------------------------------------------------- void RimWellLogTrack::setAutoScaleXEnabled( bool enabled ) { - m_isAutoScaleXEnabled = enabled; + CAF_ASSERT( "A well log track can be both vertical and horizontal, use setAutoScalePropertyValuesEnabled " ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimWellLogTrack::setAutoScaleYEnabled( bool enabled ) +{ + CAF_ASSERT( "A well log track can be both vertical and horizontal, use setAutoScaleDepthValuesEnabled " ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogTrack::setAutoScalePropertyValuesEnabled( bool enabled ) +{ + m_isAutoScalePropertyValuesEnabled = enabled; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogTrack::setAutoScaleDepthValuesEnabled( bool enabled ) { if ( enabled ) { @@ -1355,41 +1433,42 @@ void RimWellLogTrack::setAutoScaleYEnabled( bool enabled ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogTrack::setAutoScaleXIfNecessary() +void RimWellLogTrack::setAutoScalePropertyValuesIfNecessary() { // Avoid resetting if visible range has set to empty by user - bool emptyRange = isEmptyVisibleXRange(); - if ( !m_isAutoScaleXEnabled && emptyRange ) return; + bool emptyRange = isEmptyVisiblePropertyRange(); + if ( !m_isAutoScalePropertyValuesEnabled && emptyRange ) return; const double eps = 1.0e-8; - calculateXZoomRange(); + calculatePropertyValueZoomRange(); - double maxRange = std::max( m_visibleXRangeMax - m_visibleXRangeMin, m_availableXRangeMax - m_availableXRangeMin ); + double maxRange = std::max( m_visiblePropertyValueRangeMax - m_visiblePropertyValueRangeMin, + m_availablePropertyValueRangeMax - m_availablePropertyValueRangeMin ); - double maxLow = std::max( m_visibleXRangeMin(), m_availableXRangeMin ); - double minHigh = std::min( m_visibleXRangeMax(), m_availableXRangeMax ); + double maxLow = std::max( m_visiblePropertyValueRangeMin(), m_availablePropertyValueRangeMin ); + double minHigh = std::min( m_visiblePropertyValueRangeMax(), m_availablePropertyValueRangeMax ); double overlap = minHigh - maxLow; if ( maxRange < eps || overlap < eps * maxRange ) { - setAutoScaleXEnabled( true ); + setAutoScalePropertyValuesEnabled( true ); } - updateXZoom(); + updatePropertyValueZoom(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogTrack::setXAxisTitle( const QString& text ) +void RimWellLogTrack::setPropertyValueAxisTitle( const QString& text ) { - m_xAxisTitle = text; + m_propertyValueAxisTitle = text; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimWellLogTrack::yAxisTitle() const +QString RimWellLogTrack::depthAxisTitle() const { RimDepthTrackPlot* parent; this->firstAncestorOrThisOfType( parent ); @@ -1510,17 +1589,16 @@ RimWellLogTrack::TrajectoryType RimWellLogTrack::formationTrajectoryType() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuQwtPlotWidget* RimWellLogTrack::doCreatePlotViewWidget( QWidget* mainWindowParent ) +RiuPlotWidget* RimWellLogTrack::doCreatePlotViewWidget( QWidget* mainWindowParent ) { if ( m_plotWidget == nullptr ) { m_plotWidget = new RiuWellLogTrack( this, mainWindowParent ); - m_plotWidget->setAxisInverted( QwtPlot::yLeft ); updateAxisScaleEngine(); for ( size_t cIdx = 0; cIdx < m_curves.size(); ++cIdx ) { - m_curves[cIdx]->setParentQwtPlotNoReplot( this->m_plotWidget ); + m_curves[cIdx]->setParentPlotNoReplot( m_plotWidget ); } } return m_plotWidget; @@ -1549,8 +1627,9 @@ void RimWellLogTrack::reattachAllCurves() { for ( RimPlotCurve* curve : m_curves ) { - curve->reattachQwtCurve(); + curve->reattach(); } + for ( auto& plotObjects : m_wellPathAttributePlotObjects ) { plotObjects->reattachToQwt(); @@ -1588,17 +1667,17 @@ void RimWellLogTrack::updateEditors() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogTrack::setVisibleXRange( double minValue, double maxValue ) +void RimWellLogTrack::setVisiblePropertyValueRange( double minValue, double maxValue ) { - this->setAutoScaleXEnabled( false ); - m_visibleXRangeMin = minValue; - m_visibleXRangeMax = maxValue; + this->setAutoScalePropertyValuesEnabled( false ); + m_visiblePropertyValueRangeMin = minValue; + m_visiblePropertyValueRangeMax = maxValue; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogTrack::setVisibleYRange( double minValue, double maxValue ) +void RimWellLogTrack::setVisibleDepthRange( double minValue, double maxValue ) { m_visibleDepthRangeMin = minValue; m_visibleDepthRangeMax = maxValue; @@ -1607,10 +1686,10 @@ void RimWellLogTrack::setVisibleYRange( double minValue, double maxValue ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogTrack::updateZoomInQwt() +void RimWellLogTrack::updateZoomInParentPlot() { - updateXZoom(); - updateYZoom(); + updatePropertyValueZoom(); + updateDepthZoom(); m_plotWidget->scheduleReplot(); } @@ -1635,9 +1714,9 @@ void RimWellLogTrack::setMinAndMaxTicksOnly( bool enable ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogTrack::setXAxisGridVisibility( RimWellLogPlot::AxisGridVisibility gridLines ) +void RimWellLogTrack::setPropertyValueAxisGridVisibility( RimWellLogPlot::AxisGridVisibility gridLines ) { - m_xAxisGridVisibility = gridLines; + m_propertyValueAxisGridVisibility = gridLines; } //-------------------------------------------------------------------------------------------------- @@ -1777,6 +1856,14 @@ RiuQwtPlotWidget* RimWellLogTrack::viewer() return m_plotWidget; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuPlotWidget* RimWellLogTrack::plotWidget() +{ + return m_plotWidget; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1798,19 +1885,19 @@ QImage RimWellLogTrack::snapshotWindowContent() //-------------------------------------------------------------------------------------------------- void RimWellLogTrack::zoomAll() { - setAutoScaleXEnabled( true ); - setAutoScaleYEnabled( true ); - updateZoomInQwt(); + setAutoScalePropertyValuesEnabled( true ); + setAutoScaleDepthValuesEnabled( true ); + updateZoomInParentPlot(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObject* RimWellLogTrack::findPdmObjectFromQwtCurve( const QwtPlotCurve* curve ) const +caf::PdmObject* RimWellLogTrack::findPdmObjectFromPlotCurve( const RiuPlotCurve* curve ) const { for ( size_t idx = 0; idx < m_curves.size(); idx++ ) { - if ( m_curves[idx]->qwtPlotCurve() == curve ) + if ( m_curves[idx]->isSameCurve( curve ) ) { return m_curves[idx]; } @@ -1851,10 +1938,10 @@ void RimWellLogTrack::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering } else { - m_formationSource = CASE; + m_formationSource = FormationSource::CASE; } - if ( m_formationSource() == CASE ) + if ( m_formationSource() == FormationSource::CASE ) { annotationGroup->add( &m_formationCase ); @@ -1878,7 +1965,7 @@ void RimWellLogTrack::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering m_formationBranchIndex ); } } - else if ( m_formationSource() == WELL_PICK_FILTER ) + else if ( m_formationSource() == FormationSource::WELL_PICK_FILTER ) { annotationGroup->add( &m_formationWellPathForSourceWellPath ); if ( m_formationWellPathForSourceWellPath() ) @@ -1921,9 +2008,9 @@ void RimWellLogTrack::initAfterRead() m_resultDefinition->setEclipseCase( dynamic_cast( eclipseCase ) ); } - if ( m_xAxisGridVisibility() == RimWellLogPlot::AXIS_GRID_MINOR ) + if ( m_propertyValueAxisGridVisibility() == RimWellLogPlot::AXIS_GRID_MINOR ) { - m_xAxisGridVisibility = RimWellLogPlot::AXIS_GRID_MAJOR_AND_MINOR; + m_propertyValueAxisGridVisibility = RimWellLogPlot::AXIS_GRID_MAJOR_AND_MINOR; } for ( auto curve : m_curves ) @@ -1963,7 +2050,7 @@ caf::PdmFieldHandle* RimWellLogTrack::userDescriptionField() //-------------------------------------------------------------------------------------------------- size_t RimWellLogTrack::curveIndex( RimWellLogCurve* curve ) { - return m_curves.index( curve ); + return m_curves.indexOf( curve ); } //-------------------------------------------------------------------------------------------------- @@ -1973,19 +2060,48 @@ void RimWellLogTrack::updateAxisScaleEngine() { if ( !m_plotWidget ) return; - if ( m_isLogarithmicScaleEnabled ) + RimDepthTrackPlot* wellLogPlot = nullptr; + this->firstAncestorOrThisOfType( wellLogPlot ); + if ( wellLogPlot ) { - m_plotWidget->setAxisScaleEngine( QwtPlot::xTop, new QwtLogScaleEngine ); + if ( wellLogPlot->depthOrientation() == RimDepthTrackPlot::DepthOrientation::VERTICAL ) + { + m_plotWidget->setAxisInverted( RiuPlotAxis::defaultLeft(), true ); - // NB! Must assign scale engine to bottom in order to make QwtPlotGrid work - m_plotWidget->setAxisScaleEngine( QwtPlot::xBottom, new QwtLogScaleEngine ); - } - else - { - m_plotWidget->setAxisScaleEngine( QwtPlot::xTop, new RiuQwtLinearScaleEngine ); + if ( m_isLogarithmicScaleEnabled ) + { + m_plotWidget->qwtPlot()->setAxisScaleEngine( QwtAxis::XTop, new QwtLogScaleEngine ); - // NB! Must assign scale engine to bottom in order to make QwtPlotGrid work - m_plotWidget->setAxisScaleEngine( QwtPlot::xBottom, new RiuQwtLinearScaleEngine ); + // NB! Must assign scale engine to bottom in order to make QwtPlotGrid work + m_plotWidget->qwtPlot()->setAxisScaleEngine( QwtAxis::XBottom, new QwtLogScaleEngine ); + } + else + { + m_plotWidget->qwtPlot()->setAxisScaleEngine( QwtAxis::XTop, new RiuQwtLinearScaleEngine ); + + // NB! Must assign scale engine to bottom in order to make QwtPlotGrid work + m_plotWidget->qwtPlot()->setAxisScaleEngine( QwtAxis::XBottom, new RiuQwtLinearScaleEngine ); + } + } + else + { + m_plotWidget->setAxisInverted( RiuPlotAxis::defaultLeft(), false ); + + if ( m_isLogarithmicScaleEnabled ) + { + m_plotWidget->qwtPlot()->setAxisScaleEngine( QwtAxis::YLeft, new QwtLogScaleEngine ); + + // NB! Must assign scale engine to bottom in order to make QwtPlotGrid work + m_plotWidget->qwtPlot()->setAxisScaleEngine( QwtAxis::YRight, new QwtLogScaleEngine ); + } + else + { + m_plotWidget->qwtPlot()->setAxisScaleEngine( QwtAxis::YLeft, new RiuQwtLinearScaleEngine ); + + // NB! Must assign scale engine to bottom in order to make QwtPlotGrid work + m_plotWidget->qwtPlot()->setAxisScaleEngine( QwtAxis::YRight, new RiuQwtLinearScaleEngine ); + } + } } } @@ -2001,6 +2117,27 @@ std::pair RimWellLogTrack::adjustXRange( double minValue, double return std::make_pair( adjustedMin, adjustedMax ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair RimWellLogTrack::extendMinMaxRange( double minValue, double maxValue, double factor ) +{ + auto modifiedMin = minValue; + auto modifiedMax = maxValue; + + auto range = std::fabs( maxValue - minValue ); + modifiedMax += factor * range; + + auto candidateMinValue = minValue - factor * range; + if ( std::signbit( minValue ) == std::signbit( candidateMinValue ) ) + { + // Leave minimum unchanged if the changes causes change of sign to make sure that zero is located properly + modifiedMin = candidateMinValue; + } + + return { modifiedMin, modifiedMax }; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -2031,19 +2168,30 @@ RimDepthTrackPlot* RimWellLogTrack::parentWellLogPlot() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogTrack::handleWheelEvent( QWheelEvent* event ) +void RimWellLogTrack::handleWheelEvent( QWheelEvent* wheelEvent ) { RimDepthTrackPlot* wellLogPlot = nullptr; this->firstAncestorOrThisOfType( wellLogPlot ); if ( wellLogPlot ) { - if ( event->modifiers() & Qt::ControlModifier ) + if ( wheelEvent->modifiers() & Qt::ControlModifier ) { - QwtScaleMap scaleMap = m_plotWidget->canvasMap( QwtPlot::yLeft ); - double zoomCenter = scaleMap.invTransform( event->pos().y() ); + double zoomCenter = 0.0; + auto position = caf::position( wheelEvent ); - if ( event->delta() > 0 ) + if ( wellLogPlot->depthOrientation() == RimDepthTrackPlot::DepthOrientation::VERTICAL ) + { + QwtScaleMap scaleMap = m_plotWidget->qwtPlot()->canvasMap( QwtAxis::YLeft ); + zoomCenter = scaleMap.invTransform( position.y() ); + } + else + { + QwtScaleMap scaleMap = m_plotWidget->qwtPlot()->canvasMap( QwtAxis::XTop ); + zoomCenter = scaleMap.invTransform( position.x() ); + } + + if ( wheelEvent->angleDelta().y() > 0 ) { wellLogPlot->setDepthAxisRangeByFactorAndCenter( RI_SCROLLWHEEL_ZOOMFACTOR, zoomCenter ); } @@ -2054,8 +2202,8 @@ void RimWellLogTrack::handleWheelEvent( QWheelEvent* event ) } else { - wellLogPlot->setDepthAxisRangeByPanDepth( event->delta() < 0 ? RI_SCROLLWHEEL_PANFACTOR - : -RI_SCROLLWHEEL_PANFACTOR ); + wellLogPlot->setDepthAxisRangeByPanDepth( wheelEvent->angleDelta().y() < 0 ? RI_SCROLLWHEEL_PANFACTOR + : -RI_SCROLLWHEEL_PANFACTOR ); } } } @@ -2114,9 +2262,9 @@ void RimWellLogTrack::connectCurveSignals( RimWellLogCurve* curve ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogTrack::computeAndSetXRangeMinForLogarithmicScale() +void RimWellLogTrack::computeAndSetPropertyValueRangeMinForLogarithmicScale() { - if ( m_isAutoScaleXEnabled && m_isLogarithmicScaleEnabled ) + if ( m_isAutoScalePropertyValuesEnabled && m_isLogarithmicScaleEnabled ) { double pos = HUGE_VAL; double neg = -HUGE_VAL; @@ -2125,13 +2273,15 @@ void RimWellLogTrack::computeAndSetXRangeMinForLogarithmicScale() { if ( m_curves[cIdx]->isCurveVisible() && m_curves[cIdx]->curveData() ) { - RigStatisticsCalculator::posNegClosestToZero( m_curves[cIdx]->curveData()->xPlotValues(), pos, neg ); + RigStatisticsCalculator::posNegClosestToZero( m_curves[cIdx]->curveData()->propertyValuesByIntervals(), + pos, + neg ); } } if ( pos != HUGE_VAL ) { - m_visibleXRangeMin = pos; + m_visiblePropertyValueRangeMin = pos; } } } @@ -2144,7 +2294,7 @@ void RimWellLogTrack::setLogarithmicScale( bool enable ) m_isLogarithmicScaleEnabled = enable; updateAxisScaleEngine(); - computeAndSetXRangeMinForLogarithmicScale(); + computeAndSetPropertyValueRangeMinForLogarithmicScale(); } //-------------------------------------------------------------------------------------------------- @@ -2185,7 +2335,7 @@ std::map> RimWellLogTrack::visibleStackedCurv //-------------------------------------------------------------------------------------------------- std::vector RimWellLogTrack::curves() const { - return m_curves.childObjects(); + return m_curves.children(); } //-------------------------------------------------------------------------------------------------- @@ -2195,7 +2345,7 @@ std::vector RimWellLogTrack::visibleCurves() const { std::vector curvesVector; - for ( RimWellLogCurve* curve : m_curves.childObjects() ) + for ( RimWellLogCurve* curve : m_curves.children() ) { if ( curve->isCurveVisible() ) { @@ -2216,11 +2366,11 @@ void RimWellLogTrack::uiOrderingForRftPltFormations( caf::PdmUiOrdering& uiOrder formationGroup->add( &m_regionAnnotationType ); formationGroup->add( &m_regionAnnotationDisplay ); formationGroup->add( &m_formationSource ); - if ( m_formationSource == CASE ) + if ( m_formationSource == FormationSource::CASE ) { formationGroup->add( &m_formationCase ); } - if ( m_formationSource == WELL_PICK_FILTER ) + if ( m_formationSource == FormationSource::WELL_PICK_FILTER ) { if ( m_formationWellPathForSourceWellPath() && m_formationWellPathForSourceWellPath()->hasFormations() ) { @@ -2235,11 +2385,12 @@ void RimWellLogTrack::uiOrderingForRftPltFormations( caf::PdmUiOrdering& uiOrder //-------------------------------------------------------------------------------------------------- void RimWellLogTrack::uiOrderingForXAxisSettings( caf::PdmUiOrdering& uiOrdering ) { - caf::PdmUiGroup* gridGroup = uiOrdering.addNewGroup( "X Axis Settings" ); + caf::PdmUiGroup* gridGroup = uiOrdering.addNewGroup( "Property Axis Settings" ); gridGroup->add( &m_isLogarithmicScaleEnabled ); - gridGroup->add( &m_visibleXRangeMin ); - gridGroup->add( &m_visibleXRangeMax ); - gridGroup->add( &m_xAxisGridVisibility ); + gridGroup->add( &m_visiblePropertyValueRangeMin ); + gridGroup->add( &m_visiblePropertyValueRangeMax ); + gridGroup->add( &m_invertPropertyValueAxis ); + gridGroup->add( &m_propertyValueAxisGridVisibility ); gridGroup->add( &m_minAndMaxTicksOnly ); // TODO Revisit if these settings are required @@ -2489,7 +2640,7 @@ void RimWellLogTrack::updateStackedCurveData() for ( auto curve : stackedCurvesInGroup ) { auto interpolatedCurveValues = curve->curveData()->calculateResampledCurveData( depthType, allDepthValues ); - auto xValues = interpolatedCurveValues->xValues(); + auto xValues = interpolatedCurveValues->propertyValues(); for ( size_t i = 0; i < xValues.size(); ++i ) { if ( xValues[i] != HUGE_VAL ) @@ -2499,8 +2650,15 @@ void RimWellLogTrack::updateStackedCurveData() } RigWellLogCurveData tempCurveData; - tempCurveData.setValuesAndDepths( allStackedValues, allDepthValues, depthType, 0.0, displayUnit, false ); - auto plotDepthValues = tempCurveData.depthPlotValues( depthType, displayUnit ); + tempCurveData.setValuesAndDepths( allStackedValues, + allDepthValues, + depthType, + 0.0, + displayUnit, + false, + m_isLogarithmicScaleEnabled ); + + auto plotDepthValues = tempCurveData.depths( depthType ); auto polyLineStartStopIndices = tempCurveData.polylineStartStopIndices(); curve->setOverrideCurveData( allStackedValues, plotDepthValues, polyLineStartStopIndices ); @@ -2582,7 +2740,7 @@ void RimWellLogTrack::updateFormationNamesOnPlot() RiaDefines::DepthUnitType fromDepthUnit = plot->caseDepthUnit(); RiaDefines::DepthUnitType toDepthUnit = plot->depthUnit(); - if ( m_formationSource() == WELL_PICK_FILTER ) + if ( m_formationSource() == FormationSource::WELL_PICK_FILTER ) { if ( m_formationWellPathForSourceWellPath == nullptr ) return; @@ -2616,7 +2774,7 @@ void RimWellLogTrack::updateFormationNamesOnPlot() std::vector convertedYValues = RiaWellLogUnitTools::convertDepths( yValues, fromDepthUnit, toDepthUnit ); - m_annotationTool->attachWellPicks( m_plotWidget, formationNamesToPlot, convertedYValues ); + m_annotationTool->attachWellPicks( m_plotWidget->qwtPlot(), formationNamesToPlot, convertedYValues ); } else { @@ -2675,7 +2833,8 @@ void RimWellLogTrack::updateFormationNamesOnPlot() if ( geoMechWellLogExtractor ) { // Attach water and rock base formations - const std::pair xRange = std::make_pair( m_visibleXRangeMin(), m_visibleXRangeMax() ); + const std::pair xRange = + std::make_pair( m_visiblePropertyValueRangeMin(), m_visiblePropertyValueRangeMax() ); const caf::ColorTable waterAndRockColors = RiaColorTables::waterAndRockPaletteColors(); const std::vector> waterAndRockIntervals = @@ -2684,7 +2843,7 @@ void RimWellLogTrack::updateFormationNamesOnPlot() const std::vector> convertedYValues = RiaWellLogUnitTools::convertDepths( waterAndRockIntervals, fromDepthUnit, toDepthUnit ); - m_annotationTool->attachNamedRegions( m_plotWidget, + m_annotationTool->attachNamedRegions( m_plotWidget->qwtPlot(), { "Sea Level", "" }, xRange, convertedYValues, @@ -2696,7 +2855,7 @@ void RimWellLogTrack::updateFormationNamesOnPlot() { Qt::SolidPattern, Qt::Dense6Pattern } ); } - if ( m_formationSource == CASE ) + if ( m_formationSource == FormationSource::CASE && m_plotWidget ) { if ( ( m_formationSimWellName == QString( "None" ) && m_formationWellPathForSourceCase == nullptr ) || m_formationCase == nullptr ) @@ -2723,13 +2882,14 @@ void RimWellLogTrack::updateFormationNamesOnPlot() &formationNamesToPlot, &yValues ); - const std::pair xRange = std::make_pair( m_visibleXRangeMin(), m_visibleXRangeMax() ); + const std::pair xRange = + std::make_pair( m_visiblePropertyValueRangeMin(), m_visiblePropertyValueRangeMax() ); std::vector> convertedYValues = RiaWellLogUnitTools::convertDepths( yValues, fromDepthUnit, toDepthUnit ); caf::ColorTable colorTable( m_colorShadingLegend->colorArray() ); - m_annotationTool->attachNamedRegions( m_plotWidget, + m_annotationTool->attachNamedRegions( m_plotWidget->qwtPlot(), formationNamesToPlot, xRange, convertedYValues, @@ -2784,9 +2944,10 @@ void RimWellLogTrack::updateResultPropertyNamesOnPlot() CurveSamplingPointData curveData = RimWellLogTrack::curveSamplingPointData( eclWellLogExtractor, resultAccessor.p() ); // Attach water and rock base formations - const std::pair xRange = std::make_pair( m_visibleXRangeMin(), m_visibleXRangeMax() ); + const std::pair xRange = + std::make_pair( m_visiblePropertyValueRangeMin(), m_visiblePropertyValueRangeMax() ); - if ( m_formationSource == CASE ) + if ( m_formationSource == FormationSource::CASE ) { if ( ( m_formationSimWellName == QString( "None" ) && m_formationWellPathForSourceCase == nullptr ) || m_formationCase == nullptr ) @@ -2857,7 +3018,7 @@ void RimWellLogTrack::updateResultPropertyNamesOnPlot() int fontSize = caf::FontTools::absolutePointSize( RiaPreferences::current()->defaultPlotFontSize(), m_regionLabelFontSize() ); - m_annotationTool->attachNamedRegions( m_plotWidget, + m_annotationTool->attachNamedRegions( m_plotWidget->qwtPlot(), namesToPlot, xRange, convertedYValues, @@ -2895,7 +3056,8 @@ void RimWellLogTrack::updateCurveDataRegionsOnPlot() RiaExtractionTools::findOrCreateWellLogExtractor( wellPath, dynamic_cast( geoMechCase ) ); if ( !geoMechWellLogExtractor ) return; - std::pair xRange = std::make_pair( m_visibleXRangeMin(), m_visibleXRangeMax() ); + std::pair xRange = + std::make_pair( m_visiblePropertyValueRangeMin(), m_visiblePropertyValueRangeMax() ); CurveSamplingPointData curveData; curveData.md = geoMechWellLogExtractor->cellIntersectionMDs(); @@ -2934,7 +3096,7 @@ void RimWellLogTrack::updateCurveDataRegionsOnPlot() std::vector> convertedYValues = RiaWellLogUnitTools::convertDepths( yValues, fromDepthUnit, toDepthUnit ); - m_annotationTool->attachNamedRegions( m_plotWidget, + m_annotationTool->attachNamedRegions( m_plotWidget->qwtPlot(), sourceNamesToPlot, xRange, convertedYValues, @@ -2965,7 +3127,7 @@ void RimWellLogTrack::updateCurveDataRegionsOnPlot() std::vector> convertedYValues = RiaWellLogUnitTools::convertDepths( yValues, fromDepthUnit, toDepthUnit ); - m_annotationTool->attachNamedRegions( m_plotWidget, + m_annotationTool->attachNamedRegions( m_plotWidget->qwtPlot(), sourceNamesToPlot, xRange, convertedYValues, @@ -2995,7 +3157,7 @@ void RimWellLogTrack::updateCurveDataRegionsOnPlot() std::vector> convertedYValues = RiaWellLogUnitTools::convertDepths( yValues, fromDepthUnit, toDepthUnit ); - m_annotationTool->attachNamedRegions( m_plotWidget, + m_annotationTool->attachNamedRegions( m_plotWidget->qwtPlot(), sourceNamesToPlot, xRange, convertedYValues, @@ -3094,10 +3256,10 @@ void RimWellLogTrack::updateWellPathAttributesOnPlot() attributePlotObject->setDepthType( depthType ); attributePlotObject->setShowLabel( m_showWellPathComponentLabels() ); attributePlotObject->loadDataAndUpdate( false ); - attributePlotObject->setParentQwtPlotNoReplot( m_plotWidget ); + attributePlotObject->setParentPlotNoReplot( m_plotWidget->qwtPlot() ); } } - updateXZoom(); + updatePropertyValueZoom(); } //-------------------------------------------------------------------------------------------------- @@ -3126,8 +3288,8 @@ void RimWellLogTrack::doUpdateLayout() void RimWellLogTrack::onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, std::vector& referringObjects ) { - setAutoScaleXEnabled( true ); - updateZoomInQwt(); + setAutoScalePropertyValuesEnabled( true ); + updateZoomInParentPlot(); RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow(); mainPlotWindow->updateWellLogPlotToolBar(); } @@ -3213,3 +3375,25 @@ void RimWellLogTrack::setEnsembleWellLogCurveSet( RimEnsembleWellLogCurveSet* cu { m_ensembleWellLogCurveSet = curveSet; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuPlotAxis RimWellLogTrack::depthAxis() const +{ + RimDepthTrackPlot* wellLogPlot; + this->firstAncestorOrThisOfTypeAsserted( wellLogPlot ); + + return wellLogPlot->depthAxis(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuPlotAxis RimWellLogTrack::valueAxis() const +{ + RimDepthTrackPlot* wellLogPlot; + this->firstAncestorOrThisOfTypeAsserted( wellLogPlot ); + + return wellLogPlot->valueAxis(); +} diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogTrack.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogTrack.h index b3a9ce9159..5b23753ce0 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogTrack.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogTrack.h @@ -25,15 +25,14 @@ #include "RiuPlotAnnotationTool.h" #include "RimPlot.h" -#include "RimRegularLegendConfig.h" + +#include "RiuPlotAxis.h" #include "cafPdmChildArrayField.h" #include "cafPdmField.h" #include "cafPdmObject.h" #include "cafPdmPtrField.h" -#include "qwt_plot.h" - #include #include @@ -59,8 +58,6 @@ class RimEclipseResultDefinition; class RimColorLegend; class RimEnsembleWellLogCurveSet; -class QwtPlotCurve; - struct CurveSamplingPointData { std::vector data; @@ -98,7 +95,8 @@ class RimWellLogTrack : public RimPlot ~RimWellLogTrack() override; QWidget* viewWidget() override; - RiuQwtPlotWidget* viewer() override; + RiuQwtPlotWidget* viewer(); + RiuPlotWidget* plotWidget() override; QImage snapshotWindowContent() override; void zoomAll() override; @@ -113,8 +111,8 @@ class RimWellLogTrack : public RimPlot size_t curveIndex( RimWellLogCurve* curve ); size_t curveCount() { return m_curves.size(); } - void setXAxisTitle( const QString& text ); - QString yAxisTitle() const; + void setPropertyValueAxisTitle( const QString& text ); + QString depthAxisTitle() const; void setFormationWellPath( RimWellPath* wellPath ); RimWellPath* formationWellPath() const; @@ -141,21 +139,24 @@ class RimWellLogTrack : public RimPlot bool useBranchDetection ); void setAndUpdateSimWellFormationNamesData( RimCase* rimCase, const QString& simWellName ); - void setAutoScaleXEnabled( bool enabled ) override; - void setAutoScaleYEnabled( bool enabled ) override; - void setAutoScaleXIfNecessary(); + [[deprecated( "Use setAutoScalePropertyValuesEnabled() instead." )]] void setAutoScaleXEnabled( bool enabled ) override; + [[deprecated( "Use setAutoScaleDepthValuesEnabled() instead." )]] void setAutoScaleYEnabled( bool enabled ) override; - void availableXAxisRange( double* minX, double* maxX ); + void setAutoScalePropertyValuesEnabled( bool enabled ); + void setAutoScaleDepthValuesEnabled( bool enabled ); + void setAutoScalePropertyValuesIfNecessary(); + + void availablePropertyValueRange( double* minX, double* maxX ); void availableDepthRange( double* minimumDepth, double* maximumDepth ); - void visibleXAxisRange( double* minX, double* maxX ); + void visiblePropertyValueRange( double* minX, double* maxX ); void visibleDepthRange( double* minimumDepth, double* maximumDepth ); - void setVisibleXRange( double minValue, double maxValue ); - void setVisibleYRange( double minValue, double maxValue ); + void setVisiblePropertyValueRange( double minValue, double maxValue ); + void setVisibleDepthRange( double minValue, double maxValue ); - void updateZoomInQwt() override; - void updateZoomFromQwt() override; + void updateZoomInParentPlot() override; + void updateZoomFromParentPlot() override; void updateParentPlotZoom(); @@ -163,7 +164,7 @@ class RimWellLogTrack : public RimPlot void setTickIntervals( double majorTickInterval, double minorTickInterval ); void setMinAndMaxTicksOnly( bool enable ); - void setXAxisGridVisibility( RimWellLogPlot::AxisGridVisibility gridLines ); + void setPropertyValueAxisGridVisibility( RimWellLogPlot::AxisGridVisibility gridLines ); void setAnnotationType( RiuPlotAnnotationTool::RegionAnnotationType annotationType ); void setAnnotationDisplay( RiuPlotAnnotationTool::RegionDisplay annotationDisplay ); @@ -189,7 +190,7 @@ class RimWellLogTrack : public RimPlot RimWellPath* wellPathAttributeSource() const; - caf::PdmObject* findPdmObjectFromQwtCurve( const QwtPlotCurve* curve ) const override; + caf::PdmObject* findPdmObjectFromPlotCurve( const RiuPlotCurve* curve ) const override; void setLogarithmicScale( bool enable ); bool isLogarithmicScale() const; @@ -203,13 +204,13 @@ class RimWellLogTrack : public RimPlot void uiOrderingForXAxisSettings( caf::PdmUiOrdering& uiOrdering ); void setFormationsForCaseWithSimWellOnly( bool caseWithSimWellOnly ); - void updateXAxisAndGridTickIntervals(); + void updatePropertyValueAxisAndGridTickIntervals(); void updateLegend() override; QString asciiDataForPlotExport() const override; - void onAxisSelected( int axis, bool toggle ) override; + void onAxisSelected( RiuPlotAxis axis, bool toggle ) override; void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, std::vector& referringObjects ) override; @@ -240,17 +241,22 @@ class RimWellLogTrack : public RimPlot // RimViewWindow overrides void deleteViewWidget() override; void onLoadDataAndUpdate() override; + void onChildrenUpdated( caf::PdmChildArrayFieldHandle* childArray, + std::vector& updatedObjects ) override; private: - RiuQwtPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent = nullptr ) override; + RiuPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent = nullptr ) override; void cleanupBeforeClose(); void detachAllPlotItems(); - void calculateXZoomRange(); - void calculateYZoomRange(); + void calculatePropertyValueZoomRange(); + void calculateDepthZoomRange(); + + void updatePropertyValueZoom(); + void updateDepthZoom(); - void updateXZoom(); - void updateYZoom(); + RiuPlotAxis depthAxis() const; + RiuPlotAxis valueAxis() const; int axisFontSize() const; @@ -260,8 +266,7 @@ class RimWellLogTrack : public RimPlot void curveAppearanceChanged( const caf::SignalEmitter* emitter ); void curveStackingChanged( const caf::SignalEmitter* emitter, bool stacked ); - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void initAfterRead() override; @@ -271,7 +276,7 @@ class RimWellLogTrack : public RimPlot caf::PdmFieldHandle* userDescriptionField() override; - void computeAndSetXRangeMinForLogarithmicScale(); + void computeAndSetPropertyValueRangeMinForLogarithmicScale(); static void simWellOptionItems( QList* options, RimCase* eclCase ); @@ -293,6 +298,8 @@ class RimWellLogTrack : public RimPlot std::pair adjustXRange( double minValue, double maxValue, double tickInterval ); + std::pair extendMinMaxRange( double minValue, double maxValue, double factor ); + void updateWellPathAttributesCollection(); RimDepthTrackPlot* parentWellLogPlot() const; @@ -304,22 +311,23 @@ class RimWellLogTrack : public RimPlot const RigGeoMechWellLogExtractor* extractor ) const; void connectCurveSignals( RimWellLogCurve* curve ); - bool isEmptyVisibleXRange() const; + bool isEmptyVisiblePropertyRange() const; private: - QString m_xAxisTitle; + QString m_propertyValueAxisTitle; caf::PdmField m_description; caf::PdmChildArrayField m_curves; - caf::PdmField m_visibleXRangeMin; - caf::PdmField m_visibleXRangeMax; + caf::PdmField m_visiblePropertyValueRangeMin; + caf::PdmField m_visiblePropertyValueRangeMax; caf::PdmField m_visibleDepthRangeMin; caf::PdmField m_visibleDepthRangeMax; - caf::PdmField m_isAutoScaleXEnabled; + caf::PdmField m_isAutoScalePropertyValuesEnabled; caf::PdmField m_isLogarithmicScaleEnabled; - caf::PdmField m_xAxisGridVisibility; + caf::PdmField m_invertPropertyValueAxis; + caf::PdmField m_propertyValueAxisGridVisibility; caf::PdmField m_explicitTickIntervals; caf::PdmField m_minAndMaxTicksOnly; @@ -364,8 +372,8 @@ class RimWellLogTrack : public RimPlot QPointer m_plotWidget; std::unique_ptr m_annotationTool; - double m_availableXRangeMin; - double m_availableXRangeMax; + double m_availablePropertyValueRangeMin; + double m_availablePropertyValueRangeMax; double m_availableDepthRangeMin; double m_availableDepthRangeMax; }; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogWbsCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogWbsCurve.cpp index 59fe90554d..9634f79ac6 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogWbsCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogWbsCurve.cpp @@ -12,10 +12,10 @@ CAF_PDM_SOURCE_INIT( RimWellLogWbsCurve, "RimWellLogWbsCurve" ); //-------------------------------------------------------------------------------------------------- RimWellLogWbsCurve::RimWellLogWbsCurve() { - CAF_PDM_InitObject( "Well Bore Stability Curve", RimWellLogCurve::wellLogCurveIconName(), "", "" ); + CAF_PDM_InitObject( "Well Bore Stability Curve", RimWellLogCurve::wellLogCurveIconName() ); - CAF_PDM_InitField( &m_smoothCurve, "SmoothCurve", false, "Smooth Curve", "", "", "" ); - CAF_PDM_InitField( &m_smoothingThreshold, "SmoothingThreshold", 0.002, "Smoothing Threshold", "", "", "" ); + CAF_PDM_InitField( &m_smoothCurve, "SmoothCurve", false, "Smooth Curve" ); + CAF_PDM_InitField( &m_smoothingThreshold, "SmoothingThreshold", 0.002, "Smoothing Threshold" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/WellMeasurement/RimWellMeasurement.cpp b/ApplicationLibCode/ProjectDataModel/WellMeasurement/RimWellMeasurement.cpp index d0c6a849b0..17be05d7a2 100644 --- a/ApplicationLibCode/ProjectDataModel/WellMeasurement/RimWellMeasurement.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellMeasurement/RimWellMeasurement.cpp @@ -29,16 +29,16 @@ CAF_PDM_SOURCE_INIT( RimWellMeasurement, "WellMeasurement" ); //-------------------------------------------------------------------------------------------------- RimWellMeasurement::RimWellMeasurement() { - CAF_PDM_InitObject( "RimWellMeasurement", ":/WellMeasurement16x16.png", "", "" ); - - CAF_PDM_InitFieldNoDefault( &m_wellName, "WellName", "Well Name", "", "", "" ); - CAF_PDM_InitField( &m_MD, "Depth", -1.0, "MD", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_date, "Date", "Date", "", "", "" ); - CAF_PDM_InitField( &m_value, "Value", 0.0, "Value", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_kind, "Kind", "Kind", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_quality, "Quality", "Quality", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_remark, "Remark", "Remark", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_filePath, "FilePath", "File Path", "", "", "" ); + CAF_PDM_InitObject( "RimWellMeasurement", ":/WellMeasurement16x16.png" ); + + CAF_PDM_InitFieldNoDefault( &m_wellName, "WellName", "Well Name" ); + CAF_PDM_InitField( &m_MD, "Depth", -1.0, "MD" ); + CAF_PDM_InitFieldNoDefault( &m_date, "Date", "Date" ); + CAF_PDM_InitField( &m_value, "Value", 0.0, "Value" ); + CAF_PDM_InitFieldNoDefault( &m_kind, "Kind", "Kind" ); + CAF_PDM_InitFieldNoDefault( &m_quality, "Quality", "Quality" ); + CAF_PDM_InitFieldNoDefault( &m_remark, "Remark", "Remark" ); + CAF_PDM_InitFieldNoDefault( &m_filePath, "FilePath", "File Path" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/WellMeasurement/RimWellMeasurementCollection.cpp b/ApplicationLibCode/ProjectDataModel/WellMeasurement/RimWellMeasurementCollection.cpp index a8d626d839..01c1c411b8 100644 --- a/ApplicationLibCode/ProjectDataModel/WellMeasurement/RimWellMeasurementCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellMeasurement/RimWellMeasurementCollection.cpp @@ -37,14 +37,14 @@ CAF_PDM_SOURCE_INIT( RimWellMeasurementCollection, "WellMeasurements" ); //-------------------------------------------------------------------------------------------------- RimWellMeasurementCollection::RimWellMeasurementCollection() { - CAF_PDM_InitObject( "Well Measurements", ":/WellMeasurement16x16.png", "", "" ); + CAF_PDM_InitObject( "Well Measurements", ":/WellMeasurement16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_measurements, "Measurements", "Well Measurements", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_measurements, "Measurements", "Well Measurements" ); m_measurements.uiCapability()->setUiEditorTypeName( caf::PdmUiTableViewEditor::uiEditorTypeName() ); m_measurements.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); m_measurements.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_importedFiles, "ImportedFiles", "Imported Files", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_importedFiles, "ImportedFiles", "Imported Files" ); m_importedFiles.uiCapability()->setUiTreeHidden( true ); } @@ -89,7 +89,7 @@ void RimWellMeasurementCollection::deleteAllEmptyCurves() for ( auto curve : measurementCurves ) { - if ( curve->curveData()->xValues().empty() ) + if ( curve->curveData()->propertyValues().empty() ) { RimWellLogTrack* track = nullptr; curve->firstAncestorOrThisOfTypeAsserted( track ); @@ -129,7 +129,7 @@ bool RimWellMeasurementCollection::isEmpty() const //-------------------------------------------------------------------------------------------------- void RimWellMeasurementCollection::insertMeasurement( RimWellMeasurement* insertBefore, RimWellMeasurement* measurement ) { - size_t index = m_measurements.index( insertBefore ); + size_t index = m_measurements.indexOf( insertBefore ); if ( index < m_measurements.size() ) m_measurements.insert( index, measurement ); else @@ -154,7 +154,7 @@ void RimWellMeasurementCollection::appendMeasurement( RimWellMeasurement* measur //-------------------------------------------------------------------------------------------------- void RimWellMeasurementCollection::deleteMeasurement( RimWellMeasurement* measurementToDelete ) { - m_measurements.removeChildObject( measurementToDelete ); + m_measurements.removeChild( measurementToDelete ); delete measurementToDelete; this->updateAllCurves(); @@ -165,7 +165,7 @@ void RimWellMeasurementCollection::deleteMeasurement( RimWellMeasurement* measur //-------------------------------------------------------------------------------------------------- void RimWellMeasurementCollection::deleteAllMeasurements() { - m_measurements.deleteAllChildObjects(); + m_measurements.deleteChildren(); this->updateAllCurves(); } @@ -243,7 +243,7 @@ void RimWellMeasurementCollection::addFilePath( const QString& filePath ) //-------------------------------------------------------------------------------------------------- void RimWellMeasurementCollection::removeFilePath( RimWellMeasurementFilePath* measurementFilePath ) { - m_importedFiles.removeChildObject( measurementFilePath ); + m_importedFiles.removeChild( measurementFilePath ); delete measurementFilePath; } @@ -265,7 +265,7 @@ void RimWellMeasurementCollection::removeMeasurementsForFilePath( RimWellMeasure // Remove then remove them without invalidating the iterator for ( unsigned int i = 0; i < measurementsToRemove.size(); i++ ) { - m_measurements.removeChildObject( measurementsToRemove[i] ); + m_measurements.removeChild( measurementsToRemove[i] ); delete measurementsToRemove[i]; } diff --git a/ApplicationLibCode/ProjectDataModel/WellMeasurement/RimWellMeasurementCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellMeasurement/RimWellMeasurementCurve.cpp index d8766e549d..1f969e59fe 100644 --- a/ApplicationLibCode/ProjectDataModel/WellMeasurement/RimWellMeasurementCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellMeasurement/RimWellMeasurementCurve.cpp @@ -50,12 +50,12 @@ CAF_PDM_SOURCE_INIT( RimWellMeasurementCurve, "WellMeasurementCurve" ); //-------------------------------------------------------------------------------------------------- RimWellMeasurementCurve::RimWellMeasurementCurve() { - CAF_PDM_InitObject( "Well Measurement Curve", RimWellLogCurve::wellLogCurveIconName(), "", "" ); + CAF_PDM_InitObject( "Well Measurement Curve", RimWellLogCurve::wellLogCurveIconName() ); - CAF_PDM_InitFieldNoDefault( &m_wellPath, "CurveWellPath", "Well Path", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wellPath, "CurveWellPath", "Well Path" ); m_wellPath.uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_measurementKind, "CurveMeasurementKind", "Measurement Kind", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_measurementKind, "CurveMeasurementKind", "Measurement Kind" ); m_measurementKind.uiCapability()->setUiTreeChildrenHidden( true ); m_wellPath = nullptr; @@ -116,27 +116,31 @@ void RimWellMeasurementCurve::onLoadDataAndUpdate( bool updateParentPlot ) -rigWellPath->interpolatedPointAlongWellPath( measuredDepthValue ).z() ); } - this->setValuesWithMdAndTVD( values, - measuredDepthValues, - trueVerticalDepthValues, - m_wellPath->wellPathGeometry()->rkbDiff(), - RiaDefines::DepthUnitType::UNIT_METER, - false ); + bool useLogarithmicScale = false; + this->setPropertyValuesWithMdAndTVD( values, + measuredDepthValues, + trueVerticalDepthValues, + m_wellPath->wellPathGeometry()->rkbDiff(), + RiaDefines::DepthUnitType::UNIT_METER, + false, + useLogarithmicScale ); } else { - this->setValuesAndDepths( values, - measuredDepthValues, - RiaDefines::DepthTypeEnum::MEASURED_DEPTH, - 0.0, - RiaDefines::DepthUnitType::UNIT_METER, - false ); + bool useLogarithmicScale = false; + this->setPropertyValuesAndDepths( values, + measuredDepthValues, + RiaDefines::DepthTypeEnum::MEASURED_DEPTH, + 0.0, + RiaDefines::DepthUnitType::UNIT_METER, + false, + useLogarithmicScale ); } } if ( m_isUsingAutoName ) { - m_qwtPlotCurve->setTitle( createCurveAutoName() ); + m_plotCurve->setTitle( createCurveAutoName() ); } setSymbol( getSymbolForMeasurementKind( m_measurementKind() ) ); @@ -156,10 +160,11 @@ void RimWellMeasurementCurve::onLoadDataAndUpdate( bool updateParentPlot ) depthType = wellLogPlot->depthType(); } - m_qwtPlotCurve->setSamples( this->curveData()->xPlotValues().data(), - this->curveData()->depthPlotValues( depthType, displayUnit ).data(), - static_cast( this->curveData()->xPlotValues().size() ) ); - m_qwtPlotCurve->setLineSegmentStartStopIndices( this->curveData()->polylineStartStopIndices() ); + bool useLogarithmicScale = false; + m_plotCurve->setSamplesFromXValuesAndYValues( this->curveData()->propertyValuesByIntervals(), + this->curveData()->depthValuesByIntervals( depthType, displayUnit ), + useLogarithmicScale ); + m_plotCurve->setLineSegmentStartStopIndices( this->curveData()->polylineStartStopIndices() ); } this->RimPlotCurve::updateCurvePresentation( updateParentPlot ); @@ -169,9 +174,9 @@ void RimWellMeasurementCurve::onLoadDataAndUpdate( bool updateParentPlot ) updateZoomInParentPlot(); } - if ( m_parentQwtPlot ) + if ( m_parentPlot ) { - m_parentQwtPlot->replot(); + m_parentPlot->replot(); } } @@ -205,7 +210,7 @@ void RimWellMeasurementCurve::fieldChangedByUi( const caf::PdmFieldHandle* chang this->loadDataAndUpdate( true ); } - if ( m_parentQwtPlot ) m_parentQwtPlot->replot(); + if ( m_parentPlot ) m_parentPlot->replot(); } //-------------------------------------------------------------------------------------------------- @@ -225,6 +230,8 @@ void RimWellMeasurementCurve::defineUiOrdering( QString uiConfigName, caf::PdmUi caf::PdmUiGroup* nameGroup = uiOrdering.addNewGroup( "Curve Name" ); nameGroup->add( &m_showLegend ); RimPlotCurve::curveNameUiOrdering( *nameGroup ); + + uiOrdering.skipRemainingFields( true ); } //-------------------------------------------------------------------------------------------------- @@ -238,12 +245,11 @@ void RimWellMeasurementCurve::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTr //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList - RimWellMeasurementCurve::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) +QList RimWellMeasurementCurve::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; - options = RimWellLogCurve::calculateValueOptions( fieldNeedingOptions, useOptionsOnly ); + options = RimWellLogCurve::calculateValueOptions( fieldNeedingOptions ); if ( options.size() > 0 ) return options; if ( fieldNeedingOptions == &m_wellPath ) @@ -350,25 +356,25 @@ void RimWellMeasurementCurve::setMeasurementKind( const QString& measurementKind //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuQwtSymbol::PointSymbolEnum RimWellMeasurementCurve::getSymbolForMeasurementKind( const QString& measurementKind ) +RiuPlotCurveSymbol::PointSymbolEnum RimWellMeasurementCurve::getSymbolForMeasurementKind( const QString& measurementKind ) { - std::map symbolTable; - symbolTable["XLOT"] = RiuQwtSymbol::SYMBOL_RECT; - symbolTable["LOT"] = RiuQwtSymbol::SYMBOL_TRIANGLE; - symbolTable["FIT"] = RiuQwtSymbol::SYMBOL_DIAMOND; - symbolTable["MCF"] = RiuQwtSymbol::SYMBOL_ELLIPSE; - symbolTable["MNF"] = RiuQwtSymbol::SYMBOL_ELLIPSE; - symbolTable["TH"] = RiuQwtSymbol::SYMBOL_STAR1; - symbolTable["LE"] = RiuQwtSymbol::SYMBOL_STAR2; - symbolTable["BA"] = RiuQwtSymbol::SYMBOL_STAR1; - symbolTable["CORE"] = RiuQwtSymbol::SYMBOL_RECT; - symbolTable["PPG"] = RiuQwtSymbol::SYMBOL_RECT; + std::map symbolTable; + symbolTable["XLOT"] = RiuPlotCurveSymbol::SYMBOL_RECT; + symbolTable["LOT"] = RiuPlotCurveSymbol::SYMBOL_TRIANGLE; + symbolTable["FIT"] = RiuPlotCurveSymbol::SYMBOL_DIAMOND; + symbolTable["MCF"] = RiuPlotCurveSymbol::SYMBOL_ELLIPSE; + symbolTable["MNF"] = RiuPlotCurveSymbol::SYMBOL_ELLIPSE; + symbolTable["TH"] = RiuPlotCurveSymbol::SYMBOL_STAR1; + symbolTable["LE"] = RiuPlotCurveSymbol::SYMBOL_STAR2; + symbolTable["BA"] = RiuPlotCurveSymbol::SYMBOL_STAR1; + symbolTable["CORE"] = RiuPlotCurveSymbol::SYMBOL_RECT; + symbolTable["PPG"] = RiuPlotCurveSymbol::SYMBOL_RECT; auto it = symbolTable.find( measurementKind ); if ( it != symbolTable.end() ) return it->second; else - return RiuQwtSymbol::SYMBOL_CROSS; + return RiuPlotCurveSymbol::SYMBOL_CROSS; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/WellMeasurement/RimWellMeasurementCurve.h b/ApplicationLibCode/ProjectDataModel/WellMeasurement/RimWellMeasurementCurve.h index 69cc2e1800..82c76270d6 100644 --- a/ApplicationLibCode/ProjectDataModel/WellMeasurement/RimWellMeasurementCurve.h +++ b/ApplicationLibCode/ProjectDataModel/WellMeasurement/RimWellMeasurementCurve.h @@ -60,11 +60,10 @@ class RimWellMeasurementCurve : public RimWellLogCurve void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; - RiuQwtSymbol::PointSymbolEnum getSymbolForMeasurementKind( const QString& measurementKind ); - cvf::Color3f getColorForMeasurementKind( const QString& measurementKind ); + RiuPlotCurveSymbol::PointSymbolEnum getSymbolForMeasurementKind( const QString& measurementKind ); + cvf::Color3f getColorForMeasurementKind( const QString& measurementKind ); protected: caf::PdmPtrField m_wellPath; diff --git a/ApplicationLibCode/ProjectDataModel/WellMeasurement/RimWellMeasurementFilePath.cpp b/ApplicationLibCode/ProjectDataModel/WellMeasurement/RimWellMeasurementFilePath.cpp index 21ac554355..708db05aa7 100644 --- a/ApplicationLibCode/ProjectDataModel/WellMeasurement/RimWellMeasurementFilePath.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellMeasurement/RimWellMeasurementFilePath.cpp @@ -29,10 +29,10 @@ CAF_PDM_SOURCE_INIT( RimWellMeasurementFilePath, "WellMeasurementFilePath" ); //-------------------------------------------------------------------------------------------------- RimWellMeasurementFilePath::RimWellMeasurementFilePath() { - CAF_PDM_InitObject( "RimWellMeasurementFilePath", ":/WellMeasurement16x16.png", "", "" ); + CAF_PDM_InitObject( "RimWellMeasurementFilePath", ":/WellMeasurement16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_userDescription, "UserDecription", "Name", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_filePath, "FilePath", "File Path", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_userDescription, "UserDecription", "Name" ); + CAF_PDM_InitFieldNoDefault( &m_filePath, "FilePath", "File Path" ); m_filePath.uiCapability()->setUiReadOnly( true ); m_filePath.uiCapability()->setUiEditorTypeName( caf::PdmUiLineEditor::uiEditorTypeName() ); } diff --git a/ApplicationLibCode/ProjectDataModel/WellMeasurement/RimWellMeasurementInView.cpp b/ApplicationLibCode/ProjectDataModel/WellMeasurement/RimWellMeasurementInView.cpp index b9dac31c47..f0410796f6 100644 --- a/ApplicationLibCode/ProjectDataModel/WellMeasurement/RimWellMeasurementInView.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellMeasurement/RimWellMeasurementInView.cpp @@ -48,41 +48,41 @@ CAF_PDM_SOURCE_INIT( RimWellMeasurementInView, "WellMeasurementInView" ); //-------------------------------------------------------------------------------------------------- RimWellMeasurementInView::RimWellMeasurementInView() { - CAF_PDM_InitObject( "Well Measurement", ":/WellMeasurement16x16.png", "", "" ); + CAF_PDM_InitObject( "Well Measurement", ":/WellMeasurement16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_measurementKind, "MeasurementKind", "Measurement Kind", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_measurementKind, "MeasurementKind", "Measurement Kind" ); m_measurementKind.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_legendConfig, "LegendDefinition", "Color Legend", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_legendConfig, "LegendDefinition", "Color Legend" ); m_legendConfig = new RimRegularLegendConfig(); m_legendConfig.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_wells, "Wells", "Wells", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wells, "Wells", "Wells" ); m_wells.uiCapability()->setAutoAddingOptionFromValue( false ); m_wells.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); m_wells.xmlCapability()->disableIO(); // The m_wells field does not serialize in a suitable format, so we work around it by // serializing to a pipe-delimited string. - CAF_PDM_InitFieldNoDefault( &m_wellsSerialized, "WellsSerialized", "WellsSerialized", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wellsSerialized, "WellsSerialized", "WellsSerialized" ); m_wellsSerialized.uiCapability()->setUiHidden( true ); // Keep track of the wells which has a given measurement in order to automatically select // new wells when they appear in new measurements - CAF_PDM_InitFieldNoDefault( &m_availableWellsSerialized, "AvailableWellsSerialized", "AvailableWellsSerialized", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_availableWellsSerialized, "AvailableWellsSerialized", "AvailableWellsSerialized" ); // m_availableWellsSerialized.uiCapability()->setUiHidden( true ); - CAF_PDM_InitField( &m_lowerBound, "LowerBound", -HUGE_VAL, "Min", "", "", "" ); + CAF_PDM_InitField( &m_lowerBound, "LowerBound", -HUGE_VAL, "Min" ); m_lowerBound.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_upperBound, "UpperBound", HUGE_VAL, "Max", "", "", "" ); + CAF_PDM_InitField( &m_upperBound, "UpperBound", HUGE_VAL, "Max" ); m_upperBound.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); - CAF_PDM_InitFieldNoDefault( &m_qualityFilter, "QualityFilter", "Quality Filter", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_qualityFilter, "QualityFilter", "Quality Filter" ); m_qualityFilter.uiCapability()->setAutoAddingOptionFromValue( false ); m_qualityFilter.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_radiusScaleFactor, "RadiusScaleFactor", 2.5, "Radius Scale", "", "", "" ); + CAF_PDM_InitField( &m_radiusScaleFactor, "RadiusScaleFactor", 2.5, "Radius Scale" ); m_radiusScaleFactor.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); this->setName( "Well Measurement" ); @@ -321,8 +321,7 @@ bool RimWellMeasurementInView::hasMeasurementKindForWell( const RimWellPath* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList - RimWellMeasurementInView::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) +QList RimWellMeasurementInView::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; if ( fieldNeedingOptions == &m_wells ) diff --git a/ApplicationLibCode/ProjectDataModel/WellMeasurement/RimWellMeasurementInView.h b/ApplicationLibCode/ProjectDataModel/WellMeasurement/RimWellMeasurementInView.h index 0a11e0d46a..ddf78a21b7 100644 --- a/ApplicationLibCode/ProjectDataModel/WellMeasurement/RimWellMeasurementInView.h +++ b/ApplicationLibCode/ProjectDataModel/WellMeasurement/RimWellMeasurementInView.h @@ -66,8 +66,7 @@ class RimWellMeasurementInView : public RimCheckableNamedObject void initAfterRead() override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; bool updateLegendData(); static bool hasMeasurementKindForWell( const RimWellPath* wellPath, diff --git a/ApplicationLibCode/ProjectDataModel/WellMeasurement/RimWellMeasurementInViewCollection.cpp b/ApplicationLibCode/ProjectDataModel/WellMeasurement/RimWellMeasurementInViewCollection.cpp index de0fb11e97..b94142f949 100644 --- a/ApplicationLibCode/ProjectDataModel/WellMeasurement/RimWellMeasurementInViewCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellMeasurement/RimWellMeasurementInViewCollection.cpp @@ -43,9 +43,9 @@ CAF_PDM_SOURCE_INIT( RimWellMeasurementInViewCollection, "WellMeasurementsInView //-------------------------------------------------------------------------------------------------- RimWellMeasurementInViewCollection::RimWellMeasurementInViewCollection() { - CAF_PDM_InitObject( "Well Measurements", ":/WellMeasurement16x16.png", "", "" ); + CAF_PDM_InitObject( "Well Measurements", ":/WellMeasurement16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_measurementsInView, "MeasurementKinds", "Measurement Kinds", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_measurementsInView, "MeasurementKinds", "Measurement Kinds" ); m_measurementsInView.uiCapability()->setUiTreeHidden( true ); m_isChecked = false; diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimFileWellPath.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimFileWellPath.cpp index 5d6c2799c0..8176ac1515 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimFileWellPath.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimFileWellPath.cpp @@ -26,40 +26,37 @@ RimFileWellPath::RimFileWellPath() "FileWellPath", "Well Paths Loaded From File" ); - CAF_PDM_InitFieldNoDefault( &id, "WellPathId", "Id", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &id, "WellPathId", "Id" ); id.uiCapability()->setUiReadOnly( true ); id.xmlCapability()->disableIO(); - CAF_PDM_InitFieldNoDefault( &sourceSystem, "SourceSystem", "Source System", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &sourceSystem, "SourceSystem", "Source System" ); sourceSystem.uiCapability()->setUiReadOnly( true ); sourceSystem.xmlCapability()->disableIO(); - CAF_PDM_InitFieldNoDefault( &utmZone, "UTMZone", "UTM Zone", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &utmZone, "UTMZone", "UTM Zone" ); utmZone.uiCapability()->setUiReadOnly( true ); utmZone.xmlCapability()->disableIO(); - CAF_PDM_InitFieldNoDefault( &updateDate, "WellPathUpdateDate", "Update Date", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &updateDate, "WellPathUpdateDate", "Update Date" ); updateDate.uiCapability()->setUiReadOnly( true ); updateDate.xmlCapability()->disableIO(); - CAF_PDM_InitFieldNoDefault( &updateUser, "WellPathUpdateUser", "Update User", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &updateUser, "WellPathUpdateUser", "Update User" ); updateUser.uiCapability()->setUiReadOnly( true ); updateUser.xmlCapability()->disableIO(); - CAF_PDM_InitFieldNoDefault( &m_surveyType, "WellPathSurveyType", "Survey Type", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_surveyType, "WellPathSurveyType", "Survey Type" ); m_surveyType.uiCapability()->setUiReadOnly( true ); m_surveyType.xmlCapability()->disableIO(); - CAF_PDM_InitFieldNoDefault( &m_filePath, "WellPathFilepath", "File Path", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_filePath, "WellPathFilepath", "File Path" ); m_filePath.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitFieldNoDefault( &m_filePathInCache, "WellPathFilePathInCache", "File Name", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_filePathInCache, "WellPathFilePathInCache", "File Name" ); m_filePathInCache.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitField( &m_wellPathIndexInFile, "WellPathNumberInFile", -1, "Well Number in File", "", "", "" ); + CAF_PDM_InitField( &m_wellPathIndexInFile, "WellPathNumberInFile", -1, "Well Number in File" ); m_wellPathIndexInFile.uiCapability()->setUiReadOnly( true ); CAF_PDM_InitField( &m_useAutoGeneratedPointAtSeaLevel, "UseAutoGeneratedPointAtSeaLevel", false, - "Generate Point at Sea Level", - "", - "", - "" ); + "Generate Point at Sea Level" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimModeledWellPath.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimModeledWellPath.cpp index a86ad9dbed..472d8955ed 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimModeledWellPath.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimModeledWellPath.cpp @@ -54,10 +54,7 @@ RimModeledWellPath::RimModeledWellPath() CAF_PDM_InitScriptableFieldWithScriptKeywordNoDefault( &m_geometryDefinition, "WellPathGeometryDef", "WellPathGeometry", - "Trajectory", - "", - "", - "" ); + "Trajectory" ); m_geometryDefinition = new RimWellPathGeometryDef; m_geometryDefinition->changed.connect( this, &RimModeledWellPath::onGeometryDefinitionChanged ); @@ -222,8 +219,7 @@ void RimModeledWellPath::fieldChangedByUi( const caf::PdmFieldHandle* changedFie //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimModeledWellPath::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RimModeledWellPath::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimModeledWellPath.h b/ApplicationLibCode/ProjectDataModel/WellPath/RimModeledWellPath.h index 39ae1e880f..0833836feb 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimModeledWellPath.h +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimModeledWellPath.h @@ -49,8 +49,7 @@ class RimModeledWellPath : public RimWellPath void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void updateGeometry( bool fullUpdate ); diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellIASettings.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellIASettings.cpp index f90ccae58b..bca6d5a65b 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellIASettings.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellIASettings.cpp @@ -61,37 +61,37 @@ CAF_PDM_SOURCE_INIT( RimWellIASettings, "RimWellIASettings" ); //-------------------------------------------------------------------------------------------------- RimWellIASettings::RimWellIASettings() { - CAF_PDM_InitObject( "Integrity Analysis Model Settings", ":/WellIntAnalysis.png", "", "" ); + CAF_PDM_InitObject( "Integrity Analysis Model Settings", ":/WellIntAnalysis.png" ); setName( "Model" ); - CAF_PDM_InitFieldNoDefault( &m_geomechCase, "GeomechCase", "GeoMech Case", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_geomechCase, "GeomechCase", "GeoMech Case" ); - CAF_PDM_InitFieldNoDefault( &m_baseDir, "BaseDir", "Working Directory", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_baseDir, "BaseDir", "Working Directory" ); m_baseDir.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitField( &m_startMD, "StartMeasuredDepth", 0.0, "Start MD", "", "", "" ); - CAF_PDM_InitField( &m_endMD, "EndMeasuredDepth", 0.0, "End MD", "", "", "" ); + CAF_PDM_InitField( &m_startMD, "StartMeasuredDepth", 0.0, "Start MD" ); + CAF_PDM_InitField( &m_endMD, "EndMeasuredDepth", 0.0, "End MD" ); m_startMD.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); m_endMD.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_bufferXY, "BufferXY", 5.0, "Model Size (XY)", "", "", "" ); + CAF_PDM_InitField( &m_bufferXY, "BufferXY", 5.0, "Model Size (XY)" ); - CAF_PDM_InitFieldNoDefault( &m_parameters, "ModelingParameters", "Modeling Parameters", ":/Bullet.png", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_parameters, "ModelingParameters", "Modeling Parameters", ":/Bullet.png" ); - CAF_PDM_InitFieldNoDefault( &m_csvParameters, "TimeStepParameters", "Time Step Parameters", ":/Bullet.png", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_csvParameters, "TimeStepParameters", "Time Step Parameters", ":/Bullet.png" ); - CAF_PDM_InitFieldNoDefault( &m_nameProxy, "NameProxy", "Name Proxy", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_nameProxy, "NameProxy", "Name Proxy" ); m_nameProxy.registerGetMethod( this, &RimWellIASettings::fullName ); m_nameProxy.uiCapability()->setUiReadOnly( true ); m_nameProxy.uiCapability()->setUiHidden( true ); m_nameProxy.xmlCapability()->disableIO(); - CAF_PDM_InitField( &m_showBox, "showBox", false, "Show model box", "", "", "" ); + CAF_PDM_InitField( &m_showBox, "showBox", false, "Show model box" ); - CAF_PDM_InitFieldNoDefault( &m_geostaticDate, "startDate", "Start Date (geostatic):", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_geostaticDate, "startDate", "Start Date (geostatic):" ); - CAF_PDM_InitField( &m_boxValid, "boxValid", false, "Model box is valid", "", "", "" ); + CAF_PDM_InitField( &m_boxValid, "boxValid", false, "Model box is valid" ); m_boxValid.uiCapability()->setUiHidden( true ); this->setDeletable( true ); @@ -116,7 +116,7 @@ bool RimWellIASettings::initSettings( QString& outErrmsg ) RifParameterXmlReader basicreader( RiaPreferencesGeoMech::current()->geomechWIADefaultXML() ); if ( !basicreader.parseFile( outErrmsg ) ) return false; - m_parameters.clear(); + m_parameters.deleteChildren(); for ( auto group : basicreader.parameterGroups() ) { m_parameters.push_back( group ); @@ -153,8 +153,7 @@ void RimWellIASettings::fieldChangedByUi( const caf::PdmFieldHandle* changedFiel //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimWellIASettings::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RimWellIASettings::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; @@ -526,7 +525,7 @@ void RimWellIASettings::addCsvGroup( QString name, QStringList timeSteps, double //-------------------------------------------------------------------------------------------------- void RimWellIASettings::initCsvParameters() { - m_csvParameters.clear(); + m_csvParameters.deleteChildren(); QStringList timeSteps = m_geomechCase->timeStepStrings(); diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellIASettings.h b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellIASettings.h index 1ce2f839d1..a51b53e5d5 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellIASettings.h +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellIASettings.h @@ -90,8 +90,7 @@ class RimWellIASettings : public RimCheckableNamedObject void updateVisualization(); protected: - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellIASettingsCollection.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellIASettingsCollection.cpp index fa8042fbf7..c0c77bcace 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellIASettingsCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellIASettingsCollection.cpp @@ -38,9 +38,9 @@ CAF_PDM_SOURCE_INIT( RimWellIASettingsCollection, "RimWellIASettingsCollection" //-------------------------------------------------------------------------------------------------- RimWellIASettingsCollection::RimWellIASettingsCollection() { - CAF_PDM_InitObject( "Integrity Analysis Models", ":/WellIntAnalysis.png", "", "" ); + CAF_PDM_InitObject( "Integrity Analysis Models", ":/WellIntAnalysis.png" ); - CAF_PDM_InitFieldNoDefault( &m_wellIASettings, "WellIASettings", "Settings", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wellIASettings, "WellIASettings", "Settings" ); m_wellIASettings.uiCapability()->setUiHidden( true ); m_wellIASettings.uiCapability()->setUiTreeHidden( true ); @@ -89,7 +89,7 @@ RimWellIASettings* RimWellIASettingsCollection::startWellIntegrationAnalysis( QS //-------------------------------------------------------------------------------------------------- std::vector RimWellIASettingsCollection::settings() const { - return m_wellIASettings.childObjects(); + return m_wellIASettings.children(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPath.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPath.cpp index c84d6c8ee0..764bed1621 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPath.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPath.cpp @@ -57,6 +57,7 @@ #include "RiuMainWindow.h" #include "cafPdmFieldScriptingCapability.h" +#include "cafPdmUiTreeAttributes.h" #include "cafPdmUiTreeOrdering.h" #include "cafPdmUiTreeViewEditor.h" #include "cafUtils.h" @@ -75,6 +76,15 @@ CAF_PDM_SOURCE_INIT( RimWellPath, "WellPathBase" ); //-------------------------------------------------------------------------------------------------- const char RimWellPath::SIM_WELL_NONE_UI_TEXT[] = "None"; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimWellPath::isDeletable() const +{ + // Avoid framework functions, as delete is implemented in RicDeleteWellPathFeature + return false; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -83,63 +93,63 @@ RimWellPath::RimWellPath() { CAF_PDM_InitScriptableObjectWithNameAndComment( "WellPath", ":/Well.svg", "", "", "WellPath", "A ResInsight Well Path" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_name, "Name", "Name", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_name, "Name", "Name" ); m_name.registerKeywordAlias( "WellPathName" ); m_name.uiCapability()->setUiReadOnly( true ); m_name.uiCapability()->setUiHidden( true ); m_name.xmlCapability()->disableIO(); - CAF_PDM_InitFieldNoDefault( &m_airGap, "AirGap", "Air Gap", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_airGap, "AirGap", "Air Gap" ); m_airGap.registerGetMethod( this, &RimWellPath::airGap ); m_airGap.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitFieldNoDefault( &m_datumElevation, "DatumElevation", "Datum Elevation", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_datumElevation, "DatumElevation", "Datum Elevation" ); m_datumElevation.registerGetMethod( this, &RimWellPath::datumElevation ); m_datumElevation.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitFieldNoDefault( &m_unitSystem, "UnitSystem", "Unit System", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_unitSystem, "UnitSystem", "Unit System" ); m_unitSystem.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitField( &m_simWellName, "SimWellName", QString( "" ), "Well", "", "", "" ); - CAF_PDM_InitField( &m_branchIndex, "SimBranchIndex", 0, "Branch", "", "", "" ); + CAF_PDM_InitField( &m_simWellName, "SimWellName", QString( "" ), "Well" ); + CAF_PDM_InitField( &m_branchIndex, "SimBranchIndex", 0, "Branch" ); - CAF_PDM_InitField( &m_showWellPathLabel, "ShowWellPathLabel", true, "Show Well Path Label", "", "", "" ); + CAF_PDM_InitField( &m_showWellPathLabel, "ShowWellPathLabel", true, "Show Well Path Label" ); - CAF_PDM_InitField( &m_showWellPath, "ShowWellPath", true, "Show Well Path", "", "", "" ); + CAF_PDM_InitField( &m_showWellPath, "ShowWellPath", true, "Show Well Path" ); m_showWellPath.uiCapability()->setUiHidden( true ); - CAF_PDM_InitField( &m_wellPathRadiusScaleFactor, "WellPathRadiusScale", 1.0, "Well Path Radius Scale", "", "", "" ); - CAF_PDM_InitField( &m_wellPathColor, "WellPathColor", cvf::Color3f( 0.999f, 0.333f, 0.999f ), "Well Path Color", "", "", "" ); + CAF_PDM_InitField( &m_wellPathRadiusScaleFactor, "WellPathRadiusScale", 1.0, "Well Path Radius Scale" ); + CAF_PDM_InitField( &m_wellPathColor, "WellPathColor", cvf::Color3f( 0.999f, 0.333f, 0.999f ), "Well Path Color" ); - CAF_PDM_InitFieldNoDefault( &m_completions, "Completions", "Completions", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_completions, "Completions", "Completions" ); m_completions = new RimWellPathCompletions; m_completions.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_completionSettings, "CompletionSettings", "Completion Settings", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_completionSettings, "CompletionSettings", "Completion Settings" ); m_completionSettings = new RimWellPathCompletionSettings; - CAF_PDM_InitFieldNoDefault( &m_wellLogFiles, "WellLogFiles", "Well Log Files", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wellLogFiles, "WellLogFiles", "Well Log Files" ); m_wellLogFiles.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_3dWellLogCurves, "CollectionOf3dWellLogCurves", "3D Track", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_3dWellLogCurves, "CollectionOf3dWellLogCurves", "3D Track" ); m_3dWellLogCurves = new Rim3dWellLogCurveCollection; m_3dWellLogCurves.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitField( &m_formationKeyInFile, "WellPathFormationKeyInFile", QString( "" ), "Key in File", "", "", "" ); + CAF_PDM_InitField( &m_formationKeyInFile, "WellPathFormationKeyInFile", QString( "" ), "Key in File" ); m_formationKeyInFile.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitFieldNoDefault( &m_wellPathFormationFilePath, "WellPathFormationFilePath", "File Path", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wellPathFormationFilePath, "WellPathFormationFilePath", "File Path" ); m_wellPathFormationFilePath.uiCapability()->setUiReadOnly( true ); - CAF_PDM_InitFieldNoDefault( &m_wellPathAttributes, "WellPathAttributes", "Casing Design Rubbish", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wellPathAttributes, "WellPathAttributes", "Casing Design Rubbish" ); m_wellPathAttributes = new RimWellPathAttributeCollection; m_wellPathAttributes->uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_wellPathTieIn, "WellPathTieIn", "well Path Tie-In", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wellPathTieIn, "WellPathTieIn", "well Path Tie-In" ); m_wellPathTieIn = new RimWellPathTieIn; m_wellPathTieIn->connectWellPaths( nullptr, this, 0.0 ); - CAF_PDM_InitFieldNoDefault( &m_wellIASettingsCollection, "WellIASettings", "Integrity Analysis Settings", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wellIASettingsCollection, "WellIASettings", "Integrity Analysis Settings" ); m_wellIASettingsCollection = new RimWellIASettingsCollection(); this->setDeletable( true ); @@ -485,8 +495,7 @@ void RimWellPath::fieldChangedByUi( const caf::PdmFieldHandle* changedField, con //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimWellPath::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RimWellPath::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; @@ -921,7 +930,7 @@ void RimWellPath::detachWellLogFile( RimWellLogFile* logFileInfo ) { if ( m_wellLogFiles[i] == pdmObject ) { - m_wellLogFiles.removeChildObject( pdmObject ); + m_wellLogFiles.removeChild( pdmObject ); break; } } diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPath.h b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPath.h index 0cd051badd..ca007ddf82 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPath.h +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPath.h @@ -175,10 +175,10 @@ class RimWellPath : public caf::PdmObject, public RimWellPathComponentInterface caf::PdmFieldHandle* userDescriptionField() override; caf::PdmFieldHandle* objectToggleField() override; + bool isDeletable() const override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void initAfterRead() override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName ) override; diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathAttribute.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathAttribute.cpp index 90bb5711d5..5d84d1d02d 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathAttribute.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathAttribute.cpp @@ -38,11 +38,11 @@ double RimWellPathAttribute::MIN_DIAMETER_IN_INCHES = 7.0; //-------------------------------------------------------------------------------------------------- RimWellPathAttribute::RimWellPathAttribute() { - CAF_PDM_InitObject( "RimWellPathAttribute", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_type, "CompletionType", "Type ", "", "", "" ); - CAF_PDM_InitField( &m_startMD, "DepthStart", -1.0, "Start MD", "", "", "" ); - CAF_PDM_InitField( &m_endMD, "DepthEnd", -1.0, "End MD", "", "", "" ); - CAF_PDM_InitField( &m_diameterInInches, "DiameterInInches", MAX_DIAMETER_IN_INCHES, "Diameter", "", "", "" ); + CAF_PDM_InitObject( "RimWellPathAttribute" ); + CAF_PDM_InitFieldNoDefault( &m_type, "CompletionType", "Type " ); + CAF_PDM_InitField( &m_startMD, "DepthStart", -1.0, "Start MD" ); + CAF_PDM_InitField( &m_endMD, "DepthEnd", -1.0, "End MD" ); + CAF_PDM_InitField( &m_diameterInInches, "DiameterInInches", MAX_DIAMETER_IN_INCHES, "Diameter" ); m_type = RiaDefines::WellPathComponentType::CASING; m_diameterInInches.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); } @@ -202,8 +202,7 @@ bool RimWellPathAttribute::isDiameterSupported() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList - RimWellPathAttribute::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) +QList RimWellPathAttribute::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; if ( fieldNeedingOptions == &m_type ) diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathAttribute.h b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathAttribute.h index 31128a6bb5..f682505d1a 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathAttribute.h +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathAttribute.h @@ -60,8 +60,7 @@ class RimWellPathAttribute : public caf::PdmObject, public RimWellPathComponentI static std::set supportedDiameters( RiaDefines::WellPathComponentType type ); bool isDiameterSupported() const; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; static QString generateInchesLabel( double diameter ); void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathAttributeCollection.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathAttributeCollection.cpp index 61bac96986..36731c0373 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathAttributeCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathAttributeCollection.cpp @@ -32,9 +32,9 @@ CAF_PDM_SOURCE_INIT( RimWellPathAttributeCollection, "WellPathAttributes" ); //-------------------------------------------------------------------------------------------------- RimWellPathAttributeCollection::RimWellPathAttributeCollection() { - CAF_PDM_InitObject( "Casing Design", ":/CasingDesign16x16", "", "" ); + CAF_PDM_InitObject( "Casing Design", ":/CasingDesign16x16" ); - CAF_PDM_InitFieldNoDefault( &m_attributes, "Attributes", "Casing Design Attributes", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_attributes, "Attributes", "Casing Design Attributes" ); m_attributes.uiCapability()->setUiEditorTypeName( caf::PdmUiTableViewEditor::uiEditorTypeName() ); m_attributes.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); m_attributes.uiCapability()->setCustomContextMenuEnabled( true ); @@ -82,7 +82,7 @@ std::vector RimWellPathAttributeCollection::attributes() //-------------------------------------------------------------------------------------------------- void RimWellPathAttributeCollection::insertAttribute( RimWellPathAttribute* insertBefore, RimWellPathAttribute* attribute ) { - size_t index = m_attributes.index( insertBefore ); + size_t index = m_attributes.indexOf( insertBefore ); if ( index < m_attributes.size() ) m_attributes.insert( index, attribute ); else @@ -96,7 +96,7 @@ void RimWellPathAttributeCollection::insertAttribute( RimWellPathAttribute* inse //-------------------------------------------------------------------------------------------------- void RimWellPathAttributeCollection::deleteAttribute( RimWellPathAttribute* attributeToDelete ) { - m_attributes.removeChildObject( attributeToDelete ); + m_attributes.removeChild( attributeToDelete ); delete attributeToDelete; this->updateAllReferringTracks(); @@ -107,7 +107,7 @@ void RimWellPathAttributeCollection::deleteAttribute( RimWellPathAttribute* attr //-------------------------------------------------------------------------------------------------- void RimWellPathAttributeCollection::deleteAllAttributes() { - m_attributes.deleteAllChildObjects(); + m_attributes.deleteChildren(); this->updateAllReferringTracks(); } diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp index aa2b59d153..e5631a986a 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp @@ -93,39 +93,36 @@ RimWellPathCollection::RimWellPathCollection() "WellPathCollection", "Collection of Well Paths" ); - CAF_PDM_InitField( &isActive, "Active", true, "Active", "", "", "" ); + CAF_PDM_InitField( &isActive, "Active", true, "Active" ); isActive.uiCapability()->setUiHidden( true ); - CAF_PDM_InitField( &showWellPathLabel, "ShowWellPathLabel", true, "Show Well Path Labels", "", "", "" ); + CAF_PDM_InitField( &showWellPathLabel, "ShowWellPathLabel", true, "Show Well Path Labels" ); cvf::Color3f defWellLabelColor = RiaPreferences::current()->defaultWellLabelColor(); - CAF_PDM_InitField( &wellPathLabelColor, "WellPathLabelColor", defWellLabelColor, "Well label color", "", "", "" ); + CAF_PDM_InitField( &wellPathLabelColor, "WellPathLabelColor", defWellLabelColor, "Well label color" ); CAF_PDM_InitField( &wellPathVisibility, "GlobalWellPathVisibility", WellVisibilityEnum( ALL_ON ), - "Global Well Path Visibility", - "", - "", - "" ); + "Global Well Path Visibility" ); - CAF_PDM_InitField( &wellPathRadiusScaleFactor, "WellPathRadiusScale", 0.1, "Well Path Radius Scale", "", "", "" ); - CAF_PDM_InitField( &wellPathCrossSectionVertexCount, "WellPathVertexCount", 12, "Well Path Vertex Count", "", "", "" ); + CAF_PDM_InitField( &wellPathRadiusScaleFactor, "WellPathRadiusScale", 0.1, "Well Path Radius Scale" ); + CAF_PDM_InitField( &wellPathCrossSectionVertexCount, "WellPathVertexCount", 12, "Well Path Vertex Count" ); wellPathCrossSectionVertexCount.xmlCapability()->disableIO(); wellPathCrossSectionVertexCount.uiCapability()->setUiHidden( true ); - CAF_PDM_InitField( &wellPathClip, "WellPathClip", true, "Clip Well Paths", "", "", "" ); - CAF_PDM_InitField( &wellPathClipZDistance, "WellPathClipZDistance", 100, "Well Path Clipping Depth Distance", "", "", "" ); + CAF_PDM_InitField( &wellPathClip, "WellPathClip", true, "Clip Well Paths" ); + CAF_PDM_InitField( &wellPathClipZDistance, "WellPathClipZDistance", 100, "Well Path Clipping Depth Distance" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_wellPaths, "WellPaths", "Well Paths", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_wellPaths, "WellPaths", "Well Paths" ); m_wellPaths.uiCapability()->setUiTreeHidden( true ); m_wellPaths.uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_wellMeasurements, "WellMeasurements", "Measurements", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wellMeasurements, "WellMeasurements", "Measurements" ); m_wellMeasurements = new RimWellMeasurementCollection; m_wellMeasurements.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_wellPathNodes, "WellPathNodes", "Well Path Nodes", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wellPathNodes, "WellPathNodes", "Well Path Nodes" ); m_wellPathNodes.xmlCapability()->disableIO(); m_wellPathImporter = std::make_unique(); @@ -297,7 +294,7 @@ void RimWellPathCollection::addWellPath( gsl::not_null wellPath, b //-------------------------------------------------------------------------------------------------- std::vector RimWellPathCollection::allWellPaths() const { - return m_wellPaths.childObjects(); + return m_wellPaths.children(); } //-------------------------------------------------------------------------------------------------- @@ -575,8 +572,8 @@ RimWellPath* RimWellPathCollection::tryFindMatchingWellPath( const QString& well //-------------------------------------------------------------------------------------------------- void RimWellPathCollection::deleteAllWellPaths() { - m_wellPaths.deleteAllChildObjects(); - m_wellPathNodes.deleteAllChildObjects(); + m_wellPaths.deleteChildren(); + m_wellPathNodes.deleteChildren(); m_wellPathImporter->clear(); updateAllRequiredEditors(); @@ -587,7 +584,7 @@ void RimWellPathCollection::deleteAllWellPaths() //-------------------------------------------------------------------------------------------------- void RimWellPathCollection::deleteWell( RimWellPath* wellPath ) { - m_wellPaths.removeChildObject( wellPath ); + m_wellPaths.removeChild( wellPath ); delete wellPath; } @@ -792,9 +789,9 @@ caf::AppEnum RimWellPathCollection::findUnitSyste //-------------------------------------------------------------------------------------------------- void RimWellPathCollection::rebuildWellPathNodes() { - m_wellPathNodes.deleteAllChildObjects(); + m_wellPathNodes.deleteChildren(); - std::map> rootWells = wellPathsForWellNameStem( m_wellPaths.childObjects() ); + std::map> rootWells = wellPathsForWellNameStem( m_wellPaths.children() ); for ( auto [groupName, wellPathGroup] : rootWells ) { if ( groupName == unGroupedText() ) diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathGeometryDef.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathGeometryDef.cpp index 1ea4923911..7ff2ab11e4 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathGeometryDef.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathGeometryDef.cpp @@ -68,62 +68,47 @@ RimWellPathGeometryDef::RimWellPathGeometryDef() "ReferencePosUtmXyd", "ReferencePoint", cvf::Vec3d( 0, 0, 0 ), - "UTM Reference Point", - "", - "", - "" ); + "UTM Reference Point" ); - CAF_PDM_InitScriptableField( &m_airGap, "AirGap", 0.0, "Air Gap", "", "", "" ); + CAF_PDM_InitScriptableField( &m_airGap, "AirGap", 0.0, "Air Gap" ); m_airGap.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); - CAF_PDM_InitScriptableField( &m_mdAtFirstTarget, "MdAtFirstTarget", 0.0, "MD at First Target", "", "", "" ); + CAF_PDM_InitScriptableField( &m_mdAtFirstTarget, "MdAtFirstTarget", 0.0, "MD at First Target" ); m_mdAtFirstTarget.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() ); - CAF_PDM_InitScriptableFieldNoDefault( &m_wellTargets, "WellPathTargets", "Well Targets", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_wellTargets, "WellPathTargets", "Well Targets" ); m_wellTargets.uiCapability()->setUiEditorTypeName( caf::PdmUiTableViewEditor::uiEditorTypeName() ); m_wellTargets.uiCapability()->setUiTreeChildrenHidden( true ); m_wellTargets.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); m_wellTargets.uiCapability()->setCustomContextMenuEnabled( true ); - CAF_PDM_InitField( &m_showAbsolutePosForWellTargets, "ShowAbsolutePosForWellTargets", false, "Show UTM Coords", "", "", "" ); + CAF_PDM_InitField( &m_showAbsolutePosForWellTargets, "ShowAbsolutePosForWellTargets", false, "Show UTM Coords" ); CAF_PDM_InitField( &m_useTopLevelWellReferencePoint, "UseTopLevelWellReferencePoint", false, - "Use Top Level Well Reference Point", - "", - "", - "" ); + "Use Top Level Well Reference Point" ); CAF_PDM_InitScriptableField( &m_useAutoGeneratedTargetAtSeaLevel, "UseAutoGeneratedTargetAtSeaLevel", true, - "Generate Target at Sea Level", - "", - "", - "" ); - - CAF_PDM_InitScriptableField( &m_linkReferencePointUpdates, - "LinkReferencePointUpdates", - false, - "Link Reference Point", - "", - "", - "" ); - - CAF_PDM_InitScriptableFieldNoDefault( &m_autoTargetAtSeaLevel, "AutoGeneratedTarget", "Auto Generated Target", "", "", "" ); + "Generate Target at Sea Level" ); + + CAF_PDM_InitScriptableField( &m_linkReferencePointUpdates, "LinkReferencePointUpdates", false, "Link Reference Point" ); + + CAF_PDM_InitScriptableFieldNoDefault( &m_autoTargetAtSeaLevel, "AutoGeneratedTarget", "Auto Generated Target" ); m_autoTargetAtSeaLevel = new RimWellPathTarget; m_autoTargetAtSeaLevel->setEnabled( false ); - CAF_PDM_InitScriptableField( &m_isAttachedToParentWell, "AttachedToParentWell", false, "Attached to Parent Well", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_fixedWellPathPoints, "FixedWellPathPoints", "", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_fixedMeasuredDepths, "FixedMeasuredDepths", "", "", "", "" ); + CAF_PDM_InitScriptableField( &m_isAttachedToParentWell, "AttachedToParentWell", false, "Attached to Parent Well" ); + CAF_PDM_InitFieldNoDefault( &m_fixedWellPathPoints, "FixedWellPathPoints", "" ); + CAF_PDM_InitFieldNoDefault( &m_fixedMeasuredDepths, "FixedMeasuredDepths", "" ); - CAF_PDM_InitField( &m_pickPointsEnabled, "m_pickPointsEnabled", false, "", "", "", "" ); + CAF_PDM_InitField( &m_pickPointsEnabled, "m_pickPointsEnabled", false, "" ); caf::PdmUiPushButtonEditor::configureEditorForField( &m_pickPointsEnabled ); - CAF_PDM_InitScriptableField( &m_showSpheres, "ShowSpheres", true, "Spheres", "", "", "" ); - CAF_PDM_InitField( &m_sphereColor, "SphereColor", cvf::Color3f( cvf::Color3f::CEETRON ), "Sphere Color", "", "", "" ); - CAF_PDM_InitField( &m_sphereRadiusFactor, "SphereRadiusFactor", 0.15, "Sphere Radius Factor", "", "", "" ); + CAF_PDM_InitScriptableField( &m_showSpheres, "ShowSpheres", true, "Spheres" ); + CAF_PDM_InitField( &m_sphereColor, "SphereColor", cvf::Color3f( cvf::Color3f::CEETRON ), "Sphere Color" ); + CAF_PDM_InitField( &m_sphereRadiusFactor, "SphereRadiusFactor", 0.15, "Sphere Radius Factor" ); } //-------------------------------------------------------------------------------------------------- @@ -390,7 +375,7 @@ std::pair //-------------------------------------------------------------------------------------------------- void RimWellPathGeometryDef::insertTarget( const RimWellPathTarget* targetToInsertBefore, RimWellPathTarget* targetToInsert ) { - size_t index = m_wellTargets.index( targetToInsertBefore ); + size_t index = m_wellTargets.indexOf( targetToInsertBefore ); if ( index < m_wellTargets.size() ) m_wellTargets.insert( index, targetToInsert ); else @@ -404,7 +389,7 @@ void RimWellPathGeometryDef::insertTarget( const RimWellPathTarget* targetToInse //-------------------------------------------------------------------------------------------------- void RimWellPathGeometryDef::deleteTarget( RimWellPathTarget* targetTodelete ) { - m_wellTargets.removeChildObject( targetTodelete ); + m_wellTargets.removeChild( targetTodelete ); delete targetTodelete; } @@ -413,7 +398,7 @@ void RimWellPathGeometryDef::deleteTarget( RimWellPathTarget* targetTodelete ) //-------------------------------------------------------------------------------------------------- void RimWellPathGeometryDef::deleteAllTargets() { - m_wellTargets.deleteAllChildObjects(); + m_wellTargets.deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -423,7 +408,7 @@ RimWellPathTarget* RimWellPathGeometryDef::appendTarget() { RimWellPathTarget* wellPathTarget = nullptr; - auto targets = m_wellTargets.childObjects(); + auto targets = m_wellTargets.children(); if ( targets.empty() ) { wellPathTarget = new RimWellPathTarget; @@ -494,8 +479,7 @@ void RimWellPathGeometryDef::updateWellPathVisualization( bool fullUpdate ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList - RimWellPathGeometryDef::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) +QList RimWellPathGeometryDef::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; @@ -639,28 +623,16 @@ RiaLineArcWellPathCalculator RimWellPathGeometryDef::lineArcWellPathCalculator() for ( size_t tIdx = 0; tIdx < activeTargets.size(); ++tIdx ) { - activeTargets[tIdx]->flagRadius1AsIncorrect( targetStatuses[tIdx].isRadius1Editable, false, 0 ); - activeTargets[tIdx]->flagRadius2AsIncorrect( targetStatuses[tIdx].isRadius2Editable, false, 0 ); + activeTargets[tIdx]->setDerivedTangent( targetStatuses[tIdx].resultAzimuthRadians, + targetStatuses[tIdx].resultInclinationRadians ); - if ( targetStatuses[tIdx].hasDerivedTangent ) - { - activeTargets[tIdx]->setDerivedTangent( targetStatuses[tIdx].resultAzimuth, - targetStatuses[tIdx].resultInclination ); - } + activeTargets[tIdx]->setRadius1Data( targetStatuses[tIdx].isRadius1Editable, + targetStatuses[tIdx].hasOverriddenRadius1, + targetStatuses[tIdx].resultRadius1 ); - if ( targetStatuses[tIdx].hasOverriddenRadius1 ) - { - activeTargets[tIdx]->flagRadius1AsIncorrect( targetStatuses[tIdx].isRadius1Editable, - true, - targetStatuses[tIdx].resultRadius1 ); - } - - if ( targetStatuses[tIdx].hasOverriddenRadius2 ) - { - activeTargets[tIdx]->flagRadius2AsIncorrect( targetStatuses[tIdx].isRadius2Editable, - true, - targetStatuses[tIdx].resultRadius2 ); - } + activeTargets[tIdx]->setRadius2Data( targetStatuses[tIdx].isRadius2Editable, + targetStatuses[tIdx].hasOverriddenRadius2, + targetStatuses[tIdx].resultRadius2 ); } return wellPathCalculator; diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathGeometryDef.h b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathGeometryDef.h index 50b2a66802..772e7f44e1 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathGeometryDef.h +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathGeometryDef.h @@ -111,8 +111,7 @@ class RimWellPathGeometryDef : public caf::PdmObject void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName ) override; void initAfterRead() override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; RiaLineArcWellPathCalculator lineArcWellPathCalculator() const; diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathGroup.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathGroup.cpp index f1afeb8997..3bdc04eab8 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathGroup.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathGroup.cpp @@ -37,9 +37,9 @@ CAF_PDM_SOURCE_INIT( RimWellPathGroup, "WellPathGroup" ); //-------------------------------------------------------------------------------------------------- RimWellPathGroup::RimWellPathGroup() { - CAF_PDM_InitObject( "Well Path Group", ":/WellPathGroup.svg", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_childWellPaths, "ChildWellPaths", "Child Well Paths", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_groupName, "GroupName", "Group Name", "", "", "" ); + CAF_PDM_InitObject( "Well Path Group", ":/WellPathGroup.svg" ); + CAF_PDM_InitFieldNoDefault( &m_childWellPaths, "ChildWellPaths", "Child Well Paths" ); + CAF_PDM_InitFieldNoDefault( &m_groupName, "GroupName", "Group Name" ); CAF_PDM_InitField( &m_addValveAtConnection, "AddValveAtConnection", @@ -48,7 +48,7 @@ RimWellPathGroup::RimWellPathGroup() "", "Should an outlet valve be added to branches for MSW export?", "" ); - CAF_PDM_InitFieldNoDefault( &m_valve, "Valve", "Branch Outlet Valve", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_valve, "Valve", "Branch Outlet Valve" ); m_valve = new RimWellPathValve; m_groupName.registerGetMethod( this, &RimWellPathGroup::createGroupName ); @@ -99,7 +99,7 @@ void RimWellPathGroup::addChildWellPath( RimWellPath* wellPath ) //-------------------------------------------------------------------------------------------------- std::vector RimWellPathGroup::childWellPaths() const { - return m_childWellPaths.childObjects(); + return m_childWellPaths.children(); } //-------------------------------------------------------------------------------------------------- @@ -123,7 +123,7 @@ bool RimWellPathGroup::hasChildWellPath( RimWellPath* wellPath ) //-------------------------------------------------------------------------------------------------- void RimWellPathGroup::removeChildWellPath( RimWellPath* wellPath ) { - m_childWellPaths.removeChildObject( wellPath ); + m_childWellPaths.removeChild( wellPath ); RimWellPath::copyCompletionSettings( this, wellPath ); if ( auto geometry = wellPath->wellPathGeometry(); geometry ) @@ -145,7 +145,7 @@ void RimWellPathGroup::removeChildWellPath( RimWellPath* wellPath ) //-------------------------------------------------------------------------------------------------- void RimWellPathGroup::removeAllChildWellPaths() { - auto childWellPaths = m_childWellPaths.childObjects(); + auto childWellPaths = m_childWellPaths.children(); for ( auto wellPath : childWellPaths ) { removeChildWellPath( wellPath ); @@ -252,7 +252,7 @@ void RimWellPathGroup::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin std::vector RimWellPathGroup::wellPathGeometries() const { std::vector allGeometries; - for ( const auto child : m_childWellPaths() ) + for ( const auto& child : m_childWellPaths() ) { if ( child->wellPathGeometry() ) { @@ -419,7 +419,7 @@ void RimWellPathGroup::makeMoreLevelsIfNecessary() RimWellPathGroup* newGroup = new RimWellPathGroup; for ( auto wellPath : wellPaths ) { - m_childWellPaths().removeChildObject( wellPath ); + m_childWellPaths().removeChild( wellPath ); newGroup->addChildWellPath( wellPath ); newGroup->wellPathGeometry()->setUniqueStartAndEndIndex( childStartIndex, std::numeric_limits::max() ); diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathTarget.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathTarget.cpp index 9087b479a4..571cf151c9 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathTarget.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathTarget.cpp @@ -23,6 +23,7 @@ #include "RigWellPath.h" #include "RimModeledWellPath.h" +#include "RimProject.h" #include "RimWellPath.h" #include "RimWellPathGeometryDef.h" @@ -51,10 +52,6 @@ void caf::AppEnum::setUp() //-------------------------------------------------------------------------------------------------- RimWellPathTarget::RimWellPathTarget() : moved( this ) - , m_targetType( TargetTypeEnum::POINT ) - , m_targetPointXYD( cvf::Vec3d::ZERO ) - , m_azimuth( 0.0 ) - , m_inclination( 0.0 ) , m_isFullUpdateEnabled( true ) { CAF_PDM_InitScriptableObjectWithNameAndComment( "Well Target", @@ -64,28 +61,41 @@ RimWellPathTarget::RimWellPathTarget() "WellPathTarget", "Class containing the Well Target definition" ); - CAF_PDM_InitField( &m_isEnabled, "IsEnabled", true, "", "", "", "" ); - CAF_PDM_InitField( &m_isLocked, "IsLocked", false, "", "", "", "" ); - m_isLocked.uiCapability()->setUiHidden( true ); + CAF_PDM_InitField( &m_isEnabled, "IsEnabled", true, "" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_targetPointXYD, "TargetPoint", "Relative Coord", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_targetPointForDisplay, "TargetPointForDisplay", "UTM Coord", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_targetPointXYD, "TargetPoint", "Relative Coord" ); + CAF_PDM_InitFieldNoDefault( &m_targetPointForDisplay, "TargetPointForDisplay", "UTM Coord" ); m_targetPointForDisplay.registerGetMethod( this, &RimWellPathTarget::targetPointForDisplayXYD ); m_targetPointForDisplay.registerSetMethod( this, &RimWellPathTarget::setTargetPointFromDisplayCoord ); - CAF_PDM_InitScriptableFieldNoDefault( &m_targetMeasuredDepth, "TargetMeasuredDepth", "MD", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_targetMeasuredDepth, "TargetMeasuredDepth", "MD" ); m_targetMeasuredDepth.registerGetMethod( this, &RimWellPathTarget::measuredDepth ); CAF_PDM_InitScriptableField( &m_dogleg1, "Dogleg1", 3.0, "DL in", "", "[deg/30m]", "" ); CAF_PDM_InitScriptableField( &m_dogleg2, "Dogleg2", 3.0, "DL out", "", "[deg/30m]", "" ); - CAF_PDM_InitFieldNoDefault( &m_targetType, "TargetType", "Type", "", "", "" ); - m_targetType.uiCapability()->setUiHidden( true ); + CAF_PDM_InitScriptableField( &m_useFixedAzimuth, "UseFixedAzimuth", false, "Azi" ); + CAF_PDM_InitScriptableField( &m_azimuthDeg, "Azimuth", 0.0, "Azi(deg)" ); - CAF_PDM_InitField( &m_hasTangentConstraintUiField, "HasTangentConstraint", false, "Dir", "", "", "" ); - m_hasTangentConstraintUiField.xmlCapability()->disableIO(); - CAF_PDM_InitScriptableField( &m_azimuth, "Azimuth", 0.0, "Azi(deg)", "", "", "" ); - CAF_PDM_InitScriptableField( &m_inclination, "Inclination", 0.0, "Inc(deg)", "", "", "" ); + CAF_PDM_InitScriptableField( &m_useFixedInclination, "UseFixedInclination", false, "Inc" ); + CAF_PDM_InitScriptableField( &m_inclinationDeg, "Inclination", 0.0, "Inc(deg)" ); + + CAF_PDM_InitScriptableField( &m_estimatedDogleg1, "EstimatedDogleg1", 0.0, "Est DL in", "", "[deg/30m]", "" ); + m_estimatedDogleg1.uiCapability()->setUiReadOnly( true ); + CAF_PDM_InitScriptableField( &m_estimatedDogleg2, "EstimatedDogleg2", 0.0, "Est DL out", "", "[deg/30m]", "" ); + m_estimatedDogleg2.uiCapability()->setUiReadOnly( true ); + CAF_PDM_InitScriptableField( &m_estimatedAzimuthDeg, "EstimatedAzimuth", 0.0, "Est Azi(deg)" ); + m_estimatedAzimuthDeg.uiCapability()->setUiReadOnly( true ); + CAF_PDM_InitScriptableField( &m_estimatedInclinationDeg, "EstimatedInclination", 0.0, "Est Inc(deg)" ); + m_estimatedInclinationDeg.uiCapability()->setUiReadOnly( true ); + + CAF_PDM_InitFieldNoDefault( &m_targetType_OBSOLETE, "TargetType", "Type" ); + m_targetType_OBSOLETE.uiCapability()->setUiHidden( true ); + m_targetType_OBSOLETE.xmlCapability()->setIOWritable( false ); + + CAF_PDM_InitField( &m_hasTangentConstraintUiField_OBSOLETE, "HasTangentConstraint", false, "Dir" ); + m_hasTangentConstraintUiField_OBSOLETE.xmlCapability()->setIOWritable( false ); + m_hasTangentConstraintUiField_OBSOLETE.uiCapability()->setUiHidden( true ); } //-------------------------------------------------------------------------------------------------- @@ -124,10 +134,12 @@ void RimWellPathTarget::setPointXYZ( const cvf::Vec3d& point ) //-------------------------------------------------------------------------------------------------- void RimWellPathTarget::setAsPointTargetXYD( const cvf::Vec3d& point ) { - m_targetType = TargetTypeEnum::POINT; m_targetPointXYD = point; - m_azimuth = 0.0; - m_inclination = 0.0; + + m_useFixedAzimuth = false; + m_useFixedInclination = false; + m_azimuthDeg = 0.0; + m_inclinationDeg = 0.0; } //-------------------------------------------------------------------------------------------------- @@ -135,10 +147,12 @@ void RimWellPathTarget::setAsPointTargetXYD( const cvf::Vec3d& point ) //-------------------------------------------------------------------------------------------------- void RimWellPathTarget::setAsPointTargetXYZ( const cvf::Vec3d& point ) { - m_targetType = TargetTypeEnum::POINT; m_targetPointXYD = cvf::Vec3d( point.x(), point.y(), -point.z() ); - m_azimuth = 0.0; - m_inclination = 0.0; + + m_useFixedAzimuth = false; + m_useFixedInclination = false; + m_azimuthDeg = 0.0; + m_inclinationDeg = 0.0; } //-------------------------------------------------------------------------------------------------- @@ -153,24 +167,46 @@ void RimWellPathTarget::setAsPointXYZAndTangentTarget( const cvf::Vec3d& point, //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellPathTarget::setAsPointXYZAndTangentTarget( const cvf::Vec3d& point, double azimuth, double inclination ) +void RimWellPathTarget::setAsPointXYZAndTangentTarget( const cvf::Vec3d& point, double azimuthRadians, double inclinationRadians ) { - m_targetType = TargetTypeEnum::POINT_AND_TANGENT; + m_targetType_OBSOLETE = TargetTypeEnum::POINT_AND_TANGENT; + m_targetPointXYD = cvf::Vec3d( point.x(), point.y(), -point.z() ); - m_azimuth = cvf::Math::toDegrees( azimuth ); - m_inclination = cvf::Math::toDegrees( inclination ); + + m_useFixedAzimuth = true; + m_useFixedInclination = true; + m_azimuthDeg = cvf::Math::toDegrees( azimuthRadians ); + m_inclinationDeg = cvf::Math::toDegrees( inclinationRadians ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellPathTarget::setDerivedTangent( double azimuth, double inclination ) +void RimWellPathTarget::setFixedAzimuth( double fixedAzimuthDeg ) { - if ( m_targetType == TargetTypeEnum::POINT ) - { - m_azimuth = cvf::Math::toDegrees( azimuth ); - m_inclination = cvf::Math::toDegrees( inclination ); - } + m_useFixedAzimuth = true; + m_azimuthDeg = fixedAzimuthDeg; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellPathTarget::setFixedInclination( double fixedInclinationDeg ) +{ + m_useFixedInclination = true; + m_inclinationDeg = fixedInclinationDeg; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellPathTarget::setDerivedTangent( double azimuthRadians, double inclinationRadians ) +{ + m_estimatedAzimuthDeg = cvf::Math::toDegrees( azimuthRadians ); + m_estimatedInclinationDeg = cvf::Math::toDegrees( inclinationRadians ); + + if ( !m_useFixedAzimuth ) m_azimuthDeg = cvf::Math::toDegrees( azimuthRadians ); + if ( !m_useFixedInclination ) m_inclinationDeg = cvf::Math::toDegrees( inclinationRadians ); } //-------------------------------------------------------------------------------------------------- @@ -190,24 +226,17 @@ RiaLineArcWellPathCalculator::WellTarget RimWellPathTarget::wellTargetData() { RiaLineArcWellPathCalculator::WellTarget targetData; - targetData.targetPointXYZ = targetPointXYZ(); - targetData.isTangentConstrained = ( targetType() == TargetTypeEnum::POINT_AND_TANGENT ); - targetData.azimuth = azimuth(); - targetData.inclination = inclination(); - targetData.radius1 = radius1(); - targetData.radius2 = radius2(); + targetData.targetPointXYZ = targetPointXYZ(); + targetData.isAzimuthConstrained = m_useFixedAzimuth(); + targetData.isInclinationConstrained = m_useFixedInclination(); + targetData.azimuthRadians = azimuthRadians(); + targetData.inclinationRadians = inclinationRadians(); + targetData.radius1 = radius1(); + targetData.radius2 = radius2(); return targetData; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimWellPathTarget::TargetTypeEnum RimWellPathTarget::targetType() const -{ - return m_targetType(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -221,11 +250,11 @@ cvf::Vec3d RimWellPathTarget::targetPointXYZ() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double RimWellPathTarget::azimuth() const +double RimWellPathTarget::azimuthRadians() const { - if ( m_targetType() == TargetTypeEnum::POINT_AND_TANGENT ) + if ( m_useFixedAzimuth() ) { - return cvf::Math::toRadians( m_azimuth ); + return cvf::Math::toRadians( m_azimuthDeg ); } return std::numeric_limits::infinity(); @@ -234,11 +263,11 @@ double RimWellPathTarget::azimuth() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double RimWellPathTarget::inclination() const +double RimWellPathTarget::inclinationRadians() const { - if ( m_targetType() == TargetTypeEnum::POINT_AND_TANGENT ) + if ( m_useFixedInclination() ) { - return cvf::Math::toRadians( m_inclination ); + return cvf::Math::toRadians( m_inclinationDeg ); } return std::numeric_limits::infinity(); @@ -249,8 +278,8 @@ double RimWellPathTarget::inclination() const //-------------------------------------------------------------------------------------------------- cvf::Vec3d RimWellPathTarget::tangent() const { - double aziRad = cvf::Math::toRadians( m_azimuth ); - double incRad = cvf::Math::toRadians( m_inclination ); + double aziRad = cvf::Math::toRadians( m_azimuthDeg ); + double incRad = cvf::Math::toRadians( m_inclinationDeg ); return RiaOffshoreSphericalCoords::unitVectorFromAziInc( aziRad, incRad ); } @@ -294,21 +323,23 @@ double doglegFromRadius( double radius ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellPathTarget::flagRadius1AsIncorrect( bool isEditable, bool isIncorrect, double actualRadius ) +void RimWellPathTarget::setRadius1Data( bool isEditable, bool isIncorrect, double actualRadius ) { + double estimatedDogLeg = doglegFromRadius( actualRadius ); + m_estimatedDogleg1 = estimatedDogLeg; + if ( isIncorrect ) { if ( actualRadius < radius1() ) { m_dogleg1.uiCapability()->setUiContentTextColor( Qt::red ); - m_dogleg1.uiCapability()->setUiToolTip( "Actual Dogleg: " + QString::number( doglegFromRadius( actualRadius ) ) + + m_dogleg1.uiCapability()->setUiToolTip( "Actual Dogleg: " + QString::number( estimatedDogLeg ) + "\nThe dogleg constraint is not satisfied!" ); } else { m_dogleg1.uiCapability()->setUiContentTextColor( Qt::darkGreen ); - m_dogleg1.uiCapability()->setUiToolTip( "Actual Dogleg: " + - QString::number( doglegFromRadius( actualRadius ) ) ); + m_dogleg1.uiCapability()->setUiToolTip( "Actual Dogleg: " + QString::number( estimatedDogLeg ) ); } } else @@ -323,21 +354,23 @@ void RimWellPathTarget::flagRadius1AsIncorrect( bool isEditable, bool isIncorrec //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellPathTarget::flagRadius2AsIncorrect( bool isEditable, bool isIncorrect, double actualRadius ) +void RimWellPathTarget::setRadius2Data( bool isEditable, bool isIncorrect, double actualRadius ) { + double estimatedDogLeg = doglegFromRadius( actualRadius ); + m_estimatedDogleg2 = estimatedDogLeg; + if ( isIncorrect ) { if ( actualRadius < radius2() ) { m_dogleg2.uiCapability()->setUiContentTextColor( Qt::red ); - m_dogleg2.uiCapability()->setUiToolTip( "Actual Dogleg: " + QString::number( doglegFromRadius( actualRadius ) ) + + m_dogleg2.uiCapability()->setUiToolTip( "Actual Dogleg: " + QString::number( estimatedDogLeg ) + "\nThe dogleg constraint is not satisfied!" ); } else { m_dogleg2.uiCapability()->setUiContentTextColor( Qt::darkGreen ); - m_dogleg2.uiCapability()->setUiToolTip( "Actual Dogleg: " + - QString::number( doglegFromRadius( actualRadius ) ) ); + m_dogleg2.uiCapability()->setUiToolTip( "Actual Dogleg: " + QString::number( estimatedDogLeg ) ); } } else @@ -354,7 +387,7 @@ void RimWellPathTarget::flagRadius2AsIncorrect( bool isEditable, bool isIncorrec //-------------------------------------------------------------------------------------------------- std::vector RimWellPathTarget::fieldsFor3dManipulator() { - return { &m_targetType, &m_targetPointXYD, &m_azimuth, &m_inclination }; + return { &m_targetPointXYD, &m_azimuthDeg, &m_inclinationDeg }; } //-------------------------------------------------------------------------------------------------- @@ -373,6 +406,21 @@ void RimWellPathTarget::enableFullUpdate( bool enable ) m_isFullUpdateEnabled = enable; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellPathTarget::initAfterRead() +{ + if ( RimProject::current()->isProjectFileVersionEqualOrOlderThan( "2021.10.2" ) ) + { + if ( m_targetType_OBSOLETE() == RimWellPathTarget::TargetTypeEnum::POINT_AND_TANGENT ) + { + m_useFixedAzimuth = true; + m_useFixedInclination = true; + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -473,27 +521,6 @@ RimWellPathGeometryDef* RimWellPathTarget::geometryDefinition() const return geoDef; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QList RimWellPathTarget::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) -{ - QList options; - if ( fieldNeedingOptions == &m_targetType ) - { - options.push_back( - caf::PdmOptionItemInfo( "o->", - RimWellPathTarget::TargetTypeEnum::POINT_AND_TANGENT ) ); //, false, - // QIcon(":/WellTargetPointTangent16x16.png") - //)); - options.push_back( - caf::PdmOptionItemInfo( "o", RimWellPathTarget::TargetTypeEnum::POINT ) ); //, false, - // QIcon(":/WellTargetPoint16x16.png"))); - } - return options; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -501,14 +528,6 @@ void RimWellPathTarget::fieldChangedByUi( const caf::PdmFieldHandle* changedFiel const QVariant& oldValue, const QVariant& newValue ) { - if ( changedField == &m_hasTangentConstraintUiField ) - { - if ( m_hasTangentConstraintUiField ) - m_targetType = TargetTypeEnum::POINT_AND_TANGENT; - else - m_targetType = TargetTypeEnum::POINT; - } - moved.send( m_isFullUpdateEnabled ); } @@ -517,39 +536,20 @@ void RimWellPathTarget::fieldChangedByUi( const caf::PdmFieldHandle* changedFiel //-------------------------------------------------------------------------------------------------- void RimWellPathTarget::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { - m_hasTangentConstraintUiField = ( m_targetType == TargetTypeEnum::POINT_AND_TANGENT ); - - if ( m_isEnabled() && !m_isLocked() ) + if ( m_isEnabled() ) { - m_hasTangentConstraintUiField.uiCapability()->setUiReadOnly( false ); - m_targetType.uiCapability()->setUiReadOnly( false ); m_targetPointXYD.uiCapability()->setUiReadOnly( false ); - if ( m_targetType == TargetTypeEnum::POINT ) - { - m_azimuth.uiCapability()->setUiReadOnly( true ); - m_inclination.uiCapability()->setUiReadOnly( true ); - } - else - { - m_azimuth.uiCapability()->setUiReadOnly( false ); - m_inclination.uiCapability()->setUiReadOnly( false ); - } + m_azimuthDeg.uiCapability()->setUiReadOnly( !m_useFixedAzimuth() ); + m_inclinationDeg.uiCapability()->setUiReadOnly( !m_useFixedInclination() ); } else { m_dogleg1.uiCapability()->setUiReadOnly( true ); - m_targetType.uiCapability()->setUiReadOnly( true ); m_targetPointXYD.uiCapability()->setUiReadOnly( true ); - m_azimuth.uiCapability()->setUiReadOnly( true ); - m_inclination.uiCapability()->setUiReadOnly( true ); + m_azimuthDeg.uiCapability()->setUiReadOnly( true ); + m_inclinationDeg.uiCapability()->setUiReadOnly( true ); m_dogleg2.uiCapability()->setUiReadOnly( true ); - m_hasTangentConstraintUiField.uiCapability()->setUiReadOnly( true ); - } - - if ( m_isLocked ) - { - m_isEnabled.uiCapability()->setUiReadOnly( true ); } { diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathTarget.h b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathTarget.h index f383e91e73..288ce09111 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathTarget.h +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathTarget.h @@ -48,8 +48,10 @@ class RimWellPathTarget : public caf::PdmObject void setAsPointTargetXYD( const cvf::Vec3d& point ); void setAsPointTargetXYZ( const cvf::Vec3d& point ); void setAsPointXYZAndTangentTarget( const cvf::Vec3d& point, const cvf::Vec3d& tangent ); - void setAsPointXYZAndTangentTarget( const cvf::Vec3d& point, double azimuth, double inclination ); - void setDerivedTangent( double azimuth, double inclination ); + void setAsPointXYZAndTangentTarget( const cvf::Vec3d& point, double azimuthRadians, double inclinationRadians ); + void setFixedAzimuth( double fixedAzimuthDeg ); + void setFixedInclination( double fixedInclinationDeg ); + void setDerivedTangent( double azimuthRadians, double inclinationRadians ); void updateFrom3DManipulator( const cvf::Vec3d& pointXYD ); RiaLineArcWellPathCalculator::WellTarget wellTargetData(); @@ -60,48 +62,53 @@ class RimWellPathTarget : public caf::PdmObject POINT }; - TargetTypeEnum targetType() const; - cvf::Vec3d targetPointXYZ() const; - double azimuth() const; - double inclination() const; - cvf::Vec3d tangent() const; - double radius1() const; - double radius2() const; - void flagRadius1AsIncorrect( bool isEditable, bool isIncorrect, double actualRadius ); - void flagRadius2AsIncorrect( bool isEditable, bool isIncorrect, double actualRadius ); + cvf::Vec3d targetPointXYZ() const; + double azimuthRadians() const; + double inclinationRadians() const; + cvf::Vec3d tangent() const; + double radius1() const; + double radius2() const; + void setRadius1Data( bool isEditable, bool isIncorrect, double actualRadius ); + void setRadius2Data( bool isEditable, bool isIncorrect, double actualRadius ); std::vector fieldsFor3dManipulator(); void onMoved(); private: - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; - void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; - void defineEditorAttribute( const caf::PdmFieldHandle* field, - QString uiConfigName, - caf::PdmUiEditorAttribute* attribute ) override; + void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + void defineEditorAttribute( const caf::PdmFieldHandle* field, + QString uiConfigName, + caf::PdmUiEditorAttribute* attribute ) override; + void initAfterRead() override; cvf::Vec3d targetPointForDisplayXYD() const; void setTargetPointFromDisplayCoord( const cvf::Vec3d& coordInXYZ ); double measuredDepth() const; RimWellPathGeometryDef* geometryDefinition() const; + void enableFullUpdate( bool enable ); private: - void enableFullUpdate( bool enable ); - bool m_isFullUpdateEnabled; - caf::PdmField m_isEnabled; - caf::PdmField m_isLocked; - caf::PdmField> m_targetType; - caf::PdmField m_targetPointXYD; - caf::PdmProxyValueField m_targetPointForDisplay; - caf::PdmProxyValueField m_targetMeasuredDepth; - - caf::PdmField m_azimuth; - caf::PdmField m_inclination; + caf::PdmField m_isEnabled; + caf::PdmField m_targetPointXYD; + caf::PdmProxyValueField m_targetPointForDisplay; + caf::PdmProxyValueField m_targetMeasuredDepth; + + caf::PdmField m_azimuthDeg; + caf::PdmField m_inclinationDeg; caf::PdmField m_dogleg1; caf::PdmField m_dogleg2; - caf::PdmField m_hasTangentConstraintUiField; + caf::PdmField m_useFixedAzimuth; + caf::PdmField m_useFixedInclination; + + caf::PdmField m_estimatedDogleg1; + caf::PdmField m_estimatedDogleg2; + caf::PdmField m_estimatedAzimuthDeg; + caf::PdmField m_estimatedInclinationDeg; + + bool m_isFullUpdateEnabled; + caf::PdmField m_hasTangentConstraintUiField_OBSOLETE; + caf::PdmField> m_targetType_OBSOLETE; }; diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathTieIn.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathTieIn.cpp index cd9352efd3..d581b2d3de 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathTieIn.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathTieIn.cpp @@ -42,14 +42,14 @@ RimWellPathTieIn::RimWellPathTieIn() { CAF_PDM_InitObject( "Well Path Tie In", ":/NotDefined.png", "", "Well Path Tie In description" ); - CAF_PDM_InitFieldNoDefault( &m_parentWell, "ParentWellPath", "Parent Well Path", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_childWell, "ChildWellPath", "ChildWellPath", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_tieInMeasuredDepth, "TieInMeasuredDepth", "Tie In Measured Depth", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_parentWell, "ParentWellPath", "Parent Well Path" ); + CAF_PDM_InitFieldNoDefault( &m_childWell, "ChildWellPath", "ChildWellPath" ); + CAF_PDM_InitFieldNoDefault( &m_tieInMeasuredDepth, "TieInMeasuredDepth", "Tie In Measured Depth" ); m_tieInMeasuredDepth.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_addValveAtConnection, "AddValveAtConnection", false, "Add Outlet Valve for Branches", "", "", "" ); + CAF_PDM_InitField( &m_addValveAtConnection, "AddValveAtConnection", false, "Add Outlet Valve for Branches" ); - CAF_PDM_InitFieldNoDefault( &m_valve, "Valve", "Branch Outlet Valve", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_valve, "Valve", "Branch Outlet Valve" ); m_valve = new RimWellPathValve; } @@ -213,8 +213,7 @@ void RimWellPathTieIn::fieldChangedByUi( const caf::PdmFieldHandle* changedField //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimWellPathTieIn::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) +QList RimWellPathTieIn::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathTieIn.h b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathTieIn.h index 77ddbf05f1..549bc04499 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathTieIn.h +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathTieIn.h @@ -50,8 +50,7 @@ class RimWellPathTieIn : public caf::PdmObject void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, diff --git a/ApplicationLibCode/ProjectDataModel/cafTreeNode.cpp b/ApplicationLibCode/ProjectDataModel/cafTreeNode.cpp index 1031c14372..cbe7a2cad4 100644 --- a/ApplicationLibCode/ProjectDataModel/cafTreeNode.cpp +++ b/ApplicationLibCode/ProjectDataModel/cafTreeNode.cpp @@ -27,9 +27,9 @@ CAF_PDM_SOURCE_INIT( cafTreeNode, "cafTreeNode" ); //-------------------------------------------------------------------------------------------------- cafTreeNode::cafTreeNode() { - CAF_PDM_InitObject( "WellPath", ":/Folder.svg", "", "" ); + CAF_PDM_InitObject( "WellPath", ":/Folder.svg" ); - CAF_PDM_InitFieldNoDefault( &m_childNodes, "ChildNodes", "ChildNodes", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_childNodes, "ChildNodes", "ChildNodes" ); } //-------------------------------------------------------------------------------------------------- @@ -45,7 +45,7 @@ void cafTreeNode::addChild( cafTreeNode* treeNode ) //-------------------------------------------------------------------------------------------------- std::vector cafTreeNode::childNodes() const { - return m_childNodes.childObjects(); + return m_childNodes.children(); } //-------------------------------------------------------------------------------------------------- @@ -104,12 +104,12 @@ CAF_PDM_SOURCE_INIT( cafNamedTreeNode, "cafNamedTreeNode" ); cafNamedTreeNode::cafNamedTreeNode() : m_showCheckedBox( false ) { - CAF_PDM_InitObject( "Node", ":/Folder.svg", "", "" ); + CAF_PDM_InitObject( "Node", ":/Folder.svg" ); - CAF_PDM_InitField( &m_name, "Name", QString(), "Name", "", "", "" ); + CAF_PDM_InitField( &m_name, "Name", QString(), "Name" ); m_name.uiCapability()->setUiHidden( true ); - CAF_PDM_InitField( &m_isChecked, "IsChecked", true, "Active", "", "", "" ); + CAF_PDM_InitField( &m_isChecked, "IsChecked", true, "Active" ); m_isChecked.uiCapability()->setUiHidden( true ); } @@ -190,9 +190,9 @@ CAF_PDM_SOURCE_INIT( cafObjectReferenceTreeNode, "cafObjectReferenceTreeNode" ); //-------------------------------------------------------------------------------------------------- cafObjectReferenceTreeNode::cafObjectReferenceTreeNode() { - CAF_PDM_InitObject( "cafObjectReferenceTreeNode", ":/Folder.svg", "", "" ); + CAF_PDM_InitObject( "cafObjectReferenceTreeNode", ":/Folder.svg" ); - CAF_PDM_InitFieldNoDefault( &m_referencedObject, "ReferencedObject", "Referenced Object", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_referencedObject, "ReferencedObject", "Referenced Object" ); m_childNodes.uiCapability()->setUiTreeHidden( true ); @@ -226,7 +226,7 @@ void cafObjectReferenceTreeNode::defineUiTreeOrdering( caf::PdmUiTreeOrdering& u uiTreeOrdering.add( m_referencedObject() ); } - for ( auto c : m_childNodes.childObjects() ) + for ( auto c : m_childNodes.children() ) { if ( auto obj = c->referencedObject() ) { diff --git a/ApplicationLibCode/ProjectDataModelCommands/CommandRouter/RimcExtractSurfaces.cpp b/ApplicationLibCode/ProjectDataModelCommands/CommandRouter/RimcExtractSurfaces.cpp index 248422020c..43be85f5af 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/CommandRouter/RimcExtractSurfaces.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/CommandRouter/RimcExtractSurfaces.cpp @@ -43,12 +43,12 @@ RimcCommandRouter_extractSurfaces::RimcCommandRouter_extractSurfaces( caf::PdmOb { CAF_PDM_InitObject( "Extract Layer Surface", "", "", "Extract Layer Surface" ); - CAF_PDM_InitScriptableField( &m_gridModelFilename, "GridModelFilename", QString(), "Grid Model Case Filename", "", "", "" ); - CAF_PDM_InitScriptableField( &m_layers, "Layers", std::vector(), "Layers", "", "", "" ); - CAF_PDM_InitScriptableField( &m_minimumI, "MinimumI", -1, "Minimum I", "", "", "" ); - CAF_PDM_InitScriptableField( &m_maximumI, "MaximumI", -1, "Maximum I", "", "", "" ); - CAF_PDM_InitScriptableField( &m_minimumJ, "MinimumJ", -1, "Minimum J", "", "", "" ); - CAF_PDM_InitScriptableField( &m_maximumJ, "MaximumJ", -1, "Maximum J", "", "", "" ); + CAF_PDM_InitScriptableField( &m_gridModelFilename, "GridModelFilename", QString(), "Grid Model Case Filename" ); + CAF_PDM_InitScriptableField( &m_layers, "Layers", std::vector(), "Layers" ); + CAF_PDM_InitScriptableField( &m_minimumI, "MinimumI", -1, "Minimum I" ); + CAF_PDM_InitScriptableField( &m_maximumI, "MaximumI", -1, "Maximum I" ); + CAF_PDM_InitScriptableField( &m_minimumJ, "MinimumJ", -1, "Minimum J" ); + CAF_PDM_InitScriptableField( &m_maximumJ, "MaximumJ", -1, "Maximum J" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcDataContainerDouble.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcDataContainerDouble.cpp index 2d948588ff..e2c5729761 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcDataContainerDouble.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcDataContainerDouble.cpp @@ -29,8 +29,8 @@ CAF_PDM_SOURCE_INIT( RimcDataContainerDouble, "DataContainerFloat" ); //-------------------------------------------------------------------------------------------------- RimcDataContainerDouble::RimcDataContainerDouble() { - CAF_PDM_InitScriptableObject( "Data Container Float", "", "", "" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_doubleValues, "values", "Float Values", "", "", "" ); + CAF_PDM_InitScriptableObject( "Data Container Float" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_doubleValues, "values", "Float Values" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcDataContainerString.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcDataContainerString.cpp index 5910d6103f..c8127da08e 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcDataContainerString.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcDataContainerString.cpp @@ -29,6 +29,6 @@ CAF_PDM_SOURCE_INIT( RimcDataContainerString, "DataContainerString" ); //-------------------------------------------------------------------------------------------------- RimcDataContainerString::RimcDataContainerString() { - CAF_PDM_InitScriptableObject( "Data Container String", "", "", "" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_stringValues, "values", "String Values", "", "", "" ); + CAF_PDM_InitScriptableObject( "Data Container String" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_stringValues, "values", "String Values" ); } diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcDataContainerTime.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcDataContainerTime.cpp index 877aec9978..cce355fc72 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcDataContainerTime.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcDataContainerTime.cpp @@ -29,6 +29,6 @@ CAF_PDM_SOURCE_INIT( RimcDataContainerTime, "DataContainerTime" ); //-------------------------------------------------------------------------------------------------- RimcDataContainerTime::RimcDataContainerTime() { - CAF_PDM_InitScriptableObject( "Data Container Time", "", "", "" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_timeValues, "values", "Time Values", "", "", "" ); + CAF_PDM_InitScriptableObject( "Data Container Time" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_timeValues, "values", "Time Values" ); } diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcProject.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcProject.cpp index ac971634e3..7a2c2be9e6 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcProject.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcProject.cpp @@ -46,7 +46,7 @@ RimProject_importSummaryCase::RimProject_importSummaryCase( caf::PdmObjectHandle : caf::PdmObjectMethod( self ) { CAF_PDM_InitObject( "Import Summary Case", "", "", "Import Summary Case" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_fileName, "FileName", "", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_fileName, "FileName", "" ); } //-------------------------------------------------------------------------------------------------- @@ -76,7 +76,7 @@ caf::PdmObjectHandle* RimProject_importSummaryCase::execute() RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow(); if ( mainPlotWindow && !newCases.empty() ) { - mainPlotWindow->updateSummaryPlotToolBar(); + mainPlotWindow->updateMultiPlotToolBar(); } } @@ -122,7 +122,7 @@ RimProject_summaryCase::RimProject_summaryCase( caf::PdmObjectHandle* self ) : caf::PdmObjectMethod( self ) { CAF_PDM_InitObject( "Find Summary Case", "", "", "Find Summary Case" ); - CAF_PDM_InitScriptableField( &m_caseId, "CaseId", -1, "", "", "", "" ); + CAF_PDM_InitScriptableField( &m_caseId, "CaseId", -1, "" ); } //-------------------------------------------------------------------------------------------------- @@ -174,7 +174,7 @@ RimProject_surfaceFolder::RimProject_surfaceFolder( caf::PdmObjectHandle* self ) : caf::PdmObjectMethod( self ) { CAF_PDM_InitObject( "Get Surface Folder", "", "", "Get Surface Folder" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_folderName, "FolderName", "", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_folderName, "FolderName", "" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcStimPlanModelCollection.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcStimPlanModelCollection.cpp index a4e85ae916..6e8dfac619 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcStimPlanModelCollection.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcStimPlanModelCollection.cpp @@ -43,7 +43,7 @@ RimcStimPlanModelCollection_appendStimPlanModel::RimcStimPlanModelCollection_app { CAF_PDM_InitObject( "Create StimPlan Model", "", "", "Create a new StimPlan Model" ); CAF_PDM_InitScriptableFieldNoDefault( &m_wellPath, "WellPath", "", "", "", "Well Path" ); - CAF_PDM_InitScriptableField( &m_md, "MeasuredDepth", 0.0, "Measured Depth", "", "", "" ); + CAF_PDM_InitScriptableField( &m_md, "MeasuredDepth", 0.0, "Measured Depth" ); CAF_PDM_InitScriptableFieldNoDefault( &m_stimPlanModelTemplate, "StimPlanModelTemplate", "", "", "", "StimPlan Model Template" ); } diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcSummaryCase.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcSummaryCase.cpp index d6168567c7..616dcdf3b5 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcSummaryCase.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcSummaryCase.cpp @@ -93,7 +93,7 @@ CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimSummaryCase, RimSummaryCase_availableAddre RimSummaryCase_availableAddresses::RimSummaryCase_availableAddresses( caf::PdmObjectHandle* self ) : caf::PdmObjectMethod( self ) { - CAF_PDM_InitObject( "Available Addresses", "", "", "" ); + CAF_PDM_InitObject( "Available Addresses" ); } //-------------------------------------------------------------------------------------------------- @@ -145,7 +145,7 @@ CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimSummaryCase, RimSummaryCase_availableTimeS RimSummaryCase_availableTimeSteps::RimSummaryCase_availableTimeSteps( caf::PdmObjectHandle* self ) : caf::PdmObjectMethod( self ) { - CAF_PDM_InitObject( "Available TimeSteps", "", "", "" ); + CAF_PDM_InitObject( "Available TimeSteps" ); } //-------------------------------------------------------------------------------------------------- @@ -190,7 +190,7 @@ CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimSummaryCase, RimSummaryCase_resampleValues RimSummaryCase_resampleValues::RimSummaryCase_resampleValues( caf::PdmObjectHandle* self ) : caf::PdmObjectMethod( self ) { - CAF_PDM_InitObject( "Resample Values", "", "", "" ); + CAF_PDM_InitObject( "Resample Values" ); CAF_PDM_InitScriptableFieldNoDefault( &m_addressString, "Address", "", "", "", "Formatted address specifying the summary vector" ); CAF_PDM_InitScriptableFieldNoDefault( &m_resamplingPeriod, "ResamplingPeriod", "", "", "", "Resampling Period" ); @@ -220,10 +220,10 @@ caf::PdmObjectHandle* RimSummaryCase_resampleValues::execute() const auto& timeValues = sumReader->timeSteps( adr ); - QString periodString = m_resamplingPeriod().trimmed(); - RiaQDateTimeTools::DateTimePeriod period = RiaQDateTimeTools::DateTimePeriodEnum::fromText( periodString ); + QString periodString = m_resamplingPeriod().trimmed(); + RiaDefines::DateTimePeriod period = RiaDefines::DateTimePeriodEnum::fromText( periodString ); - if ( period != RiaQDateTimeTools::DateTimePeriod::NONE ) + if ( period != RiaDefines::DateTimePeriod::NONE ) { auto [resampledTimeSteps, resampledValues] = RiaSummaryTools::resampledValuesForPeriod( adr, timeValues, values, period ); diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcSummaryPlotCollection.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcSummaryPlotCollection.cpp index 8caa9c5f3c..296508a476 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcSummaryPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcSummaryPlotCollection.cpp @@ -20,9 +20,10 @@ #include "SummaryPlotCommands/RicNewDefaultSummaryPlotFeature.h" #include "SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.h" -#include "SummaryPlotCommands/RicNewSummaryPlotFeature.h" #include "SummaryPlotCommands/RicSummaryPlotFeatureImpl.h" +#include "RiaTextStringTools.h" + #include "RimSummaryCase.h" #include "RimSummaryPlot.h" #include "RimSummaryPlotCollection.h" @@ -56,17 +57,16 @@ RimcSummaryPlotCollection_newSummaryPlot::RimcSummaryPlotCollection_newSummaryPl //-------------------------------------------------------------------------------------------------- caf::PdmObjectHandle* RimcSummaryPlotCollection_newSummaryPlot::execute() { - QStringList addressStrings = m_addressString().split( ";", QString::SkipEmptyParts ); + QStringList addressStrings = RiaTextStringTools::splitSkipEmptyParts( m_addressString(), ";" ); RimSummaryPlot* newPlot = nullptr; if ( m_ensemble ) { if ( !addressStrings.empty() ) { - newPlot = RicSummaryPlotFeatureImpl::createSummaryPlotFromAddresses( self(), - std::vector(), - m_ensemble, - addressStrings ); + newPlot = RicSummaryPlotFeatureImpl::createSummaryPlotForEnsemble( std::vector(), + m_ensemble, + addressStrings ); } else { @@ -78,22 +78,17 @@ caf::PdmObjectHandle* RimcSummaryPlotCollection_newSummaryPlot::execute() std::vector summaryCases = m_summaryCases.ptrReferencedObjects(); if ( !addressStrings.empty() ) { - newPlot = RicSummaryPlotFeatureImpl::createSummaryPlotFromAddresses( self(), - summaryCases, - nullptr, - addressStrings ); + newPlot = RicSummaryPlotFeatureImpl::createSummaryPlotForCases( summaryCases, addressStrings ); } else { - newPlot = RicNewDefaultSummaryPlotFeature::createFromSummaryCases( self(), - summaryCases ); + newPlot = RicNewDefaultSummaryPlotFeature::createFromSummaryCases( summaryCases ); } } if ( newPlot ) { newPlot->loadDataAndUpdate(); - self()->updateAllRequiredEditors(); } return newPlot; diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcSummaryResampleData.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcSummaryResampleData.cpp index 32db4cc80b..f4ba9c34f2 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcSummaryResampleData.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcSummaryResampleData.cpp @@ -29,7 +29,7 @@ CAF_PDM_SOURCE_INIT( RimcSummaryResampleData, "ResampleData" ); //-------------------------------------------------------------------------------------------------- RimcSummaryResampleData::RimcSummaryResampleData() { - CAF_PDM_InitScriptableObject( "Resample Data", "", "", "" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_timeValues, "TimeSteps", "Time Steps", "", "", "" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_doubleValues, "Values", "Values", "", "", "" ); + CAF_PDM_InitScriptableObject( "Resample Data" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_timeValues, "TimeSteps", "Time Steps" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_doubleValues, "Values", "Values" ); } diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcSurfaceCollection.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcSurfaceCollection.cpp index 16985c5482..deaa6f7bd2 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcSurfaceCollection.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcSurfaceCollection.cpp @@ -141,8 +141,8 @@ RimcSurfaceCollection_newSurface::RimcSurfaceCollection_newSurface( caf::PdmObje : caf::PdmObjectMethod( self ) { CAF_PDM_InitObject( "New Surface", "", "", "Create a new surface" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_case, "Case", "", "", "", "" ); - CAF_PDM_InitScriptableFieldNoDefault( &m_kIndex, "KIndex", "", "", "", "" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_case, "Case", "" ); + CAF_PDM_InitScriptableField( &m_kIndex, "KIndex", 0, "" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcWellLogPlot.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcWellLogPlot.cpp index 9f3176f494..28421983f6 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcWellLogPlot.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcWellLogPlot.cpp @@ -70,20 +70,20 @@ RimWellLogTrack* RimcWellLogPlot_newWellLogTrack::createWellLogTrack( RimWellLog RimWellLogTrack* plotTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack( false, title, wellLogPlot ); if ( eclipseCase ) plotTrack->setFormationCase( eclipseCase ); if ( wellPath ) plotTrack->setFormationWellPath( wellPath ); + plotTrack->setColSpan( RimPlot::TWO ); plotTrack->setLegendsVisible( true ); plotTrack->setPlotTitleVisible( true ); plotTrack->setShowWindow( true ); - plotTrack->setXAxisGridVisibility( RimWellLogPlot::AXIS_GRID_MAJOR ); + plotTrack->setPropertyValueAxisGridVisibility( RimWellLogPlot::AXIS_GRID_MAJOR ); plotTrack->setShowRegionLabels( true ); - plotTrack->setAutoScaleXEnabled( true ); + plotTrack->setAutoScalePropertyValuesEnabled( true ); plotTrack->updateConnectedEditors(); + wellLogPlot->setShowWindow( true ); wellLogPlot->updateConnectedEditors(); - - RiaApplication::instance()->project()->updateConnectedEditors(); - wellLogPlot->loadDataAndUpdate(); + return plotTrack; } diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcWellLogTrack.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcWellLogTrack.cpp index 61e2d26a81..7aca01aa48 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcWellLogTrack.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcWellLogTrack.cpp @@ -100,14 +100,12 @@ RimWellLogExtractionCurve* curve->updateConnectedEditors(); - wellLogTrack->setXAxisGridVisibility( RimWellLogPlot::AXIS_GRID_MAJOR ); + wellLogTrack->setPropertyValueAxisGridVisibility( RimWellLogPlot::AXIS_GRID_MAJOR ); wellLogTrack->setShowRegionLabels( true ); - wellLogTrack->setAutoScaleXEnabled( true ); + wellLogTrack->setAutoScalePropertyValuesEnabled( true ); wellLogTrack->updateConnectedEditors(); wellLogTrack->setShowWindow( true ); - RiaApplication::instance()->project()->updateConnectedEditors(); - RimWellLogPlot* wellLogPlot = dynamic_cast( wellLogTrack->parentField() ); if ( wellLogPlot ) wellLogPlot->loadDataAndUpdate(); diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcWellPath.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcWellPath.cpp index 5fa296d9b9..d58155fa7e 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcWellPath.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcWellPath.cpp @@ -18,14 +18,21 @@ #include "RimcWellPath.h" +#include "RiaLogging.h" + +#include "RimEclipseCase.h" +#include "RimEclipseCaseTools.h" #include "RimPerforationCollection.h" #include "RimPerforationInterval.h" #include "RimStimPlanFractureTemplate.h" +#include "RimStimPlanModel.h" #include "RimTools.h" #include "RimWellPath.h" #include "RimWellPathCollection.h" #include "RimWellPathFracture.h" +#include "RigStimPlanModelTools.h" + #include "FractureCommands/RicNewWellPathFractureFeature.h" #include "cafPdmAbstractFieldScriptingCapability.h" @@ -41,13 +48,15 @@ RimcWellPath_addFracture::RimcWellPath_addFracture( caf::PdmObjectHandle* self ) { CAF_PDM_InitObject( "Add StimPlan Fracture", "", "", "Add StimPlan Fracture" ); - CAF_PDM_InitScriptableField( &m_md, "MeasuredDepth", 0.0, "Measured Depth", "", "", "" ); + CAF_PDM_InitScriptableField( &m_md, "MeasuredDepth", 0.0, "Measured Depth" ); CAF_PDM_InitScriptableFieldNoDefault( &m_stimPlanFractureTemplate, "StimPlanFractureTemplate", "", "", "", "StimPlan Fracture Template" ); + CAF_PDM_InitScriptableField( &m_alignDip, "AlignDip", false, "Align Dip" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_eclipseCase, "EclipseCase", "", "", "", "Eclipse Case" ); } //-------------------------------------------------------------------------------------------------- @@ -61,6 +70,40 @@ caf::PdmObjectHandle* RimcWellPath_addFracture::execute() if ( m_stimPlanFractureTemplate ) wellPathFracture->setFractureTemplate( m_stimPlanFractureTemplate() ); + if ( m_alignDip ) + { + if ( m_eclipseCase && m_eclipseCase->eclipseCaseData() ) + { + RiaLogging::info( "Computing formation dip for fracture alignment" ); + + double boundingBoxHorizontal = 50.0; + double boundingBoxVertical = 100.0; + + cvf::Vec3d position = wellPathFracture->anchorPosition(); + cvf::Vec3d direction = RigStimPlanModelTools::calculateTSTDirection( m_eclipseCase->eclipseCaseData(), + position, + boundingBoxHorizontal, + boundingBoxVertical ); + RiaLogging::info( + QString( "Direction: %1 %2 %3" ).arg( direction.x() ).arg( direction.y() ).arg( direction.z() ) ); + cvf::Vec3d fractureDirectionNormal = wellPathFracture->computeFractureDirectionNormal(); + + cvf::Vec3d formationDirection = + RimStimPlanModel::projectVectorIntoFracturePlane( position, fractureDirectionNormal, direction ); + if ( !formationDirection.isUndefined() ) + { + double formationDip = RigStimPlanModelTools::calculateFormationDip( formationDirection ) - 90.0; + RiaLogging::info( QString( "Computed formation dip: %1" ).arg( formationDip ) ); + + wellPathFracture->setDip( formationDip ); + } + } + else + { + RiaLogging::error( "No eclipse case found. Fracture not aligned with formation dip." ); + } + } + return wellPathFracture; } diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcWellPath.h b/ApplicationLibCode/ProjectDataModelCommands/RimcWellPath.h index aec0c347e3..f0e2acdc51 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcWellPath.h +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcWellPath.h @@ -26,6 +26,7 @@ #include class RimStimPlanFractureTemplate; +class RimEclipseCase; //================================================================================================== /// @@ -44,6 +45,8 @@ class RimcWellPath_addFracture : public caf::PdmObjectMethod private: caf::PdmField m_md; caf::PdmPtrField m_stimPlanFractureTemplate; + caf::PdmField m_alignDip; + caf::PdmPtrField m_eclipseCase; }; //================================================================================================== diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcWellPathGeometryDef.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcWellPathGeometryDef.cpp index 98db4c9822..e179dbf81e 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcWellPathGeometryDef.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcWellPathGeometryDef.cpp @@ -40,6 +40,11 @@ RimcRimWellPathGeometryDef_appendNewWellTarget::RimcRimWellPathGeometryDef_appen CAF_PDM_InitObject( "Create and Add New Well Target", "", "", "Create and Add New Well Target" ); CAF_PDM_InitScriptableFieldNoDefault( &m_coordinate, "Coordinate", "", "", "", "Coordinate" ); CAF_PDM_InitScriptableField( &m_isAbsolute, "Absolute", false, "", "", "", "Relative or Absolute Coordinate" ); + + CAF_PDM_InitScriptableField( &m_useFixedAzimuth, "UseFixedAzimuth", false, "" ); + CAF_PDM_InitScriptableField( &m_useFixedInclination, "UseFixedInclination", false, "" ); + CAF_PDM_InitScriptableField( &m_fixedAzimuthValue, "FixedAzimuthValue", 0.0, "", "", "", "[Degrees]" ); + CAF_PDM_InitScriptableField( &m_fixedInclinationValue, "FixedInclinationValue", 0.0, "", "", "", "[Degrees]" ); } //-------------------------------------------------------------------------------------------------- @@ -60,6 +65,17 @@ caf::PdmObjectHandle* RimcRimWellPathGeometryDef_appendNewWellTarget::execute() auto newTarget = new RimWellPathTarget; newTarget->setAsPointTargetXYD( cvf::Vec3d( relativeTargetPoint.x(), relativeTargetPoint.y(), -relativeTargetPoint.z() ) ); + + if ( m_useFixedAzimuth ) + { + newTarget->setFixedAzimuth( m_fixedAzimuthValue ); + } + + if ( m_useFixedInclination ) + { + newTarget->setFixedInclination( m_fixedInclinationValue ); + } + geoDef->insertTarget( nullptr, newTarget ); geoDef->updateConnectedEditors(); diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcWellPathGeometryDef.h b/ApplicationLibCode/ProjectDataModelCommands/RimcWellPathGeometryDef.h index b22ad820e0..18b7058d64 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcWellPathGeometryDef.h +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcWellPathGeometryDef.h @@ -43,4 +43,9 @@ class RimcRimWellPathGeometryDef_appendNewWellTarget : public caf::PdmObjectMeth private: caf::PdmField m_coordinate; caf::PdmField m_isAbsolute; + + caf::PdmField m_useFixedAzimuth; + caf::PdmField m_fixedAzimuthValue; + caf::PdmField m_useFixedInclination; + caf::PdmField m_fixedInclinationValue; }; diff --git a/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultCalculator.cpp b/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultCalculator.cpp index c35e6826e2..ac00907433 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultCalculator.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultCalculator.cpp @@ -148,9 +148,11 @@ bool RigCaseCellResultCalculator::computeDifference( RigEclipseCaseData* { cvf::ref sourceResultAccessor = RigResultAccessorFactory::createFromResultAddress( sourceCase, gridIdx, porosityModel, fIdx, nativeAddress ); + if ( sourceResultAccessor.isNull() ) continue; cvf::ref resultModifier = RigResultModifierFactory::createResultModifier( sourceCase, gridIdx, porosityModel, fIdx, address ); + if ( resultModifier.isNull() ) continue; size_t baseFrameIdx = fIdx; if ( address.isDeltaTimeStepActive() ) @@ -160,6 +162,7 @@ bool RigCaseCellResultCalculator::computeDifference( RigEclipseCaseData* cvf::ref baseResultAccessor = RigResultAccessorFactory::createFromResultAddress( baseCase, gridIdx, porosityModel, baseFrameIdx, nativeAddress ); + if ( baseResultAccessor.isNull() ) continue; for ( size_t localGridCellIdx = 0; localGridCellIdx < grid->cellCount(); localGridCellIdx++ ) { diff --git a/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.cpp index 1ebb3053c4..99c5d87e96 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -21,6 +21,7 @@ #include "RigCaseCellResultsData.h" #include "RiaApplication.h" +#include "RiaDefines.h" #include "RiaEclipseUnitTools.h" #include "RiaLogging.h" @@ -42,6 +43,7 @@ #include "RifReaderEclipseOutput.h" +#include "cafAssert.h" #include "cafProgressInfo.h" #include "cvfGeometryTools.h" @@ -907,6 +909,23 @@ void RigCaseCellResultsData::eraseAllSourSimData() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigCaseCellResultsData::setRemovedTagOnGeneratedResult( const RigEclipseResultAddress& resultAddress ) +{ + CAF_ASSERT( resultAddress.resultCatType() == RiaDefines::ResultCatType::GENERATED ); + + for ( auto& it : m_resultInfos ) + { + if ( it.resultType() == RiaDefines::ResultCatType::GENERATED && it.resultName() == resultAddress.resultName() ) + { + it.setResultType( RiaDefines::ResultCatType::REMOVED ); + return; + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -914,14 +933,16 @@ void RigCaseCellResultsData::createPlaceholderResultEntries() { // SOIL { - if ( !hasResultEntry( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "SOIL" ) ) ) + if ( !hasResultEntry( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, RiaResultNames::soil() ) ) ) { - if ( hasResultEntry( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "SWAT" ) ) || - hasResultEntry( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "SGAS" ) ) ) + if ( hasResultEntry( + RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, RiaResultNames::swat() ) ) || + hasResultEntry( + RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, RiaResultNames::sgas() ) ) ) { size_t soilIndex = findOrCreateScalarResultIndex( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, - "SOIL" ), + RiaResultNames::soil() ), false ); this->setMustBeCalculated( soilIndex ); } @@ -931,7 +952,7 @@ void RigCaseCellResultsData::createPlaceholderResultEntries() // Oil Volume if ( RiaApplication::enableDevelopmentFeatures() ) { - if ( hasResultEntry( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "SOIL" ) ) ) + if ( hasResultEntry( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, RiaResultNames::soil() ) ) ) { findOrCreateScalarResultIndex( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, RiaResultNames::riOilVolumeResultName() ), @@ -1348,14 +1369,16 @@ size_t RigCaseCellResultsData::findOrLoadKnownScalarResult( const RigEclipseResu return scalarResultIndex; } - if ( resultName == "SOIL" ) + if ( resultName == RiaResultNames::soil() ) { if ( this->mustBeCalculated( scalarResultIndex ) ) { // Trigger loading of SWAT, SGAS to establish time step count if no data has been loaded from file at // this point - findOrLoadKnownScalarResult( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "SWAT" ) ); - findOrLoadKnownScalarResult( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "SGAS" ) ); + findOrLoadKnownScalarResult( + RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, RiaResultNames::swat() ) ); + findOrLoadKnownScalarResult( + RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, RiaResultNames::sgas() ) ); m_cellScalarResults[scalarResultIndex].resize( this->maxTimeStepCount() ); for ( size_t timeStepIdx = 0; timeStepIdx < this->maxTimeStepCount(); timeStepIdx++ ) @@ -1548,7 +1571,7 @@ size_t RigCaseCellResultsData::findOrLoadKnownScalarResultForTimeStep( const Rig QString resultName = resVarAddr.resultName(); // Special handling for SOIL - if ( type == RiaDefines::ResultCatType::DYNAMIC_NATIVE && resultName.toUpper() == "SOIL" ) + if ( type == RiaDefines::ResultCatType::DYNAMIC_NATIVE && resultName.toUpper() == RiaResultNames::soil() ) { size_t soilScalarResultIndex = this->findScalarResultIndexFromAddress( resVarAddr ); @@ -1648,15 +1671,17 @@ void RigCaseCellResultsData::computeSOILForTimeStep( size_t timeStepIndex ) // Compute SGAS based on SWAT if the simulation contains no oil testAndComputeSgasForTimeStep( timeStepIndex ); - RigEclipseResultAddress SWATAddr( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "SWAT" ); - RigEclipseResultAddress SGASAddr( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "SGAS" ); + RigEclipseResultAddress SWATAddr( RiaDefines::ResultCatType::DYNAMIC_NATIVE, RiaResultNames::swat() ); + RigEclipseResultAddress SGASAddr( RiaDefines::ResultCatType::DYNAMIC_NATIVE, RiaResultNames::sgas() ); RigEclipseResultAddress SSOLAddr( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "SSOL" ); size_t scalarIndexSWAT = - findOrLoadKnownScalarResultForTimeStep( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "SWAT" ), + findOrLoadKnownScalarResultForTimeStep( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, + RiaResultNames::swat() ), timeStepIndex ); size_t scalarIndexSGAS = - findOrLoadKnownScalarResultForTimeStep( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "SGAS" ), + findOrLoadKnownScalarResultForTimeStep( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, + RiaResultNames::sgas() ), timeStepIndex ); size_t scalarIndexSSOL = findOrLoadKnownScalarResultForTimeStep( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "SSOL" ), @@ -1694,7 +1719,7 @@ void RigCaseCellResultsData::computeSOILForTimeStep( size_t timeStepIndex ) } // Make sure memory is allocated for the new SOIL results - RigEclipseResultAddress SOILAddr( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "SOIL" ); + RigEclipseResultAddress SOILAddr( RiaDefines::ResultCatType::DYNAMIC_NATIVE, RiaResultNames::soil() ); size_t soilResultScalarIndex = this->findScalarResultIndexFromAddress( SOILAddr ); m_cellScalarResults[soilResultScalarIndex].resize( soilTimeStepCount ); @@ -1768,7 +1793,8 @@ void RigCaseCellResultsData::computeSOILForTimeStep( size_t timeStepIndex ) void RigCaseCellResultsData::testAndComputeSgasForTimeStep( size_t timeStepIndex ) { size_t scalarIndexSWAT = - findOrLoadKnownScalarResultForTimeStep( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "SWAT" ), + findOrLoadKnownScalarResultForTimeStep( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, + RiaResultNames::swat() ), timeStepIndex ); if ( scalarIndexSWAT == cvf::UNDEFINED_SIZE_T ) { @@ -1784,7 +1810,8 @@ void RigCaseCellResultsData::testAndComputeSgasForTimeStep( size_t timeStepIndex // Simulation type is gas and water. No SGAS is present, compute SGAS based on SWAT size_t scalarIndexSGAS = - this->findOrCreateScalarResultIndex( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "SGAS" ), + this->findOrCreateScalarResultIndex( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, + RiaResultNames::sgas() ), false ); if ( m_cellScalarResults[scalarIndexSGAS].size() > timeStepIndex ) { @@ -2930,8 +2957,8 @@ void RigCaseCellResultsData::computeOilVolumes() false ); const std::vector& cellVolumeResults = m_cellScalarResults[cellVolIdx][0]; - size_t soilIdx = - this->findOrLoadKnownScalarResult( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "SOIL" ) ); + size_t soilIdx = this->findOrLoadKnownScalarResult( + RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, RiaResultNames::soil() ) ); size_t oilVolIdx = this->findOrCreateScalarResultIndex( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, RiaResultNames::riOilVolumeResultName() ), diff --git a/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.h b/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.h index 4cb1a3efcb..0f48ff3d83 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.h +++ b/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.h @@ -120,6 +120,7 @@ class RigCaseCellResultsData : public cvf::Object void clearAllResults(); void freeAllocatedResultsData(); void eraseAllSourSimData(); + void setRemovedTagOnGeneratedResult( const RigEclipseResultAddress& resultAddress ); QStringList resultNames( RiaDefines::ResultCatType type ) const; std::vector existingResults() const; diff --git a/ApplicationLibCode/ReservoirDataModel/RigEclipseNativeStatCalc.cpp b/ApplicationLibCode/ReservoirDataModel/RigEclipseNativeStatCalc.cpp index 8b75882002..eba4764a53 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigEclipseNativeStatCalc.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigEclipseNativeStatCalc.cpp @@ -46,6 +46,39 @@ void RigEclipseNativeStatCalc::minMaxCellScalarValues( size_t timeStepIndex, dou max = acc.max; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigEclipseNativeStatCalc::hasPreciseP10p90() const +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigEclipseNativeStatCalc::p10p90CellScalarValues( double& p10, double& p90 ) +{ + PercentilAccumulator acc; + + for ( size_t timeStepIndex = 0; timeStepIndex < timeStepCount(); timeStepIndex++ ) + { + traverseCells( acc, timeStepIndex ); + } + + acc.computep10p90( p10, p90 ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigEclipseNativeStatCalc::p10p90CellScalarValues( size_t timeStepIndex, double& p10, double& p90 ) +{ + PercentilAccumulator acc; + traverseCells( acc, timeStepIndex ); + acc.computep10p90( p10, p90 ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ReservoirDataModel/RigEclipseNativeStatCalc.h b/ApplicationLibCode/ReservoirDataModel/RigEclipseNativeStatCalc.h index f044cff832..9a2a8d4969 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigEclipseNativeStatCalc.h +++ b/ApplicationLibCode/ReservoirDataModel/RigEclipseNativeStatCalc.h @@ -35,6 +35,9 @@ class RigEclipseNativeStatCalc : public RigStatisticsCalculator public: RigEclipseNativeStatCalc( RigCaseCellResultsData* cellResultsData, const RigEclipseResultAddress& eclipseResultAddress ); + bool hasPreciseP10p90() const override; + void p10p90CellScalarValues( double& min, double& max ) override; + void p10p90CellScalarValues( size_t timeStepIndex, double& min, double& max ) override; void minMaxCellScalarValues( size_t timeStepIndex, double& min, double& max ) override; void posNegClosestToZero( size_t timeStepIndex, double& pos, double& neg ) override; void valueSumAndSampleCount( size_t timeStepIndex, double& valueSum, size_t& sampleCount ) override; diff --git a/ApplicationLibCode/ReservoirDataModel/RigEclipseNativeVisibleCellsStatCalc.cpp b/ApplicationLibCode/ReservoirDataModel/RigEclipseNativeVisibleCellsStatCalc.cpp index 6d3f60aef0..a47db39d5e 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigEclipseNativeVisibleCellsStatCalc.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigEclipseNativeVisibleCellsStatCalc.cpp @@ -49,6 +49,39 @@ void RigEclipseNativeVisibleCellsStatCalc::minMaxCellScalarValues( size_t timeSt max = acc.max; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigEclipseNativeVisibleCellsStatCalc::hasPreciseP10p90() const +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigEclipseNativeVisibleCellsStatCalc::p10p90CellScalarValues( double& p10, double& p90 ) +{ + PercentilAccumulator acc; + + for ( size_t timeStepIndex = 0; timeStepIndex < timeStepCount(); timeStepIndex++ ) + { + traverseCells( acc, timeStepIndex ); + } + + acc.computep10p90( p10, p90 ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigEclipseNativeVisibleCellsStatCalc::p10p90CellScalarValues( size_t timeStepIndex, double& p10, double& p90 ) +{ + PercentilAccumulator acc; + traverseCells( acc, timeStepIndex ); + acc.computep10p90( p10, p90 ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ReservoirDataModel/RigEclipseNativeVisibleCellsStatCalc.h b/ApplicationLibCode/ReservoirDataModel/RigEclipseNativeVisibleCellsStatCalc.h index 641e89b977..bb8511b967 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigEclipseNativeVisibleCellsStatCalc.h +++ b/ApplicationLibCode/ReservoirDataModel/RigEclipseNativeVisibleCellsStatCalc.h @@ -36,6 +36,9 @@ class RigEclipseNativeVisibleCellsStatCalc : public RigStatisticsCalculator const RigEclipseResultAddress& scalarResultIndex, const cvf::UByteArray* cellVisibilities ); + bool hasPreciseP10p90() const override; + void p10p90CellScalarValues( double& min, double& max ) override; + void p10p90CellScalarValues( size_t timeStepIndex, double& min, double& max ) override; void minMaxCellScalarValues( size_t timeStepIndex, double& min, double& max ) override; void posNegClosestToZero( size_t timeStepIndex, double& pos, double& neg ) override; void valueSumAndSampleCount( size_t timeStepIndex, double& valueSum, size_t& sampleCount ) override; @@ -64,8 +67,9 @@ class RigEclipseNativeVisibleCellsStatCalc : public RigStatisticsCalculator return; } - const RigActiveCellInfo* actCellInfo = m_caseData->activeCellInfo(); - size_t cellCount = actCellInfo->reservoirCellCount(); + const RigActiveCellInfo* actCellInfo = m_caseData->activeCellInfo(); + size_t cellCount = actCellInfo->reservoirCellCount(); + bool isUsingGlobalActiveIndex = m_caseData->isUsingGlobalActiveIndex( m_resultAddress ); CVF_TIGHT_ASSERT( cellCount == m_cellVisibilities->size() ); @@ -74,7 +78,7 @@ class RigEclipseNativeVisibleCellsStatCalc : public RigStatisticsCalculator if ( !( *m_cellVisibilities )[cIdx] ) continue; size_t cellResultIndex = cIdx; - if ( m_caseData->isUsingGlobalActiveIndex( m_resultAddress ) ) + if ( isUsingGlobalActiveIndex ) { cellResultIndex = actCellInfo->cellResultIndex( cIdx ); } diff --git a/ApplicationLibCode/ReservoirDataModel/RigEquil.cpp b/ApplicationLibCode/ReservoirDataModel/RigEquil.cpp index a2ac817220..ef37801f87 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigEquil.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigEquil.cpp @@ -18,6 +18,8 @@ #include "RigEquil.h" +#include "RiaTextStringTools.h" + #include //-------------------------------------------------------------------------------------------------- @@ -133,7 +135,7 @@ RigEquil RigEquil::parseString( const QString& keywordData ) QString line( keywordData ); line.replace( "\t", " " ); - QStringList items = line.split( " ", QString::SkipEmptyParts ); + QStringList items = RiaTextStringTools::splitSkipEmptyParts( line ); if ( items.size() > 0 ) { datumDepth = items.at( 0 ).toDouble(); diff --git a/ApplicationLibCode/ReservoirDataModel/RigFlowDiagSolverInterface.cpp b/ApplicationLibCode/ReservoirDataModel/RigFlowDiagSolverInterface.cpp index e3ebbb1781..8cd3b4590c 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigFlowDiagSolverInterface.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigFlowDiagSolverInterface.cpp @@ -563,19 +563,19 @@ void RigFlowDiagSolverInterface::assignPhaseCorrecedPORV( RigFlowDiagResultAddre case RigFlowDiagResultAddress::PHASE_OIL: phaseSaturation = eclipseCaseData->resultValues( RiaDefines::PorosityModelType::MATRIX_MODEL, RiaDefines::ResultCatType::DYNAMIC_NATIVE, - "SOIL", + RiaResultNames::soil(), timeStepIdx ); break; case RigFlowDiagResultAddress::PHASE_GAS: phaseSaturation = eclipseCaseData->resultValues( RiaDefines::PorosityModelType::MATRIX_MODEL, RiaDefines::ResultCatType::DYNAMIC_NATIVE, - "SGAS", + RiaResultNames::sgas(), timeStepIdx ); break; case RigFlowDiagResultAddress::PHASE_WAT: phaseSaturation = eclipseCaseData->resultValues( RiaDefines::PorosityModelType::MATRIX_MODEL, RiaDefines::ResultCatType::DYNAMIC_NATIVE, - "SWAT", + RiaResultNames::swat(), timeStepIdx ); break; default: @@ -607,7 +607,7 @@ void RigFlowDiagSolverInterface::reportRelPermCurveError( const QString& message { if ( m_relpermCurveErrorCount == 0 ) { - RiaLogging::errorInMessageBox( nullptr, "ResInsight", "RelPerm curve problems: \n" + message ); + RiaLogging::warning( "RelPerm curve problems: \n" + message ); } m_relpermCurveErrorCount++; } @@ -619,7 +619,7 @@ void RigFlowDiagSolverInterface::reportPvtCurveError( const QString& message ) { if ( m_pvtCurveErrorCount == 0 ) { - RiaLogging::errorInMessageBox( nullptr, "ResInsight", "PVT curve problems: \n" + message ); + RiaLogging::warning( "PVT curve problems: \n" + message ); } m_pvtCurveErrorCount++; } diff --git a/ApplicationLibCode/ReservoirDataModel/RigLasFileExporter.cpp b/ApplicationLibCode/ReservoirDataModel/RigLasFileExporter.cpp index a761724fc5..ef6f64a1c9 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigLasFileExporter.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigLasFileExporter.cpp @@ -60,9 +60,9 @@ class SingleChannelData { CVF_ASSERT( lasFile ); - if ( !m_curveData->xValues().empty() ) + if ( !m_curveData->propertyValues().empty() ) { - std::vector wellLogValues = m_curveData->xValues( QString::fromStdString( m_unit ) ); + std::vector wellLogValues = m_curveData->propertyValues( QString::fromStdString( m_unit ) ); for ( size_t vIdx = 0; vIdx < wellLogValues.size(); vIdx++ ) { double value = wellLogValues[vIdx]; @@ -119,7 +119,7 @@ class SingleLasFileMetaData { m_logCurveData.push_back( SingleChannelData( channelName, unit, comment, curveData ) ); - for ( double xValue : curveData->xValues() ) + for ( double xValue : curveData->propertyValues() ) { if ( xValue < m_minimumCurveValue ) { @@ -536,7 +536,7 @@ void RigLasFileExporter::appendLasFileDescriptions( const std::vectorcurveData(); } - QString units = curve->curveData()->xUnits(); + QString units = curve->curveData()->propertyValueUnit(); if ( convertCurveUnits || units == RiaWellLogUnitTools::barX100UnitString() ) { diff --git a/ApplicationLibCode/ReservoirDataModel/RigResultAccessorFactory.cpp b/ApplicationLibCode/ReservoirDataModel/RigResultAccessorFactory.cpp index 1957a8d0cc..c510fba1ab 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigResultAccessorFactory.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigResultAccessorFactory.cpp @@ -96,7 +96,8 @@ cvf::ref RigResultAccessorFactory::createFromResultAddress( c size_t adjustedTimeStepIndex = timeStepIndex; if ( resVarAddr.resultCatType() == RiaDefines::ResultCatType::STATIC_NATIVE || - resVarAddr.resultCatType() == RiaDefines::ResultCatType::FORMATION_NAMES ) + resVarAddr.resultCatType() == RiaDefines::ResultCatType::FORMATION_NAMES || + resVarAddr.resultCatType() == RiaDefines::ResultCatType::ALLAN_DIAGRAMS ) { adjustedTimeStepIndex = 0; } diff --git a/ApplicationLibCode/ReservoirDataModel/RigStimPlanModelTools.cpp b/ApplicationLibCode/ReservoirDataModel/RigStimPlanModelTools.cpp index 9e20662f97..b344d91885 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigStimPlanModelTools.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigStimPlanModelTools.cpp @@ -88,10 +88,6 @@ cvf::Vec3d RigStimPlanModelTools::calculateTSTDirection( RigEclipseCaseData* ecl direction *= -1.0; } - // Calculate an adjusted TST direction to improve the zone thickness in the well log plot. - // Using average of TST and TVD (default direction) in 3D. - direction = ( direction + defaultDirection ) / 2.0; - return direction; } @@ -104,6 +100,9 @@ double RigStimPlanModelTools::calculateFormationDip( const cvf::Vec3d& direction return cvf::Math::toDegrees( cvf::GeometryTools::getAngle( direction, -cvf::Vec3d::Z_AXIS ) ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- std::tuple RigStimPlanModelTools::findClosestFaultBarrier( RigEclipseCaseData* eclipseCaseData, const cvf::Vec3d& position, @@ -261,3 +260,35 @@ QString RigStimPlanModelTools::vecToString( const cvf::Vec3d& vec ) { return QString( "[%1, %2, %3]" ).arg( vec.x() ).arg( vec.y() ).arg( vec.z() ); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigStimPlanModelTools::calculatePerforationLength( const cvf::Vec3d& direction, double perforationLength ) +{ + // Deviation from vertical. Since well path is tending downwards we compare with negative z. + double inclination = cvf::GeometryTools::getAngle( direction, -cvf::Vec3d::Z_AXIS ); + + // Keep inclination in 0-90 degrees range + if ( inclination > cvf::PI_D / 2.0 ) + { + inclination = cvf::PI_D - inclination; + } + + double correctedPerforationLength = perforationLength * std::cos( inclination ); + + RiaLogging::info( + QString( "Perforation length correction: original length: %1 inclination: %2 corrected length: %3" ) + .arg( perforationLength ) + .arg( cvf::Math::toDegrees( inclination ) ) + .arg( correctedPerforationLength ) ); + + // Handle well inclination close to 90 dgr to ensure visual perforation interval in StimPlan model plot + if ( std::fabs( cvf::Math::toDegrees( inclination ) - 90.0 ) < 0.1 ) + { + double minimumPerforationInterval = 0.5; + return std::max( minimumPerforationInterval, correctedPerforationLength ); + } + + return correctedPerforationLength; +} diff --git a/ApplicationLibCode/ReservoirDataModel/RigStimPlanModelTools.h b/ApplicationLibCode/ReservoirDataModel/RigStimPlanModelTools.h index 7181631f73..e6b31a349b 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigStimPlanModelTools.h +++ b/ApplicationLibCode/ReservoirDataModel/RigStimPlanModelTools.h @@ -67,4 +67,6 @@ class RigStimPlanModelTools generateBarrierIntersectionsBetweenPoints( RigEclipseCaseData* eclipseCaseData, const cvf::Vec3d& startPosition, const cvf::Vec3d& endPosition ); + + static double calculatePerforationLength( const cvf::Vec3d& wellPathDirection, double perforationLength ); }; diff --git a/ApplicationLibCode/ReservoirDataModel/RigTofAccumulatedPhaseFractionsCalculator.cpp b/ApplicationLibCode/ReservoirDataModel/RigTofAccumulatedPhaseFractionsCalculator.cpp index 4dc72c37b8..08c7e8c742 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigTofAccumulatedPhaseFractionsCalculator.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigTofAccumulatedPhaseFractionsCalculator.cpp @@ -46,15 +46,15 @@ RigTofAccumulatedPhaseFractionsCalculator::RigTofAccumulatedPhaseFractionsCalcul const std::vector* swatResults = eclipseCaseData->resultValues( RiaDefines::PorosityModelType::MATRIX_MODEL, RiaDefines::ResultCatType::DYNAMIC_NATIVE, - "SWAT", + RiaResultNames::swat(), timestep ); const std::vector* soilResults = eclipseCaseData->resultValues( RiaDefines::PorosityModelType::MATRIX_MODEL, RiaDefines::ResultCatType::DYNAMIC_NATIVE, - "SOIL", + RiaResultNames::soil(), timestep ); const std::vector* sgasResults = eclipseCaseData->resultValues( RiaDefines::PorosityModelType::MATRIX_MODEL, RiaDefines::ResultCatType::DYNAMIC_NATIVE, - "SGAS", + RiaResultNames::sgas(), timestep ); const std::vector* porvResults = eclipseCaseData->resultValues( RiaDefines::PorosityModelType::MATRIX_MODEL, RiaDefines::ResultCatType::STATIC_NATIVE, diff --git a/ApplicationLibCode/ReservoirDataModel/RigTofWellDistributionCalculator.cpp b/ApplicationLibCode/ReservoirDataModel/RigTofWellDistributionCalculator.cpp index 7e409efa87..664d6e7e24 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigTofWellDistributionCalculator.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigTofWellDistributionCalculator.cpp @@ -71,11 +71,11 @@ RigTofWellDistributionCalculator::RigTofWellDistributionCalculator( RimEclipseRe QString phaseResultName; if ( phase == RiaDefines::PhaseType::WATER_PHASE ) - phaseResultName = "SWAT"; + phaseResultName = RiaResultNames::swat(); else if ( phase == RiaDefines::PhaseType::OIL_PHASE ) - phaseResultName = "SOIL"; + phaseResultName = RiaResultNames::soil(); else if ( phase == RiaDefines::PhaseType::GAS_PHASE ) - phaseResultName = "SGAS"; + phaseResultName = RiaResultNames::sgas(); const std::vector* phaseResults = eclipseCaseData->resultValues( RiaDefines::PorosityModelType::MATRIX_MODEL, RiaDefines::ResultCatType::DYNAMIC_NATIVE, phaseResultName, diff --git a/ApplicationLibCode/ReservoirDataModel/RigWellLogCurveData.cpp b/ApplicationLibCode/ReservoirDataModel/RigWellLogCurveData.cpp index f4b929ce8b..cda550113a 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigWellLogCurveData.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigWellLogCurveData.cpp @@ -31,11 +31,13 @@ /// //-------------------------------------------------------------------------------------------------- RigWellLogCurveData::RigWellLogCurveData() + : m_isExtractionCurve( false ) + , m_rkbDiff( 0.0 ) + , m_useLogarithmicScale( false ) + , m_depthUnit( RiaDefines::DepthUnitType::UNIT_METER ) + , m_propertyValueUnitString( RiaWellLogUnitTools::noUnitString() ) + { - m_isExtractionCurve = false; - m_rkbDiff = 0.0; - m_depthUnit = RiaDefines::DepthUnitType::UNIT_METER; - m_xUnitString = RiaWellLogUnitTools::noUnitString(); } //-------------------------------------------------------------------------------------------------- @@ -61,14 +63,16 @@ void RigWellLogCurveData::setValuesAndDepths( const std::vector& xValues RiaDefines::DepthTypeEnum depthType, double rkbDiff, RiaDefines::DepthUnitType depthUnit, - bool isExtractionCurve ) + bool isExtractionCurve, + bool useLogarithmicScale ) { CVF_ASSERT( xValues.size() == depths.size() ); - m_xValues = xValues; - m_depths[depthType] = depths; - m_depthUnit = depthUnit; - m_rkbDiff = rkbDiff; + m_propertyValues = xValues; + m_depths[depthType] = depths; + m_depthUnit = depthUnit; + m_rkbDiff = rkbDiff; + m_useLogarithmicScale = useLogarithmicScale; // Disable depth value filtering is intended to be used for // extraction curve data @@ -84,17 +88,19 @@ void RigWellLogCurveData::setValuesAndDepths( const std::vector& const std::map>& depths, double rkbDiff, RiaDefines::DepthUnitType depthUnit, - bool isExtractionCurve ) + bool isExtractionCurve, + bool useLogarithmicScale ) { for ( auto it = depths.begin(); it != depths.end(); ++it ) { CVF_ASSERT( xValues.size() == it->second.size() ); } - m_xValues = xValues; - m_depths = depths; - m_depthUnit = depthUnit; - m_rkbDiff = rkbDiff; + m_propertyValues = xValues; + m_depths = depths; + m_depthUnit = depthUnit; + m_rkbDiff = rkbDiff; + m_useLogarithmicScale = useLogarithmicScale; // Disable depth value filtering is intended to be used for // extraction curve data @@ -106,43 +112,43 @@ void RigWellLogCurveData::setValuesAndDepths( const std::vector& //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigWellLogCurveData::setXUnits( const QString& xUnitString ) +void RigWellLogCurveData::setPropertyValueUnit( const QString& propertyValueUnitString ) { - m_xUnitString = xUnitString; + m_propertyValueUnitString = propertyValueUnitString; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RigWellLogCurveData::xValues() const +std::vector RigWellLogCurveData::propertyValues() const { - return m_xValues; + return m_propertyValues; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RigWellLogCurveData::xValues( const QString& units ) const +std::vector RigWellLogCurveData::propertyValues( const QString& units ) const { std::vector convertedValues; - if ( units != m_xUnitString && + if ( units != m_propertyValueUnitString && RiaWellLogUnitTools::convertValues( depths( RiaDefines::DepthTypeEnum::TRUE_VERTICAL_DEPTH_RKB ), - m_xValues, + m_propertyValues, &convertedValues, - m_xUnitString, + m_propertyValueUnitString, units ) ) { return convertedValues; } - return m_xValues; + return m_propertyValues; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RigWellLogCurveData::xUnits() const +QString RigWellLogCurveData::propertyValueUnit() const { - return m_xUnitString; + return m_propertyValueUnitString; } //-------------------------------------------------------------------------------------------------- @@ -180,6 +186,15 @@ std::vector RigWellLogCurveData::depths( RiaDefines::DepthTypeEnum depth return std::vector(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RigWellLogCurveData::depths( RiaDefines::DepthTypeEnum depthType, + RiaDefines::DepthUnitType destinationDepthUnit ) const +{ + return depthsForDepthUnit( depths( depthType ), m_depthUnit, destinationDepthUnit ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -212,10 +227,10 @@ std::set RigWellLogCurveData::availableDepthTypes() c //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RigWellLogCurveData::xPlotValues() const +std::vector RigWellLogCurveData::propertyValuesByIntervals() const { std::vector filteredValues; - RiaCurveDataTools::getValuesByIntervals( m_xValues, m_intervalsOfContinousValidValues, &filteredValues ); + RiaCurveDataTools::getValuesByIntervals( m_propertyValues, m_intervalsOfContinousValidValues, &filteredValues ); return filteredValues; } @@ -223,25 +238,14 @@ std::vector RigWellLogCurveData::xPlotValues() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RigWellLogCurveData::depthPlotValues( RiaDefines::DepthTypeEnum depthType, - RiaDefines::DepthUnitType destinationDepthUnit ) const +std::vector RigWellLogCurveData::depthValuesByIntervals( RiaDefines::DepthTypeEnum depthType, + RiaDefines::DepthUnitType destinationDepthUnit ) const { - std::vector filteredValues; + const std::vector depthValues = + RigWellLogCurveData::depthsForDepthUnit( depths( depthType ), m_depthUnit, destinationDepthUnit ); - const std::vector depthValues = depths( depthType ); - if ( !depthValues.empty() ) - { - if ( destinationDepthUnit == m_depthUnit ) - { - RiaCurveDataTools::getValuesByIntervals( depthValues, m_intervalsOfContinousValidValues, &filteredValues ); - } - else - { - std::vector convertedValues = - RiaWellLogUnitTools::convertDepths( depthValues, m_depthUnit, destinationDepthUnit ); - RiaCurveDataTools::getValuesByIntervals( convertedValues, m_intervalsOfContinousValidValues, &filteredValues ); - } - } + std::vector filteredValues; + RiaCurveDataTools::getValuesByIntervals( depthValues, m_intervalsOfContinousValidValues, &filteredValues ); return filteredValues; } @@ -279,8 +283,8 @@ cvf::ref RigWellLogCurveData::calculateResampledCurveData( { double segmentStartMd = mdIt->second[segmentStartIdx]; double segmentEndMd = mdIt->second[segmentStartIdx + 1]; - double segmentStartX = m_xValues[segmentStartIdx]; - double segmentEndX = m_xValues[segmentStartIdx + 1]; + double segmentStartX = m_propertyValues[segmentStartIdx]; + double segmentEndX = m_propertyValues[segmentStartIdx + 1]; double segmentStartTvd = 0.0; double segmentEndTvd = 0.0; @@ -318,7 +322,7 @@ cvf::ref RigWellLogCurveData::calculateResampledCurveData( std::map> resampledDepths = { { RiaDefines::DepthTypeEnum::TRUE_VERTICAL_DEPTH, tvDepths }, { RiaDefines::DepthTypeEnum::MEASURED_DEPTH, measuredDepths } }; - reSampledData->setValuesAndDepths( xValues, resampledDepths, m_rkbDiff, m_depthUnit, true ); + reSampledData->setValuesAndDepths( xValues, resampledDepths, m_rkbDiff, m_depthUnit, true, m_useLogarithmicScale ); } else { @@ -327,7 +331,8 @@ cvf::ref RigWellLogCurveData::calculateResampledCurveData( RiaDefines::DepthTypeEnum::MEASURED_DEPTH, 0.0, m_depthUnit, - m_isExtractionCurve ); + m_isExtractionCurve, + m_useLogarithmicScale ); } return reSampledData; @@ -346,8 +351,8 @@ void RigWellLogCurveData::interpolateSegment( RiaDefines::DepthTypeEnum resampli double depth0 = depthIt->second[firstIndex]; double depth1 = depthIt->second[secondIndex]; - double x0 = m_xValues[firstIndex]; - double x1 = m_xValues[secondIndex]; + double x0 = m_propertyValues[firstIndex]; + double x1 = m_propertyValues[secondIndex]; double slope = 0.0; if ( std::fabs( depth1 - depth0 ) > eps ) { @@ -412,7 +417,7 @@ cvf::ref RigWellLogCurveData::calculateResampledCurveData( if ( std::fabs( depthIt->second[segmentStartIdx] - depth ) < eps ) // already have this depth point, // reuse it { - xValues.push_back( m_xValues[segmentStartIdx] ); + xValues.push_back( m_propertyValues[segmentStartIdx] ); // Copy all depth types for this segment for ( auto depthTypeValuesPair : m_depths ) { @@ -458,7 +463,7 @@ cvf::ref RigWellLogCurveData::calculateResampledCurveData( CAF_ASSERT( foundPoint ); } - reSampledData->setValuesAndDepths( xValues, resampledDepths, m_rkbDiff, m_depthUnit, true ); + reSampledData->setValuesAndDepths( xValues, resampledDepths, m_rkbDiff, m_depthUnit, true, m_useLogarithmicScale ); return reSampledData; } @@ -468,7 +473,7 @@ cvf::ref RigWellLogCurveData::calculateResampledCurveData( void RigWellLogCurveData::calculateIntervalsOfContinousValidValues() { std::vector> intervalsOfValidValues = - RiaCurveDataTools::calculateIntervalsOfValidValues( m_xValues, false ); + RiaCurveDataTools::calculateIntervalsOfValidValues( m_propertyValues, m_useLogarithmicScale ); m_intervalsOfContinousValidValues.clear(); @@ -495,6 +500,20 @@ void RigWellLogCurveData::calculateIntervalsOfContinousValidValues() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RigWellLogCurveData::depthsForDepthUnit( const std::vector& depths, + RiaDefines::DepthUnitType sourceDepthUnit, + RiaDefines::DepthUnitType destinationDepthUnit ) +{ + if ( destinationDepthUnit == sourceDepthUnit ) return depths; + + std::vector convertedValues = + RiaWellLogUnitTools::convertDepths( depths, sourceDepthUnit, destinationDepthUnit ); + return convertedValues; +} + //-------------------------------------------------------------------------------------------------- /// Splits the start stop interval between cells that are not close enough. //-------------------------------------------------------------------------------------------------- @@ -557,7 +576,7 @@ bool RigWellLogCurveData::calculateDepthRange( RiaDefines::DepthTypeEnum depthTy double minValue = HUGE_VAL; double maxValue = -HUGE_VAL; - std::vector depthValues = depthPlotValues( depthType, depthUnit ); + std::vector depthValues = depthValuesByIntervals( depthType, depthUnit ); for ( size_t vIdx = 0; vIdx < depthValues.size(); vIdx++ ) { double value = depthValues[vIdx]; diff --git a/ApplicationLibCode/ReservoirDataModel/RigWellLogCurveData.h b/ApplicationLibCode/ReservoirDataModel/RigWellLogCurveData.h index 20194c5126..e44097f7e3 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigWellLogCurveData.h +++ b/ApplicationLibCode/ReservoirDataModel/RigWellLogCurveData.h @@ -43,24 +43,29 @@ class RigWellLogCurveData : public cvf::Object void setDepthUnit( RiaDefines::DepthUnitType depthUnit ); - void setValuesAndDepths( const std::vector& xValues, + void setValuesAndDepths( const std::vector& propertyValues, const std::vector& depths, RiaDefines::DepthTypeEnum depthType, double rkbDiff, RiaDefines::DepthUnitType depthUnit, - bool isExtractionCurve ); - void setValuesAndDepths( const std::vector& xValues, + bool isExtractionCurve, + bool useLogarithmicScale ); + + void setValuesAndDepths( const std::vector& propertyValues, const std::map>& depths, double rkbDiff, RiaDefines::DepthUnitType depthUnit, - bool isExtractionCurve ); - void setXUnits( const QString& xUnitString ); + bool isExtractionCurve, + bool useLogarithmicScale ); + + void setPropertyValueUnit( const QString& propertyValueUnitString ); - std::vector xValues() const; - std::vector xValues( const QString& units ) const; - QString xUnits() const; + std::vector propertyValues() const; + std::vector propertyValues( const QString& units ) const; + QString propertyValueUnit() const; std::vector depths( RiaDefines::DepthTypeEnum depthType ) const; + std::vector depths( RiaDefines::DepthTypeEnum depthType, RiaDefines::DepthUnitType destinationDepthUnit ) const; std::set availableDepthTypes() const; @@ -71,9 +76,9 @@ class RigWellLogCurveData : public cvf::Object RiaDefines::DepthUnitType depthUnit() const; - std::vector xPlotValues() const; - std::vector depthPlotValues( RiaDefines::DepthTypeEnum depthType, - RiaDefines::DepthUnitType destinationDepthUnit ) const; + std::vector propertyValuesByIntervals() const; + std::vector depthValuesByIntervals( RiaDefines::DepthTypeEnum depthType, + RiaDefines::DepthUnitType destinationDepthUnit ) const; std::vector> polylineStartStopIndices() const; cvf::ref calculateResampledCurveData( double newMeasuredDepthStepSize ) const; @@ -89,19 +94,24 @@ class RigWellLogCurveData : public cvf::Object private: void calculateIntervalsOfContinousValidValues(); + static std::vector depthsForDepthUnit( const std::vector& depths, + RiaDefines::DepthUnitType sourceDepthUnit, + RiaDefines::DepthUnitType destinationDepthUnit ); + static void splitIntervalAtEmptySpace( const std::vector& depthValues, size_t startIdx, size_t stopIdx, std::vector>* intervals ); private: - std::vector m_xValues; + std::vector m_propertyValues; std::map> m_depths; bool m_isExtractionCurve; double m_rkbDiff; + bool m_useLogarithmicScale; std::vector> m_intervalsOfContinousValidValues; RiaDefines::DepthUnitType m_depthUnit; - QString m_xUnitString; + QString m_propertyValueUnitString; }; diff --git a/ApplicationLibCode/ReservoirDataModel/RigWellPathGeometryTools.cpp b/ApplicationLibCode/ReservoirDataModel/RigWellPathGeometryTools.cpp index e849e2b0c4..a1ecd0f8b2 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigWellPathGeometryTools.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigWellPathGeometryTools.cpp @@ -24,9 +24,64 @@ #include "cvfMatrix3.h" #include "RiaOffshoreSphericalCoords.h" + +#include "qwt_curve_fitter.h" +#include "qwt_spline.h" +#include "qwt_spline_curve_fitter.h" + #include #include +int RigWellPathGeometryTools::lookup( double x, const QPolygonF& values ) +{ +#if 0 + //qLowerBound/qHigherBound ??? +#endif + int i1; + const int size = values.size(); + + if ( x <= values[0].x() ) + i1 = 0; + else if ( x >= values[size - 2].x() ) + i1 = size - 2; + else + { + i1 = 0; + int i2 = size - 2; + int i3 = 0; + + while ( i2 - i1 > 1 ) + { + i3 = i1 + ( ( i2 - i1 ) >> 1 ); + + if ( values[i3].x() > x ) + i2 = i3; + else + i1 = i3; + } + } + return i1; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigWellPathGeometryTools::value( double x, const QPolygonF& values ) +{ + if ( values.size() == 0 ) return 0.0; + + const int i = lookup( x, values ); + + if ( i >= values.size() - 1 ) return values.back().y(); + + auto low = values[i]; + auto high = values[i + 1]; + + auto delta = ( x - low.x() ) / ( high.x() - low.x() ); + + return ( 1 - delta ) * low.y() + delta * high.y(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -97,24 +152,24 @@ std::vector RigWellPathGeometryTools::interpolateMdFromTvd( const std::v std::vector interpolatedMdValues; interpolatedMdValues.reserve( tvdValuesToInterpolateFrom.size() ); - QwtSpline spline = createSpline( originalMdValues, originalTvdValues ); - std::vector segmentStartIndices = findSplineSegmentsContainingRoots( spline, tvdValuesToInterpolateFrom ); + auto splinePoints = createSplinePoints( originalMdValues, originalTvdValues ); + std::vector segmentStartIndices = findSplineSegmentsContainingRoots( splinePoints, tvdValuesToInterpolateFrom ); for ( size_t i = 0; i < segmentStartIndices.size(); ++i ) { double currentTVDValue = tvdValuesToInterpolateFrom[i]; - double startMD = spline.points().front().x(); - double endMD = spline.points().back().y(); + double startMD = splinePoints.front().x(); + double endMD = splinePoints.back().y(); if ( segmentStartIndices[i] != -1 ) { int startIndex = segmentStartIndices[i]; int endIndex = startIndex + 1; // Search interval for best MD value - startMD = spline.points()[startIndex].x(); - endMD = spline.points().back().y(); + startMD = splinePoints[startIndex].x(); + endMD = splinePoints.back().y(); - if ( endIndex < spline.points().size() ) + if ( endIndex < splinePoints.size() ) { if ( !interpolatedMdValues.empty() ) { @@ -125,10 +180,10 @@ std::vector RigWellPathGeometryTools::interpolateMdFromTvd( const std::v } startMD = std::max( startMD, interpolatedMdValues.back() + 0.1 * mdDiff ); } - endMD = spline.points()[endIndex].x(); + endMD = splinePoints[endIndex].x(); } } - double mdValue = solveForX( spline, startMD, endMD, currentTVDValue ); + double mdValue = solveForX( splinePoints, startMD, endMD, currentTVDValue ); interpolatedMdValues.push_back( mdValue ); } return interpolatedMdValues; @@ -193,7 +248,7 @@ std::pair /// //-------------------------------------------------------------------------------------------------- std::vector - RigWellPathGeometryTools::findSplineSegmentsContainingRoots( const QwtSpline& spline, + RigWellPathGeometryTools::findSplineSegmentsContainingRoots( const QPolygonF& points, const std::vector& tvdValuesToInterpolateFrom ) { std::vector segmentStartIndices; @@ -206,9 +261,9 @@ std::vector bool foundMatch = false; // Increment current_it until we find an interval containing our TVD - while ( currentSplineStartIndex < spline.points().size() - 2 ) + while ( currentSplineStartIndex < points.size() - 2 ) { - double diffCurrent = spline.points()[currentSplineStartIndex].y() - tvdValue; + double diffCurrent = points[currentSplineStartIndex].y() - tvdValue; if ( std::abs( diffCurrent ) < 1.0e-8 ) // Current is matching the point { foundMatch = true; @@ -217,7 +272,7 @@ std::vector int nextStartIndex = currentSplineStartIndex + 1; - double diffNext = spline.points()[nextStartIndex].y() - tvdValue; + double diffNext = points[nextStartIndex].y() - tvdValue; if ( diffCurrent * diffNext < 0.0 ) // One is above, the other is below { foundMatch = true; @@ -325,7 +380,7 @@ cvf::Vec3d RigWellPathGeometryTools::estimateDominantDirectionInXYPlane( const s //-------------------------------------------------------------------------------------------------- /// Golden-section minimization: https://en.wikipedia.org/wiki/Golden-section_search //-------------------------------------------------------------------------------------------------- -double RigWellPathGeometryTools::solveForX( const QwtSpline& spline, double minX, double maxX, double y ) +double RigWellPathGeometryTools::solveForX( const QPolygonF& spline, double minX, double maxX, double y ) { const double phi = ( 1.0 + std::sqrt( 5.0 ) ) / 2.0; const double tol = 1.0e-8; @@ -334,8 +389,8 @@ double RigWellPathGeometryTools::solveForX( const QwtSpline& spline, double minX double c = b - ( b - a ) / phi; double d = a + ( b - a ) / phi; - double fc = spline.value( c ) - y; - double fd = spline.value( d ) - y; + double fc = value( c, spline ) - y; + double fd = value( d, spline ) - y; for ( int n = 0; n < 100; ++n ) { @@ -350,7 +405,8 @@ double RigWellPathGeometryTools::solveForX( const QwtSpline& spline, double minX d = c; fd = fc; c = b - ( b - a ) / phi; - fc = spline.value( c ) - y; + + fc = value( c, spline ) - y; } else { @@ -358,7 +414,7 @@ double RigWellPathGeometryTools::solveForX( const QwtSpline& spline, double minX c = d; fc = fd; d = a + ( b - a ) / phi; - fd = spline.value( d ) - y; + fd = value( d, spline ) - y; } } return ( a + b ) / 2.0; @@ -367,8 +423,8 @@ double RigWellPathGeometryTools::solveForX( const QwtSpline& spline, double minX //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QwtSpline RigWellPathGeometryTools::createSpline( const std::vector& originalMdValues, - const std::vector& originalTvdValues ) +QPolygonF RigWellPathGeometryTools::createSplinePoints( const std::vector& originalMdValues, + const std::vector& originalTvdValues ) { QPolygonF polygon; for ( size_t i = 0; i < originalMdValues.size(); ++i ) @@ -376,7 +432,9 @@ QwtSpline RigWellPathGeometryTools::createSpline( const std::vector& ori polygon << QPointF( originalMdValues[i], originalTvdValues[i] ); } QwtSplineCurveFitter curveFitter; - QPolygonF splinePoints = curveFitter.fitCurve( polygon ); + double tolerance = 0.5; + auto splinePoints = curveFitter.spline()->polygon( polygon, tolerance ); + if ( splinePoints.empty() ) splinePoints = polygon; // Extend spline from 0.0 (if it does not already exist) to a large value for MD // This is to force a specific and known extrapolation. @@ -405,8 +463,5 @@ QwtSpline RigWellPathGeometryTools::createSpline( const std::vector& ori splinePoints.push_back( endPoint ); } - QwtSpline spline; - spline.setPoints( splinePoints ); - - return spline; + return splinePoints; } diff --git a/ApplicationLibCode/ReservoirDataModel/RigWellPathGeometryTools.h b/ApplicationLibCode/ReservoirDataModel/RigWellPathGeometryTools.h index 94fbfef20e..dd4a9873b2 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigWellPathGeometryTools.h +++ b/ApplicationLibCode/ReservoirDataModel/RigWellPathGeometryTools.h @@ -20,12 +20,10 @@ #include "cvfVector3.h" -#include -#include - -#include +#include #include +#include class RigWellPath; @@ -56,10 +54,15 @@ class RigWellPathGeometryTools const std::vector& vertices ); static cvf::Vec3d estimateDominantDirectionInXYPlane( const std::vector& vertices ); - static double solveForX( const QwtSpline& spline, double minX, double maxX, double y ); + static double solveForX( const QPolygonF& spline, double minX, double maxX, double y ); - static QwtSpline createSpline( const std::vector& originalMdValues, - const std::vector& originalTvdValues ); - static std::vector findSplineSegmentsContainingRoots( const QwtSpline& spline, + static QPolygonF createSplinePoints( const std::vector& originalMdValues, + const std::vector& originalTvdValues ); + + static std::vector findSplineSegmentsContainingRoots( const QPolygonF& points, const std::vector& tvdValuesToInterpolateFrom ); + + // Temporary helper function to method removed from Qwt >= 6.2 + static int lookup( double x, const QPolygonF& values ); + static double value( double x, const QPolygonF& values ); }; diff --git a/ApplicationLibCode/ResultStatisticsCache/RigStatisticsCalculator.cpp b/ApplicationLibCode/ResultStatisticsCache/RigStatisticsCalculator.cpp index b7d8afe85b..41a328ac92 100644 --- a/ApplicationLibCode/ResultStatisticsCache/RigStatisticsCalculator.cpp +++ b/ApplicationLibCode/ResultStatisticsCache/RigStatisticsCalculator.cpp @@ -19,6 +19,7 @@ #include "RigStatisticsCalculator.h" +#include #include // Needed for HUGE_VAL on Linux //-------------------------------------------------------------------------------------------------- @@ -135,3 +136,27 @@ void RigStatisticsCalculator::posNegClosestToZero( const std::vector& va } } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigStatisticsCalculator::hasPreciseP10p90() const +{ + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigStatisticsCalculator::p10p90CellScalarValues( double& p10, double& p90 ) +{ + assert( false && "Precise p10/p90 not available" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigStatisticsCalculator::p10p90CellScalarValues( size_t timeStepIndex, double& p10, double& p90 ) +{ + assert( false && "Precise p10/p90 not available" ); +} diff --git a/ApplicationLibCode/ResultStatisticsCache/RigStatisticsCalculator.h b/ApplicationLibCode/ResultStatisticsCache/RigStatisticsCalculator.h index 31f4efd9f2..0c37ed37ea 100644 --- a/ApplicationLibCode/ResultStatisticsCache/RigStatisticsCalculator.h +++ b/ApplicationLibCode/ResultStatisticsCache/RigStatisticsCalculator.h @@ -46,6 +46,10 @@ class RigStatisticsCalculator : public cvf::Object virtual void uniqueValues( size_t timeStepIndex, std::set& values ) = 0; + virtual bool hasPreciseP10p90() const; + virtual void p10p90CellScalarValues( double& p10, double& p90 ); + virtual void p10p90CellScalarValues( size_t timeStepIndex, double& p10, double& p90 ); + virtual size_t timeStepCount() = 0; void mobileVolumeWeightedMean( double& mean ); diff --git a/ApplicationLibCode/ResultStatisticsCache/RigStatisticsDataCache.cpp b/ApplicationLibCode/ResultStatisticsCache/RigStatisticsDataCache.cpp index 72e37c971b..4176d50a6c 100644 --- a/ApplicationLibCode/ResultStatisticsCache/RigStatisticsDataCache.cpp +++ b/ApplicationLibCode/ResultStatisticsCache/RigStatisticsDataCache.cpp @@ -310,7 +310,23 @@ void RigStatisticsDataCache::mobileVolumeWeightedMean( double& mean ) //-------------------------------------------------------------------------------------------------- void RigStatisticsDataCache::p10p90CellScalarValues( double& p10, double& p90 ) { - computeHistogramStatisticsIfNeeded(); + if ( !m_statsAllTimesteps.m_isp10p90Calculated ) + { + if ( m_statisticsCalculator->hasPreciseP10p90() ) + { + // Prefer precise p10/p90 calculation where available + m_statisticsCalculator->p10p90CellScalarValues( p10, p90 ); + + m_statsAllTimesteps.m_p10 = p10; + m_statsAllTimesteps.m_p90 = p90; + } + else + { + computeHistogramStatisticsIfNeeded(); + } + + m_statsAllTimesteps.m_isp10p90Calculated = true; + } p10 = m_statsAllTimesteps.m_p10; p90 = m_statsAllTimesteps.m_p90; @@ -321,7 +337,28 @@ void RigStatisticsDataCache::p10p90CellScalarValues( double& p10, double& p90 ) //-------------------------------------------------------------------------------------------------- void RigStatisticsDataCache::p10p90CellScalarValues( size_t timeStepIndex, double& p10, double& p90 ) { - computeHistogramStatisticsIfNeeded( timeStepIndex ); + if ( timeStepIndex >= m_statsPrTs.size() ) + { + m_statsPrTs.resize( timeStepIndex + 1 ); + } + + if ( !m_statsPrTs[timeStepIndex].m_isp10p90Calculated ) + { + if ( m_statisticsCalculator->hasPreciseP10p90() ) + { + // Prefer precise p10/p90 calculation where available + m_statisticsCalculator->p10p90CellScalarValues( timeStepIndex, p10, p90 ); + + m_statsPrTs[timeStepIndex].m_p10 = p10; + m_statsPrTs[timeStepIndex].m_p90 = p90; + } + else + { + computeHistogramStatisticsIfNeeded( timeStepIndex ); + } + + m_statsPrTs[timeStepIndex].m_isp10p90Calculated = true; + } p10 = m_statsPrTs[timeStepIndex].m_p10; p90 = m_statsPrTs[timeStepIndex].m_p90; diff --git a/ApplicationLibCode/ResultStatisticsCache/RigStatisticsDataCache.h b/ApplicationLibCode/ResultStatisticsCache/RigStatisticsDataCache.h index 1cc1147ae3..7ca6f844e5 100644 --- a/ApplicationLibCode/ResultStatisticsCache/RigStatisticsDataCache.h +++ b/ApplicationLibCode/ResultStatisticsCache/RigStatisticsDataCache.h @@ -82,6 +82,7 @@ class RigStatisticsDataCache : public cvf::Object m_isClosestToZeroCalculated = false; m_p10 = HUGE_VAL; m_p90 = HUGE_VAL; + m_isp10p90Calculated = false; m_valueSum = 0.0; m_isValueSumCalculated = false; m_volumeWeightedMean = HUGE_VAL; @@ -101,6 +102,7 @@ class RigStatisticsDataCache : public cvf::Object double m_p10; double m_p90; + bool m_isp10p90Calculated; double m_valueSum; bool m_isValueSumCalculated; diff --git a/ApplicationLibCode/ResultStatisticsCache/RigStatisticsMath.cpp b/ApplicationLibCode/ResultStatisticsCache/RigStatisticsMath.cpp index 0ae38b380b..b8c75c9281 100644 --- a/ApplicationLibCode/ResultStatisticsCache/RigStatisticsMath.cpp +++ b/ApplicationLibCode/ResultStatisticsCache/RigStatisticsMath.cpp @@ -105,20 +105,16 @@ void RigStatisticsMath::calculateStatisticsCurves( const std::vector& va P90 }; - std::vector sortedValues; - double valueSum = 0; + std::vector sortedValues = values; - { - std::multiset vSet( values.begin(), values.end() ); - for ( double v : vSet ) - { - if ( RiaStatisticsTools::isValidNumber( v ) ) - { - sortedValues.push_back( v ); - valueSum += v; - } - } - } + sortedValues.erase( std::remove_if( sortedValues.begin(), + sortedValues.end(), + []( double x ) { return !RiaStatisticsTools::isValidNumber( x ); } ), + sortedValues.end() ); + + std::sort( sortedValues.begin(), sortedValues.end() ); + + double valueSum = std::accumulate( sortedValues.begin(), sortedValues.end(), 0.0 ); int valueCount = (int)sortedValues.size(); double percentiles[] = { 0.1, 0.5, 0.9 }; diff --git a/ApplicationLibCode/ResultStatisticsCache/RigStatisticsMath.h b/ApplicationLibCode/ResultStatisticsCache/RigStatisticsMath.h index b1209edb07..91f0e2bc95 100644 --- a/ApplicationLibCode/ResultStatisticsCache/RigStatisticsMath.h +++ b/ApplicationLibCode/ResultStatisticsCache/RigStatisticsMath.h @@ -130,6 +130,40 @@ class MinMaxAccumulator double min; }; +class PercentilAccumulator +{ +public: + PercentilAccumulator() {} + + void addData( const std::vector& values ) + { + for ( double val : values ) + { + addValue( val ); + } + } + + void addData( const std::vector& values ) + { + for ( float val : values ) + { + addValue( val ); + } + } + + void addValue( double value ) { values.push_back( value ); } + + void computep10p90( double& p10, double& p90 ) + { + double mean = HUGE_VAL; + double p50 = HUGE_VAL; + + RigStatisticsMath::calculateStatisticsCurves( values, &p10, &p50, &p90, &mean, RigStatisticsMath::PercentileStyle::SWITCHED ); + } + + std::vector values; +}; + class PosNegAccumulator { public: diff --git a/ApplicationLibCode/RiuThemesDirectory.h.cmake b/ApplicationLibCode/RiuThemesDirectory.h.cmake index a8572d890e..e945a82982 100644 --- a/ApplicationLibCode/RiuThemesDirectory.h.cmake +++ b/ApplicationLibCode/RiuThemesDirectory.h.cmake @@ -1,3 +1,3 @@ // Test data directory used by unit tests -#define GUI_THEMES_DIR "${CMAKE_CURRENT_LIST_DIR}/Resources/themes" \ No newline at end of file +#define GUI_THEMES_DIR "${CMAKE_CURRENT_LIST_DIR}/../ApplicationExeCode/Resources/themes" diff --git a/ApplicationLibCode/UnitTests/CMakeLists_files.cmake b/ApplicationLibCode/UnitTests/CMakeLists_files.cmake index 7ab65025b3..2e5cb9569d 100644 --- a/ApplicationLibCode/UnitTests/CMakeLists_files.cmake +++ b/ApplicationLibCode/UnitTests/CMakeLists_files.cmake @@ -60,7 +60,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCaseCollection-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RifActiveCellsReader-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RifCsvDataTableFormatter-Test.cpp - ${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveAnalyzer-Test.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiaSummaryAddressAnalyzer-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaStdStringTools-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaInterpolationTools-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RifWellMeasurementReader-Test.cpp @@ -81,6 +81,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/StructGridInterface-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/opm-summary-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RifEclipseTextFileReader-Test.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiaSummaryStringTools-Test.cpp ) if(RESINSIGHT_ENABLE_GRPC) diff --git a/ApplicationLibCode/UnitTests/ObservedDataParser-Test.cpp b/ApplicationLibCode/UnitTests/ObservedDataParser-Test.cpp index 4da0bff5f7..245948da06 100644 --- a/ApplicationLibCode/UnitTests/ObservedDataParser-Test.cpp +++ b/ApplicationLibCode/UnitTests/ObservedDataParser-Test.cpp @@ -1,16 +1,19 @@ #include "gtest/gtest.h" +#include "RiaQDateTimeTools.h" #include "RifColumnBasedUserData.h" #include "RifColumnBasedUserDataParser.h" #include "RifCsvUserDataParser.h" +#include "RifEclipseUserDataKeywordTools.h" #include "RifEclipseUserDataParserTools.h" #include "RifKeywordVectorParser.h" #include "SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeatureUi.h" -#include "RiaQDateTimeTools.h" -#include "RifEclipseUserDataKeywordTools.h" #include #include + +#include "caf.h" + #include //-------------------------------------------------------------------------------------------------- @@ -21,7 +24,7 @@ TEST( RifColumnBasedAsciiParserTest, TestDateFormatYyyymmddWithDash ) AsciiDataParseOptions parseOptions; parseOptions.dateFormat = "yyyy-MM-dd"; parseOptions.cellSeparator = "\t"; - parseOptions.locale = QLocale::Norwegian; + parseOptions.locale = caf::norwegianLocale(); parseOptions.timeSeriesColumnName = "Date"; QString data; @@ -78,7 +81,7 @@ TEST( RifColumnBasedAsciiParserTest, TestDateFormatYymmddWithDot ) AsciiDataParseOptions parseOptions; parseOptions.dateFormat = "yy.MM.dd"; parseOptions.cellSeparator = "\t"; - parseOptions.locale = QLocale::Norwegian; + parseOptions.locale = caf::norwegianLocale(); parseOptions.timeSeriesColumnName = "Date"; QString data; @@ -133,7 +136,7 @@ TEST( RifColumnBasedAsciiParserTest, TestDateFormatDdmmyyWithDot ) AsciiDataParseOptions parseOptions; parseOptions.dateFormat = "dd.MM.yy"; parseOptions.cellSeparator = "\t"; - parseOptions.locale = QLocale::Norwegian; + parseOptions.locale = caf::norwegianLocale(); parseOptions.timeSeriesColumnName = "Date"; QString data; @@ -188,7 +191,7 @@ TEST( RifColumnBasedAsciiParserTest, TestDecimalLocaleNorwegian ) parseOptions.dateFormat = "yy.MM.dd"; parseOptions.cellSeparator = "\t"; parseOptions.decimalSeparator = ","; - parseOptions.locale = QLocale::Norwegian; + parseOptions.locale = caf::norwegianLocale(); parseOptions.timeSeriesColumnName = "Date"; QString data; @@ -560,7 +563,7 @@ TEST( RifColumnBasedRsmspecParserTest, TestTableValues ) EXPECT_EQ( 3.0, tables.at( 1 ).columnInfos().at( 0 ).values.at( 2 ) ); EXPECT_EQ( 370.0, tables.at( 1 ).columnInfos().at( 3 ).values.at( 3 ) ); - EXPECT_EQ( "WOPR", tables.at( 0 ).columnInfos().at( 1 ).summaryAddress.quantityName() ); + EXPECT_EQ( "WOPR", tables.at( 0 ).columnInfos().at( 1 ).summaryAddress.vectorName() ); EXPECT_EQ( "P-15P", tables.at( 0 ).columnInfos().at( 5 ).summaryAddress.wellName() ); EXPECT_EQ( "P-9P", tables.at( 1 ).columnInfos().at( 1 ).summaryAddress.wellName() ); EXPECT_NE( "P-9P", tables.at( 1 ).columnInfos().at( 0 ).summaryAddress.wellName() ); @@ -872,7 +875,7 @@ TEST( RifKeywordBasedRsmspecParserTest, TestShutins ) EXPECT_EQ( 2014.39, tables.at( 0 ).columnInfos().at( 1 ).values[2] ); - EXPECT_EQ( "WOPR", tables.at( 0 ).columnInfos().at( 2 ).summaryAddress.quantityName() ); + EXPECT_EQ( "WOPR", tables.at( 0 ).columnInfos().at( 2 ).summaryAddress.vectorName() ); EXPECT_EQ( "OP-1", tables.at( 0 ).columnInfos().at( 2 ).summaryAddress.wellName() ); EXPECT_NE( "OP-1", tables.at( 0 ).columnInfos().at( 1 ).summaryAddress.wellName() ); diff --git a/ApplicationLibCode/UnitTests/RiaDateStringParser-Test.cpp b/ApplicationLibCode/UnitTests/RiaDateStringParser-Test.cpp index 5000eecd40..e38543570d 100644 --- a/ApplicationLibCode/UnitTests/RiaDateStringParser-Test.cpp +++ b/ApplicationLibCode/UnitTests/RiaDateStringParser-Test.cpp @@ -14,7 +14,7 @@ //-------------------------------------------------------------------------------------------------- TEST( RiaDateStringParserTest, ParseYearFirstWithSeparators ) { - QDateTime may2ndDT = QDateTime( QDate( 2011, 05, 02 ) ); + QDateTime may2ndDT = RiaQDateTimeTools::createDateTime( QDate( 2011, 05, 02 ) ); may2ndDT.setTimeSpec( RiaQDateTimeTools::currentTimeSpec() ); std::vector may2ndStrings = { "2011 05 02", @@ -33,7 +33,7 @@ TEST( RiaDateStringParserTest, ParseYearFirstWithSeparators ) EXPECT_TRUE( may2ndDT == parsedDate ); } - QDateTime nov24thDT = QDateTime( QDate( 1992, 11, 24 ) ); + QDateTime nov24thDT = RiaQDateTimeTools::createDateTime( QDate( 1992, 11, 24 ) ); nov24thDT.setTimeSpec( RiaQDateTimeTools::currentTimeSpec() ); std::vector nov24thStrings = { "1992-11-24", "1992-Nov-24", "1992-nov-24", "1992.11.24" }; @@ -48,7 +48,7 @@ TEST( RiaDateStringParserTest, ParseYearFirstWithSeparators ) //-------------------------------------------------------------------------------------------------- TEST( RiaDateStringParserTest, ParseDayFirstWithSeparators ) { - QDateTime may2ndDT = QDateTime( QDate( 2011, 05, 02 ) ); + QDateTime may2ndDT = RiaQDateTimeTools::createDateTime( QDate( 2011, 05, 02 ) ); may2ndDT.setTimeSpec( RiaQDateTimeTools::currentTimeSpec() ); std::vector may2ndStrings = { "02 05 2011", @@ -66,7 +66,7 @@ TEST( RiaDateStringParserTest, ParseDayFirstWithSeparators ) EXPECT_TRUE( may2ndDT == parsedDate ); } - QDateTime nov24thDT = QDateTime( QDate( 1992, 11, 24 ) ); + QDateTime nov24thDT = RiaQDateTimeTools::createDateTime( QDate( 1992, 11, 24 ) ); nov24thDT.setTimeSpec( RiaQDateTimeTools::currentTimeSpec() ); std::vector nov24thStrings = { "24-11-1992", "24-Nov-1992", "24.Nov 1992", "24.11.1992" }; @@ -81,7 +81,7 @@ TEST( RiaDateStringParserTest, ParseDayFirstWithSeparators ) //-------------------------------------------------------------------------------------------------- TEST( RiaDateStringParserTest, ParseMonthFirstWithSeparators ) { - QDateTime may2ndDT = QDateTime( QDate( 2011, 05, 02 ) ); + QDateTime may2ndDT = RiaQDateTimeTools::createDateTime( QDate( 2011, 05, 02 ) ); may2ndDT.setTimeSpec( RiaQDateTimeTools::currentTimeSpec() ); std::vector may2ndStrings = { "May 02 2011", "may 02 2011", "May_02_2011", "May.02.2011", "May 02. 2011" }; @@ -91,7 +91,7 @@ TEST( RiaDateStringParserTest, ParseMonthFirstWithSeparators ) EXPECT_TRUE( may2ndDT == parsedDate ); } - QDateTime nov24thDT = QDateTime( QDate( 1992, 11, 24 ) ); + QDateTime nov24thDT = RiaQDateTimeTools::createDateTime( QDate( 1992, 11, 24 ) ); nov24thDT.setTimeSpec( RiaQDateTimeTools::currentTimeSpec() ); std::vector nov24thStrings = { "11-24-1992", "Nov-24-1992", "Nov 24. 1992", "11.24.1992", "11 24 1992" }; @@ -106,8 +106,8 @@ TEST( RiaDateStringParserTest, ParseMonthFirstWithSeparators ) //-------------------------------------------------------------------------------------------------- TEST( RiaDateStringParserTest, ParseWithoutSeparators ) { - QDateTime may2ndDT = QDateTime( QDate( 2011, 05, 02 ) ); - QDateTime feb5thDT = QDateTime( QDate( 2011, 02, 05 ) ); + QDateTime may2ndDT = RiaQDateTimeTools::createDateTime( QDate( 2011, 05, 02 ) ); + QDateTime feb5thDT = RiaQDateTimeTools::createDateTime( QDate( 2011, 02, 05 ) ); may2ndDT.setTimeSpec( RiaQDateTimeTools::currentTimeSpec() ); feb5thDT.setTimeSpec( RiaQDateTimeTools::currentTimeSpec() ); @@ -122,7 +122,7 @@ TEST( RiaDateStringParserTest, ParseWithoutSeparators ) EXPECT_FALSE( may2ndDT == RiaDateStringParser::parseDateString( may2ndMonthFirstString ) ); EXPECT_TRUE( feb5thDT == RiaDateStringParser::parseDateString( may2ndMonthFirstString ) ); - QDateTime nov24thDT = QDateTime( QDate( 1992, 11, 24 ) ); + QDateTime nov24thDT = RiaQDateTimeTools::createDateTime( QDate( 1992, 11, 24 ) ); nov24thDT.setTimeSpec( RiaQDateTimeTools::currentTimeSpec() ); std::vector nov24thStrings = { "19921124", "24111992", "921124", "241192", "11241992", "112492" }; diff --git a/ApplicationLibCode/UnitTests/RiaSummaryCurveAnalyzer-Test.cpp b/ApplicationLibCode/UnitTests/RiaSummaryAddressAnalyzer-Test.cpp similarity index 73% rename from ApplicationLibCode/UnitTests/RiaSummaryCurveAnalyzer-Test.cpp rename to ApplicationLibCode/UnitTests/RiaSummaryAddressAnalyzer-Test.cpp index c69c5b1eff..9dc48e58e9 100644 --- a/ApplicationLibCode/UnitTests/RiaSummaryCurveAnalyzer-Test.cpp +++ b/ApplicationLibCode/UnitTests/RiaSummaryAddressAnalyzer-Test.cpp @@ -1,11 +1,11 @@ #include "gtest/gtest.h" -#include "RiaSummaryCurveAnalyzer.h" +#include "RiaSummaryAddressAnalyzer.h" //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -TEST( RiaSummaryCurveAnalyzer, WellCompletions ) +TEST( RiaSummaryAddressAnalyzer, WellCompletions ) { std::vector addresses; @@ -45,7 +45,7 @@ TEST( RiaSummaryCurveAnalyzer, WellCompletions ) addresses.push_back( adr ); } - RiaSummaryCurveAnalyzer analyzer; + RiaSummaryAddressAnalyzer analyzer; analyzer.appendAddresses( addresses ); EXPECT_EQ( 2u, analyzer.wellNames().size() ); @@ -62,7 +62,7 @@ TEST( RiaSummaryCurveAnalyzer, WellCompletions ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -TEST( RiaSummaryCurveAnalyzer, WellSegments ) +TEST( RiaSummaryAddressAnalyzer, WellSegments ) { std::vector addresses; @@ -96,7 +96,7 @@ TEST( RiaSummaryCurveAnalyzer, WellSegments ) addresses.push_back( adr ); } - RiaSummaryCurveAnalyzer analyzer; + RiaSummaryAddressAnalyzer analyzer; analyzer.appendAddresses( addresses ); EXPECT_EQ( 2u, analyzer.wellNames().size() ); @@ -111,7 +111,7 @@ TEST( RiaSummaryCurveAnalyzer, WellSegments ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -TEST( RiaSummaryCurveAnalyzer, CellBlocks ) +TEST( RiaSummaryAddressAnalyzer, CellBlocks ) { std::vector addresses; @@ -132,9 +132,48 @@ TEST( RiaSummaryCurveAnalyzer, CellBlocks ) addresses.push_back( adr ); } - RiaSummaryCurveAnalyzer analyzer; + RiaSummaryAddressAnalyzer analyzer; analyzer.appendAddresses( addresses ); auto blocks = analyzer.blocks(); EXPECT_EQ( 3u, blocks.size() ); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST( RiaSummaryAddressAnalyzer, QuantitiesPerCategory ) +{ + std::vector addresses; + + { + RifEclipseSummaryAddress adr = RifEclipseSummaryAddress::fieldAddress( "FOPT" ); + addresses.push_back( adr ); + } + { + RifEclipseSummaryAddress adr = RifEclipseSummaryAddress::fieldAddress( "FOPR" ); + addresses.push_back( adr ); + } + + { + RifEclipseSummaryAddress adr = RifEclipseSummaryAddress::wellAddress( "WOPT", "WellA" ); + addresses.push_back( adr ); + } + { + RifEclipseSummaryAddress adr = RifEclipseSummaryAddress::wellAddress( "WOPR", "WellB" ); + addresses.push_back( adr ); + } + { + RifEclipseSummaryAddress adr = RifEclipseSummaryAddress::wellAddress( "WWPR", "WellA" ); + addresses.push_back( adr ); + } + + RiaSummaryAddressAnalyzer analyzer; + analyzer.appendAddresses( addresses ); + + auto categories = analyzer.categories(); + EXPECT_EQ( 2u, categories.size() ); + + auto vectorNamesForWells = analyzer.vectorNamesForCategory( RifEclipseSummaryAddress::SUMMARY_WELL ); + EXPECT_EQ( 3u, vectorNamesForWells.size() ); +} diff --git a/ApplicationLibCode/UnitTests/RiaSummaryStringTools-Test.cpp b/ApplicationLibCode/UnitTests/RiaSummaryStringTools-Test.cpp new file mode 100644 index 0000000000..9735fa2404 --- /dev/null +++ b/ApplicationLibCode/UnitTests/RiaSummaryStringTools-Test.cpp @@ -0,0 +1,46 @@ +#include "gtest/gtest.h" + +#include "RiaSummaryStringTools.h" + +#include +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST( RiaSummaryStringToolsTest, ParseNumbers ) +{ + QString wellFilter = "wopt:op_*"; + QString fieldFilter = "fopt"; + QStringList dataSourceNames = { "iter-1", "iter-22", "real-10", "real-11" }; + + { + QString dataSourceFilter = "iter-1"; + QStringList arguments = { wellFilter, fieldFilter, dataSourceFilter }; + + QStringList addressFilters; + QStringList dataSourceFilters; + + RiaSummaryStringTools::splitUsingDataSourceNames( arguments, dataSourceNames, addressFilters, dataSourceFilters ); + + EXPECT_TRUE( addressFilters[0] == wellFilter ); + EXPECT_TRUE( addressFilters[1] == fieldFilter ); + + EXPECT_TRUE( dataSourceFilters[0] == dataSourceFilter ); + } + + { + QString dataSourceFilter = "iter-22:real-2*"; + QStringList arguments = { wellFilter, fieldFilter, dataSourceFilter }; + + QStringList addressFilters; + QStringList dataSourceFilters; + + RiaSummaryStringTools::splitUsingDataSourceNames( arguments, dataSourceNames, addressFilters, dataSourceFilters ); + + EXPECT_TRUE( addressFilters[0] == wellFilter ); + EXPECT_TRUE( addressFilters[1] == fieldFilter ); + + EXPECT_TRUE( dataSourceFilters[0] == dataSourceFilter ); + } +} diff --git a/ApplicationLibCode/UnitTests/RiaTimeHistoryCurveTools-Test.cpp b/ApplicationLibCode/UnitTests/RiaTimeHistoryCurveTools-Test.cpp index fcabcb6677..4826dfb52f 100644 --- a/ApplicationLibCode/UnitTests/RiaTimeHistoryCurveTools-Test.cpp +++ b/ApplicationLibCode/UnitTests/RiaTimeHistoryCurveTools-Test.cpp @@ -35,7 +35,7 @@ TEST( RiaTimeHistoryCurveResampler, Test_Resampling_NoPeriod ) RiaTimeHistoryCurveResampler resampler; resampler.setCurveData( dataValues, toSecsSinceEpochVector( timeStrings ) ); - resampler.resampleAndComputeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod::MONTH ); + resampler.resampleAndComputeWeightedMeanValues( RiaDefines::DateTimePeriod::MONTH ); EXPECT_EQ( 1, (int)resampler.resampledTimeSteps().size() ); EXPECT_EQ( toSecsSinceEpoch( "2018-03-01" ), resampler.resampledTimeSteps()[0] ); @@ -52,7 +52,7 @@ TEST( RiaTimeHistoryCurveResampler, Test_Resampling_Decade ) RiaTimeHistoryCurveResampler resampler; resampler.setCurveData( dataValues, toSecsSinceEpochVector( timeStrings ) ); - resampler.resampleAndComputeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod::DECADE ); + resampler.resampleAndComputeWeightedMeanValues( RiaDefines::DateTimePeriod::DECADE ); EXPECT_EQ( 4, (int)resampler.resampledTimeSteps().size() ); EXPECT_EQ( toSecsSinceEpoch( "1990-01-01" ), resampler.resampledTimeSteps()[0] ); @@ -72,7 +72,7 @@ TEST( RiaTimeHistoryCurveResampler, Test_Resampling_Year ) RiaTimeHistoryCurveResampler resampler; resampler.setCurveData( dataValues, toSecsSinceEpochVector( timeStrings ) ); - resampler.resampleAndComputeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod::YEAR ); + resampler.resampleAndComputeWeightedMeanValues( RiaDefines::DateTimePeriod::YEAR ); EXPECT_EQ( 5, (int)resampler.resampledTimeSteps().size() ); EXPECT_EQ( toSecsSinceEpoch( "2015-01-01" ), resampler.resampledTimeSteps()[0] ); @@ -93,7 +93,7 @@ TEST( RiaTimeHistoryCurveResampler, Test_Resampling_HalfYear ) RiaTimeHistoryCurveResampler resampler; resampler.setCurveData( dataValues, toSecsSinceEpochVector( timeStrings ) ); - resampler.resampleAndComputeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod::HALFYEAR ); + resampler.resampleAndComputeWeightedMeanValues( RiaDefines::DateTimePeriod::HALFYEAR ); EXPECT_EQ( 5, (int)resampler.resampledTimeSteps().size() ); EXPECT_EQ( toSecsSinceEpoch( "2016-07-01" ), resampler.resampledTimeSteps()[0] ); @@ -114,7 +114,7 @@ TEST( RiaTimeHistoryCurveResampler, Test_Resampling_Quarter ) RiaTimeHistoryCurveResampler resampler; resampler.setCurveData( dataValues, toSecsSinceEpochVector( timeStrings ) ); - resampler.resampleAndComputeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod::QUARTER ); + resampler.resampleAndComputeWeightedMeanValues( RiaDefines::DateTimePeriod::QUARTER ); EXPECT_EQ( 7, (int)resampler.resampledTimeSteps().size() ); EXPECT_EQ( toSecsSinceEpoch( "2016-10-01" ), resampler.resampledTimeSteps()[0] ); @@ -137,7 +137,7 @@ TEST( RiaTimeHistoryCurveResampler, Test_Resampling_Month ) RiaTimeHistoryCurveResampler resampler; resampler.setCurveData( dataValues, toSecsSinceEpochVector( timeStrings ) ); - resampler.resampleAndComputeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod::MONTH ); + resampler.resampleAndComputeWeightedMeanValues( RiaDefines::DateTimePeriod::MONTH ); EXPECT_EQ( 6, (int)resampler.resampledTimeSteps().size() ); EXPECT_EQ( toSecsSinceEpoch( "2017-10-01" ), resampler.resampledTimeSteps()[0] ); @@ -159,7 +159,7 @@ TEST( RiaTimeHistoryCurveResampler, Test_Resampling_Week ) RiaTimeHistoryCurveResampler resampler; resampler.setCurveData( dataValues, toSecsSinceEpochVector( timeStrings ) ); - resampler.resampleAndComputeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod::WEEK ); + resampler.resampleAndComputeWeightedMeanValues( RiaDefines::DateTimePeriod::WEEK ); EXPECT_EQ( 10, (int)resampler.resampledTimeSteps().size() ); EXPECT_EQ( toSecsSinceEpoch( "2017-11-06" ), resampler.resampledTimeSteps()[0] ); @@ -185,7 +185,7 @@ TEST( RiaTimeHistoryCurveResampler, Test_Resampling_NoSampleCrossingPeriodBounda RiaTimeHistoryCurveResampler resampler; resampler.setCurveData( dataValues, toSecsSinceEpochVector( timeStrings ) ); - resampler.resampleAndComputeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod::YEAR ); + resampler.resampleAndComputeWeightedMeanValues( RiaDefines::DateTimePeriod::YEAR ); EXPECT_EQ( 1, (int)resampler.resampledTimeSteps().size() ); EXPECT_EQ( toSecsSinceEpoch( "2018-01-01" ), resampler.resampledTimeSteps()[0] ); @@ -202,7 +202,7 @@ TEST( RiaTimeHistoryCurveResampler, Test_WeightedMean_SingleSample ) RiaTimeHistoryCurveResampler resampler; resampler.setCurveData( dataValues, toSecsSinceEpochVector( timeStrings ) ); - resampler.resampleAndComputeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod::MONTH ); + resampler.resampleAndComputeWeightedMeanValues( RiaDefines::DateTimePeriod::MONTH ); EXPECT_EQ( 1, (int)resampler.resampledTimeSteps().size() ); EXPECT_EQ( toSecsSinceEpoch( "2018-03-01" ), resampler.resampledTimeSteps()[0] ); @@ -222,7 +222,7 @@ TEST( RiaTimeHistoryCurveResampler, Test_WeightedMean_Days ) RiaTimeHistoryCurveResampler resampler; resampler.setCurveData( dataValues, toSecsSinceEpochVector( timeStrings ) ); - resampler.resampleAndComputeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod::DAY ); + resampler.resampleAndComputeWeightedMeanValues( RiaDefines::DateTimePeriod::DAY ); EXPECT_EQ( 5, (int)resampler.resampledTimeSteps().size() ); EXPECT_EQ( toSecsSinceEpoch( "2018-02-03" ), resampler.resampledTimeSteps()[0] ); @@ -256,7 +256,7 @@ TEST( RiaTimeHistoryCurveResampler, Test_WeightedMean_Decade ) RiaTimeHistoryCurveResampler resampler; resampler.setCurveData( dataValues, toSecsSinceEpochVector( timeStrings ) ); - resampler.resampleAndComputeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod::DECADE ); + resampler.resampleAndComputeWeightedMeanValues( RiaDefines::DateTimePeriod::DECADE ); EXPECT_EQ( 3, (int)resampler.resampledTimeSteps().size() ); EXPECT_EQ( tp0, resampler.resampledTimeSteps()[0] ); @@ -287,7 +287,7 @@ TEST( RiaTimeHistoryCurveResampler, Test_WeightedMean_SamplesStartBeforePeriod ) RiaTimeHistoryCurveResampler resampler; resampler.setCurveData( dataValues, toSecsSinceEpochVector( timeStrings ) ); - resampler.resampleAndComputeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod::MONTH ); + resampler.resampleAndComputeWeightedMeanValues( RiaDefines::DateTimePeriod::MONTH ); EXPECT_EQ( 3, (int)resampler.resampledTimeSteps().size() ); EXPECT_EQ( tp0, resampler.resampledTimeSteps()[0] ); @@ -320,7 +320,7 @@ TEST( RiaTimeHistoryCurveResampler, Test_WeightedMean_SamplesStartBeforePeriod_T RiaTimeHistoryCurveResampler resampler; resampler.setCurveData( dataValues, toSecsSinceEpochVector( timeStrings ) ); - resampler.resampleAndComputeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod::MONTH ); + resampler.resampleAndComputeWeightedMeanValues( RiaDefines::DateTimePeriod::MONTH ); EXPECT_EQ( 3, (int)resampler.resampledTimeSteps().size() ); EXPECT_EQ( tp0, resampler.resampledTimeSteps()[0] ); @@ -349,7 +349,7 @@ TEST( RiaTimeHistoryCurveResampler, Test_WeightedMean_SamplesStartAndEndMatchPer RiaTimeHistoryCurveResampler resampler; resampler.setCurveData( dataValues, toSecsSinceEpochVector( timeStrings ) ); - resampler.resampleAndComputeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod::MONTH ); + resampler.resampleAndComputeWeightedMeanValues( RiaDefines::DateTimePeriod::MONTH ); EXPECT_EQ( 2, (int)resampler.resampledTimeSteps().size() ); EXPECT_EQ( toSecsSinceEpoch( "2018-02-01" ), resampler.resampledTimeSteps().front() ); @@ -379,7 +379,7 @@ TEST( RiaTimeHistoryCurveResampler, Test_WeightedMean_SamplesStartMatchPeriodSta RiaTimeHistoryCurveResampler resampler; resampler.setCurveData( dataValues, toSecsSinceEpochVector( timeStrings ) ); - resampler.resampleAndComputeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod::MONTH ); + resampler.resampleAndComputeWeightedMeanValues( RiaDefines::DateTimePeriod::MONTH ); EXPECT_EQ( 3, (int)resampler.resampledTimeSteps().size() ); EXPECT_EQ( tp0, resampler.resampledTimeSteps()[0] ); @@ -409,7 +409,7 @@ TEST( RiaTimeHistoryCurveResampler, Test_WeightedMean_MultipleSamplesInLastPerio RiaTimeHistoryCurveResampler resampler; resampler.setCurveData( dataValues, toSecsSinceEpochVector( timeStrings ) ); - resampler.resampleAndComputeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod::MONTH ); + resampler.resampleAndComputeWeightedMeanValues( RiaDefines::DateTimePeriod::MONTH ); EXPECT_EQ( 2, (int)resampler.resampledTimeSteps().size() ); EXPECT_EQ( tp0, resampler.resampledTimeSteps()[0] ); @@ -433,7 +433,7 @@ TEST( RiaTimeHistoryCurveResampler, Test_PeriodEndValues_SingleSample ) RiaTimeHistoryCurveResampler resampler; resampler.setCurveData( dataValues, toSecsSinceEpochVector( timeStrings ) ); - resampler.resampleAndComputePeriodEndValues( RiaQDateTimeTools::DateTimePeriod::MONTH ); + resampler.resampleAndComputePeriodEndValues( RiaDefines::DateTimePeriod::MONTH ); EXPECT_EQ( 1, (int)resampler.resampledTimeSteps().size() ); EXPECT_EQ( toSecsSinceEpoch( "2018-03-01" ), resampler.resampledTimeSteps()[0] ); @@ -459,7 +459,7 @@ TEST( RiaTimeHistoryCurveResampler, Test_PeriodEndValues_SamplesStartBeforePerio RiaTimeHistoryCurveResampler resampler; resampler.setCurveData( dataValues, toSecsSinceEpochVector( timeStrings ) ); - resampler.resampleAndComputePeriodEndValues( RiaQDateTimeTools::DateTimePeriod::MONTH ); + resampler.resampleAndComputePeriodEndValues( RiaDefines::DateTimePeriod::MONTH ); EXPECT_EQ( 3, (int)resampler.resampledTimeSteps().size() ); EXPECT_EQ( tp0, resampler.resampledTimeSteps()[0] ); @@ -486,7 +486,7 @@ TEST( RiaTimeHistoryCurveResampler, Test_PeriodEndValues_SamplesStartMatchPeriod RiaTimeHistoryCurveResampler resampler; resampler.setCurveData( dataValues, toSecsSinceEpochVector( timeStrings ) ); - resampler.resampleAndComputePeriodEndValues( RiaQDateTimeTools::DateTimePeriod::MONTH ); + resampler.resampleAndComputePeriodEndValues( RiaDefines::DateTimePeriod::MONTH ); EXPECT_EQ( 3, (int)resampler.resampledTimeSteps().size() ); EXPECT_EQ( toSecsSinceEpoch( "2018-02-01" ), resampler.resampledTimeSteps()[0] ); @@ -509,7 +509,7 @@ TEST( RiaTimeHistoryCurveResampler, Test_PeriodEndValues_SamplesStartAndEndMatch RiaTimeHistoryCurveResampler resampler; resampler.setCurveData( dataValues, toSecsSinceEpochVector( timeStrings ) ); - resampler.resampleAndComputePeriodEndValues( RiaQDateTimeTools::DateTimePeriod::MONTH ); + resampler.resampleAndComputePeriodEndValues( RiaDefines::DateTimePeriod::MONTH ); EXPECT_EQ( 2, (int)resampler.resampledTimeSteps().size() ); EXPECT_EQ( toSecsSinceEpoch( "2018-02-01" ), resampler.resampledTimeSteps().front() ); diff --git a/ApplicationLibCode/UnitTests/RifEclipseSummaryAddress-Test.cpp b/ApplicationLibCode/UnitTests/RifEclipseSummaryAddress-Test.cpp index 40c39dec3e..9d6f67a931 100644 --- a/ApplicationLibCode/UnitTests/RifEclipseSummaryAddress-Test.cpp +++ b/ApplicationLibCode/UnitTests/RifEclipseSummaryAddress-Test.cpp @@ -16,7 +16,7 @@ TEST( RifEclipseSummaryAddressTest, TestEclipseAddressParsing_Field ) EXPECT_TRUE( addr.isValid() ); EXPECT_EQ( RifEclipseSummaryAddress::SUMMARY_FIELD, addr.category() ); - EXPECT_EQ( "FOPT", addr.quantityName() ); + EXPECT_EQ( "FOPT", addr.vectorName() ); EXPECT_FALSE( addr.isErrorResult() ); } @@ -28,7 +28,7 @@ TEST( RifEclipseSummaryAddressTest, TestEclipseAddressParsing_Aquifer ) EXPECT_TRUE( addr.isValid() ); EXPECT_EQ( RifEclipseSummaryAddress::SUMMARY_AQUIFER, addr.category() ); - EXPECT_EQ( "AAQR", addr.quantityName() ); + EXPECT_EQ( "AAQR", addr.vectorName() ); EXPECT_EQ( 456, addr.aquiferNumber() ); EXPECT_FALSE( addr.isErrorResult() ); } @@ -41,7 +41,7 @@ TEST( RifEclipseSummaryAddressTest, TestEclipseAddressParsing_Network ) EXPECT_TRUE( addr.isValid() ); EXPECT_EQ( RifEclipseSummaryAddress::SUMMARY_NETWORK, addr.category() ); - EXPECT_EQ( "NETW", addr.quantityName() ); + EXPECT_EQ( "NETW", addr.vectorName() ); EXPECT_FALSE( addr.isErrorResult() ); } @@ -53,7 +53,7 @@ TEST( RifEclipseSummaryAddressTest, DISABLED_TestEclipseAddressParsing_Misc ) EXPECT_TRUE( addr.isValid() ); EXPECT_EQ( RifEclipseSummaryAddress::SUMMARY_MISC, addr.category() ); - EXPECT_EQ( "CPU", addr.quantityName() ); + EXPECT_EQ( "CPU", addr.vectorName() ); EXPECT_FALSE( addr.isErrorResult() ); } @@ -65,7 +65,7 @@ TEST( RifEclipseSummaryAddressTest, TestEclipseAddressParsing_Region ) EXPECT_TRUE( addr.isValid() ); EXPECT_EQ( RifEclipseSummaryAddress::SUMMARY_REGION, addr.category() ); - EXPECT_EQ( "RPR", addr.quantityName() ); + EXPECT_EQ( "RPR", addr.vectorName() ); EXPECT_EQ( 7081, addr.regionNumber() ); EXPECT_FALSE( addr.isErrorResult() ); } @@ -78,7 +78,7 @@ TEST( RifEclipseSummaryAddressTest, TestEclipseAddressParsing_RegionToRegion ) EXPECT_TRUE( addr.isValid() ); EXPECT_EQ( RifEclipseSummaryAddress::SUMMARY_REGION_2_REGION, addr.category() ); - EXPECT_EQ( "ROFR", addr.quantityName() ); + EXPECT_EQ( "ROFR", addr.vectorName() ); EXPECT_EQ( 7081, addr.regionNumber() ); EXPECT_EQ( 8001, addr.regionNumber2() ); EXPECT_FALSE( addr.isErrorResult() ); @@ -91,9 +91,9 @@ TEST( RifEclipseSummaryAddressTest, TestEclipseAddressParsing_WellGroup ) RifEclipseSummaryAddress addr = RifEclipseSummaryAddress::fromEclipseTextAddressParseErrorTokens( addrString ); EXPECT_TRUE( addr.isValid() ); - EXPECT_EQ( RifEclipseSummaryAddress::SUMMARY_WELL_GROUP, addr.category() ); - EXPECT_EQ( "GOPR", addr.quantityName() ); - EXPECT_EQ( "WELLS1", addr.wellGroupName() ); + EXPECT_EQ( RifEclipseSummaryAddress::SUMMARY_GROUP, addr.category() ); + EXPECT_EQ( "GOPR", addr.vectorName() ); + EXPECT_EQ( "WELLS1", addr.groupName() ); EXPECT_FALSE( addr.isErrorResult() ); } @@ -105,7 +105,7 @@ TEST( RifEclipseSummaryAddressTest, TestEclipseAddressParsing_Well ) EXPECT_TRUE( addr.isValid() ); EXPECT_EQ( RifEclipseSummaryAddress::SUMMARY_WELL, addr.category() ); - EXPECT_EQ( "WOPR", addr.quantityName() ); + EXPECT_EQ( "WOPR", addr.vectorName() ); EXPECT_EQ( "B-2H", addr.wellName() ); EXPECT_FALSE( addr.isErrorResult() ); } @@ -118,7 +118,7 @@ TEST( RifEclipseSummaryAddressTest, TestEclipseAddressParsing_WellCompletion ) EXPECT_TRUE( addr.isValid() ); EXPECT_EQ( RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION, addr.category() ); - EXPECT_EQ( "COFRL", addr.quantityName() ); + EXPECT_EQ( "COFRL", addr.vectorName() ); EXPECT_EQ( "B-1H", addr.wellName() ); EXPECT_EQ( 15, addr.cellI() ); EXPECT_EQ( 13, addr.cellJ() ); @@ -134,7 +134,7 @@ TEST( RifEclipseSummaryAddressTest, TestEclipseAddressParsing_WellLgr ) EXPECT_TRUE( addr.isValid() ); EXPECT_EQ( RifEclipseSummaryAddress::SUMMARY_WELL_LGR, addr.category() ); - EXPECT_EQ( "LWABC", addr.quantityName() ); + EXPECT_EQ( "LWABC", addr.vectorName() ); EXPECT_EQ( "LGRNA", addr.lgrName() ); EXPECT_EQ( "B-10H", addr.wellName() ); EXPECT_FALSE( addr.isErrorResult() ); @@ -148,7 +148,7 @@ TEST( RifEclipseSummaryAddressTest, TestEclipseAddressParsing_WellCompletionLgr EXPECT_TRUE( addr.isValid() ); EXPECT_EQ( RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION_LGR, addr.category() ); - EXPECT_EQ( "LCGAS", addr.quantityName() ); + EXPECT_EQ( "LCGAS", addr.vectorName() ); EXPECT_EQ( "LGR1", addr.lgrName() ); EXPECT_EQ( "B-1H", addr.wellName() ); EXPECT_EQ( 11, addr.cellI() ); @@ -165,7 +165,7 @@ TEST( RifEclipseSummaryAddressTest, TestEclipseAddressParsing_WellSegment ) EXPECT_TRUE( addr.isValid() ); EXPECT_EQ( RifEclipseSummaryAddress::SUMMARY_WELL_SEGMENT, addr.category() ); - EXPECT_EQ( "SOFR", addr.quantityName() ); + EXPECT_EQ( "SOFR", addr.vectorName() ); EXPECT_EQ( "B-5H", addr.wellName() ); EXPECT_EQ( 32, addr.wellSegmentNumber() ); EXPECT_FALSE( addr.isErrorResult() ); @@ -179,7 +179,7 @@ TEST( RifEclipseSummaryAddressTest, TestEclipseAddressParsing_Block ) EXPECT_TRUE( addr.isValid() ); EXPECT_EQ( RifEclipseSummaryAddress::SUMMARY_BLOCK, addr.category() ); - EXPECT_EQ( "BPR", addr.quantityName() ); + EXPECT_EQ( "BPR", addr.vectorName() ); EXPECT_EQ( 123, addr.cellI() ); EXPECT_EQ( 122, addr.cellJ() ); EXPECT_EQ( 121, addr.cellK() ); @@ -194,7 +194,7 @@ TEST( RifEclipseSummaryAddressTest, TestEclipseAddressParsing_BlockLgr ) EXPECT_TRUE( addr.isValid() ); EXPECT_EQ( RifEclipseSummaryAddress::SUMMARY_BLOCK_LGR, addr.category() ); - EXPECT_EQ( "LBABC", addr.quantityName() ); + EXPECT_EQ( "LBABC", addr.vectorName() ); EXPECT_EQ( "LGRN", addr.lgrName() ); EXPECT_EQ( 45, addr.cellI() ); EXPECT_EQ( 47, addr.cellJ() ); @@ -210,7 +210,7 @@ TEST( RifEclipseSummaryAddressTest, TestEclipseAddressParsing_Imported ) EXPECT_TRUE( addr.isValid() ); EXPECT_EQ( RifEclipseSummaryAddress::SUMMARY_IMPORTED, addr.category() ); - EXPECT_EQ( "FAULT (Imp)", addr.quantityName() ); + EXPECT_EQ( "FAULT (Imp)", addr.vectorName() ); EXPECT_FALSE( addr.isErrorResult() ); } @@ -222,7 +222,7 @@ TEST( RifEclipseSummaryAddressTest, TestEclipseAddressParsing_ErrorResult1 ) EXPECT_TRUE( addr.isValid() ); EXPECT_EQ( RifEclipseSummaryAddress::SUMMARY_AQUIFER, addr.category() ); - EXPECT_EQ( "AAQR", addr.quantityName() ); + EXPECT_EQ( "AAQR", addr.vectorName() ); EXPECT_EQ( 456, addr.aquiferNumber() ); EXPECT_TRUE( addr.isErrorResult() ); } @@ -235,7 +235,7 @@ TEST( RifEclipseSummaryAddressTest, TestEclipseAddressParsing_ErrorResult2 ) EXPECT_TRUE( addr.isValid() ); EXPECT_EQ( RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION_LGR, addr.category() ); - EXPECT_EQ( "LCGAS", addr.quantityName() ); + EXPECT_EQ( "LCGAS", addr.vectorName() ); EXPECT_EQ( "LGR1", addr.lgrName() ); EXPECT_EQ( "B-1H", addr.wellName() ); EXPECT_EQ( 11, addr.cellI() ); @@ -252,7 +252,7 @@ TEST( RifEclipseSummaryAddressTest, TestEclipseAddressParsing_ErrorResult3 ) EXPECT_TRUE( addr.isValid() ); EXPECT_EQ( RifEclipseSummaryAddress::SUMMARY_IMPORTED, addr.category() ); - EXPECT_EQ( "FAULT (Imp)", addr.quantityName() ); + EXPECT_EQ( "FAULT (Imp)", addr.vectorName() ); EXPECT_TRUE( addr.isErrorResult() ); } @@ -269,7 +269,7 @@ TEST( RifEclipseSummaryAddressTest, TestEclipseAddressIjkParsing ) EXPECT_TRUE( addr.isValid() ); EXPECT_EQ( RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION, addr.category() ); - EXPECT_EQ( "WOPR", addr.quantityName() ); + EXPECT_EQ( "WOPR", addr.vectorName() ); EXPECT_EQ( "1-BH", addr.wellName() ); EXPECT_EQ( 6, addr.cellI() ); EXPECT_EQ( 7, addr.cellJ() ); @@ -289,7 +289,7 @@ TEST( RifEclipseSummaryAddressTest, TestEclipseAddressRegToRegParsing ) EXPECT_TRUE( addr.isValid() ); EXPECT_EQ( RifEclipseSummaryAddress::SUMMARY_REGION_2_REGION, addr.category() ); - EXPECT_EQ( "ROFR", addr.quantityName() ); + EXPECT_EQ( "ROFR", addr.vectorName() ); EXPECT_EQ( 123, addr.regionNumber() ); EXPECT_EQ( 456, addr.regionNumber2() ); EXPECT_TRUE( !addr.isErrorResult() ); @@ -298,28 +298,28 @@ TEST( RifEclipseSummaryAddressTest, TestEclipseAddressRegToRegParsing ) TEST( RifEclipseSummaryAddressTest, TestQuantityNameManipulations ) { { - auto s = RifEclipseSummaryAddress::baseQuantityName( "FOPT" ); + auto s = RifEclipseSummaryAddress::baseVectorName( "FOPT" ); EXPECT_EQ( "FOPT", s ); } { - auto s = RifEclipseSummaryAddress::baseQuantityName( "FOPT_1" ); + auto s = RifEclipseSummaryAddress::baseVectorName( "FOPT_1" ); EXPECT_EQ( "FOPT", s ); } { - auto s = RifEclipseSummaryAddress::baseQuantityName( "FOPR" ); + auto s = RifEclipseSummaryAddress::baseVectorName( "FOPR" ); EXPECT_EQ( "FOPR", s ); } { - auto s = RifEclipseSummaryAddress::baseQuantityName( "FOPR_1" ); + auto s = RifEclipseSummaryAddress::baseVectorName( "FOPR_1" ); EXPECT_EQ( "FOPR", s ); } { // https://github.com/OPM/ResInsight/issues/6481 - auto s = RifEclipseSummaryAddress::baseQuantityName( "FCMIT_1" ); + auto s = RifEclipseSummaryAddress::baseVectorName( "FCMIT_1" ); EXPECT_EQ( "FCMIT", s ); } } diff --git a/ApplicationLibCode/UnitTests/RifEclipseTextFileReader-Test.cpp b/ApplicationLibCode/UnitTests/RifEclipseTextFileReader-Test.cpp index dde1ee92c8..f7a56132e6 100644 --- a/ApplicationLibCode/UnitTests/RifEclipseTextFileReader-Test.cpp +++ b/ApplicationLibCode/UnitTests/RifEclipseTextFileReader-Test.cpp @@ -204,3 +204,33 @@ TEST( RifEclipseTextFileReader, ValueMultiplier ) EXPECT_FLOAT_EQ( 0.5f, firstKeyword.values[2] ); EXPECT_FLOAT_EQ( 12345.12f, firstKeyword.values[3] ); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST( RifEclipseTextFileReader, KeywordsWithoutValue ) +{ + std::string fileContent = "NOECHO\n" + "SWAT\n" + "1.0 2.0 3.0\n" + "/\n" + "SOIL\n" + "6.0 7.0 8.0 9.0\n" + "/\n"; + + auto keywordDataItems = RifEclipseTextFileReader::parseStringData( fileContent ); + + EXPECT_EQ( 3u, keywordDataItems.size() ); + + auto noEchoKeyword = keywordDataItems[0]; + EXPECT_EQ( 0u, noEchoKeyword.values.size() ); + + auto swatKeyword = keywordDataItems[1]; + EXPECT_EQ( 3u, swatKeyword.values.size() ); + + auto soilKeyword = keywordDataItems[2]; + EXPECT_EQ( 4u, soilKeyword.values.size() ); + + EXPECT_FLOAT_EQ( 1.0f, swatKeyword.values[0] ); + EXPECT_FLOAT_EQ( 6.0f, soilKeyword.values[0] ); +} diff --git a/ApplicationLibCode/UnitTests/RifReaderEclipseSummary-Test.cpp b/ApplicationLibCode/UnitTests/RifReaderEclipseSummary-Test.cpp index e13a7730de..8a7932d707 100644 --- a/ApplicationLibCode/UnitTests/RifReaderEclipseSummary-Test.cpp +++ b/ApplicationLibCode/UnitTests/RifReaderEclipseSummary-Test.cpp @@ -133,7 +133,7 @@ resulting for (size_t i = 0; i < addresses.size(); i++) { RifEclipseSummaryAddress adr(addresses[i].category(), addresses[i].simulationItemName(), -addresses[i].quantityName()); myAddresses.push_back(adr); +addresses[i].vectorName()); myAddresses.push_back(adr); } for (size_t i = 0; i < addresses.size(); i++) diff --git a/ApplicationLibCode/UnitTests/RifTextDataTableFormatter-Test.cpp b/ApplicationLibCode/UnitTests/RifTextDataTableFormatter-Test.cpp index f645c83d83..e449e636fb 100644 --- a/ApplicationLibCode/UnitTests/RifTextDataTableFormatter-Test.cpp +++ b/ApplicationLibCode/UnitTests/RifTextDataTableFormatter-Test.cpp @@ -1,5 +1,7 @@ #include "gtest/gtest.h" +#include "RiaTextStringTools.h" + #include "RifTextDataTableFormatter.h" #include @@ -106,7 +108,7 @@ TEST( RifTextDataTableFormatter, LongLine ) formatter.rowCompleted(); formatter.tableCompleted(); - QStringList tableLines = tableText.split( QRegExp( "[\r\n]" ), QString::SkipEmptyParts ); + QStringList tableLines = RiaTextStringTools::splitSkipEmptyParts( tableText, QRegExp( "[\r\n]" ) ); for ( QString line : tableLines ) { std::cout << QString( "Line: \"%1\"" ).arg( line ).toStdString() << std::endl; @@ -153,7 +155,7 @@ TEST( RifTextDataTableFormatter, LongLine132 ) formatter.rowCompleted(); formatter.tableCompleted(); - QStringList tableLines = tableText.split( QRegExp( "[\r\n]" ), QString::SkipEmptyParts ); + QStringList tableLines = RiaTextStringTools::splitSkipEmptyParts( tableText, QRegExp( "[\r\n]" ) ); for ( QString line : tableLines ) { std::cout << QString( "Line: \"%1\"" ).arg( line ).toStdString() << std::endl; @@ -200,7 +202,7 @@ TEST( RifTextDataTableFormatter, LongLine133 ) formatter.rowCompleted(); formatter.tableCompleted(); - QStringList tableLines = tableText.split( QRegExp( "[\r\n]" ), QString::SkipEmptyParts ); + QStringList tableLines = RiaTextStringTools::splitSkipEmptyParts( tableText, QRegExp( "[\r\n]" ) ); for ( QString line : tableLines ) { std::cout << QString( "Line: \"%1\"" ).arg( line ).toStdString() << std::endl; diff --git a/ApplicationLibCode/UnitTests/RifcCommandCore-Test.cpp b/ApplicationLibCode/UnitTests/RifcCommandCore-Test.cpp index ced25e6cb3..66a31cd1af 100644 --- a/ApplicationLibCode/UnitTests/RifcCommandCore-Test.cpp +++ b/ApplicationLibCode/UnitTests/RifcCommandCore-Test.cpp @@ -15,10 +15,10 @@ class TestCommand1 : public RicfCommandObject public: TestCommand1() { - CAF_PDM_InitScriptableField( &m_textArgument, "TextArgument", QString(), "TextArgument", "", "", "" ); - CAF_PDM_InitScriptableField( &m_doubleArgument, "DoubleArgument", 0.0, "DoubleArgument", "", "", "" ); - CAF_PDM_InitScriptableField( &m_intArgument, "IntArgument", 0, "IntArgument", "", "", "" ); - CAF_PDM_InitScriptableField( &m_boolArgument, "BoolArgument", false, "BoolArgument", "", "", "" ); + CAF_PDM_InitScriptableField( &m_textArgument, "TextArgument", QString(), "TextArgument" ); + CAF_PDM_InitScriptableField( &m_doubleArgument, "DoubleArgument", 0.0, "DoubleArgument" ); + CAF_PDM_InitScriptableField( &m_intArgument, "IntArgument", 0, "IntArgument" ); + CAF_PDM_InitScriptableField( &m_boolArgument, "BoolArgument", false, "BoolArgument" ); } caf::PdmScriptResponse execute() override @@ -44,10 +44,10 @@ class TC2 : public RicfCommandObject public: TC2() { - CAF_PDM_InitScriptableField( &m_textArgument, "ta", QString(), "TextArgument", "", "", "" ); - CAF_PDM_InitScriptableField( &m_doubleArgument, "da", 0.0, "DoubleArgument", "", "", "" ); - CAF_PDM_InitScriptableField( &m_intArgument, "ia", 0, "IntArgument", "", "", "" ); - CAF_PDM_InitScriptableField( &m_boolArgument, "ba", false, "BoolArgument", "", "", "" ); + CAF_PDM_InitScriptableField( &m_textArgument, "ta", QString(), "TextArgument" ); + CAF_PDM_InitScriptableField( &m_doubleArgument, "da", 0.0, "DoubleArgument" ); + CAF_PDM_InitScriptableField( &m_intArgument, "ia", 0, "IntArgument" ); + CAF_PDM_InitScriptableField( &m_boolArgument, "ba", false, "BoolArgument" ); } caf::PdmScriptResponse execute() override diff --git a/ApplicationLibCode/UnitTests/RigHexIntersectionTools-Test.cpp b/ApplicationLibCode/UnitTests/RigHexIntersectionTools-Test.cpp index 067ed98c4c..da42aecd14 100644 --- a/ApplicationLibCode/UnitTests/RigHexIntersectionTools-Test.cpp +++ b/ApplicationLibCode/UnitTests/RigHexIntersectionTools-Test.cpp @@ -18,8 +18,10 @@ #include "gtest/gtest.h" -#include "QDateTime" -#include "QDebug" +#include +#include +#include + #include "RigHexIntersectionTools.h" //-------------------------------------------------------------------------------------------------- @@ -74,12 +76,12 @@ TEST( RigHexIntersectionTools, DISABLED_planeHexCellIntersectionPerformanceTest fracturePlaneNotIntersecting.setFromPointAndNormal( cvf::Vec3d( 1.5, 1.5, 1.5 ), cvf::Vec3d( 1, 0, 0 ) ); fracturePlaneIntersecting.setFromPointAndNormal( cvf::Vec3d( 0.5, 0.5, 0.5 ), cvf::Vec3d( 1, 0, 0 ) ); - QTime timeTotal; + QElapsedTimer timeTotal; timeTotal.start(); for ( int run = 0; run < 5; run++ ) { - QTime timeLocal; + QElapsedTimer timeLocal; timeLocal.start(); for ( int i = 0; i < 2000000; i++ ) diff --git a/ApplicationLibCode/UnitTests/RigSlice2D-Test.cpp b/ApplicationLibCode/UnitTests/RigSlice2D-Test.cpp index ddc639f4d7..1019551755 100644 --- a/ApplicationLibCode/UnitTests/RigSlice2D-Test.cpp +++ b/ApplicationLibCode/UnitTests/RigSlice2D-Test.cpp @@ -16,9 +16,9 @@ TEST( RigSlice2DTest, GetAndSet ) for ( size_t y = 0; y < ny; y++ ) for ( size_t x = 0; x < nx; x++ ) - slice.setValue( x, y, x * y ); + slice.setValue( x, y, static_cast( x * y ) ); for ( size_t y = 0; y < ny; y++ ) for ( size_t x = 0; x < nx; x++ ) - EXPECT_EQ( x * y, slice.getValue( x, y ) ); + EXPECT_EQ( static_cast( x * y ), slice.getValue( x, y ) ); } diff --git a/ApplicationLibCode/UnitTests/RigStatisticsMath-Test.cpp b/ApplicationLibCode/UnitTests/RigStatisticsMath-Test.cpp index 17e42e4c6a..de0a3820c8 100644 --- a/ApplicationLibCode/UnitTests/RigStatisticsMath-Test.cpp +++ b/ApplicationLibCode/UnitTests/RigStatisticsMath-Test.cpp @@ -20,6 +20,7 @@ #include "gtest/gtest.h" +#include "QElapsedTimer" #include "RigStatisticsMath.h" //-------------------------------------------------------------------------------------------------- @@ -295,3 +296,37 @@ TEST( RigStatisticsMath, calculateStatisticsCurves ) EXPECT_DOUBLE_EQ( 1.0, mean ); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST( RigStatisticsMath, DISABLED_performanceTesting ) +{ + RigStatisticsMath::PercentileStyle percentileStyle = RigStatisticsMath::PercentileStyle::REGULAR; + { + size_t timerCount = 10; + for ( size_t t = 0; t < timerCount; t++ ) + { + QElapsedTimer timer; + timer.start(); + + size_t iterationCount = 10000; + for ( size_t i = 0; i < iterationCount; i++ ) + { + size_t numberOfValues = 200; + std::vector values( numberOfValues ); + std::iota( values.begin(), values.end(), numberOfValues ); + + double mean = HUGE_VAL; + double p10 = HUGE_VAL; + double p50 = HUGE_VAL; + double p90 = HUGE_VAL; + + RigStatisticsMath::calculateStatisticsCurves( values, &p10, &p50, &p90, &mean, percentileStyle ); + } + + auto testDuration = timer.elapsed(); + std::cout << testDuration << "\n"; + } + } +} diff --git a/ApplicationLibCode/UnitTests/RimRelocatePath-Test.cpp b/ApplicationLibCode/UnitTests/RimRelocatePath-Test.cpp index 960cf64a3e..f92644935f 100644 --- a/ApplicationLibCode/UnitTests/RimRelocatePath-Test.cpp +++ b/ApplicationLibCode/UnitTests/RimRelocatePath-Test.cpp @@ -39,7 +39,7 @@ void fieldsByType( caf::PdmObjectHandle* object, std::vector& typedFields ) } } - field->childObjects( &children ); + field->children( &children ); } for ( const auto& child : children ) diff --git a/ApplicationLibCode/UnitTests/RimWellLogExtractionCurveImpl-Test.cpp b/ApplicationLibCode/UnitTests/RimWellLogExtractionCurveImpl-Test.cpp index 274557a9d5..cd7400679f 100644 --- a/ApplicationLibCode/UnitTests/RimWellLogExtractionCurveImpl-Test.cpp +++ b/ApplicationLibCode/UnitTests/RimWellLogExtractionCurveImpl-Test.cpp @@ -18,7 +18,8 @@ TEST( RimWellLogExtractionCurveImplTest, StripOffInvalidValAtEndsOfVector ) values.push_back( 3.0 ); values.push_back( HUGE_VAL ); - auto valuesIntervals = RiaCurveDataTools::calculateIntervalsOfValidValues( values, false ); + bool includePositiveValuesOnly = false; + auto valuesIntervals = RiaCurveDataTools::calculateIntervalsOfValidValues( values, includePositiveValuesOnly ); EXPECT_EQ( 1, static_cast( valuesIntervals.size() ) ); EXPECT_EQ( 2, static_cast( valuesIntervals[0].first ) ); @@ -40,7 +41,8 @@ TEST( RimWellLogExtractionCurveImplTest, StripOffHugeValAtEndsAndInteriorOfVecto values.push_back( 3.0 ); values.push_back( HUGE_VAL ); - auto valuesIntervals = RiaCurveDataTools::calculateIntervalsOfValidValues( values, false ); + bool includePositiveValuesOnly = false; + auto valuesIntervals = RiaCurveDataTools::calculateIntervalsOfValidValues( values, includePositiveValuesOnly ); EXPECT_EQ( 2, static_cast( valuesIntervals.size() ) ); EXPECT_EQ( 2, static_cast( valuesIntervals[0].first ) ); @@ -48,3 +50,31 @@ TEST( RimWellLogExtractionCurveImplTest, StripOffHugeValAtEndsAndInteriorOfVecto EXPECT_EQ( 5, static_cast( valuesIntervals[1].first ) ); EXPECT_EQ( 6, static_cast( valuesIntervals[1].second ) ); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST( RimWellLogExtractionCurveImplTest, PositiveValuesOnly ) +{ + std::vector values; + values.push_back( HUGE_VAL ); + values.push_back( HUGE_VAL ); + values.push_back( -1.0 ); + values.push_back( 0.0 ); + values.push_back( 0.1 ); + values.push_back( 0.2 ); + values.push_back( -1.0 ); + values.push_back( HUGE_VAL ); + values.push_back( 2.0 ); + values.push_back( 3.0 ); + values.push_back( HUGE_VAL ); + + bool includePositiveValuesOnly = true; + auto valuesIntervals = RiaCurveDataTools::calculateIntervalsOfValidValues( values, includePositiveValuesOnly ); + + EXPECT_EQ( 2, static_cast( valuesIntervals.size() ) ); + EXPECT_EQ( 4, static_cast( valuesIntervals[0].first ) ); + EXPECT_EQ( 5, static_cast( valuesIntervals[0].second ) ); + EXPECT_EQ( 8, static_cast( valuesIntervals[1].first ) ); + EXPECT_EQ( 9, static_cast( valuesIntervals[1].second ) ); +} diff --git a/ApplicationLibCode/UnitTests/RiuSummaryVectorDescriptionMap-Test.cpp b/ApplicationLibCode/UnitTests/RiuSummaryVectorDescriptionMap-Test.cpp index ace8b00d5a..b4cf28c5cb 100644 --- a/ApplicationLibCode/UnitTests/RiuSummaryVectorDescriptionMap-Test.cpp +++ b/ApplicationLibCode/UnitTests/RiuSummaryVectorDescriptionMap-Test.cpp @@ -10,40 +10,40 @@ TEST( RiuSummaryQuantityNameInfoProvider, TestInit ) { { std::string s( "SRSFC" ); - auto cat = RiuSummaryQuantityNameInfoProvider::instance()->categoryFromQuantityName( s ); + auto cat = RiuSummaryQuantityNameInfoProvider::instance()->identifyCategory( s ); EXPECT_TRUE( cat == RifEclipseSummaryAddress::SUMMARY_WELL_SEGMENT ); - auto longName = RiuSummaryQuantityNameInfoProvider::instance()->longNameFromQuantityName( s ); + auto longName = RiuSummaryQuantityNameInfoProvider::instance()->longNameFromVectorName( s ); EXPECT_TRUE( longName == "Reach brine concentration" ); } { std::string s( "SRSFC" ); - auto test = RiuSummaryQuantityNameInfoProvider::instance()->longNameFromQuantityName( s ); + auto test = RiuSummaryQuantityNameInfoProvider::instance()->longNameFromVectorName( s ); EXPECT_TRUE( test == "Reach brine concentration" ); } { std::string s( "does not exist" ); - auto cat = RiuSummaryQuantityNameInfoProvider::instance()->categoryFromQuantityName( s ); + auto cat = RiuSummaryQuantityNameInfoProvider::instance()->identifyCategory( s ); EXPECT_TRUE( cat == RifEclipseSummaryAddress::SUMMARY_INVALID ); - auto longName = RiuSummaryQuantityNameInfoProvider::instance()->longNameFromQuantityName( s ); + auto longName = RiuSummaryQuantityNameInfoProvider::instance()->longNameFromVectorName( s ); EXPECT_TRUE( longName == "" ); } { std::string s( "does not exist" ); - auto test = RiuSummaryQuantityNameInfoProvider::instance()->longNameFromQuantityName( s ); + auto test = RiuSummaryQuantityNameInfoProvider::instance()->longNameFromVectorName( s ); EXPECT_TRUE( test == "" ); } { std::string s( "does not exist" ); - auto test = RiuSummaryQuantityNameInfoProvider::instance()->longNameFromQuantityName( s, true ); + auto test = RiuSummaryQuantityNameInfoProvider::instance()->longNameFromVectorName( s, true ); EXPECT_TRUE( test == s ); } @@ -56,16 +56,16 @@ TEST( RiuSummaryQuantityNameInfoProvider, TestCustomNaming ) { { std::string s( "SRSFCABC" ); - auto cat = RiuSummaryQuantityNameInfoProvider::instance()->categoryFromQuantityName( s ); + auto cat = RiuSummaryQuantityNameInfoProvider::instance()->identifyCategory( s ); EXPECT_TRUE( cat == RifEclipseSummaryAddress::SUMMARY_WELL_SEGMENT ); - auto longName = RiuSummaryQuantityNameInfoProvider::instance()->longNameFromQuantityName( s ); + auto longName = RiuSummaryQuantityNameInfoProvider::instance()->longNameFromVectorName( s ); EXPECT_TRUE( longName == "Reach brine concentration" ); } { std::string s( "BHD__ABC" ); - auto test = RiuSummaryQuantityNameInfoProvider::instance()->longNameFromQuantityName( s ); + auto test = RiuSummaryQuantityNameInfoProvider::instance()->longNameFromVectorName( s ); EXPECT_TRUE( test == "Hydraulic head" ); } @@ -78,13 +78,13 @@ TEST( RiuSummaryQuantityNameInfoProvider, Test6x ) { { std::string s( "GLIT" ); - auto cat = RiuSummaryQuantityNameInfoProvider::instance()->categoryFromQuantityName( s ); - EXPECT_TRUE( cat == RifEclipseSummaryAddress::SUMMARY_WELL_GROUP ); + auto cat = RiuSummaryQuantityNameInfoProvider::instance()->identifyCategory( s ); + EXPECT_TRUE( cat == RifEclipseSummaryAddress::SUMMARY_GROUP ); } { std::string s( "WSBVPROP" ); - auto cat = RiuSummaryQuantityNameInfoProvider::instance()->categoryFromQuantityName( s ); + auto cat = RiuSummaryQuantityNameInfoProvider::instance()->identifyCategory( s ); EXPECT_TRUE( cat == RifEclipseSummaryAddress::SUMMARY_WELL ); } } @@ -108,7 +108,7 @@ TEST( DISABLED_RiuSummaryQuantityNameInfoProvider, PerformanceLookup ) { for ( const auto& s : values ) { - RiuSummaryQuantityNameInfoProvider::instance()->categoryFromQuantityName( s ); + RiuSummaryQuantityNameInfoProvider::instance()->identifyCategory( s ); } } diff --git a/ApplicationLibCode/UnitTests/opm-summary-Test.cpp b/ApplicationLibCode/UnitTests/opm-summary-Test.cpp index c65b554a67..8e38300d4d 100644 --- a/ApplicationLibCode/UnitTests/opm-summary-Test.cpp +++ b/ApplicationLibCode/UnitTests/opm-summary-Test.cpp @@ -1,11 +1,17 @@ #include "gtest/gtest.h" +#include "RiaRftDefines.h" #include "RiaTestDataDirectory.h" + #include "RifOpmCommonSummary.h" +#include "RifReaderOpmRft.h" +#include "opm/io/eclipse/ERft.hpp" #include "opm/io/eclipse/ESmry.hpp" #include "opm/io/eclipse/ExtESmry.hpp" +#include + static const QString H5_TEST_DATA_DIRECTORY = QString( "%1/h5-file/" ).arg( TEST_DATA_DIR ); //-------------------------------------------------------------------------------------------------- @@ -43,3 +49,246 @@ TEST( OpmSummaryTests, ReadOpmSummaryDataListContent ) EXPECT_TRUE( eclAdr.isValid() ); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST( OpmSummaryTests, DISABLED_OpmImportRftData ) +{ + std::vector esmryKeywords; + { + // QString filePath = "e:/gitroot/opm-tests/model1/opm-simulation-reference/flow/MSW_MODEL_1.RFT"; + // QString filePath = "e:/gitroot/opm-tests/norne/ECL.2014.2/NORNE_ATW2013.RFT"; + // QString filePath = "d:/Models/Statoil/MSW-RFTfile/NORNE_ATW2013_RFTPLT_MSW.RFT"; + QString filePath = "e:/models/from_equinor_sftp/MSW-RFTfile/NORNE_ATW2013_RFTPLT_MSW.RFT"; + + Opm::EclIO::ERft eRft( filePath.toStdString() ); + + auto wells = eRft.listOfWells(); + auto dates = eRft.listOfdates(); + auto reports = eRft.listOfRftReports(); + + std::cout << "\nWells:\n"; + for ( const auto& w : wells ) + { + std::cout << w << "\n"; + } + + std::cout << "\nDates:\n"; + for ( const auto& date : dates ) + { + auto [year, month, day] = date; + + std::cout << year << ", " << month << ", " << day << "\n"; + } + + std::cout << "\nReports:\n"; + for ( const auto& report : reports ) + { + auto [text, date, floatValue] = report; + + std::cout << text << ", " << floatValue << "\n"; + } + + std::cout << "\nRFT Arrays:\n"; + for ( int i = 0; i < eRft.numberOfReports(); i++ ) + { + std::cout << "\n"; + + auto rftVectors = eRft.listOfRftArrays( i ); + + for ( const auto& rftVec : rftVectors ) + { + auto [name, arrType, itemCount] = rftVec; + + std::cout << name << ", " << itemCount << "\n"; + } + } + } +} + +// std::vector getValues(Opm::EclIO::ERft& fileReader, std::) + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST( OpmSummaryTests, DISABLED_OpmComputeSegmentTopology ) +{ + std::vector esmryKeywords; + { + // QString filePath = "e:/gitroot/opm-tests/model1/opm-simulation-reference/flow/MSW_MODEL_1.RFT"; + // QString filePath = "e:/gitroot/opm-tests/norne/ECL.2014.2/NORNE_ATW2013.RFT"; + // QString filePath = "d:/Models/Statoil/MSW-RFTfile/NORNE_ATW2013_RFTPLT_MSW.RFT"; + // QString filePath = "e:/models/from_equinor_sftp/MSW-RFTfile/NORNE_ATW2013_RFTPLT_MSW.RFT"; + QString filePath = "e:/models/from_equinor_sftp/MSWRFT_toCS/MSWLOOPED_UN_RFT.RFT"; + + Opm::EclIO::ERft eRft( filePath.toStdString() ); + + auto wells = eRft.listOfWells(); + auto dates = eRft.listOfdates(); + + class RftSegmentData + { + public: + RftSegmentData( int segnxt, int brno, int brnst, int brnen, int segNo ) + : m_segNext( segnxt ) + , m_segbrno( brno ) + , m_brnst( brnst ) + , m_brnen( brnen ) + , m_segmentNo( segNo ) + { + } + + int segNext() const { return m_segNext; } + int segBrno() const { return m_segbrno; } + int segBrnst() const { return m_brnst; } + int segBrnen() const { return m_brnen; } + int segNo() const { return m_segmentNo; } + + private: + int m_segNext; + int m_segbrno; + int m_brnst; + int m_brnen; + int m_segmentNo; + }; + + using RftSegmentKey = std::pair; + std::map> rftWellDateSegments; + + for ( const auto& well : wells ) + { + for ( const auto& date : dates ) + { + std::vector segmentsForWellDate; + + std::vector segnxt; + std::vector segbrno; + std::vector brnstValues; + std::vector brnenValues; + std::vector segNo; + + { + std::string resultName = "SEGNXT"; + if ( eRft.hasArray( resultName, well, date ) ) + { + segnxt = eRft.getRft( resultName, well, date ); + } + } + { + std::string resultName = "SEGBRNO"; + if ( eRft.hasArray( resultName, well, date ) ) + { + segbrno = eRft.getRft( resultName, well, date ); + } + } + { + std::string resultName = "BRNST"; + if ( eRft.hasArray( resultName, well, date ) ) + { + brnstValues = eRft.getRft( resultName, well, date ); + } + } + { + std::string resultName = "BRNEN"; + if ( eRft.hasArray( resultName, well, date ) ) + { + brnenValues = eRft.getRft( resultName, well, date ); + } + } + + if ( segnxt.empty() ) continue; + if ( segnxt.size() != segbrno.size() ) continue; + if ( brnenValues.empty() || brnstValues.empty() ) continue; + + for ( size_t i = 0; i < segnxt.size(); i++ ) + { + int branchIndex = segbrno[i] - 1; + int nextBranchIndex = -1; + if ( i + 1 < segbrno.size() ) nextBranchIndex = segbrno[i + 1] - 1; + + bool isLastSegmentOnBranch = branchIndex != nextBranchIndex; + + int brnst = brnstValues[branchIndex]; + int brnen = brnenValues[branchIndex]; + + int segmentId = -1; + if ( !isLastSegmentOnBranch ) + { + if ( i + 1 < segnxt.size() ) segmentId = segnxt[i + 1]; + } + else + { + segmentId = brnen; + } + + segNo.push_back( segmentId ); + + segmentsForWellDate.emplace_back( RftSegmentData( segnxt[i], segbrno[i], brnst, brnen, segmentId ) ); + } + + auto wellDateKey = std::make_pair( well, date ); + + rftWellDateSegments[wellDateKey] = segmentsForWellDate; + } + } + + for ( const auto& a : rftWellDateSegments ) + { + auto [wellName, date] = a.first; + auto segmentData = a.second; + + std::cout << "\nWell: " << wellName << "Date : " << std::get<0>( date ) << " " << std::get<1>( date ) << " " + << std::get<2>( date ) << " \n"; + + for ( const auto& r : segmentData ) + { + std::cout << "SEGNXT " << std::setw( 2 ) << r.segNext() << ", "; + std::cout << "SEGBRNO " << std::setw( 2 ) << r.segBrno() << ", "; + std::cout << "BNRST " << std::setw( 2 ) << r.segBrnst() << ", "; + std::cout << "BRNEN " << std::setw( 2 ) << r.segBrnen() << ", "; + std::cout << "SEGNO " << std::setw( 2 ) << r.segNo() << "\n"; + } + } + } +} + +TEST( OpmSummaryTests, OpmComputeSegmentTopology ) +{ + std::vector esmryKeywords; + { + // QString filePath = "e:/gitroot/opm-tests/model1/opm-simulation-reference/flow/MSW_MODEL_1.RFT"; + // QString filePath = "e:/gitroot/opm-tests/norne/ECL.2014.2/NORNE_ATW2013.RFT"; + // QString filePath = "d:/Models/Statoil/MSW-RFTfile/NORNE_ATW2013_RFTPLT_MSW.RFT"; + // QString filePath = "e:/models/from_equinor_sftp/MSW-RFTfile/NORNE_ATW2013_RFTPLT_MSW.RFT"; + QString filePath = "e:/models/from_equinor_sftp/MSWRFT_toCS/MSWLOOPED_UN_RFT.RFT"; + + RifReaderOpmRft reader( filePath ); + + auto adresses = reader.eclipseRftAddresses(); + + std::vector segStartDepth; + std::vector segEndDepth; + std::vector segNumber; + + std::set segmentAdresses; + for ( const auto& adr : adresses ) + { + if ( adr.wellLogChannel() == RifEclipseRftAddress::RftWellLogChannelType::SEGMENT_VALUES ) + { + segmentAdresses.insert( adr ); + } + } + + for ( const auto& adr : segmentAdresses ) + { + qDebug() << adr.timeStep().toString( "YYYY MM dd" ) << " " << adr.segmentResultName(); + + if ( adr.segmentResultName() == RiaDefines::segmentNumberResultName() ) + { + std::vector values; + reader.values( adr, &values ); + } + } + } +} diff --git a/ApplicationLibCode/UserInterface/AnalysisPlots/RiuGroupedBarChartBuilder.cpp b/ApplicationLibCode/UserInterface/AnalysisPlots/RiuGroupedBarChartBuilder.cpp index 0a0a26ad84..e094201924 100644 --- a/ApplicationLibCode/UserInterface/AnalysisPlots/RiuGroupedBarChartBuilder.cpp +++ b/ApplicationLibCode/UserInterface/AnalysisPlots/RiuGroupedBarChartBuilder.cpp @@ -36,7 +36,9 @@ #include "qwt_scale_widget.h" #include +#include +#include #include #include @@ -668,13 +670,13 @@ void RiuGroupedBarChartBuilder::addBarChartToPlot( QwtPlot* plot, Qt::Orientatio // Set up the axis to contain group texts and tick marks { - QwtPlot::Axis axis = QwtPlot::xBottom; - QwtPlot::Axis valueAxis = QwtPlot::yLeft; + QwtAxis::Position axis = QwtAxis::XBottom; + QwtAxis::Position valueAxis = QwtAxis::YLeft; if ( barOrientation == Qt::Horizontal ) { - axis = QwtPlot::yLeft; - valueAxis = QwtPlot::xBottom; + axis = QwtAxis::YLeft; + valueAxis = QwtAxis::XBottom; } QwtScaleDiv groupAxisScaleDiv( 0, currentBarPosition ); diff --git a/ApplicationLibCode/UserInterface/AnalysisPlots/RiuGroupedBarChartBuilder.h b/ApplicationLibCode/UserInterface/AnalysisPlots/RiuGroupedBarChartBuilder.h index c3c28ad5ee..aef1a82714 100644 --- a/ApplicationLibCode/UserInterface/AnalysisPlots/RiuGroupedBarChartBuilder.h +++ b/ApplicationLibCode/UserInterface/AnalysisPlots/RiuGroupedBarChartBuilder.h @@ -24,6 +24,7 @@ #include #include +#include class QwtPlot; class QColor; diff --git a/ApplicationLibCode/UserInterface/CMakeLists_files.cmake b/ApplicationLibCode/UserInterface/CMakeLists_files.cmake index 344f285a01..1faccdfb4b 100644 --- a/ApplicationLibCode/UserInterface/CMakeLists_files.cmake +++ b/ApplicationLibCode/UserInterface/CMakeLists_files.cmake @@ -5,10 +5,13 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RiuFemResultTextBuilder.h ${CMAKE_CURRENT_LIST_DIR}/RiuGeoQuestNavigation.h ${CMAKE_CURRENT_LIST_DIR}/RiuInterfaceToViewWindow.h + ${CMAKE_CURRENT_LIST_DIR}/RiuPlotCurveSymbol.h ${CMAKE_CURRENT_LIST_DIR}/RiuQwtSymbol.h + ${CMAKE_CURRENT_LIST_DIR}/RiuPlotCurve.h ${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotCurve.h ${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotCurveDefines.h - ${CMAKE_CURRENT_LIST_DIR}/RiuRimQwtPlotCurve.h + ${CMAKE_CURRENT_LIST_DIR}/RiuPlotItem.h + ${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotItem.h ${CMAKE_CURRENT_LIST_DIR}/RiuPlotMainWindow.h ${CMAKE_CURRENT_LIST_DIR}/RiuMainWindow.h ${CMAKE_CURRENT_LIST_DIR}/RiuMainWindowBase.h @@ -38,6 +41,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RiuDockedQwtPlot.h ${CMAKE_CURRENT_LIST_DIR}/RiuGridCrossQwtPlot.h ${CMAKE_CURRENT_LIST_DIR}/RiuSummaryQwtPlot.h + ${CMAKE_CURRENT_LIST_DIR}/RiuSummaryPlot.h ${CMAKE_CURRENT_LIST_DIR}/RiuTextDialog.h ${CMAKE_CURRENT_LIST_DIR}/RiuTimeStepChangedHandler.h ${CMAKE_CURRENT_LIST_DIR}/RiuTofAccumulatedPhaseFractionsPlot.h @@ -52,6 +56,10 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RiuWellLogTrack.h ${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotPage.h ${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotBook.h + ${CMAKE_CURRENT_LIST_DIR}/RiuSummaryMultiPlotPage.h + ${CMAKE_CURRENT_LIST_DIR}/RiuSummaryMultiPlotBook.h + ${CMAKE_CURRENT_LIST_DIR}/RiuPlotWidget.h + ${CMAKE_CURRENT_LIST_DIR}/RiuPlotAxis.h ${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotWidget.h ${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotLegend.h ${CMAKE_CURRENT_LIST_DIR}/RiuPlotAnnotationTool.h @@ -93,6 +101,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RiuFileDialogTools.h ${CMAKE_CURRENT_LIST_DIR}/RiuGuiTheme.h ${CMAKE_CURRENT_LIST_DIR}/RiuQssSyntaxHighlighter.h + ${CMAKE_CURRENT_LIST_DIR}/RiuQwtDateScaleWrapper.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -102,10 +111,12 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RiuFemResultTextBuilder.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuGeoQuestNavigation.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuInterfaceToViewWindow.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiuPlotCurveSymbol.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuQwtSymbol.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiuPlotCurve.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotCurve.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotCurveDefines.cpp - ${CMAKE_CURRENT_LIST_DIR}/RiuRimQwtPlotCurve.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotItem.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuPlotMainWindow.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuMainWindow.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuMainWindowBase.cpp @@ -134,6 +145,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RiuDockedQwtPlot.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuGridCrossQwtPlot.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuSummaryQwtPlot.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiuSummaryPlot.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuTextDialog.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuTimeStepChangedHandler.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuTofAccumulatedPhaseFractionsPlot.cpp @@ -145,8 +157,12 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RiuPickItemInfo.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuWellLogTrack.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuWellLogPlot.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiuSummaryMultiPlotPage.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiuSummaryMultiPlotBook.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotPage.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotBook.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiuPlotWidget.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiuPlotAxis.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotWidget.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotLegend.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuPlotAnnotationTool.cpp @@ -188,14 +204,38 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RiuQssSyntaxHighlighter.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuTextEditWithCompletion.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuTextContentFrame.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiuQwtDateScaleWrapper.cpp ) -if(Qt5Charts_FOUND) - list(APPEND CODE_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RiuQtChartView.h) +if(RESINSIGHT_USE_QT_CHARTS) + list( + APPEND + CODE_HEADER_FILES + ${CMAKE_CURRENT_LIST_DIR}/RiuQtChartView.h + ${CMAKE_CURRENT_LIST_DIR}/RiuQtChartsPlotCurve.h + ${CMAKE_CURRENT_LIST_DIR}/RiuQtChartsPlotWidget.h + ${CMAKE_CURRENT_LIST_DIR}/RiuQtChartsPlotTools.h + ${CMAKE_CURRENT_LIST_DIR}/RiuQtChartsPlotCurveSymbol.h + ${CMAKE_CURRENT_LIST_DIR}/RiuQtChartsToolTip.h + ${CMAKE_CURRENT_LIST_DIR}/RiuSummaryQtChartsPlot.h + ) - list(APPEND CODE_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RiuQtChartView.cpp) + list( + APPEND + CODE_SOURCE_FILES + ${CMAKE_CURRENT_LIST_DIR}/RiuQtChartView.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiuQtChartsPlotCurve.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiuQtChartsPlotWidget.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiuQtChartsPlotTools.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiuQtChartsPlotCurveSymbol.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiuQtChartsToolTip.cpp + ${CMAKE_CURRENT_LIST_DIR}/RiuSummaryQtChartsPlot.cpp + ) - # list(APPEND QT_MOC_HEADERS ${CMAKE_CURRENT_LIST_DIR}/RiuQtChartView.h) + list(APPEND QT_MOC_HEADERS ${CMAKE_CURRENT_LIST_DIR}/RiuQtChartsPlotWidget.h + ${CMAKE_CURRENT_LIST_DIR}/RiuSummaryQtChartsPlot.h + ${CMAKE_CURRENT_LIST_DIR}/RiuQtChartsPlotCurve.h + ) endif() list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) @@ -221,14 +261,18 @@ list( ${CMAKE_CURRENT_LIST_DIR}/RiuTreeViewEventFilter.h ${CMAKE_CURRENT_LIST_DIR}/RiuWellLogPlot.h ${CMAKE_CURRENT_LIST_DIR}/RiuWellLogTrack.h + ${CMAKE_CURRENT_LIST_DIR}/RiuSummaryMultiPlotBook.h + ${CMAKE_CURRENT_LIST_DIR}/RiuSummaryMultiPlotPage.h ${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotPage.h ${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotBook.h ${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotWidget.h + ${CMAKE_CURRENT_LIST_DIR}/RiuPlotWidget.h ${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotLegend.h ${CMAKE_CURRENT_LIST_DIR}/RiuRecentFileActionProvider.h ${CMAKE_CURRENT_LIST_DIR}/RiuDockedQwtPlot.h ${CMAKE_CURRENT_LIST_DIR}/RiuGridCrossQwtPlot.h ${CMAKE_CURRENT_LIST_DIR}/RiuSummaryQwtPlot.h + ${CMAKE_CURRENT_LIST_DIR}/RiuSummaryPlot.h ${CMAKE_CURRENT_LIST_DIR}/RiuTofAccumulatedPhaseFractionsPlot.h ${CMAKE_CURRENT_LIST_DIR}/RiuQwtScalePicker.h ${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotWheelZoomer.h diff --git a/ApplicationLibCode/UserInterface/Riu3DMainWindowTools.cpp b/ApplicationLibCode/UserInterface/Riu3DMainWindowTools.cpp index f251c98b27..d56a827740 100644 --- a/ApplicationLibCode/UserInterface/Riu3DMainWindowTools.cpp +++ b/ApplicationLibCode/UserInterface/Riu3DMainWindowTools.cpp @@ -38,10 +38,7 @@ QWidget* Riu3DMainWindowTools::mainWindowWidget() //-------------------------------------------------------------------------------------------------- void Riu3DMainWindowTools::setActiveViewer( QWidget* subWindow ) { - if ( RiuMainWindow::instance() ) - { - RiuMainWindow::instance()->setActiveViewer( subWindow ); - } + if ( RiuMainWindow::instance() ) RiuMainWindow::instance()->setActiveViewer( subWindow ); } //-------------------------------------------------------------------------------------------------- @@ -49,10 +46,7 @@ void Riu3DMainWindowTools::setActiveViewer( QWidget* subWindow ) //-------------------------------------------------------------------------------------------------- void Riu3DMainWindowTools::setExpanded( const caf::PdmUiItem* uiItem, bool expanded /*= true*/ ) { - if ( RiuMainWindow::instance() ) - { - RiuMainWindow::instance()->setExpanded( uiItem, expanded ); - } + if ( RiuMainWindow::instance() ) RiuMainWindow::instance()->setExpanded( uiItem, expanded ); } //-------------------------------------------------------------------------------------------------- @@ -60,10 +54,7 @@ void Riu3DMainWindowTools::setExpanded( const caf::PdmUiItem* uiItem, bool expan //-------------------------------------------------------------------------------------------------- void Riu3DMainWindowTools::selectAsCurrentItem( const caf::PdmObject* object, bool allowActiveViewChange /*= true*/ ) { - if ( RiuMainWindow::instance() ) - { - RiuMainWindow::instance()->selectAsCurrentItem( object, allowActiveViewChange ); - } + if ( RiuMainWindow::instance() ) RiuMainWindow::instance()->selectAsCurrentItem( object, allowActiveViewChange ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/UserInterface/RiuAbstractLegendFrame.cpp b/ApplicationLibCode/UserInterface/RiuAbstractLegendFrame.cpp index b0673687c1..edab0cb3fe 100644 --- a/ApplicationLibCode/UserInterface/RiuAbstractLegendFrame.cpp +++ b/ApplicationLibCode/UserInterface/RiuAbstractLegendFrame.cpp @@ -37,6 +37,7 @@ RiuAbstractLegendFrame::RiuAbstractLegendFrame( QWidget* parent, const QString& , m_title( title ) { setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum ); + updateFontSize(); } //-------------------------------------------------------------------------------------------------- @@ -69,7 +70,7 @@ QSize RiuAbstractLegendFrame::sizeHint() const preferredWidth = std::max( preferredWidth, titleWidth ); preferredWidth = std::min( preferredWidth, 200 ); - return QSize( preferredWidth, preferredHeight ); + return { preferredWidth, preferredHeight }; } //-------------------------------------------------------------------------------------------------- @@ -81,11 +82,21 @@ QSize RiuAbstractLegendFrame::minimumSizeHint() const layoutInfo( &layout ); QFontMetrics fontMetrics( this->font() ); - QRect titleRect = fontMetrics.boundingRect( QRect( 0, 0, 200, 200 ), Qt::AlignLeft | Qt::TextWordWrap, m_title ); - int preferredContentHeight = titleRect.height() + 2 * layout.lineSpacing + 1.0 * layout.lineSpacing; - int preferredHeight = preferredContentHeight + layout.margins.top() + layout.margins.bottom(); - int titleWidth = titleRect.width() + layout.margins.left() + layout.margins.right(); + int preferredHeight = 0; + int titleWidth = 0; + + QStringList tokens = m_title.split( "\n" ); + for ( const auto& s : tokens ) + { + QRect titleRect = fontMetrics.boundingRect( QRect( 0, 0, 200, 200 ), Qt::AlignLeft, s ); + int preferredContentHeight = titleRect.height() + 2 * layout.lineSpacing + 1.0 * layout.lineSpacing; + int candidateHeight = preferredContentHeight + layout.margins.top() + layout.margins.bottom(); + int candidateTitleWidth = titleRect.width() + layout.margins.left() + layout.margins.right(); + + preferredHeight = std::max( preferredHeight, candidateHeight ); + titleWidth = std::max( titleWidth, candidateTitleWidth ); + } int firstTextWidth = fontMetrics.boundingRect( label( 0 ) ).width(); int lastTextWidth = fontMetrics.boundingRect( label( labelCount() - 1 ) ).width(); @@ -97,7 +108,7 @@ QSize RiuAbstractLegendFrame::minimumSizeHint() const preferredWidth = std::max( preferredWidth, titleWidth ); preferredWidth = std::min( preferredWidth, 400 ); - return QSize( preferredWidth, preferredHeight ); + return { preferredWidth, preferredHeight }; } //-------------------------------------------------------------------------------------------------- @@ -105,9 +116,7 @@ QSize RiuAbstractLegendFrame::minimumSizeHint() const //-------------------------------------------------------------------------------------------------- void RiuAbstractLegendFrame::renderTo( QPainter* painter, const QRect& targetRect ) { - QFont font = this->font(); - font.setPixelSize( caf::FontTools::pointSizeToPixelSize( RiaPreferences::current()->defaultPlotFontSize() ) ); - this->setFont( font ); + updateFontSize(); QColor textColor = RiuGuiTheme::getColorByVariableName( "textColor" ); @@ -135,7 +144,7 @@ void RiuAbstractLegendFrame::renderTo( QPainter* painter, const QRect& targetRec } std::vector> visibleTickLabels = visibleLabels( layout ); - for ( auto tickLabel : visibleTickLabels ) + for ( const auto& tickLabel : visibleTickLabels ) { painter->save(); painter->translate( tickLabel.first.topLeft() ); @@ -154,8 +163,6 @@ void RiuAbstractLegendFrame::renderTo( QPainter* painter, const QRect& targetRec renderRect( painter, layout, i ); } painter->drawRect( layout.colorBarRect ); - // painter->drawLine( QPointF( layout.tickMidX, layout.tickYPixelPos->get( i ) ), - // QPointF( layout.tickMidX, layout.tickYPixelPos->get( i + 1 ) ) ); painter->restore(); } @@ -187,7 +194,7 @@ std::vector> RiuAbstractLegendFrame::visibleLabels( co QString valueString = label( i ); lastRect = rect; - visibleTickLabels.push_back( { rect, valueString } ); + visibleTickLabels.emplace_back( rect, valueString ); } return visibleTickLabels; } diff --git a/ApplicationLibCode/UserInterface/RiuAbstractOverlayContentFrame.cpp b/ApplicationLibCode/UserInterface/RiuAbstractOverlayContentFrame.cpp index 1f814c3eaa..2567f4ab1d 100644 --- a/ApplicationLibCode/UserInterface/RiuAbstractOverlayContentFrame.cpp +++ b/ApplicationLibCode/UserInterface/RiuAbstractOverlayContentFrame.cpp @@ -41,6 +41,16 @@ RiuAbstractOverlayContentFrame::~RiuAbstractOverlayContentFrame() { } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuAbstractOverlayContentFrame::updateFontSize() +{ + QFont font = this->font(); + font.setPixelSize( caf::FontTools::pointSizeToPixelSize( RiaPreferences::current()->defaultPlotFontSize() ) ); + this->setFont( font ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -52,9 +62,7 @@ RiuTextOverlayContentFrame::RiuTextOverlayContentFrame( QWidget* parent /*= null m_textLabel = new QLabel; layout->addWidget( m_textLabel ); - QFont font = m_textLabel->font(); - caf::FontTools::pointSizeToPixelSize( RiaPreferences::current()->defaultPlotFontSize() ); - m_textLabel->setFont( font ); + updateLabelFont(); } //-------------------------------------------------------------------------------------------------- @@ -70,6 +78,8 @@ void RiuTextOverlayContentFrame::setText( const QString& text ) //-------------------------------------------------------------------------------------------------- void RiuTextOverlayContentFrame::renderTo( QPainter* painter, const QRect& targetRect ) { + updateLabelFont(); + painter->save(); painter->translate( targetRect.topLeft() + QPoint( this->contentsMargins().left(), this->contentsMargins().top() ) ); painter->setFont( m_textLabel->font() ); @@ -81,3 +91,13 @@ void RiuTextOverlayContentFrame::renderTo( QPainter* painter, const QRect& targe painter->restore(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuTextOverlayContentFrame::updateLabelFont() +{ + QFont font = m_textLabel->font(); + font.setPixelSize( caf::FontTools::pointSizeToPixelSize( RiaPreferences::current()->defaultPlotFontSize() ) ); + m_textLabel->setFont( font ); +} diff --git a/ApplicationLibCode/UserInterface/RiuAbstractOverlayContentFrame.h b/ApplicationLibCode/UserInterface/RiuAbstractOverlayContentFrame.h index 6456440b92..b11b0899b5 100644 --- a/ApplicationLibCode/UserInterface/RiuAbstractOverlayContentFrame.h +++ b/ApplicationLibCode/UserInterface/RiuAbstractOverlayContentFrame.h @@ -31,6 +31,9 @@ class RiuAbstractOverlayContentFrame : public QFrame ~RiuAbstractOverlayContentFrame() override; virtual void renderTo( QPainter* painter, const QRect& targetRect ) = 0; + +protected: + void updateFontSize(); }; class RiuTextOverlayContentFrame : public RiuAbstractOverlayContentFrame @@ -42,6 +45,9 @@ class RiuTextOverlayContentFrame : public RiuAbstractOverlayContentFrame void setText( const QString& text ); void renderTo( QPainter* painter, const QRect& targetRect ) override; +private: + void updateLabelFont(); + private: QPointer m_textLabel; }; diff --git a/ApplicationLibCode/UserInterface/RiuAdvancedSnapshotExportWidget.cpp b/ApplicationLibCode/UserInterface/RiuAdvancedSnapshotExportWidget.cpp index c14ee2711e..12105bd166 100644 --- a/ApplicationLibCode/UserInterface/RiuAdvancedSnapshotExportWidget.cpp +++ b/ApplicationLibCode/UserInterface/RiuAdvancedSnapshotExportWidget.cpp @@ -226,7 +226,7 @@ void RiuAdvancedSnapshotExportWidget::deleteAllSnapshotItems() { if ( !m_rimProject ) return; - m_rimProject->multiSnapshotDefinitions.deleteAllChildObjects(); + m_rimProject->multiSnapshotDefinitions.deleteChildren(); m_rimProject->multiSnapshotDefinitions.uiCapability()->updateConnectedEditors(); } diff --git a/ApplicationLibCode/UserInterface/RiuCadNavigation.cpp b/ApplicationLibCode/UserInterface/RiuCadNavigation.cpp index c849a27821..74423d6cab 100644 --- a/ApplicationLibCode/UserInterface/RiuCadNavigation.cpp +++ b/ApplicationLibCode/UserInterface/RiuCadNavigation.cpp @@ -18,7 +18,10 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RiuCadNavigation.h" + +#include "caf.h" #include "cafViewer.h" + #include "cvfCamera.h" #include "cvfHitItemCollection.h" #include "cvfManipulatorTrackball.h" @@ -57,7 +60,7 @@ bool RiuCadNavigation::handleInputEvent( QInputEvent* inputEvent ) int translatedMousePosX, translatedMousePosY; cvfEventPos( me->x(), me->y(), &translatedMousePosX, &translatedMousePosY ); - if ( me->button() == Qt::MidButton && me->modifiers() == Qt::NoModifier && isRotationEnabled() ) + if ( me->button() == Qt::MiddleButton && me->modifiers() == Qt::NoModifier && isRotationEnabled() ) { this->pickAndSetPointOfInterest( me->x(), me->y() ); @@ -67,7 +70,7 @@ bool RiuCadNavigation::handleInputEvent( QInputEvent* inputEvent ) isEventHandled = true; } else if ( me->button() == Qt::LeftButton || - ( me->button() == Qt::MidButton && ( me->modifiers() & Qt::ShiftModifier ) ) ) + ( me->button() == Qt::MiddleButton && ( me->modifiers() & Qt::ShiftModifier ) ) ) { m_trackball->startNavigation( cvf::ManipulatorTrackball::PAN, translatedMousePosX, translatedMousePosY ); m_isNavigating = true; @@ -82,7 +85,7 @@ bool RiuCadNavigation::handleInputEvent( QInputEvent* inputEvent ) if ( m_isNavigating ) { QMouseEvent* me = static_cast( inputEvent ); - if ( me->button() == Qt::MidButton || me->button() == Qt::LeftButton ) + if ( me->button() == Qt::MiddleButton || me->button() == Qt::LeftButton ) { m_trackball->endNavigation(); @@ -121,18 +124,19 @@ bool RiuCadNavigation::handleInputEvent( QInputEvent* inputEvent ) { if ( inputEvent->modifiers() == Qt::NoModifier ) { - QWheelEvent* we = static_cast( inputEvent ); + QWheelEvent* we = static_cast( inputEvent ); + auto position = caf::position( we ); - updatePointOfInterestDuringZoomIfNecessary( we->x(), we->y() ); + updatePointOfInterestDuringZoomIfNecessary( position.x(), position.y() ); if ( m_isRotCenterInitialized ) { int translatedMousePosX, translatedMousePosY; - cvfEventPos( we->x(), we->y(), &translatedMousePosX, &translatedMousePosY ); + cvfEventPos( position.x(), position.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/ApplicationLibCode/UserInterface/RiuCalculationsContextMenuManager.cpp b/ApplicationLibCode/UserInterface/RiuCalculationsContextMenuManager.cpp index 52e807a48a..3fb635e834 100644 --- a/ApplicationLibCode/UserInterface/RiuCalculationsContextMenuManager.cpp +++ b/ApplicationLibCode/UserInterface/RiuCalculationsContextMenuManager.cpp @@ -17,14 +17,17 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RiuCalculationsContextMenuManager.h" + #include "RimSummaryCalculationCollection.h" -#include "SummaryPlotCommands/RicSummaryCurveCalculatorUi.h" + +#include "RicUserDefinedCalculatorUi.h" + #include //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuCalculationsContextMenuManager::attachWidget( QWidget* widget, RicSummaryCurveCalculatorUi* curveCalc ) +void RiuCalculationsContextMenuManager::attachWidget( QWidget* widget, RicUserDefinedCalculatorUi* curveCalc ) { if ( m_widget != widget ) { @@ -63,13 +66,15 @@ void RiuCalculationsContextMenuManager::slotMenuItems( QPoint point ) //-------------------------------------------------------------------------------------------------- void RiuCalculationsContextMenuManager::slotCreateCalculationCopy() { - RimSummaryCalculation* currCalculation = m_curveCalc != nullptr ? m_curveCalc->currentCalculation() : nullptr; - - if ( m_widget != nullptr && currCalculation != nullptr ) + if ( m_widget != nullptr && m_curveCalc != nullptr ) { - RimSummaryCalculationCollection* coll = RicSummaryCurveCalculatorUi::calculationCollection(); - RimSummaryCalculation* calcCopy = coll->addCalculationCopy( currCalculation ); - m_curveCalc->setCurrentCalculation( calcCopy ); - m_curveCalc->updateConnectedEditors(); + RimUserDefinedCalculation* currCalculation = m_curveCalc->currentCalculation(); + if ( currCalculation != nullptr ) + { + RimUserDefinedCalculationCollection* coll = m_curveCalc->calculationCollection(); + RimUserDefinedCalculation* calcCopy = coll->addCalculationCopy( currCalculation ); + m_curveCalc->setCurrentCalculation( calcCopy ); + m_curveCalc->updateConnectedEditors(); + } } } diff --git a/ApplicationLibCode/UserInterface/RiuCalculationsContextMenuManager.h b/ApplicationLibCode/UserInterface/RiuCalculationsContextMenuManager.h index f66649a151..7e7e0d27ee 100644 --- a/ApplicationLibCode/UserInterface/RiuCalculationsContextMenuManager.h +++ b/ApplicationLibCode/UserInterface/RiuCalculationsContextMenuManager.h @@ -21,14 +21,15 @@ #include "cafPdmChildArrayField.h" #include "cafPdmField.h" #include "cafPdmObject.h" + #include #include #include + #include #include -class RimSummaryCalculationVariable; -class RicSummaryCurveCalculatorUi; +class RicUserDefinedCalculatorUi; //================================================================================================== /// @@ -47,7 +48,7 @@ class RiuCalculationsContextMenuManager : public QObject { } - void attachWidget( QWidget* widget, RicSummaryCurveCalculatorUi* curveCalc ); + void attachWidget( QWidget* widget, RicUserDefinedCalculatorUi* curveCalc ); public slots: void slotMenuItems( QPoint point ); @@ -57,7 +58,7 @@ private slots: private: QPointer m_widget; - RicSummaryCurveCalculatorUi* m_curveCalc; + RicUserDefinedCalculatorUi* m_curveCalc; int m_textPosition; std::map> m_actionCache; }; diff --git a/ApplicationLibCode/UserInterface/RiuCategoryLegendFrame.cpp b/ApplicationLibCode/UserInterface/RiuCategoryLegendFrame.cpp index 19a81a3ba7..3902c4130b 100644 --- a/ApplicationLibCode/UserInterface/RiuCategoryLegendFrame.cpp +++ b/ApplicationLibCode/UserInterface/RiuCategoryLegendFrame.cpp @@ -1,5 +1,7 @@ #include "RiuCategoryLegendFrame.h" +#include "RiaTextStringTools.h" + #include "cafCategoryLegend.h" #include "cvfqtUtils.h" @@ -29,7 +31,7 @@ RiuCategoryLegendFrame::~RiuCategoryLegendFrame() void RiuCategoryLegendFrame::layoutInfo( LayoutInfo* layout ) const { QFontMetrics fontMetrics( this->font() ); - QStringList titleLines = m_title.split( "\n", QString::SkipEmptyParts ); + QStringList titleLines = RiaTextStringTools::splitSkipEmptyParts( m_title, "\n" ); layout->charHeight = fontMetrics.height(); layout->charAscent = fontMetrics.ascent(); diff --git a/ApplicationLibCode/UserInterface/RiuDockWidgetTools.cpp b/ApplicationLibCode/UserInterface/RiuDockWidgetTools.cpp index cdc88c47c6..2b759b319e 100644 --- a/ApplicationLibCode/UserInterface/RiuDockWidgetTools.cpp +++ b/ApplicationLibCode/UserInterface/RiuDockWidgetTools.cpp @@ -103,9 +103,65 @@ QString RiuDockWidgetTools::undoStackName() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RiuDockWidgetTools::plotMainWindowProjectTreeName() +QString RiuDockWidgetTools::summaryPlotManagerName() { - return "plotMainWindow_dockProjectTree"; + return "dockSummaryPlotManager"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuDockWidgetTools::mainWindowProjectTreeName() +{ + return "mainWindow_dockProjectTree"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuDockWidgetTools::mainWindowDataSourceTreeName() +{ + return "mainWindow_dockDataSourceTree"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuDockWidgetTools::mainWindowScriptsTreeName() +{ + return "mainWindow_dockScriptsTree"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuDockWidgetTools::plotMainWindowDataSourceTreeName() +{ + return "plotMainWindow_dockDataSourceTree"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuDockWidgetTools::plotMainWindowPlotsTreeName() +{ + return "plotMainWindow_dockPlotsTree"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuDockWidgetTools::plotMainWindowTemplateTreeName() +{ + return "plotMainWindow_dockTemplatesTree"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuDockWidgetTools::plotMainWindowScriptsTreeName() +{ + return "plotMainWindow_dockScriptsTree"; } //-------------------------------------------------------------------------------------------------- @@ -221,6 +277,8 @@ QAction* RiuDockWidgetTools::toggleActionForWidget( const QObject* parent, const //-------------------------------------------------------------------------------------------------- void RiuDockWidgetTools::setVisibleDockingWindowsForEclipse() { + if ( !RiuMainWindow::instance() ) return; + RiuMainWindow* mainWindow = RiuMainWindow::instance(); auto widgetVisibilities = widgetVisibilitiesForEclipse(); @@ -232,6 +290,8 @@ void RiuDockWidgetTools::setVisibleDockingWindowsForEclipse() //-------------------------------------------------------------------------------------------------- void RiuDockWidgetTools::setVisibleDockingWindowsForGeoMech() { + if ( !RiuMainWindow::instance() ) return; + RiuMainWindow* mainWindow = RiuMainWindow::instance(); auto widgetVisibilities = widgetVisibilitiesForGeoMech(); @@ -292,6 +352,8 @@ QVariant RiuDockWidgetTools::defaultDockWidgetVisibilities() //-------------------------------------------------------------------------------------------------- void RiuDockWidgetTools::workaroundForQwtDockWidgets() { + if ( !RiuMainWindow::instance() ) return; + RiuMainWindow* mainWindow = RiuMainWindow::instance(); QList dockWidgets = mainWindow->findChildren(); diff --git a/ApplicationLibCode/UserInterface/RiuDockWidgetTools.h b/ApplicationLibCode/UserInterface/RiuDockWidgetTools.h index 61fd0d8da5..dc96e9114b 100644 --- a/ApplicationLibCode/UserInterface/RiuDockWidgetTools.h +++ b/ApplicationLibCode/UserInterface/RiuDockWidgetTools.h @@ -46,8 +46,17 @@ class RiuDockWidgetTools static QString messagesName(); static QString mohrsCirclePlotName(); static QString undoStackName(); + static QString summaryPlotManagerName(); + + static QString mainWindowProjectTreeName(); + static QString mainWindowDataSourceTreeName(); + static QString mainWindowScriptsTreeName(); + + static QString plotMainWindowDataSourceTreeName(); + static QString plotMainWindowPlotsTreeName(); + static QString plotMainWindowTemplateTreeName(); + static QString plotMainWindowScriptsTreeName(); - static QString plotMainWindowProjectTreeName(); static QString plotMainWindowPropertyEditorName(); static QString plotMainWindowMessagesName(); static QString plotMainWindowUndoStackName(); @@ -65,9 +74,9 @@ class RiuDockWidgetTools static void setDockWidgetVisibility( const QObject* parent, const QString& dockWidgetName, bool isVisible ); static void applyDockWidgetVisibilities( const QObject* parent, const QMap& visibilityMap ); + static QDockWidget* findDockWidget( const QObject* parent, const QString& dockWidgetName ); + private: static QMap widgetVisibilitiesForEclipse(); static QMap widgetVisibilitiesForGeoMech(); - - static QDockWidget* findDockWidget( const QObject* parent, const QString& dockWidgetName ); }; diff --git a/ApplicationLibCode/UserInterface/RiuDockedQwtPlot.cpp b/ApplicationLibCode/UserInterface/RiuDockedQwtPlot.cpp index bb2582f570..94c625a4e9 100644 --- a/ApplicationLibCode/UserInterface/RiuDockedQwtPlot.cpp +++ b/ApplicationLibCode/UserInterface/RiuDockedQwtPlot.cpp @@ -39,7 +39,7 @@ RiuDockedQwtPlot::RiuDockedQwtPlot( QWidget* parent /*= nullptr*/ ) //-------------------------------------------------------------------------------------------------- void RiuDockedQwtPlot::applyFontSizes( bool replot /*= false*/ ) { - std::set allAxes = { QwtPlot::xBottom, QwtPlot::yLeft, QwtPlot::xTop, QwtPlot::yRight }; + std::set allAxes = { QwtAxis::XBottom, QwtAxis::YLeft, QwtAxis::XTop, QwtAxis::YRight }; caf::FontTools::FontSize fontSize = RiaPreferences::current()->defaultPlotFontSize(); @@ -54,7 +54,7 @@ void RiuDockedQwtPlot::applyFontSizes( bool replot /*= false*/ ) titleText.setFont( font ); this->setTitle( titleText ); - for ( QwtPlot::Axis axis : allAxes ) + for ( QwtAxis::Position axis : allAxes ) { QwtText text = this->axisTitle( axis ); QFont axisTitleFont = text.font(); diff --git a/ApplicationLibCode/UserInterface/RiuDragDrop.cpp b/ApplicationLibCode/UserInterface/RiuDragDrop.cpp index 88bd676b81..848d03d36d 100644 --- a/ApplicationLibCode/UserInterface/RiuDragDrop.cpp +++ b/ApplicationLibCode/UserInterface/RiuDragDrop.cpp @@ -19,8 +19,6 @@ #include "RiuDragDrop.h" -#include "RiaGuiApplication.h" - #include "OperationsUsingObjReferences/RicPasteEclipseCasesFeature.h" #include "RicCloseCaseFeature.h" #include "WellLogCommands/RicNewWellLogFileCurveFeature.h" @@ -28,11 +26,15 @@ #include "RimCaseCollection.h" #include "RimEclipseCase.h" +#include "RimEclipseResultAddress.h" #include "RimEclipseResultCase.h" #include "RimIdenticalGridCaseGroup.h" #include "RimMimeData.h" #include "RimMultiPlot.h" #include "RimPlot.h" +#include "RimProject.h" +#include "RimSummaryAddress.h" +#include "RimSummaryAddressCollection.h" #include "RimSummaryCase.h" #include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" @@ -46,6 +48,7 @@ #include "RimWellLogFileChannel.h" #include "RimWellLogPlot.h" #include "RimWellLogTrack.h" + #include "RiuMainWindow.h" #include "RicWellLogTools.h" @@ -55,6 +58,8 @@ #include "cafSelectionManager.h" #include +#include +#include #include //-------------------------------------------------------------------------------------------------- @@ -171,9 +176,10 @@ class RiuTypedPdmObjects //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuDragDrop::RiuDragDrop() +RiuDragDrop::RiuDragDrop( caf::PdmUiTreeView* treeView ) + : m_projectTreeView( treeView ) + , m_proposedDropAction( Qt::MoveAction ) { - m_proposedDropAction = Qt::MoveAction; } //-------------------------------------------------------------------------------------------------- @@ -183,6 +189,26 @@ RiuDragDrop::~RiuDragDrop() { } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RiuDragDrop::draggedObjectsFromTreeView( caf::PdmUiTreeView* dragSource, + const QMimeData* data ) +{ + const MimeDataWithIndexes* myMimeData = qobject_cast( data ); + if ( myMimeData ) + { + caf::PdmObjectGroup draggedObjects; + QModelIndexList indices = myMimeData->indexes(); + + objectGroupFromModelIndexes( dragSource, &draggedObjects, indices ); + + return draggedObjects.objects; + } + + return {}; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -212,12 +238,11 @@ Qt::DropActions RiuDragDrop::supportedDropActions() const //-------------------------------------------------------------------------------------------------- Qt::ItemFlags RiuDragDrop::flags( const QModelIndex& index ) const { - Qt::ItemFlags itemflags = nullptr; + Qt::ItemFlags itemflags; - if ( index.isValid() && RiaGuiApplication::activeMainWindow() ) + if ( index.isValid() ) { - caf::PdmUiTreeView* uiTreeView = RiaGuiApplication::activeMainWindow()->projectTreeView(); - caf::PdmUiItem* uiItem = uiTreeView->uiItemFromModelIndex( index ); + caf::PdmUiItem* uiItem = m_projectTreeView->uiItemFromModelIndex( index ); caf::PdmObject* pdmObj = dynamic_cast( uiItem ); if ( pdmObj ) @@ -232,9 +257,26 @@ Qt::ItemFlags RiuDragDrop::flags( const QModelIndex& index ) const dynamic_cast( uiItem ) || dynamic_cast( uiItem ) || dynamic_cast( uiItem ) ) { - // TODO: Remember to handle reservoir holding the main grid itemflags |= Qt::ItemIsDragEnabled; } + else + { + auto sumAdrColl = dynamic_cast( uiItem ); + if ( sumAdrColl && sumAdrColl->canBeDragged() ) + { + itemflags |= Qt::ItemIsDragEnabled; + } + auto sumAdr = dynamic_cast( uiItem ); + if ( sumAdr ) + { + itemflags |= Qt::ItemIsDragEnabled; + } + auto eclipseResultAdr = dynamic_cast( uiItem ); + if ( eclipseResultAdr ) + { + itemflags |= Qt::ItemIsDragEnabled; + } + } if ( m_dragItems.empty() ) return itemflags; @@ -339,8 +381,7 @@ Qt::ItemFlags RiuDragDrop::flags( const QModelIndex& index ) const //-------------------------------------------------------------------------------------------------- bool RiuDragDrop::dropMimeData( const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& dropTargetIndex ) { - CVF_ASSERT( RiaGuiApplication::activeMainWindow() ); - caf::PdmUiTreeView* uiTreeView = RiaGuiApplication::activeMainWindow()->projectTreeView(); + caf::PdmUiTreeView* uiTreeView = m_projectTreeView; caf::PdmUiItem* dropTargetUiItem = uiTreeView->uiItemFromModelIndex( dropTargetIndex ); caf::PdmObjectHandle* dropTarget = dynamic_cast( dropTargetUiItem ); @@ -351,7 +392,7 @@ bool RiuDragDrop::dropMimeData( const QMimeData* data, Qt::DropAction action, in if ( myMimeData && dropTargetIndex.isValid() ) { QModelIndexList indices = myMimeData->indexes(); - objectGroupFromModelIndexes( &draggedObjects, indices ); + objectGroupFromModelIndexes( uiTreeView, &draggedObjects, indices ); } else { @@ -655,12 +696,13 @@ bool RiuDragDrop::handleSummaryCaseMainCollectionDrop( Qt::DropAction //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuDragDrop::objectGroupFromModelIndexes( caf::PdmObjectGroup* objectGroup, const QModelIndexList& indexes ) +void RiuDragDrop::objectGroupFromModelIndexes( caf::PdmUiTreeView* uiTreeView, + caf::PdmObjectGroup* objectGroup, + const QModelIndexList& indexes ) { CVF_ASSERT( objectGroup ); objectGroup->objects.clear(); - caf::PdmUiTreeView* uiTreeView = RiuMainWindow::instance()->projectTreeView(); for ( int i = 0; i < indexes.size(); i++ ) { @@ -728,3 +770,82 @@ bool RiuDragDrop::handleSurfaceCollectionDrop( Qt::DropAction action, return true; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiuDragDrop::handleGenericDropEvent( QEvent* event, std::vector& droppedObjects ) +{ + if ( !event ) return false; + + const MimeDataWithIndexes* mimeData = nullptr; + Qt::KeyboardModifiers keyModifiers; + + bool bResult = false; + + if ( event->type() == QEvent::Drop ) + { + // These drop events come from Qwt + auto dropEvent = static_cast( event ); + if ( dropEvent ) + { + mimeData = qobject_cast( dropEvent->mimeData() ); + keyModifiers = dropEvent->keyboardModifiers(); + + dropEvent->acceptProposedAction(); + dropEvent->accept(); + bResult = true; + } + } + else if ( event->type() == QEvent::GraphicsSceneDrop ) + { + // These drop events come from QtChart + auto dropEvent = static_cast( event ); + if ( dropEvent ) + { + mimeData = qobject_cast( dropEvent->mimeData() ); + + dropEvent->acceptProposedAction(); + dropEvent->accept(); + bResult = true; + } + } + + if ( mimeData ) + { + auto objects = convertToObjects( mimeData ); + droppedObjects.insert( droppedObjects.end(), objects.begin(), objects.end() ); + + bResult = true; + } + + return bResult; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RiuDragDrop::convertToObjects( const QMimeData* mimeData ) +{ + std::vector droppedObjects; + if ( mimeData ) + { + QString mimeType = caf::PdmUiDragDropInterface::mimeTypeForObjectReferenceList(); + + QByteArray data = mimeData->data( mimeType ); + if ( data.isEmpty() ) return {}; + + QStringList objectReferences; + QDataStream in( &data, QIODevice::ReadOnly ); + in >> objectReferences; + + auto proj = RimProject::current(); + for ( const auto& objRef : objectReferences ) + { + auto obj = caf::PdmReferenceHelper::objectFromReference( proj, objRef ); + if ( obj ) droppedObjects.push_back( obj ); + } + } + + return droppedObjects; +} diff --git a/ApplicationLibCode/UserInterface/RiuDragDrop.h b/ApplicationLibCode/UserInterface/RiuDragDrop.h index a61443dd59..4d90896c20 100644 --- a/ApplicationLibCode/UserInterface/RiuDragDrop.h +++ b/ApplicationLibCode/UserInterface/RiuDragDrop.h @@ -27,7 +27,8 @@ namespace caf { class PdmObjectHandle; -} +class PdmUiTreeView; +} // namespace caf class RimMultiPlot; class RimIdenticalGridCaseGroup; @@ -39,6 +40,7 @@ class RimSurfaceCollection; class RimWellLogPlot; class RimWellLogTrack; class RimWellLogCurve; +class QEvent; //-------------------------------------------------------------------------------------------------- /// @@ -46,9 +48,16 @@ class RimWellLogCurve; class RiuDragDrop : public caf::PdmUiDragDropInterface { public: - RiuDragDrop(); + RiuDragDrop( caf::PdmUiTreeView* treeView ); ~RiuDragDrop() override; + static std::vector draggedObjectsFromTreeView( caf::PdmUiTreeView* dragSource, + const QMimeData* data ); + + static bool handleGenericDropEvent( QEvent* event, std::vector& droppedObjects ); + + static std::vector convertToObjects( const QMimeData* mimeData ); + protected: Qt::DropActions supportedDropActions() const override; Qt::ItemFlags flags( const QModelIndex& index ) const override; @@ -96,10 +105,14 @@ class RiuDragDrop : public caf::PdmUiDragDropInterface caf::PdmObjectGroup& objectGroup, RimSurfaceCollection* surfaceCollection ); - static void objectGroupFromModelIndexes( caf::PdmObjectGroup* objectGroup, const QModelIndexList& indexes ); + static void objectGroupFromModelIndexes( caf::PdmUiTreeView* uiTreeView, + caf::PdmObjectGroup* objectGroup, + const QModelIndexList& indexes ); static std::vector> objectHandlesFromSelection(); private: mutable std::vector> m_dragItems; - Qt::DropAction m_proposedDropAction; + + Qt::DropAction m_proposedDropAction; + caf::PdmUiTreeView* m_projectTreeView; }; diff --git a/ApplicationLibCode/UserInterface/RiuFemTimeHistoryResultAccessor.cpp b/ApplicationLibCode/UserInterface/RiuFemTimeHistoryResultAccessor.cpp index 394791ce81..31188b51b6 100644 --- a/ApplicationLibCode/UserInterface/RiuFemTimeHistoryResultAccessor.cpp +++ b/ApplicationLibCode/UserInterface/RiuFemTimeHistoryResultAccessor.cpp @@ -19,6 +19,8 @@ #include "RiuFemTimeHistoryResultAccessor.h" +#include "RiaNumberFormat.h" + #include "RigFemClosestResultIndexCalculator.h" #include "RigFemPart.h" #include "RigFemPartCollection.h" @@ -26,6 +28,7 @@ #include "RigFemPartResultsCollection.h" #include "RigFemTypes.h" #include "RigGeoMechCaseData.h" + #include "RiuGeoMechXfTensorResultAccessor.h" #include // Needed for HUGE_VAL on Linux @@ -101,11 +104,12 @@ QString RiuFemTimeHistoryResultAccessor::geometrySelectionText() const cvf::Vec3d domainCoord = m_intersectionPointInDomain; text += QString( ", ijk[%1, %2, %3] " ).arg( i ).arg( j ).arg( k ); - QString formattedText; - formattedText.sprintf( "Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", - domainCoord.x(), - domainCoord.y(), - -domainCoord.z() ); + auto xTxt = RiaNumberFormat::valueToText( domainCoord.x(), RiaNumberFormat::NumberFormatType::FIXED, 2 ); + auto yTxt = RiaNumberFormat::valueToText( domainCoord.y(), RiaNumberFormat::NumberFormatType::FIXED, 2 ); + auto zTxt = RiaNumberFormat::valueToText( -domainCoord.z(), RiaNumberFormat::NumberFormatType::FIXED, 2 ); + + QString formattedText = + QString( "Intersection point : [E: %1, N: %2, Depth: %3]" ).arg( xTxt ).arg( yTxt ).arg( zTxt ); text += formattedText; } diff --git a/ApplicationLibCode/UserInterface/RiuFlowCharacteristicsPlot.cpp b/ApplicationLibCode/UserInterface/RiuFlowCharacteristicsPlot.cpp index b179e3680e..624da965b7 100644 --- a/ApplicationLibCode/UserInterface/RiuFlowCharacteristicsPlot.cpp +++ b/ApplicationLibCode/UserInterface/RiuFlowCharacteristicsPlot.cpp @@ -25,10 +25,12 @@ #include "RimFlowCharacteristicsPlot.h" +#include "RiuPlotCurveSymbol.h" #include "RiuQwtPlotCurve.h" #include "RiuQwtPlotTools.h" #include "RiuQwtPlotWheelZoomer.h" #include "RiuQwtPlotZoomer.h" +#include "RiuQwtSymbol.h" #include "RiuResultQwtPlot.h" #include "cvfColor3.h" @@ -39,7 +41,7 @@ #include "qwt_legend.h" #include "qwt_plot.h" #include "qwt_plot_zoomer.h" -#include "qwt_symbol.h" +#include "qwt_text.h" #include #include @@ -47,6 +49,8 @@ #include #include +#include // Needed for HUGE_VAL on Linux + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -95,20 +99,20 @@ RiuFlowCharacteristicsPlot::RiuFlowCharacteristicsPlot( RimFlowCharacteristicsPl caf::FontTools::RelativeSize::Small ); { - QwtText axisTitle = m_sweepEffPlot->axisTitle( QwtPlot::xBottom ); + QwtText axisTitle = m_sweepEffPlot->axisTitle( QwtAxis::XBottom ); auto font = axisTitle.font(); font.setPointSize( legendFontSize ); axisTitle.setFont( font ); axisTitle.setText( "Dimensionless Time" ); - m_sweepEffPlot->setAxisTitle( QwtPlot::xBottom, axisTitle ); + m_sweepEffPlot->setAxisTitle( QwtAxis::XBottom, axisTitle ); } { - QwtText axisTitle = m_sweepEffPlot->axisTitle( QwtPlot::yLeft ); + QwtText axisTitle = m_sweepEffPlot->axisTitle( QwtAxis::YLeft ); auto font = axisTitle.font(); font.setPointSize( legendFontSize ); axisTitle.setFont( font ); axisTitle.setText( "Sweep Efficiency" ); - m_sweepEffPlot->setAxisTitle( QwtPlot::yLeft, axisTitle ); + m_sweepEffPlot->setAxisTitle( QwtAxis::YLeft, axisTitle ); } RiuQwtPlotTools::setCommonPlotBehaviour( m_flowCapVsStorageCapPlot ); @@ -117,20 +121,20 @@ RiuFlowCharacteristicsPlot::RiuFlowCharacteristicsPlot( RimFlowCharacteristicsPl m_flowCapVsStorageCapPlot->setTitle( "Flow Capacity vs Storage Capacity" ); { - QwtText axisTitle = m_flowCapVsStorageCapPlot->axisTitle( QwtPlot::xBottom ); + QwtText axisTitle = m_flowCapVsStorageCapPlot->axisTitle( QwtAxis::XBottom ); auto font = axisTitle.font(); font.setPointSize( legendFontSize ); axisTitle.setFont( font ); axisTitle.setText( "Storage Capacity [C]" ); - m_flowCapVsStorageCapPlot->setAxisTitle( QwtPlot::xBottom, axisTitle ); + m_flowCapVsStorageCapPlot->setAxisTitle( QwtAxis::XBottom, axisTitle ); } { - QwtText axisTitle = m_flowCapVsStorageCapPlot->axisTitle( QwtPlot::yLeft ); + QwtText axisTitle = m_flowCapVsStorageCapPlot->axisTitle( QwtAxis::YLeft ); auto font = axisTitle.font(); font.setPointSize( legendFontSize ); axisTitle.setFont( font ); axisTitle.setText( "Flow Capacity [F]" ); - m_flowCapVsStorageCapPlot->setAxisTitle( QwtPlot::yLeft, axisTitle ); + m_flowCapVsStorageCapPlot->setAxisTitle( QwtAxis::YLeft, axisTitle ); } } @@ -194,9 +198,7 @@ void RiuFlowCharacteristicsPlot::addCurveWithLargeSymbol( QwtPlot* plot, { auto curve = createEmptyCurve( plot, curveName, color ); - QwtSymbol::Style style = QwtSymbol::Diamond; - QwtSymbol* symbol = new QwtSymbol( style ); - + RiuPlotCurveSymbol* symbol = new RiuQwtSymbol( RiuPlotCurveSymbol::PointSymbolEnum::SYMBOL_DIAMOND ); symbol->setSize( 15, 15 ); symbol->setColor( color ); @@ -221,7 +223,7 @@ void RiuFlowCharacteristicsPlot::addCurveWithLargeSymbol( QwtPlot* plot, RiuQwtPlotCurve* RiuFlowCharacteristicsPlot::createEmptyCurve( QwtPlot* plot, const QString& curveName, const QColor& curveColor ) { - RiuQwtPlotCurve* plotCurve = new RiuQwtPlotCurve( curveName ); + RiuQwtPlotCurve* plotCurve = new RiuQwtPlotCurve( nullptr, curveName ); plotCurve->setTitle( curveName ); plotCurve->setPen( QPen( curveColor ) ); @@ -240,7 +242,8 @@ void RiuFlowCharacteristicsPlot::addFlowCapStorageCapCurve( const QDateTime& RiuQwtPlotCurve* plotCurve = createEmptyCurve( m_flowCapVsStorageCapPlot, dateTime.toString(), m_dateToColorMap[dateTime] ); - plotCurve->setSamplesFromXValuesAndYValues( xVals, yVals, false ); + bool useLogarithmicScale = false; + plotCurve->setSamplesFromXValuesAndYValues( xVals, yVals, useLogarithmicScale ); m_flowCapVsStorageCapPlot->replot(); } @@ -254,7 +257,8 @@ void RiuFlowCharacteristicsPlot::addSweepEfficiencyCurve( const QDateTime& CVF_ASSERT( !m_dateToColorMap.empty() ); RiuQwtPlotCurve* plotCurve = createEmptyCurve( m_sweepEffPlot, dateTime.toString(), m_dateToColorMap[dateTime] ); - plotCurve->setSamplesFromXValuesAndYValues( xVals, yVals, false ); + bool useLogarithmicScale = false; + plotCurve->setSamplesFromXValuesAndYValues( xVals, yVals, useLogarithmicScale ); m_sweepEffPlot->replot(); } @@ -278,8 +282,8 @@ void RiuFlowCharacteristicsPlot::removeAllCurves() //-------------------------------------------------------------------------------------------------- void zoomAllInPlot( QwtPlot* plot ) { - plot->setAxisAutoScale( QwtPlot::xBottom, true ); - plot->setAxisAutoScale( QwtPlot::yLeft, true ); + plot->setAxisAutoScale( QwtAxis::XBottom, true ); + plot->setAxisAutoScale( QwtAxis::YLeft, true ); plot->replot(); } diff --git a/ApplicationLibCode/UserInterface/RiuFlowCharacteristicsPlot.h b/ApplicationLibCode/UserInterface/RiuFlowCharacteristicsPlot.h index f559e5ea5e..666031a845 100644 --- a/ApplicationLibCode/UserInterface/RiuFlowCharacteristicsPlot.h +++ b/ApplicationLibCode/UserInterface/RiuFlowCharacteristicsPlot.h @@ -22,8 +22,6 @@ #include "cafPdmPointer.h" -#include "qwt_plot.h" - #include #include @@ -33,6 +31,7 @@ class RiuResultQwtPlot; class RiuQwtPlotCurve; class QLabel; +class QwtPlot; namespace cvf { diff --git a/ApplicationLibCode/UserInterface/RiuGeoQuestNavigation.cpp b/ApplicationLibCode/UserInterface/RiuGeoQuestNavigation.cpp index eb44867d0c..58b7108aee 100644 --- a/ApplicationLibCode/UserInterface/RiuGeoQuestNavigation.cpp +++ b/ApplicationLibCode/UserInterface/RiuGeoQuestNavigation.cpp @@ -18,7 +18,10 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RiuGeoQuestNavigation.h" + +#include "caf.h" #include "cafViewer.h" + #include "cvfCamera.h" #include "cvfHitItemCollection.h" #include "cvfManipulatorTrackball.h" @@ -66,7 +69,7 @@ bool RiuGeoQuestNavigation::handleInputEvent( QInputEvent* inputEvent ) m_hasMovedMouseDuringNavigation = false; isEventHandled = true; } - else if ( me->button() == Qt::MidButton ) + else if ( me->button() == Qt::MiddleButton ) { if ( me->modifiers() == Qt::NoModifier ) { @@ -84,7 +87,7 @@ bool RiuGeoQuestNavigation::handleInputEvent( QInputEvent* inputEvent ) if ( m_isNavigating ) { QMouseEvent* me = static_cast( inputEvent ); - if ( me->button() == Qt::LeftButton || me->button() == Qt::MidButton ) + if ( me->button() == Qt::LeftButton || me->button() == Qt::MiddleButton ) { m_trackball->endNavigation(); @@ -132,18 +135,19 @@ bool RiuGeoQuestNavigation::handleInputEvent( QInputEvent* inputEvent ) { if ( inputEvent->modifiers() == Qt::NoModifier ) { - QWheelEvent* we = static_cast( inputEvent ); + QWheelEvent* we = static_cast( inputEvent ); + auto position = caf::position( we ); - updatePointOfInterestDuringZoomIfNecessary( we->x(), we->y() ); + updatePointOfInterestDuringZoomIfNecessary( position.x(), position.y() ); if ( m_isRotCenterInitialized ) { int translatedMousePosX, translatedMousePosY; - cvfEventPos( we->x(), we->y(), &translatedMousePosX, &translatedMousePosY ); + cvfEventPos( position.x(), position.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/ApplicationLibCode/UserInterface/RiuGridCrossQwtPlot.cpp b/ApplicationLibCode/UserInterface/RiuGridCrossQwtPlot.cpp index e935f7bb9c..a28ad6e771 100644 --- a/ApplicationLibCode/UserInterface/RiuGridCrossQwtPlot.cpp +++ b/ApplicationLibCode/UserInterface/RiuGridCrossQwtPlot.cpp @@ -30,11 +30,12 @@ #include "RiuContextMenuLauncher.h" #include "RiuGuiTheme.h" #include "RiuPlotAnnotationTool.h" +#include "RiuPlotCurve.h" #include "RiuQwtCurvePointTracker.h" +#include "RiuQwtPlotItem.h" #include "RiuQwtPlotTools.h" #include "RiuQwtPlotWheelZoomer.h" #include "RiuQwtPlotZoomer.h" -#include "RiuRimQwtPlotCurve.h" #include "RiuWidgetDragger.h" #include "cafCmdFeatureMenuBuilder.h" @@ -44,6 +45,7 @@ #include "qwt_legend.h" #include "qwt_legend_label.h" +#include "qwt_plot_curve.h" #include "qwt_plot_panner.h" #include "qwt_scale_draw.h" #include "qwt_scale_widget.h" @@ -62,29 +64,29 @@ RiuGridCrossQwtPlot::RiuGridCrossQwtPlot( RimGridCrossPlot* plot, QWidget* paren : RiuQwtPlotWidget( plot, parent ) { // LeftButton for the zooming - m_zoomerLeft = new RiuQwtPlotZoomer( canvas() ); + m_zoomerLeft = new RiuQwtPlotZoomer( qwtPlot()->canvas() ); m_zoomerLeft->setTrackerMode( QwtPicker::AlwaysOff ); m_zoomerLeft->initMousePattern( 1 ); // Attach a zoomer for the right axis - m_zoomerRight = new RiuQwtPlotZoomer( canvas() ); - m_zoomerRight->setAxis( xTop, yRight ); + m_zoomerRight = new RiuQwtPlotZoomer( qwtPlot()->canvas() ); + m_zoomerRight->setAxes( QwtAxis::XTop, QwtAxis::YRight ); m_zoomerRight->setTrackerMode( QwtPicker::AlwaysOff ); m_zoomerRight->initMousePattern( 1 ); // MidButton for the panning - QwtPlotPanner* panner = new QwtPlotPanner( canvas() ); - panner->setMouseButton( Qt::MidButton ); + QwtPlotPanner* panner = new QwtPlotPanner( qwtPlot()->canvas() ); + panner->setMouseButton( Qt::MiddleButton ); - auto wheelZoomer = new RiuQwtPlotWheelZoomer( this ); + auto wheelZoomer = new RiuQwtPlotWheelZoomer( qwtPlot() ); connect( wheelZoomer, SIGNAL( zoomUpdated() ), SLOT( onZoomedSlot() ) ); connect( m_zoomerLeft, SIGNAL( zoomed( const QRectF& ) ), SLOT( onZoomedSlot() ) ); connect( m_zoomerRight, SIGNAL( zoomed( const QRectF& ) ), SLOT( onZoomedSlot() ) ); connect( panner, SIGNAL( panned( int, int ) ), SLOT( onZoomedSlot() ) ); connect( this, - SIGNAL( plotItemSelected( QwtPlotItem*, bool, int ) ), - SLOT( onPlotItemSelected( QwtPlotItem*, bool, int ) ) ); + SIGNAL( plotItemSelected( std::shared_ptr, bool, int ) ), + SLOT( onPlotItemSelected( std::shared_ptr, bool, int ) ) ); m_annotationTool = std::unique_ptr( new RiuPlotAnnotationTool() ); m_selectedPointMarker = new QwtPlotMarker; @@ -99,11 +101,11 @@ RiuGridCrossQwtPlot::RiuGridCrossQwtPlot( RimGridCrossPlot* plot, QWidget* paren m_selectedPointMarker->setSpacing( 3 ); m_selectedPointMarker->setZ( 1000.0 ); // Make sure it ends up in front of highlighted curves. - RiuQwtPlotTools::setCommonPlotBehaviour( this ); - RiuQwtPlotTools::setDefaultAxes( this ); + RiuQwtPlotTools::setCommonPlotBehaviour( qwtPlot() ); + RiuQwtPlotTools::setDefaultAxes( qwtPlot() ); this->installEventFilter( this ); - this->canvas()->installEventFilter( this ); + this->qwtPlot()->canvas()->installEventFilter( this ); setInternalQwtLegendVisible( true ); @@ -139,7 +141,7 @@ void RiuGridCrossQwtPlot::updateAnnotationObjects( RimPlotAxisPropertiesInterfac for ( auto annotation : axisProperties->annotations() ) { - m_annotationTool->attachAnnotationLine( this, + m_annotationTool->attachAnnotationLine( qwtPlot(), annotation->color(), annotation->name(), annotation->value(), @@ -152,13 +154,13 @@ void RiuGridCrossQwtPlot::updateAnnotationObjects( RimPlotAxisPropertiesInterfac //-------------------------------------------------------------------------------------------------- void RiuGridCrossQwtPlot::setLegendFontSize( int fontSize ) { - if ( legend() ) + if ( qwtPlot()->legend() ) { - QFont font = legend()->font(); + QFont font = qwtPlot()->legend()->font(); font.setPixelSize( caf::FontTools::pointSizeToPixelSize( fontSize ) ); - legend()->setFont( font ); + qwtPlot()->legend()->setFont( font ); // Set font size for all existing labels - QList labels = legend()->findChildren(); + QList labels = qwtPlot()->legend()->findChildren(); for ( QwtLegendLabel* label : labels ) { label->setFont( font ); @@ -174,29 +176,32 @@ void RiuGridCrossQwtPlot::setInternalQwtLegendVisible( bool visible ) if ( visible ) { QwtLegend* legend = new QwtLegend( this ); - this->insertLegend( legend, BottomLegend ); + this->qwtPlot()->insertLegend( legend, QwtPlot::BottomLegend ); } else { - this->insertLegend( nullptr ); + this->qwtPlot()->insertLegend( nullptr ); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuGridCrossQwtPlot::onPlotItemSelected( QwtPlotItem* plotItem, bool toggle, int pointNumber ) +void RiuGridCrossQwtPlot::onPlotItemSelected( std::shared_ptr plotItem, bool toggle, int pointNumber ) { if ( pointNumber == -1 ) m_selectedPointMarker->detach(); else { - QwtPlotCurve* curve = dynamic_cast( plotItem ); + RiuQwtPlotItem* qwtPlotItem = dynamic_cast( plotItem.get() ); + if ( !qwtPlotItem ) return; + + QwtPlotCurve* curve = dynamic_cast( qwtPlotItem->qwtPlotItem() ); if ( curve ) { QPointF sample = curve->sample( pointNumber ); m_selectedPointMarker->setValue( sample ); - m_selectedPointMarker->setAxes( QwtPlot::xBottom, QwtPlot::yLeft ); - m_selectedPointMarker->attach( this ); + m_selectedPointMarker->setAxes( QwtAxis::XBottom, QwtAxis::YLeft ); + m_selectedPointMarker->attach( qwtPlot() ); QString curveName, xAxisName, yAxisName; if ( curveText( curve, &curveName, &xAxisName, &yAxisName ) ) { @@ -224,7 +229,7 @@ bool RiuGridCrossQwtPlot::curveText( const QwtPlotCurve* curve, QString* curveTi { CVF_ASSERT( curveTitle && xParamName && yParamName ); - auto riuCurve = dynamic_cast( curve ); + auto riuCurve = dynamic_cast( curve ); if ( riuCurve ) { auto crossPlotCurve = dynamic_cast( riuCurve->ownerRimCurve() ); diff --git a/ApplicationLibCode/UserInterface/RiuGridCrossQwtPlot.h b/ApplicationLibCode/UserInterface/RiuGridCrossQwtPlot.h index 5acd93ffb8..597a5304e7 100644 --- a/ApplicationLibCode/UserInterface/RiuGridCrossQwtPlot.h +++ b/ApplicationLibCode/UserInterface/RiuGridCrossQwtPlot.h @@ -17,7 +17,6 @@ ///////////////////////////////////////////////////////////////////////////////// #pragma once -#include "RiuInterfaceToViewWindow.h" #include "RiuPlotAnnotationTool.h" #include "RiuQwtPlotWidget.h" @@ -58,7 +57,7 @@ class RiuGridCrossQwtPlot : public RiuQwtPlotWidget void updateAnnotationObjects( RimPlotAxisPropertiesInterface* axisProperties ); - void setLegendFontSize( int fontSize ); + void setLegendFontSize( int fontSize ) override; void setInternalQwtLegendVisible( bool visible ); protected: @@ -68,7 +67,7 @@ class RiuGridCrossQwtPlot : public RiuQwtPlotWidget private slots: void onZoomedSlot(); - void onPlotItemSelected( QwtPlotItem* selectedItem, bool toggleItem, int sampleIndex ); + void onPlotItemSelected( std::shared_ptr selectedItem, bool toggleItem, int sampleIndex ); private: std::unique_ptr m_annotationTool; diff --git a/ApplicationLibCode/UserInterface/RiuGridStatisticsHistogramWidget.h b/ApplicationLibCode/UserInterface/RiuGridStatisticsHistogramWidget.h index 135d8adfd2..29d44de659 100644 --- a/ApplicationLibCode/UserInterface/RiuGridStatisticsHistogramWidget.h +++ b/ApplicationLibCode/UserInterface/RiuGridStatisticsHistogramWidget.h @@ -29,7 +29,7 @@ class QStringList; class RiuGridStatisticsHistogramWidget : public QWidget { public: - RiuGridStatisticsHistogramWidget( QWidget* parent = nullptr, Qt::WindowFlags f = nullptr ); + RiuGridStatisticsHistogramWidget( QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags() ); void setHistogramData( double min, double max, const std::vector& histogram ); void setPercentiles( double pmin, double pmax ); diff --git a/ApplicationLibCode/UserInterface/RiuMainWindow.cpp b/ApplicationLibCode/UserInterface/RiuMainWindow.cpp index 6fff52198d..a8b7d15f27 100644 --- a/ApplicationLibCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationLibCode/UserInterface/RiuMainWindow.cpp @@ -27,6 +27,8 @@ #include "RiaRegressionTest.h" #include "RiaRegressionTestRunner.h" +#include "RicGridCalculatorDialog.h" + #include "Rim2dIntersectionView.h" #include "Rim3dView.h" #include "RimCellEdgeColors.h" @@ -48,7 +50,6 @@ #include "RimViewWindow.h" #include "RiuDockWidgetTools.h" -#include "RiuDragDrop.h" #include "RiuMdiSubWindow.h" #include "RiuMessagePanel.h" #include "RiuMohrsCirclePlot.h" @@ -70,10 +71,10 @@ #include "cafPdmUiPropertyView.h" #include "cafPdmUiPropertyViewDialog.h" #include "cafPdmUiTreeView.h" -#include "cafQTreeViewStateSerializer.h" #include "cafSelectionManager.h" #include "cafUtils.h" +#include "ApplicationCommands/RicLaunchRegressionTestsFeature.h" #include "ExportCommands/RicSnapshotAllViewsToFileFeature.h" #include "MeasurementCommands/RicToggleMeasurementModeFeature.h" #include "SummaryPlotCommands/RicEditSummaryPlotFeature.h" @@ -121,7 +122,9 @@ RiuMainWindow::RiuMainWindow() , m_windowMenu( nullptr ) , m_holoLensToolBar( nullptr ) { - m_mdiArea = new RiuMdiArea; + setAttribute( Qt::WA_DeleteOnClose ); + + m_mdiArea = new RiuMdiArea( this ); connect( m_mdiArea, SIGNAL( subWindowActivated( QMdiSubWindow* ) ), SLOT( slotSubWindowActivated( QMdiSubWindow* ) ) ); setCentralWidget( m_mdiArea ); @@ -132,8 +135,6 @@ RiuMainWindow::RiuMainWindow() createToolBars(); createDockPanels(); - m_dragDropInterface = std::unique_ptr( new RiuDragDrop() ); - if ( m_undoView ) { m_undoView->setStack( caf::CmdExecCommandManager::instance()->undoStack() ); @@ -173,6 +174,11 @@ RiuMainWindow::RiuMainWindow() RiuMainWindow::~RiuMainWindow() { setPdmRoot( nullptr ); + + if ( m_pdmUiPropertyView ) + { + m_pdmUiPropertyView->showProperties( nullptr ); + } } //-------------------------------------------------------------------------------------------------- @@ -187,6 +193,14 @@ RiuMainWindow* RiuMainWindow::instance() return nullptr; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMainWindow::closeIfOpen() +{ + if ( instance() != nullptr ) instance()->close(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -565,6 +579,8 @@ void RiuMainWindow::createMenus() helpMenu->addSeparator(); helpMenu->addAction( cmdFeatureMgr->action( "RicHelpOpenUsersGuideFeature" ) ); helpMenu->addAction( cmdFeatureMgr->action( "RicSearchHelpFeature" ) ); + helpMenu->addAction( cmdFeatureMgr->action( "RicSearchIssuesHelpFeature" ) ); + helpMenu->addAction( cmdFeatureMgr->action( "RicCreateNewIssueHelpFeature" ) ); connect( helpMenu, SIGNAL( aboutToShow() ), SLOT( slotRefreshHelpActions() ) ); } @@ -619,6 +635,7 @@ void RiuMainWindow::createToolBars() toolbar->addAction( cmdFeatureMgr->action( "RicShowPlotWindowFeature" ) ); toolbar->addAction( cmdFeatureMgr->action( "RicLinkVisibleViewsFeature" ) ); toolbar->addAction( cmdFeatureMgr->action( "RicTileWindowsFeature" ) ); + toolbar->addAction( cmdFeatureMgr->action( "RicShowGridCalculatorFeature" ) ); } { @@ -692,6 +709,8 @@ void RiuMainWindow::createToolBars() toolbar->setObjectName( toolbar->windowTitle() ); toolbar->addAction( cmdFeatureMgr->action( "RicLaunchUnitTestsFeature" ) ); toolbar->addAction( cmdFeatureMgr->action( "RicLaunchRegressionTestsFeature" ) ); + toolbar->addAction( cmdFeatureMgr->action( "RicLaunchRegressionTestDialogFeature" ) ); + toolbar->addAction( cmdFeatureMgr->action( "RicShowClassNamesFeature" ) ); toolbar->addAction( cmdFeatureMgr->action( "RicRunCommandFileFeature" ) ); toolbar->addAction( cmdFeatureMgr->action( "RicExecuteLastUsedScriptFeature" ) ); toolbar->addAction( cmdFeatureMgr->action( "RicExportCompletionsForVisibleWellPathsFeature" ) ); @@ -710,38 +729,64 @@ void RiuMainWindow::createToolBars() //-------------------------------------------------------------------------------------------------- void RiuMainWindow::createDockPanels() { + const int nTreeViews = 3; + const std::vector treeViewTitles = { "Project Tree", "Data Sources", "Scripts" }; + const std::vector treeViewConfigs = { "MainWindow.ProjectTree", "MainWindow.DataSources", "MainWindow.Scripts" }; + const std::vector treeViewDockNames = { RiuDockWidgetTools::mainWindowProjectTreeName(), + RiuDockWidgetTools::mainWindowDataSourceTreeName(), + RiuDockWidgetTools::mainWindowScriptsTreeName() }; + + createTreeViews( nTreeViews ); + + QDockWidget* dockOntopOfWidget = nullptr; + + for ( int i = 0; i < nTreeViews; i++ ) { - QDockWidget* dockWidget = new QDockWidget( "Project Tree", this ); - dockWidget->setObjectName( RiuDockWidgetTools::projectTreeName() ); + QDockWidget* dockWidget = new QDockWidget( treeViewTitles[i], this ); + dockWidget->setObjectName( treeViewDockNames[i] ); dockWidget->setAllowedAreas( Qt::AllDockWidgetAreas ); - m_projectTreeView = new caf::PdmUiTreeView( this ); - m_projectTreeView->enableSelectionManagerUpdating( true ); + caf::PdmUiTreeView* projectTree = projectTreeView( i ); + projectTree->enableSelectionManagerUpdating( true ); - m_projectTreeView->enableAppendOfClassNameToUiItemText( RiaPreferencesSystem::current()->appendClassNameToUiText() ); + projectTree->enableAppendOfClassNameToUiItemText( RiaPreferencesSystem::current()->appendClassNameToUiText() ); - dockWidget->setWidget( m_projectTreeView ); + dockWidget->setWidget( projectTree ); - m_projectTreeView->treeView()->setHeaderHidden( true ); - m_projectTreeView->treeView()->setSelectionMode( QAbstractItemView::ExtendedSelection ); + projectTree->treeView()->setHeaderHidden( true ); + projectTree->treeView()->setSelectionMode( QAbstractItemView::ExtendedSelection ); // Drag and drop configuration - m_projectTreeView->treeView()->setDragEnabled( true ); - m_projectTreeView->treeView()->viewport()->setAcceptDrops( true ); - m_projectTreeView->treeView()->setDropIndicatorShown( true ); - m_projectTreeView->treeView()->setDragDropMode( QAbstractItemView::DragDrop ); + projectTree->treeView()->setDragEnabled( true ); + projectTree->treeView()->viewport()->setAcceptDrops( true ); + projectTree->treeView()->setDropIndicatorShown( true ); + projectTree->treeView()->setDragDropMode( QAbstractItemView::DragDrop ); // Install event filter used to handle key press events - RiuTreeViewEventFilter* treeViewEventFilter = new RiuTreeViewEventFilter( this ); - m_projectTreeView->treeView()->installEventFilter( treeViewEventFilter ); + RiuTreeViewEventFilter* treeViewEventFilter = new RiuTreeViewEventFilter( this, projectTree ); + projectTree->treeView()->installEventFilter( treeViewEventFilter ); addDockWidget( Qt::LeftDockWidgetArea, dockWidget ); - connect( m_projectTreeView, SIGNAL( selectionChanged() ), this, SLOT( selectedObjectsChanged() ) ); - m_projectTreeView->treeView()->setContextMenuPolicy( Qt::CustomContextMenu ); - connect( m_projectTreeView->treeView(), + if ( dockOntopOfWidget ) + { + tabifyDockWidget( dockOntopOfWidget, dockWidget ); + } + else + { + dockOntopOfWidget = dockWidget; + } + + connect( dockWidget, SIGNAL( visibilityChanged( bool ) ), projectTree, SLOT( treeVisibilityChanged( bool ) ) ); + + connect( projectTree, SIGNAL( selectionChanged() ), this, SLOT( selectedObjectsChanged() ) ); + + projectTree->treeView()->setContextMenuPolicy( Qt::CustomContextMenu ); + connect( projectTree->treeView(), SIGNAL( customContextMenuRequested( const QPoint& ) ), SLOT( customMenuRequested( const QPoint& ) ) ); + + projectTree->setUiConfigurationName( treeViewConfigs[i] ); } QDockWidget* resultPlotDock = nullptr; @@ -1173,9 +1218,10 @@ void RiuMainWindow::setPdmRoot( caf::PdmObject* pdmRoot ) { m_pdmRoot = pdmRoot; - m_projectTreeView->setPdmItem( pdmRoot ); - // For debug only : m_projectTreeView->treeView()->expandAll(); - m_projectTreeView->setDragDropInterface( m_dragDropInterface.get() ); + for ( auto tv : projectTreeViews() ) + { + tv->setPdmItem( pdmRoot ); + } for ( auto& additionalProjectView : m_additionalProjectViews ) { @@ -1188,8 +1234,6 @@ void RiuMainWindow::setPdmRoot( caf::PdmObject* pdmRoot ) projPropView->setPdmItem( pdmRoot ); } } - - caf::SelectionManager::instance()->setPdmRootObject( pdmRoot ); } //-------------------------------------------------------------------------------------------------- @@ -1301,15 +1345,20 @@ void RiuMainWindow::selectViewInProjectTreePreservingSubItemSelection( const Rim if ( is3dViewCurrentlySelected && ( previousActiveReservoirView != activatedView ) ) { - QModelIndex newViewModelIndex = m_projectTreeView->findModelIndex( activatedView ); + auto tv = getTreeViewWithItem( activatedView ); + if ( !tv ) return; + + QModelIndex newViewModelIndex = tv->findModelIndex( activatedView ); + if ( !newViewModelIndex.isValid() ) return; + QModelIndex newSelectionIndex = newViewModelIndex; if ( previousActiveReservoirView && is3dViewCurrentlySelected ) { // Try to select the same entry in the new View, as was selected in the previous - QModelIndex previousViewModelIndex = m_projectTreeView->findModelIndex( previousActiveReservoirView ); - QModelIndex currentSelectionIndex = m_projectTreeView->treeView()->selectionModel()->currentIndex(); + QModelIndex previousViewModelIndex = tv->findModelIndex( previousActiveReservoirView ); + QModelIndex currentSelectionIndex = tv->treeView()->selectionModel()->currentIndex(); if ( currentSelectionIndex != newViewModelIndex && currentSelectionIndex.isValid() ) { @@ -1332,8 +1381,7 @@ void RiuMainWindow::selectViewInProjectTreePreservingSubItemSelection( const Rim QModelIndex tmp = route[i]; if ( newSelectionIndex.isValid() ) { - newSelectionIndex = - m_projectTreeView->treeView()->model()->index( tmp.row(), tmp.column(), newSelectionIndex ); + newSelectionIndex = tv->treeView()->model()->index( tmp.row(), tmp.column(), newSelectionIndex ); } } @@ -1345,10 +1393,10 @@ void RiuMainWindow::selectViewInProjectTreePreservingSubItemSelection( const Rim } } - m_projectTreeView->treeView()->setCurrentIndex( newSelectionIndex ); + tv->treeView()->setCurrentIndex( newSelectionIndex ); if ( newSelectionIndex != newViewModelIndex ) { - m_projectTreeView->treeView()->setExpanded( newViewModelIndex, true ); + tv->treeView()->setExpanded( newViewModelIndex, true ); } } } @@ -1440,8 +1488,11 @@ void RiuMainWindow::slotBuildWindowActions() //-------------------------------------------------------------------------------------------------- void RiuMainWindow::selectedObjectsChanged() { + caf::PdmUiTreeView* projectTree = dynamic_cast( sender() ); + if ( !projectTree ) return; + std::vector uiItems; - m_projectTreeView->selectedUiItems( uiItems ); + projectTree->selectedUiItems( uiItems ); caf::PdmObjectHandle* firstSelectedObject = nullptr; if ( !uiItems.empty() ) @@ -1499,7 +1550,7 @@ void RiuMainWindow::selectedObjectsChanged() // The only way to get to this code is by selection change initiated from the project tree view // As we are activating an MDI-window, the focus is given to this MDI-window // Set focus back to the tree view to be able to continue keyboard tree view navigation - m_projectTreeView->treeView()->setFocus(); + projectTree->treeView()->setFocus(); } } } @@ -1687,24 +1738,8 @@ void RiuMainWindow::slotToggleLightingAction( bool enable ) //-------------------------------------------------------------------------------------------------- void RiuMainWindow::restoreTreeViewState() { - if ( m_projectTreeView ) - { - QString stateString = RimProject::current()->mainWindowTreeViewState; - if ( !stateString.isEmpty() ) - { - m_projectTreeView->treeView()->collapseAll(); - caf::QTreeViewStateSerializer::applyTreeViewStateFromString( m_projectTreeView->treeView(), stateString ); - } - - QString currentIndexString = RimProject::current()->mainWindowCurrentModelIndexPath; - if ( !currentIndexString.isEmpty() ) - { - QModelIndex mi = - caf::QTreeViewStateSerializer::getModelIndexFromString( m_projectTreeView->treeView()->model(), - currentIndexString ); - m_projectTreeView->treeView()->setCurrentIndex( mi ); - } - } + restoreTreeViewStates( RimProject::current()->mainWindowTreeViewStates(), + RimProject::current()->mainWindowCurrentModelIndexPaths() ); } //-------------------------------------------------------------------------------------------------- @@ -1878,8 +1913,11 @@ void RiuMainWindow::slotCreateCommandObject() RiaApplication* app = RiaApplication::instance(); if ( !app->project() ) return; + caf::PdmUiTreeView* projectTree = dynamic_cast( sender() ); + if ( !projectTree ) return; + std::vector selectedUiItems; - m_projectTreeView->selectedUiItems( selectedUiItems ); + projectTree->selectedUiItems( selectedUiItems ); caf::PdmObjectGroup selectedObjects; for ( auto* selectedUiItem : selectedUiItems ) @@ -1910,19 +1948,7 @@ void RiuMainWindow::slotCreateCommandObject() //-------------------------------------------------------------------------------------------------- void RiuMainWindow::slotShowRegressionTestDialog() { - RiaRegressionTest regTestConfig; - regTestConfig.readSettingsFromApplicationStore(); - - caf::PdmUiPropertyViewDialog regressionTestDialog( this, ®TestConfig, "Regression Test", "" ); - regressionTestDialog.resize( QSize( 600, 350 ) ); - - if ( regressionTestDialog.exec() == QDialog::Accepted ) - { - // Write preferences using QSettings and apply them to the application - regTestConfig.writeSettingsToApplicationStore(); - - RiaRegressionTestRunner::instance()->executeRegressionTests(); - } + RicLaunchRegressionTestDialogFeature::showRegressionTestDialog(); } //-------------------------------------------------------------------------------------------------- @@ -2124,3 +2150,16 @@ bool RiuMainWindow::isAnyMdiSubWindowVisible() { return !m_mdiArea->subWindowList().empty(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicGridCalculatorDialog* RiuMainWindow::gridCalculatorDialog( bool createIfNotPresent ) +{ + if ( !m_gridCalculatorDialog && createIfNotPresent ) + { + m_gridCalculatorDialog = std::make_unique( this ); + } + + return m_gridCalculatorDialog.get(); +} diff --git a/ApplicationLibCode/UserInterface/RiuMainWindow.h b/ApplicationLibCode/UserInterface/RiuMainWindow.h index ca3ec7a1e7..fcf01b2b40 100644 --- a/ApplicationLibCode/UserInterface/RiuMainWindow.h +++ b/ApplicationLibCode/UserInterface/RiuMainWindow.h @@ -24,7 +24,6 @@ #include "RiuMdiArea.h" #include "cafPdmObjectHandle.h" -#include "cafPdmUiDragDropInterface.h" #include #include @@ -52,6 +51,8 @@ class RiuRelativePermeabilityPlotPanel; class RiuPvtPlotPanel; class RiuMohrsCirclePlot; +class RicGridCalculatorDialog; + struct RimMdiWindowGeometry; namespace caf @@ -82,6 +83,7 @@ class RiuMainWindow : public RiuMainWindowBase ~RiuMainWindow() override; static RiuMainWindow* instance(); + static void closeIfOpen(); QString mainWindowName() override; @@ -127,6 +129,8 @@ class RiuMainWindow : public RiuMainWindowBase void setDefaultToolbarVisibility(); void applyFontSizesToDockedPlots(); + RicGridCalculatorDialog* gridCalculatorDialog( bool createIfNotPresent ); + protected: void closeEvent( QCloseEvent* event ) override; @@ -172,10 +176,11 @@ class RiuMainWindow : public RiuMainWindowBase RiuProcessMonitor* m_processMonitor; QPointer m_messagePanel; - RiuResultQwtPlot* m_resultQwtPlot; - RiuMohrsCirclePlot* m_mohrsCirclePlot; - RiuRelativePermeabilityPlotPanel* m_relPermPlotPanel; - RiuPvtPlotPanel* m_pvtPlotPanel; + RiuResultQwtPlot* m_resultQwtPlot; + RiuMohrsCirclePlot* m_mohrsCirclePlot; + RiuRelativePermeabilityPlotPanel* m_relPermPlotPanel; + RiuPvtPlotPanel* m_pvtPlotPanel; + std::unique_ptr m_gridCalculatorDialog; QMenu* m_windowMenu; QLabel* m_memoryCriticalWarning; @@ -247,8 +252,6 @@ private slots: void setPdmRoot( caf::PdmObject* pdmRoot ); private: - std::unique_ptr m_dragDropInterface; - caf::PdmObject* m_pdmRoot; caf::PdmUiPropertyView* m_pdmUiPropertyView; diff --git a/ApplicationLibCode/UserInterface/RiuMainWindowBase.cpp b/ApplicationLibCode/UserInterface/RiuMainWindowBase.cpp index 0b768e1fcd..46dc29bb68 100644 --- a/ApplicationLibCode/UserInterface/RiuMainWindowBase.cpp +++ b/ApplicationLibCode/UserInterface/RiuMainWindowBase.cpp @@ -19,25 +19,28 @@ #include "RiuMainWindowBase.h" #include "RiaApplication.h" +#include "RiaDefines.h" #include "RiaPreferences.h" #include "RiaVersionInfo.h" #include "RiuDockWidgetTools.h" +#include "RiuDragDrop.h" #include "RiuMdiSubWindow.h" #include "RimProject.h" #include "RimViewWindow.h" +#include "cafCmdFeatureManager.h" #include "cafPdmObject.h" #include "cafPdmUiTreeView.h" - -#include "cafCmdFeatureManager.h" +#include "cafQTreeViewStateSerializer.h" #include #include #include #include #include +#include #include #include @@ -45,8 +48,7 @@ /// //-------------------------------------------------------------------------------------------------- RiuMainWindowBase::RiuMainWindowBase() - : m_projectTreeView( nullptr ) - , m_allowActiveViewChangeFromSelection( true ) + : m_allowActiveViewChangeFromSelection( true ) , m_showFirstVisibleWindowMaximized( true ) , m_blockSubWindowActivation( false ) , m_blockSubWindowProjectTreeSelection( false ) @@ -71,6 +73,19 @@ RiuMainWindowBase::RiuMainWindowBase() connect( m_redoAction, SIGNAL( triggered() ), SLOT( slotRedo() ) ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuMainWindowBase::~RiuMainWindowBase() +{ + for ( auto v : m_projectTreeViews ) + { + delete v; + } + + m_projectTreeViews.clear(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -238,7 +253,18 @@ QString RiuMainWindowBase::registryFolderName() void RiuMainWindowBase::selectAsCurrentItem( const caf::PdmObject* object, bool allowActiveViewChange ) { m_allowActiveViewChangeFromSelection = allowActiveViewChange; - m_projectTreeView->selectAsCurrentItem( object ); + + auto tv = getTreeViewWithItem( object ); + if ( tv ) + { + tv->selectAsCurrentItem( object ); + QDockWidget* dw = dynamic_cast( tv->parentWidget() ); + if ( dw ) + { + dw->show(); + } + } + m_allowActiveViewChangeFromSelection = true; } @@ -247,11 +273,15 @@ void RiuMainWindowBase::selectAsCurrentItem( const caf::PdmObject* object, bool //-------------------------------------------------------------------------------------------------- void RiuMainWindowBase::toggleItemInSelection( const caf::PdmObject* object, bool allowActiveViewChange ) { + auto tv = getTreeViewWithItem( object ); + if ( !tv ) return; + m_allowActiveViewChangeFromSelection = allowActiveViewChange; std::vector currentSelection; - m_projectTreeView->selectedUiItems( currentSelection ); + tv->selectedUiItems( currentSelection ); std::vector updatedSelection; - bool alreadySelected = false; + + bool alreadySelected = false; for ( caf::PdmUiItem* uiItem : currentSelection ) { if ( object == uiItem ) @@ -267,7 +297,7 @@ void RiuMainWindowBase::toggleItemInSelection( const caf::PdmObject* object, boo { updatedSelection.push_back( object ); } - m_projectTreeView->selectItems( updatedSelection ); + tv->selectItems( updatedSelection ); m_allowActiveViewChangeFromSelection = true; } @@ -316,24 +346,27 @@ bool RiuMainWindowBase::isBlockingViewSelectionOnSubWindowActivated() const //-------------------------------------------------------------------------------------------------- void RiuMainWindowBase::removeViewerFromMdiArea( QMdiArea* mdiArea, QWidget* viewer ) { - bool wasMaximized = viewer && viewer->isMaximized(); + bool removedSubWindowWasActive = false; - QMdiSubWindow* subWindowBeingClosed = findMdiSubWindow( viewer ); - bool removedSubWindowWasActive = false; - if ( subWindowBeingClosed->isActiveWindow() ) + QMdiSubWindow* subWindowBeingClosed = findMdiSubWindow( viewer ); + bool wasMaximized = subWindowBeingClosed->isMaximized(); + if ( subWindowBeingClosed ) { - // If we are removing the active window, we will need a new active window - // Start by making the window inactive so Qt doesn't pick the active window itself - mdiArea->setActiveSubWindow( nullptr ); - removedSubWindowWasActive = true; - } - mdiArea->removeSubWindow( subWindowBeingClosed ); + if ( subWindowBeingClosed->isActiveWindow() ) + { + // If we are removing the active window, we will need a new active window + // Start by making the window inactive so Qt doesn't pick the active window itself + mdiArea->setActiveSubWindow( nullptr ); + removedSubWindowWasActive = true; + } + mdiArea->removeSubWindow( subWindowBeingClosed ); - // These two lines had to be introduced after themes was used - // Probably related to polish/unpolish of widgets in an MDI setting - // https://github.com/OPM/ResInsight/issues/6676 - subWindowBeingClosed->hide(); - subWindowBeingClosed->deleteLater(); + // These two lines had to be introduced after themes was used + // Probably related to polish/unpolish of widgets in an MDI setting + // https://github.com/OPM/ResInsight/issues/6676 + subWindowBeingClosed->hide(); + subWindowBeingClosed->deleteLater(); + } QList subWindowList = mdiArea->subWindowList( QMdiArea::ActivationHistoryOrder ); if ( !subWindowList.empty() ) @@ -360,7 +393,8 @@ void RiuMainWindowBase::removeViewerFromMdiArea( QMdiArea* mdiArea, QWidget* vie //-------------------------------------------------------------------------------------------------- void RiuMainWindowBase::setExpanded( const caf::PdmUiItem* uiItem, bool expanded ) { - m_projectTreeView->setExpanded( uiItem, expanded ); + caf::PdmUiTreeView* tv = getTreeViewWithItem( uiItem ); + if ( tv ) tv->setExpanded( uiItem, expanded ); } //-------------------------------------------------------------------------------------------------- @@ -466,3 +500,88 @@ void RiuMainWindowBase::slotRefreshUndoRedoActions() m_redoAction->setDisabled( !m_undoView->stack()->canRedo() ); m_undoAction->setDisabled( !m_undoView->stack()->canUndo() ); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMainWindowBase::createTreeViews( int numberOfTrees ) +{ + CVF_ASSERT( m_projectTreeViews.empty() ); + + for ( int i = 0; i < numberOfTrees; i++ ) + { + auto tv = new caf::PdmUiTreeView(); + caf::PdmUiDragDropInterface* dragDropInterface = new RiuDragDrop( tv ); + tv->setDragDropInterface( dragDropInterface ); + m_projectTreeViews.push_back( tv ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmUiTreeView* RiuMainWindowBase::projectTreeView( int treeId ) +{ + CVF_ASSERT( treeId >= 0 ); + CVF_ASSERT( treeId < (int)m_projectTreeViews.size() ); + + return m_projectTreeViews[treeId]; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmUiTreeView* RiuMainWindowBase::getTreeViewWithItem( const caf::PdmUiItem* uiItem ) +{ + for ( auto tv : m_projectTreeViews ) + { + QModelIndex qmi = tv->findModelIndex( uiItem ); + if ( qmi.isValid() ) + { + return tv; + } + } + return nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RiuMainWindowBase::projectTreeViews() +{ + return m_projectTreeViews; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMainWindowBase::restoreTreeViewStates( QString treeStateString, QString treeIndexeString ) +{ + QStringList treeStates = treeStateString.split( RiaDefines::stringListSeparator() ); + QStringList treeIndexes = treeIndexeString.split( RiaDefines::stringListSeparator() ); + + const int nTreeViews = (int)projectTreeViews().size(); + + if ( treeStates.size() < nTreeViews ) return; + if ( treeIndexes.size() < nTreeViews ) return; + + for ( int treeId = 0; treeId < nTreeViews; treeId++ ) + { + auto tv = projectTreeView( treeId ); + + QString stateString = treeStates[treeId]; + if ( !stateString.isEmpty() ) + { + tv->treeView()->collapseAll(); + caf::QTreeViewStateSerializer::applyTreeViewStateFromString( tv->treeView(), stateString ); + } + + QString currentIndexString = treeIndexes[treeId]; + if ( !currentIndexString.isEmpty() ) + { + QModelIndex mi = + caf::QTreeViewStateSerializer::getModelIndexFromString( tv->treeView()->model(), currentIndexString ); + tv->treeView()->setCurrentIndex( mi ); + } + } +} diff --git a/ApplicationLibCode/UserInterface/RiuMainWindowBase.h b/ApplicationLibCode/UserInterface/RiuMainWindowBase.h index 81f255a93c..8f10db2864 100644 --- a/ApplicationLibCode/UserInterface/RiuMainWindowBase.h +++ b/ApplicationLibCode/UserInterface/RiuMainWindowBase.h @@ -20,6 +20,11 @@ #include +#include "cafPdmUiDragDropInterface.h" + +#include +#include + class QMdiArea; struct RimMdiWindowGeometry; @@ -42,7 +47,8 @@ class RiuMainWindowBase : public QMainWindow Q_OBJECT public: - RiuMainWindowBase(); + RiuMainWindowBase(); + ~RiuMainWindowBase() override; virtual QString mainWindowName() = 0; @@ -65,8 +71,11 @@ class RiuMainWindowBase : public QMainWindow void hideAllDockWidgets(); - caf::PdmUiTreeView* projectTreeView() { return m_projectTreeView; } - void setExpanded( const caf::PdmUiItem* uiItem, bool expanded = true ); + std::vector projectTreeViews(); + caf::PdmUiTreeView* projectTreeView( int treeId ); + caf::PdmUiTreeView* getTreeViewWithItem( const caf::PdmUiItem* item ); + + void setExpanded( const caf::PdmUiItem* uiItem, bool expanded = true ); void selectAsCurrentItem( const caf::PdmObject* object, bool allowActiveViewChange = true ); void toggleItemInSelection( const caf::PdmObject* object, bool allowActiveViewChange = true ); @@ -85,12 +94,15 @@ class RiuMainWindowBase : public QMainWindow bool isBlockingViewSelectionOnSubWindowActivated() const; protected: + void createTreeViews( int numberOfTrees ); void removeViewerFromMdiArea( QMdiArea* mdiArea, QWidget* viewer ); void initializeSubWindow( QMdiArea* mdiArea, QMdiSubWindow* mdiSubWindow, const QPoint& subWindowPos, const QSize& subWindowSize ); + void restoreTreeViewStates( QString treeStateString, QString treeIndexString ); + protected slots: void slotDockWidgetToggleViewActionTriggered(); void slotRefreshHelpActions(); @@ -100,8 +112,7 @@ protected slots: void slotRefreshUndoRedoActions(); protected: - caf::PdmUiTreeView* m_projectTreeView; - bool m_allowActiveViewChangeFromSelection; // To be used in selectedObjectsChanged() to control + bool m_allowActiveViewChangeFromSelection; // To be used in selectedObjectsChanged() to control // whether to select the corresponding active view or not QAction* m_undoAction; @@ -112,6 +123,9 @@ protected slots: QString registryFolderName(); private: + std::vector m_projectTreeViews; + std::vector> m_dragDropInterfaces; + bool m_showFirstVisibleWindowMaximized; bool m_blockSubWindowActivation; bool m_blockSubWindowProjectTreeSelection; diff --git a/ApplicationLibCode/UserInterface/RiuMainWindowTools.cpp b/ApplicationLibCode/UserInterface/RiuMainWindowTools.cpp index b38549ebbb..9bce9f176d 100644 --- a/ApplicationLibCode/UserInterface/RiuMainWindowTools.cpp +++ b/ApplicationLibCode/UserInterface/RiuMainWindowTools.cpp @@ -37,6 +37,7 @@ #include #include +#include //-------------------------------------------------------------------------------------------------- /// @@ -47,49 +48,38 @@ void RiuMainWindowTools::collapseSiblings( const caf::PdmUiItem* sourceUiItem ) if ( !RiaGuiApplication::isRunning() ) return; - { - caf::PdmUiTreeView* sourceTreeView = nullptr; - caf::PdmUiTreeOrdering* sourceTreeOrderingItem = nullptr; + caf::PdmUiTreeView* sourceTreeView = nullptr; + if ( RiuMainWindow::instance() ) + { + sourceTreeView = RiuMainWindow::instance()->getTreeViewWithItem( sourceUiItem ); + } + if ( !sourceTreeView ) + { + RiuPlotMainWindow* mpw = RiaGuiApplication::instance()->mainPlotWindow(); + if ( mpw ) { - QModelIndex modIndex; + sourceTreeView = mpw->getTreeViewWithItem( sourceUiItem ); + } + } - if ( RiuMainWindow::instance() ) - { - modIndex = RiuMainWindow::instance()->projectTreeView()->findModelIndex( sourceUiItem ); - } + if ( !sourceTreeView ) return; - if ( modIndex.isValid() ) - { - sourceTreeView = RiuMainWindow::instance()->projectTreeView(); - } - else - { - RiuPlotMainWindow* mpw = RiaGuiApplication::instance()->mainPlotWindow(); - if ( mpw ) - { - modIndex = mpw->projectTreeView()->findModelIndex( sourceUiItem ); - if ( modIndex.isValid() ) - { - sourceTreeView = mpw->projectTreeView(); - } - } - } + caf::PdmUiTreeOrdering* sourceTreeOrderingItem = nullptr; + QModelIndex modIndex = sourceTreeView->findModelIndex( sourceUiItem ); + if ( !modIndex.isValid() ) return; - if ( !modIndex.isValid() ) return; + sourceTreeOrderingItem = sourceTreeView->uiTreeOrderingFromModelIndex( modIndex ); + if ( sourceTreeOrderingItem == nullptr ) return; - sourceTreeOrderingItem = static_cast( modIndex.internalPointer() ); - } - - if ( sourceTreeView && sourceTreeOrderingItem && sourceTreeOrderingItem->parent() ) + if ( sourceTreeOrderingItem && sourceTreeOrderingItem->parent() ) + { + for ( int i = 0; i < sourceTreeOrderingItem->parent()->childCount(); i++ ) { - for ( int i = 0; i < sourceTreeOrderingItem->parent()->childCount(); i++ ) + auto siblingTreeOrderingItem = sourceTreeOrderingItem->parent()->child( i ); + if ( siblingTreeOrderingItem != sourceTreeOrderingItem ) { - auto siblingTreeOrderingItem = sourceTreeOrderingItem->parent()->child( i ); - if ( siblingTreeOrderingItem != sourceTreeOrderingItem ) - { - sourceTreeView->setExpanded( siblingTreeOrderingItem->activeItem(), false ); - } + sourceTreeView->setExpanded( siblingTreeOrderingItem->activeItem(), false ); } } } diff --git a/ApplicationLibCode/UserInterface/RiuMdiArea.cpp b/ApplicationLibCode/UserInterface/RiuMdiArea.cpp index 9790558dbe..b2895b5eb0 100644 --- a/ApplicationLibCode/UserInterface/RiuMdiArea.cpp +++ b/ApplicationLibCode/UserInterface/RiuMdiArea.cpp @@ -20,6 +20,22 @@ #include "RiuMainWindow.h" #include "RiuMdiSubWindow.h" #include "RiuPlotMainWindow.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuMdiArea::RiuMdiArea( QWidget* parent /*= nullptr*/ ) + : QMdiArea( parent ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuMdiArea::~RiuMdiArea() +{ +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/UserInterface/RiuMdiArea.h b/ApplicationLibCode/UserInterface/RiuMdiArea.h index 9a187c3169..ff78ff4bc9 100644 --- a/ApplicationLibCode/UserInterface/RiuMdiArea.h +++ b/ApplicationLibCode/UserInterface/RiuMdiArea.h @@ -29,6 +29,9 @@ class RiuMdiArea : public QMdiArea Q_OBJECT public: + RiuMdiArea( QWidget* parent = nullptr ); + ~RiuMdiArea() override; + std::list subWindowListSortedByPosition(); protected: diff --git a/ApplicationLibCode/UserInterface/RiuMdiSubWindow.cpp b/ApplicationLibCode/UserInterface/RiuMdiSubWindow.cpp index 058a480b4b..b7c7d9a616 100644 --- a/ApplicationLibCode/UserInterface/RiuMdiSubWindow.cpp +++ b/ApplicationLibCode/UserInterface/RiuMdiSubWindow.cpp @@ -48,7 +48,6 @@ RiuMdiSubWindow::RiuMdiSubWindow( QWidget* parent /*= 0*/, Qt::WindowFlags flags //-------------------------------------------------------------------------------------------------- RiuMdiSubWindow::~RiuMdiSubWindow() { - RiuMainWindow::instance()->slotRefreshViewActions(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/UserInterface/RiuMohrsCirclePlot.cpp b/ApplicationLibCode/UserInterface/RiuMohrsCirclePlot.cpp index 2ea6ee8fa6..478fe7d705 100644 --- a/ApplicationLibCode/UserInterface/RiuMohrsCirclePlot.cpp +++ b/ApplicationLibCode/UserInterface/RiuMohrsCirclePlot.cpp @@ -20,9 +20,6 @@ #include "RiaColorTables.h" -#include "Riu3dSelectionManager.h" -#include "RiuQwtPlotTools.h" - #include "RigFemPart.h" #include "RigFemPartCollection.h" #include "RigFemPartGrid.h" @@ -37,12 +34,15 @@ #include "RimGeoMechResultDefinition.h" #include "RimGeoMechView.h" +#include "Riu3dSelectionManager.h" +#include "RiuQwtPlotTools.h" + #include "cvfAssert.h" #include +#include #include #include -#include #include "qwt_legend.h" #include "qwt_plot_curve.h" @@ -70,13 +70,11 @@ RiuMohrsCirclePlot::RiuMohrsCirclePlot( QWidget* parent ) { RiuQwtPlotTools::setCommonPlotBehaviour( this ); - enableAxis( QwtPlot::xBottom, true ); - enableAxis( QwtPlot::yLeft, true ); - enableAxis( QwtPlot::xTop, false ); - enableAxis( QwtPlot::yRight, false ); + setAxesCount( QwtAxis::XBottom, 1 ); + setAxesCount( QwtAxis::YLeft, 1 ); - setAxisTitle( QwtPlot::xBottom, "Effective Normal Stress" ); - setAxisTitle( QwtPlot::yLeft, "Shear Stress" ); + setAxisTitle( QwtAxis::XBottom, "Effective Normal Stress" ); + setAxisTitle( QwtAxis::YLeft, "Shear Stress" ); applyFontSizes( false ); @@ -459,7 +457,7 @@ void RiuMohrsCirclePlot::updateTransparentCurvesOnPrincipals() qVectorPoints.push_back( QPointF( mohrCircleInfo.principals[2], 0 ) ); transparentCurve->setSamples( qVectorPoints ); - transparentCurve->setYAxis( QwtPlot::yLeft ); + transparentCurve->setYAxis( QwtAxis::YLeft ); transparentCurve->setStyle( QwtPlotCurve::NoCurve ); transparentCurve->setLegendAttribute( QwtPlotCurve::LegendNoAttribute ); @@ -715,8 +713,8 @@ void RiuMohrsCirclePlot::setAxesScaleAndReplot() yMaxDisplayed = heightToKeepAspectRatio; } - this->setAxisScale( QwtPlot::yLeft, 0, yMaxDisplayed ); - this->setAxisScale( QwtPlot::xBottom, xMin, xMaxDisplayed ); + this->setAxisScale( QwtAxis::YLeft, 0, yMaxDisplayed ); + this->setAxisScale( QwtAxis::XBottom, xMin, xMaxDisplayed ); this->replot(); } diff --git a/ApplicationLibCode/UserInterface/RiuMohrsCirclePlot.h b/ApplicationLibCode/UserInterface/RiuMohrsCirclePlot.h index 19a103b8a4..f84f79acc1 100644 --- a/ApplicationLibCode/UserInterface/RiuMohrsCirclePlot.h +++ b/ApplicationLibCode/UserInterface/RiuMohrsCirclePlot.h @@ -20,12 +20,7 @@ #include "RiuDockedQwtPlot.h" -#include "qwt_plot.h" -#include "qwt_plot_curve.h" -#include "qwt_plot_item.h" - #include "cafTensor3.h" - #include "cvfColor3.h" #include @@ -38,6 +33,7 @@ class RiuSelectionItem; class RimGeoMechCase; class RimGeoMechResultDefinition; class RiuGeoMechSelectionItem; +class QwtPlotCurve; //================================================================================================== // diff --git a/ApplicationLibCode/UserInterface/RiuMultiPlotBook.cpp b/ApplicationLibCode/UserInterface/RiuMultiPlotBook.cpp index 6df1004a5f..e866660621 100644 --- a/ApplicationLibCode/UserInterface/RiuMultiPlotBook.cpp +++ b/ApplicationLibCode/UserInterface/RiuMultiPlotBook.cpp @@ -18,30 +18,28 @@ #include "RiuMultiPlotBook.h" #include "RiaGuiApplication.h" +#include "RiaPlotDefines.h" #include "RiaPlotWindowRedrawScheduler.h" #include "RiaPreferences.h" #include "RimContextCommandBuilder.h" #include "RimMultiPlot.h" +#include "RimSummaryMultiPlot.h" #include "RimWellLogTrack.h" +#include "RiuDragDrop.h" #include "RiuMainWindow.h" #include "RiuMultiPlotPage.h" #include "RiuPlotMainWindow.h" #include "RiuPlotObjectPicker.h" -#include "RiuQwtPlotLegend.h" -#include "RiuQwtPlotWidget.h" +#include "RiuPlotWidget.h" +#include "RiuSummaryMultiPlotPage.h" #include "cafCmdFeatureMenuBuilder.h" #include "cafSelectionManager.h" #include "cvfAssert.h" -#include "qwt_legend.h" -#include "qwt_plot_layout.h" -#include "qwt_plot_renderer.h" -#include "qwt_scale_draw.h" - #include #include #include @@ -49,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -86,7 +85,7 @@ class BookFrame : public QFrame for ( auto page : pages ) { fullSize.setWidth( std::max( fullSize.width(), page->minimumSizeHint().width() ) ); - fullSize.setHeight( fullSize.height() + 8 + page->minimumSizeHint().height() ); + fullSize.setHeight( fullSize.height() + m_margins + page->minimumSizeHint().height() ); } return fullSize; } @@ -105,6 +104,10 @@ RiuMultiPlotBook::RiuMultiPlotBook( RimMultiPlot* plotDefinition, QWidget* paren , m_titleVisible( true ) , m_subTitlesVisible( true ) , m_previewMode( true ) + , m_currentPageIndex( 0 ) + , m_goToPageAfterUpdate( false ) + , m_pageTimerId( -1 ) + , m_pageToGoTo( 0 ) { const int spacing = 8; @@ -125,11 +128,15 @@ RiuMultiPlotBook::RiuMultiPlotBook( RimMultiPlot* plotDefinition, QWidget* paren m_scrollArea->setVisible( true ); m_book->setVisible( true ); + m_scrollArea->viewport()->installEventFilter( this ); + m_scrollArea->verticalScrollBar()->installEventFilter( this ); + setAutoFillBackground( true ); this->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::MinimumExpanding ); setFocusPolicy( Qt::StrongFocus ); + setAcceptDrops( true ); QSize pageSize = m_plotDefinition->pageLayout().fullRectPixels( RiaGuiApplication::applicationResolution() ).size(); applyPagePreviewBookSize( pageSize.width() ); @@ -156,7 +163,7 @@ RimViewWindow* RiuMultiPlotBook::ownerViewWindow() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMultiPlotBook::addPlot( RiuQwtPlotWidget* plotWidget ) +void RiuMultiPlotBook::addPlot( RiuPlotWidget* plotWidget ) { // Push the plot to the back of the list insertPlot( plotWidget, m_plotWidgets.size() ); @@ -165,16 +172,27 @@ void RiuMultiPlotBook::addPlot( RiuQwtPlotWidget* plotWidget ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMultiPlotBook::insertPlot( RiuQwtPlotWidget* plotWidget, size_t index ) +void RiuMultiPlotBook::insertPlot( RiuPlotWidget* plotWidget, size_t index ) { m_plotWidgets.insert( static_cast( index ), plotWidget ); + m_goToPageAfterUpdate = true; + m_pageToGoTo = -2; + scheduleUpdate(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMultiPlotBook::removePlot( RiuPlotWidget* plotWidget ) +{ + removePlotNoUpdate( plotWidget ); scheduleUpdate(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMultiPlotBook::removePlot( RiuQwtPlotWidget* plotWidget ) +void RiuMultiPlotBook::removePlotNoUpdate( RiuPlotWidget* plotWidget ) { if ( !plotWidget ) return; @@ -182,8 +200,6 @@ void RiuMultiPlotBook::removePlot( RiuQwtPlotWidget* plotWidget ) CVF_ASSERT( plotWidgetIdx >= 0 ); m_plotWidgets.removeAt( plotWidgetIdx ); - - scheduleUpdate(); } //-------------------------------------------------------------------------------------------------- @@ -202,19 +218,6 @@ void RiuMultiPlotBook::removeAllPlots() void RiuMultiPlotBook::setPlotTitle( const QString& plotTitle ) { m_plotTitle = plotTitle; - for ( int i = 0; i < m_pages.size(); ++i ) - { - int pageIndex = i + 1; - int pageCount = (int)m_pages.size(); - if ( pageCount > pageIndex ) - { - m_pages[i]->setPlotTitle( QString( "%1 %2/%3" ).arg( m_plotTitle ).arg( i + 1 ).arg( m_pages.size() ) ); - } - else - { - m_pages[i]->setPlotTitle( QString( "%1" ).arg( m_plotTitle ) ); - } - } } //-------------------------------------------------------------------------------------------------- @@ -241,6 +244,18 @@ void RiuMultiPlotBook::setSubTitlesVisible( bool visible ) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMultiPlotBook::scheduleTitleUpdate() +{ + for ( auto page : m_pages ) + { + page->scheduleUpdate( RiaDefines::MultiPlotPageUpdateType::TITLE ); + } + scheduleUpdate( RiaDefines::MultiPlotPageUpdateType::TITLE ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -277,7 +292,7 @@ void RiuMultiPlotBook::setAxisFontSizes( int axisTitleFontSize, int axisValueFon //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -int RiuMultiPlotBook::indexOfPlotWidget( RiuQwtPlotWidget* plotWidget ) +int RiuMultiPlotBook::indexOfPlotWidget( RiuPlotWidget* plotWidget ) { return m_plotWidgets.indexOf( plotWidget ); } @@ -306,9 +321,9 @@ void RiuMultiPlotBook::setPagePreviewModeEnabled( bool previewMode ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMultiPlotBook::scheduleUpdate() +void RiuMultiPlotBook::scheduleUpdate( RiaDefines::MultiPlotPageUpdateType whatToUpdate ) { - RiaPlotWindowRedrawScheduler::instance()->scheduleMultiPlotWindowUpdate( this ); + RiaPlotWindowRedrawScheduler::instance()->scheduleMultiPlotBookUpdate( this, whatToUpdate ); } //-------------------------------------------------------------------------------------------------- @@ -316,7 +331,7 @@ void RiuMultiPlotBook::scheduleUpdate() //-------------------------------------------------------------------------------------------------- void RiuMultiPlotBook::scheduleReplotOfAllPlots() { - for ( RiuQwtPlotWidget* plotWidget : visiblePlotWidgets() ) + for ( RiuPlotWidget* plotWidget : visiblePlotWidgets() ) { plotWidget->scheduleReplot(); } @@ -327,23 +342,31 @@ void RiuMultiPlotBook::scheduleReplotOfAllPlots() //-------------------------------------------------------------------------------------------------- void RiuMultiPlotBook::renderTo( QPaintDevice* paintDevice ) { - int resolution = paintDevice->logicalDpiX(); - double scaling = resolution / static_cast( RiaGuiApplication::applicationResolution() ); + auto scaling = RiaDefines::scalingFactor( paintDevice ); - bool firstPage = true; QPainter painter( paintDevice ); - for ( RiuMultiPlotPage* page : m_pages ) + + auto pagedDevice = dynamic_cast( paintDevice ); + if ( pagedDevice ) { - if ( !firstPage ) + bool firstPage = true; + for ( RiuMultiPlotPage* page : m_pages ) { - QPagedPaintDevice* pagedDevice = dynamic_cast( paintDevice ); - if ( pagedDevice ) + if ( !firstPage ) { pagedDevice->newPage(); } + page->renderTo( &painter, scaling ); + firstPage = false; + } + } + else + { + if ( m_currentPageIndex < m_pages.size() ) + { + auto page = m_pages[m_currentPageIndex]; + page->renderTo( &painter, scaling ); } - page->renderTo( &painter, scaling ); - firstPage = false; } } @@ -373,8 +396,10 @@ void RiuMultiPlotBook::contextMenuEvent( QContextMenuEvent* event ) //-------------------------------------------------------------------------------------------------- void RiuMultiPlotBook::showEvent( QShowEvent* event ) { + m_goToPageAfterUpdate = true; QWidget::showEvent( event ); - performUpdate(); + + performUpdate( RiaDefines::MultiPlotPageUpdateType::ALL ); if ( m_previewMode ) { applyPagePreviewBookSize( width() ); @@ -385,6 +410,15 @@ void RiuMultiPlotBook::showEvent( QShowEvent* event ) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMultiPlotBook::hideEvent( QHideEvent* event ) +{ + m_pageToGoTo = m_currentPageIndex; + QWidget::hideEvent( event ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -455,21 +489,76 @@ bool RiuMultiPlotBook::showYAxis( int row, int column ) const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMultiPlotBook::performUpdate() +void RiuMultiPlotBook::performUpdate( RiaDefines::MultiPlotPageUpdateType whatToUpdate ) { + if ( !m_plotDefinition || !m_plotDefinition->isValid() || !m_plotDefinition->showWindow() ) return; + applyLook(); - deleteAllPages(); - createPages(); + if ( ( ( whatToUpdate & RiaDefines::MultiPlotPageUpdateType::PLOT ) == RiaDefines::MultiPlotPageUpdateType::PLOT ) || + m_pages.size() == 0 ) + { + deleteAllPages(); + createPages(); + } + else if ( ( whatToUpdate & RiaDefines::MultiPlotPageUpdateType::TITLE ) == RiaDefines::MultiPlotPageUpdateType::TITLE ) + { + updatePageTitles(); + } + updateGeometry(); + + RimSummaryMultiPlot* multiPlot = dynamic_cast( m_plotDefinition.p() ); + if ( multiPlot ) multiPlot->checkAndApplyAutoAppearance(); + + // use a timer to trigger a viewer page change, if needed + if ( m_goToPageAfterUpdate ) + { + m_pageTimerId = startTimer( 50 ); + m_goToPageAfterUpdate = false; + } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList> RiuMultiPlotBook::visiblePlotWidgets() const +void RiuMultiPlotBook::updatePageTitles() { - QList> plotWidgets; - for ( QPointer plotWidget : m_plotWidgets ) + if ( m_pages.isEmpty() ) return; + + if ( m_pages.size() > 1 ) + { + for ( int i = 0; i < m_pages.size(); ++i ) + { + int pageNumber = i + 1; + m_pages[i]->setPlotTitle( QString( "%1 %2/%3" ).arg( m_plotTitle ).arg( pageNumber ).arg( m_pages.size() ) ); + } + } + else + { + m_pages[0]->setPlotTitle( QString( "%1" ).arg( m_plotTitle ) ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMultiPlotBook::timerEvent( QTimerEvent* event ) +{ + if ( event->timerId() == m_pageTimerId ) + { + killTimer( m_pageTimerId ); + changeCurrentPage( m_pageToGoTo ); + RiaGuiApplication::instance()->mainPlotWindow()->raise(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList> RiuMultiPlotBook::visiblePlotWidgets() const +{ + QList> plotWidgets; + for ( QPointer plotWidget : m_plotWidgets ) { CAF_ASSERT( plotWidget ); if ( plotWidget->isChecked() ) @@ -501,8 +590,8 @@ void RiuMultiPlotBook::createPages() { CAF_ASSERT( m_plotDefinition ); - QList> plotWidgets = this->visiblePlotWidgets(); - auto rowAndColumnCount = this->rowAndColumnCount( plotWidgets.size() ); + QList> plotWidgets = this->visiblePlotWidgets(); + auto [rowCount, columnCount] = this->rowAndColumnCount( plotWidgets.size() ); int rowsPerPage = m_plotDefinition->rowsPerPage(); int row = 0; @@ -514,9 +603,9 @@ void RiuMultiPlotBook::createPages() for ( int visibleIndex = 0; visibleIndex < plotWidgets.size(); ++visibleIndex ) { int expectedColSpan = static_cast( plotWidgets[visibleIndex]->colSpan() ); - int colSpan = std::min( expectedColSpan, rowAndColumnCount.second ); + int colSpan = std::min( expectedColSpan, columnCount ); - std::tie( row, column ) = page->findAvailableRowAndColumn( row, column, colSpan, rowAndColumnCount.second ); + std::tie( row, column ) = page->findAvailableRowAndColumn( row, column, colSpan, columnCount ); if ( row >= rowsPerPage ) { page = createPage(); @@ -525,20 +614,15 @@ void RiuMultiPlotBook::createPages() } CAF_ASSERT( plotWidgets[visibleIndex] ); page->addPlot( plotWidgets[visibleIndex] ); - page->performUpdate(); + page->performUpdate( RiaDefines::MultiPlotPageUpdateType::ALL ); } // Set page numbers in title when there's more than one page - if ( m_pages.size() > 1 ) - { - for ( int i = 0; i < m_pages.size(); ++i ) - { - int pageNumber = i + 1; - m_pages[i]->setPlotTitle( QString( "%1 %2/%3" ).arg( m_plotTitle ).arg( pageNumber ).arg( m_pages.size() ) ); - } - } - m_book->adjustSize(); + updatePageTitles(); + + adjustBookFrame(); } + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -554,7 +638,22 @@ RiuMultiPlotPage* RiuMultiPlotBook::createPage() { RiuMultiPlotPage* page = new RiuMultiPlotPage( m_plotDefinition, this ); - // Reapply plot settings + applyPageSettings( page ); + + m_pages.push_back( page ); + m_bookLayout->addWidget( page ); + + page->setVisible( true ); + return page; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMultiPlotBook::applyPageSettings( RiuMultiPlotPage* page ) +{ + if ( !page ) return; + page->setPlotTitle( m_plotTitle ); page->setTitleFontSizes( m_plotDefinition->titleFontSize(), m_plotDefinition->subTitleFontSize() ); page->setLegendFontSize( m_plotDefinition->legendFontSize() ); @@ -562,12 +661,6 @@ RiuMultiPlotPage* RiuMultiPlotBook::createPage() page->setTitleVisible( m_titleVisible ); page->setSubTitlesVisible( m_subTitlesVisible ); page->setPagePreviewModeEnabled( m_previewMode ); - - m_pages.push_back( page ); - m_bookLayout->addWidget( page ); - - page->setVisible( true ); - return page; } //-------------------------------------------------------------------------------------------------- @@ -591,3 +684,111 @@ void RiuMultiPlotBook::applyLook() m_book->setPalette( newPalette ); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMultiPlotBook::changeCurrentPage( int pageNumber ) +{ + if ( pageNumber < -1 ) pageNumber = m_pages.size() - 1; + m_currentPageIndex = pageNumber; + if ( m_currentPageIndex >= m_pages.size() ) m_currentPageIndex = m_pages.size() - 1; + if ( m_currentPageIndex < 0 ) m_currentPageIndex = 0; + if ( !m_pages.isEmpty() ) m_scrollArea->ensureWidgetVisible( m_pages[m_currentPageIndex] ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMultiPlotBook::scrollToPlot( RiuPlotWidget* plotWidget ) +{ + int pageNum = 0; + + for ( auto& page : m_pages ) + { + if ( page->indexOfPlotWidget( plotWidget ) >= 0 ) + { + changeCurrentPage( pageNum ); + return; + } + pageNum++; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMultiPlotBook::goToNextPage() +{ + changeCurrentPage( m_currentPageIndex + 1 ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMultiPlotBook::goToPrevPage() +{ + changeCurrentPage( m_currentPageIndex - 1 ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMultiPlotBook::goToLastPage() +{ + changeCurrentPage( m_pages.size() - 1 ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMultiPlotBook::keepCurrentPageAfterUpdate() +{ + m_goToPageAfterUpdate = true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMultiPlotBook::dragEnterEvent( QDragEnterEvent* event ) +{ + event->acceptProposedAction(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMultiPlotBook::dropEvent( QDropEvent* event ) +{ + std::vector objects; + + if ( RiuDragDrop::handleGenericDropEvent( event, objects ) ) + { + RimSummaryMultiPlot* multiPlot = dynamic_cast( m_plotDefinition.p() ); + if ( multiPlot ) + { + multiPlot->handleDroppedObjects( objects ); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiuMultiPlotBook::eventFilter( QObject* obj, QEvent* event ) +{ + if ( event->type() == QEvent::Wheel ) + { + event->accept(); + return true; + } + return QWidget::eventFilter( obj, event ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMultiPlotBook::adjustBookFrame() +{ + m_book->adjustSize(); +} diff --git a/ApplicationLibCode/UserInterface/RiuMultiPlotBook.h b/ApplicationLibCode/UserInterface/RiuMultiPlotBook.h index e664f93b65..ba7b979eec 100644 --- a/ApplicationLibCode/UserInterface/RiuMultiPlotBook.h +++ b/ApplicationLibCode/UserInterface/RiuMultiPlotBook.h @@ -17,7 +17,6 @@ ///////////////////////////////////////////////////////////////////////////////// #pragma once -#include "RiuInterfaceToViewWindow.h" #include "RiuMultiPlotPage.h" #include "cafPdmPointer.h" @@ -35,7 +34,7 @@ class RiaPlotWindowRedrawScheduler; class RimMultiPlot; class RiuMultiPlotPage; -class RiuQwtPlotWidget; +class RiuPlotWidget; class BookFrame; class QFocusEvent; @@ -54,43 +53,51 @@ class RiuMultiPlotBook : public QWidget, public RiuInterfaceToViewWindow { Q_OBJECT -public: - using ColumnCount = RiuMultiPlotPage::ColumnCount; - public: RiuMultiPlotBook( RimMultiPlot* plotDefinition, QWidget* parent = nullptr ); ~RiuMultiPlotBook() override; RimViewWindow* ownerViewWindow() const override; - void addPlot( RiuQwtPlotWidget* plotWidget ); - void insertPlot( RiuQwtPlotWidget* plotWidget, size_t index ); - void removePlot( RiuQwtPlotWidget* plotWidget ); + void addPlot( RiuPlotWidget* plotWidget ); + void insertPlot( RiuPlotWidget* plotWidget, size_t index ); + void removePlot( RiuPlotWidget* plotWidget ); + void removePlotNoUpdate( RiuPlotWidget* plotWidget ); void removeAllPlots(); void setPlotTitle( const QString& plotTitle ); void setTitleVisible( bool visible ); void setSubTitlesVisible( bool visible ); + void scheduleTitleUpdate(); void setTitleFontSizes( int titleFontSize, int subTitleFontSize ); void setLegendFontSize( int legendFontSize ); void setAxisFontSizes( int axisTitleFontSize, int axisValueFontSize ); - int indexOfPlotWidget( RiuQwtPlotWidget* plotWidget ); + int indexOfPlotWidget( RiuPlotWidget* plotWidget ); bool pagePreviewModeEnabled() const; void setPagePreviewModeEnabled( bool previewMode ); - void scheduleUpdate(); + void scheduleUpdate( RiaDefines::MultiPlotPageUpdateType whatToUpdate = RiaDefines::MultiPlotPageUpdateType::ALL ); void scheduleReplotOfAllPlots(); void renderTo( QPaintDevice* painter ); + void scrollToPlot( RiuPlotWidget* plotWidget ); + + void goToNextPage(); + void goToPrevPage(); + void goToLastPage(); + + void keepCurrentPageAfterUpdate(); + protected: void contextMenuEvent( QContextMenuEvent* ) override; void showEvent( QShowEvent* event ) override; + void hideEvent( QHideEvent* event ) override; void resizeEvent( QResizeEvent* event ) override; void applyPagePreviewBookSize( int frameWidth ); @@ -100,16 +107,33 @@ class RiuMultiPlotBook : public QWidget, public RiuInterfaceToViewWindow virtual bool showYAxis( int row, int column ) const; - QList> visiblePlotWidgets() const; + QList> visiblePlotWidgets() const; + + void dragEnterEvent( QDragEnterEvent* event ) override; + void dropEvent( QDropEvent* event ) override; + + void timerEvent( QTimerEvent* event ) override; + + bool eventFilter( QObject* obj, QEvent* ev ) override; + + virtual void createPages(); + + void adjustBookFrame(); + void applyPageSettings( RiuMultiPlotPage* page ); -private: - void deleteAllPages(); - void createPages(); const QList>& pages() const; - RiuMultiPlotPage* createPage(); - void applyLook(); + + void updatePageTitles(); + +private: + RiuMultiPlotPage* createPage(); + void deleteAllPages(); + void applyLook(); + + void changeCurrentPage( int pageNumber ); + private slots: - virtual void performUpdate(); + virtual void performUpdate( RiaDefines::MultiPlotPageUpdateType updateType ); protected: friend class RiaPlotWindowRedrawScheduler; @@ -120,10 +144,15 @@ private slots: QPointer m_bookLayout; QList> m_pages; - QList> m_plotWidgets; + QList> m_plotWidgets; caf::PdmPointer m_plotDefinition; QString m_plotTitle; bool m_titleVisible; bool m_subTitlesVisible; bool m_previewMode; + int m_currentPageIndex; + + bool m_goToPageAfterUpdate; + int m_pageToGoTo; + int m_pageTimerId; }; diff --git a/ApplicationLibCode/UserInterface/RiuMultiPlotPage.cpp b/ApplicationLibCode/UserInterface/RiuMultiPlotPage.cpp index 7fc454d4fc..176c31acd2 100644 --- a/ApplicationLibCode/UserInterface/RiuMultiPlotPage.cpp +++ b/ApplicationLibCode/UserInterface/RiuMultiPlotPage.cpp @@ -26,15 +26,20 @@ #include "WellLogCommands/RicWellLogPlotTrackFeatureImpl.h" #include "RiaGuiApplication.h" +#include "RiaPlotDefines.h" #include "RimContextCommandBuilder.h" #include "RimMultiPlot.h" +#include "RimPlotCurve.h" #include "RimWellLogTrack.h" #include "RiuMainWindow.h" #include "RiuPlotMainWindow.h" #include "RiuPlotObjectPicker.h" +#include "RiuPlotWidget.h" +#include "RiuQtChartsPlotWidget.h" #include "RiuQwtPlotLegend.h" +#include "RiuQwtPlotTools.h" #include "RiuQwtPlotWidget.h" #include "cafCmdFeatureMenuBuilder.h" @@ -55,8 +60,10 @@ #include #include #include +#include #include #include +#include #include @@ -99,6 +106,7 @@ RiuMultiPlotPage::RiuMultiPlotPage( RimPlotWindow* plotDefinition, QWidget* pare new RiuPlotObjectPicker( m_plotTitle, m_plotDefinition ); setFocusPolicy( Qt::StrongFocus ); + setAcceptDrops( true ); this->setObjectName( QString( "%1" ).arg( reinterpret_cast( this ) ) ); @@ -133,7 +141,7 @@ RimPlotWindow* RiuMultiPlotPage::ownerPlotDefinition() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMultiPlotPage::addPlot( RiuQwtPlotWidget* plotWidget ) +void RiuMultiPlotPage::addPlot( RiuPlotWidget* plotWidget ) { // Insert the plot to the left of the scroll bar insertPlot( plotWidget, m_plotWidgets.size() ); @@ -142,7 +150,7 @@ void RiuMultiPlotPage::addPlot( RiuQwtPlotWidget* plotWidget ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMultiPlotPage::insertPlot( RiuQwtPlotWidget* plotWidget, size_t index ) +void RiuMultiPlotPage::insertPlot( RiuPlotWidget* plotWidget, size_t index ) { m_plotWidgets.insert( static_cast( index ), plotWidget ); plotWidget->setVisible( false ); @@ -166,9 +174,21 @@ void RiuMultiPlotPage::insertPlot( RiuQwtPlotWidget* plotWidget, size_t index ) legend->setMaxColumns( legendColumns ); legend->horizontalScrollBar()->setVisible( false ); legend->verticalScrollBar()->setVisible( false ); - legend->connect( plotWidget, - SIGNAL( legendDataChanged( const QVariant&, const QList& ) ), - SLOT( updateLegend( const QVariant&, const QList& ) ) ); + RiuQwtPlotWidget* qwtPlotWidget = dynamic_cast( plotWidget ); + if ( qwtPlotWidget ) + { + legend->connect( qwtPlotWidget->qwtPlot(), + SIGNAL( legendDataChanged( const QVariant&, const QList& ) ), + SLOT( updateLegend( const QVariant&, const QList& ) ) ); + } + else + { + auto qtchartPlotWidget = dynamic_cast( plotWidget ); + legend->connect( qtchartPlotWidget, + SIGNAL( legendDataChanged( const QList& ) ), + SLOT( updateLegend( const QList& ) ) ); + } + QObject::connect( legend, SIGNAL( legendUpdated() ), this, SLOT( onLegendUpdated() ) ); legend->contentsWidget()->layout()->setAlignment( Qt::AlignBottom | Qt::AlignHCenter ); @@ -183,7 +203,7 @@ void RiuMultiPlotPage::insertPlot( RiuQwtPlotWidget* plotWidget, size_t index ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMultiPlotPage::removePlot( RiuQwtPlotWidget* plotWidget ) +void RiuMultiPlotPage::removePlot( RiuPlotWidget* plotWidget ) { if ( !plotWidget ) return; @@ -206,6 +226,8 @@ void RiuMultiPlotPage::removePlot( RiuQwtPlotWidget* plotWidget ) m_subTitles.removeAt( plotWidgetIdx ); delete subTitle; + m_childCountForAdjustSizeOperation.clear(); + scheduleUpdate(); } @@ -215,7 +237,7 @@ void RiuMultiPlotPage::removePlot( RiuQwtPlotWidget* plotWidget ) void RiuMultiPlotPage::removeAllPlots() { auto plotWidgets = m_plotWidgets; - for ( RiuQwtPlotWidget* plotWidget : plotWidgets ) + for ( RiuPlotWidget* plotWidget : plotWidgets ) { removePlot( plotWidget ); } @@ -296,7 +318,7 @@ void RiuMultiPlotPage::setPagePreviewModeEnabled( bool previewMode ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -int RiuMultiPlotPage::indexOfPlotWidget( RiuQwtPlotWidget* plotWidget ) +int RiuMultiPlotPage::indexOfPlotWidget( RiuPlotWidget* plotWidget ) { return m_plotWidgets.indexOf( plotWidget ); } @@ -304,10 +326,10 @@ int RiuMultiPlotPage::indexOfPlotWidget( RiuQwtPlotWidget* plotWidget ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMultiPlotPage::scheduleUpdate() +void RiuMultiPlotPage::scheduleUpdate( RiaDefines::MultiPlotPageUpdateType whatToUpdate ) { CAF_ASSERT( m_plotDefinition ); - RiaPlotWindowRedrawScheduler::instance()->scheduleMultiPlotPageUpdate( this ); + RiaPlotWindowRedrawScheduler::instance()->scheduleMultiPlotPageUpdate( this, whatToUpdate ); } //-------------------------------------------------------------------------------------------------- @@ -315,7 +337,7 @@ void RiuMultiPlotPage::scheduleUpdate() //-------------------------------------------------------------------------------------------------- void RiuMultiPlotPage::scheduleReplotOfAllPlots() { - for ( RiuQwtPlotWidget* plotWidget : visiblePlotWidgets() ) + for ( RiuPlotWidget* plotWidget : visiblePlotWidgets() ) { plotWidget->scheduleReplot(); } @@ -340,8 +362,7 @@ void RiuMultiPlotPage::updateSubTitles() //-------------------------------------------------------------------------------------------------- void RiuMultiPlotPage::renderTo( QPaintDevice* paintDevice ) { - int resolution = paintDevice->logicalDpiX(); - double scaling = resolution / static_cast( RiaGuiApplication::applicationResolution() ); + auto scaling = RiaDefines::scalingFactor( paintDevice ); QPainter painter( paintDevice ); renderTo( &painter, scaling ); @@ -426,7 +447,7 @@ QLabel* RiuMultiPlotPage::createTitleLabel() const void RiuMultiPlotPage::showEvent( QShowEvent* event ) { QWidget::showEvent( event ); - performUpdate(); + performUpdate( RiaDefines::MultiPlotPageUpdateType::ALL ); } //-------------------------------------------------------------------------------------------------- @@ -517,9 +538,9 @@ void RiuMultiPlotPage::onSelectionManagerSelectionChanged( const std::set& { if ( !m_plotDefinition ) return; - for ( RiuQwtPlotWidget* plotWidget : m_plotWidgets ) + for ( RiuPlotWidget* plotWidget : m_plotWidgets ) { - CAF_ASSERT( plotWidget ); + if ( !plotWidget ) continue; RimPlot* plot = plotWidget->plotDefinition(); if ( !plot ) continue; @@ -542,12 +563,30 @@ bool RiuMultiPlotPage::showYAxis( int row, int column ) const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMultiPlotPage::performUpdate() +void RiuMultiPlotPage::performUpdate( RiaDefines::MultiPlotPageUpdateType whatToUpdate ) { - applyLook(); - updateMarginsFromPageLayout(); - reinsertPlotWidgets(); - alignCanvasTops(); + auto multiPlot = dynamic_cast( m_plotDefinition.p() ); + if ( multiPlot && !multiPlot->isValid() ) return; + + if ( whatToUpdate == RiaDefines::MultiPlotPageUpdateType::ALL ) + { + applyLook(); + updateMarginsFromPageLayout(); + + reinsertPlotWidgets(); + alignCanvasTops(); + return; + } + + if ( ( whatToUpdate & RiaDefines::MultiPlotPageUpdateType::LEGEND ) == RiaDefines::MultiPlotPageUpdateType::LEGEND ) + { + refreshLegends(); + alignCanvasTops(); + } + if ( ( whatToUpdate & RiaDefines::MultiPlotPageUpdateType::TITLE ) == RiaDefines::MultiPlotPageUpdateType::TITLE ) + { + updateSubTitles(); + } } //-------------------------------------------------------------------------------------------------- @@ -555,53 +594,45 @@ void RiuMultiPlotPage::performUpdate() //-------------------------------------------------------------------------------------------------- void RiuMultiPlotPage::onLegendUpdated() { - scheduleUpdate(); + scheduleUpdate( RiaDefines::MultiPlotPageUpdateType::LEGEND ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMultiPlotPage::reinsertPlotWidgets() +void RiuMultiPlotPage::refreshLegends() { - clearGridLayout(); - - auto titleFont = m_plotTitle->font(); - titleFont.setPixelSize( m_titleFontPixelSize ); - m_plotTitle->setFont( titleFont ); - - for ( int tIdx = 0; tIdx < m_plotWidgets.size(); ++tIdx ) + QList> legends = this->legendsForVisiblePlots(); + for ( const auto& l : legends ) { - if ( m_plotWidgets[tIdx] ) - { - m_plotWidgets[tIdx]->hide(); - } - if ( m_legends[tIdx] ) - { - m_legends[tIdx]->hide(); - } - if ( m_subTitles[tIdx] ) - { - m_subTitles[tIdx]->hide(); - } + l->setVisible( !l->isEmpty() ); } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMultiPlotPage::reinsertPlotWidgets() +{ + clearGridLayout(); QList> subTitles = this->subTitlesForVisiblePlots(); QList> legends = this->legendsForVisiblePlots(); - QList> plotWidgets = this->visiblePlotWidgets(); + QList> plotWidgets = this->visiblePlotWidgets(); if ( !plotWidgets.empty() ) { - auto rowAndColumnCount = this->rowAndColumnCount( plotWidgets.size() ); + auto [rowCount, columnCount] = this->rowAndColumnCount( plotWidgets.size() ); int row = 0; int column = 0; for ( int visibleIndex = 0; visibleIndex < plotWidgets.size(); ++visibleIndex ) { int expectedColSpan = static_cast( plotWidgets[visibleIndex]->colSpan() ); - int colSpan = std::min( expectedColSpan, rowAndColumnCount.second ); + int colSpan = std::min( expectedColSpan, columnCount ); int rowSpan = plotWidgets[visibleIndex]->rowSpan(); - std::tie( row, column ) = findAvailableRowAndColumn( row, column, colSpan, rowAndColumnCount.second ); + std::tie( row, column ) = findAvailableRowAndColumn( row, column, colSpan, columnCount ); m_gridLayout->addWidget( subTitles[visibleIndex], 3 * row, column, 1, colSpan ); if ( legends[visibleIndex] ) @@ -615,12 +646,21 @@ void RiuMultiPlotPage::reinsertPlotWidgets() subTitleFont.setPixelSize( m_subTitleFontPixelSize ); subTitles[visibleIndex]->setFont( subTitleFont ); - plotWidgets[visibleIndex]->setAxisLabelsAndTicksEnabled( QwtPlot::yLeft, + plotWidgets[visibleIndex]->setAxisLabelsAndTicksEnabled( RiuPlotAxis::defaultLeft(), showYAxis( row, column ), showYAxis( row, column ) ); - plotWidgets[visibleIndex]->setAxisTitleEnabled( QwtPlot::yLeft, showYAxis( row, column ) ); + plotWidgets[visibleIndex]->setAxisTitleEnabled( RiuPlotAxis::defaultLeft(), showYAxis( row, column ) ); plotWidgets[visibleIndex]->setAxesFontsAndAlignment( m_axisTitleFontSize, m_axisValueFontSize ); + { + auto margins = plotWidgets[visibleIndex]->contentsMargins(); + margins.setBottom( 40 ); + + // Adjust the space below a graph to make sure the heading of the row below is closest to the + // corresponding graph + plotWidgets[visibleIndex]->setContentsMargins( margins ); + } + plotWidgets[visibleIndex]->show(); if ( legends[visibleIndex] ) @@ -665,7 +705,7 @@ int RiuMultiPlotPage::alignCanvasTops() { CVF_ASSERT( m_legends.size() == m_plotWidgets.size() ); - QList> plotWidgets = visiblePlotWidgets(); + QList> plotWidgets = visiblePlotWidgets(); QList> legends = legendsForVisiblePlots(); if ( plotWidgets.empty() ) return 0; @@ -675,22 +715,44 @@ int RiuMultiPlotPage::alignCanvasTops() for ( int visibleIndex = 0; visibleIndex < plotWidgets.size(); ++visibleIndex ) { - int row = visibleIndex / rowAndColumnCount.second; - if ( plotWidgets[visibleIndex]->axisEnabled( QwtPlot::xTop ) ) + RiuQwtPlotWidget* qwtPlotWidget = dynamic_cast( plotWidgets[visibleIndex].data() ); + if ( qwtPlotWidget ) { - QFont font = m_plotWidgets[visibleIndex]->axisFont( QwtPlot::xTop ); - maxExtents[row] = - std::max( maxExtents[row], plotWidgets[visibleIndex]->axisScaleDraw( QwtPlot::xTop )->extent( font ) ); + int row = visibleIndex / rowAndColumnCount.second; + if ( plotWidgets[visibleIndex]->axisEnabled( RiuPlotAxis::defaultTop() ) ) + { + QFont font = qwtPlotWidget->qwtPlot()->axisFont( QwtAxis::XTop ); + maxExtents[row] = std::max( maxExtents[row], + qwtPlotWidget->qwtPlot()->axisScaleDraw( QwtAxis::XTop )->extent( font ) ); + } } } for ( int visibleIndex = 0; visibleIndex < plotWidgets.size(); ++visibleIndex ) { - int row = visibleIndex / rowAndColumnCount.second; - plotWidgets[visibleIndex]->axisScaleDraw( QwtPlot::xTop )->setMinimumExtent( maxExtents[row] ); - if ( legends[visibleIndex] ) + RiuQwtPlotWidget* qwtPlotWidget = dynamic_cast( plotWidgets[visibleIndex].data() ); + if ( qwtPlotWidget ) { - legends[visibleIndex]->adjustSize(); + int row = visibleIndex / rowAndColumnCount.second; + qwtPlotWidget->qwtPlot()->axisScaleDraw( QwtAxis::XTop )->setMinimumExtent( maxExtents[row] ); + auto legend = legends[visibleIndex]; + if ( legend ) + { + int previousChildCount = -1; + + auto it = m_childCountForAdjustSizeOperation.find( legend ); + if ( it != m_childCountForAdjustSizeOperation.end() ) + { + previousChildCount = it->second; + } + + auto legendItemCount = legend->contentsWidget()->children().size(); + if ( previousChildCount != legendItemCount ) + { + legends[visibleIndex]->adjustSize(); + m_childCountForAdjustSizeOperation[legend] = legendItemCount; + } + } } } return maxExtents[0]; @@ -721,15 +783,31 @@ void RiuMultiPlotPage::clearGridLayout() delete m_gridLayout; m_gridLayout = new QGridLayout( m_plotWidgetFrame ); } + + for ( int tIdx = 0; tIdx < m_plotWidgets.size(); ++tIdx ) + { + if ( m_plotWidgets[tIdx] ) + { + m_plotWidgets[tIdx]->hide(); + } + if ( m_legends[tIdx] ) + { + m_legends[tIdx]->hide(); + } + if ( m_subTitles[tIdx] ) + { + m_subTitles[tIdx]->hide(); + } + } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList> RiuMultiPlotPage::visiblePlotWidgets() const +QList> RiuMultiPlotPage::visiblePlotWidgets() const { - QList> plotWidgets; - for ( QPointer plotWidget : m_plotWidgets ) + QList> plotWidgets; + for ( QPointer plotWidget : m_plotWidgets ) { if ( plotWidget->isChecked() ) { @@ -836,3 +914,13 @@ void RiuMultiPlotPage::applyLook() setGraphicsEffect( nullptr ); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMultiPlotPage::updateTitleFont() +{ + auto titleFont = m_plotTitle->font(); + titleFont.setPixelSize( m_titleFontPixelSize ); + m_plotTitle->setFont( titleFont ); +} diff --git a/ApplicationLibCode/UserInterface/RiuMultiPlotPage.h b/ApplicationLibCode/UserInterface/RiuMultiPlotPage.h index fc643efa22..575bdb6f2b 100644 --- a/ApplicationLibCode/UserInterface/RiuMultiPlotPage.h +++ b/ApplicationLibCode/UserInterface/RiuMultiPlotPage.h @@ -19,6 +19,8 @@ #include "RiuInterfaceToViewWindow.h" +#include "RiaDefines.h" + #include "cafPdmPointer.h" #include "cafSelectionChangedReceiver.h" @@ -34,7 +36,7 @@ class RiaPlotWindowRedrawScheduler; class RimPlotWindow; class RiuQwtPlotLegend; -class RiuQwtPlotWidget; +class RiuPlotWidget; class QFocusEvent; class QLabel; @@ -53,16 +55,6 @@ class RiuMultiPlotPage : public QWidget, public caf::SelectionChangedReceiver, p { Q_OBJECT -public: - enum class ColumnCount - { - COLUMNS_1 = 1, - COLUMNS_2 = 2, - COLUMNS_3 = 3, - COLUMNS_4 = 4, - COLUMNS_UNLIMITED = 1000, - }; - public: RiuMultiPlotPage( RimPlotWindow* plotDefinition, QWidget* parent = nullptr ); ~RiuMultiPlotPage() override; @@ -70,11 +62,11 @@ class RiuMultiPlotPage : public QWidget, public caf::SelectionChangedReceiver, p RimViewWindow* ownerViewWindow() const override; RimPlotWindow* ownerPlotDefinition(); - void addPlot( RiuQwtPlotWidget* plotWidget ); - void insertPlot( RiuQwtPlotWidget* plotWidget, size_t index ); - void removePlot( RiuQwtPlotWidget* plotWidget ); + void addPlot( RiuPlotWidget* plotWidget ); + void insertPlot( RiuPlotWidget* plotWidget, size_t index ); + void removePlot( RiuPlotWidget* plotWidget ); void removeAllPlots(); - int indexOfPlotWidget( RiuQwtPlotWidget* plotWidget ); + int indexOfPlotWidget( RiuPlotWidget* plotWidget ); void setPlotTitle( const QString& plotTitle ); void setTitleVisible( bool visible ); @@ -86,8 +78,8 @@ class RiuMultiPlotPage : public QWidget, public caf::SelectionChangedReceiver, p bool previewModeEnabled() const; void setPagePreviewModeEnabled( bool previewMode ); - void scheduleUpdate(); - void scheduleReplotOfAllPlots(); + void scheduleUpdate( RiaDefines::MultiPlotPageUpdateType whatToUpdate = RiaDefines::MultiPlotPageUpdateType::ALL ); + void scheduleReplotOfAllPlots(); virtual void updateVerticalScrollBar( double visibleMin, double visibleMax, double totalMin, double totalMax ) {} void updateSubTitles(); @@ -98,6 +90,11 @@ class RiuMultiPlotPage : public QWidget, public caf::SelectionChangedReceiver, p QSize minimumSizeHint() const override; int heightForWidth( int width ) const override; + std::pair findAvailableRowAndColumn( int startRow, int startColumn, int columnSpan, int columnCount ) const; + +public slots: + virtual void performUpdate( RiaDefines::MultiPlotPageUpdateType whatToUpdate ); + protected: void contextMenuEvent( QContextMenuEvent* ) override; QLabel* createTitleLabel() const; @@ -112,25 +109,25 @@ class RiuMultiPlotPage : public QWidget, public caf::SelectionChangedReceiver, p virtual bool showYAxis( int row, int column ) const; - void reinsertPlotWidgets(); - int alignCanvasTops(); + virtual void reinsertPlotWidgets(); + virtual void refreshLegends(); + + void updateTitleFont(); + + int alignCanvasTops(); void clearGridLayout(); - QList> visiblePlotWidgets() const; + QList> visiblePlotWidgets() const; QList> legendsForVisiblePlots() const; QList> subTitlesForVisiblePlots() const; - std::pair findAvailableRowAndColumn( int startRow, int startColumn, int columnSpan, int columnCount ) const; - void applyLook(); + private slots: - virtual void performUpdate(); - void onLegendUpdated(); + void onLegendUpdated(); protected: - friend class RiuMultiPlotBook; - QPointer m_layout; QPointer m_plotLayout; QPointer m_plotWidgetFrame; @@ -138,7 +135,7 @@ private slots: QPointer m_plotTitle; QList> m_subTitles; QList> m_legends; - QList> m_plotWidgets; + QList> m_plotWidgets; caf::PdmPointer m_plotDefinition; int m_titleFontPixelSize; @@ -150,6 +147,8 @@ private slots: bool m_previewMode; bool m_showSubTitles; + std::map m_childCountForAdjustSizeOperation; + private: friend class RiaPlotWindowRedrawScheduler; }; diff --git a/ApplicationLibCode/UserInterface/RiuPlotAnnotationTool.cpp b/ApplicationLibCode/UserInterface/RiuPlotAnnotationTool.cpp index 0aedbfb7b7..35b02f8a98 100644 --- a/ApplicationLibCode/UserInterface/RiuPlotAnnotationTool.cpp +++ b/ApplicationLibCode/UserInterface/RiuPlotAnnotationTool.cpp @@ -25,6 +25,7 @@ #include "qwt_plot.h" #include "qwt_plot_zoneitem.h" +#include "qwt_text.h" #include @@ -95,7 +96,7 @@ void RiuPlotAnnotationTool::attachNamedRegions( QwtPlot* shading->setBrush( brush ); shading->attach( m_plot ); shading->setZ( -100.0 ); - shading->setXAxis( QwtPlot::xTop ); + shading->setXAxis( QwtAxis::XTop ); m_horizontalMarkers.push_back( std::move( shading ) ); } @@ -334,7 +335,7 @@ void RiuPlotAnnotationTool::horizontalRange( const QString& nam shading->setBrush( brush ); shading->attach( m_plot ); shading->setZ( -100.0 ); - shading->setXAxis( QwtPlot::xBottom ); + shading->setXAxis( QwtAxis::XBottom ); m_horizontalMarkers.push_back( std::move( shading ) ); QwtPlotMarker* line( new QwtPlotMarker() ); @@ -369,7 +370,7 @@ void RiuPlotAnnotationTool::verticalRange( const QString& name, shading->setBrush( brush ); shading->attach( m_plot ); shading->setZ( -100.0 ); - shading->setXAxis( QwtPlot::xBottom ); + shading->setXAxis( QwtAxis::XBottom ); m_verticalMarkers.push_back( std::move( shading ) ); QStringList labels = name.split( " - " ); @@ -413,7 +414,7 @@ void RiuPlotAnnotationTool::verticalLine( QwtPlotMarker* line, curvePen.setColor( color ); curvePen.setWidth( 1 ); - line->setAxes( QwtPlot::xBottom, QwtPlot::yLeft ); + line->setAxes( QwtAxis::XBottom, QwtAxis::YLeft ); line->setLineStyle( QwtPlotMarker::VLine ); line->setLinePen( curvePen ); line->setXValue( xValue ); diff --git a/ApplicationLibCode/UserInterface/RiuPlotAnnotationTool.h b/ApplicationLibCode/UserInterface/RiuPlotAnnotationTool.h index c6477db97e..a37f45664f 100644 --- a/ApplicationLibCode/UserInterface/RiuPlotAnnotationTool.h +++ b/ApplicationLibCode/UserInterface/RiuPlotAnnotationTool.h @@ -25,6 +25,7 @@ #include #include +#include #include class QString; diff --git a/ApplicationLibCode/UserInterface/RiuPlotAxis.cpp b/ApplicationLibCode/UserInterface/RiuPlotAxis.cpp new file mode 100644 index 0000000000..47d7569c73 --- /dev/null +++ b/ApplicationLibCode/UserInterface/RiuPlotAxis.cpp @@ -0,0 +1,128 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiuPlotAxis.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuPlotAxis::RiuPlotAxis() + : m_axis( RiaDefines::PlotAxis::PLOT_AXIS_LEFT ) + , m_index( 0 ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuPlotAxis::RiuPlotAxis( RiaDefines::PlotAxis axis ) + : m_axis( axis ) + , m_index( 0 ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuPlotAxis::RiuPlotAxis( RiaDefines::PlotAxis axis, int index ) + : m_axis( axis ) + , m_index( index ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuPlotAxis::~RiuPlotAxis() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuPlotAxis RiuPlotAxis::defaultLeft() +{ + return RiuPlotAxis( RiaDefines::PlotAxis::PLOT_AXIS_LEFT ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuPlotAxis RiuPlotAxis::defaultRight() +{ + return RiuPlotAxis( RiaDefines::PlotAxis::PLOT_AXIS_RIGHT ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuPlotAxis RiuPlotAxis::defaultTop() +{ + return RiuPlotAxis( RiaDefines::PlotAxis::PLOT_AXIS_TOP ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuPlotAxis RiuPlotAxis::defaultBottom() +{ + return RiuPlotAxis( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaDefines::PlotAxis RiuPlotAxis::axis() const +{ + return m_axis; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RiuPlotAxis::index() const +{ + return m_index; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiuPlotAxis::operator<( const RiuPlotAxis& rhs ) const +{ + if ( m_axis != rhs.m_axis ) + return m_axis < rhs.m_axis; + else + return m_index < rhs.m_index; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiuPlotAxis::operator==( const RiuPlotAxis& rhs ) const +{ + return m_axis == rhs.m_axis && m_index == rhs.m_index; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiuPlotAxis::operator!=( const RiuPlotAxis& rhs ) const +{ + return !( *this == rhs ); +} diff --git a/ApplicationLibCode/UserInterface/RiuPlotAxis.h b/ApplicationLibCode/UserInterface/RiuPlotAxis.h new file mode 100644 index 0000000000..d3a1460350 --- /dev/null +++ b/ApplicationLibCode/UserInterface/RiuPlotAxis.h @@ -0,0 +1,47 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RiaPlotDefines.h" + +class RiuPlotAxis +{ +public: + explicit RiuPlotAxis(); + explicit RiuPlotAxis( RiaDefines::PlotAxis axis ); + explicit RiuPlotAxis( RiaDefines::PlotAxis axis, int index ); + virtual ~RiuPlotAxis(); + + static RiuPlotAxis defaultLeft(); + static RiuPlotAxis defaultRight(); + static RiuPlotAxis defaultTop(); + static RiuPlotAxis defaultBottom(); + + RiaDefines::PlotAxis axis() const; + + int index() const; + + bool operator<( const RiuPlotAxis& rhs ) const; + bool operator==( const RiuPlotAxis& rhs ) const; + bool operator!=( const RiuPlotAxis& rhs ) const; + +private: + RiaDefines::PlotAxis m_axis; + int m_index; +}; diff --git a/ApplicationLibCode/UserInterface/RiuPlotCurve.cpp b/ApplicationLibCode/UserInterface/RiuPlotCurve.cpp new file mode 100644 index 0000000000..7de827ffa1 --- /dev/null +++ b/ApplicationLibCode/UserInterface/RiuPlotCurve.cpp @@ -0,0 +1,206 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiuPlotCurve.h" + +#include "RiaCurveDataTools.h" +#include "RiaTimeTTools.h" + +#include "RimPlotCurve.h" + +#include "qwt_date.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuPlotCurve::RiuPlotCurve( RimPlotCurve* ownerRimCurve, const QString& title ) +{ + m_ownerRimCurve = ownerRimCurve; + + m_symbolSkipPixelDistance = 10.0f; + + m_blackAndWhiteLegendIcon = false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuPlotCurve::~RiuPlotCurve() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuPlotCurve::setSamplesValues( const std::vector& xValues, const std::vector& yValues ) +{ + setSamplesInPlot( xValues, yValues ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuPlotCurve::setSamplesFromXValuesAndYValues( const std::vector& xValues, + const std::vector& yValues, + bool useLogarithmicScale ) +{ + computeValidIntervalsAndSetCurveData( xValues, yValues, useLogarithmicScale ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuPlotCurve::setSamplesFromDatesAndYValues( const std::vector& dateTimes, + const std::vector& yValues, + bool useLogarithmicScale ) +{ + auto xValues = RiuPlotCurve::fromQDateTime( dateTimes ); + + computeValidIntervalsAndSetCurveData( xValues, yValues, useLogarithmicScale ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuPlotCurve::setSamplesFromTimeTAndYValues( const std::vector& dateTimes, + const std::vector& yValues, + bool useLogarithmicScale ) +{ + auto xValues = RiuPlotCurve::fromTime_t( dateTimes ); + + computeValidIntervalsAndSetCurveData( xValues, yValues, useLogarithmicScale ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuPlotCurve::setLineSegmentStartStopIndices( const std::vector>& lineSegmentStartStopIndices ) +{ + m_polyLineStartStopIndices = lineSegmentStartStopIndices; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuPlotCurve::setSymbolSkipPixelDistance( float distance ) +{ + m_symbolSkipPixelDistance = distance >= 0.0f ? distance : 0.0f; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuPlotCurve::setPerPointLabels( const std::vector& labels ) +{ + m_perPointLabels = labels; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuPlotCurve::setBlackAndWhiteLegendIcon( bool blackAndWhite ) +{ + m_blackAndWhiteLegendIcon = blackAndWhite; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuPlotCurve::computeValidIntervalsAndSetCurveData( const std::vector& xValues, + const std::vector& yValues, + bool useLogarithmicScale ) +{ + auto intervalsOfValidValues = RiaCurveDataTools::calculateIntervalsOfValidValues( yValues, useLogarithmicScale ); + + std::vector validYValues; + std::vector validXValues; + + RiaCurveDataTools::getValuesByIntervals( yValues, intervalsOfValidValues, &validYValues ); + RiaCurveDataTools::getValuesByIntervals( xValues, intervalsOfValidValues, &validXValues ); + + setSamplesInPlot( validXValues, validYValues ); + + setLineSegmentStartStopIndices( RiaCurveDataTools::computePolyLineStartStopIndices( intervalsOfValidValues ) ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RiuPlotCurve::fromQDateTime( const std::vector& dateTimes ) +{ + std::vector doubleValues; + + if ( !dateTimes.empty() ) + { + doubleValues.reserve( dateTimes.size() ); + + for ( const auto& dt : dateTimes ) + { + // TODO: remove Qwt usage here.. + doubleValues.push_back( QwtDate::toDouble( dt ) ); + } + } + + return doubleValues; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RiuPlotCurve::fromTime_t( const std::vector& timeSteps ) +{ + std::vector doubleValues; + + if ( !timeSteps.empty() ) + { + doubleValues.reserve( timeSteps.size() ); + for ( const auto& time : timeSteps ) + { + doubleValues.push_back( RiaTimeTTools::toDouble( time ) ); + } + } + + return doubleValues; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuPlotCurve::setSamplesFromXYErrorValues( const std::vector& xValues, + const std::vector& yValues, + const std::vector& errorValues, + bool useLogarithmicScale, + RiaCurveDataTools::ErrorAxis errorAxis ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimPlotCurve* RiuPlotCurve::ownerRimCurve() +{ + return m_ownerRimCurve; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RimPlotCurve* RiuPlotCurve::ownerRimCurve() const +{ + return m_ownerRimCurve; +} diff --git a/ApplicationLibCode/UserInterface/RiuPlotCurve.h b/ApplicationLibCode/UserInterface/RiuPlotCurve.h new file mode 100644 index 0000000000..492cd1d929 --- /dev/null +++ b/ApplicationLibCode/UserInterface/RiuPlotCurve.h @@ -0,0 +1,152 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RiaCurveDataTools.h" + +#include "RiuPlotCurveSymbol.h" +#include "RiuPlotWidget.h" +#include "RiuQwtPlotCurveDefines.h" + +#include +#include +#include +#include + +class RimPlotCurve; + +//================================================================================================== +// +// If infinite data is present in the curve data, Qwt is not able to draw a nice curve. +// This class assumes that inf data is removed, and segments to be draw are indicated by start/stop indices into curve +// data. +// +// Single values in the curve are drawn using a CrossX symbol +// +// Here you can see the curve segments visualized. Curve segments are drawn between vector indices. +// +// 0 - 1 +// 5 - 7 +// 9 -10 +// +// * * +// * * * +// Curve * * * ----- X +// +// Values 1.0|2.0|inf|inf|inf|1.0|2.0|1.0|inf|1.0|1.0|inf|1.0|inf +// Vec index 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10| 11| 12| 13 +//================================================================================================== +class RiuPlotCurve +{ +public: + explicit RiuPlotCurve( RimPlotCurve* ownerRimCurve, const QString& title = QString() ); + explicit RiuPlotCurve(); + virtual ~RiuPlotCurve(); + + virtual void setTitle( const QString& title ) = 0; + + virtual void setSamplesValues( const std::vector& xValues, const std::vector& yValues ); + + void setSamplesFromXValuesAndYValues( const std::vector& xValues, + const std::vector& yValues, + bool useLogarithmicScale ); + + void setSamplesFromDatesAndYValues( const std::vector& dateTimes, + const std::vector& yValues, + bool useLogarithmicScale ); + + void setSamplesFromTimeTAndYValues( const std::vector& dateTimes, + const std::vector& yValues, + bool useLogarithmicScale ); + + virtual void setSamplesFromXYErrorValues( + const std::vector& xValues, + const std::vector& yValues, + const std::vector& errorValues, + bool useLogarithmicScale, + RiaCurveDataTools::ErrorAxis errorAxis = RiaCurveDataTools::ErrorAxis::ERROR_ALONG_Y_AXIS ); + + void setLineSegmentStartStopIndices( const std::vector>& lineSegmentStartStopIndices ); + + void setSymbolSkipPixelDistance( float distance ); + void setPerPointLabels( const std::vector& labels ); + + virtual void setAppearance( RiuQwtPlotCurveDefines::LineStyleEnum lineStyle, + RiuQwtPlotCurveDefines::CurveInterpolationEnum interpolationType, + int curveThickness, + const QColor& curveColor, + const QBrush& fillBrush = QBrush( Qt::NoBrush ) ) = 0; + + virtual void setBrush( const QBrush& brush ) = 0; + virtual void setColor( const QColor& color ) = 0; + + void setBlackAndWhiteLegendIcon( bool blackAndWhite ); + virtual void setVisibleInLegend( bool isVisibleInLegend ) = 0; + virtual void setLegendIconSize( const QSize& iconSize ) = 0; + virtual QSize legendIconSize() const = 0; + virtual QPixmap legendIcon( const QSizeF& size ) const = 0; + + virtual void attachToPlot( RiuPlotWidget* plotWidget ) = 0; + virtual void showInPlot() = 0; + virtual void detach() = 0; + + static std::vector fromQDateTime( const std::vector& dateTimes ); + static std::vector fromTime_t( const std::vector& timeSteps ); + + virtual void setZ( int z ) = 0; + + virtual void updateErrorBarsAppearance( bool showErrorBars, const QColor& curveColor ) = 0; + virtual void clearErrorBars() = 0; + + virtual int numSamples() const = 0; + virtual std::pair sample( int index ) const = 0; + + RimPlotCurve* ownerRimCurve(); + const RimPlotCurve* ownerRimCurve() const; + + virtual std::pair xDataRange() const = 0; + virtual std::pair yDataRange() const = 0; + + virtual void setXAxis( RiuPlotAxis axis ) = 0; + virtual void setYAxis( RiuPlotAxis axis ) = 0; + + virtual void setSymbol( RiuPlotCurveSymbol* symbol ) = 0; + + virtual RiuPlotCurveSymbol* createSymbol( RiuPlotCurveSymbol::PointSymbolEnum symbol ) const = 0; + + virtual void setCurveFittingTolerance( double tolerance ) = 0; + +protected: + virtual void setSamplesInPlot( const std::vector& xValues, const std::vector& yValues ) = 0; + +private: + void computeValidIntervalsAndSetCurveData( const std::vector& xValues, + const std::vector& yValues, + bool useLogarithmicScale ); + +protected: + float m_symbolSkipPixelDistance; + bool m_blackAndWhiteLegendIcon; + + std::vector m_perPointLabels; + + std::vector> m_polyLineStartStopIndices; + + caf::PdmPointer m_ownerRimCurve; +}; diff --git a/ApplicationLibCode/UserInterface/RiuPlotCurveInfoTextProvider.h b/ApplicationLibCode/UserInterface/RiuPlotCurveInfoTextProvider.h new file mode 100644 index 0000000000..70fe084dc9 --- /dev/null +++ b/ApplicationLibCode/UserInterface/RiuPlotCurveInfoTextProvider.h @@ -0,0 +1,33 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Equinor ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 + +class RiuPlotCurve; + +//-------------------------------------------------------------------------------------------------- +/// Interface for retrieving curve info text +//-------------------------------------------------------------------------------------------------- +class RiuPlotCurveInfoTextProvider +{ +public: + virtual QString curveInfoText( RiuPlotCurve* curve ) const = 0; +}; diff --git a/ApplicationLibCode/UserInterface/RiuPlotCurveSymbol.cpp b/ApplicationLibCode/UserInterface/RiuPlotCurveSymbol.cpp new file mode 100644 index 0000000000..040c609c68 --- /dev/null +++ b/ApplicationLibCode/UserInterface/RiuPlotCurveSymbol.cpp @@ -0,0 +1,153 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Equinor ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "RiuPlotCurveSymbol.h" + +#include "cafFontTools.h" +#include "cvfAssert.h" + +#include +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuPlotCurveSymbol::RiuPlotCurveSymbol( PointSymbolEnum riuStyle, + const QString& label, + LabelPosition labelPosition, + int labelFontSizePt ) + : m_style( riuStyle ) + , m_globalLabel( label ) + , m_labelPosition( labelPosition ) + , m_labelFontSizePx( caf::FontTools::pointSizeToPixelSize( labelFontSizePt ) ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuPlotCurveSymbol::globalLabel() const +{ + return m_globalLabel; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuPlotCurveSymbol::setGlobalLabel( const QString& label ) +{ + m_globalLabel = label; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuPlotCurveSymbol::setLabelPosition( LabelPosition labelPosition ) +{ + m_labelPosition = labelPosition; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuPlotCurveSymbol::setLabelFontSize( int labelFontSizePt ) +{ + m_labelFontSizePx = caf::FontTools::pointSizeToPixelSize( labelFontSizePt ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuPlotCurveSymbol::PointSymbolEnum RiuPlotCurveSymbol::cycledSymbolStyle( int indexLevel1, int indexLevel2 ) +{ + std::vector> categorisedStyles = { + { SYMBOL_ELLIPSE, SYMBOL_RECT, SYMBOL_DIAMOND }, + { SYMBOL_DOWN_TRIANGLE, SYMBOL_UP_TRIANGLE }, + { SYMBOL_LEFT_TRIANGLE, SYMBOL_RIGHT_TRIANGLE }, + { SYMBOL_CROSS, SYMBOL_XCROSS }, + { SYMBOL_STAR1, SYMBOL_STAR2 }, + }; + + int level1Category = indexLevel1 % int( categorisedStyles.size() ); + int level2Category = indexLevel2 % int( categorisedStyles[level1Category].size() ); + + return categorisedStyles[level1Category][level2Category]; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuPlotCurveSymbol::PointSymbolEnum RiuPlotCurveSymbol::cycledSymbolStyle( int indexLevel ) +{ + std::vector contrastingSymbols = { SYMBOL_ELLIPSE, + SYMBOL_CROSS, + SYMBOL_RECT, + SYMBOL_DOWN_TRIANGLE, + SYMBOL_UP_TRIANGLE, + SYMBOL_LEFT_TRIANGLE, + SYMBOL_RIGHT_TRIANGLE, + SYMBOL_STAR2, + SYMBOL_DIAMOND, + SYMBOL_STAR1 }; + + return contrastingSymbols[indexLevel % (int)contrastingSymbols.size()]; +} + +//-------------------------------------------------------------------------------------------------- +/// Is this a symbol with an interior and a border? If false, it is just lines. +//-------------------------------------------------------------------------------------------------- +bool RiuPlotCurveSymbol::isFilledSymbol( PointSymbolEnum symbol ) +{ + return symbol != SYMBOL_NONE && symbol != SYMBOL_CROSS && symbol != SYMBOL_XCROSS && symbol != SYMBOL_STAR1; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QRect RiuPlotCurveSymbol::labelBoundingRect( const QPainter* painter, const QRect& symbolRect, const QString& label ) const +{ + CVF_ASSERT( painter ); + + QPoint symbolPosition = symbolRect.topLeft(); + + int symbolWidth = symbolRect.width(); + int symbolHeight = symbolRect.height(); + + int labelWidth = painter->fontMetrics().horizontalAdvance( label ); + int labelHeight = painter->fontMetrics().height(); + + QPoint labelPosition; + if ( m_labelPosition == LabelAboveSymbol ) + { + labelPosition = QPoint( symbolPosition.x() - labelWidth / 2, symbolPosition.y() - 5 ); + } + else if ( m_labelPosition == LabelBelowSymbol ) + { + labelPosition = QPoint( symbolPosition.x() - labelWidth / 2, symbolPosition.y() + symbolHeight + 5 ); + } + else if ( m_labelPosition == LabelLeftOfSymbol ) + { + labelPosition = QPoint( symbolPosition.x() - labelWidth - symbolWidth, symbolPosition.y() ); + } + else if ( m_labelPosition == LabelRightOfSymbol ) + { + labelPosition = QPoint( symbolPosition.x() + symbolWidth + 3, symbolPosition.y() ); + } + return QRect( labelPosition.x(), labelPosition.y(), labelWidth, labelHeight ); +} diff --git a/ApplicationLibCode/UserInterface/RiuPlotCurveSymbol.h b/ApplicationLibCode/UserInterface/RiuPlotCurveSymbol.h new file mode 100644 index 0000000000..93ca53d803 --- /dev/null +++ b/ApplicationLibCode/UserInterface/RiuPlotCurveSymbol.h @@ -0,0 +1,101 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Equinor ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 + +class QColor; +class QPen; +class QPainter; +class QRect; +class QPixmap; + +//-------------------------------------------------------------------------------------------------- +/// Interface for plot curve symbol +//-------------------------------------------------------------------------------------------------- +class RiuPlotCurveSymbol +{ +public: + enum LabelPosition + { + LabelAboveSymbol, + LabelBelowSymbol, + LabelLeftOfSymbol, + LabelRightOfSymbol + }; + + enum PointSymbolEnum + { + SYMBOL_NONE, + SYMBOL_ELLIPSE, + SYMBOL_RECT, + SYMBOL_DIAMOND, + SYMBOL_TRIANGLE, + SYMBOL_DOWN_TRIANGLE, + SYMBOL_CROSS, + SYMBOL_XCROSS, + SYMBOL_LEFT_ALIGNED_TRIANGLE, // Aligned so pin point is at lower right corner + SYMBOL_RIGHT_ALIGNED_TRIANGLE, // Aligned so pin point is at lower left corner + SYMBOL_LEFT_ANGLED_TRIANGLE, + SYMBOL_RIGHT_ANGLED_TRIANGLE, + SYMBOL_UP_TRIANGLE, + SYMBOL_STAR1, + SYMBOL_STAR2, + SYMBOL_HEXAGON, + SYMBOL_LEFT_TRIANGLE, + SYMBOL_RIGHT_TRIANGLE + }; + + RiuPlotCurveSymbol( PointSymbolEnum riuStyle, + const QString& label, + LabelPosition labelPosition = LabelAboveSymbol, + int labelFontSizePt = 8 ); + + QString globalLabel() const; + + void setGlobalLabel( const QString& label ); + + void setLabelPosition( LabelPosition labelPosition ); + + void setLabelFontSize( int labelFontSizePt ); + + virtual void setPixmap( const QPixmap& pixmap ) = 0; + + virtual void setSize( int width, int height ) = 0; + + virtual void setColor( const QColor& color ) = 0; + + virtual void setPen( const QPen& pen ) = 0; + + virtual QRect boundingRect() const = 0; + + static PointSymbolEnum cycledSymbolStyle( int indexLevel1, int indexLevel2 ); + static PointSymbolEnum cycledSymbolStyle( int indexLevel ); + + static bool isFilledSymbol( PointSymbolEnum symbol ); + + QRect labelBoundingRect( const QPainter* painter, const QRect& symbolRect, const QString& label ) const; + +protected: + PointSymbolEnum m_style; + QString m_globalLabel; + int m_labelFontSizePx; + LabelPosition m_labelPosition; +}; diff --git a/ApplicationLibCode/UserInterface/RiuPlotItem.h b/ApplicationLibCode/UserInterface/RiuPlotItem.h new file mode 100644 index 0000000000..e7fdb92738 --- /dev/null +++ b/ApplicationLibCode/UserInterface/RiuPlotItem.h @@ -0,0 +1,26 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +class RiuPlotItem +{ +public: + explicit RiuPlotItem(){}; + virtual ~RiuPlotItem(){}; +}; diff --git a/ApplicationLibCode/UserInterface/RiuPlotMainWindow.cpp b/ApplicationLibCode/UserInterface/RiuPlotMainWindow.cpp index b489e32637..77f3473fe6 100644 --- a/ApplicationLibCode/UserInterface/RiuPlotMainWindow.cpp +++ b/ApplicationLibCode/UserInterface/RiuPlotMainWindow.cpp @@ -26,14 +26,19 @@ #include "RiaRegressionTestRunner.h" #include "RiaSummaryTools.h" +#include "PlotBuilderCommands/RicSummaryPlotBuilder.h" + #include "RimEnsembleCurveSetCollection.h" +#include "RimMainPlotCollection.h" #include "RimMultiPlot.h" #include "RimProject.h" #include "RimSummaryCaseMainCollection.h" #include "RimSummaryCurveCollection.h" +#include "RimSummaryMultiPlot.h" +#include "RimSummaryMultiPlotCollection.h" #include "RimSummaryPlot.h" -#include "RimSummaryPlotCollection.h" #include "RimSummaryPlotFilterTextCurveSetEditor.h" +#include "RimSummaryPlotManager.h" #include "RimViewWindow.h" #include "RimWellAllocationPlot.h" #include "RimWellLogCurveCommonDataSource.h" @@ -58,7 +63,6 @@ #include "cafPdmUiPropertyView.h" #include "cafPdmUiToolBarEditor.h" #include "cafPdmUiTreeView.h" -#include "cafQTreeViewStateSerializer.h" #include "cafSelectionManager.h" #include @@ -78,7 +82,7 @@ RiuPlotMainWindow::RiuPlotMainWindow() : m_activePlotViewWindow( nullptr ) , m_windowMenu( nullptr ) { - m_mdiArea = new RiuMdiArea; + m_mdiArea = new RiuMdiArea( this ); connect( m_mdiArea, SIGNAL( subWindowActivated( QMdiSubWindow* ) ), SLOT( slotSubWindowActivated( QMdiSubWindow* ) ) ); setCentralWidget( m_mdiArea ); @@ -86,11 +90,11 @@ RiuPlotMainWindow::RiuPlotMainWindow() createToolBars(); createDockPanels(); + setAcceptDrops( true ); + // Store the layout so we can offer reset option m_initialDockAndToolbarLayout = saveState( 0 ); - m_dragDropInterface = std::unique_ptr( new RiuDragDrop() ); - if ( m_undoView ) { m_undoView->setStack( caf::CmdExecCommandManager::instance()->undoStack() ); @@ -105,6 +109,7 @@ RiuPlotMainWindow::RiuPlotMainWindow() //-------------------------------------------------------------------------------------------------- RiuPlotMainWindow::~RiuPlotMainWindow() { + m_summaryPlotManagerView->showProperties( nullptr ); setPdmRoot( nullptr ); } @@ -116,6 +121,18 @@ QString RiuPlotMainWindow::mainWindowName() return "RiuPlotMainWindow"; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuPlotMainWindow* RiuPlotMainWindow::instance() +{ + if ( RiaGuiApplication::isRunning() ) + { + return RiaGuiApplication::instance()->mainPlotWindow(); + } + return nullptr; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -129,6 +146,16 @@ void RiuPlotMainWindow::initializeGuiNewProjectLoaded() m_pdmUiPropertyView->currentObject()->uiCapability()->updateConnectedEditors(); } + auto sumPlotManager = dynamic_cast( m_summaryPlotManager.get() ); + if ( sumPlotManager ) + { + auto* obj = RiaSummaryTools::summaryCaseMainCollection(); + obj->dataSourceHasChanged.connect( sumPlotManager, &RimSummaryPlotManager::onSummaryDataSourceHasChanged ); + + sumPlotManager->resetDataSourceSelection(); + sumPlotManager->updateConnectedEditors(); + } + { auto* obj = RiaSummaryTools::summaryCaseMainCollection(); if ( obj ) @@ -138,7 +165,7 @@ void RiuPlotMainWindow::initializeGuiNewProjectLoaded() } { - auto* obj = RiaSummaryTools::summaryPlotCollection(); + auto* obj = RiaSummaryTools::summaryMultiPlotCollection(); if ( obj ) { setExpanded( obj ); @@ -181,8 +208,8 @@ void RiuPlotMainWindow::cleanupGuiBeforeProjectClose() cleanUpTemporaryWidgets(); m_wellLogPlotToolBarEditor->clear(); - m_summaryPlotToolBarEditor->clear(); m_multiPlotToolBarEditor->clear(); + m_multiPlotLayoutToolBarEditor->clear(); setWindowTitle( "Plots - ResInsight" ); } @@ -340,6 +367,8 @@ void RiuPlotMainWindow::createMenus() helpMenu->addSeparator(); helpMenu->addAction( cmdFeatureMgr->action( "RicHelpOpenUsersGuideFeature" ) ); helpMenu->addAction( cmdFeatureMgr->action( "RicSearchHelpFeature" ) ); + helpMenu->addAction( cmdFeatureMgr->action( "RicSearchIssuesHelpFeature" ) ); + helpMenu->addAction( cmdFeatureMgr->action( "RicCreateNewIssueHelpFeature" ) ); connect( helpMenu, SIGNAL( aboutToShow() ), SLOT( slotRefreshHelpActions() ) ); } @@ -409,15 +438,15 @@ void RiuPlotMainWindow::createToolBars() } } - m_wellLogPlotToolBarEditor = new caf::PdmUiToolBarEditor( "Well Log Plot", this ); + m_wellLogPlotToolBarEditor = std::make_unique( "Well Log Plot", this ); m_wellLogPlotToolBarEditor->hide(); - m_summaryPlotToolBarEditor = new caf::PdmUiToolBarEditor( "Summary Plot", this ); - m_summaryPlotToolBarEditor->hide(); - - m_multiPlotToolBarEditor = new caf::PdmUiToolBarEditor( "Multi Plot", this ); + m_multiPlotToolBarEditor = std::make_unique( "Multi Plot", this ); m_multiPlotToolBarEditor->hide(); + m_multiPlotLayoutToolBarEditor = std::make_unique( "Multi Plot Layout", this ); + m_multiPlotLayoutToolBarEditor->hide(); + if ( RiaPreferences::current()->useUndoRedo() ) { QToolBar* toolbar = addToolBar( tr( "Edit" ) ); @@ -443,40 +472,67 @@ void RiuPlotMainWindow::refreshToolbars() //-------------------------------------------------------------------------------------------------- void RiuPlotMainWindow::createDockPanels() { + const int nTreeViews = 4; + const std::vector treeViewTitles = { "Plots", "Data Sources", "Templates", "Scripts" }; + const std::vector treeViewConfigs = { "PlotWindow.Plots", + "PlotWindow.DataSources", + "PlotWindow.Templates", + "PlotWindow.Scripts" }; + const std::vector treeViewDockNames = { RiuDockWidgetTools::plotMainWindowPlotsTreeName(), + RiuDockWidgetTools::plotMainWindowDataSourceTreeName(), + RiuDockWidgetTools::plotMainWindowTemplateTreeName(), + RiuDockWidgetTools::plotMainWindowScriptsTreeName() }; + + const std::vector defaultDockWidgetArea{ Qt::LeftDockWidgetArea, + Qt::RightDockWidgetArea, + Qt::LeftDockWidgetArea, + Qt::LeftDockWidgetArea }; + + createTreeViews( nTreeViews ); + + std::vector rightTabbedWidgets; + std::vector leftTabbedWidgets; + + for ( int i = 0; i < nTreeViews; i++ ) { - QDockWidget* dockWidget = new QDockWidget( "Plot Project Tree", this ); - dockWidget->setObjectName( RiuDockWidgetTools::plotMainWindowProjectTreeName() ); + QDockWidget* dockWidget = new QDockWidget( treeViewTitles[i], this ); + dockWidget->setObjectName( treeViewDockNames[i] ); dockWidget->setAllowedAreas( Qt::AllDockWidgetAreas ); - m_projectTreeView = new caf::PdmUiTreeView( this ); - m_projectTreeView->enableSelectionManagerUpdating( true ); + caf::PdmUiTreeView* projectTree = projectTreeView( i ); + projectTree->enableSelectionManagerUpdating( true ); - m_projectTreeView->enableAppendOfClassNameToUiItemText( RiaPreferencesSystem::current()->appendClassNameToUiText() ); + projectTree->enableAppendOfClassNameToUiItemText( RiaPreferencesSystem::current()->appendClassNameToUiText() ); - dockWidget->setWidget( m_projectTreeView ); + dockWidget->setWidget( projectTree ); - m_projectTreeView->treeView()->setHeaderHidden( true ); - m_projectTreeView->treeView()->setSelectionMode( QAbstractItemView::ExtendedSelection ); + projectTree->treeView()->setHeaderHidden( true ); + projectTree->treeView()->setSelectionMode( QAbstractItemView::ExtendedSelection ); // Drag and drop configuration - m_projectTreeView->treeView()->setDragEnabled( true ); - m_projectTreeView->treeView()->viewport()->setAcceptDrops( true ); - m_projectTreeView->treeView()->setDropIndicatorShown( true ); - m_projectTreeView->treeView()->setDragDropMode( QAbstractItemView::DragDrop ); + projectTree->treeView()->setDragEnabled( true ); + projectTree->treeView()->viewport()->setAcceptDrops( true ); + projectTree->treeView()->setDropIndicatorShown( true ); + projectTree->treeView()->setDragDropMode( QAbstractItemView::DragDrop ); // Install event filter used to handle key press events - RiuTreeViewEventFilter* treeViewEventFilter = new RiuTreeViewEventFilter( this ); - m_projectTreeView->treeView()->installEventFilter( treeViewEventFilter ); + RiuTreeViewEventFilter* treeViewEventFilter = new RiuTreeViewEventFilter( this, projectTree ); + projectTree->treeView()->installEventFilter( treeViewEventFilter ); - addDockWidget( Qt::LeftDockWidgetArea, dockWidget ); + addDockWidget( defaultDockWidgetArea[i], dockWidget ); + + if ( defaultDockWidgetArea[i] == Qt::LeftDockWidgetArea ) leftTabbedWidgets.push_back( dockWidget ); + if ( defaultDockWidgetArea[i] == Qt::RightDockWidgetArea ) rightTabbedWidgets.push_back( dockWidget ); - connect( m_projectTreeView, SIGNAL( selectionChanged() ), this, SLOT( selectedObjectsChanged() ) ); - m_projectTreeView->treeView()->setContextMenuPolicy( Qt::CustomContextMenu ); - connect( m_projectTreeView->treeView(), + connect( dockWidget, SIGNAL( visibilityChanged( bool ) ), projectTree, SLOT( treeVisibilityChanged( bool ) ) ); + connect( projectTree, SIGNAL( selectionChanged() ), this, SLOT( selectedObjectsChanged() ) ); + + projectTree->treeView()->setContextMenuPolicy( Qt::CustomContextMenu ); + connect( projectTree->treeView(), SIGNAL( customContextMenuRequested( const QPoint& ) ), SLOT( customMenuRequested( const QPoint& ) ) ); - m_projectTreeView->setUiConfigurationName( "PlotWindow" ); + projectTree->setUiConfigurationName( treeViewConfigs[i] ); } { @@ -484,8 +540,8 @@ void RiuPlotMainWindow::createDockPanels() dockWidget->setObjectName( RiuDockWidgetTools::plotMainWindowPropertyEditorName() ); dockWidget->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea ); - m_pdmUiPropertyView = new caf::PdmUiPropertyView( dockWidget ); - dockWidget->setWidget( m_pdmUiPropertyView ); + m_pdmUiPropertyView = std::make_unique( dockWidget ); + dockWidget->setWidget( m_pdmUiPropertyView.get() ); addDockWidget( Qt::LeftDockWidgetArea, dockWidget ); } @@ -495,7 +551,26 @@ void RiuPlotMainWindow::createDockPanels() dockWidget->setObjectName( RiuDockWidgetTools::plotMainWindowMessagesName() ); m_messagePanel = new RiuMessagePanel( dockWidget ); dockWidget->setWidget( m_messagePanel ); - addDockWidget( Qt::BottomDockWidgetArea, dockWidget ); + splitDockWidget( rightTabbedWidgets.front(), dockWidget, Qt::Vertical ); + dockWidget->hide(); + } + + { + QDockWidget* dockWidget = new QDockWidget( "Plot Manager", this ); + dockWidget->setObjectName( RiuDockWidgetTools::summaryPlotManagerName() ); + + m_summaryPlotManagerView = std::make_unique( dockWidget ); + + auto plotManager = std::make_unique(); + m_summaryPlotManagerView->showProperties( plotManager.get() ); + m_summaryPlotManagerView->installEventFilter( plotManager.get() ); + m_summaryPlotManager = std::move( plotManager ); + + dockWidget->setWidget( m_summaryPlotManagerView.get() ); + addDockWidget( Qt::RightDockWidgetArea, dockWidget ); + + rightTabbedWidgets.push_back( dockWidget ); + dockWidget->hide(); } @@ -507,10 +582,32 @@ void RiuPlotMainWindow::createDockPanels() dockWidget->setWidget( m_undoView ); addDockWidget( Qt::RightDockWidgetArea, dockWidget ); + rightTabbedWidgets.push_back( dockWidget ); dockWidget->hide(); } + { + QDockWidget* topDock = nullptr; + for ( auto d : leftTabbedWidgets ) + { + if ( !topDock ) + topDock = d; + else + tabifyDockWidget( topDock, d ); + } + } + { + QDockWidget* topDock = nullptr; + for ( auto d : rightTabbedWidgets ) + { + if ( !topDock ) + topDock = d; + else + tabifyDockWidget( topDock, d ); + } + } + setCorner( Qt::BottomLeftCorner, Qt::LeftDockWidgetArea ); setCorner( Qt::BottomRightCorner, Qt::BottomDockWidgetArea ); @@ -634,103 +731,85 @@ void RiuPlotMainWindow::updateMultiPlotToolBar() RimMultiPlot* plotWindow = dynamic_cast( m_activePlotViewWindow.p() ); if ( plotWindow ) { - std::vector toolBarFields = { plotWindow->pagePreviewField(), - plotWindow->columnCountField(), - plotWindow->rowsPerPageField() }; - m_multiPlotToolBarEditor->setFields( toolBarFields ); - m_multiPlotToolBarEditor->updateUi(); - m_multiPlotToolBarEditor->show(); - } - else - { - m_multiPlotToolBarEditor->clear(); - m_multiPlotToolBarEditor->hide(); - } - refreshToolbars(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuPlotMainWindow::updateSummaryPlotToolBar( bool forceUpdateUi ) -{ - RimSummaryPlot* summaryPlot = dynamic_cast( m_activePlotViewWindow.p() ); - RimMultiPlot* multiPlot = dynamic_cast( m_activePlotViewWindow.p() ); - if ( multiPlot ) - { - summaryPlot = caf::SelectionManager::instance()->selectedItemOfType(); - } - - if ( summaryPlot ) - { - std::vector toolBarFields = summaryPlot->fieldsToShowInToolbar(); + std::vector toolBarFields = plotWindow->fieldsToShowInToolbar(); - QString keyword; - - if ( !m_summaryPlotToolBarEditor->isEditorDataValid( toolBarFields ) ) + if ( toolBarFields.empty() ) { - keyword = m_summaryPlotToolBarEditor->keywordForFocusWidget(); - - m_summaryPlotToolBarEditor->setFields( toolBarFields ); + m_multiPlotToolBarEditor->clear(); + m_multiPlotToolBarEditor->hide(); + } + else + { + m_multiPlotToolBarEditor->setFields( toolBarFields ); + m_multiPlotToolBarEditor->updateUi(); + m_multiPlotToolBarEditor->show(); } - m_summaryPlotToolBarEditor->updateUi( caf::PdmUiToolBarEditor::uiEditorConfigName() ); - m_summaryPlotToolBarEditor->show(); - m_summaryPlotToolBarEditor->setFocusWidgetFromKeyword( keyword ); + std::vector layoutFields = plotWindow->fieldsToShowInLayoutToolbar(); + m_multiPlotLayoutToolBarEditor->setFields( layoutFields ); + m_multiPlotLayoutToolBarEditor->updateUi(); + m_multiPlotLayoutToolBarEditor->show(); } else { - m_summaryPlotToolBarEditor->clear(); - m_summaryPlotToolBarEditor->hide(); + m_multiPlotToolBarEditor->clear(); + m_multiPlotToolBarEditor->hide(); + m_multiPlotLayoutToolBarEditor->clear(); + m_multiPlotLayoutToolBarEditor->hide(); } - refreshToolbars(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuPlotMainWindow::setFocusToLineEditInSummaryToolBar() +RicSummaryPlotEditorDialog* RiuPlotMainWindow::summaryCurveCreatorDialog( bool createIfNotPresent ) { - if ( m_summaryPlotToolBarEditor ) + if ( !m_summaryCurveCreatorDialog && createIfNotPresent ) { - m_summaryPlotToolBarEditor->setFocusWidgetFromKeyword( - RimSummaryPlotFilterTextCurveSetEditor::curveFilterFieldKeyword() ); + m_summaryCurveCreatorDialog = std::make_unique( this ); } + + return m_summaryCurveCreatorDialog.get(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RicSummaryPlotEditorDialog* RiuPlotMainWindow::summaryCurveCreatorDialog() +RicSummaryCurveCalculatorDialog* RiuPlotMainWindow::summaryCurveCalculatorDialog( bool createIfNotPresent ) { - if ( m_summaryCurveCreatorDialog.isNull() ) + if ( !m_summaryCurveCalculatorDialog && createIfNotPresent ) { - m_summaryCurveCreatorDialog = new RicSummaryPlotEditorDialog( this ); + m_summaryCurveCalculatorDialog = std::make_unique( this ); } - return m_summaryCurveCreatorDialog; + return m_summaryCurveCalculatorDialog.get(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RicSummaryCurveCalculatorDialog* RiuPlotMainWindow::summaryCurveCalculatorDialog() +RiuMessagePanel* RiuPlotMainWindow::messagePanel() { - if ( m_summaryCurveCalculatorDialog.isNull() ) - { - m_summaryCurveCalculatorDialog = new RicSummaryCurveCalculatorDialog( this ); - } - - return m_summaryCurveCalculatorDialog; + return m_messagePanel; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuMessagePanel* RiuPlotMainWindow::messagePanel() +void RiuPlotMainWindow::showAndSetKeyboardFocusToSummaryPlotManager() { - return m_messagePanel; + auto dockWidget = RiuDockWidgetTools::findDockWidget( this, RiuDockWidgetTools::summaryPlotManagerName() ); + if ( dockWidget ) + { + dockWidget->setVisible( true ); + + auto sumPlotManager = dynamic_cast( m_summaryPlotManager.get() ); + if ( sumPlotManager ) + { + sumPlotManager->setFocusToFilterText(); + } + } } //-------------------------------------------------------------------------------------------------- @@ -767,13 +846,14 @@ void RiuPlotMainWindow::initializeViewer( QMdiSubWindow* subWindow, QWidget* vie } //-------------------------------------------------------------------------------------------------- -/// This method needs to handle memory deallocation !!! +/// //-------------------------------------------------------------------------------------------------- void RiuPlotMainWindow::setPdmRoot( caf::PdmObject* pdmRoot ) { - m_projectTreeView->setPdmItem( pdmRoot ); - // For debug only : m_projectTreeView->treeView()->expandAll(); - m_projectTreeView->setDragDropInterface( m_dragDropInterface.get() ); + for ( auto tv : projectTreeViews() ) + { + tv->setPdmItem( pdmRoot ); + } } //-------------------------------------------------------------------------------------------------- @@ -790,33 +870,36 @@ void RiuPlotMainWindow::slotSubWindowActivated( QMdiSubWindow* subWindow ) if ( !isBlockingViewSelectionOnSubWindowActivated() ) { - std::vector currentSelection; - m_projectTreeView->selectedUiItems( currentSelection ); - bool childSelected = false; - for ( caf::PdmUiItem* uiItem : currentSelection ) + caf::PdmUiTreeView* projectTree = getTreeViewWithItem( activatedView ); + if ( projectTree ) { - caf::PdmObject* pdmObject = dynamic_cast( uiItem ); - if ( pdmObject ) + std::vector currentSelection; + projectTree->selectedUiItems( currentSelection ); + bool childSelected = false; + for ( caf::PdmUiItem* uiItem : currentSelection ) { - std::vector ancestralViews; - pdmObject->allAncestorsOrThisOfType( ancestralViews ); - for ( auto ancestralView : ancestralViews ) + caf::PdmObject* pdmObject = dynamic_cast( uiItem ); + if ( pdmObject ) { - if ( ancestralView == activatedView ) + std::vector ancestralViews; + pdmObject->allAncestorsOrThisOfType( ancestralViews ); + for ( auto ancestralView : ancestralViews ) { - childSelected = true; + if ( ancestralView == activatedView ) + { + childSelected = true; + } } } } - } - if ( !childSelected ) - { - selectAsCurrentItem( activatedView ); + if ( !childSelected ) + { + selectAsCurrentItem( activatedView ); + } } } updateWellLogPlotToolBar(); - updateSummaryPlotToolBar(); updateMultiPlotToolBar(); } @@ -865,8 +948,11 @@ void RiuPlotMainWindow::slotBuildWindowActions() //-------------------------------------------------------------------------------------------------- void RiuPlotMainWindow::selectedObjectsChanged() { + caf::PdmUiTreeView* projectTree = dynamic_cast( sender() ); + if ( !projectTree ) return; + std::vector uiItems; - m_projectTreeView->selectedUiItems( uiItems ); + projectTree->selectedUiItems( uiItems ); caf::PdmObjectHandle* firstSelectedObject = nullptr; if ( !uiItems.empty() ) @@ -917,18 +1003,25 @@ void RiuPlotMainWindow::selectedObjectsChanged() if ( firstSelectedObject ) { - RimSummaryPlot* summaryPlot = nullptr; - firstSelectedObject->firstAncestorOrThisOfType( summaryPlot ); - if ( summaryPlot ) + RimSummaryMultiPlot* multiSummaryPlot = nullptr; + firstSelectedObject->firstAncestorOrThisOfType( multiSummaryPlot ); + if ( multiSummaryPlot ) { - updateSummaryPlotToolBar(); + updateMultiPlotToolBar(); + + RimSummaryPlot* summaryPlot = nullptr; + firstSelectedObject->firstAncestorOrThisOfType( summaryPlot ); + if ( summaryPlot ) + { + multiSummaryPlot->makeSureIsVisible( summaryPlot ); + } } } // The only way to get to this code is by selection change initiated from the project tree view // As we are activating an MDI-window, the focus is given to this MDI-window // Set focus back to the tree view to be able to continue keyboard tree view navigation - m_projectTreeView->treeView()->setFocus(); + projectTree->treeView()->setFocus(); } } } @@ -938,24 +1031,8 @@ void RiuPlotMainWindow::selectedObjectsChanged() //-------------------------------------------------------------------------------------------------- void RiuPlotMainWindow::restoreTreeViewState() { - if ( m_projectTreeView ) - { - QString stateString = RimProject::current()->plotWindowTreeViewState; - if ( !stateString.isEmpty() ) - { - m_projectTreeView->treeView()->collapseAll(); - caf::QTreeViewStateSerializer::applyTreeViewStateFromString( m_projectTreeView->treeView(), stateString ); - } - - QString currentIndexString = RimProject::current()->plotWindowCurrentModelIndexPath; - if ( !currentIndexString.isEmpty() ) - { - QModelIndex mi = - caf::QTreeViewStateSerializer::getModelIndexFromString( m_projectTreeView->treeView()->model(), - currentIndexString ); - m_projectTreeView->treeView()->setCurrentIndex( mi ); - } - } + restoreTreeViewStates( RimProject::current()->plotWindowTreeViewStates(), + RimProject::current()->plotWindowCurrentModelIndexPaths() ); } //-------------------------------------------------------------------------------------------------- @@ -1079,3 +1156,26 @@ bool RiuPlotMainWindow::isAnyMdiSubWindowVisible() { return m_mdiArea->subWindowList().size() > 0; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuPlotMainWindow::dragEnterEvent( QDragEnterEvent* event ) +{ + QPoint curpos = m_mdiArea->mapFromGlobal( QCursor::pos() ); + + if ( m_mdiArea->rect().contains( curpos ) ) event->acceptProposedAction(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuPlotMainWindow::dropEvent( QDropEvent* event ) +{ + std::vector objects; + + if ( RiuDragDrop::handleGenericDropEvent( event, objects ) ) + { + RicSummaryPlotBuilder::createAndAppendSummaryMultiPlot( objects ); + } +} diff --git a/ApplicationLibCode/UserInterface/RiuPlotMainWindow.h b/ApplicationLibCode/UserInterface/RiuPlotMainWindow.h index 8d33de1fcf..53759b548e 100644 --- a/ApplicationLibCode/UserInterface/RiuPlotMainWindow.h +++ b/ApplicationLibCode/UserInterface/RiuPlotMainWindow.h @@ -22,7 +22,6 @@ #include "RiuMdiArea.h" #include "cafPdmPointer.h" -#include "cafPdmUiDragDropInterface.h" #include @@ -59,6 +58,8 @@ class RiuPlotMainWindow : public RiuMainWindowBase RiuPlotMainWindow(); ~RiuPlotMainWindow() override; + static RiuPlotMainWindow* instance(); + QString mainWindowName() override; void initializeGuiNewProjectLoaded(); @@ -86,17 +87,19 @@ class RiuPlotMainWindow : public RiuMainWindowBase void updateWellLogPlotToolBar(); void updateMultiPlotToolBar(); - void updateSummaryPlotToolBar( bool forceUpdateUi = false ); - void setFocusToLineEditInSummaryToolBar(); - RicSummaryPlotEditorDialog* summaryCurveCreatorDialog(); - RicSummaryCurveCalculatorDialog* summaryCurveCalculatorDialog(); + RicSummaryPlotEditorDialog* summaryCurveCreatorDialog( bool createIfNotPresent ); + RicSummaryCurveCalculatorDialog* summaryCurveCalculatorDialog( bool createIfNotPresent ); RiuMessagePanel* messagePanel(); + void showAndSetKeyboardFocusToSummaryPlotManager(); + protected: void closeEvent( QCloseEvent* event ) override; void keyPressEvent( QKeyEvent* ) override; + void dragEnterEvent( QDragEnterEvent* event ) override; + void dropEvent( QDropEvent* event ) override; private: void setPdmRoot( caf::PdmObject* pdmRoot ); @@ -131,15 +134,16 @@ private slots: QMenu* m_windowMenu; - caf::PdmUiToolBarEditor* m_wellLogPlotToolBarEditor; - caf::PdmUiToolBarEditor* m_multiPlotToolBarEditor; - caf::PdmUiToolBarEditor* m_summaryPlotToolBarEditor; - std::unique_ptr m_dragDropInterface; + std::unique_ptr m_wellLogPlotToolBarEditor; + std::unique_ptr m_multiPlotToolBarEditor; + std::unique_ptr m_multiPlotLayoutToolBarEditor; - caf::PdmUiPropertyView* m_pdmUiPropertyView; + std::unique_ptr m_pdmUiPropertyView; + std::unique_ptr m_summaryPlotManagerView; - QPointer m_summaryCurveCreatorDialog; - QPointer m_summaryCurveCalculatorDialog; + std::unique_ptr m_summaryCurveCreatorDialog; + std::unique_ptr m_summaryCurveCalculatorDialog; + std::unique_ptr m_summaryPlotManager; std::vector m_temporaryWidgets; }; diff --git a/ApplicationLibCode/UserInterface/RiuPlotMainWindowTools.cpp b/ApplicationLibCode/UserInterface/RiuPlotMainWindowTools.cpp index 60390a91e2..262ed61c9d 100644 --- a/ApplicationLibCode/UserInterface/RiuPlotMainWindowTools.cpp +++ b/ApplicationLibCode/UserInterface/RiuPlotMainWindowTools.cpp @@ -83,6 +83,21 @@ void RiuPlotMainWindowTools::toggleItemInSelection( const caf::PdmObject* object } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuPlotMainWindowTools::selectOrToggleObject( const caf::PdmObject* object, bool toggle ) +{ + if ( toggle ) + { + RiuPlotMainWindowTools::toggleItemInSelection( object ); + } + else + { + RiuPlotMainWindowTools::selectAsCurrentItem( object ); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -94,7 +109,6 @@ void RiuPlotMainWindowTools::refreshToolbars() if ( mpw ) { - mpw->updateSummaryPlotToolBar(); mpw->updateWellLogPlotToolBar(); mpw->updateMultiPlotToolBar(); } diff --git a/ApplicationLibCode/UserInterface/RiuPlotMainWindowTools.h b/ApplicationLibCode/UserInterface/RiuPlotMainWindowTools.h index 0cd9aa5f4c..38da6f5cb6 100644 --- a/ApplicationLibCode/UserInterface/RiuPlotMainWindowTools.h +++ b/ApplicationLibCode/UserInterface/RiuPlotMainWindowTools.h @@ -34,5 +34,6 @@ class RiuPlotMainWindowTools static void setExpanded( const caf::PdmUiItem* uiItem, bool expanded = true ); static void selectAsCurrentItem( const caf::PdmObject* object, bool allowActiveViewChange = true ); static void toggleItemInSelection( const caf::PdmObject* object, bool allowActiveViewChange = true ); + static void selectOrToggleObject( const caf::PdmObject* object, bool toggle ); static void refreshToolbars(); }; diff --git a/ApplicationLibCode/UserInterface/RiuPlotWidget.cpp b/ApplicationLibCode/UserInterface/RiuPlotWidget.cpp new file mode 100644 index 0000000000..1fd7ea5437 --- /dev/null +++ b/ApplicationLibCode/UserInterface/RiuPlotWidget.cpp @@ -0,0 +1,287 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "RiuQwtPlotWidget.h" + +#include "RiaGuiApplication.h" +#include "RiaPlotDefines.h" +#include "RiaPlotWindowRedrawScheduler.h" + +#include "RimMimeData.h" +#include "RimPlot.h" +#include "RimProject.h" + +#include "RiuDragDrop.h" +#include "RiuDraggableOverlayFrame.h" +#include "RiuPlotMainWindow.h" + +#include "cafAssert.h" + +#include +#include + +#include +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuPlotWidget::RiuPlotWidget( RimPlot* plotDefinition, QWidget* parent ) + : QWidget( parent ) + , m_plotDefinition( plotDefinition ) + , m_overlayMargins( 5 ) + , m_plotTitle( "" ) + , m_plotTitleEnabled( true ) +{ + CAF_ASSERT( m_plotDefinition ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuPlotWidget::~RiuPlotWidget() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimPlot* RiuPlotWidget::plotDefinition() +{ + return m_plotDefinition; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiuPlotWidget::isChecked() const +{ + if ( m_plotDefinition ) + { + return m_plotDefinition->showWindow(); + } + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RiuPlotWidget::colSpan() const +{ + if ( m_plotDefinition ) + { + return m_plotDefinition->colSpan(); + } + return 1; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RiuPlotWidget::rowSpan() const +{ + if ( m_plotDefinition ) + { + return m_plotDefinition->rowSpan(); + } + return 1; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const QString& RiuPlotWidget::plotTitle() const +{ + return m_plotTitle; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuPlotWidget::setPlotTitleEnabled( bool enabled ) +{ + m_plotTitleEnabled = enabled; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiuPlotWidget::plotTitleEnabled() const +{ + return m_plotTitleEnabled; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QPoint RiuPlotWidget::dragStartPosition() const +{ + return m_clickPosition; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuPlotWidget::scheduleReplot() +{ + RiaPlotWindowRedrawScheduler::instance()->schedulePlotWidgetReplot( this ); +} + +//-------------------------------------------------------------------------------------------------- +/// Adds an overlay frame. The overlay frame becomes the responsibility of the plot widget +//-------------------------------------------------------------------------------------------------- +void RiuPlotWidget::addOverlayFrame( RiuDraggableOverlayFrame* overlayFrame ) +{ + if ( std::find( m_overlayFrames.begin(), m_overlayFrames.end(), overlayFrame ) == m_overlayFrames.end() ) + { + overlayFrame->setParent( getParentForOverlay() ); + m_overlayFrames.push_back( overlayFrame ); + updateLayout(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// Remove the overlay widget. The frame becomes the responsibility of the caller +//-------------------------------------------------------------------------------------------------- +void RiuPlotWidget::removeOverlayFrame( RiuDraggableOverlayFrame* overlayFrame ) +{ + CAF_ASSERT( overlayFrame ); + + overlayFrame->hide(); + overlayFrame->setParent( nullptr ); + m_overlayFrames.removeOne( overlayFrame ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuPlotWidget::removeEventFilter() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuPlotWidget::updateOverlayFrameLayout() +{ + const int spacing = 5; + + int xpos = spacing; + int ypos = spacing; + int widthOfCurrentColumn = 0; + + QSize canvasSize = getParentForOverlay()->size(); + QSize maxFrameSize( canvasSize.width() - 2 * m_overlayMargins, canvasSize.height() - 2 * m_overlayMargins ); + + for ( RiuDraggableOverlayFrame* frame : m_overlayFrames ) + { + if ( frame ) + { + QSize minFrameSize = frame->minimumSizeHint(); + QSize desiredFrameSize = frame->sizeHint(); + + int width = std::min( std::max( minFrameSize.width(), desiredFrameSize.width() ), maxFrameSize.width() ); + int height = std::min( std::max( minFrameSize.height(), desiredFrameSize.height() ), maxFrameSize.height() ); + + frame->resize( width, height ); + + if ( frame->anchorCorner() == RiuDraggableOverlayFrame::AnchorCorner::TopLeft ) + { + if ( ypos + frame->height() + spacing > getParentForOverlay()->height() && widthOfCurrentColumn > 0 ) + { + xpos += spacing + widthOfCurrentColumn; + ypos = spacing; + widthOfCurrentColumn = 0; + } + frame->move( xpos, ypos ); + ypos += frame->height() + spacing; + widthOfCurrentColumn = std::max( widthOfCurrentColumn, frame->width() ); + } + else if ( frame->anchorCorner() == RiuDraggableOverlayFrame::AnchorCorner::TopRight ) + { + QRect frameRect = frame->frameGeometry(); + QRect canvasRect = getParentForOverlay()->rect(); + QPoint canvasTopRight = canvasRect.topRight(); + frameRect.moveTopRight( QPoint( canvasTopRight.x() - spacing, canvasTopRight.y() + spacing ) ); + frame->move( frameRect.topLeft() ); + } + frame->show(); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiuPlotWidget::handleDragDropEvent( QEvent* event ) +{ + if ( !event ) return false; + + if ( event->type() == QEvent::DragEnter ) + { + auto dragEnterEvent = dynamic_cast( event ); + if ( dragEnterEvent ) + { + dragEnterEvent->acceptProposedAction(); + + return true; + } + } + + std::vector objects; + + if ( RiuDragDrop::handleGenericDropEvent( event, objects ) ) + { + if ( m_plotDefinition ) m_plotDefinition->handleDroppedObjects( objects ); + return true; + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RiuPlotWidget::overlayMargins() const +{ + return m_overlayMargins; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimViewWindow* RiuPlotWidget::ownerViewWindow() const +{ + return m_plotDefinition; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RiuPlotWidget::defaultMinimumWidth() +{ + return 80; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuPlotWidget::updateZoomDependentCurveProperties() +{ +} diff --git a/ApplicationLibCode/UserInterface/RiuPlotWidget.h b/ApplicationLibCode/UserInterface/RiuPlotWidget.h new file mode 100644 index 0000000000..fd2bcd16cc --- /dev/null +++ b/ApplicationLibCode/UserInterface/RiuPlotWidget.h @@ -0,0 +1,206 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "RiaPlotDefines.h" +#include "RiuInterfaceToViewWindow.h" +#include "RiuPlotAxis.h" + +#include "cafPdmObject.h" +#include "cafPdmPointer.h" + +#include +#include + +class RiaPlotWindowRedrawScheduler; +class RimPlot; +class RimPlotCurve; + +class RiuDraggableOverlayFrame; +class RiuPlotCurve; + +class QPainter; +class QPaintDevice; + +//================================================================================================== +// +// +// +//================================================================================================== +class RiuPlotWidget : public QWidget, public RiuInterfaceToViewWindow +{ + Q_OBJECT + +public: + enum class AxisScaleType + { + LINEAR, + LOGARITHMIC, + DATE + }; + + enum class Legend + { + BOTTOM, + TOP, + LEFT, + RIGHT + }; + + enum class PlotItemType + { + CURVE, + LEGEND + }; + + RiuPlotWidget( RimPlot* plotDefinition, QWidget* parent = nullptr ); + ~RiuPlotWidget() override; + + RimPlot* plotDefinition(); + + bool isChecked() const; + + int colSpan() const; + int rowSpan() const; + + virtual int axisTitleFontSize( RiuPlotAxis axis ) const = 0; + virtual int axisValueFontSize( RiuPlotAxis axis ) const = 0; + virtual void setAxisFontsAndAlignment( RiuPlotAxis, + int titleFontSize, + int valueFontSize, + bool titleBold = false, + int alignment = (int)Qt::AlignCenter ) = 0; + virtual void setAxesFontsAndAlignment( int titleFontSize, + int valueFontSize, + bool titleBold = false, + int alignment = (int)Qt::AlignCenter ) = 0; + + virtual void enableAxisNumberLabels( RiuPlotAxis axis, bool isEnabled ) = 0; + virtual void enableAxis( RiuPlotAxis axis, bool isEnabled ) = 0; + virtual bool axisEnabled( RiuPlotAxis axis ) const = 0; + + virtual void setAxisScale( RiuPlotAxis axis, double min, double max ) = 0; + virtual void setAxisAutoScale( RiuPlotAxis axis, bool enable ) = 0; + + virtual void setAxisMaxMinor( RiuPlotAxis axis, int maxMinor ) = 0; + virtual void setAxisMaxMajor( RiuPlotAxis axis, int maxMajor ) = 0; + + virtual RiuPlotWidget::AxisScaleType axisScaleType( RiuPlotAxis axis ) const = 0; + virtual void setAxisScaleType( RiuPlotAxis axis, RiuPlotWidget::AxisScaleType axisScaleType ) = 0; + + virtual void setAxisTitleText( RiuPlotAxis axis, const QString& title ) = 0; + virtual void setAxisTitleEnabled( RiuPlotAxis axis, bool enable ) = 0; + + virtual bool isMultiAxisSupported() const = 0; + virtual RiuPlotAxis createNextPlotAxis( RiaDefines::PlotAxis axis ) = 0; + virtual void pruneAxes( const std::set& usedAxes ) = 0; + virtual void moveAxis( RiuPlotAxis oldAxis, RiuPlotAxis newAxis ) = 0; + + virtual void setPlotTitle( const QString& plotTitle ) = 0; + const QString& plotTitle() const; + void setPlotTitleEnabled( bool enabled ); + bool plotTitleEnabled() const; + virtual void setPlotTitleFontSize( int titleFontSize ) = 0; + + virtual void setLegendFontSize( int fontSize ) = 0; + virtual void setInternalLegendVisible( bool visible ) = 0; + virtual void insertLegend( RiuPlotWidget::Legend ) = 0; + virtual void clearLegend() = 0; + virtual void updateLegend() = 0; + + virtual void detachItems( RiuPlotWidget::PlotItemType plotItemType ) = 0; + + virtual std::pair axisRange( RiuPlotAxis axis ) const = 0; + virtual void setAxisRange( RiuPlotAxis axis, double min, double max ) = 0; + + virtual void setAxisInverted( RiuPlotAxis axis, bool isInverted ) = 0; + virtual void setAxisLabelsAndTicksEnabled( RiuPlotAxis axis, bool enableLabels, bool enableTicks ) = 0; + + virtual void enableGridLines( RiuPlotAxis axis, bool majorGridLines, bool minorGridLines ) = 0; + + virtual void setMajorAndMinorTickIntervals( RiuPlotAxis axis, + double majorTickInterval, + double minorTickInterval, + double minValue, + double maxValue ) = 0; + virtual void setMajorAndMinorTickIntervalsAndRange( RiuPlotAxis axis, + double majorTickInterval, + double minorTickInterval, + double minTickValue, + double maxTickValue, + double rangeMin, + double rangeMax ) = 0; + + virtual void + setAutoTickIntervalCounts( RiuPlotAxis axis, int maxMajorTickIntervalCount, int maxMinorTickIntervalCount ) = 0; + + virtual double majorTickInterval( RiuPlotAxis axis ) const = 0; + virtual double minorTickInterval( RiuPlotAxis axis ) const = 0; + + virtual int axisExtent( RiuPlotAxis axis ) const = 0; + + virtual void ensureAxisIsCreated( RiuPlotAxis axis ) = 0; + + QPoint dragStartPosition() const; + + void scheduleReplot(); + virtual void replot() = 0; + + void addOverlayFrame( RiuDraggableOverlayFrame* overlayWidget ); + void removeOverlayFrame( RiuDraggableOverlayFrame* overlayWidget ); + virtual void updateLayout() = 0; + + virtual void renderTo( QPainter* painter, const QRect& targetRect, double scaling ) = 0; + virtual void renderTo( QPaintDevice* painter, const QRect& targetRect ) = 0; + int overlayMargins() const; + + RimViewWindow* ownerViewWindow() const override; + + virtual void removeEventFilter(); + + virtual void updateAxes() = 0; + + virtual RiuPlotCurve* createPlotCurve( RimPlotCurve* ownerRimCurve, const QString& title, const QColor& color ) = 0; + + virtual const QColor& backgroundColor() const = 0; + + virtual QWidget* getParentForOverlay() const = 0; + + virtual std::pair findClosestCurve( const QPoint& pos, double& distanceToClick ) const = 0; + + virtual void updateZoomDependentCurveProperties(); + +protected: + void updateOverlayFrameLayout(); + + bool handleDragDropEvent( QEvent* event ); + + static int defaultMinimumWidth(); + + caf::PdmPointer m_plotDefinition; + QPoint m_clickPosition; + std::map m_axisTitles; + std::map m_axisTitlesEnabled; + const int m_overlayMargins; + QString m_plotTitle; + bool m_plotTitleEnabled; + + QList> m_overlayFrames; +}; diff --git a/ApplicationLibCode/UserInterface/RiuProjectPropertyView.cpp b/ApplicationLibCode/UserInterface/RiuProjectPropertyView.cpp index b157e60876..eb38dcf905 100644 --- a/ApplicationLibCode/UserInterface/RiuProjectPropertyView.cpp +++ b/ApplicationLibCode/UserInterface/RiuProjectPropertyView.cpp @@ -43,7 +43,7 @@ RiuProjectAndPropertyView::RiuProjectAndPropertyView( QWidget* parent, Qt::Windo m_projectTreeView->enableSelectionManagerUpdating( true ); // Install event filter used to handle key press events - RiuTreeViewEventFilter* treeViewEventFilter = new RiuTreeViewEventFilter( this ); + RiuTreeViewEventFilter* treeViewEventFilter = new RiuTreeViewEventFilter( this, m_projectTreeView ); m_projectTreeView->treeView()->installEventFilter( treeViewEventFilter ); // Drag and drop configuration diff --git a/ApplicationLibCode/UserInterface/RiuProjectPropertyView.h b/ApplicationLibCode/UserInterface/RiuProjectPropertyView.h index 981ca5b825..8e3855a26d 100644 --- a/ApplicationLibCode/UserInterface/RiuProjectPropertyView.h +++ b/ApplicationLibCode/UserInterface/RiuProjectPropertyView.h @@ -33,7 +33,7 @@ class PdmObjectHandle; class RiuProjectAndPropertyView : public QWidget { public: - RiuProjectAndPropertyView( QWidget* parent = nullptr, Qt::WindowFlags f = nullptr ); + RiuProjectAndPropertyView( QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags() ); void setPdmItem( caf::PdmUiItem* object ); void showProperties( caf::PdmObjectHandle* object ); @@ -41,4 +41,4 @@ class RiuProjectAndPropertyView : public QWidget private: caf::PdmUiTreeView* m_projectTreeView; caf::PdmUiPropertyView* m_propertyView; -}; \ No newline at end of file +}; diff --git a/ApplicationLibCode/UserInterface/RiuPvtPlotPanel.cpp b/ApplicationLibCode/UserInterface/RiuPvtPlotPanel.cpp index 15419d3f20..d3e19c9daa 100644 --- a/ApplicationLibCode/UserInterface/RiuPvtPlotPanel.cpp +++ b/ApplicationLibCode/UserInterface/RiuPvtPlotPanel.cpp @@ -38,6 +38,7 @@ #include "qwt_plot_marker.h" #include "qwt_plot_picker.h" #include "qwt_symbol.h" +#include "qwt_text.h" #include #include @@ -142,22 +143,22 @@ void RiuPvtPlotWidget::setPlotDefaults( QwtPlot* plot ) // Axis number font { - QFont axisFont = plot->axisFont( QwtPlot::xBottom ); + QFont axisFont = plot->axisFont( QwtAxis::XBottom ); axisFont.setPointSize( 8 ); - plot->setAxisFont( QwtPlot::xBottom, axisFont ); - plot->setAxisFont( QwtPlot::yLeft, axisFont ); + plot->setAxisFont( QwtAxis::XBottom, axisFont ); + plot->setAxisFont( QwtAxis::YLeft, axisFont ); } // Axis title font { - QwtText axisTitle = plot->axisTitle( QwtPlot::xBottom ); + QwtText axisTitle = plot->axisTitle( QwtAxis::XBottom ); QFont axisTitleFont = axisTitle.font(); axisTitleFont.setPointSize( 8 ); axisTitleFont.setBold( false ); axisTitle.setFont( axisTitleFont ); axisTitle.setRenderFlags( Qt::AlignRight ); - plot->setAxisTitle( QwtPlot::xBottom, axisTitle ); - plot->setAxisTitle( QwtPlot::yLeft, axisTitle ); + plot->setAxisTitle( QwtAxis::XBottom, axisTitle ); + plot->setAxisTitle( QwtAxis::YLeft, axisTitle ); } // Title font @@ -169,8 +170,8 @@ void RiuPvtPlotWidget::setPlotDefaults( QwtPlot* plot ) plot->setTitle( plotTitle ); } - plot->setAxisMaxMinor( QwtPlot::xBottom, 2 ); - plot->setAxisMaxMinor( QwtPlot::yLeft, 3 ); + plot->setAxisMaxMinor( QwtAxis::XBottom, 2 ); + plot->setAxisMaxMinor( QwtAxis::YLeft, 3 ); plot->plotLayout()->setAlignCanvasToScales( true ); } @@ -309,9 +310,9 @@ void RiuPvtPlotWidget::plotCurves( RiaDefines::EclipseUnitSystem m_qwtPlot->setTitle( plotTitle ); - m_qwtPlot->setAxisTitle( QwtPlot::xBottom, + m_qwtPlot->setAxisTitle( QwtAxis::XBottom, QString( "Pressure [%1]" ).arg( RiaEclipseUnitTools::unitStringPressure( unitSystem ) ) ); - m_qwtPlot->setAxisTitle( QwtPlot::yLeft, yAxisTitle ); + m_qwtPlot->setAxisTitle( QwtAxis::YLeft, yAxisTitle ); updateTrackerPlotMarkerAndLabelFromPicker(); diff --git a/ApplicationLibCode/UserInterface/RiuQtChartView.cpp b/ApplicationLibCode/UserInterface/RiuQtChartView.cpp index df58794e72..fe81705a6b 100644 --- a/ApplicationLibCode/UserInterface/RiuQtChartView.cpp +++ b/ApplicationLibCode/UserInterface/RiuQtChartView.cpp @@ -27,7 +27,7 @@ RiuQtChartView::RiuQtChartView( RimPlotWindow* plotWindow, QWidget* parent ) : QtCharts::QChartView( parent ) , m_plotWindow( plotWindow ) { - CAF_ASSERT( m_plotWindow ); + setMouseTracking( true ); } //-------------------------------------------------------------------------------------------------- @@ -44,3 +44,63 @@ RimViewWindow* RiuQtChartView::ownerViewWindow() const { return m_plotWindow; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartView::mousePressEvent( QMouseEvent* event ) +{ + if ( event->button() == Qt::MiddleButton ) + { + m_isPanning = true; + m_panStartPosition = event->pos(); + setCursor( Qt::ClosedHandCursor ); + event->accept(); + } + else + { + QtCharts::QChartView::mousePressEvent( event ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartView::mouseReleaseEvent( QMouseEvent* event ) +{ + if ( event->button() == Qt::MiddleButton ) + { + m_isPanning = false; + setCursor( Qt::ArrowCursor ); + event->accept(); + } + else + { + if ( event->button() == Qt::RightButton ) + { + // Skip QtCharts::QChartView::mouseReleaseEvent() to avoid zoom on right mouse button + return QGraphicsView::mouseReleaseEvent( event ); + } + + QtCharts::QChartView::mouseReleaseEvent( event ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartView::mouseMoveEvent( QMouseEvent* event ) +{ + if ( event->buttons() & Qt::MiddleButton && m_isPanning ) + { + QPoint newPosition = event->pos(); + QPointF delta = mapToScene( newPosition ) - mapToScene( m_panStartPosition ); + chart()->scroll( -delta.x(), delta.y() ); + m_panStartPosition = newPosition; + event->accept(); + } + else + { + QtCharts::QChartView::mouseMoveEvent( event ); + } +} diff --git a/ApplicationLibCode/UserInterface/RiuQtChartView.h b/ApplicationLibCode/UserInterface/RiuQtChartView.h index 34a1dc5f54..9edea6bca5 100644 --- a/ApplicationLibCode/UserInterface/RiuQtChartView.h +++ b/ApplicationLibCode/UserInterface/RiuQtChartView.h @@ -37,6 +37,14 @@ class RiuQtChartView : public QtCharts::QChartView, public RiuInterfaceToViewWin RimViewWindow* ownerViewWindow() const override; +protected: + void mouseReleaseEvent( QMouseEvent* event ) override; + void mousePressEvent( QMouseEvent* event ) override; + void mouseMoveEvent( QMouseEvent* event ) override; + private: caf::PdmPointer m_plotWindow; + + bool m_isPanning; + QPoint m_panStartPosition; }; diff --git a/ApplicationLibCode/UserInterface/RiuQtChartsPlotCurve.cpp b/ApplicationLibCode/UserInterface/RiuQtChartsPlotCurve.cpp new file mode 100644 index 0000000000..33e7313e99 --- /dev/null +++ b/ApplicationLibCode/UserInterface/RiuQtChartsPlotCurve.cpp @@ -0,0 +1,636 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiuQtChartsPlotCurve.h" + +#include "RiaPlotDefines.h" + +#include "RiuQtChartsPlotCurveSymbol.h" +#include "RiuQtChartsPlotWidget.h" + +#include "cvfBoundingBox.h" + +#include +#include +#include +#include +#include + +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuQtChartsPlotCurve::RiuQtChartsPlotCurve( RimPlotCurve* ownerRimCurve, const QString& title ) + : RiuPlotCurve( ownerRimCurve, title ) +{ + m_plotWidget = nullptr; + + m_lineSeries = new QtCharts::QLineSeries(); + m_lineSeries->setName( title ); + + m_areaSeries = new QtCharts::QAreaSeries(); + m_areaSeries->setName( title ); + + m_scatterSeries = new QtCharts::QScatterSeries(); + m_scatterSeries->setName( title ); + + m_axisX = RiuPlotAxis::defaultBottom(); + m_axisY = RiuPlotAxis::defaultLeft(); + + m_isVisibleInLegend = false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuQtChartsPlotCurve::~RiuQtChartsPlotCurve() +{ + if ( m_plotWidget && m_plotWidget->qtChart() ) + { + m_plotWidget->detach( this ); + + auto* line = lineSeries(); + if ( line ) + { + m_plotWidget->qtChart()->removeSeries( line ); + + // removeSeries() releases chart ownership of the data, delete data to avoid memory leak + delete line; + } + + auto* area = areaSeries(); + if ( area ) + { + m_plotWidget->qtChart()->removeSeries( area ); + + // removeSeries() releases chart ownership of the data, delete data to avoid memory leak + delete area; + } + + auto* scatter = scatterSeries(); + if ( scatter ) + { + m_plotWidget->qtChart()->removeSeries( scatter ); + + // removeSeries() releases chart ownership of the data, delete data to avoid memory leak + delete scatter; + } + } + + // Delete if it is still owned by by plot curve + delete m_lineSeries; + m_lineSeries = nullptr; + + delete m_areaSeries; + m_areaSeries = nullptr; + + delete m_scatterSeries; + m_scatterSeries = nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotCurve::setTitle( const QString& title ) +{ + if ( !isQtChartObjectsPresent() ) return; + + lineSeries()->setName( title ); + areaSeries()->setName( title ); + scatterSeries()->setName( title ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotCurve::setAppearance( RiuQwtPlotCurveDefines::LineStyleEnum lineStyle, + RiuQwtPlotCurveDefines::CurveInterpolationEnum interpolationType, + int requestedCurveThickness, + const QColor& curveColor, + const QBrush& fillBrush /* = QBrush( Qt::NoBrush )*/ ) +{ + if ( !isQtChartObjectsPresent() ) return; + + Qt::PenStyle penStyle = RiuQwtPlotCurveDefines::convertToPenStyle( lineStyle ); + + QPen curvePen( curveColor ); + curvePen.setWidth( requestedCurveThickness ); + curvePen.setStyle( penStyle ); + + lineSeries()->setPen( curvePen ); + lineSeries()->setBrush( fillBrush ); + + areaSeries()->setPen( curvePen ); + areaSeries()->setBrush( fillBrush ); + + if ( fillBrush.style() == Qt::NoBrush ) + { + lineSeries()->show(); + areaSeries()->hide(); + setVisibleInLegend( m_isVisibleInLegend ); + } + else + { + lineSeries()->hide(); + areaSeries()->show(); + setVisibleInLegend( m_isVisibleInLegend ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotCurve::setBrush( const QBrush& brush ) +{ + if ( !isQtChartObjectsPresent() ) return; + + lineSeries()->setBrush( brush ); + areaSeries()->setBrush( brush ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotCurve::setColor( const QColor& color ) +{ + QPen curvePen = lineSeries()->pen(); + curvePen.setColor( color ); + lineSeries()->setPen( curvePen ); + + curvePen = areaSeries()->pen(); + curvePen.setColor( color ); + areaSeries()->setPen( curvePen ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotCurve::attachToPlot( RiuPlotWidget* plotWidget ) +{ + m_plotWidget = dynamic_cast( plotWidget ); + CAF_ASSERT( m_plotWidget ); + + if ( m_plotWidget->getLineSeries( this ) && m_plotWidget->getScatterSeries( this ) ) + { + m_plotWidget->qtChart()->legend()->setMarkerShape( QtCharts::QLegend::MarkerShape::MarkerShapeFromSeries ); + setVisibleInLegend( true ); + + lineSeries()->show(); + } + else + { + if ( !m_lineSeries ) m_lineSeries = new QtCharts::QLineSeries(); + if ( !m_areaSeries ) m_areaSeries = new QtCharts::QAreaSeries(); + if ( !m_scatterSeries ) m_scatterSeries = new QtCharts::QScatterSeries(); + + m_plotWidget->attach( this, m_lineSeries, m_areaSeries, m_scatterSeries, m_axisX, m_axisY ); + // Plot widget takes ownership. + m_lineSeries = nullptr; + m_areaSeries = nullptr; + m_scatterSeries = nullptr; + } + + if ( scatterSeries() ) + { + if ( m_symbol ) + { + scatterSeries()->show(); + auto qtChartsSymbol = dynamic_cast( m_symbol.get() ); + CAF_ASSERT( qtChartsSymbol ); + qtChartsSymbol->applyToScatterSeries( scatterSeries() ); + } + else + { + scatterSeries()->hide(); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotCurve::detach() +{ + QtCharts::QLineSeries* line = lineSeries(); + if ( line ) + { + line->hide(); + } + + QtCharts::QAreaSeries* area = areaSeries(); + if ( area ) + { + area->hide(); + } + + if ( scatterSeries() ) + { + scatterSeries()->hide(); + } + + if ( m_plotWidget ) + { + m_plotWidget->detach( this ); + setVisibleInLegend( false ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotCurve::showInPlot() +{ + // show(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotCurve::setSamplesInPlot( const std::vector& xValues, const std::vector& yValues ) +{ + if ( !isQtChartObjectsPresent() ) return; + + CAF_ASSERT( xValues.size() == yValues.size() ); + + QVector values( static_cast( xValues.size() ) ); + + for ( int i = 0; i < static_cast( xValues.size() ); i++ ) + { + values[i] = QPointF( xValues[i], yValues[i] ); + } + + QtCharts::QLineSeries* line = lineSeries(); + line->replace( values ); + + QtCharts::QLineSeries* upper = new QtCharts::QLineSeries; + upper->replace( values ); + areaSeries()->setUpperSeries( upper ); + + updateScatterSeries(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotCurve::updateScatterSeries() +{ + if ( !scatterSeries() ) return; + + double minX = std::numeric_limits::max(); + double maxX = -std::numeric_limits::max(); + + QVector points; + + if ( lineSeries() ) + { + points = lineSeries()->pointsVector(); + + bool foundAxis = false; + + auto axes = lineSeries()->attachedAxes(); + for ( auto axis : axes ) + { + if ( axis->orientation() == Qt::Orientation::Horizontal ) + { + QtCharts::QValueAxis* valueAxis = dynamic_cast( axis ); + QtCharts::QDateTimeAxis* dateTimeAxis = dynamic_cast( axis ); + if ( valueAxis ) + { + minX = valueAxis->min(); + maxX = valueAxis->max(); + foundAxis = true; + } + else if ( dateTimeAxis ) + { + minX = dateTimeAxis->min().toMSecsSinceEpoch(); + maxX = dateTimeAxis->max().toMSecsSinceEpoch(); + foundAxis = true; + } + } + } + + if ( !foundAxis ) + { + for ( auto p : points ) + { + minX = std::min( minX, p.x() ); + maxX = std::max( maxX, p.x() ); + } + } + } + + QVector scatterValues; + if ( !points.empty() ) + { + double range = maxX - minX; + + double displaySize = 1400; + if ( m_plotWidget && m_plotWidget->qtChart() ) + { + // Use the max size since plot area can be small before the widget is shown + displaySize = std::max( displaySize, m_plotWidget->qtChart()->plotArea().width() ); + } + + double rangePerPixel = range / displaySize; + + double skipDistance = rangePerPixel * m_symbolSkipPixelDistance; + + // Always have symbol on first point + scatterValues << points[0]; + + int lastDrawnIndex = 0; + for ( int i = 1; i < static_cast( points.size() ); i++ ) + { + // Skip points until skip distance is reached + double diff = points[i].x() - points[lastDrawnIndex].x(); + + // Always add last point. + bool isLastPoint = i == points.size() - 1; + if ( diff > skipDistance || isLastPoint ) + { + scatterValues << points[i]; + lastDrawnIndex = i; + } + } + } + + scatterSeries()->replace( scatterValues ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiuQtChartsPlotCurve::isQtChartObjectsPresent() const +{ + if ( !lineSeries() ) return false; + + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotCurve::setZ( int z ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotCurve::clearErrorBars() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotCurve::updateErrorBarsAppearance( bool showErrorBars, const QColor& curveColor ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotCurve::setXAxis( RiuPlotAxis axis ) +{ + m_axisX = axis; + if ( m_plotWidget ) + { + m_plotWidget->setXAxis( axis, lineSeries(), this ); + m_plotWidget->setXAxis( axis, areaSeries(), this ); + m_plotWidget->setXAxis( axis, scatterSeries(), this ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotCurve::setYAxis( RiuPlotAxis axis ) +{ + m_axisY = axis; + if ( m_plotWidget ) + { + m_plotWidget->setYAxis( axis, lineSeries(), this ); + m_plotWidget->setYAxis( axis, areaSeries(), this ); + m_plotWidget->setYAxis( axis, scatterSeries(), this ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RiuQtChartsPlotCurve::numSamples() const +{ + if ( !lineSeries() ) return 0; + + return lineSeries()->count(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair RiuQtChartsPlotCurve::sample( int index ) const +{ + CAF_ASSERT( index >= 0 && index <= numSamples() ); + auto p = lineSeries()->at( index ); + return std::make_pair( p.x(), p.y() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair RiuQtChartsPlotCurve::xDataRange() const +{ + cvf::BoundingBox bb = computeBoundingBox(); + return std::make_pair( bb.min().x(), bb.max().x() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair RiuQtChartsPlotCurve::yDataRange() const +{ + cvf::BoundingBox bb = computeBoundingBox(); + return std::make_pair( bb.min().y(), bb.max().y() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::BoundingBox RiuQtChartsPlotCurve::computeBoundingBox() const +{ + auto points = lineSeries()->pointsVector(); + + cvf::BoundingBox bb; + for ( auto p : points ) + bb.add( cvf::Vec3d( p.x(), p.y(), 0.0 ) ); + + return bb; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotCurve::setVisibleInLegend( bool isVisibleInLegend ) +{ + if ( !m_plotWidget ) return; + + CAF_ASSERT( m_plotWidget->qtChart() ); + CAF_ASSERT( m_plotWidget->qtChart()->legend() ); + + // The markers can be set visible independent to the visibility state of the containing legend. Use the + // visibility state of the legend to override the visibility flag + if ( !m_plotWidget->qtChart()->legend()->isAttachedToChart() ) isVisibleInLegend = false; + if ( !m_plotWidget->qtChart()->legend()->isVisible() ) isVisibleInLegend = false; + + bool showScatterMarker = isVisibleInLegend && m_symbol; + bool showLineMarker = isVisibleInLegend && !m_symbol; + + auto setLegendVisibility = [this]( auto series, bool isVisible ) { + if ( series ) + { + auto markers = m_plotWidget->qtChart()->legend()->markers( series ); + if ( !markers.isEmpty() ) markers[0]->setVisible( isVisible ); + } + }; + + m_isVisibleInLegend = showLineMarker || showScatterMarker; + setLegendVisibility( lineSeries(), showLineMarker ); + setLegendVisibility( areaSeries(), false ); + setLegendVisibility( scatterSeries(), showScatterMarker ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QtCharts::QLineSeries* RiuQtChartsPlotCurve::lineSeries() const +{ + if ( m_lineSeries ) return m_lineSeries; + if ( m_plotWidget ) return dynamic_cast( m_plotWidget->getLineSeries( this ) ); + + return nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QtCharts::QScatterSeries* RiuQtChartsPlotCurve::scatterSeries() const +{ + if ( m_scatterSeries ) return m_scatterSeries; + if ( m_plotWidget ) return dynamic_cast( m_plotWidget->getScatterSeries( this ) ); + + return nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QtCharts::QAreaSeries* RiuQtChartsPlotCurve::areaSeries() const +{ + if ( m_areaSeries ) return m_areaSeries; + if ( m_plotWidget ) return dynamic_cast( m_plotWidget->getAreaSeries( this ) ); + + return nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotCurve::setSymbol( RiuPlotCurveSymbol* symbol ) +{ + if ( symbol ) + { + auto qtChartsSymbol = dynamic_cast( symbol ); + CAF_ASSERT( qtChartsSymbol ); + m_symbol.reset( symbol ); + + if ( scatterSeries() ) + { + qtChartsSymbol->applyToScatterSeries( scatterSeries() ); + updateScatterSeries(); + updateLineAndAreaSeries(); + } + } + else + { + m_symbol.reset(); + if ( scatterSeries() ) scatterSeries()->hide(); + updateLineAndAreaSeries(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotCurve::updateLineAndAreaSeries() +{ + bool isFilled = areaSeries() && areaSeries()->brush().style() != Qt::NoBrush; + bool isLine = lineSeries() && lineSeries()->pen().style() != Qt::PenStyle::NoPen; + if ( areaSeries() ) areaSeries()->setVisible( isFilled ); + if ( lineSeries() ) lineSeries()->setVisible( isLine ); + setVisibleInLegend( m_isVisibleInLegend ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuPlotCurveSymbol* RiuQtChartsPlotCurve::createSymbol( RiuPlotCurveSymbol::PointSymbolEnum symbol ) const +{ + return new RiuQtChartsPlotCurveSymbol( symbol ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotCurve::setCurveFittingTolerance( double tolerance ) +{ + // Not supported +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotCurve::setLegendIconSize( const QSize& iconSize ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QSize RiuQtChartsPlotCurve::legendIconSize() const +{ + // Default from Qwt + return QSize( 8, 8 ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QPixmap RiuQtChartsPlotCurve::legendIcon( const QSizeF& iconSize ) const +{ + return QPixmap(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotCurve::axisRangeChanged() +{ + updateScatterSeries(); +} diff --git a/ApplicationLibCode/UserInterface/RiuQtChartsPlotCurve.h b/ApplicationLibCode/UserInterface/RiuQtChartsPlotCurve.h new file mode 100644 index 0000000000..3518adf4db --- /dev/null +++ b/ApplicationLibCode/UserInterface/RiuQtChartsPlotCurve.h @@ -0,0 +1,110 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RiuPlotCurve.h" +#include "RiuQwtPlotCurveDefines.h" + +#include "cvfBoundingBox.h" + +#include +#include +#include + +class RiuQtChartsPlotWidget; +class RiuPlotCurveSymbol; + +//================================================================================================== +// +//================================================================================================== +class RiuQtChartsPlotCurve : public QObject, public RiuPlotCurve +{ + Q_OBJECT +public: + explicit RiuQtChartsPlotCurve( RimPlotCurve* ownerRimCurve, const QString& title = QString() ); + ~RiuQtChartsPlotCurve() override; + + void setTitle( const QString& title ) override; + + void setAppearance( RiuQwtPlotCurveDefines::LineStyleEnum lineStyle, + RiuQwtPlotCurveDefines::CurveInterpolationEnum interpolationType, + int curveThickness, + const QColor& curveColor, + const QBrush& fillBrush = QBrush( Qt::NoBrush ) ) override; + + void setBrush( const QBrush& brush ) override; + void setColor( const QColor& color ) override; + + void setLegendIconSize( const QSize& iconSize ) override; + QSize legendIconSize() const override; + QPixmap legendIcon( const QSizeF& size ) const override; + + void attachToPlot( RiuPlotWidget* plotWidget ) override; + void showInPlot() override; + + void setZ( int z ) override; + + void updateErrorBarsAppearance( bool showErrorBars, const QColor& curveColor ) override; + void clearErrorBars() override; + + int numSamples() const override; + std::pair sample( int index ) const override; + + std::pair xDataRange() const override; + std::pair yDataRange() const override; + + void detach() override; + + void setXAxis( RiuPlotAxis axis ) override; + void setYAxis( RiuPlotAxis axis ) override; + + void setVisibleInLegend( bool isVisibleInLegend ) override; + + void setSymbol( RiuPlotCurveSymbol* symbol ) override; + + void updateLineAndAreaSeries(); + + RiuPlotCurveSymbol* createSymbol( RiuPlotCurveSymbol::PointSymbolEnum symbol ) const override; + void setCurveFittingTolerance( double tolerance ) override; + + void updateScatterSeries(); + +public slots: + void axisRangeChanged(); + +private: + void setSamplesInPlot( const std::vector&, const std::vector& ) override; + + bool isQtChartObjectsPresent() const; + QtCharts::QLineSeries* lineSeries() const; + QtCharts::QScatterSeries* scatterSeries() const; + QtCharts::QAreaSeries* areaSeries() const; + + cvf::BoundingBox computeBoundingBox() const; + +private: + QtCharts::QLineSeries* m_lineSeries; + QtCharts::QScatterSeries* m_scatterSeries; + QtCharts::QAreaSeries* m_areaSeries; + std::shared_ptr m_symbol; + QPointer m_plotWidget; + RiuPlotAxis m_axisX; + RiuPlotAxis m_axisY; + bool m_isVisibleInLegend; +}; diff --git a/ApplicationLibCode/UserInterface/RiuQtChartsPlotCurveSymbol.cpp b/ApplicationLibCode/UserInterface/RiuQtChartsPlotCurveSymbol.cpp new file mode 100644 index 0000000000..fe91037e38 --- /dev/null +++ b/ApplicationLibCode/UserInterface/RiuQtChartsPlotCurveSymbol.cpp @@ -0,0 +1,674 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Equinor ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "RiuQtChartsPlotCurveSymbol.h" + +#include "RiaColorTools.h" +#include "RiaFontCache.h" +#include "RiaLogging.h" + +#include "RiuPlotCurveSymbol.h" +#include "cvfAssert.h" + +#include +#include +#include + +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuQtChartsPlotCurveSymbol::RiuQtChartsPlotCurveSymbol( PointSymbolEnum riuStyle, + const QString& label, + LabelPosition labelPosition, + int labelFontSizePt ) + : RiuPlotCurveSymbol( riuStyle, label, labelPosition, labelFontSizePt ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotCurveSymbol::setSize( int width, int height ) +{ + m_size = std::min( width, height ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotCurveSymbol::setColor( const QColor& color ) +{ + m_color = color; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotCurveSymbol::setPen( const QPen& pen ) +{ + m_pen = pen; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotCurveSymbol::setPixmap( const QPixmap& pixmap ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotCurveSymbol::applyToScatterSeries( QtCharts::QScatterSeries* series ) const +{ + if ( m_style == PointSymbolEnum::SYMBOL_NONE ) + { + series->hide(); + return; + } + + series->show(); + + if ( m_style == PointSymbolEnum::SYMBOL_RECT ) + { + setImageBrush( series, createRectImage() ); + } + else if ( m_style == PointSymbolEnum::SYMBOL_ELLIPSE ) + { + setImageBrush( series, createEllipseImage() ); + } + else if ( m_style == PointSymbolEnum::SYMBOL_CROSS ) + { + setImageBrush( series, createCrossImage() ); + } + else if ( m_style == PointSymbolEnum::SYMBOL_XCROSS ) + { + setImageBrush( series, createXCrossImage() ); + } + else if ( m_style == PointSymbolEnum::SYMBOL_DIAMOND ) + { + setImageBrush( series, createDiamondImage() ); + } + else if ( m_style == PointSymbolEnum::SYMBOL_HEXAGON ) + { + setImageBrush( series, createHexagonImage() ); + } + else if ( m_style == PointSymbolEnum::SYMBOL_STAR1 ) + { + setImageBrush( series, createStar1Image() ); + } + else if ( m_style == PointSymbolEnum::SYMBOL_STAR1 ) + { + setImageBrush( series, createStar1Image() ); + } + else if ( m_style == PointSymbolEnum::SYMBOL_STAR2 ) + { + setImageBrush( series, createStar2Image() ); + } + else if ( m_style == PointSymbolEnum::SYMBOL_TRIANGLE || m_style == PointSymbolEnum::SYMBOL_UP_TRIANGLE || + m_style == PointSymbolEnum::SYMBOL_DOWN_TRIANGLE || m_style == PointSymbolEnum::SYMBOL_LEFT_TRIANGLE || + m_style == PointSymbolEnum::SYMBOL_RIGHT_TRIANGLE ) + { + setImageBrush( series, createTriangleImage( m_style ) ); + } + else + { + RiaLogging::warning( "Missing symbol style." ); + } + + series->setMarkerSize( m_size ); + series->setColor( m_color ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QImage RiuQtChartsPlotCurveSymbol::image() const +{ + if ( m_style == PointSymbolEnum::SYMBOL_NONE ) + { + return QImage(); + } + + if ( m_style == PointSymbolEnum::SYMBOL_RECT ) + { + return createRectImage(); + } + else if ( m_style == PointSymbolEnum::SYMBOL_ELLIPSE ) + { + return createEllipseImage(); + } + else if ( m_style == PointSymbolEnum::SYMBOL_CROSS ) + { + return createCrossImage(); + } + else if ( m_style == PointSymbolEnum::SYMBOL_XCROSS ) + { + return createXCrossImage(); + } + else if ( m_style == PointSymbolEnum::SYMBOL_DIAMOND ) + { + return createDiamondImage(); + } + else if ( m_style == PointSymbolEnum::SYMBOL_HEXAGON ) + { + return createHexagonImage(); + } + else if ( m_style == PointSymbolEnum::SYMBOL_STAR1 ) + { + return createStar1Image(); + } + else if ( m_style == PointSymbolEnum::SYMBOL_STAR1 ) + { + return createStar1Image(); + } + else if ( m_style == PointSymbolEnum::SYMBOL_STAR2 ) + { + return createStar2Image(); + } + else if ( m_style == PointSymbolEnum::SYMBOL_TRIANGLE || m_style == PointSymbolEnum::SYMBOL_UP_TRIANGLE || + m_style == PointSymbolEnum::SYMBOL_DOWN_TRIANGLE || m_style == PointSymbolEnum::SYMBOL_LEFT_TRIANGLE || + m_style == PointSymbolEnum::SYMBOL_RIGHT_TRIANGLE ) + { + return createTriangleImage( m_style ); + } + + return QImage(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotCurveSymbol::setImageBrush( QtCharts::QScatterSeries* series, const QImage& image ) const +{ + series->setMarkerShape( QtCharts::QScatterSeries::MarkerShapeRectangle ); + series->setBrush( image ); + series->setPen( QColor( Qt::transparent ) ); +} + +//-------------------------------------------------------------------------------------------------- +/// Adapted from QwtSymbol::qwtDrawTriangleSymbols +//-------------------------------------------------------------------------------------------------- +QImage RiuQtChartsPlotCurveSymbol::createTriangleImage( RiuPlotCurveSymbol::PointSymbolEnum symbolStyle ) const +{ + QSize size( m_size, m_size ); + + QImage star( size.width(), size.height(), QImage::Format_ARGB32 ); + star.fill( Qt::transparent ); + + QPainter painter( &star ); + painter.setRenderHint( QPainter::Antialiasing ); + + QPen pen( m_pen ); + pen.setWidth( 1.0 ); + pen.setJoinStyle( Qt::MiterJoin ); + + painter.setPen( pen ); + painter.setBrush( m_color ); + + double sw2 = 0.5 * size.width(); + double sh2 = 0.5 * size.height(); + + QPolygonF triangle( 3 ); + QPointF* trianglePoints = triangle.data(); + + double x = size.width() * 0.5; + double y = size.width() * 0.5; + + const double x1 = x - sw2; + const double x2 = x1 + size.width(); + const double y1 = y - sh2; + const double y2 = y1 + size.height(); + + if ( symbolStyle == PointSymbolEnum::SYMBOL_LEFT_TRIANGLE ) + { + trianglePoints[0].rx() = x2; + trianglePoints[0].ry() = y1; + + trianglePoints[1].rx() = x1; + trianglePoints[1].ry() = y; + + trianglePoints[2].rx() = x2; + trianglePoints[2].ry() = y2; + } + + if ( symbolStyle == PointSymbolEnum::SYMBOL_RIGHT_TRIANGLE ) + { + trianglePoints[0].rx() = x1; + trianglePoints[0].ry() = y1; + + trianglePoints[1].rx() = x2; + trianglePoints[1].ry() = y; + + trianglePoints[2].rx() = x1; + trianglePoints[2].ry() = y2; + } + + if ( symbolStyle == PointSymbolEnum::SYMBOL_UP_TRIANGLE || symbolStyle == PointSymbolEnum::SYMBOL_TRIANGLE ) + { + trianglePoints[0].rx() = x1; + trianglePoints[0].ry() = y2; + + trianglePoints[1].rx() = x; + trianglePoints[1].ry() = y1; + + trianglePoints[2].rx() = x2; + trianglePoints[2].ry() = y2; + } + + if ( symbolStyle == PointSymbolEnum::SYMBOL_DOWN_TRIANGLE ) + { + trianglePoints[0].rx() = x1; + trianglePoints[0].ry() = y1; + + trianglePoints[1].rx() = x; + trianglePoints[1].ry() = y2; + + trianglePoints[2].rx() = x2; + trianglePoints[2].ry() = y1; + } + + painter.drawPolygon( triangle ); + + return star; +} + +//-------------------------------------------------------------------------------------------------- +/// Adapted from QwtSymbol::qwtDrawLineSymbols +//-------------------------------------------------------------------------------------------------- +QImage RiuQtChartsPlotCurveSymbol::createCrossImage() const +{ + const QSize size( m_size, m_size ); + + QImage image( m_size, m_size, QImage::Format_ARGB32 ); + image.fill( Qt::transparent ); + + QPainter painter( &image ); + painter.setRenderHint( QPainter::Antialiasing ); + + QPen pen( m_pen ); + pen.setWidth( 1.0 ); + pen.setJoinStyle( Qt::MiterJoin ); + + painter.setPen( pen ); + painter.setBrush( m_color ); + + const double sw = size.width(); + const double sh = size.height(); + const double sw2 = 0.5 * size.width(); + const double sh2 = 0.5 * size.height(); + + double midX = size.width() * 0.5; + double midY = size.height() * 0.5; + + { + const double x = midX - sw2; + const double y = midY; + + painter.drawLine( x, y, x + sw, y ); + } + { + const double y = midY - sh2; + const double x = midX; + + painter.drawLine( x, y, x, y + sh ); + } + + return image; +} + +//-------------------------------------------------------------------------------------------------- +/// Adapted from QwtSymbol::qwtDrawXCrossSymbols +//-------------------------------------------------------------------------------------------------- +QImage RiuQtChartsPlotCurveSymbol::createXCrossImage() const +{ + const QSize size( m_size, m_size ); + + QImage image( m_size, m_size, QImage::Format_ARGB32 ); + image.fill( Qt::transparent ); + + QPainter painter( &image ); + painter.setRenderHint( QPainter::Antialiasing ); + + QPen pen( m_pen ); + pen.setWidth( 1.0 ); + pen.setJoinStyle( Qt::MiterJoin ); + + painter.setPen( pen ); + painter.setBrush( m_color ); + + const double sw = size.width(); + const double sh = size.height(); + const double sw2 = 0.5 * size.width(); + const double sh2 = 0.5 * size.height(); + + double midX = size.width() * 0.5; + double midY = size.height() * 0.5; + + const double x1 = midX - sw2; + const double x2 = x1 + sw; + const double y1 = midY - sh2; + const double y2 = y1 + sh; + + painter.drawLine( x1, y1, x2, y2 ); + painter.drawLine( x1, y2, x2, y1 ); + + return image; +} + +//-------------------------------------------------------------------------------------------------- +/// Adapted from QwtSymbol::qwtDrawRectSymbols +//-------------------------------------------------------------------------------------------------- +QImage RiuQtChartsPlotCurveSymbol::createRectImage() const +{ + const QSize size( m_size, m_size ); + + QImage image( m_size, m_size, QImage::Format_ARGB32 ); + image.fill( Qt::transparent ); + + QPainter painter( &image ); + painter.setRenderHint( QPainter::Antialiasing ); + + QPen pen( m_pen ); + pen.setWidth( 1.0 ); + pen.setJoinStyle( Qt::MiterJoin ); + + painter.setPen( pen ); + painter.setBrush( m_color ); + + const double sw = size.width(); + const double sh = size.height(); + const double sw2 = 0.5 * size.width(); + const double sh2 = 0.5 * size.height(); + + // Mid point + const double x = sw * 0.5; + const double y = sw * 0.5; + + const QRectF r( x - sw2, y - sh2, sw, sh ); + painter.drawRect( r ); + + return image; +} + +//-------------------------------------------------------------------------------------------------- +/// Adapted from QwtSymbol::qwtDrawEllipseSymbols +//-------------------------------------------------------------------------------------------------- +QImage RiuQtChartsPlotCurveSymbol::createEllipseImage() const +{ + const QSize size( m_size, m_size ); + + QImage image( m_size, m_size, QImage::Format_ARGB32 ); + image.fill( Qt::transparent ); + + QPainter painter( &image ); + painter.setRenderHint( QPainter::Antialiasing ); + + QPen pen( m_pen ); + pen.setWidth( 1.0 ); + pen.setJoinStyle( Qt::MiterJoin ); + + painter.setPen( pen ); + painter.setBrush( m_color ); + + const double sw = size.width(); + const double sh = size.height(); + const double sw2 = 0.5 * size.width(); + const double sh2 = 0.5 * size.height(); + + // Mid point + const double x = sw * 0.5; + const double y = sw * 0.5; + + const QRectF r( x - sw2, y - sh2, sw, sh ); + painter.drawEllipse( r ); + + return image; +} + +//-------------------------------------------------------------------------------------------------- +/// Adapted from QwtSymbol::qwtDrawStar1Symbols +//-------------------------------------------------------------------------------------------------- +QImage RiuQtChartsPlotCurveSymbol::createStar1Image() const +{ + QImage image( m_size, m_size, QImage::Format_ARGB32 ); + image.fill( Qt::transparent ); + + QPainter painter( &image ); + painter.setRenderHint( QPainter::Antialiasing ); + + QPen pen( m_pen ); + pen.setWidth( 1.0 ); + pen.setJoinStyle( Qt::MiterJoin ); + + painter.setPen( pen ); + painter.setBrush( m_color ); + + QRectF r( 0, 0, m_size, m_size ); + + const double sqrt1_2 = 1.0 / sqrt( 2 ); + + const QPointF c = r.center(); + const double d1 = r.width() / 2.0 * ( 1.0 - sqrt1_2 ); + + painter.drawLine( r.left() + d1, r.top() + d1, r.right() - d1, r.bottom() - d1 ); + painter.drawLine( r.left() + d1, r.bottom() - d1, r.right() - d1, r.top() + d1 ); + painter.drawLine( c.x(), r.top(), c.x(), r.bottom() ); + painter.drawLine( r.left(), c.y(), r.right(), c.y() ); + + return image; +} + +//-------------------------------------------------------------------------------------------------- +/// Adapted from QwtSymbol::qwtDrawStar2Symbols +//-------------------------------------------------------------------------------------------------- +QImage RiuQtChartsPlotCurveSymbol::createStar2Image() const +{ + QImage image( m_size, m_size, QImage::Format_ARGB32 ); + image.fill( Qt::transparent ); + + QPainter painter( &image ); + painter.setRenderHint( QPainter::Antialiasing ); + + QPen pen( m_pen ); + pen.setWidth( 1.0 ); + pen.setJoinStyle( Qt::MiterJoin ); + + painter.setPen( pen ); + painter.setBrush( m_color ); + + QRectF r( 0, 0, m_size, m_size ); + + const double cos30 = 0.866025; // cos(30°) + + const double dy = 0.25 * m_size; + const double dx = 0.5 * m_size * cos30 / 3.0; + + QPolygonF star( 12 ); + QPointF* starPoints = star.data(); + + double x = m_size * 0.5; + double y = m_size * 0.5; + + double x1 = x - 3 * dx; + double y1 = y - 2 * dy; + + const double x2 = x1 + 1 * dx; + const double x3 = x1 + 2 * dx; + const double x4 = x1 + 3 * dx; + const double x5 = x1 + 4 * dx; + const double x6 = x1 + 5 * dx; + const double x7 = x1 + 6 * dx; + + const double y2 = y1 + 1 * dy; + const double y3 = y1 + 2 * dy; + const double y4 = y1 + 3 * dy; + const double y5 = y1 + 4 * dy; + + starPoints[0].rx() = x4; + starPoints[0].ry() = y1; + + starPoints[1].rx() = x5; + starPoints[1].ry() = y2; + + starPoints[2].rx() = x7; + starPoints[2].ry() = y2; + + starPoints[3].rx() = x6; + starPoints[3].ry() = y3; + + starPoints[4].rx() = x7; + starPoints[4].ry() = y4; + + starPoints[5].rx() = x5; + starPoints[5].ry() = y4; + + starPoints[6].rx() = x4; + starPoints[6].ry() = y5; + + starPoints[7].rx() = x3; + starPoints[7].ry() = y4; + + starPoints[8].rx() = x1; + starPoints[8].ry() = y4; + + starPoints[9].rx() = x2; + starPoints[9].ry() = y3; + + starPoints[10].rx() = x1; + starPoints[10].ry() = y2; + + starPoints[11].rx() = x3; + starPoints[11].ry() = y2; + + painter.drawPolygon( star ); + + return image; +} + +//-------------------------------------------------------------------------------------------------- +/// Adapted from QwtSymbol::qwtDrawHexagonSymbols +//-------------------------------------------------------------------------------------------------- +QImage RiuQtChartsPlotCurveSymbol::createHexagonImage() const +{ + QImage image( m_size, m_size, QImage::Format_ARGB32 ); + image.fill( Qt::transparent ); + + QPainter painter( &image ); + painter.setRenderHint( QPainter::Antialiasing ); + + QPen pen( m_pen ); + pen.setWidth( 1.0 ); + pen.setJoinStyle( Qt::MiterJoin ); + + painter.setPen( pen ); + painter.setBrush( m_color ); + + QRectF r( 0, 0, m_size, m_size ); + + const double cos30 = 0.866025; // cos(30°) + const double dx = 0.5 * ( m_size - cos30 ); + + const double dy = 0.25 * m_size; + + QPolygonF hexaPolygon( 6 ); + QPointF* hexaPoints = hexaPolygon.data(); + + double x = m_size * 0.5; + double y = m_size * 0.5; + + double x1 = x - dx; + double y1 = y - 2 * dy; + + const double x2 = x1 + 1 * dx; + const double x3 = x1 + 2 * dx; + + const double y2 = y1 + 1 * dy; + const double y3 = y1 + 3 * dy; + const double y4 = y1 + 4 * dy; + + hexaPoints[0].rx() = x2; + hexaPoints[0].ry() = y1; + + hexaPoints[1].rx() = x3; + hexaPoints[1].ry() = y2; + + hexaPoints[2].rx() = x3; + hexaPoints[2].ry() = y3; + + hexaPoints[3].rx() = x2; + hexaPoints[3].ry() = y4; + + hexaPoints[4].rx() = x1; + hexaPoints[4].ry() = y3; + + hexaPoints[5].rx() = x1; + hexaPoints[5].ry() = y2; + + painter.drawPolygon( hexaPolygon ); + return image; +} + +//-------------------------------------------------------------------------------------------------- +/// Adapted from QwtSymbol::qwtDrawDiamondSymbols +//-------------------------------------------------------------------------------------------------- +QImage RiuQtChartsPlotCurveSymbol::createDiamondImage() const +{ + QImage image( m_size, m_size, QImage::Format_ARGB32 ); + image.fill( Qt::transparent ); + + QPainter painter( &image ); + painter.setRenderHint( QPainter::Antialiasing ); + + QPen pen( m_pen ); + pen.setWidth( 1.0 ); + pen.setJoinStyle( Qt::MiterJoin ); + + painter.setPen( pen ); + painter.setBrush( m_color ); + + QSize size( m_size, m_size ); + + double x = size.width() * 0.5; + double y = size.height() * 0.5; + const double x1 = x - 0.5 * size.width(); + const double y1 = y - 0.5 * size.height(); + const double x2 = x1 + size.width(); + const double y2 = y1 + size.height(); + + QPolygonF polygon; + polygon += QPointF( x, y1 ); + polygon += QPointF( x2, y ); + polygon += QPointF( x, y2 ); + polygon += QPointF( x1, y ); + + painter.drawPolygon( polygon ); + + return image; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QRect RiuQtChartsPlotCurveSymbol::boundingRect() const +{ + return QRect( 0, 0, m_size, m_size ); +} diff --git a/ApplicationLibCode/UserInterface/RiuQtChartsPlotCurveSymbol.h b/ApplicationLibCode/UserInterface/RiuQtChartsPlotCurveSymbol.h new file mode 100644 index 0000000000..5fd3d02fbf --- /dev/null +++ b/ApplicationLibCode/UserInterface/RiuQtChartsPlotCurveSymbol.h @@ -0,0 +1,81 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Equinor ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "RiuPlotCurveSymbol.h" + +#include +#include +#include +#include + +class QPainter; +class QPointF; +class QRect; + +namespace QtCharts +{ +class QScatterSeries; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +class RiuQtChartsPlotCurveSymbol : public RiuPlotCurveSymbol +{ +public: + RiuQtChartsPlotCurveSymbol( RiuPlotCurveSymbol::PointSymbolEnum riuStyle, + const QString& label = QString(), + LabelPosition labelPosition = RiuPlotCurveSymbol::LabelAboveSymbol, + int labelFontSizePt = 8 ); + + void renderSymbolLabel( QPainter* painter, const QPointF& position, const QString& label ) const; + + void setSize( int width, int height ) override; + + void setColor( const QColor& color ) override; + + void setPen( const QPen& pen ) override; + + void setPixmap( const QPixmap& pixmap ) override; + + QRect boundingRect() const override; + + void applyToScatterSeries( QtCharts::QScatterSeries* series ) const; + + QImage image() const; + +private: + QImage createTriangleImage( RiuPlotCurveSymbol::PointSymbolEnum symbolStyle ) const; + QImage createRectImage() const; + QImage createStar1Image() const; + QImage createStar2Image() const; + QImage createHexagonImage() const; + QImage createEllipseImage() const; + QImage createCrossImage() const; + QImage createXCrossImage() const; + QImage createDiamondImage() const; + + void setImageBrush( QtCharts::QScatterSeries* series, const QImage& image ) const; + + QColor m_color; + QPen m_pen; + int m_size; +}; diff --git a/ApplicationLibCode/UserInterface/RiuQtChartsPlotTools.cpp b/ApplicationLibCode/UserInterface/RiuQtChartsPlotTools.cpp new file mode 100644 index 0000000000..a129a30b56 --- /dev/null +++ b/ApplicationLibCode/UserInterface/RiuQtChartsPlotTools.cpp @@ -0,0 +1,105 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiuQtChartsPlotTools.h" + +#include "RiaApplication.h" +#include "RiaPlotDefines.h" +#include "RiaPreferences.h" +#include "RiaQDateTimeTools.h" + +#include "RiuGuiTheme.h" +#include "RiuQtChartsPlotWidget.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotTools::setCommonPlotBehaviour( RiuQtChartsPlotWidget* plot ) +{ + // Plot background and frame look + QPalette newPalette( plot->palette() ); + newPalette.setColor( QPalette::Window, Qt::white ); + plot->setPalette( newPalette ); + + plot->setAutoFillBackground( true ); + + // Axis number font + int axisFontSize = caf::FontTools::absolutePointSize( RiaPreferences::current()->defaultPlotFontSize(), + caf::FontTools::RelativeSize::Medium ); + + // Axis title font + int titleFontSize = caf::FontTools::absolutePointSize( RiaPreferences::current()->defaultPlotFontSize(), + caf::FontTools::RelativeSize::Medium ); + bool titleBold = false; + plot->setAxesFontsAndAlignment( titleFontSize, axisFontSize, titleBold, Qt::AlignRight ); + + // Store the pointer address as an object name. This way + // each plot can be identified uniquely for CSS-stylesheets + QString objectName = QString( "%1" ).arg( reinterpret_cast( plot ) ); + plot->setObjectName( objectName ); + + QString canvasName = QString( "%1" ).arg( reinterpret_cast( plot->getParentForOverlay() ) ); + plot->getParentForOverlay()->setObjectName( canvasName ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotTools::setDefaultAxes( RiuQtChartsPlotWidget* plot ) +{ + plot->enableAxis( RiuPlotAxis::defaultBottom(), true ); + plot->enableAxis( RiuPlotAxis::defaultLeft(), true ); + plot->enableAxis( RiuPlotAxis::defaultTop(), false ); + plot->enableAxis( RiuPlotAxis::defaultRight(), false ); + + plot->setAxisMaxMinor( RiuPlotAxis::defaultBottom(), 2 ); + plot->setAxisMaxMinor( RiuPlotAxis::defaultLeft(), 0 ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotTools::enableDateBasedBottomXAxis( RiuQtChartsPlotWidget* plot, + const QString& dateFormat, + const QString& timeFormat, + RiaDefines::DateFormatComponents dateComponents, + RiaDefines::TimeFormatComponents timeComponents ) +{ + QString format = dateTimeFormatForInterval( dateFormat, timeFormat, dateComponents, timeComponents ); + plot->setAxisFormat( RiuPlotAxis::defaultBottom(), format ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuQtChartsPlotTools::dateTimeFormatForInterval( const QString& dateFormat, + const QString& timeFormat, + RiaDefines::DateFormatComponents dateComponents, + RiaDefines::TimeFormatComponents timeComponents ) +{ + if ( dateComponents != RiaDefines::DateFormatComponents::DATE_FORMAT_UNSPECIFIED && + timeComponents != RiaDefines::TimeFormatComponents::TIME_FORMAT_UNSPECIFIED ) + { + return RiaQDateTimeTools::timeFormatString( timeFormat, timeComponents ) + "\n" + + RiaQDateTimeTools::dateFormatString( dateFormat, dateComponents ); + } + + // Default: + return RiaQDateTimeTools::timeFormatString( timeFormat, RiaDefines::TimeFormatComponents::TIME_FORMAT_NONE ) + "\n" + + RiaQDateTimeTools::dateFormatString( dateFormat, RiaDefines::DateFormatComponents::DATE_FORMAT_YEAR_MONTH_DAY ); +} diff --git a/ApplicationLibCode/UserInterface/RiuQtChartsPlotTools.h b/ApplicationLibCode/UserInterface/RiuQtChartsPlotTools.h new file mode 100644 index 0000000000..58a7744c9b --- /dev/null +++ b/ApplicationLibCode/UserInterface/RiuQtChartsPlotTools.h @@ -0,0 +1,40 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// +#pragma once + +#include "RiaDateTimeDefines.h" + +class RiuQtChartsPlotWidget; + +class RiuQtChartsPlotTools +{ +public: + static void setCommonPlotBehaviour( RiuQtChartsPlotWidget* plot ); + static void setDefaultAxes( RiuQtChartsPlotWidget* plot ); + static void enableDateBasedBottomXAxis( + RiuQtChartsPlotWidget* plot, + const QString& dateFormat, + const QString& timeFormat, + RiaDefines::DateFormatComponents dateComponents = RiaDefines::DateFormatComponents::DATE_FORMAT_UNSPECIFIED, + RiaDefines::TimeFormatComponents timeComponents = RiaDefines::TimeFormatComponents::TIME_FORMAT_UNSPECIFIED ); + + static QString dateTimeFormatForInterval( const QString& dateFormat, + const QString& timeFormat, + RiaDefines::DateFormatComponents dateComponents, + RiaDefines::TimeFormatComponents timeComponents ); +}; diff --git a/ApplicationLibCode/UserInterface/RiuQtChartsPlotWidget.cpp b/ApplicationLibCode/UserInterface/RiuQtChartsPlotWidget.cpp new file mode 100644 index 0000000000..8eedb07b43 --- /dev/null +++ b/ApplicationLibCode/UserInterface/RiuQtChartsPlotWidget.cpp @@ -0,0 +1,1350 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiuQtChartsPlotWidget.h" + +#include "RiaDefines.h" +#include "RiaFontCache.h" +#include "RiaGuiApplication.h" +#include "RiaPlotDefines.h" +#include "RiaPlotWindowRedrawScheduler.h" +#include "RimPlot.h" + +#include "RiuDraggableOverlayFrame.h" +#include "RiuGuiTheme.h" +#include "RiuPlotCurveInfoTextProvider.h" +#include "RiuPlotMainWindowTools.h" +#include "RiuPlotWidget.h" +#include "RiuQtChartView.h" +#include "RiuQtChartsPlotCurve.h" +#include "RiuQtChartsToolTip.h" +#include "RiuQwtDateScaleWrapper.h" +#include "RiuQwtPlotTools.h" + +#include "caf.h" +#include "cafAssert.h" + +#include "cvfTrace.h" + +#include +#include +#include +#include +#include +#include + +#include +#include + +using namespace QtCharts; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuQtChartsPlotWidget::RiuQtChartsPlotWidget( RimPlot* plotDefinition, + QWidget* parent, + RiuPlotCurveInfoTextProvider* plotCurveNameProvider ) + : RiuPlotWidget( plotDefinition, parent ) + , m_plotCurveNameProvider( plotCurveNameProvider ) + , m_dateScaleWrapper( new RiuQwtDateScaleWrapper() ) + , m_toolTip( nullptr ) +{ + CAF_ASSERT( m_plotDefinition ); + + QVBoxLayout* layout = new QVBoxLayout; + layout->setContentsMargins( 0, 0, 0, 0 ); + setLayout( layout ); + + QChart* chart = new QChart(); + chart->layout()->setContentsMargins( 0, 0, 0, 0 ); + chart->setBackgroundRoundness( 0 ); + chart->setAcceptDrops( true ); + chart->installEventFilter( this ); + + m_viewer = new RiuQtChartView( nullptr, parent ); + m_viewer->setChart( chart ); + m_viewer->setRenderHint( QPainter::Antialiasing ); + + layout->addWidget( m_viewer ); + + addAxis( RiuPlotAxis::defaultBottom(), true, true ); + addAxis( RiuPlotAxis::defaultLeft(), true, true ); + addAxis( RiuPlotAxis::defaultRight(), true, true ); + addAxis( RiuPlotAxis::defaultTop(), false, false ); + + m_viewer->setRubberBand( QChartView::RectangleRubberBand ); + + setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuQtChartsPlotWidget::~RiuQtChartsPlotWidget() +{ + if ( m_plotDefinition ) + { + m_plotDefinition->detachAllCurves(); + } + + delete m_dateScaleWrapper; + m_dateScaleWrapper = nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::axisRangeChanged() +{ + auto catAxis = categoryAxis(); + if ( catAxis ) + { + auto min = catAxis->min(); + auto max = catAxis->max(); + + auto existingLabels = catAxis->categoriesLabels(); + for ( const auto& l : existingLabels ) + { + catAxis->remove( l ); + } + + auto positionLabel = m_dateScaleWrapper->positionsAndLabels( min, max ); + for ( auto [pos, label] : positionLabel ) + { + catAxis->append( label, pos ); + } + } + + if ( qtChart()->isZoomed() ) emit plotZoomed(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RiuQtChartsPlotWidget::axisTitleFontSize( RiuPlotAxis axis ) const +{ + if ( axisEnabled( axis ) ) + { + return plotAxis( axis )->titleFont().pointSize(); + } + + return -1; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RiuQtChartsPlotWidget::axisValueFontSize( RiuPlotAxis axis ) const +{ + if ( axisEnabled( axis ) ) + { + return plotAxis( axis )->labelsFont().pointSize(); + } + + return -1; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::setAxisFontsAndAlignment( RiuPlotAxis axis, + int titleFontSize, + int valueFontSize, + bool titleBold, + int alignment ) +{ + int titleFontPixelSize = caf::FontTools::pointSizeToPixelSize( titleFontSize ); + int valueFontPixelSize = caf::FontTools::pointSizeToPixelSize( valueFontSize ); + + // Axis number font + QFont axisFont = plotAxis( axis )->labelsFont(); + axisFont.setPixelSize( valueFontPixelSize ); + axisFont.setBold( false ); + plotAxis( axis )->setLabelsFont( axisFont ); + + // Axis title font + QFont axisTitleFont = plotAxis( axis )->labelsFont(); + axisTitleFont.setPixelSize( titleFontPixelSize ); + axisTitleFont.setBold( titleBold ); + plotAxis( axis )->setTitleFont( axisTitleFont ); + + applyAxisTitleToPlot( axis ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::setAxesFontsAndAlignment( int titleFontSize, int valueFontSize, bool titleBold, int alignment ) +{ + for ( const auto& axisTitlePair : m_axisTitles ) + { + setAxisFontsAndAlignment( axisTitlePair.first, titleFontSize, valueFontSize, titleBold, alignment ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::enableAxisNumberLabels( RiuPlotAxis axis, bool isEnabled ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::setAxisTitleText( RiuPlotAxis axis, const QString& title ) +{ + m_axisTitles[axis] = title; + applyAxisTitleToPlot( axis ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::setAxisTitleEnabled( RiuPlotAxis axis, bool enable ) +{ + m_axisTitlesEnabled[axis] = enable; + applyAxisTitleToPlot( axis ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::setAxisFormat( RiuPlotAxis axis, const QString& format ) +{ + auto ax = plotAxis( axis ); + + auto valueAxis = dynamic_cast( ax ); + if ( valueAxis ) valueAxis->setLabelFormat( format ); + + auto logAxis = dynamic_cast( ax ); + if ( logAxis ) logAxis->setLabelFormat( format ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::setPlotTitle( const QString& plotTitle ) +{ + m_plotTitle = plotTitle; + applyPlotTitleToPlot(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const QString& RiuQtChartsPlotWidget::plotTitle() const +{ + return m_plotTitle; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::setPlotTitleEnabled( bool enabled ) +{ + m_plotTitleEnabled = enabled; + applyPlotTitleToPlot(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiuQtChartsPlotWidget::plotTitleEnabled() const +{ + return m_plotTitleEnabled; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::setPlotTitleFontSize( int titleFontSize ) +{ + QFont font = qtChart()->titleFont(); + font.setPixelSize( caf::FontTools::pointSizeToPixelSize( titleFontSize ) ); + qtChart()->setTitleFont( font ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::setLegendFontSize( int fontSize ) +{ + if ( qtChart()->legend() ) + { + QFont font = qtChart()->legend()->font(); + font.setPixelSize( caf::FontTools::pointSizeToPixelSize( fontSize ) ); + qtChart()->legend()->setFont( font ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::setInternalLegendVisible( bool visible ) +{ + if ( visible ) + { + insertLegend( RiuPlotWidget::Legend::BOTTOM ); + } + else + { + clearLegend(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::insertLegend( RiuPlotWidget::Legend legendPosition ) +{ + auto mapLegendPosition = []( RiuPlotWidget::Legend pos ) { + if ( pos == RiuPlotWidget::Legend::BOTTOM ) + return Qt::AlignBottom; + else if ( pos == RiuPlotWidget::Legend::TOP ) + return Qt::AlignTop; + else if ( pos == RiuPlotWidget::Legend::LEFT ) + return Qt::AlignLeft; + + return Qt::AlignRight; + }; + + QLegend* legend = qtChart()->legend(); + legend->setAlignment( mapLegendPosition( legendPosition ) ); + if ( !legend->isAttachedToChart() ) + { + legend->attachToChart(); + } + + replot(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::clearLegend() +{ + QLegend* legend = qtChart()->legend(); + legend->detachFromChart(); + legend->hide(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair RiuQtChartsPlotWidget::axisRange( RiuPlotAxis axis ) const +{ + auto ax = plotAxis( axis ); + + auto valueAxis = dynamic_cast( ax ); + if ( valueAxis ) return std::make_pair( valueAxis->min(), valueAxis->max() ); + + auto logAxis = dynamic_cast( ax ); + if ( logAxis ) return std::make_pair( logAxis->min(), logAxis->max() ); + + return std::make_pair( 0.0, 1.0 ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::setAxisRange( RiuPlotAxis axis, double min, double max ) +{ + // Note: Especially the Y-axis may be inverted + if ( plotAxis( axis )->isReverse() ) + { + setAxisScale( axis, max, min ); + } + else + { + setAxisScale( axis, min, max ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::setAxisInverted( RiuPlotAxis axis, bool isInverted ) +{ + auto ax = plotAxis( axis ); + ax->setReverse( isInverted ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::setAxisLabelsAndTicksEnabled( RiuPlotAxis axis, bool enableLabels, bool enableTicks ) +{ + plotAxis( axis )->setLabelsVisible( enableLabels ); + plotAxis( axis )->setGridLineVisible( enableTicks ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::enableGridLines( RiuPlotAxis axis, bool majorGridLines, bool minorGridLines ) +{ + plotAxis( axis )->setGridLineVisible( majorGridLines ); + plotAxis( axis )->setMinorGridLineVisible( minorGridLines ); + + QPen gridLinePen( Qt::lightGray, 1.0, Qt::SolidLine ); + plotAxis( axis )->setGridLinePen( gridLinePen ); + + QPen minorGridLinePen( Qt::lightGray, 1.0, Qt::DashLine ); + plotAxis( axis )->setMinorGridLinePen( minorGridLinePen ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::setMajorAndMinorTickIntervals( RiuPlotAxis axis, + double majorTickInterval, + double minorTickInterval, + double minValue, + double maxValue ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::setMajorAndMinorTickIntervalsAndRange( RiuPlotAxis axis, + double majorTickInterval, + double minorTickInterval, + double minTickValue, + double maxTickValue, + double rangeMin, + double rangeMax ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::setAutoTickIntervalCounts( RiuPlotAxis axis, + int maxMajorTickIntervalCount, + int maxMinorTickIntervalCount ) +{ + setAxisMaxMajor( axis, maxMajorTickIntervalCount ); + setAxisMaxMinor( axis, maxMinorTickIntervalCount ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RiuQtChartsPlotWidget::majorTickInterval( RiuPlotAxis axis ) const +{ +#if QT_VERSION >= QT_VERSION_CHECK( 5, 12, 0 ) + // QValueAxis::tickInterval was introduced in 5.12 + QAbstractAxis* ax = plotAxis( axis ); + QValueAxis* valueAxis = dynamic_cast( ax ); + if ( valueAxis ) return valueAxis->tickInterval(); +#endif + return 0.0; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RiuQtChartsPlotWidget::minorTickInterval( RiuPlotAxis axis ) const +{ + return 0.0; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RiuQtChartsPlotWidget::axisExtent( RiuPlotAxis axis ) const +{ + CAF_ASSERT( false && "Not implemented" ); + return 100; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QPoint RiuQtChartsPlotWidget::dragStartPosition() const +{ + return m_clickPosition; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::scheduleReplot() +{ + RiaPlotWindowRedrawScheduler::instance()->schedulePlotWidgetReplot( this ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::updateLayout() +{ + updateOverlayFrameLayout(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::updateLegend() +{ + qtChart()->legend()->update(); + + auto curves = plotDefinition()->visibleCurvesForLegend(); + + auto legendData = RiuQwtPlotTools::createLegendData( curves ); + emit legendDataChanged( legendData ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::resizeEvent( QResizeEvent* event ) +{ + QWidget::resizeEvent( event ); + updateOverlayFrameLayout(); + event->accept(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::keyPressEvent( QKeyEvent* event ) +{ + switch ( event->key() ) + { + case Qt::Key_Plus: + qtChart()->zoomIn(); + break; + case Qt::Key_Minus: + qtChart()->zoomOut(); + break; + default: + QWidget::keyPressEvent( event ); + break; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::applyPlotTitleToPlot() +{ + QString plotTitleToApply = m_plotTitleEnabled ? m_plotTitle : QString( "" ); + m_viewer->chart()->setTitle( plotTitleToApply ); + m_viewer->chart()->update(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::applyAxisTitleToPlot( RiuPlotAxis axis ) +{ + QString titleToApply = m_axisTitlesEnabled[axis] ? m_axisTitles[axis] : QString( "" ); + plotAxis( axis )->setTitleText( titleToApply ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QSize RiuQtChartsPlotWidget::sizeHint() const +{ + return QSize( 0, 0 ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QSize RiuQtChartsPlotWidget::minimumSizeHint() const +{ + return QSize( 0, 0 ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiuQtChartsPlotWidget::isZoomerActive() const +{ + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// Empty default implementation +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::endZoomOperations() +{ +} + +//-------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::renderTo( QPainter* painter, const QRect& targetRect, double scaling ) +{ + // TODO: handle scaling... + painter->setRenderHint( QPainter::Antialiasing ); + m_viewer->render( painter, targetRect ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::renderTo( QPaintDevice* paintDevice, const QRect& targetRect ) +{ + int resolution = paintDevice->logicalDpiX(); + double scaling = resolution / static_cast( RiaGuiApplication::applicationResolution() ); + QPainter painter( paintDevice ); + renderTo( &painter, targetRect, scaling ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RiuQtChartsPlotWidget::overlayMargins() const +{ + return m_overlayMargins; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QWidget* RiuQtChartsPlotWidget::getParentForOverlay() const +{ + return m_viewer; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimViewWindow* RiuQtChartsPlotWidget::ownerViewWindow() const +{ + return m_plotDefinition; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RiuQtChartsPlotWidget::defaultMinimumWidth() +{ + return 80; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::replot() +{ + qtChart()->update(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QCategoryAxis* RiuQtChartsPlotWidget::categoryAxis() +{ + for ( const auto& a : m_axes ) + { + auto catAxis = dynamic_cast( a.second ); + if ( catAxis ) return catAxis; + } + + return nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::updateZoomDependentCurveProperties() +{ + for ( auto it : m_scatterSeriesMap ) + { + auto plotCurve = dynamic_cast( it.first ); + if ( plotCurve ) plotCurve->updateScatterSeries(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::setFormatStrings( const QString& dateFormat, + const QString& timeFormat, + RiaDefines::DateFormatComponents dateComponents, + RiaDefines::TimeFormatComponents timeComponents ) +{ + m_dateScaleWrapper->setFormatStrings( dateFormat, timeFormat, dateComponents, timeComponents ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::enableAxis( RiuPlotAxis axis, bool isEnabled ) +{ + m_axesEnabled[axis] = isEnabled; + plotAxis( axis )->setVisible( isEnabled ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiuQtChartsPlotWidget::axisEnabled( RiuPlotAxis axis ) const +{ + auto it = m_axesEnabled.find( axis ); + if ( it != m_axesEnabled.end() ) + return it->second; + else + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::setAxisMaxMinor( RiuPlotAxis axis, int maxMinor ) +{ + QAbstractAxis* ax = plotAxis( axis ); + QValueAxis* valueAxis = dynamic_cast( ax ); + if ( valueAxis ) + { + valueAxis->setMinorTickCount( maxMinor ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::setAxisMaxMajor( RiuPlotAxis axis, int maxMajor ) +{ + QAbstractAxis* ax = plotAxis( axis ); + QValueAxis* valueAxis = dynamic_cast( ax ); + if ( valueAxis ) + { + valueAxis->setTickCount( maxMajor ); + } + else + { + m_dateScaleWrapper->setMaxMajorTicks( maxMajor ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::setAxisAutoScale( RiuPlotAxis axis, bool autoScale ) +{ + m_axesAutoScale[axis] = autoScale; + + if ( autoScale ) + { + rescaleAxis( axis ); + + QAbstractAxis* ax = plotAxis( axis ); + QValueAxis* valueAxis = dynamic_cast( ax ); + if ( valueAxis ) + { + // Block signals to avoid triggering RimSummaryPlot::onPlotZoomed + valueAxis->blockSignals( true ); + valueAxis->applyNiceNumbers(); + valueAxis->blockSignals( false ); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::setAxisScale( RiuPlotAxis axis, double min, double max ) +{ + plotAxis( axis )->setRange( min, max ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuQtChartsPlotWidget::AxisScaleType RiuQtChartsPlotWidget::axisScaleType( RiuPlotAxis axis ) const +{ + if ( plotAxis( axis )->type() == QAbstractAxis::AxisTypeLogValue ) return AxisScaleType::LOGARITHMIC; + if ( plotAxis( axis )->type() == QAbstractAxis::AxisTypeDateTime ) return AxisScaleType::DATE; + return AxisScaleType::LINEAR; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::setAxisScaleType( RiuPlotAxis axis, RiuQtChartsPlotWidget::AxisScaleType axisScaleType ) +{ + QAbstractAxis* axisToBeDeleted = plotAxis( axis ); + QAbstractAxis* insertaxis = nullptr; + + if ( axisScaleType == AxisScaleType::LOGARITHMIC ) + { + insertaxis = new QLogValueAxis; + } + else if ( axisScaleType == AxisScaleType::DATE ) + { + auto categoryAxis = new QCategoryAxis; + categoryAxis->setLabelsPosition( QCategoryAxis::AxisLabelsPosition::AxisLabelsPositionOnValue ); + insertaxis = categoryAxis; + } + else if ( axisScaleType == AxisScaleType::LINEAR ) + { + insertaxis = new QValueAxis; + } + + QChart* chart = qtChart(); + if ( chart->axes().contains( axisToBeDeleted ) ) chart->removeAxis( axisToBeDeleted ); + chart->addAxis( insertaxis, mapPlotAxisToQtAlignment( axis.axis() ) ); + + m_axes[axis] = insertaxis; + for ( auto serie : chart->series() ) + { + if ( serie->attachedAxes().contains( axisToBeDeleted ) ) serie->detachAxis( axisToBeDeleted ); + serie->attachAxis( insertaxis ); + } + + // We have the ownership of the axis object, delete to avoid memory leak + delete axisToBeDeleted; + axisToBeDeleted = nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::updateAxes() +{ + axisRangeChanged(); + m_viewer->chart()->update(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuPlotCurve* RiuQtChartsPlotWidget::createPlotCurve( RimPlotCurve* ownerRimCurve, const QString& title, const QColor& color ) +{ + return new RiuQtChartsPlotCurve( ownerRimCurve, title ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QChart* RiuQtChartsPlotWidget::qtChart() +{ + return m_viewer->chart(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::attach( RiuPlotCurve* plotCurve, + QAbstractSeries* lineSeries, + QAbstractSeries* areaSeries, + QAbstractSeries* scatterSeries, + RiuPlotAxis xAxis, + RiuPlotAxis yAxis ) +{ + auto addToChart = [this]( std::map& curveSeriesMap, + auto plotCurve, + auto series, + auto xAxis, + auto yAxis, + RiuQtChartsPlotCurve* qtChartsPlotCurve ) { + if ( !series->chart() ) + { + curveSeriesMap[plotCurve] = series; + qtChart()->addSeries( series ); + setXAxis( xAxis, series, qtChartsPlotCurve ); + setYAxis( yAxis, series, qtChartsPlotCurve ); + } + }; + + auto qtChartsPlotCurve = dynamic_cast( plotCurve ); + addToChart( m_lineSeriesMap, plotCurve, lineSeries, xAxis, yAxis, qtChartsPlotCurve ); + addToChart( m_areaSeriesMap, plotCurve, areaSeries, xAxis, yAxis, qtChartsPlotCurve ); + addToChart( m_scatterSeriesMap, plotCurve, scatterSeries, xAxis, yAxis, qtChartsPlotCurve ); + + connect( dynamic_cast( lineSeries ), &QLineSeries::hovered, this, &RiuQtChartsPlotWidget::tooltip ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::detach( RiuPlotCurve* plotCurve ) +{ + m_lineSeriesMap.erase( plotCurve ); + m_areaSeriesMap.erase( plotCurve ); + m_scatterSeriesMap.erase( plotCurve ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QAbstractSeries* RiuQtChartsPlotWidget::getLineSeries( const RiuPlotCurve* plotCurve ) const +{ + auto series = m_lineSeriesMap.find( const_cast( plotCurve ) ); + if ( series != m_lineSeriesMap.end() ) + return series->second; + else + return nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QAbstractSeries* RiuQtChartsPlotWidget::getAreaSeries( const RiuPlotCurve* plotCurve ) const +{ + auto series = m_areaSeriesMap.find( const_cast( plotCurve ) ); + if ( series != m_areaSeriesMap.end() ) + return series->second; + else + return nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QAbstractSeries* RiuQtChartsPlotWidget::getScatterSeries( const RiuPlotCurve* plotCurve ) const +{ + auto series = m_scatterSeriesMap.find( const_cast( plotCurve ) ); + if ( series != m_scatterSeriesMap.end() ) + return series->second; + else + return nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::detachItems( RiuPlotWidget::PlotItemType plotItemType ) +{ + cvf::Trace::show( "RiuQtChartsPlotWidget::detachItems" ); + + if ( plotItemType == RiuPlotWidget::PlotItemType::CURVE ) + { + m_lineSeriesMap.clear(); + m_areaSeriesMap.clear(); + m_scatterSeriesMap.clear(); + qtChart()->removeAllSeries(); + } + else + { + cvf::Trace::show( "Detach items not implemented for this type." ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::setXAxis( RiuPlotAxis axis, QAbstractSeries* series, RiuQtChartsPlotCurve* plotCurve ) +{ + attachSeriesToAxis( axis, series, plotCurve ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::setYAxis( RiuPlotAxis axis, QAbstractSeries* series, RiuQtChartsPlotCurve* plotCurve ) +{ + attachSeriesToAxis( axis, series, plotCurve ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::ensureAxisIsCreated( RiuPlotAxis axis ) +{ + if ( m_axes.find( axis ) == m_axes.end() ) + { + addAxis( axis, true, true ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::attachSeriesToAxis( RiuPlotAxis axis, QAbstractSeries* series, RiuQtChartsPlotCurve* plotCurve ) +{ + // Make sure the axis we are about to set exists. + ensureAxisIsCreated( axis ); + + if ( qtChart()->series().contains( series ) && !series->attachedAxes().contains( plotAxis( axis ) ) ) + { + auto newAxis = plotAxis( axis ); + + // Detach any other axis for the same orientation + for ( auto ax : series->attachedAxes() ) + { + if ( ax->orientation() == orientation( axis.axis() ) ) + { + series->detachAxis( ax ); + } + } + + series->attachAxis( newAxis ); + + if ( qobject_cast( newAxis ) || qobject_cast( newAxis ) ) + { + connect( newAxis, SIGNAL( rangeChanged( double, double ) ), this, SLOT( axisRangeChanged() ), Qt::UniqueConnection ); + if ( plotCurve ) + { + connect( newAxis, + SIGNAL( rangeChanged( double, double ) ), + plotCurve, + SLOT( axisRangeChanged() ), + Qt::UniqueConnection ); + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::addAxis( RiuPlotAxis plotAxis, bool isEnabled, bool isAutoScale ) +{ + auto* axis = new QValueAxis(); + qtChart()->addAxis( axis, mapPlotAxisToQtAlignment( plotAxis.axis() ) ); + m_axes[plotAxis] = axis; + m_axesEnabled[plotAxis] = isEnabled; + m_axesAutoScale[plotAxis] = isAutoScale; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::deleteAxis( RiuPlotAxis axis ) +{ + auto toBeDeleted = plotAxis( axis ); + + qtChart()->removeAxis( toBeDeleted ); + m_axes.erase( axis ); + m_axesEnabled.erase( axis ); + m_axesAutoScale.erase( axis ); + + delete toBeDeleted; + toBeDeleted = nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuPlotAxis RiuQtChartsPlotWidget::createNextPlotAxis( RiaDefines::PlotAxis axis ) +{ + int minIdx = -1; + for ( const auto& a : m_axes ) + { + if ( a.first.axis() == axis ) + { + minIdx = std::max( a.first.index(), minIdx ); + } + } + + RiuPlotAxis plotAxis( axis, minIdx + 1 ); + + addAxis( plotAxis, true, true ); + return plotAxis; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiuQtChartsPlotWidget::isMultiAxisSupported() const +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::rescaleAxis( RiuPlotAxis axis ) +{ + if ( !m_axesAutoScale[axis] ) return; + + QAbstractAxis* pAxis = plotAxis( axis ); + Qt::Orientation orr = orientation( axis.axis() ); + + double min = std::numeric_limits::max(); + double max = -std::numeric_limits::max(); + for ( auto series : qtChart()->series() ) + { + auto attachedAxes = series->attachedAxes(); + if ( attachedAxes.contains( pAxis ) ) + { + QVector points; + for ( auto attachedAxis : attachedAxes ) + { + auto* valueAxis = dynamic_cast( attachedAxis ); + if ( valueAxis && valueAxis->orientation() == orr && dynamic_cast( series ) ) + { + points = dynamic_cast( series )->pointsVector(); + } + + for ( auto p : points ) + { + if ( orr == Qt::Orientation::Horizontal ) + { + min = std::min( min, p.x() ); + max = std::max( max, p.x() ); + } + else + { + min = std::min( min, p.y() ); + max = std::max( max, p.y() ); + } + } + } + } + } + + // Block signals to avoid triggering RimSummaryPlot::onPlotZoomed + pAxis->blockSignals( true ); + + if ( axis.axis() == RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM ) + { + auto catAxis = categoryAxis(); + if ( catAxis ) + { + auto existingLabels = catAxis->categoriesLabels(); + for ( const auto& l : existingLabels ) + { + catAxis->remove( l ); + } + + auto [adjustedMin, adjustedMax, tickCount] = m_dateScaleWrapper->adjustedRange( min, max ); + catAxis->setRange( adjustedMin, adjustedMax ); + + auto positionLabel = m_dateScaleWrapper->positionsAndLabels( adjustedMin, adjustedMax ); + for ( auto [pos, label] : positionLabel ) + { + catAxis->append( label, pos ); + } + } + } + else + { + pAxis->setRange( min, max ); + } + + pAxis->blockSignals( false ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QAbstractAxis* RiuQtChartsPlotWidget::plotAxis( RiuPlotAxis axis ) const +{ + const auto ax = m_axes.find( axis ); + if ( ax != m_axes.end() ) + { + return ax->second; + } + + return nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Qt::Orientation RiuQtChartsPlotWidget::orientation( RiaDefines::PlotAxis axis ) const +{ + if ( axis == RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM || axis == RiaDefines::PlotAxis::PLOT_AXIS_TOP ) + return Qt::Orientation::Horizontal; + + return Qt::Orientation::Vertical; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::dragEnterEvent( QDragEnterEvent* event ) +{ + RiuPlotWidget::handleDragDropEvent( event ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::dropEvent( QDropEvent* event ) +{ + RiuPlotWidget::handleDragDropEvent( event ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::wheelEvent( QWheelEvent* wheelEvent ) +{ + float factor = wheelEvent->angleDelta().y() > 0 ? 0.9 : 1.1; + + QRectF plotAreaRect = m_viewer->chart()->plotArea(); + QPointF centerPoint = plotAreaRect.center(); + + // Adjust the size of the plot area + plotAreaRect.setWidth( plotAreaRect.width() * factor ); + plotAreaRect.setHeight( plotAreaRect.height() * factor ); + + auto position = caf::position( wheelEvent ); + + // Find new center which keeps the mouse location in the same place in the plot + QPointF newCenterPoint( ( 2 * centerPoint - position ) - ( centerPoint - position ) / factor ); + plotAreaRect.moveCenter( newCenterPoint ); + + // Zoom in on the adjusted plot area + m_viewer->chart()->zoomIn( plotAreaRect ); + + wheelEvent->accept(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiuQtChartsPlotWidget::eventFilter( QObject* watched, QEvent* event ) +{ + if ( RiuPlotWidget::handleDragDropEvent( event ) ) return true; + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const QColor& RiuQtChartsPlotWidget::backgroundColor() const +{ + return m_viewer->chart()->backgroundBrush().color(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair RiuQtChartsPlotWidget::findClosestCurve( const QPoint& pos, double& distanceToClick ) const +{ + return std::make_pair( nullptr, -1 ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Qt::Alignment RiuQtChartsPlotWidget::mapPlotAxisToQtAlignment( RiaDefines::PlotAxis axis ) +{ + if ( axis == RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM ) return Qt::AlignBottom; + if ( axis == RiaDefines::PlotAxis::PLOT_AXIS_TOP ) return Qt::AlignTop; + if ( axis == RiaDefines::PlotAxis::PLOT_AXIS_LEFT ) return Qt::AlignLeft; + return Qt::AlignRight; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::pruneAxes( const std::set& usedAxes ) +{ + for ( auto [plotAxis, qtAxis] : m_axes ) + { + if ( usedAxes.count( plotAxis ) == 0 ) + { + deleteAxis( plotAxis ); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::moveAxis( RiuPlotAxis oldAxis, RiuPlotAxis newAxis ) +{ + deleteAxis( oldAxis ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsPlotWidget::tooltip( const QPointF& point, bool state ) +{ + QAbstractSeries* series = qobject_cast( sender() ); + if ( !m_toolTip ) m_toolTip = new RiuQtChartsToolTip( qtChart(), series ); + + auto xySeries = dynamic_cast( series ); + + auto snapToPoint = point; + + if ( xySeries ) + { + auto points = xySeries->pointsVector(); + int closestIndex = -1; + for ( int i = 0; i < points.size() - 1; i++ ) + { + if ( point.x() > points[i + 1].x() ) continue; + + if ( points[i].x() < point.x() && point.x() < points[i + 1].x() ) + { + if ( std::fabs( points[i].x() - point.x() ) < std::fabs( point.x() - points[i + 1].x() ) ) + { + closestIndex = i; + } + else + { + closestIndex = i + 1; + } + break; + } + } + + if ( closestIndex > 0 ) + { + snapToPoint = points[closestIndex]; + } + } + + if ( state ) + { + QString nameFromSeries = createNameFromSeries( series ); + + QDateTime date = QDateTime::fromMSecsSinceEpoch( snapToPoint.x() ); + QString dateString = RiaQDateTimeTools::toStringUsingApplicationLocale( date, "hh:mm dd.MMMM.yyyy" ); + + QString text = QString( "%1 (%2)" ).arg( snapToPoint.y() ).arg( dateString ); + + if ( !nameFromSeries.isEmpty() ) text.prepend( nameFromSeries + ": " ); + + m_toolTip->setText( text ); + + m_toolTip->setAnchor( snapToPoint ); + m_toolTip->setSeries( series ); + m_toolTip->setZValue( 200 ); + m_toolTip->updateGeometry(); + m_toolTip->show(); + } + else + { + m_toolTip->hide(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuQtChartsPlotWidget::createNameFromSeries( QAbstractSeries* series ) const +{ + if ( !m_plotCurveNameProvider ) return ""; + + for ( auto [plotCurve, plotSeries] : m_lineSeriesMap ) + { + if ( plotSeries == series ) + { + return m_plotCurveNameProvider->curveInfoText( plotCurve ); + } + } + + return ""; +} diff --git a/ApplicationLibCode/UserInterface/RiuQtChartsPlotWidget.h b/ApplicationLibCode/UserInterface/RiuQtChartsPlotWidget.h new file mode 100644 index 0000000000..ca11c07151 --- /dev/null +++ b/ApplicationLibCode/UserInterface/RiuQtChartsPlotWidget.h @@ -0,0 +1,260 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "RiaDateTimeDefines.h" +#include "RiaDefines.h" +#include "RiaPlotDefines.h" + +#include "RiuPlotWidget.h" + +#include "cafPdmObject.h" +#include "cafPdmPointer.h" + +#include "qwt_legend_data.h" + +#include + +#include + +class RiaPlotWindowRedrawScheduler; +class RimPlot; +class RiuPlotCurve; +class RiuQtChartsPlotCurve; +class RiuQtChartsToolTip; +class RiuPlotCurveSymbol; +class RiuPlotCurveInfoTextProvider; + +class QEvent; +class QLabel; +class QPainter; +class QPaintDevice; +class QWheelEvent; +class RiuQwtDateScaleWrapper; + +namespace QtCharts +{ +class QValueAxis; +class QChart; +class QAbstractSeries; +class QAbstractAxis; +class QChartView; +class QCategoryAxis; +}; // namespace QtCharts + +//================================================================================================== +// +// +// +//================================================================================================== +class RiuQtChartsPlotWidget : public RiuPlotWidget +{ + Q_OBJECT + +public: + RiuQtChartsPlotWidget( RimPlot* plotDefinition, + QWidget* parent = nullptr, + RiuPlotCurveInfoTextProvider* plotCurveNameProvider = nullptr ); + ~RiuQtChartsPlotWidget() override; + + int axisTitleFontSize( RiuPlotAxis axis ) const override; + int axisValueFontSize( RiuPlotAxis axis ) const override; + void setAxisFontsAndAlignment( RiuPlotAxis, + int titleFontSize, + int valueFontSize, + bool titleBold = false, + int alignment = (int)Qt::AlignCenter ) override; + void setAxesFontsAndAlignment( int titleFontSize, + int valueFontSize, + bool titleBold = false, + int alignment = (int)Qt::AlignCenter ) override; + + void enableAxisNumberLabels( RiuPlotAxis axis, bool isEnabled ) override; + void enableAxis( RiuPlotAxis axis, bool isEnabled ) override; + bool axisEnabled( RiuPlotAxis axis ) const override; + + void setAxisScale( RiuPlotAxis axis, double min, double max ) override; + void setAxisAutoScale( RiuPlotAxis axis, bool enable ) override; + + void setAxisMaxMinor( RiuPlotAxis axis, int maxMinor ) override; + void setAxisMaxMajor( RiuPlotAxis axis, int maxMajor ) override; + + RiuPlotWidget::AxisScaleType axisScaleType( RiuPlotAxis axis ) const override; + void setAxisScaleType( RiuPlotAxis axis, RiuPlotWidget::AxisScaleType axisScaleType ) override; + + void setAxisTitleText( RiuPlotAxis axis, const QString& title ) override; + void setAxisTitleEnabled( RiuPlotAxis axis, bool enable ) override; + + void setAxisFormat( RiuPlotAxis axis, const QString& format ); + + void pruneAxes( const std::set& usedAxis ) override; + void moveAxis( RiuPlotAxis oldAxis, RiuPlotAxis newAxis ) override; + + RiuPlotAxis createNextPlotAxis( RiaDefines::PlotAxis axis ) override; + bool isMultiAxisSupported() const override; + + void setPlotTitle( const QString& plotTitle ) override; + const QString& plotTitle() const; + void setPlotTitleEnabled( bool enabled ); + bool plotTitleEnabled() const; + void setPlotTitleFontSize( int titleFontSize ) override; + + void setLegendFontSize( int fontSize ) override; + void setInternalLegendVisible( bool visible ) override; + void insertLegend( RiuPlotWidget::Legend ) override; + void clearLegend() override; + + std::pair axisRange( RiuPlotAxis axis ) const override; + void setAxisRange( RiuPlotAxis axis, double min, double max ) override; + + void setAxisInverted( RiuPlotAxis axis, bool isInverted ) override; + void setAxisLabelsAndTicksEnabled( RiuPlotAxis axis, bool enableLabels, bool enableTicks ) override; + + void enableGridLines( RiuPlotAxis axis, bool majorGridLines, bool minorGridLines ) override; + + void setMajorAndMinorTickIntervals( RiuPlotAxis axis, + double majorTickInterval, + double minorTickInterval, + double minValue, + double maxValue ) override; + void setMajorAndMinorTickIntervalsAndRange( RiuPlotAxis axis, + double majorTickInterval, + double minorTickInterval, + double minTickValue, + double maxTickValue, + double rangeMin, + double rangeMax ) override; + void setAutoTickIntervalCounts( RiuPlotAxis axis, int maxMajorTickIntervalCount, int maxMinorTickIntervalCount ) override; + double majorTickInterval( RiuPlotAxis axis ) const override; + double minorTickInterval( RiuPlotAxis axis ) const override; + + void detachItems( RiuPlotWidget::PlotItemType plotItemType ) override; + + int axisExtent( RiuPlotAxis axis ) const override; + + void ensureAxisIsCreated( RiuPlotAxis axis ) override; + + QPoint dragStartPosition() const; + + void scheduleReplot(); + + void updateLayout() override; + + void renderTo( QPainter* painter, const QRect& targetRect, double scaling ) override; + void renderTo( QPaintDevice* painter, const QRect& targetRect ) override; + int overlayMargins() const; + + RimViewWindow* ownerViewWindow() const override; + + void updateLegend() override; + void updateAxes() override; + + RiuPlotCurve* createPlotCurve( RimPlotCurve* ownerRimCurve, const QString& title, const QColor& color ) override; + + QtCharts::QChart* qtChart(); + + void attach( RiuPlotCurve* plotCurve, + QtCharts::QAbstractSeries* lineSeries, + QtCharts::QAbstractSeries* areaSeries, + QtCharts::QAbstractSeries* scatterSeries, + RiuPlotAxis xAxis, + RiuPlotAxis yAxis ); + void detach( RiuPlotCurve* plotCurve ); + + QtCharts::QAbstractSeries* getLineSeries( const RiuPlotCurve* plotCurve ) const; + QtCharts::QAbstractSeries* getAreaSeries( const RiuPlotCurve* plotCurve ) const; + QtCharts::QAbstractSeries* getScatterSeries( const RiuPlotCurve* plotCurve ) const; + + void setXAxis( RiuPlotAxis axis, QtCharts::QAbstractSeries* series, RiuQtChartsPlotCurve* plotCurve ); + void setYAxis( RiuPlotAxis axis, QtCharts::QAbstractSeries* series, RiuQtChartsPlotCurve* plotCurve ); + + const QColor& backgroundColor() const override; + + QWidget* getParentForOverlay() const override; + + std::pair findClosestCurve( const QPoint& pos, double& distanceToClick ) const override; + + void updateZoomDependentCurveProperties() override; + + void setFormatStrings( const QString& dateFormat, + const QString& timeFormat, + RiaDefines::DateFormatComponents dateComponents, + RiaDefines::TimeFormatComponents timeComponents ); + +protected: + void attachSeriesToAxis( RiuPlotAxis axis, QtCharts::QAbstractSeries* series, RiuQtChartsPlotCurve* plotCurve ); + + void resizeEvent( QResizeEvent* event ) override; + void keyPressEvent( QKeyEvent* event ) override; + void wheelEvent( QWheelEvent* event ) override; + bool eventFilter( QObject* watched, QEvent* event ) override; + + void applyPlotTitleToPlot(); + void applyAxisTitleToPlot( RiuPlotAxis axis ); + + QSize sizeHint() const override; + QSize minimumSizeHint() const override; + + virtual bool isZoomerActive() const; + virtual void endZoomOperations(); + + void rescaleAxis( RiuPlotAxis axis ); + QtCharts::QAbstractAxis* plotAxis( RiuPlotAxis axis ) const; + Qt::Orientation orientation( RiaDefines::PlotAxis axis ) const; + + void dragEnterEvent( QDragEnterEvent* event ) override; + void dropEvent( QDropEvent* event ) override; + +signals: + void plotZoomed(); + void legendDataChanged( const QList& data ); + +private slots: + void axisRangeChanged(); + void tooltip( const QPointF& point, bool state ); + +private: + void addAxis( RiuPlotAxis plotAxis, bool isEnabled, bool isAutoScale ); + void deleteAxis( RiuPlotAxis plotAxis ); + + static Qt::Alignment mapPlotAxisToQtAlignment( RiaDefines::PlotAxis axis ); + + static int defaultMinimumWidth(); + void replot() override; + + QtCharts::QCategoryAxis* categoryAxis(); + + QString createNameFromSeries( QtCharts::QAbstractSeries* series ) const; + +private: + QPointer m_viewer; + + std::map m_axes; + std::map m_axesEnabled; + std::map m_axesAutoScale; + + std::map m_lineSeriesMap; + std::map m_areaSeriesMap; + std::map m_scatterSeriesMap; + + RiuQwtDateScaleWrapper* m_dateScaleWrapper; + RiuQtChartsToolTip* m_toolTip; + RiuPlotCurveInfoTextProvider* m_plotCurveNameProvider; +}; diff --git a/ApplicationLibCode/UserInterface/RiuQtChartsToolTip.cpp b/ApplicationLibCode/UserInterface/RiuQtChartsToolTip.cpp new file mode 100644 index 0000000000..151f9a8f31 --- /dev/null +++ b/ApplicationLibCode/UserInterface/RiuQtChartsToolTip.cpp @@ -0,0 +1,112 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiuQtChartsToolTip.h" + +#include +#include +#include +#include +#include + +using namespace QtCharts; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuQtChartsToolTip::RiuQtChartsToolTip( QChart* chart, QtCharts::QAbstractSeries* series ) + : QGraphicsItem( chart ) + , m_chart( chart ) + , m_series( series ) + , m_radius( 10 ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QRectF RiuQtChartsToolTip::boundingRect() const +{ + QPointF anchor = mapFromParent( m_chart->mapToPosition( m_anchor, m_series ) ); + QRectF rect = m_rect.united( m_textRect ); + rect.setLeft( std::min( rect.left(), anchor.x() ) ); + rect.setRight( std::max( rect.right(), anchor.x() ) ); + rect.setTop( std::min( rect.top(), anchor.y() ) ); + rect.setBottom( std::max( rect.bottom(), anchor.y() ) ); + return rect; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsToolTip::paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget ) +{ + Q_UNUSED( option ) + Q_UNUSED( widget ) + QPainterPath path; + + QPointF anchor = mapFromParent( m_chart->mapToPosition( m_anchor, m_series ) ); + + path.addEllipse( anchor, m_radius, m_radius ); + path = path.simplified(); + + painter->setPen( QPen( Qt::black ) ); + + painter->drawPath( path ); + painter->drawText( m_textRect, m_text ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsToolTip::setSeries( QAbstractSeries* series ) +{ + m_series = series; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsToolTip::setText( const QString& text ) +{ + m_text = text; + QFontMetrics metrics( m_font ); + m_textRect = metrics.boundingRect( QRect( 0, 0, 150, 150 ), Qt::AlignLeft, m_text ); + m_textRect.translate( m_radius, 0 ); + prepareGeometryChange(); + + m_rect.setRect( -m_radius, -m_radius, m_radius, m_radius ); + m_rect.moveCenter( QPoint( m_radius, m_radius ) ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsToolTip::setAnchor( QPointF point ) +{ + m_anchor = point; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQtChartsToolTip::updateGeometry() +{ + prepareGeometryChange(); + setPos( m_chart->mapToPosition( m_anchor, m_series ) ); +} diff --git a/ApplicationLibCode/UserInterface/RiuQtChartsToolTip.h b/ApplicationLibCode/UserInterface/RiuQtChartsToolTip.h new file mode 100644 index 0000000000..d741bb83f9 --- /dev/null +++ b/ApplicationLibCode/UserInterface/RiuQtChartsToolTip.h @@ -0,0 +1,48 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include +#include +#include + +class RiuQtChartsToolTip : public QGraphicsItem +{ +public: + RiuQtChartsToolTip( QtCharts::QChart* parent, QtCharts::QAbstractSeries* series ); + + void setSeries( QtCharts::QAbstractSeries* series ); + void setText( const QString& text ); + void setAnchor( QPointF point ); + void updateGeometry(); + + QRectF boundingRect() const override; + void paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget ) override; + +private: + QString m_text; + QRectF m_textRect; + QRectF m_rect; + QPointF m_anchor; + QFont m_font; + int m_radius; + QtCharts::QChart* m_chart; + QtCharts::QAbstractSeries* m_series; +}; diff --git a/ApplicationLibCode/UserInterface/RiuQwtCurvePointTracker.cpp b/ApplicationLibCode/UserInterface/RiuQwtCurvePointTracker.cpp index 437c6c4e68..29ab863aba 100644 --- a/ApplicationLibCode/UserInterface/RiuQwtCurvePointTracker.cpp +++ b/ApplicationLibCode/UserInterface/RiuQwtCurvePointTracker.cpp @@ -20,12 +20,14 @@ #include "RiaQDateTimeTools.h" #include "RiuGuiTheme.h" - -#include "qwt_plot_marker.h" -#include "qwt_symbol.h" +#include "RiuPlotCurve.h" +#include "RiuPlotCurveInfoTextProvider.h" #include "qwt_date_scale_draw.h" #include "qwt_plot_curve.h" +#include "qwt_plot_marker.h" +#include "qwt_symbol.h" +#include "qwt_text.h" #include // For DBL_MAX @@ -34,9 +36,9 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuQwtCurvePointTracker::RiuQwtCurvePointTracker( QwtPlot* plot, - bool isMainAxisHorizontal, - IPlotCurveInfoTextProvider* curveInfoTextProvider ) +RiuQwtCurvePointTracker::RiuQwtCurvePointTracker( QwtPlot* plot, + bool isMainAxisHorizontal, + RiuPlotCurveInfoTextProvider* curveInfoTextProvider ) : QwtPlotPicker( plot->canvas() ) , m_plot( plot ) , m_isMainAxisHorizontal( isMainAxisHorizontal ) @@ -101,8 +103,8 @@ QwtText RiuQwtCurvePointTracker::trackerText( const QPoint& pos ) const if ( m_plot ) { - QwtPlot::Axis relatedYAxis = QwtPlot::yLeft; - QwtPlot::Axis relatedXAxis = QwtPlot::xBottom; + QwtAxisId relatedYAxis( QwtAxis::YLeft, 0 ); + QwtAxisId relatedXAxis( QwtAxis::XBottom, 0 ); QString curveInfoText; QString mainAxisValueString; @@ -134,12 +136,12 @@ QwtText RiuQwtCurvePointTracker::trackerText( const QPoint& pos ) const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QPointF RiuQwtCurvePointTracker::closestCurvePoint( const QPoint& cursorPosition, - QString* curveInfoText, - QString* valueAxisValueString, - QString* mainAxisValueString, - QwtPlot::Axis* relatedXAxis, - QwtPlot::Axis* relatedYAxis ) const +QPointF RiuQwtCurvePointTracker::closestCurvePoint( const QPoint& cursorPosition, + QString* curveInfoText, + QString* valueAxisValueString, + QString* mainAxisValueString, + QwtAxisId* relatedXAxis, + QwtAxisId* relatedYAxis ) const { QPointF samplePoint; @@ -168,8 +170,8 @@ QPointF RiuQwtCurvePointTracker::closestCurvePoint( const QPoint& cursorPositio { samplePoint = closestCurve->sample( closestPointSampleIndex ); - if ( relatedXAxis ) *relatedXAxis = static_cast( closestCurve->xAxis() ); - if ( relatedYAxis ) *relatedYAxis = static_cast( closestCurve->yAxis() ); + if ( relatedXAxis ) *relatedXAxis = closestCurve->xAxis(); + if ( relatedYAxis ) *relatedYAxis = closestCurve->yAxis(); } if ( mainAxisValueString ) @@ -186,7 +188,7 @@ QPointF RiuQwtCurvePointTracker::closestCurvePoint( const QPoint& cursorPositio if ( curveInfoText && closestCurve && m_curveInfoTextProvider ) { - *curveInfoText = m_curveInfoTextProvider->curveInfoText( closestCurve ); + *curveInfoText = m_curveInfoTextProvider->curveInfoText( dynamic_cast( closestCurve ) ); } if ( dateScaleDraw ) @@ -226,8 +228,8 @@ QPointF RiuQwtCurvePointTracker::closestCurvePoint( const QPoint& cursorPositio /// //-------------------------------------------------------------------------------------------------- void RiuQwtCurvePointTracker::updateClosestCurvePointMarker( const QPointF& closestPoint, - QwtPlot::Axis relatedXAxis, - QwtPlot::Axis relatedYAxis ) const + QwtAxisId relatedXAxis, + QwtAxisId relatedYAxis ) const { bool replotRequired = false; diff --git a/ApplicationLibCode/UserInterface/RiuQwtCurvePointTracker.h b/ApplicationLibCode/UserInterface/RiuQwtCurvePointTracker.h index 0f4ff14d9c..260ab76883 100644 --- a/ApplicationLibCode/UserInterface/RiuQwtCurvePointTracker.h +++ b/ApplicationLibCode/UserInterface/RiuQwtCurvePointTracker.h @@ -24,7 +24,7 @@ class QwtPlotMarker; class QwtPlotCurve; -class IPlotCurveInfoTextProvider; +class RiuPlotCurveInfoTextProvider; //-------------------------------------------------------------------------------------------------- /// Class to add mouse over-tracking of curve points with text marker @@ -32,9 +32,9 @@ class IPlotCurveInfoTextProvider; class RiuQwtCurvePointTracker : public QwtPlotPicker { public: - explicit RiuQwtCurvePointTracker( QwtPlot* plot, - bool isMainAxisHorizontal, - IPlotCurveInfoTextProvider* curveInfoTextProvider = nullptr ); + explicit RiuQwtCurvePointTracker( QwtPlot* plot, + bool isMainAxisHorizontal, + RiuPlotCurveInfoTextProvider* curveInfoTextProvider = nullptr ); ~RiuQwtCurvePointTracker() override; protected: @@ -42,27 +42,16 @@ class RiuQwtCurvePointTracker : public QwtPlotPicker void removeMarkerOnFocusLeave(); QwtText trackerText( const QPoint& pos ) const override; - QPointF closestCurvePoint( const QPoint& cursorPosition, - QString* curveInfoText, - QString* valueAxisValueString, - QString* mainAxisValueString, - QwtPlot::Axis* relatedXAxis, - QwtPlot::Axis* relatedYAxis ) const; - void updateClosestCurvePointMarker( const QPointF& closestPoint, - QwtPlot::Axis relatedXAxis, - QwtPlot::Axis relatedYAxis ) const; - - QPointer m_plot; - QwtPlotMarker* m_plotMarker; - bool m_isMainAxisHorizontal; - IPlotCurveInfoTextProvider* m_curveInfoTextProvider; -}; - -//-------------------------------------------------------------------------------------------------- -/// Interface for retrieving curve info text -//-------------------------------------------------------------------------------------------------- -class IPlotCurveInfoTextProvider -{ -public: - virtual QString curveInfoText( QwtPlotCurve* curve ) = 0; + QPointF closestCurvePoint( const QPoint& cursorPosition, + QString* curveInfoText, + QString* valueAxisValueString, + QString* mainAxisValueString, + QwtAxisId* relatedXAxis, + QwtAxisId* relatedYAxis ) const; + void updateClosestCurvePointMarker( const QPointF& closestPoint, QwtAxisId relatedXAxis, QwtAxisId relatedYAxis ) const; + + QPointer m_plot; + QwtPlotMarker* m_plotMarker; + bool m_isMainAxisHorizontal; + RiuPlotCurveInfoTextProvider* m_curveInfoTextProvider; }; diff --git a/ApplicationLibCode/UserInterface/RiuQwtDateScaleWrapper.cpp b/ApplicationLibCode/UserInterface/RiuQwtDateScaleWrapper.cpp new file mode 100644 index 0000000000..a9dd286629 --- /dev/null +++ b/ApplicationLibCode/UserInterface/RiuQwtDateScaleWrapper.cpp @@ -0,0 +1,128 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiuQwtDateScaleWrapper.h" +#include "RiuQwtPlotTools.h" + +#include "qwt_text.h" + +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuQwtDateScaleWrapper::RiuQwtDateScaleWrapper() + : m_scaleEngine( Qt::UTC ) + , m_maxMajorTicks( 7 ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQwtDateScaleWrapper::setFormatStrings( const QString& dateFormat, + const QString& timeFormat, + RiaDefines::DateFormatComponents dateComponents, + RiaDefines::TimeFormatComponents timeComponents ) +{ + std::set intervals = { QwtDate::Year, + QwtDate::Month, + QwtDate::Week, + QwtDate::Day, + QwtDate::Hour, + QwtDate::Minute, + QwtDate::Second, + QwtDate::Millisecond }; + + for ( QwtDate::IntervalType interval : intervals ) + { + m_scaleDraw.setDateFormat( interval, + RiuQwtPlotTools::dateTimeFormatForInterval( interval, + dateFormat, + timeFormat, + dateComponents, + timeComponents ) ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQwtDateScaleWrapper::setMaxMajorTicks( int tickCount ) +{ + m_maxMajorTicks = tickCount; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::tuple RiuQwtDateScaleWrapper::adjustedRange( const double& min, const double& max ) const +{ + double stepSize = 0.0; + + double adjustedMin = min; + double adjustedMax = max; + m_scaleEngine.autoScale( m_maxMajorTicks, adjustedMin, adjustedMax, stepSize ); + + auto scaleDiv = m_scaleEngine.divideScale( adjustedMin, adjustedMax, m_maxMajorTicks, 0 ); + auto ticks = scaleDiv.ticks( QwtScaleDiv::MajorTick ); + + return { adjustedMin, adjustedMax, ticks.size() - 1 }; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuQwtDateScaleWrapper::formatStringForRange( const QDateTime& min, const QDateTime& max ) +{ + auto intervalType = m_scaleEngine.intervalType( min, max, m_maxMajorTicks ); + auto dateFormat = m_scaleDraw.dateFormat( intervalType ); + + return dateFormat; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector> RiuQwtDateScaleWrapper::positionsAndLabels( const double& min, const double& max ) +{ + double stepSize = 0.0; + + double adjustedMin = min; + double adjustedMax = max; + m_scaleEngine.autoScale( m_maxMajorTicks, adjustedMin, adjustedMax, stepSize ); + + auto scaleDiv = m_scaleEngine.divideScale( adjustedMin, adjustedMax, m_maxMajorTicks, 0 ); + auto ticks = scaleDiv.ticks( QwtScaleDiv::MajorTick ); + + m_scaleDraw.setScaleDiv( scaleDiv ); + + auto formatString = + formatStringForRange( QDateTime::fromMSecsSinceEpoch( min ), QDateTime::fromMSecsSinceEpoch( max ) ); + + std::vector> valueAndLabel; + for ( auto t : ticks ) + { + auto qwtLabel = m_scaleDraw.label( t ); + auto labelText = QDateTime::fromMSecsSinceEpoch( t ).toString( formatString ); + + valueAndLabel.emplace_back( t, labelText ); + } + + return valueAndLabel; +} diff --git a/ApplicationLibCode/UserInterface/RiuQwtDateScaleWrapper.h b/ApplicationLibCode/UserInterface/RiuQwtDateScaleWrapper.h new file mode 100644 index 0000000000..ee37ecd6d1 --- /dev/null +++ b/ApplicationLibCode/UserInterface/RiuQwtDateScaleWrapper.h @@ -0,0 +1,45 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// +#pragma once + +#include "RiaQDateTimeTools.h" + +#include +#include + +class RiuQwtDateScaleWrapper +{ +public: + RiuQwtDateScaleWrapper(); + + void setFormatStrings( const QString& dateFormat, + const QString& timeFormat, + RiaDefines::DateFormatComponents dateComponents, + RiaDefines::TimeFormatComponents timeComponents ); + + void setMaxMajorTicks( int tickCount ); + QString formatStringForRange( const QDateTime& min, const QDateTime& max ); + + std::tuple adjustedRange( const double& min, const double& max ) const; + std::vector> positionsAndLabels( const double& min, const double& max ); + +private: + QwtDateScaleDraw m_scaleDraw; + QwtDateScaleEngine m_scaleEngine; + int m_maxMajorTicks; +}; diff --git a/ApplicationLibCode/UserInterface/RiuQwtLinearScaleEngine.cpp b/ApplicationLibCode/UserInterface/RiuQwtLinearScaleEngine.cpp index 633b11ea58..ff167eabc1 100644 --- a/ApplicationLibCode/UserInterface/RiuQwtLinearScaleEngine.cpp +++ b/ApplicationLibCode/UserInterface/RiuQwtLinearScaleEngine.cpp @@ -18,6 +18,8 @@ #include "RiuQwtLinearScaleEngine.h" +#include "qwt_interval.h" + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/UserInterface/RiuQwtPlotCurve.cpp b/ApplicationLibCode/UserInterface/RiuQwtPlotCurve.cpp index 5110f0f361..4f5415b654 100644 --- a/ApplicationLibCode/UserInterface/RiuQwtPlotCurve.cpp +++ b/ApplicationLibCode/UserInterface/RiuQwtPlotCurve.cpp @@ -21,29 +21,32 @@ #include "RiaCurveDataTools.h" #include "RiaImageTools.h" -#include "RiaTimeTTools.h" +#include "RiuQwtPlotTools.h" +#include "RiuQwtPlotWidget.h" #include "RiuQwtSymbol.h" #include "qwt_date.h" +#include "qwt_graphic.h" #include "qwt_interval_symbol.h" #include "qwt_painter.h" +#include "qwt_plot_curve.h" +#include "qwt_plot_intervalcurve.h" #include "qwt_point_mapper.h" #include "qwt_scale_map.h" #include "qwt_symbol.h" +#include "qwt_weeding_curve_fitter.h" +#include #include -//-------------------------------------------------------------------------------------------------- -/// Internal constants -//-------------------------------------------------------------------------------------------------- -#define DOUBLE_INF std::numeric_limits::infinity() - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuQwtPlotCurve::RiuQwtPlotCurve( const QString& title ) - : QwtPlotCurve( title ) +RiuQwtPlotCurve::RiuQwtPlotCurve( RimPlotCurve* ownerRimCurve, const QString& title ) + : RiuPlotCurve( ownerRimCurve, title ) + , QwtPlotCurve( title ) + , m_showErrorBars( false ) { this->setLegendAttribute( QwtPlotCurve::LegendShowLine, true ); this->setLegendAttribute( QwtPlotCurve::LegendShowSymbol, true ); @@ -51,9 +54,11 @@ RiuQwtPlotCurve::RiuQwtPlotCurve( const QString& title ) this->setRenderHint( QwtPlotItem::RenderAntialiased, true ); - m_symbolSkipPixelDistance = 10.0f; - - m_blackAndWhiteLegendIcon = false; + m_qwtCurveErrorBars = new QwtPlotIntervalCurve(); + m_qwtCurveErrorBars->setStyle( QwtPlotIntervalCurve::CurveStyle::NoCurve ); + m_qwtCurveErrorBars->setSymbol( new QwtIntervalSymbol( QwtIntervalSymbol::Bar ) ); + m_qwtCurveErrorBars->setItemAttribute( QwtPlotItem::Legend, false ); + m_qwtCurveErrorBars->setZ( RiuQwtPlotCurveDefines::zDepthForIndex( RiuQwtPlotCurveDefines::ZIndex::Z_ERROR_BARS ) ); } //-------------------------------------------------------------------------------------------------- @@ -61,40 +66,18 @@ RiuQwtPlotCurve::RiuQwtPlotCurve( const QString& title ) //-------------------------------------------------------------------------------------------------- RiuQwtPlotCurve::~RiuQwtPlotCurve() { -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuQwtPlotCurve::setSamplesFromXValuesAndYValues( const std::vector& xValues, - const std::vector& yValues, - bool keepOnlyPositiveValues ) -{ - computeValidIntervalsAndSetCurveData( xValues, yValues, keepOnlyPositiveValues ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuQwtPlotCurve::setSamplesFromDatesAndYValues( const std::vector& dateTimes, - const std::vector& yValues, - bool keepOnlyPositiveValues ) -{ - auto xValues = RiuQwtPlotCurve::fromQDateTime( dateTimes ); + detach(); - computeValidIntervalsAndSetCurveData( xValues, yValues, keepOnlyPositiveValues ); + delete m_qwtCurveErrorBars; + m_qwtCurveErrorBars = nullptr; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuQwtPlotCurve::setSamplesFromTimeTAndYValues( const std::vector& dateTimes, - const std::vector& yValues, - bool keepOnlyPositiveValues ) +void RiuQwtPlotCurve::setTitle( const QString& title ) { - auto xValues = RiuQwtPlotCurve::fromTime_t( dateTimes ); - - computeValidIntervalsAndSetCurveData( xValues, yValues, keepOnlyPositiveValues ); + QwtPlotCurve::setTitle( title ); } //-------------------------------------------------------------------------------------------------- @@ -111,9 +94,17 @@ void RiuQwtPlotCurve::drawCurve( QPainter* p, size_t intervalCount = m_polyLineStartStopIndices.size(); if ( intervalCount > 0 ) { - for ( size_t intIdx = 0; intIdx < intervalCount; intIdx++ ) + for ( const auto& [segmentFromCandiate, segmentToCandidate] : m_polyLineStartStopIndices ) { - if ( m_polyLineStartStopIndices[intIdx].first == m_polyLineStartStopIndices[intIdx].second ) + // Skip segments outside the requested index range + if ( static_cast( segmentToCandidate ) < from ) continue; + if ( static_cast( segmentFromCandiate ) > to ) continue; + + // Draw the curve points limited to incoming from/to indices + auto actualFromIndex = std::max( from, static_cast( segmentFromCandiate ) ); + auto actualToIndex = std::min( to, static_cast( segmentToCandidate ) ); + + if ( actualFromIndex == actualToIndex ) { // Use a symbol to draw a single value, as a single value will not be visible // when using QwtPlotCurve::drawCurve without symbols activated @@ -121,23 +112,14 @@ void RiuQwtPlotCurve::drawCurve( QPainter* p, QwtSymbol symbol( QwtSymbol::XCross ); symbol.setSize( 10, 10 ); - QwtPlotCurve::drawSymbols( p, - symbol, - xMap, - yMap, - canvasRect, - (int)m_polyLineStartStopIndices[intIdx].first, - (int)m_polyLineStartStopIndices[intIdx].second ); + QwtPlotCurve::drawSymbols( p, symbol, xMap, yMap, canvasRect, actualFromIndex, actualToIndex ); } else { - QwtPlotCurve::drawCurve( p, - style, - xMap, - yMap, - canvasRect, - (int)m_polyLineStartStopIndices[intIdx].first, - (int)m_polyLineStartStopIndices[intIdx].second ); + if ( actualFromIndex < actualToIndex ) + { + QwtPlotCurve::drawCurve( p, style, xMap, yMap, canvasRect, actualFromIndex, actualToIndex ); + } } } } @@ -235,30 +217,6 @@ void RiuQwtPlotCurve::drawSymbols( QPainter* painter, } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuQwtPlotCurve::setLineSegmentStartStopIndices( const std::vector>& lineSegmentStartStopIndices ) -{ - m_polyLineStartStopIndices = lineSegmentStartStopIndices; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuQwtPlotCurve::setSymbolSkipPixelDistance( float distance ) -{ - m_symbolSkipPixelDistance = distance >= 0.0f ? distance : 0.0f; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuQwtPlotCurve::setPerPointLabels( const std::vector& labels ) -{ - m_perPointLabels = labels; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -269,7 +227,7 @@ void RiuQwtPlotCurve::setAppearance( RiuQwtPlotCurveDefines::LineStyleEnum const QBrush& fillBrush /* = QBrush( Qt::NoBrush )*/ ) { QwtPlotCurve::CurveStyle curveStyle = QwtPlotCurve::NoCurve; - Qt::PenStyle penStyle = Qt::NoPen; + Qt::PenStyle penStyle = RiuQwtPlotCurveDefines::convertToPenStyle( lineStyle ); // Qwt bug workaround (#4135): need to set 0 curve thickness for STYLE_NONE int curveThickness = 0; @@ -287,25 +245,6 @@ void RiuQwtPlotCurve::setAppearance( RiuQwtPlotCurveDefines::LineStyleEnum curveStyle = QwtPlotCurve::Lines; break; } - - switch ( lineStyle ) - { - case RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID: - penStyle = Qt::SolidLine; - break; - case RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_DASH: - penStyle = Qt::DashLine; - break; - case RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_DOT: - penStyle = Qt::DotLine; - break; - case RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_DASH_DOT: - penStyle = Qt::DashDotLine; - break; - - default: - break; - } } QPen curvePen( curveColor ); curvePen.setWidth( curveThickness ); @@ -319,9 +258,19 @@ void RiuQwtPlotCurve::setAppearance( RiuQwtPlotCurveDefines::LineStyleEnum //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuQwtPlotCurve::setBlackAndWhiteLegendIcon( bool blackAndWhite ) +void RiuQwtPlotCurve::setBrush( const QBrush& brush ) +{ + QwtPlotCurve::setBrush( brush ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQwtPlotCurve::setColor( const QColor& color ) { - m_blackAndWhiteLegendIcon = blackAndWhite; + QPen curvePen = pen(); + curvePen.setColor( color ); + setPen( curvePen ); } //-------------------------------------------------------------------------------------------------- @@ -344,58 +293,261 @@ QwtGraphic RiuQwtPlotCurve::legendIcon( int index, const QSizeF& size ) const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuQwtPlotCurve::computeValidIntervalsAndSetCurveData( const std::vector& xValues, - const std::vector& yValues, - bool keepOnlyPositiveValues ) +QPixmap RiuQwtPlotCurve::legendIcon( const QSizeF& size ) const +{ + return legendIcon( 0, size ).toPixmap(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQwtPlotCurve::setLegendIconSize( const QSize& iconSize ) { - auto intervalsOfValidValues = RiaCurveDataTools::calculateIntervalsOfValidValues( yValues, keepOnlyPositiveValues ); + QwtPlotCurve::setLegendIconSize( iconSize ); +} - std::vector validYValues; - std::vector validXValues; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QSize RiuQwtPlotCurve::legendIconSize() const +{ + return QwtPlotCurve::legendIconSize(); +} - RiaCurveDataTools::getValuesByIntervals( yValues, intervalsOfValidValues, &validYValues ); - RiaCurveDataTools::getValuesByIntervals( xValues, intervalsOfValidValues, &validXValues ); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQwtPlotCurve::attachToPlot( RiuPlotWidget* plotWidget ) +{ + m_plotWidget = dynamic_cast( plotWidget ); + CAF_ASSERT( m_plotWidget ); - setSamples( validXValues.data(), validYValues.data(), static_cast( validXValues.size() ) ); + attach( m_plotWidget->qwtPlot() ); - setLineSegmentStartStopIndices( RiaCurveDataTools::computePolyLineStartStopIndices( intervalsOfValidValues ) ); + if ( m_showErrorBars ) + { + m_qwtCurveErrorBars->attach( m_plotWidget->qwtPlot() ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQwtPlotCurve::detach() +{ + QwtPlotCurve::detach(); + m_qwtCurveErrorBars->detach(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RiuQwtPlotCurve::fromQDateTime( const std::vector& dateTimes ) +void RiuQwtPlotCurve::showInPlot() { - std::vector doubleValues; + show(); +} - if ( !dateTimes.empty() ) +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQwtPlotCurve::setSamplesInPlot( const std::vector& xValues, const std::vector& yValues ) +{ + CAF_ASSERT( xValues.size() == yValues.size() ); + + setSamples( xValues.data(), yValues.data(), static_cast( xValues.size() ) ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQwtPlotCurve::setZ( int z ) +{ + QwtPlotCurve::setZ( z ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQwtPlotCurve::updateErrorBarsAppearance( bool showErrorBars, const QColor& curveColor ) +{ + m_showErrorBars = showErrorBars; + if ( m_qwtCurveErrorBars ) + { + QwtIntervalSymbol* newSymbol = new QwtIntervalSymbol( QwtIntervalSymbol::Bar ); + newSymbol->setPen( QPen( curveColor ) ); + m_qwtCurveErrorBars->setSymbol( newSymbol ); + m_qwtCurveErrorBars->setVisible( showErrorBars ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQwtPlotCurve::clearErrorBars() +{ + m_showErrorBars = false; + + m_qwtCurveErrorBars->setSamples( nullptr ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RiuQwtPlotCurve::numSamples() const +{ + return static_cast( dataSize() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair RiuQwtPlotCurve::sample( int index ) const +{ + CAF_ASSERT( index >= 0 && index <= numSamples() ); + auto p = QwtPlotCurve::sample( index ); + return std::make_pair( p.x(), p.y() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair RiuQwtPlotCurve::xDataRange() const +{ + return std::make_pair( minXValue(), maxXValue() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair RiuQwtPlotCurve::yDataRange() const +{ + return std::make_pair( minYValue(), maxYValue() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQwtPlotCurve::setSamplesFromXYErrorValues( const std::vector& xValues, + const std::vector& yValues, + const std::vector& errorValues, + bool useLogarithmicScale, + RiaCurveDataTools::ErrorAxis errorAxis ) +{ + CVF_ASSERT( xValues.size() == yValues.size() ); + CVF_ASSERT( xValues.size() == errorValues.size() ); + + auto intervalsOfValidValues = RiaCurveDataTools::calculateIntervalsOfValidValues( yValues, useLogarithmicScale ); + std::vector filteredYValues; + std::vector filteredXValues; + + RiaCurveDataTools::getValuesByIntervals( yValues, intervalsOfValidValues, &filteredYValues ); + RiaCurveDataTools::getValuesByIntervals( xValues, intervalsOfValidValues, &filteredXValues ); + + std::vector filteredErrorValues; + RiaCurveDataTools::getValuesByIntervals( errorValues, intervalsOfValidValues, &filteredErrorValues ); + + QVector errorIntervals; + + errorIntervals.reserve( static_cast( filteredXValues.size() ) ); + + for ( size_t i = 0; i < filteredXValues.size(); i++ ) { - doubleValues.reserve( dateTimes.size() ); + if ( !std::isinf( filteredYValues[i] ) && !std::isinf( filteredErrorValues[i] ) ) + { + if ( errorAxis == RiaCurveDataTools::ErrorAxis::ERROR_ALONG_Y_AXIS ) + { + errorIntervals << QwtIntervalSample( filteredXValues[i], + filteredYValues[i] - filteredErrorValues[i], + filteredYValues[i] + filteredErrorValues[i] ); + } + else + { + errorIntervals << QwtIntervalSample( filteredYValues[i], + filteredXValues[i] - filteredErrorValues[i], + filteredXValues[i] + filteredErrorValues[i] ); + } + } + } - for ( const auto& dt : dateTimes ) + setSamplesInPlot( filteredXValues, filteredYValues ); + + setLineSegmentStartStopIndices( intervalsOfValidValues ); + + if ( m_qwtCurveErrorBars ) + { + m_qwtCurveErrorBars->setSamples( errorIntervals ); + if ( errorAxis == RiaCurveDataTools::ErrorAxis::ERROR_ALONG_Y_AXIS ) { - doubleValues.push_back( QwtDate::toDouble( dt ) ); + m_qwtCurveErrorBars->setOrientation( Qt::Vertical ); + } + else + { + m_qwtCurveErrorBars->setOrientation( Qt::Horizontal ); } } +} - return doubleValues; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQwtPlotCurve::setXAxis( RiuPlotAxis axis ) +{ + if ( m_plotWidget ) QwtPlotCurve::setXAxis( m_plotWidget->toQwtPlotAxis( axis ) ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RiuQwtPlotCurve::fromTime_t( const std::vector& timeSteps ) +void RiuQwtPlotCurve::setYAxis( RiuPlotAxis axis ) { - std::vector doubleValues; + if ( m_plotWidget ) QwtPlotCurve::setYAxis( m_plotWidget->toQwtPlotAxis( axis ) ); +} - if ( !timeSteps.empty() ) +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQwtPlotCurve::setVisibleInLegend( bool isVisibleInLegend ) +{ + setItemAttribute( QwtPlotItem::Legend, isVisibleInLegend ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQwtPlotCurve::setSymbol( RiuPlotCurveSymbol* symbol ) +{ + auto qwtSymbol = dynamic_cast( symbol ); + QwtPlotCurve::setSymbol( qwtSymbol ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuPlotCurveSymbol* RiuQwtPlotCurve::createSymbol( RiuPlotCurveSymbol::PointSymbolEnum symbol ) const +{ + return new RiuQwtSymbol( symbol ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQwtPlotCurve::setCurveFittingTolerance( double tolerance ) +{ + bool enableCurveFitting = ( tolerance > 0.0 ); + if ( !enableCurveFitting ) { - doubleValues.reserve( timeSteps.size() ); - for ( const auto& time : timeSteps ) + setCurveAttribute( QwtPlotCurve::Fitted, false ); + } + else + { + auto cf = dynamic_cast( curveFitter() ); + if ( !cf ) { - doubleValues.push_back( RiaTimeTTools::toDouble( time ) ); + cf = new QwtWeedingCurveFitter; + setCurveFitter( cf ); } - } + setCurveAttribute( QwtPlotCurve::Fitted, true ); - return doubleValues; + cf->setTolerance( tolerance ); + } } diff --git a/ApplicationLibCode/UserInterface/RiuQwtPlotCurve.h b/ApplicationLibCode/UserInterface/RiuQwtPlotCurve.h index f83cdade33..c6f0fc213b 100644 --- a/ApplicationLibCode/UserInterface/RiuQwtPlotCurve.h +++ b/ApplicationLibCode/UserInterface/RiuQwtPlotCurve.h @@ -19,67 +19,70 @@ #pragma once +#include "RiuPlotCurve.h" #include "RiuQwtPlotCurveDefines.h" #include "qwt_plot_curve.h" -#include "qwt_plot_intervalcurve.h" -#include "qwt_symbol.h" + +class QwtPlotIntervalCurve; +class RiuQwtPlotWidget; //================================================================================================== // -// If infinite data is present in the curve data, Qwt is not able to draw a nice curve. -// This class assumes that inf data is removed, and segments to be draw are indicated by start/stop indices into curve -// data. -// -// Single values in the curve are drawn using a CrossX symbol -// -// Here you can see the curve segments visualized. Curve segments are drawn between vector indices. -// -// 0 - 1 -// 5 - 7 -// 9 -10 -// -// * * -// * * * -// Curve * * * ----- X -// -// Values 1.0|2.0|inf|inf|inf|1.0|2.0|1.0|inf|1.0|1.0|inf|1.0|inf -// Vec index 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10| 11| 12| 13 //================================================================================================== -class RiuQwtPlotCurve : public QwtPlotCurve +class RiuQwtPlotCurve : public RiuPlotCurve, public QwtPlotCurve { public: - explicit RiuQwtPlotCurve( const QString& title = QString() ); + explicit RiuQwtPlotCurve( RimPlotCurve* ownerRimCurve = nullptr, const QString& title = QString() ); ~RiuQwtPlotCurve() override; - void setSamplesFromXValuesAndYValues( const std::vector& xValues, - const std::vector& yValues, - bool keepOnlyPositiveValues ); - - void setSamplesFromDatesAndYValues( const std::vector& dateTimes, - const std::vector& yValues, - bool keepOnlyPositiveValues ); - - void setSamplesFromTimeTAndYValues( const std::vector& dateTimes, - const std::vector& yValues, - bool keepOnlyPositiveValues ); - - void setLineSegmentStartStopIndices( const std::vector>& lineSegmentStartStopIndices ); - - void setSymbolSkipPixelDistance( float distance ); - void setPerPointLabels( const std::vector& labels ); + void setTitle( const QString& title ) override; void setAppearance( RiuQwtPlotCurveDefines::LineStyleEnum lineStyle, RiuQwtPlotCurveDefines::CurveInterpolationEnum interpolationType, int curveThickness, const QColor& curveColor, - const QBrush& fillBrush = QBrush( Qt::NoBrush ) ); + const QBrush& fillBrush = QBrush( Qt::NoBrush ) ) override; + + void setBrush( const QBrush& brush ) override; + void setColor( const QColor& color ) override; + + void setLegendIconSize( const QSize& iconSize ) override; + QSize legendIconSize() const override; + QPixmap legendIcon( const QSizeF& size ) const override; - void setBlackAndWhiteLegendIcon( bool blackAndWhite ); QwtGraphic legendIcon( int index, const QSizeF& size ) const override; + void setVisibleInLegend( bool isVisibleInLegend ) override; + + void attachToPlot( RiuPlotWidget* plotWidget ) override; + void detach() override; + void showInPlot() override; + + void setZ( int z ) override; + + void updateErrorBarsAppearance( bool showErrorBars, const QColor& curveColor ) override; + void clearErrorBars() override; + + int numSamples() const override; + std::pair sample( int index ) const override; - static std::vector fromQDateTime( const std::vector& dateTimes ); - static std::vector fromTime_t( const std::vector& timeSteps ); + std::pair xDataRange() const override; + std::pair yDataRange() const override; + + void setSamplesFromXYErrorValues( + const std::vector& xValues, + const std::vector& yValues, + const std::vector& errorValues, + bool useLogarithmicScale, + RiaCurveDataTools::ErrorAxis errorAxis = RiaCurveDataTools::ErrorAxis::ERROR_ALONG_Y_AXIS ) override; + + void setXAxis( RiuPlotAxis axis ) override; + void setYAxis( RiuPlotAxis axis ) override; + + void setSymbol( RiuPlotCurveSymbol* symbol ) override; + RiuPlotCurveSymbol* createSymbol( RiuPlotCurveSymbol::PointSymbolEnum symbol ) const override; + + void setCurveFittingTolerance( double tolerance ) override; protected: void drawCurve( QPainter* p, @@ -98,16 +101,10 @@ class RiuQwtPlotCurve : public QwtPlotCurve int from, int to ) const override; -private: - void computeValidIntervalsAndSetCurveData( const std::vector& xValues, - const std::vector& yValues, - bool keepOnlyPositiveValues ); - -private: - float m_symbolSkipPixelDistance; - bool m_blackAndWhiteLegendIcon; + void setSamplesInPlot( const std::vector&, const std::vector& ) override; - std::vector m_perPointLabels; + QwtPlotIntervalCurve* m_qwtCurveErrorBars; + bool m_showErrorBars; - std::vector> m_polyLineStartStopIndices; + QPointer m_plotWidget; }; diff --git a/ApplicationLibCode/UserInterface/RiuQwtPlotCurveDefines.cpp b/ApplicationLibCode/UserInterface/RiuQwtPlotCurveDefines.cpp index 8db9feefa3..9550755efc 100644 --- a/ApplicationLibCode/UserInterface/RiuQwtPlotCurveDefines.cpp +++ b/ApplicationLibCode/UserInterface/RiuQwtPlotCurveDefines.cpp @@ -75,3 +75,22 @@ int RiuQwtPlotCurveDefines::zDepthForIndex( ZIndex index ) return 0; } + +Qt::PenStyle RiuQwtPlotCurveDefines::convertToPenStyle( RiuQwtPlotCurveDefines::LineStyleEnum lineStyle ) +{ + switch ( lineStyle ) + { + case RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_NONE: + return Qt::NoPen; + case RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID: + return Qt::SolidLine; + case RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_DASH: + return Qt::DashLine; + case RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_DOT: + return Qt::DotLine; + case RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_DASH_DOT: + return Qt::DashDotLine; + default: + return Qt::NoPen; + } +} diff --git a/ApplicationLibCode/UserInterface/RiuQwtPlotCurveDefines.h b/ApplicationLibCode/UserInterface/RiuQwtPlotCurveDefines.h index d7f670f91e..a5e4579de8 100644 --- a/ApplicationLibCode/UserInterface/RiuQwtPlotCurveDefines.h +++ b/ApplicationLibCode/UserInterface/RiuQwtPlotCurveDefines.h @@ -19,6 +19,8 @@ #pragma once +#include + namespace RiuQwtPlotCurveDefines { enum class CurveInterpolationEnum @@ -48,4 +50,6 @@ enum class ZIndex int zDepthForIndex( ZIndex index ); +Qt::PenStyle convertToPenStyle( RiuQwtPlotCurveDefines::LineStyleEnum lineStyle ); + }; // namespace RiuQwtPlotCurveDefines diff --git a/ApplicationLibCode/UserInterface/RiuQwtPlotItem.cpp b/ApplicationLibCode/UserInterface/RiuQwtPlotItem.cpp new file mode 100644 index 0000000000..21dffabca7 --- /dev/null +++ b/ApplicationLibCode/UserInterface/RiuQwtPlotItem.cpp @@ -0,0 +1,34 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiuQwtPlotItem.h" + +RiuQwtPlotItem::RiuQwtPlotItem( QwtPlotItem* qwtPlotItem ) + : RiuPlotItem() + , m_qwtPlotItem( qwtPlotItem ) +{ +} + +RiuQwtPlotItem::~RiuQwtPlotItem() +{ +} + +QwtPlotItem* RiuQwtPlotItem::qwtPlotItem() const +{ + return m_qwtPlotItem; +}; diff --git a/ApplicationLibCode/UserInterface/RiuRimQwtPlotCurve.h b/ApplicationLibCode/UserInterface/RiuQwtPlotItem.h similarity index 65% rename from ApplicationLibCode/UserInterface/RiuRimQwtPlotCurve.h rename to ApplicationLibCode/UserInterface/RiuQwtPlotItem.h index 270ed3e974..16ddc6eb07 100644 --- a/ApplicationLibCode/UserInterface/RiuRimQwtPlotCurve.h +++ b/ApplicationLibCode/UserInterface/RiuQwtPlotItem.h @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2018- Equinor ASA +// Copyright (C) 2022- Equinor ASA // // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -15,22 +15,21 @@ // for more details. // ///////////////////////////////////////////////////////////////////////////////// -#pragma once -#include "RiuQwtPlotCurve.h" +#pragma once -#include "cafPdmPointer.h" +#include "RiuPlotItem.h" -class RimPlotCurve; +class QwtPlotItem; -class RiuRimQwtPlotCurve : public RiuQwtPlotCurve +class RiuQwtPlotItem : public RiuPlotItem { public: - explicit RiuRimQwtPlotCurve( RimPlotCurve* ownerRimCurve, const QString& title = QString() ); + RiuQwtPlotItem( QwtPlotItem* qwtPlotItem ); + ~RiuQwtPlotItem() override; - RimPlotCurve* ownerRimCurve(); - const RimPlotCurve* ownerRimCurve() const; + QwtPlotItem* qwtPlotItem() const; private: - caf::PdmPointer m_ownerRimCurve; + QwtPlotItem* m_qwtPlotItem; }; diff --git a/ApplicationLibCode/UserInterface/RiuQwtPlotItemGroup.cpp b/ApplicationLibCode/UserInterface/RiuQwtPlotItemGroup.cpp index ac3a8bb28a..6a25b43d8f 100644 --- a/ApplicationLibCode/UserInterface/RiuQwtPlotItemGroup.cpp +++ b/ApplicationLibCode/UserInterface/RiuQwtPlotItemGroup.cpp @@ -18,6 +18,10 @@ #include "RiuQwtPlotItemGroup.h" +#include "qwt_graphic.h" + +#include + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/UserInterface/RiuQwtPlotLegend.cpp b/ApplicationLibCode/UserInterface/RiuQwtPlotLegend.cpp index 5c5e251da9..c98fd6caf9 100644 --- a/ApplicationLibCode/UserInterface/RiuQwtPlotLegend.cpp +++ b/ApplicationLibCode/UserInterface/RiuQwtPlotLegend.cpp @@ -18,6 +18,7 @@ #include "RiuQwtPlotLegend.h" #include "qwt_dyngrid_layout.h" +#include "qwt_legend_label.h" #include #include @@ -109,3 +110,28 @@ void RiuQwtPlotLegend::updateLegend( const QVariant& variant, const QList& legendData ) +{ + // Delete all existing widgets + deleteAll(); + + // Create legend widgets based on legendData + updateLegend( QVariant(), legendData ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQwtPlotLegend::deleteAll() +{ + auto widgets = contentsWidget()->findChildren(); + for ( auto w : widgets ) + { + w->hide(); + w->deleteLater(); + } +} diff --git a/ApplicationLibCode/UserInterface/RiuQwtPlotLegend.h b/ApplicationLibCode/UserInterface/RiuQwtPlotLegend.h index ebcc18bea6..e5db48035b 100644 --- a/ApplicationLibCode/UserInterface/RiuQwtPlotLegend.h +++ b/ApplicationLibCode/UserInterface/RiuQwtPlotLegend.h @@ -28,10 +28,14 @@ class RiuQwtPlotLegend : public QwtLegend QSize sizeHint() const override; public slots: void updateLegend( const QVariant&, const QList& ) override; + void updateLegend( const QList& ); signals: void legendUpdated(); +private: + void deleteAll(); + private: int m_columnCount; }; diff --git a/ApplicationLibCode/UserInterface/RiuQwtPlotTools.cpp b/ApplicationLibCode/UserInterface/RiuQwtPlotTools.cpp index 6dcf4d2084..9ac0460fb8 100644 --- a/ApplicationLibCode/UserInterface/RiuQwtPlotTools.cpp +++ b/ApplicationLibCode/UserInterface/RiuQwtPlotTools.cpp @@ -17,20 +17,29 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RiuQwtPlotTools.h" -#include "RiuGuiTheme.h" - #include "RiaApplication.h" +#include "RiaColorTools.h" #include "RiaPreferences.h" +#include "RiaQDateTimeTools.h" +#include "RiuPlotAxis.h" +#include "RimPlotCurve.h" + +#include "RiuGuiTheme.h" +#include "RiuQtChartsPlotCurveSymbol.h" +#include "RiuQwtPlotLegend.h" + +#include "qwt_axis.h" #include "qwt_date_scale_draw.h" #include "qwt_date_scale_engine.h" +#include "qwt_graphic.h" +#include "qwt_painter.h" #include "qwt_plot.h" #include "qwt_plot_grid.h" #include "qwt_plot_layout.h" #include "qwt_plot_shapeitem.h" #include "qwt_scale_widget.h" -#include #include //-------------------------------------------------------------------------------------------------- @@ -61,18 +70,18 @@ void RiuQwtPlotTools::setCommonPlotBehaviour( QwtPlot* plot ) // Axis number font int axisFontSize = caf::FontTools::absolutePointSize( RiaPreferences::current()->defaultPlotFontSize(), caf::FontTools::RelativeSize::Medium ); - QFont axisFont = plot->axisFont( QwtPlot::xBottom ); + QFont axisFont = plot->axisFont( QwtAxis::XBottom ); axisFont.setPixelSize( caf::FontTools::pointSizeToPixelSize( axisFontSize ) ); - plot->setAxisFont( QwtPlot::xBottom, axisFont ); - plot->setAxisFont( QwtPlot::xTop, axisFont ); - plot->setAxisFont( QwtPlot::yLeft, axisFont ); - plot->setAxisFont( QwtPlot::yRight, axisFont ); + plot->setAxisFont( QwtAxis::XBottom, axisFont ); + plot->setAxisFont( QwtAxis::XTop, axisFont ); + plot->setAxisFont( QwtAxis::YLeft, axisFont ); + plot->setAxisFont( QwtAxis::YRight, axisFont ); // Axis title font - std::vector axes = { QwtPlot::xBottom, QwtPlot::xTop, QwtPlot::yLeft, QwtPlot::yRight }; + std::vector axes = { QwtAxis::XBottom, QwtAxis::XTop, QwtAxis::YLeft, QwtAxis::YRight }; - for ( QwtPlot::Axis axis : axes ) + for ( QwtAxis::Position axis : axes ) { QwtText axisTitle = plot->axisTitle( axis ); QFont axisTitleFont = axisTitle.font(); @@ -109,28 +118,26 @@ void RiuQwtPlotTools::setCommonPlotBehaviour( QwtPlot* plot ) //-------------------------------------------------------------------------------------------------- void RiuQwtPlotTools::setDefaultAxes( QwtPlot* plot ) { - plot->enableAxis( QwtPlot::xBottom, true ); - plot->enableAxis( QwtPlot::yLeft, true ); - plot->enableAxis( QwtPlot::xTop, false ); - plot->enableAxis( QwtPlot::yRight, false ); - - plot->axisWidget( QwtPlot::xBottom )->setMargin( 0 ); - plot->axisWidget( QwtPlot::yLeft )->setMargin( 0 ); - plot->axisWidget( QwtPlot::xTop )->setMargin( 0 ); - plot->axisWidget( QwtPlot::yRight )->setMargin( 0 ); - - plot->setAxisMaxMinor( QwtPlot::xBottom, 2 ); - plot->setAxisMaxMinor( QwtPlot::yLeft, 3 ); + plot->setAxesCount( QwtAxis::XBottom, 1 ); + plot->setAxesCount( QwtAxis::YLeft, 1 ); + + plot->axisWidget( QwtAxis::XBottom )->setMargin( 0 ); + plot->axisWidget( QwtAxis::YLeft )->setMargin( 0 ); + plot->axisWidget( QwtAxis::XTop )->setMargin( 0 ); + plot->axisWidget( QwtAxis::YRight )->setMargin( 0 ); + + plot->setAxisMaxMinor( QwtAxis::XBottom, 2 ); + plot->setAxisMaxMinor( QwtAxis::YLeft, 3 ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuQwtPlotTools::enableDateBasedBottomXAxis( QwtPlot* plot, - const QString& dateFormat, - const QString& timeFormat, - RiaQDateTimeTools::DateFormatComponents dateComponents, - RiaQDateTimeTools::TimeFormatComponents timeComponents ) +void RiuQwtPlotTools::enableDateBasedBottomXAxis( QwtPlot* plot, + const QString& dateFormat, + const QString& timeFormat, + RiaDefines::DateFormatComponents dateComponents, + RiaDefines::TimeFormatComponents timeComponents ) { QwtDateScaleDraw* scaleDraw = new QwtDateScaleDraw( Qt::UTC ); @@ -150,21 +157,21 @@ void RiuQwtPlotTools::enableDateBasedBottomXAxis( QwtPlot* } QwtDateScaleEngine* scaleEngine = new QwtDateScaleEngine( Qt::UTC ); - plot->setAxisScaleEngine( QwtPlot::xBottom, scaleEngine ); - plot->setAxisScaleDraw( QwtPlot::xBottom, scaleDraw ); + plot->setAxisScaleEngine( QwtAxis::XBottom, scaleEngine ); + plot->setAxisScaleDraw( QwtAxis::XBottom, scaleDraw ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RiuQwtPlotTools::dateTimeFormatForInterval( QwtDate::IntervalType interval, - const QString& dateFormat, - const QString& timeFormat, - RiaQDateTimeTools::DateFormatComponents dateComponents, - RiaQDateTimeTools::TimeFormatComponents timeComponents ) +QString RiuQwtPlotTools::dateTimeFormatForInterval( QwtDate::IntervalType interval, + const QString& dateFormat, + const QString& timeFormat, + RiaDefines::DateFormatComponents dateComponents, + RiaDefines::TimeFormatComponents timeComponents ) { - if ( dateComponents != RiaQDateTimeTools::DATE_FORMAT_UNSPECIFIED && - timeComponents != RiaQDateTimeTools::TimeFormatComponents::TIME_FORMAT_UNSPECIFIED ) + if ( dateComponents != RiaDefines::DateFormatComponents::DATE_FORMAT_UNSPECIFIED && + timeComponents != RiaDefines::TimeFormatComponents::TIME_FORMAT_UNSPECIFIED ) { return RiaQDateTimeTools::timeFormatString( timeFormat, timeComponents ) + "\n" + RiaQDateTimeTools::dateFormatString( dateFormat, dateComponents ); @@ -175,44 +182,49 @@ QString RiuQwtPlotTools::dateTimeFormatForInterval( QwtDate::IntervalType { case QwtDate::Millisecond: return RiaQDateTimeTools::timeFormatString( timeFormat, - RiaQDateTimeTools::TimeFormatComponents::TIME_FORMAT_HOUR_MINUTE_SECOND_MILLISECOND ); + RiaDefines::TimeFormatComponents::TIME_FORMAT_HOUR_MINUTE_SECOND_MILLISECOND ); case QwtDate::Second: return RiaQDateTimeTools::timeFormatString( timeFormat, - RiaQDateTimeTools::TimeFormatComponents::TIME_FORMAT_HOUR_MINUTE_SECOND ); + RiaDefines::TimeFormatComponents::TIME_FORMAT_HOUR_MINUTE_SECOND ); case QwtDate::Minute: { QString fullFormat = RiaQDateTimeTools::timeFormatString( timeFormat, - RiaQDateTimeTools::TimeFormatComponents::TIME_FORMAT_HOUR_MINUTE ); + RiaDefines::TimeFormatComponents::TIME_FORMAT_HOUR_MINUTE ); fullFormat += "\n"; fullFormat += - RiaQDateTimeTools::dateFormatString( dateFormat, RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH_DAY ); + RiaQDateTimeTools::dateFormatString( dateFormat, + RiaDefines::DateFormatComponents::DATE_FORMAT_YEAR_MONTH_DAY ); return fullFormat; } case QwtDate::Hour: { QString fullFormat = - RiaQDateTimeTools::timeFormatString( timeFormat, - RiaQDateTimeTools::TimeFormatComponents::TIME_FORMAT_HOUR ); + RiaQDateTimeTools::timeFormatString( timeFormat, RiaDefines::TimeFormatComponents::TIME_FORMAT_HOUR ); if ( !fullFormat.endsWith( "AP" ) ) { fullFormat += ":00"; } fullFormat += "\n"; fullFormat += - RiaQDateTimeTools::dateFormatString( dateFormat, RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH_DAY ); + RiaQDateTimeTools::dateFormatString( dateFormat, + RiaDefines::DateFormatComponents::DATE_FORMAT_YEAR_MONTH_DAY ); return fullFormat; } case QwtDate::Day: - return RiaQDateTimeTools::dateFormatString( dateFormat, RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH_DAY ); + return RiaQDateTimeTools::dateFormatString( dateFormat, + RiaDefines::DateFormatComponents::DATE_FORMAT_YEAR_MONTH_DAY ); case QwtDate::Week: - return RiaQDateTimeTools::dateFormatString( dateFormat, RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH ); + return RiaQDateTimeTools::dateFormatString( dateFormat, + RiaDefines::DateFormatComponents::DATE_FORMAT_YEAR_MONTH ); case QwtDate::Month: - return RiaQDateTimeTools::dateFormatString( dateFormat, RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH ); + return RiaQDateTimeTools::dateFormatString( dateFormat, + RiaDefines::DateFormatComponents::DATE_FORMAT_YEAR_MONTH ); case QwtDate::Year: - return RiaQDateTimeTools::dateFormatString( dateFormat, RiaQDateTimeTools::DATE_FORMAT_YEAR ); + return RiaQDateTimeTools::dateFormatString( dateFormat, RiaDefines::DateFormatComponents::DATE_FORMAT_YEAR ); default: - return RiaQDateTimeTools::dateFormatString( dateFormat, RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH_DAY ); + return RiaQDateTimeTools::dateFormatString( dateFormat, + RiaDefines::DateFormatComponents::DATE_FORMAT_YEAR_MONTH_DAY ); } } } @@ -230,3 +242,105 @@ QwtPlotShapeItem* RiuQwtPlotTools::createBoxShape( const QString& label, { return createBoxShapeT( label, startX, endX, startY, endY, color, brushStyle ); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QwtAxis::Position RiuQwtPlotTools::toQwtPlotAxisEnum( RiaDefines::PlotAxis riaPlotAxis ) +{ + if ( riaPlotAxis == RiaDefines::PlotAxis::PLOT_AXIS_LEFT ) + return QwtAxis::YLeft; + else if ( riaPlotAxis == RiaDefines::PlotAxis::PLOT_AXIS_RIGHT ) + return QwtAxis::YRight; + else if ( riaPlotAxis == RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM ) + return QwtAxis::XBottom; + else if ( riaPlotAxis == RiaDefines::PlotAxis::PLOT_AXIS_TOP ) + return QwtAxis::XTop; + + return QwtAxis::YLeft; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaDefines::PlotAxis RiuQwtPlotTools::fromQwtPlotAxis( QwtAxis::Position axis ) +{ + if ( axis == QwtAxis::YLeft ) + return RiaDefines::PlotAxis::PLOT_AXIS_LEFT; + else if ( axis == QwtAxis::YRight ) + return RiaDefines::PlotAxis::PLOT_AXIS_RIGHT; + else if ( axis == QwtAxis::XBottom ) + return RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM; + else if ( axis == QwtAxis::XTop ) + return RiaDefines::PlotAxis::PLOT_AXIS_TOP; + + return RiaDefines::PlotAxis::PLOT_AXIS_LEFT; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQwtPlotTools::updateLegendData( RiuQwtPlotLegend* legend, const std::vector& curves ) +{ + QList legendDataList = createLegendData( curves ); + + legend->updateLegend( QVariant(), legendDataList ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RiuQwtPlotTools::createLegendData( const std::vector& curves ) +{ + QList legendDataList; + + for ( auto c : curves ) + { + QwtLegendData test; + test.setValue( QwtLegendData::Role::TitleRole, c->curveName() ); + + c->updateUiIconFromPlotSymbol(); + auto icon = c->uiIcon(); + auto size = icon->availableSizes().first(); + // see QwtPlotCurve::legendIcon + + QwtGraphic graphic; + { + graphic.setDefaultSize( size ); + graphic.setRenderHint( QwtGraphic::RenderPensUnscaled, true ); + + QPainter painter( &graphic ); + painter.setRenderHint( QPainter::Antialiasing ); + + { + QPen pn; + pn.setCapStyle( Qt::FlatCap ); + pn.setColor( RiaColorTools::toQColor( c->color() ) ); + + painter.setPen( pn ); + + const double y = 0.5 * size.height(); + QwtPainter::drawLine( &painter, 0.0, y, size.width(), y ); + } + + if ( c->symbol() != RiuQtChartsPlotCurveSymbol::SYMBOL_NONE ) + { + RiuQtChartsPlotCurveSymbol symbol( c->symbol() ); + symbol.setSize( size.height() / 2, size.height() / 2 ); + symbol.setColor( RiaColorTools::toQColor( c->color() ) ); + + auto image = symbol.image(); + + QPoint p( size.width() / 4, size.height() / 4 ); + painter.drawImage( p, image ); + } + } + + QVariant v = QVariant::fromValue( graphic ); + test.setValue( QwtLegendData::Role::IconRole, v ); + + legendDataList.push_back( test ); + } + + return legendDataList; +} diff --git a/ApplicationLibCode/UserInterface/RiuQwtPlotTools.h b/ApplicationLibCode/UserInterface/RiuQwtPlotTools.h index 27121e3a95..058c0fbb46 100644 --- a/ApplicationLibCode/UserInterface/RiuQwtPlotTools.h +++ b/ApplicationLibCode/UserInterface/RiuQwtPlotTools.h @@ -17,28 +17,36 @@ ///////////////////////////////////////////////////////////////////////////////// #pragma once -#include "RiaQDateTimeTools.h" +#include "RiaDateTimeDefines.h" +#include "RiaPlotDefines.h" + +#include #include #include #include +class RiuQwtPlotLegend; +class RimPlotCurve; + +class RiuPlotAxis; + class RiuQwtPlotTools { public: static void setCommonPlotBehaviour( QwtPlot* plot ); static void setDefaultAxes( QwtPlot* plot ); static void enableDateBasedBottomXAxis( - QwtPlot* plot, - const QString& dateFormat, - const QString& timeFormat, - RiaQDateTimeTools::DateFormatComponents dateComponents = RiaQDateTimeTools::DATE_FORMAT_UNSPECIFIED, - RiaQDateTimeTools::TimeFormatComponents timeComponents = RiaQDateTimeTools::TimeFormatComponents::TIME_FORMAT_UNSPECIFIED ); + QwtPlot* plot, + const QString& dateFormat, + const QString& timeFormat, + RiaDefines::DateFormatComponents dateComponents = RiaDefines::DateFormatComponents::DATE_FORMAT_UNSPECIFIED, + RiaDefines::TimeFormatComponents timeComponents = RiaDefines::TimeFormatComponents::TIME_FORMAT_UNSPECIFIED ); - static QString dateTimeFormatForInterval( QwtDate::IntervalType interval, - const QString& dateFormat, - const QString& timeFormat, - RiaQDateTimeTools::DateFormatComponents dateComponents, - RiaQDateTimeTools::TimeFormatComponents timeComponents ); + static QString dateTimeFormatForInterval( QwtDate::IntervalType interval, + const QString& dateFormat, + const QString& timeFormat, + RiaDefines::DateFormatComponents dateComponents, + RiaDefines::TimeFormatComponents timeComponents ); static QwtPlotShapeItem* createBoxShape( const QString& label, double startX, @@ -56,6 +64,12 @@ class RiuQwtPlotTools double endY, QColor color, Qt::BrushStyle brushStyle = Qt::SolidPattern ); + + static void updateLegendData( RiuQwtPlotLegend* legend, const std::vector& curves ); + static QList createLegendData( const std::vector& curves ); + static QwtAxis::Position toQwtPlotAxisEnum( RiaDefines::PlotAxis riaPlotAxis ); + + static RiaDefines::PlotAxis fromQwtPlotAxis( QwtAxis::Position ); }; //-------------------------------------------------------------------------------------------------- @@ -79,7 +93,7 @@ PlotShapeItemType* RiuQwtPlotTools::createBoxShapeT( const QString& label, polygon.push_back( QPointF( startX, endY ) ); polygon.push_back( QPointF( startX, startY ) ); columnShape->setPolygon( polygon ); - columnShape->setXAxis( QwtPlot::xBottom ); + columnShape->setXAxis( QwtAxis::XBottom ); columnShape->setBrush( QBrush( color, brushStyle ) ); columnShape->setLegendMode( QwtPlotShapeItem::LegendShape ); columnShape->setLegendIconSize( QSize( 16, 16 ) ); diff --git a/ApplicationLibCode/UserInterface/RiuQwtPlotWheelZoomer.cpp b/ApplicationLibCode/UserInterface/RiuQwtPlotWheelZoomer.cpp index ec0fbc790a..2265f8c9c0 100644 --- a/ApplicationLibCode/UserInterface/RiuQwtPlotWheelZoomer.cpp +++ b/ApplicationLibCode/UserInterface/RiuQwtPlotWheelZoomer.cpp @@ -18,8 +18,12 @@ #include "RiuQwtPlotWheelZoomer.h" +#include "caf.h" + +#include "qwt_interval.h" #include "qwt_plot.h" #include "qwt_scale_div.h" +#include "qwt_scale_map.h" #include #include @@ -43,7 +47,7 @@ RiuQwtPlotWheelZoomer::RiuQwtPlotWheelZoomer( QwtPlot* plot ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuQwtPlotWheelZoomer::zoomOnAxis( QwtPlot* plot, QwtPlot::Axis axis, double zoomFactor, int eventPos ) +void RiuQwtPlotWheelZoomer::zoomOnAxis( QwtPlot* plot, QwtAxis::Position axis, double zoomFactor, int eventPos ) { QwtScaleMap scaleMap = plot->canvasMap( axis ); double zoomCenter = scaleMap.invTransform( eventPos ); @@ -71,7 +75,7 @@ void RiuQwtPlotWheelZoomer::zoomOnAxis( QwtPlot* plot, QwtPlot::Axis axis, doubl //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RiuQwtPlotWheelZoomer::axisIsLogarithmic( QwtPlot::Axis axis ) const +bool RiuQwtPlotWheelZoomer::axisIsLogarithmic( QwtAxis::Position axis ) const { auto it = m_axesAreLogarithmic.find( axis ); return it != m_axesAreLogarithmic.end() ? it->second : false; @@ -86,15 +90,16 @@ bool RiuQwtPlotWheelZoomer::eventFilter( QObject* watched, QEvent* event ) if ( wheelEvent ) { double zoomFactor = 1.0 / RIU_SCROLLWHEEL_ZOOMFACTOR; - if ( wheelEvent->delta() > 0 ) + if ( wheelEvent->angleDelta().y() > 0 ) { zoomFactor = RIU_SCROLLWHEEL_ZOOMFACTOR; } - zoomOnAxis( m_plot, QwtPlot::xBottom, zoomFactor, wheelEvent->pos().x() ); - zoomOnAxis( m_plot, QwtPlot::xTop, zoomFactor, wheelEvent->pos().x() ); - zoomOnAxis( m_plot, QwtPlot::yLeft, zoomFactor, wheelEvent->pos().y() ); - zoomOnAxis( m_plot, QwtPlot::yRight, zoomFactor, wheelEvent->pos().y() ); + auto position = caf::position( wheelEvent ); + zoomOnAxis( m_plot, QwtAxis::XBottom, zoomFactor, position.x() ); + zoomOnAxis( m_plot, QwtAxis::XTop, zoomFactor, position.x() ); + zoomOnAxis( m_plot, QwtAxis::YLeft, zoomFactor, position.y() ); + zoomOnAxis( m_plot, QwtAxis::YRight, zoomFactor, position.y() ); m_plot->replot(); emit zoomUpdated(); @@ -106,7 +111,7 @@ bool RiuQwtPlotWheelZoomer::eventFilter( QObject* watched, QEvent* event ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuQwtPlotWheelZoomer::setAxisIsLogarithmic( QwtPlot::Axis axis, bool logarithmic ) +void RiuQwtPlotWheelZoomer::setAxisIsLogarithmic( QwtAxis::Position axis, bool logarithmic ) { m_axesAreLogarithmic[axis] = logarithmic; } diff --git a/ApplicationLibCode/UserInterface/RiuQwtPlotWheelZoomer.h b/ApplicationLibCode/UserInterface/RiuQwtPlotWheelZoomer.h index e589c0aae5..1c32c646f4 100644 --- a/ApplicationLibCode/UserInterface/RiuQwtPlotWheelZoomer.h +++ b/ApplicationLibCode/UserInterface/RiuQwtPlotWheelZoomer.h @@ -33,17 +33,17 @@ class RiuQwtPlotWheelZoomer : public QObject bool eventFilter( QObject* watched, QEvent* event ) override; - void setAxisIsLogarithmic( QwtPlot::Axis axis, bool logarithmic ); + void setAxisIsLogarithmic( QwtAxis::Position axis, bool logarithmic ); signals: void zoomUpdated(); private: - void zoomOnAxis( QwtPlot* plot, QwtPlot::Axis axis, double zoomFactor, int eventPos ); - bool axisIsLogarithmic( QwtPlot::Axis axis ) const; + void zoomOnAxis( QwtPlot* plot, QwtAxis::Position axis, double zoomFactor, int eventPos ); + bool axisIsLogarithmic( QwtAxis::Position axis ) const; private: QwtPlot* m_plot; - std::map m_axesAreLogarithmic; + std::map m_axesAreLogarithmic; }; diff --git a/ApplicationLibCode/UserInterface/RiuQwtPlotWidget.cpp b/ApplicationLibCode/UserInterface/RiuQwtPlotWidget.cpp index cbbdabcde0..051d5bcd3d 100644 --- a/ApplicationLibCode/UserInterface/RiuQwtPlotWidget.cpp +++ b/ApplicationLibCode/UserInterface/RiuQwtPlotWidget.cpp @@ -20,21 +20,29 @@ #include "RiuQwtPlotWidget.h" #include "RiaColorTools.h" -#include "RiaFontCache.h" +#include "RiaDefines.h" #include "RiaGuiApplication.h" +#include "RiaPlotDefines.h" #include "RiaPlotWindowRedrawScheduler.h" + #include "RimPlot.h" #include "RiuDraggableOverlayFrame.h" #include "RiuGuiTheme.h" +#include "RiuPlotAxis.h" #include "RiuPlotMainWindowTools.h" +#include "RiuPlotWidget.h" #include "RiuQwtCurvePointTracker.h" #include "RiuQwtLinearScaleEngine.h" +#include "RiuQwtPlotCurve.h" +#include "RiuQwtPlotItem.h" #include "RiuQwtPlotTools.h" #include "RiuQwtScalePicker.h" #include "cafAssert.h" +#include "qwt_axis.h" +#include "qwt_date_scale_engine.h" #include "qwt_legend.h" #include "qwt_legend_label.h" #include "qwt_plot_barchart.h" @@ -46,107 +54,83 @@ #include "qwt_plot_renderer.h" #include "qwt_plot_shapeitem.h" #include "qwt_scale_draw.h" +#include "qwt_scale_engine.h" #include "qwt_scale_widget.h" #include "qwt_symbol.h" #include "qwt_text.h" #include "qwt_text_label.h" -#include -#include #include #include -#include -#include -#include #include -#include +#include +#include +#include #include #include #include +#include "RiaLogging.h" + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RiuQwtPlotWidget::RiuQwtPlotWidget( RimPlot* plotDefinition, QWidget* parent ) - : QwtPlot( parent ) - , m_plotDefinition( plotDefinition ) - , m_overlayMargins( 5 ) - , m_plotTitle( "" ) - , m_plotTitleEnabled( true ) + : RiuPlotWidget( plotDefinition, parent ) { CAF_ASSERT( m_plotDefinition ); - RiuQwtPlotTools::setCommonPlotBehaviour( this ); - this->installEventFilter( this ); - this->canvas()->installEventFilter( this ); + auto* layout = new QVBoxLayout; + layout->setContentsMargins( 0, 0, 0, 0 ); + setLayout( layout ); - this->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); -} + m_plot = new QwtPlot( this ); + m_plot->setAcceptDrops( true ); + layout->addWidget( m_plot ); -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RiuQwtPlotWidget::~RiuQwtPlotWidget() -{ - if ( m_plotDefinition ) - { - m_plotDefinition->detachAllCurves(); - } -} + RiuQwtPlotTools::setCommonPlotBehaviour( m_plot ); -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimPlot* RiuQwtPlotWidget::plotDefinition() -{ - return m_plotDefinition; -} + m_plot->installEventFilter( this ); + m_plot->canvas()->installEventFilter( this ); -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RiuQwtPlotWidget::isChecked() const -{ - if ( m_plotDefinition ) - { - return m_plotDefinition->showWindow(); - } - return false; -} + setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -int RiuQwtPlotWidget::colSpan() const -{ - if ( m_plotDefinition ) - { - return m_plotDefinition->colSpan(); - } - return 1; + connect( this, SIGNAL( plotSelected( bool ) ), plotDefinition, SLOT( onPlotSelected( bool ) ) ); + connect( this, SIGNAL( axisSelected( RiuPlotAxis, bool ) ), plotDefinition, SLOT( onAxisSelected( RiuPlotAxis, bool ) ) ); + connect( this, + SIGNAL( plotItemSelected( std::shared_ptr, bool, int ) ), + plotDefinition, + SLOT( onPlotItemSelected( std::shared_ptr, bool, int ) ) ); + connect( this, SIGNAL( onKeyPressEvent( QKeyEvent* ) ), plotDefinition, SLOT( onKeyPressEvent( QKeyEvent* ) ) ); + connect( this, SIGNAL( onWheelEvent( QWheelEvent* ) ), plotDefinition, SLOT( onWheelEvent( QWheelEvent* ) ) ); + connect( this, SIGNAL( destroyed() ), plotDefinition, SLOT( onViewerDestroyed() ) ); + + ensureAxisIsCreated( RiuPlotAxis::defaultLeft() ); + ensureAxisIsCreated( RiuPlotAxis::defaultBottom() ); + ensureAxisIsCreated( RiuPlotAxis::defaultRight() ); + ensureAxisIsCreated( RiuPlotAxis::defaultTop() ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -int RiuQwtPlotWidget::rowSpan() const +RiuQwtPlotWidget::~RiuQwtPlotWidget() { if ( m_plotDefinition ) { - return m_plotDefinition->rowSpan(); + m_plotDefinition->detachAllCurves(); } - return 1; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -int RiuQwtPlotWidget::axisTitleFontSize( QwtPlot::Axis axis ) const +int RiuQwtPlotWidget::axisTitleFontSize( RiuPlotAxis axis ) const { - if ( this->axisEnabled( axis ) ) + if ( axisEnabled( axis ) ) { - return this->axisFont( axis ).pointSize(); + return m_plot->axisFont( toQwtPlotAxis( axis ) ).pointSize(); } return -1; } @@ -154,11 +138,11 @@ int RiuQwtPlotWidget::axisTitleFontSize( QwtPlot::Axis axis ) const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -int RiuQwtPlotWidget::axisValueFontSize( QwtPlot::Axis axis ) const +int RiuQwtPlotWidget::axisValueFontSize( RiuPlotAxis axis ) const { - if ( this->axisEnabled( axis ) ) + if ( axisEnabled( axis ) ) { - return this->axisTitle( axis ).font().pointSize(); + return m_plot->axisTitle( toQwtPlotAxis( axis ) ).font().pointSize(); } return -1; } @@ -166,30 +150,28 @@ int RiuQwtPlotWidget::axisValueFontSize( QwtPlot::Axis axis ) const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuQwtPlotWidget::setAxisFontsAndAlignment( QwtPlot::Axis axis, - int titleFontSize, - int valueFontSize, - bool titleBold, - int alignment ) +void RiuQwtPlotWidget::setAxisFontsAndAlignment( RiuPlotAxis axis, int titleFontSize, int valueFontSize, bool titleBold, int alignment ) { int titleFontPixelSize = caf::FontTools::pointSizeToPixelSize( titleFontSize ); int valueFontPixelSize = caf::FontTools::pointSizeToPixelSize( valueFontSize ); // Axis number font - QFont axisFont = this->axisFont( axis ); + + auto qwtAxis = toQwtPlotAxis( axis ); + QFont axisFont = m_plot->axisFont( qwtAxis ); axisFont.setPixelSize( valueFontPixelSize ); axisFont.setBold( false ); - this->setAxisFont( axis, axisFont ); + m_plot->setAxisFont( qwtAxis, axisFont ); // Axis title font - QwtText axisTitle = this->axisTitle( axis ); + QwtText axisTitle = m_plot->axisTitle( qwtAxis ); QFont axisTitleFont = axisTitle.font(); axisTitleFont.setPixelSize( titleFontPixelSize ); axisTitleFont.setBold( titleBold ); axisTitle.setFont( axisTitleFont ); axisTitle.setRenderFlags( alignment | Qt::TextWordWrap ); - setAxisTitle( axis, axisTitle ); + m_plot->setAxisTitle( qwtAxis, axisTitle ); applyAxisTitleToQwt( axis ); } @@ -198,7 +180,7 @@ void RiuQwtPlotWidget::setAxisFontsAndAlignment( QwtPlot::Axis axis, //-------------------------------------------------------------------------------------------------- void RiuQwtPlotWidget::setAxesFontsAndAlignment( int titleFontSize, int valueFontSize, bool titleBold, int alignment ) { - for ( auto axisTitlePair : m_axisTitles ) + for ( const auto& axisTitlePair : m_axisTitles ) { setAxisFontsAndAlignment( axisTitlePair.first, titleFontSize, valueFontSize, titleBold, alignment ); } @@ -207,7 +189,7 @@ void RiuQwtPlotWidget::setAxesFontsAndAlignment( int titleFontSize, int valueFon //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuQwtPlotWidget::setAxisTitleText( QwtPlot::Axis axis, const QString& title ) +void RiuQwtPlotWidget::setAxisTitleText( RiuPlotAxis axis, const QString& title ) { m_axisTitles[axis] = title; applyAxisTitleToQwt( axis ); @@ -216,7 +198,7 @@ void RiuQwtPlotWidget::setAxisTitleText( QwtPlot::Axis axis, const QString& titl //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuQwtPlotWidget::setAxisTitleEnabled( QwtPlot::Axis axis, bool enable ) +void RiuQwtPlotWidget::setAxisTitleEnabled( RiuPlotAxis axis, bool enable ) { m_axisTitlesEnabled[axis] = enable; applyAxisTitleToQwt( axis ); @@ -261,11 +243,11 @@ bool RiuQwtPlotWidget::plotTitleEnabled() const //-------------------------------------------------------------------------------------------------- void RiuQwtPlotWidget::setPlotTitleFontSize( int titleFontSize ) { - auto title = this->title(); + auto title = m_plot->title(); QFont font = title.font(); font.setPixelSize( caf::FontTools::pointSizeToPixelSize( titleFontSize ) ); title.setFont( font ); - setTitle( title ); + m_plot->setTitle( title ); } //-------------------------------------------------------------------------------------------------- @@ -273,13 +255,13 @@ void RiuQwtPlotWidget::setPlotTitleFontSize( int titleFontSize ) //-------------------------------------------------------------------------------------------------- void RiuQwtPlotWidget::setLegendFontSize( int fontSize ) { - if ( legend() ) + if ( m_plot->legend() ) { - QFont font = legend()->font(); + QFont font = m_plot->legend()->font(); font.setPixelSize( caf::FontTools::pointSizeToPixelSize( fontSize ) ); - legend()->setFont( font ); + m_plot->legend()->setFont( font ); // Set font size for all existing labels - QList labels = legend()->findChildren(); + QList labels = m_plot->legend()->findChildren(); for ( QwtLegendLabel* label : labels ) { label->setFont( font ); @@ -294,30 +276,50 @@ void RiuQwtPlotWidget::setInternalLegendVisible( bool visible ) { if ( visible ) { - QwtLegend* legend = new QwtLegend( this ); - this->insertLegend( legend, BottomLegend ); + auto* legend = new QwtLegend( this ); + m_plot->insertLegend( legend, QwtPlot::BottomLegend ); } else { - this->insertLegend( nullptr ); + m_plot->insertLegend( nullptr ); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QwtInterval RiuQwtPlotWidget::axisRange( QwtPlot::Axis axis ) const +void RiuQwtPlotWidget::insertLegend( RiuPlotWidget::Legend legendPosition ) +{ + CAF_ASSERT( legendPosition == RiuPlotWidget::Legend::BOTTOM ); + + auto* legend = new QwtLegend( this ); + m_plot->insertLegend( legend, QwtPlot::BottomLegend ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQwtPlotWidget::clearLegend() +{ + m_plot->insertLegend( nullptr ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair RiuQwtPlotWidget::axisRange( RiuPlotAxis axis ) const { - return axisScaleDiv( axis ).interval(); + QwtInterval interval = m_plot->axisScaleDiv( toQwtPlotAxis( axis ) ).interval(); + return std::make_pair( interval.minValue(), interval.maxValue() ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuQwtPlotWidget::setAxisRange( QwtPlot::Axis axis, double min, double max ) +void RiuQwtPlotWidget::setAxisRange( RiuPlotAxis axis, double min, double max ) { // Note: Especially the Y-axis may be inverted - if ( axisScaleEngine( axis )->testAttribute( QwtScaleEngine::Inverted ) ) + if ( m_plot->axisScaleEngine( toQwtPlotAxis( axis ) )->testAttribute( QwtScaleEngine::Inverted ) ) { setAxisScale( axis, max, min ); } @@ -330,39 +332,40 @@ void RiuQwtPlotWidget::setAxisRange( QwtPlot::Axis axis, double min, double max //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuQwtPlotWidget::setAxisInverted( QwtPlot::Axis axis ) +void RiuQwtPlotWidget::setAxisInverted( RiuPlotAxis axis, bool isInverted ) { - axisScaleEngine( axis )->setAttribute( QwtScaleEngine::Inverted, true ); + m_plot->axisScaleEngine( toQwtPlotAxis( axis ) )->setAttribute( QwtScaleEngine::Inverted, isInverted ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuQwtPlotWidget::setAxisLabelsAndTicksEnabled( QwtPlot::Axis axis, bool enableLabels, bool enableTicks ) +void RiuQwtPlotWidget::setAxisLabelsAndTicksEnabled( RiuPlotAxis axis, bool enableLabels, bool enableTicks ) { - this->axisScaleDraw( axis )->enableComponent( QwtAbstractScaleDraw::Ticks, enableTicks ); - this->axisScaleDraw( axis )->enableComponent( QwtAbstractScaleDraw::Labels, enableLabels ); + m_plot->axisScaleDraw( toQwtPlotAxis( axis ) )->enableComponent( QwtAbstractScaleDraw::Ticks, enableTicks ); + m_plot->axisScaleDraw( toQwtPlotAxis( axis ) )->enableComponent( QwtAbstractScaleDraw::Labels, enableLabels ); recalculateAxisExtents( axis ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuQwtPlotWidget::enableGridLines( QwtPlot::Axis axis, bool majorGridLines, bool minorGridLines ) +void RiuQwtPlotWidget::enableGridLines( RiuPlotAxis axis, bool majorGridLines, bool minorGridLines ) { - QwtPlotItemList plotItems = this->itemList( QwtPlotItem::Rtti_PlotGrid ); + QwtPlotItemList plotItems = m_plot->itemList( QwtPlotItem::Rtti_PlotGrid ); + auto qwtAxis = toQwtPlotAxis( axis ); for ( QwtPlotItem* plotItem : plotItems ) { - QwtPlotGrid* grid = static_cast( plotItem ); - if ( axis == QwtPlot::xTop || axis == QwtPlot::xBottom ) + auto* grid = static_cast( plotItem ); + if ( qwtAxis == QwtAxis::XTop || qwtAxis == QwtAxis::XBottom ) { - grid->setXAxis( axis ); + grid->setXAxis( qwtAxis ); grid->enableX( majorGridLines ); grid->enableXMin( minorGridLines ); } else { - grid->setYAxis( axis ); + grid->setYAxis( qwtAxis ); grid->enableY( majorGridLines ); grid->enableYMin( minorGridLines ); } @@ -374,34 +377,36 @@ void RiuQwtPlotWidget::enableGridLines( QwtPlot::Axis axis, bool majorGridLines, //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuQwtPlotWidget::setMajorAndMinorTickIntervals( QwtPlot::Axis axis, - double majorTickInterval, - double minorTickInterval, - double minValue, - double maxValue ) +void RiuQwtPlotWidget::setMajorAndMinorTickIntervals( RiuPlotAxis axis, + double majorTickInterval, + double minorTickInterval, + double minValue, + double maxValue ) { - RiuQwtLinearScaleEngine* scaleEngine = dynamic_cast( this->axisScaleEngine( axis ) ); + auto qwtAxis = toQwtPlotAxis( axis ); + auto* scaleEngine = dynamic_cast( m_plot->axisScaleEngine( qwtAxis ) ); if ( scaleEngine ) { QwtScaleDiv scaleDiv = scaleEngine->divideScaleWithExplicitIntervals( minValue, maxValue, majorTickInterval, minorTickInterval ); - this->setAxisScaleDiv( axis, scaleDiv ); + m_plot->setAxisScaleDiv( qwtAxis, scaleDiv ); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuQwtPlotWidget::setMajorAndMinorTickIntervalsAndRange( QwtPlot::Axis axis, - double majorTickInterval, - double minorTickInterval, - double minTickValue, - double maxTickValue, - double rangeMin, - double rangeMax ) +void RiuQwtPlotWidget::setMajorAndMinorTickIntervalsAndRange( RiuPlotAxis axis, + double majorTickInterval, + double minorTickInterval, + double minTickValue, + double maxTickValue, + double rangeMin, + double rangeMax ) { - RiuQwtLinearScaleEngine* scaleEngine = dynamic_cast( this->axisScaleEngine( axis ) ); + auto qwtAxis = toQwtPlotAxis( axis ); + auto* scaleEngine = dynamic_cast( m_plot->axisScaleEngine( qwtAxis ) ); if ( scaleEngine ) { QwtScaleDiv scaleDiv = scaleEngine->divideScaleWithExplicitIntervalsAndRange( minTickValue, @@ -411,30 +416,28 @@ void RiuQwtPlotWidget::setMajorAndMinorTickIntervalsAndRange( QwtPlot::Axis axis rangeMin, rangeMax ); - this->setAxisScaleDiv( axis, scaleDiv ); + m_plot->setAxisScaleDiv( qwtAxis, scaleDiv ); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuQwtPlotWidget::setAutoTickIntervalCounts( QwtPlot::Axis axis, - int maxMajorTickIntervalCount, - int maxMinorTickIntervalCount ) +void RiuQwtPlotWidget::setAutoTickIntervalCounts( RiuPlotAxis axis, int maxMajorTickIntervalCount, int maxMinorTickIntervalCount ) { - this->setAxisMaxMajor( axis, maxMajorTickIntervalCount ); - this->setAxisMaxMinor( axis, maxMinorTickIntervalCount ); + m_plot->setAxisMaxMajor( toQwtPlotAxis( axis ), maxMajorTickIntervalCount ); + m_plot->setAxisMaxMinor( toQwtPlotAxis( axis ), maxMinorTickIntervalCount ); // Reapply axis limits to force Qwt to use the tick settings. - QwtInterval currentRange = this->axisInterval( axis ); + QwtInterval currentRange = m_plot->axisInterval( toQwtPlotAxis( axis ) ); setAxisScale( axis, currentRange.minValue(), currentRange.maxValue() ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double RiuQwtPlotWidget::majorTickInterval( QwtPlot::Axis axis ) const +double RiuQwtPlotWidget::majorTickInterval( RiuPlotAxis axis ) const { - QwtScaleDiv scaleDiv = this->axisScaleDiv( axis ); + QwtScaleDiv scaleDiv = m_plot->axisScaleDiv( toQwtPlotAxis( axis ) ); QList majorTicks = scaleDiv.ticks( QwtScaleDiv::MajorTick ); if ( majorTicks.size() < 2 ) return 0.0; @@ -444,9 +447,9 @@ double RiuQwtPlotWidget::majorTickInterval( QwtPlot::Axis axis ) const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double RiuQwtPlotWidget::minorTickInterval( QwtPlot::Axis axis ) const +double RiuQwtPlotWidget::minorTickInterval( RiuPlotAxis axis ) const { - QwtScaleDiv scaleDiv = this->axisScaleDiv( QwtPlot::xTop ); + QwtScaleDiv scaleDiv = m_plot->axisScaleDiv( QwtAxis::XTop ); QList minorTicks = scaleDiv.ticks( QwtScaleDiv::MinorTick ); if ( minorTicks.size() < 2 ) return 0.0; @@ -456,24 +459,26 @@ double RiuQwtPlotWidget::minorTickInterval( QwtPlot::Axis axis ) const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -int RiuQwtPlotWidget::axisExtent( QwtPlot::Axis axis ) const +int RiuQwtPlotWidget::axisExtent( RiuPlotAxis axis ) const { - if ( std::abs( axisRange( axis ).maxValue() - axisRange( axis ).minValue() ) < 1.0e-14 ) return 0; + auto [rangeMin, rangeMax] = axisRange( axis ); + if ( std::abs( rangeMax - rangeMin ) < 1.0e-14 ) return 0; - int lineExtent = 0; + int lineExtent = 0; + auto qwtAxis = toQwtPlotAxis( axis ); - if ( this->axisScaleDraw( axis )->hasComponent( QwtAbstractScaleDraw::Ticks ) ) + if ( m_plot->axisScaleDraw( qwtAxis )->hasComponent( QwtAbstractScaleDraw::Ticks ) ) { - lineExtent += this->axisScaleDraw( axis )->maxTickLength(); + lineExtent += m_plot->axisScaleDraw( qwtAxis )->maxTickLength(); } - if ( this->axisScaleDraw( axis )->hasComponent( QwtAbstractScaleDraw::Labels ) ) + if ( m_plot->axisScaleDraw( qwtAxis )->hasComponent( QwtAbstractScaleDraw::Labels ) ) { - QFont tickLabelFont = axisFont( axis ); + QFont tickLabelFont = m_plot->axisFont( toQwtPlotAxis( axis ) ); // Make space for a fairly long value label QSize labelSize = QFontMetrics( tickLabelFont ).boundingRect( QString( "9.9e-9" ) ).size(); - if ( axis == QwtPlot::yLeft || axis == QwtPlot::yRight ) + if ( axis.axis() == RiaDefines::PlotAxis::PLOT_AXIS_LEFT || axis.axis() == RiaDefines::PlotAxis::PLOT_AXIS_RIGHT ) { lineExtent = labelSize.width(); } @@ -483,12 +488,12 @@ int RiuQwtPlotWidget::axisExtent( QwtPlot::Axis axis ) const } } - if ( !axisTitle( axis ).text().isEmpty() ) + if ( !m_plot->axisTitle( qwtAxis ).text().isEmpty() ) { auto it = m_axisTitlesEnabled.find( axis ); if ( it != m_axisTitlesEnabled.end() && it->second ) { - QFont titleFont = axisTitle( axis ).font(); + QFont titleFont = m_plot->axisTitle( qwtAxis ).font(); // Label is aligned vertically on vertical axes // So height is sufficient in both cases. lineExtent += QFontMetrics( titleFont ).height(); @@ -498,38 +503,6 @@ int RiuQwtPlotWidget::axisExtent( QwtPlot::Axis axis ) const return lineExtent; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RiuQwtPlotWidget::frameIsInFrontOfThis( const QRect& frameGeometry ) -{ - QRect ownGeometry = this->canvas()->geometry(); - ownGeometry.translate( this->geometry().topLeft() ); - - if ( frameGeometry.bottom() < ownGeometry.center().y() ) - { - return true; - } - else if ( frameGeometry.left() < ownGeometry.left() && frameGeometry.top() < ownGeometry.center().y() ) - { - return true; - } - else - { - QRect intersection = ownGeometry.intersected( frameGeometry ); - - double ownArea = double( ownGeometry.height() ) * double( ownGeometry.width() ); - double frameArea = double( frameGeometry.height() ) * double( frameGeometry.width() ); - double intersectionArea = double( intersection.height() ) * double( intersection.width() ); - if ( intersectionArea > 0.8 * std::min( ownArea, frameArea ) ) - { - return true; - } - } - - return false; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -547,37 +520,20 @@ void RiuQwtPlotWidget::scheduleReplot() } //-------------------------------------------------------------------------------------------------- -/// Adds an overlay frame. The overlay frame becomes the responsibility of the plot widget +/// //-------------------------------------------------------------------------------------------------- -void RiuQwtPlotWidget::addOverlayFrame( RiuDraggableOverlayFrame* overlayFrame ) +void RiuQwtPlotWidget::updateLayout() { - if ( std::find( m_overlayFrames.begin(), m_overlayFrames.end(), overlayFrame ) == m_overlayFrames.end() ) - { - overlayFrame->setParent( this->canvas() ); - m_overlayFrames.push_back( overlayFrame ); - updateLayout(); - } + m_plot->updateLayout(); + updateOverlayFrameLayout(); } -//-------------------------------------------------------------------------------------------------- -/// Remove the overlay widget. The frame becomes the responsibility of the caller -//-------------------------------------------------------------------------------------------------- -void RiuQwtPlotWidget::removeOverlayFrame( RiuDraggableOverlayFrame* overlayFrame ) -{ - CAF_ASSERT( overlayFrame ); - - overlayFrame->hide(); - overlayFrame->setParent( nullptr ); - m_overlayFrames.removeOne( overlayFrame ); -}; - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuQwtPlotWidget::updateLayout() +void RiuQwtPlotWidget::updateLegend() { - QwtPlot::updateLayout(); - updateOverlayFrameLayout(); + m_plot->updateLegend(); } //-------------------------------------------------------------------------------------------------- @@ -585,8 +541,10 @@ void RiuQwtPlotWidget::updateLayout() //-------------------------------------------------------------------------------------------------- bool RiuQwtPlotWidget::eventFilter( QObject* watched, QEvent* event ) { - QWheelEvent* wheelEvent = dynamic_cast( event ); - if ( wheelEvent && watched == canvas() ) + if ( RiuPlotWidget::handleDragDropEvent( event ) ) return true; + + auto* wheelEvent = dynamic_cast( event ); + if ( wheelEvent && watched == m_plot->canvas() ) { event->accept(); @@ -594,11 +552,17 @@ bool RiuQwtPlotWidget::eventFilter( QObject* watched, QEvent* event ) return true; } - QMouseEvent* mouseEvent = dynamic_cast( event ); + auto* mouseEvent = dynamic_cast( event ); if ( mouseEvent ) { if ( isZoomerActive() ) return false; + if ( mouseEvent->type() == QMouseEvent::MouseButtonDblClick ) + { + if ( m_plotDefinition ) m_plotDefinition->zoomAll(); + return true; + } + bool toggleItemInSelection = ( mouseEvent->modifiers() & Qt::ControlModifier ) != 0; if ( mouseEvent->type() == QMouseEvent::MouseButtonPress && mouseEvent->button() == Qt::LeftButton ) @@ -606,15 +570,15 @@ bool RiuQwtPlotWidget::eventFilter( QObject* watched, QEvent* event ) m_clickPosition = mouseEvent->pos(); } - if ( watched == this && !this->canvas()->geometry().contains( mouseEvent->pos() ) ) + if ( watched == m_plot && !m_plot->canvas()->geometry().contains( mouseEvent->pos() ) ) { - if ( mouseEvent->type() == QMouseEvent::MouseButtonRelease && ( mouseEvent->button() == Qt::LeftButton ) && + if ( mouseEvent->type() == QMouseEvent::MouseButtonPress && ( mouseEvent->button() == Qt::LeftButton ) && !m_clickPosition.isNull() ) { - QWidget* childClicked = this->childAt( m_clickPosition ); + QWidget* childClicked = m_plot->childAt( m_clickPosition ); if ( childClicked ) { - QwtScaleWidget* scaleWidget = qobject_cast( childClicked ); + auto* scaleWidget = qobject_cast( childClicked ); if ( scaleWidget ) { onAxisSelected( scaleWidget, toggleItemInSelection ); @@ -631,7 +595,7 @@ bool RiuQwtPlotWidget::eventFilter( QObject* watched, QEvent* event ) } } } - else if ( watched == canvas() ) + else if ( watched == m_plot->canvas() ) { if ( mouseEvent->type() == QMouseEvent::MouseButtonRelease && mouseEvent->button() == Qt::LeftButton && !m_clickPosition.isNull() ) @@ -652,7 +616,8 @@ bool RiuQwtPlotWidget::eventFilter( QObject* watched, QEvent* event ) void RiuQwtPlotWidget::hideEvent( QHideEvent* event ) { resetPlotItemHighlighting(); - QwtPlot::hideEvent( event ); + // TODO: remove? + // m_plot->hideEvent( event ); } //-------------------------------------------------------------------------------------------------- @@ -660,7 +625,8 @@ void RiuQwtPlotWidget::hideEvent( QHideEvent* event ) //-------------------------------------------------------------------------------------------------- void RiuQwtPlotWidget::showEvent( QShowEvent* event ) { - QwtPlot::showEvent( event ); + // TODO: remove? + // m_plot->showEvent( event ); } //-------------------------------------------------------------------------------------------------- @@ -668,7 +634,8 @@ void RiuQwtPlotWidget::showEvent( QShowEvent* event ) //-------------------------------------------------------------------------------------------------- void RiuQwtPlotWidget::resizeEvent( QResizeEvent* event ) { - QwtPlot::resizeEvent( event ); + // TODO: remove??? + // QwtPlot::resizeEvent( event ); updateOverlayFrameLayout(); event->accept(); } @@ -687,27 +654,28 @@ void RiuQwtPlotWidget::keyPressEvent( QKeyEvent* event ) void RiuQwtPlotWidget::applyPlotTitleToQwt() { QString plotTitleToApply = m_plotTitleEnabled ? m_plotTitle : QString( "" ); - QwtText plotTitle = this->title(); + QwtText plotTitle = m_plot->title(); plotTitle.setRenderFlags( Qt::AlignHCenter | Qt::TextSingleLine ); if ( plotTitleToApply != plotTitle.text() ) { plotTitle.setText( plotTitleToApply ); - setTitle( plotTitle ); + m_plot->setTitle( plotTitle ); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuQwtPlotWidget::applyAxisTitleToQwt( QwtPlot::Axis axis ) +void RiuQwtPlotWidget::applyAxisTitleToQwt( RiuPlotAxis axis ) { QString titleToApply = m_axisTitlesEnabled[axis] ? m_axisTitles[axis] : QString( "" ); - QwtText axisTitle = this->axisTitle( axis ); + auto qwtAxis = toQwtPlotAxis( axis ); + QwtText axisTitle = m_plot->axisTitle( qwtAxis ); if ( titleToApply != axisTitle.text() ) { axisTitle.setText( titleToApply ); - setAxisTitle( axis, axisTitle ); + m_plot->setAxisTitle( qwtAxis, axisTitle ); } recalculateAxisExtents( axis ); } @@ -717,7 +685,7 @@ void RiuQwtPlotWidget::applyAxisTitleToQwt( QwtPlot::Axis axis ) //-------------------------------------------------------------------------------------------------- QSize RiuQwtPlotWidget::sizeHint() const { - return QSize( 0, 0 ); + return { 0, 0 }; } //-------------------------------------------------------------------------------------------------- @@ -725,7 +693,7 @@ QSize RiuQwtPlotWidget::sizeHint() const //-------------------------------------------------------------------------------------------------- QSize RiuQwtPlotWidget::minimumSizeHint() const { - return QSize( 0, 0 ); + return { 0, 0 }; } //-------------------------------------------------------------------------------------------------- @@ -748,11 +716,11 @@ void RiuQwtPlotWidget::endZoomOperations() //-------------------------------------------------------------------------------------------------- void RiuQwtPlotWidget::renderTo( QPainter* painter, const QRect& targetRect, double scaling ) { - static_cast( this->canvas() )->setPaintAttribute( QwtPlotCanvas::BackingStore, false ); + static_cast( m_plot->canvas() )->setPaintAttribute( QwtPlotCanvas::BackingStore, false ); QPoint plotTopLeftInWindowCoords = targetRect.topLeft(); - QRectF canvasRect = this->plotLayout()->canvasRect(); + QRectF canvasRect = m_plot->plotLayout()->canvasRect(); QPoint canvasTopLeftInPlotCoords( canvasRect.topLeft().x() * scaling, canvasRect.topLeft().y() * scaling ); QPoint canvasBottomRightInPlotCoords( canvasRect.bottomRight().x(), canvasRect.bottomRight().y() ); @@ -760,8 +728,8 @@ void RiuQwtPlotWidget::renderTo( QPainter* painter, const QRect& targetRect, dou QPoint canvasBottomRightInWindowCoords = canvasBottomRightInPlotCoords + plotTopLeftInWindowCoords; QwtPlotRenderer renderer( this ); - renderer.render( this, painter, targetRect ); - static_cast( this->canvas() )->setPaintAttribute( QwtPlotCanvas::BackingStore, true ); + renderer.render( m_plot, painter, targetRect ); + static_cast( m_plot->canvas() )->setPaintAttribute( QwtPlotCanvas::BackingStore, true ); for ( RiuDraggableOverlayFrame* overlayFrame : m_overlayFrames ) { @@ -797,8 +765,8 @@ void RiuQwtPlotWidget::renderTo( QPainter* painter, const QRect& targetRect, dou //-------------------------------------------------------------------------------------------------- void RiuQwtPlotWidget::renderTo( QPaintDevice* paintDevice, const QRect& targetRect ) { - int resolution = paintDevice->logicalDpiX(); - double scaling = resolution / static_cast( RiaGuiApplication::applicationResolution() ); + auto scaling = RiaDefines::scalingFactor( paintDevice ); + QPainter painter( paintDevice ); renderTo( &painter, targetRect, scaling ); } @@ -824,26 +792,37 @@ RimViewWindow* RiuQwtPlotWidget::ownerViewWindow() const //-------------------------------------------------------------------------------------------------- void RiuQwtPlotWidget::onAxisSelected( QwtScaleWidget* scale, bool toggleItemInSelection ) { - int axisId = -1; - for ( int i = 0; i < QwtPlot::axisCnt; ++i ) + for ( int i = 0; i < QwtAxis::AxisPositions; ++i ) { - if ( scale == this->axisWidget( i ) ) + auto pos = static_cast( i ); + int count = m_plot->axesCount( pos ); + for ( int id = 0; id < count; id++ ) { - axisId = i; + QwtAxisId axisId( pos, id ); + if ( scale == m_plot->axisWidget( axisId ) ) + { + resetPlotItemHighlighting(); + highlightPlotItemsForQwtAxis( axisId ); + scheduleReplot(); + + RiuPlotAxis plotAxis = findPlotAxisForQwtAxis( axisId ); + emit axisSelected( plotAxis, toggleItemInSelection ); + return; + } } } - emit axisSelected( axisId, toggleItemInSelection ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuQwtPlotWidget::recalculateAxisExtents( QwtPlot::Axis axis ) +void RiuQwtPlotWidget::recalculateAxisExtents( RiuPlotAxis axis ) { - if ( axis == QwtPlot::yLeft || axis == QwtPlot::yRight ) + auto qwtAxis = toQwtPlotAxis( axis ); + if ( qwtAxis.pos == QwtAxis::YLeft || qwtAxis.pos == QwtAxis::YRight ) { int extent = axisExtent( axis ); - axisScaleDraw( axis )->setMinimumExtent( extent ); + m_plot->axisScaleDraw( qwtAxis )->setMinimumExtent( extent ); setMinimumWidth( defaultMinimumWidth() + extent ); } } @@ -851,52 +830,17 @@ void RiuQwtPlotWidget::recalculateAxisExtents( QwtPlot::Axis axis ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuQwtPlotWidget::updateOverlayFrameLayout() +int RiuQwtPlotWidget::highlightItemWidthAdjustment() { - const int spacing = 5; - - int xpos = spacing; - int ypos = spacing; - int widthOfCurrentColumn = 0; - - QSize canvasSize = this->canvas()->size(); - QSize maxFrameSize( canvasSize.width() - 2 * m_overlayMargins, canvasSize.height() - 2 * m_overlayMargins ); - - for ( RiuDraggableOverlayFrame* frame : m_overlayFrames ) - { - if ( frame ) - { - QSize minFrameSize = frame->minimumSizeHint(); - QSize desiredFrameSize = frame->sizeHint(); - - int width = std::min( std::max( minFrameSize.width(), desiredFrameSize.width() ), maxFrameSize.width() ); - int height = std::min( std::max( minFrameSize.height(), desiredFrameSize.height() ), maxFrameSize.height() ); - - frame->resize( width, height ); + return 2; +} - if ( frame->anchorCorner() == RiuDraggableOverlayFrame::AnchorCorner::TopLeft ) - { - if ( ypos + frame->height() + spacing > this->canvas()->height() && widthOfCurrentColumn > 0 ) - { - xpos += spacing + widthOfCurrentColumn; - ypos = spacing; - widthOfCurrentColumn = 0; - } - frame->move( xpos, ypos ); - ypos += frame->height() + spacing; - widthOfCurrentColumn = std::max( widthOfCurrentColumn, frame->width() ); - } - else if ( frame->anchorCorner() == RiuDraggableOverlayFrame::AnchorCorner::TopRight ) - { - QRect frameRect = frame->frameGeometry(); - QRect canvasRect = canvas()->rect(); - QPoint canvasTopRight = canvasRect.topRight(); - frameRect.moveTopRight( QPoint( canvasTopRight.x() - spacing, canvasTopRight.y() + spacing ) ); - frame->move( frameRect.topLeft() ); - } - frame->show(); - } - } +//-------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QWidget* RiuQwtPlotWidget::getParentForOverlay() const +{ + return m_plot->canvas(); } //-------------------------------------------------------------------------------------------- @@ -914,14 +858,14 @@ void RiuQwtPlotWidget::findClosestPlotItem( const QPoint& pos, *closestCurvePoint = -1; *distanceFromClick = std::numeric_limits::infinity(); - const QwtPlotItemList& itmList = itemList(); - for ( QwtPlotItemIterator it = itmList.begin(); it != itmList.end(); it++ ) + const QwtPlotItemList& itmList = m_plot->itemList(); + for ( auto it : itmList ) { - if ( ( *it )->rtti() == QwtPlotItem::Rtti_PlotCurve ) + if ( it->rtti() == QwtPlotItem::Rtti_PlotCurve ) { - QwtPlotCurve* candidateCurve = static_cast( *it ); - double dist = std::numeric_limits::infinity(); - int curvePoint = candidateCurve->closestPoint( pos, &dist ); + auto* candidateCurve = static_cast( it ); + double dist = std::numeric_limits::infinity(); + int curvePoint = candidateCurve->closestPoint( pos, &dist ); if ( dist < *distanceFromClick ) { *closestItem = candidateCurve; @@ -929,20 +873,22 @@ void RiuQwtPlotWidget::findClosestPlotItem( const QPoint& pos, *closestCurvePoint = curvePoint; } } - else if ( ( *it )->rtti() == QwtPlotItem::Rtti_PlotShape ) + else if ( it->rtti() == QwtPlotItem::Rtti_PlotShape ) { - QwtPlotShapeItem* shapeItem = static_cast( *it ); - QPointF scalePos( invTransform( xBottom, pos.x() ), invTransform( yLeft, pos.y() ) ); + auto* shapeItem = static_cast( it ); + QPointF scalePos( m_plot->invTransform( QwtAxis::XBottom, pos.x() ), + m_plot->invTransform( QwtAxis::YLeft, pos.y() ) ); if ( shapeItem->shape().boundingRect().contains( scalePos ) ) { - *closestItem = *it; + *closestItem = it; *distanceFromClick = 0.0; } } - else if ( ( *it )->rtti() == QwtPlotItem::Rtti_PlotBarChart ) + else if ( it->rtti() == QwtPlotItem::Rtti_PlotBarChart ) { - QwtPlotBarChart* barChart = static_cast( *it ); - QPointF scalePos( invTransform( xBottom, pos.x() ), invTransform( yLeft, pos.y() ) ); + auto* barChart = static_cast( it ); + QPointF scalePos( m_plot->invTransform( QwtAxis::XBottom, pos.x() ), + m_plot->invTransform( QwtAxis::YLeft, pos.y() ) ); bool horizontal = barChart->orientation() == Qt::Horizontal; for ( size_t i = 0; i < barChart->dataSize(); ++i ) @@ -952,7 +898,7 @@ void RiuQwtPlotWidget::findClosestPlotItem( const QPoint& pos, : std::abs( samplePoint.x() - scalePos.x() ); if ( dist < *distanceFromClick ) { - *closestItem = *it; + *closestItem = it; *closestCurvePoint = (int)i; *distanceFromClick = dist; } @@ -961,6 +907,23 @@ void RiuQwtPlotWidget::findClosestPlotItem( const QPoint& pos, } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- + +std::pair RiuQwtPlotWidget::findClosestCurve( const QPoint& pos, double& distanceFromClick ) const +{ + QwtPlotItem* closestItem = nullptr; + + int closestCurvePoint = -1; + QPoint globalPos = mapToGlobal( pos ); + QPoint localPos = qwtPlot()->canvas()->mapFromGlobal( globalPos ); + + findClosestPlotItem( localPos, &closestItem, &closestCurvePoint, &distanceFromClick ); + auto plotCurve = dynamic_cast( closestItem ); + return std::make_pair( plotCurve, closestCurvePoint ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -977,15 +940,18 @@ void RiuQwtPlotWidget::selectClosestPlotItem( const QPoint& pos, bool toggleItem if ( closestItem && distanceFromClick < 20 ) { // TODO: highlight all selected curves - highlightPlotItem( closestItem ); - emit plotItemSelected( closestItem, toggleItemInSelection, distanceFromClick < 10 ? closestCurvePoint : -1 ); - - scheduleReplot(); + std::set plotItems = { closestItem }; + highlightPlotItems( plotItems ); + auto plotItem = std::make_shared( closestItem ); + emit plotItemSelected( plotItem, toggleItemInSelection, distanceFromClick < 10 ? closestCurvePoint : -1 ); } else { emit plotSelected( toggleItemInSelection ); } + + // Always do a replot, as the reset operation also requires replot + replot(); } //-------------------------------------------------------------------------------------------------- @@ -1001,31 +967,76 @@ int RiuQwtPlotWidget::defaultMinimumWidth() //-------------------------------------------------------------------------------------------------- void RiuQwtPlotWidget::replot() { - QwtPlot::replot(); + m_plot->replot(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuQwtPlotWidget::highlightPlotItem( const QwtPlotItem* closestItem ) +void RiuQwtPlotWidget::highlightPlotItems( const std::set& closestItems ) { + if ( closestItems.size() == 1 ) + { + auto* constPlotCurve = dynamic_cast( *closestItems.begin() ); + auto* plotCurve = const_cast( constPlotCurve ); + + if ( plotCurve ) + { + auto curveColor = plotCurve->pen().color(); + if ( RiaColorTools::isBrightnessAboveThreshold( RiaColorTools::fromQColorTo3f( curveColor ) ) ) + { + // The brightness of selected curve is above threshold. Modify the saturation, and leave the other + // curves unchanged + + QColor symbolColor; + QColor symbolLineColor; + auto* symbol = const_cast( plotCurve->symbol() ); + if ( symbol ) + { + symbolColor = symbol->brush().color(); + symbolLineColor = symbol->pen().color(); + } + + double zValue = plotCurve->z(); + plotCurve->setZ( zValue + 100.0 ); + highlightPlotAxes( plotCurve->xAxis(), plotCurve->yAxis() ); + + auto hightlightColor = curveColor; + qreal h, s, v; + hightlightColor.getHsvF( &h, &s, &v ); + hightlightColor.setHsvF( h, 0.95, v ); + + auto curveWidth = plotCurve->pen().width(); + plotCurve->setPen( hightlightColor, + plotCurve->pen().width() + highlightItemWidthAdjustment(), + plotCurve->pen().style() ); + + CurveProperties properties = { curveColor, symbolColor, symbolLineColor, curveWidth }; + m_originalCurveProperties.insert( std::make_pair( plotCurve, properties ) ); + m_originalZValues.insert( std::make_pair( plotCurve, zValue ) ); + + return; + } + } + } + // NB! Create a copy of the item list before the loop to avoid invalidated iterators when iterating the list // plotCurve->setZ() causes the ordering of items in the list to change - auto plotItemList = this->itemList(); + auto plotItemList = m_plot->itemList(); for ( QwtPlotItem* plotItem : plotItemList ) { - QwtPlotCurve* plotCurve = dynamic_cast( plotItem ); - QwtPlotShapeItem* plotShapeItem = dynamic_cast( plotItem ); + auto* plotCurve = dynamic_cast( plotItem ); if ( plotCurve ) { QPen existingPen = plotCurve->pen(); - QColor bgColor = this->canvasBackground().color(); + QColor bgColor = m_plot->canvasBackground().color(); QColor curveColor = existingPen.color(); QColor symbolColor; QColor symbolLineColor; + auto penWidth = existingPen.width(); - QwtSymbol* symbol = const_cast( plotCurve->symbol() ); + auto* symbol = const_cast( plotCurve->symbol() ); if ( symbol ) { symbolColor = symbol->brush().color(); @@ -1033,9 +1044,12 @@ void RiuQwtPlotWidget::highlightPlotItem( const QwtPlotItem* closestItem ) } double zValue = plotCurve->z(); - if ( plotCurve == closestItem ) + if ( closestItems.count( plotCurve ) > 0 ) { + existingPen.setWidth( penWidth + highlightItemWidthAdjustment() ); + plotCurve->setPen( existingPen ); plotCurve->setZ( zValue + 100.0 ); + highlightPlotAxes( plotCurve->xAxis(), plotCurve->yAxis() ); } else { @@ -1050,12 +1064,15 @@ void RiuQwtPlotWidget::highlightPlotItem( const QwtPlotItem* closestItem ) symbol->setPen( blendedSymbolLineColor, symbol->pen().width(), symbol->pen().style() ); } } - CurveColors curveColors = { curveColor, symbolColor, symbolLineColor }; - m_originalCurveColors.insert( std::make_pair( plotCurve, curveColors ) ); - m_originalCurveColors.insert( std::make_pair( plotCurve, curveColors ) ); + CurveProperties properties = { curveColor, symbolColor, symbolLineColor, penWidth }; + m_originalCurveProperties.insert( std::make_pair( plotCurve, properties ) ); m_originalZValues.insert( std::make_pair( plotCurve, zValue ) ); + + continue; } - else if ( plotShapeItem && plotItem == closestItem ) + + auto* plotShapeItem = dynamic_cast( plotItem ); + if ( plotShapeItem && closestItems.count( plotItem ) > 0 ) { QPen pen = plotShapeItem->pen(); pen.setColor( QColor( Qt::green ) ); @@ -1073,27 +1090,30 @@ void RiuQwtPlotWidget::resetPlotItemHighlighting() { // NB! Create a copy of the item list before the loop to avoid invalidated iterators when iterating the list // plotCurve->setZ() causes the ordering of items in the list to change - auto plotItemList = this->itemList(); + auto plotItemList = m_plot->itemList(); for ( QwtPlotItem* plotItem : plotItemList ) { - QwtPlotCurve* plotCurve = dynamic_cast( plotItem ); - QwtPlotShapeItem* plotShapeItem = dynamic_cast( plotItem ); - if ( plotCurve && m_originalCurveColors.count( plotCurve ) ) + auto* plotCurve = dynamic_cast( plotItem ); + if ( plotCurve && m_originalCurveProperties.count( plotCurve ) ) { const QPen& existingPen = plotCurve->pen(); - auto colors = m_originalCurveColors[plotCurve]; + auto properties = m_originalCurveProperties[plotCurve]; double zValue = m_originalZValues[plotCurve]; - plotCurve->setPen( colors.lineColor, existingPen.width(), existingPen.style() ); + plotCurve->setPen( properties.lineColor, properties.lineWidth, existingPen.style() ); plotCurve->setZ( zValue ); - QwtSymbol* symbol = const_cast( plotCurve->symbol() ); + auto* symbol = const_cast( plotCurve->symbol() ); if ( symbol ) { - symbol->setColor( colors.symbolColor ); - symbol->setPen( colors.symbolLineColor, symbol->pen().width(), symbol->pen().style() ); + symbol->setColor( properties.symbolColor ); + symbol->setPen( properties.symbolLineColor, symbol->pen().width(), symbol->pen().style() ); } + + continue; } - else if ( plotShapeItem ) + + auto* plotShapeItem = dynamic_cast( plotItem ); + if ( plotShapeItem ) { QPen pen = plotShapeItem->pen(); @@ -1105,6 +1125,397 @@ void RiuQwtPlotWidget::resetPlotItemHighlighting() plotShapeItem->setZ( plotShapeItem->z() - 100.0 ); } } - m_originalCurveColors.clear(); + m_originalCurveProperties.clear(); m_originalZValues.clear(); + + resetPlotAxisHighlighting(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQwtPlotWidget::resetPlotAxisHighlighting() +{ + // Reset axis widgets highlighting + std::vector axisPositions = { QwtAxis::Position::YLeft, + QwtAxis::Position::YRight, + QwtAxis::Position::XTop, + QwtAxis::Position::XBottom }; + + // Use text color from theme + QColor textColor = RiuGuiTheme::getColorByVariableName( "text-color" ); + QString style = + QString( "color: rgb(%1, %2, %3);" ).arg( textColor.red() ).arg( textColor.green() ).arg( textColor.blue() ); + + for ( auto pos : axisPositions ) + { + int count = m_plot->axesCount( pos ); + for ( int i = 0; i < count; i++ ) + { + QwtAxisId axisId( pos, i ); + auto axisWidget = m_plot->axisWidget( axisId ); + axisWidget->setStyleSheet( style ); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQwtPlotWidget::highlightPlotItemsForQwtAxis( QwtAxisId axisId ) +{ + std::set plotItems; + auto plotItemList = m_plot->itemList(); + for ( QwtPlotItem* plotItem : plotItemList ) + { + auto* plotCurve = dynamic_cast( plotItem ); + if ( plotCurve ) + { + QwtAxisId xAxis = plotCurve->xAxis(); + QwtAxisId yAxis = plotCurve->yAxis(); + if ( xAxis == axisId || yAxis == axisId ) + { + plotItems.insert( plotItem ); + } + } + } + + highlightPlotItems( plotItems ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQwtPlotWidget::highlightPlotAxes( QwtAxisId axisIdX, QwtAxisId axisIdY ) +{ + std::vector axisPositions = { QwtAxis::Position::YLeft, + QwtAxis::Position::YRight, + QwtAxis::Position::XTop, + QwtAxis::Position::XBottom }; + + // Highlight selected axis by toning down the others in same dimension + for ( auto pos : axisPositions ) + { + int count = m_plot->axesCount( pos ); + for ( int i = 0; i < count; i++ ) + { + QwtAxisId axisId( pos, i ); + + if ( axisId != axisIdX && axisId != axisIdY ) + { + auto axisWidget = m_plot->axisWidget( axisId ); + axisWidget->setStyleSheet( "color: #D9D9D9" ); + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QwtPlot* RiuQwtPlotWidget::qwtPlot() const +{ + return m_plot; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQwtPlotWidget::ensureAxisIsCreated( RiuPlotAxis axis ) +{ + // Check if the axis already exists + auto it = m_axisMapping.find( axis ); + if ( it != m_axisMapping.end() ) return; + + // Special handling for default axis (index == 0): + // These are already created by qwt. + if ( axis.index() == 0 ) + { + QwtAxisId newQwtAxis( RiuQwtPlotTools::toQwtPlotAxisEnum( axis.axis() ), 0 ); + m_axisMapping.insert( std::make_pair( axis, newQwtAxis ) ); + } + else + { + auto qwtAxisId = RiuQwtPlotTools::toQwtPlotAxisEnum( axis.axis() ); + + int count = m_plot->axesCount( qwtAxisId ); + int requiredCount = count + 1; + + m_plot->setAxesCount( qwtAxisId, requiredCount ); + QwtAxisId newQwtAxis( qwtAxisId, count ); + m_axisMapping.insert( std::make_pair( axis, newQwtAxis ) ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQwtPlotWidget::enableAxis( RiuPlotAxis axis, bool isEnabled ) +{ + ensureAxisIsCreated( axis ); + + m_plot->setAxisVisible( toQwtPlotAxis( axis ), isEnabled ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQwtPlotWidget::enableAxisNumberLabels( RiuPlotAxis axis, bool isEnabled ) +{ + m_plot->axisScaleDraw( toQwtPlotAxis( axis ) )->enableComponent( QwtAbstractScaleDraw::Labels, isEnabled ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiuQwtPlotWidget::axisEnabled( RiuPlotAxis axis ) const +{ + auto qwtPlotAxis = toQwtPlotAxis( axis ); + if ( qwtPlotAxis.pos < 0 ) return false; + + return m_plot->isAxisVisible( qwtPlotAxis ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQwtPlotWidget::setAxisMaxMinor( RiuPlotAxis axis, int maxMinor ) +{ + m_plot->setAxisMaxMinor( toQwtPlotAxis( axis ), maxMinor ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQwtPlotWidget::setAxisMaxMajor( RiuPlotAxis axis, int maxMajor ) +{ + m_plot->setAxisMaxMajor( toQwtPlotAxis( axis ), maxMajor ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQwtPlotWidget::removeEventFilter() +{ + m_plot->removeEventFilter( m_plot ); + m_plot->canvas()->removeEventFilter( m_plot ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQwtPlotWidget::setAxisAutoScale( RiuPlotAxis axis, bool autoScale ) +{ + m_plot->setAxisAutoScale( toQwtPlotAxis( axis ), autoScale ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQwtPlotWidget::setAxisScale( RiuPlotAxis axis, double min, double max ) +{ + setAxisScale( toQwtPlotAxis( axis ), min, max ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQwtPlotWidget::setAxisScale( QwtAxisId axis, double min, double max ) +{ + m_plot->setAxisScale( axis, min, max ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuQwtPlotWidget::AxisScaleType RiuQwtPlotWidget::axisScaleType( RiuPlotAxis axis ) const +{ + auto qwtAxis = toQwtPlotAxis( axis ); + + auto* logScaleEngine = dynamic_cast( m_plot->axisScaleEngine( qwtAxis ) ); + auto* dateScaleEngine = dynamic_cast( m_plot->axisScaleEngine( qwtAxis ) ); + if ( logScaleEngine != nullptr ) return AxisScaleType::LOGARITHMIC; + if ( dateScaleEngine != nullptr ) return AxisScaleType::DATE; + + return AxisScaleType::LINEAR; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQwtPlotWidget::setAxisScaleType( RiuPlotAxis axis, RiuQwtPlotWidget::AxisScaleType axisScaleType ) +{ + auto qwtAxis = toQwtPlotAxis( axis ); + setAxisScaleType( qwtAxis, axisScaleType ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQwtPlotWidget::setAxisScaleType( QwtAxisId axis, RiuQwtPlotWidget::AxisScaleType axisScaleType ) +{ + if ( axisScaleType == AxisScaleType::LOGARITHMIC ) m_plot->setAxisScaleEngine( axis, new QwtLogScaleEngine ); + if ( axisScaleType == AxisScaleType::LINEAR ) m_plot->setAxisScaleEngine( axis, new QwtLinearScaleEngine ); + if ( axisScaleType == AxisScaleType::DATE ) m_plot->setAxisScaleEngine( axis, new QwtDateScaleEngine ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQwtPlotWidget::updateAxes() +{ + m_plot->updateAxes(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuPlotAxis RiuQwtPlotWidget::createNextPlotAxis( RiaDefines::PlotAxis axis ) +{ + auto qwtAxis = RiuQwtPlotTools::toQwtPlotAxisEnum( axis ); + + auto count = m_plot->axesCount( qwtAxis ); + + return RiuPlotAxis( axis, count ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuPlotCurve* RiuQwtPlotWidget::createPlotCurve( RimPlotCurve* ownerRimCurve, const QString& title, const QColor& color ) +{ + return new RiuQwtPlotCurve( ownerRimCurve, title ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQwtPlotWidget::detachItems( RiuPlotWidget::PlotItemType plotItemType ) +{ + CAF_ASSERT( plotItemType == RiuPlotWidget::PlotItemType::CURVE ); + if ( plotItemType == RiuPlotWidget::PlotItemType::CURVE ) qwtPlot()->detachItems( QwtPlotItem::Rtti_PlotCurve ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const QColor& RiuQwtPlotWidget::backgroundColor() const +{ + return m_plot->canvasBackground().color(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiuQwtPlotWidget::isMultiAxisSupported() const +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQwtPlotWidget::pruneAxes( const std::set& usedAxes ) +{ + // Make a list of axes to remove since moving the axis invalidates the m_axisMapping iterator + std::vector axesToRemove; + for ( auto [plotAxis, qwtMapping] : m_axisMapping ) + { + if ( usedAxes.count( plotAxis ) == 0 ) + { + axesToRemove.push_back( plotAxis ); + } + } + + for ( const auto& plotAxis : axesToRemove ) + moveAxis( plotAxis, RiuPlotAxis::defaultLeft() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuPlotAxis RiuQwtPlotWidget::findPlotAxisForQwtAxis( const QwtAxisId& qwtAxisId ) const +{ + for ( auto [plotAxis, qwtMapping] : m_axisMapping ) + if ( qwtMapping == qwtAxisId ) return plotAxis; + + CAF_ASSERT( false ); + return RiuPlotAxis::defaultLeft(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQwtPlotWidget::moveAxis( RiuPlotAxis oldAxis, RiuPlotAxis newAxis ) +{ + auto countAxis = [this]( RiaDefines::PlotAxis axis ) { + int count = 0; + for ( auto [plotAxis, qwtMapping] : m_axisMapping ) + { + if ( plotAxis.axis() == axis ) count++; + } + return count; + }; + + auto isLastItem = [this]( RiuPlotAxis plotAxis, int count ) { + auto qwtAxis = toQwtPlotAxis( plotAxis ); + return qwtAxis.id == ( count - 1 ); + }; + + auto removeAxis = [this, countAxis, isLastItem]( RiuPlotAxis plotAxis ) { + auto qwtAxisPos = RiuQwtPlotTools::toQwtPlotAxisEnum( plotAxis.axis() ); + + int count = countAxis( plotAxis.axis() ); + + bool isLast = isLastItem( plotAxis, count ); + if ( isLast ) + { + // If axis to remove is the last axis item on the given side it + // is safe to let qwt delete it in setAxesCount. + m_axisMapping.erase( plotAxis ); + m_plot->setAxesCount( qwtAxisPos, count - 1 ); + } + else + { + // When the axis to delete is not the last axis item on the given side + // we have to move the last axis into the position of the axis to remove. + + // Move the last item into the spot which has been freed up + auto targetQwtAxis = m_axisMapping.find( plotAxis )->second; + + // Last item on the same side as we are deleting from + auto sourceQwtAxis = QwtAxisId( qwtAxisPos, count - 1 ); + auto sourcePlotAxis = findPlotAxisForQwtAxis( sourceQwtAxis ); + + // Copy properties of the last axis item + setAxisScaleType( targetQwtAxis, axisScaleType( sourcePlotAxis ) ); + auto range = axisRange( sourcePlotAxis ); + setAxisScale( targetQwtAxis, range.first, range.second ); + + bool autoScale = m_plot->axisAutoScale( sourceQwtAxis ); + m_plot->setAxisAutoScale( targetQwtAxis, autoScale ); + + // Finally remove the last item (which has been overwritten the item to remove). + m_axisMapping.erase( plotAxis ); + m_axisMapping.erase( sourcePlotAxis ); + m_axisMapping.insert( std::make_pair( sourcePlotAxis, targetQwtAxis ) ); + m_plot->setAxesCount( qwtAxisPos, count - 1 ); + } + }; + + removeAxis( oldAxis ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QwtAxisId RiuQwtPlotWidget::toQwtPlotAxis( RiuPlotAxis plotAxis ) const +{ + auto it = m_axisMapping.find( plotAxis ); + if ( it != m_axisMapping.end() ) + { + return it->second; + } + + return { -1, -1 }; } diff --git a/ApplicationLibCode/UserInterface/RiuQwtPlotWidget.h b/ApplicationLibCode/UserInterface/RiuQwtPlotWidget.h index 0a07ac795c..75f85ddbdf 100644 --- a/ApplicationLibCode/UserInterface/RiuQwtPlotWidget.h +++ b/ApplicationLibCode/UserInterface/RiuQwtPlotWidget.h @@ -19,27 +19,33 @@ #pragma once -#include "RiuInterfaceToViewWindow.h" +#include "RiaDefines.h" +#include "RiaPlotDefines.h" + +#include "RiuPlotWidget.h" #include "cafPdmObject.h" #include "cafPdmPointer.h" -#include "qwt_plot.h" +#include "qwt_axis_id.h" #include -#include - class RiaPlotWindowRedrawScheduler; class RimPlot; -class RiuDraggableOverlayFrame; +class RimPlotCurve; + +class RiuPlotCurve; +class RiuPlotItem; +class QwtPlot; class QwtLegend; class QwtPicker; class QwtPlotCurve; class QwtPlotGrid; class QwtPlotItem; class QwtPlotMarker; +class QwtScaleWidget; class QEvent; class QLabel; @@ -52,7 +58,7 @@ class QWheelEvent; // // //================================================================================================== -class RiuQwtPlotWidget : public QwtPlot, public RiuInterfaceToViewWindow +class RiuQwtPlotWidget : public RiuPlotWidget { Q_OBJECT @@ -60,82 +66,118 @@ class RiuQwtPlotWidget : public QwtPlot, public RiuInterfaceToViewWindow RiuQwtPlotWidget( RimPlot* plotDefinition, QWidget* parent = nullptr ); ~RiuQwtPlotWidget() override; - RimPlot* plotDefinition(); - - bool isChecked() const; - - int colSpan() const; - int rowSpan() const; - - int axisTitleFontSize( QwtPlot::Axis axis ) const; - int axisValueFontSize( QwtPlot::Axis axis ) const; - void setAxisFontsAndAlignment( QwtPlot::Axis, + int axisTitleFontSize( RiuPlotAxis axis ) const override; + int axisValueFontSize( RiuPlotAxis axis ) const override; + void setAxisFontsAndAlignment( RiuPlotAxis, int titleFontSize, int valueFontSize, bool titleBold = false, - int alignment = (int)Qt::AlignCenter ); + int alignment = (int)Qt::AlignCenter ) override; void setAxesFontsAndAlignment( int titleFontSize, int valueFontSize, bool titleBold = false, - int alignment = (int)Qt::AlignCenter ); + int alignment = (int)Qt::AlignCenter ) override; + + void enableAxis( RiuPlotAxis axis, bool isEnabled ) override; + void enableAxisNumberLabels( RiuPlotAxis axis, bool isEnabled ) override; + bool axisEnabled( RiuPlotAxis axis ) const override; + + void setAxisScale( RiuPlotAxis axis, double min, double max ) override; + void setAxisAutoScale( RiuPlotAxis axis, bool enable ) override; + + void setAxisMaxMinor( RiuPlotAxis axis, int maxMinor ) override; + void setAxisMaxMajor( RiuPlotAxis axis, int maxMajor ) override; + + RiuPlotWidget::AxisScaleType axisScaleType( RiuPlotAxis axis ) const override; + void setAxisScaleType( RiuPlotAxis axis, RiuPlotWidget::AxisScaleType axisScaleType ) override; - void setAxisTitleText( QwtPlot::Axis axis, const QString& title ); - void setAxisTitleEnabled( QwtPlot::Axis axis, bool enable ); + void setAxisTitleText( RiuPlotAxis axis, const QString& title ) override; + void setAxisTitleEnabled( RiuPlotAxis axis, bool enable ) override; - void setPlotTitle( const QString& plotTitle ); + void moveAxis( RiuPlotAxis oldAxis, RiuPlotAxis newAxis ) override; + void pruneAxes( const std::set& usedAxes ) override; + RiuPlotAxis createNextPlotAxis( RiaDefines::PlotAxis axis ) override; + bool isMultiAxisSupported() const override; + + void setPlotTitle( const QString& plotTitle ) override; const QString& plotTitle() const; void setPlotTitleEnabled( bool enabled ); bool plotTitleEnabled() const; - void setPlotTitleFontSize( int titleFontSize ); - - void setLegendFontSize( int fontSize ); - void setInternalLegendVisible( bool visible ); - - QwtInterval axisRange( QwtPlot::Axis axis ) const; - void setAxisRange( QwtPlot::Axis axis, double min, double max ); - - void setAxisInverted( QwtPlot::Axis axis ); - void setAxisLabelsAndTicksEnabled( QwtPlot::Axis axis, bool enableLabels, bool enableTicks ); - - void enableGridLines( QwtPlot::Axis axis, bool majorGridLines, bool minorGridLines ); - - void setMajorAndMinorTickIntervals( QwtPlot::Axis axis, - double majorTickInterval, - double minorTickInterval, - double minValue, - double maxValue ); - void setMajorAndMinorTickIntervalsAndRange( QwtPlot::Axis axis, - double majorTickInterval, - double minorTickInterval, - double minTickValue, - double maxTickValue, - double rangeMin, - double rangeMax ); - void setAutoTickIntervalCounts( QwtPlot::Axis axis, int maxMajorTickIntervalCount, int maxMinorTickIntervalCount ); - double majorTickInterval( QwtPlot::Axis axis ) const; - double minorTickInterval( QwtPlot::Axis axis ) const; - - int axisExtent( QwtPlot::Axis axis ) const; - - bool frameIsInFrontOfThis( const QRect& frameGeometry ); + void setPlotTitleFontSize( int titleFontSize ) override; + + void setLegendFontSize( int fontSize ) override; + void setInternalLegendVisible( bool visible ) override; + void insertLegend( RiuPlotWidget::Legend ) override; + void clearLegend() override; + + std::pair axisRange( RiuPlotAxis axis ) const override; + void setAxisRange( RiuPlotAxis axis, double min, double max ) override; + + void setAxisInverted( RiuPlotAxis axis, bool isInverted ) override; + void setAxisLabelsAndTicksEnabled( RiuPlotAxis axis, bool enableLabels, bool enableTicks ) override; + + void enableGridLines( RiuPlotAxis axis, bool majorGridLines, bool minorGridLines ) override; + + void setMajorAndMinorTickIntervals( RiuPlotAxis axis, + double majorTickInterval, + double minorTickInterval, + double minValue, + double maxValue ) override; + void setMajorAndMinorTickIntervalsAndRange( RiuPlotAxis axis, + double majorTickInterval, + double minorTickInterval, + double minTickValue, + double maxTickValue, + double rangeMin, + double rangeMax ) override; + void setAutoTickIntervalCounts( RiuPlotAxis axis, int maxMajorTickIntervalCount, int maxMinorTickIntervalCount ) override; + double majorTickInterval( RiuPlotAxis axis ) const override; + double minorTickInterval( RiuPlotAxis axis ) const override; + + int axisExtent( RiuPlotAxis axis ) const override; + + void ensureAxisIsCreated( RiuPlotAxis axis ) override; + QPoint dragStartPosition() const; void scheduleReplot(); - void addOverlayFrame( RiuDraggableOverlayFrame* overlayWidget ); - void removeOverlayFrame( RiuDraggableOverlayFrame* overlayWidget ); void updateLayout() override; - void renderTo( QPainter* painter, const QRect& targetRect, double scaling ); - void renderTo( QPaintDevice* painter, const QRect& targetRect ); + void renderTo( QPainter* painter, const QRect& targetRect, double scaling ) override; + void renderTo( QPaintDevice* painter, const QRect& targetRect ) override; int overlayMargins() const; RimViewWindow* ownerViewWindow() const override; + QwtPlot* qwtPlot() const; + + void removeEventFilter() override; + + void updateLegend() override; + void updateAxes() override; + + RiuPlotCurve* createPlotCurve( RimPlotCurve* ownerRimCurve, const QString& title, const QColor& color ) override; + + void detachItems( RiuPlotWidget::PlotItemType plotItemType ) override; + + void findClosestPlotItem( const QPoint& pos, + QwtPlotItem** closestItem, + int* closestCurvePoint, + double* distanceFromClick ) const; + + const QColor& backgroundColor() const override; + + QWidget* getParentForOverlay() const override; + + std::pair findClosestCurve( const QPoint& pos, double& distanceToClick ) const override; + + QwtAxisId toQwtPlotAxis( RiuPlotAxis axis ) const; + signals: void plotSelected( bool toggleSelection ); - void axisSelected( int axisId, bool toggleSelection ); - void plotItemSelected( QwtPlotItem* plotItem, bool toggleSelection, int sampleIndex ); + void axisSelected( RiuPlotAxis axisId, bool toggleSelection ); + void plotItemSelected( std::shared_ptr plotItem, bool toggleSelection, int sampleIndex ); void onKeyPressEvent( QKeyEvent* event ); void onWheelEvent( QWheelEvent* event ); void plotZoomed(); @@ -148,7 +190,7 @@ class RiuQwtPlotWidget : public QwtPlot, public RiuInterfaceToViewWindow void keyPressEvent( QKeyEvent* event ) override; void applyPlotTitleToQwt(); - void applyAxisTitleToQwt( QwtPlot::Axis axis ); + void applyAxisTitleToQwt( RiuPlotAxis axis ); QSize sizeHint() const override; QSize minimumSizeHint() const override; @@ -156,43 +198,38 @@ class RiuQwtPlotWidget : public QwtPlot, public RiuInterfaceToViewWindow virtual bool isZoomerActive() const; virtual void endZoomOperations(); - void findClosestPlotItem( const QPoint& pos, - QwtPlotItem** closestItem, - int* closestCurvePoint, - double* distanceFromClick ) const; + void setAxisScaleType( QwtAxisId axis, RiuQwtPlotWidget::AxisScaleType axisScaleType ); + void setAxisScale( QwtAxisId axis, double min, double max ); + + RiuPlotAxis findPlotAxisForQwtAxis( const QwtAxisId& qwtAxisId ) const; private: void selectClosestPlotItem( const QPoint& pos, bool toggleItemInSelection = false ); static int defaultMinimumWidth(); void replot() override; - void highlightPlotItem( const QwtPlotItem* closestItem ); + void highlightPlotAxes( QwtAxisId axisIdX, QwtAxisId axisIdY ); + void highlightPlotItemsForQwtAxis( QwtAxisId axisId ); + void highlightPlotItems( const std::set& closestItems ); void resetPlotItemHighlighting(); + void resetPlotAxisHighlighting(); void onAxisSelected( QwtScaleWidget* scale, bool toggleItemInSelection ); - void recalculateAxisExtents( QwtPlot::Axis axis ); + void recalculateAxisExtents( RiuPlotAxis axis ); - void updateOverlayFrameLayout(); + static int highlightItemWidthAdjustment(); private: - caf::PdmPointer m_plotDefinition; - QPoint m_clickPosition; - std::map m_axisTitles; - std::map m_axisTitlesEnabled; - const int m_overlayMargins; - QString m_plotTitle; - bool m_plotTitleEnabled; - - QList> m_overlayFrames; - - struct CurveColors + struct CurveProperties { QColor lineColor; QColor symbolColor; QColor symbolLineColor; + int lineWidth; }; - std::map m_originalCurveColors; - std::map m_originalZValues; + std::map m_originalCurveProperties; + std::map m_originalZValues; + std::map m_axisMapping; - friend class RiaPlotWindowRedrawScheduler; + QPointer m_plot; }; diff --git a/ApplicationLibCode/UserInterface/RiuQwtScalePicker.cpp b/ApplicationLibCode/UserInterface/RiuQwtScalePicker.cpp index bcc528c96b..75e640aba2 100644 --- a/ApplicationLibCode/UserInterface/RiuQwtScalePicker.cpp +++ b/ApplicationLibCode/UserInterface/RiuQwtScalePicker.cpp @@ -6,6 +6,7 @@ #include #include +#include #include //-------------------------------------------------------------------------------------------------- @@ -14,7 +15,7 @@ RiuQwtScalePicker::RiuQwtScalePicker( QwtPlot* plot ) : QObject( plot ) { - for ( uint i = 0; i < QwtPlot::axisCnt; i++ ) + for ( uint i = 0; i < QwtAxis::AxisPositions; i++ ) { QwtScaleWidget* scaleWidget = plot->axisWidget( i ); if ( scaleWidget ) scaleWidget->installEventFilter( this ); diff --git a/ApplicationLibCode/UserInterface/RiuQwtSymbol.cpp b/ApplicationLibCode/UserInterface/RiuQwtSymbol.cpp index 719abef29f..b8f292b726 100644 --- a/ApplicationLibCode/UserInterface/RiuQwtSymbol.cpp +++ b/ApplicationLibCode/UserInterface/RiuQwtSymbol.cpp @@ -22,7 +22,9 @@ #include "RiaColorTools.h" #include "RiaFontCache.h" +#include "RiuPlotCurveSymbol.h" #include "cvfAssert.h" +#include "qwt_symbol.h" #include #include @@ -31,10 +33,8 @@ /// Internal class to support labels on symbols //-------------------------------------------------------------------------------------------------- RiuQwtSymbol::RiuQwtSymbol( PointSymbolEnum riuStyle, const QString& label, LabelPosition labelPosition, int labelFontSizePt ) - : QwtSymbol( QwtSymbol::NoSymbol ) - , m_globalLabel( label ) - , m_labelPosition( labelPosition ) - , m_labelFontSizePx( caf::FontTools::pointSizeToPixelSize( labelFontSizePt ) ) + : RiuPlotCurveSymbol( riuStyle, label, labelPosition, labelFontSizePt ) + , QwtSymbol( QwtSymbol::NoSymbol ) { QwtSymbol::Style style = QwtSymbol::NoSymbol; @@ -132,6 +132,30 @@ RiuQwtSymbol::RiuQwtSymbol( PointSymbolEnum riuStyle, const QString& label, Labe setStyle( style ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQwtSymbol::setSize( int width, int height ) +{ + QwtSymbol::setSize( width, height ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQwtSymbol::setColor( const QColor& color ) +{ + QwtSymbol::setColor( color ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuQwtSymbol::setPen( const QPen& pen ) +{ + QwtSymbol::setPen( pen ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -170,104 +194,15 @@ void RiuQwtSymbol::renderSymbolLabel( QPainter* painter, const QPointF& position //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RiuQwtSymbol::globalLabel() const -{ - return m_globalLabel; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuQwtSymbol::setGlobalLabel( const QString& label ) -{ - m_globalLabel = label; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuQwtSymbol::setLabelPosition( LabelPosition labelPosition ) -{ - m_labelPosition = labelPosition; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RiuQwtSymbol::PointSymbolEnum RiuQwtSymbol::cycledSymbolStyle( int indexLevel1, int indexLevel2 ) +void RiuQwtSymbol::setPixmap( const QPixmap& pixmap ) { - std::vector> categorisedStyles = { - { SYMBOL_ELLIPSE, SYMBOL_RECT, SYMBOL_DIAMOND }, - { SYMBOL_DOWN_TRIANGLE, SYMBOL_UP_TRIANGLE }, - { SYMBOL_LEFT_TRIANGLE, SYMBOL_RIGHT_TRIANGLE }, - { SYMBOL_CROSS, SYMBOL_XCROSS }, - { SYMBOL_STAR1, SYMBOL_STAR2 }, - }; - - int level1Category = indexLevel1 % int( categorisedStyles.size() ); - int level2Category = indexLevel2 % int( categorisedStyles[level1Category].size() ); - - return categorisedStyles[level1Category][level2Category]; + QwtSymbol::setPixmap( pixmap ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuQwtSymbol::PointSymbolEnum RiuQwtSymbol::cycledSymbolStyle( int indexLevel ) -{ - std::vector contrastingSymbols = { SYMBOL_ELLIPSE, - SYMBOL_CROSS, - SYMBOL_RECT, - SYMBOL_DOWN_TRIANGLE, - SYMBOL_UP_TRIANGLE, - SYMBOL_LEFT_TRIANGLE, - SYMBOL_RIGHT_TRIANGLE, - SYMBOL_STAR2, - SYMBOL_DIAMOND, - SYMBOL_STAR1 }; - - return contrastingSymbols[indexLevel % (int)contrastingSymbols.size()]; -} - -//-------------------------------------------------------------------------------------------------- -/// Is this a symbol with an interior and a border? If false, it is just lines. -//-------------------------------------------------------------------------------------------------- -bool RiuQwtSymbol::isFilledSymbol( PointSymbolEnum symbol ) +QRect RiuQwtSymbol::boundingRect() const { - return symbol != SYMBOL_NONE && symbol != SYMBOL_CROSS && symbol != SYMBOL_XCROSS && symbol != SYMBOL_STAR1; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QRect RiuQwtSymbol::labelBoundingRect( const QPainter* painter, const QRect& symbolRect, const QString& label ) const -{ - CVF_ASSERT( painter ); - - QPoint symbolPosition = symbolRect.topLeft(); - - int symbolWidth = symbolRect.width(); - int symbolHeight = symbolRect.height(); - - int labelWidth = painter->fontMetrics().width( label ); - int labelHeight = painter->fontMetrics().height(); - - QPoint labelPosition; - if ( m_labelPosition == LabelAboveSymbol ) - { - labelPosition = QPoint( symbolPosition.x() - labelWidth / 2, symbolPosition.y() - 5 ); - } - else if ( m_labelPosition == LabelBelowSymbol ) - { - labelPosition = QPoint( symbolPosition.x() - labelWidth / 2, symbolPosition.y() + symbolHeight + 5 ); - } - else if ( m_labelPosition == LabelLeftOfSymbol ) - { - labelPosition = QPoint( symbolPosition.x() - labelWidth - symbolWidth, symbolPosition.y() ); - } - else if ( m_labelPosition == LabelRightOfSymbol ) - { - labelPosition = QPoint( symbolPosition.x() + symbolWidth + 3, symbolPosition.y() ); - } - return QRect( labelPosition.x(), labelPosition.y(), labelWidth, labelHeight ); + return QwtSymbol::boundingRect(); } diff --git a/ApplicationLibCode/UserInterface/RiuQwtSymbol.h b/ApplicationLibCode/UserInterface/RiuQwtSymbol.h index 8b3e627773..343a50ec7f 100644 --- a/ApplicationLibCode/UserInterface/RiuQwtSymbol.h +++ b/ApplicationLibCode/UserInterface/RiuQwtSymbol.h @@ -18,70 +18,39 @@ ///////////////////////////////////////////////////////////////////////////////// #pragma once +#include "RiuPlotCurveSymbol.h" #include "qwt_symbol.h" + #include +class QPainter; +class QPointF; +class QRect; + //-------------------------------------------------------------------------------------------------- /// This class overrides renderSymbols to draw symbols and labels. /// The label is only visible in the legend, while it is clipped in the plot. /// Therefore the method RiuQwtPlotCurve::drawSymbols also draw labels to have labels /// in the plot as well. //-------------------------------------------------------------------------------------------------- -class RiuQwtSymbol : public QwtSymbol +class RiuQwtSymbol : public RiuPlotCurveSymbol, public QwtSymbol { public: - enum LabelPosition - { - LabelAboveSymbol, - LabelBelowSymbol, - LabelLeftOfSymbol, - LabelRightOfSymbol - }; - enum PointSymbolEnum - { - SYMBOL_NONE, - SYMBOL_ELLIPSE, - SYMBOL_RECT, - SYMBOL_DIAMOND, - SYMBOL_TRIANGLE, - SYMBOL_DOWN_TRIANGLE, - SYMBOL_CROSS, - SYMBOL_XCROSS, - SYMBOL_LEFT_ALIGNED_TRIANGLE, // Aligned so pin point is at lower right corner - SYMBOL_RIGHT_ALIGNED_TRIANGLE, // Aligned so pin point is at lower left corner - SYMBOL_LEFT_ANGLED_TRIANGLE, - SYMBOL_RIGHT_ANGLED_TRIANGLE, - SYMBOL_UP_TRIANGLE, - SYMBOL_STAR1, - SYMBOL_STAR2, - SYMBOL_HEXAGON, - SYMBOL_LEFT_TRIANGLE, - SYMBOL_RIGHT_TRIANGLE - }; - - RiuQwtSymbol( PointSymbolEnum riuStyle, - const QString& label, - LabelPosition labelPosition = LabelAboveSymbol, - int labelFontSizePt = 8 ); - void renderSymbols( QPainter* painter, const QPointF* points, int numPoints ) const override; - void renderSymbolLabel( QPainter* painter, const QPointF& position, const QString& label ) const; - QString globalLabel() const; - - void setGlobalLabel( const QString& label ); + RiuQwtSymbol( RiuPlotCurveSymbol::PointSymbolEnum riuStyle, + const QString& label = QString(), + LabelPosition labelPosition = RiuPlotCurveSymbol::LabelAboveSymbol, + int labelFontSizePt = 8 ); + void renderSymbols( QPainter* painter, const QPointF* points, int numPoints ) const override; + void renderSymbolLabel( QPainter* painter, const QPointF& position, const QString& label ) const; - void setLabelPosition( LabelPosition labelPosition ); + void setSize( int width, int height ) override; - static PointSymbolEnum cycledSymbolStyle( int indexLevel1, int indexLevel2 ); - static PointSymbolEnum cycledSymbolStyle( int indexLevel ); + void setColor( const QColor& color ) override; - static bool isFilledSymbol( PointSymbolEnum symbol ); + void setPen( const QPen& pen ) override; -private: - QRect labelBoundingRect( const QPainter* painter, const QRect& symbolRect, const QString& label ) const; + void setPixmap( const QPixmap& pixmap ) override; -private: - QString m_globalLabel; - int m_labelFontSizePx; - LabelPosition m_labelPosition; + QRect boundingRect() const override; }; diff --git a/ApplicationLibCode/UserInterface/RiuRelativePermeabilityPlotPanel.cpp b/ApplicationLibCode/UserInterface/RiuRelativePermeabilityPlotPanel.cpp index b2bb8e8db4..bd40c5bf8f 100644 --- a/ApplicationLibCode/UserInterface/RiuRelativePermeabilityPlotPanel.cpp +++ b/ApplicationLibCode/UserInterface/RiuRelativePermeabilityPlotPanel.cpp @@ -18,18 +18,21 @@ #include "RiuRelativePermeabilityPlotPanel.h" +#include "RigFlowDiagSolverInterface.h" + +#include "RiaCurveDataTools.h" +#include "RiaEclipseUnitTools.h" +#include "RiaPlotDefines.h" +#include "RiaResultNames.h" #include "RiuDockedQwtPlot.h" #include "RiuGuiTheme.h" +#include "RiuPlotCurveSymbol.h" #include "RiuQwtPlotCurve.h" #include "RiuQwtPlotTools.h" +#include "RiuQwtSymbol.h" #include "RiuRelativePermeabilityPlotUpdater.h" #include "RiuTextDialog.h" -#include "RiaCurveDataTools.h" -#include "RiaEclipseUnitTools.h" - -#include "RigFlowDiagSolverInterface.h" - #include "cvfAssert.h" #include "cvfTrace.h" @@ -38,7 +41,7 @@ #include "qwt_plot_curve.h" #include "qwt_plot_marker.h" #include "qwt_scale_engine.h" -#include "qwt_symbol.h" +#include "qwt_text.h" #include #include @@ -175,13 +178,11 @@ void RiuRelativePermeabilityPlotPanel::setPlotDefaults( QwtPlot* plot ) plot->setTitle( plotTitle ); } - plot->enableAxis( QwtPlot::xBottom, true ); - plot->enableAxis( QwtPlot::yLeft, true ); - plot->enableAxis( QwtPlot::xTop, false ); - plot->enableAxis( QwtPlot::yRight, false ); + plot->setAxesCount( QwtAxis::XBottom, 1 ); + plot->setAxesCount( QwtAxis::YLeft, 1 ); - plot->setAxisMaxMinor( QwtPlot::xBottom, 2 ); - plot->setAxisMaxMinor( QwtPlot::yLeft, 3 ); + plot->setAxisMaxMinor( QwtAxis::XBottom, 2 ); + plot->setAxisMaxMinor( QwtAxis::YLeft, 3 ); QwtLegend* legend = new QwtLegend( plot ); plot->insertLegend( legend, QwtPlot::BottomLegend ); @@ -303,8 +304,8 @@ void RiuRelativePermeabilityPlotPanel::addTransparentCurve( QwtPlot* curveLeftAxis->setSamples( pointsOnLeftAxis ); curveRightAxis->setSamples( pointsOnRightAxis ); - curveLeftAxis->setYAxis( QwtPlot::yLeft ); - curveRightAxis->setYAxis( QwtPlot::yRight ); + curveLeftAxis->setYAxis( QwtAxis::YLeft ); + curveRightAxis->setYAxis( QwtAxis::YRight ); curveLeftAxis->setStyle( QwtPlotCurve::NoCurve ); curveRightAxis->setStyle( QwtPlotCurve::NoCurve ); @@ -362,11 +363,9 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt( RiaDefines::EclipseUnitS plotOnWhichYAxis = RIGHT_YAXIS; } - // QwtPlotCurve* qwtCurve = new QwtPlotCurve(curve.name.c_str()); - RiuQwtPlotCurve* qwtCurve = new RiuQwtPlotCurve( curve.name.c_str() ); + RiuQwtPlotCurve* qwtCurve = new RiuQwtPlotCurve( nullptr, curve.name.c_str() ); CVF_ASSERT( curve.saturationVals.size() == curve.yVals.size() ); - // qwtCurve->setSamples(curve.xVals.data(), curve.yVals.data(), static_cast(curve.xVals.size())); const bool includePositiveValuesOnly = ( logScaleLeftAxis && plotOnWhichYAxis == LEFT_YAXIS ); qwtCurve->setSamplesFromXValuesAndYValues( curve.saturationVals, curve.yVals, includePositiveValuesOnly ); @@ -402,7 +401,7 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt( RiaDefines::EclipseUnitS const QPen curvePen( QBrush(), 1, penStyle ); qwtCurve->setPen( curvePen ); - QwtSymbol* curveSymbol = new QwtSymbol( QwtSymbol::Ellipse ); + RiuQwtSymbol* curveSymbol = new RiuQwtSymbol( RiuPlotCurveSymbol::SYMBOL_ELLIPSE ); curveSymbol->setSize( 6, 6 ); curveSymbol->setBrush( Qt::NoBrush ); qwtCurve->setSymbol( curveSymbol ); @@ -415,7 +414,7 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt( RiaDefines::EclipseUnitS if ( plotOnWhichYAxis == RIGHT_YAXIS ) { - qwtCurve->setYAxis( QwtPlot::yRight ); + qwtCurve->setYAxis( RiuPlotAxis::defaultRight() ); shouldEnableRightYAxis = true; } @@ -459,60 +458,63 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt( RiaDefines::EclipseUnitS } } - plot->enableAxis( QwtPlot::yRight, shouldEnableRightYAxis ); + if ( shouldEnableRightYAxis ) + plot->setAxesCount( QwtAxis::YRight, 1 ); + else + plot->setAxesCount( QwtAxis::YRight, 0 ); addTransparentCurve( plot, points, axes, logScaleLeftAxis ); // Add vertical marker lines to indicate cell SWAT and/or SGAS saturations if ( swat != HUGE_VAL ) { - addVerticalSaturationMarkerLine( swat, "SWAT", waterColor, plot, myPlotMarkers ); + addVerticalSaturationMarkerLine( swat, RiaResultNames::swat(), waterColor, plot, myPlotMarkers ); } if ( sgas != HUGE_VAL ) { - addVerticalSaturationMarkerLine( sgas, "SGAS", gasColor, plot, myPlotMarkers ); + addVerticalSaturationMarkerLine( sgas, RiaResultNames::sgas(), gasColor, plot, myPlotMarkers ); } if ( logScaleLeftAxis ) { - if ( !dynamic_cast( plot->axisScaleEngine( QwtPlot::yLeft ) ) ) + if ( !dynamic_cast( plot->axisScaleEngine( QwtAxis::YLeft ) ) ) { - plot->setAxisScaleEngine( QwtPlot::yLeft, new QwtLogScaleEngine ); + plot->setAxisScaleEngine( QwtAxis::YLeft, new QwtLogScaleEngine ); } } else { - if ( !dynamic_cast( plot->axisScaleEngine( QwtPlot::yLeft ) ) ) + if ( !dynamic_cast( plot->axisScaleEngine( QwtAxis::YLeft ) ) ) { - plot->setAxisScaleEngine( QwtPlot::yLeft, new QwtLinearScaleEngine ); + plot->setAxisScaleEngine( QwtAxis::YLeft, new QwtLinearScaleEngine ); } } if ( fixedXAxis ) { - plot->setAxisScale( QwtPlot::xBottom, 0.0, 1.0 ); - plot->setAxisAutoScale( QwtPlot::xBottom, false ); + plot->setAxisScale( QwtAxis::XBottom, 0.0, 1.0 ); + plot->setAxisAutoScale( QwtAxis::XBottom, false ); } else { - plot->setAxisAutoScale( QwtPlot::xBottom, true ); + plot->setAxisAutoScale( QwtAxis::XBottom, true ); } if ( fixedLeftYAxis ) { if ( logScaleLeftAxis ) { - plot->setAxisScale( QwtPlot::yLeft, 1.0e-6, 1.0 ); + plot->setAxisScale( QwtAxis::YLeft, 1.0e-6, 1.0 ); } else { - plot->setAxisScale( QwtPlot::yLeft, 0.0, 1.0 ); + plot->setAxisScale( QwtAxis::YLeft, 0.0, 1.0 ); } - plot->setAxisAutoScale( QwtPlot::yLeft, false ); + plot->setAxisAutoScale( QwtAxis::YLeft, false ); } else { - plot->setAxisAutoScale( QwtPlot::yLeft, true ); + plot->setAxisAutoScale( QwtAxis::YLeft, true ); } QString titleStr = "Relative Permeability"; @@ -522,9 +524,9 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt( RiaDefines::EclipseUnitS } plot->setTitle( titleStr ); - plot->setAxisTitle( QwtPlot::xBottom, determineXAxisTitleFromCurveCollection( curveArr ) ); - plot->setAxisTitle( QwtPlot::yLeft, "Kr" ); - plot->setAxisTitle( QwtPlot::yRight, QString( "Pc [%1]" ).arg( RiaEclipseUnitTools::unitStringPressure( unitSystem ) ) ); + plot->setAxisTitle( QwtAxis::XBottom, determineXAxisTitleFromCurveCollection( curveArr ) ); + plot->setAxisTitle( QwtAxis::YLeft, "Kr" ); + plot->setAxisTitle( QwtAxis::YRight, QString( "Pc [%1]" ).arg( RiaEclipseUnitTools::unitStringPressure( unitSystem ) ) ); plot->replot(); } @@ -625,7 +627,7 @@ void RiuRelativePermeabilityPlotPanel::addCurveConstSaturationIntersectionMarker if ( whichYAxis == RIGHT_YAXIS ) { - pointMarker->setYAxis( QwtPlot::yRight ); + pointMarker->setYAxis( QwtAxis::YRight ); } myPlotMarkers->push_back( pointMarker ); diff --git a/ApplicationLibCode/UserInterface/RiuRelativePermeabilityPlotUpdater.cpp b/ApplicationLibCode/UserInterface/RiuRelativePermeabilityPlotUpdater.cpp index a6d62a6b6a..a5c40a3b2b 100644 --- a/ApplicationLibCode/UserInterface/RiuRelativePermeabilityPlotUpdater.cpp +++ b/ApplicationLibCode/UserInterface/RiuRelativePermeabilityPlotUpdater.cpp @@ -172,9 +172,9 @@ bool RiuRelativePermeabilityPlotUpdater::queryDataAndUpdatePlot( const RimEclips RigCaseCellResultsData* cellResultsData = eclipseCaseData->results( RiaDefines::PorosityModelType::MATRIX_MODEL ); cellResultsData->ensureKnownResultLoaded( - RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "SWAT" ) ); + RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, RiaResultNames::swat() ) ); cellResultsData->ensureKnownResultLoaded( - RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "SGAS" ) ); + RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, RiaResultNames::sgas() ) ); cellResultsData->ensureKnownResultLoaded( RigEclipseResultAddress( RiaDefines::ResultCatType::STATIC_NATIVE, "SATNUM" ) ); @@ -185,14 +185,14 @@ bool RiuRelativePermeabilityPlotUpdater::queryDataAndUpdatePlot( const RimEclips RiaDefines::PorosityModelType::MATRIX_MODEL, timeStepIndex, RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, - "SWAT" ) ); + RiaResultNames::swat() ) ); cvf::ref sgasAccessor = RigResultAccessorFactory::createFromResultAddress( eclipseCaseData, gridIndex, RiaDefines::PorosityModelType::MATRIX_MODEL, timeStepIndex, RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, - "SGAS" ) ); + RiaResultNames::sgas() ) ); cvf::ref satnumAccessor = RigResultAccessorFactory::createFromResultAddress( eclipseCaseData, gridIndex, diff --git a/ApplicationLibCode/UserInterface/RiuResultQwtPlot.cpp b/ApplicationLibCode/UserInterface/RiuResultQwtPlot.cpp index c8f087be81..768335ec35 100644 --- a/ApplicationLibCode/UserInterface/RiuResultQwtPlot.cpp +++ b/ApplicationLibCode/UserInterface/RiuResultQwtPlot.cpp @@ -78,7 +78,7 @@ void RiuResultQwtPlot::addCurve( const RimCase* rimCase, return; } - RiuQwtPlotCurve* plotCurve = new RiuQwtPlotCurve( "Curve 1" ); + RiuQwtPlotCurve* plotCurve = new RiuQwtPlotCurve( nullptr, "Curve 1" ); plotCurve->setSamplesFromDatesAndYValues( dateTimes, timeHistoryValues, false ); plotCurve->setTitle( curveName ); @@ -88,7 +88,7 @@ void RiuResultQwtPlot::addCurve( const RimCase* rimCase, plotCurve->attach( this ); m_plotCurves.push_back( plotCurve ); - this->setAxisScale( QwtPlot::xTop, QwtDate::toDouble( dateTimes.front() ), QwtDate::toDouble( dateTimes.back() ) ); + this->setAxisScale( QwtAxis::XTop, QwtDate::toDouble( dateTimes.front() ), QwtDate::toDouble( dateTimes.back() ) ); this->applyFontSizes( false ); this->replot(); @@ -185,18 +185,16 @@ void RiuResultQwtPlot::setDefaults() { RiuQwtPlotTools::setCommonPlotBehaviour( this ); - enableAxis( QwtPlot::xBottom, true ); - enableAxis( QwtPlot::yLeft, true ); - enableAxis( QwtPlot::xTop, false ); - enableAxis( QwtPlot::yRight, false ); + setAxesCount( QwtAxis::XBottom, 1 ); + setAxesCount( QwtAxis::YLeft, 1 ); QString dateFormat = RiaPreferences::current()->dateFormat(); QString timeFormat = RiaPreferences::current()->timeFormat(); RiuQwtPlotTools::enableDateBasedBottomXAxis( this, dateFormat, timeFormat ); - setAxisMaxMinor( QwtPlot::xBottom, 2 ); - setAxisMaxMinor( QwtPlot::yLeft, 3 ); + setAxisMaxMinor( QwtAxis::XBottom, 2 ); + setAxisMaxMinor( QwtAxis::YLeft, 3 ); applyFontSizes( false ); diff --git a/ApplicationLibCode/UserInterface/RiuResultQwtPlot.h b/ApplicationLibCode/UserInterface/RiuResultQwtPlot.h index 4c94cd5ad2..e6f346b9d2 100644 --- a/ApplicationLibCode/UserInterface/RiuResultQwtPlot.h +++ b/ApplicationLibCode/UserInterface/RiuResultQwtPlot.h @@ -21,8 +21,6 @@ #include "RiuDockedQwtPlot.h" -#include "qwt_plot.h" - #include #include #include diff --git a/ApplicationLibCode/UserInterface/RiuResultTextBuilder.cpp b/ApplicationLibCode/UserInterface/RiuResultTextBuilder.cpp index 22ba2aea6c..26c0dde78e 100644 --- a/ApplicationLibCode/UserInterface/RiuResultTextBuilder.cpp +++ b/ApplicationLibCode/UserInterface/RiuResultTextBuilder.cpp @@ -19,6 +19,7 @@ #include "RiuResultTextBuilder.h" +#include "RigAllanDiagramData.h" #include "RigCaseCellResultsData.h" #include "RigEclipseCaseData.h" #include "RigFormationNames.h" @@ -37,13 +38,12 @@ #include "RimEclipseView.h" #include "RimExtrudedCurveIntersection.h" #include "RimFormationNames.h" +#include "RimIntersectionResultDefinition.h" #include "RimRegularLegendConfig.h" #include "RimReservoirCellResultsStorage.h" #include "RivExtrudedCurveIntersectionPartMgr.h" -#include "RigAllanDiagramData.h" -#include "RimIntersectionResultDefinition.h" #include "cafDisplayCoordTransform.h" //-------------------------------------------------------------------------------------------------- @@ -544,11 +544,11 @@ void RiuResultTextBuilder::appendTextFromResultColors( RigEclipseCaseData* if ( gridCellResults ) { gridCellResults->ensureKnownResultLoaded( - RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "SOIL" ) ); + RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, RiaResultNames::soil() ) ); gridCellResults->ensureKnownResultLoaded( - RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "SGAS" ) ); + RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, RiaResultNames::sgas() ) ); gridCellResults->ensureKnownResultLoaded( - RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "SWAT" ) ); + RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, RiaResultNames::swat() ) ); cvf::ref dataAccessObjectX = RigResultAccessorFactory::createFromResultAddress( eclipseCase, @@ -556,21 +556,21 @@ void RiuResultTextBuilder::appendTextFromResultColors( RigEclipseCaseData* porosityModel, timeStepIndex, RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, - "SOIL" ) ); + RiaResultNames::soil() ) ); cvf::ref dataAccessObjectY = RigResultAccessorFactory::createFromResultAddress( eclipseCase, gridIndex, porosityModel, timeStepIndex, RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, - "SGAS" ) ); + RiaResultNames::sgas() ) ); cvf::ref dataAccessObjectZ = RigResultAccessorFactory::createFromResultAddress( eclipseCase, gridIndex, porosityModel, timeStepIndex, RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, - "SWAT" ) ); + RiaResultNames::swat() ) ); double scalarValue = 0.0; @@ -900,11 +900,11 @@ QString RiuResultTextBuilder::cellResultText( RimEclipseResultDefinition* eclRes if ( gridCellResults ) { gridCellResults->ensureKnownResultLoaded( - RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "SOIL" ) ); + RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, RiaResultNames::soil() ) ); gridCellResults->ensureKnownResultLoaded( - RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "SGAS" ) ); + RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, RiaResultNames::sgas() ) ); gridCellResults->ensureKnownResultLoaded( - RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "SWAT" ) ); + RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, RiaResultNames::swat() ) ); RiaDefines::PorosityModelType porosityModel = eclResDef->porosityModel(); @@ -914,21 +914,21 @@ QString RiuResultTextBuilder::cellResultText( RimEclipseResultDefinition* eclRes porosityModel, m_timeStepIndex, RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, - "SOIL" ) ); + RiaResultNames::soil() ) ); cvf::ref dataAccessObjectY = RigResultAccessorFactory::createFromResultAddress( eclipseCaseData, m_gridIndex, porosityModel, m_timeStepIndex, RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, - "SGAS" ) ); + RiaResultNames::sgas() ) ); cvf::ref dataAccessObjectZ = RigResultAccessorFactory::createFromResultAddress( eclipseCaseData, m_gridIndex, porosityModel, m_timeStepIndex, RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, - "SWAT" ) ); + RiaResultNames::swat() ) ); double scalarValue = 0.0; diff --git a/ApplicationLibCode/UserInterface/RiuRmsNavigation.cpp b/ApplicationLibCode/UserInterface/RiuRmsNavigation.cpp index ec4b1a757b..520c858f1e 100644 --- a/ApplicationLibCode/UserInterface/RiuRmsNavigation.cpp +++ b/ApplicationLibCode/UserInterface/RiuRmsNavigation.cpp @@ -18,7 +18,10 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RiuRmsNavigation.h" + +#include "caf.h" #include "cafViewer.h" + #include "cvfCamera.h" #include "cvfHitItemCollection.h" #include "cvfManipulatorTrackball.h" @@ -57,7 +60,7 @@ bool RiuRmsNavigation::handleInputEvent( QInputEvent* inputEvent ) int translatedMousePosX, translatedMousePosY; cvfEventPos( me->x(), me->y(), &translatedMousePosX, &translatedMousePosY ); - if ( me->button() == Qt::MidButton && isRotationEnabled() ) + if ( me->button() == Qt::MiddleButton && isRotationEnabled() ) { this->pickAndSetPointOfInterest( me->x(), me->y() ); @@ -100,7 +103,7 @@ bool RiuRmsNavigation::handleInputEvent( QInputEvent* inputEvent ) if ( m_isNavigating ) { QMouseEvent* me = static_cast( inputEvent ); - if ( me->button() == Qt::RightButton || me->button() == Qt::MidButton ) + if ( me->button() == Qt::RightButton || me->button() == Qt::MiddleButton ) { m_trackball->endNavigation(); @@ -157,18 +160,19 @@ bool RiuRmsNavigation::handleInputEvent( QInputEvent* inputEvent ) { if ( inputEvent->modifiers() == Qt::NoModifier ) { - QWheelEvent* we = static_cast( inputEvent ); + QWheelEvent* we = static_cast( inputEvent ); + auto position = caf::position( we ); - updatePointOfInterestDuringZoomIfNecessary( we->x(), we->y() ); + updatePointOfInterestDuringZoomIfNecessary( position.x(), position.y() ); if ( m_isRotCenterInitialized ) { int translatedMousePosX, translatedMousePosY; - cvfEventPos( we->x(), we->y(), &translatedMousePosX, &translatedMousePosY ); + cvfEventPos( position.x(), position.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/ApplicationLibCode/UserInterface/RiuScalarMapperLegendFrame.cpp b/ApplicationLibCode/UserInterface/RiuScalarMapperLegendFrame.cpp index cbc36c2c9d..6bc6fd50c6 100644 --- a/ApplicationLibCode/UserInterface/RiuScalarMapperLegendFrame.cpp +++ b/ApplicationLibCode/UserInterface/RiuScalarMapperLegendFrame.cpp @@ -17,6 +17,8 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RiuScalarMapperLegendFrame.h" +#include "RiaTextStringTools.h" + #include "cvfScalarMapperDiscreteLinear.h" #include "cvfScalarMapperDiscreteLog.h" #include "cvfString.h" @@ -72,7 +74,7 @@ void RiuScalarMapperLegendFrame::setTickFormat( NumberFormat format ) void RiuScalarMapperLegendFrame::layoutInfo( LayoutInfo* layout ) const { QFontMetrics fontMetrics( this->font() ); - QStringList titleLines = m_title.split( "\n", QString::SkipEmptyParts ); + QStringList titleLines = RiaTextStringTools::splitSkipEmptyParts( m_title, "\n" ); layout->charHeight = fontMetrics.height(); layout->charAscent = fontMetrics.ascent(); diff --git a/ApplicationLibCode/UserInterface/RiuScalarMapperLegendFrame.h b/ApplicationLibCode/UserInterface/RiuScalarMapperLegendFrame.h index a2737b7003..af3ed2d5da 100644 --- a/ApplicationLibCode/UserInterface/RiuScalarMapperLegendFrame.h +++ b/ApplicationLibCode/UserInterface/RiuScalarMapperLegendFrame.h @@ -19,7 +19,6 @@ #include "RiaNumberFormat.h" -#include "RimRegularLegendConfig.h" #include "RiuAbstractLegendFrame.h" #include "cvfObject.h" diff --git a/ApplicationLibCode/UserInterface/RiuSelectionChangedHandler.cpp b/ApplicationLibCode/UserInterface/RiuSelectionChangedHandler.cpp index 01990bd050..5e99329fd4 100644 --- a/ApplicationLibCode/UserInterface/RiuSelectionChangedHandler.cpp +++ b/ApplicationLibCode/UserInterface/RiuSelectionChangedHandler.cpp @@ -79,6 +79,8 @@ RiuSelectionChangedHandler::~RiuSelectionChangedHandler() //-------------------------------------------------------------------------------------------------- void RiuSelectionChangedHandler::handleSelectionDeleted() const { + if ( !RiuMainWindow::instance() ) return; + RiuMainWindow::instance()->resultPlot()->deleteAllCurves(); RiuRelativePermeabilityPlotUpdater* relPermPlotUpdater = @@ -101,6 +103,8 @@ void RiuSelectionChangedHandler::handleSelectionDeleted() const //-------------------------------------------------------------------------------------------------- void RiuSelectionChangedHandler::handleItemAppended( const RiuSelectionItem* item ) const { + if ( !RiuMainWindow::instance() ) return; + addCurveFromSelectionItem( item ); RiuRelativePermeabilityPlotUpdater* relPermUpdater = @@ -123,6 +127,8 @@ void RiuSelectionChangedHandler::handleItemAppended( const RiuSelectionItem* ite //-------------------------------------------------------------------------------------------------- void RiuSelectionChangedHandler::handleSetSelectedItem( const RiuSelectionItem* item ) const { + if ( !RiuMainWindow::instance() ) return; + RiuMainWindow::instance()->resultPlot()->deleteAllCurves(); RiuMohrsCirclePlot* mohrsCirclePlot = RiuMainWindow::instance()->mohrsCirclePlot(); diff --git a/ApplicationLibCode/UserInterface/RiuSimpleHistogramWidget.h b/ApplicationLibCode/UserInterface/RiuSimpleHistogramWidget.h index 697bc16128..14afcecf69 100644 --- a/ApplicationLibCode/UserInterface/RiuSimpleHistogramWidget.h +++ b/ApplicationLibCode/UserInterface/RiuSimpleHistogramWidget.h @@ -29,7 +29,7 @@ class QStringList; class RiuSimpleHistogramWidget : public QWidget { public: - RiuSimpleHistogramWidget( const QString& objectName, QWidget* parent = nullptr, Qt::WindowFlags f = nullptr ); + RiuSimpleHistogramWidget( const QString& objectName, QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags() ); void setHistogramData( double min, double max, const std::vector& histogram ); void setPercentiles( double pmin, double pmax ); diff --git a/ApplicationLibCode/UserInterface/RiuSummaryMultiPlotBook.cpp b/ApplicationLibCode/UserInterface/RiuSummaryMultiPlotBook.cpp new file mode 100644 index 0000000000..0b945c6b46 --- /dev/null +++ b/ApplicationLibCode/UserInterface/RiuSummaryMultiPlotBook.cpp @@ -0,0 +1,106 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// +#include "RiuSummaryMultiPlotBook.h" + +#include "RimSummaryMultiPlot.h" + +#include "RiuSummaryMultiPlotPage.h" + +#include "RiuPlotWidget.h" + +#include +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuSummaryMultiPlotBook::RiuSummaryMultiPlotBook( RimSummaryMultiPlot* plotDefinition, QWidget* parent ) + : RiuMultiPlotBook( plotDefinition, parent ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuSummaryMultiPlotBook::~RiuSummaryMultiPlotBook() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuSummaryMultiPlotBook::createPages() +{ + CAF_ASSERT( m_plotDefinition ); + + QList> plotWidgets = this->visiblePlotWidgets(); + + int columns = std::max( 1, m_plotDefinition->columnCount() ); + int rowsPerPage = m_plotDefinition->rowsPerPage(); + + int row = 0; + int col = 0; + + auto summaryMultiPlot = dynamic_cast( m_plotDefinition.p() ); + if ( summaryMultiPlot ) summaryMultiPlot->clearLayoutInfo(); + + RiuSummaryMultiPlotPage* page = createSummaryPage(); + + for ( int visibleIndex = 0; visibleIndex < plotWidgets.size(); ++visibleIndex ) + { + int expectedColSpan = static_cast( plotWidgets[visibleIndex]->colSpan() ); + int colSpan = std::min( expectedColSpan, columns ); + + if ( row >= rowsPerPage ) + { + row = 0; + page = createSummaryPage(); + } + + page->addPlot( plotWidgets[visibleIndex] ); + page->performUpdate( RiaDefines::MultiPlotPageUpdateType::ALL ); + + col += colSpan; + if ( col >= columns ) + { + row++; + col = 0; + } + } + + // Set page numbers in title when there's more than one page + updatePageTitles(); + adjustBookFrame(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuSummaryMultiPlotPage* RiuSummaryMultiPlotBook::createSummaryPage() +{ + RimSummaryMultiPlot* sumMultPlot = dynamic_cast( m_plotDefinition.p() ); + RiuSummaryMultiPlotPage* page = new RiuSummaryMultiPlotPage( sumMultPlot, this ); + + applyPageSettings( page ); + + m_pages.push_back( page ); + m_bookLayout->addWidget( page ); + + page->setVisible( true ); + return page; +} diff --git a/ApplicationLibCode/UserInterface/RiuSummaryMultiPlotBook.h b/ApplicationLibCode/UserInterface/RiuSummaryMultiPlotBook.h new file mode 100644 index 0000000000..7d3561f410 --- /dev/null +++ b/ApplicationLibCode/UserInterface/RiuSummaryMultiPlotBook.h @@ -0,0 +1,42 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// +#pragma once + +#include "RiuMultiPlotBook.h" + +class RimSummaryMultiPlot; +class RiuSummaryMultiPlotPage; + +//================================================================================================== +// +// +//================================================================================================== +class RiuSummaryMultiPlotBook : public RiuMultiPlotBook +{ + Q_OBJECT + +public: + RiuSummaryMultiPlotBook( RimSummaryMultiPlot* plotDefinition, QWidget* parent = nullptr ); + ~RiuSummaryMultiPlotBook() override; + +protected: + void createPages() override; + +private: + RiuSummaryMultiPlotPage* createSummaryPage(); +}; diff --git a/ApplicationLibCode/UserInterface/RiuSummaryMultiPlotPage.cpp b/ApplicationLibCode/UserInterface/RiuSummaryMultiPlotPage.cpp new file mode 100644 index 0000000000..72ff0aa121 --- /dev/null +++ b/ApplicationLibCode/UserInterface/RiuSummaryMultiPlotPage.cpp @@ -0,0 +1,169 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiuSummaryMultiPlotPage.h" + +#include "RimSummaryMultiPlot.h" +#include "RimSummaryPlot.h" + +#include "RiuPlotWidget.h" +#include "RiuQwtPlotLegend.h" + +#include +#include + +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuSummaryMultiPlotPage::RiuSummaryMultiPlotPage( RimSummaryMultiPlot* plotDefinition, QWidget* parent ) + : RiuMultiPlotPage( plotDefinition, parent ) + , m_summaryMultiPlot( plotDefinition ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuSummaryMultiPlotPage::~RiuSummaryMultiPlotPage() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuSummaryMultiPlotPage::reinsertPlotWidgets() +{ + if ( m_gridLayout ) + { + for ( int phIdx = 0; phIdx < m_placeholderWidgets.size(); phIdx++ ) + { + m_gridLayout->removeWidget( m_placeholderWidgets[phIdx] ); + m_placeholderWidgets[phIdx]->hide(); + } + } + + clearGridLayout(); + updateTitleFont(); + + int cols = m_summaryMultiPlot->columnCount(); + int rows = m_summaryMultiPlot->rowsPerPage(); + int nPlots = visiblePlotWidgets().size(); + + int nCells = cols * rows; + reservePlaceholders( nCells - nPlots ); + + QList> subTitles = this->subTitlesForVisiblePlots(); + QList> legends = this->legendsForVisiblePlots(); + QList> plotWidgets = this->visiblePlotWidgets(); + + int visibleIndex = 0; + int phIndex = 0; + + for ( int row = 0; row < rows; row++ ) + { + for ( int col = 0; col < cols; col++ ) + { + if ( visibleIndex >= nPlots ) + { + m_gridLayout->addWidget( m_placeholderWidgets[phIndex], row * 3 + 2, col ); + m_gridLayout->setRowStretch( row * 3 + 2, 1 ); + m_gridLayout->setColumnStretch( col, 6 ); + m_placeholderWidgets[phIndex]->show(); + phIndex++; + continue; + } + + auto plotWidget = plotWidgets[visibleIndex]; + int expectedColSpan = plotWidget->colSpan(); + int colSpan = std::min( expectedColSpan, cols - col ); + + m_gridLayout->addWidget( subTitles[visibleIndex], 3 * row, col, 1, colSpan ); + if ( legends[visibleIndex] ) + { + m_gridLayout->addWidget( legends[visibleIndex], 3 * row + 1, col, 1, colSpan, Qt::AlignHCenter | Qt::AlignBottom ); + } + m_gridLayout->addWidget( plotWidget, 3 * row + 2, col, 1, colSpan ); + auto summaryPlot = dynamic_cast( plotWidget->plotDefinition() ); + if ( summaryPlot ) m_summaryMultiPlot->setLayoutInfo( summaryPlot, row, col ); + + bool isSubTitleVisible = m_showSubTitles && !subTitles[visibleIndex]->text().isEmpty(); + subTitles[visibleIndex]->setVisible( isSubTitleVisible ); + QFont subTitleFont = subTitles[visibleIndex]->font(); + subTitleFont.setPixelSize( m_subTitleFontPixelSize ); + subTitles[visibleIndex]->setFont( subTitleFont ); + + plotWidget->setAxisLabelsAndTicksEnabled( RiuPlotAxis::defaultLeft(), + showYAxis( row, col ), + showYAxis( row, col ) ); + plotWidget->setAxisTitleEnabled( RiuPlotAxis::defaultLeft(), showYAxis( row, col ) ); + plotWidget->setAxesFontsAndAlignment( m_axisTitleFontSize, m_axisValueFontSize ); + + // Adjust the space below a graph to make sure the heading of the row below is closest to the + // corresponding graph + auto margins = plotWidget->contentsMargins(); + margins.setBottom( 40 ); + plotWidget->setContentsMargins( margins ); + plotWidget->show(); + + if ( legends[visibleIndex] ) + { + if ( m_plotDefinition->legendsVisible() && !legends[visibleIndex]->isEmpty() ) + { + int legendColumns = 1; + if ( m_plotDefinition->legendsHorizontal() ) + { + legendColumns = 0; // unlimited + } + legends[visibleIndex]->setMaxColumns( legendColumns ); + QFont legendFont = legends[visibleIndex]->font(); + legendFont.setPixelSize( m_legendFontPixelSize ); + legends[visibleIndex]->setFont( legendFont ); + legends[visibleIndex]->show(); + } + else + { + legends[visibleIndex]->hide(); + } + } + // Set basic row and column stretches + m_gridLayout->setRowStretch( 3 * row + 2, 1 ); + for ( int c = col; c < col + colSpan; c++ ) + { + int colStretch = 6; // Empirically chosen to try to counter the width of the axis on the first track + if ( showYAxis( row, col ) ) colStretch += 1; + m_gridLayout->setColumnStretch( c, std::max( colStretch, m_gridLayout->columnStretch( c ) ) ); + } + + visibleIndex++; + col += colSpan - 1; + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuSummaryMultiPlotPage::reservePlaceholders( int count ) +{ + while ( m_placeholderWidgets.size() < count ) + { + m_placeholderWidgets.push_back( new QWidget( this ) ); + } +} diff --git a/ApplicationLibCode/UserInterface/RiuSummaryMultiPlotPage.h b/ApplicationLibCode/UserInterface/RiuSummaryMultiPlotPage.h new file mode 100644 index 0000000000..e4de6c9103 --- /dev/null +++ b/ApplicationLibCode/UserInterface/RiuSummaryMultiPlotPage.h @@ -0,0 +1,44 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// +#pragma once + +#include "RiuMultiPlotPage.h" + +class RimSummaryMultiPlot; + +#include +#include +#include + +class RiuSummaryMultiPlotPage : public RiuMultiPlotPage +{ + Q_OBJECT + +public: + RiuSummaryMultiPlotPage( RimSummaryMultiPlot* plotDefinition, QWidget* parent = nullptr ); + ~RiuSummaryMultiPlotPage() override; + +protected: + void reinsertPlotWidgets() override; + + void reservePlaceholders( int count ); + +private: + RimSummaryMultiPlot* m_summaryMultiPlot; + QList> m_placeholderWidgets; +}; diff --git a/ApplicationLibCode/UserInterface/RiuSummaryPlot.cpp b/ApplicationLibCode/UserInterface/RiuSummaryPlot.cpp new file mode 100644 index 0000000000..d6db4b0782 --- /dev/null +++ b/ApplicationLibCode/UserInterface/RiuSummaryPlot.cpp @@ -0,0 +1,217 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2019- 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 "RiuSummaryPlot.h" + +#include "Commands/CorrelationPlotCommands/RicNewCorrelationPlotFeature.h" + +#include "RimEnsembleCurveSet.h" +#include "RimPlot.h" +#include "RimSummaryCurve.h" +#include "RimSummaryPlot.h" + +#include "RiuPlotCurve.h" +#include "RiuPlotWidget.h" + +#include "cafCmdFeatureMenuBuilder.h" + +#include +#include + +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuSummaryPlot::RiuSummaryPlot( RimSummaryPlot* plot ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuSummaryPlot::~RiuSummaryPlot() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuSummaryPlot::showContextMenu( QPoint pos ) +{ + if ( !plotWidget() ) return; + + QMenu menu; + caf::CmdFeatureMenuBuilder menuBuilder; + + menuBuilder << "RicShowPlotDataFeature"; + + double distanceFromClick = std::numeric_limits::infinity(); + + auto [plotCurve, closestCurvePoint] = plotWidget()->findClosestCurve( pos, distanceFromClick ); + + if ( plotCurve && closestCurvePoint >= 0 ) + { + auto* summaryCurve = dynamic_cast( plotCurve->ownerRimCurve() ); + if ( summaryCurve && closestCurvePoint < (int)summaryCurve->timeStepsY().size() ) + { + std::time_t timeStep = summaryCurve->timeStepsY()[closestCurvePoint]; + + RimSummaryCaseCollection* ensemble = nullptr; + QString clickedQuantityName; + QStringList allQuantityNamesInPlot; + + RimEnsembleCurveSet* clickedEnsembleCurveSet = nullptr; + summaryCurve->firstAncestorOrThisOfType( clickedEnsembleCurveSet ); + + bool curveClicked = distanceFromClick < 50; + + if ( clickedEnsembleCurveSet ) + { + ensemble = clickedEnsembleCurveSet->summaryCaseCollection(); + if ( ensemble && ensemble->isEnsemble() ) + { + clickedQuantityName = QString::fromStdString( clickedEnsembleCurveSet->summaryAddress().uiText() ); + + if ( curveClicked ) + { + QVariant curveVariant( QVariant::fromValue( static_cast( summaryCurve ) ) ); + menuBuilder.addCmdFeatureWithUserData( "RicNewSummaryPlotFromCurveFeature", + "Create New Plot from Curve", + curveVariant ); + } + } + } + + { + auto summaryCase = summaryCurve->summaryCaseY(); + if ( summaryCase ) + { + int summaryCaseId = summaryCase->caseId(); + QVariant summaryCaseIdVariant( summaryCaseId ); + auto modelName = summaryCase->nativeCaseName(); + + menuBuilder.addCmdFeatureWithUserData( "RicImportGridModelFromSummaryCurveFeature", + QString( "Open Grid Model '%1'" ).arg( modelName ), + summaryCaseIdVariant ); + } + } + + if ( !curveClicked ) + { + auto* summaryPlot = static_cast( plotWidget()->plotDefinition() ); + std::vector allCurveSetsInPlot; + summaryPlot->descendantsOfType( allCurveSetsInPlot ); + for ( auto curveSet : allCurveSetsInPlot ) + { + allQuantityNamesInPlot.push_back( QString::fromStdString( curveSet->summaryAddress().uiText() ) ); + } + } + else + { + allQuantityNamesInPlot.push_back( clickedQuantityName ); + } + + if ( !clickedQuantityName.isEmpty() || !allQuantityNamesInPlot.isEmpty() ) + { + if ( ensemble && ensemble->isEnsemble() ) + { + EnsemblePlotParams params( ensemble, allQuantityNamesInPlot, clickedQuantityName, timeStep ); + QVariant variant = QVariant::fromValue( params ); + + menuBuilder.addCmdFeatureWithUserData( "RicNewAnalysisPlotFeature", "New Analysis Plot", variant ); + + QString subMenuName = "Create Correlation Plot"; + if ( curveClicked ) + { + subMenuName = "Create Correlation Plot From Curve Point"; + } + menuBuilder.subMenuStart( subMenuName, *caf::IconProvider( ":/CorrelationPlots16x16.png" ).icon() ); + + { + if ( curveClicked ) + { + menuBuilder.addCmdFeatureWithUserData( "RicNewCorrelationPlotFeature", + "New Tornado Plot", + variant ); + } + menuBuilder.addCmdFeatureWithUserData( "RicNewCorrelationMatrixPlotFeature", + "New Matrix Plot", + variant ); + menuBuilder.addCmdFeatureWithUserData( "RicNewCorrelationReportPlotFeature", + "New Report Plot", + variant ); + if ( curveClicked ) + { + menuBuilder.subMenuStart( "Cross Plots", + *caf::IconProvider( ":/CorrelationCrossPlot16x16.png" ).icon() ); + std::vector> ensembleParameters = + ensemble->parameterCorrelations( clickedEnsembleCurveSet->summaryAddress(), timeStep ); + std::sort( ensembleParameters.begin(), + ensembleParameters.end(), + []( const std::pair& lhs, + const std::pair& rhs ) { + return std::fabs( lhs.second ) > std::fabs( rhs.second ); + } ); + + for ( const auto& param : ensembleParameters ) + { + if ( std::fabs( param.second ) >= 1.0e-6 ) + { + params.ensembleParameter = param.first.name; + variant = QVariant::fromValue( params ); + menuBuilder.addCmdFeatureWithUserData( "RicNewParameterResultCrossPlotFeature", + QString( "New Cross Plot Against %1 " + "(Correlation: %2)" ) + .arg( param.first.name ) + .arg( param.second, 5, 'f', 2 ), + variant ); + } + } + menuBuilder.subMenuEnd(); + } + } + menuBuilder.subMenuEnd(); + } + } + } + } + + menuBuilder.addSeparator(); + + RimSummaryPlot* plot = dynamic_cast( plotWidget()->plotDefinition() ); + if ( plot ) + { + QVariant plotVariant( QVariant::fromValue( static_cast( plot ) ) ); + menuBuilder.addCmdFeatureWithUserData( "RicSplitMultiPlotFeature", "Split into Multiple Plots", plotVariant ); + menuBuilder.addCmdFeatureWithUserData( "RicDeleteSubPlotFeature", "Delete Plot", plotVariant ); + } + + menuBuilder.appendToMenu( &menu ); + + if ( !menu.actions().empty() ) + { + menu.exec( plotWidget()->mapToGlobal( pos ) ); + + // Parts of progress dialog GUI can be present after menu has closed related to + // RicImportGridModelFromSummaryCurveFeature. Make sure the plot is updated, and call processEvents() to make + // sure all GUI events are processed + // plotWidget()->update(); + QApplication::processEvents(); + } +} diff --git a/ApplicationLibCode/UserInterface/RiuSummaryPlot.h b/ApplicationLibCode/UserInterface/RiuSummaryPlot.h new file mode 100644 index 0000000000..87fd5cca17 --- /dev/null +++ b/ApplicationLibCode/UserInterface/RiuSummaryPlot.h @@ -0,0 +1,56 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2019- 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 "RiaDateTimeDefines.h" + +#include +#include + +class RimSummaryPlot; +class RimPlotAxisPropertiesInterface; +class RiuPlotWidget; + +//================================================================================================== +// +// +// +//================================================================================================== +class RiuSummaryPlot : public QObject +{ + Q_OBJECT +public: + RiuSummaryPlot( RimSummaryPlot* plot ); + ~RiuSummaryPlot() override; + + virtual void useDateBasedTimeAxis( + const QString& dateFormat, + const QString& timeFormat, + RiaDefines::DateFormatComponents dateComponents = RiaDefines::DateFormatComponents::DATE_FORMAT_UNSPECIFIED, + RiaDefines::TimeFormatComponents timeComponents = RiaDefines::TimeFormatComponents::TIME_FORMAT_UNSPECIFIED ) = 0; + + virtual void useTimeBasedTimeAxis() = 0; + + virtual void updateAnnotationObjects( RimPlotAxisPropertiesInterface* axisProperties ) = 0; + + virtual RiuPlotWidget* plotWidget() const = 0; + +public slots: + void showContextMenu( QPoint ); +}; diff --git a/ApplicationLibCode/UserInterface/RiuSummaryQtChartsPlot.cpp b/ApplicationLibCode/UserInterface/RiuSummaryQtChartsPlot.cpp new file mode 100644 index 0000000000..ec7a8936c5 --- /dev/null +++ b/ApplicationLibCode/UserInterface/RiuSummaryQtChartsPlot.cpp @@ -0,0 +1,100 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2019- 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 "RiuSummaryQtChartsPlot.h" + +#include "RiaPreferences.h" + +#include "RimEnsembleCurveInfoTextProvider.h" +#include "RimSummaryPlot.h" + +#include "RiuPlotCurve.h" +#include "RiuPlotWidget.h" +#include "RiuQtChartsPlotTools.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuSummaryQtChartsPlot::RiuSummaryQtChartsPlot( RimSummaryPlot* plot, QWidget* parent ) + : RiuSummaryPlot( plot ) +{ + m_plotWidget = new RiuQtChartsPlotWidget( plot, parent, new RimEnsembleCurveInfoTextProvider ); + m_plotWidget->setContextMenuPolicy( Qt::CustomContextMenu ); + connect( m_plotWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( showContextMenu( QPoint ) ) ); + + setDefaults(); + + RiuQtChartsPlotTools::setCommonPlotBehaviour( m_plotWidget ); + RiuQtChartsPlotTools::setDefaultAxes( m_plotWidget ); + + m_plotWidget->setInternalLegendVisible( true ); +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuSummaryQtChartsPlot::~RiuSummaryQtChartsPlot() +{ + delete m_plotWidget; + m_plotWidget = nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuSummaryQtChartsPlot::useDateBasedTimeAxis( const QString& dateFormat, + const QString& timeFormat, + RiaDefines::DateFormatComponents dateComponents, + RiaDefines::TimeFormatComponents timeComponents ) +{ + m_plotWidget->setAxisScaleType( RiuPlotAxis::defaultBottom(), RiuPlotWidget::AxisScaleType::DATE ); + m_plotWidget->setFormatStrings( dateFormat, timeFormat, dateComponents, timeComponents ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuSummaryQtChartsPlot::useTimeBasedTimeAxis() +{ + m_plotWidget->setAxisScaleType( RiuPlotAxis::defaultBottom(), RiuPlotWidget::AxisScaleType::DATE ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuSummaryQtChartsPlot::updateAnnotationObjects( RimPlotAxisPropertiesInterface* axisProperties ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuSummaryQtChartsPlot::setDefaults() +{ + QString dateFormat = RiaPreferences::current()->dateFormat(); + QString timeFormat = RiaPreferences::current()->timeFormat(); + + useDateBasedTimeAxis( dateFormat, timeFormat ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuPlotWidget* RiuSummaryQtChartsPlot::plotWidget() const +{ + return m_plotWidget; +} diff --git a/ApplicationLibCode/UserInterface/RiuSummaryQtChartsPlot.h b/ApplicationLibCode/UserInterface/RiuSummaryQtChartsPlot.h new file mode 100644 index 0000000000..26cbf33154 --- /dev/null +++ b/ApplicationLibCode/UserInterface/RiuSummaryQtChartsPlot.h @@ -0,0 +1,62 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2019- 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 "RiaDateTimeDefines.h" + +#include "RiuQtChartsPlotWidget.h" +#include "RiuSummaryPlot.h" + +#include + +class QWidget; +class RimSummaryPlot; +class RimPlotAxisPropertiesInterface; + +//================================================================================================== +// +// +// +//================================================================================================== +class RiuSummaryQtChartsPlot : public RiuSummaryPlot +{ + Q_OBJECT; + +public: + RiuSummaryQtChartsPlot( RimSummaryPlot* plot, QWidget* parent ); + ~RiuSummaryQtChartsPlot() override; + + void useDateBasedTimeAxis( + const QString& dateFormat, + const QString& timeFormat, + RiaDefines::DateFormatComponents dateComponents = RiaDefines::DateFormatComponents::DATE_FORMAT_UNSPECIFIED, + RiaDefines::TimeFormatComponents timeComponents = RiaDefines::TimeFormatComponents::TIME_FORMAT_UNSPECIFIED ) override; + + void useTimeBasedTimeAxis() override; + + void updateAnnotationObjects( RimPlotAxisPropertiesInterface* axisProperties ) override; + + RiuPlotWidget* plotWidget() const override; + +protected: + void setDefaults(); + +private: + QPointer m_plotWidget; +}; diff --git a/ApplicationLibCode/UserInterface/RiuSummaryQuantityNameInfoProvider.cpp b/ApplicationLibCode/UserInterface/RiuSummaryQuantityNameInfoProvider.cpp index 968efe5a72..c7c779dd9c 100644 --- a/ApplicationLibCode/UserInterface/RiuSummaryQuantityNameInfoProvider.cpp +++ b/ApplicationLibCode/UserInterface/RiuSummaryQuantityNameInfoProvider.cpp @@ -18,8 +18,37 @@ #include "RiuSummaryQuantityNameInfoProvider.h" +#include #include +// The region_to_region helper functions are taken from +// https://github.com/OPM/opm-common/blob/e1e0edba7da2d3b30f1f009511a62be073c27eb0/src/opm/input/eclipse/EclipseState/SummaryConfig/SummaryConfig.cpp#L317-L342 + +namespace ParseHelpers +{ +bool is_supported_region_to_region( const std::string& keyword ) +{ + static const auto supported_kw = std::regex{ R"~~(R[OGW]F[RT][-+GL_]?([A-Z0-9_]{3})?)~~" }; + + // R[OGW]F[RT][-+GL]? (e.g., "ROFTG", "RGFR+", or "RWFT") + return std::regex_match( keyword, supported_kw ); +} + +bool is_unsupported_region_to_region( const std::string& keyword ) +{ + static const auto unsupported_kw = std::regex{ R"~~(R([EK]|NL)F[RT][-+_]?([A-Z0-9_]{3})?)~~" }; + + // R[EK]F[RT][-+]? (e.g., "REFT" or "RKFR+") + // RNLF[RT][-+]? (e.g., "RNLFR-" or "RNLFT") + return std::regex_match( keyword, unsupported_kw ); +} + +bool is_region_to_region( const std::string& keyword ) +{ + return is_supported_region_to_region( keyword ) || is_unsupported_region_to_region( keyword ); +} +} // namespace ParseHelpers + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -33,9 +62,66 @@ RiuSummaryQuantityNameInfoProvider* RiuSummaryQuantityNameInfoProvider::instance /// //-------------------------------------------------------------------------------------------------- RifEclipseSummaryAddress::SummaryVarCategory - RiuSummaryQuantityNameInfoProvider::categoryFromQuantityName( const std::string& quantity ) const + RiuSummaryQuantityNameInfoProvider::identifyCategory( const std::string& vectorName ) +{ + // Try to an exact match on the vector name first in the vector table. + bool exactMatch = true; + auto exactCategory = categoryFromVectorName( vectorName, exactMatch ); + if ( exactCategory != RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_INVALID ) return exactCategory; + + if ( vectorName.size() < 3 || vectorName.size() > 8 ) + return RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_INVALID; + + // Try to match the base vector name with more heuristics + auto strippedQuantityName = RifEclipseSummaryAddress::baseVectorName( vectorName ); + + // First, try to lookup vector in vector table + auto category = categoryFromVectorName( strippedQuantityName ); + if ( category != RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_INVALID ) return category; + + switch ( strippedQuantityName[0] ) + { + case 'A': + return RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_AQUIFER; + case 'B': + return RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_BLOCK; + case 'F': + return RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_FIELD; + case 'N': + return RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_NETWORK; + case 'S': + return RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL_SEGMENT; + case 'W': + return RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL; + default: + break; + } + + if ( strippedQuantityName[0] == 'R' ) + { + if ( ParseHelpers::is_region_to_region( strippedQuantityName ) ) + return RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_REGION_2_REGION; + + return RifEclipseSummaryAddress::SUMMARY_REGION; + } + + // Then check LGR categories + std::string firstTwoLetters = strippedQuantityName.substr( 0, 2 ); + + if ( firstTwoLetters == "LB" ) return RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_BLOCK_LGR; + if ( firstTwoLetters == "LC" ) return RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL_COMPLETION_LGR; + if ( firstTwoLetters == "LW" ) return RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL_LGR; + + return RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_INVALID; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifEclipseSummaryAddress::SummaryVarCategory + RiuSummaryQuantityNameInfoProvider::categoryFromVectorName( const std::string& vectorName, bool exactMatch ) const { - auto info = quantityInfo( quantity ); + auto info = quantityInfo( vectorName, exactMatch ); return info.category; } @@ -44,16 +130,18 @@ RifEclipseSummaryAddress::SummaryVarCategory /// //-------------------------------------------------------------------------------------------------- RiuSummaryQuantityNameInfoProvider::RiuSummaryQuantityInfo - RiuSummaryQuantityNameInfoProvider::quantityInfo( const std::string& quantity ) const + RiuSummaryQuantityNameInfoProvider::quantityInfo( const std::string& vectorName, bool exactMatch ) const { - auto it = m_summaryToDescMap.find( quantity ); - + auto it = m_summaryToDescMap.find( vectorName ); if ( it != m_summaryToDescMap.end() ) { return it->second; } - if ( quantity.size() > 1 && quantity[1] == 'U' ) + // Stop searching if not found in lookup table and exact match was requested. + if ( exactMatch ) return RiuSummaryQuantityInfo(); + + if ( vectorName.size() > 1 && vectorName[1] == 'U' ) { // User defined vector name // The summary type is given by the first letter, and U defines user-defined @@ -63,18 +151,26 @@ RiuSummaryQuantityNameInfoProvider::RiuSummaryQuantityInfo return RiuSummaryQuantityInfo(); } - if ( quantity.size() > 5 ) + + if ( vectorName.size() > 5 ) { // Check for custom vector naming - std::string baseName = quantity.substr( 0, 5 ); + std::string postfix = vectorName.substr( vectorName.size() - 5, 5 ); + std::string baseName = vectorName.substr( 0, 5 ); while ( baseName.back() == '_' ) baseName.pop_back(); + bool isDifference = ( postfix == "_DIFF" ); + it = m_summaryToDescMap.find( baseName ); if ( it != m_summaryToDescMap.end() ) { + if ( isDifference ) + { + return RiuSummaryQuantityInfo( it->second.category, it->second.longName + " Difference" ); + } return it->second; } } @@ -85,8 +181,8 @@ RiuSummaryQuantityNameInfoProvider::RiuSummaryQuantityInfo //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::string RiuSummaryQuantityNameInfoProvider::longNameFromQuantityName( const std::string& vectorName, - bool returnVectorNameIfNotFound ) const +std::string RiuSummaryQuantityNameInfoProvider::longNameFromVectorName( const std::string& vectorName, + bool returnVectorNameIfNotFound ) const { auto info = quantityInfo( vectorName ); return info.category != RifEclipseSummaryAddress::SUMMARY_INVALID || !returnVectorNameIfNotFound ? info.longName @@ -583,329 +679,323 @@ std::unordered_map createInfoForEclipseKeywords(); static std::unordered_map createInfoFor6xKeywords(); diff --git a/ApplicationLibCode/UserInterface/RiuSummaryQwtPlot.cpp b/ApplicationLibCode/UserInterface/RiuSummaryQwtPlot.cpp index 2036c1f7ac..deee087cc4 100644 --- a/ApplicationLibCode/UserInterface/RiuSummaryQwtPlot.cpp +++ b/ApplicationLibCode/UserInterface/RiuSummaryQwtPlot.cpp @@ -23,26 +23,19 @@ #include "Commands/CorrelationPlotCommands/RicNewCorrelationPlotFeature.h" -#include "RimEnsembleCurveSet.h" -#include "RimEnsembleCurveSetCollection.h" -#include "RimEnsembleStatisticsCase.h" -#include "RimMainPlotCollection.h" -#include "RimPlot.h" +#include "RimEnsembleCurveInfoTextProvider.h" #include "RimPlotAxisAnnotation.h" #include "RimPlotAxisProperties.h" #include "RimPlotAxisPropertiesInterface.h" -#include "RimRegularLegendConfig.h" #include "RimSummaryCase.h" -#include "RimSummaryCaseCollection.h" #include "RimSummaryCurve.h" -#include "RimSummaryCurveCollection.h" #include "RimSummaryPlot.h" -#include "RimSummaryPlotCollection.h" #include "RiuPlotAnnotationTool.h" +#include "RiuPlotCurve.h" #include "RiuQwtCurvePointTracker.h" #include "RiuQwtPlotWheelZoomer.h" -#include "RiuRimQwtPlotCurve.h" +#include "RiuQwtPlotWidget.h" #include "RiuWidgetDragger.h" #include "RiuPlotMainWindowTools.h" @@ -51,8 +44,6 @@ #include "RiuQwtPlotZoomer.h" #include "RiuQwtScalePicker.h" -#include "RimProject.h" - #include "cafCmdFeatureMenuBuilder.h" #include "cafIconProvider.h" #include "cafSelectionManager.h" @@ -77,51 +68,34 @@ #include -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -class EnsembleCurveInfoTextProvider : public IPlotCurveInfoTextProvider -{ -public: - //-------------------------------------------------------------------------------------------------- - /// - //-------------------------------------------------------------------------------------------------- - QString curveInfoText( QwtPlotCurve* curve ) override - { - RiuRimQwtPlotCurve* riuCurve = dynamic_cast( curve ); - RimSummaryCurve* sumCurve = nullptr; - if ( riuCurve ) - { - sumCurve = dynamic_cast( riuCurve->ownerRimCurve() ); - } - - return sumCurve && sumCurve->summaryCaseY() ? sumCurve->summaryCaseY()->displayCaseName() : ""; - } -}; -static EnsembleCurveInfoTextProvider ensembleCurveInfoTextProvider; +static RimEnsembleCurveInfoTextProvider ensembleCurveInfoTextProvider; //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RiuSummaryQwtPlot::RiuSummaryQwtPlot( RimSummaryPlot* plot, QWidget* parent /*= nullptr*/ ) - : RiuQwtPlotWidget( plot, parent ) + : RiuSummaryPlot( plot ) { + m_plotWidget = new RiuQwtPlotWidget( plot, parent ); + m_plotWidget->setContextMenuPolicy( Qt::CustomContextMenu ); + connect( m_plotWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( showContextMenu( QPoint ) ) ); + // LeftButton for the zooming - m_zoomerLeft = new RiuQwtPlotZoomer( canvas() ); + m_zoomerLeft = new RiuQwtPlotZoomer( m_plotWidget->qwtPlot()->canvas() ); m_zoomerLeft->setTrackerMode( QwtPicker::AlwaysOff ); m_zoomerLeft->initMousePattern( 1 ); // Attach a zoomer for the right axis - m_zoomerRight = new RiuQwtPlotZoomer( canvas() ); - m_zoomerRight->setAxis( xTop, yRight ); + m_zoomerRight = new RiuQwtPlotZoomer( m_plotWidget->qwtPlot()->canvas() ); + m_zoomerRight->setAxes( QwtAxis::XTop, QwtAxis::YRight ); m_zoomerRight->setTrackerMode( QwtPicker::AlwaysOff ); m_zoomerRight->initMousePattern( 1 ); // MidButton for the panning - QwtPlotPanner* panner = new QwtPlotPanner( canvas() ); - panner->setMouseButton( Qt::MidButton ); + QwtPlotPanner* panner = new QwtPlotPanner( m_plotWidget->qwtPlot()->canvas() ); + panner->setMouseButton( Qt::MiddleButton ); - m_wheelZoomer = new RiuQwtPlotWheelZoomer( this ); + m_wheelZoomer = new RiuQwtPlotWheelZoomer( m_plotWidget->qwtPlot() ); connect( m_wheelZoomer, SIGNAL( zoomUpdated() ), SLOT( onZoomedSlot() ) ); connect( m_zoomerLeft, SIGNAL( zoomed( const QRectF& ) ), SLOT( onZoomedSlot() ) ); @@ -129,12 +103,14 @@ RiuSummaryQwtPlot::RiuSummaryQwtPlot( RimSummaryPlot* plot, QWidget* parent /*= connect( panner, SIGNAL( panned( int, int ) ), SLOT( onZoomedSlot() ) ); setDefaults(); - new RiuQwtCurvePointTracker( this, true, &ensembleCurveInfoTextProvider ); + new RiuQwtCurvePointTracker( m_plotWidget->qwtPlot(), true, &ensembleCurveInfoTextProvider ); - RiuQwtPlotTools::setCommonPlotBehaviour( this ); - RiuQwtPlotTools::setDefaultAxes( this ); + RiuQwtPlotTools::setCommonPlotBehaviour( m_plotWidget->qwtPlot() ); + RiuQwtPlotTools::setDefaultAxes( m_plotWidget->qwtPlot() ); - setInternalLegendVisible( true ); + // PERFORMANCE NOTE + // Do not set internal legends visible, as this will cause a performance hit. + m_plotWidget->setInternalLegendVisible( false ); m_annotationTool = std::unique_ptr( new RiuPlotAnnotationTool() ); } @@ -144,17 +120,19 @@ RiuSummaryQwtPlot::RiuSummaryQwtPlot( RimSummaryPlot* plot, QWidget* parent /*= //-------------------------------------------------------------------------------------------------- RiuSummaryQwtPlot::~RiuSummaryQwtPlot() { + delete m_plotWidget; + m_plotWidget = nullptr; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuSummaryQwtPlot::useDateBasedTimeAxis( const QString& dateFormat, - const QString& timeFormat, - RiaQDateTimeTools::DateFormatComponents dateComponents, - RiaQDateTimeTools::TimeFormatComponents timeComponents ) +void RiuSummaryQwtPlot::useDateBasedTimeAxis( const QString& dateFormat, + const QString& timeFormat, + RiaDefines::DateFormatComponents dateComponents, + RiaDefines::TimeFormatComponents timeComponents ) { - RiuQwtPlotTools::enableDateBasedBottomXAxis( this, dateFormat, timeFormat, dateComponents, timeComponents ); + RiuQwtPlotTools::enableDateBasedBottomXAxis( m_plotWidget->qwtPlot(), dateFormat, timeFormat, dateComponents, timeComponents ); } //-------------------------------------------------------------------------------------------------- @@ -162,16 +140,8 @@ void RiuSummaryQwtPlot::useDateBasedTimeAxis( const QString& //-------------------------------------------------------------------------------------------------- void RiuSummaryQwtPlot::useTimeBasedTimeAxis() { - setAxisScaleEngine( QwtPlot::xBottom, new QwtLinearScaleEngine() ); - setAxisScaleDraw( QwtPlot::xBottom, new QwtScaleDraw() ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuSummaryQwtPlot::setAxisIsLogarithmic( QwtPlot::Axis axis, bool logarithmic ) -{ - if ( m_wheelZoomer ) m_wheelZoomer->setAxisIsLogarithmic( axis, logarithmic ); + m_plotWidget->qwtPlot()->setAxisScaleEngine( QwtAxis::XBottom, new QwtLinearScaleEngine() ); + m_plotWidget->qwtPlot()->setAxisScaleDraw( QwtAxis::XBottom, new QwtScaleDraw() ); } //-------------------------------------------------------------------------------------------------- @@ -180,7 +150,7 @@ void RiuSummaryQwtPlot::setAxisIsLogarithmic( QwtPlot::Axis axis, bool logarithm void RiuSummaryQwtPlot::updateAnnotationObjects( RimPlotAxisPropertiesInterface* axisProperties ) { RiuPlotAnnotationTool::Orientation orientation = RiuPlotAnnotationTool::Orientation::HORIZONTAL; - if ( axisProperties->plotAxisType() == RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM ) + if ( axisProperties->plotAxisType().axis() == RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM ) { orientation = RiuPlotAnnotationTool::Orientation::VERTICAL; } @@ -190,7 +160,7 @@ void RiuSummaryQwtPlot::updateAnnotationObjects( RimPlotAxisPropertiesInterface* { if ( annotation->annotationType() == RimPlotAxisAnnotation::AnnotationType::LINE ) { - m_annotationTool->attachAnnotationLine( this, + m_annotationTool->attachAnnotationLine( m_plotWidget->qwtPlot(), annotation->color(), annotation->name(), annotation->value(), @@ -198,7 +168,7 @@ void RiuSummaryQwtPlot::updateAnnotationObjects( RimPlotAxisPropertiesInterface* } else if ( annotation->annotationType() == RimPlotAxisAnnotation::AnnotationType::RANGE ) { - m_annotationTool->attachAnnotationRange( this, + m_annotationTool->attachAnnotationRange( m_plotWidget->qwtPlot(), annotation->color(), annotation->name(), annotation->rangeStart(), @@ -208,163 +178,6 @@ void RiuSummaryQwtPlot::updateAnnotationObjects( RimPlotAxisPropertiesInterface* } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuSummaryQwtPlot::contextMenuEvent( QContextMenuEvent* event ) -{ - QMenu menu; - caf::CmdFeatureMenuBuilder menuBuilder; - - emit plotSelected( false ); - - menuBuilder << "RicShowPlotDataFeature"; - menuBuilder << "RicSavePlotTemplateFeature"; - - QwtPlotItem* closestItem = nullptr; - double distanceFromClick = std::numeric_limits::infinity(); - int closestCurvePoint = -1; - QPoint globalPos = event->globalPos(); - QPoint localPos = this->canvas()->mapFromGlobal( globalPos ); - - findClosestPlotItem( localPos, &closestItem, &closestCurvePoint, &distanceFromClick ); - if ( closestItem && closestCurvePoint >= 0 ) - { - RiuRimQwtPlotCurve* plotCurve = dynamic_cast( closestItem ); - if ( plotCurve ) - { - RimSummaryCurve* summaryCurve = dynamic_cast( plotCurve->ownerRimCurve() ); - if ( summaryCurve && closestCurvePoint < (int)summaryCurve->timeStepsY().size() ) - { - std::time_t timeStep = summaryCurve->timeStepsY()[closestCurvePoint]; - - RimSummaryCaseCollection* ensemble = nullptr; - QString clickedQuantityName; - QStringList allQuantityNamesInPlot; - - RimEnsembleCurveSet* clickedEnsembleCurveSet = nullptr; - summaryCurve->firstAncestorOrThisOfType( clickedEnsembleCurveSet ); - - bool curveClicked = distanceFromClick < 50; - - if ( clickedEnsembleCurveSet ) - { - ensemble = clickedEnsembleCurveSet->summaryCaseCollection(); - if ( ensemble && ensemble->isEnsemble() ) - { - clickedQuantityName = QString::fromStdString( clickedEnsembleCurveSet->summaryAddress().uiText() ); - } - } - - { - auto summaryCase = summaryCurve->summaryCaseY(); - if ( summaryCase ) - { - int summaryCaseId = summaryCase->caseId(); - QVariant summaryCaseIdVariant( summaryCaseId ); - auto modelName = summaryCase->nativeCaseName(); - - menuBuilder.addCmdFeatureWithUserData( "RicImportGridModelFromSummaryCurveFeature", - QString( "Open Grid Model '%1'" ).arg( modelName ), - summaryCaseIdVariant ); - } - } - - if ( !curveClicked ) - { - RimSummaryPlot* summaryPlot = static_cast( plotDefinition() ); - std::vector allCurveSetsInPlot; - summaryPlot->descendantsOfType( allCurveSetsInPlot ); - for ( auto curveSet : allCurveSetsInPlot ) - { - allQuantityNamesInPlot.push_back( QString::fromStdString( curveSet->summaryAddress().uiText() ) ); - } - } - else - { - allQuantityNamesInPlot.push_back( clickedQuantityName ); - } - - if ( !clickedQuantityName.isEmpty() || !allQuantityNamesInPlot.isEmpty() ) - { - if ( ensemble && ensemble->isEnsemble() ) - { - EnsemblePlotParams params( ensemble, allQuantityNamesInPlot, clickedQuantityName, timeStep ); - QVariant variant = QVariant::fromValue( params ); - - menuBuilder.addCmdFeatureWithUserData( "RicNewAnalysisPlotFeature", "New Analysis Plot", variant ); - - QString subMenuName = "Create Correlation Plot"; - if ( curveClicked ) - { - subMenuName = "Create Correlation Plot From Curve Point"; - } - menuBuilder.subMenuStart( subMenuName, *caf::IconProvider( ":/CorrelationPlots16x16.png" ).icon() ); - - { - if ( curveClicked ) - { - menuBuilder.addCmdFeatureWithUserData( "RicNewCorrelationPlotFeature", - "New Tornado Plot", - variant ); - } - menuBuilder.addCmdFeatureWithUserData( "RicNewCorrelationMatrixPlotFeature", - "New Matrix Plot", - variant ); - menuBuilder.addCmdFeatureWithUserData( "RicNewCorrelationReportPlotFeature", - "New Report Plot", - variant ); - if ( curveClicked ) - { - menuBuilder.subMenuStart( "Cross Plots", - *caf::IconProvider( ":/CorrelationCrossPlot16x16.png" ).icon() ); - std::vector> ensembleParameters = - ensemble->parameterCorrelations( clickedEnsembleCurveSet->summaryAddress(), timeStep ); - std::sort( ensembleParameters.begin(), - ensembleParameters.end(), - []( const std::pair& lhs, - const std::pair& rhs ) { - return std::fabs( lhs.second ) > std::fabs( rhs.second ); - } ); - - for ( const auto& param : ensembleParameters ) - { - if ( std::fabs( param.second ) >= 1.0e-6 ) - { - params.ensembleParameter = param.first.name; - variant = QVariant::fromValue( params ); - menuBuilder.addCmdFeatureWithUserData( "RicNewParameterResultCrossPlotFeature", - QString( "New Cross Plot Against %1 " - "(Correlation: %2)" ) - .arg( param.first.name ) - .arg( param.second, 5, 'f', 2 ), - variant ); - } - } - menuBuilder.subMenuEnd(); - } - } - menuBuilder.subMenuEnd(); - } - } - } - } - } - - menuBuilder.appendToMenu( &menu ); - - if ( menu.actions().size() > 0 ) - { - menu.exec( event->globalPos() ); - - // Parts of progress dialog GUI can be present after menu has closed related to - // RicImportGridModelFromSummaryCurveFeature. Make sure the plot is updated, and call processEvents() to make - // sure all GUI events are processed - update(); - QApplication::processEvents(); - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -398,5 +211,13 @@ void RiuSummaryQwtPlot::endZoomOperations() //-------------------------------------------------------------------------------------------------- void RiuSummaryQwtPlot::onZoomedSlot() { - emit plotZoomed(); + emit m_plotWidget->plotZoomed(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuPlotWidget* RiuSummaryQwtPlot::plotWidget() const +{ + return m_plotWidget; } diff --git a/ApplicationLibCode/UserInterface/RiuSummaryQwtPlot.h b/ApplicationLibCode/UserInterface/RiuSummaryQwtPlot.h index 8c76a8adff..a5ff1f4ad7 100644 --- a/ApplicationLibCode/UserInterface/RiuSummaryQwtPlot.h +++ b/ApplicationLibCode/UserInterface/RiuSummaryQwtPlot.h @@ -18,11 +18,11 @@ #pragma once -#include "RiaQDateTimeTools.h" +#include "RiaDateTimeDefines.h" + #include "RiuInterfaceToViewWindow.h" #include "RiuQwtPlotWidget.h" - -#include "cafPdmPointer.h" +#include "RiuSummaryPlot.h" #include @@ -39,7 +39,7 @@ class RiuPlotAnnotationTool; // // //================================================================================================== -class RiuSummaryQwtPlot : public RiuQwtPlotWidget +class RiuSummaryQwtPlot : public RiuSummaryPlot { Q_OBJECT; @@ -47,28 +47,29 @@ class RiuSummaryQwtPlot : public RiuQwtPlotWidget RiuSummaryQwtPlot( RimSummaryPlot* plot, QWidget* parent = nullptr ); ~RiuSummaryQwtPlot() override; - void useDateBasedTimeAxis( const QString& dateFormat, - const QString& timeFormat, - RiaQDateTimeTools::DateFormatComponents dateComponents = RiaQDateTimeTools::DATE_FORMAT_UNSPECIFIED, - RiaQDateTimeTools::TimeFormatComponents timeComponents = - RiaQDateTimeTools::TimeFormatComponents::TIME_FORMAT_UNSPECIFIED ); + void useDateBasedTimeAxis( + const QString& dateFormat, + const QString& timeFormat, + RiaDefines::DateFormatComponents dateComponents = RiaDefines::DateFormatComponents::DATE_FORMAT_UNSPECIFIED, + RiaDefines::TimeFormatComponents timeComponents = RiaDefines::TimeFormatComponents::TIME_FORMAT_UNSPECIFIED ) override; + + void useTimeBasedTimeAxis() override; - void useTimeBasedTimeAxis(); - void setAxisIsLogarithmic( QwtPlot::Axis axis, bool logarithmic ); + void updateAnnotationObjects( RimPlotAxisPropertiesInterface* axisProperties ) override; - void updateAnnotationObjects( RimPlotAxisPropertiesInterface* axisProperties ); + RiuPlotWidget* plotWidget() const override; protected: - void contextMenuEvent( QContextMenuEvent* ) override; void setDefaults(); - bool isZoomerActive() const override; - void endZoomOperations() override; + bool isZoomerActive() const; + void endZoomOperations(); private slots: void onZoomedSlot(); private: std::unique_ptr m_annotationTool; + QPointer m_plotWidget; QPointer m_zoomerLeft; QPointer m_zoomerRight; diff --git a/ApplicationLibCode/UserInterface/RiuSummaryVectorSelectionUi.cpp b/ApplicationLibCode/UserInterface/RiuSummaryVectorSelectionUi.cpp index 3c570386bf..32b2e8686a 100644 --- a/ApplicationLibCode/UserInterface/RiuSummaryVectorSelectionUi.cpp +++ b/ApplicationLibCode/UserInterface/RiuSummaryVectorSelectionUi.cpp @@ -71,7 +71,7 @@ class SummaryIdentifierAndField { } - virtual ~SummaryIdentifierAndField() { delete m_pdmField; } + virtual ~SummaryIdentifierAndField(); RifEclipseSummaryAddress::SummaryIdentifierType summaryIdentifier() const { return m_summaryIdentifier; } caf::PdmField>* pdmField() { return m_pdmField; } @@ -81,6 +81,14 @@ class SummaryIdentifierAndField caf::PdmField>* m_pdmField; }; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +SummaryIdentifierAndField::~SummaryIdentifierAndField() +{ + delete m_pdmField; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -101,8 +109,8 @@ RiuSummaryVectorSelectionUi::RiuSummaryVectorSelectionUi() { RifEclipseSummaryAddress::SUMMARY_REGION_2_REGION, { { new SummaryIdentifierAndField( RifEclipseSummaryAddress::INPUT_REGION_2_REGION ) }, { new SummaryIdentifierAndField( RifEclipseSummaryAddress::INPUT_VECTOR_NAME ) } } }, - { RifEclipseSummaryAddress::SUMMARY_WELL_GROUP, - { { new SummaryIdentifierAndField( RifEclipseSummaryAddress::INPUT_WELL_GROUP_NAME ) }, + { RifEclipseSummaryAddress::SUMMARY_GROUP, + { { new SummaryIdentifierAndField( RifEclipseSummaryAddress::INPUT_GROUP_NAME ) }, { new SummaryIdentifierAndField( RifEclipseSummaryAddress::INPUT_VECTOR_NAME ) } } }, { RifEclipseSummaryAddress::SUMMARY_WELL, { { new SummaryIdentifierAndField( RifEclipseSummaryAddress::INPUT_WELL_NAME ) }, @@ -136,227 +144,128 @@ RiuSummaryVectorSelectionUi::RiuSummaryVectorSelectionUi() { RifEclipseSummaryAddress::SUMMARY_IMPORTED, { { new SummaryIdentifierAndField( RifEclipseSummaryAddress::INPUT_VECTOR_NAME ) } } }, } ) - , m_showIndividualEnsembleCases( false ) + , m_showIndividualEnsembleCases( true ) { - CAF_PDM_InitFieldNoDefault( &m_selectedSources, "SummaryCases", "Cases", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_selectedSources, "SummaryCases", "Cases" ); m_selectedSources.uiCapability()->setAutoAddingOptionFromValue( false ); - CAF_PDM_InitFieldNoDefault( &m_currentSummaryCategory, "CurrentSummaryCategory", "Current Summary Category", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_selectedSummaryCategories, "SelectedSummaryCategories", "Summary Categories", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_currentSummaryCategory, "CurrentSummaryCategory", "Current Summary Category" ); + CAF_PDM_InitFieldNoDefault( &m_selectedSummaryCategories, "SelectedSummaryCategories", "Summary Categories" ); CAF_PDM_InitFieldNoDefault( m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_FIELD][0]->pdmField(), "FieldVectors", - "Field vectors", - "", - "", - "" ); + "Field vectors" ); CAF_PDM_InitFieldNoDefault( m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_AQUIFER][0]->pdmField(), "Aquifers", - "Aquifers", - "", - "", - "" ); + "Aquifers" ); CAF_PDM_InitFieldNoDefault( m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_AQUIFER][1]->pdmField(), "AquiferVectors", - "Aquifer Vectors", - "", - "", - "" ); + "Aquifer Vectors" ); CAF_PDM_InitFieldNoDefault( m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_NETWORK][0]->pdmField(), "NetworkVectors", - "Network Vectors", - "", - "", - "" ); + "Network Vectors" ); CAF_PDM_InitFieldNoDefault( m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_MISC][0]->pdmField(), "MiscVectors", - "Misc Vectors", - "", - "", - "" ); + "Misc Vectors" ); CAF_PDM_InitFieldNoDefault( m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_REGION][0]->pdmField(), "Regions", - "Regions", - "", - "", - "" ); + "Regions" ); CAF_PDM_InitFieldNoDefault( m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_REGION][1]->pdmField(), "RegionsVectors", - "Regions Vectors", - "", - "", - "" ); + "Regions Vectors" ); CAF_PDM_InitFieldNoDefault( m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_REGION_2_REGION][0]->pdmField(), "Region2RegionRegions", - "Regions", - "", - "", - "" ); + "Regions" ); CAF_PDM_InitFieldNoDefault( m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_REGION_2_REGION][1]->pdmField(), "Region2RegionVectors", - "Region2s Vectors", - "", - "", - "" ); + "Region2s Vectors" ); - CAF_PDM_InitFieldNoDefault( m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_WELL_GROUP][0]->pdmField(), + CAF_PDM_InitFieldNoDefault( m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_GROUP][0]->pdmField(), "WellGroupWellGroupNames", - "Well groups", - "", - "", - "" ); - CAF_PDM_InitFieldNoDefault( m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_WELL_GROUP][1]->pdmField(), + "Groups" ); + CAF_PDM_InitFieldNoDefault( m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_GROUP][1]->pdmField(), "WellGroupVectors", - "Well Group Vectors", - "", - "", - "" ); + "Well Group Vectors" ); CAF_PDM_InitFieldNoDefault( m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_WELL][0]->pdmField(), "WellWellName", - "Wells", - "", - "", - "" ); + "Wells" ); CAF_PDM_InitFieldNoDefault( m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_WELL][1]->pdmField(), "WellVectors", - "Well Vectors", - "", - "", - "" ); + "Well Vectors" ); CAF_PDM_InitFieldNoDefault( m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION][0]->pdmField(), "WellCompletionWellName", - "Wells", - "", - "", - "" ); + "Wells" ); CAF_PDM_InitFieldNoDefault( m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION][1]->pdmField(), "WellCompletionIjk", - "Cell IJK", - "", - "", - "" ); + "Cell IJK" ); CAF_PDM_InitFieldNoDefault( m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION][2]->pdmField(), "WellCompletionVectors", - "Well Completion Vectors", - "", - "", - "" ); + "Well Completion Vectors" ); CAF_PDM_InitFieldNoDefault( m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION_LGR][0]->pdmField(), "WellCompletionLgrLgrName", - "LGR Names", - "", - "", - "" ); + "LGR Names" ); CAF_PDM_InitFieldNoDefault( m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION_LGR][1]->pdmField(), "WellCompletionLgrWellName", - "Wells", - "", - "", - "" ); + "Wells" ); CAF_PDM_InitFieldNoDefault( m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION_LGR][2]->pdmField(), "WellCompletionLgrIjk", - "Cell IJK", - "", - "", - "" ); + "Cell IJK" ); CAF_PDM_InitFieldNoDefault( m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION_LGR][3]->pdmField(), "WellCompletionLgrVectors", - "Well Completion Vectors", - "", - "", - "" ); + "Well Completion Vectors" ); CAF_PDM_InitFieldNoDefault( m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_WELL_LGR][0]->pdmField(), "WellLgrLgrName", - "LGR Names", - "", - "", - "" ); + "LGR Names" ); CAF_PDM_InitFieldNoDefault( m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_WELL_LGR][1]->pdmField(), "WellLgrWellName", - "Wells", - "", - "", - "" ); + "Wells" ); CAF_PDM_InitFieldNoDefault( m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_WELL_LGR][2]->pdmField(), "WellLgrVectors", - "Vectors", - "", - "", - "" ); + "Vectors" ); CAF_PDM_InitFieldNoDefault( m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_WELL_SEGMENT][0]->pdmField(), "WellSegmentWellName", - "Wells", - "", - "", - "" ); + "Wells" ); CAF_PDM_InitFieldNoDefault( m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_WELL_SEGMENT][1]->pdmField(), "WellSegmentNumber", - "Segments", - "", - "", - "" ); + "Segments" ); CAF_PDM_InitFieldNoDefault( m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_WELL_SEGMENT][2]->pdmField(), "WellSegmentVectors", - "Vectors", - "", - "", - "" ); + "Vectors" ); CAF_PDM_InitFieldNoDefault( m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_BLOCK][0]->pdmField(), "BlockIjk", - "Cell IJK", - "", - "", - "" ); + "Cell IJK" ); CAF_PDM_InitFieldNoDefault( m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_BLOCK][1]->pdmField(), "BlockVectors", - "Block Vectors", - "", - "", - "" ); + "Block Vectors" ); CAF_PDM_InitFieldNoDefault( m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_BLOCK_LGR][0]->pdmField(), "BlockLgrLgrName", - "LGR Names", - "", - "", - "" ); + "LGR Names" ); CAF_PDM_InitFieldNoDefault( m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_BLOCK_LGR][1]->pdmField(), "BlockLgrIjk", - "Cell IJK", - "", - "", - "" ); + "Cell IJK" ); CAF_PDM_InitFieldNoDefault( m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_BLOCK_LGR][2]->pdmField(), "BlockLgrVectors", - "Block Vectors", - "", - "", - "" ); + "Block Vectors" ); CAF_PDM_InitFieldNoDefault( m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_CALCULATED][0]->pdmField(), "CalculatedVectors", - "Calculated Vectors", - "", - "", - "" ); + "Calculated Vectors" ); CAF_PDM_InitFieldNoDefault( m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_IMPORTED][0]->pdmField(), "ImportedVectors", - "Imported vectors", - "", - "", - "" ); + "Imported vectors" ); for ( const auto& itemTypes : m_identifierFieldsMap ) { @@ -402,7 +311,7 @@ RiuSummaryVectorSelectionUi::~RiuSummaryVectorSelectionUi() { for ( const auto& identifierAndField : identifierAndFieldList.second ) { - delete identifierAndField->pdmField(); + delete identifierAndField; } } } @@ -420,28 +329,17 @@ std::vector RiuSummaryVectorSelectionUi::allCurveDefi for ( SummarySource* currSource : selectedSummarySources() ) { - RimSummaryCaseCollection* ensemble = dynamic_cast( currSource ); - RimSummaryCase* sumCase = dynamic_cast( currSource ); + RimSummaryCase* sumCase = dynamic_cast( currSource ); + if ( sumCase == nullptr ) continue; std::set addressesFromSource; std::vector casesFromSource; - // Build case list - if ( ensemble ) + RifSummaryReaderInterface* reader = sumCase ? sumCase->summaryReader() : nullptr; + if ( reader ) { - auto addresses = ensemble->ensembleSummaryAddresses(); - addressesFromSource.insert( addresses.begin(), addresses.end() ); - auto ensembleCases = ensemble->allSummaryCases(); - casesFromSource.insert( casesFromSource.end(), ensembleCases.begin(), ensembleCases.end() ); - } - else - { - RifSummaryReaderInterface* reader = sumCase ? sumCase->summaryReader() : nullptr; - if ( reader ) - { - addressesFromSource.insert( reader->allResultAddresses().begin(), reader->allResultAddresses().end() ); - casesFromSource.push_back( sumCase ); - } + addressesFromSource.insert( reader->allResultAddresses().begin(), reader->allResultAddresses().end() ); + casesFromSource.push_back( sumCase ); } for ( auto caseFromSource : casesFromSource ) @@ -450,8 +348,7 @@ std::vector RiuSummaryVectorSelectionUi::allCurveDefi { if ( selectedAddressesFromUi.count( addressFromSource ) > 0 ) { - curveDefinitions.insert( - RiaSummaryCurveDefinition( caseFromSource, addressFromSource, ensemble != nullptr ) ); + curveDefinitions.insert( RiaSummaryCurveDefinition( caseFromSource, addressFromSource, false ) ); } } } @@ -638,6 +535,92 @@ void RiuSummaryVectorSelectionUi::setDefaultSelection( const std::vector RiuSummaryVectorSelectionUi::optionsForSummaryDataSource( bool hideSummaryCases, + bool hideEnsembles, + bool showIndividualEnsembleCases ) +{ + QList options; + + RimProject* proj = RimProject::current(); + std::vector oilFields; + + proj->allOilFields( oilFields ); + for ( RimOilField* oilField : oilFields ) + { + RimSummaryCaseMainCollection* sumCaseMainColl = oilField->summaryCaseMainCollection(); + if ( sumCaseMainColl ) + { + if ( !hideSummaryCases ) + { + // Top level cases + for ( const auto& sumCase : sumCaseMainColl->topLevelSummaryCases() ) + { + options.push_back( caf::PdmOptionItemInfo( sumCase->displayCaseName(), sumCase ) ); + } + } + + // Ensembles + if ( !hideEnsembles ) + { + bool ensembleHeaderCreated = false; + for ( const auto& sumCaseColl : sumCaseMainColl->summaryCaseCollections() ) + { + if ( !sumCaseColl->isEnsemble() ) continue; + + if ( !ensembleHeaderCreated ) + { + options.push_back( caf::PdmOptionItemInfo::createHeader( "Ensembles", true ) ); + ensembleHeaderCreated = true; + } + // Ensemble level + { + auto optionItem = caf::PdmOptionItemInfo( sumCaseColl->name(), sumCaseColl ); + optionItem.setLevel( 1 ); + options.push_back( optionItem ); + } + } + } + + if ( !hideSummaryCases ) + { + // Grouped cases + for ( const auto& sumCaseColl : sumCaseMainColl->summaryCaseCollections() ) + { + if ( sumCaseColl->isEnsemble() && !showIndividualEnsembleCases ) continue; + + options.push_back( caf::PdmOptionItemInfo::createHeader( sumCaseColl->name(), true ) ); + + for ( const auto& sumCase : sumCaseColl->allSummaryCases() ) + { + auto optionItem = caf::PdmOptionItemInfo( sumCase->displayCaseName(), sumCase ); + optionItem.setLevel( 1 ); + options.push_back( optionItem ); + } + } + + // Observed data + auto observedDataColl = oilField->observedDataCollection(); + if ( observedDataColl->allObservedSummaryData().size() > 0 ) + { + options.push_back( caf::PdmOptionItemInfo::createHeader( "Observed Data", true ) ); + + for ( const auto& obsData : observedDataColl->allObservedSummaryData() ) + { + auto optionItem = caf::PdmOptionItemInfo( obsData->caseName(), obsData ); + optionItem.setLevel( 1 ); + options.push_back( optionItem ); + } + } + } + } + } + + return options; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -683,7 +666,6 @@ void RiuSummaryVectorSelectionUi::setSelectedCurveDefinitions( const std::vector m_selectedSources.end() ) { m_selectedSources.push_back( curveDef.ensemble() ); - handleAddedSource( curveDef.ensemble() ); } } } @@ -695,7 +677,6 @@ void RiuSummaryVectorSelectionUi::setSelectedCurveDefinitions( const std::vector m_selectedSources.end() ) { m_selectedSources.push_back( curveDef.summaryCase() ); - handleAddedSource( curveDef.summaryCase() ); } } } @@ -738,8 +719,6 @@ void RiuSummaryVectorSelectionUi::setSelectedCurveDefinitions( const std::vector m_currentSummaryCategory.setValue( cat ); } - m_previouslySelectedSources = m_selectedSources.ptrReferencedObjects(); - m_prevCurveCount = allCurveDefinitionsFromSelection().size(); m_prevCurveSetCount = allCurveSetDefinitionsFromSelections().size(); } @@ -772,35 +751,6 @@ void RiuSummaryVectorSelectionUi::fieldChangedByUi( const caf::PdmFieldHandle* c const QVariant& oldValue, const QVariant& newValue ) { - if ( changedField == &m_selectedSources ) - { - caf::PdmObject* objectAdded = nullptr; - for ( caf::PdmObject* selectedObject : m_selectedSources() ) - { - auto it = std::find( m_previouslySelectedSources.begin(), m_previouslySelectedSources.end(), selectedObject ); - if ( it == m_previouslySelectedSources.end() ) - { - objectAdded = selectedObject; - handleAddedSource( objectAdded ); - break; - } - } - if ( !objectAdded ) - { - caf::PdmObject* objectRemoved = nullptr; - for ( caf::PdmObject* previouslySelectedObject : m_previouslySelectedSources ) - { - auto it = std::find( m_selectedSources.begin(), m_selectedSources.end(), previouslySelectedObject ); - if ( it == m_selectedSources.end() ) - { - objectRemoved = previouslySelectedObject; - handleRemovedSource( objectRemoved ); - break; - } - } - } - m_previouslySelectedSources = m_selectedSources.ptrReferencedObjects(); - } if ( changedField != &m_selectedSources && changedField != &m_selectedSummaryCategories && changedField != &m_currentSummaryCategory ) { @@ -873,7 +823,7 @@ void RiuSummaryVectorSelectionUi::fieldChangedByUi( const caf::PdmFieldHandle* c /// //-------------------------------------------------------------------------------------------------- QList - RiuSummaryVectorSelectionUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) + RiuSummaryVectorSelectionUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { QList options; @@ -955,14 +905,14 @@ void RiuSummaryVectorSelectionUi::defineUiOrdering( QString uiConfigName, caf::P summaryiesField = m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_REGION_2_REGION][1]->pdmField(); } - else if ( sumCategory == RifEclipseSummaryAddress::SUMMARY_WELL_GROUP ) + else if ( sumCategory == RifEclipseSummaryAddress::SUMMARY_GROUP ) { { - caf::PdmUiGroup* myGroup = uiOrdering.addNewGroup( "Well Groups" ); - myGroup->add( m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_WELL_GROUP][0]->pdmField() ); + caf::PdmUiGroup* myGroup = uiOrdering.addNewGroup( "Groups" ); + myGroup->add( m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_GROUP][0]->pdmField() ); } - summaryiesField = m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_WELL_GROUP][1]->pdmField(); + summaryiesField = m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_GROUP][1]->pdmField(); } else if ( sumCategory == RifEclipseSummaryAddress::SUMMARY_WELL ) { @@ -1165,22 +1115,22 @@ std::set for ( const auto& adr : addrUnion ) { - if ( m_hideHistoryVectors && adr.isHistoryQuantity() ) continue; + if ( m_hideHistoryVectors && adr.isHistoryVector() ) continue; if ( m_hideDifferenceVectors ) { const auto diffText = RifReaderEclipseSummary::differenceIdentifier(); - if ( RiaStdStringTools::endsWith( adr.quantityName(), diffText ) ) continue; + if ( RiaStdStringTools::endsWith( adr.vectorName(), diffText ) ) continue; } if ( m_hideVectorsWithoutHistory ) { - auto candidateName = adr.quantityName() + RifReaderEclipseSummary::historyIdentifier(); + auto candidateName = adr.vectorName() + RifReaderEclipseSummary::historyIdentifier(); bool found = false; for ( const auto& ad : addrUnion ) { - if ( ad.quantityName() == candidateName ) found = true; + if ( ad.vectorName() == candidateName ) found = true; } if ( !found ) continue; @@ -1386,8 +1336,7 @@ void RiuSummaryVectorSelectionUi::defineEditorAttribute( const caf::PdmFieldHand //-------------------------------------------------------------------------------------------------- void RiuSummaryVectorSelectionUi::resetAllFields() { - m_selectedSources.clear(); - m_previouslySelectedSources.clear(); + m_selectedSources.clearWithoutDelete(); m_selectedSummaryCategories = std::vector>(); // clear all state in fields @@ -1444,87 +1393,12 @@ RimSummaryCase* RiuSummaryVectorSelectionUi::calculatedSummaryCase() //-------------------------------------------------------------------------------------------------- void RiuSummaryVectorSelectionUi::appendOptionItemsForSources( QList& options ) const { - RimProject* proj = RimProject::current(); - std::vector oilFields; + auto dataSourceOptions = + optionsForSummaryDataSource( m_hideSummaryCases, m_hideEnsembles, m_showIndividualEnsembleCases ); - proj->allOilFields( oilFields ); - for ( RimOilField* oilField : oilFields ) + for ( auto& o : dataSourceOptions ) { - RimSummaryCaseMainCollection* sumCaseMainColl = oilField->summaryCaseMainCollection(); - if ( sumCaseMainColl ) - { - if ( !m_hideSummaryCases ) - { - // Top level cases - for ( const auto& sumCase : sumCaseMainColl->topLevelSummaryCases() ) - { - options.push_back( caf::PdmOptionItemInfo( sumCase->displayCaseName(), sumCase ) ); - } - } - - // Ensembles - if ( !m_hideEnsembles ) - { - bool ensembleHeaderCreated = false; - for ( const auto& sumCaseColl : sumCaseMainColl->summaryCaseCollections() ) - { - if ( !sumCaseColl->isEnsemble() ) continue; - - if ( !ensembleHeaderCreated ) - { - options.push_back( caf::PdmOptionItemInfo::createHeader( "Ensembles", true ) ); - ensembleHeaderCreated = true; - } - // Ensemble level - { - auto optionItem = caf::PdmOptionItemInfo( sumCaseColl->name(), sumCaseColl ); - optionItem.setLevel( 1 ); - options.push_back( optionItem ); - } - if ( m_showIndividualEnsembleCases ) - { - for ( const auto& sumCase : sumCaseColl->allSummaryCases() ) - { - auto optionItem = caf::PdmOptionItemInfo( sumCase->displayCaseName(), sumCase ); - optionItem.setLevel( 2 ); - options.push_back( optionItem ); - } - } - } - } - - if ( !m_hideSummaryCases ) - { - // Grouped cases - for ( const auto& sumCaseColl : sumCaseMainColl->summaryCaseCollections() ) - { - if ( sumCaseColl->isEnsemble() ) continue; - - options.push_back( caf::PdmOptionItemInfo::createHeader( sumCaseColl->name(), true ) ); - - for ( const auto& sumCase : sumCaseColl->allSummaryCases() ) - { - auto optionItem = caf::PdmOptionItemInfo( sumCase->displayCaseName(), sumCase ); - optionItem.setLevel( 1 ); - options.push_back( optionItem ); - } - } - - // Observed data - auto observedDataColl = oilField->observedDataCollection(); - if ( observedDataColl->allObservedSummaryData().size() > 0 ) - { - options.push_back( caf::PdmOptionItemInfo::createHeader( "Observed Data", true ) ); - - for ( const auto& obsData : observedDataColl->allObservedSummaryData() ) - { - auto optionItem = caf::PdmOptionItemInfo( obsData->caseName(), obsData ); - optionItem.setLevel( 1 ); - options.push_back( optionItem ); - } - } - } - } + options.push_back( o ); } } @@ -1541,7 +1415,7 @@ void RiuSummaryVectorSelectionUi::appendOptionItemsForCategories( QListlongNameFromQuantityName( itemName ); + RiuSummaryQuantityNameInfoProvider::instance()->longNameFromVectorName( itemName ); if ( longVectorName.empty() ) { @@ -1698,91 +1572,3 @@ void RiuSummaryVectorSelectionUi::appendOptionItemsForSubCategoriesAndVectors( Q } } } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuSummaryVectorSelectionUi::handleAddedSource( SummarySource* sourceAdded ) -{ - CAF_ASSERT( sourceAdded ); - auto caseCollection = dynamic_cast( sourceAdded ); - if ( caseCollection && m_showIndividualEnsembleCases ) - { - // Select all children - for ( auto summaryCase : caseCollection->allSummaryCases() ) - { - auto it = std::find( m_selectedSources.begin(), m_selectedSources.end(), summaryCase ); - if ( it == m_selectedSources.end() ) - { - m_selectedSources.push_back( summaryCase ); - } - } - } - else - { - auto summaryCase = dynamic_cast( sourceAdded ); - if ( summaryCase ) - { - auto caseCollection = summaryCase->ensemble(); - if ( caseCollection ) - { - auto it = std::find( m_selectedSources.begin(), m_selectedSources.end(), caseCollection ); - if ( it == m_selectedSources.end() ) - { - // Check if all children have been selected. - bool allChildrenSelected = true; - for ( auto summaryChild : caseCollection->allSummaryCases() ) - { - auto it = std::find( m_selectedSources.begin(), m_selectedSources.end(), summaryChild ); - if ( it == m_selectedSources.end() ) - { - allChildrenSelected = false; - break; - } - } - if ( allChildrenSelected ) // Add collection if all children have been selected - { - m_selectedSources.push_back( caseCollection ); - } - } - } - } - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuSummaryVectorSelectionUi::handleRemovedSource( SummarySource* sourceRemoved ) -{ - CAF_ASSERT( sourceRemoved ); - auto caseCollection = dynamic_cast( sourceRemoved ); - if ( caseCollection ) - { - // Select all children - for ( auto summaryCase : caseCollection->allSummaryCases() ) - { - auto it = std::find( m_selectedSources.begin(), m_selectedSources.end(), summaryCase ); - if ( it != m_selectedSources.end() ) - { - m_selectedSources.removePtr( *it ); - } - } - } - else - { - auto summaryCase = dynamic_cast( sourceRemoved ); - if ( summaryCase ) - { - auto caseCollection = summaryCase->ensemble(); - if ( caseCollection ) - { - auto it = std::find( m_selectedSources.begin(), m_selectedSources.end(), caseCollection ); - if ( it != m_selectedSources.end() ) - { - m_selectedSources.removePtr( *it ); - } - } - } - } -} diff --git a/ApplicationLibCode/UserInterface/RiuSummaryVectorSelectionUi.h b/ApplicationLibCode/UserInterface/RiuSummaryVectorSelectionUi.h index ebf8fe2ef1..fa07030d20 100644 --- a/ApplicationLibCode/UserInterface/RiuSummaryVectorSelectionUi.h +++ b/ApplicationLibCode/UserInterface/RiuSummaryVectorSelectionUi.h @@ -71,10 +71,12 @@ class RiuSummaryVectorSelectionUi : public caf::PdmObject void setDefaultSelection( const std::vector& defaultCases ); + static QList + optionsForSummaryDataSource( bool hideSummaryCases, bool hideEnsembles, bool showIndividualEnsembleCases ); + private: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, @@ -115,12 +117,8 @@ class RiuSummaryVectorSelectionUi : public caf::PdmObject void appendOptionItemsForSubCategoriesAndVectors( QList& options, SummaryIdentifierAndField* identifierAndField ) const; - void handleAddedSource( SummarySource* sourceAdded ); - void handleRemovedSource( SummarySource* sourceRemoved ); - private: caf::PdmPtrArrayField m_selectedSources; - std::vector m_previouslySelectedSources; caf::PdmField>> m_selectedSummaryCategories; caf::PdmField> m_currentSummaryCategory; diff --git a/ApplicationLibCode/UserInterface/RiuTextContentFrame.cpp b/ApplicationLibCode/UserInterface/RiuTextContentFrame.cpp index cd7ac88644..ce25ee32d8 100644 --- a/ApplicationLibCode/UserInterface/RiuTextContentFrame.cpp +++ b/ApplicationLibCode/UserInterface/RiuTextContentFrame.cpp @@ -18,6 +18,8 @@ #include "RiuTextContentFrame.h" +#include "RiaTextStringTools.h" + #include "RiaFontCache.h" #include "RiaPreferences.h" @@ -29,8 +31,6 @@ #include -//#include - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -92,9 +92,7 @@ QSize RiuTextContentFrame::minimumSizeHint() const //-------------------------------------------------------------------------------------------------- void RiuTextContentFrame::renderTo( QPainter* painter, const QRect& targetRect ) { - QFont font = this->font(); - font.setPixelSize( caf::FontTools::pointSizeToPixelSize( RiaPreferences::current()->defaultPlotFontSize() ) ); - this->setFont( font ); + updateFontSize(); QColor textColor = RiuGuiTheme::getColorByVariableName( "textColor" ); @@ -126,18 +124,6 @@ void RiuTextContentFrame::renderTo( QPainter* painter, const QRect& targetRect ) painter->translate( QPoint( layout.margins.left(), layout.margins.top() + layout.lineSpacing * 2 ) ); painter->setPen( QPen( textColor ) ); - /* - QwtMathMLTextEngine textEngine = QwtMathMLTextEngine(); - textEngine.draw( painter, - QRect( targetRect.left() + layout.margins.left(), - targetRect.top() + layout.margins.top() + layout.lineSpacing * 2, - targetRect.width() - layout.margins.left() - layout.margins.right(), - targetRect.height() - layout.margins.top() - layout.margins.bottom() - - layout.margins.top() + layout.lineSpacing * 2 ), - Qt::AlignLeft, - m_text ); - - */ QTextDocument td; td.setDocumentMargin( 0.0 ); td.setDefaultFont( this->font() ); @@ -168,7 +154,7 @@ void RiuTextContentFrame::paintEvent( QPaintEvent* e ) void RiuTextContentFrame::layoutInfo( LayoutInfo* layout ) const { QFontMetrics fontMetrics( this->font() ); - QStringList titleLines = m_text.split( "\n", QString::SkipEmptyParts ); + QStringList titleLines = RiaTextStringTools::splitSkipEmptyParts( m_text, "\n" ); layout->charHeight = fontMetrics.height(); layout->charAscent = fontMetrics.ascent(); diff --git a/ApplicationLibCode/UserInterface/RiuTextDialog.h b/ApplicationLibCode/UserInterface/RiuTextDialog.h index a57c39eb46..453990de54 100644 --- a/ApplicationLibCode/UserInterface/RiuTextDialog.h +++ b/ApplicationLibCode/UserInterface/RiuTextDialog.h @@ -18,8 +18,6 @@ #pragma once -#include "RiaQDateTimeTools.h" - #include #include #include diff --git a/ApplicationLibCode/UserInterface/RiuTofAccumulatedPhaseFractionsPlot.cpp b/ApplicationLibCode/UserInterface/RiuTofAccumulatedPhaseFractionsPlot.cpp index b22a023b2f..e2735b7d52 100644 --- a/ApplicationLibCode/UserInterface/RiuTofAccumulatedPhaseFractionsPlot.cpp +++ b/ApplicationLibCode/UserInterface/RiuTofAccumulatedPhaseFractionsPlot.cpp @@ -32,8 +32,10 @@ #include "cvfAssert.h" #include "qwt_legend.h" +#include "qwt_plot_curve.h" #include "qwt_plot_grid.h" #include "qwt_plot_layout.h" +#include "qwt_text.h" #include #include @@ -190,7 +192,7 @@ void RiuTofAccumulatedPhaseFractionsPlot::setSamples( std::vector xSampl { maxVal = std::max( val, maxVal ); } - setAxisScale( QwtPlot::xBottom, 0, maxVal ); + setAxisScale( QwtAxis::XBottom, 0, maxVal ); updateAxes(); } replot(); @@ -202,16 +204,14 @@ void RiuTofAccumulatedPhaseFractionsPlot::setSamples( std::vector xSampl void RiuTofAccumulatedPhaseFractionsPlot::setDefaults() { setCommonPlotBehaviour( this ); - setAxisTitle( QwtPlot::xBottom, "Years" ); + setAxisTitle( QwtAxis::XBottom, "Years" ); - enableAxis( QwtPlot::xBottom, true ); - enableAxis( QwtPlot::yLeft, true ); - setAxisScale( QwtPlot::yLeft, 0, 1, 0.2 ); - enableAxis( QwtPlot::xTop, false ); - enableAxis( QwtPlot::yRight, false ); + setAxesCount( QwtAxis::XBottom, 1 ); + setAxesCount( QwtAxis::YLeft, 1 ); + setAxisScale( QwtAxis::YLeft, 0, 1, 0.2 ); - setAxisMaxMinor( QwtPlot::xBottom, 2 ); - setAxisMaxMinor( QwtPlot::yLeft, 3 ); + setAxisMaxMinor( QwtAxis::XBottom, 2 ); + setAxisMaxMinor( QwtAxis::YLeft, 3 ); QSizePolicy sizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); sizePolicy.setHeightForWidth( true ); @@ -253,26 +253,26 @@ void RiuTofAccumulatedPhaseFractionsPlot::setCommonPlotBehaviour( QwtPlot* plot grid->setPen( gridPen ); // Axis number font - QFont axisFont = plot->axisFont( QwtPlot::xBottom ); + QFont axisFont = plot->axisFont( QwtAxis::XBottom ); axisFont.setPointSize( 10 ); - plot->setAxisFont( QwtPlot::xBottom, axisFont ); - plot->setAxisFont( QwtPlot::xTop, axisFont ); - plot->setAxisFont( QwtPlot::yLeft, axisFont ); - plot->setAxisFont( QwtPlot::yRight, axisFont ); + plot->setAxisFont( QwtAxis::XBottom, axisFont ); + plot->setAxisFont( QwtAxis::XTop, axisFont ); + plot->setAxisFont( QwtAxis::YLeft, axisFont ); + plot->setAxisFont( QwtAxis::YRight, axisFont ); // Axis title font - QwtText axisTitle = plot->axisTitle( QwtPlot::xBottom ); + QwtText axisTitle = plot->axisTitle( QwtAxis::XBottom ); QFont axisTitleFont = axisTitle.font(); axisTitleFont.setPointSize( 10 ); axisTitleFont.setBold( false ); axisTitle.setFont( axisTitleFont ); axisTitle.setRenderFlags( Qt::AlignRight ); - plot->setAxisTitle( QwtPlot::xBottom, axisTitle ); - plot->setAxisTitle( QwtPlot::xTop, axisTitle ); - plot->setAxisTitle( QwtPlot::yLeft, axisTitle ); - plot->setAxisTitle( QwtPlot::yRight, axisTitle ); + plot->setAxisTitle( QwtAxis::XBottom, axisTitle ); + plot->setAxisTitle( QwtAxis::XTop, axisTitle ); + plot->setAxisTitle( QwtAxis::YLeft, axisTitle ); + plot->setAxisTitle( QwtAxis::YRight, axisTitle ); // Enable mouse tracking and event filter diff --git a/ApplicationLibCode/UserInterface/RiuTofAccumulatedPhaseFractionsPlot.h b/ApplicationLibCode/UserInterface/RiuTofAccumulatedPhaseFractionsPlot.h index 4d04457da0..c13949e182 100644 --- a/ApplicationLibCode/UserInterface/RiuTofAccumulatedPhaseFractionsPlot.h +++ b/ApplicationLibCode/UserInterface/RiuTofAccumulatedPhaseFractionsPlot.h @@ -22,7 +22,6 @@ #include "cafPdmPointer.h" #include "qwt_plot.h" -#include "qwt_plot_curve.h" #include #include @@ -31,6 +30,7 @@ #include "RiuInterfaceToViewWindow.h" class RimTofAccumulatedPhaseFractionsPlot; +class QwtPlotCurve; //================================================================================================== // diff --git a/ApplicationLibCode/UserInterface/RiuTreeViewEventFilter.cpp b/ApplicationLibCode/UserInterface/RiuTreeViewEventFilter.cpp index e2faad723c..a7e57e7d13 100644 --- a/ApplicationLibCode/UserInterface/RiuTreeViewEventFilter.cpp +++ b/ApplicationLibCode/UserInterface/RiuTreeViewEventFilter.cpp @@ -44,8 +44,9 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuTreeViewEventFilter::RiuTreeViewEventFilter( QObject* parent ) +RiuTreeViewEventFilter::RiuTreeViewEventFilter( QObject* parent, caf::PdmUiTreeView* treeView ) : QObject( parent ) + , m_projectTreeView( treeView ) { } @@ -141,14 +142,7 @@ bool RiuTreeViewEventFilter::eventFilter( QObject* obj, QEvent* event ) // Do not toggle state if currently editing a name in the tree view bool toggleStateForSelection = true; - if ( RiuMainWindow::instance()->projectTreeView() && - RiuMainWindow::instance()->projectTreeView()->isTreeItemEditWidgetActive() ) - { - toggleStateForSelection = false; - } - else if ( RiaGuiApplication::instance()->mainPlotWindow() && - RiaGuiApplication::instance()->mainPlotWindow()->projectTreeView() && - RiaGuiApplication::instance()->mainPlotWindow()->projectTreeView()->isTreeItemEditWidgetActive() ) + if ( m_projectTreeView && m_projectTreeView->isTreeItemEditWidgetActive() ) { toggleStateForSelection = false; } diff --git a/ApplicationLibCode/UserInterface/RiuTreeViewEventFilter.h b/ApplicationLibCode/UserInterface/RiuTreeViewEventFilter.h index be6756ca9e..0c27e0b247 100644 --- a/ApplicationLibCode/UserInterface/RiuTreeViewEventFilter.h +++ b/ApplicationLibCode/UserInterface/RiuTreeViewEventFilter.h @@ -29,18 +29,22 @@ class QKeyEvent; namespace caf { class CmdFeature; -} +class PdmUiTreeView; +} // namespace caf //-------------------------------------------------------------------------------------------------- class RiuTreeViewEventFilter : public QObject { Q_OBJECT public: - explicit RiuTreeViewEventFilter( QObject* parent ); + explicit RiuTreeViewEventFilter( QObject* parent, caf::PdmUiTreeView* treeView ); static bool activateFeatureFromKeyEvent( QKeyEvent* keyEvent ); static bool activateFirstEnabledFeature( const std::vector& features ); protected: bool eventFilter( QObject* obj, QEvent* event ) override; + +private: + caf::PdmUiTreeView* m_projectTreeView; }; diff --git a/ApplicationLibCode/UserInterface/RiuViewerCommands.cpp b/ApplicationLibCode/UserInterface/RiuViewerCommands.cpp index 71956a5b94..2d67366dc6 100644 --- a/ApplicationLibCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationLibCode/UserInterface/RiuViewerCommands.cpp @@ -769,7 +769,7 @@ void RiuViewerCommands::handlePickAction( int winPosX, int winPosY, Qt::Keyboard { std::vector uiItems; - RiuMainWindow::instance()->projectTreeView()->selectedUiItems( uiItems ); + RiuMainWindow::instance()->projectTreeView( 0 )->selectedUiItems( uiItems ); if ( uiItems.size() == 1 ) { diff --git a/ApplicationLibCode/UserInterface/RiuWellAllocationPlot.h b/ApplicationLibCode/UserInterface/RiuWellAllocationPlot.h index 6c8cc081b3..474cef26ba 100644 --- a/ApplicationLibCode/UserInterface/RiuWellAllocationPlot.h +++ b/ApplicationLibCode/UserInterface/RiuWellAllocationPlot.h @@ -18,8 +18,6 @@ #pragma once -#include "qwt_plot.h" - #include "cafPdmPointer.h" #include diff --git a/ApplicationLibCode/UserInterface/RiuWellLogPlot.cpp b/ApplicationLibCode/UserInterface/RiuWellLogPlot.cpp index 20b853355e..c24427b4ec 100644 --- a/ApplicationLibCode/UserInterface/RiuWellLogPlot.cpp +++ b/ApplicationLibCode/UserInterface/RiuWellLogPlot.cpp @@ -17,22 +17,31 @@ RiuWellLogPlot::RiuWellLogPlot( RimDepthTrackPlot* plotDefinition, QWidget* parent ) : RiuMultiPlotPage( plotDefinition, parent ) { - m_trackScrollBar = new QScrollBar( nullptr ); - m_trackScrollBar->setOrientation( Qt::Vertical ); - m_trackScrollBar->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred ); + m_verticalTrackScrollBar = new QScrollBar( nullptr ); + m_verticalTrackScrollBar->setOrientation( Qt::Vertical ); + m_verticalTrackScrollBar->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred ); - m_trackScrollBarLayout = new QVBoxLayout; - m_trackScrollBarLayout->addWidget( m_trackScrollBar, 0 ); + m_verticalTrackScrollBarLayout = new QVBoxLayout; + m_verticalTrackScrollBarLayout->addWidget( m_verticalTrackScrollBar, 0 ); - connect( m_trackScrollBar, SIGNAL( valueChanged( int ) ), this, SLOT( slotSetMinDepth( int ) ) ); + connect( m_verticalTrackScrollBar, SIGNAL( valueChanged( int ) ), this, SLOT( slotSetMinDepth( int ) ) ); + + m_horizontalTrackScrollBar = new QScrollBar( nullptr ); + m_horizontalTrackScrollBar->setOrientation( Qt::Horizontal ); + m_horizontalTrackScrollBar->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); + + m_horizontalTrackScrollBarLayout = new QHBoxLayout; + m_horizontalTrackScrollBarLayout->addWidget( m_horizontalTrackScrollBar, 0 ); + + connect( m_horizontalTrackScrollBar, SIGNAL( valueChanged( int ) ), this, SLOT( slotSetMinDepth( int ) ) ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimDepthTrackPlot* RiuWellLogPlot::wellLogPlotDefinition() +RimDepthTrackPlot* RiuWellLogPlot::depthTrackPlot() { - RimDepthTrackPlot* wellLogPlot = dynamic_cast( m_plotDefinition.p() ); + auto* wellLogPlot = dynamic_cast( m_plotDefinition.p() ); CAF_ASSERT( wellLogPlot ); return wellLogPlot; } @@ -54,13 +63,21 @@ void RiuWellLogPlot::updateVerticalScrollBar( double minVisible, double maxVisib double visibleRange = maxVisible - minVisible; - m_trackScrollBar->blockSignals( true ); + m_verticalTrackScrollBar->blockSignals( true ); { - m_trackScrollBar->setRange( (int)minAvailable, (int)( ( maxAvailable - visibleRange ) ) ); - m_trackScrollBar->setPageStep( (int)visibleRange ); - m_trackScrollBar->setValue( (int)minVisible ); + m_verticalTrackScrollBar->setRange( (int)minAvailable, (int)( ( maxAvailable - visibleRange ) ) ); + m_verticalTrackScrollBar->setPageStep( (int)visibleRange ); + m_verticalTrackScrollBar->setValue( (int)minVisible ); } - m_trackScrollBar->blockSignals( false ); + m_verticalTrackScrollBar->blockSignals( false ); + + m_horizontalTrackScrollBar->blockSignals( true ); + { + m_horizontalTrackScrollBar->setRange( (int)minAvailable, (int)( ( maxAvailable - visibleRange ) ) ); + m_horizontalTrackScrollBar->setPageStep( (int)visibleRange ); + m_horizontalTrackScrollBar->setValue( (int)minVisible ); + } + m_horizontalTrackScrollBar->blockSignals( false ); } //-------------------------------------------------------------------------------------------------- @@ -68,9 +85,15 @@ void RiuWellLogPlot::updateVerticalScrollBar( double minVisible, double maxVisib //-------------------------------------------------------------------------------------------------- void RiuWellLogPlot::renderTo( QPaintDevice* paintDevice ) { - m_trackScrollBar->setVisible( false ); + m_verticalTrackScrollBar->setVisible( false ); + m_horizontalTrackScrollBar->setVisible( false ); + RiuMultiPlotPage::renderTo( paintDevice ); - m_trackScrollBar->setVisible( true ); + + if ( depthTrackPlot() && depthTrackPlot()->depthOrientation() == RimDepthTrackPlot::DepthOrientation::HORIZONTAL ) + m_horizontalTrackScrollBar->setVisible( true ); + else + m_verticalTrackScrollBar->setVisible( true ); } //-------------------------------------------------------------------------------------------------- @@ -86,12 +109,21 @@ bool RiuWellLogPlot::showYAxis( int row, int column ) const //-------------------------------------------------------------------------------------------------- void RiuWellLogPlot::reinsertScrollbar() { - QList> plotWidgets = this->visiblePlotWidgets(); - int colCount = this->m_gridLayout->columnCount(); + QList> plotWidgets = this->visiblePlotWidgets(); + int colCount = this->m_gridLayout->columnCount(); + int rowCount = this->m_gridLayout->rowCount(); - m_gridLayout->addLayout( m_trackScrollBarLayout, 2, colCount, 1, 1 ); - m_trackScrollBar->setVisible( !plotWidgets.empty() ); - m_gridLayout->setColumnStretch( colCount, 0 ); + if ( depthTrackPlot() && depthTrackPlot()->depthOrientation() == RimDepthTrackPlot::DepthOrientation::HORIZONTAL ) + { + m_gridLayout->addLayout( m_horizontalTrackScrollBarLayout, rowCount, 0, 1, colCount ); + m_horizontalTrackScrollBar->setVisible( !plotWidgets.empty() ); + } + else + { + m_gridLayout->addLayout( m_verticalTrackScrollBarLayout, 2, colCount, 1, 1 ); + m_verticalTrackScrollBar->setVisible( !plotWidgets.empty() ); + m_gridLayout->setColumnStretch( colCount, 0 ); + } } //-------------------------------------------------------------------------------------------------- @@ -99,7 +131,7 @@ void RiuWellLogPlot::reinsertScrollbar() //-------------------------------------------------------------------------------------------------- void RiuWellLogPlot::alignScrollbar( int offset ) { - m_trackScrollBarLayout->setContentsMargins( 0, offset, 0, 0 ); + m_verticalTrackScrollBarLayout->setContentsMargins( 0, offset, 0, 0 ); } //-------------------------------------------------------------------------------------------------- @@ -109,19 +141,21 @@ void RiuWellLogPlot::slotSetMinDepth( int value ) { double minimumDepth; double maximumDepth; - wellLogPlotDefinition()->visibleDepthRange( &minimumDepth, &maximumDepth ); + depthTrackPlot()->visibleDepthRange( &minimumDepth, &maximumDepth ); double delta = value - minimumDepth; - wellLogPlotDefinition()->setDepthAxisRange( minimumDepth + delta, maximumDepth + delta ); - wellLogPlotDefinition()->setAutoScaleDepthEnabled( false ); + depthTrackPlot()->setDepthAxisRange( minimumDepth + delta, maximumDepth + delta ); + depthTrackPlot()->setAutoScaleDepthValuesEnabled( false ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuWellLogPlot::performUpdate() +void RiuWellLogPlot::performUpdate( RiaDefines::MultiPlotPageUpdateType /* whatToUpdate */ ) { - m_trackScrollBar->setVisible( false ); + m_horizontalTrackScrollBar->setVisible( false ); + m_verticalTrackScrollBar->setVisible( false ); + reinsertPlotWidgets(); reinsertScrollbar(); int axisShift = alignCanvasTops(); diff --git a/ApplicationLibCode/UserInterface/RiuWellLogPlot.h b/ApplicationLibCode/UserInterface/RiuWellLogPlot.h index a61ea17aba..9be0f46575 100644 --- a/ApplicationLibCode/UserInterface/RiuWellLogPlot.h +++ b/ApplicationLibCode/UserInterface/RiuWellLogPlot.h @@ -41,13 +41,16 @@ class RiuWellLogPlot : public RiuMultiPlotPage void alignScrollbar( int offset ); private: - RimDepthTrackPlot* wellLogPlotDefinition(); + RimDepthTrackPlot* depthTrackPlot(); private slots: void slotSetMinDepth( int value ); - void performUpdate() override; + void performUpdate( RiaDefines::MultiPlotPageUpdateType whatToUpdate ) override; private: - QPointer m_trackScrollBarLayout; - QScrollBar* m_trackScrollBar; + QPointer m_verticalTrackScrollBarLayout; + QScrollBar* m_verticalTrackScrollBar; + + QPointer m_horizontalTrackScrollBarLayout; + QScrollBar* m_horizontalTrackScrollBar; }; diff --git a/ApplicationLibCode/UserInterface/RiuWellLogTrack.cpp b/ApplicationLibCode/UserInterface/RiuWellLogTrack.cpp index b571514f56..73cd2fe029 100644 --- a/ApplicationLibCode/UserInterface/RiuWellLogTrack.cpp +++ b/ApplicationLibCode/UserInterface/RiuWellLogTrack.cpp @@ -19,14 +19,20 @@ #include "RiuWellLogTrack.h" +#include "RiaDefines.h" +#include "RiaPlotDefines.h" #include "RimWellLogCurve.h" #include "RimWellLogExtractionCurve.h" #include "RimWellLogTrack.h" #include "RiuGuiTheme.h" +#include "RiuPlotCurve.h" +#include "RiuPlotCurveInfoTextProvider.h" #include "RiuQwtCurvePointTracker.h" -#include "RiuRimQwtPlotCurve.h" +#include "RiuQwtPlotTools.h" +#include "qwt_plot.h" +#include "qwt_plot_curve.h" #include "qwt_scale_draw.h" #include "qwt_scale_engine.h" #include "qwt_scale_widget.h" @@ -36,8 +42,9 @@ class RiuWellLogCurvePointTracker : public RiuQwtCurvePointTracker { public: - RiuWellLogCurvePointTracker( QwtPlot* plot, IPlotCurveInfoTextProvider* curveInfoTextProvider ) + RiuWellLogCurvePointTracker( QwtPlot* plot, RiuPlotCurveInfoTextProvider* curveInfoTextProvider, RimWellLogTrack* track ) : RiuQwtCurvePointTracker( plot, false, curveInfoTextProvider ) + , m_wellLogTrack( track ) { } @@ -51,8 +58,8 @@ class RiuWellLogCurvePointTracker : public RiuQwtCurvePointTracker if ( m_plot ) { - QwtPlot::Axis relatedYAxis = QwtPlot::yLeft; - QwtPlot::Axis relatedXAxis = QwtPlot::xTop; + QwtAxisId relatedYAxis( QwtAxis::YLeft, 0 ); + QwtAxisId relatedXAxis( QwtAxis::XTop, 0 ); QString curveInfoText; QString depthAxisValueString; @@ -61,7 +68,19 @@ class RiuWellLogCurvePointTracker : public RiuQwtCurvePointTracker closestCurvePoint( pos, &curveInfoText, &xAxisValueString, &depthAxisValueString, &relatedXAxis, &relatedYAxis ); if ( !closestPoint.isNull() ) { - QString str = QString( "%1\nDepth: %2" ).arg( xAxisValueString ).arg( depthAxisValueString ); + QString str; + + RimWellLogPlot* wlp = nullptr; + m_wellLogTrack->firstAncestorOfType( wlp ); + + if ( wlp && wlp->depthOrientation() == RimDepthTrackPlot::DepthOrientation::VERTICAL ) + { + str = QString( "%1\nDepth: %2" ).arg( xAxisValueString ).arg( depthAxisValueString ); + } + else + { + str = QString( "%1\nDepth: %2" ).arg( depthAxisValueString ).arg( xAxisValueString ); + } if ( !curveInfoText.isEmpty() ) { @@ -79,21 +98,23 @@ class RiuWellLogCurvePointTracker : public RiuQwtCurvePointTracker return txt; } + +private: + caf::PdmPointer m_wellLogTrack; }; //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -class WellLogCurveInfoTextProvider : public IPlotCurveInfoTextProvider +class WellLogCurveInfoTextProvider : public RiuPlotCurveInfoTextProvider { public: //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- - QString curveInfoText( QwtPlotCurve* curve ) override + QString curveInfoText( RiuPlotCurve* riuCurve ) const override { - RiuRimQwtPlotCurve* riuCurve = dynamic_cast( curve ); - RimWellLogCurve* wlCurve = nullptr; + RimWellLogCurve* wlCurve = nullptr; if ( riuCurve ) { wlCurve = dynamic_cast( riuCurve->ownerRimCurve() ); @@ -114,12 +135,12 @@ static WellLogCurveInfoTextProvider wellLogCurveInfoTextProvider; RiuWellLogTrack::RiuWellLogTrack( RimWellLogTrack* track, QWidget* parent /*= nullptr */ ) : RiuQwtPlotWidget( track, parent ) { - setAxisEnabled( QwtPlot::yLeft, true ); - setAxisEnabled( QwtPlot::yRight, false ); - setAxisEnabled( QwtPlot::xTop, true ); - setAxisEnabled( QwtPlot::xBottom, false ); + setAxisEnabled( QwtAxis::YLeft, true ); + setAxisEnabled( QwtAxis::YRight, false ); + setAxisEnabled( QwtAxis::XTop, true ); + setAxisEnabled( QwtAxis::XBottom, true ); - new RiuWellLogCurvePointTracker( this, &wellLogCurveInfoTextProvider ); + new RiuWellLogCurvePointTracker( this->qwtPlot(), &wellLogCurveInfoTextProvider, track ); } //-------------------------------------------------------------------------------------------------- @@ -132,22 +153,19 @@ RiuWellLogTrack::~RiuWellLogTrack() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuWellLogTrack::setAxisEnabled( QwtPlot::Axis axis, bool enabled ) +void RiuWellLogTrack::setAxisEnabled( QwtAxis::Position axis, bool enabled ) { + RiuPlotAxis plotAxis = RiuPlotAxis( RiuQwtPlotTools::fromQwtPlotAxis( axis ) ); + RiuQwtPlotWidget::enableAxis( plotAxis, enabled ); + if ( enabled ) { - enableAxis( axis, true ); - // Align the canvas with the actual min and max values of the curves - axisScaleEngine( axis )->setAttribute( QwtScaleEngine::Floating, true ); - setAxisScale( axis, 0.0, 100.0 ); - axisScaleDraw( axis )->setMinimumExtent( axisExtent( axis ) ); + qwtPlot()->axisScaleEngine( axis )->setAttribute( QwtScaleEngine::Floating, true ); + setAxisScale( plotAxis, 0.0, 100.0 ); + qwtPlot()->axisScaleDraw( axis )->setMinimumExtent( axisExtent( plotAxis ) ); - axisWidget( axis )->setMargin( 0 ); - setAxisTitleEnabled( axis, true ); - } - else - { - enableAxis( axis, false ); + qwtPlot()->axisWidget( axis )->setMargin( 0 ); + setAxisTitleEnabled( plotAxis, true ); } } diff --git a/ApplicationLibCode/UserInterface/RiuWellLogTrack.h b/ApplicationLibCode/UserInterface/RiuWellLogTrack.h index 85def5a8ba..60dda603c6 100644 --- a/ApplicationLibCode/UserInterface/RiuWellLogTrack.h +++ b/ApplicationLibCode/UserInterface/RiuWellLogTrack.h @@ -20,6 +20,8 @@ #include "RiuQwtPlotWidget.h" +#include "qwt_plot.h" + class RimWellLogTrack; class QWheelEvent; @@ -36,6 +38,5 @@ class RiuWellLogTrack : public RiuQwtPlotWidget RiuWellLogTrack( RimWellLogTrack* track, QWidget* parent = nullptr ); ~RiuWellLogTrack() override; -private: - void setAxisEnabled( QwtPlot::Axis axis, bool enabled ); + void setAxisEnabled( QwtAxis::Position axis, bool enabled ); }; diff --git a/ApplicationLibCode/UserInterface/RiuWellPathComponentPlotItem.cpp b/ApplicationLibCode/UserInterface/RiuWellPathComponentPlotItem.cpp index 6075b4516d..94abab598d 100644 --- a/ApplicationLibCode/UserInterface/RiuWellPathComponentPlotItem.cpp +++ b/ApplicationLibCode/UserInterface/RiuWellPathComponentPlotItem.cpp @@ -38,6 +38,7 @@ #include "qwt_plot.h" #include "qwt_plot_marker.h" #include "qwt_plot_shapeitem.h" +#include "qwt_text.h" #include #include @@ -180,15 +181,25 @@ void RiuWellPathComponentPlotItem::onLoadDataAndUpdate( bool updateParentPlot ) double posMax = 0.75 + m_columnOffset; addColumnFeature( -posMax, -posMin, startDepth, endDepth, componentColor() ); addColumnFeature( posMin, posMax, startDepth, endDepth, componentColor() ); - addMarker( -posMax, endDepth, 12, RiuQwtSymbol::SYMBOL_LEFT_ANGLED_TRIANGLE, componentColor() ); - addMarker( posMax, endDepth, 12, RiuQwtSymbol::SYMBOL_RIGHT_ANGLED_TRIANGLE, componentColor() ); - addMarker( casingTrackEnd, endDepth, 12, RiuQwtSymbol::SYMBOL_RIGHT_ANGLED_TRIANGLE, componentColor( 0.0 ), label() ); + addMarker( -posMax, endDepth, 12, RiuPlotCurveSymbol::SYMBOL_LEFT_ANGLED_TRIANGLE, componentColor() ); + addMarker( posMax, endDepth, 12, RiuPlotCurveSymbol::SYMBOL_RIGHT_ANGLED_TRIANGLE, componentColor() ); + addMarker( casingTrackEnd, + endDepth, + 12, + RiuPlotCurveSymbol::SYMBOL_RIGHT_ANGLED_TRIANGLE, + componentColor( 0.0 ), + label() ); } else if ( m_componentType == RiaDefines::WellPathComponentType::LINER ) { addColumnFeature( -0.5, -0.25, startDepth, endDepth, componentColor() ); addColumnFeature( 0.25, 0.5, startDepth, endDepth, componentColor() ); - addMarker( casingTrackEnd, endDepth, 10, RiuQwtSymbol::SYMBOL_RIGHT_ANGLED_TRIANGLE, componentColor( 0.0 ), label() ); + addMarker( casingTrackEnd, + endDepth, + 10, + RiuPlotCurveSymbol::SYMBOL_RIGHT_ANGLED_TRIANGLE, + componentColor( 0.0 ), + label() ); } else if ( m_componentType == RiaDefines::WellPathComponentType::PERFORATION_INTERVAL ) { @@ -200,18 +211,31 @@ void RiuWellPathComponentPlotItem::onLoadDataAndUpdate( bool updateParentPlot ) double markerDepth = startDepth; while ( markerDepth < endDepth - 5 ) { - addMarker( -casingTrackEnd, markerDepth, markerSize, RiuQwtSymbol::SYMBOL_LEFT_ALIGNED_TRIANGLE, componentColor() ); - addMarker( casingTrackEnd, markerDepth, markerSize, RiuQwtSymbol::SYMBOL_RIGHT_ALIGNED_TRIANGLE, componentColor() ); + addMarker( -casingTrackEnd, + markerDepth, + markerSize, + RiuPlotCurveSymbol::SYMBOL_LEFT_ALIGNED_TRIANGLE, + componentColor() ); + addMarker( casingTrackEnd, + markerDepth, + markerSize, + RiuPlotCurveSymbol::SYMBOL_RIGHT_ALIGNED_TRIANGLE, + componentColor() ); markerDepth += markerSpacing; } - addMarker( casingTrackEnd, midDepth, 10, RiuQwtSymbol::SYMBOL_RIGHT_ALIGNED_TRIANGLE, componentColor( 0.0 ), label() ); + addMarker( casingTrackEnd, + midDepth, + 10, + RiuPlotCurveSymbol::SYMBOL_RIGHT_ALIGNED_TRIANGLE, + componentColor( 0.0 ), + label() ); QwtPlotItem* legendItem1 = - createMarker( 16.0, 0.0, 6, RiuQwtSymbol::SYMBOL_RIGHT_ALIGNED_TRIANGLE, componentColor() ); + createMarker( 16.0, 0.0, 6, RiuPlotCurveSymbol::SYMBOL_RIGHT_ALIGNED_TRIANGLE, componentColor() ); legendItem1->setLegendIconSize( QSize( 4, 8 ) ); QwtPlotItem* legendItem2 = - createMarker( 16.0, 8.0, 6, RiuQwtSymbol::SYMBOL_RIGHT_ALIGNED_TRIANGLE, componentColor() ); + createMarker( 16.0, 8.0, 6, RiuPlotCurveSymbol::SYMBOL_RIGHT_ALIGNED_TRIANGLE, componentColor() ); legendItem2->setLegendIconSize( QSize( 4, 8 ) ); m_combinedComponentGroup.addLegendItem( legendItem1 ); m_combinedComponentGroup.addLegendItem( legendItem2 ); @@ -220,7 +244,12 @@ void RiuWellPathComponentPlotItem::onLoadDataAndUpdate( bool updateParentPlot ) { addColumnFeature( -casingTrackEnd, -0.25, startDepth, endDepth, componentColor(), Qt::BDiagPattern ); addColumnFeature( 0.25, casingTrackEnd, startDepth, endDepth, componentColor(), Qt::FDiagPattern ); - addMarker( casingTrackEnd, midDepth, 10, RiuQwtSymbol::SYMBOL_RIGHT_ANGLED_TRIANGLE, componentColor( 0.0 ), label() ); + addMarker( casingTrackEnd, + midDepth, + 10, + RiuPlotCurveSymbol::SYMBOL_RIGHT_ANGLED_TRIANGLE, + componentColor( 0.0 ), + label() ); } else if ( m_componentType == RiaDefines::WellPathComponentType::FRACTURE ) { @@ -229,7 +258,7 @@ void RiuWellPathComponentPlotItem::onLoadDataAndUpdate( bool updateParentPlot ) addMarker( casingTrackEnd, startDepth, 10, - RiuQwtSymbol::SYMBOL_NONE, + RiuPlotCurveSymbol::SYMBOL_NONE, componentColor(), "", Qt::AlignTop | Qt::AlignRight, @@ -238,7 +267,7 @@ void RiuWellPathComponentPlotItem::onLoadDataAndUpdate( bool updateParentPlot ) addMarker( casingTrackEnd, endDepth, 10, - RiuQwtSymbol::SYMBOL_NONE, + RiuPlotCurveSymbol::SYMBOL_NONE, componentColor(), "", Qt::AlignTop | Qt::AlignRight, @@ -247,7 +276,7 @@ void RiuWellPathComponentPlotItem::onLoadDataAndUpdate( bool updateParentPlot ) addMarker( casingTrackEnd, startDepth, 1, - RiuQwtSymbol::SYMBOL_RIGHT_ANGLED_TRIANGLE, + RiuPlotCurveSymbol::SYMBOL_RIGHT_ANGLED_TRIANGLE, componentColor( 0.0f ), label(), Qt::AlignTop | Qt::AlignRight ); @@ -256,34 +285,66 @@ void RiuWellPathComponentPlotItem::onLoadDataAndUpdate( bool updateParentPlot ) { for ( double md : m_subMDs ) { - addMarker( 0.0, md, 16, RiuQwtSymbol::SYMBOL_ELLIPSE, componentColor(), "", Qt::AlignCenter, Qt::Horizontal, false, true ); + addMarker( 0.0, + md, + 16, + RiuPlotCurveSymbol::SYMBOL_ELLIPSE, + componentColor(), + "", + Qt::AlignCenter, + Qt::Horizontal, + false, + true ); } m_combinedComponentGroup.addLegendItem( - createMarker( 0.0, 0.0, 12.0, RiuQwtSymbol::SYMBOL_ELLIPSE, componentColor() ) ); + createMarker( 0.0, 0.0, 12.0, RiuPlotCurveSymbol::SYMBOL_ELLIPSE, componentColor() ) ); } else if ( m_componentType == RiaDefines::WellPathComponentType::ICV ) { for ( double md : m_subMDs ) { - addMarker( 0.0, md, 16, RiuQwtSymbol::SYMBOL_ELLIPSE, componentColor(), "", Qt::AlignCenter, Qt::Horizontal, false, true ); + addMarker( 0.0, + md, + 16, + RiuPlotCurveSymbol::SYMBOL_ELLIPSE, + componentColor(), + "", + Qt::AlignCenter, + Qt::Horizontal, + false, + true ); } m_combinedComponentGroup.addLegendItem( - createMarker( 0.0, 0.0, 12.0, RiuQwtSymbol::SYMBOL_ELLIPSE, componentColor() ) ); + createMarker( 0.0, 0.0, 12.0, RiuPlotCurveSymbol::SYMBOL_ELLIPSE, componentColor() ) ); } else if ( m_componentType == RiaDefines::WellPathComponentType::AICD ) { for ( double md : m_subMDs ) { - addMarker( 0.0, md, 16, RiuQwtSymbol::SYMBOL_ELLIPSE, componentColor(), "", Qt::AlignCenter, Qt::Horizontal, false, true ); + addMarker( 0.0, + md, + 16, + RiuPlotCurveSymbol::SYMBOL_ELLIPSE, + componentColor(), + "", + Qt::AlignCenter, + Qt::Horizontal, + false, + true ); } m_combinedComponentGroup.addLegendItem( - createMarker( 0.0, 0.0, 12.0, RiuQwtSymbol::SYMBOL_ELLIPSE, componentColor() ) ); + createMarker( 0.0, 0.0, 12.0, RiuPlotCurveSymbol::SYMBOL_ELLIPSE, componentColor() ) ); } else if ( m_componentType == RiaDefines::WellPathComponentType::PACKER ) { addColumnFeature( -1.1 * casingTrackEnd, -0.25, startDepth, endDepth, componentColor(), Qt::DiagCrossPattern ); addColumnFeature( 0.25, 1.1 * casingTrackEnd, startDepth, endDepth, componentColor(), Qt::DiagCrossPattern ); - addMarker( casingTrackEnd, midDepth, 10, RiuQwtSymbol::SYMBOL_RIGHT_ANGLED_TRIANGLE, componentColor( 0.0 ), label() ); + addMarker( casingTrackEnd, + midDepth, + 10, + RiuPlotCurveSymbol::SYMBOL_RIGHT_ANGLED_TRIANGLE, + componentColor( 0.0 ), + label() ); } m_combinedComponentGroup.setTitle( legendTitle() ); m_combinedComponentGroup.setLegendIconSize( QSize( 20, 16 ) ); @@ -335,16 +396,16 @@ std::pair RiuWellPathComponentPlotItem::depthsOfDepthType() cons //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuWellPathComponentPlotItem::addMarker( double posX, - double depth, - int size, - RiuQwtSymbol::PointSymbolEnum symbolType, - cvf::Color4f baseColor, - const QString& label /*= QString("")*/, - Qt::Alignment labelAlignment /*= Qt::AlignTop*/, - Qt::Orientation labelOrientation /*= Qt::Vertical*/, - bool drawLine /*= false*/, - bool contrastTextColor /*= true*/ ) +void RiuWellPathComponentPlotItem::addMarker( double posX, + double depth, + int size, + RiuPlotCurveSymbol::PointSymbolEnum symbolType, + cvf::Color4f baseColor, + const QString& label /*= QString("")*/, + Qt::Alignment labelAlignment /*= Qt::AlignTop*/, + Qt::Orientation labelOrientation /*= Qt::Vertical*/, + bool drawLine /*= false*/, + bool contrastTextColor /*= true*/ ) { QwtPlotItem* marker = createMarker( posX, depth, size, symbolType, baseColor, label, labelAlignment, labelOrientation, drawLine, contrastTextColor ); @@ -354,12 +415,12 @@ void RiuWellPathComponentPlotItem::addMarker( double posX //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QwtPlotItem* RiuWellPathComponentPlotItem::createMarker( double posX, - double depth, - int size, - RiuQwtSymbol::PointSymbolEnum symbolType, - cvf::Color4f baseColor, - const QString& label /*= QString("")*/, +QwtPlotItem* RiuWellPathComponentPlotItem::createMarker( double posX, + double depth, + int size, + RiuPlotCurveSymbol::PointSymbolEnum symbolType, + cvf::Color4f baseColor, + const QString& label /*= QString("")*/, Qt::Alignment labelAlignment /*= Qt::AlignTop*/, Qt::Orientation labelOrientation /*= Qt::Vertical*/, bool drawLine /*= false*/, @@ -372,8 +433,8 @@ QwtPlotItem* RiuWellPathComponentPlotItem::createMarker( double textColor = RiaColorTools::toQColor( RiaColorTools::contrastColor( baseColor.toColor3f() ) ); } QwtPlotMarker* marker = new QwtPlotMarker( label ); - RiuQwtSymbol* symbol = new RiuQwtSymbol( symbolType, "", RiuQwtSymbol::LabelRightOfSymbol ); - symbol->setSize( size ); + RiuQwtSymbol* symbol = new RiuQwtSymbol( symbolType, "", RiuPlotCurveSymbol::LabelRightOfSymbol ); + symbol->setSize( size, size ); symbol->setColor( bgColor ); marker->setSymbol( symbol ); marker->setSpacing( 6 ); @@ -512,7 +573,7 @@ void RiuWellPathComponentPlotItem::setContributeToLegend( bool contributeToLegen //-------------------------------------------------------------------------------------------------- void RiuWellPathComponentPlotItem::setParentQwtPlotAndReplot( QwtPlot* plot ) { - setParentQwtPlotNoReplot( plot ); + setParentPlotNoReplot( plot ); if ( m_parentQwtPlot ) { m_parentQwtPlot->replot(); @@ -522,7 +583,7 @@ void RiuWellPathComponentPlotItem::setParentQwtPlotAndReplot( QwtPlot* plot ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuWellPathComponentPlotItem::setParentQwtPlotNoReplot( QwtPlot* plot ) +void RiuWellPathComponentPlotItem::setParentPlotNoReplot( QwtPlot* plot ) { m_parentQwtPlot = plot; attachToQwt(); diff --git a/ApplicationLibCode/UserInterface/RiuWellPathComponentPlotItem.h b/ApplicationLibCode/UserInterface/RiuWellPathComponentPlotItem.h index ec7a452188..3a28088fe7 100644 --- a/ApplicationLibCode/UserInterface/RiuWellPathComponentPlotItem.h +++ b/ApplicationLibCode/UserInterface/RiuWellPathComponentPlotItem.h @@ -68,7 +68,7 @@ class RiuWellPathComponentPlotItem void setContributeToLegend( bool contributeToLegend ); void setParentQwtPlotAndReplot( QwtPlot* plot ); - void setParentQwtPlotNoReplot( QwtPlot* plot ); + void setParentPlotNoReplot( QwtPlot* plot ); void attachToQwt(); void detachFromQwt(); void reattachToQwt(); @@ -80,26 +80,26 @@ class RiuWellPathComponentPlotItem std::pair depthsOfDepthType() const; - void addMarker( double posX, - double depth, - int size, - RiuQwtSymbol::PointSymbolEnum symbolType, - cvf::Color4f baseColor, - const QString& label = QString( "" ), - Qt::Alignment labelAlignment = Qt::AlignVCenter | Qt::AlignRight, - Qt::Orientation labelOrientation = Qt::Horizontal, - bool drawLine = false, - bool contrastTextColor = false ); - QwtPlotItem* createMarker( double posX, - double depth, - int size, - RiuQwtSymbol::PointSymbolEnum symbolType, - cvf::Color4f baseColor, - const QString& label = QString( "" ), - Qt::Alignment labelAlignment = Qt::AlignVCenter | Qt::AlignRight, - Qt::Orientation labelOrientation = Qt::Horizontal, - bool drawLine = false, - bool contrastTextColor = false ); + void addMarker( double posX, + double depth, + int size, + RiuPlotCurveSymbol::PointSymbolEnum symbolType, + cvf::Color4f baseColor, + const QString& label = QString( "" ), + Qt::Alignment labelAlignment = Qt::AlignVCenter | Qt::AlignRight, + Qt::Orientation labelOrientation = Qt::Horizontal, + bool drawLine = false, + bool contrastTextColor = false ); + QwtPlotItem* createMarker( double posX, + double depth, + int size, + RiuPlotCurveSymbol::PointSymbolEnum symbolType, + cvf::Color4f baseColor, + const QString& label = QString( "" ), + Qt::Alignment labelAlignment = Qt::AlignVCenter | Qt::AlignRight, + Qt::Orientation labelOrientation = Qt::Horizontal, + bool drawLine = false, + bool contrastTextColor = false ); void addColumnFeature( double startX, double endX, double startDepth, diff --git a/CMakeLists.txt b/CMakeLists.txt index 475c1a9071..5af32ce03b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -226,12 +226,25 @@ else() COMPILE_FLAGS "/wd4244 /wd4267 /wd4013 /wd4190 /wd4018 /wd4477 /wd4098 /wd4293 /wd4305 /wd4020 /wd4028 /wd4715 /wd4245 /wd4804 /wd4100 /wd4456 /wd4458 /wd4090 /wd4297 /wd4701 /wd4101 /wd4702 /wd4457" ) + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + set_target_properties( + ecl + PROPERTIES + COMPILE_FLAGS + "-Wno-deprecated -Wno-deprecated-declarations -Wno-sign-compare" + ) else() set_target_properties( ecl - PROPERTIES COMPILE_FLAGS - "-Wno-deprecated -Wno-deprecated-declarations -Wno-clobbered" + PROPERTIES + COMPILE_FLAGS + "-Wno-deprecated -Wno-deprecated-declarations -Wno-clobbered -Wno-int-in-bool-context" + ) + + target_compile_options( + ecl PRIVATE $<$:-Wno-class-memaccess> ) + endif() list(APPEND THIRD_PARTY_LIBRARIES ecl) @@ -251,7 +264,7 @@ set(CMAKE_CXX_COMPILER_LAUNCHER ${TEMP_CMAKE_CXX_COMPILER_LAUNCHER}) # ############################################################################## # Go through required git submodules # # ############################################################################## -list(APPEND THIRD_PARTY_SUBMODULES qwt) +list(APPEND THIRD_PARTY_SUBMODULES fast_float qwt) # ############################################################################## # Init GIT submodules if they haven't already # @@ -385,8 +398,10 @@ list(APPEND THIRD_PARTY_LIBRARIES NRLib) # ############################################################################## # Qt # ############################################################################## +set(RI_QT_MINIMUM_VERSION 5.12) + find_package( - Qt5 + Qt5 ${RI_QT_MINIMUM_VERSION} COMPONENTS Core Gui OpenGL @@ -394,24 +409,41 @@ find_package( Script ScriptTools Widgets - OPTIONAL_COMPONENTS Charts ) -if(Qt5Charts_FOUND) - message(STATUS "QtCharts found: ${Qt5Charts_LIBRARIES}") - add_definitions(-DUSE_QTCHARTS) -else() - message(STATUS "QtCharts missing.") -endif() # Open GL find_package(OpenGL) +# ############################################################################## +# QtCharts +# ############################################################################## +option(RESINSIGHT_USE_QT_CHARTS "Enable QtCharts in the code" ON) +if(RESINSIGHT_USE_QT_CHARTS) + find_package(Qt5 OPTIONAL_COMPONENTS Charts) + + if(Qt5Charts_FOUND) + message(STATUS "QtCharts found: ${Qt5Charts_LIBRARIES}") + add_definitions(-DUSE_QTCHARTS) + else() + message(STATUS "QtCharts not found.") + set(RESINSIGHT_USE_QT_CHARTS OFF) + endif() +endif() + # ############################################################################## # Qwt # ############################################################################## add_subdirectory(ThirdParty/qwt) +if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + target_compile_options(qwt PRIVATE -Wno-deprecated-copy) +elseif(MSVC) + target_compile_options(qwt PRIVATE /wd4996 /wd4005) +elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + target_compile_options(qwt PRIVATE -Wno-deprecated) +endif() + if(RESINSIGHT_ENABLE_UNITY_BUILD) message("Cmake Unity build is enabled on : qwt") set_property(TARGET qwt PROPERTY UNITY_BUILD true) @@ -428,6 +460,11 @@ list(APPEND THIRD_PARTY_LIBRARIES qwt) # ############################################################################## add_subdirectory(ThirdParty/nightcharts) +if(MSVC) + target_compile_options(nightcharts PRIVATE /wd4996) +elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + target_compile_options(nightcharts PRIVATE -Wno-deprecated) +endif() list(APPEND THIRD_PARTY_LIBRARIES nightcharts) @@ -437,6 +474,10 @@ list(APPEND THIRD_PARTY_LIBRARIES nightcharts) add_subdirectory(ThirdParty/expressionparser) +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + target_compile_options(expressionparser PUBLIC -Wno-overloaded-virtual) +endif() + list(APPEND THIRD_PARTY_LIBRARIES expressionparser) # ############################################################################## @@ -445,6 +486,10 @@ list(APPEND THIRD_PARTY_LIBRARIES expressionparser) add_subdirectory(ThirdParty/clipper) +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + target_compile_options(clipper PUBLIC -Wno-deprecated-copy) +endif() + list(APPEND THIRD_PARTY_LIBRARIES clipper) # ############################################################################## @@ -500,6 +545,17 @@ list( LibCore ) +if(MSVC) + target_compile_options(LibGuiQt PRIVATE /wd4996) +endif() + +if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + target_compile_options( + LibRender PRIVATE -Wno-undefined-var-template -Wno-invalid-source-encoding + -Wno-null-pointer-arithmetic + ) +endif() + set_property(TARGET ${VIZ_FWK_LIBRARIES} PROPERTY FOLDER "VizFwk") # ############################################################################## @@ -517,8 +573,10 @@ add_subdirectory(Fwk/AppFwk/cafProjectDataModel) add_subdirectory(Fwk/AppFwk/cafCommand) add_subdirectory(Fwk/AppFwk/cafUserInterface) add_subdirectory(Fwk/AppFwk/cafPdmCvf) + add_subdirectory(Fwk/AppFwk/CommonCode) add_subdirectory(Fwk/AppFwk/cafVizExtensions) + option(CAF_CVF_SCRIPTING "" ON) add_subdirectory(Fwk/AppFwk/cafPdmScripting) set_property(TARGET cafPdmScripting PROPERTY FOLDER "AppFwk") @@ -529,6 +587,32 @@ set_property(TARGET cafCommandFeatures PROPERTY FOLDER "AppFwk") add_subdirectory(Fwk/AppFwk/cafTensor) add_subdirectory(Fwk/AppFwk/cafHexInterpolator) +if(MSVC) + target_compile_options(cafViewer PRIVATE /wd4996) + target_compile_options(cafPdmCore PRIVATE /wd4996) + target_compile_options(cafPdmCore PRIVATE /wd4996) + target_compile_options(cafPdmXml PRIVATE /wd4996) + target_compile_options(cafUserInterface PRIVATE /wd4996) +endif() + +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + target_compile_options(cafCommandFeatures PRIVATE -Wno-deprecated-copy) +endif() + +if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + target_compile_options( + CommonCode PRIVATE -Wno-deprecated-copy -Wno-undefined-var-template + ) + target_compile_options( + cafCommandFeatures PRIVATE -Wno-deprecated-copy -Wno-undefined-var-template + ) + target_compile_options( + cafVizExtensions PRIVATE -Wno-deprecated-copy -Wno-undefined-var-template + -Wno-invalid-source-encoding + ) + target_compile_options(cafUserInterface PRIVATE -Wno-null-pointer-arithmetic) +endif() + list( APPEND APP_FWK_LIBRARIES @@ -570,6 +654,9 @@ if(RESINSIGHT_INCLUDE_APPFWK_TESTS) add_subdirectory(Fwk/AppFwk/cafPdmScripting/cafPdmScripting_UnitTests) set_property(TARGET cafPdmScripting_UnitTests PROPERTY FOLDER "AppFwkTests") + add_subdirectory(Fwk/AppFwk/cafUserInterface/cafUserInterface_UnitTests) + set_property(TARGET cafUserInterface_UnitTests PROPERTY FOLDER "AppFwkTests") + # Executables add_subdirectory(Fwk/AppFwk/cafTests/cafTestApplication) set_property(TARGET cafTestApplication PROPERTY FOLDER "AppFwkTests") diff --git a/Fwk/AppFwk/CommonCode/cafMouseState.cpp b/Fwk/AppFwk/CommonCode/cafMouseState.cpp index db8d7b09c3..53348763e2 100644 --- a/Fwk/AppFwk/CommonCode/cafMouseState.cpp +++ b/Fwk/AppFwk/CommonCode/cafMouseState.cpp @@ -237,7 +237,7 @@ int QtMouseState::numMouseButtonsInState( Qt::MouseButtons buttonState ) if ( buttonState & Qt::LeftButton ) iNum++; if ( buttonState & Qt::RightButton ) iNum++; - if ( buttonState & Qt::MidButton ) iNum++; + if ( buttonState & Qt::MiddleButton ) iNum++; return iNum; } diff --git a/Fwk/AppFwk/cafCommand/cafCmdFeatureManager.cpp b/Fwk/AppFwk/cafCommand/cafCmdFeatureManager.cpp index 4df8ce8dba..88bd4470f0 100644 --- a/Fwk/AppFwk/cafCommand/cafCmdFeatureManager.cpp +++ b/Fwk/AppFwk/cafCommand/cafCmdFeatureManager.cpp @@ -46,6 +46,9 @@ namespace caf { typedef Factory CommandFeatureFactory; + +CmdFeatureManager* CmdFeatureManager::sm_singleton = nullptr; + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -67,6 +70,18 @@ CmdFeatureManager::CmdFeatureManager() //-------------------------------------------------------------------------------------------------- CmdFeatureManager::~CmdFeatureManager() { + releaseAllCommandFeatures(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void CmdFeatureManager::createSingleton() +{ + if ( !sm_singleton ) + { + sm_singleton = new CmdFeatureManager; + } } //-------------------------------------------------------------------------------------------------- @@ -74,8 +89,8 @@ CmdFeatureManager::~CmdFeatureManager() //-------------------------------------------------------------------------------------------------- CmdFeatureManager* CmdFeatureManager::instance() { - static CmdFeatureManager* singleton = new CmdFeatureManager; - return singleton; + CAF_ASSERT( sm_singleton ); + return sm_singleton; } //-------------------------------------------------------------------------------------------------- @@ -345,4 +360,25 @@ QWidget* CmdFeatureManager::currentContextMenuTargetWidget() return m_currentContextMenuTargetWidget; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void CmdFeatureManager::releaseAllCommandFeatures() +{ + for ( auto c : m_commandFeatures ) + { + if ( c ) delete c; + c = nullptr; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void CmdFeatureManager::deleteSingleton() +{ + if ( sm_singleton ) delete sm_singleton; + sm_singleton = nullptr; +} + } // end namespace caf diff --git a/Fwk/AppFwk/cafCommand/cafCmdFeatureManager.h b/Fwk/AppFwk/cafCommand/cafCmdFeatureManager.h index 5128320d8d..518dbab7ca 100644 --- a/Fwk/AppFwk/cafCommand/cafCmdFeatureManager.h +++ b/Fwk/AppFwk/cafCommand/cafCmdFeatureManager.h @@ -63,6 +63,9 @@ class CmdFeatureManager : public QObject static CmdFeatureManager* instance(); ~CmdFeatureManager() override; + static void createSingleton(); + static void deleteSingleton(); + QAction* action( const QString& commandId ); QAction* action( const QString& commandId, const QString& customActionText ); QAction* actionWithUserData( const QString& commandId, const QString& customActionText, const QVariant& userData ); @@ -86,7 +89,11 @@ class CmdFeatureManager : public QObject CmdFeature* commandFeature( const std::string& commandId ) const; + void releaseAllCommandFeatures(); + private: + static CmdFeatureManager* sm_singleton; + std::vector m_commandFeatures; std::map m_commandIdToFeatureIdxMap; std::map m_actionToFeatureIdxMap; diff --git a/Fwk/AppFwk/cafCommand/cafCmdFieldChangeExec.cpp b/Fwk/AppFwk/cafCommand/cafCmdFieldChangeExec.cpp index d356a565d3..4b27c7d692 100644 --- a/Fwk/AppFwk/cafCommand/cafCmdFieldChangeExec.cpp +++ b/Fwk/AppFwk/cafCommand/cafCmdFieldChangeExec.cpp @@ -41,39 +41,38 @@ namespace caf { -CAF_PDM_SOURCE_INIT( CmdFieldChangeExecData, "CmdFieldChangeExecData" ); - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- QString CmdFieldChangeExec::name() { - PdmFieldHandle* field = - PdmReferenceHelper::fieldFromReference( m_commandData->m_rootObject, m_commandData->m_pathToField ); - if ( field ) + if ( !m_commandData->m_pathToFields.empty() ) { - QString fieldText; - - PdmUiFieldHandle* uiFieldHandle = field->uiCapability(); - if ( uiFieldHandle ) + PdmFieldHandle* field = + PdmReferenceHelper::fieldFromReference( m_commandData->m_rootObject, m_commandData->m_pathToFields.front() ); + if ( field ) { - fieldText = QString( "Change field '%1'" ).arg( uiFieldHandle->uiName() ); - } + QString fieldText; - if ( field->ownerObject() ) - { - PdmUiObjectHandle* uiObjHandle = uiObj( field->ownerObject() ); - if ( uiObjHandle ) + PdmUiFieldHandle* uiFieldHandle = field->uiCapability(); + if ( uiFieldHandle ) { - fieldText += QString( " in '%1'" ).arg( uiObjHandle->uiName() ); + fieldText = QString( "Change field '%1'" ).arg( uiFieldHandle->uiName() ); } + + if ( field->ownerObject() ) + { + PdmUiObjectHandle* uiObjHandle = uiObj( field->ownerObject() ); + if ( uiObjHandle ) + { + fieldText += QString( " in '%1'" ).arg( uiObjHandle->uiName() ); + } + } + return fieldText; } - return fieldText; - } - else - { - return m_commandData->classKeyword(); } + + return "Field Changed"; } //-------------------------------------------------------------------------------------------------- @@ -81,53 +80,88 @@ QString CmdFieldChangeExec::name() //-------------------------------------------------------------------------------------------------- void CmdFieldChangeExec::redo() { - PdmFieldHandle* field = - PdmReferenceHelper::fieldFromReference( m_commandData->m_rootObject, m_commandData->m_pathToField ); - if ( !field ) - { - CAF_ASSERT( false ); - return; - } + m_commandData->m_undoFieldValueSerialized.resize( m_commandData->m_pathToFields.size() ); - PdmUiFieldHandle* uiFieldHandle = field->uiCapability(); - PdmXmlFieldHandle* xmlFieldHandle = field->xmlCapability(); - if ( uiFieldHandle && xmlFieldHandle ) + for ( size_t i = 0; i < m_commandData->m_pathToFields.size(); i++ ) { - if ( m_commandData->m_redoFieldValueSerialized.isEmpty() ) + auto fieldTextPath = m_commandData->m_pathToFields[i]; + + PdmFieldHandle* field = PdmReferenceHelper::fieldFromReference( m_commandData->m_rootObject, fieldTextPath ); + if ( !field ) continue; + + bool objectFlag = false; + PdmObjectHandle* obj = field->ownerObject(); + auto uiObjectHandle = uiObj( obj ); + if ( uiObjectHandle ) { - // We end up here only when the user actually has done something in the actual living Gui editor. - { - QXmlStreamWriter xmlStream( &m_commandData->m_undoFieldValueSerialized ); - writeFieldDataToValidXmlDocument( xmlStream, xmlFieldHandle ); - } + objectFlag = uiObjectHandle->notifyAllFieldsInMultiFieldChangedEvents(); - // This function will notify field change, no need to explicitly call notification - // The ui value might be an index into the option entry cache, so we need to set the value - // and be aware of the option entries, and then serialize the actual field value we ended up with. + // Make sure that uiOrdering has been called on all objects, as some object do some state initialization. + // This is relevant for data source stepping objects. This operation could be made into a virtual function. + caf::PdmUiOrdering ordering; + uiObjectHandle->uiOrdering( "", ordering ); + } - uiFieldHandle->setValueFromUiEditor( m_commandData->m_newUiValue ); + PdmUiFieldHandle* uiFieldHandle = field->uiCapability(); + PdmXmlFieldHandle* xmlFieldHandle = field->xmlCapability(); + if ( uiFieldHandle && xmlFieldHandle ) + { + // In multi field update operations, a single fieldChanged() notification is sufficient for many use cases + // where properties like color/size are modified. For control operations like changing the data source + // for multiple sub objects, we need to issue fieldChanged() for all modified fields. This behaviour can be + // forced both on object level and field level + + bool isLastField = ( i == m_commandData->m_pathToFields.size() - 1 ); + bool sendFieldChangedNotification = isLastField; + if ( objectFlag ) sendFieldChangedNotification = true; + if ( uiFieldHandle->notifyAllFieldsInMultiFieldChangedEvents() ) sendFieldChangedNotification = true; + if ( m_commandData->m_undoFieldValueSerialized[i].isEmpty() ) { - QXmlStreamWriter xmlStream( &m_commandData->m_redoFieldValueSerialized ); - writeFieldDataToValidXmlDocument( xmlStream, xmlFieldHandle ); + // We end up here only when the user actually has done something in the actual living Gui editor. + { + QXmlStreamWriter xmlStream( &m_commandData->m_undoFieldValueSerialized[i] ); + writeFieldDataToValidXmlDocument( xmlStream, xmlFieldHandle ); + } + + // This function will notify field change, no need to explicitly call notification + // The ui value might be an index into the option entry cache, so we need to set the value + // and be aware of the option entries, and then serialize the actual field value we ended up with. + + uiFieldHandle->setValueFromUiEditor( m_commandData->m_newUiValue, sendFieldChangedNotification ); + + if ( m_commandData->m_redoFieldValueSerialized.isEmpty() ) + { + QXmlStreamWriter xmlStream( &m_commandData->m_redoFieldValueSerialized ); + writeFieldDataToValidXmlDocument( xmlStream, xmlFieldHandle ); + } } - } - else - { - QVariant oldFieldData = uiFieldHandle->toUiBasedQVariant(); + else + { + QVariant oldFieldData = uiFieldHandle->toUiBasedQVariant(); - QXmlStreamReader xmlStream( m_commandData->m_redoFieldValueSerialized ); + QXmlStreamReader xmlStream( m_commandData->m_redoFieldValueSerialized ); - readFieldValueFromValidXmlDocument( xmlStream, xmlFieldHandle ); + readFieldValueFromValidXmlDocument( xmlStream, xmlFieldHandle ); - QVariant newFieldData = uiFieldHandle->toUiBasedQVariant(); + QVariant newFieldData = uiFieldHandle->toUiBasedQVariant(); - // New data is present in field, notify data changed - uiFieldHandle->notifyFieldChanged( oldFieldData, newFieldData ); + // New data is present in field, notify data changed + if ( sendFieldChangedNotification ) + { + uiFieldHandle->notifyFieldChanged( oldFieldData, newFieldData ); + if ( m_notificationCenter ) + m_notificationCenter->notifyObserversOfDataChange( field->ownerObject() ); + } + } } } - if ( m_notificationCenter ) m_notificationCenter->notifyObserversOfDataChange( field->ownerObject() ); + if ( m_commandData->m_ownerOfChildArrayField && m_commandData->m_childArrayFieldHandle ) + { + std::vector objs; + m_commandData->m_ownerOfChildArrayField->onChildrenUpdated( m_commandData->m_childArrayFieldHandle, objs ); + } } //-------------------------------------------------------------------------------------------------- @@ -135,30 +169,40 @@ void CmdFieldChangeExec::redo() //-------------------------------------------------------------------------------------------------- void CmdFieldChangeExec::undo() { - PdmFieldHandle* field = - PdmReferenceHelper::fieldFromReference( m_commandData->m_rootObject, m_commandData->m_pathToField ); - if ( !field ) + for ( size_t i = 0; i < m_commandData->m_pathToFields.size(); i++ ) { - CAF_ASSERT( false ); - return; - } + auto fieldTextPath = m_commandData->m_pathToFields[i]; - PdmUiFieldHandle* uiFieldHandle = field->uiCapability(); - PdmXmlFieldHandle* xmlFieldHandle = field->xmlCapability(); - if ( uiFieldHandle && xmlFieldHandle ) - { - QXmlStreamReader xmlStream( m_commandData->m_undoFieldValueSerialized ); - QVariant oldFieldData = uiFieldHandle->toUiBasedQVariant(); + PdmFieldHandle* field = PdmReferenceHelper::fieldFromReference( m_commandData->m_rootObject, fieldTextPath ); + if ( !field ) continue; - readFieldValueFromValidXmlDocument( xmlStream, xmlFieldHandle ); + PdmUiFieldHandle* uiFieldHandle = field->uiCapability(); + PdmXmlFieldHandle* xmlFieldHandle = field->xmlCapability(); + if ( uiFieldHandle && xmlFieldHandle ) + { + bool isLastField = ( i == m_commandData->m_pathToFields.size() - 1 ); + + QXmlStreamReader xmlStream( m_commandData->m_undoFieldValueSerialized[i] ); + QVariant oldFieldData = uiFieldHandle->toUiBasedQVariant(); + + readFieldValueFromValidXmlDocument( xmlStream, xmlFieldHandle ); - QVariant newFieldData = uiFieldHandle->toUiBasedQVariant(); + QVariant newFieldData = uiFieldHandle->toUiBasedQVariant(); - // New data is present in field, notify data changed - uiFieldHandle->notifyFieldChanged( oldFieldData, newFieldData ); + // New data is present in field, notify data changed + if ( isLastField ) + { + uiFieldHandle->notifyFieldChanged( oldFieldData, newFieldData ); + if ( m_notificationCenter ) m_notificationCenter->notifyObserversOfDataChange( field->ownerObject() ); + } + } } - if ( m_notificationCenter ) m_notificationCenter->notifyObserversOfDataChange( field->ownerObject() ); + if ( m_commandData->m_ownerOfChildArrayField && m_commandData->m_childArrayFieldHandle ) + { + std::vector objs; + m_commandData->m_ownerOfChildArrayField->onChildrenUpdated( m_commandData->m_childArrayFieldHandle, objs ); + } } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafCommand/cafCmdFieldChangeExec.h b/Fwk/AppFwk/cafCommand/cafCmdFieldChangeExec.h index e21c07ebee..3c4014aed2 100644 --- a/Fwk/AppFwk/cafCommand/cafCmdFieldChangeExec.h +++ b/Fwk/AppFwk/cafCommand/cafCmdFieldChangeExec.h @@ -40,35 +40,32 @@ #include "cafPdmField.h" #include "cafPdmObject.h" +#include + namespace caf { -class PdmChildArrayFieldHandle; - //================================================================================================== /// //================================================================================================== -class CmdFieldChangeExecData : public PdmObject +class CmdFieldChangeExecData { - CAF_PDM_HEADER_INIT; - public: CmdFieldChangeExecData() + : m_rootObject( nullptr ) + , m_childArrayFieldHandle( nullptr ) + , m_ownerOfChildArrayField( nullptr ) { - CAF_PDM_InitObject( "CmdFieldChangeExecData uiName", - "", - "CmdFieldChangeExecData tooltip", - "CmdFieldChangeExecData whatsthis" ); - - CAF_PDM_InitField( &m_pathToField, "PathToField", QString(), "PathToField", "", "PathToField tooltip", "PathToField whatsthis" ); } caf::PdmPointer m_rootObject; + PdmChildArrayFieldHandle* m_childArrayFieldHandle; + PdmObjectHandle* m_ownerOfChildArrayField; - PdmField m_pathToField; - QVariant m_newUiValue; // QVariant coming from the UI + std::vector m_pathToFields; + std::vector m_undoFieldValueSerialized; - QString m_undoFieldValueSerialized; - QString m_redoFieldValueSerialized; + QVariant m_newUiValue; + QString m_redoFieldValueSerialized; }; //================================================================================================== diff --git a/Fwk/AppFwk/cafCommand/cafCmdUiCommandSystemImpl.cpp b/Fwk/AppFwk/cafCommand/cafCmdUiCommandSystemImpl.cpp index 34fd552843..6019d1c3c2 100644 --- a/Fwk/AppFwk/cafCommand/cafCmdUiCommandSystemImpl.cpp +++ b/Fwk/AppFwk/cafCommand/cafCmdUiCommandSystemImpl.cpp @@ -40,10 +40,10 @@ #include "cafCmdExecuteCommand.h" #include "cafCmdFeatureManager.h" #include "cafCmdFieldChangeExec.h" - +#include "cafPdmChildArrayField.h" #include "cafPdmFieldHandle.h" +#include "cafPdmObjectHandle.h" #include "cafPdmUiObjectHandle.h" - #include "cafSelectionManager.h" #include @@ -71,45 +71,64 @@ void CmdUiCommandSystemImpl::fieldChangedCommand( const std::vector commands; - for ( size_t i = 0; i < fieldsToUpdate.size(); i++ ) + PdmChildArrayFieldHandle* childArrayFieldHandle = nullptr; + PdmObjectHandle* ownerOfChildArrayField = nullptr; + PdmObjectHandle* rootObjHandle = nullptr; + + auto firstField = fieldsToUpdate.front(); + if ( firstField ) + { + // Find the first childArrayField by traversing parent field and objects. Usually, the childArrayField is + // the parent, but in some cases when we change fields in a sub-object of the object we need to traverse + // more levels + + ownerOfChildArrayField = firstField->ownerObject(); + while ( ownerOfChildArrayField ) + { + if ( ownerOfChildArrayField->parentField() ) + { + childArrayFieldHandle = + dynamic_cast( ownerOfChildArrayField->parentField() ); + ownerOfChildArrayField = ownerOfChildArrayField->parentField()->ownerObject(); + + if ( childArrayFieldHandle && ownerOfChildArrayField ) break; + } + else + { + ownerOfChildArrayField = nullptr; + } + } + + rootObjHandle = PdmReferenceHelper::findRoot( firstField ); + } + + std::vector pathsToFields; + for ( caf::PdmFieldHandle* field : fieldsToUpdate ) { - PdmFieldHandle* field = fieldsToUpdate[i]; PdmUiFieldHandle* uiFieldHandle = field->uiCapability(); if ( uiFieldHandle ) { QVariant fieldCurrentUiValue = uiFieldHandle->uiValue(); - if ( fieldCurrentUiValue != newUiValue ) { - PdmObjectHandle* rootObjHandle = PdmReferenceHelper::findRoot( field ); - - QString reference = PdmReferenceHelper::referenceFromRootToField( rootObjHandle, field ); - if ( reference.isEmpty() ) + QString pathToField = PdmReferenceHelper::referenceFromRootToField( rootObjHandle, field ); + if ( !pathToField.isEmpty() ) { - CAF_ASSERT( false ); - return; + pathsToFields.push_back( pathToField ); } - - CmdFieldChangeExec* fieldChangeExec = - new CmdFieldChangeExec( SelectionManager::instance()->notificationCenter() ); - - fieldChangeExec->commandData()->m_newUiValue = newUiValue; - fieldChangeExec->commandData()->m_pathToField = reference; - fieldChangeExec->commandData()->m_rootObject = rootObjHandle; - - commands.push_back( fieldChangeExec ); } } } - if ( commands.size() == 1 ) - { - CmdExecCommandManager::instance()->processExecuteCommand( commands[0] ); - } - else - { - CmdExecCommandManager::instance()->processExecuteCommandsAsMacro( commands ); - } + auto* fieldChangeExec = new CmdFieldChangeExec( SelectionManager::instance()->notificationCenter() ); + + fieldChangeExec->commandData()->m_newUiValue = newUiValue; + fieldChangeExec->commandData()->m_pathToFields = pathsToFields; + fieldChangeExec->commandData()->m_rootObject = rootObjHandle; + fieldChangeExec->commandData()->m_ownerOfChildArrayField = ownerOfChildArrayField; + fieldChangeExec->commandData()->m_childArrayFieldHandle = childArrayFieldHandle; + + CmdExecCommandManager::instance()->processExecuteCommand( fieldChangeExec ); } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafCommandFeatures/AddAndDelete/cafCmdAddItemExec.cpp b/Fwk/AppFwk/cafCommandFeatures/AddAndDelete/cafCmdAddItemExec.cpp index 3779c34405..83a7831eb0 100644 --- a/Fwk/AppFwk/cafCommandFeatures/AddAndDelete/cafCmdAddItemExec.cpp +++ b/Fwk/AppFwk/cafCommandFeatures/AddAndDelete/cafCmdAddItemExec.cpp @@ -123,7 +123,7 @@ void CmdAddItemExec::undo() if ( listField && m_commandData->m_createdItemIndex >= 0 ) { std::vector children; - listField->childObjects( &children ); + listField->children( &children ); caf::PdmObjectHandle* obj = children[m_commandData->m_createdItemIndex]; diff --git a/Fwk/AppFwk/cafCommandFeatures/AddAndDelete/cafCmdDeleteItemExec.cpp b/Fwk/AppFwk/cafCommandFeatures/AddAndDelete/cafCmdDeleteItemExec.cpp index ae3c873b8c..3ff19477bb 100644 --- a/Fwk/AppFwk/cafCommandFeatures/AddAndDelete/cafCmdDeleteItemExec.cpp +++ b/Fwk/AppFwk/cafCommandFeatures/AddAndDelete/cafCmdDeleteItemExec.cpp @@ -66,7 +66,7 @@ void CmdDeleteItemExec::redo() if ( listField ) { std::vector children; - listField->childObjects( &children ); + listField->children( &children ); PdmObjectHandle* obj = children[m_commandData->m_indexToObject]; caf::SelectionManager::instance()->removeObjectFromAllSelections( obj ); diff --git a/Fwk/AppFwk/cafCommandFeatures/AddAndDelete/cafCmdDeleteItemFeature.cpp b/Fwk/AppFwk/cafCommandFeatures/AddAndDelete/cafCmdDeleteItemFeature.cpp index 166777e4dc..1ec852d5e4 100644 --- a/Fwk/AppFwk/cafCommandFeatures/AddAndDelete/cafCmdDeleteItemFeature.cpp +++ b/Fwk/AppFwk/cafCommandFeatures/AddAndDelete/cafCmdDeleteItemFeature.cpp @@ -79,7 +79,7 @@ CmdExecuteCommand* CmdDeleteItemFeature::createExecuteCommand() int indexAfter = -1; std::vector childObjects; - childArrayFieldHandle->childObjects( &childObjects ); + childArrayFieldHandle->children( &childObjects ); for ( size_t i = 0; i < childObjects.size(); i++ ) { diff --git a/Fwk/AppFwk/cafCommandFeatures/ToggleCommands/cafToggleItemsFeatureImpl.cpp b/Fwk/AppFwk/cafCommandFeatures/ToggleCommands/cafToggleItemsFeatureImpl.cpp index 5444d7b91e..4a91543dd8 100644 --- a/Fwk/AppFwk/cafCommandFeatures/ToggleCommands/cafToggleItemsFeatureImpl.cpp +++ b/Fwk/AppFwk/cafCommandFeatures/ToggleCommands/cafToggleItemsFeatureImpl.cpp @@ -194,10 +194,10 @@ caf::PdmUiTreeOrdering* ToggleItemsFeatureImpl::findTreeItemFromSelectedUiItem( if ( pdmUiTreeView ) { QModelIndex modIndex = pdmUiTreeView->findModelIndex( uiItem ); - return static_cast( modIndex.internalPointer() ); + return pdmUiTreeView->uiTreeOrderingFromModelIndex( modIndex ); } return nullptr; } -} // namespace caf \ No newline at end of file +} // namespace caf diff --git a/Fwk/AppFwk/cafCommandFeatures/ToggleCommands/cafToggleItemsOnOthersOffFeature.cpp b/Fwk/AppFwk/cafCommandFeatures/ToggleCommands/cafToggleItemsOnOthersOffFeature.cpp index c44e94f9e4..a43373c6c2 100644 --- a/Fwk/AppFwk/cafCommandFeatures/ToggleCommands/cafToggleItemsOnOthersOffFeature.cpp +++ b/Fwk/AppFwk/cafCommandFeatures/ToggleCommands/cafToggleItemsOnOthersOffFeature.cpp @@ -141,7 +141,7 @@ std::vector ToggleItemsOnOthersOffFeature::childObjects( std::vector children; if ( parent ) { - parent->childObjects( &children ); + parent->children( &children ); } return children; } @@ -159,4 +159,4 @@ caf::PdmField* ToggleItemsOnOthersOffFeature::objectToggleField( caf::PdmO return nullptr; } -} // namespace caf \ No newline at end of file +} // namespace caf diff --git a/Fwk/AppFwk/cafPdmCvf/cafPdmMat3d/cafPdmUiCoreMat3d.h b/Fwk/AppFwk/cafPdmCvf/cafPdmMat3d/cafPdmUiCoreMat3d.h index 6fee9bd031..f5ea85d59f 100644 --- a/Fwk/AppFwk/cafPdmCvf/cafPdmMat3d/cafPdmUiCoreMat3d.h +++ b/Fwk/AppFwk/cafPdmCvf/cafPdmMat3d/cafPdmUiCoreMat3d.h @@ -69,10 +69,7 @@ class PdmUiFieldSpecialization } /// Methods to get a list of options for a field, specialized for AppEnum - static QList valueOptions( bool* useOptionsOnly, const cvf::Mat3d& ) - { - return QList(); - } + static QList valueOptions( const cvf::Mat3d& ) { return QList(); } /// Methods to retrieve the possible PdmObject pointed to by a field static void childObjects( const PdmDataValueField&, std::vector* ) {} diff --git a/Fwk/AppFwk/cafPdmCvf/cafPdmUiCoreColor3f.h b/Fwk/AppFwk/cafPdmCvf/cafPdmUiCoreColor3f.h index fe8f6cf8b3..656b9a690e 100644 --- a/Fwk/AppFwk/cafPdmCvf/cafPdmUiCoreColor3f.h +++ b/Fwk/AppFwk/cafPdmCvf/cafPdmUiCoreColor3f.h @@ -69,10 +69,7 @@ class PdmUiFieldSpecialization } /// Methods to get a list of options for a field, specialized for AppEnum - static QList valueOptions( bool* useOptionsOnly, const cvf::Color3f& ) - { - return QList(); - } + static QList valueOptions( const cvf::Color3f& ) { return QList(); } /// Methods to retrieve the possible PdmObject pointed to by a field static void childObjects( const PdmDataValueField&, std::vector* ) {} diff --git a/Fwk/AppFwk/cafPdmCvf/cafPdmUiCoreMat4d.h b/Fwk/AppFwk/cafPdmCvf/cafPdmUiCoreMat4d.h index 5c56a271f1..25902dd8ab 100644 --- a/Fwk/AppFwk/cafPdmCvf/cafPdmUiCoreMat4d.h +++ b/Fwk/AppFwk/cafPdmCvf/cafPdmUiCoreMat4d.h @@ -69,10 +69,7 @@ class PdmUiFieldSpecialization } /// Methods to get a list of options for a field, specialized for AppEnum - static QList valueOptions( bool* useOptionsOnly, const cvf::Mat4d& ) - { - return QList(); - } + static QList valueOptions( const cvf::Mat4d& ) { return QList(); } /// Methods to retrieve the possible PdmObject pointed to by a field static void childObjects( const PdmDataValueField&, std::vector* ) {} diff --git a/Fwk/AppFwk/cafPdmCvf/cafPdmUiCoreVec3d.h b/Fwk/AppFwk/cafPdmCvf/cafPdmUiCoreVec3d.h index 817bd45ddf..073f34da31 100644 --- a/Fwk/AppFwk/cafPdmCvf/cafPdmUiCoreVec3d.h +++ b/Fwk/AppFwk/cafPdmCvf/cafPdmUiCoreVec3d.h @@ -69,10 +69,7 @@ class PdmUiFieldSpecialization } /// Methods to get a list of options for a field, specialized for AppEnum - static QList valueOptions( bool* useOptionsOnly, const cvf::Vec3d& ) - { - return QList(); - } + static QList valueOptions( const cvf::Vec3d& ) { return QList(); } /// Methods to retrieve the possible PdmObject pointed to by a field static void childObjects( const PdmDataValueField&, std::vector* ) {} diff --git a/Fwk/AppFwk/cafPdmScripting/cafPdmFieldScriptingCapability.h b/Fwk/AppFwk/cafPdmScripting/cafPdmFieldScriptingCapability.h index 491307c6c8..d096d5f9c5 100644 --- a/Fwk/AppFwk/cafPdmScripting/cafPdmFieldScriptingCapability.h +++ b/Fwk/AppFwk/cafPdmScripting/cafPdmFieldScriptingCapability.h @@ -648,7 +648,7 @@ class PdmFieldScriptingCapability> : public PdmAbs void readFromField( QTextStream& outputStream, bool quoteStrings = true, bool quoteNonBuiltins = false ) const override { - PdmFieldScriptingCapabilityIOHandler>::readFromField( m_field->childObjects(), + PdmFieldScriptingCapabilityIOHandler>::readFromField( m_field->children(), outputStream, quoteStrings, quoteNonBuiltins ); diff --git a/Fwk/AppFwk/cafPdmScripting/cafPdmPythonGenerator.cpp b/Fwk/AppFwk/cafPdmScripting/cafPdmPythonGenerator.cpp index e6fc0518b6..e541ac96a2 100644 --- a/Fwk/AppFwk/cafPdmScripting/cafPdmPythonGenerator.cpp +++ b/Fwk/AppFwk/cafPdmScripting/cafPdmPythonGenerator.cpp @@ -486,6 +486,7 @@ QString PdmPythonGenerator::dataTypeString( const PdmFieldHandle* field, bool us std::map builtins = { { QString::fromStdString( typeid( double ).name() ), "float" }, { QString::fromStdString( typeid( float ).name() ), "float" }, { QString::fromStdString( typeid( int ).name() ), "int" }, + { QString::fromStdString( typeid( bool ).name() ), "bool" }, { QString::fromStdString( typeid( time_t ).name() ), "time" }, { QString::fromStdString( typeid( QString ).name() ), "str" } }; diff --git a/Fwk/AppFwk/cafPdmScripting/cafPdmScripting_UnitTests/cafPdmScriptingBasicTest.cpp b/Fwk/AppFwk/cafPdmScripting/cafPdmScripting_UnitTests/cafPdmScriptingBasicTest.cpp index e044b0f76d..d828bffded 100644 --- a/Fwk/AppFwk/cafPdmScripting/cafPdmScripting_UnitTests/cafPdmScriptingBasicTest.cpp +++ b/Fwk/AppFwk/cafPdmScripting/cafPdmScripting_UnitTests/cafPdmScriptingBasicTest.cpp @@ -201,7 +201,7 @@ class InheritedDemoObj : public DemoPdmObject "Whatsthis SimpleObjectsField" ); } - ~InheritedDemoObj() { m_simpleObjectsField.deleteAllChildObjects(); } + ~InheritedDemoObj() { m_simpleObjectsField.deleteChildren(); } caf::PdmField> m_texts; caf::PdmField> m_numbers; @@ -222,7 +222,7 @@ class MyPdmDocument : public caf::PdmDocument CAF_PDM_InitFieldNoDefault( &objects, "PdmObjects", "", "", "", "" ) } - ~MyPdmDocument() { objects.deleteAllChildObjects(); } + ~MyPdmDocument() { objects.deleteChildren(); } caf::PdmChildArrayField objects; }; diff --git a/Fwk/AppFwk/cafProjectDataModel/cafFactory.h b/Fwk/AppFwk/cafProjectDataModel/cafFactory.h index a4793bcd1a..52cd2cd488 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafFactory.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafFactory.h @@ -152,6 +152,15 @@ class Factory return keys; } + void deleteCreatorObjects() + { + for ( auto f : m_factoryMap ) + { + if ( f.second ) delete f.second; + } + m_factoryMap.clear(); + } + private: Factory() {} ~Factory() diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/CMakeLists.txt b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/CMakeLists.txt index 9637b34f47..40d4e76c70 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/CMakeLists.txt +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/CMakeLists.txt @@ -16,6 +16,8 @@ find_package( set(QT_LIBRARIES Qt5::Core) set(PROJECT_FILES + caf.h + caf.cpp cafAssert.h cafAppEnum.h cafClassTypeName.h diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/caf.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/caf.cpp new file mode 100644 index 0000000000..63544caf05 --- /dev/null +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/caf.cpp @@ -0,0 +1,81 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2020- Ceetron Solutions AS +// +// This library may be used under the terms of either the GNU General Public License or +// the GNU Lesser General Public License as follows: +// +// GNU General Public License Usage +// This library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at <> +// for more details. +// +// GNU Lesser General Public License Usage +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU Lesser General Public License at <> +// for more details. +// +//################################################################################################## +#include "caf.h" + +#include "QtGui/qevent.h" +#include +#include + +namespace caf +{ +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QLocale norwegianLocale() +{ +#if QT_VERSION >= QT_VERSION_CHECK( 5, 15, 0 ) + return QLocale::NorwegianBokmal; +#else + return QLocale::Norwegian; +#endif +} // namespace caf::norwegianLocale() + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QTextStream& endl( QTextStream& s ) +{ + // https: // github.com/qt/qtbase/blob/dev/src/corelib/serialization/qtextstream.cpp#L2845 +#if QT_VERSION >= QT_VERSION_CHECK( 5, 15, 0 ) + return s << QLatin1Char( '\n' ) << Qt::flush; +#else + return s << QLatin1Char( '\n' ) << flush; +#endif +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QPointF position( QWheelEvent* wheelEvent ) +{ +#if QT_VERSION >= QT_VERSION_CHECK( 5, 15, 0 ) + return wheelEvent->position(); +#else + return wheelEvent->pos(); +#endif +} + +} // namespace caf diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/caf.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/caf.h new file mode 100644 index 0000000000..22264b50d4 --- /dev/null +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/caf.h @@ -0,0 +1,48 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2020- Ceetron Solutions AS +// +// This library may be used under the terms of either the GNU General Public License or +// the GNU Lesser General Public License as follows: +// +// GNU General Public License Usage +// This library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at <> +// for more details. +// +// GNU Lesser General Public License Usage +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU Lesser General Public License at <> +// for more details. +// +//################################################################################################## +#pragma once + +class QLocale; +class QTextStream; +class QPointF; +class QWheelEvent; + +namespace caf +{ +QLocale norwegianLocale(); +QTextStream& endl( QTextStream& s ); +QPointF position( QWheelEvent* wheelEvent ); +}; // namespace caf diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildArrayField.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildArrayField.h index 999d252d9b..4f6f0b6b9b 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildArrayField.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildArrayField.h @@ -24,7 +24,7 @@ class PdmChildArrayFieldHandle : public PdmPtrArrayFieldHandle PdmChildArrayFieldHandle() {} ~PdmChildArrayFieldHandle() override {} - virtual void deleteAllChildObjects() = 0; + virtual void deleteChildren() = 0; bool hasSameFieldCountForAllObjects(); }; @@ -63,14 +63,15 @@ class PdmChildArrayField : public PdmChildArrayFieldHandle size_t size() const override { return m_pointers.size(); } bool empty() const override { return m_pointers.empty(); } - void clear() override; - void deleteAllChildObjects() override; + void clearWithoutDelete() override; + void deleteChildren() override; void insertAt( int indexAfter, PdmObjectHandle* obj ) override; void insertAt( int indexAfter, std::unique_ptr obj ); PdmObjectHandle* at( size_t index ) override; void setValue( const std::vector& objects ); + size_t indexOf( const PdmObjectHandle* obj ) const override; - virtual void deleteAllChildObjectsAsync(); + virtual void deleteChildrenAsync(); // std::vector-like access @@ -85,8 +86,7 @@ class PdmChildArrayField : public PdmChildArrayFieldHandle void insert( size_t indexAfter, const std::vector>& objects ); size_t count( const DataType* pointer ) const; - void erase( size_t index ) override; - size_t index( const DataType* pointer ) const; + void erase( size_t index ) override; typename std::vector>::iterator begin() { return m_pointers.begin(); }; typename std::vector>::iterator end() { return m_pointers.end(); }; @@ -95,10 +95,10 @@ class PdmChildArrayField : public PdmChildArrayFieldHandle typename std::vector>::const_iterator end() const { return m_pointers.end(); }; // Child objects - std::vector childObjects() const; + std::vector children() const; - void childObjects( std::vector* objects ) override; - void removeChildObject( PdmObjectHandle* object ) override; + void children( std::vector* objects ) override; + void removeChild( PdmObjectHandle* object ) override; private: // To be disabled PDM_DISABLE_COPY_AND_ASSIGN( PdmChildArrayField ); diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildArrayField.inl b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildArrayField.inl index 181b078358..a915c10cdd 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildArrayField.inl +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildArrayField.inl @@ -14,7 +14,7 @@ namespace caf template PdmChildArrayField::~PdmChildArrayField() { - deleteAllChildObjects(); + deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -138,11 +138,28 @@ size_t PdmChildArrayField::count( const DataType* pointer ) const return itemCount; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +template +size_t PdmChildArrayField::indexOf( const PdmObjectHandle* obj ) const +{ + for ( size_t i = 0; i < m_pointers.size(); ++i ) + { + if ( obj == m_pointers[i].rawPtr() ) + { + return i; + } + } + + return ( size_t )( -1 ); // Undefined size_t > m_pointers.size(); +} + //-------------------------------------------------------------------------------------------------- /// Empty the container without deleting the objects pointed to. //-------------------------------------------------------------------------------------------------- template -void PdmChildArrayField::clear() +void PdmChildArrayField::clearWithoutDelete() { CAF_ASSERT( isInitializedByInitFieldMacro() ); @@ -154,7 +171,7 @@ void PdmChildArrayField::clear() /// Deletes all the objects pointed to by the field, then clears the container. //-------------------------------------------------------------------------------------------------- template -void PdmChildArrayField::deleteAllChildObjects() +void PdmChildArrayField::deleteChildren() { CAF_ASSERT( isInitializedByInitFieldMacro() ); @@ -172,7 +189,7 @@ void PdmChildArrayField::deleteAllChildObjects() /// Then clears the container and lets the thread delete the objects. //-------------------------------------------------------------------------------------------------- template -void PdmChildArrayField::deleteAllChildObjectsAsync() +void PdmChildArrayField::deleteChildrenAsync() { CAF_ASSERT( isInitializedByInitFieldMacro() ); @@ -196,30 +213,13 @@ void PdmChildArrayField::erase( size_t index ) m_pointers.erase( m_pointers.begin() + index ); } -//-------------------------------------------------------------------------------------------------- -/// Get the index of the given object pointer -//-------------------------------------------------------------------------------------------------- -template -size_t PdmChildArrayField::index( const DataType* pointer ) const -{ - for ( size_t i = 0; i < m_pointers.size(); ++i ) - { - if ( pointer == m_pointers[i].p() ) - { - return i; - } - } - - return ( size_t )( -1 ); // Undefined size_t > m_pointers.size(); -} - //-------------------------------------------------------------------------------------------------- /// Assign objects to the field, replacing the current child objects //-------------------------------------------------------------------------------------------------- template void PdmChildArrayField::setValue( const std::vector& objects ) { - clear(); + clearWithoutDelete(); for ( auto object : objects ) { push_back( object ); @@ -230,7 +230,7 @@ void PdmChildArrayField::setValue( const std::vector& obje /// Removes all instances of object pointer from the container without deleting the object. //-------------------------------------------------------------------------------------------------- template -void PdmChildArrayField::removeChildObject( PdmObjectHandle* object ) +void PdmChildArrayField::removeChild( PdmObjectHandle* object ) { CAF_ASSERT( isInitializedByInitFieldMacro() ); @@ -259,7 +259,7 @@ void PdmChildArrayField::removeChildObject( PdmObjectHandle* object ) /// //-------------------------------------------------------------------------------------------------- template -std::vector caf::PdmChildArrayField::childObjects() const +std::vector caf::PdmChildArrayField::children() const { std::vector objects; @@ -278,7 +278,7 @@ std::vector caf::PdmChildArrayField::childObjects() const /// //-------------------------------------------------------------------------------------------------- template -void PdmChildArrayField::childObjects( std::vector* objects ) +void PdmChildArrayField::children( std::vector* objects ) { if ( !objects ) return; size_t i; diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildArrayFieldHandle.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildArrayFieldHandle.cpp index 394be37f4d..88d55d3471 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildArrayFieldHandle.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildArrayFieldHandle.cpp @@ -11,7 +11,7 @@ namespace caf bool PdmChildArrayFieldHandle::hasSameFieldCountForAllObjects() { std::vector listObjects; - this->childObjects( &listObjects ); + this->children( &listObjects ); if ( listObjects.size() == 0 ) { diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildField.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildField.h index 622af931fa..9c664db0d9 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildField.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildField.h @@ -21,8 +21,8 @@ class PdmFieldXmlCap; class PdmChildFieldHandle : public PdmFieldHandle { public: - virtual void childObjects( std::vector* objects ) = 0; - virtual void setChildObject( PdmObjectHandle* object ) = 0; + virtual void children( std::vector* objects ) = 0; + virtual void setChildObject( PdmObjectHandle* object ) = 0; }; template @@ -67,9 +67,9 @@ class PdmChildField : public PdmChildFieldHandle const PdmPointer& v() const { return m_fieldValue; } // Child objects - virtual void childObjects( std::vector* objects ) override; + virtual void children( std::vector* objects ) override; void setChildObject( PdmObjectHandle* object ) override; - virtual void removeChildObject( PdmObjectHandle* object ) override; + virtual void removeChild( PdmObjectHandle* object ) override; private: PDM_DISABLE_COPY_AND_ASSIGN( PdmChildField ); diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildField.inl b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildField.inl index bfcd1f24a0..99ab353fee 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildField.inl +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildField.inl @@ -9,7 +9,7 @@ namespace caf /// //-------------------------------------------------------------------------------------------------- template -void caf::PdmChildField::childObjects( std::vector* objects ) +void caf::PdmChildField::children( std::vector* objects ) { CAF_ASSERT( objects ); PdmObjectHandle* obj = m_fieldValue.rawPtr(); @@ -28,7 +28,7 @@ void caf::PdmChildField::setChildObject( PdmObjectHandle* object ) if ( m_fieldValue.rawPtr() != nullptr ) { PdmObjectHandle* oldObject = m_fieldValue.rawPtr(); - this->removeChildObject( oldObject ); + this->removeChild( oldObject ); delete oldObject; } m_fieldValue.setRawPtr( object ); @@ -39,7 +39,7 @@ void caf::PdmChildField::setChildObject( PdmObjectHandle* object ) /// //-------------------------------------------------------------------------------------------------- template -void caf::PdmChildField::removeChildObject( PdmObjectHandle* object ) +void caf::PdmChildField::removeChild( PdmObjectHandle* object ) { if ( m_fieldValue.rawPtr() != nullptr && m_fieldValue.rawPtr() == object ) { diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/Parent.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/Parent.cpp index dd2066be8c..74b5371a54 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/Parent.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/Parent.cpp @@ -10,7 +10,7 @@ Parent::Parent() Parent::~Parent() { delete m_simpleObjectF(); - m_simpleObjectsField.deleteAllChildObjects(); + m_simpleObjectsField.deleteChildren(); } void Parent::doSome() diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/cafPdmChildArrayFieldHandleTest.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/cafPdmChildArrayFieldHandleTest.cpp index 5bccf96c11..f44a40f599 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/cafPdmChildArrayFieldHandleTest.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/cafPdmChildArrayFieldHandleTest.cpp @@ -68,8 +68,8 @@ class ContainerObj : public caf::PdmObjectHandle ~ContainerObj() { - derivedObjs.deleteAllChildObjects(); - derivedOtherObjs.deleteAllChildObjects(); + derivedObjs.deleteChildren(); + derivedOtherObjs.deleteChildren(); } caf::PdmChildArrayField derivedObjs; diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/cafPdmCoreBasicTest.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/cafPdmCoreBasicTest.cpp index d9a3f814d9..85cb5a98da 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/cafPdmCoreBasicTest.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/cafPdmCoreBasicTest.cpp @@ -292,10 +292,10 @@ TEST( BaseTest, PdmChildArrayField ) // childObjects std::vector objects; - ihd1->m_childArrayField.childObjects( &objects ); + ihd1->m_childArrayField.children( &objects ); EXPECT_EQ( size_t( 3 ), objects.size() ); - std::vector typedObjects = ihd1->m_childArrayField.childObjects(); + std::vector typedObjects = ihd1->m_childArrayField.children(); EXPECT_EQ( size_t( 3 ), typedObjects.size() ); // set() @@ -303,7 +303,7 @@ TEST( BaseTest, PdmChildArrayField ) EXPECT_TRUE( NULL == ihd1->m_childArrayField[1] ); EXPECT_TRUE( s2->parentField() == NULL ); - ihd1->m_childArrayField.removeChildObject( NULL ); + ihd1->m_childArrayField.removeChild( NULL ); EXPECT_EQ( size_t( 2 ), ihd1->m_childArrayField.size() ); EXPECT_EQ( s3, ihd1->m_childArrayField[1] ); EXPECT_EQ( s1, ihd1->m_childArrayField[0] ); @@ -325,7 +325,7 @@ TEST( BaseTest, PdmChildArrayField ) EXPECT_TRUE( s2->parentField() == NULL ); // clear() - ihd1->m_childArrayField.clear(); + ihd1->m_childArrayField.clearWithoutDelete(); EXPECT_EQ( size_t( 0 ), ihd1->m_childArrayField.size() ); EXPECT_TRUE( s1->parentField() == NULL ); @@ -334,7 +334,7 @@ TEST( BaseTest, PdmChildArrayField ) ihd1->m_childArrayField.push_back( s2 ); ihd1->m_childArrayField.push_back( s3 ); - ihd1->m_childArrayField.deleteAllChildObjects(); + ihd1->m_childArrayField.deleteChildren(); EXPECT_EQ( size_t( 0 ), ihd1->m_childArrayField.size() ); EXPECT_TRUE( s1 == NULL ); EXPECT_TRUE( s2 == NULL ); @@ -382,7 +382,7 @@ TEST( BaseTest, PdmChildArrayFieldHandle ) // virtual void clear() = 0; // virtual PdmObject* createAppendObject(int indexAfter) = 0; // virtual void erase(size_t index) = 0; - // virtual void deleteAllChildObjects() = 0; + // virtual void deleteChildren() = 0; // // virtual PdmObject* at(size_t index) = 0; // @@ -424,7 +424,7 @@ TEST( BaseTest, PdmChildArrayFieldHandle ) EXPECT_TRUE( listField->hasSameFieldCountForAllObjects() ); EXPECT_FALSE( listField->empty() ); - listField->deleteAllChildObjects(); + listField->deleteChildren(); EXPECT_EQ( 0u, listField->size() ); EXPECT_TRUE( listField->hasSameFieldCountForAllObjects() ); EXPECT_TRUE( listField->empty() ); @@ -474,7 +474,7 @@ TEST( BaseTest, PdmChildField ) EXPECT_TRUE( c2 == a.field2 ); std::vector objects; - a.field2.childObjects( &objects ); + a.field2.children( &objects ); EXPECT_EQ( (size_t)1, objects.size() ); EXPECT_EQ( c2, objects[0] ); } diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/cafPdmReferenceHelperTest.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/cafPdmReferenceHelperTest.cpp index e79b59dc1c..ee1e11af6a 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/cafPdmReferenceHelperTest.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/cafPdmReferenceHelperTest.cpp @@ -56,7 +56,7 @@ class ReferenceSimpleObj : public caf::PdmObjectHandle ~ReferenceSimpleObj() { delete m_pointersField(); - m_simpleObjPtrField.deleteAllChildObjects(); + m_simpleObjPtrField.deleteChildren(); } // Fields @@ -203,10 +203,10 @@ TEST( PdmReferenceHelperTest, ObjectFromReference ) QString refString = caf::PdmReferenceHelper::referenceFromRootToObject( ihd1, s2 ); EXPECT_EQ( s2, caf::PdmReferenceHelper::objectFromReference( ihd1, refString ) ); - ihd1->m_simpleObjPtrField.removeChildObject( s2 ); + ihd1->m_simpleObjPtrField.removeChild( s2 ); EXPECT_EQ( NULL, caf::PdmReferenceHelper::objectFromReference( ihd1, refString ) ); - ihd1->m_simpleObjPtrField.deleteAllChildObjects(); + ihd1->m_simpleObjPtrField.deleteChildren(); EXPECT_EQ( NULL, caf::PdmReferenceHelper::objectFromReference( ihd1, refString ) ); @@ -241,10 +241,10 @@ TEST( PdmReferenceHelperTest, FieldFromReference ) QString refString = caf::PdmReferenceHelper::referenceFromRootToField( ihd1, fHandle ); EXPECT_EQ( fHandle, caf::PdmReferenceHelper::fieldFromReference( ihd1, refString ) ); - ihd1->m_simpleObjPtrField.removeChildObject( s2 ); + ihd1->m_simpleObjPtrField.removeChild( s2 ); EXPECT_EQ( NULL, caf::PdmReferenceHelper::fieldFromReference( ihd1, refString ) ); - ihd1->m_simpleObjPtrField.deleteAllChildObjects(); + ihd1->m_simpleObjPtrField.deleteChildren(); EXPECT_EQ( NULL, caf::PdmReferenceHelper::fieldFromReference( ihd1, refString ) ); diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/cafSignalTest.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/cafSignalTest.cpp index 84577be9cc..563877af61 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/cafSignalTest.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/cafSignalTest.cpp @@ -72,6 +72,12 @@ class TestObserver : public caf::SignalObserver emitter->structSignal.connect( this, &TestObserver::setSimpleStruct ); } + void connectSignalsTwice( TestEmitter* emitter ) + { + emitter->basicSignal.connect( this, &TestObserver::setBasicSignalReceived ); + emitter->basicSignal.connect( this, &TestObserver::setBasicSignalReceived ); + } + void setBasicSignalReceived( const caf::SignalEmitter* emitter ) { m_receivedBasicSignal = true; } void setBoolValue( const caf::SignalEmitter*, bool test ) { m_boolValue = test; } void setStringValue( const caf::SignalEmitter*, std::string test ) { m_stringValue = test; } @@ -149,3 +155,15 @@ TEST( SignalTest, ObserverDeletion ) ASSERT_EQ( (size_t)0, emitter.basicSignal.observerCount() ); emitter.triggerBasicSignal(); } + +// TEST( SignalTest, ConnectSignalTwiceAssert ) +//{ +// ASSERT_DEATH( +// { +// TestEmitter emitter; +// TestObserver observer; +// +// observer.connectSignalsTwice( &emitter ); +// }, +// "" ); +//} diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmFieldHandle.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmFieldHandle.cpp index 335b1af045..f7fcc74622 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmFieldHandle.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmFieldHandle.cpp @@ -37,10 +37,10 @@ void PdmFieldHandle::setKeyword( const QString& keyword ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool PdmFieldHandle::hasChildObjects() +bool PdmFieldHandle::hasChildren() { std::vector children; - this->childObjects( &children ); + this->children( &children ); return ( children.size() > 0 ); } diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmFieldHandle.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmFieldHandle.h index 026919f6fe..d481f4a869 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmFieldHandle.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmFieldHandle.h @@ -31,9 +31,9 @@ class PdmFieldHandle std::vector keywordAliases() const; // Child objects - bool hasChildObjects(); - virtual void childObjects( std::vector* ) {} - virtual void removeChildObject( PdmObjectHandle* ) {} + bool hasChildren(); + virtual void children( std::vector* ) {} + virtual void removeChild( PdmObjectHandle* ) {} void setOwnerClass( const QString& ownerClass ); // Ptr referenced objects diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmFieldReorderCapability.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmFieldReorderCapability.cpp index d37dbd832c..4a65433791 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmFieldReorderCapability.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmFieldReorderCapability.cpp @@ -189,3 +189,11 @@ PdmFieldReorderCapability* PdmFieldReorderCapability::reorderCapabilityOfParentC return nullptr; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t PdmFieldReorderCapability::indexOf( PdmObjectHandle* pdmObject ) +{ + return m_field->indexOf( pdmObject ); +} diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmFieldReorderCapability.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmFieldReorderCapability.h index 0b0c40cbdf..5365a513be 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmFieldReorderCapability.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmFieldReorderCapability.h @@ -51,6 +51,8 @@ class PdmFieldReorderCapability : public PdmFieldCapability, public SignalEmitte public: PdmFieldReorderCapability( PdmPtrArrayFieldHandle* field, bool giveOwnership ); + size_t indexOf( PdmObjectHandle* pdmObject ); + bool canItemBeMovedUp( size_t index ) const; bool canItemBeMovedDown( size_t index ) const; diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmObjectHandle.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmObjectHandle.h index 3811191203..2d4608d3a0 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmObjectHandle.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmObjectHandle.h @@ -9,6 +9,8 @@ #include #include +class QMimeData; + namespace caf { class PdmObjectCapability; @@ -105,6 +107,11 @@ class PdmObjectHandle : public SignalObserver, public SignalEmitter std::vector& referringObjects ); virtual void onChildAdded( caf::PdmFieldHandle* containerForNewObject ){}; + virtual void onChildrenUpdated( PdmChildArrayFieldHandle* childArray, + std::vector& updatedObjects ){}; + + virtual void + handleDroppedMimeData( const QMimeData* data, Qt::DropAction action, caf::PdmFieldHandle* destinationField ){}; protected: void addField( PdmFieldHandle* field, const QString& keyword ); @@ -260,7 +267,7 @@ void PdmObjectHandle::descendantsOfType( std::vector& descendants ) const for ( auto f : m_fields ) { std::vector childObjects; - f->childObjects( &childObjects ); + f->children( &childObjects ); for ( auto childObject : childObjects ) { diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmPtrArrayField.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmPtrArrayField.h index 69348fe8d8..c1e1b734d8 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmPtrArrayField.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmPtrArrayField.h @@ -50,11 +50,12 @@ class PdmPtrArrayField : public PdmPtrArrayFieldHandle // Reimplementation of PdmPointersFieldHandle methods - virtual size_t size() const { return m_pointers.size(); } - virtual bool empty() const { return m_pointers.empty(); } - virtual void clear(); - virtual void insertAt( int indexAfter, PdmObjectHandle* obj ); - virtual PdmObjectHandle* at( size_t index ); + size_t size() const override { return m_pointers.size(); } + bool empty() const override { return m_pointers.empty(); } + void clearWithoutDelete() override; + void insertAt( int indexAfter, PdmObjectHandle* obj ) override; + PdmObjectHandle* at( size_t index ) override; + size_t indexOf( const PdmObjectHandle* obj ) const override; // std::vector-like access @@ -66,9 +67,8 @@ class PdmPtrArrayField : public PdmPtrArrayFieldHandle void insert( size_t indexAfter, const std::vector>& objects ); size_t count( const DataType* pointer ) const; - void erase( size_t index ); - size_t index( DataType* pointer ); - void removePtr( PdmObjectHandle* object ); + void erase( size_t index ) override; + void removePtr( PdmObjectHandle* object ); typename std::vector>::iterator begin() { return m_pointers.begin(); }; typename std::vector>::iterator end() { return m_pointers.end(); }; @@ -79,7 +79,7 @@ class PdmPtrArrayField : public PdmPtrArrayFieldHandle std::vector ptrReferencedObjects() const; // Child objects - virtual void ptrReferencedObjects( std::vector* ); + void ptrReferencedObjects( std::vector* ) override; private: // To be disabled PDM_DISABLE_COPY_AND_ASSIGN( PdmPtrArrayField ); diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmPtrArrayField.inl b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmPtrArrayField.inl index 7f4aa36950..7430d5b175 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmPtrArrayField.inl +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmPtrArrayField.inl @@ -24,7 +24,7 @@ PdmPtrArrayField::~PdmPtrArrayField() template void PdmPtrArrayField::setValue( const std::vector>& fieldValue ) { - this->clear(); + this->clearWithoutDelete(); this->insert( 0, fieldValue ); } @@ -43,7 +43,7 @@ const std::vector>& PdmPtrArrayField::value() co template void PdmPtrArrayField::setValue( const std::vector& fieldValue ) { - this->clear(); + this->clearWithoutDelete(); for ( DataType* rawPtr : fieldValue ) { this->push_back( PdmPointer( rawPtr ) ); @@ -140,11 +140,28 @@ size_t PdmPtrArrayField::count( const DataType* pointer ) const return itemCount; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +template +size_t PdmPtrArrayField::indexOf( const PdmObjectHandle* obj ) const +{ + for ( size_t i = 0; i < m_pointers.size(); ++i ) + { + if ( obj == m_pointers[i].rawPtr() ) + { + return i; + } + } + + return ( size_t )( -1 ); // Undefined size_t > m_pointers.size(); +} + //-------------------------------------------------------------------------------------------------- /// Empty the container without deleting the objects pointed to. //-------------------------------------------------------------------------------------------------- template -void PdmPtrArrayField::clear() +void PdmPtrArrayField::clearWithoutDelete() { CAF_ASSERT( isInitializedByInitFieldMacro() ); @@ -170,23 +187,6 @@ void PdmPtrArrayField::erase( size_t index ) m_pointers.erase( m_pointers.begin() + index ); } -//-------------------------------------------------------------------------------------------------- -/// Get the index of the given object pointer -//-------------------------------------------------------------------------------------------------- -template -size_t PdmPtrArrayField::index( DataType* pointer ) -{ - for ( size_t i = 0; i < m_pointers.size(); ++i ) - { - if ( pointer == m_pointers[i].p() ) - { - return i; - } - } - - return ( size_t )( -1 ); // Undefined size_t > m_pointers.size(); -} - //-------------------------------------------------------------------------------------------------- /// Removes all instances of object pointer from the container without deleting the object. //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmPtrArrayFieldHandle.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmPtrArrayFieldHandle.h index 4d6df4a82e..0d60034053 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmPtrArrayFieldHandle.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmPtrArrayFieldHandle.h @@ -17,9 +17,10 @@ class PdmPtrArrayFieldHandle : public PdmFieldHandle virtual size_t size() const = 0; virtual bool empty() const = 0; - virtual void clear() = 0; + virtual void clearWithoutDelete() = 0; virtual void insertAt( int indexAfter, PdmObjectHandle* obj ) = 0; virtual void erase( size_t index ) = 0; + virtual size_t indexOf( const PdmObjectHandle* obj ) const = 0; virtual PdmObjectHandle* at( size_t index ) = 0; }; diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmReferenceHelper.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmReferenceHelper.cpp index be263c27f7..bb9eb7b9b7 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmReferenceHelper.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmReferenceHelper.cpp @@ -141,7 +141,7 @@ QStringList PdmReferenceHelper::referenceFromRootToObjectAsStringList( PdmObject } std::vector childObjects; - parentField->childObjects( &childObjects ); + parentField->children( &childObjects ); if ( childObjects.size() > 0 ) { @@ -220,7 +220,7 @@ PdmObjectHandle* PdmReferenceHelper::objectFromReferenceStringList( PdmObjectHan } std::vector childObjects; - fieldHandle->childObjects( &childObjects ); + fieldHandle->children( &childObjects ); if ( childObjects.size() == 0 ) { diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafSignal.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafSignal.h index 2fd7e3b484..4d718d1305 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafSignal.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafSignal.h @@ -135,6 +135,11 @@ class Signal : public AbstractSignal { static_assert( std::is_convertible::value, "Only classes that inherit SignalObserver can connect as an observer of a Signal." ); + + // Connecting a signal twice is not supported + // CAF_ASSERT( m_observerCallbacks.find( observer ) == m_observerCallbacks.end() ); + if ( m_observerCallbacks.find( observer ) != m_observerCallbacks.end() ) return; + m_observerCallbacks[observer] = std::make_pair( callback, true ); observer->addObservedSignal( this ); } diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmDocument.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmDocument.cpp index 72a4b557c8..376d95bd3a 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmDocument.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmDocument.cpp @@ -137,7 +137,7 @@ void PdmDocument::updateUiIconStateRecursively( PdmObjectHandle* object ) size_t fIdx; for ( fIdx = 0; fIdx < fields.size(); ++fIdx ) { - if ( fields[fIdx] ) fields[fIdx]->childObjects( &children ); + if ( fields[fIdx] ) fields[fIdx]->children( &children ); } size_t cIdx; diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmObject.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmObject.cpp index 2339b98d9e..3b8cc2afc0 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmObject.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmObject.cpp @@ -72,7 +72,7 @@ void PdmObject::descendantsIncludingThisFromClassKeyword( const QString& for ( auto f : fields ) { std::vector childObjects; - f->childObjects( &childObjects ); + f->children( &childObjects ); for ( auto childObject : childObjects ) { PdmObject* pdmObjectChild = dynamic_cast( childObject ); @@ -94,7 +94,7 @@ void PdmObject::childrenFromClassKeyword( const QString& classKeyword, std::vect for ( auto f : fields ) { std::vector childObjects; - f->childObjects( &childObjects ); + f->children( &childObjects ); for ( auto childObject : childObjects ) { PdmObject* pdmObjectChild = dynamic_cast( childObject ); diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafIconProvider.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafIconProvider.cpp index ca78a25d5c..0f8d6365b6 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafIconProvider.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafIconProvider.cpp @@ -38,6 +38,7 @@ #include #include #include +#include using namespace caf; @@ -201,9 +202,16 @@ std::unique_ptr IconProvider::icon( const QSize& size ) const if ( !m_iconResourceString.isEmpty() ) { - QIcon resourceStringIcon( m_iconResourceString ); - if ( !resourceStringIcon.isNull() ) + QPixmap pm; + if ( !QPixmapCache::find( m_iconResourceString, &pm ) ) { + pm.load( m_iconResourceString ); + QPixmapCache::insert( m_iconResourceString, pm ); + } + + if ( !pm.isNull() ) + { + QIcon resourceStringIcon( pm ); QPixmap iconPixmap = resourceStringIcon.pixmap( size, m_active ? QIcon::Normal : QIcon::Disabled ); QPainter painter( &pixmap ); painter.drawPixmap( 0, 0, iconPixmap ); diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafInternalPdmFieldTypeSpecializations.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafInternalPdmFieldTypeSpecializations.h index aaf1fb44bf..ec8a7dcdb9 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafInternalPdmFieldTypeSpecializations.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafInternalPdmFieldTypeSpecializations.h @@ -46,10 +46,7 @@ class PdmUiFieldSpecialization> return variantValue.value>() == variantValue2.value>(); } - static QList valueOptions( bool* useOptionsOnly, const PdmPointer& ) - { - return QList(); - } + static QList valueOptions( const PdmPointer& ) { return QList(); } }; //================================================================================================== @@ -94,10 +91,7 @@ class PdmUiFieldSpecialization> } /// Methods to get a list of options for a field, specialized for AppEnum - static QList valueOptions( bool* useOptionsOnly, const std::list& ) - { - return QList(); - } + static QList valueOptions( const std::list& ) { return QList(); } /// Methods to retrieve the possible PdmObject pointed to by a field static void childObjects( const PdmDataValueField>&, std::vector* ) {} @@ -130,10 +124,7 @@ class PdmUiFieldSpecialization> } /// Methods to get a list of options for a field, specialized for AppEnum - static QList valueOptions( bool* useOptionsOnly, const std::vector& ) - { - return QList(); - } + static QList valueOptions( const std::vector& ) { return QList(); } /// Methods to retrieve the possible PdmObject pointed to by a field static void childObjects( const PdmDataValueField>& field, std::vector* objects ) @@ -169,10 +160,8 @@ class PdmUiFieldSpecialization> } /// Methods to get a list of options for a field, specialized for AppEnum - static QList valueOptions( bool* useOptionsOnly, const caf::AppEnum& ) + static QList valueOptions( const caf::AppEnum& ) { - if ( useOptionsOnly ) *useOptionsOnly = true; - QList optionList; for ( size_t i = 0; i < caf::AppEnum::size(); ++i ) @@ -216,10 +205,7 @@ class PdmUiFieldSpecialization } /// Methods to get a list of options for a field, specialized for AppEnum - static QList valueOptions( bool* useOptionsOnly, const caf::FilePath& ) - { - return QList(); - } + static QList valueOptions( const caf::FilePath& ) { return QList(); } /// Methods to retrieve the possible PdmObject pointed to by a field static void childObjects( const PdmDataValueField& field, std::vector* objects ) {} diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafInternalPdmUiFieldCapability.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafInternalPdmUiFieldCapability.h index 9a056a283c..2c2c66697c 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafInternalPdmUiFieldCapability.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafInternalPdmUiFieldCapability.h @@ -17,8 +17,8 @@ class PdmFieldUiCap : public PdmUiFieldHandle // Gui generalized interface public: QVariant uiValue() const override; - void setValueFromUiEditor( const QVariant& uiValue ) override; - QList valueOptions( bool* useOptionsOnly ) const override; + void setValueFromUiEditor( const QVariant& uiValue, bool notifyFieldChanged ) override; + QList valueOptions() const override; QVariant toUiBasedQVariant() const override; @@ -48,8 +48,8 @@ class PdmFieldUiCap> : public PdmUiFieldHandle // Gui generalized interface public: QVariant uiValue() const override { return QVariant(); } - void setValueFromUiEditor( const QVariant& uiValue ) override {} - QList valueOptions( bool* useOptionsOnly ) const override { return QList(); } + void setValueFromUiEditor( const QVariant& uiValue, bool notifyFieldChanged ) override {} + QList valueOptions() const override { return QList(); } QVariant toUiBasedQVariant() const override { return QVariant(); } }; @@ -71,8 +71,8 @@ class PdmFieldUiCap> : public PdmUiFieldHandle // Gui generalized interface public: QVariant uiValue() const override { return QVariant(); } - void setValueFromUiEditor( const QVariant& uiValue ) override {} - QList valueOptions( bool* useOptionsOnly ) const override { return QList(); } + void setValueFromUiEditor( const QVariant& uiValue, bool notifyFieldChanged ) override {} + QList valueOptions() const override { return QList(); } QVariant toUiBasedQVariant() const override { return QVariant(); } }; diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafInternalPdmUiFieldCapability.inl b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafInternalPdmUiFieldCapability.inl index a732ce7f95..9277531673 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafInternalPdmUiFieldCapability.inl +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafInternalPdmUiFieldCapability.inl @@ -14,7 +14,7 @@ namespace caf //-------------------------------------------------------------------------------------------------- template -void caf::PdmFieldUiCap::setValueFromUiEditor( const QVariant& uiValue ) +void PdmFieldUiCap::setValueFromUiEditor( const QVariant& uiValue, bool notifyFieldChanged ) { QVariant oldUiBasedQVariant = toUiBasedQVariant(); @@ -100,7 +100,7 @@ void caf::PdmFieldUiCap::setValueFromUiEditor( const QVariant& uiValu QVariant newUiBasedQVariant = toUiBasedQVariant(); - this->notifyFieldChanged( oldUiBasedQVariant, newUiBasedQVariant ); + if ( notifyFieldChanged ) this->notifyFieldChanged( oldUiBasedQVariant, newUiBasedQVariant ); } //-------------------------------------------------------------------------------------------------- @@ -123,7 +123,7 @@ void caf::PdmFieldUiCap::setValueFromUiEditor( const QVariant& uiValu //-------------------------------------------------------------------------------------------------- template -QVariant caf::PdmFieldUiCap::uiValue() const +QVariant PdmFieldUiCap::uiValue() const { if ( m_optionEntryCache.size() ) { @@ -137,11 +137,13 @@ QVariant caf::PdmFieldUiCap::uiValue() const if ( isAutoAddingOptionFromValue() && indexesToFoundOptions.size() != static_cast( uiBasedQVariant.toList().size() ) ) { - CAF_ASSERT( false ); // Did not find all the field values among the options available, even though we - // should. Reasons might be: - // The "core" data type in the field is probably not supported by - // QVariant::toString() You forgot to call valueOptions() before the call to - // uiValue(). + return QVariant(); + + // CAF_ASSERT( false ); // Did not find all the field values among the options available, even though we + // should. Reasons might be: + // The "core" data type in the field is probably not supported by + // QVariant::toString() You forgot to call valueOptions() before the call to + // uiValue(). } else { @@ -181,22 +183,21 @@ QVariant caf::PdmFieldUiCap::uiValue() const //-------------------------------------------------------------------------------------------------- template -QList caf::PdmFieldUiCap::valueOptions( bool* useOptionsOnly ) const +QList PdmFieldUiCap::valueOptions() const { m_optionEntryCache.clear(); // First check if the owner PdmObject has a value options specification. If it has, we use it. if ( m_field->ownerObject() ) { - m_optionEntryCache = uiObj( m_field->ownerObject() )->calculateValueOptions( this->m_field, useOptionsOnly ); + m_optionEntryCache = uiObj( m_field->ownerObject() )->calculateValueOptions( this->m_field ); } // If we got no options, use the options defined by the type. Normally only caf::AppEnum type if ( !m_optionEntryCache.size() ) { - m_optionEntryCache = - PdmUiFieldSpecialization::valueOptions( useOptionsOnly, m_field->value() ); + m_optionEntryCache = PdmUiFieldSpecialization::valueOptions( m_field->value() ); } if ( m_optionEntryCache.size() && isAutoAddingOptionFromValue() ) @@ -261,7 +262,7 @@ QList caf::PdmFieldUiCap::valueOptions( bool* useO /// //-------------------------------------------------------------------------------------------------- template -QVariant caf::PdmFieldUiCap::toUiBasedQVariant() const +QVariant PdmFieldUiCap::toUiBasedQVariant() const { return PdmUiFieldSpecialization::convert( m_field->value() ); } @@ -270,8 +271,8 @@ QVariant caf::PdmFieldUiCap::toUiBasedQVariant() const /// //-------------------------------------------------------------------------------------------------- template -bool caf::PdmFieldUiCap::isQVariantDataEqual( const QVariant& oldUiBasedQVariant, - const QVariant& newUiBasedQVariant ) const +bool PdmFieldUiCap::isQVariantDataEqual( const QVariant& oldUiBasedQVariant, + const QVariant& newUiBasedQVariant ) const { return PdmValueFieldSpecialization::isEqual( oldUiBasedQVariant, newUiBasedQVariant ); } diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiCommandSystemProxy.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiCommandSystemProxy.cpp index 2f0b719b17..69c1a2a289 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiCommandSystemProxy.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiCommandSystemProxy.cpp @@ -114,7 +114,7 @@ void PdmUiCommandSystemProxy::setUiValueToField( PdmUiFieldHandle* uiFieldHandle for ( auto fieldHandle : fieldsToUpdate ) { - fieldHandle->uiCapability()->setValueFromUiEditor( newUiValue ); + fieldHandle->uiCapability()->setValueFromUiEditor( newUiValue, true ); } } } @@ -164,7 +164,8 @@ std::vector PdmUiCommandSystemProxy::fieldsFromSelection( PdmFi if ( items.size() < 2 ) return {}; const auto fieldKeyword = editorField->keyword(); - const auto& fieldOwnerTypeId = typeid( *editorField->ownerObject() ); + auto ownerObject = editorField->ownerObject(); + const auto& fieldOwnerTypeId = typeid( *ownerObject ); std::vector additionalFieldsToUpdate; for ( auto& item : items ) @@ -197,7 +198,7 @@ std::vector PdmUiCommandSystemProxy::fieldsFromSelection( PdmFi for ( auto field : childFields ) { std::vector childObjects; - field->childObjects( &childObjects ); + field->children( &childObjects ); for ( auto childObj : childObjects ) { auto childFieldHandle = childObj->findField( fieldKeyword ); diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldHandle.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldHandle.cpp index c6593b2e0f..ee718b937c 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldHandle.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldHandle.cpp @@ -44,7 +44,7 @@ QVariant PdmUiFieldHandle::uiValue() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList PdmUiFieldHandle::valueOptions( bool* useOptionsOnly ) const +QList PdmUiFieldHandle::valueOptions() const { return QList(); } @@ -124,7 +124,7 @@ void PdmUiFieldHandle::setAutoAddingOptionFromValue( bool isAddingValue ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void PdmUiFieldHandle::setValueFromUiEditor( const QVariant& uiValue ) +void PdmUiFieldHandle::setValueFromUiEditor( const QVariant& uiValue, bool notifyFieldChanged ) { } diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldHandle.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldHandle.h index c5707f65e4..a6296f1414 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldHandle.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldHandle.h @@ -20,7 +20,7 @@ class PdmUiFieldHandle : public PdmUiItem, public PdmFieldCapability, public Pdm // The QVariant encapsulates the real value, or an index into the valueOptions virtual QVariant uiValue() const; - virtual QList valueOptions( bool* useOptionsOnly ) const; + virtual QList valueOptions() const; void notifyFieldChanged( const QVariant& oldUiBasedQVariant, const QVariant& newUiBasedQVariant ) override; @@ -30,7 +30,7 @@ class PdmUiFieldHandle : public PdmUiItem, public PdmFieldCapability, public Pdm private: friend class PdmUiCommandSystemProxy; friend class CmdFieldChangeExec; - virtual void setValueFromUiEditor( const QVariant& uiValue ); + virtual void setValueFromUiEditor( const QVariant& uiValue, bool notifyFieldChanged ); // This is needed to handle custom types in QVariants since operator == between QVariant does not work when they use // custom types. virtual bool isQVariantDataEqual( const QVariant& oldUiBasedQVariant, const QVariant& newUiBasedQVariant ) const; diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldSpecialization.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldSpecialization.h index 0c4211da32..59287a8e58 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldSpecialization.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldSpecialization.h @@ -50,10 +50,7 @@ class PdmUiFieldSpecialization } /// Methods to get a list of options for a field, specialized for AppEnum - static QList valueOptions( bool* useOptionsOnly, const T& ) - { - return QList(); - } + static QList valueOptions( const T& ) { return QList(); } /// Methods to retrieve the possible PdmObject pointed to by a field static void childObjects( const PdmDataValueField&, std::vector* ) {} diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.cpp index 9d2484e330..d6cfa56136 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.cpp @@ -227,9 +227,11 @@ bool PdmUiItem::sm_showExtraDebugText = false; //-------------------------------------------------------------------------------------------------- const QString PdmUiItem::uiName( const QString& uiConfigName ) const { + const PdmUiItemInfo* sttInfo = m_staticItemInfo; + if ( uiConfigName == uiConfigNameForStaticData() && sttInfo ) return sttInfo->m_uiName; + const PdmUiItemInfo* conInfo = configInfo( uiConfigName ); const PdmUiItemInfo* defInfo = defaultInfo(); - const PdmUiItemInfo* sttInfo = m_staticItemInfo; if ( conInfo && !( conInfo->m_uiName.isNull() ) ) return conInfo->m_uiName; if ( defInfo && !( defInfo->m_uiName.isNull() ) ) return defInfo->m_uiName; @@ -246,6 +248,14 @@ void PdmUiItem::setUiName( const QString& uiName, const QString& uiConfigName /* m_configItemInfos[uiConfigName].m_uiName = uiName; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString PdmUiItem::uiConfigNameForStaticData() +{ + return "uiConfigNameForStaticData"; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -478,6 +488,33 @@ void PdmUiItem::setUiReadOnly( bool isReadOnly, const QString& uiConfigName /*= m_configItemInfos[uiConfigName].m_isReadOnly = isReadOnly; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool PdmUiItem::notifyAllFieldsInMultiFieldChangedEvents( const QString& uiConfigName /*= "" */ ) const +{ + const PdmUiItemInfo* conInfo = configInfo( uiConfigName ); + const PdmUiItemInfo* defInfo = defaultInfo(); + const PdmUiItemInfo* sttInfo = m_staticItemInfo; + + if ( conInfo && !( conInfo->m_notifyAllFieldsInMultiFieldChangedEvents == -1 ) ) + return conInfo->m_notifyAllFieldsInMultiFieldChangedEvents; + if ( defInfo && !( defInfo->m_notifyAllFieldsInMultiFieldChangedEvents == -1 ) ) + return defInfo->m_notifyAllFieldsInMultiFieldChangedEvents; + if ( sttInfo && !( sttInfo->m_notifyAllFieldsInMultiFieldChangedEvents == -1 ) ) + return sttInfo->m_notifyAllFieldsInMultiFieldChangedEvents; + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void PdmUiItem::setNotifyAllFieldsInMultiFieldChangedEvents( bool enable, const QString& uiConfigName /*= "" */ ) +{ + m_configItemInfos[uiConfigName].m_notifyAllFieldsInMultiFieldChangedEvents = enable; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.h index 9c67228696..997ce49b42 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.h @@ -71,6 +71,7 @@ class PdmUiItemInfo , m_isReadOnly( -1 ) , m_labelAlignment( LEFT ) , m_isCustomContextMenuEnabled( -1 ) + , m_notifyAllFieldsInMultiFieldChangedEvents( -1 ) { } @@ -105,6 +106,7 @@ class PdmUiItemInfo int m_isReadOnly; ///< UiItem should be insensitive, or read only. -1 means not set. LabelPosType m_labelAlignment; int m_isCustomContextMenuEnabled; + int m_notifyAllFieldsInMultiFieldChangedEvents; }; //================================================================================================== @@ -248,8 +250,9 @@ class PdmUiItem PdmUiItem( const PdmUiItem& ) = delete; PdmUiItem& operator=( const PdmUiItem& ) = delete; - const QString uiName( const QString& uiConfigName = "" ) const; - void setUiName( const QString& uiName, const QString& uiConfigName = "" ); + const QString uiName( const QString& uiConfigName = "" ) const; + void setUiName( const QString& uiName, const QString& uiConfigName = "" ); + static QString uiConfigNameForStaticData(); std::unique_ptr uiIcon( const QString& uiConfigName = "" ) const; const IconProvider uiIconProvider( const QString& uiConfigName = "" ) const; @@ -277,6 +280,9 @@ class PdmUiItem bool isUiReadOnly( const QString& uiConfigName = "" ) const; void setUiReadOnly( bool isReadOnly, const QString& uiConfigName = "" ); + bool notifyAllFieldsInMultiFieldChangedEvents( const QString& uiConfigName = "" ) const; + void setNotifyAllFieldsInMultiFieldChangedEvents( bool enable, const QString& uiConfigName = "" ); + PdmUiItemInfo::LabelPosType uiLabelPosition( const QString& uiConfigName = "" ) const; void setUiLabelPosition( PdmUiItemInfo::LabelPosType alignment, const QString& uiConfigName = "" ); diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.cpp index b420bd1b66..3ab7a5201a 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.cpp @@ -118,13 +118,13 @@ void PdmUiObjectHandle::addDefaultUiTreeChildren( PdmUiTreeOrdering* uiTreeOrder for ( size_t fIdx = 0; fIdx < fields.size(); ++fIdx ) { - if ( fields[fIdx]->hasChildObjects() && !uiTreeOrdering->containsField( fields[fIdx] ) ) + if ( fields[fIdx]->hasChildren() && !uiTreeOrdering->containsField( fields[fIdx] ) ) { if ( fields[fIdx]->uiCapability()->isUiTreeHidden() && !fields[fIdx]->uiCapability()->isUiTreeChildrenHidden() ) { std::vector children; - fields[fIdx]->childObjects( &children ); + fields[fIdx]->children( &children ); std::set objectsAddedByApplication; for ( int i = 0; i < uiTreeOrdering->childCount(); i++ ) @@ -193,7 +193,7 @@ void PdmUiObjectHandle::expandUiTree( PdmUiTreeOrdering* root, const QString& ui !root->field()->uiCapability()->isUiTreeChildrenHidden( uiConfigName ) ) { std::vector fieldsChildObjects; - root->field()->childObjects( &fieldsChildObjects ); + root->field()->children( &fieldsChildObjects ); for ( size_t cIdx = 0; cIdx < fieldsChildObjects.size(); ++cIdx ) { PdmObjectHandle* childObject = fieldsChildObjects[cIdx]; diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.h index cc0a8a3d5d..ee395297a1 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.h @@ -61,8 +61,7 @@ class PdmUiObjectHandle : public PdmUiItem, public PdmObjectCapability virtual void childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) {} /// Method to re-implement to supply option values for a specific field - virtual QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) + virtual QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { return QList(); } diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiTreeOrdering.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiTreeOrdering.cpp index bb9ab1ec3b..90acb343ba 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiTreeOrdering.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiTreeOrdering.cpp @@ -59,7 +59,7 @@ void PdmUiTreeOrdering::add( PdmFieldHandle* field, QString uiConfigName ) if ( !field->uiCapability()->isUiTreeChildrenHidden( uiConfigName ) ) { std::vector children; - field->childObjects( &children ); + field->children( &children ); for ( PdmObjectHandle* objHandle : children ) { diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmXmlFieldCapability.inl b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmXmlFieldCapability.inl index a79b8853b2..9719add212 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmXmlFieldCapability.inl +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmXmlFieldCapability.inl @@ -163,7 +163,7 @@ void caf::PdmFieldXmlCap>::readFieldData( QXmlS m_isResolved = false; m_referenceString = dataString; - m_field->clear(); + m_field->clearWithoutDelete(); } //-------------------------------------------------------------------------------------------------- @@ -193,7 +193,7 @@ bool caf::PdmFieldXmlCap>::resolveReferences() { if ( m_isResolved ) return true; if ( m_referenceString.isEmpty() ) return true; - m_field->clear(); + m_field->clearWithoutDelete(); bool foundValidObjectFromString = true; QStringList tokens = m_referenceString.split( '|' ); @@ -373,7 +373,7 @@ template void caf::PdmFieldXmlCap>::readFieldData( QXmlStreamReader& xmlStream, PdmObjectFactory* objectFactory ) { - m_field->deleteAllChildObjects(); + m_field->deleteChildren(); PdmFieldIOHelper::skipCharactersAndComments( xmlStream ); while ( xmlStream.isStartElement() ) { diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmDefaultObjectFactory.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmDefaultObjectFactory.cpp index 93ece27245..2ee67310e6 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmDefaultObjectFactory.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmDefaultObjectFactory.cpp @@ -1,11 +1,63 @@ #include "cafPdmDefaultObjectFactory.h" +#include + namespace caf { //-------------------------------------------------------------------------------------------------- /// PdmObjectFactory implementations //-------------------------------------------------------------------------------------------------- +PdmDefaultObjectFactory* PdmDefaultObjectFactory::sm_singleton = nullptr; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +PdmDefaultObjectFactory::~PdmDefaultObjectFactory() +{ + // Each keyword alias is connected to the one creator object, so it is not possible to traverse the map directly and + // delete the creator objects. Create a set of unique creator objects. + std::set uniqueObjects; + + for ( const auto& f : m_factoryMap ) + { + uniqueObjects.insert( f.second ); + } + + for ( auto obj : uniqueObjects ) + { + if ( obj ) delete obj; + } + + m_factoryMap.clear(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +PdmDefaultObjectFactory* PdmDefaultObjectFactory::instance() +{ + createSingleton(); + return sm_singleton; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void PdmDefaultObjectFactory::createSingleton() +{ + if ( !sm_singleton ) sm_singleton = new PdmDefaultObjectFactory; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void PdmDefaultObjectFactory::deleteSingleton() +{ + if ( sm_singleton ) delete sm_singleton; + sm_singleton = nullptr; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -17,10 +69,8 @@ PdmObjectHandle* PdmDefaultObjectFactory::create( const QString& classNameKeywor { return entryIt->second->create(); } - else - { - return nullptr; - } + + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -38,13 +88,4 @@ std::vector PdmDefaultObjectFactory::classKeywords() const return names; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -PdmDefaultObjectFactory* PdmDefaultObjectFactory::instance() -{ - static PdmDefaultObjectFactory* fact = new PdmDefaultObjectFactory; - return fact; -} - } // End of namespace caf diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmDefaultObjectFactory.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmDefaultObjectFactory.h index eb5f29927b..4321f25e6c 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmDefaultObjectFactory.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmDefaultObjectFactory.h @@ -58,46 +58,28 @@ class PdmDefaultObjectFactory : public PdmObjectFactory public: static PdmDefaultObjectFactory* instance(); + static void createSingleton(); + static void deleteSingleton(); + PdmObjectHandle* create( const QString& classNameKeyword ) override; template - bool registerCreator() - { - std::vector classNameKeywords = PdmObjectBaseDerivative::classKeywordAliases(); - - for ( QString classNameKeyword : classNameKeywords ) - { - auto entryIt = m_factoryMap.find( classNameKeyword ); - if ( entryIt != m_factoryMap.end() ) - { - CAF_ASSERT( classNameKeyword != entryIt->first ); // classNameKeyword has already been used - CAF_ASSERT( false ); // To be sure .. - return false; // never hit; - } - } - auto object = new PdmObjectCreator(); - for ( QString classNameKeyword : classNameKeywords ) - { - m_factoryMap[classNameKeyword] = object; - } - return true; - } + bool registerCreator(); std::vector classKeywords() const override; private: - PdmDefaultObjectFactory() {} - ~PdmDefaultObjectFactory() override - { /* Could clean up, but ... */ - } + ~PdmDefaultObjectFactory() override; + + static PdmDefaultObjectFactory* sm_singleton; // Internal helper classes class PdmObjectCreatorBase { public: - PdmObjectCreatorBase() {} - virtual ~PdmObjectCreatorBase() {} + PdmObjectCreatorBase() = default; + virtual ~PdmObjectCreatorBase() = default; virtual PdmObjectHandle* create() = 0; }; @@ -112,4 +94,30 @@ class PdmDefaultObjectFactory : public PdmObjectFactory std::map m_factoryMap; }; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +template +bool caf::PdmDefaultObjectFactory::registerCreator() +{ + std::vector classNameKeywords = PdmObjectBaseDerivative::classKeywordAliases(); + + for ( const QString& classNameKeyword : classNameKeywords ) + { + auto entryIt = m_factoryMap.find( classNameKeyword ); + if ( entryIt != m_factoryMap.end() ) + { + CAF_ASSERT( classNameKeyword != entryIt->first ); // classNameKeyword has already been used + CAF_ASSERT( false ); // To be sure .. + return false; // never hit; + } + } + auto object = new PdmObjectCreator(); + for ( const QString& classNameKeyword : classNameKeywords ) + { + m_factoryMap[classNameKeyword] = object; + } + return true; +} + } // End of namespace caf diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmSettings.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmSettings.cpp index 4ccde3f392..ddebafab34 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmSettings.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmSettings.cpp @@ -61,7 +61,7 @@ void PdmSettings::readFieldsFromApplicationStore( caf::PdmObjectHandle* object, caf::PdmFieldHandle* fieldHandle = fields[i]; std::vector children; - fieldHandle->childObjects( &children ); + fieldHandle->children( &children ); for ( size_t childIdx = 0; childIdx < children.size(); childIdx++ ) { caf::PdmObjectHandle* child = children[childIdx]; @@ -109,7 +109,7 @@ void PdmSettings::writeFieldsToApplicationStore( const caf::PdmObjectHandle* obj caf::PdmFieldHandle* fieldHandle = fields[i]; std::vector children; - fieldHandle->childObjects( &children ); + fieldHandle->children( &children ); for ( size_t childIdx = 0; childIdx < children.size(); childIdx++ ) { caf::PdmObjectHandle* child = children[childIdx]; diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXmlObjectHandle.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXmlObjectHandle.cpp index bb53a79cc5..4284025b72 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXmlObjectHandle.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXmlObjectHandle.cpp @@ -325,7 +325,7 @@ void PdmXmlObjectHandle::initAfterReadRecursively( PdmObjectHandle* object ) size_t fIdx; for ( fIdx = 0; fIdx < fields.size(); ++fIdx ) { - if ( fields[fIdx] ) fields[fIdx]->childObjects( &children ); + if ( fields[fIdx] ) fields[fIdx]->children( &children ); } size_t cIdx; @@ -359,7 +359,7 @@ void PdmXmlObjectHandle::resolveReferencesRecursively( PdmObjectHandle* PdmFieldHandle* field = fields[fIdx]; if ( field ) { - field->childObjects( &children ); + field->children( &children ); bool resolvedOk = field->xmlCapability()->resolveReferences(); if ( fieldWithFailingResolve && !resolvedOk ) @@ -408,7 +408,7 @@ void PdmXmlObjectHandle::setupBeforeSaveRecursively( PdmObjectHandle* object ) size_t fIdx; for ( fIdx = 0; fIdx < fields.size(); ++fIdx ) { - if ( fields[fIdx] ) fields[fIdx]->childObjects( &children ); + if ( fields[fIdx] ) fields[fIdx]->children( &children ); } size_t cIdx; diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmXmlBasicTest.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmXmlBasicTest.cpp index 97734d3c42..fc37b8922b 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmXmlBasicTest.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmXmlBasicTest.cpp @@ -189,7 +189,7 @@ class InheritedDemoObj : public DemoPdmObject CAF_PDM_XML_InitField( &m_childArrayField, "DemoPdmObjectects" ); } - ~InheritedDemoObj() { m_childArrayField.deleteAllChildObjects(); } + ~InheritedDemoObj() { m_childArrayField.deleteChildren(); } caf::PdmDataValueField m_texts; caf::PdmChildArrayField m_childArrayField; @@ -257,7 +257,7 @@ class ReferenceDemoPdmObject : public caf::PdmObjectHandle, public caf::PdmXmlOb ~ReferenceDemoPdmObject() { delete m_pointersField(); - m_simpleObjPtrField2.deleteAllChildObjects(); + m_simpleObjPtrField2.deleteChildren(); } // Fields diff --git a/Fwk/AppFwk/cafProjectDataModel/cafProjectDataModel_UnitTests/cafPdmBasicTest.cpp b/Fwk/AppFwk/cafProjectDataModel/cafProjectDataModel_UnitTests/cafPdmBasicTest.cpp index 63dfae0aee..f09a293922 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafProjectDataModel_UnitTests/cafPdmBasicTest.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafProjectDataModel_UnitTests/cafPdmBasicTest.cpp @@ -193,7 +193,7 @@ class InheritedDemoObj : public DemoPdmObject "Whatsthis SimpleObjectsField" ); } - ~InheritedDemoObj() { m_simpleObjectsField.deleteAllChildObjects(); } + ~InheritedDemoObj() { m_simpleObjectsField.deleteChildren(); } caf::PdmField> m_texts; caf::PdmField> m_testEnumField; @@ -212,7 +212,7 @@ class MyPdmDocument : public caf::PdmDocument CAF_PDM_InitFieldNoDefault( &objects, "PdmObjects", "", "", "", "" ) } - ~MyPdmDocument() { objects.deleteAllChildObjects(); } + ~MyPdmDocument() { objects.deleteChildren(); } caf::PdmChildArrayField objects; }; @@ -550,7 +550,7 @@ TEST( BaseTest, ReadWrite ) } d2->m_simpleObjPtrField = NULL; - xmlDoc.objects.deleteAllChildObjects(); + xmlDoc.objects.deleteChildren(); } { @@ -866,7 +866,7 @@ TEST( BaseTest, PdmChildArrayFieldHandle ) // virtual void clear() = 0; // virtual PdmObject* createAppendObject(int indexAfter) = 0; // virtual void erase(size_t index) = 0; - // virtual void deleteAllChildObjects() = 0; + // virtual void deleteChildren() = 0; // // virtual PdmObject* at(size_t index) = 0; // @@ -907,7 +907,7 @@ TEST( BaseTest, PdmChildArrayFieldHandle ) EXPECT_TRUE( listField->hasSameFieldCountForAllObjects() ); EXPECT_FALSE( listField->empty() ); - listField->deleteAllChildObjects(); + listField->deleteChildren(); EXPECT_EQ( 0u, listField->size() ); EXPECT_TRUE( listField->hasSameFieldCountForAllObjects() ); EXPECT_TRUE( listField->empty() ); diff --git a/Fwk/AppFwk/cafTests/cafTestApplication/CMakeLists.txt b/Fwk/AppFwk/cafTests/cafTestApplication/CMakeLists.txt index 88102d6e33..89c306b8d4 100644 --- a/Fwk/AppFwk/cafTests/cafTestApplication/CMakeLists.txt +++ b/Fwk/AppFwk/cafTests/cafTestApplication/CMakeLists.txt @@ -45,6 +45,8 @@ set(PROJECT_FILES MenuItemProducer.h TamComboBox.h TamComboBox.cpp + LineEditAndPushButtons.h + LineEditAndPushButtons.cpp ) # add the executable diff --git a/Fwk/AppFwk/cafTests/cafTestApplication/CustomObjectEditor.h b/Fwk/AppFwk/cafTests/cafTestApplication/CustomObjectEditor.h index bd8108ddcc..a5f9d3d1c7 100644 --- a/Fwk/AppFwk/cafTests/cafTestApplication/CustomObjectEditor.h +++ b/Fwk/AppFwk/cafTests/cafTestApplication/CustomObjectEditor.h @@ -69,7 +69,7 @@ class CustomObjectEditor : public PdmUiFormLayoutObjectEditor void defineGridLayout(int rowCount, int columnCount); // See QGridLayout::addWidget - void addWidget(QWidget* widget, int row, int column, int rowSpan, int columnSpan, Qt::Alignment alignment = nullptr); + void addWidget(QWidget* widget, int row, int column, int rowSpan, int columnSpan, Qt::Alignment alignment = Qt::Alignment()); void removeWidget(QWidget* widget); void addBlankCell(int row, int column); diff --git a/Fwk/AppFwk/cafTests/cafTestApplication/LineEditAndPushButtons.cpp b/Fwk/AppFwk/cafTests/cafTestApplication/LineEditAndPushButtons.cpp new file mode 100644 index 0000000000..32059e1f39 --- /dev/null +++ b/Fwk/AppFwk/cafTests/cafTestApplication/LineEditAndPushButtons.cpp @@ -0,0 +1,188 @@ + +#include "LineEditAndPushButtons.h" + +#include "cafPdmUiLineEditor.h" +#include "cafPdmUiListEditor.h" +#include "cafPdmUiPushButtonEditor.h" +#include "cafPdmUiTreeSelectionEditor.h" + +CAF_PDM_SOURCE_INIT(LineEditAndPushButtons, "LineEditAndPushButtons"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +LineEditAndPushButtons::LineEditAndPushButtons() +{ + CAF_PDM_InitObject("Line Edit And Push Buttons", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_statusTextField, "StatusTextField", "Status Text", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_textField, "TextField", "Text", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_textListField, "TextListField", "Text List Field", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_pushButton_a, "PushButtonA", "Rotate", "", "", ""); + m_pushButton_a.uiCapability()->setUiEditorTypeName(caf::PdmUiPushButtonEditor::uiEditorTypeName()); + m_pushButton_a.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); + + CAF_PDM_InitFieldNoDefault(&m_pushButtonReplace, "PushButtonB", "Replace (CTRL + Enter)", "", "", ""); + m_pushButtonReplace.uiCapability()->setUiEditorTypeName(caf::PdmUiPushButtonEditor::uiEditorTypeName()); + m_pushButtonReplace.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); + + CAF_PDM_InitFieldNoDefault(&m_pushButtonClear, "PushButtonC", "Clear (Alt + Enter)", "", "", ""); + m_pushButtonClear.uiCapability()->setUiEditorTypeName(caf::PdmUiPushButtonEditor::uiEditorTypeName()); + m_pushButtonClear.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); + + CAF_PDM_InitFieldNoDefault(&m_pushButtonAppend, "PushButtonD", "Append (Shift + Enter)", "", "", ""); + m_pushButtonAppend.uiCapability()->setUiEditorTypeName(caf::PdmUiPushButtonEditor::uiEditorTypeName()); + m_pushButtonAppend.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); + + std::vector items; + items.push_back("sldkfj"); + items.push_back("annet sldkfj"); + items.push_back("kort"); + items.push_back("veldig langt"); + items.push_back("kort"); + + m_textListField = items; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void LineEditAndPushButtons::fieldChangedByUi(const caf::PdmFieldHandle* changedField, + const QVariant& oldValue, + const QVariant& newValue) +{ + if (changedField == &m_pushButton_a) + { + rotateContent(); + } + + if (changedField == &m_textField) + { + auto mods = QGuiApplication::keyboardModifiers(); + + // Use global keyboard modifiers to trigger different events when content is changed in editor changes + + if (mods & Qt::ShiftModifier) + appendText(); + else if (mods & Qt::ControlModifier) + replaceText(); + else if (mods & Qt::AltModifier) + clearText(); + else + { + m_statusTextField = m_textField; + } + } + + if (changedField == &m_pushButtonReplace) + { + replaceText(); + } + if (changedField == &m_pushButtonClear) + { + clearText(); + } + if (changedField == &m_pushButtonAppend) + { + appendText(); + } + + m_pushButton_a = false; + m_pushButtonReplace = false; + m_pushButtonClear = false; + m_pushButtonAppend = false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void LineEditAndPushButtons::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void LineEditAndPushButtons::defineEditorAttribute(const caf::PdmFieldHandle* field, + QString uiConfigName, + caf::PdmUiEditorAttribute* attribute) +{ + if (field == &m_textField) + { + auto myAttr = dynamic_cast(attribute); + if (myAttr) + { + myAttr->notifyWhenTextIsEdited = true; + } + } + + { + auto myAttr = dynamic_cast(attribute); + if (myAttr) + { + if (field == &m_pushButton_a) + { + myAttr->m_buttonText = "&Push Me"; + } + if (field == &m_pushButtonReplace) + { + myAttr->m_buttonText = "Replace (Ctrl + Enter)"; + } + if (field == &m_pushButtonClear) + { + myAttr->m_buttonText = "Clear (Alt + Enter)"; + } + if (field == &m_pushButtonAppend) + { + myAttr->m_buttonText = "Append (Shift + Enter)"; + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void LineEditAndPushButtons::rotateContent() +{ + auto original = m_textListField.value(); + + std::list newContent; + newContent.insert(newContent.begin(), original.begin(), original.end()); + + auto firstItem = newContent.front(); + newContent.pop_front(); + newContent.push_back(firstItem); + + std::vector tmp; + tmp.insert(tmp.begin(), newContent.begin(), newContent.end()); + + m_textListField = tmp; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void LineEditAndPushButtons::appendText() +{ + auto original = m_textListField.value(); + original.push_back(m_textField); + + m_textListField = original; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void LineEditAndPushButtons::replaceText() +{ + clearText(); + appendText(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void LineEditAndPushButtons::clearText() +{ + m_textListField = std::vector(); +} diff --git a/Fwk/AppFwk/cafTests/cafTestApplication/LineEditAndPushButtons.h b/Fwk/AppFwk/cafTests/cafTestApplication/LineEditAndPushButtons.h new file mode 100644 index 0000000000..f3cb5e3008 --- /dev/null +++ b/Fwk/AppFwk/cafTests/cafTestApplication/LineEditAndPushButtons.h @@ -0,0 +1,38 @@ +#pragma once + +#include "cafPdmField.h" +#include "cafPdmObject.h" +#include "cafPdmProxyValueField.h" + +class LineEditAndPushButtons : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + LineEditAndPushButtons(); + + void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; + +private: + void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + + void defineEditorAttribute(const caf::PdmFieldHandle* field, + QString uiConfigName, + caf::PdmUiEditorAttribute* attribute) override; + + void rotateContent(); + void appendText(); + void replaceText(); + void clearText(); + +private: + caf::PdmField m_textField; + caf::PdmField m_statusTextField; + caf::PdmField> m_textListField; + + caf::PdmField m_pushButton_a; + + caf::PdmField m_pushButtonReplace; + caf::PdmField m_pushButtonClear; + caf::PdmField m_pushButtonAppend; +}; diff --git a/Fwk/AppFwk/cafTests/cafTestApplication/Main.cpp b/Fwk/AppFwk/cafTests/cafTestApplication/Main.cpp index 2fcebf530f..ce6ab18095 100644 --- a/Fwk/AppFwk/cafTests/cafTestApplication/Main.cpp +++ b/Fwk/AppFwk/cafTests/cafTestApplication/Main.cpp @@ -1,16 +1,38 @@ #include "MainWindow.h" +#include "cafCmdFeatureManager.h" +#include "cafPdmDefaultObjectFactory.h" + +#include "cafFactory.h" +#include "cafPdmUiFieldEditorHandle.h" #include int main(int argc, char* argv[]) { - QApplication app(argc, argv); + auto appExitCode = 0; + { + QApplication app(argc, argv); + + MainWindow window; + window.setWindowTitle("Ceetron Application Framework Test Application"); + window.resize(1000, 810); + window.show(); + + appExitCode = app.exec(); + } + + caf::CmdFeatureManager::deleteSingleton(); + caf::PdmDefaultObjectFactory::deleteSingleton(); - MainWindow window; - window.setWindowTitle("Ceetron Application Framework Test Application"); - window.resize(1000, 810); - window.show(); + { + auto factory = caf::Factory::instance(); + factory->deleteCreatorObjects(); + } + { + auto factory = caf::Factory::instance(); + factory->deleteCreatorObjects(); + } - return app.exec(); + return appExitCode; } diff --git a/Fwk/AppFwk/cafTests/cafTestApplication/MainWindow.cpp b/Fwk/AppFwk/cafTests/cafTestApplication/MainWindow.cpp index 90c752ba2c..c9205c7f73 100644 --- a/Fwk/AppFwk/cafTests/cafTestApplication/MainWindow.cpp +++ b/Fwk/AppFwk/cafTests/cafTestApplication/MainWindow.cpp @@ -4,6 +4,7 @@ #include "MainWindow.h" #include "CustomObjectEditor.h" +#include "LineEditAndPushButtons.h" #include "ManyGroups.h" #include "MenuItemProducer.h" #include "TamComboBox.h" @@ -54,10 +55,9 @@ class DemoPdmObjectGroup : public caf::PdmDocument public: DemoPdmObjectGroup() { - CAF_PDM_InitFieldNoDefault(&objects, "PdmObjects", "", "", "", "") + CAF_PDM_InitFieldNoDefault(&objects, "PdmObjects", "MyRootObject", "", "", ""); - objects.uiCapability() - ->setUiHidden(true); + objects.uiCapability()->setUiHidden(true); } public: @@ -199,8 +199,7 @@ class SmallDemoPdmObject : public caf::PdmObject //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- - QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly) override + QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions) override { QList options; @@ -750,8 +749,7 @@ class SmallDemoPdmObjectA : public caf::PdmObject } } - QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly) override + QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions) override { QList options; @@ -761,7 +759,7 @@ class SmallDemoPdmObjectA : public caf::PdmObject std::vector objects; field = this->parentField(); - field->childObjects(&objects); + field->children(&objects); for (size_t i = 0; i < objects.size(); ++i) { @@ -794,8 +792,6 @@ class SmallDemoPdmObjectA : public caf::PdmObject } } - if (useOptionsOnly) *useOptionsOnly = true; - return options; } @@ -942,8 +938,7 @@ class DemoPdmObject : public caf::PdmObject //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- - QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly) override + QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions) override { QList options; if (&m_multiSelectList == fieldNeedingOptions) @@ -970,8 +965,6 @@ class DemoPdmObject : public caf::PdmObject } } - if (useOptionsOnly) *useOptionsOnly = true; - return options; } @@ -1200,6 +1193,8 @@ void MainWindow::buildTestModel() SingleEditorPdmObject* singleEditorObj = new SingleEditorPdmObject; m_testRoot->objects.push_back(singleEditorObj); + m_testRoot->objects.push_back(new LineEditAndPushButtons); + auto tamComboBox = new TamComboBox; m_testRoot->objects.push_back(tamComboBox); @@ -1297,6 +1292,8 @@ MainWindow::~MainWindow() m_pdmUiPropertyView->showProperties(nullptr); m_pdmUiTableView->setChildArrayField(nullptr); + releaseTestData(); + delete m_pdmUiTreeView; delete m_pdmUiTreeView2; delete m_pdmUiPropertyView; @@ -1311,7 +1308,7 @@ void MainWindow::releaseTestData() { if (m_testRoot) { - m_testRoot->objects.deleteAllChildObjects(); + m_testRoot->objects.deleteChildren(); delete m_testRoot; } } @@ -1410,7 +1407,7 @@ void MainWindow::slotRemove() // Ordering is important - field->removeChildObject(obj); + field->removeChild(obj); // Delete object delete obj; diff --git a/Fwk/AppFwk/cafTests/cafTestApplication/ManyGroups.cpp b/Fwk/AppFwk/cafTests/cafTestApplication/ManyGroups.cpp index 8d35e7906e..114b90ac9b 100644 --- a/Fwk/AppFwk/cafTests/cafTestApplication/ManyGroups.cpp +++ b/Fwk/AppFwk/cafTests/cafTestApplication/ManyGroups.cpp @@ -87,8 +87,7 @@ void ManyGroups::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList ManyGroups::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly) +QList ManyGroups::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions) { QList options; diff --git a/Fwk/AppFwk/cafTests/cafTestApplication/ManyGroups.h b/Fwk/AppFwk/cafTests/cafTestApplication/ManyGroups.h index 3464cd52c5..7e01459b50 100644 --- a/Fwk/AppFwk/cafTests/cafTestApplication/ManyGroups.h +++ b/Fwk/AppFwk/cafTests/cafTestApplication/ManyGroups.h @@ -38,8 +38,7 @@ class ManyGroups : public caf::PdmObject //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- - QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly) override; + QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions) override; private: double m_doubleMember; diff --git a/Fwk/AppFwk/cafTests/cafTestApplication/TamComboBox.cpp b/Fwk/AppFwk/cafTests/cafTestApplication/TamComboBox.cpp index a1477d84c5..938267befd 100644 --- a/Fwk/AppFwk/cafTests/cafTestApplication/TamComboBox.cpp +++ b/Fwk/AppFwk/cafTests/cafTestApplication/TamComboBox.cpp @@ -19,8 +19,7 @@ TamComboBox::TamComboBox() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList TamComboBox::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly) +QList TamComboBox::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions) { QList options; diff --git a/Fwk/AppFwk/cafTests/cafTestApplication/TamComboBox.h b/Fwk/AppFwk/cafTests/cafTestApplication/TamComboBox.h index 33b3296f16..c5366adb14 100644 --- a/Fwk/AppFwk/cafTests/cafTestApplication/TamComboBox.h +++ b/Fwk/AppFwk/cafTests/cafTestApplication/TamComboBox.h @@ -18,8 +18,7 @@ class TamComboBox : public caf::PdmObject public: TamComboBox(); - virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly) override; + virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions) override; virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; diff --git a/Fwk/AppFwk/cafTests/cafTestApplication/WidgetLayoutTest.h b/Fwk/AppFwk/cafTests/cafTestApplication/WidgetLayoutTest.h index 68dba8027a..bc2fb3d031 100644 --- a/Fwk/AppFwk/cafTests/cafTestApplication/WidgetLayoutTest.h +++ b/Fwk/AppFwk/cafTests/cafTestApplication/WidgetLayoutTest.h @@ -10,7 +10,7 @@ class WidgetLayoutTest : public QWidget Q_OBJECT public: - WidgetLayoutTest(QWidget* parent = nullptr, Qt::WindowFlags f = nullptr); + WidgetLayoutTest(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); ~WidgetLayoutTest() override; private: diff --git a/Fwk/AppFwk/cafTests/cafTestCvfApplication/MainWindow.cpp b/Fwk/AppFwk/cafTests/cafTestCvfApplication/MainWindow.cpp index 5834254d13..2cde2fa261 100644 --- a/Fwk/AppFwk/cafTests/cafTestCvfApplication/MainWindow.cpp +++ b/Fwk/AppFwk/cafTests/cafTestCvfApplication/MainWindow.cpp @@ -282,7 +282,7 @@ void MainWindow::slotRemove() // Ordering is important - field->removeChildObject(obj); + field->removeChild(obj); // Delete object delete obj; diff --git a/Fwk/AppFwk/cafUserInterface/CMakeLists.txt b/Fwk/AppFwk/cafUserInterface/CMakeLists.txt index 15d71efcd3..8d558685b2 100644 --- a/Fwk/AppFwk/cafUserInterface/CMakeLists.txt +++ b/Fwk/AppFwk/cafUserInterface/CMakeLists.txt @@ -165,6 +165,9 @@ set(PROJECT_FILES cafStyleSheetTools.cpp cafPdmUiTabbedPropertyViewDialog.h cafPdmUiTabbedPropertyViewDialog.cpp + cafPdmUiTreeViewItemDelegate.h + cafPdmUiTreeViewItemDelegate.cpp + cafPdmUiTreeAttributes.h ) add_library( diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiComboBoxEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiComboBoxEditor.cpp index f491f3bf10..062fd3689d 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiComboBoxEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiComboBoxEditor.cpp @@ -217,9 +217,7 @@ void PdmUiComboBoxEditor::configureAndUpdateUi( const QString& uiConfigName ) m_comboBox->setEnabled( !uiField()->isUiReadOnly( uiConfigName ) ); m_comboBox->setToolTip( uiField()->uiToolTip( uiConfigName ) ); - bool fromMenuOnly = true; - QList options = uiField()->valueOptions( &fromMenuOnly ); - CAF_ASSERT( fromMenuOnly ); // Not supported + QList options = uiField()->valueOptions(); m_comboBox->blockSignals( true ); m_comboBox->clear(); @@ -254,7 +252,7 @@ void PdmUiComboBoxEditor::configureAndUpdateUi( const QString& uiConfigName ) } else if ( m_attributes.minimumContentsLength > 0 ) { - m_comboBox->setSizeAdjustPolicy( QComboBox::AdjustToMinimumContentsLength ); + m_comboBox->setSizeAdjustPolicy( QComboBox::AdjustToContents ); m_comboBox->setMinimumContentsLength( m_attributes.minimumContentsLength ); // Make sure the popup adjusts to the content even if the widget itself doesn't QFont font = m_comboBox->view()->font(); @@ -281,9 +279,28 @@ void PdmUiComboBoxEditor::configureAndUpdateUi( const QString& uiConfigName ) { m_comboBox->setEditable( true ); + if ( !m_attributes.enableAutoComplete ) + { + m_comboBox->setCompleter( nullptr ); + } + m_comboBox->lineEdit()->setPlaceholderText( m_attributes.placeholderText ); } + if ( m_attributes.notifyWhenTextIsEdited ) + { + connect( m_comboBox, + SIGNAL( editTextChanged( const QString& ) ), + this, + SLOT( slotEditTextChanged( const QString& ) ) ); + + if ( m_interactiveEditText == m_comboBox->lineEdit()->text() && m_interactiveEditCursorPosition > -1 ) + { + m_comboBox->lineEdit()->setCursorPosition( m_interactiveEditCursorPosition ); + m_comboBox->lineEdit()->deselect(); + } + } + if ( m_attributes.minimumWidth != -1 ) { m_comboBox->setMinimumWidth( m_attributes.minimumWidth ); @@ -345,7 +362,7 @@ void PdmUiComboBoxEditor::configureAndUpdateUi( const QString& uiConfigName ) } else { - toolButtonIcon = stepUpIcon(); + toolButtonIcon = stepDownIcon(); } if ( m_comboBox->count() == 0 || m_comboBox->currentIndex() >= m_comboBox->count() - 1 ) { @@ -455,6 +472,14 @@ class CustomQComboBox : public QComboBox } }; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +PdmUiComboBoxEditor::PdmUiComboBoxEditor() + : m_interactiveEditCursorPosition( -1 ) +{ +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -472,6 +497,9 @@ QWidget* PdmUiComboBoxEditor::createEditorWidget( QWidget* parent ) connect( m_comboBox, SIGNAL( activated( int ) ), this, SLOT( slotIndexActivated( int ) ) ); + // Forward focus event to combo box editor + m_placeholder->setFocusProxy( m_comboBox ); + return m_placeholder; } @@ -509,6 +537,19 @@ void PdmUiComboBoxEditor::slotIndexActivated( int index ) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void PdmUiComboBoxEditor::slotEditTextChanged( const QString& text ) +{ + if ( text == m_interactiveEditText ) return; + + m_interactiveEditText = text; + m_interactiveEditCursorPosition = m_comboBox->lineEdit()->cursorPosition(); + + this->setValueToField( text ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiComboBoxEditor.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiComboBoxEditor.h index f83a3d7f9e..4dbb3b1f63 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiComboBoxEditor.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiComboBoxEditor.h @@ -61,8 +61,10 @@ class PdmUiComboBoxEditorAttribute : public PdmUiEditorAttribute minimumContentsLength = 8; maximumMenuContentsLength = 40; enableEditableContent = false; + enableAutoComplete = true; minimumWidth = -1; iconSize = QSize( 14, 14 ); + notifyWhenTextIsEdited = false; } public: @@ -72,6 +74,7 @@ class PdmUiComboBoxEditorAttribute : public PdmUiEditorAttribute // Set to <= 0 to ignore and use AdjustToContentsOnFirstShow instead int maximumMenuContentsLength; bool enableEditableContent; + bool enableAutoComplete; int minimumWidth; QString placeholderText; QString nextButtonText; @@ -80,6 +83,8 @@ class PdmUiComboBoxEditorAttribute : public PdmUiEditorAttribute QSize iconSize; QIcon nextIcon; QIcon previousIcon; + + bool notifyWhenTextIsEdited; }; //================================================================================================== @@ -91,7 +96,7 @@ class PdmUiComboBoxEditor : public PdmUiFieldEditorHandle CAF_PDM_UI_FIELD_EDITOR_HEADER_INIT; public: - PdmUiComboBoxEditor() {} + PdmUiComboBoxEditor(); ~PdmUiComboBoxEditor() override {} protected: @@ -102,6 +107,7 @@ class PdmUiComboBoxEditor : public PdmUiFieldEditorHandle protected slots: void slotIndexActivated( int index ); + void slotEditTextChanged( const QString& ); void slotNextButtonPressed(); void slotPreviousButtonPressed(); @@ -116,6 +122,9 @@ protected slots: QPointer m_placeholder; PdmUiComboBoxEditorAttribute m_attributes; + + QString m_interactiveEditText; + int m_interactiveEditCursorPosition; }; } // end namespace caf diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiDragDropInterface.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiDragDropInterface.h index 43bf610306..02db7b3201 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiDragDropInterface.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiDragDropInterface.h @@ -50,6 +50,8 @@ class PdmUiDragDropInterface public: virtual ~PdmUiDragDropInterface() = 0; + static QString mimeTypeForObjectReferenceList() { return "ObjectReferenceList"; } + protected: friend class PdmUiTreeViewQModel; friend class PdmUiTreeViewWidget; diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiFieldEditorHelper.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiFieldEditorHelper.cpp index deec96180f..e5e2404be9 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiFieldEditorHelper.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiFieldEditorHelper.cpp @@ -60,7 +60,8 @@ caf::PdmUiFieldEditorHandle* caf::PdmUiFieldEditorHelper::createFieldEditorForFi else { // Find the default field editor - QString fieldTypeName = qStringTypeName( *( field->fieldHandle() ) ); + auto fieldHandle = field->fieldHandle(); + QString fieldTypeName = qStringTypeName( *fieldHandle ); if ( fieldTypeName.indexOf( "PdmPtrField" ) != -1 ) { @@ -74,10 +75,7 @@ caf::PdmUiFieldEditorHandle* caf::PdmUiFieldEditorHelper::createFieldEditorForFi { // Handle a single value field with valueOptions: Make a combobox - bool useOptionsOnly = true; - QList options = field->valueOptions( &useOptionsOnly ); - CAF_ASSERT( useOptionsOnly ); // Not supported - + QList options = field->valueOptions(); if ( !options.empty() ) { fieldTypeName = caf::PdmUiComboBoxEditor::uiEditorTypeName(); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiFormLayoutObjectEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiFormLayoutObjectEditor.cpp index 3538d71a10..80b89e91a5 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiFormLayoutObjectEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiFormLayoutObjectEditor.cpp @@ -215,6 +215,8 @@ int caf::PdmUiFormLayoutObjectEditor::recursivelyConfigureAndUpdateUiOrderingInG labelAndFieldVerticalLayout->addWidget( fieldLabelWidget, 0, Qt::AlignTop ); labelAndFieldVerticalLayout->addWidget( fieldEditorWidget, 1, Qt::AlignTop ); + m_layouts.push_back( labelAndFieldVerticalLayout ); + // Apply margins determined by the editor type // fieldLabelWidget->setContentsMargins(fieldEditor->labelContentMargins()); currentColumn += itemColumnSpan; @@ -489,6 +491,13 @@ void caf::PdmUiFormLayoutObjectEditor::cleanupBeforeSettingPdmObject() } m_groupBoxes.clear(); + + for ( auto l : m_layouts ) + { + delete l; + l = nullptr; + } + m_layouts.clear(); } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiFormLayoutObjectEditor.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiFormLayoutObjectEditor.h index 46d9de8885..36edebe077 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiFormLayoutObjectEditor.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiFormLayoutObjectEditor.h @@ -47,6 +47,7 @@ class QMinimizePanel; class QGridLayout; class QWidget; +class QVBoxLayout; namespace caf { @@ -110,6 +111,7 @@ private slots: std::map> m_newGroupBoxes; ///< used temporarily to store the new(complete) set of ///< group boxes std::map> m_objectKeywordGroupUiNameExpandedState; + std::vector> m_layouts; }; } // end namespace caf diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp index fe9f9942d6..4bad41d482 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp @@ -141,13 +141,15 @@ void PdmUiLineEditor::configureAndUpdateUi( const QString& uiConfigName ) { m_lineEdit->setPlaceholderText( leab.placeholderText ); } - } - bool fromMenuOnly = true; - m_optionCache = uiField()->valueOptions( &fromMenuOnly ); - CAF_ASSERT( fromMenuOnly ); // Not supported + if ( leab.notifyWhenTextIsEdited ) + { + connect( m_lineEdit, SIGNAL( textEdited( const QString& ) ), this, SLOT( slotEditingFinished() ) ); + } + } - if ( !m_optionCache.isEmpty() && fromMenuOnly == true ) + m_optionCache = uiField()->valueOptions(); + if ( !m_optionCache.isEmpty() ) { if ( !m_completer ) { @@ -220,7 +222,10 @@ void PdmUiLineEditor::configureAndUpdateUi( const QString& uiConfigName ) displayString = displayStringAttrib.m_displayString; } - m_lineEdit->setText( displayString ); + if ( displayString != m_lineEdit->text() ) + { + m_lineEdit->setText( displayString ); + } } } } diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.h index 229f831595..d512e107bb 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.h @@ -65,6 +65,7 @@ class PdmUiLineEditorAttribute : public PdmUiEditorAttribute maximumWidth = -1; selectAllOnFocusEvent = false; placeholderText = ""; + notifyWhenTextIsEdited = false; } public: @@ -77,6 +78,7 @@ class PdmUiLineEditorAttribute : public PdmUiEditorAttribute int maximumWidth; bool selectAllOnFocusEvent; QString placeholderText; + bool notifyWhenTextIsEdited; }; //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp index 862c4bc697..1471399f4f 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp @@ -159,9 +159,8 @@ void PdmUiListEditor::configureAndUpdateUi( const QString& uiConfigName ) m_listView->setEnabled( !uiField()->isUiReadOnly( uiConfigName ) ); m_listView->setToolTip( uiField()->uiToolTip( uiConfigName ) ); - bool optionsOnly = true; - QList options = uiField()->valueOptions( &optionsOnly ); - m_optionItemCount = options.size(); + QList options = uiField()->valueOptions(); + m_optionItemCount = options.size(); if ( options.size() > 0 || uiField()->isUiReadOnly( uiConfigName ) ) { m_isEditOperationsAvailable = false; @@ -194,8 +193,6 @@ void PdmUiListEditor::configureAndUpdateUi( const QString& uiConfigName ) if ( !options.isEmpty() ) { - CAF_ASSERT( optionsOnly ); // Handling Additions on the fly not implemented - strListModel->setItemsEditable( false ); QModelIndex currentItem = m_listView->selectionModel()->currentIndex(); QStringList texts = PdmOptionItemInfo::extractUiTexts( options ); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiListView.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiListView.h index 2a526e1cab..e374cb84ab 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiListView.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiListView.h @@ -52,7 +52,7 @@ class PdmUiListView : public QWidget { Q_OBJECT public: - PdmUiListView( QWidget* parent = nullptr, Qt::WindowFlags f = nullptr ); + PdmUiListView( QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags() ); ~PdmUiListView() override; void setPdmObject( caf::PdmObjectCollection* object ); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyView.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyView.cpp index 5d24a80e8e..598e750fd8 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyView.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyView.cpp @@ -53,7 +53,7 @@ QVerticalScrollArea::QVerticalScrollArea( QWidget* parent ) : QScrollArea( parent ) { setWidgetResizable( true ); - setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); + setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded ); setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded ); } @@ -65,6 +65,7 @@ QSize QVerticalScrollArea::sizeHint() const QSize widgetSize = widget()->sizeHint(); QSize scrollSize = QScrollArea::sizeHint(); scrollSize.setWidth( widgetSize.width() + verticalScrollBar()->width() ); + return scrollSize; } @@ -73,9 +74,9 @@ QSize QVerticalScrollArea::sizeHint() const //-------------------------------------------------------------------------------------------------- QSize QVerticalScrollArea::minimumSizeHint() const { - QSize widgetSize = widget()->minimumSizeHint(); QSize scrollSize = QScrollArea::minimumSizeHint(); - scrollSize.setWidth( widgetSize.width() + verticalScrollBar()->width() ); + scrollSize.setWidth( 10 ); + return scrollSize; } diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableView.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableView.h index ec4d81d909..1c41eba05f 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableView.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableView.h @@ -59,7 +59,7 @@ class PdmUiTableView : public QWidget { Q_OBJECT public: - PdmUiTableView( QWidget* parent = nullptr, Qt::WindowFlags f = nullptr ); + PdmUiTableView( QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags() ); ~PdmUiTableView() override; void setChildArrayField( PdmChildArrayFieldHandle* childArrayField ); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.cpp index a8135988fa..bd490f6ba1 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.cpp @@ -164,6 +164,11 @@ void PdmUiTableViewEditor::configureAndUpdateUi( const QString& uiConfigName ) QPalette myPalette( m_tableView->palette() ); myPalette.setColor( QPalette::Base, editorAttrib.baseColor ); m_tableView->setPalette( myPalette ); + + // Drop target settings + m_tableView->setAcceptDrops( editorAttrib.enableDropTarget ); + m_tableView->setDropIndicatorShown( editorAttrib.enableDropTarget ); + m_tableModelPdm->enableDropTarget( editorAttrib.enableDropTarget ); } m_tableModelPdm->setArrayFieldAndBuildEditors( childArrayFH, uiConfigName ); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.h index 0d1662649a..413938ccdd 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.h @@ -92,6 +92,7 @@ class PdmUiTableViewEditorAttribute : public PdmUiEditorAttribute , minimumHeight( -1 ) , alwaysEnforceResizePolicy( false ) , resizePolicy( NO_AUTOMATIC_RESIZE ) + , enableDropTarget( false ) { QPalette myPalette; baseColor = myPalette.color( QPalette::Active, QPalette::Base ); @@ -106,6 +107,7 @@ class PdmUiTableViewEditorAttribute : public PdmUiEditorAttribute QColor baseColor; bool alwaysEnforceResizePolicy; ResizePolicy resizePolicy; + bool enableDropTarget; }; //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewQModel.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewQModel.cpp index 9079dab4ec..cea9c7bd77 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewQModel.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewQModel.cpp @@ -57,8 +57,9 @@ namespace caf //-------------------------------------------------------------------------------------------------- PdmUiTableViewQModel::PdmUiTableViewQModel( QWidget* parent ) : QAbstractTableModel( parent ) + , m_pdmList( nullptr ) + , m_dropTargetEnabled( false ) { - m_pdmList = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -141,6 +142,12 @@ Qt::ItemFlags PdmUiTableViewQModel::flags( const QModelIndex& index ) const } } } + + if ( m_dropTargetEnabled ) + { + flagMask |= Qt::ItemIsDropEnabled; + } + return flagMask; } @@ -214,9 +221,7 @@ QVariant PdmUiTableViewQModel::data( const QModelIndex& index, int role /*= Qt:: if ( !valuesSelectedInField.empty() ) { QList options; - bool useOptionsOnly = true; - options = uiFieldHandle->valueOptions( &useOptionsOnly ); - CAF_ASSERT( useOptionsOnly ); // Not supported + options = uiFieldHandle->valueOptions(); for ( const QVariant& v : valuesSelectedInField ) { @@ -236,10 +241,7 @@ QVariant PdmUiTableViewQModel::data( const QModelIndex& index, int role /*= Qt:: return displayText; } - bool useOptionsOnly = true; - QList valueOptions = uiFieldHandle->valueOptions( &useOptionsOnly ); - CAF_ASSERT( useOptionsOnly ); // Not supported - + QList valueOptions = uiFieldHandle->valueOptions(); if ( !valueOptions.isEmpty() ) { int listIndex = uiFieldHandle->uiValue().toInt(); @@ -661,6 +663,63 @@ void PdmUiTableViewQModel::createPersistentPushButtonWidgets( QTableView* tableV } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void PdmUiTableViewQModel::enableDropTarget( bool enable ) +{ + m_dropTargetEnabled = enable; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool PdmUiTableViewQModel::dropMimeData( const QMimeData* data, + Qt::DropAction action, + int row, + int column, + const QModelIndex& parent ) +{ + // The receiving model index is specified by the parent. Find object and field from parent, and send QMimeData to + // this object + + if ( !m_dropTargetEnabled ) return false; + + auto pdmObject = pdmObjectForRow( parent.row() ); + auto field = getField( parent ); + + if ( pdmObject ) + { + pdmObject->handleDroppedMimeData( data, action, field ); + return true; + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Qt::DropActions PdmUiTableViewQModel::supportedDropActions() const +{ + return Qt::CopyAction | Qt::MoveAction | Qt::LinkAction; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool PdmUiTableViewQModel::canDropMimeData( const QMimeData* data, + Qt::DropAction action, + int row, + int column, + const QModelIndex& parent ) const +{ + // This function can be extended to validate incoming QMimeData and see if this data is matching with the drop + // target. For now, all data is allowed to be dropped when drop target is enabled + + return m_dropTargetEnabled; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewQModel.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewQModel.h index d0459eba12..ad933a4dd2 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewQModel.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewQModel.h @@ -100,6 +100,16 @@ class PdmUiTableViewQModel : public QAbstractTableModel bool isRepresentingBoolean( const QModelIndex& index ) const; void createPersistentPushButtonWidgets( QTableView* tableView ); + void enableDropTarget( bool enable ); + +protected: + bool dropMimeData( const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent ) override; + Qt::DropActions supportedDropActions() const override; + bool canDropMimeData( const QMimeData* data, + Qt::DropAction action, + int row, + int column, + const QModelIndex& parent ) const override; private: int getFieldIndex( PdmFieldHandle* field ) const; @@ -117,6 +127,7 @@ class PdmUiTableViewQModel : public QAbstractTableModel PdmPointer m_ownerObject; PdmChildArrayFieldHandle* m_pdmList; QString m_currentConfigName; + bool m_dropTargetEnabled; std::map m_fieldEditors; std::vector m_modelColumnIndexToFieldIndex; diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiToolBarEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiToolBarEditor.cpp index e02a406c18..f61e06c4b6 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiToolBarEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiToolBarEditor.cpp @@ -121,9 +121,9 @@ void PdmUiToolBarEditor::configureAndUpdateUi( const QString& uiConfigName ) } } - PdmUiOrdering config; for ( caf::PdmUiObjectHandle* ownerUiObject : ownerUiObjects ) { + PdmUiOrdering config; ownerUiObject->uiOrdering( uiConfigName, config ); } } @@ -183,8 +183,11 @@ void PdmUiToolBarEditor::configureAndUpdateUi( const QString& uiConfigName ) } } - CAF_ASSERT( m_fields.size() == m_fieldViews.size() ); - CAF_ASSERT( static_cast( m_fields.size() ) == m_actions.size() ); + // CAF_ASSERT( m_fields.size() == m_fieldViews.size() ); + if ( static_cast( m_fields.size() ) != m_actions.size() ) return; + + // CAF_ASSERT( static_cast( m_fields.size() ) == m_actions.size() ); + if ( static_cast( m_fields.size() ) != m_actions.size() ) return; for ( size_t i = 0; i < m_fields.size(); i++ ) { diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeAttributes.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeAttributes.h new file mode 100644 index 0000000000..5c692a2084 --- /dev/null +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeAttributes.h @@ -0,0 +1,104 @@ + + +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2011-2013 Ceetron AS +// +// This library may be used under the terms of either the GNU General Public License or +// the GNU Lesser General Public License as follows: +// +// GNU General Public License Usage +// This library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at <> +// for more details. +// +// GNU Lesser General Public License Usage +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU Lesser General Public License at <> +// for more details. +// +//################################################################################################## + +#pragma once + +#include "cafPdmUiFieldEditorHandle.h" +#include "cafSignal.h" + +namespace caf +{ +class PdmUiTreeViewItemAttribute : public PdmUiEditorAttribute +{ +public: + struct Tag : public SignalEmitter + { + enum Position + { + IN_FRONT, + AT_END + }; + Tag() + : text() + , position( AT_END ) + , bgColor( Qt::red ) + , fgColor( Qt::white ) + , selectedOnly( false ) + , clicked( this ) + { + } + QString text; + IconProvider icon; + Position position; + QColor bgColor; + QColor fgColor; + bool selectedOnly; + + caf::Signal clicked; + + static std::unique_ptr create() { return std::unique_ptr( new Tag ); } + + private: + Tag& operator=( const Tag& rhs ) { return *this; } + }; + + std::vector> tags; +}; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +class PdmUiTreeViewEditorAttribute : public PdmUiEditorAttribute +{ +public: + PdmUiTreeViewEditorAttribute() + : currentObject( nullptr ) + , objectForUpdateOfUiTree( nullptr ) + { + } + +public: + QStringList columnHeaders; + + /// This object is set as current item in the tree view in configureAndUpdateUi() + caf::PdmObjectHandle* currentObject; + + caf::PdmObjectHandle* objectForUpdateOfUiTree; +}; + +} // namespace caf diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeEditorHandle.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeEditorHandle.h index ebe0b98c5c..ff189e739a 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeEditorHandle.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeEditorHandle.h @@ -61,14 +61,14 @@ class PdmUiTreeEditorHandle : public PdmUiEditorHandle void setPdmItemRoot( PdmUiItem* root ); PdmUiItem* pdmItemRoot(); - void updateSubTree( PdmUiItem* root ) { this->updateMySubTree( root ); } + void updateSubTree( PdmUiItem* root, bool notifyEditors ) { this->updateMySubTree( root, notifyEditors ); } protected: virtual QWidget* createWidget( QWidget* parent ) = 0; /// Supposed to update the representation of the tree from root and downwards, as gracefully as possible. /// Will be called when the content of root might have been changed - virtual void updateMySubTree( PdmUiItem* root ) = 0; + virtual void updateMySubTree( PdmUiItem* root, bool notifyEditors ) = 0; protected: QPointer m_widget; diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeItemEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeItemEditor.cpp index 70061c2d37..b39f1ae5dd 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeItemEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeItemEditor.cpp @@ -55,7 +55,8 @@ void PdmUiTreeItemEditor::configureAndUpdateUi( const QString& uiConfigName ) { if ( m_treeViewEditor ) { - m_treeViewEditor->updateSubTree( this->pdmItem() ); + bool notifyEditors = true; + m_treeViewEditor->updateSubTree( this->pdmItem(), notifyEditors ); } } diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp index 2e82015604..94a0fce6ab 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp @@ -178,8 +178,7 @@ void PdmUiTreeSelectionEditor::configureAndUpdateUi( const QString& uiConfigName m_treeView->setModel( m_proxyModel ); } - bool optionsOnly = true; - QList options = uiField()->valueOptions( &optionsOnly ); + QList options = uiField()->valueOptions(); bool itemCountHasChaged = false; if ( m_model->optionItemCount() != options.size() ) itemCountHasChaged = true; diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeView.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeView.cpp index c8355f1a28..50c7f528fd 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeView.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeView.cpp @@ -38,10 +38,17 @@ #include "cafPdmObject.h" #include "cafPdmUiDefaultObjectEditor.h" - +#include "cafPdmUiDragDropInterface.h" +#include "cafPdmUiTreeOrdering.h" #include "cafPdmUiTreeViewEditor.h" +#include "cafQTreeViewStateSerializer.h" + #include +#include +#include +#include #include +#include namespace caf { @@ -51,16 +58,30 @@ namespace caf PdmUiTreeView::PdmUiTreeView( QWidget* parent, Qt::WindowFlags f ) : QWidget( parent, f ) { - m_layout = new QVBoxLayout( this ); + m_layout = new QVBoxLayout(); m_layout->setContentsMargins( 0, 0, 0, 0 ); setLayout( m_layout ); - m_treeViewEditor = new PdmUiTreeViewEditor(); + QHBoxLayout* searchLayout = new QHBoxLayout(); + + m_searchBox = new QLineEdit( this ); + m_searchBox->setPlaceholderText( "Type here to search in tree." ); + searchLayout->addWidget( m_searchBox ); + m_clearSearchButton = new QPushButton( "X" ); + m_clearSearchButton->setMaximumSize( 30, 30 ); + searchLayout->addWidget( m_clearSearchButton ); - QWidget* widget = m_treeViewEditor->getOrCreateWidget( this ); +#if QT_VERSION >= QT_VERSION_CHECK( 5, 10, 0 ) + m_layout->addLayout( searchLayout ); + connect( m_searchBox, SIGNAL( textChanged( QString ) ), SLOT( slotOnSearchTextChanged() ) ); + connect( m_clearSearchButton, SIGNAL( clicked() ), SLOT( slotOnClearSearchBox() ) ); +#endif - this->m_layout->insertWidget( 0, widget ); + m_treeViewEditor = new PdmUiTreeViewEditor(); + QWidget* treewidget = m_treeViewEditor->getOrCreateWidget( this ); + + m_layout->addWidget( treewidget ); connect( m_treeViewEditor, SIGNAL( selectionChanged() ), SLOT( slotOnSelectionChanged() ) ); } @@ -143,6 +164,53 @@ void PdmUiTreeView::slotOnSelectionChanged() emit selectedObjectChanged( objHandle ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void PdmUiTreeView::slotOnClearSearchBox() +{ + m_searchBox->setText( "" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void PdmUiTreeView::slotOnSearchTextChanged() +{ + QString searchText = m_searchBox->text().trimmed(); + if ( searchText.isEmpty() ) + { + m_treeViewEditor->setFilterString( searchText ); + if ( !m_treeStateString.isEmpty() ) + { + m_treeViewEditor->treeView()->collapseAll(); + QTreeViewStateSerializer::applyTreeViewStateFromString( m_treeViewEditor->treeView(), m_treeStateString ); + m_treeStateString = ""; + } + return; + } + else if ( m_treeStateString.isEmpty() ) + { + QTreeViewStateSerializer::storeTreeViewStateToString( m_treeViewEditor->treeView(), m_treeStateString ); + } + m_treeViewEditor->setFilterString( searchText ); + m_treeViewEditor->treeView()->expandAll(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void PdmUiTreeView::storeTreeViewStateToString( QString& treeViewState ) const +{ + QString searchText = m_searchBox->text().trimmed(); + if ( !searchText.isEmpty() ) + { + treeViewState = m_treeStateString; + return; + } + QTreeViewStateSerializer::storeTreeViewStateToString( m_treeViewEditor->treeView(), treeViewState ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -192,6 +260,14 @@ PdmUiItem* PdmUiTreeView::uiItemFromModelIndex( const QModelIndex& index ) const return m_treeViewEditor->uiItemFromModelIndex( index ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +PdmUiTreeOrdering* PdmUiTreeView::uiTreeOrderingFromModelIndex( const QModelIndex& index ) const +{ + return m_treeViewEditor->uiTreeOrderingFromModelIndex( index ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -208,7 +284,8 @@ void PdmUiTreeView::updateSubTree( const QModelIndex& index ) auto uiItem = uiItemFromModelIndex( index ); if ( uiItem ) { - m_treeViewEditor->updateSubTree( uiItem ); + bool notifyEditors = true; + m_treeViewEditor->updateSubTree( uiItem, notifyEditors ); } } @@ -228,4 +305,12 @@ void PdmUiTreeView::enableAppendOfClassNameToUiItemText( bool enable ) m_treeViewEditor->enableAppendOfClassNameToUiItemText( enable ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void PdmUiTreeView::treeVisibilityChanged( bool visible ) +{ + if ( visible ) slotOnSelectionChanged(); +} + } // End of namespace caf diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeView.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeView.h index ec60d2040d..f7c579bc2b 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeView.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeView.h @@ -38,18 +38,23 @@ #include #include +#include "cafPdmUiDragDropInterface.h" + class QVBoxLayout; class QTreeView; class QItemSelection; class QMenu; class QModelIndex; +class QLineEdit; +class QPushButton; +class QSortFilterProxyModel; namespace caf { class PdmUiItem; class PdmUiTreeViewEditor; -class PdmUiDragDropInterface; class PdmObjectHandle; +class PdmUiTreeOrdering; //================================================================================================== /// @@ -59,7 +64,7 @@ class PdmUiTreeView : public QWidget { Q_OBJECT public: - PdmUiTreeView( QWidget* parent = nullptr, Qt::WindowFlags f = nullptr ); + PdmUiTreeView( QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags() ); ~PdmUiTreeView() override; void enableDefaultContextMenu( bool enable ); @@ -83,20 +88,33 @@ class PdmUiTreeView : public QWidget PdmUiItem* uiItemFromModelIndex( const QModelIndex& index ) const; QModelIndex findModelIndex( const PdmUiItem* object ) const; void updateSubTree( const QModelIndex& index ); - void setDragDropInterface( PdmUiDragDropInterface* dragDropInterface ); + + PdmUiTreeOrdering* uiTreeOrderingFromModelIndex( const QModelIndex& index ) const; + + void setDragDropInterface( PdmUiDragDropInterface* dragDropInterface ); + + void storeTreeViewStateToString( QString& treeViewState ) const; signals: void selectionChanged(); // Convenience signal for use with PdmUiPropertyView void selectedObjectChanged( caf::PdmObjectHandle* object ); // Signal/Slot system needs caf:: prefix in some cases +public slots: + void treeVisibilityChanged( bool visible ); + private slots: void slotOnSelectionChanged(); + void slotOnClearSearchBox(); + void slotOnSearchTextChanged(); private: PdmUiTreeViewEditor* m_treeViewEditor; QString m_uiConfigName; QVBoxLayout* m_layout; + QLineEdit* m_searchBox; + QPushButton* m_clearSearchButton; + QString m_treeStateString; }; } // End of namespace caf diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.cpp index 74473d5976..5e9a75d42c 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.cpp @@ -45,6 +45,7 @@ #include "cafPdmUiDragDropInterface.h" #include "cafPdmUiEditorHandle.h" #include "cafPdmUiTreeOrdering.h" +#include "cafPdmUiTreeViewItemDelegate.h" #include "cafPdmUiTreeViewQModel.h" #include "cafSelectionManager.h" @@ -149,6 +150,7 @@ PdmUiTreeViewEditor::PdmUiTreeViewEditor() m_treeView = nullptr; m_treeViewModel = nullptr; m_delegate = nullptr; + m_filterModel = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -156,7 +158,26 @@ PdmUiTreeViewEditor::PdmUiTreeViewEditor() //-------------------------------------------------------------------------------------------------- PdmUiTreeViewEditor::~PdmUiTreeViewEditor() { + m_treeView->removeEventFilter( this ); m_treeViewModel->setPdmItemRoot( nullptr ); + + delete m_mainWidget; + m_mainWidget = nullptr; + + delete m_delegate; + m_delegate = nullptr; + + delete m_treeViewModel; + m_treeViewModel = nullptr; + + delete m_filterModel; + m_filterModel = nullptr; + + delete m_treeView; + m_treeView = nullptr; + + delete m_layout; + m_layout = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -170,11 +191,20 @@ QWidget* PdmUiTreeViewEditor::createWidget( QWidget* parent ) m_mainWidget->setLayout( m_layout ); m_treeViewModel = new caf::PdmUiTreeViewQModel( this ); - m_treeView = new PdmUiTreeViewWidget( m_mainWidget ); - m_treeView->setModel( m_treeViewModel ); + m_filterModel = new QSortFilterProxyModel( this ); + m_filterModel->setFilterKeyColumn( 0 ); + m_filterModel->setFilterCaseSensitivity( Qt::CaseInsensitive ); + +#if QT_VERSION >= QT_VERSION_CHECK( 5, 10, 0 ) + m_filterModel->setRecursiveFilteringEnabled( true ); +#endif + + m_filterModel->setSourceModel( m_treeViewModel ); + m_treeView = new PdmUiTreeViewWidget( m_mainWidget ); + m_treeView->setModel( m_filterModel ); m_treeView->installEventFilter( this ); - m_delegate = new PdmUiTreeViewItemDelegate( this, m_treeViewModel ); + m_delegate = new PdmUiTreeViewItemDelegate( this, m_filterModel ); m_treeView->setItemDelegate( m_delegate ); @@ -256,10 +286,16 @@ void PdmUiTreeViewEditor::selectedUiItems( std::vector& objects ) if ( !this->treeView() ) return; QModelIndexList idxList = this->treeView()->selectionModel()->selectedIndexes(); + QModelIndexList proxyList; for ( int i = 0; i < idxList.size(); i++ ) { - caf::PdmUiItem* item = this->m_treeViewModel->uiItemFromModelIndex( idxList[i] ); + proxyList.append( m_filterModel->mapToSource( idxList[i] ) ); + } + + for ( int i = 0; i < proxyList.size(); i++ ) + { + caf::PdmUiItem* item = this->m_treeViewModel->uiItemFromModelIndex( proxyList[i] ); if ( item ) { objects.push_back( item ); @@ -270,7 +306,7 @@ void PdmUiTreeViewEditor::selectedUiItems( std::vector& objects ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void PdmUiTreeViewEditor::updateMySubTree( PdmUiItem* uiItem ) +void PdmUiTreeViewEditor::updateMySubTree( PdmUiItem* uiItem, bool notifyEditors ) { if ( m_treeViewModel ) { @@ -288,9 +324,9 @@ void PdmUiTreeViewEditor::updateMySubTree( PdmUiItem* uiItem ) } } - m_treeViewModel->updateSubTree( itemToUpdate ); - QModelIndex index = m_treeViewModel->findModelIndex( itemToUpdate ); - updateItemDelegateForSubTree( index ); + m_treeViewModel->updateSubTree( itemToUpdate, notifyEditors ); + QModelIndex itemIndex = m_treeViewModel->findModelIndex( itemToUpdate ); + updateItemDelegateForSubTree( itemIndex ); } } @@ -393,11 +429,16 @@ PdmChildArrayFieldHandle* PdmUiTreeViewEditor::currentChildArrayFieldHandle() void PdmUiTreeViewEditor::selectAsCurrentItem( const PdmUiItem* uiItem ) { QModelIndex index = m_treeViewModel->findModelIndex( uiItem ); - QModelIndex currentIndex = m_treeView->currentIndex(); + QModelIndex indexForItem = m_filterModel->mapFromSource( index ); + + auto currentSelected = treeView()->currentIndex(); + + // Return if index is the same, as resetting the selection causes flickering + if ( indexForItem == currentSelected ) return; m_treeView->clearSelection(); - m_treeView->setCurrentIndex( index ); + m_treeView->setCurrentIndex( indexForItem ); } //-------------------------------------------------------------------------------------------------- @@ -438,21 +479,53 @@ void PdmUiTreeViewEditor::slotOnSelectionChanged( const QItemSelection& selected //-------------------------------------------------------------------------------------------------- void PdmUiTreeViewEditor::setExpanded( const PdmUiItem* uiItem, bool doExpand ) const { - QModelIndex index = m_treeViewModel->findModelIndex( uiItem ); - m_treeView->setExpanded( index, doExpand ); + QModelIndex index = m_treeViewModel->findModelIndex( uiItem ); + QModelIndex filterIndex = m_filterModel->mapFromSource( index ); - if ( doExpand ) + if ( filterIndex.isValid() ) { - m_treeView->scrollTo( index ); + m_treeView->setExpanded( filterIndex, doExpand ); + + if ( doExpand ) + { + m_treeView->scrollTo( filterIndex ); + } } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QModelIndex PdmUiTreeViewEditor::mapIndexIfNecessary( QModelIndex index ) const +{ + const QAbstractProxyModel* proxyModel = dynamic_cast( index.model() ); + + QModelIndex returnIndex = index; + if ( proxyModel ) + { + returnIndex = proxyModel->mapToSource( index ); + } + + return returnIndex; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- PdmUiItem* PdmUiTreeViewEditor::uiItemFromModelIndex( const QModelIndex& index ) const { - return m_treeViewModel->uiItemFromModelIndex( index ); + QModelIndex realIndex = mapIndexIfNecessary( index ); + return m_treeViewModel->uiItemFromModelIndex( realIndex ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +PdmUiTreeOrdering* PdmUiTreeViewEditor::uiTreeOrderingFromModelIndex( const QModelIndex& index ) const +{ + QModelIndex realIndex = mapIndexIfNecessary( index ); + if ( realIndex.isValid() ) return static_cast( realIndex.internalPointer() ); + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -460,7 +533,8 @@ PdmUiItem* PdmUiTreeViewEditor::uiItemFromModelIndex( const QModelIndex& index ) //-------------------------------------------------------------------------------------------------- QModelIndex PdmUiTreeViewEditor::findModelIndex( const PdmUiItem* object ) const { - return m_treeViewModel->findModelIndex( object ); + QModelIndex index = m_treeViewModel->findModelIndex( object ); + return m_filterModel->mapFromSource( index ); } //-------------------------------------------------------------------------------------------------- @@ -471,6 +545,14 @@ void PdmUiTreeViewEditor::setDragDropInterface( PdmUiDragDropInterface* dragDrop m_treeViewModel->setDragDropInterface( dragDropInterface ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void PdmUiTreeViewEditor::setFilterString( QString filterString ) +{ + m_filterModel->setFilterWildcard( filterString ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -479,6 +561,7 @@ bool PdmUiTreeViewEditor::eventFilter( QObject* obj, QEvent* event ) if ( event->type() == QEvent::FocusIn ) { this->updateSelectionManager(); + emit selectionChanged(); } // standard event processing @@ -501,12 +584,15 @@ void PdmUiTreeViewEditor::updateSelectionManager() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void PdmUiTreeViewEditor::updateItemDelegateForSubTree( const QModelIndex& modelIndex /*= QModelIndex()*/ ) +void PdmUiTreeViewEditor::updateItemDelegateForSubTree( const QModelIndex& subRootIndex /* = QModelIndex() */ ) { - auto allIndices = m_treeViewModel->allIndicesRecursive(); - for ( QModelIndex index : allIndices ) + auto allIndices = m_treeViewModel->allIndicesRecursive( subRootIndex ); + for ( QModelIndex& index : allIndices ) { - m_delegate->clearTags( index ); + QModelIndex filterIndex = m_filterModel->mapFromSource( index ); + if ( !filterIndex.isValid() ) continue; + + m_delegate->clearTags( filterIndex ); PdmUiItem* uiItem = m_treeViewModel->uiItemFromModelIndex( index ); PdmUiObjectHandle* uiObjectHandle = dynamic_cast( uiItem ); @@ -522,14 +608,14 @@ void PdmUiTreeViewEditor::updateItemDelegateForSubTree( const QModelIndex& model std::vector selection; selectedUiItems( selection ); - if ( reorderability && index.row() >= 0 && selection.size() == 1u && selection.front() == uiItem ) + if ( reorderability && filterIndex.row() >= 0 && selection.size() == 1u && selection.front() == uiItem ) { - size_t indexInParent = static_cast( index.row() ); + size_t indexInParentField = reorderability->indexOf( pdmObject ); { auto tag = PdmUiTreeViewItemAttribute::Tag::create(); tag->icon = caf::IconProvider( ":/caf/Up16x16.png" ); tag->selectedOnly = true; - if ( reorderability->canItemBeMovedUp( indexInParent ) ) + if ( reorderability->canItemBeMovedUp( indexInParentField ) ) { tag->clicked.connect( reorderability, &PdmFieldReorderCapability::onMoveItemUp ); } @@ -538,13 +624,13 @@ void PdmUiTreeViewEditor::updateItemDelegateForSubTree( const QModelIndex& model tag->icon.setActive( false ); } - m_delegate->addTag( index, std::move( tag ) ); + m_delegate->addTag( filterIndex, std::move( tag ) ); } { auto tag = PdmUiTreeViewItemAttribute::Tag::create(); tag->icon = IconProvider( ":/caf/Down16x16.png" ); tag->selectedOnly = true; - if ( reorderability->canItemBeMovedDown( indexInParent ) ) + if ( reorderability->canItemBeMovedDown( indexInParentField ) ) { tag->clicked.connect( reorderability, &PdmFieldReorderCapability::onMoveItemDown ); } @@ -552,7 +638,7 @@ void PdmUiTreeViewEditor::updateItemDelegateForSubTree( const QModelIndex& model { tag->icon.setActive( false ); } - m_delegate->addTag( index, std::move( tag ) ); + m_delegate->addTag( filterIndex, std::move( tag ) ); } } } @@ -563,7 +649,7 @@ void PdmUiTreeViewEditor::updateItemDelegateForSubTree( const QModelIndex& model { if ( !tag->text.isEmpty() || tag->icon.valid() ) { - m_delegate->addTag( index, std::move( tag ) ); + m_delegate->addTag( filterIndex, std::move( tag ) ); } } } @@ -586,260 +672,4 @@ bool PdmUiTreeViewEditor::isAppendOfClassNameToUiItemTextEnabled() return m_appendClassNameToUiItemText; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -PdmUiTreeViewItemDelegate::PdmUiTreeViewItemDelegate( PdmUiTreeViewEditor* parent, PdmUiTreeViewQModel* model ) - : QStyledItemDelegate( parent->treeView() ) - , m_treeView( parent ) - , m_model( model ) -{ -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void PdmUiTreeViewItemDelegate::clearTags( QModelIndex index ) -{ - m_tags.erase( index ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void PdmUiTreeViewItemDelegate::clearAllTags() -{ - m_tags.clear(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void PdmUiTreeViewItemDelegate::addTag( QModelIndex index, std::unique_ptr tag ) -{ - std::vector>& tagList = m_tags[index]; - tagList.push_back( std::move( tag ) ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QRect PdmUiTreeViewItemDelegate::tagRect( const QRect& itemRect, QModelIndex index, size_t tagIndex ) const -{ - auto it = m_tags.find( index ); - if ( it == m_tags.end() ) return QRect(); - - QSize fullSize = itemRect.size(); - - QPoint offset( 0, 0 ); - - for ( size_t i = 0; i < it->second.size(); ++i ) - { - const PdmUiTreeViewItemAttribute::Tag* tag = it->second[i].get(); - if ( tag->icon.valid() ) - { - auto icon = tag->icon.icon(); - QSize iconSize = icon->actualSize( fullSize ); - QRect iconRect; - if ( tag->position == PdmUiTreeViewItemAttribute::Tag::AT_END ) - { - QPoint bottomRight = itemRect.bottomRight() - offset; - QPoint topLeft = bottomRight - QPoint( iconSize.width(), iconSize.height() ); - iconRect = QRect( topLeft, bottomRight ); - } - else - { - QPoint topLeft = itemRect.topLeft() + offset; - QPoint bottomRight = topLeft + QPoint( iconSize.width(), iconSize.height() ); - iconRect = QRect( topLeft, bottomRight ); - } - offset += QPoint( iconSize.width() + 2, 0 ); - - if ( i == tagIndex ) return iconRect; - } - } - return QRect(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void PdmUiTreeViewItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const -{ - QStyledItemDelegate::paint( painter, option, index ); - - auto it = m_tags.find( index ); - if ( it == m_tags.end() ) return; - - // Save painter so we can restore it - painter->save(); - - QRect rect = option.rect; - QPoint center = rect.center(); - - QSize fullSize = rect.size(); - - QPoint offset( 0, 0 ); - - for ( const std::unique_ptr& tag : it->second ) - { - if ( tag->selectedOnly && !( option.state & QStyle::State_Selected ) ) continue; - - if ( tag->icon.valid() ) - { - auto icon = tag->icon.icon(); - QSize iconSize = icon->actualSize( fullSize ); - QRect iconRect; - if ( tag->position == PdmUiTreeViewItemAttribute::Tag::AT_END ) - { - QPoint bottomRight( rect.bottomRight().x() - offset.x(), center.y() + iconSize.height() / 2 ); - QPoint topLeft( bottomRight.x() - iconSize.width(), bottomRight.y() - iconSize.height() ); - iconRect = QRect( topLeft, bottomRight ); - } - else - { - QPoint topLeft( rect.topLeft().x() + offset.x(), center.y() - iconSize.height() / 2 ); - QPoint bottomRight( topLeft.x() + iconSize.width(), topLeft.y() + iconSize.height() ); - iconRect = QRect( topLeft, bottomRight ); - } - offset += QPoint( iconSize.width() + 2, 0 ); - icon->paint( painter, iconRect ); - } - else - { - const int insideTopBottomMargins = 1; - const int insideleftRightMargins = 6; - const int outsideLeftRightMargins = 4; - - QFont font = QApplication::font(); - if ( font.pixelSize() > 0 ) - { - font.setPixelSize( std::max( 1, font.pixelSize() - 1 ) ); - } - else - { - font.setPointSize( std::max( 1, font.pointSize() - 1 ) ); - } - painter->setFont( font ); - - QString text = tag->text; - QColor bgColor = tag->bgColor; - QColor fgColor = tag->fgColor; - - QSize textSize( QFontMetrics( font ).size( Qt::TextSingleLine, text ) ); - int textDiff = ( fullSize.height() - textSize.height() ); - - QRect textRect; - if ( tag->position == PdmUiTreeViewItemAttribute::Tag::AT_END ) - { - QPoint bottomRight = rect.bottomRight() - QPoint( outsideLeftRightMargins, 0 ) - offset; - QPoint textBottomRight = bottomRight - QPoint( insideleftRightMargins, textDiff / 2 ); - QPoint textTopLeft = textBottomRight - QPoint( textSize.width(), textSize.height() ); - textRect = QRect( textTopLeft, textBottomRight ); - } - else - { - QPoint textTopLeft = QPoint( 0, rect.topLeft().y() ) + offset + - QPoint( outsideLeftRightMargins + insideleftRightMargins, +textDiff / 2 ); - QPoint textBottomRight = textTopLeft + QPoint( textSize.width(), textSize.height() ); - textRect = QRect( textTopLeft, textBottomRight ); - } - - QRect tagRect = textRect.marginsAdded( - QMargins( insideleftRightMargins, insideTopBottomMargins, insideleftRightMargins, insideTopBottomMargins ) ); - - offset += QPoint( tagRect.width() + 2, 0 ); - - QBrush brush( bgColor ); - - painter->setBrush( brush ); - painter->setPen( bgColor ); - painter->setRenderHint( QPainter::Antialiasing ); - const double xRoundingRadiusPercent = 50.0; - const double yRoundingRadiusPercent = 25.0; - painter->drawRoundedRect( tagRect, xRoundingRadiusPercent, yRoundingRadiusPercent, Qt::RelativeSize ); - - painter->setPen( fgColor ); - painter->drawText( textRect, Qt::AlignCenter, text ); - } - } - // Restore painter - painter->restore(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector PdmUiTreeViewItemDelegate::tags( QModelIndex index ) const -{ - std::vector tagPtrVector; - - auto it = m_tags.find( index ); - if ( it != m_tags.end() ) - { - for ( const auto& tag : it->second ) - { - tagPtrVector.push_back( tag.get() ); - } - } - return tagPtrVector; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool PdmUiTreeViewItemDelegate::editorEvent( QEvent* event, - QAbstractItemModel* model, - const QStyleOptionViewItem& option, - const QModelIndex& itemIndex ) -{ - if ( event->type() == QEvent::MouseButtonPress ) - { - QMouseEvent* mouseEvent = static_cast( event ); - - if ( mouseEvent->button() == Qt::LeftButton && mouseEvent->modifiers() == Qt::NoModifier ) - { - const PdmUiTreeViewItemAttribute::Tag* tag; - if ( tagClicked( mouseEvent->pos(), option.rect, itemIndex, &tag ) ) - { - QModelIndex parentIndex = itemIndex.parent(); - - auto uiItem = m_treeView->uiItemFromModelIndex( itemIndex ); - auto parentUiItem = m_treeView->uiItemFromModelIndex( parentIndex ); - - tag->clicked.send( (size_t)itemIndex.row() ); - - m_treeView->updateSubTree( parentUiItem ); - m_treeView->selectAsCurrentItem( uiItem ); - } - } - } - - return QStyledItemDelegate::editorEvent( event, model, option, itemIndex ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool PdmUiTreeViewItemDelegate::tagClicked( const QPoint& pos, - const QRect& itemRect, - const QModelIndex& itemIndex, - const PdmUiTreeViewItemAttribute::Tag** tag ) const -{ - if ( itemIndex.isValid() ) - { - auto itemTags = tags( itemIndex ); - - for ( size_t i = 0; i < itemTags.size(); ++i ) - { - QRect rect = tagRect( itemRect, itemIndex, i ); - if ( rect.contains( pos ) ) - { - *tag = itemTags[i]; - return true; - } - } - } - return false; -} } // end namespace caf diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.h index 6391c04ef7..bae96c76fa 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.h @@ -47,14 +47,13 @@ #include #include #include +#include #include #include #include #include -class MySortFilterProxyModel; - class QGridLayout; class QMenu; class QTreeView; @@ -68,6 +67,7 @@ class PdmUiItem; class PdmUiTreeViewEditor; class PdmUiTreeViewQModel; class PdmUiTreeViewWidget; +class PdmUiTreeViewItemDelegate; class PdmUiTreeViewStyle : public QProxyStyle { @@ -98,92 +98,6 @@ class PdmUiTreeViewWidget : public QTreeView void dragLeaveEvent( QDragLeaveEvent* event ) override; }; -class PdmUiTreeViewItemAttribute : public PdmUiEditorAttribute -{ -public: - struct Tag : public SignalEmitter - { - enum Position - { - IN_FRONT, - AT_END - }; - Tag() - : text() - , position( AT_END ) - , bgColor( Qt::red ) - , fgColor( Qt::white ) - , selectedOnly( false ) - , clicked( this ) - { - } - QString text; - IconProvider icon; - Position position; - QColor bgColor; - QColor fgColor; - bool selectedOnly; - - caf::Signal clicked; - - static std::unique_ptr create() { return std::unique_ptr( new Tag ); } - - private: - Tag( const Tag& rhs ) = default; - Tag& operator =( const Tag& rhs ) { return *this; } - }; - - std::vector> tags; -}; - -class PdmUiTreeViewItemDelegate : public QStyledItemDelegate -{ -public: - PdmUiTreeViewItemDelegate( PdmUiTreeViewEditor* parent, PdmUiTreeViewQModel* model ); - void clearTags( QModelIndex index ); - void clearAllTags(); - void addTag( QModelIndex index, std::unique_ptr tag ); - void paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const override; - std::vector tags( QModelIndex index ) const; - -protected: - bool editorEvent( QEvent* event, - QAbstractItemModel* model, - const QStyleOptionViewItem& option, - const QModelIndex& itemIndex ) override; - bool tagClicked( const QPoint& clickPos, - const QRect& itemRect, - const QModelIndex& itemIndex, - const PdmUiTreeViewItemAttribute::Tag** tag ) const; - QRect tagRect( const QRect& itemRect, QModelIndex itemIndex, size_t tagIndex ) const; - -private: - PdmUiTreeViewEditor* m_treeView; - PdmUiTreeViewQModel* m_model; - std::map>> m_tags; -}; - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -class PdmUiTreeViewEditorAttribute : public PdmUiEditorAttribute -{ -public: - PdmUiTreeViewEditorAttribute() - : currentObject( nullptr ) - , objectForUpdateOfUiTree( nullptr ) - { - } - -public: - QStringList columnHeaders; - - /// This object is set as current item in the tree view in configureAndUpdateUi() - caf::PdmObjectHandle* currentObject; - - caf::PdmObjectHandle* objectForUpdateOfUiTree; -}; - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -209,20 +123,23 @@ class PdmUiTreeViewEditor : public PdmUiTreeEditorHandle void selectedUiItems( std::vector& objects ); void setExpanded( const PdmUiItem* uiItem, bool doExpand ) const; - PdmUiItem* uiItemFromModelIndex( const QModelIndex& index ) const; - QModelIndex findModelIndex( const PdmUiItem* object ) const; + PdmUiItem* uiItemFromModelIndex( const QModelIndex& index ) const; + PdmUiTreeOrdering* uiTreeOrderingFromModelIndex( const QModelIndex& index ) const; + QModelIndex findModelIndex( const PdmUiItem* object ) const; QWidget* createWidget( QWidget* parent ) override; void setDragDropInterface( PdmUiDragDropInterface* dragDropInterface ); + void setFilterString( QString filterStr ); + signals: void selectionChanged(); protected: void configureAndUpdateUi( const QString& uiConfigName ) override; - void updateMySubTree( PdmUiItem* uiItem ) override; + void updateMySubTree( PdmUiItem* uiItem, bool notifyEditors ) override; void updateContextMenuSignals(); private slots: @@ -232,18 +149,21 @@ private slots: private: PdmChildArrayFieldHandle* currentChildArrayFieldHandle(); + QModelIndex mapIndexIfNecessary( QModelIndex index ) const; + void updateSelectionManager(); - void updateItemDelegateForSubTree( const QModelIndex& modelIndex = QModelIndex() ); + void updateItemDelegateForSubTree( const QModelIndex& subRootIndex = QModelIndex() ); bool eventFilter( QObject* obj, QEvent* event ) override; private: - QPointer m_mainWidget; - QVBoxLayout* m_layout; + QPointer m_mainWidget; + QPointer m_layout; - PdmUiTreeViewWidget* m_treeView; - PdmUiTreeViewQModel* m_treeViewModel; - PdmUiTreeViewItemDelegate* m_delegate; + QPointer m_treeView; + QPointer m_treeViewModel; + QPointer m_delegate; + QPointer m_filterModel; bool m_useDefaultContextMenu; bool m_updateSelectionManager; diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewItemDelegate.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewItemDelegate.cpp new file mode 100644 index 0000000000..65b436a2d5 --- /dev/null +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewItemDelegate.cpp @@ -0,0 +1,332 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2011-2013 Ceetron AS +// +// This library may be used under the terms of either the GNU General Public License or +// the GNU Lesser General Public License as follows: +// +// GNU General Public License Usage +// This library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at <> +// for more details. +// +// GNU Lesser General Public License Usage +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU Lesser General Public License at <> +// for more details. +// +//################################################################################################## + +#include "cafPdmUiTreeViewItemDelegate.h" + +#include "cafPdmChildArrayField.h" +#include "cafPdmField.h" +#include "cafPdmFieldReorderCapability.h" +#include "cafPdmObject.h" +#include "cafPdmPtrArrayFieldHandle.h" +#include "cafPdmUiCommandSystemProxy.h" +#include "cafPdmUiDragDropInterface.h" +#include "cafPdmUiEditorHandle.h" +#include "cafPdmUiTreeOrdering.h" +#include "cafPdmUiTreeViewEditor.h" +#include "cafPdmUiTreeViewQModel.h" +#include "cafSelectionManager.h" + +#include +#include +#include +#include +#include +#include +#include + +namespace caf +{ +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +PdmUiTreeViewItemDelegate::PdmUiTreeViewItemDelegate( PdmUiTreeViewEditor* parent, QAbstractItemModel* model ) + : QStyledItemDelegate( parent->treeView() ) + , m_treeView( parent ) + , m_model( model ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void PdmUiTreeViewItemDelegate::clearTags( QModelIndex index ) +{ + m_tags.erase( index ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void PdmUiTreeViewItemDelegate::clearAllTags() +{ + m_tags.clear(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void PdmUiTreeViewItemDelegate::addTag( QModelIndex index, std::unique_ptr tag ) +{ + std::vector>& tagList = m_tags[index]; + tagList.push_back( std::move( tag ) ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QRect PdmUiTreeViewItemDelegate::tagRect( const QRect& itemRect, QModelIndex index, size_t tagIndex ) const +{ + auto it = m_tags.find( index ); + if ( it == m_tags.end() ) return QRect(); + + QSize fullSize = itemRect.size(); + + QPoint offset( 0, 0 ); + + for ( size_t i = 0; i < it->second.size(); ++i ) + { + const PdmUiTreeViewItemAttribute::Tag* tag = it->second[i].get(); + if ( tag->icon.valid() ) + { + auto icon = tag->icon.icon(); + QSize iconSize = icon->actualSize( fullSize ); + QRect iconRect; + if ( tag->position == PdmUiTreeViewItemAttribute::Tag::AT_END ) + { + QPoint bottomRight = itemRect.bottomRight() - offset; + QPoint topLeft = bottomRight - QPoint( iconSize.width(), iconSize.height() ); + iconRect = QRect( topLeft, bottomRight ); + } + else + { + QPoint topLeft = itemRect.topLeft() + offset; + QPoint bottomRight = topLeft + QPoint( iconSize.width(), iconSize.height() ); + iconRect = QRect( topLeft, bottomRight ); + } + offset += QPoint( iconSize.width() + 2, 0 ); + + if ( i == tagIndex ) return iconRect; + } + } + return QRect(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void PdmUiTreeViewItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const +{ + QStyledItemDelegate::paint( painter, option, index ); + + auto it = m_tags.find( index ); + if ( it == m_tags.end() ) return; + + // Save painter so we can restore it + painter->save(); + + QRect rect = option.rect; + QPoint center = rect.center(); + + QSize fullSize = rect.size(); + + QPoint offset( 0, 0 ); + + for ( const std::unique_ptr& tag : it->second ) + { + if ( tag->selectedOnly && !( option.state & QStyle::State_Selected ) ) continue; + + if ( tag->icon.valid() ) + { + auto icon = tag->icon.icon(); + QSize iconSize = icon->actualSize( fullSize ); + QRect iconRect; + if ( tag->position == PdmUiTreeViewItemAttribute::Tag::AT_END ) + { + QPoint bottomRight( rect.bottomRight().x() - offset.x(), center.y() + iconSize.height() / 2 ); + QPoint topLeft( bottomRight.x() - iconSize.width(), bottomRight.y() - iconSize.height() ); + iconRect = QRect( topLeft, bottomRight ); + } + else + { + QPoint topLeft( rect.topLeft().x() + offset.x(), center.y() - iconSize.height() / 2 ); + QPoint bottomRight( topLeft.x() + iconSize.width(), topLeft.y() + iconSize.height() ); + iconRect = QRect( topLeft, bottomRight ); + } + offset += QPoint( iconSize.width() + 2, 0 ); + icon->paint( painter, iconRect ); + } + else + { + const int insideTopBottomMargins = 1; + const int insideleftRightMargins = 6; + const int outsideLeftRightMargins = 4; + + QFont font = QApplication::font(); + if ( font.pixelSize() > 0 ) + { + font.setPixelSize( std::max( 1, font.pixelSize() - 1 ) ); + } + else + { + font.setPointSize( std::max( 1, font.pointSize() - 1 ) ); + } + painter->setFont( font ); + + QString text = tag->text; + QColor bgColor = tag->bgColor; + QColor fgColor = tag->fgColor; + + QSize textSize( QFontMetrics( font ).size( Qt::TextSingleLine, text ) ); + int textDiff = ( fullSize.height() - textSize.height() ); + + QRect textRect; + if ( tag->position == PdmUiTreeViewItemAttribute::Tag::AT_END ) + { + QPoint bottomRight = rect.bottomRight() - QPoint( outsideLeftRightMargins, 0 ) - offset; + QPoint textBottomRight = bottomRight - QPoint( insideleftRightMargins, textDiff / 2 ); + QPoint textTopLeft = textBottomRight - QPoint( textSize.width(), textSize.height() ); + textRect = QRect( textTopLeft, textBottomRight ); + } + else + { + QPoint textTopLeft = QPoint( 0, rect.topLeft().y() ) + offset + + QPoint( outsideLeftRightMargins + insideleftRightMargins, +textDiff / 2 ); + QPoint textBottomRight = textTopLeft + QPoint( textSize.width(), textSize.height() ); + textRect = QRect( textTopLeft, textBottomRight ); + } + + QRect tagRect = textRect.marginsAdded( + QMargins( insideleftRightMargins, insideTopBottomMargins, insideleftRightMargins, insideTopBottomMargins ) ); + + offset += QPoint( tagRect.width() + 2, 0 ); + + QBrush brush( bgColor ); + + painter->setBrush( brush ); + painter->setPen( bgColor ); + painter->setRenderHint( QPainter::Antialiasing ); + const double xRoundingRadiusPercent = 50.0; + const double yRoundingRadiusPercent = 25.0; + painter->drawRoundedRect( tagRect, xRoundingRadiusPercent, yRoundingRadiusPercent, Qt::RelativeSize ); + + painter->setPen( fgColor ); + painter->drawText( textRect, Qt::AlignCenter, text ); + } + } + // Restore painter + painter->restore(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector PdmUiTreeViewItemDelegate::tags( QModelIndex index ) const +{ + std::vector tagPtrVector; + + auto it = m_tags.find( index ); + if ( it != m_tags.end() ) + { + for ( const auto& tag : it->second ) + { + tagPtrVector.push_back( tag.get() ); + } + } + return tagPtrVector; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool PdmUiTreeViewItemDelegate::editorEvent( QEvent* event, + QAbstractItemModel* model, + const QStyleOptionViewItem& option, + const QModelIndex& itemIndex ) +{ + if ( event->type() == QEvent::MouseButtonPress ) + { + auto* mouseEvent = static_cast( event ); + if ( mouseEvent->button() == Qt::LeftButton && mouseEvent->modifiers() == Qt::NoModifier ) + { + const PdmUiTreeViewItemAttribute::Tag* tag; + if ( tagClicked( mouseEvent->pos(), option.rect, itemIndex, &tag ) ) + { + auto uiItem = m_treeView->uiItemFromModelIndex( itemIndex ); + auto parentIndex = itemIndex.parent(); + auto parentUiItem = m_treeView->uiItemFromModelIndex( parentIndex ); + + auto* uiObjectHandle = dynamic_cast( uiItem ); + if ( uiObjectHandle ) + { + PdmObjectHandle* pdmObject = uiObjectHandle->objectHandle(); + if ( pdmObject ) + { + PdmFieldReorderCapability* reorderability = + PdmFieldReorderCapability::reorderCapabilityOfParentContainer( pdmObject ); + + size_t indexInParent = reorderability->indexOf( pdmObject ); + tag->clicked.send( indexInParent ); + } + } + + bool notifyEditors = true; + m_treeView->updateSubTree( parentUiItem, notifyEditors ); + m_treeView->selectAsCurrentItem( uiItem ); + + return true; + } + } + } + + return QStyledItemDelegate::editorEvent( event, model, option, itemIndex ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool PdmUiTreeViewItemDelegate::tagClicked( const QPoint& pos, + const QRect& itemRect, + const QModelIndex& itemIndex, + const PdmUiTreeViewItemAttribute::Tag** tag ) const +{ + if ( itemIndex.isValid() ) + { + auto itemTags = tags( itemIndex ); + + for ( size_t i = 0; i < itemTags.size(); ++i ) + { + QRect rect = tagRect( itemRect, itemIndex, i ); + if ( rect.contains( pos ) ) + { + *tag = itemTags[i]; + return true; + } + } + } + return false; +} + +} // namespace caf diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewItemDelegate.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewItemDelegate.h new file mode 100644 index 0000000000..b63d5e2fae --- /dev/null +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewItemDelegate.h @@ -0,0 +1,84 @@ + +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2011-2013 Ceetron AS +// +// This library may be used under the terms of either the GNU General Public License or +// the GNU Lesser General Public License as follows: +// +// GNU General Public License Usage +// This library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at <> +// for more details. +// +// GNU Lesser General Public License Usage +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU Lesser General Public License at <> +// for more details. +// +//################################################################################################## + +#pragma once + +#include "cafPdmUiFieldEditorHandle.h" +#include "cafPdmUiTreeAttributes.h" +#include "cafPdmUiTreeEditorHandle.h" + +#include +#include +#include +#include +#include +#include + +#include + +namespace caf +{ +class PdmUiTreeViewEditor; + +class PdmUiTreeViewItemDelegate : public QStyledItemDelegate +{ +public: + PdmUiTreeViewItemDelegate( PdmUiTreeViewEditor* parent, QAbstractItemModel* model ); + void clearTags( QModelIndex index ); + void clearAllTags(); + void addTag( QModelIndex index, std::unique_ptr tag ); + void paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const override; + std::vector tags( QModelIndex index ) const; + +protected: + bool editorEvent( QEvent* event, + QAbstractItemModel* model, + const QStyleOptionViewItem& option, + const QModelIndex& itemIndex ) override; + bool tagClicked( const QPoint& clickPos, + const QRect& itemRect, + const QModelIndex& itemIndex, + const PdmUiTreeViewItemAttribute::Tag** tag ) const; + QRect tagRect( const QRect& itemRect, QModelIndex itemIndex, size_t tagIndex ) const; + +private: + PdmUiTreeViewEditor* m_treeView; + QAbstractItemModel* m_model; + + std::map>> m_tags; +}; +} // namespace caf diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewQModel.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewQModel.cpp index 40a6a1ec36..0213272a5c 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewQModel.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewQModel.cpp @@ -45,6 +45,7 @@ #include "cafPdmUiTreeViewEditor.h" #include +#include #include namespace caf @@ -60,6 +61,18 @@ PdmUiTreeViewQModel::PdmUiTreeViewQModel( PdmUiTreeViewEditor* treeViewEditor ) m_treeViewEditor = treeViewEditor; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +PdmUiTreeViewQModel::~PdmUiTreeViewQModel() +{ + if ( m_dragDropInterface ) + { + delete m_dragDropInterface; + m_dragDropInterface = nullptr; + } +} + //-------------------------------------------------------------------------------------------------- /// Will populate the tree with the contents of the Pdm data structure rooted at rootItem. /// Will not show the rootItem itself, only the children and downwards @@ -69,7 +82,8 @@ void PdmUiTreeViewQModel::setPdmItemRoot( PdmUiItem* rootItem ) // Check if we are already watching this root if ( rootItem && m_treeOrderingRoot && m_treeOrderingRoot->activeItem() == rootItem ) { - this->updateSubTree( rootItem ); + bool notifyEditors = false; + this->updateSubTree( rootItem, notifyEditors ); return; } @@ -135,7 +149,7 @@ void PdmUiTreeViewQModel::emitDataChanged( const QModelIndex& index ) //-------------------------------------------------------------------------------------------------- /// Refreshes the UI-tree below the supplied root PdmUiItem //-------------------------------------------------------------------------------------------------- -void PdmUiTreeViewQModel::updateSubTree( PdmUiItem* pdmRoot ) +void PdmUiTreeViewQModel::updateSubTree( PdmUiItem* pdmRoot, bool notifyEditors ) { // Build the new "Correct" Tree @@ -180,7 +194,7 @@ void PdmUiTreeViewQModel::updateSubTree( PdmUiItem* pdmRoot ) existingSubTreeRoot->debugDump( 0 ); #endif - updateSubTreeRecursive( existingSubTreeRootModIdx, existingSubTreeRoot, newTreeRootTmp ); + updateSubTreeRecursive( existingSubTreeRootModIdx, existingSubTreeRoot, newTreeRootTmp, notifyEditors ); delete newTreeRootTmp; @@ -212,7 +226,8 @@ class RecursiveUpdateData //-------------------------------------------------------------------------------------------------- void PdmUiTreeViewQModel::updateSubTreeRecursive( const QModelIndex& existingSubTreeRootModIdx, PdmUiTreeOrdering* existingSubTreeRoot, - PdmUiTreeOrdering* sourceSubTreeRoot ) + PdmUiTreeOrdering* sourceSubTreeRoot, + bool notifyEditors ) { // Build map for source items std::map sourceTreeMap; @@ -283,14 +298,15 @@ void PdmUiTreeViewQModel::updateSubTreeRecursive( const QModelIndex& existingSub if ( !anyChanges ) { // Notify Qt that the toggle/name/icon etc might have been changed - emitDataChanged( existingSubTreeRootModIdx ); + if ( notifyEditors ) emitDataChanged( existingSubTreeRootModIdx ); // No changes to list of children at this level, call update on all children for ( int i = 0; i < existingSubTreeRoot->childCount(); ++i ) { updateSubTreeRecursive( index( i, 0, existingSubTreeRootModIdx ), existingSubTreeRoot->child( i ), - sourceSubTreeRoot->child( i ) ); + sourceSubTreeRoot->child( i ), + notifyEditors ); } } else @@ -298,7 +314,7 @@ void PdmUiTreeViewQModel::updateSubTreeRecursive( const QModelIndex& existingSub std::vector recursiveUpdateData; std::vector newMergedOrdering; - emit layoutAboutToBeChanged(); + if ( notifyEditors ) emit layoutAboutToBeChanged(); { // Detect items to be moved from source to existing // Merge items from existing and source into newMergedOrdering using order in sourceSubTreeRoot @@ -328,7 +344,7 @@ void PdmUiTreeViewQModel::updateSubTreeRecursive( const QModelIndex& existingSub it != indicesToRemoveFromSource.rend(); ++it ) { - // Use the removeChildrenNoDelete() to remove the pointer from the list without deleting the pointer + // Use the removeChildNoDelete() to remove the pointer from the list without deleting the pointer sourceSubTreeRoot->removeChildrenNoDelete( *it, 1 ); } @@ -347,7 +363,7 @@ void PdmUiTreeViewQModel::updateSubTreeRecursive( const QModelIndex& existingSub } } - emit layoutChanged(); + if ( notifyEditors ) emit layoutChanged(); // Insert new items into existingSubTreeRoot for ( size_t i = 0; i < newMergedOrdering.size(); i++ ) @@ -367,7 +383,10 @@ void PdmUiTreeViewQModel::updateSubTreeRecursive( const QModelIndex& existingSub QModelIndex mi = index( recursiveUpdateData[i].m_row, 0, existingSubTreeRootModIdx ); CAF_ASSERT( mi.isValid() ); - updateSubTreeRecursive( mi, recursiveUpdateData[i].m_existingChild, recursiveUpdateData[i].m_sourceChild ); + updateSubTreeRecursive( mi, + recursiveUpdateData[i].m_existingChild, + recursiveUpdateData[i].m_sourceChild, + notifyEditors ); } } } @@ -852,7 +871,35 @@ QMimeData* PdmUiTreeViewQModel::mimeData( const QModelIndexList& indexes ) const { if ( m_dragDropInterface ) { - return m_dragDropInterface->mimeData( indexes ); + QStringList objectPaths; + + for ( const auto& i : indexes ) + { + auto uiObjHandle = dynamic_cast( uiItemFromModelIndex( i ) ); + if ( uiObjHandle && uiObjHandle->objectHandle() ) + { + auto objHandle = uiObjHandle->objectHandle(); + + auto root = PdmReferenceHelper::findRoot( objHandle ); + auto path = PdmReferenceHelper::referenceFromRootToObject( root, objHandle ); + + objectPaths.push_back( path ); + } + } + + auto mimeDataObject = m_dragDropInterface->mimeData( indexes ); + + QByteArray data; + QDataStream dataStreamWrite( &data, QIODevice::WriteOnly ); + dataStreamWrite << objectPaths; + + QString mimeType = PdmUiDragDropInterface::mimeTypeForObjectReferenceList(); + + // The QModelIndexList is useful for drag and drop internally in one tree widget. If we + // drag from a tree into other widgets, it is useful to have the full path as text from root to object. + mimeDataObject->setData( mimeType, data ); + + return mimeDataObject; } else { diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewQModel.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewQModel.h index 408f13462c..4f95514d23 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewQModel.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewQModel.h @@ -60,9 +60,10 @@ class PdmUiTreeViewQModel : public QAbstractItemModel public: explicit PdmUiTreeViewQModel( PdmUiTreeViewEditor* treeViewEditor ); + virtual ~PdmUiTreeViewQModel(); void setPdmItemRoot( PdmUiItem* rootItem ); - void updateSubTree( PdmUiItem* subTreeRoot ); + void updateSubTree( PdmUiItem* subTreeRoot, bool notifyEditors ); void setColumnHeaders( const QStringList& columnHeaders ); void setUiConfigName( const QString& uiConfigName ) { m_uiConfigName = uiConfigName; } @@ -80,7 +81,8 @@ class PdmUiTreeViewQModel : public QAbstractItemModel private: void updateSubTreeRecursive( const QModelIndex& uiSubTreeRootModelIdx, PdmUiTreeOrdering* uiModelSubTreeRoot, - PdmUiTreeOrdering* updatedPdmSubTreeRoot ); + PdmUiTreeOrdering* updatedPdmSubTreeRoot, + bool notifyEditors ); PdmUiTreeOrdering* treeItemFromIndex( const QModelIndex& index ) const; QModelIndex findModelIndexRecursive( const QModelIndex& currentIndex, const PdmUiItem* object ) const; diff --git a/Fwk/AppFwk/cafUserInterface/cafUserInterface_UnitTests/CMakeLists.txt b/Fwk/AppFwk/cafUserInterface/cafUserInterface_UnitTests/CMakeLists.txt index e29067d251..d66d8b99aa 100644 --- a/Fwk/AppFwk/cafUserInterface/cafUserInterface_UnitTests/CMakeLists.txt +++ b/Fwk/AppFwk/cafUserInterface/cafUserInterface_UnitTests/CMakeLists.txt @@ -2,24 +2,12 @@ cmake_minimum_required(VERSION 2.8.12) project(cafUserInterface_UnitTests) -# Qt -option(CEE_USE_QT5 "Use Qt5" OFF) - -if(CEE_USE_QT5) - find_package( - Qt5 - COMPONENTS - REQUIRED Core Gui Widgets - ) - set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::Widgets) -else() - find_package( - Qt4 - COMPONENTS QtCore QtGui QtMain - REQUIRED - ) - include(${QT_USE_FILE}) -endif(CEE_USE_QT5) +find_package( + Qt5 + COMPONENTS + REQUIRED Core Gui Widgets +) +set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::Widgets Qt5::OpenGL) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) @@ -37,33 +25,11 @@ target_link_libraries( ) # Copy Qt Dlls -if(Qt5Core_FOUND) - foreach(qtlib ${QT_LIBRARIES}) - add_custom_command( - TARGET ${PROJECT_NAME} - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different $ - $ - ) - endforeach(qtlib) - # Copy Qt Dlls -else() - # Copy Qt Dlls - if(MSVC) - set(QTLIBLIST QtCore QtGui QtOpenGl) - foreach(qtlib ${QTLIBLIST}) - - # Debug - execute_process( - COMMAND cmake -E copy_if_different ${QT_BINARY_DIR}/${qtlib}d4.dll - ${CMAKE_BINARY_DIR}/Debug/${qtlib}d4.dll - ) - - # Release - execute_process( - COMMAND cmake -E copy_if_different ${QT_BINARY_DIR}/${qtlib}4.dll - ${CMAKE_BINARY_DIR}/Release/${qtlib}4.dll - ) - endforeach(qtlib) - endif(MSVC) -endif(Qt5Core_FOUND) +foreach(qtlib ${QT_LIBRARIES}) + add_custom_command( + TARGET ${PROJECT_NAME} + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different $ + $ + ) +endforeach(qtlib) diff --git a/Fwk/AppFwk/cafUserInterface/cafUserInterface_UnitTests/cafPdmUiTreeViewModelTest.cpp b/Fwk/AppFwk/cafUserInterface/cafUserInterface_UnitTests/cafPdmUiTreeViewModelTest.cpp index 85ae851d3c..805eaba8e7 100644 --- a/Fwk/AppFwk/cafUserInterface/cafUserInterface_UnitTests/cafPdmUiTreeViewModelTest.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafUserInterface_UnitTests/cafPdmUiTreeViewModelTest.cpp @@ -36,7 +36,7 @@ class DemoPdmObject : public caf::PdmObject CAF_PDM_InitFieldNoDefault( &m_simpleObjPtrField, "SimpleObjPtrField", "SimpleObjPtrField", "", "Tooltip", "WhatsThis" ); } - ~DemoPdmObject() { m_simpleObjPtrField.deleteAllChildObjects(); } + ~DemoPdmObject() { m_simpleObjPtrField.deleteChildren(); } caf::PdmChildArrayField m_simpleObjPtrField; }; @@ -66,7 +66,7 @@ TEST( PdmUiTreeViewModelTest, DeleteOneItemAndVerifyTreeOrdering ) mi = treeView.findModelIndex( obj1 ); EXPECT_TRUE( mi.isValid() ); - demoObj->m_simpleObjPtrField.removeChildObject( obj1 ); + demoObj->m_simpleObjPtrField.removeChild( obj1 ); demoObj->m_simpleObjPtrField().uiCapability()->updateConnectedEditors(); mi = treeView.findModelIndex( obj1 ); @@ -125,7 +125,7 @@ TEST( PdmUiTreeViewModelTest, ChangeOrderingAndVerifyTreeOrdering ) mi = treeView.findModelIndex( obj4 ); EXPECT_EQ( 3, mi.row() ); - demoObj->m_simpleObjPtrField.clear(); + demoObj->m_simpleObjPtrField.clearWithoutDelete(); demoObj->m_simpleObjPtrField.push_back( obj1 ); demoObj->m_simpleObjPtrField.push_back( obj4 ); demoObj->m_simpleObjPtrField.push_back( obj3 ); @@ -166,7 +166,7 @@ TEST( PdmUiTreeViewModelTest, ChangeDeepInTreeNotifyRootAndVerifyTreeOrdering ) mi = treeView.findModelIndex( obj4 ); EXPECT_EQ( 3, mi.row() ); - demoObj->m_simpleObjPtrField.removeChildObject( obj4 ); + demoObj->m_simpleObjPtrField.removeChild( obj4 ); root->m_simpleObjPtrField().uiCapability()->updateConnectedEditors(); diff --git a/Fwk/AppFwk/cafViewer/cafCadNavigation.cpp b/Fwk/AppFwk/cafViewer/cafCadNavigation.cpp index e785945581..483e9fd5ec 100644 --- a/Fwk/AppFwk/cafViewer/cafCadNavigation.cpp +++ b/Fwk/AppFwk/cafViewer/cafCadNavigation.cpp @@ -74,7 +74,7 @@ bool caf::CadNavigation::handleInputEvent( QInputEvent* inputEvent ) int translatedMousePosX, translatedMousePosY; cvfEventPos( me->x(), me->y(), &translatedMousePosX, &translatedMousePosY ); - if ( me->button() == Qt::MidButton && me->modifiers() == Qt::NoModifier && isRotationEnabled() ) + if ( me->button() == Qt::MiddleButton && me->modifiers() == Qt::NoModifier && isRotationEnabled() ) { this->pickAndSetPointOfInterest( me->x(), me->y() ); @@ -85,7 +85,7 @@ bool caf::CadNavigation::handleInputEvent( QInputEvent* inputEvent ) m_hasMovedMouseDuringNavigation = false; isEventHandled = true; } - else if ( me->button() == Qt::MidButton && ( me->modifiers() & Qt::ShiftModifier ) ) + else if ( me->button() == Qt::MiddleButton && ( me->modifiers() & Qt::ShiftModifier ) ) { m_trackball->startNavigation( cvf::ManipulatorTrackball::PAN, translatedMousePosX, translatedMousePosY ); m_isNavigating = true; @@ -100,7 +100,7 @@ bool caf::CadNavigation::handleInputEvent( QInputEvent* inputEvent ) if ( m_isNavigating ) { QMouseEvent* me = static_cast( inputEvent ); - if ( me->button() == Qt::MidButton ) + if ( me->button() == Qt::MiddleButton ) { m_trackball->endNavigation(); diff --git a/Fwk/AppFwk/cafViewer/cafCeetronNavigation.cpp b/Fwk/AppFwk/cafViewer/cafCeetronNavigation.cpp index 8e77a1d3b8..bdd52b41be 100644 --- a/Fwk/AppFwk/cafViewer/cafCeetronNavigation.cpp +++ b/Fwk/AppFwk/cafViewer/cafCeetronNavigation.cpp @@ -229,7 +229,7 @@ ManipulatorTrackball::NavigationType caf::CeetronNavigation::getNavigationTypeFr { return ManipulatorTrackball::ROTATE; } - else if ( mouseButtons == Qt::MidButton || mouseButtons == ( Qt::LeftButton | Qt::RightButton ) ) + else if ( mouseButtons == Qt::MiddleButton || mouseButtons == ( Qt::LeftButton | Qt::RightButton ) ) { return ManipulatorTrackball::WALK; } diff --git a/Fwk/AppFwk/cafViewer/cafCeetronPlusNavigation.cpp b/Fwk/AppFwk/cafViewer/cafCeetronPlusNavigation.cpp index ebce016cf3..e6df70a6d0 100644 --- a/Fwk/AppFwk/cafViewer/cafCeetronPlusNavigation.cpp +++ b/Fwk/AppFwk/cafViewer/cafCeetronPlusNavigation.cpp @@ -98,7 +98,7 @@ bool caf::CeetronPlusNavigation::handleInputEvent( QInputEvent* inputEvent ) isEventHandled = true; } } - else if ( me->button() == Qt::MidButton ) + else if ( me->button() == Qt::MiddleButton ) { if ( me->modifiers() == Qt::NoModifier ) { @@ -130,7 +130,7 @@ bool caf::CeetronPlusNavigation::handleInputEvent( QInputEvent* inputEvent ) if ( m_hasMovedMouseDuringNavigation ) isEventHandled = true; m_hasMovedMouseDuringNavigation = false; } - else if ( me->button() == Qt::MidButton ) + else if ( me->button() == Qt::MiddleButton ) { m_isZooming = false; diff --git a/Fwk/AppFwk/cafViewer/cafOpenGLWidget.h b/Fwk/AppFwk/cafViewer/cafOpenGLWidget.h index 32b66ae291..0da8fe54cc 100644 --- a/Fwk/AppFwk/cafViewer/cafOpenGLWidget.h +++ b/Fwk/AppFwk/cafViewer/cafOpenGLWidget.h @@ -59,7 +59,7 @@ class OpenGLWidget : public QGLWidget QWidget* parent, OpenGLWidget* shareWidget = nullptr, Qt::WindowFlags f = nullptr ); - OpenGLWidget( OpenGLWidget* shareWidget, QWidget* parent, Qt::WindowFlags f = nullptr ); + OpenGLWidget( OpenGLWidget* shareWidget, QWidget* parent, Qt::WindowFlags f = Qt::WindowFlags() ); cvf::OpenGLContext* cvfOpenGLContext() const; void cvfShutdownOpenGLContext(); diff --git a/Fwk/VizFwk/LibCore/cvfArray.inl b/Fwk/VizFwk/LibCore/cvfArray.inl index 6f76a71919..1a45775764 100644 --- a/Fwk/VizFwk/LibCore/cvfArray.inl +++ b/Fwk/VizFwk/LibCore/cvfArray.inl @@ -169,7 +169,7 @@ Array::~Array() template inline const T& Array::operator[] (size_t index) const { - CVF_TIGHT_ASSERT(this && m_data); + CVF_TIGHT_ASSERT(m_data); CVF_TIGHT_ASSERT(index < m_size); return m_data[index]; @@ -182,7 +182,7 @@ inline const T& Array::operator[] (size_t index) const template inline T& Array::operator[] (size_t index) { - CVF_TIGHT_ASSERT(this && m_data); + CVF_TIGHT_ASSERT(m_data); CVF_TIGHT_ASSERT(index < m_size); return m_data[index]; @@ -338,7 +338,6 @@ T cvf::Array::val(size_t index) const template inline const T* Array::ptr() const { - CVF_TIGHT_ASSERT(this); return m_data; } @@ -349,7 +348,6 @@ inline const T* Array::ptr() const template inline T* Array::ptr() { - CVF_TIGHT_ASSERT(this); return m_data; } @@ -361,7 +359,6 @@ inline T* Array::ptr() template inline const T* Array::ptr(size_t index) const { - CVF_TIGHT_ASSERT(this); CVF_TIGHT_ASSERT(index < m_size); return &m_data[index]; @@ -374,7 +371,6 @@ inline const T* Array::ptr(size_t index) const template inline T* Array::ptr(size_t index) { - CVF_TIGHT_ASSERT(this); CVF_TIGHT_ASSERT(index < m_size); return &m_data[index]; diff --git a/Fwk/VizFwk/LibGeometry/cvfBoundingBox.cpp b/Fwk/VizFwk/LibGeometry/cvfBoundingBox.cpp index ffb61848f8..486a125401 100644 --- a/Fwk/VizFwk/LibGeometry/cvfBoundingBox.cpp +++ b/Fwk/VizFwk/LibGeometry/cvfBoundingBox.cpp @@ -428,6 +428,29 @@ String BoundingBox::debugString() const return str; } +//-------------------------------------------------------------------------------------------------- +/// Cuts the box at the given depth, to never go below the given depth +/// +/// Note: cutting is a one time operation, adding new points to the box might extend the box below the cut depth +//-------------------------------------------------------------------------------------------------- +void BoundingBox::cutBelow(double depth) +{ + if (m_min.z() < depth) m_min.z() = depth; + if (m_max.z() < depth) m_max.z() = depth; +} + +//-------------------------------------------------------------------------------------------------- +/// Cuts the box at the given depth, to never go above the given depth +/// +/// Note: cutting is a one time operation, adding new points to the box might extend the box below the cut depth +//-------------------------------------------------------------------------------------------------- +void BoundingBox::cutAbove(double depth) +{ + if (m_min.z() > depth) m_min.z() = depth; + if (m_max.z() > depth) m_max.z() = depth; +} + + } // namespace cvf diff --git a/Fwk/VizFwk/LibGeometry/cvfBoundingBox.h b/Fwk/VizFwk/LibGeometry/cvfBoundingBox.h index d007379c2e..f2b02cda05 100644 --- a/Fwk/VizFwk/LibGeometry/cvfBoundingBox.h +++ b/Fwk/VizFwk/LibGeometry/cvfBoundingBox.h @@ -86,6 +86,9 @@ class BoundingBox void transform(const Mat4d& matrix); const BoundingBox getTransformed(const Mat4d& matrix) const; + void cutBelow(double depth); + void cutAbove(double depth); + String debugString() const; private: diff --git a/Fwk/VizFwk/LibGeometry/cvfBoundingBoxTree.cpp b/Fwk/VizFwk/LibGeometry/cvfBoundingBoxTree.cpp index 89086e5467..7fbc9d3e8b 100644 --- a/Fwk/VizFwk/LibGeometry/cvfBoundingBoxTree.cpp +++ b/Fwk/VizFwk/LibGeometry/cvfBoundingBoxTree.cpp @@ -187,6 +187,9 @@ namespace cvf { AABBTreeNodeInternal* createNode(); AABBTreeNodeLeaf* createOrAssignLeaf(size_t leafIndex, size_t bbId); + private: + static void deleteInternalNodesBottomUp(AABBTreeNode* node); + protected: struct InternalNodeAndRange { @@ -598,6 +601,7 @@ bool AABBTree::buildTree(AABBTreeNodeInternal* pNode, size_t iFromIdx, size_t iT return true; } + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -606,6 +610,8 @@ void AABBTree::freeThis() // Delete all the internal nodes if (m_pRoot) { + AABBTree::deleteInternalNodesBottomUp(m_pRoot); + m_pRoot = NULL; } @@ -781,6 +787,24 @@ cvf::AABBTreeNodeLeaf* AABBTree::createOrAssignLeaf(size_t leafIndex, size_t bbI return leaf; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void AABBTree::deleteInternalNodesBottomUp(AABBTreeNode* node) +{ + // All leaf nodes (AABBTreeNodeLeaf) are allocated in m_leafPool and does not require a delete + if (node->type() == AB_LEAF) return; + + auto internalNode = dynamic_cast(node); + CVF_ASSERT(internalNode); + + AABBTree::deleteInternalNodesBottomUp(internalNode->left()); + AABBTree::deleteInternalNodesBottomUp(internalNode->right()); + + delete internalNode; +} + //-------------------------------------------------------------------------------------------------- /// Creates leafs for the supplied valid bounding boxes, keeping the original index //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/VizFwk/LibGuiQt/cvfqtMouseState.cpp b/Fwk/VizFwk/LibGuiQt/cvfqtMouseState.cpp index 72a7d0bcda..cc28ad140b 100644 --- a/Fwk/VizFwk/LibGuiQt/cvfqtMouseState.cpp +++ b/Fwk/VizFwk/LibGuiQt/cvfqtMouseState.cpp @@ -246,7 +246,7 @@ int MouseState::numMouseButtonsInState(Qt::MouseButtons buttonState) if (buttonState & Qt::LeftButton) iNum++; if (buttonState & Qt::RightButton) iNum++; - if (buttonState & Qt::MidButton) iNum++; + if (buttonState & Qt::MiddleButton) iNum++; return iNum; } diff --git a/GrpcInterface/CMakeLists.txt b/GrpcInterface/CMakeLists.txt index b3b7d65bc5..a1bf143c16 100644 --- a/GrpcInterface/CMakeLists.txt +++ b/GrpcInterface/CMakeLists.txt @@ -231,13 +231,14 @@ target_include_directories(${PROJECT_NAME} PUBLIC target_link_libraries(${PROJECT_NAME} PRIVATE ${_LINK_LIBRARIES}) if(MSVC) - # GRPC generates a lot of harmless warnings on MSVC - set_target_properties( - ${PROJECT_NAME} - PROPERTIES COMPILE_FLAGS "/wd4251 /wd4702 /wd4005 /wd4244 /wd4125 /wd4267") + target_compile_options( + GrpcInterface + PRIVATE /wd4251 /wd4244 /wd4267) else() - set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS - "-Wno-overloaded-virtual") + target_compile_options( + GrpcInterface + PRIVATE -Wno-switch -Wno-overloaded-virtual + ) endif() # install gRPC Python files diff --git a/GrpcInterface/Python/rips/PythonExamples/create_intersection.py b/GrpcInterface/Python/rips/PythonExamples/create_intersection.py index 7a4aa786bf..aa6b74d7f9 100644 --- a/GrpcInterface/Python/rips/PythonExamples/create_intersection.py +++ b/GrpcInterface/Python/rips/PythonExamples/create_intersection.py @@ -41,14 +41,33 @@ coord = [0, 0, 0] geometry.append_well_target(coord) -# Append new well targets relative the the reference point +# Append well target with fixed azimuth coord = [2229.10, -833.74, -74.70] -target = geometry.append_well_target(coord) +target = geometry.append_well_target( + coord, use_fixed_azimuth=True, fixed_azimuth_value=45.1 +) + +# Append well target with fixed inclination +coord = [3403.15, -1938.61, -80.93] +target = geometry.append_well_target( + coord, use_fixed_inclination=True, fixed_inclination_value=115.2 +) coord = [4577.21, -3043.47, -87.15] target = geometry.append_well_target(coord) geometry.update() +# Read out estimated dogleg and azimuth/inclination for well targets +for w in geometry.well_path_targets(): + print( + "DL1:{} DL2:{} Azi: {} Incl: {}".format( + w.estimated_dogleg1, + w.estimated_dogleg2, + w.estimated_azimuth, + w.estimated_inclination, + ) + ) + # Add a curve intersection based on the modeled well path well_path_intersection = intersection_coll.add_new_object(rips.CurveIntersection) well_path_intersection.type = "CS_WELL_PATH" diff --git a/GrpcInterface/Python/rips/PythonExamples/import_fractures_on_well.py b/GrpcInterface/Python/rips/PythonExamples/import_fractures_on_well.py index cc3b33c12f..97eb8456a7 100644 --- a/GrpcInterface/Python/rips/PythonExamples/import_fractures_on_well.py +++ b/GrpcInterface/Python/rips/PythonExamples/import_fractures_on_well.py @@ -38,6 +38,8 @@ fracture = well_path.add_fracture( measured_depth=measured_depth, stim_plan_fracture_template=fracture_template, + align_dip=True, + eclipse_case=case, ) # Update the orientation of the fracture diff --git a/GrpcInterface/Python/rips/PythonExamples/summary_vectors.py b/GrpcInterface/Python/rips/PythonExamples/summary_vectors.py index 04165aca13..69dfb915be 100644 --- a/GrpcInterface/Python/rips/PythonExamples/summary_vectors.py +++ b/GrpcInterface/Python/rips/PythonExamples/summary_vectors.py @@ -30,7 +30,22 @@ for t, value in zip(summary_data_sampled.time_steps, summary_data_sampled.values): print(time.strftime("%a, %d %b %Y ", time.gmtime(t)) + " | " + str(value)) -summary_case.set_summary_values("FOPT_M1", "myUnit", summary_data.values) -summary_case.set_summary_values("FOPT_M2", "myUnit", summary_data.values) -summary_case.set_summary_values("FOPT_M3", "myUnit", summary_data.values) -summary_case.set_summary_values("FOPT_M4", "myUnit", summary_data.values) +test_values = summary_data.values +offset = test_values[len(test_values) - 1] / 10 + +for index, item in enumerate(test_values): + test_values[index] = test_values[index] + offset + +summary_case.set_summary_values("FOPT_M1", "myUnit", test_values) + +for index, item in enumerate(test_values): + test_values[index] = test_values[index] + offset +summary_case.set_summary_values("FOPT_M2", "myUnit", test_values) + +for index, item in enumerate(test_values): + test_values[index] = test_values[index] + offset +summary_case.set_summary_values("FOPT_M3", "myUnit", test_values) + +for index, item in enumerate(test_values): + test_values[index] = test_values[index] + offset +summary_case.set_summary_values("FOPT_M4", "myUnit", test_values) diff --git a/GrpcInterface/Python/rips/tests/create_well_path.py b/GrpcInterface/Python/rips/tests/create_well_path.py deleted file mode 100644 index 41206b7174..0000000000 --- a/GrpcInterface/Python/rips/tests/create_well_path.py +++ /dev/null @@ -1,35 +0,0 @@ -from rips.generated.generated_classes import ( - ModeledWellPath, - StimPlanModel, - WellPathGeometry, - WellPathTarget, -) -import sys -import os - -sys.path.insert(1, os.path.join(sys.path[0], "../../")) -import rips - - -def test_well_path_target(rips_instance, initialize_test): - well_path_coll = rips_instance.project.descendants(rips.WellPathCollection)[0] - - my_well_path = well_path_coll.add_new_object(rips.ModeledWellPath) - my_well_path.name = "test" - my_well_path.update() - - geometry = my_well_path.well_path_geometry() - geometry.add_new_object(rips.WellPathTarget) - geometry.add_new_object(rips.WellPathTarget) - geometry.add_new_object(rips.WellPathTarget) - assert len(geometry.well_path_targets()) == 3 - - assert len(well_path_coll.well_paths()) == 1 - my_well_path_duplicate = well_path_coll.well_paths()[0] - assert my_well_path_duplicate.name == "test" - geometry_duplicate = my_well_path_duplicate.well_path_geometry() - assert len(geometry_duplicate.well_path_targets()) == 3 - - # Not allowed to add object of unrelated type - invalid_object = geometry.add_new_object(rips.WellPath) - assert invalid_object is None diff --git a/GrpcInterface/Python/rips/tests/test_create_well_path.py b/GrpcInterface/Python/rips/tests/test_create_well_path.py new file mode 100644 index 0000000000..2cc866e05e --- /dev/null +++ b/GrpcInterface/Python/rips/tests/test_create_well_path.py @@ -0,0 +1,66 @@ +from rips.generated.generated_classes import ( + ModeledWellPath, + StimPlanModel, + WellPathGeometry, + WellPathTarget, +) +import sys +import os + +sys.path.insert(1, os.path.join(sys.path[0], "../../")) +import rips + + +def test_add_new_object_for_well_paths(rips_instance, initialize_test): + well_path_coll = rips_instance.project.descendants(rips.WellPathCollection)[0] + + my_well_path = well_path_coll.add_new_object(rips.ModeledWellPath) + my_well_path.name = "test" + my_well_path.update() + + geometry = my_well_path.well_path_geometry() + geometry.add_new_object(rips.WellPathTarget) + geometry.add_new_object(rips.WellPathTarget) + geometry.add_new_object(rips.WellPathTarget) + assert len(geometry.well_path_targets()) == 3 + + assert len(well_path_coll.well_paths()) == 1 + my_well_path_duplicate = well_path_coll.well_paths()[0] + assert my_well_path_duplicate.name == "test" + geometry_duplicate = my_well_path_duplicate.well_path_geometry() + assert len(geometry_duplicate.well_path_targets()) == 3 + + # Not allowed to add object of unrelated type + invalid_object = geometry.add_new_object(rips.WellPath) + assert invalid_object is None + + +def test_add_well_path_targets(rips_instance, initialize_test): + well_path_coll = rips_instance.project.descendants(rips.WellPathCollection)[0] + + my_well_path = well_path_coll.add_new_object(rips.ModeledWellPath) + my_well_path.name = "test" + my_well_path.update() + + geometry = my_well_path.well_path_geometry() + + # Append well target with fixed azimuth + coord = [2229.10, -833.74, -74.70] + target = geometry.append_well_target( + coord, use_fixed_azimuth=True, fixed_azimuth_value=110.1 + ) + assert target.use_fixed_inclination == False + assert target.use_fixed_azimuth == True + assert target.azimuth == 110.1 + assert target.inclination == 0.0 + + # Append well target with fixed inclination + coord = [4577.21, -3043.47, -87.15] + target = geometry.append_well_target( + coord, use_fixed_inclination=True, fixed_inclination_value=25.6 + ) + + assert target.use_fixed_inclination == True + assert target.use_fixed_azimuth == False + assert target.azimuth == 0.0 + assert target.inclination == 25.6 diff --git a/GrpcInterface/Python/rips/tests/test_summary_cases.py b/GrpcInterface/Python/rips/tests/test_summary_cases.py index 766e49e17b..de988d5abd 100644 --- a/GrpcInterface/Python/rips/tests/test_summary_cases.py +++ b/GrpcInterface/Python/rips/tests/test_summary_cases.py @@ -123,35 +123,3 @@ def test_summary_set_values(rips_instance, initialize_test): addresses = summary_case.available_addresses() current_keyword_count = len(addresses.values) assert current_keyword_count == original_keyword_count + 1 - - -def test_summary_set_values(rips_instance, initialize_test): - casePath = dataroot.PATH + "/flow_diagnostics_test/SIMPLE_SUMMARY2.SMSPEC" - summary_case = rips_instance.project.import_summary_case(casePath) - assert summary_case.id == 1 - - addresses = summary_case.available_addresses() - original_keyword_count = len(addresses.values) - - summary_data = summary_case.summary_vector_values("FOPT") - assert len(summary_data.values) == 60 - - summary_case.set_summary_values("FOPT_1", "", summary_data.values) - generated_summary_data = summary_case.summary_vector_values("FOPT_1") - assert len(generated_summary_data.values) == 60 - - addresses = summary_case.available_addresses() - current_keyword_count = len(addresses.values) - assert current_keyword_count == original_keyword_count + 1 - - # Using existing keyword will overwrite existing data - summary_case.set_summary_values("FOPT_1", "", summary_data.values) - addresses = summary_case.available_addresses() - current_keyword_count = len(addresses.values) - assert current_keyword_count == original_keyword_count + 1 - - # invalid value count, check that available addresses are unchanged - summary_case.set_summary_values("FOPT_2", "", []) - addresses = summary_case.available_addresses() - current_keyword_count = len(addresses.values) - assert current_keyword_count == original_keyword_count + 1 diff --git a/GrpcInterface/Python/rips/tests/test_well_log_extraction.py b/GrpcInterface/Python/rips/tests/test_well_log_extraction.py new file mode 100644 index 0000000000..b411bbbfcf --- /dev/null +++ b/GrpcInterface/Python/rips/tests/test_well_log_extraction.py @@ -0,0 +1,46 @@ +import sys +import os +import tempfile + +sys.path.insert(1, os.path.join(sys.path[0], "../../")) +import rips + +import dataroot + + +def test_10k_well_log_extraction(rips_instance, initialize_test): + case_root_path = dataroot.PATH + "/TEST10K_FLT_LGR_NNC" + case_path = case_root_path + "/TEST10K_FLT_LGR_NNC.EGRID" + case = rips_instance.project.load_case(path=case_path) + assert len(case.grids()) == 2 + well_path_files = [ + case_root_path + "/wellpath_a.dev", + ] + + view = case.create_view() + view.set_time_step(1) + + well_path_names = rips_instance.project.import_well_paths(well_path_files) + wells = rips_instance.project.well_paths() + well_path = wells[0] + + properties = [ + ("STATIC_NATIVE", "INDEX_K", 0), + ("STATIC_NATIVE", "PORO", 0), + ("STATIC_NATIVE", "PERMX", 0), + ("DYNAMIC_NATIVE", "PRESSURE", 0), + ] + + well_log_plot_collection = rips_instance.project.descendants( + rips.WellLogPlotCollection + )[0] + + well_log_plot = well_log_plot_collection.new_well_log_plot(case, well_path) + + # Create a track for each property + for (prop_type, prop_name, time_step) in properties: + track = well_log_plot.new_well_log_track("Track: " + prop_name, case, well_path) + c = track.add_extraction_curve(case, well_path, prop_type, prop_name, time_step) + + with tempfile.TemporaryDirectory(prefix="rips") as tmpdirname: + well_log_plot.export_data_as_las(export_folder=tmpdirname) diff --git a/GrpcInterface/RiaGrpcCallbacks.h b/GrpcInterface/RiaGrpcCallbacks.h index f7c2bb6cd2..fdef188e9d 100644 --- a/GrpcInterface/RiaGrpcCallbacks.h +++ b/GrpcInterface/RiaGrpcCallbacks.h @@ -85,6 +85,7 @@ class RiaGrpcServiceCallback : public RiaGrpcCallbackInterface { public: RiaGrpcServiceCallback( ServiceT* service ); + ~RiaGrpcServiceCallback(); QString name() const override; const RequestT& request() const; @@ -99,6 +100,14 @@ class RiaGrpcServiceCallback : public RiaGrpcCallbackInterface ReplyT m_reply; }; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +template +RiaGrpcServiceCallback::~RiaGrpcServiceCallback() +{ +} + //================================================================================================== // // Templated gRPC-callback for non-streaming services diff --git a/GrpcInterface/RiaGrpcCommandService.cpp b/GrpcInterface/RiaGrpcCommandService.cpp index a8073357cf..3ee39f216a 100644 --- a/GrpcInterface/RiaGrpcCommandService.cpp +++ b/GrpcInterface/RiaGrpcCommandService.cpp @@ -259,7 +259,7 @@ void RiaGrpcCommandService::assignPdmObjectValues( caf::PdmObjectHandle* if ( pdmChildFieldHandle ) { std::vector childObjects; - pdmChildFieldHandle->childObjects( &childObjects ); + pdmChildFieldHandle->children( &childObjects ); caf::PdmObjectHandle* childObject = nullptr; CAF_ASSERT( childObjects.size() <= 1u ); // We do not support child array fields yet diff --git a/GrpcInterface/RiaGrpcPdmObjectService.cpp b/GrpcInterface/RiaGrpcPdmObjectService.cpp index 2be5c99584..b97d5c5c63 100644 --- a/GrpcInterface/RiaGrpcPdmObjectService.cpp +++ b/GrpcInterface/RiaGrpcPdmObjectService.cpp @@ -416,7 +416,7 @@ grpc::Status RiaGrpcPdmObjectService::GetChildPdmObjects( grpc::ServerContext* if ( scriptability && scriptability->scriptFieldName() == fieldName ) { std::vector childObjects; - field->childObjects( &childObjects ); + field->children( &childObjects ); for ( auto pdmChild : childObjects ) { rips::PdmObject* ripsChild = reply->add_objects(); diff --git a/GrpcInterface/RiaGrpcPropertiesService.cpp b/GrpcInterface/RiaGrpcPropertiesService.cpp index 0cb7a6d6e1..2c596c584c 100644 --- a/GrpcInterface/RiaGrpcPropertiesService.cpp +++ b/GrpcInterface/RiaGrpcPropertiesService.cpp @@ -248,12 +248,31 @@ class RiaActiveCellResultsStateHandler : public RiaCellResultsStateHandler RigEclipseResultAddress resVarAddr ) override { auto activeCellInfo = caseData->activeCellInfo( porosityModel ); + m_cellCount = activeCellInfo->reservoirActiveCellCount(); m_resultValues = caseData->results( porosityModel )->modifiableCellScalarResult( resVarAddr, timeStepIndex ); if ( m_resultValues->empty() ) { m_resultValues->resize( activeCellInfo->reservoirActiveCellCount() ); } - m_cellCount = activeCellInfo->reservoirActiveCellCount(); + else if ( m_resultValues->size() != m_cellCount ) + { + // Filter out inactive cells + std::vector activeCellResultValues( m_cellCount ); + size_t reservoirCellCount = activeCellInfo->reservoirCellCount(); + for ( size_t cellIdx = 0; cellIdx < reservoirCellCount; cellIdx++ ) + { + size_t activeCellIdx = caseData->activeCellInfo( m_porosityModel )->cellResultIndex( cellIdx ); + if ( activeCellIdx != cvf::UNDEFINED_SIZE_T ) + activeCellResultValues[activeCellIdx] = ( *m_resultValues )[cellIdx]; + } + + // Use the filtered result + m_resultValues->resize( m_cellCount ); + for ( size_t activeIdx = 0; activeIdx < m_cellCount; activeIdx++ ) + { + ( *m_resultValues )[activeIdx] = activeCellResultValues[activeIdx]; + } + } } double cellResult( size_t currentCellIndex ) const override { return ( *m_resultValues )[currentCellIndex]; } diff --git a/GrpcInterface/RiaGrpcServer.cpp b/GrpcInterface/RiaGrpcServer.cpp index f89ba9af87..7dc9eff813 100644 --- a/GrpcInterface/RiaGrpcServer.cpp +++ b/GrpcInterface/RiaGrpcServer.cpp @@ -74,6 +74,7 @@ class RiaGrpcServerImpl std::unique_ptr m_server; std::list> m_services; std::list m_unprocessedRequests; + std::list m_allocatedCallbakcs; std::mutex m_requestMutex; std::thread m_thread; }; @@ -217,6 +218,12 @@ void RiaGrpcServerImpl::quit() m_server.reset(); m_completionQueue.reset(); + for ( auto c : m_allocatedCallbakcs ) + { + delete c; + } + m_allocatedCallbakcs.clear(); + // Finally clear services m_services.clear(); } @@ -253,6 +260,8 @@ void RiaGrpcServerImpl::process( RiaGrpcCallbackInterface* method ) if ( method->callState() == RiaGrpcCallbackInterface::CREATE_HANDLER ) { method->createRequestHandler( m_completionQueue.get() ); + + m_allocatedCallbakcs.push_back( method ); } else if ( method->callState() == RiaGrpcCallbackInterface::INIT_REQUEST_STARTED ) { @@ -269,7 +278,11 @@ void RiaGrpcServerImpl::process( RiaGrpcCallbackInterface* method ) else { method->onFinishRequest(); + process( method->createNewFromThis() ); + + m_allocatedCallbakcs.remove( method ); + delete method; } } diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 3908b92314..6cc10100df 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -1,17 +1,17 @@ -set(RESINSIGHT_MAJOR_VERSION 2021) -set(RESINSIGHT_MINOR_VERSION 10) -set(RESINSIGHT_PATCH_VERSION 3) +set(RESINSIGHT_MAJOR_VERSION 2022) +set(RESINSIGHT_MINOR_VERSION 06) +set(RESINSIGHT_PATCH_VERSION 0) # Opional text with no restrictions -#set(RESINSIGHT_VERSION_TEXT "-dev") -#set(RESINSIGHT_VERSION_TEXT "-RC_01") +#"set(RESINSIGHT_VERSION_TEXT "-dev") +#set(RESINSIGHT_VERSION_TEXT "-RC_03") # Optional text # 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 ".01") +# set(RESINSIGHT_DEV_VERSION ".01") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") diff --git a/ThirdParty/Ert/lib/ecl/ecl_smspec.cpp b/ThirdParty/Ert/lib/ecl/ecl_smspec.cpp index e0a4742c90..7136067d46 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_smspec.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_smspec.cpp @@ -754,6 +754,8 @@ static void ecl_smspec_install_special_keys( ecl_smspec_type * ecl_smspec , cons break; case(ECL_SMSPEC_AQUIFER_VAR): break; + case(ECL_SMSPEC_NETWORK_VAR): + break; default: throw std::invalid_argument("Internal error - should not be here \n"); } diff --git a/ThirdParty/Ert/lib/ecl/smspec_node.cpp b/ThirdParty/Ert/lib/ecl/smspec_node.cpp index a1c98178fb..fdeada0d78 100644 --- a/ThirdParty/Ert/lib/ecl/smspec_node.cpp +++ b/ThirdParty/Ert/lib/ecl/smspec_node.cpp @@ -57,11 +57,26 @@ ecl_smspec_identify_special_var() and ecl_smspec_identify_var_type(). */ -static const char* special_vars[] = {"NEWTON", - "NAIMFRAC", +static const char* special_vars[] = {"NAIMFRAC", + "NBAKFL", + "NBYTOT", + "NCPRLINS", + "NEWTFL", + "NEWTON", + "NLINEARP", + "NLINEARS", "NLINEARS", - "NLINSMIN", "NLINSMAX", + "NLINSMIN", + "NLRESMAX", + "NLRESSUM", + "NMESSAGE", + "NNUMFL", + "NNUMST", + "NTS", + "NTSECL", + "NTSMCL", + "NTSPCL", "ELAPSED", "MAXDPR", "MAXDSO", @@ -592,6 +607,10 @@ void smspec_node::set_gen_keys( const char* key_join_string_) { // KEYWORD gen_key1 = keyword; break; + case(ECL_SMSPEC_NETWORK_VAR): + // KEYWORD + gen_key1 = keyword; + break; case(ECL_SMSPEC_GROUP_VAR): // KEYWORD:WGNAME gen_key1 = smspec_alloc_group_key( key_join_string_ , keyword , wgname); @@ -718,6 +737,9 @@ ecl_smspec_var_type smspec_node::valid_type(const char * keyword, const char * w return var_type; } + if (var_type == ECL_SMSPEC_NETWORK_VAR) + return var_type; + return ECL_SMSPEC_INVALID_VAR; } @@ -907,6 +929,8 @@ smspec_node::smspec_node(int param_index, case(ECL_SMSPEC_AQUIFER_VAR): set_num( grid_dims , num ); break; + case(ECL_SMSPEC_NETWORK_VAR): + break; default: throw std::invalid_argument("Should not be here ... "); break; @@ -941,6 +965,8 @@ smspec_node::smspec_node( int param_index_, switch (this->var_type) { case(ECL_SMSPEC_LOCAL_WELL_VAR): break; + case(ECL_SMSPEC_NETWORK_VAR): + break; case(ECL_SMSPEC_LOCAL_BLOCK_VAR): set_lgr_ijk( lgr_i, lgr_j , lgr_k ); break; diff --git a/ThirdParty/clipper/CMakeLists.txt b/ThirdParty/clipper/CMakeLists.txt index 300964eeb3..9f84a5e20b 100644 --- a/ThirdParty/clipper/CMakeLists.txt +++ b/ThirdParty/clipper/CMakeLists.txt @@ -1,5 +1,9 @@ cmake_minimum_required (VERSION 2.8.12) +if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-copy") +endif() + project (clipper) set(project_source_files diff --git a/ThirdParty/custom-opm-common/CMakeLists.txt b/ThirdParty/custom-opm-common/CMakeLists.txt index c1e0e3d2a9..5956aa84d0 100644 --- a/ThirdParty/custom-opm-common/CMakeLists.txt +++ b/ThirdParty/custom-opm-common/CMakeLists.txt @@ -1,8 +1,5 @@ cmake_minimum_required (VERSION 2.8) -# -DBOOST_FILESYSTEM_VERSION=3 -DBOOST_TEST_DYN_LINK -DHAVE_CASE_SENSITIVE_FILESYSTEM=1 -DHAVE_REGEX=1 -DOPM_PARSER_DECK_API=1 -Wall -std=c++11 -fopenmp -Wall -g -O0 -DDEBUG -ggdb3 - - # Languages and global compiler settings if(CMAKE_VERSION VERSION_LESS 3.8) message(WARNING "CMake version does not support c++17, guessing -std=c++17") @@ -13,12 +10,19 @@ else() set(CMAKE_CXX_EXTENSIONS OFF) endif() - if(MSVC) - add_definitions( "/wd4996 /wd4244 /wd4267" ) + add_definitions( "/wd4996 /wd4244 /wd4267 /wd4101 /wd4477" ) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /permissive-") endif(MSVC) +if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter -Wno-switch -Wno-sign-compare -Wno-deprecated-copy -Wno-missing-field-initializers") +endif() + +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sign-compare -Wno-missing-field-initializers -Wno-deprecated-copy") +endif() + project (custom-opm-common) find_package(Boost) @@ -84,6 +88,7 @@ add_library(${PROJECT_NAME} opm-common/src/opm/io/eclipse/ESmry.cpp opm-common/src/opm/io/eclipse/ExtESmry.cpp opm-common/src/opm/io/eclipse/EInit.cpp + opm-common/src/opm/io/eclipse/ERft.cpp # Required for use of static function RstConnection::inverse_peaceman opm-common/src/opm/io/eclipse/rst/connection.cpp @@ -111,12 +116,12 @@ if(RESINSIGHT_ENABLE_UNITY_BUILD) endforeach(fileToExclude) endif() - find_path(BOOST_SPIRIT_INCLUDE_DIRS "boost/spirit.hpp" HINTS ${Boost_INCLUDE_DIRS}) target_link_libraries(custom-opm-common ${ADDITIONAL_LINK_LIBRARIES} ) + target_include_directories(custom-opm-common PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/opm-common diff --git a/ThirdParty/custom-opm-common/opm-common/opm/io/eclipse/EclOutput.hpp b/ThirdParty/custom-opm-common/opm-common/opm/io/eclipse/EclOutput.hpp index a20c4d0dd2..74628ce416 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/io/eclipse/EclOutput.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/io/eclipse/EclOutput.hpp @@ -63,13 +63,13 @@ class EclOutput if (isFormatted) { - writeFormattedHeader(name, data.size(), arrType, element_size); + writeFormattedHeader(name, static_cast(data.size()), arrType, element_size); if (arrType != MESS) writeFormattedArray(data); } else { - writeBinaryHeader(name, data.size(), arrType, element_size); + writeBinaryHeader(name, static_cast(data.size()), arrType, element_size); if (arrType != MESS) writeBinaryArray(data); } diff --git a/ThirdParty/custom-opm-common/opm-common/opm/io/eclipse/SummaryNode.hpp b/ThirdParty/custom-opm-common/opm-common/opm/io/eclipse/SummaryNode.hpp index 82f16e4baf..a26dcb4445 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/io/eclipse/SummaryNode.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/io/eclipse/SummaryNode.hpp @@ -24,6 +24,7 @@ #include #include #include +#include namespace Opm { namespace EclIO { diff --git a/ThirdParty/custom-opm-flowdiag-app/CMakeLists.txt b/ThirdParty/custom-opm-flowdiag-app/CMakeLists.txt index a3cfcd3d34..a44c68d824 100644 --- a/ThirdParty/custom-opm-flowdiag-app/CMakeLists.txt +++ b/ThirdParty/custom-opm-flowdiag-app/CMakeLists.txt @@ -6,6 +6,10 @@ if (CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -Wno-deprecated-declarations") endif() +if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -Wno-deprecated-declarations -Wno-delete-abstract-non-virtual-dtor -Wno-deprecated-copy") +endif() + include_directories( ../custom-opm-flowdiagnostics/opm-flowdiagnostics opm-flowdiagnostics-applications diff --git a/ThirdParty/qwt b/ThirdParty/qwt index 0bd598c700..886436d422 160000 --- a/ThirdParty/qwt +++ b/ThirdParty/qwt @@ -1 +1 @@ -Subproject commit 0bd598c7008afbaa7216755fb9a4ac0da2e612eb +Subproject commit 886436d42226eb2f978735717da03d4e1a912d55 diff --git a/ThirdParty/vcpkg b/ThirdParty/vcpkg index 5568f110b5..af2287382b 160000 --- a/ThirdParty/vcpkg +++ b/ThirdParty/vcpkg @@ -1 +1 @@ -Subproject commit 5568f110b509a9fd90711978a7cb76bae75bb092 +Subproject commit af2287382b1991dbdcb7e5112d236f3323b9dd7a diff --git a/doc/qwtplot.plantuml b/doc/qwtplot.plantuml index 9ca60b088e..a4442853da 100644 --- a/doc/qwtplot.plantuml +++ b/doc/qwtplot.plantuml @@ -1,25 +1,31 @@ @startuml package Rim { - PdmObject <|-- RimViewWindow package plots { -RimViewWindow <|-- RimGridCrossPlot -RimViewWindow <|-- RimSummaryPlot -RimRiuQwtPlotOwnerInterface <|-- RimGridCrossPlot -RimRiuQwtPlotOwnerInterface <|-- RimSummaryPlot +RimViewWindow <|-- RimPlotWindow +RimPlotWindow <|-- RimPlot +RimPlot <|-- RimSummaryPlot +} } -package Qwt { -QWidget <|-- QwtPlot +package RiuQwt { +class RiuSummaryQwtPlot +class RiuQwtPlotWidget } -package RiuQwt -{ -QwtPlot <|--- RiuQwtPlot -RiuQwtPlot <|--- RiuSummaryQwtPlot -RiuQwtPlot -r-> RimRiuQwtPlotOwnerInterface +package RiuQtCharts { +class RiuSummaryQtChartsPlot +class RiuQtChartsPlotWidget } -RimSummaryPlot -r-> RiuSummaryQwtPlot -RimGridCrossPlot -r-> RiuQwtPlot +RiuPlotWidget <|--- RiuQwtPlotWidget +RiuSummaryPlot <|-- RiuSummaryQwtPlot + +RiuSummaryQwtPlot --> RiuQwtPlotWidget +RiuSummaryQtChartsPlot --> RiuQtChartsPlotWidget + +RiuSummaryPlot <|-- RiuSummaryQtChartsPlot +RiuPlotWidget <|--- RiuQtChartsPlotWidget + +RimSummaryPlot --> RiuSummaryPlot @enduml