mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1321 Update Flow Characteristics plot when new timesteps arrives.
Added a updateCurrentTimeStepInPlots method Deleted obsolete ifdeffed code from main plot collection
This commit is contained in:
@@ -104,6 +104,22 @@ void RimFlowCharacteristicsPlot::deleteViewWidget()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimFlowCharacteristicsPlot::updateCurrentTimeStep()
|
||||
{
|
||||
if (m_timeStepSelectionType() != ALL_AVAILABLE) return;
|
||||
if (!m_flowDiagSolution()) return;
|
||||
|
||||
RigFlowDiagResults* flowResult = m_flowDiagSolution->flowDiagResults();
|
||||
std::vector<int> calculatedTimesteps = flowResult->calculatedTimeSteps();
|
||||
|
||||
if (m_currentlyPlottedTimeSteps == calculatedTimesteps) return;
|
||||
|
||||
this->loadDataAndUpdate();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -199,7 +215,8 @@ void RimFlowCharacteristicsPlot::fieldChangedByUi(const caf::PdmFieldHandle* cha
|
||||
|
||||
if ( &m_case == changedField )
|
||||
{
|
||||
m_flowDiagSolution = m_case->defaultFlowDiagSolution();
|
||||
m_flowDiagSolution = m_case->defaultFlowDiagSolution();
|
||||
m_currentlyPlottedTimeSteps.clear();
|
||||
}
|
||||
|
||||
// All fields update plot
|
||||
@@ -251,6 +268,8 @@ void RimFlowCharacteristicsPlot::loadDataAndUpdate()
|
||||
if (calculatedTimeStepsSet.count(tsIdx)) calculatedTimesteps.push_back(tsIdx);
|
||||
}
|
||||
}
|
||||
|
||||
m_currentlyPlottedTimeSteps = calculatedTimesteps;
|
||||
|
||||
std::vector<QDateTime> timeStepDates = m_case->timeStepDates();
|
||||
std::vector<double> lorenzVals(timeStepDates.size(), HUGE_VAL);
|
||||
|
||||
@@ -53,7 +53,8 @@ public:
|
||||
RimFlowCharacteristicsPlot();
|
||||
virtual ~RimFlowCharacteristicsPlot();
|
||||
|
||||
void setFromFlowSolution(RimFlowDiagSolution* flowSolution);
|
||||
void setFromFlowSolution(RimFlowDiagSolution* flowSolution);
|
||||
void updateCurrentTimeStep();
|
||||
|
||||
// RimViewWindow overrides
|
||||
|
||||
@@ -86,5 +87,7 @@ private:
|
||||
caf::PdmField<caf::AppEnum<TimeSelectionType> > m_timeStepSelectionType;
|
||||
caf::PdmField<std::vector<int> > m_selectedTimeSteps;
|
||||
|
||||
std::vector<int> m_currentlyPlottedTimeSteps;
|
||||
|
||||
QPointer<RiuFlowCharacteristicsPlot> m_flowCharPlotWidget;
|
||||
};
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
#include "RiuMainWindow.h"
|
||||
#include "RiuProjectPropertyView.h"
|
||||
#include "RimFlowCharacteristicsPlot.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimMainPlotCollection, "MainPlotCollection");
|
||||
|
||||
@@ -52,8 +53,6 @@ RimMainPlotCollection::RimMainPlotCollection()
|
||||
m_summaryPlotCollection = new RimSummaryPlotCollection();
|
||||
m_flowPlotCollection = new RimFlowPlotCollection();
|
||||
|
||||
//m_plotMainWindow = NULL;
|
||||
//m_plotManagerMainWindow = NULL;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -65,8 +64,6 @@ RimMainPlotCollection::~RimMainPlotCollection()
|
||||
if (m_summaryPlotCollection()) delete m_summaryPlotCollection();
|
||||
if (m_flowPlotCollection()) delete m_flowPlotCollection();
|
||||
|
||||
//m_plotManagerMainWindow->close();
|
||||
//m_plotManagerMainWindow->deleteLater();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -74,62 +71,9 @@ RimMainPlotCollection::~RimMainPlotCollection()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimMainPlotCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
||||
{
|
||||
#if 0
|
||||
if (changedField == &showWindow)
|
||||
{
|
||||
if (showWindow)
|
||||
{
|
||||
showPlotWindow();
|
||||
}
|
||||
else
|
||||
{
|
||||
hidePlotWindow();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#if 0
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimMainPlotCollection::showPlotWindow()
|
||||
{
|
||||
if (!m_plotManagerMainWindow)
|
||||
{
|
||||
m_plotManagerMainWindow = new QMainWindow;
|
||||
m_plotManagerMainWindow->setDockNestingEnabled(true);
|
||||
|
||||
m_plotMainWindow = new QMainWindow;
|
||||
m_plotMainWindow->setDockNestingEnabled(true);
|
||||
|
||||
// NOTE! setCentralWidget takes ownership of widget
|
||||
m_plotManagerMainWindow->setCentralWidget(m_plotMainWindow);
|
||||
|
||||
{
|
||||
QDockWidget* dockWidget = new QDockWidget("Plots", m_plotManagerMainWindow);
|
||||
dockWidget->setObjectName("dockWidget");
|
||||
|
||||
RiuMainWindow* mainWindow = RiuMainWindow::instance();
|
||||
|
||||
RiuProjectAndPropertyView* projPropView = new RiuProjectAndPropertyView(dockWidget);
|
||||
dockWidget->setWidget(projPropView);
|
||||
|
||||
RimProject* proj = NULL;
|
||||
this->firstAncestorOrThisOfType(proj);
|
||||
|
||||
projPropView->setPdmItem(this);
|
||||
|
||||
m_plotManagerMainWindow->addDockWidget(Qt::LeftDockWidgetArea, dockWidget);
|
||||
}
|
||||
}
|
||||
|
||||
m_plotMainWindow->show();
|
||||
|
||||
m_plotManagerMainWindow->showNormal();
|
||||
m_plotManagerMainWindow->raise();
|
||||
}
|
||||
|
||||
#endif
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -173,115 +117,12 @@ void RimMainPlotCollection::deleteAllContainedObjects()
|
||||
m_flowPlotCollection()->closeDefaultPlotWindowAndDeletePlots();
|
||||
}
|
||||
|
||||
#if 0
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimMainPlotCollection::createDockWindowsForAllPlots()
|
||||
{
|
||||
for (size_t i = 0; i < m_graphPlots.size(); i++)
|
||||
{
|
||||
if (!dockWidgetFromPlot(m_graphPlots[i]))
|
||||
{
|
||||
createPlotDockWidget(m_graphPlots[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QDockWidget* RimMainPlotCollection::dockWidgetFromPlot(RimSummaryPlot* graphPlot)
|
||||
void RimMainPlotCollection::updateCurrentTimeStepInPlots()
|
||||
{
|
||||
foreach(QDockWidget* dockW, m_plotViewDockWidgets)
|
||||
{
|
||||
if (dockW && dockW->widget() == graphPlot->widget())
|
||||
{
|
||||
return dockW;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
m_flowPlotCollection()->defaultFlowCharacteristicsPlot()->updateCurrentTimeStep();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimMainPlotCollection::createPlotDockWidget(RimSummaryPlot* graphPlot)
|
||||
{
|
||||
assert(m_plotMainWindow != NULL);
|
||||
|
||||
QDockWidget* dockWidget = new QDockWidget(QString("Plot Widget Tree (%1)").arg(m_plotViewDockWidgets.size() + 1), m_plotMainWindow);
|
||||
dockWidget->setObjectName("dockWidget");
|
||||
// dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
||||
|
||||
QWidget* widget = graphPlot->createPlotWidget(m_plotMainWindow);
|
||||
|
||||
dockWidget->setWidget(widget);
|
||||
|
||||
m_plotMainWindow->addDockWidget(Qt::RightDockWidgetArea, dockWidget);
|
||||
|
||||
m_plotViewDockWidgets.push_back(dockWidget);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimMainPlotCollection::eraseDockWidget(RimSummaryPlot* graphPlot)
|
||||
{
|
||||
QDockWidget* dockW = dockWidgetFromPlot(graphPlot);
|
||||
if (dockW)
|
||||
{
|
||||
m_plotMainWindow->removeDockWidget(dockW);
|
||||
dockW->setWidget(NULL);
|
||||
dockW->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimMainPlotCollection::redrawAllPlots()
|
||||
{
|
||||
for (size_t i = 0; i < m_graphPlots.size(); i++)
|
||||
{
|
||||
m_graphPlots[i]->redrawAllCurves();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QMainWindow* RimMainPlotCollection::windowWithGraphPlots()
|
||||
{
|
||||
return m_plotMainWindow;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimMainPlotCollection::initAfterRead()
|
||||
{
|
||||
if (show())
|
||||
{
|
||||
showPlotWindow();
|
||||
}
|
||||
else
|
||||
{
|
||||
hidePlotWindow();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimMainPlotCollection::hidePlotWindow()
|
||||
{
|
||||
if (m_plotManagerMainWindow)
|
||||
{
|
||||
m_plotManagerMainWindow->hide();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -50,39 +50,18 @@ public:
|
||||
RimSummaryPlotCollection* summaryPlotCollection();
|
||||
RimFlowPlotCollection* flowPlotCollection();
|
||||
|
||||
void deleteAllContainedObjects();
|
||||
void deleteAllContainedObjects();
|
||||
void updateCurrentTimeStepInPlots();
|
||||
|
||||
#if 0
|
||||
// Separate Window stuff
|
||||
void showPlotWindow();
|
||||
void hidePlotWindow();
|
||||
|
||||
void redrawAllPlots();
|
||||
void createDockWindowsForAllPlots();
|
||||
QMainWindow* windowWithGraphPlots();
|
||||
private:
|
||||
|
||||
QDockWidget* dockWidgetFromPlot(RimSummaryPlot* graphPlot);
|
||||
void createPlotDockWidget(RimSummaryPlot* graphPlot);
|
||||
void eraseDockWidget(RimSummaryPlot* graphPlot);
|
||||
|
||||
private:
|
||||
QMainWindow* m_plotManagerMainWindow; // Outer main Window
|
||||
QMainWindow* m_plotMainWindow; // Inner main window
|
||||
|
||||
std::vector<QPointer<QDockWidget> > m_plotViewDockWidgets; // ChildPlotWidgets
|
||||
#endif
|
||||
protected:
|
||||
|
||||
// Overridden PDM methods
|
||||
virtual caf::PdmFieldHandle* objectToggleField();
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
|
||||
//virtual void initAfterRead();
|
||||
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
|
||||
|
||||
caf::PdmChildField<RimWellLogPlotCollection*> m_wellLogPlotCollection;
|
||||
caf::PdmChildField<RimSummaryPlotCollection*> m_summaryPlotCollection;
|
||||
caf::PdmChildField<RimFlowPlotCollection*> m_flowPlotCollection;
|
||||
|
||||
caf::PdmField<bool> show;
|
||||
caf::PdmField<bool> show;
|
||||
};
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimGridCollection.h"
|
||||
#include "RimIntersectionCollection.h"
|
||||
#include "RimMainPlotCollection.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimPropertyFilterCollection.h"
|
||||
@@ -301,6 +302,10 @@ void RimView::setCurrentTimeStepAndUpdate(int frameIndex)
|
||||
setCurrentTimeStep(frameIndex);
|
||||
|
||||
this->updateCurrentTimeStep();
|
||||
|
||||
RimProject* project;
|
||||
firstAncestorOrThisOfTypeAsserted(project);
|
||||
project->mainPlotCollection()->updateCurrentTimeStepInPlots();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -324,7 +329,11 @@ void RimView::setCurrentTimeStep(int frameIndex)
|
||||
void RimView::updateCurrentTimeStepAndRedraw()
|
||||
{
|
||||
this->updateCurrentTimeStep();
|
||||
|
||||
|
||||
RimProject* project;
|
||||
firstAncestorOrThisOfTypeAsserted(project);
|
||||
project->mainPlotCollection()->updateCurrentTimeStepInPlots();
|
||||
|
||||
if (m_viewer) m_viewer->update();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user