Página principal | Jerarquía de la clase | Lista alfabética | Lista de componentes | Lista de archivos | Miembros de las clases | Archivos de los miembros | Páginas relacionadas

v_sensor.C

Ir a la documentación de este archivo.
00001 //===========================================================================
00002 //= v_sensor.cc                               Julio de 1998, enero del 2000 =
00003 //=-------------------------------------------------------------------------=
00004 //= Definicion de clases de visores de sensores                             =
00005 //=-------------------------------------------------------------------------=
00006 //= ADVERTENCIA: ESTE SOFTWARE NO ESTA CONCEBIDO NI DISENNADO PARA EL USO   =
00007 //= EN EQUIPO DE CONTROL EN LINEA EN ENTORNOS PELIGROSOS QUE REQUIERAN UN   =
00008 //= DESEMPENNO LIBRE DE FALLAS, COMO LA OPERACION DE PLANTAS NUCLEARES,     = 
00009 //= SISTEMAS DE NAVEGACION O COMUNICACION EN AVIONES, TRAFICO AEREO,        =
00010 //= EQUIPO MEDICO DEL CUAL DEPENDAN VIDAS HUMANAS O SISTEMAS DE ARMAMENTO,  =
00011 //= EN LOS CUALES UNA FALLA EN EL SOFTWARE PUEDA IMPLICAR DIRECTAMENTE LA   =
00012 //= MUERTE, DANNOS PERSONALES O DANNOS FISICOS Y/O AMBIENTALES GRAVES       =
00013 //= ("ACTIVIDADES DE ALGO RIESGO").                                         =
00014 //=-------------------------------------------------------------------------=
00015 //= Autor original: Oscar J. Chavarro G.  A.K.A. JEDILINK. Copyright (c),   =
00016 //= 1997 - 2003, oscarchavarro@hotmail.com                                  =
00017 //= AQUYNZA es software libre, y se rige bajo los terminos de la licencia   =
00018 //= LGPL de GNU (http://www.gnu.org). Para mayor informacion respecto a la  =
00019 //= licencia de uso, consulte el archivo ./doc/LICENCIA en la distribucion. =
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 //= Constantes y macros                                                     =
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 //= Funciones utilitarias                                                   =
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); // Informacion
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); // Marco
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     //- Pintar la escala - (deberia basarse en una paleta)
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); // Marco
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 //= Clase VISOR_SENSOR                                                      =
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 /* OJO: Esto no deberia estar en este modulo! */
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 //= EOF                                                                     =
00188 //===========================================================================
00189 

Este archivo HTML ha sido generado automáticamente a partir del código fuente AQUYNZA. NO LO EDITE. Para mayor información contacte al autor.