mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-31 17:17:50 -05:00
Several adjustments user interface and project file
* Avoid writing error message if observed data for a well is not present * Add missing log text during replace summary ensemble * Make sure plot window is visible after importing summary ensemble * Add observed FMU folder to path section * Move worker functions to RiaProjectFileTools * Reset numbering of path IDs when saving project. * Remove warning when fault name is longer than 8 characters
This commit is contained in:
1 parent
52b000cc57
commit
88e0aad8cf
10 files changed
+311
-319
No files matched your search
@@ -17,89 +17,28 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiaProjectFileTools.h"
|
||||
#include "Tools/RiaVariableMapper.h"
|
||||
|
||||
#include "RimCase.h"
|
||||
#include "RimCaseDisplayNameTools.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimSummaryCase.h"
|
||||
|
||||
#include <QStringList>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiaProjectFileTools::isCandidateVersionNewerThanOther( const QString& candidateProjectFileVersion, const QString& projectFileVersion )
|
||||
namespace internal
|
||||
{
|
||||
int candidateMajorVersion = 0;
|
||||
int candidateMinorVersion = 0;
|
||||
int candidatePatchNumber = -1;
|
||||
int candidateDevelopmentId = -1;
|
||||
|
||||
RiaProjectFileTools::decodeVersionString( candidateProjectFileVersion,
|
||||
&candidateMajorVersion,
|
||||
&candidateMinorVersion,
|
||||
&candidatePatchNumber,
|
||||
&candidateDevelopmentId );
|
||||
|
||||
int majorVersion = 0;
|
||||
int minorVersion = 0;
|
||||
int patchNumber = -1;
|
||||
int developmentId = -1;
|
||||
|
||||
RiaProjectFileTools::decodeVersionString( projectFileVersion, &majorVersion, &minorVersion, &patchNumber, &developmentId );
|
||||
|
||||
return RiaProjectFileTools::isCandidateNewerThanOther( candidateMajorVersion,
|
||||
candidateMinorVersion,
|
||||
candidatePatchNumber,
|
||||
candidateDevelopmentId,
|
||||
majorVersion,
|
||||
minorVersion,
|
||||
patchNumber,
|
||||
developmentId );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaProjectFileTools::decodeVersionString( const QString& projectFileVersion, int* majorVersion, int* minorVersion, int* patch, int* developmentId )
|
||||
{
|
||||
if ( projectFileVersion.isEmpty() ) return;
|
||||
|
||||
QStringList subStrings = projectFileVersion.split( "." );
|
||||
|
||||
if ( !subStrings.empty() )
|
||||
{
|
||||
*majorVersion = subStrings[0].toInt();
|
||||
}
|
||||
|
||||
if ( subStrings.size() > 1 )
|
||||
{
|
||||
*minorVersion = subStrings[1].toInt();
|
||||
}
|
||||
|
||||
if ( subStrings.size() > 2 )
|
||||
{
|
||||
QString candidate = subStrings[2];
|
||||
QString candidateDigitsOnly = RiaProjectFileTools::stringOfDigits( candidate );
|
||||
|
||||
*patch = candidateDigitsOnly.toInt();
|
||||
}
|
||||
|
||||
if ( subStrings.size() > 3 )
|
||||
{
|
||||
QString candidate = subStrings.back();
|
||||
QString candidateDigitsOnly = RiaProjectFileTools::stringOfDigits( candidate );
|
||||
|
||||
*developmentId = candidateDigitsOnly.toInt();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiaProjectFileTools::isCandidateNewerThanOther( int candidateMajorVersion,
|
||||
int candidateMinorVersion,
|
||||
int candidatePatchNumber,
|
||||
int candidateDevelopmentId,
|
||||
int otherMajorVersion,
|
||||
int otherMinorVersion,
|
||||
int otherPatchNumber,
|
||||
int otherDevelopmentId )
|
||||
bool isCandidateNewerThanOther( int candidateMajorVersion,
|
||||
int candidateMinorVersion,
|
||||
int candidatePatchNumber,
|
||||
int candidateDevelopmentId,
|
||||
int otherMajorVersion,
|
||||
int otherMinorVersion,
|
||||
int otherPatchNumber,
|
||||
int otherDevelopmentId )
|
||||
{
|
||||
if ( candidateMajorVersion != otherMajorVersion )
|
||||
{
|
||||
@@ -133,7 +72,7 @@ bool RiaProjectFileTools::isCandidateNewerThanOther( int candidateMajorVersion,
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiaProjectFileTools::stringOfDigits( const QString& string )
|
||||
QString stringOfDigits( const QString& string )
|
||||
{
|
||||
QString digitsOnly;
|
||||
|
||||
@@ -154,3 +93,220 @@ QString RiaProjectFileTools::stringOfDigits( const QString& string )
|
||||
|
||||
return digitsOnly;
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiaProjectFileTools::isCandidateVersionNewerThanOther( const QString& candidateProjectFileVersion, const QString& projectFileVersion )
|
||||
{
|
||||
int candidateMajorVersion = 0;
|
||||
int candidateMinorVersion = 0;
|
||||
int candidatePatchNumber = -1;
|
||||
int candidateDevelopmentId = -1;
|
||||
|
||||
RiaProjectFileTools::decodeVersionString( candidateProjectFileVersion,
|
||||
&candidateMajorVersion,
|
||||
&candidateMinorVersion,
|
||||
&candidatePatchNumber,
|
||||
&candidateDevelopmentId );
|
||||
|
||||
int majorVersion = 0;
|
||||
int minorVersion = 0;
|
||||
int patchNumber = -1;
|
||||
int developmentId = -1;
|
||||
|
||||
RiaProjectFileTools::decodeVersionString( projectFileVersion, &majorVersion, &minorVersion, &patchNumber, &developmentId );
|
||||
|
||||
return internal::isCandidateNewerThanOther( candidateMajorVersion,
|
||||
candidateMinorVersion,
|
||||
candidatePatchNumber,
|
||||
candidateDevelopmentId,
|
||||
majorVersion,
|
||||
minorVersion,
|
||||
patchNumber,
|
||||
developmentId );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiaProjectFileTools::transferPathsToGlobalPathList( RimProject* project )
|
||||
{
|
||||
RiaVariableMapper variableMapper( "" );
|
||||
|
||||
for ( caf::FilePath* filePath : project->allFilePaths() )
|
||||
{
|
||||
QString path = filePath->path();
|
||||
if ( !path.isEmpty() )
|
||||
{
|
||||
QString pathId = variableMapper.addPathAndGetId( path );
|
||||
filePath->setPath( pathId );
|
||||
}
|
||||
}
|
||||
|
||||
for ( auto summaryCase : project->allSummaryCases() )
|
||||
{
|
||||
if ( summaryCase->displayNameType() == RimCaseDisplayNameTools::DisplayName::CUSTOM )
|
||||
{
|
||||
// At this point, after the replace of variables into caf::FilePath objects, the variable name is
|
||||
// stored in the summary case object. Read out the variable name and append "_name" for custom
|
||||
// summary variables.
|
||||
|
||||
QString variableName = summaryCase->summaryHeaderFilename();
|
||||
variableName = variableName.remove( RiaVariableMapper::variableToken() );
|
||||
|
||||
variableName = RiaVariableMapper::variableToken() + variableName + RiaVariableMapper::postfixName() +
|
||||
RiaVariableMapper::variableToken();
|
||||
|
||||
QString variableValue = summaryCase->displayCaseName();
|
||||
variableMapper.addVariable( variableName, variableValue );
|
||||
|
||||
summaryCase->setCustomCaseName( variableName );
|
||||
}
|
||||
}
|
||||
|
||||
for ( auto gridCase : project->allGridCases() )
|
||||
{
|
||||
if ( gridCase->displayNameType() == RimCaseDisplayNameTools::DisplayName::CUSTOM )
|
||||
{
|
||||
// At this point, after the replace of variables into caf::FilePath objects, the variable name is
|
||||
// stored in the summary case object. Read out the variable name and append "_name" for custom
|
||||
// summary variables.
|
||||
|
||||
QString variableName = gridCase->gridFileName();
|
||||
variableName = variableName.remove( RiaVariableMapper::variableToken() );
|
||||
|
||||
variableName = RiaVariableMapper::variableToken() + variableName + RiaVariableMapper::postfixName() +
|
||||
RiaVariableMapper::variableToken();
|
||||
|
||||
QString variableValue = gridCase->caseUserDescription();
|
||||
variableMapper.addVariable( variableName, variableValue );
|
||||
|
||||
gridCase->setCustomCaseName( variableName );
|
||||
}
|
||||
}
|
||||
|
||||
variableMapper.replaceVariablesInValues();
|
||||
|
||||
return variableMapper.variableTableAsText();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaProjectFileTools::distributePathsFromGlobalPathList( RimProject* project, const QString& pathList )
|
||||
{
|
||||
if ( !project ) return;
|
||||
|
||||
RiaVariableMapper pathListMapper( pathList );
|
||||
|
||||
for ( auto filePath : project->allFilePaths() )
|
||||
{
|
||||
filePath->setPath( updatedFilePathFromPathId( filePath->path(), &pathListMapper ) );
|
||||
}
|
||||
|
||||
for ( auto summaryCase : project->allSummaryCases() )
|
||||
{
|
||||
if ( summaryCase->displayNameType() == RimCaseDisplayNameTools::DisplayName::CUSTOM )
|
||||
{
|
||||
auto variableName = summaryCase->displayCaseName();
|
||||
|
||||
bool isFound = false;
|
||||
QString variableValue = pathListMapper.valueForVariable( variableName, &isFound );
|
||||
if ( isFound )
|
||||
{
|
||||
summaryCase->setCustomCaseName( variableValue );
|
||||
}
|
||||
else if ( variableName.contains( RiaVariableMapper::postfixName() + RiaVariableMapper::variableToken() ) )
|
||||
{
|
||||
// The variable name is not found in the variable list, but the name indicates a variable. Reset
|
||||
// to full case name.
|
||||
summaryCase->setDisplayNameOption( RimCaseDisplayNameTools::DisplayName::FULL_CASE_NAME );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for ( auto gridCase : project->allGridCases() )
|
||||
{
|
||||
if ( gridCase->displayNameType() == RimCaseDisplayNameTools::DisplayName::CUSTOM )
|
||||
{
|
||||
auto variableName = gridCase->caseUserDescription();
|
||||
|
||||
bool isFound = false;
|
||||
QString variableValue = pathListMapper.valueForVariable( variableName, &isFound );
|
||||
if ( isFound )
|
||||
{
|
||||
gridCase->setCustomCaseName( variableValue );
|
||||
}
|
||||
else if ( variableName.contains( RiaVariableMapper::postfixName() + RiaVariableMapper::variableToken() ) )
|
||||
{
|
||||
// The variable name is not found in the variable list, but the name indicates a variable. Reset
|
||||
// to full case name.
|
||||
gridCase->setDisplayNameType( RimCaseDisplayNameTools::DisplayName::FULL_CASE_NAME );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiaProjectFileTools::updatedFilePathFromPathId( QString filePath, RiaVariableMapper* pathListMapper )
|
||||
{
|
||||
if ( pathListMapper )
|
||||
{
|
||||
QString pathIdCandidate = filePath.trimmed();
|
||||
QStringList pathIdComponents = pathIdCandidate.split( RiaVariableMapper::variableToken() );
|
||||
|
||||
if ( pathIdComponents.size() == 3 && pathIdComponents[0].size() == 0 && pathIdComponents[1].size() > 0 &&
|
||||
pathIdComponents[2].size() == 0 )
|
||||
{
|
||||
bool isFound = false;
|
||||
QString path = pathListMapper->valueForVariable( pathIdCandidate, &isFound );
|
||||
if ( isFound )
|
||||
{
|
||||
return path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return filePath;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaProjectFileTools::decodeVersionString( const QString& projectFileVersion, int* majorVersion, int* minorVersion, int* patch, int* developmentId )
|
||||
{
|
||||
if ( projectFileVersion.isEmpty() ) return;
|
||||
|
||||
QStringList subStrings = projectFileVersion.split( "." );
|
||||
|
||||
if ( !subStrings.empty() )
|
||||
{
|
||||
*majorVersion = subStrings[0].toInt();
|
||||
}
|
||||
|
||||
if ( subStrings.size() > 1 )
|
||||
{
|
||||
*minorVersion = subStrings[1].toInt();
|
||||
}
|
||||
|
||||
if ( subStrings.size() > 2 )
|
||||
{
|
||||
QString candidate = subStrings[2];
|
||||
QString candidateDigitsOnly = internal::stringOfDigits( candidate );
|
||||
|
||||
*patch = candidateDigitsOnly.toInt();
|
||||
}
|
||||
|
||||
if ( subStrings.size() > 3 )
|
||||
{
|
||||
QString candidate = subStrings.back();
|
||||
QString candidateDigitsOnly = internal::stringOfDigits( candidate );
|
||||
|
||||
*developmentId = candidateDigitsOnly.toInt();
|
||||
}
|
||||
}
|
||||
@@ -26,65 +26,59 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
class RiaVariableMapper;
|
||||
class RimProject;
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//==================================================================================================
|
||||
class RiaProjectFileTools
|
||||
namespace RiaProjectFileTools
|
||||
{
|
||||
public:
|
||||
static bool isCandidateVersionNewerThanOther( const QString& candidateProjectFileVersion, const QString& otherProjectFileVersion );
|
||||
bool isCandidateVersionNewerThanOther( const QString& candidateProjectFileVersion, const QString& otherProjectFileVersion );
|
||||
|
||||
// Public to be able to unit test function, not intended to be used
|
||||
static void decodeVersionString( const QString& projectFileVersion, int* majorVersion, int* minorVersion, int* patch, int* developmentId );
|
||||
template <typename T>
|
||||
std::vector<T*> writableFieldContent( const caf::PdmObjectHandle* object )
|
||||
{
|
||||
if ( !object ) return {};
|
||||
|
||||
template <typename T>
|
||||
static std::vector<T*> writableFieldContent( const caf::PdmObjectHandle* object )
|
||||
std::vector<T*> fieldContents;
|
||||
|
||||
std::vector<caf::PdmObjectHandle*> children;
|
||||
for ( const auto& field : object->fields() )
|
||||
{
|
||||
if ( !object ) return {};
|
||||
if ( !field ) continue;
|
||||
|
||||
std::vector<T*> fieldContents;
|
||||
if ( field->xmlCapability() && !field->xmlCapability()->isIOWritable() ) continue;
|
||||
|
||||
std::vector<caf::PdmObjectHandle*> children;
|
||||
for ( const auto& field : object->fields() )
|
||||
caf::PdmField<T>* typedField = dynamic_cast<caf::PdmField<T>*>( field );
|
||||
if ( typedField ) fieldContents.push_back( &typedField->v() );
|
||||
|
||||
caf::PdmField<std::vector<T>>* typedFieldInVector = dynamic_cast<caf::PdmField<std::vector<T>>*>( field );
|
||||
if ( typedFieldInVector )
|
||||
{
|
||||
if ( !field ) continue;
|
||||
|
||||
if ( field->xmlCapability() && !field->xmlCapability()->isIOWritable() ) continue;
|
||||
|
||||
caf::PdmField<T>* typedField = dynamic_cast<caf::PdmField<T>*>( field );
|
||||
if ( typedField ) fieldContents.push_back( &typedField->v() );
|
||||
|
||||
caf::PdmField<std::vector<T>>* typedFieldInVector = dynamic_cast<caf::PdmField<std::vector<T>>*>( field );
|
||||
if ( typedFieldInVector )
|
||||
for ( T& typedFieldFromVector : typedFieldInVector->v() )
|
||||
{
|
||||
for ( T& typedFieldFromVector : typedFieldInVector->v() )
|
||||
{
|
||||
fieldContents.push_back( &typedFieldFromVector );
|
||||
}
|
||||
fieldContents.push_back( &typedFieldFromVector );
|
||||
}
|
||||
|
||||
auto other = field->children();
|
||||
children.insert( children.end(), other.begin(), other.end() );
|
||||
}
|
||||
|
||||
for ( const auto& child : children )
|
||||
{
|
||||
auto childObjects = writableFieldContent<T>( child );
|
||||
fieldContents.insert( fieldContents.end(), childObjects.begin(), childObjects.end() );
|
||||
}
|
||||
|
||||
return fieldContents;
|
||||
auto other = field->children();
|
||||
children.insert( children.end(), other.begin(), other.end() );
|
||||
}
|
||||
|
||||
private:
|
||||
static bool isCandidateNewerThanOther( int candidateMajorVersion,
|
||||
int candidateMinorVersion,
|
||||
int candidatePatchNumber,
|
||||
int candidateDevelopmentId,
|
||||
int otherMajorVersion,
|
||||
int otherMinorVersion,
|
||||
int otherPatchNumber,
|
||||
int otherDevelopmentId );
|
||||
for ( const auto& child : children )
|
||||
{
|
||||
auto childObjects = writableFieldContent<T>( child );
|
||||
fieldContents.insert( fieldContents.end(), childObjects.begin(), childObjects.end() );
|
||||
}
|
||||
|
||||
static QString stringOfDigits( const QString& string );
|
||||
};
|
||||
return fieldContents;
|
||||
}
|
||||
|
||||
QString transferPathsToGlobalPathList( RimProject* project );
|
||||
void distributePathsFromGlobalPathList( RimProject* project, const QString& pathList );
|
||||
QString updatedFilePathFromPathId( QString filePath, RiaVariableMapper* pathListMapper );
|
||||
|
||||
// Public to be able to unit test function
|
||||
void decodeVersionString( const QString& projectFileVersion, int* majorVersion, int* minorVersion, int* patch, int* developmentId );
|
||||
}; // namespace RiaProjectFileTools
|
||||
@@ -120,6 +120,8 @@ void RicImportEnsembleFeature::onActionTriggered( bool isChecked )
|
||||
RiaSummaryTools::summaryCaseMainCollection()->updateConnectedEditors();
|
||||
}
|
||||
}
|
||||
|
||||
RiuPlotMainWindowTools::showPlotMainWindow();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -76,6 +76,9 @@ void RicReplaceSummaryEnsembleFeature::onActionTriggered( bool isChecked )
|
||||
|
||||
collection->updateFileSetNames();
|
||||
collection->updateAllRequiredEditors();
|
||||
|
||||
RiaLogging::info( QString( "Completed replace ensemble, new name is '" ) + summaryEnsemble->name() + "'" );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -540,12 +540,6 @@ void RifEclipseInputFileTools::saveFault( QTextStream&
|
||||
RiaLogging::error( QString( "Fault name '%1' contains spaces" ).arg( faultName ) );
|
||||
return;
|
||||
}
|
||||
else if ( faultName.length() > 8 )
|
||||
{
|
||||
// Keep going anyway, eclipse files sometimes have longer than
|
||||
// the specified 8 characters in the name without Eclipse complaining
|
||||
RiaLogging::warning( QString( "Fault name '%1' is longer than 8 characters" ).arg( faultName ) );
|
||||
}
|
||||
|
||||
std::vector<RigFault::CellAndFace> faultCellAndFaces;
|
||||
|
||||
@@ -1633,12 +1627,6 @@ void RifEclipseInputFileTools::readFaults( QFile& data, qint64 filePos, cvf::Col
|
||||
errorMessages.insert( QString( "Fault name '%1' contains spaces" ).arg( faultName ) );
|
||||
continue;
|
||||
}
|
||||
else if ( faultName.length() > 8 )
|
||||
{
|
||||
// Keep going anyway, eclipse files sometimes have longer than
|
||||
// the specified 8 characters in the name without Eclipse complaining
|
||||
warningMessages.insert( QString( "Fault name '%1' is longer than 8 characters" ).arg( faultName ) );
|
||||
}
|
||||
|
||||
int i1, i2, j1, j2, k1, k2;
|
||||
i1 = entries[1].toInt();
|
||||
|
||||
@@ -259,13 +259,15 @@ void RifReaderFmuRft::importData()
|
||||
};
|
||||
|
||||
// The text file name can be either <wellName>_<measurementId>.txt or <wellName>.txt
|
||||
QString txtFile = findFileName( wellName, "txt", measurementId, dir );
|
||||
auto locations = importLocations( dir.absoluteFilePath( txtFile ) );
|
||||
QString txtFile = findFileName( wellName, "txt", measurementId, dir );
|
||||
if ( !QFile::exists( txtFile ) ) continue;
|
||||
|
||||
auto locations = importLocations( dir.absoluteFilePath( txtFile ) );
|
||||
if ( locations.empty() ) continue;
|
||||
|
||||
// The observation file name can be either <wellName>_<measurementId>.obs or <wellName>.obs
|
||||
QString observationFileName = findFileName( wellName, "obs", measurementId, dir );
|
||||
if ( observationFileName.isEmpty() ) continue;
|
||||
if ( !QFile::exists( observationFileName ) ) continue;
|
||||
|
||||
for ( const auto& wellDate : wellDates )
|
||||
{
|
||||
|
||||
@@ -30,9 +30,14 @@ CAF_PDM_SOURCE_INIT( RimObservedFmuRftData, "ObservedFmuRftData" );
|
||||
RimObservedFmuRftData::RimObservedFmuRftData()
|
||||
{
|
||||
CAF_PDM_InitObject( "Observed FMU Data", ":/ObservedRFTDataFile16x16.png" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_directoryPath, "Directory", "Directory" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_directoryPath, "ObservedFolder", "Directory" );
|
||||
m_directoryPath.uiCapability()->setUiReadOnly( true );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_directoryPath_OBSOLETE, "Directory", "Directory" );
|
||||
m_directoryPath_OBSOLETE.uiCapability()->setUiReadOnly( true );
|
||||
m_directoryPath_OBSOLETE.xmlCapability()->setIOWritable( false );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_wells, "Wells", "Wells" );
|
||||
m_wells.xmlCapability()->disableIO();
|
||||
m_wells.uiCapability()->setUiReadOnly( true );
|
||||
@@ -52,7 +57,7 @@ void RimObservedFmuRftData::setDirectoryPath( const QString& path )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimObservedFmuRftData::createRftReaderInterface()
|
||||
{
|
||||
m_fmuRftReader = new RifReaderFmuRft( m_directoryPath );
|
||||
m_fmuRftReader = new RifReaderFmuRft( m_directoryPath().path() );
|
||||
m_fmuRftReader->importData();
|
||||
}
|
||||
|
||||
@@ -109,3 +114,14 @@ std::vector<QString> RimObservedFmuRftData::labels( const RifEclipseRftAddress&
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimObservedFmuRftData::initAfterRead()
|
||||
{
|
||||
if ( m_directoryPath().path().isEmpty() )
|
||||
{
|
||||
m_directoryPath = m_directoryPath_OBSOLETE();
|
||||
}
|
||||
}
|
||||
@@ -40,9 +40,13 @@ public:
|
||||
std::vector<QString> wells() const;
|
||||
std::vector<QString> labels( const RifEclipseRftAddress& rftAddress );
|
||||
|
||||
protected:
|
||||
void initAfterRead() override;
|
||||
|
||||
private:
|
||||
cvf::ref<RifReaderFmuRft> m_fmuRftReader;
|
||||
|
||||
caf::PdmField<QString> m_directoryPath;
|
||||
caf::PdmField<caf::FilePath> m_directoryPath;
|
||||
caf::PdmField<QString> m_directoryPath_OBSOLETE;
|
||||
caf::PdmProxyValueField<std::vector<QString>> m_wells;
|
||||
};
|
||||
@@ -27,12 +27,9 @@
|
||||
#include "RiaPreferences.h"
|
||||
#include "RiaProjectBackupTools.h"
|
||||
#include "RiaProjectFileTools.h"
|
||||
#include "RiaTextStringTools.h"
|
||||
#include "RiaVersionInfo.h"
|
||||
|
||||
#include "RicfCommandObject.h"
|
||||
#include "RigEclipseCaseData.h"
|
||||
#include "RigGridBase.h"
|
||||
|
||||
#include "Cloud/RimCloudDataSourceCollection.h"
|
||||
#include "ContourMap/RimEclipseContourMapViewCollection.h"
|
||||
@@ -45,7 +42,6 @@
|
||||
#include "RimAnalysisPlotCollection.h"
|
||||
#include "RimAnnotationCollection.h"
|
||||
#include "RimAnnotationInViewCollection.h"
|
||||
#include "RimCalcScript.h"
|
||||
#include "RimCase.h"
|
||||
#include "RimCaseCollection.h"
|
||||
#include "RimColorLegendCollection.h"
|
||||
@@ -85,21 +81,18 @@
|
||||
#include "RimSeismicView.h"
|
||||
#include "RimSeismicViewCollection.h"
|
||||
#include "RimStimPlanModelPlotCollection.h"
|
||||
#include "RimSummaryCalculation.h"
|
||||
#include "RimSummaryCalculationCollection.h"
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RimSummaryCaseMainCollection.h"
|
||||
#include "RimSummaryEnsemble.h"
|
||||
#include "RimSummaryMultiPlotCollection.h"
|
||||
#include "RimSummaryTableCollection.h"
|
||||
#include "RimSurfaceCollection.h"
|
||||
#include "RimTools.h"
|
||||
#include "RimUserDefinedPolylinesAnnotation.h"
|
||||
#include "RimValveTemplate.h"
|
||||
#include "RimValveTemplateCollection.h"
|
||||
#include "RimViewLinker.h"
|
||||
#include "RimViewLinkerCollection.h"
|
||||
#include "RimViewWindow.h"
|
||||
#include "RimWellLogLasFile.h"
|
||||
#include "RimWellLogPlotCollection.h"
|
||||
#include "RimWellPath.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
@@ -108,32 +101,22 @@
|
||||
#include "VerticalFlowPerformance/RimVfpDataCollection.h"
|
||||
#include "VerticalFlowPerformance/RimVfpPlotCollection.h"
|
||||
|
||||
#include "Tools/RiaVariableMapper.h"
|
||||
|
||||
#ifdef USE_QTCHARTS
|
||||
#include "RimEnsembleFractureStatisticsPlot.h"
|
||||
#include "RimEnsembleFractureStatisticsPlotCollection.h"
|
||||
#include "RimGridStatisticsPlot.h"
|
||||
#include "RimGridStatisticsPlotCollection.h"
|
||||
#endif
|
||||
|
||||
#include "RiuMainWindow.h"
|
||||
#include "RiuPlotMainWindow.h"
|
||||
|
||||
#include "OctaveScriptCommands/RicExecuteScriptForCasesFeature.h"
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
#include "cafCmdFeatureManager.h"
|
||||
#include "cafCmdFeatureMenuBuilder.h"
|
||||
#include "cafPdmObjectScriptingCapability.h"
|
||||
#include "cafPdmUiTreeOrdering.h"
|
||||
#include "cvfBoundingBox.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QMenu>
|
||||
#include <QFile>
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimProject, "ResInsightProject" );
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -310,7 +293,7 @@ void RimProject::close()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimProject::updatesAfterProjectFileIsRead()
|
||||
{
|
||||
distributePathsFromGlobalPathList();
|
||||
RiaProjectFileTools::distributePathsFromGlobalPathList( this, m_globalPathList() );
|
||||
|
||||
// Create an empty oil field in case the project did not contain one
|
||||
if ( oilFields.empty() )
|
||||
@@ -473,7 +456,7 @@ RimMainPlotCollection* RimProject::mainPlotCollection() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimProject::writeProjectFile()
|
||||
{
|
||||
transferPathsToGlobalPathList();
|
||||
m_globalPathList = RiaProjectFileTools::transferPathsToGlobalPathList( this );
|
||||
|
||||
QFile xmlFile( fileName() );
|
||||
if ( !xmlFile.open( QIODevice::WriteOnly | QIODevice::Text ) ) return false;
|
||||
@@ -488,7 +471,7 @@ bool RimProject::writeProjectFile()
|
||||
RiaProjectBackupTools::appendTextToDatabase( backupFilename, maximumRecordCount, content );
|
||||
}
|
||||
|
||||
distributePathsFromGlobalPathList();
|
||||
RiaProjectFileTools::distributePathsFromGlobalPathList( this, m_globalPathList() );
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1562,152 +1545,3 @@ void RimProject::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, Q
|
||||
|
||||
uiTreeOrdering.skipRemainingChildren( true );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimProject::transferPathsToGlobalPathList()
|
||||
{
|
||||
RiaVariableMapper variableMapper( m_globalPathList() );
|
||||
|
||||
for ( caf::FilePath* filePath : allFilePaths() )
|
||||
{
|
||||
QString path = filePath->path();
|
||||
if ( !path.isEmpty() )
|
||||
{
|
||||
QString pathId = variableMapper.addPathAndGetId( path );
|
||||
filePath->setPath( pathId );
|
||||
}
|
||||
}
|
||||
|
||||
for ( auto summaryCase : allSummaryCases() )
|
||||
{
|
||||
if ( summaryCase->displayNameType() == RimCaseDisplayNameTools::DisplayName::CUSTOM )
|
||||
{
|
||||
// At this point, after the replace of variables into caf::FilePath objects, the variable name is
|
||||
// stored in the summary case object. Read out the variable name and append "_name" for custom
|
||||
// summary variables.
|
||||
|
||||
QString variableName = summaryCase->summaryHeaderFilename();
|
||||
variableName = variableName.remove( RiaVariableMapper::variableToken() );
|
||||
|
||||
variableName = RiaVariableMapper::variableToken() + variableName + RiaVariableMapper::postfixName() +
|
||||
RiaVariableMapper::variableToken();
|
||||
|
||||
QString variableValue = summaryCase->displayCaseName();
|
||||
variableMapper.addVariable( variableName, variableValue );
|
||||
|
||||
summaryCase->setCustomCaseName( variableName );
|
||||
}
|
||||
}
|
||||
|
||||
for ( auto gridCase : allGridCases() )
|
||||
{
|
||||
if ( gridCase->displayNameType() == RimCaseDisplayNameTools::DisplayName::CUSTOM )
|
||||
{
|
||||
// At this point, after the replace of variables into caf::FilePath objects, the variable name is
|
||||
// stored in the summary case object. Read out the variable name and append "_name" for custom
|
||||
// summary variables.
|
||||
|
||||
QString variableName = gridCase->gridFileName();
|
||||
variableName = variableName.remove( RiaVariableMapper::variableToken() );
|
||||
|
||||
variableName = RiaVariableMapper::variableToken() + variableName + RiaVariableMapper::postfixName() +
|
||||
RiaVariableMapper::variableToken();
|
||||
|
||||
QString variableValue = gridCase->caseUserDescription();
|
||||
variableMapper.addVariable( variableName, variableValue );
|
||||
|
||||
gridCase->setCustomCaseName( variableName );
|
||||
}
|
||||
}
|
||||
|
||||
variableMapper.replaceVariablesInValues();
|
||||
|
||||
m_globalPathList = variableMapper.variableTableAsText();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimProject::updatedFilePathFromPathId( QString filePath, RiaVariableMapper* pathListMapper /*=nullptr*/ ) const
|
||||
{
|
||||
std::unique_ptr<RiaVariableMapper> internalMapper;
|
||||
|
||||
if ( pathListMapper == nullptr )
|
||||
{
|
||||
internalMapper = std::make_unique<RiaVariableMapper>( m_globalPathList );
|
||||
pathListMapper = internalMapper.get();
|
||||
}
|
||||
|
||||
QString returnValue = filePath;
|
||||
QString pathIdCandidate = filePath.trimmed();
|
||||
QStringList pathIdComponents = pathIdCandidate.split( RiaVariableMapper::variableToken() );
|
||||
|
||||
if ( pathIdComponents.size() == 3 && pathIdComponents[0].size() == 0 && pathIdComponents[1].size() > 0 && pathIdComponents[2].size() == 0 )
|
||||
{
|
||||
bool isFound = false;
|
||||
QString path = pathListMapper->valueForVariable( pathIdCandidate, &isFound );
|
||||
if ( isFound )
|
||||
{
|
||||
returnValue = path;
|
||||
}
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimProject::distributePathsFromGlobalPathList()
|
||||
{
|
||||
RiaVariableMapper pathListMapper( m_globalPathList() );
|
||||
|
||||
for ( caf::FilePath* filePath : allFilePaths() )
|
||||
{
|
||||
filePath->setPath( updatedFilePathFromPathId( filePath->path(), &pathListMapper ) );
|
||||
}
|
||||
|
||||
for ( auto summaryCase : allSummaryCases() )
|
||||
{
|
||||
if ( summaryCase->displayNameType() == RimCaseDisplayNameTools::DisplayName::CUSTOM )
|
||||
{
|
||||
auto variableName = summaryCase->displayCaseName();
|
||||
|
||||
bool isFound = false;
|
||||
QString variableValue = pathListMapper.valueForVariable( variableName, &isFound );
|
||||
if ( isFound )
|
||||
{
|
||||
summaryCase->setCustomCaseName( variableValue );
|
||||
}
|
||||
else if ( variableName.contains( RiaVariableMapper::postfixName() + RiaVariableMapper::variableToken() ) )
|
||||
{
|
||||
// The variable name is not found in the variable list, but the name indicates a variable. Reset
|
||||
// to full case name.
|
||||
summaryCase->setDisplayNameOption( RimCaseDisplayNameTools::DisplayName::FULL_CASE_NAME );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for ( auto gridCase : allGridCases() )
|
||||
{
|
||||
if ( gridCase->displayNameType() == RimCaseDisplayNameTools::DisplayName::CUSTOM )
|
||||
{
|
||||
auto variableName = gridCase->caseUserDescription();
|
||||
|
||||
bool isFound = false;
|
||||
QString variableValue = pathListMapper.valueForVariable( variableName, &isFound );
|
||||
if ( isFound )
|
||||
{
|
||||
gridCase->setCustomCaseName( variableValue );
|
||||
}
|
||||
else if ( variableName.contains( RiaVariableMapper::postfixName() + RiaVariableMapper::variableToken() ) )
|
||||
{
|
||||
// The variable name is not found in the variable list, but the name indicates a variable. Reset
|
||||
// to full case name.
|
||||
gridCase->setDisplayNameType( RimCaseDisplayNameTools::DisplayName::FULL_CASE_NAME );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,8 +30,6 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
class RiaVariableMapper;
|
||||
|
||||
class RigEclipseCaseData;
|
||||
class RigGridManager;
|
||||
class RigMainGrid;
|
||||
@@ -204,11 +202,6 @@ protected:
|
||||
|
||||
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override;
|
||||
|
||||
private:
|
||||
void transferPathsToGlobalPathList();
|
||||
void distributePathsFromGlobalPathList();
|
||||
QString updatedFilePathFromPathId( QString filePath, RiaVariableMapper* pathListMapper = nullptr ) const;
|
||||
|
||||
private:
|
||||
caf::PdmChildField<RimMainPlotCollection*> m_mainPlotCollection;
|
||||
caf::PdmChildField<RimQuickAccessCollection*> m_pinnedFieldCollection;
|
||||
|
||||
Reference in new issue
Block a user