aAction = new QAction(QIcon(":icons/edit.png"), tr("Edit..."), this);
connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onEdit(bool)));
myActions["EDIT_CMD"] = aAction;
-
- aAction = new QAction(QIcon(), tr("Select parent feature"), this);
- aAction->setCheckable(false);
- connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onSelectParentFeature()));
- myActions["SELECT_PARENT_CMD"] = aAction;
}
myModule->editFeature(aFeature);
}
-void PartSet_MenuMgr::onSelectParentFeature()
-{
- QObjectPtrList aObjects = myModule->workshop()->selection()->selectedObjects();
- if (aObjects.size() != 1)
- return;
-
- SessionPtr aMgr = ModelAPI_Session::get();
- ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>( aObjects.first() );
- if( !aResult.get() )
- return;
-
- FeaturePtr aParentFeature = aResult->document()->feature( aResult );
- QObjectPtrList aSelection;
- aSelection.append( aParentFeature );
- myModule->workshop()->selection()->setSelectedObjects( aSelection );
-}
-
bool PartSet_MenuMgr::eventFilter(QObject* theObj, QEvent* theEvent)
{
if (theEvent->type() == QEvent::MouseButtonDblClick) {
/// A slot called on edit of feature
void onEdit(bool);
- void onSelectParentFeature();
-
protected:
bool eventFilter(QObject* theObj, QEvent* theEvent);
aAction = new QAction(QIcon(":pictures/find_result.png"), tr("Select results"), this);
addAction("SHOW_RESULTS_CMD", aAction);
+ aAction = new QAction(QIcon(":pictures/find_result.png"), tr("Select parent feature"), this);
+ addAction("SHOW_FEATURE_CMD", aAction);
+
buildObjBrowserMenu();
buildViewerMenu();
}
action("CLEAN_HISTORY_CMD")->setEnabled(true);
action("SHOW_RESULTS_CMD")->setEnabled(hasFeature);
+ action("SHOW_FEATURE_CMD")->setEnabled(hasResult);
}
// Show/Hide command has to be disabled for objects from non active document
aList.append(mySeparator);
aList.append(action("RENAME_CMD"));
aList.append(action("COLOR_CMD"));
+ aList.append(action("SHOW_FEATURE_CMD"));
myObjBrowserMenus[ModelAPI_ResultConstruction::group()] = aList;
//-------------------------------------
aList.append(mySeparator);
aList.append(action("RENAME_CMD"));
aList.append(action("COLOR_CMD"));
+ aList.append(action("SHOW_FEATURE_CMD"));
myObjBrowserMenus[ModelAPI_ResultBody::group()] = aList;
// Group menu
myObjBrowserMenus[ModelAPI_ResultGroup::group()] = aList;
//-------------------------------------
// Feature menu
aList.clear();
- aList.append(action("SHOW_RESULTS_CMD"));
- aList.append(mySeparator);
aList.append(action("RENAME_CMD"));
+ aList.append(action("SHOW_RESULTS_CMD"));
aList.append(action("MOVE_CMD"));
aList.append(mySeparator);
aList.append(action("CLEAN_HISTORY_CMD"));
setViewerSelectionMode(-1);
} else if (theId == "SHOW_RESULTS_CMD") {
highlightResults(aObjects);
+ } else if (theId == "SHOW_FEATURE_CMD") {
+ highlightFeature(aObjects);
}
}
objectBrowser()->blockSignals(aBlocked);
}
}
+
+void XGUI_Workshop::highlightFeature(const QObjectPtrList& theObjects)
+{
+ ResultPtr aResult;
+ QObjectPtrList aSelList = theObjects;
+ FeaturePtr aFeature;
+ foreach(ObjectPtr aObj, theObjects) {
+ aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
+ if (aResult.get()) {
+ aFeature = ModelAPI_Feature::feature(aResult);
+ if (aFeature.get()) {
+ aSelList.append(aFeature);
+ }
+ }
+ }
+ if (aSelList.count() > theObjects.count()) {
+ // if something was found
+ bool aBlocked = objectBrowser()->blockSignals(true);
+ objectBrowser()->setObjectsSelected(aSelList);
+ objectBrowser()->blockSignals(aBlocked);
+ }
+}
/// features found in the given list
void highlightResults(const QObjectPtrList& theObjects);
+ /// Highlights feature objects in Object Browser according to
+ /// features found in the given list
+ void highlightFeature(const QObjectPtrList& theObjects);
+
/// Returns Data Model XML reader which contains information about
/// Data structure configuration
const Config_DataModelReader* dataModelXMLReader() const { return myDataModelXMLReader; }