Wired up application logic related to new RiuMainPlotWindow

This commit is contained in:
Magne Sjaastad 2016-06-27 11:07:01 +02:00
parent e92624a862
commit bbf1574feb
12 changed files with 194 additions and 92 deletions

View File

@ -193,6 +193,8 @@ RiaApplication::RiaApplication(int& argc, char** argv)
m_resViewUpdateTimer = NULL;
m_runningRegressionTests = false;
m_mainPlotWindow = NULL;
}
@ -687,8 +689,12 @@ bool RiaApplication::closeProject(bool askToSaveIfDirty)
mainWnd->cleanupGuiBeforeProjectClose();
RiuMainPlotWindow* mainPlotWnd = RiuMainPlotWindow::instance();
mainPlotWnd->cleanupGuiBeforeProjectClose();
if (m_mainPlotWindow)
{
m_mainPlotWindow->cleanupGuiBeforeProjectClose();
deleteMainPlotWindow();
}
caf::EffectGenerator::clearEffectCache();
@ -714,10 +720,9 @@ void RiaApplication::onProjectOpenedOrClosed()
{
mainWnd->initializeGuiNewProjectLoaded();
}
RiuMainPlotWindow* mainPlotWnd = RiuMainPlotWindow::instance();
if (mainPlotWnd)
if (m_mainPlotWindow)
{
mainPlotWnd->initializeGuiNewProjectLoaded();
m_mainPlotWindow->initializeGuiNewProjectLoaded();
}
setWindowCaptionFromAppState();
@ -1287,6 +1292,54 @@ int RiaApplication::launchUnitTestsWithConsole()
return launchUnitTests();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication::createMainPlotWindow()
{
CVF_ASSERT(m_mainPlotWindow == NULL);
m_mainPlotWindow = new RiuMainPlotWindow;
m_mainPlotWindow->setWindowTitle("Summary Plots for ResInsight");
m_mainPlotWindow->setDefaultWindowSize();
m_mainPlotWindow->loadWinGeoAndDockToolBarLayout();
m_mainPlotWindow->showWindow();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication::deleteMainPlotWindow()
{
m_mainPlotWindow->deleteLater();
processEvents();
m_mainPlotWindow = NULL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuMainPlotWindow* RiaApplication::getOrCreateMainPlotWindow()
{
if (!m_mainPlotWindow)
{
createMainPlotWindow();
}
return m_mainPlotWindow;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuMainPlotWindow* RiaApplication::mainPlotWindow()
{
return m_mainPlotWindow;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -43,6 +43,7 @@ class RimProject;
class RimCommandObject;
class RiaProjectModifier;
class RimWellLogPlot;
class RiuMainPlotWindow;
namespace caf
{
@ -163,6 +164,9 @@ public:
int launchUnitTests();
int launchUnitTestsWithConsole();
RiuMainPlotWindow* getOrCreateMainPlotWindow();
RiuMainPlotWindow* mainPlotWindow();
private:
enum ProjectLoadAction
{
@ -178,6 +182,9 @@ private:
QImage grabFrameBufferImage();
void clearViewsScheduledForUpdate();
void createMainPlotWindow();
void deleteMainPlotWindow();
private slots:
void slotWorkerProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
@ -215,4 +222,6 @@ private:
QString m_helpText;
bool m_runningRegressionTests;
RiuMainPlotWindow* m_mainPlotWindow;
};

View File

@ -22,25 +22,24 @@
#include "RicWellLogPlotCurveFeatureImpl.h"
#include "RicNewWellLogPlotFeatureImpl.h"
#include "RimMainPlotCollection.h"
#include "RimProject.h"
#include "RimWellLogFile.h"
#include "RimWellLogFileChannel.h"
#include "RimWellLogPlot.h"
#include "RimWellLogTrack.h"
#include "RimWellLogFileCurve.h"
#include "RimProject.h"
#include "RimMainPlotCollection.h"
#include "RimWellLogPlot.h"
#include "RimWellLogPlotCollection.h"
#include "RimWellLogTrack.h"
#include "RimWellPath.h"
#include "RimWellPathCollection.h"
#include "RiuMainPlotWindow.h"
#include "RigWellLogFile.h"
#include "RiaApplication.h"
#include "RiuMainWindow.h"
#include "RiuWellLogTrack.h"
#include "cafSelectionManager.h"
#include "cafPdmUiTreeView.h"
#include <QAction>
@ -110,9 +109,12 @@ void RicAddWellLogToPlotFeature::onActionTriggered(bool isChecked)
plot->updateDepthZoom();
plotTrack->viewer()->replot();
// Make sure the summary plot window is created and visible
RiuMainPlotWindow* plotwindow = RiaApplication::instance()->getOrCreateMainPlotWindow();
RiaApplication::instance()->project()->updateConnectedEditors();
RiuMainWindow::instance()->projectTreeView()->selectAsCurrentItem(selection.back());
plotwindow->selectAsCurrentItem(selection.back());
}
//--------------------------------------------------------------------------------------------------

View File

@ -29,8 +29,8 @@
#include "RimWellLogTrack.h"
#include "RimWellPath.h"
#include "RimWellPathCollection.h"
#include "RiuMainPlotWindow.h"
#include "RiuMainWindow.h"
#include "RiaApplication.h"
#include "cafSelectionManager.h"
@ -136,7 +136,13 @@ RimWellLogExtractionCurve* RicNewWellLogCurveExtractionFeature::addCurve(RimWell
plotTrack->addCurve(curve);
plotTrack->updateConnectedEditors();
RiuMainWindow::instance()->selectAsCurrentItem(curve);
// Make sure the summary plot window is created and visible
RiuMainPlotWindow* plotwindow = RiaApplication::instance()->getOrCreateMainPlotWindow();
RiaApplication::instance()->project()->updateConnectedEditors();
plotwindow->selectAsCurrentItem(curve);
return curve;
}

View File

@ -22,17 +22,17 @@
#include "RicWellLogPlotCurveFeatureImpl.h"
#include "RicNewWellLogPlotFeatureImpl.h"
#include "RimWellLogFileCurve.h"
#include "RimWellLogTrack.h"
#include "RiaApplication.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RimWellLogFile.h"
#include "RimWellLogFileChannel.h"
#include "RimWellLogFileCurve.h"
#include "RimWellLogTrack.h"
#include "RimWellPath.h"
#include "RimWellPathCollection.h"
#include "RimProject.h"
#include "RimOilField.h"
#include "RiuMainWindow.h"
#include "RiaApplication.h"
#include "RiuMainPlotWindow.h"
#include "cafSelectionManager.h"
@ -152,7 +152,8 @@ RimWellLogFileCurve* RicNewWellLogFileCurveFeature::addCurve(RimWellLogTrack* pl
plotTrack->updateConnectedEditors();
RiuMainWindow::instance()->selectAsCurrentItem(curve);
RiuMainPlotWindow* plotwindow = RiaApplication::instance()->getOrCreateMainPlotWindow();
plotwindow->selectAsCurrentItem(curve);
return curve;
}

View File

@ -19,13 +19,12 @@
#include "RicWellLogPlotTrackFeatureImpl.h"
#include "RimWellLogCurve.h"
#include "RimWellLogPlot.h"
#include "RimWellLogTrack.h"
#include "RimWellLogCurve.h"
#include "RiuMainWindow.h"
#include "cvfAssert.h"
#include "cafPdmUiTreeView.h"
//--------------------------------------------------------------------------------------------------
///

View File

@ -735,34 +735,49 @@ void RimProject::appendScriptItems(QMenu* menu, RimScriptCollection* scriptColle
//--------------------------------------------------------------------------------------------------
void RimProject::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/)
{
if (viewLinkerCollection()->viewLinker())
if (uiConfigName == "PlotWindow")
{
// Use object instead of field to avoid duplicate entries in the tree view
uiTreeOrdering.add(viewLinkerCollection());
}
RimOilField* oilField = activeOilField();
if (oilField)
{
if (oilField->analysisModels()) uiTreeOrdering.add(oilField->analysisModels());
if (oilField->geoMechModels()) uiTreeOrdering.add(oilField->geoMechModels());
if (oilField->wellPathCollection()) uiTreeOrdering.add(oilField->wellPathCollection());
}
if (mainPlotCollection)
{
if (mainPlotCollection->wellLogPlotCollection())
RimOilField* oilField = activeOilField();
if (oilField)
{
uiTreeOrdering.add(mainPlotCollection->wellLogPlotCollection());
if (oilField->summaryCaseCollection()) uiTreeOrdering.add(oilField->summaryCaseCollection());
}
if (mainPlotCollection->summaryPlotCollection())
{
uiTreeOrdering.add(mainPlotCollection->summaryPlotCollection());
}
}
uiTreeOrdering.add(scriptCollection());
uiTreeOrdering.setForgetRemainingFields(true);
if (mainPlotCollection)
{
if (mainPlotCollection->wellLogPlotCollection())
{
uiTreeOrdering.add(mainPlotCollection->wellLogPlotCollection());
}
if (mainPlotCollection->summaryPlotCollection())
{
uiTreeOrdering.add(mainPlotCollection->summaryPlotCollection());
}
}
uiTreeOrdering.setForgetRemainingFields(true);
return;
}
else
{
if (viewLinkerCollection()->viewLinker())
{
// Use object instead of field to avoid duplicate entries in the tree view
uiTreeOrdering.add(viewLinkerCollection());
}
RimOilField* oilField = activeOilField();
if (oilField)
{
if (oilField->analysisModels()) uiTreeOrdering.add(oilField->analysisModels());
if (oilField->geoMechModels()) uiTreeOrdering.add(oilField->geoMechModels());
if (oilField->wellPathCollection()) uiTreeOrdering.add(oilField->wellPathCollection());
}
uiTreeOrdering.add(scriptCollection());
uiTreeOrdering.setForgetRemainingFields(true);
}
}

View File

@ -18,6 +18,8 @@
#include "RimSummaryPlot.h"
#include "RiaApplication.h"
#include "RimSummaryCurve.h"
#include "RimSummaryCurveFilter.h"
#include "RimSummaryPlotCollection.h"
@ -58,7 +60,10 @@ RimSummaryPlot::RimSummaryPlot()
//--------------------------------------------------------------------------------------------------
RimSummaryPlot::~RimSummaryPlot()
{
RiuMainPlotWindow::instance()->removeViewer(m_qwtPlot);
if (RiaApplication::instance()->mainPlotWindow())
{
RiaApplication::instance()->mainPlotWindow()->removeViewer(m_qwtPlot);
}
deletePlotWidget();
@ -184,7 +189,11 @@ void RimSummaryPlot::setupBeforeSave()
{
if (m_qwtPlot)
{
this->setMdiWindowGeometry(RiuMainPlotWindow::instance()->windowGeometryForViewer(m_qwtPlot));
if (RiaApplication::instance()->mainPlotWindow())
{
this->setMdiWindowGeometry(RiaApplication::instance()->mainPlotWindow()->windowGeometryForViewer(m_qwtPlot));
}
}
}
@ -223,11 +232,13 @@ void RimSummaryPlot::setDescription(const QString& description)
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::updateViewerWidget()
{
RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->getOrCreateMainPlotWindow();
if (m_showWindow())
{
if (!m_qwtPlot)
{
m_qwtPlot = new RiuSummaryQwtPlot(this, RiuMainPlotWindow::instance());
m_qwtPlot = new RiuSummaryQwtPlot(this, mainPlotWindow);
for(RimSummaryCurveFilter* curveFilter: m_curveFilters)
{
@ -239,8 +250,8 @@ void RimSummaryPlot::updateViewerWidget()
curve->setParentQwtPlot(m_qwtPlot);
}
RiuMainPlotWindow::instance()->addViewer(m_qwtPlot, this->mdiWindowGeometry());
RiuMainPlotWindow::instance()->setActiveViewer(m_qwtPlot);
mainPlotWindow->addViewer(m_qwtPlot, this->mdiWindowGeometry());
mainPlotWindow->setActiveViewer(m_qwtPlot);
}
//updateViewerWidgetWindowTitle();
@ -249,9 +260,9 @@ void RimSummaryPlot::updateViewerWidget()
{
if (m_qwtPlot)
{
this->setMdiWindowGeometry(RiuMainPlotWindow::instance()->windowGeometryForViewer(m_qwtPlot));
this->setMdiWindowGeometry(mainPlotWindow->windowGeometryForViewer(m_qwtPlot));
RiuMainPlotWindow::instance()->removeViewer(m_qwtPlot);
mainPlotWindow->removeViewer(m_qwtPlot);
detachAllCurves();
deletePlotWidget();

View File

@ -19,11 +19,13 @@
#include "RimWellLogPlot.h"
#include "RiaApplication.h"
#include "RimWellLogTrack.h"
#include "RiuWellLogPlot.h"
#include "RiuWellLogTrack.h"
#include "RiuMainWindow.h"
#include "RiuMainPlotWindow.h"
#include "cafPdmUiTreeView.h"
@ -85,7 +87,10 @@ RimWellLogPlot::RimWellLogPlot()
//--------------------------------------------------------------------------------------------------
RimWellLogPlot::~RimWellLogPlot()
{
RiuMainWindow::instance()->removeViewer(m_viewer);
if (RiaApplication::instance()->mainPlotWindow())
{
RiaApplication::instance()->mainPlotWindow()->removeViewer(m_viewer);
}
detachAllCurves();
m_tracks.deleteAllChildObjects();
@ -98,16 +103,18 @@ RimWellLogPlot::~RimWellLogPlot()
//--------------------------------------------------------------------------------------------------
void RimWellLogPlot::updateViewerWidget()
{
RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->getOrCreateMainPlotWindow();
if (m_showWindow())
{
if (!m_viewer)
{
m_viewer = new RiuWellLogPlot(this, RiuMainWindow::instance());
m_viewer = new RiuWellLogPlot(this, mainPlotWindow);
recreateTrackPlots();
RiuMainWindow::instance()->addViewer(m_viewer, this->mdiWindowGeometry());
RiuMainWindow::instance()->setActiveViewer(m_viewer);
mainPlotWindow->addViewer(m_viewer, this->mdiWindowGeometry());
mainPlotWindow->setActiveViewer(m_viewer);
}
updateViewerWidgetWindowTitle();
@ -116,14 +123,13 @@ void RimWellLogPlot::updateViewerWidget()
{
if (m_viewer)
{
this->setMdiWindowGeometry( RiuMainWindow::instance()->windowGeometryForViewer(m_viewer));
this->setMdiWindowGeometry(mainPlotWindow->windowGeometryForViewer(m_viewer));
RiuMainWindow::instance()->removeViewer(m_viewer);
mainPlotWindow->removeViewer(m_viewer);
detachAllCurves();
delete m_viewer;
m_viewer = NULL;
}
}
}
@ -365,7 +371,10 @@ void RimWellLogPlot::setupBeforeSave()
{
if (m_viewer)
{
this->setMdiWindowGeometry( RiuMainWindow::instance()->windowGeometryForViewer(m_viewer));
if (RiaApplication::instance()->mainPlotWindow())
{
this->setMdiWindowGeometry(RiaApplication::instance()->mainPlotWindow()->windowGeometryForViewer(m_viewer));
}
}
}

View File

@ -143,23 +143,14 @@ RiuMainPlotWindow::RiuMainPlotWindow()
// When enableUndoCommandSystem is set false, all commands are executed and deleted immediately
//caf::CmdExecCommandManager::instance()->enableUndoCommandSystem(true);
{
setWindowTitle("Summary Plots for ResInsight");
setDefaultWindowSize();
loadWinGeoAndDockToolBarLayout();
showWindow();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuMainPlotWindow* RiuMainPlotWindow::instance()
RiuMainPlotWindow::~RiuMainPlotWindow()
{
static RiuMainPlotWindow staticInstance;
return &staticInstance;
delete m_dragDropInterface;
}
//--------------------------------------------------------------------------------------------------
@ -211,14 +202,6 @@ void RiuMainPlotWindow::cleanupGuiBeforeProjectClose()
//--------------------------------------------------------------------------------------------------
void RiuMainPlotWindow::closeEvent(QCloseEvent* event)
{
if (!RiaApplication::instance()->closeProject(true))
{
event->ignore();
return;
}
delete m_dragDropInterface;
saveWinGeoAndDockToolBarLayout();
event->accept();
@ -578,6 +561,8 @@ void RiuMainPlotWindow::createDockPanels()
connect(m_projectTreeView, SIGNAL(selectionChanged()), this, SLOT(selectedObjectsChanged()));
m_projectTreeView->treeView()->setContextMenuPolicy(Qt::CustomContextMenu);
connect(m_projectTreeView->treeView(), SIGNAL(customContextMenuRequested(const QPoint&)), SLOT(customMenuRequested(const QPoint&)));
m_projectTreeView->setUiConfigurationName("PlotWindow");
}
/*

View File

@ -72,7 +72,7 @@ class RiuMainPlotWindow : public RiuMainWindowBase
public:
RiuMainPlotWindow();
static RiuMainPlotWindow* instance();
~RiuMainPlotWindow();
virtual QString mainWindowName() { return "RiuMainPlotWindow"; }
@ -289,8 +289,6 @@ private:
caf::PdmUiDragDropInterface* m_dragDropInterface;
QUndoView* m_undoView;
caf::PdmObject* m_pdmRoot;
caf::PdmUiPropertyView* m_pdmUiPropertyView;

View File

@ -18,11 +18,14 @@
#include "RiuMdiSubWindow.h"
#include "RiaApplication.h"
#include "RimSummaryPlot.h"
#include "RimView.h"
#include "RimWellLogPlot.h"
#include "RiuMainPlotWindow.h"
#include "RiuMainWindow.h"
#include "RiuSummaryQwtPlot.h"
#include "RiuViewer.h"
#include "RiuWellLogPlot.h"
@ -40,7 +43,12 @@ RiuMdiSubWindow::RiuMdiSubWindow(QWidget* parent /*= 0*/, Qt::WindowFlags flags
//--------------------------------------------------------------------------------------------------
RiuMdiSubWindow::~RiuMdiSubWindow()
{
RiuMainPlotWindow::instance()->slotRefreshViewActions();
RiuMainWindow::instance()->slotRefreshViewActions();
if (RiaApplication::instance()->mainPlotWindow())
{
RiaApplication::instance()->mainPlotWindow()->slotRefreshViewActions();
}
}
//--------------------------------------------------------------------------------------------------
@ -54,18 +62,24 @@ void RiuMdiSubWindow::closeEvent(QCloseEvent* event)
RiuSummaryQwtPlot* summaryPlot = dynamic_cast<RiuSummaryQwtPlot*>(mainWidget);
if (wellLogPlot)
{
wellLogPlot->ownerPlotDefinition()->setMdiWindowGeometry(RiuMainPlotWindow::instance()->windowGeometryForWidget(this));
RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow();
CVF_ASSERT(mainPlotWindow);
wellLogPlot->ownerPlotDefinition()->setMdiWindowGeometry(mainPlotWindow->windowGeometryForWidget(this));
}
else if (summaryPlot)
{
summaryPlot->ownerPlotDefinition()->setMdiWindowGeometry(RiuMainPlotWindow::instance()->windowGeometryForWidget(this));
RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow();
CVF_ASSERT(mainPlotWindow);
summaryPlot->ownerPlotDefinition()->setMdiWindowGeometry(mainPlotWindow->windowGeometryForWidget(this));
}
else
{
RiuViewer* viewer = mainWidget->findChild<RiuViewer*>();
if (viewer)
{
viewer->ownerReservoirView()->setMdiWindowGeometry(RiuMainPlotWindow::instance()->windowGeometryForWidget(this));
viewer->ownerReservoirView()->setMdiWindowGeometry(RiuMainWindow::instance()->windowGeometryForWidget(this));
}
}