Sceduled Update-display-model-And-Redraw system

p4#: 22343
This commit is contained in:
Jacob Støren 2013-09-07 10:27:22 +02:00
parent c3c50ae62e
commit bb2af8269e
2 changed files with 48 additions and 1 deletions

View File

@ -1612,3 +1612,45 @@ QString RiaApplication::commandLineParameterHelp() const
return text;
}
//--------------------------------------------------------------------------------------------------
/// 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(RimReservoirView* 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::slotUpdateScheduledDisplayModels()
{
// Compress to remove duplicates
std::set<RimReservoirView*> resViewsToUpdate;
for (size_t i = 0; i < m_resViewsToUpdate.size(); ++i)
{
resViewsToUpdate.insert(m_resViewsToUpdate[i]);
}
for (std::set<RimReservoirView*>::iterator it = resViewsToUpdate.begin(); it != resViewsToUpdate.end(); ++it )
{
if (*it)
{
(*it)->createDisplayModelAndRedraw();
}
}
}

View File

@ -68,6 +68,8 @@ public:
RimReservoirView* activeReservoirView();
const RimReservoirView* activeReservoirView() const;
void scheduleDisplayModelUpdateAndRedraw(RimReservoirView* resViewToUpdate);
RimProject* project();
void createMockModel();
@ -137,11 +139,15 @@ private:
private slots:
void slotWorkerProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
void slotUpdateScheduledDisplayModels();
private:
caf::PdmPointer<RimReservoirView> m_activeReservoirView;
caf::PdmPointer<RimProject> m_project;
std::vector<caf::PdmPointer<RimReservoirView> > m_resViewsToUpdate;
QTimer* m_resViewUpdateTimer;
RiaSocketServer* m_socketServer;
caf::UiProcess* m_workerProcess;
@ -151,7 +157,6 @@ private:
QString m_currentProgram;
QStringList m_currentArguments;
RiaPreferences* m_preferences;
std::map<QString, QString> m_fileDialogDefaultDirectories;