From e512f6a5c103625d256309a6aa83c74168b5e010 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 8 Mar 2023 07:35:27 +0100 Subject: [PATCH] Several RFT plot adjustments * #9923 Call loadDataAndUpdate() after visibility of curves is updated This will ensure that all zoom ranges are recalculated based on visible curves. * #9923 Put new segment plots in RFT Plot collection * #9923 Add "Create Rft Sement Plot" to RFT plot collection * #9923 Make sure the main window is displayed when required Make sure the main window is opened and views updated when a grid model is opened from a summary case. * #9923 Make sure fieldChanged is triggered when required Exclude field having the target state. If these fields are included, the one and only call to setValueWithFieldChanged() can contain a field with the target state value. When setting a value to a field with the same value, nothing happens and the UI will get an inconsistent state (some curves toggled off are still visible in a plot). --- .../RicShowMainWindowFeature.cpp | 21 ++++++++++++ ...cImportGridModelFromSummaryCaseFeature.cpp | 4 +++ .../RicToggleItemsFeatureImpl.cpp | 33 +++++++++++++++--- .../RicNewMultiPhaseRftSegmentPlotFeature.cpp | 8 ++--- .../RicNewRftSegmentWellLogPlotFeature.cpp | 34 +++++++++++++++---- .../RicNewRftSegmentWellLogPlotFeature.h | 2 ++ .../RicNewWellLogPlotFeatureImpl.cpp | 18 ++++++++-- .../RicNewWellLogPlotFeatureImpl.h | 2 +- .../RimContextCommandBuilder.cpp | 2 ++ .../ProjectDataModel/RimRftPlotCollection.cpp | 11 ++++-- .../ProjectDataModel/RimRftPlotCollection.h | 6 ++-- .../RimWellLogCurveCommonDataSource.cpp | 6 ++++ 12 files changed, 122 insertions(+), 25 deletions(-) diff --git a/ApplicationLibCode/Commands/ApplicationCommands/RicShowMainWindowFeature.cpp b/ApplicationLibCode/Commands/ApplicationCommands/RicShowMainWindowFeature.cpp index 28f6176390..0a04392faa 100644 --- a/ApplicationLibCode/Commands/ApplicationCommands/RicShowMainWindowFeature.cpp +++ b/ApplicationLibCode/Commands/ApplicationCommands/RicShowMainWindowFeature.cpp @@ -20,6 +20,10 @@ #include "RiaGuiApplication.h" +#include "Rim3dView.h" +#include "RimCase.h" +#include "RimProject.h" + #include "RiuMainWindow.h" #include @@ -51,6 +55,23 @@ void RicShowMainWindowFeature::showMainWindow() { RiaGuiApplication* app = RiaGuiApplication::instance(); app->getOrCreateAndShowMainWindow(); + + // When the main window is created, make sure all the views are loaded and displayed + + std::vector allGridModels; + RimProject::current()->allCases( allGridModels ); + + for ( RimCase* gridModel : allGridModels ) + { + if ( gridModel ) + { + std::vector views = gridModel->views(); + for ( Rim3dView* view : views ) + { + if ( view ) view->loadDataAndUpdate(); + } + } + } } } diff --git a/ApplicationLibCode/Commands/RicImportGridModelFromSummaryCaseFeature.cpp b/ApplicationLibCode/Commands/RicImportGridModelFromSummaryCaseFeature.cpp index 44710aed8b..990063700e 100644 --- a/ApplicationLibCode/Commands/RicImportGridModelFromSummaryCaseFeature.cpp +++ b/ApplicationLibCode/Commands/RicImportGridModelFromSummaryCaseFeature.cpp @@ -18,6 +18,8 @@ #include "RicImportGridModelFromSummaryCaseFeature.h" +#include "ApplicationCommands/RicShowMainWindowFeature.h" + #include "RiaEclipseFileNameTools.h" #include "RiaImportEclipseCaseTools.h" #include "RiaLogging.h" @@ -125,6 +127,8 @@ bool RicImportGridModelFromSummaryCaseFeature::findAndActivateFirstView( const R { if ( !gridCase->gridViews().empty() ) { + RicShowMainWindowFeature::showMainWindow(); + Riu3DMainWindowTools::selectAsCurrentItem( gridCase->gridViews().front() ); return true; diff --git a/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsFeatureImpl.cpp b/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsFeatureImpl.cpp index 878191d89d..0f0d83d93c 100644 --- a/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsFeatureImpl.cpp +++ b/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsFeatureImpl.cpp @@ -99,11 +99,36 @@ bool RicToggleItemsFeatureImpl::isToggleCommandsForSubItems() //-------------------------------------------------------------------------------------------------- void RicToggleItemsFeatureImpl::setObjectToggleStateForSelection( SelectionToggleType state ) { - auto fields = findToggleFieldsFromSelection( state ); - if ( fields.empty() ) return; + auto selectedFields = findToggleFieldsFromSelection( state ); - auto lastField = fields.back(); - for ( auto field : fields ) + std::vector*> fieldsToUpdate; + if ( state == TOGGLE_OFF || state == TOGGLE_ON ) + { + // Exclude field having the target state. If these fields are included, the one and only call to setValueWithFieldChanged() can + // contain a field with the target state value. When setting a value to a field with the same value, nothing happens and the UI will + // get an inconsistent state (some curves toggled off are still visible in a plot). + + const bool targetState = ( state == TOGGLE_ON ) ? true : false; + + for ( const auto& field : selectedFields ) + { + bool currentValue = field->v(); + if ( currentValue != targetState ) + { + fieldsToUpdate.push_back( field ); + } + } + } + else + { + // All fields will be updated when toggling + fieldsToUpdate = selectedFields; + } + + if ( fieldsToUpdate.empty() ) return; + + auto lastField = fieldsToUpdate.back(); + for ( auto field : fieldsToUpdate ) { bool value = !( field->v() ); diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicNewMultiPhaseRftSegmentPlotFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicNewMultiPhaseRftSegmentPlotFeature.cpp index 56bd81989c..0cf5cf3e91 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicNewMultiPhaseRftSegmentPlotFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicNewMultiPhaseRftSegmentPlotFeature.cpp @@ -58,11 +58,7 @@ bool RicNewMultiPhaseRftSegmentPlotFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicNewMultiPhaseRftSegmentPlotFeature::onActionTriggered( bool isChecked ) { - auto rftCase = caf::SelectionManager::instance()->selectedItemOfType(); - if ( !rftCase ) return; - - RimSummaryCase* summaryCase = nullptr; - rftCase->firstAncestorOfType( summaryCase ); + RimSummaryCase* summaryCase = RicNewRftSegmentWellLogPlotFeature::getSelectedOrFirstRftCase(); if ( !summaryCase ) return; auto rftReader = summaryCase->rftReader(); @@ -72,7 +68,7 @@ void RicNewMultiPhaseRftSegmentPlotFeature::onActionTriggered( bool isChecked ) return; } - auto plot = RicNewWellLogPlotFeatureImpl::createHorizontalWellLogPlot(); + auto plot = RicNewWellLogPlotFeatureImpl::createRftSegmentPlot(); QString wellName = "Unknown"; diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicNewRftSegmentWellLogPlotFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicNewRftSegmentWellLogPlotFeature.cpp index 0c8c826db5..45f762e969 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicNewRftSegmentWellLogPlotFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicNewRftSegmentWellLogPlotFeature.cpp @@ -27,6 +27,7 @@ #include "RiaLogging.h" #include "RiaPlotWindowRedrawScheduler.h" #include "RiaRftDefines.h" +#include "RiaSummaryTools.h" #include "RifReaderOpmRft.h" @@ -58,11 +59,7 @@ bool RicNewRftSegmentWellLogPlotFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicNewRftSegmentWellLogPlotFeature::onActionTriggered( bool isChecked ) { - auto rftCase = caf::SelectionManager::instance()->selectedItemOfType(); - if ( !rftCase ) return; - - RimSummaryCase* summaryCase = nullptr; - rftCase->firstAncestorOfType( summaryCase ); + RimSummaryCase* summaryCase = RicNewRftSegmentWellLogPlotFeature::getSelectedOrFirstRftCase(); if ( !summaryCase ) return; auto rftReader = summaryCase->rftReader(); @@ -72,7 +69,7 @@ void RicNewRftSegmentWellLogPlotFeature::onActionTriggered( bool isChecked ) return; } - auto plot = RicNewWellLogPlotFeatureImpl::createHorizontalWellLogPlot(); + auto plot = RicNewWellLogPlotFeatureImpl::createRftSegmentPlot(); QString wellName = "Unknown"; auto wellNames = rftReader->wellNames(); @@ -293,6 +290,31 @@ void RicNewRftSegmentWellLogPlotFeature::appendConnectionFactorTrack( RimWellLog curve->setFillStyle( Qt::SolidPattern ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryCase* RicNewRftSegmentWellLogPlotFeature::getSelectedOrFirstRftCase() +{ + auto rftCase = caf::SelectionManager::instance()->selectedItemOfType(); + if ( rftCase ) + { + RimSummaryCase* summaryCase = nullptr; + rftCase->firstAncestorOfType( summaryCase ); + if ( summaryCase ) return summaryCase; + } + + auto summaryCases = RiaSummaryTools::singleTopLevelSummaryCases(); + for ( const auto& candidateCase : summaryCases ) + { + if ( candidateCase && candidateCase->rftReader() ) + { + return candidateCase; + } + } + + return nullptr; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicNewRftSegmentWellLogPlotFeature.h b/ApplicationLibCode/Commands/WellLogCommands/RicNewRftSegmentWellLogPlotFeature.h index 25e25f426e..2d4e3aefc3 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicNewRftSegmentWellLogPlotFeature.h +++ b/ApplicationLibCode/Commands/WellLogCommands/RicNewRftSegmentWellLogPlotFeature.h @@ -40,6 +40,8 @@ public: static void appendPressureTrack( RimWellLogPlot* plot, const QString& wellName, RimSummaryCase* summaryCase ); static void appendConnectionFactorTrack( RimWellLogPlot* plot, const QString& wellName, RimSummaryCase* summaryCase ); + static RimSummaryCase* getSelectedOrFirstRftCase(); + private: bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogPlotFeatureImpl.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogPlotFeatureImpl.cpp index db0345340f..0717895fd8 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogPlotFeatureImpl.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogPlotFeatureImpl.cpp @@ -23,6 +23,7 @@ #include "RimEclipseCase.h" #include "RimMainPlotCollection.h" #include "RimProject.h" +#include "RimRftPlotCollection.h" #include "RimStimPlanModelPlot.h" #include "RimStimPlanModelPlotCollection.h" #include "RimWellBoreStabilityPlot.h" @@ -84,9 +85,22 @@ RimWellBoreStabilityPlot* RicNewWellLogPlotFeatureImpl::createWellBoreStabilityP //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimWellLogPlot* RicNewWellLogPlotFeatureImpl::createHorizontalWellLogPlot() +RimWellLogPlot* RicNewWellLogPlotFeatureImpl::createRftSegmentPlot() { - auto plot = createWellLogPlot(); + auto rftPlotCollection = RimMainPlotCollection::current()->rftPlotCollection(); + CVF_ASSERT( rftPlotCollection ); + + // Make sure the summary plot window is created + RiaGuiApplication::instance()->getOrCreateMainPlotWindow(); + + RimWellLogPlot* plot = new RimWellLogPlot(); + plot->setAsPlotMdiWindow(); + + rftPlotCollection->addPlot( plot ); + + plot->nameConfig()->setCustomName( QString( "RFT Segment Plot %1" ).arg( rftPlotCollection->plotCount() ) ); + + rftPlotCollection->updateConnectedEditors(); plot->setDepthOrientation( RiaDefines::Orientation::HORIZONTAL ); plot->setNamingMethod( RiaDefines::ObjectNamingMethod::TEMPLATE ); diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogPlotFeatureImpl.h b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogPlotFeatureImpl.h index 0f14d50f2e..02bb158987 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogPlotFeatureImpl.h +++ b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogPlotFeatureImpl.h @@ -38,7 +38,7 @@ public: const QString& plotDescription = QString( "" ), const RimWbsParameters* params = nullptr ); - static RimWellLogPlot* createHorizontalWellLogPlot(); + static RimWellLogPlot* createRftSegmentPlot(); static RimWellLogTrack* createWellLogTrackWithAutoUpdate(); static RimWellLogPlot* createWellLogPlot( bool showAfterCreation = true, const QString& plotDescription = QString( "" ) ); diff --git a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp index 627f236aff..c992d63d24 100644 --- a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -542,6 +542,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() else if ( dynamic_cast( firstUiItem ) ) { menuBuilder << "RicNewRftPlotFeature"; + menuBuilder << "RicNewMultiPhaseRftSegmentPlotFeature"; + menuBuilder << "RicNewRftSegmentWellLogPlotFeature"; } else if ( dynamic_cast( firstUiItem ) ) { diff --git a/ApplicationLibCode/ProjectDataModel/RimRftPlotCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimRftPlotCollection.cpp index b8c247e244..eaabe6c4ed 100644 --- a/ApplicationLibCode/ProjectDataModel/RimRftPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimRftPlotCollection.cpp @@ -204,8 +204,13 @@ const std::vector RimRftPlotCollection::rftPlots() const std::vector plots; for ( const auto& plot : m_rftPlots ) { - plots.push_back( plot ); + auto wellRftPlot = dynamic_cast( plot.p() ); + if ( wellRftPlot ) + { + plots.push_back( wellRftPlot ); + } } + return plots; } @@ -231,7 +236,7 @@ size_t RimRftPlotCollection::plotCount() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimRftPlotCollection::addPlot( gsl::not_null newPlot ) +void RimRftPlotCollection::addPlot( gsl::not_null newPlot ) { m_rftPlots.push_back( newPlot ); } @@ -239,7 +244,7 @@ void RimRftPlotCollection::addPlot( gsl::not_null newPlot ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimRftPlotCollection::removePlot( gsl::not_null plot ) +void RimRftPlotCollection::removePlot( gsl::not_null plot ) { m_rftPlots.removeChild( plot ); updateAllRequiredEditors(); diff --git a/ApplicationLibCode/ProjectDataModel/RimRftPlotCollection.h b/ApplicationLibCode/ProjectDataModel/RimRftPlotCollection.h index 798efec2ec..dacb6f2fb4 100644 --- a/ApplicationLibCode/ProjectDataModel/RimRftPlotCollection.h +++ b/ApplicationLibCode/ProjectDataModel/RimRftPlotCollection.h @@ -66,14 +66,14 @@ public: void deleteAllExtractors(); const std::vector rftPlots() const; - void addPlot( gsl::not_null newPlot ); - void removePlot( gsl::not_null plot ); + void addPlot( gsl::not_null newPlot ); + void removePlot( gsl::not_null plot ); void deleteAllPlots() override; void loadDataAndUpdateAllPlots() override; size_t plotCount() const override; private: - caf::PdmChildArrayField m_rftPlots; + caf::PdmChildArrayField m_rftPlots; cvf::Collection m_extractors; cvf::Collection m_geomExtractors; }; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.cpp index 9e1154e023..35f18a437d 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.cpp @@ -712,10 +712,16 @@ void RimWellLogCurveCommonDataSource::applyDataSourceChanges() this->applyDataSourceChanges( curves, tracks ); + // plot->loadDataAndUpdate() has been called in applyDataSourceChanges(), and this is required before the visibility of tracks and + // curves can be updated. However, if the visibility of curves changes, another loadDataAndUpdate() is required to calculate zoom + // based on visible curves. + for ( auto& track : tracks ) { track->updateCheckStateBasedOnCurveData(); } + + parentPlot->loadDataAndUpdate(); } }