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