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 = new SketcherPrs_HVDirection(theConstraint, thePlane, true);
68 anAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs));
74 AISObjectPtr SketcherPrs_Factory::verticalConstraint(ModelAPI_Feature* theConstraint,
75 const std::shared_ptr<GeomAPI_Ax3>& thePlane,
76 AISObjectPtr thePrevious)
78 std::shared_ptr<GeomAPI_AISObject> anAISObj;
79 if (SketcherPrs_HVDirection::IsReadyToDisplay(theConstraint, thePlane)) {
80 if (thePrevious.get())
81 anAISObj = thePrevious;
83 anAISObj = AISObjectPtr(new GeomAPI_AISObject());
84 Handle(SketcherPrs_HVDirection) aPrs = new SketcherPrs_HVDirection(theConstraint, thePlane, false);
85 anAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs));
91 AISObjectPtr SketcherPrs_Factory::translateConstraint(ModelAPI_Feature* theConstraint,
92 const std::shared_ptr<GeomAPI_Ax3>& thePlane,
93 AISObjectPtr thePrevious)
95 std::shared_ptr<GeomAPI_AISObject> anAISObj;
96 if (SketcherPrs_Transformation::IsReadyToDisplay(theConstraint, thePlane)) {
97 if (thePrevious.get())
98 anAISObj = thePrevious;
100 anAISObj = AISObjectPtr(new GeomAPI_AISObject());
101 Handle(SketcherPrs_Transformation) aPrs = new SketcherPrs_Transformation(theConstraint, thePlane, true);
102 anAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs));
108 AISObjectPtr SketcherPrs_Factory::rotateConstraint(ModelAPI_Feature* theConstraint,
109 const std::shared_ptr<GeomAPI_Ax3>& thePlane,
110 AISObjectPtr thePrevious)
112 std::shared_ptr<GeomAPI_AISObject> anAISObj;
113 if (SketcherPrs_Transformation::IsReadyToDisplay(theConstraint, thePlane)) {
114 if (thePrevious.get())
115 anAISObj = thePrevious;
117 anAISObj = AISObjectPtr(new GeomAPI_AISObject());
118 Handle(SketcherPrs_Transformation) aPrs = new SketcherPrs_Transformation(theConstraint, thePlane, false);
119 anAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs));