2016-05-25 06:15:17 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2016- Statoil ASA
|
2019-01-14 06:54:19 -06:00
|
|
|
//
|
2016-05-25 06:15:17 -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-01-14 06:54:19 -06:00
|
|
|
//
|
2016-05-25 06:15:17 -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-01-14 06:54:19 -06:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2016-05-25 06:15:17 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RicNewSummaryCurveFeature.h"
|
|
|
|
|
2018-12-20 03:46:48 -06:00
|
|
|
#include "RiaColorTables.h"
|
2019-09-06 03:40:57 -05:00
|
|
|
#include "RiaGuiApplication.h"
|
2016-05-25 06:15:17 -05:00
|
|
|
|
2019-01-14 06:54:19 -06:00
|
|
|
#include "RiaSummaryTools.h"
|
2016-05-25 06:15:17 -05:00
|
|
|
#include "RimMainPlotCollection.h"
|
2021-02-19 08:11:15 -06:00
|
|
|
#include "RimObservedDataCollection.h"
|
|
|
|
#include "RimObservedSummaryData.h"
|
2016-06-02 02:57:25 -05:00
|
|
|
#include "RimOilField.h"
|
|
|
|
#include "RimProject.h"
|
2017-09-06 09:32:46 -05:00
|
|
|
#include "RimSummaryCaseMainCollection.h"
|
2016-05-25 06:15:17 -05:00
|
|
|
#include "RimSummaryCurve.h"
|
2016-06-02 02:57:25 -05:00
|
|
|
#include "RimSummaryPlot.h"
|
|
|
|
#include "RimSummaryPlotCollection.h"
|
|
|
|
|
2018-04-26 23:28:08 -05:00
|
|
|
#include "RiuPlotMainWindow.h"
|
2016-06-02 02:57:25 -05:00
|
|
|
|
2016-05-25 06:15:17 -05:00
|
|
|
#include "cafSelectionManager.h"
|
2016-06-02 02:57:25 -05:00
|
|
|
|
|
|
|
#include "cvfAssert.h"
|
|
|
|
|
2019-08-09 02:54:55 -05:00
|
|
|
#include "RicSummaryPlotFeatureImpl.h"
|
2019-09-06 03:40:57 -05:00
|
|
|
#include "RiuPlotMainWindowTools.h"
|
|
|
|
#include <QAction>
|
2016-05-25 06:15:17 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_CMD_SOURCE_INIT( RicNewSummaryCurveFeature, "RicNewSummaryCurveFeature" );
|
2019-01-14 06:54:19 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2016-05-25 06:15:17 -05:00
|
|
|
bool RicNewSummaryCurveFeature::isCommandEnabled()
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
return ( selectedSummaryPlot() );
|
2016-05-25 06:15:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-14 06:54:19 -06:00
|
|
|
///
|
2016-05-25 06:15:17 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicNewSummaryCurveFeature::onActionTriggered( bool isChecked )
|
2016-05-25 06:15:17 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
RiaGuiApplication* app = RiaGuiApplication::instance();
|
|
|
|
RimProject* project = app->project();
|
|
|
|
CVF_ASSERT( project );
|
2016-05-25 06:15:17 -05:00
|
|
|
|
|
|
|
RimSummaryPlot* plot = selectedSummaryPlot();
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( plot )
|
2016-05-25 06:15:17 -05:00
|
|
|
{
|
2019-01-14 06:54:19 -06:00
|
|
|
RimSummaryCase* defaultCase = nullptr;
|
2020-03-06 04:29:28 -06:00
|
|
|
if ( !plot->summaryCurves().empty() )
|
|
|
|
{
|
|
|
|
defaultCase = plot->summaryCurves().back()->summaryCaseY();
|
|
|
|
}
|
2017-03-09 01:11:01 -06:00
|
|
|
|
2019-10-03 03:12:37 -05:00
|
|
|
if ( !defaultCase )
|
|
|
|
{
|
|
|
|
std::vector<RimSummaryCase*> allSummaryCases =
|
|
|
|
project->activeOilField()->summaryCaseMainCollection()->allSummaryCases();
|
|
|
|
|
|
|
|
if ( !allSummaryCases.empty() )
|
|
|
|
{
|
|
|
|
defaultCase = allSummaryCases.front();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-19 08:11:15 -06:00
|
|
|
if ( !defaultCase )
|
|
|
|
{
|
|
|
|
auto allSummaryCases = project->activeOilField()->observedDataCollection()->allObservedSummaryData();
|
|
|
|
|
|
|
|
if ( !allSummaryCases.empty() )
|
|
|
|
{
|
|
|
|
defaultCase = allSummaryCases.front();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-06 04:29:28 -06:00
|
|
|
RimSummaryCurve* newCurve = new RimSummaryCurve();
|
|
|
|
|
|
|
|
// Use same counting as RicNewSummaryEnsembleCurveSetFeature::onActionTriggered
|
|
|
|
cvf::Color3f curveColor =
|
|
|
|
RiaColorTables::summaryCurveDefaultPaletteColors().cycledColor3f( plot->singleColorCurveCount() );
|
|
|
|
newCurve->setColor( curveColor );
|
|
|
|
|
|
|
|
plot->addCurveNoUpdate( newCurve );
|
|
|
|
newCurve->setSummaryCaseY( defaultCase );
|
2017-03-09 01:11:01 -06:00
|
|
|
|
2019-08-08 09:22:00 -05:00
|
|
|
plot->loadDataAndUpdate();
|
2016-05-25 06:15:17 -05:00
|
|
|
plot->updateConnectedEditors();
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
app->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem( newCurve );
|
2017-12-15 03:37:51 -06:00
|
|
|
|
2019-05-06 03:36:05 -05:00
|
|
|
RiuPlotMainWindow* mainPlotWindow = app->mainPlotWindow();
|
2017-12-15 03:37:51 -06:00
|
|
|
mainPlotWindow->updateSummaryPlotToolBar();
|
2016-05-25 06:15:17 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-14 06:54:19 -06:00
|
|
|
///
|
2016-05-25 06:15:17 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicNewSummaryCurveFeature::setupActionLook( QAction* actionToSetup )
|
2016-05-25 06:15:17 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
actionToSetup->setText( "New Summary Curve" );
|
|
|
|
actionToSetup->setIcon( QIcon( ":/SummaryCurve16x16.png" ) );
|
2016-05-25 06:15:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-14 06:54:19 -06:00
|
|
|
///
|
2016-05-25 06:15:17 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimSummaryPlot* RicNewSummaryCurveFeature::selectedSummaryPlot() const
|
|
|
|
{
|
2017-10-02 05:48:01 -05:00
|
|
|
RimSummaryPlot* sumPlot = nullptr;
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
|
|
|
|
if ( selObj )
|
2017-10-02 05:48:01 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
sumPlot = RiaSummaryTools::parentSummaryPlot( selObj );
|
2017-10-02 05:48:01 -05:00
|
|
|
}
|
2016-11-17 10:37:56 -06:00
|
|
|
|
|
|
|
return sumPlot;
|
2016-05-25 06:15:17 -05:00
|
|
|
}
|