42cf5bc1 |
1 | // Created on: 2003-10-10 |
2 | // Created by: Alexander SOLOVYOV |
3 | // Copyright (c) 2003-2014 OPEN CASCADE SAS |
4 | // |
5 | // This file is part of Open CASCADE Technology software library. |
6 | // |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
12 | // |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
15 | |
16 | #ifndef _MeshVS_Mesh_HeaderFile |
17 | #define _MeshVS_Mesh_HeaderFile |
18 | |
19 | #include <Standard.hxx> |
20 | #include <Standard_Type.hxx> |
21 | |
22 | #include <MeshVS_SequenceOfPrsBuilder.hxx> |
23 | #include <MeshVS_DataMapOfIntegerOwner.hxx> |
24 | #include <MeshVS_MeshSelectionMethod.hxx> |
25 | #include <AIS_InteractiveObject.hxx> |
26 | #include <Standard_Boolean.hxx> |
27 | #include <PrsMgr_PresentationManager3d.hxx> |
28 | #include <Standard_Integer.hxx> |
29 | #include <SelectMgr_Selection.hxx> |
30 | #include <SelectMgr_SequenceOfOwner.hxx> |
31 | #include <Quantity_NameOfColor.hxx> |
32 | #include <Standard_CString.hxx> |
33 | class MeshVS_PrsBuilder; |
34 | class TColStd_HPackedMapOfInteger; |
35 | class MeshVS_DataSource; |
36 | class MeshVS_Drawer; |
37 | class SelectMgr_EntityOwner; |
38 | class Prs3d_Presentation; |
39 | |
40 | |
41 | class MeshVS_Mesh; |
42 | DEFINE_STANDARD_HANDLE(MeshVS_Mesh, AIS_InteractiveObject) |
43 | |
44 | //! the main class provides interface to create mesh presentation as a whole |
45 | class MeshVS_Mesh : public AIS_InteractiveObject |
46 | { |
47 | |
48 | public: |
49 | |
50 | |
51 | //! Constructor. |
52 | //! theIsAllowOverlapped is Standard_True, if it is allowed to draw edges overlapped with beams |
53 | //! Its value is stored in drawer |
54 | Standard_EXPORT MeshVS_Mesh(const Standard_Boolean theIsAllowOverlapped = Standard_False); |
55 | |
42cf5bc1 |
56 | //! Computes presentation using builders added to sequence. Each builder computes |
57 | //! own part of mesh presentation according to its type. |
58 | Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& PM, const Handle(Prs3d_Presentation)& Prs, const Standard_Integer DisplayMode) Standard_OVERRIDE; |
59 | |
60 | //! Computes selection according to SelectMode |
61 | Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& Sel, const Standard_Integer SelectMode) Standard_OVERRIDE; |
62 | |
63 | //! Draw selected owners presentation |
64 | Standard_EXPORT virtual void HilightSelected (const Handle(PrsMgr_PresentationManager3d)& PM, const SelectMgr_SequenceOfOwner& Owners) Standard_OVERRIDE; |
65 | |
66 | //! Draw hilighted owner presentation |
67 | Standard_EXPORT virtual void HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)& PM, const Quantity_NameOfColor Color, const Handle(SelectMgr_EntityOwner)& Owner) Standard_OVERRIDE; |
68 | |
69 | //! Clears internal selection presentation |
70 | Standard_EXPORT virtual void ClearSelected() Standard_OVERRIDE; |
71 | |
72 | //! How many builders there are in sequence |
73 | Standard_EXPORT Standard_Integer GetBuildersCount() const; |
74 | |
75 | //! Returns builder by its index in sequence |
76 | Standard_EXPORT Handle(MeshVS_PrsBuilder) GetBuilder (const Standard_Integer Index) const; |
77 | |
78 | //! Returns builder by its ID |
79 | Standard_EXPORT Handle(MeshVS_PrsBuilder) GetBuilderById (const Standard_Integer Id) const; |
80 | |
81 | //! Returns the smallest positive ID, not occupied by any builder. |
82 | //! This method using when builder is created with ID = -1 |
83 | Standard_EXPORT Standard_Integer GetFreeId() const; |
84 | |
85 | //! Adds builder to tale of sequence. |
86 | //! PrsBuilder is builder to be added |
87 | //! If TreatAsHilighter is true, MeshVS_Mesh will use this builder to create |
88 | //! presentation of hilighted and selected owners. |
89 | //! Only one builder can be hilighter, so that if you call this method with |
90 | //! TreatAsHilighter = Standard_True some times, only last builder will be hilighter |
91 | //! WARNING: As minimum one builder must be added as hilighter, otherwise selection cannot be computed |
92 | Standard_EXPORT void AddBuilder (const Handle(MeshVS_PrsBuilder)& Builder, const Standard_Boolean TreatAsHilighter = Standard_False); |
93 | |
94 | //! Changes hilighter ( see above ) |
95 | Standard_EXPORT void SetHilighter (const Handle(MeshVS_PrsBuilder)& Builder); |
96 | |
97 | //! Sets builder with sequence index "Index" as hilighter |
98 | Standard_EXPORT Standard_Boolean SetHilighter (const Standard_Integer Index); |
99 | |
100 | //! Sets builder with identificator "Id" as hilighter |
101 | Standard_EXPORT Standard_Boolean SetHilighterById (const Standard_Integer Id); |
102 | |
103 | //! Returns hilighter |
104 | Standard_EXPORT Handle(MeshVS_PrsBuilder) GetHilighter() const; |
105 | |
106 | //! Removes builder from sequence. If it is hilighter, hilighter will be NULL |
107 | //! ( Don't remember to set it to other after!!! ) |
108 | Standard_EXPORT void RemoveBuilder (const Standard_Integer Index); |
109 | |
110 | //! Removes builder with identificator Id |
111 | Standard_EXPORT void RemoveBuilderById (const Standard_Integer Id); |
112 | |
113 | //! Finds builder by its type the string represents |
114 | Standard_EXPORT Handle(MeshVS_PrsBuilder) FindBuilder (const Standard_CString TypeString) const; |
115 | |
116 | //! Returns map of owners. |
117 | Standard_EXPORT const MeshVS_DataMapOfIntegerOwner& GetOwnerMaps (const Standard_Boolean IsElement); |
118 | |
119 | //! Returns default builders' data source |
120 | Standard_EXPORT Handle(MeshVS_DataSource) GetDataSource() const; |
121 | |
122 | //! Sets default builders' data source |
123 | Standard_EXPORT void SetDataSource (const Handle(MeshVS_DataSource)& aDataSource); |
124 | |
125 | //! Returns default builders' drawer |
126 | Standard_EXPORT Handle(MeshVS_Drawer) GetDrawer() const; |
127 | |
128 | //! Sets default builders' drawer |
129 | Standard_EXPORT void SetDrawer (const Handle(MeshVS_Drawer)& aDrawer); |
130 | |
131 | //! Returns True if specified element is hidden |
132 | //! By default no elements are hidden |
133 | Standard_EXPORT Standard_Boolean IsHiddenElem (const Standard_Integer ID) const; |
134 | |
135 | //! Returns True if specified node is hidden. |
136 | //! By default all nodes are hidden |
137 | Standard_EXPORT Standard_Boolean IsHiddenNode (const Standard_Integer ID) const; |
138 | |
139 | //! Returns True if specified element is not hidden |
140 | Standard_EXPORT Standard_Boolean IsSelectableElem (const Standard_Integer ID) const; |
141 | |
142 | //! Returns True if specified node is specified as selectable. |
143 | Standard_EXPORT Standard_Boolean IsSelectableNode (const Standard_Integer ID) const; |
144 | |
145 | //! Returns map of hidden nodes (may be null handle) |
146 | Standard_EXPORT const Handle(TColStd_HPackedMapOfInteger)& GetHiddenNodes() const; |
147 | |
148 | //! Sets map of hidden nodes, which shall not be displayed individually. |
149 | //! If nodes shared by some elements shall not be drawn, |
150 | //! they should be included into that map |
151 | Standard_EXPORT void SetHiddenNodes (const Handle(TColStd_HPackedMapOfInteger)& Ids); |
152 | |
153 | //! Returns map of hidden elements (may be null handle) |
154 | Standard_EXPORT const Handle(TColStd_HPackedMapOfInteger)& GetHiddenElems() const; |
155 | |
156 | //! Sets map of hidden elements |
157 | Standard_EXPORT void SetHiddenElems (const Handle(TColStd_HPackedMapOfInteger)& Ids); |
158 | |
159 | //! Returns map of selectable elements (may be null handle) |
160 | Standard_EXPORT const Handle(TColStd_HPackedMapOfInteger)& GetSelectableNodes() const; |
161 | |
162 | //! Sets map of selectable nodes. |
163 | Standard_EXPORT void SetSelectableNodes (const Handle(TColStd_HPackedMapOfInteger)& Ids); |
164 | |
165 | //! Automatically computes selectable nodes; the node is considered |
166 | //! as being selectable if it is either not hidden, or is hidden |
167 | //! but referred by at least one non-hidden element. |
168 | //! Thus all nodes that are visible (either individually, or as ends or |
169 | //! corners of elements) are selectable by default. |
170 | Standard_EXPORT void UpdateSelectableNodes(); |
171 | |
172 | //! Returns set mesh selection method (see MeshVS.cdl) |
173 | Standard_EXPORT MeshVS_MeshSelectionMethod GetMeshSelMethod() const; |
174 | |
175 | //! Sets mesh selection method (see MeshVS.cdl) |
176 | Standard_EXPORT void SetMeshSelMethod (const MeshVS_MeshSelectionMethod M); |
177 | |
178 | //! Returns True if the given owner represents a whole mesh. |
179 | Standard_EXPORT virtual Standard_Boolean IsWholeMeshOwner (const Handle(SelectMgr_EntityOwner)& theOwner) const; |
180 | |
181 | friend class MeshVS_PrsBuilder; |
182 | |
183 | |
92efcf78 |
184 | DEFINE_STANDARD_RTTIEXT(MeshVS_Mesh,AIS_InteractiveObject) |
42cf5bc1 |
185 | |
186 | protected: |
187 | |
188 | |
189 | MeshVS_DataMapOfIntegerOwner myNodeOwners; |
190 | MeshVS_DataMapOfIntegerOwner myElementOwners; |
191 | MeshVS_DataMapOfIntegerOwner my0DOwners; |
192 | MeshVS_DataMapOfIntegerOwner myLinkOwners; |
193 | MeshVS_DataMapOfIntegerOwner myFaceOwners; |
194 | MeshVS_DataMapOfIntegerOwner myVolumeOwners; |
195 | MeshVS_DataMapOfIntegerOwner myGroupOwners; |
196 | MeshVS_DataMapOfIntegerOwner myMeshOwners; |
197 | Handle(MeshVS_Drawer) myCurrentDrawer; |
198 | Handle(MeshVS_Drawer) mySelectionDrawer; |
199 | Handle(MeshVS_Drawer) myHilightDrawer; |
200 | Handle(SelectMgr_EntityOwner) myWholeMeshOwner; |
201 | |
202 | |
203 | private: |
204 | |
205 | |
206 | MeshVS_SequenceOfPrsBuilder myBuilders; |
207 | Handle(MeshVS_PrsBuilder) myHilighter; |
208 | Handle(TColStd_HPackedMapOfInteger) myHiddenElements; |
209 | Handle(TColStd_HPackedMapOfInteger) myHiddenNodes; |
210 | Handle(TColStd_HPackedMapOfInteger) mySelectableNodes; |
211 | Handle(MeshVS_DataSource) myDataSource; |
212 | MeshVS_MeshSelectionMethod mySelectionMethod; |
213 | |
214 | |
215 | }; |
216 | |
217 | |
218 | |
219 | |
220 | |
221 | |
222 | |
223 | #endif // _MeshVS_Mesh_HeaderFile |