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