#3528 Allow deleting of the whole casing design table.

This commit is contained in:
Gaute Lindkvist 2018-10-19 16:39:28 +02:00
parent 9abbdb2fd8
commit b316aff35a
4 changed files with 50 additions and 11 deletions

View File

@ -42,6 +42,13 @@ bool RicDeleteWellPathAttributeFeature::isCommandEnabled()
return true; return true;
} }
} }
{
if (caf::SelectionManager::instance()->selectedItemOfType<RimWellPathAttributeCollection>())
{
return true;
}
}
return false; return false;
} }
@ -53,24 +60,32 @@ void RicDeleteWellPathAttributeFeature::onActionTriggered(bool isChecked)
{ {
std::vector<RimWellPathAttribute*> attributes; std::vector<RimWellPathAttribute*> attributes;
caf::SelectionManager::instance()->objectsByType(&attributes, caf::SelectionManager::FIRST_LEVEL); caf::SelectionManager::instance()->objectsByType(&attributes, caf::SelectionManager::FIRST_LEVEL);
RimWellPathAttributeCollection* wellPathAttributeCollection = nullptr;
if (attributes.size() > 0) if (attributes.size() > 0)
{ {
RimWellPathAttributeCollection* wellPathAttributeCollection = nullptr;
attributes[0]->firstAncestorOrThisOfTypeAsserted(wellPathAttributeCollection); attributes[0]->firstAncestorOrThisOfTypeAsserted(wellPathAttributeCollection);
for (RimWellPathAttribute* attributeToDelete : attributes) for (RimWellPathAttribute* attributeToDelete : attributes)
{ {
wellPathAttributeCollection->deleteAttribute(attributeToDelete); wellPathAttributeCollection->deleteAttribute(attributeToDelete);
} }
wellPathAttributeCollection->updateAllRequiredEditors(); wellPathAttributeCollection->updateAllRequiredEditors();
}
if (wellPathAttributeCollection->attributes().empty()) else
{
wellPathAttributeCollection = caf::SelectionManager::instance()->selectedItemOfType<RimWellPathAttributeCollection>();
if (wellPathAttributeCollection)
{ {
RimWellPath* wellPath = nullptr; wellPathAttributeCollection->deleteAllAttributes();
wellPathAttributeCollection->firstAncestorOrThisOfTypeAsserted(wellPath);
wellPath->updateConnectedEditors();
Riu3DMainWindowTools::selectAsCurrentItem(wellPath);
} }
} }
if (wellPathAttributeCollection->attributes().empty())
{
RimWellPath* wellPath = nullptr;
wellPathAttributeCollection->firstAncestorOrThisOfTypeAsserted(wellPath);
wellPath->updateConnectedEditors();
Riu3DMainWindowTools::selectAsCurrentItem(wellPath);
}
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -78,6 +93,16 @@ void RicDeleteWellPathAttributeFeature::onActionTriggered(bool isChecked)
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicDeleteWellPathAttributeFeature::setupActionLook(QAction* actionToSetup) void RicDeleteWellPathAttributeFeature::setupActionLook(QAction* actionToSetup)
{ {
actionToSetup->setText("Delete Attribute"); std::vector<RimWellPathAttribute*> attributes;
actionToSetup->setIcon(QIcon(":/Erase.png")); caf::SelectionManager::instance()->objectsByType(&attributes, caf::SelectionManager::FIRST_LEVEL);
if (attributes.size() > 0)
{
actionToSetup->setText("Delete Attribute");
actionToSetup->setIcon(QIcon(":/Erase.png"));
}
else if (caf::SelectionManager::instance()->selectedItemOfType<RimWellPathAttributeCollection>())
{
actionToSetup->setText("Delete Casing Design");
actionToSetup->setIcon(QIcon(":/Erase.png"));
}
} }

View File

@ -82,6 +82,7 @@
#include "RimWellLogPlotCollection.h" #include "RimWellLogPlotCollection.h"
#include "RimWellLogTrack.h" #include "RimWellLogTrack.h"
#include "RimWellPath.h" #include "RimWellPath.h"
#include "RimWellPathAttributeCollection.h"
#include "RimWellPathCollection.h" #include "RimWellPathCollection.h"
#include "RimWellPltPlot.h" #include "RimWellPltPlot.h"
#include "RimWellRftPlot.h" #include "RimWellRftPlot.h"
@ -312,6 +313,10 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
menuBuilder << "Separator"; menuBuilder << "Separator";
} }
else if (dynamic_cast<RimWellPathAttributeCollection*>(uiItem))
{
menuBuilder << "RicDeleteWellPathAttributeFeature";
}
else if (dynamic_cast<Rim3dWellLogCurveCollection*>(uiItem) || else if (dynamic_cast<Rim3dWellLogCurveCollection*>(uiItem) ||
dynamic_cast<Rim3dWellLogExtractionCurve*>(uiItem) || dynamic_cast<Rim3dWellLogExtractionCurve*>(uiItem) ||
dynamic_cast<Rim3dWellLogFileCurve*>(uiItem) || dynamic_cast<Rim3dWellLogFileCurve*>(uiItem) ||

View File

@ -100,6 +100,15 @@ void RimWellPathAttributeCollection::deleteAttribute(RimWellPathAttribute* attri
this->updateAllReferringTracks(); this->updateAllReferringTracks();
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathAttributeCollection::deleteAllAttributes()
{
m_attributes.deleteAllChildObjects();
this->updateAllReferringTracks();
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -36,7 +36,7 @@ public:
std::vector<RimWellPathAttribute*> attributes() const; std::vector<RimWellPathAttribute*> attributes() const;
void insertAttribute(RimWellPathAttribute* insertBefore, RimWellPathAttribute* attribute); void insertAttribute(RimWellPathAttribute* insertBefore, RimWellPathAttribute* attribute);
void deleteAttribute(RimWellPathAttribute* attributeToDelete); void deleteAttribute(RimWellPathAttribute* attributeToDelete);
void deleteAllAttributes();
protected: protected:
void defineCustomContextMenu(const caf::PdmFieldHandle* fieldNeedingMenu, QMenu* menu, QWidget* fieldEditorWidget) override; void defineCustomContextMenu(const caf::PdmFieldHandle* fieldNeedingMenu, QMenu* menu, QWidget* fieldEditorWidget) override;
void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override; void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override;