From ba372f7fbe7eea0be4b4724240fa4dbc4f150475 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 21 Dec 2020 19:43:36 +0100 Subject: [PATCH] #7128 VFP Plot: fix delete functionality. --- .../ProjectDataModel/RimVfpPlot.cpp | 2 ++ .../ProjectDataModel/RimVfpPlotCollection.cpp | 27 ++++++++++++++++++- .../ProjectDataModel/RimVfpPlotCollection.h | 13 ++++++--- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimVfpPlot.cpp b/ApplicationCode/ProjectDataModel/RimVfpPlot.cpp index a39416474f..c226a14a1c 100644 --- a/ApplicationCode/ProjectDataModel/RimVfpPlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimVfpPlot.cpp @@ -135,6 +135,8 @@ RimVfpPlot::RimVfpPlot() //-------------------------------------------------------------------------------------------------- RimVfpPlot::~RimVfpPlot() { + removeMdiWindowFromMdiArea(); + deleteViewWidget(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimVfpPlotCollection.cpp b/ApplicationCode/ProjectDataModel/RimVfpPlotCollection.cpp index e26679a74c..2a619f8d38 100644 --- a/ApplicationCode/ProjectDataModel/RimVfpPlotCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimVfpPlotCollection.cpp @@ -60,7 +60,15 @@ void RimVfpPlotCollection::addPlot( RimVfpPlot* newPlot ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimVfpPlotCollection::plots() +void RimVfpPlotCollection::insertPlot( RimVfpPlot* vfpPlot, size_t index ) +{ + m_vfpPlots.insert( index, vfpPlot ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimVfpPlotCollection::plots() const { return m_vfpPlots.childObjects(); } @@ -72,3 +80,20 @@ void RimVfpPlotCollection::deleteAllChildObjects() { m_vfpPlots.deleteAllChildObjects(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RimVfpPlotCollection::plotCount() const +{ + return m_vfpPlots.size(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpPlotCollection::removePlot( RimVfpPlot* vfpPlot ) +{ + m_vfpPlots.removeChildObject( vfpPlot ); + updateAllRequiredEditors(); +} diff --git a/ApplicationCode/ProjectDataModel/RimVfpPlotCollection.h b/ApplicationCode/ProjectDataModel/RimVfpPlotCollection.h index a4a8676b78..fdfe2c6f6e 100644 --- a/ApplicationCode/ProjectDataModel/RimVfpPlotCollection.h +++ b/ApplicationCode/ProjectDataModel/RimVfpPlotCollection.h @@ -17,16 +17,17 @@ ///////////////////////////////////////////////////////////////////////////////// #pragma once +#include "RimAbstractPlotCollection.h" +#include "RimVfpPlot.h" + #include "cafPdmChildArrayField.h" #include "cafPdmObject.h" -class RimVfpPlot; - //================================================================================================== /// /// //================================================================================================== -class RimVfpPlotCollection : public caf::PdmObject +class RimVfpPlotCollection : public caf::PdmObject, public RimTypedPlotCollection { CAF_PDM_HEADER_INIT; @@ -35,9 +36,13 @@ public: ~RimVfpPlotCollection() override; void addPlot( RimVfpPlot* newPlot ); - std::vector plots(); + std::vector plots() const; void deleteAllChildObjects(); + size_t plotCount() const final; + void insertPlot( RimVfpPlot* vfpPlot, size_t index ) final; + void removePlot( RimVfpPlot* vfpPlot ) final; + private: caf::PdmChildArrayField m_vfpPlots; };