From 11e57b663c66142adf94a32d3165cd4c5b561da7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 3 Sep 2015 15:10:02 +0200 Subject: [PATCH] Detaching all curves before the plot is deleted. Qwt needed it. --- ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp | 13 +++++++++++++ ApplicationCode/ProjectDataModel/RimWellLogPlot.h | 1 + .../ProjectDataModel/RimWellLogPlotCurve.cpp | 10 +++++++++- .../ProjectDataModel/RimWellLogPlotCurve.h | 8 +++++--- .../ProjectDataModel/RimWellLogPlotTrace.cpp | 11 +++++++++++ .../ProjectDataModel/RimWellLogPlotTrace.h | 2 ++ 6 files changed, 41 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp b/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp index 5fbbfb82d4..436021d5e6 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp @@ -64,6 +64,7 @@ RimWellLogPlot::RimWellLogPlot() RimWellLogPlot::~RimWellLogPlot() { RiuMainWindow::instance()->removeViewer(m_viewer); + detachAllCurves(); delete m_viewer; } @@ -92,6 +93,7 @@ void RimWellLogPlot::updateViewerWidget() windowGeometry = RiuMainWindow::instance()->windowGeometryForViewer(m_viewer); RiuMainWindow::instance()->removeViewer(m_viewer); + detachAllCurves(); delete m_viewer; m_viewer = NULL; @@ -285,3 +287,14 @@ void RimWellLogPlot::recreateTracePlots() m_viewer->insertTracePlot(traces[tIdx]->viewer()); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogPlot::detachAllCurves() +{ + for (size_t tIdx = 0; tIdx < traces.size(); ++tIdx) + { + traces[tIdx]->detachAllCurves(); + } +} diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlot.h b/ApplicationCode/ProjectDataModel/RimWellLogPlot.h index 5299be9964..278e0d3994 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlot.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlot.h @@ -65,6 +65,7 @@ protected: private: void updateViewerWidget(); void recreateTracePlots(); + void detachAllCurves(); virtual caf::PdmFieldHandle* objectToggleField(); diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlotCurve.cpp b/ApplicationCode/ProjectDataModel/RimWellLogPlotCurve.cpp index 06973ce2fd..2f633c0a62 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlotCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlotCurve.cpp @@ -140,7 +140,7 @@ caf::PdmFieldHandle* RimWellLogPlotCurve::userDescriptionField() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimWellLogPlotCurve::depthRange(double* minimumDepth, double* maximumDepth) +bool RimWellLogPlotCurve::depthRange(double* minimumDepth, double* maximumDepth) const { CVF_ASSERT(minimumDepth && maximumDepth); CVF_ASSERT(m_plotCurve); @@ -164,3 +164,11 @@ void RimWellLogPlotCurve::setColor(const cvf::Color3f& color) m_curveColor = color; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogPlotCurve::detachCurve() +{ + m_plotCurve->detach(); +} + diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlotCurve.h b/ApplicationCode/ProjectDataModel/RimWellLogPlotCurve.h index b68249e760..174f7bb7ac 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlotCurve.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlotCurve.h @@ -39,12 +39,14 @@ class RimWellLogPlotCurve : public caf::PdmObject public: RimWellLogPlotCurve(); virtual ~RimWellLogPlotCurve(); - void setDescription(QString description) {m_userName = description;} - void setPlot(RiuWellLogTracePlot* plot); + void setDescription(QString description) {m_userName = description;} void setColor(const cvf::Color3f& color); - bool depthRange(double* minimumDepth, double* maximumDepth); + + bool depthRange(double* minimumDepth, double* maximumDepth) const; + void setPlot(RiuWellLogTracePlot* plot); + void detachCurve(); virtual void updatePlotData(); protected: diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlotTrace.cpp b/ApplicationCode/ProjectDataModel/RimWellLogPlotTrace.cpp index 7593976e01..f311c3cc5b 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlotTrace.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlotTrace.cpp @@ -177,3 +177,14 @@ void RimWellLogPlotTrace::recreateViewer() curves[cIdx]->setPlot(this->m_viewer); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogPlotTrace::detachAllCurves() +{ + for (size_t cIdx = 0; cIdx < curves.size(); ++cIdx) + { + curves[cIdx]->detachCurve(); + } +} diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlotTrace.h b/ApplicationCode/ProjectDataModel/RimWellLogPlotTrace.h index 74ef6e9fbc..ac9beedfc1 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlotTrace.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlotTrace.h @@ -45,6 +45,8 @@ public: size_t curveCount() { return curves.size(); } void recreateViewer(); + void detachAllCurves(); + void loadDataAndUpdate(); bool availableDepthRange(double* minimumDepth, double* maximumDepth);