2182812a |
1 | // Created on: 1997-01-17 |
b311480e |
2 | // Created by: Robert COUBLANC |
3 | // Copyright (c) 1997-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
b311480e |
16 | |
d94bed0e |
17 | #include <AIS_InteractiveContext.hxx> |
2ec85268 |
18 | |
42cf5bc1 |
19 | #include <AIS_DataMapIteratorOfDataMapOfIOStatus.hxx> |
d94bed0e |
20 | #include <AIS_ConnectedInteractive.hxx> |
7fd59977 |
21 | #include <AIS_GlobalStatus.hxx> |
42cf5bc1 |
22 | #include <AIS_InteractiveObject.hxx> |
42cf5bc1 |
23 | #include <AIS_MultipleConnectedInteractive.hxx> |
42cf5bc1 |
24 | #include <Precision.hxx> |
7fd59977 |
25 | #include <Prs3d_DatumAspect.hxx> |
42cf5bc1 |
26 | #include <Prs3d_IsoAspect.hxx> |
27 | #include <Prs3d_LineAspect.hxx> |
7fd59977 |
28 | #include <Prs3d_PlaneAspect.hxx> |
f838dac4 |
29 | #include <Prs3d_PointAspect.hxx> |
42cf5bc1 |
30 | #include <Prs3d_ShadingAspect.hxx> |
42cf5bc1 |
31 | #include <SelectMgr_EntityOwner.hxx> |
42cf5bc1 |
32 | #include <TColStd_MapIteratorOfMapOfTransient.hxx> |
33 | #include <TopLoc_Location.hxx> |
42cf5bc1 |
34 | #include <V3d_View.hxx> |
35 | #include <V3d_Viewer.hxx> |
7fd59977 |
36 | |
478862fc |
37 | #include <AIS_Shape.hxx> |
38 | #include <StdSelect_BRepOwner.hxx> |
39 | #include <TopoDS_Shape.hxx> |
40 | |
2ec85268 |
41 | IMPLEMENT_STANDARD_RTTIEXT(AIS_InteractiveContext, Standard_Transient) |
92efcf78 |
42 | |
e33e7e78 |
43 | namespace |
7fd59977 |
44 | { |
b586500b |
45 | typedef NCollection_DataMap<Handle(SelectMgr_SelectableObject), Handle(SelectMgr_IndexedMapOfOwner)> AIS_MapOfObjectOwners; |
46 | typedef NCollection_DataMap<Handle(SelectMgr_SelectableObject), Handle(SelectMgr_IndexedMapOfOwner)>::Iterator AIS_MapIteratorOfMapOfObjectOwners; |
f838dac4 |
47 | |
48 | //! Initialize default highlighting attributes. |
df8c7e3e |
49 | static void initDefaultHilightAttributes (const Handle(Prs3d_Drawer)& theDrawer, |
50 | const Quantity_Color& theColor) |
f838dac4 |
51 | { |
52 | theDrawer->SetMethod (Aspect_TOHM_COLOR); |
53 | theDrawer->SetDisplayMode (0); |
df8c7e3e |
54 | theDrawer->SetColor (theColor); |
f838dac4 |
55 | |
df8c7e3e |
56 | theDrawer->SetupOwnShadingAspect(); |
57 | theDrawer->SetupOwnPointAspect(); |
f838dac4 |
58 | theDrawer->SetLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0)); |
59 | *theDrawer->LineAspect()->Aspect() = *theDrawer->Link()->LineAspect()->Aspect(); |
60 | theDrawer->SetWireAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0)); |
61 | *theDrawer->WireAspect()->Aspect() = *theDrawer->Link()->WireAspect()->Aspect(); |
62 | theDrawer->SetPlaneAspect (new Prs3d_PlaneAspect()); |
63 | *theDrawer->PlaneAspect()->EdgesAspect() = *theDrawer->Link()->PlaneAspect()->EdgesAspect(); |
64 | theDrawer->SetFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0)); |
65 | *theDrawer->FreeBoundaryAspect()->Aspect() = *theDrawer->Link()->FreeBoundaryAspect()->Aspect(); |
66 | theDrawer->SetUnFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0)); |
67 | *theDrawer->UnFreeBoundaryAspect()->Aspect() = *theDrawer->Link()->UnFreeBoundaryAspect()->Aspect(); |
df8c7e3e |
68 | theDrawer->SetDatumAspect (new Prs3d_DatumAspect()); |
69 | |
70 | theDrawer->ShadingAspect()->SetColor (theColor); |
71 | theDrawer->WireAspect()->SetColor (theColor); |
72 | theDrawer->LineAspect()->SetColor (theColor); |
73 | theDrawer->PlaneAspect()->ArrowAspect()->SetColor (theColor); |
74 | theDrawer->PlaneAspect()->IsoAspect()->SetColor (theColor); |
75 | theDrawer->PlaneAspect()->EdgesAspect()->SetColor (theColor); |
76 | theDrawer->FreeBoundaryAspect()->SetColor (theColor); |
77 | theDrawer->UnFreeBoundaryAspect()->SetColor (theColor); |
78 | theDrawer->PointAspect()->SetColor (theColor); |
24f9d04c |
79 | for (Standard_Integer aPartIter = 0; aPartIter < Prs3d_DatumParts_None; ++aPartIter) |
df8c7e3e |
80 | { |
81 | if (Handle(Prs3d_LineAspect) aLineAsp = theDrawer->DatumAspect()->LineAspect ((Prs3d_DatumParts )aPartIter)) |
82 | { |
83 | aLineAsp->SetColor (theColor); |
84 | } |
85 | } |
f838dac4 |
86 | |
87 | theDrawer->WireAspect()->SetWidth (2.0); |
88 | theDrawer->LineAspect()->SetWidth (2.0); |
89 | theDrawer->PlaneAspect()->EdgesAspect()->SetWidth (2.0); |
90 | theDrawer->FreeBoundaryAspect() ->SetWidth (2.0); |
91 | theDrawer->UnFreeBoundaryAspect()->SetWidth (2.0); |
92 | theDrawer->PointAspect()->SetTypeOfMarker (Aspect_TOM_O_POINT); |
93 | theDrawer->PointAspect()->SetScale (2.0); |
94 | |
95 | // the triangulation should be computed using main presentation attributes, |
96 | // and should not be overridden by highlighting |
97 | theDrawer->SetAutoTriangulation (Standard_False); |
98 | } |
2195ab96 |
99 | } |
7fd59977 |
100 | |
101 | //======================================================================= |
102 | //function : AIS_InteractiveContext |
103 | //purpose : |
104 | //======================================================================= |
105 | |
106 | AIS_InteractiveContext::AIS_InteractiveContext(const Handle(V3d_Viewer)& MainViewer): |
decbff0d |
107 | myMainPM (new PrsMgr_PresentationManager (MainViewer->StructureManager())), |
7fd59977 |
108 | myMainVwr(MainViewer), |
cbff1e55 |
109 | myToHilightSelected(Standard_True), |
f838dac4 |
110 | mySelection(new AIS_Selection()), |
897aeb20 |
111 | myFilters (new SelectMgr_AndOrFilter(SelectMgr_FilterType_OR)), |
7fd59977 |
112 | myDefaultDrawer(new Prs3d_Drawer()), |
f0cddd16 |
113 | myCurDetected(0), |
114 | myCurHighlighted(0), |
14c4193d |
115 | myPickingStrategy (SelectMgr_PickingStrategy_FirstAcceptable), |
68dcee02 |
116 | myAutoHilight(Standard_True), |
016e5959 |
117 | myIsAutoActivateSelMode(Standard_True) |
f838dac4 |
118 | { |
45fc824b |
119 | mgrSelector = new SelectMgr_SelectionManager (new StdSelect_ViewerSelector3d()); |
68dcee02 |
120 | |
f838dac4 |
121 | myStyles[Prs3d_TypeOfHighlight_None] = myDefaultDrawer; |
122 | myStyles[Prs3d_TypeOfHighlight_Selected] = new Prs3d_Drawer(); |
123 | myStyles[Prs3d_TypeOfHighlight_Dynamic] = new Prs3d_Drawer(); |
124 | myStyles[Prs3d_TypeOfHighlight_LocalSelected] = new Prs3d_Drawer(); |
125 | myStyles[Prs3d_TypeOfHighlight_LocalDynamic] = new Prs3d_Drawer(); |
126 | myStyles[Prs3d_TypeOfHighlight_SubIntensity] = new Prs3d_Drawer(); |
127 | |
4f5e9344 |
128 | myDefaultDrawer->SetupOwnDefaults(); |
f838dac4 |
129 | myDefaultDrawer->SetZLayer(Graphic3d_ZLayerId_Default); |
130 | myDefaultDrawer->SetDisplayMode(0); |
131 | { |
132 | const Handle(Prs3d_Drawer)& aStyle = myStyles[Prs3d_TypeOfHighlight_Dynamic]; |
133 | aStyle->Link (myDefaultDrawer); |
df8c7e3e |
134 | initDefaultHilightAttributes (aStyle, Quantity_NOC_CYAN1); |
f838dac4 |
135 | aStyle->SetZLayer(Graphic3d_ZLayerId_Top); |
f838dac4 |
136 | } |
137 | { |
138 | const Handle(Prs3d_Drawer)& aStyle = myStyles[Prs3d_TypeOfHighlight_LocalDynamic]; |
139 | aStyle->Link (myDefaultDrawer); |
df8c7e3e |
140 | initDefaultHilightAttributes (aStyle, Quantity_NOC_CYAN1); |
f838dac4 |
141 | aStyle->SetZLayer(Graphic3d_ZLayerId_Topmost); |
f838dac4 |
142 | } |
143 | { |
144 | const Handle(Prs3d_Drawer)& aStyle = myStyles[Prs3d_TypeOfHighlight_Selected]; |
145 | aStyle->Link (myDefaultDrawer); |
df8c7e3e |
146 | initDefaultHilightAttributes (aStyle, Quantity_NOC_GRAY80); |
f838dac4 |
147 | aStyle->SetZLayer(Graphic3d_ZLayerId_UNKNOWN); |
f838dac4 |
148 | } |
149 | { |
150 | const Handle(Prs3d_Drawer)& aStyle = myStyles[Prs3d_TypeOfHighlight_LocalSelected]; |
151 | aStyle->Link (myDefaultDrawer); |
df8c7e3e |
152 | initDefaultHilightAttributes (aStyle, Quantity_NOC_GRAY80); |
f838dac4 |
153 | aStyle->SetZLayer(Graphic3d_ZLayerId_UNKNOWN); |
f838dac4 |
154 | } |
155 | { |
156 | const Handle(Prs3d_Drawer)& aStyle = myStyles[Prs3d_TypeOfHighlight_SubIntensity]; |
157 | aStyle->SetZLayer(Graphic3d_ZLayerId_UNKNOWN); |
158 | aStyle->SetMethod(Aspect_TOHM_COLOR); |
159 | aStyle->SetColor (Quantity_NOC_GRAY40); |
160 | } |
161 | |
7fd59977 |
162 | InitAttributes(); |
163 | } |
164 | |
2ec85268 |
165 | //======================================================================= |
166 | //function : ~AIS_InteractiveContext |
167 | //purpose : |
168 | //======================================================================= |
169 | AIS_InteractiveContext::~AIS_InteractiveContext() |
7fd59977 |
170 | { |
016e5959 |
171 | // clear the current selection |
02974a19 |
172 | mySelection->Clear(); |
68dcee02 |
173 | mgrSelector.Nullify(); |
2195ab96 |
174 | |
da0e82aa |
175 | Handle(AIS_InteractiveContext) aNullContext; |
2195ab96 |
176 | for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next()) |
da0e82aa |
177 | { |
b5cce1ab |
178 | const Handle(AIS_InteractiveObject)& anObj = anObjIter.Key(); |
2195ab96 |
179 | anObj->SetContext (aNullContext); |
b5cce1ab |
180 | for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anObj->Selections()); aSelIter.More(); aSelIter.Next()) |
c3282ec1 |
181 | { |
b5cce1ab |
182 | aSelIter.Value()->UpdateBVHStatus (SelectMgr_TBU_Renew); |
c3282ec1 |
183 | } |
da0e82aa |
184 | } |
7fd59977 |
185 | } |
186 | |
2108d9a2 |
187 | //======================================================================= |
188 | //function : LastActiveView |
189 | //purpose : |
190 | //======================================================================= |
191 | Handle(V3d_View) AIS_InteractiveContext::LastActiveView() const |
192 | { |
193 | if (myLastActiveView == NULL |
194 | || myMainVwr.IsNull()) |
195 | { |
196 | return Handle(V3d_View)(); |
197 | } |
198 | |
199 | // as a precaution - check that myLastActiveView pointer is a valid active View |
200 | for (V3d_ListOfViewIterator aViewIter = myMainVwr->ActiveViewIterator(); aViewIter.More(); aViewIter.Next()) |
201 | { |
202 | if (aViewIter.Value() == myLastActiveView) |
203 | { |
204 | return aViewIter.Value(); |
205 | } |
206 | } |
207 | return Handle(V3d_View)(); |
208 | } |
209 | |
7fd59977 |
210 | //======================================================================= |
211 | //function : UpdateCurrentViewer |
212 | //purpose : |
213 | //======================================================================= |
214 | |
215 | void AIS_InteractiveContext::UpdateCurrentViewer() |
216 | { |
217 | if (!myMainVwr.IsNull()) |
218 | myMainVwr->Update(); |
219 | } |
220 | |
7fd59977 |
221 | //======================================================================= |
222 | //function : DisplayedObjects |
2195ab96 |
223 | //purpose : |
7fd59977 |
224 | //======================================================================= |
68dcee02 |
225 | void AIS_InteractiveContext::DisplayedObjects (AIS_ListOfInteractive& theListOfIO) const |
7fd59977 |
226 | { |
2195ab96 |
227 | for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next()) |
228 | { |
39e6123e |
229 | if (anObjIter.Key()->DisplayStatus() == PrsMgr_DisplayStatus_Displayed) |
2195ab96 |
230 | { |
68dcee02 |
231 | theListOfIO.Append (anObjIter.Key()); |
7fd59977 |
232 | } |
2195ab96 |
233 | } |
7fd59977 |
234 | } |
2195ab96 |
235 | |
7fd59977 |
236 | //======================================================================= |
237 | //function : DisplayedObjects |
2195ab96 |
238 | //purpose : |
7fd59977 |
239 | //======================================================================= |
2195ab96 |
240 | void AIS_InteractiveContext::DisplayedObjects (const AIS_KindOfInteractive theKind, |
241 | const Standard_Integer theSign, |
68dcee02 |
242 | AIS_ListOfInteractive& theListOfIO) const |
7fd59977 |
243 | { |
39e6123e |
244 | ObjectsByDisplayStatus (theKind, theSign, PrsMgr_DisplayStatus_Displayed, theListOfIO); |
7fd59977 |
245 | } |
246 | |
7fd59977 |
247 | //======================================================================= |
248 | //function : ErasedObjects |
2195ab96 |
249 | //purpose : |
7fd59977 |
250 | //======================================================================= |
2195ab96 |
251 | void AIS_InteractiveContext::ErasedObjects (AIS_ListOfInteractive& theListOfIO) const |
7fd59977 |
252 | { |
39e6123e |
253 | ObjectsByDisplayStatus (PrsMgr_DisplayStatus_Erased, theListOfIO); |
7fd59977 |
254 | } |
255 | |
256 | //======================================================================= |
257 | //function : ErasedObjects |
2195ab96 |
258 | //purpose : |
7fd59977 |
259 | //======================================================================= |
2195ab96 |
260 | void AIS_InteractiveContext::ErasedObjects (const AIS_KindOfInteractive theKind, |
261 | const Standard_Integer theSign, |
262 | AIS_ListOfInteractive& theListOfIO) const |
7fd59977 |
263 | { |
39e6123e |
264 | ObjectsByDisplayStatus (theKind, theSign, PrsMgr_DisplayStatus_Erased, theListOfIO); |
7fd59977 |
265 | } |
266 | |
267 | //======================================================================= |
268 | //function : ObjectsByDisplayStatus |
2195ab96 |
269 | //purpose : |
7fd59977 |
270 | //======================================================================= |
39e6123e |
271 | void AIS_InteractiveContext::ObjectsByDisplayStatus (const PrsMgr_DisplayStatus theStatus, |
2195ab96 |
272 | AIS_ListOfInteractive& theListOfIO) const |
7fd59977 |
273 | { |
2195ab96 |
274 | for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next()) |
275 | { |
39e6123e |
276 | if (anObjIter.Key()->DisplayStatus() == theStatus) |
2195ab96 |
277 | { |
278 | theListOfIO.Append (anObjIter.Key()); |
279 | } |
7fd59977 |
280 | } |
281 | } |
282 | |
283 | //======================================================================= |
284 | //function : ObjectsByDisplayStatus |
2195ab96 |
285 | //purpose : |
7fd59977 |
286 | //======================================================================= |
2195ab96 |
287 | void AIS_InteractiveContext::ObjectsByDisplayStatus (const AIS_KindOfInteractive theKind, |
288 | const Standard_Integer theSign, |
39e6123e |
289 | const PrsMgr_DisplayStatus theStatus, |
2195ab96 |
290 | AIS_ListOfInteractive& theListOfIO) const |
291 | { |
292 | for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next()) |
293 | { |
39e6123e |
294 | if (theStatus != PrsMgr_DisplayStatus_None |
295 | && anObjIter.Key()->DisplayStatus() != theStatus) |
a1954302 |
296 | { |
297 | continue; |
298 | } |
299 | else if (anObjIter.Key()->Type() != theKind) |
2195ab96 |
300 | { |
301 | continue; |
302 | } |
7fd59977 |
303 | |
2195ab96 |
304 | if (theSign == -1 |
305 | || anObjIter.Key()->Signature() == theSign) |
306 | { |
307 | theListOfIO.Append (anObjIter.Key()); |
7fd59977 |
308 | } |
309 | } |
310 | } |
311 | |
312 | //======================================================================= |
313 | //function : ObjectsInside |
2195ab96 |
314 | //purpose : |
7fd59977 |
315 | //======================================================================= |
2195ab96 |
316 | void AIS_InteractiveContext::ObjectsInside (AIS_ListOfInteractive& theListOfIO, |
317 | const AIS_KindOfInteractive theKind, |
318 | const Standard_Integer theSign) const |
7fd59977 |
319 | { |
82b856b8 |
320 | if (theKind == AIS_KindOfInteractive_None |
2195ab96 |
321 | && theSign == -1) |
322 | { |
323 | for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next()) |
324 | { |
325 | theListOfIO.Append (anObjIter.Key()); |
7fd59977 |
326 | } |
2195ab96 |
327 | return; |
7fd59977 |
328 | } |
2195ab96 |
329 | |
330 | for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next()) |
331 | { |
332 | if (anObjIter.Key()->Type() != theKind) |
333 | { |
334 | continue; |
335 | } |
336 | |
337 | if (theSign == -1 |
338 | || anObjIter.Key()->Signature() == theSign) |
339 | { |
340 | theListOfIO.Append (anObjIter.Key()); |
7fd59977 |
341 | } |
342 | } |
343 | } |
344 | |
a272ed94 |
345 | //======================================================================= |
346 | //function : ObjectsForView |
347 | //purpose : |
348 | //======================================================================= |
349 | void AIS_InteractiveContext::ObjectsForView (AIS_ListOfInteractive& theListOfIO, |
350 | const Handle(V3d_View)& theView, |
351 | const Standard_Boolean theIsVisibleInView, |
39e6123e |
352 | const PrsMgr_DisplayStatus theStatus) const |
a272ed94 |
353 | { |
c357e426 |
354 | Handle(Graphic3d_CView) aViewImpl = theView->View(); |
355 | const Standard_Integer aViewId = aViewImpl->Identification(); |
a272ed94 |
356 | for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next()) |
357 | { |
39e6123e |
358 | if (theStatus != PrsMgr_DisplayStatus_None |
359 | && anObjIter.Key()->DisplayStatus() != theStatus) |
a272ed94 |
360 | { |
361 | theListOfIO.Append (anObjIter.Key()); |
362 | continue; |
363 | } |
364 | |
86d6c284 |
365 | Handle(Graphic3d_ViewAffinity) anAffinity = anObjIter.Key()->ViewAffinity(); |
a272ed94 |
366 | const Standard_Boolean isVisible = anAffinity->IsVisible (aViewId); |
367 | if (isVisible == theIsVisibleInView) |
368 | { |
369 | theListOfIO.Append (anObjIter.Key()); |
370 | } |
371 | } |
372 | } |
373 | |
7fd59977 |
374 | //======================================================================= |
375 | //function : Display |
2195ab96 |
376 | //purpose : |
7fd59977 |
377 | //======================================================================= |
2195ab96 |
378 | void AIS_InteractiveContext::Display (const Handle(AIS_InteractiveObject)& theIObj, |
379 | const Standard_Boolean theToUpdateViewer) |
380 | { |
381 | if (theIObj.IsNull()) |
382 | { |
383 | return; |
384 | } |
385 | |
386 | Standard_Integer aDispMode = 0, aHiMod = -1, aSelMode = -1; |
387 | GetDefModes (theIObj, aDispMode, aHiMod, aSelMode); |
68dcee02 |
388 | Display (theIObj, aDispMode, myIsAutoActivateSelMode ? aSelMode : -1, theToUpdateViewer); |
2195ab96 |
389 | } |
7fd59977 |
390 | |
a272ed94 |
391 | //======================================================================= |
392 | //function : SetViewAffinity |
393 | //purpose : |
394 | //======================================================================= |
395 | void AIS_InteractiveContext::SetViewAffinity (const Handle(AIS_InteractiveObject)& theIObj, |
396 | const Handle(V3d_View)& theView, |
397 | const Standard_Boolean theIsVisible) |
398 | { |
399 | if (theIObj.IsNull() |
400 | || !myObjects.IsBound (theIObj)) |
401 | { |
402 | return; |
403 | } |
404 | |
86d6c284 |
405 | Handle(Graphic3d_ViewAffinity) anAffinity = theIObj->ViewAffinity(); |
c357e426 |
406 | Handle(Graphic3d_CView) aViewImpl = theView->View(); |
407 | anAffinity->SetVisible (aViewImpl->Identification(), theIsVisible == Standard_True); |
a272ed94 |
408 | } |
409 | |
2195ab96 |
410 | //======================================================================= |
411 | //function : Display |
412 | //purpose : |
413 | //======================================================================= |
414 | void AIS_InteractiveContext::Display (const Handle(AIS_InteractiveObject)& theIObj, |
415 | const Standard_Integer theDispMode, |
416 | const Standard_Integer theSelectionMode, |
417 | const Standard_Boolean theToUpdateViewer, |
39e6123e |
418 | const PrsMgr_DisplayStatus theDispStatus) |
7fd59977 |
419 | { |
2195ab96 |
420 | if (theIObj.IsNull()) |
421 | { |
422 | return; |
423 | } |
7fd59977 |
424 | |
39e6123e |
425 | if (theDispStatus == PrsMgr_DisplayStatus_Erased) |
a1954302 |
426 | { |
427 | Erase (theIObj, theToUpdateViewer); |
68dcee02 |
428 | Load (theIObj, theSelectionMode); |
6194ee76 |
429 | if (Handle(AIS_GlobalStatus)* aStatusPtr = myObjects.ChangeSeek (theIObj)) |
430 | { |
431 | (*aStatusPtr)->SetDisplayMode (theDispMode); |
432 | } |
a1954302 |
433 | return; |
434 | } |
435 | |
2ec85268 |
436 | setContextToObject (theIObj); |
2195ab96 |
437 | if (!myObjects.IsBound (theIObj)) |
438 | { |
39e6123e |
439 | setObjectStatus (theIObj, PrsMgr_DisplayStatus_Displayed, theDispMode, theSelectionMode); |
86d6c284 |
440 | theIObj->ViewAffinity()->SetVisible (true); // reset view affinity mask |
441 | myMainVwr->StructureManager()->RegisterObject (theIObj, theIObj->ViewAffinity()); |
2195ab96 |
442 | myMainPM->Display(theIObj, theDispMode); |
443 | if (theSelectionMode != -1) |
444 | { |
543a9964 |
445 | const Handle(SelectMgr_SelectableObject)& anObj = theIObj; // to avoid ambiguity |
446 | if (!mgrSelector->Contains (anObj)) |
2195ab96 |
447 | { |
448 | mgrSelector->Load (theIObj); |
7fd59977 |
449 | } |
68dcee02 |
450 | mgrSelector->Activate (theIObj, theSelectionMode); |
2195ab96 |
451 | } |
7fd59977 |
452 | } |
7fd59977 |
453 | else |
454 | { |
2195ab96 |
455 | Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj); |
a6964ce6 |
456 | |
f2b63181 |
457 | // Mark the presentation modes hidden of interactive object different from aDispMode. |
2195ab96 |
458 | // Then make sure aDispMode is displayed and maybe highlighted. |
459 | // Finally, activate selection mode <SelMode> if not yet activated. |
3db69e41 |
460 | const Standard_Integer anOldMode = aStatus->DisplayMode(); |
461 | if (anOldMode != theDispMode) |
2195ab96 |
462 | { |
3db69e41 |
463 | if(myMainPM->IsHighlighted (theIObj, anOldMode)) |
2195ab96 |
464 | { |
f838dac4 |
465 | unhighlightGlobal (theIObj); |
2195ab96 |
466 | } |
3db69e41 |
467 | myMainPM->SetVisibility (theIObj, anOldMode, Standard_False); |
2195ab96 |
468 | } |
7fd59977 |
469 | |
3db69e41 |
470 | aStatus->SetDisplayMode (theDispMode); |
7fd59977 |
471 | |
39e6123e |
472 | theIObj->SetDisplayStatus (PrsMgr_DisplayStatus_Displayed); |
2195ab96 |
473 | myMainPM->Display (theIObj, theDispMode); |
2195ab96 |
474 | if (aStatus->IsHilighted()) |
475 | { |
f838dac4 |
476 | highlightGlobal (theIObj, aStatus->HilightStyle(), theDispMode); |
2195ab96 |
477 | } |
478 | if (theSelectionMode != -1) |
479 | { |
543a9964 |
480 | const Handle(SelectMgr_SelectableObject)& anObj = theIObj; // to avoid ambiguity |
481 | if (!mgrSelector->Contains (anObj)) |
2195ab96 |
482 | { |
483 | mgrSelector->Load (theIObj); |
7fd59977 |
484 | } |
2195ab96 |
485 | if (!mgrSelector->IsActivated (theIObj, theSelectionMode)) |
486 | { |
42ddd002 |
487 | aStatus->AddSelectionMode (theSelectionMode); |
68dcee02 |
488 | mgrSelector->Activate (theIObj, theSelectionMode); |
7fd59977 |
489 | } |
7fd59977 |
490 | } |
491 | } |
7fd59977 |
492 | |
2195ab96 |
493 | if (theToUpdateViewer) |
494 | { |
495 | myMainVwr->Update(); |
496 | } |
497 | } |
7fd59977 |
498 | |
499 | //======================================================================= |
500 | //function : Load |
2195ab96 |
501 | //purpose : |
7fd59977 |
502 | //======================================================================= |
2195ab96 |
503 | void AIS_InteractiveContext::Load (const Handle(AIS_InteractiveObject)& theIObj, |
68dcee02 |
504 | const Standard_Integer theSelMode) |
7fd59977 |
505 | { |
2195ab96 |
506 | if (theIObj.IsNull()) |
507 | { |
508 | return; |
509 | } |
7fd59977 |
510 | |
2ec85268 |
511 | setContextToObject (theIObj); |
6194ee76 |
512 | if (!myObjects.IsBound (theIObj)) |
2195ab96 |
513 | { |
6194ee76 |
514 | Standard_Integer aDispMode, aHiMod, aSelModeDef; |
515 | GetDefModes (theIObj, aDispMode, aHiMod, aSelModeDef); |
39e6123e |
516 | setObjectStatus (theIObj, PrsMgr_DisplayStatus_Erased, aDispMode, theSelMode != -1 ? theSelMode : aSelModeDef); |
86d6c284 |
517 | theIObj->ViewAffinity()->SetVisible (true); // reset view affinity mask |
518 | myMainVwr->StructureManager()->RegisterObject (theIObj, theIObj->ViewAffinity()); |
6194ee76 |
519 | } |
89cc29b0 |
520 | |
6194ee76 |
521 | // Register theIObj in the selection manager to prepare further activation of selection |
522 | const Handle(SelectMgr_SelectableObject)& anObj = theIObj; // to avoid ambiguity |
523 | if (!mgrSelector->Contains (anObj)) |
524 | { |
525 | mgrSelector->Load (theIObj); |
2195ab96 |
526 | } |
527 | } |
7fd59977 |
528 | |
529 | //======================================================================= |
530 | //function : Erase |
2195ab96 |
531 | //purpose : |
7fd59977 |
532 | //======================================================================= |
2195ab96 |
533 | void AIS_InteractiveContext::Erase (const Handle(AIS_InteractiveObject)& theIObj, |
534 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
535 | { |
2195ab96 |
536 | if (theIObj.IsNull()) |
537 | { |
538 | return; |
539 | } |
7fd59977 |
540 | |
2195ab96 |
541 | if (!theIObj->IsAutoHilight()) |
542 | { |
543 | theIObj->ClearSelected(); |
7fd59977 |
544 | } |
2195ab96 |
545 | |
68dcee02 |
546 | EraseGlobal (theIObj, Standard_False); |
2195ab96 |
547 | if (theToUpdateViewer) |
548 | { |
549 | myMainVwr->Update(); |
550 | } |
7fd59977 |
551 | } |
7fd59977 |
552 | |
553 | //======================================================================= |
554 | //function : EraseAll |
2195ab96 |
555 | //purpose : |
7fd59977 |
556 | //======================================================================= |
2195ab96 |
557 | void AIS_InteractiveContext::EraseAll (const Standard_Boolean theToUpdateViewer) |
7fd59977 |
558 | { |
2195ab96 |
559 | for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next()) |
560 | { |
39e6123e |
561 | if (anObjIter.Key()->DisplayStatus() == PrsMgr_DisplayStatus_Displayed) |
eb4320f2 |
562 | { |
2195ab96 |
563 | Erase (anObjIter.Key(), Standard_False); |
7fd59977 |
564 | } |
565 | } |
2195ab96 |
566 | |
567 | if (theToUpdateViewer) |
568 | { |
569 | myMainVwr->Update(); |
570 | } |
7fd59977 |
571 | } |
572 | |
573 | //======================================================================= |
574 | //function : DisplayAll |
2195ab96 |
575 | //purpose : |
7fd59977 |
576 | //======================================================================= |
2195ab96 |
577 | void AIS_InteractiveContext::DisplayAll (const Standard_Boolean theToUpdateViewer) |
7fd59977 |
578 | { |
2195ab96 |
579 | for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next()) |
580 | { |
39e6123e |
581 | const PrsMgr_DisplayStatus aStatus = anObjIter.Key()->DisplayStatus(); |
582 | if (aStatus == PrsMgr_DisplayStatus_Erased) |
eb4320f2 |
583 | { |
2195ab96 |
584 | Display (anObjIter.Key(), Standard_False); |
7fd59977 |
585 | } |
586 | } |
2195ab96 |
587 | |
588 | if (theToUpdateViewer) |
589 | { |
590 | myMainVwr->Update(); |
591 | } |
7fd59977 |
592 | } |
593 | |
594 | //======================================================================= |
595 | //function : DisplaySelected |
2195ab96 |
596 | //purpose : |
7fd59977 |
597 | //======================================================================= |
2195ab96 |
598 | void AIS_InteractiveContext::DisplaySelected (const Standard_Boolean theToUpdateViewer) |
7fd59977 |
599 | { |
b5cce1ab |
600 | for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next()) |
2195ab96 |
601 | { |
b5cce1ab |
602 | Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (aSelIter.Value()->Selectable()); |
2195ab96 |
603 | Display (anObj, Standard_False); |
2195ab96 |
604 | } |
7fd59977 |
605 | |
b5cce1ab |
606 | if (theToUpdateViewer && !mySelection->Objects().IsEmpty()) |
2195ab96 |
607 | { |
608 | myMainVwr->Update(); |
609 | } |
610 | } |
7fd59977 |
611 | |
2195ab96 |
612 | //======================================================================= |
613 | //function : EraseSelected |
614 | //purpose : |
615 | //======================================================================= |
616 | void AIS_InteractiveContext::EraseSelected (const Standard_Boolean theToUpdateViewer) |
7fd59977 |
617 | { |
b5cce1ab |
618 | Standard_Boolean isFound = Standard_False; |
619 | for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Init (mySelection->Objects())) |
2195ab96 |
620 | { |
b5cce1ab |
621 | Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (aSelIter.Value()->Selectable()); |
2195ab96 |
622 | Erase (anObj, Standard_False); |
623 | isFound = Standard_True; |
624 | } |
625 | |
626 | if (isFound && theToUpdateViewer) |
627 | { |
628 | myMainVwr->Update(); |
7fd59977 |
629 | } |
630 | } |
2195ab96 |
631 | |
7fd59977 |
632 | //======================================================================= |
2195ab96 |
633 | //function : DisplayStatus |
634 | //purpose : |
7fd59977 |
635 | //======================================================================= |
39e6123e |
636 | PrsMgr_DisplayStatus AIS_InteractiveContext::DisplayStatus (const Handle(AIS_InteractiveObject)& theIObj) const |
7fd59977 |
637 | { |
2195ab96 |
638 | if (theIObj.IsNull()) |
639 | { |
39e6123e |
640 | return PrsMgr_DisplayStatus_None; |
2195ab96 |
641 | } |
68dcee02 |
642 | const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theIObj); |
39e6123e |
643 | return aStatus != NULL ? theIObj->DisplayStatus() : PrsMgr_DisplayStatus_None; |
7fd59977 |
644 | } |
645 | |
7fd59977 |
646 | //======================================================================= |
647 | //function : Remove |
2195ab96 |
648 | //purpose : |
7fd59977 |
649 | //======================================================================= |
2195ab96 |
650 | void AIS_InteractiveContext::Remove (const Handle(AIS_InteractiveObject)& theIObj, |
651 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
652 | { |
2195ab96 |
653 | if (theIObj.IsNull()) |
654 | { |
655 | return; |
7fd59977 |
656 | } |
2195ab96 |
657 | |
2ec85268 |
658 | if (theIObj->HasInteractiveContext()) |
659 | { |
660 | if (theIObj->myCTXPtr != this) |
661 | { |
9775fa61 |
662 | throw Standard_ProgramError("AIS_InteractiveContext - object has been displayed in another context!"); |
2ec85268 |
663 | } |
664 | theIObj->SetContext (Handle(AIS_InteractiveContext)()); |
665 | } |
2195ab96 |
666 | ClearGlobal (theIObj, theToUpdateViewer); |
7fd59977 |
667 | } |
668 | |
669 | //======================================================================= |
670 | //function : RemoveAll |
2195ab96 |
671 | //purpose : |
7fd59977 |
672 | //======================================================================= |
2195ab96 |
673 | void AIS_InteractiveContext::RemoveAll (const Standard_Boolean theToUpdateViewer) |
7fd59977 |
674 | { |
6054db8a |
675 | ClearDetected(); |
676 | |
7fd59977 |
677 | AIS_ListOfInteractive aList; |
2195ab96 |
678 | ObjectsInside (aList); |
478862fc |
679 | for (AIS_ListOfInteractive::Iterator aListIterator (aList); aListIterator.More(); aListIterator.Next()) |
2195ab96 |
680 | { |
681 | Remove (aListIterator.Value(), Standard_False); |
7fd59977 |
682 | } |
7fd59977 |
683 | |
2195ab96 |
684 | if (theToUpdateViewer) |
685 | { |
686 | myMainVwr->Update(); |
7fd59977 |
687 | } |
7fd59977 |
688 | } |
689 | |
7fd59977 |
690 | //======================================================================= |
8e5fb5ea |
691 | //function : HilightWithColor |
692 | //purpose : |
7fd59977 |
693 | //======================================================================= |
8e5fb5ea |
694 | void AIS_InteractiveContext::HilightWithColor(const Handle(AIS_InteractiveObject)& theObj, |
f838dac4 |
695 | const Handle(Prs3d_Drawer)& theStyle, |
8e5fb5ea |
696 | const Standard_Boolean theIsToUpdate) |
7fd59977 |
697 | { |
8e5fb5ea |
698 | if (theObj.IsNull()) |
4f5e9344 |
699 | { |
2195ab96 |
700 | return; |
4f5e9344 |
701 | } |
7fd59977 |
702 | |
2ec85268 |
703 | setContextToObject (theObj); |
68dcee02 |
704 | if (!myObjects.IsBound (theObj)) |
4f5e9344 |
705 | { |
68dcee02 |
706 | return; |
4f5e9344 |
707 | } |
eb4320f2 |
708 | |
68dcee02 |
709 | const Handle(AIS_GlobalStatus)& aStatus = myObjects (theObj); |
710 | aStatus->SetHilightStatus (Standard_True); |
8e5fb5ea |
711 | |
39e6123e |
712 | if (theObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed) |
eb4320f2 |
713 | { |
68dcee02 |
714 | highlightGlobal (theObj, theStyle, aStatus->DisplayMode()); |
715 | aStatus->SetHilightStyle (theStyle); |
eb4320f2 |
716 | } |
717 | |
8e5fb5ea |
718 | if (theIsToUpdate) |
4f5e9344 |
719 | { |
2195ab96 |
720 | myMainVwr->Update(); |
4f5e9344 |
721 | } |
7fd59977 |
722 | } |
723 | |
724 | //======================================================================= |
725 | //function : Unhilight |
726 | //purpose : |
727 | //======================================================================= |
39e6123e |
728 | void AIS_InteractiveContext::Unhilight (const Handle(AIS_InteractiveObject)& theObj, |
729 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
730 | { |
39e6123e |
731 | Handle(AIS_GlobalStatus)* aStatus = !theObj.IsNull() ? myObjects.ChangeSeek (theObj) : NULL; |
732 | if (aStatus == NULL) |
733 | { |
734 | return; |
735 | } |
eb4320f2 |
736 | |
39e6123e |
737 | (*aStatus)->SetHilightStatus (Standard_False); |
738 | (*aStatus)->SetHilightStyle (Handle(Prs3d_Drawer)()); |
739 | if (theObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed) |
eb4320f2 |
740 | { |
39e6123e |
741 | unhighlightGlobal (theObj); |
eb4320f2 |
742 | } |
68dcee02 |
743 | |
39e6123e |
744 | if (theToUpdateViewer) |
745 | { |
746 | myMainVwr->Update(); |
747 | } |
7fd59977 |
748 | } |
749 | |
750 | //======================================================================= |
751 | //function : IsHilighted |
8e5fb5ea |
752 | //purpose : Returns true if the objects global status is set to highlighted. |
7fd59977 |
753 | //======================================================================= |
8e5fb5ea |
754 | Standard_Boolean AIS_InteractiveContext::IsHilighted (const Handle(AIS_InteractiveObject)& theObj) const |
7fd59977 |
755 | { |
68dcee02 |
756 | const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theObj); |
757 | return aStatus != NULL |
758 | && (*aStatus)->IsHilighted(); |
7fd59977 |
759 | } |
760 | |
c3282ec1 |
761 | //======================================================================= |
762 | //function : IsHilighted |
8e5fb5ea |
763 | //purpose : Returns true if the owner is highlighted with selection style. |
c3282ec1 |
764 | //======================================================================= |
8e5fb5ea |
765 | Standard_Boolean AIS_InteractiveContext::IsHilighted (const Handle(SelectMgr_EntityOwner)& theOwner) const |
c3282ec1 |
766 | { |
767 | if (theOwner.IsNull() || !theOwner->HasSelectable()) |
768 | return Standard_False; |
769 | |
770 | const Handle(AIS_InteractiveObject) anObj = |
771 | Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()); |
772 | |
8e5fb5ea |
773 | if (anObj->GlobalSelOwner() == theOwner) |
774 | { |
775 | if (!myObjects.IsBound (anObj)) |
776 | return Standard_False; |
777 | |
778 | return myObjects (anObj)->IsHilighted(); |
779 | } |
780 | |
8d2c79f4 |
781 | const Handle(Prs3d_Drawer)& aStyle = getSelStyle (anObj, theOwner); |
782 | const Standard_Integer aHiMode = getHilightMode (anObj, aStyle, -1); |
783 | return theOwner->IsHilighted (myMainPM, aHiMode); |
8e5fb5ea |
784 | } |
785 | |
786 | //======================================================================= |
787 | //function : HighlightStyle |
788 | //purpose : |
789 | //======================================================================= |
790 | Standard_Boolean AIS_InteractiveContext::HighlightStyle (const Handle(AIS_InteractiveObject)& theObj, |
f838dac4 |
791 | Handle(Prs3d_Drawer)& theStyle) const |
8e5fb5ea |
792 | { |
68dcee02 |
793 | const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theObj); |
794 | if (aStatus != NULL |
795 | && (*aStatus)->IsHilighted()) |
8e5fb5ea |
796 | { |
68dcee02 |
797 | theStyle = (*aStatus)->HilightStyle(); |
8e5fb5ea |
798 | return Standard_True; |
799 | } |
68dcee02 |
800 | |
801 | theStyle.Nullify(); |
802 | return Standard_False; |
8e5fb5ea |
803 | } |
c3282ec1 |
804 | |
8e5fb5ea |
805 | //======================================================================= |
806 | //function : HighlightStyle |
807 | //purpose : |
808 | //======================================================================= |
809 | Standard_Boolean AIS_InteractiveContext::HighlightStyle (const Handle(SelectMgr_EntityOwner)& theOwner, |
f838dac4 |
810 | Handle(Prs3d_Drawer)& theStyle) const |
8e5fb5ea |
811 | { |
812 | if (theOwner.IsNull() || !theOwner->HasSelectable()) |
813 | return Standard_False; |
814 | |
815 | if (IsHilighted (theOwner)) |
c3282ec1 |
816 | { |
8e5fb5ea |
817 | const Handle(AIS_InteractiveObject) anObj = |
818 | Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()); |
819 | if (anObj->GlobalSelOwner() == theOwner) |
c3282ec1 |
820 | { |
8e5fb5ea |
821 | theStyle = myObjects (anObj)->HilightStyle(); |
c3282ec1 |
822 | } |
823 | else |
824 | { |
8e5fb5ea |
825 | // since part selection style is not stored in global status, |
826 | // check if the object has own selection style. If not, it can |
827 | // only be highlighted with default selection style (because |
828 | // sub-intensity does not modify any selection states) |
f838dac4 |
829 | theStyle = getSelStyle (anObj, theOwner); |
c3282ec1 |
830 | } |
c3282ec1 |
831 | return Standard_True; |
832 | } |
8e5fb5ea |
833 | else |
834 | { |
835 | theStyle.Nullify(); |
836 | return Standard_False; |
837 | } |
c3282ec1 |
838 | } |
7fd59977 |
839 | |
840 | //======================================================================= |
841 | //function : IsDisplayed |
842 | //purpose : |
843 | //======================================================================= |
844 | |
68dcee02 |
845 | Standard_Boolean AIS_InteractiveContext::IsDisplayed(const Handle(AIS_InteractiveObject)& theObj) const |
7fd59977 |
846 | { |
68dcee02 |
847 | if(theObj.IsNull()) return Standard_False; |
7fd59977 |
848 | |
68dcee02 |
849 | const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theObj); |
850 | return aStatus != NULL |
39e6123e |
851 | && theObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed; |
7fd59977 |
852 | } |
7fd59977 |
853 | |
854 | //======================================================================= |
855 | //function : IsDisplayed |
2195ab96 |
856 | //purpose : |
7fd59977 |
857 | //======================================================================= |
2195ab96 |
858 | Standard_Boolean AIS_InteractiveContext::IsDisplayed (const Handle(AIS_InteractiveObject)& theIObj, |
859 | const Standard_Integer theMode) const |
7fd59977 |
860 | { |
2195ab96 |
861 | if (theIObj.IsNull()) |
862 | { |
863 | return Standard_False; |
864 | } |
865 | |
68dcee02 |
866 | const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theIObj); |
867 | return aStatus != NULL |
39e6123e |
868 | && theIObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed |
68dcee02 |
869 | && (*aStatus)->DisplayMode() == theMode; |
7fd59977 |
870 | } |
871 | |
7fd59977 |
872 | //======================================================================= |
873 | //function : DisplayPriority |
2195ab96 |
874 | //purpose : |
7fd59977 |
875 | //======================================================================= |
e463b2f6 |
876 | Graphic3d_DisplayPriority AIS_InteractiveContext::DisplayPriority (const Handle(AIS_InteractiveObject)& theIObj) const |
7fd59977 |
877 | { |
2195ab96 |
878 | if (theIObj.IsNull()) |
879 | { |
e463b2f6 |
880 | return Graphic3d_DisplayPriority_INVALID; |
2195ab96 |
881 | } |
eb4320f2 |
882 | |
68dcee02 |
883 | const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theIObj); |
884 | if (aStatus != NULL |
39e6123e |
885 | && (theIObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed |
886 | || theIObj->DisplayStatus() == PrsMgr_DisplayStatus_Erased)) |
eb4320f2 |
887 | { |
2195ab96 |
888 | Standard_Integer aDispMode = theIObj->HasDisplayMode() |
889 | ? theIObj->DisplayMode() |
f838dac4 |
890 | : (theIObj->AcceptDisplayMode (myDefaultDrawer->DisplayMode()) |
891 | ? myDefaultDrawer->DisplayMode() |
2195ab96 |
892 | : 0); |
893 | return myMainPM->DisplayPriority (theIObj, aDispMode); |
7fd59977 |
894 | } |
e463b2f6 |
895 | return Graphic3d_DisplayPriority_INVALID; |
7fd59977 |
896 | } |
2195ab96 |
897 | |
7fd59977 |
898 | //======================================================================= |
899 | //function : SetDisplayPriority |
2195ab96 |
900 | //purpose : |
7fd59977 |
901 | //======================================================================= |
2195ab96 |
902 | void AIS_InteractiveContext::SetDisplayPriority (const Handle(AIS_InteractiveObject)& theIObj, |
e463b2f6 |
903 | const Graphic3d_DisplayPriority thePriority) |
7fd59977 |
904 | { |
2195ab96 |
905 | if (theIObj.IsNull()) |
906 | { |
7fd59977 |
907 | return; |
2195ab96 |
908 | } |
909 | |
2ec85268 |
910 | setContextToObject (theIObj); |
68dcee02 |
911 | const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theIObj); |
912 | if (aStatus != NULL |
39e6123e |
913 | && (theIObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed |
914 | || theIObj->DisplayStatus() == PrsMgr_DisplayStatus_Erased)) |
2195ab96 |
915 | { |
68dcee02 |
916 | Standard_Integer aDisplayMode = theIObj->HasDisplayMode() |
917 | ? theIObj->DisplayMode() |
918 | : (theIObj->AcceptDisplayMode (myDefaultDrawer->DisplayMode()) |
919 | ? myDefaultDrawer->DisplayMode() |
920 | : 0); |
921 | myMainPM->SetDisplayPriority (theIObj, aDisplayMode, thePriority); |
eb4320f2 |
922 | } |
7fd59977 |
923 | } |
924 | |
925 | //======================================================================= |
926 | //function : Redisplay |
2195ab96 |
927 | //purpose : |
7fd59977 |
928 | //======================================================================= |
2195ab96 |
929 | void AIS_InteractiveContext::Redisplay (const Handle(AIS_InteractiveObject)& theIObj, |
930 | const Standard_Boolean theToUpdateViewer, |
931 | const Standard_Boolean theAllModes) |
7fd59977 |
932 | { |
2195ab96 |
933 | RecomputePrsOnly (theIObj, theToUpdateViewer, theAllModes); |
934 | RecomputeSelectionOnly (theIObj); |
7fd59977 |
935 | } |
936 | |
937 | //======================================================================= |
938 | //function : Redisplay |
2195ab96 |
939 | //purpose : |
7fd59977 |
940 | //======================================================================= |
2195ab96 |
941 | void AIS_InteractiveContext::Redisplay (const AIS_KindOfInteractive theKOI, |
942 | const Standard_Integer /*theSign*/, |
943 | const Standard_Boolean theToUpdateViewer) |
944 | { |
945 | Standard_Boolean isRedisplayed = Standard_False; |
946 | for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next()) |
947 | { |
b2fedee6 |
948 | const Handle(AIS_InteractiveObject)& anObj = anObjIter.Key(); |
2195ab96 |
949 | if (anObj->Type() != theKOI) |
950 | { |
951 | continue; |
7fd59977 |
952 | } |
2195ab96 |
953 | |
954 | Redisplay (anObj, Standard_False); |
39e6123e |
955 | isRedisplayed = anObjIter.Key()->DisplayStatus() == PrsMgr_DisplayStatus_Displayed |
2195ab96 |
956 | || isRedisplayed; |
7fd59977 |
957 | } |
2195ab96 |
958 | |
959 | if (theToUpdateViewer |
960 | && isRedisplayed) |
eb4320f2 |
961 | { |
962 | myMainVwr->Update(); |
7fd59977 |
963 | } |
964 | } |
965 | |
7fd59977 |
966 | //======================================================================= |
967 | //function : RecomputePrsOnly |
2195ab96 |
968 | //purpose : |
7fd59977 |
969 | //======================================================================= |
2195ab96 |
970 | void AIS_InteractiveContext::RecomputePrsOnly (const Handle(AIS_InteractiveObject)& theIObj, |
971 | const Standard_Boolean theToUpdateViewer, |
972 | const Standard_Boolean theAllModes) |
7fd59977 |
973 | { |
2195ab96 |
974 | if (theIObj.IsNull()) |
975 | { |
976 | return; |
977 | } |
eb4320f2 |
978 | |
226fce20 |
979 | theIObj->SetToUpdate(); |
980 | theIObj->UpdatePresentations (theAllModes); |
2195ab96 |
981 | if (!theToUpdateViewer) |
eb4320f2 |
982 | { |
983 | return; |
984 | } |
985 | |
68dcee02 |
986 | const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theIObj); |
987 | if (aStatus != NULL |
39e6123e |
988 | && theIObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed) |
eb4320f2 |
989 | { |
990 | myMainVwr->Update(); |
7fd59977 |
991 | } |
992 | } |
993 | //======================================================================= |
994 | //function : RecomputeSelectionOnly |
995 | //purpose : |
996 | //======================================================================= |
bc677575 |
997 | void AIS_InteractiveContext::RecomputeSelectionOnly (const Handle(AIS_InteractiveObject)& theIO) |
7fd59977 |
998 | { |
bc677575 |
999 | if (theIO.IsNull()) |
1000 | { |
1001 | return; |
1002 | } |
7fd59977 |
1003 | |
2182812a |
1004 | TColStd_ListOfInteger aModes; |
1005 | ActivatedModes (theIO, aModes); |
1006 | |
1007 | for (TColStd_ListIteratorOfListOfInteger aModesIter (aModes); aModesIter.More(); aModesIter.Next()) |
1008 | { |
1009 | mgrSelector->Deactivate (theIO, aModesIter.Value()); |
1010 | } |
1011 | |
bc677575 |
1012 | mgrSelector->RecomputeSelection (theIO); |
0d969553 |
1013 | |
68dcee02 |
1014 | const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theIO); |
1015 | if (aStatus == NULL |
39e6123e |
1016 | || theIO->DisplayStatus() != PrsMgr_DisplayStatus_Displayed) |
bc677575 |
1017 | { |
1018 | return; |
1019 | } |
1020 | |
2182812a |
1021 | for (TColStd_ListIteratorOfListOfInteger aModesIter (aModes); aModesIter.More(); aModesIter.Next()) |
bc677575 |
1022 | { |
68dcee02 |
1023 | mgrSelector->Activate (theIO, aModesIter.Value()); |
7fd59977 |
1024 | } |
1025 | } |
1026 | |
1027 | //======================================================================= |
1028 | //function : Update |
2195ab96 |
1029 | //purpose : |
7fd59977 |
1030 | //======================================================================= |
f3889691 |
1031 | void AIS_InteractiveContext::Update (const Handle(AIS_InteractiveObject)& theIObj, |
2195ab96 |
1032 | const Standard_Boolean theUpdateViewer) |
7fd59977 |
1033 | { |
f3889691 |
1034 | if (theIObj.IsNull()) |
1035 | { |
1036 | return; |
1037 | } |
7fd59977 |
1038 | |
226fce20 |
1039 | theIObj->UpdatePresentations(); |
f3889691 |
1040 | mgrSelector->Update(theIObj); |
1041 | |
1042 | if (theUpdateViewer) |
1043 | { |
68dcee02 |
1044 | const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theIObj); |
1045 | if (aStatus != NULL |
39e6123e |
1046 | && theIObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed) |
f3889691 |
1047 | { |
68dcee02 |
1048 | myMainVwr->Update(); |
7fd59977 |
1049 | } |
1050 | } |
1051 | } |
1052 | |
7fd59977 |
1053 | //======================================================================= |
1054 | //function : SetLocation |
2195ab96 |
1055 | //purpose : |
7fd59977 |
1056 | //======================================================================= |
2195ab96 |
1057 | void AIS_InteractiveContext::SetLocation (const Handle(AIS_InteractiveObject)& theIObj, |
1058 | const TopLoc_Location& theLoc) |
7fd59977 |
1059 | { |
2195ab96 |
1060 | if (theIObj.IsNull()) |
1061 | { |
1062 | return; |
1063 | } |
7fd59977 |
1064 | |
2195ab96 |
1065 | if (theIObj->HasTransformation() |
1066 | && theLoc.IsIdentity()) |
1067 | { |
1068 | theIObj->ResetTransformation(); |
1069 | mgrSelector->Update (theIObj, Standard_False); |
1070 | return; |
1071 | } |
1072 | else if (theLoc.IsIdentity()) |
1073 | { |
7fd59977 |
1074 | return; |
1075 | } |
7fd59977 |
1076 | |
0d969553 |
1077 | // first reset the previous location to properly clean everything... |
2195ab96 |
1078 | if (theIObj->HasTransformation()) |
1079 | { |
1080 | theIObj->ResetTransformation(); |
1081 | } |
7fd59977 |
1082 | |
2195ab96 |
1083 | theIObj->SetLocalTransformation (theLoc.Transformation()); |
7fd59977 |
1084 | |
68dcee02 |
1085 | mgrSelector->Update (theIObj, Standard_False); |
5396886c |
1086 | |
1087 | // if the object or its part is highlighted dynamically, it is necessary to apply location transformation |
1088 | // to its highlight structure immediately |
8e5fb5ea |
1089 | if (!myLastPicked.IsNull() && myLastPicked->IsSameSelectable (theIObj)) |
5396886c |
1090 | { |
7bbccb5f |
1091 | const Standard_Integer aHiMod = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0; |
5396886c |
1092 | myLastPicked->UpdateHighlightTrsf (myMainVwr, |
1093 | myMainPM, |
7bbccb5f |
1094 | aHiMod); |
5396886c |
1095 | } |
7fd59977 |
1096 | } |
2195ab96 |
1097 | |
7fd59977 |
1098 | //======================================================================= |
1099 | //function : ResetLocation |
2195ab96 |
1100 | //purpose : |
7fd59977 |
1101 | //======================================================================= |
2195ab96 |
1102 | void AIS_InteractiveContext::ResetLocation (const Handle(AIS_InteractiveObject)& theIObj) |
7fd59977 |
1103 | { |
2195ab96 |
1104 | if (theIObj.IsNull()) |
1105 | { |
1106 | return; |
1107 | } |
7fd59977 |
1108 | |
2195ab96 |
1109 | theIObj->ResetTransformation(); |
1110 | mgrSelector->Update (theIObj, Standard_False); |
7fd59977 |
1111 | } |
1112 | |
1113 | //======================================================================= |
1114 | //function : HasLocation |
2195ab96 |
1115 | //purpose : |
7fd59977 |
1116 | //======================================================================= |
2195ab96 |
1117 | Standard_Boolean AIS_InteractiveContext::HasLocation (const Handle(AIS_InteractiveObject)& theIObj) const |
7fd59977 |
1118 | { |
2195ab96 |
1119 | return !theIObj.IsNull() |
1120 | && theIObj->HasTransformation(); |
7fd59977 |
1121 | } |
1122 | |
2195ab96 |
1123 | //======================================================================= |
1124 | //function : Location |
1125 | //purpose : |
1126 | //======================================================================= |
1127 | TopLoc_Location AIS_InteractiveContext::Location (const Handle(AIS_InteractiveObject)& theIObj) const |
7fd59977 |
1128 | { |
2195ab96 |
1129 | return theIObj->Transformation(); |
7fd59977 |
1130 | } |
1131 | |
7fd59977 |
1132 | //======================================================================= |
1133 | //function : SetDisplayMode |
2195ab96 |
1134 | //purpose : |
7fd59977 |
1135 | //======================================================================= |
e5d7e249 |
1136 | void AIS_InteractiveContext::SetDisplayMode(const Standard_Integer theMode, |
1137 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1138 | { |
f838dac4 |
1139 | if (theMode == myDefaultDrawer->DisplayMode()) |
2195ab96 |
1140 | { |
1141 | return; |
1142 | } |
7fd59977 |
1143 | |
2195ab96 |
1144 | for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next()) |
1145 | { |
1146 | Handle(AIS_InteractiveObject) anObj = anObjIter.Key(); |
1147 | Standard_Boolean toProcess = anObj->IsKind (STANDARD_TYPE(AIS_Shape)) |
1148 | || anObj->IsKind (STANDARD_TYPE(AIS_ConnectedInteractive)) |
1149 | || anObj->IsKind (STANDARD_TYPE(AIS_MultipleConnectedInteractive)); |
7fd59977 |
1150 | |
2195ab96 |
1151 | if (!toProcess |
1152 | || anObj->HasDisplayMode() |
1153 | || !anObj->AcceptDisplayMode (theMode)) |
1154 | { |
1155 | continue; |
1156 | } |
1157 | |
b2fedee6 |
1158 | const Handle(AIS_GlobalStatus)& aStatus = anObjIter.Value(); |
3db69e41 |
1159 | aStatus->SetDisplayMode (theMode); |
2195ab96 |
1160 | |
39e6123e |
1161 | if (anObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed) |
2195ab96 |
1162 | { |
2195ab96 |
1163 | myMainPM->Display (anObj, theMode); |
8e5fb5ea |
1164 | if (!myLastPicked.IsNull() && myLastPicked->IsSameSelectable (anObj)) |
c3282ec1 |
1165 | { |
1166 | myMainPM->BeginImmediateDraw(); |
f838dac4 |
1167 | unhighlightGlobal (anObj); |
c3282ec1 |
1168 | myMainPM->EndImmediateDraw (myMainVwr); |
1169 | } |
2195ab96 |
1170 | if (aStatus->IsSubIntensityOn()) |
7fd59977 |
1171 | { |
8e5fb5ea |
1172 | highlightWithSubintensity (anObj, theMode); |
7fd59977 |
1173 | } |
f838dac4 |
1174 | myMainPM->SetVisibility (anObj, myDefaultDrawer->DisplayMode(), Standard_False); |
2195ab96 |
1175 | } |
1176 | } |
1177 | |
f838dac4 |
1178 | myDefaultDrawer->SetDisplayMode (theMode); |
2195ab96 |
1179 | if (theToUpdateViewer) |
1180 | { |
1181 | myMainVwr->Update(); |
1182 | } |
7fd59977 |
1183 | } |
1184 | |
1185 | //======================================================================= |
1186 | //function : SetDisplayMode |
2195ab96 |
1187 | //purpose : |
7fd59977 |
1188 | //======================================================================= |
2195ab96 |
1189 | void AIS_InteractiveContext::SetDisplayMode (const Handle(AIS_InteractiveObject)& theIObj, |
1190 | const Standard_Integer theMode, |
1191 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1192 | { |
2ec85268 |
1193 | setContextToObject (theIObj); |
2195ab96 |
1194 | if (!myObjects.IsBound (theIObj)) |
1195 | { |
1196 | theIObj->SetDisplayMode (theMode); |
1197 | return; |
1198 | } |
1199 | else if (!theIObj->AcceptDisplayMode (theMode)) |
1200 | { |
1201 | return; |
1202 | } |
eb4320f2 |
1203 | |
2195ab96 |
1204 | Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj); |
39e6123e |
1205 | if (theIObj->DisplayStatus() != PrsMgr_DisplayStatus_Displayed) |
2195ab96 |
1206 | { |
b2bafb33 |
1207 | aStatus->SetDisplayMode (theMode); |
2195ab96 |
1208 | theIObj->SetDisplayMode (theMode); |
1209 | return; |
1210 | } |
a6964ce6 |
1211 | |
2195ab96 |
1212 | // erase presentations for all display modes different from <aMode> |
3db69e41 |
1213 | const Standard_Integer anOldMode = aStatus->DisplayMode(); |
1214 | if (anOldMode != theMode) |
2195ab96 |
1215 | { |
3db69e41 |
1216 | if (myMainPM->IsHighlighted (theIObj, anOldMode)) |
2195ab96 |
1217 | { |
f838dac4 |
1218 | unhighlightGlobal (theIObj); |
7fd59977 |
1219 | } |
3db69e41 |
1220 | myMainPM->SetVisibility (theIObj, anOldMode, Standard_False); |
7fd59977 |
1221 | } |
2195ab96 |
1222 | |
3db69e41 |
1223 | aStatus->SetDisplayMode (theMode); |
2195ab96 |
1224 | |
1225 | myMainPM->Display (theIObj, theMode); |
2195ab96 |
1226 | if (aStatus->IsHilighted()) |
1227 | { |
f838dac4 |
1228 | highlightGlobal (theIObj, getSelStyle (theIObj, theIObj->GlobalSelOwner()), theMode); |
2195ab96 |
1229 | } |
1230 | if (aStatus->IsSubIntensityOn()) |
1231 | { |
8e5fb5ea |
1232 | highlightWithSubintensity (theIObj, theMode); |
2195ab96 |
1233 | } |
1234 | |
1235 | if (theToUpdateViewer) |
1236 | { |
1237 | myMainVwr->Update(); |
1238 | } |
1239 | theIObj->SetDisplayMode (theMode); |
7fd59977 |
1240 | } |
1241 | |
1242 | //======================================================================= |
1243 | //function : UnsetDisplayMode |
2195ab96 |
1244 | //purpose : |
7fd59977 |
1245 | //======================================================================= |
2195ab96 |
1246 | void AIS_InteractiveContext::UnsetDisplayMode (const Handle(AIS_InteractiveObject)& theIObj, |
1247 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1248 | { |
2195ab96 |
1249 | if (theIObj.IsNull() |
1250 | || !theIObj->HasDisplayMode()) |
1251 | { |
1252 | return; |
1253 | } |
1254 | |
1255 | if (!myObjects.IsBound (theIObj)) |
1256 | { |
1257 | theIObj->UnsetDisplayMode(); |
1258 | return; |
1259 | } |
1260 | |
1261 | const Standard_Integer anOldMode = theIObj->DisplayMode(); |
f838dac4 |
1262 | if (myDefaultDrawer->DisplayMode() == anOldMode) |
2195ab96 |
1263 | { |
1264 | return; |
1265 | } |
1266 | |
1267 | const Handle(AIS_GlobalStatus)& aStatus = myObjects (theIObj); |
f838dac4 |
1268 | aStatus->SetDisplayMode (myDefaultDrawer->DisplayMode()); |
2195ab96 |
1269 | |
39e6123e |
1270 | if (theIObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed) |
2195ab96 |
1271 | { |
1272 | if (myMainPM->IsHighlighted (theIObj, anOldMode)) |
7fd59977 |
1273 | { |
f838dac4 |
1274 | unhighlightGlobal (theIObj); |
2195ab96 |
1275 | } |
1276 | myMainPM->SetVisibility (theIObj, anOldMode, Standard_False); |
f838dac4 |
1277 | myMainPM->Display (theIObj, myDefaultDrawer->DisplayMode()); |
2195ab96 |
1278 | if (aStatus->IsHilighted()) |
1279 | { |
8e5fb5ea |
1280 | highlightSelected (theIObj->GlobalSelOwner()); |
2195ab96 |
1281 | } |
1282 | if (aStatus->IsSubIntensityOn()) |
1283 | { |
f838dac4 |
1284 | highlightWithSubintensity (theIObj, myDefaultDrawer->DisplayMode()); |
7fd59977 |
1285 | } |
2195ab96 |
1286 | |
1287 | if (theToUpdateViewer) |
1288 | { |
1289 | myMainVwr->Update(); |
1290 | } |
1291 | } |
1292 | |
1293 | theIObj->UnsetDisplayMode(); |
7fd59977 |
1294 | } |
1295 | |
1296 | //======================================================================= |
1297 | //function : SetCurrentFacingModel |
2195ab96 |
1298 | //purpose : |
7fd59977 |
1299 | //======================================================================= |
2195ab96 |
1300 | void AIS_InteractiveContext::SetCurrentFacingModel (const Handle(AIS_InteractiveObject)& theIObj, |
1301 | const Aspect_TypeOfFacingModel theModel) |
b8ddfc2f |
1302 | { |
2195ab96 |
1303 | if (!theIObj.IsNull()) |
1304 | { |
1305 | theIObj->SetCurrentFacingModel (theModel); |
1306 | } |
7fd59977 |
1307 | } |
7fd59977 |
1308 | |
2195ab96 |
1309 | //======================================================================= |
1310 | //function : SetColor |
1311 | //purpose : |
1312 | //======================================================================= |
1313 | void AIS_InteractiveContext::SetColor (const Handle(AIS_InteractiveObject)& theIObj, |
1314 | const Quantity_Color& theColor, |
1315 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1316 | { |
2195ab96 |
1317 | if (theIObj.IsNull()) |
1318 | { |
1319 | return; |
1320 | } |
7fd59977 |
1321 | |
2ec85268 |
1322 | setContextToObject (theIObj); |
2195ab96 |
1323 | theIObj->SetColor (theColor); |
226fce20 |
1324 | theIObj->UpdatePresentations(); |
1325 | if (theToUpdateViewer) |
1326 | { |
1327 | UpdateCurrentViewer(); |
1328 | } |
2195ab96 |
1329 | } |
7fd59977 |
1330 | |
5ad8c033 |
1331 | //======================================================================= |
1332 | //function : SetIsoOnTriangulation |
1333 | //purpose : |
1334 | //======================================================================= |
1335 | void AIS_InteractiveContext::IsoOnTriangulation (const Standard_Boolean theIsEnabled, |
1336 | const Handle(AIS_InteractiveObject)& theObject) |
1337 | { |
1338 | if (theObject.IsNull()) |
1339 | { |
1340 | return; |
1341 | } |
1342 | |
1343 | theObject->SetIsoOnTriangulation (theIsEnabled); |
1344 | } |
1345 | |
2195ab96 |
1346 | //======================================================================= |
1347 | //function : SetDeviationCoefficient |
1348 | //purpose : |
1349 | //======================================================================= |
1350 | void AIS_InteractiveContext::SetDeviationCoefficient (const Handle(AIS_InteractiveObject)& theIObj, |
1351 | const Standard_Real theCoefficient, |
1352 | const Standard_Boolean theToUpdateViewer) |
1353 | { |
1354 | if (theIObj.IsNull()) |
1355 | { |
1356 | return; |
1357 | } |
7fd59977 |
1358 | |
2195ab96 |
1359 | // to be modified after the related methods of AIS_Shape are passed to InteractiveObject |
2ec85268 |
1360 | setContextToObject (theIObj); |
82b856b8 |
1361 | if (theIObj->Type() != AIS_KindOfInteractive_Object |
1362 | && theIObj->Type() != AIS_KindOfInteractive_Shape) |
2195ab96 |
1363 | { |
1364 | return; |
1365 | } |
1366 | else if (theIObj->Signature() != 0) |
1367 | { |
1368 | return; |
1369 | } |
1370 | |
1371 | Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj); |
1372 | aShape->SetOwnDeviationCoefficient (theCoefficient); |
226fce20 |
1373 | aShape->UpdatePresentations(); |
1374 | if (theToUpdateViewer) |
1375 | { |
1376 | UpdateCurrentViewer(); |
1377 | } |
7fd59977 |
1378 | } |
1379 | |
7fd59977 |
1380 | //======================================================================= |
1381 | //function : SetDeviationAngle |
2195ab96 |
1382 | //purpose : |
7fd59977 |
1383 | //======================================================================= |
2195ab96 |
1384 | void AIS_InteractiveContext::SetDeviationAngle (const Handle(AIS_InteractiveObject)& theIObj, |
1385 | const Standard_Real theAngle, |
1386 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1387 | { |
2195ab96 |
1388 | if (theIObj.IsNull()) |
1389 | { |
1390 | return; |
1391 | } |
1392 | |
e33e7e78 |
1393 | // To be modified after the related methods of AIS_Shape are passed to InteractiveObject |
2ec85268 |
1394 | setContextToObject (theIObj); |
82b856b8 |
1395 | if (theIObj->Type() != AIS_KindOfInteractive_Shape) |
2195ab96 |
1396 | { |
1397 | return; |
1398 | } |
1399 | else if (theIObj->Signature() != 0) |
1400 | { |
1401 | return; |
1402 | } |
7fd59977 |
1403 | |
2195ab96 |
1404 | Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj); |
1405 | aShape->SetOwnDeviationAngle (theAngle); |
226fce20 |
1406 | aShape->UpdatePresentations(); |
1407 | if (theToUpdateViewer) |
1408 | { |
1409 | UpdateCurrentViewer(); |
1410 | } |
7fd59977 |
1411 | } |
2195ab96 |
1412 | |
7fd59977 |
1413 | //======================================================================= |
2195ab96 |
1414 | //function : SetAngleAndDeviation |
1415 | //purpose : |
7fd59977 |
1416 | //======================================================================= |
2195ab96 |
1417 | void AIS_InteractiveContext::SetAngleAndDeviation (const Handle(AIS_InteractiveObject)& theIObj, |
1418 | const Standard_Real theAngle, |
1419 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1420 | { |
2195ab96 |
1421 | if (theIObj.IsNull()) |
1422 | { |
1423 | return; |
1424 | } |
1425 | |
e33e7e78 |
1426 | // To be modified after the related methods of AIS_Shape are passed to InteractiveObject |
2ec85268 |
1427 | setContextToObject (theIObj); |
82b856b8 |
1428 | if (theIObj->Type() != AIS_KindOfInteractive_Shape) |
2195ab96 |
1429 | { |
1430 | return; |
1431 | } |
1432 | if (theIObj->Signature() != 0) |
1433 | { |
1434 | return; |
1435 | } |
7fd59977 |
1436 | |
2195ab96 |
1437 | Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj); |
1438 | aShape->SetAngleAndDeviation (theAngle); |
226fce20 |
1439 | aShape->UpdatePresentations(); |
1440 | if (theToUpdateViewer) |
2195ab96 |
1441 | { |
226fce20 |
1442 | UpdateCurrentViewer(); |
226fce20 |
1443 | } |
7fd59977 |
1444 | } |
1445 | |
1446 | //======================================================================= |
1447 | //function : UnsetColor |
2195ab96 |
1448 | //purpose : |
7fd59977 |
1449 | //======================================================================= |
2195ab96 |
1450 | void AIS_InteractiveContext::UnsetColor (const Handle(AIS_InteractiveObject)& theIObj, |
1451 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1452 | { |
2195ab96 |
1453 | if (theIObj.IsNull()) |
1454 | { |
1455 | return; |
1456 | } |
1457 | |
1458 | theIObj->UnsetColor(); |
226fce20 |
1459 | theIObj->UpdatePresentations(); |
1460 | if (theToUpdateViewer) |
1461 | { |
1462 | UpdateCurrentViewer(); |
1463 | } |
7fd59977 |
1464 | } |
1465 | |
1466 | //======================================================================= |
1467 | //function : HasColor |
2195ab96 |
1468 | //purpose : |
7fd59977 |
1469 | //======================================================================= |
2195ab96 |
1470 | Standard_Boolean AIS_InteractiveContext::HasColor (const Handle(AIS_InteractiveObject)& theIObj) const |
7fd59977 |
1471 | { |
2195ab96 |
1472 | return theIObj->HasColor(); |
7fd59977 |
1473 | } |
1474 | |
2195ab96 |
1475 | //======================================================================= |
1476 | //function : Color |
1477 | //purpose : |
1478 | //======================================================================= |
1479 | void AIS_InteractiveContext::Color (const Handle(AIS_InteractiveObject)& theIObj, |
1480 | Quantity_Color& theColor) const |
7fd59977 |
1481 | { |
2195ab96 |
1482 | theIObj->Color (theColor); |
7fd59977 |
1483 | } |
7fd59977 |
1484 | |
1485 | //======================================================================= |
1486 | //function : Width |
2195ab96 |
1487 | //purpose : |
7fd59977 |
1488 | //======================================================================= |
2195ab96 |
1489 | Standard_Real AIS_InteractiveContext::Width (const Handle(AIS_InteractiveObject)& theIObj) const |
7fd59977 |
1490 | { |
2195ab96 |
1491 | return theIObj->Width(); |
7fd59977 |
1492 | } |
1493 | |
1494 | //======================================================================= |
1495 | //function : SetWidth |
2195ab96 |
1496 | //purpose : |
7fd59977 |
1497 | //======================================================================= |
2195ab96 |
1498 | void AIS_InteractiveContext::SetWidth (const Handle(AIS_InteractiveObject)& theIObj, |
1499 | const Standard_Real theWidth, |
1500 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1501 | { |
2195ab96 |
1502 | if (theIObj.IsNull()) |
1503 | { |
1504 | return; |
1505 | } |
1506 | |
2ec85268 |
1507 | setContextToObject (theIObj); |
2195ab96 |
1508 | theIObj->SetWidth (theWidth); |
226fce20 |
1509 | theIObj->UpdatePresentations(); |
a9080ef9 |
1510 | if (!myLastPicked.IsNull() && myLastPicked->IsSameSelectable (theIObj)) |
c3282ec1 |
1511 | { |
a9080ef9 |
1512 | if (myLastPicked->IsAutoHilight()) |
c3282ec1 |
1513 | { |
f838dac4 |
1514 | const Standard_Integer aHiMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0; |
a9080ef9 |
1515 | myLastPicked->HilightWithColor (myMainPM, |
1516 | myLastPicked->IsSelected() ? getSelStyle (theIObj, myLastPicked) : getHiStyle (theIObj, myLastPicked), |
8e5fb5ea |
1517 | aHiMode); |
c3282ec1 |
1518 | } |
1519 | else |
1520 | { |
8e5fb5ea |
1521 | theIObj->HilightOwnerWithColor (myMainPM, |
a9080ef9 |
1522 | myLastPicked->IsSelected() ? getSelStyle (theIObj, myLastPicked) : getHiStyle (theIObj, myLastPicked), |
1523 | myLastPicked); |
c3282ec1 |
1524 | } |
1525 | } |
226fce20 |
1526 | if (theToUpdateViewer) |
1527 | { |
1528 | UpdateCurrentViewer(); |
1529 | } |
7fd59977 |
1530 | } |
1531 | |
1532 | //======================================================================= |
1533 | //function : UnsetWidth |
2195ab96 |
1534 | //purpose : |
7fd59977 |
1535 | //======================================================================= |
2195ab96 |
1536 | void AIS_InteractiveContext::UnsetWidth (const Handle(AIS_InteractiveObject)& theIObj, |
1537 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1538 | { |
2195ab96 |
1539 | if (theIObj.IsNull()) |
1540 | { |
1541 | return; |
1542 | } |
1543 | |
1544 | theIObj->UnsetWidth(); |
226fce20 |
1545 | theIObj->UpdatePresentations(); |
1546 | if (theToUpdateViewer) |
1547 | { |
1548 | UpdateCurrentViewer(); |
1549 | } |
7fd59977 |
1550 | } |
1551 | |
1552 | //======================================================================= |
1553 | //function : SetMaterial |
2195ab96 |
1554 | //purpose : |
7fd59977 |
1555 | //======================================================================= |
2195ab96 |
1556 | void AIS_InteractiveContext::SetMaterial (const Handle(AIS_InteractiveObject)& theIObj, |
87432b82 |
1557 | const Graphic3d_MaterialAspect& theMaterial, |
2195ab96 |
1558 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1559 | { |
2195ab96 |
1560 | if (theIObj.IsNull()) |
1561 | { |
1562 | return; |
1563 | } |
1564 | |
2ec85268 |
1565 | setContextToObject (theIObj); |
87432b82 |
1566 | theIObj->SetMaterial (theMaterial); |
226fce20 |
1567 | theIObj->UpdatePresentations(); |
1568 | if (theToUpdateViewer) |
1569 | { |
1570 | UpdateCurrentViewer(); |
1571 | } |
7fd59977 |
1572 | } |
1573 | |
1574 | //======================================================================= |
1575 | //function : UnsetMaterial |
2195ab96 |
1576 | //purpose : |
7fd59977 |
1577 | //======================================================================= |
2195ab96 |
1578 | void AIS_InteractiveContext::UnsetMaterial (const Handle(AIS_InteractiveObject)& theIObj, |
1579 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1580 | { |
2195ab96 |
1581 | if (theIObj.IsNull()) |
1582 | { |
1583 | return; |
1584 | } |
1585 | theIObj->UnsetMaterial(); |
226fce20 |
1586 | theIObj->UpdatePresentations(); |
1587 | if (theToUpdateViewer) |
1588 | { |
1589 | UpdateCurrentViewer(); |
1590 | } |
7fd59977 |
1591 | } |
1592 | |
1593 | //======================================================================= |
1594 | //function : SetTransparency |
2195ab96 |
1595 | //purpose : |
7fd59977 |
1596 | //======================================================================= |
2195ab96 |
1597 | void AIS_InteractiveContext::SetTransparency (const Handle(AIS_InteractiveObject)& theIObj, |
1598 | const Standard_Real theValue, |
1599 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1600 | { |
2195ab96 |
1601 | if (theIObj.IsNull()) |
1602 | { |
1603 | return; |
1604 | } |
1605 | |
2ec85268 |
1606 | setContextToObject (theIObj); |
2195ab96 |
1607 | if (!theIObj->IsTransparent() |
f838dac4 |
1608 | && theValue <= 0.005) |
a6964ce6 |
1609 | { |
1610 | return; |
1611 | } |
1612 | |
f838dac4 |
1613 | if (theValue <= 0.005) |
2195ab96 |
1614 | { |
1615 | UnsetTransparency (theIObj, theToUpdateViewer); |
7fd59977 |
1616 | return; |
1617 | } |
a6964ce6 |
1618 | |
2195ab96 |
1619 | theIObj->SetTransparency (theValue); |
226fce20 |
1620 | theIObj->UpdatePresentations(); |
1621 | if (theToUpdateViewer) |
1622 | { |
1623 | UpdateCurrentViewer(); |
1624 | } |
7fd59977 |
1625 | } |
1626 | |
1627 | //======================================================================= |
1628 | //function : UnsetTransparency |
2195ab96 |
1629 | //purpose : |
7fd59977 |
1630 | //======================================================================= |
2195ab96 |
1631 | void AIS_InteractiveContext::UnsetTransparency (const Handle(AIS_InteractiveObject)& theIObj, |
1632 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1633 | { |
2195ab96 |
1634 | if (theIObj.IsNull()) |
1635 | { |
1636 | return; |
1637 | } |
7fd59977 |
1638 | |
2195ab96 |
1639 | theIObj->UnsetTransparency(); |
226fce20 |
1640 | theIObj->UpdatePresentations(); |
1641 | if (theToUpdateViewer) |
1642 | { |
1643 | UpdateCurrentViewer(); |
1644 | } |
7fd59977 |
1645 | } |
1646 | |
2195ab96 |
1647 | //======================================================================= |
1648 | //function : SetSelectedAspect |
1649 | //purpose : |
1650 | //======================================================================= |
1651 | void AIS_InteractiveContext::SetSelectedAspect (const Handle(Prs3d_BasicAspect)& theAspect, |
2195ab96 |
1652 | const Standard_Boolean theToUpdateViewer) |
1653 | { |
2b886265 |
1654 | Standard_DISABLE_DEPRECATION_WARNINGS |
2195ab96 |
1655 | Standard_Boolean isFound = Standard_False; |
02974a19 |
1656 | for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next()) |
2195ab96 |
1657 | { |
1658 | isFound = Standard_True; |
02974a19 |
1659 | Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (aSelIter.Value()->Selectable()); |
2831708b |
1660 | anObj->SetAspect (theAspect); |
2195ab96 |
1661 | } |
2b886265 |
1662 | Standard_ENABLE_DEPRECATION_WARNINGS |
2195ab96 |
1663 | |
016e5959 |
1664 | if (isFound && theToUpdateViewer) |
2195ab96 |
1665 | { |
1666 | myMainVwr->Update(); |
7fd59977 |
1667 | } |
1668 | } |
7fd59977 |
1669 | |
1670 | //======================================================================= |
1671 | //function : SetLocalAttributes |
2195ab96 |
1672 | //purpose : |
7fd59977 |
1673 | //======================================================================= |
2195ab96 |
1674 | void AIS_InteractiveContext::SetLocalAttributes (const Handle(AIS_InteractiveObject)& theIObj, |
6262338c |
1675 | const Handle(Prs3d_Drawer)& theDrawer, |
2195ab96 |
1676 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1677 | { |
2195ab96 |
1678 | if (theIObj.IsNull()) |
1679 | { |
1680 | return; |
1681 | } |
1682 | |
2ec85268 |
1683 | setContextToObject (theIObj); |
2195ab96 |
1684 | theIObj->SetAttributes (theDrawer); |
1685 | Update (theIObj, theToUpdateViewer); |
7fd59977 |
1686 | } |
1687 | |
1688 | //======================================================================= |
1689 | //function : UnsetLocalAttributes |
2195ab96 |
1690 | //purpose : |
7fd59977 |
1691 | //======================================================================= |
2195ab96 |
1692 | void AIS_InteractiveContext::UnsetLocalAttributes (const Handle(AIS_InteractiveObject)& theIObj, |
1693 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1694 | { |
2195ab96 |
1695 | if (theIObj.IsNull()) |
1696 | { |
1697 | return; |
1698 | } |
7fd59977 |
1699 | |
2ec85268 |
1700 | setContextToObject (theIObj); |
2195ab96 |
1701 | theIObj->UnsetAttributes(); |
1702 | Update (theIObj, theToUpdateViewer); |
1703 | } |
7fd59977 |
1704 | |
1705 | //======================================================================= |
1706 | //function : Status |
2195ab96 |
1707 | //purpose : |
7fd59977 |
1708 | //======================================================================= |
2195ab96 |
1709 | void AIS_InteractiveContext::Status (const Handle(AIS_InteractiveObject)& theIObj, |
1710 | TCollection_ExtendedString& theStatus) const |
7fd59977 |
1711 | { |
2195ab96 |
1712 | theStatus = ""; |
1713 | if (theIObj.IsNull() |
1714 | || !myObjects.IsBound (theIObj)) |
1715 | { |
1716 | return; |
1717 | } |
7fd59977 |
1718 | |
2195ab96 |
1719 | theStatus += "\t ____________________________________________"; |
1720 | theStatus += "\t| Known at Neutral Point:\n\tDisplayStatus:"; |
1721 | const Handle(AIS_GlobalStatus)& aStatus = myObjects (theIObj); |
39e6123e |
1722 | switch (theIObj->DisplayStatus()) |
2195ab96 |
1723 | { |
39e6123e |
1724 | case PrsMgr_DisplayStatus_Displayed: |
2195ab96 |
1725 | { |
1726 | theStatus += "\t| -->Displayed\n"; |
7fd59977 |
1727 | break; |
1728 | } |
39e6123e |
1729 | case PrsMgr_DisplayStatus_Erased: |
2195ab96 |
1730 | { |
1731 | theStatus += "\t| -->Erased\n"; |
1732 | break; |
7fd59977 |
1733 | } |
2195ab96 |
1734 | default: |
1735 | break; |
1736 | } |
1737 | |
1738 | theStatus += "\t| Active Display Modes in the MainViewer :\n"; |
3db69e41 |
1739 | theStatus += "\t|\t Mode "; |
1740 | theStatus += TCollection_AsciiString (aStatus->DisplayMode()); |
1741 | theStatus += "\n"; |
1742 | |
2195ab96 |
1743 | if (IsSelected(theIObj)) theStatus +="\t| Selected\n"; |
7fd59977 |
1744 | |
2195ab96 |
1745 | theStatus += "\t| Active Selection Modes in the MainViewer :\n"; |
1746 | for (TColStd_ListIteratorOfListOfInteger aSelModeIter (aStatus->SelectionModes()); aSelModeIter.More(); aSelModeIter.Next()) |
1747 | { |
1748 | theStatus += "\t\t Mode "; |
1749 | theStatus += TCollection_AsciiString (aSelModeIter.Value()); |
1750 | theStatus += "\n"; |
1751 | } |
1752 | theStatus += "\t ____________________________________________"; |
1753 | } |
7fd59977 |
1754 | |
1755 | //======================================================================= |
1756 | //function : GetDefModes |
2195ab96 |
1757 | //purpose : |
7fd59977 |
1758 | //======================================================================= |
2195ab96 |
1759 | void AIS_InteractiveContext::GetDefModes (const Handle(AIS_InteractiveObject)& theIObj, |
1760 | Standard_Integer& theDispMode, |
1761 | Standard_Integer& theHiMode, |
1762 | Standard_Integer& theSelMode) const |
7fd59977 |
1763 | { |
2195ab96 |
1764 | if (theIObj.IsNull()) |
1765 | { |
1766 | return; |
1767 | } |
7fd59977 |
1768 | |
2195ab96 |
1769 | theDispMode = theIObj->HasDisplayMode() |
1770 | ? theIObj->DisplayMode() |
f838dac4 |
1771 | : (theIObj->AcceptDisplayMode (myDefaultDrawer->DisplayMode()) |
1772 | ? myDefaultDrawer->DisplayMode() |
2195ab96 |
1773 | : 0); |
1774 | theHiMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : theDispMode; |
c3282ec1 |
1775 | theSelMode = theIObj->GlobalSelectionMode(); |
2195ab96 |
1776 | } |
7fd59977 |
1777 | |
1778 | //======================================================================= |
1779 | //function : EraseGlobal |
2195ab96 |
1780 | //purpose : |
7fd59977 |
1781 | //======================================================================= |
2195ab96 |
1782 | void AIS_InteractiveContext::EraseGlobal (const Handle(AIS_InteractiveObject)& theIObj, |
1783 | const Standard_Boolean theToUpdateviewer) |
7fd59977 |
1784 | { |
a9080ef9 |
1785 | Handle(AIS_GlobalStatus) aStatus; |
2195ab96 |
1786 | if (theIObj.IsNull() |
a9080ef9 |
1787 | || !myObjects.Find (theIObj, aStatus) |
39e6123e |
1788 | || theIObj->DisplayStatus() == PrsMgr_DisplayStatus_Erased) |
2195ab96 |
1789 | { |
1790 | return; |
1791 | } |
7fd59977 |
1792 | |
a1954302 |
1793 | const Standard_Integer aDispMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0; |
741c4f3e |
1794 | unselectOwners (theIObj); |
3db69e41 |
1795 | myMainPM->SetVisibility (theIObj, aStatus->DisplayMode(), Standard_False); |
1796 | |
4f51d9d7 |
1797 | if (!myLastPicked.IsNull() |
8e5fb5ea |
1798 | && myLastPicked->IsSameSelectable (theIObj)) |
4f51d9d7 |
1799 | { |
731c9b5b |
1800 | clearDynamicHighlight(); |
4f51d9d7 |
1801 | } |
1802 | |
905b0e31 |
1803 | // make sure highlighting presentations are properly erased |
1804 | theIObj->ErasePresentations (false); |
1805 | |
c3282ec1 |
1806 | if (IsSelected (theIObj) |
3db69e41 |
1807 | && aStatus->DisplayMode() != aDispMode) |
a1954302 |
1808 | { |
1809 | myMainPM->SetVisibility (theIObj, aDispMode, Standard_False); |
1810 | } |
1811 | |
1812 | for (TColStd_ListIteratorOfListOfInteger aSelModeIter (aStatus->SelectionModes()); aSelModeIter.More(); aSelModeIter.Next()) |
1813 | { |
68dcee02 |
1814 | mgrSelector->Deactivate (theIObj, aSelModeIter.Value()); |
7fd59977 |
1815 | } |
c3282ec1 |
1816 | aStatus->ClearSelectionModes(); |
39e6123e |
1817 | theIObj->SetDisplayStatus (PrsMgr_DisplayStatus_Erased); |
a1954302 |
1818 | |
1819 | if (theToUpdateviewer) |
1820 | { |
1821 | myMainVwr->Update(); |
1822 | } |
7fd59977 |
1823 | } |
1824 | |
c3282ec1 |
1825 | //======================================================================= |
741c4f3e |
1826 | //function : unselectOwners |
c3282ec1 |
1827 | //purpose : |
1828 | //======================================================================= |
741c4f3e |
1829 | void AIS_InteractiveContext::unselectOwners (const Handle(AIS_InteractiveObject)& theObject) |
c3282ec1 |
1830 | { |
02974a19 |
1831 | SelectMgr_SequenceOfOwner aSeq; |
1832 | for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next()) |
c3282ec1 |
1833 | { |
a3d4053c |
1834 | if (aSelIter.Value()->IsSameSelectable (theObject)) |
c3282ec1 |
1835 | { |
02974a19 |
1836 | aSeq.Append (aSelIter.Value()); |
c3282ec1 |
1837 | } |
02974a19 |
1838 | } |
1839 | for (SelectMgr_SequenceOfOwner::Iterator aDelIter (aSeq); aDelIter.More(); aDelIter.Next()) |
1840 | { |
1841 | AddOrRemoveSelected (aDelIter.Value(), Standard_False); |
c3282ec1 |
1842 | } |
1843 | } |
1844 | |
7fd59977 |
1845 | //======================================================================= |
1846 | //function : ClearGlobal |
2195ab96 |
1847 | //purpose : |
7fd59977 |
1848 | //======================================================================= |
2195ab96 |
1849 | void AIS_InteractiveContext::ClearGlobal (const Handle(AIS_InteractiveObject)& theIObj, |
1850 | const Standard_Boolean theToUpdateviewer) |
7fd59977 |
1851 | { |
a9080ef9 |
1852 | Handle(AIS_GlobalStatus) aStatus; |
2195ab96 |
1853 | if (theIObj.IsNull() |
a9080ef9 |
1854 | || !myObjects.Find (theIObj, aStatus)) |
2195ab96 |
1855 | { |
f751596e |
1856 | // for cases when reference shape of connected interactives was not displayed |
1857 | // but its selection primitives were calculated |
543a9964 |
1858 | const Handle(SelectMgr_SelectableObject)& anObj = theIObj; // to avoid ambiguity |
1859 | mgrSelector->Remove (anObj); |
2195ab96 |
1860 | return; |
1861 | } |
1862 | |
741c4f3e |
1863 | unselectOwners (theIObj); |
7fd59977 |
1864 | |
e2d7642f |
1865 | myMainPM->Erase (theIObj, -1); |
905b0e31 |
1866 | theIObj->ErasePresentations (true); // make sure highlighting presentations are properly erased |
4f51d9d7 |
1867 | |
2195ab96 |
1868 | // Object removes from Detected sequence |
f2a88e54 |
1869 | for (Standard_Integer aDetIter = myDetectedSeq.Lower(); aDetIter <= myDetectedSeq.Upper();) |
7fd59977 |
1870 | { |
45fc824b |
1871 | Handle(SelectMgr_EntityOwner) aPicked = MainSelector()->Picked (myDetectedSeq (aDetIter)); |
f2a88e54 |
1872 | Handle(AIS_InteractiveObject) anObj; |
1873 | if (!aPicked.IsNull()) |
1874 | { |
1875 | anObj = Handle(AIS_InteractiveObject)::DownCast (aPicked->Selectable()); |
1876 | } |
1877 | |
2195ab96 |
1878 | if (!anObj.IsNull() |
f2a88e54 |
1879 | && anObj == theIObj) |
2195ab96 |
1880 | { |
f0cddd16 |
1881 | myDetectedSeq.Remove (aDetIter); |
f2a88e54 |
1882 | if (myCurDetected == aDetIter) |
1883 | { |
1884 | myCurDetected = Min (myDetectedSeq.Upper(), aDetIter); |
1885 | } |
1886 | if (myCurHighlighted == aDetIter) |
1887 | { |
1888 | myCurHighlighted = 0; |
1889 | } |
1890 | } |
1891 | else |
1892 | { |
1893 | aDetIter++; |
2195ab96 |
1894 | } |
7fd59977 |
1895 | } |
1896 | |
2195ab96 |
1897 | // remove IO from the selection manager to avoid memory leaks |
543a9964 |
1898 | const Handle(SelectMgr_SelectableObject)& anObj = theIObj; // to avoid ambiguity |
1899 | mgrSelector->Remove (anObj); |
7fd59977 |
1900 | |
39e6123e |
1901 | setObjectStatus (theIObj, PrsMgr_DisplayStatus_None, -1, -1); |
86d6c284 |
1902 | theIObj->ViewAffinity()->SetVisible (true); // reset view affinity mask |
c357e426 |
1903 | myMainVwr->StructureManager()->UnregisterObject (theIObj); |
6a24c6de |
1904 | |
a9080ef9 |
1905 | if (!myLastPicked.IsNull()) |
1beb58d7 |
1906 | { |
a9080ef9 |
1907 | if (myLastPicked->IsSameSelectable (theIObj)) |
1beb58d7 |
1908 | { |
731c9b5b |
1909 | clearDynamicHighlight(); |
f2a88e54 |
1910 | myLastPicked.Nullify(); |
1beb58d7 |
1911 | } |
1912 | } |
c3282ec1 |
1913 | |
39e6123e |
1914 | if (theToUpdateviewer |
1915 | && theIObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed) |
eb4320f2 |
1916 | { |
1917 | myMainVwr->Update(); |
1918 | } |
7fd59977 |
1919 | } |
1920 | |
1921 | //======================================================================= |
1922 | //function : ClearGlobalPrs |
2195ab96 |
1923 | //purpose : |
7fd59977 |
1924 | //======================================================================= |
2195ab96 |
1925 | void AIS_InteractiveContext::ClearGlobalPrs (const Handle(AIS_InteractiveObject)& theIObj, |
1926 | const Standard_Integer theMode, |
1927 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1928 | { |
39e6123e |
1929 | const Handle(AIS_GlobalStatus)* aStatus = !theIObj.IsNull() ? myObjects.Seek (theIObj) : NULL; |
1930 | if (aStatus == NULL) |
2195ab96 |
1931 | { |
1932 | return; |
1933 | } |
1934 | |
39e6123e |
1935 | if ((*aStatus)->DisplayMode() == theMode) |
2195ab96 |
1936 | { |
1937 | const Standard_Integer aDispMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0; |
1938 | if (aDispMode == theMode |
1939 | && myMainPM->IsHighlighted (theIObj, theMode)) |
1940 | { |
f838dac4 |
1941 | unhighlightGlobal (theIObj); |
2195ab96 |
1942 | } |
1943 | |
1944 | myMainPM->Erase (theIObj, theMode); |
7fd59977 |
1945 | } |
eb4320f2 |
1946 | |
39e6123e |
1947 | if (theIObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed |
2195ab96 |
1948 | && theToUpdateViewer) |
1949 | { |
7fd59977 |
1950 | myMainVwr->Update(); |
2195ab96 |
1951 | } |
7fd59977 |
1952 | } |
1953 | |
8a590580 |
1954 | //======================================================================= |
1955 | //function : ClearDetected |
1956 | //purpose : |
1957 | //======================================================================= |
1958 | Standard_Boolean AIS_InteractiveContext::ClearDetected (Standard_Boolean theToRedrawImmediate) |
1959 | { |
1960 | myCurDetected = 0; |
1961 | myCurHighlighted = 0; |
1962 | myDetectedSeq.Clear(); |
8a590580 |
1963 | Standard_Boolean toUpdate = Standard_False; |
1964 | if (!myLastPicked.IsNull() && myLastPicked->HasSelectable()) |
1965 | { |
1966 | toUpdate = Standard_True; |
1967 | clearDynamicHighlight(); |
1968 | } |
8a590580 |
1969 | myLastPicked.Nullify(); |
45fc824b |
1970 | MainSelector()->ClearPicked(); |
8a590580 |
1971 | if (toUpdate && theToRedrawImmediate) |
1972 | { |
1973 | myMainVwr->RedrawImmediate(); |
1974 | } |
1975 | return toUpdate; |
1976 | } |
1977 | |
7fd59977 |
1978 | //======================================================================= |
1979 | //function : SetIsoNumber |
2195ab96 |
1980 | //purpose : |
7fd59977 |
1981 | //======================================================================= |
2195ab96 |
1982 | void AIS_InteractiveContext::SetIsoNumber (const Standard_Integer theNb, |
1983 | const AIS_TypeOfIso theType) |
7fd59977 |
1984 | { |
2195ab96 |
1985 | switch (theType) |
1986 | { |
1987 | case AIS_TOI_IsoU: |
1988 | myDefaultDrawer->UIsoAspect()->SetNumber (theNb); |
1989 | break; |
1990 | case AIS_TOI_IsoV: |
1991 | myDefaultDrawer->VIsoAspect()->SetNumber (theNb); |
1992 | break; |
1993 | case AIS_TOI_Both: |
1994 | myDefaultDrawer->UIsoAspect()->SetNumber (theNb); |
1995 | myDefaultDrawer->VIsoAspect()->SetNumber (theNb); |
1996 | break; |
7fd59977 |
1997 | } |
1998 | } |
2195ab96 |
1999 | |
7fd59977 |
2000 | //======================================================================= |
2001 | //function : IsoNumber |
2195ab96 |
2002 | //purpose : |
7fd59977 |
2003 | //======================================================================= |
2195ab96 |
2004 | Standard_Integer AIS_InteractiveContext::IsoNumber (const AIS_TypeOfIso theType) |
7fd59977 |
2005 | { |
2195ab96 |
2006 | switch (theType) |
2007 | { |
2008 | case AIS_TOI_IsoU: return myDefaultDrawer->UIsoAspect()->Number(); |
2009 | case AIS_TOI_IsoV: return myDefaultDrawer->VIsoAspect()->Number(); |
2010 | case AIS_TOI_Both: return myDefaultDrawer->UIsoAspect()->Number() == myDefaultDrawer->VIsoAspect()->Number() |
2011 | ? myDefaultDrawer->UIsoAspect()->Number() |
2012 | : -1; |
7fd59977 |
2013 | } |
2014 | return 0; |
2015 | } |
2016 | |
51004f1c |
2017 | //======================================================================= |
3c982548 |
2018 | //function : SetPixelTolerance |
51004f1c |
2019 | //purpose : |
3c982548 |
2020 | //======================================================================= |
3bf9a45f |
2021 | void AIS_InteractiveContext::SetPixelTolerance (const Standard_Integer thePrecision) |
2195ab96 |
2022 | { |
45fc824b |
2023 | MainSelector()->SetPixelTolerance (thePrecision); |
7fd59977 |
2024 | } |
3c982548 |
2025 | |
2026 | //======================================================================= |
2027 | //function : PixelTolerance |
2195ab96 |
2028 | //purpose : |
3c982548 |
2029 | //======================================================================= |
3bf9a45f |
2030 | Standard_Integer AIS_InteractiveContext::PixelTolerance() const |
2195ab96 |
2031 | { |
45fc824b |
2032 | return MainSelector()->PixelTolerance(); |
3c982548 |
2033 | } |
7fd59977 |
2034 | |
8a1170ad |
2035 | //======================================================================= |
2036 | //function : SetSelectionSensitivity |
2037 | //purpose : Allows to manage sensitivity of a particular selection of interactive object theObject |
2038 | //======================================================================= |
2039 | void AIS_InteractiveContext::SetSelectionSensitivity (const Handle(AIS_InteractiveObject)& theObject, |
2040 | const Standard_Integer theMode, |
2041 | const Standard_Integer theNewSensitivity) |
2042 | { |
8a1170ad |
2043 | mgrSelector->SetSelectionSensitivity (theObject, theMode, theNewSensitivity); |
2044 | } |
2045 | |
7fd59977 |
2046 | //======================================================================= |
2047 | //function : InitAttributes |
2195ab96 |
2048 | //purpose : |
7fd59977 |
2049 | //======================================================================= |
7fd59977 |
2050 | void AIS_InteractiveContext::InitAttributes() |
2051 | { |
a966542b |
2052 | Graphic3d_MaterialAspect aMat (Graphic3d_NameOfMaterial_Brass); |
2195ab96 |
2053 | myDefaultDrawer->ShadingAspect()->SetMaterial (aMat); |
7fd59977 |
2054 | |
2055 | // myDefaultDrawer->ShadingAspect()->SetColor(Quantity_NOC_GRAY70); |
2195ab96 |
2056 | Handle(Prs3d_LineAspect) aLineAspect = myDefaultDrawer->HiddenLineAspect(); |
2057 | aLineAspect->SetColor (Quantity_NOC_GRAY20); |
2058 | aLineAspect->SetWidth (1.0); |
2059 | aLineAspect->SetTypeOfLine (Aspect_TOL_DASH); |
7fd59977 |
2060 | |
28ee613b |
2061 | // tolerance to 2 pixels... |
3bf9a45f |
2062 | SetPixelTolerance (2); |
7fd59977 |
2063 | |
2064 | // Customizing the drawer for trihedrons and planes... |
2195ab96 |
2065 | Handle(Prs3d_DatumAspect) aTrihAspect = myDefaultDrawer->DatumAspect(); |
2066 | const Standard_Real aLength = 100.0; |
2067 | aTrihAspect->SetAxisLength (aLength, aLength, aLength); |
87432b82 |
2068 | const Quantity_Color aColor = Quantity_NOC_LIGHTSTEELBLUE4; |
24f9d04c |
2069 | aTrihAspect->LineAspect(Prs3d_DatumParts_XAxis)->SetColor (aColor); |
2070 | aTrihAspect->LineAspect(Prs3d_DatumParts_YAxis)->SetColor (aColor); |
2071 | aTrihAspect->LineAspect(Prs3d_DatumParts_ZAxis)->SetColor (aColor); |
7fd59977 |
2072 | |
2195ab96 |
2073 | Handle(Prs3d_PlaneAspect) aPlaneAspect = myDefaultDrawer->PlaneAspect(); |
2074 | const Standard_Real aPlaneLength = 200.0; |
2075 | aPlaneAspect->SetPlaneLength (aPlaneLength, aPlaneLength); |
2076 | aPlaneAspect->EdgesAspect()->SetColor (Quantity_NOC_SKYBLUE); |
7fd59977 |
2077 | } |
2078 | |
7fd59977 |
2079 | //======================================================================= |
2080 | //function : TrihedronSize |
2195ab96 |
2081 | //purpose : |
7fd59977 |
2082 | //======================================================================= |
2083 | Standard_Real AIS_InteractiveContext::TrihedronSize() const |
2084 | { |
24f9d04c |
2085 | return myDefaultDrawer->DatumAspect()->AxisLength(Prs3d_DatumParts_XAxis); |
7fd59977 |
2086 | } |
2195ab96 |
2087 | |
7fd59977 |
2088 | //======================================================================= |
2089 | //function : SetTrihedronSize |
2195ab96 |
2090 | //purpose : |
7fd59977 |
2091 | //======================================================================= |
2195ab96 |
2092 | void AIS_InteractiveContext::SetTrihedronSize (const Standard_Real theVal, |
2093 | const Standard_Boolean /*updateviewer*/) |
7fd59977 |
2094 | { |
2195ab96 |
2095 | myDefaultDrawer->DatumAspect()->SetAxisLength (theVal, theVal, theVal); |
82b856b8 |
2096 | Redisplay (AIS_KindOfInteractive_Datum, 3, Standard_False); |
2097 | Redisplay (AIS_KindOfInteractive_Datum, 4, Standard_True); |
7fd59977 |
2098 | } |
2099 | |
7fd59977 |
2100 | //======================================================================= |
2101 | //function : SetPlaneSize |
2195ab96 |
2102 | //purpose : |
7fd59977 |
2103 | //======================================================================= |
2195ab96 |
2104 | void AIS_InteractiveContext::SetPlaneSize(const Standard_Real theValX, |
2105 | const Standard_Real theValY, |
0577ae8c |
2106 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
2107 | { |
2195ab96 |
2108 | myDefaultDrawer->PlaneAspect()->SetPlaneLength (theValX, theValY); |
82b856b8 |
2109 | Redisplay (AIS_KindOfInteractive_Datum, 7, theToUpdateViewer); |
7fd59977 |
2110 | } |
2111 | |
2112 | //======================================================================= |
2113 | //function : SetPlaneSize |
2195ab96 |
2114 | //purpose : |
7fd59977 |
2115 | //======================================================================= |
2195ab96 |
2116 | void AIS_InteractiveContext::SetPlaneSize (const Standard_Real theVal, |
2117 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
2118 | { |
2195ab96 |
2119 | SetPlaneSize (theVal, theVal, theToUpdateViewer); |
7fd59977 |
2120 | } |
2121 | |
2122 | //======================================================================= |
2123 | //function : PlaneSize |
2195ab96 |
2124 | //purpose : |
7fd59977 |
2125 | //======================================================================= |
2195ab96 |
2126 | Standard_Boolean AIS_InteractiveContext::PlaneSize (Standard_Real& theX, |
2127 | Standard_Real& theY) const |
7fd59977 |
2128 | { |
2195ab96 |
2129 | theX = myDefaultDrawer->PlaneAspect()->PlaneXLength(); |
2130 | theY = myDefaultDrawer->PlaneAspect()->PlaneYLength(); |
2131 | return (Abs (theX - theY) <= Precision::Confusion()); |
7fd59977 |
2132 | } |
2133 | |
59f45b7c |
2134 | //======================================================================= |
2135 | //function : SetZLayer |
2195ab96 |
2136 | //purpose : |
59f45b7c |
2137 | //======================================================================= |
59f45b7c |
2138 | void AIS_InteractiveContext::SetZLayer (const Handle(AIS_InteractiveObject)& theIObj, |
8f138407 |
2139 | const Graphic3d_ZLayerId theLayerId) |
59f45b7c |
2140 | { |
2195ab96 |
2141 | if (theIObj.IsNull()) |
59f45b7c |
2142 | return; |
2143 | |
a1954302 |
2144 | theIObj->SetZLayer (theLayerId); |
59f45b7c |
2145 | } |
2146 | |
2147 | //======================================================================= |
2148 | //function : GetZLayer |
2195ab96 |
2149 | //purpose : |
59f45b7c |
2150 | //======================================================================= |
8f138407 |
2151 | Graphic3d_ZLayerId AIS_InteractiveContext::GetZLayer (const Handle(AIS_InteractiveObject)& theIObj) const |
59f45b7c |
2152 | { |
a1954302 |
2153 | return !theIObj.IsNull() |
2154 | ? theIObj->ZLayer() |
2155 | : Graphic3d_ZLayerId_UNKNOWN; |
59f45b7c |
2156 | } |
f751596e |
2157 | |
2158 | //======================================================================= |
2159 | //function : RebuildSelectionStructs |
2160 | //purpose : Rebuilds 1st level of BVH selection forcibly |
2161 | //======================================================================= |
2162 | void AIS_InteractiveContext::RebuildSelectionStructs() |
2163 | { |
45fc824b |
2164 | MainSelector()->RebuildObjectsTree (Standard_True); |
f751596e |
2165 | } |
2166 | |
2167 | //======================================================================= |
2168 | //function : Disconnect |
2169 | //purpose : Disconnects selectable object from an assembly and updates selection structures |
2170 | //======================================================================= |
2171 | void AIS_InteractiveContext::Disconnect (const Handle(AIS_InteractiveObject)& theAssembly, |
2172 | const Handle(AIS_InteractiveObject)& theObjToDisconnect) |
2173 | { |
2174 | if (theAssembly->IsInstance ("AIS_MultipleConnectedInteractive")) |
2175 | { |
c5f3a425 |
2176 | Handle(AIS_MultipleConnectedInteractive) theObj (Handle(AIS_MultipleConnectedInteractive)::DownCast (theAssembly)); |
f751596e |
2177 | theObj->Disconnect (theObjToDisconnect); |
7dd7c146 |
2178 | if (!myObjects.IsBound (theObjToDisconnect)) |
2179 | { |
2180 | // connected presentation might contain displayed presentations |
2181 | myMainPM->Erase (theObjToDisconnect, -1); |
2182 | theObjToDisconnect->ErasePresentations (true); |
2183 | } |
2184 | |
543a9964 |
2185 | const Handle(SelectMgr_SelectableObject)& anObj = theObjToDisconnect; // to avoid ambiguity |
2186 | mgrSelector->Remove (anObj); |
f751596e |
2187 | } |
c04c30b3 |
2188 | else if (theAssembly->IsInstance ("AIS_ConnectedInteractive") && theObjToDisconnect.IsNull()) |
f751596e |
2189 | { |
c5f3a425 |
2190 | Handle(AIS_ConnectedInteractive) theObj (Handle(AIS_ConnectedInteractive)::DownCast (theAssembly)); |
f751596e |
2191 | theObj->Disconnect(); |
543a9964 |
2192 | const Handle(SelectMgr_SelectableObject)& anObj = theObj; // to avoid ambiguity |
2193 | mgrSelector->Remove (anObj); |
f751596e |
2194 | } |
2195 | else |
2196 | return; |
2197 | } |
b586500b |
2198 | |
0577ae8c |
2199 | //======================================================================= |
2200 | //function : FitSelected |
2201 | //purpose : Fits the view corresponding to the bounds of selected objects |
2202 | //======================================================================= |
2203 | void AIS_InteractiveContext::FitSelected (const Handle(V3d_View)& theView) |
2204 | { |
2205 | FitSelected (theView, 0.01, Standard_True); |
2206 | } |
2207 | |
b586500b |
2208 | //======================================================================= |
2108d9a2 |
2209 | //function : BoundingBoxOfSelection |
2210 | //purpose : |
b586500b |
2211 | //======================================================================= |
b56df3a6 |
2212 | Bnd_Box AIS_InteractiveContext::BoundingBoxOfSelection (const Handle(V3d_View)& theView) const |
b586500b |
2213 | { |
b586500b |
2214 | Bnd_Box aBndSelected; |
b586500b |
2215 | AIS_MapOfObjectOwners anObjectOwnerMap; |
b56df3a6 |
2216 | const Standard_Integer aViewId = !theView.IsNull() ? theView->View()->Identification() : -1; |
68dcee02 |
2217 | for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next()) |
b586500b |
2218 | { |
b5cce1ab |
2219 | const Handle(SelectMgr_EntityOwner)& anOwner = aSelIter.Value(); |
02974a19 |
2220 | Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast(anOwner->Selectable()); |
2221 | if (anObj->IsInfinite()) |
b586500b |
2222 | { |
02974a19 |
2223 | continue; |
2224 | } |
b586500b |
2225 | |
86d6c284 |
2226 | Handle(Graphic3d_ViewAffinity) anAffinity = anObj->ViewAffinity(); |
b56df3a6 |
2227 | const Standard_Boolean isVisible = aViewId == -1 || anAffinity->IsVisible (aViewId); |
2228 | if (!isVisible) |
2229 | { |
2230 | continue; |
2231 | } |
2232 | |
02974a19 |
2233 | if (anOwner == anObj->GlobalSelOwner()) |
2234 | { |
b586500b |
2235 | Bnd_Box aTmpBnd; |
2236 | anObj->BoundingBox (aTmpBnd); |
2237 | aBndSelected.Add (aTmpBnd); |
2238 | } |
2239 | else |
2240 | { |
b586500b |
2241 | Handle(SelectMgr_IndexedMapOfOwner) anOwnerMap; |
2242 | if (!anObjectOwnerMap.Find (anOwner->Selectable(), anOwnerMap)) |
2243 | { |
2244 | anOwnerMap = new SelectMgr_IndexedMapOfOwner(); |
2245 | anObjectOwnerMap.Bind (anOwner->Selectable(), anOwnerMap); |
2246 | } |
2247 | |
2248 | anOwnerMap->Add (anOwner); |
2249 | } |
2250 | } |
2251 | |
2252 | for (AIS_MapIteratorOfMapOfObjectOwners anIter (anObjectOwnerMap); anIter.More(); anIter.Next()) |
2253 | { |
b2fedee6 |
2254 | const Handle(SelectMgr_SelectableObject)& anObject = anIter.Key(); |
b586500b |
2255 | Bnd_Box aTmpBox = anObject->BndBoxOfSelected (anIter.ChangeValue()); |
2256 | aBndSelected.Add (aTmpBox); |
2257 | } |
2258 | |
2108d9a2 |
2259 | return aBndSelected; |
2260 | } |
b586500b |
2261 | |
2108d9a2 |
2262 | //======================================================================= |
2263 | //function : FitSelected |
2264 | //purpose : Fits the view corresponding to the bounds of selected objects |
2265 | //======================================================================= |
2266 | void AIS_InteractiveContext::FitSelected (const Handle(V3d_View)& theView, |
2267 | const Standard_Real theMargin, |
2268 | const Standard_Boolean theToUpdate) |
2269 | { |
b56df3a6 |
2270 | Bnd_Box aBndSelected = BoundingBoxOfSelection (theView); |
2108d9a2 |
2271 | if (!aBndSelected.IsVoid()) |
2272 | { |
2273 | theView->FitAll (aBndSelected, theMargin, theToUpdate); |
2274 | } |
b586500b |
2275 | } |
1d92133e |
2276 | |
2277 | //======================================================================= |
2278 | //function : SetTransformPersistence |
2279 | //purpose : |
2280 | //======================================================================= |
2281 | void AIS_InteractiveContext::SetTransformPersistence (const Handle(AIS_InteractiveObject)& theObject, |
778cd667 |
2282 | const Handle(Graphic3d_TransformPers)& theTrsfPers) |
1d92133e |
2283 | { |
778cd667 |
2284 | theObject->SetTransformPersistence (theTrsfPers); |
1d92133e |
2285 | if (!myObjects.IsBound (theObject)) |
2286 | { |
2287 | return; |
2288 | } |
2289 | |
2290 | mgrSelector->UpdateSelection (theObject); |
2291 | |
42ddd002 |
2292 | const Graphic3d_ZLayerId aLayerId = theObject->ZLayer(); |
1d92133e |
2293 | const Handle(V3d_Viewer)& aCurViewer = CurrentViewer(); |
6a24c6de |
2294 | for (V3d_ListOfViewIterator anActiveViewIter (aCurViewer->ActiveViewIterator()); anActiveViewIter.More(); anActiveViewIter.Next()) |
1d92133e |
2295 | { |
6a24c6de |
2296 | anActiveViewIter.Value()->View()->InvalidateBVHData (aLayerId); |
2297 | anActiveViewIter.Value()->View()->InvalidateZLayerBoundingBox (aLayerId); |
1d92133e |
2298 | } |
2299 | } |
49582f9d |
2300 | |
2301 | //======================================================================= |
2302 | //function : GravityPoint |
2303 | //purpose : |
2304 | //======================================================================= |
2305 | gp_Pnt AIS_InteractiveContext::GravityPoint (const Handle(V3d_View)& theView) const |
2306 | { |
2307 | return theView->GravityPoint(); |
2308 | } |
39e6123e |
2309 | |
4f5e9344 |
2310 | //======================================================================= |
2311 | //function : setContextToObject |
2312 | //purpose : |
2313 | //======================================================================= |
2314 | void AIS_InteractiveContext::setContextToObject (const Handle(AIS_InteractiveObject)& theObj) |
2315 | { |
2316 | if (theObj->HasInteractiveContext()) |
2317 | { |
2318 | if (theObj->myCTXPtr != this) |
2319 | { |
2320 | throw Standard_ProgramError("AIS_InteractiveContext - object has been already displayed in another context!"); |
2321 | } |
2322 | } |
2323 | else |
2324 | { |
2325 | theObj->SetContext (this); |
2326 | } |
2327 | |
2328 | for (PrsMgr_ListOfPresentableObjectsIter aPrsIter (theObj->Children()); aPrsIter.More(); aPrsIter.Next()) |
2329 | { |
2330 | if (Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast (aPrsIter.Value())) |
2331 | { |
2332 | setContextToObject (aChild); |
2333 | } |
2334 | } |
2335 | } |
2336 | |
13c556d9 |
2337 | //======================================================================= |
2338 | //function : setObjectStatus |
2339 | //purpose : |
2340 | //======================================================================= |
2341 | void AIS_InteractiveContext::setObjectStatus (const Handle(AIS_InteractiveObject)& theIObj, |
39e6123e |
2342 | const PrsMgr_DisplayStatus theStatus, |
13c556d9 |
2343 | const Standard_Integer theDispMode, |
2344 | const Standard_Integer theSelectionMode) |
2345 | { |
39e6123e |
2346 | theIObj->SetDisplayStatus (theStatus); |
2347 | if (theStatus != PrsMgr_DisplayStatus_None) |
13c556d9 |
2348 | { |
42ddd002 |
2349 | Handle(AIS_GlobalStatus) aStatus = new AIS_GlobalStatus(); |
2350 | aStatus->SetDisplayMode (theDispMode); |
2351 | if (theSelectionMode != -1) |
2352 | { |
2353 | aStatus->AddSelectionMode (theSelectionMode); |
2354 | } |
13c556d9 |
2355 | myObjects.Bind (theIObj, aStatus); |
2356 | } |
2357 | else |
39e6123e |
2358 | { |
13c556d9 |
2359 | myObjects.UnBind (theIObj); |
39e6123e |
2360 | } |
13c556d9 |
2361 | |
2362 | for (PrsMgr_ListOfPresentableObjectsIter aPrsIter (theIObj->Children()); aPrsIter.More(); aPrsIter.Next()) |
2363 | { |
2364 | Handle(AIS_InteractiveObject) aChild (Handle(AIS_InteractiveObject)::DownCast (aPrsIter.Value())); |
2365 | if (aChild.IsNull()) |
39e6123e |
2366 | { |
13c556d9 |
2367 | continue; |
39e6123e |
2368 | } |
13c556d9 |
2369 | |
2370 | setObjectStatus (aChild, theStatus, theDispMode, theSelectionMode); |
2371 | } |
2372 | } |
478862fc |
2373 | |
2374 | //======================================================================= |
2375 | //function : highlightWithColor |
2376 | //purpose : |
2377 | //======================================================================= |
2378 | void AIS_InteractiveContext::highlightWithColor (const Handle(SelectMgr_EntityOwner)& theOwner, |
2379 | const Handle(V3d_Viewer)& theViewer) |
2380 | { |
2381 | const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()); |
2382 | if (anObj.IsNull()) |
2383 | { |
2384 | return; |
2385 | } |
2386 | |
2387 | const Handle(Prs3d_Drawer)& aStyle = getHiStyle (anObj, theOwner); |
2388 | const Standard_Integer aHiMode = getHilightMode (anObj, aStyle, -1); |
2389 | |
2390 | myMainPM->BeginImmediateDraw(); |
2391 | theOwner->HilightWithColor (myMainPM, aStyle, aHiMode); |
2392 | myMainPM->EndImmediateDraw (theViewer.IsNull() ? myMainVwr : theViewer); |
2393 | } |
2394 | |
2395 | //======================================================================= |
2396 | //function : highlightSelected |
2397 | //purpose : |
2398 | //======================================================================= |
2399 | void AIS_InteractiveContext::highlightSelected (const Handle(SelectMgr_EntityOwner)& theOwner) |
2400 | { |
2401 | AIS_NListOfEntityOwner anOwners; |
2402 | const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()); |
2403 | if (anObj.IsNull()) |
2404 | { |
2405 | return; |
2406 | } |
2407 | |
2408 | if (!theOwner->IsAutoHilight()) |
2409 | { |
2410 | SelectMgr_SequenceOfOwner aSeq; |
2411 | for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next()) |
2412 | { |
2413 | if (aSelIter.Value()->IsSameSelectable (anObj)) |
2414 | { |
2415 | anOwners.Append (aSelIter.Value()); |
2416 | } |
2417 | } |
2418 | } |
2419 | else |
2420 | { |
2421 | anOwners.Append (theOwner); |
2422 | } |
2423 | highlightOwners (anOwners, Handle(Prs3d_Drawer)()); |
2424 | } |
2425 | |
2426 | //======================================================================= |
2427 | //function : highlightGlobal |
2428 | //purpose : |
2429 | //======================================================================= |
2430 | void AIS_InteractiveContext::highlightGlobal (const Handle(AIS_InteractiveObject)& theObj, |
2431 | const Handle(Prs3d_Drawer)& theStyle, |
2432 | const Standard_Integer theDispMode) |
2433 | { |
2434 | if (theObj.IsNull()) |
2435 | { |
2436 | return; |
2437 | } |
2438 | |
2439 | const Standard_Integer aHiMode = getHilightMode (theObj, theStyle, theDispMode); |
2440 | const Handle(SelectMgr_EntityOwner)& aGlobOwner = theObj->GlobalSelOwner(); |
2441 | |
2442 | if (aGlobOwner.IsNull()) |
2443 | { |
2444 | myMainPM->Color (theObj, theStyle, aHiMode); |
2445 | return; |
2446 | } |
2447 | |
2448 | AIS_NListOfEntityOwner anOwners; |
2449 | if (!aGlobOwner->IsAutoHilight()) |
2450 | { |
2451 | SelectMgr_SequenceOfOwner aSeq; |
2452 | for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next()) |
2453 | { |
2454 | if (aSelIter.Value()->IsSameSelectable (theObj)) |
2455 | { |
2456 | anOwners.Append (aSelIter.Value()); |
2457 | } |
2458 | } |
2459 | } |
2460 | else |
2461 | { |
2462 | anOwners.Append (aGlobOwner); |
2463 | } |
2464 | highlightOwners (anOwners, theStyle); |
2465 | } |
2466 | |
2467 | //======================================================================= |
2468 | //function : unhighlightSelected |
2469 | //purpose : |
2470 | //======================================================================= |
2471 | void AIS_InteractiveContext::unhighlightSelected (const Standard_Boolean theIsToHilightSubIntensity) |
2472 | { |
2473 | unhighlightOwners (mySelection->Objects(), theIsToHilightSubIntensity); |
2474 | } |
2475 | |
2476 | //======================================================================= |
2477 | //function : unhighlightOwners |
2478 | //purpose : |
2479 | //======================================================================= |
2480 | void AIS_InteractiveContext::unhighlightOwners (const AIS_NListOfEntityOwner& theOwners, |
2481 | const Standard_Boolean theIsToHilightSubIntensity) |
2482 | { |
2483 | NCollection_IndexedMap<Handle(AIS_InteractiveObject)> anObjToClear; |
2484 | for (AIS_NListOfEntityOwner::Iterator aSelIter (theOwners); aSelIter.More(); aSelIter.Next()) |
2485 | { |
2486 | const Handle(SelectMgr_EntityOwner) anOwner = aSelIter.Value(); |
2487 | const Handle(AIS_InteractiveObject) anInteractive = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable()); |
2488 | Handle(AIS_GlobalStatus)* aStatusPtr = myObjects.ChangeSeek (anInteractive); |
2489 | if (!aStatusPtr) |
2490 | { |
2491 | continue; |
2492 | } |
2493 | |
2494 | if (anOwner->IsAutoHilight()) |
2495 | { |
2496 | anOwner->Unhilight (myMainPM); |
2497 | if (theIsToHilightSubIntensity) |
2498 | { |
2499 | if ((*aStatusPtr)->IsSubIntensityOn()) |
2500 | { |
2501 | const Standard_Integer aHiMode = getHilightMode (anInteractive, (*aStatusPtr)->HilightStyle(), (*aStatusPtr)->DisplayMode()); |
2502 | highlightWithSubintensity (anOwner, aHiMode); |
2503 | } |
2504 | } |
2505 | } |
2506 | else |
2507 | { |
2508 | anObjToClear.Add (anInteractive); |
2509 | } |
2510 | if (anOwner == anInteractive->GlobalSelOwner()) |
2511 | { |
2512 | (*aStatusPtr)->SetHilightStatus (Standard_False); |
2513 | } |
2514 | (*aStatusPtr)->SetHilightStyle (Handle(Prs3d_Drawer)()); |
2515 | } |
2516 | for (NCollection_IndexedMap<Handle(AIS_InteractiveObject)>::Iterator anIter (anObjToClear); anIter.More(); anIter.Next()) |
2517 | { |
2518 | const Handle(AIS_InteractiveObject)& anObj = anIter.Value(); |
2519 | myMainPM->Unhighlight (anObj); |
2520 | anObj->ClearSelected(); |
2521 | } |
2522 | } |
2523 | |
2524 | //======================================================================= |
2525 | //function : unhighlightGlobal |
2526 | //purpose : |
2527 | //======================================================================= |
2528 | void AIS_InteractiveContext::unhighlightGlobal (const Handle(AIS_InteractiveObject)& theObj) |
2529 | { |
2530 | if (theObj.IsNull()) |
2531 | { |
2532 | return; |
2533 | } |
2534 | |
2535 | const Handle(SelectMgr_EntityOwner)& aGlobOwner = theObj->GlobalSelOwner(); |
2536 | if (aGlobOwner.IsNull()) |
2537 | { |
2538 | myMainPM->Unhighlight (theObj); |
2539 | return; |
2540 | } |
2541 | |
2542 | AIS_NListOfEntityOwner anOwners; |
2543 | anOwners.Append (aGlobOwner); |
2544 | unhighlightOwners (anOwners); |
2545 | } |
2546 | |
2547 | //======================================================================= |
2548 | //function : turnOnSubintensity |
2549 | //purpose : |
2550 | //======================================================================= |
2551 | void AIS_InteractiveContext::turnOnSubintensity (const Handle(AIS_InteractiveObject)& theObject, |
2552 | const Standard_Integer theDispMode, |
2553 | const Standard_Boolean theIsDisplayedOnly) const |
2554 | { |
2555 | // the only differ with selection highlight is color, so sync transparency values |
2556 | const Handle(Prs3d_Drawer)& aSubStyle = myStyles[Prs3d_TypeOfHighlight_SubIntensity]; |
2557 | aSubStyle->SetTransparency (myStyles[Prs3d_TypeOfHighlight_Selected]->Transparency()); |
2558 | |
2559 | if (theObject.IsNull()) |
2560 | { |
2561 | for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjsIter (myObjects); anObjsIter.More(); anObjsIter.Next()) |
2562 | { |
2563 | const Handle(AIS_GlobalStatus)& aStatus = anObjsIter.Value(); |
2564 | if (theObject->DisplayStatus() != PrsMgr_DisplayStatus_Displayed && theIsDisplayedOnly) |
2565 | { |
2566 | continue; |
2567 | } |
2568 | |
42ddd002 |
2569 | aStatus->SetSubIntensity (true); |
478862fc |
2570 | myMainPM->Color (anObjsIter.Key(), aSubStyle, theDispMode != -1 ? theDispMode : aStatus->DisplayMode()); |
2571 | } |
2572 | } |
2573 | else |
2574 | { |
2575 | Handle(AIS_GlobalStatus) aStatus; |
2576 | if (!myObjects.Find (theObject, aStatus)) |
2577 | { |
2578 | return; |
2579 | } |
2580 | |
2581 | if (theObject->DisplayStatus() != PrsMgr_DisplayStatus_Displayed && theIsDisplayedOnly) |
2582 | { |
2583 | return; |
2584 | } |
2585 | |
42ddd002 |
2586 | aStatus->SetSubIntensity (true); |
478862fc |
2587 | myMainPM->Color (theObject, aSubStyle, theDispMode != -1 ? theDispMode : aStatus->DisplayMode()); |
2588 | } |
2589 | } |
2590 | |
2591 | //======================================================================= |
2592 | //function : highlightWithSubintensity |
2593 | //purpose : |
2594 | //======================================================================= |
2595 | void AIS_InteractiveContext::highlightWithSubintensity (const Handle(AIS_InteractiveObject)& theObject, |
2596 | const Standard_Integer theMode) const |
2597 | { |
2598 | // the only differ with selection highlight is color, so |
2599 | // sync transparency values |
2600 | myStyles[Prs3d_TypeOfHighlight_SubIntensity]->SetTransparency (myStyles[Prs3d_TypeOfHighlight_Selected]->Transparency()); |
2601 | |
2602 | myMainPM->Color (theObject, myStyles[Prs3d_TypeOfHighlight_SubIntensity], theMode); |
2603 | } |
2604 | |
2605 | //======================================================================= |
2606 | //function : highlightWithSubintensity |
2607 | //purpose : |
2608 | //======================================================================= |
2609 | void AIS_InteractiveContext::highlightWithSubintensity (const Handle(SelectMgr_EntityOwner)& theOwner, |
2610 | const Standard_Integer theMode) const |
2611 | { |
2612 | // the only differ with selection highlight is color, so |
2613 | // sync transparency values |
2614 | myStyles[Prs3d_TypeOfHighlight_SubIntensity]->SetTransparency (myStyles[Prs3d_TypeOfHighlight_Selected]->Transparency()); |
2615 | |
2616 | theOwner->HilightWithColor (myMainPM, myStyles[Prs3d_TypeOfHighlight_SubIntensity], theMode); |
2617 | } |
2618 | |
2619 | //======================================================================= |
2620 | //function : isSlowHiStyle |
2621 | //purpose : |
2622 | //======================================================================= |
2623 | Standard_Boolean AIS_InteractiveContext::isSlowHiStyle (const Handle(SelectMgr_EntityOwner)& theOwner, |
2624 | const Handle(V3d_Viewer)& theViewer) const |
2625 | { |
2626 | if (const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable())) |
2627 | { |
2628 | const Handle(Prs3d_Drawer)& aHiStyle = getHiStyle (anObj, myLastPicked); |
2629 | return aHiStyle->ZLayer() == Graphic3d_ZLayerId_UNKNOWN |
2630 | || !theViewer->ZLayerSettings (aHiStyle->ZLayer()).IsImmediate(); |
2631 | } |
2632 | return Standard_False; |
2633 | } |
2634 | |
2635 | //======================================================================= |
2636 | //function : MoveTo |
2637 | //purpose : |
2638 | //======================================================================= |
2639 | AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer theXPix, |
2640 | const Standard_Integer theYPix, |
2641 | const Handle(V3d_View)& theView, |
2642 | const Standard_Boolean theToRedrawOnUpdate) |
2643 | { |
2644 | if (theView->Viewer() != myMainVwr) |
2645 | { |
2646 | throw Standard_ProgramError ("AIS_InteractiveContext::MoveTo() - invalid argument"); |
2647 | } |
45fc824b |
2648 | MainSelector()->Pick (theXPix, theYPix, theView); |
807340d9 |
2649 | return moveTo (theView, theToRedrawOnUpdate); |
2650 | } |
478862fc |
2651 | |
807340d9 |
2652 | //======================================================================= |
2653 | //function : MoveTo |
2654 | //purpose : |
2655 | //======================================================================= |
2656 | AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const gp_Ax1& theAxis, |
2657 | const Handle(V3d_View)& theView, |
2658 | const Standard_Boolean theToRedrawOnUpdate) |
2659 | { |
2660 | if (theView->Viewer() != myMainVwr) |
2661 | { |
2662 | throw Standard_ProgramError ("AIS_InteractiveContext::MoveTo() - invalid argument"); |
2663 | } |
45fc824b |
2664 | MainSelector()->Pick (theAxis, theView); |
807340d9 |
2665 | return moveTo (theView, theToRedrawOnUpdate); |
2666 | } |
2667 | |
2668 | //======================================================================= |
2669 | //function : moveTo |
2670 | //purpose : |
2671 | //======================================================================= |
2672 | AIS_StatusOfDetection AIS_InteractiveContext::moveTo (const Handle(V3d_View)& theView, |
2673 | const Standard_Boolean theToRedrawOnUpdate) |
2674 | { |
478862fc |
2675 | myCurDetected = 0; |
2676 | myCurHighlighted = 0; |
2677 | myDetectedSeq.Clear(); |
2678 | myLastActiveView = theView.get(); |
2679 | |
86d6c284 |
2680 | // preliminaries |
478862fc |
2681 | AIS_StatusOfDetection aStatus = AIS_SOD_Nothing; |
2682 | Standard_Boolean toUpdateViewer = Standard_False; |
2683 | |
478862fc |
2684 | // filling of myAISDetectedSeq sequence storing information about detected AIS objects |
2685 | // (the objects must be AIS_Shapes) |
45fc824b |
2686 | const Standard_Integer aDetectedNb = MainSelector()->NbPicked(); |
478862fc |
2687 | Standard_Integer aNewDetected = 0; |
2688 | Standard_Boolean toIgnoreDetTop = Standard_False; |
2689 | for (Standard_Integer aDetIter = 1; aDetIter <= aDetectedNb; ++aDetIter) |
2690 | { |
45fc824b |
2691 | Handle(SelectMgr_EntityOwner) anOwner = MainSelector()->Picked (aDetIter); |
478862fc |
2692 | if (anOwner.IsNull() |
2693 | || !myFilters->IsOk (anOwner)) |
2694 | { |
2695 | if (myPickingStrategy == SelectMgr_PickingStrategy_OnlyTopmost) |
2696 | { |
2697 | toIgnoreDetTop = Standard_True; |
2698 | } |
2699 | continue; |
2700 | } |
2701 | |
2702 | if (aNewDetected < 1 |
2703 | && !toIgnoreDetTop) |
2704 | { |
2705 | aNewDetected = aDetIter; |
2706 | } |
2707 | |
2708 | myDetectedSeq.Append (aDetIter); |
2709 | } |
2710 | |
2711 | if (aNewDetected >= 1) |
2712 | { |
2713 | myCurHighlighted = myDetectedSeq.Lower(); |
2714 | |
2715 | // Does nothing if previously detected object is equal to the current one. |
2716 | // However in advanced selection modes the owners comparison |
2717 | // is not effective because in that case only one owner manage the |
2718 | // selection in current selection mode. It is necessary to check the current detected |
2719 | // entity and hilight it only if the detected entity is not the same as |
2720 | // previous detected (IsForcedHilight call) |
45fc824b |
2721 | Handle(SelectMgr_EntityOwner) aNewPickedOwner = MainSelector()->Picked (aNewDetected); |
478862fc |
2722 | if (aNewPickedOwner == myLastPicked && !aNewPickedOwner->IsForcedHilight()) |
2723 | { |
2724 | return myLastPicked->IsSelected() |
2725 | ? AIS_SOD_Selected |
2726 | : AIS_SOD_OnlyOneDetected; |
2727 | } |
2728 | |
2729 | // Previously detected object is unhilighted if it is not selected or hilighted |
2730 | // with selection color if it is selected. Such highlighting with selection color |
2731 | // is needed only if myToHilightSelected flag is true. In this case previously detected |
2732 | // object has been already highlighted with myHilightColor during previous MoveTo() |
2733 | // method call. As result it is necessary to rehighligt it with mySelectionColor. |
2734 | if (!myLastPicked.IsNull() && myLastPicked->HasSelectable()) |
2735 | { |
2736 | if (isSlowHiStyle (myLastPicked, theView->Viewer())) |
2737 | { |
2738 | theView->Viewer()->Invalidate(); |
2739 | } |
2740 | |
2741 | clearDynamicHighlight(); |
2742 | toUpdateViewer = Standard_True; |
2743 | } |
2744 | |
2745 | // initialize myLastPicked field with currently detected object |
2746 | myLastPicked = aNewPickedOwner; |
2747 | |
2748 | // highlight detected object if it is not selected or myToHilightSelected flag is true |
2749 | if (myLastPicked->HasSelectable()) |
2750 | { |
2751 | if (myAutoHilight |
2752 | && (!myLastPicked->IsSelected() |
2753 | || myToHilightSelected)) |
2754 | { |
2755 | if (isSlowHiStyle (myLastPicked, theView->Viewer())) |
2756 | { |
2757 | theView->Viewer()->Invalidate(); |
2758 | } |
2759 | |
2760 | highlightWithColor (myLastPicked, theView->Viewer()); |
2761 | toUpdateViewer = Standard_True; |
2762 | } |
2763 | |
2764 | aStatus = myLastPicked->IsSelected() |
2765 | ? AIS_SOD_Selected |
2766 | : AIS_SOD_OnlyOneDetected; |
2767 | } |
2768 | } |
2769 | else |
2770 | { |
2771 | // previously detected object is unhilighted if it is not selected or hilighted |
2772 | // with selection color if it is selected |
2773 | aStatus = AIS_SOD_Nothing; |
2774 | if (myAutoHilight |
2775 | && !myLastPicked.IsNull() |
2776 | && myLastPicked->HasSelectable()) |
2777 | { |
2778 | if (isSlowHiStyle (myLastPicked, theView->Viewer())) |
2779 | { |
2780 | theView->Viewer()->Invalidate(); |
2781 | } |
2782 | |
2783 | clearDynamicHighlight(); |
2784 | toUpdateViewer = Standard_True; |
2785 | } |
2786 | |
2787 | myLastPicked.Nullify(); |
2788 | } |
2789 | |
2790 | if (toUpdateViewer |
2791 | && theToRedrawOnUpdate) |
2792 | { |
2793 | if (theView->ComputedMode()) |
2794 | { |
2795 | theView->Viewer()->Update(); |
2796 | } |
2797 | else |
2798 | { |
2799 | if (theView->IsInvalidated()) |
2800 | { |
2801 | theView->Viewer()->Redraw(); |
2802 | } |
2803 | else |
2804 | { |
2805 | theView->Viewer()->RedrawImmediate(); |
2806 | } |
2807 | } |
2808 | } |
2809 | |
2810 | return aStatus; |
2811 | } |
2812 | |
2813 | //======================================================================= |
2814 | //function : AddSelect |
2815 | //purpose : |
2816 | //======================================================================= |
2817 | AIS_StatusOfPick AIS_InteractiveContext::AddSelect (const Handle(SelectMgr_EntityOwner)& theObject) |
2818 | { |
2819 | mySelection->AddSelect (theObject); |
2820 | |
2821 | Standard_Integer aSelNum = NbSelected(); |
2822 | return (aSelNum == 0) ? AIS_SOP_NothingSelected |
2823 | : (aSelNum == 1) ? AIS_SOP_OneSelected |
2824 | : AIS_SOP_SeveralSelected; |
2825 | } |
2826 | |
2827 | //======================================================================= |
2828 | //function : SelectRectangle |
2829 | //purpose : |
2830 | //======================================================================= |
2831 | AIS_StatusOfPick AIS_InteractiveContext::SelectRectangle (const Graphic3d_Vec2i& thePntMin, |
2832 | const Graphic3d_Vec2i& thePntMax, |
2833 | const Handle(V3d_View)& theView, |
2834 | const AIS_SelectionScheme theSelScheme) |
2835 | { |
2836 | if (theView->Viewer() != myMainVwr) |
2837 | { |
2838 | throw Standard_ProgramError ("AIS_InteractiveContext::SelectRectangle() - invalid argument"); |
2839 | } |
2840 | |
2841 | myLastActiveView = theView.get(); |
45fc824b |
2842 | MainSelector()->Pick (thePntMin.x(), thePntMin.y(), thePntMax.x(), thePntMax.y(), theView); |
478862fc |
2843 | |
2844 | AIS_NArray1OfEntityOwner aPickedOwners; |
45fc824b |
2845 | if (MainSelector()->NbPicked() > 0) |
478862fc |
2846 | { |
45fc824b |
2847 | aPickedOwners.Resize (1, MainSelector()->NbPicked(), false); |
2848 | for (Standard_Integer aPickIter = 1; aPickIter <= MainSelector()->NbPicked(); ++aPickIter) |
478862fc |
2849 | { |
45fc824b |
2850 | aPickedOwners.SetValue (aPickIter, MainSelector()->Picked (aPickIter)); |
478862fc |
2851 | } |
2852 | } |
2853 | |
2854 | return Select (aPickedOwners, theSelScheme); |
2855 | } |
2856 | |
2857 | //======================================================================= |
2858 | //function : SelectPolygon |
2859 | //purpose : |
2860 | //======================================================================= |
2861 | AIS_StatusOfPick AIS_InteractiveContext::SelectPolygon (const TColgp_Array1OfPnt2d& thePolyline, |
2862 | const Handle(V3d_View)& theView, |
2863 | const AIS_SelectionScheme theSelScheme) |
2864 | { |
2865 | if (theView->Viewer() != myMainVwr) |
2866 | { |
2867 | throw Standard_ProgramError ("AIS_InteractiveContext::SelectPolygon() - invalid argument"); |
2868 | } |
2869 | |
2870 | myLastActiveView = theView.get(); |
45fc824b |
2871 | MainSelector()->Pick (thePolyline, theView); |
478862fc |
2872 | |
2873 | AIS_NArray1OfEntityOwner aPickedOwners; |
45fc824b |
2874 | if (MainSelector()->NbPicked() > 0) |
478862fc |
2875 | { |
45fc824b |
2876 | aPickedOwners.Resize (1, MainSelector()->NbPicked(), false); |
2877 | for (Standard_Integer aPickIter = 1; aPickIter <= MainSelector()->NbPicked(); ++aPickIter) |
478862fc |
2878 | { |
45fc824b |
2879 | aPickedOwners.SetValue (aPickIter, MainSelector()->Picked (aPickIter)); |
478862fc |
2880 | } |
2881 | } |
2882 | |
2883 | return Select (aPickedOwners, theSelScheme); |
2884 | } |
2885 | |
2886 | //======================================================================= |
2887 | //function : SelectPoint |
2888 | //purpose : |
2889 | //======================================================================= |
2890 | AIS_StatusOfPick AIS_InteractiveContext::SelectPoint (const Graphic3d_Vec2i& thePnt, |
2891 | const Handle(V3d_View)& theView, |
2892 | const AIS_SelectionScheme theSelScheme) |
2893 | { |
2894 | if (theView->Viewer() != myMainVwr) |
2895 | { |
2896 | throw Standard_ProgramError ("AIS_InteractiveContext::SelectPoint() - invalid argument"); |
2897 | } |
2898 | |
2899 | myLastActiveView = theView.get(); |
45fc824b |
2900 | MainSelector()->Pick (thePnt.x(), thePnt.y(), theView); |
478862fc |
2901 | |
2902 | AIS_NArray1OfEntityOwner aPickedOwners; |
45fc824b |
2903 | if (MainSelector()->NbPicked() > 0) |
478862fc |
2904 | { |
45fc824b |
2905 | aPickedOwners.Resize (1, MainSelector()->NbPicked(), false); |
2906 | for (Standard_Integer aPickIter = 1; aPickIter <= MainSelector()->NbPicked(); ++aPickIter) |
478862fc |
2907 | { |
45fc824b |
2908 | aPickedOwners.SetValue (aPickIter, MainSelector()->Picked (aPickIter)); |
478862fc |
2909 | } |
2910 | } |
2911 | |
2912 | return Select (aPickedOwners, theSelScheme); |
2913 | } |
2914 | |
2915 | //======================================================================= |
2916 | //function : SelectDetected |
2917 | //purpose : |
2918 | //======================================================================= |
2919 | AIS_StatusOfPick AIS_InteractiveContext::SelectDetected (const AIS_SelectionScheme theSelScheme) |
2920 | { |
2921 | if (theSelScheme == AIS_SelectionScheme_Replace && !myLastPicked.IsNull()) |
2922 | { |
2923 | Graphic3d_Vec2i aMousePos (-1, -1); |
45fc824b |
2924 | gp_Pnt2d aMouseRealPos = MainSelector()->GetManager().GetMousePosition(); |
e1eb39d2 |
2925 | if (!Precision::IsInfinite (aMouseRealPos.X()) && |
2926 | !Precision::IsInfinite (aMouseRealPos.Y())) |
478862fc |
2927 | { |
e1eb39d2 |
2928 | aMousePos.SetValues ((Standard_Integer )aMouseRealPos.X(), (Standard_Integer )aMouseRealPos.Y()); |
478862fc |
2929 | } |
2930 | if (myLastPicked->HandleMouseClick (aMousePos, Aspect_VKeyMouse_LeftButton, Aspect_VKeyFlags_NONE, false)) |
2931 | { |
2932 | return AIS_SOP_NothingSelected; |
2933 | } |
2934 | } |
2935 | |
2936 | AIS_NArray1OfEntityOwner aPickedOwners (1, 1); |
2937 | aPickedOwners.SetValue (1, myLastPicked); |
2938 | return Select (aPickedOwners, theSelScheme); |
2939 | } |
2940 | |
2941 | //======================================================================= |
2942 | //function : Select |
2943 | //purpose : |
2944 | //======================================================================= |
2945 | AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Integer theXPMin, |
2946 | const Standard_Integer theYPMin, |
2947 | const Standard_Integer theXPMax, |
2948 | const Standard_Integer theYPMax, |
2949 | const Handle(V3d_View)& theView, |
2950 | const Standard_Boolean theToUpdateViewer) |
2951 | { |
2952 | AIS_StatusOfPick aStatus = SelectRectangle (Graphic3d_Vec2i (theXPMin, theYPMin), |
2953 | Graphic3d_Vec2i (theXPMax, theYPMax), |
2954 | theView); |
2955 | if (theToUpdateViewer) |
2956 | { |
2957 | UpdateCurrentViewer(); |
2958 | } |
2959 | return aStatus; |
2960 | } |
2961 | |
2962 | //======================================================================= |
2963 | //function : Select |
2964 | //purpose : Selection by polyline |
2965 | //======================================================================= |
2966 | AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& thePolyline, |
2967 | const Handle(V3d_View)& theView, |
2968 | const Standard_Boolean theToUpdateViewer) |
2969 | { |
2970 | AIS_StatusOfPick aStatus = SelectPolygon (thePolyline, theView); |
2971 | if (theToUpdateViewer) |
2972 | { |
2973 | UpdateCurrentViewer(); |
2974 | } |
2975 | return aStatus; |
2976 | } |
2977 | |
2978 | //======================================================================= |
2979 | //function : Select |
2980 | //purpose : |
2981 | //======================================================================= |
2982 | AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Boolean theToUpdateViewer) |
2983 | { |
2984 | AIS_StatusOfPick aStatus = SelectDetected(); |
2985 | if (theToUpdateViewer) |
2986 | { |
2987 | UpdateCurrentViewer(); |
2988 | } |
2989 | return aStatus; |
2990 | } |
2991 | |
2992 | //======================================================================= |
2993 | //function : ShiftSelect |
2994 | //purpose : |
2995 | //======================================================================= |
2996 | AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Boolean theToUpdateViewer) |
2997 | { |
2998 | AIS_StatusOfPick aStatus = SelectDetected (AIS_SelectionScheme_XOR); |
2999 | if (theToUpdateViewer) |
3000 | { |
3001 | UpdateCurrentViewer(); |
3002 | } |
3003 | return aStatus; |
3004 | } |
3005 | |
3006 | //======================================================================= |
3007 | //function : ShiftSelect |
3008 | //purpose : |
3009 | //======================================================================= |
3010 | AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Integer theXPMin, |
3011 | const Standard_Integer theYPMin, |
3012 | const Standard_Integer theXPMax, |
3013 | const Standard_Integer theYPMax, |
3014 | const Handle(V3d_View)& theView, |
3015 | const Standard_Boolean theToUpdateViewer) |
3016 | { |
3017 | AIS_StatusOfPick aStatus = SelectRectangle (Graphic3d_Vec2i (theXPMin, theYPMin), |
3018 | Graphic3d_Vec2i (theXPMax, theYPMax), |
3019 | theView, |
3020 | AIS_SelectionScheme_XOR); |
3021 | if (theToUpdateViewer) |
3022 | { |
3023 | UpdateCurrentViewer(); |
3024 | } |
3025 | return aStatus; |
3026 | } |
3027 | |
3028 | //======================================================================= |
3029 | //function : ShiftSelect |
3030 | //purpose : |
3031 | //======================================================================= |
3032 | AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const TColgp_Array1OfPnt2d& thePolyline, |
3033 | const Handle(V3d_View)& theView, |
3034 | const Standard_Boolean theToUpdateViewer) |
3035 | { |
3036 | AIS_StatusOfPick aStatus = SelectPolygon (thePolyline, theView, AIS_SelectionScheme_XOR); |
3037 | if (theToUpdateViewer) |
3038 | { |
3039 | UpdateCurrentViewer(); |
3040 | } |
3041 | return aStatus; |
3042 | } |
3043 | |
3044 | //======================================================================= |
3045 | //function : Select |
3046 | //purpose : |
3047 | //======================================================================= |
3048 | AIS_StatusOfPick AIS_InteractiveContext::Select (const AIS_NArray1OfEntityOwner& theOwners, |
3049 | const AIS_SelectionScheme theSelScheme) |
3050 | { |
3051 | NCollection_IndexedMap<Handle(SelectMgr_EntityOwner)> aSelOwnerMap (myAutoHilight ? mySelection->Objects().Size() : 0); |
3052 | if (myAutoHilight) |
3053 | { |
3054 | clearDynamicHighlight(); |
3055 | |
3056 | // collect currently selected owners |
3057 | for (AIS_NListOfEntityOwner::Iterator anOwnerIter (mySelection->Objects()); anOwnerIter.More(); anOwnerIter.Next()) |
3058 | { |
3059 | aSelOwnerMap.Add (anOwnerIter.Value()); |
3060 | } |
3061 | } |
3062 | |
45fc824b |
3063 | mySelection->SelectOwners (theOwners, theSelScheme, MainSelector()->GetManager().IsOverlapAllowed(), myFilters); |
478862fc |
3064 | |
3065 | if (myAutoHilight) |
3066 | { |
3067 | // collect lists of owners to unhighlight (unselected) and to highlight (selected) |
3068 | AIS_NListOfEntityOwner anOwnersToUnhighlight, anOwnersToHighlight; |
3069 | for (AIS_NListOfEntityOwner::Iterator anOwnerIter (mySelection->Objects()); anOwnerIter.More(); anOwnerIter.Next()) |
3070 | { |
3071 | // add newly selected owners |
3072 | const Handle(SelectMgr_EntityOwner)& anOwner = anOwnerIter.Value(); |
3073 | if (!aSelOwnerMap.RemoveKey (anOwner)) |
3074 | { |
3075 | // newly selected owner |
3076 | anOwnersToHighlight.Append (anOwner); |
3077 | } |
3078 | else |
3079 | { |
3080 | // already selected owner |
3081 | if (!anOwner->IsAutoHilight() |
3082 | && theSelScheme != AIS_SelectionScheme_XOR |
3083 | && theSelScheme != AIS_SelectionScheme_Add) |
3084 | { |
3085 | // hack to perform AIS_InteractiveObject::ClearSelected() before highlighting |
3086 | anOwnersToUnhighlight.Append (anOwner); |
3087 | anOwnersToHighlight.Append (anOwner); |
3088 | } |
3089 | else if (anOwner->IsForcedHilight() |
3090 | || !anOwner->IsAutoHilight()) |
3091 | { |
3092 | anOwnersToHighlight.Append (anOwner); |
3093 | } |
3094 | } |
3095 | } |
3096 | |
3097 | for (NCollection_IndexedMap<Handle(SelectMgr_EntityOwner)>::Iterator anOwnerIter (aSelOwnerMap); anOwnerIter.More(); anOwnerIter.Next()) |
3098 | { |
3099 | // owners removed from selection |
3100 | const Handle(SelectMgr_EntityOwner)& anOwner = anOwnerIter.Value(); |
3101 | anOwnersToUnhighlight.Append (anOwner); |
3102 | } |
3103 | |
3104 | unhighlightOwners (anOwnersToUnhighlight); |
3105 | highlightOwners (anOwnersToHighlight, Handle(Prs3d_Drawer)()); |
3106 | } |
3107 | |
3108 | Standard_Integer aSelNum = NbSelected(); |
3109 | return (aSelNum == 0) ? AIS_SOP_NothingSelected |
3110 | : (aSelNum == 1) ? AIS_SOP_OneSelected |
3111 | : AIS_SOP_SeveralSelected; |
3112 | } |
3113 | |
3114 | //======================================================================= |
3115 | //function : HilightSelected |
3116 | //purpose : |
3117 | //======================================================================= |
3118 | void AIS_InteractiveContext::HilightSelected (const Standard_Boolean theToUpdateViewer) |
3119 | { |
3120 | // In case of selection without using local context |
3121 | clearDynamicHighlight(); |
3122 | |
3123 | highlightOwners (mySelection->Objects(), Handle(Prs3d_Drawer)()); |
3124 | |
3125 | if (theToUpdateViewer) |
3126 | { |
3127 | UpdateCurrentViewer(); |
3128 | } |
3129 | } |
3130 | |
3131 | //======================================================================= |
3132 | //function : highlightOwners |
3133 | //purpose : |
3134 | //======================================================================= |
3135 | void AIS_InteractiveContext::highlightOwners (const AIS_NListOfEntityOwner& theOwners, |
3136 | const Handle(Prs3d_Drawer)& theStyle) |
3137 | { |
3138 | NCollection_DataMap<Handle(AIS_InteractiveObject), NCollection_Handle<SelectMgr_SequenceOfOwner> > anObjOwnerMap; |
3139 | for (AIS_NListOfEntityOwner::Iterator aSelIter (theOwners); aSelIter.More(); aSelIter.Next()) |
3140 | { |
3141 | const Handle(SelectMgr_EntityOwner) anOwner = aSelIter.Value(); |
3142 | const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable()); |
3143 | if (anObj.IsNull()) |
3144 | continue; |
3145 | |
3146 | const Handle(Prs3d_Drawer)& anObjSelStyle = !theStyle.IsNull() ? theStyle : getSelStyle (anObj, anOwner); |
3147 | Handle(AIS_GlobalStatus)* aStatusPtr = myObjects.ChangeSeek (anObj); |
3148 | if (!aStatusPtr) |
3149 | { |
3150 | continue; |
3151 | } |
3152 | if (anOwner == anObj->GlobalSelOwner()) |
3153 | { |
3154 | (*aStatusPtr)->SetHilightStatus (Standard_True); |
3155 | (*aStatusPtr)->SetHilightStyle (anObjSelStyle); |
3156 | } |
3157 | if (!anOwner->IsAutoHilight()) |
3158 | { |
3159 | NCollection_Handle<SelectMgr_SequenceOfOwner> aSeq; |
3160 | if (anObjOwnerMap.Find (anObj, aSeq)) |
3161 | { |
3162 | aSeq->Append (anOwner); |
3163 | } |
3164 | else |
3165 | { |
3166 | aSeq = new SelectMgr_SequenceOfOwner(); |
3167 | aSeq->Append (anOwner); |
3168 | anObjOwnerMap.Bind (anObj, aSeq); |
3169 | } |
3170 | } |
3171 | else |
3172 | { |
3173 | const Standard_Integer aHiMode = getHilightMode (anObj, anObjSelStyle, (*aStatusPtr)->DisplayMode()); |
3174 | anOwner->HilightWithColor (myMainPM, anObjSelStyle, aHiMode); |
3175 | } |
3176 | } |
3177 | |
3178 | if (!anObjOwnerMap.IsEmpty()) |
3179 | { |
3180 | for (NCollection_DataMap<Handle(AIS_InteractiveObject), NCollection_Handle<SelectMgr_SequenceOfOwner> >::Iterator anIter (anObjOwnerMap); |
3181 | anIter.More(); anIter.Next()) |
3182 | { |
3183 | anIter.Key()->HilightSelected (myMainPM, *anIter.Value()); |
3184 | } |
3185 | anObjOwnerMap.Clear(); |
3186 | } |
3187 | } |
3188 | |
3189 | //======================================================================= |
3190 | //function : UnhilightSelected |
3191 | //purpose : |
3192 | //======================================================================= |
3193 | void AIS_InteractiveContext::UnhilightSelected (const Standard_Boolean theToUpdateViewer) |
3194 | { |
3195 | unhighlightSelected(); |
3196 | |
3197 | if (theToUpdateViewer) |
3198 | { |
3199 | UpdateCurrentViewer(); |
3200 | } |
3201 | } |
3202 | |
3203 | //======================================================================= |
3204 | //function : ClearSelected |
3205 | //purpose : |
3206 | //======================================================================= |
3207 | void AIS_InteractiveContext::ClearSelected (const Standard_Boolean theToUpdateViewer) |
3208 | { |
3209 | if (NbSelected() == 0) |
3210 | { |
3211 | return; |
3212 | } |
3213 | |
3214 | if (myAutoHilight) |
3215 | { |
3216 | unhighlightSelected(); |
3217 | } |
3218 | |
3219 | mySelection->Clear(); |
3220 | if (myAutoHilight) |
3221 | { |
3222 | clearDynamicHighlight(); |
3223 | } |
3224 | |
3225 | if (theToUpdateViewer) |
3226 | { |
3227 | UpdateCurrentViewer(); |
3228 | } |
3229 | } |
3230 | |
f9998f03 |
3231 | //======================================================================= |
3232 | //function : isDetected |
3233 | //purpose : |
3234 | //======================================================================= |
3235 | Standard_Boolean AIS_InteractiveContext::isDetected (const Handle(AIS_InteractiveObject)& theObject) |
3236 | { |
3237 | for (Standard_Integer aDetIter = myDetectedSeq.Lower(); aDetIter <= myDetectedSeq.Upper(); aDetIter++) |
3238 | { |
3239 | Handle(SelectMgr_EntityOwner) aPicked = MainSelector()->Picked(myDetectedSeq(aDetIter)); |
3240 | Handle(AIS_InteractiveObject) anObj; |
3241 | if (!aPicked.IsNull()) |
3242 | { |
3243 | anObj = Handle(AIS_InteractiveObject)::DownCast(aPicked->Selectable()); |
3244 | } |
3245 | |
3246 | if (!anObj.IsNull() |
3247 | && anObj == theObject) |
3248 | { |
3249 | return Standard_True; |
3250 | } |
3251 | } |
3252 | return Standard_False; |
3253 | } |
3254 | |
478862fc |
3255 | //======================================================================= |
3256 | //function : SetSelected |
3257 | //purpose : Sets the whole object as selected and highlights it with selection color |
3258 | //======================================================================= |
3259 | void AIS_InteractiveContext::SetSelected (const Handle(AIS_InteractiveObject)& theObject, |
3260 | const Standard_Boolean theToUpdateViewer) |
3261 | { |
3262 | if (theObject.IsNull()) |
3263 | { |
3264 | return; |
3265 | } |
3266 | |
3267 | if (!myObjects.IsBound (theObject)) |
3268 | { |
3269 | return; |
3270 | } |
3271 | |
3272 | Handle(SelectMgr_EntityOwner) anOwner = theObject->GlobalSelOwner(); |
3273 | if (anOwner.IsNull()) |
3274 | { |
3275 | return; |
3276 | } |
3277 | |
3278 | const Handle(Prs3d_Drawer)& anObjSelStyle = getSelStyle (theObject, anOwner); |
3279 | if (NbSelected() == 1 && myObjects (theObject)->IsHilighted() && myAutoHilight) |
3280 | { |
3281 | Handle(Prs3d_Drawer) aCustomStyle; |
3282 | if (HighlightStyle (theObject, aCustomStyle)) |
3283 | { |
3284 | if (!aCustomStyle.IsNull() && anObjSelStyle != aCustomStyle) |
3285 | { |
3286 | HilightWithColor (theObject, anObjSelStyle, theToUpdateViewer); |
3287 | } |
3288 | } |
3289 | return; |
3290 | } |
3291 | |
3292 | for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next()) |
3293 | { |
3294 | const Handle(SelectMgr_EntityOwner)& aSelOwner = aSelIter.Value(); |
3295 | if (!myFilters->IsOk (aSelOwner)) |
3296 | { |
3297 | continue; |
3298 | } |
3299 | |
3300 | Handle(AIS_InteractiveObject) aSelectable = Handle(AIS_InteractiveObject)::DownCast (aSelOwner->Selectable()); |
3301 | if (myAutoHilight) |
3302 | { |
3303 | Unhilight (aSelectable, Standard_False); |
3304 | } |
3305 | if (aSelOwner == aSelectable->GlobalSelOwner()) |
3306 | { |
3307 | if (Handle(AIS_GlobalStatus)* aStatusPtr = myObjects.ChangeSeek (aSelectable)) |
3308 | { |
3309 | (*aStatusPtr)->SetHilightStatus (Standard_False); |
3310 | } |
3311 | } |
3312 | } |
3313 | |
3314 | // added to avoid untimely viewer update... |
f9998f03 |
3315 | const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable()); |
3316 | mySelection->ClearAndSelect (anOwner, myFilters, isDetected (anObj)); |
478862fc |
3317 | |
3318 | if (myAutoHilight) |
3319 | { |
3320 | Handle(Prs3d_Drawer) aCustomStyle; |
3321 | if (HighlightStyle (theObject, aCustomStyle)) |
3322 | { |
3323 | if (!aCustomStyle.IsNull() && anObjSelStyle != aCustomStyle) |
3324 | { |
3325 | HilightWithColor (theObject, anObjSelStyle, Standard_False); |
3326 | } |
3327 | } |
3328 | else |
3329 | { |
3330 | HilightWithColor (theObject, anObjSelStyle, Standard_False); |
3331 | } |
3332 | } |
3333 | |
3334 | if (theToUpdateViewer) |
3335 | { |
3336 | UpdateCurrentViewer(); |
3337 | } |
3338 | } |
3339 | |
3340 | //======================================================================= |
3341 | //function : SetSelected |
3342 | //purpose : Sets the whole object as selected and highlights it with selection color |
3343 | //======================================================================= |
3344 | void AIS_InteractiveContext::SetSelected (const Handle(SelectMgr_EntityOwner)& theOwner, |
3345 | const Standard_Boolean theToUpdateViewer) |
3346 | { |
3347 | if (theOwner.IsNull() || !theOwner->HasSelectable() || !myFilters->IsOk (theOwner)) |
3348 | { |
3349 | return; |
3350 | } |
3351 | |
3352 | const Handle(AIS_InteractiveObject) anObject = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()); |
3353 | const Handle(Prs3d_Drawer)& anObjSelStyle = getSelStyle (anObject, theOwner); |
3354 | if (NbSelected() == 1 && theOwner->IsSelected() && !theOwner->IsForcedHilight()) |
3355 | { |
3356 | Handle(Prs3d_Drawer) aCustomStyle; |
3357 | if (myAutoHilight && HighlightStyle (theOwner, aCustomStyle)) |
3358 | { |
3359 | if (!aCustomStyle.IsNull() && anObjSelStyle != aCustomStyle) |
3360 | { |
3361 | const Standard_Integer aHiMode = anObject->HasHilightMode() ? anObject->HilightMode() : 0; |
3362 | theOwner->HilightWithColor (myMainPM, anObjSelStyle, aHiMode); |
3363 | } |
3364 | } |
3365 | return; |
3366 | } |
3367 | |
3368 | if (!myObjects.IsBound (anObject)) |
3369 | { |
3370 | return; |
3371 | } |
3372 | |
3373 | if (myAutoHilight) |
3374 | { |
3375 | unhighlightSelected(); |
3376 | } |
3377 | |
f9998f03 |
3378 | mySelection->ClearAndSelect (theOwner, myFilters, isDetected (anObject)); |
478862fc |
3379 | if (myAutoHilight) |
3380 | { |
3381 | Handle(Prs3d_Drawer) aCustomStyle; |
3382 | if (!HighlightStyle (theOwner, aCustomStyle) || |
3383 | (!aCustomStyle.IsNull() && aCustomStyle != anObjSelStyle)) |
3384 | { |
3385 | highlightSelected (theOwner); |
3386 | } |
3387 | } |
3388 | |
3389 | if (theToUpdateViewer) |
3390 | { |
3391 | UpdateCurrentViewer(); |
3392 | } |
3393 | } |
3394 | |
3395 | //======================================================================= |
3396 | //function : AddOrRemoveSelected |
3397 | //purpose : |
3398 | //======================================================================= |
3399 | void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(AIS_InteractiveObject)& theObject, |
3400 | const Standard_Boolean theToUpdateViewer) |
3401 | { |
3402 | if (theObject.IsNull() |
3403 | || !myObjects.IsBound (theObject)) |
3404 | { |
3405 | return; |
3406 | } |
3407 | |
3408 | const Handle(SelectMgr_EntityOwner) anOwner = theObject->GlobalSelOwner(); |
3409 | if (!anOwner.IsNull() |
3410 | && anOwner->HasSelectable()) |
3411 | { |
3412 | AddOrRemoveSelected (anOwner, theToUpdateViewer); |
3413 | } |
3414 | } |
3415 | |
3416 | //======================================================================= |
3417 | //function : AddOrRemoveSelected |
3418 | //purpose : Allows to highlight or unhighlight the owner given depending on |
3419 | // its selection status |
3420 | //======================================================================= |
3421 | void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(SelectMgr_EntityOwner)& theOwner, |
3422 | const Standard_Boolean theToUpdateViewer) |
3423 | { |
3424 | if (theOwner.IsNull() || !theOwner->HasSelectable()) |
3425 | { |
3426 | return; |
3427 | } |
3428 | |
f9998f03 |
3429 | if (!myFilters->IsOk (theOwner) && !theOwner->IsSelected()) |
478862fc |
3430 | { |
3431 | return; |
3432 | } |
3433 | |
f9998f03 |
3434 | AIS_SelectionScheme aSelScheme = theOwner->IsSelected() ? AIS_SelectionScheme_Remove : AIS_SelectionScheme_Add; |
3435 | const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()); |
3436 | mySelection->Select (theOwner, myFilters, aSelScheme, isDetected (anObj)); |
478862fc |
3437 | |
3438 | if (myAutoHilight) |
3439 | { |
478862fc |
3440 | Handle(AIS_GlobalStatus)* aStatusPtr = myObjects.ChangeSeek (anObj); |
3441 | if (!aStatusPtr) |
3442 | { |
3443 | return; |
3444 | } |
3445 | |
3446 | if (theOwner->IsSelected()) |
3447 | { |
3448 | highlightSelected (theOwner); |
3449 | } |
3450 | else |
3451 | { |
3452 | AIS_NListOfEntityOwner anOwners; |
3453 | anOwners.Append (theOwner); |
3454 | unhighlightOwners (anOwners); |
3455 | |
3456 | (*aStatusPtr)->SetHilightStyle (Handle(Prs3d_Drawer)()); |
3457 | } |
3458 | } |
3459 | |
3460 | if (theToUpdateViewer) |
3461 | { |
3462 | UpdateCurrentViewer(); |
3463 | } |
3464 | } |
3465 | |
3466 | // ======================================================================= |
3467 | // function : SetSelectedState |
3468 | // purpose : |
3469 | // ======================================================================= |
3470 | Standard_Boolean AIS_InteractiveContext::SetSelectedState (const Handle(SelectMgr_EntityOwner)& theEntity, |
3471 | const Standard_Boolean theIsSelected) |
3472 | { |
3473 | if (theEntity.IsNull()) |
3474 | { |
3475 | throw Standard_ProgramError ("Internal error: AIS_InteractiveContext::SetSelectedState() called with NO object"); |
3476 | } |
3477 | |
3478 | if (!theEntity->HasSelectable() |
3479 | || mySelection->IsSelected (theEntity) == theIsSelected) |
3480 | { |
3481 | return false; |
3482 | } |
3483 | |
3484 | if (theEntity->IsAutoHilight()) |
3485 | { |
3486 | AddOrRemoveSelected (theEntity, false); |
3487 | return true; |
3488 | } |
3489 | |
3490 | if (theIsSelected) |
3491 | { |
3492 | const AIS_SelectStatus aSelStatus = mySelection->AddSelect (theEntity); |
3493 | theEntity->SetSelected (true); |
3494 | return aSelStatus == AIS_SS_Added; |
3495 | } |
3496 | else |
3497 | { |
f9998f03 |
3498 | const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast(theEntity->Selectable()); |
3499 | const AIS_SelectStatus aSelStatus = mySelection->Select (theEntity, myFilters, AIS_SelectionScheme_Remove, isDetected (anObj)); |
478862fc |
3500 | theEntity->SetSelected (false); |
3501 | return aSelStatus == AIS_SS_Removed; |
3502 | } |
3503 | } |
3504 | |
3505 | //======================================================================= |
3506 | //function : IsSelected |
3507 | //purpose : |
3508 | //======================================================================= |
3509 | Standard_Boolean AIS_InteractiveContext::IsSelected (const Handle(AIS_InteractiveObject)& theObj) const |
3510 | { |
3511 | if (theObj.IsNull()) |
3512 | { |
3513 | return Standard_False; |
3514 | } |
3515 | |
3516 | const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theObj); |
3517 | if (aStatus == NULL) |
3518 | { |
3519 | return Standard_False; |
3520 | } |
3521 | |
3522 | const Standard_Integer aGlobalSelMode = theObj->GlobalSelectionMode(); |
3523 | const TColStd_ListOfInteger& anActivatedModes = (*aStatus)->SelectionModes(); |
3524 | for (TColStd_ListIteratorOfListOfInteger aModeIter (anActivatedModes); aModeIter.More(); aModeIter.Next()) |
3525 | { |
3526 | if (aModeIter.Value() == aGlobalSelMode) |
3527 | { |
3528 | if (Handle(SelectMgr_EntityOwner) aGlobOwner = theObj->GlobalSelOwner()) |
3529 | { |
3530 | return aGlobOwner->IsSelected(); |
3531 | } |
3532 | return Standard_False; |
3533 | } |
3534 | } |
3535 | return Standard_False; |
3536 | } |
3537 | |
3538 | //======================================================================= |
3539 | //function : FirstSelectedObject |
3540 | //purpose : |
3541 | //======================================================================= |
3542 | Handle(AIS_InteractiveObject) AIS_InteractiveContext::FirstSelectedObject() const |
3543 | { |
3544 | return !mySelection->Objects().IsEmpty() |
3545 | ? Handle(AIS_InteractiveObject)::DownCast (mySelection->Objects().First()->Selectable()) |
3546 | : Handle(AIS_InteractiveObject)(); |
3547 | } |
3548 | |
3549 | //======================================================================= |
3550 | //function : HasSelectedShape |
3551 | //purpose : |
3552 | //======================================================================= |
3553 | Standard_Boolean AIS_InteractiveContext::HasSelectedShape() const |
3554 | { |
3555 | if (!mySelection->More()) |
3556 | { |
3557 | return Standard_False; |
3558 | } |
3559 | |
3560 | const Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast (mySelection->Value()); |
3561 | return !anOwner.IsNull() && anOwner->HasShape(); |
3562 | } |
3563 | |
3564 | //======================================================================= |
3565 | //function : SelectedShape |
3566 | //purpose : |
3567 | //======================================================================= |
3568 | TopoDS_Shape AIS_InteractiveContext::SelectedShape() const |
3569 | { |
3570 | if (!mySelection->More()) |
3571 | { |
3572 | return TopoDS_Shape(); |
3573 | } |
3574 | |
3575 | const Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast (mySelection->Value()); |
3576 | if (anOwner.IsNull() || !anOwner->HasSelectable()) |
3577 | { |
3578 | return TopoDS_Shape(); |
3579 | } |
3580 | |
3581 | return anOwner->Shape().Located (anOwner->Location() * anOwner->Shape().Location()); |
3582 | } |
3583 | |
3584 | //======================================================================= |
3585 | //function : EntityOwners |
3586 | //purpose : |
3587 | //======================================================================= |
3588 | void AIS_InteractiveContext::EntityOwners (Handle(SelectMgr_IndexedMapOfOwner)& theOwners, |
3589 | const Handle(AIS_InteractiveObject)& theIObj, |
3590 | const Standard_Integer theMode) const |
3591 | { |
3592 | if (theIObj.IsNull()) |
3593 | { |
3594 | return; |
3595 | } |
3596 | |
3597 | TColStd_ListOfInteger aModes; |
3598 | if (theMode == -1) |
3599 | { |
3600 | ActivatedModes (theIObj, aModes); |
3601 | } |
3602 | else |
3603 | { |
3604 | aModes.Append (theMode); |
3605 | } |
3606 | |
3607 | if (theOwners.IsNull()) |
3608 | { |
3609 | theOwners = new SelectMgr_IndexedMapOfOwner(); |
3610 | } |
3611 | |
3612 | for (TColStd_ListIteratorOfListOfInteger anItr (aModes); anItr.More(); anItr.Next()) |
3613 | { |
3614 | const int aMode = anItr.Value(); |
3615 | const Handle(SelectMgr_Selection)& aSel = theIObj->Selection (aMode); |
3616 | if (aSel.IsNull()) |
3617 | { |
3618 | continue; |
3619 | } |
3620 | |
3621 | for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSel->Entities()); aSelEntIter.More(); aSelEntIter.Next()) |
3622 | { |
3623 | if (Handle(Select3D_SensitiveEntity) aEntity = aSelEntIter.Value()->BaseSensitive()) |
3624 | { |
3625 | if (const Handle(SelectMgr_EntityOwner)& aOwner = aEntity->OwnerId()) |
3626 | { |
3627 | theOwners->Add (aOwner); |
3628 | } |
3629 | } |
3630 | } |
3631 | } |
3632 | } |
3633 | |
3634 | //======================================================================= |
3635 | //function : HasDetectedShape |
3636 | //purpose : |
3637 | //======================================================================= |
3638 | Standard_Boolean AIS_InteractiveContext::HasDetectedShape() const |
3639 | { |
3640 | Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast (myLastPicked); |
3641 | return !anOwner.IsNull() |
3642 | && anOwner->HasShape(); |
3643 | } |
3644 | |
3645 | //======================================================================= |
3646 | //function : DetectedShape |
3647 | //purpose : |
3648 | //======================================================================= |
3649 | const TopoDS_Shape& AIS_InteractiveContext::DetectedShape() const |
3650 | { |
3651 | Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast (myLastPicked); |
3652 | return anOwner->Shape(); |
3653 | } |
3654 | |
3655 | //======================================================================= |
3656 | //function : HilightNextDetected |
3657 | //purpose : |
3658 | //======================================================================= |
3659 | Standard_Integer AIS_InteractiveContext::HilightNextDetected (const Handle(V3d_View)& theView, |
3660 | const Standard_Boolean theToRedrawImmediate) |
3661 | { |
3662 | myMainPM->ClearImmediateDraw(); |
3663 | if (myDetectedSeq.IsEmpty()) |
3664 | { |
3665 | return 0; |
3666 | } |
3667 | |
3668 | if (++myCurHighlighted > myDetectedSeq.Upper()) |
3669 | { |
3670 | myCurHighlighted = myDetectedSeq.Lower(); |
3671 | } |
45fc824b |
3672 | const Handle(SelectMgr_EntityOwner)& anOwner = MainSelector()->Picked (myDetectedSeq (myCurHighlighted)); |
478862fc |
3673 | if (anOwner.IsNull()) |
3674 | { |
3675 | return 0; |
3676 | } |
3677 | |
3678 | highlightWithColor (anOwner, theView->Viewer()); |
3679 | myLastPicked = anOwner; |
3680 | |
3681 | if (theToRedrawImmediate) |
3682 | { |
3683 | myMainPM->RedrawImmediate (theView->Viewer()); |
3684 | myMainVwr->RedrawImmediate(); |
3685 | } |
3686 | |
3687 | return myCurHighlighted; |
3688 | } |
3689 | |
3690 | //======================================================================= |
3691 | //function : HilightPreviousDetected |
3692 | //purpose : |
3693 | //======================================================================= |
3694 | Standard_Integer AIS_InteractiveContext::HilightPreviousDetected (const Handle(V3d_View)& theView, |
3695 | const Standard_Boolean theToRedrawImmediate) |
3696 | { |
3697 | myMainPM->ClearImmediateDraw(); |
3698 | if (myDetectedSeq.IsEmpty()) |
3699 | { |
3700 | return 0; |
3701 | } |
3702 | |
3703 | if (--myCurHighlighted < myDetectedSeq.Lower()) |
3704 | { |
3705 | myCurHighlighted = myDetectedSeq.Upper(); |
3706 | } |
45fc824b |
3707 | const Handle(SelectMgr_EntityOwner)& anOwner = MainSelector()->Picked (myDetectedSeq (myCurHighlighted)); |
478862fc |
3708 | if (anOwner.IsNull()) |
3709 | { |
3710 | return 0; |
3711 | } |
3712 | |
3713 | highlightWithColor (anOwner, theView->Viewer()); |
3714 | myLastPicked = anOwner; |
3715 | |
3716 | if (theToRedrawImmediate) |
3717 | { |
3718 | myMainPM->RedrawImmediate (theView->Viewer()); |
3719 | myMainVwr->RedrawImmediate(); |
3720 | } |
3721 | |
3722 | return myCurHighlighted; |
3723 | } |
3724 | |
3725 | //======================================================================= |
3726 | //function : DetectedCurrentOwner |
3727 | //purpose : |
3728 | //======================================================================= |
3729 | Handle(SelectMgr_EntityOwner) AIS_InteractiveContext::DetectedCurrentOwner() const |
3730 | { |
3731 | return MoreDetected() |
45fc824b |
3732 | ? MainSelector()->Picked (myDetectedSeq (myCurDetected)) |
478862fc |
3733 | : Handle(SelectMgr_EntityOwner)(); |
3734 | } |
3735 | |
3736 | //======================================================================= |
3737 | //function : DetectedCurrentShape |
3738 | //purpose : |
3739 | //======================================================================= |
3740 | const TopoDS_Shape& AIS_InteractiveContext::DetectedCurrentShape() const |
3741 | { |
3742 | static const TopoDS_Shape AIS_InteractiveContext_myDummyShape; |
3743 | |
3744 | Standard_DISABLE_DEPRECATION_WARNINGS |
3745 | Handle(AIS_Shape) aCurrentShape = Handle(AIS_Shape)::DownCast (DetectedCurrentObject()); |
3746 | Standard_ENABLE_DEPRECATION_WARNINGS |
3747 | return !aCurrentShape.IsNull() |
3748 | ? aCurrentShape->Shape() |
3749 | : AIS_InteractiveContext_myDummyShape; |
3750 | } |
3751 | |
3752 | //======================================================================= |
3753 | //function : DetectedCurrentObject |
3754 | //purpose : |
3755 | //======================================================================= |
3756 | Handle(AIS_InteractiveObject) AIS_InteractiveContext::DetectedCurrentObject() const |
3757 | { |
3758 | return MoreDetected() |
45fc824b |
3759 | ? Handle(AIS_InteractiveObject)::DownCast (MainSelector()->Picked (myDetectedSeq (myCurDetected))->Selectable()) |
478862fc |
3760 | : Handle(AIS_InteractiveObject)(); |
3761 | } |
3762 | |
3763 | //======================================================================= |
3764 | //function : SetSelectionModeActive |
3765 | //purpose : |
3766 | //======================================================================= |
3767 | void AIS_InteractiveContext::SetSelectionModeActive (const Handle(AIS_InteractiveObject)& theObj, |
3768 | const Standard_Integer theMode, |
3769 | const Standard_Boolean theIsActive, |
3770 | const AIS_SelectionModesConcurrency theActiveFilter, |
3771 | const Standard_Boolean theIsForce) |
3772 | { |
3773 | if (theObj.IsNull()) |
3774 | { |
3775 | return; |
3776 | } |
3777 | |
3778 | const Handle(AIS_GlobalStatus)* aStat = myObjects.Seek (theObj); |
3779 | if (aStat == NULL) |
3780 | { |
3781 | return; |
3782 | } |
3783 | |
3784 | if (!theIsActive |
3785 | || (theMode == -1 |
3786 | && theActiveFilter == AIS_SelectionModesConcurrency_Single)) |
3787 | { |
3788 | if (theObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed |
3789 | || theIsForce) |
3790 | { |
3791 | if (theMode == -1) |
3792 | { |
3793 | for (TColStd_ListIteratorOfListOfInteger aModeIter ((*aStat)->SelectionModes()); aModeIter.More(); aModeIter.Next()) |
3794 | { |
3795 | mgrSelector->Deactivate (theObj, aModeIter.Value()); |
3796 | } |
3797 | } |
3798 | else |
3799 | { |
3800 | mgrSelector->Deactivate (theObj, theMode); |
3801 | } |
3802 | } |
3803 | |
3804 | if (theMode == -1) |
3805 | { |
3806 | (*aStat)->ClearSelectionModes(); |
3807 | } |
3808 | else |
3809 | { |
3810 | (*aStat)->RemoveSelectionMode (theMode); |
3811 | } |
3812 | return; |
3813 | } |
3814 | else if (theMode == -1) |
3815 | { |
3816 | return; |
3817 | } |
3818 | |
3819 | if ((*aStat)->SelectionModes().Size() == 1 |
3820 | && (*aStat)->SelectionModes().First() == theMode) |
3821 | { |
3822 | return; |
3823 | } |
3824 | |
3825 | if (theObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed |
3826 | || theIsForce) |
3827 | { |
3828 | switch (theActiveFilter) |
3829 | { |
3830 | case AIS_SelectionModesConcurrency_Single: |
3831 | { |
3832 | for (TColStd_ListIteratorOfListOfInteger aModeIter ((*aStat)->SelectionModes()); aModeIter.More(); aModeIter.Next()) |
3833 | { |
3834 | mgrSelector->Deactivate (theObj, aModeIter.Value()); |
3835 | } |
3836 | (*aStat)->ClearSelectionModes(); |
3837 | break; |
3838 | } |
3839 | case AIS_SelectionModesConcurrency_GlobalOrLocal: |
3840 | { |
3841 | const Standard_Integer aGlobSelMode = theObj->GlobalSelectionMode(); |
3842 | TColStd_ListOfInteger aRemovedModes; |
3843 | for (TColStd_ListIteratorOfListOfInteger aModeIter ((*aStat)->SelectionModes()); aModeIter.More(); aModeIter.Next()) |
3844 | { |
3845 | if ((theMode == aGlobSelMode && aModeIter.Value() != aGlobSelMode) |
3846 | || (theMode != aGlobSelMode && aModeIter.Value() == aGlobSelMode)) |
3847 | { |
3848 | mgrSelector->Deactivate (theObj, aModeIter.Value()); |
3849 | aRemovedModes.Append (aModeIter.Value()); |
3850 | } |
3851 | } |
3852 | if (aRemovedModes.Size() == (*aStat)->SelectionModes().Size()) |
3853 | { |
3854 | (*aStat)->ClearSelectionModes(); |
3855 | } |
3856 | else |
3857 | { |
3858 | for (TColStd_ListIteratorOfListOfInteger aModeIter (aRemovedModes); aModeIter.More(); aModeIter.Next()) |
3859 | { |
3860 | (*aStat)->RemoveSelectionMode (aModeIter.Value()); |
3861 | } |
3862 | } |
3863 | break; |
3864 | } |
3865 | case AIS_SelectionModesConcurrency_Multiple: |
3866 | { |
3867 | break; |
3868 | } |
3869 | } |
3870 | mgrSelector->Activate (theObj, theMode); |
3871 | } |
3872 | (*aStat)->AddSelectionMode (theMode); |
3873 | } |
3874 | |
3875 | // ============================================================================ |
3876 | // function : Activate |
3877 | // purpose : |
3878 | // ============================================================================ |
3879 | void AIS_InteractiveContext::Activate (const Standard_Integer theMode, |
3880 | const Standard_Boolean theIsForce) |
3881 | { |
3882 | AIS_ListOfInteractive aDisplayedObjects; |
3883 | DisplayedObjects (aDisplayedObjects); |
3884 | for (AIS_ListOfInteractive::Iterator anIter (aDisplayedObjects); anIter.More(); anIter.Next()) |
3885 | { |
3886 | Load (anIter.Value(), -1); |
3887 | Activate (anIter.Value(), theMode, theIsForce); |
3888 | } |
3889 | } |
3890 | |
3891 | // ============================================================================ |
3892 | // function : Deactivate |
3893 | // purpose : |
3894 | // ============================================================================ |
3895 | void AIS_InteractiveContext::Deactivate (const Standard_Integer theMode) |
3896 | { |
3897 | AIS_ListOfInteractive aDisplayedObjects; |
3898 | DisplayedObjects (aDisplayedObjects); |
3899 | for (AIS_ListOfInteractive::Iterator anIter (aDisplayedObjects); anIter.More(); anIter.Next()) |
3900 | { |
3901 | Deactivate (anIter.Value(), theMode); |
3902 | } |
3903 | } |
3904 | |
3905 | // ============================================================================ |
3906 | // function : Deactivate |
3907 | // purpose : |
3908 | // ============================================================================ |
3909 | void AIS_InteractiveContext::Deactivate() |
3910 | { |
3911 | AIS_ListOfInteractive aDisplayedObjects; |
3912 | DisplayedObjects (aDisplayedObjects); |
3913 | |
3914 | for (AIS_ListOfInteractive::Iterator anIter (aDisplayedObjects); anIter.More(); anIter.Next()) |
3915 | { |
3916 | Deactivate (anIter.Value()); |
3917 | } |
3918 | } |
3919 | |
3920 | //======================================================================= |
3921 | //function : ActivatedModes |
3922 | //purpose : |
3923 | //======================================================================= |
3924 | void AIS_InteractiveContext::ActivatedModes (const Handle(AIS_InteractiveObject)& theObj, |
3925 | TColStd_ListOfInteger& theList) const |
3926 | { |
3927 | const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theObj); |
3928 | if (aStatus != NULL) |
3929 | { |
3930 | for (TColStd_ListIteratorOfListOfInteger aModeIter ((*aStatus)->SelectionModes()); aModeIter.More(); aModeIter.Next()) |
3931 | { |
3932 | theList.Append (aModeIter.Value()); |
3933 | } |
3934 | } |
3935 | } |
3936 | |
3937 | //======================================================================= |
3938 | //function : SubIntensityOn |
3939 | //purpose : |
3940 | //======================================================================= |
3941 | void AIS_InteractiveContext::SubIntensityOn (const Handle(AIS_InteractiveObject)& theObj, |
3942 | const Standard_Boolean theToUpdateViewer) |
3943 | { |
3944 | turnOnSubintensity (theObj); |
3945 | if (theToUpdateViewer) |
3946 | { |
3947 | myMainVwr->Update(); |
3948 | } |
3949 | } |
3950 | |
3951 | //======================================================================= |
3952 | //function : SubIntensityOff |
3953 | //purpose : |
3954 | //======================================================================= |
3955 | void AIS_InteractiveContext::SubIntensityOff (const Handle(AIS_InteractiveObject)& theObj, |
3956 | const Standard_Boolean theToUpdateViewer) |
3957 | { |
3958 | const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theObj); |
3959 | if (aStatus == NULL |
3960 | || !(*aStatus)->IsSubIntensityOn()) |
3961 | { |
3962 | return; |
3963 | } |
3964 | |
42ddd002 |
3965 | (*aStatus)->SetSubIntensity (false); |
478862fc |
3966 | Standard_Boolean toUpdateMain = Standard_False; |
3967 | if (theObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed) |
3968 | { |
3969 | myMainPM->Unhighlight (theObj); |
3970 | toUpdateMain = Standard_True; |
3971 | } |
3972 | |
3973 | if (IsSelected (theObj)) |
3974 | { |
3975 | highlightSelected (theObj->GlobalSelOwner()); |
3976 | } |
3977 | |
3978 | if (theToUpdateViewer && toUpdateMain) |
3979 | { |
3980 | myMainVwr->Update(); |
3981 | } |
3982 | } |
3983 | |
3984 | //======================================================================= |
3985 | //function : DisplayActiveSensitive |
3986 | //purpose : |
3987 | //======================================================================= |
3988 | void AIS_InteractiveContext::DisplayActiveSensitive(const Handle(V3d_View)& theView) |
3989 | { |
45fc824b |
3990 | MainSelector()->DisplaySensitive (theView); |
478862fc |
3991 | } |
3992 | |
3993 | //======================================================================= |
3994 | //function : DisplayActiveSensitive |
3995 | //purpose : |
3996 | //======================================================================= |
3997 | void AIS_InteractiveContext::DisplayActiveSensitive (const Handle(AIS_InteractiveObject)& theObj, |
3998 | const Handle(V3d_View)& theView) |
3999 | { |
4000 | const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theObj); |
4001 | if (aStatus == NULL) |
4002 | { |
4003 | return; |
4004 | } |
4005 | |
4006 | for (TColStd_ListIteratorOfListOfInteger aModeIter ((*aStatus)->SelectionModes()); aModeIter.More(); aModeIter.Next()) |
4007 | { |
4008 | const Handle(SelectMgr_Selection)& aSel = theObj->Selection (aModeIter.Value()); |
45fc824b |
4009 | MainSelector()->DisplaySensitive (aSel, theObj->Transformation(), theView, Standard_False); |
478862fc |
4010 | } |
4011 | } |
4012 | |
4013 | //======================================================================= |
4014 | //function : ClearActiveSensitive |
4015 | //purpose : |
4016 | //======================================================================= |
4017 | void AIS_InteractiveContext::ClearActiveSensitive (const Handle(V3d_View)& theView) |
4018 | { |
45fc824b |
4019 | MainSelector()->ClearSensitive (theView); |
478862fc |
4020 | } |
4021 | |
478862fc |
4022 | //======================================================================= |
4023 | //function : IsImmediateModeOn |
4024 | //purpose : |
4025 | //======================================================================= |
4026 | Standard_Boolean AIS_InteractiveContext::IsImmediateModeOn() const |
4027 | { |
4028 | return myMainPM->IsImmediateModeOn(); |
4029 | } |
4030 | |
4031 | //======================================================================= |
4032 | //function : BeginImmediateDraw |
4033 | //purpose : |
4034 | //======================================================================= |
4035 | Standard_Boolean AIS_InteractiveContext::BeginImmediateDraw() |
4036 | { |
4037 | if (myMainPM->IsImmediateModeOn()) |
4038 | { |
4039 | myMainPM->BeginImmediateDraw(); |
4040 | return Standard_True; |
4041 | } |
4042 | return Standard_False; |
4043 | } |
4044 | |
4045 | //======================================================================= |
4046 | //function : ImmediateAdd |
4047 | //purpose : |
4048 | //======================================================================= |
4049 | Standard_Boolean AIS_InteractiveContext::ImmediateAdd (const Handle(AIS_InteractiveObject)& theObj, |
4050 | const Standard_Integer theMode) |
4051 | { |
4052 | if (myMainPM->IsImmediateModeOn()) |
4053 | { |
4054 | myMainPM->AddToImmediateList (myMainPM->Presentation (theObj, theMode)); |
4055 | return Standard_True; |
4056 | } |
4057 | return Standard_False; |
4058 | } |
4059 | |
4060 | //======================================================================= |
4061 | //function : EndImmediateDraw |
4062 | //purpose : |
4063 | //======================================================================= |
4064 | Standard_Boolean AIS_InteractiveContext::EndImmediateDraw (const Handle(V3d_View)& theView) |
4065 | { |
4066 | if (myMainPM->IsImmediateModeOn()) |
4067 | { |
4068 | myMainPM->EndImmediateDraw (theView->Viewer()); |
4069 | return Standard_True; |
4070 | } |
4071 | return Standard_False; |
4072 | } |
4073 | |
4074 | //======================================================================= |
4075 | //function : EndImmediateDraw |
4076 | //purpose : |
4077 | //======================================================================= |
4078 | Standard_Boolean AIS_InteractiveContext::EndImmediateDraw() |
4079 | { |
4080 | if (myMainPM->IsImmediateModeOn()) |
4081 | { |
4082 | myMainPM->EndImmediateDraw (myMainVwr); |
4083 | return Standard_True; |
4084 | } |
4085 | return Standard_False; |
4086 | } |
4087 | |
4088 | //======================================================================= |
4089 | //function : SetPolygonOffsets |
4090 | //purpose : |
4091 | //======================================================================= |
4092 | void AIS_InteractiveContext::SetPolygonOffsets (const Handle(AIS_InteractiveObject)& theObj, |
4093 | const Standard_Integer theMode, |
4094 | const Standard_ShortReal theFactor, |
4095 | const Standard_ShortReal theUnits, |
4096 | const Standard_Boolean theToUpdateViewer) |
4097 | { |
4098 | if (theObj.IsNull()) |
4099 | { |
4100 | return; |
4101 | } |
4102 | |
4103 | setContextToObject (theObj); |
4104 | theObj->SetPolygonOffsets (theMode, theFactor, theUnits); |
4105 | |
4106 | const Handle(AIS_GlobalStatus)* aStatus = theToUpdateViewer ? myObjects.Seek (theObj) : NULL; |
4107 | if (aStatus != NULL |
4108 | && theObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed) |
4109 | { |
4110 | myMainVwr->Update(); |
4111 | } |
4112 | } |
4113 | |
4114 | //======================================================================= |
4115 | //function : HasPolygonOffsets |
4116 | //purpose : |
4117 | //======================================================================= |
4118 | Standard_Boolean AIS_InteractiveContext::HasPolygonOffsets (const Handle(AIS_InteractiveObject)& theObj) const |
4119 | { |
4120 | return !theObj.IsNull() && theObj->HasPolygonOffsets(); |
4121 | } |
4122 | |
4123 | //======================================================================= |
4124 | //function : PolygonOffsets |
4125 | //purpose : |
4126 | //======================================================================= |
4127 | void AIS_InteractiveContext::PolygonOffsets (const Handle(AIS_InteractiveObject)& theObj, |
4128 | Standard_Integer& theMode, |
4129 | Standard_ShortReal& theFactor, |
4130 | Standard_ShortReal& theUnits) const |
4131 | { |
4132 | if (HasPolygonOffsets (theObj)) |
4133 | { |
4134 | theObj->PolygonOffsets (theMode, theFactor, theUnits); |
4135 | } |
4136 | } |
4137 | |
4138 | //======================================================================= |
4139 | //function : DumpJson |
4140 | //purpose : |
4141 | //======================================================================= |
4142 | void AIS_InteractiveContext::DumpJson (Standard_OStream& theOStream, Standard_Integer) const |
4143 | { |
4144 | OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream) |
4145 | |
4146 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myObjects.Size()) |
4147 | |
4148 | OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, mgrSelector.get()) |
4149 | OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myMainPM.get()) |
4150 | OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myMainVwr.get()) |
478862fc |
4151 | OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myLastActiveView) |
4152 | |
4153 | OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myLastPicked.get()) |
4154 | |
4155 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToHilightSelected) |
4156 | |
4157 | OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, mySelection.get()) |
4158 | OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myFilters.get()) |
4159 | OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myDefaultDrawer.get()) |
4160 | |
4161 | OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myStyles[Prs3d_TypeOfHighlight_Selected]) |
4162 | OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myStyles[Prs3d_TypeOfHighlight_Dynamic]) |
4163 | OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myStyles[Prs3d_TypeOfHighlight_LocalSelected]) |
4164 | OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myStyles[Prs3d_TypeOfHighlight_LocalDynamic]) |
4165 | OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myStyles[Prs3d_TypeOfHighlight_SubIntensity]) |
4166 | |
4167 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDetectedSeq.Size()) |
4168 | |
4169 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myCurDetected) |
4170 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myCurHighlighted) |
4171 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myPickingStrategy) |
4172 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myAutoHilight) |
4173 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsAutoActivateSelMode) |
4174 | } |