planners/aca/jma_switch.cpp

Go to the documentation of this file.
00001 /*============================================================================= *
00002  * File           : jma_switch.c
00003  * Module         : graphics
00004  * Test File      : 
00005  * Author         : Juan Manuel AHUACTZIN
00006  * Creation       : Wed Jun  2 17:37:02 PDT 1999
00007  *
00008  *============================================================================= *
00009          (c) Copyright 1999, J.M. Ahuactzin all rights reserved
00010  *============================================================================= *
00011  *------------------------- Description --------------------------------------- *
00012  *   
00013  *------------------------- Modifications ------------------------------------- *
00014  * 
00015  * 
00016  */
00017 
00018 
00019 /* #include <xdraw.h> */
00020 #include "jma_switch.h"
00021 #include <stdlib.h>
00022 
00023 #include "opengl/glos.h"
00024 #include <gl/gl.h>
00025 //#include <gl/glaux.h>
00026 #include <conio.h>
00027 
00028 /*******************************************************************************
00029  ROUTINE NAME: switch_draw_createwindow
00030 
00031  PURPOSE: create a window for displaying the environment
00032           
00033  PROGRAMED BY: JMAL
00034 
00035  LAST CHANGED: Jun 9  1999          BY: JMAL
00036 ********************************************************************************/
00037 
00038 /*void switch_draw_createwindow(
00039         char win_name[],
00040         int win_width,
00041         int win_height,
00042         int win_xo,
00043         int win_yo,
00044         int win_id
00045 )
00046 
00047 {
00048   // draw_createwindow(win_name,(int) win_width,(int) win_height,
00049 //                  (int) win_xo,(int) win_yo, win_id); 
00050         auxInitDisplayMode(AUX_SINGLE | AUX_RGB | AUX_DEPTH);
00051         auxInitPosition( win_xo, win_yo, win_width + 1, win_height + 1 ) ;
00052         auxInitWindow( win_name );
00053         glMatrixMode( GL_PROJECTION ) ;
00054         glLoadIdentity() ;
00055         glOrtho( 0, win_width, 0, win_height, -10, 10 ) ;
00056         glColor4d( 1.0, 1.0, 1.0, 1.0 ) ;
00057         glClearColor( 0.5, 0.5, 0.5, 1.0 ) ;
00058         glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;
00059 };
00060 */
00061 /*******************************************************************************
00062  ROUTINE NAME: switch_draw_set_color
00063 
00064  PURPOSE: change the color for drawing objects
00065           
00066  PROGRAMED BY: JMAL
00067 
00068  LAST CHANGED: Jun 9  1999          BY: JMAL
00069 ********************************************************************************/
00070 
00071 void switch_draw_set_color
00072 (
00073         int color
00074 )
00075 {
00076   /* switch(color)
00077     {
00078     case SWITCH_WHITE: 
00079       draw_set_color(WHITE);
00080       break;
00081     case SWITCH_BLACK:
00082       draw_set_color(BLACK);
00083       break;
00084     case SWITCH_RED:
00085         draw_set_color(RED);
00086       break;
00087     case SWITCH_GREEN:
00088       draw_set_color(GREEN);
00089       break;
00090     case SWITCH_BLUE:
00091       draw_set_color(BLUE);
00092       break;
00093     case SWITCH_YELLOW:
00094       draw_set_color(YELLOW);
00095       break;
00096     case SWITCH_MAGENTA:
00097       draw_set_color(MAGENTA);
00098       break;
00099     case SWITCH_CYAN:
00100       draw_set_color(CYAN);
00101       break;
00102     default:
00103       draw_set_color(BLACK);
00104     }
00105     
00106 draw_set_color(color); */
00107         switch(color)
00108     {
00109     case SWITCH_WHITE: 
00110       glColor4d( 1.0, 1.0, 1.0, 1.0 ) ;
00111       break;
00112     case SWITCH_BLACK:
00113       glColor4d( 0.0, 0.0, 0.0, 1.0 ) ;
00114       break;
00115     case SWITCH_RED:
00116         glColor4d( 1.0, 0.0, 0.0, 1.0 ) ;
00117       break;
00118     case SWITCH_GREEN:
00119       glColor4d( 0.0, 1.0, 0.0, 1.0 ) ;
00120       break;
00121     case SWITCH_BLUE:
00122       glColor4d( 0.0, 0.0, 1.0, 1.0 ) ;
00123       break;
00124     case SWITCH_YELLOW:
00125       glColor4d( 1.0, 1.0, 0.0, 1.0 ) ;
00126       break;
00127     case SWITCH_MAGENTA:
00128       glColor4d( 1.0, 0.0, 1.0, 1.0 ) ;
00129       break;
00130     case SWITCH_CYAN:
00131       glColor4d( 0.0, 1.0, 1.0, 1.0 ) ;
00132       break;
00133     default:
00134       glColor4d( 1.0, 1.0, 1.0, 1.0 ) ;
00135     }
00136 
00137 }
00138 
00139 /*******************************************************************************
00140  ROUTINE NAME: switch_draw_line
00141 
00142  PURPOSE: draws a line
00143           
00144  PROGRAMED BY: JMAL
00145 
00146  LAST CHANGED: Jun 9  1999          BY: JMAL
00147 ********************************************************************************/
00148 
00149 void switch_draw_line
00150 (
00151         double x1,
00152         double y1,
00153         double x2,
00154         double y2,
00155         double thickness
00156 )
00157 {
00158         glBegin( GL_LINES ) ;
00159                 glVertex2d( x1, y1 ) ;
00160                 glVertex2d( x2, y2 ) ;
00161         glEnd() ;
00162         glFlush() ;
00163 /* draw_line((int)x1,(int)y1,(int)x2,(int)y2,(int)thickness); */
00164 }
00165 
00166 /*******************************************************************************
00167  ROUTINE NAME: switch_draw_cross
00168 
00169  PURPOSE: draws a cross
00170           
00171  PROGRAMED BY: JMAL
00172 
00173  LAST CHANGED: Jun 9  1999          BY: JMAL
00174 ********************************************************************************/
00175 
00176 void switch_draw_cross
00177 (
00178         double x,
00179         double y,
00180         double cross_size,
00181         double thickness
00182 )
00183 {
00184         glPointSize( static_cast< float >( thickness ) ) ;
00185         glBegin( GL_POINTS ) ;
00186                 glVertex2d( x, y ) ;
00187         glEnd() ;
00188         glPointSize( 1.0 ) ;
00189         glFlush() ;
00190 /* draw_cross((int) x,(int)y,(int)cross_size,(int)thickness);*/
00191 }
00192 
00193 /*******************************************************************************
00194  ROUTINE NAME: switch_get_cursor_coord
00195 
00196  PURPOSE: get the coordinates of the cursor
00197           
00198  PROGRAMED BY: JMAL
00199 
00200  LAST CHANGED: Jun 9  1999          BY: JMAL
00201 ********************************************************************************/
00202 
00203 TwoD_Point switch_get_cursor_coord()
00204 {
00205   TwoD_Point my_point;
00206  /* Point2D* PP;
00207 
00208   PP = get_cursor_coord();
00209 
00210   my_point.x = PP->x;
00211   my_point.y = PP->y; */
00212 
00213   static int calledYet = 0 ;
00214   if( calledYet )
00215   {
00216           my_point.x = 10 ;
00217           my_point.y = 10 ;
00218   }
00219   else
00220   {
00221           my_point.x = 900 ;
00222           my_point.y = 400 ;
00223   }
00224   calledYet = 1 ;
00225   return(my_point); 
00226 
00227 }
00228 
00229 /*******************************************************************************
00230  ROUTINE NAME: 
00231 
00232  PURPOSE: 
00233           
00234  PROGRAMED BY: JMAL
00235 
00236  LAST CHANGED: Jun 9  1999          BY: JMAL
00237 ********************************************************************************/
00238 
00239 double switch_random()
00240 {
00241         return((double) rand());
00242 }
00243 
00244 
00245 
00246 /*******************************************************************************
00247  ROUTINE NAME: 
00248 
00249  PURPOSE: 
00250           
00251  PROGRAMED BY: JMAL
00252 
00253  LAST CHANGED: Jun 9  1999          BY: JMAL
00254 ********************************************************************************/
00255 
00256 void switch_srandom(
00257         int seed
00258 )
00259 {
00260         srand(seed);
00261 }

Generated on Sat Apr 1 21:30:39 2006 for Motion Planning Kernel by  doxygen 1.4.6-NO