0024510: Remove unused local variables
[occt.git] / src / OpenGl / OpenGl_Trihedron.cxx
index 07348fa..ea25d1c 100644 (file)
@@ -1,18 +1,23 @@
-// File:      OpenGl_Trihedron.cxx
-// Created:   20 September 2011
-// Author:    Sergey ZERCHANINOV
-// Copyright: OPEN CASCADE 2011
-
-#define QTOCC_PATCH   /* Active QtOPENCASCADE patches */
-
-#include <OpenGl_tgl_all.hxx>
+// Created on: 2011-09-20
+// Created by: Sergey ZERCHANINOV
+// Copyright (c) 2011-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and / or modify it
+// under the terms of the GNU Lesser General Public version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <OpenGl_GlCore11.hxx>
 
 #include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <math.h> /* pour M_PI */
-
-#include <OpenGl_TextureBox.hxx>
 
 #include <InterfaceGraphic_Graphic3d.hxx>  /* pour CALL_DEF_STRUCTURE */
 #include <InterfaceGraphic_Aspect.hxx>  /* pour CALL_DEF_VIEW  */
 
 #include <OpenGl_transform_persistence.hxx>
 
-#ifdef HAVE_GL2PS
-#include <gl2ps.h>
-#endif
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-
 #include <OpenGl_Workspace.hxx>
 #include <OpenGl_View.hxx>
 #include <OpenGl_Trihedron.hxx>
 
-IMPLEMENT_STANDARD_HANDLE(OpenGl_Trihedron,MMgt_TShared)
-IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Trihedron,MMgt_TShared)
-
-/*----------------------------------------------------------------------*/
-/*
-* Constantes
-*/ 
-
-#define NO_DEBUG
-#define NO_PRINT
-#define NO_PRINT_MATRIX
-
-#ifndef M_PI
-# define M_PI          3.14159265358979323846
-#endif
+static const OpenGl_TextParam THE_LABEL_PARAMS =
+{
+  16, Graphic3d_HTA_LEFT, Graphic3d_VTA_BOTTOM
+};
 
 static const CALL_DEF_CONTEXTLINE myDefaultContextLine =
 {
@@ -73,7 +56,7 @@ static const CALL_DEF_CONTEXTTEXT myDefaultContextText =
   { 1.F, 1.F, 1.F }, //ColorSubTitle
   0, //TextZoomable
   0.F, //TextAngle
-  OSD_FA_Regular //TextFontAspect
+  Font_FA_Regular //TextFontAspect
 };
 
 /*----------------------------------------------------------------------*/
@@ -103,13 +86,13 @@ static int   theNbFacettes = 12;
 */
 
 //call_triedron_redraw
-void OpenGl_Trihedron::Redraw (const Handle(OpenGl_Workspace) &AWorkspace) const
+void OpenGl_Trihedron::redraw (const Handle(OpenGl_Workspace)& theWorkspace) const
 {
-  const Standard_Real U = AWorkspace->ActiveView()->Height();
-  const Standard_Real V = AWorkspace->ActiveView()->Width();
+  const Standard_Real U = theWorkspace->ActiveView()->Height();
+  const Standard_Real V = theWorkspace->ActiveView()->Width();
 
   /* la taille des axes est 1 proportion (fixee a l'init du triedre) */
-  /* de la dimension la plus petite de la window.                    */ 
+  /* de la dimension la plus petite de la window.                    */
   const GLdouble L = ( U < V ? U : V ) * myScale;
 
   /*
@@ -168,21 +151,19 @@ void OpenGl_Trihedron::Redraw (const Handle(OpenGl_Workspace) &AWorkspace) const
       break;
   }
 
-  /* 
-  * Creation du triedre 
+  /*
+  * Creation du triedre
   */
-  const OpenGl_AspectLine *AspectLine = AWorkspace->AspectLine( Standard_True );
 
-#ifdef QTOCC_PATCH /* Fotis Sioutis 2007-11-14 15:06 
-  I have also seen in previous posts that the view trihedron in V3d_WIREFRAME mode 
-  changes colors depending on the state of the view. This behaviour can be easily 
+  /* Fotis Sioutis 2007-11-14 15:06
+  I have also seen in previous posts that the view trihedron in V3d_WIREFRAME mode
+  changes colors depending on the state of the view. This behaviour can be easily
   corrected by altering call_triedron_redraw function in OpenGl_triedron.c of TKOpengl.
-  The only change needed is to erase glDisable(GL_LIGHTING) that is called before the 
+  The only change needed is to erase glDisable(GL_LIGHTING) that is called before the
   Axis name drawing and move this function call just before the initial axis drawing.
-  Below is the code portion with the modification.I don't know if this is considered to 
+  Below is the code portion with the modification.I don't know if this is considered to
   be a bug but anyway i believe it might help some of you out there.*/
   glDisable(GL_LIGHTING);
-#endif
 
   /* Position de l'origine */
   const GLdouble TriedronOrigin[3] = { 0.0, 0.0, 0.0 };
@@ -270,20 +251,18 @@ void OpenGl_Trihedron::Redraw (const Handle(OpenGl_Workspace) &AWorkspace) const
     TriedronCoord[1] = rayon * cos(ii * Angle1);
     glVertex3dv( TriedronCoord );
     ii--;
-  }  
+  }
   glEnd();
 
