mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
RimCase reintroduced as baseclass for all cases
Refactored to handle cases generically in a lot of places. Mostly complete regarding all these issues, but not tested yet: Assigning caseId Update relative path to the case data RimProject::createDisplayModelAndRedrawAllViews RimProject::computeUtmAreaOfInterest Load case data on project open save snapshots for all views RegressionTest viewer size Finding case based on caseId Giving case information to octave
This commit is contained in:
@@ -363,24 +363,24 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi
|
||||
|
||||
// Now load the ReservoirViews for the cases
|
||||
// Add all "native" cases in the project
|
||||
std::vector<RimEclipseCase*> casesToLoad;
|
||||
std::vector<RimCase*> casesToLoad;
|
||||
m_project->allCases(casesToLoad);
|
||||
|
||||
caf::ProgressInfo caseProgress(casesToLoad.size() , "Reading Cases");
|
||||
|
||||
for (size_t cIdx = 0; cIdx < casesToLoad.size(); ++cIdx)
|
||||
{
|
||||
RimEclipseCase* ri = casesToLoad[cIdx];
|
||||
CVF_ASSERT(ri);
|
||||
RimCase* cas = casesToLoad[cIdx];
|
||||
CVF_ASSERT(cas);
|
||||
|
||||
caseProgress.setProgressDescription(ri->caseUserDescription());
|
||||
|
||||
caf::ProgressInfo viewProgress(ri->reservoirViews().size() , "Creating Views");
|
||||
caseProgress.setProgressDescription(cas->caseUserDescription());
|
||||
std::vector<RimView*> views = cas->views();
|
||||
caf::ProgressInfo viewProgress(views.size() , "Creating Views");
|
||||
|
||||
size_t j;
|
||||
for (j = 0; j < ri->reservoirViews().size(); j++)
|
||||
for (j = 0; j < views.size(); j++)
|
||||
{
|
||||
RimReservoirView* riv = ri->reservoirViews[j];
|
||||
RimView* riv = views[j];
|
||||
CVF_ASSERT(riv);
|
||||
|
||||
viewProgress.setProgressDescription(riv->name());
|
||||
@@ -1526,17 +1526,19 @@ void RiaApplication::saveSnapshotForAllViews(const QString& snapshotFolderName)
|
||||
|
||||
const QString absSnapshotPath = snapshotPath.absolutePath();
|
||||
|
||||
std::vector<RimEclipseCase*> projectCases;
|
||||
std::vector<RimCase*> projectCases;
|
||||
m_project->allCases(projectCases);
|
||||
|
||||
for (size_t i = 0; i < projectCases.size(); i++)
|
||||
{
|
||||
RimEclipseCase* ri = projectCases[i];
|
||||
if (!ri) continue;
|
||||
RimCase* cas = projectCases[i];
|
||||
if (!cas) continue;
|
||||
|
||||
for (size_t j = 0; j < ri->reservoirViews().size(); j++)
|
||||
std::vector<RimView*> views = cas->views();
|
||||
|
||||
for (size_t j = 0; j < views.size(); j++)
|
||||
{
|
||||
RimReservoirView* riv = ri->reservoirViews()[j];
|
||||
RimView* riv = views[j];
|
||||
|
||||
if (riv && riv->viewer())
|
||||
{
|
||||
@@ -1548,7 +1550,7 @@ void RiaApplication::saveSnapshotForAllViews(const QString& snapshotFolderName)
|
||||
// Process all events to avoid a black image when grabbing frame buffer
|
||||
QCoreApplication::processEvents();
|
||||
|
||||
QString fileName = ri->caseUserDescription() + "-" + riv->name();
|
||||
QString fileName = cas->caseUserDescription() + "-" + riv->name();
|
||||
fileName.replace(" ", "_");
|
||||
|
||||
QString absoluteFileName = caf::Utils::constructFullFileName(absSnapshotPath, fileName, ".png");
|
||||
@@ -2104,17 +2106,20 @@ void RiaApplication::regressionTestConfigureProject()
|
||||
|
||||
if (m_project.isNull()) return;
|
||||
|
||||
std::vector<RimEclipseCase*> projectCases;
|
||||
std::vector<RimCase*> projectCases;
|
||||
m_project->allCases(projectCases);
|
||||
|
||||
|
||||
for (size_t i = 0; i < projectCases.size(); i++)
|
||||
{
|
||||
RimEclipseCase* ri = projectCases[i];
|
||||
if (!ri) continue;
|
||||
RimCase* cas = projectCases[i];
|
||||
if (!cas) continue;
|
||||
|
||||
for (size_t j = 0; j < ri->reservoirViews().size(); j++)
|
||||
std::vector<RimView*> views = cas->views();
|
||||
|
||||
for (size_t j = 0; j < views.size(); j++)
|
||||
{
|
||||
RimReservoirView* riv = ri->reservoirViews()[j];
|
||||
RimView* riv = views[j];
|
||||
|
||||
if (riv && riv->viewer())
|
||||
{
|
||||
@@ -2122,8 +2127,13 @@ void RiaApplication::regressionTestConfigureProject()
|
||||
riv->viewer()->setFixedSize(1000, 745);
|
||||
}
|
||||
|
||||
riv->faultCollection->setShowFaultsOutsideFilters(false);
|
||||
riv->faultResultSettings->showCustomFaultResult.setValueFromUi(false);
|
||||
RimReservoirView* resvView = dynamic_cast<RimReservoirView*>(riv);
|
||||
|
||||
if (resvView)
|
||||
{
|
||||
resvView->faultCollection->setShowFaultsOutsideFilters(false);
|
||||
resvView->faultResultSettings->showCustomFaultResult.setValueFromUi(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ bool RiaProjectModifier::replaceSourceCases(RimProject* project)
|
||||
bool RiaProjectModifier::replaceCase(RimProject* project)
|
||||
{
|
||||
bool didReplacement = false;
|
||||
std::vector<RimEclipseCase*> allCases;
|
||||
std::vector<RimCase*> allCases;
|
||||
project->allCases(allCases);
|
||||
|
||||
for (size_t caseIdx = 0; caseIdx < allCases.size(); ++caseIdx)
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "RigFemScalarResultFrames.h"
|
||||
#include "RigStatisticsDataCache.h"
|
||||
#include <cmath>
|
||||
#include "cvfBoundingBox.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@@ -311,4 +312,3 @@ void RigGeoMechCaseData::assertResultsLoaded(int stepIndex, const RigFemResultAd
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ ${CEE_CURRENT_LIST_DIR}RimGeoMechCase.h
|
||||
${CEE_CURRENT_LIST_DIR}RimGeoMechView.h
|
||||
${CEE_CURRENT_LIST_DIR}RimGeoMechResultSlot.h
|
||||
${CEE_CURRENT_LIST_DIR}RimView.h
|
||||
|
||||
${CEE_CURRENT_LIST_DIR}RimCase.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
@@ -111,6 +111,7 @@ ${CEE_CURRENT_LIST_DIR}RimGeoMechCase.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimGeoMechView.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimGeoMechResultSlot.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimView.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimCase.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
||||
208
ApplicationCode/ProjectDataModel/RimCase.cpp
Normal file
208
ApplicationCode/ProjectDataModel/RimCase.cpp
Normal file
@@ -0,0 +1,208 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions 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 "RimCase.h"
|
||||
#include "cafPdmObjectFactory.h"
|
||||
|
||||
#include "cafPdmAbstractClassSourceInit.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
#include <QDebug>
|
||||
|
||||
CAF_PDM_ABSTRACT_SOURCE_INIT(RimCase, "RimCase");
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimCase::RimCase()
|
||||
{
|
||||
CAF_PDM_InitField(&caseUserDescription, "CaseUserDescription", QString(), "Case name", "", "" ,"");
|
||||
|
||||
CAF_PDM_InitField(&caseId, "CaseId", -1, "Case ID", "", "" ,"");
|
||||
caseId.setUiReadOnly(true);
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimCase::~RimCase()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Relocate the supplied file name, based on the search path as follows:
|
||||
/// fileName, newProjectPath/fileNameWoPath, relocatedPath/fileNameWoPath
|
||||
/// If the file is not found in any of the positions, the fileName is returned but converted to Qt Style path separators: "/"
|
||||
///
|
||||
/// The relocatedPath is found in this way:
|
||||
/// use the start of newProjectPath
|
||||
/// plus the end of the path to m_gridFileName
|
||||
/// such that the common start of oldProjectPath and m_gridFileName is removed from m_gridFileName
|
||||
/// and replaced with the start of newProjectPath up to where newProjectPath starts to be equal to oldProjectPath
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimCase::relocateFile(const QString& orgFileName, const QString& orgNewProjectPath, const QString& orgOldProjectPath,
|
||||
bool* foundFile, std::vector<QString>* searchedPaths)
|
||||
{
|
||||
if (foundFile) *foundFile = true;
|
||||
|
||||
// Make sure we have a Qt formatted path ( using "/" not "\")
|
||||
QString fileName = QDir::fromNativeSeparators(orgFileName);
|
||||
QString newProjectPath = QDir::fromNativeSeparators(orgNewProjectPath);
|
||||
QString oldProjectPath = QDir::fromNativeSeparators(orgOldProjectPath);
|
||||
|
||||
// If we from a file or whatever gets a real windows path on linux, we need to manually convert it
|
||||
// because Qt will not. QDir::fromNativeSeparators does nothing on linux.
|
||||
|
||||
bool isWindowsPath = false;
|
||||
if (orgFileName.count("/")) isWindowsPath = false; // "/" are not allowed in a windows path
|
||||
else if (orgFileName.count("\\")
|
||||
&& !QFile::exists(orgFileName)) // To make sure we do not convert single linux files containing "\"
|
||||
{
|
||||
isWindowsPath = true;
|
||||
}
|
||||
|
||||
if (isWindowsPath)
|
||||
{
|
||||
// Windows absolute path detected. transform.
|
||||
fileName.replace(QString("\\"), QString("/"));
|
||||
}
|
||||
|
||||
if (searchedPaths) searchedPaths->push_back(fileName);
|
||||
if (QFile::exists(fileName))
|
||||
{
|
||||
return fileName;
|
||||
}
|
||||
|
||||
// First check in the new project file directory
|
||||
{
|
||||
QString fileNameWithoutPath = QFileInfo(fileName).fileName();
|
||||
QString candidate = QDir::fromNativeSeparators(newProjectPath + QDir::separator() + fileNameWithoutPath);
|
||||
if (searchedPaths) searchedPaths->push_back(candidate);
|
||||
|
||||
if (QFile::exists(candidate))
|
||||
{
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
|
||||
// Then find the possible move of a directory structure where projects and files referenced are moved in "paralell"
|
||||
|
||||
QFileInfo gridFileInfo(QDir::fromNativeSeparators(fileName));
|
||||
QString gridFilePath = gridFileInfo.path();
|
||||
QString gridFileNameWoPath = gridFileInfo.fileName();
|
||||
QStringList gridPathElements = gridFilePath.split("/", QString::KeepEmptyParts);
|
||||
|
||||
QString oldProjPath = QDir::fromNativeSeparators(oldProjectPath);
|
||||
QStringList oldProjPathElements = oldProjPath.split("/", QString::KeepEmptyParts);
|
||||
|
||||
QString newProjPath = QDir::fromNativeSeparators(newProjectPath);
|
||||
QStringList newProjPathElements = newProjPath.split("/", QString::KeepEmptyParts);
|
||||
|
||||
// Find the possible equal start of the old project path, and the referenced file
|
||||
|
||||
bool pathStartsAreEqual = false;
|
||||
bool pathEndsDiffer = false;
|
||||
int firstDiffIdx = 0;
|
||||
for ( firstDiffIdx = 0; firstDiffIdx < gridPathElements.size() && firstDiffIdx < oldProjPathElements.size(); ++firstDiffIdx)
|
||||
{
|
||||
if (gridPathElements[firstDiffIdx] == oldProjPathElements[firstDiffIdx])
|
||||
{
|
||||
pathStartsAreEqual = pathStartsAreEqual || !gridPathElements[firstDiffIdx].isEmpty();
|
||||
}
|
||||
else
|
||||
{
|
||||
pathEndsDiffer = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!pathEndsDiffer && firstDiffIdx < gridPathElements.size() || firstDiffIdx < oldProjPathElements.size())
|
||||
{
|
||||
pathEndsDiffer = true;
|
||||
}
|
||||
|
||||
// If the path starts are equal, try to substitute it in the referenced file, with the corresponding new project path start
|
||||
|
||||
if (pathStartsAreEqual)
|
||||
{
|
||||
if (pathEndsDiffer)
|
||||
{
|
||||
QString oldGridFilePathEnd;
|
||||
for (int i = firstDiffIdx; i < gridPathElements.size(); ++i)
|
||||
{
|
||||
oldGridFilePathEnd += gridPathElements[i];
|
||||
oldGridFilePathEnd += "/";
|
||||
}
|
||||
|
||||
// Find the new Project File Start Path
|
||||
|
||||
QStringList oldProjectFilePathEndElements;
|
||||
for (int i = firstDiffIdx; i < oldProjPathElements.size(); ++i)
|
||||
{
|
||||
oldProjectFilePathEndElements.push_back(oldProjPathElements[i]);
|
||||
}
|
||||
|
||||
int ppIdx = oldProjectFilePathEndElements.size() -1;
|
||||
int lastDiffIdx = newProjPathElements.size() -1;
|
||||
|
||||
for (; lastDiffIdx >= 0 && ppIdx >= 0; --lastDiffIdx, --ppIdx)
|
||||
{
|
||||
if (oldProjectFilePathEndElements[ppIdx] != newProjPathElements[lastDiffIdx])
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QString newProjecetFileStartPath;
|
||||
for (int i = 0; i <= lastDiffIdx; ++i)
|
||||
{
|
||||
newProjecetFileStartPath += newProjPathElements[i];
|
||||
newProjecetFileStartPath += "/";
|
||||
}
|
||||
|
||||
QString relocationPath = newProjecetFileStartPath + oldGridFilePathEnd;
|
||||
|
||||
QString relocatedFileName = relocationPath + gridFileNameWoPath;
|
||||
|
||||
if (searchedPaths) searchedPaths->push_back(relocatedFileName);
|
||||
|
||||
if (QFile::exists(relocatedFileName))
|
||||
{
|
||||
return relocatedFileName;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// The Grid file was located in the same dir as the Project file. This is supposed to be handled above.
|
||||
// So we did not find it
|
||||
}
|
||||
}
|
||||
|
||||
// return the unchanged filename, if we could not find a valid relocation file
|
||||
if (foundFile) *foundFile = false;
|
||||
|
||||
return fileName;
|
||||
}
|
||||
51
ApplicationCode/ProjectDataModel/RimCase.h
Normal file
51
ApplicationCode/ProjectDataModel/RimCase.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions 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 "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class RimView;
|
||||
|
||||
class RimCase : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
public:
|
||||
RimCase();
|
||||
virtual ~RimCase();
|
||||
|
||||
caf::PdmField<QString> caseUserDescription;
|
||||
|
||||
caf::PdmField<int> caseId;
|
||||
virtual std::vector<RimView*> views() = 0;
|
||||
|
||||
virtual void updateFilePathsFromProjectPath(const QString& projectPath, const QString& oldProjectPath) = 0;
|
||||
|
||||
protected:
|
||||
static QString relocateFile(const QString& fileName, const QString& newProjectPath, const QString& oldProjectPath,
|
||||
bool* foundFile, std::vector<QString>* searchedPaths);
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -43,17 +43,16 @@
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimEclipseCase, "RimReservoir");
|
||||
#include "cafPdmAbstractClassSourceInit.h"
|
||||
|
||||
CAF_PDM_ABSTRACT_SOURCE_INIT(RimEclipseCase, "RimReservoir");
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEclipseCase::RimEclipseCase()
|
||||
{
|
||||
CAF_PDM_InitField(&caseUserDescription, "CaseUserDescription", QString(), "Case name", "", "" ,"");
|
||||
|
||||
CAF_PDM_InitField(&caseId, "CaseId", -1, "Case ID", "", "" ,"");
|
||||
caseId.setUiReadOnly(true);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&reservoirViews, "ReservoirViews", "", "", "", "");
|
||||
|
||||
@@ -383,160 +382,6 @@ RimReservoirCellResultsStorage* RimEclipseCase::results(RifReaderInterface::Poro
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Relocate the supplied file name, based on the search path as follows:
|
||||
/// fileName, newProjectPath/fileNameWoPath, relocatedPath/fileNameWoPath
|
||||
/// If the file is not found in any of the positions, the fileName is returned but converted to Qt Style path separators: "/"
|
||||
///
|
||||
/// The relocatedPath is found in this way:
|
||||
/// use the start of newProjectPath
|
||||
/// plus the end of the path to m_gridFileName
|
||||
/// such that the common start of oldProjectPath and m_gridFileName is removed from m_gridFileName
|
||||
/// and replaced with the start of newProjectPath up to where newProjectPath starts to be equal to oldProjectPath
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimEclipseCase::relocateFile(const QString& orgFileName, const QString& orgNewProjectPath, const QString& orgOldProjectPath,
|
||||
bool* foundFile, std::vector<QString>* searchedPaths)
|
||||
{
|
||||
if (foundFile) *foundFile = true;
|
||||
|
||||
// Make sure we have a Qt formatted path ( using "/" not "\")
|
||||
QString fileName = QDir::fromNativeSeparators(orgFileName);
|
||||
QString newProjectPath = QDir::fromNativeSeparators(orgNewProjectPath);
|
||||
QString oldProjectPath = QDir::fromNativeSeparators(orgOldProjectPath);
|
||||
|
||||
// If we from a file or whatever gets a real windows path on linux, we need to manually convert it
|
||||
// because Qt will not. QDir::fromNativeSeparators does nothing on linux.
|
||||
|
||||
bool isWindowsPath = false;
|
||||
if (orgFileName.count("/")) isWindowsPath = false; // "/" are not allowed in a windows path
|
||||
else if (orgFileName.count("\\")
|
||||
&& !QFile::exists(orgFileName)) // To make sure we do not convert single linux files containing "\"
|
||||
{
|
||||
isWindowsPath = true;
|
||||
}
|
||||
|
||||
if (isWindowsPath)
|
||||
{
|
||||
// Windows absolute path detected. transform.
|
||||
fileName.replace(QString("\\"), QString("/"));
|
||||
}
|
||||
|
||||
if (searchedPaths) searchedPaths->push_back(fileName);
|
||||
if (QFile::exists(fileName))
|
||||
{
|
||||
return fileName;
|
||||
}
|
||||
|
||||
// First check in the new project file directory
|
||||
{
|
||||
QString fileNameWithoutPath = QFileInfo(fileName).fileName();
|
||||
QString candidate = QDir::fromNativeSeparators(newProjectPath + QDir::separator() + fileNameWithoutPath);
|
||||
if (searchedPaths) searchedPaths->push_back(candidate);
|
||||
|
||||
if (QFile::exists(candidate))
|
||||
{
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
|
||||
// Then find the possible move of a directory structure where projects and files referenced are moved in "paralell"
|
||||
|
||||
QFileInfo gridFileInfo(QDir::fromNativeSeparators(fileName));
|
||||
QString gridFilePath = gridFileInfo.path();
|
||||
QString gridFileNameWoPath = gridFileInfo.fileName();
|
||||
QStringList gridPathElements = gridFilePath.split("/", QString::KeepEmptyParts);
|
||||
|
||||
QString oldProjPath = QDir::fromNativeSeparators(oldProjectPath);
|
||||
QStringList oldProjPathElements = oldProjPath.split("/", QString::KeepEmptyParts);
|
||||
|
||||
QString newProjPath = QDir::fromNativeSeparators(newProjectPath);
|
||||
QStringList newProjPathElements = newProjPath.split("/", QString::KeepEmptyParts);
|
||||
|
||||
// Find the possible equal start of the old project path, and the referenced file
|
||||
|
||||
bool pathStartsAreEqual = false;
|
||||
bool pathEndsDiffer = false;
|
||||
int firstDiffIdx = 0;
|
||||
for ( firstDiffIdx = 0; firstDiffIdx < gridPathElements.size() && firstDiffIdx < oldProjPathElements.size(); ++firstDiffIdx)
|
||||
{
|
||||
if (gridPathElements[firstDiffIdx] == oldProjPathElements[firstDiffIdx])
|
||||
{
|
||||
pathStartsAreEqual = pathStartsAreEqual || !gridPathElements[firstDiffIdx].isEmpty();
|
||||
}
|
||||
else
|
||||
{
|
||||
pathEndsDiffer = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!pathEndsDiffer && firstDiffIdx < gridPathElements.size() || firstDiffIdx < oldProjPathElements.size())
|
||||
{
|
||||
pathEndsDiffer = true;
|
||||
}
|
||||
|
||||
// If the path starts are equal, try to substitute it in the referenced file, with the corresponding new project path start
|
||||
|
||||
if (pathStartsAreEqual)
|
||||
{
|
||||
if (pathEndsDiffer)
|
||||
{
|
||||
QString oldGridFilePathEnd;
|
||||
for (int i = firstDiffIdx; i < gridPathElements.size(); ++i)
|
||||
{
|
||||
oldGridFilePathEnd += gridPathElements[i];
|
||||
oldGridFilePathEnd += "/";
|
||||
}
|
||||
|
||||
// Find the new Project File Start Path
|
||||
|
||||
QStringList oldProjectFilePathEndElements;
|
||||
for (int i = firstDiffIdx; i < oldProjPathElements.size(); ++i)
|
||||
{
|
||||
oldProjectFilePathEndElements.push_back(oldProjPathElements[i]);
|
||||
}
|
||||
|
||||
int ppIdx = oldProjectFilePathEndElements.size() -1;
|
||||
int lastDiffIdx = newProjPathElements.size() -1;
|
||||
|
||||
for (; lastDiffIdx >= 0 && ppIdx >= 0; --lastDiffIdx, --ppIdx)
|
||||
{
|
||||
if (oldProjectFilePathEndElements[ppIdx] != newProjPathElements[lastDiffIdx])
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QString newProjecetFileStartPath;
|
||||
for (int i = 0; i <= lastDiffIdx; ++i)
|
||||
{
|
||||
newProjecetFileStartPath += newProjPathElements[i];
|
||||
newProjecetFileStartPath += "/";
|
||||
}
|
||||
|
||||
QString relocationPath = newProjecetFileStartPath + oldGridFilePathEnd;
|
||||
|
||||
QString relocatedFileName = relocationPath + gridFileNameWoPath;
|
||||
|
||||
if (searchedPaths) searchedPaths->push_back(relocatedFileName);
|
||||
|
||||
if (QFile::exists(relocatedFileName))
|
||||
{
|
||||
return relocatedFileName;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// The Grid file was located in the same dir as the Project file. This is supposed to be handled above.
|
||||
// So we did not find it
|
||||
}
|
||||
}
|
||||
|
||||
// return the unchanged filename, if we could not find a valid relocation file
|
||||
if (foundFile) *foundFile = false;
|
||||
|
||||
return fileName;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@@ -574,3 +419,16 @@ bool RimEclipseCase::openReserviorCase()
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimView*> RimEclipseCase::views()
|
||||
{
|
||||
std::vector<RimView*> views;
|
||||
for (size_t vIdx = 0; vIdx < reservoirViews.size(); ++vIdx)
|
||||
{
|
||||
views.push_back(reservoirViews[vIdx]);
|
||||
}
|
||||
return views;
|
||||
}
|
||||
|
||||
@@ -20,12 +20,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RimCase.h"
|
||||
|
||||
#include "cvfBase.h"
|
||||
#include "cvfObject.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "RifReaderInterface.h"
|
||||
|
||||
class QString;
|
||||
|
||||
class RigCaseData;
|
||||
@@ -35,12 +36,13 @@ class RimCaseCollection;
|
||||
class RimIdenticalGridCaseGroup;
|
||||
class RimReservoirCellResultsStorage;
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
// Interface for reservoirs.
|
||||
//
|
||||
//==================================================================================================
|
||||
class RimEclipseCase : public caf::PdmObject
|
||||
class RimEclipseCase : public RimCase
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
public:
|
||||
@@ -49,8 +51,6 @@ public:
|
||||
|
||||
|
||||
// Fields:
|
||||
caf::PdmField<QString> caseUserDescription;
|
||||
caf::PdmField<int> caseId;
|
||||
caf::PdmField<bool> releaseResultMemory;
|
||||
caf::PdmPointersField<RimReservoirView*> reservoirViews;
|
||||
caf::PdmField<bool> flipXAxis;
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
|
||||
|
||||
bool openReserviorCase();
|
||||
virtual bool openEclipseGridFile() { return false; }; // Should be pure virtual but PDM does not allow that.
|
||||
virtual bool openEclipseGridFile() = 0;
|
||||
|
||||
RigCaseData* reservoirData();
|
||||
const RigCaseData* reservoirData() const;
|
||||
@@ -75,11 +75,11 @@ public:
|
||||
virtual QString locationOnDisc() const { return QString(); }
|
||||
virtual QString gridFileName() const { return QString(); }
|
||||
|
||||
virtual void updateFilePathsFromProjectPath(const QString& projectPath, const QString& oldProjectPath) { };
|
||||
|
||||
RimCaseCollection* parentCaseCollection();
|
||||
RimIdenticalGridCaseGroup* parentGridCaseGroup();
|
||||
|
||||
virtual std::vector<RimView*> views();
|
||||
|
||||
// Overridden methods from PdmObject
|
||||
public:
|
||||
@@ -92,8 +92,7 @@ protected:
|
||||
protected:
|
||||
void computeCachedData();
|
||||
void setReservoirData(RigCaseData* eclipseCase);
|
||||
static QString relocateFile(const QString& fileName, const QString& newProjectPath, const QString& oldProjectPath,
|
||||
bool* foundFile, std::vector<QString>* searchedPaths);
|
||||
|
||||
|
||||
private:
|
||||
cvf::ref<RigCaseData> m_rigEclipseCase;
|
||||
|
||||
@@ -91,4 +91,35 @@ bool RimGeoMechCase::openGeoMechCase()
|
||||
return m_geoMechCaseData->openAndReadFemParts();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGeoMechCase::updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath)
|
||||
{
|
||||
bool foundFile = false;
|
||||
std::vector<QString> searchedPaths;
|
||||
|
||||
// Update filename and folder paths when opening project from a different file location
|
||||
m_caseFileName = relocateFile(m_caseFileName(), newProjectPath, oldProjectPath, &foundFile, &searchedPaths);
|
||||
|
||||
#if 0 // Output the search path for debugging
|
||||
for (size_t i = 0; i < searchedPaths.size(); ++i)
|
||||
qDebug() << searchedPaths[i];
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimView*> RimGeoMechCase::views()
|
||||
{
|
||||
std::vector<RimView*> views;
|
||||
for (size_t vIdx = 0; vIdx < geoMechViews.size(); ++vIdx)
|
||||
{
|
||||
views.push_back(geoMechViews[vIdx]);
|
||||
}
|
||||
return views;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
#include "RimCase.h"
|
||||
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
@@ -32,7 +33,7 @@ class RifGeoMechReaderInterface;
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimGeoMechCase : public caf::PdmObject
|
||||
class RimGeoMechCase : public RimCase
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
@@ -48,6 +49,9 @@ public:
|
||||
|
||||
RimGeoMechView* createAndAddReservoirView();
|
||||
|
||||
virtual void updateFilePathsFromProjectPath(const QString& projectPath, const QString& oldProjectPath);
|
||||
virtual std::vector<RimView*> views();
|
||||
|
||||
// Fields:
|
||||
caf::PdmField<QString> caseUserDescription;
|
||||
caf::PdmPointersField<RimGeoMechView*> geoMechViews;
|
||||
|
||||
@@ -392,7 +392,11 @@ RimGeoMechCase* RimGeoMechView::geoMechCase()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGeoMechView::clampCurrentTimestep()
|
||||
{
|
||||
size_t maxFrameCount = m_geomechCase->geoMechData()->frameCount(0, cellResult()->resultAddress());
|
||||
size_t maxFrameCount = 0;
|
||||
|
||||
if (m_geomechCase){
|
||||
maxFrameCount = m_geomechCase->geoMechData()->frameCount(0, cellResult()->resultAddress());
|
||||
}
|
||||
|
||||
if (m_currentTimeStep >= maxFrameCount ) m_currentTimeStep = (int)(maxFrameCount -1);
|
||||
if (m_currentTimeStep < 0 ) m_currentTimeStep = 0;
|
||||
@@ -455,3 +459,4 @@ void RivElmVisibilityCalculator::computeAllVisible(cvf::UByteArray* elmVisibilit
|
||||
elmVisibilities->resize(femPart->elementCount());
|
||||
elmVisibilities->setAll(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
void setGeoMechCase(RimGeoMechCase* gmCase);
|
||||
RimGeoMechCase* geoMechCase();
|
||||
|
||||
void loadDataAndUpdate();
|
||||
virtual void loadDataAndUpdate();
|
||||
|
||||
virtual void endAnimation() {}
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
#include "RimWellPathImport.h"
|
||||
|
||||
#include <QDir>
|
||||
#include "RimGeoMechModels.h"
|
||||
#include "RimGeoMechCase.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimProject, "ResInsightProject");
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -137,7 +139,7 @@ void RimProject::initScriptDirectories()
|
||||
{
|
||||
int largestId = -1;
|
||||
|
||||
std::vector<RimEclipseCase*> cases;
|
||||
std::vector<RimCase*> cases;
|
||||
allCases(cases);
|
||||
|
||||
for (size_t i = 0; i < cases.size(); i++)
|
||||
@@ -324,7 +326,7 @@ void RimProject::setProjectFileNameAndUpdateDependencies(const QString& fileName
|
||||
|
||||
// Loop over all cases and update file path
|
||||
|
||||
std::vector<RimEclipseCase*> cases;
|
||||
std::vector<RimCase*> cases;
|
||||
allCases(cases);
|
||||
for (size_t i = 0; i < cases.size(); i++)
|
||||
{
|
||||
@@ -345,7 +347,7 @@ void RimProject::setProjectFileNameAndUpdateDependencies(const QString& fileName
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimProject::assignCaseIdToCase(RimEclipseCase* reservoirCase)
|
||||
void RimProject::assignCaseIdToCase(RimCase* reservoirCase)
|
||||
{
|
||||
if (reservoirCase)
|
||||
{
|
||||
@@ -371,32 +373,44 @@ void RimProject::assignIdToCaseGroup(RimIdenticalGridCaseGroup* caseGroup)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimProject::allCases(std::vector<RimEclipseCase*>& cases)
|
||||
void RimProject::allCases(std::vector<RimCase*>& cases)
|
||||
{
|
||||
for (size_t oilFieldIdx = 0; oilFieldIdx < oilFields().size(); oilFieldIdx++)
|
||||
{
|
||||
RimOilField* oilField = oilFields[oilFieldIdx];
|
||||
RimAnalysisModels* analysisModels = oilField ? oilField->analysisModels() : NULL;
|
||||
if (analysisModels == NULL) continue;
|
||||
if (!oilField) continue;
|
||||
|
||||
for (size_t caseIdx = 0; caseIdx < analysisModels->cases.size(); caseIdx++)
|
||||
RimAnalysisModels* analysisModels = oilField->analysisModels();
|
||||
if (analysisModels )
|
||||
{
|
||||
cases.push_back(analysisModels->cases[caseIdx]);
|
||||
}
|
||||
for (size_t cgIdx = 0; cgIdx < analysisModels->caseGroups.size(); cgIdx++)
|
||||
{
|
||||
// Load the Main case of each IdenticalGridCaseGroup
|
||||
RimIdenticalGridCaseGroup* cg = analysisModels->caseGroups[cgIdx];
|
||||
if (cg == NULL) continue;
|
||||
|
||||
for (size_t caseIdx = 0; caseIdx < cg->statisticsCaseCollection()->reservoirs.size(); caseIdx++)
|
||||
for (size_t caseIdx = 0; caseIdx < analysisModels->cases.size(); caseIdx++)
|
||||
{
|
||||
cases.push_back(cg->statisticsCaseCollection()->reservoirs[caseIdx]);
|
||||
cases.push_back(analysisModels->cases[caseIdx]);
|
||||
}
|
||||
|
||||
for (size_t caseIdx = 0; caseIdx < cg->caseCollection()->reservoirs.size(); caseIdx++)
|
||||
for (size_t cgIdx = 0; cgIdx < analysisModels->caseGroups.size(); cgIdx++)
|
||||
{
|
||||
cases.push_back(cg->caseCollection()->reservoirs[caseIdx]);
|
||||
// Load the Main case of each IdenticalGridCaseGroup
|
||||
RimIdenticalGridCaseGroup* cg = analysisModels->caseGroups[cgIdx];
|
||||
if (cg == NULL) continue;
|
||||
|
||||
for (size_t caseIdx = 0; caseIdx < cg->statisticsCaseCollection()->reservoirs.size(); caseIdx++)
|
||||
{
|
||||
cases.push_back(cg->statisticsCaseCollection()->reservoirs[caseIdx]);
|
||||
}
|
||||
|
||||
for (size_t caseIdx = 0; caseIdx < cg->caseCollection()->reservoirs.size(); caseIdx++)
|
||||
{
|
||||
cases.push_back(cg->caseCollection()->reservoirs[caseIdx]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RimGeoMechModels* geomModels = oilField->geoMechModels();
|
||||
if (geomModels)
|
||||
{
|
||||
for (size_t caseIdx = 0; caseIdx < geomModels->cases.size(); caseIdx++)
|
||||
{
|
||||
cases.push_back(geomModels->cases[caseIdx]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -408,17 +422,17 @@ void RimProject::allCases(std::vector<RimEclipseCase*>& cases)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimProject::createDisplayModelAndRedrawAllViews()
|
||||
{
|
||||
std::vector<RimEclipseCase*> cases;
|
||||
std::vector<RimCase*> cases;
|
||||
allCases(cases);
|
||||
for (size_t caseIdx = 0; caseIdx < cases.size(); caseIdx++)
|
||||
{
|
||||
RimEclipseCase* rimCase = cases[caseIdx];
|
||||
RimCase* rimCase = cases[caseIdx];
|
||||
if (rimCase == NULL) continue;
|
||||
std::vector<RimView*> views = rimCase->views();
|
||||
|
||||
for (size_t viewIdx = 0; viewIdx < rimCase->reservoirViews.size(); viewIdx++)
|
||||
for (size_t viewIdx = 0; viewIdx < views.size(); viewIdx++)
|
||||
{
|
||||
RimReservoirView* reservoirView = rimCase->reservoirViews[viewIdx];
|
||||
reservoirView->scheduleCreateDisplayModelAndRedraw();
|
||||
views[viewIdx]->scheduleCreateDisplayModelAndRedraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -439,14 +453,14 @@ RimOilField* RimProject::activeOilField()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimProject::computeUtmAreaOfInterest()
|
||||
{
|
||||
std::vector<RimEclipseCase*> cases;
|
||||
std::vector<RimCase*> cases;
|
||||
allCases(cases);
|
||||
|
||||
cvf::BoundingBox projectBB;
|
||||
|
||||
for (size_t i = 0; i < cases.size(); i++)
|
||||
{
|
||||
RimEclipseCase* rimCase = cases[i];
|
||||
RimEclipseCase* rimCase = dynamic_cast<RimEclipseCase*>(cases[i]);
|
||||
|
||||
if (rimCase && rimCase->reservoirData())
|
||||
{
|
||||
@@ -457,6 +471,10 @@ void RimProject::computeUtmAreaOfInterest()
|
||||
projectBB.add(rigGrid->boundingBox());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Todo : calculate BBox of GeoMechCase
|
||||
}
|
||||
}
|
||||
|
||||
if (projectBB.isValid())
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
class RimOilField;
|
||||
class RimEclipseCase;
|
||||
class RimCase;
|
||||
class RigGridManager;
|
||||
class RimScriptCollection;
|
||||
class RimIdenticalGridCaseGroup;
|
||||
@@ -57,11 +58,11 @@ public:
|
||||
|
||||
void setProjectFileNameAndUpdateDependencies(const QString& fileName);
|
||||
|
||||
void assignCaseIdToCase(RimEclipseCase* reservoirCase);
|
||||
void assignCaseIdToCase(RimCase* reservoirCase);
|
||||
void assignIdToCaseGroup(RimIdenticalGridCaseGroup* caseGroup);
|
||||
|
||||
void allCases(std::vector<RimEclipseCase*>& cases); // VL endre impl
|
||||
void createDisplayModelAndRedrawAllViews(); // VL endre impl
|
||||
void allCases(std::vector<RimCase*>& cases);
|
||||
void createDisplayModelAndRedrawAllViews();
|
||||
|
||||
void computeUtmAreaOfInterest();
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ public:
|
||||
|
||||
// Display model generation
|
||||
public:
|
||||
void loadDataAndUpdate();
|
||||
virtual void loadDataAndUpdate();
|
||||
bool isTimeStepDependentDataVisible() const;
|
||||
|
||||
void scheduleGeometryRegen(unsigned short geometryType);
|
||||
|
||||
@@ -70,6 +70,7 @@ public:
|
||||
};
|
||||
|
||||
caf::PdmField< bool > m_calculateEditCommand;
|
||||
virtual void updateFilePathsFromProjectPath(const QString& projectPath, const QString& oldProjectPath){}
|
||||
|
||||
private:
|
||||
RimIdenticalGridCaseGroup* caseGroup();
|
||||
|
||||
@@ -241,7 +241,7 @@ void RimUiTreeView::contextMenuEvent(QContextMenuEvent* event)
|
||||
RiuMainWindow* ruiMainWindow = RiuMainWindow::instance();
|
||||
if (ruiMainWindow)
|
||||
{
|
||||
std::vector<RimEclipseCase*> cases;
|
||||
std::vector<RimCase*> cases;
|
||||
ruiMainWindow->selectedCases(cases);
|
||||
|
||||
if (cases.size() > 0)
|
||||
|
||||
@@ -42,7 +42,7 @@ void caf::AppEnum< RimView::SurfaceModeType >::setUp()
|
||||
} // End namespace caf
|
||||
|
||||
|
||||
|
||||
#include "cafPdmAbstractClassSourceInit.h"
|
||||
|
||||
CAF_PDM_ABSTRACT_SOURCE_INIT(RimView, "GenericView"); // Do not use. Abstract class
|
||||
|
||||
|
||||
@@ -33,10 +33,6 @@ namespace cvf
|
||||
class Transform;
|
||||
}
|
||||
|
||||
#define CAF_PDM_ABSTRACT_SOURCE_INIT(ClassName, keyword) \
|
||||
bool ClassName::Error_You_forgot_to_add_the_macro_CAF_PDM_HEADER_INIT_and_or_CAF_PDM_SOURCE_INIT_to_your_cpp_file_for_this_class() { return false;} \
|
||||
QString ClassName::classKeywordStatic() { assert(PdmObject::isValidXmlElementName(keyword)); return keyword; }
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
@@ -99,6 +95,8 @@ public:
|
||||
void createDisplayModelAndRedraw();
|
||||
|
||||
public:
|
||||
virtual void loadDataAndUpdate() = 0;
|
||||
|
||||
virtual caf::PdmFieldHandle* objectToggleField() { return &showWindow; }
|
||||
virtual caf::PdmFieldHandle* userDescriptionField() { return &name; }
|
||||
protected:
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
#define CAF_PDM_ABSTRACT_SOURCE_INIT(ClassName, keyword) \
|
||||
bool ClassName::Error_You_forgot_to_add_the_macro_CAF_PDM_HEADER_INIT_and_or_CAF_PDM_SOURCE_INIT_to_your_cpp_file_for_this_class() { return false;} \
|
||||
QString ClassName::classKeywordStatic() { assert(PdmObject::isValidXmlElementName(keyword)); return keyword; }
|
||||
|
||||
|
||||
@@ -50,11 +50,11 @@
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void getCaseInfoFromCases(std::vector<RimEclipseCase*>& cases, std::vector<qint64>& caseIds, std::vector<QString>& caseNames, std::vector<QString> &caseTypes, std::vector<qint64>& caseGroupIds)
|
||||
void getCaseInfoFromCases(std::vector<RimCase*>& cases, std::vector<qint64>& caseIds, std::vector<QString>& caseNames, std::vector<QString> &caseTypes, std::vector<qint64>& caseGroupIds)
|
||||
{
|
||||
for (size_t i = 0; i < cases.size(); i++)
|
||||
{
|
||||
RimEclipseCase* rimCase = cases[i];
|
||||
RimCase* rimCase = cases[i];
|
||||
|
||||
qint64 caseId = -1;
|
||||
QString caseName;
|
||||
@@ -125,7 +125,7 @@ public:
|
||||
RiuMainWindow* ruiMainWindow = RiuMainWindow::instance();
|
||||
if (ruiMainWindow)
|
||||
{
|
||||
std::vector<RimEclipseCase*> cases;
|
||||
std::vector<RimCase*> cases;
|
||||
ruiMainWindow->selectedCases(cases);
|
||||
|
||||
std::vector<qint64> caseIds;
|
||||
@@ -243,7 +243,7 @@ public:
|
||||
if (analysisModels)
|
||||
{
|
||||
|
||||
std::vector<RimEclipseCase*> cases;
|
||||
std::vector<RimCase*> cases;
|
||||
if (argCaseGroupId == -1)
|
||||
{
|
||||
proj->allCases(cases);
|
||||
|
||||
@@ -163,14 +163,14 @@ RimEclipseCase* RiaSocketServer::findReservoir(int caseId)
|
||||
RimProject* project = RiaApplication::instance()->project();
|
||||
if (!project) return NULL;
|
||||
|
||||
std::vector<RimEclipseCase*> cases;
|
||||
std::vector<RimCase*> cases;
|
||||
project->allCases(cases);
|
||||
|
||||
for (size_t i = 0; i < cases.size(); i++)
|
||||
{
|
||||
if (cases[i]->caseId == currCaseId)
|
||||
{
|
||||
return cases[i];
|
||||
return dynamic_cast<RimEclipseCase*>(cases[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,14 +72,20 @@ RimEclipseCase* RiaSocketTools::findCaseFromArgs(RiaSocketServer* server, const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaSocketTools::getCaseInfoFromCase(RimEclipseCase* rimCase, qint64& caseId, QString& caseName, QString& caseType, qint64& caseGroupId)
|
||||
void RiaSocketTools::getCaseInfoFromCase(RimCase* rimCase, qint64& caseId, QString& caseName, QString& caseType, qint64& caseGroupId)
|
||||
{
|
||||
CVF_ASSERT(rimCase);
|
||||
|
||||
caseId = rimCase->caseId;
|
||||
caseName = rimCase->caseUserDescription;
|
||||
|
||||
RimCaseCollection* caseCollection = rimCase->parentCaseCollection();
|
||||
RimEclipseCase* eclCase = dynamic_cast<RimEclipseCase*> (rimCase);
|
||||
RimCaseCollection* caseCollection = NULL;
|
||||
if (eclCase)
|
||||
{
|
||||
caseCollection = eclCase->parentCaseCollection();
|
||||
}
|
||||
|
||||
if (caseCollection)
|
||||
{
|
||||
caseGroupId = caseCollection->parentCaseGroup()->groupId;
|
||||
@@ -101,6 +107,10 @@ void RiaSocketTools::getCaseInfoFromCase(RimEclipseCase* rimCase, qint64& caseId
|
||||
{
|
||||
caseType = "InputCase";
|
||||
}
|
||||
else if (eclCase)
|
||||
{
|
||||
caseType = "GeoMechCase";
|
||||
}
|
||||
else
|
||||
{
|
||||
caseType = "ResultCase";
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class RimEclipseCase;
|
||||
class RimCase;
|
||||
class RiaSocketServer;
|
||||
class QTcpSocket;
|
||||
|
||||
@@ -28,7 +28,7 @@ class RiaSocketTools
|
||||
{
|
||||
public:
|
||||
static RimEclipseCase* findCaseFromArgs(RiaSocketServer* server, const QList<QByteArray>& args);
|
||||
static void getCaseInfoFromCase(RimEclipseCase* rimCase, qint64& caseId, QString& caseName, QString& caseType, qint64& caseGroupId);
|
||||
static void getCaseInfoFromCase(RimCase* rimCase, qint64& caseId, QString& caseName, QString& caseType, qint64& caseGroupId);
|
||||
|
||||
static bool writeBlockData(RiaSocketServer* server, QTcpSocket* socket, const char* data, quint64 bytesToWrite);
|
||||
};
|
||||
|
||||
@@ -1329,18 +1329,20 @@ void RiuMainWindow::slotSubWindowActivated(QMdiSubWindow* subWindow)
|
||||
if (!proj) return;
|
||||
|
||||
// Iterate all cases in each oil field
|
||||
std::vector<RimEclipseCase*> allCases;
|
||||
std::vector<RimCase*> allCases;
|
||||
proj->allCases(allCases);
|
||||
|
||||
for (size_t caseIdx = 0; caseIdx < allCases.size(); ++caseIdx)
|
||||
{
|
||||
RimEclipseCase* reservoirCase = allCases[caseIdx];
|
||||
RimCase* reservoirCase = allCases[caseIdx];
|
||||
if (reservoirCase == NULL) continue;
|
||||
|
||||
std::vector<RimView*> views = reservoirCase->views();
|
||||
|
||||
size_t viewIdx;
|
||||
for (viewIdx = 0; viewIdx < reservoirCase->reservoirViews().size(); viewIdx++)
|
||||
for (viewIdx = 0; viewIdx < views.size(); viewIdx++)
|
||||
{
|
||||
RimReservoirView* riv = reservoirCase->reservoirViews()[viewIdx];
|
||||
RimView* riv = views[viewIdx];
|
||||
|
||||
if (riv &&
|
||||
riv->viewer() &&
|
||||
@@ -1858,7 +1860,7 @@ void RiuMainWindow::updateScaleValue()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// TODO: This function will be moved to a class responsible for handling the application selection concept
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMainWindow::selectedCases(std::vector<RimEclipseCase*>& cases)
|
||||
void RiuMainWindow::selectedCases(std::vector<RimCase*>& cases)
|
||||
{
|
||||
if (m_treeView && m_treeView->selectionModel())
|
||||
{
|
||||
@@ -1867,7 +1869,7 @@ void RiuMainWindow::selectedCases(std::vector<RimEclipseCase*>& cases)
|
||||
caf::PdmObjectGroup group;
|
||||
m_treeModelPdm->populateObjectGroupFromModelIndexList(selectedModelIndexes, &group);
|
||||
|
||||
std::vector<caf::PdmPointer<RimEclipseCase> > typedObjects;
|
||||
std::vector<caf::PdmPointer<RimCase> > typedObjects;
|
||||
group.objectsByType(&typedObjects);
|
||||
|
||||
for (size_t i = 0; i < typedObjects.size(); i++)
|
||||
|
||||
@@ -43,6 +43,7 @@ class RiuProcessMonitor;
|
||||
class RimUiTreeModelPdm;
|
||||
class RimUiTreeView;
|
||||
class RimEclipseCase;
|
||||
class RimCase;
|
||||
|
||||
namespace caf
|
||||
{
|
||||
@@ -93,7 +94,7 @@ public:
|
||||
|
||||
void setCurrentObjectInTreeView(caf::PdmObject* object);
|
||||
|
||||
void selectedCases(std::vector<RimEclipseCase*>& cases);
|
||||
void selectedCases(std::vector<RimCase*>& cases);
|
||||
|
||||
void setDefaultWindowSize();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user