Salome HOME
Move MakeBrick*.py to examples module for availability for testing.
[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 #include "SketcherPrs_Angle.h"
21
22 #define CONSTRAINT_PRS_IMPL(NAME, CLASS) \
23 AISObjectPtr SketcherPrs_Factory::NAME(ModelAPI_Feature* theConstraint, \
24                                        const std::shared_ptr<GeomAPI_Ax3>& thePlane) \
25 { \
26   std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject()); \
27   Handle(CLASS) aPrs = new CLASS(theConstraint, thePlane); \
28   aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs)); \
29   return aAISObj; \
30 }
31
32 CONSTRAINT_PRS_IMPL(coincidentConstraint, SketcherPrs_Coincident);
33 CONSTRAINT_PRS_IMPL(parallelConstraint, SketcherPrs_Parallel);
34 CONSTRAINT_PRS_IMPL(perpendicularConstraint, SketcherPrs_Perpendicular);
35 CONSTRAINT_PRS_IMPL(rigidConstraint, SketcherPrs_Rigid);
36 CONSTRAINT_PRS_IMPL(equalConstraint, SketcherPrs_Equal);
37 CONSTRAINT_PRS_IMPL(tangentConstraint, SketcherPrs_Tangent);
38 CONSTRAINT_PRS_IMPL(radiusConstraint, SketcherPrs_Radius);
39 CONSTRAINT_PRS_IMPL(lengthDimensionConstraint, SketcherPrs_LengthDimension);
40 CONSTRAINT_PRS_IMPL(mirrorConstraint, SketcherPrs_Mirror);
41 CONSTRAINT_PRS_IMPL(angleConstraint, SketcherPrs_Angle);
42
43
44 AISObjectPtr SketcherPrs_Factory::horisontalConstraint(ModelAPI_Feature* theConstraint,
45                                        const std::shared_ptr<GeomAPI_Ax3>& thePlane)
46
47   std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject()); 
48   Handle(SketcherPrs_HVDirection) aPrs = new SketcherPrs_HVDirection(theConstraint, thePlane, true); 
49   aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs)); 
50   return aAISObj; 
51 }
52
53 AISObjectPtr SketcherPrs_Factory::verticalConstraint(ModelAPI_Feature* theConstraint,
54                                        const std::shared_ptr<GeomAPI_Ax3>& thePlane)
55
56   std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject()); 
57   Handle(SketcherPrs_HVDirection) aPrs = new SketcherPrs_HVDirection(theConstraint, thePlane, false); 
58   aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs)); 
59   return aAISObj; 
60 }
61
62 AISObjectPtr SketcherPrs_Factory::translateConstraint(ModelAPI_Feature* theConstraint,
63                                        const std::shared_ptr<GeomAPI_Ax3>& thePlane)
64
65   std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject()); 
66   Handle(SketcherPrs_Transformation) aPrs = new SketcherPrs_Transformation(theConstraint, thePlane, true); 
67   aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs)); 
68   return aAISObj; 
69 }
70
71 AISObjectPtr SketcherPrs_Factory::rotateConstraint(ModelAPI_Feature* theConstraint,
72                                        const std::shared_ptr<GeomAPI_Ax3>& thePlane)
73
74   std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject()); 
75   Handle(SketcherPrs_Transformation) aPrs = new SketcherPrs_Transformation(theConstraint, thePlane, false); 
76   aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs)); 
77   return aAISObj; 
78 }