00001 /********************************************************************** 00002 * gesture_box_drawer.C 00003 * 00004 **********************************************************************/ 00005 00006 #include "geom/gl_view.H" 00007 #include "std/config.H" 00008 00009 #include "gesture_box_drawer.H" 00010 00011 using mlib::PIXEL; 00012 using mlib::PIXEL_list; 00013 00014 int 00015 GestureBoxDrawer::draw(const GESTURE* gest, CVIEWptr& v) { 00016 // load identity for model matrix 00017 glMatrixMode(GL_MODELVIEW); 00018 glPushMatrix(); 00019 glLoadIdentity(); 00020 00021 // set up to draw in PIXEL coords: 00022 glMatrixMode(GL_PROJECTION); 00023 glPushMatrix(); 00024 glLoadMatrixd(VIEW::peek()->pix_proj().transpose().matrix()); 00025 00026 // Set up line drawing attributes 00027 glPushAttrib(GL_ENABLE_BIT | GL_LINE_BIT | GL_CURRENT_BIT); 00028 glDisable(GL_LIGHTING); // GL_ENABLE_BIT 00029 00030 // turn on antialiasing for width-2 lines: 00031 GL_VIEW::init_line_smooth(GLfloat(v->line_scale()*2)); 00032 00033 // draw the line strip 00034 const PIXEL_list& pts = gest->pts(); 00035 int nb_pts = pts.num(); 00036 if (nb_pts>=2){ 00037 PIXEL pt_a = pts[0]; 00038 PIXEL pt_b (pts[0][0], pts[nb_pts-1][1]); 00039 PIXEL pt_c = pts[nb_pts-1]; 00040 PIXEL pt_d (pts[nb_pts-1][0], pts[0][1]); 00041 00042 glBegin(GL_LINE_STRIP); 00043 double grey = 0.3f; 00044 glColor3d(grey, grey, grey); // GL_CURRENT_BIT 00045 glVertex2dv(pt_a.data()); 00046 glVertex2dv(pt_b.data()); 00047 glVertex2dv(pt_c.data()); 00048 glVertex2dv(pt_d.data()); 00049 glVertex2dv(pt_a.data()); 00050 glEnd(); 00051 } 00052 00053 // I tried to implement some code for corner getting highlighted 00054 // it is on the gesture.C version on Unnameable 00055 00056 GL_VIEW::end_line_smooth(); 00057 00058 glPopAttrib(); 00059 glPopMatrix(); 00060 glMatrixMode(GL_MODELVIEW); 00061 glPopMatrix(); 00062 00063 return 0; 00064 } 00065 00066