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:
Magne Sjaastad authored and GitHub committed 2025-06-03 14:29:44 +02:00
1 parent 52b000cc57
commit 88e0aad8cf
10 files changed
+311 -319

No files matched your search

@@ -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 );
}
}
}
}