- ModuleBase_ViewerPrs aPrs;
- // 1. find selected presentation either in the viewer or in OB
- XGUI_Selection* aSelection = myWorkshop->selector()->selection();
- QList<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
- // the selection in OCC viewer - the selection of a face in the viewer
- // it can be th main plane's face of a face on a visualized body
- if (!aSelected.empty()) {
- aPrs = aSelected.first();
+ QList<ModuleBase_ViewerPrs> aSelected = getFilteredSelected();
+
+ if (aSelected.empty())
+ return;
+ ModuleBase_ViewerPrs aPrs = aSelected.first();
+
+ bool aDone = ModuleBase_WidgetValidated::setSelection(aSelected, false);
+ if (aDone) {
+ updateByPlaneSelected(aPrs);
+ updateObject(myFeature);
+ }
+}
+
+void PartSet_WidgetSketchLabel::updateByPlaneSelected(const ModuleBase_ViewerPrs& thePrs)
+{
+ // 1. hide main planes if they have been displayed
+ erasePreviewPlanes();
+ // 2. if the planes were displayed, change the view projection
+ TopoDS_Shape aShape = thePrs.shape();
+ std::shared_ptr<GeomAPI_Shape> aGShape;
+ std::shared_ptr<GeomAPI_Shape> aBaseShape;
+
+ DataPtr aData = feature()->data();
+ AttributeSelectionPtr aSelAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
+ (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID()));
+
+ // selection happens in OCC viewer
+ if (!aShape.IsNull()) {
+ aGShape = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape());
+ aGShape->setImpl(new TopoDS_Shape(aShape));
+
+ if (aSelAttr && aSelAttr->context()) {
+ aBaseShape = aSelAttr->context()->shape();
+ }