summaryrefslogtreecommitdiff
path: root/2004/i/nono/src/ovision/adjust.cc
diff options
context:
space:
mode:
Diffstat (limited to '2004/i/nono/src/ovision/adjust.cc')
-rw-r--r--2004/i/nono/src/ovision/adjust.cc53
1 files changed, 44 insertions, 9 deletions
diff --git a/2004/i/nono/src/ovision/adjust.cc b/2004/i/nono/src/ovision/adjust.cc
index 682a8d9..f4b7b06 100644
--- a/2004/i/nono/src/ovision/adjust.cc
+++ b/2004/i/nono/src/ovision/adjust.cc
@@ -15,6 +15,13 @@ using namespace std;
int window;
Comm *comm;
int point[3][2] = {{-1,-1},{-1,-1},{-1,-1}};
+int width=538; int height=395;
+
+int* GetPpoint()
+{
+ return (int*)point;
+}
+
/// Sortie du programme
void
@@ -122,25 +129,31 @@ InitGL(int width, int height)
// Plan de projection en 2D
glOrtho(0.0, WIDTH, 0.0, HEIGHT, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
+
+ glPointSize(4.0f);
}
/// Redimenssionement d'une fenetre
void
-ReSizeGLScene(int width, int height)
+ReSizeGLScene(int w, int h)
{
// Evite div par 0
- if (height==0) height=1;
+ if (height==0) h=1;
+
+ height = h;
+ width = w;
// Initialise le point de vue
- glViewport(0, 0, width, height);
+ glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
// Remise a zero et mode 2D
glLoadIdentity();
glOrtho(0.0, WIDTH, 0.0, HEIGHT, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
+
}
@@ -187,14 +200,19 @@ DrawGLScene()
for (int i=0; i<NBIMG; i++)
DrawImage(i);
+
+
+ glColor3ub(0,0,255);
+ glDisable(GL_TEXTURE_2D);
// Dessine points de calibration de la distance
for (int i=0; i<3; i++)
{
if (point[i][0] >= 0)
glBegin(GL_POINTS);
- glVertex3f(point[i][0], point[i][1], -0.7f);
+ glVertex3f(point[i][0], point[i][1], -0.9f);
glEnd();
}
+ glEnable(GL_TEXTURE_2D);
glFlush();
@@ -222,33 +240,49 @@ MouseFunc(int button, int state, int x, int y)
{
if (state == GLUT_UP)
{
- if ((x < 352+BORDER) && (y < 288+BORDER) && (x > BORDER) && (y > BORDER))
+ // On calcul les coordonnees de l'image
+ x = (int)((double)WIDTH/width * x);
+ y = height - y;
+ y = (int)((double)HEIGHT/height * y);
+ if ((x < 352+BORDER) && (y < HEIGHT-BORDER) && (x > BORDER) && (y > 2*BORDER+288))
{
int i=0;
+
+ // Ajout de point
if (button == GLUT_LEFT_BUTTON)
+ {
while(i < 3)
{
if (point[i][0] < 0)
{
point[i][0] = x;
point[i][1] = y;
- i=3;
+ i=5;
+ cout << "Point ajoute: " << x << ", " << y << endl;
}
i++;
}
+ if (i == 5) cout << "MouseFunc : 3 points sont deja selectionnes" << endl;
+ }
+
+ // Suppression de point
else if (button == GLUT_RIGHT_BUTTON)
+ {
while(i<3)
{
if ((abs(point[i][0] - x) < 5) && (abs(point[i][1] -y) < 5))
{
point[i][0] = -1;
point[i][1] = -1;
- i=3;
+ i=5;
}
i++;
}
+ if (i == 5) cout << "MouseFunc : 0 point selectionne" << endl;
+ }
}
- cout << "x : " << x << " " << y << endl;
+ DrawGLScene();
+
}
}
@@ -259,12 +293,13 @@ main(int argc, char **argv)
// Initialisation de l'OpenGL
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
- glutInitWindowSize(538, 395);
+ glutInitWindowSize(width, height);
glutInitWindowPosition(0, 0);
window = glutCreateWindow("Adjust - Efrei Robotique");
glutDisplayFunc(&DrawGLScene);
glutReshapeFunc(&ReSizeGLScene);
glutKeyboardFunc(&KeyPressed);
+ glutMouseFunc(&MouseFunc);
InitGL(WIDTH, HEIGHT);
// Init de comm