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