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