- XGUI_Selection* aSelection = myWorkshop->selector()->selection();
- QList<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
- if (!aSelected.empty()) {
- ModuleBase_ViewerPrs aPrs = aSelected.first();
- Handle(SelectMgr_EntityOwner) anOwner = aSelected.first().owner();
- if (isValid(anOwner)) {
- setSelection(anOwner);
-
- TopoDS_Shape aShape = aPrs.shape();
- if (!aShape.IsNull()) {
- erasePreviewPlanes();
- DataPtr aData = feature()->data();
- AttributeSelectionPtr aSelAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
- (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID()));
- if (aSelAttr) {
- GeomShapePtr aShapePtr = aSelAttr->value();
- if (aShapePtr.get() == NULL || aShapePtr->isNull()) {
- std::shared_ptr<GeomAPI_Shape> aGShape(new GeomAPI_Shape);
- aGShape->setImpl(new TopoDS_Shape(aShape));
- // get plane parameters
- std::shared_ptr<GeomAPI_Pln> aPlane = GeomAlgoAPI_FaceBuilder::plane(aGShape);
- std::shared_ptr<GeomAPI_Dir> aDir = aPlane->direction();
-
- myWorkshop->viewer()->setViewProjection(aDir->x(), aDir->y(), aDir->z());
- }
- }
+ 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));