]> SALOME platform Git repositories - modules/shaper.git/blob - src/SketcherPrs/SketcherPrs_SymbolPrs.h
Salome HOME
7a9c37b032529b8b89e16eab40c65eed85c1f407
[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 #include <OpenGl_Workspace.hxx>
20
21 class SketchPlugin_Constraint;
22 class OpenGl_Context;
23
24
25 DEFINE_STANDARD_HANDLE(SketcherPrs_SymbolPrs, AIS_InteractiveObject)
26
27 /**
28 * \ingroup GUI
29 * A base class of constraint presentation which is represented by an icon
30 */
31 class SketcherPrs_SymbolPrs: public AIS_InteractiveObject
32 {
33 public:
34   /// Constructor
35   /// \param theConstraint a constraint feature
36   /// \param thePlane a coordinate plane of current sketch
37   Standard_EXPORT SketcherPrs_SymbolPrs(SketchPlugin_Constraint* theConstraint, 
38                         const std::shared_ptr<GeomAPI_Ax3>& thePlane);
39   
40   //! Method which clear all selected owners belonging
41   //! to this selectable object ( for fast presentation draw )
42   Standard_EXPORT virtual void ClearSelected();
43
44
45   //! Method which draws selected owners ( for fast presentation draw )
46   Standard_EXPORT virtual void HilightSelected(const Handle(PrsMgr_PresentationManager3d)& thePM, 
47                                                const SelectMgr_SequenceOfOwner& theOwners);
48   
49   //! Method which hilight an owner belonging to
50   //! this selectable object  ( for fast presentation draw )
51   Standard_EXPORT virtual void HilightOwnerWithColor(const Handle(PrsMgr_PresentationManager3d)& thePM, 
52                                                      const Quantity_NameOfColor theColor, const Handle(SelectMgr_EntityOwner)& theOwner);
53
54   Standard_EXPORT std::shared_ptr<GeomAPI_Ax3> plane() const { return myPlane; }
55
56   Standard_EXPORT SketchPlugin_Constraint* feature() const { return myConstraint; }
57
58
59   Handle(Graphic3d_ArrayOfPoints) pointsArray() const { return myPntArray; }
60
61   void Render(const Handle(OpenGl_Workspace)& theWorkspace) const;
62
63   void Release (OpenGl_Context* theContext);
64
65   DEFINE_STANDARD_RTTI(SketcherPrs_SymbolPrs)
66
67 protected:
68   /// Redefinition of virtual function
69   Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
70     const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode = 0);
71
72   /// Redefinition of virtual function
73   Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
74     const Standard_Integer aMode);
75
76   /// Returns an icon file name. Has to be redefined in successors
77   virtual const char* iconName() const = 0;
78
79   /// Check and creates if it is necessary myAspect member.
80   /// It has to be called before the object computation
81   virtual void prepareAspect();
82
83   /// Returns icon corresponded to the current constraint type
84   Handle(Image_AlienPixMap) icon();
85
86   /// Add a line into the given group
87   /// \param theGroup a group for drawing
88   /// \param theAttrName an attribute name which corresponds to referenced line
89   void addLine(const Handle(Graphic3d_Group)& theGroup, std::string theAttrName) const;
90
91   /// Redefine this function in order to add additiona lines of constraint base
92   /// \param thePrs a presentation
93   /// \param theColor a color of additiona lines
94   virtual void drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const {}
95
96   /// Update myPntArray according to presentation positions
97   /// \return true in case of success
98   virtual bool updatePoints(double theStep) const { return true; }
99
100 protected:
101   /// Constraint feature
102   SketchPlugin_Constraint* myConstraint;
103
104   /// Plane of the current sketcher
105   std::shared_ptr<GeomAPI_Ax3> myPlane;
106
107   /// Aspect for entities drawing
108   Handle(Graphic3d_AspectMarker3d) myAspect;
109
110   /// Array of symbols positions
111   mutable Handle(Graphic3d_ArrayOfPoints) myPntArray;
112
113 private: 
114   /// Static map to collect constraints icons {IconName : IconPixMap}
115   static std::map<const char*, Handle(Image_AlienPixMap)> myIconsMap;
116
117   mutable Handle(OpenGl_VertexBuffer) myVboAttribs;
118 };
119
120 #endif