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; |
448 | Standard_Boolean jobdone(Standard_False); |
81bba717 |
449 | // it is checked which were the temporary attributes |
450 | // and they are set to 0 |
7fd59977 |
451 | |
81bba717 |
452 | // desactivate standard modes |
7fd59977 |
453 | if(Att->Decomposed()){ |
454 | for(It.Initialize(myListOfStandardMode);It.More();It.Next()){ |
455 | mySM->Deactivate(aSelectable,It.Value(),myMainVS); |
456 | } |
457 | } |
458 | |
81bba717 |
459 | // if object or temporary presentations... |
7fd59977 |
460 | if(Att->IsTemporary()) |
461 | { |
462 | if(Att->IsSubIntensityOn()) |
463 | myMainPM->Unhighlight(aSelectable,Att->HilightMode()); |
464 | |
81bba717 |
465 | // remove if bug on clear correct... |
7fd59977 |
466 | myMainPM->Erase(aSelectable,Att->DisplayMode()); |
467 | myMainPM->Clear(aSelectable,Att->DisplayMode()); |
468 | if(myMainPM->IsDisplayed(aSelectable,Att->HilightMode())) |
469 | myMainPM->Erase(aSelectable,Att->HilightMode()); |
470 | // myMainPM->Clear(aSelectable,Att->HilightMode()); |
471 | jobdone = Standard_True; |
472 | } |
81bba717 |
473 | // if below intensity |
7fd59977 |
474 | else |
475 | { |
476 | if(Att->IsSubIntensityOn()) |
477 | myCTX->SubIntensityOff(aSelectable); |
478 | } |
81bba717 |
479 | // desactivate stored proper modes |
7fd59977 |
480 | for(It.Initialize(Att->SelectionModes());It.More();It.Next()){ |
481 | mySM->Deactivate(aSelectable,It.Value(),myMainVS); |
482 | } |
ab943560 |
483 | // pop : si je laisses cela plantes dans les elements de construction |
484 | // alors a toi de jouer ROB |
7fd59977 |
485 | // RemoveSelected(aSelectable); |
486 | |
487 | if(IsSelected(aSelectable)) |
488 | AddOrRemoveSelected(aSelectable); |
489 | myActiveObjects.UnBind(aSelectable); |
490 | |
491 | //Last detected object keeps for lastindex initialization. |
492 | Handle(SelectMgr_EntityOwner) aLastPicked = myMainVS->OnePicked(); |
493 | |
494 | UpdateSort(); |
495 | |
496 | //Object removes from SelectMgr |
497 | if( mySM->Contains(aSelectable) ) |
498 | mySM->Remove(aSelectable); |
499 | |
500 | //Object removes from Detected sequence |
501 | AIS_SequenceOfInteractive detectAIS; |
502 | |
503 | Standard_Integer i = 1; |
504 | for(i = 1 ; i < myAISDetectedSeq.Length(); i++) |
505 | { |
506 | Handle(AIS_InteractiveObject) anObj = DetectedCurrentObject(); |
507 | if( !anObj.IsNull() && anObj != aSelectable ) |
508 | myAISDetectedSeq.Remove( i ); |
509 | } |
510 | |
511 | Standard_Integer aHM = aSelectable->HasHilightMode() ? aSelectable->HilightMode() : 0; |
512 | |
513 | //EntityOwners remove from AIS_Selection |
514 | Handle(AIS_Selection) aSel = AIS_Selection::Selection(mySelName.ToCString()); |
515 | AIS_NListTransient::Iterator anIter(aSel->Objects()); |
516 | AIS_NListTransient removeEntites; |
517 | for(; anIter.More(); anIter.Next()){ |
518 | const Handle(Standard_Transient)& Tr = anIter.Value(); |
519 | if (!Tr.IsNull()){ |
520 | const Handle(SelectMgr_EntityOwner)& anOwnr = *((const Handle(SelectMgr_EntityOwner)*) &Tr); |
521 | if(anOwnr->Selectable() == aSelectable){ |
522 | removeEntites.Append(Tr); |
523 | if(IsSelected(anOwnr)) |
524 | anOwnr->Unhilight(myMainPM, aHM);//Unhilight selected |
525 | } |
526 | } |
527 | } |
528 | AIS_NListTransient::Iterator anIterRemove(removeEntites); |
529 | for(; anIterRemove.More(); anIterRemove.Next()) |
530 | aSel->Select(anIterRemove.Value());//EntityOwner removes from the selection data |
531 | |
532 | //EntityOwners remove from myMapOfOwner |
533 | SelectMgr_IndexedMapOfOwner ownersToKeep; |
534 | const Handle(V3d_Viewer)& aViewer = myCTX->CurrentViewer(); |
535 | for(i = 1; i <= myMapOfOwner.Extent(); i++){ |
536 | const Handle(SelectMgr_EntityOwner)& anOwner = myMapOfOwner(i) ; |
eafb234b |
537 | if(!anOwner.IsNull()) { |
7fd59977 |
538 | if(anOwner->Selectable() != aSelectable) |
539 | ownersToKeep.Add(anOwner); |
540 | else |
541 | { |
542 | if(anOwner->IsHilighted(myMainPM, aHM)) |
543 | { |
544 | for(aViewer->InitActiveViews(); aViewer->MoreActiveViews(); aViewer->NextActiveViews()) |
545 | Unhilight(anOwner, aViewer->ActiveView()); |
546 | } |
547 | } |
eafb234b |
548 | } |
7fd59977 |
549 | } |
550 | myMapOfOwner.Clear(); |
551 | myMapOfOwner.Assign(ownersToKeep); |
552 | mylastindex = myMapOfOwner.FindIndex(aLastPicked); |
553 | |
554 | return Standard_True; |
555 | } |
556 | |
557 | //======================================================================= |
558 | //function : ActivateStandardMode |
559 | //purpose : |
560 | //======================================================================= |
561 | |
562 | void AIS_LocalContext::ActivateStandardMode(const TopAbs_ShapeEnum aType) |
563 | { |
564 | |
81bba717 |
565 | //check if it is not in the list |
7fd59977 |
566 | TColStd_ListIteratorOfListOfInteger It(myListOfStandardMode); |
567 | for(;It.More();It.Next()) |
568 | if(It.Value()==aType) return; |
569 | Standard_Integer IMode = AIS_Shape::SelectionMode(aType); |
570 | |
571 | |
81bba717 |
572 | // create a hidden filter answering ok to the type except for : |
573 | // if the type is shape... |
574 | // if the filters already impact at the type <aType> |
7fd59977 |
575 | if(aType != TopAbs_SHAPE){ |
576 | if(myStdFilters[IMode].IsNull()) |
577 | myStdFilters[IMode] = new StdSelect_ShapeTypeFilter(aType); |
578 | if(!HasFilters(aType)) |
579 | myFilters->Add(myStdFilters[IMode]); |
580 | } |
581 | |
81bba717 |
582 | // the mode is activated for all objects of type Shape |
583 | // accepting the decomposition in standard mode. |
7fd59977 |
584 | myListOfStandardMode.Append(IMode); |
585 | |
586 | AIS_DataMapIteratorOfDataMapOfSelStat ItM(myActiveObjects); |
587 | |
588 | for(;ItM.More();ItM.Next()){ |
7fd59977 |
589 | if(ItM.Value()->Decomposed()) |
7fd59977 |
590 | myCTX->SelectionManager()->Activate(ItM.Key(), |
591 | IMode, |
592 | myMainVS); |
593 | } |
594 | |
595 | } |
596 | |
597 | //======================================================================= |
598 | //function : DeActivateStandardMode |
599 | //purpose : |
600 | //======================================================================= |
601 | |
602 | void AIS_LocalContext::DeactivateStandardMode(const TopAbs_ShapeEnum aType) |
603 | { |
604 | TColStd_ListIteratorOfListOfInteger It(myListOfStandardMode); |
605 | Standard_Integer IMode = AIS_Shape::SelectionMode(aType); |
606 | for(;It.More();It.Next()) |
607 | if(It.Value()==IMode) { |
608 | AIS_DataMapIteratorOfDataMapOfSelStat ItM(myActiveObjects); |
609 | |
610 | for(;ItM.More();ItM.Next()){ |
611 | if(ItM.Value()->Decomposed()){ |
612 | myCTX->SelectionManager()->Deactivate(ItM.Key(), |
613 | IMode, |
614 | myMainVS); |
615 | ItM.Value()->RemoveSelectionMode(IMode); |
616 | } |
617 | } |
618 | myListOfStandardMode.Remove(It); |
619 | if(myFilters->IsIn(myStdFilters[IMode])) |
620 | myFilters->Remove(myStdFilters[IMode]); |
621 | UpdateSort(); |
622 | return; |
623 | } |
624 | UpdateSort(); |
625 | } |
626 | |
627 | //======================================================================= |
628 | //function : AddFilter |
629 | //purpose : |
630 | //======================================================================= |
631 | |
632 | void AIS_LocalContext::AddFilter(const Handle(SelectMgr_Filter)& aFilter) |
633 | { |
81bba717 |
634 | // it is checked if the filter impacts at the type of active sub-shape |
635 | // for which a filter of type has been already implemented... |
7fd59977 |
636 | |
637 | TColStd_ListIteratorOfListOfInteger It(myListOfStandardMode); |
638 | |
639 | for(;It.More();It.Next()){ |
640 | if(aFilter->ActsOn(AIS_Shape::SelectionType(It.Value()))) |
641 | if(myFilters->IsIn(myStdFilters[It.Value()])) |
642 | myFilters->Remove(myStdFilters[It.Value()]); |
643 | } |
644 | myFilters->Add(aFilter); |
645 | } |
646 | |
647 | //======================================================================= |
648 | //function : RemoveFilter |
649 | //purpose : |
650 | //======================================================================= |
651 | |
652 | void AIS_LocalContext::RemoveFilter(const Handle(SelectMgr_Filter)& aFilter) |
653 | { |
654 | if(myFilters->IsIn(aFilter)) myFilters->Remove(aFilter); |
655 | |
81bba717 |
656 | // it is checked if the filter for type standard is active. |
657 | // if yes, it is checked there are still similarities among the |
658 | // remaining filters... |
659 | // otherwise, the standard filter is restored to |
660 | // continu selecting active modes... |
7fd59977 |
661 | TColStd_ListIteratorOfListOfInteger It(myListOfStandardMode); |
662 | TopAbs_ShapeEnum SE; |
663 | for(;It.More();It.Next()){ |
664 | SE = AIS_Shape::SelectionType(It.Value()); |
665 | if(aFilter->ActsOn(SE)) |
666 | if(!HasFilters(SE)) |
667 | myFilters->Add(myStdFilters[It.Value()]); |
668 | } |
669 | } |
670 | |
671 | |
672 | |
ab943560 |
673 | Standard_Boolean AIS_LocalContext::HasSameProjector(const Handle(Select3D_Projector)& thePrj) const |
7fd59977 |
674 | { |
ab943560 |
675 | const Handle(Select3D_Projector)& aCurPrj = myMainVS->Projector(); |
676 | if (aCurPrj->Perspective() != thePrj->Perspective()) |
677 | return Standard_False; |
678 | if (aCurPrj->Perspective() && aCurPrj->Focus() != thePrj->Focus()) |
679 | return Standard_False; |
680 | const gp_GTrsf& aCurTrsf = aCurPrj->Transformation(); |
681 | const gp_GTrsf& aPrjTrsf = thePrj->Transformation(); |
682 | |
683 | for (Standard_Integer i = 1; i <= 3; ++i) |
684 | { |
685 | for (Standard_Integer j = 1; j <= 3 ; ++j) |
686 | { |
687 | if (aCurTrsf.Value (i, j) != aPrjTrsf.Value (i, j)) |
688 | return Standard_False; |
7fd59977 |
689 | } |
690 | } |
ab943560 |
691 | |
7fd59977 |
692 | return Standard_True; |
693 | } |
694 | |
695 | |
696 | //======================================================================= |
697 | //function : Terminate |
698 | //purpose : |
699 | //======================================================================= |
700 | |
701 | void AIS_LocalContext::Terminate( const Standard_Boolean updateviewer ) |
702 | { |
703 | ClearDetected(); |
704 | Clear(); |
705 | myMapOfOwner.Clear(); |
706 | |
707 | mylastindex=0; |
81bba717 |
708 | // clear the selector... |
7fd59977 |
709 | myMainVS->Clear(); |
710 | myCTX->SelectionManager()->Remove(myMainVS); |
711 | |
712 | |
713 | AIS_Selection::SetCurrentSelection(mySelName.ToCString()); |
714 | Handle(AIS_Selection) S = AIS_Selection::CurrentSelection(); |
715 | Handle(Standard_Transient) Tr; |
716 | for(S->Init();S->More();S->Next()){ |
717 | Tr = S->Value(); |
718 | (*((Handle(SelectMgr_EntityOwner)*)&Tr))->State(0); |
719 | } |
720 | |
721 | |
722 | AIS_Selection::Select(); |
723 | AIS_Selection::Remove(mySelName.ToCString()); |
724 | |
725 | // CLE |
726 | // const Handle(V3d_Viewer)& Vwr = myCTX->CurrentViewer(); |
727 | Handle(V3d_Viewer) Vwr = myCTX->CurrentViewer(); |
728 | // ENDCLE |
729 | Handle(V3d_View) curV; |
730 | for(Vwr->InitActiveViews();Vwr->MoreActiveViews();Vwr->NextActiveViews()){ |
731 | curV = Vwr->ActiveView(); |
732 | Visual3d_TransientManager::ClearDraw( curV->View(), updateviewer ); |
733 | } |
734 | |
735 | |
736 | #ifdef DEB |
737 | Handle(V3d_View) BidV; |
738 | myMainVS->ClearAreas(BidV); |
739 | myMainVS->ClearSensitive(BidV); |
740 | |
741 | #endif |
742 | } |
743 | |
744 | |
745 | //======================================================================= |
746 | //function : SubIntensity |
747 | //purpose : |
748 | //======================================================================= |
749 | |
750 | void AIS_LocalContext::SubIntensityOn(const Handle(AIS_InteractiveObject)& anObject) |
751 | { |
752 | if(!myActiveObjects.IsBound(anObject)) return; |
753 | |
754 | const Handle(AIS_LocalStatus)& Att = myActiveObjects(anObject); |
755 | |
756 | if(Att->IsTemporary()) |
757 | myMainPM->Color(anObject,myCTX->SubIntensityColor(),Att->DisplayMode()); |
758 | |
759 | Att->SubIntensityOn(); |
760 | } |
761 | //======================================================================= |
762 | //function : SubIntensity |
763 | //purpose : |
764 | //======================================================================= |
765 | |
766 | void AIS_LocalContext::SubIntensityOff(const Handle(AIS_InteractiveObject)& anObject) |
767 | { |
768 | if(!myActiveObjects.IsBound(anObject)) return; |
769 | |
770 | const Handle(AIS_LocalStatus)& Att = myActiveObjects(anObject); |
771 | |
772 | if(Att->IsTemporary()) |
773 | myMainPM->Unhighlight(anObject); |
774 | Att->SubIntensityOff(); |
775 | } |
776 | |
777 | |
778 | //======================================================================= |
779 | //function : Hilight |
780 | //purpose : |
781 | //======================================================================= |
782 | |
783 | void AIS_LocalContext::Hilight(const Handle(AIS_InteractiveObject)& anObject) |
784 | { |
785 | if(!myActiveObjects.IsBound(anObject)){ |
786 | Standard_Integer HiMod = anObject->HasHilightMode()? anObject->HilightMode() : 0; |
787 | Handle(AIS_LocalStatus) Att = new AIS_LocalStatus(Standard_True, |
788 | Standard_False, |
789 | -1,-1,HiMod); |
790 | myActiveObjects.Bind(anObject,Att); |
791 | |
792 | } |
793 | const Handle(AIS_LocalStatus)& Att = myActiveObjects(anObject); |
794 | myMainPM->Color(anObject,myCTX->HilightColor(),Att->HilightMode()); |
795 | Att->SubIntensityOn(); |
796 | } |
797 | //======================================================================= |
798 | //function : Hilight |
799 | //purpose : |
800 | //======================================================================= |
801 | |
802 | void AIS_LocalContext::Hilight(const Handle(AIS_InteractiveObject)& anObject, |
803 | const Quantity_NameOfColor Col) |
804 | { |
805 | if(!myActiveObjects.IsBound(anObject)){ |
806 | Standard_Integer HiMod = anObject->HasHilightMode()? anObject->HilightMode() : 0; |
807 | Handle(AIS_LocalStatus) Att = new AIS_LocalStatus(Standard_True, |
808 | Standard_False, |
809 | -1,-1,HiMod); |
810 | myActiveObjects.Bind(anObject,Att); |
811 | |
812 | } |
813 | const Handle(AIS_LocalStatus)& Att = myActiveObjects(anObject); |
814 | myMainPM->Color(anObject,Col,Att->HilightMode()); |
815 | Att->SubIntensityOn(); |
816 | Att->SetHilightColor(Col); |
817 | } |
818 | |
819 | //======================================================================= |
820 | //function : Unhilight |
821 | //purpose : |
822 | //======================================================================= |
823 | |
824 | void AIS_LocalContext::Unhilight(const Handle(AIS_InteractiveObject)& anObject) |
825 | { |
826 | if(!myActiveObjects.IsBound(anObject)) return; |
827 | |
81bba717 |
828 | // chieck if by hazard the object is somewhere else... |
7fd59977 |
829 | Standard_Integer Indx; |
830 | Standard_Boolean IsSomeWhereElse = |
831 | myCTX->IsInLocal(anObject,Indx) && Indx != myCTX->IndexOfCurrentLocal(); |
832 | |
833 | const Handle(AIS_LocalStatus)& Att = myActiveObjects(anObject); |
834 | myMainPM->Unhighlight(anObject,Att->HilightMode()); |
835 | if(Att->IsTemporary() && Att->DisplayMode()==-1) |
836 | if(!IsSomeWhereElse) |
eb4320f2 |
837 | myMainPM->SetVisibility (anObject, Att->HilightMode(), Standard_False); |
838 | |
7fd59977 |
839 | Att->SubIntensityOff(); |
840 | Att->SetHilightColor(Quantity_NOC_WHITE); |
841 | } |
842 | |
843 | |
844 | //======================================================================= |
845 | //function : IsIn |
846 | //purpose : |
847 | //======================================================================= |
848 | |
849 | Standard_Boolean AIS_LocalContext:: |
850 | IsIn(const Handle(AIS_InteractiveObject)& anObject) const |
851 | { |
852 | return myActiveObjects.IsBound(anObject); |
853 | } |
854 | |
855 | //======================================================================= |
856 | //function : IsHilighted |
857 | //purpose : |
858 | //======================================================================= |
859 | |
860 | Standard_Boolean AIS_LocalContext::IsHilighted(const Handle(AIS_InteractiveObject)& anObject) const |
861 | { |
862 | if(!myActiveObjects.IsBound(anObject)) return Standard_False; |
863 | return myActiveObjects(anObject)->IsSubIntensityOn(); |
864 | } |
865 | |
866 | Standard_Boolean AIS_LocalContext::IsHilighted(const Handle(AIS_InteractiveObject)& anObject, |
867 | Standard_Boolean& WithColor, |
868 | Quantity_NameOfColor& HiCol) const |
869 | { |
870 | if(!myActiveObjects.IsBound(anObject)) return Standard_False; |
871 | if( myActiveObjects(anObject)->IsSubIntensityOn()){ |
872 | HiCol = myActiveObjects(anObject)->HilightColor(); |
873 | if(HiCol==Quantity_NOC_WHITE) |
874 | WithColor = Standard_True; |
875 | else |
876 | WithColor = Standard_False; |
877 | return Standard_True; |
878 | } |
879 | return Standard_False; |
880 | } |
881 | |
882 | |
883 | void AIS_LocalContext::SetDisplayPriority(const Handle(AIS_InteractiveObject)& anObject, |
884 | const Standard_Integer Prior) |
885 | { |
886 | if(!myActiveObjects.IsBound(anObject)) return; |
887 | const Handle(AIS_LocalStatus)& STAT = myActiveObjects(anObject); |
888 | if(STAT->DisplayMode()==-1) return; |
889 | myMainPM->SetDisplayPriority(anObject,STAT->DisplayMode(),Prior); |
890 | if(STAT->IsSubIntensityOn()) |
891 | myMainPM->SetDisplayPriority(anObject,STAT->HilightMode(),Prior); |
892 | |
893 | |
894 | } |
895 | |
7fd59977 |
896 | //======================================================================= |
897 | //function : DisplayedObjects |
898 | //purpose : |
899 | //======================================================================= |
900 | Standard_Integer AIS_LocalContext::DisplayedObjects(TColStd_MapOfTransient& theMap) const |
901 | { |
902 | Standard_Integer NbDisp(0); |
903 | for(AIS_DataMapIteratorOfDataMapOfSelStat it(myActiveObjects);it.More();it.Next()){ |
904 | const Handle(SelectMgr_SelectableObject)& SO = it.Key(); |
905 | if(!theMap.Contains(SO)) |
906 | if(it.Value()->DisplayMode()!=-1){ |
907 | theMap.Add(SO); |
908 | NbDisp++; |
909 | } |
910 | } |
911 | return NbDisp; |
912 | } |
913 | |
914 | |
915 | //======================================================================= |
916 | //function : IsDisplayed |
917 | //purpose : |
918 | //======================================================================= |
919 | |
920 | Standard_Boolean AIS_LocalContext::IsDisplayed(const Handle(AIS_InteractiveObject)& anObject) const |
921 | { |
922 | if(!myActiveObjects.IsBound(anObject)) return Standard_False; |
923 | return (myActiveObjects(anObject)->DisplayMode()!=-1); |
924 | } |
925 | |
926 | //======================================================================= |
927 | //function : IsDisplayed |
928 | //purpose : |
929 | //======================================================================= |
930 | |
931 | Standard_Boolean AIS_LocalContext::IsDisplayed(const Handle(AIS_InteractiveObject)& anObject, |
932 | const Standard_Integer aMode) const |
933 | { |
934 | if(!myActiveObjects.IsBound(anObject)) return Standard_False; |
935 | return (myActiveObjects(anObject)->DisplayMode()==aMode); |
936 | } |
937 | |
938 | //======================================================================= |
939 | //function : SelectionModes |
940 | //purpose : |
941 | //======================================================================= |
942 | |
943 | const TColStd_ListOfInteger& AIS_LocalContext:: |
944 | SelectionModes(const Handle(AIS_InteractiveObject)& anObject) const |
945 | { |
946 | return myActiveObjects(anObject)->SelectionModes(); |
947 | } |
948 | |
949 | //======================================================================= |
950 | //function : Status |
951 | //purpose : |
952 | //======================================================================= |
953 | |
954 | TCollection_AsciiString AIS_LocalContext::Status() const |
955 | { |
956 | TCollection_AsciiString t; |
957 | return t; |
958 | } |
959 | |
960 | const Handle(AIS_LocalStatus)& AIS_LocalContext::Status(const Handle(AIS_InteractiveObject)& anObject) const |
961 | { |
962 | return myActiveObjects(anObject); |
963 | } |
964 | |
965 | //======================================================================= |
966 | //function : LoadContextObjects |
967 | //purpose : |
968 | //======================================================================= |
969 | |
970 | void AIS_LocalContext::LoadContextObjects() |
971 | { |
972 | AIS_ListIteratorOfListOfInteractive It; |
973 | if(myLoadDisplayed) { |
974 | AIS_ListOfInteractive LL; |
975 | myCTX->DisplayedObjects(LL,Standard_True); |
976 | Handle(AIS_LocalStatus) Att; |
977 | for (It.Initialize(LL);It.More();It.Next()){ |
978 | Att= new AIS_LocalStatus(); |
979 | Att->SetDecomposition((It.Value()->AcceptShapeDecomposition() && myAcceptStdMode)); |
980 | Att->SetTemporary(Standard_False); |
981 | Att->SetHilightMode(It.Value()->HasHilightMode()? It.Value()->HilightMode(): 0); |
982 | |
983 | myActiveObjects.Bind(It.Value(),Att); |
984 | } |
985 | } |
986 | } |
987 | |
988 | void AIS_LocalContext::UnloadContextObjects() |
989 | { |
990 | AIS_ListIteratorOfListOfInteractive It; |
991 | if(myLoadDisplayed) |
992 | { |
993 | AIS_ListOfInteractive LL; |
994 | myCTX->DisplayedObjects(LL,Standard_True); |
995 | |
996 | for (It.Initialize(LL);It.More();It.Next()) |
997 | { |
998 | myActiveObjects.UnBind(It.Value()); |
999 | } |
1000 | } |
1001 | } |
1002 | //======================================================================= |
1003 | //function : Process |
1004 | //purpose : |
1005 | //======================================================================= |
1006 | |
1007 | void AIS_LocalContext::Process(const Handle(SelectMgr_SelectableObject)& anObject, |
1008 | const Standard_Boolean WithProj) |
1009 | { |
1010 | if(!myActiveObjects.IsBound(anObject)) return; |
1011 | if(myActiveObjects(anObject)->Decomposed()) |
1012 | ActivateStandardModes(anObject,WithProj); |
1013 | else |
1014 | { |
1015 | TColStd_ListIteratorOfListOfInteger It(myActiveObjects(anObject)->SelectionModes()); |
1016 | for(;It.More();It.Next()) |
1017 | myCTX->SelectionManager()->Activate(anObject,It.Value(),myMainVS,WithProj); |
1018 | } |
1019 | } |
1020 | |
1021 | //======================================================================= |
1022 | //function : Process |
1023 | //purpose : |
1024 | //======================================================================= |
1025 | |
1026 | void AIS_LocalContext::Process(const Standard_Boolean WithProj) |
1027 | { |
1028 | |
1029 | myMainVS->Clear(); |
1030 | |
1031 | AIS_DataMapIteratorOfDataMapOfSelStat It(myActiveObjects); |
1032 | |
1033 | for(;It.More();It.Next()){ |
1034 | myCTX->SelectionManager()->Load(It.Key(),myMainVS); |
1035 | if(It.Value()->Decomposed()) |
1036 | ActivateStandardModes(It.Key(),WithProj); |
1037 | else if( myCTX->GetAutoActivateSelection() ) |
1038 | { |
1039 | It.Value()->AddSelectionMode(0); |
1040 | myCTX->SelectionManager()->Activate(It.Key(),0,myMainVS,WithProj); |
1041 | } |
1042 | } |
1043 | |
1044 | } |
1045 | |
1046 | //======================================================================= |
1047 | //function : ActivateModes |
1048 | //purpose : |
1049 | //======================================================================= |
1050 | |
1051 | void AIS_LocalContext::ActivateStandardModes(const Handle(SelectMgr_SelectableObject)& anObject, |
1052 | const Standard_Boolean WithProj) |
1053 | { |
1054 | if(!myActiveObjects.IsBound(anObject)) return; |
1055 | |
1056 | TColStd_ListIteratorOfListOfInteger itl (myListOfStandardMode); |
1057 | |
1058 | const Handle(AIS_LocalStatus)& LS = myActiveObjects(anObject); |
1059 | if(LS->Decomposed()){ |
1060 | for(;itl.More();itl.Next()){ |
1061 | myCTX->SelectionManager()->Activate(anObject,itl.Value(),myMainVS,WithProj); |
1062 | LS->AddSelectionMode(itl.Value()); |
1063 | } |
1064 | } |
1065 | } |
1066 | |
1067 | |
1068 | //======================================================================= |
1069 | //function : ClearObjects |
1070 | //purpose : |
1071 | //======================================================================= |
1072 | |
1073 | void AIS_LocalContext::ClearObjects() |
1074 | { |
1075 | AIS_DataMapIteratorOfDataMapOfSelStat It(myActiveObjects); |
1076 | for(;It.More();It.Next()) |
1077 | { |
1078 | Handle(AIS_InteractiveObject) SO = |
1079 | Handle(AIS_InteractiveObject)::DownCast(It.Key()); |
1080 | |
1081 | const Handle(AIS_LocalStatus)& CurAtt = It.Value(); |
1082 | //TColStd_ListIteratorOfListOfInteger ItL; |
81bba717 |
1083 | // if object is temporary the presentations managed by myMainPM are removed |
7fd59977 |
1084 | AIS_DisplayStatus TheDS = myCTX->DisplayStatus(SO); |
1085 | |
1086 | if(TheDS != AIS_DS_Displayed){ |
1087 | if(myMainPM->IsDisplayed(SO,CurAtt->DisplayMode())){ |
1088 | if(CurAtt->IsSubIntensityOn()&& |
1089 | myMainPM->IsHighlighted(SO,CurAtt->HilightMode())) |
1090 | myMainPM->Unhighlight(SO,CurAtt->HilightMode()); |
1091 | myMainPM->Erase(SO,CurAtt->DisplayMode()); |
1092 | } |
1093 | |
1094 | if(CurAtt->IsTemporary()){ |
1095 | myMainPM->Erase(SO,CurAtt->DisplayMode());} |
1096 | // myMainPM->Clear(SO,CurAtt->DisplayMode());} |
1097 | } |
1098 | else { |
1099 | if (CurAtt->IsSubIntensityOn()){ |
1100 | myCTX->SubIntensityOff(Handle(AIS_InteractiveObject)::DownCast(SO));} |
1101 | Standard_Integer DiMo = SO->HasDisplayMode()? |
1102 | SO->DisplayMode():myCTX->DisplayMode(); |
1103 | if(CurAtt->DisplayMode()!=-1 && |
1104 | CurAtt->DisplayMode()!= DiMo) |
1105 | myMainPM->Erase(SO,CurAtt->DisplayMode()); |
1106 | } |
1107 | |
1108 | TColStd_ListIteratorOfListOfInteger ITL(CurAtt->SelectionModes()); |
1109 | for(;ITL.More();ITL.Next()) |
1110 | mySM->Deactivate(SO,ITL.Value(),myMainVS); |
1111 | |
1112 | if(CurAtt->IsTemporary()) |
1113 | mySM->Remove(SO,myMainVS); |
1114 | |
1115 | } |
1116 | ClearSelected( Standard_False ); |
1117 | myActiveObjects.Clear(); |
1118 | // myMainVS->ClearAreas();myMainVS->ClearSensitive(); |
1119 | } |
1120 | |
1121 | |
1122 | Standard_Boolean AIS_LocalContext::IsDecompositionOn() const |
1123 | {return !myListOfStandardMode.IsEmpty();} |
1124 | |
1125 | |
1126 | |
1127 | |
1128 | //======================================================================= |
1129 | //function : HasAlreadyFilters |
1130 | //purpose : |
1131 | //======================================================================= |
1132 | |
1133 | Standard_Boolean AIS_LocalContext:: |
1134 | HasFilters(const TopAbs_ShapeEnum aType) const |
1135 | { |
1136 | return myFilters->ActsOn(aType); |
1137 | } |
1138 | |
1139 | void AIS_LocalContext::ClearDetected() |
1140 | { |
eb4320f2 |
1141 | for(Standard_Integer I=1;I<=myMapOfOwner.Extent();I++) |
1142 | { |
1143 | if(!myMapOfOwner(I).IsNull()) |
1144 | { |
7fd59977 |
1145 | if(myMapOfOwner(I)->IsHilighted(myMainPM)) |
eb4320f2 |
1146 | myMapOfOwner(I)->Unhilight(myMainPM); |
1147 | else |
1148 | { |
1149 | const Handle(SelectMgr_SelectableObject)& SO = |
1150 | myMapOfOwner.FindKey(I)->Selectable(); |
1151 | if(myActiveObjects.IsBound(SO)) |
1152 | { |
1153 | const Handle(AIS_LocalStatus)& Att = myActiveObjects(SO); |
1154 | |
1155 | if(Att->IsTemporary() && |
1156 | Att->DisplayMode()==-1 && |
1157 | Att->SelectionModes().IsEmpty()) |
1158 | { |
1159 | myMapOfOwner(I)->Clear(myMainPM); |
1160 | } |
1161 | } |
7fd59977 |
1162 | } |
1163 | } |
1164 | } |
7fd59977 |
1165 | } |
1166 | |
1167 | void AIS_LocalContext::UpdateConversion() |
1168 | { |
1169 | myMainVS->UpdateConversion(); |
1170 | } |
1171 | |
1172 | void AIS_LocalContext::UpdateSort() |
1173 | { |
1174 | myMainVS->UpdateSort(); |
1175 | } |
1176 | |
1177 | |
1178 | |
1179 | //======================================================================= |
1180 | //function : IMMEDIATE MODE |
1181 | //purpose : |
1182 | //======================================================================= |
1183 | |
1184 | Standard_Boolean AIS_LocalContext::BeginImmediateDraw() |
1185 | { |
1186 | if(myMainPM->IsImmediateModeOn()){ |
1187 | myMainPM->BeginDraw(); |
1188 | return Standard_True; |
1189 | } |
1190 | return Standard_False; |
1191 | } |
1192 | |
1193 | |
1194 | Standard_Boolean AIS_LocalContext::ImmediateAdd(const Handle(AIS_InteractiveObject)& anIObj, |
1195 | const Standard_Integer aMode) |
1196 | { |
1197 | if(!myMainPM->IsImmediateModeOn()) |
1198 | return Standard_False; |
1199 | myMainPM->Add(anIObj,aMode); |
1200 | return Standard_True; |
1201 | } |
1202 | |
1203 | Standard_Boolean AIS_LocalContext::ImmediateRemove(const Handle(AIS_InteractiveObject)& anIObj, |
1204 | const Standard_Integer aMode) |
1205 | { |
1206 | if(!myMainPM->IsImmediateModeOn()) return Standard_False; |
1207 | myMainPM->Remove(anIObj,aMode); |
1208 | return Standard_True; |
1209 | } |
1210 | |
1211 | Standard_Boolean AIS_LocalContext::EndImmediateDraw(const Handle(V3d_View)& aView, |
1212 | const Standard_Boolean DoubleBuf) |
1213 | { |
1214 | if(!myMainPM->IsImmediateModeOn()) return Standard_False; |
1215 | myMainPM->EndDraw(aView,DoubleBuf); |
1216 | return Standard_True; |
1217 | } |
1218 | |
1219 | Standard_Boolean AIS_LocalContext::IsImmediateModeOn() const |
1220 | {return myMainPM->IsImmediateModeOn();} |
1221 | |
3c982548 |
1222 | void AIS_LocalContext::SetSensitivityMode(const StdSelect_SensitivityMode aMode) { |
1223 | |
1224 | myMainVS->SetSensitivityMode(aMode); |
1225 | } |
1226 | |
1227 | StdSelect_SensitivityMode AIS_LocalContext::SensitivityMode() const { |
1228 | |
1229 | return myMainVS->SensitivityMode(); |
1230 | } |
1231 | |
7fd59977 |
1232 | void AIS_LocalContext::SetSensitivity(const Standard_Real aPrecision) { |
1233 | |
1234 | myMainVS->SetSensitivity(aPrecision); |
1235 | } |
1236 | |
3c982548 |
1237 | Standard_Real AIS_LocalContext::Sensitivity() const { |
7fd59977 |
1238 | |
3c982548 |
1239 | return myMainVS->Sensitivity(); |
1240 | } |
1241 | |
1242 | void AIS_LocalContext::SetPixelTolerance(const Standard_Integer aPrecision) { |
1243 | |
1244 | myMainVS->SetPixelTolerance(aPrecision); |
1245 | } |
1246 | |
1247 | Standard_Integer AIS_LocalContext::PixelTolerance() const { |
1248 | |
1249 | return myMainVS->PixelTolerance(); |
7fd59977 |
1250 | } |
59f45b7c |
1251 | |
1252 | //======================================================================= |
1253 | //function : SetZLayer |
1254 | //purpose : |
1255 | //======================================================================= |
1256 | |
1257 | void AIS_LocalContext::SetZLayer (const Handle(AIS_InteractiveObject)& theIObj, |
1258 | const Standard_Integer theLayerId) |
1259 | { |
1260 | if (!myActiveObjects.IsBound (theIObj)) |
1261 | return; |
1262 | |
1263 | const Handle(AIS_LocalStatus)& aStatus = myActiveObjects (theIObj); |
1264 | if (aStatus->DisplayMode () == -1) |
1265 | return; |
1266 | |
1267 | theIObj->SetZLayer (myMainPM, theLayerId); |
1268 | } |
1269 | |
1270 | //======================================================================= |
1271 | //function : GetZLayer |
1272 | //purpose : |
1273 | //======================================================================= |
1274 | |
1275 | Standard_Integer AIS_LocalContext::GetZLayer (const Handle(AIS_InteractiveObject)& theIObj) const |
1276 | { |
1277 | if (!myActiveObjects.IsBound (theIObj)) |
1278 | return -1; |
1279 | |
1280 | return theIObj->GetZLayer (myMainPM); |
1281 | } |