Skip to content

Commit

Permalink
Merge pull request #69 from OPM/internal
Browse files Browse the repository at this point in the history
ResInsight 0.9.28
  • Loading branch information
magnesj committed Sep 20, 2013
2 parents f1ca636 + 1ddc0a4 commit 921048b
Show file tree
Hide file tree
Showing 139 changed files with 442,977 additions and 277 deletions.
103 changes: 97 additions & 6 deletions ApplicationCode/Application/RiaApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,24 @@ bool RiaApplication::loadProject(const QString& projectFileName)
caseProgress.incrementProgress();
}

// NB! This function must be called before executing command objects,
// because the tree view state is restored from project file and sets
// current active view ( see restoreTreeViewState() )
// Default behavior for scripts is to use current active view for data read/write
onProjectOpenedOrClosed();
processEvents();

// Loop over command objects and execute them
for (size_t i = 0; i < m_project->commandObjects.size(); i++)
{
m_commandQueue.push_back(m_project->commandObjects[i]);
}

// Lock the command queue
m_commandQueueLock.lock();

// Execute command objects, and release the mutex when the queue is empty
executeCommandObjects();

return true;
}
Expand Down Expand Up @@ -495,6 +512,8 @@ bool RiaApplication::closeProject(bool askToSaveIfDirty)
caf::EffectGenerator::clearEffectCache();
m_project->close();

m_commandQueue.clear();

onProjectOpenedOrClosed();

return true;
Expand Down Expand Up @@ -855,9 +874,11 @@ bool RiaApplication::parseArguments()
if (mainWnd)
{
mainWnd->hideAllDockWindows();
}

runRegressionTest(regressionTestPath);
runRegressionTest(regressionTestPath);

mainWnd->loadWinGeoAndDockToolBarLayout();
}

return false;
}
Expand Down Expand Up @@ -959,6 +980,10 @@ void RiaApplication::slotWorkerProcessFinished(int exitCode, QProcess::ExitStatu
return;
}


executeCommandObjects();


