Detaching all curves before the plot is deleted. Qwt needed it.

This commit is contained in:
Jacob Støren 2015-09-03 15:10:02 +02:00
parent f149cfff6d
commit 11e57b663c
6 changed files with 41 additions and 4 deletions

View File

@ -64,6 +64,7 @@ RimWellLogPlot::RimWellLogPlot()
RimWellLogPlot::~RimWellLogPlot() RimWellLogPlot::~RimWellLogPlot()
{ {
RiuMainWindow::instance()->removeViewer(m_viewer); RiuMainWindow::instance()->removeViewer(m_viewer);
detachAllCurves();
delete m_viewer; delete m_viewer;
} }
@ -92,6 +93,7 @@ void RimWellLogPlot::updateViewerWidget()
windowGeometry = RiuMainWindow::instance()->windowGeometryForViewer(m_viewer); windowGeometry = RiuMainWindow::instance()->windowGeometryForViewer(m_viewer);
RiuMainWindow::instance()->removeViewer(m_viewer); RiuMainWindow::instance()->removeViewer(m_viewer);
detachAllCurves();
delete m_viewer; delete m_viewer;
m_viewer = NULL; m_viewer = NULL;
@ -285,3 +287,14 @@ void RimWellLogPlot::recreateTracePlots()
m_viewer->insertTracePlot(traces[tIdx]->viewer()); m_viewer->insertTracePlot(traces[tIdx]->viewer());
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlot::detachAllCurves()
{
for (size_t tIdx = 0; tIdx < traces.size(); ++tIdx)
{
traces[tIdx]->detachAllCurves();
}
}

View File

@ -65,6 +65,7 @@ protected:
private: private:
void updateViewerWidget(); void updateViewerWidget();
void recreateTracePlots(); void recreateTracePlots();
void detachAllCurves();
virtual caf::PdmFieldHandle* objectToggleField(); virtual caf::PdmFieldHandle* objectToggleField();

View File

@ -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(minimumDepth && maximumDepth);
CVF_ASSERT(m_plotCurve); CVF_ASSERT(m_plotCurve);
@ -164,3 +164,11 @@ void RimWellLogPlotCurve::setColor(const cvf::Color3f& color)
m_curveColor = color; m_curveColor = color;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlotCurve::detachCurve()
{
m_plotCurve->detach();
}

View File

@ -39,12 +39,14 @@ class RimWellLogPlotCurve : public caf::PdmObject
public: public:
RimWellLogPlotCurve(); RimWellLogPlotCurve();
virtual ~RimWellLogPlotCurve(); virtual ~RimWellLogPlotCurve();
void setDescription(QString description) {m_userName = description;} void setDescription(QString description) {m_userName = description;}
void setColor(const cvf::Color3f& color);
bool depthRange(double* minimumDepth, double* maximumDepth) const;
void setPlot(RiuWellLogTracePlot* plot); void setPlot(RiuWellLogTracePlot* plot);
void setColor(const cvf::Color3f& color); void detachCurve();
bool depthRange(double* minimumDepth, double* maximumDepth);
virtual void updatePlotData(); virtual void updatePlotData();
protected: protected:

View File

@ -177,3 +177,14 @@ void RimWellLogPlotTrace::recreateViewer()
curves[cIdx]->setPlot(this->m_viewer); curves[cIdx]->setPlot(this->m_viewer);
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlotTrace::detachAllCurves()
{
for (size_t cIdx = 0; cIdx < curves.size(); ++cIdx)
{
curves[cIdx]->detachCurve();
}
}

View File

@ -45,6 +45,8 @@ public:
size_t curveCount() { return curves.size(); } size_t curveCount() { return curves.size(); }
void recreateViewer(); void recreateViewer();
void detachAllCurves();
void loadDataAndUpdate(); void loadDataAndUpdate();
bool availableDepthRange(double* minimumDepth, double* maximumDepth); bool availableDepthRange(double* minimumDepth, double* maximumDepth);