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