X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FPartSet%2FPartSet_OperationSketch.cpp;h=c343503e2467bf22f60015430cd021df48d9c088;hb=d4572a0253007ff9fc263253720e37bf896f8d0d;hp=c9608cd2e1982d8536a3d49b45da62d9d528897f;hpb=a764a876ed5d1480b2a76f4e12307985bcf96c16;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_OperationSketch.cpp b/src/PartSet/PartSet_OperationSketch.cpp index c9608cd2e..c343503e2 100644 --- a/src/PartSet/PartSet_OperationSketch.cpp +++ b/src/PartSet/PartSet_OperationSketch.cpp @@ -4,9 +4,12 @@ #include -#include +#include #include -#include +#include +#include +#include +#include #include #include @@ -37,27 +40,47 @@ int PartSet_OperationSketch::getSelectionMode() const return TopAbs_FACE; } -void PartSet_OperationSketch::setSelectedObjects(const AIS_ListOfInteractive& theList) +void PartSet_OperationSketch::setSelectedShapes(const NCollection_List& theList) { if (theList.IsEmpty()) return; - // 1. get selected fase - Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast(theList.First()); - if (anAISShape.IsNull()) - return; - - const TopoDS_Shape& aShape = anAISShape->Shape(); - boost::shared_ptr aRes(new GeomAPI_Shape); - aRes->setImpl(new TopoDS_Shape(aShape)); + // get selected shape + const TopoDS_Shape& aShape = theList.First(); + boost::shared_ptr aGShape(new GeomAPI_Shape); + aGShape->setImpl(new TopoDS_Shape(aShape)); // get plane parameters - double anX = 1, anY = 0, aZ = 0, anOrigin = 0; + boost::shared_ptr aPlane = GeomAlgoAPI_FaceBuilder::plane(aGShape); // set plane parameters to feature - //boost::shared_ptr aData = feature()->data(); - //boost::shared_ptr anAttr = aData->docRef(SKETCH_ATTR_X); - //anAttr->setValue(anX); + boost::shared_ptr aData = feature()->data(); + double anA, aB, aC, aD; + aPlane->coefficients(anA, aB, aC, aD); + + boost::shared_ptr anAttr; + /* + aData->real(SKETCH_ATTR_PLANE_A)->setValue(anA); + aData->real(SKETCH_ATTR_PLANE_B)->setValue(aB); + aData->real(SKETCH_ATTR_PLANE_C)->setValue(aC); + aData->real(SKETCH_ATTR_PLANE_D)->setValue(aD); + */ + // temporary solution for main planes only + boost::shared_ptr anOrigin = + boost::dynamic_pointer_cast(aData->attribute(SKETCH_ATTR_ORIGIN)); + anOrigin->setValue(0, 0, 0); + boost::shared_ptr aNormal = + boost::dynamic_pointer_cast(aData->attribute(SKETCH_ATTR_NORM)); + aNormal->setValue(anA, aB, aC); + boost::shared_ptr aDirX = + boost::dynamic_pointer_cast(aData->attribute(SKETCH_ATTR_DIRX)); + aDirX->setValue(aB, aC, anA); + boost::shared_ptr aDirY = + boost::dynamic_pointer_cast(aData->attribute(SKETCH_ATTR_DIRY)); + aDirY->setValue(aC, anA, aB); + + boost::shared_ptr aDir = aPlane->direction(); + emit viewerProjectionChange(aDir->x(), aDir->y(), aDir->z()); commit(); }