diff --git a/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp b/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp index e8942c8ce1..ce1a4b5eae 100644 --- a/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp @@ -121,7 +121,7 @@ void RiuMainPlotWindow::cleanupGuiBeforeProjectClose() cleanUpTemporaryWidgets(); - m_summaryPlotToolBar->clear(); + m_summaryPlotToolBarEditor->clear(); setWindowTitle("Plots - ResInsight"); } @@ -307,7 +307,8 @@ void RiuMainPlotWindow::createToolBars() } } - m_summaryPlotToolBar = new caf::PdmUiToolBarEditor("Summary Plot", this); + m_summaryPlotToolBarEditor = new caf::PdmUiToolBarEditor("Summary Plot", this); + m_summaryPlotToolBarEditor->hide(); } //-------------------------------------------------------------------------------------------------- @@ -525,6 +526,24 @@ void RiuMainPlotWindow::slotSubWindowActivated(QMdiSubWindow* subWindow) m_activePlotViewWindow = viewWindow; } + + RimSummaryPlot* summaryPlot = dynamic_cast(viewWindow); + if (summaryPlot) + { + std::vector toolBarFields; + toolBarFields = summaryPlot->summaryCurveCollection()->fieldsToShowInToolbar(); + + m_summaryPlotToolBarEditor->setFields(toolBarFields); + m_summaryPlotToolBarEditor->updateUi(); + + m_summaryPlotToolBarEditor->show(); + } + else + { + m_summaryPlotToolBarEditor->clear(); + + m_summaryPlotToolBarEditor->hide(); + } } //-------------------------------------------------------------------------------------------------- @@ -598,19 +617,6 @@ void RiuMainPlotWindow::selectedObjectsChanged() } m_pdmUiPropertyView->showProperties(firstSelectedObject); - std::vector toolBarFields; - if (firstSelectedObject) - { - RimSummaryPlot* summaryPlot = nullptr; - firstSelectedObject->firstAncestorOrThisOfType(summaryPlot); - if (summaryPlot) - { - toolBarFields = summaryPlot->summaryCurveCollection()->fieldsToShowInToolbar(); - } - } - m_summaryPlotToolBar->setFields(toolBarFields); - m_summaryPlotToolBar->updateUi(); - if (uiItems.size() == 1) { // Find the reservoir view or the Plot that the selected item is within diff --git a/ApplicationCode/UserInterface/RiuMainPlotWindow.h b/ApplicationCode/UserInterface/RiuMainPlotWindow.h index d28fbe1a45..f6e97c2542 100644 --- a/ApplicationCode/UserInterface/RiuMainPlotWindow.h +++ b/ApplicationCode/UserInterface/RiuMainPlotWindow.h @@ -119,7 +119,7 @@ private: QMenu* m_windowMenu; caf::PdmUiTreeView* m_projectTreeView; - caf::PdmUiToolBarEditor* m_summaryPlotToolBar; + caf::PdmUiToolBarEditor* m_summaryPlotToolBarEditor; std::unique_ptr m_dragDropInterface; caf::PdmUiPropertyView* m_pdmUiPropertyView; diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiToolBarEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiToolBarEditor.cpp index 716f6ea28c..ae7c1d3e1c 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiToolBarEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiToolBarEditor.cpp @@ -185,4 +185,26 @@ void PdmUiToolBarEditor::clear() m_actions.clear(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void PdmUiToolBarEditor::show() +{ + if (m_toolbar) + { + m_toolbar->show(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void PdmUiToolBarEditor::hide() +{ + if (m_toolbar) + { + m_toolbar->hide(); + } +} + } // end namespace caf diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiToolBarEditor.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiToolBarEditor.h index 6d9684bb77..aa3285b123 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiToolBarEditor.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiToolBarEditor.h @@ -63,6 +63,9 @@ public: void setFields(std::vector& fields); void clear(); + + void show(); + void hide(); private: virtual void configureAndUpdateUi(const QString& uiConfigName) override;