00001
00002
00003
00004
00005 #ifndef CAJUN_DRAW_GRID_TILE_H
00006 #define CAJUN_DRAW_GRID_TILE_H
00007
00008 #include "data_queue.H"
00009 #include "cbviz_util.H"
00010 #include "conf.H"
00011 #include <vector>
00012 #include "component_interface.H"
00013
00014 namespace cajun
00015 {
00017 struct grid_square_t
00018 {
00019 float x, z;
00020 float r, g, b;
00021 };
00022
00024 class draw_grid_tile_t : public component_interface_t
00025 {
00026 public:
00027 draw_grid_tile_t (double cbviz_origin[3], conf_t &conf,
00028 int id, bool display, world_state_t *ws_);
00029 virtual ~draw_grid_tile_t ();
00030 void update_data (double bot_pos_[3]);
00031 void display(double bot_pos[3]);
00032 void init_data ();
00033 void toggle_display () {m_display = !m_display;}
00034 private:
00036 unsigned buffer_size;
00037 double red, green, blue;
00038 float tile_value;
00039 grid_square_t *tiles;
00040
00041 std::vector <grid_tile_data_t> *m_grid_to_draw;
00042 std::vector <grid_tile_data_t> *m_grid_to_populate;
00043 double m_last_tile_tstamp;
00044
00045 grid_tile_data_t m_grid_tile;
00046 grid_path_data_t m_grid_path;
00047 double m_grid_height;
00048 double m_cell_max_value;
00049 double m_cell_spacing;
00050 int m_grid_display_function;
00051 int m_color_function;
00052
00053 double m_x_dx, m_x_dy, m_y_dx, m_y_dy;
00054
00055 struct { int dx; int dy; } m_neighbor[8];
00056
00057 void draw_by_arrow (grid_tile_data_t const &tile,
00058 unsigned x, unsigned y);
00059 void draw_by_square (grid_tile_data_t const &tile,
00060 unsigned x, unsigned y);
00061
00062 void draw_arrow (double x, double y, int dx, int dy,
00063 double square_length);
00064
00065 void read_grid_path();
00066 void draw_path (double cell_size_);
00067 data_queue_reader_t<grid_path_data_t> *m_grid_path_data_dq;
00068
00069 void read_grid_tile();
00070 void draw_tile (grid_tile_data_t const &tile);
00071 data_queue_reader_t<grid_tile_data_t> *m_grid_tile_data_dq;
00072 };
00073 }
00074 #endif
00075