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:
@@ -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 );
|
||||
|
||||
Reference in New Issue
Block a user