From c488348168e6337601de87f9b70c501926be6487 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sun, 16 Dec 2018 09:45:52 +0100 Subject: [PATCH] #3835 Ensemble : Improve hos curve visibility is defined --- .../ProjectDataModel/RimPlotCurve.cpp | 50 +++++++++++++------ .../ProjectDataModel/RimPlotCurve.h | 3 ++ 2 files changed, 37 insertions(+), 16 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp index 5c64efa587..5feb88ef8a 100644 --- a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp @@ -218,19 +218,7 @@ void RimPlotCurve::setCustomName(const QString& customName) //-------------------------------------------------------------------------------------------------- void RimPlotCurve::updateCurveVisibility(bool updateParentPlot) { - bool isVisibleInPossibleParent = true; - - { - RimSummaryCurveCollection* summaryCurveCollection = nullptr; - this->firstAncestorOrThisOfType(summaryCurveCollection); - if (summaryCurveCollection) isVisibleInPossibleParent = summaryCurveCollection->isCurvesVisible(); - - RimEnsembleCurveSet* ensembleCurveSet = nullptr; - firstAncestorOrThisOfType(ensembleCurveSet); - if (ensembleCurveSet) isVisibleInPossibleParent = ensembleCurveSet->isCurvesVisible(); - } - - if (m_showCurve() && m_parentQwtPlot && isVisibleInPossibleParent) + if (canCurveBeAttached()) { m_qwtPlotCurve->attach(m_parentQwtPlot); } @@ -282,7 +270,7 @@ void RimPlotCurve::updateCurvePresentation(bool updatePlotLegendAndTitle) void RimPlotCurve::setParentQwtPlotAndReplot(QwtPlot* plot) { m_parentQwtPlot = plot; - if (m_showCurve && m_parentQwtPlot) + if (canCurveBeAttached()) { m_qwtPlotCurve->attach(m_parentQwtPlot); m_parentQwtPlot->replot(); @@ -295,7 +283,7 @@ void RimPlotCurve::setParentQwtPlotAndReplot(QwtPlot* plot) void RimPlotCurve::setParentQwtPlotNoReplot(QwtPlot* plot) { m_parentQwtPlot = plot; - if (m_showCurve && m_parentQwtPlot) + if (canCurveBeAttached()) { m_qwtPlotCurve->attach(m_parentQwtPlot); } @@ -331,7 +319,7 @@ void RimPlotCurve::detachQwtCurve() void RimPlotCurve::reattachQwtCurve() { detachQwtCurve(); - if (m_parentQwtPlot && m_showCurve) + if (canCurveBeAttached()) { m_qwtPlotCurve->attach(m_parentQwtPlot); } @@ -454,6 +442,36 @@ void RimPlotCurve::curveNameUiOrdering(caf::PdmUiOrdering& uiOrdering) uiOrdering.add(&m_curveName); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimPlotCurve::canCurveBeAttached() const +{ + if (!m_parentQwtPlot) + { + return false; + } + + if (!m_showCurve()) + { + return false; + } + + bool isVisibleInPossibleParent = true; + + { + RimSummaryCurveCollection* summaryCurveCollection = nullptr; + this->firstAncestorOrThisOfType(summaryCurveCollection); + if (summaryCurveCollection) isVisibleInPossibleParent = summaryCurveCollection->isCurvesVisible(); + + RimEnsembleCurveSet* ensembleCurveSet = nullptr; + firstAncestorOrThisOfType(ensembleCurveSet); + if (ensembleCurveSet) isVisibleInPossibleParent = ensembleCurveSet->isCurvesVisible(); + } + + return isVisibleInPossibleParent; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimPlotCurve.h b/ApplicationCode/ProjectDataModel/RimPlotCurve.h index 8150d873b1..51bf266ada 100644 --- a/ApplicationCode/ProjectDataModel/RimPlotCurve.h +++ b/ApplicationCode/ProjectDataModel/RimPlotCurve.h @@ -109,6 +109,9 @@ protected: void appearanceUiOrdering(caf::PdmUiOrdering& uiOrdering); void curveNameUiOrdering(caf::PdmUiOrdering& uiOrdering); +private: + bool canCurveBeAttached() const; + protected: QPointer m_parentQwtPlot; RiuQwtPlotCurve* m_qwtPlotCurve;