mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Merge pull request #4697 from OPM/plot-templates-framework
Plot templates framework
This commit is contained in:
commit
1ec3694d64
@ -1118,6 +1118,7 @@ void RiaApplication::applyPreferences()
|
||||
if ( this->project() )
|
||||
{
|
||||
this->project()->setScriptDirectories( m_preferences->scriptDirectories() );
|
||||
this->project()->setPlotTemplateFolders( m_preferences->plotTemplateFolders() );
|
||||
this->project()->updateConnectedEditors();
|
||||
}
|
||||
caf::PdmSettings::writeFieldsToApplicationStore( m_preferences );
|
||||
@ -1415,6 +1416,7 @@ void RiaApplication::initialize()
|
||||
// Start with a project
|
||||
m_project = new RimProject;
|
||||
m_project->setScriptDirectories( m_preferences->scriptDirectories() );
|
||||
m_project->setPlotTemplateFolders( m_preferences->plotTemplateFolders() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -301,6 +301,17 @@ RiaPreferences::RiaPreferences( void )
|
||||
CAF_PDM_InitFieldNoDefault( &m_timeFormat, "timeFormat", "Time Format", "", "", "" );
|
||||
m_timeFormat.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() );
|
||||
m_timeFormat = RiaQDateTimeTools::supportedTimeFormats().front();
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_plotTemplateFolders, "plotTemplateFolders", "Plot Template Folder(s)", "", "", "" );
|
||||
m_plotTemplateFolders.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() );
|
||||
CAF_PDM_InitField( &m_searchPlotTemplateFoldersRecursively,
|
||||
"SearchPlotTemplateFoldersRecursively",
|
||||
true,
|
||||
"Search Plot Templates Recursively",
|
||||
"",
|
||||
"",
|
||||
"" );
|
||||
m_searchPlotTemplateFoldersRecursively.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -320,7 +331,7 @@ void RiaPreferences::defineEditorAttribute( const caf::PdmFieldHandle* field,
|
||||
{
|
||||
m_readerSettings->defineEditorAttribute( field, uiConfigName, attribute );
|
||||
|
||||
if ( field == &scriptDirectories )
|
||||
if ( field == &scriptDirectories || field == &m_plotTemplateFolders )
|
||||
{
|
||||
caf::PdmUiFilePathEditorAttribute* myAttr = dynamic_cast<caf::PdmUiFilePathEditorAttribute*>( attribute );
|
||||
if ( myAttr )
|
||||
@ -334,7 +345,8 @@ void RiaPreferences::defineEditorAttribute( const caf::PdmFieldHandle* field,
|
||||
field == &m_appendClassNameToUiText || field == &m_appendFieldKeywordToToolTipText ||
|
||||
field == &m_showTestToolbar || field == &m_includeFractureDebugInfoFile ||
|
||||
field == &showLasCurveWithoutTvdWarning || field == &holoLensDisableCertificateVerification ||
|
||||
field == &m_showProjectChangedDialog || field == &showLegendBackground )
|
||||
field == &m_showProjectChangedDialog || field == &m_searchPlotTemplateFoldersRecursively ||
|
||||
field == &showLegendBackground )
|
||||
{
|
||||
caf::PdmUiCheckBoxEditorAttribute* myAttr = dynamic_cast<caf::PdmUiCheckBoxEditorAttribute*>( attribute );
|
||||
if ( myAttr )
|
||||
@ -422,6 +434,10 @@ void RiaPreferences::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering&
|
||||
uiOrdering.add( &defaultSummaryHistoryCurveStyle );
|
||||
uiOrdering.add( &m_dateFormat );
|
||||
uiOrdering.add( &m_timeFormat );
|
||||
|
||||
caf::PdmUiGroup* group = uiOrdering.addNewGroup( "Plot Templates" );
|
||||
group->add( &m_plotTemplateFolders );
|
||||
group->add( &m_searchPlotTemplateFoldersRecursively );
|
||||
}
|
||||
else if ( uiConfigName == RiaPreferences::tabNameScripting() )
|
||||
{
|
||||
@ -673,6 +689,33 @@ const QString& RiaPreferences::timeFormat() const
|
||||
return m_timeFormat();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiaPreferences::searchPlotTemplateFoldersRecursively() const
|
||||
{
|
||||
return m_searchPlotTemplateFoldersRecursively();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QStringList RiaPreferences::plotTemplateFolders() const
|
||||
{
|
||||
QStringList filteredFolders;
|
||||
QStringList pathList = m_plotTemplateFolders().split( ';' );
|
||||
for ( const auto& path : pathList )
|
||||
{
|
||||
QDir dir( path );
|
||||
if ( !path.isEmpty() && dir.exists() && dir.isReadable() )
|
||||
{
|
||||
filteredFolders.push_back( path );
|
||||
}
|
||||
}
|
||||
|
||||
return filteredFolders;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -79,6 +79,9 @@ public:
|
||||
const QString& dateFormat() const;
|
||||
const QString& timeFormat() const;
|
||||
|
||||
bool searchPlotTemplateFoldersRecursively() const;
|
||||
QStringList plotTemplateFolders() const;
|
||||
|
||||
std::map<RiaDefines::FontSettingType, RiaFontCache::FontSize> defaultFontSizes() const;
|
||||
|
||||
public: // Pdm Fields
|
||||
@ -162,5 +165,9 @@ private:
|
||||
caf::PdmField<QString> m_holoLensExportFolder;
|
||||
caf::PdmField<QString> m_dateFormat;
|
||||
caf::PdmField<QString> m_timeFormat;
|
||||
QStringList m_tabNames;
|
||||
|
||||
caf::PdmField<QString> m_plotTemplateFolders;
|
||||
caf::PdmField<bool> m_searchPlotTemplateFoldersRecursively;
|
||||
|
||||
QStringList m_tabNames;
|
||||
};
|
||||
|
@ -20,7 +20,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cvfBase.h>
|
||||
#include <cvfBoundingBox.h>
|
||||
|
||||
//==================================================================================================
|
||||
|
@ -18,7 +18,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cvfBase.h>
|
||||
#include <cvfVector3.h>
|
||||
|
||||
#include <array>
|
||||
|
@ -124,6 +124,7 @@ list( APPEND REFERENCED_CMAKE_FILES
|
||||
ProjectDataModel/Annotations/CMakeLists_files.cmake
|
||||
ProjectDataModel/Completions/CMakeLists_files.cmake
|
||||
ProjectDataModel/Measurement/CMakeLists_files.cmake
|
||||
ProjectDataModel/PlotTemplates/CMakeLists_files.cmake
|
||||
|
||||
GeoMech/GeoMechVisualization/CMakeLists_files.cmake
|
||||
|
||||
@ -157,6 +158,7 @@ list( APPEND REFERENCED_CMAKE_FILES
|
||||
Commands/ViewLink/CMakeLists_files.cmake
|
||||
Commands/WellLogCommands/CMakeLists_files.cmake
|
||||
Commands/WellPathCommands/CMakeLists_files.cmake
|
||||
Commands/PlotTemplateCommands/CMakeLists_files.cmake
|
||||
|
||||
CommandFileInterface/CMakeLists_files.cmake
|
||||
CommandFileInterface/Core/CMakeLists_files.cmake
|
||||
|
@ -0,0 +1,24 @@
|
||||
|
||||
set (SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicSavePlotTemplateFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicCreatePlotFromSelectionFeature.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicSavePlotTemplateFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicCreatePlotFromSelectionFeature.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
${SOURCE_GROUP_HEADER_FILES}
|
||||
)
|
||||
|
||||
list(APPEND CODE_SOURCE_FILES
|
||||
${SOURCE_GROUP_SOURCE_FILES}
|
||||
)
|
||||
|
||||
list(APPEND QT_MOC_HEADERS
|
||||
)
|
||||
|
||||
source_group( "CommandFeature\\PlotTemplate" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake )
|
||||
|
@ -0,0 +1,198 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2019- Equinor ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiaGuiApplication.h"
|
||||
#include "RiaSummaryTools.h"
|
||||
|
||||
#include "RicCreatePlotFromSelectionFeature.h"
|
||||
|
||||
#include "RimMainPlotCollection.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RimSummaryCurve.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
#include "RimSummaryPlotCollection.h"
|
||||
#include "RimWellPath.h"
|
||||
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QFileDialog>
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicCreatePlotFromSelectionFeature, "RicCreatePlotFromSelectionFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicCreatePlotFromSelectionFeature::RicCreatePlotFromSelectionFeature() {}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicCreatePlotFromSelectionFeature::isCommandEnabled()
|
||||
{
|
||||
if ( selectedSummaryCases().size() == 2 ) return true;
|
||||
if ( selectedWellPaths().size() == 2 ) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCreatePlotFromSelectionFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
{
|
||||
auto sumCases = selectedSummaryCases();
|
||||
if ( sumCases.size() == 2 )
|
||||
{
|
||||
QString fileName = "d:/projects/ri-plot-templates/one_well_two_cases.rpt";
|
||||
|
||||
RimSummaryPlot* newSummaryPlot = createPlotFromTemplateFile( fileName );
|
||||
if ( newSummaryPlot )
|
||||
{
|
||||
RimSummaryPlotCollection* plotColl =
|
||||
RiaApplication::instance()->project()->mainPlotCollection()->summaryPlotCollection();
|
||||
|
||||
plotColl->summaryPlots.push_back( newSummaryPlot );
|
||||
|
||||
// Resolve references after object has been inserted into the data model
|
||||
newSummaryPlot->resolveReferencesRecursively();
|
||||
newSummaryPlot->initAfterReadRecursively();
|
||||
|
||||
QString nameOfCopy = QString( "Copy of " ) + newSummaryPlot->description();
|
||||
newSummaryPlot->setDescription( nameOfCopy );
|
||||
|
||||
auto summaryCurves = newSummaryPlot->summaryCurves();
|
||||
if ( summaryCurves.size() == sumCases.size() )
|
||||
{
|
||||
for ( size_t i = 0; i < summaryCurves.size(); i++ )
|
||||
{
|
||||
auto sumCase = sumCases[i];
|
||||
summaryCurves[i]->setSummaryCaseY( sumCase );
|
||||
}
|
||||
}
|
||||
|
||||
plotColl->updateConnectedEditors();
|
||||
|
||||
newSummaryPlot->loadDataAndUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
auto wellPaths = selectedWellPaths();
|
||||
if ( wellPaths.size() == 2 )
|
||||
{
|
||||
QString fileName = "d:/projects/ri-plot-templates/one_well_two_cases.rpt";
|
||||
RimSummaryPlot* newSummaryPlot = createPlotFromTemplateFile( fileName );
|
||||
if ( newSummaryPlot )
|
||||
{
|
||||
RimSummaryPlotCollection* plotColl = RiaSummaryTools::summaryPlotCollection();
|
||||
|
||||
plotColl->summaryPlots.push_back( newSummaryPlot );
|
||||
|
||||
// Resolve references after object has been inserted into the data model
|
||||
newSummaryPlot->resolveReferencesRecursively();
|
||||
newSummaryPlot->initAfterReadRecursively();
|
||||
|
||||
QString nameOfCopy = QString( "Copy of " ) + newSummaryPlot->description();
|
||||
newSummaryPlot->setDescription( nameOfCopy );
|
||||
|
||||
auto summaryCurves = newSummaryPlot->summaryCurves();
|
||||
if ( summaryCurves.size() == wellPaths.size() )
|
||||
{
|
||||
for ( size_t i = 0; i < summaryCurves.size(); i++ )
|
||||
{
|
||||
auto wellPath = wellPaths[i];
|
||||
|
||||
summaryCurves[i]->summaryAddressY().setWellName( wellPath->name().toStdString() );
|
||||
}
|
||||
}
|
||||
|
||||
plotColl->updateConnectedEditors();
|
||||
|
||||
newSummaryPlot->loadDataAndUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCreatePlotFromSelectionFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText( "Create Plot from Template" );
|
||||
// actionToSetup->setIcon( QIcon( ":/SummaryPlotLight16x16.png" ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryPlot* RicCreatePlotFromSelectionFeature::createPlotFromTemplateFile( const QString& fileName ) const
|
||||
{
|
||||
QFile importFile( fileName );
|
||||
if ( !importFile.open( QIODevice::ReadOnly | QIODevice::Text ) )
|
||||
{
|
||||
RiaLogging::error( QString( "Create Plot from Template : Could not open the file: %1" ).arg( fileName ) );
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QTextStream stream( &importFile );
|
||||
|
||||
QString objectAsText = stream.readAll();
|
||||
|
||||
caf::PdmObjectHandle* obj =
|
||||
caf::PdmXmlObjectHandle::readUnknownObjectFromXmlString( objectAsText, caf::PdmDefaultObjectFactory::instance() );
|
||||
|
||||
RimSummaryPlot* newSummaryPlot = dynamic_cast<RimSummaryPlot*>( obj );
|
||||
if ( newSummaryPlot )
|
||||
{
|
||||
return newSummaryPlot;
|
||||
}
|
||||
else
|
||||
{
|
||||
delete obj;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimSummaryCase*> RicCreatePlotFromSelectionFeature::selectedSummaryCases() const
|
||||
{
|
||||
std::vector<RimSummaryCase*> objects;
|
||||
caf::SelectionManager::instance()->objectsByType( &objects );
|
||||
|
||||
return objects;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimWellPath*> RicCreatePlotFromSelectionFeature::selectedWellPaths() const
|
||||
{
|
||||
std::vector<RimWellPath*> objects;
|
||||
caf::SelectionManager::instance()->objectsByType( &objects );
|
||||
|
||||
return objects;
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2019- Equinor ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
class RimSummaryCase;
|
||||
class RimWellPath;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicCreatePlotFromSelectionFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RicCreatePlotFromSelectionFeature();
|
||||
|
||||
protected:
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
|
||||
private:
|
||||
RimSummaryPlot* createPlotFromTemplateFile( const QString& fileName ) const;
|
||||
|
||||
private:
|
||||
std::vector<RimSummaryCase*> selectedSummaryCases() const;
|
||||
std::vector<RimWellPath*> selectedWellPaths() const;
|
||||
};
|
@ -0,0 +1,113 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2019- Equinor ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiaGuiApplication.h"
|
||||
#include "RiaLogging.h"
|
||||
#include "RiaSummaryTools.h"
|
||||
|
||||
#include "RicSavePlotTemplateFeature.h"
|
||||
|
||||
#include "RimProject.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QFileDialog>
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicSavePlotTemplateFeature, "RicSavePlotTemplateFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicSavePlotTemplateFeature::RicSavePlotTemplateFeature() {}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicSavePlotTemplateFeature::isCommandEnabled()
|
||||
{
|
||||
if ( selectedSummaryPlot() ) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSavePlotTemplateFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
RiaGuiApplication* app = RiaGuiApplication::instance();
|
||||
|
||||
QString startPath;
|
||||
if ( !app->project()->fileName().isEmpty() )
|
||||
{
|
||||
startPath = app->project()->fileName();
|
||||
startPath = startPath.replace( QString( ".rsp" ), QString( ".rpt" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
startPath = app->lastUsedDialogDirectory( "PLOT_TEMPLATE" );
|
||||
startPath += "/ri-plot-template.rpt";
|
||||
}
|
||||
|
||||
QString fileName = QFileDialog::getSaveFileName( nullptr,
|
||||
tr( "Save Plot Template To File" ),
|
||||
startPath,
|
||||
tr( "Plot Template Files (*.rpt);;All files(*.*)" ) );
|
||||
if ( !fileName.isEmpty() )
|
||||
{
|
||||
auto objectAsText = selectedSummaryPlot()->writeObjectToXmlString();
|
||||
|
||||
QFile exportFile( fileName );
|
||||
if ( !exportFile.open( QIODevice::WriteOnly | QIODevice::Text ) )
|
||||
{
|
||||
RiaLogging::error( QString( "Save Plot Template : Could not open the file: %1" ).arg( fileName ) );
|
||||
return;
|
||||
}
|
||||
|
||||
QTextStream stream( &exportFile );
|
||||
stream << objectAsText;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSavePlotTemplateFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText( "Save As Plot Template" );
|
||||
// actionToSetup->setIcon( QIcon( ":/SummaryPlotLight16x16.png" ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryPlot* RicSavePlotTemplateFeature::selectedSummaryPlot() const
|
||||
{
|
||||
RimSummaryPlot* sumPlot = nullptr;
|
||||
|
||||
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
|
||||
if ( selObj )
|
||||
{
|
||||
sumPlot = RiaSummaryTools::parentSummaryPlot( selObj );
|
||||
}
|
||||
|
||||
return sumPlot;
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2019- Equinor ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
class RimSummaryPlot;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicSavePlotTemplateFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RicSavePlotTemplateFeature();
|
||||
|
||||
protected:
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
|
||||
private:
|
||||
RimSummaryPlot* selectedSummaryPlot() const;
|
||||
};
|
@ -330,7 +330,7 @@ void RicSummaryCurveCreator::defineUiOrdering( QString uiConfigName, caf::PdmUiO
|
||||
|
||||
syncPreviewCurvesFromUiSelection();
|
||||
|
||||
m_summaryCurveSelectionEditor->updateUi();
|
||||
m_summaryCurveSelectionEditor->updateUi( uiConfigName );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -0,0 +1,20 @@
|
||||
|
||||
set (SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimPlotTemplateFolderItem.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimPlotTemplateFileItem.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimPlotTemplateFolderItem.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimPlotTemplateFileItem.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
${SOURCE_GROUP_HEADER_FILES}
|
||||
)
|
||||
|
||||
list(APPEND CODE_SOURCE_FILES
|
||||
${SOURCE_GROUP_SOURCE_FILES}
|
||||
)
|
||||
|
||||
source_group( "ProjectDataModel\\PlotTemplates" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake )
|
@ -0,0 +1,65 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RimPlotTemplateFileItem.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaFieldHandleTools.h"
|
||||
#include "RiaLogging.h"
|
||||
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmUiFilePathEditor.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimPlotTemplateFileItem, "PlotTemplateFileItem" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimPlotTemplateFileItem::RimPlotTemplateFileItem()
|
||||
{
|
||||
CAF_PDM_InitObject( "PlotTemplateFileItem", ":/OctaveScriptFile16x16.png", "Calc Script", "" );
|
||||
|
||||
CAF_PDM_InitField( &m_absoluteFileName, "AbsolutePath", QString(), "Location", "", "", "" );
|
||||
m_absoluteFileName.uiCapability()->setUiReadOnly( true );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimPlotTemplateFileItem::~RimPlotTemplateFileItem() {}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimPlotTemplateFileItem::setFilePath( const QString& filePath )
|
||||
{
|
||||
QFileInfo fi( filePath );
|
||||
this->uiCapability()->setUiName( fi.baseName() );
|
||||
|
||||
m_absoluteFileName = filePath;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimPlotTemplateFileItem::absoluteFilePath() const
|
||||
{
|
||||
return m_absoluteFileName();
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimPlotTemplateFileItem : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimPlotTemplateFileItem();
|
||||
~RimPlotTemplateFileItem() override;
|
||||
|
||||
void setFilePath( const QString& filePath );
|
||||
QString absoluteFilePath() const;
|
||||
|
||||
private:
|
||||
caf::PdmField<QString> m_absoluteFileName;
|
||||
};
|
@ -0,0 +1,200 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2019- Equinor ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RimPlotTemplateFolderItem.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaPreferences.h"
|
||||
|
||||
#include "RimPlotTemplateFileItem.h"
|
||||
|
||||
#include "cafPdmUiFilePathEditor.h"
|
||||
#include "cafUtils.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QStringList>
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimPlotTemplateFolderItem, "PlotTemplateCollection" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimPlotTemplateFolderItem::RimPlotTemplateFolderItem()
|
||||
{
|
||||
CAF_PDM_InitObject( "PlotTemplateCollection", ":/Folder.png", "", "" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_folderName, "FolderName", "Folder", "", "", "" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_fileNames, "FileNames", "", "", "", "" );
|
||||
m_fileNames.uiCapability()->setUiHidden( true );
|
||||
CAF_PDM_InitFieldNoDefault( &m_subFolders, "SubFolders", "", "", "", "" );
|
||||
m_subFolders.uiCapability()->setUiHidden( true );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimPlotTemplateFolderItem::~RimPlotTemplateFolderItem() {}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimPlotTemplateFolderItem::createRootFolderItemsFromFolderPaths( const QStringList& folderPaths )
|
||||
{
|
||||
createSubFolderItemsFromFolderPaths( folderPaths );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimPlotTemplateFileItem*> RimPlotTemplateFolderItem::fileNames() const
|
||||
{
|
||||
return m_fileNames.childObjects();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimPlotTemplateFolderItem*> RimPlotTemplateFolderItem::subFolders() const
|
||||
{
|
||||
return m_subFolders.childObjects();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimPlotTemplateFolderItem::setFolderPath( const QString& path )
|
||||
{
|
||||
m_folderName.v().setPath( path );
|
||||
|
||||
QFileInfo fi( path );
|
||||
this->uiCapability()->setUiName( fi.baseName() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimPlotTemplateFolderItem::searchForFileAndFolderNames()
|
||||
{
|
||||
m_fileNames.deleteAllChildObjects();
|
||||
m_subFolders.deleteAllChildObjects();
|
||||
|
||||
if ( m_folderName().path().isEmpty() )
|
||||
{
|
||||
for ( size_t i = 0; i < m_subFolders.size(); ++i )
|
||||
{
|
||||
if ( m_subFolders[i] ) m_subFolders[i]->searchForFileAndFolderNames();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
QDir myDir( this->m_folderName().path() );
|
||||
if ( !myDir.isReadable() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Build a list of all scripts in the specified directory
|
||||
{
|
||||
QStringList nameFilters;
|
||||
nameFilters << "*.rpt";
|
||||
QStringList fileList = caf::Utils::getFilesInDirectory( m_folderName().path(), nameFilters, true );
|
||||
|
||||
for ( int i = 0; i < fileList.size(); i++ )
|
||||
{
|
||||
const QString& fileName = fileList.at( i );
|
||||
|
||||
if ( caf::Utils::fileExists( fileName ) )
|
||||
{
|
||||
RimPlotTemplateFileItem* fileItem = new RimPlotTemplateFileItem();
|
||||
fileItem->setFilePath( fileName );
|
||||
m_fileNames.push_back( fileItem );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( searchSubFoldersRecursively() )
|
||||
{
|
||||
QStringList folderPaths;
|
||||
|
||||
QDir dir( m_folderName().path() );
|
||||
QFileInfoList fileInfoList = dir.entryInfoList( QDir::AllDirs | QDir::NoDotAndDotDot | QDir::Readable );
|
||||
|
||||
for ( const auto& fi : fileInfoList )
|
||||
{
|
||||
folderPaths.push_back( fi.absoluteFilePath() );
|
||||
}
|
||||
|
||||
createSubFolderItemsFromFolderPaths( folderPaths );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimPlotTemplateFolderItem::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue )
|
||||
{
|
||||
if ( &m_folderName == changedField )
|
||||
{
|
||||
QFileInfo fi( m_folderName().path() );
|
||||
this->setUiName( fi.baseName() );
|
||||
|
||||
this->searchForFileAndFolderNames();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimPlotTemplateFolderItem::defineEditorAttribute( const caf::PdmFieldHandle* field,
|
||||
QString uiConfigName,
|
||||
caf::PdmUiEditorAttribute* attribute )
|
||||
{
|
||||
if ( field == &m_folderName )
|
||||
{
|
||||
caf::PdmUiFilePathEditorAttribute* myAttr = dynamic_cast<caf::PdmUiFilePathEditorAttribute*>( attribute );
|
||||
if ( myAttr )
|
||||
{
|
||||
myAttr->m_selectDirectory = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimPlotTemplateFolderItem::createSubFolderItemsFromFolderPaths( const QStringList& folderPaths )
|
||||
{
|
||||
for ( const auto& path : folderPaths )
|
||||
{
|
||||
RimPlotTemplateFolderItem* scriptLocation = new RimPlotTemplateFolderItem();
|
||||
scriptLocation->setFolderPath( path );
|
||||
scriptLocation->searchForFileAndFolderNames();
|
||||
|
||||
m_subFolders.push_back( scriptLocation );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimPlotTemplateFolderItem::searchSubFoldersRecursively() const
|
||||
{
|
||||
return RiaApplication::instance()->preferences()->searchPlotTemplateFoldersRecursively();
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2019- Equinor ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafPdmChildArrayField.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
namespace caf
|
||||
{
|
||||
class PdmUiEditorAttribute;
|
||||
}
|
||||
|
||||
class RimPlotTemplateFileItem;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimPlotTemplateFolderItem : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimPlotTemplateFolderItem();
|
||||
~RimPlotTemplateFolderItem() override;
|
||||
|
||||
void createRootFolderItemsFromFolderPaths( const QStringList& folderPaths );
|
||||
|
||||
std::vector<RimPlotTemplateFileItem*> fileNames() const;
|
||||
std::vector<RimPlotTemplateFolderItem*> subFolders() const;
|
||||
|
||||
private:
|
||||
void searchForFileAndFolderNames();
|
||||
void setFolderPath( const QString& path );
|
||||
void createSubFolderItemsFromFolderPaths( const QStringList& folderPaths );
|
||||
|
||||
bool searchSubFoldersRecursively() const;
|
||||
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue ) override;
|
||||
void defineEditorAttribute( const caf::PdmFieldHandle* field,
|
||||
QString uiConfigName,
|
||||
caf::PdmUiEditorAttribute* attribute ) override;
|
||||
|
||||
private:
|
||||
caf::PdmField<caf::FilePath> m_folderName;
|
||||
caf::PdmChildArrayField<RimPlotTemplateFileItem*> m_fileNames;
|
||||
caf::PdmChildArrayField<RimPlotTemplateFolderItem*> m_subFolders;
|
||||
};
|
@ -550,6 +550,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
||||
menuBuilder << "Separator";
|
||||
menuBuilder << "RicShowSummaryCurveCalculatorFeature";
|
||||
menuBuilder << "Separator";
|
||||
menuBuilder << "RicSavePlotTemplateFeature";
|
||||
menuBuilder << "Separator";
|
||||
|
||||
// Export is not supported for cross plot
|
||||
if ( !summaryCrossPlot ) menuBuilder << "RicAsciiExportSummaryPlotFeature";
|
||||
@ -843,6 +845,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
||||
menuBuilder << "RicDeleteSummaryCaseCollectionFeature";
|
||||
menuBuilder << "RicCloseObservedDataFeature";
|
||||
|
||||
menuBuilder << "RicCreatePlotFromSelectionFeature";
|
||||
|
||||
// Work in progress -- End
|
||||
appendCreateCompletions( menuBuilder, menuBuilder.itemCount() > 0u );
|
||||
bool addedExportWellPaths = appendExportWellPaths( menuBuilder, menuBuilder.itemCount() > 0u ) > 0;
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "RigEclipseCaseData.h"
|
||||
#include "RigGridBase.h"
|
||||
|
||||
#include "PlotTemplates/RimPlotTemplateFolderItem.h"
|
||||
#include "RimAdvancedSnapshotExportDefinition.h"
|
||||
#include "RimAnnotationCollection.h"
|
||||
#include "RimAnnotationInViewCollection.h"
|
||||
@ -191,6 +192,10 @@ RimProject::RimProject( void )
|
||||
|
||||
mainPlotCollection = new RimMainPlotCollection();
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_plotTemplateFolderItem, "PlotTemplateCollection", "Plot Templates", "", "", "" );
|
||||
m_plotTemplateFolderItem = new RimPlotTemplateFolderItem();
|
||||
m_plotTemplateFolderItem.xmlCapability()->disableIO();
|
||||
|
||||
// For now, create a default first oilfield that contains the rest of the project
|
||||
oilFields.push_back( new RimOilField );
|
||||
|
||||
@ -353,6 +358,17 @@ void RimProject::setScriptDirectories( const QString& scriptDirectories )
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimProject::setPlotTemplateFolders( const QStringList& plotTemplateFolders )
|
||||
{
|
||||
if ( m_plotTemplateFolderItem() ) delete m_plotTemplateFolderItem();
|
||||
m_plotTemplateFolderItem = new RimPlotTemplateFolderItem();
|
||||
|
||||
m_plotTemplateFolderItem->createRootFolderItemsFromFolderPaths( plotTemplateFolders );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -1155,6 +1171,14 @@ RimMeasurement* RimProject::measurement() const
|
||||
return activeOilField()->measurement;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimPlotTemplateFolderItem* RimProject::rootPlotTemlateItem() const
|
||||
{
|
||||
return m_plotTemplateFolderItem;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -1237,6 +1261,8 @@ void RimProject::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, Q
|
||||
itemCollection->add( mainPlotCollection->saturationPressurePlotCollection() );
|
||||
}
|
||||
}
|
||||
|
||||
uiTreeOrdering.add( m_plotTemplateFolderItem() );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -66,6 +66,7 @@ class RimFractureTemplate;
|
||||
class RimValveTemplateCollection;
|
||||
class RimValveTemplate;
|
||||
class RimCompletionTemplateCollection;
|
||||
class RimPlotTemplateFolderItem;
|
||||
|
||||
namespace caf
|
||||
{
|
||||
@ -104,6 +105,7 @@ public:
|
||||
caf::PdmField<QString> plotWindowCurrentModelIndexPath;
|
||||
|
||||
void setScriptDirectories( const QString& scriptDirectories );
|
||||
void setPlotTemplateFolders( const QStringList& plotTemplateFolders );
|
||||
|
||||
QString projectFileVersionString() const;
|
||||
bool isProjectFileVersionEqualOrOlderThan( const QString& otherProjectFileVersion ) const;
|
||||
@ -172,6 +174,8 @@ public:
|
||||
RiaEclipseUnitTools::UnitSystemType commonUnitSystemForAllCases() const;
|
||||
RimMeasurement* measurement() const;
|
||||
|
||||
RimPlotTemplateFolderItem* rootPlotTemlateItem() const;
|
||||
|
||||
protected:
|
||||
// Overridden methods
|
||||
void initAfterRead() override;
|
||||
@ -186,7 +190,8 @@ private:
|
||||
private:
|
||||
caf::PdmField<QString> m_projectFileVersionString;
|
||||
|
||||
caf::PdmChildField<RimDialogData*> m_dialogData;
|
||||
caf::PdmChildField<RimDialogData*> m_dialogData;
|
||||
caf::PdmChildField<RimPlotTemplateFolderItem*> m_plotTemplateFolderItem;
|
||||
|
||||
caf::PdmField<bool> m_show3DWindow;
|
||||
caf::PdmField<bool> m_showPlotWindow;
|
||||
|
@ -25,6 +25,8 @@
|
||||
|
||||
#include "SummaryPlotCommands/RicSummaryCurveCreator.h"
|
||||
|
||||
#include "PlotTemplates/RimPlotTemplateFileItem.h"
|
||||
#include "PlotTemplates/RimPlotTemplateFolderItem.h"
|
||||
#include "RimAsciiDataCurve.h"
|
||||
#include "RimEnsembleCurveSet.h"
|
||||
#include "RimEnsembleCurveSetCollection.h"
|
||||
@ -194,6 +196,8 @@ RimSummaryPlot::RimSummaryPlot()
|
||||
CAF_PDM_InitField( &m_isAutoZoom_OBSOLETE, "AutoZoom", true, "Auto Zoom", "", "", "" );
|
||||
RiaFieldhandleTools::disableWriteAndSetFieldHidden( &m_isAutoZoom_OBSOLETE );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_plotTemplate, "PlotTemplate", "Template", "", "", "" );
|
||||
|
||||
m_isCrossPlot = false;
|
||||
|
||||
m_nameHelperAllCurves.reset( new RimSummaryPlotNameHelper );
|
||||
@ -1234,6 +1238,27 @@ QList<caf::PdmOptionItemInfo> RimSummaryPlot::calculateValueOptions( const caf::
|
||||
options.push_back( caf::PdmOptionItemInfo( text, value ) );
|
||||
}
|
||||
}
|
||||
else if ( fieldNeedingOptions == &m_plotTemplate )
|
||||
{
|
||||
options.push_back( caf::PdmOptionItemInfo( "None", nullptr ) );
|
||||
|
||||
auto rootPlotTemplate = RiaApplication::instance()->project()->rootPlotTemlateItem();
|
||||
if ( rootPlotTemplate )
|
||||
{
|
||||
std::vector<caf::PdmObject*> allTemplates;
|
||||
{
|
||||
RimPlotTemplateFileItem fileItem;
|
||||
rootPlotTemplate->descendantsIncludingThisFromClassKeyword( fileItem.classKeyword(), allTemplates );
|
||||
}
|
||||
|
||||
for ( auto t : allTemplates )
|
||||
{
|
||||
caf::PdmOptionItemInfo optionItem( t->uiName(), t );
|
||||
options.push_back( optionItem );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
@ -1552,6 +1577,8 @@ void RimSummaryPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering&
|
||||
|
||||
m_userDefinedPlotTitle.uiCapability()->setUiReadOnly( m_useAutoPlotTitle );
|
||||
|
||||
uiOrdering.add( &m_plotTemplate );
|
||||
|
||||
uiOrdering.skipRemainingFields( true );
|
||||
}
|
||||
|
||||
@ -1842,6 +1869,22 @@ void RimSummaryPlot::showLegend( bool enable )
|
||||
m_showLegend = enable;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::setPlotTemplate( RimPlotTemplateFileItem* plotTemplate )
|
||||
{
|
||||
m_plotTemplate = plotTemplate;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimPlotTemplateFileItem* RimSummaryPlot::plotTemplate() const
|
||||
{
|
||||
return m_plotTemplate();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -18,8 +18,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafPdmChildArrayField.h"
|
||||
|
||||
#include "RiaDefines.h"
|
||||
#include "RiaQDateTimeTools.h"
|
||||
#include "RiaSummaryCurveDefinition.h"
|
||||
@ -30,6 +28,10 @@
|
||||
#include "RimViewWindow.h"
|
||||
|
||||
#include "qwt_plot_textlabel.h"
|
||||
|
||||
#include "cafPdmChildArrayField.h"
|
||||
#include "cafPdmPtrField.h"
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
#include <memory>
|
||||
@ -49,6 +51,7 @@ class RimPlotAxisPropertiesInterface;
|
||||
class RimPlotAxisProperties;
|
||||
class RiuSummaryQwtPlot;
|
||||
class RimSummaryPlotNameHelper;
|
||||
class RimPlotTemplateFileItem;
|
||||
|
||||
class QwtInterval;
|
||||
class QwtPlotCurve;
|
||||
@ -145,6 +148,9 @@ public:
|
||||
bool isNormalizationEnabled();
|
||||
void showLegend( bool enable );
|
||||
|
||||
void setPlotTemplate( RimPlotTemplateFileItem* plotTemplate );
|
||||
RimPlotTemplateFileItem* plotTemplate() const;
|
||||
|
||||
public:
|
||||
// Rim2dPlotInterface overrides
|
||||
void updateAxisScaling() override;
|
||||
@ -223,6 +229,8 @@ private:
|
||||
caf::PdmChildField<RimPlotAxisProperties*> m_bottomAxisProperties;
|
||||
caf::PdmChildField<RimSummaryTimeAxisProperties*> m_timeAxisProperties;
|
||||
|
||||
caf::PdmPtrField<RimPlotTemplateFileItem*> m_plotTemplate;
|
||||
|
||||
QPointer<RiuSummaryQwtPlot> m_qwtPlot;
|
||||
std::unique_ptr<QwtPlotTextLabel> m_plotInfoLabel;
|
||||
|
||||
|
@ -667,7 +667,7 @@ void RiuSummaryCurveDefSelection::setSelectedCurveDefinitions( const std::vector
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::set<RifEclipseSummaryAddress> RiuSummaryCurveDefSelection::findPossibleSummaryAddressesFromCalculated()
|
||||
std::set<RifEclipseSummaryAddress> RiuSummaryCurveDefSelection::findPossibleSummaryAddressesFromCalculated() const
|
||||
{
|
||||
std::set<RifEclipseSummaryAddress> addressSet;
|
||||
|
||||
@ -740,230 +740,17 @@ QList<caf::PdmOptionItemInfo>
|
||||
|
||||
if ( fieldNeedingOptions == &m_selectedSources )
|
||||
{
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
std::vector<RimOilField*> oilFields;
|
||||
|
||||
proj->allOilFields( oilFields );
|
||||
for ( RimOilField* oilField : oilFields )
|
||||
{
|
||||
RimSummaryCaseMainCollection* sumCaseMainColl = oilField->summaryCaseMainCollection();
|
||||
if ( sumCaseMainColl )
|
||||
{
|
||||
if ( !m_hideSummaryCases )
|
||||
{
|
||||
// Top level cases
|
||||
for ( const auto& sumCase : sumCaseMainColl->topLevelSummaryCases() )
|
||||
{
|
||||
options.push_back( caf::PdmOptionItemInfo( sumCase->caseName(), sumCase ) );
|
||||
}
|
||||
}
|
||||
|
||||
// Ensembles
|
||||
if ( !m_hideEnsembles )
|
||||
{
|
||||
bool ensembleHeaderCreated = false;
|
||||
for ( const auto& sumCaseColl : sumCaseMainColl->summaryCaseCollections() )
|
||||
{
|
||||
if ( !sumCaseColl->isEnsemble() ) continue;
|
||||
|
||||
if ( !ensembleHeaderCreated )
|
||||
{
|
||||
options.push_back( caf::PdmOptionItemInfo::createHeader( "Ensembles", true ) );
|
||||
ensembleHeaderCreated = true;
|
||||
}
|
||||
|
||||
auto optionItem = caf::PdmOptionItemInfo( sumCaseColl->name(), sumCaseColl );
|
||||
optionItem.setLevel( 1 );
|
||||
options.push_back( optionItem );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !m_hideSummaryCases )
|
||||
{
|
||||
// Grouped cases
|
||||
for ( const auto& sumCaseColl : sumCaseMainColl->summaryCaseCollections() )
|
||||
{
|
||||
if ( sumCaseColl->isEnsemble() ) continue;
|
||||
|
||||
options.push_back( caf::PdmOptionItemInfo::createHeader( sumCaseColl->name(), true ) );
|
||||
|
||||
for ( const auto& sumCase : sumCaseColl->allSummaryCases() )
|
||||
{
|
||||
auto optionItem = caf::PdmOptionItemInfo( sumCase->caseName(), sumCase );
|
||||
optionItem.setLevel( 1 );
|
||||
options.push_back( optionItem );
|
||||
}
|
||||
}
|
||||
|
||||
// Observed data
|
||||
auto observedDataColl = oilField->observedDataCollection();
|
||||
if ( observedDataColl->allObservedSummaryData().size() > 0 )
|
||||
{
|
||||
options.push_back( caf::PdmOptionItemInfo::createHeader( "Observed Data", true ) );
|
||||
|
||||
for ( const auto& obsData : observedDataColl->allObservedSummaryData() )
|
||||
{
|
||||
auto optionItem = caf::PdmOptionItemInfo( obsData->caseName(), obsData );
|
||||
optionItem.setLevel( 1 );
|
||||
options.push_back( optionItem );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
appendOptionItemsForSources( options );
|
||||
}
|
||||
else if ( fieldNeedingOptions == &m_selectedSummaryCategories )
|
||||
{
|
||||
std::vector<RifEclipseSummaryAddress::SummaryVarCategory> sortedCategoriesForUi;
|
||||
|
||||
sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_FIELD );
|
||||
sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_AQUIFER );
|
||||
sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_NETWORK );
|
||||
sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_MISC );
|
||||
sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_REGION );
|
||||
sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_REGION_2_REGION );
|
||||
sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL_GROUP );
|
||||
sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL );
|
||||
sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL_COMPLETION );
|
||||
sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL_SEGMENT );
|
||||
sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_BLOCK );
|
||||
sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL_LGR );
|
||||
sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL_COMPLETION_LGR );
|
||||
sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_BLOCK_LGR );
|
||||
sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_CALCULATED );
|
||||
sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_IMPORTED );
|
||||
// NB SUMMARY_ENSEMBLE_STATISTICS is intentionally excluded
|
||||
// categoriesForUiDisplay.push_back(RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_ENSEMBLE_STATISTICS);
|
||||
|
||||
for ( auto category : sortedCategoriesForUi )
|
||||
{
|
||||
auto uiText = caf::AppEnum<RifEclipseSummaryAddress::SummaryVarCategory>::uiText( category );
|
||||
options.push_back( caf::PdmOptionItemInfo( uiText, category ) );
|
||||
}
|
||||
appendOptionItemsForCategories( options );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Lookup item type input field
|
||||
auto identifierAndField = lookupIdentifierAndFieldFromFieldHandle( fieldNeedingOptions );
|
||||
if ( identifierAndField != nullptr )
|
||||
{
|
||||
enum
|
||||
{
|
||||
SUM_CASES,
|
||||
OBS_DATA,
|
||||
CALCULATED_CURVES
|
||||
};
|
||||
|
||||
const int itemCount = CALCULATED_CURVES + 1;
|
||||
|
||||
std::set<RifEclipseSummaryAddress> addrUnion[itemCount];
|
||||
addrUnion[SUM_CASES] = findPossibleSummaryAddressesFromSelectedCases( identifierAndField );
|
||||
addrUnion[OBS_DATA] = findPossibleSummaryAddressesFromSelectedObservedData( identifierAndField );
|
||||
addrUnion[CALCULATED_CURVES] = findPossibleSummaryAddressesFromCalculated();
|
||||
|
||||
std::set<std::string> itemNames[itemCount];
|
||||
for ( int i = 0; i < itemCount; i++ )
|
||||
{
|
||||
for ( const auto& address : addrUnion[i] )
|
||||
{
|
||||
if ( address.isErrorResult() ) continue;
|
||||
|
||||
auto name = address.uiText( identifierAndField->summaryIdentifier() );
|
||||
if ( name.size() > 0 )
|
||||
{
|
||||
itemNames[i].insert( name );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool isVectorField = identifierAndField->summaryIdentifier() == RifEclipseSummaryAddress::INPUT_VECTOR_NAME;
|
||||
|
||||
// Merge sets for all other fields than vector fields
|
||||
if ( !isVectorField )
|
||||
{
|
||||
itemNames[SUM_CASES].insert( itemNames[OBS_DATA].begin(), itemNames[OBS_DATA].end() );
|
||||
itemNames[OBS_DATA].clear();
|
||||
}
|
||||
|
||||
for ( int i = 0; i < itemCount; i++ )
|
||||
{
|
||||
// Create headers only for vector fields when observed data is selected
|
||||
bool hasObservedData = itemNames[OBS_DATA].size() > 0;
|
||||
bool groupItems = isVectorField && hasObservedData;
|
||||
if ( groupItems )
|
||||
{
|
||||
QString headerText;
|
||||
if ( i == SUM_CASES )
|
||||
{
|
||||
headerText = QString( "Simulated Data" );
|
||||
}
|
||||
else if ( i == OBS_DATA )
|
||||
{
|
||||
headerText = QString( "Observed Data" );
|
||||
}
|
||||
else if ( i == CALCULATED_CURVES )
|
||||
{
|
||||
headerText = QString( "Calculated" );
|
||||
}
|
||||
|
||||
if ( !headerText.isEmpty() )
|
||||
{
|
||||
options.push_back( caf::PdmOptionItemInfo::createHeader( headerText, true ) );
|
||||
}
|
||||
}
|
||||
|
||||
auto itemPostfix = ( isVectorField && i == OBS_DATA ) ? QString( OBSERVED_DATA_AVALUE_POSTFIX )
|
||||
: QString( "" );
|
||||
|
||||
// Sort numeric identifiers by numeric val
|
||||
std::vector<std::string> itemNamesVector;
|
||||
{
|
||||
switch ( identifierAndField->summaryIdentifier() )
|
||||
{
|
||||
case RifEclipseSummaryAddress::INPUT_REGION_NUMBER:
|
||||
case RifEclipseSummaryAddress::INPUT_SEGMENT_NUMBER:
|
||||
case RifEclipseSummaryAddress::INPUT_AQUIFER_NUMBER:
|
||||
{
|
||||
std::set<int> values;
|
||||
for ( const std::string& itemName : itemNames[i] )
|
||||
{
|
||||
values.insert( RiaStdStringTools::toInt( itemName ) );
|
||||
}
|
||||
for ( int v : values )
|
||||
{
|
||||
itemNamesVector.push_back( std::to_string( v ) );
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
itemNamesVector.insert( itemNamesVector.end(), itemNames[i].begin(), itemNames[i].end() );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for ( const auto& itemName : itemNamesVector )
|
||||
{
|
||||
QString displayName;
|
||||
|
||||
if ( isVectorField )
|
||||
{
|
||||
std::string longVectorName = RiuSummaryVectorDescriptionMap::instance()->vectorLongName( itemName,
|
||||
true );
|
||||
displayName = QString::fromStdString( longVectorName );
|
||||
displayName += QString( " (%1)" ).arg( QString::fromStdString( itemName ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
displayName = QString::fromStdString( itemName );
|
||||
}
|
||||
|
||||
auto optionItem = caf::PdmOptionItemInfo( displayName,
|
||||
QString::fromStdString( itemName ) + itemPostfix );
|
||||
if ( groupItems ) optionItem.setLevel( 1 );
|
||||
options.push_back( optionItem );
|
||||
}
|
||||
}
|
||||
}
|
||||
appendOptionItemsForSubCategoriesAndVectors( options, identifierAndField );
|
||||
}
|
||||
|
||||
return options;
|
||||
@ -1130,10 +917,10 @@ void RiuSummaryCurveDefSelection::defineUiOrdering( QString uiConfigName, caf::P
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::set<RifEclipseSummaryAddress> RiuSummaryCurveDefSelection::findPossibleSummaryAddressesFromSelectedCases(
|
||||
const SummaryIdentifierAndField* identifierAndField )
|
||||
const SummaryIdentifierAndField* identifierAndField ) const
|
||||
{
|
||||
std::vector<SummarySource*> sources;
|
||||
for ( const auto& source : m_selectedSources() )
|
||||
for ( const auto& source : m_selectedSources.value() )
|
||||
{
|
||||
RimSummaryCase* sumCase = dynamic_cast<RimSummaryCase*>( source.p() );
|
||||
RimSummaryCaseCollection* ensemble = dynamic_cast<RimSummaryCaseCollection*>( source.p() );
|
||||
@ -1154,10 +941,10 @@ std::set<RifEclipseSummaryAddress> RiuSummaryCurveDefSelection::findPossibleSumm
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::set<RifEclipseSummaryAddress> RiuSummaryCurveDefSelection::findPossibleSummaryAddressesFromSelectedObservedData(
|
||||
const SummaryIdentifierAndField* identifierAndField )
|
||||
const SummaryIdentifierAndField* identifierAndField ) const
|
||||
{
|
||||
std::vector<SummarySource*> obsData;
|
||||
for ( const auto& source : m_selectedSources() )
|
||||
for ( const auto& source : m_selectedSources.value() )
|
||||
{
|
||||
RimSummaryCase* sumCase = dynamic_cast<RimSummaryCase*>( source.p() );
|
||||
|
||||
@ -1172,9 +959,8 @@ std::set<RifEclipseSummaryAddress> RiuSummaryCurveDefSelection::findPossibleSumm
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Returns the summary addresses that match the selected item type and input selections made in GUI
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::set<RifEclipseSummaryAddress>
|
||||
RiuSummaryCurveDefSelection::findPossibleSummaryAddresses( const std::vector<SummarySource*>& selectedSources,
|
||||
const SummaryIdentifierAndField* identifierAndField )
|
||||
std::set<RifEclipseSummaryAddress> RiuSummaryCurveDefSelection::findPossibleSummaryAddresses(
|
||||
const std::vector<SummarySource*>& selectedSources, const SummaryIdentifierAndField* identifierAndField ) const
|
||||
{
|
||||
std::set<RifEclipseSummaryAddress> addrUnion;
|
||||
|
||||
@ -1458,3 +1244,237 @@ RimSummaryCase* RiuSummaryCurveDefSelection::calculatedSummaryCase()
|
||||
|
||||
return calcColl->calculationSummaryCase();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSummaryCurveDefSelection::appendOptionItemsForSources( QList<caf::PdmOptionItemInfo>& options ) const
|
||||
{
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
std::vector<RimOilField*> oilFields;
|
||||
|
||||
proj->allOilFields( oilFields );
|
||||
for ( RimOilField* oilField : oilFields )
|
||||
{
|
||||
RimSummaryCaseMainCollection* sumCaseMainColl = oilField->summaryCaseMainCollection();
|
||||
if ( sumCaseMainColl )
|
||||
{
|
||||
if ( !m_hideSummaryCases )
|
||||
{
|
||||
// Top level cases
|
||||
for ( const auto& sumCase : sumCaseMainColl->topLevelSummaryCases() )
|
||||
{
|
||||
options.push_back( caf::PdmOptionItemInfo( sumCase->caseName(), sumCase ) );
|
||||
}
|
||||
}
|
||||
|
||||
// Ensembles
|
||||
if ( !m_hideEnsembles )
|
||||
{
|
||||
bool ensembleHeaderCreated = false;
|
||||
for ( const auto& sumCaseColl : sumCaseMainColl->summaryCaseCollections() )
|
||||
{
|
||||
if ( !sumCaseColl->isEnsemble() ) continue;
|
||||
|
||||
if ( !ensembleHeaderCreated )
|
||||
{
|
||||
options.push_back( caf::PdmOptionItemInfo::createHeader( "Ensembles", true ) );
|
||||
ensembleHeaderCreated = true;
|
||||
}
|
||||
|
||||
auto optionItem = caf::PdmOptionItemInfo( sumCaseColl->name(), sumCaseColl );
|
||||
optionItem.setLevel( 1 );
|
||||
options.push_back( optionItem );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !m_hideSummaryCases )
|
||||
{
|
||||
// Grouped cases
|
||||
for ( const auto& sumCaseColl : sumCaseMainColl->summaryCaseCollections() )
|
||||
{
|
||||
if ( sumCaseColl->isEnsemble() ) continue;
|
||||
|
||||
options.push_back( caf::PdmOptionItemInfo::createHeader( sumCaseColl->name(), true ) );
|
||||
|
||||
for ( const auto& sumCase : sumCaseColl->allSummaryCases() )
|
||||
{
|
||||
auto optionItem = caf::PdmOptionItemInfo( sumCase->caseName(), sumCase );
|
||||
optionItem.setLevel( 1 );
|
||||
options.push_back( optionItem );
|
||||
}
|
||||
}
|
||||
|
||||
// Observed data
|
||||
auto observedDataColl = oilField->observedDataCollection();
|
||||
if ( observedDataColl->allObservedSummaryData().size() > 0 )
|
||||
{
|
||||
options.push_back( caf::PdmOptionItemInfo::createHeader( "Observed Data", true ) );
|
||||
|
||||
for ( const auto& obsData : observedDataColl->allObservedSummaryData() )
|
||||
{
|
||||
auto optionItem = caf::PdmOptionItemInfo( obsData->caseName(), obsData );
|
||||
optionItem.setLevel( 1 );
|
||||
options.push_back( optionItem );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSummaryCurveDefSelection::appendOptionItemsForCategories( QList<caf::PdmOptionItemInfo>& options ) const
|
||||
{
|
||||
std::vector<RifEclipseSummaryAddress::SummaryVarCategory> sortedCategoriesForUi;
|
||||
|
||||
sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_FIELD );
|
||||
sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_AQUIFER );
|
||||
sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_NETWORK );
|
||||
sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_MISC );
|
||||
sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_REGION );
|
||||
sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_REGION_2_REGION );
|
||||
sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL_GROUP );
|
||||
sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL );
|
||||
sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL_COMPLETION );
|
||||
sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL_SEGMENT );
|
||||
sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_BLOCK );
|
||||
sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL_LGR );
|
||||
sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL_COMPLETION_LGR );
|
||||
sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_BLOCK_LGR );
|
||||
sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_CALCULATED );
|
||||
sortedCategoriesForUi.push_back( RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_IMPORTED );
|
||||
// NB SUMMARY_ENSEMBLE_STATISTICS is intentionally excluded
|
||||
// categoriesForUiDisplay.push_back(RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_ENSEMBLE_STATISTICS);
|
||||
|
||||
for ( auto category : sortedCategoriesForUi )
|
||||
{
|
||||
auto uiText = caf::AppEnum<RifEclipseSummaryAddress::SummaryVarCategory>::uiText( category );
|
||||
options.push_back( caf::PdmOptionItemInfo( uiText, category ) );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSummaryCurveDefSelection::appendOptionItemsForSubCategoriesAndVectors(
|
||||
QList<caf::PdmOptionItemInfo>& options, SummaryIdentifierAndField* identifierAndField ) const
|
||||
{
|
||||
if ( identifierAndField == nullptr ) return;
|
||||
|
||||
enum
|
||||
{
|
||||
SUM_CASES,
|
||||
OBS_DATA,
|
||||
CALCULATED_CURVES
|
||||
};
|
||||
|
||||
const int itemCount = CALCULATED_CURVES + 1;
|
||||
|
||||
std::set<RifEclipseSummaryAddress> addrUnion[itemCount];
|
||||
addrUnion[SUM_CASES] = findPossibleSummaryAddressesFromSelectedCases( identifierAndField );
|
||||
addrUnion[OBS_DATA] = findPossibleSummaryAddressesFromSelectedObservedData( identifierAndField );
|
||||
addrUnion[CALCULATED_CURVES] = findPossibleSummaryAddressesFromCalculated();
|
||||
|
||||
std::set<std::string> itemNames[itemCount];
|
||||
for ( int i = 0; i < itemCount; i++ )
|
||||
{
|
||||
for ( const auto& address : addrUnion[i] )
|
||||
{
|
||||
if ( address.isErrorResult() ) continue;
|
||||
|
||||
auto name = address.uiText( identifierAndField->summaryIdentifier() );
|
||||
if ( name.size() > 0 )
|
||||
{
|
||||
itemNames[i].insert( name );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool isVectorField = identifierAndField->summaryIdentifier() == RifEclipseSummaryAddress::INPUT_VECTOR_NAME;
|
||||
|
||||
// Merge sets for all other fields than vector fields
|
||||
if ( !isVectorField )
|
||||
{
|
||||
itemNames[SUM_CASES].insert( itemNames[OBS_DATA].begin(), itemNames[OBS_DATA].end() );
|
||||
itemNames[OBS_DATA].clear();
|
||||
}
|
||||
|
||||
for ( int i = 0; i < itemCount; i++ )
|
||||
{
|
||||
// Create headers only for vector fields when observed data is selected
|
||||
bool hasObservedData = itemNames[OBS_DATA].size() > 0;
|
||||
bool groupItems = isVectorField && hasObservedData;
|
||||
if ( groupItems )
|
||||
{
|
||||
QString headerText;
|
||||
if ( i == SUM_CASES )
|
||||
{
|
||||
headerText = QString( "Simulated Data" );
|
||||
}
|
||||
else if ( i == OBS_DATA )
|
||||
{
|
||||
headerText = QString( "Observed Data" );
|
||||
}
|
||||
else if ( i == CALCULATED_CURVES )
|
||||
{
|
||||
headerText = QString( "Calculated" );
|
||||
}
|
||||
|
||||
if ( !headerText.isEmpty() )
|
||||
{
|
||||
options.push_back( caf::PdmOptionItemInfo::createHeader( headerText, true ) );
|
||||
}
|
||||
}
|
||||
|
||||
auto itemPostfix = ( isVectorField && i == OBS_DATA ) ? QString( OBSERVED_DATA_AVALUE_POSTFIX ) : QString( "" );
|
||||
|
||||
// Sort numeric identifiers by numeric val
|
||||
std::vector<std::string> itemNamesVector;
|
||||
{
|
||||
switch ( identifierAndField->summaryIdentifier() )
|
||||
{
|
||||
case RifEclipseSummaryAddress::INPUT_REGION_NUMBER:
|
||||
case RifEclipseSummaryAddress::INPUT_SEGMENT_NUMBER:
|
||||
case RifEclipseSummaryAddress::INPUT_AQUIFER_NUMBER:
|
||||
{
|
||||
std::set<int> values;
|
||||
for ( const std::string& itemName : itemNames[i] )
|
||||
{
|
||||
values.insert( RiaStdStringTools::toInt( itemName ) );
|
||||
}
|
||||
for ( int v : values )
|
||||
{
|
||||
itemNamesVector.push_back( std::to_string( v ) );
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
itemNamesVector.insert( itemNamesVector.end(), itemNames[i].begin(), itemNames[i].end() );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for ( const auto& itemName : itemNamesVector )
|
||||
{
|
||||
QString displayName;
|
||||
|
||||
if ( isVectorField )
|
||||
{
|
||||
std::string longVectorName = RiuSummaryVectorDescriptionMap::instance()->vectorLongName( itemName, true );
|
||||
displayName = QString::fromStdString( longVectorName );
|
||||
displayName += QString( " (%1)" ).arg( QString::fromStdString( itemName ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
displayName = QString::fromStdString( itemName );
|
||||
}
|
||||
|
||||
auto optionItem = caf::PdmOptionItemInfo( displayName, QString::fromStdString( itemName ) + itemPostfix );
|
||||
if ( groupItems ) optionItem.setLevel( 1 );
|
||||
options.push_back( optionItem );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -76,13 +76,14 @@ private:
|
||||
QString uiConfigName,
|
||||
caf::PdmUiEditorAttribute* attribute ) override;
|
||||
|
||||
std::set<RifEclipseSummaryAddress> findPossibleSummaryAddresses( const std::vector<SummarySource*>& selectedSources,
|
||||
const SummaryIdentifierAndField* identifierAndField );
|
||||
std::set<RifEclipseSummaryAddress>
|
||||
findPossibleSummaryAddressesFromSelectedCases( const SummaryIdentifierAndField* identifierAndField );
|
||||
findPossibleSummaryAddresses( const std::vector<SummarySource*>& selectedSources,
|
||||
const SummaryIdentifierAndField* identifierAndField ) const;
|
||||
std::set<RifEclipseSummaryAddress>
|
||||
findPossibleSummaryAddressesFromSelectedObservedData( const SummaryIdentifierAndField* identifierAndField );
|
||||
std::set<RifEclipseSummaryAddress> findPossibleSummaryAddressesFromCalculated();
|
||||
findPossibleSummaryAddressesFromSelectedCases( const SummaryIdentifierAndField* identifierAndField ) const;
|
||||
std::set<RifEclipseSummaryAddress>
|
||||
findPossibleSummaryAddressesFromSelectedObservedData( const SummaryIdentifierAndField* identifierAndField ) const;
|
||||
std::set<RifEclipseSummaryAddress> findPossibleSummaryAddressesFromCalculated() const;
|
||||
|
||||
std::vector<SummaryIdentifierAndField*>
|
||||
buildControllingFieldList( const SummaryIdentifierAndField* identifierAndField ) const;
|
||||
@ -105,6 +106,11 @@ private:
|
||||
std::vector<SummarySource*> selectedSummarySources() const;
|
||||
static RimSummaryCase* calculatedSummaryCase();
|
||||
|
||||
void appendOptionItemsForSources( QList<caf::PdmOptionItemInfo>& options ) const;
|
||||
void appendOptionItemsForCategories( QList<caf::PdmOptionItemInfo>& options ) const;
|
||||
void appendOptionItemsForSubCategoriesAndVectors( QList<caf::PdmOptionItemInfo>& options,
|
||||
SummaryIdentifierAndField* identifierAndField ) const;
|
||||
|
||||
private:
|
||||
caf::PdmPtrArrayField<SummarySource*> m_selectedSources;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user