mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4796 Summary Plot Template : Add context menu of summary cases
This commit is contained in:
@@ -754,6 +754,14 @@ QString RiaPreferences::defaultPlotTemplateAbsolutePath() const
|
||||
return m_defaultPlotTemplate().path();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaPreferences::setDefaultPlotTemplatePath( const QString& templatePath )
|
||||
{
|
||||
m_defaultPlotTemplate = templatePath;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -83,6 +83,7 @@ public:
|
||||
QStringList plotTemplateFolders() const;
|
||||
void appendPlotTemplateFolders( const QString& folder );
|
||||
QString defaultPlotTemplateAbsolutePath() const;
|
||||
void setDefaultPlotTemplatePath( const QString& templatePath );
|
||||
|
||||
std::map<RiaDefines::FontSettingType, RiaFontCache::FontSize> defaultFontSizes() const;
|
||||
|
||||
|
||||
@@ -20,12 +20,9 @@
|
||||
|
||||
#include "RiaGuiApplication.h"
|
||||
|
||||
#include "RicSelectPlotTemplateUi.h"
|
||||
#include "RicSummaryPlotTemplateTools.h"
|
||||
|
||||
#include "PlotTemplates/RimPlotTemplateFileItem.h"
|
||||
#include "RimDialogData.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimSummaryCase.h"
|
||||
|
||||
#include "RiuPlotMainWindow.h"
|
||||
@@ -51,16 +48,7 @@ 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 );
|
||||
|
||||
@@ -20,13 +20,18 @@
|
||||
|
||||
#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" );
|
||||
|
||||
@@ -44,6 +49,23 @@ bool RicCreatePlotFromTemplateByShortcutFeature::isCommandEnabled()
|
||||
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 fileName = RicSummaryPlotTemplateTools::selectPlotTemplatePath();
|
||||
|
||||
RiaApplication::instance()->preferences()->setDefaultPlotTemplatePath( fileName );
|
||||
}
|
||||
|
||||
std::vector<RimSummaryCase*> sumCases = selectedSummaryCases();
|
||||
|
||||
RimSummaryPlot* newSummaryPlot = RicSummaryPlotTemplateTools::createPlotFromTemplateFile( fileName );
|
||||
@@ -55,7 +77,7 @@ void RicCreatePlotFromTemplateByShortcutFeature::onActionTriggered( bool isCheck
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCreatePlotFromTemplateByShortcutFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText( "Create Plot from Template" );
|
||||
actionToSetup->setText( "Create Plot from Default Template" );
|
||||
actionToSetup->setIcon( QIcon( ":/SummaryTemplate16x16.png" ) );
|
||||
|
||||
QKeySequence keySeq( Qt::CTRL + Qt::Key_T );
|
||||
|
||||
@@ -19,10 +19,16 @@
|
||||
#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"
|
||||
@@ -30,6 +36,10 @@
|
||||
#include "RimSummaryPlot.h"
|
||||
#include "RimSummaryPlotCollection.h"
|
||||
|
||||
#include "RiuPlotMainWindow.h"
|
||||
|
||||
#include "cafPdmUiPropertyViewDialog.h"
|
||||
|
||||
#include <QFile>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -225,6 +235,28 @@ QString RicSummaryPlotTemplateTools::htmlTextFromCount( const QString& itemText,
|
||||
return text;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RicSummaryPlotTemplateTools::selectPlotTemplatePath()
|
||||
{
|
||||
QString fileName;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -48,6 +48,8 @@ public:
|
||||
|
||||
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 );
|
||||
|
||||
@@ -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";
|
||||
@@ -882,10 +890,6 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
||||
menuBuilder << "RicAsciiExportSummaryPlotFeature";
|
||||
}
|
||||
}
|
||||
else if ( dynamic_cast<RimSummaryCase*>( uiItem ) )
|
||||
{
|
||||
appendPlotTemplateMenus( menuBuilder );
|
||||
}
|
||||
else if ( dynamic_cast<RimWellLogPlot*>( uiItem ) )
|
||||
{
|
||||
menuBuilder << "RicAsciiExportWellLogPlotFeature";
|
||||
@@ -1091,12 +1095,20 @@ void RimContextCommandBuilder::appendScriptItems( caf::CmdFeatureMenuBuilder& me
|
||||
void RimContextCommandBuilder::appendPlotTemplateItems( caf::CmdFeatureMenuBuilder& menuBuilder,
|
||||
RimPlotTemplateFolderItem* plotTemplateRoot )
|
||||
{
|
||||
for ( const auto& fileItem : plotTemplateRoot->fileNames() )
|
||||
if ( !plotTemplateRoot->fileNames().empty() )
|
||||
{
|
||||
QString menuText = fileItem->uiName();
|
||||
menuBuilder.addCmdFeatureWithUserData( "RicCreatePlotFromTemplateFeature",
|
||||
menuText,
|
||||
QVariant( fileItem->absoluteFilePath() ) );
|
||||
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() )
|
||||
|
||||
Reference in New Issue
Block a user