mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Replace local selected object code in MSW export with cafSelectionManager methods.
This commit is contained in:
parent
c32590a5da
commit
b8f4aab4a9
@ -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<RimFishbonesCollection>();
|
||||
RimWellPath* wellPath = caf::SelectionManager::instance()->selectedItemAncestorOfType<RimWellPath>();
|
||||
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<caf::PdmObjectHandle*>(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<caf::PdmObjectHandle*>(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<RimFishbonesCollection>())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -41,10 +41,7 @@ protected:
|
||||
virtual bool isCommandEnabled() override;
|
||||
|
||||
public:
|
||||
static void exportWellSegments(const RimWellPath* wellPath, const std::vector<RimFishbonesMultipleSubs*>& fishbonesSubs, const RicCaseAndFileExportSettingsUi& settings);
|
||||
|
||||
private:
|
||||
static RimFishbonesCollection* selectedFishbonesCollection();
|
||||
static RimWellPath* selectedWellPath();
|
||||
|
||||
static void exportWellSegments(const RimWellPath* wellPath,
|
||||
const std::vector<RimFishbonesMultipleSubs*>& fishbonesSubs,
|
||||
const RicCaseAndFileExportSettingsUi& settings);
|
||||
};
|
||||
|
@ -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<RimWellPath>();
|
||||
RimWellPathFracture* fracture = caf::SelectionManager::instance()->selectedItemAncestorOfType<RimWellPathFracture>();
|
||||
RimWellPathFractureCollection* collection = caf::SelectionManager::instance()->selectedItemAncestorOfType<RimWellPathFractureCollection>();
|
||||
|
||||
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<caf::PdmObjectHandle*>(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<caf::PdmObjectHandle*>(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<caf::PdmObjectHandle*>(pdmUiItem);
|
||||
if (objHandle)
|
||||
{
|
||||
objHandle->firstAncestorOrThisOfType(objToFind);
|
||||
}
|
||||
|
||||
return objToFind;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicExportFracturesWellSegmentsFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
if (selectedWellPathFracture())
|
||||
if (caf::SelectionManager::instance()->selectedItemOfType<RimWellPathFracture>())
|
||||
{
|
||||
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<RimWellPathFractureCollection>())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -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();
|
||||
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user