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