- // Clear text in the label
- myLabel->setText("");
- myLabel->setToolTip("");
- disconnect(myWorkshop->selector(), SIGNAL(selectionChanged()),
- this, SLOT(onPlaneSelected()));
- activateFilters(myWorkshop->module()->workshop(), false);
-
- // Clear selection mode and define sketching mode
- //XGUI_Displayer* aDisp = myWorkshop->displayer();
- //aDisp->closeLocalContexts();
- emit planeSelected(plane());
- setSketchingMode();
-
- // Update sketcher actions
- XGUI_ActionsMgr* anActMgr = myWorkshop->actionsMgr();
- anActMgr->update();
- myWorkshop->viewer()->update();
+ // 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();
+ }
+ }
+ else { // selection happens in OCC viewer(on body) of in the OB browser
+ if (aSelAttr) {
+ aGShape = aSelAttr->value();
+ }
+ }
+ if (aGShape.get() != NULL) {
+ // get plane parameters
+ std::shared_ptr<GeomAPI_Pln> aPlane = GeomAlgoAPI_FaceBuilder::plane(aGShape);
+ std::shared_ptr<GeomAPI_Dir> aDir = aPlane->direction();
+ gp_XYZ aXYZ = aDir->impl<gp_Dir>().XYZ();
+ double aTwist = 0.0;
+
+ // orienting projection
+ if(aBaseShape.get() != NULL) {
+ std::shared_ptr<GeomAPI_Pnt> aCenterPnt = GeomAlgoAPI_ShapeTools::centreOfMass(aGShape);
+ gp_Pnt aPnt = aCenterPnt->impl<gp_Pnt>();
+ aPnt.Translate(aDir->impl<gp_Dir>().XYZ() * (10 * Precision::Confusion()));
+
+ BRepClass3d_SolidClassifier aClassifier;
+ aClassifier.Load(aBaseShape->impl<TopoDS_Shape>());
+ aClassifier.Perform(aPnt, Precision::Confusion());
+
+ if(aClassifier.State() == TopAbs_IN) {
+ aXYZ.Reverse();