(#431) Handling viewer deletion by upper right X in window gracefully

This commit is contained in:
Pål Hagen 2015-09-08 11:11:42 +02:00
parent 1000c96c3e
commit 77c22e4562
3 changed files with 30 additions and 11 deletions

View File

@ -45,8 +45,8 @@ RimWellLogPlot::RimWellLogPlot()
m_viewer = NULL; m_viewer = NULL;
CAF_PDM_InitField(&showWindow, "ShowWindow", true, "Show well log plot", "", "", ""); CAF_PDM_InitField(&m_showWindow, "ShowWindow", true, "Show well log plot", "", "", "");
showWindow.uiCapability()->setUiHidden(true); m_showWindow.uiCapability()->setUiHidden(true);
CAF_PDM_InitFieldNoDefault(&m_userName, "PlotDescription", "Name", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_userName, "PlotDescription", "Name", "", "", "");
CAF_PDM_InitField(&m_minimumVisibleDepth, "MinimumDepth", 0.0, "Minimum depth", "", "", ""); CAF_PDM_InitField(&m_minimumVisibleDepth, "MinimumDepth", 0.0, "Minimum depth", "", "", "");
@ -77,7 +77,7 @@ RimWellLogPlot::~RimWellLogPlot()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellLogPlot::updateViewerWidget() void RimWellLogPlot::updateViewerWidget()
{ {
if (showWindow()) if (m_showWindow())
{ {
if (!m_viewer) if (!m_viewer)
{ {
@ -111,7 +111,7 @@ void RimWellLogPlot::updateViewerWidget()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellLogPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) void RimWellLogPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{ {
if (changedField == &showWindow) if (changedField == &m_showWindow)
{ {
updateViewerWidget(); updateViewerWidget();
} }
@ -130,7 +130,7 @@ void RimWellLogPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimWellLogPlot::objectToggleField() 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)); 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();
}

View File

@ -62,8 +62,6 @@ public:
void updateAxisRanges(); void updateAxisRanges();
void setVisibleDepthRangeFromContents(); void setVisibleDepthRangeFromContents();
caf::PdmField<bool> showWindow;
protected: protected:
// Overridden PDM methods // Overridden PDM methods
@ -74,6 +72,7 @@ private:
void updateViewerWidget(); void updateViewerWidget();
void recreateTracePlots(); void recreateTracePlots();
void detachAllCurves(); void detachAllCurves();
void handleViewerDeletion();
virtual caf::PdmFieldHandle* objectToggleField(); virtual caf::PdmFieldHandle* objectToggleField();
@ -82,7 +81,8 @@ private:
private: private:
QPointer<RiuWellLogPlot> m_viewer; QPointer<RiuWellLogPlot> m_viewer;
caf::PdmField< std::vector<int> > windowGeometry; caf::PdmField<bool> m_showWindow;
caf::PdmField< std::vector<int> > windowGeometry;
caf::PdmChildArrayField<RimWellLogPlotTrace*> traces; caf::PdmChildArrayField<RimWellLogPlotTrace*> traces;
@ -92,4 +92,6 @@ private:
double m_depthRangeMinimum; double m_depthRangeMinimum;
double m_depthRangeMaximum; double m_depthRangeMaximum;
friend class RiuWellLogPlot;
}; };

View File

@ -59,9 +59,7 @@ RiuWellLogPlot::~RiuWellLogPlot()
{ {
if (m_plotDefinition) if (m_plotDefinition)
{ {
m_plotDefinition->showWindow = false; m_plotDefinition->handleViewerDeletion();
m_plotDefinition->uiCapability()->updateUiIconFromToggleField();
m_plotDefinition->updateConnectedEditors();
} }
} }