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