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

visor.C

Ir a la documentación de este archivo.
00001 //===========================================================================
00002 //= visor.h                                                   Enero de 1999 =
00003 //=-------------------------------------------------------------------------=
00004 //= Definicion de la interface VISOR                                        =
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 "jed_gl.h"
00023 #include "lista.cc"
00024 #include "framework/visual/visor.h"
00025 #include "framework/visual/v_sensor.h"
00026 
00027 //===========================================================================
00028 //= Constantes y macros                                                     =
00029 //===========================================================================
00030 
00031 #define ESPERO(tipo, msg) \
00032     if ( tipo_token != (tipo) ) { \
00033         fprintf(stderr, "<VISOR> " \
00034           "ERROR: Esperaba %s y recibi [%s].\n", \
00035           (msg), cad); fflush(stderr);  return FALSE; \
00036     }
00037 
00038 #define VERIFICAR(c) \
00039     if ( !(c) ) {\
00040         fprintf(stderr, \
00041             "<VISOR> " \
00042             "ERROR: No se pudo crear un objeto dinamico!\n");\
00043         fflush(stderr);\
00044         exit(1);\
00045     }
00046 
00047 //===========================================================================
00048 //= Clase VISOR                                                             =
00049 //===========================================================================
00050 
00051 VISOR::VISOR()
00052 {
00053     _metodo_de_visualizacion = MDV_ZBUFFER;
00054 }
00055 
00056 VISOR::~VISOR()
00057 {
00058     int i;
00059 
00060     for ( i = 0; i < lista_visores_subordinados.tam(); i++ ) {
00061         delete lista_visores_subordinados[i];
00062     }
00063     lista_visores_subordinados.elim();
00064 }
00065 
00066 int
00067 VISOR::metodo_de_visualizacion(void)
00068 {
00069     return _metodo_de_visualizacion;
00070 }
00071 
00072 #ifdef GL_ENABLED
00073 
00074 void
00075 VISOR::pintar_visores_subordinados_gl(CAMARA *C)
00076 {
00077     int i;
00078 
00079     for ( i = 0; i < lista_visores_subordinados.tam(); i++ ) {
00080         lista_visores_subordinados[i]->camara = (*C);
00081         lista_visores_subordinados[i]->pintar_gl();
00082     }
00083 }
00084 
00085 void
00086 VISOR::pintar_gl(void)
00087 {
00088     //- Limpie el fondo -
00089     glMatrixMode(GL_PROJECTION);    glLoadIdentity();
00090     glMatrixMode(GL_MODELVIEW);     glLoadIdentity();
00091     glDisable(GL_LIGHTING);         glDisable(GL_DEPTH_TEST);
00092     glColor3f(0, 0, 0);             glFrontFace(GL_CCW); //OJO!
00093     glBegin(GL_QUADS);
00094         glVertex2f(1, 1);           glVertex2f(-1, 1);
00095         glVertex2f(-1, -1);         glVertex2f(1, -1);
00096     glEnd();
00097 
00098     if ( !lista_visores_subordinados.tam() ) {
00099         glColor3f(1, 0, 0);
00100         glBegin(GL_LINES);
00101             glVertex2f(1, 1);           glVertex2f(-1, -1);
00102             glVertex2f(-1, 1);          glVertex2f(1, -1);
00103         glEnd();
00104     }
00105 
00106     //----------------------------------------------------------------------
00107     pintar_visores_subordinados_gl(&camara);
00108 }
00109 #endif
00110 
00111 BOOLEAN
00112 VISOR::pintar_raytracing_criollo(IMAGEN_RGB * /*Imagen*/)
00118 {
00119     return FALSE;
00120 }
00121 
00122 BOOLEAN
00123 VISOR::pintar_povray(IMAGEN_RGB * /*Imagen*/, char * /*archivo*/,
00124                      BOOLEAN /*modo_interactivo*/)
00130 {
00131     return FALSE;
00132 }
00133 
00134 int
00135 VISOR::procesar_teclado(EVENTO_GUI *e)
00136 {
00137     return camara.procesar_teclado(e);
00138 }
00139 
00140 int
00141 VISOR::procesar_mouse(EVENTO_GUI * /*e*/)
00142 {
00143     return 0;
00144 }
00145 
00146 void
00147 VISOR::procesar_resize(int x, int y, int x_tam, int y_tam)
00148 {
00149 #ifdef GL_ENABLED
00150     glViewport(x, y, x_tam, y_tam);
00151 #endif
00152 
00153     camara.procesar_resize(x_tam, y_tam);
00154 }
00155 
00156 int
00157 VISOR::procesar_comando(int /*idc*/)
00158 {
00159     return 0;
00160 }
00161 
00162 char *
00163 VISOR::reportar_menu(void)
00164 {
00165     return UNDEFINED_CAD;
00166 }
00167 
00168 char *
00169 VISOR::reportar_botonera(void)
00170 {
00171     return UNDEFINED_CAD;
00172 }
00173 
00174 //= SERVICIOS DE PERSISTENCIA ===============================================
00175 
00176 void
00177 VISOR::grabar(FILE *fd)
00178 {
00179     fprintf(fd, "    // Visor\n");
00180 }
00181 
00182 BOOLEAN
00183 VISOR::leer_visor_subordinado(TOKENIZADOR *Sabiondo, char *cad)
00184 {
00185     VISOR_SENSOR *Visor_sensor;
00186 
00187     if ( strcmp(cad, "subvisor_sensor_float") == 0 ) { 
00188         Visor_sensor = new VISOR_SENSOR_FLOAT();
00189         if ( !Visor_sensor || 
00190              !Visor_sensor->leer(Sabiondo) ) return FALSE;
00191         lista_visores_subordinados.anx(Visor_sensor);
00192       }
00193       else if ( strcmp(cad, "subvisor_sensor_vector") == 0 ) { 
00194         Visor_sensor = new VISOR_SENSOR_VECTOR();
00195         if ( !Visor_sensor || 
00196              !Visor_sensor->leer(Sabiondo) ) return FALSE;
00197         lista_visores_subordinados.anx(Visor_sensor);
00198     }
00199 
00200     return TRUE;
00201 }
00202 
00203 BOOLEAN
00204 VISOR::leer(TOKENIZADOR *Sabiondo)
00205 {
00206     char cad[1000];
00207     int tipo_token = TK_DESCONOCIDO, pos;
00208 
00209     //- Ejecute el parser especifico de la COSA_RIGIDA -----------------
00210     pos = 1;
00211     while ( tipo_token != TK_CERRAR) {
00212         tipo_token = Sabiondo->siguiente_token(cad);
00213         switch ( pos ) {
00214             case 1:
00215               ESPERO(TK_CADENA, "una cadena con un nombre de un VISOR");
00216               if ( strlen(cad) > MAX_CAD-1 ) cad[MAX_CAD-1] = '\0'; 
00217               des_comille(cad);
00218               //set_nombre(cad);
00219               pos++;
00220               break;
00221             case 2:  ESPERO(TK_ABRIR, "\"{\"");  pos++; break;
00222             default:
00223               if ( tipo_token == TK_CERRAR ) break;
00224               ESPERO(TK_IDENTIFICADOR, "un identificador (3)");
00225               if ( !leer_visor_subordinado(Sabiondo, cad) ) {
00226                   return FALSE;
00227               }
00228               ;
00229               break;
00230         }
00231     }
00232 
00233     return TRUE;
00234 }
00235 
00236 LISTA <VISOR_SENSOR *> *
00237 VISOR::sensores(void)
00238 {
00239     return &lista_visores_subordinados;
00240 }
00241 
00242 //===========================================================================
00243 //= EOF                                                                     =
00244 //===========================================================================
00245 

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.