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"
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>
20 #include <Standard_DefineHandle.hxx>
23 #include <OpenGl_Workspace.hxx>
25 class SketchPlugin_Constraint;
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(SketchPlugin_Constraint* 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 Standard_EXPORT std::shared_ptr<GeomAPI_Ax3> plane() const { return myPlane; }
62 Standard_EXPORT SketchPlugin_Constraint* feature() const { return myConstraint; }
65 Handle(Graphic3d_ArrayOfPoints) pointsArray() const { return myPntArray; }
67 void Render(const Handle(OpenGl_Workspace)& theWorkspace) const;
69 void Release (OpenGl_Context* theContext);
71 DEFINE_STANDARD_RTTI(SketcherPrs_SymbolPrs)
74 /// Redefinition of virtual function
75 Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
76 const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode = 0);
78 /// Redefinition of virtual function
79 Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
80 const Standard_Integer aMode);
82 /// Returns an icon file name. Has to be redefined in successors
83 virtual const char* iconName() const = 0;
85 /// Check and creates if it is necessary myAspect member.
86 /// It has to be called before the object computation
87 virtual void prepareAspect();
89 /// Returns icon corresponded to the current constraint type
90 Handle(Image_AlienPixMap) icon();
92 /// Add a line into the given group
93 /// \param theGroup a group for drawing
94 /// \param theAttrName an attribute name which corresponds to referenced line
95 void addLine(const Handle(Graphic3d_Group)& theGroup, std::string theAttrName) const;
97 /// Redefine this function in order to add additiona lines of constraint base
98 /// \param thePrs a presentation
99 /// \param theColor a color of additiona lines
100 virtual void drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const {}
102 /// Update myPntArray according to presentation positions
103 /// \return true in case of success
104 virtual bool updatePoints(double theStep) const { return true; }
107 /// Constraint feature
108 SketchPlugin_Constraint* myConstraint;
110 /// Plane of the current sketcher
111 std::shared_ptr<GeomAPI_Ax3> myPlane;
113 /// Aspect for entities drawing
114 Handle(Graphic3d_AspectMarker3d) myAspect;
116 /// Array of symbols positions
117 mutable Handle(Graphic3d_ArrayOfPoints) myPntArray;
119 Handle(SelectMgr_EntityOwner) myOwner;
122 /// Static map to collect constraints icons {IconName : IconPixMap}
123 static std::map<const char*, Handle(Image_AlienPixMap)> myIconsMap;
125 mutable Handle(OpenGl_VertexBuffer) myVboAttribs;
127 Select3D_SensitiveEntitySequence mySPoints;