plot_gtk.h

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

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