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