0025442: Visualization, TKOpenGl - prevent inclusion of system header glxext.h
[occt.git] / src / OpenGl / OpenGl_GraduatedTrihedron.cxx
CommitLineData
b311480e 1// Created on: 2011-09-20
2// Created by: Sergey ZERCHANINOV
a174a3c5 3// Copyright (c) 2011-2013 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
d5f74e42 7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
b311480e 15
5f8b738e 16#include <OpenGl_GlCore11.hxx>
7fd59977 17
18#include <stddef.h>
19#include <stdio.h>
20#include <stdlib.h>
21#include <math.h>
22
7fd59977 23#include <InterfaceGraphic_Graphic3d.hxx>
24#include <InterfaceGraphic_Aspect.hxx>
25#include <InterfaceGraphic_Visual3d.hxx>
26
03155c18 27#ifndef _WIN32
a174a3c5 28 #include <string.h>
7fd59977 29#endif
30
2166f0fa
SK
31#include <OpenGl_Workspace.hxx>
32#include <OpenGl_View.hxx>
33#include <OpenGl_GraduatedTrihedron.hxx>
34#include <OpenGl_AspectLine.hxx>
7fd59977 35
2166f0fa 36const OpenGl_AspectLine myDefaultAspectLine;
7fd59977 37
a174a3c5 38static const OpenGl_TextParam THE_LABEL_PARAMS =
39{
40 16, Graphic3d_HTA_LEFT, Graphic3d_VTA_BOTTOM
41};
42
2166f0fa
SK
43/* Bounding box */
44float xmin = 0.0f, ymin = 0.0f, zmin = 0.0f, xmax = 100.0f, ymax = 100.0f, zmax = 100.0f;
7fd59977 45
46/* Normal of the view (not normalized!) */
cfd5fa01 47static float getNormal(float* normal)
7fd59977 48{
ca3c13d1 49#if !defined(GL_ES_VERSION_2_0)
2166f0fa
SK
50 GLint viewport[4];
51 GLdouble model_matrix[16], proj_matrix[16];
52
53 glGetDoublev(GL_MODELVIEW_MATRIX, model_matrix);
54 glGetDoublev(GL_PROJECTION_MATRIX, proj_matrix);
55 glGetIntegerv(GL_VIEWPORT, viewport);
56
57 double x1, y1, z1, x2, y2, z2, x3, y3, z3;
58 gluUnProject(viewport[0], viewport[1], 0., model_matrix, proj_matrix, viewport, &x1, &y1, &z1);
59 gluUnProject(viewport[0] + viewport[2], viewport[1], 0., model_matrix, proj_matrix, viewport, &x2, &y2, &z2);
60 gluUnProject(viewport[0], viewport[1] + viewport[3], 0., model_matrix, proj_matrix, viewport, &x3, &y3, &z3);
61
62 /* Normal out of user is p1p3^p1p2 */
63 const double dx1 = x3 - x1;
64 const double dy1 = y3 - y1;
65 const double dz1 = z3 - z1;
66 const double dx2 = x2 - x1;
67 const double dy2 = y2 - y1;
68 const double dz2 = z2 - z1;
69 normal[0] = (float) (dy1 * dz2 - dz1 * dy2);
70 normal[1] = (float) (dz1 * dx2 - dx1 * dz2);
71 normal[2] = (float) (dx1 * dy2 - dy1 * dx2);
72
73 /* Distance corresponding to 1 pixel */
74 const float width = (float) sqrt(dx2 * dx2 + dy2 * dy2 + dz2 * dz2);
75 return width / (float) viewport[2];
ca3c13d1 76#else
77 return 1.0f;
78#endif
7fd59977 79}
80
81static float getDistance2Corner(float* normal, float* center, float x, float y, float z)
82{
83 return normal[0] * (x - center[0]) + normal[1] * (y - center[1]) + normal[2] * (z - center[2]);
84}
85
cfd5fa01 86static char getFarestCorner(float d000, float d100, float d010, float d001,
7fd59977 87 float d110, float d101, float d011, float d111)
88{
cfd5fa01 89 if (d000 > 0.0f &&
90 d000 > d100 && d000 > d010 && d000 > d001 && d000 > d110 &&
7fd59977 91 d000 > d101 && d000 > d011 && d000 > d111)
92 {
93 return 1;
94 }
95 else if (d100 > 0.0f &&
cfd5fa01 96 d100 > d000 && d100 > d010 && d100 > d001 && d100 > d110 &&
7fd59977 97 d100 > d101 && d100 > d011 && d100 > d111)
98 {
99 return 2;
100 }
101 else if (d010 > 0.0f &&
cfd5fa01 102 d010 > d000 && d010 > d100 && d010 > d001 && d010 > d110 &&
7fd59977 103 d010 > d101 && d010 > d011 && d010 > d111)
104 {
105 return 3;
106 }
107 else if (d001 > 0.0f &&
cfd5fa01 108 d001 > d000 && d001 > d100 && d001 > d010 && d001 > d110 &&
7fd59977 109 d001 > d101 && d001 > d011 && d001 > d111)
110 {
111 return 4;
112 }
113 else if (d110 > 0.0f &&
cfd5fa01 114 d110 > d000 && d110 > d100 && d110 > d010 && d110 > d001 &&
7fd59977 115 d110 > d101 && d110 > d011 && d110 > d111)
116 {
117 return 5;
118 }
119 else if (d101 > 0.0f &&
cfd5fa01 120 d101 > d000 && d101 > d100 && d101 > d010 && d101 > d001 &&
7fd59977 121 d101 > d110 && d101 > d011 && d101 > d111)
122 {
123 return 6;
124 }
125 else if (d011 > 0.0f &&
cfd5fa01 126 d011 > d000 && d011 > d100 && d011 > d010 && d011 > d001 &&
7fd59977 127 d011 > d110 && d011 > d101 && d011 > d111)
128 {
129 return 7;
130 }
131 return 8; /* d111 */
132}
133
cfd5fa01 134static void drawArrow(float x1, float y1, float z1,
7fd59977 135 float x2, float y2, float z2,
136 float xn, float yn, float zn)
137{
ca3c13d1 138#if !defined(GL_ES_VERSION_2_0)
7fd59977 139 float h, r;
140 float xa, ya, za;
141 float x0, y0, z0;
142 float xr, yr, zr;
143 float xa1, ya1, za1, xa2, ya2, za2;
144
145 /* Start of arrow: at 10% from the end */
146 x0 = x1 + 0.9f * (x2 - x1); y0 = y1 + 0.9f * (y2 - y1); z0 = z1 + 0.9f * (z2 - z1);
147
148 /* Base of the arrow */
149 xa = (x2 - x0); ya = (y2 - y0); za = (z2 - z0);
150
151 /* Height of the arrow */
152 h = sqrtf(xa * xa + ya * ya + za * za);
153 if (h <= 0.0f)
154 return;
155 xa = xa / h; ya = ya / h; za = za / h;
156
157 /* Radial direction to the arrow */
158 xr = ya * zn - za * yn;
159 yr = za * xn - xa * zn;
160 zr = xa * yn - ya * xn;
161
162 /* Normalize the radial vector */
163 r = sqrtf(xr * xr + yr * yr + zr * zr);
164 if (r <= 0.0f)
165 return;
166 xr = xr / r; yr = yr / r; zr = zr / r;
167
168 /* First point of the base of the arrow */
169 r = 0.2f * h;
170 xr = r * xr; yr = r * yr; zr = r * zr;
171 xa1 = x0 + xr; ya1 = y0 + yr; za1 = z0 + zr;
172
173 /* Second point of the base of the arrow */
174 xa2 = x0 - xr; ya2 = y0 - yr; za2 = z0 - zr;
175
176 /* Draw a line to the arrow */
177 glBegin(GL_LINES);
178 glVertex3f(x1, y1, z1);
179 glVertex3f(x0, y0, z0);
180 glEnd();
181
182 /* Draw a triangle of the arrow */
183 glBegin(GL_LINE_LOOP);
184 glVertex3f(xa1, ya1, za1);
185 glVertex3f(xa2, ya2, za2);
186 glVertex3f(x2, y2, z2);
187 glEnd();
ca3c13d1 188#endif
7fd59977 189}
190
a174a3c5 191// =======================================================================
192// function : Release
193// purpose :
194// =======================================================================
10b9c7df 195void OpenGl_GraduatedTrihedron::Release (OpenGl_Context* theCtx)
7fd59977 196{
a174a3c5 197 myLabelX.Release (theCtx);
198 myLabelY.Release (theCtx);
199 myLabelZ.Release (theCtx);
200 myLabelValues.Release (theCtx);
7fd59977 201}
202
a174a3c5 203OpenGl_GraduatedTrihedron::OpenGl_GraduatedTrihedron (const Graphic3d_CGraduatedTrihedron& theData)
b64d84be 204: myLabelX (NCollection_String ((Standard_Utf16Char* )theData.xname.ToExtString()).ToCString(), OpenGl_Vec3(1.0f, 0.0f, 0.0f), THE_LABEL_PARAMS),
205 myLabelY (NCollection_String ((Standard_Utf16Char* )theData.yname.ToExtString()).ToCString(), OpenGl_Vec3(0.0f, 1.0f, 0.0f), THE_LABEL_PARAMS),
206 myLabelZ (NCollection_String ((Standard_Utf16Char* )theData.zname.ToExtString()).ToCString(), OpenGl_Vec3(0.0f, 0.0f, 1.0f), THE_LABEL_PARAMS),
a174a3c5 207 myToDrawXName (theData.xdrawname == Standard_True),
208 myToDrawYName (theData.ydrawname == Standard_True),
209 myToDrawZName (theData.zdrawname == Standard_True),
210 myToDrawXValues (theData.xdrawvalues == Standard_True),
211 myToDrawYValues (theData.ydrawvalues == Standard_True),
212 myToDrawZValues (theData.zdrawvalues == Standard_True),
213 myToDrawGrid (theData.drawgrid == Standard_True),
214 myToDrawAxes (theData.drawaxes == Standard_True),
215 myNbX (theData.nbx),
216 myNbY (theData.nby),
217 myNbZ (theData.nbz),
218 myXOffset (theData.xoffset),
219 myYOffset (theData.yoffset),
220 myZOffset (theData.zoffset),
221 myXAxisOffset (theData.xaxisoffset),
222 myYAxisOffset (theData.yaxisoffset),
223 myZAxisOffset (theData.zaxisoffset),
224 myDrawXTickmarks (theData.xdrawtickmarks),
225 myDrawYTickmarks (theData.ydrawtickmarks),
226 myDrawZTickmarks (theData.zdrawtickmarks),
227 myXTickmarkLength (theData.xtickmarklength),
228 myYTickmarkLength (theData.ytickmarklength),
229 myZTickmarkLength (theData.ztickmarklength),
230 myCbCubicAxes (theData.cbCubicAxes),
231 myPtrVisual3dView (theData.ptrVisual3dView)
7fd59977 232{
a174a3c5 233 myAspectLabels.ChangeFontName() = theData.fontOfNames;
234 myAspectValues.ChangeFontName() = theData.fontOfValues;
235 myAspectLabels.SetFontAspect (theData.styleOfNames);
236 myAspectValues.SetFontAspect (theData.styleOfValues);
237 myLabelX.SetFontSize (NULL, theData.sizeOfNames);
238 myLabelY.SetFontSize (NULL, theData.sizeOfNames);
239 myLabelZ.SetFontSize (NULL, theData.sizeOfNames);
240 myLabelValues.SetFontSize (NULL, theData.sizeOfValues);
241
242 // Grid color
243 myGridColor[0] = (float) theData.gridcolor.Red();
244 myGridColor[1] = (float) theData.gridcolor.Green();
245 myGridColor[2] = (float) theData.gridcolor.Blue();
246 // X name color
247 myXNameColor.rgb[0] = (float )theData.xnamecolor.Red();
248 myXNameColor.rgb[1] = (float )theData.xnamecolor.Green();
249 myXNameColor.rgb[2] = (float )theData.xnamecolor.Blue();
250 myXNameColor.rgb[3] = 1.0f;
251 // Y name color
252 myYNameColor.rgb[0] = (float )theData.ynamecolor.Red();
253 myYNameColor.rgb[1] = (float )theData.ynamecolor.Green();
254 myYNameColor.rgb[2] = (float )theData.ynamecolor.Blue();
255 myYNameColor.rgb[3] = 1.0f;
256 // Z name color
257 myZNameColor.rgb[0] = (float )theData.znamecolor.Red();
258 myZNameColor.rgb[1] = (float )theData.znamecolor.Green();
259 myZNameColor.rgb[2] = (float )theData.znamecolor.Blue();
260 myZNameColor.rgb[3] = 1.0f;
261 // X color of axis and values
262 myXColor.rgb[0] = (float )theData.xcolor.Red();
263 myXColor.rgb[1] = (float )theData.xcolor.Green();
264 myXColor.rgb[2] = (float )theData.xcolor.Blue();
265 myXColor.rgb[3] = 1.0f;
266 // Y color of axis and values
267 myYColor.rgb[0] = (float )theData.ycolor.Red();
268 myYColor.rgb[1] = (float )theData.ycolor.Green();
269 myYColor.rgb[2] = (float )theData.ycolor.Blue();
270 myYColor.rgb[3] = 1.0f;
271 // Z color of axis and values
272 myZColor.rgb[0] = (float )theData.zcolor.Red();
273 myZColor.rgb[1] = (float )theData.zcolor.Green();
274 myZColor.rgb[2] = (float )theData.zcolor.Blue();
275 myZColor.rgb[3] = 1.0f;
276}
277
278OpenGl_GraduatedTrihedron::~OpenGl_GraduatedTrihedron()
279{
280 //
2166f0fa 281}
13a22457 282
2166f0fa 283//call_graduatedtrihedron_redraw
a174a3c5 284void OpenGl_GraduatedTrihedron::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
2166f0fa 285{
ca3c13d1 286#if !defined(GL_ES_VERSION_2_0)
a174a3c5 287 const OpenGl_AspectLine *oldAspectLine = theWorkspace->SetAspectLine(&myDefaultAspectLine);
288 theWorkspace->AspectLine(Standard_True);
13a22457
S
289
290 /* Update boundary box */
2166f0fa
SK
291 if (myCbCubicAxes)
292 myCbCubicAxes(myPtrVisual3dView);
13a22457
S
293
294 /* Disable lighting for lines */
295 GLboolean light = glIsEnabled(GL_LIGHTING);
296 if (light)
297 glDisable(GL_LIGHTING);
2166f0fa 298
13a22457 299 /* Find the farest point of bounding box */
7fd59977 300
13a22457
S
301 /* Get normal of the view out of user. */
302 /* Also, the method return distance corresponding to 1 pixel */
303 float normal[3];
304 float dpix = getNormal(normal);
2166f0fa 305
13a22457
S
306 /* Normalize normal */
307 float d = sqrtf(normal[0] * normal[0] + normal[1] * normal[1] + normal[2] * normal[2]);
308 normal[0] /= d;
309 normal[1] /= d;
310 normal[2] /= d;
311
312 /* Get central point of bounding box */
313 float center[3];
314 center[0] = 0.5f * (xmin + xmax);
315 center[1] = 0.5f * (ymin + ymax);
316 center[2] = 0.5f * (zmin + zmax);
317
318 /* Check distance to corners of bounding box along the normal */
319 float d000 = getDistance2Corner(normal, center, xmin, ymin, zmin);
320 float d100 = getDistance2Corner(normal, center, xmax, ymin, zmin);
321 float d010 = getDistance2Corner(normal, center, xmin, ymax, zmin);
322 float d001 = getDistance2Corner(normal, center, xmin, ymin, zmax);
323 float d110 = getDistance2Corner(normal, center, xmax, ymax, zmin);
324 float d101 = getDistance2Corner(normal, center, xmax, ymin, zmax);
325 float d011 = getDistance2Corner(normal, center, xmin, ymax, zmax);
326 float d111 = getDistance2Corner(normal, center, xmax, ymax, zmax);
327 unsigned char farestCorner = getFarestCorner(d000, d100, d010, d001, d110, d101, d011, d111);
328
329 /* Choose axes for the grid. */
330 float LX1[6], LX2[6], LX3[6]; /* Lines along X direction */
331 float LY1[6], LY2[6], LY3[6]; /* Lines along Y direction */
332 float LZ1[6], LZ2[6], LZ3[6]; /* Lines along Z direction */
1d47d8d0 333 unsigned char LX1draw = 0, LX2draw = 0, LX3draw = 0; /* Allows drawing of X-line (000 - 100 is forbidden) */
334 unsigned char LY1draw = 0, LY2draw = 0, LY3draw = 0; /* Allows drawing of Y-line (000 - 010 is forbidden) */
335 unsigned char LZ1draw = 0, LZ2draw = 0, LZ3draw = 0; /* Allows drawing of Z-line (000 - 001 is forbidden) */
13a22457
S
336
337 /* The first axis will be used for drawing the text and the values. */
338 switch (farestCorner)
339 {
340 case 1: /* d000 */
341 {
342 /* 001 - 101 */
343 LX1draw = 1;
344 LX1[0] = xmin; LX1[1] = ymin; LX1[2] = zmax; LX1[3] = xmax; LX1[4] = ymin; LX1[5] = zmax;
345 /* 000 - 100 */
346 LX2draw = 0; /* forbidden! */
347 LX2[0] = xmin; LX2[1] = ymin; LX2[2] = zmin; LX2[3] = xmax; LX2[4] = ymin; LX2[5] = zmin;
348 /* 010 - 110 */
349 LX3draw = 1;
350 LX3[0] = xmin; LX3[1] = ymax; LX3[2] = zmin; LX3[3] = xmax; LX3[4] = ymax; LX3[5] = zmin;
351
352 /* 100 - 110 */
353 LY1draw = 1;
354 LY1[0] = xmax; LY1[1] = ymin; LY1[2] = zmin; LY1[3] = xmax; LY1[4] = ymax; LY1[5] = zmin;
355 /* 000 - 010 */
356 LY2draw = 0; /* forbidden! */
357 LY2[0] = xmin; LY2[1] = ymin; LY2[2] = zmin; LY2[3] = xmin; LY2[4] = ymax; LY2[5] = zmin;
358 /* 001 - 011 */
359 LY3draw = 1;
360 LY3[0] = xmin; LY3[1] = ymin; LY3[2] = zmax; LY3[3] = xmin; LY3[4] = ymax; LY3[5] = zmax;
361
362 /* 100 - 101 */
363 LZ1draw = 1;
364 LZ1[0] = xmax; LZ1[1] = ymin; LZ1[2] = zmin; LZ1[3] = xmax; LZ1[4] = ymin; LZ1[5] = zmax;
365 /* 000 - 001 */
366 LZ2draw = 0; /* forbidden! */
367 LZ2[0] = xmin; LZ2[1] = ymin; LZ2[2] = zmin; LZ2[3] = xmin; LZ2[4] = ymin; LZ2[5] = zmax;
368 /* 010 - 011 */
369 LZ3draw = 1;
370 LZ3[0] = xmin; LZ3[1] = ymax; LZ3[2] = zmin; LZ3[3] = xmin; LZ3[4] = ymax; LZ3[5] = zmax;
371
372 break;
373 }
374 case 2: /* d100 */
375 {
376 /* 001 - 101 */
377 LX1draw = 1;
378 LX1[0] = xmin; LX1[1] = ymin; LX1[2] = zmax; LX1[3] = xmax; LX1[4] = ymin; LX1[5] = zmax;
379 /* 000 - 100 */
380 LX2draw = 0; /* forbidden! */
381 LX2[0] = xmin; LX2[1] = ymin; LX2[2] = zmin; LX2[3] = xmax; LX2[4] = ymin; LX2[5] = zmin;
382 /* 010 - 110 */
383 LX3draw = 1;
384 LX3[0] = xmin; LX3[1] = ymax; LX3[2] = zmin; LX3[3] = xmax; LX3[4] = ymax; LX3[5] = zmin;
385
386 /* 000 - 010 */
387 LY1draw = 0; /* forbidden! */
388 LY1[0] = xmin; LY1[1] = ymin; LY1[2] = zmin; LY1[3] = xmin; LY1[4] = ymax; LY1[5] = zmin;
389 /* 100 - 110 */
390 LY2draw = 1;
391 LY2[0] = xmax; LY2[1] = ymin; LY2[2] = zmin; LY2[3] = xmax; LY2[4] = ymax; LY2[5] = zmin;
392 /* 101 - 111 */
393 LY3draw = 1;
394 LY3[0] = xmax; LY3[1] = ymin; LY3[2] = zmax; LY3[3] = xmax; LY3[4] = ymax; LY3[5] = zmax;
395
396 /* 000 - 001 */
397 LZ1draw = 0; /* forbidden! */
398 LZ1[0] = xmin; LZ1[1] = ymin; LZ1[2] = zmin; LZ1[3] = xmin; LZ1[4] = ymin; LZ1[5] = zmax;
399 /* 100 - 101 */
400 LZ2draw = 1;
401 LZ2[0] = xmax; LZ2[1] = ymin; LZ2[2] = zmin; LZ2[3] = xmax; LZ2[4] = ymin; LZ2[5] = zmax;
402 /* 110 - 111 */
403 LZ3draw = 1;
404 LZ3[0] = xmax; LZ3[1] = ymax; LZ3[2] = zmin; LZ3[3] = xmax; LZ3[4] = ymax; LZ3[5] = zmax;
405
406 break;
407 }
408 case 3: /* d010 */
409 {
410 /* 000 - 100 */
411 LX1draw = 0; /* forbidden */
412 LX1[0] = xmin; LX1[1] = ymin; LX1[2] = zmin; LX1[3] = xmax; LX1[4] = ymin; LX1[5] = zmin;
413 /* 010 - 110 */
414 LX2draw = 1;
415 LX2[0] = xmin; LX2[1] = ymax; LX2[2] = zmin; LX2[3] = xmax; LX2[4] = ymax; LX2[5] = zmin;
416 /* 011 - 111 */
417 LX3draw = 1;
418 LX3[0] = xmin; LX3[1] = ymax; LX3[2] = zmax; LX3[3] = xmax; LX3[4] = ymax; LX3[5] = zmax;
419
420 /* 100 - 110 */
421 LY1draw = 1;
422 LY1[0] = xmax; LY1[1] = ymin; LY1[2] = zmin; LY1[3] = xmax; LY1[4] = ymax; LY1[5] = zmin;
423 /* 000 - 010 */
424 LY2draw = 0; /* forbidden */
425 LY2[0] = xmin; LY2[1] = ymin; LY2[2] = zmin; LY2[3] = xmin; LY2[4] = ymax; LY2[5] = zmin;
426 /* 001 - 011 */
427 LY3draw = 1;
428 LY3[0] = xmin; LY3[1] = ymin; LY3[2] = zmax; LY3[3] = xmin; LY3[4] = ymax; LY3[5] = zmax;
429
430 /* 110 - 111 */
431 LZ1draw = 1;
432 LZ1[0] = xmax; LZ1[1] = ymax; LZ1[2] = zmin; LZ1[3] = xmax; LZ1[4] = ymax; LZ1[5] = zmax;
433 /* 010 - 011 */
434 LZ2draw = 1;
435 LZ2[0] = xmin; LZ2[1] = ymax; LZ2[2] = zmin; LZ2[3] = xmin; LZ2[4] = ymax; LZ2[5] = zmax;
436 /* 000 - 001 */
437 LZ3draw = 0; /* forbidden */
438 LZ3[0] = xmin; LZ3[1] = ymin; LZ3[2] = zmin; LZ3[3] = xmin; LZ3[4] = ymin; LZ3[5] = zmax;
439
440 break;
441 }
442 case 4: /* d001 */
443 {
444 /* 000 - 100 */
445 LX1draw = 0; /* forbidden */
446 LX1[0] = xmin; LX1[1] = ymin; LX1[2] = zmin; LX1[3] = xmax; LX1[4] = ymin; LX1[5] = zmin;
447 /* 001 - 101 */
448 LX2draw = 1;
449 LX2[0] = xmin; LX2[1] = ymin; LX2[2] = zmax; LX2[3] = xmax; LX2[4] = ymin; LX2[5] = zmax;
450 /* 011 - 111 */
451 LX3draw = 1;
452 LX3[0] = xmin; LX3[1] = ymax; LX3[2] = zmax; LX3[3] = xmax; LX3[4] = ymax; LX3[5] = zmax;
453
454 /* 000 - 010 */
455 LY1draw = 0; /* forbidden */
456 LY1[0] = xmin; LY1[1] = ymin; LY1[2] = zmin; LY1[3] = xmin; LY1[4] = ymax; LY1[5] = zmin;
457 /* 001 - 011 */
458 LY2draw = 1;
459 LY2[0] = xmin; LY2[1] = ymin; LY2[2] = zmax; LY2[3] = xmin; LY2[4] = ymax; LY2[5] = zmax;
460 /* 101 - 111 */
461 LY3draw = 1;
462 LY3[0] = xmax; LY3[1] = ymin; LY3[2] = zmax; LY3[3] = xmax; LY3[4] = ymax; LY3[5] = zmax;
463
464 /* 100 - 101 */
465 LZ1draw = 1;
466 LZ1[0] = xmax; LZ1[1] = ymin; LZ1[2] = zmin; LZ1[3] = xmax; LZ1[4] = ymin; LZ1[5] = zmax;
467 /* 000 - 001 */
468 LZ2draw = 0; /* forbidden */
469 LZ2[0] = xmin; LZ2[1] = ymin; LZ2[2] = zmin; LZ2[3] = xmin; LZ2[4] = ymin; LZ2[5] = zmax;
470 /* 010 - 011 */
471 LZ3draw = 1;
472 LZ3[0] = xmin; LZ3[1] = ymax; LZ3[2] = zmin; LZ3[3] = xmin; LZ3[4] = ymax; LZ3[5] = zmax;
473
474 break;
475 }
476 case 5: /* d110 */
477 {
478 /* 000 - 100 */
479 LX1draw = 0; /* forbidden */
480 LX1[0] = xmin; LX1[1] = ymin; LX1[2] = zmin; LX1[3] = xmax; LX1[4] = ymin; LX1[5] = zmin;
481 /* 010 - 110 */
482 LX2draw = 1;
483 LX2[0] = xmin; LX2[1] = ymax; LX2[2] = zmin; LX2[3] = xmax; LX2[4] = ymax; LX2[5] = zmin;
484 /* 011 - 111 */
485 LX3draw = 1;
486 LX3[0] = xmin; LX3[1] = ymax; LX3[2] = zmax; LX3[3] = xmax; LX3[4] = ymax; LX3[5] = zmax;
487
488 /* 000 - 010 */
489 LY1draw = 0; /* forbidden */
490 LY1[0] = xmin; LY1[1] = ymin; LY1[2] = zmin; LY1[3] = xmin; LY1[4] = ymax; LY1[5] = zmin;
491 /* 100 - 110 */
492 LY2draw = 1;
493 LY2[0] = xmax; LY2[1] = ymin; LY2[2] = zmin; LY2[3] = xmax; LY2[4] = ymax; LY2[5] = zmin;
494 /* 101 - 111 */
495 LY3draw = 1;
496 LY3[0] = xmax; LY3[1] = ymin; LY3[2] = zmax; LY3[3] = xmax; LY3[4] = ymax; LY3[5] = zmax;
497
498 /* 100 - 101 */
499 LZ1draw = 1;
500 LZ1[0] = xmax; LZ1[1] = ymin; LZ1[2] = zmin; LZ1[3] = xmax; LZ1[4] = ymin; LZ1[5] = zmax;
501 /* 110 - 111 */
502 LZ2draw = 1;
503 LZ2[0] = xmax; LZ2[1] = ymax; LZ2[2] = zmin; LZ2[3] = xmax; LZ2[4] = ymax; LZ2[5] = zmax;
504 /* 010 - 011 */
505 LZ3draw = 1;
506 LZ3[0] = xmin; LZ3[1] = ymax; LZ3[2] = zmin; LZ3[3] = xmin; LZ3[4] = ymax; LZ3[5] = zmax;
507
508 break;
509 }
510 case 6: /* d101 */
511 {
512 /* 000 - 100 */
513 LX1draw = 0; /* forbidden */
514 LX1[0] = xmin; LX1[1] = ymin; LX1[2] = zmin; LX1[3] = xmax; LX1[4] = ymin; LX1[5] = zmin;
515 /* 001 - 101 */
516 LX2draw = 1;
517 LX2[0] = xmin; LX2[1] = ymin; LX2[2] = zmax; LX2[3] = xmax; LX2[4] = ymin; LX2[5] = zmax;
518 /* 011 - 111 */
519 LX3draw = 1;
520 LX3[0] = xmin; LX3[1] = ymax; LX3[2] = zmax; LX3[3] = xmax; LX3[4] = ymax; LX3[5] = zmax;
521
522 /* 100 - 110 */
523 LY1draw = 1;
524 LY1[0] = xmax; LY1[1] = ymin; LY1[2] = zmin; LY1[3] = xmax; LY1[4] = ymax; LY1[5] = zmin;
525 /* 101 - 111 */
526 LY2draw = 1;
527 LY2[0] = xmax; LY2[1] = ymin; LY2[2] = zmax; LY2[3] = xmax; LY2[4] = ymax; LY2[5] = zmax;
528 /* 001 - 011 */
529 LY3draw = 1;
530 LY3[0] = xmin; LY3[1] = ymin; LY3[2] = zmax; LY3[3] = xmin; LY3[4] = ymax; LY3[5] = zmax;
531
532 /* 000 - 001 */
533 LZ1draw = 0; /* forbidden */
534 LZ1[0] = xmin; LZ1[1] = ymin; LZ1[2] = zmin; LZ1[3] = xmin; LZ1[4] = ymin; LZ1[5] = zmax;
535 /* 100 - 101 */
536 LZ2draw = 1;
537 LZ2[0] = xmax; LZ2[1] = ymin; LZ2[2] = zmin; LZ2[3] = xmax; LZ2[4] = ymin; LZ2[5] = zmax;
538 /* 110 - 111 */
539 LZ3draw = 1;
540 LZ3[0] = xmax; LZ3[1] = ymax; LZ3[2] = zmin; LZ3[3] = xmax; LZ3[4] = ymax; LZ3[5] = zmax;
541
542 break;
543 }
544 case 7: /* d011 */
545 {
546 /* 001 - 101 */
547 LX1draw = 1;
548 LX1[0] = xmin; LX1[1] = ymin; LX1[2] = zmax; LX1[3] = xmax; LX1[4] = ymin; LX1[5] = zmax;
549 /* 011 - 111 */
550 LX2draw = 1;
551 LX2[0] = xmin; LX2[1] = ymax; LX2[2] = zmax; LX2[3] = xmax; LX2[4] = ymax; LX2[5] = zmax;
552 /* 010 - 110 */
553 LX3draw = 1;
554 LX3[0] = xmin; LX3[1] = ymax; LX3[2] = zmin; LX3[3] = xmax; LX3[4] = ymax; LX3[5] = zmin;
555
556 /* 000 - 010 */
557 LY1draw = 0; /* forbidden */
558 LY1[0] = xmin; LY1[1] = ymin; LY1[2] = zmin; LY1[3] = xmin; LY1[4] = ymax; LY1[5] = zmin;
559 /* 001 - 011 */
560 LY2draw = 1;
561 LY2[0] = xmin; LY2[1] = ymin; LY2[2] = zmax; LY2[3] = xmin; LY2[4] = ymax; LY2[5] = zmax;
562 /* 101 - 111 */
563 LY3draw = 1;
564 LY3[0] = xmax; LY3[1] = ymin; LY3[2] = zmax; LY3[3] = xmax; LY3[4] = ymax; LY3[5] = zmax;
565
566 /* 000 - 001 */
567 LZ1draw = 0; /* forbidden */
568 LZ1[0] = xmin; LZ1[1] = ymin; LZ1[2] = zmin; LZ1[3] = xmin; LZ1[4] = ymin; LZ1[5] = zmax;
569 /* 010 - 011 */
570 LZ2draw = 1;
571 LZ2[0] = xmin; LZ2[1] = ymax; LZ2[2] = zmin; LZ2[3] = xmin; LZ2[4] = ymax; LZ2[5] = zmax;
572 /* 110 - 111 */
573 LZ3draw = 1;
574 LZ3[0] = xmax; LZ3[1] = ymax; LZ3[2] = zmin; LZ3[3] = xmax; LZ3[4] = ymax; LZ3[5] = zmax;
575
576 break;
577 }
578 case 8: /* d111 */
579 {
580 /* 010 - 110 */
581 LX1draw = 1;
582 LX1[0] = xmin; LX1[1] = ymax; LX1[2] = zmin; LX1[3] = xmax; LX1[4] = ymax; LX1[5] = zmin;
583 /* 011 - 111 */
584 LX2draw = 1;
585 LX2[0] = xmin; LX2[1] = ymax; LX2[2] = zmax; LX2[3] = xmax; LX2[4] = ymax; LX2[5] = zmax;
586 /* 001 - 101 */
587 LX3draw = 1;
588 LX3[0] = xmin; LX3[1] = ymin; LX3[2] = zmax; LX3[3] = xmax; LX3[4] = ymin; LX3[5] = zmax;
589
590 /* 100 - 110 */
591 LY1draw = 1;
592 LY1[0] = xmax; LY1[1] = ymin; LY1[2] = zmin; LY1[3] = xmax; LY1[4] = ymax; LY1[5] = zmin;
593 /* 101 - 111 */
594 LY2draw = 1;
595 LY2[0] = xmax; LY2[1] = ymin; LY2[2] = zmax; LY2[3] = xmax; LY2[4] = ymax; LY2[5] = zmax;
596 /* 001 - 011 */
597 LY3draw = 1;
598 LY3[0] = xmin; LY3[1] = ymin; LY3[2] = zmax; LY3[3] = xmin; LY3[4] = ymax; LY3[5] = zmax;
599
600 /* 100 - 101 */
601 LZ1draw = 1;
602 LZ1[0] = xmax; LZ1[1] = ymin; LZ1[2] = zmin; LZ1[3] = xmax; LZ1[4] = ymin; LZ1[5] = zmax;
603 /* 110 - 111 */
604 LZ2draw = 1;
605 LZ2[0] = xmax; LZ2[1] = ymax; LZ2[2] = zmin; LZ2[3] = xmax; LZ2[4] = ymax; LZ2[5] = zmax;
606 /* 010 - 011 */
607 LZ3draw = 1;
608 LZ3[0] = xmin; LZ3[1] = ymax; LZ3[2] = zmin; LZ3[3] = xmin; LZ3[4] = ymax; LZ3[5] = zmax;
609
610 break;
611 }
612 }
613
a174a3c5 614 // Draw the graduated trihedron
615 unsigned int i, offset;
13a22457
S
616 float m1[3], m2[3];
617 float step, dx, dy, dz;
618
a174a3c5 619 // Grid
620 if (myToDrawGrid)
13a22457 621 {
2166f0fa 622 glColor3fv(myGridColor);
13a22457 623 glBegin(GL_LINES);
a174a3c5 624 // Boundary grid-lines
13a22457
S
625 if (LX1draw == 1)
626 {
627 glVertex3fv(&(LX1[0]));
628 glVertex3fv(&(LX1[3]));
629 }
630 if (LX2draw == 1)
631 {
632 glVertex3fv(&(LX2[0]));
633 glVertex3fv(&(LX2[3]));
634 }
635 if (LX3draw == 1)
636 {
637 glVertex3fv(&(LX3[0]));
638 glVertex3fv(&(LX3[3]));
639 }
640 if (LY1draw == 1)
641 {
642 glVertex3fv(&(LY1[0]));
643 glVertex3fv(&(LY1[3]));
644 }
645 if (LY2draw == 1)
646 {
647 glVertex3fv(&(LY2[0]));
648 glVertex3fv(&(LY2[3]));
649 }
650 if (LY3draw == 1)
651 {
652 glVertex3fv(&(LY3[0]));
653 glVertex3fv(&(LY3[3]));
654 }
655 if (LZ1draw == 1)
656 {
657 glVertex3fv(&(LZ1[0]));
658 glVertex3fv(&(LZ1[3]));
659 }
660 if (LZ2draw == 1)
661 {
662 glVertex3fv(&(LZ2[0]));
663 glVertex3fv(&(LZ2[3]));
664 }
665 if (LZ3draw == 1)
666 {
667 glVertex3fv(&(LZ3[0]));
668 glVertex3fv(&(LZ3[3]));
669 }
670 glEnd();
671
672 /* Intermediate grid-lines */
673 /* X-Grid lines */
2166f0fa 674 if (myNbX > 0)
13a22457 675 {
a174a3c5 676 i = myToDrawAxes ? 1 : 0;
2166f0fa
SK
677 step = fabsf(LX1[3] - LX1[0]) / (float) myNbX;
678 while (i < myNbX)
13a22457
S
679 {
680 glBegin(GL_LINE_STRIP);
681 glVertex3f(LX1[0] + i * step, LX1[1], LX1[2]);
682 glVertex3f(LX2[0] + i * step, LX2[1], LX2[2]);
683 glVertex3f(LX3[0] + i * step, LX3[1], LX3[2]);
684 glEnd();
685 i++;
686 }
687 }
688 /* Y-Grid lines */
2166f0fa 689 if (myNbY > 0)
13a22457 690 {
a174a3c5 691 i = myToDrawAxes ? 1 : 0;
2166f0fa
SK
692 step = fabsf(LY1[4] - LY1[1]) / (float) myNbY;
693 while (i < myNbY)
13a22457
S
694 {
695 glBegin(GL_LINE_STRIP);
696 glVertex3f(LY1[0], LY1[1] + i * step, LY1[2]);
697 glVertex3f(LY2[0], LY2[1] + i * step, LY2[2]);
698 glVertex3f(LY3[0], LY3[1] + i * step, LY3[2]);
699 glEnd();
700 i++;
701 }
702 }
703 /* Z-Grid lines */
2166f0fa 704 if (myNbZ > 0)
13a22457 705 {
a174a3c5 706 i = myToDrawAxes ? 1 : 0;
2166f0fa 707 step = fabsf(LZ1[5] - LZ1[2]) / (float) myNbZ;
a174a3c5 708
2166f0fa 709 while (i < myNbZ)
13a22457
S
710 {
711 glBegin(GL_LINE_STRIP);
712 glVertex3f(LZ1[0], LZ1[1], LZ1[2] + i * step);
713 glVertex3f(LZ2[0], LZ2[1], LZ2[2] + i * step);
714 glVertex3f(LZ3[0], LZ3[1], LZ3[2] + i * step);
715 glEnd();
716 i++;
717 }
718 }
719 }
720
a174a3c5 721 // Axes (arrows)
722 if (myToDrawAxes)
13a22457 723 {
a174a3c5 724 // X-axis
725 glColor3fv(myXColor.rgb);
13a22457
S
726 drawArrow(xmin, ymin, zmin, xmax, ymin, zmin, normal[0], normal[1], normal[2]);
727
a174a3c5 728 // Y-axis
729 glColor3fv(myYColor.rgb);
13a22457
S
730 drawArrow(xmin, ymin, zmin, xmin, ymax, zmin, normal[0], normal[1], normal[2]);
731
a174a3c5 732 // Z-axis
733 glColor3fv(myZColor.rgb);
13a22457
S
734 drawArrow(xmin, ymin, zmin, xmin, ymin, zmax, normal[0], normal[1], normal[2]);
735 }
736
a174a3c5 737 // Names of axes & values
13a22457 738 char textValue[128];
13a22457 739
a174a3c5 740 if (myToDrawXName || myToDrawXValues)
13a22457 741 {
a174a3c5 742 // Middle point of the first X-axis
13a22457
S
743 m1[0] = 0.5f * (LX1[0] + LX1[3]);
744 m1[1] = 0.5f * (LX1[1] + LX1[4]);
745 m1[2] = 0.5f * (LX1[2] + LX1[5]);
746
a174a3c5 747 // Middle point of the second X-axis
13a22457
S
748 m2[0] = 0.5f * (LX2[0] + LX2[3]);
749 m2[1] = 0.5f * (LX2[1] + LX2[4]);
750 m2[2] = 0.5f * (LX2[2] + LX2[5]);
751
a174a3c5 752 // Apply offset to m1
13a22457
S
753 dy = m1[1] - m2[1];
754 if (fabsf(dy) > 1.e-7f)
7fd59977 755 {
13a22457 756 dy = (dy > 0.0f)? 1.0f : -1.0f;
7fd59977 757 }
13a22457
S
758 dz = m1[2] - m2[2];
759 if (fabsf(dz) > 1.e-7f)
760 {
761 dz = (dz > 0.0f)? 1.0f : -1.0f;
762 }
763 m2[1] = dpix * dy;
764 m2[2] = dpix * dz;
7fd59977 765
a174a3c5 766 // Name of X-axis
767 if (myToDrawXName)
13a22457 768 {
2166f0fa 769 offset = myXAxisOffset + myXTickmarkLength;
a174a3c5 770
771 // draw axes labels
772 myAspectLabels.ChangeColor() = myXNameColor;
773 const OpenGl_AspectText* aPrevAspectText = theWorkspace->SetAspectText (&myAspectLabels);
774 myLabelX.SetPosition (OpenGl_Vec3(m1[0], m1[1] + offset * m2[1], m1[2] + offset * m2[2]));
775 myLabelX.Render (theWorkspace);
776 theWorkspace->SetAspectText (aPrevAspectText);
13a22457 777 }
7fd59977 778
a174a3c5 779 // X-values
780 if (myToDrawXValues && myNbX > 0)
7fd59977 781 {
a174a3c5 782 myAspectValues.ChangeColor() = myXColor;
783 const OpenGl_AspectText* aPrevAspectText = theWorkspace->SetAspectText (&myAspectValues);
13a22457 784
2166f0fa
SK
785 step = fabsf(LX1[3] - LX1[0]) / (float) myNbX;
786 offset = myXOffset + myXTickmarkLength;
a174a3c5 787 for (unsigned int anIter = 0; anIter <= myNbX; ++anIter)
13a22457 788 {
a174a3c5 789 sprintf (textValue, "%g", LX1[0] + anIter * step);
790 myLabelValues.Init (theWorkspace->GetGlContext(), textValue,
791 OpenGl_Vec3(LX1[0] + anIter * step, m1[1] + offset * m2[1], m1[2] + offset * m2[2]));
792 myLabelValues.Render (theWorkspace);
13a22457 793 }
a174a3c5 794 theWorkspace->SetAspectText (aPrevAspectText);
13a22457
S
795 }
796
a174a3c5 797 // X-tickmark
2166f0fa 798 if (myDrawXTickmarks && myNbX > 0)
13a22457 799 {
2166f0fa 800 glColor3fv(myGridColor);
13a22457 801
2166f0fa 802 step = fabsf(LX1[3] - LX1[0]) / (float) myNbX;
a174a3c5 803 for (unsigned int anIter = 0; anIter <= myNbX; ++anIter)
13a22457 804 {
7fd59977 805 glBegin(GL_LINES);
a174a3c5 806 glVertex3f(LX1[0] + anIter * step, m1[1], m1[2]);
807 glVertex3f(LX1[0] + anIter * step, m1[1] + myXTickmarkLength * m2[1], m1[2] + myXTickmarkLength * m2[2]);
7fd59977 808 glEnd();
13a22457
S
809 }
810 }
811 }
812
a174a3c5 813 if (myToDrawYName || myToDrawYValues)
13a22457 814 {
a174a3c5 815 // Middle point of the first Y-axis
13a22457
S
816 m1[0] = 0.5f * (LY1[0] + LY1[3]);
817 m1[1] = 0.5f * (LY1[1] + LY1[4]);
818 m1[2] = 0.5f * (LY1[2] + LY1[5]);
819
a174a3c5 820 // Middle point of the second Y-axis
13a22457
S
821 m2[0] = 0.5f * (LY2[0] + LY2[3]);
822 m2[1] = 0.5f * (LY2[1] + LY2[4]);
823 m2[2] = 0.5f * (LY2[2] + LY2[5]);
824
a174a3c5 825 // Apply offset to m1
13a22457
S
826 dx = m1[0] - m2[0];
827 if (fabsf(dx) > 1.e-7f)
828 {
829 dx = (dx > 0.0f)? 1.0f : -1.0f;
830 }
831 dz = m1[2] - m2[2];
832 if (fabsf(dz) > 1.e-7f)
833 {
834 dz = (dz > 0.0f)? 1.0f : -1.0f;
835 }
836
837 m2[0] = dpix * dx;
838 m2[2] = dpix * dz;
7fd59977 839
a174a3c5 840 // Name of Y-axis
841 if (myToDrawYName)
13a22457 842 {
2166f0fa 843 offset = myYAxisOffset + myYTickmarkLength;
a174a3c5 844
845 myAspectLabels.ChangeColor() = myYNameColor;
846 const OpenGl_AspectText* aPrevAspectText = theWorkspace->SetAspectText (&myAspectLabels);
847 myLabelY.SetPosition (OpenGl_Vec3(m1[0] + offset * m2[0], m1[1], m1[2] + offset * m2[2]));
848 myLabelY.Render (theWorkspace);
849 theWorkspace->SetAspectText (aPrevAspectText);
7fd59977 850 }
851
a174a3c5 852 // Y-values
853 if (myToDrawYValues && myNbY > 0)
7fd59977 854 {
a174a3c5 855 myAspectValues.ChangeColor() = myYColor;
856 const OpenGl_AspectText* aPrevAspectText = theWorkspace->SetAspectText (&myAspectValues);
13a22457 857
2166f0fa
SK
858 step = fabsf(LY1[4] - LY1[1]) / (float) myNbY;
859 offset = myYOffset + myYTickmarkLength;
a174a3c5 860 for (unsigned int anIter = 0; anIter <= myNbY; ++anIter)
13a22457 861 {
a174a3c5 862 sprintf (textValue, "%g", LY1[1] + anIter * step);
863 myLabelValues.Init (theWorkspace->GetGlContext(), textValue,
864 OpenGl_Vec3(m1[0] + offset * m2[0], LY1[1] + anIter * step, m1[2] + offset * m2[2]));
865 myLabelValues.Render (theWorkspace);
13a22457 866 }
a174a3c5 867 theWorkspace->SetAspectText (aPrevAspectText);
7fd59977 868 }
7fd59977 869
a174a3c5 870 // Y-tickmark
2166f0fa 871 if (myDrawYTickmarks && myNbY > 0)
13a22457 872 {
2166f0fa 873 glColor3fv(myGridColor);
13a22457
S
874
875 i = 0;
2166f0fa
SK
876 step = fabsf(LY1[4] - LY1[1]) / (float) myNbY;
877 while (i <= myNbY)
13a22457
S
878 {
879 glBegin(GL_LINES);
2166f0fa
SK
880 glVertex3f(m1[0], LY1[1] + i * step, m1[2]);
881 glVertex3f(m1[0] + myYTickmarkLength * m2[0], LY1[1] + i * step, m1[2] + myYTickmarkLength * m2[2]);
13a22457
S
882 glEnd();
883 i++;
884 }
885 }
886 }
887
a174a3c5 888 if (myToDrawZName || myToDrawZValues)
13a22457 889 {
a174a3c5 890 // Middle point of the first Z-axis
13a22457
S
891 m1[0] = 0.5f * (LZ1[0] + LZ1[3]);
892 m1[1] = 0.5f * (LZ1[1] + LZ1[4]);
893 m1[2] = 0.5f * (LZ1[2] + LZ1[5]);
894
a174a3c5 895 // Middle point of the second Z-axis
13a22457
S
896 m2[0] = 0.5f * (LZ2[0] + LZ2[3]);
897 m2[1] = 0.5f * (LZ2[1] + LZ2[4]);
898 m2[2] = 0.5f * (LZ2[2] + LZ2[5]);
899
a174a3c5 900 // Apply offset to m1
13a22457
S
901 dx = m1[0] - m2[0];
902 if (fabsf(dx) > 1.e-7f)
903 {
904 dx = (dx > 0.0f)? 1.0f : -1.0f;
905 }
906 dy = m1[1] - m2[1];
907 if (fabsf(dy) > 1.e-7f)
7fd59977 908 {
13a22457 909 dy = (dy > 0.0f)? 1.0f : -1.0f;
7fd59977 910 }
911
13a22457
S
912 m2[0] = dpix * dx;
913 m2[1] = dpix * dy;
914
a174a3c5 915 // Name of Z-axis
916 if (myToDrawZName)
7fd59977 917 {
2166f0fa 918 offset = myZAxisOffset + myZTickmarkLength;
a174a3c5 919
920 myAspectLabels.ChangeColor() = myZNameColor;
921 const OpenGl_AspectText* aPrevAspectText = theWorkspace->SetAspectText (&myAspectLabels);
922 myLabelZ.SetPosition (OpenGl_Vec3(m1[0] + offset * m2[0], m1[1] + offset * m2[1], m1[2]));
923 myLabelZ.Render (theWorkspace);
924 theWorkspace->SetAspectText (aPrevAspectText);
7fd59977 925 }
926
a174a3c5 927 // Z-values
928 if (myToDrawZValues && myNbZ > 0)
7fd59977 929 {
a174a3c5 930 myAspectValues.ChangeColor() = myZColor;
931 const OpenGl_AspectText* aPrevAspectText = theWorkspace->SetAspectText (&myAspectValues);
13a22457 932
2166f0fa
SK
933 step = fabsf(LZ1[5] - LZ1[2]) / (float) myNbZ;
934 offset = myZOffset + myZTickmarkLength;
a174a3c5 935 for (unsigned int anIter = 0; anIter <= myNbZ; ++anIter)
13a22457 936 {
a174a3c5 937 sprintf (textValue, "%g", LZ1[2] + anIter * step);
938 myLabelValues.Init (theWorkspace->GetGlContext(), textValue,
939 OpenGl_Vec3(m1[0] + offset * m2[0], m1[1] + offset * m2[1], LZ1[2] + anIter * step));
940 myLabelValues.Render (theWorkspace);
13a22457 941 }
a174a3c5 942 theWorkspace->SetAspectText (aPrevAspectText);
7fd59977 943 }
944
a174a3c5 945 // Z-tickmark
2166f0fa 946 if (myDrawZTickmarks && myNbZ > 0)
13a22457 947 {
2166f0fa 948 glColor3fv(myGridColor);
13a22457
S
949
950 i = 0;
2166f0fa
SK
951 step = fabsf(LZ1[5] - LZ1[2]) / (float) myNbZ;
952 while (i <= myNbZ)
13a22457
S
953 {
954 glBegin(GL_LINES);
2166f0fa
SK
955 glVertex3f(m1[0], m1[1], LZ1[2] + i * step);
956 glVertex3f(m1[0] + myZTickmarkLength * m2[0], m1[1] + myZTickmarkLength * m2[1], LZ1[2] + i * step);
13a22457
S
957 glEnd();
958 i++;
959 }
960 }
961 }
962
a174a3c5 963 // Activate the lighting if it was turned off by this method call
13a22457
S
964 if (light)
965 glEnable(GL_LIGHTING);
2166f0fa 966
a174a3c5 967 theWorkspace->SetAspectLine(oldAspectLine);
ca3c13d1 968#endif
7fd59977 969}
970
2166f0fa
SK
971//call_graduatedtrihedron_minmaxvalues
972void OpenGl_GraduatedTrihedron::SetMinMax (const Standard_ShortReal xMin, const Standard_ShortReal yMin, const Standard_ShortReal zMin,
973 const Standard_ShortReal xMax, const Standard_ShortReal yMax, const Standard_ShortReal zMax)
7fd59977 974{
2166f0fa
SK
975 xmin = xMin;
976 ymin = yMin;
977 zmin = zMin;
978 xmax = xMax;
979 ymax = yMax;
980 zmax = zMax;
13a22457 981}