2017-08-17 05:52:18 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2017 Statoil ASA
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2017-08-17 05:52:18 -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-08-17 05:52:18 -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-08-17 05:52:18 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RicAddStoredFlowCharacteristicsPlotFeature.h"
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
#include "RimFlowCharacteristicsPlot.h"
|
2017-08-17 05:52:18 -05:00
|
|
|
#include "RimFlowPlotCollection.h"
|
|
|
|
#include "RimMainPlotCollection.h"
|
|
|
|
|
2018-02-27 08:21:14 -06:00
|
|
|
#include "RiuPlotMainWindowTools.h"
|
2017-08-17 05:52:18 -05:00
|
|
|
|
|
|
|
#include "cafSelectionManager.h"
|
|
|
|
|
|
|
|
#include "cvfAssert.h"
|
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_CMD_SOURCE_INIT( RicAddStoredFlowCharacteristicsPlotFeature, "RicAddStoredFlowCharacteristicsPlotFeature" );
|
2017-08-17 05:52:18 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-08-17 05:52:18 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2023-06-26 07:28:46 -05:00
|
|
|
bool RicAddStoredFlowCharacteristicsPlotFeature::isCommandEnabled() const
|
2017-08-17 05:52:18 -05:00
|
|
|
{
|
2022-08-19 07:30:25 -05:00
|
|
|
RimFlowPlotCollection* flowPlotColl = RimMainPlotCollection::current()->flowPlotCollection();
|
|
|
|
if ( flowPlotColl )
|
2017-08-17 05:52:18 -05:00
|
|
|
{
|
2022-08-19 07:30:25 -05:00
|
|
|
RimFlowCharacteristicsPlot* flowCharacteristicsPlot =
|
|
|
|
dynamic_cast<RimFlowCharacteristicsPlot*>( caf::SelectionManager::instance()->selectedItem() );
|
2017-08-17 05:52:18 -05:00
|
|
|
|
2022-08-19 07:30:25 -05:00
|
|
|
if ( flowPlotColl->defaultFlowCharacteristicsPlot() == flowCharacteristicsPlot )
|
|
|
|
{
|
|
|
|
return true;
|
2017-08-17 05:52:18 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-08-17 05:52:18 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicAddStoredFlowCharacteristicsPlotFeature::onActionTriggered( bool isChecked )
|
2017-08-17 05:52:18 -05:00
|
|
|
{
|
2022-08-19 07:30:25 -05:00
|
|
|
RimFlowPlotCollection* flowPlotColl = RimMainPlotCollection::current()->flowPlotCollection();
|
|
|
|
if ( flowPlotColl )
|
2017-08-17 05:52:18 -05:00
|
|
|
{
|
2022-08-19 07:30:25 -05:00
|
|
|
RimFlowCharacteristicsPlot* sourceObject =
|
|
|
|
dynamic_cast<RimFlowCharacteristicsPlot*>( caf::SelectionManager::instance()->selectedItem() );
|
2017-08-17 05:52:18 -05:00
|
|
|
|
2024-06-14 10:18:28 -05:00
|
|
|
auto flowCharacteristicsPlot = sourceObject->copyObject<RimFlowCharacteristicsPlot>();
|
2022-08-19 07:30:25 -05:00
|
|
|
CVF_ASSERT( flowCharacteristicsPlot );
|
2017-08-17 05:52:18 -05:00
|
|
|
|
2022-08-19 07:30:25 -05:00
|
|
|
flowPlotColl->addFlowCharacteristicsPlotToStoredPlots( flowCharacteristicsPlot );
|
|
|
|
flowCharacteristicsPlot->resolveReferencesRecursively();
|
2019-09-06 03:40:57 -05:00
|
|
|
|
2022-08-19 07:30:25 -05:00
|
|
|
flowCharacteristicsPlot->loadDataAndUpdate();
|
2017-08-17 05:52:18 -05:00
|
|
|
|
2022-08-19 07:30:25 -05:00
|
|
|
flowPlotColl->updateConnectedEditors();
|
2017-08-17 05:52:18 -05:00
|
|
|
|
2022-08-19 07:30:25 -05:00
|
|
|
RiuPlotMainWindowTools::showPlotMainWindow();
|
|
|
|
RiuPlotMainWindowTools::onObjectAppended( flowCharacteristicsPlot );
|
2017-08-17 05:52:18 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-08-17 05:52:18 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicAddStoredFlowCharacteristicsPlotFeature::setupActionLook( QAction* actionToSetup )
|
2017-08-17 05:52:18 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
// actionToSetup->setIcon(QIcon(":/new_icon16x16.png"));
|
|
|
|
actionToSetup->setText( "Add Stored Flow Characteristics Plot" );
|
2017-08-17 05:52:18 -05:00
|
|
|
}
|