mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Default summaryplot improvements (#8950)
* Add summary default plot type selection in preferences * Create plots as set in preferences when loading summary cases. Allow selecting default plot templates from templates explorer tree * Do not create plot if data vector setting is empty
This commit is contained in:
parent
f91fe41f1d
commit
8e3289a432
@ -357,7 +357,7 @@ void RiaPreferences::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering&
|
||||
otherGroup->add( &holoLensDisableCertificateVerification );
|
||||
otherGroup->add( &m_useUndoRedo );
|
||||
}
|
||||
else if ( uiConfigName == RiaPreferences::tabNameEclipseGrid() )
|
||||
else if ( uiConfigName == RiaPreferences::tabNameGrid() )
|
||||
{
|
||||
caf::PdmUiGroup* newCaseBehaviourGroup = uiOrdering.addNewGroup( "Behavior When Loading Data" );
|
||||
newCaseBehaviourGroup->add( &autocomputeDepthRelatedProperties );
|
||||
@ -365,7 +365,7 @@ void RiaPreferences::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering&
|
||||
|
||||
m_readerSettings->uiOrdering( uiConfigName, *newCaseBehaviourGroup );
|
||||
}
|
||||
else if ( uiConfigName == RiaPreferences::tabNameEclipseSummary() )
|
||||
else if ( uiConfigName == RiaPreferences::tabNameSummary() )
|
||||
{
|
||||
m_summaryPreferences->appendRestartFileGroup( uiOrdering );
|
||||
|
||||
@ -377,16 +377,20 @@ void RiaPreferences::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering&
|
||||
}
|
||||
else if ( uiConfigName == RiaPreferences::tabNamePlotting() )
|
||||
{
|
||||
uiOrdering.add( &m_dateFormat );
|
||||
uiOrdering.add( &m_timeFormat );
|
||||
caf::PdmUiGroup* summaryGrp = uiOrdering.addNewGroup( "Summary Plots" );
|
||||
|
||||
summaryPreferences()->appendItemsToPlottingGroup( uiOrdering );
|
||||
summaryPreferences()->appendItemsToPlottingGroup( *summaryGrp );
|
||||
|
||||
caf::PdmUiGroup* group = uiOrdering.addNewGroup( "Plot Templates" );
|
||||
caf::PdmUiGroup* group = summaryGrp->addNewGroup( "Plot Templates" );
|
||||
group->add( &m_plotTemplateFolders );
|
||||
group->add( &m_searchPlotTemplateFoldersRecursively );
|
||||
|
||||
caf::PdmUiGroup* pageSetup = uiOrdering.addNewGroup( "Page Setup" );
|
||||
caf::PdmUiGroup* generalGrp = uiOrdering.addNewGroup( "General" );
|
||||
|
||||
generalGrp->add( &m_dateFormat );
|
||||
generalGrp->add( &m_timeFormat );
|
||||
|
||||
caf::PdmUiGroup* pageSetup = generalGrp->addNewGroup( "Page Setup" );
|
||||
pageSetup->add( &m_pageSize );
|
||||
pageSetup->add( &m_pageOrientation, false );
|
||||
pageSetup->add( &m_pageLeftMargin );
|
||||
@ -394,7 +398,7 @@ void RiaPreferences::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering&
|
||||
pageSetup->add( &m_pageTopMargin );
|
||||
pageSetup->add( &m_pageBottomMargin, false );
|
||||
|
||||
uiOrdering.add( &m_useQtChartsPlotByDefault );
|
||||
generalGrp->add( &m_useQtChartsPlotByDefault );
|
||||
m_useQtChartsPlotByDefault.uiCapability()->setUiHidden( true );
|
||||
|
||||
QString unitLabel = " [mm]";
|
||||
@ -431,15 +435,15 @@ void RiaPreferences::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering&
|
||||
m_geoMechPreferences()->appendItems( uiOrdering );
|
||||
}
|
||||
#endif
|
||||
else if ( uiConfigName == RiaPreferences::tabNameExport() )
|
||||
else if ( uiConfigName == RiaPreferences::tabNameImportExport() )
|
||||
{
|
||||
uiOrdering.add( &csvTextExportFieldSeparator );
|
||||
uiOrdering.add( &m_openExportedPdfInViewer );
|
||||
}
|
||||
else if ( uiConfigName == RiaPreferences::tabNameImport() )
|
||||
{
|
||||
uiOrdering.add( &m_surfaceImportResamplingDistance );
|
||||
uiOrdering.add( &m_multiLateralWellPattern );
|
||||
caf::PdmUiGroup* importGroup = uiOrdering.addNewGroup( "Import" );
|
||||
importGroup->add( &m_surfaceImportResamplingDistance );
|
||||
importGroup->add( &m_multiLateralWellPattern );
|
||||
|
||||
caf::PdmUiGroup* exportGroup = uiOrdering.addNewGroup( "Export" );
|
||||
exportGroup->add( &csvTextExportFieldSeparator );
|
||||
exportGroup->add( &m_openExportedPdfInViewer );
|
||||
}
|
||||
else if ( RiaApplication::enableDevelopmentFeatures() && uiConfigName == RiaPreferences::tabNameSystem() )
|
||||
{
|
||||
@ -509,11 +513,14 @@ void RiaPreferences::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
m_pageTopMargin = defaultMarginSize( m_pageSize() );
|
||||
m_pageBottomMargin = defaultMarginSize( m_pageSize() );
|
||||
}
|
||||
|
||||
if ( changedField == &m_guiTheme )
|
||||
else if ( changedField == &m_guiTheme )
|
||||
{
|
||||
RiuGuiTheme::updateGuiTheme( m_guiTheme() );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_summaryPreferences->fieldChangedByUi( changedField, oldValue, newValue );
|
||||
}
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@ -526,17 +533,17 @@ QString RiaPreferences::tabNameGeneral()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiaPreferences::tabNameEclipseGrid()
|
||||
QString RiaPreferences::tabNameGrid()
|
||||
{
|
||||
return "Eclipse Grid";
|
||||
return "Grid";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiaPreferences::tabNameEclipseSummary()
|
||||
QString RiaPreferences::tabNameSummary()
|
||||
{
|
||||
return "Eclipse Summary";
|
||||
return "Summary";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -563,14 +570,6 @@ QString RiaPreferences::tabNameScripting()
|
||||
return "Scripting";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiaPreferences::tabNameExport()
|
||||
{
|
||||
return "Export";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -582,9 +581,9 @@ QString RiaPreferences::tabNameSystem()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiaPreferences::tabNameImport()
|
||||
QString RiaPreferences::tabNameImportExport()
|
||||
{
|
||||
return "Import";
|
||||
return "Import/Export";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -611,15 +610,14 @@ QStringList RiaPreferences::tabNames()
|
||||
QStringList names;
|
||||
|
||||
names << tabNameGeneral();
|
||||
names << tabNameEclipseGrid();
|
||||
names << tabNameEclipseSummary();
|
||||
names << tabNameGrid();
|
||||
names << tabNameSummary();
|
||||
names << tabNamePlotting();
|
||||
names << tabNameScripting();
|
||||
#ifdef USE_ODB_API
|
||||
names << tabNameGeomech();
|
||||
#endif
|
||||
names << tabNameExport();
|
||||
names << tabNameImport();
|
||||
names << tabNameImportExport();
|
||||
|
||||
if ( RiaApplication::enableDevelopmentFeatures() )
|
||||
{
|
||||
|
@ -154,14 +154,13 @@ protected:
|
||||
|
||||
private:
|
||||
static QString tabNameGeneral();
|
||||
static QString tabNameEclipseGrid();
|
||||
static QString tabNameEclipseSummary();
|
||||
static QString tabNameGrid();
|
||||
static QString tabNameSummary();
|
||||
static QString tabNameGeomech();
|
||||
static QString tabNamePlotting();
|
||||
static QString tabNameScripting();
|
||||
static QString tabNameExport();
|
||||
static QString tabNameSystem();
|
||||
static QString tabNameImport();
|
||||
static QString tabNameImportExport();
|
||||
|
||||
static double defaultMarginSize( QPageSize::PageSizeId pageSizeId );
|
||||
|
||||
|
@ -18,11 +18,17 @@
|
||||
|
||||
#include "RiaPreferencesSummary.h"
|
||||
|
||||
#include "PlotTemplateCommands/RicSummaryPlotTemplateTools.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaPreferences.h"
|
||||
|
||||
#include "PlotTemplates/RimPlotTemplateFileItem.h"
|
||||
|
||||
#include "cafPdmUiCheckBoxEditor.h"
|
||||
#include "cafPdmUiComboBoxEditor.h"
|
||||
#include "cafPdmUiListEditor.h"
|
||||
#include "cafPdmUiPushButtonEditor.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@ -57,6 +63,15 @@ void RiaPreferencesSummary::SummaryReaderModeType::setUp()
|
||||
setDefault( RiaPreferencesSummary::SummaryReaderMode::HDF5_OPM_COMMON );
|
||||
}
|
||||
|
||||
template <>
|
||||
void RiaPreferencesSummary::DefaultSummaryPlotEnum::setUp()
|
||||
{
|
||||
addItem( RiaPreferencesSummary::DefaultSummaryPlotType::NONE, "NONE", "No Plots" );
|
||||
addItem( RiaPreferencesSummary::DefaultSummaryPlotType::DATA_VECTORS, "DATA_VECTORS", "Use Data Vector Names" );
|
||||
addItem( RiaPreferencesSummary::DefaultSummaryPlotType::PLOT_TEMPLATES, "PLOT_TEMPLATES", "Use Plot Templates" );
|
||||
setDefault( RiaPreferencesSummary::DefaultSummaryPlotType::DATA_VECTORS );
|
||||
}
|
||||
|
||||
} // namespace caf
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RiaPreferencesSummary, "RiaPreferencesSummary" );
|
||||
@ -96,6 +111,16 @@ RiaPreferencesSummary::RiaPreferencesSummary()
|
||||
"",
|
||||
"Semicolon separated list of filters used to create curves in new summary plots",
|
||||
"" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_defaultSummaryPlot, "defaultSummaryPlot", "Create Plot On Summary Data Import" );
|
||||
|
||||
CAF_PDM_InitField( &m_selectDefaultTemplates, "selectDefaultTemplate", false, "", "", "Select Default Templates" );
|
||||
m_selectDefaultTemplates.xmlCapability()->disableIO();
|
||||
m_selectDefaultTemplates.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_selectedDefaultTemplates, "defaultSummaryTemplates", "Select Summary Plot Templates" );
|
||||
m_selectedDefaultTemplates.uiCapability()->setUiReadOnly( true );
|
||||
m_selectedDefaultTemplates.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() );
|
||||
m_selectedDefaultTemplates.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
|
||||
|
||||
CAF_PDM_InitField( &m_createEnhancedSummaryDataFile,
|
||||
"createEnhancedSummaryDataFile_v01",
|
||||
@ -228,7 +253,23 @@ void RiaPreferencesSummary::appendRestartFileGroup( caf::PdmUiOrdering& uiOrderi
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaPreferencesSummary::appendItemsToPlottingGroup( caf::PdmUiOrdering& uiOrdering ) const
|
||||
{
|
||||
uiOrdering.add( &m_defaultSummaryCurvesTextFilter );
|
||||
uiOrdering.add( &m_defaultSummaryPlot );
|
||||
|
||||
switch ( m_defaultSummaryPlot() )
|
||||
{
|
||||
case RiaPreferencesSummary::DefaultSummaryPlotType::DATA_VECTORS:
|
||||
uiOrdering.add( &m_defaultSummaryCurvesTextFilter );
|
||||
break;
|
||||
|
||||
case RiaPreferencesSummary::DefaultSummaryPlotType::PLOT_TEMPLATES:
|
||||
uiOrdering.add( &m_selectedDefaultTemplates );
|
||||
uiOrdering.add( &m_selectDefaultTemplates );
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
uiOrdering.add( &m_defaultSummaryHistoryCurveStyle );
|
||||
uiOrdering.add( &m_curveColorByPhase );
|
||||
|
||||
@ -356,6 +397,22 @@ void RiaPreferencesSummary::defineEditorAttribute( const caf::PdmFieldHandle* fi
|
||||
myattr->iconSize = QSize( 24, 16 );
|
||||
}
|
||||
}
|
||||
else if ( field == &m_selectDefaultTemplates )
|
||||
{
|
||||
auto attrib = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute );
|
||||
if ( attrib )
|
||||
{
|
||||
attrib->m_buttonText = "Select Default Templates";
|
||||
}
|
||||
}
|
||||
else if ( field == &m_selectedDefaultTemplates )
|
||||
{
|
||||
auto attrib = dynamic_cast<caf::PdmUiListEditorAttribute*>( attribute );
|
||||
if ( attrib )
|
||||
{
|
||||
attrib->m_heightHint = 30;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -450,3 +507,79 @@ RiaDefines::RowCount RiaPreferencesSummary::defaultMultiPlotRowCount() const
|
||||
{
|
||||
return m_defaultRowsPerPage();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaPreferencesSummary::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue )
|
||||
{
|
||||
if ( changedField == &m_selectDefaultTemplates )
|
||||
{
|
||||
m_selectDefaultTemplates = false;
|
||||
|
||||
auto selection = RicSummaryPlotTemplateTools::selectDefaultPlotTemplates( m_selectedDefaultTemplates() );
|
||||
if ( selection.empty() ) return;
|
||||
|
||||
m_selectedDefaultTemplates = selection;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiaPreferencesSummary::DefaultSummaryPlotType RiaPreferencesSummary::defaultSummaryPlotType() const
|
||||
{
|
||||
return m_defaultSummaryPlot();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<QString> RiaPreferencesSummary::defaultSummaryPlotTemplates() const
|
||||
{
|
||||
return m_selectedDefaultTemplates();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiaPreferencesSummary::isDefaultSummaryPlotTemplate( QString filename ) const
|
||||
{
|
||||
int count = std::count( m_selectedDefaultTemplates().begin(), m_selectedDefaultTemplates().end(), filename );
|
||||
return ( count > 0 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaPreferencesSummary::addToDefaultPlotTemplates( QString filename )
|
||||
{
|
||||
if ( isDefaultSummaryPlotTemplate( filename ) ) return;
|
||||
|
||||
std::vector<QString> newlist;
|
||||
newlist.insert( newlist.end(), m_selectedDefaultTemplates().begin(), m_selectedDefaultTemplates().end() );
|
||||
newlist.push_back( filename );
|
||||
m_selectedDefaultTemplates = newlist;
|
||||
|
||||
RiaPreferences::current()->writePreferencesToApplicationStore();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaPreferencesSummary::removeFromDefaultPlotTemplates( QString filename )
|
||||
{
|
||||
if ( !isDefaultSummaryPlotTemplate( filename ) ) return;
|
||||
|
||||
std::vector<QString> newlist;
|
||||
|
||||
for ( auto& item : m_selectedDefaultTemplates() )
|
||||
{
|
||||
if ( item != filename ) newlist.push_back( item );
|
||||
}
|
||||
m_selectedDefaultTemplates = newlist;
|
||||
|
||||
RiaPreferences::current()->writePreferencesToApplicationStore();
|
||||
}
|
||||
|
@ -19,11 +19,15 @@
|
||||
#pragma once
|
||||
|
||||
#include "cafAppEnum.h"
|
||||
#include "cafPdmChildArrayField.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
#include "RiaDefines.h"
|
||||
|
||||
#include <QString>
|
||||
#include <vector>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -56,6 +60,14 @@ public:
|
||||
};
|
||||
using SummaryHistoryCurveStyleModeType = caf::AppEnum<SummaryHistoryCurveStyleMode>;
|
||||
|
||||
enum class DefaultSummaryPlotType
|
||||
{
|
||||
NONE,
|
||||
DATA_VECTORS,
|
||||
PLOT_TEMPLATES
|
||||
};
|
||||
using DefaultSummaryPlotEnum = caf::AppEnum<DefaultSummaryPlotType>;
|
||||
|
||||
using ColumnCountEnum = caf::AppEnum<RiaDefines::ColumnCount>;
|
||||
using RowCountEnum = caf::AppEnum<RiaDefines::RowCount>;
|
||||
|
||||
@ -71,6 +83,12 @@ public:
|
||||
bool createH5SummaryDataFiles() const;
|
||||
int createH5SummaryDataThreadCount() const;
|
||||
|
||||
DefaultSummaryPlotType defaultSummaryPlotType() const;
|
||||
std::vector<QString> defaultSummaryPlotTemplates() const;
|
||||
bool isDefaultSummaryPlotTemplate( QString filename ) const;
|
||||
void addToDefaultPlotTemplates( QString filename );
|
||||
void removeFromDefaultPlotTemplates( QString filename );
|
||||
|
||||
void appendRestartFileGroup( caf::PdmUiOrdering& uiOrdering ) const;
|
||||
void appendItemsToPlottingGroup( caf::PdmUiOrdering& uiOrdering ) const;
|
||||
|
||||
@ -92,6 +110,7 @@ public:
|
||||
void defineEditorAttribute( const caf::PdmFieldHandle* field,
|
||||
QString uiConfigName,
|
||||
caf::PdmUiEditorAttribute* attribute ) override;
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||
|
||||
protected:
|
||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||
@ -99,6 +118,10 @@ protected:
|
||||
bool* useOptionsOnly ) override;
|
||||
|
||||
private:
|
||||
caf::PdmField<DefaultSummaryPlotEnum> m_defaultSummaryPlot;
|
||||
caf::PdmField<bool> m_selectDefaultTemplates;
|
||||
caf::PdmField<std::vector<QString>> m_selectedDefaultTemplates;
|
||||
|
||||
caf::PdmField<bool> m_summaryRestartFilesShowImportDialog;
|
||||
caf::PdmField<SummaryRestartFilesImportModeType> m_summaryImportMode;
|
||||
caf::PdmField<SummaryRestartFilesImportModeType> m_gridImportMode;
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include "RicSummaryPlotBuilder.h"
|
||||
|
||||
#include "PlotTemplateCommands/RicSummaryPlotTemplateTools.h"
|
||||
#include "SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.h"
|
||||
#include "SummaryPlotCommands/RicSummaryPlotFeatureImpl.h"
|
||||
|
||||
@ -28,6 +29,7 @@
|
||||
#include "RifReaderEclipseSummary.h"
|
||||
#include "RifSummaryReaderInterface.h"
|
||||
|
||||
#include "RiaPreferencesSummary.h"
|
||||
#include "RimEnsembleCurveSet.h"
|
||||
#include "RimEnsembleCurveSetCollection.h"
|
||||
#include "RimMainPlotCollection.h"
|
||||
@ -408,6 +410,22 @@ RimSummaryMultiPlot*
|
||||
RicSummaryPlotBuilder::createAndAppendDefaultSummaryMultiPlot( const std::vector<RimSummaryCase*>& cases,
|
||||
const std::vector<RimSummaryCaseCollection*>& ensembles )
|
||||
{
|
||||
RiaPreferencesSummary* prefs = RiaPreferencesSummary::current();
|
||||
|
||||
if ( prefs->defaultSummaryPlotType() == RiaPreferencesSummary::DefaultSummaryPlotType::NONE ) return nullptr;
|
||||
|
||||
if ( prefs->defaultSummaryPlotType() == RiaPreferencesSummary::DefaultSummaryPlotType::PLOT_TEMPLATES )
|
||||
{
|
||||
RimSummaryMultiPlot* plotToSelect = nullptr;
|
||||
for ( auto& filename : prefs->defaultSummaryPlotTemplates() )
|
||||
{
|
||||
plotToSelect = RicSummaryPlotTemplateTools::create( filename, cases, ensembles );
|
||||
}
|
||||
return plotToSelect;
|
||||
}
|
||||
|
||||
if ( prefs->defaultSummaryCurvesTextFilter().trimmed().isEmpty() ) return nullptr;
|
||||
|
||||
RimProject* project = RimProject::current();
|
||||
auto* plotCollection = project->mainPlotCollection()->summaryMultiPlotCollection();
|
||||
|
||||
|
@ -9,6 +9,7 @@ set(SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicRenamePlotTemplateFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicEditPlotTemplateFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicDeletePlotTemplateFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicSetAsDefaultTemplateFeature.h
|
||||
)
|
||||
|
||||
set(SOURCE_GROUP_SOURCE_FILES
|
||||
@ -22,6 +23,7 @@ set(SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicRenamePlotTemplateFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicEditPlotTemplateFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicDeletePlotTemplateFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicSetAsDefaultTemplateFeature.cpp
|
||||
)
|
||||
|
||||
list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
|
||||
|
@ -36,7 +36,7 @@ void RicReloadPlotTemplatesFeature::rebuildFromDisc()
|
||||
RiaPreferences* prefs = RiaPreferences::current();
|
||||
|
||||
proj->setPlotTemplateFolders( prefs->plotTemplateFolders() );
|
||||
proj->rootPlotTemlateItem()->updateConnectedEditors();
|
||||
proj->rootPlotTemplateItem()->updateConnectedEditors();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -36,6 +36,7 @@ CAF_PDM_SOURCE_INIT( RicSelectPlotTemplateUi, "RicSelectPlotTemplateUi" );
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicSelectPlotTemplateUi::RicSelectPlotTemplateUi()
|
||||
: m_useMultiSelect( false )
|
||||
{
|
||||
CAF_PDM_InitObject( "RicSelectPlotTemplateUi" );
|
||||
|
||||
@ -44,6 +45,21 @@ RicSelectPlotTemplateUi::RicSelectPlotTemplateUi()
|
||||
m_selectedPlotTemplates.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSelectPlotTemplateUi::setMultiSelectMode( bool multiSelect )
|
||||
{
|
||||
m_useMultiSelect = multiSelect;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSelectPlotTemplateUi::setInitialSelection( std::vector<QString> selectedTemplates )
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -72,7 +88,7 @@ QList<caf::PdmOptionItemInfo>
|
||||
|
||||
if ( fieldNeedingOptions == &m_selectedPlotTemplates )
|
||||
{
|
||||
auto plotTemplateRoot = RimProject::current()->rootPlotTemlateItem();
|
||||
auto plotTemplateRoot = RimProject::current()->rootPlotTemplateItem();
|
||||
|
||||
RimPlotTemplateFolderItem::appendOptionItemsForPlotTemplates( options, plotTemplateRoot );
|
||||
}
|
||||
@ -92,7 +108,7 @@ void RicSelectPlotTemplateUi::defineEditorAttribute( const caf::PdmFieldHandle*
|
||||
auto a = dynamic_cast<caf::PdmUiTreeSelectionEditorAttribute*>( attribute );
|
||||
if ( a )
|
||||
{
|
||||
a->singleSelectionMode = true;
|
||||
a->singleSelectionMode = !m_useMultiSelect;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,9 @@
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmPtrArrayField.h"
|
||||
|
||||
#include <QString>
|
||||
#include <vector>
|
||||
|
||||
class RimPlotTemplateFileItem;
|
||||
class RimPlotTemplateFolderItem;
|
||||
|
||||
@ -35,6 +38,9 @@ class RicSelectPlotTemplateUi : public caf::PdmObject
|
||||
public:
|
||||
RicSelectPlotTemplateUi();
|
||||
|
||||
void setMultiSelectMode( bool multiSelect );
|
||||
void setInitialSelection( std::vector<QString> selectedTemplates );
|
||||
|
||||
std::vector<RimPlotTemplateFileItem*> selectedPlotTemplates();
|
||||
|
||||
private:
|
||||
@ -47,4 +53,5 @@ private:
|
||||
|
||||
private:
|
||||
caf::PdmPtrArrayField<RimPlotTemplateFileItem*> m_selectedPlotTemplates;
|
||||
bool m_useMultiSelect;
|
||||
};
|
||||
|
@ -0,0 +1,86 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2022 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 "RicSetAsDefaultTemplateFeature.h"
|
||||
|
||||
#include "PlotTemplates/RimPlotTemplateFileItem.h"
|
||||
|
||||
#include "RiaPreferencesSummary.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QInputDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QString>
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicSetAsDefaultTemplateFeature, "RicSetAsDefaultTemplateFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicSetAsDefaultTemplateFeature::isCommandEnabled()
|
||||
{
|
||||
return selectedTemplate() != nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSetAsDefaultTemplateFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
RimPlotTemplateFileItem* file = selectedTemplate();
|
||||
if ( file == nullptr ) return;
|
||||
|
||||
if ( isChecked )
|
||||
RiaPreferencesSummary::current()->addToDefaultPlotTemplates( file->absoluteFilePath() );
|
||||
else
|
||||
RiaPreferencesSummary::current()->removeFromDefaultPlotTemplates( file->absoluteFilePath() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSetAsDefaultTemplateFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText( "Default Template" );
|
||||
// actionToSetup->setIcon( QIcon( ":/SummaryTemplate16x16.png" ) );
|
||||
|
||||
RimPlotTemplateFileItem* file = selectedTemplate();
|
||||
if ( file != nullptr )
|
||||
{
|
||||
actionToSetup->setCheckable( true );
|
||||
actionToSetup->setChecked(
|
||||
RiaPreferencesSummary::current()->isDefaultSummaryPlotTemplate( file->absoluteFilePath() ) );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimPlotTemplateFileItem* RicSetAsDefaultTemplateFeature::selectedTemplate()
|
||||
{
|
||||
std::vector<caf::PdmUiItem*> uiItems;
|
||||
caf::SelectionManager::instance()->selectedItems( uiItems );
|
||||
if ( uiItems.size() != 1 ) return nullptr;
|
||||
|
||||
RimPlotTemplateFileItem* file = dynamic_cast<RimPlotTemplateFileItem*>( uiItems[0] );
|
||||
return file;
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2022 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 RimPlotTemplateFileItem;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicSetAsDefaultTemplateFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
|
||||
private:
|
||||
RimPlotTemplateFileItem* selectedTemplate();
|
||||
};
|
@ -175,6 +175,60 @@ RimSummaryMultiPlot* RicSummaryPlotTemplateTools::create( const QString& fileNam
|
||||
return newSummaryPlot;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryMultiPlot* RicSummaryPlotTemplateTools::create( const QString& fileName,
|
||||
const std::vector<RimSummaryCase*>& sumCases,
|
||||
const std::vector<RimSummaryCaseCollection*>& ensembles )
|
||||
{
|
||||
std::vector<QString> wellNames;
|
||||
std::vector<QString> groupNames;
|
||||
std::vector<QString> regions;
|
||||
|
||||
RiaSummaryAddressAnalyzer analyzer;
|
||||
|
||||
if ( !sumCases.empty() )
|
||||
{
|
||||
auto firstCase = sumCases.front();
|
||||
|
||||
analyzer.appendAddresses( firstCase->summaryReader()->allResultAddresses() );
|
||||
}
|
||||
else if ( !ensembles.empty() )
|
||||
{
|
||||
auto caseCollection = ensembles.front();
|
||||
|
||||
auto firstCase = caseCollection->firstSummaryCase();
|
||||
if ( firstCase != nullptr )
|
||||
{
|
||||
analyzer.appendAddresses( firstCase->summaryReader()->allResultAddresses() );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !analyzer.wellNames().empty() )
|
||||
wellNames.push_back( QString::fromStdString( *( analyzer.wellNames().begin() ) ) );
|
||||
if ( !analyzer.groupNames().empty() )
|
||||
groupNames.push_back( QString::fromStdString( *( analyzer.groupNames().begin() ) ) );
|
||||
if ( !analyzer.regionNumbers().empty() )
|
||||
regions.push_back( QString::number( *( analyzer.regionNumbers().begin() ) ) );
|
||||
|
||||
auto proj = RimProject::current();
|
||||
auto collections = proj->mainPlotCollection()->summaryMultiPlotCollection();
|
||||
|
||||
auto newSummaryPlot = RicSummaryPlotTemplateTools::createMultiPlotFromTemplateFile( fileName );
|
||||
if ( !newSummaryPlot ) return nullptr;
|
||||
|
||||
collections->addSummaryMultiPlot( newSummaryPlot );
|
||||
newSummaryPlot->resolveReferencesRecursively();
|
||||
|
||||
RicSummaryPlotTemplateTools::setValuesForPlaceholders( newSummaryPlot, sumCases, ensembles, wellNames, groupNames, regions );
|
||||
newSummaryPlot->initAfterReadRecursively();
|
||||
newSummaryPlot->loadDataAndUpdate();
|
||||
collections->updateConnectedEditors();
|
||||
|
||||
return newSummaryPlot;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -399,6 +453,32 @@ QString RicSummaryPlotTemplateTools::selectPlotTemplatePath()
|
||||
return {};
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<QString> RicSummaryPlotTemplateTools::selectDefaultPlotTemplates( std::vector<QString> currentSelection )
|
||||
{
|
||||
RiuPlotMainWindow* plotwindow = RiaGuiApplication::instance()->mainPlotWindow();
|
||||
RicSelectPlotTemplateUi ui;
|
||||
ui.setMultiSelectMode( true );
|
||||
ui.setInitialSelection( currentSelection );
|
||||
|
||||
caf::PdmUiPropertyViewDialog propertyDialog( plotwindow, &ui, "Select Default Plot Templates", "" );
|
||||
propertyDialog.resize( QSize( 500, 600 ) );
|
||||
|
||||
std::vector<QString> selection;
|
||||
|
||||
if ( propertyDialog.exec() == QDialog::Accepted && !ui.selectedPlotTemplates().empty() )
|
||||
{
|
||||
for ( auto item : ui.selectedPlotTemplates() )
|
||||
{
|
||||
selection.push_back( item->absoluteFilePath() );
|
||||
}
|
||||
}
|
||||
|
||||
return selection;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -34,6 +34,7 @@ class RimSummaryCaseCollection;
|
||||
class RifEclipseSummaryAddress;
|
||||
class RimSummaryMultiPlot;
|
||||
class RimSummaryAddressCollection;
|
||||
class RimPlotTemplateFileItem;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@ -43,7 +44,12 @@ class RicSummaryPlotTemplateTools
|
||||
public:
|
||||
static RimSummaryMultiPlot* create( const QString& fileName );
|
||||
|
||||
static QString selectPlotTemplatePath();
|
||||
static RimSummaryMultiPlot* create( const QString& fileName,
|
||||
const std::vector<RimSummaryCase*>& cases,
|
||||
const std::vector<RimSummaryCaseCollection*>& ensembles );
|
||||
|
||||
static QString selectPlotTemplatePath();
|
||||
static std::vector<QString> selectDefaultPlotTemplates( std::vector<QString> currentSelection );
|
||||
|
||||
static QString summaryCaseFieldKeyword();
|
||||
static QString summaryGroupFieldKeyword();
|
||||
|
@ -1028,6 +1028,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
||||
menuBuilder << "RicDeletePlotTemplateFeature";
|
||||
menuBuilder << "RicEditPlotTemplateFeature";
|
||||
menuBuilder << "Separator";
|
||||
menuBuilder << "RicSetAsDefaultTemplateFeature";
|
||||
menuBuilder << "Separator";
|
||||
menuBuilder << "RicReloadPlotTemplatesFeature";
|
||||
}
|
||||
else if ( dynamic_cast<RimSummaryMultiPlot*>( firstUiItem ) )
|
||||
|
@ -1320,7 +1320,7 @@ RimMeasurement* RimProject::measurement() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimPlotTemplateFolderItem* RimProject::rootPlotTemlateItem() const
|
||||
RimPlotTemplateFolderItem* RimProject::rootPlotTemplateItem() const
|
||||
{
|
||||
return m_plotTemplateTopFolder;
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ public:
|
||||
caf::AppEnum<RiaDefines::EclipseUnitSystem> commonUnitSystemForAllCases() const;
|
||||
RimMeasurement* measurement() const;
|
||||
|
||||
RimPlotTemplateFolderItem* rootPlotTemlateItem() const;
|
||||
RimPlotTemplateFolderItem* rootPlotTemplateItem() const;
|
||||
|
||||
std::vector<caf::FilePath*> allFilePaths() const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user