2019-09-30 00:50:51 -05:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// 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"
|
2019-09-30 06:28:08 -05:00
|
|
|
|
2019-09-30 00:50:51 -05:00
|
|
|
#include "RicSummaryPlotTemplateTools.h"
|
|
|
|
|
|
|
|
#include "RimSummaryCase.h"
|
|
|
|
|
2019-09-30 06:28:08 -05:00
|
|
|
#include "RiuPlotMainWindow.h"
|
|
|
|
|
2019-09-30 00:50:51 -05:00
|
|
|
#include "cafSelectionManager.h"
|
|
|
|
|
|
|
|
#include <QAction>
|
2019-09-30 06:28:08 -05:00
|
|
|
#include <QFile>
|
|
|
|
#include <QMessageBox>
|
2019-09-30 00:50:51 -05:00
|
|
|
|
|
|
|
CAF_CMD_SOURCE_INIT( RicCreatePlotFromTemplateByShortcutFeature, "RicCreatePlotFromTemplateByShortcutFeature" );
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RicCreatePlotFromTemplateByShortcutFeature::isCommandEnabled()
|
|
|
|
{
|
|
|
|
return !selectedSummaryCases().empty();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicCreatePlotFromTemplateByShortcutFeature::onActionTriggered( bool isChecked )
|
|
|
|
{
|
|
|
|
QString fileName = RiaApplication::instance()->preferences()->defaultPlotTemplateAbsolutePath();
|
2019-09-30 06:28:08 -05:00
|
|
|
|
|
|
|
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 );
|
|
|
|
}
|
|
|
|
|
2019-09-30 00:50:51 -05:00
|
|
|
std::vector<RimSummaryCase*> sumCases = selectedSummaryCases();
|
|
|
|
|
|
|
|
RimSummaryPlot* newSummaryPlot = RicSummaryPlotTemplateTools::createPlotFromTemplateFile( fileName );
|
|
|
|
RicSummaryPlotTemplateTools::appendSummaryPlotToPlotCollection( newSummaryPlot, sumCases );
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicCreatePlotFromTemplateByShortcutFeature::setupActionLook( QAction* actionToSetup )
|
|
|
|
{
|
2019-09-30 06:28:08 -05:00
|
|
|
actionToSetup->setText( "Create Plot from Default Template" );
|
2019-09-30 00:50:51 -05:00
|
|
|
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;
|
|
|
|
}
|