Skip to content
Snippets Groups Projects
Commit 59b40e99 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

enable 3D points in 2D graphs

parent a247bf82
No related branches found
No related tags found
No related merge requests found
...@@ -265,7 +265,8 @@ void drawContext::draw2d() ...@@ -265,7 +265,8 @@ void drawContext::draw2d()
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); glLoadIdentity();
glOrtho((double)viewport[0], (double)viewport[2], glOrtho((double)viewport[0], (double)viewport[2],
(double)viewport[1], (double)viewport[3], -1., 1.); (double)viewport[1], (double)viewport[3],
-100., 100.); // in pixels, so we can draw some 3D glyphs
// hack to make the 2D primitives appear "in front" in GL2PS // hack to make the 2D primitives appear "in front" in GL2PS
glTranslated(0., 0., CTX::instance()->clipFactor > 1. ? glTranslated(0., 0., CTX::instance()->clipFactor > 1. ?
......
...@@ -310,7 +310,7 @@ static void drawGraphAxes(drawContext *ctx, PView *p, double xleft, double ytop, ...@@ -310,7 +310,7 @@ static void drawGraphAxes(drawContext *ctx, PView *p, double xleft, double ytop,
static void addGraphPoint(drawContext *ctx, PView *p, double xleft, double ytop, static void addGraphPoint(drawContext *ctx, PView *p, double xleft, double ytop,
double width, double height, double x, double y, double width, double height, double x, double y,
double xmin, double xmax, double ymin, double ymax, double xmin, double xmax, double ymin, double ymax,
bool numeric) bool numeric, bool sphere)
{ {
PViewOptions *opt = p->getOptions(); PViewOptions *opt = p->getOptions();
...@@ -337,6 +337,8 @@ static void addGraphPoint(drawContext *ctx, PView *p, double xleft, double ytop, ...@@ -337,6 +337,8 @@ static void addGraphPoint(drawContext *ctx, PView *p, double xleft, double ytop,
sprintf(label, opt->format.c_str(), y); sprintf(label, opt->format.c_str(), y);
ctx->drawString(label); ctx->drawString(label);
} }
else if(sphere)
ctx->drawSphere(opt->pointSize, px, py, 0, 10, 10, opt->light);
else else
glVertex2d(px, py); glVertex2d(px, py);
} }
...@@ -355,24 +357,6 @@ static void drawGraphCurves(drawContext *ctx, PView *p, double xleft, double yto ...@@ -355,24 +357,6 @@ static void drawGraphCurves(drawContext *ctx, PView *p, double xleft, double yto
glLineWidth((float)opt->lineWidth); glLineWidth((float)opt->lineWidth);
gl2psLineWidth((float)(opt->lineWidth * CTX::instance()->print.epsLineWidthFactor)); gl2psLineWidth((float)(opt->lineWidth * CTX::instance()->print.epsLineWidthFactor));
if(opt->intervalsType == PViewOptions::Numeric){
for(unsigned int i = 0; i < y.size(); i++)
for(unsigned int j = 0; j < x.size(); j++)
addGraphPoint(ctx, p, xleft, ytop, width, height, x[j], y[i][j],
xmin, xmax, opt->tmpMin, opt->tmpMax, true);
}
if(opt->intervalsType == PViewOptions::Iso ||
opt->intervalsType == PViewOptions::Discrete ||
opt->intervalsType == PViewOptions::Numeric){
glBegin(GL_POINTS);
for(unsigned int i = 0; i < y.size(); i++)
for(unsigned int j = 0; j < x.size(); j++)
addGraphPoint(ctx, p, xleft, ytop, width, height, x[j], y[i][j],
xmin, xmax, opt->tmpMin, opt->tmpMax, false);
glEnd();
}
if(opt->intervalsType == PViewOptions::Discrete || if(opt->intervalsType == PViewOptions::Discrete ||
opt->intervalsType == PViewOptions::Continuous){ opt->intervalsType == PViewOptions::Continuous){
for(unsigned int i = 0; i < y.size(); i++){ for(unsigned int i = 0; i < y.size(); i++){
...@@ -384,7 +368,7 @@ static void drawGraphCurves(drawContext *ctx, PView *p, double xleft, double yto ...@@ -384,7 +368,7 @@ static void drawGraphCurves(drawContext *ctx, PView *p, double xleft, double yto
glBegin(GL_LINE_STRIP); glBegin(GL_LINE_STRIP);
for(unsigned int j = 0; j < x.size(); j++) for(unsigned int j = 0; j < x.size(); j++)
addGraphPoint(ctx, p, xleft, ytop, width, height, x[j], y[i][j], addGraphPoint(ctx, p, xleft, ytop, width, height, x[j], y[i][j],
xmin, xmax, opt->tmpMin, opt->tmpMax, false); xmin, xmax, opt->tmpMin, opt->tmpMax, false, false);
glEnd(); glEnd();
if(opt->useStipple){ if(opt->useStipple){
glDisable(GL_LINE_STIPPLE); glDisable(GL_LINE_STIPPLE);
...@@ -392,6 +376,25 @@ static void drawGraphCurves(drawContext *ctx, PView *p, double xleft, double yto ...@@ -392,6 +376,25 @@ static void drawGraphCurves(drawContext *ctx, PView *p, double xleft, double yto
} }
} }
} }
if(opt->intervalsType == PViewOptions::Iso ||
opt->intervalsType == PViewOptions::Discrete ||
opt->intervalsType == PViewOptions::Numeric){
bool sphere = (opt->pointType == 1 || opt->pointType == 3);
if(!sphere) glBegin(GL_POINTS);
for(unsigned int i = 0; i < y.size(); i++)
for(unsigned int j = 0; j < x.size(); j++)
addGraphPoint(ctx, p, xleft, ytop, width, height, x[j], y[i][j],
xmin, xmax, opt->tmpMin, opt->tmpMax, false, sphere);
if(!sphere) glEnd();
}
if(opt->intervalsType == PViewOptions::Numeric){
for(unsigned int i = 0; i < y.size(); i++)
for(unsigned int j = 0; j < x.size(); j++)
addGraphPoint(ctx, p, xleft, ytop, width, height, x[j], y[i][j],
xmin, xmax, opt->tmpMin, opt->tmpMax, true, false);
}
} }
static void drawGraph(drawContext *ctx, PView *p, double xleft, double ytop, static void drawGraph(drawContext *ctx, PView *p, double xleft, double ytop,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment