Merge pull request #60 from OPM/internal

Bugfixes for 0.9.26 and improved regression test framework
This commit is contained in:
Magne Sjaastad 2013-09-15 23:04:26 -07:00
commit 0a17429a74
44 changed files with 442563 additions and 109 deletions

View File

@ -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;
}
@ -495,6 +512,8 @@ bool RiaApplication::closeProject(bool askToSaveIfDirty)
caf::EffectGenerator::clearEffectCache();
m_project->close();
m_commandQueue.clear();
onProjectOpenedOrClosed();
return true;
@ -855,9 +874,11 @@ bool RiaApplication::parseArguments()
if (mainWnd)
{
mainWnd->hideAllDockWindows();
}
runRegressionTest(regressionTestPath);
runRegressionTest(regressionTestPath);
mainWnd->loadWinGeoAndDockToolBarLayout();
}
return false;
}
@ -959,6 +980,10 @@ void RiaApplication::slotWorkerProcessFinished(int exitCode, QProcess::ExitStatu
return;
}
executeCommandObjects();
// Exit code != 0 means we have an error
if (exitCode != 0)
{
@ -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);
@ -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++)
@ -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));
@ -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();
}
}

View File

@ -19,6 +19,8 @@
#pragma once
#include <QApplication>
#include <QProcess>
#include <QMutex>
#include "cafPdmObject.h"
#include "cafPdmField.h"
#include "cvfBase.h"
@ -35,6 +37,7 @@ class RiaSocketServer;
class RiaPreferences;
class RimReservoirView;
class RimProject;
class RimCommandObject;
namespace caf
{
@ -133,6 +136,9 @@ public:
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();
@ -168,4 +174,7 @@ private:
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;
};

View File

@ -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;
}

View File

@ -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
@ -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

View File

