00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "framework/visual/visor.h"
00023
00024 #ifdef VEL_ROSITA
00025 #include "framework/visual/v_sensor.h"
00026 #endif
00027
00028
00029
00030
00031
00032 #define ESPERO(tipo, msg) \
00033 if ( tipo_token != (tipo) ) { \
00034 fprintf(stderr, "<VISOR_SENSOR> " \
00035 "ERROR: Esperaba %s y recibi [%s].\n", \
00036 (msg), cad); fflush(stderr); return FALSE; \
00037 }
00038
00039
00040
00041
00042
00043 #ifdef GL_ENABLED
00044 void
00045 jvs_cuadro_gl(float x, float y, float x_tam, float y_tam, float percent,
00046 double _transparencia)
00057 {
00058 glBegin(GL_QUADS);
00059 glVertex2f(x+x_tam, y+y_tam*percent);
00060 glVertex2f(x, y+y_tam*percent);
00061 glVertex2f(x, y);
00062 glVertex2f(x+x_tam, y);
00063 glEnd();
00064
00065 glColor4f(1, 1, 1, (float)_transparencia);
00066 glBegin(GL_LINE_LOOP);
00067 glVertex2f(x,y); glVertex2f(x+x_tam,y);
00068 glVertex2f(x+x_tam,y+y_tam);glVertex2f(x,y+y_tam);
00069 glEnd();
00070 }
00071
00072 void
00073 jvs_pintar_paleta(float x, float y, float x_tam, float y_tam,
00074 double _transparencia)
00084 {
00085 int i;
00086
00087
00088 glShadeModel(GL_SMOOTH);
00089 glBegin(GL_QUADS);
00090 for ( i = 0; i < 10; i++ ) {
00091 glColor4f((float)(i+1)/10, 0, 1 - (float)(i+1)/10,
00092 (float)_transparencia);
00093 glVertex2f(x+x_tam, y+y_tam*((float)i+1)/10);
00094 glVertex2f(x, y+y_tam*((float)i+1)/10);
00095 glColor4f((float)i/10, 0, 1 - (float)i/10, (float)_transparencia);
00096 glVertex2f(x, y+y_tam*(float)i/10);
00097 glVertex2f(x+x_tam, y+y_tam*(float)i/10);
00098 }
00099 glEnd();
00100 glBegin(GL_LINE_LOOP);
00101 glColor4f(1, 1, 1, (float)_transparencia);
00102 glVertex2f(x,y); glVertex2f(x+x_tam,y);
00103 glVertex2f(x+x_tam,y+y_tam);glVertex2f(x,y+y_tam);
00104 glEnd();
00105 }
00106 #endif // GL_ENABLED
00107
00108
00109
00110
00111
00112 VISOR_SENSOR::VISOR_SENSOR()
00113 {
00114 tam_grilla = 1;
00115 x_grilla = y_grilla = 0;
00116 dx_grilla = dy_grilla = 1;
00117 cuadre_grilla = 0;
00118 _transparencia = 1;
00119 }
00120
00121 void
00122 VISOR_SENSOR::posicione(int tam, int i, int j, int cuadre)
00123
00124 {
00125 tam_grilla = tam;
00126 x_grilla = i;
00127 y_grilla = j;
00128 cuadre_grilla = cuadre;
00129 }
00130
00131 char *
00132 VISOR_SENSOR::nombre_variable(void)
00133 {
00134 return _nombre_variable;
00135 }
00136
00137 BOOLEAN
00138 VISOR_SENSOR::leer_sensor(TOKENIZADOR *Sabiondo, char *cad)
00143 {
00144 int tipo_token = TK_DESCONOCIDO;
00145
00146 if ( strcmp(cad, "tam_grilla") == 0 ) {
00147 tipo_token = Sabiondo->siguiente_token(cad);
00148 ESPERO(TK_NUMERO, "un numero");
00149 tam_grilla = atoi(cad);
00150 }
00151 else if ( strcmp(cad, "x_grilla") == 0 ) {
00152 tipo_token = Sabiondo->siguiente_token(cad);
00153 ESPERO(TK_NUMERO, "un numero");
00154 x_grilla = atoi(cad);
00155 }
00156 else if ( strcmp(cad, "y_grilla") == 0 ) {
00157 tipo_token = Sabiondo->siguiente_token(cad);
00158 ESPERO(TK_NUMERO, "un numero");
00159 y_grilla = atoi(cad);
00160 }
00161 else if ( strcmp(cad, "dx_grilla") == 0 ) {
00162 tipo_token = Sabiondo->siguiente_token(cad);
00163 ESPERO(TK_NUMERO, "un numero");
00164 dx_grilla = atoi(cad);
00165 }
00166 else if ( strcmp(cad, "dy_grilla") == 0 ) {
00167 tipo_token = Sabiondo->siguiente_token(cad);
00168 ESPERO(TK_NUMERO, "un numero");
00169 dy_grilla = atoi(cad);
00170 }
00171 else if ( strcmp(cad, "cuadre_grilla") == 0 ) {
00172 tipo_token = Sabiondo->siguiente_token(cad);
00173 ESPERO(TK_NUMERO, "-1, 0, o 1");
00174 cuadre_grilla = atoi(cad);
00175 }
00176 else if ( strcmp(cad, "transparencia") == 0 ) {
00177 tipo_token = Sabiondo->siguiente_token(cad);
00178 ESPERO(TK_NUMERO, "un numero");
00179 _transparencia = atof(cad);
00180 }
00181 ;
00182 return TRUE;
00183 }
00184
00185
00186
00187
00188
00189