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