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