diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.cpp index 1759b069a6..e7fcf2ef2d 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.cpp @@ -57,8 +57,8 @@ CAF_CMD_SOURCE_INIT(RicExportFishbonesWellSegmentsFeature, "RicExportFishbonesWe //-------------------------------------------------------------------------------------------------- void RicExportFishbonesWellSegmentsFeature::onActionTriggered(bool isChecked) { - RimFishbonesCollection* fishbonesCollection = selectedFishbonesCollection(); - RimWellPath* wellPath = selectedWellPath(); + RimFishbonesCollection* fishbonesCollection = caf::SelectionManager::instance()->selectedItemAncestorOfType(); + RimWellPath* wellPath = caf::SelectionManager::instance()->selectedItemAncestorOfType(); CVF_ASSERT(fishbonesCollection); CVF_ASSERT(wellPath); @@ -99,42 +99,6 @@ void RicExportFishbonesWellSegmentsFeature::onActionTriggered(bool isChecked) } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimFishbonesCollection* RicExportFishbonesWellSegmentsFeature::selectedFishbonesCollection() -{ - RimFishbonesCollection* objToFind = nullptr; - - caf::PdmUiItem* pdmUiItem = caf::SelectionManager::instance()->selectedItem(); - - caf::PdmObjectHandle* objHandle = dynamic_cast(pdmUiItem); - if (objHandle) - { - objHandle->firstAncestorOrThisOfType(objToFind); - } - - return objToFind; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimWellPath* RicExportFishbonesWellSegmentsFeature::selectedWellPath() -{ - RimWellPath* objToFind = nullptr; - - caf::PdmUiItem* pdmUiItem = caf::SelectionManager::instance()->selectedItem(); - - caf::PdmObjectHandle* objHandle = dynamic_cast(pdmUiItem); - if (objHandle) - { - objHandle->firstAncestorOrThisOfType(objToFind); - } - - return objToFind; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -148,7 +112,7 @@ void RicExportFishbonesWellSegmentsFeature::setupActionLook(QAction* actionToSet //-------------------------------------------------------------------------------------------------- bool RicExportFishbonesWellSegmentsFeature::isCommandEnabled() { - if (selectedFishbonesCollection()) + if (caf::SelectionManager::instance()->selectedItemAncestorOfType()) { return true; } diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.h b/ApplicationCode/Commands/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.h index fccab1c442..083bfff7c2 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.h @@ -41,10 +41,7 @@ protected: virtual bool isCommandEnabled() override; public: - static void exportWellSegments(const RimWellPath* wellPath, const std::vector& fishbonesSubs, const RicCaseAndFileExportSettingsUi& settings); - -private: - static RimFishbonesCollection* selectedFishbonesCollection(); - static RimWellPath* selectedWellPath(); - + static void exportWellSegments(const RimWellPath* wellPath, + const std::vector& fishbonesSubs, + const RicCaseAndFileExportSettingsUi& settings); }; diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportFracturesWellSegmentsFeature.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicExportFracturesWellSegmentsFeature.cpp index 35cb49ed94..ff2ae2bc1f 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicExportFracturesWellSegmentsFeature.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportFracturesWellSegmentsFeature.cpp @@ -90,12 +90,12 @@ void RicExportFracturesWellSegmentsFeature::exportWellSegments(const RimWellPath //-------------------------------------------------------------------------------------------------- void RicExportFracturesWellSegmentsFeature::onActionTriggered(bool isChecked) { - RimWellPath* wellPath = selectedWellPath(); - RimWellPathFracture* fracture = selectedWellPathFracture(); - RimWellPathFractureCollection* fractureCollection = selectedWellPathFractureCollection(); + RimWellPath* wellPath = caf::SelectionManager::instance()->selectedItemAncestorOfType(); + RimWellPathFracture* fracture = caf::SelectionManager::instance()->selectedItemAncestorOfType(); + RimWellPathFractureCollection* collection = caf::SelectionManager::instance()->selectedItemAncestorOfType(); CVF_ASSERT(wellPath); - CVF_ASSERT(fractureCollection); + CVF_ASSERT(collection); RiaApplication* app = RiaApplication::instance(); @@ -130,7 +130,7 @@ void RicExportFracturesWellSegmentsFeature::onActionTriggered(bool isChecked) } else { - for (RimWellPathFracture* fracture : fractureCollection->fractures()) + for (RimWellPathFracture* fracture : collection->fractures()) { if (fracture->isChecked()) { @@ -143,66 +143,12 @@ void RicExportFracturesWellSegmentsFeature::onActionTriggered(bool isChecked) } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimWellPath* RicExportFracturesWellSegmentsFeature::selectedWellPath() -{ - RimWellPath* objToFind = nullptr; - - caf::PdmUiItem* pdmUiItem = caf::SelectionManager::instance()->selectedItem(); - - caf::PdmObjectHandle* objHandle = dynamic_cast(pdmUiItem); - if (objHandle) - { - objHandle->firstAncestorOrThisOfType(objToFind); - } - - return objToFind; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimWellPathFracture* RicExportFracturesWellSegmentsFeature::selectedWellPathFracture() -{ - RimWellPathFracture* objToFind = nullptr; - - caf::PdmUiItem* pdmUiItem = caf::SelectionManager::instance()->selectedItem(); - - caf::PdmObjectHandle* objHandle = dynamic_cast(pdmUiItem); - if (objHandle) - { - objHandle->firstAncestorOrThisOfType(objToFind); - } - - return objToFind; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimWellPathFractureCollection* RicExportFracturesWellSegmentsFeature::selectedWellPathFractureCollection() -{ - RimWellPathFractureCollection* objToFind = nullptr; - - caf::PdmUiItem* pdmUiItem = caf::SelectionManager::instance()->selectedItem(); - - caf::PdmObjectHandle* objHandle = dynamic_cast(pdmUiItem); - if (objHandle) - { - objHandle->firstAncestorOrThisOfType(objToFind); - } - - return objToFind; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RicExportFracturesWellSegmentsFeature::setupActionLook(QAction* actionToSetup) { - if (selectedWellPathFracture()) + if (caf::SelectionManager::instance()->selectedItemOfType()) { actionToSetup->setText("Export Fracture as Multi Segment Well"); } @@ -217,7 +163,7 @@ void RicExportFracturesWellSegmentsFeature::setupActionLook(QAction* actionToSet //-------------------------------------------------------------------------------------------------- bool RicExportFracturesWellSegmentsFeature::isCommandEnabled() { - if (selectedWellPathFractureCollection()) + if (caf::SelectionManager::instance()->selectedItemAncestorOfType()) { return true; } diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportFracturesWellSegmentsFeature.h b/ApplicationCode/Commands/CompletionExportCommands/RicExportFracturesWellSegmentsFeature.h index 27876d608e..3da20bd68f 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicExportFracturesWellSegmentsFeature.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportFracturesWellSegmentsFeature.h @@ -40,9 +40,4 @@ protected: virtual void onActionTriggered(bool isChecked) override; virtual void setupActionLook(QAction* actionToSetup) override; virtual bool isCommandEnabled() override; - - static RimWellPath* selectedWellPath(); - static RimWellPathFracture* selectedWellPathFracture(); - static RimWellPathFractureCollection* selectedWellPathFractureCollection(); - };