diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp b/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp index 36ba94300e..15cc75c1c7 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp @@ -45,8 +45,8 @@ RimWellLogPlot::RimWellLogPlot() m_viewer = NULL; - CAF_PDM_InitField(&showWindow, "ShowWindow", true, "Show well log plot", "", "", ""); - showWindow.uiCapability()->setUiHidden(true); + CAF_PDM_InitField(&m_showWindow, "ShowWindow", true, "Show well log plot", "", "", ""); + m_showWindow.uiCapability()->setUiHidden(true); CAF_PDM_InitFieldNoDefault(&m_userName, "PlotDescription", "Name", "", "", ""); CAF_PDM_InitField(&m_minimumVisibleDepth, "MinimumDepth", 0.0, "Minimum depth", "", "", ""); @@ -77,7 +77,7 @@ RimWellLogPlot::~RimWellLogPlot() //-------------------------------------------------------------------------------------------------- void RimWellLogPlot::updateViewerWidget() { - if (showWindow()) + if (m_showWindow()) { if (!m_viewer) { @@ -111,7 +111,7 @@ void RimWellLogPlot::updateViewerWidget() //-------------------------------------------------------------------------------------------------- void RimWellLogPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { - if (changedField == &showWindow) + if (changedField == &m_showWindow) { updateViewerWidget(); } @@ -130,7 +130,7 @@ void RimWellLogPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c //-------------------------------------------------------------------------------------------------- caf::PdmFieldHandle* RimWellLogPlot::objectToggleField() { - return &showWindow; + return &m_showWindow; } //-------------------------------------------------------------------------------------------------- @@ -355,3 +355,22 @@ void RimWellLogPlot::updateViewerWidgetWindowTitle() m_viewer->setWindowTitle(QString("Well Log Plot - %1").arg(m_userName)); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogPlot::handleViewerDeletion() +{ + m_showWindow = false; + + if (m_viewer) + { + windowGeometry = RiuMainWindow::instance()->windowGeometryForViewer(m_viewer); + + detachAllCurves(); + m_viewer = NULL; + } + + uiCapability()->updateUiIconFromToggleField(); + updateConnectedEditors(); +} diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlot.h b/ApplicationCode/ProjectDataModel/RimWellLogPlot.h index c3717caeab..cc07ff7c3a 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlot.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlot.h @@ -62,8 +62,6 @@ public: void updateAxisRanges(); void setVisibleDepthRangeFromContents(); - caf::PdmField showWindow; - protected: // Overridden PDM methods @@ -74,6 +72,7 @@ private: void updateViewerWidget(); void recreateTracePlots(); void detachAllCurves(); + void handleViewerDeletion(); virtual caf::PdmFieldHandle* objectToggleField(); @@ -82,7 +81,8 @@ private: private: QPointer m_viewer; - caf::PdmField< std::vector > windowGeometry; + caf::PdmField m_showWindow; + caf::PdmField< std::vector > windowGeometry; caf::PdmChildArrayField traces; @@ -92,4 +92,6 @@ private: double m_depthRangeMinimum; double m_depthRangeMaximum; + + friend class RiuWellLogPlot; }; diff --git a/ApplicationCode/UserInterface/RiuWellLogPlot.cpp b/ApplicationCode/UserInterface/RiuWellLogPlot.cpp index 169a206a3d..5ef2d9d684 100644 --- a/ApplicationCode/UserInterface/RiuWellLogPlot.cpp +++ b/ApplicationCode/UserInterface/RiuWellLogPlot.cpp @@ -59,9 +59,7 @@ RiuWellLogPlot::~RiuWellLogPlot() { if (m_plotDefinition) { - m_plotDefinition->showWindow = false; - m_plotDefinition->uiCapability()->updateUiIconFromToggleField(); - m_plotDefinition->updateConnectedEditors(); + m_plotDefinition->handleViewerDeletion(); } }