b311480e |
1 | // Created on: 1997-01-17 |
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 | |
7fd59977 |
17 | //Modified by ROB : Traque des UpdateConversion intempestifs. |
18 | |
42cf5bc1 |
19 | #include <AIS_DataMapIteratorOfDataMapOfSelStat.hxx> |
20 | #include <AIS_InteractiveContext.hxx> |
21 | #include <AIS_InteractiveObject.hxx> |
7fd59977 |
22 | #include <AIS_ListIteratorOfListOfInteractive.hxx> |
23 | #include <AIS_ListOfInteractive.hxx> |
42cf5bc1 |
24 | #include <AIS_LocalContext.hxx> |
25 | #include <AIS_LocalStatus.hxx> |
26 | #include <AIS_Selection.hxx> |
27 | #include <AIS_Shape.hxx> |
28 | #include <Aspect_TypeOfMarker.hxx> |
7fd59977 |
29 | #include <Graphic3d_Structure.hxx> |
30 | #include <Prs3d_LineAspect.hxx> |
31 | #include <Prs3d_PlaneAspect.hxx> |
32 | #include <Prs3d_PointAspect.hxx> |
33 | #include <Prs3d_Presentation.hxx> |
42cf5bc1 |
34 | #include <SelectMgr_CompositionFilter.hxx> |
35 | #include <SelectMgr_EntityOwner.hxx> |
36 | #include <SelectMgr_Filter.hxx> |
37 | #include <SelectMgr_OrFilter.hxx> |
38 | #include <SelectMgr_SelectableObject.hxx> |
39 | #include <SelectMgr_SelectionManager.hxx> |
40 | #include <Standard_Transient.hxx> |
41 | #include <Standard_Type.hxx> |
7fd59977 |
42 | #include <StdSelect_ShapeTypeFilter.hxx> |
f751596e |
43 | #include <StdSelect_ViewerSelector3d.hxx> |
42cf5bc1 |
44 | #include <TCollection_AsciiString.hxx> |
45 | #include <TColStd_ListIteratorOfListOfInteger.hxx> |
46 | #include <TopAbs_ShapeEnum.hxx> |
47 | #include <TopoDS_Shape.hxx> |
7fd59977 |
48 | #include <V3d_View.hxx> |
42cf5bc1 |
49 | #include <V3d_Viewer.hxx> |
7fd59977 |
50 | #include <Visual3d_View.hxx> |
51 | |
7fd59977 |
52 | #include <stdio.h> |
7fd59977 |
53 | static TCollection_AsciiString AIS_Local_SelName(const Standard_Address address, |
54 | const Standard_Integer anIndex) |
55 | { |
56 | // TCollection_AsciiString SelName; |
7fd59977 |
57 | char string[100]; |
58 | sprintf(string,"%p_%d", address, anIndex); // works under any system |
59 | TCollection_AsciiString SelName(string); |
7fd59977 |
60 | return SelName; |
61 | } |
62 | |
63 | |
64 | //======================================================================= |
65 | //function : AIS_LocalContext |
66 | //purpose : |
67 | //======================================================================= |
68 | |
69 | |
70 | AIS_LocalContext::AIS_LocalContext(){} |
71 | |
72 | AIS_LocalContext::AIS_LocalContext(const Handle(AIS_InteractiveContext)& aCtx, |
73 | const Standard_Integer Index, |
74 | const Standard_Boolean LoadDisplayed, |
75 | const Standard_Boolean AcceptStandardModes, |
76 | const Standard_Boolean AcceptEraseOfTemp, |
35e08fe8 |
77 | const Standard_Boolean /*BothViewers*/): |
7fd59977 |
78 | myCTX(aCtx), |
79 | myLoadDisplayed(LoadDisplayed), |
80 | myAcceptStdMode(AcceptStandardModes), |
81 | myAcceptErase(AcceptEraseOfTemp), |
82 | mySM(aCtx->SelectionManager()), |
f751596e |
83 | myMainVS(aCtx->MainSelector()), |
7fd59977 |
84 | myFilters(new SelectMgr_OrFilter()), |
85 | myAutoHilight(Standard_True), |
b586500b |
86 | myMapOfOwner (new SelectMgr_IndexedMapOfOwner()), |
7fd59977 |
87 | mylastindex(0), |
88 | mylastgood(0), |
d2094e11 |
89 | myCurDetected(0), |
90 | myAISCurDetected(0) |
91 | |
7fd59977 |
92 | { |
64e2d3bd |
93 | // bind self to AIS_InteractiveContext::myLocalContexts. Further, the |
94 | // constructor executes logic that implies that the context is already |
95 | // created and mapped. |
96 | aCtx->myLocalContexts.Bind (Index, this); |
97 | |
f751596e |
98 | myMainVS->ResetSelectionActivationStatus(); |
7fd59977 |
99 | myMainPM = aCtx->MainPrsMgr(); |
100 | mySelName = AIS_Local_SelName(this, Index); |
101 | AIS_Selection::CreateSelection(mySelName.ToCString()); |
102 | |
103 | mySM->Add(myMainVS); |
104 | if(myLoadDisplayed) LoadContextObjects(); |
f751596e |
105 | Process(); |
7fd59977 |
106 | |
107 | } |
108 | |
109 | |
110 | //======================================================================= |
111 | //function : SetContext |
112 | //purpose : |
113 | //======================================================================= |
114 | |
115 | void AIS_LocalContext::SetContext(const Handle(AIS_InteractiveContext)& aCtx) |
116 | { myCTX = aCtx;} |
117 | |
118 | //======================================================================= |
119 | //function : Display |
120 | //purpose : |
121 | //======================================================================= |
122 | |
123 | Standard_Boolean AIS_LocalContext::Display(const Handle(AIS_InteractiveObject)& anInteractive, |
124 | const Standard_Integer WhichMode, |
125 | const Standard_Boolean AllowShapeDecomposition, |
126 | const Standard_Integer ActivationMode) |
127 | { |
128 | if(myActiveObjects.IsBound(anInteractive)){ |
129 | const Handle(AIS_LocalStatus)& STAT = myActiveObjects(anInteractive); |
130 | |
131 | if(STAT->DisplayMode() == -1){ |
132 | if(!myMainPM->IsDisplayed(anInteractive,WhichMode)) |
133 | myMainPM->Display(anInteractive,WhichMode); |
134 | if(STAT->IsTemporary()) |
135 | STAT->SetDisplayMode(WhichMode); |
136 | } |
137 | else if(STAT->DisplayMode()!=WhichMode && STAT->IsTemporary()){ |
138 | myMainPM->Erase(anInteractive,STAT->DisplayMode()); |
139 | STAT->SetDisplayMode(WhichMode); |
140 | if(!myMainPM->IsDisplayed(anInteractive,WhichMode)) |
141 | myMainPM->Display(anInteractive,WhichMode); |
142 | } |
143 | |
144 | if(ActivationMode!=-1){ |
145 | if(!STAT->IsActivated(ActivationMode)){ |
146 | STAT->ClearSelectionModes(); |
147 | mySM->Load(anInteractive,myMainVS); |
148 | STAT->AddSelectionMode(ActivationMode); |
149 | mySM->Activate(anInteractive,ActivationMode,myMainVS); |
150 | } |
151 | } |
152 | } |
153 | else { |
154 | Handle(AIS_LocalStatus) Att = new AIS_LocalStatus(); |
155 | |
156 | if(anInteractive->AcceptShapeDecomposition() && AllowShapeDecomposition) |
157 | Att->SetDecomposition(Standard_True); |
158 | else |
159 | Att->SetDecomposition(Standard_False); |
81bba717 |
160 | // status temporary or not |
7fd59977 |
161 | if(myCTX->DisplayStatus(anInteractive) == AIS_DS_None || |
162 | myCTX->DisplayStatus(anInteractive) == AIS_DS_Temporary) |
163 | Att->SetTemporary(Standard_True); |
164 | else |
165 | Att->SetTemporary(Standard_False); |
166 | |
167 | |
168 | |
169 | if(!myCTX->IsDisplayed(anInteractive,WhichMode)){ |
170 | |
171 | //storing information.... |
172 | Att->SetDisplayMode(WhichMode); |
173 | if (ActivationMode!=-1) |
174 | Att->AddSelectionMode(ActivationMode); |
175 | Standard_Integer HiMod = anInteractive->HasHilightMode()? anInteractive->HilightMode(): WhichMode; |
176 | Att->SetHilightMode(HiMod); |
177 | |
178 | if(!myMainPM->IsDisplayed(anInteractive,WhichMode)) |
179 | myMainPM->Display(anInteractive,WhichMode); |
180 | |
181 | if(ActivationMode!=-1){ |
182 | mySM->Load(anInteractive,myMainVS); |
183 | mySM->Activate(anInteractive,ActivationMode,myMainVS); |
184 | } |
185 | } |
186 | else{ |
187 | Standard_Integer HiMod = anInteractive->HasHilightMode()? anInteractive->HilightMode(): WhichMode; |
188 | Att->SetHilightMode(HiMod); |
189 | } |
190 | myActiveObjects.Bind(anInteractive,Att); |
191 | } |
192 | Process(anInteractive); |
193 | |
194 | |
195 | |
196 | |
197 | return Standard_True; |
198 | } |
199 | |
200 | //======================================================================= |
201 | //function : Load |
202 | //purpose : |
203 | //======================================================================= |
204 | |
205 | Standard_Boolean AIS_LocalContext:: |
206 | Load(const Handle(AIS_InteractiveObject)& anInteractive, |
207 | const Standard_Boolean AllowShapeDecomposition, |
208 | const Standard_Integer ActivationMode) |
209 | { |
f751596e |
210 | if (myActiveObjects.IsBound (anInteractive)) |
211 | { |
212 | if (anInteractive->HasSelection (ActivationMode)) |
213 | { |
214 | const Handle(SelectMgr_Selection)& aSel = anInteractive->Selection (ActivationMode); |
215 | if (aSel->GetSelectionState() != SelectMgr_SOS_Activated) |
216 | { |
217 | if (!myMainVS->Contains (anInteractive)) |
218 | { |
219 | mySM->Load (anInteractive, myMainVS); |
220 | } |
221 | mySM->Activate (anInteractive, ActivationMode, myMainVS); |
222 | return Standard_True; |
223 | } |
224 | } |
225 | return Standard_False; |
226 | } |
227 | |
7fd59977 |
228 | Handle(AIS_LocalStatus) Att = new AIS_LocalStatus(); |
229 | |
230 | if(anInteractive->AcceptShapeDecomposition() && AllowShapeDecomposition) |
231 | Att->SetDecomposition(Standard_True); |
232 | else |
233 | Att->SetDecomposition(Standard_False); |
234 | |
235 | if(!myCTX->IsDisplayed(anInteractive)) |
236 | Att->SetTemporary(Standard_True); |
237 | else |
238 | Att->SetTemporary(Standard_False); |
239 | Att->SetDisplayMode(-1); |
240 | |
241 | //storing information.... |
242 | if(ActivationMode!=-1) |
243 | Att->AddSelectionMode(ActivationMode); |
244 | Standard_Integer HiMod = anInteractive->HasHilightMode()? anInteractive->HilightMode():0; |
245 | Att->SetHilightMode(HiMod); |
246 | //Action |
247 | |
248 | mySM->Load(anInteractive,myMainVS); |
249 | if(ActivationMode != -1){ |
250 | mySM->Activate(anInteractive,ActivationMode,myMainVS); |
251 | } |
252 | myActiveObjects.Bind(anInteractive,Att); |
253 | Process(anInteractive); |
254 | return Standard_True; |
255 | } |
256 | |
257 | //======================================================================= |
258 | //function : ClearPrs |
259 | //purpose : |
260 | //======================================================================= |
261 | |
262 | Standard_Boolean AIS_LocalContext:: |
263 | ClearPrs(const Handle(AIS_InteractiveObject)& anInteractive, |
264 | const Standard_Integer aMode) |
265 | { |
266 | if(!myActiveObjects.IsBound(anInteractive)) |
267 | return Standard_False; |
268 | |
269 | Standard_Boolean jobdone(Standard_False); |
270 | const Handle(AIS_LocalStatus)& STAT = myActiveObjects(anInteractive); |
271 | |
272 | //Display step |
273 | if(STAT->IsSubIntensityOn()) { |
274 | STAT->SubIntensityOff(); |
275 | if(STAT->HilightMode()==aMode) |
276 | myMainPM->Unhighlight(anInteractive,STAT->HilightMode()); |
277 | } |
278 | myMainPM->Clear(anInteractive,aMode); // correction connexions 23/09/97 |
279 | jobdone = Standard_True; |
280 | if(STAT->DisplayMode()==aMode) |
281 | STAT->SetDisplayMode(-1); |
282 | return jobdone; |
283 | } |
284 | //======================================================================= |
285 | //function : Erase |
286 | //purpose : |
287 | //======================================================================= |
288 | |
289 | Standard_Boolean AIS_LocalContext:: |
290 | Erase(const Handle(AIS_InteractiveObject)& anInteractive) |
291 | { |
292 | if(!myActiveObjects.IsBound(anInteractive)) |
293 | return Standard_False; |
294 | const Handle(AIS_LocalStatus)& STAT = myActiveObjects(anInteractive); |
295 | |
296 | //Display step |
297 | if(STAT->IsSubIntensityOn()) { |
298 | STAT->SubIntensityOff(); |
299 | myMainPM->Unhighlight(anInteractive,STAT->HilightMode()); |
300 | } |
301 | |
302 | Standard_Boolean status(Standard_False); |
303 | |
304 | if(STAT->DisplayMode()!=-1) { |
305 | if(IsSelected(anInteractive)) |
306 | AddOrRemoveSelected(anInteractive); |
307 | if(myMainPM->IsHighlighted(anInteractive,STAT->HilightMode())) |
308 | myMainPM->Unhighlight(anInteractive,STAT->HilightMode()); |
eb4320f2 |
309 | myMainPM->SetVisibility (anInteractive, STAT->DisplayMode(), Standard_False); |
7fd59977 |
310 | STAT->SetDisplayMode(-1); |
311 | status = Standard_True; |
312 | } |
313 | if(STAT->IsTemporary()){ |
314 | if(myMainPM->IsDisplayed(anInteractive,STAT->HilightMode())) |
eb4320f2 |
315 | myMainPM->SetVisibility (anInteractive, STAT->HilightMode(), Standard_False); |
7fd59977 |
316 | } |
fb4b684a |
317 | |
318 | // Deactivate selectable entities of interactive object |
543a9964 |
319 | const Handle(SelectMgr_SelectableObject)& anObj = anInteractive; // to avoid ambiguity |
320 | if (mySM->Contains (anObj)) |
fb4b684a |
321 | { |
322 | TColStd_ListIteratorOfListOfInteger aModeIter (STAT->SelectionModes()); |
323 | for (; aModeIter.More(); aModeIter.Next()) |
324 | { |
325 | mySM->Deactivate (anInteractive, aModeIter.Value(), myMainVS); |
326 | } |
327 | } |
328 | |
bc677575 |
329 | ClearOutdatedSelection (anInteractive, Standard_True); |
fb4b684a |
330 | |
7fd59977 |
331 | return status; |
332 | } |
333 | |
334 | |
335 | //======================================================================= |
336 | //function : SetShapeDecomposition |
337 | //purpose : |
338 | //======================================================================= |
339 | |
340 | void AIS_LocalContext::SetShapeDecomposition(const Handle(AIS_InteractiveObject)& aStoredObject, |
341 | const Standard_Boolean aStatus) |
342 | { |
343 | if(!myActiveObjects.IsBound(aStoredObject)) return; |
344 | |
345 | if(aStatus == myActiveObjects(aStoredObject)->Decomposed()) |
346 | return; |
347 | |
348 | myActiveObjects(aStoredObject)->SetDecomposition(aStatus); |
349 | |
350 | Process(aStoredObject); |
351 | } |
352 | |
353 | //======================================================================= |
354 | //function : Clear |
355 | //purpose : |
356 | //======================================================================= |
357 | |
358 | void AIS_LocalContext::Clear(const AIS_ClearMode aType) |
359 | { |
360 | switch (aType){ |
361 | case AIS_CM_All: |
362 | { |
363 | ClearObjects(); |
364 | myFilters->Clear(); |
365 | while(!myListOfStandardMode.IsEmpty()) |
366 | DeactivateStandardMode(AIS_Shape::SelectionType(myListOfStandardMode.Last())); |
367 | break; |
368 | } |
369 | case AIS_CM_Interactive: |
370 | ClearObjects(); |
371 | break; |
372 | case AIS_CM_Filters: |
373 | myFilters->Clear(); |
374 | break; |
375 | case AIS_CM_StandardModes: |
376 | { |
377 | while(!myListOfStandardMode.IsEmpty()) |
378 | DeactivateStandardMode(AIS_Shape::SelectionType(myListOfStandardMode.Last())); |
379 | break; |
380 | } |
381 | case AIS_CM_TemporaryShapePrs: |
382 | ClearDetected(); |
383 | } |
7fd59977 |
384 | } |
385 | //======================================================================= |
386 | //function : ActivateMode |
387 | //purpose : |
388 | //======================================================================= |
389 | |
390 | void AIS_LocalContext::ActivateMode(const Handle(AIS_InteractiveObject)& aSelectable, |
391 | const Standard_Integer aMode) |
392 | { |
393 | if(!myActiveObjects.IsBound(aSelectable)) return; |
394 | // if(myActiveObjects(aSelectable)->SelectionMode()!=aMode) |
395 | // mySM->Deactivate(aSelectable,aMode,myMainVS); |
396 | if(aMode != -1){ |
397 | myActiveObjects(aSelectable)->AddSelectionMode(aMode); |
398 | mySM->Activate(aSelectable,aMode,myMainVS); |
399 | } |
7fd59977 |
400 | } |
401 | //======================================================================= |
402 | //function : ActivateMode |
403 | //purpose : |
404 | //======================================================================= |
405 | |
406 | void AIS_LocalContext::DeactivateMode(const Handle(AIS_InteractiveObject)& aSelectable, |
407 | const Standard_Integer aMode) |
408 | { |
409 | if(!myActiveObjects.IsBound(aSelectable)) return; |
410 | |
411 | if(aMode==-1) return; |
412 | |
413 | myActiveObjects(aSelectable)->RemoveSelectionMode(aMode); |
414 | mySM->Deactivate(aSelectable,aMode,myMainVS); |
7fd59977 |
415 | } |
416 | //======================================================================= |
417 | //function : ActivateMode |
418 | //purpose : |
419 | //======================================================================= |
420 | |
421 | void AIS_LocalContext::Deactivate(const Handle(AIS_InteractiveObject)& aSelectable) |
422 | { |
423 | if(!myActiveObjects.IsBound(aSelectable)) return; |
424 | |
f751596e |
425 | mySM->Deactivate(aSelectable, -1, myMainVS); |
7fd59977 |
426 | myActiveObjects(aSelectable)->ClearSelectionModes(); |
7fd59977 |
427 | } |
428 | |
429 | //======================================================================= |
430 | //function : Remove |
431 | //purpose : |
432 | //======================================================================= |
433 | |
434 | Standard_Boolean AIS_LocalContext::Remove(const Handle(AIS_InteractiveObject)& aSelectable) |
435 | { |
7fd6425d |
436 | if(!myActiveObjects.IsBound (aSelectable)) |
437 | { |
438 | return Standard_False; |
439 | } |
440 | |
441 | if (IsSelected (aSelectable)) |
442 | { |
443 | AddOrRemoveSelected (aSelectable, Standard_False); |
444 | } |
445 | |
446 | const Handle(AIS_LocalStatus)& Att = myActiveObjects (aSelectable); |
7fd59977 |
447 | |
7fd59977 |
448 | TColStd_ListIteratorOfListOfInteger It; |
7fd59977 |
449 | |
7fd6425d |
450 | // Deactivate standard modes |
451 | if (Att->Decomposed()) |
452 | { |
453 | for (It.Initialize (myListOfStandardMode); It.More(); It.Next()) |
454 | { |
455 | mySM->Deactivate (aSelectable, It.Value(), myMainVS); |
7fd59977 |
456 | } |
457 | } |
7fd6425d |
458 | |
459 | // If object or temporary presentations |
460 | if (Att->IsTemporary()) |
461 | { |
462 | if (Att->IsSubIntensityOn()) |
7fd59977 |
463 | { |
7fd6425d |
464 | myMainPM->Unhighlight (aSelectable, Att->HilightMode()); |
7fd59977 |
465 | } |
7fd6425d |
466 | |
467 | myMainPM->Erase (aSelectable, Att->DisplayMode()); |
468 | myMainPM->Clear (aSelectable, Att->DisplayMode()); |
469 | if (myMainPM->IsDisplayed (aSelectable, Att->HilightMode())) |
7fd59977 |
470 | { |
7fd6425d |
471 | myMainPM->Erase (aSelectable, Att->HilightMode()); |
7fd59977 |
472 | } |
7fd59977 |
473 | } |
7fd6425d |
474 | // If subintensity used |
475 | else if (Att->IsSubIntensityOn()) |
476 | { |
477 | myCTX->SubIntensityOff (aSelectable); |
478 | } |
7fd59977 |
479 | |
7fd6425d |
480 | // Deactivate stored selection modes |
481 | for (It.Initialize (Att->SelectionModes()); It.More(); It.Next()) |
482 | { |
483 | mySM->Deactivate (aSelectable, It.Value(), myMainVS); |
484 | } |
7fd59977 |
485 | |
fb4b684a |
486 | // Remove the interactive object from selection manager |
543a9964 |
487 | const Handle(SelectMgr_SelectableObject)& anObj = aSelectable; // to avoid ambiguity |
488 | if (mySM->Contains (anObj)) |
7fd59977 |
489 | { |
543a9964 |
490 | mySM->Remove (anObj); |
7fd59977 |
491 | } |
bc677575 |
492 | ClearOutdatedSelection (aSelectable, Standard_True); |
7fd59977 |
493 | |
7fd6425d |
494 | // This should be done at the very end because most methods use |
495 | // myActiveObjects even during clean-up |
496 | myActiveObjects.UnBind (aSelectable); |
7fd59977 |
497 | return Standard_True; |
498 | } |
499 | |
500 | //======================================================================= |
501 | //function : ActivateStandardMode |
502 | //purpose : |
503 | //======================================================================= |
504 | |
505 | void AIS_LocalContext::ActivateStandardMode(const TopAbs_ShapeEnum aType) |
506 | { |
507 | |
81bba717 |
508 | //check if it is not in the list |
7fd59977 |
509 | TColStd_ListIteratorOfListOfInteger It(myListOfStandardMode); |
510 | for(;It.More();It.Next()) |
511 | if(It.Value()==aType) return; |
512 | Standard_Integer IMode = AIS_Shape::SelectionMode(aType); |
513 | |
514 | |
81bba717 |
515 | // create a hidden filter answering ok to the type except for : |
516 | // if the type is shape... |
517 | // if the filters already impact at the type <aType> |
7fd59977 |
518 | if(aType != TopAbs_SHAPE){ |
519 | if(myStdFilters[IMode].IsNull()) |
520 | myStdFilters[IMode] = new StdSelect_ShapeTypeFilter(aType); |
521 | if(!HasFilters(aType)) |
522 | myFilters->Add(myStdFilters[IMode]); |
523 | } |
524 | |
81bba717 |
525 | // the mode is activated for all objects of type Shape |
526 | // accepting the decomposition in standard mode. |
7fd59977 |
527 | myListOfStandardMode.Append(IMode); |
528 | |
529 | AIS_DataMapIteratorOfDataMapOfSelStat ItM(myActiveObjects); |
530 | |
531 | for(;ItM.More();ItM.Next()){ |
7fd59977 |
532 | if(ItM.Value()->Decomposed()) |
7fd59977 |
533 | myCTX->SelectionManager()->Activate(ItM.Key(), |
534 | IMode, |
535 | myMainVS); |
536 | } |
537 | |
538 | } |
539 | |
540 | //======================================================================= |
541 | //function : DeActivateStandardMode |
542 | //purpose : |
543 | //======================================================================= |
544 | |
545 | void AIS_LocalContext::DeactivateStandardMode(const TopAbs_ShapeEnum aType) |
546 | { |
547 | TColStd_ListIteratorOfListOfInteger It(myListOfStandardMode); |
548 | Standard_Integer IMode = AIS_Shape::SelectionMode(aType); |
549 | for(;It.More();It.Next()) |
550 | if(It.Value()==IMode) { |
551 | AIS_DataMapIteratorOfDataMapOfSelStat ItM(myActiveObjects); |
552 | |
553 | for(;ItM.More();ItM.Next()){ |
554 | if(ItM.Value()->Decomposed()){ |
555 | myCTX->SelectionManager()->Deactivate(ItM.Key(), |
556 | IMode, |
557 | myMainVS); |
558 | ItM.Value()->RemoveSelectionMode(IMode); |
559 | } |
560 | } |
561 | myListOfStandardMode.Remove(It); |
562 | if(myFilters->IsIn(myStdFilters[IMode])) |
563 | myFilters->Remove(myStdFilters[IMode]); |
7fd59977 |
564 | return; |
565 | } |
7fd59977 |
566 | } |
567 | |
568 | //======================================================================= |
569 | //function : AddFilter |
570 | //purpose : |
571 | //======================================================================= |
572 | |
573 | void AIS_LocalContext::AddFilter(const Handle(SelectMgr_Filter)& aFilter) |
574 | { |
81bba717 |
575 | // it is checked if the filter impacts at the type of active sub-shape |
576 | // for which a filter of type has been already implemented... |
7fd59977 |
577 | |
578 | TColStd_ListIteratorOfListOfInteger It(myListOfStandardMode); |
579 | |
580 | for(;It.More();It.Next()){ |
581 | if(aFilter->ActsOn(AIS_Shape::SelectionType(It.Value()))) |
582 | if(myFilters->IsIn(myStdFilters[It.Value()])) |
583 | myFilters->Remove(myStdFilters[It.Value()]); |
584 | } |
585 | myFilters->Add(aFilter); |
586 | } |
587 | |
588 | //======================================================================= |
589 | //function : RemoveFilter |
590 | //purpose : |
591 | //======================================================================= |
592 | |
593 | void AIS_LocalContext::RemoveFilter(const Handle(SelectMgr_Filter)& aFilter) |
594 | { |
595 | if(myFilters->IsIn(aFilter)) myFilters->Remove(aFilter); |
596 | |
81bba717 |
597 | // it is checked if the filter for type standard is active. |
598 | // if yes, it is checked there are still similarities among the |
599 | // remaining filters... |
600 | // otherwise, the standard filter is restored to |
601 | // continu selecting active modes... |
7fd59977 |
602 | TColStd_ListIteratorOfListOfInteger It(myListOfStandardMode); |
603 | TopAbs_ShapeEnum SE; |
604 | for(;It.More();It.Next()){ |
605 | SE = AIS_Shape::SelectionType(It.Value()); |
606 | if(aFilter->ActsOn(SE)) |
607 | if(!HasFilters(SE)) |
608 | myFilters->Add(myStdFilters[It.Value()]); |
609 | } |
610 | } |
611 | |
7fd59977 |
612 | //======================================================================= |
613 | //function : Terminate |
679ecdee |
614 | //purpose : |
7fd59977 |
615 | //======================================================================= |
616 | |
679ecdee |
617 | void AIS_LocalContext::Terminate (const Standard_Boolean theToUpdate) |
7fd59977 |
618 | { |
619 | ClearDetected(); |
620 | Clear(); |
b586500b |
621 | myMapOfOwner->Clear(); |
7fd59977 |
622 | |
623 | mylastindex=0; |
81bba717 |
624 | // clear the selector... |
7fd59977 |
625 | myMainVS->Clear(); |
7fd59977 |
626 | |
627 | |
628 | AIS_Selection::SetCurrentSelection(mySelName.ToCString()); |
629 | Handle(AIS_Selection) S = AIS_Selection::CurrentSelection(); |
630 | Handle(Standard_Transient) Tr; |
631 | for(S->Init();S->More();S->Next()){ |
632 | Tr = S->Value(); |
c5f3a425 |
633 | Handle(SelectMgr_EntityOwner)::DownCast (Tr)->SetSelected (Standard_False); |
7fd59977 |
634 | } |
635 | |
636 | |
637 | AIS_Selection::Select(); |
638 | AIS_Selection::Remove(mySelName.ToCString()); |
639 | |
679ecdee |
640 | Handle(V3d_Viewer) aViewer = myCTX->CurrentViewer(); |
641 | for (aViewer->InitActiveViews(); aViewer->MoreActiveViews(); aViewer->NextActiveViews()) |
642 | { |
643 | Handle(V3d_View) aView = aViewer->ActiveView(); |
644 | aView->View()->ClearImmediate(); |
7fd59977 |
645 | } |
646 | |
679ecdee |
647 | Handle(V3d_View) aDummyView; |
679ecdee |
648 | myMainVS->ClearSensitive (aDummyView); |
7fd59977 |
649 | |
679ecdee |
650 | if (theToUpdate) |
651 | { |
652 | myCTX->UpdateCurrentViewer(); |
653 | } |
7fd59977 |
654 | } |
655 | |
656 | |
657 | //======================================================================= |
658 | //function : SubIntensity |
659 | //purpose : |
660 | //======================================================================= |
661 | |
662 | void AIS_LocalContext::SubIntensityOn(const Handle(AIS_InteractiveObject)& anObject) |
663 | { |
664 | if(!myActiveObjects.IsBound(anObject)) return; |
665 | |
666 | const Handle(AIS_LocalStatus)& Att = myActiveObjects(anObject); |
667 | |
668 | if(Att->IsTemporary()) |
669 | myMainPM->Color(anObject,myCTX->SubIntensityColor(),Att->DisplayMode()); |
670 | |
671 | Att->SubIntensityOn(); |
672 | } |
673 | //======================================================================= |
674 | //function : SubIntensity |
675 | //purpose : |
676 | //======================================================================= |
677 | |
678 | void AIS_LocalContext::SubIntensityOff(const Handle(AIS_InteractiveObject)& anObject) |
679 | { |
680 | if(!myActiveObjects.IsBound(anObject)) return; |
681 | |
682 | const Handle(AIS_LocalStatus)& Att = myActiveObjects(anObject); |
683 | |
684 | if(Att->IsTemporary()) |
685 | myMainPM->Unhighlight(anObject); |
686 | Att->SubIntensityOff(); |
687 | } |
688 | |
689 | |
690 | //======================================================================= |
691 | //function : Hilight |
692 | //purpose : |
693 | //======================================================================= |
694 | |
695 | void AIS_LocalContext::Hilight(const Handle(AIS_InteractiveObject)& anObject) |
696 | { |
697 | if(!myActiveObjects.IsBound(anObject)){ |
698 | Standard_Integer HiMod = anObject->HasHilightMode()? anObject->HilightMode() : 0; |
699 | Handle(AIS_LocalStatus) Att = new AIS_LocalStatus(Standard_True, |
700 | Standard_False, |
701 | -1,-1,HiMod); |
702 | myActiveObjects.Bind(anObject,Att); |
703 | |
704 | } |
705 | const Handle(AIS_LocalStatus)& Att = myActiveObjects(anObject); |
706 | myMainPM->Color(anObject,myCTX->HilightColor(),Att->HilightMode()); |
707 | Att->SubIntensityOn(); |
708 | } |
709 | //======================================================================= |
710 | //function : Hilight |
711 | //purpose : |
712 | //======================================================================= |
713 | |
714 | void AIS_LocalContext::Hilight(const Handle(AIS_InteractiveObject)& anObject, |
715 | const Quantity_NameOfColor Col) |
716 | { |
717 | if(!myActiveObjects.IsBound(anObject)){ |
718 | Standard_Integer HiMod = anObject->HasHilightMode()? anObject->HilightMode() : 0; |
719 | Handle(AIS_LocalStatus) Att = new AIS_LocalStatus(Standard_True, |
720 | Standard_False, |
721 | -1,-1,HiMod); |
722 | myActiveObjects.Bind(anObject,Att); |
723 | |
724 | } |
725 | const Handle(AIS_LocalStatus)& Att = myActiveObjects(anObject); |
726 | myMainPM->Color(anObject,Col,Att->HilightMode()); |
727 | Att->SubIntensityOn(); |
728 | Att->SetHilightColor(Col); |
729 | } |
730 | |
731 | //======================================================================= |
732 | //function : Unhilight |
733 | //purpose : |
734 | //======================================================================= |
735 | |
736 | void AIS_LocalContext::Unhilight(const Handle(AIS_InteractiveObject)& anObject) |
737 | { |
738 | if(!myActiveObjects.IsBound(anObject)) return; |
739 | |
81bba717 |
740 | // chieck if by hazard the object is somewhere else... |
7fd59977 |
741 | Standard_Integer Indx; |
742 | Standard_Boolean IsSomeWhereElse = |
743 | myCTX->IsInLocal(anObject,Indx) && Indx != myCTX->IndexOfCurrentLocal(); |
744 | |
745 | const Handle(AIS_LocalStatus)& Att = myActiveObjects(anObject); |
746 | myMainPM->Unhighlight(anObject,Att->HilightMode()); |
747 | if(Att->IsTemporary() && Att->DisplayMode()==-1) |
748 | if(!IsSomeWhereElse) |
eb4320f2 |
749 | myMainPM->SetVisibility (anObject, Att->HilightMode(), Standard_False); |
750 | |
7fd59977 |
751 | Att->SubIntensityOff(); |
752 | Att->SetHilightColor(Quantity_NOC_WHITE); |
753 | } |
754 | |
755 | |
756 | //======================================================================= |
757 | //function : IsIn |
758 | //purpose : |
759 | //======================================================================= |
760 | |
761 | Standard_Boolean AIS_LocalContext:: |
762 | IsIn(const Handle(AIS_InteractiveObject)& anObject) const |
763 | { |
764 | return myActiveObjects.IsBound(anObject); |
765 | } |
766 | |
767 | //======================================================================= |
768 | //function : IsHilighted |
769 | //purpose : |
770 | //======================================================================= |
771 | |
772 | Standard_Boolean AIS_LocalContext::IsHilighted(const Handle(AIS_InteractiveObject)& anObject) const |
773 | { |
774 | if(!myActiveObjects.IsBound(anObject)) return Standard_False; |
775 | return myActiveObjects(anObject)->IsSubIntensityOn(); |
776 | } |
777 | |
778 | Standard_Boolean AIS_LocalContext::IsHilighted(const Handle(AIS_InteractiveObject)& anObject, |
779 | Standard_Boolean& WithColor, |
780 | Quantity_NameOfColor& HiCol) const |
781 | { |
782 | if(!myActiveObjects.IsBound(anObject)) return Standard_False; |
783 | if( myActiveObjects(anObject)->IsSubIntensityOn()){ |
784 | HiCol = myActiveObjects(anObject)->HilightColor(); |
785 | if(HiCol==Quantity_NOC_WHITE) |
786 | WithColor = Standard_True; |
787 | else |
788 | WithColor = Standard_False; |
789 | return Standard_True; |
790 | } |
791 | return Standard_False; |
792 | } |
793 | |
794 | |
795 | void AIS_LocalContext::SetDisplayPriority(const Handle(AIS_InteractiveObject)& anObject, |
796 | const Standard_Integer Prior) |
797 | { |
798 | if(!myActiveObjects.IsBound(anObject)) return; |
799 | const Handle(AIS_LocalStatus)& STAT = myActiveObjects(anObject); |
800 | if(STAT->DisplayMode()==-1) return; |
801 | myMainPM->SetDisplayPriority(anObject,STAT->DisplayMode(),Prior); |
802 | if(STAT->IsSubIntensityOn()) |
803 | myMainPM->SetDisplayPriority(anObject,STAT->HilightMode(),Prior); |
804 | |
805 | |
806 | } |
807 | |
7fd59977 |
808 | //======================================================================= |
809 | //function : DisplayedObjects |
810 | //purpose : |
811 | //======================================================================= |
812 | Standard_Integer AIS_LocalContext::DisplayedObjects(TColStd_MapOfTransient& theMap) const |
813 | { |
814 | Standard_Integer NbDisp(0); |
815 | for(AIS_DataMapIteratorOfDataMapOfSelStat it(myActiveObjects);it.More();it.Next()){ |
816 | const Handle(SelectMgr_SelectableObject)& SO = it.Key(); |
817 | if(!theMap.Contains(SO)) |
818 | if(it.Value()->DisplayMode()!=-1){ |
819 | theMap.Add(SO); |
820 | NbDisp++; |
821 | } |
822 | } |
823 | return NbDisp; |
824 | } |
825 | |
826 | |
827 | //======================================================================= |
828 | //function : IsDisplayed |
829 | //purpose : |
830 | //======================================================================= |
831 | |
832 | Standard_Boolean AIS_LocalContext::IsDisplayed(const Handle(AIS_InteractiveObject)& anObject) const |
833 | { |
834 | if(!myActiveObjects.IsBound(anObject)) return Standard_False; |
835 | return (myActiveObjects(anObject)->DisplayMode()!=-1); |
836 | } |
837 | |
838 | //======================================================================= |
839 | //function : IsDisplayed |
840 | //purpose : |
841 | //======================================================================= |
842 | |
843 | Standard_Boolean AIS_LocalContext::IsDisplayed(const Handle(AIS_InteractiveObject)& anObject, |
844 | const Standard_Integer aMode) const |
845 | { |
846 | if(!myActiveObjects.IsBound(anObject)) return Standard_False; |
847 | return (myActiveObjects(anObject)->DisplayMode()==aMode); |
848 | } |
849 | |
850 | //======================================================================= |
851 | //function : SelectionModes |
852 | //purpose : |
853 | //======================================================================= |
854 | |
855 | const TColStd_ListOfInteger& AIS_LocalContext:: |
856 | SelectionModes(const Handle(AIS_InteractiveObject)& anObject) const |
857 | { |
858 | return myActiveObjects(anObject)->SelectionModes(); |
859 | } |
860 | |
861 | //======================================================================= |
862 | //function : Status |
863 | //purpose : |
864 | //======================================================================= |
865 | |
866 | TCollection_AsciiString AIS_LocalContext::Status() const |
867 | { |
868 | TCollection_AsciiString t; |
869 | return t; |
870 | } |
871 | |
872 | const Handle(AIS_LocalStatus)& AIS_LocalContext::Status(const Handle(AIS_InteractiveObject)& anObject) const |
873 | { |
874 | return myActiveObjects(anObject); |
875 | } |
876 | |
877 | //======================================================================= |
878 | //function : LoadContextObjects |
879 | //purpose : |
880 | //======================================================================= |
881 | |
882 | void AIS_LocalContext::LoadContextObjects() |
883 | { |
884 | AIS_ListIteratorOfListOfInteractive It; |
885 | if(myLoadDisplayed) { |
886 | AIS_ListOfInteractive LL; |
887 | myCTX->DisplayedObjects(LL,Standard_True); |
888 | Handle(AIS_LocalStatus) Att; |
889 | for (It.Initialize(LL);It.More();It.Next()){ |
f751596e |
890 | const Handle(AIS_InteractiveObject)& anObj = It.Value(); |
7fd59977 |
891 | Att= new AIS_LocalStatus(); |
f751596e |
892 | Att->SetDecomposition((anObj->AcceptShapeDecomposition() && myAcceptStdMode)); |
7fd59977 |
893 | Att->SetTemporary(Standard_False); |
f751596e |
894 | Att->SetHilightMode(anObj->HasHilightMode()? anObj->HilightMode(): 0); |
895 | for (anObj->Init(); anObj->More(); anObj->Next()) |
896 | { |
897 | const Handle(SelectMgr_Selection)& aSel = anObj->CurrentSelection(); |
898 | aSel->SetSelectionState (SelectMgr_SOS_Deactivated); |
899 | } |
900 | myActiveObjects.Bind(anObj,Att); |
7fd59977 |
901 | } |
902 | } |
903 | } |
904 | |
905 | void AIS_LocalContext::UnloadContextObjects() |
906 | { |
907 | AIS_ListIteratorOfListOfInteractive It; |
908 | if(myLoadDisplayed) |
909 | { |
910 | AIS_ListOfInteractive LL; |
911 | myCTX->DisplayedObjects(LL,Standard_True); |
912 | |
913 | for (It.Initialize(LL);It.More();It.Next()) |
914 | { |
915 | myActiveObjects.UnBind(It.Value()); |
916 | } |
917 | } |
918 | } |
919 | //======================================================================= |
920 | //function : Process |
921 | //purpose : |
922 | //======================================================================= |
923 | |
f751596e |
924 | void AIS_LocalContext::Process(const Handle(SelectMgr_SelectableObject)& anObject) |
7fd59977 |
925 | { |
926 | if(!myActiveObjects.IsBound(anObject)) return; |
927 | if(myActiveObjects(anObject)->Decomposed()) |
f751596e |
928 | ActivateStandardModes(anObject); |
7fd59977 |
929 | else |
930 | { |
931 | TColStd_ListIteratorOfListOfInteger It(myActiveObjects(anObject)->SelectionModes()); |
932 | for(;It.More();It.Next()) |
f751596e |
933 | myCTX->SelectionManager()->Activate(anObject,It.Value(),myMainVS); |
7fd59977 |
934 | } |
935 | } |
936 | |
937 | //======================================================================= |
938 | //function : Process |
939 | //purpose : |
940 | //======================================================================= |
941 | |
f751596e |
942 | void AIS_LocalContext::Process() |
7fd59977 |
943 | { |
944 | |
945 | myMainVS->Clear(); |
946 | |
947 | AIS_DataMapIteratorOfDataMapOfSelStat It(myActiveObjects); |
948 | |
949 | for(;It.More();It.Next()){ |
950 | myCTX->SelectionManager()->Load(It.Key(),myMainVS); |
951 | if(It.Value()->Decomposed()) |
f751596e |
952 | ActivateStandardModes(It.Key()); |
7fd59977 |
953 | else if( myCTX->GetAutoActivateSelection() ) |
954 | { |
955 | It.Value()->AddSelectionMode(0); |
f751596e |
956 | myCTX->SelectionManager()->Activate(It.Key(),0,myMainVS); |
7fd59977 |
957 | } |
958 | } |
959 | |
960 | } |
961 | |
962 | //======================================================================= |
963 | //function : ActivateModes |
964 | //purpose : |
965 | //======================================================================= |
966 | |
f751596e |
967 | void AIS_LocalContext::ActivateStandardModes(const Handle(SelectMgr_SelectableObject)& anObject) |
7fd59977 |
968 | { |
969 | if(!myActiveObjects.IsBound(anObject)) return; |
970 | |
971 | TColStd_ListIteratorOfListOfInteger itl (myListOfStandardMode); |
972 | |
973 | const Handle(AIS_LocalStatus)& LS = myActiveObjects(anObject); |
974 | if(LS->Decomposed()){ |
975 | for(;itl.More();itl.Next()){ |
f751596e |
976 | myCTX->SelectionManager()->Activate(anObject,itl.Value(),myMainVS); |
7fd59977 |
977 | LS->AddSelectionMode(itl.Value()); |
978 | } |
979 | } |
980 | } |
981 | |
982 | |
983 | //======================================================================= |
984 | //function : ClearObjects |
985 | //purpose : |
986 | //======================================================================= |
987 | |
988 | void AIS_LocalContext::ClearObjects() |
989 | { |
990 | AIS_DataMapIteratorOfDataMapOfSelStat It(myActiveObjects); |
991 | for(;It.More();It.Next()) |
992 | { |
993 | Handle(AIS_InteractiveObject) SO = |
994 | Handle(AIS_InteractiveObject)::DownCast(It.Key()); |
995 | |
996 | const Handle(AIS_LocalStatus)& CurAtt = It.Value(); |
997 | //TColStd_ListIteratorOfListOfInteger ItL; |
81bba717 |
998 | // if object is temporary the presentations managed by myMainPM are removed |
7fd59977 |
999 | AIS_DisplayStatus TheDS = myCTX->DisplayStatus(SO); |
1000 | |
1001 | if(TheDS != AIS_DS_Displayed){ |
1002 | if(myMainPM->IsDisplayed(SO,CurAtt->DisplayMode())){ |
1003 | if(CurAtt->IsSubIntensityOn()&& |
1004 | myMainPM->IsHighlighted(SO,CurAtt->HilightMode())) |
1005 | myMainPM->Unhighlight(SO,CurAtt->HilightMode()); |
1006 | myMainPM->Erase(SO,CurAtt->DisplayMode()); |
1007 | } |
1008 | |
1009 | if(CurAtt->IsTemporary()){ |
1010 | myMainPM->Erase(SO,CurAtt->DisplayMode());} |
1011 | // myMainPM->Clear(SO,CurAtt->DisplayMode());} |
1012 | } |
1013 | else { |
1014 | if (CurAtt->IsSubIntensityOn()){ |
1015 | myCTX->SubIntensityOff(Handle(AIS_InteractiveObject)::DownCast(SO));} |
1016 | Standard_Integer DiMo = SO->HasDisplayMode()? |
1017 | SO->DisplayMode():myCTX->DisplayMode(); |
1018 | if(CurAtt->DisplayMode()!=-1 && |
1019 | CurAtt->DisplayMode()!= DiMo) |
1020 | myMainPM->Erase(SO,CurAtt->DisplayMode()); |
1021 | } |
1022 | |
f751596e |
1023 | TColStd_ListIteratorOfListOfInteger aSelModeIter (CurAtt->SelectionModes()); |
1024 | for ( ; aSelModeIter.More(); aSelModeIter.Next()) |
1025 | { |
1026 | Standard_Integer aSelMode = aSelModeIter.Value(); |
1027 | mySM->Deactivate (SO, aSelMode, myMainVS); |
1028 | } |
1029 | |
7fd59977 |
1030 | } |
1031 | ClearSelected( Standard_False ); |
b3c433fe |
1032 | |
1033 | // Clear selection structures for temporary objects, created in local context |
1034 | for (AIS_DataMapIteratorOfDataMapOfSelStat anIter (myActiveObjects); anIter.More(); anIter.Next()) |
1035 | { |
1036 | if (anIter.Value()->IsTemporary()) |
1037 | { |
1038 | mySM->Remove (anIter.Key(), myMainVS); |
1039 | } |
1040 | } |
1041 | |
7fd59977 |
1042 | myActiveObjects.Clear(); |
7fd59977 |
1043 | } |
1044 | |
1045 | |
1046 | Standard_Boolean AIS_LocalContext::IsDecompositionOn() const |
1047 | {return !myListOfStandardMode.IsEmpty();} |
1048 | |
1049 | |
1050 | |
1051 | |
1052 | //======================================================================= |
1053 | //function : HasAlreadyFilters |
1054 | //purpose : |
1055 | //======================================================================= |
1056 | |
1057 | Standard_Boolean AIS_LocalContext:: |
1058 | HasFilters(const TopAbs_ShapeEnum aType) const |
1059 | { |
1060 | return myFilters->ActsOn(aType); |
1061 | } |
1062 | |
1063 | void AIS_LocalContext::ClearDetected() |
1064 | { |
b586500b |
1065 | for(Standard_Integer I=1;I<=myMapOfOwner->Extent();I++) |
eb4320f2 |
1066 | { |
b586500b |
1067 | if(!myMapOfOwner->FindKey (I).IsNull()) |
eb4320f2 |
1068 | { |
b586500b |
1069 | if(myMapOfOwner->FindKey (I)->IsHilighted(myMainPM)) |
1070 | myMapOfOwner->FindKey (I)->Unhilight(myMainPM); |
eb4320f2 |
1071 | else |
1072 | { |
1073 | const Handle(SelectMgr_SelectableObject)& SO = |
b586500b |
1074 | myMapOfOwner->FindKey (I)->Selectable(); |
eb4320f2 |
1075 | if(myActiveObjects.IsBound(SO)) |
1076 | { |
1077 | const Handle(AIS_LocalStatus)& Att = myActiveObjects(SO); |
1078 | |
1079 | if(Att->IsTemporary() && |
1080 | Att->DisplayMode()==-1 && |
1081 | Att->SelectionModes().IsEmpty()) |
1082 | { |
b586500b |
1083 | myMapOfOwner->FindKey (I)->Clear(myMainPM); |
eb4320f2 |
1084 | } |
1085 | } |
7fd59977 |
1086 | } |
1087 | } |
1088 | } |
7fd59977 |
1089 | } |
1090 | |
7fd59977 |
1091 | //======================================================================= |
679ecdee |
1092 | //function : BeginImmediateDraw |
1093 | //purpose : |
7fd59977 |
1094 | //======================================================================= |
679ecdee |
1095 | Standard_Boolean AIS_LocalContext::BeginImmediateDraw() |
7fd59977 |
1096 | { |
679ecdee |
1097 | if (myMainPM->IsImmediateModeOn()) |
1098 | { |
1099 | myMainPM->BeginImmediateDraw(); |
7fd59977 |
1100 | return Standard_True; |
1101 | } |
1102 | return Standard_False; |
1103 | } |
1104 | |
679ecdee |
1105 | //======================================================================= |
1106 | //function : ImmediateAdd |
1107 | //purpose : |
1108 | //======================================================================= |
1109 | Standard_Boolean AIS_LocalContext::ImmediateAdd (const Handle(AIS_InteractiveObject)& theObj, |
1110 | const Standard_Integer theMode) |
7fd59977 |
1111 | { |
679ecdee |
1112 | if (!myMainPM->IsImmediateModeOn()) |
1113 | { |
7fd59977 |
1114 | return Standard_False; |
679ecdee |
1115 | } |
1116 | |
af324faa |
1117 | myMainPM->AddToImmediateList (myMainPM->Presentation (theObj, theMode)->Presentation()); |
7fd59977 |
1118 | return Standard_True; |
1119 | } |
1120 | |
679ecdee |
1121 | //======================================================================= |
1122 | //function : EndImmediateDraw |
1123 | //purpose : |
1124 | //======================================================================= |
1125 | Standard_Boolean AIS_LocalContext::EndImmediateDraw (const Handle(V3d_View)& theView) |
7fd59977 |
1126 | { |
679ecdee |
1127 | if (!myMainPM->IsImmediateModeOn()) |
1128 | { |
1129 | return Standard_False; |
1130 | } |
1131 | |
1132 | myMainPM->EndImmediateDraw (theView); |
7fd59977 |
1133 | return Standard_True; |
1134 | } |
1135 | |
679ecdee |
1136 | // ======================================================================= |
1137 | // function : ClearImmediateDraw |
1138 | // purpose : |
1139 | // ======================================================================= |
1140 | void AIS_LocalContext::ClearImmediateDraw() |
7fd59977 |
1141 | { |
679ecdee |
1142 | myMainPM->ClearImmediateDraw(); |
7fd59977 |
1143 | } |
1144 | |
679ecdee |
1145 | //======================================================================= |
1146 | //function : IsImmediateModeOn |
1147 | //purpose : |
1148 | //======================================================================= |
7fd59977 |
1149 | Standard_Boolean AIS_LocalContext::IsImmediateModeOn() const |
679ecdee |
1150 | { |
1151 | return myMainPM->IsImmediateModeOn(); |
1152 | } |
7fd59977 |
1153 | |
f751596e |
1154 | void AIS_LocalContext::SetPixelTolerance(const Standard_Real aPrecision) { |
3c982548 |
1155 | |
1156 | myMainVS->SetPixelTolerance(aPrecision); |
1157 | } |
1158 | |
f751596e |
1159 | Standard_Real AIS_LocalContext::PixelTolerance() const { |
3c982548 |
1160 | |
1161 | return myMainVS->PixelTolerance(); |
7fd59977 |
1162 | } |