2017-11-07 14:26:44 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2016- Statoil ASA
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2017-11-07 14:26:44 -06: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-11-07 14:26:44 -06: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-11-07 14:26:44 -06:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RicNewSummaryCrossPlotFeature.h"
|
|
|
|
|
2018-05-07 02:45:50 -05:00
|
|
|
#include "RiaSummaryTools.h"
|
2017-11-07 14:26:44 -06:00
|
|
|
|
|
|
|
#include "RicEditSummaryPlotFeature.h"
|
2020-02-18 05:29:13 -06:00
|
|
|
#include "RicSummaryPlotEditorDialog.h"
|
2020-02-18 06:36:07 -06:00
|
|
|
#include "RicSummaryPlotEditorUi.h"
|
2017-11-07 14:26:44 -06:00
|
|
|
|
|
|
|
#include "RimMainPlotCollection.h"
|
|
|
|
#include "RimProject.h"
|
2019-09-06 03:40:57 -05:00
|
|
|
#include "RimSummaryCase.h"
|
|
|
|
#include "RimSummaryCaseCollection.h"
|
2017-11-07 14:26:44 -06:00
|
|
|
#include "RimSummaryCrossPlotCollection.h"
|
|
|
|
#include "RimSummaryPlot.h"
|
|
|
|
|
2018-02-27 08:53:33 -06:00
|
|
|
#include "RiuPlotMainWindowTools.h"
|
2017-11-07 14:26:44 -06:00
|
|
|
|
2018-05-07 02:45:50 -05:00
|
|
|
#include "cafSelectionManagerTools.h"
|
|
|
|
|
2017-11-07 14:26:44 -06:00
|
|
|
#include "cvfAssert.h"
|
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_CMD_SOURCE_INIT( RicNewSummaryCrossPlotFeature, "RicNewSummaryCrossPlotFeature" );
|
2017-11-07 14:26:44 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-11-07 14:26:44 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RicNewSummaryCrossPlotFeature::isCommandEnabled()
|
|
|
|
{
|
2018-05-07 02:45:50 -05:00
|
|
|
RimSummaryCrossPlotCollection* sumPlotColl = nullptr;
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
|
|
|
|
if ( selObj )
|
2018-05-07 02:45:50 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
sumPlotColl = RiaSummaryTools::parentCrossPlotCollection( selObj );
|
2018-05-07 02:45:50 -05:00
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( sumPlotColl ) return true;
|
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
|
|
|
RimSummaryCase* sumCase = dynamic_cast<RimSummaryCase*>( item );
|
|
|
|
RimSummaryCaseCollection* sumGroup = dynamic_cast<RimSummaryCaseCollection*>( item );
|
2018-05-28 07:36:44 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( sumGroup && sumGroup->isEnsemble() ) sumGroup = nullptr;
|
|
|
|
if ( !sumCase && !sumGroup ) return false;
|
2018-05-07 02:45:50 -05:00
|
|
|
}
|
2017-11-07 14:26:44 -06:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-11-07 14:26:44 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicNewSummaryCrossPlotFeature::onActionTriggered( bool isChecked )
|
2017-11-07 14:26:44 -06:00
|
|
|
{
|
2020-05-12 02:50:38 -05:00
|
|
|
RimProject* project = RimProject::current();
|
2019-09-06 03:40:57 -05:00
|
|
|
CVF_ASSERT( project );
|
2017-11-07 14:26:44 -06:00
|
|
|
|
|
|
|
RimSummaryCrossPlotCollection* summaryCrossPlotColl = project->mainPlotCollection()->summaryCrossPlotCollection();
|
2019-09-06 03:40:57 -05:00
|
|
|
RimSummaryPlot* summaryPlot = summaryCrossPlotColl->createSummaryPlot();
|
|
|
|
|
2020-09-16 12:33:44 -05:00
|
|
|
summaryCrossPlotColl->addPlot( summaryPlot );
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( summaryPlot )
|
2017-11-07 14:26:44 -06:00
|
|
|
{
|
|
|
|
summaryCrossPlotColl->updateConnectedEditors();
|
|
|
|
summaryPlot->loadDataAndUpdate();
|
|
|
|
|
2018-02-27 08:53:33 -06:00
|
|
|
RiuPlotMainWindowTools::showPlotMainWindow();
|
2022-08-18 05:37:51 -05:00
|
|
|
RiuPlotMainWindowTools::onObjectAppended( summaryPlot );
|
2017-11-07 14:26:44 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-11-07 14:26:44 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicNewSummaryCrossPlotFeature::setupActionLook( QAction* actionToSetup )
|
2017-11-07 14:26:44 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
actionToSetup->setText( "New Summary Cross Plot" );
|
|
|
|
actionToSetup->setIcon( QIcon( ":/SummaryXPlotLight16x16.png" ) );
|
2017-11-07 14:26:44 -06:00
|
|
|
}
|