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_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"
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) \
28 std::shared_ptr<GeomAPI_AISObject> anAISObj; \
29 if (CLASS::IsReadyToDisplay(theConstraint, thePlane)) { \
30 if (thePrevious.get()) \
31 anAISObj = thePrevious; \
33 anAISObj = AISObjectPtr(new GeomAPI_AISObject()); \
34 Handle(CLASS) aPrs = new CLASS(theConstraint, thePlane); \
35 anAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs)); \
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);
52 // Non-standard constraints definition
53 AISObjectPtr SketcherPrs_Factory::horisontalConstraint(ModelAPI_Feature* theConstraint,
54 const std::shared_ptr<GeomAPI_Ax3>& thePlane,
55 AISObjectPtr thePrevious)
57 std::shared_ptr<GeomAPI_AISObject> anAISObj;
58 if (SketcherPrs_HVDirection::IsReadyToDisplay(theConstraint, thePlane)) {
59 if (thePrevious.get())
60 anAISObj = thePrevious;
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));
70 AISObjectPtr SketcherPrs_Factory::verticalConstraint(ModelAPI_Feature* theConstraint,
71 const std::shared_ptr<GeomAPI_Ax3>& thePlane,
72 AISObjectPtr thePrevious)
74 std::shared_ptr<GeomAPI_AISObject> anAISObj;
75 if (SketcherPrs_HVDirection::IsReadyToDisplay(theConstraint, thePlane)) {
76 if (thePrevious.get())
77 anAISObj = thePrevious;
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));
87 AISObjectPtr SketcherPrs_Factory::translateConstraint(ModelAPI_Feature* theConstraint,
88 const std::shared_ptr<GeomAPI_Ax3>& thePlane,
89 AISObjectPtr thePrevious)
91 std::shared_ptr<GeomAPI_AISObject> anAISObj;
92 if (SketcherPrs_Transformation::IsReadyToDisplay(theConstraint, thePlane)) {
93 if (thePrevious.get())
94 anAISObj = thePrevious;
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));
104 AISObjectPtr SketcherPrs_Factory::rotateConstraint(ModelAPI_Feature* theConstraint,
105 const std::shared_ptr<GeomAPI_Ax3>& thePlane,
106 AISObjectPtr thePrevious)
108 std::shared_ptr<GeomAPI_AISObject> anAISObj;
109 if (SketcherPrs_Transformation::IsReadyToDisplay(theConstraint, thePlane)) {
110 if (thePrevious.get())
111 anAISObj = thePrevious;
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));