From eb6b0997c80e5c6a08841c8488eea8fc3c4df4ca Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 1 Dec 2017 15:15:43 +0100 Subject: [PATCH] #2170 Summary Cross Plot : Improve update and visibility of UI when stepping --- .../Summary/RimSummaryCurveCollection.cpp | 2 +- .../Summary/RimSummaryPlotSourceStepping.cpp | 14 +++++- .../UserInterface/RiuMainPlotWindow.cpp | 46 ++++++++++++------- .../UserInterface/RiuMainPlotWindow.h | 2 + .../cafPdmUiToolBarEditor.cpp | 27 +++++++++++ .../cafUserInterface/cafPdmUiToolBarEditor.h | 1 + 6 files changed, 73 insertions(+), 19 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp index cf076ca72e..e9207eb2c6 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp @@ -353,7 +353,7 @@ void RimSummaryCurveCollection::defineUiOrdering(QString uiConfigName, caf::PdmU } { - auto group = uiOrdering.addNewGroup("Union Source Stepping"); + auto group = uiOrdering.addNewGroup("XY Union Source Stepping"); m_unionSourceStepping()->uiOrdering(uiConfigName, *group); } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp index 877c8a1f38..9cf57e1d29 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp @@ -27,10 +27,12 @@ #include "RimProject.h" #include "RimSummaryCase.h" #include "RimSummaryCaseMainCollection.h" +#include "RimSummaryCrossPlot.h" #include "RimSummaryCurve.h" #include "RimSummaryCurveCollection.h" #include "RimSummaryPlot.h" +#include "RiuMainPlotWindow.h" #include "cafPdmUiComboBoxEditor.h" #include "cafPdmUiItem.h" #include "cafPdmUiListEditor.h" @@ -449,8 +451,18 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi(const caf::PdmFieldHandle* c this->firstAncestorOrThisOfTypeAsserted(summaryPlot); summaryPlot->updatePlotTitle(); - summaryPlot->loadDataAndUpdate(); + + RimSummaryCrossPlot* summaryCrossPlot = dynamic_cast(summaryPlot); + if (summaryCrossPlot) + { + // Trigger update of curve collection (and summary toolbar in main window), as the visibility of combo boxes might + // have been changed due to the updates in this function + curveCollection->updateConnectedEditors(); + + RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); + mainPlotWindow->updateSummaryPlotToolBar(); + } } } diff --git a/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp b/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp index ce1a4b5eae..8eb1b5798d 100644 --- a/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp @@ -416,6 +416,34 @@ void RiuMainPlotWindow::addToTemporaryWidgets(QWidget* widget) m_temporaryWidgets.push_back(widget); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMainPlotWindow::updateSummaryPlotToolBar() +{ + RimSummaryPlot* summaryPlot = dynamic_cast(m_activePlotViewWindow); + if (summaryPlot) + { + std::vector toolBarFields; + toolBarFields = summaryPlot->summaryCurveCollection()->fieldsToShowInToolbar(); + + if (!m_summaryPlotToolBarEditor->isEditorDataValid(toolBarFields)) + { + m_summaryPlotToolBarEditor->setFields(toolBarFields); + m_summaryPlotToolBarEditor->updateUi(); + } + + m_summaryPlotToolBarEditor->show(); + } + else + { + m_summaryPlotToolBarEditor->clear(); + + m_summaryPlotToolBarEditor->hide(); + } + +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -527,23 +555,7 @@ 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(); - } + updateSummaryPlotToolBar(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuMainPlotWindow.h b/ApplicationCode/UserInterface/RiuMainPlotWindow.h index f6e97c2542..697a0f7fc7 100644 --- a/ApplicationCode/UserInterface/RiuMainPlotWindow.h +++ b/ApplicationCode/UserInterface/RiuMainPlotWindow.h @@ -83,6 +83,8 @@ public: void addToTemporaryWidgets(QWidget* widget); + void updateSummaryPlotToolBar(); + protected: virtual void closeEvent(QCloseEvent* event); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiToolBarEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiToolBarEditor.cpp index ae7c1d3e1c..1647d760d3 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiToolBarEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiToolBarEditor.cpp @@ -73,6 +73,33 @@ PdmUiToolBarEditor::~PdmUiToolBarEditor() clear(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool PdmUiToolBarEditor::isEditorDataValid(const std::vector& fields) const +{ + if (m_fields.size() == fields.size() && + m_fieldViews.size() == fields.size()) + { + bool equalContent = true; + + for (size_t i = 0; i < m_fields.size(); i++) + { + if (m_fields[i] != fields[i]) + { + equalContent = false; + } + } + + if (equalContent) + { + return true; + } + } + + return false; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiToolBarEditor.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiToolBarEditor.h index aa3285b123..fc9a4f4e4f 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiToolBarEditor.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiToolBarEditor.h @@ -61,6 +61,7 @@ public: PdmUiToolBarEditor(const QString& title, QMainWindow* mainWindow); ~PdmUiToolBarEditor(); + bool isEditorDataValid(const std::vector& fields) const; void setFields(std::vector& fields); void clear();