Salome HOME
PositionMgr improvement
[modules/shaper.git] / src / SketcherPrs / SketcherPrs_SymbolPrs.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        SketcherPrs_SymbolPrs.h
4 // Created:     12 March 2015
5 // Author:      Vitaly SMETANNIKOV
6
7 #ifndef SketcherPrs_SymbolPrs_H
8 #define SketcherPrs_SymbolPrs_H
9
10 #include <AIS_InteractiveObject.hxx>
11 #include <GeomAPI_Ax3.h>
12 #include <Graphic3d_ArrayOfPoints.hxx>
13 #include <Graphic3d_AspectMarker3d.hxx>
14 #include <Image_AlienPixMap.hxx>
15
16 #include <Standard_DefineHandle.hxx>
17 #include <map>
18
19 class SketchPlugin_Constraint;
20
21
22 DEFINE_STANDARD_HANDLE(SketcherPrs_SymbolPrs, AIS_InteractiveObject)
23
24 /**
25 * \ingroup GUI
26 * A base class of constraint presentation which is represented by an icon
27 */
28 class SketcherPrs_SymbolPrs: public AIS_InteractiveObject
29 {
30 public:
31   /// Constructor
32   /// \param theConstraint a constraint feature
33   /// \param thePlane a coordinate plane of current sketch
34   Standard_EXPORT SketcherPrs_SymbolPrs(SketchPlugin_Constraint* theConstraint, 
35                         const std::shared_ptr<GeomAPI_Ax3>& thePlane);
36   
37   //! Method which clear all selected owners belonging
38   //! to this selectable object ( for fast presentation draw )
39   Standard_EXPORT virtual void ClearSelected();
40
41
42   //! Method which draws selected owners ( for fast presentation draw )
43   Standard_EXPORT virtual void HilightSelected(const Handle(PrsMgr_PresentationManager3d)& thePM, 
44                                                const SelectMgr_SequenceOfOwner& theOwners);
45   
46   //! Method which hilight an owner belonging to
47   //! this selectable object  ( for fast presentation draw )
48   Standard_EXPORT virtual void HilightOwnerWithColor(const Handle(PrsMgr_PresentationManager3d)& thePM, 
49                                                      const Quantity_NameOfColor theColor, const Handle(SelectMgr_EntityOwner)& theOwner);
50
51   Standard_EXPORT std::shared_ptr<GeomAPI_Ax3> plane() const { return myPlane; }
52
53   Standard_EXPORT SketchPlugin_Constraint* feature() const { return myConstraint; }
54
55   DEFINE_STANDARD_RTTI(SketcherPrs_SymbolPrs)
56
57 protected:
58
59   /// Redefinition of virtual function
60   Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
61     const Standard_Integer aMode);
62
63   /// Returns an icon file name. Has to be redefined in successors
64   virtual const char* iconName() const = 0;
65
66   /// Check and creates if it is necessary myAspect member.
67   /// It has to be called before the object computation
68   virtual void prepareAspect();
69
70   /// Returns icon corresponded to the current constraint type
71   Handle(Image_AlienPixMap) icon();
72
73   /// Add a line into the given group
74   /// \param theGroup a group for drawing
75   /// \param theAttrName an attribute name which corresponds to referenced line
76   void addLine(const Handle(Graphic3d_Group)& theGroup, std::string theAttrName) const;
77
78   /// Redefine this function in order to add additiona lines of constraint base
79   /// \param thePrs a presentation
80   /// \param theColor a color of additiona lines
81   virtual void drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const {}
82
83 protected:
84   /// Constraint feature
85   SketchPlugin_Constraint* myConstraint;
86
87   /// Plane of the current sketcher
88   std::shared_ptr<GeomAPI_Ax3> myPlane;
89
90   /// Aspect for entities drawing
91   Handle(Graphic3d_AspectMarker3d) myAspect;
92
93   /// Array of symbols positions
94   Handle(Graphic3d_ArrayOfPoints) myPntArray;
95
96 private: 
97   /// Static map to collect constraints icons {IconName : IconPixMap}
98   static std::map<const char*, Handle(Image_AlienPixMap)> myIconsMap;
99
100 };
101
102 #endif