@ -0,0 +1,345 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
//
// 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 "RimCommandObject.h"
#include "RiaApplication.h"
#include "RimCalcScript.h"
#include "RimProject.h"
#include "cafPdmUiTextEditor.h"
#include "cafPdmUiPushButtonEditor.h"
#include "cafPdmDocument.h"
#include <QFile>
#include "RimStatisticsCase.h"
// Included due to template use in pdm fields
#include "RimReservoirView.h"
#include "RimReservoirCellResultsCacher.h"
#include "RimResultSlot.h"
#include "RimCellEdgeResultSlot.h"
#include "RimCellRangeFilterCollection.h"
#include "RimCellPropertyFilterCollection.h"
#include "RimWellCollection.h"
#include "Rim3dOverlayInfoConfig.h"
#include "RimOilField.h"
#include "RimScriptCollection.h"
#include "RimIdenticalGridCaseGroup.h"
#include "RimAnalysisModels.h"
#include "RimWellPathCollection.h"
#include "RimCaseCollection.h"
CAF_PDM_SOURCE_INIT(RimCommandObject, "RimCommandObject");
CAF_PDM_SOURCE_INIT(RimCommandExecuteScript, "RimCommandExecuteScript");
CAF_PDM_SOURCE_INIT(RimCommandIssueFieldChanged, "RimCommandIssueFieldChanged");
//------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCommandObject::RimCommandObject()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCommandObject::~RimCommandObject()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCommandExecuteScript::RimCommandExecuteScript()
{
CAF_PDM_InitFieldNoDefault(&name, "Name", "Name", "", "", "");
CAF_PDM_InitField(&scriptText, "ScriptText", QString(), "ScriptText", "", "" ,"");
scriptText.setUiEditorTypeName(caf::PdmUiTextEditor::uiEditorTypeName());
CAF_PDM_InitField(&isEnabled, "IsEnabled", true, "Enabled ", "", "", "");
CAF_PDM_InitField(&execute, "Execute", true, "Execute", "", "", "");
execute.setIOWritable(false);
execute.setIOReadable(false);
execute.setUiEditorTypeName(caf::PdmUiPushButtonEditor::uiEditorTypeName());
execute.setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCommandExecuteScript::~RimCommandExecuteScript()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCommandExecuteScript::redo()
{
if (!isEnabled) return;
RiaApplication* app = RiaApplication::instance();
QString octavePath = app->octavePath();
if (!octavePath.isEmpty())
{
// http://www.gnu.org/software/octave/doc/interpreter/Command-Line-Options.html#Command-Line-Options
QStringList arguments;
arguments.append("--path");
arguments << QApplication::applicationDirPath();
arguments.append("-q");
arguments.append("--eval");
arguments << this->scriptText();
RiaApplication::instance()->launchProcess(octavePath, arguments);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCommandExecuteScript::undo()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCommandExecuteScript::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute)
{
caf::PdmUiTextEditorAttribute* myAttr = dynamic_cast<caf::PdmUiTextEditorAttribute*>(attribute);
if (myAttr)
{
myAttr->showSaveButton = true;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimCommandExecuteScript::userDescriptionField()
{
return &name;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCommandExecuteScript::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
if (&execute == changedField)
{
RiaApplication* app = RiaApplication::instance();
app->addCommandObject(this);
app->executeCommandObjects();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimCommandExecuteScript::isAsyncronous()
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCommandFactory::createCommandObjects(const caf::PdmObjectGroup& selectedObjects, std::vector<RimCommandObject*>* commandObjects)
{
for (size_t i = 0; i < selectedObjects.objects.size(); i++)
{
caf::PdmObject* pdmObject = selectedObjects.objects[i];
if (dynamic_cast<RimCalcScript*>(pdmObject))
{
RimCalcScript* calcScript = dynamic_cast<RimCalcScript*>(pdmObject);
QFile file(calcScript->absolutePath);
if (file.open(QIODevice::ReadOnly | QIODevice::Text))
{
QTextStream in(&file);
QByteArray byteArray = file.readAll();
QString scriptText(byteArray);
RimCommandExecuteScript* command = new RimCommandExecuteScript;
command->scriptText = scriptText;
commandObjects->push_back(command);
}
}
else if (dynamic_cast<RimStatisticsCase*>(pdmObject))
{
RimStatisticsCase* statisticsCase = dynamic_cast<RimStatisticsCase*>(pdmObject);
RimCommandIssueFieldChanged* command = new RimCommandIssueFieldChanged;
command->objectName = statisticsCase->uiName();
command->fieldName = statisticsCase->m_calculateEditCommand.keyword();
command->fieldValueToApply = "true";
commandObjects->push_back(command);
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCommandIssueFieldChanged::RimCommandIssueFieldChanged()
{
CAF_PDM_InitFieldNoDefault(&commandName, "CommandName", "CommandName", "", "", "");
CAF_PDM_InitField(&objectName, "ObjectName", QString(), "ObjectName", "", "" ,"");
CAF_PDM_InitField(&fieldName, "FieldName", QString(), "FieldName", "", "" ,"");
CAF_PDM_InitField(&fieldValueToApply, "FieldValueToApply", QString(), "FieldValueToApply", "", "" ,"");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCommandIssueFieldChanged::~RimCommandIssueFieldChanged()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCommandIssueFieldChanged::redo()
{
RiaApplication* app = RiaApplication::instance();
PdmObject* project = app->project();
caf::PdmObject* pdmObject = findObjectByName(project, this->objectName);
if (pdmObject)
{
caf::PdmFieldHandle* fieldHandle = findFieldByKeyword(pdmObject, this->fieldName);
if (fieldHandle)
{
QVariant variantValue(this->fieldValueToApply);
fieldHandle->setValueFromUi(variantValue);
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCommandIssueFieldChanged::undo()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimCommandIssueFieldChanged::userDescriptionField()
{
return &commandName;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCommandIssueFieldChanged::childObjects(caf::PdmObject* pdmObject, std::vector<caf::PdmObject*>& children)
{
if (!pdmObject) return;
std::vector<caf::PdmFieldHandle*> fields;
pdmObject->fields(fields);
size_t fIdx;
for (fIdx = 0; fIdx < fields.size(); ++fIdx)
{
if (fields[fIdx]) fields[fIdx]->childObjects(&children);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmObject* RimCommandIssueFieldChanged::findObjectByName(caf::PdmObject* pdmObject, const QString& objectName)
{
std::vector<caf::PdmFieldHandle*> fields;
pdmObject->fields(fields);
if (pdmObject->uiName() == objectName)
{
return pdmObject;
}
for (size_t fIdx = 0; fIdx < fields.size(); fIdx++)
{
if (fields[fIdx])
{
std::vector<caf::PdmObject*> children;
fields[fIdx]->childObjects(&children);
for (size_t cIdx = 0; cIdx < children.size(); cIdx++)
{
PdmObject* candidateObj = findObjectByName(children[cIdx], objectName);
if (candidateObj)
{
return candidateObj;
}
}
}
}
return NULL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimCommandIssueFieldChanged::findFieldByKeyword(caf::PdmObject* pdmObject, const QString& keywordName)
{
std::vector<caf::PdmFieldHandle*> fields;
pdmObject->fields(fields);
for (size_t fIdx = 0; fIdx < fields.size(); fIdx++)
{
if (fields[fIdx] && fields[fIdx]->keyword() == keywordName)
{
return fields[fIdx];
}
}
return NULL;
}

View File

@ -0,0 +1,109 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
//
// 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 "cvfBase.h"
#include "cvfObject.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmDocument.h"
#include <QString>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class RimCommandObject : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimCommandObject();
virtual ~RimCommandObject();
virtual bool isAsyncronous() { return false; };
virtual void redo() {};
virtual void undo() {};
};
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class RimCommandExecuteScript : public RimCommandObject
{
CAF_PDM_HEADER_INIT;
public:
RimCommandExecuteScript();
virtual ~RimCommandExecuteScript();
caf::PdmField<QString> name;
caf::PdmField<bool> isEnabled;
caf::PdmField<bool> execute;
caf::PdmField<QString> scriptText;
virtual void redo();
virtual void undo();
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute);
virtual caf::PdmFieldHandle* userDescriptionField();
virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue );
virtual bool isAsyncronous();
};
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class RimCommandIssueFieldChanged : public RimCommandObject
{
CAF_PDM_HEADER_INIT;
public:
RimCommandIssueFieldChanged();
virtual ~RimCommandIssueFieldChanged();
caf::PdmField<QString> commandName;
caf::PdmField<QString> objectName;
caf::PdmField<QString> fieldName;
caf::PdmField<QString> fieldValueToApply;
virtual void redo();
virtual void undo();
virtual caf::PdmFieldHandle* userDescriptionField();
private:
void childObjects(caf::PdmObject* pdmObject, std::vector<caf::PdmObject*>& children);
caf::PdmObject* findObjectByName(caf::PdmObject* root, const QString& objectName);
caf::PdmFieldHandle* findFieldByKeyword(caf::PdmObject* pdmObject, const QString& fieldName);
};
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class RimCommandFactory
{
public:
static void createCommandObjects(const caf::PdmObjectGroup& selectedObjects, std::vector<RimCommandObject*>* commandObjects);
};

View File

@ -75,6 +75,9 @@ RimProject::RimProject(void)
wellPathImport = new RimWellPathImport();
wellPathImport.setUiHidden(true);
CAF_PDM_InitFieldNoDefault(&commandObjects, "CommandObjects", "CommandObjects", "", "", "");
//wellPathImport.setUiHidden(true);
CAF_PDM_InitFieldNoDefault(&currentModelIndexPath, "TreeViewCurrentModelIndexPath", "", "", "", "");
currentModelIndexPath.setUiHidden(true);
@ -121,6 +124,8 @@ void RimProject::close()
wellPathImport = new RimWellPathImport();
commandObjects.deleteAllChildObjects();
fileName = "";
nextValidCaseId = 0;
@ -258,8 +263,8 @@ void RimProject::initAfterRead()
if (casesObsolete().size() > 0 || caseGroupsObsolete.size() > 0)
{
printf("RimProject::initAfterRead: Was not able to move all cases (%i left) or caseGroups (%i left) from Project to analysisModels",
casesObsolete().size(), caseGroupsObsolete.size());
//printf("RimProject::initAfterRead: Was not able to move all cases (%i left) or caseGroups (%i left) from Project to analysisModels",
// casesObsolete().size(), caseGroupsObsolete.size());
}
// Set project pointer to each well path

View File

@ -20,6 +20,7 @@
#include "cafPdmDocument.h"
#include "RimWellPathImport.h"
#include "RimCommandObject.h"
class RimOilField;
class RimCase;
@ -28,7 +29,6 @@ class RimScriptCollection;
class RimIdenticalGridCaseGroup;
class RigMainGrid;
class RigCaseData;
class RimWellPathCollection;
//==================================================================================================
///
@ -45,6 +45,7 @@ public:
caf::PdmPointersField<RimOilField*> oilFields;
caf::PdmField<RimScriptCollection*> scriptCollection;
caf::PdmField<RimWellPathImport*> wellPathImport;
caf::PdmPointersField<RimCommandObject*> commandObjects;
caf::PdmField<QString> treeViewState;
caf::PdmField<QString> currentModelIndexPath;
caf::PdmField<int> nextValidCaseId; // Unique case ID within a project, used to identify a case from Octave scripts

View File

@ -1081,7 +1081,7 @@ void RimReservoirView::appendCellResultInfo(size_t gridIndex, size_t cellIndex,
{
RigSingleWellResultsData* singleWellResultData = wellResults.at(i);
if (m_currentTimeStep < singleWellResultData->firstResultTimeStep())
if (m_currentTimeStep < static_cast<int>(singleWellResultData->firstResultTimeStep()))
{
continue;
}

View File

@ -200,7 +200,9 @@ void RimStatisticsCase::computeStatistics()
getSourceCases(sourceCases);
if (sourceCases.size() == 0)
if (sourceCases.size() == 0
|| !sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)
|| !sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->cellResults())
{
return;
}
@ -298,7 +300,6 @@ void RimStatisticsCase::getSourceCases(std::vector<RimCase*>& sourceCases)
{
CVF_ASSERT(gridCaseGroup->caseCollection);
CVF_ASSERT(gridCaseGroup->caseCollection->reservoirs[i]);
CVF_ASSERT(gridCaseGroup->caseCollection->reservoirs[i]->reservoirData());
RimCase* sourceCase = gridCaseGroup->caseCollection->reservoirs[i];
sourceCases.push_back(sourceCase);
@ -461,6 +462,7 @@ void RimStatisticsCase::fieldChangedByUi(const caf::PdmFieldHandle* changedField
else
{
computeStatistics();
updateConnectedEditorsAndReservoirViews();
}
m_calculateEditCommand = false;
}
@ -642,6 +644,28 @@ bool RimStatisticsCase::hasComputedStatistics() const
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimStatisticsCase::updateConnectedEditorsAndReservoirViews()
{
for (size_t i = 0; i < reservoirViews.size(); ++i)
{
if (reservoirViews[i])
{
// As new result might have been introduced, update all editors connected
reservoirViews[i]->cellResult->updateConnectedEditors();
// It is usually not needed to create new display model, but if any derived geometry based on generated data (from Octave)
// a full display model rebuild is required
reservoirViews[i]->scheduleCreateDisplayModelAndRedraw();
}
}
this->updateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -650,16 +674,7 @@ void RimStatisticsCase::clearComputedStatistics()
reservoirData()->results(RifReaderInterface::MATRIX_RESULTS)->clearAllResults();
reservoirData()->results(RifReaderInterface::FRACTURE_RESULTS)->clearAllResults();
for (size_t i = 0; i < reservoirViews().size(); i++)
{
RimReservoirView* reservoirView = reservoirViews()[i];
CVF_ASSERT(reservoirView);
reservoirView->scheduleGeometryRegen(RivReservoirViewPartMgr::ACTIVE);
reservoirView->createDisplayModelAndRedraw();
}
this->updateConnectedEditors();
updateConnectedEditorsAndReservoirViews();
}
//--------------------------------------------------------------------------------------------------

View File

@ -64,6 +64,7 @@ public:
INTERPOLATED_OBSERVATION
};
caf::PdmField< bool > m_calculateEditCommand;
private:
RimIdenticalGridCaseGroup* caseGroup();
@ -76,6 +77,8 @@ private:
void updateSelectionSummaryLabel();
void updatePercentileUiVisibility();
void updateConnectedEditorsAndReservoirViews();
void setWellResultsAndUpdateViews(const cvf::Collection<RigSingleWellResultsData>& sourceCaseWellResults);
// Pdm system overrides
@ -86,7 +89,6 @@ private:
virtual void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute );
// Fields
caf::PdmField< bool > m_calculateEditCommand;
caf::PdmField< caf::AppEnum< RimDefines::ResultCatType > > m_resultType;
caf::PdmField< caf::AppEnum< RimDefines::PorosityModelType > > m_porosityModel;

View File

@ -1084,3 +1084,21 @@ void RimUiTreeModelPdm::deleteAllWellPaths(const QModelIndex& itemIndex)
clearClipboard();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUiTreeModelPdm::populateObjectGroupFromModelIndexList(const QModelIndexList& modelIndexList, caf::PdmObjectGroup* objectGroup)
{
CVF_ASSERT(objectGroup);
for (int i = 0; i < modelIndexList.size(); i++)
{
caf::PdmUiTreeItem* uiItem = UiTreeModelPdm::getTreeItemFromIndex(modelIndexList.at(i));
if (uiItem && uiItem->dataObject() && uiItem->dataObject().p())
{
objectGroup->addObject(uiItem->dataObject().p());
}
}
}

View File

@ -64,6 +64,7 @@ public:
void addToParentAndBuildUiItems(caf::PdmUiTreeItem* parentTreeItem, int position, caf::PdmObject* pdmObject);
void populateObjectGroupFromModelIndexList(const QModelIndexList& modelIndexList, caf::PdmObjectGroup* objectGroup);
void addObjects(const QModelIndex& itemIndex, caf::PdmObjectGroup& pdmObjects);
void moveObjects(const QModelIndex& itemIndex, caf::PdmObjectGroup& pdmObjects);

View File

@ -560,7 +560,6 @@ void RimUiTreeView::slotExecuteScript()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -574,6 +573,8 @@ void RimUiTreeView::slotExecuteScriptForSelectedCases()
QModelIndex mi = RimUiTreeView::getModelIndexFromString(model(), encodedModelIndex);
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
if (!myModel) return;
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(mi);
if (uiItem)
{
@ -618,7 +619,8 @@ void RimUiTreeView::slotExecuteScriptForSelectedCases()
caf::PdmObjectGroup group;
QModelIndexList mil = m->selectedRows();
populateObjectGroupFromModelIndexList(mil, &group);
myModel->populateObjectGroupFromModelIndexList(mil, &group);
std::vector<caf::PdmPointer<RimCase> > typedObjects;
group.objectsByType(&typedObjects);
@ -909,7 +911,7 @@ void RimUiTreeView::slotCloseCase()
caf::PdmObjectGroup group;
QModelIndexList mil = m->selectedRows();
populateObjectGroupFromModelIndexList(mil, &group);
myModel->populateObjectGroupFromModelIndexList(mil, &group);
std::vector<caf::PdmPointer<RimCase> > typedObjects;
group.objectsByType(&typedObjects);
@ -1048,7 +1050,7 @@ void RimUiTreeView::createPdmObjectsFromClipboard(caf::PdmObjectGroup* objectGro
if (!mdWithIndexes) return;
QModelIndexList indexList = mdWithIndexes->indexes();
populateObjectGroupFromModelIndexList(indexList, objectGroup);
myModel->populateObjectGroupFromModelIndexList(indexList, objectGroup);
}
//--------------------------------------------------------------------------------------------------
@ -1536,27 +1538,6 @@ void RimUiTreeView::slotToggleItemsOff()
executeSelectionToggleOperation(TOGGLE_OFF);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUiTreeView::populateObjectGroupFromModelIndexList(const QModelIndexList& modelIndexList, caf::PdmObjectGroup* objectGroup)
{
CVF_ASSERT(objectGroup);
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
if (!myModel) return;
for (int i = 0; i < modelIndexList.size(); i++)
{
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(modelIndexList.at(i));
if (uiItem && uiItem->dataObject() && uiItem->dataObject().p())
{
objectGroup->addObject(uiItem->dataObject().p());
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -47,8 +47,6 @@ public:
void applyTreeViewStateFromString(const QString& treeViewState);
void storeTreeViewStateToString(QString& treeViewState);
void populateObjectGroupFromModelIndexList(const QModelIndexList& modelIndexList, caf::PdmObjectGroup* objectGroup);
static QModelIndex getModelIndexFromString(QAbstractItemModel* model, const QString& currentIndexString);
static void encodeStringFromModelIndex(const QModelIndex mi, QString& currentIndexString);

View File

@ -294,7 +294,7 @@ RimWellPathAsciiFileReader::WellData RimWellPathAsciiFileReader::readWellData(QS
CVF_ASSERT(it != m_fileNameToWellDataGroupMap.end());
if (indexInFile < it->second.size())
if (indexInFile < static_cast<int>(it->second.size()))
{
return it->second[indexInFile];
}

View File

@ -95,4 +95,4 @@ private:
void readAllWellData(QString filePath);
std::map<QString, std::vector<WellData> > m_fileNameToWellDataGroupMap;
};
};

View File

@ -50,7 +50,7 @@ void RigMainGrid::addLocalGrid(RigLocalGrid* localGrid)
localGrid->setGridIndex(m_localGrids.size()); // Maingrid itself has grid index 0
if (m_gridIdToIndexMapping.size() <= localGrid->gridId())
if (m_gridIdToIndexMapping.size() <= static_cast<size_t>(localGrid->gridId()))
{
m_gridIdToIndexMapping.resize(localGrid->gridId() + 1, cvf::UNDEFINED_SIZE_T);
}
@ -175,7 +175,7 @@ void RigMainGrid::setFlipAxis(bool flipXAxis, bool flipYAxis)
//--------------------------------------------------------------------------------------------------
RigGridBase* RigMainGrid::gridById(int localGridId)
{
CVF_ASSERT (localGridId >= 0 && localGridId < m_gridIdToIndexMapping.size());
CVF_ASSERT (localGridId >= 0 && static_cast<size_t>(localGridId) < m_gridIdToIndexMapping.size());
return this->gridByIndex(m_gridIdToIndexMapping[localGridId]);
}

View File

@ -247,7 +247,7 @@ void RigSingleWellResultsData::computeStaticWellCellPath()
for (bIt = staticWellBranches.begin(); bIt != staticWellBranches.end(); ++bIt)
{
if (bIt->first >= m_wellCellsTimeSteps[0].m_wellResultBranches.size())
if (bIt->first >= static_cast<int>(m_wellCellsTimeSteps[0].m_wellResultBranches.size()))
{
continue;
}

View File

@ -315,14 +315,14 @@ public:
continue;
}
for (size_t cellIdx = 0; static_cast<size_t>(cellIdx) < rigGrid->cellCount(); cellIdx++)
for (size_t cellIdx = 0; cellIdx < rigGrid->cellCount(); cellIdx++)
{
double cellValue = cellCenterDataAccessObject->cellScalar(cellIdx);
if (cellValue == HUGE_VAL)
{
cellValue = 0.0;
}
values[cellIdx] = cellValue;
values[valueIdx++] = cellValue;
}
}
@ -585,9 +585,6 @@ public:
++m_currentTimeStepNumberToRead;
}
// std::cout << "RiaSetActiveCellProperty, completed " << std::endl;
// currentClient->disconnect();
// std::cout << "RiaSetActiveCellProperty, completed (after disconnect) " << std::endl;
// If we have read all the data, refresh the views
@ -625,13 +622,16 @@ public:
{
if (m_currentReservoir->reservoirViews[i])
{
m_currentReservoir->reservoirViews[i]->updateCurrentTimeStepAndRedraw();
// As new result might have been introduced, update all editors connected
m_currentReservoir->reservoirViews[i]->cellResult->updateConnectedEditors();
// It is usually not needed to create new display model, but if any derived geometry based on generated data (from Octave)
// a full display model rebuild is required
m_currentReservoir->reservoirViews[i]->scheduleCreateDisplayModelAndRedraw();
}
}
}
// std::cout << "RiaSetActiveCellProperty, completed : scalarIndex : " << m_currentScalarIndex;
return true;
}
@ -952,7 +952,12 @@ public:
{
if (m_currentReservoir->reservoirViews[i])
{
m_currentReservoir->reservoirViews[i]->updateCurrentTimeStepAndRedraw();
// As new result might have been introduced, update all editors connected
m_currentReservoir->reservoirViews[i]->cellResult->updateConnectedEditors();
// It is usually not needed to create new display model, but if any derived geometry based on generated data (from Octave)
// a full display model rebuild is required
m_currentReservoir->reservoirViews[i]->scheduleCreateDisplayModelAndRedraw();
}
}
}

View File

@ -59,6 +59,7 @@
#include "RimCellRangeFilterCollection.h"
#include "Rim3dOverlayInfoConfig.h"
#include "RiuWellImportWizard.h"
#include "RimCalcScript.h"
@ -138,6 +139,8 @@ void RiuMainWindow::initializeGuiNewProjectLoaded()
slotRefreshViewActions();
refreshAnimationActions();
refreshDrawStyleActions();
m_processMonitor->slotClearTextEdit();
}
//--------------------------------------------------------------------------------------------------
@ -198,6 +201,8 @@ void RiuMainWindow::createActions()
m_snapshotToClipboard = new QAction(QIcon(":/SnapShot.png"), "Copy Snapshot To Clipboard", this);
m_snapshotAllViewsToFile = new QAction(QIcon(":/SnapShotSaveViews.png"), "Snapshot All Views To File", this);
m_createCommandObject = new QAction("Create Command Object", this);
m_saveProjectAction = new QAction(QIcon(":/Save.png"), "&Save Project", this);
m_saveProjectAsAction = new QAction(QIcon(":/Save.png"), "Save Project &As", this);
@ -220,6 +225,8 @@ void RiuMainWindow::createActions()
connect(m_snapshotToFile, SIGNAL(triggered()), SLOT(slotSnapshotToFile()));
connect(m_snapshotToClipboard, SIGNAL(triggered()), SLOT(slotSnapshotToClipboard()));
connect(m_snapshotAllViewsToFile, SIGNAL(triggered()), SLOT(slotSnapshotAllViewsToFile()));
connect(m_createCommandObject, SIGNAL(triggered()), SLOT(slotCreateCommandObject()));
connect(m_saveProjectAction, SIGNAL(triggered()), SLOT(slotSaveProject()));
connect(m_saveProjectAsAction, SIGNAL(triggered()), SLOT(slotSaveProjectAs()));
@ -355,9 +362,13 @@ void RiuMainWindow::createMenus()
debugMenu->addAction(m_mockResultsModelAction);
debugMenu->addAction(m_mockLargeResultsModelAction);
debugMenu->addAction(m_mockInputModelAction);
debugMenu->addSeparator();
debugMenu->addAction(m_createCommandObject);
connect(debugMenu, SIGNAL(aboutToShow()), SLOT(slotRefreshDebugActions()));
// Windows menu
m_windowMenu = menuBar()->addMenu("&Windows");
connect(m_windowMenu, SIGNAL(aboutToShow()), SLOT(slotBuildWindowActions()));
@ -1581,7 +1592,7 @@ void RiuMainWindow::selectedCases(std::vector<RimCase*>& cases)
QModelIndexList selectedModelIndexes = m_treeView->selectionModel()->selectedIndexes();
caf::PdmObjectGroup group;
m_treeView->populateObjectGroupFromModelIndexList(selectedModelIndexes, &group);
m_treeModelPdm->populateObjectGroupFromModelIndexList(selectedModelIndexes, &group);
std::vector<caf::PdmPointer<RimCase> > typedObjects;
group.objectsByType(&typedObjects);
@ -1661,3 +1672,31 @@ void RiuMainWindow::slotShowCommandLineHelp()
QString text = app->commandLineParameterHelp();
app->showFormattedTextInMessageBox(text);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMainWindow::slotCreateCommandObject()
{
RiaApplication* app = RiaApplication::instance();
if (!app->project()) return;
QItemSelectionModel* selectionModel = m_treeView->selectionModel();
if (selectionModel)
{
QModelIndexList selectedModelIndices = selectionModel->selectedIndexes();
caf::PdmObjectGroup selectedObjects;
m_treeModelPdm->populateObjectGroupFromModelIndexList(selectedModelIndices, &selectedObjects);
std::vector<RimCommandObject*> commandObjects;
RimCommandFactory::createCommandObjects(selectedObjects, &commandObjects);
for (size_t i = 0; i < commandObjects.size(); i++)
{
app->project()->commandObjects.push_back(commandObjects[i]);
}
app->project()->updateConnectedEditors();
}
}

View File

@ -87,6 +87,7 @@ public:
RiuProcessMonitor* processMonitor();
void hideAllDockWindows();
void loadWinGeoAndDockToolBarLayout();
void setCurrentObjectInTreeView(caf::PdmObject* object);
@ -101,7 +102,6 @@ private:
void createToolBars();
void createDockPanels();
void saveWinGeoAndDockToolBarLayout();
void loadWinGeoAndDockToolBarLayout();
bool checkForDocumentModifications();
@ -154,6 +154,8 @@ private:
QAction* m_snapshotToClipboard;
QAction* m_snapshotAllViewsToFile;
QAction* m_createCommandObject;
// Help actions
QAction* m_aboutAction;
QAction* m_commandLineHelpAction;
@ -221,6 +223,8 @@ private slots:
void slotSnapshotToClipboard();
void slotSnapshotAllViewsToFile();
void slotCreateCommandObject();
// Mock models
void slotMockModel();
void slotMockResultsModel();

View File

@ -80,7 +80,7 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget">
<widget class="QWidget" name="layoutWidget1">
<layout class="QGridLayout" name="gridLayout_2" columnstretch="0,0">
<item row="1" column="0" colspan="2">
<widget class="QListView" name="m_eclipseCasesList">

View File

@ -52,6 +52,9 @@ public:
void startMonitorWorkProcess(caf::UiProcess* process);
void stopMonitorWorkProcess();
public slots:
void slotClearTextEdit();
private:
void setStatusMsg(const QString& status, int messageType);
void addStringToLog(const QString& text);
@ -61,6 +64,5 @@ private slots:
void slotProcReadyReadStdOut();
void slotProcReadyReadStdErr();
void slotTerminateProcess();
void slotClearTextEdit();
};

View File

@ -5,14 +5,14 @@
#include "riSettings.h"
void getWellCells( std::vector<int>& cellIs,
std::vector<int>& cellJs,
std::vector<int>& cellKs,
std::vector<int>& gridIndices,
std::vector<int>& cellStatuses,
std::vector<int>& branchIds,
std::vector<int>& segmentIds,
const QString &hostName, quint16 port,
const qint64& caseId, const QString& wellName, int requestedTimeStep)
std::vector<int>& cellJs,
std::vector<int>& cellKs,
std::vector<int>& gridIndices,
std::vector<int>& cellStatuses,
std::vector<int>& branchIds,
std::vector<int>& segmentIds,
const QString &hostName, quint16 port,
const qint64& caseId, const QString& wellName, int requestedTimeStep)
{
QString serverName = hostName;
quint16 serverPort = port;
@ -30,7 +30,7 @@ void getWellCells( std::vector<int>& cellIs,
QString command;
command += QString("GetWellCells") + " " + QString::number(caseId) + " " + wellName + " " + QString::number(requestedTimeStep) ;
QByteArray cmdBytes = command.toLatin1();
QDataStream socketStream(&socket);
@ -116,12 +116,13 @@ DEFUN_DLD (riGetWellCells, args, nargout,
"as a vector of Structures. \n"
"The Structure is defined as:\n"
"WellCellInfo { \n"
" I, J, K = int # Index to the cell in the grid\n"
" GridIndex = int # the index of the grid. Main grid has index 0.\n"
" CellStatus = int # is either 0 or 1, meaning the cell is closed or open respectively.\n"
" I, J, K = int # Index to the cell in the grid\n"
" GridIndex = int # the index of the grid. Main grid has index 0.\n"
" CellStatus = int # is either 0 or 1, meaning the cell is closed or open respectively\n"
" BranchId = int # Branch id of the branch intersecting the cell\n"
" SegmentId = int # Branch segment id of the branch intersecting the cell\n"
"}\n"
"If the CaseId is not defined, ResInsights Current Case is used.\n"
)
{
if (nargout != 1)
@ -138,7 +139,7 @@ DEFUN_DLD (riGetWellCells, args, nargout,
print_usage();
return octave_value();
}
if (nargin > 3)
{
error("riGetWellCells: Too many arguments, this function takes at most three arguments.\n");
@ -204,12 +205,12 @@ DEFUN_DLD (riGetWellCells, args, nargout,
std::vector<int> segmentIds;
getWellCells( cellIs, cellJs, cellKs,
gridIndices,
cellStatuses,
branchIds,
segmentIds,
"127.0.0.1", 40001,
caseId, QString::fromStdString(wellName), requestedTimeStep);
gridIndices,
cellStatuses,
branchIds,
segmentIds,
"127.0.0.1", 40001,
caseId, QString::fromStdString(wellName), requestedTimeStep);
size_t cellCount = cellIs.size();

10
README
View File

@ -14,7 +14,7 @@ DOWNLOADING RESINSIGHT
CONTRIBUTION
Please use master branch for contributions and pull requests. Please do not use branch 'internal' for contributions.
BUILDING RESINSIGHT
BUILDING RESINSIGHT - Linux
ResInsight uses the cmake build system and requires cmake version 2.8 or higher. Moreover, you need version 4.7.3 of Qt or newer, look below for dependecy list. An out-of-tree build is typically done with
mkdir ResInsight/build
cd ResInsight/build
@ -23,6 +23,14 @@ ResInsight uses the cmake build system and requires cmake version 2.8 or higher.
make install
You will find the ResInsight binary under the Install directory in your build directory.
BUILDING RESINSIGHT - Windows
Open the CMake GUI.
Set the path to the source code: <ResInsight-sourcecode-folder>
Set the path to the build directory: <ResInsight-build-folder>
Click "Configure" and select your preferred compiler, "Visual Studio 10" or "Visual Studio 10 Win64"
Set the build variables and click "Configure" again.
Click "Generate", and a project file will be created in the build directory <ResInsight-build-folder>
DEPENDENCIES FOR DEBIAN BASED DISTRIBUTIONS
sudo apt-get install git cmake build-essential octave octave-headers qt4-dev-tools
If you are running Ubuntu 12.10 or newer, you will need to replace octave-headers with liboctave-dev in the line above.

View File

@ -1,7 +1,7 @@
set(CMAKE_MAJOR_VERSION 0)
set(CMAKE_MINOR_VERSION 9)
set(CMAKE_PATCH_VERSION 26)
set(CMAKE_PATCH_VERSION 27)
set(PRODUCTVER ${CMAKE_MAJOR_VERSION},${CMAKE_MINOR_VERSION},0,${CMAKE_PATCH_VERSION})
set(STRPRODUCTVER ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION})

File diff suppressed because it is too large Load Diff

View File

@ -28,4 +28,7 @@ add_library( ${PROJECT_NAME}
cafPdmUiObjectEditorHandle.h
cafPdmUiOrdering.cpp
cafPdmUiOrdering.h
cafPdmUiTreeOrdering.cpp
cafPdmUiTreeOrdering.h
)

View File

@ -82,6 +82,16 @@ void PdmFieldHandle::setKeyword(const QString& keyword)
m_keyword = keyword;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool PdmFieldHandle::hasChildObjects()
{
std::vector<PdmObject*> children;
this->childObjects(&children);
return (children.size() > 0);
}
//--------------------------------------------------------------------------------------------------
/// PdmObjectFactory implementations
//--------------------------------------------------------------------------------------------------

View File

@ -66,8 +66,11 @@ public:
virtual QVariant uiValue() const { return QVariant(); }
virtual void setValueFromUi(const QVariant& ) { }
virtual bool hasChildObjects();
virtual void childObjects(std::vector<PdmObject*>* ) { }
virtual void removeChildObject(PdmObject* ) { }
virtual QList<PdmOptionItemInfo>
valueOptions( bool* useOptionsOnly) { return QList<PdmOptionItemInfo>(); }

View File

@ -26,6 +26,7 @@
#include <QXmlStreamWriter>
#include "cafPdmObjectFactory.h"
#include "cafPdmDocument.h"
#include "cafPdmUiTreeOrdering.h"
namespace caf
{
@ -363,6 +364,71 @@ PdmObject* PdmObject::deepCopy()
*/
}
//--------------------------------------------------------------------------------------------------
/// This method is to be used to create a tree-representation of the object hierarchy starting at this
/// object. The caller is responsible to delete the returned PdmUiTreeOrdering
//--------------------------------------------------------------------------------------------------
PdmUiTreeOrdering* PdmObject::uiTreeOrdering(QString uiConfigName /*= ""*/)
{
PdmUiTreeOrdering* uiTreeOrdering = new PdmUiTreeOrdering(NULL, -1, this);
this->defineUiTreeOrdering(*uiTreeOrdering, uiConfigName);
if (!uiTreeOrdering->forgetRemainingFields())
{
// Add the remaining Fields To UiConfig
for (size_t fIdx = 0; fIdx < m_fields.size(); ++fIdx)
{
if ( (m_fields[fIdx]->hasChildObjects()) && !uiTreeOrdering->containsField(m_fields[fIdx]))
{
uiTreeOrdering->add( m_fields[fIdx]);
}
}
}
expandUiTree(uiTreeOrdering, uiConfigName);
return uiTreeOrdering;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmObject::expandUiTree(PdmUiTreeOrdering* root, QString uiConfigName /*= "" */)
{
if (!root) return;
if ( root->childCount() == 0)
{
if (!root->isSubTreeDefined() && root->dataObject())
{
if (root->m_field)
{
std::vector<PdmObject*> fieldsChildObjects;
root->m_field->childObjects(&fieldsChildObjects);
for (size_t cIdx = 0; cIdx < fieldsChildObjects.size(); ++cIdx)
{
root->add(fieldsChildObjects[cIdx]);
}
}
else
{
root->dataObject()->defineUiTreeOrdering(*root, uiConfigName);
}
}
}
for (int cIdx = 0; cIdx < root->childCount(); ++cIdx)
{
PdmUiTreeOrdering* child = dynamic_cast<PdmUiTreeOrdering*>(root->child(cIdx));
if (!child->isSubTreeDefined())
{
expandUiTree(child);
}
}
}
} //End of namespace caf

View File

@ -50,7 +50,7 @@ namespace caf
class PdmFieldHandle;
template < class FieldDataType > class PdmField;
class PdmUiEditorAttribute;
class PdmUiTreeOrdering;
//==================================================================================================
/// Macros helping in development of PDM objects
//==================================================================================================
@ -146,6 +146,10 @@ public:
/// supplied by the \sa defineUiOrdering method that can be reimplemented
void uiOrdering(QString uiConfigName, PdmUiOrdering& uiOrdering) ;
/// Method to be called by Ui displaying a tree representation of the object hierarchy
/// Caller must delete the returned object.
PdmUiTreeOrdering* uiTreeOrdering( QString uiConfigName = "");
/// For a specific field, return editor specific parameters used to customize the editor behavior.
void editorAttribute(const PdmFieldHandle* field, QString uiConfigName, PdmUiEditorAttribute * attribute);
@ -184,6 +188,10 @@ protected: // Virtual
/// If the uiOrdering is empty, it is interpreted as meaning all fields w/o grouping.
virtual void defineUiOrdering(QString uiConfigName, PdmUiOrdering& uiOrdering) {}
/// Override to customize the tree representations of the object hierarchy.
/// If the PdmUiTreeOrdering is empty, it is interpreted as meaning all fields containing child objects in order
virtual void defineUiTreeOrdering(PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) { }
/// Override to provide editor specific data for the field and uiConfigName
virtual void defineEditorAttribute(const PdmFieldHandle* field, QString uiConfigName, PdmUiEditorAttribute * attribute) {}
@ -227,6 +235,10 @@ private:
void addParentField(PdmFieldHandle* parentField);
void removeParentField(PdmFieldHandle* parentField);
private:
/// Recursive function to traverse and create a Ui tree representation of the object hierarchy
static void expandUiTree( PdmUiTreeOrdering* root, QString uiConfigName = "" );
private:
std::multiset<PdmFieldHandle*> m_parentFields;
std::vector<PdmFieldHandle*> m_fields;

View File

@ -0,0 +1,87 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2012 Ceetron AS
//
// This library 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.
//
// This library 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 "cafPdmUiTreeOrdering.h"
#include "cafPdmField.h"
namespace caf
{
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmUiTreeOrdering::add(PdmFieldHandle * field)
{
PdmUiTreeOrdering* to = new PdmUiTreeOrdering(this, -1, field->ownerObject());
to->m_field = field;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmUiTreeOrdering::add(PdmObject* object)
{
PdmUiTreeOrdering* to = new PdmUiTreeOrdering(this, -1, object);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
PdmUiTreeOrdering* PdmUiTreeOrdering::add(const QString & title, const QString& iconResourceName)
{
PdmUiTreeOrdering* to = new PdmUiTreeOrdering(this, -1, NULL);
to->m_uiInfo = new PdmUiItemInfo(title, QIcon(iconResourceName));
return to;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool PdmUiTreeOrdering::containsField(PdmFieldHandle* field)
{
assert (field);
for (int cIdx = 0; cIdx < this->childCount(); ++cIdx)
{
PdmUiTreeOrdering* child = dynamic_cast<PdmUiTreeOrdering*>(this->child(cIdx));
if (!(child->m_field == field))
{
return true;
}
}
return false;
}
//--------------------------------------------------------------------------------------------------
/// Creates an new PdmUiTreeOrdering item, and adds it to parent. If position is -1, it is added
/// at the end of parents existing child list.
//--------------------------------------------------------------------------------------------------
PdmUiTreeOrdering::PdmUiTreeOrdering(PdmUiTreeOrdering* parent /*= NULL*/, int position /*= -1*/, PdmObject* dataObject /*= NULL*/) : UiTreeItem< PdmPointer<PdmObject> >(parent, position, dataObject),
m_field(NULL),
m_uiInfo(NULL),
m_forgetRemainingFields(false),
m_isSubTreeDefined(false)
{
}
} //End of namespace caf

View File

@ -0,0 +1,70 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2012 Ceetron AS
//
// This library 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.
//
// This library 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 <vector>
#include <QString>
#include "cafPdmUiItem.h"
#include "../cafUserInterface/cafUiTreeItem.h"
#include "cafPdmPointer.h"
namespace caf
{
class PdmObject;
class PdmFieldHandle;
//typedef UiTreeItem<PdmPointer<PdmObject> > PdmUiTreeItem;
//==================================================================================================
/// Class storing a tree structure representation of some PdmObject hierarchy to be used for tree views in the Gui
//==================================================================================================
class PdmUiTreeOrdering : public UiTreeItem< PdmPointer<PdmObject> >
{
PdmUiTreeOrdering(PdmUiTreeOrdering* parent = NULL, int position = -1, PdmObject* dataObject = NULL);
void add(PdmFieldHandle * field);
void add(PdmObject* object);
PdmUiTreeOrdering* add(const QString & title, const QString& iconResourceName );
/// If the rest of the fields containing children is supposed to be omitted, setForgetRemainingFileds to true.
void setForgetRemainingFields(bool val) { m_forgetRemainingFields = val; }
/// To stop the tree generation at this level, setSubTreeDefined to true
void setSubTreeDefined(bool isSubTreeDefined ) { m_isSubTreeDefined = isSubTreeDefined; }
private:
friend class PdmObject;
bool forgetRemainingFields() const { return m_forgetRemainingFields; }
bool isSubTreeDefined() const { return m_isSubTreeDefined; }
bool containsField(PdmFieldHandle* field);
private:
PdmFieldHandle* m_field;
PdmUiItemInfo* m_uiInfo;
bool m_forgetRemainingFields;
bool m_isSubTreeDefined;
};
} // End of namespace caf

View File

@ -94,7 +94,7 @@ void UiTableModelPdm::computeColumnCount()
std::vector<PdmFieldHandle*> fields;
m_pdmObjectGroup->objects[i]->fields(fields);
if (m_columnCount < fields.size())
if (m_columnCount < static_cast<int>(fields.size()))
{
m_columnCount = static_cast<int>(fields.size());
}
@ -117,7 +117,7 @@ QVariant caf::UiTableModelPdm::data(const QModelIndex &index, int role /*= Qt::D
{
if (m_pdmObjectGroup && (role == Qt::DisplayRole || role == Qt::EditRole))
{
if (index.row() < m_pdmObjectGroup->objects.size())
if (index.row() < static_cast<int>(m_pdmObjectGroup->objects.size()))
{
PdmObject* pdmObject = m_pdmObjectGroup->objects[index.row()];
if (pdmObject)
@ -125,7 +125,7 @@ QVariant caf::UiTableModelPdm::data(const QModelIndex &index, int role /*= Qt::D
std::vector<PdmFieldHandle*> fields;
pdmObject->fields(fields);
if (index.column() < fields.size())
if (index.column() < static_cast<int>(fields.size()))
{
size_t fieldIndex = 0;

View File

@ -30,6 +30,7 @@
#include <QTextEdit>
#include <QLabel>
#include <QIntValidator>
#include <QVBoxLayout>
#include <assert.h>
#include "cafFactory.h"
@ -69,6 +70,17 @@ void PdmUiTextEditor::configureAndUpdateUi(const QString& uiConfigName)
field()->ownerObject()->editorAttribute(field(), uiConfigName, &leab);
m_textMode = leab.textMode;
if (leab.showSaveButton)
{
disconnect(m_textEdit, SIGNAL(textChanged()), this, SLOT(slotTextChanged()));
m_saveButton->show();
}
else
{
connect(m_textEdit, SIGNAL(textChanged()), this, SLOT(slotTextChanged()));
m_saveButton->hide();
}
m_textEdit->blockSignals(true);
switch (leab.textMode)
{
@ -89,9 +101,25 @@ void PdmUiTextEditor::configureAndUpdateUi(const QString& uiConfigName)
//--------------------------------------------------------------------------------------------------
QWidget* PdmUiTextEditor::createEditorWidget(QWidget * parent)
{
m_textEdit = new QTextEdit(parent);
QWidget* containerWidget = new QWidget(parent);
m_textEdit = new QTextEdit(containerWidget);
connect(m_textEdit, SIGNAL(textChanged()), this, SLOT(slotTextChanged()));
return m_textEdit;
m_saveButton = new QPushButton("Save changes", containerWidget);
connect(m_saveButton, SIGNAL(clicked()), this, SLOT(slotSaveButtonClicked()));
QVBoxLayout* layout = new QVBoxLayout;
layout->addWidget(m_textEdit);
QHBoxLayout* buttonLayout = new QHBoxLayout;
buttonLayout->insertStretch(0, 10);
buttonLayout->addWidget(m_saveButton);
layout->addLayout(buttonLayout);
containerWidget->setLayout(layout);
return containerWidget;
}
//--------------------------------------------------------------------------------------------------
@ -126,5 +154,13 @@ void PdmUiTextEditor::slotTextChanged()
this->setValueToField(v);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmUiTextEditor::slotSaveButtonClicked()
{
slotTextChanged();
}
} // end namespace caf

View File

@ -22,6 +22,7 @@
#include <QString>
#include <QWidget>
#include <QPointer>
#include <QPushButton>
#include <QTextEdit>
#include <QLabel>
@ -40,6 +41,7 @@ public:
PdmUiTextEditorAttribute()
{
textMode = PLAIN;
showSaveButton = false;
}
enum TextMode
@ -49,7 +51,8 @@ public:
};
public:
TextMode textMode;
TextMode textMode;
bool showSaveButton;
};
@ -69,10 +72,12 @@ protected:
protected slots:
void slotTextChanged();
void slotSaveButtonClicked();
private:
QPointer<QTextEdit> m_textEdit;
QPointer<QLabel> m_label;
QPointer<QTextEdit> m_textEdit;
QPointer<QPushButton> m_saveButton;
QPointer<QLabel> m_label;
PdmUiTextEditorAttribute::TextMode m_textMode;
};

View File

@ -19,7 +19,8 @@
#pragma once
#include <QAbstractItemModel>
//#include <QAbstractItemModel>
#include <QList>
#include <assert.h>
@ -47,7 +48,7 @@ public:
setDataObject(dataObject);
}
~UiTreeItem()
virtual ~UiTreeItem()
{
qDeleteAll(m_childItems);
}

2
debian/rules vendored
View File

@ -13,7 +13,7 @@
dh $@
override_dh_auto_configure:
dh_auto_configure --buildsystem=cmake -- -DCMAKE_BUILD_TYPE=Release -DPRIVATE_INSTALL=0 -DCMAKE_INSTALL_DOCDIR=share/doc/resinsight
dh_auto_configure --buildsystem=cmake -- -DCMAKE_BUILD_TYPE=Release -DRESINSIGHT_PRIVATE_INSTALL=0 -DCMAKE_INSTALL_DOCDIR=share/doc/resinsight
.PHONY: override_dh_strip
override_dh_strip:

View File

@ -41,7 +41,7 @@ This package contains the ResInsight octave plugins.
%patch3 -p1
%build
cmake28 -DPRIVATE_INSTALL=0 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%{_prefix} -DCMAKE_INSTALL_DOCDIR=share/doc/resinsight-0.9.2
cmake28 -DRESINSIGHT_PRIVATE_INSTALL=0 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%{_prefix} -DCMAKE_INSTALL_DOCDIR=share/doc/resinsight-0.9.2
make
%install