Files
ResInsight/ApplicationLibCode/Commands/FlowCommands/RicShowTotalAllocationDataFeature.cpp
T

96 lines
3.5 KiB
C++
Raw Normal View History

2017-04-19 13:44:08 +02:00
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
2017-04-19 13:44:08 +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.
//
2017-04-19 13:44:08 +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.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
2017-04-19 13:44:08 +02:00
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicShowTotalAllocationDataFeature.h"
#include "ApplicationCommands/RicShowPlotDataFeature.h"
#include "RimTotalWellAllocationPlot.h"
#include "RimWellAllocationPlot.h"
#include "cafAssert.h"
2017-04-19 13:44:08 +02:00
#include "cafSelectionManager.h"
#include <QAction>
#include <set>
CAF_CMD_SOURCE_INIT( RicShowTotalAllocationDataFeature, "RicShowTotalAllocationDataFeature" );
2017-04-19 13:44:08 +02:00
//--------------------------------------------------------------------------------------------------
///
2017-04-19 13:44:08 +02:00
//--------------------------------------------------------------------------------------------------
2023-06-26 14:28:46 +02:00
bool RicShowTotalAllocationDataFeature::isCommandEnabled() const
2017-04-19 13:44:08 +02:00
{
std::set<RimWellAllocationPlot*> wellAllocPlots = RicShowTotalAllocationDataFeature::selectedWellAllocationPlots();
return !wellAllocPlots.empty();
2017-04-19 13:44:08 +02:00
}
//--------------------------------------------------------------------------------------------------
///
2017-04-19 13:44:08 +02:00
//--------------------------------------------------------------------------------------------------
void RicShowTotalAllocationDataFeature::onActionTriggered( bool isChecked )
2017-04-19 13:44:08 +02:00
{
disableModelChangeContribution();
2017-04-19 13:44:08 +02:00
std::set<RimWellAllocationPlot*> wellAllocPlots = RicShowTotalAllocationDataFeature::selectedWellAllocationPlots();
CAF_ASSERT( wellAllocPlots.size() > 0 );
2017-04-19 13:44:08 +02:00
for ( auto wellAllocPlot : wellAllocPlots )
2017-04-19 13:44:08 +02:00
{
QString txt = wellAllocPlot->description();
txt += "\n";
txt += "\n";
txt += wellAllocPlot->totalWellFlowPlot()->totalAllocationAsText();
QString title = "Total Allocation (" + wellAllocPlot->wellName() + ")";
RicShowPlotDataFeature::showTextWindow( title, txt );
2017-04-19 13:44:08 +02:00
}
}
//--------------------------------------------------------------------------------------------------
///
2017-04-19 13:44:08 +02:00
//--------------------------------------------------------------------------------------------------
void RicShowTotalAllocationDataFeature::setupActionLook( QAction* actionToSetup )
2017-04-19 13:44:08 +02:00
{
actionToSetup->setText( "Show Total Allocation Data" );
2020-10-01 17:25:19 +02:00
// actionToSetup->setIcon(QIcon(":/PlotWindow.svg"));
2017-04-19 13:44:08 +02:00
}
//--------------------------------------------------------------------------------------------------
///
2017-04-19 13:44:08 +02:00
//--------------------------------------------------------------------------------------------------
std::set<RimWellAllocationPlot*> RicShowTotalAllocationDataFeature::selectedWellAllocationPlots()
{
std::set<RimWellAllocationPlot*> wellAllocPlots;
for ( auto obj : caf::SelectionManager::instance()->objectsByType<caf::PdmObject>() )
2017-04-19 13:44:08 +02:00
{
CAF_ASSERT( obj );
2017-04-19 13:44:08 +02:00
RimWellAllocationPlot* parentPlot = obj->firstAncestorOrThisOfType<RimWellAllocationPlot>();
if ( parentPlot )
2017-04-19 13:44:08 +02:00
{
wellAllocPlots.insert( parentPlot );
2017-04-19 13:44:08 +02:00
}
}
return wellAllocPlots;
}