///////////////////////////////////////////////////////////////////////////////// // // 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 "RicExportCompletionsForTemporaryLgrsFeature.h" #include "RicWellPathExportCompletionDataFeature.h" #include "RigMainGrid.h" #include "RiuPlotMainWindow.h" #include "RimEclipseCase.h" #include "RimGridCollection.h" #include "RimProject.h" #include "RimWellPath.h" #include "RimWellPathCollection.h" #include "cafSelectionManagerTools.h" #include CAF_CMD_SOURCE_INIT( RicExportCompletionsForTemporaryLgrsFeature, "RicExportCompletionsForTemporaryLgrsFeature" ); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- bool RicExportCompletionsForTemporaryLgrsFeature::isCommandEnabled() const { if ( wellPathsAssociatedWithLgrs().empty() ) { return false; } std::vector selGridInfos = caf::selectedObjectsByTypeStrict(); return selGridInfos.size() == 1 && selGridInfos.front()->uiName() == RimGridCollection::temporaryGridUiName(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RicExportCompletionsForTemporaryLgrsFeature::onActionTriggered( bool isChecked ) { std::vector wellPaths = wellPathsAssociatedWithLgrs(); if ( wellPaths.empty() ) { return; } std::vector simWells; QString dialogTitle = "Export Completion Data for Temporary LGRs"; RicWellPathExportCompletionDataFeature::prepareExportSettingsAndExportCompletions( dialogTitle, wellPaths, simWells ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RicExportCompletionsForTemporaryLgrsFeature::setupActionLook( QAction* actionToSetup ) { actionToSetup->setText( "Export Completion Data" ); actionToSetup->setIcon( QIcon( ":/ExportCompletionsSymbol16x16.png" ) ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- std::vector RicExportCompletionsForTemporaryLgrsFeature::wellPathsAssociatedWithLgrs() { std::vector wellPaths; auto selectedEclipseCase = caf::firstAncestorOfTypeFromSelectedObject(); if ( selectedEclipseCase ) { auto mainGrid = selectedEclipseCase->mainGrid(); std::set wellPathNames; for ( size_t i = 0; i < mainGrid->gridCount(); i++ ) { const RigGridBase* grid = mainGrid->gridByIndex( i ); if ( !grid->associatedWellPathName().empty() ) { wellPathNames.insert( QString::fromStdString( grid->associatedWellPathName() ) ); } } auto project = RimProject::current(); for ( const auto& wellPathName : wellPathNames ) { auto wellPath = project->wellPathByName( wellPathName ); if ( wellPath ) { wellPaths.push_back( wellPath ); } } } return wellPaths; }