Merge branch 'dev' into pre-proto

This commit is contained in:
Bjørnar Grip Fjær 2017-08-01 12:44:11 +02:00
commit 7179aaeac9
128 changed files with 5129 additions and 423 deletions

View File

@ -90,9 +90,11 @@
#include "RiuFlowCharacteristicsPlot.h"
#include "RicImportSummaryCaseFeature.h"
#include "RicSnapshotViewToClipboardFeature.h"
#include "ExportCommands/RicSnapshotViewToClipboardFeature.h"
#include "SummaryPlotCommands/RicNewSummaryPlotFeature.h"
#include "RicfCommandFileExecutor.h"
#include "cafFixedAtlasFont.h"
#include "cafAppEnum.h"
@ -218,6 +220,8 @@ RiaApplication::RiaApplication(int& argc, char** argv)
m_runningRegressionTests = false;
m_runningWorkerProcess = false;
m_mainPlotWindow = nullptr;
m_recentFileActionProvider = std::unique_ptr<RiuRecentFileActionProvider>(new RiuRecentFileActionProvider);
@ -1320,7 +1324,9 @@ bool RiaApplication::parseArguments()
progOpt.registerOption("size", "<width> <height>", "Set size of the main application window.", cvf::ProgramOptions::MULTI_VALUE);
progOpt.registerOption("replaceCase", "[<caseId>] <newGridFile>", "Replace grid in <caseId> or first case with <newgridFile>. Repeat parameter for multiple replace operations.", cvf::ProgramOptions::MULTI_VALUE, cvf::ProgramOptions::COMBINE_REPEATED);
progOpt.registerOption("replaceSourceCases", "[<caseGroupId>] <gridListFile>", "Replace source cases in <caseGroupId> or first grid case group with the grid files listed in the <gridListFile> file. Repeat parameter for multiple replace operations.", cvf::ProgramOptions::MULTI_VALUE, cvf::ProgramOptions::COMBINE_REPEATED);
progOpt.registerOption("replacePropertiesFolder", "[<caseId>] <newPropertiesFolder>", "Replace the folder containing property files for an eclipse input case.", cvf::ProgramOptions::MULTI_VALUE);
progOpt.registerOption("multiCaseSnapshots", "<gridListFile>", "For each grid file listed in the <gridListFile> file, replace the first case in the project and save snapshot of all views.", cvf::ProgramOptions::SINGLE_VALUE);
progOpt.registerOption("commandFile", "<commandfile>", "Execute the command file.", cvf::ProgramOptions::SINGLE_VALUE);
progOpt.registerOption("help", "", "Displays help text.");
progOpt.registerOption("?", "", "Displays help text.");
progOpt.registerOption("regressiontest", "<folder>", "System command", cvf::ProgramOptions::SINGLE_VALUE);
@ -1483,6 +1489,30 @@ bool RiaApplication::parseArguments()
projectLoadAction = PLA_CALCULATE_STATISTICS;
}
if (cvf::Option o = progOpt.option("replacePropertiesFolder"))
{
if (projectModifier.isNull()) projectModifier = new RiaProjectModifier;
if (o.valueCount() == 1)
{
QString propertiesFolder = cvfqt::Utils::toQString(o.safeValue(0));
projectModifier->setReplacePropertiesFolderFirstOccurrence(propertiesFolder);
}
else
{
size_t optionIdx = 0;
while (optionIdx < o.valueCount())
{
const int caseId = o.safeValue(optionIdx++).toInt(-1);
QString propertiesFolder = cvfqt::Utils::toQString(o.safeValue(optionIdx++));
if (caseId != -1 && !propertiesFolder.isEmpty())
{
projectModifier->setReplacePropertiesFolder(caseId, propertiesFolder);
}
}
}
}
loadProject(projectFileName, projectLoadAction, projectModifier.p());
}
@ -1493,18 +1523,27 @@ bool RiaApplication::parseArguments()
QStringList caseNames = cvfqt::Utils::toQStringList(o.values());
foreach (QString caseName, caseNames)
{
QString caseFileNameWithExt = caseName + ".EGRID";
if (caf::Utils::fileExists(caseFileNameWithExt))
QString fileExtension = caf::Utils::fileExtension(caseName);
if (caf::Utils::fileExists(caseName) &&
(fileExtension == "EGRID" || fileExtension == "GRID"))
{
openEclipseCaseFromFile(caseFileNameWithExt);
openEclipseCaseFromFile(caseName);
}
else
{
caseFileNameWithExt = caseName + ".GRID";
QString caseFileNameWithExt = caseName + ".EGRID";
if (caf::Utils::fileExists(caseFileNameWithExt))
{
openEclipseCaseFromFile(caseFileNameWithExt);
}
else
{
caseFileNameWithExt = caseName + ".GRID";
if (caf::Utils::fileExists(caseFileNameWithExt))
{
openEclipseCaseFromFile(caseFileNameWithExt);
}
}
}
}
}
@ -1576,6 +1615,24 @@ bool RiaApplication::parseArguments()
return false;
}
if (cvf::Option o = progOpt.option("commandFile"))
{
QString commandFile = cvfqt::Utils::toQString(o.safeValue(0));
QFile file(commandFile);
RicfMessages messages;
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
{
// TODO : Error logging?
return false;
}
QTextStream in(&file);
RicfCommandFileExecutor::instance()->executeCommands(in);
closeAllWindows();
processEvents();
return false;
}
return true;
}
@ -1795,6 +1852,14 @@ std::vector<QAction*> RiaApplication::recentFileActions() const
return m_recentFileActionProvider->actions();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication::setStartDir(const QString& startDir)
{
m_startupDefaultDirectory = startDir;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -1895,6 +1960,7 @@ void RiaApplication::slotWorkerProcessFinished(int exitCode, QProcess::ExitStatu
if (exitStatus == QProcess::CrashExit)
{
// MFLog::error("Simulation execution crashed or was aborted.");
m_runningWorkerProcess = false;
return;
}
@ -1906,6 +1972,7 @@ void RiaApplication::slotWorkerProcessFinished(int exitCode, QProcess::ExitStatu
if (exitCode != 0)
{
// MFLog::error(QString("Simulation execution failed (exit code %1).").arg(exitCode));
m_runningWorkerProcess = false;
return;
}
@ -1918,6 +1985,7 @@ void RiaApplication::slotWorkerProcessFinished(int exitCode, QProcess::ExitStatu
{
// Disable concept of current case
m_socketServer->setCurrentCaseId(-1);
m_runningWorkerProcess = false;
}
}
@ -1942,6 +2010,7 @@ bool RiaApplication::launchProcess(const QString& program, const QStringList& ar
m_socketServer->setCurrentCaseId(-1);
}
m_runningWorkerProcess = true;
m_workerProcess = new caf::UiProcess(this);
QProcessEnvironment penv = QProcessEnvironment::systemEnvironment();
@ -1978,6 +2047,7 @@ bool RiaApplication::launchProcess(const QString& program, const QStringList& ar
{
m_workerProcess->close();
m_workerProcess = NULL;
m_runningWorkerProcess = false;
RiuMainWindow::instance()->processMonitor()->stopMonitorWorkProcess();
@ -2097,9 +2167,25 @@ void RiaApplication::terminateProcess()
m_workerProcess->close();
}
m_runningWorkerProcess = false;
m_workerProcess = NULL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication::waitForProcess() const
{
while (m_runningWorkerProcess)
{
#ifdef WIN32
Sleep(100);
#else
usleep(100000);
#endif
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -82,6 +82,12 @@ public:
NAVIGATION_POLICY_RMS
};
enum ProjectLoadAction
{
PLA_NONE = 0,
PLA_CALCULATE_STATISTICS = 1
};
public:
RiaApplication(int& argc, char** argv);
~RiaApplication();
@ -125,6 +131,7 @@ public:
QString currentProjectPath() const;
QString createAbsolutePathFromProjectRelativePath(QString projectRelativePath);
bool loadProject(const QString& projectFileName);
bool loadProject(const QString& projectFileName, ProjectLoadAction loadAction, RiaProjectModifier* projectModifier);
bool saveProject();
bool saveProjectAs(const QString& fileName);
bool saveProjectPromptForFileName();
@ -160,6 +167,7 @@ public:
bool launchProcess(const QString& program, const QStringList& arguments);
bool launchProcessForMultipleCases(const QString& program, const QStringList& arguments, const std::vector<int>& caseIds);
void terminateProcess();
void waitForProcess() const;
RiaPreferences* preferences();
void applyPreferences();
@ -196,17 +204,13 @@ public:
void addToRecentFiles(const QString& fileName);
std::vector<QAction*> recentFileActions() const;
private:
enum ProjectLoadAction
{
PLA_NONE = 0,
PLA_CALCULATE_STATISTICS = 1
};
void setStartDir(const QString& startDir);
bool loadProject(const QString& projectFileName, ProjectLoadAction loadAction, RiaProjectModifier* projectModifier);
static std::vector<QString> readFileListFromTextFile(QString listFileName);
private:
void onProjectOpenedOrClosed();
std::vector<QString> readFileListFromTextFile(QString listFileName);
void setWindowCaptionFromAppState();
void clearViewsScheduledForUpdate();
@ -269,6 +273,8 @@ private:
QString m_helpText;
bool m_runningRegressionTests;
bool m_runningWorkerProcess;
RiuMainPlotWindow* m_mainPlotWindow;
std::unique_ptr<RiuRecentFileActionProvider> m_recentFileActionProvider;

View File

@ -44,11 +44,11 @@ int main(int argc, char *argv[])
window.loadWinGeoAndDockToolBarLayout();
window.showWindow();
RiaLogging::setLoggerInstance(new RiuMessagePanelLogger(window.messagePanel()));
RiaLogging::loggerInstance()->setLevel(RI_LL_DEBUG);
if (app.parseArguments())
{
RiaLogging::setLoggerInstance(new RiuMessagePanelLogger(window.messagePanel()));
RiaLogging::loggerInstance()->setLevel(RI_LL_DEBUG);
int exitCode = app.exec();
RiaLogging::deleteLoggerInstance();

View File

@ -21,6 +21,7 @@
#include "RimCaseCollection.h"
#include "RimEclipseCaseCollection.h"
#include "RimEclipseInputCase.h"
#include "RimEclipseResultCase.h"
#include "RimIdenticalGridCaseGroup.h"
#include "RimOilField.h"
@ -75,6 +76,25 @@ void RiaProjectModifier::setReplaceSourceCasesById(int caseGroupIdToReplace, std
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaProjectModifier::setReplacePropertiesFolderFirstOccurrence(QString newPropertiesFolder)
{
m_caseIdToPropertiesFolderMap[RiaProjectModifier::firstOccurrenceId()] = makeFilePathAbsolute(newPropertiesFolder);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaProjectModifier::setReplacePropertiesFolder(int caseIdToReplace, QString newPropertiesFolder)
{
if (caseIdToReplace >= 0)
{
m_caseIdToPropertiesFolderMap[caseIdToReplace] = makeFilePathAbsolute(newPropertiesFolder);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -90,6 +110,11 @@ bool RiaProjectModifier::applyModificationsToProject(RimProject* project)
replaceSourceCases(project);
}
if (m_caseIdToPropertiesFolderMap.size() > 0)
{
replacePropertiesFolder(project);
}
return true;
}
@ -167,6 +192,38 @@ void RiaProjectModifier::replaceCase(RimProject* project)
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaProjectModifier::replacePropertiesFolder(RimProject* project)
{
std::vector<RimCase*> allCases;
project->allCases(allCases);
for (RimCase* rimCase : allCases)
{
RimEclipseInputCase* inputCase = dynamic_cast<RimEclipseInputCase*>(rimCase);
if (inputCase)
{
for (auto item : m_caseIdToPropertiesFolderMap)
{
int caseIdToReplace = item.first;
if (caseIdToReplace == RiaProjectModifier::firstOccurrenceId())
{
caseIdToReplace = firstInputCaseId(project);
}
if (caseIdToReplace == inputCase->caseId())
{
inputCase->updateAdditionalFileFolder(item.second);
}
}
}
}
}
//--------------------------------------------------------------------------------------------------
/// Returns absolute path name to the specified file.
///
@ -236,6 +293,26 @@ int RiaProjectModifier::firstGroupId(RimProject* project)
return -1;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RiaProjectModifier::firstInputCaseId(RimProject * project)
{
std::vector<RimCase*> allCases;
project->allCases(allCases);
for (RimCase* rimCase : allCases)
{
RimEclipseInputCase* resultCase = dynamic_cast<RimEclipseInputCase*>(rimCase);
if (resultCase)
{
return resultCase->caseId();
}
}
return -1;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -47,21 +47,28 @@ public:
void setReplaceSourceCasesFirstOccurrence(std::vector<QString> newGridFileNames);
void setReplaceSourceCasesById(int caseGroupIdToReplace, std::vector<QString> newGridFileNames);
void setReplacePropertiesFolderFirstOccurrence(QString newPropertiesFolder);
void setReplacePropertiesFolder(int caseIdToReplace, QString newPropertiesFolder);
bool applyModificationsToProject(RimProject* project);
private:
void replaceSourceCases(RimProject* project);
void replaceCase(RimProject* project);
void replacePropertiesFolder(RimProject* project);
static QString makeFilePathAbsolute(QString relOrAbsolutePath);
static QString caseNameFromGridFileName(QString fullGridFilePathName);
static int firstCaseId(RimProject* project);
static int firstGroupId(RimProject* project);
static int firstInputCaseId(RimProject* project);
static int firstOccurrenceId();
private:
std::map<int, QString> m_caseIdToGridFileNameMap;
std::map<int, std::vector<QString> > m_groupIdToGridFileNamesMap;
std::map<int, QString> m_caseIdToPropertiesFolderMap;
};

View File

@ -46,6 +46,8 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/ModelVisualization/GridBox
${CMAKE_CURRENT_SOURCE_DIR}/ModelVisualization/Intersections
${CMAKE_CURRENT_SOURCE_DIR}/UserInterface
${CMAKE_CURRENT_SOURCE_DIR}/CommandFileInterface
${CMAKE_CURRENT_SOURCE_DIR}/CommandFileInterface/Core
${CMAKE_CURRENT_SOURCE_DIR}/ProjectDataModel
${CMAKE_CURRENT_SOURCE_DIR}/ProjectDataModel/Completions
@ -113,6 +115,7 @@ list( APPEND REFERENCED_CMAKE_FILES
Commands/CrossSectionCommands/CMakeLists_files.cmake
Commands/EclipseCommands/CMakeLists_files.cmake
Commands/EclipseCommands/EclipseWell/CMakeLists_files.cmake
Commands/ExportCommands/CMakeLists_files.cmake
Commands/FlowCommands/CMakeLists_files.cmake
Commands/IntersectionBoxCommands/CMakeLists_files.cmake
Commands/OctaveScriptCommands/CMakeLists_files.cmake
@ -122,6 +125,9 @@ list( APPEND REFERENCED_CMAKE_FILES
Commands/ViewLink/CMakeLists_files.cmake
Commands/WellLogCommands/CMakeLists_files.cmake
Commands/WellPathCommands/CMakeLists_files.cmake
CommandFileInterface/CMakeLists_files.cmake
CommandFileInterface/Core/CMakeLists_files.cmake
)
option (RESINSIGHT_INCLUDE_APPLICATION_UNIT_TESTS "Include ApplicationCode Unit Tests" OFF)

View File

@ -0,0 +1,50 @@
set (SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RicfCloseProject.h
${CMAKE_CURRENT_LIST_DIR}/RicfCommandFileExecutor.h
${CMAKE_CURRENT_LIST_DIR}/RicfComputeCaseGroupStatistics.h
${CMAKE_CURRENT_LIST_DIR}/RicfExportMsw.h
${CMAKE_CURRENT_LIST_DIR}/RicfExportMultiCaseSnapshots.h
${CMAKE_CURRENT_LIST_DIR}/RicfExportProperty.h
${CMAKE_CURRENT_LIST_DIR}/RicfExportSnapshots.h
${CMAKE_CURRENT_LIST_DIR}/RicfExportWellPathCompletions.h
${CMAKE_CURRENT_LIST_DIR}/RicfLoadCase.h
${CMAKE_CURRENT_LIST_DIR}/RicfOpenProject.h
${CMAKE_CURRENT_LIST_DIR}/RicfReplaceCase.h
${CMAKE_CURRENT_LIST_DIR}/RicfReplaceSourceCases.h
${CMAKE_CURRENT_LIST_DIR}/RicfRunOctaveScript.h
${CMAKE_CURRENT_LIST_DIR}/RicfSetExportFolder.h
${CMAKE_CURRENT_LIST_DIR}/RicfSetMainWindowSize.h
${CMAKE_CURRENT_LIST_DIR}/RicfSetStartDir.h
${CMAKE_CURRENT_LIST_DIR}/RicfSetTimeStep.h
)
set (SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RicfCloseProject.cpp
${CMAKE_CURRENT_LIST_DIR}/RicfCommandFileExecutor.cpp
${CMAKE_CURRENT_LIST_DIR}/RicfComputeCaseGroupStatistics.cpp
${CMAKE_CURRENT_LIST_DIR}/RicfExportMsw.cpp
${CMAKE_CURRENT_LIST_DIR}/RicfExportMultiCaseSnapshots.cpp
${CMAKE_CURRENT_LIST_DIR}/RicfExportProperty.cpp
${CMAKE_CURRENT_LIST_DIR}/RicfExportSnapshots.cpp
${CMAKE_CURRENT_LIST_DIR}/RicfExportWellPathCompletions.cpp
${CMAKE_CURRENT_LIST_DIR}/RicfLoadCase.cpp
${CMAKE_CURRENT_LIST_DIR}/RicfOpenProject.cpp
${CMAKE_CURRENT_LIST_DIR}/RicfReplaceCase.cpp
${CMAKE_CURRENT_LIST_DIR}/RicfReplaceSourceCases.cpp
${CMAKE_CURRENT_LIST_DIR}/RicfRunOctaveScript.cpp
${CMAKE_CURRENT_LIST_DIR}/RicfSetExportFolder.cpp
${CMAKE_CURRENT_LIST_DIR}/RicfSetMainWindowSize.cpp
${CMAKE_CURRENT_LIST_DIR}/RicfSetStartDir.cpp
${CMAKE_CURRENT_LIST_DIR}/RicfSetTimeStep.cpp
)
list(APPEND CODE_HEADER_FILES
${SOURCE_GROUP_HEADER_FILES}
)
list(APPEND CODE_SOURCE_FILES
${SOURCE_GROUP_SOURCE_FILES}
)
source_group( "CommandFileInterface" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake )

View File

@ -0,0 +1,28 @@
set (SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RicfCommandObject.h
${CMAKE_CURRENT_LIST_DIR}/RicfFieldCapability.h
${CMAKE_CURRENT_LIST_DIR}/RicfFieldHandle.h
${CMAKE_CURRENT_LIST_DIR}/RicfObjectCapability.h
${CMAKE_CURRENT_LIST_DIR}/RifcCommandFileReader.h
${CMAKE_CURRENT_LIST_DIR}/RicfMessages.h
)
set (SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RicfCommandObject.cpp
${CMAKE_CURRENT_LIST_DIR}/RicfFieldCapability.cpp
${CMAKE_CURRENT_LIST_DIR}/RicfFieldHandle.cpp
${CMAKE_CURRENT_LIST_DIR}/RicfObjectCapability.cpp
${CMAKE_CURRENT_LIST_DIR}/RifcCommandFileReader.cpp
${CMAKE_CURRENT_LIST_DIR}/RicfMessages.cpp
)
list(APPEND CODE_HEADER_FILES
${SOURCE_GROUP_HEADER_FILES}
)
list(APPEND CODE_SOURCE_FILES
${SOURCE_GROUP_SOURCE_FILES}
)
source_group( "CommandFileInterface\\Core" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake )

View File

@ -0,0 +1,37 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicfCommandObject.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicfCommandObject::RicfCommandObject(): RicfObjectCapability(this, false)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicfCommandObject::~RicfCommandObject()
{
}

View File

@ -0,0 +1,43 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmObject.h"
#include "RicfObjectCapability.h"
#include "RicfFieldCapability.h"
#define RICF_InitField(field, keyword, default, uiName, iconResourceName, toolTip, whatsThis) \
CAF_PDM_InitField(field, keyword, default, uiName, iconResourceName, toolTip, whatsThis); \
AddRicfCapabilityToField(field)
//==================================================================================================
//
//
//
//==================================================================================================
class RicfCommandObject : public caf::PdmObject, public RicfObjectCapability
{
public:
RicfCommandObject();
~RicfCommandObject();
virtual void execute() = 0;
};

View File

@ -0,0 +1,88 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicfFieldCapability.h"
#include "RicfMessages.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicfFieldReader<QString>::readFieldData(QString& fieldValue, QTextStream& inputStream, RicfMessages* errorMessageContainer)
{
fieldValue = "";
errorMessageContainer->skipWhiteSpaceWithLineNumberCount(inputStream);
QString accumulatedFieldValue;
QChar currentChar;
currentChar = errorMessageContainer->readCharWithLineNumberCount(inputStream);
if ( currentChar == QChar('"') )
{
while ( !inputStream.atEnd() )
{
currentChar = errorMessageContainer->readCharWithLineNumberCount(inputStream);
if ( currentChar != QChar('\\') )
{
if ( currentChar == QChar('"') ) // End Quote
{
// Reached end of string
break;
}
else
{
accumulatedFieldValue += currentChar;
}
}
else
{
currentChar = errorMessageContainer->readCharWithLineNumberCount(inputStream);
accumulatedFieldValue += currentChar;
}
}
}
else
{
// Unexpected start of string, Missing '"'
// Error message
errorMessageContainer->addError("String argument does not seem to be quoted. Missing the start '\"' in the \""
+ errorMessageContainer->currentArgument + "\" argument of the command: \""
+ errorMessageContainer->currentCommand + "\"" );
// Could interpret as unquoted text
}
fieldValue = accumulatedFieldValue;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicfFieldWriter<QString>::writeFieldData(const QString& fieldValue, QTextStream& outputStream)
{
outputStream << "\"";
for ( int i = 0; i < fieldValue.size(); ++i )
{
if ( fieldValue[i] == QChar('"') || fieldValue[i] == QChar('\\') )
{
outputStream << "\\";
}
outputStream << fieldValue[i];
}
outputStream << "\"";
}

View File

@ -0,0 +1,207 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RicfFieldHandle.h"
#include "RicfMessages.h"
#include "cafAppEnum.h"
#include <QTextStream>
#include <QString>
template <typename DataType>
struct RicfFieldReader
{
static void readFieldData(DataType & fieldValue, QTextStream& inputStream, RicfMessages* errorMessageContainer)
{
inputStream >> fieldValue;
if (inputStream.status() == QTextStream::ReadCorruptData)
{
errorMessageContainer->addError("Argument value is unreadable in the argument: \""
+ errorMessageContainer->currentArgument + "\" in the command: \""
+ errorMessageContainer->currentCommand + "\"" );
inputStream.setStatus( QTextStream::Ok);
}
}
};
template <typename DataType>
struct RicfFieldWriter
{
static void writeFieldData(const DataType & fieldValue, QTextStream& outputStream)
{
outputStream << fieldValue;
}
};
template <>
struct RicfFieldReader<QString>
{
static void readFieldData(QString & fieldValue, QTextStream& inputStream, RicfMessages* errorMessageContainer);
};
template <>
struct RicfFieldWriter<QString>
{
static void writeFieldData(const QString & fieldValue, QTextStream& outputStream);
};
template <typename T>
struct RicfFieldReader< caf::AppEnum<T> >
{
static void readFieldData(caf::AppEnum<T>& fieldValue, QTextStream& inputStream, RicfMessages* errorMessageContainer)
{
errorMessageContainer->skipWhiteSpaceWithLineNumberCount(inputStream);
QString accumulatedFieldValue;
QChar nextChar;
QChar currentChar;
while (!inputStream.atEnd())
{
nextChar = errorMessageContainer->peekNextChar(inputStream);
if (nextChar.isLetterOrNumber() || nextChar == QChar('_'))
{
currentChar = errorMessageContainer->readCharWithLineNumberCount(inputStream);
accumulatedFieldValue += currentChar;
}
else
{
break;
}
}
if (!fieldValue.setFromText(accumulatedFieldValue))
{
// Unexpected enum value
// Error message
errorMessageContainer->addError("Argument must be valid enum value. "
+ errorMessageContainer->currentArgument + "\" argument of the command: \""
+ errorMessageContainer->currentCommand + "\"");
}
}
};
template <typename T>
struct RicfFieldWriter< caf::AppEnum<T> >
{
static void writeFieldData(const caf::AppEnum<T>& fieldValue, QTextStream& outputStream)
{
outputStream << fieldValue;
}
};
template <typename T>
struct RicfFieldReader< std::vector<T> >
{
static void readFieldData(std::vector<T>& fieldValue, QTextStream& inputStream, RicfMessages* errorMessageContainer)
{
errorMessageContainer->skipWhiteSpaceWithLineNumberCount(inputStream);
QChar chr = errorMessageContainer->readCharWithLineNumberCount(inputStream);
if (chr == QChar('[')) {
while (!inputStream.atEnd())
{
errorMessageContainer->skipWhiteSpaceWithLineNumberCount(inputStream);
QChar nextChar = errorMessageContainer->peekNextChar(inputStream);
if (nextChar == QChar(']'))
{
nextChar = errorMessageContainer->readCharWithLineNumberCount(inputStream);
break;
}
else if (nextChar == QChar(','))
{
nextChar = errorMessageContainer->readCharWithLineNumberCount(inputStream);
errorMessageContainer->skipWhiteSpaceWithLineNumberCount(inputStream);
}
T value;
RicfFieldReader<T>::readFieldData(value, inputStream, errorMessageContainer);
fieldValue.push_back(value);
}
}
else {
errorMessageContainer->addError("Array argument is missing start '['. "
+ errorMessageContainer->currentArgument + "\" argument of the command: \""
+ errorMessageContainer->currentCommand + "\"" );
}
}
};
template <typename T>
struct RicfFieldWriter< std::vector<T> >
{
static void writeFieldData(const std::vector<T>& fieldValue, QTextStream& outputStream)
{
outputStream << "[";
for (size_t i = 0; i < fieldValue.size(); ++i)
{
RicfFieldWriter<T>::writeFieldData(fieldValue[i], outputStream);
if (i < fieldValue.size() - 1)
{
outputStream << ", ";
}
}
outputStream << "]";
}
};
//==================================================================================================
//
//
//
//==================================================================================================
template < typename FieldType>
class RicfFieldCapability : public RicfFieldHandle
{
public:
RicfFieldCapability(FieldType* field, bool giveOwnership) : RicfFieldHandle(field, giveOwnership) { m_field = field; }
// Xml Serializing
public:
virtual void readFieldData (QTextStream& inputStream, caf::PdmObjectFactory* objectFactory, RicfMessages* errorMessageContainer) override
{
//m_field->xmlCapability()->assertValid();
typename FieldType::FieldDataType value;
RicfFieldReader<typename FieldType::FieldDataType>::readFieldData(value, inputStream, errorMessageContainer);
m_field->setValue(value);
}
virtual void writeFieldData(QTextStream& outputStream) const override
{
//m_field->xmlCapability()->assertValid();
RicfFieldWriter<typename FieldType::FieldDataType>::writeFieldData(m_field->value(), outputStream);
}
private:
FieldType* m_field;
};
template<typename FieldType>
void AddRicfCapabilityToField(FieldType* field)
{
if(field->template capability< RicfFieldCapability<FieldType> >() == NULL)
{
new RicfFieldCapability<FieldType>(field, true);
}
}

View File

@ -0,0 +1,39 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicfFieldHandle.h"
#include "cafPdmFieldHandle.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicfFieldHandle::RicfFieldHandle(caf::PdmFieldHandle* owner, bool giveOwnership)
{
m_owner = owner;
owner->addCapability(this, giveOwnership);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicfFieldHandle::~RicfFieldHandle()
{
}

View File

@ -0,0 +1,55 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmFieldCapability.h"
namespace caf
{
class PdmObjectFactory;
class PdmFieldHandle;
}
class RicfMessages;
class QTextStream;
//==================================================================================================
//
//
//
//==================================================================================================
class RicfFieldHandle : public caf::PdmFieldCapability
{
public:
RicfFieldHandle(caf::PdmFieldHandle* owner , bool giveOwnership);
virtual ~RicfFieldHandle();
virtual void readFieldData (QTextStream& inputStream,
caf::PdmObjectFactory* objectFactory,
RicfMessages* errorMessageContainer ) = 0;
virtual void writeFieldData(QTextStream& outputStream) const = 0;
private:
caf::PdmFieldHandle* m_owner;
};

View File

@ -0,0 +1,81 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicfMessages.h"
#include <QTextStream>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicfMessages::addWarning(const QString& message)
{
m_messages.push_back(std::make_pair(MESSAGE_WARNING, "Line " + QString::number(m_currentLineNumber) +": " + message));
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicfMessages::addError(const QString& message)
{
m_messages.push_back(std::make_pair(MESSAGE_ERROR, "Line " + QString::number(m_currentLineNumber) +": " + message));
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicfMessages::skipWhiteSpaceWithLineNumberCount(QTextStream& inputStream)
{
while ( !inputStream.atEnd() )
{
QChar ch = readCharWithLineNumberCount(inputStream);
if ( !ch.isSpace() )
{
inputStream.seek(inputStream.pos()-1);
break;
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QChar RicfMessages::readCharWithLineNumberCount(QTextStream& inputStream)
{
QChar ch;
inputStream >> ch;
if ( ch == QChar('\n') )
{
m_currentLineNumber++;
}
return ch;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QChar RicfMessages::peekNextChar(QTextStream& inputStream)
{
QChar ch;
if (!inputStream.atEnd())
{
inputStream >> ch;
inputStream.seek(inputStream.pos() - 1);
}
return ch;
}

View File

@ -0,0 +1,51 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <vector>
#include <QString>
class QTextStream;
class RicfMessages
{
public:
RicfMessages() : m_currentLineNumber(1) {}
enum MessageType
{
MESSAGE_WARNING,
MESSAGE_ERROR
};
void addWarning(const QString& message);
void addError(const QString& message);
void skipWhiteSpaceWithLineNumberCount(QTextStream& inputStream);
QChar readCharWithLineNumberCount(QTextStream& inputStream);
QChar peekNextChar(QTextStream& inputStream);
QString currentCommand;
QString currentArgument;
std::vector<std::pair<MessageType, QString> > m_messages;
private:
int m_currentLineNumber;
};

View File

@ -0,0 +1,200 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicfObjectCapability.h"
#include "cafPdmObjectHandle.h"
#include <QTextStream>
#include "RicfFieldHandle.h"
#include "cafPdmXmlFieldHandle.h"
#include "RicfMessages.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicfObjectCapability::RicfObjectCapability(caf::PdmObjectHandle* owner, bool giveOwnership)
{
m_owner = owner;
m_owner->addCapability(this, giveOwnership);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicfObjectCapability::~RicfObjectCapability()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicfObjectCapability::readFields(QTextStream& inputStream,
caf::PdmObjectFactory* objectFactory,
RicfMessages* errorMessageContainer)
{
std::set<QString> readFields;
bool isLastArgumentRead = false;
while ( !inputStream.atEnd() && !isLastArgumentRead )
{
// Read field keyword
bool fieldDataFound = true;
bool isEndOfArgumentFound = false;
QString keyword;
{
errorMessageContainer->skipWhiteSpaceWithLineNumberCount(inputStream);
while ( !inputStream.atEnd() )
{
QChar currentChar;
currentChar = errorMessageContainer->readCharWithLineNumberCount(inputStream);
if ( currentChar.isSpace() )
{
// Must skip to, and read "="
errorMessageContainer->skipWhiteSpaceWithLineNumberCount(inputStream);
currentChar = errorMessageContainer->readCharWithLineNumberCount(inputStream);
if ( currentChar != QChar('=') )
{
// Error message: Missing "=" after argument name
errorMessageContainer->addError("Can't find the '=' after the argument named: \"" + keyword + "\" in the command: \"" + errorMessageContainer->currentCommand + "\"" );
fieldDataFound = false;
if (currentChar == QChar(')') )
{
isLastArgumentRead = true;
}
else if (currentChar == QChar(',') )
{
isEndOfArgumentFound = true;
}
}
break;
}
if ( currentChar == QChar('=') )
{
break;
}
keyword += currentChar;
}
if ( readFields.count(keyword) )
{
// Warning message: Referenced the same argument several times
errorMessageContainer->addWarning("The argument: \"" + keyword + "\" is referenced several times in the command: \"" + errorMessageContainer->currentCommand + "\"" );
}
}
if (fieldDataFound)
{
// Make field read its data
caf::PdmFieldHandle* fieldHandle = m_owner->findField(keyword);
if ( fieldHandle && fieldHandle->xmlCapability() && fieldHandle->capability<RicfFieldHandle>() )
{
caf::PdmXmlFieldHandle* xmlFieldHandle = fieldHandle->xmlCapability();
RicfFieldHandle* rcfField = fieldHandle->capability<RicfFieldHandle>();
if ( xmlFieldHandle->isIOReadable() )
{
errorMessageContainer->currentArgument = keyword;
rcfField->readFieldData(inputStream, objectFactory, errorMessageContainer);
errorMessageContainer->currentArgument = keyword;
}
}
else
{
// Error message: Unknown argument name
errorMessageContainer->addWarning("The argument: \"" + keyword + "\" does not exist in the command: \"" + errorMessageContainer->currentCommand + "\"");
}
}
// Skip to end of argument ',' or end of call ')'
if (!(isLastArgumentRead || isEndOfArgumentFound) )
{
QChar currentChar;
bool isOutsideQuotes = true;
while ( !inputStream.atEnd() )
{
currentChar = errorMessageContainer->readCharWithLineNumberCount(inputStream);
if ( isOutsideQuotes )
{
if ( currentChar == QChar(',') )
{
break;
}
if ( currentChar == QChar(')') )
{
isLastArgumentRead = true;
break;
}
if ( currentChar == QChar('\"') )
{
isOutsideQuotes = false;
}
}
else
{
if ( currentChar == QChar('\"') )
{
isOutsideQuotes = true;
}
if ( currentChar == QChar('\\') )
{
currentChar = errorMessageContainer->readCharWithLineNumberCount(inputStream);
}
}
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicfObjectCapability::writeFields(QTextStream& outputStream) const
{
std::vector<caf::PdmFieldHandle*> fields;
m_owner->fields(fields);
int writtenFieldCount = 0;
for ( size_t it = 0; it < fields.size(); ++it )
{
const caf::PdmXmlFieldHandle* xmlField = fields[it]->xmlCapability();
const RicfFieldHandle* rcfField = fields[it]->capability<RicfFieldHandle>();
if ( rcfField && xmlField && xmlField->isIOWritable() )
{
QString keyword = xmlField->fieldHandle()->keyword();
CAF_ASSERT(caf::PdmXmlObjectHandle::isValidXmlElementName(keyword));
if ( writtenFieldCount >= 1 )
{
outputStream << ", ";
++writtenFieldCount;
}
outputStream << keyword << " = ";
rcfField->writeFieldData(outputStream);
}
}
}

View File

@ -0,0 +1,51 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmObjectCapability.h"
namespace caf
{
class PdmObjectHandle;
class PdmObjectFactory;
}
class QTextStream;
class RicfMessages;
//==================================================================================================
//
//
//
//==================================================================================================
class RicfObjectCapability : public caf::PdmObjectCapability
{
public:
RicfObjectCapability(caf::PdmObjectHandle* owner, bool giveOwnership);
virtual ~RicfObjectCapability();
void readFields(QTextStream& inputStream, caf::PdmObjectFactory* objectFactory, RicfMessages* errorMessageContainer);
void writeFields(QTextStream& outputStream) const;
private:
caf::PdmObjectHandle* m_owner;
};

View File

@ -0,0 +1,137 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RifcCommandFileReader.h"
#include "RicfCommandObject.h"
#include "RicfObjectCapability.h"
#include "RicfMessages.h"
#include "cafPdmObjectFactory.h"
#include <QTextStream>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RicfCommandObject*> RicfCommandFileReader::readCommands(QTextStream& inputStream,
caf::PdmObjectFactory* objectFactory,
RicfMessages* errorMessageContainer)
{
std::vector<RicfCommandObject*> readCommands;
while ( !inputStream.atEnd() )
{
errorMessageContainer->skipWhiteSpaceWithLineNumberCount(inputStream);
// Read command name
QString commandName;
bool foundStartBracet = false;
{
errorMessageContainer->skipWhiteSpaceWithLineNumberCount(inputStream);
while ( !inputStream.atEnd() )
{
QChar currentChar;
currentChar = errorMessageContainer->readCharWithLineNumberCount(inputStream);
if ( currentChar.isSpace() )
{
errorMessageContainer->skipWhiteSpaceWithLineNumberCount(inputStream);
QChar isBracket('a');
isBracket = errorMessageContainer->readCharWithLineNumberCount(inputStream);
if ( isBracket != QChar('(') )
{
// Error, could not find start bracket for command
errorMessageContainer->addError("Could not find start bracket for command " + commandName);
return readCommands;
}
break;
}
else if ( currentChar == QChar('(') )
{
break;
}
commandName += currentChar;
}
}
if (commandName.isEmpty() && inputStream.atEnd())
{
// Read past the last command
break;
}
CAF_ASSERT(objectFactory);
caf::PdmObjectHandle* obj = objectFactory->create(commandName);
RicfCommandObject* cObj = dynamic_cast<RicfCommandObject*>(obj);
if ( cObj == nullptr )
{
errorMessageContainer->addError("The command: \"" + commandName + "\" does not exist.");
// Error: Unknown command
// Skip to end of command
QChar currentChar;
bool isOutsideQuotes = true;
while ( !inputStream.atEnd() )
{
currentChar = errorMessageContainer->readCharWithLineNumberCount(inputStream);
if ( isOutsideQuotes )
{
if ( currentChar == QChar(')') )
{
break;
}
if ( currentChar == QChar('\"') )
{
isOutsideQuotes = false;
}
}
else
{
if ( currentChar == QChar('\"') )
{
isOutsideQuotes = true;
}
if ( currentChar == QChar('\\') )
{
currentChar = errorMessageContainer->readCharWithLineNumberCount(inputStream);
}
}
}
}
else
{
readCommands.push_back(cObj);
auto rcfCap = cObj->capability<RicfObjectCapability>();
errorMessageContainer->currentCommand = commandName;
rcfCap->readFields(inputStream, objectFactory, errorMessageContainer);
errorMessageContainer->currentCommand = "";
}
}
return readCommands;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicfCommandFileReader::writeCommands(QTextStream& outputStream, const std::vector<RicfCommandObject*>& commandsToWrite)
{
}

View File

@ -0,0 +1,47 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
class RicfCommandObject;
class QTextStream;
#include <vector>
namespace caf
{
class PdmObjectFactory;
}
class RicfMessages;
//==================================================================================================
//
//
//
//==================================================================================================
class RicfCommandFileReader
{
public:
static std::vector<RicfCommandObject*> readCommands(QTextStream& inputStream,
caf::PdmObjectFactory* objectFactory,
RicfMessages* errorMessageContainer);
static void writeCommands(QTextStream& outputStream,
const std::vector<RicfCommandObject*>& commandsToWrite);
};

View File

@ -0,0 +1,38 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicfCloseProject.h"
#include "RiaApplication.h"
CAF_PDM_SOURCE_INIT(RicfCloseProject, "closeProject");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicfCloseProject::RicfCloseProject()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicfCloseProject::execute()
{
RiaApplication::instance()->closeProject();
}

View File

@ -0,0 +1,40 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RicfCommandObject.h"
#include "cafPdmField.h"
//==================================================================================================
//
//
//
//==================================================================================================
class RicfCloseProject : public RicfCommandObject
{
CAF_PDM_HEADER_INIT;
public:
RicfCloseProject();
virtual void execute() override;
private:
};

View File

@ -0,0 +1,121 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicfCommandFileExecutor.h"
#include "RifcCommandFileReader.h"
#include "RicfCommandObject.h"
#include "RiaLogging.h"
namespace caf {
template<>
void RicfCommandFileExecutor::ExportTypeEnum::setUp()
{
addItem(RicfCommandFileExecutor::COMPLETIONS, "COMPLETIONS", "Completions");
addItem(RicfCommandFileExecutor::PROPERTIES, "PROPERTIES", "Properties");
addItem(RicfCommandFileExecutor::SNAPSHOTS, "SNAPSHOTS", "Snapshots");
addItem(RicfCommandFileExecutor::STATISTICS, "STATISTICS", "Statistics");
setDefault(RicfCommandFileExecutor::COMPLETIONS);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicfCommandFileExecutor::RicfCommandFileExecutor()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicfCommandFileExecutor::~RicfCommandFileExecutor()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicfCommandFileExecutor::executeCommands(QTextStream& stream)
{
std::vector<RicfCommandObject*> commands = RicfCommandFileReader::readCommands(stream, caf::PdmDefaultObjectFactory::instance(), &m_messages);
for (auto message : m_messages.m_messages)
{
if (message.first == RicfMessages::MESSAGE_WARNING)
{
RiaLogging::warning(QString("Command file parsing warning: %1").arg(message.second));
}
else
{
RiaLogging::error(QString("Command file parsing error: %1").arg(message.second));
return;
}
}
for (RicfCommandObject* command : commands)
{
command->execute();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicfCommandFileExecutor::setExportPath(ExportType type, QString path)
{
m_exportPaths[type] = path;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicfCommandFileExecutor::getExportPath(ExportType type) const
{
auto it = m_exportPaths.find(type);
QString path;
if (it != m_exportPaths.end())
{
path = it->second;
}
return path;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicfCommandFileExecutor::setLastProjectPath(const QString& path)
{
m_lastProjectPath = path;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicfCommandFileExecutor::getLastProjectPath() const
{
return m_lastProjectPath;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicfCommandFileExecutor* RicfCommandFileExecutor::instance()
{
static RicfCommandFileExecutor* commandFileExecutorInstance = new RicfCommandFileExecutor();
return commandFileExecutorInstance;
}

View File

@ -0,0 +1,61 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RicfMessages.h"
#include "cafAppEnum.h"
#include <map>
//==================================================================================================
//
//
//
//==================================================================================================
class RicfCommandFileExecutor
{
public:
enum ExportType {
COMPLETIONS,
SNAPSHOTS,
PROPERTIES,
STATISTICS
};
typedef caf::AppEnum<ExportType> ExportTypeEnum;
public:
RicfCommandFileExecutor();
~RicfCommandFileExecutor();
void executeCommands(QTextStream& stream);
void setExportPath(ExportType type, QString path);
QString getExportPath(ExportType type) const;
void setLastProjectPath(const QString& path);
QString getLastProjectPath() const;
static RicfCommandFileExecutor* instance();
private:
RicfMessages m_messages;
std::map<ExportType, QString> m_exportPaths;
QString m_lastProjectPath;
};

View File

@ -0,0 +1,79 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicfComputeCaseGroupStatistics.h"
#include "RimProject.h"
#include "RimOilField.h"
#include "RimEclipseCaseCollection.h"
#include "RimEclipseCase.h"
#include "RimEclipseStatisticsCase.h"
#include "RimIdenticalGridCaseGroup.h"
#include "RimCaseCollection.h"
#include "RimView.h"
#include "RiaApplication.h"
#include "RiaLogging.h"
CAF_PDM_SOURCE_INIT(RicfComputeCaseGroupStatistics, "computeCaseGroupStatistics");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicfComputeCaseGroupStatistics::RicfComputeCaseGroupStatistics()
{
RICF_InitField(&m_caseIds, "cases", std::vector<int>(), "Case IDs", "", "", "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicfComputeCaseGroupStatistics::execute()
{
for (int caseId : m_caseIds())
{
bool foundCase = false;
for (RimIdenticalGridCaseGroup* group : RiaApplication::instance()->project()->activeOilField()->analysisModels()->caseGroups)
{
for (RimEclipseCase* c : group->statisticsCaseCollection->reservoirs)
{
if (c->caseId == caseId)
{
RimEclipseStatisticsCase* statsCase = dynamic_cast<RimEclipseStatisticsCase*>(c);
if (statsCase)
{
statsCase->computeStatisticsAndUpdateViews();
}
else
{
RiaLogging::warning(QString("computeCaseGroupStatistics: Found case with ID %1, but it is not a statistics case, cannot compute statistics.").arg(caseId));
}
foundCase = true;
break;
}
}
if (foundCase) break;
}
if (!foundCase)
{
RiaLogging::warning(QString("computeCaseGroupStatistics: Could not find statistics case with ID %1.").arg(caseId));
}
}
}

View File

@ -0,0 +1,41 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RicfCommandObject.h"
#include "cafPdmField.h"
//==================================================================================================
//
//
//
//==================================================================================================
class RicfComputeCaseGroupStatistics : public RicfCommandObject
{
CAF_PDM_HEADER_INIT;
public:
RicfComputeCaseGroupStatistics();
virtual void execute() override;
private:
caf::PdmField< std::vector<int> > m_caseIds;
};

View File

@ -0,0 +1,96 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicfExportMsw.h"
#include "RicfCommandFileExecutor.h"
#include "RiaApplication.h"
#include "RiaLogging.h"
#include "RimProject.h"
#include "RimOilField.h"
#include "RimWellPathCollection.h"
#include "RimWellPath.h"
#include "RimEclipseCaseCollection.h"
#include "RimEclipseCase.h"
#include "RimFishbonesCollection.h"
#include "RimFishbonesMultipleSubs.h"
#include "CompletionCommands/RicExportFishbonesWellSegmentsFeature.h"
CAF_PDM_SOURCE_INIT(RicfExportMsw, "exportMsw");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicfExportMsw::RicfExportMsw()
{
RICF_InitField(&m_caseId, "case", -1, "Case", "", "", "");
RICF_InitField(&m_wellPathName, "wellPath", QString(), "Case", "", "", "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicfExportMsw::execute()
{
RicCaseAndFileExportSettingsUi exportSettings;
{
bool foundCase = false;
for (RimEclipseCase* c : RiaApplication::instance()->project()->activeOilField()->analysisModels->cases())
{
if (c->caseId() == m_caseId())
{
exportSettings.caseToApply = c;
foundCase = true;
break;
}
}
if (!foundCase)
{
RiaLogging::error(QString("exportMsw: Could not find case with ID %1.").arg(m_caseId()));
return;
}
}
QString exportFolder = RicfCommandFileExecutor::instance()->getExportPath(RicfCommandFileExecutor::COMPLETIONS);
if (exportFolder.isNull())
{
exportFolder = RiaApplication::instance()->createAbsolutePathFromProjectRelativePath("completions");
}
exportSettings.folder = exportFolder;
RimWellPath* wellPath = RiaApplication::instance()->project()->activeOilField()->wellPathCollection->wellPathByName(m_wellPathName);
if (!wellPath)
{
RiaLogging::error(QString("exportMsw: Could not find well path with name %1").arg(m_wellPathName()));
return;
}
std::vector<RimFishbonesMultipleSubs*> fishbonesSubs;
for (RimFishbonesMultipleSubs* fishbones : wellPath->fishbonesCollection()->fishbonesSubs())
{
fishbonesSubs.push_back(fishbones);
}
RicExportFishbonesWellSegmentsFeature::exportWellSegments(wellPath, fishbonesSubs, exportSettings);
}

View File

@ -0,0 +1,42 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RicfCommandObject.h"
#include "cafPdmField.h"
//==================================================================================================
//
//
//
//==================================================================================================
class RicfExportMsw : public RicfCommandObject
{
CAF_PDM_HEADER_INIT;
public:
RicfExportMsw();
virtual void execute() override;
private:
caf::PdmField<int> m_caseId;
caf::PdmField<QString> m_wellPathName;
};

View File

@ -0,0 +1,57 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicfExportMultiCaseSnapshots.h"
#include "RicfCommandFileExecutor.h"
#include "RiaApplication.h"
#include "RiaLogging.h"
#include "RiaProjectModifier.h"
CAF_PDM_SOURCE_INIT(RicfExportMultiCaseSnapshots, "exportMultiCaseSnapshots");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicfExportMultiCaseSnapshots::RicfExportMultiCaseSnapshots()
{
RICF_InitField(&m_gridListFile, "gridListFile", QString(), "Grid List File", "", "", "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicfExportMultiCaseSnapshots::execute()
{
if (m_gridListFile().isNull())
{
RiaLogging::error("exportMultiCaseSnapshots: Required parameter gridListFile.");
return;
}
QString lastProjectPath = RicfCommandFileExecutor::instance()->getLastProjectPath();
if (lastProjectPath.isNull())
{
RiaLogging::error("exportMultiCaseSnapshots: 'openProject' must be called before 'exportMultiCaseSnapshots' to specify project file to replace cases in.");
return;
}
std::vector<QString> listFileNames = RiaApplication::readFileListFromTextFile(m_gridListFile());
RiaApplication::instance()->runMultiCaseSnapshots(lastProjectPath, listFileNames, RicfCommandFileExecutor::instance()->getExportPath(RicfCommandFileExecutor::SNAPSHOTS));
}

View File

@ -0,0 +1,41 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RicfCommandObject.h"
#include "cafPdmField.h"
//==================================================================================================
//
//
//
//==================================================================================================
class RicfExportMultiCaseSnapshots : public RicfCommandObject
{
CAF_PDM_HEADER_INIT;
public:
RicfExportMultiCaseSnapshots();
virtual void execute() override;
private:
caf::PdmField<QString> m_gridListFile;
};

View File

@ -0,0 +1,106 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicfExportProperty.h"
#include "RicfCommandFileExecutor.h"
#include "RiaApplication.h"
#include "RiaLogging.h"
#include "RimProject.h"
#include "RimOilField.h"
#include "RimEclipseCaseCollection.h"
#include "RimEclipseCase.h"
#include "RimEclipseView.h"
#include "RimEclipseCellColors.h"
#include "RifEclipseInputFileTools.h"
#include <QDir>
CAF_PDM_SOURCE_INIT(RicfExportProperty, "exportProperty");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicfExportProperty::RicfExportProperty()
{
RICF_InitField(&m_caseId, "case", -1, "Case", "", "", "");
RICF_InitField(&m_timeStepIndex, "timeStep", -1, "Time Step Index", "", "", "");
RICF_InitField(&m_propertyName, "property", QString(), "Property Name", "", "", "");
RICF_InitField(&m_eclipseKeyword, "eclipseKeyword", QString(), "Eclipse Keyword", "", "", "");
RICF_InitField(&m_undefinedValue, "undefinedValue", 0.0, "Undefined Value", "", "", "");
RICF_InitField(&m_path, "exportFile", QString(), "Export File", "", "", "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicfExportProperty::execute()
{
QString fileName = m_path;
if (fileName.isNull())
{
QDir propertiesDir(RicfCommandFileExecutor::instance()->getExportPath(RicfCommandFileExecutor::PROPERTIES));
fileName = propertiesDir.filePath(m_propertyName);
}
RimEclipseCase* eclipseCase;
{
bool foundCase = false;
for (RimEclipseCase* c : RiaApplication::instance()->project()->activeOilField()->analysisModels()->cases)
{
if (c->caseId == m_caseId)
{
eclipseCase = c;
foundCase = true;
break;
}
}
if (!foundCase)
{
RiaLogging::error(QString("exportProperty: Could not find case with ID %1").arg(m_caseId()));
return;
}
}
// FIXME : Select correct view?
RimEclipseView* view;
for (RimView* v : eclipseCase->views())
{
view = dynamic_cast<RimEclipseView*>(v);
if (view) break;
}
if (!view)
{
RiaLogging::error(QString("exportProperty: Could not find a view for case with ID %1").arg(m_caseId()));
return;
}
if (m_eclipseKeyword().isNull())
{
m_eclipseKeyword = m_propertyName;
}
view->cellResult->setResultVariable(m_propertyName);
view->loadDataAndUpdate();
RifEclipseInputFileTools::writeBinaryResultToTextFile(fileName, eclipseCase->eclipseCaseData(), m_timeStepIndex, view->cellResult, m_eclipseKeyword, m_undefinedValue);
}

View File

@ -0,0 +1,46 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RicfCommandObject.h"
#include "cafPdmField.h"
//==================================================================================================
//
//
//
//==================================================================================================
class RicfExportProperty : public RicfCommandObject
{
CAF_PDM_HEADER_INIT;
public:
RicfExportProperty();
virtual void execute() override;
private:
caf::PdmField<int> m_caseId;
caf::PdmField<int> m_timeStepIndex;
caf::PdmField<QString> m_propertyName;
caf::PdmField<QString> m_eclipseKeyword;
caf::PdmField<double> m_undefinedValue;
caf::PdmField<QString> m_path;
};

View File

@ -0,0 +1,76 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicfExportSnapshots.h"
#include "RicfCommandFileExecutor.h"
#include "ExportCommands/RicSnapshotViewToClipboardFeature.h"
#include "RiaApplication.h"
#include "RiuMainWindow.h"
#include <QFileInfo>
CAF_PDM_SOURCE_INIT(RicfExportSnapshots, "exportSnapshots");
namespace caf {
template<>
void RicfExportSnapshots::SnapshotsTypeEnum::setUp()
{
addItem(RicfExportSnapshots::ALL, "ALL", "All");
addItem(RicfExportSnapshots::VIEWS, "VIEWS", "Views");
addItem(RicfExportSnapshots::PLOTS, "PLOTS", "Plots");
setDefault(RicfExportSnapshots::ALL);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicfExportSnapshots::RicfExportSnapshots()
{
RICF_InitField(&m_type, "type", RicfExportSnapshots::SnapshotsTypeEnum(), "Type", "", "", "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicfExportSnapshots::execute()
{
RiuMainWindow* mainWnd = RiuMainWindow::instance();
CVF_ASSERT(mainWnd);
mainWnd->hideAllDockWindows();
QString absolutePathToSnapshotDir = RicfCommandFileExecutor::instance()->getExportPath(RicfCommandFileExecutor::SNAPSHOTS);
if (absolutePathToSnapshotDir.isNull())
{
absolutePathToSnapshotDir = RiaApplication::instance()->createAbsolutePathFromProjectRelativePath("snapshots");
}
if (m_type == RicfExportSnapshots::VIEWS || m_type == RicfExportSnapshots::ALL)
{
RiaApplication::instance()->saveSnapshotForAllViews(absolutePathToSnapshotDir);
}
if (m_type == RicfExportSnapshots::PLOTS || m_type == RicfExportSnapshots::ALL)
{
RicSnapshotAllPlotsToFileFeature::exportSnapshotOfAllPlotsIntoFolder(absolutePathToSnapshotDir);
}
mainWnd->loadWinGeoAndDockToolBarLayout();
}

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- Statoil ASA
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@ -18,36 +18,34 @@
#pragma once
#include "RicCaseAndFileExportSettingsUi.h"
#include "RicfCommandObject.h"
#include "cafAppEnum.h"
#include "cafPdmField.h"
//==================================================================================================
///
///
//
//
//
//==================================================================================================
class RicExportWellSegmentsSettingsUi : public RicCaseAndFileExportSettingsUi
class RicfExportSnapshots : public RicfCommandObject
{
CAF_PDM_HEADER_INIT;
public:
enum PressureDropType {
HYDROSTATIC,
HYDROSTATIC_FRICTION,
HYDROSTATIC_FRICTION_ACCELERATION
enum SnapshotsType
{
VIEWS,
PLOTS,
ALL
};
typedef caf::AppEnum<SnapshotsType> SnapshotsTypeEnum;
typedef caf::AppEnum<RicExportWellSegmentsSettingsUi::PressureDropType> PressureDropEnum;
public:
RicfExportSnapshots();
enum LengthAndDepthType {
ABS,
INC
};
virtual void execute() override;
typedef caf::AppEnum<RicExportWellSegmentsSettingsUi::LengthAndDepthType> LengthAndDepthEnum;
RicExportWellSegmentsSettingsUi();
caf::PdmField<PressureDropEnum> pressureDrop;
caf::PdmField<LengthAndDepthEnum> lengthAndDepth;
};
private:
caf::PdmField<SnapshotsTypeEnum> m_type;
};

View File

@ -0,0 +1,114 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicfExportWellPathCompletions.h"
#include "RicfCommandFileExecutor.h"
#include "RiaApplication.h"
#include "RiaLogging.h"
#include "RimProject.h"
#include "RimOilField.h"
#include "RimEclipseCaseCollection.h"
#include "RimEclipseCase.h"
#include "RimWellPathCollection.h"
#include "RimWellPath.h"
#include "CompletionCommands/RicWellPathExportCompletionDataFeature.h"
CAF_PDM_SOURCE_INIT(RicfExportWellPathCompletions, "exportWellPathCompletions");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicfExportWellPathCompletions::RicfExportWellPathCompletions()
{
RICF_InitField(&m_caseId, "case", -1, "Case ID", "", "", "");
RICF_InitField(&m_timeStep, "timeStep", -1, "Time Step Index", "", "", "");
RICF_InitField(&m_wellPathNames, "wellPathNames", std::vector<QString>(), "Well Path Names", "", "", "");
RICF_InitField(&m_wellSelection, "wellSelection", RicExportCompletionDataSettingsUi::WellSelectionType(), "Well Selection", "", "", "");
RICF_InitField(&m_fileSplit, "fileSplit", RicExportCompletionDataSettingsUi::ExportSplitType(), "File Split", "", "", "");
RICF_InitField(&m_compdatExport, "compdatExport", RicExportCompletionDataSettingsUi::CompdatExportType(), "Compdat Export", "", "", "");
RICF_InitField(&m_includePerforations, "includePerforations", true, "Include Perforations", "", "", "");
RICF_InitField(&m_includeFishbones, "includeFishbones", true, "Include Fishbones", "", "", "");
RICF_InitField(&m_excludeMainBoreForFishbones, "excludeMainBoreForFishbones", false, "Exclude Main Bore for Fishbones", "", "", "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicfExportWellPathCompletions::execute()
{
RicExportCompletionDataSettingsUi exportSettings(false);
exportSettings.timeStep = m_timeStep;
exportSettings.wellSelection = m_wellSelection;
exportSettings.fileSplit = m_fileSplit;
exportSettings.compdatExport = m_compdatExport;
exportSettings.includePerforations = m_includePerforations;
exportSettings.includeFishbones = m_includeFishbones;
exportSettings.excludeMainBoreForFishbones = m_excludeMainBoreForFishbones;
{
bool foundCase = false;
for (RimEclipseCase* c : RiaApplication::instance()->project()->activeOilField()->analysisModels->cases())
{
if (c->caseId() == m_caseId())
{
exportSettings.caseToApply = c;
foundCase = true;
break;
}
}
if (!foundCase)
{
RiaLogging::error(QString("exportWellPathCompletions: Could not find case with ID %1").arg(m_caseId()));
return;
}
}
QString exportFolder = RicfCommandFileExecutor::instance()->getExportPath(RicfCommandFileExecutor::COMPLETIONS);
if (exportFolder.isNull())
{
exportFolder = RiaApplication::instance()->createAbsolutePathFromProjectRelativePath("completions");
}
exportSettings.folder = exportFolder;
std::vector<RimWellPath*> wellPaths;
if (m_wellPathNames().empty())
{
std::copy(RiaApplication::instance()->project()->activeOilField()->wellPathCollection->wellPaths().begin(),
RiaApplication::instance()->project()->activeOilField()->wellPathCollection->wellPaths().end(),
std::back_inserter(wellPaths));
}
else
{
for (const QString& wellPathName : m_wellPathNames())
{
RimWellPath* wellPath = RiaApplication::instance()->project()->activeOilField()->wellPathCollection->wellPathByName(wellPathName);
if (wellPath)
{
wellPaths.push_back(wellPath);
}
}
}
std::vector<RimEclipseWell*> simWells;
RicWellPathExportCompletionDataFeature::exportCompletions(wellPaths, simWells, exportSettings);
}

View File

@ -0,0 +1,53 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RicfCommandObject.h"
#include "CompletionCommands/RicExportCompletionDataSettingsUi.h"
#include "cafAppEnum.h"
#include "cafPdmField.h"
//==================================================================================================
//
//
//
//==================================================================================================
class RicfExportWellPathCompletions : public RicfCommandObject
{
CAF_PDM_HEADER_INIT;
public:
RicfExportWellPathCompletions();
virtual void execute() override;
private:
caf::PdmField<int> m_caseId;
caf::PdmField<int> m_timeStep;
caf::PdmField< std::vector<QString> > m_wellPathNames;
caf::PdmField<RicExportCompletionDataSettingsUi::WellSelectionType> m_wellSelection;
caf::PdmField<RicExportCompletionDataSettingsUi::ExportSplitType> m_fileSplit;
caf::PdmField<RicExportCompletionDataSettingsUi::CompdatExportType> m_compdatExport;
caf::PdmField<bool> m_includePerforations;
caf::PdmField<bool> m_includeFishbones;
caf::PdmField<bool> m_excludeMainBoreForFishbones;
};

View File

@ -0,0 +1,44 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicfLoadCase.h"
#include "RiaApplication.h"
#include "RiaLogging.h"
CAF_PDM_SOURCE_INIT(RicfLoadCase, "loadCase");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicfLoadCase::RicfLoadCase()
{
RICF_InitField(&m_path, "path", QString(), "Path to Case File", "", "", "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicfLoadCase::execute()
{
bool ok = RiaApplication::instance()->openEclipseCaseFromFile(m_path);
if (!ok)
{
RiaLogging::error(QString("loadCase: Unable to load case from %1").arg(m_path()));
}
}

View File

@ -0,0 +1,41 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RicfCommandObject.h"
#include "cafPdmField.h"
//==================================================================================================
//
//
//
//==================================================================================================
class RicfLoadCase : public RicfCommandObject
{
CAF_PDM_HEADER_INIT;
public:
RicfLoadCase();
virtual void execute() override;
private:
caf::PdmField<QString> m_path;
};

View File

@ -0,0 +1,49 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicfOpenProject.h"
#include "RicfCommandFileExecutor.h"
#include "RiaApplication.h"
#include "RiaLogging.h"
CAF_PDM_SOURCE_INIT(RicfOpenProject, "openProject");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicfOpenProject::RicfOpenProject()
{
RICF_InitField(&m_path, "path", QString(), "Path", "", "", "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicfOpenProject::execute()
{
bool ok = RiaApplication::instance()->loadProject(m_path);
if (!ok)
{
RiaLogging::error(QString("openProject: Unable to open project at %1").arg(m_path()));
return;
}
RicfCommandFileExecutor::instance()->setLastProjectPath(m_path);
}

View File

@ -0,0 +1,41 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RicfCommandObject.h"
#include "cafPdmField.h"
//==================================================================================================
//
//
//
//==================================================================================================
class RicfOpenProject : public RicfCommandObject
{
CAF_PDM_HEADER_INIT;
public:
RicfOpenProject();
virtual void execute() override;
private:
caf::PdmField<QString> m_path;
};

View File

@ -0,0 +1,68 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicfReplaceCase.h"
#include "RicfCommandFileExecutor.h"
#include "RiaApplication.h"
#include "RiaLogging.h"
#include "RiaProjectModifier.h"
CAF_PDM_SOURCE_INIT(RicfReplaceCase, "replaceCase");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicfReplaceCase::RicfReplaceCase()
{
RICF_InitField(&m_caseId, "case", -1, "Case ID", "", "", "");
RICF_InitField(&m_newGridFile, "newGridFile", QString(), "New Grid File", "", "", "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicfReplaceCase::execute()
{
if (m_newGridFile().isNull())
{
RiaLogging::error("replaceCase: Required parameter newGridFile.");
return;
}
QString lastProjectPath = RicfCommandFileExecutor::instance()->getLastProjectPath();
if (lastProjectPath.isNull())
{
RiaLogging::error("replaceCase: 'openProject' must be called before 'replaceCase' to specify project file to replace case in.");
return;
}
cvf::ref<RiaProjectModifier> projectModifier = new RiaProjectModifier;
if (m_caseId() == -1)
{
projectModifier->setReplaceCaseFirstOccurrence(m_newGridFile());
}
else
{
projectModifier->setReplaceCase(m_caseId(), m_newGridFile());
}
RiaApplication::instance()->loadProject(lastProjectPath, RiaApplication::PLA_NONE, projectModifier.p());
}

View File

@ -0,0 +1,42 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RicfCommandObject.h"
#include "cafPdmField.h"
//==================================================================================================
//
//
//
//==================================================================================================
class RicfReplaceCase : public RicfCommandObject
{
CAF_PDM_HEADER_INIT;
public:
RicfReplaceCase();
virtual void execute() override;
private:
caf::PdmField<QString> m_newGridFile;
caf::PdmField<int> m_caseId;
};

View File

@ -0,0 +1,69 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicfReplaceSourceCases.h"
#include "RicfCommandFileExecutor.h"
#include "RiaApplication.h"
#include "RiaLogging.h"
#include "RiaProjectModifier.h"
CAF_PDM_SOURCE_INIT(RicfReplaceSourceCases, "replaceSourceCases");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicfReplaceSourceCases::RicfReplaceSourceCases()
{
RICF_InitField(&m_caseGroupId, "group", -1, "Group ID", "", "", "");
RICF_InitField(&m_gridListFile, "gridListFile", QString(), "Grid List File", "", "", "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicfReplaceSourceCases::execute()
{
if (m_gridListFile().isNull())
{
RiaLogging::error("replaceSourceCases: Required parameter gridListFile.");
return;
}
QString lastProjectPath = RicfCommandFileExecutor::instance()->getLastProjectPath();
if (lastProjectPath.isNull())
{
RiaLogging::error("replaceSourceCases: 'openProject' must be called before 'replaceSourceCases' to specify project file to replace cases in.");
return;
}
cvf::ref<RiaProjectModifier> projectModifier = new RiaProjectModifier;
std::vector<QString> listFileNames = RiaApplication::readFileListFromTextFile(m_gridListFile());
if (m_caseGroupId() == -1)
{
projectModifier->setReplaceSourceCasesFirstOccurrence(listFileNames);
}
else
{
projectModifier->setReplaceSourceCasesById(m_caseGroupId(), listFileNames);
}
RiaApplication::instance()->loadProject(lastProjectPath, RiaApplication::PLA_CALCULATE_STATISTICS, projectModifier.p());
}

View File

@ -0,0 +1,42 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RicfCommandObject.h"
#include "cafPdmField.h"
//==================================================================================================
//
//
//
//==================================================================================================
class RicfReplaceSourceCases : public RicfCommandObject
{
CAF_PDM_HEADER_INIT;
public:
RicfReplaceSourceCases();
virtual void execute() override;
private:
caf::PdmField<QString> m_gridListFile;
caf::PdmField<int> m_caseGroupId;
};

View File

@ -0,0 +1,67 @@
#include "RicfRunOctaveScript.h"
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicfRunOctaveScript.h"
#include "RiaApplication.h"
#include "RiaLogging.h"
#include <QFileInfo>
CAF_PDM_SOURCE_INIT(RicfRunOctaveScript, "runOctaveScript");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicfRunOctaveScript::RicfRunOctaveScript()
{
RICF_InitField(&m_path, "path", QString(), "Path", "", "", "");
RICF_InitField(&m_caseIds, "cases", std::vector<int>(), "Case IDs", "", "", "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicfRunOctaveScript::execute()
{
QString octavePath = RiaApplication::instance()->octavePath();
QFileInfo scriptFileInfo(m_path());
QStringList processArguments;
processArguments << "--path" << scriptFileInfo.absolutePath();
processArguments << scriptFileInfo.absoluteFilePath();
bool ok;
if (m_caseIds().empty())
{
ok = RiaApplication::instance()->launchProcess(octavePath, processArguments);
}
else
{
ok = RiaApplication::instance()->launchProcessForMultipleCases(octavePath, processArguments, m_caseIds());
}
if (!ok)
{
RiaLogging::error(QString("runOctaveScript: Could not execute script %1").arg(m_path()));
}
else
{
RiaApplication::instance()->waitForProcess();
}
}

View File

@ -0,0 +1,42 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RicfCommandObject.h"
#include "cafPdmField.h"
//==================================================================================================
//
//
//
//==================================================================================================
class RicfRunOctaveScript : public RicfCommandObject
{
CAF_PDM_HEADER_INIT;
public:
RicfRunOctaveScript();
virtual void execute() override;
private:
caf::PdmField<QString> m_path;
caf::PdmField< std::vector<int> > m_caseIds;
};

View File

@ -0,0 +1,42 @@
#include "RicfSetExportFolder.h"
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicfSetExportFolder.h"
#include "RiaApplication.h"
CAF_PDM_SOURCE_INIT(RicfSetExportFolder, "setExportFolder");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicfSetExportFolder::RicfSetExportFolder()
{
RICF_InitField(&m_type, "type", RicfCommandFileExecutor::ExportTypeEnum(RicfCommandFileExecutor::COMPLETIONS), "Type", "", "", "");
RICF_InitField(&m_path, "path", QString(), "Path", "", "", "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicfSetExportFolder::execute()
{
RicfCommandFileExecutor* executor = RicfCommandFileExecutor::instance();
executor->setExportPath(m_type(), m_path);
}

View File

@ -0,0 +1,44 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RicfCommandObject.h"
#include "RicfCommandFileExecutor.h"
#include "cafPdmField.h"
//==================================================================================================
//
//
//
//==================================================================================================
class RicfSetExportFolder : public RicfCommandObject
{
CAF_PDM_HEADER_INIT;
public:
RicfSetExportFolder();
virtual void execute() override;
private:
caf::PdmField<RicfCommandFileExecutor::ExportTypeEnum> m_type;
caf::PdmField<QString> m_path;
};

View File

@ -0,0 +1,41 @@
#include "RicfSetMainWindowSize.h"
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicfSetMainWindowSize.h"
#include "RiuMainWindow.h"
CAF_PDM_SOURCE_INIT(RicfSetMainWindowSize, "setMainWindowSize");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicfSetMainWindowSize::RicfSetMainWindowSize()
{
RICF_InitField(&m_height, "height", -1, "Height", "", "", "");
RICF_InitField(&m_width, "width", -1, "Width", "", "", "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicfSetMainWindowSize::execute()
{
RiuMainWindow::instance()->resize(m_width, m_height);
}

View File

@ -0,0 +1,42 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RicfCommandObject.h"
#include "cafPdmField.h"
//==================================================================================================
//
//
//
//==================================================================================================
class RicfSetMainWindowSize : public RicfCommandObject
{
CAF_PDM_HEADER_INIT;
public:
RicfSetMainWindowSize();
virtual void execute() override;
private:
caf::PdmField<int> m_height;
caf::PdmField<int> m_width;
};

View File

@ -0,0 +1,39 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicfSetStartDir.h"
#include "RiaApplication.h"
CAF_PDM_SOURCE_INIT(RicfSetStartDir, "setStartDir");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicfSetStartDir::RicfSetStartDir()
{
RICF_InitField(&m_path, "path", QString(), "Path", "", "", "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicfSetStartDir::execute()
{
RiaApplication::instance()->setStartDir(m_path);
}

View File

@ -0,0 +1,41 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RicfCommandObject.h"
#include "cafPdmField.h"
//==================================================================================================
//
//
//
//==================================================================================================
class RicfSetStartDir : public RicfCommandObject
{
CAF_PDM_HEADER_INIT;
public:
RicfSetStartDir();
virtual void execute() override;
private:
caf::PdmField<QString> m_path;
};

View File

@ -0,0 +1,70 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicfSetTimeStep.h"
#include "RimProject.h"
#include "RimOilField.h"
#include "RimEclipseCaseCollection.h"
#include "RimEclipseCase.h"
#include "RimView.h"
#include "RiaApplication.h"
#include "RiaLogging.h"
CAF_PDM_SOURCE_INIT(RicfSetTimeStep, "setTimeStep");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicfSetTimeStep::RicfSetTimeStep()
{
RICF_InitField(&m_caseId, "case", -1, "Case ID", "", "", "");
RICF_InitField(&m_timeStepIndex, "timeStep", -1, "Time Step Index", "", "", "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicfSetTimeStep::execute()
{
RimEclipseCase* eclipseCase;
{
bool foundCase = false;
for (RimEclipseCase* c : RiaApplication::instance()->project()->activeOilField()->analysisModels()->cases)
{
if (c->caseId == m_caseId)
{
eclipseCase = c;
foundCase = true;
break;
}
}
if (!foundCase)
{
RiaLogging::error(QString("setTimeStep: Could not find case with ID %1").arg(m_caseId()));
return;
}
}
for (RimView* view : eclipseCase->views())
{
view->setCurrentTimeStepAndUpdate(m_timeStepIndex);
}
}

View File

@ -0,0 +1,42 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RicfCommandObject.h"
#include "cafPdmField.h"
//==================================================================================================
//
//
//
//==================================================================================================
class RicfSetTimeStep : public RicfCommandObject
{
CAF_PDM_HEADER_INIT;
public:
RicfSetTimeStep();
virtual void execute() override;
private:
caf::PdmField<int> m_caseId;
caf::PdmField<int> m_timeStepIndex;
};

View File

@ -28,14 +28,9 @@ ${CEE_CURRENT_LIST_DIR}RicReloadFormationNamesFeature.h
${CEE_CURRENT_LIST_DIR}RicWellLogsImportFileFeature.h
${CEE_CURRENT_LIST_DIR}RicTogglePerspectiveViewFeature.h
${CEE_CURRENT_LIST_DIR}RicExportToLasFileFeature.h
${CEE_CURRENT_LIST_DIR}RicExportToLasFileResampleUi.h
${CEE_CURRENT_LIST_DIR}RicSnapshotViewToClipboardFeature.h
${CEE_CURRENT_LIST_DIR}RicImportGeoMechCaseFeature.h
${CEE_CURRENT_LIST_DIR}RicImportSummaryCaseFeature.h
${CEE_CURRENT_LIST_DIR}RicExportFaultsFeature.h
${CEE_CURRENT_LIST_DIR}RicExportMultipleSnapshotsFeature.h
${CEE_CURRENT_LIST_DIR}RicExportFeatureImpl.h
${CEE_CURRENT_LIST_DIR}RicNewSimWellFractureFeature.h
${CEE_CURRENT_LIST_DIR}RicNewSimWellFractureAtPosFeature.h
@ -88,14 +83,10 @@ ${CEE_CURRENT_LIST_DIR}RicImportFormationNamesFeature.cpp
${CEE_CURRENT_LIST_DIR}RicReloadFormationNamesFeature.cpp
${CEE_CURRENT_LIST_DIR}RicTogglePerspectiveViewFeature.cpp
${CEE_CURRENT_LIST_DIR}RicExportToLasFileFeature.cpp
${CEE_CURRENT_LIST_DIR}RicExportToLasFileResampleUi.cpp
${CEE_CURRENT_LIST_DIR}RicSnapshotViewToClipboardFeature.cpp
${CEE_CURRENT_LIST_DIR}RicImportGeoMechCaseFeature.cpp
${CEE_CURRENT_LIST_DIR}RicImportSummaryCaseFeature.cpp
${CEE_CURRENT_LIST_DIR}RicExportFeatureImpl.cpp
${CEE_CURRENT_LIST_DIR}RicExportFaultsFeature.cpp
${CEE_CURRENT_LIST_DIR}RicExportMultipleSnapshotsFeature.cpp
${CEE_CURRENT_LIST_DIR}RicNewSimWellFractureFeature.cpp
${CEE_CURRENT_LIST_DIR}RicNewSimWellFractureAtPosFeature.cpp

View File

@ -11,7 +11,6 @@ ${CEE_CURRENT_LIST_DIR}RicExportCompletionDataSettingsUi.h
${CEE_CURRENT_LIST_DIR}RicExportFishbonesLateralsFeature.h
${CEE_CURRENT_LIST_DIR}RicExportFishbonesWellSegmentsFeature.h
${CEE_CURRENT_LIST_DIR}RicExportFractureCompletionsImpl.h
${CEE_CURRENT_LIST_DIR}RicExportWellSegmentsSettingsUi.h
${CEE_CURRENT_LIST_DIR}RicNewFishbonesSubsAtMeasuredDepthFeature.h
${CEE_CURRENT_LIST_DIR}RicNewFishbonesSubsFeature.h
${CEE_CURRENT_LIST_DIR}RicNewPerforationIntervalFeature.h
@ -29,7 +28,6 @@ ${CEE_CURRENT_LIST_DIR}RicExportCompletionDataSettingsUi.cpp
${CEE_CURRENT_LIST_DIR}RicExportFishbonesLateralsFeature.cpp
${CEE_CURRENT_LIST_DIR}RicExportFishbonesWellSegmentsFeature.cpp
${CEE_CURRENT_LIST_DIR}RicExportFractureCompletionsImpl.cpp
${CEE_CURRENT_LIST_DIR}RicExportWellSegmentsSettingsUi.cpp
${CEE_CURRENT_LIST_DIR}RicNewFishbonesSubsAtMeasuredDepthFeature.cpp
${CEE_CURRENT_LIST_DIR}RicNewFishbonesSubsFeature.cpp
${CEE_CURRENT_LIST_DIR}RicNewPerforationIntervalFeature.cpp

View File

@ -53,7 +53,7 @@ void RicExportFishbonesLateralsFeature::onActionTriggered(bool isChecked)
QString defaultDir = app->lastUsedDialogDirectoryWithFallback("WELL_PATH_EXPORT_DIR", projectFolder);
QString defaultFileName = defaultDir + "/" + caf::Utils::makeValidFileBasename((wellPath->name())) + ".dev";
QString defaultFileName = defaultDir + "/" + caf::Utils::makeValidFileBasename((wellPath->name())) + "_laterals.dev";
QString completeFilename = QFileDialog::getSaveFileName(nullptr, "Select File for Well Path Data Export", defaultFileName, "Well Path Text File(*.dev);;All files(*.*)");
if (completeFilename.isEmpty()) return;

View File

@ -21,6 +21,8 @@
#include "RiaApplication.h"
#include "RiaLogging.h"
#include "RicExportFeatureImpl.h"
#include "RimProject.h"
#include "RimFishboneWellPathCollection.h"
#include "RimFishbonesCollection.h"
@ -61,7 +63,7 @@ void RicExportFishbonesWellSegmentsFeature::onActionTriggered(bool isChecked)
QString projectFolder = app->currentProjectPath();
QString defaultDir = RiaApplication::instance()->lastUsedDialogDirectoryWithFallback("COMPLETIONS", projectFolder);
RicExportWellSegmentsSettingsUi exportSettings;
RicCaseAndFileExportSettingsUi exportSettings;
std::vector<RimCase*> cases;
app->project()->allCases(cases);
for (auto c : cases)
@ -76,8 +78,9 @@ void RicExportFishbonesWellSegmentsFeature::onActionTriggered(bool isChecked)
exportSettings.folder = defaultDir;
//Bjørnar: skal denne være noe annet?
caf::PdmUiPropertyViewDialog propertyDialog(RiuMainWindow::instance(), &exportSettings, "Export Completion Data", "");
caf::PdmUiPropertyViewDialog propertyDialog(RiuMainWindow::instance(), &exportSettings, "Export Well Segments", "");
RicExportFeatureImpl::configureForExport(&propertyDialog);
if (propertyDialog.exec() == QDialog::Accepted)
{
RiaApplication::instance()->setLastUsedDialogDirectory("COMPLETIONS", QFileInfo(exportSettings.folder).absolutePath());
@ -152,7 +155,7 @@ bool RicExportFishbonesWellSegmentsFeature::isCommandEnabled()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportFishbonesWellSegmentsFeature::exportWellSegments(const RimWellPath* wellPath, const std::vector<RimFishbonesMultipleSubs*>& fishbonesSubs, const RicExportWellSegmentsSettingsUi& settings)
void RicExportFishbonesWellSegmentsFeature::exportWellSegments(const RimWellPath* wellPath, const std::vector<RimFishbonesMultipleSubs*>& fishbonesSubs, const RicCaseAndFileExportSettingsUi& settings)
{
QString filePath = QDir(settings.folder()).filePath("Welsegs");
QFile exportFile(filePath);
@ -183,7 +186,7 @@ void RicExportFishbonesWellSegmentsFeature::exportWellSegments(const RimWellPath
//--------------------------------------------------------------------------------------------------
void RicExportFishbonesWellSegmentsFeature::generateWelsegsTable(RifEclipseDataTableFormatter& formatter,
const RimWellPath* wellPath,
const RicExportWellSegmentsSettingsUi& settings,
const RicCaseAndFileExportSettingsUi& settings,
const std::vector<WellSegmentLocation>& locations)
{
RiaEclipseUnitTools::UnitSystem unitSystem = settings.caseToApply->eclipseCaseData()->unitsType();
@ -208,8 +211,8 @@ void RicExportFishbonesWellSegmentsFeature::generateWelsegsTable(RifEclipseDataT
formatter.add(startTVD);
formatter.add(startMD);
formatter.add("1*");
formatter.add(settings.lengthAndDepth().text());
formatter.add(settings.pressureDrop().text());
formatter.add(wellPath->fishbonesCollection()->lengthAndDepth().text());
formatter.add(wellPath->fishbonesCollection()->pressureDrop().text());
formatter.rowCompleted();
}
@ -238,7 +241,7 @@ void RicExportFishbonesWellSegmentsFeature::generateWelsegsTable(RifEclipseDataT
for (const WellSegmentLocation& location : locations)
{
if (settings.lengthAndDepth() == RicExportWellSegmentsSettingsUi::INC)
if (wellPath->fishbonesCollection()->lengthAndDepth() == RimFishbonesCollection::INC)
{
depth = location.trueVerticalDepth - previousTVD;
length = location.fishbonesSubs->measuredDepth(location.subIndex) - previousMD;
@ -248,9 +251,6 @@ void RicExportFishbonesWellSegmentsFeature::generateWelsegsTable(RifEclipseDataT
depth += location.trueVerticalDepth - previousTVD;
length += location.fishbonesSubs->measuredDepth(location.subIndex) - previousMD;
}
double diameter = computeEffectiveDiameter(wellPath->fishbonesCollection()->linerDiameter(unitSystem),
wellPath->fishbonesCollection()->mainBoreDiameter(unitSystem));
formatter.comment(QString("Segment for sub %1").arg(location.subIndex));
formatter.add(location.segmentNumber).add(location.segmentNumber);
@ -258,7 +258,7 @@ void RicExportFishbonesWellSegmentsFeature::generateWelsegsTable(RifEclipseDataT
formatter.add(location.segmentNumber - 1); // All main stem segments are connected to the segment below them
formatter.add(length);
formatter.add(depth);
formatter.add(diameter);
formatter.add(wellPath->fishbonesCollection()->linerDiameter(unitSystem));
formatter.add(wellPath->fishbonesCollection()->roughnessFactor(unitSystem));
formatter.rowCompleted();
@ -273,15 +273,13 @@ void RicExportFishbonesWellSegmentsFeature::generateWelsegsTable(RifEclipseDataT
formatter.comment("Rough: MSW - Open Hole Roughness Factor");
for (const WellSegmentLocation& location : locations)
{
double diameter = computeEffectiveDiameter(wellPath->fishbonesCollection()->linerDiameter(unitSystem),
wellPath->fishbonesCollection()->mainBoreDiameter(unitSystem));
formatter.comment("ICD");
formatter.add(location.icdSegmentNumber).add(location.icdSegmentNumber);
formatter.add(location.icdBranchNumber);
formatter.add(location.segmentNumber);
formatter.add(0.1); // ICDs have 0.1 length
formatter.add(0); // Depth change
formatter.add(diameter);
formatter.add(wellPath->fishbonesCollection()->linerDiameter(unitSystem));
formatter.add(wellPath->fishbonesCollection()->roughnessFactor(unitSystem));
formatter.rowCompleted();
@ -294,7 +292,7 @@ void RicExportFishbonesWellSegmentsFeature::generateWelsegsTable(RifEclipseDataT
for (const WellSegmentLateralIntersection& intersection : lateral.intersections)
{
if (settings.lengthAndDepth() == RicExportWellSegmentsSettingsUi::INC)
if (wellPath->fishbonesCollection()->lengthAndDepth() == RimFishbonesCollection::INC)
{
depth = intersection.depth;
length = intersection.length;
@ -327,7 +325,7 @@ void RicExportFishbonesWellSegmentsFeature::generateWelsegsTable(RifEclipseDataT
//--------------------------------------------------------------------------------------------------
void RicExportFishbonesWellSegmentsFeature::generateCompsegsTable(RifEclipseDataTableFormatter& formatter,
const RimWellPath* wellPath,
const RicExportWellSegmentsSettingsUi& settings,
const RicCaseAndFileExportSettingsUi& settings,
const std::vector<WellSegmentLocation>& locations)
{
RigMainGrid* grid = settings.caseToApply->eclipseCaseData()->mainGrid();
@ -385,7 +383,7 @@ void RicExportFishbonesWellSegmentsFeature::generateCompsegsTable(RifEclipseData
//--------------------------------------------------------------------------------------------------
void RicExportFishbonesWellSegmentsFeature::generateWsegvalvTable(RifEclipseDataTableFormatter& formatter,
const RimWellPath* wellPath,
const RicExportWellSegmentsSettingsUi& settings,
const RicCaseAndFileExportSettingsUi& settings,
const std::vector<WellSegmentLocation>& locations)
{
RiaEclipseUnitTools::UnitSystem unitSystem = settings.caseToApply->eclipseCaseData()->unitsType();

View File

@ -20,7 +20,7 @@
#include "RifEclipseDataTableFormatter.h"
#include "RicExportWellSegmentsSettingsUi.h"
#include "RicCaseAndFileExportSettingsUi.h"
#include "RicWellPathExportCompletionDataFeature.h"
@ -42,14 +42,16 @@ protected:
virtual void setupActionLook(QAction* actionToSetup) override;
virtual bool isCommandEnabled() override;
public:
static void exportWellSegments(const RimWellPath* wellPath, const std::vector<RimFishbonesMultipleSubs*>& fishbonesSubs, const RicCaseAndFileExportSettingsUi& settings);
private:
static RimFishbonesCollection* selectedFishbonesCollection();
static RimWellPath* selectedWellPath();
static void exportWellSegments(const RimWellPath* wellPath, const std::vector<RimFishbonesMultipleSubs*>& fishbonesSubs, const RicExportWellSegmentsSettingsUi& settings);
static void generateWelsegsTable(RifEclipseDataTableFormatter& formatter, const RimWellPath* wellPath, const RicExportWellSegmentsSettingsUi& settings, const std::vector<WellSegmentLocation>& locations);
static void generateCompsegsTable(RifEclipseDataTableFormatter& formatter, const RimWellPath* wellPath, const RicExportWellSegmentsSettingsUi& settings, const std::vector<WellSegmentLocation>& locations);
static void generateWsegvalvTable(RifEclipseDataTableFormatter& formatter, const RimWellPath* wellPath, const RicExportWellSegmentsSettingsUi& settings, const std::vector<WellSegmentLocation>& locations);
static void generateWelsegsTable(RifEclipseDataTableFormatter& formatter, const RimWellPath* wellPath, const RicCaseAndFileExportSettingsUi& settings, const std::vector<WellSegmentLocation>& locations);
static void generateCompsegsTable(RifEclipseDataTableFormatter& formatter, const RimWellPath* wellPath, const RicCaseAndFileExportSettingsUi& settings, const std::vector<WellSegmentLocation>& locations);
static void generateWsegvalvTable(RifEclipseDataTableFormatter& formatter, const RimWellPath* wellPath, const RicCaseAndFileExportSettingsUi& settings, const std::vector<WellSegmentLocation>& locations);
static double computeEffectiveDiameter(double innerDiameter, double outerDiameter);
};

View File

@ -1,51 +0,0 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicExportWellSegmentsSettingsUi.h"
namespace caf {
template<>
void RicExportWellSegmentsSettingsUi::PressureDropEnum::setUp()
{
addItem(RicExportWellSegmentsSettingsUi::HYDROSTATIC, "H--", "Hydrostatic");
addItem(RicExportWellSegmentsSettingsUi::HYDROSTATIC_FRICTION, "HF-", "Hydrostatic + Friction");
addItem(RicExportWellSegmentsSettingsUi::HYDROSTATIC_FRICTION_ACCELERATION, "HFA", "Hydrostatic + Friction + Acceleration");
setDefault(RicExportWellSegmentsSettingsUi::HYDROSTATIC);
}
template<>
void RicExportWellSegmentsSettingsUi::LengthAndDepthEnum::setUp()
{
addItem(RicExportWellSegmentsSettingsUi::INC, "INC", "Incremental");
addItem(RicExportWellSegmentsSettingsUi::ABS, "ABS", "Absolute");
setDefault(RicExportWellSegmentsSettingsUi::INC);
}
}
CAF_PDM_SOURCE_INIT(RicExportWellSegmentsSettingsUi, "RicExportWellSegmentsSettingsUi");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicExportWellSegmentsSettingsUi::RicExportWellSegmentsSettingsUi()
{
CAF_PDM_InitObject("RimExportWellSegmentsSettings", "", "", "");
CAF_PDM_InitFieldNoDefault(&pressureDrop, "PressureDrop", "Pressure Drop", "", "", "");
CAF_PDM_InitFieldNoDefault(&lengthAndDepth, "LengthAndDepth", "Length and Depth", "", "", "");
}

View File

@ -216,8 +216,7 @@ void RicFishbonesTransmissibilityCalculationFeatureImp::findMainWellBoreParts(st
for (auto& cell : intersectedCellsIntersectionInfo)
{
//TODO: should skinFactor be taken from well group instead???
double skinFactor = wellPath->fishbonesCollection()->wellPathCollection()->skinFactor();
double skinFactor = wellPath->fishbonesCollection()->mainBoreSkinFactor();
QString completionMetaData = wellPath->name() + " main bore";
WellBorePartForTransCalc wellBorePart = WellBorePartForTransCalc(cell.internalCellLengths,
holeDiameter / 2,

View File

@ -21,43 +21,45 @@
#include "RiaApplication.h"
#include "RiaLogging.h"
#include "RimProject.h"
#include "RimWellPath.h"
#include "RimWellPathCollection.h"
#include "RimFishbonesMultipleSubs.h"
#include "RimFishbonesCollection.h"
#include "RicExportCompletionDataSettingsUi.h"
#include "RicExportFeatureImpl.h"
#include "RicFishbonesTransmissibilityCalculationFeatureImp.h"
#include "RicExportFractureCompletionsImpl.h"
#include "RigActiveCellInfo.h"
#include "RigEclipseCaseData.h"
#include "RigMainGrid.h"
#include "RigResultAccessorFactory.h"
#include "RigTransmissibilityEquations.h"
#include "RigWellLogExtractionTools.h"
#include "RigWellPath.h"
#include "RigWellPathIntersectionTools.h"
#include "RimFishboneWellPath.h"
#include "RimFishboneWellPathCollection.h"
#include "RimPerforationInterval.h"
#include "RimFishbonesCollection.h"
#include "RimFishbonesMultipleSubs.h"
#include "RimPerforationCollection.h"
#include "RimPerforationInterval.h"
#include "RimProject.h"
#include "RimReservoirCellResultsStorage.h"
#include "RimEclipseWell.h"
#include "RimEclipseWellCollection.h"
#include "RimWellPath.h"
#include "RimWellPathCollection.h"
#include "RimWellPathCompletions.h"
#include "RicExportCompletionDataSettingsUi.h"
#include "RiuMainWindow.h"
#include "RigWellLogExtractionTools.h"
#include "RigWellPathIntersectionTools.h"
#include "RigEclipseCaseData.h"
#include "RigMainGrid.h"
#include "RigWellPath.h"
#include "RigResultAccessorFactory.h"
#include "RigTransmissibilityEquations.h"
#include "cafSelectionManager.h"
#include "cafPdmUiPropertyViewDialog.h"
#include "cafSelectionManager.h"
#include "cvfPlane.h"
#include <QAction>
#include <QDir>
#include <QFileDialog>
#include <QMessageBox>
#include "RicFishbonesTransmissibilityCalculationFeatureImp.h"
#include "RicExportFractureCompletionsImpl.h"
#include "RigActiveCellInfo.h"
CAF_CMD_SOURCE_INIT(RicWellPathExportCompletionDataFeature, "RicWellPathExportCompletionDataFeature");
@ -135,6 +137,8 @@ void RicWellPathExportCompletionDataFeature::onActionTriggered(bool isChecked)
exportSettings.folder = defaultDir;
caf::PdmUiPropertyViewDialog propertyDialog(RiuMainWindow::instance(), &exportSettings, "Export Completion Data", "");
RicExportFeatureImpl::configureForExport(&propertyDialog);
if (propertyDialog.exec() == QDialog::Accepted)
{
RiaApplication::instance()->setLastUsedDialogDirectory("COMPLETIONS", exportSettings.folder);
@ -464,13 +468,22 @@ RigCompletionData RicWellPathExportCompletionDataFeature::combineEclipseCellComp
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicWellPathExportCompletionDataFeature::printCompletionsToFile(const QString& exportFolder, const QString& fileName, std::vector<RigCompletionData>& completions, RicExportCompletionDataSettingsUi::CompdatExportType exportType)
void RicWellPathExportCompletionDataFeature::printCompletionsToFile(const QString& folderName, const QString& fileName, std::vector<RigCompletionData>& completions, RicExportCompletionDataSettingsUi::CompdatExportType exportType)
{
//TODO: Check that completion is ready for export
QString filePath = QDir(exportFolder).filePath(fileName);
QDir exportFolder = QDir(folderName);
if (!exportFolder.exists())
{
bool createdPath = exportFolder.mkpath(folderName);
if (createdPath) RiaLogging::info("Created export folder " + folderName);
else RiaLogging::error("Selected output folder does not exist, and could not be created.");
}
QString filePath = exportFolder.filePath(fileName);
QFile exportFile(filePath);
if (!exportFile.open(QIODevice::WriteOnly))
if (!exportFile.open(QIODevice::WriteOnly))
{
RiaLogging::error(QString("Export Completions Data: Could not open the file: %1").arg(filePath));
return;

View File

@ -153,11 +153,11 @@ public:
double wellRadius,
size_t cellIndex,
CellDirection direction);
static void exportCompletions(const std::vector<RimWellPath*>& wellPaths, const std::vector<RimEclipseWell*>& simWells, const RicExportCompletionDataSettingsUi& exportSettings);
private:
static RigCompletionData combineEclipseCellCompletions(const std::vector<RigCompletionData>& completions,
const RicExportCompletionDataSettingsUi& settings);
static void exportCompletions(const std::vector<RimWellPath*>& wellPaths, const std::vector<RimEclipseWell*>& simWells, const RicExportCompletionDataSettingsUi& exportSettings);
static void printCompletionsToFile(const QString& exportFolder, const QString& fileName, std::vector<RigCompletionData>& completions, RicExportCompletionDataSettingsUi::CompdatExportType exportType);
static std::vector<RigCompletionData> getCompletionsForWellAndCompletionType(const std::vector<RigCompletionData>& completions, const QString& wellName, RigCompletionData::CompletionType completionType);

View File

@ -18,9 +18,6 @@ ${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterNewFeature.h
${CEE_CURRENT_LIST_DIR}RicImportEclipseCaseFeature.h
${CEE_CURRENT_LIST_DIR}RicImportInputEclipseCaseFeature.h
${CEE_CURRENT_LIST_DIR}RicNewStatisticsCaseFeature.h
${CEE_CURRENT_LIST_DIR}RicSaveEclipseInputPropertyFeature.h
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.h
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyFeature.h
${CEE_CURRENT_LIST_DIR}RicApplyPropertyFilterAsCellResultFeature.h
)
@ -38,9 +35,6 @@ ${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterNewFeature.cpp
${CEE_CURRENT_LIST_DIR}RicImportEclipseCaseFeature.cpp
${CEE_CURRENT_LIST_DIR}RicImportInputEclipseCaseFeature.cpp
${CEE_CURRENT_LIST_DIR}RicNewStatisticsCaseFeature.cpp
${CEE_CURRENT_LIST_DIR}RicSaveEclipseInputPropertyFeature.cpp
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.cpp
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyFeature.cpp
${CEE_CURRENT_LIST_DIR}RicApplyPropertyFilterAsCellResultFeature.cpp
)

View File

@ -0,0 +1,43 @@
# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly
if (${CMAKE_VERSION} VERSION_GREATER "2.8.2")
set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/)
endif()
set (SOURCE_GROUP_HEADER_FILES
${CEE_CURRENT_LIST_DIR}RicExportCarfin.h
${CEE_CURRENT_LIST_DIR}RicExportCarfinUi.h
${CEE_CURRENT_LIST_DIR}RicExportToLasFileFeature.h
${CEE_CURRENT_LIST_DIR}RicExportToLasFileResampleUi.h
${CEE_CURRENT_LIST_DIR}RicSnapshotViewToClipboardFeature.h
${CEE_CURRENT_LIST_DIR}RicExportFaultsFeature.h
${CEE_CURRENT_LIST_DIR}RicExportMultipleSnapshotsFeature.h
${CEE_CURRENT_LIST_DIR}RicSaveEclipseInputPropertyFeature.h
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.h
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyFeature.h
${CEE_CURRENT_LIST_DIR}RicCellRangeUi.h
)
set (SOURCE_GROUP_SOURCE_FILES
${CEE_CURRENT_LIST_DIR}RicExportCarfin.cpp
${CEE_CURRENT_LIST_DIR}RicExportCarfinUi.cpp
${CEE_CURRENT_LIST_DIR}RicExportToLasFileFeature.cpp
${CEE_CURRENT_LIST_DIR}RicExportToLasFileResampleUi.cpp
${CEE_CURRENT_LIST_DIR}RicSnapshotViewToClipboardFeature.cpp
${CEE_CURRENT_LIST_DIR}RicExportFaultsFeature.cpp
${CEE_CURRENT_LIST_DIR}RicExportMultipleSnapshotsFeature.cpp
${CEE_CURRENT_LIST_DIR}RicSaveEclipseInputPropertyFeature.cpp
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.cpp
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyFeature.cpp
${CEE_CURRENT_LIST_DIR}RicCellRangeUi.cpp
)
list(APPEND CODE_HEADER_FILES
${SOURCE_GROUP_HEADER_FILES}
)
list(APPEND CODE_SOURCE_FILES
${SOURCE_GROUP_SOURCE_FILES}
)
source_group( "CommandFeature\\Export" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake )

View File

@ -0,0 +1,327 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicCellRangeUi.h"
#include "RicExportCarfinUi.h"
#include "RifReaderInterface.h"
#include "RigActiveCellInfo.h"
#include "RigEclipseCaseData.h"
#include "RigReservoirGridTools.h"
#include "RimCase.h"
#include "RimEclipseCase.h"
#include "cafPdmUiSliderEditor.h"
#include "cvfStructGrid.h"
CAF_PDM_SOURCE_INIT(RicCellRangeUi, "RicCellRangeUi");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicCellRangeUi::RicCellRangeUi()
{
CAF_PDM_InitObject("Cell Range", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_case, "Case", "Case", "", "", "");
m_case.uiCapability()->setUiHidden(true);
CAF_PDM_InitField(&m_gridIndex, "GridIndex", 0, "Grid", "", "", "");
CAF_PDM_InitField(&m_startIndexI, "StartIndexI", 1, "Start index I", "", "", "");
CAF_PDM_InitField(&m_startIndexJ, "StartIndexJ", 1, "Start index J", "", "", "");
CAF_PDM_InitField(&m_startIndexK, "StartIndexK", 1, "Start index K", "", "", "");
CAF_PDM_InitField(&m_cellCountI, "CellCountI", 1, "Cell Count I", "", "", "");
CAF_PDM_InitField(&m_cellCountJ, "CellCountJ", 1, "Cell Count J", "", "", "");
CAF_PDM_InitField(&m_cellCountK, "CellCountK", 1, "Cell Count K", "", "", "");
m_startIndexI.uiCapability()->setUiEditorTypeName(caf::PdmUiSliderEditor::uiEditorTypeName());
m_startIndexJ.uiCapability()->setUiEditorTypeName(caf::PdmUiSliderEditor::uiEditorTypeName());
m_startIndexK.uiCapability()->setUiEditorTypeName(caf::PdmUiSliderEditor::uiEditorTypeName());
m_cellCountI.uiCapability()->setUiEditorTypeName( caf::PdmUiSliderEditor::uiEditorTypeName());
m_cellCountJ.uiCapability()->setUiEditorTypeName( caf::PdmUiSliderEditor::uiEditorTypeName());
m_cellCountK.uiCapability()->setUiEditorTypeName( caf::PdmUiSliderEditor::uiEditorTypeName());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicCellRangeUi::setCase(RimCase* rimCase)
{
if (m_case != rimCase)
{
m_case = rimCase;
setDefaultValues();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::VecIjk RicCellRangeUi::start() const
{
return caf::VecIjk{m_startIndexI, m_startIndexJ, m_startIndexK};
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::VecIjk RicCellRangeUi::count() const
{
return caf::VecIjk{ m_cellCountI, m_cellCountJ, m_cellCountK };
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicCellRangeUi::gridName() const
{
if (m_gridIndex() == 0) return "";
return RigReservoirGridTools::gridName(m_case, m_gridIndex());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicCellRangeUi::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute)
{
caf::PdmUiSliderEditorAttribute* myAttr = dynamic_cast<caf::PdmUiSliderEditorAttribute*>(attribute);
if (!myAttr)
{
return;
}
const cvf::StructGridInterface* grid = RigReservoirGridTools::gridByIndex(m_case, m_gridIndex());
if (grid)
{
if (field == &m_startIndexI || field == &m_cellCountI)
{
myAttr->m_minimum = 1;
myAttr->m_maximum = static_cast<int>(grid->cellCountI());
}
else if (field == &m_startIndexJ || field == &m_cellCountJ)
{
myAttr->m_minimum = 1;
myAttr->m_maximum = static_cast<int>(grid->cellCountJ());
}
else if (field == &m_startIndexK || field == &m_cellCountK)
{
myAttr->m_minimum = 1;
myAttr->m_maximum = static_cast<int>(grid->cellCountK());
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RicCellRangeUi::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly)
{
QList<caf::PdmOptionItemInfo> options;
if (useOptionsOnly) (*useOptionsOnly) = true;
if (&m_gridIndex == fieldNeedingOptions)
{
for (int gIdx = 0; gIdx < RigReservoirGridTools::gridCount(m_case); ++gIdx)
{
QString gridName;
gridName += RigReservoirGridTools::gridName(m_case, gIdx);
if (gIdx == 0)
{
if (gridName.isEmpty())
gridName += "Main Grid";
else
gridName += " (Main Grid)";
}
caf::PdmOptionItemInfo item(gridName, (int)gIdx);
options.push_back(item);
}
}
return options;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicCellRangeUi::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
clampValues();
if (changedField == &m_gridIndex)
{
setDefaultValues();
updateLegendText();
}
// If this object is contained in another object, make sure the other object is updated
RicExportCarfinUi* exportCarfin = nullptr;
this->firstAncestorOrThisOfType(exportCarfin);
if (exportCarfin)
{
exportCarfin->uiCapability()->updateConnectedEditors();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicCellRangeUi::clampValues()
{
if (!m_case) return;
const cvf::StructGridInterface* grid = RigReservoirGridTools::gridByIndex(m_case, m_gridIndex());
if (!grid) return;
m_cellCountI = cvf::Math::clamp(m_cellCountI.v(), 1, static_cast<int>(grid->cellCountI()));
m_startIndexI = cvf::Math::clamp(m_startIndexI.v(), 1, static_cast<int>(grid->cellCountI()));
m_cellCountJ = cvf::Math::clamp(m_cellCountJ.v(), 1, static_cast<int>(grid->cellCountJ()));
m_startIndexJ = cvf::Math::clamp(m_startIndexJ.v(), 1, static_cast<int>(grid->cellCountJ()));
m_cellCountK = cvf::Math::clamp(m_cellCountK.v(), 1, static_cast<int>(grid->cellCountK()));
m_startIndexK = cvf::Math::clamp(m_startIndexK.v(), 1, static_cast<int>(grid->cellCountK()));
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicCellRangeUi::setDefaultValues()
{
const cvf::StructGridInterface* grid = RigReservoirGridTools::gridByIndex(m_case, m_gridIndex());
if (!grid) return;
RigActiveCellInfo* actCellInfo = this->activeCellInfo();
const cvf::StructGridInterface* mainGrid = RigReservoirGridTools::mainGrid(m_case);
if (grid == mainGrid && actCellInfo)
{
cvf::Vec3st min, max;
actCellInfo->IJKBoundingBox(min, max);
// Adjust to Eclipse indexing
min.x() = min.x() + 1;
min.y() = min.y() + 1;
min.z() = min.z() + 1;
max.x() = max.x() + 1;
max.y() = max.y() + 1;
max.z() = max.z() + 1;
m_startIndexI = static_cast<int>(min.x());
m_startIndexJ = static_cast<int>(min.y());
m_startIndexK = static_cast<int>(min.z());
m_cellCountI = static_cast<int>(max.x() - min.x() + 1);
m_cellCountJ = static_cast<int>(max.y() - min.y() + 1);
m_cellCountK = static_cast<int>(max.z() - min.z() + 1);
}
else
{
m_startIndexI = 1;
m_startIndexJ = 1;
m_startIndexK = 1;
m_cellCountI = static_cast<int>(grid->cellCountI());
m_cellCountJ = static_cast<int>(grid->cellCountJ());
m_cellCountK = static_cast<int>(grid->cellCountK());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigActiveCellInfo* RicCellRangeUi::activeCellInfo() const
{
RimEclipseCase* rimEclipeCase = dynamic_cast<RimEclipseCase*>(m_case());
if (rimEclipeCase && rimEclipeCase->eclipseCaseData())
{
return rimEclipeCase->eclipseCaseData()->activeCellInfo(RifReaderInterface::MATRIX_RESULTS);
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicCellRangeUi::updateLegendText()
{
const cvf::StructGridInterface* grid = RigReservoirGridTools::gridByIndex(m_case, m_gridIndex());
const cvf::StructGridInterface* mainGrid = RigReservoirGridTools::mainGrid(m_case);
RigActiveCellInfo* actCellInfo = activeCellInfo();
if (grid == mainGrid && actCellInfo)
{
cvf::Vec3st min, max;
actCellInfo->IJKBoundingBox(min, max);
// Adjust to Eclipse indexing
min.x() = min.x() + 1;
min.y() = min.y() + 1;
min.z() = min.z() + 1;
max.x() = max.x() + 1;
max.y() = max.y() + 1;
max.z() = max.z() + 1;
m_startIndexI.uiCapability()->setUiName(QString("I Start (%1)").arg(min.x()));
m_startIndexJ.uiCapability()->setUiName(QString("J Start (%1)").arg(min.y()));
m_startIndexK.uiCapability()->setUiName(QString("K Start (%1)").arg(min.z()));
m_cellCountI.uiCapability()->setUiName(QString(" Width (%1)").arg(max.x() - min.x() + 1));
m_cellCountJ.uiCapability()->setUiName(QString(" Width (%1)").arg(max.y() - min.y() + 1));
m_cellCountK.uiCapability()->setUiName(QString(" Width (%1)").arg(max.z() - min.z() + 1));
}
else
{
m_startIndexI.uiCapability()->setUiName(QString("I Start"));
m_startIndexJ.uiCapability()->setUiName(QString("J Start"));
m_startIndexK.uiCapability()->setUiName(QString("K Start"));
m_cellCountI.uiCapability()->setUiName(QString(" Width"));
m_cellCountJ.uiCapability()->setUiName(QString(" Width"));
m_cellCountK.uiCapability()->setUiName(QString(" Width"));
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicCellRangeUi::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
{
uiOrdering.add(&m_gridIndex);
uiOrdering.add(&m_startIndexI);
uiOrdering.add(&m_cellCountI);
uiOrdering.add(&m_startIndexJ);
uiOrdering.add(&m_cellCountJ);
uiOrdering.add(&m_startIndexK);
uiOrdering.add(&m_cellCountK);
updateLegendText();
}

View File

@ -0,0 +1,68 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmObject.h"
#include "cafPdmField.h"
#include "cafPdmPtrField.h"
#include "cafVecIjk.h"
class RimCase;
class RigActiveCellInfo;
//==================================================================================================
///
//==================================================================================================
class RicCellRangeUi : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RicCellRangeUi();
void setCase(RimCase* rimCase);
caf::VecIjk start() const;
caf::VecIjk count() const;
QString gridName() const;
private:
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override;
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override;
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
void clampValues();
void setDefaultValues();
RigActiveCellInfo* activeCellInfo() const;
void updateLegendText();
private:
caf::PdmPtrField<RimCase*> m_case;
caf::PdmField<int> m_gridIndex;
caf::PdmField<int> m_startIndexI; // Eclipse indexing, first index is 1
caf::PdmField<int> m_startIndexJ; // Eclipse indexing, first index is 1
caf::PdmField<int> m_startIndexK; // Eclipse indexing, first index is 1
caf::PdmField<int> m_cellCountI;
caf::PdmField<int> m_cellCountJ;
caf::PdmField<int> m_cellCountK;
};

View File

@ -0,0 +1,156 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicExportCarfin.h"
#include "RiaApplication.h"
#include "RiaLogging.h"
#include "RicCellRangeUi.h"
#include "RicExportCarfinUi.h"
#include "RicExportFeatureImpl.h"
#include "RifEclipseDataTableFormatter.h"
#include "RimDialogData.h"
#include "RimEclipseCase.h"
#include "RimProject.h"
#include "cafPdmUiPropertyViewDialog.h"
#include "cafSelectionManager.h"
#include <QAction>
#include <QFile>
CAF_CMD_SOURCE_INIT(RicExportCarfin, "RicExportCarfin");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicExportCarfin::isCommandEnabled()
{
if (RicExportCarfin::selectedCase() != nullptr)
{
return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportCarfin::onActionTriggered(bool isChecked)
{
RimEclipseCase* rimCase = RicExportCarfin::selectedCase();
CVF_ASSERT(rimCase);
QString exportCarfinDataAsString = RiaApplication::instance()->project()->dialogData()->exportCarfinDataAsString();
RicExportCarfinUi* exportCarfinObject = RiaApplication::instance()->project()->dialogData()->exportCarfin();
exportCarfinObject->setCase(rimCase);
caf::PdmUiPropertyViewDialog propertyDialog(nullptr, exportCarfinObject, "Export CARFIN to Eclipse Data", "");
RicExportFeatureImpl::configureForExport(&propertyDialog);
if (propertyDialog.exec() == QDialog::Accepted)
{
QString filePath = exportCarfinObject->exportFileName();
QFile exportFile(filePath);
if (!exportFile.open(QIODevice::WriteOnly))
{
RiaLogging::error(QString("Export CARFIN: Could not open the file: %1").arg(filePath));
return;
}
QTextStream stream(&exportFile);
RifEclipseDataTableFormatter formatter(stream);
std::vector<RifEclipseOutputTableColumn> header = {
RifEclipseOutputTableColumn("I1"),
RifEclipseOutputTableColumn("I2"),
RifEclipseOutputTableColumn("J1"),
RifEclipseOutputTableColumn("J2"),
RifEclipseOutputTableColumn("K1"),
RifEclipseOutputTableColumn("K2"),
RifEclipseOutputTableColumn("NX"),
RifEclipseOutputTableColumn("NY"),
RifEclipseOutputTableColumn("NZ"),
RifEclipseOutputTableColumn("NWMAX"),
RifEclipseOutputTableColumn("Parent LGR")
};
formatter.keyword("CARFIN");
formatter.header(header);
formatter.add(exportCarfinObject->cellRange()->start().i());
formatter.add(exportCarfinObject->cellRange()->start().i() + exportCarfinObject->cellRange()->count().i());
formatter.add(exportCarfinObject->cellRange()->start().j());
formatter.add(exportCarfinObject->cellRange()->start().j() + exportCarfinObject->cellRange()->count().j());
formatter.add(exportCarfinObject->cellRange()->start().k());
formatter.add(exportCarfinObject->cellRange()->start().k() + exportCarfinObject->cellRange()->count().k());
formatter.add(exportCarfinObject->lgrCellCount().i());
formatter.add(exportCarfinObject->lgrCellCount().j());
formatter.add(exportCarfinObject->lgrCellCount().k());
formatter.add(exportCarfinObject->maxWellCount());
if (!exportCarfinObject->gridName().isEmpty())
{
formatter.add(exportCarfinObject->gridName());
}
formatter.rowCompleted();
formatter.tableCompleted();
}
else
{
RiaApplication::instance()->project()->dialogData()->setExportCarfinDataFromString(exportCarfinDataAsString);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportCarfin::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Export CARFIN ...");
actionToSetup->setIcon(QIcon(":/Save.png"));
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseCase* RicExportCarfin::selectedCase()
{
std::vector<RimEclipseCase*> selectedObjects;
caf::SelectionManager::instance()->objectsByType(&selectedObjects);
if (selectedObjects.size() == 1)
{
return selectedObjects[0];
}
return nullptr;
}

View File

@ -0,0 +1,40 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafCmdFeature.h"
class RimEclipseCase;
//==================================================================================================
///
//==================================================================================================
class RicExportCarfin : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
virtual bool isCommandEnabled() override;
virtual void onActionTriggered( bool isChecked ) override;
virtual void setupActionLook( QAction* actionToSetup ) override;
private:
static RimEclipseCase* selectedCase();
};

View File

@ -0,0 +1,202 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicExportCarfinUi.h"
#include "RicCellRangeUi.h"
#include "RimEclipseCase.h"
#include "RimTools.h"
#include "cafPdmUiFilePathEditor.h"
#include "cafVecIjk.h"
CAF_PDM_SOURCE_INIT(RicExportCarfinUi, "RicExportCarfinUi");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicExportCarfinUi::RicExportCarfinUi()
{
CAF_PDM_InitObject("Export CARFIN", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_cellRange, "CellRange", "CellRange", "", "", "");
m_cellRange = new RicCellRangeUi;
CAF_PDM_InitFieldNoDefault(&m_exportFileName, "ExportFileName", "Export Filename", "", "", "");
m_exportFileName.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
CAF_PDM_InitFieldNoDefault(&m_caseToApply, "CaseToApply", "Source Case", "", "", "");
CAF_PDM_InitField(&m_cellCountI, "CellCountI", 2, "Cell Count I", "", "", "");
CAF_PDM_InitField(&m_cellCountJ, "CellCountJ", 2, "Cell Count J", "", "", "");
CAF_PDM_InitField(&m_cellCountK, "CellCountK", 2, "Cell Count K", "", "", "");
CAF_PDM_InitField(&m_maxWellCount, "MaxWellCount", 8, "Max Well Count", "", "", "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportCarfinUi::setCase(RimEclipseCase* rimCase)
{
bool isDifferent = (rimCase != m_caseToApply);
setCasePointers(rimCase);
if (isDifferent)
{
setDefaultValuesFromCase();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RicExportCarfinUi::maxWellCount() const
{
return m_maxWellCount();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::VecIjk RicExportCarfinUi::lgrCellCount() const
{
return caf::VecIjk{m_cellCountI, m_cellCountJ, m_cellCountK};
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const RicCellRangeUi* RicExportCarfinUi::cellRange() const
{
return m_cellRange();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicExportCarfinUi::exportFileName() const
{
return m_exportFileName();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseCase* RicExportCarfinUi::caseToApply() const
{
return m_caseToApply();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicExportCarfinUi::gridName() const
{
return m_cellRange->gridName();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportCarfinUi::setCasePointers(RimEclipseCase* rimCase)
{
m_caseToApply = rimCase;
m_cellRange->setCase(rimCase);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportCarfinUi::setDefaultValuesFromCase()
{
if (m_caseToApply)
{
QString caseFolder = m_caseToApply->locationOnDisc();
m_exportFileName = caseFolder + "/carfin.data";
}
m_cellCountI = 2;
m_cellCountJ = 2;
m_cellCountK = 2;
m_maxWellCount = 8;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RicExportCarfinUi::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly)
{
QList<caf::PdmOptionItemInfo> options;
if (fieldNeedingOptions == &m_caseToApply)
{
RimTools::caseOptionItems(&options);
}
return options;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportCarfinUi::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
if (changedField == &m_caseToApply)
{
setCasePointers(m_caseToApply);
setDefaultValuesFromCase();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportCarfinUi::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
{
uiOrdering.add(&m_caseToApply);
uiOrdering.add(&m_exportFileName);
caf::PdmUiGroup* sourceGridBox = uiOrdering.addNewGroup("Source Grid Box");
m_cellRange->uiOrdering(uiConfigName, *sourceGridBox);
caf::PdmUiGroup* gridRefinement = uiOrdering.addNewGroup("Grid Refinement");
gridRefinement->add(&m_cellCountI);
gridRefinement->add(&m_cellCountJ);
gridRefinement->add(&m_cellCountK);
gridRefinement->add(&m_maxWellCount);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportCarfinUi::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute)
{
if (field == &m_exportFileName)
{
caf::PdmUiFilePathEditorAttribute* myAttr = dynamic_cast<caf::PdmUiFilePathEditorAttribute*>(attribute);
if (myAttr)
{
myAttr->m_selectSaveFileName = true;
}
}
}

View File

@ -0,0 +1,72 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmObject.h"
#include "cafPdmChildField.h"
#include "cafPdmField.h"
#include "cafPdmPtrField.h"
class RimEclipseCase;
class RicCellRangeUi;
namespace caf {
class VecIjk;
}
//==================================================================================================
///
//==================================================================================================
class RicExportCarfinUi : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RicExportCarfinUi();
void setCase(RimEclipseCase* rimCase);
int maxWellCount() const;
caf::VecIjk lgrCellCount() const;
const RicCellRangeUi* cellRange() const;
QString exportFileName() const;
RimEclipseCase* caseToApply() const;
QString gridName() const;
private:
void setCasePointers(RimEclipseCase* rimCase);
void setDefaultValuesFromCase();
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override;
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override;
private:
caf::PdmField<QString> m_exportFileName;
caf::PdmPtrField<RimEclipseCase*> m_caseToApply;
caf::PdmChildField<RicCellRangeUi*> m_cellRange;
caf::PdmField<int> m_cellCountI;
caf::PdmField<int> m_cellCountJ;
caf::PdmField<int> m_cellCountK;
caf::PdmField<int> m_maxWellCount;
};

View File

@ -19,6 +19,7 @@
#include "RicExportToLasFileFeature.h"
#include "RicExportFeatureImpl.h"
#include "RicExportToLasFileResampleUi.h"
#include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h"
@ -78,6 +79,7 @@ void RicExportToLasFileFeature::onActionTriggered(bool isChecked)
}
caf::PdmUiPropertyViewDialog propertyDialog(NULL, &featureUi, "Export Curve Data to LAS file(s)", "", QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
RicExportFeatureImpl::configureForExport(&propertyDialog);
propertyDialog.resize(QSize(400, 200));
if (propertyDialog.exec() == QDialog::Accepted &&

View File

@ -19,22 +19,25 @@
#include "RicSaveEclipseInputPropertyFeature.h"
#include "RimEclipseInputProperty.h"
#include "RimEclipseInputPropertyCollection.h"
#include "RimExportInputPropertySettings.h"
#include "RimEclipseInputCase.h"
#include "RiaApplication.h"
#include "RicExportFeatureImpl.h"
#include "RifEclipseInputFileTools.h"
#include "RiaApplication.h"
#include "RimEclipseInputCase.h"
#include "RimEclipseInputProperty.h"
#include "RimEclipseInputPropertyCollection.h"
#include "RimExportInputPropertySettings.h"
#include "RiuMainWindow.h"
#include "cafSelectionManager.h"
#include "cafPdmUiPropertyViewDialog.h"
#include "cafSelectionManager.h"
#include <QAction>
#include <QMessageBox>
#include <QFileInfo>
#include <QMessageBox>
CAF_CMD_SOURCE_INIT(RicSaveEclipseInputPropertyFeature, "RicSaveEclipseInputPropertyFeature");
@ -99,6 +102,8 @@ void RicSaveEclipseInputPropertyFeature::onActionTriggered(bool isChecked)
}
caf::PdmUiPropertyViewDialog propertyDialog(RiuMainWindow::instance(), &exportSettings, "Export Eclipse Property to Text File", "");
RicExportFeatureImpl::configureForExport(&propertyDialog);
if (propertyDialog.exec() == QDialog::Accepted)
{
bool isOk = RifEclipseInputFileTools::writePropertyToTextFile(exportSettings.fileName, inputReservoir->eclipseCaseData(), 0, inputProperty->resultName, exportSettings.eclipseKeyword);

View File

@ -19,25 +19,27 @@
#include "RicSaveEclipseResultAsInputPropertyExec.h"
#include "RimEclipseCellColors.h"
#include "RimBinaryExportSettings.h"
#include "RimEclipseView.h"
#include "RimEclipseCase.h"
#include "RiaApplication.h"
#include "RigCaseCellResultsData.h"
#include "RicExportFeatureImpl.h"
#include "RifEclipseInputFileTools.h"
#include "RifReaderInterface.h"
#include "RiaApplication.h"
#include "RigCaseCellResultsData.h"
#include "RimBinaryExportSettings.h"
#include "RimEclipseCase.h"
#include "RimEclipseCellColors.h"
#include "RimEclipseView.h"
#include "RiuMainWindow.h"
#include "cafPdmUiPropertyViewDialog.h"
#include <QFileInfo>
#include <QMessageBox>
#include "cafUtils.h"
#include <QMessageBox>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -90,6 +92,7 @@ void RicSaveEclipseResultAsInputPropertyExec::redo()
}
caf::PdmUiPropertyViewDialog propertyDialog(RiuMainWindow::instance(), &exportSettings, "Export Binary Eclipse Data to Text File", "");
RicExportFeatureImpl::configureForExport(&propertyDialog);
if (propertyDialog.exec() == QDialog::Accepted)
{

View File

@ -0,0 +1,37 @@
#include "QDialogButtonBox"
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicExportFeatureImpl.h"
#include "cafPdmUiPropertyViewDialog.h"
#include <QDialogButtonBox>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportFeatureImpl::configureForExport(caf::PdmUiPropertyViewDialog* propertyViewDialog)
{
QDialogButtonBox* dialogButtonBox = propertyViewDialog->dialogButtonBox();
dialogButtonBox->clear();
dialogButtonBox->addButton("Export", QDialogButtonBox::AcceptRole);
dialogButtonBox->addButton("Cancel", QDialogButtonBox::RejectRole);
}

View File

@ -0,0 +1,32 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
namespace caf {
class PdmUiPropertyViewDialog;
}
//==================================================================================================
///
//==================================================================================================
class RicExportFeatureImpl
{
public:
static void configureForExport(caf::PdmUiPropertyViewDialog* propertyViewDialog);
};

View File

@ -91,6 +91,7 @@ ${CEE_CURRENT_LIST_DIR}RimGeometrySelectionItem.h
${CEE_CURRENT_LIST_DIR}RimEclipseGeometrySelectionItem.h
${CEE_CURRENT_LIST_DIR}RimStimPlanLegendConfig.h
${CEE_CURRENT_LIST_DIR}RimStimPlanColors.h
${CEE_CURRENT_LIST_DIR}RimDialogData.h
)
set (SOURCE_GROUP_SOURCE_FILES
@ -180,6 +181,7 @@ ${CEE_CURRENT_LIST_DIR}RimGeometrySelectionItem.cpp
${CEE_CURRENT_LIST_DIR}RimEclipseGeometrySelectionItem.cpp
${CEE_CURRENT_LIST_DIR}RimStimPlanLegendConfig.cpp
${CEE_CURRENT_LIST_DIR}RimStimPlanColors.cpp
${CEE_CURRENT_LIST_DIR}RimDialogData.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@ -42,9 +42,9 @@ RimFishboneWellPathCollection::RimFishboneWellPathCollection()
CAF_PDM_InitObject("WellPathCompletions", ":/FishBoneGroupFromFile16x16.png", "", "");
nameField()->uiCapability()->setUiHidden(true);
this->setName("Well Paths");
this->setName("Imported Laterals");
CAF_PDM_InitFieldNoDefault(&m_wellPaths, "WellPaths", "Well Paths", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_wellPaths, "WellPaths", "Imported Laterals", "", "", "");
m_wellPaths.uiCapability()->setUiHidden(true);
CAF_PDM_InitFieldNoDefault(&m_pipeProperties, "PipeProperties", "Pipe Properties", "", "", "");

View File

@ -31,6 +31,25 @@
#include <algorithm>
namespace caf {
template<>
void RimFishbonesCollection::PressureDropEnum::setUp()
{
addItem(RimFishbonesCollection::HYDROSTATIC, "H--", "Hydrostatic");
addItem(RimFishbonesCollection::HYDROSTATIC_FRICTION, "HF-", "Hydrostatic + Friction");
addItem(RimFishbonesCollection::HYDROSTATIC_FRICTION_ACCELERATION, "HFA", "Hydrostatic + Friction + Acceleration");
setDefault(RimFishbonesCollection::HYDROSTATIC);
}
template<>
void RimFishbonesCollection::LengthAndDepthEnum::setUp()
{
addItem(RimFishbonesCollection::INC, "INC", "Incremental");
addItem(RimFishbonesCollection::ABS, "ABS", "Absolute");
setDefault(RimFishbonesCollection::INC);
}
}
CAF_PDM_SOURCE_INIT(RimFishbonesCollection, "FishbonesCollection");
//--------------------------------------------------------------------------------------------------
@ -47,15 +66,19 @@ RimFishbonesCollection::RimFishbonesCollection()
fishbonesSubs.uiCapability()->setUiHidden(true);
CAF_PDM_InitFieldNoDefault(&m_wellPathCollection, "WellPathCollection", "Well Paths", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_wellPathCollection, "WellPathCollection", "Imported Laterals", "", "", "");
m_wellPathCollection = new RimFishboneWellPathCollection;
m_wellPathCollection.uiCapability()->setUiHidden(true);
CAF_PDM_InitField(&m_startMD, "StartMD", HUGE_VAL, "Start MD", "", "", "");
CAF_PDM_InitField(&m_mainBoreDiameter, "MainBoreDiameter", 0.216, "Main Bore Diameter", "", "", "");
CAF_PDM_InitField(&m_skinFactor, "MainBoreSkinFactor", 0., "Main Bore Skin Factor [0..1]", "", "", "");
CAF_PDM_InitField(&m_linerDiameter, "LinerDiameter", 0.152, "Liner Inner Diameter", "", "", "");
CAF_PDM_InitField(&m_roughnessFactor, "RoughnessFactor", 1e-05, "Roughness Factor", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_pressureDrop, "PressureDrop", "Pressure Drop", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_lengthAndDepth, "LengthAndDepth", "Length and Depth", "", "", "");
manuallyModifiedStartMD = false;
}
@ -121,10 +144,13 @@ void RimFishbonesCollection::defineUiOrdering(QString uiConfigName, caf::PdmUiOr
caf::PdmUiGroup* wellGroup = uiOrdering.addNewGroup("Fishbone Well Properties");
wellGroup->add(&m_startMD);
wellGroup->add(&m_mainBoreDiameter);
wellGroup->add(&m_skinFactor);
caf::PdmUiGroup* mswGroup = uiOrdering.addNewGroup("Multi Segment Wells");
mswGroup->add(&m_linerDiameter);
mswGroup->add(&m_roughnessFactor);
mswGroup->add(&m_pressureDrop);
mswGroup->add(&m_lengthAndDepth);
}
//--------------------------------------------------------------------------------------------------

View File

@ -41,6 +41,21 @@ class RimFishbonesCollection : public RimCheckableNamedObject
CAF_PDM_HEADER_INIT;
public:
enum PressureDropType {
HYDROSTATIC,
HYDROSTATIC_FRICTION,
HYDROSTATIC_FRICTION_ACCELERATION
};
typedef caf::AppEnum<PressureDropType> PressureDropEnum;
enum LengthAndDepthType {
ABS,
INC
};
typedef caf::AppEnum<LengthAndDepthType> LengthAndDepthEnum;
RimFishbonesCollection();
RimFishboneWellPathCollection* wellPathCollection() const;
@ -50,10 +65,14 @@ public:
void recalculateStartMD();
double startMD() const { return m_startMD; }
double mainBoreSkinFactor() const { return m_skinFactor; }
double mainBoreDiameter(RiaEclipseUnitTools::UnitSystem unitSystem) const;
double linerDiameter(RiaEclipseUnitTools::UnitSystem unitSystem) const;
double roughnessFactor(RiaEclipseUnitTools::UnitSystem unitSystem) const;
PressureDropEnum pressureDrop() const { return m_pressureDrop(); }
LengthAndDepthEnum lengthAndDepth() const { return m_lengthAndDepth(); }
void setUnitSystemSpecificDefaults();
protected:
@ -67,9 +86,13 @@ private:
caf::PdmChildField<RimFishboneWellPathCollection*> m_wellPathCollection;
caf::PdmField<double> m_startMD;
caf::PdmField<double> m_skinFactor;
caf::PdmField<double> m_mainBoreDiameter;
caf::PdmField<double> m_linerDiameter;
caf::PdmField<double> m_roughnessFactor;
caf::PdmField<PressureDropEnum> m_pressureDrop;
caf::PdmField<LengthAndDepthEnum> m_lengthAndDepth;
bool manuallyModifiedStartMD;
};

View File

@ -73,7 +73,7 @@ RimFishbonesMultipleSubs::RimFishbonesMultipleSubs()
CAF_PDM_InitField(&m_lateralOpenHoleRoghnessFactor, "LateralOpenHoleRoghnessFactor", 0.001, "Open Hole Roghness Factor [m]", "", "", "");
CAF_PDM_InitField(&m_lateralTubingRoghnessFactor, "LateralTubingRoghnessFactor", 1e-5, "Tubing Roghness Factor [m]", "", "", "");
CAF_PDM_InitField(&m_lateralInstallSuccessFraction, "LateralInstallSuccessFraction", 0.7, "Install Success Rate [0..1]", "", "", "");
CAF_PDM_InitField(&m_lateralInstallSuccessFraction, "LateralInstallSuccessFraction", 1.0, "Install Success Rate [0..1]", "", "", "");
CAF_PDM_InitField(&m_icdCount, "IcdCount", size_t(2), "ICDs per Sub", "", "", "");
CAF_PDM_InitField(&m_icdOrificeDiameter, "IcdOrificeDiameter", 7.0, "ICD Orifice Diameter [mm]", "", "", "");

View File

@ -40,7 +40,7 @@ RimPerforationInterval::RimPerforationInterval()
CAF_PDM_InitField(&m_endMD, "EndMeasuredDepth", 0.0, "End MD", "", "", "");
CAF_PDM_InitField(&m_diameter, "Diameter", 0.216, "Diameter", "", "", "");
CAF_PDM_InitField(&m_skinFactor, "SkinFactor", 0.0, "Skin Factor", "", "", "");
CAF_PDM_InitField(&m_startOfHistory, "StartOfHistory", true, "Start of History", "", "", "");
CAF_PDM_InitField(&m_startOfHistory, "StartOfHistory", true, "All Timesteps", "", "", "");
CAF_PDM_InitField(&m_date, "StartDate", QDateTime::currentDateTime(), "Start Date", "", "", "");
nameField()->uiCapability()->setUiReadOnly(true);

View File

@ -22,16 +22,17 @@
#include "RimCellRangeFilter.h"
#include "RigActiveCellInfo.h"
#include "RigGridBase.h"
#include "RigMainGrid.h"
#include "RigReservoirGridTools.h"
#include "RimEclipseCase.h"
#include "RimCellRangeFilterCollection.h"
#include "RimEclipseCase.h"
#include "RimEclipseView.h"
#include "RimViewController.h"
#include "cafPdmUiSliderEditor.h"
#include "cvfAssert.h"
#include "cvfStructGrid.h"
CAF_PDM_SOURCE_INIT(RimCellRangeFilter, "CellRangeFilter");
@ -125,8 +126,16 @@ void RimCellRangeFilter::setDefaultValues()
const cvf::StructGridInterface* grid = selectedGrid();
RigActiveCellInfo* actCellInfo = parentContainer()->activeCellInfo();
if (grid == parentContainer()->gridByIndex(0) && actCellInfo)
RimView* rimView = nullptr;
this->firstAncestorOrThisOfTypeAsserted(rimView);
RigActiveCellInfo* actCellInfo = RigReservoirGridTools::activeCellInfo(rimView);
RimCase* rimCase = nullptr;
this->firstAncestorOrThisOfTypeAsserted(rimCase);
const cvf::StructGridInterface* mainGrid = RigReservoirGridTools::mainGrid(rimCase);
if (grid == mainGrid && actCellInfo)
{
cvf::Vec3st min, max;
actCellInfo->IJKBoundingBox(min, max);
@ -195,8 +204,15 @@ void RimCellRangeFilter::defineEditorAttribute(const caf::PdmFieldHandle* field,
myAttr->m_maximum = static_cast<int>(grid->cellCountK());
}
RigActiveCellInfo* actCellInfo = parentContainer()->activeCellInfo();
if (grid == parentContainer()->gridByIndex(0) && actCellInfo)
RimCase* rimCase = nullptr;
this->firstAncestorOrThisOfTypeAsserted(rimCase);
const cvf::StructGridInterface* mainGrid = RigReservoirGridTools::mainGrid(rimCase);
RimView* rimView = nullptr;
this->firstAncestorOrThisOfTypeAsserted(rimView);
RigActiveCellInfo* actCellInfo = RigReservoirGridTools::activeCellInfo(rimView);
if (grid == mainGrid && actCellInfo)
{
cvf::Vec3st min, max;
actCellInfo->IJKBoundingBox(min, max);
@ -264,12 +280,15 @@ QList<caf::PdmOptionItemInfo> RimCellRangeFilter::calculateValueOptions(const ca
if (useOptionsOnly) (*useOptionsOnly) = true;
if (&gridIndex == fieldNeedingOptions)
{
for (int gIdx = 0; gIdx < parentContainer()->gridCount(); ++gIdx)
{
RimCase* rimCase = nullptr;
this->firstAncestorOrThisOfTypeAsserted(rimCase);
for (int gIdx = 0; gIdx < RigReservoirGridTools::gridCount(rimCase); ++gIdx)
{
QString gridName;
gridName += parentContainer()->gridName(gIdx);
gridName += RigReservoirGridTools::gridName(rimCase, gIdx);
if (gIdx == 0)
{
if (gridName.isEmpty())
@ -288,11 +307,10 @@ QList<caf::PdmOptionItemInfo> RimCellRangeFilter::calculateValueOptions(const ca
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimCellRangeFilter::isRangeFilterControlled()
bool RimCellRangeFilter::isRangeFilterControlled() const
{
RimView* rimView = NULL;
firstAncestorOrThisOfType(rimView);
CVF_ASSERT(rimView);
RimView* rimView = nullptr;
firstAncestorOrThisOfTypeAsserted(rimView);
bool isRangeFilterControlled = false;
if (rimView && rimView->viewController() && rimView->viewController()->isRangeFiltersControlled())
@ -308,15 +326,15 @@ bool RimCellRangeFilter::isRangeFilterControlled()
//--------------------------------------------------------------------------------------------------
const cvf::StructGridInterface* RimCellRangeFilter::selectedGrid()
{
if (gridIndex() >= parentContainer()->gridCount())
RimCase* rimCase = nullptr;
this->firstAncestorOrThisOfTypeAsserted(rimCase);
int clampedIndex = gridIndex();
if (clampedIndex >= RigReservoirGridTools::gridCount(rimCase))
{
gridIndex = 0;
clampedIndex = 0;
}
const cvf::StructGridInterface* grid = parentContainer()->gridByIndex(gridIndex());
CVF_ASSERT(grid);
return grid;
return RigReservoirGridTools::gridByIndex(rimCase, clampedIndex);
}

View File

@ -44,9 +44,6 @@ public:
RimCellRangeFilter();
virtual ~RimCellRangeFilter();
RimCellRangeFilterCollection* parentContainer();
void setDefaultValues();
caf::PdmField<int> gridIndex; // The index of the grid that this filter applies to
caf::PdmField<bool> propagateToSubGrids; // Do propagate the effects to the sub-grids
@ -57,9 +54,8 @@ public:
caf::PdmField<int> cellCountJ;
caf::PdmField<int> cellCountK;
void computeAndSetValidValues();
void updateActiveState();
void setDefaultValues();
void updateActiveState();
protected:
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
@ -70,10 +66,10 @@ protected:
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly );
private:
bool isRangeFilterControlled();
private:
const cvf::StructGridInterface* selectedGrid();
RimCellRangeFilterCollection* parentContainer();
bool isRangeFilterControlled() const;
void computeAndSetValidValues();
const cvf::StructGridInterface* selectedGrid();
};

View File

@ -20,22 +20,15 @@
#include "RimCellRangeFilterCollection.h"
#include "RigFemPart.h"
#include "RigFemPartCollection.h"
#include "RigFemPartGrid.h"
#include "RigGeoMechCaseData.h"
#include "RigMainGrid.h"
#include "RimCellRangeFilter.h"
#include "RimEclipseCase.h"
#include "RimEclipseView.h"
#include "RimGeoMechCase.h"
#include "RimGeoMechView.h"
#include "RimView.h"
#include "RimViewController.h"
#include "RimViewLinker.h"
#include "cafPdmUiEditorHandle.h"
#include "cvfStructGridGeometryGenerator.h"
CAF_PDM_SOURCE_INIT(RimCellRangeFilterCollection, "CellRangeFilterCollection");
@ -101,35 +94,6 @@ void RimCellRangeFilterCollection::compoundCellRangeFilter(cvf::CellRangeFilter*
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigMainGrid* RimCellRangeFilterCollection::mainGrid() const
{
RimEclipseView* eclipseView = this->eclipseView();
if (eclipseView && eclipseView->mainGrid())
{
return eclipseView->mainGrid();
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigActiveCellInfo* RimCellRangeFilterCollection::activeCellInfo() const
{
RimEclipseView* eclipseView = this->eclipseView();
if (eclipseView)
{
return eclipseView->currentActiveCellInfo();
}
return NULL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -168,14 +132,6 @@ void RimCellRangeFilterCollection::updateDisplayModeNotifyManagedViews(RimCellRa
view->scheduleCreateDisplayModelAndRedraw();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseView* RimCellRangeFilterCollection::eclipseView() const
{
return dynamic_cast<RimEclipseView*>(baseView());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -214,89 +170,6 @@ bool RimCellRangeFilterCollection::hasActiveIncludeFilters() const
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const cvf::StructGridInterface* RimCellRangeFilterCollection::gridByIndex(int gridIndex) const
{
RigMainGrid* mnGrid = mainGrid();
RigFemPartCollection* femPartColl = this->femPartColl();
if (mnGrid)
{
RigGridBase* grid = mnGrid->gridByIndex(gridIndex);
CVF_ASSERT(grid);
return grid;
}
else if (femPartColl)
{
if (gridIndex < femPartColl->partCount())
return femPartColl->part(gridIndex)->structGrid();
else
return NULL;
}
return NULL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimCellRangeFilterCollection::gridCount() const
{
RigMainGrid* mnGrid = mainGrid();
RigFemPartCollection* femPartColl = this->femPartColl();
if (mnGrid)
{
return (int)mnGrid->gridCount();
}
else if (femPartColl)
{
return femPartColl->partCount();
}
return 0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimCellRangeFilterCollection::gridName(int gridIndex) const
{
RigMainGrid* mnGrid = mainGrid();
RigFemPartCollection* femPartColl = this->femPartColl();
if (mnGrid)
{
return mnGrid->gridByIndex(gridIndex)->gridName().c_str();
}
else if (femPartColl)
{
return QString::number(gridIndex);
}
return "";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFemPartCollection* RimCellRangeFilterCollection::femPartColl() const
{
RimGeoMechView* geoView = dynamic_cast<RimGeoMechView*>(baseView());
if (geoView &&
geoView->geoMechCase() &&
geoView->geoMechCase()->geoMechData() )
{
return geoView->geoMechCase()->geoMechData()->femParts();
}
return NULL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -22,17 +22,11 @@
#include "cafPdmChildArrayField.h"
#include "cafPdmField.h"
class RigActiveCellInfo;
class RigFemPartCollection;
class RigGridBase;
class RimView;
class RimCellRangeFilter;
class RimEclipseView;
class RigMainGrid;
namespace cvf {
class CellRangeFilter;
class StructGridInterface;
};
//==================================================================================================
@ -55,12 +49,6 @@ public:
bool hasActiveFilters() const;
bool hasActiveIncludeFilters() const;
const cvf::StructGridInterface* gridByIndex(int gridIndex) const;
int gridCount() const;
QString gridName(int gridIndex) const;
RigActiveCellInfo* activeCellInfo() const;
void updateDisplayModeNotifyManagedViews(RimCellRangeFilter* changedRangeFilter);
void updateIconState();
@ -71,9 +59,4 @@ protected:
private:
RimView* baseView() const;
private:
RimEclipseView* eclipseView() const;
RigMainGrid* mainGrid() const;
RigFemPartCollection* femPartColl() const;
};

View File

@ -427,6 +427,7 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
commandIds << "RicWellPathExportCompletionDataFeature";
commandIds << "RicWellPathImportCompletionsFileFeature";
commandIds << "RicFlyToObjectFeature";
commandIds << "RicExportCarfin";
// Fracture commands
commandIds << "RicNewWellPathFractureFeature";

Some files were not shown because too many files have changed in this diff Show More