0027818: Visualization - provide an interface to define highlight presentation properties
[occt.git] / src / StdSelect / StdSelect_BRepOwner.hxx
1 // Created on: 1995-03-08
2 // Created by: Mister rmi
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #ifndef _StdSelect_BRepOwner_HeaderFile
18 #define _StdSelect_BRepOwner_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
22
23 #include <Standard_Integer.hxx>
24 #include <Standard_Boolean.hxx>
25 #include <TopoDS_Shape.hxx>
26 #include <SelectMgr_EntityOwner.hxx>
27 #include <PrsMgr_PresentationManager3d.hxx>
28 #include <Quantity_NameOfColor.hxx>
29 #include <Graphic3d_ZLayerId.hxx>
30 class StdSelect_Shape;
31 class TopoDS_Shape;
32 class SelectMgr_SelectableObject;
33 class PrsMgr_PresentationManager;
34 class TopLoc_Location;
35
36
37 class StdSelect_BRepOwner;
38 DEFINE_STANDARD_HANDLE(StdSelect_BRepOwner, SelectMgr_EntityOwner)
39
40 //! Defines Specific Owners for Sensitive Primitives
41 //! (Sensitive Segments,Circles...).
42 //! Used in Dynamic Selection Mechanism.
43 //! A BRepOwner has an Owner (the shape it represents)
44 //! and Users (One or More Transient entities).
45 //! The highlight-unhighlight methods are empty and
46 //! must be redefined by each User.
47 class StdSelect_BRepOwner : public SelectMgr_EntityOwner
48 {
49
50 public:
51
52   
53   //! Constructs an owner specification framework defined
54   //! by the priority aPriority.
55   Standard_EXPORT StdSelect_BRepOwner(const Standard_Integer aPriority);
56   
57   //! Constructs an owner specification framework defined
58   //! by the shape aShape and the priority aPriority.
59   //! aShape and aPriority are stored in this framework. If
60   //! more than one owner are detected during dynamic
61   //! selection, the one with the highest priority is the one stored.
62   Standard_EXPORT StdSelect_BRepOwner(const TopoDS_Shape& aShape, const Standard_Integer aPriority = 0, const Standard_Boolean ComesFromDecomposition = Standard_False);
63   
64   //! Constructs an owner specification framework defined
65   //! by the shape aShape, the selectable object theOrigin
66   //! and the priority aPriority.
67   //! aShape, theOrigin and aPriority are stored in this
68   //! framework. If more than one owner are detected
69   //! during dynamic selection, the one with the highest
70   //! priority is the one stored.
71   Standard_EXPORT StdSelect_BRepOwner(const TopoDS_Shape& aShape, const Handle(SelectMgr_SelectableObject)& theOrigin, const Standard_Integer aPriority = 0, const Standard_Boolean FromDecomposition = Standard_False);
72   
73   //! returns False if no shape was set
74     Standard_Boolean HasShape() const;
75   
76   //! <FromDecomposition> indicates whether <aShape>
77   //! comes from decomposition of a bigger shape.
78   Standard_EXPORT void Set (const TopoDS_Shape& aShape, const Standard_Boolean FromDecomposition = Standard_False);
79   
80     Standard_Boolean ComesFromDecomposition() const;
81   
82     const TopoDS_Shape& Shape() const;
83   
84
85   //! Returns true if this framework has a highlight mode defined for it.
86     Standard_Boolean HasHilightMode() const;
87   
88   //! Sets the highlight mode for this framework.
89   //! This defines the type of display used to highlight the
90   //! owner of the shape when it is detected by the selector.
91   //! The default type of display is wireframe, defined by the index 0.
92     void SetHilightMode (const Standard_Integer aMode);
93   
94   //! Resets the higlight mode for this framework.
95   //! This defines the type of display used to highlight the
96   //! owner of the shape when it is detected by the selector.
97   //! The default type of display is wireframe, defined by the index 0.
98     void ResetHilightMode();
99   
100   //! Returns the highlight mode for this framework.
101   //! This defines the type of display used to highlight the
102   //! owner of the shape when it is detected by the selector.
103   //! The default type of display is wireframe, defined by the index 0.
104     Standard_Integer HilightMode() const;
105   
106   //! Returns true if an object with the selection mode
107   //! aMode is highlighted in the presentation manager aPM.
108   Standard_EXPORT virtual Standard_Boolean IsHilighted (const Handle(PrsMgr_PresentationManager)& aPM, const Standard_Integer aMode = 0) const Standard_OVERRIDE;
109   
110   Standard_EXPORT virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM,
111                                                  const Handle(Graphic3d_HighlightStyle)&     theStyle,
112                                                  const Standard_Integer                      theMode = 0) Standard_OVERRIDE;
113   
114   //! Removes highlighting from the type of shape
115   //! identified the selection mode aMode in the presentation manager aPM.
116   Standard_EXPORT virtual void Unhilight (const Handle(PrsMgr_PresentationManager)& aPM, const Standard_Integer aMode = 0) Standard_OVERRIDE;
117   
118   //! Clears the presentation manager object aPM of all
119   //! shapes with the selection mode aMode.
120   Standard_EXPORT virtual void Clear (const Handle(PrsMgr_PresentationManager)& aPM, const Standard_Integer aMode = 0) Standard_OVERRIDE;
121   
122   Standard_EXPORT virtual void SetLocation (const TopLoc_Location& aLoc) Standard_OVERRIDE;
123   
124   Standard_EXPORT virtual void ResetLocation() Standard_OVERRIDE;
125   
126   //! Set Z layer ID and update all presentations.
127   Standard_EXPORT virtual void SetZLayer (const Graphic3d_ZLayerId theLayerId) Standard_OVERRIDE;
128
129   //! Implements immediate application of location transformation of parent object to dynamic highlight structure
130   Standard_EXPORT virtual void UpdateHighlightTrsf (const Handle(V3d_Viewer)& theViewer,
131                                                     const Handle(PrsMgr_PresentationManager3d)& theManager,
132                                                     const Standard_Integer theDispMode) Standard_OVERRIDE;
133
134   DEFINE_STANDARD_RTTIEXT(StdSelect_BRepOwner,SelectMgr_EntityOwner)
135
136 protected:
137
138
139   Standard_Boolean myFromDecomposition;
140   TopoDS_Shape myShape;
141
142
143 private:
144
145
146   Handle(StdSelect_Shape) myPrsSh;
147   Standard_Integer myCurMode;
148
149
150 };
151
152
153 #include <StdSelect_BRepOwner.lxx>
154
155
156
157
158
159 #endif // _StdSelect_BRepOwner_HeaderFile