mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#6367 Improve the way we automatically name ensembles and cases
This commit is contained in:
parent
f38d119cc8
commit
7cf24d02ff
@ -19,7 +19,11 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "RiaFilePathTools.h"
|
#include "RiaFilePathTools.h"
|
||||||
|
|
||||||
|
#include "cafAssert.h"
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -173,3 +177,170 @@ QString RiaFilePathTools::rootSearchPathFromSearchFilter( const QString& searchF
|
|||||||
|
|
||||||
return pathPartList.join( separator() );
|
return pathPartList.join( separator() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
QStringList RiaFilePathTools::splitPathIntoComponents( const QString& inputPath, bool splitExtensionIntoSeparateEntry )
|
||||||
|
{
|
||||||
|
auto path = QDir::cleanPath( inputPath );
|
||||||
|
|
||||||
|
QStringList components;
|
||||||
|
|
||||||
|
QDir dir( path );
|
||||||
|
|
||||||
|
QFileInfo fileInfo( path );
|
||||||
|
|
||||||
|
if ( splitExtensionIntoSeparateEntry )
|
||||||
|
{
|
||||||
|
QString extension = fileInfo.completeSuffix();
|
||||||
|
path = path.replace( QString( ".%1" ).arg( extension ), "" );
|
||||||
|
components.push_front( extension );
|
||||||
|
components.push_front( fileInfo.baseName() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
components.push_back( fileInfo.fileName() );
|
||||||
|
}
|
||||||
|
|
||||||
|
while ( dir.cdUp() )
|
||||||
|
{
|
||||||
|
components.push_front( dir.dirName() );
|
||||||
|
}
|
||||||
|
return components;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct PathNode
|
||||||
|
{
|
||||||
|
QString name;
|
||||||
|
PathNode* parent;
|
||||||
|
std::list<std::unique_ptr<PathNode>> children;
|
||||||
|
QString fileName;
|
||||||
|
|
||||||
|
PathNode( const QString& name, PathNode* parent )
|
||||||
|
: name( name )
|
||||||
|
, parent( parent )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void addToPathTree( PathNode* node, QStringList pathComponents, const QString& fileName )
|
||||||
|
{
|
||||||
|
CAF_ASSERT( node );
|
||||||
|
if ( !pathComponents.empty() )
|
||||||
|
{
|
||||||
|
QString pathComponent = pathComponents.front();
|
||||||
|
pathComponents.pop_front();
|
||||||
|
|
||||||
|
for ( auto it = node->children.begin(); it != node->children.end(); ++it )
|
||||||
|
{
|
||||||
|
if ( it->get()->name == pathComponent )
|
||||||
|
{
|
||||||
|
addToPathTree( it->get(), pathComponents, fileName );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
node->children.push_back( std::make_unique<PathNode>( pathComponent, node ) );
|
||||||
|
addToPathTree( node->children.back().get(), pathComponents, fileName );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Reached leaf, just set file name
|
||||||
|
node->fileName = fileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void trimTree( PathNode* node )
|
||||||
|
{
|
||||||
|
if ( node->children.size() == 1u )
|
||||||
|
{
|
||||||
|
// Unnecessary level. Remove it.
|
||||||
|
std::unique_ptr<PathNode> singleChildNode = std::move( node->children.front() );
|
||||||
|
node->children.clear();
|
||||||
|
node->children.swap( singleChildNode->children );
|
||||||
|
node->fileName = singleChildNode->fileName;
|
||||||
|
|
||||||
|
// Re-parent children
|
||||||
|
for ( auto it = node->children.begin(); it != node->children.end(); ++it )
|
||||||
|
{
|
||||||
|
it->get()->parent = node;
|
||||||
|
}
|
||||||
|
trimTree( node );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for ( auto it = node->children.begin(); it != node->children.end(); ++it )
|
||||||
|
{
|
||||||
|
trimTree( it->get() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void extractLeafNodes( PathNode* node, std::list<PathNode*>* leafNodes )
|
||||||
|
{
|
||||||
|
if ( node->children.empty() )
|
||||||
|
{
|
||||||
|
leafNodes->push_back( node );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for ( auto it = node->children.begin(); it != node->children.end(); ++it )
|
||||||
|
{
|
||||||
|
extractLeafNodes( it->get(), leafNodes );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void pathToNode( PathNode* node, QStringList* path )
|
||||||
|
{
|
||||||
|
CAF_ASSERT( path );
|
||||||
|
|
||||||
|
if ( node != nullptr )
|
||||||
|
{
|
||||||
|
if ( !node->name.isEmpty() ) path->push_front( node->name );
|
||||||
|
pathToNode( node->parent, path );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
/// Takes a list of file paths and returns a map with the key components that separate the path
|
||||||
|
/// from the others.
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
std::map<QString, QStringList> RiaFilePathTools::keyPathComponentsForEachFilePath( const QStringList& filePaths )
|
||||||
|
{
|
||||||
|
std::map<QString, QStringList> allComponents;
|
||||||
|
|
||||||
|
std::multiset<QString> allPathComponents;
|
||||||
|
for ( auto fileName : filePaths )
|
||||||
|
{
|
||||||
|
QStringList pathComponentsForFile = splitPathIntoComponents( fileName, true );
|
||||||
|
allComponents[fileName] = pathComponentsForFile;
|
||||||
|
|
||||||
|
for ( auto pathComponent : pathComponentsForFile )
|
||||||
|
{
|
||||||
|
allPathComponents.insert( pathComponent );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto topNode = std::make_unique<PathNode>( "", nullptr );
|
||||||
|
|
||||||
|
for ( auto keyComponentsPair : allComponents )
|
||||||
|
{
|
||||||
|
addToPathTree( topNode.get(), keyComponentsPair.second, keyComponentsPair.first );
|
||||||
|
}
|
||||||
|
|
||||||
|
trimTree( topNode.get() );
|
||||||
|
std::list<PathNode*> leafNodes;
|
||||||
|
extractLeafNodes( topNode.get(), &leafNodes );
|
||||||
|
|
||||||
|
std::map<QString, QStringList> keyComponents;
|
||||||
|
for ( PathNode* node : leafNodes )
|
||||||
|
{
|
||||||
|
QStringList path;
|
||||||
|
pathToNode( node, &path );
|
||||||
|
keyComponents[node->fileName] = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
return keyComponents;
|
||||||
|
}
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QStringList>
|
||||||
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
@ -41,4 +43,8 @@ public:
|
|||||||
static std::pair<QString, QString> toFolderAndFileName( const QString& absFileName );
|
static std::pair<QString, QString> toFolderAndFileName( const QString& absFileName );
|
||||||
static QString removeDuplicatePathSeparators( const QString& path );
|
static QString removeDuplicatePathSeparators( const QString& path );
|
||||||
static QString rootSearchPathFromSearchFilter( const QString& searchFilter );
|
static QString rootSearchPathFromSearchFilter( const QString& searchFilter );
|
||||||
|
|
||||||
|
static QStringList splitPathIntoComponents( const QString& path, bool splitExtensionIntoSeparateEntry = false );
|
||||||
|
|
||||||
|
static std::map<QString, QStringList> keyPathComponentsForEachFilePath( const QStringList& filePaths );
|
||||||
};
|
};
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
@ -55,3 +56,29 @@ QString RiaTextStringTools::trimAndRemoveDoubleSpaces( const QString& s )
|
|||||||
|
|
||||||
return trimmed;
|
return trimmed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
QString RiaTextStringTools::findCommonRoot( const QStringList& stringList )
|
||||||
|
{
|
||||||
|
QString root = stringList.front();
|
||||||
|
for ( const auto& item : stringList )
|
||||||
|
{
|
||||||
|
if ( root.length() > item.length() )
|
||||||
|
{
|
||||||
|
root.truncate( item.length() );
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( int i = 0; i < root.length(); ++i )
|
||||||
|
{
|
||||||
|
if ( root[i] != item[i] )
|
||||||
|
{
|
||||||
|
root.truncate( i );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
class QString;
|
class QString;
|
||||||
|
class QStringList;
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
@ -27,4 +28,5 @@ namespace RiaTextStringTools
|
|||||||
{
|
{
|
||||||
bool compare( const QString& expected, const QString& actual );
|
bool compare( const QString& expected, const QString& actual );
|
||||||
QString trimAndRemoveDoubleSpaces( const QString& s );
|
QString trimAndRemoveDoubleSpaces( const QString& s );
|
||||||
|
QString findCommonRoot( const QStringList& stringList );
|
||||||
} // namespace RiaTextStringTools
|
} // namespace RiaTextStringTools
|
||||||
|
@ -19,7 +19,9 @@
|
|||||||
#include "RicImportEnsembleFeature.h"
|
#include "RicImportEnsembleFeature.h"
|
||||||
|
|
||||||
#include "RiaApplication.h"
|
#include "RiaApplication.h"
|
||||||
|
#include "RiaFilePathTools.h"
|
||||||
#include "RiaPreferences.h"
|
#include "RiaPreferences.h"
|
||||||
|
#include "RiaTextStringTools.h"
|
||||||
|
|
||||||
#include "RicCreateSummaryCaseCollectionFeature.h"
|
#include "RicCreateSummaryCaseCollectionFeature.h"
|
||||||
#include "RicImportSummaryCasesFeature.h"
|
#include "RicImportSummaryCasesFeature.h"
|
||||||
@ -44,8 +46,13 @@
|
|||||||
#include "SummaryPlotCommands/RicNewSummaryPlotFeature.h"
|
#include "SummaryPlotCommands/RicNewSummaryPlotFeature.h"
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QFileInfo>
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
|
#include <set>
|
||||||
|
|
||||||
CAF_CMD_SOURCE_INIT( RicImportEnsembleFeature, "RicImportEnsembleFeature" );
|
CAF_CMD_SOURCE_INIT( RicImportEnsembleFeature, "RicImportEnsembleFeature" );
|
||||||
|
|
||||||
@ -69,7 +76,14 @@ void RicImportEnsembleFeature::onActionTriggered( bool isChecked )
|
|||||||
|
|
||||||
if ( fileNames.isEmpty() ) return;
|
if ( fileNames.isEmpty() ) return;
|
||||||
|
|
||||||
QString ensembleName = askForEnsembleName();
|
QString root = commonRoot( fileNames );
|
||||||
|
|
||||||
|
QRegularExpression trimRe( "[^a-zA-Z0-9]+$" );
|
||||||
|
QString trimmedRoot = root.replace( trimRe, "" );
|
||||||
|
QString suggestion = trimmedRoot;
|
||||||
|
if ( suggestion.isEmpty() ) suggestion = "Ensemble";
|
||||||
|
|
||||||
|
QString ensembleName = askForEnsembleName( trimmedRoot );
|
||||||
if ( ensembleName.isEmpty() ) return;
|
if ( ensembleName.isEmpty() ) return;
|
||||||
|
|
||||||
std::vector<RimSummaryCase*> cases;
|
std::vector<RimSummaryCase*> cases;
|
||||||
@ -79,6 +93,11 @@ void RicImportEnsembleFeature::onActionTriggered( bool isChecked )
|
|||||||
RimSummaryCaseCollection* ensemble =
|
RimSummaryCaseCollection* ensemble =
|
||||||
RicCreateSummaryCaseCollectionFeature::groupSummaryCases( cases, ensembleName, true );
|
RicCreateSummaryCaseCollectionFeature::groupSummaryCases( cases, ensembleName, true );
|
||||||
|
|
||||||
|
for ( auto summaryCase : ensemble->allSummaryCases() )
|
||||||
|
{
|
||||||
|
summaryCase->updateAutoShortName();
|
||||||
|
}
|
||||||
|
|
||||||
if ( ensemble )
|
if ( ensemble )
|
||||||
{
|
{
|
||||||
RicNewSummaryEnsembleCurveSetFeature::createPlotForCurveSetsAndUpdate( {ensemble} );
|
RicNewSummaryEnsembleCurveSetFeature::createPlotForCurveSetsAndUpdate( {ensemble} );
|
||||||
@ -105,21 +124,45 @@ void RicImportEnsembleFeature::setupActionLook( QAction* actionToSetup )
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
QString RicImportEnsembleFeature::askForEnsembleName()
|
QString RicImportEnsembleFeature::askForEnsembleName( const QString& suggestion )
|
||||||
{
|
{
|
||||||
RimProject* project = RimProject::current();
|
RimProject* project = RimProject::current();
|
||||||
std::vector<RimSummaryCaseCollection*> groups = project->summaryGroups();
|
std::vector<RimSummaryCaseCollection*> groups = project->summaryGroups();
|
||||||
int ensembleCount = std::count_if( groups.begin(), groups.end(), []( RimSummaryCaseCollection* group ) {
|
int ensemblesStartingWithRoot =
|
||||||
return group->isEnsemble();
|
std::count_if( groups.begin(), groups.end(), [suggestion]( RimSummaryCaseCollection* group ) {
|
||||||
} );
|
return group->isEnsemble() && group->name().startsWith( suggestion );
|
||||||
ensembleCount += 1;
|
} );
|
||||||
|
|
||||||
QInputDialog dialog;
|
QInputDialog dialog;
|
||||||
dialog.setInputMode( QInputDialog::TextInput );
|
dialog.setInputMode( QInputDialog::TextInput );
|
||||||
dialog.setWindowTitle( "Ensemble Name" );
|
dialog.setWindowTitle( "Ensemble Name" );
|
||||||
dialog.setLabelText( "Ensemble Name" );
|
dialog.setLabelText( "Ensemble Name" );
|
||||||
dialog.setTextValue( QString( "Ensemble %1" ).arg( ensembleCount ) );
|
if ( ensemblesStartingWithRoot > 0 )
|
||||||
|
{
|
||||||
|
dialog.setTextValue( QString( "%1 %2" ).arg( suggestion ).arg( ensemblesStartingWithRoot + 1 ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dialog.setTextValue( suggestion );
|
||||||
|
}
|
||||||
|
|
||||||
dialog.resize( 300, 50 );
|
dialog.resize( 300, 50 );
|
||||||
dialog.exec();
|
dialog.exec();
|
||||||
return dialog.result() == QDialog::Accepted ? dialog.textValue() : QString( "" );
|
return dialog.result() == QDialog::Accepted ? dialog.textValue() : QString( "" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
QString RicImportEnsembleFeature::commonRoot( const QStringList& fileList )
|
||||||
|
{
|
||||||
|
QStringList fileNameList;
|
||||||
|
for ( auto filePath : fileList )
|
||||||
|
{
|
||||||
|
QFileInfo fileInfo( filePath );
|
||||||
|
QString fileNameWithoutExt = fileInfo.baseName();
|
||||||
|
fileNameList.push_back( fileNameWithoutExt );
|
||||||
|
}
|
||||||
|
QString root = RiaTextStringTools::findCommonRoot( fileNameList );
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
@ -39,5 +39,6 @@ protected:
|
|||||||
void onActionTriggered( bool isChecked ) override;
|
void onActionTriggered( bool isChecked ) override;
|
||||||
void setupActionLook( QAction* actionToSetup ) override;
|
void setupActionLook( QAction* actionToSetup ) override;
|
||||||
|
|
||||||
QString askForEnsembleName();
|
QString askForEnsembleName( const QString& suggestion );
|
||||||
|
QString commonRoot( const QStringList& fileList );
|
||||||
};
|
};
|
||||||
|
@ -106,7 +106,7 @@ void RicReplaceCaseFeature::onActionTriggered( bool isChecked )
|
|||||||
if ( gridSummaryCase )
|
if ( gridSummaryCase )
|
||||||
{
|
{
|
||||||
gridSummaryCase->setAssociatedEclipseCase( selectedCase );
|
gridSummaryCase->setAssociatedEclipseCase( selectedCase );
|
||||||
gridSummaryCase->resetAutoShortName();
|
gridSummaryCase->updateAutoShortName();
|
||||||
gridSummaryCase->createSummaryReaderInterface();
|
gridSummaryCase->createSummaryReaderInterface();
|
||||||
gridSummaryCase->createRftReaderInterface();
|
gridSummaryCase->createRftReaderInterface();
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ void RicReplaceSummaryCaseFeature::onActionTriggered( bool isChecked )
|
|||||||
|
|
||||||
QString oldSummaryHeaderFilename = summaryCase->summaryHeaderFilename();
|
QString oldSummaryHeaderFilename = summaryCase->summaryHeaderFilename();
|
||||||
summaryCase->setSummaryHeaderFileName( fileNames[0] );
|
summaryCase->setSummaryHeaderFileName( fileNames[0] );
|
||||||
summaryCase->resetAutoShortName();
|
summaryCase->updateAutoShortName();
|
||||||
summaryCase->createSummaryReaderInterface();
|
summaryCase->createSummaryReaderInterface();
|
||||||
summaryCase->createRftReaderInterface();
|
summaryCase->createRftReaderInterface();
|
||||||
RiaLogging::info( QString( "Replaced summary data for %1" ).arg( oldSummaryHeaderFilename ) );
|
RiaLogging::info( QString( "Replaced summary data for %1" ).arg( oldSummaryHeaderFilename ) );
|
||||||
|
@ -274,7 +274,8 @@ void RimCorrelationPlot::addDataToChartBuilder( RiuGroupedBarChartBuilder& chart
|
|||||||
{
|
{
|
||||||
double value = m_showAbsoluteValues() ? std::abs( parameterCorrPair.second ) : parameterCorrPair.second;
|
double value = m_showAbsoluteValues() ? std::abs( parameterCorrPair.second ) : parameterCorrPair.second;
|
||||||
double sortValue = m_sortByAbsoluteValues() ? std::abs( value ) : value;
|
double sortValue = m_sortByAbsoluteValues() ? std::abs( value ) : value;
|
||||||
QString barText = QString( "%1 (%2)" ).arg( parameterCorrPair.first.name ).arg( parameterCorrPair.second );
|
QString barText =
|
||||||
|
QString( "%1 (%2)" ).arg( parameterCorrPair.first.name ).arg( parameterCorrPair.second, 5, 'f', 2 );
|
||||||
QString majorText = "", medText = "", minText = "", legendText = barText;
|
QString majorText = "", medText = "", minText = "", legendText = barText;
|
||||||
chartBuilder.addBarEntry( majorText, medText, minText, sortValue, legendText, barText, value );
|
chartBuilder.addBarEntry( majorText, medText, minText, sortValue, legendText, barText, value );
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ RimCalculatedSummaryCase::RimCalculatedSummaryCase()
|
|||||||
CAF_PDM_InitObject( "Calculated", ":/SummaryCase48x48.png", "", "" );
|
CAF_PDM_InitObject( "Calculated", ":/SummaryCase48x48.png", "", "" );
|
||||||
|
|
||||||
m_calculatedCurveReader = nullptr;
|
m_calculatedCurveReader = nullptr;
|
||||||
m_shortName = "Calculated";
|
m_displayName = "Calculated";
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -272,7 +272,7 @@ std::pair<std::vector<time_t>, std::vector<double>>
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
QString RimDerivedSummaryCase::caseName() const
|
QString RimDerivedSummaryCase::caseName() const
|
||||||
{
|
{
|
||||||
return m_shortName;
|
return m_displayName;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -413,7 +413,7 @@ void RimDerivedSummaryCase::updateDisplayNameFromCases()
|
|||||||
|
|
||||||
QString name = operatorText + QString( "(%1 , %2)" ).arg( case1Name, case2Name );
|
QString name = operatorText + QString( "(%1 , %2)" ).arg( case1Name, case2Name );
|
||||||
|
|
||||||
m_shortName = name;
|
m_displayName = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -422,7 +422,7 @@ void RimDerivedSummaryCase::updateDisplayNameFromCases()
|
|||||||
void RimDerivedSummaryCase::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
void RimDerivedSummaryCase::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
||||||
{
|
{
|
||||||
// Base class
|
// Base class
|
||||||
uiOrdering.add( &m_shortName );
|
uiOrdering.add( &m_displayName );
|
||||||
|
|
||||||
uiOrdering.add( &m_summaryCase1 );
|
uiOrdering.add( &m_summaryCase1 );
|
||||||
uiOrdering.add( &m_operator );
|
uiOrdering.add( &m_operator );
|
||||||
|
@ -18,18 +18,15 @@
|
|||||||
|
|
||||||
#include "RimSummaryCase.h"
|
#include "RimSummaryCase.h"
|
||||||
|
|
||||||
|
#include "RiaFilePathTools.h"
|
||||||
#include "RiaSummaryTools.h"
|
#include "RiaSummaryTools.h"
|
||||||
|
|
||||||
#include "RicfCommandObject.h"
|
#include "RicfCommandObject.h"
|
||||||
#include "RifSummaryReaderInterface.h"
|
#include "RifSummaryReaderInterface.h"
|
||||||
|
|
||||||
#include "RimMainPlotCollection.h"
|
#include "RimMainPlotCollection.h"
|
||||||
#include "RimObservedDataCollection.h"
|
|
||||||
#include "RimObservedSummaryData.h"
|
|
||||||
#include "RimOilField.h"
|
|
||||||
#include "RimProject.h"
|
#include "RimProject.h"
|
||||||
#include "RimSummaryCaseCollection.h"
|
#include "RimSummaryCaseCollection.h"
|
||||||
#include "RimSummaryCaseMainCollection.h"
|
|
||||||
#include "RimSummaryPlotCollection.h"
|
#include "RimSummaryPlotCollection.h"
|
||||||
|
|
||||||
#include "cafPdmFieldScriptingCapability.h"
|
#include "cafPdmFieldScriptingCapability.h"
|
||||||
@ -37,20 +34,36 @@
|
|||||||
#include "cvfAssert.h"
|
#include "cvfAssert.h"
|
||||||
|
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
CAF_PDM_ABSTRACT_SOURCE_INIT( RimSummaryCase, "SummaryCase" );
|
CAF_PDM_ABSTRACT_SOURCE_INIT( RimSummaryCase, "SummaryCase" );
|
||||||
|
|
||||||
const QString RimSummaryCase::DEFAULT_DISPLAY_NAME = "Display Name";
|
namespace caf
|
||||||
|
{
|
||||||
|
template <>
|
||||||
|
void AppEnum<RimSummaryCase::DisplayName>::setUp()
|
||||||
|
{
|
||||||
|
addItem( RimSummaryCase::DisplayName::FULL_CASE_NAME, "FULL_CASE_NAME", "Full Case Name" );
|
||||||
|
addItem( RimSummaryCase::DisplayName::SHORT_CASE_NAME, "SHORT_CASE_NAME", "Shortened Case Name" );
|
||||||
|
addItem( RimSummaryCase::DisplayName::CUSTOM, "CUSTOM_NAME", "Custom Name" );
|
||||||
|
setDefault( RimSummaryCase::DisplayName::SHORT_CASE_NAME );
|
||||||
|
}
|
||||||
|
} // namespace caf
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
RimSummaryCase::RimSummaryCase()
|
RimSummaryCase::RimSummaryCase()
|
||||||
|
: nameChanged( this )
|
||||||
{
|
{
|
||||||
CAF_PDM_InitScriptableObject( "Summary Case", ":/SummaryCase16x16.png", "", "The Base Class for all Summary Cases" );
|
CAF_PDM_InitScriptableObject( "Summary Case", ":/SummaryCase16x16.png", "", "The Base Class for all Summary Cases" );
|
||||||
|
|
||||||
CAF_PDM_InitScriptableField( &m_shortName, "ShortName", QString( "Display Name" ), DEFAULT_DISPLAY_NAME, "", "", "" );
|
CAF_PDM_InitScriptableFieldNoDefault( &m_displayName, "ShortName", "Display Name", "", "", "" );
|
||||||
CAF_PDM_InitScriptableField( &m_useAutoShortName, "AutoShortyName", false, "Use Auto Display Name", "", "", "" );
|
CAF_PDM_InitScriptableFieldNoDefault( &m_displayNameOption, "NameSetting", "Name Setting", "", "", "" );
|
||||||
|
|
||||||
|
CAF_PDM_InitScriptableField( &m_useAutoShortName_OBSOLETE, "AutoShortyName", false, "Use Auto Display Name", "", "", "" );
|
||||||
|
m_useAutoShortName_OBSOLETE.xmlCapability()->setIOWritable( false );
|
||||||
|
m_useAutoShortName_OBSOLETE.uiCapability()->setUiHidden( true );
|
||||||
|
|
||||||
CAF_PDM_InitScriptableFieldNoDefault( &m_summaryHeaderFilename, "SummaryHeaderFilename", "Summary Header File", "", "", "" );
|
CAF_PDM_InitScriptableFieldNoDefault( &m_summaryHeaderFilename, "SummaryHeaderFilename", "Summary Header File", "", "", "" );
|
||||||
m_summaryHeaderFilename.uiCapability()->setUiReadOnly( true );
|
m_summaryHeaderFilename.uiCapability()->setUiReadOnly( true );
|
||||||
@ -92,7 +105,7 @@ void RimSummaryCase::setSummaryHeaderFileName( const QString& fileName )
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
bool RimSummaryCase::isObservedData()
|
bool RimSummaryCase::isObservedData() const
|
||||||
{
|
{
|
||||||
return m_isObservedData;
|
return m_isObservedData;
|
||||||
}
|
}
|
||||||
@ -136,10 +149,10 @@ RimSummaryCaseCollection* RimSummaryCase::ensemble() const
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RimSummaryCase::copyFrom( const RimSummaryCase& rhs )
|
void RimSummaryCase::copyFrom( const RimSummaryCase& rhs )
|
||||||
{
|
{
|
||||||
m_shortName = rhs.m_shortName;
|
m_displayName = rhs.m_displayName;
|
||||||
m_useAutoShortName = rhs.m_useAutoShortName;
|
m_useAutoShortName_OBSOLETE = rhs.m_useAutoShortName_OBSOLETE;
|
||||||
m_summaryHeaderFilename = rhs.m_summaryHeaderFilename;
|
m_summaryHeaderFilename = rhs.m_summaryHeaderFilename;
|
||||||
m_isObservedData = rhs.m_isObservedData;
|
m_isObservedData = rhs.m_isObservedData;
|
||||||
|
|
||||||
this->updateTreeItemName();
|
this->updateTreeItemName();
|
||||||
this->updateOptionSensitivity();
|
this->updateOptionSensitivity();
|
||||||
@ -160,18 +173,17 @@ void RimSummaryCase::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
|||||||
const QVariant& oldValue,
|
const QVariant& oldValue,
|
||||||
const QVariant& newValue )
|
const QVariant& newValue )
|
||||||
{
|
{
|
||||||
if ( changedField == &m_useAutoShortName )
|
if ( changedField == &m_displayNameOption )
|
||||||
{
|
{
|
||||||
this->updateAutoShortName();
|
updateAutoShortName();
|
||||||
|
nameChanged.send();
|
||||||
}
|
}
|
||||||
else if ( changedField == &m_shortName )
|
else if ( changedField == &m_displayName )
|
||||||
{
|
{
|
||||||
updateTreeItemName();
|
updateTreeItemName();
|
||||||
|
nameChanged.send();
|
||||||
}
|
}
|
||||||
|
|
||||||
RimSummaryPlotCollection* summaryPlotColl = RiaSummaryTools::summaryPlotCollection();
|
|
||||||
summaryPlotColl->updateSummaryNameHasChanged();
|
|
||||||
|
|
||||||
updateOptionSensitivity();
|
updateOptionSensitivity();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,7 +192,7 @@ void RimSummaryCase::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RimSummaryCase::updateOptionSensitivity()
|
void RimSummaryCase::updateOptionSensitivity()
|
||||||
{
|
{
|
||||||
m_shortName.uiCapability()->setUiReadOnly( m_useAutoShortName );
|
m_displayName.uiCapability()->setUiReadOnly( m_displayNameOption != DisplayName::CUSTOM );
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -212,10 +224,7 @@ void RimSummaryCase::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrderin
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RimSummaryCase::updateTreeItemName()
|
void RimSummaryCase::updateTreeItemName()
|
||||||
{
|
{
|
||||||
if ( caseName() != displayCaseName() )
|
this->setUiName( displayCaseName() );
|
||||||
this->setUiName( caseName() + " (" + displayCaseName() + ")" );
|
|
||||||
else
|
|
||||||
this->setUiName( caseName() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -223,7 +232,7 @@ void RimSummaryCase::updateTreeItemName()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
QString RimSummaryCase::displayCaseName() const
|
QString RimSummaryCase::displayCaseName() const
|
||||||
{
|
{
|
||||||
return m_shortName();
|
return m_displayName();
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -257,6 +266,11 @@ void RimSummaryCase::initAfterRead()
|
|||||||
RimProject::current()->assignCaseIdToSummaryCase( this );
|
RimProject::current()->assignCaseIdToSummaryCase( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( m_useAutoShortName_OBSOLETE )
|
||||||
|
{
|
||||||
|
m_displayNameOption = DisplayName::SHORT_CASE_NAME;
|
||||||
|
}
|
||||||
|
|
||||||
updateOptionSensitivity();
|
updateOptionSensitivity();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,70 +279,69 @@ void RimSummaryCase::initAfterRead()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
QString RimSummaryCase::uniqueShortNameForCase( RimSummaryCase* summaryCase )
|
QString RimSummaryCase::uniqueShortNameForCase( RimSummaryCase* summaryCase )
|
||||||
{
|
{
|
||||||
RimOilField* oilField = nullptr;
|
QString ensembleName;
|
||||||
summaryCase->firstAncestorOrThisOfType( oilField );
|
std::vector<RimSummaryCase*> summaryCases;
|
||||||
CVF_ASSERT( oilField );
|
|
||||||
|
|
||||||
std::set<QString> allAutoShortNames;
|
auto ensemble = summaryCase->ensemble();
|
||||||
|
if ( ensemble )
|
||||||
std::vector<RimSummaryCase*> allCases = oilField->summaryCaseMainCollection->allSummaryCases();
|
|
||||||
std::vector<RimObservedSummaryData*> observedDataCases = oilField->observedDataCollection->allObservedSummaryData();
|
|
||||||
|
|
||||||
for ( auto observedData : observedDataCases )
|
|
||||||
{
|
{
|
||||||
allCases.push_back( observedData );
|
summaryCases = ensemble->allSummaryCases();
|
||||||
}
|
|
||||||
|
|
||||||
for ( RimSummaryCase* sumCase : allCases )
|
|
||||||
{
|
|
||||||
if ( sumCase && sumCase != summaryCase )
|
|
||||||
{
|
|
||||||
allAutoShortNames.insert( sumCase->displayCaseName() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool foundUnique = false;
|
|
||||||
|
|
||||||
QString caseName = summaryCase->caseName();
|
|
||||||
QString shortName;
|
|
||||||
|
|
||||||
if ( caseName.size() > 2 )
|
|
||||||
{
|
|
||||||
QString candidate;
|
|
||||||
candidate += caseName[0];
|
|
||||||
|
|
||||||
for ( int i = 1; i < caseName.size(); ++i )
|
|
||||||
{
|
|
||||||
if ( allAutoShortNames.count( candidate + caseName[i] ) == 0 )
|
|
||||||
{
|
|
||||||
shortName = candidate + caseName[i];
|
|
||||||
foundUnique = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
shortName = caseName.left( 2 );
|
RimProject::current()->descendantsIncludingThisOfType( summaryCases );
|
||||||
if ( allAutoShortNames.count( shortName ) == 0 )
|
|
||||||
{
|
|
||||||
foundUnique = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int autoNumber = 0;
|
QRegularExpression trimRe( "^[^a-zA-Z0-9]+" );
|
||||||
|
|
||||||
while ( !foundUnique )
|
QStringList summaryFilePaths;
|
||||||
|
summaryFilePaths.push_back( summaryCase->summaryHeaderFilename() );
|
||||||
|
|
||||||
|
for ( auto otherSummaryCase : summaryCases )
|
||||||
{
|
{
|
||||||
QString candidate = shortName + QString::number( autoNumber++ );
|
if ( otherSummaryCase != summaryCase )
|
||||||
if ( allAutoShortNames.count( candidate ) == 0 )
|
|
||||||
{
|
{
|
||||||
shortName = candidate;
|
summaryFilePaths.push_back( otherSummaryCase->summaryHeaderFilename() );
|
||||||
foundUnique = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return shortName;
|
std::map<QString, QStringList> keyFileComponentsForAllFiles =
|
||||||
|
RiaFilePathTools::keyPathComponentsForEachFilePath( summaryFilePaths );
|
||||||
|
|
||||||
|
QStringList keyFileComponents = keyFileComponentsForAllFiles[summaryCase->summaryHeaderFilename()];
|
||||||
|
CAF_ASSERT( !keyFileComponents.empty() );
|
||||||
|
|
||||||
|
if ( !ensembleName.isEmpty() )
|
||||||
|
{
|
||||||
|
for ( auto& component : keyFileComponents )
|
||||||
|
{
|
||||||
|
component = component.replace( ensembleName, "" );
|
||||||
|
component = component.replace( trimRe, "" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList shortNameComponents;
|
||||||
|
QRegularExpression numberRe( "[0-9]+" );
|
||||||
|
for ( auto keyComponent : keyFileComponents )
|
||||||
|
{
|
||||||
|
QStringList subComponents;
|
||||||
|
QString numberGroup = numberRe.match( keyComponent ).captured();
|
||||||
|
if ( !numberGroup.isEmpty() )
|
||||||
|
{
|
||||||
|
keyComponent = keyComponent.replace( numberGroup, "" );
|
||||||
|
|
||||||
|
QString stem = keyComponent.left( 2 );
|
||||||
|
if ( !stem.isEmpty() ) subComponents.push_back( stem );
|
||||||
|
subComponents.push_back( numberGroup );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
subComponents.push_back( keyComponent.left( 4 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
shortNameComponents.push_back( subComponents.join( "-" ) );
|
||||||
|
}
|
||||||
|
return shortNameComponents.join( "," );
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -336,27 +349,18 @@ QString RimSummaryCase::uniqueShortNameForCase( RimSummaryCase* summaryCase )
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RimSummaryCase::updateAutoShortName()
|
void RimSummaryCase::updateAutoShortName()
|
||||||
{
|
{
|
||||||
if ( m_useAutoShortName )
|
if ( m_displayNameOption == DisplayName::FULL_CASE_NAME )
|
||||||
{
|
{
|
||||||
m_shortName = RimSummaryCase::uniqueShortNameForCase( this );
|
m_displayName = caseName();
|
||||||
}
|
}
|
||||||
else if ( m_shortName() == DEFAULT_DISPLAY_NAME )
|
else if ( m_displayNameOption == DisplayName::SHORT_CASE_NAME )
|
||||||
{
|
{
|
||||||
m_shortName = caseName();
|
m_displayName = RimSummaryCase::uniqueShortNameForCase( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTreeItemName();
|
updateTreeItemName();
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
void RimSummaryCase::resetAutoShortName()
|
|
||||||
{
|
|
||||||
m_shortName = DEFAULT_DISPLAY_NAME;
|
|
||||||
updateAutoShortName();
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -40,6 +40,17 @@ class RimSummaryCase : public caf::PdmObject
|
|||||||
{
|
{
|
||||||
CAF_PDM_HEADER_INIT;
|
CAF_PDM_HEADER_INIT;
|
||||||
|
|
||||||
|
public:
|
||||||
|
caf::Signal<> nameChanged;
|
||||||
|
|
||||||
|
enum class DisplayName
|
||||||
|
{
|
||||||
|
FULL_CASE_NAME,
|
||||||
|
SHORT_CASE_NAME,
|
||||||
|
CUSTOM
|
||||||
|
};
|
||||||
|
using DisplayNameEnum = caf::AppEnum<DisplayName>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RimSummaryCase();
|
RimSummaryCase();
|
||||||
~RimSummaryCase() override;
|
~RimSummaryCase() override;
|
||||||
@ -53,7 +64,6 @@ public:
|
|||||||
RiaEclipseUnitTools::UnitSystemType unitsSystem();
|
RiaEclipseUnitTools::UnitSystemType unitsSystem();
|
||||||
|
|
||||||
void updateAutoShortName();
|
void updateAutoShortName();
|
||||||
void resetAutoShortName();
|
|
||||||
void updateOptionSensitivity();
|
void updateOptionSensitivity();
|
||||||
|
|
||||||
virtual void createSummaryReaderInterface() = 0;
|
virtual void createSummaryReaderInterface() = 0;
|
||||||
@ -66,7 +76,7 @@ public:
|
|||||||
|
|
||||||
void setSummaryHeaderFileName( const QString& fileName );
|
void setSummaryHeaderFileName( const QString& fileName );
|
||||||
|
|
||||||
bool isObservedData();
|
bool isObservedData() const;
|
||||||
|
|
||||||
void setCaseRealizationParameters( const std::shared_ptr<RigCaseRealizationParameters>& crlParameters );
|
void setCaseRealizationParameters( const std::shared_ptr<RigCaseRealizationParameters>& crlParameters );
|
||||||
std::shared_ptr<RigCaseRealizationParameters> caseRealizationParameters() const;
|
std::shared_ptr<RigCaseRealizationParameters> caseRealizationParameters() const;
|
||||||
@ -88,13 +98,16 @@ private:
|
|||||||
static QString uniqueShortNameForCase( RimSummaryCase* summaryCase );
|
static QString uniqueShortNameForCase( RimSummaryCase* summaryCase );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
caf::PdmField<QString> m_shortName;
|
caf::PdmField<QString> m_displayName;
|
||||||
caf::PdmField<bool> m_useAutoShortName;
|
caf::PdmField<DisplayNameEnum> m_displayNameOption;
|
||||||
caf::PdmField<caf::FilePath> m_summaryHeaderFilename;
|
caf::PdmField<caf::FilePath> m_summaryHeaderFilename;
|
||||||
bool m_isObservedData;
|
|
||||||
caf::PdmField<int> m_caseId;
|
bool m_isObservedData;
|
||||||
|
caf::PdmField<int> m_caseId;
|
||||||
|
|
||||||
std::shared_ptr<RigCaseRealizationParameters> m_crlParameters;
|
std::shared_ptr<RigCaseRealizationParameters> m_crlParameters;
|
||||||
|
|
||||||
|
caf::PdmField<bool> m_useAutoShortName_OBSOLETE;
|
||||||
|
|
||||||
static const QString DEFAULT_DISPLAY_NAME;
|
static const QString DEFAULT_DISPLAY_NAME;
|
||||||
};
|
};
|
||||||
|
@ -187,6 +187,7 @@ QString EnsembleParameter::uiName() const
|
|||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
RimSummaryCaseCollection::RimSummaryCaseCollection()
|
RimSummaryCaseCollection::RimSummaryCaseCollection()
|
||||||
|
: caseNameChanged( this )
|
||||||
{
|
{
|
||||||
CAF_PDM_InitScriptableObject( "Summary Case Group", ":/SummaryGroup16x16.png", "", "" );
|
CAF_PDM_InitScriptableObject( "Summary Case Group", ":/SummaryGroup16x16.png", "", "" );
|
||||||
|
|
||||||
@ -227,6 +228,8 @@ RimSummaryCaseCollection::~RimSummaryCaseCollection()
|
|||||||
void RimSummaryCaseCollection::removeCase( RimSummaryCase* summaryCase )
|
void RimSummaryCaseCollection::removeCase( RimSummaryCase* summaryCase )
|
||||||
{
|
{
|
||||||
size_t caseCountBeforeRemove = m_cases.size();
|
size_t caseCountBeforeRemove = m_cases.size();
|
||||||
|
|
||||||
|
summaryCase->nameChanged.disconnect( this );
|
||||||
m_cases.removeChildObject( summaryCase );
|
m_cases.removeChildObject( summaryCase );
|
||||||
|
|
||||||
m_cachedSortedEnsembleParameters.clear();
|
m_cachedSortedEnsembleParameters.clear();
|
||||||
@ -245,6 +248,8 @@ void RimSummaryCaseCollection::removeCase( RimSummaryCase* summaryCase )
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RimSummaryCaseCollection::addCase( RimSummaryCase* summaryCase, bool updateCurveSets )
|
void RimSummaryCaseCollection::addCase( RimSummaryCase* summaryCase, bool updateCurveSets )
|
||||||
{
|
{
|
||||||
|
summaryCase->nameChanged.connect( this, &RimSummaryCaseCollection::onCaseNameChanged );
|
||||||
|
|
||||||
m_cases.push_back( summaryCase );
|
m_cases.push_back( summaryCase );
|
||||||
m_cachedSortedEnsembleParameters.clear();
|
m_cachedSortedEnsembleParameters.clear();
|
||||||
|
|
||||||
@ -982,6 +987,14 @@ void RimSummaryCaseCollection::fieldChangedByUi( const caf::PdmFieldHandle* chan
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RimSummaryCaseCollection::onCaseNameChanged( const SignalEmitter* emitter )
|
||||||
|
{
|
||||||
|
caseNameChanged.send();
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -91,6 +91,9 @@ class RimSummaryCaseCollection : public caf::PdmObject
|
|||||||
{
|
{
|
||||||
CAF_PDM_HEADER_INIT;
|
CAF_PDM_HEADER_INIT;
|
||||||
|
|
||||||
|
public:
|
||||||
|
caf::Signal<> caseNameChanged;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RimSummaryCaseCollection();
|
RimSummaryCaseCollection();
|
||||||
~RimSummaryCaseCollection() override;
|
~RimSummaryCaseCollection() override;
|
||||||
@ -146,6 +149,8 @@ private:
|
|||||||
void initAfterRead() override;
|
void initAfterRead() override;
|
||||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||||
|
|
||||||
|
void onCaseNameChanged( const SignalEmitter* emitter );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void onLoadDataAndUpdate();
|
virtual void onLoadDataAndUpdate();
|
||||||
void updateReferringCurveSets();
|
void updateReferringCurveSets();
|
||||||
|
@ -17,6 +17,9 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
#include "RimSummaryCaseMainCollection.h"
|
#include "RimSummaryCaseMainCollection.h"
|
||||||
|
|
||||||
|
#include "RiaSummaryTools.h"
|
||||||
|
#include "RimSummaryPlotCollection.h"
|
||||||
|
|
||||||
#include "RifCaseRealizationParametersReader.h"
|
#include "RifCaseRealizationParametersReader.h"
|
||||||
#include "RifEclipseSummaryTools.h"
|
#include "RifEclipseSummaryTools.h"
|
||||||
#include "RifSummaryCaseRestartSelector.h"
|
#include "RifSummaryCaseRestartSelector.h"
|
||||||
@ -30,6 +33,7 @@
|
|||||||
#include "RimSummaryCase.h"
|
#include "RimSummaryCase.h"
|
||||||
#include "RimSummaryCaseCollection.h"
|
#include "RimSummaryCaseCollection.h"
|
||||||
#include "RimSummaryCurve.h"
|
#include "RimSummaryCurve.h"
|
||||||
|
#include "RimSummaryPlot.h"
|
||||||
|
|
||||||
#include "cafProgressInfo.h"
|
#include "cafProgressInfo.h"
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
@ -213,6 +217,7 @@ void RimSummaryCaseMainCollection::addCases( const std::vector<RimSummaryCase*>
|
|||||||
void RimSummaryCaseMainCollection::addCase( RimSummaryCase* summaryCase )
|
void RimSummaryCaseMainCollection::addCase( RimSummaryCase* summaryCase )
|
||||||
{
|
{
|
||||||
m_cases.push_back( summaryCase );
|
m_cases.push_back( summaryCase );
|
||||||
|
summaryCase->nameChanged.connect( this, &RimSummaryCaseMainCollection::onCaseNameChanged );
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -235,7 +240,9 @@ void RimSummaryCaseMainCollection::removeCase( RimSummaryCase* summaryCase )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
summaryCase->nameChanged.disconnect( this );
|
||||||
m_cases.removeChildObject( summaryCase );
|
m_cases.removeChildObject( summaryCase );
|
||||||
|
|
||||||
for ( RimSummaryCaseCollection* summaryCaseCollection : m_caseCollections )
|
for ( RimSummaryCaseCollection* summaryCaseCollection : m_caseCollections )
|
||||||
{
|
{
|
||||||
summaryCaseCollection->removeCase( summaryCase );
|
summaryCaseCollection->removeCase( summaryCase );
|
||||||
@ -285,6 +292,7 @@ RimSummaryCaseCollection*
|
|||||||
|
|
||||||
summaryCaseCollection->setAsEnsemble( isEnsemble );
|
summaryCaseCollection->setAsEnsemble( isEnsemble );
|
||||||
|
|
||||||
|
summaryCaseCollection->caseNameChanged.connect( this, &RimSummaryCaseMainCollection::onCaseNameChanged );
|
||||||
m_caseCollections.push_back( summaryCaseCollection );
|
m_caseCollections.push_back( summaryCaseCollection );
|
||||||
|
|
||||||
return summaryCaseCollection;
|
return summaryCaseCollection;
|
||||||
@ -295,6 +303,7 @@ RimSummaryCaseCollection*
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RimSummaryCaseMainCollection::removeCaseCollection( RimSummaryCaseCollection* caseCollection )
|
void RimSummaryCaseMainCollection::removeCaseCollection( RimSummaryCaseCollection* caseCollection )
|
||||||
{
|
{
|
||||||
|
caseCollection->caseNameChanged.disconnect( this );
|
||||||
m_caseCollections.removeChildObject( caseCollection );
|
m_caseCollections.removeChildObject( caseCollection );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -487,6 +496,15 @@ RimSummaryCaseCollection* RimSummaryCaseMainCollection::defaultAllocator()
|
|||||||
return new RimSummaryCaseCollection();
|
return new RimSummaryCaseCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RimSummaryCaseMainCollection::onCaseNameChanged( const SignalEmitter* emitter )
|
||||||
|
{
|
||||||
|
RimSummaryPlotCollection* summaryPlotColl = RiaSummaryTools::summaryPlotCollection();
|
||||||
|
summaryPlotColl->updateSummaryNameHasChanged();
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -78,6 +78,8 @@ private:
|
|||||||
static void reassignSummaryCurves( const RimGridSummaryCase* fromGridCase, RimFileSummaryCase* toFileCase );
|
static void reassignSummaryCurves( const RimGridSummaryCase* fromGridCase, RimFileSummaryCase* toFileCase );
|
||||||
static RimSummaryCaseCollection* defaultAllocator();
|
static RimSummaryCaseCollection* defaultAllocator();
|
||||||
|
|
||||||
|
void onCaseNameChanged( const SignalEmitter* emitter );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
caf::PdmChildArrayField<RimSummaryCase*> m_cases;
|
caf::PdmChildArrayField<RimSummaryCase*> m_cases;
|
||||||
caf::PdmChildArrayField<RimSummaryCaseCollection*> m_caseCollections;
|
caf::PdmChildArrayField<RimSummaryCaseCollection*> m_caseCollections;
|
||||||
|
Loading…
Reference in New Issue
Block a user