diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index 69f974e6bc..a364c0d99c 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -575,7 +575,7 @@ void RiaApplication::loadAndUpdatePlotData() size_t plotCount = 0; plotCount += wlpColl ? wlpColl->wellLogPlots().size() : 0; plotCount += spColl ? spColl->summaryPlots().size() : 0; - plotCount += flowColl ? flowColl->flowPlots().size() : 0; + plotCount += flowColl ? flowColl->plotCount() : 0; caf::ProgressInfo plotProgress(plotCount, "Loading Plot Data"); if (wlpColl) @@ -595,17 +595,15 @@ void RiaApplication::loadAndUpdatePlotData() plotProgress.incrementProgress(); } } + + plotProgress.setNextProgressIncrement(flowColl->plotCount()); if (flowColl) { - flowColl->defaultPlot->loadDataAndUpdate(); - - for (RimWellAllocationPlot* p : flowColl->flowPlots()) - { - p->loadDataAndUpdate(); - plotProgress.incrementProgress(); - } + flowColl->loadDataAndUpdate(); } + plotProgress.incrementProgress(); + } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/FlowCommands/RicAddStoredWellAllocationPlotFeature.cpp b/ApplicationCode/Commands/FlowCommands/RicAddStoredWellAllocationPlotFeature.cpp index 76c74525c0..cd567f1ac2 100644 --- a/ApplicationCode/Commands/FlowCommands/RicAddStoredWellAllocationPlotFeature.cpp +++ b/ApplicationCode/Commands/FlowCommands/RicAddStoredWellAllocationPlotFeature.cpp @@ -70,7 +70,7 @@ void RicAddStoredWellAllocationPlotFeature::onActionTriggered(bool isChecked) RimWellAllocationPlot* wellAllocationPlot = dynamic_cast(sourceObject->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); CVF_ASSERT(wellAllocationPlot); - flowPlotColl->flowPlots.push_back(wellAllocationPlot); + flowPlotColl->addPlot(wellAllocationPlot); wellAllocationPlot->resolveReferencesRecursively(); wellAllocationPlot->loadDataAndUpdate(); diff --git a/ApplicationCode/Commands/FlowCommands/RicShowWellAllocationPlotFeature.cpp b/ApplicationCode/Commands/FlowCommands/RicShowWellAllocationPlotFeature.cpp index 8c8deffbdf..cfab274510 100644 --- a/ApplicationCode/Commands/FlowCommands/RicShowWellAllocationPlotFeature.cpp +++ b/ApplicationCode/Commands/FlowCommands/RicShowWellAllocationPlotFeature.cpp @@ -59,13 +59,13 @@ void RicShowWellAllocationPlotFeature::onActionTriggered(bool isChecked) RimFlowPlotCollection* flowPlotColl = RiaApplication::instance()->project()->mainPlotCollection->flowPlotCollection(); if (flowPlotColl) { - flowPlotColl->defaultPlot->setFromSimulationWell(eclWell); - flowPlotColl->defaultPlot->updateConnectedEditors(); + flowPlotColl->defaultPlot()->setFromSimulationWell(eclWell); + flowPlotColl->defaultPlot()->updateConnectedEditors(); // Make sure the summary plot window is created and visible RiuMainPlotWindow* plotwindow = RiaApplication::instance()->getOrCreateAndShowMainPlotWindow(); //RiaApplication::instance()->project()->updateConnectedEditors(); - plotwindow->selectAsCurrentItem(flowPlotColl->defaultPlot); + plotwindow->selectAsCurrentItem(flowPlotColl->defaultPlot()); } } } diff --git a/ApplicationCode/ProjectDataModel/Flow/RimFlowPlotCollection.cpp b/ApplicationCode/ProjectDataModel/Flow/RimFlowPlotCollection.cpp index 6e0a59b8ea..a361fa4cd6 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimFlowPlotCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimFlowPlotCollection.cpp @@ -22,6 +22,7 @@ #include "cvfAssert.h" +#include "cafProgressInfo.h" CAF_PDM_SOURCE_INIT(RimFlowPlotCollection, "FlowPlotCollection"); @@ -32,12 +33,10 @@ RimFlowPlotCollection::RimFlowPlotCollection() { CAF_PDM_InitObject("Flow Diagnostics Plots", ":/newIcon16x16.png", "", ""); - CAF_PDM_InitFieldNoDefault(&defaultPlot, "DefaultFlowPlot", "", "", "", ""); - defaultPlot = new RimWellAllocationPlot; - defaultPlot->setDescription("Default Flow Diagnostics Plot"); - defaultPlot.uiCapability()->setUiHidden(true); + CAF_PDM_InitFieldNoDefault(&m_defaultPlot, "DefaultFlowPlot", "", "", "", ""); + m_defaultPlot.uiCapability()->setUiHidden(true); - CAF_PDM_InitFieldNoDefault(&flowPlots, "FlowPlots", "Stored Plots", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_flowPlots, "FlowPlots", "Stored Plots", "", "", ""); } //-------------------------------------------------------------------------------------------------- @@ -45,9 +44,9 @@ RimFlowPlotCollection::RimFlowPlotCollection() //-------------------------------------------------------------------------------------------------- RimFlowPlotCollection::~RimFlowPlotCollection() { - delete defaultPlot(); + delete m_defaultPlot(); - flowPlots.deleteAllChildObjects(); + m_flowPlots.deleteAllChildObjects(); } //-------------------------------------------------------------------------------------------------- @@ -55,7 +54,59 @@ RimFlowPlotCollection::~RimFlowPlotCollection() //-------------------------------------------------------------------------------------------------- void RimFlowPlotCollection::closeDefaultPlotWindowAndDeletePlots() { - defaultPlot->removeFromMdiAreaAndDeleteViewWidget(); - - flowPlots.deleteAllChildObjects(); + if ( m_defaultPlot ) + { + m_defaultPlot->removeFromMdiAreaAndDeleteViewWidget(); + delete m_defaultPlot(); + } + m_flowPlots.deleteAllChildObjects(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFlowPlotCollection::loadDataAndUpdate() +{ + caf::ProgressInfo plotProgress(m_flowPlots.size() + 1, ""); + + if (m_defaultPlot) m_defaultPlot->loadDataAndUpdate(); + plotProgress.incrementProgress(); + + for (RimWellAllocationPlot* p : m_flowPlots) + { + p->loadDataAndUpdate(); + plotProgress.incrementProgress(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RimFlowPlotCollection::plotCount() const +{ + return m_flowPlots.size(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFlowPlotCollection::addPlot(RimWellAllocationPlot* plot) +{ + m_flowPlots.push_back(plot); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellAllocationPlot* RimFlowPlotCollection::defaultPlot() +{ + if ( !m_defaultPlot() ) + { + m_defaultPlot = new RimWellAllocationPlot; + m_defaultPlot->setDescription("Default Flow Diagnostics Plot"); + } + + this->updateConnectedEditors(); + + return m_defaultPlot(); } diff --git a/ApplicationCode/ProjectDataModel/Flow/RimFlowPlotCollection.h b/ApplicationCode/ProjectDataModel/Flow/RimFlowPlotCollection.h index b3fa710a66..e48ab29229 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimFlowPlotCollection.h +++ b/ApplicationCode/ProjectDataModel/Flow/RimFlowPlotCollection.h @@ -36,7 +36,13 @@ public: virtual ~RimFlowPlotCollection(); void closeDefaultPlotWindowAndDeletePlots(); + void loadDataAndUpdate(); + size_t plotCount() const; - caf::PdmChildField defaultPlot; - caf::PdmChildArrayField flowPlots; + void addPlot(RimWellAllocationPlot* plot); + RimWellAllocationPlot* defaultPlot(); + +private: + caf::PdmChildField m_defaultPlot; + caf::PdmChildArrayField m_flowPlots; };