mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Merge branch 'dev' into pre-proto
This commit is contained in:
50
ApplicationCode/CommandFileInterface/CMakeLists_files.cmake
Normal file
50
ApplicationCode/CommandFileInterface/CMakeLists_files.cmake
Normal 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 )
|
||||
@@ -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 )
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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 << "\"";
|
||||
}
|
||||
207
ApplicationCode/CommandFileInterface/Core/RicfFieldCapability.h
Normal file
207
ApplicationCode/CommandFileInterface/Core/RicfFieldCapability.h
Normal 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
}
|
||||
55
ApplicationCode/CommandFileInterface/Core/RicfFieldHandle.h
Normal file
55
ApplicationCode/CommandFileInterface/Core/RicfFieldHandle.h
Normal 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;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
81
ApplicationCode/CommandFileInterface/Core/RicfMessages.cpp
Normal file
81
ApplicationCode/CommandFileInterface/Core/RicfMessages.cpp
Normal 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;
|
||||
}
|
||||
51
ApplicationCode/CommandFileInterface/Core/RicfMessages.h
Normal file
51
ApplicationCode/CommandFileInterface/Core/RicfMessages.h
Normal 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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
};
|
||||
38
ApplicationCode/CommandFileInterface/RicfCloseProject.cpp
Normal file
38
ApplicationCode/CommandFileInterface/RicfCloseProject.cpp
Normal 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();
|
||||
}
|
||||
40
ApplicationCode/CommandFileInterface/RicfCloseProject.h
Normal file
40
ApplicationCode/CommandFileInterface/RicfCloseProject.h
Normal 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:
|
||||
};
|
||||
121
ApplicationCode/CommandFileInterface/RicfCommandFileExecutor.cpp
Normal file
121
ApplicationCode/CommandFileInterface/RicfCommandFileExecutor.cpp
Normal 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;
|
||||
}
|
||||
@@ -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;
|
||||
};
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
};
|
||||
96
ApplicationCode/CommandFileInterface/RicfExportMsw.cpp
Normal file
96
ApplicationCode/CommandFileInterface/RicfExportMsw.cpp
Normal 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);
|
||||
}
|
||||
42
ApplicationCode/CommandFileInterface/RicfExportMsw.h
Normal file
42
ApplicationCode/CommandFileInterface/RicfExportMsw.h
Normal 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;
|
||||
};
|
||||
@@ -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));
|
||||
}
|
||||
@@ -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;
|
||||
};
|
||||
106
ApplicationCode/CommandFileInterface/RicfExportProperty.cpp
Normal file
106
ApplicationCode/CommandFileInterface/RicfExportProperty.cpp
Normal 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);
|
||||
}
|
||||
46
ApplicationCode/CommandFileInterface/RicfExportProperty.h
Normal file
46
ApplicationCode/CommandFileInterface/RicfExportProperty.h
Normal 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;
|
||||
};
|
||||
76
ApplicationCode/CommandFileInterface/RicfExportSnapshots.cpp
Normal file
76
ApplicationCode/CommandFileInterface/RicfExportSnapshots.cpp
Normal 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();
|
||||
}
|
||||
51
ApplicationCode/CommandFileInterface/RicfExportSnapshots.h
Normal file
51
ApplicationCode/CommandFileInterface/RicfExportSnapshots.h
Normal 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 "RicfCommandObject.h"
|
||||
|
||||
#include "cafAppEnum.h"
|
||||
#include "cafPdmField.h"
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
class RicfExportSnapshots : public RicfCommandObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
enum SnapshotsType
|
||||
{
|
||||
VIEWS,
|
||||
PLOTS,
|
||||
ALL
|
||||
};
|
||||
typedef caf::AppEnum<SnapshotsType> SnapshotsTypeEnum;
|
||||
|
||||
public:
|
||||
RicfExportSnapshots();
|
||||
|
||||
virtual void execute() override;
|
||||
|
||||
private:
|
||||
caf::PdmField<SnapshotsTypeEnum> m_type;
|
||||
};
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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;
|
||||
};
|
||||
44
ApplicationCode/CommandFileInterface/RicfLoadCase.cpp
Normal file
44
ApplicationCode/CommandFileInterface/RicfLoadCase.cpp
Normal 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()));
|
||||
}
|
||||
}
|
||||
41
ApplicationCode/CommandFileInterface/RicfLoadCase.h
Normal file
41
ApplicationCode/CommandFileInterface/RicfLoadCase.h
Normal 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;
|
||||
};
|
||||
49
ApplicationCode/CommandFileInterface/RicfOpenProject.cpp
Normal file
49
ApplicationCode/CommandFileInterface/RicfOpenProject.cpp
Normal 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);
|
||||
}
|
||||
41
ApplicationCode/CommandFileInterface/RicfOpenProject.h
Normal file
41
ApplicationCode/CommandFileInterface/RicfOpenProject.h
Normal 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;
|
||||
};
|
||||
68
ApplicationCode/CommandFileInterface/RicfReplaceCase.cpp
Normal file
68
ApplicationCode/CommandFileInterface/RicfReplaceCase.cpp
Normal 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());
|
||||
}
|
||||
42
ApplicationCode/CommandFileInterface/RicfReplaceCase.h
Normal file
42
ApplicationCode/CommandFileInterface/RicfReplaceCase.h
Normal 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;
|
||||
};
|
||||
@@ -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());
|
||||
}
|
||||
@@ -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;
|
||||
};
|
||||
67
ApplicationCode/CommandFileInterface/RicfRunOctaveScript.cpp
Normal file
67
ApplicationCode/CommandFileInterface/RicfRunOctaveScript.cpp
Normal 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();
|
||||
}
|
||||
}
|
||||
42
ApplicationCode/CommandFileInterface/RicfRunOctaveScript.h
Normal file
42
ApplicationCode/CommandFileInterface/RicfRunOctaveScript.h
Normal 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;
|
||||
};
|
||||
42
ApplicationCode/CommandFileInterface/RicfSetExportFolder.cpp
Normal file
42
ApplicationCode/CommandFileInterface/RicfSetExportFolder.cpp
Normal 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);
|
||||
}
|
||||
44
ApplicationCode/CommandFileInterface/RicfSetExportFolder.h
Normal file
44
ApplicationCode/CommandFileInterface/RicfSetExportFolder.h
Normal 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;
|
||||
};
|
||||
@@ -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);
|
||||
}
|
||||
42
ApplicationCode/CommandFileInterface/RicfSetMainWindowSize.h
Normal file
42
ApplicationCode/CommandFileInterface/RicfSetMainWindowSize.h
Normal 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;
|
||||
};
|
||||
39
ApplicationCode/CommandFileInterface/RicfSetStartDir.cpp
Normal file
39
ApplicationCode/CommandFileInterface/RicfSetStartDir.cpp
Normal 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);
|
||||
}
|
||||
41
ApplicationCode/CommandFileInterface/RicfSetStartDir.h
Normal file
41
ApplicationCode/CommandFileInterface/RicfSetStartDir.h
Normal 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;
|
||||
};
|
||||
70
ApplicationCode/CommandFileInterface/RicfSetTimeStep.cpp
Normal file
70
ApplicationCode/CommandFileInterface/RicfSetTimeStep.cpp
Normal 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);
|
||||
}
|
||||
}
|
||||
42
ApplicationCode/CommandFileInterface/RicfSetTimeStep.h
Normal file
42
ApplicationCode/CommandFileInterface/RicfSetTimeStep.h
Normal 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;
|
||||
};
|
||||
Reference in New Issue
Block a user