mcl_gtk.h

00001 /*
00002  * @(#)mcl_gtk.h       07/04/06
00003  * 
00004  * Description  : GTK animation for a simple implementation of MCL 
00005  *                (MCL - Monte Carlo Localization).
00006  * License      : GNU GPL v.2
00007  * Author       : Tran Duy Khanh (www.tran.cz)
00008  */
00009 
00010 #ifndef __mcl_gtk__
00011 #define __mcl_gtk__
00012 
00013 #include <gtk/gtk.h>
00014 
00015 #define SCENE_REFRESH           500
00016 #define BORDER                  15
00017 #define FWIDTH                  3000
00018 #define FHEIGHT                 2100
00019 
00020 struct prog_opt option;                 /* program option flags */
00021 FILE *file_out, *file_err;              /* output filename */
00022 int argc;                               /* program arguments counter */
00023 char **argv;                            /* program arguments */
00024 
00025 /* DATA STRUCTURES */
00026 
00027 /* program options structure */
00028 struct prog_opt {
00029         unsigned int opt_flag;          /* option flag */
00030         
00031         #define OPT_GTK_TEST    0x1000  /* -g ; test GTK animation */
00032         #define OPT_TEXT_MODE   0x2000  /* -t ; text-mode only. Dont use GTK. */
00033 };
00034 
00035 /* mutex */
00036 pthread_mutex_t mcl_mutex;
00037 
00038 /* Main window and drawing area */
00039 GtkWidget *window;
00040 GtkWidget *drawing_area;
00041 
00042 /* Pixmaps */
00043 static GdkPixmap *xpm_scene = NULL;             /* Scene pixmap */
00044 
00045 /* Pixmap object */
00046 struct pixmap_obj {
00047         char *xpm_filename;
00048         GdkPixmap *pixmap;
00049         GdkBitmap *mask;
00050         unsigned int seq_count;
00051         unsigned int width;
00052         unsigned int height;
00053 };
00054 
00055 /* Movable object */
00056 struct moveable_obj {
00057         int type;
00058         int x;
00059         int y;
00060         unsigned int width;
00061         unsigned int height;
00062         unsigned int seq;
00063         unsigned int seq_count;
00064 };
00065 
00066 /* background pixmap */
00067 struct pixmap_obj xpm_background[] = {
00068         { "images/background.xpm", NULL, NULL, 0, 632, 452}, 
00069         { NULL, NULL, NULL, 0, 0, 0 }   /* End mark */
00070 };
00071 
00072 /* robot pixmap */
00073 struct pixmap_obj xpm_robot[] = {
00074         { "images/robot.xpm", NULL, NULL, 0, 19, 19 }, 
00075         { NULL, NULL, NULL, 0, 0, 0 }   /* End mark */
00076 };
00077 
00078 /* sample pixmap */
00079 struct pixmap_obj xpm_sample[] = {
00080         { "images/point3x3r.xpm", NULL, NULL, 0, 3, 3 }, 
00081         { "images/point3x3b.xpm", NULL, NULL, 0, 3, 3 }, 
00082         { "images/point3x3c.xpm", NULL, NULL, 0, 3, 3 }, 
00083         { "images/point3x3y.xpm", NULL, NULL, 0, 3, 3 }, 
00084         { "images/point3x3g.xpm", NULL, NULL, 0, 3, 3 }, 
00085         { NULL, NULL, NULL, 0, 0, 0 }   /* End mark */
00086 };
00087 
00088 struct moveable_obj *moveable;
00089 
00093 /* GTK */
00094 void quit ();
00095 void get_size (GdkPixmap *xpm, unsigned int *width, unsigned int *height);
00096 void load_pixmaps (GtkWidget *widget, struct moveable_obj *moveable, 
00097                                         struct pixmap_obj *pixmaps);
00098 void load_scene_pixmap(GtkWidget *widget);
00099 static gint configure_event (GtkWidget *widget, GdkEventConfigure *event);
00100 gint expose_event (GtkWidget *widget, GdkEventExpose *event);
00101 gint repaint (gpointer data);
00102 void test_repaint();
00103 void test_animation(int argc, char *argv[]);
00104 void init_animation(int argc, char *argv[], void (*repaint_func)());
00105 void scene_repaint();
00106 
00110 void print_usage();
00111 
00118 int parseopt(int argc, char **argv);
00119 
00123 #define DEBUG
00124 #ifdef DEBUG
00125 #define PROG_NAME               "mcl_gtk"
00126 #define DBG(f, a...)            printf(f, ## a)
00127 #define DBGPROG(f, a...)        printf(PROG_NAME ": " f, ## a)
00128 #else
00129 #define DBG(f, a...)            do { } while(0);
00130 #define DBGPROG(f, a...)        do { } while(0);
00131 #endif
00132 
00133 #endif  /* __mcl_gtk__ */

Generated on Thu Sep 13 11:28:28 2007 for DCE-Eurobot by  doxygen 1.5.3