-  /* 
-  * Noms des axes et de l'origine
-  */
-  const OpenGl_AspectText *AspectText = AWorkspace->AspectText( Standard_True );
-  glColor3fv (AspectText->Color().rgb);
-
-  AWorkspace->RenderText (L"X", 0, float(L + rayon),    0.0f,                   float(-rayon));
-  AWorkspace->RenderText (L"Y", 0, float(rayon),        float(L + 3.0 * rayon), float(2.0 * rayon));
-  AWorkspace->RenderText (L"Z", 0, float(-2.0 * rayon), float(0.5 * rayon),     float(L + 3.0 * rayon));
+  // draw axes labels
+  myLabelX.SetPosition (OpenGl_Vec3(float(L + rayon),    0.0f,                   float(-rayon)));
+  myLabelY.SetPosition (OpenGl_Vec3(float(rayon),        float(L + 3.0 * rayon), float(2.0 * rayon)));
+  myLabelZ.SetPosition (OpenGl_Vec3(float(-2.0 * rayon), float(0.5 * rayon),     float(L + 3.0 * rayon)));
+  myLabelX.Render (theWorkspace);
+  myLabelY.Render (theWorkspace);
+  myLabelZ.Render (theWorkspace);
 
-  /* 
+  /*
   * restauration du contexte des matrices
   */
   glMatrixMode (GL_PROJECTION);
@@ -297,10 +276,10 @@ void OpenGl_Trihedron::Redraw (const Handle(OpenGl_Workspace) &AWorkspace) const
 *  Draws ZBUFFER trihedron mode
 *******************************************************/
 //call_zbuffer_triedron_redraw
