Salome HOME
Bug #1279: Bad display of distance constraint in the sktech
[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 { \
27   std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject()); \
28   Handle(CLASS) aPrs = new CLASS(theConstraint, thePlane); \
29   aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs)); \
30   return aAISObj; \
31 }
32
33 CONSTRAINT_PRS_IMPL(coincidentConstraint, SketcherPrs_Coincident);
34 CONSTRAINT_PRS_IMPL(parallelConstraint, SketcherPrs_Parallel);
35 CONSTRAINT_PRS_IMPL(perpendicularConstraint, SketcherPrs_Perpendicular);
36 CONSTRAINT_PRS_IMPL(rigidConstraint, SketcherPrs_Rigid);
37 CONSTRAINT_PRS_IMPL(equalConstraint, SketcherPrs_Equal);
38 CONSTRAINT_PRS_IMPL(tangentConstraint, SketcherPrs_Tangent);
39 CONSTRAINT_PRS_IMPL(radiusConstraint, SketcherPrs_Radius);
40 CONSTRAINT_PRS_IMPL(lengthDimensionConstraint, SketcherPrs_LengthDimension);
41 CONSTRAINT_PRS_IMPL(mirrorConstraint, SketcherPrs_Mirror);
42 CONSTRAINT_PRS_IMPL(angleConstraint, SketcherPrs_Angle);
43
44 // Non-standard constraints definition
45 AISObjectPtr SketcherPrs_Factory::horisontalConstraint(ModelAPI_Feature* theConstraint,
46                                        const std::shared_ptr<GeomAPI_Ax3>& thePlane)
47
48   std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject()); 
49   Handle(SketcherPrs_HVDirection) aPrs = new SketcherPrs_HVDirection(theConstraint, thePlane, true); 
50   aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs)); 
51   return aAISObj; 
52 }
53
54 AISObjectPtr SketcherPrs_Factory::verticalConstraint(ModelAPI_Feature* theConstraint,
55                                        const std::shared_ptr<GeomAPI_Ax3>& thePlane)
56
57   std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject()); 
58   Handle(SketcherPrs_HVDirection) aPrs = new SketcherPrs_HVDirection(theConstraint, thePlane, false); 
59   aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs)); 
60   return aAISObj; 
61 }
62
63 AISObjectPtr SketcherPrs_Factory::translateConstraint(ModelAPI_Feature* theConstraint,
64                                        const std::shared_ptr<GeomAPI_Ax3>& thePlane)
65
66   std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject()); 
67   Handle(SketcherPrs_Transformation) aPrs = new SketcherPrs_Transformation(theConstraint, thePlane, true); 
68   aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs)); 
69   return aAISObj; 
70 }
71
72 AISObjectPtr SketcherPrs_Factory::rotateConstraint(ModelAPI_Feature* theConstraint,
73                                        const std::shared_ptr<GeomAPI_Ax3>& thePlane)
74
75   std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject()); 
76   Handle(SketcherPrs_Transformation) aPrs = new SketcherPrs_Transformation(theConstraint, thePlane, false); 
77   aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs)); 
78   return aAISObj; 
79 }