Commit | Line | Data |
---|---|---|
7fd59977 | 1 | // File: AIS_InteractiveContext.cxx |
2 | // Created: Fri Jan 17 13:36:48 1997 | |
3 | // Author: Robert COUBLANC | |
4 | // Modified by XAB & Serguei Dec 97 (angle &deviation coeffts) | |
5 | // <rob@robox.paris1.matra-dtv.fr> | |
6 | ||
7 | #define BUC60577 //GG_101099 Enable to compute correctly | |
8 | // transparency with more than one object in the view. | |
9 | ||
10 | #define GER61351 //GG_171199 Enable to set an object RGB color | |
11 | // instead a restricted object NameOfColor. | |
12 | ||
13 | #define G003 //EUG_26/01/00 Degenerate support (G003) | |
14 | ||
15 | #define IMP140200 //GG Add SetSelectedAspect() method. | |
16 | ||
17 | #define BUC60632 //GG 15/03/00 Add protection on SetDisplayMode() | |
18 | // method, compute only authorized presentation. | |
19 | ||
20 | #define BUC60688 //GG 25/05/00 Add SetSensitivity() methods. | |
21 | ||
22 | #define BUC60722 //GG 04/09/00 Always enable viewer update when erasing something | |
23 | ||
24 | #define IMP051001 //GG Adds SetZDetected() and ZDetected() methods | |
25 | ||
26 | #define OCC172 //SAV clear static map before destroying context. | |
27 | ||
28 | #define OCC204 //SAV 26/02/02 : pass <updateviewer> flag to | |
29 | // AddOrRemoveCurrentObject method from ClearGlobal. | |
30 | ||
31 | #define OCC4373 //SAN 10/11/03 : improve display mode management in | |
32 | // Display( IO, updateviewer ) and | |
33 | // SetDisplayMode( IO, mode, updateviewer ) methods | |
34 | ||
35 | #include <AIS_InteractiveContext.ixx> | |
36 | ||
37 | //#include <AIS_DataMapIteratorOfDataMapOfInteractiveInteger.hxx> | |
38 | #include <TColStd_ListIteratorOfListOfInteger.hxx> | |
39 | #include <TColStd_MapIteratorOfMapOfTransient.hxx> | |
40 | #include <AIS_LocalContext.hxx> | |
41 | #include <AIS_LocalStatus.hxx> | |
42 | #include <Precision.hxx> | |
43 | #include <AIS_Selection.hxx> | |
44 | #include <AIS_DataMapIteratorOfDataMapOfIOStatus.hxx> | |
45 | #include <AIS_ConnectedShape.hxx> | |
46 | #include <AIS_MultipleConnectedShape.hxx> | |
47 | #include <AIS_DataMapIteratorOfDataMapOfILC.hxx> | |
48 | #include <AIS_GlobalStatus.hxx> | |
49 | #include <AIS_MapIteratorOfMapOfInteractive.hxx> | |
50 | #include <PrsMgr_ModedPresentation.hxx> | |
51 | #include <Visual3d_ViewManager.hxx> | |
52 | #include <Prs3d_ShadingAspect.hxx> | |
53 | #include <AIS_Shape.hxx> | |
54 | #include <Graphic3d_AspectFillArea3d.hxx> | |
55 | #include <HLRBRep.hxx> | |
56 | #include <Prs3d_IsoAspect.hxx> | |
57 | #include <Prs3d_DatumAspect.hxx> | |
58 | #include <Prs3d_PlaneAspect.hxx> | |
59 | #include <PrsMgr_PresentableObject.hxx> | |
e33e7e78 | 60 | #include <Standard_Atomic.hxx> |
7fd59977 | 61 | #include <UnitsAPI.hxx> |
62 | ||
63 | #include <AIS_Trihedron.hxx> | |
64 | #include <Geom_Axis2Placement.hxx> | |
65 | #include <OSD_Environment.hxx> | |
66 | ||
67 | #include <AIS_ListIteratorOfListOfInteractive.hxx> | |
68 | ||
69 | // In the method GetDefModes() the returned value of the selection mode | |
70 | // is always equal to 0 if it is -1. | |
71 | #define BUC61051 | |
72 | ||
73 | // On close the local context the method ::ResetOriginalState() sets the selection mode equal to 0 | |
74 | // in spite of the selection mode of the interactive object in Natural Point. | |
75 | #define OCC166 | |
76 | ||
77 | // An interactive Object being erased in the main viewer and put into collector should have the same selection mode. | |
78 | // It impacts the performance! | |
79 | #define OCC328 | |
80 | ||
81 | static Standard_Boolean AISDebugModeOn() | |
82 | { | |
83 | // static OSD_Environment aisdb("AISDEBUGMODE"); | |
84 | // return !aisdb.Value().IsEmpty(); | |
85 | static Standard_Integer isDebugMode(-1); | |
86 | if (isDebugMode < 0) { | |
87 | isDebugMode = 1; | |
88 | OSD_Environment aisdb("AISDEBUGMODE"); | |
89 | if (aisdb.Value().IsEmpty()) | |
90 | isDebugMode = 0; | |
91 | } | |
92 | return (isDebugMode != 0); | |
93 | } | |
94 | ||
e33e7e78 | 95 | namespace |
7fd59977 | 96 | { |
e33e7e78 RK |
97 | static volatile Standard_Integer THE_AIS_INDEX_SEL = 0; |
98 | static volatile Standard_Integer THE_AIS_INDEX_CUR = 0; | |
7fd59977 | 99 | |
e33e7e78 RK |
100 | static TCollection_AsciiString AIS_Context_NewSelName() |
101 | { | |
102 | return TCollection_AsciiString ("AIS_SelContext_") | |
103 | + TCollection_AsciiString (Standard_Atomic_Increment (&THE_AIS_INDEX_SEL)); | |
104 | } | |
7fd59977 | 105 | |
e33e7e78 RK |
106 | static TCollection_AsciiString AIS_Context_NewCurName() |
107 | { | |
108 | return TCollection_AsciiString ("AIS_CurContext_") | |
109 | + TCollection_AsciiString (Standard_Atomic_Increment (&THE_AIS_INDEX_CUR)); | |
110 | } | |
111 | }; | |
7fd59977 | 112 | |
113 | //======================================================================= | |
114 | //function : AIS_InteractiveContext | |
115 | //purpose : | |
116 | //======================================================================= | |
117 | ||
118 | AIS_InteractiveContext::AIS_InteractiveContext(const Handle(V3d_Viewer)& MainViewer): | |
119 | mgrSelector(new SelectMgr_SelectionManager()), | |
120 | myMainPM(new PrsMgr_PresentationManager3d(MainViewer->Viewer())), | |
121 | myMainVwr(MainViewer), | |
122 | myMainSel(new StdSelect_ViewerSelector3d()), | |
123 | myIsCollClosed(Standard_True), | |
124 | myToHilightSelected( Standard_False ), | |
125 | myFilters(new SelectMgr_OrFilter()), | |
126 | myDefaultDrawer(new Prs3d_Drawer()), | |
127 | myDefaultColor(Quantity_NOC_GOLDENROD), | |
128 | myHilightColor(Quantity_NOC_CYAN1), | |
129 | mySelectionColor(Quantity_NOC_GRAY80), | |
130 | myPreselectionColor(Quantity_NOC_GREEN), | |
131 | mySubIntensity(Quantity_NOC_GRAY40), | |
132 | myDisplayMode(0), | |
133 | myCurLocalIndex(0), | |
134 | #ifdef IMP051001 | |
135 | myZDetectionFlag(0), | |
136 | #endif | |
137 | myIsAutoActivateSelMode( Standard_True ) | |
138 | { | |
139 | InitAttributes(); | |
140 | } | |
141 | ||
142 | ||
143 | //======================================================================= | |
144 | //function : AIS_InteractiveContext | |
145 | //purpose : | |
146 | //======================================================================= | |
147 | ||
148 | AIS_InteractiveContext::AIS_InteractiveContext(const Handle(V3d_Viewer)& MainViewer, | |
149 | const Handle(V3d_Viewer)& Collector): | |
150 | mgrSelector(new SelectMgr_SelectionManager()), | |
151 | myMainPM(new PrsMgr_PresentationManager3d(MainViewer->Viewer())), | |
152 | myMainVwr(MainViewer), | |
153 | myMainSel(new StdSelect_ViewerSelector3d()), | |
154 | myCollectorPM(new PrsMgr_PresentationManager3d(Collector->Viewer())), | |
155 | myCollectorVwr(Collector), | |
156 | myCollectorSel(new StdSelect_ViewerSelector3d()), | |
157 | myIsCollClosed(Standard_False), | |
158 | myToHilightSelected( Standard_False ), | |
159 | myFilters(new SelectMgr_OrFilter()), | |
160 | myDefaultDrawer(new Prs3d_Drawer()), | |
161 | myDefaultColor(Quantity_NOC_GOLDENROD), | |
162 | myHilightColor(Quantity_NOC_CYAN1), | |
163 | mySelectionColor(Quantity_NOC_GRAY80), | |
164 | myPreselectionColor(Quantity_NOC_GREEN), | |
165 | mySubIntensity(Quantity_NOC_GRAY40), | |
166 | myDisplayMode(0), | |
167 | myCurLocalIndex(0), | |
168 | #ifdef IMP051001 | |
169 | myZDetectionFlag(0), | |
170 | #endif | |
171 | myIsAutoActivateSelMode( Standard_True ) | |
172 | { | |
173 | InitAttributes(); | |
174 | mgrSelector->Add(myCollectorSel); | |
175 | #ifdef BUC60688 | |
176 | SetSensitivity(); | |
177 | #else | |
178 | myCollectorSel->Set(4); | |
179 | #endif | |
180 | ||
181 | } | |
182 | ||
183 | void AIS_InteractiveContext::Delete() const | |
184 | { | |
185 | #ifdef OCC172 | |
186 | // to avoid an exception | |
187 | if ( AIS_Selection::Find( mySelectionName.ToCString() ) ) | |
188 | AIS_Selection::Remove( mySelectionName.ToCString() ); | |
189 | ||
190 | // to avoid an exception | |
191 | if ( AIS_Selection::Find( myCurrentName.ToCString() ) ) | |
192 | AIS_Selection::Remove( myCurrentName.ToCString() ); | |
193 | ||
194 | // let's remove one reference explicitly. this operation's supposed to | |
195 | // be performed when mgrSelector will be destroyed but anyway... | |
196 | mgrSelector->Remove( myMainSel ); | |
197 | #endif | |
198 | MMgt_TShared::Delete(); | |
199 | } | |
200 | ||
201 | //======================================================================= | |
202 | //function : AIS_SelectionName | |
203 | //purpose : | |
204 | //======================================================================= | |
205 | const TCollection_AsciiString& AIS_InteractiveContext::SelectionName() const | |
206 | { | |
207 | if(!HasOpenedContext()) | |
208 | return mySelectionName; | |
209 | return myLocalContexts(myCurLocalIndex)->SelectionName(); | |
210 | ||
211 | } | |
212 | ||
213 | ||
214 | ||
215 | //======================================================================= | |
216 | //function : UpdateCurrentViewer | |
217 | //purpose : | |
218 | //======================================================================= | |
219 | ||
220 | void AIS_InteractiveContext::UpdateCurrentViewer() | |
221 | { | |
222 | if (!myMainVwr.IsNull()) | |
223 | myMainVwr->Update(); | |
224 | } | |
225 | ||
226 | void AIS_InteractiveContext::OpenCollector() | |
227 | { | |
228 | myIsCollClosed =Standard_True; | |
229 | // a completer.... | |
230 | } | |
231 | ||
232 | ||
233 | ||
234 | //======================================================================= | |
235 | //function : DomainOfMainViewer | |
236 | //purpose : | |
237 | //======================================================================= | |
238 | ||
239 | Standard_CString AIS_InteractiveContext::DomainOfMainViewer() const | |
240 | { | |
241 | return myMainVwr->Domain(); | |
242 | ||
243 | } | |
244 | ||
245 | //======================================================================= | |
246 | //function : DisplayedObjects | |
247 | //purpose : | |
248 | //======================================================================= | |
249 | ||
250 | void AIS_InteractiveContext::DisplayedObjects(AIS_ListOfInteractive& aListOfIO, | |
251 | const Standard_Boolean OnlyFromNeutral) const | |
252 | { | |
253 | #ifdef DEBUG | |
254 | cout<<"AIS_IC::DisplayedObjects"<<endl; | |
255 | #endif | |
256 | ||
257 | AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects); | |
258 | if(!HasOpenedContext() || OnlyFromNeutral){ | |
259 | for(;It.More();It.Next()){ | |
260 | if(It.Value()->GraphicStatus()==AIS_DS_Displayed) | |
261 | aListOfIO.Append(It.Key()); | |
262 | } | |
263 | } | |
264 | else{ | |
265 | TColStd_MapOfTransient theMap; | |
266 | // point neutre | |
267 | for(;It.More();It.Next()){ | |
268 | if(It.Value()->GraphicStatus()==AIS_DS_Displayed) | |
269 | theMap.Add(It.Key()); | |
270 | } | |
271 | #ifdef DEBUG | |
272 | cout<<"\tFrom Neutral Point : "<<theMap.Extent()<<endl; | |
273 | #endif | |
274 | ||
275 | //balayons tous les contextes locaux... | |
276 | Standard_Integer NbDisp; | |
277 | for(AIS_DataMapIteratorOfDataMapOfILC it1(myLocalContexts);it1.More();it1.Next()){ | |
278 | const Handle(AIS_LocalContext)& LC = it1.Value(); | |
279 | NbDisp = LC->DisplayedObjects(theMap); | |
280 | #ifdef DEBUG | |
281 | cout<<"\tIn Local Context "<<it1.Key()<<" : "<<NbDisp<<endl; | |
282 | #endif | |
283 | ||
284 | } | |
285 | Handle(AIS_InteractiveObject) curIO; | |
286 | Handle(Standard_Transient) Tr; | |
287 | for(TColStd_MapIteratorOfMapOfTransient it2(theMap);it2.More();it2.Next()){ | |
288 | Tr = it2.Key(); | |
289 | curIO = *((Handle(AIS_InteractiveObject)*) &Tr); | |
290 | aListOfIO.Append(curIO); | |
291 | } | |
292 | } | |
293 | } | |
294 | //======================================================================= | |
295 | //function : DisplayedObjects | |
296 | //purpose : | |
297 | //======================================================================= | |
298 | ||
299 | void AIS_InteractiveContext::DisplayedObjects(const AIS_KindOfInteractive TheKind, | |
300 | const Standard_Integer TheSign, | |
301 | AIS_ListOfInteractive& aListOfIO, | |
302 | const Standard_Boolean /*OnlyFromNeutral*/) const | |
303 | { | |
304 | ObjectsByDisplayStatus( TheKind, TheSign, AIS_DS_Displayed, aListOfIO ); | |
305 | } | |
306 | ||
307 | //======================================================================= | |
308 | //function : UpdateCollector | |
309 | //purpose : | |
310 | //======================================================================= | |
311 | ||
312 | void AIS_InteractiveContext::UpdateCollector() | |
313 | { | |
314 | if (!myCollectorVwr.IsNull()) | |
315 | myCollectorVwr->Update(); | |
316 | } | |
317 | ||
318 | //======================================================================= | |
319 | //function : DomainOfCollector | |
320 | //purpose : | |
321 | //======================================================================= | |
322 | ||
323 | Standard_CString AIS_InteractiveContext::DomainOfCollector() const | |
324 | { | |
325 | if(myCollectorVwr.IsNull()) return ""; | |
326 | return myCollectorVwr->Domain(); | |
327 | } | |
328 | ||
329 | //======================================================================= | |
330 | //function : ObjectsInCollector | |
331 | //purpose : | |
332 | //======================================================================= | |
333 | ||
334 | void AIS_InteractiveContext::ObjectsInCollector(AIS_ListOfInteractive& aListOfIO) const | |
335 | { | |
336 | ObjectsByDisplayStatus( AIS_DS_Erased, aListOfIO ); | |
337 | } | |
338 | ||
339 | //======================================================================= | |
340 | //function : ObjectsInCollector | |
341 | //purpose : | |
342 | //======================================================================= | |
343 | ||
344 | void AIS_InteractiveContext::ObjectsInCollector(const AIS_KindOfInteractive TheKind, | |
345 | const Standard_Integer TheSign, | |
346 | AIS_ListOfInteractive& aListOfIO) const | |
347 | { | |
348 | ObjectsByDisplayStatus( TheKind, TheSign, AIS_DS_Erased, aListOfIO ); | |
349 | } | |
350 | ||
351 | //======================================================================= | |
352 | //function : ErasedObjects | |
353 | //purpose : | |
354 | //======================================================================= | |
355 | ||
356 | void AIS_InteractiveContext::ErasedObjects(AIS_ListOfInteractive& theListOfIO) const | |
357 | { | |
358 | ObjectsByDisplayStatus( AIS_DS_FullErased, theListOfIO ); | |
359 | } | |
360 | ||
361 | //======================================================================= | |
362 | //function : ErasedObjects | |
363 | //purpose : | |
364 | //======================================================================= | |
365 | ||
366 | void AIS_InteractiveContext::ErasedObjects(const AIS_KindOfInteractive TheKind, | |
367 | const Standard_Integer TheSign, | |
368 | AIS_ListOfInteractive& theListOfIO) const | |
369 | { | |
370 | ObjectsByDisplayStatus( TheKind, TheSign, AIS_DS_FullErased, theListOfIO ); | |
371 | } | |
372 | ||
373 | //======================================================================= | |
374 | //function : ObjectsByDisplayStatus | |
375 | //purpose : | |
376 | //======================================================================= | |
377 | ||
378 | void AIS_InteractiveContext::ObjectsByDisplayStatus(const AIS_DisplayStatus theStatus, | |
379 | AIS_ListOfInteractive& theListOfIO) const | |
380 | { | |
381 | AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects); | |
382 | for(;It.More();It.Next()){ | |
383 | if(It.Value()->GraphicStatus() == theStatus) | |
384 | theListOfIO.Append(It.Key()); | |
385 | } | |
386 | } | |
387 | ||
388 | //======================================================================= | |
389 | //function : ObjectsByDisplayStatus | |
390 | //purpose : | |
391 | //======================================================================= | |
392 | ||
393 | void AIS_InteractiveContext::ObjectsByDisplayStatus(const AIS_KindOfInteractive TheKind, | |
394 | const Standard_Integer TheSign, | |
395 | const AIS_DisplayStatus theStatus, | |
396 | AIS_ListOfInteractive& theListOfIO) const | |
397 | { | |
398 | AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects); | |
399 | for(;It.More();It.Next()){ | |
400 | if(It.Value()->GraphicStatus()==theStatus){ | |
401 | if(It.Key()->Type()==TheKind){ | |
402 | if(TheSign ==-1) | |
403 | theListOfIO.Append(It.Key()); | |
404 | else{ | |
405 | if(It.Key()->Signature()==TheSign) | |
406 | theListOfIO.Append(It.Key()); | |
407 | } | |
408 | } | |
409 | } | |
410 | } | |
411 | } | |
412 | ||
413 | //======================================================================= | |
414 | //function : ObjectsInside | |
415 | //purpose : | |
416 | //======================================================================= | |
417 | ||
418 | void AIS_InteractiveContext::ObjectsInside(AIS_ListOfInteractive& aListOfIO, | |
419 | const AIS_KindOfInteractive TheKind, | |
420 | const Standard_Integer TheSign) const | |
421 | { | |
422 | AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects); | |
423 | if(TheKind==AIS_KOI_None && TheSign ==-1){ | |
424 | for(;It.More();It.Next()){ | |
425 | aListOfIO.Append(It.Key()); | |
426 | } | |
427 | } | |
428 | else{ | |
429 | for(;It.More();It.Next()){ | |
430 | if(It.Key()->Type()==TheKind){ | |
431 | if(TheSign ==-1) | |
432 | aListOfIO.Append(It.Key()); | |
433 | else{ | |
434 | if(It.Key()->Signature()==TheSign) | |
435 | aListOfIO.Append(It.Key()); | |
436 | } | |
437 | } | |
438 | } | |
439 | } | |
440 | } | |
441 | ||
442 | //======================================================================= | |
443 | //function : Display | |
444 | //purpose : | |
445 | //======================================================================= | |
446 | ||
447 | void AIS_InteractiveContext::Display(const Handle(AIS_InteractiveObject)& anIObj, | |
448 | const Standard_Boolean updateviewer ) | |
449 | { | |
450 | if(anIObj.IsNull()) return; | |
451 | ||
452 | Standard_Integer DispMode,HiMod,SelMode; | |
453 | ||
454 | GetDefModes(anIObj,DispMode,HiMod,SelMode); | |
455 | ||
456 | Handle (AIS_InteractiveContext) aThis = this; | |
457 | if(!anIObj->HasInteractiveContext()) | |
458 | anIObj->SetContext(aThis); | |
459 | ||
460 | //PAS DE CONTEXTE LOCAL OUVERT | |
461 | if(!HasOpenedContext()) { | |
462 | #ifndef OCC4373 | |
463 | // SAN : Do not return here. Perform advanced display mode analysis a bit later... | |
464 | if(IsDisplayed(anIObj)) return; | |
465 | #endif | |
466 | Standard_Boolean updcol = Standard_False; | |
467 | ||
468 | // il n'existait pas encore | |
469 | if(!myObjects.IsBound(anIObj)){ | |
470 | ||
471 | Handle(AIS_GlobalStatus) STATUS= | |
472 | #ifdef OCC166 | |
473 | new AIS_GlobalStatus(AIS_DS_Displayed,DispMode,SelMode); | |
474 | #else | |
475 | new AIS_GlobalStatus(AIS_DS_Displayed,DispMode,0); | |
476 | #endif | |
477 | myObjects.Bind (anIObj,STATUS); | |
478 | myMainPM->Display(anIObj,DispMode); | |
479 | if( myIsAutoActivateSelMode ) | |
480 | { | |
481 | if(!mgrSelector->Contains(anIObj)) | |
482 | mgrSelector->Load(anIObj); | |
483 | mgrSelector->Activate(anIObj,SelMode,myMainSel); | |
484 | } | |
485 | ||
486 | if(updateviewer) myMainVwr->Update(); | |
487 | } | |
488 | // il est quelque part ailleurs.... | |
489 | else { | |
490 | // CLE | |
491 | // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj); | |
492 | Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj); | |
493 | // ENDCLE | |
494 | switch (STATUS->GraphicStatus()){ | |
495 | case AIS_DS_Erased:{ | |
496 | if(STATUS->IsHilighted()) | |
497 | myCollectorPM->Unhighlight(anIObj,HiMod); | |
498 | myCollectorPM->Erase(anIObj,HiMod); | |
499 | mgrSelector->Deactivate(anIObj,myCollectorSel); | |
500 | updcol = updateviewer; | |
501 | }// attention on fait expres de ne pas mettre de break.. | |
502 | case AIS_DS_FullErased:{ | |
e33e7e78 RK |
503 | TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes()); |
504 | for (;ItL.More();ItL.Next()){ | |
7fd59977 | 505 | myMainPM->Display(anIObj,ItL.Value()); |
506 | if(STATUS->IsSubIntensityOn()) | |
507 | myMainPM->Color(anIObj,mySubIntensity,ItL.Value()); | |
508 | } | |
509 | if( myIsAutoActivateSelMode ) | |
510 | for (ItL.Initialize(STATUS->SelectionModes());ItL.More();ItL.Next()) | |
511 | mgrSelector->Activate(anIObj,ItL.Value(),myMainSel); | |
512 | STATUS->SetGraphicStatus(AIS_DS_Displayed); | |
513 | if(STATUS->IsHilighted()) | |
514 | myMainPM->Highlight(anIObj,HiMod); | |
515 | break; | |
516 | } | |
517 | #ifdef OCC4373 | |
518 | // SAN : erase presentations for all display modes different from <DispMode>; | |
519 | // then make sure <DispMode> is displayed and maybe highlighted; | |
520 | // Finally, activate selection mode <SelMode> if not yet activated. | |
521 | case AIS_DS_Displayed:{ | |
522 | TColStd_ListOfInteger aModesToRemove; | |
e33e7e78 RK |
523 | TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes()); |
524 | for(;ItL.More();ItL.Next()){ | |
7fd59977 | 525 | |
526 | Standard_Integer OldMode = ItL.Value(); | |
527 | ||
528 | if(OldMode!=DispMode){ | |
529 | aModesToRemove.Append(OldMode); | |
530 | if(myMainPM->IsHighlighted(anIObj,OldMode)) | |
531 | myMainPM->Unhighlight(anIObj,OldMode); | |
532 | myMainPM->Erase(anIObj,OldMode); | |
533 | } | |
534 | } | |
535 | ||
536 | for(ItL.Initialize(aModesToRemove);ItL.More();ItL.Next()) | |
537 | STATUS->RemoveDisplayMode(ItL.Value()); | |
538 | ||
539 | if(!STATUS->IsDModeIn(DispMode)) | |
540 | STATUS->AddDisplayMode(DispMode); | |
541 | ||
542 | myMainPM->Display(anIObj,DispMode); | |
543 | if(STATUS->IsHilighted()){ | |
544 | myMainPM->Highlight(anIObj,HiMod); | |
545 | } | |
546 | if( myIsAutoActivateSelMode ) | |
547 | { | |
548 | if(!mgrSelector->Contains(anIObj)) | |
549 | mgrSelector->Load(anIObj); | |
550 | if(!mgrSelector->IsActivated(anIObj,SelMode)) | |
551 | mgrSelector->Activate(anIObj,SelMode,myMainSel); | |
552 | } | |
553 | ||
554 | break; | |
555 | } | |
556 | #endif | |
557 | default: | |
558 | break; | |
559 | } | |
560 | } | |
561 | ||
562 | if(anIObj->IsTransparent() && !myMainVwr->Viewer()->Transparency()) | |
563 | myMainVwr->Viewer()->SetTransparency(Standard_True); | |
564 | if(updateviewer) myMainVwr->Update(); | |
565 | if(updcol && !myCollectorVwr.IsNull()) myCollectorVwr->Update(); | |
566 | } | |
567 | ||
568 | // CONTEXTE LOCAL OUVERT | |
569 | else | |
570 | { | |
571 | myLocalContexts(myCurLocalIndex)->Display(anIObj,DispMode,anIObj->AcceptShapeDecomposition(),SelMode); | |
572 | ||
573 | if(anIObj->IsTransparent() && !myMainVwr->Viewer()->Transparency()) | |
574 | myMainVwr->Viewer()->SetTransparency(Standard_True); | |
575 | ||
576 | ||
577 | if(updateviewer) myMainVwr->Update(); | |
578 | } | |
579 | } | |
580 | ||
581 | //======================================================================= | |
582 | //function : Display | |
583 | //purpose : | |
584 | //======================================================================= | |
585 | ||
586 | void AIS_InteractiveContext::Display(const Handle(AIS_InteractiveObject)& anIObj, | |
587 | const Standard_Integer aDisplayMode, | |
588 | const Standard_Integer aSelectionMode, | |
589 | const Standard_Boolean updateviewer, | |
590 | const Standard_Boolean allowdecomposition) | |
591 | { | |
592 | if(anIObj.IsNull()) return; | |
593 | ||
594 | if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this); | |
595 | ||
596 | // si aucun contexte local... | |
597 | if(!HasOpenedContext()) { | |
598 | // if(!anIObj->HasDisplayMode()) | |
599 | // anIObj->SetDisplayMode(aDisplayMode); | |
600 | ||
601 | if(!myObjects.IsBound(anIObj)){ | |
602 | Handle(AIS_GlobalStatus) STATUS= | |
603 | new AIS_GlobalStatus(AIS_DS_Displayed,aDisplayMode,aSelectionMode); | |
604 | myObjects.Bind (anIObj,STATUS); | |
605 | myMainPM->Display(anIObj,aDisplayMode); | |
606 | if(aSelectionMode!=-1){ | |
607 | if(!mgrSelector->Contains(anIObj)) | |
608 | mgrSelector->Load(anIObj,aSelectionMode); | |
609 | mgrSelector->Activate(anIObj,aSelectionMode,myMainSel); | |
610 | } | |
611 | if(updateviewer) myMainVwr->Update(); | |
612 | } | |
613 | // anIObj->SelectionMode(aSelectionMode); | |
614 | else{ | |
615 | // CLE | |
616 | // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj); | |
617 | Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj); | |
618 | // ENDCLE | |
619 | if(!STATUS->IsDModeIn(aDisplayMode)){ | |
620 | myMainPM->Display(anIObj,aDisplayMode); | |
621 | STATUS->AddDisplayMode(aDisplayMode); | |
622 | if(STATUS->IsSubIntensityOn()) | |
623 | myMainPM->Color(anIObj,mySubIntensity,aDisplayMode); | |
624 | } | |
625 | if(aSelectionMode!=-1){ | |
626 | STATUS->AddSelectionMode(aSelectionMode); | |
627 | mgrSelector->Activate(anIObj,aSelectionMode,myMainSel); | |
628 | } | |
629 | if(updateviewer) myMainVwr->Update(); | |
630 | ||
631 | } | |
632 | } | |
633 | else | |
634 | { | |
635 | myLocalContexts(myCurLocalIndex)->Display(anIObj,aDisplayMode,allowdecomposition,aSelectionMode); | |
636 | if(updateviewer) myMainVwr->Update(); | |
637 | } | |
638 | } | |
639 | ||
640 | ||
641 | //======================================================================= | |
642 | //function : Load | |
643 | //purpose : | |
644 | //======================================================================= | |
645 | ||
646 | void AIS_InteractiveContext::Load(const Handle(AIS_InteractiveObject)& anIObj, | |
647 | const Standard_Integer SelMode, | |
648 | const Standard_Boolean AllowDecomposition) | |
649 | { | |
650 | if(anIObj.IsNull()) return; | |
651 | if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this); | |
652 | ||
653 | ||
654 | if(!HasOpenedContext()) { | |
655 | if(SelMode==-1 && !AllowDecomposition){ | |
656 | Standard_Integer DispMode,HiMod,SelModeDef; | |
657 | ||
658 | GetDefModes(anIObj,DispMode,HiMod,SelModeDef); | |
659 | Handle(AIS_GlobalStatus) STATUS= | |
660 | new AIS_GlobalStatus(AIS_DS_FullErased,DispMode,SelModeDef); | |
661 | myObjects.Bind (anIObj,STATUS); | |
662 | return; | |
663 | } | |
664 | } | |
665 | myLocalContexts(myCurLocalIndex)->Load(anIObj,AllowDecomposition,SelMode); | |
666 | } | |
667 | ||
668 | ||
669 | //======================================================================= | |
670 | //function : Erase | |
671 | //purpose : | |
672 | //======================================================================= | |
673 | ||
674 | void AIS_InteractiveContext::Erase(const Handle(AIS_InteractiveObject)& anIObj, | |
675 | const Standard_Boolean updateviewer, | |
676 | const Standard_Boolean PutInCollector) | |
677 | { | |
678 | if(anIObj.IsNull()) return; | |
679 | ||
680 | if ( !anIObj->IsAutoHilight() ) | |
681 | anIObj->ClearSelected(); | |
682 | ||
683 | if(!HasOpenedContext()){ | |
684 | EraseGlobal(anIObj,updateviewer,PutInCollector); | |
685 | } | |
686 | else | |
687 | { | |
688 | // d'abors on regarde si on peut effacer dans le contexte local courant | |
689 | // ensuite, on essaye d'effacer dans les autres contextes locaux, | |
690 | // s'ils le permettent... | |
691 | ||
692 | Standard_Boolean WasInCtx = myLocalContexts(myCurLocalIndex)->Erase(anIObj); | |
693 | // if(!WasInCtx) { | |
694 | AIS_DataMapIteratorOfDataMapOfILC It(myLocalContexts); | |
695 | for (;It.More();It.Next()){ | |
696 | if(It.Value()->AcceptErase()) | |
697 | #ifdef BUC60722 | |
698 | WasInCtx |= It.Value()->Erase(anIObj); | |
699 | #else | |
700 | WasInCtx = It.Value()->Erase(anIObj); | |
701 | #endif | |
702 | } | |
703 | ||
704 | if(!WasInCtx) | |
705 | EraseGlobal(anIObj,updateviewer,PutInCollector); | |
706 | else | |
707 | if(updateviewer) myMainVwr->Update(); | |
708 | } | |
709 | } | |
710 | //======================================================================= | |
711 | //function : Erase | |
712 | //purpose : | |
713 | //======================================================================= | |
714 | ||
715 | void AIS_InteractiveContext::EraseMode(const Handle(AIS_InteractiveObject)& anIObj, | |
716 | const Standard_Integer aMode, | |
717 | const Standard_Boolean /*updateviewer*/) | |
718 | { | |
719 | if(anIObj.IsNull()) return; | |
720 | ||
721 | if(!myObjects.IsBound(anIObj)) return; | |
722 | ||
723 | if(anIObj->HasDisplayMode()){ | |
724 | if(anIObj->DisplayMode()==aMode) return; | |
725 | } | |
726 | else if(myDisplayMode==aMode) return; | |
727 | // CLE | |
728 | // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj); | |
729 | Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj); | |
730 | // ENDCLE | |
731 | if(STATUS->GraphicStatus()!=AIS_DS_Displayed) return; | |
732 | ||
733 | ||
734 | // if(STATUS->IsDModeIn(aMode)) {} | |
735 | } | |
736 | ||
737 | ||
738 | ||
739 | //======================================================================= | |
740 | //function : EraseAll | |
741 | //purpose : | |
742 | //======================================================================= | |
743 | ||
744 | void AIS_InteractiveContext::EraseAll(const Standard_Boolean PutInCollector, | |
745 | const Standard_Boolean updateviewer) | |
746 | { | |
747 | if(!HasOpenedContext()){ | |
748 | AIS_DataMapIteratorOfDataMapOfIOStatus ItM(myObjects); | |
749 | ||
750 | for(;ItM.More();ItM.Next()){ | |
751 | if(ItM.Value()->GraphicStatus() == AIS_DS_Displayed) | |
752 | Erase(ItM.Key(),Standard_False,PutInCollector); | |
753 | } | |
754 | if(updateviewer){ | |
755 | myMainVwr->Update(); | |
756 | if (PutInCollector && !myCollectorVwr.IsNull()) | |
757 | myCollectorVwr->Update(); | |
758 | } | |
759 | } | |
760 | ||
761 | } | |
762 | ||
763 | //======================================================================= | |
764 | //function : DisplayAll | |
765 | //purpose : | |
766 | //======================================================================= | |
767 | ||
768 | void AIS_InteractiveContext::DisplayAll(const Standard_Boolean OnlyFromCollector, | |
769 | const Standard_Boolean updateviewer) | |
770 | { | |
771 | if(!HasOpenedContext()){ | |
772 | Standard_Boolean FoundInCollector(Standard_False); | |
773 | AIS_DisplayStatus aDStatus = OnlyFromCollector ? AIS_DS_Erased : AIS_DS_FullErased,TheStatus; | |
774 | ||
775 | if(!HasOpenedContext()){ | |
776 | AIS_DataMapIteratorOfDataMapOfIOStatus ItM(myObjects); | |
777 | ||
778 | for(;ItM.More();ItM.Next()){ | |
779 | TheStatus = ItM.Value()->GraphicStatus(); | |
780 | if(TheStatus == aDStatus) | |
781 | Display(ItM.Key(),Standard_False); | |
782 | if(TheStatus == AIS_DS_Erased) | |
783 | FoundInCollector = Standard_True; | |
784 | } | |
785 | if(updateviewer){ | |
786 | myMainVwr->Update(); | |
787 | if(FoundInCollector && !myCollectorVwr.IsNull()) | |
788 | myCollectorVwr->Update(); | |
789 | } | |
790 | } | |
791 | } | |
792 | ||
793 | } | |
794 | ||
795 | //======================================================================= | |
796 | //function : DisplaySelected | |
797 | //purpose : | |
798 | //======================================================================= | |
799 | ||
800 | void AIS_InteractiveContext::DisplaySelected(const Standard_Boolean updateviewer) | |
801 | { | |
802 | ||
803 | if(!HasOpenedContext()){ | |
804 | Standard_Boolean found = Standard_False; | |
805 | Handle(AIS_Selection) sel = AIS_Selection::Selection(myCurrentName.ToCString()); | |
806 | Handle(AIS_InteractiveObject) iObj; | |
807 | for (sel->Init();sel->More();sel->Next()) { | |
808 | iObj = Handle(AIS_InteractiveObject)::DownCast(sel->Value()); | |
809 | Display(iObj,Standard_False); | |
810 | found = Standard_True; | |
811 | } | |
812 | if(found && updateviewer) { | |
813 | myMainVwr->Update(); | |
814 | if(!(myIsCollClosed && myCollectorVwr.IsNull())) | |
815 | ||
816 | myCollectorVwr->Update(); | |
817 | } | |
818 | } | |
819 | } | |
820 | ||
821 | ||
822 | //======================================================================= | |
823 | //function : EraseSelected | |
824 | //purpose : | |
825 | //======================================================================= | |
826 | ||
827 | void AIS_InteractiveContext::EraseSelected(const Standard_Boolean PutInCollector, | |
828 | const Standard_Boolean updateviewer) | |
829 | { | |
830 | ||
831 | if(!HasOpenedContext()){ | |
832 | Standard_Boolean found = Standard_False; | |
833 | Handle(AIS_Selection) sel = AIS_Selection::Selection(myCurrentName.ToCString()); | |
834 | Handle(AIS_InteractiveObject) iObj; | |
835 | for(sel->Init();sel->More();sel->Next()) { | |
836 | iObj = Handle(AIS_InteractiveObject)::DownCast(sel->Value()); | |
837 | Erase(iObj,Standard_False,PutInCollector); | |
838 | found = Standard_True; | |
839 | } | |
840 | if(found && updateviewer) { | |
841 | myMainVwr->Update(); | |
842 | if(PutInCollector && !myCollectorVwr.IsNull()) | |
843 | myCollectorVwr->Update(); | |
844 | } | |
845 | } | |
846 | } | |
847 | //======================================================================= | |
848 | //function : | |
849 | //purpose : | |
850 | //======================================================================= | |
851 | ||
852 | Standard_Boolean AIS_InteractiveContext::KeepTemporary(const Handle(AIS_InteractiveObject)& anIObj, | |
853 | const Standard_Integer WhichContext) | |
854 | { | |
855 | if(anIObj.IsNull()) return Standard_False; | |
856 | ||
857 | if(!HasOpenedContext()) return Standard_False; | |
858 | if(myObjects.IsBound(anIObj)) return Standard_False; | |
859 | if(WhichContext!=-1 && !myLocalContexts.IsBound(WhichContext)) return Standard_False; | |
860 | ||
81bba717 | 861 | // Protection : if one tries to preserve a temporary object |
862 | // which is not in the local active context... rob 11-06-97 | |
7fd59977 | 863 | |
864 | Standard_Integer IsItInLocal = myCurLocalIndex; | |
865 | Standard_Boolean Found(Standard_False); | |
866 | ||
867 | while(IsItInLocal>0 && !Found){ | |
868 | if(!myLocalContexts.IsBound(IsItInLocal)) | |
869 | IsItInLocal--; | |
870 | else if(myLocalContexts(IsItInLocal)->IsIn(anIObj)) | |
871 | Found = Standard_True; | |
872 | else | |
873 | IsItInLocal--; | |
874 | } | |
875 | ||
876 | if(!Found) return Standard_False; | |
877 | ||
878 | ||
879 | // const Handle(AIS_LocalStatus)& LS = (WhichContext== -1) ? | |
880 | // myLocalContexts(IsItInLocal)->Status(anIObj):myLocalContexts(WhichContext)->Status(anIObj); | |
881 | // CLE | |
882 | // const Handle(AIS_LocalStatus)& LS = myLocalContexts(IsItInLocal)->Status(anIObj); | |
883 | Handle(AIS_LocalStatus) LS = myLocalContexts(IsItInLocal)->Status(anIObj); | |
884 | // ENDCLE | |
885 | ||
886 | ||
887 | if(LS->IsTemporary()){ | |
888 | Standard_Integer DM,HM,SM; | |
889 | GetDefModes(anIObj,DM,HM,SM); | |
890 | ||
891 | SM = LS->SelectionModes().IsEmpty() ? SM : LS->SelectionModes().First(); | |
892 | if(LS->DisplayMode()!= DM ){ | |
893 | Standard_Integer LSM = LS->SelectionModes().IsEmpty() ? -1 : LS->SelectionModes().First(); | |
894 | myLocalContexts(IsItInLocal)->Display(anIObj,DM,LS->Decomposed(),LSM); | |
895 | } | |
896 | ||
897 | Handle (AIS_GlobalStatus) GS = new AIS_GlobalStatus(AIS_DS_Displayed, | |
898 | DM, | |
899 | SM, | |
900 | Standard_False); | |
901 | // GS->SubIntensityOn(); | |
902 | myObjects.Bind(anIObj,GS); | |
903 | mgrSelector->Load(anIObj); | |
904 | mgrSelector->Activate(anIObj,SM,myMainSel); | |
905 | ||
906 | LS->SetTemporary(Standard_False); | |
907 | } | |
908 | return Standard_True; | |
909 | } | |
910 | ||
911 | ||
912 | //======================================================================= | |
913 | //purpose : | |
914 | //======================================================================= | |
915 | ||
916 | AIS_DisplayStatus AIS_InteractiveContext::DisplayStatus(const Handle(AIS_InteractiveObject)& anIObj) const | |
917 | { | |
918 | if(anIObj.IsNull()) return AIS_DS_None; | |
919 | ||
920 | if(myObjects.IsBound(anIObj)) | |
921 | return myObjects(anIObj)->GraphicStatus(); | |
922 | ||
923 | AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts); | |
924 | for(;ItM.More();ItM.Next()){ | |
925 | if(ItM.Value()->IsIn(anIObj)) | |
926 | return AIS_DS_Temporary; | |
927 | } | |
928 | ||
929 | return AIS_DS_None; | |
930 | ||
931 | } | |
932 | ||
933 | ||
934 | ||
935 | ||
936 | //======================================================================= | |
937 | //function : DisplayedModes | |
938 | //purpose : | |
939 | //======================================================================= | |
940 | ||
941 | const TColStd_ListOfInteger& AIS_InteractiveContext:: | |
942 | DisplayedModes(const Handle(AIS_InteractiveObject)& anIObj) const | |
943 | { | |
944 | return myObjects(anIObj)->DisplayedModes(); | |
945 | } | |
946 | ||
947 | ||
948 | //======================================================================= | |
949 | //function : Remove | |
950 | //purpose : | |
951 | //======================================================================= | |
952 | void AIS_InteractiveContext::Remove(const Handle(AIS_InteractiveObject)& anIObj, | |
953 | const Standard_Boolean updateviewer) | |
954 | { | |
955 | ||
956 | if(anIObj.IsNull()) return; | |
957 | ||
958 | if(!HasOpenedContext()){ | |
959 | ClearGlobal(anIObj,updateviewer); | |
960 | } | |
961 | else | |
962 | { | |
963 | Standard_Boolean WasInCtx = myLocalContexts(myCurLocalIndex)->Remove(anIObj); | |
964 | AIS_DataMapIteratorOfDataMapOfILC It(myLocalContexts); | |
965 | for (;It.More() ;It.Next()){ | |
966 | if(It.Value()->AcceptErase()) | |
967 | WasInCtx = It.Value()->Remove(anIObj); | |
968 | ||
969 | } | |
970 | // if(!WasInCtx) | |
971 | ClearGlobal(anIObj,updateviewer); | |
972 | // else | |
973 | // if(updateviewer) myMainVwr->Update(); | |
974 | } | |
975 | } | |
976 | ||
977 | //======================================================================= | |
978 | //function : RemoveAll | |
979 | //purpose : | |
980 | //======================================================================= | |
981 | void AIS_InteractiveContext::RemoveAll(const Standard_Boolean updateviewer) | |
982 | { | |
983 | AIS_ListOfInteractive aList; | |
984 | ObjectsInside(aList); | |
985 | AIS_ListIteratorOfListOfInteractive aListIterator; | |
986 | for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){ | |
987 | Remove(aListIterator.Value(), Standard_False); | |
988 | } | |
989 | ||
990 | if(updateviewer) | |
991 | myMainVwr->Update(); | |
992 | } | |
993 | ||
994 | //======================================================================= | |
995 | //function : Clear | |
996 | //purpose : | |
997 | //======================================================================= | |
998 | ||
999 | void AIS_InteractiveContext::Clear(const Handle(AIS_InteractiveObject)& anIObj, | |
1000 | const Standard_Boolean updateviewer) | |
1001 | { | |
1002 | if(anIObj.IsNull()) return; | |
1003 | ||
1004 | if(!HasOpenedContext()){ | |
1005 | ClearGlobal(anIObj,updateviewer); | |
1006 | } | |
1007 | else | |
1008 | { | |
1009 | ||
1010 | Standard_Boolean WasInCtx = myLocalContexts(myCurLocalIndex)->Remove(anIObj); | |
1011 | AIS_DataMapIteratorOfDataMapOfILC It(myLocalContexts); | |
1012 | for (;It.More() ;It.Next()){ | |
1013 | if(It.Value()->AcceptErase()) | |
1014 | WasInCtx = It.Value()->Remove(anIObj); | |
1015 | ||
1016 | } | |
1017 | if(!WasInCtx) | |
1018 | ClearGlobal(anIObj,updateviewer); | |
1019 | else | |
1020 | if(updateviewer) myMainVwr->Update(); | |
1021 | } | |
1022 | } | |
1023 | ||
1024 | ||
1025 | ||
1026 | ||
1027 | //======================================================================= | |
1028 | //function : ClearPrs | |
1029 | //purpose : | |
1030 | //======================================================================= | |
1031 | ||
1032 | void AIS_InteractiveContext::ClearPrs(const Handle(AIS_InteractiveObject)& anIObj, | |
1033 | const Standard_Integer aMode, | |
1034 | const Standard_Boolean updateviewer) | |
1035 | { | |
1036 | if(anIObj.IsNull()) return; | |
1037 | ||
1038 | if(!HasOpenedContext()){ | |
1039 | ClearGlobalPrs(anIObj,aMode,updateviewer); | |
1040 | } | |
1041 | else | |
1042 | { | |
1043 | Standard_Boolean WasInCtx = myLocalContexts(myCurLocalIndex)->ClearPrs(anIObj,aMode); | |
1044 | AIS_DataMapIteratorOfDataMapOfILC It(myLocalContexts); | |
1045 | for (;It.More() ;It.Next()){ | |
1046 | if(It.Value()->AcceptErase()) | |
1047 | WasInCtx = It.Value()->ClearPrs(anIObj,aMode); | |
1048 | } | |
1049 | if(!WasInCtx) | |
1050 | ClearGlobalPrs(anIObj,aMode,updateviewer); | |
1051 | else | |
1052 | if(updateviewer) myMainVwr->Update(); | |
1053 | ||
1054 | } | |
1055 | } | |
1056 | ||
1057 | //======================================================================= | |
1058 | //function : Hilight | |
1059 | //purpose : | |
1060 | //======================================================================= | |
1061 | ||
1062 | void AIS_InteractiveContext::Hilight(const Handle(AIS_InteractiveObject)& anIObj, | |
1063 | const Standard_Boolean updateviewer) | |
1064 | { | |
1065 | if(anIObj.IsNull()) return; | |
1066 | ||
1067 | if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this); | |
1068 | if (!HasOpenedContext()) | |
1069 | { | |
1070 | if(!myObjects.IsBound(anIObj)) return; | |
1071 | ||
1072 | // CLE | |
1073 | // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj); | |
1074 | // const TColStd_ListOfInteger& LL = STATUS->DisplayedModes(); | |
1075 | Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj); | |
1076 | ||
1077 | // ENDCLE | |
1078 | STATUS->SetHilightStatus (Standard_True); | |
1079 | ||
1080 | switch(STATUS->GraphicStatus()){ | |
1081 | case AIS_DS_Displayed: | |
1082 | { | |
1083 | Standard_Integer DispMode,HiMode,SelMode; | |
1084 | GetDefModes(anIObj,DispMode,HiMode,SelMode); | |
1085 | // if(!STATUS->IsDModeIn(HiMode)){ | |
1086 | // myMainPM->Display(anIObj,HiMode); | |
1087 | // } | |
1088 | myMainPM->Highlight(anIObj,HiMode); | |
1089 | if(updateviewer) myMainVwr->Update(); | |
1090 | break; | |
1091 | } | |
1092 | case AIS_DS_Erased: | |
1093 | { | |
1094 | Standard_Integer HiMode = anIObj->HasHilightMode()? anIObj->HilightMode():0; | |
1095 | myCollectorPM->Highlight(anIObj,HiMode); | |
1096 | if(updateviewer) myCollectorVwr->Update(); | |
1097 | break; | |
1098 | } | |
1099 | default: | |
1100 | break; | |
1101 | } | |
1102 | } | |
1103 | else | |
1104 | myLocalContexts(myCurLocalIndex)->Hilight(anIObj); | |
1105 | if(updateviewer) myMainVwr->Update(); | |
1106 | } | |
1107 | //======================================================================= | |
1108 | //function : Hilight | |
1109 | //purpose : | |
1110 | //======================================================================= | |
1111 | ||
1112 | void AIS_InteractiveContext::HilightWithColor(const Handle(AIS_InteractiveObject)& anIObj, | |
1113 | const Quantity_NameOfColor aCol, | |
1114 | const Standard_Boolean updateviewer) | |
1115 | { | |
1116 | if(anIObj.IsNull()) return; | |
1117 | ||
1118 | if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this); | |
1119 | ||
1120 | if (!HasOpenedContext()) | |
1121 | { | |
1122 | if(!myObjects.IsBound(anIObj)) return; | |
1123 | ||
1124 | const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj); | |
1125 | STATUS->SetHilightStatus (Standard_True); | |
1126 | ||
1127 | switch(STATUS->GraphicStatus()){ | |
1128 | case AIS_DS_Displayed: | |
1129 | { | |
1130 | Standard_Integer DispMode,HiMode,SelMode; | |
1131 | GetDefModes(anIObj,DispMode,HiMode,SelMode); | |
1132 | // if(!STATUS->IsDModeIn(HiMode)){ | |
1133 | // myMainPM->Display(anIObj,HiMode); | |
1134 | // } | |
1135 | myMainPM->Color(anIObj,aCol,HiMode); | |
1136 | STATUS->SetHilightColor(aCol); | |
1137 | if(updateviewer) myMainVwr->Update(); | |
1138 | break; | |
1139 | } | |
1140 | case AIS_DS_Erased: | |
1141 | { | |
1142 | Standard_Integer HiMode = anIObj->HasHilightMode()? anIObj->HilightMode():0; | |
1143 | myCollectorPM->Color(anIObj,aCol,HiMode); | |
1144 | if(updateviewer) myCollectorVwr->Update(); | |
1145 | break; | |
1146 | } | |
1147 | default: | |
1148 | break; | |
1149 | } | |
1150 | } | |
1151 | else | |
1152 | myLocalContexts(myCurLocalIndex)->Hilight(anIObj,aCol); | |
1153 | if(updateviewer) myMainVwr->Update(); | |
1154 | } | |
1155 | ||
1156 | //======================================================================= | |
1157 | //function : Unhilight | |
1158 | //purpose : | |
1159 | //======================================================================= | |
1160 | ||
1161 | void AIS_InteractiveContext::Unhilight(const Handle(AIS_InteractiveObject)& anIObj, const Standard_Boolean updateviewer) | |
1162 | { | |
1163 | if(anIObj.IsNull()) return; | |
1164 | ||
1165 | if (!HasOpenedContext()) | |
1166 | { | |
1167 | if(!myObjects.IsBound(anIObj)) return; | |
1168 | ||
1169 | const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj); | |
1170 | STATUS->SetHilightStatus (Standard_False); | |
1171 | STATUS->SetHilightColor(Quantity_NOC_WHITE); | |
1172 | ||
1173 | switch(STATUS->GraphicStatus()){ | |
1174 | case AIS_DS_Displayed: | |
1175 | { | |
1176 | Standard_Integer DispMode,HiMode,SelMode; | |
1177 | GetDefModes(anIObj,DispMode,HiMode,SelMode); | |
1178 | myMainPM->Unhighlight(anIObj,HiMode); | |
1179 | // if(!STATUS->IsDModeIn(HiMode)) | |
1180 | // myMainPM->Erase(anIObj,HiMode); | |
1181 | if(updateviewer) myMainVwr->Update(); | |
1182 | break; | |
1183 | } | |
1184 | case AIS_DS_Erased: | |
1185 | { | |
1186 | Standard_Integer HiMode = anIObj->HasHilightMode()? anIObj->HilightMode():0; | |
1187 | myCollectorPM->Unhighlight(anIObj,HiMode); | |
1188 | if(updateviewer) myCollectorVwr->Update(); | |
1189 | break; | |
1190 | } | |
1191 | default: | |
1192 | break; | |
1193 | } | |
1194 | } | |
1195 | else | |
1196 | myLocalContexts(myCurLocalIndex)->Unhilight(anIObj); | |
1197 | if(updateviewer) myMainVwr->Update(); | |
1198 | } | |
1199 | ||
1200 | //======================================================================= | |
1201 | //function : IsHilighted | |
1202 | //purpose : | |
1203 | //======================================================================= | |
1204 | ||
1205 | Standard_Boolean AIS_InteractiveContext::IsHilighted(const Handle(AIS_InteractiveObject)& anIObj) const | |
1206 | { | |
1207 | if(anIObj.IsNull()) return Standard_False; | |
1208 | ||
1209 | if (!HasOpenedContext()){ | |
1210 | if(!myObjects.IsBound(anIObj)) | |
1211 | return Standard_False; | |
1212 | return myObjects(anIObj)->IsHilighted(); | |
1213 | } | |
1214 | AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts); | |
1215 | for(;ItM.More();ItM.Next()){ | |
1216 | if(ItM.Value()->IsHilighted(anIObj)) | |
1217 | return Standard_True; | |
1218 | } | |
1219 | return Standard_False; | |
1220 | } | |
1221 | ||
1222 | Standard_Boolean AIS_InteractiveContext::IsHilighted(const Handle(AIS_InteractiveObject)& anIObj, | |
1223 | Standard_Boolean& WithColor, | |
1224 | Quantity_NameOfColor& TheHiCol) const | |
1225 | { | |
1226 | if(!HasOpenedContext()){ | |
1227 | if(myObjects.IsBound(anIObj)){ | |
1228 | const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj); | |
1229 | if(STAT->IsHilighted()){ | |
1230 | if(STAT->HilightColor()!=Quantity_NOC_WHITE){ | |
1231 | WithColor=Standard_True; | |
1232 | TheHiCol = STAT->HilightColor(); | |
1233 | } | |
1234 | else | |
1235 | WithColor = Standard_False; | |
1236 | return Standard_True; | |
1237 | } | |
1238 | } | |
1239 | return Standard_False; | |
1240 | } | |
1241 | Standard_Integer MaxIndex = HighestIndex(); | |
1242 | for(Standard_Integer i=MaxIndex;i>=1 ; i--){ | |
1243 | if(myLocalContexts.IsBound(i)){ | |
1244 | if(myLocalContexts(i)->IsHilighted(anIObj,WithColor,TheHiCol)) | |
1245 | return Standard_True; | |
1246 | } | |
1247 | ||
1248 | } | |
1249 | return Standard_False; | |
1250 | } | |
1251 | ||
1252 | ||
1253 | ||
1254 | //======================================================================= | |
1255 | //function : IsDisplayed | |
1256 | //purpose : | |
1257 | //======================================================================= | |
1258 | ||
1259 | Standard_Boolean AIS_InteractiveContext::IsDisplayed(const Handle(AIS_InteractiveObject)& anIObj) const | |
1260 | { | |
1261 | if(anIObj.IsNull()) return Standard_False; | |
1262 | ||
1263 | ||
1264 | if(myObjects.IsBound(anIObj)) | |
1265 | if(myObjects(anIObj)->GraphicStatus()==AIS_DS_Displayed) | |
1266 | return Standard_True; | |
1267 | ||
1268 | AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts); | |
1269 | for(;ItM.More();ItM.Next()){ | |
1270 | if(ItM.Value()->IsDisplayed(anIObj)) | |
1271 | return Standard_True; | |
1272 | } | |
1273 | return Standard_False; | |
1274 | ||
1275 | } | |
1276 | //======================================================================= | |
1277 | //function : IsDisplayed | |
1278 | //purpose : | |
1279 | //======================================================================= | |
1280 | ||
1281 | Standard_Boolean AIS_InteractiveContext::IsInCollector(const Handle(AIS_InteractiveObject)& anIObj) const | |
1282 | { | |
1283 | if(anIObj.IsNull()) return Standard_False; | |
1284 | ||
1285 | ||
1286 | if(myObjects.IsBound(anIObj)) | |
1287 | return (myObjects(anIObj)->GraphicStatus()==AIS_DS_Erased); | |
1288 | return Standard_False; | |
1289 | } | |
1290 | ||
1291 | ||
1292 | //======================================================================= | |
1293 | //function : IsDisplayed | |
1294 | //purpose : | |
1295 | //======================================================================= | |
1296 | ||
1297 | Standard_Boolean AIS_InteractiveContext:: | |
1298 | IsDisplayed(const Handle(AIS_InteractiveObject)& anIObj, | |
1299 | const Standard_Integer aMode) const | |
1300 | { | |
1301 | if(anIObj.IsNull()) return Standard_False; | |
1302 | if(myObjects.IsBound(anIObj)) { | |
1303 | if(myObjects(anIObj)->GraphicStatus()==AIS_DS_Displayed && | |
1304 | myObjects(anIObj)->IsDModeIn(aMode)) | |
1305 | return Standard_True; | |
1306 | } | |
1307 | ||
1308 | AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts); | |
1309 | for(;ItM.More();ItM.Next()){ | |
1310 | if(ItM.Value()->IsDisplayed(anIObj,aMode)) | |
1311 | return Standard_True; | |
1312 | } | |
1313 | return Standard_False; | |
1314 | } | |
1315 | ||
1316 | ||
1317 | //======================================================================= | |
1318 | //function : DisplayPriority | |
1319 | //purpose : | |
1320 | //======================================================================= | |
1321 | ||
1322 | Standard_Integer AIS_InteractiveContext:: | |
1323 | DisplayPriority(const Handle(AIS_InteractiveObject)& anIObj) const | |
1324 | { | |
1325 | if(anIObj.IsNull()) return -1; | |
1326 | if(myObjects.IsBound(anIObj)){ | |
1327 | // CLE | |
1328 | // const Handle(AIS_GlobalStatus) & STATUS = myObjects(anIObj); | |
1329 | Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj); | |
1330 | // ENDCLE | |
1331 | Standard_Integer DM,HM,SM ; | |
1332 | GetDefModes(anIObj,DM,HM,SM); | |
1333 | switch(STATUS->GraphicStatus()){ | |
1334 | case AIS_DS_Displayed: | |
1335 | { | |
1336 | return myMainPM->DisplayPriority(anIObj,DM); | |
1337 | break; | |
1338 | } | |
1339 | case AIS_DS_Erased: | |
1340 | return myCollectorPM->DisplayPriority(anIObj,HM); | |
1341 | default: | |
1342 | break; | |
1343 | } | |
1344 | return 0; | |
1345 | } | |
1346 | return 0; | |
1347 | } | |
1348 | //======================================================================= | |
1349 | //function : SetDisplayPriority | |
1350 | //purpose : | |
1351 | //======================================================================= | |
1352 | ||
1353 | void AIS_InteractiveContext::SetDisplayPriority(const Handle(AIS_InteractiveObject)& anIObj, | |
1354 | const Standard_Integer aPriority) | |
1355 | { | |
1356 | if(anIObj.IsNull()) | |
1357 | return; | |
1358 | if(!anIObj->HasInteractiveContext()) | |
1359 | anIObj->SetContext(this); | |
1360 | if(myObjects.IsBound(anIObj)){ | |
1361 | // CLE | |
1362 | // const Handle(AIS_GlobalStatus) & STATUS = myObjects(anIObj); | |
1363 | Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj); | |
1364 | // ENDCLE | |
1365 | Standard_Integer DM,HM,SM ; | |
1366 | GetDefModes(anIObj,DM,HM,SM); | |
1367 | switch(STATUS->GraphicStatus()){ | |
1368 | case AIS_DS_Displayed: | |
1369 | { | |
1370 | myMainPM->SetDisplayPriority(anIObj,DM,aPriority); | |
1371 | break; | |
1372 | } | |
1373 | case AIS_DS_Erased: | |
1374 | { | |
1375 | myCollectorPM->SetDisplayPriority(anIObj,HM,aPriority); | |
1376 | break; | |
1377 | } | |
1378 | default: | |
1379 | break; | |
1380 | } | |
1381 | } | |
1382 | else if (HasOpenedContext()) | |
1383 | {myLocalContexts(myCurLocalIndex)->SetDisplayPriority(anIObj,aPriority);} | |
1384 | } | |
1385 | ||
1386 | //======================================================================= | |
1387 | //function : Redisplay | |
1388 | //purpose : | |
1389 | //======================================================================= | |
1390 | ||
1391 | void AIS_InteractiveContext::Redisplay(const Handle(AIS_InteractiveObject)& anIObj, | |
1392 | const Standard_Boolean updateviewer, | |
1393 | const Standard_Boolean allmodes) | |
1394 | { | |
1395 | if(AISDebugModeOn()){ | |
1396 | cout<<"===>AIS_InteractiveContext::Redisplay de :"; | |
1397 | cout<<anIObj->DynamicType()->Name()<<endl; | |
1398 | } | |
1399 | ||
1400 | RecomputePrsOnly(anIObj,updateviewer,allmodes); | |
1401 | RecomputeSelectionOnly(anIObj); | |
1402 | } | |
1403 | ||
1404 | //======================================================================= | |
1405 | //function : Redisplay | |
1406 | //purpose : | |
1407 | //======================================================================= | |
1408 | ||
1409 | void AIS_InteractiveContext::Redisplay(const AIS_KindOfInteractive KOI, | |
1410 | const Standard_Integer /*Sign*/, | |
1411 | const Standard_Boolean updateviewer) | |
1412 | { | |
1413 | Standard_Boolean found_viewer(Standard_False),found_coll(Standard_False); | |
1414 | // update | |
1415 | for(AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);It.More();It.Next()){ | |
1416 | // CLE | |
1417 | // const Handle(AIS_InteractiveObject)& IO = It.Key(); | |
1418 | Handle(AIS_InteractiveObject) IO = It.Key(); | |
1419 | // ENDCLE | |
1420 | if(IO->Type()== KOI){ | |
1421 | #ifdef DEB | |
1422 | // Standard_Boolean good = (Sign==-1)? Standard_True : | |
1423 | // ((IO->Signature()==Sign)? Standard_True:Standard_False); | |
1424 | #endif | |
1425 | Redisplay(IO,Standard_False); | |
1426 | switch(It.Value()->GraphicStatus()){ | |
1427 | case AIS_DS_Displayed: | |
1428 | found_viewer = Standard_True; | |
1429 | break; | |
1430 | case AIS_DS_Erased: | |
1431 | found_coll = Standard_True; | |
1432 | break; | |
1433 | default: | |
1434 | break; | |
1435 | } | |
1436 | } | |
1437 | } | |
1438 | // update viewer... | |
1439 | if(updateviewer){ | |
1440 | if(found_viewer) | |
1441 | myMainVwr->Update(); | |
1442 | if(found_coll) | |
1443 | myCollectorVwr->Update(); | |
1444 | } | |
1445 | } | |
1446 | ||
1447 | ||
1448 | //======================================================================= | |
1449 | //function : RecomputePrsOnly | |
1450 | //purpose : | |
1451 | //======================================================================= | |
1452 | ||
1453 | void AIS_InteractiveContext::RecomputePrsOnly(const Handle(AIS_InteractiveObject)& anIObj, | |
1454 | const Standard_Boolean updateviewer, | |
1455 | const Standard_Boolean allmodes) | |
1456 | { | |
1457 | if(anIObj.IsNull()) return; | |
1458 | anIObj->Update(allmodes); | |
1459 | ||
1460 | if(updateviewer) { | |
1461 | if(HasOpenedContext()) | |
1462 | myMainVwr->Update(); | |
1463 | else{ | |
1464 | if(myObjects.IsBound(anIObj)){ | |
1465 | switch(myObjects(anIObj)->GraphicStatus()){ | |
1466 | case AIS_DS_Displayed: | |
1467 | myMainVwr->Update(); | |
1468 | break; | |
1469 | case AIS_DS_Erased: | |
1470 | { | |
1471 | if(!myCollectorVwr.IsNull()) | |
1472 | myCollectorVwr->Update(); | |
1473 | } | |
1474 | default: | |
1475 | break; | |
1476 | } | |
1477 | } | |
1478 | } | |
1479 | } | |
1480 | } | |
1481 | //======================================================================= | |
1482 | //function : RecomputeSelectionOnly | |
1483 | //purpose : | |
1484 | //======================================================================= | |
1485 | void AIS_InteractiveContext::RecomputeSelectionOnly(const Handle(AIS_InteractiveObject)& anIObj) | |
1486 | { | |
1487 | if(anIObj.IsNull()) return; | |
1488 | mgrSelector->RecomputeSelection(anIObj); | |
1489 | ||
1490 | ||
1491 | // A VOIR SI ENCORE UTILE... | |
1492 | TColStd_ListOfInteger LI; | |
1493 | TColStd_ListIteratorOfListOfInteger Lit; | |
1494 | ActivatedModes(anIObj,LI); | |
1495 | if(!HasOpenedContext()){ | |
1496 | if(!myObjects.IsBound(anIObj)) return; | |
1497 | switch(myObjects(anIObj)->GraphicStatus()) | |
1498 | { | |
1499 | case AIS_DS_Displayed: | |
1500 | { | |
1501 | for(Lit.Initialize(LI);Lit.More();Lit.Next()) | |
1502 | mgrSelector->Activate(anIObj,Lit.Value(),myMainSel); | |
1503 | break; | |
1504 | } | |
1505 | case AIS_DS_Erased: | |
1506 | { | |
1507 | for(Lit.Initialize(LI);Lit.More();Lit.Next()) | |
1508 | mgrSelector->Activate(anIObj,Lit.Value(),myCollectorSel); | |
1509 | ||
1510 | break; | |
1511 | } | |
1512 | default: | |
1513 | break; | |
1514 | } | |
1515 | } | |
1516 | } | |
1517 | ||
1518 | //======================================================================= | |
1519 | //function : Update | |
1520 | //purpose : | |
1521 | //======================================================================= | |
1522 | ||
1523 | void AIS_InteractiveContext::Update(const Handle(AIS_InteractiveObject)& anIObj, | |
1524 | const Standard_Boolean updateviewer) | |
1525 | { | |
1526 | if(anIObj.IsNull()) return; | |
1527 | ||
1528 | ||
1529 | ||
1530 | TColStd_ListOfInteger LL; | |
1531 | anIObj->ToBeUpdated(LL); | |
1532 | TColStd_ListIteratorOfListOfInteger ITI(LL); | |
1533 | Standard_Boolean wasupdated(Standard_False); | |
1534 | ||
1535 | for (;ITI.More();ITI.Next()){ | |
1536 | anIObj->Update(ITI.Value(),Standard_False); | |
1537 | wasupdated = Standard_True; | |
1538 | } | |
1539 | ||
1540 | if(wasupdated) | |
1541 | mgrSelector->Update(anIObj); | |
1542 | ||
1543 | if(updateviewer){ | |
1544 | if(!myObjects.IsBound(anIObj)) return; | |
1545 | switch(myObjects(anIObj)->GraphicStatus()){ | |
1546 | case AIS_DS_Displayed: | |
1547 | case AIS_DS_Temporary: | |
1548 | myMainVwr->Update(); | |
1549 | break; | |
1550 | case AIS_DS_Erased: | |
1551 | myCollectorVwr->Update(); | |
1552 | break; | |
1553 | default: | |
1554 | break; | |
1555 | } | |
1556 | } | |
1557 | } | |
1558 | ||
1559 | ||
1560 | ||
1561 | //======================================================================= | |
1562 | //function : SetLocation | |
1563 | //purpose : | |
1564 | //======================================================================= | |
1565 | ||
1566 | void AIS_InteractiveContext::SetLocation(const Handle(AIS_InteractiveObject)& anIObj, | |
1567 | const TopLoc_Location& aLoc) | |
1568 | { | |
1569 | if(anIObj.IsNull()) return; | |
1570 | ||
1571 | ||
1572 | if(anIObj->HasLocation() && aLoc.IsIdentity()){ | |
1573 | anIObj->ResetLocation(); | |
1574 | mgrSelector->Update(anIObj,Standard_False); | |
1575 | return; | |
1576 | } | |
1577 | if(aLoc.IsIdentity()) return ; | |
1578 | ||
1579 | // d'abord faire un reset de la precedente location pour tout nettoyer proprement... | |
1580 | if(anIObj->HasLocation()) | |
1581 | anIObj->ResetLocation(); | |
1582 | ||
1583 | ||
1584 | anIObj->SetLocation(aLoc); | |
1585 | ||
1586 | if(!HasOpenedContext()) | |
1587 | mgrSelector->Update(anIObj,Standard_False); | |
1588 | else | |
1589 | { | |
1590 | // CLE | |
1591 | // const Handle(StdSelect_ViewerSelector3d)& tempSel = myLocalContexts(myCurLocalIndex)->MainSelector(); | |
1592 | Handle(StdSelect_ViewerSelector3d) tempSel = myLocalContexts(myCurLocalIndex)->MainSelector(); | |
1593 | // ENDCLE | |
1594 | mgrSelector->Update(anIObj,tempSel,Standard_False); | |
1595 | } | |
1596 | } | |
1597 | //======================================================================= | |
1598 | //function : ResetLocation | |
1599 | //purpose : | |
1600 | //======================================================================= | |
1601 | void AIS_InteractiveContext::ResetLocation(const Handle(AIS_InteractiveObject)& anIObj) | |
1602 | { | |
1603 | if(anIObj.IsNull()) return; | |
1604 | ||
1605 | anIObj->ResetLocation(); | |
1606 | mgrSelector->Update(anIObj,Standard_False); | |
1607 | } | |
1608 | ||
1609 | //======================================================================= | |
1610 | //function : HasLocation | |
1611 | //purpose : | |
1612 | //======================================================================= | |
1613 | ||
1614 | Standard_Boolean AIS_InteractiveContext:: | |
1615 | HasLocation(const Handle(AIS_InteractiveObject)& anIObj) const | |
1616 | { | |
1617 | if(anIObj.IsNull()) return Standard_False; | |
1618 | ||
1619 | return anIObj->HasLocation(); | |
1620 | } | |
1621 | ||
1622 | const TopLoc_Location& AIS_InteractiveContext:: | |
1623 | Location(const Handle(AIS_InteractiveObject)& anIObj) const | |
1624 | { | |
1625 | return anIObj->Location(); | |
1626 | } | |
1627 | ||
1628 | //======================================================================= | |
1629 | //function : SetDeviationCoefficient | |
1630 | //purpose : | |
1631 | //======================================================================= | |
1632 | ||
1633 | void AIS_InteractiveContext::SetDeviationCoefficient(const Standard_Real aCoefficient) | |
1634 | { | |
1635 | myDefaultDrawer->SetDeviationCoefficient(aCoefficient); | |
1636 | } | |
1637 | //======================================================================= | |
1638 | //function : SetDeviationAngle | |
1639 | //purpose : | |
1640 | //======================================================================= | |
1641 | ||
1642 | void AIS_InteractiveContext::SetDeviationAngle(const Standard_Real anAngle) | |
1643 | { | |
1644 | myDefaultDrawer->SetDeviationCoefficient(anAngle); | |
1645 | } | |
1646 | ||
1647 | //======================================================================= | |
1648 | //function : DeviationAngle | |
1649 | //purpose : Gets deviationAngle | |
1650 | //======================================================================= | |
1651 | ||
1652 | Standard_Real AIS_InteractiveContext::DeviationAngle() const | |
1653 | { | |
1654 | return PI/180.0e0 ; | |
1655 | // return myDefaultDrawer->DeviationAngle(); | |
1656 | } | |
1657 | ||
1658 | //======================================================================= | |
1659 | //function : DeviationCoefficient | |
1660 | //purpose : | |
1661 | //======================================================================= | |
1662 | ||
1663 | Standard_Real AIS_InteractiveContext::DeviationCoefficient() const | |
1664 | { | |
1665 | return myDefaultDrawer->DeviationCoefficient(); | |
1666 | } | |
1667 | //======================================================================= | |
1668 | //function : SetHLRDeviationCoefficient | |
1669 | //purpose : | |
1670 | //======================================================================= | |
1671 | ||
1672 | void AIS_InteractiveContext::SetHLRDeviationCoefficient(const Standard_Real aCoefficient) | |
1673 | { | |
1674 | myDefaultDrawer->SetHLRDeviationCoefficient(aCoefficient); | |
1675 | } | |
1676 | ||
1677 | //======================================================================= | |
1678 | //function : HLRDeviationCoefficient | |
1679 | //purpose : | |
1680 | //======================================================================= | |
1681 | ||
1682 | Standard_Real AIS_InteractiveContext::HLRDeviationCoefficient() const | |
1683 | { | |
1684 | return myDefaultDrawer->HLRDeviationCoefficient(); | |
1685 | } | |
1686 | ||
1687 | //======================================================================= | |
1688 | //function : SetHLRAngle | |
1689 | //purpose : | |
1690 | //======================================================================= | |
1691 | ||
1692 | void AIS_InteractiveContext::SetHLRAngle(const Standard_Real anAngle) | |
1693 | { | |
1694 | myDefaultDrawer->SetHLRAngle(anAngle); | |
1695 | } | |
1696 | ||
1697 | //======================================================================= | |
1698 | //function : SetHLRAngleAndDeviation | |
1699 | //purpose : compute with anangle a HLRAngle and a HLRDeviationCoefficient | |
1700 | // and set them in myHLRAngle and in myHLRDeviationCoefficient | |
1701 | // of myDefaultDrawer | |
1702 | //======================================================================= | |
1703 | ||
1704 | void AIS_InteractiveContext::SetHLRAngleAndDeviation(const Standard_Real anAngle) | |
1705 | { | |
1706 | ||
1707 | Standard_Real OutAngl,OutDefl; | |
1708 | HLRBRep::PolyHLRAngleAndDeflection(anAngle,OutAngl,OutDefl); | |
1709 | ||
1710 | myDefaultDrawer->SetHLRAngle(OutAngl); | |
1711 | myDefaultDrawer->SetHLRDeviationCoefficient(OutDefl); | |
1712 | ||
1713 | } | |
1714 | ||
1715 | //======================================================================= | |
1716 | //function : HLRAngle | |
1717 | //purpose : | |
1718 | //======================================================================= | |
1719 | ||
1720 | Standard_Real AIS_InteractiveContext::HLRAngle() const | |
1721 | { | |
1722 | return myDefaultDrawer->HLRAngle(); | |
1723 | } | |
1724 | ||
1725 | //======================================================================= | |
1726 | //function : SetDisplayMode | |
1727 | //purpose : | |
1728 | //======================================================================= | |
1729 | ||
1730 | void AIS_InteractiveContext::SetDisplayMode(const AIS_DisplayMode aMode, | |
1731 | const Standard_Boolean updateviewer) | |
1732 | { | |
1733 | if(aMode==myDisplayMode) return; | |
1734 | AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects); | |
1735 | ||
1736 | for(;It.More();It.Next()){ | |
1737 | // CLE | |
1738 | // const Handle(AIS_InteractiveObject)& anObj = It.Key(); | |
1739 | Handle(AIS_InteractiveObject) anObj = It.Key(); | |
1740 | // ENDCLE | |
1741 | Standard_Boolean Processed = (anObj->IsKind(STANDARD_TYPE(AIS_Shape)) || | |
1742 | anObj->IsKind(STANDARD_TYPE(AIS_ConnectedShape)) || | |
1743 | anObj->IsKind(STANDARD_TYPE(AIS_MultipleConnectedShape)) ); | |
1744 | ||
1745 | if ((!anObj->HasDisplayMode()) && Processed) | |
1746 | { | |
1747 | if(anObj->AcceptDisplayMode(aMode)){ | |
1748 | // CLE | |
1749 | // const Handle(AIS_GlobalStatus)& STATUS = It.Value(); | |
1750 | Handle(AIS_GlobalStatus) STATUS = It.Value(); | |
1751 | // ENDCLE | |
1752 | if(STATUS->IsDModeIn(myDisplayMode)) | |
1753 | STATUS->RemoveDisplayMode(myDisplayMode); | |
1754 | ||
1755 | STATUS->AddDisplayMode(aMode); | |
1756 | ||
1757 | if(STATUS->GraphicStatus()== AIS_DS_Displayed){ | |
1758 | myMainPM->Erase(anObj, myDisplayMode); | |
1759 | myMainPM->Display(anObj, aMode); | |
1760 | if(STATUS->IsSubIntensityOn()) | |
1761 | myMainPM->Color(anObj,mySubIntensity,aMode); | |
1762 | } | |
1763 | // myDisplayMode = aMode; | |
1764 | } | |
1765 | } | |
1766 | ||
1767 | } | |
1768 | myDisplayMode = aMode; | |
1769 | if(updateviewer) myMainVwr->Update(); | |
1770 | } | |
1771 | ||
1772 | //======================================================================= | |
1773 | //function : SetDisplayMode | |
1774 | //purpose : | |
1775 | //======================================================================= | |
1776 | ||
1777 | void AIS_InteractiveContext::SetDisplayMode(const Handle(AIS_InteractiveObject)& anIObj, | |
1778 | const Standard_Integer aMode, | |
1779 | const Standard_Boolean updateviewer) | |
1780 | { | |
1781 | ||
1782 | if(!anIObj->HasInteractiveContext()) | |
1783 | anIObj->SetContext(this); | |
1784 | if(!HasOpenedContext()){ | |
1785 | ||
1786 | if(!myObjects.IsBound(anIObj)) | |
1787 | anIObj->SetDisplayMode(aMode); | |
1788 | #ifdef BUC60632 | |
1789 | else if( anIObj->AcceptDisplayMode(aMode) ) | |
1790 | #else | |
1791 | else | |
1792 | #endif | |
1793 | { | |
1794 | // CLE | |
1795 | // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj); | |
1796 | Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj); | |
1797 | // ENDCLE | |
1798 | #ifndef OCC4373 | |
81bba717 | 1799 | // the interactive object has no mode : OldMode = Mode Session |
1800 | // already has a mode : OldMode = old mode Propre | |
7fd59977 | 1801 | |
1802 | Standard_Integer OldMode = anIObj->HasDisplayMode() ? anIObj->DisplayMode(): myDisplayMode; | |
1803 | ||
1804 | if(STATUS->IsDModeIn(OldMode)) | |
1805 | STATUS->RemoveDisplayMode(OldMode); | |
1806 | STATUS->AddDisplayMode(aMode); | |
1807 | ||
1808 | if(STATUS->GraphicStatus()==AIS_DS_Displayed){ | |
1809 | if(aMode!=OldMode ){ | |
1810 | if(myMainPM->IsHighlighted(anIObj,OldMode)) | |
1811 | myMainPM->Unhighlight(anIObj,OldMode); | |
1812 | ||
1813 | myMainPM->Erase(anIObj,OldMode); | |
1814 | #else | |
1815 | // SAN : erase presentations for all display modes different from <aMode> | |
1816 | if(STATUS->GraphicStatus()==AIS_DS_Displayed){ | |
1817 | TColStd_ListOfInteger aModesToRemove; | |
e33e7e78 RK |
1818 | TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes()); |
1819 | for(;ItL.More();ItL.Next()){ | |
7fd59977 | 1820 | |
1821 | Standard_Integer OldMode = ItL.Value(); | |
1822 | ||
1823 | if(OldMode!=aMode){ | |
1824 | aModesToRemove.Append(OldMode); | |
1825 | if(myMainPM->IsHighlighted(anIObj,OldMode)) | |
1826 | myMainPM->Unhighlight(anIObj,OldMode); | |
1827 | myMainPM->Erase(anIObj,OldMode); | |
1828 | } | |
1829 | } | |
1830 | ||
1831 | for(ItL.Initialize(aModesToRemove);ItL.More();ItL.Next()) | |
1832 | STATUS->RemoveDisplayMode(ItL.Value()); | |
1833 | ||
1834 | if(!STATUS->IsDModeIn(aMode)) | |
1835 | STATUS->AddDisplayMode(aMode); | |
1836 | #endif | |
1837 | ||
1838 | myMainPM->Display(anIObj,aMode); | |
1839 | Standard_Integer DM,HM,SM; | |
1840 | GetDefModes(anIObj,DM,HM,SM); | |
1841 | if(STATUS->IsHilighted()){ | |
1842 | myMainPM->Highlight(anIObj,HM); | |
1843 | } | |
1844 | if(STATUS->IsSubIntensityOn()){ | |
1845 | myMainPM->Color(anIObj,mySubIntensity,aMode); | |
1846 | } | |
1847 | if(anIObj->IsTransparent() && !myMainVwr->Viewer()->Transparency()) | |
1848 | myMainVwr->Viewer()->SetTransparency(Standard_True); | |
1849 | ||
1850 | if(updateviewer) myMainVwr->Update(); | |
1851 | #ifndef OCC4373 | |
1852 | } | |
1853 | #endif | |
1854 | } | |
1855 | anIObj->SetDisplayMode(aMode); | |
1856 | } | |
1857 | } | |
1858 | } | |
1859 | ||
1860 | //======================================================================= | |
1861 | //function : UnsetDisplayMode | |
1862 | //purpose : | |
1863 | //======================================================================= | |
1864 | ||
1865 | void AIS_InteractiveContext:: | |
1866 | UnsetDisplayMode(const Handle(AIS_InteractiveObject)& anIObj, | |
1867 | const Standard_Boolean updateviewer) | |
1868 | { | |
1869 | if(anIObj.IsNull()) return ; | |
1870 | if(!anIObj->HasDisplayMode()) return; | |
1871 | ||
1872 | if(!myObjects.IsBound(anIObj)) | |
1873 | anIObj->UnsetDisplayMode(); | |
1874 | else | |
1875 | { | |
1876 | Standard_Integer OldMode = anIObj->DisplayMode(); | |
1877 | if(myDisplayMode==OldMode) return; | |
1878 | const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj); | |
1879 | STATUS->RemoveDisplayMode(OldMode); | |
1880 | if(!STATUS->IsDModeIn(myDisplayMode)) | |
1881 | STATUS->AddDisplayMode(myDisplayMode); | |
1882 | if(STATUS->GraphicStatus()==AIS_DS_Displayed){ | |
1883 | if(myMainPM->IsHighlighted(anIObj,OldMode)) | |
1884 | myMainPM->Unhighlight(anIObj,OldMode); | |
1885 | myMainPM->Erase(anIObj,OldMode); | |
1886 | myMainPM->Display(anIObj,myDisplayMode); | |
1887 | Standard_Integer DM,HM,SM; | |
1888 | GetDefModes(anIObj,DM,HM,SM); | |
1889 | if(STATUS->IsHilighted()){ | |
1890 | myMainPM->Highlight(anIObj,HM); | |
1891 | } | |
1892 | if(STATUS->IsSubIntensityOn()){ | |
1893 | myMainPM->Color(anIObj,mySubIntensity,myDisplayMode); | |
1894 | } | |
1895 | if(updateviewer) myMainVwr->Update(); | |
1896 | } | |
1897 | anIObj->UnsetDisplayMode(); | |
1898 | ||
1899 | } | |
1900 | } | |
1901 | ||
1902 | //======================================================================= | |
1903 | //function : SetCurrentFacingModel | |
1904 | //purpose : | |
1905 | //======================================================================= | |
1906 | ||
1907 | #ifdef GER61351 | |
1908 | void AIS_InteractiveContext::SetCurrentFacingModel( | |
1909 | const Handle(AIS_InteractiveObject)& anIObj, | |
1910 | const Aspect_TypeOfFacingModel aModel) { | |
1911 | if ( !anIObj.IsNull () ) { | |
1912 | anIObj->SetCurrentFacingModel(aModel); | |
1913 | } | |
1914 | } | |
1915 | #endif | |
1916 | ||
1917 | //======================================================================= | |
1918 | //function : SetColor | |
1919 | //purpose : | |
1920 | //======================================================================= | |
1921 | ||
1922 | void AIS_InteractiveContext::SetColor(const Handle(AIS_InteractiveObject)& anIObj, | |
1923 | const Quantity_NameOfColor aColor, | |
1924 | const Standard_Boolean updateviewer) | |
1925 | #ifdef GER61351 | |
1926 | { | |
1927 | SetColor(anIObj,Quantity_Color(aColor),updateviewer); | |
1928 | } | |
1929 | ||
1930 | void AIS_InteractiveContext::SetColor(const Handle(AIS_InteractiveObject)& anIObj, | |
1931 | const Quantity_Color &aColor, | |
1932 | const Standard_Boolean updateviewer) | |
1933 | #endif | |
1934 | { | |
1935 | if(anIObj.IsNull()) return ; | |
1936 | ||
1937 | if(!anIObj->HasInteractiveContext()) | |
1938 | anIObj->SetContext(this); | |
1939 | anIObj->SetColor(aColor); | |
1940 | if(anIObj->RecomputeEveryPrs()) | |
1941 | anIObj->Redisplay(); | |
1942 | else | |
1943 | { | |
1944 | Standard_Integer NbDisp=0; | |
1945 | TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes()); | |
1946 | for (;ITI.More();ITI.Next()) | |
1947 | { | |
1948 | anIObj->Update(ITI.Value(),Standard_False); | |
1949 | NbDisp++; | |
1950 | } | |
1951 | anIObj->SetRecomputeOk(); | |
1952 | #ifdef DEB | |
1953 | cout<<"nb de modes a recalculer : "<<NbDisp<<endl; | |
1954 | #endif | |
1955 | } | |
1956 | ||
1957 | ||
1958 | #ifdef DEB | |
1959 | // // pour isg | |
1960 | // if(anIObj->Type()==AIS_KOI_Datum && anIObj->Signature()==3){ | |
1961 | // Handle(AIS_Trihedron) Tr = *((Handle(AIS_Trihedron)*)&anIObj); | |
1962 | // Standard_Real Lx = myDefaultDrawer->DatumAspect()->FirstAxisLength(); | |
1963 | // gp_Trsf T; | |
1964 | // gp_Dir D =Tr->Component()->XDirection(); | |
1965 | // gp_Pnt O = Tr->Component()->Location(); | |
1966 | // gp_Vec V(D);V*=Lx/5.; | |
1967 | // T.SetRotation(gp_Ax1(O,D),PI/6.); | |
1968 | // T.SetTranslationPart(V); | |
1969 | // TopLoc_Location L,IncLoc(T); | |
1970 | ||
1971 | // for(Standard_Integer I=1;I<90;I++){ | |
1972 | // if(anIObj->HasLocation()) | |
1973 | // L = anIObj->Location() * IncLoc; | |
1974 | // else | |
1975 | // L = IncLoc; | |
1976 | // SetLocation(anIObj,L); | |
1977 | // UpdateCurrentViewer(); | |
1978 | // } | |
1979 | // for(I=1;I<90;I++){ | |
1980 | // L = anIObj->Location() /IncLoc; | |
1981 | // SetLocation(anIObj,L); | |
1982 | // UpdateCurrentViewer(); | |
1983 | // } | |
1984 | // ResetLocation(anIObj); | |
1985 | // } | |
1986 | #endif | |
1987 | if(updateviewer) UpdateCurrentViewer(); | |
1988 | } | |
1989 | ||
1990 | //======================================================================= | |
1991 | //function : SetDeviationCoefficient | |
1992 | //purpose : | |
1993 | //======================================================================= | |
1994 | ||
1995 | void AIS_InteractiveContext::SetDeviationCoefficient( | |
1996 | const Handle(AIS_InteractiveObject)& anIObj, | |
1997 | const Standard_Real aCoefficient, | |
1998 | const Standard_Boolean updateviewer) | |
1999 | { | |
2000 | // cout<<" Coefficient:"<< aCoefficient <<endl; | |
2001 | if(anIObj.IsNull()) return ; | |
2002 | ||
2003 | if(!anIObj->HasInteractiveContext()) | |
2004 | anIObj->SetContext(this); | |
2005 | ||
81bba717 | 2006 | // To be modified after the related methods of AIS_Shape are passed to InteractiveObject |
7fd59977 | 2007 | if(anIObj->Type()!=AIS_KOI_Object && anIObj->Type()!=AIS_KOI_Shape) return; |
2008 | if(anIObj->Signature()!=0) return; | |
2009 | (*((Handle(AIS_Shape)*)&anIObj))->SetOwnDeviationCoefficient(aCoefficient); | |
2010 | ||
2011 | ||
2012 | ||
2013 | if(anIObj->RecomputeEveryPrs()) | |
2014 | anIObj->Redisplay(); | |
2015 | else | |
2016 | { | |
2017 | Standard_Integer NbDisp=0; | |
2018 | TColStd_ListOfInteger LL; | |
2019 | anIObj->ToBeUpdated(LL); | |
2020 | TColStd_ListIteratorOfListOfInteger ITI(LL); | |
2021 | for (;ITI.More();ITI.Next()) | |
2022 | { | |
2023 | anIObj->Update(ITI.Value(),Standard_False); | |
2024 | NbDisp++; | |
2025 | } | |
2026 | anIObj->SetRecomputeOk(); | |
2027 | #ifdef DEB | |
2028 | cout<<"nb de modes a recalculer : "<<NbDisp<<endl; | |
2029 | #endif | |
2030 | } | |
2031 | if(updateviewer) UpdateCurrentViewer(); | |
2032 | } | |
2033 | ||
2034 | //======================================================================= | |
2035 | //function : SetHLRDeviationCoefficient | |
2036 | //purpose : | |
2037 | //======================================================================= | |
2038 | ||
2039 | void AIS_InteractiveContext::SetHLRDeviationCoefficient( | |
2040 | const Handle(AIS_InteractiveObject)& anIObj, | |
2041 | const Standard_Real aCoefficient, | |
2042 | const Standard_Boolean updateviewer) | |
2043 | { | |
2044 | // cout<<" HLRCoefficient:"<< aCoefficient <<endl; | |
2045 | if(anIObj.IsNull()) return ; | |
2046 | ||
2047 | if(!anIObj->HasInteractiveContext()) | |
2048 | anIObj->SetContext(this); | |
81bba717 | 2049 | // To be modified after the related methods of AIS_Shape are passed to InteractiveObject |
7fd59977 | 2050 | if(anIObj->Type()!=AIS_KOI_Object && anIObj->Type()!=AIS_KOI_Shape) return; |
2051 | if(anIObj->Signature()!=0) return; | |
2052 | (*((Handle(AIS_Shape)*)&anIObj))->SetOwnHLRDeviationCoefficient(aCoefficient); | |
2053 | ||
2054 | ||
2055 | ||
2056 | if(anIObj->RecomputeEveryPrs()) | |
2057 | anIObj->Redisplay(); | |
2058 | else | |
2059 | { | |
2060 | Standard_Integer NbDisp=0; | |
2061 | ||
2062 | TColStd_ListOfInteger LL; | |
2063 | anIObj->ToBeUpdated(LL); | |
2064 | TColStd_ListIteratorOfListOfInteger ITI(LL); | |
2065 | for (;ITI.More();ITI.Next()) | |
2066 | { | |
2067 | anIObj->Update(ITI.Value(),Standard_False); | |
2068 | NbDisp++; | |
2069 | } | |
2070 | anIObj->SetRecomputeOk(); | |
2071 | #ifdef DEB | |
2072 | cout<<"nb de modes a recalculer : "<<NbDisp<<endl; | |
2073 | #endif | |
2074 | } | |
2075 | if(updateviewer) UpdateCurrentViewer(); | |
2076 | } | |
2077 | ||
2078 | ||
2079 | //======================================================================= | |
2080 | //function : SetDeviationAngle | |
2081 | //purpose : | |
2082 | //======================================================================= | |
2083 | ||
2084 | void AIS_InteractiveContext::SetDeviationAngle( | |
2085 | const Handle(AIS_InteractiveObject)& anIObj, | |
2086 | const Standard_Real anAngle, | |
2087 | const Standard_Boolean updateviewer) | |
2088 | { | |
2089 | // cout<<" Angle:"<< anAngle <<endl; | |
2090 | if(anIObj.IsNull()) return ; | |
2091 | ||
2092 | if(!anIObj->HasInteractiveContext()) | |
2093 | anIObj->SetContext(this); | |
e33e7e78 | 2094 | // To be modified after the related methods of AIS_Shape are passed to InteractiveObject |
7fd59977 | 2095 | if(anIObj->Type()!=AIS_KOI_Shape) return; |
2096 | if(anIObj->Signature()!=0) return; | |
2097 | (*((Handle(AIS_Shape)*)&anIObj))->SetOwnDeviationAngle(anAngle); | |
2098 | ||
2099 | ||
2100 | if(anIObj->RecomputeEveryPrs()) | |
2101 | anIObj->Redisplay(); | |
2102 | else | |
2103 | { | |
2104 | Standard_Integer NbDisp=0; | |
2105 | TColStd_ListOfInteger LL; | |
2106 | anIObj->ToBeUpdated(LL); | |
2107 | TColStd_ListIteratorOfListOfInteger ITI(LL); | |
2108 | for (;ITI.More();ITI.Next()) | |
2109 | { | |
2110 | anIObj->Update(ITI.Value(),Standard_False); | |
2111 | NbDisp++; | |
2112 | } | |
2113 | anIObj->SetRecomputeOk(); | |
2114 | #ifdef DEB | |
2115 | cout<<"nb de modes a recalculer : "<<NbDisp<<endl; | |
2116 | #endif | |
2117 | } | |
2118 | if(updateviewer) UpdateCurrentViewer(); | |
2119 | } | |
2120 | //======================================================================= | |
2121 | //function : SetDeviationAngle | |
2122 | //purpose : | |
2123 | //======================================================================= | |
2124 | ||
2125 | void AIS_InteractiveContext::SetAngleAndDeviation( | |
2126 | const Handle(AIS_InteractiveObject)& anIObj, | |
2127 | const Standard_Real anAngle, | |
2128 | const Standard_Boolean updateviewer) | |
2129 | { | |
2130 | // cout<<" Angle:"<< anAngle <<endl; | |
2131 | if(anIObj.IsNull()) return ; | |
2132 | // Standard_Real anAngleRad = PI*anAngle/180; test rob... | |
2133 | if(!anIObj->HasInteractiveContext()) | |
2134 | anIObj->SetContext(this); | |
2135 | ||
e33e7e78 | 2136 | // To be modified after the related methods of AIS_Shape are passed to InteractiveObject |
7fd59977 | 2137 | if(anIObj->Type()!=AIS_KOI_Shape) return; |
2138 | if(anIObj->Signature()!=0) return; | |
2139 | (*((Handle(AIS_Shape)*)&anIObj))->SetAngleAndDeviation(anAngle); | |
2140 | ||
2141 | ||
2142 | if(anIObj->RecomputeEveryPrs()) | |
2143 | anIObj->Redisplay(); | |
2144 | else | |
2145 | Update(anIObj,updateviewer); | |
2146 | } | |
2147 | ||
2148 | //======================================================================= | |
2149 | //function : SetDeviationAngle | |
2150 | //purpose : | |
2151 | //======================================================================= | |
2152 | ||
2153 | void AIS_InteractiveContext::SetHLRAngleAndDeviation( | |
2154 | const Handle(AIS_InteractiveObject)& anIObj, | |
2155 | const Standard_Real anAngle, | |
2156 | const Standard_Boolean updateviewer) | |
2157 | { | |
2158 | // cout<<" Angle:"<< anAngle <<endl; | |
2159 | ||
2160 | if(anIObj.IsNull()) return ; | |
2161 | if(!anIObj->HasInteractiveContext()) | |
2162 | anIObj->SetContext(this); | |
2163 | ||
e33e7e78 | 2164 | // To be modified after the related methods of AIS_Shape are passed to InteractiveObject |
7fd59977 | 2165 | if(anIObj->Type()!=AIS_KOI_Shape) return; |
2166 | if(anIObj->Signature()!=0) return; | |
2167 | (*((Handle(AIS_Shape)*)&anIObj))->SetHLRAngleAndDeviation(anAngle); | |
2168 | ||
2169 | ||
2170 | if(anIObj->RecomputeEveryPrs()) | |
2171 | anIObj->Redisplay(); | |
2172 | else | |
2173 | { | |
2174 | Standard_Integer NbDisp=0; | |
2175 | ||
2176 | TColStd_ListOfInteger LL; | |
2177 | anIObj->ToBeUpdated(LL); | |
2178 | TColStd_ListIteratorOfListOfInteger ITI(LL); | |
2179 | for (;ITI.More();ITI.Next()) | |
2180 | { | |
2181 | anIObj->Update(ITI.Value(),Standard_False); | |
2182 | NbDisp++; | |
2183 | } | |
2184 | anIObj->SetRecomputeOk(); | |
2185 | #ifdef DEB | |
2186 | cout<<"nb de modes a recalculer : "<<NbDisp<<endl; | |
2187 | #endif | |
2188 | } | |
2189 | if(updateviewer) UpdateCurrentViewer(); | |
2190 | } | |
2191 | ||
2192 | //======================================================================= | |
2193 | //function : SetHLRDeviationAngle | |
2194 | //purpose : | |
2195 | //======================================================================= | |
2196 | ||
2197 | void AIS_InteractiveContext::SetHLRDeviationAngle( | |
2198 | const Handle(AIS_InteractiveObject)& anIObj, | |
2199 | const Standard_Real anAngle, | |
2200 | const Standard_Boolean updateviewer) | |
2201 | { | |
2202 | // cout<<" HLRAngle:"<< anAngle <<endl; | |
2203 | if(anIObj.IsNull()) return ; | |
2204 | ||
2205 | if(!anIObj->HasInteractiveContext()) | |
2206 | anIObj->SetContext(this); | |
e33e7e78 | 2207 | // To be modified after the related methods of AIS_Shape are passed to InteractiveObject |
7fd59977 | 2208 | if( anIObj->Type()!=AIS_KOI_Shape) return; |
2209 | if(anIObj->Signature()!=0) return; | |
2210 | (*((Handle(AIS_Shape)*)&anIObj))->SetOwnHLRDeviationAngle(anAngle); | |
2211 | ||
2212 | ||
2213 | if(anIObj->RecomputeEveryPrs()) | |
2214 | anIObj->Redisplay(); | |
2215 | else | |
2216 | { | |
2217 | Standard_Integer NbDisp=0; | |
2218 | TColStd_ListOfInteger LL; | |
2219 | anIObj->ToBeUpdated(LL); | |
2220 | TColStd_ListIteratorOfListOfInteger ITI(LL); | |
2221 | for (;ITI.More();ITI.Next()) | |
2222 | { | |
2223 | anIObj->Update(ITI.Value(),Standard_False); | |
2224 | NbDisp++; | |
2225 | } | |
2226 | anIObj->SetRecomputeOk(); | |
2227 | #ifdef DEB | |
2228 | cout<<"nb de modes a recalculer : "<<NbDisp<<endl; | |
2229 | #endif | |
2230 | } | |
2231 | if(updateviewer) UpdateCurrentViewer(); | |
2232 | } | |
2233 | ||
2234 | //======================================================================= | |
2235 | //function : UnsetColor | |
2236 | //purpose : | |
2237 | //======================================================================= | |
2238 | ||
2239 | void AIS_InteractiveContext::UnsetColor(const Handle(AIS_InteractiveObject)& anIObj, | |
2240 | const Standard_Boolean updateviewer) | |
2241 | { | |
2242 | if(anIObj.IsNull()) return ; | |
2243 | anIObj->UnsetColor(); | |
2244 | if(anIObj->RecomputeEveryPrs()) | |
2245 | anIObj->Redisplay(); | |
2246 | else | |
2247 | { | |
2248 | Standard_Integer NbDisp =0; | |
2249 | TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes()); | |
2250 | for (;ITI.More();ITI.Next()) | |
2251 | { | |
2252 | anIObj->Update(ITI.Value(),Standard_False); | |
2253 | NbDisp++; | |
2254 | } | |
2255 | #ifdef DEB | |
2256 | cout<<"nb de modes a recalculer : "<<NbDisp<<endl; | |
2257 | #endif | |
2258 | anIObj->SetRecomputeOk(); | |
2259 | } | |
2260 | if(updateviewer) | |
2261 | UpdateCurrentViewer(); | |
2262 | } | |
2263 | ||
2264 | //======================================================================= | |
2265 | //function : HasColor | |
2266 | //purpose : | |
2267 | //======================================================================= | |
2268 | ||
2269 | Standard_Boolean AIS_InteractiveContext::HasColor(const Handle(AIS_InteractiveObject)& anIObj) const | |
2270 | { | |
2271 | return anIObj->HasColor(); | |
2272 | ||
2273 | } | |
2274 | ||
2275 | //======================================================================= | |
2276 | //function : Color | |
2277 | //purpose : | |
2278 | //======================================================================= | |
2279 | ||
2280 | Quantity_NameOfColor AIS_InteractiveContext::Color(const Handle(AIS_InteractiveObject)& anIObj) const | |
2281 | { | |
2282 | return anIObj->Color(); | |
2283 | } | |
2284 | ||
2285 | #ifdef GER61351 | |
2286 | void AIS_InteractiveContext::Color(const Handle(AIS_InteractiveObject)& anIObj, | |
2287 | Quantity_Color &aColor) const | |
2288 | { | |
2289 | anIObj->Color(aColor); | |
2290 | } | |
2291 | #endif | |
2292 | ||
2293 | //======================================================================= | |
2294 | //function : Width | |
2295 | //purpose : | |
2296 | //======================================================================= | |
2297 | ||
2298 | Standard_Real AIS_InteractiveContext::Width(const Handle(AIS_InteractiveObject)& anIObj) const | |
2299 | { | |
2300 | return anIObj->Width(); | |
2301 | } | |
2302 | ||
2303 | //======================================================================= | |
2304 | //function : SetWidth | |
2305 | //purpose : | |
2306 | //======================================================================= | |
2307 | ||
2308 | void AIS_InteractiveContext::SetWidth(const Handle(AIS_InteractiveObject)& anIObj, | |
2309 | const Standard_Real aValue, | |
2310 | const Standard_Boolean updateviewer) | |
2311 | { | |
2312 | if(anIObj.IsNull()) return ; | |
2313 | ||
2314 | if(!anIObj->HasInteractiveContext()) | |
2315 | anIObj->SetContext(this); | |
2316 | anIObj->SetWidth(aValue); | |
2317 | if(anIObj->RecomputeEveryPrs()) | |
2318 | anIObj->Redisplay(); | |
2319 | else | |
2320 | { | |
2321 | Standard_Integer NbDisp=0; | |
2322 | TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes()); | |
2323 | for (;ITI.More();ITI.Next()) | |
2324 | { | |
2325 | anIObj->Update(ITI.Value(),Standard_False); | |
2326 | NbDisp++; | |
2327 | } | |
2328 | #ifdef DEB | |
2329 | cout<<"nb de modes a recalculer : "<<NbDisp<<endl; | |
2330 | #endif | |
2331 | anIObj->SetRecomputeOk(); | |
2332 | } | |
2333 | if(updateviewer) | |
2334 | UpdateCurrentViewer(); | |
2335 | } | |
2336 | ||
2337 | //======================================================================= | |
2338 | //function : UnsetWidth | |
2339 | //purpose : | |
2340 | //======================================================================= | |
2341 | ||
2342 | void AIS_InteractiveContext::UnsetWidth(const Handle(AIS_InteractiveObject)& anIObj, | |
2343 | const Standard_Boolean updateviewer) | |
2344 | { | |
2345 | if(anIObj.IsNull()) return ; | |
2346 | anIObj->UnsetWidth(); | |
2347 | if(anIObj->RecomputeEveryPrs()) | |
2348 | anIObj->Redisplay(); | |
2349 | else | |
2350 | { | |
2351 | TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes()); | |
2352 | for (;ITI.More();ITI.Next()) | |
2353 | { | |
2354 | anIObj->Update(ITI.Value(),Standard_False); | |
2355 | } | |
2356 | anIObj->SetRecomputeOk(); | |
2357 | } | |
2358 | if(updateviewer) | |
2359 | UpdateCurrentViewer(); | |
2360 | } | |
2361 | ||
2362 | //======================================================================= | |
2363 | //function : SetMaterial | |
2364 | //purpose : | |
2365 | //======================================================================= | |
2366 | ||
2367 | void AIS_InteractiveContext::SetMaterial(const Handle(AIS_InteractiveObject)& anIObj, | |
2368 | //POP pour K4L | |
2369 | const Graphic3d_NameOfMaterial aName, | |
2370 | // const Graphic3d_NameOfPhysicalMaterial aName, | |
2371 | const Standard_Boolean updateviewer) | |
2372 | { | |
2373 | if(!anIObj->HasInteractiveContext()) | |
2374 | anIObj->SetContext(this); | |
2375 | anIObj->SetMaterial(aName); | |
2376 | if(anIObj->RecomputeEveryPrs()) | |
2377 | anIObj->Redisplay(); | |
2378 | else | |
2379 | { | |
2380 | TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes()); | |
2381 | for (;ITI.More();ITI.Next()) | |
2382 | { | |
2383 | anIObj->Update(ITI.Value(),Standard_False); | |
2384 | } | |
2385 | anIObj->SetRecomputeOk(); | |
2386 | } | |
2387 | if(updateviewer) | |
2388 | UpdateCurrentViewer(); | |
2389 | ||
2390 | } | |
2391 | ||
2392 | //======================================================================= | |
2393 | //function : UnsetMaterial | |
2394 | //purpose : | |
2395 | //======================================================================= | |
2396 | ||
2397 | void AIS_InteractiveContext::UnsetMaterial(const Handle(AIS_InteractiveObject)& anIObj, | |
2398 | const Standard_Boolean updateviewer) | |
2399 | { | |
2400 | if(anIObj.IsNull()) return ; | |
2401 | anIObj->UnsetMaterial(); | |
2402 | if(anIObj->RecomputeEveryPrs()) | |
2403 | anIObj->Redisplay(); | |
2404 | else | |
2405 | { | |
2406 | TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes()); | |
2407 | for (;ITI.More();ITI.Next()) | |
2408 | { | |
2409 | anIObj->Update(ITI.Value(),Standard_False); | |
2410 | } | |
2411 | anIObj->SetRecomputeOk(); | |
2412 | } | |
2413 | if(updateviewer) | |
2414 | UpdateCurrentViewer(); | |
2415 | } | |
2416 | ||
2417 | //======================================================================= | |
2418 | //function : SetTransparency | |
2419 | //purpose : | |
2420 | //======================================================================= | |
2421 | ||
2422 | void AIS_InteractiveContext::SetTransparency(const Handle(AIS_InteractiveObject)& anIObj, | |
2423 | const Standard_Real aValue, | |
2424 | const Standard_Boolean updateviewer) | |
2425 | { | |
2426 | if(anIObj.IsNull()) return ; | |
2427 | if(!anIObj->HasInteractiveContext()) | |
2428 | anIObj->SetContext(this); | |
2429 | ||
2430 | #ifdef BUC60577 //right optimization | |
2431 | if(!anIObj->IsTransparent() && aValue<=0.05) return; | |
2432 | #else | |
2433 | // if(!anIObj->IsTransparent() && aValue<=0.05) return; | |
2434 | #endif | |
2435 | if(aValue<=0.05){ | |
2436 | UnsetTransparency(anIObj,updateviewer); | |
2437 | return; | |
2438 | } | |
2439 | ||
2440 | if(!myMainVwr->Viewer()->Transparency()) | |
2441 | myMainVwr->Viewer()->SetTransparency(Standard_True); | |
2442 | anIObj->SetTransparency(aValue); | |
2443 | if(anIObj->RecomputeEveryPrs()) | |
2444 | anIObj->Redisplay(); | |
2445 | else | |
2446 | { | |
2447 | TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes()); | |
2448 | for (;ITI.More();ITI.Next()) | |
2449 | { | |
2450 | anIObj->Update(ITI.Value(),Standard_False); | |
2451 | } | |
2452 | anIObj->SetRecomputeOk(); | |
2453 | } | |
2454 | if(updateviewer) | |
2455 | UpdateCurrentViewer(); | |
2456 | } | |
2457 | ||
2458 | //======================================================================= | |
2459 | //function : UnsetTransparency | |
2460 | //purpose : | |
2461 | //======================================================================= | |
2462 | ||
2463 | void AIS_InteractiveContext::UnsetTransparency(const Handle(AIS_InteractiveObject)& anIObj, | |
2464 | const Standard_Boolean updateviewer) | |
2465 | { | |
2466 | if(anIObj.IsNull()) return ; | |
2467 | anIObj->UnsetTransparency(); | |
2468 | if(anIObj->RecomputeEveryPrs()) | |
2469 | anIObj->Redisplay(); | |
2470 | else | |
2471 | { | |
2472 | TColStd_ListIteratorOfListOfInteger ITI(anIObj->ListOfRecomputeModes()); | |
2473 | for (;ITI.More();ITI.Next()) | |
2474 | { | |
2475 | anIObj->Update(ITI.Value(),Standard_False); | |
2476 | } | |
2477 | anIObj->SetRecomputeOk(); | |
2478 | } | |
2479 | ||
2480 | // To Unset transparency in the viewer, if no other object is transparent ...(Speed) | |
2481 | AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects); | |
2482 | Standard_Boolean FoundTransp(Standard_False); | |
2483 | for(;It.More() && !FoundTransp ;It.Next()){ | |
2484 | if(It.Key()->IsTransparent()) | |
2485 | FoundTransp = Standard_True; | |
2486 | } | |
2487 | if(!FoundTransp) | |
2488 | myMainVwr->Viewer()->SetTransparency(Standard_False); | |
2489 | ||
2490 | ||
2491 | if(updateviewer) | |
2492 | UpdateCurrentViewer(); | |
2493 | } | |
2494 | ||
2495 | //======================================================================= | |
2496 | //function : SetDegenerateModel | |
2497 | //purpose : | |
2498 | //======================================================================= | |
2499 | ||
2500 | #ifdef G003 | |
2501 | void AIS_InteractiveContext :: SetDegenerateModel ( | |
2502 | const Handle( AIS_InteractiveObject )& anObject, | |
2503 | const Aspect_TypeOfDegenerateModel aModel, | |
2504 | const Quantity_Ratio aRatio | |
2505 | ) { | |
2506 | if ( !anObject.IsNull () ) { | |
2507 | if ( !anObject -> HasInteractiveContext () ) | |
2508 | anObject -> SetContext ( this ); | |
2509 | anObject->SetDegenerateModel(aModel,aRatio); | |
2510 | ||
2511 | } // end if | |
2512 | } // end AIS_InteractiveContext :: SetDegenerateModel | |
2513 | ||
2514 | void AIS_InteractiveContext :: SetDegenerateModel ( | |
2515 | const Aspect_TypeOfDegenerateModel aModel, | |
2516 | const Quantity_Ratio aRatio | |
2517 | ) { | |
2518 | ||
2519 | AIS_DataMapIteratorOfDataMapOfIOStatus it ( myObjects ); | |
2520 | ||
2521 | while ( it.More () ) { | |
2522 | ||
2523 | Handle( AIS_InteractiveObject ) obj = it.Key (); | |
2524 | ||
2525 | obj->SetDegenerateModel(aModel,aRatio); | |
2526 | ||
2527 | it.Next (); | |
2528 | ||
2529 | } // end while | |
2530 | ||
2531 | } // end AIS_InteractiveContext :: SetDegenerateModel | |
2532 | #endif | |
2533 | ||
2534 | #ifdef IMP140200 | |
2535 | //======================================================================= | |
2536 | //function : SetSelectedAspect | |
2537 | //purpose : | |
2538 | //======================================================================= | |
2539 | void AIS_InteractiveContext::SetSelectedAspect( | |
2540 | const Handle(Prs3d_BasicAspect)& anAspect, | |
2541 | const Standard_Boolean globalChange, | |
2542 | const Standard_Boolean updateViewer) { | |
2543 | if( !HasOpenedContext() ) { | |
2544 | Standard_Boolean found = Standard_False; | |
2545 | Handle(AIS_Selection) sel = | |
2546 | AIS_Selection::Selection(myCurrentName.ToCString()); | |
2547 | Handle(AIS_InteractiveObject) object; | |
2548 | for( sel->Init() ; sel->More() ; sel->Next()) { | |
2549 | found = Standard_True; | |
2550 | object = Handle(AIS_InteractiveObject)::DownCast(sel->Value()); | |
2551 | object->SetAspect(anAspect,globalChange); | |
2552 | } | |
2553 | if( found && updateViewer) { | |
2554 | myMainVwr->Update(); | |
2555 | if( !(myIsCollClosed && myCollectorVwr.IsNull()) ) | |
2556 | myCollectorVwr->Update(); | |
2557 | } | |
2558 | } | |
2559 | } | |
2560 | #endif | |
2561 | ||
2562 | //======================================================================= | |
2563 | //function : SetLocalAttributes | |
2564 | //purpose : | |
2565 | //======================================================================= | |
2566 | ||
2567 | void AIS_InteractiveContext::SetLocalAttributes(const Handle(AIS_InteractiveObject)& anIObj, | |
2568 | const Handle(AIS_Drawer)& aDrawer, | |
2569 | const Standard_Boolean updateviewer) | |
2570 | { | |
2571 | if(anIObj.IsNull()) return ; | |
2572 | if(!anIObj->HasInteractiveContext()) | |
2573 | anIObj->SetContext(this); | |
2574 | anIObj->SetAttributes(aDrawer); | |
2575 | Update(anIObj,updateviewer); | |
2576 | ||
2577 | } | |
2578 | ||
2579 | //======================================================================= | |
2580 | //function : UnsetLocalAttributes | |
2581 | //purpose : | |
2582 | //======================================================================= | |
2583 | void AIS_InteractiveContext::UnsetLocalAttributes(const Handle(AIS_InteractiveObject)& anIObj, | |
2584 | const Standard_Boolean updateviewer) | |
2585 | { | |
2586 | if(anIObj.IsNull()) return ; | |
2587 | if(!anIObj->HasInteractiveContext()) | |
2588 | anIObj->SetContext(this); | |
2589 | anIObj->UnsetAttributes(); | |
2590 | Update(anIObj,updateviewer); | |
2591 | } | |
2592 | ||
2593 | ||
2594 | //======================================================================= | |
2595 | //function : Status | |
2596 | //purpose : | |
2597 | //======================================================================= | |
2598 | ||
2599 | void AIS_InteractiveContext::Status(const Handle(AIS_InteractiveObject)& anIObj, TCollection_ExtendedString& astatus) const | |
2600 | { | |
2601 | astatus = ""; | |
2602 | ||
2603 | if(anIObj.IsNull()) return ; | |
2604 | if(myObjects.IsBound(anIObj)){ | |
2605 | astatus += "\t ____________________________________________"; | |
2606 | astatus += "\t| Known at Neutral Point:\n\tDisplayStatus:"; | |
2607 | const Handle(AIS_GlobalStatus)& ST = myObjects(anIObj); | |
2608 | switch(ST->GraphicStatus()){ | |
2609 | case AIS_DS_Displayed: | |
2610 | { | |
2611 | astatus +="\t| -->Displayed\n"; | |
2612 | break; | |
2613 | } | |
2614 | case AIS_DS_Erased: | |
2615 | { | |
2616 | astatus +="\t| -->Erased\n"; | |
2617 | break; | |
2618 | } | |
2619 | case AIS_DS_FullErased: | |
2620 | { | |
2621 | astatus +="\t| -->Full Erased\n"; | |
2622 | break; | |
2623 | } | |
2624 | default: | |
2625 | break; | |
2626 | } | |
2627 | astatus += "\t| Active Display Modes in the MainViewer :\n"; | |
e33e7e78 RK |
2628 | TColStd_ListIteratorOfListOfInteger ItL (ST->DisplayedModes()); |
2629 | for(;ItL.More();ItL.Next()){ | |
7fd59977 | 2630 | astatus += "\t|\t Mode "; |
2631 | astatus += TCollection_AsciiString(ItL.Value()); | |
2632 | astatus+="\n"; | |
2633 | } | |
2634 | if(IsCurrent(anIObj)) astatus +="\t| Current\n"; | |
2635 | if(IsSelected(anIObj)) astatus +="\t| Selected\n"; | |
2636 | ||
2637 | astatus += "\t| Active Selection Modes in the MainViewer :\n"; | |
2638 | for(ItL.Initialize(ST->SelectionModes());ItL.More();ItL.Next()){ | |
2639 | astatus += "\t\t Mode "; | |
2640 | astatus += TCollection_AsciiString(ItL.Value()); | |
2641 | astatus+="\n"; | |
2642 | } | |
2643 | astatus += "\t ____________________________________________"; | |
2644 | ||
2645 | } | |
2646 | } | |
2647 | ||
2648 | ||
2649 | //======================================================================= | |
2650 | //function : GetDefModes | |
2651 | //purpose : | |
2652 | //======================================================================= | |
2653 | ||
2654 | void AIS_InteractiveContext::GetDefModes(const Handle(AIS_InteractiveObject)& anIObj, | |
2655 | Standard_Integer& DispMode, | |
2656 | Standard_Integer& HiMode, | |
2657 | Standard_Integer& SelMode) const | |
2658 | { | |
2659 | if(anIObj.IsNull()) return ; | |
2660 | DispMode = anIObj->HasDisplayMode() ? anIObj->DisplayMode() : | |
2661 | (anIObj->AcceptDisplayMode(myDisplayMode)? myDisplayMode : 0); | |
2662 | ||
2663 | HiMode = anIObj->HasHilightMode()? anIObj->HilightMode():DispMode; | |
2664 | #ifdef BUC61051 | |
2665 | SelMode = anIObj->HasSelectionMode()? anIObj->SelectionMode() : -1; | |
2666 | #else | |
2667 | SelMode = anIObj->HasSelectionMode()? anIObj->SelectionMode() : 0; | |
2668 | #endif | |
2669 | } | |
2670 | ||
2671 | ||
2672 | //======================================================================= | |
2673 | //function : EraseGlobal | |
2674 | //purpose : | |
2675 | //======================================================================= | |
2676 | ||
2677 | void AIS_InteractiveContext::EraseGlobal(const Handle(AIS_InteractiveObject)& anIObj, | |
2678 | const Standard_Boolean updateviewer, | |
2679 | const Standard_Boolean PutInCollector) | |
2680 | { | |
2681 | if(anIObj.IsNull()) return ; | |
2682 | if(!myObjects.IsBound(anIObj)) return; | |
2683 | ||
2684 | // CLE | |
2685 | // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj); | |
2686 | Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj); | |
2687 | // ENDCLE | |
2688 | Standard_Integer Dmode = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0; | |
2689 | if(STATUS->GraphicStatus()==AIS_DS_Displayed){ | |
2690 | ||
e33e7e78 RK |
2691 | TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes()); |
2692 | for(;ItL.More();ItL.Next()){ | |
7fd59977 | 2693 | if(myMainPM->IsHighlighted(anIObj,ItL.Value())) |
2694 | myMainPM->Unhighlight(anIObj,ItL.Value()); | |
2695 | myMainPM->Erase(anIObj,ItL.Value()); | |
2696 | } | |
2697 | if(IsCurrent(anIObj) && !STATUS->IsDModeIn(Dmode)) | |
2698 | myMainPM->Erase(anIObj,Dmode); | |
2699 | ||
2700 | for(ItL.Initialize(STATUS->SelectionModes());ItL.More();ItL.Next()) | |
2701 | mgrSelector->Deactivate(anIObj,ItL.Value(),myMainSel); | |
2702 | if(updateviewer) myMainVwr->Update(); | |
2703 | } | |
2704 | if(PutInCollector && !myCollectorPM.IsNull()){ | |
2705 | myCollectorPM->Display(anIObj,Dmode); | |
2706 | #ifdef OCC328 | |
2707 | Standard_Integer SMode = anIObj->SelectionMode(); | |
2708 | mgrSelector->Activate(anIObj,SMode,myCollectorSel); | |
2709 | #else | |
2710 | mgrSelector->Activate(anIObj,0,myCollectorSel); | |
2711 | #endif | |
2712 | if(STATUS->IsHilighted()) | |
2713 | myCollectorPM->Highlight(anIObj,Dmode); | |
2714 | STATUS->SetGraphicStatus(AIS_DS_Erased); | |
2715 | if(updateviewer) myCollectorVwr->Update(); | |
2716 | } | |
2717 | else | |
2718 | STATUS->SetGraphicStatus(AIS_DS_FullErased); | |
2719 | ||
2720 | } | |
2721 | ||
2722 | //======================================================================= | |
2723 | //function : ClearGlobal | |
2724 | //purpose : | |
2725 | //======================================================================= | |
2726 | ||
2727 | void AIS_InteractiveContext::ClearGlobal(const Handle(AIS_InteractiveObject)& anIObj, | |
2728 | const Standard_Boolean updateviewer) | |
2729 | { | |
2730 | if(anIObj.IsNull()) return ; | |
2731 | if(!myObjects.IsBound(anIObj)) return; | |
2732 | // CLE | |
2733 | // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj); | |
2734 | Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj); | |
2735 | // ENDCLE | |
e33e7e78 RK |
2736 | TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes()); |
2737 | for(;ItL.More();ItL.Next()){ | |
7fd59977 | 2738 | if(STATUS->IsHilighted()){ |
2739 | if(IsCurrent(anIObj)) | |
2740 | #ifdef OCC204 | |
2741 | AddOrRemoveCurrentObject( anIObj, updateviewer ); | |
2742 | #else | |
2743 | AddOrRemoveCurrentObject(anIObj); | |
2744 | #endif | |
2745 | else if(myMainPM->IsHighlighted(anIObj,ItL.Value())) | |
2746 | myMainPM->Unhighlight(anIObj,ItL.Value()); | |
2747 | } | |
2748 | myMainPM->Erase(anIObj,ItL.Value()); | |
2749 | myMainPM->Clear(anIObj,ItL.Value()); | |
2750 | if(anIObj->HasHilightMode()){ | |
2751 | Standard_Integer im = anIObj->HilightMode(); | |
2752 | myMainPM->Unhighlight(anIObj,im); | |
2753 | myMainPM->Erase(anIObj,im); | |
2754 | ||
2755 | } | |
2756 | } | |
2757 | ||
2758 | //Object removes from Detected sequence | |
2759 | Standard_Integer i = 1; | |
2760 | for(i = 1; i < myAISDetectedSeq.Length(); i++) | |
2761 | { | |
2762 | Handle(AIS_InteractiveObject) anObj = DetectedCurrentObject(); | |
2763 | if( !anObj.IsNull() && anObj != anIObj ) | |
2764 | myAISDetectedSeq.Remove( i ); | |
2765 | } | |
2766 | ||
2767 | if(myWasLastMain && !myLastinMain.IsNull()) | |
2768 | if(myLastinMain == anIObj) | |
2769 | myLastinMain.Nullify(); | |
2770 | else | |
2771 | if(!myWasLastMain && !myLastinColl.IsNull()) | |
2772 | if(myLastinColl == anIObj) | |
2773 | myLastinColl.Nullify(); | |
2774 | ||
2775 | if(myLastPicked == anIObj) | |
2776 | myLastPicked.Nullify(); | |
2777 | ||
2778 | // OCC21671: Remove IO from the selection manager in any case | |
2779 | // to avoid memory leaks | |
2780 | mgrSelector->Remove(anIObj); | |
2781 | ||
2782 | switch(STATUS->GraphicStatus()){ | |
2783 | case AIS_DS_Erased: | |
2784 | { | |
2785 | Standard_Integer DM = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0; | |
2786 | if(STATUS->IsHilighted()){ | |
2787 | myCollectorPM->Unhighlight(anIObj,DM); | |
2788 | } | |
2789 | myCollectorPM->Erase(anIObj,DM); | |
2790 | myCollectorPM->Clear(anIObj,DM); | |
2791 | if(updateviewer) myCollectorVwr->Update(); | |
2792 | break; | |
2793 | } | |
2794 | case AIS_DS_Displayed: | |
2795 | { | |
2796 | if(updateviewer) myMainVwr->Update(); | |
2797 | break; | |
2798 | } | |
2799 | default: | |
2800 | break; | |
2801 | } | |
2802 | myObjects.UnBind(anIObj); | |
2803 | ||
2804 | } | |
2805 | ||
2806 | //======================================================================= | |
2807 | //function : ClearGlobalPrs | |
2808 | //purpose : | |
2809 | //======================================================================= | |
2810 | ||
2811 | void AIS_InteractiveContext::ClearGlobalPrs(const Handle(AIS_InteractiveObject)& anIObj, | |
2812 | const Standard_Integer aMode, | |
2813 | const Standard_Boolean updateviewer) | |
2814 | { | |
2815 | if(anIObj.IsNull()) return ; | |
2816 | if(!myObjects.IsBound(anIObj)) return; | |
2817 | const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj); | |
2818 | ||
2819 | Standard_Integer DM = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0; | |
2820 | if(STATUS->IsDModeIn(aMode)){ | |
2821 | if(DM==aMode && myMainPM->IsHighlighted(anIObj,aMode)) | |
2822 | myMainPM->Unhighlight(anIObj,aMode); | |
2823 | ||
2824 | myMainPM->Erase(anIObj,aMode); | |
2825 | myMainPM->Clear(anIObj,aMode); | |
2826 | } | |
2827 | ||
2828 | if(STATUS->GraphicStatus()== AIS_DS_Erased) | |
2829 | { | |
2830 | if(DM==aMode){ | |
2831 | if(STATUS->IsHilighted()) | |
2832 | myCollectorPM->Unhighlight(anIObj,aMode); | |
2833 | myCollectorPM->Erase(anIObj,DM); | |
2834 | myCollectorPM->Clear(anIObj,DM); | |
2835 | } | |
2836 | if(updateviewer) myCollectorVwr->Update(); | |
2837 | } | |
2838 | else if(STATUS->GraphicStatus()==AIS_DS_Displayed && updateviewer) | |
2839 | myMainVwr->Update(); | |
2840 | } | |
2841 | ||
2842 | //======================================================================= | |
2843 | //function : DrawHiddenLine | |
2844 | //purpose : | |
2845 | //======================================================================= | |
2846 | ||
2847 | Standard_Boolean AIS_InteractiveContext::DrawHiddenLine () const { | |
2848 | ||
2849 | return myDefaultDrawer->DrawHiddenLine(); | |
2850 | } | |
2851 | ||
2852 | //======================================================================= | |
2853 | //function : EnableDrawHiddenLine | |
2854 | //purpose : | |
2855 | //======================================================================= | |
2856 | ||
2857 | void AIS_InteractiveContext::EnableDrawHiddenLine () const { | |
2858 | myDefaultDrawer->EnableDrawHiddenLine(); | |
2859 | } | |
2860 | ||
2861 | //======================================================================= | |
2862 | //function : DisableDrawHiddenLine | |
2863 | //purpose : | |
2864 | //======================================================================= | |
2865 | ||
2866 | void AIS_InteractiveContext::DisableDrawHiddenLine () const { | |
2867 | myDefaultDrawer->DisableDrawHiddenLine(); | |
2868 | } | |
2869 | ||
2870 | //======================================================================= | |
2871 | //function : HiddenLineAspect | |
2872 | //purpose : | |
2873 | //======================================================================= | |
2874 | ||
2875 | Handle (Prs3d_LineAspect) AIS_InteractiveContext::HiddenLineAspect () const { | |
2876 | return myDefaultDrawer->HiddenLineAspect(); | |
2877 | } | |
2878 | ||
2879 | //======================================================================= | |
2880 | //function : SetHiddenLineAspect | |
2881 | //purpose : | |
2882 | //======================================================================= | |
2883 | ||
2884 | void AIS_InteractiveContext::SetHiddenLineAspect ( const Handle(Prs3d_LineAspect)& anAspect) const { | |
2885 | myDefaultDrawer->SetHiddenLineAspect(anAspect); | |
2886 | } | |
2887 | ||
2888 | //======================================================================= | |
2889 | //function : SetIsoNumber | |
2890 | //purpose : | |
2891 | //======================================================================= | |
2892 | ||
2893 | void AIS_InteractiveContext::SetIsoNumber(const Standard_Integer Nb,const AIS_TypeOfIso Type) | |
2894 | { | |
2895 | switch(Type){ | |
2896 | case AIS_TOI_IsoU: | |
2897 | myDefaultDrawer->UIsoAspect()->SetNumber(Nb); | |
2898 | break; | |
2899 | case AIS_TOI_IsoV: | |
2900 | myDefaultDrawer->VIsoAspect()->SetNumber(Nb); | |
2901 | break; | |
2902 | case AIS_TOI_Both: | |
2903 | myDefaultDrawer->UIsoAspect()->SetNumber(Nb); | |
2904 | myDefaultDrawer->VIsoAspect()->SetNumber(Nb); | |
2905 | break; | |
2906 | ||
2907 | } | |
2908 | } | |
2909 | //======================================================================= | |
2910 | //function : IsoNumber | |
2911 | //purpose : | |
2912 | //======================================================================= | |
2913 | ||
2914 | Standard_Integer AIS_InteractiveContext::IsoNumber(const AIS_TypeOfIso Type) | |
2915 | { | |
2916 | ||
2917 | switch(Type){ | |
2918 | case AIS_TOI_IsoU: | |
2919 | return myDefaultDrawer->UIsoAspect()->Number(); | |
2920 | case AIS_TOI_IsoV: | |
2921 | return myDefaultDrawer->VIsoAspect()->Number(); | |
2922 | case AIS_TOI_Both: | |
2923 | return (myDefaultDrawer->UIsoAspect()->Number()== | |
2924 | myDefaultDrawer->VIsoAspect()->Number()) ? | |
2925 | myDefaultDrawer->UIsoAspect()->Number(): -1; | |
2926 | } | |
2927 | return 0; | |
2928 | } | |
2929 | ||
2930 | //======================================================================= | |
2931 | //function : IsoOnPlane | |
2932 | //purpose : | |
2933 | //======================================================================= | |
2934 | ||
2935 | void AIS_InteractiveContext::IsoOnPlane(const Standard_Boolean SwitchOn) | |
2936 | { | |
2937 | myDefaultDrawer->SetIsoOnPlane(SwitchOn); | |
2938 | } | |
2939 | ||
2940 | //======================================================================= | |
2941 | //function : IsoOnPlane | |
2942 | //purpose : | |
2943 | //======================================================================= | |
2944 | ||
2945 | Standard_Boolean AIS_InteractiveContext::IsoOnPlane() const | |
2946 | { | |
2947 | return myDefaultDrawer->IsoOnPlane(); | |
2948 | } | |
2949 | ||
2950 | //======================================================================= | |
2951 | //function : SetSelectionMode | |
2952 | //purpose : | |
2953 | //======================================================================= | |
2954 | ||
2955 | void AIS_InteractiveContext::SetSelectionMode(const Handle_AIS_InteractiveObject&, const Standard_Integer ) | |
2956 | { | |
2957 | } | |
2958 | ||
2959 | //======================================================================= | |
2960 | //function : UnsetSelectionMode | |
2961 | //purpose : | |
2962 | //======================================================================= | |
2963 | ||
2964 | void AIS_InteractiveContext::UnsetSelectionMode(const Handle_AIS_InteractiveObject&) | |
2965 | { | |
2966 | } | |
2967 | ||
2968 | #ifdef BUC60688 | |
2969 | //======================================================================= | |
2970 | //function : SetSensitivity | |
2971 | //purpose : | |
2972 | //======================================================================= | |
2973 | ||
2974 | void AIS_InteractiveContext::SetSensitivity(const Standard_Real aPrecision) { | |
2975 | ||
2976 | if( HasOpenedContext() ) | |
2977 | myLocalContexts(myCurLocalIndex)->SetSensitivity(aPrecision); | |
2978 | else { | |
2979 | myMainSel->SetSensitivity(aPrecision); | |
2980 | if( !myCollectorSel.IsNull() ) myCollectorSel->SetSensitivity(aPrecision); | |
2981 | } | |
2982 | } | |
2983 | ||
2984 | //======================================================================= | |
2985 | //function : SetSensitivity | |
2986 | //purpose : | |
2987 | //======================================================================= | |
2988 | ||
2989 | void AIS_InteractiveContext::SetSensitivity(const Standard_Integer aPrecision) { | |
2990 | ||
2991 | if( HasOpenedContext() ) | |
2992 | myLocalContexts(myCurLocalIndex)->SetSensitivity(aPrecision); | |
2993 | else { | |
2994 | myMainSel->Set(aPrecision); | |
2995 | if( !myCollectorSel.IsNull() ) myCollectorSel->Set(aPrecision); | |
2996 | } | |
2997 | } | |
2998 | #endif | |
2999 | ||
3000 | //======================================================================= | |
3001 | //function : IsInLocal | |
3002 | //purpose : | |
3003 | //======================================================================= | |
3004 | ||
3005 | Standard_Boolean AIS_InteractiveContext::IsInLocal(const Handle_AIS_InteractiveObject& anIObj, | |
3006 | Standard_Integer& TheIndex) const | |
3007 | { | |
3008 | if(anIObj.IsNull()) return Standard_False; | |
81bba717 | 3009 | // if it exists at neutral point 0 index is returned |
7fd59977 | 3010 | if(myObjects.IsBound(anIObj)) { |
3011 | TheIndex = 0; | |
3012 | return Standard_False; | |
3013 | } | |
3014 | for(Standard_Integer I=1;I<=myLocalContexts.Extent();I++){ | |
3015 | if(myLocalContexts.IsBound(I)){ | |
3016 | if(myLocalContexts(I)->IsIn(anIObj)){ | |
3017 | TheIndex = I; | |
3018 | return Standard_True; | |
3019 | ||
3020 | } | |
3021 | } | |
3022 | } | |
3023 | TheIndex =-1; | |
3024 | return Standard_False; | |
3025 | } | |
3026 | ||
3027 | //======================================================================= | |
3028 | //function : InitAttributes | |
3029 | //purpose : | |
3030 | //======================================================================= | |
3031 | ||
3032 | void AIS_InteractiveContext::InitAttributes() | |
3033 | { | |
3034 | ||
3035 | mgrSelector->Add(myMainSel); | |
3036 | myCurrentName = AIS_Context_NewCurName(); | |
3037 | mySelectionName = AIS_Context_NewSelName(); | |
3038 | ||
3039 | AIS_Selection::CreateSelection(mySelectionName.ToCString()); | |
3040 | AIS_Selection::CreateSelection(myCurrentName.ToCString()); | |
3041 | ||
3042 | ||
3043 | myDefaultDrawer->SetShadingAspectGlobal(Standard_False); | |
3044 | Graphic3d_MaterialAspect aMat(Graphic3d_NOM_BRASS); | |
3045 | myDefaultDrawer->ShadingAspect()->SetMaterial(aMat); | |
3046 | ||
3047 | // myDefaultDrawer->ShadingAspect()->SetColor(Quantity_NOC_GRAY70); | |
3048 | Handle (Prs3d_LineAspect) HLA = myDefaultDrawer->HiddenLineAspect(); | |
3049 | HLA->SetColor(Quantity_NOC_GRAY20); | |
3050 | HLA->SetWidth(1); | |
3051 | HLA->SetTypeOfLine(Aspect_TOL_DASH); | |
3052 | ||
81bba717 | 3053 | // tolerance to 4 pixels... |
7fd59977 | 3054 | #ifdef BUC60688 |
3055 | SetSensitivity(); | |
3056 | #else | |
3057 | myMainSel->Set(4); | |
3058 | #endif | |
3059 | ||
3060 | // Customizing the drawer for trihedrons and planes... | |
3061 | ||
3062 | Handle (Prs3d_DatumAspect) DA = myDefaultDrawer->DatumAspect(); | |
3063 | Standard_Real aLength(100.); | |
3064 | DA->SetAxisLength(aLength,aLength,aLength); | |
3065 | Quantity_NameOfColor col = Quantity_NOC_LIGHTSTEELBLUE4; | |
3066 | DA->FirstAxisAspect()->SetColor(col); | |
3067 | DA->SecondAxisAspect()->SetColor(col); | |
3068 | DA->ThirdAxisAspect()->SetColor(col); | |
3069 | ||
3070 | Handle(Prs3d_PlaneAspect)PA = myDefaultDrawer->PlaneAspect(); | |
3071 | aLength =200.; | |
3072 | PA->SetPlaneLength(aLength,aLength); | |
3073 | PA->EdgesAspect()->SetColor(Quantity_NOC_SKYBLUE); | |
3074 | ||
3075 | ||
3076 | } | |
3077 | ||
3078 | ||
3079 | //======================================================================= | |
3080 | //function : TrihedronSize | |
3081 | //purpose : | |
3082 | //======================================================================= | |
3083 | Standard_Real AIS_InteractiveContext::TrihedronSize() const | |
3084 | { | |
3085 | return myDefaultDrawer->DatumAspect()->FirstAxisLength(); | |
3086 | } | |
3087 | //======================================================================= | |
3088 | //function : SetTrihedronSize | |
3089 | //purpose : | |
3090 | //======================================================================= | |
3091 | void AIS_InteractiveContext::SetTrihedronSize(const Standard_Real aVal,const Standard_Boolean /*updateviewer*/) | |
3092 | { | |
3093 | myDefaultDrawer->DatumAspect()->SetAxisLength(aVal,aVal,aVal); | |
3094 | Redisplay(AIS_KOI_Datum,3,Standard_False); | |
3095 | Redisplay(AIS_KOI_Datum,4,Standard_True); | |
3096 | } | |
3097 | ||
3098 | ||
3099 | ||
3100 | //======================================================================= | |
3101 | //function : SetPlaneSize | |
3102 | //purpose : | |
3103 | //======================================================================= | |
3104 | void AIS_InteractiveContext::SetPlaneSize(const Standard_Real aValX, | |
3105 | const Standard_Real aValY, | |
3106 | const Standard_Boolean /*updateviewer*/) | |
3107 | { | |
3108 | myDefaultDrawer->PlaneAspect()->SetPlaneLength(aValX,aValY); | |
3109 | Redisplay(AIS_KOI_Datum,7); | |
3110 | } | |
3111 | ||
3112 | //======================================================================= | |
3113 | //function : SetPlaneSize | |
3114 | //purpose : | |
3115 | //======================================================================= | |
3116 | ||
3117 | void AIS_InteractiveContext::SetPlaneSize(const Standard_Real aVal, | |
3118 | const Standard_Boolean updateviewer) | |
3119 | { | |
3120 | SetPlaneSize(aVal,aVal,updateviewer); | |
3121 | } | |
3122 | ||
3123 | //======================================================================= | |
3124 | //function : PlaneSize | |
3125 | //purpose : | |
3126 | //======================================================================= | |
3127 | ||
3128 | Standard_Boolean AIS_InteractiveContext::PlaneSize(Standard_Real& LX,Standard_Real& LY) const | |
3129 | { | |
3130 | LX = myDefaultDrawer->PlaneAspect()->PlaneXLength(); | |
3131 | LY = myDefaultDrawer->PlaneAspect()->PlaneYLength(); | |
3132 | return (Abs(LX-LY)<=Precision::Confusion()); | |
3133 | } | |
3134 | ||
3135 | ||
3136 | ||
3137 | //======================================================================= | |
3138 | //function : | |
3139 | //purpose : | |
3140 | //======================================================================= | |
3141 | void AIS_InteractiveContext::SetAutoActivateSelection( const Standard_Boolean Auto ) | |
3142 | { | |
3143 | myIsAutoActivateSelMode = Auto; | |
3144 | } | |
3145 | ||
3146 | //======================================================================= | |
3147 | //function : | |
3148 | //purpose : | |
3149 | //======================================================================= | |
3150 | Standard_Boolean AIS_InteractiveContext::GetAutoActivateSelection() const | |
3151 | { | |
3152 | return myIsAutoActivateSelMode; | |
3153 | } |