1 // Name : SketchAPI_Sketch.cpp
5 // 07/06/16 - Sergey POKHODENKO - Creation of the file
7 //--------------------------------------------------------------------------------------
8 #include "SketchAPI_Sketch.h"
9 //--------------------------------------------------------------------------------------
10 #include <SketchPlugin_Constraint.h>
11 #include <SketchPlugin_ConstraintAngle.h>
12 #include <SketchPlugin_ConstraintCoincidence.h>
13 #include <SketchPlugin_ConstraintCollinear.h>
14 #include <SketchPlugin_ConstraintDistance.h>
15 #include <SketchPlugin_ConstraintEqual.h>
16 #include <SketchPlugin_ConstraintFillet.h>
17 #include <SketchPlugin_ConstraintHorizontal.h>
18 #include <SketchPlugin_ConstraintLength.h>
19 #include <SketchPlugin_ConstraintMiddle.h>
20 #include <SketchPlugin_ConstraintMirror.h>
21 #include <SketchPlugin_ConstraintParallel.h>
22 #include <SketchPlugin_ConstraintPerpendicular.h>
23 #include <SketchPlugin_ConstraintRadius.h>
24 #include <SketchPlugin_ConstraintRigid.h>
25 #include <SketchPlugin_ConstraintTangent.h>
26 #include <SketchPlugin_ConstraintVertical.h>
27 //--------------------------------------------------------------------------------------
28 #include <ModelAPI_CompositeFeature.h>
29 #include <ModelAPI_ResultConstruction.h>
30 #include <ModelHighAPI_RefAttr.h>
31 #include <ModelHighAPI_Selection.h>
32 #include <ModelHighAPI_Tools.h>
33 //--------------------------------------------------------------------------------------
34 #include "SketchAPI_Arc.h"
35 #include "SketchAPI_Circle.h"
36 #include "SketchAPI_IntersectionPoint.h"
37 #include "SketchAPI_Line.h"
38 #include "SketchAPI_Mirror.h"
39 #include "SketchAPI_Point.h"
40 #include "SketchAPI_Projection.h"
41 #include "SketchAPI_Rectangle.h"
42 #include "SketchAPI_Rotation.h"
43 #include "SketchAPI_Translation.h"
44 //--------------------------------------------------------------------------------------
45 SketchAPI_Sketch::SketchAPI_Sketch(
46 const std::shared_ptr<ModelAPI_Feature> & theFeature)
47 : ModelHighAPI_Interface(theFeature)
52 SketchAPI_Sketch::SketchAPI_Sketch(
53 const std::shared_ptr<ModelAPI_Feature> & theFeature,
54 const std::shared_ptr<GeomAPI_Ax3> & thePlane)
55 : ModelHighAPI_Interface(theFeature)
62 SketchAPI_Sketch::SketchAPI_Sketch(
63 const std::shared_ptr<ModelAPI_Feature> & theFeature,
64 const ModelHighAPI_Selection & theExternal)
65 : ModelHighAPI_Interface(theFeature)
68 setExternal(theExternal);
72 SketchAPI_Sketch::~SketchAPI_Sketch()
77 //--------------------------------------------------------------------------------------
78 std::shared_ptr<ModelAPI_CompositeFeature> SketchAPI_Sketch::compositeFeature() const
80 return std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(feature());
83 //--------------------------------------------------------------------------------------
84 void SketchAPI_Sketch::setPlane(const std::shared_ptr<GeomAPI_Ax3> & thePlane)
86 fillAttribute(thePlane->origin(), myorigin);
87 fillAttribute(thePlane->dirX(), mydirX);
88 fillAttribute(thePlane->normal(), mynormal);
93 void SketchAPI_Sketch::setExternal(const ModelHighAPI_Selection & theExternal)
95 fillAttribute(theExternal, myexternal);
100 //--------------------------------------------------------------------------------------
101 void SketchAPI_Sketch::setValue(
102 const std::shared_ptr<ModelAPI_Feature> & theConstraint,
103 const ModelHighAPI_Double & theValue)
105 // TODO(spo): check somehow that the feature is a constraint or eliminate crash if the feature have no real attribute VALUE
106 fillAttribute(theValue, theConstraint->real(SketchPlugin_Constraint::VALUE()));
108 // theConstraint->execute();
111 //--------------------------------------------------------------------------------------
112 std::list<ModelHighAPI_Selection> SketchAPI_Sketch::selectFace() const
114 const_cast<SketchAPI_Sketch*>(this)->execute();
116 std::list<ModelHighAPI_Selection> aSelectionList;
118 ResultConstructionPtr aResultConstruction =
119 std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(feature()->firstResult());
120 if (aResultConstruction.get() == NULL)
121 return aSelectionList;
123 for (int anIndex = 0; anIndex < aResultConstruction->facesNum(); ++anIndex) {
124 aSelectionList.push_back(
125 ModelHighAPI_Selection(aResultConstruction,
126 aResultConstruction->face(anIndex)));
129 return aSelectionList;
132 //--------------------------------------------------------------------------------------
133 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
134 const std::shared_ptr<GeomAPI_Ax3> & thePlane)
136 // TODO(spo): check that thePart is not empty
137 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(SketchAPI_Sketch::ID());
138 return SketchPtr(new SketchAPI_Sketch(aFeature, thePlane));
141 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
142 const ModelHighAPI_Selection & theExternal)
144 // TODO(spo): check that thePart is not empty
145 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(SketchAPI_Sketch::ID());
146 return SketchPtr(new SketchAPI_Sketch(aFeature, theExternal));
149 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
150 const std::string & theExternalName)
152 // TODO(spo): check that thePart is not empty
153 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(SketchAPI_Sketch::ID());
154 return SketchPtr(new SketchAPI_Sketch(aFeature, ModelHighAPI_Selection("FACE", theExternalName)));
157 //--------------------------------------------------------------------------------------
158 std::shared_ptr<SketchAPI_Point> SketchAPI_Sketch::addPoint(
159 double theX, double theY)
161 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Point::ID());
162 return PointPtr(new SketchAPI_Point(aFeature, theX, theY));
164 std::shared_ptr<SketchAPI_Point> SketchAPI_Sketch::addPoint(
165 const std::shared_ptr<GeomAPI_Pnt2d> & thePoint)
167 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Point::ID());
168 return PointPtr(new SketchAPI_Point(aFeature, thePoint));
170 std::shared_ptr<SketchAPI_Point> SketchAPI_Sketch::addPoint(const ModelHighAPI_Selection & theExternal)
172 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Point::ID());
173 return PointPtr(new SketchAPI_Point(aFeature, theExternal));
175 std::shared_ptr<SketchAPI_Point> SketchAPI_Sketch::addPoint(const std::string & theExternalName)
177 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Point::ID());
178 return PointPtr(new SketchAPI_Point(aFeature, theExternalName));
181 //--------------------------------------------------------------------------------------
182 std::shared_ptr<SketchAPI_IntersectionPoint> SketchAPI_Sketch::addIntersectionPoint(
183 const ModelHighAPI_Selection & theExternal)
185 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_IntersectionPoint::ID());
186 return IntersectionPointPtr(new SketchAPI_IntersectionPoint(aFeature, theExternal));
188 std::shared_ptr<SketchAPI_IntersectionPoint> SketchAPI_Sketch::addIntersectionPoint(
189 const std::string & theExternalName)
191 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_IntersectionPoint::ID());
192 return IntersectionPointPtr(new SketchAPI_IntersectionPoint(aFeature, theExternalName));
195 //--------------------------------------------------------------------------------------
196 std::shared_ptr<SketchAPI_Line> SketchAPI_Sketch::addLine(double theX1, double theY1, double theX2, double theY2)
198 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Line::ID());
199 return LinePtr(new SketchAPI_Line(aFeature, theX1, theY1, theX2, theY2));
201 std::shared_ptr<SketchAPI_Line> SketchAPI_Sketch::addLine(
202 const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
203 const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint)
205 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Line::ID());
206 return LinePtr(new SketchAPI_Line(aFeature, theStartPoint, theEndPoint));
208 std::shared_ptr<SketchAPI_Line> SketchAPI_Sketch::addLine(const ModelHighAPI_Selection & theExternal)
210 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Line::ID());
211 return LinePtr(new SketchAPI_Line(aFeature, theExternal));
213 std::shared_ptr<SketchAPI_Line> SketchAPI_Sketch::addLine(const std::string & theExternalName)
215 // TODO(spo): Add constraint SketchConstraintRigid like in PythonAPI. Is it necessary?
216 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Line::ID());
217 return LinePtr(new SketchAPI_Line(aFeature, theExternalName));
220 //--------------------------------------------------------------------------------------
221 std::shared_ptr<SketchAPI_Rectangle> SketchAPI_Sketch::addRectangle(double theX1, double theY1, double theX2, double theY2)
223 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchAPI_Rectangle::ID());
224 return RectanglePtr(new SketchAPI_Rectangle(aFeature, theX1, theY1, theX2, theY2));
226 std::shared_ptr<SketchAPI_Rectangle> SketchAPI_Sketch::addRectangle(
227 const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
228 const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint)
230 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchAPI_Rectangle::ID());
231 return RectanglePtr(new SketchAPI_Rectangle(aFeature, theStartPoint, theEndPoint));
234 //--------------------------------------------------------------------------------------
235 std::shared_ptr<SketchAPI_Circle> SketchAPI_Sketch::addCircle(double theCenterX,
239 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Circle::ID());
240 return CirclePtr(new SketchAPI_Circle(aFeature, theCenterX, theCenterY, theRadius));
243 std::shared_ptr<SketchAPI_Circle> SketchAPI_Sketch::addCircle(const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
246 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Circle::ID());
247 return CirclePtr(new SketchAPI_Circle(aFeature, theCenter, theRadius));
250 std::shared_ptr<SketchAPI_Circle> SketchAPI_Sketch::addCircle(double theX1, double theY1,
251 double theX2, double theY2,
252 double theX3, double theY3)
254 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Circle::ID());
255 return CirclePtr(new SketchAPI_Circle(aFeature, theX1, theY1, theX2, theY2, theX3, theY3));
258 std::shared_ptr<SketchAPI_Circle> SketchAPI_Sketch::addCircle(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
259 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
260 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3)
262 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Circle::ID());
263 return CirclePtr(new SketchAPI_Circle(aFeature, thePoint1, thePoint2, thePoint3));
266 std::shared_ptr<SketchAPI_Circle> SketchAPI_Sketch::addCircle(const ModelHighAPI_Selection & theExternal)
268 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Circle::ID());
269 return CirclePtr(new SketchAPI_Circle(aFeature, theExternal));
272 std::shared_ptr<SketchAPI_Circle> SketchAPI_Sketch::addCircle(const std::string & theExternalName)
274 // TODO(spo): Add constraint SketchConstraintRigid like in PythonAPI. Is it necessary?
275 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Circle::ID());
276 return CirclePtr(new SketchAPI_Circle(aFeature, theExternalName));
279 //--------------------------------------------------------------------------------------
280 std::shared_ptr<SketchAPI_Arc> SketchAPI_Sketch::addArc(double theCenterX, double theCenterY,
281 double theStartX, double theStartY,
282 double theEndX, double theEndY,
285 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Arc::ID());
286 return ArcPtr(new SketchAPI_Arc(aFeature,
287 theCenterX, theCenterY,
288 theStartX, theStartY,
293 std::shared_ptr<SketchAPI_Arc> SketchAPI_Sketch::addArc(const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
294 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
295 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
298 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Arc::ID());
299 return ArcPtr(new SketchAPI_Arc(aFeature, theCenter, theStart, theEnd, theInversed));
302 std::shared_ptr<SketchAPI_Arc> SketchAPI_Sketch::addArc(double theStartX, double theStartY,
303 double theEndX, double theEndY,
304 double thePassedX, double thePassedY)
306 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Arc::ID());
307 return ArcPtr(new SketchAPI_Arc(aFeature,
308 theStartX, theStartY,
310 thePassedX, thePassedY));
313 std::shared_ptr<SketchAPI_Arc> SketchAPI_Sketch::addArc(const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
314 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
315 const std::shared_ptr<GeomAPI_Pnt2d>& thePassed)
317 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Arc::ID());
318 return ArcPtr(new SketchAPI_Arc(aFeature, theStart, theEnd, thePassed));
321 std::shared_ptr<SketchAPI_Arc> SketchAPI_Sketch::addArc(const ModelHighAPI_RefAttr& theTangentPoint,
322 double theEndX, double theEndY,
325 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Arc::ID());
326 return ArcPtr(new SketchAPI_Arc(aFeature, theTangentPoint, theEndX, theEndY, theInversed));
329 std::shared_ptr<SketchAPI_Arc> SketchAPI_Sketch::addArc(const ModelHighAPI_RefAttr& theTangentPoint,
330 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
333 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Arc::ID());
334 return ArcPtr(new SketchAPI_Arc(aFeature, theTangentPoint, theEnd, theInversed));
337 std::shared_ptr<SketchAPI_Arc> SketchAPI_Sketch::addArc(const ModelHighAPI_Selection & theExternal)
339 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Arc::ID());
340 return ArcPtr(new SketchAPI_Arc(aFeature, theExternal));
343 std::shared_ptr<SketchAPI_Arc> SketchAPI_Sketch::addArc(const std::string & theExternalName)
345 // TODO(spo): Add constraint SketchConstraintRigid like in PythonAPI. Is it necessary?
346 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Arc::ID());
347 return ArcPtr(new SketchAPI_Arc(aFeature, theExternalName));
350 //--------------------------------------------------------------------------------------
351 std::shared_ptr<SketchAPI_Projection> SketchAPI_Sketch::addProjection(
352 const ModelHighAPI_Selection & theExternalFeature)
354 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Projection::ID());
355 return ProjectionPtr(new SketchAPI_Projection(aFeature, theExternalFeature));
358 //--------------------------------------------------------------------------------------
359 std::shared_ptr<SketchAPI_Mirror> SketchAPI_Sketch::addMirror(
360 const ModelHighAPI_RefAttr & theMirrorLine,
361 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects)
363 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_ConstraintMirror::ID());
364 return MirrorPtr(new SketchAPI_Mirror(aFeature, theMirrorLine, theObjects));
367 //--------------------------------------------------------------------------------------
368 std::shared_ptr<SketchAPI_Translation> SketchAPI_Sketch::addTranslation(
369 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
370 const ModelHighAPI_RefAttr & thePoint1,
371 const ModelHighAPI_RefAttr & thePoint2,
372 const ModelHighAPI_Integer & theNumberOfObjects,
375 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_MultiTranslation::ID());
376 return TranslationPtr(new SketchAPI_Translation(aFeature, theObjects, thePoint1, thePoint2, theNumberOfObjects, theFullValue));
379 //--------------------------------------------------------------------------------------
380 std::shared_ptr<SketchAPI_Rotation> SketchAPI_Sketch::addRotation(
381 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
382 const ModelHighAPI_RefAttr & theCenter,
383 const ModelHighAPI_Double & theAngle,
384 const ModelHighAPI_Integer & theNumberOfObjects,
387 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_MultiRotation::ID());
388 return RotationPtr(new SketchAPI_Rotation(aFeature, theObjects, theCenter, theAngle, theNumberOfObjects, theFullValue));
391 //--------------------------------------------------------------------------------------
392 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setAngle(
393 const ModelHighAPI_RefAttr & theLine1,
394 const ModelHighAPI_RefAttr & theLine2,
395 const ModelHighAPI_Double & theValue)
397 // TODO(spo): is support of angle type necessary?
398 std::shared_ptr<ModelAPI_Feature> aFeature =
399 compositeFeature()->addFeature(SketchPlugin_ConstraintAngle::ID());
400 fillAttribute(theLine1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
401 fillAttribute(theLine2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
402 fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
407 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setCoincident(
408 const ModelHighAPI_RefAttr & thePoint1,
409 const ModelHighAPI_RefAttr & thePoint2)
411 std::shared_ptr<ModelAPI_Feature> aFeature =
412 compositeFeature()->addFeature(SketchPlugin_ConstraintCoincidence::ID());
413 fillAttribute(thePoint1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
414 fillAttribute(thePoint2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
419 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setCollinear(
420 const ModelHighAPI_RefAttr & theLine1,
421 const ModelHighAPI_RefAttr & theLine2)
423 std::shared_ptr<ModelAPI_Feature> aFeature =
424 compositeFeature()->addFeature(SketchPlugin_ConstraintCollinear::ID());
425 fillAttribute(theLine1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
426 fillAttribute(theLine2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
431 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setDistance(
432 const ModelHighAPI_RefAttr & thePoint,
433 const ModelHighAPI_RefAttr & thePointOrLine,
434 const ModelHighAPI_Double & theValue)
436 std::shared_ptr<ModelAPI_Feature> aFeature =
437 compositeFeature()->addFeature(SketchPlugin_ConstraintDistance::ID());
438 fillAttribute(thePoint, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
439 fillAttribute(thePointOrLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
440 fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
445 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setEqual(
446 const ModelHighAPI_RefAttr & theObject1,
447 const ModelHighAPI_RefAttr & theObject2)
449 std::shared_ptr<ModelAPI_Feature> aFeature =
450 compositeFeature()->addFeature(SketchPlugin_ConstraintEqual::ID());
451 fillAttribute(theObject1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
452 fillAttribute(theObject2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
457 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setFillet(
458 const std::list<ModelHighAPI_RefAttr> & thePoints,
459 const ModelHighAPI_Double & theRadius)
461 std::shared_ptr<ModelAPI_Feature> aFeature =
462 compositeFeature()->addFeature(SketchPlugin_ConstraintFillet::ID());
463 fillAttribute(thePoints, aFeature->data()->refattrlist(SketchPlugin_Constraint::ENTITY_A()));
464 fillAttribute(theRadius, aFeature->real(SketchPlugin_Constraint::VALUE()));
469 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setHorizontal(
470 const ModelHighAPI_RefAttr & theLine)
472 std::shared_ptr<ModelAPI_Feature> aFeature =
473 compositeFeature()->addFeature(SketchPlugin_ConstraintHorizontal::ID());
474 fillAttribute(theLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
479 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setLength(
480 const ModelHighAPI_RefAttr & theLine,
481 const ModelHighAPI_Double & theValue)
483 std::shared_ptr<ModelAPI_Feature> aFeature =
484 compositeFeature()->addFeature(SketchPlugin_ConstraintLength::ID());
485 fillAttribute(theLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
486 fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
491 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setMiddlePoint(
492 const ModelHighAPI_RefAttr & thePoint,
493 const ModelHighAPI_RefAttr & theLine)
495 std::shared_ptr<ModelAPI_Feature> aFeature =
496 compositeFeature()->addFeature(SketchPlugin_ConstraintMiddle::ID());
497 fillAttribute(thePoint, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
498 fillAttribute(theLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
503 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setParallel(
504 const ModelHighAPI_RefAttr & theLine1,
505 const ModelHighAPI_RefAttr & theLine2)
507 std::shared_ptr<ModelAPI_Feature> aFeature =
508 compositeFeature()->addFeature(SketchPlugin_ConstraintParallel::ID());
509 fillAttribute(theLine1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
510 fillAttribute(theLine2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
515 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setPerpendicular(
516 const ModelHighAPI_RefAttr & theLine1,
517 const ModelHighAPI_RefAttr & theLine2)
519 std::shared_ptr<ModelAPI_Feature> aFeature =
520 compositeFeature()->addFeature(SketchPlugin_ConstraintPerpendicular::ID());
521 fillAttribute(theLine1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
522 fillAttribute(theLine2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
527 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setRadius(
528 const ModelHighAPI_RefAttr & theCircleOrArc,
529 const ModelHighAPI_Double & theValue)
531 std::shared_ptr<ModelAPI_Feature> aFeature =
532 compositeFeature()->addFeature(SketchPlugin_ConstraintRadius::ID());
533 fillAttribute(theCircleOrArc, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
534 fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
539 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setRigid(
540 const ModelHighAPI_RefAttr & theObject)
542 // TODO(spo): should it be renamed to Fixed?
543 std::shared_ptr<ModelAPI_Feature> aFeature =
544 compositeFeature()->addFeature(SketchPlugin_ConstraintRigid::ID());
545 fillAttribute(theObject, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
550 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setTangent(
551 const ModelHighAPI_RefAttr & theLine,
552 const ModelHighAPI_RefAttr & theCircle)
554 std::shared_ptr<ModelAPI_Feature> aFeature =
555 compositeFeature()->addFeature(SketchPlugin_ConstraintTangent::ID());
556 fillAttribute(theLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
557 fillAttribute(theCircle, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
562 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setVertical(
563 const ModelHighAPI_RefAttr & theLine)
565 std::shared_ptr<ModelAPI_Feature> aFeature =
566 compositeFeature()->addFeature(SketchPlugin_ConstraintVertical::ID());
567 fillAttribute(theLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
572 //--------------------------------------------------------------------------------------