From: dbv Date: Tue, 30 Jun 2015 19:26:52 +0000 (+0300) Subject: Bug #619: Sketch plane rotation. X-Git-Tag: V_1.3.0~144 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ed0fc127d631676e17e23fb93a1a71d3e5f39052;p=modules%2Fshaper.git Bug #619: Sketch plane rotation. Fixed view projection when selecting body face as sketch plane. --- diff --git a/src/PartSet/PartSet_WidgetSketchLabel.cpp b/src/PartSet/PartSet_WidgetSketchLabel.cpp index e2d551bd2..d0de6fb94 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.cpp +++ b/src/PartSet/PartSet_WidgetSketchLabel.cpp @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -33,6 +34,7 @@ #include #include +#include #include #include #include @@ -116,15 +118,22 @@ void PartSet_WidgetSketchLabel::onSelectionChanged() // 4. if the planes were displayed, change the view projection TopoDS_Shape aShape = aPrs.shape(); std::shared_ptr aGShape; + std::shared_ptr aBaseShape; + + DataPtr aData = feature()->data(); + AttributeSelectionPtr aSelAttr = std::dynamic_pointer_cast + (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID())); + // selection happens in OCC viewer if (!aShape.IsNull()) { - aGShape = std::shared_ptr(new GeomAPI_Shape); + aGShape = std::make_shared(); 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 - DataPtr aData = feature()->data(); - AttributeSelectionPtr aSelAttr = std::dynamic_pointer_cast - (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID())); if (aSelAttr) { aGShape = aSelAttr->value(); } @@ -133,8 +142,24 @@ void PartSet_WidgetSketchLabel::onSelectionChanged() // get plane parameters std::shared_ptr aPlane = GeomAlgoAPI_FaceBuilder::plane(aGShape); std::shared_ptr aDir = aPlane->direction(); + gp_XYZ aXYZ = aDir->impl().XYZ(); + + // orienting projection + if(aBaseShape.get() != NULL) { + std::shared_ptr aCenterPnt = GeomAlgoAPI_ShapeProps::centreOfMass(aGShape); + gp_Pnt aPnt = aCenterPnt->impl(); + aPnt.Translate(aDir->impl().XYZ() * (10 * Precision::Confusion())); + + BRepClass3d_SolidClassifier aClassifier; + aClassifier.Load(aBaseShape->impl()); + aClassifier.Perform(aPnt, Precision::Confusion()); + + if(aClassifier.State() == TopAbs_IN) { + aXYZ.Reverse(); + } + } - myWorkshop->viewer()->setViewProjection(aDir->x(), aDir->y(), aDir->z()); + myWorkshop->viewer()->setViewProjection(aXYZ.X(), aXYZ.Y(), aXYZ.Z()); } // 5. Clear text in the label myLabel->setText("");