b311480e |
1 | // Created on: 1997-01-29 |
2 | // Created by: Robert COUBLANC |
3 | // Copyright (c) 1997-1999 Matra Datavision |
4 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | // |
6 | // The content of this file is subject to the Open CASCADE Technology Public |
7 | // License Version 6.5 (the "License"). You may not use the content of this file |
8 | // except in compliance with the License. Please obtain a copy of the License |
9 | // at http://www.opencascade.org and read it completely before using this file. |
10 | // |
11 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | // |
14 | // The Original Code and all software distributed under the License is |
15 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | // Initial Developer hereby disclaims all such warranties, including without |
17 | // limitation, any warranties of merchantability, fitness for a particular |
18 | // purpose or non-infringement. Please see the License for the specific terms |
19 | // and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | |
22 | #define IMP051001 //GG Adds SetZDetected() and ZDetected() methods |
23 | |
24 | #include <AIS_InteractiveContext.jxx> |
25 | |
26 | #include <AIS_LocalContext.hxx> |
27 | |
28 | #include <AIS_GlobalStatus.hxx> |
29 | #include <TColStd_ListIteratorOfListOfInteger.hxx> |
30 | |
31 | #include <AIS_DataMapIteratorOfDataMapOfIOStatus.hxx> |
32 | #include <AIS_DataMapIteratorOfDataMapOfILC.hxx> |
33 | #include <Graphic3d_StructureManager.hxx> |
34 | #include <Graphic3d_Structure.hxx> |
35 | #include <Graphic3d_MapOfStructure.hxx> |
36 | #include <Graphic3d_MapIteratorOfMapOfStructure.hxx> |
37 | #include <AIS_Selection.hxx> |
38 | |
7fd59977 |
39 | //======================================================================= |
40 | //function : OpenLocalContext |
41 | //purpose : |
42 | //======================================================================= |
43 | |
44 | Standard_Integer AIS_InteractiveContext:: |
45 | OpenLocalContext(const Standard_Boolean UseDisplayedObjects, |
46 | const Standard_Boolean AllowShapeDecomposition, |
47 | const Standard_Boolean AcceptEraseOfTemporary, |
48 | const Standard_Boolean /*BothViewers*/) |
49 | { |
50 | |
81bba717 |
51 | // the entities eventually detected just before the context was opened are unhighlighted... |
7fd59977 |
52 | if(!IsCurrent(myLastPicked)){ |
53 | if(!myLastPicked.IsNull()){ |
54 | Standard_Integer HiMod = myLastPicked->HasHilightMode()?myLastPicked->HilightMode():0; |
55 | myMainPM->Unhighlight(myLastPicked,HiMod); |
56 | }} |
57 | |
58 | if(!mylastmoveview.IsNull()){ |
59 | if(myCurLocalIndex>0) |
60 | myLocalContexts(myCurLocalIndex)->UnhilightLastDetected(mylastmoveview); |
61 | } |
62 | |
81bba717 |
63 | // entities connected to dynamic selection at neutral point are set to 0. |
7fd59977 |
64 | |
65 | myLastinMain.Nullify(); |
66 | myLastinColl.Nullify(); |
67 | myLastPicked.Nullify(); |
68 | myWasLastMain = Standard_True; |
69 | |
70 | |
71 | |
72 | Standard_Integer untilnow = myCurLocalIndex; |
73 | |
74 | myCurLocalIndex = HighestIndex() + 1; |
75 | |
76 | Handle(AIS_LocalContext) NewLocal= new AIS_LocalContext(this,myCurLocalIndex, |
77 | UseDisplayedObjects, |
78 | AllowShapeDecomposition, |
79 | AcceptEraseOfTemporary); |
64e2d3bd |
80 | // the AIS_LocalContext bind itself to myLocalContexts |
81 | // because procedures performed in AIS_LocalContext constructor |
82 | // already may access myLocalContexts(myCurLocalIndex) (like methods AIS_LocalContext::IsSelected()). |
83 | //myLocalContexts.Bind (myCurLocalIndex, NewLocal); |
84 | NewLocal->MainSelector()->Set ((myLocalContexts.Extent() > 1) |
ab943560 |
85 | ? myLocalContexts (untilnow)->MainSelector()->Projector() |
86 | : myMainSel->Projector()); |
87 | |
7fd59977 |
88 | NewLocal->MainSelector()->UpdateConversion(); |
7fd59977 |
89 | |
90 | #ifdef DEB |
91 | cout<<"\tOpen Local Context No "<<myCurLocalIndex<<endl; |
92 | if(UseDisplayedObjects){ |
93 | cout<<"\t\tObjects from Neutral Point loaded"<<endl; |
94 | if(AllowShapeDecomposition) |
95 | cout<<"\t\tDecomposition Authorized for Loaded Shapes"<<endl; |
96 | else |
97 | cout<<"\t\tNo Decomposition Authorized for Loaded Shapes"<<endl; |
98 | } |
99 | else |
100 | cout<<"\t\tNo Objects Were Loaded "<<endl; |
101 | #endif |
102 | return myCurLocalIndex; |
7fd59977 |
103 | } |
104 | |
105 | //======================================================================= |
106 | //function : CloseLocalContext |
107 | //purpose : |
108 | //======================================================================= |
109 | |
110 | void AIS_InteractiveContext::CloseLocalContext(const Standard_Integer Index, |
111 | const Standard_Boolean updateviewer) |
112 | { |
113 | |
114 | Standard_Boolean debugmode(Standard_False); |
115 | #ifdef DEB |
116 | debugmode = Standard_True; |
117 | #endif |
118 | |
119 | Standard_Integer GoodIndex = (Index ==-1) ? myCurLocalIndex : Index; |
120 | |
121 | if(debugmode) cout<<"Call to CloseLocalContext - Index "<<GoodIndex<<endl; |
122 | if(!HasOpenedContext()){ |
123 | if(debugmode) cout<<"\t But No Local Context is opened"<<endl; |
124 | return; |
125 | } |
126 | if(!myLocalContexts.IsBound(GoodIndex)) { |
127 | if(debugmode) cout<<" Attempt to Close a non-existent Local Context"<<endl; |
128 | return; |
129 | } |
130 | |
81bba717 |
131 | // the only open local context is closed... |
7fd59977 |
132 | if(myLocalContexts.Extent()==1 && GoodIndex == myCurLocalIndex){ |
133 | |
134 | Standard_Boolean updateproj = !(myLocalContexts(myCurLocalIndex)->HasSameProjector(myMainSel->Projector())); |
135 | myLocalContexts(myCurLocalIndex)->Terminate( updateviewer ); |
136 | myLocalContexts.UnBind(myCurLocalIndex); |
137 | myCurLocalIndex = 0; |
138 | |
139 | ResetOriginalState(Standard_False); |
140 | if(updateproj) |
141 | myMainSel->UpdateConversion(); |
142 | else{ |
143 | myMainSel->ReactivateProjector(); |
144 | myMainSel->UpdateSort(); |
145 | } |
146 | if(debugmode) |
147 | cout<<"No More Opened Local Context "<<endl; |
148 | } |
149 | |
81bba717 |
150 | // Otherwise the local context will be still open after the current is closed |
7fd59977 |
151 | else{ |
152 | Handle(StdSelect_ViewerSelector3d) VS = myLocalContexts(GoodIndex)->MainSelector(); |
153 | myLocalContexts(GoodIndex)->Terminate(); |
154 | myLocalContexts.UnBind(GoodIndex); |
81bba717 |
155 | // the current is closed... |
7fd59977 |
156 | if(GoodIndex==myCurLocalIndex){ |
157 | myCurLocalIndex = HighestIndex(); |
158 | const Handle(AIS_LocalContext)& LocCtx = myLocalContexts(myCurLocalIndex); |
159 | if(LocCtx->HasSameProjector(VS->Projector())){ |
160 | LocCtx->MainSelector()->ReactivateProjector(); |
161 | } |
162 | else |
163 | LocCtx->MainSelector()->UpdateConversion(); |
164 | } |
165 | else if(debugmode) |
166 | cout<<"a No Current Local Context WasClosed"<<endl; |
167 | |
168 | if(debugmode) cout<<"Index Of CurrentLocalContext:"<<myCurLocalIndex<<endl; |
169 | |
170 | } |
171 | |
172 | |
173 | if(updateviewer) myMainVwr->Update(); |
174 | } |
175 | |
176 | //======================================================================= |
177 | //function : CloseAllContexts |
178 | //purpose : |
179 | //======================================================================= |
180 | |
181 | void AIS_InteractiveContext::CloseAllContexts(const Standard_Boolean updateviewer) |
182 | { |
183 | |
184 | while(!myLocalContexts.IsEmpty()){ |
185 | CloseLocalContext(myCurLocalIndex,Standard_False); |
186 | } |
187 | |
188 | ResetOriginalState(Standard_False); |
189 | |
190 | myMainSel->UpdateSort(); |
191 | if(!myIsCollClosed && !myCollectorSel.IsNull()) |
192 | myCollectorSel->UpdateSort(); |
193 | if(updateviewer) myMainVwr->Update(); |
194 | } |
195 | |
196 | //======================================================================= |
197 | //function : IndexOfCurrentLocal |
198 | //purpose : |
199 | //======================================================================= |
200 | |
201 | Standard_Integer AIS_InteractiveContext::IndexOfCurrentLocal() const |
202 | { |
203 | return myCurLocalIndex; |
204 | } |
205 | |
206 | //======================================================================= |
207 | //function : ClearLocalContext |
208 | //purpose : |
209 | //======================================================================= |
210 | |
211 | void AIS_InteractiveContext::ClearLocalContext(const AIS_ClearMode aMode) |
212 | { |
213 | if (!HasOpenedContext()) return; |
214 | myLocalContexts(myCurLocalIndex)->Clear(aMode); |
215 | |
216 | } |
217 | |
218 | //======================================================================= |
219 | //function : HighestIndex |
220 | //purpose : |
221 | //======================================================================= |
222 | |
223 | Standard_Integer AIS_InteractiveContext::HighestIndex() const |
224 | { |
225 | AIS_DataMapIteratorOfDataMapOfILC It(myLocalContexts); |
226 | Standard_Integer HiInd = 0; |
227 | for(;It.More();It.Next()) |
228 | HiInd = (It.Key()>HiInd) ? It.Key() : HiInd; |
229 | return HiInd; |
230 | |
231 | } |
232 | |
233 | |
234 | //======================================================================= |
235 | //function : Activate |
236 | //purpose : |
237 | //======================================================================= |
238 | |
239 | void AIS_InteractiveContext:: |
240 | Activate(const Handle(AIS_InteractiveObject)& anIObj, |
241 | const Standard_Integer aMode) |
242 | { |
243 | if(!HasOpenedContext()){ |
244 | if(!myObjects.IsBound(anIObj)) return; |
245 | const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj); |
246 | if(STAT->GraphicStatus()==AIS_DS_Displayed) |
247 | mgrSelector->Activate(anIObj,aMode,myMainSel); |
248 | STAT ->AddSelectionMode(aMode); |
249 | } |
250 | else{ |
251 | myLocalContexts(myCurLocalIndex)->ActivateMode(anIObj,aMode); |
252 | } |
253 | } |
254 | |
255 | //======================================================================= |
256 | //function : LocalSelector |
257 | //purpose : |
258 | //======================================================================= |
259 | Handle( StdSelect_ViewerSelector3d ) AIS_InteractiveContext::LocalSelector() const |
260 | { |
261 | if( !HasOpenedContext() ) |
262 | return Handle( StdSelect_ViewerSelector3d )(); |
263 | else |
264 | return myLocalContexts( myCurLocalIndex )->MainSelector(); |
265 | } |
266 | |
267 | |
268 | //======================================================================= |
269 | //function : DeActivate |
270 | //purpose : |
271 | //======================================================================= |
272 | void AIS_InteractiveContext:: |
273 | Deactivate(const Handle(AIS_InteractiveObject)& anIObj) |
274 | { |
275 | if(!HasOpenedContext()){ |
276 | if(!myObjects.IsBound(anIObj)) return; |
ab943560 |
277 | TColStd_ListIteratorOfListOfInteger ItL; |
7fd59977 |
278 | for(ItL.Initialize(myObjects(anIObj)->SelectionModes()); |
279 | ItL.More(); |
280 | ItL.Next()){ |
281 | if(myObjects(anIObj)->GraphicStatus() == AIS_DS_Displayed) |
282 | mgrSelector->Deactivate(anIObj,ItL.Value(),myMainSel); |
283 | } |
284 | myObjects(anIObj)->ClearSelectionModes(); |
285 | } |
286 | else{ |
287 | const Handle(AIS_LocalContext)& LC = myLocalContexts(myCurLocalIndex); |
288 | LC->Deactivate(anIObj); |
289 | } |
290 | } |
291 | |
292 | //======================================================================= |
293 | //function : Deactivate |
294 | //purpose : |
295 | //======================================================================= |
296 | |
297 | void AIS_InteractiveContext::Deactivate(const Handle(AIS_InteractiveObject)& anIObj, |
298 | const Standard_Integer aMode) |
299 | { |
300 | if(!HasOpenedContext()){ |
301 | if(!myObjects.IsBound(anIObj)) return; |
302 | const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj); |
303 | |
304 | if(STAT->GraphicStatus() == AIS_DS_Displayed) |
305 | mgrSelector->Deactivate(anIObj,aMode,myMainSel); |
306 | STAT->RemoveSelectionMode(aMode); |
307 | } |
308 | else{ |
309 | myLocalContexts(myCurLocalIndex)->DeactivateMode(anIObj,aMode); |
310 | } |
311 | } |
312 | |
313 | //======================================================================= |
314 | //function : ActivatedModes |
315 | //purpose : |
316 | //======================================================================= |
317 | |
318 | void AIS_InteractiveContext:: |
319 | ActivatedModes(const Handle(AIS_InteractiveObject)& anIObj, |
320 | TColStd_ListOfInteger& theList) const |
321 | { |
ab943560 |
322 | TColStd_ListIteratorOfListOfInteger ItL; |
7fd59977 |
323 | if(!HasOpenedContext()){ |
324 | if(myObjects.IsBound(anIObj)){ |
7fd59977 |
325 | for(ItL.Initialize(myObjects(anIObj)->SelectionModes()); |
326 | ItL.More(); |
327 | ItL.Next()) |
328 | theList.Append(ItL.Value()); |
329 | |
330 | } |
331 | } |
332 | else{ |
333 | if(myLocalContexts(myCurLocalIndex)->IsIn(anIObj)){ |
334 | for(ItL.Initialize(myLocalContexts(myCurLocalIndex)->SelectionModes(anIObj)); |
335 | ItL.More(); |
336 | ItL.Next()) |
337 | theList.Append(ItL.Value()); |
338 | } |
339 | } |
340 | } |
341 | |
342 | //======================================================================= |
343 | //function : SetShapeDecomposition |
344 | //purpose : |
345 | //======================================================================= |
346 | |
347 | void AIS_InteractiveContext::SetShapeDecomposition(const Handle(AIS_InteractiveObject)& anIObj, |
348 | const Standard_Boolean StdModeSensitive) |
349 | { |
350 | if(!HasOpenedContext()) return; |
351 | myLocalContexts(myCurLocalIndex)->SetShapeDecomposition(anIObj,StdModeSensitive); |
352 | } |
353 | |
354 | //======================================================================= |
355 | //function : SetTemporaryAttributes |
356 | //purpose : |
357 | //======================================================================= |
358 | |
359 | void AIS_InteractiveContext:: |
360 | SetTemporaryAttributes(const Handle(AIS_InteractiveObject)& /*anObj*/, |
361 | const Handle(Prs3d_Drawer)& /*aDrawer*/, |
362 | const Standard_Boolean /*updateviewer*/) |
363 | { |
364 | } |
365 | |
366 | //======================================================================= |
367 | //function : SubIntensityOn |
368 | //purpose : |
369 | //======================================================================= |
370 | void AIS_InteractiveContext:: |
371 | SubIntensityOn(const Handle(AIS_InteractiveObject)& anIObj, |
372 | const Standard_Boolean updateviewer) |
373 | { |
374 | if(!HasOpenedContext()){ |
375 | if(!myObjects.IsBound(anIObj)) |
376 | return; |
377 | const Handle(AIS_GlobalStatus)& GB=myObjects(anIObj); |
378 | if(GB->IsSubIntensityOn()) |
379 | return; |
380 | GB->SubIntensityOn(); |
381 | Standard_Boolean UpdMain(Standard_False),UpdColl(Standard_False); |
382 | |
383 | for(TColStd_ListIteratorOfListOfInteger It(GB->DisplayedModes());It.More();It.Next()){ |
384 | if(GB->GraphicStatus()==AIS_DS_Displayed){ |
385 | myMainPM->Color(anIObj,mySubIntensity,It.Value()); |
386 | UpdMain = Standard_True;} |
387 | else if(GB->GraphicStatus()==AIS_DS_Erased){ |
388 | myCollectorPM->Color(anIObj,mySubIntensity,It.Value()); |
389 | UpdColl=Standard_True; |
390 | } |
391 | } |
392 | if(updateviewer){ |
393 | if(UpdMain) |
394 | myMainVwr->Update(); |
395 | if(UpdColl) |
396 | myCollectorVwr->Update(); |
397 | } |
398 | } |
399 | else { |
400 | if(myObjects.IsBound(anIObj)){ |
401 | const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj); |
402 | STAT->SubIntensityOn(); |
ab943560 |
403 | TColStd_ListIteratorOfListOfInteger ItL; |
7fd59977 |
404 | for (ItL.Initialize(STAT->DisplayedModes());ItL.More();ItL.Next()) |
405 | myMainPM->Color(anIObj,mySubIntensity,ItL.Value()); |
406 | } |
407 | else |
408 | myLocalContexts(myCurLocalIndex)->SubIntensityOn(anIObj); |
409 | |
410 | if(updateviewer) myMainVwr->Update(); |
411 | } |
412 | } |
413 | //======================================================================= |
414 | //function : SubIntensityOff |
415 | //purpose : |
416 | //======================================================================= |
417 | |
418 | void AIS_InteractiveContext:: |
419 | SubIntensityOff(const Handle(AIS_InteractiveObject)& anIObj, |
420 | const Standard_Boolean updateviewer) |
421 | { |
422 | if(!HasOpenedContext()){ |
423 | if(!myObjects.IsBound(anIObj)) |
424 | return; |
425 | const Handle(AIS_GlobalStatus)& GB=myObjects(anIObj); |
426 | if(!GB->IsSubIntensityOn()) |
427 | return; |
428 | GB->SubIntensityOff(); |
429 | Standard_Boolean UpdMain(Standard_False),UpdColl(Standard_False); |
430 | |
431 | for(TColStd_ListIteratorOfListOfInteger It(GB->DisplayedModes());It.More();It.Next()){ |
432 | if(GB->GraphicStatus()!=AIS_DS_Erased){ |
433 | myMainPM->Unhighlight(anIObj,It.Value()); |
434 | UpdMain = Standard_True;} |
435 | else { |
436 | myCollectorPM->Unhighlight(anIObj,It.Value()); |
437 | UpdColl=Standard_True; |
438 | } |
439 | } |
440 | |
441 | Standard_Integer DM,HM,SM; |
442 | GetDefModes(anIObj,DM,HM,SM); |
443 | if(AIS_Selection::IsSelected(anIObj)) |
444 | myMainPM->Highlight(anIObj,HM); |
445 | |
446 | if(updateviewer){ |
447 | if(UpdMain) |
448 | myMainVwr->Update(); |
449 | if(UpdColl) |
450 | myCollectorVwr->Update(); |
451 | } |
452 | } |
453 | else { |
454 | if(myObjects.IsBound(anIObj)){ |
455 | const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj); |
456 | STAT->SubIntensityOff(); |
ab943560 |
457 | TColStd_ListIteratorOfListOfInteger ItL; |
7fd59977 |
458 | for (ItL.Initialize(STAT->DisplayedModes());ItL.More();ItL.Next()) |
459 | myMainPM->Unhighlight(anIObj,ItL.Value()); |
460 | if(STAT->IsHilighted()) |
461 | Hilight(anIObj); |
462 | } |
463 | else |
464 | myLocalContexts(myCurLocalIndex)->SubIntensityOff(anIObj); |
465 | if(IsSelected(anIObj)) |
466 | Hilight(anIObj); |
467 | |
468 | if(updateviewer) myMainVwr->Update(); |
469 | } |
470 | } |
471 | |
472 | //======================================================================= |
473 | //function : SubIntensityOn |
474 | //purpose : ALL THE DISPLAYED OBJECTS HAVE SUBINTENSITY... |
475 | //======================================================================= |
476 | |
477 | void AIS_InteractiveContext::SubIntensityOn(const Standard_Boolean updateviewer) |
478 | { |
479 | if(!HasOpenedContext()) return; |
480 | |
481 | AIS_DataMapIteratorOfDataMapOfIOStatus It (myObjects); |
482 | TColStd_ListIteratorOfListOfInteger ItM; |
483 | for(;It.More();It.Next()){ |
484 | const Handle(AIS_GlobalStatus)& STAT = It.Value(); |
485 | if(STAT->GraphicStatus()==AIS_DS_Displayed) |
486 | { |
487 | STAT->SubIntensityOn(); |
488 | for(ItM.Initialize(STAT->DisplayedModes());ItM.More();ItM.Next()) |
489 | {myMainPM->Color(It.Key(),mySubIntensity,ItM.Value());} |
490 | } |
491 | } |
492 | if(updateviewer) myMainVwr->Update(); |
493 | } |
494 | |
495 | //======================================================================= |
496 | //function : SubIntensityOff |
497 | //purpose : |
498 | //======================================================================= |
499 | void AIS_InteractiveContext::SubIntensityOff(const Standard_Boolean updateviewer) |
500 | { |
7fd59977 |
501 | if(!HasOpenedContext()) return; |
ab943560 |
502 | |
7fd59977 |
503 | AIS_DataMapIteratorOfDataMapOfIOStatus It (myObjects); |
ab943560 |
504 | TColStd_ListIteratorOfListOfInteger ItL; |
7fd59977 |
505 | for(;It.More();It.Next()){ |
506 | const Handle(AIS_GlobalStatus)& STAT = It.Value(); |
507 | if(STAT->IsSubIntensityOn()) |
508 | STAT->SubIntensityOff(); |
509 | for(ItL.Initialize(STAT->DisplayedModes());ItL.More();ItL.Next()) |
510 | myMainPM->Unhighlight(It.Key()); |
511 | } |
ab943560 |
512 | |
7fd59977 |
513 | if(updateviewer) myMainVwr->Update(); |
514 | } |
515 | |
516 | //======================================================================= |
517 | //function : AddFilter |
518 | //purpose : |
519 | //======================================================================= |
520 | void AIS_InteractiveContext::AddFilter(const Handle(SelectMgr_Filter)& aFilter) |
521 | { |
522 | if(HasOpenedContext()) |
523 | myLocalContexts(myCurLocalIndex)->AddFilter(aFilter); |
524 | else |
525 | myFilters->Add(aFilter); |
526 | } |
527 | |
528 | //======================================================================= |
529 | //function : ActivateStandardMode |
530 | //purpose : |
531 | //======================================================================= |
532 | void AIS_InteractiveContext::ActivateStandardMode(const TopAbs_ShapeEnum aStandardActivation) |
533 | { |
534 | if(!HasOpenedContext()) return; |
535 | myLocalContexts(myCurLocalIndex)->ActivateStandardMode (aStandardActivation); |
536 | } |
537 | |
538 | //======================================================================= |
539 | //function : DeActivateStandardMode |
540 | //purpose : |
541 | //======================================================================= |
542 | void AIS_InteractiveContext::DeactivateStandardMode(const TopAbs_ShapeEnum aStandardActivation) |
543 | { |
544 | if(!HasOpenedContext()) return; |
545 | myLocalContexts(myCurLocalIndex)->DeactivateStandardMode (aStandardActivation); |
546 | } |
547 | |
548 | //======================================================================= |
549 | //function : RemoveFilter |
550 | //purpose : |
551 | //======================================================================= |
552 | void AIS_InteractiveContext::RemoveFilter(const Handle(SelectMgr_Filter)& aFilter) |
553 | { |
554 | if(HasOpenedContext()) |
555 | myLocalContexts(myCurLocalIndex)->RemoveFilter (aFilter); |
556 | else |
557 | myFilters->Remove(aFilter); |
558 | } |
559 | |
560 | //======================================================================= |
561 | //function : RemoveFilters |
562 | //purpose : |
563 | //======================================================================= |
564 | |
565 | void AIS_InteractiveContext::RemoveFilters() |
566 | { |
567 | if(!HasOpenedContext()) |
568 | myFilters->Clear(); |
569 | else |
570 | myLocalContexts(myCurLocalIndex)->Clear(AIS_CM_Filters); |
571 | } |
572 | |
573 | //======================================================================= |
574 | //function : ActivatedStandardModes |
575 | //purpose : |
576 | //======================================================================= |
577 | const TColStd_ListOfInteger& AIS_InteractiveContext::ActivatedStandardModes() const |
578 | { |
579 | return myLocalContexts(myCurLocalIndex)->StandardModes(); |
580 | } |
581 | |
582 | //======================================================================= |
583 | //function : Filters |
584 | //purpose : |
585 | //======================================================================= |
586 | const SelectMgr_ListOfFilter& AIS_InteractiveContext::Filters() const |
587 | { |
588 | if(HasOpenedContext()) |
589 | return myLocalContexts(myCurLocalIndex)->ListOfFilter(); |
590 | return myFilters->StoredFilters(); |
591 | } |
592 | |
593 | //======================================================================= |
594 | //function : DisplayActiveAreas |
595 | //purpose : |
596 | //======================================================================= |
597 | void AIS_InteractiveContext::DisplayActiveAreas(const Handle(V3d_View)& aviou) |
598 | { |
599 | if(HasOpenedContext()) |
600 | myLocalContexts(myCurLocalIndex)->DisplayAreas(aviou); |
601 | else |
602 | myMainSel->DisplayAreas(aviou); |
603 | |
604 | } |
605 | |
606 | //======================================================================= |
607 | //function : ClearActiveAreas |
608 | //purpose : |
609 | //======================================================================= |
610 | void AIS_InteractiveContext::ClearActiveAreas(const Handle(V3d_View)& aviou) |
611 | { |
612 | if(HasOpenedContext()) |
613 | myLocalContexts(myCurLocalIndex)->ClearAreas(aviou); |
614 | else |
615 | myMainSel->ClearAreas(aviou); |
616 | } |
617 | |
618 | //======================================================================= |
619 | //function : DisplayActiveSensitive |
620 | //purpose : |
621 | //======================================================================= |
622 | void AIS_InteractiveContext::DisplayActiveSensitive(const Handle(V3d_View)& aviou) |
623 | { |
624 | if(HasOpenedContext()) |
625 | myLocalContexts(myCurLocalIndex)->DisplaySensitive(aviou); |
626 | else |
627 | myMainSel->DisplaySensitive(aviou); |
628 | } |
629 | //======================================================================= |
630 | //function : DisplayActiveSensitive |
631 | //purpose : |
632 | //======================================================================= |
633 | |
634 | void AIS_InteractiveContext::DisplayActiveSensitive(const Handle(AIS_InteractiveObject)& anIObj, |
635 | const Handle(V3d_View)& aviou) |
636 | { |
637 | TColStd_ListIteratorOfListOfInteger It; |
638 | Handle(StdSelect_ViewerSelector3d) VS; |
639 | if(HasOpenedContext()){ |
640 | const Handle(AIS_LocalContext)& LC = myLocalContexts(myCurLocalIndex); |
641 | if(!LC->IsIn(anIObj)) return; |
642 | It.Initialize(LC->SelectionModes(anIObj)); |
643 | VS = LC->MainSelector(); |
644 | } |
645 | else{ |
646 | if(!myObjects.IsBound(anIObj)) return; |
647 | It.Initialize(myObjects(anIObj)->SelectionModes()); |
648 | VS = myMainSel; |
649 | } |
650 | |
651 | |
652 | for(;It.More();It.Next()){ |
653 | const Handle(SelectMgr_Selection)& Sel = anIObj->Selection(It.Value()); |
654 | VS->DisplaySensitive(Sel,aviou,Standard_False); |
655 | } |
656 | |
657 | } |
658 | |
659 | //======================================================================= |
660 | //function : DisplayActiveAreas |
661 | //purpose : |
662 | //======================================================================= |
663 | |
664 | void AIS_InteractiveContext::DisplayActiveAreas(const Handle(AIS_InteractiveObject)& anIObj, |
665 | const Handle(V3d_View)& aviou) |
666 | { |
667 | TColStd_ListIteratorOfListOfInteger It; |
668 | Handle(StdSelect_ViewerSelector3d) VS; |
669 | if(HasOpenedContext()){ |
670 | const Handle(AIS_LocalContext)& LC = myLocalContexts(myCurLocalIndex); |
671 | if(!LC->IsIn(anIObj)) return; |
672 | It.Initialize(LC->SelectionModes(anIObj)); |
673 | VS = LC->MainSelector(); |
674 | } |
675 | else{ |
676 | if(!myObjects.IsBound(anIObj)) return; |
677 | It.Initialize(myObjects(anIObj)->SelectionModes()); |
678 | VS = myMainSel; |
679 | } |
680 | |
681 | |
682 | for(;It.More();It.Next()){ |
683 | const Handle(SelectMgr_Selection)& Sel = anIObj->Selection(It.Value()); |
684 | VS->DisplayAreas(Sel,aviou,Standard_False); |
685 | } |
686 | |
687 | } |
688 | |
689 | //======================================================================= |
690 | //function : ClearActiveSensitive |
691 | //purpose : |
692 | //======================================================================= |
693 | void AIS_InteractiveContext::ClearActiveSensitive(const Handle(V3d_View)& aviou) |
694 | { |
695 | |
696 | if(HasOpenedContext()) |
697 | myLocalContexts(myCurLocalIndex)->ClearSensitive(aviou); |
698 | else |
699 | myMainSel->ClearSensitive(aviou); |
700 | } |
701 | |
702 | //======================================================================= |
703 | //function : SetAutomaticHilight |
704 | //purpose : |
705 | //======================================================================= |
706 | void AIS_InteractiveContext::SetAutomaticHilight(const Standard_Boolean aStatus) |
707 | { |
708 | |
709 | if(HasOpenedContext()) |
710 | myLocalContexts(myCurLocalIndex)->SetAutomaticHilight(aStatus); |
711 | } |
712 | |
713 | //======================================================================= |
714 | //function : AutomaticHilight |
715 | //purpose : |
716 | //======================================================================= |
717 | Standard_Boolean AIS_InteractiveContext::AutomaticHilight() const |
718 | { |
719 | if(HasOpenedContext()) |
720 | return myLocalContexts(myCurLocalIndex)->AutomaticHilight(); |
721 | return Standard_True; |
722 | } |
723 | |
724 | //======================================================================= |
725 | //function : UseDisplayedObjects |
726 | //purpose : |
727 | //======================================================================= |
728 | |
729 | void AIS_InteractiveContext::UseDisplayedObjects() |
730 | { |
731 | if(HasOpenedContext()) |
732 | myLocalContexts(myCurLocalIndex)->LoadContextObjects(); |
733 | } |
734 | |
735 | //======================================================================= |
736 | //function : NotUseDisplayedObjects |
737 | //purpose : |
738 | //======================================================================= |
739 | |
740 | void AIS_InteractiveContext::NotUseDisplayedObjects() |
741 | { |
742 | if(HasOpenedContext()) |
743 | myLocalContexts(myCurLocalIndex)->UnloadContextObjects(); |
744 | } |
745 | |
746 | |
747 | |
748 | |
749 | //======================================================================= |
750 | //function : PurgeDisplay |
751 | //purpose : |
752 | //======================================================================= |
753 | |
754 | Standard_Integer AIS_InteractiveContext::PurgeDisplay(const Standard_Boolean CollectorToo) |
755 | { |
756 | if(HasOpenedContext()) return 0; |
757 | |
758 | Standard_Integer NbStr = PurgeViewer(myMainVwr); |
759 | if(!myCollectorVwr.IsNull()) |
760 | if(CollectorToo){ |
761 | NbStr+=PurgeViewer(myCollectorVwr); |
762 | if(!IsCollectorClosed()) |
763 | myCollectorVwr->Update(); |
764 | } |
765 | myMainVwr->Update(); |
766 | return NbStr; |
767 | |
768 | } |
769 | |
770 | |
771 | //======================================================================= |
772 | //function : PurgeViewer |
773 | //purpose : |
774 | //======================================================================= |
775 | Standard_Integer AIS_InteractiveContext::PurgeViewer(const Handle(V3d_Viewer)& Vwr) |
776 | { |
777 | const Handle(Graphic3d_StructureManager)& GSM = Vwr->Viewer(); |
778 | Standard_Integer NbCleared(0); |
779 | Graphic3d_MapOfStructure SOS; |
780 | GSM->DisplayedStructures(SOS); |
781 | |
782 | Handle(Graphic3d_Structure) G; |
783 | for(Graphic3d_MapIteratorOfMapOfStructure It(SOS); It.More();It.Next()){ |
784 | G = It.Key(); |
785 | Standard_Address Add = G->Owner(); |
786 | if(Add==NULL){ |
787 | G->Erase(); |
81bba717 |
788 | G->Clear();// it means that it is not referenced as a presentation of InterfactiveObject... |
7fd59977 |
789 | NbCleared++; |
790 | } |
791 | Handle(AIS_InteractiveObject) IO = (AIS_InteractiveObject*)Add; |
792 | if(!myObjects.IsBound(IO)){ |
793 | G->Erase(); |
794 | NbCleared++; |
795 | } |
796 | } |
797 | return NbCleared; |
798 | } |
799 | |
800 | |
801 | //======================================================================= |
802 | //function : IsImmediateModeOn |
803 | //purpose : |
804 | //======================================================================= |
805 | Standard_Boolean AIS_InteractiveContext::IsImmediateModeOn() const |
806 | { |
807 | if(!HasOpenedContext()) return Standard_False; |
808 | return myLocalContexts(myCurLocalIndex)->IsImmediateModeOn(); |
809 | } |
810 | |
811 | Standard_Boolean AIS_InteractiveContext::BeginImmediateDraw() |
812 | { |
813 | if(HasOpenedContext()) |
814 | return myLocalContexts(myCurLocalIndex)->BeginImmediateDraw(); |
815 | return Standard_False; |
816 | } |
817 | |
818 | //======================================================================= |
819 | //function : ImmediateAdd |
820 | //purpose : |
821 | //======================================================================= |
822 | |
823 | Standard_Boolean AIS_InteractiveContext::ImmediateAdd(const Handle(AIS_InteractiveObject)& anIObj, |
824 | const Standard_Integer AMode) |
825 | { |
826 | if(HasOpenedContext()){ |
827 | return myLocalContexts(myCurLocalIndex)->ImmediateAdd(anIObj,AMode);} |
828 | return Standard_False; |
829 | } |
830 | |
831 | //======================================================================= |
832 | //function : ImmediateRemove |
833 | //purpose : |
834 | //======================================================================= |
835 | |
836 | Standard_Boolean AIS_InteractiveContext::ImmediateRemove(const Handle(AIS_InteractiveObject)& anIObj, |
837 | const Standard_Integer aMode) |
838 | { |
839 | if(HasOpenedContext()) |
840 | return myLocalContexts(myCurLocalIndex)->ImmediateRemove(anIObj,aMode); |
841 | return Standard_False; |
842 | } |
843 | |
844 | //======================================================================= |
845 | //function : EndImmediateDraw |
846 | //purpose : |
847 | //======================================================================= |
848 | |
849 | Standard_Boolean AIS_InteractiveContext::EndImmediateDraw(const Handle(V3d_View)& aView, |
850 | const Standard_Boolean DoubleBuf) |
851 | { |
852 | if(HasOpenedContext()) |
853 | return myLocalContexts(myCurLocalIndex)->EndImmediateDraw(aView,DoubleBuf); |
854 | return Standard_False; |
855 | |
856 | } |
857 | |
858 | //======================================================================= |
859 | //function : EndImmediateDraw |
860 | //purpose : |
861 | //======================================================================= |
862 | |
863 | Standard_Boolean AIS_InteractiveContext::EndImmediateDraw(const Standard_Boolean DoubleBuf) |
864 | { |
865 | if(HasOpenedContext()){ |
866 | Handle(V3d_View) V ; |
867 | myMainVwr->InitActiveViews(); |
868 | if(myMainVwr->MoreActiveViews()){ |
869 | V = myMainVwr->ActiveView(); |
870 | |
871 | return myLocalContexts(myCurLocalIndex)->EndImmediateDraw(V,DoubleBuf); |
872 | } |
873 | } |
874 | return Standard_False; |
875 | |
876 | } |
877 | |
878 | |
879 | //======================================================================= |
880 | //function : ResetOriginalState |
881 | //purpose : |
882 | //======================================================================= |
883 | |
884 | void AIS_InteractiveContext::ResetOriginalState(const Standard_Boolean updateviewer) |
885 | { |
886 | Standard_Boolean upd_main(Standard_False),upd_col(Standard_False); |
887 | TColStd_ListIteratorOfListOfInteger itl; |
ab943560 |
888 | |
7fd59977 |
889 | for (AIS_DataMapIteratorOfDataMapOfIOStatus it(myObjects);it.More();it.Next()){ |
890 | const Handle(AIS_InteractiveObject)& iobj = it.Key(); |
891 | const Handle(AIS_GlobalStatus)& STAT = it.Value(); |
892 | switch(STAT->GraphicStatus()){ |
893 | case AIS_DS_Displayed:{ |
894 | upd_main = Standard_True; |
895 | |
81bba717 |
896 | // part display... |
7fd59977 |
897 | for(itl.Initialize(STAT->DisplayedModes());itl.More();itl.Next()) |
898 | myMainPM->Display(iobj,itl.Value()); |
899 | if(STAT->IsHilighted()){ |
900 | if(STAT->HilightColor()!=Quantity_NOC_WHITE) |
901 | HilightWithColor(iobj,STAT->HilightColor(),Standard_False); |
902 | else |
903 | Hilight(iobj,Standard_False); |
904 | } |
81bba717 |
905 | //part selection |
7fd59977 |
906 | for(itl.Initialize(STAT->SelectionModes());itl.More();itl.Next()){ |
907 | if(itl.Value()!=-1) |
908 | mgrSelector->Activate(iobj,itl.Value(),myMainSel); |
909 | } |
910 | break; |
911 | } |
912 | case AIS_DS_Erased:{ |
913 | upd_col = Standard_True; |
914 | EraseGlobal(iobj,Standard_False,Standard_True); |
915 | break; |
916 | } |
917 | case AIS_DS_FullErased:{ |
918 | EraseGlobal(iobj,Standard_False,Standard_False); |
919 | break; |
920 | } |
921 | default: |
922 | break; |
923 | } |
924 | } |
925 | if(updateviewer){ |
926 | if(upd_main) |
927 | myMainVwr->Update(); |
928 | if(upd_col) |
929 | myCollectorVwr->Update(); |
930 | } |
931 | } |
932 | |
933 | #ifdef IMP051001 |
934 | //======================================================================= |
935 | //function : SetZDetection |
936 | //purpose : |
937 | //======================================================================= |
938 | void AIS_InteractiveContext::SetZDetection(const Standard_Boolean aStatus) |
939 | { |
940 | myZDetectionFlag = aStatus; |
941 | } |
942 | |
943 | //======================================================================= |
944 | //function : ZDetection |
945 | //purpose : |
946 | //======================================================================= |
947 | Standard_Boolean AIS_InteractiveContext::ZDetection() const |
948 | { |
949 | return myZDetectionFlag; |
950 | } |
951 | #endif |