2017-10-12 00:32:21 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2017 Statoil ASA
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2017-10-12 00:32:21 -05:00
|
|
|
// 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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2017-10-12 00:32:21 -05:00
|
|
|
// 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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2017-10-12 00:32:21 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RicShowSummaryCurveCalculatorFeature.h"
|
|
|
|
|
|
|
|
#include "RicSummaryCurveCalculatorDialog.h"
|
|
|
|
|
2019-12-10 08:35:00 -06:00
|
|
|
#include "RiaGuiApplication.h"
|
|
|
|
|
2017-12-04 04:43:27 -06:00
|
|
|
#include "RimProject.h"
|
|
|
|
#include "RimSummaryCalculationCollection.h"
|
|
|
|
|
2019-12-10 08:35:00 -06:00
|
|
|
#include "RiuPlotMainWindow.h"
|
|
|
|
|
2017-10-12 00:32:21 -05:00
|
|
|
#include <QAction>
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_CMD_SOURCE_INIT( RicShowSummaryCurveCalculatorFeature, "RicShowSummaryCurveCalculatorFeature" );
|
2017-10-12 00:32:21 -05:00
|
|
|
|
2017-11-13 14:40:26 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-11-13 14:40:26 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2022-03-03 03:15:32 -06:00
|
|
|
RicSummaryCurveCalculatorDialog* RicShowSummaryCurveCalculatorFeature::curveCalculatorDialog( bool createIfNotPresent )
|
2017-11-13 14:40:26 -06:00
|
|
|
{
|
2019-12-10 08:35:00 -06:00
|
|
|
RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow();
|
|
|
|
|
|
|
|
if ( mainPlotWindow )
|
|
|
|
{
|
2022-03-03 03:15:32 -06:00
|
|
|
return mainPlotWindow->summaryCurveCalculatorDialog( createIfNotPresent );
|
2019-12-10 08:35:00 -06:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
|
2019-12-10 08:35:00 -06:00
|
|
|
return nullptr;
|
2017-11-13 14:40:26 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-11-13 14:40:26 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicShowSummaryCurveCalculatorFeature::hideCurveCalculatorDialog()
|
|
|
|
{
|
2022-03-03 03:15:32 -06:00
|
|
|
auto dialog = RicShowSummaryCurveCalculatorFeature::curveCalculatorDialog( false );
|
|
|
|
if ( dialog ) dialog->hide();
|
2017-11-13 14:40:26 -06:00
|
|
|
}
|
|
|
|
|
2017-10-12 00:32:21 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-10-12 00:32:21 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RicShowSummaryCurveCalculatorFeature::isCommandEnabled()
|
|
|
|
{
|
2022-05-10 03:24:52 -05:00
|
|
|
return true;
|
2017-10-12 00:32:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-10-12 00:32:21 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicShowSummaryCurveCalculatorFeature::onActionTriggered( bool isChecked )
|
2017-10-12 00:32:21 -05:00
|
|
|
{
|
2022-03-03 03:15:32 -06:00
|
|
|
RicSummaryCurveCalculatorDialog* dialog = RicShowSummaryCurveCalculatorFeature::curveCalculatorDialog( true );
|
2017-11-13 14:40:26 -06:00
|
|
|
|
2020-05-12 02:50:38 -05:00
|
|
|
RimProject* proj = RimProject::current();
|
2017-12-04 04:43:27 -06:00
|
|
|
RimSummaryCalculationCollection* calcColl = proj->calculationCollection();
|
2022-04-22 05:18:34 -05:00
|
|
|
if ( calcColl->calculations().empty() )
|
2017-12-04 04:43:27 -06:00
|
|
|
{
|
|
|
|
calcColl->addCalculation();
|
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
dialog->setCalculationAndUpdateUi( calcColl->calculations()[0] );
|
2017-11-13 14:40:26 -06:00
|
|
|
|
|
|
|
dialog->show();
|
|
|
|
dialog->raise();
|
2017-10-12 00:32:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-10-12 00:32:21 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicShowSummaryCurveCalculatorFeature::setupActionLook( QAction* actionToSetup )
|
2017-10-12 00:32:21 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
actionToSetup->setText( "Curve Calculator" );
|
2020-10-01 10:25:19 -05:00
|
|
|
actionToSetup->setIcon( QIcon( ":/Calculator.svg" ) );
|
2017-10-12 00:32:21 -05:00
|
|
|
}
|