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 <AIS_InteractiveObject.hxx>
11 #include <GeomAPI_Ax3.h>
12 #include <Graphic3d_ArrayOfPoints.hxx>
13 #include <Graphic3d_AspectMarker3d.hxx>
14 #include <Image_AlienPixMap.hxx>
16 #include <Standard_DefineHandle.hxx>
19 #include <OpenGl_Workspace.hxx>
21 class SketchPlugin_Constraint;
25 DEFINE_STANDARD_HANDLE(SketcherPrs_SymbolPrs, AIS_InteractiveObject)
29 * A base class of constraint presentation which is represented by an icon
31 class SketcherPrs_SymbolPrs: public AIS_InteractiveObject
35 /// \param theConstraint a constraint feature
36 /// \param thePlane a coordinate plane of current sketch
37 Standard_EXPORT SketcherPrs_SymbolPrs(SketchPlugin_Constraint* theConstraint,
38 const std::shared_ptr<GeomAPI_Ax3>& thePlane);
40 //! Method which clear all selected owners belonging
41 //! to this selectable object ( for fast presentation draw )
42 Standard_EXPORT virtual void ClearSelected();
45 //! Method which draws selected owners ( for fast presentation draw )
46 Standard_EXPORT virtual void HilightSelected(const Handle(PrsMgr_PresentationManager3d)& thePM,
47 const SelectMgr_SequenceOfOwner& theOwners);
49 //! Method which hilight an owner belonging to
50 //! this selectable object ( for fast presentation draw )
51 Standard_EXPORT virtual void HilightOwnerWithColor(const Handle(PrsMgr_PresentationManager3d)& thePM,
52 const Quantity_NameOfColor theColor, const Handle(SelectMgr_EntityOwner)& theOwner);
54 Standard_EXPORT std::shared_ptr<GeomAPI_Ax3> plane() const { return myPlane; }
56 Standard_EXPORT SketchPlugin_Constraint* feature() const { return myConstraint; }
59 Handle(Graphic3d_ArrayOfPoints) pointsArray() const { return myPntArray; }
61 void Render(const Handle(OpenGl_Workspace)& theWorkspace) const;
63 void Release (OpenGl_Context* theContext);
65 DEFINE_STANDARD_RTTI(SketcherPrs_SymbolPrs)
68 /// Redefinition of virtual function
69 Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
70 const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode = 0);
72 /// Redefinition of virtual function
73 Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
74 const Standard_Integer aMode);
76 /// Returns an icon file name. Has to be redefined in successors
77 virtual const char* iconName() const = 0;
79 /// Check and creates if it is necessary myAspect member.
80 /// It has to be called before the object computation
81 virtual void prepareAspect();
83 /// Returns icon corresponded to the current constraint type
84 Handle(Image_AlienPixMap) icon();
86 /// Add a line into the given group
87 /// \param theGroup a group for drawing
88 /// \param theAttrName an attribute name which corresponds to referenced line
89 void addLine(const Handle(Graphic3d_Group)& theGroup, std::string theAttrName) const;
91 /// Redefine this function in order to add additiona lines of constraint base
92 /// \param thePrs a presentation
93 /// \param theColor a color of additiona lines
94 virtual void drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const {}
96 /// Update myPntArray according to presentation positions
97 /// \return true in case of success
98 virtual bool updatePoints(double theStep) const { return true; }
101 /// Constraint feature
102 SketchPlugin_Constraint* myConstraint;
104 /// Plane of the current sketcher
105 std::shared_ptr<GeomAPI_Ax3> myPlane;
107 /// Aspect for entities drawing
108 Handle(Graphic3d_AspectMarker3d) myAspect;
110 /// Array of symbols positions
111 mutable Handle(Graphic3d_ArrayOfPoints) myPntArray;
114 /// Static map to collect constraints icons {IconName : IconPixMap}
115 static std::map<const char*, Handle(Image_AlienPixMap)> myIconsMap;
117 mutable Handle(OpenGl_VertexBuffer) myVboAttribs;