b311480e |
1 | // Created on: 1997-01-17 |
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 | // |
973c2be1 |
8 | // This library is free software; you can redistribute it and / or modify it |
9 | // under the terms of the GNU Lesser General Public version 2.1 as published |
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. |
b311480e |
16 | |
7fd59977 |
17 | //Modified by ROB : Traque des UpdateConversion intempestifs. |
18 | |
19 | #define BUC60688 //GG 25/05/00 Add SetSensitivity() methods. |
20 | |
21 | #define BUC60722 //GG_040900 Disable detection on an unviewable object |
22 | |
23 | #define IMP160701 //SZV Add InitDetected(),MoreDetected(),NextDetected(), |
24 | // DetectedCurrentShape(),DetectedCurrentObject() |
25 | // methods |
26 | |
27 | #define ALE70590 //GG Avoid raise especially under W2000-SP2 |
28 | // when opening many local context due to a |
29 | // system error in the selection name computation routine. |
30 | // Many thanks to Philippe CARRET for the helpfull he has |
31 | // give to accelerate the resolution of this problem. |
32 | |
33 | #include <AIS_LocalContext.ixx> |
34 | #include <SelectMgr_OrFilter.hxx> |
35 | #include <SelectMgr_CompositionFilter.hxx> |
36 | #include <AIS_LocalStatus.hxx> |
37 | #include <AIS_Shape.hxx> |
38 | #include <TColStd_ListIteratorOfListOfInteger.hxx> |
39 | #include <AIS_ListIteratorOfListOfInteractive.hxx> |
40 | #include <AIS_ListOfInteractive.hxx> |
41 | #include <AIS_DataMapIteratorOfDataMapOfSelStat.hxx> |
42 | #include <TopAbs_ShapeEnum.hxx> |
43 | #include <Graphic3d_Structure.hxx> |
44 | #include <Prs3d_LineAspect.hxx> |
45 | #include <Prs3d_PlaneAspect.hxx> |
46 | #include <Prs3d_PointAspect.hxx> |
47 | #include <Prs3d_Presentation.hxx> |
48 | #include <Aspect_TypeOfMarker.hxx> |
49 | #include <StdSelect_ShapeTypeFilter.hxx> |
50 | #include <AIS_Selection.hxx> |
51 | #include <V3d_Viewer.hxx> |
52 | #include <V3d_View.hxx> |
53 | #include <Visual3d_TransientManager.hxx> |
54 | #include <Visual3d_View.hxx> |
55 | |
56 | #ifdef ALE70590 |
57 | #include <stdio.h> |
58 | #else |
59 | #include <Standard_SStream.hxx> |
60 | #endif |
61 | |
62 | static TCollection_AsciiString AIS_Local_SelName(const Standard_Address address, |
63 | const Standard_Integer anIndex) |
64 | { |
65 | // TCollection_AsciiString SelName; |
66 | #ifdef ALE70590 |
67 | char string[100]; |
68 | sprintf(string,"%p_%d", address, anIndex); // works under any system |
69 | TCollection_AsciiString SelName(string); |
70 | #else |
71 | Standard_SStream stream; |
72 | stream<<address; // something is wrong here using the SStream because |
73 | // the following access to rdbuf crash for an unknown reason |
74 | // especially under W2000 with SP2 and sometime under WNT and W98. |
75 | // NOTE that stream is not ended by a NULL char and it's probably |
76 | // one of the reasons why this crash. |
77 | // In any case the resulting ascii string give a wrong and random |
78 | // name under WINDOWS ! |
79 | TCollection_AsciiString SelName(stream.rdbuf()->str()); |
80 | // SelName = TCollection_AsciiString("AIS_Local_"); |
81 | TCollection_AsciiString theind(anIndex); |
82 | SelName += "_"; |
83 | SelName += theind; |
84 | #endif |
85 | return SelName; |
86 | } |
87 | |
88 | |
89 | //======================================================================= |
90 | //function : AIS_LocalContext |
91 | //purpose : |
92 | //======================================================================= |
93 | |
94 | |
95 | AIS_LocalContext::AIS_LocalContext(){} |
96 | |
97 | AIS_LocalContext::AIS_LocalContext(const Handle(AIS_InteractiveContext)& aCtx, |
98 | const Standard_Integer Index, |
99 | const Standard_Boolean LoadDisplayed, |
100 | const Standard_Boolean AcceptStandardModes, |
101 | const Standard_Boolean AcceptEraseOfTemp, |
35e08fe8 |
102 | const Standard_Boolean /*BothViewers*/): |
7fd59977 |
103 | myCTX(aCtx), |
104 | myLoadDisplayed(LoadDisplayed), |
105 | myAcceptStdMode(AcceptStandardModes), |
106 | myAcceptErase(AcceptEraseOfTemp), |
107 | mySM(aCtx->SelectionManager()), |
108 | myMainVS(new StdSelect_ViewerSelector3d(aCtx->MainSelector()->Projector())), |
109 | myFilters(new SelectMgr_OrFilter()), |
110 | myAutoHilight(Standard_True), |
111 | mylastindex(0), |
112 | mylastgood(0), |
113 | myCurDetected(0) |
114 | #ifdef IMP160701 |
115 | ,myAISCurDetected(0) |
116 | #endif |
117 | { |
64e2d3bd |
118 | // bind self to AIS_InteractiveContext::myLocalContexts. Further, the |
119 | // constructor executes logic that implies that the context is already |
120 | // created and mapped. |
121 | aCtx->myLocalContexts.Bind (Index, this); |
122 | |
7fd59977 |
123 | myMainPM = aCtx->MainPrsMgr(); |
124 | mySelName = AIS_Local_SelName(this, Index); |
125 | AIS_Selection::CreateSelection(mySelName.ToCString()); |
126 | |
127 | mySM->Add(myMainVS); |
128 | if(myLoadDisplayed) LoadContextObjects(); |
129 | Process(Standard_False); |
130 | |
131 | } |
132 | |
133 | |
134 | //======================================================================= |
135 | //function : SetContext |
136 | //purpose : |
137 | //======================================================================= |
138 | |
139 | void AIS_LocalContext::SetContext(const Handle(AIS_InteractiveContext)& aCtx) |
140 | { myCTX = aCtx;} |
141 | |
142 | //======================================================================= |
143 | //function : Display |
144 | //purpose : |
145 | //======================================================================= |
146 | |
147 | Standard_Boolean AIS_LocalContext::Display(const Handle(AIS_InteractiveObject)& anInteractive, |
148 | const Standard_Integer WhichMode, |
149 | const Standard_Boolean AllowShapeDecomposition, |
150 | const Standard_Integer ActivationMode) |
151 | { |
152 | if(myActiveObjects.IsBound(anInteractive)){ |
153 | const Handle(AIS_LocalStatus)& STAT = myActiveObjects(anInteractive); |
154 | |
155 | if(STAT->DisplayMode() == -1){ |
156 | if(!myMainPM->IsDisplayed(anInteractive,WhichMode)) |
157 | myMainPM->Display(anInteractive,WhichMode); |
158 | if(STAT->IsTemporary()) |
159 | STAT->SetDisplayMode(WhichMode); |
160 | } |
161 | else if(STAT->DisplayMode()!=WhichMode && STAT->IsTemporary()){ |
162 | myMainPM->Erase(anInteractive,STAT->DisplayMode()); |
163 | STAT->SetDisplayMode(WhichMode); |
164 | if(!myMainPM->IsDisplayed(anInteractive,WhichMode)) |
165 | myMainPM->Display(anInteractive,WhichMode); |
166 | } |
167 | |
168 | if(ActivationMode!=-1){ |
169 | if(!STAT->IsActivated(ActivationMode)){ |
170 | STAT->ClearSelectionModes(); |
171 | mySM->Load(anInteractive,myMainVS); |
172 | STAT->AddSelectionMode(ActivationMode); |
173 | mySM->Activate(anInteractive,ActivationMode,myMainVS); |
174 | } |
175 | } |
176 | } |
177 | else { |
178 | Handle(AIS_LocalStatus) Att = new AIS_LocalStatus(); |
179 | |
180 | if(anInteractive->AcceptShapeDecomposition() && AllowShapeDecomposition) |
181 | Att->SetDecomposition(Standard_True); |
182 | else |
183 | Att->SetDecomposition(Standard_False); |
81bba717 |
184 | // status temporary or not |
7fd59977 |
185 | if(myCTX->DisplayStatus(anInteractive) == AIS_DS_None || |
186 | myCTX->DisplayStatus(anInteractive) == AIS_DS_Temporary) |
187 | Att->SetTemporary(Standard_True); |
188 | else |
189 | Att->SetTemporary(Standard_False); |
190 | |
191 | |
192 | |
193 | if(!myCTX->IsDisplayed(anInteractive,WhichMode)){ |
194 | |
195 | //storing information.... |
196 | Att->SetDisplayMode(WhichMode); |
197 | if (ActivationMode!=-1) |
198 | Att->AddSelectionMode(ActivationMode); |
199 | Standard_Integer HiMod = anInteractive->HasHilightMode()? anInteractive->HilightMode(): WhichMode; |
200 | Att->SetHilightMode(HiMod); |
201 | |
202 | if(!myMainPM->IsDisplayed(anInteractive,WhichMode)) |
203 | myMainPM->Display(anInteractive,WhichMode); |
204 | |
205 | if(ActivationMode!=-1){ |
206 | mySM->Load(anInteractive,myMainVS); |
207 | mySM->Activate(anInteractive,ActivationMode,myMainVS); |
208 | } |
209 | } |
210 | else{ |
211 | Standard_Integer HiMod = anInteractive->HasHilightMode()? anInteractive->HilightMode(): WhichMode; |
212 | Att->SetHilightMode(HiMod); |
213 | } |
214 | myActiveObjects.Bind(anInteractive,Att); |
215 | } |
216 | Process(anInteractive); |
217 | |
218 | |
219 | |
220 | |
221 | return Standard_True; |
222 | } |
223 | |
224 | //======================================================================= |
225 | //function : Load |
226 | //purpose : |
227 | //======================================================================= |
228 | |
229 | Standard_Boolean AIS_LocalContext:: |
230 | Load(const Handle(AIS_InteractiveObject)& anInteractive, |
231 | const Standard_Boolean AllowShapeDecomposition, |
232 | const Standard_Integer ActivationMode) |
233 | { |
234 | if(myActiveObjects.IsBound(anInteractive)) return Standard_False; |
235 | Handle(AIS_LocalStatus) Att = new AIS_LocalStatus(); |
236 | |
237 | if(anInteractive->AcceptShapeDecomposition() && AllowShapeDecomposition) |
238 | Att->SetDecomposition(Standard_True); |
239 | else |
240 | Att->SetDecomposition(Standard_False); |
241 | |
242 | if(!myCTX->IsDisplayed(anInteractive)) |
243 | Att->SetTemporary(Standard_True); |
244 | else |
245 | Att->SetTemporary(Standard_False); |
246 | Att->SetDisplayMode(-1); |
247 | |
248 | //storing information.... |
249 | if(ActivationMode!=-1) |
250 | Att->AddSelectionMode(ActivationMode); |
251 | Standard_Integer HiMod = anInteractive->HasHilightMode()? anInteractive->HilightMode():0; |
252 | Att->SetHilightMode(HiMod); |
253 | //Action |
254 | |
255 | mySM->Load(anInteractive,myMainVS); |
256 | if(ActivationMode != -1){ |
257 | mySM->Activate(anInteractive,ActivationMode,myMainVS); |
258 | } |
259 | myActiveObjects.Bind(anInteractive,Att); |
260 | Process(anInteractive); |
261 | return Standard_True; |
262 | } |
263 | |
264 | //======================================================================= |
265 | //function : ClearPrs |
266 | //purpose : |
267 | //======================================================================= |
268 | |
269 | Standard_Boolean AIS_LocalContext:: |
270 | ClearPrs(const Handle(AIS_InteractiveObject)& anInteractive, |
271 | const Standard_Integer aMode) |
272 | { |
273 | if(!myActiveObjects.IsBound(anInteractive)) |
274 | return Standard_False; |
275 | |
276 | Standard_Boolean jobdone(Standard_False); |
277 | const Handle(AIS_LocalStatus)& STAT = myActiveObjects(anInteractive); |
278 | |
279 | //Display step |
280 | if(STAT->IsSubIntensityOn()) { |
281 | STAT->SubIntensityOff(); |
282 | if(STAT->HilightMode()==aMode) |
283 | myMainPM->Unhighlight(anInteractive,STAT->HilightMode()); |
284 | } |
285 | myMainPM->Clear(anInteractive,aMode); // correction connexions 23/09/97 |
286 | jobdone = Standard_True; |
287 | if(STAT->DisplayMode()==aMode) |
288 | STAT->SetDisplayMode(-1); |
289 | return jobdone; |
290 | } |
291 | //======================================================================= |
292 | //function : Erase |
293 | //purpose : |
294 | //======================================================================= |
295 | |
296 | Standard_Boolean AIS_LocalContext:: |
297 | Erase(const Handle(AIS_InteractiveObject)& anInteractive) |
298 | { |
299 | if(!myActiveObjects.IsBound(anInteractive)) |
300 | return Standard_False; |
301 | const Handle(AIS_LocalStatus)& STAT = myActiveObjects(anInteractive); |
302 | |
303 | //Display step |
304 | if(STAT->IsSubIntensityOn()) { |
305 | STAT->SubIntensityOff(); |
306 | myMainPM->Unhighlight(anInteractive,STAT->HilightMode()); |
307 | } |
308 | |
309 | Standard_Boolean status(Standard_False); |
310 | |
311 | if(STAT->DisplayMode()!=-1) { |
312 | if(IsSelected(anInteractive)) |
313 | AddOrRemoveSelected(anInteractive); |
314 | if(myMainPM->IsHighlighted(anInteractive,STAT->HilightMode())) |
315 | myMainPM->Unhighlight(anInteractive,STAT->HilightMode()); |
eb4320f2 |
316 | myMainPM->SetVisibility (anInteractive, STAT->DisplayMode(), Standard_False); |
7fd59977 |
317 | STAT->SetDisplayMode(-1); |
318 | status = Standard_True; |
319 | } |
320 | if(STAT->IsTemporary()){ |
321 | if(myMainPM->IsDisplayed(anInteractive,STAT->HilightMode())) |
eb4320f2 |
322 | myMainPM->SetVisibility (anInteractive, STAT->HilightMode(), Standard_False); |
7fd59977 |
323 | } |
324 | //selection step |
325 | |
326 | TColStd_ListIteratorOfListOfInteger It(STAT->SelectionModes()); |
327 | for(;It.More();It.Next()) |
328 | mySM->Deactivate(anInteractive,It.Value(),myMainVS); |
329 | // STAT->ClearSelectionModes(); |
330 | return status; |
331 | } |
332 | |
333 | |
334 | //======================================================================= |
335 | //function : SetShapeDecomposition |
336 | //purpose : |
337 | //======================================================================= |
338 | |
339 | void AIS_LocalContext::SetShapeDecomposition(const Handle(AIS_InteractiveObject)& aStoredObject, |
340 | const Standard_Boolean aStatus) |
341 | { |
342 | if(!myActiveObjects.IsBound(aStoredObject)) return; |
343 | |
344 | if(aStatus == myActiveObjects(aStoredObject)->Decomposed()) |
345 | return; |
346 | |
347 | myActiveObjects(aStoredObject)->SetDecomposition(aStatus); |
348 | |
349 | Process(aStoredObject); |
350 | } |
351 | |
352 | //======================================================================= |
353 | //function : Clear |
354 | //purpose : |
355 | //======================================================================= |
356 | |
357 | void AIS_LocalContext::Clear(const AIS_ClearMode aType) |
358 | { |
359 | switch (aType){ |
360 | case AIS_CM_All: |
361 | { |
362 | ClearObjects(); |
363 | myFilters->Clear(); |
364 | while(!myListOfStandardMode.IsEmpty()) |
365 | DeactivateStandardMode(AIS_Shape::SelectionType(myListOfStandardMode.Last())); |
366 | break; |
367 | } |
368 | case AIS_CM_Interactive: |
369 | ClearObjects(); |
370 | break; |
371 | case AIS_CM_Filters: |
372 | myFilters->Clear(); |
373 | break; |
374 | case AIS_CM_StandardModes: |
375 | { |
376 | while(!myListOfStandardMode.IsEmpty()) |
377 | DeactivateStandardMode(AIS_Shape::SelectionType(myListOfStandardMode.Last())); |
378 | break; |
379 | } |
380 | case AIS_CM_TemporaryShapePrs: |
381 | ClearDetected(); |
382 | } |
383 | UpdateSort(); |
384 | } |
385 | //======================================================================= |
386 | //function : ActivateMode |
387 | //purpose : |
388 | //======================================================================= |
389 | |
390 | void AIS_LocalContext::ActivateMode(const Handle(AIS_InteractiveObject)& aSelectable, |
391 | const Standard_Integer aMode) |
392 | { |
393 | if(!myActiveObjects.IsBound(aSelectable)) return; |
394 | // if(myActiveObjects(aSelectable)->SelectionMode()!=aMode) |
395 | // mySM->Deactivate(aSelectable,aMode,myMainVS); |
396 | if(aMode != -1){ |
397 | myActiveObjects(aSelectable)->AddSelectionMode(aMode); |
398 | mySM->Activate(aSelectable,aMode,myMainVS); |
399 | } |
400 | UpdateSort(); |
401 | } |
402 | //======================================================================= |
403 | //function : ActivateMode |
404 | //purpose : |
405 | //======================================================================= |
406 | |
407 | void AIS_LocalContext::DeactivateMode(const Handle(AIS_InteractiveObject)& aSelectable, |
408 | const Standard_Integer aMode) |
409 | { |
410 | if(!myActiveObjects.IsBound(aSelectable)) return; |
411 | |
412 | if(aMode==-1) return; |
413 | |
414 | myActiveObjects(aSelectable)->RemoveSelectionMode(aMode); |
415 | mySM->Deactivate(aSelectable,aMode,myMainVS); |
416 | UpdateSort(); |
417 | |
418 | } |
419 | //======================================================================= |
420 | //function : ActivateMode |
421 | //purpose : |
422 | //======================================================================= |
423 | |
424 | void AIS_LocalContext::Deactivate(const Handle(AIS_InteractiveObject)& aSelectable) |
425 | { |
426 | if(!myActiveObjects.IsBound(aSelectable)) return; |
427 | |
428 | mySM->Deactivate(aSelectable,myMainVS); |
429 | myActiveObjects(aSelectable)->ClearSelectionModes(); |
430 | UpdateSort(); |
431 | } |
432 | |
433 | //======================================================================= |
434 | //function : Remove |
435 | //purpose : |
436 | //======================================================================= |
437 | |
438 | Standard_Boolean AIS_LocalContext::Remove(const Handle(AIS_InteractiveObject)& aSelectable) |
439 | { |
440 | if(!myActiveObjects.IsBound(aSelectable)) return Standard_False; |
441 | |
442 | if(IsSelected(aSelectable)) |
443 | AddOrRemoveSelected(aSelectable,Standard_False); |
444 | |
445 | const Handle(AIS_LocalStatus)& Att = myActiveObjects(aSelectable); |
446 | |
447 | TColStd_ListIteratorOfListOfInteger It; |
81bba717 |
448 | // it is checked which were the temporary attributes |
449 | // and they are set to 0 |
7fd59977 |
450 | |
81bba717 |
451 | // desactivate standard modes |
7fd59977 |
452 | if(Att->Decomposed()){ |
453 | for(It.Initialize(myListOfStandardMode);It.More();It.Next()){ |
454 | mySM->Deactivate(aSelectable,It.Value(),myMainVS); |
455 | } |
456 | } |
457 | |
81bba717 |
458 | // if object or temporary presentations... |
7fd59977 |
459 | if(Att->IsTemporary()) |
460 | { |
461 | if(Att->IsSubIntensityOn()) |
462 | myMainPM->Unhighlight(aSelectable,Att->HilightMode()); |
463 | |
81bba717 |
464 | // remove if bug on clear correct... |
7fd59977 |
465 | myMainPM->Erase(aSelectable,Att->DisplayMode()); |
466 | myMainPM->Clear(aSelectable,Att->DisplayMode()); |
467 | if(myMainPM->IsDisplayed(aSelectable,Att->HilightMode())) |
468 | myMainPM->Erase(aSelectable,Att->HilightMode()); |
469 | // myMainPM->Clear(aSelectable,Att->HilightMode()); |
7fd59977 |
470 | } |
81bba717 |
471 | // if below intensity |
7fd59977 |
472 | else |
473 | { |
474 | if(Att->IsSubIntensityOn()) |
475 | myCTX->SubIntensityOff(aSelectable); |
476 | } |
81bba717 |
477 | // desactivate stored proper modes |
7fd59977 |
478 | for(It.Initialize(Att->SelectionModes());It.More();It.Next()){ |
479 | mySM->Deactivate(aSelectable,It.Value(),myMainVS); |
480 | } |
ab943560 |
481 | // pop : si je laisses cela plantes dans les elements de construction |
482 | // alors a toi de jouer ROB |
7fd59977 |
483 | // RemoveSelected(aSelectable); |
484 | |
485 | if(IsSelected(aSelectable)) |
486 | AddOrRemoveSelected(aSelectable); |
487 | myActiveObjects.UnBind(aSelectable); |
488 | |
489 | //Last detected object keeps for lastindex initialization. |
490 | Handle(SelectMgr_EntityOwner) aLastPicked = myMainVS->OnePicked(); |
491 | |
492 | UpdateSort(); |
493 | |
494 | //Object removes from SelectMgr |
495 | if( mySM->Contains(aSelectable) ) |
496 | mySM->Remove(aSelectable); |
497 | |
498 | //Object removes from Detected sequence |
499 | AIS_SequenceOfInteractive detectAIS; |
500 | |
501 | Standard_Integer i = 1; |
502 | for(i = 1 ; i < myAISDetectedSeq.Length(); i++) |
503 | { |
504 | Handle(AIS_InteractiveObject) anObj = DetectedCurrentObject(); |
505 | if( !anObj.IsNull() && anObj != aSelectable ) |
506 | myAISDetectedSeq.Remove( i ); |
507 | } |
508 | |
509 | Standard_Integer aHM = aSelectable->HasHilightMode() ? aSelectable->HilightMode() : 0; |
510 | |
511 | //EntityOwners remove from AIS_Selection |
512 | Handle(AIS_Selection) aSel = AIS_Selection::Selection(mySelName.ToCString()); |
513 | AIS_NListTransient::Iterator anIter(aSel->Objects()); |
514 | AIS_NListTransient removeEntites; |
515 | for(; anIter.More(); anIter.Next()){ |
516 | const Handle(Standard_Transient)& Tr = anIter.Value(); |
517 | if (!Tr.IsNull()){ |
518 | const Handle(SelectMgr_EntityOwner)& anOwnr = *((const Handle(SelectMgr_EntityOwner)*) &Tr); |
519 | if(anOwnr->Selectable() == aSelectable){ |
520 | removeEntites.Append(Tr); |
521 | if(IsSelected(anOwnr)) |
522 | anOwnr->Unhilight(myMainPM, aHM);//Unhilight selected |
523 | } |
524 | } |
525 | } |
526 | AIS_NListTransient::Iterator anIterRemove(removeEntites); |
527 | for(; anIterRemove.More(); anIterRemove.Next()) |
528 | aSel->Select(anIterRemove.Value());//EntityOwner removes from the selection data |
529 | |
530 | //EntityOwners remove from myMapOfOwner |
531 | SelectMgr_IndexedMapOfOwner ownersToKeep; |
532 | const Handle(V3d_Viewer)& aViewer = myCTX->CurrentViewer(); |
533 | for(i = 1; i <= myMapOfOwner.Extent(); i++){ |
534 | const Handle(SelectMgr_EntityOwner)& anOwner = myMapOfOwner(i) ; |
eafb234b |
535 | if(!anOwner.IsNull()) { |
7fd59977 |
536 | if(anOwner->Selectable() != aSelectable) |
537 | ownersToKeep.Add(anOwner); |
538 | else |
539 | { |
540 | if(anOwner->IsHilighted(myMainPM, aHM)) |
541 | { |
542 | for(aViewer->InitActiveViews(); aViewer->MoreActiveViews(); aViewer->NextActiveViews()) |
543 | Unhilight(anOwner, aViewer->ActiveView()); |
544 | } |
545 | } |
eafb234b |
546 | } |
7fd59977 |
547 | } |
548 | myMapOfOwner.Clear(); |
549 | myMapOfOwner.Assign(ownersToKeep); |
550 | mylastindex = myMapOfOwner.FindIndex(aLastPicked); |
551 | |
552 | return Standard_True; |
553 | } |
554 | |
555 | //======================================================================= |
556 | //function : ActivateStandardMode |
557 | //purpose : |
558 | //======================================================================= |
559 | |
560 | void AIS_LocalContext::ActivateStandardMode(const TopAbs_ShapeEnum aType) |
561 | { |
562 | |
81bba717 |
563 | //check if it is not in the list |
7fd59977 |
564 | TColStd_ListIteratorOfListOfInteger It(myListOfStandardMode); |
565 | for(;It.More();It.Next()) |
566 | if(It.Value()==aType) return; |
567 | Standard_Integer IMode = AIS_Shape::SelectionMode(aType); |
568 | |
569 | |
81bba717 |
570 | // create a hidden filter answering ok to the type except for : |
571 | // if the type is shape... |
572 | // if the filters already impact at the type <aType> |
7fd59977 |
573 | if(aType != TopAbs_SHAPE){ |
574 | if(myStdFilters[IMode].IsNull()) |
575 | myStdFilters[IMode] = new StdSelect_ShapeTypeFilter(aType); |
576 | if(!HasFilters(aType)) |
577 | myFilters->Add(myStdFilters[IMode]); |
578 | } |
579 | |
81bba717 |
580 | // the mode is activated for all objects of type Shape |
581 | // accepting the decomposition in standard mode. |
7fd59977 |
582 | myListOfStandardMode.Append(IMode); |
583 | |
584 | AIS_DataMapIteratorOfDataMapOfSelStat ItM(myActiveObjects); |
585 | |
586 | for(;ItM.More();ItM.Next()){ |
7fd59977 |
587 | if(ItM.Value()->Decomposed()) |
7fd59977 |
588 | myCTX->SelectionManager()->Activate(ItM.Key(), |
589 | IMode, |
590 | myMainVS); |
591 | } |
592 | |
593 | } |
594 | |
595 | //======================================================================= |
596 | //function : DeActivateStandardMode |
597 | //purpose : |
598 | //======================================================================= |
599 | |
600 | void AIS_LocalContext::DeactivateStandardMode(const TopAbs_ShapeEnum aType) |
601 | { |
602 | TColStd_ListIteratorOfListOfInteger It(myListOfStandardMode); |
603 | Standard_Integer IMode = AIS_Shape::SelectionMode(aType); |
604 | for(;It.More();It.Next()) |
605 | if(It.Value()==IMode) { |
606 | AIS_DataMapIteratorOfDataMapOfSelStat ItM(myActiveObjects); |
607 | |
608 | for(;ItM.More();ItM.Next()){ |
609 | if(ItM.Value()->Decomposed()){ |
610 | myCTX->SelectionManager()->Deactivate(ItM.Key(), |
611 | IMode, |
612 | myMainVS); |
613 | ItM.Value()->RemoveSelectionMode(IMode); |
614 | } |
615 | } |
616 | myListOfStandardMode.Remove(It); |
617 | if(myFilters->IsIn(myStdFilters[IMode])) |
618 | myFilters->Remove(myStdFilters[IMode]); |
619 | UpdateSort(); |
620 | return; |
621 | } |
622 | UpdateSort(); |
623 | } |
624 | |
625 | //======================================================================= |
626 | //function : AddFilter |
627 | //purpose : |
628 | //======================================================================= |
629 | |
630 | void AIS_LocalContext::AddFilter(const Handle(SelectMgr_Filter)& aFilter) |
631 | { |
81bba717 |
632 | // it is checked if the filter impacts at the type of active sub-shape |
633 | // for which a filter of type has been already implemented... |
7fd59977 |
634 | |
635 | TColStd_ListIteratorOfListOfInteger It(myListOfStandardMode); |
636 | |
637 | for(;It.More();It.Next()){ |
638 | if(aFilter->ActsOn(AIS_Shape::SelectionType(It.Value()))) |
639 | if(myFilters->IsIn(myStdFilters[It.Value()])) |
640 | myFilters->Remove(myStdFilters[It.Value()]); |
641 | } |
642 | myFilters->Add(aFilter); |
643 | } |
644 | |
645 | //======================================================================= |
646 | //function : RemoveFilter |
647 | //purpose : |
648 | //======================================================================= |
649 | |
650 | void AIS_LocalContext::RemoveFilter(const Handle(SelectMgr_Filter)& aFilter) |
651 | { |
652 | if(myFilters->IsIn(aFilter)) myFilters->Remove(aFilter); |
653 | |
81bba717 |
654 | // it is checked if the filter for type standard is active. |
655 | // if yes, it is checked there are still similarities among the |
656 | // remaining filters... |
657 | // otherwise, the standard filter is restored to |
658 | // continu selecting active modes... |
7fd59977 |
659 | TColStd_ListIteratorOfListOfInteger It(myListOfStandardMode); |
660 | TopAbs_ShapeEnum SE; |
661 | for(;It.More();It.Next()){ |
662 | SE = AIS_Shape::SelectionType(It.Value()); |
663 | if(aFilter->ActsOn(SE)) |
664 | if(!HasFilters(SE)) |
665 | myFilters->Add(myStdFilters[It.Value()]); |
666 | } |
667 | } |
668 | |
669 | |
670 | |
ab943560 |
671 | Standard_Boolean AIS_LocalContext::HasSameProjector(const Handle(Select3D_Projector)& thePrj) const |
7fd59977 |
672 | { |
ab943560 |
673 | const Handle(Select3D_Projector)& aCurPrj = myMainVS->Projector(); |
674 | if (aCurPrj->Perspective() != thePrj->Perspective()) |
675 | return Standard_False; |
676 | if (aCurPrj->Perspective() && aCurPrj->Focus() != thePrj->Focus()) |
677 | return Standard_False; |
678 | const gp_GTrsf& aCurTrsf = aCurPrj->Transformation(); |
679 | const gp_GTrsf& aPrjTrsf = thePrj->Transformation(); |
680 | |
681 | for (Standard_Integer i = 1; i <= 3; ++i) |
682 | { |
683 | for (Standard_Integer j = 1; j <= 3 ; ++j) |
684 | { |
685 | if (aCurTrsf.Value (i, j) != aPrjTrsf.Value (i, j)) |
686 | return Standard_False; |
7fd59977 |
687 | } |
688 | } |
ab943560 |
689 | |
7fd59977 |
690 | return Standard_True; |
691 | } |
692 | |
693 | |
694 | //======================================================================= |
695 | //function : Terminate |
696 | //purpose : |
697 | //======================================================================= |
698 | |
699 | void AIS_LocalContext::Terminate( const Standard_Boolean updateviewer ) |
700 | { |
701 | ClearDetected(); |
702 | Clear(); |
703 | myMapOfOwner.Clear(); |
704 | |
705 | mylastindex=0; |
81bba717 |
706 | // clear the selector... |
7fd59977 |
707 | myMainVS->Clear(); |
708 | myCTX->SelectionManager()->Remove(myMainVS); |
709 | |
710 | |
711 | AIS_Selection::SetCurrentSelection(mySelName.ToCString()); |
712 | Handle(AIS_Selection) S = AIS_Selection::CurrentSelection(); |
713 | Handle(Standard_Transient) Tr; |
714 | for(S->Init();S->More();S->Next()){ |
715 | Tr = S->Value(); |
716 | (*((Handle(SelectMgr_EntityOwner)*)&Tr))->State(0); |
717 | } |
718 | |
719 | |
720 | AIS_Selection::Select(); |
721 | AIS_Selection::Remove(mySelName.ToCString()); |
722 | |
723 | // CLE |
724 | // const Handle(V3d_Viewer)& Vwr = myCTX->CurrentViewer(); |
725 | Handle(V3d_Viewer) Vwr = myCTX->CurrentViewer(); |
726 | // ENDCLE |
727 | Handle(V3d_View) curV; |
728 | for(Vwr->InitActiveViews();Vwr->MoreActiveViews();Vwr->NextActiveViews()){ |
729 | curV = Vwr->ActiveView(); |
730 | Visual3d_TransientManager::ClearDraw( curV->View(), updateviewer ); |
731 | } |
732 | |
733 | |
734 | #ifdef DEB |
735 | Handle(V3d_View) BidV; |
736 | myMainVS->ClearAreas(BidV); |
737 | myMainVS->ClearSensitive(BidV); |
738 | |
739 | #endif |
740 | } |
741 | |
742 | |
743 | //======================================================================= |
744 | //function : SubIntensity |
745 | //purpose : |
746 | //======================================================================= |
747 | |
748 | void AIS_LocalContext::SubIntensityOn(const Handle(AIS_InteractiveObject)& anObject) |
749 | { |
750 | if(!myActiveObjects.IsBound(anObject)) return; |
751 | |
752 | const Handle(AIS_LocalStatus)& Att = myActiveObjects(anObject); |
753 | |
754 | if(Att->IsTemporary()) |
755 | myMainPM->Color(anObject,myCTX->SubIntensityColor(),Att->DisplayMode()); |
756 | |
757 | Att->SubIntensityOn(); |
758 | } |
759 | //======================================================================= |
760 | //function : SubIntensity |
761 | //purpose : |
762 | //======================================================================= |
763 | |
764 | void AIS_LocalContext::SubIntensityOff(const Handle(AIS_InteractiveObject)& anObject) |
765 | { |
766 | if(!myActiveObjects.IsBound(anObject)) return; |
767 | |
768 | const Handle(AIS_LocalStatus)& Att = myActiveObjects(anObject); |
769 | |
770 | if(Att->IsTemporary()) |
771 | myMainPM->Unhighlight(anObject); |
772 | Att->SubIntensityOff(); |
773 | } |
774 | |
775 | |
776 | //======================================================================= |
777 | //function : Hilight |
778 | //purpose : |
779 | //======================================================================= |
780 | |
781 | void AIS_LocalContext::Hilight(const Handle(AIS_InteractiveObject)& anObject) |
782 | { |
783 | if(!myActiveObjects.IsBound(anObject)){ |
784 | Standard_Integer HiMod = anObject->HasHilightMode()? anObject->HilightMode() : 0; |
785 | Handle(AIS_LocalStatus) Att = new AIS_LocalStatus(Standard_True, |
786 | Standard_False, |
787 | -1,-1,HiMod); |
788 | myActiveObjects.Bind(anObject,Att); |
789 | |
790 | } |
791 | const Handle(AIS_LocalStatus)& Att = myActiveObjects(anObject); |
792 | myMainPM->Color(anObject,myCTX->HilightColor(),Att->HilightMode()); |
793 | Att->SubIntensityOn(); |
794 | } |
795 | //======================================================================= |
796 | //function : Hilight |
797 | //purpose : |
798 | //======================================================================= |
799 | |
800 | void AIS_LocalContext::Hilight(const Handle(AIS_InteractiveObject)& anObject, |
801 | const Quantity_NameOfColor Col) |
802 | { |
803 | if(!myActiveObjects.IsBound(anObject)){ |
804 | Standard_Integer HiMod = anObject->HasHilightMode()? anObject->HilightMode() : 0; |
805 | Handle(AIS_LocalStatus) Att = new AIS_LocalStatus(Standard_True, |
806 | Standard_False, |
807 | -1,-1,HiMod); |
808 | myActiveObjects.Bind(anObject,Att); |
809 | |
810 | } |
811 | const Handle(AIS_LocalStatus)& Att = myActiveObjects(anObject); |
812 | myMainPM->Color(anObject,Col,Att->HilightMode()); |
813 | Att->SubIntensityOn(); |
814 | Att->SetHilightColor(Col); |
815 | } |
816 | |
817 | //======================================================================= |
818 | //function : Unhilight |
819 | //purpose : |
820 | //======================================================================= |
821 | |
822 | void AIS_LocalContext::Unhilight(const Handle(AIS_InteractiveObject)& anObject) |
823 | { |
824 | if(!myActiveObjects.IsBound(anObject)) return; |
825 | |
81bba717 |
826 | // chieck if by hazard the object is somewhere else... |
7fd59977 |
827 | Standard_Integer Indx; |
828 | Standard_Boolean IsSomeWhereElse = |
829 | myCTX->IsInLocal(anObject,Indx) && Indx != myCTX->IndexOfCurrentLocal(); |
830 | |
831 | const Handle(AIS_LocalStatus)& Att = myActiveObjects(anObject); |
832 | myMainPM->Unhighlight(anObject,Att->HilightMode()); |
833 | if(Att->IsTemporary() && Att->DisplayMode()==-1) |
834 | if(!IsSomeWhereElse) |
eb4320f2 |
835 | myMainPM->SetVisibility (anObject, Att->HilightMode(), Standard_False); |
836 | |
7fd59977 |
837 | Att->SubIntensityOff(); |
838 | Att->SetHilightColor(Quantity_NOC_WHITE); |
839 | } |
840 | |
841 | |
842 | //======================================================================= |
843 | //function : IsIn |
844 | //purpose : |
845 | //======================================================================= |
846 | |
847 | Standard_Boolean AIS_LocalContext:: |
848 | IsIn(const Handle(AIS_InteractiveObject)& anObject) const |
849 | { |
850 | return myActiveObjects.IsBound(anObject); |
851 | } |
852 | |
853 | //======================================================================= |
854 | //function : IsHilighted |
855 | //purpose : |
856 | //======================================================================= |
857 | |
858 | Standard_Boolean AIS_LocalContext::IsHilighted(const Handle(AIS_InteractiveObject)& anObject) const |
859 | { |
860 | if(!myActiveObjects.IsBound(anObject)) return Standard_False; |
861 | return myActiveObjects(anObject)->IsSubIntensityOn(); |
862 | } |
863 | |
864 | Standard_Boolean AIS_LocalContext::IsHilighted(const Handle(AIS_InteractiveObject)& anObject, |
865 | Standard_Boolean& WithColor, |
866 | Quantity_NameOfColor& HiCol) const |
867 | { |
868 | if(!myActiveObjects.IsBound(anObject)) return Standard_False; |
869 | if( myActiveObjects(anObject)->IsSubIntensityOn()){ |
870 | HiCol = myActiveObjects(anObject)->HilightColor(); |
871 | if(HiCol==Quantity_NOC_WHITE) |
872 | WithColor = Standard_True; |
873 | else |
874 | WithColor = Standard_False; |
875 | return Standard_True; |
876 | } |
877 | return Standard_False; |
878 | } |
879 | |
880 | |
881 | void AIS_LocalContext::SetDisplayPriority(const Handle(AIS_InteractiveObject)& anObject, |
882 | const Standard_Integer Prior) |
883 | { |
884 | if(!myActiveObjects.IsBound(anObject)) return; |
885 | const Handle(AIS_LocalStatus)& STAT = myActiveObjects(anObject); |
886 | if(STAT->DisplayMode()==-1) return; |
887 | myMainPM->SetDisplayPriority(anObject,STAT->DisplayMode(),Prior); |
888 | if(STAT->IsSubIntensityOn()) |
889 | myMainPM->SetDisplayPriority(anObject,STAT->HilightMode(),Prior); |
890 | |
891 | |
892 | } |
893 | |
7fd59977 |
894 | //======================================================================= |
895 | //function : DisplayedObjects |
896 | //purpose : |
897 | //======================================================================= |
898 | Standard_Integer AIS_LocalContext::DisplayedObjects(TColStd_MapOfTransient& theMap) const |
899 | { |
900 | Standard_Integer NbDisp(0); |
901 | for(AIS_DataMapIteratorOfDataMapOfSelStat it(myActiveObjects);it.More();it.Next()){ |
902 | const Handle(SelectMgr_SelectableObject)& SO = it.Key(); |
903 | if(!theMap.Contains(SO)) |
904 | if(it.Value()->DisplayMode()!=-1){ |
905 | theMap.Add(SO); |
906 | NbDisp++; |
907 | } |
908 | } |
909 | return NbDisp; |
910 | } |
911 | |
912 | |
913 | //======================================================================= |
914 | //function : IsDisplayed |
915 | //purpose : |
916 | //======================================================================= |
917 | |
918 | Standard_Boolean AIS_LocalContext::IsDisplayed(const Handle(AIS_InteractiveObject)& anObject) const |
919 | { |
920 | if(!myActiveObjects.IsBound(anObject)) return Standard_False; |
921 | return (myActiveObjects(anObject)->DisplayMode()!=-1); |
922 | } |
923 | |
924 | //======================================================================= |
925 | //function : IsDisplayed |
926 | //purpose : |
927 | //======================================================================= |
928 | |
929 | Standard_Boolean AIS_LocalContext::IsDisplayed(const Handle(AIS_InteractiveObject)& anObject, |
930 | const Standard_Integer aMode) const |
931 | { |
932 | if(!myActiveObjects.IsBound(anObject)) return Standard_False; |
933 | return (myActiveObjects(anObject)->DisplayMode()==aMode); |
934 | } |
935 | |
936 | //======================================================================= |
937 | //function : SelectionModes |
938 | //purpose : |
939 | //======================================================================= |
940 | |
941 | const TColStd_ListOfInteger& AIS_LocalContext:: |
942 | SelectionModes(const Handle(AIS_InteractiveObject)& anObject) const |
943 | { |
944 | return myActiveObjects(anObject)->SelectionModes(); |
945 | } |
946 | |
947 | //======================================================================= |
948 | //function : Status |
949 | //purpose : |
950 | //======================================================================= |
951 | |
952 | TCollection_AsciiString AIS_LocalContext::Status() const |
953 | { |
954 | TCollection_AsciiString t; |
955 | return t; |
956 | } |
957 | |
958 | const Handle(AIS_LocalStatus)& AIS_LocalContext::Status(const Handle(AIS_InteractiveObject)& anObject) const |
959 | { |
960 | return myActiveObjects(anObject); |
961 | } |
962 | |
963 | //======================================================================= |
964 | //function : LoadContextObjects |
965 | //purpose : |
966 | //======================================================================= |
967 | |
968 | void AIS_LocalContext::LoadContextObjects() |
969 | { |
970 | AIS_ListIteratorOfListOfInteractive It; |
971 | if(myLoadDisplayed) { |
972 | AIS_ListOfInteractive LL; |
973 | myCTX->DisplayedObjects(LL,Standard_True); |
974 | Handle(AIS_LocalStatus) Att; |
975 | for (It.Initialize(LL);It.More();It.Next()){ |
976 | Att= new AIS_LocalStatus(); |
977 | Att->SetDecomposition((It.Value()->AcceptShapeDecomposition() && myAcceptStdMode)); |
978 | Att->SetTemporary(Standard_False); |
979 | Att->SetHilightMode(It.Value()->HasHilightMode()? It.Value()->HilightMode(): 0); |
980 | |
981 | myActiveObjects.Bind(It.Value(),Att); |
982 | } |
983 | } |
984 | } |
985 | |
986 | void AIS_LocalContext::UnloadContextObjects() |
987 | { |
988 | AIS_ListIteratorOfListOfInteractive It; |
989 | if(myLoadDisplayed) |
990 | { |
991 | AIS_ListOfInteractive LL; |
992 | myCTX->DisplayedObjects(LL,Standard_True); |
993 | |
994 | for (It.Initialize(LL);It.More();It.Next()) |
995 | { |
996 | myActiveObjects.UnBind(It.Value()); |
997 | } |
998 | } |
999 | } |
1000 | //======================================================================= |
1001 | //function : Process |
1002 | //purpose : |
1003 | //======================================================================= |
1004 | |
1005 | void AIS_LocalContext::Process(const Handle(SelectMgr_SelectableObject)& anObject, |
1006 | const Standard_Boolean WithProj) |
1007 | { |
1008 | if(!myActiveObjects.IsBound(anObject)) return; |
1009 | if(myActiveObjects(anObject)->Decomposed()) |
1010 | ActivateStandardModes(anObject,WithProj); |
1011 | else |
1012 | { |
1013 | TColStd_ListIteratorOfListOfInteger It(myActiveObjects(anObject)->SelectionModes()); |
1014 | for(;It.More();It.Next()) |
1015 | myCTX->SelectionManager()->Activate(anObject,It.Value(),myMainVS,WithProj); |
1016 | } |
1017 | } |
1018 | |
1019 | //======================================================================= |
1020 | //function : Process |
1021 | //purpose : |
1022 | //======================================================================= |
1023 | |
1024 | void AIS_LocalContext::Process(const Standard_Boolean WithProj) |
1025 | { |
1026 | |
1027 | myMainVS->Clear(); |
1028 | |
1029 | AIS_DataMapIteratorOfDataMapOfSelStat It(myActiveObjects); |
1030 | |
1031 | for(;It.More();It.Next()){ |
1032 | myCTX->SelectionManager()->Load(It.Key(),myMainVS); |
1033 | if(It.Value()->Decomposed()) |
1034 | ActivateStandardModes(It.Key(),WithProj); |
1035 | else if( myCTX->GetAutoActivateSelection() ) |
1036 | { |
1037 | It.Value()->AddSelectionMode(0); |
1038 | myCTX->SelectionManager()->Activate(It.Key(),0,myMainVS,WithProj); |
1039 | } |
1040 | } |
1041 | |
1042 | } |
1043 | |
1044 | //======================================================================= |
1045 | //function : ActivateModes |
1046 | //purpose : |
1047 | //======================================================================= |
1048 | |
1049 | void AIS_LocalContext::ActivateStandardModes(const Handle(SelectMgr_SelectableObject)& anObject, |
1050 | const Standard_Boolean WithProj) |
1051 | { |
1052 | if(!myActiveObjects.IsBound(anObject)) return; |
1053 | |
1054 | TColStd_ListIteratorOfListOfInteger itl (myListOfStandardMode); |
1055 | |
1056 | const Handle(AIS_LocalStatus)& LS = myActiveObjects(anObject); |
1057 | if(LS->Decomposed()){ |
1058 | for(;itl.More();itl.Next()){ |
1059 | myCTX->SelectionManager()->Activate(anObject,itl.Value(),myMainVS,WithProj); |
1060 | LS->AddSelectionMode(itl.Value()); |
1061 | } |
1062 | } |
1063 | } |
1064 | |
1065 | |
1066 | //======================================================================= |
1067 | //function : ClearObjects |
1068 | //purpose : |
1069 | //======================================================================= |
1070 | |
1071 | void AIS_LocalContext::ClearObjects() |
1072 | { |
1073 | AIS_DataMapIteratorOfDataMapOfSelStat It(myActiveObjects); |
1074 | for(;It.More();It.Next()) |
1075 | { |
1076 | Handle(AIS_InteractiveObject) SO = |
1077 | Handle(AIS_InteractiveObject)::DownCast(It.Key()); |
1078 | |
1079 | const Handle(AIS_LocalStatus)& CurAtt = It.Value(); |
1080 | //TColStd_ListIteratorOfListOfInteger ItL; |
81bba717 |
1081 | // if object is temporary the presentations managed by myMainPM are removed |
7fd59977 |
1082 | AIS_DisplayStatus TheDS = myCTX->DisplayStatus(SO); |
1083 | |
1084 | if(TheDS != AIS_DS_Displayed){ |
1085 | if(myMainPM->IsDisplayed(SO,CurAtt->DisplayMode())){ |
1086 | if(CurAtt->IsSubIntensityOn()&& |
1087 | myMainPM->IsHighlighted(SO,CurAtt->HilightMode())) |
1088 | myMainPM->Unhighlight(SO,CurAtt->HilightMode()); |
1089 | myMainPM->Erase(SO,CurAtt->DisplayMode()); |
1090 | } |
1091 | |
1092 | if(CurAtt->IsTemporary()){ |
1093 | myMainPM->Erase(SO,CurAtt->DisplayMode());} |
1094 | // myMainPM->Clear(SO,CurAtt->DisplayMode());} |
1095 | } |
1096 | else { |
1097 | if (CurAtt->IsSubIntensityOn()){ |
1098 | myCTX->SubIntensityOff(Handle(AIS_InteractiveObject)::DownCast(SO));} |
1099 | Standard_Integer DiMo = SO->HasDisplayMode()? |
1100 | SO->DisplayMode():myCTX->DisplayMode(); |
1101 | if(CurAtt->DisplayMode()!=-1 && |
1102 | CurAtt->DisplayMode()!= DiMo) |
1103 | myMainPM->Erase(SO,CurAtt->DisplayMode()); |
1104 | } |
1105 | |
1106 | TColStd_ListIteratorOfListOfInteger ITL(CurAtt->SelectionModes()); |
1107 | for(;ITL.More();ITL.Next()) |
1108 | mySM->Deactivate(SO,ITL.Value(),myMainVS); |
1109 | |
1110 | if(CurAtt->IsTemporary()) |
1111 | mySM->Remove(SO,myMainVS); |
1112 | |
1113 | } |
1114 | ClearSelected( Standard_False ); |
1115 | myActiveObjects.Clear(); |
1116 | // myMainVS->ClearAreas();myMainVS->ClearSensitive(); |
1117 | } |
1118 | |
1119 | |
1120 | Standard_Boolean AIS_LocalContext::IsDecompositionOn() const |
1121 | {return !myListOfStandardMode.IsEmpty();} |
1122 | |
1123 | |
1124 | |
1125 | |
1126 | //======================================================================= |
1127 | //function : HasAlreadyFilters |
1128 | //purpose : |
1129 | //======================================================================= |
1130 | |
1131 | Standard_Boolean AIS_LocalContext:: |
1132 | HasFilters(const TopAbs_ShapeEnum aType) const |
1133 | { |
1134 | return myFilters->ActsOn(aType); |
1135 | } |
1136 | |
1137 | void AIS_LocalContext::ClearDetected() |
1138 | { |
eb4320f2 |
1139 | for(Standard_Integer I=1;I<=myMapOfOwner.Extent();I++) |
1140 | { |
1141 | if(!myMapOfOwner(I).IsNull()) |
1142 | { |
7fd59977 |
1143 | if(myMapOfOwner(I)->IsHilighted(myMainPM)) |
eb4320f2 |
1144 | myMapOfOwner(I)->Unhilight(myMainPM); |
1145 | else |
1146 | { |
1147 | const Handle(SelectMgr_SelectableObject)& SO = |
1148 | myMapOfOwner.FindKey(I)->Selectable(); |
1149 | if(myActiveObjects.IsBound(SO)) |
1150 | { |
1151 | const Handle(AIS_LocalStatus)& Att = myActiveObjects(SO); |
1152 | |
1153 | if(Att->IsTemporary() && |
1154 | Att->DisplayMode()==-1 && |
1155 | Att->SelectionModes().IsEmpty()) |
1156 | { |
1157 | myMapOfOwner(I)->Clear(myMainPM); |
1158 | } |
1159 | } |
7fd59977 |
1160 | } |
1161 | } |
1162 | } |
7fd59977 |
1163 | } |
1164 | |
1165 | void AIS_LocalContext::UpdateConversion() |
1166 | { |
1167 | myMainVS->UpdateConversion(); |
1168 | } |
1169 | |
1170 | void AIS_LocalContext::UpdateSort() |
1171 | { |
1172 | myMainVS->UpdateSort(); |
1173 | } |
1174 | |
1175 | |
1176 | |
1177 | //======================================================================= |
1178 | //function : IMMEDIATE MODE |
1179 | //purpose : |
1180 | //======================================================================= |
1181 | |
1182 | Standard_Boolean AIS_LocalContext::BeginImmediateDraw() |
1183 | { |
1184 | if(myMainPM->IsImmediateModeOn()){ |
1185 | myMainPM->BeginDraw(); |
1186 | return Standard_True; |
1187 | } |
1188 | return Standard_False; |
1189 | } |
1190 | |
1191 | |
1192 | Standard_Boolean AIS_LocalContext::ImmediateAdd(const Handle(AIS_InteractiveObject)& anIObj, |
1193 | const Standard_Integer aMode) |
1194 | { |
1195 | if(!myMainPM->IsImmediateModeOn()) |
1196 | return Standard_False; |
1197 | myMainPM->Add(anIObj,aMode); |
1198 | return Standard_True; |
1199 | } |
1200 | |
1201 | Standard_Boolean AIS_LocalContext::ImmediateRemove(const Handle(AIS_InteractiveObject)& anIObj, |
1202 | const Standard_Integer aMode) |
1203 | { |
1204 | if(!myMainPM->IsImmediateModeOn()) return Standard_False; |
1205 | myMainPM->Remove(anIObj,aMode); |
1206 | return Standard_True; |
1207 | } |
1208 | |
1209 | Standard_Boolean AIS_LocalContext::EndImmediateDraw(const Handle(V3d_View)& aView, |
1210 | const Standard_Boolean DoubleBuf) |
1211 | { |
1212 | if(!myMainPM->IsImmediateModeOn()) return Standard_False; |
1213 | myMainPM->EndDraw(aView,DoubleBuf); |
1214 | return Standard_True; |
1215 | } |
1216 | |
1217 | Standard_Boolean AIS_LocalContext::IsImmediateModeOn() const |
1218 | {return myMainPM->IsImmediateModeOn();} |
1219 | |
3c982548 |
1220 | void AIS_LocalContext::SetSensitivityMode(const StdSelect_SensitivityMode aMode) { |
1221 | |
1222 | myMainVS->SetSensitivityMode(aMode); |
1223 | } |
1224 | |
1225 | StdSelect_SensitivityMode AIS_LocalContext::SensitivityMode() const { |
1226 | |
1227 | return myMainVS->SensitivityMode(); |
1228 | } |
1229 | |
7fd59977 |
1230 | void AIS_LocalContext::SetSensitivity(const Standard_Real aPrecision) { |
1231 | |
1232 | myMainVS->SetSensitivity(aPrecision); |
1233 | } |
1234 | |
3c982548 |
1235 | Standard_Real AIS_LocalContext::Sensitivity() const { |
7fd59977 |
1236 | |
3c982548 |
1237 | return myMainVS->Sensitivity(); |
1238 | } |
1239 | |
1240 | void AIS_LocalContext::SetPixelTolerance(const Standard_Integer aPrecision) { |
1241 | |
1242 | myMainVS->SetPixelTolerance(aPrecision); |
1243 | } |
1244 | |
1245 | Standard_Integer AIS_LocalContext::PixelTolerance() const { |
1246 | |
1247 | return myMainVS->PixelTolerance(); |
7fd59977 |
1248 | } |
59f45b7c |
1249 | |
1250 | //======================================================================= |
1251 | //function : SetZLayer |
1252 | //purpose : |
1253 | //======================================================================= |
1254 | |
1255 | void AIS_LocalContext::SetZLayer (const Handle(AIS_InteractiveObject)& theIObj, |
1256 | const Standard_Integer theLayerId) |
1257 | { |
1258 | if (!myActiveObjects.IsBound (theIObj)) |
1259 | return; |
1260 | |
1261 | const Handle(AIS_LocalStatus)& aStatus = myActiveObjects (theIObj); |
1262 | if (aStatus->DisplayMode () == -1) |
1263 | return; |
1264 | |
1265 | theIObj->SetZLayer (myMainPM, theLayerId); |
1266 | } |
1267 | |
1268 | //======================================================================= |
1269 | //function : GetZLayer |
1270 | //purpose : |
1271 | //======================================================================= |
1272 | |
1273 | Standard_Integer AIS_LocalContext::GetZLayer (const Handle(AIS_InteractiveObject)& theIObj) const |
1274 | { |
1275 | if (!myActiveObjects.IsBound (theIObj)) |
1276 | return -1; |
1277 | |
1278 | return theIObj->GetZLayer (myMainPM); |
1279 | } |