]> SALOME platform Git repositories - modules/shaper.git/blob - src/SketcherPrs/SketcherPrs_Factory.cpp
Salome HOME
Remove extra files
[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_Collinear.h"
11 #include "SketcherPrs_Parallel.h"
12 #include "SketcherPrs_Perpendicular.h"
13 #include "SketcherPrs_Rigid.h"
14 #include "SketcherPrs_HVDirection.h"
15 #include "SketcherPrs_Equal.h"
16 #include "SketcherPrs_Tangent.h"
17 #include "SketcherPrs_Radius.h"
18 #include "SketcherPrs_LengthDimension.h"
19 #include "SketcherPrs_Middle.h"
20 #include "SketcherPrs_Mirror.h"
21 #include "SketcherPrs_Transformation.h"
22 #include "SketcherPrs_Angle.h"
23
24 // Macros for constraint presentation definition
25 #define CONSTRAINT_PRS_IMPL(NAME, CLASS) \
26 AISObjectPtr SketcherPrs_Factory::NAME(ModelAPI_Feature* theConstraint, \
27                                        const std::shared_ptr<GeomAPI_Ax3>& thePlane, \
28                                        AISObjectPtr thePrevious) \
29 { \
30   std::shared_ptr<GeomAPI_AISObject> anAISObj; \
31   if (CLASS::IsReadyToDisplay(theConstraint, thePlane)) { \
32     if (thePrevious.get()) \
33       anAISObj = thePrevious; \
34     else { \
35       anAISObj = AISObjectPtr(new GeomAPI_AISObject()); \
36       Handle(CLASS) aPrs = new CLASS(theConstraint, thePlane); \
37       anAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs)); \
38     } \
39   } \
40   return anAISObj; \
41 }
42
43 CONSTRAINT_PRS_IMPL(coincidentConstraint, SketcherPrs_Coincident);
44 CONSTRAINT_PRS_IMPL(collinearConstraint, SketcherPrs_Collinear);
45 CONSTRAINT_PRS_IMPL(parallelConstraint, SketcherPrs_Parallel);
46 CONSTRAINT_PRS_IMPL(perpendicularConstraint, SketcherPrs_Perpendicular);
47 CONSTRAINT_PRS_IMPL(rigidConstraint, SketcherPrs_Rigid);
48 CONSTRAINT_PRS_IMPL(equalConstraint, SketcherPrs_Equal);
49 CONSTRAINT_PRS_IMPL(tangentConstraint, SketcherPrs_Tangent);
50 CONSTRAINT_PRS_IMPL(radiusConstraint, SketcherPrs_Radius);
51 CONSTRAINT_PRS_IMPL(lengthDimensionConstraint, SketcherPrs_LengthDimension);
52 CONSTRAINT_PRS_IMPL(middleConstraint, SketcherPrs_Middle);
53 CONSTRAINT_PRS_IMPL(mirrorConstraint, SketcherPrs_Mirror);
54 CONSTRAINT_PRS_IMPL(angleConstraint, SketcherPrs_Angle);
55
56 // Non-standard constraints definition
57 AISObjectPtr SketcherPrs_Factory::horisontalConstraint(ModelAPI_Feature* theConstraint,
58                                        const std::shared_ptr<GeomAPI_Ax3>& thePlane,
59                                        AISObjectPtr thePrevious)
60 {
61   std::shared_ptr<GeomAPI_AISObject> anAISObj;
62   if (SketcherPrs_HVDirection::IsReadyToDisplay(theConstraint, thePlane)) {
63     if (thePrevious.get())
64       anAISObj = thePrevious;
65     else {
66       anAISObj = AISObjectPtr(new GeomAPI_AISObject());
67       Handle(SketcherPrs_HVDirection) aPrs = 
68         new SketcherPrs_HVDirection(theConstraint, thePlane, true);
69       anAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs));
70     }
71   }
72   return anAISObj;
73 }
74
75 AISObjectPtr SketcherPrs_Factory::verticalConstraint(ModelAPI_Feature* theConstraint,
76                                        const std::shared_ptr<GeomAPI_Ax3>& thePlane,
77                                        AISObjectPtr thePrevious)
78
79   std::shared_ptr<GeomAPI_AISObject> anAISObj;
80   if (SketcherPrs_HVDirection::IsReadyToDisplay(theConstraint, thePlane)) {
81     if (thePrevious.get())
82       anAISObj = thePrevious;
83     else {
84       anAISObj = AISObjectPtr(new GeomAPI_AISObject());
85       Handle(SketcherPrs_HVDirection) aPrs = 
86         new SketcherPrs_HVDirection(theConstraint, thePlane, false);
87       anAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs));
88     }
89   }
90   return anAISObj;
91 }
92
93 AISObjectPtr SketcherPrs_Factory::translateConstraint(ModelAPI_Feature* theConstraint,
94                                        const std::shared_ptr<GeomAPI_Ax3>& thePlane,
95                                        AISObjectPtr thePrevious)
96
97   std::shared_ptr<GeomAPI_AISObject> anAISObj;
98   if (SketcherPrs_Transformation::IsReadyToDisplay(theConstraint, thePlane)) {
99     if (thePrevious.get())
100       anAISObj = thePrevious;
101     else {
102       anAISObj = AISObjectPtr(new GeomAPI_AISObject());
103       Handle(SketcherPrs_Transformation) aPrs = 
104         new SketcherPrs_Transformation(theConstraint, thePlane, true); 
105       anAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs));
106     }
107   }
108   return anAISObj;
109 }
110
111 AISObjectPtr SketcherPrs_Factory::rotateConstraint(ModelAPI_Feature* theConstraint,
112                                        const std::shared_ptr<GeomAPI_Ax3>& thePlane,
113                                        AISObjectPtr thePrevious)
114
115   std::shared_ptr<GeomAPI_AISObject> anAISObj;
116   if (SketcherPrs_Transformation::IsReadyToDisplay(theConstraint, thePlane)) {
117     if (thePrevious.get())
118       anAISObj = thePrevious;
119     else {
120       anAISObj = AISObjectPtr(new GeomAPI_AISObject());
121       Handle(SketcherPrs_Transformation) aPrs = 
122         new SketcherPrs_Transformation(theConstraint, thePlane, false); 
123       anAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs));
124     }
125   }
126   return anAISObj;
127 }