From 9391453c2c48e600f57db3e7c3f7a89771a0e030 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Thu, 17 Sep 2020 10:02:58 +0200 Subject: [PATCH] Better fix for legend and title in sub plots and summary dialog --- .../AnalysisPlots/RimAnalysisPlot.cpp | 2 +- .../RimAnalysisPlotCollection.cpp | 1 + .../RimCorrelationMatrixPlot.cpp | 4 +++- .../CorrelationPlots/RimCorrelationPlot.cpp | 3 ++- .../RimCorrelationPlotCollection.cpp | 1 + .../RimCorrelationReportPlot.cpp | 2 +- .../RimParameterResultCrossPlot.cpp | 13 +++++++---- .../GridCrossPlots/RimGridCrossPlot.cpp | 2 +- .../RimGridCrossPlotCollection.cpp | 1 + .../ProjectDataModel/RimDepthTrackPlot.cpp | 2 +- .../ProjectDataModel/RimMultiPlot.cpp | 23 ++++++++++--------- .../ProjectDataModel/RimMultiPlot.h | 14 ++++++----- ApplicationCode/ProjectDataModel/RimPlot.cpp | 17 +++++++++++--- ApplicationCode/ProjectDataModel/RimPlot.h | 2 ++ .../ProjectDataModel/RimPltPlotCollection.cpp | 4 ++-- .../ProjectDataModel/RimRftPlotCollection.cpp | 4 ++-- .../ProjectDataModel/RimViewWindow.cpp | 1 + .../Summary/RimSummaryCrossPlotCollection.cpp | 1 + .../Summary/RimSummaryPlot.cpp | 6 ++--- .../Summary/RimSummaryPlotCollection.cpp | 1 + ApplicationCode/UserInterface/RiuDragDrop.cpp | 4 ++++ .../UserInterface/RiuMultiPlotBook.cpp | 10 ++++---- .../UserInterface/RiuMultiPlotPage.cpp | 2 +- .../UserInterface/RiuQwtPlotWidget.cpp | 2 +- .../UserInterface/RiuQwtPlotWidget.h | 2 +- .../UserInterface/RiuSummaryQwtPlot.cpp | 2 +- 26 files changed, 79 insertions(+), 47 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlot.cpp b/ApplicationCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlot.cpp index 186934e30a..0e41e9b301 100644 --- a/ApplicationCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlot.cpp +++ b/ApplicationCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlot.cpp @@ -1646,7 +1646,7 @@ void RimAnalysisPlot::updatePlotTitle() { QString plotTitle = description(); m_plotWidget->setPlotTitle( plotTitle ); - m_plotWidget->setPlotTitleEnabled( m_showPlotTitle ); + m_plotWidget->setPlotTitleEnabled( m_showPlotTitle && !isSubPlot() ); m_plotWidget->scheduleReplot(); } } diff --git a/ApplicationCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlotCollection.cpp b/ApplicationCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlotCollection.cpp index 8a22dd054b..bc7c1c9855 100644 --- a/ApplicationCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlotCollection.cpp +++ b/ApplicationCode/ProjectDataModel/AnalysisPlots/RimAnalysisPlotCollection.cpp @@ -192,4 +192,5 @@ void RimAnalysisPlotCollection::insertPlot( RimAnalysisPlot* analysisPlot, size_ void RimAnalysisPlotCollection::removePlot( RimAnalysisPlot* analysisPlot ) { m_analysisPlots.removeChildObject( analysisPlot ); + updateAllRequiredEditors(); } diff --git a/ApplicationCode/ProjectDataModel/CorrelationPlots/RimCorrelationMatrixPlot.cpp b/ApplicationCode/ProjectDataModel/CorrelationPlots/RimCorrelationMatrixPlot.cpp index a5de9a5be8..29f4f9d6d9 100644 --- a/ApplicationCode/ProjectDataModel/CorrelationPlots/RimCorrelationMatrixPlot.cpp +++ b/ApplicationCode/ProjectDataModel/CorrelationPlots/RimCorrelationMatrixPlot.cpp @@ -176,6 +176,8 @@ RimCorrelationMatrixPlot::RimCorrelationMatrixPlot() m_legendConfig->setColorLegend( RimRegularLegendConfig::mapToColorLegend( RimRegularLegendConfig::ColorRangesType::CORRELATION ) ); + setLegendsVisible( false ); + this->uiCapability()->setUiTreeChildrenHidden( true ); m_selectMultipleVectors = true; } @@ -661,7 +663,7 @@ void RimCorrelationMatrixPlot::updatePlotTitle() if ( m_plotWidget ) { m_plotWidget->setPlotTitle( m_description ); - m_plotWidget->setPlotTitleEnabled( m_showPlotTitle ); + m_plotWidget->setPlotTitleEnabled( m_showPlotTitle && !isSubPlot() ); if ( isMdiWindow() ) { m_plotWidget->setPlotTitleFontSize( titleFontSize() ); diff --git a/ApplicationCode/ProjectDataModel/CorrelationPlots/RimCorrelationPlot.cpp b/ApplicationCode/ProjectDataModel/CorrelationPlots/RimCorrelationPlot.cpp index 5154e181a8..0c814fcdb8 100644 --- a/ApplicationCode/ProjectDataModel/CorrelationPlots/RimCorrelationPlot.cpp +++ b/ApplicationCode/ProjectDataModel/CorrelationPlots/RimCorrelationPlot.cpp @@ -89,6 +89,7 @@ RimCorrelationPlot::RimCorrelationPlot() m_selectedParametersList.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); m_selectedParametersList.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); + setLegendsVisible( false ); setDeletable( true ); } @@ -296,7 +297,7 @@ void RimCorrelationPlot::updatePlotTitle() .arg( timeStepString() ); } m_plotWidget->setPlotTitle( m_description ); - m_plotWidget->setPlotTitleEnabled( m_showPlotTitle ); + m_plotWidget->setPlotTitleEnabled( m_showPlotTitle && !isSubPlot() ); m_plotWidget->setPlotTitleFontSize( titleFontSize() ); } diff --git a/ApplicationCode/ProjectDataModel/CorrelationPlots/RimCorrelationPlotCollection.cpp b/ApplicationCode/ProjectDataModel/CorrelationPlots/RimCorrelationPlotCollection.cpp index d5ae8aa8bd..b69b26600d 100644 --- a/ApplicationCode/ProjectDataModel/CorrelationPlots/RimCorrelationPlotCollection.cpp +++ b/ApplicationCode/ProjectDataModel/CorrelationPlots/RimCorrelationPlotCollection.cpp @@ -192,6 +192,7 @@ void RimCorrelationPlotCollection::insertPlot( RimAbstractCorrelationPlot* plot, void RimCorrelationPlotCollection::removePlot( RimAbstractCorrelationPlot* plot ) { m_correlationPlots.removeChildObject( plot ); + updateAllRequiredEditors(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/CorrelationPlots/RimCorrelationReportPlot.cpp b/ApplicationCode/ProjectDataModel/CorrelationPlots/RimCorrelationReportPlot.cpp index bfe666a0f9..2f6258b5d9 100644 --- a/ApplicationCode/ProjectDataModel/CorrelationPlots/RimCorrelationReportPlot.cpp +++ b/ApplicationCode/ProjectDataModel/CorrelationPlots/RimCorrelationReportPlot.cpp @@ -84,7 +84,7 @@ RimCorrelationReportPlot::RimCorrelationReportPlot() m_correlationPlot->setLegendsVisible( false ); m_parameterResultCrossPlot = new RimParameterResultCrossPlot; - m_parameterResultCrossPlot->setLegendsVisible( false ); + m_parameterResultCrossPlot->setLegendsVisible( true ); this->uiCapability()->setUiTreeChildrenHidden( true ); diff --git a/ApplicationCode/ProjectDataModel/CorrelationPlots/RimParameterResultCrossPlot.cpp b/ApplicationCode/ProjectDataModel/CorrelationPlots/RimParameterResultCrossPlot.cpp index 8ab7327fa5..9bad9a16a8 100644 --- a/ApplicationCode/ProjectDataModel/CorrelationPlots/RimParameterResultCrossPlot.cpp +++ b/ApplicationCode/ProjectDataModel/CorrelationPlots/RimParameterResultCrossPlot.cpp @@ -166,10 +166,13 @@ void RimParameterResultCrossPlot::onLoadDataAndUpdate() if ( m_plotWidget && m_analyserOfSelectedCurveDefs ) { createPoints(); - QwtLegend* legend = new QwtLegend( m_plotWidget ); - m_plotWidget->insertLegend( legend, QwtPlot::RightLegend ); - m_plotWidget->setLegendFontSize( legendFontSize() ); - m_plotWidget->updateLegend(); + if ( m_showPlotLegends && !isSubPlot() ) + { + QwtLegend* legend = new QwtLegend( m_plotWidget ); + m_plotWidget->insertLegend( legend, QwtPlot::RightLegend ); + m_plotWidget->setLegendFontSize( legendFontSize() ); + m_plotWidget->updateLegend(); + } this->updateAxes(); this->updatePlotTitle(); @@ -307,6 +310,6 @@ void RimParameterResultCrossPlot::updatePlotTitle() .arg( timeStepString() ); } m_plotWidget->setPlotTitle( m_description ); - m_plotWidget->setPlotTitleEnabled( m_showPlotTitle ); + m_plotWidget->setPlotTitleEnabled( m_showPlotTitle && !isSubPlot() ); m_plotWidget->setPlotTitleFontSize( titleFontSize() ); } diff --git a/ApplicationCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.cpp b/ApplicationCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.cpp index 5b2d2d1f5a..46bd695930 100644 --- a/ApplicationCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.cpp +++ b/ApplicationCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.cpp @@ -634,7 +634,7 @@ void RimGridCrossPlot::updateCurveNamesAndPlotTitle() { QString plotTitle = this->createAutoName(); m_plotWidget->setPlotTitle( plotTitle ); - m_plotWidget->setPlotTitleEnabled( m_showPlotTitle ); + m_plotWidget->setPlotTitleEnabled( m_showPlotTitle && !isSubPlot() ); } updateMdiWindowTitle(); } diff --git a/ApplicationCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotCollection.cpp b/ApplicationCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotCollection.cpp index ea846e60a8..0103654a9f 100644 --- a/ApplicationCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotCollection.cpp +++ b/ApplicationCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotCollection.cpp @@ -83,4 +83,5 @@ void RimGridCrossPlotCollection::insertPlot( RimGridCrossPlot* plot, size_t inde void RimGridCrossPlotCollection::removePlot( RimGridCrossPlot* plot ) { m_gridCrossPlots.removeChildObject( plot ); + updateAllRequiredEditors(); } diff --git a/ApplicationCode/ProjectDataModel/RimDepthTrackPlot.cpp b/ApplicationCode/ProjectDataModel/RimDepthTrackPlot.cpp index e795b6492f..d18468d24d 100644 --- a/ApplicationCode/ProjectDataModel/RimDepthTrackPlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimDepthTrackPlot.cpp @@ -672,7 +672,7 @@ void RimDepthTrackPlot::onPlotAdditionOrRemoval() calculateAvailableDepthRange(); updateZoom(); updateSubPlotNames(); - updateConnectedEditors(); + updateAllRequiredEditors(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimMultiPlot.cpp b/ApplicationCode/ProjectDataModel/RimMultiPlot.cpp index 52d42aaf77..cbc1e76fd4 100644 --- a/ApplicationCode/ProjectDataModel/RimMultiPlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimMultiPlot.cpp @@ -183,14 +183,6 @@ void RimMultiPlot::setMultiPlotTitle( const QString& title ) m_plotWindowTitle = title; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimMultiPlot::addPlot( RimPlot* plot ) -{ - insertPlot( plot, m_plots.size() ); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -206,8 +198,6 @@ void RimMultiPlot::insertPlot( RimPlot* plot, size_t index ) m_viewer->insertPlot( plot->viewer(), index ); } plot->setShowWindow( true ); - plot->setLegendsVisible( false ); - plot->setPlotTitleVisible( false ); plot->updateAfterInsertingIntoMultiPlot(); onPlotAdditionOrRemoval(); @@ -484,7 +474,7 @@ void RimMultiPlot::onPlotAdditionOrRemoval() updateSubPlotNames(); updatePlotWindowTitle(); applyPlotWindowTitleToWidgets(); - updateConnectedEditors(); + updateAllRequiredEditors(); updateLayout(); RiuPlotMainWindowTools::refreshToolbars(); } @@ -499,6 +489,17 @@ void RimMultiPlot::onPlotsReordered( const caf::SignalEmitter* emitter ) loadDataAndUpdate(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimMultiPlot::onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, + std::vector& referringObjects ) +{ + updateSubPlotNames(); + recreatePlotWidgets(); + loadDataAndUpdate(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimMultiPlot.h b/ApplicationCode/ProjectDataModel/RimMultiPlot.h index 24c90d2bb3..9ed31edb6d 100644 --- a/ApplicationCode/ProjectDataModel/RimMultiPlot.h +++ b/ApplicationCode/ProjectDataModel/RimMultiPlot.h @@ -18,6 +18,7 @@ #pragma once +#include "RimAbstractPlotCollection.h" #include "RimPlotAxisPropertiesInterface.h" #include "RimPlotWindow.h" @@ -37,7 +38,7 @@ class RimPlot; -class RimMultiPlot : public RimPlotWindow +class RimMultiPlot : public RimPlotWindow, public RimTypedPlotCollection { CAF_PDM_HEADER_INIT; @@ -69,16 +70,15 @@ public: QString multiPlotTitle() const; void setMultiPlotTitle( const QString& title ); - void addPlot( RimPlot* plot ); - void insertPlot( RimPlot* plot, size_t index ); - void removePlot( RimPlot* plot ); + void insertPlot( RimPlot* plot, size_t index ) override; + void removePlot( RimPlot* plot ) override; void movePlotsToThis( const std::vector& plots, int insertAtPosition ); - size_t plotCount() const; + size_t plotCount() const override; size_t plotIndex( const RimPlot* plot ) const; RimPlot* plotByIndex( size_t index ) const; - std::vector plots() const; + std::vector plots() const override; std::vector visiblePlots() const; void updatePlotOrderFromGridWidget(); @@ -136,6 +136,8 @@ private: void doRenderWindowContent( QPaintDevice* paintDevice ) override; void onPlotAdditionOrRemoval(); void onPlotsReordered( const caf::SignalEmitter* emitter ); + void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, + std::vector& referringObjects ) override; protected: caf::PdmField m_showPlotWindowTitle; diff --git a/ApplicationCode/ProjectDataModel/RimPlot.cpp b/ApplicationCode/ProjectDataModel/RimPlot.cpp index 31fbf715bb..13290b4681 100644 --- a/ApplicationCode/ProjectDataModel/RimPlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimPlot.cpp @@ -140,9 +140,10 @@ void RimPlot::removeFromMdiAreaAndCollection() //-------------------------------------------------------------------------------------------------- void RimPlot::updateAfterInsertingIntoMultiPlot() { - updateLegend(); - updateAxes(); - updateLayout(); + loadDataAndUpdate(); + /* updateLegend(); + updateAxes(); + updateLayout(); */ } //-------------------------------------------------------------------------------------------------- @@ -281,3 +282,13 @@ void RimPlot::onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, { loadDataAndUpdate(); } + +//-------------------------------------------------------------------------------------------------- +/// Is this inside another plot window? +//-------------------------------------------------------------------------------------------------- +bool RimPlot::isSubPlot() const +{ + RimPlotWindow* parentPlotWindow = nullptr; + firstAncestorOfType( parentPlotWindow ); + return parentPlotWindow != nullptr; +} diff --git a/ApplicationCode/ProjectDataModel/RimPlot.h b/ApplicationCode/ProjectDataModel/RimPlot.h index d39500efaf..f0fccf83fd 100644 --- a/ApplicationCode/ProjectDataModel/RimPlot.h +++ b/ApplicationCode/ProjectDataModel/RimPlot.h @@ -91,6 +91,8 @@ public: void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, std::vector& referringObjects ) override; + bool isSubPlot() const; + protected: void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; diff --git a/ApplicationCode/ProjectDataModel/RimPltPlotCollection.cpp b/ApplicationCode/ProjectDataModel/RimPltPlotCollection.cpp index b78229d294..bf4018275c 100644 --- a/ApplicationCode/ProjectDataModel/RimPltPlotCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimPltPlotCollection.cpp @@ -223,8 +223,8 @@ void RimPltPlotCollection::addPlot( RimWellPltPlot* newPlot ) //-------------------------------------------------------------------------------------------------- void RimPltPlotCollection::removePlot( RimWellPltPlot* plot ) { - size_t index = m_pltPlots.index( plot ); - if ( index < m_pltPlots.size() ) m_pltPlots.erase( index ); + m_pltPlots.removeChildObject( plot ); + updateAllRequiredEditors(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimRftPlotCollection.cpp b/ApplicationCode/ProjectDataModel/RimRftPlotCollection.cpp index 4cfa928e4c..4a5284f14c 100644 --- a/ApplicationCode/ProjectDataModel/RimRftPlotCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimRftPlotCollection.cpp @@ -223,8 +223,8 @@ void RimRftPlotCollection::addPlot( RimWellRftPlot* newPlot ) //-------------------------------------------------------------------------------------------------- void RimRftPlotCollection::removePlot( RimWellRftPlot* plot ) { - size_t index = m_rftPlots.index( plot ); - if ( index < m_rftPlots.size() ) m_rftPlots.erase( index ); + m_rftPlots.removeChildObject( plot ); + updateAllRequiredEditors(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimViewWindow.cpp b/ApplicationCode/ProjectDataModel/RimViewWindow.cpp index 9e2b7f2058..734b9d26a7 100644 --- a/ApplicationCode/ProjectDataModel/RimViewWindow.cpp +++ b/ApplicationCode/ProjectDataModel/RimViewWindow.cpp @@ -93,6 +93,7 @@ void RimViewWindow::loadDataAndUpdate() { assignIdIfNecessary(); onLoadDataAndUpdate(); + updateUiIconFromToggleField(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCrossPlotCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCrossPlotCollection.cpp index 83618b8cb7..9bbc5affb0 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCrossPlotCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCrossPlotCollection.cpp @@ -108,6 +108,7 @@ void RimSummaryCrossPlotCollection::insertPlot( RimSummaryPlot* plot, size_t ind void RimSummaryCrossPlotCollection::removePlot( RimSummaryPlot* plot ) { m_summaryCrossPlots.removeChildObject( plot ); + updateAllRequiredEditors(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index 97818eb640..183439cbd1 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -588,7 +588,7 @@ void RimSummaryPlot::updatePlotTitle() { QString plotTitle = description(); m_plotWidget->setPlotTitle( plotTitle ); - m_plotWidget->setPlotTitleEnabled( m_showPlotTitle ); + m_plotWidget->setPlotTitleEnabled( m_showPlotTitle && !isSubPlot() ); m_plotWidget->scheduleReplot(); } } @@ -656,7 +656,7 @@ void RimSummaryPlot::updateLegend() { if ( m_plotWidget ) { - m_plotWidget->setLegendVisible( m_showPlotLegends ); + m_plotWidget->setInternalLegendVisible( m_showPlotLegends && !isSubPlot() ); } reattachAllCurves(); @@ -1559,7 +1559,7 @@ void RimSummaryPlot::onLoadDataAndUpdate() if ( m_plotWidget ) { - m_plotWidget->setLegendVisible( m_showPlotLegends ); + m_plotWidget->setInternalLegendVisible( m_showPlotLegends && !isSubPlot() ); m_plotWidget->setLegendFontSize( legendFontSize() ); m_plotWidget->updateLegend(); } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotCollection.cpp index 1db449cdf1..f98ee0be93 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotCollection.cpp @@ -145,4 +145,5 @@ void RimSummaryPlotCollection::insertPlot( RimSummaryPlot* summaryPlot, size_t i void RimSummaryPlotCollection::removePlot( RimSummaryPlot* summaryPlot ) { m_summaryPlots.removeChildObject( summaryPlot ); + updateAllRequiredEditors(); } diff --git a/ApplicationCode/UserInterface/RiuDragDrop.cpp b/ApplicationCode/UserInterface/RiuDragDrop.cpp index b993a2fcd7..88bd676b81 100644 --- a/ApplicationCode/UserInterface/RiuDragDrop.cpp +++ b/ApplicationCode/UserInterface/RiuDragDrop.cpp @@ -199,6 +199,10 @@ Qt::DropActions RiuDragDrop::supportedDropActions() const { return Qt::CopyAction; } + else if ( RiuTypedPdmObjects::containsTypedObjects( m_dragItems ) ) + { + // return Qt::CopyAction; + } return Qt::MoveAction; } diff --git a/ApplicationCode/UserInterface/RiuMultiPlotBook.cpp b/ApplicationCode/UserInterface/RiuMultiPlotBook.cpp index f9d1105887..57265475ef 100644 --- a/ApplicationCode/UserInterface/RiuMultiPlotBook.cpp +++ b/ApplicationCode/UserInterface/RiuMultiPlotBook.cpp @@ -191,11 +191,9 @@ void RiuMultiPlotBook::removePlot( RiuQwtPlotWidget* plotWidget ) //-------------------------------------------------------------------------------------------------- void RiuMultiPlotBook::removeAllPlots() { - auto plotWidgets = m_plotWidgets; - for ( RiuQwtPlotWidget* plotWidget : plotWidgets ) - { - removePlot( plotWidget ); - } + deleteAllPages(); + m_plotWidgets.clear(); + scheduleUpdate(); } //-------------------------------------------------------------------------------------------------- @@ -483,6 +481,7 @@ QList> RiuMultiPlotBook::visiblePlotWidgets() const QList> plotWidgets; for ( QPointer plotWidget : m_plotWidgets ) { + CAF_ASSERT( plotWidget ); if ( plotWidget->isChecked() ) { plotWidgets.push_back( plotWidget ); @@ -534,6 +533,7 @@ void RiuMultiPlotBook::createPages() row = 0; column = 0; } + CAF_ASSERT( plotWidgets[visibleIndex] ); page->addPlot( plotWidgets[visibleIndex] ); page->performUpdate(); } diff --git a/ApplicationCode/UserInterface/RiuMultiPlotPage.cpp b/ApplicationCode/UserInterface/RiuMultiPlotPage.cpp index ef9901bcb4..988358cf0a 100644 --- a/ApplicationCode/UserInterface/RiuMultiPlotPage.cpp +++ b/ApplicationCode/UserInterface/RiuMultiPlotPage.cpp @@ -155,7 +155,7 @@ void RiuMultiPlotPage::insertPlot( RiuQwtPlotWidget* plotWidget, size_t index ) m_subTitles.insert( static_cast( index ), subTitle ); RiuQwtPlotLegend* legend = nullptr; - if ( m_plotDefinition->legendsVisible() ) + if ( m_plotDefinition->legendsVisible() && plotWidget->plotDefinition()->legendsVisible() ) { legend = new RiuQwtPlotLegend( this ); int legendColumns = 1; diff --git a/ApplicationCode/UserInterface/RiuQwtPlotWidget.cpp b/ApplicationCode/UserInterface/RiuQwtPlotWidget.cpp index 3fb3cac95c..fd1e318418 100644 --- a/ApplicationCode/UserInterface/RiuQwtPlotWidget.cpp +++ b/ApplicationCode/UserInterface/RiuQwtPlotWidget.cpp @@ -290,7 +290,7 @@ void RiuQwtPlotWidget::setLegendFontSize( int fontSize ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuQwtPlotWidget::setLegendVisible( bool visible ) +void RiuQwtPlotWidget::setInternalLegendVisible( bool visible ) { if ( visible ) { diff --git a/ApplicationCode/UserInterface/RiuQwtPlotWidget.h b/ApplicationCode/UserInterface/RiuQwtPlotWidget.h index a7aa71ecef..24118a2921 100644 --- a/ApplicationCode/UserInterface/RiuQwtPlotWidget.h +++ b/ApplicationCode/UserInterface/RiuQwtPlotWidget.h @@ -91,7 +91,7 @@ public: void setPlotTitleFontSize( int titleFontSize ); void setLegendFontSize( int fontSize ); - void setLegendVisible( bool visible ); + void setInternalLegendVisible( bool visible ); QwtInterval axisRange( QwtPlot::Axis axis ) const; void setAxisRange( QwtPlot::Axis axis, double min, double max ); diff --git a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp index adf3c98d4f..3a0c5a5eae 100644 --- a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp +++ b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp @@ -131,7 +131,7 @@ RiuSummaryQwtPlot::RiuSummaryQwtPlot( RimSummaryPlot* plot, QWidget* parent /*= RiuQwtPlotTools::setCommonPlotBehaviour( this ); RiuQwtPlotTools::setDefaultAxes( this ); - setLegendVisible( true ); + setInternalLegendVisible( true ); } //--------------------------------------------------------------------------------------------------