///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2017 Statoil ASA // // 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. // // 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 // for more details. // ///////////////////////////////////////////////////////////////////////////////// #include "RicShowTotalAllocationDataFeature.h" #include "ApplicationCommands/RicShowPlotDataFeature.h" #include "RimTotalWellAllocationPlot.h" #include "RimWellAllocationPlot.h" #include "cafSelectionManager.h" #include "cvfAssert.h" #include #include CAF_CMD_SOURCE_INIT( RicShowTotalAllocationDataFeature, "RicShowTotalAllocationDataFeature" ); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- bool RicShowTotalAllocationDataFeature::isCommandEnabled() const { std::set wellAllocPlots = RicShowTotalAllocationDataFeature::selectedWellAllocationPlots(); return wellAllocPlots.size() > 0; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RicShowTotalAllocationDataFeature::onActionTriggered( bool isChecked ) { this->disableModelChangeContribution(); std::set wellAllocPlots = RicShowTotalAllocationDataFeature::selectedWellAllocationPlots(); CVF_ASSERT( wellAllocPlots.size() > 0 ); for ( auto wellAllocPlot : wellAllocPlots ) { QString txt = wellAllocPlot->description(); txt += "\n"; txt += "\n"; txt += wellAllocPlot->totalWellFlowPlot()->totalAllocationAsText(); QString title = "Total Allocation (" + wellAllocPlot->wellName() + ")"; RicShowPlotDataFeature::showTextWindow( title, txt ); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RicShowTotalAllocationDataFeature::setupActionLook( QAction* actionToSetup ) { actionToSetup->setText( "Show Total Allocation Data" ); // actionToSetup->setIcon(QIcon(":/PlotWindow.svg")); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- std::set RicShowTotalAllocationDataFeature::selectedWellAllocationPlots() { std::set wellAllocPlots; std::vector objects; caf::SelectionManager::instance()->objectsByType( &objects ); for ( auto obj : objects ) { CVF_ASSERT( obj ); RimWellAllocationPlot* parentPlot = obj->firstAncestorOrThisOfType(); if ( parentPlot ) { wellAllocPlots.insert( parentPlot ); } } return wellAllocPlots; }