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