screenTask.h

Go to the documentation of this file.
00001 #ifndef SCREEN_TASK_H
00002 #define SCREEN_TASK_H
00003 
00013 #include "vmonitor.h"
00014 #include "checkBoxComponent.h"
00015 #include <set>
00016 
00017 
00021 class ScreenTask : public TaskInterface {
00022   enum {
00023     MiniFontPx = 12,
00024     LogFontPx = 18,
00025 
00026     FrameHeight = 108,
00027     MiniMapWidth = FrameHeight * 640 / 480,
00028     MiniInfoWidth = FrameHeight * 140 / 100,
00029     LineWidth = 2,
00030 
00031     LogLevel = 1,
00032     LogLevelFore = 2,
00033 
00034     MiniMap_X = LineWidth,
00035     MiniInfo_X = MiniMap_X + MiniMapWidth + LineWidth,
00036     MiniCmd_X = MiniInfo_X + MiniInfoWidth + LineWidth,
00037 
00038     INVALID_LAYER_ID = 0,
00039     TEXT_LAYER = 1,
00040     GRAPHIX_LAYER = 2,
00041     ALL_LAYER = 3,
00042 
00043     MiniScrMagnify = 10,
00044   };
00045   WindowInterface* win;
00046   TTF_Draw* ttf;
00047   vmonitor* mon;
00048   FillSurface* main_back;
00049   FillSurface* under_back;
00050   Uint32 ticks;
00051   bool isActivated;
00052   bool component_created;
00053   bool pause_next;
00054   bool pause_locked;
00055 
00056   DrawSurface* msec_text;
00057   DrawSurface* pos_text;
00058   DrawSurface* pause_text;
00059   DrawSurface* scroll_text;
00060   FillSurface* v_line;
00061   FillSurface* h_line_1;
00062   FillSurface* h_line_2;
00063   LabelComponent* msec_label;
00064   LabelComponent* pos_label;
00065   LabelComponent* pause_label;
00066   ViewComponent* main_view;
00067   ViewComponent* user_view;
00068   ViewComponent* mini_view;
00069   ContLineDraw* body_lines;
00070   ScrollAreaComponent* debug_area;
00071   ComboBoxComponent* crd_cmb;
00072   CheckBoxComponent* scroll_checkbox;
00073 
00074   double view_magnify;
00075   VXV::Grid view_center;
00076   VXV::Grid grid_center;
00077   bool no_scroll;
00078 
00079   bool debug_area_clear;
00080   unsigned long layer_index;
00081   static std::vector<BasicDrawInterface*> graphix_groups;
00082   static std::set<unsigned long> delete_index;
00083   static std::map<unsigned long,BasicDrawInterface*> text_map;
00084   static std::map<unsigned long,BasicDrawInterface*> graphix_map;
00085 
00086   std::deque<VXV::Grid> body_original;
00087   std::vector<CoordinateCtrl::polygon_t> env_polygons;
00088   std::deque<VXV::Grid> mini_body;
00089   std::deque<VXV::Grid> scr_rect;
00090 
00091   void updateView(void);
00092   void rotatePoint(VXV::Grid& point, double radian);
00093   void drawRunGrid(const VXV::Position& offset);
00094   void drawRobotBody(const VXV::Position& bodyPos, const VXV::Direction& diff);
00095   void drawEnvironment(const VXV::Position& pos_diff,
00096                        const VXV::Position& diff);
00097   void drawObjects(void);
00098   int printf(ScrollAreaComponent* area, const char* fmt, va_list ap);
00099   void userInputHandle(UserInput::userInput_t& ui);
00100   void drawRobotInfo(const VXV::Position& bodyPos);
00101   void handlePauseInput(UserInput::userInput_t& ui);
00102   void drawMiniMap(VXV::Position& bodyPos);
00103   void handleCrdSelectInput(void);
00104 
00105 public:
00106   ScrollAreaComponent* command_log;
00107 
00114   ScreenTask(WindowInterface* winObj, TTF_Draw* ttfObj);
00115   ~ScreenTask(void);
00116 
00117   void init(void);
00118   void recv(void) {}
00119   void exec1msec(unsigned long total_msec) {}
00120   void send(void);
00121   bool updatePosition(void) { return false; }
00122   VXV::Position3D getBodyPosition(const VXV::Position3D& position) {
00123     return VXV::Position3D();
00124   }
00125 
00129   void show(void);
00130 
00134   void hide(void);
00135 
00141   void updateViewMagnify(double magnify);
00142 
00148   void setViewCenter(VXV::Grid& center);
00149 
00155   void setEnvironment(const std::vector<CoordinateCtrl::polygon_t>& objs);
00156 
00162   void clear(unsigned long index);
00163 
00172   unsigned long setPoints(const std::vector<VXV::Grid3D>& points,
00173                           unsigned long color, int width = 1);
00174 
00183   unsigned long setLine(const VXV::Grid3D& p0, const VXV::Grid3D& p1,
00184                         unsigned long color);
00185 
00193   unsigned long setContLine(const std::deque<VXV::Grid3D>& points,
00194                             unsigned long color);
00195 
00196   unsigned long setCircle(const VXV::Grid& center, int r, unsigned long color);
00197 
00210   unsigned long setText(const char* text, const VXV::Grid& pos, int pxSize,
00211                         bool pin, unsigned long color, unsigned long back);
00212 
00213   int consolePrintf(const char* fmt, va_list ap);
00214   int commandLogPrintf(const char* fmt, ...);
00215   void activate(void);
00216 
00217   void scrollWithRobot(bool on);
00218 };
00219 
00220 #endif /* !SCREEN_TASK_H */
00221 

Generated on Mon Apr 13 22:52:03 2009 by  doxygen 1.5.7.1