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 | |
884 | |
885 | //======================================================================= |
886 | //function : DisplayedObjects |
887 | //purpose : |
888 | //======================================================================= |
889 | Standard_Integer AIS_LocalContext::DisplayedObjects(TColStd_MapOfTransient& theMap) const |
890 | { |
891 | Standard_Integer NbDisp(0); |
892 | for(AIS_DataMapIteratorOfDataMapOfSelStat it(myActiveObjects);it.More();it.Next()){ |
893 | const Handle(SelectMgr_SelectableObject)& SO = it.Key(); |
894 | if(!theMap.Contains(SO)) |
895 | if(it.Value()->DisplayMode()!=-1){ |
896 | theMap.Add(SO); |
897 | NbDisp++; |
898 | } |
899 | } |
900 | return NbDisp; |
901 | } |
902 | |
903 | |
904 | //======================================================================= |
905 | //function : IsDisplayed |
906 | //purpose : |
907 | //======================================================================= |
908 | |
909 | Standard_Boolean AIS_LocalContext::IsDisplayed(const Handle(AIS_InteractiveObject)& anObject) const |
910 | { |
911 | if(!myActiveObjects.IsBound(anObject)) return Standard_False; |
912 | return (myActiveObjects(anObject)->DisplayMode()!=-1); |
913 | } |
914 | |
915 | //======================================================================= |
916 | //function : IsDisplayed |
917 | //purpose : |
918 | //======================================================================= |
919 | |
920 | Standard_Boolean AIS_LocalContext::IsDisplayed(const Handle(AIS_InteractiveObject)& anObject, |
921 | const Standard_Integer aMode) const |
922 | { |
923 | if(!myActiveObjects.IsBound(anObject)) return Standard_False; |
924 | return (myActiveObjects(anObject)->DisplayMode()==aMode); |
925 | } |
926 | |
927 | //======================================================================= |
928 | //function : SelectionModes |
929 | //purpose : |
930 | //======================================================================= |
931 | |
932 | const TColStd_ListOfInteger& AIS_LocalContext:: |
933 | SelectionModes(const Handle(AIS_InteractiveObject)& anObject) const |
934 | { |
935 | return myActiveObjects(anObject)->SelectionModes(); |
936 | } |
937 | |
938 | //======================================================================= |
939 | //function : Status |
940 | //purpose : |
941 | //======================================================================= |
942 | |
943 | TCollection_AsciiString AIS_LocalContext::Status() const |
944 | { |
945 | TCollection_AsciiString t; |
946 | return t; |
947 | } |
948 | |
949 | const Handle(AIS_LocalStatus)& AIS_LocalContext::Status(const Handle(AIS_InteractiveObject)& anObject) const |
950 | { |
951 | return myActiveObjects(anObject); |
952 | } |
953 | |
954 | //======================================================================= |
955 | //function : LoadContextObjects |
956 | //purpose : |
957 | //======================================================================= |
958 | |
959 | void AIS_LocalContext::LoadContextObjects() |
960 | { |
961 | AIS_ListIteratorOfListOfInteractive It; |
962 | if(myLoadDisplayed) { |
963 | AIS_ListOfInteractive LL; |
964 | myCTX->DisplayedObjects(LL,Standard_True); |
965 | Handle(AIS_LocalStatus) Att; |
966 | for (It.Initialize(LL);It.More();It.Next()){ |
967 | Att= new AIS_LocalStatus(); |
968 | Att->SetDecomposition((It.Value()->AcceptShapeDecomposition() && myAcceptStdMode)); |
969 | Att->SetTemporary(Standard_False); |
970 | Att->SetHilightMode(It.Value()->HasHilightMode()? It.Value()->HilightMode(): 0); |
971 | |
972 | myActiveObjects.Bind(It.Value(),Att); |
973 | } |
974 | } |
975 | } |
976 | |
977 | void AIS_LocalContext::UnloadContextObjects() |
978 | { |
979 | AIS_ListIteratorOfListOfInteractive It; |
980 | if(myLoadDisplayed) |
981 | { |
982 | AIS_ListOfInteractive LL; |
983 | myCTX->DisplayedObjects(LL,Standard_True); |
984 | |
985 | for (It.Initialize(LL);It.More();It.Next()) |
986 | { |
987 | myActiveObjects.UnBind(It.Value()); |
988 | } |
989 | } |
990 | } |
991 | //======================================================================= |
992 | //function : Process |
993 | //purpose : |
994 | //======================================================================= |
995 | |
996 | void AIS_LocalContext::Process(const Handle(SelectMgr_SelectableObject)& anObject, |
997 | const Standard_Boolean WithProj) |
998 | { |
999 | if(!myActiveObjects.IsBound(anObject)) return; |
1000 | if(myActiveObjects(anObject)->Decomposed()) |
1001 | ActivateStandardModes(anObject,WithProj); |
1002 | else |
1003 | { |
1004 | TColStd_ListIteratorOfListOfInteger It(myActiveObjects(anObject)->SelectionModes()); |
1005 | for(;It.More();It.Next()) |
1006 | myCTX->SelectionManager()->Activate(anObject,It.Value(),myMainVS,WithProj); |
1007 | } |
1008 | } |
1009 | |
1010 | //======================================================================= |
1011 | //function : Process |
1012 | //purpose : |
1013 | //======================================================================= |
1014 | |
1015 | void AIS_LocalContext::Process(const Standard_Boolean WithProj) |
1016 | { |
1017 | |
1018 | myMainVS->Clear(); |
1019 | |
1020 | AIS_DataMapIteratorOfDataMapOfSelStat It(myActiveObjects); |
1021 | |
1022 | for(;It.More();It.Next()){ |
1023 | myCTX->SelectionManager()->Load(It.Key(),myMainVS); |
1024 | if(It.Value()->Decomposed()) |
1025 | ActivateStandardModes(It.Key(),WithProj); |
1026 | else if( myCTX->GetAutoActivateSelection() ) |
1027 | { |
1028 | It.Value()->AddSelectionMode(0); |
1029 | myCTX->SelectionManager()->Activate(It.Key(),0,myMainVS,WithProj); |
1030 | } |
1031 | } |
1032 | |
1033 | } |
1034 | |
1035 | //======================================================================= |
1036 | //function : ActivateModes |
1037 | //purpose : |
1038 | //======================================================================= |
1039 | |
1040 | void AIS_LocalContext::ActivateStandardModes(const Handle(SelectMgr_SelectableObject)& anObject, |
1041 | const Standard_Boolean WithProj) |
1042 | { |
1043 | if(!myActiveObjects.IsBound(anObject)) return; |
1044 | |
1045 | TColStd_ListIteratorOfListOfInteger itl (myListOfStandardMode); |
1046 | |
1047 | const Handle(AIS_LocalStatus)& LS = myActiveObjects(anObject); |
1048 | if(LS->Decomposed()){ |
1049 | for(;itl.More();itl.Next()){ |
1050 | myCTX->SelectionManager()->Activate(anObject,itl.Value(),myMainVS,WithProj); |
1051 | LS->AddSelectionMode(itl.Value()); |
1052 | } |
1053 | } |
1054 | } |
1055 | |
1056 | |
1057 | //======================================================================= |
1058 | //function : ClearObjects |
1059 | //purpose : |
1060 | //======================================================================= |
1061 | |
1062 | void AIS_LocalContext::ClearObjects() |
1063 | { |
1064 | AIS_DataMapIteratorOfDataMapOfSelStat It(myActiveObjects); |
1065 | for(;It.More();It.Next()) |
1066 | { |
1067 | Handle(AIS_InteractiveObject) SO = |
1068 | Handle(AIS_InteractiveObject)::DownCast(It.Key()); |
1069 | |
1070 | const Handle(AIS_LocalStatus)& CurAtt = It.Value(); |
1071 | //TColStd_ListIteratorOfListOfInteger ItL; |
81bba717 |
1072 | // if object is temporary the presentations managed by myMainPM are removed |
7fd59977 |
1073 | AIS_DisplayStatus TheDS = myCTX->DisplayStatus(SO); |
1074 | |
1075 | if(TheDS != AIS_DS_Displayed){ |
1076 | if(myMainPM->IsDisplayed(SO,CurAtt->DisplayMode())){ |
1077 | if(CurAtt->IsSubIntensityOn()&& |
1078 | myMainPM->IsHighlighted(SO,CurAtt->HilightMode())) |
1079 | myMainPM->Unhighlight(SO,CurAtt->HilightMode()); |
1080 | myMainPM->Erase(SO,CurAtt->DisplayMode()); |
1081 | } |
1082 | |
1083 | if(CurAtt->IsTemporary()){ |
1084 | myMainPM->Erase(SO,CurAtt->DisplayMode());} |
1085 | // myMainPM->Clear(SO,CurAtt->DisplayMode());} |
1086 | } |
1087 | else { |
1088 | if (CurAtt->IsSubIntensityOn()){ |
1089 | myCTX->SubIntensityOff(Handle(AIS_InteractiveObject)::DownCast(SO));} |
1090 | Standard_Integer DiMo = SO->HasDisplayMode()? |
1091 | SO->DisplayMode():myCTX->DisplayMode(); |
1092 | if(CurAtt->DisplayMode()!=-1 && |
1093 | CurAtt->DisplayMode()!= DiMo) |
1094 | myMainPM->Erase(SO,CurAtt->DisplayMode()); |
1095 | } |
1096 | |
1097 | TColStd_ListIteratorOfListOfInteger ITL(CurAtt->SelectionModes()); |
1098 | for(;ITL.More();ITL.Next()) |
1099 | mySM->Deactivate(SO,ITL.Value(),myMainVS); |
1100 | |
1101 | if(CurAtt->IsTemporary()) |
1102 | mySM->Remove(SO,myMainVS); |
1103 | |
1104 | } |
1105 | ClearSelected( Standard_False ); |
1106 | myActiveObjects.Clear(); |
1107 | // myMainVS->ClearAreas();myMainVS->ClearSensitive(); |
1108 | } |
1109 | |
1110 | |
1111 | Standard_Boolean AIS_LocalContext::IsDecompositionOn() const |
1112 | {return !myListOfStandardMode.IsEmpty();} |
1113 | |
1114 | |
1115 | |
1116 | |
1117 | //======================================================================= |
1118 | //function : HasAlreadyFilters |
1119 | //purpose : |
1120 | //======================================================================= |
1121 | |
1122 | Standard_Boolean AIS_LocalContext:: |
1123 | HasFilters(const TopAbs_ShapeEnum aType) const |
1124 | { |
1125 | return myFilters->ActsOn(aType); |
1126 | } |
1127 | |
1128 | void AIS_LocalContext::ClearDetected() |
1129 | { |
1130 | for(Standard_Integer I=1;I<=myMapOfOwner.Extent();I++){ |
1131 | |
1132 | if(!myMapOfOwner(I).IsNull()){ |
1133 | if(myMapOfOwner(I)->IsHilighted(myMainPM)) |
1134 | myMapOfOwner(I)->Unhilight(myMainPM); |
1135 | else if (myMapOfOwner(I)->IsHilighted(myCTX->CollectorPrsMgr())) |
1136 | myMapOfOwner(I)->Unhilight(myCTX->CollectorPrsMgr()); |
1137 | |
1138 | else{ |
1139 | const Handle(SelectMgr_SelectableObject)& SO = |
1140 | myMapOfOwner.FindKey(I)->Selectable(); |
1141 | if(myActiveObjects.IsBound(SO)){ |
1142 | const Handle(AIS_LocalStatus)& Att = myActiveObjects(SO); |
1143 | |
1144 | if(Att->IsTemporary() && |
1145 | Att->DisplayMode()==-1 && |
1146 | Att->SelectionModes().IsEmpty()){ |
1147 | myMapOfOwner(I)->Clear(myMainPM); |
1148 | //myMapOfOwner(I)->Clear();//rob-jmi... |
1149 | } |
1150 | } |
1151 | } |
1152 | } |
1153 | } |
1154 | |
1155 | } |
1156 | |
1157 | void AIS_LocalContext::UpdateConversion() |
1158 | { |
1159 | myMainVS->UpdateConversion(); |
1160 | } |
1161 | |
1162 | void AIS_LocalContext::UpdateSort() |
1163 | { |
1164 | myMainVS->UpdateSort(); |
1165 | } |
1166 | |
1167 | |
1168 | |
1169 | //======================================================================= |
1170 | //function : IMMEDIATE MODE |
1171 | //purpose : |
1172 | //======================================================================= |
1173 | |
1174 | Standard_Boolean AIS_LocalContext::BeginImmediateDraw() |
1175 | { |
1176 | if(myMainPM->IsImmediateModeOn()){ |
1177 | myMainPM->BeginDraw(); |
1178 | return Standard_True; |
1179 | } |
1180 | return Standard_False; |
1181 | } |
1182 | |
1183 | |
1184 | Standard_Boolean AIS_LocalContext::ImmediateAdd(const Handle(AIS_InteractiveObject)& anIObj, |
1185 | const Standard_Integer aMode) |
1186 | { |
1187 | if(!myMainPM->IsImmediateModeOn()) |
1188 | return Standard_False; |
1189 | myMainPM->Add(anIObj,aMode); |
1190 | return Standard_True; |
1191 | } |
1192 | |
1193 | Standard_Boolean AIS_LocalContext::ImmediateRemove(const Handle(AIS_InteractiveObject)& anIObj, |
1194 | const Standard_Integer aMode) |
1195 | { |
1196 | if(!myMainPM->IsImmediateModeOn()) return Standard_False; |
1197 | myMainPM->Remove(anIObj,aMode); |
1198 | return Standard_True; |
1199 | } |
1200 | |
1201 | Standard_Boolean AIS_LocalContext::EndImmediateDraw(const Handle(V3d_View)& aView, |
1202 | const Standard_Boolean DoubleBuf) |
1203 | { |
1204 | if(!myMainPM->IsImmediateModeOn()) return Standard_False; |
1205 | myMainPM->EndDraw(aView,DoubleBuf); |
1206 | return Standard_True; |
1207 | } |
1208 | |
1209 | Standard_Boolean AIS_LocalContext::IsImmediateModeOn() const |
1210 | {return myMainPM->IsImmediateModeOn();} |
1211 | |
1212 | #ifdef BUC60688 |
1213 | void AIS_LocalContext::SetSensitivity(const Standard_Real aPrecision) { |
1214 | |
1215 | myMainVS->SetSensitivity(aPrecision); |
1216 | } |
1217 | |
1218 | void AIS_LocalContext::SetSensitivity(const Standard_Integer aPrecision) { |
1219 | |
1220 | myMainVS->Set(aPrecision); |
1221 | } |
1222 | #endif |