17 #define SQU(a) ((a) * (a))
20 std::string &label,
double p1[3],
double p2[3],
21 double perp[3],
int mikado,
double pixelfact,
22 double value_p1[3],
double value_p2[3])
26 double t[3] = {p2[0] - p1[0], p2[1] - p1[1], p2[2] - p1[2]};
28 double value_t[3] = {value_p2[0] - value_p1[0], value_p2[1] - value_p1[1],
29 value_p2[2] - value_p1[2]};
30 double value_l =
norme(value_t);
31 double w = 10 * pixelfact;
35 ctx->
drawString(label, p2[0] + t[0] * w2, p2[1] + t[1] * w2,
40 if(format.empty())
return n;
43 double lp =
norme(perp);
46 case 0: perp[1] = -1.;
break;
47 case 1: perp[0] = -1.;
break;
48 case 2: perp[0] = 1.;
break;
57 sprintf(tmp, format.c_str(), -M_PI * 1.e4);
58 double win1[3], win2[3];
61 double winl = sqrt(
SQU(win2[0] - win1[0]) +
SQU(win2[1] - win1[1]));
63 if((n - 1) * strl > winl) n = (int)(winl / strl) + 1;
72 double step = l / (double)(n - 1);
73 double value_step = value_l / (double)(n - 1);
75 for(
int i = 0; i < n; i++) {
77 double p[3] = {p1[0] + t[0] * d, p1[1] + t[1] * d, p1[2] + t[2] * d};
78 double q[3] = {p[0] + perp[0] * w, p[1] + perp[1] * w, p[2] + perp[2] * w};
79 double r[3] = {p[0] + perp[0] * w2, p[1] + perp[1] * w2,
82 double value_d = i * value_step;
83 double value_p[3] = {value_p1[0] + value_t[0] * value_d,
84 value_p1[1] + value_t[1] * value_d,
85 value_p1[2] + value_t[2] * value_d};
88 glVertex3d(p[0], p[1], p[2]);
89 glVertex3d(q[0], q[1], q[2]);
94 sprintf(tmp, format.c_str(), value_d);
96 sprintf(tmp, format.c_str(), value_p[comp]);
97 double winp[3], winr[3];
100 if(fabs(winr[0] - winp[0]) < 2.)
102 else if(winr[0] < winp[0])
104 if(fabs(winr[1] - winp[1]) < 2.)
106 else if(winr[1] < winp[1])
118 double t1[3] = {p2[0] - p1[0], p2[1] - p1[1], p2[2] - p1[2]};
119 double t2[3] = {p3[0] - p1[0], p3[1] - p1[1], p3[2] - p1[2]};
120 double l1 =
norme(t1);
121 double l2 =
norme(t2);
123 glEnable(GL_LINE_STIPPLE);
124 glLineStipple(1, 0x1111);
128 for(
int i = 1; i < n1 - 1; i++) {
129 double d = (double)i / (
double)(n1 - 1) * l1;
130 glVertex3d(p1[0] + t1[0] * d, p1[1] + t1[1] * d, p1[2] + t1[2] * d);
131 glVertex3d(p1[0] + t1[0] * d + t2[0] * l2, p1[1] + t1[1] * d + t2[1] * l2,
132 p1[2] + t1[2] * d + t2[2] * l2);
134 for(
int i = 1; i < n2 - 1; i++) {
135 double d = (double)i / (
double)(n2 - 1) * l2;
136 glVertex3d(p1[0] + t2[0] * d, p1[1] + t2[1] * d, p1[2] + t2[2] * d);
137 glVertex3d(p1[0] + t2[0] * d + t1[0] * l1, p1[1] + t2[1] * d + t1[1] * l1,
138 p1[2] + t2[2] * d + t1[2] * l1);
142 glDisable(GL_LINE_STIPPLE);
147 double ymax,
double zmax,
int ntics,
int mikado)
150 ntics = (ntics - 1) * mikado;
151 if(ntics < 1) ntics = 1;
152 double dd[3] = {(xmax - xmin) / ntics, (ymax - ymin) / ntics,
153 (zmax - zmin) / ntics};
155 glGetDoublev(GL_CURRENT_COLOR, axe_color);
156 for(
int i = 1; i <= ntics; i++) {
158 glColor4dv(axe_color);
161 double cx[2] = {xmin + (i - 1) * dd[0], xmin + i * dd[0]};
162 double cy[2] = {ymin + (i - 1) * dd[1], ymin + i * dd[1]};
163 double cz[2] = {zmin + (i - 1) * dd[2], zmin + i * dd[2]};
166 glColor4dv(axe_color);
170 glVertex3d(xmin, ymin, zmin);
171 glVertex3d(xmax, ymax, zmax);
177 std::string label[3],
double bb[6],
int mikado,
187 if((mode < 1) || (bb[0] == bb[1] && bb[2] == bb[3] && bb[4] == bb[5]))
return;
189 double xmin = bb[0], xmax = bb[1];
190 double ymin = bb[2], ymax = bb[3];
191 double zmin = bb[4], zmax = bb[5];
192 double orig[3] = {xmin, ymin, zmin};
194 double value_xmin = value_bb[0], value_xmax = value_bb[1];
195 double value_ymin = value_bb[2], value_ymax = value_bb[3];
196 double value_zmin = value_bb[4], value_zmax = value_bb[5];
197 double value_orig[3] = {value_xmin, value_ymin, value_zmin};
202 double end[3] = {xmax, ymax, zmax};
203 double dir[3] = {xmax - xmin, ymax - ymin, zmax - zmin};
205 if((fabs(dir[0]) >= fabs(dir[1]) && fabs(dir[0]) >= fabs(dir[2])) ||
206 (fabs(dir[1]) >= fabs(dir[0]) && fabs(dir[1]) >= fabs(dir[2]))) {
216 double value_end[3] = {value_xmax, value_ymax, value_zmax};
217 drawTics(
this, -1, tics[0], format[0], label[0], orig, end, perp, mikado,
218 pixelfact, value_orig, value_end);
219 drawAxis(xmin, ymin, zmin, xmax, ymax, zmax, tics[0], mikado);
222 double xx[3] = {xmax, ymin, zmin};
223 double yy[3] = {xmin, ymax, zmin};
224 double zz[3] = {xmin, ymin, zmax};
225 double value_xx[3] = {value_xmax, value_ymin, value_zmin};
226 double value_yy[3] = {value_xmin, value_ymax, value_zmin};
227 double value_zz[3] = {value_xmin, value_ymin, value_zmax};
228 double dxm[3] = {0., (ymin != ymax) ? -1. : 0., (zmin != zmax) ? -1. : 0.};
229 double dym[3] = {(xmin != xmax) ? -1. : 0., 0., (zmin != zmax) ? -1. : 0.};
230 double dzm[3] = {(xmin != xmax) ? -1. : 0., (ymin != ymax) ? -1. : 0., 0.};
232 int nx = (xmin != xmax) ?
233 drawTics(
this, 0, tics[0], format[0], label[0], orig, xx, dxm,
234 mikado, pixelfact, value_orig, value_xx) :
236 int ny = (ymin != ymax) ?
237 drawTics(
this, 1, tics[1], format[1], label[1], orig, yy, dym,
238 mikado, pixelfact, value_orig, value_yy) :
240 int nz = (zmin != zmax) ?
241 drawTics(
this, 2, tics[2], format[2], label[2], orig, zz, dzm,
242 mikado, pixelfact, value_orig, value_zz) :
245 drawAxis(xmin, ymin, zmin, xmax, ymin, zmin, nx, mikado);
246 drawAxis(xmin, ymin, zmin, xmin, ymax, zmin, ny, mikado);
247 drawAxis(xmin, ymin, zmin, xmin, ymin, zmax, nz, mikado);
251 drawAxis(xmin, ymax, zmin, xmax, ymax, zmin, nx, mikado);
252 drawAxis(xmax, ymin, zmin, xmax, ymax, zmin, ny, mikado);
253 drawAxis(xmax, ymin, zmin, xmax, ymin, zmax, nz, mikado);
254 drawAxis(xmin, ymin, zmax, xmax, ymin, zmax, nx, mikado);
255 drawAxis(xmin, ymin, zmax, xmin, ymax, zmax, ny, mikado);
256 drawAxis(xmin, ymax, zmin, xmin, ymax, zmax, nz, mikado);
260 if(mode == 2 || mode == 3) {
261 drawAxis(xmin, ymax, zmax, xmax, ymax, zmax, nx, mikado);
262 drawAxis(xmax, ymin, zmax, xmax, ymax, zmax, ny, mikado);
263 drawAxis(xmax, ymax, zmin, xmax, ymax, zmax, nz, mikado);
273 double orig2[3] = {xmax, ymax, zmax};
274 double xy[3] = {xmax, ymax, zmin};
275 double yz[3] = {xmin, ymax, zmax};
276 double xz[3] = {xmax, ymin, zmax};
287 double bbox[6] = {bb.
min().
x(), bb.
max().
x(), bb.
min().
y(),
289 double value_bbox[6] = {value_bb.
min().
x(), value_bb.
max().
x(),
290 value_bb.
min().
y(), value_bb.
max().
y(),
291 value_bb.
min().
z(), value_bb.
max().
z()};
292 drawAxes(mode, tics, format, label, bbox, mikado, value_bbox);
297 bool geometryExists =
false;
300 geometryExists =
true;
314 glColor3d(1., 0., 0.);
315 for(
int j = 0; j < 6; j++)
373 double xx, xy, yx, yy, zx, zy;
376 glMatrixMode(GL_MODELVIEW);
383 float fvViewMatrix[16];
384 glGetFloatv(GL_MODELVIEW_MATRIX, fvViewMatrix);
386 xx = l * fvViewMatrix[0];
387 xy = l * fvViewMatrix[1];
388 yx = l * fvViewMatrix[4];
389 yy = l * fvViewMatrix[5];
390 zx = l * fvViewMatrix[8];
391 zy = l * fvViewMatrix[9];
411 glVertex2d(cx + xx, cy + xy);
413 glVertex2d(cx + yx, cy + yy);
415 glVertex2d(cx + zx, cy + zy);
417 drawString(
"X", cx + xx + o, cy + xy + o, 0.);
418 drawString(
"Y", cx + yx + o, cy + yy + o, 0.);
419 drawString(
"Z", cx + zx + o, cy + zy + o, 0.);