Salome HOME
Implementation of the Angle constraint (issue #788)
[modules/shaper.git] / src / SketcherPrs / SketcherPrs_Factory.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        SketcherPrs_Factory.cpp
4 // Created:     13 February 2015
5 // Author:      Vitaly SMETANNIKOV
6
7 #include "SketcherPrs_Factory.h"
8
9 #include "SketcherPrs_Coincident.h"
10 #include "SketcherPrs_Parallel.h"
11 #include "SketcherPrs_Perpendicular.h"
12 #include "SketcherPrs_Rigid.h"
13 #include "SketcherPrs_HVDirection.h"
14 #include "SketcherPrs_Equal.h"
15 #include "SketcherPrs_Tangent.h"
16 #include "SketcherPrs_Radius.h"
17 #include "SketcherPrs_LengthDimension.h"
18 #include "SketcherPrs_Mirror.h"
19 #include "SketcherPrs_Transformation.h"
20
21 #define CONSTRAINT_PRS_IMPL(NAME, CLASS) \
22 AISObjectPtr SketcherPrs_Factory::NAME(ModelAPI_Feature* theConstraint, \
23                                        const std::shared_ptr<GeomAPI_Ax3>& thePlane) \
24 { \
25   std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject()); \
26   Handle(CLASS) aPrs = new CLASS(theConstraint, thePlane); \
27   aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs)); \
28   return aAISObj; \
29 }
30
31 CONSTRAINT_PRS_IMPL(coincidentConstraint, SketcherPrs_Coincident);
32 CONSTRAINT_PRS_IMPL(parallelConstraint, SketcherPrs_Parallel);
33 CONSTRAINT_PRS_IMPL(perpendicularConstraint, SketcherPrs_Perpendicular);
34 CONSTRAINT_PRS_IMPL(rigidConstraint, SketcherPrs_Rigid);
35 CONSTRAINT_PRS_IMPL(equalConstraint, SketcherPrs_Equal);
36 CONSTRAINT_PRS_IMPL(tangentConstraint, SketcherPrs_Tangent);
37 CONSTRAINT_PRS_IMPL(radiusConstraint, SketcherPrs_Radius);
38 CONSTRAINT_PRS_IMPL(lengthDimensionConstraint, SketcherPrs_LengthDimension);
39 CONSTRAINT_PRS_IMPL(mirrorConstraint, SketcherPrs_Mirror);
40
41
42 AISObjectPtr SketcherPrs_Factory::horisontalConstraint(ModelAPI_Feature* theConstraint,
43                                        const std::shared_ptr<GeomAPI_Ax3>& thePlane)
44
45   std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject()); 
46   Handle(SketcherPrs_HVDirection) aPrs = new SketcherPrs_HVDirection(theConstraint, thePlane, true); 
47   aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs)); 
48   return aAISObj; 
49 }
50
51 AISObjectPtr SketcherPrs_Factory::verticalConstraint(ModelAPI_Feature* theConstraint,
52                                        const std::shared_ptr<GeomAPI_Ax3>& thePlane)
53
54   std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject()); 
55   Handle(SketcherPrs_HVDirection) aPrs = new SketcherPrs_HVDirection(theConstraint, thePlane, false); 
56   aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs)); 
57   return aAISObj; 
58 }
59
60 AISObjectPtr SketcherPrs_Factory::translateConstraint(ModelAPI_Feature* theConstraint,
61                                        const std::shared_ptr<GeomAPI_Ax3>& thePlane)
62
63   std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject()); 
64   Handle(SketcherPrs_Transformation) aPrs = new SketcherPrs_Transformation(theConstraint, thePlane, true); 
65   aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs)); 
66   return aAISObj; 
67 }
68
69 AISObjectPtr SketcherPrs_Factory::rotateConstraint(ModelAPI_Feature* theConstraint,
70                                        const std::shared_ptr<GeomAPI_Ax3>& thePlane)
71
72   std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject()); 
73   Handle(SketcherPrs_Transformation) aPrs = new SketcherPrs_Transformation(theConstraint, thePlane, false); 
74   aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs)); 
75   return aAISObj; 
76 }
77
78 AISObjectPtr SketcherPrs_Factory::angleConstraint(ModelAPI_Feature* theConstraint,
79                                        const std::shared_ptr<GeomAPI_Ax3>& thePlane)
80 {
81   return AISObjectPtr(new GeomAPI_AISObject());
82 }