mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2331 Moved redraw scheduling and completion type recalc out of RiaApplication
This commit is contained in:
parent
591b72901f
commit
4b26354b30
@ -6,21 +6,25 @@ endif()
|
||||
|
||||
set (SOURCE_GROUP_HEADER_FILES
|
||||
${CEE_CURRENT_LIST_DIR}RiaApplication.h
|
||||
${CEE_CURRENT_LIST_DIR}RiaCompletionTypeCalculationScheduler.h
|
||||
${CEE_CURRENT_LIST_DIR}RiaDefines.h
|
||||
${CEE_CURRENT_LIST_DIR}RiaPreferences.h
|
||||
${CEE_CURRENT_LIST_DIR}RiaPorosityModel.h
|
||||
${CEE_CURRENT_LIST_DIR}RiaSummaryCurveDefinition.h
|
||||
${CEE_CURRENT_LIST_DIR}RiaRftPltCurveDefinition.h
|
||||
${CEE_CURRENT_LIST_DIR}RiaViewRedrawScheduler.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
${CEE_CURRENT_LIST_DIR}RiaApplication.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RiaCompletionTypeCalculationScheduler.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RiaDefines.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RiaMain.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RiaPreferences.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RiaPorosityModel.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RiaSummaryCurveDefinition.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RiaRftPltCurveDefinition.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RiaViewRedrawScheduler.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
@ -34,6 +38,8 @@ ${SOURCE_GROUP_SOURCE_FILES}
|
||||
set (QT_MOC_HEADERS
|
||||
${QT_MOC_HEADERS}
|
||||
${CEE_CURRENT_LIST_DIR}RiaApplication.h
|
||||
${CEE_CURRENT_LIST_DIR}RiaCompletionTypeCalculationScheduler.h
|
||||
${CEE_CURRENT_LIST_DIR}RiaViewRedrawScheduler.h
|
||||
)
|
||||
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RiaArgumentParser.h"
|
||||
#include "RiaBaseDefs.h"
|
||||
#include "RiaImageCompareReporter.h"
|
||||
#include "RiaImageFileCompare.h"
|
||||
@ -29,7 +30,7 @@
|
||||
#include "RiaProjectModifier.h"
|
||||
#include "RiaSocketServer.h"
|
||||
#include "RiaVersionInfo.h"
|
||||
#include "RiaArgumentParser.h"
|
||||
#include "RiaViewRedrawScheduler.h"
|
||||
|
||||
#include "RigGridManager.h"
|
||||
#include "RigEclipseCaseData.h"
|
||||
@ -227,9 +228,6 @@ RiaApplication::RiaApplication(int& argc, char** argv)
|
||||
// instead of using the application font
|
||||
m_standardFont = new caf::FixedAtlasFont(caf::FixedAtlasFont::POINT_SIZE_8);
|
||||
|
||||
m_resViewUpdateTimer = nullptr;
|
||||
m_recalculateCompletionTypeTimer = nullptr;
|
||||
|
||||
m_runningRegressionTests = false;
|
||||
|
||||
m_runningWorkerProcess = false;
|
||||
@ -970,7 +968,7 @@ void RiaApplication::closeProject()
|
||||
{
|
||||
RiuMainWindow* mainWnd = RiuMainWindow::instance();
|
||||
|
||||
clearViewsScheduledForUpdate();
|
||||
RiaViewRedrawScheduler::instance()->clearViewsScheduledForUpdate();
|
||||
|
||||
terminateProcess();
|
||||
|
||||
@ -2221,21 +2219,6 @@ cvf::Font* RiaApplication::customFont()
|
||||
return m_customFont.p();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaApplication::clearViewsScheduledForUpdate()
|
||||
{
|
||||
if (m_resViewUpdateTimer)
|
||||
{
|
||||
while (m_resViewUpdateTimer->isActive())
|
||||
{
|
||||
QCoreApplication::processEvents();
|
||||
}
|
||||
}
|
||||
m_resViewsToUpdate.clear();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -2308,136 +2291,6 @@ QString RiaApplication::commandLineParameterHelp() const
|
||||
*/
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Schedule a creation of the Display model and redraw of the reservoir view
|
||||
/// The redraw will happen as soon as the event loop is entered
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaApplication::scheduleDisplayModelUpdateAndRedraw(Rim3dView* resViewToUpdate)
|
||||
{
|
||||
m_resViewsToUpdate.push_back(resViewToUpdate);
|
||||
|
||||
if (!m_resViewUpdateTimer)
|
||||
{
|
||||
m_resViewUpdateTimer = new QTimer(this);
|
||||
connect(m_resViewUpdateTimer, SIGNAL(timeout()), this, SLOT(slotUpdateScheduledDisplayModels()));
|
||||
}
|
||||
|
||||
if (!m_resViewUpdateTimer->isActive())
|
||||
{
|
||||
m_resViewUpdateTimer->setSingleShot(true);
|
||||
m_resViewUpdateTimer->start(0);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaApplication::scheduleRecalculateCompletionTypeAndRedrawAllViews()
|
||||
{
|
||||
for (RimEclipseCase* eclipseCase : project()->activeOilField()->analysisModels->cases())
|
||||
{
|
||||
m_eclipseCasesToRecalculate.push_back(eclipseCase);
|
||||
}
|
||||
|
||||
if (!m_recalculateCompletionTypeTimer)
|
||||
{
|
||||
m_recalculateCompletionTypeTimer = new QTimer(this);
|
||||
m_recalculateCompletionTypeTimer->setSingleShot(true);
|
||||
connect(m_recalculateCompletionTypeTimer, SIGNAL(timeout()), this, SLOT(slotRecalculateCompletionType()));
|
||||
}
|
||||
|
||||
m_recalculateCompletionTypeTimer->start(1500);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaApplication::scheduleRecalculateCompletionTypeAndRedrawEclipseCase(RimEclipseCase* eclipseCase)
|
||||
{
|
||||
m_eclipseCasesToRecalculate.push_back(eclipseCase);
|
||||
|
||||
|
||||
if (!m_recalculateCompletionTypeTimer)
|
||||
{
|
||||
m_recalculateCompletionTypeTimer = new QTimer(this);
|
||||
m_recalculateCompletionTypeTimer->setSingleShot(true);
|
||||
connect(m_recalculateCompletionTypeTimer, SIGNAL(timeout()), this, SLOT(slotRecalculateCompletionType()));
|
||||
}
|
||||
|
||||
m_recalculateCompletionTypeTimer->start(500);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaApplication::slotUpdateScheduledDisplayModels()
|
||||
{
|
||||
// Compress to remove duplicates
|
||||
// and update dependent views after independent views
|
||||
|
||||
std::set<Rim3dView*> independent3DViewsToUpdate;
|
||||
std::set<Rim3dView*> dependent3DViewsToUpdate;
|
||||
|
||||
for (size_t i = 0; i < m_resViewsToUpdate.size(); ++i)
|
||||
{
|
||||
if (!m_resViewsToUpdate[i]) continue;
|
||||
|
||||
if (m_resViewsToUpdate[i]->viewController())
|
||||
dependent3DViewsToUpdate.insert(m_resViewsToUpdate[i]);
|
||||
else
|
||||
independent3DViewsToUpdate.insert(m_resViewsToUpdate[i]);
|
||||
}
|
||||
|
||||
for (std::set<Rim3dView*>::iterator it = independent3DViewsToUpdate.begin(); it != independent3DViewsToUpdate.end(); ++it )
|
||||
{
|
||||
if (*it)
|
||||
{
|
||||
(*it)->createDisplayModelAndRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
for (std::set<Rim3dView*>::iterator it = dependent3DViewsToUpdate.begin(); it != dependent3DViewsToUpdate.end(); ++it)
|
||||
{
|
||||
if (*it)
|
||||
{
|
||||
(*it)->createDisplayModelAndRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
m_resViewsToUpdate.clear();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaApplication::slotRecalculateCompletionType()
|
||||
{
|
||||
std::set<RimEclipseCase*> uniqueCases(m_eclipseCasesToRecalculate.begin(), m_eclipseCasesToRecalculate.end());
|
||||
|
||||
Rim3dView* activeView = RiaApplication::instance()->activeReservoirView();
|
||||
QModelIndex mi = RiuMainWindow::instance()->projectTreeView()->treeView()->currentIndex();
|
||||
|
||||
for (RimEclipseCase* eclipseCase : uniqueCases)
|
||||
{
|
||||
eclipseCase->recalculateCompletionTypeAndRedrawAllViews();
|
||||
}
|
||||
|
||||
m_eclipseCasesToRecalculate.clear();
|
||||
|
||||
// Recalculation of completion type causes active view to be set to potentially a different view
|
||||
// Also current index in project tree is changed. Restore both to initial state.
|
||||
|
||||
if (activeView && activeView->viewer())
|
||||
{
|
||||
RiaApplication::instance()->setActiveReservoirView(activeView);
|
||||
RiuMainWindow::instance()->setActiveViewer(activeView->viewer()->layoutWidget());
|
||||
}
|
||||
|
||||
if (mi.isValid())
|
||||
{
|
||||
RiuMainWindow::instance()->projectTreeView()->treeView()->setCurrentIndex(mi);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
|
@ -105,10 +105,6 @@ public:
|
||||
|
||||
RimViewWindow* activePlotWindow() const;
|
||||
|
||||
void scheduleDisplayModelUpdateAndRedraw(Rim3dView* resViewToUpdate);
|
||||
void scheduleRecalculateCompletionTypeAndRedrawAllViews();
|
||||
void scheduleRecalculateCompletionTypeAndRedrawEclipseCase(RimEclipseCase* eclipseCase);
|
||||
|
||||
RimProject* project();
|
||||
|
||||
void createMockModel();
|
||||
@ -205,7 +201,6 @@ public:
|
||||
|
||||
static std::vector<QString> readFileListFromTextFile(QString listFileName);
|
||||
|
||||
void clearViewsScheduledForUpdate();
|
||||
|
||||
private:
|
||||
|
||||
@ -224,29 +219,19 @@ private:
|
||||
void regressionTestConfigureProject();
|
||||
static QSize regressionDefaultImageSize();
|
||||
|
||||
friend RiaArgumentParser;
|
||||
void setHelpText(const QString& helpText);
|
||||
|
||||
private slots:
|
||||
void slotWorkerProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
|
||||
void slotUpdateScheduledDisplayModels();
|
||||
void slotRecalculateCompletionType();
|
||||
|
||||
// Friend classes required to have access to slotUpdateScheduledDisplayModels
|
||||
// As snapshots are produced fast in sequence, the feature must have access to force redraw
|
||||
// of scheduled redraws
|
||||
friend class Rim3dView;
|
||||
friend class RicExportMultipleSnapshotsFeature;
|
||||
friend class RiaArgumentParser;
|
||||
|
||||
|
||||
private:
|
||||
caf::PdmPointer<Rim3dView> m_activeReservoirView;
|
||||
|
||||
caf::PdmPointer<RimProject> m_project;
|
||||
|
||||
std::vector<caf::PdmPointer<Rim3dView> > m_resViewsToUpdate;
|
||||
QTimer* m_resViewUpdateTimer;
|
||||
std::vector<caf::PdmPointer<RimEclipseCase> > m_eclipseCasesToRecalculate;
|
||||
QTimer* m_recalculateCompletionTypeTimer;
|
||||
|
||||
RiaSocketServer* m_socketServer;
|
||||
|
||||
|
@ -0,0 +1,121 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- Statoil ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiaCompletionTypeCalculationScheduler.h"
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimEclipseCaseCollection.h"
|
||||
#include "RiaApplication.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimProject.h"
|
||||
|
||||
#include <QTimer>
|
||||
#include <set>
|
||||
#include "QAbstractItemModel"
|
||||
#include "RiuMainWindow.h"
|
||||
#include "cafPdmUiTreeView.h"
|
||||
#include <QTreeView>
|
||||
#include "Rim3dView.h"
|
||||
#include "RiuViewer.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiaCompletionTypeCalculationScheduler* RiaCompletionTypeCalculationScheduler::instance()
|
||||
{
|
||||
static RiaCompletionTypeCalculationScheduler theInstance;
|
||||
|
||||
return &theInstance;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaCompletionTypeCalculationScheduler::scheduleRecalculateCompletionTypeAndRedrawAllViews()
|
||||
{
|
||||
for (RimEclipseCase* eclipseCase : RiaApplication::instance()->project()->activeOilField()->analysisModels->cases())
|
||||
{
|
||||
m_eclipseCasesToRecalculate.push_back(eclipseCase);
|
||||
}
|
||||
|
||||
if (!m_recalculateCompletionTypeTimer)
|
||||
{
|
||||
m_recalculateCompletionTypeTimer = new QTimer(this);
|
||||
m_recalculateCompletionTypeTimer->setSingleShot(true);
|
||||
connect(m_recalculateCompletionTypeTimer, SIGNAL(timeout()), this, SLOT(slotRecalculateCompletionType()));
|
||||
}
|
||||
|
||||
m_recalculateCompletionTypeTimer->start(1500);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaCompletionTypeCalculationScheduler::scheduleRecalculateCompletionTypeAndRedrawEclipseCase(RimEclipseCase* eclipseCase)
|
||||
{
|
||||
m_eclipseCasesToRecalculate.push_back(eclipseCase);
|
||||
|
||||
|
||||
if (!m_recalculateCompletionTypeTimer)
|
||||
{
|
||||
m_recalculateCompletionTypeTimer = new QTimer(this);
|
||||
m_recalculateCompletionTypeTimer->setSingleShot(true);
|
||||
connect(m_recalculateCompletionTypeTimer, SIGNAL(timeout()), this, SLOT(slotRecalculateCompletionType()));
|
||||
}
|
||||
|
||||
m_recalculateCompletionTypeTimer->start(1500);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaCompletionTypeCalculationScheduler::slotRecalculateCompletionType()
|
||||
{
|
||||
std::set<RimEclipseCase*> uniqueCases(m_eclipseCasesToRecalculate.begin(), m_eclipseCasesToRecalculate.end());
|
||||
|
||||
Rim3dView* activeView = RiaApplication::instance()->activeReservoirView();
|
||||
QModelIndex mi = RiuMainWindow::instance()->projectTreeView()->treeView()->currentIndex();
|
||||
|
||||
for (RimEclipseCase* eclipseCase : uniqueCases)
|
||||
{
|
||||
eclipseCase->recalculateCompletionTypeAndRedrawAllViews();
|
||||
}
|
||||
|
||||
m_eclipseCasesToRecalculate.clear();
|
||||
|
||||
// Recalculation of completion type causes active view to be set to potentially a different view
|
||||
// Also current index in project tree is changed. Restore both to initial state.
|
||||
|
||||
if (activeView && activeView->viewer())
|
||||
{
|
||||
RiaApplication::instance()->setActiveReservoirView(activeView);
|
||||
RiuMainWindow::instance()->setActiveViewer(activeView->viewer()->layoutWidget());
|
||||
}
|
||||
|
||||
if (mi.isValid())
|
||||
{
|
||||
RiuMainWindow::instance()->projectTreeView()->treeView()->setCurrentIndex(mi);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiaCompletionTypeCalculationScheduler::~RiaCompletionTypeCalculationScheduler()
|
||||
{
|
||||
delete m_recalculateCompletionTypeTimer;
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- Statoil ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <vector>
|
||||
#include "cafPdmPointer.h"
|
||||
|
||||
class QTimer;
|
||||
class RimEclipseCase;
|
||||
|
||||
|
||||
class RiaCompletionTypeCalculationScheduler : public QObject
|
||||
{
|
||||
Q_OBJECT;
|
||||
public:
|
||||
static RiaCompletionTypeCalculationScheduler* instance();
|
||||
void scheduleRecalculateCompletionTypeAndRedrawAllViews();
|
||||
void scheduleRecalculateCompletionTypeAndRedrawEclipseCase(RimEclipseCase* eclipseCase);
|
||||
|
||||
private slots:
|
||||
void slotRecalculateCompletionType();
|
||||
|
||||
private:
|
||||
RiaCompletionTypeCalculationScheduler() : m_recalculateCompletionTypeTimer(nullptr) {}
|
||||
~RiaCompletionTypeCalculationScheduler();
|
||||
|
||||
RiaCompletionTypeCalculationScheduler(const RiaCompletionTypeCalculationScheduler& o) = delete;
|
||||
void operator=(const RiaCompletionTypeCalculationScheduler& o) = delete;
|
||||
|
||||
std::vector<caf::PdmPointer<RimEclipseCase> > m_eclipseCasesToRecalculate;
|
||||
QTimer* m_recalculateCompletionTypeTimer;
|
||||
};
|
||||
|
||||
|
122
ApplicationCode/Application/RiaViewRedrawScheduler.cpp
Normal file
122
ApplicationCode/Application/RiaViewRedrawScheduler.cpp
Normal file
@ -0,0 +1,122 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- Statoil ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiaViewRedrawScheduler.h"
|
||||
#include "Rim3dView.h"
|
||||
|
||||
#include <QTimer>
|
||||
#include <QCoreApplication>
|
||||
|
||||
#include <set>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiaViewRedrawScheduler* RiaViewRedrawScheduler::instance()
|
||||
{
|
||||
static RiaViewRedrawScheduler theInstance;
|
||||
|
||||
return &theInstance;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaViewRedrawScheduler::clearViewsScheduledForUpdate()
|
||||
{
|
||||
if (m_resViewUpdateTimer)
|
||||
{
|
||||
while (m_resViewUpdateTimer->isActive())
|
||||
{
|
||||
QCoreApplication::processEvents();
|
||||
}
|
||||
}
|
||||
m_resViewsToUpdate.clear();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Schedule a creation of the Display model and redraw of the reservoir view
|
||||
/// The redraw will happen as soon as the event loop is entered
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaViewRedrawScheduler::scheduleDisplayModelUpdateAndRedraw(Rim3dView* resViewToUpdate)
|
||||
{
|
||||
m_resViewsToUpdate.push_back(resViewToUpdate);
|
||||
|
||||
if (!m_resViewUpdateTimer)
|
||||
{
|
||||
m_resViewUpdateTimer = new QTimer(this);
|
||||
connect(m_resViewUpdateTimer, SIGNAL(timeout()), this, SLOT(slotUpdateScheduledDisplayModels()));
|
||||
}
|
||||
|
||||
if (!m_resViewUpdateTimer->isActive())
|
||||
{
|
||||
m_resViewUpdateTimer->setSingleShot(true);
|
||||
m_resViewUpdateTimer->start(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaViewRedrawScheduler::slotUpdateScheduledDisplayModels()
|
||||
{
|
||||
// Compress to remove duplicates
|
||||
// and update dependent views after independent views
|
||||
|
||||
std::set<Rim3dView*> independent3DViewsToUpdate;
|
||||
std::set<Rim3dView*> dependent3DViewsToUpdate;
|
||||
|
||||
for (size_t i = 0; i < m_resViewsToUpdate.size(); ++i)
|
||||
{
|
||||
if (!m_resViewsToUpdate[i]) continue;
|
||||
|
||||
if (m_resViewsToUpdate[i]->viewController())
|
||||
dependent3DViewsToUpdate.insert(m_resViewsToUpdate[i]);
|
||||
else
|
||||
independent3DViewsToUpdate.insert(m_resViewsToUpdate[i]);
|
||||
}
|
||||
|
||||
for (std::set<Rim3dView*>::iterator it = independent3DViewsToUpdate.begin(); it != independent3DViewsToUpdate.end(); ++it )
|
||||
{
|
||||
if (*it)
|
||||
{
|
||||
(*it)->createDisplayModelAndRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
for (std::set<Rim3dView*>::iterator it = dependent3DViewsToUpdate.begin(); it != dependent3DViewsToUpdate.end(); ++it)
|
||||
{
|
||||
if (*it)
|
||||
{
|
||||
(*it)->createDisplayModelAndRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
m_resViewsToUpdate.clear();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiaViewRedrawScheduler::~RiaViewRedrawScheduler()
|
||||
{
|
||||
delete m_resViewUpdateTimer;
|
||||
}
|
51
ApplicationCode/Application/RiaViewRedrawScheduler.h
Normal file
51
ApplicationCode/Application/RiaViewRedrawScheduler.h
Normal file
@ -0,0 +1,51 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- Statoil ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <vector>
|
||||
#include "cafPdmPointer.h"
|
||||
|
||||
class QTimer;
|
||||
class Rim3dView;
|
||||
|
||||
|
||||
class RiaViewRedrawScheduler : public QObject
|
||||
{
|
||||
Q_OBJECT;
|
||||
public:
|
||||
static RiaViewRedrawScheduler* instance();
|
||||
void scheduleDisplayModelUpdateAndRedraw(Rim3dView* resViewToUpdate);
|
||||
void clearViewsScheduledForUpdate();
|
||||
|
||||
public slots:
|
||||
void slotUpdateScheduledDisplayModels();
|
||||
|
||||
private:
|
||||
RiaViewRedrawScheduler() : m_resViewUpdateTimer(nullptr) {}
|
||||
~RiaViewRedrawScheduler();
|
||||
|
||||
RiaViewRedrawScheduler(const RiaViewRedrawScheduler& o) = delete;
|
||||
void operator=(const RiaViewRedrawScheduler& o) = delete;
|
||||
|
||||
std::vector<caf::PdmPointer<Rim3dView> > m_resViewsToUpdate;
|
||||
QTimer* m_resViewUpdateTimer;
|
||||
};
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "RicExportMultipleSnapshotsFeature.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaViewRedrawScheduler.h"
|
||||
|
||||
#include "RicSnapshotViewToFileFeature.h"
|
||||
|
||||
@ -229,7 +230,7 @@ void RicExportMultipleSnapshotsFeature::exportViewVariationsToFolder(Rim3dView*
|
||||
// Force update of scheduled display models modifying the time step
|
||||
// This is required due to visualization structures updated by the update functions,
|
||||
// and this is not triggered by changing time step only
|
||||
RiaApplication::instance()->slotUpdateScheduledDisplayModels();
|
||||
RiaViewRedrawScheduler::instance()->slotUpdateScheduledDisplayModels();
|
||||
|
||||
viewer->setCurrentFrame(i);
|
||||
viewer->animationControl()->setCurrentFrameOnly(i);
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaLogging.h"
|
||||
#include "RiaViewRedrawScheduler.h"
|
||||
|
||||
#include "RimMainPlotCollection.h"
|
||||
#include "RimProject.h"
|
||||
@ -110,7 +111,7 @@ void RicSnapshotAllViewsToFileFeature::exportSnapshotOfAllViewsIntoFolder(QStrin
|
||||
RiuViewer* viewer = riv->viewer();
|
||||
mainWnd->setActiveViewer(viewer->layoutWidget());
|
||||
|
||||
RiaApplication::instance()->clearViewsScheduledForUpdate();
|
||||
RiaViewRedrawScheduler::instance()->clearViewsScheduledForUpdate();
|
||||
|
||||
//riv->updateCurrentTimeStepAndRedraw();
|
||||
riv->createDisplayModelAndRedraw();
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaPreferences.h"
|
||||
#include "RiaViewRedrawScheduler.h"
|
||||
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
@ -317,7 +318,7 @@ QImage Rim3dView::snapshotWindowContent()
|
||||
if (m_viewer)
|
||||
{
|
||||
// Force update of scheduled display models before snapshotting
|
||||
RiaApplication::instance()->slotUpdateScheduledDisplayModels();
|
||||
RiaViewRedrawScheduler::instance()->slotUpdateScheduledDisplayModels();
|
||||
|
||||
m_viewer->repaint();
|
||||
|
||||
@ -332,7 +333,7 @@ QImage Rim3dView::snapshotWindowContent()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void Rim3dView::scheduleCreateDisplayModelAndRedraw()
|
||||
{
|
||||
RiaApplication::instance()->scheduleDisplayModelUpdateAndRedraw(this);
|
||||
RiaViewRedrawScheduler::instance()->scheduleDisplayModelUpdateAndRedraw(this);
|
||||
if (this->isMasterView())
|
||||
{
|
||||
RimViewLinker* viewLinker = this->assosiatedViewLinker();
|
||||
|
@ -182,21 +182,6 @@ protected:
|
||||
|
||||
virtual void resetLegendsInViewer() = 0;
|
||||
virtual void calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility, int timeStep) = 0;
|
||||
|
||||
// Overridden PdmObject methods:
|
||||
|
||||
virtual caf::PdmFieldHandle* userDescriptionField() override { return &name; }
|
||||
virtual void setupBeforeSave() override;
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||
|
||||
// Overridden ViewWindow methods:
|
||||
|
||||
virtual QWidget* createViewWidget(QWidget* mainWindowParent) override;
|
||||
virtual void updateViewWidgetAfterCreation() override;
|
||||
virtual void updateMdiWindowTitle() override;
|
||||
virtual void deleteViewWidget() override;
|
||||
virtual QWidget* viewWidget() override;
|
||||
|
||||
protected: // Fields
|
||||
caf::PdmField<int> m_currentTimeStep;
|
||||
@ -219,6 +204,23 @@ protected:
|
||||
private:
|
||||
RimViewLinker* viewLinkerIfMasterView() const;
|
||||
|
||||
// Overridden PdmObject methods:
|
||||
|
||||
virtual caf::PdmFieldHandle* userDescriptionField() override { return &name; }
|
||||
virtual void setupBeforeSave() override;
|
||||
protected:
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||
|
||||
private:
|
||||
// Overridden ViewWindow methods:
|
||||
|
||||
virtual QWidget* createViewWidget(QWidget* mainWindowParent) override;
|
||||
virtual void updateViewWidgetAfterCreation() override;
|
||||
virtual void updateMdiWindowTitle() override;
|
||||
virtual void deleteViewWidget() override;
|
||||
virtual QWidget* viewWidget() override;
|
||||
|
||||
// Implementation of RiuViewerToViewInterface
|
||||
|
||||
virtual cvf::Color3f backgroundColor() const override { return m_backgroundColor();}
|
||||
|
@ -80,6 +80,7 @@
|
||||
|
||||
#include <QDir>
|
||||
#include <QMenu>
|
||||
#include "RiaCompletionTypeCalculationScheduler.h"
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimProject, "ResInsightProject");
|
||||
@ -788,7 +789,7 @@ bool RimProject::showPlotWindow() const
|
||||
void RimProject::reloadCompletionTypeResultsInAllViews()
|
||||
{
|
||||
createDisplayModelAndRedrawAllViews();
|
||||
RiaApplication::instance()->scheduleRecalculateCompletionTypeAndRedrawAllViews();
|
||||
RiaCompletionTypeCalculationScheduler::instance()->scheduleRecalculateCompletionTypeAndRedrawAllViews();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -955,7 +956,7 @@ void RimProject::reloadCompletionTypeResultsForEclipseCase(RimEclipseCase* eclip
|
||||
views[viewIdx]->scheduleCreateDisplayModelAndRedraw();
|
||||
}
|
||||
|
||||
RiaApplication::instance()->scheduleRecalculateCompletionTypeAndRedrawEclipseCase(eclipseCase);
|
||||
RiaCompletionTypeCalculationScheduler::instance()->scheduleRecalculateCompletionTypeAndRedrawEclipseCase(eclipseCase);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user