diff --git a/ApplicationCode/Commands/FishbonesCommands/RicExportFishbonesLateralsFeature.cpp b/ApplicationCode/Commands/FishbonesCommands/RicExportFishbonesLateralsFeature.cpp index 148d3a545f..7fd77802ce 100644 --- a/ApplicationCode/Commands/FishbonesCommands/RicExportFishbonesLateralsFeature.cpp +++ b/ApplicationCode/Commands/FishbonesCommands/RicExportFishbonesLateralsFeature.cpp @@ -41,7 +41,11 @@ CAF_CMD_SOURCE_INIT(RicExportFishbonesLateralsFeature, "RicExportFishbonesLatera //-------------------------------------------------------------------------------------------------- void RicExportFishbonesLateralsFeature::onActionTriggered(bool isChecked) { - RimWellPath* wellPath = selectedWellPath(); + RimFishbonesCollection* fishbonesCollection = selectedFishbonesCollection(); + CVF_ASSERT(fishbonesCollection); + + RimWellPath* wellPath = nullptr; + fishbonesCollection->firstAncestorOrThisOfType(wellPath); CVF_ASSERT(wellPath); RiaApplication* app = RiaApplication::instance(); @@ -78,7 +82,7 @@ void RicExportFishbonesLateralsFeature::onActionTriggered(bool isChecked) size_t fishboneSubIndex = 0; QTextStream stream(&exportFile); - for (RimFishbonesMultipleSubs* fishbone : wellPath->fishbonesCollection()->fishbonesSubs()) + for (RimFishbonesMultipleSubs* fishbone : fishbonesCollection->fishbonesSubs()) { if (!fishbone->isChecked()) continue; @@ -126,19 +130,19 @@ QString RicExportFishbonesLateralsFeature::formatNumber(double val, int numberOf //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimWellPath* RicExportFishbonesLateralsFeature::selectedWellPath() +RimFishbonesCollection* RicExportFishbonesLateralsFeature::selectedFishbonesCollection() { - RimWellPath* wellPath = nullptr; + RimFishbonesCollection* objToFind = nullptr; caf::PdmUiItem* pdmUiItem = caf::SelectionManager::instance()->selectedItem(); caf::PdmObjectHandle* objHandle = dynamic_cast(pdmUiItem); if (objHandle) { - objHandle->firstAncestorOrThisOfType(wellPath); + objHandle->firstAncestorOrThisOfType(objToFind); } - return wellPath; + return objToFind; } //-------------------------------------------------------------------------------------------------- @@ -155,7 +159,7 @@ void RicExportFishbonesLateralsFeature::setupActionLook(QAction* actionToSetup) //-------------------------------------------------------------------------------------------------- bool RicExportFishbonesLateralsFeature::isCommandEnabled() { - if (selectedWellPath()) + if (selectedFishbonesCollection()) { return true; } diff --git a/ApplicationCode/Commands/FishbonesCommands/RicExportFishbonesLateralsFeature.h b/ApplicationCode/Commands/FishbonesCommands/RicExportFishbonesLateralsFeature.h index 1fa1472b84..8422c11694 100644 --- a/ApplicationCode/Commands/FishbonesCommands/RicExportFishbonesLateralsFeature.h +++ b/ApplicationCode/Commands/FishbonesCommands/RicExportFishbonesLateralsFeature.h @@ -20,7 +20,7 @@ #include "cafCmdFeature.h" -class RimWellPath; +class RimFishbonesCollection; //================================================================================================== /// @@ -36,5 +36,5 @@ protected: private: static QString formatNumber(double val, int numberOfDecimals); - static RimWellPath* selectedWellPath(); + static RimFishbonesCollection* selectedFishbonesCollection(); }; diff --git a/ApplicationCode/Commands/WellPathCommands/RicWellPathImportCompletionsFileFeature.cpp b/ApplicationCode/Commands/WellPathCommands/RicWellPathImportCompletionsFileFeature.cpp index ade523098e..761e871ec6 100644 --- a/ApplicationCode/Commands/WellPathCommands/RicWellPathImportCompletionsFileFeature.cpp +++ b/ApplicationCode/Commands/WellPathCommands/RicWellPathImportCompletionsFileFeature.cpp @@ -1,7 +1,6 @@ ///////////////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2015- Statoil ASA -// Copyright (C) 2015- Ceetron Solutions AS +// 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 @@ -21,10 +20,11 @@ #include "RiaApplication.h" -#include "RimProject.h" -#include "RimWellPath.h" #include "RimFishboneWellPathCollection.h" #include "RimFishbonesCollection.h" +#include "RimProject.h" +#include "RimWellPath.h" +#include "RimWellPathCompletions.h" #include "RiuMainWindow.h" @@ -40,10 +40,8 @@ CAF_CMD_SOURCE_INIT(RicWellPathImportCompletionsFileFeature, "RicWellPathImportC //-------------------------------------------------------------------------------------------------- bool RicWellPathImportCompletionsFileFeature::isCommandEnabled() { - std::vector objects; - caf::SelectionManager::instance()->objectsByType(&objects); - - if (objects.size() == 1) { + if (RicWellPathImportCompletionsFileFeature::selectedWellPathCompletions() != nullptr) + { return true; } @@ -55,10 +53,8 @@ bool RicWellPathImportCompletionsFileFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicWellPathImportCompletionsFileFeature::onActionTriggered(bool isChecked) { - std::vector objects; - caf::SelectionManager::instance()->objectsByType(&objects); - - CVF_ASSERT(objects.size() == 1); + RimWellPathCompletions* wellPathCompletions = RicWellPathImportCompletionsFileFeature::selectedWellPathCompletions(); + CVF_ASSERT(wellPathCompletions); // Open dialog box to select well path files RiaApplication* app = RiaApplication::instance(); @@ -70,7 +66,7 @@ void RicWellPathImportCompletionsFileFeature::onActionTriggered(bool isChecked) // Remember the path to next time app->setLastUsedDialogDirectory("WELLPATH_DIR", QFileInfo(wellPathFilePaths.last()).absolutePath()); - objects[0]->fishbonesCollection()->wellPathCollection()->importCompletionsFromFile(wellPathFilePaths); + wellPathCompletions->fishbonesCollection()->wellPathCollection()->importCompletionsFromFile(wellPathFilePaths); if (app->project()) { @@ -86,3 +82,19 @@ void RicWellPathImportCompletionsFileFeature::setupActionLook(QAction* actionToS actionToSetup->setText("Import Completions from File"); actionToSetup->setIcon(QIcon(":/Well.png")); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellPathCompletions* RicWellPathImportCompletionsFileFeature::selectedWellPathCompletions() +{ + std::vector objects; + caf::SelectionManager::instance()->objectsByType(&objects); + + if (objects.size() > 0) + { + return objects[0]; + } + + return nullptr; +} diff --git a/ApplicationCode/Commands/WellPathCommands/RicWellPathImportCompletionsFileFeature.h b/ApplicationCode/Commands/WellPathCommands/RicWellPathImportCompletionsFileFeature.h index dc26985bb0..7755260aae 100644 --- a/ApplicationCode/Commands/WellPathCommands/RicWellPathImportCompletionsFileFeature.h +++ b/ApplicationCode/Commands/WellPathCommands/RicWellPathImportCompletionsFileFeature.h @@ -1,7 +1,6 @@ ///////////////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2015- Statoil ASA -// Copyright (C) 2015- Ceetron Solutions AS +// 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 @@ -21,6 +20,8 @@ #include "cafCmdFeature.h" +class RimWellPathCompletions; + //================================================================================================== /// //================================================================================================== @@ -33,5 +34,8 @@ protected: virtual bool isCommandEnabled() override; virtual void onActionTriggered( bool isChecked ) override; virtual void setupActionLook( QAction* actionToSetup ) override; + +private: + static RimWellPathCompletions* selectedWellPathCompletions(); }; diff --git a/ApplicationCode/ProjectDataModel/Fishbones/RimFishbonesCollection.cpp b/ApplicationCode/ProjectDataModel/Fishbones/RimFishbonesCollection.cpp index fac550c28c..f5c6c77b52 100644 --- a/ApplicationCode/ProjectDataModel/Fishbones/RimFishbonesCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Fishbones/RimFishbonesCollection.cpp @@ -18,16 +18,10 @@ #include "RimFishbonesCollection.h" -#include "RimEclipseWell.h" -#include "RimPerforationInterval.h" -#include "RimView.h" -#include "RimProject.h" +#include "RifWellPathImporter.h" #include "RigWellPath.h" -#include "RifWellPathImporter.h" - -#include "RiuMainWindow.h" #include "RimFishboneWellPathCollection.h" #include "RimFishbonesMultipleSubs.h" @@ -58,6 +52,8 @@ RimFishbonesCollection::RimFishbonesCollection() //-------------------------------------------------------------------------------------------------- RimFishboneWellPathCollection* RimFishbonesCollection::wellPathCollection() const { + CVF_ASSERT(m_wellPathCollection); + return m_wellPathCollection(); } diff --git a/ApplicationCode/ProjectDataModel/Fishbones/RimFishbonesCollection.h b/ApplicationCode/ProjectDataModel/Fishbones/RimFishbonesCollection.h index 7de17d9bd4..dbb8b8b58c 100644 --- a/ApplicationCode/ProjectDataModel/Fishbones/RimFishbonesCollection.h +++ b/ApplicationCode/ProjectDataModel/Fishbones/RimFishbonesCollection.h @@ -20,9 +20,7 @@ #include "RimCheckableNamedObject.h" -#include "cafPdmObject.h" #include "cafPdmChildArrayField.h" -#include "cafPdmField.h" #include "cafPdmChildField.h" class RimFishbonesMultipleSubs; diff --git a/ApplicationCode/ProjectDataModel/RimWellPathCompletions.cpp b/ApplicationCode/ProjectDataModel/RimWellPathCompletions.cpp index 8f4f3e65bd..de60a4a1ea 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathCompletions.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPathCompletions.cpp @@ -21,6 +21,8 @@ #include "RimFishbonesCollection.h" #include "RimPerforationCollection.h" +#include "cvfAssert.h" + CAF_PDM_SOURCE_INIT(RimWellPathCompletions, "WellPathCompletions"); @@ -45,6 +47,8 @@ RimWellPathCompletions::RimWellPathCompletions() //-------------------------------------------------------------------------------------------------- RimFishbonesCollection* RimWellPathCompletions::fishbonesCollection() const { + CVF_ASSERT(m_fishbonesCollection); + return m_fishbonesCollection; } @@ -53,6 +57,8 @@ RimFishbonesCollection* RimWellPathCompletions::fishbonesCollection() const //-------------------------------------------------------------------------------------------------- RimPerforationCollection* RimWellPathCompletions::perforationCollection() const { + CVF_ASSERT(m_perforationCollection); + return m_perforationCollection; }