+void PartSet_SketcherMgr::updateSelectionPriority(ObjectPtr theObject,
+ FeaturePtr theFeature)
+{
+ if (!theObject.get() || !theFeature.get())
+ return;
+
+ AISObjectPtr anAIS = workshop()->displayer()->getAISObject(theObject);
+ Handle(AIS_InteractiveObject) anAISIO;
+ if (anAIS.get() != NULL) {
+ anAISIO = anAIS->impl<Handle(AIS_InteractiveObject)>();
+ }
+
+ if (!anAISIO.IsNull()) { // the presentation for the object is visualized
+ int anAdditionalPriority = 0;
+ // current feature
+ std::shared_ptr<SketchPlugin_Feature> aSPFeature =
+ std::dynamic_pointer_cast<SketchPlugin_Feature>(theFeature);
+ if (aSPFeature.get() != NULL) {
+ // 1. Vertices
+ // 2. Simple segments
+ // 3. External objects (violet color)
+ // 4. Auxiliary segments (dotted)
+ // StdSelect_BRepSelectionTool::Load uses priority calculating:
+ // Standard_Integer aPriority = (thePriority == -1) ? GetStandardPriority (theShape, theType) : thePriority;
+ // Priority of Vertex is 8, edge(segment) is 7.
+ // It might be not corrected as provides the condition above.
+ bool isExternal = aSPFeature->isExternal();
+ bool isAuxiliary = PartSet_Tools::isAuxiliarySketchEntity(aSPFeature);
+ // current feature
+ if (!isExternal && !isAuxiliary)
+ anAdditionalPriority = 30;
+ // external feature
+ if (isExternal)
+ anAdditionalPriority = 20;
+ // auxiliary feature
+ if (isAuxiliary) {
+ anAdditionalPriority = 10; /// auxiliary objects should have less priority that
+ // edges/vertices of local selection on not-sketch objects
+ }
+ Handle(ModuleBase_ResultPrs) aResult = Handle(ModuleBase_ResultPrs)::DownCast(anAISIO);
+ if (!aResult.IsNull()) {
+ aResult->setAdditionalSelectionPriority(anAdditionalPriority);
+ }
+ }
+ }
+}
+