1 /***********************************************************************
5 Classe Visual3d_View.cxx :
8 Declaration des variables specifiques aux vues.
10 Une vue est definie par :
16 HISTORIQUE DES MODIFICATIONS :
17 --------------------------------
18 Mars 1992 : NW,JPB,CAL ; Creation.
19 04-02-97 : FMN ; Suppression de PSOutput, XWDOutput ...
20 22-04-97 : CAL ; Ajout du Plot.
21 03-06-97 : FMN ; Correction calcul SetRatio
22 06-05-97 : CAL ; Ajout du Clear sur les TOS_COMPUTED.
23 28-07-97 : PCT ; Ajout lumiere frontale headlight.
24 19-09-97 : CAL ; Remplacement de Window->Position par Window->Size;
25 17-10-97 : CAL ; Le Projects nouveau est arrive. (NewProjects)
26 24-10-97 : CAL ; Retrait de DownCast.
27 24-10-97 : CAL ; Retrait des DataStructure (Vieille maquette inutilisee).
28 17-11-97 : FMN ; Ajout DoResize dans Resized()
29 20-11-97 : CAL ; Disparition de la dependance avec math
30 ??-11-97 : CAL ; Retrait de la dependance avec math. Calcul developpe.
31 ??-11-97 : CAL ; Ajout de NumberOfDisplayedStructures
32 07-08-97 : PCT ; ajout support texture mapping
33 05-01-98 : CAL ; Ajout de AnimationMode
34 15-01-98 : FMN ; FRA60019 calcul Ratio pour MyViewMappingReset
35 15-01-98 : CAL ; Ajout de la transformation d'une TOS_COMPUTED
36 26-01-98 : CAL ; Ajout de la methode HaveTheSameOwner
37 06-02-98 : FMN ; CTS19079: TOP TEN: Probleme de highlight dans EDesigner.
38 05-03-98 : CAL ; GraphicTransform que si Trsf non invalidante
39 27-03-98 : CAL ; Ajout de TheStructure = devant Compute (...) !!!!
40 16-04-98 : CAL ; Remise a ID de la Trsf sur la COMPUTED
41 20-05-98 : CAL ; Perfs. Connection entre structures COMPUTED.
42 24-06-98 : CAL ; PRO14526 SetTransparency sur une vue non active.
43 17-07-98 : CAL ; PRO14872 test sur aTrsf dans ::SetTransform.
44 16-09-98 : BGN ; Points d'entree du Triedre (S3819, Phase 1)
45 22-09-98 : BGN ; S3989 (anciennement S3819)
46 TypeOfTriedron* from Aspect (pas Visual3d)
47 06-10-98 : CAL ; Ajout d'un TIMER si CSF_GraphicTimer est definie.
48 16-10-98 : CAL ; Ajout d'un TIMER si CSF_GraphicTimer est definie.
49 02-11-98 : CAL ; Retrait de OSD::SetSignal.
50 18-11-98 : FMN ; Correction sur la gestion de la perspective
51 02-12-98 : CAL ; S4062. Ajout des layers.
52 13-09-99 : GG ; GER61454 Adds LightLimit() and PlaneLimit() methods
53 10-11-99 : GG ; PRO19603 Add Redraw( area ) method
54 14-01-00 : GG ; IMP140100 Add ViewManager( ) method
55 22-10-01 : SAV ; Added EnableDepthTest() method.
56 30-04-02 : JMB ; MyDisplayStructure : use a Map instead of a Set (very bad performance
57 in data access when a lot of objects are used)
58 Will improve performance of selection mechanisms
60 ************************************************************************/
62 #define BUC60572 //GG_03-08-99 Add protection on Zclipping & Zcueing planes
65 #define BUC60570 //GG 14-09-99 Don't activates lighting
66 // when the view shading model is NONE.
68 #define GER61454 //GG 14-09-99 Activates model clipping planes
70 #define IMP140100 //GG14-01-00 Add ViewManager( ) method
72 #define G003 //EUG 30-09-00 Degeneration management
73 // Backfacing management
75 #define RIC120302 //GG Add a NEW SetWindow method which enable
76 // to connect a graphic widget and context to OGL.
78 #define BUC61044 /* 25/10/01 SAV ; added functionality to control gl depth testing
80 #define BUC61045 /* 25/10/01 SAV ; added functionality to control gl lighting
83 #define OCC1188 //SAV Added methods to set background image
85 /*----------------------------------------------------------------------*/
93 #define NO_TRACE_ACCEPT
94 #define NO_TRACE_CLEAR
95 #define NO_TRACE_CONNECT
99 #define NO_TRACE_DISPLAY
100 #define NO_TRACE_ISCOMP
101 #define NO_TRACE_LENGTH
102 #define NO_TRACE_LAYER
104 /*----------------------------------------------------------------------*/
114 #include <Visual3d_View.ixx>
115 #include <Visual3d_View.pxx>
116 #include <Visual3d_DepthCueingDefinitionError.hxx>
117 #include <Visual3d_ZClippingDefinitionError.hxx>
120 #include <math_Vector.hxx>
121 #endif /* OLD_METHOD */
125 #include <Graphic3d_Structure.hxx>
126 #include <Graphic3d_MapOfStructure.hxx>
127 #include <Graphic3d_MapIteratorOfMapOfStructure.hxx>
128 #include <Graphic3d_DataStructureManager.hxx>
130 #include <Graphic3d_GraphicDriver.hxx>
131 #include <Graphic3d_GraphicDevice.hxx>
133 #include <Graphic3d_Vector.hxx>
134 #include <Graphic3d_Vertex.hxx>
136 #include <Visual3d_Light.hxx>
137 #include <Visual3d_SetOfLight.hxx>
138 #include <Visual3d_HSetOfLight.hxx>
139 #include <Visual3d_SetIteratorOfSetOfLight.hxx>
141 #include <Visual3d_ClipPlane.hxx>
142 #include <Visual3d_SetOfClipPlane.hxx>
143 #include <Visual3d_HSetOfClipPlane.hxx>
144 #include <Visual3d_SetIteratorOfSetOfClipPlane.hxx>
146 #include <Visual3d_SetIteratorOfSetOfView.hxx>
148 #include <Graphic3d_TextureEnv.hxx>
150 #include <TColStd_HArray2OfReal.hxx>
153 # include <Xw_Window.hxx>
155 # include <WNT_Window.hxx>
162 //-Global data definitions
166 Visual3d_View::Visual3d_View (const Handle(Visual3d_ViewManager)& AManager):
169 MyViewMappingReset (),
170 MyViewOrientation (),
171 MyViewOrientationReset (),
172 MyTransformation (0, 3, 0, 3),
173 MyMatrixOfMapping (0, 3, 0, 3),
174 MyMatrixOfOrientation (0, 3, 0, 3),
175 MyTOCOMPUTESequence (),
176 MyCOMPUTEDSequence (),
177 MyDisplayedStructure ()
179 Standard_Integer i, j;
182 MyPtrViewManager = AManager.operator->();
184 MyPtrViewManager = (void *) AManager.operator->();
187 memset (&MyCView, 0, sizeof(MyCView));
188 MyCView.ViewId = int (AManager->Identification (this));
190 MyCView.IsDeleted = 0;
193 MyCView.DefWindow.IsDefined = 0;
195 MyCView.Context.NbActiveLight = 0;
196 MyCView.Context.NbActivePlane = 0;
198 MyCView.Context.ActivePlane = NULL;
203 if (i == j) MyTransformation (i, j) = 1.0;
204 else MyTransformation (i, j) = 0.0;
206 Standard_Real X, Y, Z;
208 (MyViewOrientation.ViewReferencePoint ()).Coord (X, Y, Z);
209 MyCView.Orientation.ViewReferencePoint.x = float (X);
210 MyCView.Orientation.ViewReferencePoint.y = float (Y);
211 MyCView.Orientation.ViewReferencePoint.z = float (Z);
212 (MyViewOrientation.ViewReferencePlane ()).Coord (X, Y, Z);
213 MyCView.Orientation.ViewReferencePlane.x = float (X);
214 MyCView.Orientation.ViewReferencePlane.y = float (Y);
215 MyCView.Orientation.ViewReferencePlane.z = float (Z);
216 (MyViewOrientation.ViewReferenceUp ()).Coord (X, Y, Z);
217 MyCView.Orientation.ViewReferenceUp.x = float (X);
218 MyCView.Orientation.ViewReferenceUp.y = float (Y);
219 MyCView.Orientation.ViewReferenceUp.z = float (Z);
221 Standard_Real Sx, Sy, Sz;
223 MyViewOrientation.AxialScale(Sx, Sy, Sz);
224 MyCView.Orientation.ViewScaleX = float (Sx);
225 MyCView.Orientation.ViewScaleY = float (Sy);
226 MyCView.Orientation.ViewScaleZ = float (Sz);
228 // NKV : 23/07/07 - Define custom MODELVIEW matrix
229 MyCView.Orientation.IsCustomMatrix = 0;
230 memset( (float*)MyCView.Orientation.ModelViewMatrix, 0, 16*sizeof( float ) );
231 MyCView.Orientation.ModelViewMatrix[0][0] =
232 MyCView.Orientation.ModelViewMatrix[1][1] =
233 MyCView.Orientation.ModelViewMatrix[2][2] =
234 MyCView.Orientation.ModelViewMatrix[3][3] = 1.;
237 Standard_Real um, vm, uM, vM;
239 MyCView.Mapping.Projection = int (MyViewMapping.Projection ());
240 (MyViewMapping.ProjectionReferencePoint ()).Coord (X, Y, Z);
241 MyCView.Mapping.ProjectionReferencePoint.x = float (X);
242 MyCView.Mapping.ProjectionReferencePoint.y = float (Y);
243 MyCView.Mapping.ProjectionReferencePoint.z = float (Z);
244 MyCView.Mapping.ViewPlaneDistance =
245 float (MyViewMapping.ViewPlaneDistance ());
246 MyCView.Mapping.BackPlaneDistance =
247 float (MyViewMapping.BackPlaneDistance ());
248 MyCView.Mapping.FrontPlaneDistance =
249 float (MyViewMapping.FrontPlaneDistance ());
250 MyViewMapping.WindowLimit (um, vm, uM, vM);
251 MyCView.Mapping.WindowLimit.um = float (um);
252 MyCView.Mapping.WindowLimit.vm = float (vm);
253 MyCView.Mapping.WindowLimit.uM = float (uM);
254 MyCView.Mapping.WindowLimit.vM = float (vM);
256 // NKV : 23/07/07 - Define custom MODELVIEW matrix
257 MyCView.Mapping.IsCustomMatrix = 0;
258 memset( (float*)MyCView.Mapping.ProjectionMatrix, 0, 16*sizeof( float ) );
259 MyCView.Mapping.ProjectionMatrix[0][0] =
260 MyCView.Mapping.ProjectionMatrix[1][1] =
261 MyCView.Mapping.ProjectionMatrix[2][2] =
262 MyCView.Mapping.ProjectionMatrix[3][3] = 1.;
265 MyCView.Context.ZBufferActivity = -1;
267 MyMatOfMapIsModified = Standard_True;
268 MyMatOfOriIsModified = Standard_True;
269 MyMatOfMapIsEvaluated = Standard_False;
270 MyMatOfOriIsEvaluated = Standard_False;
272 DegenerateModeIsActive = Standard_False;
273 AnimationModeIsActive = Standard_False;
275 MyCView.IsDegenerates = 0;
276 MyCView.IsDegeneratesPrev = 0;
277 ComputedModeIsActive = Standard_False;
278 MyCView.Backfacing = 0;
281 MyCView.DefBitmap.bitmap = 0;
282 MyCView.ptrUnderLayer = 0;
283 MyCView.ptrOverLayer = 0;
284 MyCView.GContext = 0;
285 MyCView.GDisplayCB = 0;
286 MyCView.GClientData = 0;
288 Handle(Aspect_GraphicDriver) agd =
289 (MyViewManager->GraphicDevice ())->GraphicDriver ();
291 MyGraphicDriver = *(Handle(Graphic3d_GraphicDriver) *) &agd;
295 Visual3d_View::Visual3d_View (const Handle(Visual3d_ViewManager)& AManager, const Visual3d_ViewOrientation& VO, const Visual3d_ViewMapping& VM, const Visual3d_ContextView& CTX):
296 MyTransformation (0, 3, 0, 3),
297 MyMatrixOfMapping (0, 3, 0, 3),
298 MyMatrixOfOrientation (0, 3, 0, 3),
299 MyTOCOMPUTESequence (),
300 MyCOMPUTEDSequence (),
301 MyDisplayedStructure ()
303 Standard_Integer i, j;
306 MyPtrViewManager = AManager.operator->();
308 MyPtrViewManager = (void *) AManager.operator->();
311 MyViewOrientation = VO;
314 MyViewOrientationReset = VO;
315 MyViewMappingReset = VM;
317 memset (&MyCView, 0, sizeof(MyCView));
318 MyCView.ViewId = int (AManager->Identification (this));
320 MyCView.IsDeleted = 0;
323 MyCView.DefWindow.IsDefined = 0;
325 MyCView.Context.NbActiveLight = 0;
326 MyCView.Context.NbActivePlane = 0;
328 MyCView.Context.ActivePlane = NULL;
333 if (i == j) MyTransformation (i, j) = 1.0;
334 else MyTransformation (i, j) = 0.0;
336 Standard_Real X, Y, Z;
338 (MyViewOrientation.ViewReferencePoint ()).Coord (X, Y, Z);
339 MyCView.Orientation.ViewReferencePoint.x = float (X);
340 MyCView.Orientation.ViewReferencePoint.y = float (Y);
341 MyCView.Orientation.ViewReferencePoint.z = float (Z);
342 (MyViewOrientation.ViewReferencePlane ()).Coord (X, Y, Z);
343 MyCView.Orientation.ViewReferencePlane.x = float (X);
344 MyCView.Orientation.ViewReferencePlane.y = float (Y);
345 MyCView.Orientation.ViewReferencePlane.z = float (Z);
346 (MyViewOrientation.ViewReferenceUp ()).Coord (X, Y, Z);
347 MyCView.Orientation.ViewReferenceUp.x = float (X);
348 MyCView.Orientation.ViewReferenceUp.y = float (Y);
349 MyCView.Orientation.ViewReferenceUp.z = float (Z);
351 Standard_Real Sx, Sy, Sz;
353 MyViewOrientation.AxialScale(Sx, Sy, Sz);
354 MyCView.Orientation.ViewScaleX = float (Sx);
355 MyCView.Orientation.ViewScaleY = float (Sy);
356 MyCView.Orientation.ViewScaleZ = float (Sz);
358 // NKV : 23/07/07 - Define custom MODELVIEW matrix
359 if (MyViewOrientation.IsCustomMatrix()) {
360 MyCView.Orientation.IsCustomMatrix = 1;
361 for ( i = 0; i < 4; i++)
362 for ( j = 0; j < 4; j++)
363 MyCView.Orientation.ModelViewMatrix[i][j] = MyViewOrientation.MyModelViewMatrix->Value(i,j);
366 MyCView.Orientation.IsCustomMatrix = 0;
367 memset( (float*)MyCView.Orientation.ModelViewMatrix, 0, 16*sizeof( float ) );
368 MyCView.Orientation.ModelViewMatrix[0][0] =
369 MyCView.Orientation.ModelViewMatrix[1][1] =
370 MyCView.Orientation.ModelViewMatrix[2][2] =
371 MyCView.Orientation.ModelViewMatrix[3][3] = 1.;
375 Standard_Real um, vm, uM, vM;
377 MyCView.Mapping.Projection = int (MyViewMapping.Projection ());
378 (MyViewMapping.ProjectionReferencePoint ()).Coord (X, Y, Z);
379 MyCView.Mapping.ProjectionReferencePoint.x = float (X);
380 MyCView.Mapping.ProjectionReferencePoint.y = float (Y);
381 MyCView.Mapping.ProjectionReferencePoint.z = float (Z);
382 MyCView.Mapping.ViewPlaneDistance =
383 float (MyViewMapping.ViewPlaneDistance ());
384 MyCView.Mapping.BackPlaneDistance =
385 float (MyViewMapping.BackPlaneDistance ());
386 MyCView.Mapping.FrontPlaneDistance =
387 float (MyViewMapping.FrontPlaneDistance ());
388 MyViewMapping.WindowLimit (um, vm, uM, vM);
389 MyCView.Mapping.WindowLimit.um = float (um);
390 MyCView.Mapping.WindowLimit.vm = float (vm);
391 MyCView.Mapping.WindowLimit.uM = float (uM);
392 MyCView.Mapping.WindowLimit.vM = float (vM);
394 // NKV : 23/07/07 - Define custom MODELVIEW matrix
395 if (MyViewMapping.IsCustomMatrix()) {
396 MyCView.Mapping.IsCustomMatrix = 1;
397 for ( i = 0; i < 4; i++)
398 for ( j = 0; j < 4; j++)
399 MyCView.Mapping.ProjectionMatrix[i][j] = MyViewMapping.MyProjectionMatrix->Value(i,j);
402 MyCView.Mapping.IsCustomMatrix = 0;
403 memset( (float*)MyCView.Mapping.ProjectionMatrix, 0, 16*sizeof( float ) );
404 MyCView.Mapping.ProjectionMatrix[0][0] =
405 MyCView.Mapping.ProjectionMatrix[1][1] =
406 MyCView.Mapping.ProjectionMatrix[2][2] =
407 MyCView.Mapping.ProjectionMatrix[3][3] = 1.;
411 MyCView.Context.ZBufferActivity = -1;
413 MyMatOfMapIsModified = Standard_True;
414 MyMatOfOriIsModified = Standard_True;
415 MyMatOfMapIsEvaluated = Standard_False;
416 MyMatOfOriIsEvaluated = Standard_False;
418 AnimationModeIsActive = Standard_False;
419 MyCView.IsDegenerates = 0;
420 MyCView.IsDegeneratesPrev = 0;
421 ComputedModeIsActive = Standard_False;
424 MyCView.DefBitmap.bitmap = 0;
425 MyCView.ptrUnderLayer = 0;
426 MyCView.ptrOverLayer = 0;
427 MyCView.GContext = 0;
428 MyCView.GDisplayCB = 0;
429 MyCView.GClientData = 0;
431 Handle(Aspect_GraphicDriver) agd =
432 (MyViewManager->GraphicDevice ())->GraphicDriver ();
434 MyGraphicDriver = *(Handle(Graphic3d_GraphicDriver) *) &agd;
442 void Visual3d_View::SetWindow (const Handle(Aspect_Window)& AWindow,
443 const Aspect_RenderingContext AContext,
444 const Aspect_GraphicCallbackProc& ADisplayCB,
445 const Standard_Address AClientData)
447 if (IsDeleted ()) return;
450 Visual3d_ViewDefinitionError::Raise ("Window already defined");
452 MyCView.GContext = AContext;
453 MyCView.GDisplayCB = ADisplayCB;
454 MyCView.GClientData = AClientData;
459 void Visual3d_View::SetWindow (const Handle(Aspect_Window)& AWindow) {
461 if (IsDeleted ()) return;
464 Visual3d_ViewDefinitionError::Raise ("Window already defined");
467 MyCView.WsId = MyCView.ViewId;
468 MyCView.DefWindow.IsDefined = 1;
470 const Handle(Xw_Window) theWindow = *(Handle(Xw_Window) *) &AWindow;
471 MyCView.DefWindow.XWindow = theWindow->XWindow ();
473 MyCView.DefWindow.XParentWindow = theWindow->XParentWindow ();
477 const Handle(WNT_Window) theWindow = *(Handle(WNT_Window) *) &AWindow;
478 MyCView.DefWindow.XWindow = ( HWND )(theWindow->HWindow());
480 MyCView.DefWindow.XParentWindow = ( HWND )(theWindow->HParentWindow());
483 wd = ( WNT_WindowData* )GetWindowLong (( HWND )(theWindow->HWindow()), GWL_USERDATA);
485 wd = ( WNT_WindowData* )GetWindowLong (( HWND )(theWindow->HWindow()), GWLP_USERDATA);
487 wd -> WNT_WDriver_Ptr = ( void* )this;
488 wd -> WNT_VMgr = ( void* )MyPtrViewManager;
491 Standard_Integer Width, Height;
492 AWindow->Size (Width, Height);
494 MyCView.DefWindow.dx = float( Width );
495 MyCView.DefWindow.dy = float( Height );
497 Standard_Real R, G, B;
498 MyBackground = MyWindow->Background ();
499 (MyBackground.Color ()).Values (R, G, B, Quantity_TOC_RGB);
500 MyCView.DefWindow.Background.r = float (R);
501 MyCView.DefWindow.Background.g = float (G);
502 MyCView.DefWindow.Background.b = float (B);
505 if (! MyGraphicDriver->View (MyCView))
506 Visual3d_ViewDefinitionError::Raise ("Association failed");
508 MyGradientBackground = MyWindow->GradientBackground();
509 SetGradientBackground(MyGradientBackground,1);
511 Standard_Boolean AWait = Standard_False; // => mise a jour immediate
512 MyGraphicDriver->SetVisualisation (MyCView);
513 MyGraphicDriver->AntiAliasing (MyCView, MyContext.AliasingIsOn ());
514 MyGraphicDriver->DepthCueing (MyCView, MyContext.DepthCueingIsOn ());
515 MyGraphicDriver->ClipLimit (MyCView, AWait);
516 MyGraphicDriver->Environment(MyCView);
518 // Mise a jour des plans de model clipping
521 // Mise a jour des sources lumineuses
525 * Association view-window n'entraine pas le display
526 * des structures qui peuvent etre affichees dans la
528 * En effet, l'association vue-fenetre est faite, mais
529 * l'affichage ne sera realise que lorsque la vue sera
530 * activee (Activate).
537 Handle(Aspect_Window) Visual3d_View::Window () const {
540 Visual3d_ViewDefinitionError::Raise ("Window not defined");
546 Standard_Boolean Visual3d_View::IsDefined () const {
548 if (MyCView.DefWindow.IsDefined)
549 return (Standard_True);
551 return (Standard_False);
555 Standard_Boolean Visual3d_View::IsDeleted () const {
557 if (MyCView.IsDeleted)
558 return (Standard_True);
560 return (Standard_False);
564 void Visual3d_View::Destroy () {
567 cout << "Visual3d_View::Destroy (" << Identification () << ")\n";
570 // Since MyPtrViewManager can be already distroyed,
571 // avoid attempts to access it in SetBackground()
572 MyPtrViewManager = 0;
577 void Visual3d_View::Remove () {
580 cout << "Visual3d_View::Remove (" << Identification () << ")" << endl;
583 if (IsDeleted ()) return;
584 if (! IsDefined ()) return;
586 MyTOCOMPUTESequence.Clear ();
587 MyCOMPUTEDSequence.Clear ();
588 MyDisplayedStructure.Clear ();
590 Quantity_Color BlackColor (0.0, 0.0, 0.0, Quantity_TOC_RGB);
591 Aspect_Background BlackBackground (BlackColor);
592 SetBackground (BlackBackground);
594 Aspect_GradientBackground BlackGradBackground;
595 SetGradientBackground (BlackGradBackground,0);
597 if (MyPtrViewManager)
598 MyPtrViewManager->UnIdentification( MyCView.ViewId );
600 MyGraphicDriver->RemoveView (MyCView);
603 MyCView.IsDeleted = 1;
604 MyCView.DefWindow.IsDefined = 0;
606 MyMatOfMapIsModified = Standard_True;
607 MyMatOfOriIsModified = Standard_True;
608 MyMatOfMapIsEvaluated = Standard_False;
609 MyMatOfOriIsEvaluated = Standard_False;
615 void Visual3d_View::Resized () {
617 if (IsDeleted ()) return;
620 Visual3d_ViewDefinitionError::Raise ("Window not defined");
621 MyWindow->DoResize() ;
626 void Visual3d_View::SetRatio () {
628 if (IsDeleted ()) return;
630 Aspect_TypeOfUpdate UpdateMode = MyViewManager->UpdateMode ();
631 MyViewManager->SetUpdateMode (Aspect_TOU_WAIT);
633 Standard_Real Umin, Vmin, Umax, Vmax;
634 Standard_Integer Dxw, Dyw;
635 Standard_Real Dxv, Dyv;
636 Standard_Real Xc, Yc;
640 MyWindow->Size (Dxw, Dyw);
641 MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax) ;
642 Xc = (Umin + Umax)/2. ; Yc = (Vmin + Vmax)/2. ;
643 Dxv = Umax - Umin ; Dyv = Vmax - Vmin ;
644 if( Dxw > 0 && Dyw > 0 ) Rap = (Standard_Real)Dyw/(Standard_Real)Dxw ;
674 Umin = Xc - Dxv/2. ; Vmin = Yc - Dyv/2. ;
675 Umax = Xc + Dxv/2. ; Vmax = Yc + Dyv/2. ;
677 MyViewMapping.SetWindowLimit(Umin,Vmin,Umax,Vmax) ;
679 // Mise a jour avant le SetViewMapping.
681 MyCView.DefWindow.dx = float( Dxw );
682 MyCView.DefWindow.dy = float( Dyw );
684 SetViewMapping (MyViewMapping);
685 // SetViewMappingDefault ();
686 // FMN+ Mise a jout Ratio pour le MyViewMappingReset
688 MyViewMappingReset.WindowLimit(Umin,Vmin,Umax,Vmax) ;
689 Xc = (Umin + Umax)/2. ; Yc = (Vmin + Vmax)/2. ;
690 Dxv = Umax - Umin ; Dyv = Vmax - Vmin ;
719 Umin = Xc - Dxv/2. ; Vmin = Yc - Dyv/2. ;
720 Umax = Xc + Dxv/2. ; Vmax = Yc + Dyv/2. ;
722 MyViewMappingReset.SetWindowLimit(Umin,Vmin,Umax,Vmax) ;
724 // FMN- Mise a jout Ratio pour le MyViewMappingReset
726 MyGraphicDriver->RatioWindow (MyCView);
729 // On force a recalculer les 2 matrices.
731 // La vue courante peut servir a reconstruire une vue copie
732 // qui est elle meme. Grace au SetWindow et au SetRatio on
733 // impose le recalcul des matrices de cette nouvelle vue.
734 MyMatOfMapIsEvaluated = Standard_False;
735 MyMatOfOriIsEvaluated = Standard_False;
737 MyViewManager->SetUpdateMode (UpdateMode);
738 if (UpdateMode == Aspect_TOU_ASAP) Update ();
742 void Visual3d_View::UpdateLights () {
744 Standard_Integer i, j;
745 CALL_DEF_LIGHT *lights=NULL;
748 if( MyContext.Model() == Visual3d_TOM_NONE ) {
749 // Activates only a white ambient light
750 MyCView.Context.NbActiveLight = 1;
751 lights = new CALL_DEF_LIGHT [MyCView.Context.NbActiveLight];
752 MyCView.Context.ActiveLight = lights;
754 lights[0].WsId = MyCView.ViewId;
755 lights[0].ViewId = MyCView.ViewId;
756 lights[0].LightType = int (Visual3d_TOLS_AMBIENT);
757 lights[0].Active = 1;
758 lights[0].LightId = 0;
759 lights[0].Headlight = 0;
760 lights[0].Color.r = lights[0].Color.g = lights[0].Color.b = 1.;
763 i = MyContext.NumberOfActivatedLights ();
764 j = MyGraphicDriver->InquireLightLimit ();
765 MyCView.Context.NbActiveLight = (i > j ? j : i);
767 if (MyCView.Context.NbActiveLight > 0) {
769 // Allocation dynamique
770 lights = new CALL_DEF_LIGHT [MyCView.Context.NbActiveLight];
772 MyCView.Context.ActiveLight = lights;
774 Standard_Real X, Y, Z;
776 Standard_Real LightConcentration;
777 Standard_Real LightAttenuation1;
778 Standard_Real LightAttenuation2;
779 Standard_Real LightAngle;
780 Quantity_Color LightColor;
781 Graphic3d_Vertex LightPosition;
782 Graphic3d_Vector LightDirection;
783 Visual3d_TypeOfLightSource LightType=Visual3d_TOLS_AMBIENT;
785 // Parcours des sources lumineuses
786 for (j=0; j<MyCView.Context.NbActiveLight; j++) {
787 LightType = (MyContext.ActivatedLight (j+1))->LightType ();
789 lights[j].WsId = MyCView.ViewId;
790 lights[j].ViewId = MyCView.ViewId;
792 lights[j].LightType = int (LightType);
793 lights[j].Active = 1;
795 int ((MyContext.ActivatedLight (j+1))->Identification ());
796 lights[j].Headlight = (MyContext.ActivatedLight (j+1))->Headlight ()? 1:0;
800 case Visual3d_TOLS_AMBIENT :
801 (MyContext.ActivatedLight (j+1))->Values (
806 case Visual3d_TOLS_POSITIONAL :
807 (MyContext.ActivatedLight (j+1))->Values (
815 case Visual3d_TOLS_DIRECTIONAL :
816 (MyContext.ActivatedLight (j+1))->Values (
822 case Visual3d_TOLS_SPOT :
823 (MyContext.ActivatedLight (j+1))->Values (
836 lights[j].Color.r = float (LightColor.Red ());
837 lights[j].Color.g = float (LightColor.Green ());
838 lights[j].Color.b = float (LightColor.Blue ());
840 if ( (LightType == Visual3d_TOLS_POSITIONAL) ||
841 (LightType == Visual3d_TOLS_SPOT) ) {
842 LightPosition.Coord (X, Y, Z);
843 lights[j].Position.x = float (X);
844 lights[j].Position.y = float (Y);
845 lights[j].Position.z = float (Z);
848 if ( (LightType == Visual3d_TOLS_DIRECTIONAL) ||
849 (LightType == Visual3d_TOLS_SPOT) ) {
850 LightDirection.Coord (X, Y, Z);
851 lights[j].Direction.x = float (X);
852 lights[j].Direction.y = float (Y);
853 lights[j].Direction.z = float (Z);
856 if ( (LightType == Visual3d_TOLS_POSITIONAL) ||
857 (LightType == Visual3d_TOLS_SPOT) ) {
858 lights[j].Attenuation[0] =
859 float (LightAttenuation1);
860 lights[j].Attenuation[1] =
861 float (LightAttenuation2);
864 if (LightType == Visual3d_TOLS_SPOT) {
865 lights[j].Concentration =
866 float (LightConcentration);
876 // gestion des sources lumineuses
879 MyGraphicDriver->SetLight (MyCView);
881 // Desallocation dynamique
882 if (MyCView.Context.NbActiveLight > 0) delete [] lights;
886 void Visual3d_View::UpdatePlanes () {
888 Standard_Integer i, j;
889 CALL_DEF_PLANE *planes=NULL;
891 i = MyContext.NumberOfActivatedClipPlanes ();
892 j = MyGraphicDriver->InquirePlaneLimit ();
893 MyCView.Context.NbActivePlane = (i > j ? j : i);
895 if (MyCView.Context.NbActivePlane > 0) {
897 // Allocation dynamique
898 #ifdef GER61454 //Keep the plane address for the next Update !
899 if( !MyCView.Context.ActivePlane )
900 MyCView.Context.ActivePlane = new CALL_DEF_PLANE [j];
901 planes = MyCView.Context.ActivePlane;
903 planes = new CALL_DEF_PLANE [MyCView.Context.NbActivePlane];
905 MyCView.Context.ActivePlane = planes;
907 Standard_Real A, B, C, D;
909 // Parcours des plans de clipping
910 for (j=0; j<MyCView.Context.NbActivePlane; j++) {
912 planes[j].WsId = MyCView.ViewId;
913 planes[j].ViewId = MyCView.ViewId;
915 planes[j].Active = 1;
917 int ((MyContext.ActivatedClipPlane (j+1))->Identification ());
919 (MyContext.ActivatedClipPlane (j+1))->Plane (A, B, C, D);
920 planes[j].CoefA = float (A);
921 planes[j].CoefB = float (B);
922 planes[j].CoefC = float (C);
923 planes[j].CoefD = float (D);
928 // gestion des plans de model clipping
931 MyGraphicDriver->SetPlane (MyCView);
933 // Desallocation dynamique
935 if ( MyCView.Context.ActivePlane && (MyCView.Context.NbActivePlane == 0)
937 delete [] MyCView.Context.ActivePlane;
938 MyCView.Context.ActivePlane = NULL;
941 if (MyCView.Context.NbActivePlane > 0) delete [] planes;
946 void Visual3d_View::SetBackground (const Aspect_Background& ABack) {
948 if (IsDeleted ()) return;
951 Visual3d_ViewDefinitionError::Raise ("Window not defined");
953 // A ce niveau, seule la GL peut mettre a jour le background.
954 // Il ne faut pas appeler MyWindow->SetBackground (ABack); car
955 // cette methode lance une mise a jour du fond de fenetre par X
956 // (si le fenetrage est X bien-sur)
958 Standard_Real R, G, B;
959 MyBackground = ABack;
960 (MyBackground.Color ()).Values (R, G, B, Quantity_TOC_RGB);
961 MyCView.DefWindow.Background.r = float (R);
962 MyCView.DefWindow.Background.g = float (G);
963 MyCView.DefWindow.Background.b = float (B);
965 MyGraphicDriver->Background (MyCView);
967 if (MyPtrViewManager && MyViewManager->UpdateMode () == Aspect_TOU_ASAP)
972 void Visual3d_View::SetGradientBackground(const Aspect_GradientBackground& ABack, const Standard_Boolean update)
975 if (IsDeleted ()) return;
978 Visual3d_ViewDefinitionError::Raise ("Window not defined");
980 MyGradientBackground = ABack;
981 Quantity_Color aCol1,aCol2;
982 MyGradientBackground.Colors(aCol1,aCol2);
983 MyGraphicDriver->GradientBackground(MyCView, aCol1, aCol2, MyGradientBackground.BgGradientFillMethod());
987 else if (MyPtrViewManager && MyViewManager->UpdateMode () == Aspect_TOU_ASAP)
991 void Visual3d_View::SetBackgroundImage( const Standard_CString FileName,
992 const Aspect_FillMethod FillStyle,
993 const Standard_Boolean update )
999 Visual3d_ViewDefinitionError::Raise ("Window not defined");
1001 MyGraphicDriver->BackgroundImage( FileName, MyCView, FillStyle );
1005 else if ( MyViewManager->UpdateMode() == Aspect_TOU_ASAP )
1010 void Visual3d_View::SetBgImageStyle( const Aspect_FillMethod FillStyle,
1011 const Standard_Boolean update )
1017 Visual3d_ViewDefinitionError::Raise ("Window not defined");
1019 MyGraphicDriver->SetBgImageStyle( MyCView, FillStyle );
1023 else if ( MyViewManager->UpdateMode() == Aspect_TOU_ASAP )
1028 Aspect_Background Visual3d_View::Background () const {
1030 return (MyBackground);
1034 void Visual3d_View::SetBgGradientStyle( const Aspect_GradientFillMethod FillStyle,
1035 const Standard_Boolean update )
1040 Visual3d_ViewDefinitionError::Raise ("Window not defined");
1042 MyGraphicDriver->SetBgGradientStyle( MyCView, FillStyle );
1046 else if ( MyViewManager->UpdateMode() == Aspect_TOU_ASAP )
1051 Aspect_GradientBackground Visual3d_View::GradientBackground () const {
1053 return MyGradientBackground;
1057 void Visual3d_View::SetTransform (const TColStd_Array2OfReal& AMatrix) {
1059 if (IsDeleted ()) return;
1061 Standard_Integer lr, ur, lc, uc;
1062 Standard_Integer i, j;
1064 // Assign the new transformation in an array [0..3][0..3]
1065 // Evite des problemes si le user a defini sa matrice [1..4][1..4]
1066 // ou [3..6][-1..2] !!
1067 lr = AMatrix.LowerRow ();
1068 ur = AMatrix.UpperRow ();
1069 lc = AMatrix.LowerCol ();
1070 uc = AMatrix.UpperCol ();
1072 if ( (ur - lr + 1 != 4) || (uc - lc + 1 != 4) )
1073 Visual3d_TransformError::Raise ("Transform : not a 4x4 matrix");
1075 for (i=0; i<=3; i++)
1076 for (j=0; j<=3; j++)
1077 MyTransformation (i, j) = AMatrix (lr + i, lc + j);
1079 Graphic3d_Vector VPN;
1080 Graphic3d_Vertex VRP;
1081 Graphic3d_Vector VUP;
1082 Standard_Real Sx, Sy, Sz;
1084 Visual3d_ViewOrientation NewViewOrientation;
1086 VPN = MyViewOrientation.ViewReferencePlane ();
1087 VRP = MyViewOrientation.ViewReferencePoint ();
1088 VUP = MyViewOrientation.ViewReferenceUp ();
1089 MyViewOrientation.AxialScale(Sx, Sy, Sz);
1091 NewViewOrientation.SetViewReferencePlane
1092 (Graphic3d_Structure::Transforms (Transform (), VPN));
1094 NewViewOrientation.SetViewReferencePoint
1095 (Graphic3d_Structure::Transforms (Transform (), VRP));
1097 NewViewOrientation.SetViewReferenceUp
1098 (Graphic3d_Structure::Transforms (Transform (), VUP));
1099 NewViewOrientation.SetAxialScale(Sx, Sy, Sz);
1101 SetViewOrientation (NewViewOrientation);
1103 MyMatOfOriIsModified = Standard_True;
1104 MyMatOfOriIsEvaluated = Standard_False;
1108 const TColStd_Array2OfReal& Visual3d_View::Transform () const {
1110 return (MyTransformation);
1114 void Visual3d_View::SetViewOrientation (const Visual3d_ViewOrientation& VO) {
1116 if (IsDeleted ()) return;
1118 MyViewOrientation = VO;
1120 Standard_Real X, Y, Z;
1122 // Tests sur la modification des parametres.
1123 Standard_Boolean VUPIsModified = Standard_False;
1124 Standard_Boolean VRPIsModified = Standard_False;
1125 Standard_Boolean VRUIsModified = Standard_False;
1126 Standard_Boolean ScaleIsModified = Standard_False;
1127 Standard_Boolean CustomIsModified = Standard_False;
1129 (MyViewOrientation.ViewReferencePoint ()).Coord (X, Y, Z);
1131 MyCView.Orientation.ViewReferencePoint.x != float (X)
1132 || MyCView.Orientation.ViewReferencePoint.y != float (Y)
1133 || MyCView.Orientation.ViewReferencePoint.z != float (Z);
1134 MyCView.Orientation.ViewReferencePoint.x = float (X);
1135 MyCView.Orientation.ViewReferencePoint.y = float (Y);
1136 MyCView.Orientation.ViewReferencePoint.z = float (Z);
1138 (MyViewOrientation.ViewReferencePlane ()).Coord (X, Y, Z);
1140 MyCView.Orientation.ViewReferencePlane.x != float (X)
1141 || MyCView.Orientation.ViewReferencePlane.y != float (Y)
1142 || MyCView.Orientation.ViewReferencePlane.z != float (Z);
1143 MyCView.Orientation.ViewReferencePlane.x = float (X);
1144 MyCView.Orientation.ViewReferencePlane.y = float (Y);
1145 MyCView.Orientation.ViewReferencePlane.z = float (Z);
1147 (MyViewOrientation.ViewReferenceUp ()).Coord (X, Y, Z);
1149 MyCView.Orientation.ViewReferenceUp.x != float (X)
1150 || MyCView.Orientation.ViewReferenceUp.y != float (Y)
1151 || MyCView.Orientation.ViewReferenceUp.z != float (Z);
1152 MyCView.Orientation.ViewReferenceUp.x = float (X);
1153 MyCView.Orientation.ViewReferenceUp.y = float (Y);
1154 MyCView.Orientation.ViewReferenceUp.z = float (Z);
1156 Standard_Real Sx, Sy, Sz;
1158 MyViewOrientation.AxialScale(Sx, Sy, Sz);
1160 MyCView.Orientation.ViewScaleX != float (X)
1161 || MyCView.Orientation.ViewScaleY != float (Y)
1162 || MyCView.Orientation.ViewScaleZ != float (Z);
1163 MyCView.Orientation.ViewScaleX = float (Sx);
1164 MyCView.Orientation.ViewScaleY = float (Sy);
1165 MyCView.Orientation.ViewScaleZ = float (Sz);
1168 MyCView.Orientation.IsCustomMatrix != MyViewOrientation.IsCustomMatrix();
1169 MyCView.Orientation.IsCustomMatrix = MyViewOrientation.IsCustomMatrix();
1170 if ( MyViewOrientation.IsCustomMatrix() ) {
1171 Standard_Integer i, j;
1172 for (i = 0; i < 4; i++)
1173 for (j = 0; j < 4; j++) {
1174 if (!CustomIsModified) CustomIsModified =
1175 MyCView.Orientation.ModelViewMatrix[i][j] != MyViewOrientation.MyModelViewMatrix->Value(i,j);
1176 MyCView.Orientation.ModelViewMatrix[i][j] = MyViewOrientation.MyModelViewMatrix->Value(i,j);
1181 cout << "Visual3d_View::SetViewOrientation\n";
1182 if (VUPIsModified || VRPIsModified || VRUIsModified || CustomIsModified)
1183 cout << "VUPIsModified : " << VUPIsModified
1184 << ", VRPIsModified : " << VRPIsModified
1185 << ", VRUIsModified : " << VRUIsModified
1186 << ", CustomIsModified : " << CustomIsModified << "\n" << flush;
1188 cout << "no modification\n" << flush;
1191 // Mise en route que si l'un des parametres est modifie
1192 if (VUPIsModified || VRPIsModified || VRUIsModified || ScaleIsModified || CustomIsModified) {
1194 if (VUPIsModified || VRPIsModified || VRUIsModified || CustomIsModified) {
1195 MyMatOfOriIsModified = Standard_True;
1196 MyMatOfOriIsEvaluated = Standard_False;
1199 if (! IsDefined ()) return;
1201 Standard_Boolean AWait = Standard_False; // => mise a jour immediate
1202 MyGraphicDriver->ViewOrientation (MyCView, AWait);
1206 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
1211 Visual3d_ViewOrientation Visual3d_View::ViewOrientation () const {
1213 return (MyViewOrientation);
1217 Visual3d_ViewOrientation Visual3d_View::ViewOrientationDefault () const {
1219 return (MyViewOrientationReset);
1223 void Visual3d_View::SetViewOrientationDefault () {
1225 MyViewOrientationReset.Assign (MyViewOrientation);
1229 void Visual3d_View::ViewOrientationReset () {
1231 if (IsDeleted ()) return;
1233 MyViewOrientation = MyViewOrientationReset;
1235 Standard_Real X, Y, Z;
1237 // Tests sur la modification des parametres.
1238 Standard_Boolean VUPIsModified = Standard_False;
1239 Standard_Boolean VRPIsModified = Standard_False;
1240 Standard_Boolean VRUIsModified = Standard_False;
1241 Standard_Boolean ScaleIsModified = Standard_False;
1242 Standard_Boolean CustomIsModified = Standard_False;
1244 (MyViewOrientation.ViewReferencePoint ()).Coord (X, Y, Z);
1246 MyCView.Orientation.ViewReferencePoint.x != float (X)
1247 || MyCView.Orientation.ViewReferencePoint.y != float (Y)
1248 || MyCView.Orientation.ViewReferencePoint.y != float (Y);
1249 MyCView.Orientation.ViewReferencePoint.x = float (X);
1250 MyCView.Orientation.ViewReferencePoint.y = float (Y);
1251 MyCView.Orientation.ViewReferencePoint.z = float (Z);
1253 (MyViewOrientation.ViewReferencePlane ()).Coord (X, Y, Z);
1255 MyCView.Orientation.ViewReferencePlane.x != float (X)
1256 || MyCView.Orientation.ViewReferencePlane.y != float (Y)
1257 || MyCView.Orientation.ViewReferencePlane.y != float (Y);
1258 MyCView.Orientation.ViewReferencePlane.x = float (X);
1259 MyCView.Orientation.ViewReferencePlane.y = float (Y);
1260 MyCView.Orientation.ViewReferencePlane.z = float (Z);
1262 (MyViewOrientation.ViewReferenceUp ()).Coord (X, Y, Z);
1264 MyCView.Orientation.ViewReferenceUp.x != float (X)
1265 || MyCView.Orientation.ViewReferenceUp.y != float (Y)
1266 || MyCView.Orientation.ViewReferenceUp.y != float (Y);
1267 MyCView.Orientation.ViewReferenceUp.x = float (X);
1268 MyCView.Orientation.ViewReferenceUp.y = float (Y);
1269 MyCView.Orientation.ViewReferenceUp.z = float (Z);
1271 Standard_Real Sx, Sy, Sz;
1273 MyViewOrientation.AxialScale(Sx, Sy, Sz);
1275 MyCView.Orientation.ViewScaleX != float (X)
1276 || MyCView.Orientation.ViewScaleY != float (Y)
1277 || MyCView.Orientation.ViewScaleZ != float (Z);
1278 MyCView.Orientation.ViewScaleX = float (Sx);
1279 MyCView.Orientation.ViewScaleY = float (Sy);
1280 MyCView.Orientation.ViewScaleZ = float (Sz);
1283 MyCView.Orientation.IsCustomMatrix != MyViewOrientation.IsCustomMatrix();
1284 MyCView.Orientation.IsCustomMatrix = MyViewOrientation.IsCustomMatrix();
1285 if ( MyViewOrientation.IsCustomMatrix() ) {
1286 Standard_Integer i, j;
1287 for (i = 0; i < 4; i++)
1288 for (j = 0; j < 4; j++) {
1289 if (!CustomIsModified) CustomIsModified =
1290 MyCView.Orientation.ModelViewMatrix[i][j] != MyViewOrientation.MyModelViewMatrix->Value(i,j);
1291 MyCView.Orientation.ModelViewMatrix[i][j] = MyViewOrientation.MyModelViewMatrix->Value(i,j);
1296 cout << "Visual3d_View::ViewOrientationReset\n";
1297 if (VUPIsModified || VRPIsModified || VRUIsModified || CustomIsModified)
1298 cout << "VUPIsModified : " << VUPIsModified
1299 << ", VRPIsModified : " << VRPIsModified
1300 << ", VRUIsModified : " << VRUIsModified
1301 << ", CustomIsModified : " << CustomIsModified << "\n" << flush;
1303 cout << "no modification\n" << flush;
1306 // Mise en route que si l'un des parametres est modifie
1307 if (VUPIsModified || VRPIsModified || VRUIsModified || CustomIsModified) {
1309 if (VUPIsModified || VRPIsModified || VRUIsModified || CustomIsModified) {
1310 MyMatOfOriIsModified = Standard_True;
1311 MyMatOfOriIsEvaluated = Standard_False;
1314 if (! IsDefined ()) return;
1316 Standard_Boolean AWait = Standard_False; // => mise a jour immediate
1317 MyGraphicDriver->ViewOrientation (MyCView, AWait);
1321 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
1326 void Visual3d_View::SetViewMapping (const Visual3d_ViewMapping& VM) {
1328 if (IsDeleted ()) return;
1330 Visual3d_TypeOfProjection OldType = MyViewMapping.Projection ();
1331 Visual3d_TypeOfProjection NewType = VM.Projection ();
1335 Standard_Real X, Y, Z;
1336 Standard_Real um, vm, uM, vM;
1338 MyCView.Mapping.Projection = int (MyViewMapping.Projection ());
1339 (MyViewMapping.ProjectionReferencePoint ()).Coord (X, Y, Z);
1340 MyCView.Mapping.ProjectionReferencePoint.x = float (X);
1341 MyCView.Mapping.ProjectionReferencePoint.y = float (Y);
1342 MyCView.Mapping.ProjectionReferencePoint.z = float (Z);
1343 MyCView.Mapping.ViewPlaneDistance =
1344 float (MyViewMapping.ViewPlaneDistance ());
1345 MyCView.Mapping.BackPlaneDistance =
1346 float (MyViewMapping.BackPlaneDistance ());
1347 MyCView.Mapping.FrontPlaneDistance =
1348 float (MyViewMapping.FrontPlaneDistance ());
1349 MyViewMapping.WindowLimit (um, vm, uM, vM);
1350 MyCView.Mapping.WindowLimit.um = float (um);
1351 MyCView.Mapping.WindowLimit.vm = float (vm);
1352 MyCView.Mapping.WindowLimit.uM = float (uM);
1353 MyCView.Mapping.WindowLimit.vM = float (vM);
1355 MyCView.Mapping.IsCustomMatrix = MyViewMapping.IsCustomMatrix();
1356 if (MyViewMapping.IsCustomMatrix()) {
1357 Standard_Integer i, j;
1358 for (i = 0; i < 4; i++)
1359 for (j = 0; j < 4; j++)
1360 MyCView.Mapping.ProjectionMatrix[i][j] =
1361 MyViewMapping.MyProjectionMatrix->Value(i,j);
1364 MyMatOfMapIsModified = Standard_True;
1365 MyMatOfMapIsEvaluated = Standard_False;
1367 if (! IsDefined ()) return;
1369 Standard_Boolean AWait = Standard_False; // => mise a jour immediate
1370 MyGraphicDriver->ViewMapping (MyCView, AWait);
1372 // Passage Parallele/Perspective
1373 if (OldType != NewType)
1376 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
1380 Visual3d_ViewMapping Visual3d_View::ViewMapping () const {
1382 return (MyViewMapping);
1386 Visual3d_ViewMapping Visual3d_View::ViewMappingDefault () const {
1388 return (MyViewMappingReset);
1392 void Visual3d_View::SetViewMappingDefault () {
1394 MyViewMappingReset.Assign (MyViewMapping);
1398 void Visual3d_View::ViewMappingReset () {
1400 if (IsDeleted ()) return;
1402 MyViewMapping = MyViewMappingReset;
1404 Standard_Real X, Y, Z;
1405 Standard_Real um, vm, uM, vM;
1407 MyCView.Mapping.Projection = int (MyViewMapping.Projection ());
1408 (MyViewMapping.ProjectionReferencePoint ()).Coord (X, Y, Z);
1409 MyCView.Mapping.ProjectionReferencePoint.x = float (X);
1410 MyCView.Mapping.ProjectionReferencePoint.y = float (Y);
1411 MyCView.Mapping.ProjectionReferencePoint.z = float (Z);
1412 MyCView.Mapping.ViewPlaneDistance =
1413 float (MyViewMapping.ViewPlaneDistance ());
1414 MyCView.Mapping.BackPlaneDistance =
1415 float (MyViewMapping.BackPlaneDistance ());
1416 MyCView.Mapping.FrontPlaneDistance =
1417 float (MyViewMapping.FrontPlaneDistance ());
1418 MyViewMapping.WindowLimit (um, vm, uM, vM);
1419 MyCView.Mapping.WindowLimit.um = float (um);
1420 MyCView.Mapping.WindowLimit.vm = float (vm);
1421 MyCView.Mapping.WindowLimit.uM = float (uM);
1422 MyCView.Mapping.WindowLimit.vM = float (vM);
1424 MyCView.Mapping.IsCustomMatrix = MyViewMapping.IsCustomMatrix();
1425 if (MyViewMapping.IsCustomMatrix()) {
1426 Standard_Integer i, j;
1427 for (i = 0; i < 4; i++)
1428 for (j = 0; j < 4; j++)
1429 MyCView.Mapping.ProjectionMatrix[i][j] =
1430 MyViewMapping.MyProjectionMatrix->Value(i,j);
1433 MyMatOfMapIsModified = Standard_True;
1434 MyMatOfMapIsEvaluated = Standard_False;
1436 if (! IsDefined ()) return;
1438 Standard_Boolean AWait = Standard_False; // => mise a jour immediate
1439 MyGraphicDriver->ViewMapping (MyCView, AWait);
1441 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
1445 void Visual3d_View::SetContext (const Visual3d_ContextView& CTX) {
1447 if (IsDeleted ()) return;
1449 Visual3d_TypeOfVisualization OldVisualMode;
1450 Visual3d_TypeOfVisualization NewVisualMode;
1452 // Pour gerer l'affichage uniquement en cas de
1453 // changement de mode de visualisation.
1454 OldVisualMode = MyContext.Visualization ();
1455 NewVisualMode = CTX.Visualization ();
1457 Visual3d_TypeOfModel OldModel;
1458 Visual3d_TypeOfModel NewModel;
1460 // Pour gerer le changement de visualisation uniquement
1461 // en cas de changement de mode de visualisation ou de
1463 OldModel = MyContext.Model ();
1464 NewModel = CTX.Model ();
1466 Standard_Boolean OldAliasingMode;
1467 Standard_Boolean NewAliasingMode;
1469 // Pour gerer l'antialiasing uniquement en cas de changement.
1470 OldAliasingMode = MyContext.AliasingIsOn ();
1471 NewAliasingMode = CTX.AliasingIsOn ();
1473 Standard_Boolean OldDepthCueingMode;
1474 Standard_Boolean NewDepthCueingMode;
1476 Standard_Real OldDepthCueingFrontPlane;
1477 Standard_Real NewDepthCueingFrontPlane;
1478 Standard_Real OldDepthCueingBackPlane;
1479 Standard_Real NewDepthCueingBackPlane;
1481 // Pour gerer le depth cueing uniquement en cas de changement.
1482 OldDepthCueingMode = MyContext.DepthCueingIsOn ();
1483 NewDepthCueingMode = CTX.DepthCueingIsOn ();
1485 OldDepthCueingFrontPlane = MyContext.DepthCueingFrontPlane ();
1486 NewDepthCueingFrontPlane = CTX.DepthCueingFrontPlane ();
1487 OldDepthCueingBackPlane = MyContext.DepthCueingBackPlane ();
1488 NewDepthCueingBackPlane = CTX.DepthCueingBackPlane ();
1490 Standard_Boolean OldFrontZClippingMode;
1491 Standard_Boolean NewFrontZClippingMode;
1492 Standard_Boolean OldBackZClippingMode;
1493 Standard_Boolean NewBackZClippingMode;
1495 Standard_Real OldZClippingFrontPlane;
1496 Standard_Real NewZClippingFrontPlane;
1497 Standard_Real OldZClippingBackPlane;
1498 Standard_Real NewZClippingBackPlane;
1500 // Pour gerer le Zclipping uniquement en cas de changement.
1501 OldFrontZClippingMode = MyContext.FrontZClippingIsOn ();
1502 NewFrontZClippingMode = CTX.FrontZClippingIsOn ();
1503 OldBackZClippingMode = MyContext.BackZClippingIsOn ();
1504 NewBackZClippingMode = CTX.BackZClippingIsOn ();
1506 OldZClippingFrontPlane = MyContext.ZClippingFrontPlane ();
1507 NewZClippingFrontPlane = CTX.ZClippingFrontPlane ();
1508 OldZClippingBackPlane = MyContext.ZClippingBackPlane ();
1509 NewZClippingBackPlane = CTX.ZClippingBackPlane ();
1511 Standard_Integer OldTexEnvId;
1512 Standard_Integer NewTexEnvId;
1513 Visual3d_TypeOfSurfaceDetail OldSurfaceDetail;
1514 Visual3d_TypeOfSurfaceDetail NewSurfaceDetail;
1516 Handle(Graphic3d_TextureEnv) TempTextureEnv1 = MyContext.TextureEnv();
1517 if (! TempTextureEnv1.IsNull()) OldTexEnvId = TempTextureEnv1->TextureId();
1518 else OldTexEnvId = -1;
1520 Handle(Graphic3d_TextureEnv) TempTextureEnv2 = CTX.TextureEnv();
1522 if (! TempTextureEnv2.IsNull()) NewTexEnvId = TempTextureEnv2->TextureId();
1523 else NewTexEnvId = -1;
1525 OldSurfaceDetail = MyContext.SurfaceDetail();
1526 NewSurfaceDetail = CTX.SurfaceDetail();
1532 Standard_Boolean AWait = Standard_False; // => mise a jour immediate
1534 // gestion des modes de visualisation et des types de shading.
1535 if ((OldVisualMode != NewVisualMode) || (OldModel != NewModel))
1536 MyGraphicDriver->SetVisualisation (MyCView);
1538 // gestion de l'antialiasing.
1539 if (OldAliasingMode != NewAliasingMode)
1540 MyGraphicDriver->AntiAliasing (MyCView, NewAliasingMode);
1542 // gestion du depth_cueing.
1543 if ((OldDepthCueingMode != NewDepthCueingMode) ||
1544 (OldDepthCueingFrontPlane != NewDepthCueingFrontPlane) ||
1545 (OldDepthCueingBackPlane != NewDepthCueingBackPlane)) {
1547 if( NewDepthCueingMode &&
1548 (NewDepthCueingBackPlane >= NewDepthCueingFrontPlane) )
1549 Visual3d_DepthCueingDefinitionError::Raise
1550 ("Bad value for DepthCueingPlanes position");
1552 MyGraphicDriver->DepthCueing
1553 (MyCView, NewDepthCueingMode);
1556 // gestion du Zclipping
1557 if ((OldFrontZClippingMode != NewFrontZClippingMode) ||
1558 (OldBackZClippingMode != NewBackZClippingMode) ||
1559 (OldZClippingFrontPlane != NewZClippingFrontPlane) ||
1560 (OldZClippingBackPlane != NewZClippingBackPlane)) {
1562 if( NewBackZClippingMode && NewFrontZClippingMode &&
1563 (NewZClippingBackPlane >= NewZClippingFrontPlane) )
1564 Visual3d_ZClippingDefinitionError::Raise
1565 ("Bad value for ZClippingPlanes position");
1567 MyGraphicDriver->ClipLimit (MyCView, AWait);
1570 // gestion des textures
1571 if ( (OldTexEnvId != NewTexEnvId) ||
1572 (OldSurfaceDetail != NewSurfaceDetail) )
1573 MyGraphicDriver->Environment(MyCView);
1575 // Mise a jour des plans de model clipping
1578 // Mise a jour des sources lumineuses
1582 if (OldVisualMode != NewVisualMode) {
1585 * Changement de contexte =>
1586 * Erase des structures qui ne peuvent pas etre affichees
1587 * avec le nouveau mode de visualisation.
1588 * On ne doit pas prevenir le ViewManager car
1589 * cette structure ne doit pas disparaitre de la
1590 * liste des structures affichees chez celui-ci.
1592 Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure);
1593 Visual3d_TypeOfAnswer Answer;
1595 Standard_Integer i = MyDisplayedStructure.Extent ();
1597 Graphic3d_SequenceOfStructure FooSequence;
1599 while (S1Iterator.More ()) {
1600 Answer = AcceptDisplay (S1Iterator.Key ());
1601 // Si la structure n'est plus affichable dans le
1602 // nouveau contexte de la vue, on l'efface.
1603 if ((Answer == Visual3d_TOA_NO) ||
1604 (Answer == Visual3d_TOA_COMPUTE))
1605 //Erase (S1Iterator.Key (), Aspect_TOU_WAIT);
1606 FooSequence.Append (S1Iterator.Key ());
1608 // S1Iterator.Next () se positionne sur la
1609 // prochaine structure
1613 Standard_Integer Length = FooSequence.Length ();
1614 // On efface les structures stockees
1615 for (i=1; i<=Length; i++)
1616 Erase (FooSequence.Value (i), Aspect_TOU_WAIT);
1617 if (Length != 0) FooSequence.Clear ();
1620 * Changement de contexte =>
1621 * Display des structures qui peuvent etre affichees
1622 * avec le nouveau mode de visualisation.
1623 * On recupere toutes les structures ayant le statut
1624 * Displayed dans le ViewManager et on l'affiche dans
1625 * la vue directement, si la structure n'est pas deja
1626 * affichee et si la vue l'accepte dans son contexte.
1629 i = MyViewManager->NumberOfDisplayedStructures ();
1630 Graphic3d_MapOfStructure Map;
1631 MyViewManager->DisplayedStructures(Map);
1632 Graphic3d_MapIteratorOfMapOfStructure it(Map);
1634 for (; it.More(); it.Next()) {
1635 Handle(Graphic3d_Structure) SG = it.Key();
1636 if (! IsDisplayed (SG)) {
1637 Answer = AcceptDisplay(SG);
1638 // Si la structure est affichable dans le
1639 // nouveau contexte de la vue, on l'affiche.
1640 if ((Answer == Visual3d_TOA_YES) ||
1641 (Answer == Visual3d_TOA_COMPUTE))
1642 //Display (MyViewManager->DisplayedStructure (j),
1644 FooSequence.Append (SG);
1648 Length = FooSequence.Length ();
1649 // On affiche les structures stockees
1650 for (i=1; i<=Length; i++)
1651 Display (FooSequence.Value (i), Aspect_TOU_WAIT);
1652 if (Length != 0) FooSequence.Clear ();
1655 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
1659 const Visual3d_ContextView& Visual3d_View::Context () const {
1665 void Visual3d_View::DisplayedStructures (Graphic3d_MapOfStructure& SG) const
1668 if (IsDeleted ()) return;
1670 Graphic3d_MapIteratorOfMapOfStructure Iterator (MyDisplayedStructure);
1672 while (Iterator.More ()) {
1673 SG.Add (Iterator.Key ());
1675 // Iterator.Next () se positionne sur la
1676 // prochaine structure
1682 void Visual3d_View::Activate () {
1684 if (IsDeleted ()) return;
1687 Visual3d_ViewDefinitionError::Raise ("Window not defined");
1689 if (! IsActive ()) {
1691 MyGraphicDriver->ActivateView (MyCView);
1692 MyGraphicDriver->Background (MyCView);
1693 MyGraphicDriver->Transparency
1694 (MyCView, MyViewManager->Transparency ());
1699 * Activation d'une nouvelle vue =>
1700 * Display des structures qui peuvent etre affichees
1701 * dans cette nouvelle vue.
1702 * On recupere toutes les structures ayant le statut
1703 * Displayed dans le ViewManager et on l'affiche dans
1704 * la vue directement, si la structure n'est pas deja
1705 * affichee et si la vue l'accepte dans son contexte.
1708 Visual3d_TypeOfAnswer Answer;
1709 Graphic3d_MapOfStructure Map;
1710 MyViewManager->DisplayedStructures(Map);
1711 Graphic3d_MapIteratorOfMapOfStructure it(Map);
1713 for (; it.More(); it.Next()) {
1714 Handle(Graphic3d_Structure) SG = it.Key();
1715 if (! IsDisplayed (SG)) {
1716 Answer = AcceptDisplay(SG);
1717 // Si la structure est affichable dans le
1718 // nouveau contexte de la vue, on l'affiche.
1719 if ((Answer == Visual3d_TOA_YES) ||
1720 (Answer == Visual3d_TOA_COMPUTE))
1721 Display (SG,Aspect_TOU_WAIT);
1727 // Si l'activation/desactivation du ZBuffer doit etre automatique
1728 // en fonction de la presence de facettes ou pas
1729 if (MyViewManager->ZBufferAuto ()) {
1730 Standard_Boolean BContainsFacet = ContainsFacet ();
1731 Standard_Boolean BZBuffer = ZBufferIsActivated ();
1732 // Si la vue contient des facettes
1733 // et si le ZBuffer n'est pas actif
1734 if (BContainsFacet && ! BZBuffer)
1735 SetZBufferActivity (1);
1736 // Si la vue ne contient pas des facettes
1737 // et si le ZBuffer est actif
1738 if (! BContainsFacet && BZBuffer)
1739 SetZBufferActivity (0);
1742 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
1746 Standard_Boolean Visual3d_View::IsActive () const {
1748 if (IsDeleted ()) return (Standard_False);
1751 return (Standard_True);
1753 return (Standard_False);
1757 void Visual3d_View::Deactivate () {
1759 if (IsDeleted ()) return;
1762 Visual3d_ViewDefinitionError::Raise ("Window not defined");
1766 MyGraphicDriver->DeactivateView (MyCView);
1769 * Deactivation d'une vue =>
1770 * Effacement des structures qui sont affichees
1772 * On recupere toute structure ayant le statut
1773 * Displayed dans le ViewManager et on l'efface dans
1774 * la vue directement, si la structure n'est pas deja
1775 * effacee et si la vue l'accepte dans son contexte.
1778 Visual3d_TypeOfAnswer Answer;
1779 Graphic3d_MapOfStructure Map;
1780 MyViewManager->DisplayedStructures(Map);
1781 Graphic3d_MapIteratorOfMapOfStructure it(Map);
1783 for (; it.More(); it.Next()) {
1784 Handle(Graphic3d_Structure) SG = it.Key();
1785 if (! IsDisplayed (SG)) {
1786 Answer = AcceptDisplay(SG);
1787 // Si la structure etait affichable, on l'efface.
1788 if ((Answer == Visual3d_TOA_YES) ||
1789 (Answer == Visual3d_TOA_COMPUTE))
1790 Erase (SG,Aspect_TOU_WAIT);
1794 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
1796 // Plus d'action possible sur la vue maintenant
1802 void Visual3d_View::Redraw () {
1804 Redraw (MyViewManager->UnderLayer (), MyViewManager->OverLayer ());
1808 void Visual3d_View::Redraw (const Standard_Integer x, const Standard_Integer y, const Standard_Integer width, const Standard_Integer height) {
1810 Redraw (MyViewManager->UnderLayer (), MyViewManager->OverLayer (), x, y, width, height);
1813 void Visual3d_View::Redraw (const Handle(Visual3d_Layer)& AnUnderLayer, const Handle(Visual3d_Layer)& AnOverLayer) {
1815 if (IsDeleted ()) return;
1817 if ((! IsDefined ()) || (! IsActive ())) return;
1819 if (! MyWindow->IsMapped ()) return;
1821 // san - 14/04/2004 - set up Z buffer state before redrawing
1822 // Si l'activation/desactivation du ZBuffer doit etre automatique
1823 // en fonction de la presence de facettes ou pas
1824 if (MyViewManager->ZBufferAuto ()) {
1825 Standard_Boolean BContainsFacet = ContainsFacet ();
1826 Standard_Boolean BZBuffer = ZBufferIsActivated ();
1827 // Si la vue contient des facettes
1828 // et si le ZBuffer n'est pas actif
1829 if (BContainsFacet && ! BZBuffer)
1830 SetZBufferActivity (1);
1831 // Si la vue ne contient pas des facettes
1832 // et si le ZBuffer est actif
1833 if (! BContainsFacet && BZBuffer)
1834 SetZBufferActivity (0);
1837 Aspect_CLayer2d OverCLayer;
1838 Aspect_CLayer2d UnderCLayer;
1839 OverCLayer.ptrLayer = UnderCLayer.ptrLayer = NULL;
1840 if (! AnOverLayer.IsNull ()) OverCLayer = AnOverLayer->CLayer ();
1841 if (! AnUnderLayer.IsNull ()) UnderCLayer = AnUnderLayer->CLayer ();
1842 MyGraphicDriver->Redraw (MyCView, UnderCLayer, OverCLayer);
1846 void Visual3d_View::Redraw (const Handle(Visual3d_Layer)& AnUnderLayer, const Handle(Visual3d_Layer)& AnOverLayer, const Standard_Integer x, const Standard_Integer y, const Standard_Integer width, const Standard_Integer height) {
1848 if (IsDeleted ()) return;
1850 if ((! IsDefined ()) || (! IsActive ())) return;
1852 if (! MyWindow->IsMapped ()) return;
1854 // san - 14/04/2004 - set up Z buffer state before redrawing
1855 // Si l'activation/desactivation du ZBuffer doit etre automatique
1856 // en fonction de la presence de facettes ou pas
1857 if (MyViewManager->ZBufferAuto ()) {
1858 Standard_Boolean BContainsFacet = ContainsFacet ();
1859 Standard_Boolean BZBuffer = ZBufferIsActivated ();
1860 // Si la vue contient des facettes
1861 // et si le ZBuffer n'est pas actif
1862 if (BContainsFacet && ! BZBuffer)
1863 SetZBufferActivity (1);
1864 // Si la vue ne contient pas des facettes
1865 // et si le ZBuffer est actif
1866 if (! BContainsFacet && BZBuffer)
1867 SetZBufferActivity (0);
1870 Aspect_CLayer2d OverCLayer;
1871 Aspect_CLayer2d UnderCLayer;
1872 OverCLayer.ptrLayer = UnderCLayer.ptrLayer = NULL;
1873 if (! AnOverLayer.IsNull ()) OverCLayer = AnOverLayer->CLayer ();
1874 if (! AnUnderLayer.IsNull ()) UnderCLayer = AnUnderLayer->CLayer ();
1875 MyGraphicDriver->Redraw (MyCView, UnderCLayer, OverCLayer, x, y, width, height);
1879 void Visual3d_View::Update () {
1881 Update (MyViewManager->UnderLayer (), MyViewManager->OverLayer ());
1885 void Visual3d_View::Update (const Handle(Visual3d_Layer)& AnUnderLayer, const Handle(Visual3d_Layer)& AnOverLayer) {
1887 if (IsDeleted ()) return;
1889 if ((! IsDefined ()) || (! IsActive ())) return;
1891 if (! MyWindow->IsMapped ()) return;
1893 // Si l'activation/desactivation du ZBuffer doit etre automatique
1894 // en fonction de la presence de facettes ou pas
1895 if (MyViewManager->ZBufferAuto ()) {
1896 Standard_Boolean BContainsFacet = ContainsFacet ();
1897 Standard_Boolean BZBuffer = ZBufferIsActivated ();
1898 // Si la vue contient des facettes
1899 // et si le ZBuffer n'est pas actif
1900 if (BContainsFacet && ! BZBuffer)
1901 SetZBufferActivity (1);
1902 // Si la vue ne contient pas des facettes
1903 // et si le ZBuffer est actif
1904 if (! BContainsFacet && BZBuffer)
1905 SetZBufferActivity (0);
1908 Aspect_CLayer2d OverCLayer;
1909 Aspect_CLayer2d UnderCLayer;
1910 OverCLayer.ptrLayer = UnderCLayer.ptrLayer = NULL;
1911 if (! AnUnderLayer.IsNull ()) UnderCLayer = AnUnderLayer->CLayer ();
1912 if (! AnOverLayer.IsNull ()) OverCLayer = AnOverLayer->CLayer ();
1913 //OSD::SetSignal (Standard_False);
1914 MyGraphicDriver->Update (MyCView, UnderCLayer, OverCLayer);
1915 //OSD::SetSignal (Standard_True);
1917 MyMatOfMapIsModified = Standard_False;
1918 MyMatOfOriIsModified = Standard_False;
1922 Visual3d_TypeOfAnswer Visual3d_View::AcceptDisplay (const Handle(Graphic3d_Structure)& AStructure) const {
1924 // Recuperation type de visualisation de la vue
1925 Visual3d_TypeOfVisualization ViewType = MyContext.Visualization ();
1927 // Recuperation type de visualisation de la structure
1928 Graphic3d_TypeOfStructure StructType = AStructure->Visual ();
1930 Visual3d_TypeOfAnswer Result = Visual3d_TOA_NO;
1932 if (StructType == Graphic3d_TOS_ALL)
1933 // La structure accepte tout type de vue
1934 Result = Visual3d_TOA_YES;
1936 if ((StructType == Graphic3d_TOS_SHADING)
1937 && (ViewType == Visual3d_TOV_SHADING))
1938 Result = Visual3d_TOA_YES;
1939 if ((StructType == Graphic3d_TOS_WIREFRAME)
1940 && (ViewType == Visual3d_TOV_WIREFRAME))
1941 Result = Visual3d_TOA_YES;
1942 if ((StructType == Graphic3d_TOS_COMPUTED)
1943 && (ViewType == Visual3d_TOV_WIREFRAME))
1944 Result = Visual3d_TOA_COMPUTE;
1945 if ((StructType == Graphic3d_TOS_COMPUTED)
1946 && (ViewType == Visual3d_TOV_SHADING))
1947 Result = Visual3d_TOA_COMPUTE;
1951 if (Result == Visual3d_TOA_YES)
1952 cout << "YES = Visual3d_View" << MyCView.ViewId
1953 << "::AcceptDisplay (" << AStructure->Identification () << ")\n";
1954 if (Result == Visual3d_TOA_NO)
1955 cout << "NO = Visual3d_View" << MyCView.ViewId
1956 << "::AcceptDisplay (" << AStructure->Identification () << ")\n";
1957 if (Result == Visual3d_TOA_COMPUTE)
1958 cout << "COMPUTE = Visual3d_View" << MyCView.ViewId
1959 << "::AcceptDisplay (" << AStructure->Identification () << ")\n";
1967 void Visual3d_View::ChangeDisplayPriority (const Handle(Graphic3d_Structure)& AStructure, const Standard_Integer OldPriority, const Standard_Integer NewPriority) {
1969 if (IsDeleted ()) return;
1970 if (! IsDefined ()) return;
1971 if (! IsActive ()) return;
1972 if (! IsDisplayed (AStructure)) return;
1974 Standard_Integer Index = IsComputed (AStructure);
1976 if ( Index != 0 && ComputedMode () && !DegenerateModeIsOn () )
1978 if ((Index != 0) && (! DegenerateModeIsOn ()))
1982 Standard_Integer StructId = MyCOMPUTEDSequence.Value (Index)->Identification ();
1983 cout << "Visual3d_View" << MyCView.ViewId << "::ChangeDisplayPriority ("
1984 << AStructure->Identification () << "/" << StructId
1985 << ", " << OldPriority << ", " << NewPriority << ")\n";
1988 MyGraphicDriver->EraseStructure
1990 *(Graphic3d_CStructure *)
1991 MyCOMPUTEDSequence.Value (Index)->CStructure ());
1992 MyGraphicDriver->DisplayStructure
1994 *(Graphic3d_CStructure *)
1995 MyCOMPUTEDSequence.Value (Index)->CStructure (),
2000 Standard_Integer StructId = AStructure->Identification ();
2001 cout << "Visual3d_View" << MyCView.ViewId << "::ChangeDisplayPriority ("
2002 << AStructure->Identification () << "/" << StructId
2003 << ", " << OldPriority << ", " << NewPriority << ")\n";
2006 MyGraphicDriver->EraseStructure
2008 *(Graphic3d_CStructure *)AStructure->CStructure ());
2009 MyGraphicDriver->DisplayStructure
2011 *(Graphic3d_CStructure *)AStructure->CStructure (),
2017 void Visual3d_View::Clear (const Handle(Graphic3d_Structure)& AStructure, const Standard_Boolean WithDestruction) {
2020 cout << "Visual3d_View" << MyCView.ViewId << "::Clear ("
2021 << AStructure->Identification () << ")\n";
2025 Standard_Integer Index = IsComputed (AStructure);
2028 cout << "La structure " << AStructure->Identification ()
2029 << " calculee, dans la view "
2030 << Identification () << ", par la structure "
2031 << MyCOMPUTEDSequence.Value (Index)->Identification ()
2035 MyCOMPUTEDSequence.Value (Index)->GraphicClear (WithDestruction);
2036 MyCOMPUTEDSequence.Value (Index)->SetHLRValidation (Standard_False);
2041 void Visual3d_View::Connect (const Handle(Graphic3d_Structure)& AMother, const Handle(Graphic3d_Structure)& ADaughter) {
2043 #ifdef TRACE_CONNECT
2044 cout << "Visual3d_View" << MyCView.ViewId << "::Connect ("
2045 << AMother->Identification ()
2046 << ADaughter->Identification () << ")\n";
2050 Standard_Integer IndexM = IsComputed (AMother);
2051 Standard_Integer IndexD = IsComputed (ADaughter);
2053 if (IndexM != 0 && IndexD != 0) {
2054 #ifdef TRACE_CONNECT
2055 cout << "La structure " << AMother->Identification ()
2056 << " est connectee a la structure "
2057 << ADaughter->Identification () << endl;
2058 cout << "Ces structures sont calculees.\n";
2059 cout << "Dans la view " << Identification ()
2061 << MyCOMPUTEDSequence.Value (IndexM)->Identification ()
2062 << " est connectee a la structure "
2063 << MyCOMPUTEDSequence.Value (IndexD)->Identification ()
2066 MyCOMPUTEDSequence.Value (IndexM)->GraphicConnect (MyCOMPUTEDSequence.Value (IndexD));
2071 void Visual3d_View::Disconnect (const Handle(Graphic3d_Structure)& AMother, const Handle(Graphic3d_Structure)& ADaughter) {
2073 #ifdef TRACE_CONNECT
2074 cout << "Visual3d_View" << MyCView.ViewId << "::Disconnect ("
2075 << AMother->Identification ()
2076 << ADaughter->Identification () << ")\n";
2080 Standard_Integer IndexM = IsComputed (AMother);
2081 Standard_Integer IndexD = IsComputed (ADaughter);
2083 if (IndexM != 0 && IndexD != 0) {
2084 #ifdef TRACE_CONNECT
2085 cout << "La structure " << AMother->Identification ()
2086 << " est disconnectee de la structure "
2087 << ADaughter->Identification () << endl;
2088 cout << "Ces structures sont calculees.\n";
2089 cout << "Dans la view " << Identification ()
2091 << MyCOMPUTEDSequence.Value (IndexM)->Identification ()
2092 << " est disconnectee de la structure "
2093 << MyCOMPUTEDSequence.Value (IndexD)->Identification ()
2096 MyCOMPUTEDSequence.Value (IndexM)->GraphicDisconnect (MyCOMPUTEDSequence.Value (IndexD));
2101 void Visual3d_View::Display (const Handle(Graphic3d_Structure)& AStructure) {
2103 Display (AStructure, MyViewManager->UpdateMode ());
2107 void Visual3d_View::Display (const Handle(Graphic3d_Structure)& AStructure, const Aspect_TypeOfUpdate AnUpdateMode) {
2109 if (IsDeleted ()) return;
2110 if (! IsDefined ()) return;
2111 if (! IsActive ()) return;
2113 // Si Display sur une structure qui est dans la liste
2114 // des structures calculees alors qu'elle n'est pas
2115 // ou plus, du type calcule =>
2116 // On l'enleve ainsi que l'ancienne compute associee
2117 // Ceci arrive lorsque la hlhsr redevient du type
2118 // non computed apres un SetVisual.
2119 Standard_Integer Index = IsComputed (AStructure);
2121 if ((Index != 0) && (AStructure->Visual () != Graphic3d_TOS_COMPUTED)) {
2124 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) {
2125 cout << "In Visual3d_View::Display, ";
2126 cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2127 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2131 MyTOCOMPUTESequence.Remove (Index);
2132 MyCOMPUTEDSequence.Remove (Index);
2135 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
2136 cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2137 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2143 Visual3d_TypeOfAnswer Answer = AcceptDisplay (AStructure);
2145 #ifdef TRACE_DISPLAY
2146 Standard_Integer StructId = AStructure->Identification ();
2147 cout << "Visual3d_View" << MyCView.ViewId << "::Display ("
2148 << StructId << ");\n";
2152 if (Answer == Visual3d_TOA_NO) {
2153 #ifdef TRACE_DISPLAY
2154 cout << "Answer : Visual3d_TOA_NO\n";
2160 // Mode degenere actif
2162 if ( !ComputedMode () || DegenerateModeIsOn () )
2163 Answer = Visual3d_TOA_YES;
2165 if (DegenerateModeIsOn ()) Answer = Visual3d_TOA_YES;
2169 if (Answer == Visual3d_TOA_YES ) {
2170 #ifdef TRACE_DISPLAY
2171 cout << "Answer : Visual3d_TOA_YES\n";
2174 if (IsDisplayed (AStructure)) return;
2175 MyGraphicDriver->DisplayStructure (
2177 *(Graphic3d_CStructure *)AStructure->CStructure (),
2178 int (AStructure->DisplayPriority ())
2180 MyDisplayedStructure.Add (AStructure);
2181 if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
2184 if (Answer == Visual3d_TOA_COMPUTE) {
2185 #ifdef TRACE_DISPLAY
2186 cout << "Answer : Visual3d_TOA_COMPUTE\n";
2187 cout << "Index : " << Index << "\n" << flush;
2190 // Deja calculee, mais la COMPUTED est-elle encore valide ?
2191 #ifdef TRACE_DISPLAY
2192 if (MyCOMPUTEDSequence.Value (Index)->HLRValidation ()) {
2193 cout << "La structure "
2194 << MyTOCOMPUTESequence.Value (Index)->Identification ()
2195 << " deja calculee, dans la view "
2196 << Identification () << ", par la structure "
2197 << MyCOMPUTEDSequence.Value (Index)->Identification ()
2198 << "\n n'a pas a etre recalculee car HLR est valide\n";
2202 cout << "La structure "
2203 << MyTOCOMPUTESequence.Value (Index)->Identification ()
2204 << " deja calculee, dans la view "
2205 << Identification () << ", par la structure "
2206 << MyCOMPUTEDSequence.Value (Index)->Identification ()
2207 << "\n doit etre recalculee car HLR est invalide\n";
2211 Standard_Integer OldStructId =
2212 MyCOMPUTEDSequence.Value (Index)->Identification ();
2214 // Cas COMPUTED valide
2215 if (MyCOMPUTEDSequence.Value (Index)->HLRValidation ()) {
2217 if (! IsDisplayed (AStructure)) {
2218 MyDisplayedStructure.Add (AStructure);
2219 MyGraphicDriver->DisplayStructure (
2221 *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure (),
2222 int (AStructure->DisplayPriority ())
2224 if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
2229 // Cas COMPUTED invalide
2231 // Existe-t-il une autre representation valide ?
2232 // Recherche dans la sequence des structures deja calculees
2233 // 1/ D'une structure ayant le meme Owner que <AStructure>
2234 // 2/ Qui ne soit pas <AStructure>
2235 // 3/ Dont la COMPUTED soit valide
2236 Standard_Integer NewIndex = HaveTheSameOwner (AStructure);
2238 // Cas COMPUTED invalide, AVEC une valide de remplacement
2239 if (NewIndex != 0) {
2241 if (! IsDisplayed (AStructure)) {
2242 MyCOMPUTEDSequence.SetValue
2243 (Index, MyCOMPUTEDSequence.Value (NewIndex));
2244 OldStructId = MyCOMPUTEDSequence.Value (NewIndex)->
2246 MyDisplayedStructure.Add (AStructure);
2247 MyGraphicDriver->DisplayStructure (
2249 *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (NewIndex)->CStructure (),
2250 int (AStructure->DisplayPriority ())
2252 if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
2257 // Cas COMPUTED invalide, SANS une valide de remplacement
2259 // On efface la COMPUTED si affichee
2260 if (IsDisplayed (AStructure))
2261 MyGraphicDriver->EraseStructure (
2263 *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure ()
2267 } // if (Index != 0)
2269 // Compute + Validation
2271 Handle(Graphic3d_Structure) TheStructure = AStructure->Compute (this);
2273 Handle(Graphic3d_Structure) TheStructure;
2274 TColStd_Array2OfReal ATrsf (0, 3, 0, 3);
2275 AStructure->Transform (ATrsf);
2277 TColStd_Array2OfReal Ident (0, 3, 0, 3);
2278 Standard_Integer ii, jj;
2279 for (ii=0; ii<=3; ii++)
2280 for (jj=0; jj<=3; jj++)
2281 Ident (ii, jj) = (ii == jj ? 1.0 : 0.0);
2282 TheStructure = MyCOMPUTEDSequence.Value (Index);
2283 TheStructure->SetTransform (Ident, Graphic3d_TOC_REPLACE);
2284 if (AStructure->IsTransformed ()) {
2285 AStructure->Compute (this, ATrsf, TheStructure);
2288 AStructure->Compute (this, TheStructure);
2292 if (AStructure->IsTransformed ()) {
2293 TheStructure = AStructure->Compute (this, ATrsf);
2296 TheStructure = AStructure->Compute (this);
2300 TheStructure->SetHLRValidation (Standard_True);
2303 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
2304 cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2305 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2309 // On ajoute la TOCOMPUTE et la COMPUTED associee aux sequences
2310 MyTOCOMPUTESequence.Append (AStructure);
2311 MyCOMPUTEDSequence.Append (TheStructure);
2314 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
2315 cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2316 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2320 // On enleve, si necessaire, les anciennes
2322 MyTOCOMPUTESequence.Remove (Index);
2323 MyCOMPUTEDSequence.Remove (Index);
2327 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
2328 cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2329 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2333 // Recuperation type de visualisation de la vue
2334 Visual3d_TypeOfVisualization ViewType = MyContext.Visualization ();
2336 // De quel type sera la computed ?
2337 Standard_Boolean ComputeWireframe = ((ViewType == Visual3d_TOV_WIREFRAME) &&
2338 (AStructure->ComputeVisual () != Graphic3d_TOS_SHADING));
2340 Standard_Boolean ComputeShading = ((ViewType == Visual3d_TOV_SHADING) &&
2341 (AStructure->ComputeVisual () != Graphic3d_TOS_WIREFRAME));
2343 if (ComputeWireframe)
2344 TheStructure->SetVisual (Graphic3d_TOS_WIREFRAME);
2346 TheStructure->SetVisual (Graphic3d_TOS_SHADING);
2348 if (! ComputeShading && ! ComputeWireframe)
2349 Answer = Visual3d_TOA_NO;
2351 Answer = AcceptDisplay (TheStructure);
2353 if (AStructure->IsHighlighted()) {
2354 TheStructure->SetHighlightColor (AStructure->HighlightColor ());
2355 TheStructure->GraphicHighlight (Aspect_TOHM_COLOR);
2358 #ifdef TRACE_DISPLAY
2359 cout << "La structure " << StructId
2360 << " dans la view " << Identification ()
2361 << " est calculee par la structure "
2362 << TheStructure->Identification ();
2363 if (Answer == Visual3d_TOA_YES)
2364 cout << " et affichee\n";
2366 cout << " mais pas affichee\n";
2370 // On ne l'affiche que si la structure calculee
2371 // est du bon type par rapport a celui de la vue.
2372 if (Answer != Visual3d_TOA_NO) {
2373 if (! IsDisplayed (AStructure))
2374 MyDisplayedStructure.Add (AStructure);
2375 MyGraphicDriver->DisplayStructure (
2377 *(Graphic3d_CStructure *)TheStructure->CStructure (),
2378 int (AStructure->DisplayPriority ())
2380 if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
2382 } // Visual3d_TOA_COMPUTE
2385 void Visual3d_View::Erase (const Handle(Graphic3d_Structure)& AStructure) {
2387 if (IsDeleted ()) return;
2389 Erase (AStructure, MyViewManager->UpdateMode ());
2393 void Visual3d_View::Erase (const Handle(Graphic3d_Structure)& AStructure, const Aspect_TypeOfUpdate AnUpdateMode) {
2395 Standard_Integer StructId;
2397 if (IsDeleted ()) return;
2399 // Pas de test sur window car la structure est affichee que
2400 // si la window existe, donc un seul test suffit.
2401 if (IsDisplayed (AStructure)) {
2402 Visual3d_TypeOfAnswer Answer = AcceptDisplay (AStructure);
2404 // Mode degenere actif
2406 if ( !ComputedMode () || DegenerateModeIsOn () )
2407 Answer = Visual3d_TOA_YES;
2409 if (DegenerateModeIsOn ()) Answer = Visual3d_TOA_YES;
2412 if (Answer != Visual3d_TOA_COMPUTE) {
2413 MyGraphicDriver->EraseStructure (
2415 *(Graphic3d_CStructure *)AStructure->CStructure ()
2419 if (Answer == Visual3d_TOA_COMPUTE) {
2420 Standard_Integer Index = IsComputed (AStructure);
2422 cout << "Visual3d_View" << MyCView.ViewId << "::Erase ("
2423 << AStructure->Identification () << ");\n";
2424 cout << "Index : " << Index << "\n";
2428 if ( Index != 0 && ComputedMode () &&
2429 !DegenerateModeIsOn () )
2431 if ((Index != 0) && (! DegenerateModeIsOn ()))
2435 MyCOMPUTEDSequence.Value (Index)->Identification ();
2437 cout << "Structure " << AStructure->Identification ()
2438 << " calculee, dans la view "
2439 << Identification () << ", par la structure "
2440 << StructId << " est effacee. \n";
2443 MyGraphicDriver->EraseStructure
2444 (MyCView, *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure ());
2446 // Le else est impossible
2448 MyDisplayedStructure.Remove (AStructure);
2449 if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
2454 void Visual3d_View::Highlight (const Handle(Graphic3d_Structure)& AStructure, const Aspect_TypeOfHighlightMethod AMethod) {
2457 cout << "Visual3d_View" << MyCView.ViewId << "::Highlight ("
2458 << AStructure->Identification () << ")\n";
2462 Standard_Integer Index = IsComputed (AStructure);
2465 cout << "La structure " << AStructure->Identification ()
2466 << " calculee, dans la view "
2467 << Identification () << ", par la structure "
2468 << MyCOMPUTEDSequence.Value (Index)->Identification ()
2469 << " passe en mode highlight.\n";
2472 (MyCOMPUTEDSequence.Value (Index))->SetHighlightColor
2473 (AStructure->HighlightColor ());
2474 (MyCOMPUTEDSequence.Value (Index))->GraphicHighlight (AMethod);
2479 void Visual3d_View::SetTransform (const Handle(Graphic3d_Structure)& AStructure, const TColStd_Array2OfReal& ATrsf) {
2482 cout << "Visual3d_View" << MyCView.ViewId << "::Transform ("
2483 << AStructure->Identification () << ")\n";
2487 Standard_Integer Index = IsComputed (AStructure);
2490 cout << "La structure " << AStructure->Identification ()
2491 << " calculee, dans la view "
2492 << Identification () << ", par la structure "
2493 << MyCOMPUTEDSequence.Value (Index)->Identification ()
2494 << " est transformee.\n";
2497 // Test un peu leger !
2498 // On ne transmet la trsf que si c'est :
2501 if (ATrsf (0, 1) != 0. || ATrsf (0, 2) != 0.
2502 || ATrsf (1, 0) != 0. || ATrsf (1, 2) != 0.
2503 || ATrsf (2, 0) != 0. || ATrsf (2, 1) != 0.)
2504 ReCompute (AStructure);
2506 MyCOMPUTEDSequence.Value (Index)->GraphicTransform (ATrsf);
2511 void Visual3d_View::UnHighlight (const Handle(Graphic3d_Structure)& AStructure) {
2514 cout << "Visual3d_View" << MyCView.ViewId << "::UnHighlight ("
2515 << AStructure->Identification () << ")\n";
2519 Standard_Integer Index = IsComputed (AStructure);
2522 cout << "La structure " << AStructure->Identification ()
2523 << " calculee, dans la view "
2524 << Identification () << ", par la structure "
2525 << MyCOMPUTEDSequence.Value (Index)->Identification ()
2526 << " passe en mode unhighlight.\n";
2529 MyCOMPUTEDSequence.Value (Index)->GraphicUnHighlight ();
2535 Standard_Integer Visual3d_View::IsComputed (const Handle(Graphic3d_Structure)& AStructure) const {
2537 Standard_Integer StrId = AStructure->Identification ();
2539 Standard_Integer Result = 0;
2540 Standard_Integer Length = MyTOCOMPUTESequence.Length ();
2542 // Recherche de la structure <AStructure> dans la
2543 // sequence des structures deja calculees
2544 for (Standard_Integer i=1; i<=Length && Result==0; i++)
2545 if ((MyTOCOMPUTESequence.Value (i))->Identification ()
2546 == StrId) Result = i;
2548 cout << "\nDans la vue " << Identification () << " la structure ";
2550 cout << StrId << " est calculee par "
2551 << MyCOMPUTEDSequence.Value (Result)->Identification ()
2554 cout << StrId << " n'est pas calculee\n" << flush;
2558 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) {
2559 cout << "In Visual3d_View::IsComputed, ";
2560 cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2561 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2570 Standard_Boolean Visual3d_View::IsDisplayed (const Handle(Graphic3d_Structure)& AStructure) const {
2572 Standard_Boolean Result = Standard_False;
2574 if (IsDeleted ()) return Result;
2576 Result = MyDisplayedStructure.Contains (AStructure);
2583 Standard_Boolean Visual3d_View::ContainsComputedStructure () const {
2585 Standard_Boolean Result = Standard_False;
2587 if (MyDisplayedStructure.IsEmpty ()) return Result;
2589 Graphic3d_MapIteratorOfMapOfStructure Iterator (MyDisplayedStructure);
2591 Standard_Integer i = MyDisplayedStructure.Extent ();
2593 // On s'arrette a la premiere structure qui est du type TOS_COMPUTED
2594 while (! Result && Iterator.More ()) {
2596 (((Iterator.Key ())->Visual ()) == Graphic3d_TOS_COMPUTED);
2598 // Iterator.Next () se positionne sur la
2599 // prochaine structure
2608 Standard_Boolean Visual3d_View::ContainsFacet () const {
2610 return ContainsFacet (MyDisplayedStructure);
2614 Standard_Boolean Visual3d_View::ContainsFacet (const Graphic3d_MapOfStructure& ASet) const {
2616 Standard_Boolean Result = Standard_False;
2618 if (ASet.IsEmpty ()) return Result;
2620 Graphic3d_MapIteratorOfMapOfStructure Iterator (ASet);
2622 // On s'arrette a la premiere structure qui contient une facette
2623 for ( Iterator.Initialize (ASet);
2624 Iterator.More () && ! Result;
2626 Result = (Iterator.Key ())->ContainsFacet ();
2632 void Visual3d_View::MinMaxValues (Standard_Real& XMin, Standard_Real& YMin, Standard_Real& ZMin, Standard_Real& XMax, Standard_Real& YMax, Standard_Real& ZMax) const {
2635 (MyDisplayedStructure, XMin, YMin, ZMin, XMax, YMax, ZMax);
2639 void Visual3d_View::MinMaxValues (const Graphic3d_MapOfStructure& ASet, Standard_Real& XMin, Standard_Real& YMin, Standard_Real& ZMin, Standard_Real& XMax, Standard_Real& YMax, Standard_Real& ZMax) const {
2641 if (ASet.IsEmpty ()) {
2642 XMin = RealFirst ();
2643 YMin = RealFirst ();
2644 ZMin = RealFirst ();
2652 Standard_Real Xm, Ym, Zm, XM, YM, ZM;
2653 Graphic3d_MapIteratorOfMapOfStructure Iterator (ASet);
2659 XMax = RealFirst ();
2660 YMax = RealFirst ();
2661 ZMax = RealFirst ();
2663 for ( Iterator.Initialize (ASet);
2667 if ( (Iterator.Key ())->IsInfinite ()){
2668 //XMin, YMin .... ZMax are initialized by means of infinite line data
2669 (Iterator.Key ())->MinMaxValues (Xm, Ym, Zm, XM, YM, ZM);
2670 if ( Xm != RealFirst() && Xm < XMin )
2672 if ( Ym != RealFirst() && Ym < YMin )
2674 if ( Zm != RealFirst() && Zm < ZMin )
2676 if ( XM != RealLast() && XM > XMax )
2678 if ( YM != RealLast() && YM > YMax )
2680 if ( ZM != RealLast() && ZM > ZMax )
2683 // Seules les structures non vides et non infinies
2684 // sont prises en compte pour le calcul des MinMax
2685 if (! (Iterator.Key ())->IsInfinite () &&
2686 ! (Iterator.Key ())->IsEmpty ()) {
2687 (Iterator.Key ())->MinMaxValues(Xm, Ym, Zm, XM, YM, ZM);
2688 /* ABD 29/10/04 Transform Persistence of Presentation( pan, zoom, rotate ) */
2689 //"FitAll" operation ignores object with transform persitence parameter
2690 if( (Iterator.Key ())->TransformPersistenceMode() == Graphic3d_TMF_None )
2692 if (Xm < XMin) XMin = Xm;
2693 if (Ym < YMin) YMin = Ym;
2694 if (Zm < ZMin) ZMin = Zm;
2695 if (XM > XMax) XMax = XM;
2696 if (YM > YMax) YMax = YM;
2697 if (ZM > ZMax) ZMax = ZM;
2702 // Les cas suivants ne sont pas debiles
2703 // Par exemple si toutes les structures sont vides ou infinies
2704 if (XMax < XMin) { Xm = XMin; XMin = XMax; XMax = Xm; }
2705 if (YMax < YMin) { Ym = YMin; YMin = YMax; YMax = Ym; }
2706 if (ZMax < ZMin) { Zm = ZMin; ZMin = ZMax; ZMax = Zm; }
2708 Standard_Real Sx, Sy, Sz;
2709 MyViewOrientation.AxialScale(Sx, Sy, Sz);
2710 XMin = (Sx > 1. && XMin < RealFirst ()/Sx)?RealFirst (): XMin*Sx;
2711 XMax = (Sx > 1. && XMax > RealLast ()/Sx)?RealLast (): XMax*Sx;
2712 YMin = (Sy > 1. && YMin < RealFirst ()/Sy)?RealFirst (): YMin*Sy;
2713 YMax = (Sy > 1. && YMax > RealLast ()/Sy)?RealLast (): YMax*Sy;
2714 ZMin = (Sz > 1. && ZMin < RealFirst ()/Sz)?RealFirst (): ZMin*Sz;
2715 ZMax = (Sz > 1. && ZMax > RealLast ()/Sz)?RealLast (): ZMax*Sz;
2718 void Visual3d_View::MinMaxValues (Standard_Real& XMin, Standard_Real& YMin, Standard_Real& XMax, Standard_Real& YMax) {
2720 MinMaxValues (MyDisplayedStructure, XMin, YMin, XMax, YMax);
2724 void Visual3d_View::MinMaxValues (const Graphic3d_MapOfStructure& ASet, Standard_Real& XMin, Standard_Real& YMin, Standard_Real& XMax, Standard_Real& YMax) {
2726 Standard_Real Xm, Ym, Zm, XM, YM, ZM;
2727 Standard_Real Xp, Yp, Zp;
2729 MinMaxValues (ASet, Xm, Ym, Zm, XM, YM, ZM);
2731 Projects (Xm, Ym, Zm, Xp, Yp, Zp);
2735 Projects (XM, YM, ZM, Xp, Yp, Zp);
2739 if (XMax < XMin) { Xp = XMax; XMax = XMin; XMin = Xp; }
2740 if (YMax < YMin) { Yp = YMax; YMax = YMin; YMin = Yp; }
2743 const TColStd_Array2OfReal& Visual3d_View::MatrixOfOrientation () {
2745 if (! MyMatOfOriIsEvaluated) {
2746 MyGraphicDriver->InquireMat
2747 (MyCView, MyMatrixOfOrientation, MyMatrixOfMapping);
2748 MyMatOfMapIsEvaluated = Standard_True;
2749 MyMatOfOriIsEvaluated = Standard_True;
2752 return (MyMatrixOfOrientation);
2756 const TColStd_Array2OfReal& Visual3d_View::MatrixOfMapping () {
2758 if (! MyMatOfMapIsEvaluated) {
2759 MyGraphicDriver->InquireMat
2760 (MyCView, MyMatrixOfOrientation, MyMatrixOfMapping);
2761 MyMatOfMapIsEvaluated = Standard_True;
2762 MyMatOfOriIsEvaluated = Standard_True;
2765 return (MyMatrixOfMapping);
2769 Standard_Integer Visual3d_View::NumberOfDisplayedStructures () const {
2771 Standard_Integer Result = MyDisplayedStructure.Extent ();
2778 void Visual3d_View::Projects (const Standard_Real AX, const Standard_Real AY, const Standard_Real AZ, Standard_Real& APX, Standard_Real& APY, Standard_Real& APZ) const {
2780 math_Vector PtDC (0,3), PtWC (0,3);
2783 // Sinon utiliser un new sur une Visual3d_View (constructeur+destructeur)
2784 // car Projects est une const methode or MatrixOfOrientation et
2785 // MatrixOfMapping ne le sont pas.
2786 Visual3d_View * const newthis = (Visual3d_View * const) this;
2787 newthis->MatrixOfOrientation ();
2788 newthis->MatrixOfMapping ();
2790 // World Coordinate Space
2796 // WCS -> View Reference Coordinate Space
2797 math_Vector PtVRC(0,3);
2798 PtVRC = MyMatrixOfOrientation.Multiplied (PtWC);
2800 // VRCS -> Normalized Projection Coordinate Space
2801 math_Vector PtNPC(0,3);
2802 PtNPC = MyMatrixOfMapping.Multiplied (PtVRC);
2803 for (Standard_Integer i=0; i<3; i++) PtNPC (i) = PtNPC (i) / PtNPC (3);
2806 printf("Display coordinates PtNPC: %f,%f,%f,%f\n",
2807 PtNPC(0),PtNPC(1),PtNPC(2),PtNPC(3));
2810 Standard_Real Ratio;
2812 // NPCS -> Device Coordinate Space
2813 Standard_Real Dx = Standard_Real (MyCView.DefWindow.dx);
2814 Standard_Real Dy = Standard_Real (MyCView.DefWindow.dy);
2817 PtDC (0) = PtNPC (0) * Dx;
2818 PtDC (1) = Dy - PtNPC (1) * Dy * Ratio;
2820 printf("Display coordinates : %f,%f,%f,%f\n",
2821 PtDC(0),PtDC(1),PtDC(2),PtDC(3));
2824 // NPCS -> Window Space
2825 Standard_Real um, vm, uM, vM;
2826 MyViewMapping.WindowLimit (um, vm, uM, vM);
2828 Ratio = (uM - um) / (vM - vm);
2830 PtNPC (1) = PtNPC (1) * Ratio;
2832 PtNPC (0) = PtNPC (0) / Ratio;
2835 printf("Display coordinates PtNPC: %f,%f,%f,%f\n",
2836 PtNPC(0),PtNPC(1),PtNPC(2),PtNPC(3));
2839 Standard_Real fpd = MyViewMapping.FrontPlaneDistance ();
2840 Standard_Real bpd = MyViewMapping.BackPlaneDistance ();
2843 * Les coordonnees de PtNPC sont decrites dans l'espace
2844 * [0-1]x[0-1]x[0-1].
2845 * Il faut transformer x et y dans le window space.
2846 * Il faut transformer z dans l'espace du back et front
2847 * plane, en pensant aux plans de clipping.
2848 * Ces plans de z clipping sont definis entre 0 et 1.
2851 APX = PtNPC (0) * (uM - um) + um;
2852 APY = PtNPC (1) * (vM - vm) + vm;
2853 APZ = PtNPC (2) * (fpd - bpd) + bpd;
2856 Standard_Integer l,c;
2857 printf("OrientationMatrix :");
2858 for( l=0 ; l<4 ; l++ ) {
2859 printf("\n %d->",l);
2860 for( c=0 ; c<4 ; c++ ) {
2861 printf(" %f ,",MyMatrixOfOrientation(c,l));
2865 printf("MappingMatrix :");
2866 for( l=0 ; l<4 ; l++ ) {
2867 printf("\n %d->",l);
2868 for( c=0 ; c<4 ; c++ ) {
2869 printf(" %f ,",MyMatrixOfMapping(c,l));
2873 printf("World coordinates : %f,%f,%f,%f\n",
2874 PtWC(0),PtWC(1),PtWC(2),PtWC(3));
2875 printf("View coordinates : %f,%f,%f,%f\n",
2876 PtVRC(0),PtVRC(1),PtVRC(2),PtVRC(3));
2877 printf("Display coordinates : %f,%f,%f,%f\n",
2878 PtNPC(0),PtNPC(1),PtNPC(2),PtNPC(3));
2879 printf("Window limit : %f,%f,%f,%f\n",um,vm,uM,vM);
2880 printf("Ratio : %f\n",Ratio);
2881 printf("Front-plane : %f back-plane : %f\n",fpd,bpd);
2882 printf("Projection : %f,%f,%f\n \n",APX,APY,APZ);
2886 #endif /* OLD_METHOD */
2888 // OCC18942: This method is likely to duplicate Visual3d_ViewManager::ConvertCoord() one,
2889 // therefore it is necessary to consider merging the two methods or making them call the same
2890 // graphic driver's method after OCCT 6.3.
2891 void Visual3d_View::Projects (const Standard_Real AX, const Standard_Real AY, const Standard_Real AZ, Standard_Real& APX, Standard_Real& APY, Standard_Real& APZ) {
2893 Standard_Real PtX, PtY, PtZ, PtT;
2895 static Standard_Real Ratio, um, vm, uM, vM;
2896 static Standard_Real fpd, bpd;
2898 if (! MyMatOfOriIsEvaluated || ! MyMatOfMapIsEvaluated) {
2899 MyGraphicDriver->InquireMat
2900 (MyCView, MyMatrixOfOrientation, MyMatrixOfMapping);
2901 MyMatOfOriIsEvaluated = MyMatOfMapIsEvaluated = Standard_True;
2904 // WCS -> View Reference Coordinate Space
2905 PtX = MyMatrixOfOrientation (0, 0) * AX
2906 + MyMatrixOfOrientation (0, 1) * AY
2907 + MyMatrixOfOrientation (0, 2) * AZ
2908 + MyMatrixOfOrientation (0, 3);
2909 PtY = MyMatrixOfOrientation (1, 0) * AX
2910 + MyMatrixOfOrientation (1, 1) * AY
2911 + MyMatrixOfOrientation (1, 2) * AZ
2912 + MyMatrixOfOrientation (1, 3);
2913 PtZ = MyMatrixOfOrientation (2, 0) * AX
2914 + MyMatrixOfOrientation (2, 1) * AY
2915 + MyMatrixOfOrientation (2, 2) * AZ
2916 + MyMatrixOfOrientation (2, 3);
2917 PtT = MyMatrixOfOrientation (3, 0) * AX
2918 + MyMatrixOfOrientation (3, 1) * AY
2919 + MyMatrixOfOrientation (3, 2) * AZ
2920 + MyMatrixOfOrientation (3, 3);
2922 // VRCS -> Normalized Projection Coordinate Space
2923 APX = MyMatrixOfMapping (0, 0) * PtX
2924 + MyMatrixOfMapping (0, 1) * PtY
2925 + MyMatrixOfMapping (0, 2) * PtZ
2926 + MyMatrixOfMapping (0, 3) * PtT;
2927 APY = MyMatrixOfMapping (1, 0) * PtX
2928 + MyMatrixOfMapping (1, 1) * PtY
2929 + MyMatrixOfMapping (1, 2) * PtZ
2930 + MyMatrixOfMapping (1, 3) * PtT;
2931 APZ = MyMatrixOfMapping (2, 0) * PtX
2932 + MyMatrixOfMapping (2, 1) * PtY
2933 + MyMatrixOfMapping (2, 2) * PtZ
2934 + MyMatrixOfMapping (2, 3) * PtT;
2935 APT = MyMatrixOfMapping (3, 0) * PtX
2936 + MyMatrixOfMapping (3, 1) * PtY
2937 + MyMatrixOfMapping (3, 2) * PtZ
2938 + MyMatrixOfMapping (3, 3) * PtT;
2944 // NPCS -> Window Space
2945 MyViewMapping.WindowLimit (um, vm, uM, vM);
2946 fpd = MyViewMapping.FrontPlaneDistance ();
2947 bpd = MyViewMapping.BackPlaneDistance ();
2949 if(MyCView.Mapping.IsCustomMatrix) {
2950 // OCC18942: SAN - If orientation and mapping matrices are those used by OpenGL
2951 // visualization, then X, Y and Z coordinates normally vary between -1 and 1
2952 APX = ( APX + 1 ) * 0.5 * (uM - um) + um;
2953 APY = ( APY + 1 ) * 0.5 * (vM - vm) + vm;
2955 Ratio = (uM - um) / (vM - vm);
2962 * Les coordonnees de APX, APY, APZ sont decrites dans
2963 * l'espace [0-1]x[0-1]x[0-1].
2964 * Il faut transformer x et y dans le window space.
2965 * Il faut transformer z dans l'espace du back et front
2966 * plane, en pensant aux plans de clipping.
2967 * Ces plans de z clipping sont definis entre 0 et 1.
2969 APX = APX * (uM - um) + um;
2970 APY = APY * (vM - vm) + vm;
2972 APZ = APZ * (fpd - bpd) + bpd;
2975 Standard_Integer Visual3d_View::Identification () const {
2977 return (Standard_Integer (MyCView.ViewId));
2981 void Visual3d_View::Exploration () const {
2983 if (IsDeleted ()) return;
2985 MyGraphicDriver->DumpView (MyCView);
2989 Standard_Boolean Visual3d_View::ZBufferIsActivated () const {
2991 if (IsDeleted ()) return (Standard_False);
2993 if ((! IsDefined ()) || (! IsActive ())) return (Standard_False);
2995 // -1 => non force par le programmeur => depend du type de visualisation
2996 // 0 ou 1 => force par le programmeur
2998 if (MyCView.Context.ZBufferActivity == -1)
2999 if (MyContext.Visualization () == Visual3d_TOV_SHADING)
3000 return (Standard_True);
3002 return (Standard_False);
3004 if (MyCView.Context.ZBufferActivity)
3005 return (Standard_True);
3007 return (Standard_False);
3011 void Visual3d_View::SetTransparency (const Standard_Boolean AnActivity) {
3013 if (IsDeleted ()) return;
3015 if ((! IsDefined ()) || (! IsActive ())) return;
3017 MyGraphicDriver->Transparency (MyCView, AnActivity);
3021 void Visual3d_View::SetZBufferActivity (const Standard_Integer AnActivity) {
3023 if (MyCView.Context.ZBufferActivity == AnActivity) return;
3025 if (IsDeleted ()) return;
3027 if ((! IsDefined ()) || (! IsActive ())) return;
3029 MyCView.Context.ZBufferActivity = AnActivity;
3030 MyGraphicDriver->SetVisualisation (MyCView);
3034 void Visual3d_View::UpdateView () {
3036 MyCView.Context.Aliasing = (MyContext.AliasingIsOn () ? 1:0);
3037 MyCView.Context.BackZClipping =
3038 (MyContext.BackZClippingIsOn () ? 1:0);
3039 MyCView.Context.FrontZClipping =
3040 (MyContext.FrontZClippingIsOn() ? 1:0);
3041 MyCView.Context.DepthCueing =
3042 (MyContext.DepthCueingIsOn () ? 1:0);
3044 MyCView.Context.ZClipFrontPlane =
3045 float (MyContext.ZClippingFrontPlane ());
3046 MyCView.Context.ZClipBackPlane =
3047 float (MyContext.ZClippingBackPlane ());
3048 MyCView.Context.DepthFrontPlane =
3049 float (MyContext.DepthCueingFrontPlane ());
3050 MyCView.Context.DepthBackPlane =
3051 float (MyContext.DepthCueingBackPlane ());
3053 MyCView.Context.Model = int (MyContext.Model ());
3054 MyCView.Context.Visualization = int (MyContext.Visualization ());
3056 Handle(Graphic3d_TextureEnv) TempTextureEnv = MyContext.TextureEnv();
3057 if (! TempTextureEnv.IsNull()) MyCView.Context.TexEnvId = TempTextureEnv->TextureId();
3058 else MyCView.Context.TexEnvId = -1;
3059 MyCView.Context.SurfaceDetail = MyContext.SurfaceDetail();
3063 void Visual3d_View::Compute () {
3066 Standard_Integer Length = MyCOMPUTEDSequence.Length ();
3067 for (i=1; i<=Length; i++)
3068 (MyCOMPUTEDSequence.Value (i))->SetHLRValidation (Standard_False);
3070 // Si le mode degenere est actif, on ne recalcule rien
3072 if ( DegenerateModeIsOn () || !ComputedMode () ) return;
3074 if (DegenerateModeIsOn ()) return;
3078 * Forcer le HLRValidation a False sur toutes les structures
3079 * calculees dans la vue.
3082 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) {
3083 cout << "In Visual3d_View::Compute, ";
3084 cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length ()
3085 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
3091 * Changement d'orientation ou de type de projection =>
3092 * Erase des structures qui ont ete calculees pour
3093 * l'orientation precedente.
3094 * Recalcul des nouvelles structures.
3095 * Passage du mode degenere ON a OFF =>
3096 * Erase des structures qui ont ete calculees avant que
3097 * le mode degenere passe a ON.
3098 * Recalcul des nouvelles structures.
3100 Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure);
3101 Visual3d_TypeOfAnswer Answer;
3103 i = MyDisplayedStructure.Extent ();
3105 Graphic3d_SequenceOfStructure FooSequence;
3107 while (S1Iterator.More ()) {
3108 Answer = AcceptDisplay (S1Iterator.Key ());
3109 // Si la structure etait calculee, on la recalcule.
3110 if (Answer == Visual3d_TOA_COMPUTE) {
3112 cout << "AcceptDisplay ("
3113 << (S1Iterator.Key ())->Identification ()
3114 << ") == Visual3d_TOA_COMPUTE;\n";
3117 //Display (S1Iterator.Key (), Aspect_TOU_WAIT);
3118 FooSequence.Append (S1Iterator.Key ());
3121 // S1Iterator.Next () se positionne sur la
3122 // prochaine structure
3126 Length = FooSequence.Length ();
3127 // On affiche les structures stockees
3128 for (i=1; i<=Length; i++)
3129 Display (FooSequence.Value (i), Aspect_TOU_WAIT);
3130 if (Length != 0) FooSequence.Clear ();
3134 void Visual3d_View::ReCompute (const Handle(Graphic3d_Structure)& AStructure) {
3136 if ( DegenerateModeIsOn () || !ComputedMode () ) return;
3138 if (DegenerateModeIsOn()) return;
3141 if (IsDeleted ()) return;
3143 if ((! IsDefined ()) || (! IsActive ())) return;
3145 if (! MyWindow->IsMapped ()) return;
3147 if (! AStructure->IsDisplayed ()) return;
3149 Visual3d_TypeOfAnswer Answer;
3151 Answer = AcceptDisplay (AStructure);
3153 if (Answer == Visual3d_TOA_COMPUTE) {
3154 Standard_Integer Index = IsComputed (AStructure);
3157 cout << "La structure " << AStructure->Identification ()
3158 << " n'est pas calculee dans la view "
3159 << Identification () << "\n";
3164 Standard_Integer OldStructId, NewStructId;
3166 MyCOMPUTEDSequence.Value (Index)->Identification ();
3168 Standard_Integer StructId = AStructure->Identification ();
3169 cout << "La structure " << StructId
3170 << " calculee, dans la view "
3171 << Identification () << ", par la structure "
3172 << OldStructId << " est recalculee.\n";
3176 // Compute + Validation
3178 Handle(Graphic3d_Structure) TheStructure = AStructure->Compute (this);
3180 Handle(Graphic3d_Structure) TheStructure;
3181 TColStd_Array2OfReal ATrsf (0, 3, 0, 3);
3182 AStructure->Transform (ATrsf);
3184 TColStd_Array2OfReal Ident (0, 3, 0, 3);
3185 Standard_Integer ii, jj;
3186 for (ii=0; ii<=3; ii++)
3187 for (jj=0; jj<=3; jj++)
3188 Ident (ii, jj) = (ii == jj ? 1.0 : 0.0);
3189 TheStructure = MyCOMPUTEDSequence.Value (Index);
3190 TheStructure->SetTransform (Ident, Graphic3d_TOC_REPLACE);
3191 if (AStructure->IsTransformed ()) {
3192 AStructure->Compute (this, ATrsf, TheStructure);
3195 AStructure->Compute (this, TheStructure);
3199 if (AStructure->IsTransformed ()) {
3200 TheStructure = AStructure->Compute (this, ATrsf);
3203 TheStructure = AStructure->Compute (this);
3207 TheStructure->SetHLRValidation (Standard_True);
3209 // Recuperation type de visualisation de la vue
3210 Visual3d_TypeOfVisualization ViewType = MyContext.Visualization ();
3212 // De quel type sera la computed ?
3213 Standard_Boolean ComputeWireframe = ((ViewType == Visual3d_TOV_WIREFRAME) &&
3214 (AStructure->ComputeVisual () != Graphic3d_TOS_SHADING));
3216 Standard_Boolean ComputeShading = ((ViewType == Visual3d_TOV_SHADING) &&
3217 (AStructure->ComputeVisual () != Graphic3d_TOS_WIREFRAME));
3219 if (ComputeWireframe)
3220 TheStructure->SetVisual (Graphic3d_TOS_WIREFRAME);
3222 TheStructure->SetVisual (Graphic3d_TOS_SHADING);
3224 if (AStructure->IsHighlighted ()) {
3225 TheStructure->SetHighlightColor
3226 (AStructure->HighlightColor ());
3227 TheStructure->GraphicHighlight (Aspect_TOHM_COLOR);
3231 // Recherche de la structure <AStructure>
3232 // dans la sequence des structures a calculer
3233 NewStructId = TheStructure->Identification ();
3235 // On efface l'ancienne calculee et on affiche la nouvelle
3236 MyGraphicDriver->EraseStructure (
3238 *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure ());
3239 MyGraphicDriver->DisplayStructure (
3241 *(Graphic3d_CStructure *)TheStructure->CStructure (),
3242 int (AStructure->DisplayPriority ())
3246 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) {
3247 cout << "In Visual3d_View::ReCompute, ";
3248 cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length ()
3249 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
3254 // On ajoute la hlhsr et
3255 // la nouvelle compute associee
3256 MyTOCOMPUTESequence.Append (AStructure);
3257 MyCOMPUTEDSequence.Append (TheStructure);
3260 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
3261 cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
3262 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
3266 // On enleve la hlhsr et
3267 // l'ancienne compute associee
3269 MyTOCOMPUTESequence.Remove (Index);
3270 MyCOMPUTEDSequence.Remove (Index);
3273 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
3274 cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
3275 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
3285 Visual3d_View::SetAnimationModeOn ( const Standard_Boolean degenerate ) {
3287 Visual3d_View::SetAnimationModeOn () {
3290 if (AnimationModeIsOn ()) return;
3292 AnimationModeIsActive = Standard_True;
3295 SetDegenerateModeOn ();
3297 SetDegenerateModeOff ();
3299 MyGraphicDriver->BeginAnimation (MyCView);
3303 void Visual3d_View::SetAnimationModeOff () {
3305 if (! AnimationModeIsOn ()) return;
3307 AnimationModeIsActive = Standard_False;
3309 SetDegenerateModeOff ();
3311 MyGraphicDriver->EndAnimation (MyCView);
3315 Standard_Boolean Visual3d_View::AnimationModeIsOn () const {
3317 return AnimationModeIsActive;
3321 void Visual3d_View::SetDegenerateModeOn () {
3324 cout << "Visual3d_View" << MyCView.ViewId
3325 << "::SetDegenerateModeOn ();\n";
3329 // Si le mode degenere est deja actif, on ne recalcule rien
3330 if (DegenerateModeIsOn ()) return;
3331 DegenerateModeIsActive = Standard_True;
3334 MyCView.IsDegenerates = 1;
3337 * Changement d'activite du mode degenere
3338 * Erase des structures qui ont ete calculees
3339 * et affichees quand le mode etait off.
3340 * Affichage des structures non calculees.
3342 Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure);
3343 Visual3d_TypeOfAnswer Answer;
3344 Standard_Integer StructId;
3346 while (S1Iterator.More ()) {
3348 Answer = AcceptDisplay (S1Iterator.Key ());
3349 // Si la structure etait a calculer, on efface la
3350 // structure calculee et l'on l'affiche
3351 // (C'est le role du passage en mode degenere)
3353 if (Answer == Visual3d_TOA_COMPUTE) {
3354 Standard_Integer Index = IsComputed (S1Iterator.Key ());
3357 MyCOMPUTEDSequence.Value (Index)->Identification ();
3359 cout << "La structure " << S1Iterator.Key ()->Identification ()
3360 << " calculee, dans la view "
3361 << Identification () << ", par la structure "
3362 << StructId << " passe en mode degenere.\n";
3363 cout << "On efface " << StructId << " puis on affiche "
3364 << S1Iterator.Key ()->Identification () << "\n";
3367 MyGraphicDriver->EraseStructure
3368 (MyCView, *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure ());
3369 MyGraphicDriver->DisplayStructure (
3371 *(Graphic3d_CStructure *)S1Iterator.Key ()->CStructure (),
3372 int (S1Iterator.Key ()->DisplayPriority ())
3376 // Le else est impossible (OUI !)
3377 // Si le mode etait non degenere avant alors la
3378 // structure calculee associee a S1Iterator.Key ()
3379 // existe vraiment et donc Index != 0
3383 // S1Iterator.Next () se positionne sur la
3384 // prochaine structure
3390 void Visual3d_View::SetDegenerateModeOff () {
3393 cout << "Visual3d_View" << MyCView.ViewId
3394 << "::SetDegenerateModeOff ();\n";
3398 // Si le mode degenere est deja inactif, on ne recalcule rien
3399 if (! DegenerateModeIsOn ()) return;
3401 DegenerateModeIsActive = Standard_False;
3404 MyCView.IsDegenerates = 0;
3407 * Changement d'activite du mode degenere
3408 * Erase des structures qui ont ete affichees
3409 * quand le mode etait on.
3410 * Calcul des structures.
3412 Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure);
3413 Visual3d_TypeOfAnswer Answer;
3414 Standard_Integer StructId;
3416 Standard_Integer i = MyDisplayedStructure.Extent ();
3418 while (S1Iterator.More ()) {
3420 Answer = AcceptDisplay (S1Iterator.Key ());
3421 // Si la structure etait a calculer, on l'efface
3422 // et on affiche la structure calculee
3423 // (C'est le role du passage en mode non degenere)
3425 if (Answer == Visual3d_TOA_COMPUTE) {
3426 Standard_Integer Index = IsComputed (S1Iterator.Key ());
3429 MyCOMPUTEDSequence.Value (Index)->Identification ();
3431 cout << "La structure " << S1Iterator.Key ()->Identification ()
3432 << " calculee, dans la view "
3433 << Identification () << ", par la structure "
3434 << StructId << " passe en mode normal.\n";
3435 cout << "On efface " << S1Iterator.Key ()->Identification ()
3436 << " puis on affiche " << StructId << "\n";
3439 MyGraphicDriver->EraseStructure
3441 *(Graphic3d_CStructure *)S1Iterator.Key ()->CStructure ());
3442 MyGraphicDriver->DisplayStructure (
3444 *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure (),
3445 int (S1Iterator.Key ()->DisplayPriority ())
3448 Display (S1Iterator.Key (), Aspect_TOU_WAIT);
3450 if ((S1Iterator.Key ())->IsHighlighted()) {
3451 if (! (MyCOMPUTEDSequence.Value (Index))->IsHighlighted()) {
3452 (MyCOMPUTEDSequence.Value (Index))->SetHighlightColor
3453 ((S1Iterator.Key ())->HighlightColor ());
3454 (MyCOMPUTEDSequence.Value (Index))->GraphicHighlight (Aspect_TOHM_COLOR);
3459 // Le else est impossible (NON !)
3460 // Le mode degenere a ete active avant l'affichage
3461 // de la structure. La structure a donc ete ensuite
3462 // affichee dans le mode degenere et donc sans que la
3463 // structure calculee existe.
3466 // Compute + Validation
3467 Handle(Graphic3d_Structure) AStructure = (S1Iterator.Key ());
3469 Handle(Graphic3d_Structure) TheStructure = AStructure->Compute (this);
3471 Handle(Graphic3d_Structure) TheStructure;
3472 TColStd_Array2OfReal ATrsf (0, 3, 0, 3);
3473 AStructure->Transform (ATrsf);
3475 TColStd_Array2OfReal Ident (0, 3, 0, 3);
3476 Standard_Integer ii, jj;
3477 for (ii=0; ii<=3; ii++)
3478 for (jj=0; jj<=3; jj++)
3479 Ident (ii, jj) = (ii == jj ? 1.0 : 0.0);
3480 TheStructure = MyCOMPUTEDSequence.Value (Index);
3481 TheStructure->SetTransform (Ident, Graphic3d_TOC_REPLACE);
3482 if (AStructure->IsTransformed ()) {
3483 AStructure->Compute (this, ATrsf, TheStructure);
3486 AStructure->Compute (this, TheStructure);
3490 if (AStructure->IsTransformed ()) {
3491 TheStructure = AStructure->Compute (this, ATrsf);
3494 TheStructure = AStructure->Compute (this);
3498 TheStructure->SetHLRValidation (Standard_True);
3500 // Recuperation type de visualisation de la vue
3501 Visual3d_TypeOfVisualization ViewType = MyContext.Visualization ();
3503 // De quel type sera la computed ?
3504 Standard_Boolean ComputeWireframe = ((ViewType == Visual3d_TOV_WIREFRAME) &&
3505 ((S1Iterator.Key ())->ComputeVisual () != Graphic3d_TOS_SHADING));
3507 Standard_Boolean ComputeShading = ((ViewType == Visual3d_TOV_SHADING) &&
3508 ((S1Iterator.Key ())->ComputeVisual () != Graphic3d_TOS_WIREFRAME));
3510 if (ComputeWireframe)
3511 TheStructure->SetVisual (Graphic3d_TOS_WIREFRAME);
3513 TheStructure->SetVisual (Graphic3d_TOS_SHADING);
3515 if ((S1Iterator.Key ())->IsHighlighted()) {
3516 TheStructure->SetHighlightColor
3517 ((S1Iterator.Key ())->HighlightColor ());
3518 TheStructure->GraphicHighlight (Aspect_TOHM_COLOR);
3522 Standard_Integer Result = 0;
3523 Standard_Integer Length = MyTOCOMPUTESequence.Length ();
3524 // Recherche de la structure <S1Iterator.Key ()>
3525 // dans la sequence des structures a calculer
3526 StructId = (S1Iterator.Key ())->Identification ();
3527 for (i=1; i<=Length && Result==0; i++)
3528 if ((MyTOCOMPUTESequence.Value (i))->Identification () ==
3529 StructId) Result = i;
3531 MyCOMPUTEDSequence.ChangeValue (Result) = TheStructure;
3533 // On ajoute la hlhsr et la nouvelle compute associee
3535 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) {
3536 cout << "In Visual3d_View::SetDegenerateModeOff, ";
3537 cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length ()
3538 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
3542 MyTOCOMPUTESequence.Append (S1Iterator.Key ());
3543 MyCOMPUTEDSequence.Append (TheStructure);
3545 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
3546 cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
3547 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
3552 // On efface la degeneree et on affiche la calculee
3553 MyGraphicDriver->EraseStructure
3555 *(Graphic3d_CStructure *)(S1Iterator.Key ()->CStructure ()));
3556 MyGraphicDriver->DisplayStructure (
3558 *(Graphic3d_CStructure *)TheStructure->CStructure (),
3559 int (S1Iterator.Key ()->DisplayPriority ())
3564 // S1Iterator.Next () se positionne sur la
3565 // prochaine structure
3569 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
3573 Standard_Boolean Visual3d_View::DegenerateModeIsOn () const {
3575 return DegenerateModeIsActive;
3579 Handle(Aspect_GraphicDriver) Visual3d_View::GraphicDriver () const {
3581 return MyGraphicDriver;
3585 void Visual3d_View::Plot (const Handle(Graphic3d_Plotter)& APlotter) const {
3587 Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure);
3589 while (S1Iterator.More ()) {
3591 if (DegenerateModeIsOn ())
3592 // Le mode etant degenere on plotte la structure
3593 // affichee sans s'occuper si elle est calculee
3594 (S1Iterator.Key ())->Plot (APlotter);
3596 Standard_Integer Index = IsComputed (S1Iterator.Key ());
3597 // Le mode n'etant pas degenere on plotte la structure
3598 // affichee si elle n'est pas calculee sinon
3599 // on plotte la structure calculee associee
3601 (S1Iterator.Key ())->Plot (APlotter);
3603 (MyCOMPUTEDSequence.Value (Index))->Plot (APlotter);
3606 // S1Iterator.Next () se positionne sur la
3607 // prochaine structure
3613 Standard_Integer Visual3d_View::HaveTheSameOwner (const Handle(Graphic3d_Structure)& AStructure) const {
3615 Standard_Integer Result = 0;
3616 Standard_Integer Length = MyTOCOMPUTESequence.Length ();
3618 // Recherche dans la sequence des structures deja calculees
3619 // 1/ D'une structure ayant le meme Owner que <AStructure>
3620 // 2/ Qui ne soit pas <AStructure>
3621 // 3/ Dont la COMPUTED soit valide
3622 for (Standard_Integer i=1; i<=Length && Result==0; i++)
3623 if ((MyTOCOMPUTESequence.Value (i)->Owner () == AStructure->Owner ())
3624 && (MyTOCOMPUTESequence.Value (i)->Identification () !=
3625 AStructure->Identification ())
3626 && (MyCOMPUTEDSequence.Value (i)->HLRValidation ())) Result = i;
3632 Standard_Address Visual3d_View::CView () const {
3634 return Standard_Address (&MyCView);
3639 // Triedron methods : the Triedron is a non-zoomable object.
3641 void Visual3d_View::ZBufferTriedronSetup(const Quantity_NameOfColor XColor,
3642 const Quantity_NameOfColor YColor,
3643 const Quantity_NameOfColor ZColor,
3644 const Standard_Real SizeRatio,
3645 const Standard_Real AxisDiametr,
3646 const Standard_Integer NbFacettes) {
3647 MyGraphicDriver->ZBufferTriedronSetup(XColor, YColor, ZColor,
3648 SizeRatio, AxisDiametr, NbFacettes);
3653 void Visual3d_View::TriedronDisplay (const Aspect_TypeOfTriedronPosition APosition,
3654 const Quantity_NameOfColor AColor, const Standard_Real AScale, const Standard_Boolean AsWireframe ) {
3656 MyGraphicDriver->TriedronDisplay (MyCView,APosition, AColor, AScale, AsWireframe);
3660 void Visual3d_View::TriedronErase () {
3662 MyGraphicDriver->TriedronErase (MyCView);
3667 void Visual3d_View::TriedronEcho (const Aspect_TypeOfTriedronEcho AType ) {
3669 MyGraphicDriver->TriedronEcho (MyCView,AType);
3673 Standard_Boolean checkFloat(const Standard_Real value)
3675 return value > -FLT_MAX && value < FLT_MAX;
3678 void SetMinMaxValuesCallback(void* Visual3dView)
3680 Standard_Real xmin, ymin, zmin, xmax, ymax, zmax;
3682 Handle(Visual3d_View) view = (Handle(Visual3d_View)&) Visual3dView;
3683 view->MinMaxValues(xmin, ymin, zmin, xmax, ymax, zmax);
3685 if (checkFloat(xmin) && checkFloat(ymin) && checkFloat(zmin) &&
3686 checkFloat(xmax) && checkFloat(ymax) && checkFloat(zmax))
3688 Handle(Graphic3d_GraphicDriver) driver = Handle(Graphic3d_GraphicDriver)::DownCast(view->GraphicDriver());
3689 driver->GraduatedTrihedronMinMaxValues((Standard_ShortReal)xmin, (Standard_ShortReal)ymin, (Standard_ShortReal)zmin,
3690 (Standard_ShortReal)xmax, (Standard_ShortReal)ymax, (Standard_ShortReal)zmax);
3694 void Visual3d_View::GetGraduatedTrihedron(/* Names of axes */
3695 Standard_CString& xname,
3696 Standard_CString& yname,
3697 Standard_CString& zname,
3699 Standard_Boolean& xdrawname,
3700 Standard_Boolean& ydrawname,
3701 Standard_Boolean& zdrawname,
3703 Standard_Boolean& xdrawvalues,
3704 Standard_Boolean& ydrawvalues,
3705 Standard_Boolean& zdrawvalues,
3707 Standard_Boolean& drawgrid,
3709 Standard_Boolean& drawaxes,
3710 /* Number of splits along axes */
3711 Standard_Integer& nbx,
3712 Standard_Integer& nby,
3713 Standard_Integer& nbz,
3714 /* Offset for drawing values */
3715 Standard_Integer& xoffset,
3716 Standard_Integer& yoffset,
3717 Standard_Integer& zoffset,
3718 /* Offset for drawing names of axes */
3719 Standard_Integer& xaxisoffset,
3720 Standard_Integer& yaxisoffset,
3721 Standard_Integer& zaxisoffset,
3722 /* Draw tickmarks */
3723 Standard_Boolean& xdrawtickmarks,
3724 Standard_Boolean& ydrawtickmarks,
3725 Standard_Boolean& zdrawtickmarks,
3726 /* Length of tickmarks */
3727 Standard_Integer& xtickmarklength,
3728 Standard_Integer& ytickmarklength,
3729 Standard_Integer& ztickmarklength,
3731 Quantity_Color& gridcolor,
3733 Quantity_Color& xnamecolor,
3735 Quantity_Color& ynamecolor,
3737 Quantity_Color& znamecolor,
3738 /* X color of axis and values */
3739 Quantity_Color& xcolor,
3740 /* Y color of axis and values */
3741 Quantity_Color& ycolor,
3742 /* Z color of axis and values */
3743 Quantity_Color& zcolor,
3744 /* Name of font for names of axes */
3745 Standard_CString& fontOfNames,
3746 /* Style of names of axes */
3747 OSD_FontAspect& styleOfNames,
3748 /* Size of names of axes */
3749 Standard_Integer& sizeOfNames,
3750 /* Name of font for values */
3751 Standard_CString& fontOfValues,
3752 /* Style of values */
3753 OSD_FontAspect& styleOfValues,
3754 /* Size of values */
3755 Standard_Integer& sizeOfValues) const
3757 MyGraphicDriver->GetGraduatedTrihedron(MyCView,
3774 /* Number of splits along axes */
3778 /* Offset for drawing values */
3782 /* Offset for drawing names of axes */
3786 /* Draw tickmarks */
3790 /* Length of tickmarks */
3802 /* X color of axis and values */
3804 /* Y color of axis and values */
3806 /* Z color of axis and values */
3808 /* Name of font for names of axes */
3810 /* Style of names of axes */
3812 /* Size of names of axes */
3814 /* Name of font for values */
3816 /* Style of values */
3818 /* Size of values */
3822 void Visual3d_View::GraduatedTrihedronDisplay(/* Names of axes */
3823 const Standard_CString xname,
3824 const Standard_CString yname,
3825 const Standard_CString zname,
3827 const Standard_Boolean xdrawname,
3828 const Standard_Boolean ydrawname,
3829 const Standard_Boolean zdrawname,
3831 const Standard_Boolean xdrawvalues,
3832 const Standard_Boolean ydrawvalues,
3833 const Standard_Boolean zdrawvalues,
3835 const Standard_Boolean drawgrid,
3837 const Standard_Boolean drawaxes,
3838 /* Number of splits along axes */
3839 const Standard_Integer nbx,
3840 const Standard_Integer nby,
3841 const Standard_Integer nbz,
3842 /* Offset for drawing values */
3843 const Standard_Integer xoffset,
3844 const Standard_Integer yoffset,
3845 const Standard_Integer zoffset,
3846 /* Offset for drawing names of axes */
3847 const Standard_Integer xaxisoffset,
3848 const Standard_Integer yaxisoffset,
3849 const Standard_Integer zaxisoffset,
3850 /* Draw tickmarks */
3851 const Standard_Boolean xdrawtickmarks,
3852 const Standard_Boolean ydrawtickmarks,
3853 const Standard_Boolean zdrawtickmarks,
3854 /* Length of tickmarks */
3855 const Standard_Integer xtickmarklength,
3856 const Standard_Integer ytickmarklength,
3857 const Standard_Integer ztickmarklength,
3859 const Quantity_Color& gridcolor,
3861 const Quantity_Color& xnamecolor,
3863 const Quantity_Color& ynamecolor,
3865 const Quantity_Color& znamecolor,
3866 /* X color of axis and values */
3867 const Quantity_Color& xcolor,
3868 /* Y color of axis and values */
3869 const Quantity_Color& ycolor,
3870 /* Z color of axis and values */
3871 const Quantity_Color& zcolor,
3872 /* Name of font for names of axes */
3873 const Standard_CString fontOfNames,
3874 /* Style of names of axes */
3875 const OSD_FontAspect styleOfNames,
3876 /* Size of names of axes */
3877 const Standard_Integer sizeOfNames,
3878 /* Name of font for values */
3879 const Standard_CString fontOfValues,
3880 /* Style of values */
3881 const OSD_FontAspect styleOfValues,
3882 /* Size of values */
3883 const Standard_Integer sizeOfValues)
3885 CALL_DEF_GRADUATEDTRIHEDRON cubic;
3886 cubic.ptrVisual3dView = this;
3887 cubic.cbCubicAxes = SetMinMaxValuesCallback;
3888 MyGraphicDriver->GraduatedTrihedronDisplay(MyCView,
3906 /* Number of splits along axes */
3910 /* Offset for drawing values */
3914 /* Offset for drawing names of axes */
3918 /* Draw tickmarks */
3922 /* Length of tickmarks */
3934 /* X color of axis and values */
3936 /* Y color of axis and values */
3938 /* Z color of axis and values */
3940 /* Name of font for names of axes */
3942 /* Style of names of axes */
3944 /* Size of names of axes */
3946 /* Name of font for values */
3948 /* Style of values */
3950 /* Size of values */
3954 void Visual3d_View::GraduatedTrihedronErase()
3956 MyGraphicDriver->GraduatedTrihedronErase(MyCView);
3959 const Handle(Visual3d_Layer)& Visual3d_View::UnderLayer () const {
3961 return (MyViewManager->UnderLayer ());
3965 const Handle(Visual3d_Layer)& Visual3d_View::OverLayer () const {
3967 return (MyViewManager->OverLayer ());
3971 Standard_Integer Visual3d_View::LightLimit() const {
3973 Standard_Integer maxlight = MyGraphicDriver->InquireLightLimit ();
3974 // printf(" $$$ Visual3d_View::LightLimit() is %d\n",maxlight);
3978 Standard_Integer Visual3d_View::PlaneLimit() const {
3980 Standard_Integer maxplane = MyGraphicDriver->InquirePlaneLimit ();
3981 // printf(" $$$ Visual3d_View::PlaneLimit() is %d\n",maxplane);
3986 Handle(Visual3d_ViewManager) Visual3d_View::ViewManager() const {
3988 return MyPtrViewManager;
3993 void Visual3d_View :: SetComputedMode ( const Standard_Boolean aMode ) {
3995 if ( ( (aMode && ComputedModeIsActive) ||
3996 (!aMode && !ComputedModeIsActive)
3997 ) || DegenerateModeIsOn ()
4000 Graphic3d_MapIteratorOfMapOfStructure S1Iterator ( MyDisplayedStructure );
4001 Visual3d_TypeOfAnswer Answer;
4002 Standard_Integer StructId;
4003 Standard_Integer i = MyDisplayedStructure.Extent ();
4005 if ( !( ComputedModeIsActive = aMode ) ) {
4007 while ( S1Iterator.More () ) {
4009 Answer = AcceptDisplay ( S1Iterator.Key () );
4011 if ( Answer == Visual3d_TOA_COMPUTE ) {
4013 Standard_Integer Index = IsComputed ( S1Iterator.Key () );
4017 StructId = MyCOMPUTEDSequence.Value ( Index ) -> Identification ();
4019 MyGraphicDriver -> EraseStructure (
4021 *( Graphic3d_CStructure* )
4022 MyCOMPUTEDSequence.Value ( Index ) -> CStructure ()
4024 MyGraphicDriver -> DisplayStructure (
4026 *( Graphic3d_CStructure* )
4027 S1Iterator.Key () -> CStructure (),
4028 int ( S1Iterator.Key () -> DisplayPriority () )
4030 } // end if ( Index != 0 ) . . .
4032 } // end if ( Answer . . . )
4040 while ( S1Iterator.More () ) {
4042 Answer = AcceptDisplay ( S1Iterator.Key () );
4044 if ( Answer == Visual3d_TOA_COMPUTE ) {
4046 Standard_Integer Index = IsComputed ( S1Iterator.Key () );
4050 StructId = MyCOMPUTEDSequence.Value ( Index ) -> Identification ();
4052 MyGraphicDriver -> EraseStructure (
4054 *( Graphic3d_CStructure* )
4055 S1Iterator.Key () -> CStructure ()
4057 MyGraphicDriver -> DisplayStructure (
4059 *( Graphic3d_CStructure* )
4060 MyCOMPUTEDSequence.Value ( Index ) -> CStructure (),
4061 int ( S1Iterator.Key () -> DisplayPriority () )
4064 Display ( S1Iterator.Key (), Aspect_TOU_WAIT );
4066 if ( S1Iterator.Key () -> IsHighlighted () ) {
4068 if ( !MyCOMPUTEDSequence.Value ( Index ) -> IsHighlighted () ) {
4070 MyCOMPUTEDSequence.Value ( Index ) -> SetHighlightColor (
4071 S1Iterator.Key () ->
4074 MyCOMPUTEDSequence.Value ( Index ) -> GraphicHighlight (
4083 Handle( Graphic3d_Structure ) AStructure = S1Iterator.Key ();
4085 Handle( Graphic3d_Structure ) TheStructure = AStructure -> Compute ( this );
4087 Handle( Graphic3d_Structure ) TheStructure;
4088 TColStd_Array2OfReal ATrsf ( 0, 3, 0, 3 );
4090 AStructure -> Transform ( ATrsf );
4094 TColStd_Array2OfReal Ident ( 0, 3, 0, 3 );
4095 Standard_Integer ii, jj;
4097 for ( ii = 0; ii <= 3; ++ii )
4099 for ( jj = 0; jj <= 3; ++jj )
4101 Ident ( ii, jj ) = ( ii == jj ? 1.0 : 0.0 );
4103 TheStructure = MyCOMPUTEDSequence.Value ( Index );
4105 TheStructure -> SetTransform ( Ident, Graphic3d_TOC_REPLACE );
4107 if ( AStructure->IsTransformed () )
4109 AStructure -> Compute ( this, ATrsf, TheStructure );
4113 AStructure -> Compute ( this, TheStructure );
4117 if ( AStructure -> IsTransformed () )
4119 TheStructure = AStructure -> Compute ( this, ATrsf );
4123 TheStructure = AStructure -> Compute ( this );
4127 TheStructure -> SetHLRValidation ( Standard_True );
4129 Visual3d_TypeOfVisualization ViewType = MyContext.Visualization ();
4131 Standard_Boolean ComputeWireframe =
4132 ( ( ViewType == Visual3d_TOV_WIREFRAME ) &&
4133 ( S1Iterator.Key () -> ComputeVisual () != Graphic3d_TOS_SHADING )
4136 Standard_Boolean ComputeShading =
4137 ( ( ViewType == Visual3d_TOV_SHADING ) &&
4138 ( S1Iterator.Key () -> ComputeVisual () != Graphic3d_TOS_WIREFRAME )
4141 if ( ComputeWireframe ) TheStructure -> SetVisual ( Graphic3d_TOS_WIREFRAME );
4142 if ( ComputeShading ) TheStructure -> SetVisual ( Graphic3d_TOS_SHADING );
4144 if ( S1Iterator.Key () -> IsHighlighted () ) {
4146 TheStructure -> SetHighlightColor (
4147 S1Iterator.Key () -> HighlightColor ()
4149 TheStructure -> GraphicHighlight ( Aspect_TOHM_COLOR );
4153 Standard_Integer Result = 0;
4154 Standard_Integer Length = MyTOCOMPUTESequence.Length ();
4155 StructId = S1Iterator.Key () -> Identification ();
4157 for ( i = 1; i <= Length && Result == 0; ++i )
4159 if ( MyTOCOMPUTESequence.Value ( i ) -> Identification () == StructId )
4165 MyCOMPUTEDSequence.ChangeValue ( Result ) = TheStructure;
4169 MyTOCOMPUTESequence.Append ( S1Iterator.Key () );
4170 MyCOMPUTEDSequence.Append ( TheStructure );
4174 MyGraphicDriver -> EraseStructure (
4176 *( Graphic3d_CStructure* )
4177 S1Iterator.Key () -> CStructure ()
4179 MyGraphicDriver -> DisplayStructure (
4181 *( Graphic3d_CStructure* )TheStructure -> CStructure (),
4182 int ( S1Iterator.Key () -> DisplayPriority () )
4192 if ( MyViewManager -> UpdateMode () == Aspect_TOU_ASAP ) Update ();
4196 } // end Visual3d_View :: SetComputedMode
4198 Standard_Boolean Visual3d_View :: ComputedMode () const {
4200 return ComputedModeIsActive;
4202 } // end Visual3d_View :: ComputedMode
4204 void Visual3d_View :: SetBackFacingModel (
4205 const Visual3d_TypeOfBackfacingModel aModel
4210 case Visual3d_TOBM_AUTOMATIC:
4211 MyCView.Backfacing = 0;
4214 case Visual3d_TOBM_FORCE:
4215 MyCView.Backfacing = 1;
4218 case Visual3d_TOBM_DISABLE:
4219 MyCView.Backfacing = -1;
4224 MyGraphicDriver -> SetBackFacingModel ( MyCView );
4226 } // end Visual3d_View :: SetBackFacingModel
4228 Visual3d_TypeOfBackfacingModel Visual3d_View :: BackFacingModel () const {
4230 switch ( MyCView.Backfacing ) {
4233 return Visual3d_TOBM_AUTOMATIC;
4236 return Visual3d_TOBM_FORCE;
4240 return Visual3d_TOBM_DISABLE;
4242 } // end Visual3d_View :: BackFacingModel
4245 void Visual3d_View::EnableDepthTest( const Standard_Boolean enable ) const
4248 MyGraphicDriver->SetDepthTestEnabled( MyCView, enable );
4252 Standard_Boolean Visual3d_View::IsDepthTestEnabled() const
4255 return MyGraphicDriver->IsDepthTestEnabled( MyCView );
4257 return Standard_True;
4261 void Visual3d_View::ReadDepths(const Standard_Integer x,
4262 const Standard_Integer y,
4263 const Standard_Integer width,
4264 const Standard_Integer height,
4265 const Standard_Address buffer) const
4267 MyGraphicDriver->ReadDepths( MyCView, x, y, width, height, buffer );
4270 Graphic3d_PtrFrameBuffer Visual3d_View::FBOCreate(const Standard_Integer theWidth,
4271 const Standard_Integer theHeight)
4273 return MyGraphicDriver->FBOCreate( MyCView, theWidth, theHeight );
4276 void Visual3d_View::FBORelease(Graphic3d_PtrFrameBuffer& theFBOPtr)
4278 MyGraphicDriver->FBORelease( MyCView, theFBOPtr );
4281 void Visual3d_View::FBOGetDimensions(const Graphic3d_PtrFrameBuffer theFBOPtr,
4282 Standard_Integer& theWidth, Standard_Integer& theHeight,
4283 Standard_Integer& theWidthMax, Standard_Integer& theHeightMax)
4285 MyGraphicDriver->FBOGetDimensions( MyCView, theFBOPtr,
4286 theWidth, theHeight,
4287 theWidthMax, theHeightMax );
4290 void Visual3d_View::FBOChangeViewport(Graphic3d_PtrFrameBuffer& theFBOPtr,
4291 const Standard_Integer theWidth, const Standard_Integer theHeight)
4293 MyGraphicDriver->FBOChangeViewport( MyCView, theFBOPtr,
4294 theWidth, theHeight );
4297 Standard_Boolean Visual3d_View::BufferDump (Image_CRawBufferData& theBuffer)
4299 return MyGraphicDriver->BufferDump( MyCView, theBuffer);
4302 void Visual3d_View::EnableGLLight( const Standard_Boolean enable ) const
4305 MyGraphicDriver->SetGLLightEnabled( MyCView, enable );
4310 Standard_Boolean Visual3d_View::IsGLLightEnabled() const
4313 return MyGraphicDriver->IsGLLightEnabled( MyCView );
4315 return Standard_True;
4319 void Visual3d_View::Export( const Standard_CString FileName,
4320 const Graphic3d_ExportFormat Format,
4321 const Graphic3d_SortType aSortType,
4322 const Standard_Real Precision,
4323 const Standard_Address ProgressBarFunc,
4324 const Standard_Address ProgressObject ) const
4326 Handle( Visual3d_Layer ) AnUnderLayer = MyViewManager->UnderLayer(),
4327 AnOverLayer = MyViewManager->OverLayer();
4329 Aspect_CLayer2d OverCLayer;
4330 Aspect_CLayer2d UnderCLayer;
4331 OverCLayer.ptrLayer = UnderCLayer.ptrLayer = NULL;
4333 if( !AnOverLayer.IsNull() )
4334 OverCLayer = AnOverLayer->CLayer();
4335 if( !AnUnderLayer.IsNull() )
4336 UnderCLayer = AnUnderLayer->CLayer();
4338 Standard_Integer W, H;
4339 Window()->Size( W, H );
4341 MyGraphicDriver->Export( FileName, Format, aSortType, W, H, MyCView, UnderCLayer, OverCLayer,
4342 Precision, ProgressBarFunc, ProgressObject );