From b616864416ea55eef43bfc7589331c406d1309bd Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 11 Sep 2019 09:25:00 +0200 Subject: [PATCH 1/6] System : Remove obsolete includes --- ApplicationCode/Application/Tools/RiaBoundingBoxTools.h | 1 - ApplicationCode/Application/Tools/RiaCellDividingTools.h | 1 - 2 files changed, 2 deletions(-) diff --git a/ApplicationCode/Application/Tools/RiaBoundingBoxTools.h b/ApplicationCode/Application/Tools/RiaBoundingBoxTools.h index 78ed010a5a..6bf4766fe2 100644 --- a/ApplicationCode/Application/Tools/RiaBoundingBoxTools.h +++ b/ApplicationCode/Application/Tools/RiaBoundingBoxTools.h @@ -20,7 +20,6 @@ #pragma once -#include #include //================================================================================================== diff --git a/ApplicationCode/Application/Tools/RiaCellDividingTools.h b/ApplicationCode/Application/Tools/RiaCellDividingTools.h index b164180c0f..edb992b033 100644 --- a/ApplicationCode/Application/Tools/RiaCellDividingTools.h +++ b/ApplicationCode/Application/Tools/RiaCellDividingTools.h @@ -18,7 +18,6 @@ #pragma once -#include #include #include From 87afbaf58639527b3280bf6d6f0a4ab29e2546f4 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 11 Sep 2019 09:29:21 +0200 Subject: [PATCH 2/6] Summary : Propagate uiConfigName to curveSelectionEditor --- .../Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp index ded5829166..031d7dc223 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp @@ -330,7 +330,7 @@ void RicSummaryCurveCreator::defineUiOrdering( QString uiConfigName, caf::PdmUiO syncPreviewCurvesFromUiSelection(); - m_summaryCurveSelectionEditor->updateUi(); + m_summaryCurveSelectionEditor->updateUi( uiConfigName ); } //-------------------------------------------------------------------------------------------------- From 020313da9116f0c255c38eaadae7264a07f712bf Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 11 Sep 2019 09:33:03 +0200 Subject: [PATCH 3/6] #4657 Summary Templates : Application objects Add file path to preferences Show templates in project tree Add pointer to template to RimSummaryPlot --- .../Application/RiaApplication.cpp | 2 + .../Application/RiaPreferences.cpp | 47 +++- ApplicationCode/Application/RiaPreferences.h | 9 +- ApplicationCode/CMakeLists.txt | 2 + .../CMakeLists_files.cmake | 24 +++ .../RicCreatePlotFromSelectionFeature.cpp | 198 +++++++++++++++++ .../RicCreatePlotFromSelectionFeature.h | 47 ++++ .../RicSavePlotTemplateFeature.cpp | 112 ++++++++++ .../RicSavePlotTemplateFeature.h | 42 ++++ .../PlotTemplates/CMakeLists_files.cmake | 20 ++ .../PlotTemplates/RimPlotTemplateFileItem.cpp | 65 ++++++ .../PlotTemplates/RimPlotTemplateFileItem.h | 41 ++++ .../RimPlotTemplateFolderItem.cpp | 200 ++++++++++++++++++ .../PlotTemplates/RimPlotTemplateFolderItem.h | 67 ++++++ .../RimContextCommandBuilder.cpp | 6 +- .../ProjectDataModel/RimProject.cpp | 26 +++ ApplicationCode/ProjectDataModel/RimProject.h | 7 +- .../Summary/RimSummaryPlot.cpp | 43 ++++ .../ProjectDataModel/Summary/RimSummaryPlot.h | 12 +- 19 files changed, 963 insertions(+), 7 deletions(-) create mode 100644 ApplicationCode/Commands/PlotTemplateCommands/CMakeLists_files.cmake create mode 100644 ApplicationCode/Commands/PlotTemplateCommands/RicCreatePlotFromSelectionFeature.cpp create mode 100644 ApplicationCode/Commands/PlotTemplateCommands/RicCreatePlotFromSelectionFeature.h create mode 100644 ApplicationCode/Commands/PlotTemplateCommands/RicSavePlotTemplateFeature.cpp create mode 100644 ApplicationCode/Commands/PlotTemplateCommands/RicSavePlotTemplateFeature.h create mode 100644 ApplicationCode/ProjectDataModel/PlotTemplates/CMakeLists_files.cmake create mode 100644 ApplicationCode/ProjectDataModel/PlotTemplates/RimPlotTemplateFileItem.cpp create mode 100644 ApplicationCode/ProjectDataModel/PlotTemplates/RimPlotTemplateFileItem.h create mode 100644 ApplicationCode/ProjectDataModel/PlotTemplates/RimPlotTemplateFolderItem.cpp create mode 100644 ApplicationCode/ProjectDataModel/PlotTemplates/RimPlotTemplateFolderItem.h diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index 225c48893d..b6c7eadda6 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -1118,6 +1118,7 @@ void RiaApplication::applyPreferences() if ( this->project() ) { this->project()->setScriptDirectories( m_preferences->scriptDirectories() ); + this->project()->setPlotTemplateFolders( m_preferences->plotTemplateFolders() ); this->project()->updateConnectedEditors(); } caf::PdmSettings::writeFieldsToApplicationStore( m_preferences ); @@ -1415,6 +1416,7 @@ void RiaApplication::initialize() // Start with a project m_project = new RimProject; m_project->setScriptDirectories( m_preferences->scriptDirectories() ); + m_project->setPlotTemplateFolders( m_preferences->plotTemplateFolders() ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Application/RiaPreferences.cpp b/ApplicationCode/Application/RiaPreferences.cpp index 1c454c46f0..a225c49df5 100644 --- a/ApplicationCode/Application/RiaPreferences.cpp +++ b/ApplicationCode/Application/RiaPreferences.cpp @@ -301,6 +301,17 @@ RiaPreferences::RiaPreferences( void ) CAF_PDM_InitFieldNoDefault( &m_timeFormat, "timeFormat", "Time Format", "", "", "" ); m_timeFormat.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); m_timeFormat = RiaQDateTimeTools::supportedTimeFormats().front(); + + 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", + "", + "", + "" ); + m_searchPlotTemplateFoldersRecursively.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); } //-------------------------------------------------------------------------------------------------- @@ -320,7 +331,7 @@ void RiaPreferences::defineEditorAttribute( const caf::PdmFieldHandle* field, { m_readerSettings->defineEditorAttribute( field, uiConfigName, attribute ); - if ( field == &scriptDirectories ) + if ( field == &scriptDirectories || field == &m_plotTemplateFolders ) { caf::PdmUiFilePathEditorAttribute* myAttr = dynamic_cast( attribute ); if ( myAttr ) @@ -334,7 +345,8 @@ void RiaPreferences::defineEditorAttribute( const caf::PdmFieldHandle* field, field == &m_appendClassNameToUiText || field == &m_appendFieldKeywordToToolTipText || field == &m_showTestToolbar || field == &m_includeFractureDebugInfoFile || field == &showLasCurveWithoutTvdWarning || field == &holoLensDisableCertificateVerification || - field == &m_showProjectChangedDialog || field == &showLegendBackground ) + field == &m_showProjectChangedDialog || field == &m_searchPlotTemplateFoldersRecursively || + field == &showLegendBackground ) { caf::PdmUiCheckBoxEditorAttribute* myAttr = dynamic_cast( attribute ); if ( myAttr ) @@ -422,6 +434,10 @@ void RiaPreferences::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering.add( &defaultSummaryHistoryCurveStyle ); uiOrdering.add( &m_dateFormat ); uiOrdering.add( &m_timeFormat ); + + caf::PdmUiGroup* group = uiOrdering.addNewGroup( "Plot Templates" ); + group->add( &m_plotTemplateFolders ); + group->add( &m_searchPlotTemplateFoldersRecursively ); } else if ( uiConfigName == RiaPreferences::tabNameScripting() ) { @@ -673,6 +689,33 @@ const QString& RiaPreferences::timeFormat() const return m_timeFormat(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaPreferences::searchPlotTemplateFoldersRecursively() const +{ + return m_searchPlotTemplateFoldersRecursively(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RiaPreferences::plotTemplateFolders() const +{ + QStringList filteredFolders; + QStringList pathList = m_plotTemplateFolders().split( ';' ); + for ( const auto& path : pathList ) + { + QDir dir( path ); + if ( !path.isEmpty() && dir.exists() && dir.isReadable() ) + { + filteredFolders.push_back( path ); + } + } + + return filteredFolders; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Application/RiaPreferences.h b/ApplicationCode/Application/RiaPreferences.h index 3c1afc4bcb..e0509f8aae 100644 --- a/ApplicationCode/Application/RiaPreferences.h +++ b/ApplicationCode/Application/RiaPreferences.h @@ -79,6 +79,9 @@ public: const QString& dateFormat() const; const QString& timeFormat() const; + bool searchPlotTemplateFoldersRecursively() const; + QStringList plotTemplateFolders() const; + std::map defaultFontSizes() const; public: // Pdm Fields @@ -162,5 +165,9 @@ private: caf::PdmField m_holoLensExportFolder; caf::PdmField m_dateFormat; caf::PdmField m_timeFormat; - QStringList m_tabNames; + + caf::PdmField m_plotTemplateFolders; + caf::PdmField m_searchPlotTemplateFoldersRecursively; + + QStringList m_tabNames; }; diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index b762ecf03a..88463dd4a3 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -124,6 +124,7 @@ list( APPEND REFERENCED_CMAKE_FILES ProjectDataModel/Annotations/CMakeLists_files.cmake ProjectDataModel/Completions/CMakeLists_files.cmake ProjectDataModel/Measurement/CMakeLists_files.cmake + ProjectDataModel/PlotTemplates/CMakeLists_files.cmake GeoMech/GeoMechVisualization/CMakeLists_files.cmake @@ -157,6 +158,7 @@ list( APPEND REFERENCED_CMAKE_FILES Commands/ViewLink/CMakeLists_files.cmake Commands/WellLogCommands/CMakeLists_files.cmake Commands/WellPathCommands/CMakeLists_files.cmake + Commands/PlotTemplateCommands/CMakeLists_files.cmake CommandFileInterface/CMakeLists_files.cmake CommandFileInterface/Core/CMakeLists_files.cmake diff --git a/ApplicationCode/Commands/PlotTemplateCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/PlotTemplateCommands/CMakeLists_files.cmake new file mode 100644 index 0000000000..c3d54be345 --- /dev/null +++ b/ApplicationCode/Commands/PlotTemplateCommands/CMakeLists_files.cmake @@ -0,0 +1,24 @@ + +set (SOURCE_GROUP_HEADER_FILES +${CMAKE_CURRENT_LIST_DIR}/RicSavePlotTemplateFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicCreatePlotFromSelectionFeature.h +) + +set (SOURCE_GROUP_SOURCE_FILES +${CMAKE_CURRENT_LIST_DIR}/RicSavePlotTemplateFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicCreatePlotFromSelectionFeature.cpp +) + +list(APPEND CODE_HEADER_FILES +${SOURCE_GROUP_HEADER_FILES} +) + +list(APPEND CODE_SOURCE_FILES +${SOURCE_GROUP_SOURCE_FILES} +) + +list(APPEND QT_MOC_HEADERS +) + +source_group( "CommandFeature\\PlotTemplate" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) + diff --git a/ApplicationCode/Commands/PlotTemplateCommands/RicCreatePlotFromSelectionFeature.cpp b/ApplicationCode/Commands/PlotTemplateCommands/RicCreatePlotFromSelectionFeature.cpp new file mode 100644 index 0000000000..e7b27d5165 --- /dev/null +++ b/ApplicationCode/Commands/PlotTemplateCommands/RicCreatePlotFromSelectionFeature.cpp @@ -0,0 +1,198 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 "RiaGuiApplication.h" +#include "RiaSummaryTools.h" + +#include "RicCreatePlotFromSelectionFeature.h" + +#include "RimMainPlotCollection.h" +#include "RimProject.h" +#include "RimSummaryCase.h" +#include "RimSummaryCurve.h" +#include "RimSummaryPlot.h" +#include "RimSummaryPlotCollection.h" +#include "RimWellPath.h" + +#include "cafPdmObject.h" +#include "cafSelectionManager.h" + +#include +#include + +CAF_CMD_SOURCE_INIT( RicCreatePlotFromSelectionFeature, "RicCreatePlotFromSelectionFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicCreatePlotFromSelectionFeature::RicCreatePlotFromSelectionFeature() {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicCreatePlotFromSelectionFeature::isCommandEnabled() +{ + if ( selectedSummaryCases().size() == 2 ) return true; + if ( selectedWellPaths().size() == 2 ) return true; + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicCreatePlotFromSelectionFeature::onActionTriggered( bool isChecked ) +{ + { + auto sumCases = selectedSummaryCases(); + if ( sumCases.size() == 2 ) + { + QString fileName = "d:/projects/ri-plot-templates/one_well_two_cases.rpt"; + + RimSummaryPlot* newSummaryPlot = createPlotFromTemplateFile( fileName ); + if ( newSummaryPlot ) + { + RimSummaryPlotCollection* plotColl = + RiaApplication::instance()->project()->mainPlotCollection()->summaryPlotCollection(); + + plotColl->summaryPlots.push_back( newSummaryPlot ); + + // Resolve references after object has been inserted into the data model + newSummaryPlot->resolveReferencesRecursively(); + newSummaryPlot->initAfterReadRecursively(); + + QString nameOfCopy = QString( "Copy of " ) + newSummaryPlot->description(); + newSummaryPlot->setDescription( nameOfCopy ); + + auto summaryCurves = newSummaryPlot->summaryCurves(); + if ( summaryCurves.size() == sumCases.size() ) + { + for ( size_t i = 0; i < summaryCurves.size(); i++ ) + { + auto sumCase = sumCases[i]; + summaryCurves[i]->setSummaryCaseY( sumCase ); + } + } + + plotColl->updateConnectedEditors(); + + newSummaryPlot->loadDataAndUpdate(); + } + } + } + + { + auto wellPaths = selectedWellPaths(); + if ( wellPaths.size() == 2 ) + { + QString fileName = "d:/projects/ri-plot-templates/one_well_two_cases.rpt"; + RimSummaryPlot* newSummaryPlot = createPlotFromTemplateFile( fileName ); + if ( newSummaryPlot ) + { + RimSummaryPlotCollection* plotColl = RiaSummaryTools::summaryPlotCollection(); + + plotColl->summaryPlots.push_back( newSummaryPlot ); + + // Resolve references after object has been inserted into the data model + newSummaryPlot->resolveReferencesRecursively(); + newSummaryPlot->initAfterReadRecursively(); + + QString nameOfCopy = QString( "Copy of " ) + newSummaryPlot->description(); + newSummaryPlot->setDescription( nameOfCopy ); + + auto summaryCurves = newSummaryPlot->summaryCurves(); + if ( summaryCurves.size() == wellPaths.size() ) + { + for ( size_t i = 0; i < summaryCurves.size(); i++ ) + { + auto wellPath = wellPaths[i]; + + summaryCurves[i]->summaryAddressY().setWellName( wellPath->name().toStdString() ); + } + } + + plotColl->updateConnectedEditors(); + + newSummaryPlot->loadDataAndUpdate(); + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicCreatePlotFromSelectionFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setText( "Create Plot from Template" ); + // actionToSetup->setIcon( QIcon( ":/SummaryPlotLight16x16.png" ) ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryPlot* RicCreatePlotFromSelectionFeature::createPlotFromTemplateFile( const QString& fileName ) const +{ + QFile importFile( fileName ); + if ( !importFile.open( QIODevice::ReadOnly | QIODevice::Text ) ) + { + RiaLogging::error( QString( "Create Plot from Template : Could not open the file: %1" ).arg( fileName ) ); + return nullptr; + } + + QTextStream stream( &importFile ); + + QString objectAsText = stream.readAll(); + + caf::PdmObjectHandle* obj = + caf::PdmXmlObjectHandle::readUnknownObjectFromXmlString( objectAsText, caf::PdmDefaultObjectFactory::instance() ); + + RimSummaryPlot* newSummaryPlot = dynamic_cast( obj ); + if ( newSummaryPlot ) + { + return newSummaryPlot; + } + else + { + delete obj; + } + + return nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RicCreatePlotFromSelectionFeature::selectedSummaryCases() const +{ + std::vector objects; + caf::SelectionManager::instance()->objectsByType( &objects ); + + return objects; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RicCreatePlotFromSelectionFeature::selectedWellPaths() const +{ + std::vector objects; + caf::SelectionManager::instance()->objectsByType( &objects ); + + return objects; +} diff --git a/ApplicationCode/Commands/PlotTemplateCommands/RicCreatePlotFromSelectionFeature.h b/ApplicationCode/Commands/PlotTemplateCommands/RicCreatePlotFromSelectionFeature.h new file mode 100644 index 0000000000..5d320b750b --- /dev/null +++ b/ApplicationCode/Commands/PlotTemplateCommands/RicCreatePlotFromSelectionFeature.h @@ -0,0 +1,47 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 "cafCmdFeature.h" + +class RimSummaryCase; +class RimWellPath; + +//================================================================================================== +/// +//================================================================================================== +class RicCreatePlotFromSelectionFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +public: + RicCreatePlotFromSelectionFeature(); + +protected: + bool isCommandEnabled() override; + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; + +private: + RimSummaryPlot* createPlotFromTemplateFile( const QString& fileName ) const; + +private: + std::vector selectedSummaryCases() const; + std::vector selectedWellPaths() const; +}; diff --git a/ApplicationCode/Commands/PlotTemplateCommands/RicSavePlotTemplateFeature.cpp b/ApplicationCode/Commands/PlotTemplateCommands/RicSavePlotTemplateFeature.cpp new file mode 100644 index 0000000000..aa998d8df1 --- /dev/null +++ b/ApplicationCode/Commands/PlotTemplateCommands/RicSavePlotTemplateFeature.cpp @@ -0,0 +1,112 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 "RiaGuiApplication.h" +#include "RiaSummaryTools.h" + +#include "RicSavePlotTemplateFeature.h" + +#include "RimProject.h" +#include "RimSummaryPlot.h" + +#include "cafPdmObject.h" +#include "cafSelectionManager.h" + +#include +#include + +CAF_CMD_SOURCE_INIT( RicSavePlotTemplateFeature, "RicSavePlotTemplateFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicSavePlotTemplateFeature::RicSavePlotTemplateFeature() {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicSavePlotTemplateFeature::isCommandEnabled() +{ + if ( selectedSummaryPlot() ) return true; + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSavePlotTemplateFeature::onActionTriggered( bool isChecked ) +{ + RiaGuiApplication* app = RiaGuiApplication::instance(); + + QString startPath; + if ( !app->project()->fileName().isEmpty() ) + { + startPath = app->project()->fileName(); + startPath = startPath.replace( QString( ".rsp" ), QString( ".rpt" ) ); + } + else + { + startPath = app->lastUsedDialogDirectory( "PLOT_TEMPLATE" ); + startPath += "/ri-plot-template.rpt"; + } + + QString fileName = QFileDialog::getSaveFileName( nullptr, + tr( "Save Plot Template To File" ), + startPath, + tr( "Plot Template Files (*.rpt);;All files(*.*)" ) ); + if ( !fileName.isEmpty() ) + { + auto objectAsText = selectedSummaryPlot()->writeObjectToXmlString(); + + 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; + } + + QTextStream stream( &exportFile ); + stream << objectAsText; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSavePlotTemplateFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setText( "Save As Plot Template" ); + // actionToSetup->setIcon( QIcon( ":/SummaryPlotLight16x16.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/ApplicationCode/Commands/PlotTemplateCommands/RicSavePlotTemplateFeature.h b/ApplicationCode/Commands/PlotTemplateCommands/RicSavePlotTemplateFeature.h new file mode 100644 index 0000000000..293df505d1 --- /dev/null +++ b/ApplicationCode/Commands/PlotTemplateCommands/RicSavePlotTemplateFeature.h @@ -0,0 +1,42 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 "cafCmdFeature.h" + +class RimSummaryPlot; + +//================================================================================================== +/// +//================================================================================================== +class RicSavePlotTemplateFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +public: + RicSavePlotTemplateFeature(); + +protected: + bool isCommandEnabled() override; + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; + +private: + RimSummaryPlot* selectedSummaryPlot() const; +}; diff --git a/ApplicationCode/ProjectDataModel/PlotTemplates/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/PlotTemplates/CMakeLists_files.cmake new file mode 100644 index 0000000000..4fe667bdbb --- /dev/null +++ b/ApplicationCode/ProjectDataModel/PlotTemplates/CMakeLists_files.cmake @@ -0,0 +1,20 @@ + +set (SOURCE_GROUP_HEADER_FILES +${CMAKE_CURRENT_LIST_DIR}/RimPlotTemplateFolderItem.h +${CMAKE_CURRENT_LIST_DIR}/RimPlotTemplateFileItem.h +) + +set (SOURCE_GROUP_SOURCE_FILES +${CMAKE_CURRENT_LIST_DIR}/RimPlotTemplateFolderItem.cpp +${CMAKE_CURRENT_LIST_DIR}/RimPlotTemplateFileItem.cpp +) + +list(APPEND CODE_HEADER_FILES +${SOURCE_GROUP_HEADER_FILES} +) + +list(APPEND CODE_SOURCE_FILES +${SOURCE_GROUP_SOURCE_FILES} +) + +source_group( "ProjectDataModel\\PlotTemplates" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/ProjectDataModel/PlotTemplates/RimPlotTemplateFileItem.cpp b/ApplicationCode/ProjectDataModel/PlotTemplates/RimPlotTemplateFileItem.cpp new file mode 100644 index 0000000000..ecf2764eb6 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/PlotTemplates/RimPlotTemplateFileItem.cpp @@ -0,0 +1,65 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2011-2012 Statoil ASA, Ceetron 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 "RimPlotTemplateFileItem.h" + +#include "RiaApplication.h" +#include "RiaFieldHandleTools.h" +#include "RiaLogging.h" + +#include "cafPdmField.h" +#include "cafPdmUiFilePathEditor.h" + +#include + +CAF_PDM_SOURCE_INIT( RimPlotTemplateFileItem, "PlotTemplateFileItem" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimPlotTemplateFileItem::RimPlotTemplateFileItem() +{ + CAF_PDM_InitObject( "PlotTemplateFileItem", ":/OctaveScriptFile16x16.png", "Calc Script", "" ); + + CAF_PDM_InitField( &m_absoluteFileName, "AbsolutePath", QString(), "Location", "", "", "" ); + m_absoluteFileName.uiCapability()->setUiReadOnly( true ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimPlotTemplateFileItem::~RimPlotTemplateFileItem() {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotTemplateFileItem::setFilePath( const QString& filePath ) +{ + QFileInfo fi( filePath ); + this->uiCapability()->setUiName( fi.baseName() ); + + m_absoluteFileName = filePath; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimPlotTemplateFileItem::absoluteFilePath() const +{ + return m_absoluteFileName(); +} diff --git a/ApplicationCode/ProjectDataModel/PlotTemplates/RimPlotTemplateFileItem.h b/ApplicationCode/ProjectDataModel/PlotTemplates/RimPlotTemplateFileItem.h new file mode 100644 index 0000000000..6e5d59e15d --- /dev/null +++ b/ApplicationCode/ProjectDataModel/PlotTemplates/RimPlotTemplateFileItem.h @@ -0,0 +1,41 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2011-2012 Statoil ASA, Ceetron 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 "cafPdmField.h" +#include "cafPdmObject.h" + +//================================================================================================== +/// +/// +//================================================================================================== +class RimPlotTemplateFileItem : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimPlotTemplateFileItem(); + ~RimPlotTemplateFileItem() override; + + void setFilePath( const QString& filePath ); + QString absoluteFilePath() const; + +private: + caf::PdmField m_absoluteFileName; +}; diff --git a/ApplicationCode/ProjectDataModel/PlotTemplates/RimPlotTemplateFolderItem.cpp b/ApplicationCode/ProjectDataModel/PlotTemplates/RimPlotTemplateFolderItem.cpp new file mode 100644 index 0000000000..2061a4d15f --- /dev/null +++ b/ApplicationCode/ProjectDataModel/PlotTemplates/RimPlotTemplateFolderItem.cpp @@ -0,0 +1,200 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 "RimPlotTemplateFolderItem.h" + +#include "RiaApplication.h" +#include "RiaPreferences.h" + +#include "RimPlotTemplateFileItem.h" + +#include "cafPdmUiFilePathEditor.h" +#include "cafUtils.h" + +#include +#include + +CAF_PDM_SOURCE_INIT( RimPlotTemplateFolderItem, "PlotTemplateCollection" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimPlotTemplateFolderItem::RimPlotTemplateFolderItem() +{ + CAF_PDM_InitObject( "PlotTemplateCollection", ":/Folder.png", "", "" ); + + CAF_PDM_InitFieldNoDefault( &m_folderName, "FolderName", "Folder", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_fileNames, "FileNames", "", "", "", "" ); + m_fileNames.uiCapability()->setUiHidden( true ); + CAF_PDM_InitFieldNoDefault( &m_subFolders, "SubFolders", "", "", "", "" ); + m_subFolders.uiCapability()->setUiHidden( true ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimPlotTemplateFolderItem::~RimPlotTemplateFolderItem() {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotTemplateFolderItem::createRootFolderItemsFromFolderPaths( const QStringList& folderPaths ) +{ + createSubFolderItemsFromFolderPaths( folderPaths ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimPlotTemplateFolderItem::fileNames() const +{ + return m_fileNames.childObjects(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimPlotTemplateFolderItem::subFolders() const +{ + return m_subFolders.childObjects(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotTemplateFolderItem::setFolderPath( const QString& path ) +{ + m_folderName.v().setPath( path ); + + QFileInfo fi( path ); + this->uiCapability()->setUiName( fi.baseName() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotTemplateFolderItem::searchForFileAndFolderNames() +{ + m_fileNames.deleteAllChildObjects(); + m_subFolders.deleteAllChildObjects(); + + if ( m_folderName().path().isEmpty() ) + { + for ( size_t i = 0; i < m_subFolders.size(); ++i ) + { + if ( m_subFolders[i] ) m_subFolders[i]->searchForFileAndFolderNames(); + } + return; + } + + QDir myDir( this->m_folderName().path() ); + if ( !myDir.isReadable() ) + { + return; + } + + // Build a list of all scripts in the specified directory + { + QStringList nameFilters; + nameFilters << "*.rpt"; + QStringList fileList = caf::Utils::getFilesInDirectory( m_folderName().path(), nameFilters, true ); + + for ( int i = 0; i < fileList.size(); i++ ) + { + const QString& fileName = fileList.at( i ); + + if ( caf::Utils::fileExists( fileName ) ) + { + RimPlotTemplateFileItem* fileItem = new RimPlotTemplateFileItem(); + fileItem->setFilePath( fileName ); + m_fileNames.push_back( fileItem ); + } + } + } + + if ( searchSubFoldersRecursively() ) + { + QStringList folderPaths; + + QDir dir( m_folderName().path() ); + QFileInfoList fileInfoList = dir.entryInfoList( QDir::AllDirs | QDir::NoDotAndDotDot | QDir::Readable ); + + for ( const auto& fi : fileInfoList ) + { + 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(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotTemplateFolderItem::defineEditorAttribute( const caf::PdmFieldHandle* field, + QString uiConfigName, + caf::PdmUiEditorAttribute* attribute ) +{ + if ( field == &m_folderName ) + { + caf::PdmUiFilePathEditorAttribute* myAttr = dynamic_cast( attribute ); + if ( myAttr ) + { + myAttr->m_selectDirectory = true; + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotTemplateFolderItem::createSubFolderItemsFromFolderPaths( const QStringList& folderPaths ) +{ + for ( const auto& path : folderPaths ) + { + RimPlotTemplateFolderItem* scriptLocation = new RimPlotTemplateFolderItem(); + scriptLocation->setFolderPath( path ); + scriptLocation->searchForFileAndFolderNames(); + + m_subFolders.push_back( scriptLocation ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimPlotTemplateFolderItem::searchSubFoldersRecursively() const +{ + return RiaApplication::instance()->preferences()->searchPlotTemplateFoldersRecursively(); +} diff --git a/ApplicationCode/ProjectDataModel/PlotTemplates/RimPlotTemplateFolderItem.h b/ApplicationCode/ProjectDataModel/PlotTemplates/RimPlotTemplateFolderItem.h new file mode 100644 index 0000000000..ee81d0867d --- /dev/null +++ b/ApplicationCode/ProjectDataModel/PlotTemplates/RimPlotTemplateFolderItem.h @@ -0,0 +1,67 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 "cafPdmChildArrayField.h" +#include "cafPdmField.h" +#include "cafPdmObject.h" + +namespace caf +{ +class PdmUiEditorAttribute; +} + +class RimPlotTemplateFileItem; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimPlotTemplateFolderItem : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimPlotTemplateFolderItem(); + ~RimPlotTemplateFolderItem() override; + + void createRootFolderItemsFromFolderPaths( const QStringList& folderPaths ); + + std::vector fileNames() const; + std::vector subFolders() const; + +private: + void searchForFileAndFolderNames(); + void setFolderPath( const QString& path ); + void createSubFolderItemsFromFolderPaths( const QStringList& folderPaths ); + + 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; + +private: + caf::PdmField m_folderName; + caf::PdmChildArrayField m_fileNames; + caf::PdmChildArrayField m_subFolders; +}; diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index d96bbe03f6..786ecfc5be 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -550,6 +550,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "Separator"; menuBuilder << "RicShowSummaryCurveCalculatorFeature"; menuBuilder << "Separator"; + menuBuilder << "RicSavePlotTemplateFeature"; + menuBuilder << "Separator"; // Export is not supported for cross plot if ( !summaryCrossPlot ) menuBuilder << "RicAsciiExportSummaryPlotFeature"; @@ -843,6 +845,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicDeleteSummaryCaseCollectionFeature"; menuBuilder << "RicCloseObservedDataFeature"; + menuBuilder << "RicCreatePlotFromSelectionFeature"; + // Work in progress -- End appendCreateCompletions( menuBuilder, menuBuilder.itemCount() > 0u ); bool addedExportWellPaths = appendExportWellPaths( menuBuilder, menuBuilder.itemCount() > 0u ) > 0; @@ -1186,4 +1190,4 @@ int RimContextCommandBuilder::appendSubMenuWithCommands( caf::CmdFeatureMenuBuil menuBuilder.subMenuEnd(); } return actualCommandsAdded; -} \ No newline at end of file +} diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index 9b8bf16e97..9966db6089 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -30,6 +30,7 @@ #include "RigEclipseCaseData.h" #include "RigGridBase.h" +#include "PlotTemplates/RimPlotTemplateFolderItem.h" #include "RimAdvancedSnapshotExportDefinition.h" #include "RimAnnotationCollection.h" #include "RimAnnotationInViewCollection.h" @@ -191,6 +192,10 @@ RimProject::RimProject( void ) mainPlotCollection = new RimMainPlotCollection(); + CAF_PDM_InitFieldNoDefault( &m_plotTemplateFolderItem, "PlotTemplateCollection", "Plot Templates", "", "", "" ); + m_plotTemplateFolderItem = new RimPlotTemplateFolderItem(); + m_plotTemplateFolderItem.xmlCapability()->disableIO(); + // For now, create a default first oilfield that contains the rest of the project oilFields.push_back( new RimOilField ); @@ -353,6 +358,17 @@ void RimProject::setScriptDirectories( const QString& scriptDirectories ) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimProject::setPlotTemplateFolders( const QStringList& plotTemplateFolders ) +{ + if ( m_plotTemplateFolderItem() ) delete m_plotTemplateFolderItem(); + m_plotTemplateFolderItem = new RimPlotTemplateFolderItem(); + + m_plotTemplateFolderItem->createRootFolderItemsFromFolderPaths( plotTemplateFolders ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1155,6 +1171,14 @@ RimMeasurement* RimProject::measurement() const return activeOilField()->measurement; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimPlotTemplateFolderItem* RimProject::rootPlotTemlateItem() const +{ + return m_plotTemplateFolderItem; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1237,6 +1261,8 @@ void RimProject::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, Q itemCollection->add( mainPlotCollection->saturationPressurePlotCollection() ); } } + + uiTreeOrdering.add( m_plotTemplateFolderItem() ); } else { diff --git a/ApplicationCode/ProjectDataModel/RimProject.h b/ApplicationCode/ProjectDataModel/RimProject.h index 3bfae89c46..1b256f4e63 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.h +++ b/ApplicationCode/ProjectDataModel/RimProject.h @@ -66,6 +66,7 @@ class RimFractureTemplate; class RimValveTemplateCollection; class RimValveTemplate; class RimCompletionTemplateCollection; +class RimPlotTemplateFolderItem; namespace caf { @@ -104,6 +105,7 @@ public: caf::PdmField plotWindowCurrentModelIndexPath; void setScriptDirectories( const QString& scriptDirectories ); + void setPlotTemplateFolders( const QStringList& plotTemplateFolders ); QString projectFileVersionString() const; bool isProjectFileVersionEqualOrOlderThan( const QString& otherProjectFileVersion ) const; @@ -172,6 +174,8 @@ public: RiaEclipseUnitTools::UnitSystemType commonUnitSystemForAllCases() const; RimMeasurement* measurement() const; + RimPlotTemplateFolderItem* rootPlotTemlateItem() const; + protected: // Overridden methods void initAfterRead() override; @@ -186,7 +190,8 @@ private: private: caf::PdmField m_projectFileVersionString; - caf::PdmChildField m_dialogData; + caf::PdmChildField m_dialogData; + caf::PdmChildField m_plotTemplateFolderItem; caf::PdmField m_show3DWindow; caf::PdmField m_showPlotWindow; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index 5526060cee..76fcc4fc0e 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -25,6 +25,8 @@ #include "SummaryPlotCommands/RicSummaryCurveCreator.h" +#include "PlotTemplates/RimPlotTemplateFileItem.h" +#include "PlotTemplates/RimPlotTemplateFolderItem.h" #include "RimAsciiDataCurve.h" #include "RimEnsembleCurveSet.h" #include "RimEnsembleCurveSetCollection.h" @@ -194,6 +196,8 @@ RimSummaryPlot::RimSummaryPlot() CAF_PDM_InitField( &m_isAutoZoom_OBSOLETE, "AutoZoom", true, "Auto Zoom", "", "", "" ); RiaFieldhandleTools::disableWriteAndSetFieldHidden( &m_isAutoZoom_OBSOLETE ); + CAF_PDM_InitFieldNoDefault( &m_plotTemplate, "PlotTemplate", "Template", "", "", "" ); + m_isCrossPlot = false; m_nameHelperAllCurves.reset( new RimSummaryPlotNameHelper ); @@ -1234,6 +1238,27 @@ QList RimSummaryPlot::calculateValueOptions( const caf:: options.push_back( caf::PdmOptionItemInfo( text, value ) ); } } + else if ( fieldNeedingOptions == &m_plotTemplate ) + { + options.push_back( caf::PdmOptionItemInfo( "None", nullptr ) ); + + auto rootPlotTemplate = RiaApplication::instance()->project()->rootPlotTemlateItem(); + if ( rootPlotTemplate ) + { + std::vector allTemplates; + { + RimPlotTemplateFileItem fileItem; + rootPlotTemplate->descendantsIncludingThisFromClassKeyword( fileItem.classKeyword(), allTemplates ); + } + + for ( auto t : allTemplates ) + { + caf::PdmOptionItemInfo optionItem( t->uiName(), t ); + options.push_back( optionItem ); + } + } + } + return options; } @@ -1552,6 +1577,8 @@ void RimSummaryPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& m_userDefinedPlotTitle.uiCapability()->setUiReadOnly( m_useAutoPlotTitle ); + uiOrdering.add( &m_plotTemplate ); + uiOrdering.skipRemainingFields( true ); } @@ -1842,6 +1869,22 @@ void RimSummaryPlot::showLegend( bool enable ) m_showLegend = enable; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlot::setPlotTemplate( RimPlotTemplateFileItem* plotTemplate ) +{ + m_plotTemplate = plotTemplate; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimPlotTemplateFileItem* RimSummaryPlot::plotTemplate() const +{ + return m_plotTemplate(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h index e165d1a189..967e904fc1 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h @@ -18,8 +18,6 @@ #pragma once -#include "cafPdmChildArrayField.h" - #include "RiaDefines.h" #include "RiaQDateTimeTools.h" #include "RiaSummaryCurveDefinition.h" @@ -30,6 +28,10 @@ #include "RimViewWindow.h" #include "qwt_plot_textlabel.h" + +#include "cafPdmChildArrayField.h" +#include "cafPdmPtrField.h" + #include #include @@ -49,6 +51,7 @@ class RimPlotAxisPropertiesInterface; class RimPlotAxisProperties; class RiuSummaryQwtPlot; class RimSummaryPlotNameHelper; +class RimPlotTemplateFileItem; class QwtInterval; class QwtPlotCurve; @@ -145,6 +148,9 @@ public: bool isNormalizationEnabled(); void showLegend( bool enable ); + void setPlotTemplate( RimPlotTemplateFileItem* plotTemplate ); + RimPlotTemplateFileItem* plotTemplate() const; + public: // Rim2dPlotInterface overrides void updateAxisScaling() override; @@ -223,6 +229,8 @@ private: caf::PdmChildField m_bottomAxisProperties; caf::PdmChildField m_timeAxisProperties; + caf::PdmPtrField m_plotTemplate; + QPointer m_qwtPlot; std::unique_ptr m_plotInfoLabel; From fe4fe36ee9b6707af2ddbc3622aa6cc7a9bbefec Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 9 Sep 2019 12:52:23 +0200 Subject: [PATCH 4/6] Refactor : Split calculateValueOptions to separate helper functions --- .../RiuSummaryCurveDefSelection.cpp | 470 +++++++++--------- .../RiuSummaryCurveDefSelection.h | 16 +- 2 files changed, 256 insertions(+), 230 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp index 0778f91d8a..8fb0ed37f5 100644 --- a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp +++ b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp @@ -667,7 +667,7 @@ void RiuSummaryCurveDefSelection::setSelectedCurveDefinitions( const std::vector //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::set RiuSummaryCurveDefSelection::findPossibleSummaryAddressesFromCalculated() +std::set RiuSummaryCurveDefSelection::findPossibleSummaryAddressesFromCalculated() const { std::set addressSet; @@ -740,230 +740,17 @@ QList if ( fieldNeedingOptions == &m_selectedSources ) { - RimProject* proj = RiaApplication::instance()->project(); - std::vector oilFields; - - proj->allOilFields( oilFields ); - for ( RimOilField* oilField : oilFields ) - { - RimSummaryCaseMainCollection* sumCaseMainColl = oilField->summaryCaseMainCollection(); - if ( sumCaseMainColl ) - { - if ( !m_hideSummaryCases ) - { - // Top level cases - for ( const auto& sumCase : sumCaseMainColl->topLevelSummaryCases() ) - { - options.push_back( caf::PdmOptionItemInfo( sumCase->caseName(), 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; - } - - auto optionItem = caf::PdmOptionItemInfo( sumCaseColl->name(), sumCaseColl ); - optionItem.setLevel( 1 ); - 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->caseName(), 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 ); - } - } - } - } - } + appendOptionItemsForSources( options ); } else if ( fieldNeedingOptions == &m_selectedSummaryCategories ) { - std::vector sortedCategoriesForUi; - - sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_FIELD ); - sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_AQUIFER ); - sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_NETWORK ); - sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_MISC ); - sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_REGION ); - sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_REGION_2_REGION ); - sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL_GROUP ); - sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL ); - sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL_COMPLETION ); - sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL_SEGMENT ); - sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_BLOCK ); - sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL_LGR ); - sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL_COMPLETION_LGR ); - sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_BLOCK_LGR ); - sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_CALCULATED ); - sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_IMPORTED ); - // NB SUMMARY_ENSEMBLE_STATISTICS is intentionally excluded - // categoriesForUiDisplay.push_back(RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_ENSEMBLE_STATISTICS); - - for ( auto category : sortedCategoriesForUi ) - { - auto uiText = caf::AppEnum::uiText( category ); - options.push_back( caf::PdmOptionItemInfo( uiText, category ) ); - } + appendOptionItemsForCategories( options ); } - else + else if ( fieldNeedingOptions == &m_currentSummaryCategory ) { // Lookup item type input field auto identifierAndField = lookupIdentifierAndFieldFromFieldHandle( fieldNeedingOptions ); - if ( identifierAndField != nullptr ) - { - enum - { - SUM_CASES, - OBS_DATA, - CALCULATED_CURVES - }; - - const int itemCount = CALCULATED_CURVES + 1; - - std::set addrUnion[itemCount]; - addrUnion[SUM_CASES] = findPossibleSummaryAddressesFromSelectedCases( identifierAndField ); - addrUnion[OBS_DATA] = findPossibleSummaryAddressesFromSelectedObservedData( identifierAndField ); - addrUnion[CALCULATED_CURVES] = findPossibleSummaryAddressesFromCalculated(); - - std::set itemNames[itemCount]; - for ( int i = 0; i < itemCount; i++ ) - { - for ( const auto& address : addrUnion[i] ) - { - if ( address.isErrorResult() ) continue; - - auto name = address.uiText( identifierAndField->summaryIdentifier() ); - if ( name.size() > 0 ) - { - itemNames[i].insert( name ); - } - } - } - - bool isVectorField = identifierAndField->summaryIdentifier() == RifEclipseSummaryAddress::INPUT_VECTOR_NAME; - - // Merge sets for all other fields than vector fields - if ( !isVectorField ) - { - itemNames[SUM_CASES].insert( itemNames[OBS_DATA].begin(), itemNames[OBS_DATA].end() ); - itemNames[OBS_DATA].clear(); - } - - for ( int i = 0; i < itemCount; i++ ) - { - // Create headers only for vector fields when observed data is selected - bool hasObservedData = itemNames[OBS_DATA].size() > 0; - bool groupItems = isVectorField && hasObservedData; - if ( groupItems ) - { - QString headerText; - if ( i == SUM_CASES ) - { - headerText = QString( "Simulated Data" ); - } - else if ( i == OBS_DATA ) - { - headerText = QString( "Observed Data" ); - } - else if ( i == CALCULATED_CURVES ) - { - headerText = QString( "Calculated" ); - } - - if ( !headerText.isEmpty() ) - { - options.push_back( caf::PdmOptionItemInfo::createHeader( headerText, true ) ); - } - } - - auto itemPostfix = ( isVectorField && i == OBS_DATA ) ? QString( OBSERVED_DATA_AVALUE_POSTFIX ) - : QString( "" ); - - // Sort numeric identifiers by numeric val - std::vector itemNamesVector; - { - switch ( identifierAndField->summaryIdentifier() ) - { - case RifEclipseSummaryAddress::INPUT_REGION_NUMBER: - case RifEclipseSummaryAddress::INPUT_SEGMENT_NUMBER: - case RifEclipseSummaryAddress::INPUT_AQUIFER_NUMBER: - { - std::set values; - for ( const std::string& itemName : itemNames[i] ) - { - values.insert( RiaStdStringTools::toInt( itemName ) ); - } - for ( int v : values ) - { - itemNamesVector.push_back( std::to_string( v ) ); - } - break; - } - default: - itemNamesVector.insert( itemNamesVector.end(), itemNames[i].begin(), itemNames[i].end() ); - break; - } - } - - for ( const auto& itemName : itemNamesVector ) - { - QString displayName; - - if ( isVectorField ) - { - std::string longVectorName = RiuSummaryVectorDescriptionMap::instance()->vectorLongName( itemName, - true ); - displayName = QString::fromStdString( longVectorName ); - displayName += QString( " (%1)" ).arg( QString::fromStdString( itemName ) ); - } - else - { - displayName = QString::fromStdString( itemName ); - } - - auto optionItem = caf::PdmOptionItemInfo( displayName, - QString::fromStdString( itemName ) + itemPostfix ); - if ( groupItems ) optionItem.setLevel( 1 ); - options.push_back( optionItem ); - } - } - } + appendOptionItemsForSubCategoriesAndVectors( options, identifierAndField ); } return options; @@ -1130,10 +917,10 @@ void RiuSummaryCurveDefSelection::defineUiOrdering( QString uiConfigName, caf::P /// //-------------------------------------------------------------------------------------------------- std::set RiuSummaryCurveDefSelection::findPossibleSummaryAddressesFromSelectedCases( - const SummaryIdentifierAndField* identifierAndField ) + const SummaryIdentifierAndField* identifierAndField ) const { std::vector sources; - for ( const auto& source : m_selectedSources() ) + for ( const auto& source : m_selectedSources.value() ) { RimSummaryCase* sumCase = dynamic_cast( source.p() ); RimSummaryCaseCollection* ensemble = dynamic_cast( source.p() ); @@ -1154,10 +941,10 @@ std::set RiuSummaryCurveDefSelection::findPossibleSumm /// //-------------------------------------------------------------------------------------------------- std::set RiuSummaryCurveDefSelection::findPossibleSummaryAddressesFromSelectedObservedData( - const SummaryIdentifierAndField* identifierAndField ) + const SummaryIdentifierAndField* identifierAndField ) const { std::vector obsData; - for ( const auto& source : m_selectedSources() ) + for ( const auto& source : m_selectedSources.value() ) { RimSummaryCase* sumCase = dynamic_cast( source.p() ); @@ -1172,9 +959,8 @@ std::set RiuSummaryCurveDefSelection::findPossibleSumm //-------------------------------------------------------------------------------------------------- /// Returns the summary addresses that match the selected item type and input selections made in GUI //-------------------------------------------------------------------------------------------------- -std::set - RiuSummaryCurveDefSelection::findPossibleSummaryAddresses( const std::vector& selectedSources, - const SummaryIdentifierAndField* identifierAndField ) +std::set RiuSummaryCurveDefSelection::findPossibleSummaryAddresses( + const std::vector& selectedSources, const SummaryIdentifierAndField* identifierAndField ) const { std::set addrUnion; @@ -1458,3 +1244,237 @@ RimSummaryCase* RiuSummaryCurveDefSelection::calculatedSummaryCase() return calcColl->calculationSummaryCase(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuSummaryCurveDefSelection::appendOptionItemsForSources( QList& options ) const +{ + RimProject* proj = RiaApplication::instance()->project(); + std::vector oilFields; + + proj->allOilFields( oilFields ); + for ( RimOilField* oilField : oilFields ) + { + RimSummaryCaseMainCollection* sumCaseMainColl = oilField->summaryCaseMainCollection(); + if ( sumCaseMainColl ) + { + if ( !m_hideSummaryCases ) + { + // Top level cases + for ( const auto& sumCase : sumCaseMainColl->topLevelSummaryCases() ) + { + options.push_back( caf::PdmOptionItemInfo( sumCase->caseName(), 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; + } + + auto optionItem = caf::PdmOptionItemInfo( sumCaseColl->name(), sumCaseColl ); + optionItem.setLevel( 1 ); + 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->caseName(), 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 ); + } + } + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuSummaryCurveDefSelection::appendOptionItemsForCategories( QList& options ) const +{ + std::vector sortedCategoriesForUi; + + sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_FIELD ); + sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_AQUIFER ); + sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_NETWORK ); + sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_MISC ); + sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_REGION ); + sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_REGION_2_REGION ); + sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL_GROUP ); + sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL ); + sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL_COMPLETION ); + sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL_SEGMENT ); + sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_BLOCK ); + sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL_LGR ); + sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL_COMPLETION_LGR ); + sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_BLOCK_LGR ); + sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_CALCULATED ); + sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_IMPORTED ); + // NB SUMMARY_ENSEMBLE_STATISTICS is intentionally excluded + // categoriesForUiDisplay.push_back(RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_ENSEMBLE_STATISTICS); + + for ( auto category : sortedCategoriesForUi ) + { + auto uiText = caf::AppEnum::uiText( category ); + options.push_back( caf::PdmOptionItemInfo( uiText, category ) ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuSummaryCurveDefSelection::appendOptionItemsForSubCategoriesAndVectors( + QList& options, SummaryIdentifierAndField* identifierAndField ) const +{ + if ( identifierAndField == nullptr ) return; + + enum + { + SUM_CASES, + OBS_DATA, + CALCULATED_CURVES + }; + + const int itemCount = CALCULATED_CURVES + 1; + + std::set addrUnion[itemCount]; + addrUnion[SUM_CASES] = findPossibleSummaryAddressesFromSelectedCases( identifierAndField ); + addrUnion[OBS_DATA] = findPossibleSummaryAddressesFromSelectedObservedData( identifierAndField ); + addrUnion[CALCULATED_CURVES] = findPossibleSummaryAddressesFromCalculated(); + + std::set itemNames[itemCount]; + for ( int i = 0; i < itemCount; i++ ) + { + for ( const auto& address : addrUnion[i] ) + { + if ( address.isErrorResult() ) continue; + + auto name = address.uiText( identifierAndField->summaryIdentifier() ); + if ( name.size() > 0 ) + { + itemNames[i].insert( name ); + } + } + } + + bool isVectorField = identifierAndField->summaryIdentifier() == RifEclipseSummaryAddress::INPUT_VECTOR_NAME; + + // Merge sets for all other fields than vector fields + if ( !isVectorField ) + { + itemNames[SUM_CASES].insert( itemNames[OBS_DATA].begin(), itemNames[OBS_DATA].end() ); + itemNames[OBS_DATA].clear(); + } + + for ( int i = 0; i < itemCount; i++ ) + { + // Create headers only for vector fields when observed data is selected + bool hasObservedData = itemNames[OBS_DATA].size() > 0; + bool groupItems = isVectorField && hasObservedData; + if ( groupItems ) + { + QString headerText; + if ( i == SUM_CASES ) + { + headerText = QString( "Simulated Data" ); + } + else if ( i == OBS_DATA ) + { + headerText = QString( "Observed Data" ); + } + else if ( i == CALCULATED_CURVES ) + { + headerText = QString( "Calculated" ); + } + + if ( !headerText.isEmpty() ) + { + options.push_back( caf::PdmOptionItemInfo::createHeader( headerText, true ) ); + } + } + + auto itemPostfix = ( isVectorField && i == OBS_DATA ) ? QString( OBSERVED_DATA_AVALUE_POSTFIX ) : QString( "" ); + + // Sort numeric identifiers by numeric val + std::vector itemNamesVector; + { + switch ( identifierAndField->summaryIdentifier() ) + { + case RifEclipseSummaryAddress::INPUT_REGION_NUMBER: + case RifEclipseSummaryAddress::INPUT_SEGMENT_NUMBER: + case RifEclipseSummaryAddress::INPUT_AQUIFER_NUMBER: + { + std::set values; + for ( const std::string& itemName : itemNames[i] ) + { + values.insert( RiaStdStringTools::toInt( itemName ) ); + } + for ( int v : values ) + { + itemNamesVector.push_back( std::to_string( v ) ); + } + break; + } + default: + itemNamesVector.insert( itemNamesVector.end(), itemNames[i].begin(), itemNames[i].end() ); + break; + } + } + + for ( const auto& itemName : itemNamesVector ) + { + QString displayName; + + if ( isVectorField ) + { + std::string longVectorName = RiuSummaryVectorDescriptionMap::instance()->vectorLongName( itemName, true ); + displayName = QString::fromStdString( longVectorName ); + displayName += QString( " (%1)" ).arg( QString::fromStdString( itemName ) ); + } + else + { + displayName = QString::fromStdString( itemName ); + } + + auto optionItem = caf::PdmOptionItemInfo( displayName, QString::fromStdString( itemName ) + itemPostfix ); + if ( groupItems ) optionItem.setLevel( 1 ); + options.push_back( optionItem ); + } + } +} diff --git a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.h b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.h index 798f977a76..065aeb4175 100644 --- a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.h +++ b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.h @@ -76,13 +76,14 @@ private: QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; - std::set findPossibleSummaryAddresses( const std::vector& selectedSources, - const SummaryIdentifierAndField* identifierAndField ); std::set - findPossibleSummaryAddressesFromSelectedCases( const SummaryIdentifierAndField* identifierAndField ); + findPossibleSummaryAddresses( const std::vector& selectedSources, + const SummaryIdentifierAndField* identifierAndField ) const; std::set - findPossibleSummaryAddressesFromSelectedObservedData( const SummaryIdentifierAndField* identifierAndField ); - std::set findPossibleSummaryAddressesFromCalculated(); + findPossibleSummaryAddressesFromSelectedCases( const SummaryIdentifierAndField* identifierAndField ) const; + std::set + findPossibleSummaryAddressesFromSelectedObservedData( const SummaryIdentifierAndField* identifierAndField ) const; + std::set findPossibleSummaryAddressesFromCalculated() const; std::vector buildControllingFieldList( const SummaryIdentifierAndField* identifierAndField ) const; @@ -105,6 +106,11 @@ private: std::vector selectedSummarySources() const; static RimSummaryCase* calculatedSummaryCase(); + void appendOptionItemsForSources( QList& options ) const; + void appendOptionItemsForCategories( QList& options ) const; + void appendOptionItemsForSubCategoriesAndVectors( QList& options, + SummaryIdentifierAndField* identifierAndField ) const; + private: caf::PdmPtrArrayField m_selectedSources; From c7bbd141437497a2e3154f1b7ae11859e3b40141 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 11 Sep 2019 09:56:32 +0200 Subject: [PATCH 5/6] Add missing include --- .../Commands/PlotTemplateCommands/RicSavePlotTemplateFeature.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ApplicationCode/Commands/PlotTemplateCommands/RicSavePlotTemplateFeature.cpp b/ApplicationCode/Commands/PlotTemplateCommands/RicSavePlotTemplateFeature.cpp index aa998d8df1..a8b2b79091 100644 --- a/ApplicationCode/Commands/PlotTemplateCommands/RicSavePlotTemplateFeature.cpp +++ b/ApplicationCode/Commands/PlotTemplateCommands/RicSavePlotTemplateFeature.cpp @@ -17,6 +17,7 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RiaGuiApplication.h" +#include "RiaLogging.h" #include "RiaSummaryTools.h" #include "RicSavePlotTemplateFeature.h" From 0939b41120f11763cbf6e55f044f783a00a090e8 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 11 Sep 2019 09:56:32 +0200 Subject: [PATCH 6/6] Summary : Make sure field vectors are displayed --- ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp index 8fb0ed37f5..f31c96bac1 100644 --- a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp +++ b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp @@ -746,7 +746,7 @@ QList { appendOptionItemsForCategories( options ); } - else if ( fieldNeedingOptions == &m_currentSummaryCategory ) + else { // Lookup item type input field auto identifierAndField = lookupIdentifierAndFieldFromFieldHandle( fieldNeedingOptions );