aAction = new QAction(QIcon(":pictures/assembly.png"), tr("Deactivate"), this);
addAction("DEACTIVATE_PART_CMD", aAction);
+
+ aAction = new QAction(QIcon(":pictures/delete.png"), tr("Delete"), this);
+ addAction("DELETE_CMD", aAction);
}
void XGUI_ContextMenuMgr::addAction(const QString& theId, QAction* theAction)
} else {
aActions.append(action("EDIT_CMD"));
}
+ aActions.append(action("DELETE_CMD"));
// Process Root object (document)
} else { // If feature is 0 the it means that selected root object (document)
Events_ID aFeatureUpdatedId = aLoop->eventByName(EVENT_FEATURE_UPDATED);
aLoop->registerListener(this, aFeatureUpdatedId);
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_CREATED));
+ aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_DELETED));
activateModule();
if (myMainWindow) {
const Model_FeatureUpdatedMessage* aUpdMsg = dynamic_cast<const Model_FeatureUpdatedMessage*>(theMessage);
FeaturePtr aFeature = aUpdMsg->feature();
if (aFeature->getKind() == "Part") {
- //The created part will be created in Object Browser later and we have to activate that
- // only when it created everywere
+ //The created part will be created in Object Browser later and we have to activate it
+ // only when it is created everywere
QTimer::singleShot(50, this, SLOT(activateLastPart()));
}
}
+ // Process deletion of a part
+ if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_DELETED)) {
+ PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
+ if (aMgr->currentDocument() == aMgr->rootDocument())
+ activatePart(FeaturePtr()); // Activate PartSet
+ }
+
//Update property panel on corresponding message. If there is no current operation (no
//property panel), or received message has different feature to the current - do nothing.
static Events_ID aFeatureUpdatedId = Events_Loop::loop()->eventByName(EVENT_FEATURE_UPDATED);
activatePart(aFeatures.first());
else if (theId == "DEACTIVATE_PART_CMD")
activatePart(FeaturePtr());
-
+ else if (theId == "DELETE_CMD")
+ deleteFeatures(aFeatures);
}
//**************************************************************
FeaturePtr aLastPart = aDoc->feature(PARTS_GROUP, aDoc->size(PARTS_GROUP) - 1, true);
activatePart(aLastPart);
}
+
+//**************************************************************
+void XGUI_Workshop::deleteFeatures(QFeatureList theList)
+{
+ QMainWindow* aDesktop = isSalomeMode()? salomeConnector()->desktop() : myMainWindow;
+ QMessageBox::StandardButton aRes = QMessageBox::warning(aDesktop, tr("Delete features"),
+ tr("Seleted features will be deleted. Continue?"),
+ QMessageBox::No | QMessageBox::Yes, QMessageBox::No);
+ if (aRes == QMessageBox::Yes) {
+ foreach (FeaturePtr aFeature, theList) {
+ DocumentPtr aDoc = aFeature->data()->docRef("PartDocument")->value();
+ aDoc->removeFeature(aFeature);
+ }
+ }
+}
\ No newline at end of file
//! Returns icon name according to feature Id
static QString featureIcon(const std::string& theId);
+ //! Activates or deactivates a part
+ //! If PartPtr is Null pointer then PartSet will be activated
+ void activatePart(FeaturePtr theFeature);
+
+ void deleteFeatures(QFeatureList theList);
signals:
void salomeViewerSelection();
+ void errorOccurred(const QString&);
public slots:
void updateCommandStatus();
void onFeatureTriggered();
void changeCurrentDocument(FeaturePtr thePart);
-signals:
- void errorOccurred(const QString&);
-
-public slots:
- //! Activates or deactivates a part
- //! If PartPtr is Null pointer then PartSet will be activated
- void activatePart(FeaturePtr theFeature);
-
void activateLastPart();
protected: