18 (*x > 99999 && *y > 99999) ? 3 : (*y > 99999) ? 2 : (*x > 99999) ? 1 : 0;
36 for(std::size_t i = 0; i <
PView::list.size(); i++) {
61 double &xmax, std::vector<std::vector<double> > &y,
62 double &ymin,
double &ymax)
87 if(!numy)
return false;
98 if(fabs(max.
y() - min.
y()) > fabs(max.
x() - min.
x()) &&
99 fabs(max.
y() - min.
y()) > fabs(max.
z() - min.
z()))
101 else if(fabs(max.
z() - min.
z()) > fabs(max.
x() - min.
x()) &&
102 fabs(max.
z() - min.
z()) > fabs(max.
y() - min.
y()))
117 std::vector<int> reorder(numNodes);
119 for(
int j = 0; j < numNodes; j++) reorder[j] = j;
123 reorder[numNodes - 1] = 1;
124 for(
int j = 1; j < numNodes - 1; j++) reorder[j] = 1 + j;
126 for(
int ts = space ? opt->
timeStep : 0; ts < opt->timeStep + 1; ts++) {
129 for(
int j = 0; j < numNodes; j++) {
130 double val[9], xyz[3];
131 data->
getNode(ts, ent, ele, reorder[j], xyz[0], xyz[1], xyz[2]);
132 for(
int k = 0; k < numComp; k++)
133 data->
getValue(ts, ent, ele, reorder[j], k, val[k]);
137 x.push_back(xyz[which2d]);
143 p0 =
SPoint3(xyz[0], xyz[1], xyz[2]);
147 SPoint3 p1(xyz[0], xyz[1], xyz[2]);
148 x.push_back(x.back() + p0.
distance(p1));
154 if(!numy) x.push_back(data->
getTime(ts));
155 y[numy].push_back(vy);
163 if(x.empty())
return false;
166 std::vector<double> x2;
167 std::vector<std::vector<double> > y2(y.size());
168 for(std::size_t i = 0; i < x.size(); i++) {
171 for(std::size_t j = 0; j < y2.size(); j++) y2[j].push_back(y[j][i]);
180 for(std::size_t i = 1; i < x.size(); i++) {
181 xmin = std::min(xmin, x[i]);
182 xmax = std::max(xmax, x[i]);
191 for(std::size_t i = 0; i < y.size(); i++)
192 for(std::size_t j = 0; j < y[i].size(); j++) y[i][j] = log10(y[i][j]);
196 for(std::size_t i = 0; i < y.size(); i++) {
197 for(std::size_t j = 0; j < y[i].size(); j++) {
198 ymin = std::min(ymin, y[i][j]);
199 ymax = std::max(ymax, y[i][j]);
207 double width,
double height,
double xmin,
double xmax,
208 double tic,
int overlay,
bool inModelCoordinates)
213 if(!opt->
axes)
return;
215 if(overlay > 2)
return;
217 if(width <= 0 || height <= 0)
return;
219 if(!overlay && !inModelCoordinates) {
222 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
226 glVertex2d(xleft, ytop);
227 glVertex2d(xleft + width, ytop);
228 glVertex2d(xleft + width, ytop - height);
229 glVertex2d(xleft, ytop - height);
242 if(inModelCoordinates) {
250 glPointSize((
float)ps);
258 glColor4ubv((GLubyte *)&opt->
color.
axes);
262 glBegin(GL_LINE_STRIP);
263 glVertex2d(xleft, ytop);
264 glVertex2d(xleft, ytop - height);
265 glVertex2d(xleft + width, ytop - height);
267 glVertex2d(xleft + width, ytop);
268 glVertex2d(xleft, ytop);
274 std::string label = data->
getName();
281 label += std::string(
" (") + tmp +
")";
286 label += std::string(
" (") + tmp +
")";
290 ctx->
drawString(label, xleft + (overlay ? width : 0), ytop + font_h + tic, 0,
298 label, xleft + width / 2,
299 ytop - height - 2 * font_h - 2 * tic - overlay * (font_h + tic), 0,
307 nb = (int)floor(height / font_h);
308 double dy = height / (double)nb;
310 for(
int i = 0; i < nb + 1; i++) {
312 glVertex2d(xleft, ytop - i * dy);
313 glVertex2d(xleft + tic, ytop - i * dy);
315 glVertex2d(xleft + width - tic, ytop - i * dy);
316 glVertex2d(xleft + width, ytop - i * dy);
319 if(opt->
axes > 2 && i != 0 && i != nb) {
320 glEnable(GL_LINE_STIPPLE);
321 glLineStipple(1, 0x1111);
325 glVertex2d(xleft, ytop - i * dy);
326 glVertex2d(xleft + width, ytop - i * dy);
328 glDisable(GL_LINE_STIPPLE);
335 sprintf(tmp, opt->
format.c_str(),
339 ytop - i * dy - font_a / 3., 0.);
343 ytop - i * dy - font_a / 3., 0.);
353 sprintf(tmp, opt->
axesFormat[0].c_str(), -M_PI * 1.e4);
356 if((nb - 1) * ww > width) nb = (int)(width / ww) + 1;
359 double dx = width / (double)(nb - 1);
360 double ybot = ytop - height;
362 for(
int i = 0; i < nb; i++) {
364 glVertex2d(xleft + i * dx, ybot);
365 glVertex2d(xleft + i * dx, ybot + tic);
367 glVertex2d(xleft + i * dx, ytop);
368 glVertex2d(xleft + i * dx, ytop - tic);
371 if(opt->
axes > 2 && i != 0 && i != nb - 1) {
372 glEnable(GL_LINE_STIPPLE);
373 glLineStipple(1, 0x1111);
377 glVertex2d(xleft + i * dx, ytop);
378 glVertex2d(xleft + i * dx, ybot);
380 glDisable(GL_LINE_STIPPLE);
388 sprintf(tmp, opt->
axesFormat[0].c_str(), xmin);
391 xmin + i * (xmax - xmin) / (
double)(nb - 1));
393 ybot - font_h - tic - overlay * (font_h + tic),
400 static std::map<SPoint2, unsigned int>
tags;
405 auto it =
tags.find(p);
406 if(it !=
tags.end())
return it->second;
416 double width,
double height,
double x,
double y,
417 double xmin,
double xmax,
double ymin,
double ymax,
418 bool numeric,
bool singlePoint,
419 bool inModelCoordinates)
424 if(xmin != xmax) px += (x - xmin) / (xmax - xmin) * width;
433 double ybot = ytop - height;
435 if(ymax != ymin) py += (y - ymin) / (ymax - ymin) * height;
437 if(y >= ymin && y <= ymax) {
438 unsigned int col = opt->
getColor(y, ymin, ymax,
true);
439 glColor4ubv((GLubyte *)&col);
450 sprintf(label, opt->
format.c_str(), y);
451 ctx->
drawString(label, px + offset, py + offset, 0.);
455 if(inModelCoordinates)
461 if(singlePoint) glBegin(GL_POINTS);
463 if(singlePoint) glEnd();
474 double ytop,
double width,
double height,
475 std::vector<double> &x,
double xmin,
double xmax,
476 std::vector<std::vector<double> > &y,
477 bool inModelCoordinates)
479 if(width <= 0 || height <= 0)
return;
485 glPointSize((
float)ps);
495 for(std::size_t i = 0; i < y.size(); i++) {
497 glEnable(GL_LINE_STIPPLE);
501 glBegin(GL_LINE_STRIP);
502 for(std::size_t j = 0; j < x.size(); j++)
503 addGraphPoint(ctx, p, xleft, ytop, width, height, x[j], y[i][j], xmin,
508 glDisable(GL_LINE_STIPPLE);
517 for(std::size_t i = 0; i < y.size(); i++)
518 for(std::size_t j = 0; j < x.size(); j++)
519 addGraphPoint(ctx, p, xleft, ytop, width, height, x[j], y[i][j], xmin,
525 for(std::size_t i = 0; i < y.size(); i++)
526 for(std::size_t j = 0; j < x.size(); j++)
527 addGraphPoint(ctx, p, xleft, ytop, width, height, x[j], y[i][j], xmin,
534 double width,
double height,
double tic,
int overlay = 0,
535 bool inModelCoordinates =
false)
537 std::vector<double> x;
538 std::vector<std::vector<double> > y;
539 double xmin, xmax, ymin, ymax;
540 if(!
getGraphData(p, x, xmin, xmax, y, ymin, ymax))
return;
568 drawGraphAxes(ctx, p, xleft, ytop, width, height, xmin, xmax, tic, overlay,
570 drawGraphCurves(ctx, p, xleft, ytop, width, height, x, xmin, xmax, y,
576 std::vector<PView *> graphs;
577 for(std::size_t i = 0; i <
PView::list.size(); i++) {
584 if(graphs.empty())
return;
589 double mx = 25, my = 5;
592 for(std::size_t i = 0; i < graphs.size(); i++) {
594 sprintf(label, opt->
format.c_str(), -M_PI * 1.e4);
599 if(inModelCoordinates) {
624 int overlay[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
627 for(std::size_t i = 0; i < graphs.size(); i++) {
629 double y =
viewport[1] + my + 3 * ysep;
630 PView *p = graphs[i];
636 y + (center & 2 ? opt->
size[1] / 2. : 0), opt->
size[0],
639 else if(opt->
autoPosition == 1 && !inModelCoordinates) {
640 if(graphs.size() == 1) {
641 double w = winw - 2 * mx - 2 * xsep;
642 double h = winh - 2 * my - 7 * ysep;
645 else if(graphs.size() == 2) {
646 double w = winw - 2 * mx - 2 * xsep;
647 double h = (winh - 3 * my - 12 * ysep) / 2.;
648 if(i == 1) y += (h + my + 5 * ysep);
652 double w = (winw - 3 * mx - 4 * xsep) / 2.;
653 double h = (winh - 3 * my - 12 * ysep) / 2.;
654 if(i == 1 || i == 3) x += (w + mx + 2 * xsep);
655 if(i == 2 || i == 3) y += (h + 5 * ysep);
660 !inModelCoordinates) {
666 if(a <= 5 || a == 8 || a == 9)
667 w = (winw - 3 * mx - 4 * xsep) / 2.;
669 w = winw - 2 * mx - 2 * xsep;
670 if(a <= 5 || a == 6 || a == 7)
671 h = (winh - 3 * my - 12 * ysep) / 2.;
673 h = (winh - 3 * my - 12 * ysep) / 3.;
675 h = winh - 2 * my - 7 * ysep;
676 if(a == 3 || a == 5 || a == 9) x += (w + mx + 2 * xsep);
677 if(a == 4 || a == 5 || a == 7) y += (h + my + 5 * ysep);
684 inModelCoordinates) {
686 opt->
size[0], opt->
size[1], tic, 0,
true);