mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-26 15:10:22 -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();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user