///////////////////////////////////////////////////////////////////////////////// // // 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 "RicExportCompletionsForVisibleSimWellsFeature.h" #include "RicWellPathExportCompletionDataFeature.h" #include "RimSimWellInView.h" #include "RimSimWellInViewCollection.h" #include "cafSelectionManager.h" #include CAF_CMD_SOURCE_INIT( RicExportCompletionsForVisibleSimWellsFeature, "RicExportCompletionsForVisibleSimWellsFeature" ); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- bool RicExportCompletionsForVisibleSimWellsFeature::isCommandEnabled() { std::vector simWells = visibleSimWells(); if ( simWells.empty() ) { return false; } return true; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RicExportCompletionsForVisibleSimWellsFeature::onActionTriggered( bool isChecked ) { std::vector simWells = visibleSimWells(); CVF_ASSERT( !simWells.empty() ); std::vector wellPaths; QString dialogTitle = "Export Completion Data for Visible Simulation Wells"; RicWellPathExportCompletionDataFeature::prepareExportSettingsAndExportCompletions( dialogTitle, wellPaths, simWells ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RicExportCompletionsForVisibleSimWellsFeature::setupActionLook( QAction* actionToSetup ) { actionToSetup->setText( "Export Completion Data for Visible Simulation Wells" ); actionToSetup->setIcon( QIcon( ":/ExportCompletionsSymbol16x16.png" ) ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- std::vector RicExportCompletionsForVisibleSimWellsFeature::visibleSimWells() { std::vector simWells; { std::vector simWellCollection; caf::SelectionManager::instance()->objectsByType( &simWellCollection ); if ( simWellCollection.empty() ) { std::vector selectedSimWells; caf::SelectionManager::instance()->objectsByType( &selectedSimWells ); if ( !selectedSimWells.empty() ) { RimSimWellInViewCollection* parent = nullptr; selectedSimWells[0]->firstAncestorOrThisOfType( parent ); if ( parent ) { simWellCollection.push_back( parent ); } } } for ( auto coll : simWellCollection ) { for ( const auto& wellPath : coll->wells() ) { if ( wellPath->showWell() ) { simWells.push_back( wellPath ); } } } } std::set uniqueWellPaths( simWells.begin(), simWells.end() ); simWells.assign( uniqueWellPaths.begin(), uniqueWellPaths.end() ); return simWells; }