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