2016-05-09 05:13:54 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2022-02-22 04:32:35 -06:00
|
|
|
// Copyright (C) 2022 Equinor ASA
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2016-05-09 05:13:54 -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
|
|
|
//
|
2016-05-09 05:13:54 -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>
|
2016-05-09 05:13:54 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2022-03-21 06:23:50 -05:00
|
|
|
#include "RicOpenSummaryPlotEditorFeature.h"
|
2016-05-09 05:13:54 -05:00
|
|
|
|
2017-11-15 00:07:26 -06:00
|
|
|
#include "RiaSummaryTools.h"
|
2016-06-30 03:06:15 -05:00
|
|
|
|
2017-10-27 01:26:20 -05:00
|
|
|
#include "RicEditSummaryPlotFeature.h"
|
2019-12-06 02:20:38 -06:00
|
|
|
#include "RicNewSummaryEnsembleCurveSetFeature.h"
|
2020-02-18 05:29:13 -06:00
|
|
|
#include "RicSummaryPlotEditorDialog.h"
|
2020-02-18 06:36:07 -06:00
|
|
|
#include "RicSummaryPlotEditorUi.h"
|
2020-03-13 02:34:05 -05:00
|
|
|
#include "RicSummaryPlotFeatureImpl.h"
|
2017-09-26 00:48:42 -05:00
|
|
|
|
2020-12-07 09:49:58 -06:00
|
|
|
#include "RimCustomObjectiveFunctionCollection.h"
|
2018-05-31 03:23:51 -05:00
|
|
|
#include "RimEnsembleCurveFilter.h"
|
|
|
|
#include "RimEnsembleCurveFilterCollection.h"
|
2019-09-06 03:40:57 -05:00
|
|
|
#include "RimProject.h"
|
2018-05-31 03:23:51 -05:00
|
|
|
#include "RimRegularLegendConfig.h"
|
2018-05-07 02:45:50 -05:00
|
|
|
#include "RimSummaryCase.h"
|
|
|
|
#include "RimSummaryCaseCollection.h"
|
2018-09-13 05:38:17 -05:00
|
|
|
#include "RimSummaryCaseMainCollection.h"
|
2019-09-06 03:40:57 -05:00
|
|
|
#include "RimSummaryPlot.h"
|
2017-09-26 00:48:42 -05:00
|
|
|
|
2018-04-26 23:28:08 -05:00
|
|
|
#include "RiuPlotMainWindow.h"
|
2016-05-09 05:13:54 -05:00
|
|
|
|
2018-05-07 02:45:50 -05:00
|
|
|
#include "cafSelectionManagerTools.h"
|
2019-09-06 03:40:57 -05:00
|
|
|
#include "cvfAssert.h"
|
2017-09-26 00:48:42 -05:00
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
2022-03-21 06:23:50 -05:00
|
|
|
CAF_CMD_SOURCE_INIT( RicOpenSummaryPlotEditorFeature, "RicOpenSummaryPlotEditorFeature" );
|
2016-05-09 05:13:54 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2016-05-09 05:13:54 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2022-03-21 06:23:50 -05:00
|
|
|
bool RicOpenSummaryPlotEditorFeature::isCommandEnabled()
|
2016-05-09 05:13:54 -05:00
|
|
|
{
|
2022-04-06 10:39:07 -05:00
|
|
|
RimSummaryMultiPlot* multiPlot = nullptr;
|
2020-12-12 02:54:18 -06:00
|
|
|
RimCustomObjectiveFunctionCollection* customObjFuncCollection = nullptr;
|
2017-11-15 00:07:26 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
|
|
|
|
if ( selObj )
|
2017-11-15 00:07:26 -06:00
|
|
|
{
|
2022-04-06 10:39:07 -05:00
|
|
|
multiPlot = RiaSummaryTools::parentSummaryMultiPlot( selObj );
|
2020-12-12 02:54:18 -06:00
|
|
|
selObj->firstAncestorOrThisOfType( customObjFuncCollection );
|
2017-11-15 00:07:26 -06:00
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
auto ensembleFilter = dynamic_cast<RimEnsembleCurveFilter*>( selObj );
|
|
|
|
auto ensembleFilterColl = dynamic_cast<RimEnsembleCurveFilterCollection*>( selObj );
|
|
|
|
auto legendConfig = dynamic_cast<RimRegularLegendConfig*>( selObj );
|
2018-05-31 03:23:51 -05:00
|
|
|
|
2020-12-07 09:49:58 -06:00
|
|
|
if ( ensembleFilter || ensembleFilterColl || legendConfig || customObjFuncCollection ) return false;
|
2022-04-06 10:39:07 -05:00
|
|
|
if ( multiPlot ) return true;
|
2017-11-15 00:07:26 -06:00
|
|
|
|
2018-05-07 02:45:50 -05:00
|
|
|
// Multiple case selections
|
|
|
|
std::vector<caf::PdmUiItem*> selectedItems = caf::selectedObjectsByTypeStrict<caf::PdmUiItem*>();
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( auto item : selectedItems )
|
2018-05-07 02:45:50 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !dynamic_cast<RimSummaryCase*>( item ) && !dynamic_cast<RimSummaryCaseCollection*>( item ) ) return false;
|
2018-05-07 02:45:50 -05:00
|
|
|
}
|
|
|
|
return true;
|
2016-05-09 05:13:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2016-05-09 05:13:54 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2022-03-21 06:23:50 -05:00
|
|
|
void RicOpenSummaryPlotEditorFeature::onActionTriggered( bool isChecked )
|
2016-05-09 05:13:54 -05:00
|
|
|
{
|
2020-05-12 02:50:38 -05:00
|
|
|
RimProject* project = RimProject::current();
|
2019-09-06 03:40:57 -05:00
|
|
|
CVF_ASSERT( project );
|
2016-05-09 05:13:54 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
std::vector<RimSummaryCase*> selectedCases = caf::selectedObjectsByType<RimSummaryCase*>();
|
2018-05-07 02:45:50 -05:00
|
|
|
std::vector<RimSummaryCaseCollection*> selectedGroups = caf::selectedObjectsByType<RimSummaryCaseCollection*>();
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
std::vector<caf::PdmObject*> sourcesToSelect( selectedCases.begin(), selectedCases.end() );
|
2018-05-28 06:26:56 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( sourcesToSelect.empty() && selectedGroups.empty() )
|
2018-09-13 05:38:17 -05:00
|
|
|
{
|
|
|
|
const auto allSingleCases = project->firstSummaryCaseMainCollection()->topLevelSummaryCases();
|
2019-09-06 03:40:57 -05:00
|
|
|
const auto allGroups = project->summaryGroups();
|
2018-09-13 05:38:17 -05:00
|
|
|
std::vector<RimSummaryCaseCollection*> allEnsembles;
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( const auto group : allGroups )
|
|
|
|
if ( group->isEnsemble() ) allEnsembles.push_back( group );
|
2018-09-13 05:38:17 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !allSingleCases.empty() )
|
2018-09-13 05:38:17 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
sourcesToSelect.push_back( allSingleCases.front() );
|
2018-09-13 05:38:17 -05:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
else if ( !allEnsembles.empty() )
|
2018-09-13 05:38:17 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
sourcesToSelect.push_back( allEnsembles.front() );
|
2018-09-13 05:38:17 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-07 02:45:50 -05:00
|
|
|
// Append grouped cases
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( auto group : selectedGroups )
|
2018-05-07 02:45:50 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( group->isEnsemble() )
|
2018-05-28 06:26:56 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
sourcesToSelect.push_back( group );
|
2018-05-28 06:26:56 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
auto groupCases = group->allSummaryCases();
|
2019-09-06 03:40:57 -05:00
|
|
|
sourcesToSelect.insert( sourcesToSelect.end(), groupCases.begin(), groupCases.end() );
|
2018-05-28 06:26:56 -05:00
|
|
|
}
|
2018-05-07 02:45:50 -05:00
|
|
|
}
|
|
|
|
|
2022-03-03 03:15:32 -06:00
|
|
|
auto dialog = RicEditSummaryPlotFeature::curveCreatorDialog( true );
|
2016-05-09 05:13:54 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !dialog->isVisible() )
|
2017-09-21 08:48:00 -05:00
|
|
|
{
|
2017-09-21 02:49:49 -05:00
|
|
|
dialog->show();
|
2017-09-21 08:48:00 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dialog->raise();
|
|
|
|
}
|
2016-05-09 05:13:54 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
dialog->updateFromDefaultCases( sourcesToSelect );
|
2016-06-30 06:21:04 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2016-06-30 06:21:04 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2022-03-21 06:23:50 -05:00
|
|
|
void RicOpenSummaryPlotEditorFeature::setupActionLook( QAction* actionToSetup )
|
2016-06-30 06:21:04 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
actionToSetup->setText( "Open Summary Plot Editor" );
|
|
|
|
actionToSetup->setIcon( QIcon( ":/SummaryPlotLight16x16.png" ) );
|
2016-06-30 06:21:04 -05:00
|
|
|
}
|