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