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"
|
|
|
|
|
2017-12-04 04:43:27 -06:00
|
|
|
#include "RiaApplication.h"
|
|
|
|
#include "RimProject.h"
|
|
|
|
#include "RimSummaryCalculationCollection.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
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RicSummaryCurveCalculatorDialog* RicShowSummaryCurveCalculatorFeature::curveCalculatorDialog()
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
static RicSummaryCurveCalculatorDialog* singleton = new RicSummaryCurveCalculatorDialog( nullptr );
|
|
|
|
|
2017-11-13 14:40:26 -06:00
|
|
|
return singleton;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-11-13 14:40:26 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicShowSummaryCurveCalculatorFeature::hideCurveCalculatorDialog()
|
|
|
|
{
|
|
|
|
auto dialog = RicShowSummaryCurveCalculatorFeature::curveCalculatorDialog();
|
|
|
|
|
|
|
|
dialog->hide();
|
|
|
|
}
|
|
|
|
|
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()
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
RimProject* proj = RiaApplication::instance()->project();
|
2018-05-15 03:41:27 -05:00
|
|
|
const auto& allSumCases = proj->allSummaryCases();
|
2019-09-06 03:40:57 -05:00
|
|
|
|
2018-05-15 03:41:27 -05:00
|
|
|
return !allSumCases.empty();
|
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
|
|
|
{
|
2017-11-13 14:40:26 -06:00
|
|
|
RicSummaryCurveCalculatorDialog* dialog = RicShowSummaryCurveCalculatorFeature::curveCalculatorDialog();
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
RimProject* proj = RiaApplication::instance()->project();
|
2017-12-04 04:43:27 -06:00
|
|
|
RimSummaryCalculationCollection* calcColl = proj->calculationCollection();
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( calcColl->calculations().size() == 0 )
|
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" );
|
|
|
|
actionToSetup->setIcon( QIcon( ":/calculator.png" ) );
|
2017-10-12 00:32:21 -05:00
|
|
|
}
|