1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: SketcherPrs_SymbolPrs.h
4 // Created: 12 March 2015
5 // Author: Vitaly SMETANNIKOV
7 #ifndef SketcherPrs_SymbolPrs_H
8 #define SketcherPrs_SymbolPrs_H
10 #include "SketcherPrs_SensitivePoint.h"
11 #include <ModelAPI_Feature.h>
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>
21 #include <Standard_DefineHandle.hxx>
24 #include <OpenGl_Workspace.hxx>
29 DEFINE_STANDARD_HANDLE(SketcherPrs_SymbolPrs, AIS_InteractiveObject)
33 * A base class of constraint presentation which is represented by an icon
35 class SketcherPrs_SymbolPrs: public AIS_InteractiveObject
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);
44 virtual ~SketcherPrs_SymbolPrs();
46 //! Method which clear all selected owners belonging
47 //! to this selectable object ( for fast presentation draw )
48 Standard_EXPORT virtual void ClearSelected();
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);
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);
60 /// Returns sketcher plane
61 Standard_EXPORT std::shared_ptr<GeomAPI_Ax3> plane() const { return myPlane; }
63 /// Returns feature object
64 Standard_EXPORT ModelAPI_Feature* feature() const { return myConstraint; }
66 /// Return array of points where symbols will be placed
67 Handle(Graphic3d_ArrayOfPoints) pointsArray() const { return myPntArray; }
69 /// Render of the presentation
70 /// \param theWorkspace is OpenGl workspace
71 void Render(const Handle(OpenGl_Workspace)& theWorkspace) const;
73 /// Release used OpenGl resources
74 /// \param theContext is an OpenGL context
75 void Release (OpenGl_Context* theContext);
77 DEFINE_STANDARD_RTTI(SketcherPrs_SymbolPrs)
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);
84 /// Redefinition of virtual function
85 Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
86 const Standard_Integer aMode);
88 /// Returns an icon file name. Has to be redefined in successors
89 virtual const char* iconName() const = 0;
91 /// Check and creates if it is necessary myAspect member.
92 /// It has to be called before the object computation
93 virtual void prepareAspect();
95 /// Returns icon corresponded to the current constraint type
96 Handle(Image_AlienPixMap) icon();
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;
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 {}
108 /// Update myPntArray according to presentation positions
109 /// \return true in case of success
110 virtual bool updatePoints(double theStep) const { return true; }
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;
120 /// Constraint feature
121 ModelAPI_Feature* myConstraint;
123 /// Plane of the current sketcher
124 std::shared_ptr<GeomAPI_Ax3> myPlane;
126 /// Aspect for entities drawing
127 Handle(Graphic3d_AspectMarker3d) myAspect;
129 /// Array of symbols positions
130 mutable Handle(Graphic3d_ArrayOfPoints) myPntArray;
132 /// An owner object of the presentation
133 Handle(SelectMgr_EntityOwner) myOwner;
136 /// Static map to collect constraints icons {IconName : IconPixMap}
137 static std::map<const char*, Handle(Image_AlienPixMap)> myIconsMap;
139 mutable Handle(OpenGl_VertexBuffer) myVboAttribs;
141 Select3D_SensitiveEntitySequence mySPoints;