1 // File: PartSet_OperationSketch.h
2 // Created: 20 Apr 2014
3 // Author: Natalia ERMOLAEVA
5 #include <PartSet_OperationSketch.h>
7 #include <SketchPlugin_Sketch.h>
8 #include <ModelAPI_Data.h>
9 #include <ModelAPI_AttributeDouble.h>
10 #include <GeomAlgoAPI_FaceBuilder.h>
12 #include <AIS_Shape.hxx>
13 #include <AIS_ListOfInteractive.hxx>
21 PartSet_OperationSketch::PartSet_OperationSketch(const QString& theId,
23 : PartSet_OperationSketchBase(theId, theParent)
27 PartSet_OperationSketch::~PartSet_OperationSketch()
31 bool PartSet_OperationSketch::isPerformedImmediately() const
36 int PartSet_OperationSketch::getSelectionMode() const
41 void PartSet_OperationSketch::setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList)
43 if (theList.IsEmpty())
47 const TopoDS_Shape& aShape = theList.First();
48 boost::shared_ptr<GeomAPI_Shape> aGShape(new GeomAPI_Shape);
49 aGShape->setImpl(new TopoDS_Shape(aShape));
51 // get plane parameters
52 boost::shared_ptr<GeomAPI_Pln> aPlane = GeomAlgoAPI_FaceBuilder::plane(aGShape);
54 // set plane parameters to feature
55 boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
56 double anA, aB, aC, aD;
57 aPlane->coefficients(anA, aB, aC, aD);
59 boost::shared_ptr<ModelAPI_AttributeDouble> anAttr;
61 aData->real(SKETCH_ATTR_PLANE_A)->setValue(anA);
62 aData->real(SKETCH_ATTR_PLANE_B)->setValue(aB);
63 aData->real(SKETCH_ATTR_PLANE_C)->setValue(aC);
64 aData->real(SKETCH_ATTR_PLANE_D)->setValue(aD);
66 boost::shared_ptr<GeomAPI_Dir> aDir = aPlane->direction();
67 emit viewerProjectionChange(aDir->x(), aDir->y(), aDir->z());