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 | // |
d5f74e42 |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
b311480e |
16 | |
7fd59977 |
17 | //Modified by ROB : Traque des UpdateConversion intempestifs. |
18 | |
42cf5bc1 |
19 | #include <AIS_DataMapIteratorOfDataMapOfSelStat.hxx> |
20 | #include <AIS_InteractiveContext.hxx> |
21 | #include <AIS_InteractiveObject.hxx> |
7fd59977 |
22 | #include <AIS_ListIteratorOfListOfInteractive.hxx> |
23 | #include <AIS_ListOfInteractive.hxx> |
42cf5bc1 |
24 | #include <AIS_LocalContext.hxx> |
25 | #include <AIS_LocalStatus.hxx> |
26 | #include <AIS_Selection.hxx> |
27 | #include <AIS_Shape.hxx> |
28 | #include <Aspect_TypeOfMarker.hxx> |
7fd59977 |
29 | #include <Graphic3d_Structure.hxx> |
30 | #include <Prs3d_LineAspect.hxx> |
31 | #include <Prs3d_PlaneAspect.hxx> |
32 | #include <Prs3d_PointAspect.hxx> |
33 | #include <Prs3d_Presentation.hxx> |
42cf5bc1 |
34 | #include <SelectMgr_CompositionFilter.hxx> |
35 | #include <SelectMgr_EntityOwner.hxx> |
36 | #include <SelectMgr_Filter.hxx> |
37 | #include <SelectMgr_OrFilter.hxx> |
38 | #include <SelectMgr_SelectableObject.hxx> |
39 | #include <SelectMgr_SelectionManager.hxx> |
40 | #include <Standard_Transient.hxx> |
41 | #include <Standard_Type.hxx> |
7fd59977 |
42 | #include <StdSelect_ShapeTypeFilter.hxx> |
f751596e |
43 | #include <StdSelect_ViewerSelector3d.hxx> |
42cf5bc1 |
44 | #include <TCollection_AsciiString.hxx> |
45 | #include <TColStd_ListIteratorOfListOfInteger.hxx> |
46 | #include <TopAbs_ShapeEnum.hxx> |
47 | #include <TopoDS_Shape.hxx> |
7fd59977 |
48 | #include <V3d_View.hxx> |
42cf5bc1 |
49 | #include <V3d_Viewer.hxx> |
7fd59977 |
50 | |
7fd59977 |
51 | #include <stdio.h> |
92efcf78 |
52 | IMPLEMENT_STANDARD_RTTIEXT(AIS_LocalContext,MMgt_TShared) |
53 | |
7fd59977 |
54 | static TCollection_AsciiString AIS_Local_SelName(const Standard_Address address, |
55 | const Standard_Integer anIndex) |
56 | { |
57 | // TCollection_AsciiString SelName; |
7fd59977 |
58 | char string[100]; |
59 | sprintf(string,"%p_%d", address, anIndex); // works under any system |
60 | TCollection_AsciiString SelName(string); |
7fd59977 |
61 | return SelName; |
62 | } |
63 | |
64 | |
65 | //======================================================================= |
66 | //function : AIS_LocalContext |
67 | //purpose : |
68 | //======================================================================= |
69 | |
70 | |
71 | AIS_LocalContext::AIS_LocalContext(){} |
72 | |
73 | AIS_LocalContext::AIS_LocalContext(const Handle(AIS_InteractiveContext)& aCtx, |
74 | const Standard_Integer Index, |
75 | const Standard_Boolean LoadDisplayed, |
76 | const Standard_Boolean AcceptStandardModes, |
77 | const Standard_Boolean AcceptEraseOfTemp, |
35e08fe8 |
78 | const Standard_Boolean /*BothViewers*/): |
7fd59977 |
79 | myCTX(aCtx), |
80 | myLoadDisplayed(LoadDisplayed), |
81 | myAcceptStdMode(AcceptStandardModes), |
82 | myAcceptErase(AcceptEraseOfTemp), |
83 | mySM(aCtx->SelectionManager()), |
f751596e |
84 | myMainVS(aCtx->MainSelector()), |
7fd59977 |
85 | myFilters(new SelectMgr_OrFilter()), |
86 | myAutoHilight(Standard_True), |
b586500b |
87 | myMapOfOwner (new SelectMgr_IndexedMapOfOwner()), |
7fd59977 |
88 | mylastindex(0), |
89 | mylastgood(0), |
d2094e11 |
90 | myCurDetected(0), |
91 | myAISCurDetected(0) |
92 | |
7fd59977 |
93 | { |
64e2d3bd |
94 | // bind self to AIS_InteractiveContext::myLocalContexts. Further, the |
95 | // constructor executes logic that implies that the context is already |
96 | // created and mapped. |
97 | aCtx->myLocalContexts.Bind (Index, this); |
98 | |
f751596e |
99 | myMainVS->ResetSelectionActivationStatus(); |
7fd59977 |
100 | myMainPM = aCtx->MainPrsMgr(); |
101 | mySelName = AIS_Local_SelName(this, Index); |
102 | AIS_Selection::CreateSelection(mySelName.ToCString()); |
103 | |
104 | mySM->Add(myMainVS); |
105 | if(myLoadDisplayed) LoadContextObjects(); |
f751596e |
106 | Process(); |
7fd59977 |
107 | |
108 | } |
109 | |
110 | |
111 | //======================================================================= |
112 | //function : SetContext |
113 | //purpose : |
114 | //======================================================================= |
115 | |
116 | void AIS_LocalContext::SetContext(const Handle(AIS_InteractiveContext)& aCtx) |
117 | { myCTX = aCtx;} |
118 | |
119 | //======================================================================= |
120 | //function : Display |
121 | //purpose : |
122 | //======================================================================= |
123 | |
124 | Standard_Boolean AIS_LocalContext::Display(const Handle(AIS_InteractiveObject)& anInteractive, |
125 | const Standard_Integer WhichMode, |
126 | const Standard_Boolean AllowShapeDecomposition, |
127 | const Standard_Integer ActivationMode) |
128 | { |
129 | if(myActiveObjects.IsBound(anInteractive)){ |
130 | const Handle(AIS_LocalStatus)& STAT = myActiveObjects(anInteractive); |
131 | |
132 | if(STAT->DisplayMode() == -1){ |
133 | if(!myMainPM->IsDisplayed(anInteractive,WhichMode)) |
134 | myMainPM->Display(anInteractive,WhichMode); |
135 | if(STAT->IsTemporary()) |
136 | STAT->SetDisplayMode(WhichMode); |
137 | } |
138 | else if(STAT->DisplayMode()!=WhichMode && STAT->IsTemporary()){ |
139 | myMainPM->Erase(anInteractive,STAT->DisplayMode()); |
140 | STAT->SetDisplayMode(WhichMode); |
141 | if(!myMainPM->IsDisplayed(anInteractive,WhichMode)) |
142 | myMainPM->Display(anInteractive,WhichMode); |
143 | } |
144 | |
145 | if(ActivationMode!=-1){ |
146 | if(!STAT->IsActivated(ActivationMode)){ |
147 | STAT->ClearSelectionModes(); |
148 | mySM->Load(anInteractive,myMainVS); |
149 | STAT->AddSelectionMode(ActivationMode); |
150 | mySM->Activate(anInteractive,ActivationMode,myMainVS); |
151 | } |
152 | } |
153 | } |
154 | else { |
155 | Handle(AIS_LocalStatus) Att = new AIS_LocalStatus(); |
156 | |
157 | if(anInteractive->AcceptShapeDecomposition() && AllowShapeDecomposition) |
158 | Att->SetDecomposition(Standard_True); |
159 | else |
160 | Att->SetDecomposition(Standard_False); |
81bba717 |
161 | // status temporary or not |
7fd59977 |
162 | if(myCTX->DisplayStatus(anInteractive) == AIS_DS_None || |
163 | myCTX->DisplayStatus(anInteractive) == AIS_DS_Temporary) |
164 | Att->SetTemporary(Standard_True); |
165 | else |
166 | Att->SetTemporary(Standard_False); |
167 | |
168 | |
169 | |
170 | if(!myCTX->IsDisplayed(anInteractive,WhichMode)){ |
171 | |
172 | //storing information.... |
173 | Att->SetDisplayMode(WhichMode); |
174 | if (ActivationMode!=-1) |
175 | Att->AddSelectionMode(ActivationMode); |
176 | Standard_Integer HiMod = anInteractive->HasHilightMode()? anInteractive->HilightMode(): WhichMode; |
177 | Att->SetHilightMode(HiMod); |
178 | |
179 | if(!myMainPM->IsDisplayed(anInteractive,WhichMode)) |
180 | myMainPM->Display(anInteractive,WhichMode); |
181 | |
182 | if(ActivationMode!=-1){ |
183 | mySM->Load(anInteractive,myMainVS); |
184 | mySM->Activate(anInteractive,ActivationMode,myMainVS); |
185 | } |
186 | } |
187 | else{ |
188 | Standard_Integer HiMod = anInteractive->HasHilightMode()? anInteractive->HilightMode(): WhichMode; |
189 | Att->SetHilightMode(HiMod); |
190 | } |
191 | myActiveObjects.Bind(anInteractive,Att); |
192 | } |
193 | Process(anInteractive); |
194 | |
195 | |
196 | |
197 | |
198 | return Standard_True; |
199 | } |
200 | |
201 | //======================================================================= |
202 | //function : Load |
203 | //purpose : |
204 | //======================================================================= |
205 | |
206 | Standard_Boolean AIS_LocalContext:: |
207 | Load(const Handle(AIS_InteractiveObject)& anInteractive, |
208 | const Standard_Boolean AllowShapeDecomposition, |
209 | const Standard_Integer ActivationMode) |
210 | { |
f751596e |
211 | if (myActiveObjects.IsBound (anInteractive)) |
212 | { |
213 | if (anInteractive->HasSelection (ActivationMode)) |
214 | { |
215 | const Handle(SelectMgr_Selection)& aSel = anInteractive->Selection (ActivationMode); |
216 | if (aSel->GetSelectionState() != SelectMgr_SOS_Activated) |
217 | { |
218 | if (!myMainVS->Contains (anInteractive)) |
219 | { |
220 | mySM->Load (anInteractive, myMainVS); |
221 | } |
222 | mySM->Activate (anInteractive, ActivationMode, myMainVS); |
223 | return Standard_True; |
224 | } |
225 | } |
226 | return Standard_False; |
227 | } |
228 | |
7fd59977 |
229 | Handle(AIS_LocalStatus) Att = new AIS_LocalStatus(); |
230 | |
231 | if(anInteractive->AcceptShapeDecomposition() && AllowShapeDecomposition) |
232 | Att->SetDecomposition(Standard_True); |
233 | else |
234 | Att->SetDecomposition(Standard_False); |
235 | |
236 | if(!myCTX->IsDisplayed(anInteractive)) |
237 | Att->SetTemporary(Standard_True); |
238 | else |
239 | Att->SetTemporary(Standard_False); |
240 | Att->SetDisplayMode(-1); |
241 | |
242 | //storing information.... |
243 | if(ActivationMode!=-1) |
244 | Att->AddSelectionMode(ActivationMode); |
245 | Standard_Integer HiMod = anInteractive->HasHilightMode()? anInteractive->HilightMode():0; |
246 | Att->SetHilightMode(HiMod); |
247 | //Action |
248 | |
249 | mySM->Load(anInteractive,myMainVS); |
250 | if(ActivationMode != -1){ |
251 | mySM->Activate(anInteractive,ActivationMode,myMainVS); |
252 | } |
253 | myActiveObjects.Bind(anInteractive,Att); |
254 | Process(anInteractive); |
255 | return Standard_True; |
256 | } |
257 | |
258 | //======================================================================= |
259 | //function : ClearPrs |
260 | //purpose : |
261 | //======================================================================= |
262 | |
263 | Standard_Boolean AIS_LocalContext:: |
264 | ClearPrs(const Handle(AIS_InteractiveObject)& anInteractive, |
265 | const Standard_Integer aMode) |
266 | { |
267 | if(!myActiveObjects.IsBound(anInteractive)) |
268 | return Standard_False; |
269 | |
270 | Standard_Boolean jobdone(Standard_False); |
271 | const Handle(AIS_LocalStatus)& STAT = myActiveObjects(anInteractive); |
272 | |
273 | //Display step |
274 | if(STAT->IsSubIntensityOn()) { |
275 | STAT->SubIntensityOff(); |
276 | if(STAT->HilightMode()==aMode) |
277 | myMainPM->Unhighlight(anInteractive,STAT->HilightMode()); |
278 | } |
279 | myMainPM->Clear(anInteractive,aMode); // correction connexions 23/09/97 |
280 | jobdone = Standard_True; |
281 | if(STAT->DisplayMode()==aMode) |
282 | STAT->SetDisplayMode(-1); |
283 | return jobdone; |
284 | } |
285 | //======================================================================= |
286 | //function : Erase |
287 | //purpose : |
288 | //======================================================================= |
289 | |
290 | Standard_Boolean AIS_LocalContext:: |
291 | Erase(const Handle(AIS_InteractiveObject)& anInteractive) |
292 | { |
293 | if(!myActiveObjects.IsBound(anInteractive)) |
294 | return Standard_False; |
295 | const Handle(AIS_LocalStatus)& STAT = myActiveObjects(anInteractive); |
296 | |
297 | //Display step |
298 | if(STAT->IsSubIntensityOn()) { |
299 | STAT->SubIntensityOff(); |
300 | myMainPM->Unhighlight(anInteractive,STAT->HilightMode()); |
301 | } |
302 | |
303 | Standard_Boolean status(Standard_False); |
304 | |
305 | if(STAT->DisplayMode()!=-1) { |
306 | if(IsSelected(anInteractive)) |
307 | AddOrRemoveSelected(anInteractive); |
308 | if(myMainPM->IsHighlighted(anInteractive,STAT->HilightMode())) |
309 | myMainPM->Unhighlight(anInteractive,STAT->HilightMode()); |
eb4320f2 |
310 | myMainPM->SetVisibility (anInteractive, STAT->DisplayMode(), Standard_False); |
7fd59977 |
311 | STAT->SetDisplayMode(-1); |
312 | status = Standard_True; |
313 | } |
314 | if(STAT->IsTemporary()){ |
315 | if(myMainPM->IsDisplayed(anInteractive,STAT->HilightMode())) |
eb4320f2 |
316 | myMainPM->SetVisibility (anInteractive, STAT->HilightMode(), Standard_False); |
7fd59977 |
317 | } |
fb4b684a |
318 | |
319 | // Deactivate selectable entities of interactive object |
543a9964 |
320 | const Handle(SelectMgr_SelectableObject)& anObj = anInteractive; // to avoid ambiguity |
321 | if (mySM->Contains (anObj)) |
fb4b684a |
322 | { |
c3282ec1 |
323 | while (!STAT->SelectionModes().IsEmpty()) |
fb4b684a |
324 | { |
c3282ec1 |
325 | mySM->Deactivate (anInteractive, STAT->SelectionModes().Last(), myMainVS); |
326 | STAT->RemoveSelectionMode (STAT->SelectionModes().Last()); |
fb4b684a |
327 | } |
328 | } |
329 | |
bc677575 |
330 | ClearOutdatedSelection (anInteractive, Standard_True); |
fb4b684a |
331 | |
7fd59977 |
332 | return status; |
333 | } |
334 | |
335 | |
336 | //======================================================================= |
337 | //function : SetShapeDecomposition |
338 | //purpose : |
339 | //======================================================================= |
340 | |
341 | void AIS_LocalContext::SetShapeDecomposition(const Handle(AIS_InteractiveObject)& aStoredObject, |
342 | const Standard_Boolean aStatus) |
343 | { |
344 | if(!myActiveObjects.IsBound(aStoredObject)) return; |
345 | |
346 | if(aStatus == myActiveObjects(aStoredObject)->Decomposed()) |
347 | return; |
348 | |
349 | myActiveObjects(aStoredObject)->SetDecomposition(aStatus); |
350 | |
351 | Process(aStoredObject); |
352 | } |
353 | |
354 | //======================================================================= |
355 | //function : Clear |
356 | //purpose : |
357 | //======================================================================= |
358 | |
359 | void AIS_LocalContext::Clear(const AIS_ClearMode aType) |
360 | { |
361 | switch (aType){ |
362 | case AIS_CM_All: |
363 | { |
364 | ClearObjects(); |
365 | myFilters->Clear(); |
366 | while(!myListOfStandardMode.IsEmpty()) |
367 | DeactivateStandardMode(AIS_Shape::SelectionType(myListOfStandardMode.Last())); |
368 | break; |
369 | } |
370 | case AIS_CM_Interactive: |
371 | ClearObjects(); |
372 | break; |
373 | case AIS_CM_Filters: |
374 | myFilters->Clear(); |
375 | break; |
376 | case AIS_CM_StandardModes: |
377 | { |
378 | while(!myListOfStandardMode.IsEmpty()) |
379 | DeactivateStandardMode(AIS_Shape::SelectionType(myListOfStandardMode.Last())); |
380 | break; |
381 | } |
382 | case AIS_CM_TemporaryShapePrs: |
383 | ClearDetected(); |
384 | } |
7fd59977 |
385 | } |
386 | //======================================================================= |
387 | //function : ActivateMode |
388 | //purpose : |
389 | //======================================================================= |
390 | |
391 | void AIS_LocalContext::ActivateMode(const Handle(AIS_InteractiveObject)& aSelectable, |
392 | const Standard_Integer aMode) |
393 | { |
394 | if(!myActiveObjects.IsBound(aSelectable)) return; |
395 | // if(myActiveObjects(aSelectable)->SelectionMode()!=aMode) |
396 | // mySM->Deactivate(aSelectable,aMode,myMainVS); |
397 | if(aMode != -1){ |
398 | myActiveObjects(aSelectable)->AddSelectionMode(aMode); |
399 | mySM->Activate(aSelectable,aMode,myMainVS); |
400 | } |
7fd59977 |
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); |
7fd59977 |
416 | } |
417 | //======================================================================= |
418 | //function : ActivateMode |
419 | //purpose : |
420 | //======================================================================= |
421 | |
422 | void AIS_LocalContext::Deactivate(const Handle(AIS_InteractiveObject)& aSelectable) |
423 | { |
424 | if(!myActiveObjects.IsBound(aSelectable)) return; |
425 | |
f751596e |
426 | mySM->Deactivate(aSelectable, -1, myMainVS); |
7fd59977 |
427 | myActiveObjects(aSelectable)->ClearSelectionModes(); |
7fd59977 |
428 | } |
429 | |
430 | //======================================================================= |
431 | //function : Remove |
432 | //purpose : |
433 | //======================================================================= |
434 | |
435 | Standard_Boolean AIS_LocalContext::Remove(const Handle(AIS_InteractiveObject)& aSelectable) |
436 | { |
7fd6425d |
437 | if(!myActiveObjects.IsBound (aSelectable)) |
438 | { |
439 | return Standard_False; |
440 | } |
441 | |
442 | if (IsSelected (aSelectable)) |
443 | { |
444 | AddOrRemoveSelected (aSelectable, Standard_False); |
445 | } |
446 | |
447 | const Handle(AIS_LocalStatus)& Att = myActiveObjects (aSelectable); |
7fd59977 |
448 | |
7fd59977 |
449 | TColStd_ListIteratorOfListOfInteger It; |
7fd59977 |
450 | |
7fd6425d |
451 | // Deactivate standard modes |
452 | if (Att->Decomposed()) |
453 | { |
454 | for (It.Initialize (myListOfStandardMode); It.More(); It.Next()) |
455 | { |
456 | mySM->Deactivate (aSelectable, It.Value(), myMainVS); |
7fd59977 |
457 | } |
458 | } |
7fd6425d |
459 | |
460 | // If object or temporary presentations |
461 | if (Att->IsTemporary()) |
462 | { |
463 | if (Att->IsSubIntensityOn()) |
7fd59977 |
464 | { |
7fd6425d |
465 | myMainPM->Unhighlight (aSelectable, Att->HilightMode()); |
7fd59977 |
466 | } |
7fd6425d |
467 | |
468 | myMainPM->Erase (aSelectable, Att->DisplayMode()); |
469 | myMainPM->Clear (aSelectable, Att->DisplayMode()); |
470 | if (myMainPM->IsDisplayed (aSelectable, Att->HilightMode())) |
7fd59977 |
471 | { |
7fd6425d |
472 | myMainPM->Erase (aSelectable, Att->HilightMode()); |
7fd59977 |
473 | } |
7fd59977 |
474 | } |
7fd6425d |
475 | // If subintensity used |
476 | else if (Att->IsSubIntensityOn()) |
477 | { |
478 | myCTX->SubIntensityOff (aSelectable); |
479 | } |
7fd59977 |
480 | |
7fd6425d |
481 | // Deactivate stored selection modes |
482 | for (It.Initialize (Att->SelectionModes()); It.More(); It.Next()) |
483 | { |
484 | mySM->Deactivate (aSelectable, It.Value(), myMainVS); |
485 | } |
7fd59977 |
486 | |
fb4b684a |
487 | // Remove the interactive object from selection manager |
543a9964 |
488 | const Handle(SelectMgr_SelectableObject)& anObj = aSelectable; // to avoid ambiguity |
489 | if (mySM->Contains (anObj)) |
7fd59977 |
490 | { |
543a9964 |
491 | mySM->Remove (anObj); |
7fd59977 |
492 | } |
bc677575 |
493 | ClearOutdatedSelection (aSelectable, Standard_True); |
7fd59977 |
494 | |
7fd6425d |
495 | // This should be done at the very end because most methods use |
496 | // myActiveObjects even during clean-up |
497 | myActiveObjects.UnBind (aSelectable); |
7fd59977 |
498 | return Standard_True; |
499 | } |
500 | |
501 | //======================================================================= |
502 | //function : ActivateStandardMode |
503 | //purpose : |
504 | //======================================================================= |
505 | |
506 | void AIS_LocalContext::ActivateStandardMode(const TopAbs_ShapeEnum aType) |
507 | { |
508 | |
81bba717 |
509 | //check if it is not in the list |
7fd59977 |
510 | TColStd_ListIteratorOfListOfInteger It(myListOfStandardMode); |
511 | for(;It.More();It.Next()) |
512 | if(It.Value()==aType) return; |
513 | Standard_Integer IMode = AIS_Shape::SelectionMode(aType); |
514 | |
515 | |
81bba717 |
516 | // create a hidden filter answering ok to the type except for : |
517 | // if the type is shape... |
518 | // if the filters already impact at the type <aType> |
7fd59977 |
519 | if(aType != TopAbs_SHAPE){ |
520 | if(myStdFilters[IMode].IsNull()) |
521 | myStdFilters[IMode] = new StdSelect_ShapeTypeFilter(aType); |
522 | if(!HasFilters(aType)) |
523 | myFilters->Add(myStdFilters[IMode]); |
524 | } |
525 | |
81bba717 |
526 | // the mode is activated for all objects of type Shape |
527 | // accepting the decomposition in standard mode. |
7fd59977 |
528 | myListOfStandardMode.Append(IMode); |
529 | |
530 | AIS_DataMapIteratorOfDataMapOfSelStat ItM(myActiveObjects); |
531 | |
532 | for(;ItM.More();ItM.Next()){ |
7fd59977 |
533 | if(ItM.Value()->Decomposed()) |
7fd59977 |
534 | myCTX->SelectionManager()->Activate(ItM.Key(), |
535 | IMode, |
536 | myMainVS); |
537 | } |
538 | |
539 | } |
540 | |
541 | //======================================================================= |
542 | //function : DeActivateStandardMode |
543 | //purpose : |
544 | //======================================================================= |
545 | |
546 | void AIS_LocalContext::DeactivateStandardMode(const TopAbs_ShapeEnum aType) |
547 | { |
548 | TColStd_ListIteratorOfListOfInteger It(myListOfStandardMode); |
549 | Standard_Integer IMode = AIS_Shape::SelectionMode(aType); |
550 | for(;It.More();It.Next()) |
551 | if(It.Value()==IMode) { |
552 | AIS_DataMapIteratorOfDataMapOfSelStat ItM(myActiveObjects); |
553 | |
554 | for(;ItM.More();ItM.Next()){ |
555 | if(ItM.Value()->Decomposed()){ |
556 | myCTX->SelectionManager()->Deactivate(ItM.Key(), |
557 | IMode, |
558 | myMainVS); |
559 | ItM.Value()->RemoveSelectionMode(IMode); |
560 | } |
561 | } |
562 | myListOfStandardMode.Remove(It); |
563 | if(myFilters->IsIn(myStdFilters[IMode])) |
564 | myFilters->Remove(myStdFilters[IMode]); |
7fd59977 |
565 | return; |
566 | } |
7fd59977 |
567 | } |
568 | |
569 | //======================================================================= |
570 | //function : AddFilter |
571 | //purpose : |
572 | //======================================================================= |
573 | |
574 | void AIS_LocalContext::AddFilter(const Handle(SelectMgr_Filter)& aFilter) |
575 | { |
81bba717 |
576 | // it is checked if the filter impacts at the type of active sub-shape |
577 | // for which a filter of type has been already implemented... |
7fd59977 |
578 | |
579 | TColStd_ListIteratorOfListOfInteger It(myListOfStandardMode); |
580 | |
581 | for(;It.More();It.Next()){ |
582 | if(aFilter->ActsOn(AIS_Shape::SelectionType(It.Value()))) |
583 | if(myFilters->IsIn(myStdFilters[It.Value()])) |
584 | myFilters->Remove(myStdFilters[It.Value()]); |
585 | } |
586 | myFilters->Add(aFilter); |
587 | } |
588 | |
589 | //======================================================================= |
590 | //function : RemoveFilter |
591 | //purpose : |
592 | //======================================================================= |
593 | |
594 | void AIS_LocalContext::RemoveFilter(const Handle(SelectMgr_Filter)& aFilter) |
595 | { |
596 | if(myFilters->IsIn(aFilter)) myFilters->Remove(aFilter); |
597 | |
81bba717 |
598 | // it is checked if the filter for type standard is active. |
599 | // if yes, it is checked there are still similarities among the |
600 | // remaining filters... |
601 | // otherwise, the standard filter is restored to |
602 | // continu selecting active modes... |
7fd59977 |
603 | TColStd_ListIteratorOfListOfInteger It(myListOfStandardMode); |
604 | TopAbs_ShapeEnum SE; |
605 | for(;It.More();It.Next()){ |
606 | SE = AIS_Shape::SelectionType(It.Value()); |
607 | if(aFilter->ActsOn(SE)) |
608 | if(!HasFilters(SE)) |
609 | myFilters->Add(myStdFilters[It.Value()]); |
610 | } |
611 | } |
612 | |
7fd59977 |
613 | //======================================================================= |
614 | //function : Terminate |
679ecdee |
615 | //purpose : |
7fd59977 |
616 | //======================================================================= |
617 | |
679ecdee |
618 | void AIS_LocalContext::Terminate (const Standard_Boolean theToUpdate) |
7fd59977 |
619 | { |
620 | ClearDetected(); |
621 | Clear(); |
b586500b |
622 | myMapOfOwner->Clear(); |
7fd59977 |
623 | |
624 | mylastindex=0; |
81bba717 |
625 | // clear the selector... |
7fd59977 |
626 | myMainVS->Clear(); |
7fd59977 |
627 | |
628 | |
629 | AIS_Selection::SetCurrentSelection(mySelName.ToCString()); |
630 | Handle(AIS_Selection) S = AIS_Selection::CurrentSelection(); |
631 | Handle(Standard_Transient) Tr; |
632 | for(S->Init();S->More();S->Next()){ |
633 | Tr = S->Value(); |
c5f3a425 |
634 | Handle(SelectMgr_EntityOwner)::DownCast (Tr)->SetSelected (Standard_False); |
7fd59977 |
635 | } |
636 | |
637 | |
638 | AIS_Selection::Select(); |
639 | AIS_Selection::Remove(mySelName.ToCString()); |
640 | |
679ecdee |
641 | Handle(V3d_View) aDummyView; |
679ecdee |
642 | myMainVS->ClearSensitive (aDummyView); |
7fd59977 |
643 | |
679ecdee |
644 | if (theToUpdate) |
645 | { |
646 | myCTX->UpdateCurrentViewer(); |
647 | } |
7fd59977 |
648 | } |
649 | |
650 | |
651 | //======================================================================= |
652 | //function : SubIntensity |
653 | //purpose : |
654 | //======================================================================= |
655 | |
656 | void AIS_LocalContext::SubIntensityOn(const Handle(AIS_InteractiveObject)& anObject) |
657 | { |
658 | if(!myActiveObjects.IsBound(anObject)) return; |
659 | |
660 | const Handle(AIS_LocalStatus)& Att = myActiveObjects(anObject); |
661 | |
662 | if(Att->IsTemporary()) |
663 | myMainPM->Color(anObject,myCTX->SubIntensityColor(),Att->DisplayMode()); |
664 | |
665 | Att->SubIntensityOn(); |
666 | } |
667 | //======================================================================= |
668 | //function : SubIntensity |
669 | //purpose : |
670 | //======================================================================= |
671 | |
672 | void AIS_LocalContext::SubIntensityOff(const Handle(AIS_InteractiveObject)& anObject) |
673 | { |
674 | if(!myActiveObjects.IsBound(anObject)) return; |
675 | |
676 | const Handle(AIS_LocalStatus)& Att = myActiveObjects(anObject); |
677 | |
678 | if(Att->IsTemporary()) |
679 | myMainPM->Unhighlight(anObject); |
680 | Att->SubIntensityOff(); |
681 | } |
682 | |
683 | |
684 | //======================================================================= |
685 | //function : Hilight |
686 | //purpose : |
687 | //======================================================================= |
688 | |
689 | void AIS_LocalContext::Hilight(const Handle(AIS_InteractiveObject)& anObject) |
690 | { |
691 | if(!myActiveObjects.IsBound(anObject)){ |
692 | Standard_Integer HiMod = anObject->HasHilightMode()? anObject->HilightMode() : 0; |
693 | Handle(AIS_LocalStatus) Att = new AIS_LocalStatus(Standard_True, |
694 | Standard_False, |
695 | -1,-1,HiMod); |
696 | myActiveObjects.Bind(anObject,Att); |
697 | |
698 | } |
699 | const Handle(AIS_LocalStatus)& Att = myActiveObjects(anObject); |
700 | myMainPM->Color(anObject,myCTX->HilightColor(),Att->HilightMode()); |
701 | Att->SubIntensityOn(); |
702 | } |
703 | //======================================================================= |
704 | //function : Hilight |
705 | //purpose : |
706 | //======================================================================= |
707 | |
708 | void AIS_LocalContext::Hilight(const Handle(AIS_InteractiveObject)& anObject, |
709 | const Quantity_NameOfColor Col) |
710 | { |
711 | if(!myActiveObjects.IsBound(anObject)){ |
712 | Standard_Integer HiMod = anObject->HasHilightMode()? anObject->HilightMode() : 0; |
713 | Handle(AIS_LocalStatus) Att = new AIS_LocalStatus(Standard_True, |
714 | Standard_False, |
715 | -1,-1,HiMod); |
716 | myActiveObjects.Bind(anObject,Att); |
717 | |
718 | } |
719 | const Handle(AIS_LocalStatus)& Att = myActiveObjects(anObject); |
720 | myMainPM->Color(anObject,Col,Att->HilightMode()); |
721 | Att->SubIntensityOn(); |
722 | Att->SetHilightColor(Col); |
723 | } |
724 | |
725 | //======================================================================= |
726 | //function : Unhilight |
727 | //purpose : |
728 | //======================================================================= |
729 | |
730 | void AIS_LocalContext::Unhilight(const Handle(AIS_InteractiveObject)& anObject) |
731 | { |
732 | if(!myActiveObjects.IsBound(anObject)) return; |
733 | |
81bba717 |
734 | // chieck if by hazard the object is somewhere else... |
7fd59977 |
735 | Standard_Integer Indx; |
736 | Standard_Boolean IsSomeWhereElse = |
737 | myCTX->IsInLocal(anObject,Indx) && Indx != myCTX->IndexOfCurrentLocal(); |
738 | |
739 | const Handle(AIS_LocalStatus)& Att = myActiveObjects(anObject); |
740 | myMainPM->Unhighlight(anObject,Att->HilightMode()); |
741 | if(Att->IsTemporary() && Att->DisplayMode()==-1) |
742 | if(!IsSomeWhereElse) |
eb4320f2 |
743 | myMainPM->SetVisibility (anObject, Att->HilightMode(), Standard_False); |
744 | |
7fd59977 |
745 | Att->SubIntensityOff(); |
746 | Att->SetHilightColor(Quantity_NOC_WHITE); |
747 | } |
748 | |
749 | |
750 | //======================================================================= |
751 | //function : IsIn |
752 | //purpose : |
753 | //======================================================================= |
754 | |
755 | Standard_Boolean AIS_LocalContext:: |
756 | IsIn(const Handle(AIS_InteractiveObject)& anObject) const |
757 | { |
758 | return myActiveObjects.IsBound(anObject); |
759 | } |
760 | |
761 | //======================================================================= |
762 | //function : IsHilighted |
763 | //purpose : |
764 | //======================================================================= |
765 | |
766 | Standard_Boolean AIS_LocalContext::IsHilighted(const Handle(AIS_InteractiveObject)& anObject) const |
767 | { |
768 | if(!myActiveObjects.IsBound(anObject)) return Standard_False; |
769 | return myActiveObjects(anObject)->IsSubIntensityOn(); |
770 | } |
771 | |
772 | Standard_Boolean AIS_LocalContext::IsHilighted(const Handle(AIS_InteractiveObject)& anObject, |
773 | Standard_Boolean& WithColor, |
774 | Quantity_NameOfColor& HiCol) const |
775 | { |
776 | if(!myActiveObjects.IsBound(anObject)) return Standard_False; |
777 | if( myActiveObjects(anObject)->IsSubIntensityOn()){ |
778 | HiCol = myActiveObjects(anObject)->HilightColor(); |
779 | if(HiCol==Quantity_NOC_WHITE) |
780 | WithColor = Standard_True; |
781 | else |
782 | WithColor = Standard_False; |
783 | return Standard_True; |
784 | } |
785 | return Standard_False; |
786 | } |
787 | |
788 | |
789 | void AIS_LocalContext::SetDisplayPriority(const Handle(AIS_InteractiveObject)& anObject, |
790 | const Standard_Integer Prior) |
791 | { |
792 | if(!myActiveObjects.IsBound(anObject)) return; |
793 | const Handle(AIS_LocalStatus)& STAT = myActiveObjects(anObject); |
794 | if(STAT->DisplayMode()==-1) return; |
795 | myMainPM->SetDisplayPriority(anObject,STAT->DisplayMode(),Prior); |
796 | if(STAT->IsSubIntensityOn()) |
797 | myMainPM->SetDisplayPriority(anObject,STAT->HilightMode(),Prior); |
798 | |
799 | |
800 | } |
801 | |
7fd59977 |
802 | //======================================================================= |
803 | //function : DisplayedObjects |
804 | //purpose : |
805 | //======================================================================= |
806 | Standard_Integer AIS_LocalContext::DisplayedObjects(TColStd_MapOfTransient& theMap) const |
807 | { |
808 | Standard_Integer NbDisp(0); |
809 | for(AIS_DataMapIteratorOfDataMapOfSelStat it(myActiveObjects);it.More();it.Next()){ |
810 | const Handle(SelectMgr_SelectableObject)& SO = it.Key(); |
811 | if(!theMap.Contains(SO)) |
812 | if(it.Value()->DisplayMode()!=-1){ |
813 | theMap.Add(SO); |
814 | NbDisp++; |
815 | } |
816 | } |
817 | return NbDisp; |
818 | } |
819 | |
820 | |
821 | //======================================================================= |
822 | //function : IsDisplayed |
823 | //purpose : |
824 | //======================================================================= |
825 | |
826 | Standard_Boolean AIS_LocalContext::IsDisplayed(const Handle(AIS_InteractiveObject)& anObject) const |
827 | { |
828 | if(!myActiveObjects.IsBound(anObject)) return Standard_False; |
829 | return (myActiveObjects(anObject)->DisplayMode()!=-1); |
830 | } |
831 | |
832 | //======================================================================= |
833 | //function : IsDisplayed |
834 | //purpose : |
835 | //======================================================================= |
836 | |
837 | Standard_Boolean AIS_LocalContext::IsDisplayed(const Handle(AIS_InteractiveObject)& anObject, |
838 | const Standard_Integer aMode) const |
839 | { |
840 | if(!myActiveObjects.IsBound(anObject)) return Standard_False; |
841 | return (myActiveObjects(anObject)->DisplayMode()==aMode); |
842 | } |
843 | |
844 | //======================================================================= |
845 | //function : SelectionModes |
846 | //purpose : |
847 | //======================================================================= |
848 | |
849 | const TColStd_ListOfInteger& AIS_LocalContext:: |
850 | SelectionModes(const Handle(AIS_InteractiveObject)& anObject) const |
851 | { |
852 | return myActiveObjects(anObject)->SelectionModes(); |
853 | } |
854 | |
855 | //======================================================================= |
856 | //function : Status |
857 | //purpose : |
858 | //======================================================================= |
859 | |
860 | TCollection_AsciiString AIS_LocalContext::Status() const |
861 | { |
862 | TCollection_AsciiString t; |
863 | return t; |
864 | } |
865 | |
866 | const Handle(AIS_LocalStatus)& AIS_LocalContext::Status(const Handle(AIS_InteractiveObject)& anObject) const |
867 | { |
868 | return myActiveObjects(anObject); |
869 | } |
870 | |
871 | //======================================================================= |
872 | //function : LoadContextObjects |
873 | //purpose : |
874 | //======================================================================= |
875 | |
876 | void AIS_LocalContext::LoadContextObjects() |
877 | { |
878 | AIS_ListIteratorOfListOfInteractive It; |
879 | if(myLoadDisplayed) { |
880 | AIS_ListOfInteractive LL; |
881 | myCTX->DisplayedObjects(LL,Standard_True); |
882 | Handle(AIS_LocalStatus) Att; |
883 | for (It.Initialize(LL);It.More();It.Next()){ |
f751596e |
884 | const Handle(AIS_InteractiveObject)& anObj = It.Value(); |
7fd59977 |
885 | Att= new AIS_LocalStatus(); |
f751596e |
886 | Att->SetDecomposition((anObj->AcceptShapeDecomposition() && myAcceptStdMode)); |
7fd59977 |
887 | Att->SetTemporary(Standard_False); |
f751596e |
888 | Att->SetHilightMode(anObj->HasHilightMode()? anObj->HilightMode(): 0); |
889 | for (anObj->Init(); anObj->More(); anObj->Next()) |
890 | { |
891 | const Handle(SelectMgr_Selection)& aSel = anObj->CurrentSelection(); |
892 | aSel->SetSelectionState (SelectMgr_SOS_Deactivated); |
893 | } |
894 | myActiveObjects.Bind(anObj,Att); |
7fd59977 |
895 | } |
896 | } |
897 | } |
898 | |
899 | void AIS_LocalContext::UnloadContextObjects() |
900 | { |
901 | AIS_ListIteratorOfListOfInteractive It; |
902 | if(myLoadDisplayed) |
903 | { |
904 | AIS_ListOfInteractive LL; |
905 | myCTX->DisplayedObjects(LL,Standard_True); |
906 | |
907 | for (It.Initialize(LL);It.More();It.Next()) |
908 | { |
909 | myActiveObjects.UnBind(It.Value()); |
910 | } |
911 | } |
912 | } |
913 | //======================================================================= |
914 | //function : Process |
915 | //purpose : |
916 | //======================================================================= |
917 | |
f751596e |
918 | void AIS_LocalContext::Process(const Handle(SelectMgr_SelectableObject)& anObject) |
7fd59977 |
919 | { |
920 | if(!myActiveObjects.IsBound(anObject)) return; |
921 | if(myActiveObjects(anObject)->Decomposed()) |
f751596e |
922 | ActivateStandardModes(anObject); |
7fd59977 |
923 | else |
924 | { |
925 | TColStd_ListIteratorOfListOfInteger It(myActiveObjects(anObject)->SelectionModes()); |
926 | for(;It.More();It.Next()) |
f751596e |
927 | myCTX->SelectionManager()->Activate(anObject,It.Value(),myMainVS); |
7fd59977 |
928 | } |
929 | } |
930 | |
931 | //======================================================================= |
932 | //function : Process |
933 | //purpose : |
934 | //======================================================================= |
935 | |
f751596e |
936 | void AIS_LocalContext::Process() |
7fd59977 |
937 | { |
938 | |
939 | myMainVS->Clear(); |
940 | |
941 | AIS_DataMapIteratorOfDataMapOfSelStat It(myActiveObjects); |
942 | |
943 | for(;It.More();It.Next()){ |
944 | myCTX->SelectionManager()->Load(It.Key(),myMainVS); |
945 | if(It.Value()->Decomposed()) |
f751596e |
946 | ActivateStandardModes(It.Key()); |
7fd59977 |
947 | else if( myCTX->GetAutoActivateSelection() ) |
948 | { |
949 | It.Value()->AddSelectionMode(0); |
f751596e |
950 | myCTX->SelectionManager()->Activate(It.Key(),0,myMainVS); |
7fd59977 |
951 | } |
952 | } |
953 | |
954 | } |
955 | |
956 | //======================================================================= |
957 | //function : ActivateModes |
958 | //purpose : |
959 | //======================================================================= |
960 | |
f751596e |
961 | void AIS_LocalContext::ActivateStandardModes(const Handle(SelectMgr_SelectableObject)& anObject) |
7fd59977 |
962 | { |
963 | if(!myActiveObjects.IsBound(anObject)) return; |
964 | |
965 | TColStd_ListIteratorOfListOfInteger itl (myListOfStandardMode); |
966 | |
967 | const Handle(AIS_LocalStatus)& LS = myActiveObjects(anObject); |
968 | if(LS->Decomposed()){ |
969 | for(;itl.More();itl.Next()){ |
f751596e |
970 | myCTX->SelectionManager()->Activate(anObject,itl.Value(),myMainVS); |
7fd59977 |
971 | LS->AddSelectionMode(itl.Value()); |
972 | } |
973 | } |
974 | } |
975 | |
976 | |
977 | //======================================================================= |
978 | //function : ClearObjects |
979 | //purpose : |
980 | //======================================================================= |
981 | |
982 | void AIS_LocalContext::ClearObjects() |
983 | { |
984 | AIS_DataMapIteratorOfDataMapOfSelStat It(myActiveObjects); |
985 | for(;It.More();It.Next()) |
986 | { |
987 | Handle(AIS_InteractiveObject) SO = |
988 | Handle(AIS_InteractiveObject)::DownCast(It.Key()); |
989 | |
990 | const Handle(AIS_LocalStatus)& CurAtt = It.Value(); |
991 | //TColStd_ListIteratorOfListOfInteger ItL; |
81bba717 |
992 | // if object is temporary the presentations managed by myMainPM are removed |
7fd59977 |
993 | AIS_DisplayStatus TheDS = myCTX->DisplayStatus(SO); |
994 | |
995 | if(TheDS != AIS_DS_Displayed){ |
996 | if(myMainPM->IsDisplayed(SO,CurAtt->DisplayMode())){ |
997 | if(CurAtt->IsSubIntensityOn()&& |
998 | myMainPM->IsHighlighted(SO,CurAtt->HilightMode())) |
999 | myMainPM->Unhighlight(SO,CurAtt->HilightMode()); |
1000 | myMainPM->Erase(SO,CurAtt->DisplayMode()); |
1001 | } |
1002 | |
1003 | if(CurAtt->IsTemporary()){ |
1004 | myMainPM->Erase(SO,CurAtt->DisplayMode());} |
1005 | // myMainPM->Clear(SO,CurAtt->DisplayMode());} |
1006 | } |
1007 | else { |
1008 | if (CurAtt->IsSubIntensityOn()){ |
1009 | myCTX->SubIntensityOff(Handle(AIS_InteractiveObject)::DownCast(SO));} |
1010 | Standard_Integer DiMo = SO->HasDisplayMode()? |
1011 | SO->DisplayMode():myCTX->DisplayMode(); |
1012 | if(CurAtt->DisplayMode()!=-1 && |
1013 | CurAtt->DisplayMode()!= DiMo) |
1014 | myMainPM->Erase(SO,CurAtt->DisplayMode()); |
1015 | } |
1016 | |
f751596e |
1017 | TColStd_ListIteratorOfListOfInteger aSelModeIter (CurAtt->SelectionModes()); |
1018 | for ( ; aSelModeIter.More(); aSelModeIter.Next()) |
1019 | { |
1020 | Standard_Integer aSelMode = aSelModeIter.Value(); |
1021 | mySM->Deactivate (SO, aSelMode, myMainVS); |
1022 | } |
1023 | |
7fd59977 |
1024 | } |
1025 | ClearSelected( Standard_False ); |
b3c433fe |
1026 | |
1027 | // Clear selection structures for temporary objects, created in local context |
1028 | for (AIS_DataMapIteratorOfDataMapOfSelStat anIter (myActiveObjects); anIter.More(); anIter.Next()) |
1029 | { |
1030 | if (anIter.Value()->IsTemporary()) |
1031 | { |
1032 | mySM->Remove (anIter.Key(), myMainVS); |
1033 | } |
1034 | } |
1035 | |
7fd59977 |
1036 | myActiveObjects.Clear(); |
7fd59977 |
1037 | } |
1038 | |
1039 | |
1040 | Standard_Boolean AIS_LocalContext::IsDecompositionOn() const |
1041 | {return !myListOfStandardMode.IsEmpty();} |
1042 | |
1043 | |
1044 | |
1045 | |
1046 | //======================================================================= |
1047 | //function : HasAlreadyFilters |
1048 | //purpose : |
1049 | //======================================================================= |
1050 | |
1051 | Standard_Boolean AIS_LocalContext:: |
1052 | HasFilters(const TopAbs_ShapeEnum aType) const |
1053 | { |
1054 | return myFilters->ActsOn(aType); |
1055 | } |
1056 | |
1057 | void AIS_LocalContext::ClearDetected() |
1058 | { |
b586500b |
1059 | for(Standard_Integer I=1;I<=myMapOfOwner->Extent();I++) |
eb4320f2 |
1060 | { |
b586500b |
1061 | if(!myMapOfOwner->FindKey (I).IsNull()) |
eb4320f2 |
1062 | { |
b586500b |
1063 | if(myMapOfOwner->FindKey (I)->IsHilighted(myMainPM)) |
1064 | myMapOfOwner->FindKey (I)->Unhilight(myMainPM); |
eb4320f2 |
1065 | else |
1066 | { |
1067 | const Handle(SelectMgr_SelectableObject)& SO = |
b586500b |
1068 | myMapOfOwner->FindKey (I)->Selectable(); |
eb4320f2 |
1069 | if(myActiveObjects.IsBound(SO)) |
1070 | { |
1071 | const Handle(AIS_LocalStatus)& Att = myActiveObjects(SO); |
1072 | |
1073 | if(Att->IsTemporary() && |
1074 | Att->DisplayMode()==-1 && |
1075 | Att->SelectionModes().IsEmpty()) |
1076 | { |
b586500b |
1077 | myMapOfOwner->FindKey (I)->Clear(myMainPM); |
eb4320f2 |
1078 | } |
1079 | } |
7fd59977 |
1080 | } |
1081 | } |
1082 | } |
7fd59977 |
1083 | } |
1084 | |
7fd59977 |
1085 | //======================================================================= |
679ecdee |
1086 | //function : BeginImmediateDraw |
1087 | //purpose : |
7fd59977 |
1088 | //======================================================================= |
679ecdee |
1089 | Standard_Boolean AIS_LocalContext::BeginImmediateDraw() |
7fd59977 |
1090 | { |
679ecdee |
1091 | if (myMainPM->IsImmediateModeOn()) |
1092 | { |
1093 | myMainPM->BeginImmediateDraw(); |
7fd59977 |
1094 | return Standard_True; |
1095 | } |
1096 | return Standard_False; |
1097 | } |
1098 | |
679ecdee |
1099 | //======================================================================= |
1100 | //function : ImmediateAdd |
1101 | //purpose : |
1102 | //======================================================================= |
1103 | Standard_Boolean AIS_LocalContext::ImmediateAdd (const Handle(AIS_InteractiveObject)& theObj, |
1104 | const Standard_Integer theMode) |
7fd59977 |
1105 | { |
679ecdee |
1106 | if (!myMainPM->IsImmediateModeOn()) |
1107 | { |
7fd59977 |
1108 | return Standard_False; |
679ecdee |
1109 | } |
1110 | |
af324faa |
1111 | myMainPM->AddToImmediateList (myMainPM->Presentation (theObj, theMode)->Presentation()); |
7fd59977 |
1112 | return Standard_True; |
1113 | } |
1114 | |
679ecdee |
1115 | //======================================================================= |
1116 | //function : EndImmediateDraw |
1117 | //purpose : |
1118 | //======================================================================= |
c3282ec1 |
1119 | Standard_Boolean AIS_LocalContext::EndImmediateDraw (const Handle(V3d_Viewer)& theViewer) |
7fd59977 |
1120 | { |
679ecdee |
1121 | if (!myMainPM->IsImmediateModeOn()) |
1122 | { |
1123 | return Standard_False; |
1124 | } |
1125 | |
c3282ec1 |
1126 | myMainPM->EndImmediateDraw (theViewer); |
7fd59977 |
1127 | return Standard_True; |
1128 | } |
1129 | |
679ecdee |
1130 | // ======================================================================= |
1131 | // function : ClearImmediateDraw |
1132 | // purpose : |
1133 | // ======================================================================= |
1134 | void AIS_LocalContext::ClearImmediateDraw() |
7fd59977 |
1135 | { |
679ecdee |
1136 | myMainPM->ClearImmediateDraw(); |
7fd59977 |
1137 | } |
1138 | |
679ecdee |
1139 | //======================================================================= |
1140 | //function : IsImmediateModeOn |
1141 | //purpose : |
1142 | //======================================================================= |
7fd59977 |
1143 | Standard_Boolean AIS_LocalContext::IsImmediateModeOn() const |
679ecdee |
1144 | { |
1145 | return myMainPM->IsImmediateModeOn(); |
1146 | } |
7fd59977 |
1147 | |
3bf9a45f |
1148 | void AIS_LocalContext::SetPixelTolerance(const Standard_Integer aPrecision) { |
3c982548 |
1149 | |
1150 | myMainVS->SetPixelTolerance(aPrecision); |
1151 | } |
1152 | |
3bf9a45f |
1153 | Standard_Integer AIS_LocalContext::PixelTolerance() const { |
3c982548 |
1154 | |
1155 | return myMainVS->PixelTolerance(); |
7fd59977 |
1156 | } |
8a1170ad |
1157 | |
1158 | //======================================================================= |
1159 | //function : SetSelectionSensitivity |
1160 | //purpose : Allows to manage sensitivity of a particular selection of interactive object theObject |
1161 | //======================================================================= |
1162 | void AIS_LocalContext::SetSelectionSensitivity (const Handle(AIS_InteractiveObject)& theObject, |
1163 | const Standard_Integer theMode, |
1164 | const Standard_Integer theNewSensitivity) |
1165 | { |
1166 | mySM->SetSelectionSensitivity (theObject, theMode, theNewSensitivity); |
1167 | } |