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