diff --git a/ApplicationExeCode/Resources/AppendNextCurve.png b/ApplicationExeCode/Resources/AppendNextCurve.png new file mode 100644 index 0000000000..46ca68fa25 Binary files /dev/null and b/ApplicationExeCode/Resources/AppendNextCurve.png differ diff --git a/ApplicationExeCode/Resources/AppendNextCurve.svg b/ApplicationExeCode/Resources/AppendNextCurve.svg new file mode 100644 index 0000000000..b29ed3db85 --- /dev/null +++ b/ApplicationExeCode/Resources/AppendNextCurve.svg @@ -0,0 +1,70 @@ + + + +First Aid + + + diff --git a/ApplicationExeCode/Resources/AppendPrevCurve.png b/ApplicationExeCode/Resources/AppendPrevCurve.png new file mode 100644 index 0000000000..ebbac2239c Binary files /dev/null and b/ApplicationExeCode/Resources/AppendPrevCurve.png differ diff --git a/ApplicationExeCode/Resources/AppendPrevCurve.svg b/ApplicationExeCode/Resources/AppendPrevCurve.svg new file mode 100644 index 0000000000..4c864605c9 --- /dev/null +++ b/ApplicationExeCode/Resources/AppendPrevCurve.svg @@ -0,0 +1,69 @@ + + + +First Aid + + + diff --git a/ApplicationExeCode/Resources/ResInsight.qrc b/ApplicationExeCode/Resources/ResInsight.qrc index 7f4e7fa6cd..3b07b776da 100644 --- a/ApplicationExeCode/Resources/ResInsight.qrc +++ b/ApplicationExeCode/Resources/ResInsight.qrc @@ -263,6 +263,10 @@ AppendPrev.svg AppendNext.png AppendPrev.png + AppendNextCurve.svg + AppendPrevCurve.svg + AppendNextCurve.png + AppendPrevCurve.png fs_CellFace.glsl diff --git a/ApplicationLibCode/Application/RiaPlotWindowRedrawScheduler.cpp b/ApplicationLibCode/Application/RiaPlotWindowRedrawScheduler.cpp index 2054152762..ffb1ea7881 100644 --- a/ApplicationLibCode/Application/RiaPlotWindowRedrawScheduler.cpp +++ b/ApplicationLibCode/Application/RiaPlotWindowRedrawScheduler.cpp @@ -41,9 +41,17 @@ RiaPlotWindowRedrawScheduler* RiaPlotWindowRedrawScheduler::instance() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaPlotWindowRedrawScheduler::scheduleMultiPlotWindowUpdate( RiuMultiPlotBook* plotWindow ) +void RiaPlotWindowRedrawScheduler::scheduleMultiPlotBookUpdate( RiuMultiPlotBook* plotBook, + RiaDefines::MultiPlotPageUpdateType updateType ) { - m_plotWindowsToUpdate.push_back( plotWindow ); + if ( m_plotBooksToUpdate.count( plotBook ) == 0 ) + { + m_plotBooksToUpdate[plotBook] = updateType; + } + else + { + m_plotBooksToUpdate[plotBook] = m_plotBooksToUpdate[plotBook] | updateType; + } startTimer( 0 ); } @@ -90,7 +98,7 @@ void RiaPlotWindowRedrawScheduler::clearAllScheduledUpdates() } m_plotWidgetsToReplot.clear(); m_plotPagesToUpdate.clear(); - m_plotWindowsToUpdate.clear(); + m_plotBooksToUpdate.clear(); } //-------------------------------------------------------------------------------------------------- @@ -98,30 +106,28 @@ void RiaPlotWindowRedrawScheduler::clearAllScheduledUpdates() //-------------------------------------------------------------------------------------------------- void RiaPlotWindowRedrawScheduler::performScheduledUpdatesAndReplots() { - std::vector> plotWindowsToUpdate; + std::map, RiaDefines::MultiPlotPageUpdateType> plotBooksToUpdate; std::vector> plotWidgetsToReplot; std::map, RiaDefines::MultiPlotPageUpdateType> pagesToUpdate; pagesToUpdate.swap( m_plotPagesToUpdate ); - plotWindowsToUpdate.swap( m_plotWindowsToUpdate ); + plotBooksToUpdate.swap( m_plotBooksToUpdate ); plotWidgetsToReplot.swap( m_plotWidgetsToReplot ); - std::set> updatedPlots; - std::set> updatedPlotWindows; + std::set> updatedPlots; - for ( QPointer plotWindow : plotWindowsToUpdate ) + for ( auto& [plotBook, updateType] : plotBooksToUpdate ) { - if ( !plotWindow.isNull() && !updatedPlotWindows.count( plotWindow ) ) + if ( plotBook.isNull() ) continue; + + if ( ( updateType & RiaDefines::MultiPlotPageUpdateType::PLOT ) == RiaDefines::MultiPlotPageUpdateType::PLOT ) { - for ( RiuMultiPlotPage* page : plotWindow->pages() ) + for ( RiuMultiPlotPage* page : plotBook->pages() ) { if ( pagesToUpdate.count( page ) > 0 ) pagesToUpdate.erase( page ); } - - const bool regeneratePages = true; - plotWindow->performUpdate( regeneratePages ); - updatedPlotWindows.insert( plotWindow ); } + plotBook->performUpdate( updateType ); } for ( auto& [page, updateType] : pagesToUpdate ) diff --git a/ApplicationLibCode/Application/RiaPlotWindowRedrawScheduler.h b/ApplicationLibCode/Application/RiaPlotWindowRedrawScheduler.h index c9f5a249f0..9e29d575f9 100644 --- a/ApplicationLibCode/Application/RiaPlotWindowRedrawScheduler.h +++ b/ApplicationLibCode/Application/RiaPlotWindowRedrawScheduler.h @@ -40,7 +40,9 @@ class RiaPlotWindowRedrawScheduler : public QObject public: static RiaPlotWindowRedrawScheduler* instance(); - void scheduleMultiPlotWindowUpdate( RiuMultiPlotBook* plotWindow ); + void scheduleMultiPlotBookUpdate( + RiuMultiPlotBook* plotWindow, + RiaDefines::MultiPlotPageUpdateType updateType = RiaDefines::MultiPlotPageUpdateType::ALL ); void scheduleMultiPlotPageUpdate( RiuMultiPlotPage* plotWindow, RiaDefines::MultiPlotPageUpdateType updateType = RiaDefines::MultiPlotPageUpdateType::ALL ); @@ -59,9 +61,9 @@ private: private: std::map, RiaDefines::MultiPlotPageUpdateType> m_plotPagesToUpdate; + std::map, RiaDefines::MultiPlotPageUpdateType> m_plotBooksToUpdate; - std::vector> m_plotWidgetsToReplot; - std::vector> m_plotWindowsToUpdate; + std::vector> m_plotWidgetsToReplot; QScopedPointer m_plotWindowUpdateTimer; }; diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryCurvesForObjectsFeature.cpp b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryCurvesForObjectsFeature.cpp index 22101d9aaf..d76ed95680 100644 --- a/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryCurvesForObjectsFeature.cpp +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryCurvesForObjectsFeature.cpp @@ -57,8 +57,6 @@ void RicAppendSummaryCurvesForObjectsFeature::onActionTriggered( bool isChecked auto selectionType = sumAddressCollections.front()->contentType(); auto sourcePlots = summaryMultiPlot->summaryPlots(); - auto plotsForOneInstance = - RicAppendSummaryPlotsForObjectsFeature::plotsForOneInstanceOfObjectType( sourcePlots, selectionType ); std::vector pdmObjects; for ( auto summaryAdrCollection : sumAddressCollections ) @@ -70,8 +68,6 @@ void RicAppendSummaryCurvesForObjectsFeature::onActionTriggered( bool isChecked { plot->handleDroppedObjects( pdmObjects ); } - - summaryMultiPlot->loadDataAndUpdate(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimDataSourceSteppingTools.cpp b/ApplicationLibCode/ProjectDataModel/RimDataSourceSteppingTools.cpp index 73ff2ed466..6a8d88a6a7 100644 --- a/ApplicationLibCode/ProjectDataModel/RimDataSourceSteppingTools.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimDataSourceSteppingTools.cpp @@ -29,7 +29,8 @@ //-------------------------------------------------------------------------------------------------- void RimDataSourceSteppingTools::modifyCurrentIndex( caf::PdmValueField* valueField, const QList& options, - int indexOffset ) + int indexOffset, + bool notifyChange ) { if ( valueField && !options.isEmpty() ) { @@ -65,7 +66,7 @@ void RimDataSourceSteppingTools::modifyCurrentIndex( caf::PdmValueField* { QVariant newValue = options[nextIndex].value(); valueField->setFromQVariant( newValue ); - valueField->uiCapability()->notifyFieldChanged( currentValue, newValue ); + if ( notifyChange ) valueField->uiCapability()->notifyFieldChanged( currentValue, newValue ); } } } diff --git a/ApplicationLibCode/ProjectDataModel/RimDataSourceSteppingTools.h b/ApplicationLibCode/ProjectDataModel/RimDataSourceSteppingTools.h index 3bb01edb0b..cf38740123 100644 --- a/ApplicationLibCode/ProjectDataModel/RimDataSourceSteppingTools.h +++ b/ApplicationLibCode/ProjectDataModel/RimDataSourceSteppingTools.h @@ -31,7 +31,8 @@ class RimDataSourceSteppingTools public: static void modifyCurrentIndex( caf::PdmValueField* valueField, const QList& options, - int indexOffset ); + int indexOffset, + bool notifyChange = true ); static bool updateAddressIfMatching( const QVariant& oldValue, const QVariant& newValue, diff --git a/ApplicationLibCode/ProjectDataModel/RimMultiPlot.cpp b/ApplicationLibCode/ProjectDataModel/RimMultiPlot.cpp index f86f3dd530..a9e3b8d3a5 100644 --- a/ApplicationLibCode/ProjectDataModel/RimMultiPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimMultiPlot.cpp @@ -176,6 +176,7 @@ QString RimMultiPlot::multiPlotTitle() const void RimMultiPlot::setMultiPlotTitle( const QString& title ) { m_plotWindowTitle = title; + if ( !m_viewer.isNull() ) m_viewer->setPlotTitle( title ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimMultiPlot.h b/ApplicationLibCode/ProjectDataModel/RimMultiPlot.h index 2cae684794..83b02ca3a9 100644 --- a/ApplicationLibCode/ProjectDataModel/RimMultiPlot.h +++ b/ApplicationLibCode/ProjectDataModel/RimMultiPlot.h @@ -72,8 +72,9 @@ public: virtual void removePlotNoUpdate( RimPlot* plot ); virtual void updateAfterPlotRemove(); - void deleteAllPlots() override; - void updatePlots(); + void deleteAllPlots() override; + void updatePlots(); + virtual void updatePlotWindowTitle(); size_t plotCount() const override; size_t plotIndex( const RimPlot* plot ) const; @@ -136,8 +137,7 @@ protected: void updateZoom(); void recreatePlotWidgets(); - virtual void updatePlotWindowTitle(); - void onPlotAdditionOrRemoval(); + void onPlotAdditionOrRemoval(); bool isMouseCursorInsidePlot(); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.cpp index 0c486cfb3a..f2fd55e5ab 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.cpp @@ -131,6 +131,16 @@ RimSummaryMultiPlot::RimSummaryMultiPlot() m_appendPrevPlot.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); m_appendPrevPlot.uiCapability()->setUiIconFromResourceString( ":/AppendPrev.png" ); + CAF_PDM_InitField( &m_appendNextCurve, "AppendNextCurve", false, "", "", "Step Next and Add Curve to Plot" ); + m_appendNextCurve.xmlCapability()->disableIO(); + m_appendNextCurve.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); + m_appendNextCurve.uiCapability()->setUiIconFromResourceString( ":/AppendNextCurve.png" ); + + CAF_PDM_InitField( &m_appendPrevCurve, "AppendPrevCurve", false, "", "", "Step Previous and Add Curve to Plot" ); + m_appendPrevCurve.xmlCapability()->disableIO(); + m_appendPrevCurve.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() ); + m_appendPrevCurve.uiCapability()->setUiIconFromResourceString( ":/AppendPrevCurve.png" ); + CAF_PDM_InitField( &m_linkSubPlotAxes, "LinkSubPlotAxes", true, "Link Sub Plot Axes" ); CAF_PDM_InitField( &m_autoAdjustAppearance, "AutoAdjustAppearance", false, "Auto Adjust Appearance" ); @@ -408,6 +418,18 @@ void RimSummaryMultiPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedFi int stepDirection = -1; appendSubPlotByStepping( stepDirection ); } + else if ( changedField == &m_appendNextCurve ) + { + m_appendNextCurve = false; + int stepDirection = 1; + appendCurveByStepping( stepDirection ); + } + else if ( changedField == &m_appendPrevCurve ) + { + m_appendPrevCurve = false; + int stepDirection = -1; + appendCurveByStepping( stepDirection ); + } else if ( changedField == &m_autoAdjustAppearance ) { checkAndApplyAutoAppearance(); @@ -526,6 +548,9 @@ std::vector RimSummaryMultiPlot::fieldsToShowInToolbar() toolBarFields.push_back( &m_appendPrevPlot ); toolBarFields.push_back( &m_appendNextPlot ); + toolBarFields.push_back( &m_appendPrevCurve ); + toolBarFields.push_back( &m_appendNextCurve ); + auto multiFields = RimMultiPlot::fieldsToShowInToolbar(); toolBarFields.insert( std::end( toolBarFields ), std::begin( multiFields ), std::end( multiFields ) ); @@ -1069,6 +1094,44 @@ void RimSummaryMultiPlot::appendSubPlotByStepping( int direction ) RiuPlotMainWindowTools::refreshToolbars(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryMultiPlot::appendCurveByStepping( int direction ) +{ + for ( auto plot : summaryPlots() ) + { + std::vector addresses; + + for ( auto curve : plot->allCurves( RimSummaryDataSourceStepping::Axis::Y_AXIS ) ) + { + auto address = curve->summaryAddressY(); + auto sumCase = curve->summaryCaseY(); + address = m_sourceStepping->stepAddress( address, direction ); + addresses.push_back( RimSummaryAddress::wrapFileReaderAddress( address, sumCase->caseId() ) ); + } + + for ( auto curveSet : plot->curveSets() ) + { + auto address = curveSet->summaryAddress(); + auto sumEns = curveSet->summaryCaseCollection(); + address = m_sourceStepping->stepAddress( address, direction ); + addresses.push_back( RimSummaryAddress::wrapFileReaderAddress( address, -1, sumEns->ensembleId() ) ); + } + + plot->handleDroppedObjects( addresses ); + + for ( auto adr : addresses ) + { + delete adr; + } + } + + m_sourceStepping->updateStepIndex( direction ); + + RiuPlotMainWindowTools::refreshToolbars(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.h index 081ce11015..0ed590c1fb 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.h @@ -79,6 +79,7 @@ public: void removePlotNoUpdate( RimPlot* plot ) override; void updateAfterPlotRemove() override; + void updatePlotWindowTitle() override; std::vector fieldsToShowInToolbar() override; @@ -118,13 +119,13 @@ private: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void populateNameHelper( RimSummaryPlotNameHelper* nameHelper ); - void updatePlotWindowTitle() override; void computeAggregatedAxisRange(); void updateSourceStepper(); void duplicate(); void appendSubPlotByStepping( int direction ); + void appendCurveByStepping( int direction ); void analyzePlotsAndAdjustAppearanceSettings(); @@ -142,6 +143,9 @@ private: caf::PdmField m_appendNextPlot; caf::PdmField m_appendPrevPlot; + caf::PdmField m_appendNextCurve; + caf::PdmField m_appendPrevCurve; + caf::PdmField> m_axisRangeAggregation; caf::PdmChildField m_sourceStepping; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index dffd3f1c9b..b1f389637c 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -2043,20 +2043,60 @@ std::pair> RimSummaryPlot::handleSummaryAddre if ( summaryAddr->isEnsemble() ) { + std::map> dataVectorMap; + + for ( auto& curve : curveSets() ) + { + const auto curveAddress = curve->summaryAddress(); + dataVectorMap[curveAddress].insert( curve->summaryCaseCollection() ); + } + auto ensemble = RiaSummaryTools::ensembleById( summaryAddr->ensembleId() ); if ( ensemble ) { - addNewEnsembleCurveY( summaryAddr->address(), ensemble ); - newCurves++; + RifEclipseSummaryAddress droppedAddress = summaryAddr->address(); + + bool skipAddress = false; + + if ( dataVectorMap.count( droppedAddress ) > 0 ) + { + skipAddress = ( dataVectorMap[droppedAddress].count( ensemble ) > 0 ); + } + + if ( !skipAddress ) + { + addNewEnsembleCurveY( droppedAddress, ensemble ); + newCurves++; + } } } else { + std::map> dataVectorMap; + + for ( auto& curve : summaryCurves() ) + { + const auto curveAddress = curve->summaryAddressY(); + dataVectorMap[curveAddress].insert( curve->summaryCaseY() ); + } + auto summaryCase = RiaSummaryTools::summaryCaseById( summaryAddr->caseId() ); if ( summaryCase ) { - curves.push_back( addNewCurveY( summaryAddr->address(), summaryCase ) ); - newCurves++; + RifEclipseSummaryAddress droppedAddress = summaryAddr->address(); + + bool skipAddress = false; + + if ( dataVectorMap.count( droppedAddress ) > 0 ) + { + skipAddress = ( dataVectorMap[droppedAddress].count( summaryCase ) > 0 ); + } + + if ( !skipAddress ) + { + curves.push_back( addNewCurveY( droppedAddress, summaryCase ) ); + newCurves++; + } } } return { newCurves, curves }; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp index 6cb7cefa58..ae444d369a 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp @@ -516,6 +516,7 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi( const caf::PdmFieldHandle* if ( summaryMultiPlot ) { summaryMultiPlot->updatePlots(); + summaryMultiPlot->updatePlotWindowTitle(); RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow(); mainPlotWindow->updateMultiPlotToolBar(); } @@ -883,11 +884,11 @@ bool RimSummaryPlotSourceStepping::isYAxisStepping() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryPlotSourceStepping::modifyCurrentIndex( caf::PdmValueField* valueField, int indexOffset ) +void RimSummaryPlotSourceStepping::modifyCurrentIndex( caf::PdmValueField* valueField, int indexOffset, bool notifyChange ) { bool useOptionsOnly; QList options = calculateValueOptions( valueField, &useOptionsOnly ); - RimDataSourceSteppingTools::modifyCurrentIndex( valueField, options, indexOffset ); + RimDataSourceSteppingTools::modifyCurrentIndex( valueField, options, indexOffset, notifyChange ); } //-------------------------------------------------------------------------------------------------- @@ -1285,3 +1286,15 @@ RimSummaryCaseCollection* RimSummaryPlotSourceStepping::stepEnsemble( int direct return m_ensemble; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlotSourceStepping::updateStepIndex( int direction ) +{ + caf::PdmValueField* valueField = fieldToModify(); + if ( !valueField ) return; + + bool notifyChange = false; + modifyCurrentIndex( valueField, direction, notifyChange ); +} diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.h index fdff19ac21..0df92a707f 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.h @@ -75,6 +75,8 @@ public: RimSummaryPlotSourceStepping::SourceSteppingDimension stepDimension() const; + void updateStepIndex( int direction ); + private: void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; @@ -102,7 +104,7 @@ private: bool isXAxisStepping() const; bool isYAxisStepping() const; - void modifyCurrentIndex( caf::PdmValueField* valueField, int indexOffset ); + void modifyCurrentIndex( caf::PdmValueField* valueField, int indexOffset, bool notifyChange = true ); std::vector summaryCasesForSourceStepping(); diff --git a/ApplicationLibCode/UserInterface/RiuMultiPlotBook.cpp b/ApplicationLibCode/UserInterface/RiuMultiPlotBook.cpp index 5890b38e4d..62e9c96253 100644 --- a/ApplicationLibCode/UserInterface/RiuMultiPlotBook.cpp +++ b/ApplicationLibCode/UserInterface/RiuMultiPlotBook.cpp @@ -218,19 +218,6 @@ void RiuMultiPlotBook::removeAllPlots() void RiuMultiPlotBook::setPlotTitle( const QString& plotTitle ) { m_plotTitle = plotTitle; - for ( int i = 0; i < m_pages.size(); ++i ) - { - int pageIndex = i + 1; - int pageCount = (int)m_pages.size(); - if ( pageCount > pageIndex ) - { - m_pages[i]->setPlotTitle( QString( "%1 %2/%3" ).arg( m_plotTitle ).arg( i + 1 ).arg( m_pages.size() ) ); - } - else - { - m_pages[i]->setPlotTitle( QString( "%1" ).arg( m_plotTitle ) ); - } - } } //-------------------------------------------------------------------------------------------------- @@ -266,6 +253,7 @@ void RiuMultiPlotBook::scheduleTitleUpdate() { page->scheduleUpdate( RiaDefines::MultiPlotPageUpdateType::TITLE ); } + scheduleUpdate( RiaDefines::MultiPlotPageUpdateType::TITLE ); } //-------------------------------------------------------------------------------------------------- @@ -333,9 +321,9 @@ void RiuMultiPlotBook::setPagePreviewModeEnabled( bool previewMode ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMultiPlotBook::scheduleUpdate() +void RiuMultiPlotBook::scheduleUpdate( RiaDefines::MultiPlotPageUpdateType whatToUpdate ) { - RiaPlotWindowRedrawScheduler::instance()->scheduleMultiPlotWindowUpdate( this ); + RiaPlotWindowRedrawScheduler::instance()->scheduleMultiPlotBookUpdate( this, whatToUpdate ); } //-------------------------------------------------------------------------------------------------- @@ -410,8 +398,8 @@ void RiuMultiPlotBook::showEvent( QShowEvent* event ) { m_goToPageAfterUpdate = true; QWidget::showEvent( event ); - const bool regeneratePages = false; - performUpdate( regeneratePages ); + + performUpdate( RiaDefines::MultiPlotPageUpdateType::ALL ); if ( m_previewMode ) { applyPagePreviewBookSize( width() ); @@ -501,16 +489,22 @@ bool RiuMultiPlotBook::showYAxis( int row, int column ) const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMultiPlotBook::performUpdate( bool regeneratePages ) +void RiuMultiPlotBook::performUpdate( RiaDefines::MultiPlotPageUpdateType whatToUpdate ) { if ( !m_plotDefinition || !m_plotDefinition->isValid() ) return; applyLook(); - if ( regeneratePages || m_pages.size() == 0 ) + if ( ( ( whatToUpdate & RiaDefines::MultiPlotPageUpdateType::PLOT ) == RiaDefines::MultiPlotPageUpdateType::PLOT ) || + m_pages.size() == 0 ) { deleteAllPages(); createPages(); } + else if ( ( whatToUpdate & RiaDefines::MultiPlotPageUpdateType::TITLE ) == RiaDefines::MultiPlotPageUpdateType::TITLE ) + { + updatePageTitles(); + } + updateGeometry(); RimSummaryMultiPlot* multiPlot = dynamic_cast( m_plotDefinition.p() ); @@ -524,6 +518,27 @@ void RiuMultiPlotBook::performUpdate( bool regeneratePages ) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMultiPlotBook::updatePageTitles() +{ + if ( m_pages.isEmpty() ) return; + + if ( m_pages.size() > 1 ) + { + for ( int i = 0; i < m_pages.size(); ++i ) + { + int pageNumber = i + 1; + m_pages[i]->setPlotTitle( QString( "%1 %2/%3" ).arg( m_plotTitle ).arg( pageNumber ).arg( m_pages.size() ) ); + } + } + else + { + m_pages[0]->setPlotTitle( QString( "%1" ).arg( m_plotTitle ) ); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -603,14 +618,8 @@ void RiuMultiPlotBook::createPages() } // Set page numbers in title when there's more than one page - if ( m_pages.size() > 1 ) - { - for ( int i = 0; i < m_pages.size(); ++i ) - { - int pageNumber = i + 1; - m_pages[i]->setPlotTitle( QString( "%1 %2/%3" ).arg( m_plotTitle ).arg( pageNumber ).arg( m_pages.size() ) ); - } - } + updatePageTitles(); + adjustBookFrame(); } diff --git a/ApplicationLibCode/UserInterface/RiuMultiPlotBook.h b/ApplicationLibCode/UserInterface/RiuMultiPlotBook.h index 4cbfad4a06..ba7b979eec 100644 --- a/ApplicationLibCode/UserInterface/RiuMultiPlotBook.h +++ b/ApplicationLibCode/UserInterface/RiuMultiPlotBook.h @@ -80,7 +80,7 @@ public: bool pagePreviewModeEnabled() const; void setPagePreviewModeEnabled( bool previewMode ); - void scheduleUpdate(); + void scheduleUpdate( RiaDefines::MultiPlotPageUpdateType whatToUpdate = RiaDefines::MultiPlotPageUpdateType::ALL ); void scheduleReplotOfAllPlots(); void renderTo( QPaintDevice* painter ); @@ -123,6 +123,8 @@ protected: const QList>& pages() const; + void updatePageTitles(); + private: RiuMultiPlotPage* createPage(); void deleteAllPages(); @@ -131,7 +133,7 @@ private: void changeCurrentPage( int pageNumber ); private slots: - virtual void performUpdate( bool regeneratePages ); + virtual void performUpdate( RiaDefines::MultiPlotPageUpdateType updateType ); protected: friend class RiaPlotWindowRedrawScheduler; diff --git a/ApplicationLibCode/UserInterface/RiuSummaryMultiPlotBook.cpp b/ApplicationLibCode/UserInterface/RiuSummaryMultiPlotBook.cpp index 763290d8c9..0b945c6b46 100644 --- a/ApplicationLibCode/UserInterface/RiuSummaryMultiPlotBook.cpp +++ b/ApplicationLibCode/UserInterface/RiuSummaryMultiPlotBook.cpp @@ -84,14 +84,7 @@ void RiuSummaryMultiPlotBook::createPages() } // Set page numbers in title when there's more than one page - if ( m_pages.size() > 1 ) - { - for ( int i = 0; i < m_pages.size(); ++i ) - { - int pageNumber = i + 1; - m_pages[i]->setPlotTitle( QString( "%1 %2/%3" ).arg( m_plotTitle ).arg( pageNumber ).arg( m_pages.size() ) ); - } - } + updatePageTitles(); adjustBookFrame(); }