Salome HOME
Horisontal and vertical constraints added
[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
15 #define CONSTRAINT_PRS_IMPL(NAME, CLASS) \
16 AISObjectPtr SketcherPrs_Factory::NAME(SketchPlugin_Constraint* theConstraint, \
17                                        const std::shared_ptr<GeomAPI_Ax3>& thePlane) \
18 { \
19   std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject()); \
20   Handle(CLASS) aPrs = new CLASS(theConstraint, thePlane); \
21   aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs)); \
22   return aAISObj; \
23 }
24
25 CONSTRAINT_PRS_IMPL(coincidentConstraint, SketcherPrs_Coincident);
26 CONSTRAINT_PRS_IMPL(parallelConstraint, SketcherPrs_Parallel);
27 CONSTRAINT_PRS_IMPL(perpendicularConstraint, SketcherPrs_Perpendicular);
28 CONSTRAINT_PRS_IMPL(rigidConstraint, SketcherPrs_Rigid)
29
30
31 AISObjectPtr SketcherPrs_Factory::horisontalConstraint(SketchPlugin_Constraint* theConstraint,
32                                        const std::shared_ptr<GeomAPI_Ax3>& thePlane)
33
34   std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject()); 
35   Handle(SketcherPrs_HVDirection) aPrs = new SketcherPrs_HVDirection(theConstraint, thePlane, true); 
36   aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs)); 
37   return aAISObj; 
38 }
39
40 AISObjectPtr SketcherPrs_Factory::verticalConstraint(SketchPlugin_Constraint* theConstraint,
41                                        const std::shared_ptr<GeomAPI_Ax3>& thePlane)
42
43   std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject()); 
44   Handle(SketcherPrs_HVDirection) aPrs = new SketcherPrs_HVDirection(theConstraint, thePlane, false); 
45   aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs)); 
46   return aAISObj; 
47 }