1 // File: PartSet_OperationSketchLine.h
2 // Created: 20 Apr 2014
3 // Author: Natalia ERMOLAEVA
5 #include <PartSet_OperationSketchLine.h>
7 #include <SketchPlugin_Feature.h>
8 #include <GeomDataAPI_Point2D.h>
9 #include <ModelAPI_Data.h>
11 #include <SketchPlugin_Line.h>
19 PartSet_OperationSketchLine::PartSet_OperationSketchLine(const QString& theId,
21 boost::shared_ptr<ModelAPI_Feature> theFeature)
22 : PartSet_OperationSketchBase(theId, theParent), mySketch(theFeature),
23 myPointSelectionMode(SM_FirstPoint)
27 PartSet_OperationSketchLine::~PartSet_OperationSketchLine()
31 bool PartSet_OperationSketchLine::isGranted() const
36 int PartSet_OperationSketchLine::getSelectionMode() const
38 return 0;//TopAbs_FACE;
41 void PartSet_OperationSketchLine::setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList,
42 const gp_Pnt& thePoint)
44 if (theList.IsEmpty())
47 switch (myPointSelectionMode)
50 setLinePoint(thePoint, LINE_ATTR_START);
51 myPointSelectionMode = SM_SecondPoint;
54 case SM_SecondPoint: {
55 setLinePoint(thePoint, LINE_ATTR_END);
68 void PartSet_OperationSketchLine::setMouseMovePoint(const gp_Pnt& thePoint)
70 if (myPointSelectionMode == SM_SecondPoint)
71 setLinePoint(thePoint, LINE_ATTR_END);
74 void PartSet_OperationSketchLine::startOperation()
76 PartSet_OperationSketchBase::startOperation();
79 boost::shared_ptr<SketchPlugin_Feature> aFeature =
80 boost::dynamic_pointer_cast<SketchPlugin_Feature>(mySketch);
82 aFeature->addSub(feature());
84 myPointSelectionMode = SM_FirstPoint;
87 void PartSet_OperationSketchLine::stopOperation()
89 PartSet_OperationSketchBase::stopOperation();
91 myPointSelectionMode = SM_None;
94 void PartSet_OperationSketchLine::setLinePoint(const gp_Pnt& thePoint,
95 const std::string& theAttribute)
97 boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
98 boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
99 boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(theAttribute));
100 double aX = thePoint.X(), anY = thePoint.Y();
101 aPoint->setValue(aX, anY);