]> SALOME platform Git repositories - modules/shaper.git/blob - src/SketcherPrs/SketcherPrs_SymbolPrs.h
Salome HOME
Update documentation
[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 #include <ModelAPI_Feature.h>
12
13 #include <AIS_InteractiveObject.hxx>
14 #include <GeomAPI_Ax3.h>
15 #include <Graphic3d_ArrayOfPoints.hxx>
16 #include <Graphic3d_AspectMarker3d.hxx>
17 #include <Image_AlienPixMap.hxx>
18 #include <SelectMgr_EntityOwner.hxx>
19 #include <Select3D_SensitiveEntitySequence.hxx>
20
21 #include <Standard_DefineHandle.hxx>
22 #include <map>
23
24 #include <OpenGl_Workspace.hxx>
25
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(ModelAPI_Feature* theConstraint, 
42                         const std::shared_ptr<GeomAPI_Ax3>& thePlane);
43   
44   virtual ~SketcherPrs_SymbolPrs();
45
46   //! Method which clear all selected owners belonging
47   //! to this selectable object ( for fast presentation draw )
48   Standard_EXPORT virtual void ClearSelected();
49
50
51   //! Method which draws selected owners ( for fast presentation draw )
52   Standard_EXPORT virtual void HilightSelected(const Handle(PrsMgr_PresentationManager3d)& thePM, 
53                                                const SelectMgr_SequenceOfOwner& theOwners);
54   
55   //! Method which hilight an owner belonging to
56   //! this selectable object  ( for fast presentation draw )
57   Standard_EXPORT virtual void HilightOwnerWithColor(const Handle(PrsMgr_PresentationManager3d)& thePM, 
58                                                      const Quantity_NameOfColor theColor, const Handle(SelectMgr_EntityOwner)& theOwner);
59
60   /// Returns sketcher plane
61   Standard_EXPORT std::shared_ptr<GeomAPI_Ax3> plane() const { return myPlane; }
62
63   /// Returns feature object
64   Standard_EXPORT ModelAPI_Feature* feature() const { return myConstraint; }
65
66   /// Return array of points where symbols will be placed
67   Handle(Graphic3d_ArrayOfPoints) pointsArray() const { return myPntArray; }
68
69   /// Render of the presentation
70   /// \param theWorkspace is OpenGl workspace
71   void Render(const Handle(OpenGl_Workspace)& theWorkspace) const;
72
73   /// Release used OpenGl resources
74   /// \param theContext is an OpenGL context
75   void Release (OpenGl_Context* theContext);
76
77   DEFINE_STANDARD_RTTI(SketcherPrs_SymbolPrs)
78
79 protected:
80   /// Redefinition of virtual function
81   Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
82     const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode = 0);
83
84   /// Redefinition of virtual function
85   Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
86     const Standard_Integer aMode);
87
88   /// Returns an icon file name. Has to be redefined in successors
89   virtual const char* iconName() const = 0;
90
91   /// Check and creates if it is necessary myAspect member.
92   /// It has to be called before the object computation
93   virtual void prepareAspect();
94
95   /// Returns icon corresponded to the current constraint type
96   Handle(Image_AlienPixMap) icon();
97
98   /// Add a line into the given group
99   /// \param theGroup a group for drawing
100   /// \param theAttrName an attribute name which corresponds to referenced line
101   void addLine(const Handle(Graphic3d_Group)& theGroup, std::string theAttrName) const;
102
103   /// Redefine this function in order to add additiona lines of constraint base
104   /// \param thePrs a presentation
105   /// \param theColor a color of additiona lines
106   virtual void drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const {}
107
108   /// Update myPntArray according to presentation positions
109   /// \return true in case of success
110   virtual bool updatePoints(double theStep) const { return true; }
111
112   /// Draw a shape into the given presentation scene
113   /// \param theShape the shape to draw
114   /// \param thePrs the presentation scene
115   void drawShape(const std::shared_ptr<GeomAPI_Shape>& theShape, 
116     const Handle(Prs3d_Presentation)& thePrs) const;
117
118
119 protected:
120   /// Constraint feature
121   ModelAPI_Feature* myConstraint;
122
123   /// Plane of the current sketcher
124   std::shared_ptr<GeomAPI_Ax3> myPlane;
125
126   /// Aspect for entities drawing
127   Handle(Graphic3d_AspectMarker3d) myAspect;
128
129   /// Array of symbols positions
130   mutable Handle(Graphic3d_ArrayOfPoints) myPntArray;
131
132   /// An owner object of the presentation
133   Handle(SelectMgr_EntityOwner) myOwner;
134
135 private: 
136   /// Static map to collect constraints icons {IconName : IconPixMap}
137   static std::map<const char*, Handle(Image_AlienPixMap)> myIconsMap;
138
139   mutable Handle(OpenGl_VertexBuffer) myVboAttribs;
140
141   Select3D_SensitiveEntitySequence mySPoints;
142 };
143
144 #endif