// Exit code != 0 means we have an error
if (exitCode != 0)
{
Expand Down Expand Up @@ -1000,6 +1025,18 @@ bool RiaApplication::launchProcess(const QString& program, const QStringList& ar
}

m_workerProcess = new caf::UiProcess(this);

// Set the LD_LIBRARY_PATH to make the octave plugins find the embedded Qt

QProcessEnvironment penv = m_workerProcess->processEnvironment();
QString ldPath = penv.value("LD_LIBRARY_PATH", "");

if (ldPath == "") ldPath = QApplication::applicationDirPath();
else ldPath = QApplication::applicationDirPath() + ":" + ldPath;

penv.insert("LD_LIBRARY_PATH", ldPath);
m_workerProcess->setProcessEnvironment(penv);

connect(m_workerProcess, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(slotWorkerProcessFinished(int, QProcess::ExitStatus)));

RiuMainWindow::instance()->processMonitor()->startMonitorWorkProcess(m_workerProcess);
Expand Down Expand Up @@ -1252,12 +1289,12 @@ void RiaApplication::saveSnapshotForAllViews(const QString& snapshotFolderName)
QString snapshotPath = projectDir.absolutePath();
snapshotPath += "/" + snapshotFolderName;

RimAnalysisModels* analysisModels = m_project->activeOilField() ? m_project->activeOilField()->analysisModels() : NULL;
if (analysisModels == NULL) return;
std::vector<RimCase*> projectCases;
m_project->allCases(projectCases);

for (size_t i = 0; i < analysisModels->cases().size(); ++i)
for (size_t i = 0; i < projectCases.size(); i++)
{
RimCase* ri = analysisModels->cases()[i];
RimCase* ri = projectCases[i];
if (!ri) continue;

for (size_t j = 0; j < ri->reservoirViews().size(); j++)
Expand Down Expand Up @@ -1358,6 +1395,14 @@ void RiaApplication::runRegressionTest(const QString& testRootPath)
if (testCaseFolder.exists(regTestProjectName))
{
loadProject(testCaseFolder.filePath(regTestProjectName));

// Wait until all command objects have completed
while (!m_commandQueueLock.tryLock())
{
processEvents();
}
m_commandQueueLock.unlock();

saveSnapshotForAllViews(generatedFolderName);

QDir baseDir(testCaseFolder.filePath(baseFolderName));
Expand Down Expand Up @@ -1678,3 +1723,49 @@ QVariant RiaApplication::cacheDataObject(const QString& key) const
return QVariant();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication::addCommandObject(RimCommandObject* commandObject)
{
m_commandQueue.push_back(commandObject);
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication::executeCommandObjects()
{
std::list< RimCommandObject* >::iterator it = m_commandQueue.begin();
while (it != m_commandQueue.end())
{
RimCommandObject* toBeRemoved = *it;
if (!toBeRemoved->isAsyncronous())
{
toBeRemoved->redo();

it++;
m_commandQueue.remove(toBeRemoved);
}
else
{
it++;
}
}

if (m_commandQueue.size() > 0)
{
std::list< RimCommandObject* >::iterator it = m_commandQueue.begin();

RimCommandObject* first = *it;
first->redo();

m_commandQueue.pop_front();
}
else
{
// Unlock the command queue lock when the command queue is empty
m_commandQueueLock.unlock();
}
}

9 changes: 9 additions & 0 deletions ApplicationCode/Application/RiaApplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#pragma once
#include <QApplication>
#include <QProcess>
#include <QMutex>

#include "cafPdmObject.h"
#include "cafPdmField.h"
#include "cvfBase.h"
Expand All @@ -35,6 +37,7 @@ class RiaSocketServer;
class RiaPreferences;
class RimReservoirView;
class RimProject;
class RimCommandObject;

namespace caf
{
Expand Down Expand Up @@ -133,6 +136,9 @@ class RiaApplication : public QApplication
void setCacheDataObject(const QString& key, const QVariant& dataObject);
QVariant cacheDataObject(const QString& key) const;

void addCommandObject(RimCommandObject* commandObject);
void executeCommandObjects();

private:
void onProjectOpenedOrClosed();
void setWindowCaptionFromAppState();
Expand Down Expand Up @@ -168,4 +174,7 @@ private slots:
cvf::ref<cvf::Font> m_standardFont;

QMap<QString, QVariant> m_sessionCache; // Session cache used to store username/passwords per session

std::list<RimCommandObject*> m_commandQueue;
QMutex m_commandQueueLock;
};
10 changes: 4 additions & 6 deletions ApplicationCode/Application/RiaPreferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,10 @@ void RiaPreferences::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering&
//--------------------------------------------------------------------------------------------------
void RiaPreferences::resetToDefaults()
{
std::vector<caf::PdmFieldHandle*> fields;
this->fields(fields);
useShaders = true;
showHud = false;

for (size_t i = 0; i < fields.size(); ++i)
{
fields[i]->resetToDefaultValue();
}
autocomputeSOIL = true;
autocomputeDepthRelatedProperties = true;
}

2 changes: 2 additions & 0 deletions ApplicationCode/ProjectDataModel/CMakeLists_files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ ${CEE_CURRENT_LIST_DIR}RimUiTreeView.h
${CEE_CURRENT_LIST_DIR}RimReservoirCellResultsCacher.h
${CEE_CURRENT_LIST_DIR}RimStatisticsCaseEvaluator.h
${CEE_CURRENT_LIST_DIR}RimMimeData.h
${CEE_CURRENT_LIST_DIR}RimCommandObject.h
)

set (SOURCE_GROUP_SOURCE_FILES
Expand Down Expand Up @@ -82,6 +83,7 @@ ${CEE_CURRENT_LIST_DIR}RimUiTreeView.cpp
${CEE_CURRENT_LIST_DIR}RimReservoirCellResultsCacher.cpp
${CEE_CURRENT_LIST_DIR}RimStatisticsCaseEvaluator.cpp
${CEE_CURRENT_LIST_DIR}RimMimeData.cpp
${CEE_CURRENT_LIST_DIR}RimCommandObject.cpp
)

list(APPEND CODE_HEADER_FILES
Expand Down
Loading

0 comments on commit 921048b

Please sign in to comment.