- if (aPrs.isEmpty())
- return;
-
- if (isValidSelection(aPrs)) {
- // 2. set the selection to sketch
- setSelectionCustom(aPrs);
- // 3. hide main planes if they have been displayed
- erasePreviewPlanes();
- // 4. if the planes were displayed, change the view projection
- TopoDS_Shape aShape = aPrs.shape();
- if (!aShape.IsNull()) {
- 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()) {
- //TopoDS_Shape aShape = aShapePtr->impl<TopoDS_Shape>();
- 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());
- }
- }