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 //! Method which clear all selected owners belonging
45 //! to this selectable object ( for fast presentation draw )
46 Standard_EXPORT virtual void ClearSelected();
49 //! Method which draws selected owners ( for fast presentation draw )
50 Standard_EXPORT virtual void HilightSelected(const Handle(PrsMgr_PresentationManager3d)& thePM,
51 const SelectMgr_SequenceOfOwner& theOwners);
53 //! Method which hilight an owner belonging to
54 //! this selectable object ( for fast presentation draw )
55 Standard_EXPORT virtual void HilightOwnerWithColor(const Handle(PrsMgr_PresentationManager3d)& thePM,
56 const Quantity_NameOfColor theColor, const Handle(SelectMgr_EntityOwner)& theOwner);
58 Standard_EXPORT std::shared_ptr<GeomAPI_Ax3> plane() const { return myPlane; }
60 Standard_EXPORT SketchPlugin_Constraint* feature() const { return myConstraint; }
63 Handle(Graphic3d_ArrayOfPoints) pointsArray() const { return myPntArray; }
65 void Render(const Handle(OpenGl_Workspace)& theWorkspace) const;
67 void Release (OpenGl_Context* theContext);
69 DEFINE_STANDARD_RTTI(SketcherPrs_SymbolPrs)
72 /// Redefinition of virtual function
73 Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
74 const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode = 0);
76 /// Redefinition of virtual function
77 Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
78 const Standard_Integer aMode);
80 /// Returns an icon file name. Has to be redefined in successors
81 virtual const char* iconName() const = 0;
83 /// Check and creates if it is necessary myAspect member.
84 /// It has to be called before the object computation
85 virtual void prepareAspect();
87 /// Returns icon corresponded to the current constraint type
88 Handle(Image_AlienPixMap) icon();
90 /// Add a line into the given group
91 /// \param theGroup a group for drawing
92 /// \param theAttrName an attribute name which corresponds to referenced line
93 void addLine(const Handle(Graphic3d_Group)& theGroup, std::string theAttrName) const;
95 /// Redefine this function in order to add additiona lines of constraint base
96 /// \param thePrs a presentation
97 /// \param theColor a color of additiona lines
98 virtual void drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const {}
100 /// Update myPntArray according to presentation positions
101 /// \return true in case of success
102 virtual bool updatePoints(double theStep) const { return true; }
105 /// Constraint feature
106 SketchPlugin_Constraint* myConstraint;
108 /// Plane of the current sketcher
109 std::shared_ptr<GeomAPI_Ax3> myPlane;
111 /// Aspect for entities drawing
112 Handle(Graphic3d_AspectMarker3d) myAspect;
114 /// Array of symbols positions
115 mutable Handle(Graphic3d_ArrayOfPoints) myPntArray;
117 Handle(SelectMgr_EntityOwner) myOwner;
120 /// Static map to collect constraints icons {IconName : IconPixMap}
121 static std::map<const char*, Handle(Image_AlienPixMap)> myIconsMap;
123 mutable Handle(OpenGl_VertexBuffer) myVboAttribs;
125 Select3D_SensitiveEntitySequence mySPoints;