+
+void XGUI_ContextMenuMgr::addFeatures(QMenu* theMenu) const
+{
+ SessionPtr aMgr = ModelAPI_Session::get();
+ DocumentPtr aActiveDoc = aMgr->activeDocument();
+
+ XGUI_SelectionMgr* aSelMgr = myWorkshop->selector();
+ XGUI_ActionsMgr* aActionMgr = myWorkshop->actionsMgr();
+ const Config_DataModelReader* aDataModelXML = myWorkshop->dataModelXMLReader();
+ QModelIndexList aSelectedIndexes = aSelMgr->selection()->selectedIndexes();
+
+ QString aName;
+ int aLen = 0;
+ bool aIsRoot = false;
+ foreach(QModelIndex aIdx, aSelectedIndexes) {
+ // Process only first column
+ if (aIdx.column() == 0) {
+ aIsRoot = !aIdx.parent().isValid();
+ // Exit if the selected index belongs to non active document
+ if (aIsRoot && (aActiveDoc != aMgr->moduleDocument()))
+ return;
+ if ((!aIsRoot) && (aIdx.internalPointer() != aActiveDoc.get()))
+ return;
+
+ // Get name of the selected index
+ aName = aIdx.data().toString();
+ aLen = aName.indexOf('(');
+ if (aLen != -1) {
+ aName = aName.left(--aLen);
+ }
+ std::string aFeaturesStr = aIsRoot?
+ aDataModelXML->rootFolderFeatures(aName.toStdString()) :
+ aDataModelXML->subFolderFeatures(aName.toStdString());
+ if (aFeaturesStr.length() > 0) {
+ QStringList aFeturesList =
+ QString(aFeaturesStr.c_str()).split(",", QString::SkipEmptyParts);
+ foreach(QString aFea, aFeturesList) {
+ QAction* aAction = aActionMgr->action(aFea);
+ if (aAction)
+ theMenu->addAction(aAction);
+ }
+ }
+ }
+ }
+}
+
+#define UNCHECK_ACTION(NAME) \
+{ QAction* aAction = action(NAME); \
+bool isBlock = aAction->signalsBlocked(); \
+aAction->blockSignals(true); \
+aAction->setChecked(false); \
+ aAction->blockSignals(isBlock); }
+
+
+void XGUI_ContextMenuMgr::onResultSelection(bool theChecked)
+{
+ UNCHECK_ACTION("SELECT_VERTEX_CMD");
+ UNCHECK_ACTION("SELECT_EDGE_CMD");
+ UNCHECK_ACTION("SELECT_FACE_CMD");
+}
+
+void XGUI_ContextMenuMgr::onShapeSelection(bool theChecked)
+{
+ UNCHECK_ACTION("SHOW_RESULTS_CMD");
+}