2018-04-06 08:16:14 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2016- Statoil ASA
|
2019-02-18 13:09:50 +01:00
|
|
|
//
|
2018-04-06 08:16:14 +02: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-02-18 13:09:50 +01:00
|
|
|
//
|
2018-04-06 08:16:14 +02: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-02-18 13:09:50 +01:00
|
|
|
//
|
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2018-04-06 08:16:14 +02:00
|
|
|
// for more details.
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2018-04-19 14:00:00 +02:00
|
|
|
#include "RicNewSummaryEnsembleCurveSetFeature.h"
|
2018-04-06 08:16:14 +02:00
|
|
|
|
2018-05-11 08:01:10 +02:00
|
|
|
#include "RiaColorTables.h"
|
2019-09-06 10:40:57 +02:00
|
|
|
#include "RiaGuiApplication.h"
|
2020-05-20 09:16:49 +02:00
|
|
|
#include "RiaPreferences.h"
|
2018-04-06 08:16:14 +02:00
|
|
|
|
2019-02-18 13:09:50 +01:00
|
|
|
#include "RiaSummaryTools.h"
|
2019-12-16 12:40:10 +01:00
|
|
|
#include "RimEnsembleCurveFilterCollection.h"
|
2019-02-18 13:09:50 +01:00
|
|
|
#include "RimEnsembleCurveSet.h"
|
|
|
|
|
#include "RimEnsembleCurveSetCollection.h"
|
|
|
|
|
#include "RimEnsembleCurveSetColorManager.h"
|
2018-04-06 08:16:14 +02:00
|
|
|
#include "RimMainPlotCollection.h"
|
|
|
|
|
#include "RimOilField.h"
|
|
|
|
|
#include "RimProject.h"
|
|
|
|
|
#include "RimSummaryCaseMainCollection.h"
|
|
|
|
|
#include "RimSummaryCurve.h"
|
|
|
|
|
#include "RimSummaryPlot.h"
|
|
|
|
|
#include "RimSummaryPlotCollection.h"
|
|
|
|
|
|
2018-04-27 06:28:08 +02:00
|
|
|
#include "RiuPlotMainWindow.h"
|
2018-04-06 08:16:14 +02:00
|
|
|
|
|
|
|
|
#include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h"
|
|
|
|
|
|
|
|
|
|
#include "cafSelectionManager.h"
|
|
|
|
|
|
|
|
|
|
#include "cvfAssert.h"
|
|
|
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
CAF_CMD_SOURCE_INIT( RicNewSummaryEnsembleCurveSetFeature, "RicNewSummaryEnsembleCurveSetFeature" );
|
2018-04-06 08:16:14 +02:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-02-18 13:09:50 +01:00
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-05-23 10:57:09 +02:00
|
|
|
std::vector<RimEnsembleCurveSet*>
|
|
|
|
|
RicNewSummaryEnsembleCurveSetFeature::addDefaultCurveSets( RimSummaryPlot* plot, RimSummaryCaseCollection* ensemble )
|
2019-02-18 13:09:50 +01:00
|
|
|
{
|
2020-05-27 09:10:34 +02:00
|
|
|
CVF_ASSERT( plot && ensemble );
|
2019-02-18 13:09:50 +01:00
|
|
|
|
2020-05-12 09:50:38 +02:00
|
|
|
RimProject* project = RimProject::current();
|
2019-09-06 10:40:57 +02:00
|
|
|
CVF_ASSERT( project );
|
2019-02-18 13:09:50 +01:00
|
|
|
|
2020-05-20 09:16:49 +02:00
|
|
|
QString curvesTextFilter = RiaApplication::instance()->preferences()->defaultSummaryCurvesTextFilter;
|
|
|
|
|
QStringList curveFilters = curvesTextFilter.split( ";", QString::SkipEmptyParts );
|
2019-02-18 13:09:50 +01:00
|
|
|
|
2020-05-20 09:16:49 +02:00
|
|
|
std::set<RifEclipseSummaryAddress> addrs = ensemble->ensembleSummaryAddresses();
|
2019-02-18 13:09:50 +01:00
|
|
|
|
2020-05-20 09:16:49 +02:00
|
|
|
std::vector<RimEnsembleCurveSet*> curveSets;
|
|
|
|
|
for ( const auto& addr : addrs )
|
|
|
|
|
{
|
2020-05-23 10:57:09 +02:00
|
|
|
for ( auto filter : curveFilters )
|
2020-05-20 09:16:49 +02:00
|
|
|
{
|
|
|
|
|
if ( addr.isUiTextMatchingFilterText( filter ) )
|
|
|
|
|
{
|
|
|
|
|
RimEnsembleCurveSet* curveSet = new RimEnsembleCurveSet();
|
|
|
|
|
|
|
|
|
|
// Use same counting as RicNewSummaryCurveFeature::onActionTriggered
|
|
|
|
|
auto colorIndex = plot->singleColorCurveCount();
|
|
|
|
|
curveSet->setColor( RiaColorTables::summaryCurveDefaultPaletteColors().cycledColor3f( colorIndex ) );
|
2020-05-23 10:57:09 +02:00
|
|
|
curveSet->legendConfig()->setColorLegend( RimRegularLegendConfig::mapToColorLegend(
|
|
|
|
|
RimEnsembleCurveSetColorManager::cycledEnsembleColorRange( static_cast<int>( colorIndex ) ) ) );
|
2020-05-20 09:16:49 +02:00
|
|
|
|
|
|
|
|
curveSet->setSummaryCaseCollection( ensemble );
|
|
|
|
|
curveSet->setSummaryAddress( addr );
|
|
|
|
|
curveSet->filterCollection()->addFilter();
|
|
|
|
|
|
|
|
|
|
plot->ensembleCurveSetCollection()->addCurveSet( curveSet );
|
|
|
|
|
curveSets.push_back( curveSet );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-02-18 13:09:50 +01:00
|
|
|
|
2020-05-20 09:16:49 +02:00
|
|
|
return curveSets;
|
2019-02-18 13:09:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-03-10 14:11:22 +01:00
|
|
|
RimSummaryPlot*
|
|
|
|
|
RicNewSummaryEnsembleCurveSetFeature::createPlotForCurveSetsAndUpdate( std::vector<RimSummaryCaseCollection*> ensembles )
|
2019-02-18 13:09:50 +01:00
|
|
|
{
|
2019-05-06 10:36:05 +02:00
|
|
|
RiaGuiApplication* app = RiaGuiApplication::instance();
|
2019-08-22 13:05:39 +02:00
|
|
|
RimProject* proj = app->project();
|
2019-02-18 13:09:50 +01:00
|
|
|
|
2020-05-20 09:16:49 +02:00
|
|
|
if ( RiaApplication::instance()->preferences()->defaultSummaryCurvesTextFilter().isEmpty() ) return nullptr;
|
|
|
|
|
|
2019-02-18 13:09:50 +01:00
|
|
|
RimSummaryPlotCollection* summaryPlotCollection = proj->mainPlotCollection->summaryPlotCollection();
|
|
|
|
|
RimSummaryPlot* plot = summaryPlotCollection->createSummaryPlotWithAutoTitle();
|
|
|
|
|
|
2019-12-06 09:20:38 +01:00
|
|
|
RimEnsembleCurveSet* firstCurveSetCreated = nullptr;
|
|
|
|
|
for ( RimSummaryCaseCollection* ensemble : ensembles )
|
|
|
|
|
{
|
2020-05-23 10:57:09 +02:00
|
|
|
std::vector<RimEnsembleCurveSet*> curveSets =
|
|
|
|
|
RicNewSummaryEnsembleCurveSetFeature::addDefaultCurveSets( plot, ensemble );
|
2020-05-20 09:16:49 +02:00
|
|
|
if ( !firstCurveSetCreated && !curveSets.empty() ) firstCurveSetCreated = curveSets.front();
|
2019-12-06 09:20:38 +01:00
|
|
|
}
|
|
|
|
|
|
2019-02-18 13:09:50 +01:00
|
|
|
plot->loadDataAndUpdate();
|
|
|
|
|
summaryPlotCollection->updateConnectedEditors();
|
|
|
|
|
|
|
|
|
|
RiuPlotMainWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow();
|
2019-09-06 10:40:57 +02:00
|
|
|
if ( mainPlotWindow )
|
2019-02-18 13:09:50 +01:00
|
|
|
{
|
2019-12-06 09:20:38 +01:00
|
|
|
mainPlotWindow->selectAsCurrentItem( firstCurveSetCreated );
|
2019-02-18 13:09:50 +01:00
|
|
|
mainPlotWindow->updateSummaryPlotToolBar();
|
|
|
|
|
}
|
2020-03-10 14:11:22 +01:00
|
|
|
return plot;
|
2019-02-18 13:09:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
2018-04-06 08:16:14 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-04-19 14:00:00 +02:00
|
|
|
bool RicNewSummaryEnsembleCurveSetFeature::isCommandEnabled()
|
2018-04-06 08:16:14 +02:00
|
|
|
{
|
2019-08-22 13:05:39 +02:00
|
|
|
bool summaryPlotSelected = selectedSummaryPlot();
|
2019-09-06 10:40:57 +02:00
|
|
|
if ( summaryPlotSelected )
|
2019-08-22 13:05:39 +02:00
|
|
|
{
|
2020-05-12 09:50:38 +02:00
|
|
|
RimProject* project = RimProject::current();
|
2019-09-06 10:40:57 +02:00
|
|
|
CVF_ASSERT( project );
|
|
|
|
|
if ( !project->summaryGroups().empty() )
|
|
|
|
|
{
|
2019-08-22 13:05:39 +02:00
|
|
|
return true;
|
2019-09-06 10:40:57 +02:00
|
|
|
}
|
|
|
|
|
}
|
2019-08-22 13:05:39 +02:00
|
|
|
return false;
|
2018-04-06 08:16:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-02-18 13:09:50 +01:00
|
|
|
///
|
2018-04-06 08:16:14 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
void RicNewSummaryEnsembleCurveSetFeature::onActionTriggered( bool isChecked )
|
2018-04-06 08:16:14 +02:00
|
|
|
{
|
2020-05-12 09:50:38 +02:00
|
|
|
RimProject* project = RimProject::current();
|
2019-09-06 10:40:57 +02:00
|
|
|
CVF_ASSERT( project );
|
2018-04-06 08:16:14 +02:00
|
|
|
|
|
|
|
|
RimSummaryPlot* plot = selectedSummaryPlot();
|
2019-09-06 10:40:57 +02:00
|
|
|
if ( plot )
|
2018-04-06 08:16:14 +02:00
|
|
|
{
|
2019-09-06 10:40:57 +02:00
|
|
|
CVF_ASSERT( !project->summaryGroups().empty() );
|
2019-02-18 13:09:50 +01:00
|
|
|
auto ensemble = project->summaryGroups().back();
|
2018-04-06 08:16:14 +02:00
|
|
|
|
2020-05-20 09:16:49 +02:00
|
|
|
RimEnsembleCurveSet* firstCurveSet = nullptr;
|
2020-05-23 10:57:09 +02:00
|
|
|
if ( !RiaApplication::instance()->preferences()->defaultSummaryCurvesTextFilter().isEmpty() )
|
2020-05-20 09:16:49 +02:00
|
|
|
{
|
2020-05-23 10:57:09 +02:00
|
|
|
auto curveSets = RicNewSummaryEnsembleCurveSetFeature::addDefaultCurveSets( plot, ensemble );
|
2020-05-20 09:16:49 +02:00
|
|
|
if ( !curveSets.empty() ) firstCurveSet = curveSets.front();
|
|
|
|
|
}
|
2019-10-03 11:46:12 +02:00
|
|
|
plot->loadDataAndUpdate();
|
|
|
|
|
plot->updateConnectedEditors();
|
|
|
|
|
|
|
|
|
|
RiaGuiApplication* app = RiaGuiApplication::instance();
|
|
|
|
|
RiuPlotMainWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow();
|
2020-05-23 10:57:09 +02:00
|
|
|
if ( mainPlotWindow && firstCurveSet )
|
2019-10-03 11:46:12 +02:00
|
|
|
{
|
2020-05-23 10:57:09 +02:00
|
|
|
mainPlotWindow->selectAsCurrentItem( firstCurveSet );
|
2019-10-03 11:46:12 +02:00
|
|
|
mainPlotWindow->updateSummaryPlotToolBar();
|
|
|
|
|
}
|
2018-04-06 08:16:14 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-02-18 13:09:50 +01:00
|
|
|
///
|
2018-04-06 08:16:14 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
void RicNewSummaryEnsembleCurveSetFeature::setupActionLook( QAction* actionToSetup )
|
2018-04-06 08:16:14 +02:00
|
|
|
{
|
2019-09-06 10:40:57 +02:00
|
|
|
actionToSetup->setText( "New Ensemble Curve Set" );
|
|
|
|
|
actionToSetup->setIcon( QIcon( ":/EnsembleCurveSet16x16.png" ) );
|
2018-04-06 08:16:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-02-18 13:09:50 +01:00
|
|
|
///
|
2018-04-06 08:16:14 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-04-19 14:00:00 +02:00
|
|
|
RimSummaryPlot* RicNewSummaryEnsembleCurveSetFeature::selectedSummaryPlot() const
|
2018-04-06 08:16:14 +02:00
|
|
|
{
|
|
|
|
|
RimSummaryPlot* sumPlot = nullptr;
|
|
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
|
|
|
|
|
if ( selObj )
|
2018-04-06 08:16:14 +02:00
|
|
|
{
|
2019-09-06 10:40:57 +02:00
|
|
|
sumPlot = RiaSummaryTools::parentSummaryPlot( selObj );
|
2018-04-06 08:16:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return sumPlot;
|
|
|
|
|
}
|