From 860588d755e10929e7399474fd5263e9168894b5 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 14 Feb 2025 09:35:28 +0100 Subject: [PATCH] #12008 Improve display of curves from selected cells in 3D view * Remove obsolete base class * Add conversion between one/zero-based IJK * Move code to RiaTextStringTools * Add automatic update of grid cell curves when clicking in 3D view * Fix missing conversion to QString --- ApplicationExeCode/Resources/ResInsight.qrc | 1 + ApplicationExeCode/Resources/gear.svg | 6 + .../Application/Tools/RiaTextStringTools.cpp | 19 +++ .../Application/Tools/RiaTextStringTools.h | 2 + .../RicNewGridTimeHistoryCurveFeature.cpp | 45 +++--- .../RicNewGridTimeHistoryCurveFeature.h | 1 - .../FileInterface/RifReaderEclipseWell.cpp | 5 +- .../RimGeoMechGeometrySelectionItem.h | 7 +- .../ProjectDataModel/CMakeLists_files.cmake | 2 - .../RimEclipseGeometrySelectionItem.cpp | 88 ++++++++-- .../RimEclipseGeometrySelectionItem.h | 27 ++-- .../RimGeometrySelectionItem.cpp | 35 ---- .../RimGridTimeHistoryCurve.cpp | 153 ++++++++---------- .../RimGridTimeHistoryCurve.h | 15 +- .../ProjectDataModel/RimProject.cpp | 14 +- .../ProjectDataModel/RimProject.h | 3 + .../Summary/RimSummaryMultiPlotCollection.cpp | 7 +- .../Summary/RimSummaryNameHelper.cpp | 2 +- .../Tools/CMakeLists_files.cmake | 12 +- .../Tools/RimAutomationSettings.cpp | 65 +++----- .../RimAutomationSettings.h} | 25 ++- .../ReservoirDataModel/RigGridBase.cpp | 14 -- .../ReservoirDataModel/RigGridBase.h | 1 - .../UserInterface/RiuCellSelectionTool.cpp | 24 +-- .../UserInterface/RiuCellSelectionTool.h | 1 - .../RiuSelectionChangedHandler.cpp | 79 +++++++++ .../RiuSelectionChangedHandler.h | 2 + Fwk/AppFwk/CommonCode/cafVecIjk.cpp | 16 ++ Fwk/AppFwk/CommonCode/cafVecIjk.h | 3 + 29 files changed, 402 insertions(+), 272 deletions(-) create mode 100644 ApplicationExeCode/Resources/gear.svg delete mode 100644 ApplicationLibCode/ProjectDataModel/RimGeometrySelectionItem.cpp rename ApplicationLibCode/ProjectDataModel/{RimGeometrySelectionItem.h => Tools/RimAutomationSettings.h} (50%) diff --git a/ApplicationExeCode/Resources/ResInsight.qrc b/ApplicationExeCode/Resources/ResInsight.qrc index 170f9dd0fb..5c13fc23ba 100644 --- a/ApplicationExeCode/Resources/ResInsight.qrc +++ b/ApplicationExeCode/Resources/ResInsight.qrc @@ -298,6 +298,7 @@ Select.svg NavigationProperty.svg user-defined-view.svg + gear.svg fs_CellFace.glsl diff --git a/ApplicationExeCode/Resources/gear.svg b/ApplicationExeCode/Resources/gear.svg new file mode 100644 index 0000000000..9da2ad4cff --- /dev/null +++ b/ApplicationExeCode/Resources/gear.svg @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ApplicationLibCode/Application/Tools/RiaTextStringTools.cpp b/ApplicationLibCode/Application/Tools/RiaTextStringTools.cpp index de4f4a3a34..bc743e1232 100644 --- a/ApplicationLibCode/Application/Tools/RiaTextStringTools.cpp +++ b/ApplicationLibCode/Application/Tools/RiaTextStringTools.cpp @@ -206,6 +206,25 @@ bool RiaTextStringTools::isNumber( const QString& text, const QString& decimalPo return RiaStdStringTools::isNumber( stdString, decimalChar ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QVector RiaTextStringTools::parseDoubleValues( const QString& input ) +{ + // Flexible regex to extract three double numbers with any surrounding text + QRegularExpression coordRegex( R"([-+]?\d+\.?\d*)" ); + QRegularExpressionMatchIterator it = coordRegex.globalMatch( input ); + + QVector coords; + while ( it.hasNext() ) + { + QRegularExpressionMatch match = it.next(); + coords.append( match.captured().toDouble() ); + } + + return coords; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/Tools/RiaTextStringTools.h b/ApplicationLibCode/Application/Tools/RiaTextStringTools.h index 04f5a634db..84bfe25bf1 100644 --- a/ApplicationLibCode/Application/Tools/RiaTextStringTools.h +++ b/ApplicationLibCode/Application/Tools/RiaTextStringTools.h @@ -46,6 +46,8 @@ QString replaceTemplateTextWithValues( const QString& templateText, const std::m bool isTextEqual( QStringView text, QStringView compareText ); bool isNumber( const QString& text, const QString& decimalPoint ); +QVector parseDoubleValues( const QString& input ); + } // namespace RiaTextStringTools #if QT_VERSION < QT_VERSION_CHECK( 6, 8, 0 ) diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewGridTimeHistoryCurveFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewGridTimeHistoryCurveFeature.cpp index 70c197a7d2..0e4232055b 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewGridTimeHistoryCurveFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewGridTimeHistoryCurveFeature.cpp @@ -53,31 +53,6 @@ CAF_CMD_SOURCE_INIT( RicNewGridTimeHistoryCurveFeature, "RicNewGridTimeHistoryCurveFeature" ); -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicNewGridTimeHistoryCurveFeature::createCurveFromSelectionItem( const RiuSelectionItem* selectionItem, RimSummaryPlot* plot ) -{ - CVF_ASSERT( selectionItem ); - CVF_ASSERT( plot ); - - RimGridTimeHistoryCurve* newCurve = new RimGridTimeHistoryCurve(); - newCurve->setFromSelectionItem( selectionItem ); - newCurve->setLineThickness( 2 ); - - cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable( plot->curveCount() ); - newCurve->setColor( curveColor ); - - plot->addGridTimeHistoryCurve( newCurve ); - - newCurve->loadDataAndUpdate( true ); - - plot->updateConnectedEditors(); - - RiuPlotMainWindowTools::showPlotMainWindow(); - RiuPlotMainWindowTools::selectAsCurrentItem( newCurve ); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -92,10 +67,28 @@ RimSummaryPlot* RicNewGridTimeHistoryCurveFeature::userSelectedSummaryPlot() QString lastUsedPlotRef = app->cacheDataObject( lastUsedSummaryPlotKey ).toString(); RimSummaryPlot* lastUsedPlot = dynamic_cast( caf::PdmReferenceHelper::objectFromReference( app->project(), lastUsedPlotRef ) ); + if ( lastUsedPlot ) { defaultSelectedPlot = lastUsedPlot; } + else + { + auto getFirstSummaryPlot = []() -> RimSummaryPlot* + { + auto summaryPlotColl = RiaSummaryTools::summaryMultiPlotCollection(); + for ( auto multiPlot : summaryPlotColl->multiPlots() ) + { + for ( auto summaryPlot : multiPlot->summaryPlots() ) + { + return summaryPlot; + } + } + return nullptr; + }; + + defaultSelectedPlot = getFirstSummaryPlot(); + } } RicSelectSummaryPlotUI featureUi; @@ -250,7 +243,7 @@ void RicNewGridTimeHistoryCurveFeature::onActionTriggered( bool isChecked ) for ( auto item : items ) { - RicNewGridTimeHistoryCurveFeature::createCurveFromSelectionItem( item, summaryPlot ); + RimGridTimeHistoryCurve::createCurveFromSelectionItem( item, summaryPlot ); } } diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewGridTimeHistoryCurveFeature.h b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewGridTimeHistoryCurveFeature.h index f674f1d153..f4763067cb 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewGridTimeHistoryCurveFeature.h +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewGridTimeHistoryCurveFeature.h @@ -36,7 +36,6 @@ protected: void setupActionLook( QAction* actionToSetup ) override; private: - static void createCurveFromSelectionItem( const RiuSelectionItem* selectionItem, RimSummaryPlot* plot ); static RimSummaryPlot* userSelectedSummaryPlot(); static QString suggestedNewPlotName(); }; diff --git a/ApplicationLibCode/FileInterface/RifReaderEclipseWell.cpp b/ApplicationLibCode/FileInterface/RifReaderEclipseWell.cpp index 18e2850b62..6c39032823 100644 --- a/ApplicationLibCode/FileInterface/RifReaderEclipseWell.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderEclipseWell.cpp @@ -204,10 +204,9 @@ RigWellResultPoint RifReaderEclipseWell::createWellResultPoint( const RigEclipse resultPoint.setConnectionFactor( connectionFactor ); - auto ijkOneBased = grid->ijkFromCellIndexOneBased( gridCellIndex ); - if ( ijkOneBased ) + if ( auto ijk = grid->ijkFromCellIndex( gridCellIndex ) ) { - resultPoint.setIjk( *ijkOneBased ); + resultPoint.setIjk( ijk->toOneBased() ); } } diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RimGeoMechGeometrySelectionItem.h b/ApplicationLibCode/GeoMech/GeoMechDataModel/RimGeoMechGeometrySelectionItem.h index 979ab10306..876217bfe3 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RimGeoMechGeometrySelectionItem.h +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RimGeoMechGeometrySelectionItem.h @@ -18,10 +18,9 @@ #pragma once -#include "RimGeometrySelectionItem.h" - #include "cafPdmField.h" #include "cafPdmFieldCvfVec3d.h" +#include "cafPdmObject.h" #include "cafPdmPtrField.h" class RiuGeoMechSelectionItem; @@ -31,7 +30,7 @@ class RimGeoMechCase; /// /// //================================================================================================== -class RimGeoMechGeometrySelectionItem : public RimGeometrySelectionItem +class RimGeoMechGeometrySelectionItem : public caf::PdmObject { CAF_PDM_HEADER_INIT; @@ -41,7 +40,7 @@ public: void setFromSelectionItem( const RiuGeoMechSelectionItem* selectionItem ); - QString geometrySelectionText() const override; + QString geometrySelectionText() const; RimGeoMechCase* geoMechCase() const; public: diff --git a/ApplicationLibCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/CMakeLists_files.cmake index f690533fd8..0750eef7bc 100644 --- a/ApplicationLibCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationLibCode/ProjectDataModel/CMakeLists_files.cmake @@ -64,7 +64,6 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RimCheckableNamedObject.h ${CMAKE_CURRENT_LIST_DIR}/RimCheckableObject.h ${CMAKE_CURRENT_LIST_DIR}/RimGridTimeHistoryCurve.h - ${CMAKE_CURRENT_LIST_DIR}/RimGeometrySelectionItem.h ${CMAKE_CURRENT_LIST_DIR}/RimEclipseGeometrySelectionItem.h ${CMAKE_CURRENT_LIST_DIR}/RimDialogData.h ${CMAKE_CURRENT_LIST_DIR}/RimTimeStepFilter.h @@ -193,7 +192,6 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RimCheckableNamedObject.cpp ${CMAKE_CURRENT_LIST_DIR}/RimCheckableObject.cpp ${CMAKE_CURRENT_LIST_DIR}/RimGridTimeHistoryCurve.cpp - ${CMAKE_CURRENT_LIST_DIR}/RimGeometrySelectionItem.cpp ${CMAKE_CURRENT_LIST_DIR}/RimEclipseGeometrySelectionItem.cpp ${CMAKE_CURRENT_LIST_DIR}/RimDialogData.cpp ${CMAKE_CURRENT_LIST_DIR}/RimTimeStepFilter.cpp diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseGeometrySelectionItem.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseGeometrySelectionItem.cpp index e2b06c9b01..78eb66d2d9 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseGeometrySelectionItem.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseGeometrySelectionItem.cpp @@ -18,6 +18,8 @@ #include "RimEclipseGeometrySelectionItem.h" +#include "RiaTextStringTools.h" + #include "RigEclipseCaseData.h" #include "RigGridBase.h" #include "RigTimeHistoryResultAccessor.h" @@ -25,6 +27,7 @@ #include "RimEclipseCase.h" #include "RimEclipseResultDefinition.h" #include "RimEclipseView.h" +#include "RimTools.h" #include "Riu3dSelectionManager.h" @@ -40,7 +43,10 @@ RimEclipseGeometrySelectionItem::RimEclipseGeometrySelectionItem() 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_InitFieldNoDefault( &m_ijkText, "CellText", "IJK" ); + m_ijkText.registerGetMethod( this, &RimEclipseGeometrySelectionItem::ijkTextFromCell ); + m_ijkText.registerSetMethod( this, &RimEclipseGeometrySelectionItem::setCellFromIjkText ); } //-------------------------------------------------------------------------------------------------- @@ -55,9 +61,8 @@ RimEclipseGeometrySelectionItem::~RimEclipseGeometrySelectionItem() //-------------------------------------------------------------------------------------------------- void RimEclipseGeometrySelectionItem::setFromSelectionItem( const RiuEclipseSelectionItem* selectionItem ) { - m_gridIndex = selectionItem->m_gridIndex; - m_cellIndex = selectionItem->m_gridLocalCellIndex; - m_localIntersectionPointInDisplay = selectionItem->m_localIntersectionPointInDisplay; + m_gridIndex = selectionItem->m_gridIndex; + m_cellIndex = selectionItem->m_gridLocalCellIndex; m_eclipseCase = selectionItem->m_resultDefinition->eclipseCase(); } @@ -70,8 +75,8 @@ void RimEclipseGeometrySelectionItem::setFromCaseGridAndIJK( RimEclipseCase* ecl m_eclipseCase = eclipseCase; m_gridIndex = gridIndex; - size_t lgrCellIndex = eclipseCase->eclipseCaseData()->grid( gridIndex )->cellIndexFromIJK( i, j, k ); - size_t reservoirCellIndex = eclipseCase->eclipseCaseData()->grid( gridIndex )->reservoirCellIndex( lgrCellIndex ); + size_t localIndex = grid()->cellIndexFromIJK( i, j, k ); + size_t reservoirCellIndex = grid()->reservoirCellIndex( localIndex ); m_cellIndex = reservoirCellIndex; } @@ -126,17 +131,76 @@ size_t RimEclipseGeometrySelectionItem::cellIndex() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::Vec3st RimEclipseGeometrySelectionItem::cellIJK() const +void RimEclipseGeometrySelectionItem::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { - cvf::Vec3st IJK( -1, -1, -1 ); + uiOrdering.add( &m_ijkText ); + uiOrdering.add( &m_eclipseCase ); + uiOrdering.skipRemainingFields(); +} - if ( m_cellIndex != cvf::UNDEFINED_SIZE_T ) +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimEclipseGeometrySelectionItem::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) +{ + QList options; + + if ( fieldNeedingOptions == &m_eclipseCase ) { - if ( m_eclipseCase && m_eclipseCase->eclipseCaseData() && m_eclipseCase->eclipseCaseData()->grid( m_gridIndex ) ) + RimTools::caseOptionItems( &options ); + + options.push_front( caf::PdmOptionItemInfo( "None", nullptr ) ); + } + + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimEclipseGeometrySelectionItem::ijkTextFromCell() const +{ + if ( grid() ) + { + if ( auto zeroBased = grid()->ijkFromCellIndex( m_cellIndex ) ) { - m_eclipseCase->eclipseCaseData()->grid( m_gridIndex )->ijkFromCellIndex( m_cellIndex, &IJK[0], &IJK[1], &IJK[2] ); + auto oneBased = zeroBased->toOneBased(); + return QString( "%1 %2 %3" ).arg( oneBased.i() ).arg( oneBased.j() ).arg( oneBased.k() ); } } - return IJK; + return {}; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseGeometrySelectionItem::setCellFromIjkText( const QString& text ) +{ + auto values = RiaTextStringTools::parseDoubleValues( text ); + if ( values.size() >= 3 ) + { + int i = values[0] - 1; + int j = values[1] - 1; + int k = values[2] - 1; + + if ( grid() ) + { + size_t localIndex = grid()->cellIndexFromIJK( i, j, k ); + m_cellIndex = grid()->reservoirCellIndex( localIndex ); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigGridBase* RimEclipseGeometrySelectionItem::grid() const +{ + if ( m_eclipseCase && m_eclipseCase->eclipseCaseData() && m_eclipseCase->eclipseCaseData()->grid( m_gridIndex ) ) + { + return m_eclipseCase->eclipseCaseData()->grid( m_gridIndex ); + } + + return nullptr; } diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseGeometrySelectionItem.h b/ApplicationLibCode/ProjectDataModel/RimEclipseGeometrySelectionItem.h index 7b83085337..c04b3489d9 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseGeometrySelectionItem.h +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseGeometrySelectionItem.h @@ -18,20 +18,20 @@ #pragma once -#include "RimGeometrySelectionItem.h" - #include "cafPdmField.h" -#include "cafPdmFieldCvfVec3d.h" +#include "cafPdmObject.h" +#include "cafPdmProxyValueField.h" #include "cafPdmPtrField.h" class RimEclipseCase; class RiuEclipseSelectionItem; +class RigGridBase; //================================================================================================== /// /// //================================================================================================== -class RimEclipseGeometrySelectionItem : public RimGeometrySelectionItem +class RimEclipseGeometrySelectionItem : public caf::PdmObject { CAF_PDM_HEADER_INIT; @@ -41,17 +41,26 @@ public: void setFromSelectionItem( const RiuEclipseSelectionItem* selectionItem ); void setFromCaseGridAndIJK( RimEclipseCase* eclipseCase, size_t gridIndex, size_t i, size_t j, size_t k ); - QString geometrySelectionText() const override; + QString geometrySelectionText() const; RimEclipseCase* eclipseCase() const; size_t gridIndex() const; size_t cellIndex() const; - cvf::Vec3st cellIJK() const; + +private: + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; + + QString ijkTextFromCell() const; + void setCellFromIjkText( const QString& text ); + + const RigGridBase* grid() const; private: caf::PdmPtrField m_eclipseCase; - caf::PdmField m_gridIndex; - caf::PdmField m_cellIndex; - caf::PdmField m_localIntersectionPointInDisplay; + caf::PdmProxyValueField m_ijkText; + + caf::PdmField m_gridIndex; + caf::PdmField m_cellIndex; }; diff --git a/ApplicationLibCode/ProjectDataModel/RimGeometrySelectionItem.cpp b/ApplicationLibCode/ProjectDataModel/RimGeometrySelectionItem.cpp deleted file mode 100644 index 4694c4432a..0000000000 --- a/ApplicationLibCode/ProjectDataModel/RimGeometrySelectionItem.cpp +++ /dev/null @@ -1,35 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// 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 "RimGeometrySelectionItem.h" - -CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimGeometrySelectionItem, "GeometrySelectionItem" ); - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimGeometrySelectionItem::RimGeometrySelectionItem() -{ -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimGeometrySelectionItem::~RimGeometrySelectionItem() -{ -} diff --git a/ApplicationLibCode/ProjectDataModel/RimGridTimeHistoryCurve.cpp b/ApplicationLibCode/ProjectDataModel/RimGridTimeHistoryCurve.cpp index 34d25a2358..84b44d5425 100644 --- a/ApplicationLibCode/ProjectDataModel/RimGridTimeHistoryCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimGridTimeHistoryCurve.cpp @@ -26,26 +26,22 @@ #include "RigMainGrid.h" #include "RigTimeHistoryResultAccessor.h" +#include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h" + #include "RimEclipseCase.h" -#include "RimEclipseCellColors.h" #include "RimEclipseGeometrySelectionItem.h" #include "RimEclipseResultDefinition.h" -#include "RimEclipseView.h" #include "RimGeoMechCase.h" #include "RimGeoMechGeometrySelectionItem.h" #include "RimGeoMechResultDefinition.h" -#include "RimGeoMechView.h" -#include "RimProject.h" #include "RimReservoirCellResultsStorage.h" #include "RimSummaryPlot.h" #include "RimSummaryTimeAxisProperties.h" #include "Riu3dSelectionManager.h" #include "RiuFemTimeHistoryResultAccessor.h" -#include "RiuQwtPlotCurve.h" - -#include "SummaryPlotCommands/RicSummaryPlotFeatureImpl.h" -#include "qwt_plot.h" +#include "RiuPlotCurve.h" +#include "RiuPlotMainWindowTools.h" CAF_PDM_SOURCE_INIT( RimGridTimeHistoryCurve, "GridTimeHistoryCurve" ); @@ -66,8 +62,11 @@ RimGridTimeHistoryCurve::RimGridTimeHistoryCurve() CAF_PDM_InitFieldNoDefault( &m_geoMechResultDefinition, "GeoMechResultDefinition", "GeoMech Result Definition" ); m_geoMechResultDefinition.uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitFieldNoDefault( &m_geometrySelectionItem, "GeometrySelectionItem", "Geometry Selection" ); - m_geometrySelectionItem.uiCapability()->setUiTreeChildrenHidden( true ); + CAF_PDM_InitFieldNoDefault( &m_eclipseDataSource, "EclipseDataSource", "Eclipse Data Source" ); + m_eclipseDataSource.uiCapability()->setUiTreeChildrenHidden( true ); + + CAF_PDM_InitFieldNoDefault( &m_geoMechDataSource, "GeoMechDataSource", "Geomechanical Data Source" ); + m_geoMechDataSource.uiCapability()->setUiTreeChildrenHidden( true ); CAF_PDM_InitField( &m_plotAxis, "PlotAxis", caf::AppEnum( RiaDefines::PlotAxis::PLOT_AXIS_LEFT ), "Axis" ); @@ -84,49 +83,28 @@ RimGridTimeHistoryCurve::~RimGridTimeHistoryCurve() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimGridTimeHistoryCurve::setFromSelectionItem( const RiuSelectionItem* selectionItem ) +void RimGridTimeHistoryCurve::setFromSelectionItem( const RiuSelectionItem* selectionItem, bool updateResultDefinition ) { - if ( m_geometrySelectionItem() ) + if ( const RiuEclipseSelectionItem* eclSelectionItem = dynamic_cast( selectionItem ) ) { - delete m_geometrySelectionItem(); - } + m_eclipseDataSource = new RimEclipseGeometrySelectionItem; + m_eclipseDataSource->setFromSelectionItem( eclSelectionItem ); - if ( m_eclipseResultDefinition() ) - { - delete m_eclipseResultDefinition(); - } - - if ( m_geoMechResultDefinition() ) - { - delete m_geoMechResultDefinition(); - } - - const RiuEclipseSelectionItem* eclSelectionItem = dynamic_cast( selectionItem ); - if ( eclSelectionItem ) - { - RimEclipseGeometrySelectionItem* geomSelectionItem = new RimEclipseGeometrySelectionItem; - m_geometrySelectionItem = geomSelectionItem; - - geomSelectionItem->setFromSelectionItem( eclSelectionItem ); - - if ( eclSelectionItem->m_resultDefinition ) + if ( updateResultDefinition && eclSelectionItem->m_resultDefinition ) { - m_eclipseResultDefinition = new RimEclipseResultDefinition; + if ( !m_eclipseResultDefinition() ) m_eclipseResultDefinition = new RimEclipseResultDefinition; m_eclipseResultDefinition->simpleCopy( eclSelectionItem->m_resultDefinition ); } } - const RiuGeoMechSelectionItem* geoMechSelectionItem = dynamic_cast( selectionItem ); - if ( geoMechSelectionItem ) + if ( const RiuGeoMechSelectionItem* geoMechSelectionItem = dynamic_cast( selectionItem ) ) { - RimGeoMechGeometrySelectionItem* geomSelectionItem = new RimGeoMechGeometrySelectionItem; - m_geometrySelectionItem = geomSelectionItem; + m_geoMechDataSource = new RimGeoMechGeometrySelectionItem; + m_geoMechDataSource->setFromSelectionItem( geoMechSelectionItem ); - geomSelectionItem->setFromSelectionItem( geoMechSelectionItem ); - - if ( geoMechSelectionItem->m_resultDefinition ) + if ( updateResultDefinition && geoMechSelectionItem->m_resultDefinition ) { - m_geoMechResultDefinition = new RimGeoMechResultDefinition; + if ( !m_geoMechResultDefinition ) m_geoMechResultDefinition = new RimGeoMechResultDefinition; m_geoMechResultDefinition->setGeoMechCase( geoMechSelectionItem->m_resultDefinition->geoMechCase() ); m_geoMechResultDefinition->setResultAddress( geoMechSelectionItem->m_resultDefinition->resultAddress() ); } @@ -145,7 +123,6 @@ void RimGridTimeHistoryCurve::setFromEclipseCellAndResult( RimEclipseCase* size_t k, const RigEclipseResultAddress& resAddr ) { - delete m_geometrySelectionItem(); delete m_eclipseResultDefinition(); delete m_geoMechResultDefinition(); @@ -153,33 +130,8 @@ void RimGridTimeHistoryCurve::setFromEclipseCellAndResult( RimEclipseCase* m_eclipseResultDefinition->setEclipseCase( eclCase ); m_eclipseResultDefinition->setFromEclipseResultAddress( resAddr ); - RimEclipseGeometrySelectionItem* geomSelectionItem = new RimEclipseGeometrySelectionItem; - m_geometrySelectionItem = geomSelectionItem; - geomSelectionItem->setFromCaseGridAndIJK( eclCase, gridIdx, i, j, k ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RigGridCellResultAddress RimGridTimeHistoryCurve::resultAddress() -{ - RimEclipseGeometrySelectionItem* eclipseGeomSelectionItem = - dynamic_cast( m_geometrySelectionItem.value() ); - - if ( m_eclipseResultDefinition && eclipseGeomSelectionItem ) - { - cvf::Vec3st IJK = eclipseGeomSelectionItem->cellIJK(); - - return RigGridCellResultAddress( eclipseGeomSelectionItem->gridIndex(), - IJK[0], - IJK[1], - IJK[2], - m_eclipseResultDefinition->eclipseResultAddress() ); - } - - // Todo: support geomech stuff - - return RigGridCellResultAddress(); + m_eclipseDataSource = new RimEclipseGeometrySelectionItem; + m_eclipseDataSource->setFromCaseGridAndIJK( eclCase, gridIdx, i, j, k ); } //-------------------------------------------------------------------------------------------------- @@ -343,6 +295,31 @@ RimCase* RimGridTimeHistoryCurve::gridCase() const return nullptr; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridTimeHistoryCurve::createCurveFromSelectionItem( const RiuSelectionItem* selectionItem, RimSummaryPlot* plot ) +{ + if ( !selectionItem || !plot ) return; + + RimGridTimeHistoryCurve* newCurve = new RimGridTimeHistoryCurve(); + bool updateResultDefinition = true; + newCurve->setFromSelectionItem( selectionItem, updateResultDefinition ); + newCurve->setLineThickness( 2 ); + + cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable( plot->curveCount() ); + newCurve->setColor( curveColor ); + + plot->addGridTimeHistoryCurve( newCurve ); + + newCurve->loadDataAndUpdate( true ); + + plot->updateConnectedEditors(); + + RiuPlotMainWindowTools::showPlotMainWindow(); + RiuPlotMainWindowTools::selectAsCurrentItem( newCurve ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -434,8 +411,7 @@ void RimGridTimeHistoryCurve::onLoadDataAndUpdate( bool updateParentPlot ) } } - updateZoomInParentPlot(); - + plot->zoomAll(); if ( m_parentPlot ) m_parentPlot->replot(); updateQwtPlotAxis(); @@ -554,9 +530,10 @@ void RimGridTimeHistoryCurve::defineUiOrdering( QString uiConfigName, caf::PdmUi { RimPlotCurve::updateFieldUiState(); - uiOrdering.add( &m_geometrySelectionText ); + caf::PdmUiGroup* dataSource = uiOrdering.addNewGroup( "Data Source" ); + dataSource->add( &m_geometrySelectionText ); + eclipseGeomSelectionItem()->uiOrdering( uiConfigName, *dataSource ); - // Fields declared in RimResultDefinition caf::PdmUiGroup* group1 = uiOrdering.addNewGroup( "Result" ); if ( eclipseGeomSelectionItem() ) { @@ -574,11 +551,14 @@ void RimGridTimeHistoryCurve::defineUiOrdering( QString uiConfigName, caf::PdmUi caf::PdmUiGroup* appearanceGroup = uiOrdering.addNewGroup( "Appearance" ); RimPlotCurve::appearanceUiOrdering( *appearanceGroup ); + appearanceGroup->setCollapsedByDefault(); caf::PdmUiGroup* nameGroup = uiOrdering.addNewGroup( "Curve Name" ); nameGroup->setCollapsedByDefault(); nameGroup->add( &m_showLegend ); RimPlotCurve::curveNameUiOrdering( *nameGroup ); + + uiOrdering.skipRemainingFields(); } //-------------------------------------------------------------------------------------------------- @@ -610,6 +590,19 @@ void RimGridTimeHistoryCurve::fieldChangedByUi( const caf::PdmFieldHandle* chang } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridTimeHistoryCurve::childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) +{ + if ( m_eclipseDataSource() && m_eclipseResultDefinition() ) + { + m_eclipseResultDefinition->setEclipseCase( m_eclipseDataSource->eclipseCase() ); + } + + onLoadDataAndUpdate( true ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -629,9 +622,7 @@ RigMainGrid* RimGridTimeHistoryCurve::mainGrid() //-------------------------------------------------------------------------------------------------- RimEclipseGeometrySelectionItem* RimGridTimeHistoryCurve::eclipseGeomSelectionItem() const { - RimGeometrySelectionItem* pickItem = m_geometrySelectionItem(); - - return dynamic_cast( pickItem ); + return m_eclipseDataSource(); } //-------------------------------------------------------------------------------------------------- @@ -639,9 +630,7 @@ RimEclipseGeometrySelectionItem* RimGridTimeHistoryCurve::eclipseGeomSelectionIt //-------------------------------------------------------------------------------------------------- RimGeoMechGeometrySelectionItem* RimGridTimeHistoryCurve::geoMechGeomSelectionItem() const { - RimGeometrySelectionItem* pickItem = m_geometrySelectionItem(); - - return dynamic_cast( pickItem ); + return m_geoMechDataSource(); } //-------------------------------------------------------------------------------------------------- @@ -671,9 +660,9 @@ QString RimGridTimeHistoryCurve::geometrySelectionText() const { QString text; - if ( eclipseGeomSelectionItem() && m_geometrySelectionItem() ) + if ( eclipseGeomSelectionItem() ) { - text = m_geometrySelectionItem->geometrySelectionText(); + text = eclipseGeomSelectionItem()->geometrySelectionText(); } else if ( geoMechGeomSelectionItem() ) { diff --git a/ApplicationLibCode/ProjectDataModel/RimGridTimeHistoryCurve.h b/ApplicationLibCode/ProjectDataModel/RimGridTimeHistoryCurve.h index 4c9cb21389..29eeadf67d 100644 --- a/ApplicationLibCode/ProjectDataModel/RimGridTimeHistoryCurve.h +++ b/ApplicationLibCode/ProjectDataModel/RimGridTimeHistoryCurve.h @@ -25,7 +25,6 @@ #include "cafPdmProxyValueField.h" #include "cafPdmPtrField.h" -#include "SummaryPlotCommands/RicSummaryPlotFeatureImpl.h" #include class RigMainGrid; @@ -34,11 +33,11 @@ class RimEclipseResultDefinition; class RimEclipseGeometrySelectionItem; class RimGeoMechResultDefinition; class RimGeoMechGeometrySelectionItem; -class RimGeometrySelectionItem; class RiuFemTimeHistoryResultAccessor; class RiuSelectionItem; class RigEclipseResultAddress; class RimCase; +class RimSummaryPlot; //================================================================================================== /// @@ -48,12 +47,11 @@ class RimGridTimeHistoryCurve : public RimPlotCurve { CAF_PDM_HEADER_INIT; -public: public: RimGridTimeHistoryCurve(); ~RimGridTimeHistoryCurve() override; - void setFromSelectionItem( const RiuSelectionItem* selectionItem ); + void setFromSelectionItem( const RiuSelectionItem* selectionItem, bool updateResultDefinition ); 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 ); @@ -62,12 +60,12 @@ public: std::vector timeStepValues() const; std::vector daysSinceSimulationStart() const; - RigGridCellResultAddress resultAddress(); - QString quantityName() const; QString caseName() const; RimCase* gridCase() const; + static void createCurveFromSelectionItem( const RiuSelectionItem* selectionItem, RimSummaryPlot* plot ); + protected: QString createCurveAutoName() override; void updateZoomInParentPlot() override; @@ -76,6 +74,7 @@ protected: void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void initAfterRead() override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; + void childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) override; private: RigMainGrid* mainGrid(); @@ -93,6 +92,8 @@ private: caf::PdmChildField m_eclipseResultDefinition; caf::PdmChildField m_geoMechResultDefinition; - caf::PdmChildField m_geometrySelectionItem; caf::PdmField> m_plotAxis; + + caf::PdmChildField m_eclipseDataSource; + caf::PdmChildField m_geoMechDataSource; }; diff --git a/ApplicationLibCode/ProjectDataModel/RimProject.cpp b/ApplicationLibCode/ProjectDataModel/RimProject.cpp index 51650f5baf..4946f23710 100644 --- a/ApplicationLibCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimProject.cpp @@ -102,8 +102,8 @@ #include "RimWellLogPlotCollection.h" #include "RimWellPath.h" #include "RimWellPathCollection.h" - #include "RimWellTargetCandidatesGenerator.h" +#include "Tools/RimAutomationSettings.h" #include "VerticalFlowPerformance/RimVfpDataCollection.h" #include "VerticalFlowPerformance/RimVfpPlotCollection.h" @@ -232,6 +232,9 @@ RimProject::RimProject() m_plotTemplateTopFolder = new RimPlotTemplateFolderItem(); m_plotTemplateTopFolder.xmlCapability()->disableIO(); + CAF_PDM_InitFieldNoDefault( &m_automationSettings, "AutomationSettings", "Automation Settings" ); + m_automationSettings = new RimAutomationSettings(); + // For now, create a default first oilfield that contains the rest of the project oilFields.push_back( new RimOilField ); @@ -365,6 +368,14 @@ RimQuickAccessCollection* RimProject::pinnedFieldCollection() const return m_pinnedFieldCollection(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimAutomationSettings* RimProject::automationSettings() const +{ + return m_automationSettings(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1416,6 +1427,7 @@ void RimProject::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, Q statisticsItemCollection->add( m_mainPlotCollection->ensembleFractureStatisticsPlotCollection() ); } #endif + uiTreeOrdering.add( automationSettings() ); } } else if ( uiConfigName == "PlotWindow.DataSources" ) diff --git a/ApplicationLibCode/ProjectDataModel/RimProject.h b/ApplicationLibCode/ProjectDataModel/RimProject.h index 06cc3dcda7..27254009b0 100644 --- a/ApplicationLibCode/ProjectDataModel/RimProject.h +++ b/ApplicationLibCode/ProjectDataModel/RimProject.h @@ -72,6 +72,7 @@ class RimCompletionTemplateCollection; class RimPlotTemplateFolderItem; class RimGridCalculationCollection; class RimQuickAccessCollection; +class RimAutomationSettings; namespace caf { @@ -192,6 +193,7 @@ public: void updatesAfterProjectFileIsRead(); RimQuickAccessCollection* pinnedFieldCollection() const; + RimAutomationSettings* automationSettings() const; protected: void initAfterRead() override; @@ -207,6 +209,7 @@ private: private: caf::PdmChildField m_mainPlotCollection; caf::PdmChildField m_pinnedFieldCollection; + caf::PdmChildField m_automationSettings; caf::PdmField m_globalPathList; caf::PdmField m_projectFileVersionString; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlotCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlotCollection.cpp index 039413268e..6ef469c9ea 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlotCollection.cpp @@ -144,10 +144,13 @@ void RimSummaryMultiPlotCollection::summaryPlotItemInfos( QListdescription(); + for ( RimSummaryPlot* plot : multiPlot->summaryPlots() ) { - QString displayName = plot->userDescriptionField()->uiCapability()->uiValue().toString(); - optionInfos->push_back( caf::PdmOptionItemInfo( displayName, plot, false, plot->uiCapability()->uiIconProvider() ) ); + QString displayName = mainPlotName + " : "; + displayName += plot->userDescriptionField()->uiCapability()->uiValue().toString(); + optionInfos->push_back( caf::PdmOptionItemInfo( displayName, plot, false, plot->uiIconProvider() ) ); } } } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryNameHelper.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryNameHelper.cpp index 161c8b63c6..56d3dfcf83 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryNameHelper.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryNameHelper.cpp @@ -102,7 +102,7 @@ QString RimSummaryNameHelper::aggregatedPlotTitle( const RimSummaryNameHelper& o size_t pos = vectorName.find( '_' ); if ( pos != std::string::npos ) { - title += "(" + vectorName + ")"; + title += QString( " (%1)" ).arg( QString::fromStdString( vectorName ) ); } } diff --git a/ApplicationLibCode/ProjectDataModel/Tools/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/Tools/CMakeLists_files.cmake index f94ec285b8..4933928184 100644 --- a/ApplicationLibCode/ProjectDataModel/Tools/CMakeLists_files.cmake +++ b/ApplicationLibCode/ProjectDataModel/Tools/CMakeLists_files.cmake @@ -1,9 +1,13 @@ -set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RiaVariableMapper.h - ${CMAKE_CURRENT_LIST_DIR}/RimPlotAxisTools.h +set(SOURCE_GROUP_HEADER_FILES + ${CMAKE_CURRENT_LIST_DIR}/RiaVariableMapper.h + ${CMAKE_CURRENT_LIST_DIR}/RimPlotAxisTools.h + ${CMAKE_CURRENT_LIST_DIR}/RimAutomationSettings.h ) -set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RiaVariableMapper.cpp - ${CMAKE_CURRENT_LIST_DIR}/RimPlotAxisTools.cpp +set(SOURCE_GROUP_SOURCE_FILES + ${CMAKE_CURRENT_LIST_DIR}/RiaVariableMapper.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimPlotAxisTools.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimAutomationSettings.cpp ) list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) diff --git a/ApplicationLibCode/ProjectDataModel/Tools/RimAutomationSettings.cpp b/ApplicationLibCode/ProjectDataModel/Tools/RimAutomationSettings.cpp index 574da4cff7..7a3191239b 100644 --- a/ApplicationLibCode/ProjectDataModel/Tools/RimAutomationSettings.cpp +++ b/ApplicationLibCode/ProjectDataModel/Tools/RimAutomationSettings.cpp @@ -26,7 +26,7 @@ #include "PlotBuilderCommands/RicSummaryPlotBuilder.h" #include "RiuPlotMainWindowTools.h" -#include "cafPdmUiPushButtonEditor.h" +#include "RimSummaryMultiPlot.h" CAF_PDM_SOURCE_INIT( RimAutomationSettings, "RimAutomationSettings" ); @@ -42,36 +42,24 @@ RimAutomationSettings::RimAutomationSettings() "Cell Selection Destination", "", "Add curves to the selected Summary Plot when clicking on cells in a 3D view." ); - - CAF_PDM_InitFieldNoDefault( &m_createSummaryPlot, "CreateSummaryPlot", "Create Summary Plot" ); - caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_createSummaryPlot ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryPlot* RimAutomationSettings::cellSelectionDestination() const +std::vector RimAutomationSettings::summaryPlots() const { - return m_cellSelectionDestination(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimAutomationSettings::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) -{ - if ( changedField == &m_createSummaryPlot ) + if ( auto summaryPlot = dynamic_cast( m_cellSelectionDestination() ) ) { - if ( m_createSummaryPlot ) - { - RimSummaryPlot* newPlot = new RimSummaryPlot(); - RiaSummaryPlotBuilder::createAndAppendSingleSummaryMultiPlot( newPlot ); - - RiuPlotMainWindowTools::selectAsCurrentItem( this ); - - m_cellSelectionDestination = newPlot; - } + return { summaryPlot }; } + + if ( auto multiSummaryPlot = dynamic_cast( m_cellSelectionDestination() ) ) + { + return multiSummaryPlot->summaryPlots(); + } + + return {}; } //-------------------------------------------------------------------------------------------------- @@ -83,9 +71,6 @@ void RimAutomationSettings::defineUiOrdering( QString uiConfigName, caf::PdmUiOr group->add( &m_cellSelectionDestination ); m_cellSelectionDestination.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); - - // group->add( &m_createSummaryPlot ); - uiOrdering.skipRemainingFields(); } //-------------------------------------------------------------------------------------------------- @@ -99,7 +84,19 @@ QList RimAutomationSettings::calculateValueOptions( cons { if ( auto summaryPlotColl = RiaSummaryTools::summaryMultiPlotCollection() ) { - summaryPlotColl->summaryPlotItemInfos( &options ); + for ( RimSummaryMultiPlot* multiPlot : summaryPlotColl->multiPlots() ) + { + auto mainPlotName = multiPlot->description(); + + options.push_back( caf::PdmOptionItemInfo( mainPlotName, multiPlot, false, multiPlot->uiIconProvider() ) ); + + for ( RimSummaryPlot* plot : multiPlot->summaryPlots() ) + { + QString displayName = mainPlotName + " : "; + displayName += plot->userDescriptionField()->uiCapability()->uiValue().toString(); + options.push_back( caf::PdmOptionItemInfo( displayName, plot, false, plot->uiIconProvider() ) ); + } + } } options.push_back( caf::PdmOptionItemInfo( "None", nullptr ) ); @@ -107,17 +104,3 @@ QList RimAutomationSettings::calculateValueOptions( cons return options; } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimAutomationSettings::defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) -{ - if ( field == &m_createSummaryPlot ) - { - if ( auto* attr = dynamic_cast( attribute ) ) - { - attr->m_buttonText = "Create Plot"; - } - } -} diff --git a/ApplicationLibCode/ProjectDataModel/RimGeometrySelectionItem.h b/ApplicationLibCode/ProjectDataModel/Tools/RimAutomationSettings.h similarity index 50% rename from ApplicationLibCode/ProjectDataModel/RimGeometrySelectionItem.h rename to ApplicationLibCode/ProjectDataModel/Tools/RimAutomationSettings.h index 8d3614481f..4645633899 100644 --- a/ApplicationLibCode/ProjectDataModel/RimGeometrySelectionItem.h +++ b/ApplicationLibCode/ProjectDataModel/Tools/RimAutomationSettings.h @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2017 Statoil ASA +// Copyright (C) 2025 Equinor ASA // // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -18,15 +18,30 @@ #pragma once +#include "cafPdmField.h" #include "cafPdmObject.h" +#include "cafPdmPtrField.h" -class RimGeometrySelectionItem : public caf::PdmObject +class RimPlotWindow; +class RimSummaryPlot; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimAutomationSettings : public caf::PdmObject { CAF_PDM_HEADER_INIT; public: - RimGeometrySelectionItem(); - ~RimGeometrySelectionItem() override; + RimAutomationSettings(); - virtual QString geometrySelectionText() const = 0; + std::vector summaryPlots() const; + +private: + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; + +private: + caf::PdmPtrField m_cellSelectionDestination; }; diff --git a/ApplicationLibCode/ReservoirDataModel/RigGridBase.cpp b/ApplicationLibCode/ReservoirDataModel/RigGridBase.cpp index fe38e3c80d..2e27a34617 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigGridBase.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigGridBase.cpp @@ -246,20 +246,6 @@ std::optional RigGridBase::ijkFromCellIndex( size_t cellIndex ) con return std::nullopt; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::optional RigGridBase::ijkFromCellIndexOneBased( size_t cellIndex ) const -{ - size_t i, j, k; - if ( ijkFromCellIndex( cellIndex, &i, &j, &k ) ) - { - return caf::VecIjk( ++i, ++j, ++k ); - } - - return std::nullopt; -} - //-------------------------------------------------------------------------------------------------- /// This version does no if-guarding. Check that all dimensions of the grid are non-zero before using. /// Useful for running in a loop after doing the sanity check once. diff --git a/ApplicationLibCode/ReservoirDataModel/RigGridBase.h b/ApplicationLibCode/ReservoirDataModel/RigGridBase.h index db5fb1da1c..771c88f328 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigGridBase.h +++ b/ApplicationLibCode/ReservoirDataModel/RigGridBase.h @@ -99,7 +99,6 @@ public: virtual void ijkFromCellIndexUnguarded( size_t cellIndex, size_t* i, size_t* j, size_t* k ) const; std::optional ijkFromCellIndex( size_t cellIndex ) const; - std::optional ijkFromCellIndexOneBased( size_t cellIndex ) const; bool cellIJKFromCoordinate( const cvf::Vec3d& coord, size_t* i, size_t* j, size_t* k ) const override; // unused void cellMinMaxCordinates( size_t cellIndex, cvf::Vec3d* minCoordinate, cvf::Vec3d* maxCoordinate ) const override; // unused diff --git a/ApplicationLibCode/UserInterface/RiuCellSelectionTool.cpp b/ApplicationLibCode/UserInterface/RiuCellSelectionTool.cpp index db5429b07d..edc9be7b8a 100644 --- a/ApplicationLibCode/UserInterface/RiuCellSelectionTool.cpp +++ b/ApplicationLibCode/UserInterface/RiuCellSelectionTool.cpp @@ -19,6 +19,7 @@ #include "RiuCellSelectionTool.h" #include "RiaApplication.h" +#include "RiaTextStringTools.h" #include "Rim3dView.h" #include "RimEclipseView.h" @@ -199,25 +200,6 @@ void RiuCellSelectionTool::validateAndAppend() } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QVector RiuCellSelectionTool::parseDoubleValues( const QString& input ) -{ - // Flexible regex to extract three double numbers with any surrounding text - QRegularExpression coordRegex( R"([-+]?\d+\.?\d*)" ); - QRegularExpressionMatchIterator it = coordRegex.globalMatch( input ); - - QVector coords; - while ( it.hasNext() && coords.size() < 3 ) - { - QRegularExpressionMatch match = it.next(); - coords.append( match.captured().toDouble() ); - } - - return coords; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -234,7 +216,7 @@ RiuEclipseSelectionItem* RiuCellSelectionTool::createSelectionItemFromInput() if ( m_xyzRadio->isChecked() ) { - QVector coords = parseDoubleValues( m_coordinateEdit->text().trimmed() ); + QVector coords = RiaTextStringTools::parseDoubleValues( m_coordinateEdit->text().trimmed() ); if ( coords.size() < 2 ) { return nullptr; @@ -274,7 +256,7 @@ RiuEclipseSelectionItem* RiuCellSelectionTool::createSelectionItemFromInput() } else { - QVector ijkValues = parseDoubleValues( m_cellEdit->text().trimmed() ); + QVector ijkValues = RiaTextStringTools::parseDoubleValues( m_cellEdit->text().trimmed() ); if ( ijkValues.size() != 3 ) { return nullptr; diff --git a/ApplicationLibCode/UserInterface/RiuCellSelectionTool.h b/ApplicationLibCode/UserInterface/RiuCellSelectionTool.h index cdb23b5316..32597ba6c0 100644 --- a/ApplicationLibCode/UserInterface/RiuCellSelectionTool.h +++ b/ApplicationLibCode/UserInterface/RiuCellSelectionTool.h @@ -52,7 +52,6 @@ private slots: void validateAndAppend(); private: - static QVector parseDoubleValues( const QString& input ); RiuEclipseSelectionItem* createSelectionItemFromInput(); void updateVisibleUiItems(); void setupUI(); diff --git a/ApplicationLibCode/UserInterface/RiuSelectionChangedHandler.cpp b/ApplicationLibCode/UserInterface/RiuSelectionChangedHandler.cpp index 243e91b800..0469451423 100644 --- a/ApplicationLibCode/UserInterface/RiuSelectionChangedHandler.cpp +++ b/ApplicationLibCode/UserInterface/RiuSelectionChangedHandler.cpp @@ -19,6 +19,7 @@ #include "RiuSelectionChangedHandler.h" +#include "RiaColorTables.h" #include "RiaResultNames.h" #include "RigCaseCellResultsData.h" @@ -37,7 +38,10 @@ #include "RimGeoMechCase.h" #include "RimGeoMechResultDefinition.h" #include "RimGeoMechView.h" +#include "RimGridTimeHistoryCurve.h" #include "RimProject.h" +#include "RimSummaryPlot.h" +#include "Tools/RimAutomationSettings.h" #include "Riu3dSelectionManager.h" #include "RiuDepthQwtPlot.h" @@ -125,6 +129,7 @@ void RiuSelectionChangedHandler::handleItemAppended( const RiuSelectionItem* ite if ( mohrsCirclePlot ) mohrsCirclePlot->appendSelection( item ); updateResultInfo( item ); + updateGridCellCurvesFromSelection(); scheduleUpdateForAllVisibleViews(); } @@ -417,6 +422,80 @@ void RiuSelectionChangedHandler::updateResultInfo( const RiuSelectionItem* itemA mainWnd->setResultInfo( resultInfo ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuSelectionChangedHandler::updateGridCellCurvesFromSelection() +{ + std::vector items; + Riu3dSelectionManager::instance()->selectedItems( items ); + if ( items.empty() ) return; + + auto autoSettings = RimProject::current()->automationSettings(); + for ( auto summaryPlot : autoSettings->summaryPlots() ) + { + // if no curves present, create from selection + if ( summaryPlot->gridTimeHistoryCurves().empty() ) + { + for ( auto item : items ) + { + RimGridTimeHistoryCurve::createCurveFromSelectionItem( item, summaryPlot ); + } + } + else + { + // find unique result types like soil, swat + // for each result type, create a curve for all cells in selection + + auto curves = summaryPlot->gridTimeHistoryCurves(); + + std::map uniqueCurves; + for ( auto curve : curves ) + { + if ( uniqueCurves.contains( curve->quantityName() ) ) continue; + uniqueCurves[curve->quantityName()] = curve; + } + + std::vector sourceCurves; + std::transform( uniqueCurves.begin(), + uniqueCurves.end(), + std::back_inserter( sourceCurves ), + []( const auto& pair ) { return pair.second; } ); + + std::vector newCurves; + + for ( auto curve : sourceCurves ) + { + int index = 0; + for ( auto item : items ) + { + auto newCurve = curve->copyObject(); + bool updateResultDefinition = false; + newCurve->setFromSelectionItem( item, updateResultDefinition ); + + if ( index != 0 ) + { + cvf::Color3f curveColor = RiaColorTables::wellLogPlotPaletteColors().cycledColor3f( index ); + newCurve->setColor( curveColor ); + } + index++; + + newCurves.push_back( newCurve ); + } + } + + summaryPlot->deleteAllGridTimeHistoryCurves(); + for ( auto c : newCurves ) + { + summaryPlot->addGridTimeHistoryCurve( c ); + } + + summaryPlot->updateConnectedEditors(); + summaryPlot->loadDataAndUpdate(); + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/UserInterface/RiuSelectionChangedHandler.h b/ApplicationLibCode/UserInterface/RiuSelectionChangedHandler.h index f7ac86a5b1..a551dc39a0 100644 --- a/ApplicationLibCode/UserInterface/RiuSelectionChangedHandler.h +++ b/ApplicationLibCode/UserInterface/RiuSelectionChangedHandler.h @@ -47,4 +47,6 @@ private: void scheduleUpdateForAllVisibleViews() const; void updateResultInfo( const RiuSelectionItem* itemAdded ) const; + + static void updateGridCellCurvesFromSelection(); }; diff --git a/Fwk/AppFwk/CommonCode/cafVecIjk.cpp b/Fwk/AppFwk/CommonCode/cafVecIjk.cpp index 788c6a3565..84e6e3f2a1 100644 --- a/Fwk/AppFwk/CommonCode/cafVecIjk.cpp +++ b/Fwk/AppFwk/CommonCode/cafVecIjk.cpp @@ -46,6 +46,22 @@ VecIjk::VecIjk( size_t i, size_t j, size_t k ) m_values = { { i, j, k } }; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::VecIjk VecIjk::toOneBased() const +{ + return VecIjk( i() + 1, j() + 1, k() + 1 ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::VecIjk VecIjk::toZeroBased() const +{ + return VecIjk( i() - 1, j() - 1, k() - 1 ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/CommonCode/cafVecIjk.h b/Fwk/AppFwk/CommonCode/cafVecIjk.h index e80f813cc8..e6f4a755d6 100644 --- a/Fwk/AppFwk/CommonCode/cafVecIjk.h +++ b/Fwk/AppFwk/CommonCode/cafVecIjk.h @@ -47,6 +47,9 @@ class VecIjk public: VecIjk( size_t i, size_t j, size_t k ); + VecIjk toOneBased() const; + VecIjk toZeroBased() const; + size_t i() const; size_t j() const; size_t k() const;