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