-void OpenGl_Trihedron::RedrawZBuffer (const Handle(OpenGl_Workspace) &AWorkspace) const
+void OpenGl_Trihedron::redrawZBuffer (const Handle(OpenGl_Workspace)& theWorkspace) const
 {
-  const Standard_Real U = AWorkspace->ActiveView()->Height();
-  const Standard_Real V = AWorkspace->ActiveView()->Width();
+  const Standard_Real U = theWorkspace->ActiveView()->Height();
+  const Standard_Real V = theWorkspace->ActiveView()->Width();
 
   GLdouble modelMatrix[4][4];
   glGetDoublev( GL_MODELVIEW_MATRIX,  (GLdouble *) modelMatrix );
@@ -308,28 +287,14 @@ void OpenGl_Trihedron::RedrawZBuffer (const Handle(OpenGl_Workspace) &AWorkspace
   glGetDoublev( GL_PROJECTION_MATRIX, (GLdouble *) projMatrix );
 
   /* Check position in the ViewPort */
-#ifdef QTOCC_PATCH /* PCD 29/09/2008 */
+  /* PCD 29/09/2008 */
   /* Simple code modification recommended by Fotis Sioutis and Peter Dolbey  */
   /* to remove the irritating default behaviour of triedrons using V3d_ZBUFFER   */
   /* which causes the glyph to jump around the screen when the origin moves offscreen. */
   GLboolean isWithinView = GL_FALSE;
-#else
-  /* Original code */
-  GLint   aViewPort[4];  /* to store view port coordinates */
-  glGetIntegerv(GL_VIEWPORT, aViewPort);
-  GLdouble aWinCoord[3];
-  /* Position de l'origine */
-  const GLdouble TriedronOrigin[3] = { 0.0, 0.0, 0.0 };
-  gluProject(TriedronOrigin[0], TriedronOrigin[1], TriedronOrigin[2],
-             (GLdouble *)modelMatrix, (GLdouble *)projMatrix, aViewPort,
-             &aWinCoord[0], &aWinCoord[1], &aWinCoord[2]);
-
-  GLboolean isWithinView = !((aWinCoord[0]<aViewPort[0]) || (aWinCoord[0]>aViewPort[2]) ||
-                             (aWinCoord[1]<aViewPort[1]) || (aWinCoord[1]>aViewPort[3]));
-#endif
 
   /* la taille des axes est 1 proportion (fixee a l'init du triedre) */
-  /* de la dimension la plus petite de la window.                    */ 
+  /* de la dimension la plus petite de la window.                    */
   GLdouble L = ( U < V ? U : V ) * myScale;
 
   if (!isWithinView)
@@ -357,7 +322,7 @@ void OpenGl_Trihedron::RedrawZBuffer (const Handle(OpenGl_Workspace) &AWorkspace
     */
     switch (myPos)
     {
-      case Aspect_TOTP_LEFT_LOWER : 
+      case Aspect_TOTP_LEFT_LOWER :
         glTranslated( -0.5*U + L , -0.5*V + L , 0. );
         break;
 
@@ -380,10 +345,10 @@ void OpenGl_Trihedron::RedrawZBuffer (const Handle(OpenGl_Workspace) &AWorkspace
     L *= myRatio;
   }
 
-  const OpenGl_AspectLine *AspectLine = AWorkspace->AspectLine( Standard_True );
+  const OpenGl_AspectLine *AspectLine = theWorkspace->AspectLine( Standard_True );
   const TEL_COLOUR &aLineColor = AspectLine->Color();
 
-  /* 
+  /*
   * Creation the trihedron
   */
 #define CYLINDER_LENGTH   0.75f
@@ -393,19 +358,12 @@ void OpenGl_Trihedron::RedrawZBuffer (const Handle(OpenGl_Workspace) &AWorkspace
 
   const GLboolean aIsDepthEnabled = glIsEnabled(GL_DEPTH_TEST);
 
-#ifndef BUG
-
   GLboolean aIsDepthMaskEnabled;
-#ifdef QTOCC_PATCH  /*PCD 02/07/07   */
+  /*PCD 02/07/07   */
   /* GL_DEPTH_WRITEMASK is not a valid argument to glIsEnabled, the  */
   /* original code is shown to be broken when run under an OpenGL debugger  */
   /* like GLIntercept. This is the correct way to retrieve the mask value.  */
-  glGetBooleanv(GL_DEPTH_WRITEMASK, &aIsDepthMaskEnabled); 
-#else
-  aIsDepthMaskEnabled = glIsEnabled(GL_DEPTH_WRITEMASK);
-#endif
-
-#endif 
+  glGetBooleanv(GL_DEPTH_WRITEMASK, &aIsDepthMaskEnabled);
 
   const GLdouble aCylinderLength = L * CYLINDER_LENGTH;
   const GLdouble aCylinderDiametr = L * myDiameter;
@@ -442,138 +400,66 @@ void OpenGl_Trihedron::RedrawZBuffer (const Handle(OpenGl_Workspace) &AWorkspace
   glCullFace(GL_BACK);
   glEnable(GL_CULL_FACE);
 
-#ifdef QTOCC_PATCH /*Fotis Sioutis | 2008-01-21 10:55
-  In the function call_zbuffer_triedron_redraw of TKOpengl, 
-  the z buffered trihedron changes colors in case there 
-  is an object in the scene that has an explicit material 
-  attached to it.In the trihedron display loop, 
-  GL_COLOR_MATERIAL is enabled, but only the GL_DIFFUSE 
+  /*Fotis Sioutis | 2008-01-21 10:55
+  In the function call_zbuffer_triedron_redraw of TKOpengl,
+  the z buffered trihedron changes colors in case there
+  is an object in the scene that has an explicit material
+  attached to it.In the trihedron display loop,
+  GL_COLOR_MATERIAL is enabled, but only the GL_DIFFUSE
   parameter is utilized in glColorMaterial(...).
-  This causes the last ambient,specular and emission values 
+  This causes the last ambient,specular and emission values
   used, to stay at the stack and applied to the trihedron
   (which causes the color change).
-  A fix is proposed , to change GL_DIFFUSE to 
-  GL_AMBIENT_AND_DIFFUSE in glColorMaterial call in 
-  line 946.The above of course will leave unchanged 
+  A fix is proposed , to change GL_DIFFUSE to
+  GL_AMBIENT_AND_DIFFUSE in glColorMaterial call in
+  line 946.The above of course will leave unchanged
   the SPECULAR and EMISSION values.
-  Another proposal which would fix 100% the problem 
-  is to use glMaterial instead of glColor on the trihedron 
+  Another proposal which would fix 100% the problem
+  is to use glMaterial instead of glColor on the trihedron
   drawing loop.               */
   const GLfloat aNULLColor[] = { 0.f, 0.f, 0.f, 0.f }; /* FS 21/01/08 */
   glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, aNULLColor);
   glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, aNULLColor);
   glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, aNULLColor);
   glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 0.f);
-#endif
 
   glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
   glEnable(GL_COLOR_MATERIAL);
 
   if (!aIsDepthEnabled)  {
     glEnable(GL_DEPTH_TEST);
-#ifndef BUG
     glClear(GL_DEPTH_BUFFER_BIT);
-#endif
   }
-#ifdef BUG
-  if (!(aIsDepthEnabled && isWithinView))
-    glClear(GL_DEPTH_BUFFER_BIT);
-#endif
 
-#ifndef BUG
   if (!aIsDepthMaskEnabled)  {
     /* This is how the depthmask needs to be re-enabled...*/
     glDepthMask(GL_TRUE);
     /* ...and not this stuff below */
   }
-#endif
 
   /* Position des Axes */
   GLdouble TriedronAxeX[3] = { 1.0, 0.0, 0.0 };
   GLdouble TriedronAxeY[3] = { 0.0, 1.0, 0.0 };
-  GLdouble TriedronAxeZ[3] = { 0.0, 0.0, 1.0 };
   TriedronAxeX[0] = L;
   TriedronAxeY[1] = L;
-  TriedronAxeZ[2] = L;
 
   glMatrixMode(GL_MODELVIEW);
 
-#ifdef QTOCC_PATCH /* PCD 17/06/07  */
+  /* PCD 17/06/07  */
   GLint df;
-  glGetIntegerv (GL_DEPTH_FUNC, &df); 
-#else
-  /*
-#define COLOR_REDUCE      0.3f
-#ifdef BUG
-#define ALPHA_REDUCE      0.4f
-#else
-#define ALPHA_REDUCE      1.0f
-#endif
-  //szv:if (isWithinView) {
-  glDepthFunc(GL_GREATER);
-  glPushMatrix();
-  glPushMatrix();
-  glPushMatrix();
-
-  glColor4f(aLineColor.rgb[0]*COLOR_REDUCE, 
-            aLineColor.rgb[1]*COLOR_REDUCE, 
-            aLineColor.rgb[2]*COLOR_REDUCE,
-            ALPHA_REDUCE);
-  glCallList(startList+2);
-
-  // Z axis
-  glColor4f(myZColor.rgb[0]*COLOR_REDUCE, 
-            myZColor.rgb[1]*COLOR_REDUCE, 
-            myZColor.rgb[2]*COLOR_REDUCE,
-            ALPHA_REDUCE);
-  glCallList(startList);
-  glTranslated(0, 0, L * CYLINDER_LENGTH);
-  glCallList(startList + 3);
-  glCallList(startList + 1);
-  glPopMatrix();    
-
-  // X axis
-  glRotated(90.0, TriedronAxeY[0], TriedronAxeY[1], TriedronAxeY[2]);
-  glColor4f(myXColor.rgb[0]*COLOR_REDUCE,
-            myXColor.rgb[1]*COLOR_REDUCE, 
-            myXColor.rgb[2]*COLOR_REDUCE,
-            ALPHA_REDUCE);
-  glCallList(startList);
-  glTranslated(0, 0, L * CYLINDER_LENGTH);
-  glCallList(startList + 3);
-  glCallList(startList + 1);
-  glPopMatrix();    
-
-  // Y axis
-  glRotated(-90.0, TriedronAxeX[0], TriedronAxeX[1], TriedronAxeX[2]);
-  glColor4f(myYColor.rgb[0]*COLOR_REDUCE, 
-            myYColor.rgb[1]*COLOR_REDUCE, 
-            myYColor.rgb[2]*COLOR_REDUCE,
-            ALPHA_REDUCE);
-  glCallList(startList);
-  glTranslated(0, 0, L * CYLINDER_LENGTH);
-  glCallList(startList + 3);
-  glCallList(startList + 1);
-  glPopMatrix();
-
-  glDepthFunc(GL_LESS);
-  //szv:}
-  */
-#endif
+  glGetIntegerv (GL_DEPTH_FUNC, &df);
 
-#ifdef QTOCC_PATCH
   int i;
   for (i = 0; i < 2; i++) /* PCD 11/02/08 Two pass method */
   {
     if (i == 0) /*  First pass  */
-    {                          
-      glDepthFunc(GL_ALWAYS); 
+    {
+      glDepthFunc(GL_ALWAYS);
     }
     else
     {
-      glDepthFunc(GL_LEQUAL); 
+      glDepthFunc(GL_LEQUAL);
     }
-#endif
 
     glPushMatrix();
     glPushMatrix();
@@ -588,7 +474,7 @@ void OpenGl_Trihedron::RedrawZBuffer (const Handle(OpenGl_Workspace) &AWorkspace
     glTranslated(0, 0, L * CYLINDER_LENGTH);
     glCallList(startList + 3);
     glCallList(startList + 1);
-    glPopMatrix();    
+    glPopMatrix();
 
     // X axis
     glRotated(90.0, TriedronAxeY[0], TriedronAxeY[1], TriedronAxeY[2]);
@@ -597,7 +483,7 @@ void OpenGl_Trihedron::RedrawZBuffer (const Handle(OpenGl_Workspace) &AWorkspace
     glTranslated(0, 0, L * CYLINDER_LENGTH);
     glCallList(startList + 3);
     glCallList(startList + 1);
-    glPopMatrix();    
+    glPopMatrix();
 
     // Y axis
     glRotated(-90.0, TriedronAxeX[0], TriedronAxeX[1], TriedronAxeX[2]);
@@ -607,33 +493,22 @@ void OpenGl_Trihedron::RedrawZBuffer (const Handle(OpenGl_Workspace) &AWorkspace
     glCallList(startList + 3);
     glCallList(startList + 1);
     glPopMatrix();
-
-#ifdef QTOCC_PATCH
   }
-#endif
 
-  if (!aIsDepthEnabled) 
+  if (!aIsDepthEnabled)
     glDisable(GL_DEPTH_TEST);
-#ifndef BUG
-  if (!aIsDepthMaskEnabled)
 
-#ifdef QTOCC_PATCH /*PCD 02/07/07   */
+  if (!aIsDepthMaskEnabled)
     glDepthMask(GL_FALSE);
-#else
-    glDisable(GL_DEPTH_WRITEMASK);
-#endif
 
-#endif
   glDisable(GL_CULL_FACE);
   glDisable(GL_COLOR_MATERIAL);
 
   gluDeleteQuadric(aQuadric);
   glColor3fv (aLineColor.rgb);
 
-#ifdef QTOCC_PATCH /* PCD 11/02/08 */
   /* Always write the text */
-  glDepthFunc(GL_ALWAYS); 
-#endif
+  glDepthFunc(GL_ALWAYS);
 
   glPopAttrib();
 
@@ -642,24 +517,20 @@ void OpenGl_Trihedron::RedrawZBuffer (const Handle(OpenGl_Workspace) &AWorkspace
   const GLdouble rayon = L/30. ; /* rayon de la base du cone */
   //const double Angle = 2. * M_PI/ myNbFacettes;
 
-  glDeleteLists(startList, 4); 
+  glDeleteLists(startList, 4);
 
   glDisable(GL_LIGHTING);
 
-  /* 
-  * origine names
-  */
-  const OpenGl_AspectText *AspectText = AWorkspace->AspectText( Standard_True );
-  glColor3fv (AspectText->Color().rgb);
-
-  AWorkspace->RenderText (L"X", 0, float(L + rayon),    0.0f,                   float(-rayon));
-  AWorkspace->RenderText (L"Y", 0, float(rayon),        float(L + 3.0 * rayon), float(2.0 * rayon));
-  AWorkspace->RenderText (L"Z", 0, float(-2.0 * rayon), float(0.5 * rayon),     float(L + 3.0 * rayon));
+  // draw axes labels
+  myLabelX.SetPosition (OpenGl_Vec3(float(L + rayon),    0.0f,                   float(-rayon)));
+  myLabelY.SetPosition (OpenGl_Vec3(float(rayon),        float(L + 3.0 * rayon), float(2.0 * rayon)));
+  myLabelZ.SetPosition (OpenGl_Vec3(float(-2.0 * rayon), float(0.5 * rayon),     float(L + 3.0 * rayon)));
+  myLabelX.Render (theWorkspace);
+  myLabelY.Render (theWorkspace);
+  myLabelZ.Render (theWorkspace);
 
-#ifdef QTOCC_PATCH
   /*PCD 17/06/07    */
   glDepthFunc(df);
-#endif
 
   if (!isWithinView) { /* restore matrix */
     glMatrixMode (GL_PROJECTION);
@@ -674,7 +545,7 @@ void OpenGl_Trihedron::RedrawZBuffer (const Handle(OpenGl_Workspace) &AWorkspace
 
 /*----------------------------------------------------------------------*/
 /*
-* Fonctions publiques 
+* Fonctions publiques
 */
 
 
@@ -684,27 +555,32 @@ void OpenGl_Trihedron::RedrawZBuffer (const Handle(OpenGl_Workspace) &AWorkspace
 */
 
 //call_triedron_init
-OpenGl_Trihedron::OpenGl_Trihedron (const Aspect_TypeOfTriedronPosition APosition, const Quantity_NameOfColor AColor,
-                                  const Standard_Real AScale, const Standard_Boolean AsWireframe)
-: myPos(APosition),
-  myScale(AScale),
-  myIsWireframe(AsWireframe)
+OpenGl_Trihedron::OpenGl_Trihedron (const Aspect_TypeOfTriedronPosition thePosition,
+                                    const Quantity_NameOfColor          theColor,
+                                    const Standard_Real                 theScale,
+                                    const Standard_Boolean              theAsWireframe)
+: myPos (thePosition),
+  myScale (theScale),
+  myIsWireframe (theAsWireframe),
+  myLabelX (TCollection_ExtendedString ("X"), OpenGl_Vec3(1.0f, 0.0f, 0.0f), THE_LABEL_PARAMS),
+  myLabelY (TCollection_ExtendedString ("Y"), OpenGl_Vec3(0.0f, 1.0f, 0.0f), THE_LABEL_PARAMS),
+  myLabelZ (TCollection_ExtendedString ("Z"), OpenGl_Vec3(0.0f, 0.0f, 1.0f), THE_LABEL_PARAMS)
 {
   Standard_Real R,G,B;
-  Quantity_Color Color(AColor);
-  Color.Values(R,G,B,Quantity_TOC_RGB);
+  Quantity_Color aColor (theColor);
+  aColor.Values (R, G, B, Quantity_TOC_RGB);
 
-  CALL_DEF_CONTEXTLINE aContextLine = myDefaultContextLine;
-  aContextLine.Color.r = (float)R;
-  aContextLine.Color.g = (float)G;
-  aContextLine.Color.b = (float)B;
-  myAspectLine.SetContext(aContextLine);
+  CALL_DEF_CONTEXTLINE aLineAspect = myDefaultContextLine;
+  aLineAspect.Color.r = (float)R;
+  aLineAspect.Color.g = (float)G;
+  aLineAspect.Color.b = (float)B;
+  myAspectLine.SetAspect (aLineAspect);
 
-  CALL_DEF_CONTEXTTEXT aContextText = myDefaultContextText;
-  aContextText.Color.r = (float)R;
-  aContextText.Color.g = (float)G;
-  aContextText.Color.b = (float)B;
-  myAspectText.SetContext(aContextText);
+  CALL_DEF_CONTEXTTEXT aTextAspect = myDefaultContextText;
+  aTextAspect.Color.r = (float)R;
+  aTextAspect.Color.g = (float)G;
+  aTextAspect.Color.b = (float)B;
+  myAspectText.SetAspect (aTextAspect);
 
   myXColor = theXColor;
   myYColor = theYColor;
@@ -722,51 +598,71 @@ OpenGl_Trihedron::OpenGl_Trihedron (const Aspect_TypeOfTriedronPosition APositio
 */
 
 //call_triedron_erase
-OpenGl_Trihedron::~OpenGl_Trihedron ()
+OpenGl_Trihedron::~OpenGl_Trihedron()
 {
 }
 
+// =======================================================================
+// function : Release
+// purpose  :
+// =======================================================================
+void OpenGl_Trihedron::Release (const Handle(OpenGl_Context)& theCtx)
+{
+  myLabelX.Release (theCtx);
+  myLabelY.Release (theCtx);
+  myLabelZ.Release (theCtx);
+  myAspectLine.Release (theCtx);
+  myAspectText.Release (theCtx);
+}
+
 /*----------------------------------------------------------------------*/
 
 /*
-* affichage d'un triedre non zoomable dans la wks  awsid 
+* affichage d'un triedre non zoomable dans la wks  awsid
 *
 * Triedre = Objet non Zoomable;
-* on cree cette fonction pour pouvoir travailler par les structures 
+* on cree cette fonction pour pouvoir travailler par les structures
 * utilisees par les fonctions Tsm* et TEL_VIEW_REP
 *
 */
 
 //call_triedron_redraw_from_wsid
-void OpenGl_Trihedron::Render (const Handle(OpenGl_Workspace) &AWorkspace) const
+void OpenGl_Trihedron::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
 {
-  const OpenGl_AspectLine *oldAspectLine = AWorkspace->SetAspectLine(&myAspectLine);
-  const OpenGl_AspectText *oldAspectText = AWorkspace->SetAspectText(&myAspectText);
+  const OpenGl_AspectLine* aPrevAspectLine = theWorkspace->SetAspectLine (&myAspectLine);
+  const OpenGl_AspectText* aPrevAspectText = theWorkspace->SetAspectText (&myAspectText);
 
   /* check if GL_LIGHTING should be disabled
-  no enabling 'cause it will be done (if necessary: kinda Polygon types ) 
+  no enabling 'cause it will be done (if necessary: kinda Polygon types )
   during redrawing structures
   */
-  if (!AWorkspace->UseGLLight())
-    glDisable( GL_LIGHTING );
+  if (!theWorkspace->UseGLLight())
+  {
+    glDisable (GL_LIGHTING);
+  }
 
-  /* sauvegarde du contexte (on reste dans le buffer courant) */
-  const GLboolean save_texture_state = IsTextureEnabled();
-  DisableTexture();
+  const Handle(OpenGl_Texture) aPrevTexture = theWorkspace->DisableTexture();
 
   /* affichage du Triedre Non Zoomable */
-  AWorkspace->ActiveView()->EndTransformPersistence();
+  theWorkspace->ActiveView()->EndTransformPersistence (theWorkspace->GetGlContext());
 
   if (myIsWireframe)
-    Redraw (AWorkspace);
+  {
+    redraw (theWorkspace);
+  }
   else
-    RedrawZBuffer (AWorkspace);
+  {
+    redrawZBuffer (theWorkspace);
+  }
 
-  /* restauration du contexte */
-  if (save_texture_state) EnableTexture();
+  // restore aspects
+  if (!aPrevTexture.IsNull())
+  {
+    theWorkspace->EnableTexture (aPrevTexture);
+  }
 
-  AWorkspace->SetAspectText(oldAspectText);
-  AWorkspace->SetAspectLine(oldAspectLine);
+  theWorkspace->SetAspectText (aPrevAspectText);
+  theWorkspace->SetAspectLine (aPrevAspectLine);
 }
 
 /*----------------------------------------------------------------------*/