Merge pull request #4803 from OPM/summary-template-adjustments

Adjustments to summary templates
This commit is contained in:
Magne Sjaastad
2019-09-30 22:27:35 +02:00
committed by GitHub
20 changed files with 594 additions and 119 deletions

View File

@@ -312,6 +312,9 @@ RiaPreferences::RiaPreferences( void )
"",
"" );
m_searchPlotTemplateFoldersRecursively.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
CAF_PDM_InitFieldNoDefault( &m_defaultPlotTemplate, "defaultPlotTemplate", "Default Plot Template", "", "", "" );
// m_plotTemplateFolders.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() );
}
//--------------------------------------------------------------------------------------------------
@@ -331,22 +334,32 @@ void RiaPreferences::defineEditorAttribute( const caf::PdmFieldHandle* field,
{
m_readerSettings->defineEditorAttribute( field, uiConfigName, attribute );
if ( field == &scriptDirectories || field == &m_plotTemplateFolders )
{
caf::PdmUiFilePathEditorAttribute* myAttr = dynamic_cast<caf::PdmUiFilePathEditorAttribute*>( attribute );
if ( myAttr )
{
myAttr->m_selectDirectory = true;
myAttr->m_appendUiSelectedFolderToText = true;
if ( field == &scriptDirectories || field == &m_plotTemplateFolders )
{
myAttr->m_selectDirectory = true;
myAttr->m_appendUiSelectedFolderToText = true;
}
else if ( field == &m_defaultPlotTemplate )
{
auto folders = plotTemplateFolders();
if ( !folders.empty() )
{
myAttr->m_defaultPath = folders.back();
}
}
}
}
else if ( field == &octaveShowHeaderInfoWhenExecutingScripts || field == &autocomputeDepthRelatedProperties ||
field == &loadAndShowSoil || field == &useShaders || field == &showHud ||
field == &m_appendClassNameToUiText || field == &m_appendFieldKeywordToToolTipText ||
field == &m_showTestToolbar || field == &m_includeFractureDebugInfoFile ||
field == &showLasCurveWithoutTvdWarning || field == &holoLensDisableCertificateVerification ||
field == &m_showProjectChangedDialog || field == &m_searchPlotTemplateFoldersRecursively ||
field == &showLegendBackground )
if ( field == &octaveShowHeaderInfoWhenExecutingScripts || field == &autocomputeDepthRelatedProperties ||
field == &loadAndShowSoil || field == &useShaders || field == &showHud || field == &m_appendClassNameToUiText ||
field == &m_appendFieldKeywordToToolTipText || field == &m_showTestToolbar ||
field == &m_includeFractureDebugInfoFile || field == &showLasCurveWithoutTvdWarning ||
field == &holoLensDisableCertificateVerification || field == &m_showProjectChangedDialog ||
field == &m_searchPlotTemplateFoldersRecursively || field == &showLegendBackground )
{
caf::PdmUiCheckBoxEditorAttribute* myAttr = dynamic_cast<caf::PdmUiCheckBoxEditorAttribute*>( attribute );
if ( myAttr )
@@ -438,6 +451,7 @@ void RiaPreferences::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering&
caf::PdmUiGroup* group = uiOrdering.addNewGroup( "Plot Templates" );
group->add( &m_plotTemplateFolders );
group->add( &m_searchPlotTemplateFoldersRecursively );
group->add( &m_defaultPlotTemplate );
}
else if ( uiConfigName == RiaPreferences::tabNameScripting() )
{
@@ -732,6 +746,22 @@ void RiaPreferences::appendPlotTemplateFolders( const QString& folder )
m_plotTemplateFolders = folders;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaPreferences::defaultPlotTemplateAbsolutePath() const
{
return m_defaultPlotTemplate().path();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaPreferences::setDefaultPlotTemplatePath( const QString& templatePath )
{
m_defaultPlotTemplate = templatePath;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -82,6 +82,8 @@ public:
bool searchPlotTemplateFoldersRecursively() const;
QStringList plotTemplateFolders() const;
void appendPlotTemplateFolders( const QString& folder );
QString defaultPlotTemplateAbsolutePath() const;
void setDefaultPlotTemplatePath( const QString& templatePath );
std::map<RiaDefines::FontSettingType, RiaFontCache::FontSize> defaultFontSizes() const;
@@ -167,8 +169,9 @@ private:
caf::PdmField<QString> m_dateFormat;
caf::PdmField<QString> m_timeFormat;
caf::PdmField<QString> m_plotTemplateFolders;
caf::PdmField<bool> m_searchPlotTemplateFoldersRecursively;
caf::PdmField<QString> m_plotTemplateFolders;
caf::PdmField<bool> m_searchPlotTemplateFoldersRecursively;
caf::PdmField<caf::FilePath> m_defaultPlotTemplate;
QStringList m_tabNames;
};

View File

@@ -18,6 +18,8 @@
#include "RicHelpFeatures.h"
#include "SummaryPlotCommands/RicSummaryPlotFeatureImpl.h"
#include "RiaApplication.h"
#include "RiaBaseDefs.h"
#include "RiaVersionInfo.h"
@@ -35,6 +37,7 @@
CAF_CMD_SOURCE_INIT( RicHelpAboutFeature, "RicHelpAboutFeature" );
CAF_CMD_SOURCE_INIT( RicHelpCommandLineFeature, "RicHelpCommandLineFeature" );
CAF_CMD_SOURCE_INIT( RicHelpSummaryCommandLineFeature, "RicHelpSummaryCommandLineFeature" );
CAF_CMD_SOURCE_INIT( RicHelpOpenUsersGuideFeature, "RicHelpOpenUsersGuideFeature" );
//--------------------------------------------------------------------------------------------------
@@ -205,6 +208,34 @@ void RicHelpCommandLineFeature::setupActionLook( QAction* actionToSetup )
actionToSetup->setText( "&Command Line Help" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicHelpSummaryCommandLineFeature::isCommandEnabled()
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicHelpSummaryCommandLineFeature::onActionTriggered( bool isChecked )
{
this->disableModelChangeContribution();
RiaApplication* app = RiaApplication::instance();
QString text = RicSummaryPlotFeatureImpl::summaryPlotCommandLineHelpText();
app->showFormattedTextInMessageBoxOrConsole( text );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicHelpSummaryCommandLineFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "&Summary Command Line Help" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -48,6 +48,20 @@ protected:
void setupActionLook( QAction* actionToSetup ) override;
};
//==================================================================================================
///
//==================================================================================================
class RicHelpSummaryCommandLineFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};
//==================================================================================================
///
//==================================================================================================

View File

@@ -5,6 +5,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RicCreatePlotFromSelectionFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicSelectPlotTemplateUi.h
${CMAKE_CURRENT_LIST_DIR}/RicSummaryPlotTemplateTools.h
${CMAKE_CURRENT_LIST_DIR}/RicReloadPlotTemplatesFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicCreatePlotFromTemplateFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicCreatePlotFromTemplateByShortcutFeature.h
)
set (SOURCE_GROUP_SOURCE_FILES
@@ -13,6 +15,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RicCreatePlotFromSelectionFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicSelectPlotTemplateUi.cpp
${CMAKE_CURRENT_LIST_DIR}/RicSummaryPlotTemplateTools.cpp
${CMAKE_CURRENT_LIST_DIR}/RicReloadPlotTemplatesFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicCreatePlotFromTemplateFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicCreatePlotFromTemplateByShortcutFeature.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@@ -18,26 +18,15 @@
#include "RicCreatePlotFromSelectionFeature.h"
#include "RicSelectPlotTemplateUi.h"
#include "RiaGuiApplication.h"
#include "RicSummaryPlotTemplateTools.h"
#include "RiaGuiApplication.h"
#include "RiaLogging.h"
#include "RiaSummaryTools.h"
#include "PlotTemplates/RimPlotTemplateFileItem.h"
#include "RimDialogData.h"
#include "RimMainPlotCollection.h"
#include "RimProject.h"
#include "RimSummaryCase.h"
#include "RimSummaryCurve.h"
#include "RimSummaryPlot.h"
#include "RimSummaryPlotCollection.h"
#include "RimWellPath.h"
#include "RiuPlotMainWindow.h"
#include "cafPdmObject.h"
#include "cafPdmUiPropertyViewDialog.h"
#include "cafSelectionManager.h"
@@ -59,60 +48,11 @@ bool RicCreatePlotFromSelectionFeature::isCommandEnabled()
//--------------------------------------------------------------------------------------------------
void RicCreatePlotFromSelectionFeature::onActionTriggered( bool isChecked )
{
RiuPlotMainWindow* plotwindow = RiaGuiApplication::instance()->mainPlotWindow();
RicSelectPlotTemplateUi* ui = RiaGuiApplication::instance()->project()->dialogData()->selectPlotTemplateUi();
caf::PdmUiPropertyViewDialog propertyDialog( plotwindow, ui, "Select Plot Template", "" );
if ( propertyDialog.exec() != QDialog::Accepted ) return;
if ( ui->selectedPlotTemplates().empty() ) return;
QString fileName = ui->selectedPlotTemplates().front()->absoluteFilePath();
QString fileName = RicSummaryPlotTemplateTools::selectPlotTemplatePath();
std::vector<RimSummaryCase*> sumCases = selectedSummaryCases();
RimSummaryPlot* newSummaryPlot = RicSummaryPlotTemplateTools::createPlotFromTemplateFile( fileName );
if ( newSummaryPlot )
{
RimSummaryPlotCollection* plotColl =
RiaApplication::instance()->project()->mainPlotCollection()->summaryPlotCollection();
plotColl->summaryPlots.push_back( newSummaryPlot );
newSummaryPlot->resolveReferencesRecursively();
newSummaryPlot->initAfterReadRecursively();
QString nameOfCopy = QString( "Copy of " ) + newSummaryPlot->description();
newSummaryPlot->setDescription( nameOfCopy );
auto summaryCurves = newSummaryPlot->summaryCurves();
for ( const auto& curve : summaryCurves )
{
auto fieldHandle = curve->findField( "SummaryCase" );
if ( fieldHandle )
{
auto referenceString = fieldHandle->xmlCapability()->referenceString();
auto stringList = referenceString.split( " " );
if ( stringList.size() == 2 )
{
QString indexAsString = stringList[1];
bool conversionOk = false;
auto index = indexAsString.toUInt( &conversionOk );
if ( conversionOk && index < sumCases.size() )
{
curve->setSummaryCaseY( sumCases[index] );
}
}
}
}
plotColl->updateConnectedEditors();
newSummaryPlot->loadDataAndUpdate();
}
RicSummaryPlotTemplateTools::appendSummaryPlotToPlotCollection( newSummaryPlot, sumCases );
}
//--------------------------------------------------------------------------------------------------

View File

@@ -0,0 +1,98 @@
////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicCreatePlotFromTemplateByShortcutFeature.h"
#include "RiaApplication.h"
#include "RiaPreferences.h"
#include "RicSummaryPlotTemplateTools.h"
#include "RimSummaryCase.h"
#include "RiuPlotMainWindow.h"
#include "cafSelectionManager.h"
#include <QAction>
#include <QFile>
#include <QMessageBox>
CAF_CMD_SOURCE_INIT( RicCreatePlotFromTemplateByShortcutFeature, "RicCreatePlotFromTemplateByShortcutFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicCreatePlotFromTemplateByShortcutFeature::isCommandEnabled()
{
return !selectedSummaryCases().empty();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicCreatePlotFromTemplateByShortcutFeature::onActionTriggered( bool isChecked )
{
QString fileName = RiaApplication::instance()->preferences()->defaultPlotTemplateAbsolutePath();
if ( !QFile::exists( fileName ) )
{
auto mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow();
auto reply = QMessageBox::question( mainPlotWindow,
QString( "No default plot template found." ),
QString( "Do you want to define default plot template? " ),
QMessageBox::Yes | QMessageBox::No );
if ( reply == QMessageBox::No ) return;
QString fileNameSelectedInUi = RicSummaryPlotTemplateTools::selectPlotTemplatePath();
if ( fileNameSelectedInUi.isEmpty() ) return;
fileName = fileNameSelectedInUi;
RiaApplication::instance()->preferences()->setDefaultPlotTemplatePath( fileName );
}
std::vector<RimSummaryCase*> sumCases = selectedSummaryCases();
RimSummaryPlot* newSummaryPlot = RicSummaryPlotTemplateTools::createPlotFromTemplateFile( fileName );
RicSummaryPlotTemplateTools::appendSummaryPlotToPlotCollection( newSummaryPlot, sumCases );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicCreatePlotFromTemplateByShortcutFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Create Plot from Default Template" );
actionToSetup->setIcon( QIcon( ":/SummaryTemplate16x16.png" ) );
QKeySequence keySeq( Qt::CTRL + Qt::Key_T );
actionToSetup->setShortcut( keySeq );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimSummaryCase*> RicCreatePlotFromTemplateByShortcutFeature::selectedSummaryCases() const
{
std::vector<RimSummaryCase*> objects;
caf::SelectionManager::instance()->objectsByType( &objects );
return objects;
}

View File

@@ -0,0 +1,41 @@
////////////////////////////////////////////////////////////////////////////////
//
// 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"
#include <vector>
class RimSummaryCase;
//==================================================================================================
///
//==================================================================================================
class RicCreatePlotFromTemplateByShortcutFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
private:
std::vector<RimSummaryCase*> selectedSummaryCases() const;
};

View File

@@ -0,0 +1,68 @@
////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicCreatePlotFromTemplateFeature.h"
#include "RicSummaryPlotTemplateTools.h"
#include "RimSummaryCase.h"
#include "cafSelectionManager.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicCreatePlotFromTemplateFeature, "RicCreatePlotFromTemplateFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicCreatePlotFromTemplateFeature::isCommandEnabled()
{
return !selectedSummaryCases().empty();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicCreatePlotFromTemplateFeature::onActionTriggered( bool isChecked )
{
QString fileName = userData().toString();
std::vector<RimSummaryCase*> sumCases = selectedSummaryCases();
RimSummaryPlot* newSummaryPlot = RicSummaryPlotTemplateTools::createPlotFromTemplateFile( fileName );
RicSummaryPlotTemplateTools::appendSummaryPlotToPlotCollection( newSummaryPlot, sumCases );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicCreatePlotFromTemplateFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Create Plot from Template" );
actionToSetup->setIcon( QIcon( ":/SummaryTemplate16x16.png" ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimSummaryCase*> RicCreatePlotFromTemplateFeature::selectedSummaryCases() const
{
std::vector<RimSummaryCase*> objects;
caf::SelectionManager::instance()->objectsByType( &objects );
return objects;
}

View File

@@ -0,0 +1,41 @@
////////////////////////////////////////////////////////////////////////////////
//
// 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"
#include <vector>
class RimSummaryCase;
//==================================================================================================
///
//==================================================================================================
class RicCreatePlotFromTemplateFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
private:
std::vector<RimSummaryCase*> selectedSummaryCases() const;
};

View File

@@ -18,11 +18,27 @@
#include "RicSummaryPlotTemplateTools.h"
#include "RiaApplication.h"
#include "RiaGuiApplication.h"
#include "RiaLogging.h"
#include "RiaSummaryCurveAnalyzer.h"
#include "RicSelectPlotTemplateUi.h"
#include "RifSummaryReaderInterface.h"
#include "PlotTemplates/RimPlotTemplateFileItem.h"
#include "RimDialogData.h"
#include "RimMainPlotCollection.h"
#include "RimProject.h"
#include "RimSummaryCase.h"
#include "RimSummaryCurve.h"
#include "RimSummaryPlot.h"
#include "RimSummaryPlotCollection.h"
#include "RiuPlotMainWindow.h"
#include "cafPdmUiPropertyViewDialog.h"
#include <QFile>
@@ -56,6 +72,68 @@ RimSummaryPlot* RicSummaryPlotTemplateTools::createPlotFromTemplateFile( const Q
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryPlotTemplateTools::appendSummaryPlotToPlotCollection(
RimSummaryPlot* summaryPlot, const std::vector<RimSummaryCase*>& selectedSummaryCases )
{
if ( summaryPlot )
{
RimSummaryPlotCollection* plotColl =
RiaApplication::instance()->project()->mainPlotCollection()->summaryPlotCollection();
plotColl->summaryPlots.push_back( summaryPlot );
summaryPlot->resolveReferencesRecursively();
summaryPlot->initAfterReadRecursively();
auto summaryCurves = summaryPlot->summaryCurves();
for ( const auto& curve : summaryCurves )
{
auto fieldHandle = curve->findField( "SummaryCase" );
if ( fieldHandle )
{
auto referenceString = fieldHandle->xmlCapability()->referenceString();
auto stringList = referenceString.split( " " );
if ( stringList.size() == 2 )
{
QString indexAsString = stringList[1];
bool conversionOk = false;
auto index = indexAsString.toUInt( &conversionOk );
if ( conversionOk && index < selectedSummaryCases.size() )
{
auto summaryCaseY = selectedSummaryCases[index];
curve->setSummaryCaseY( summaryCaseY );
auto currentAddressY = curve->summaryAddressY();
if ( summaryCaseY->summaryReader() &&
!summaryCaseY->summaryReader()->hasAddress( currentAddressY ) )
{
auto allAddresses = summaryCaseY->summaryReader()->allResultAddresses();
auto candidate = RicSummaryPlotTemplateTools::firstAddressByQuantity( currentAddressY,
allAddresses );
if ( candidate.category() != RifEclipseSummaryAddress::SUMMARY_INVALID )
{
curve->setSummaryAddressY( candidate );
}
}
}
}
}
}
// TODO: Create additional curves in selected case count is larger than template count
plotColl->updateConnectedEditors();
summaryPlot->loadDataAndUpdate();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -156,3 +234,41 @@ QString RicSummaryPlotTemplateTools::htmlTextFromCount( const QString& itemText,
return text;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicSummaryPlotTemplateTools::selectPlotTemplatePath()
{
RiuPlotMainWindow* plotwindow = RiaGuiApplication::instance()->mainPlotWindow();
RicSelectPlotTemplateUi* ui = RiaGuiApplication::instance()->project()->dialogData()->selectPlotTemplateUi();
caf::PdmUiPropertyViewDialog propertyDialog( plotwindow, ui, "Select Plot Template", "" );
if ( propertyDialog.exec() == QDialog::Accepted && !ui->selectedPlotTemplates().empty() )
{
QString fileName = ui->selectedPlotTemplates().front()->absoluteFilePath();
return fileName;
}
return QString();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifEclipseSummaryAddress
RicSummaryPlotTemplateTools::firstAddressByQuantity( const RifEclipseSummaryAddress& sourceAddress,
const std::set<RifEclipseSummaryAddress>& allAddresses )
{
for ( const auto& a : allAddresses )
{
if ( sourceAddress.quantityName() == a.quantityName() )
{
return a;
}
}
return RifEclipseSummaryAddress();
}

View File

@@ -29,7 +29,7 @@ class PdmObject;
}
class RimSummaryPlot;
class RimSummaryPlot;
class RimSummaryCase;
class RifEclipseSummaryAddress;
//==================================================================================================
@@ -39,9 +39,18 @@ class RicSummaryPlotTemplateTools
{
public:
static RimSummaryPlot* createPlotFromTemplateFile( const QString& fileName );
static QString htmlTextFromPlotAndSelection( const RimSummaryPlot* templatePlot,
const std::set<RifEclipseSummaryAddress>& selectedSummaryAddresses,
const std::vector<caf::PdmObject*>& selectedSources );
static void appendSummaryPlotToPlotCollection( RimSummaryPlot* summaryPlot,
const std::vector<RimSummaryCase*>& selectedSummaryCases );
static QString htmlTextFromPlotAndSelection( const RimSummaryPlot* templatePlot,
const std::set<RifEclipseSummaryAddress>& selectedSummaryAddresses,
const std::vector<caf::PdmObject*>& selectedSources );
static QString htmlTextFromCount( const QString& itemText, size_t requiredItemCount, size_t selectionCount );
static QString selectPlotTemplatePath();
private:
static RifEclipseSummaryAddress firstAddressByQuantity( const RifEclipseSummaryAddress& sourceAddress,
const std::set<RifEclipseSummaryAddress>& allAddresses );
};

View File

@@ -283,32 +283,9 @@ void RicSummaryPlotFeatureImpl::createSummaryPlotsFromArgumentLine( const QStrin
{
if ( arguments[optionIdx] == "-help" )
{
// clang-format off
RiaApplication::instance()->showFormattedTextInMessageBoxOrConsole(
"The --summaryplot option has the following syntax:\n"
"\n"
"[<plotOptions>] <eclipsesummaryvectorfilters> [<eclipsedatafiles>]\n"
"\n"
"It Creates one summary plot for each of the the summary vectors matched by the "
"<eclipsesummaryvectorfilters> using all the <eclipsedatafiles> in each plot.\n"
"The <eclipsesummaryvectorfilters> has the syntax <vectorname>[:<item>[:<subitem>[:i,j,k]]] and can be repeated.\n"
"Wildcards can also be used, eg. \"WOPT:*\" to select the total oil production from all the wells.\n"
"3D Grid properties from restart files can also be requested in the form <propertyname>:i,i,k.\n"
"The <eclipsedatafiles> can be written with or without extension.\n"
"As long as only summary vectors are requested, only the corresponding SMSPEC file will be opened for each case.\n"
"If a grid property is requested, however (eg. SOIL:20,21,1) the corresponding EGRID and restart data will be loaded as well.\n"
"\n"
"The summary plot options are: \n"
" -help\t Show this help text and ignore the rest of the options.\n"
" -h\t Include history vectors. Will be read from the summary file if the vectors exist.\n"
" \t Only history vectors from the first summary case in the project will be included.\n"
" -nl\t Omit legend in plot.\n"
" -s\t Create only one plot including all the defined vectors and cases.\n"
" -n\t Scale all curves into the range 0.0-1.0. Useful when using -s.\n"
" -e\t Import all the cases as an ensemble, and create ensemble curves sets instead of single curves.\n"
" -c <parametername>\t Same as -e, but colors the curves by the ensemble parameter <parametername> . \n"
" -cl <parametername>\t Same as -c, but uses logarithmic legend.\n" );
// clang-format on
QString text = RicSummaryPlotFeatureImpl::summaryPlotCommandLineHelpText();
RiaApplication::instance()->showFormattedTextInMessageBoxOrConsole( text );
return;
}
@@ -845,3 +822,38 @@ void RicSummaryPlotFeatureImpl::filteredSummaryAdressesFromCase(
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicSummaryPlotFeatureImpl::summaryPlotCommandLineHelpText()
{
// clang-format off
QString txt =
"The --summaryplot option has the following syntax:\n"
"\n"
"[<plotOptions>] <eclipsesummaryvectorfilters> [<eclipsedatafiles>]\n"
"\n"
"It creates one summary plot for each of the the summary vectors matched by the "
"<eclipsesummaryvectorfilters> using all the <eclipsedatafiles> in each plot.\n"
"The <eclipsesummaryvectorfilters> has the syntax <vectorname>[:<item>[:<subitem>[:i,j,k]]] and can be repeated.\n"
"Wildcards can also be used, eg. \"WOPT:*\" to select the total oil production from all the wells.\n"
"3D Grid properties from restart files can also be requested in the form <propertyname>:i,i,k.\n"
"The <eclipsedatafiles> can be written with or without extension.\n"
"As long as only summary vectors are requested, only the corresponding SMSPEC file will be opened for each case.\n"
"If a grid property is requested, however (eg. SOIL:20,21,1) the corresponding EGRID and restart data will be loaded as well.\n"
"\n"
"The summary plot options are: \n"
" -help\t Show this help text and ignore the rest of the options.\n"
" -h\t Include history vectors. Will be read from the summary file if the vectors exist.\n"
" \t Only history vectors from the first summary case in the project will be included.\n"
" -nl\t Omit legend in plot.\n"
" -s\t Create only one plot including all the defined vectors and cases.\n"
" -n\t Scale all curves into the range 0.0-1.0. Useful when using -s.\n"
" -e\t Import all the cases as an ensemble, and create ensemble curves sets instead of single curves.\n"
" -c <parametername>\t Same as -e, but colors the curves by the ensemble parameter <parametername> . \n"
" -cl <parametername>\t Same as -c, but uses logarithmic legend.\n";
// clang-format on
return txt;
}

View File

@@ -44,6 +44,8 @@ public:
std::set<RifEclipseSummaryAddress>* setToInsertFilteredAddressesIn,
std::vector<bool>* usedFilters );
static QString summaryPlotCommandLineHelpText();
private:
static std::vector<RimSummaryCurve*> addCurvesFromAddressFiltersToPlot( const QStringList& curveFilters,
RimSummaryPlot* plot,

View File

@@ -813,6 +813,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
// is aware of multiple selected items, move the command to this list
// without using dyncamic_cast.
caf::PdmUiItem* uiItem = uiItems[0];
menuBuilder << "RicPasteTimeHistoryCurveFeature";
menuBuilder << "RicPasteAsciiDataCurveFeature";
menuBuilder << "RicPasteSummaryCaseFeature";
@@ -841,14 +843,21 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
menuBuilder << "RicCreateSummaryCaseCollectionFeature";
menuBuilder << "Separator";
menuBuilder << "RicCutReferencesToClipboardFeature";
menuBuilder << "Separator";
if ( dynamic_cast<RimSummaryCase*>( uiItem ) )
{
menuBuilder << "RicCreatePlotFromSelectionFeature";
menuBuilder << "RicCreatePlotFromTemplateByShortcutFeature";
appendPlotTemplateMenus( menuBuilder );
}
menuBuilder << "Separator";
menuBuilder << "RicCloseSummaryCaseFeature";
menuBuilder << "RicCloseSummaryCaseInCollectionFeature";
menuBuilder << "RicDeleteSummaryCaseCollectionFeature";
menuBuilder << "RicCloseObservedDataFeature";
menuBuilder << "RicCreatePlotFromSelectionFeature";
// Work in progress -- End
appendCreateCompletions( menuBuilder, menuBuilder.itemCount() > 0u );
bool addedExportWellPaths = appendExportWellPaths( menuBuilder, menuBuilder.itemCount() > 0u ) > 0;
@@ -859,7 +868,6 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
menuBuilder.addSeparator();
}
caf::PdmUiItem* uiItem = uiItems[0];
if ( dynamic_cast<RimWellLogFileChannel*>( uiItem ) )
{
menuBuilder << "RicAddWellLogToPlotFeature";
@@ -1032,6 +1040,19 @@ void RimContextCommandBuilder::createExecuteScriptForCasesFeatureMenu( caf::CmdF
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimContextCommandBuilder::appendPlotTemplateMenus( caf::CmdFeatureMenuBuilder& menuBuilder )
{
RiaApplication* app = RiaApplication::instance();
RimProject* proj = app->project();
if ( proj && proj->rootPlotTemlateItem() )
{
appendPlotTemplateItems( menuBuilder, proj->rootPlotTemlateItem() );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -1069,6 +1090,34 @@ void RimContextCommandBuilder::appendScriptItems( caf::CmdFeatureMenuBuilder& me
menuBuilder.subMenuEnd();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimContextCommandBuilder::appendPlotTemplateItems( caf::CmdFeatureMenuBuilder& menuBuilder,
RimPlotTemplateFolderItem* plotTemplateRoot )
{
if ( !plotTemplateRoot->fileNames().empty() )
{
auto folderName = plotTemplateRoot->uiName();
menuBuilder.subMenuStart( folderName );
for ( const auto& fileItem : plotTemplateRoot->fileNames() )
{
QString menuText = fileItem->uiName();
menuBuilder.addCmdFeatureWithUserData( "RicCreatePlotFromTemplateFeature",
menuText,
QVariant( fileItem->absoluteFilePath() ) );
}
menuBuilder.subMenuEnd();
}
for ( const auto& folder : plotTemplateRoot->subFolders() )
{
appendPlotTemplateItems( menuBuilder, folder );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -32,6 +32,7 @@ class QStringList;
class QMenu;
class RimWellPath;
class RimScriptCollection;
class RimPlotTemplateFolderItem;
//==================================================================================================
///
@@ -45,7 +46,11 @@ public:
private:
static std::vector<RimWellPath*> allWellPaths();
static void createExecuteScriptForCasesFeatureMenu( caf::CmdFeatureMenuBuilder& menuBuilder );
static void appendPlotTemplateMenus( caf::CmdFeatureMenuBuilder& menuBuilder );
static void appendScriptItems( caf::CmdFeatureMenuBuilder& menuBuilder, RimScriptCollection* scriptCollection );
static void appendPlotTemplateItems( caf::CmdFeatureMenuBuilder& menuBuilder,
RimPlotTemplateFolderItem* plotTemplateRoot );
static int appendImportMenu( caf::CmdFeatureMenuBuilder& menuBuilder, bool addSeparatorBeforeMenu = false );
static int appendCreateCompletions( caf::CmdFeatureMenuBuilder& menuBuilder, bool addSeparatorBeforeMenu = false );

View File

@@ -548,6 +548,7 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi( const caf::PdmFieldHandle*
summaryPlot->updatePlotTitle();
summaryPlot->loadDataAndUpdate();
summaryPlot->updateConnectedEditors();
if ( ensembleCurveColl )
{

View File

@@ -537,6 +537,7 @@ void RiuMainWindow::createMenus()
QMenu* helpMenu = menuBar()->addMenu( "&Help" );
helpMenu->addAction( cmdFeatureMgr->action( "RicHelpAboutFeature" ) );
helpMenu->addAction( cmdFeatureMgr->action( "RicHelpCommandLineFeature" ) );
helpMenu->addAction( cmdFeatureMgr->action( "RicHelpSummaryCommandLineFeature" ) );
helpMenu->addSeparator();
helpMenu->addAction( cmdFeatureMgr->action( "RicHelpOpenUsersGuideFeature" ) );
}

View File

@@ -293,6 +293,7 @@ void RiuPlotMainWindow::createMenus()
QMenu* helpMenu = menuBar()->addMenu( "&Help" );
helpMenu->addAction( cmdFeatureMgr->action( "RicHelpAboutFeature" ) );
helpMenu->addAction( cmdFeatureMgr->action( "RicHelpCommandLineFeature" ) );
helpMenu->addAction( cmdFeatureMgr->action( "RicHelpSummaryCommandLineFeature" ) );
helpMenu->addSeparator();
helpMenu->addAction( cmdFeatureMgr->action( "RicHelpOpenUsersGuideFeature" ) );
}
@@ -727,16 +728,6 @@ void RiuPlotMainWindow::selectedObjectsChanged()
m_pdmUiPropertyView->showProperties( firstSelectedObject );
if ( firstSelectedObject )
{
RimSummaryPlot* summaryPlot = nullptr;
firstSelectedObject->firstAncestorOrThisOfType( summaryPlot );
if ( summaryPlot )
{
updateSummaryPlotToolBar();
}
}
if ( uiItems.size() == 1 && m_allowActiveViewChangeFromSelection )
{
// Find the reservoir view or the Plot that the selected item is within
@@ -773,6 +764,19 @@ void RiuPlotMainWindow::selectedObjectsChanged()
setActiveViewer( selectedWindow->viewWidget() );
setBlockSubWindowProjectTreeSelection( false );
}
m_activePlotViewWindow = selectedWindow;
if ( firstSelectedObject )
{
RimSummaryPlot* summaryPlot = nullptr;
firstSelectedObject->firstAncestorOrThisOfType( summaryPlot );
if ( summaryPlot )
{
updateSummaryPlotToolBar();
}
}
// The only way to get to this code is by selection change initiated from the project tree view
// As we are activating an MDI-window, the focus is given to this MDI-window
// Set focus back to the tree view to be able to continue keyboard tree view navigation

View File

@@ -86,6 +86,12 @@ bool RiuTreeViewEventFilter::eventFilter( QObject* obj, QEvent* event )
matches = caf::CmdFeatureManager::instance()->commandFeaturesMatchingKeyboardShortcut(
QKeySequence::Delete );
}
else
{
QKeySequence keySeq( keyEvent->modifiers() + keyEvent->key() );
matches = caf::CmdFeatureManager::instance()->commandFeaturesMatchingKeyboardShortcut( keySeq );
}
for ( caf::CmdFeature* feature : matches )
{