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>
12 #include <ModelAPI_AttributeRefList.h>
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_SensitiveEntitySequence.hxx>
22 #include <Standard_DefineHandle.hxx>
25 #include <OpenGl_Workspace.hxx>
30 DEFINE_STANDARD_HANDLE(SketcherPrs_SymbolPrs, AIS_InteractiveObject)
34 * A base class of constraint presentation which is represented by an icon
36 class SketcherPrs_SymbolPrs: public AIS_InteractiveObject
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);
45 virtual ~SketcherPrs_SymbolPrs();
47 //! Method which clear all selected owners belonging
48 //! to this selectable object ( for fast presentation draw )
49 Standard_EXPORT virtual void ClearSelected();
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);
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);
61 /// Returns sketcher plane
62 Standard_EXPORT std::shared_ptr<GeomAPI_Ax3> plane() const { return myPlane; }
64 /// Returns feature object
65 Standard_EXPORT ModelAPI_Feature* feature() const { return myConstraint; }
67 /// Return array of points where symbols will be placed
68 Handle(Graphic3d_ArrayOfPoints) pointsArray() const { return myPntArray; }
70 /// Render of the presentation
71 /// \param theWorkspace is OpenGl workspace
72 void Render(const Handle(OpenGl_Workspace)& theWorkspace) const;
74 /// Release used OpenGl resources
75 /// \param theContext is an OpenGL context
76 void Release (OpenGl_Context* theContext);
78 DEFINE_STANDARD_RTTI(SketcherPrs_SymbolPrs)
81 /// Redefinition of virtual function
82 Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
83 const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode = 0);
85 /// Redefinition of virtual function
86 Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
87 const Standard_Integer aMode);
89 /// Returns an icon file name. Has to be redefined in successors
90 virtual const char* iconName() const = 0;
92 /// Check and creates if it is necessary myAspect member.
93 /// It has to be called before the object computation
94 virtual void prepareAspect();
96 /// Returns icon corresponded to the current constraint type
97 Handle(Image_AlienPixMap) icon();
99 /// Add a line into the given group
100 /// \param theGroup a group for drawing
101 /// \param theAttrName an attribute name which corresponds to referenced line
102 void addLine(const Handle(Graphic3d_Group)& theGroup, std::string theAttrName) const;
104 /// Redefine this function in order to add additiona lines of constraint base
105 /// \param thePrs a presentation
106 /// \param theColor a color of additiona lines
107 virtual void drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const {}
109 /// Update myPntArray according to presentation positions
110 /// \return true in case of success
111 virtual bool updatePoints(double theStep) const { return true; }
113 /// Draw a shape into the given presentation scene
114 /// \param theShape the shape to draw
115 /// \param thePrs the presentation scene
116 void drawShape(const std::shared_ptr<GeomAPI_Shape>& theShape,
117 const Handle(Prs3d_Presentation)& thePrs) const;
119 /// Draw a list of shapes stored in a RefListAttribute
120 /// \param theListAttr the attribute of reference3s list
121 /// \param thePrs the presentation scene
122 void drawListOfShapes(const std::shared_ptr<ModelAPI_AttributeRefList>& theListAttr,
123 const Handle(Prs3d_Presentation)& thePrs) const;
126 /// Constraint feature
127 ModelAPI_Feature* myConstraint;
129 /// Plane of the current sketcher
130 std::shared_ptr<GeomAPI_Ax3> myPlane;
132 /// Aspect for entities drawing
133 Handle(Graphic3d_AspectMarker3d) myAspect;
135 /// Array of symbols positions
136 mutable Handle(Graphic3d_ArrayOfPoints) myPntArray;
138 /// An owner object of the presentation
139 Handle(SelectMgr_EntityOwner) myOwner;
142 /// Static map to collect constraints icons {IconName : IconPixMap}
143 static std::map<const char*, Handle(Image_AlienPixMap)> myIconsMap;
145 mutable Handle(OpenGl_VertexBuffer) myVboAttribs;
147 Select3D_SensitiveEntitySequence mySPoints;