1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: SketcherPrs_Factory.cpp
4 // Created: 13 February 2015
5 // Author: Vitaly SMETANNIKOV
7 #include "SketcherPrs_Factory.h"
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"
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) \
30 std::shared_ptr<GeomAPI_AISObject> anAISObj; \
31 if (CLASS::IsReadyToDisplay(theConstraint, thePlane)) { \
32 if (thePrevious.get()) \
33 anAISObj = thePrevious; \
35 anAISObj = AISObjectPtr(new GeomAPI_AISObject()); \
36 Handle(CLASS) aPrs = new CLASS(theConstraint, thePlane); \
37 anAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs)); \
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);
56 // Non-standard constraints definition
57 AISObjectPtr SketcherPrs_Factory::horisontalConstraint(ModelAPI_Feature* theConstraint,
58 const std::shared_ptr<GeomAPI_Ax3>& thePlane,
59 AISObjectPtr thePrevious)
61 std::shared_ptr<GeomAPI_AISObject> anAISObj;
62 if (SketcherPrs_HVDirection::IsReadyToDisplay(theConstraint, thePlane)) {
63 if (thePrevious.get())
64 anAISObj = thePrevious;
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));
75 AISObjectPtr SketcherPrs_Factory::verticalConstraint(ModelAPI_Feature* theConstraint,
76 const std::shared_ptr<GeomAPI_Ax3>& thePlane,
77 AISObjectPtr thePrevious)
79 std::shared_ptr<GeomAPI_AISObject> anAISObj;
80 if (SketcherPrs_HVDirection::IsReadyToDisplay(theConstraint, thePlane)) {
81 if (thePrevious.get())
82 anAISObj = thePrevious;
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));
93 AISObjectPtr SketcherPrs_Factory::translateConstraint(ModelAPI_Feature* theConstraint,
94 const std::shared_ptr<GeomAPI_Ax3>& thePlane,
95 AISObjectPtr thePrevious)
97 std::shared_ptr<GeomAPI_AISObject> anAISObj;
98 if (SketcherPrs_Transformation::IsReadyToDisplay(theConstraint, thePlane)) {
99 if (thePrevious.get())
100 anAISObj = thePrevious;
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));
111 AISObjectPtr SketcherPrs_Factory::rotateConstraint(ModelAPI_Feature* theConstraint,
112 const std::shared_ptr<GeomAPI_Ax3>& thePlane,
113 AISObjectPtr thePrevious)
115 std::shared_ptr<GeomAPI_AISObject> anAISObj;
116 if (SketcherPrs_Transformation::IsReadyToDisplay(theConstraint, thePlane)) {
117 if (thePrevious.get())
118 anAISObj = thePrevious;
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));