0023715: Generated cmake files should link against Cocoa on Mac OS X
[occt.git] / src / OpenGl / OpenGl_Trihedron.cxx
1 // Created on: 2011-09-20
2 // Created by: Sergey ZERCHANINOV
3 // Copyright (c) 2011-2012 OPEN CASCADE SAS
4 //
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
9 //
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 //
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
19
20
21 #include <OpenGl_GlCore11.hxx>
22
23 #include <stddef.h>
24 #include <stdio.h>
25 #include <stdlib.h>
26
27 #include <InterfaceGraphic_Graphic3d.hxx>  /* pour CALL_DEF_STRUCTURE */
28 #include <InterfaceGraphic_Aspect.hxx>  /* pour CALL_DEF_VIEW  */
29 #include <InterfaceGraphic_Visual3d.hxx>
30
31 #include <OpenGl_transform_persistence.hxx>
32
33 #include <OpenGl_Workspace.hxx>
34 #include <OpenGl_View.hxx>
35 #include <OpenGl_Trihedron.hxx>
36
37 IMPLEMENT_STANDARD_HANDLE(OpenGl_Trihedron,MMgt_TShared)
38 IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Trihedron,MMgt_TShared)
39
40 static const CALL_DEF_CONTEXTLINE myDefaultContextLine =
41 {
42   1, //IsDef
43   1, //IsSet
44   { 1.F, 1.F, 1.F }, //Color
45   Aspect_TOL_SOLID, //LineType
46   1.F //Width
47 };
48
49 static const CALL_DEF_CONTEXTTEXT myDefaultContextText =
50 {
51   1, //IsDef
52   1, //IsSet
53   "Courier", //Font
54   0.3F, //Space
55   1.0F, //Expan
56   { 1.F, 1.F, 1.F }, //Color
57   Aspect_TOST_NORMAL, //Style
58   Aspect_TODT_NORMAL, //DisplayType
59   { 1.F, 1.F, 1.F }, //ColorSubTitle
60   0, //TextZoomable
61   0.F, //TextAngle
62   Font_FA_Regular //TextFontAspect
63 };
64
65 /*----------------------------------------------------------------------*/
66 /*
67 * Variables statiques
68 */
69
70 /* Default parameters for ZBUFFER triheron */
71 static TEL_COLOUR theXColor = {{ 1.F, 0.F, 0.F, 0.6F }};
72 static TEL_COLOUR theYColor = {{ 0.F, 1.F, 0.F, 0.6F }};
73 static TEL_COLOUR theZColor = {{ 0.F, 0.F, 1.F, 0.6F }};
74 static float theRatio = 0.8f;
75 static float theDiameter = 0.05f;
76 static int   theNbFacettes = 12;
77
78 /*----------------------------------------------------------------------*/
79
80 /*
81 * affichage d'un triedre non zoomable a partir des index dans les tables
82 * des structures non zoomables.
83 *
84 * Triedre = Objet non Zoomable :
85 * on recalcule ses dimensions et son origine en fonction de la taille
86 * de la fenetre; on positionne selon le choix de l'init;
87 * et on inhibe seulement les translations.
88 *
89 */
90
91 //call_triedron_redraw
92 void OpenGl_Trihedron::Redraw (const Handle(OpenGl_Workspace) &AWorkspace) const
93 {
94   const Standard_Real U = AWorkspace->ActiveView()->Height();
95   const Standard_Real V = AWorkspace->ActiveView()->Width();
96
97   /* la taille des axes est 1 proportion (fixee a l'init du triedre) */
98   /* de la dimension la plus petite de la window.                    */
99   const GLdouble L = ( U < V ? U : V ) * myScale;
100
101   /*
102   * On inhibe les translations; on conserve les autres transformations.
103   */
104
105   /* on lit les matrices de transformation et de projection de la vue */
106   /* pour annuler les translations (dernieres colonnes des matrices). */
107   GLdouble modelMatrix[4][4];
108   glGetDoublev( GL_MODELVIEW_MATRIX,  (GLdouble *) modelMatrix );
109   GLdouble projMatrix[4][4];
110   glGetDoublev( GL_PROJECTION_MATRIX, (GLdouble *) projMatrix );
111
112   /* on annule la translation qui peut etre affectee a la vue */
113   modelMatrix[3][0] = 0.;
114   modelMatrix[3][1] = 0.;
115   modelMatrix[3][2] = 0.;
116   projMatrix[3][0] = 0.;
117   projMatrix[3][1] = 0.;
118   projMatrix[3][2] = 0.;
119
120   /* sauvegarde du contexte des matrices avant chargement */
121   glMatrixMode (GL_MODELVIEW);
122   glPushMatrix ();
123   glLoadMatrixd( (GLdouble *) modelMatrix );
124   glMatrixMode ( GL_PROJECTION );
125   glPushMatrix ();
126   glLoadMatrixd( (GLdouble *) projMatrix );
127
128   /*
129   * Positionnement de l'origine du triedre selon le choix de l'init
130   */
131
132   /* on fait uniquement une translation de l'origine du Triedre */
133
134   switch (myPos)
135   {
136     case Aspect_TOTP_LEFT_LOWER :
137       glTranslated( -0.5*U + L , -0.5*V + L , 0. );
138       break;
139
140     case Aspect_TOTP_LEFT_UPPER :
141       glTranslated( -0.5*U + L , +0.5*V - L -L/3., 0. );
142       break;
143
144     case Aspect_TOTP_RIGHT_LOWER :
145       glTranslated( 0.5*U - L -L/3. , -0.5*V + L , 0. );
146       break;
147
148     case Aspect_TOTP_RIGHT_UPPER :
149       glTranslated( 0.5*U - L -L/3. , +0.5*V - L -L/3. , 0. );
150       break;
151
152     //case Aspect_TOTP_CENTER :
153     default :
154       break;
155   }
156
157   /*
158   * Creation du triedre
159   */
160   const OpenGl_AspectLine *AspectLine = AWorkspace->AspectLine( Standard_True );
161
162   /* Fotis Sioutis 2007-11-14 15:06
163   I have also seen in previous posts that the view trihedron in V3d_WIREFRAME mode
164   changes colors depending on the state of the view. This behaviour can be easily
165   corrected by altering call_triedron_redraw function in OpenGl_triedron.c of TKOpengl.
166   The only change needed is to erase glDisable(GL_LIGHTING) that is called before the
167   Axis name drawing and move this function call just before the initial axis drawing.
168   Below is the code portion with the modification.I don't know if this is considered to
169   be a bug but anyway i believe it might help some of you out there.*/
170   glDisable(GL_LIGHTING);
171
172   /* Position de l'origine */
173   const GLdouble TriedronOrigin[3] = { 0.0, 0.0, 0.0 };
174
175   /* Position des Axes */
176   GLdouble TriedronAxeX[3] = { 1.0, 0.0, 0.0 };
177   GLdouble TriedronAxeY[3] = { 0.0, 1.0, 0.0 };
178   GLdouble TriedronAxeZ[3] = { 0.0, 0.0, 1.0 };
179   TriedronAxeX[0] = L ;
180   TriedronAxeY[1] = L ;
181   TriedronAxeZ[2] = L ;
182
183   /* dessin des axes */
184   glBegin(GL_LINES);
185   glVertex3dv( TriedronOrigin );
186   glVertex3dv( TriedronAxeX );
187
188   glVertex3dv( TriedronOrigin );
189   glVertex3dv( TriedronAxeY );
190
191   glVertex3dv( TriedronOrigin );
192   glVertex3dv( TriedronAxeZ );
193   glEnd();
194
195   /* fleches au bout des axes (= cones de la couleur demandee) */
196   const GLdouble l = 0.75*L; /* distance a l'origine */
197   const GLdouble rayon = L/30. ; /* rayon de la base du cone */
198   const int NbFacettes = 12; /* le cone sera compose de 12 facettes triangulaires */
199   const double Angle = 2. * M_PI/ NbFacettes;
200
201   int      ii;
202   GLdouble TriedronCoord[3] = { 1.0, 0.0, 0.0 };
203
204   /* solution FILAIRE des cones au bout des axes : une seule ligne */
205   glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
206   /* (la couleur est deja initialisee dans AspectLine) */
207   /* FIN de la solution FILAIRE CHOISIE pour les cones des axes */
208
209   /* fleche en X */
210   glBegin(GL_TRIANGLE_FAN);
211   glVertex3dv( TriedronAxeX );
212   TriedronCoord[0] = l;
213   ii = NbFacettes;
214   while (ii >= 0 ) {
215     TriedronCoord[1] = rayon * sin(ii * Angle);
216     TriedronCoord[2] = rayon * cos(ii * Angle);
217     glVertex3dv( TriedronCoord );
218     ii--;
219   }
220   glEnd();
221
222   /* fleche en Y */
223   glBegin(GL_TRIANGLE_FAN);
224   glVertex3dv( TriedronAxeY );
225   TriedronCoord[1] = l;
226   ii = NbFacettes;
227   while (ii >= 0 ) {
228     TriedronCoord[0] = rayon * cos(ii * Angle);
229     TriedronCoord[2] = rayon * sin(ii * Angle);
230     glVertex3dv( TriedronCoord );
231     ii--;
232   }
233   glEnd();
234
235   /* fleche en Z */
236   glBegin(GL_TRIANGLE_FAN);
237   glVertex3dv( TriedronAxeZ );
238   TriedronCoord[2] = l;
239   ii = NbFacettes;
240   while (ii >= 0 ) {
241     TriedronCoord[0] = rayon * sin(ii * Angle);
242     TriedronCoord[1] = rayon * cos(ii * Angle);
243     glVertex3dv( TriedronCoord );
244     ii--;
245   }
246   glEnd();
247
248   /* dessin de l'origine */
249   TriedronCoord[2] = 0.0 ;
250   ii = 24 ;
251   const double Angle1 = 2. * M_PI/ ii;
252   glBegin(GL_LINE_LOOP);
253   while (ii >= 0 ) {
254     TriedronCoord[0] = rayon * sin(ii * Angle1);
255     TriedronCoord[1] = rayon * cos(ii * Angle1);
256     glVertex3dv( TriedronCoord );
257     ii--;
258   }
259   glEnd();
260
261   /*
262   * Noms des axes et de l'origine
263   */
264   const OpenGl_AspectText *AspectText = AWorkspace->AspectText( Standard_True );
265   glColor3fv (AspectText->Color().rgb);
266
267   AWorkspace->RenderText (L"X", 0, float(L + rayon),    0.0f,                   float(-rayon));
268   AWorkspace->RenderText (L"Y", 0, float(rayon),        float(L + 3.0 * rayon), float(2.0 * rayon));
269   AWorkspace->RenderText (L"Z", 0, float(-2.0 * rayon), float(0.5 * rayon),     float(L + 3.0 * rayon));
270
271   /*
272   * restauration du contexte des matrices
273   */
274   glMatrixMode (GL_PROJECTION);
275   glPopMatrix ();
276   glMatrixMode (GL_MODELVIEW);
277   glPopMatrix ();
278 }
279
280
281 /*******************************************************
282 *  Draws ZBUFFER trihedron mode
283 *******************************************************/
284 //call_zbuffer_triedron_redraw
285 void OpenGl_Trihedron::RedrawZBuffer (const Handle(OpenGl_Workspace) &AWorkspace) const
286 {
287   const Standard_Real U = AWorkspace->ActiveView()->Height();
288   const Standard_Real V = AWorkspace->ActiveView()->Width();
289
290   GLdouble modelMatrix[4][4];
291   glGetDoublev( GL_MODELVIEW_MATRIX,  (GLdouble *) modelMatrix );
292   GLdouble projMatrix[4][4];
293   glGetDoublev( GL_PROJECTION_MATRIX, (GLdouble *) projMatrix );
294
295   /* Check position in the ViewPort */
296   /* PCD 29/09/2008 */
297   /* Simple code modification recommended by Fotis Sioutis and Peter Dolbey  */
298   /* to remove the irritating default behaviour of triedrons using V3d_ZBUFFER   */
299   /* which causes the glyph to jump around the screen when the origin moves offscreen. */
300   GLboolean isWithinView = GL_FALSE;
301
302   /* la taille des axes est 1 proportion (fixee a l'init du triedre) */
303   /* de la dimension la plus petite de la window.                    */
304   GLdouble L = ( U < V ? U : V ) * myScale;
305
306   if (!isWithinView)
307   {
308     /* Annulate translation matrix */
309     modelMatrix[3][0] = 0.;
310     modelMatrix[3][1] = 0.;
311     modelMatrix[3][2] = 0.;
312     projMatrix[3][0] = 0.;
313     projMatrix[3][1] = 0.;
314     projMatrix[3][2] = 0.;
315
316     /* save matrix */
317     glMatrixMode (GL_MODELVIEW);
318     glPushMatrix ();
319     //glLoadIdentity ();
320     glLoadMatrixd( (GLdouble *) modelMatrix);
321     glMatrixMode ( GL_PROJECTION );
322     glPushMatrix ();
323     //glLoadIdentity();
324     glLoadMatrixd( (GLdouble *) projMatrix);
325
326     /*
327     * Define position in the view
328     */
329     switch (myPos)
330     {
331       case Aspect_TOTP_LEFT_LOWER :
332         glTranslated( -0.5*U + L , -0.5*V + L , 0. );
333         break;
334
335       case Aspect_TOTP_LEFT_UPPER :
336         glTranslated( -0.5*U + L , +0.5*V - L -L/3. , 0. );
337         break;
338
339       case Aspect_TOTP_RIGHT_LOWER :
340         glTranslated( 0.5*U - L -L/3. , -0.5*V + L , 0. );
341         break;
342
343       case Aspect_TOTP_RIGHT_UPPER :
344         glTranslated( 0.5*U - L -L/3. , +0.5*V - L -L/3. , 0. );
345         break;
346
347       //case Aspect_TOTP_CENTER :
348       default :
349         break;
350     }
351     L *= myRatio;
352   }
353
354   const OpenGl_AspectLine *AspectLine = AWorkspace->AspectLine( Standard_True );
355   const TEL_COLOUR &aLineColor = AspectLine->Color();
356
357   /*
358   * Creation the trihedron
359   */
360 #define CYLINDER_LENGTH   0.75f
361
362   const GLuint startList = glGenLists(4);
363   GLUquadricObj* aQuadric = gluNewQuadric();
364
365   const GLboolean aIsDepthEnabled = glIsEnabled(GL_DEPTH_TEST);
366
367   GLboolean aIsDepthMaskEnabled;
368   /*PCD 02/07/07   */
369   /* GL_DEPTH_WRITEMASK is not a valid argument to glIsEnabled, the  */
370   /* original code is shown to be broken when run under an OpenGL debugger  */
371   /* like GLIntercept. This is the correct way to retrieve the mask value.  */
372   glGetBooleanv(GL_DEPTH_WRITEMASK, &aIsDepthMaskEnabled);
373
374   const GLdouble aCylinderLength = L * CYLINDER_LENGTH;
375   const GLdouble aCylinderDiametr = L * myDiameter;
376   const GLdouble aConeDiametr = aCylinderDiametr * 2.;
377   const GLdouble aConeLength = L * (1 - CYLINDER_LENGTH);
378   /* Correct for owerlapping */
379   /*    aCylinderLength += aConeLength - 1.2*aCylinderDiametr*aConeLength/aConeDiametr;*/
380
381   /* Create cylinder for axis */
382   gluQuadricDrawStyle(aQuadric, GLU_FILL); /* smooth shaded */
383   gluQuadricNormals(aQuadric, GLU_FLAT);
384   /* Axis */
385   glNewList(startList, GL_COMPILE);
386   gluCylinder(aQuadric, aCylinderDiametr, aCylinderDiametr, aCylinderLength, myNbFacettes, 1);
387   glEndList();
388   /* Cone */
389   glNewList(startList + 1, GL_COMPILE);
390   gluCylinder(aQuadric, aConeDiametr, 0., aConeLength, myNbFacettes, 1);
391   glEndList();
392   /* Central sphere */
393   glNewList(startList + 2, GL_COMPILE);
394   gluSphere(aQuadric, aCylinderDiametr * 2., myNbFacettes, myNbFacettes);
395   glEndList();
396   /* End disk */
397   gluQuadricOrientation(aQuadric,GLU_INSIDE); /*szv*/
398   glNewList(startList + 3, GL_COMPILE);
399   gluDisk(aQuadric, aCylinderDiametr, aConeDiametr, myNbFacettes, 1/*szv:2*/);
400   glEndList();
401
402   /* Store previous attributes */
403   glPushAttrib(GL_LIGHTING_BIT | GL_POLYGON_BIT);
404   glEnable(GL_LIGHTING);
405
406   glCullFace(GL_BACK);
407   glEnable(GL_CULL_FACE);
408
409   /*Fotis Sioutis | 2008-01-21 10:55
410   In the function call_zbuffer_triedron_redraw of TKOpengl,
411   the z buffered trihedron changes colors in case there
412   is an object in the scene that has an explicit material
413   attached to it.In the trihedron display loop,
414   GL_COLOR_MATERIAL is enabled, but only the GL_DIFFUSE
415   parameter is utilized in glColorMaterial(...).
416   This causes the last ambient,specular and emission values
417   used, to stay at the stack and applied to the trihedron
418   (which causes the color change).
419   A fix is proposed , to change GL_DIFFUSE to
420   GL_AMBIENT_AND_DIFFUSE in glColorMaterial call in
421   line 946.The above of course will leave unchanged
422   the SPECULAR and EMISSION values.
423   Another proposal which would fix 100% the problem
424   is to use glMaterial instead of glColor on the trihedron
425   drawing loop.               */
426   const GLfloat aNULLColor[] = { 0.f, 0.f, 0.f, 0.f }; /* FS 21/01/08 */
427   glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, aNULLColor);
428   glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, aNULLColor);
429   glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, aNULLColor);
430   glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 0.f);
431
432   glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
433   glEnable(GL_COLOR_MATERIAL);
434
435   if (!aIsDepthEnabled)  {
436     glEnable(GL_DEPTH_TEST);
437     glClear(GL_DEPTH_BUFFER_BIT);
438   }
439
440   if (!aIsDepthMaskEnabled)  {
441     /* This is how the depthmask needs to be re-enabled...*/
442     glDepthMask(GL_TRUE);
443     /* ...and not this stuff below */
444   }
445
446   /* Position des Axes */
447   GLdouble TriedronAxeX[3] = { 1.0, 0.0, 0.0 };
448   GLdouble TriedronAxeY[3] = { 0.0, 1.0, 0.0 };
449   GLdouble TriedronAxeZ[3] = { 0.0, 0.0, 1.0 };
450   TriedronAxeX[0] = L;
451   TriedronAxeY[1] = L;
452   TriedronAxeZ[2] = L;
453
454   glMatrixMode(GL_MODELVIEW);
455
456   /* PCD 17/06/07  */
457   GLint df;
458   glGetIntegerv (GL_DEPTH_FUNC, &df);
459
460   int i;
461   for (i = 0; i < 2; i++) /* PCD 11/02/08 Two pass method */
462   {
463     if (i == 0) /*  First pass  */
464     {
465       glDepthFunc(GL_ALWAYS);
466     }
467     else
468     {
469       glDepthFunc(GL_LEQUAL);
470     }
471
472     glPushMatrix();
473     glPushMatrix();
474     glPushMatrix();
475
476     glColor3fv(aLineColor.rgb);
477     glCallList(startList+2);
478
479     // Z axis
480     glColor4fv(myZColor.rgb);
481     glCallList(startList);
482     glTranslated(0, 0, L * CYLINDER_LENGTH);
483     glCallList(startList + 3);
484     glCallList(startList + 1);
485     glPopMatrix();
486
487     // X axis
488     glRotated(90.0, TriedronAxeY[0], TriedronAxeY[1], TriedronAxeY[2]);
489     glColor4fv(myXColor.rgb);
490     glCallList(startList);
491     glTranslated(0, 0, L * CYLINDER_LENGTH);
492     glCallList(startList + 3);
493     glCallList(startList + 1);
494     glPopMatrix();
495
496     // Y axis
497     glRotated(-90.0, TriedronAxeX[0], TriedronAxeX[1], TriedronAxeX[2]);
498     glColor4fv(myYColor.rgb);
499     glCallList(startList);
500     glTranslated(0, 0, L * CYLINDER_LENGTH);
501     glCallList(startList + 3);
502     glCallList(startList + 1);
503     glPopMatrix();
504   }
505
506   if (!aIsDepthEnabled)
507     glDisable(GL_DEPTH_TEST);
508
509   if (!aIsDepthMaskEnabled)
510     glDepthMask(GL_FALSE);
511
512   glDisable(GL_CULL_FACE);
513   glDisable(GL_COLOR_MATERIAL);
514
515   gluDeleteQuadric(aQuadric);
516   glColor3fv (aLineColor.rgb);
517
518   /* Always write the text */
519   glDepthFunc(GL_ALWAYS);
520
521   glPopAttrib();
522
523   /* fleches au bout des axes (= cones de la couleur demandee) */
524   //const GLdouble l = 0.75*L; /* distance a l'origine */
525   const GLdouble rayon = L/30. ; /* rayon de la base du cone */
526   //const double Angle = 2. * M_PI/ myNbFacettes;
527
528   glDeleteLists(startList, 4);
529
530   glDisable(GL_LIGHTING);
531
532   /*
533   * origine names
534   */
535   const OpenGl_AspectText *AspectText = AWorkspace->AspectText( Standard_True );
536   glColor3fv (AspectText->Color().rgb);
537
538   AWorkspace->RenderText (L"X", 0, float(L + rayon),    0.0f,                   float(-rayon));
539   AWorkspace->RenderText (L"Y", 0, float(rayon),        float(L + 3.0 * rayon), float(2.0 * rayon));
540   AWorkspace->RenderText (L"Z", 0, float(-2.0 * rayon), float(0.5 * rayon),     float(L + 3.0 * rayon));
541
542   /*PCD 17/06/07    */
543   glDepthFunc(df);
544
545   if (!isWithinView) { /* restore matrix */
546     glMatrixMode (GL_PROJECTION);
547     glPopMatrix ();
548     glMatrixMode (GL_MODELVIEW);
549     glPopMatrix ();
550   }
551 }
552
553
554 /*----------------------------------------------------------------------*/
555
556 /*----------------------------------------------------------------------*/
557 /*
558 * Fonctions publiques
559 */
560
561
562 /*
563 * initialisation d'un triedre non zoomable dans une vue.
564 * ou modification des valeurs deja initialisees.
565 */
566
567 //call_triedron_init
568 OpenGl_Trihedron::OpenGl_Trihedron (const Aspect_TypeOfTriedronPosition APosition, const Quantity_NameOfColor AColor,
569                                   const Standard_Real AScale, const Standard_Boolean AsWireframe)
570 : myPos(APosition),
571   myScale(AScale),
572   myIsWireframe(AsWireframe)
573 {
574   Standard_Real R,G,B;
575   Quantity_Color Color(AColor);
576   Color.Values(R,G,B,Quantity_TOC_RGB);
577
578   CALL_DEF_CONTEXTLINE aContextLine = myDefaultContextLine;
579   aContextLine.Color.r = (float)R;
580   aContextLine.Color.g = (float)G;
581   aContextLine.Color.b = (float)B;
582   myAspectLine.SetContext(aContextLine);
583
584   CALL_DEF_CONTEXTTEXT aContextText = myDefaultContextText;
585   aContextText.Color.r = (float)R;
586   aContextText.Color.g = (float)G;
587   aContextText.Color.b = (float)B;
588   myAspectText.SetContext(aContextText);
589
590   myXColor = theXColor;
591   myYColor = theYColor;
592   myZColor = theZColor;
593
594   myRatio = theRatio;
595   myDiameter = theDiameter;
596   myNbFacettes = theNbFacettes;
597 }
598
599 /*----------------------------------------------------------------------*/
600
601 /*
602 * destruction du triedre non zoomable d'une vue.
603 */
604
605 //call_triedron_erase
606 OpenGl_Trihedron::~OpenGl_Trihedron ()
607 {
608 }
609
610 /*----------------------------------------------------------------------*/
611
612 /*
613 * affichage d'un triedre non zoomable dans la wks  awsid
614 *
615 * Triedre = Objet non Zoomable;
616 * on cree cette fonction pour pouvoir travailler par les structures
617 * utilisees par les fonctions Tsm* et TEL_VIEW_REP
618 *
619 */
620
621 //call_triedron_redraw_from_wsid
622 void OpenGl_Trihedron::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
623 {
624   const OpenGl_AspectLine* aPrevAspectLine = theWorkspace->SetAspectLine (&myAspectLine);
625   const OpenGl_AspectText* aPrevAspectText = theWorkspace->SetAspectText (&myAspectText);
626
627   /* check if GL_LIGHTING should be disabled
628   no enabling 'cause it will be done (if necessary: kinda Polygon types )
629   during redrawing structures
630   */
631   if (!theWorkspace->UseGLLight())
632   {
633     glDisable (GL_LIGHTING);
634   }
635
636   const Handle(OpenGl_Texture) aPrevTexture = theWorkspace->DisableTexture();
637
638   /* affichage du Triedre Non Zoomable */
639   theWorkspace->ActiveView()->EndTransformPersistence();
640
641   if (myIsWireframe)
642   {
643     Redraw (theWorkspace);
644   }
645   else
646   {
647     RedrawZBuffer (theWorkspace);
648   }
649
650   // restore aspects
651   if (!aPrevTexture.IsNull())
652   {
653     theWorkspace->EnableTexture (aPrevTexture);
654   }
655
656   theWorkspace->SetAspectText (aPrevAspectText);
657   theWorkspace->SetAspectLine (aPrevAspectLine);
658 }
659
660 /*----------------------------------------------------------------------*/
661 //call_ztriedron_setup
662 void OpenGl_Trihedron::Setup (const Quantity_NameOfColor XColor, const Quantity_NameOfColor YColor, const Quantity_NameOfColor ZColor,
663                              const Standard_Real SizeRatio, const Standard_Real AxisDiametr, const Standard_Integer NbFacettes)
664 {
665   Standard_Real R,G,B;
666
667   Quantity_Color(XColor).Values(R, G, B, Quantity_TOC_RGB);
668   theXColor.rgb[0] = float (R);
669   theXColor.rgb[1] = float (G);
670   theXColor.rgb[2] = float (B);
671
672   Quantity_Color(YColor).Values(R, G, B, Quantity_TOC_RGB);
673   theYColor.rgb[0] = float (R);
674   theYColor.rgb[1] = float (G);
675   theYColor.rgb[2] = float (B);
676
677   Quantity_Color(ZColor).Values(R, G, B, Quantity_TOC_RGB);
678   theZColor.rgb[0] = float (R);
679   theZColor.rgb[1] = float (G);
680   theZColor.rgb[2] = float (B);
681
682   theRatio = float (SizeRatio);
683   theDiameter = float (AxisDiametr);
684   theNbFacettes = NbFacettes;
685 }