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