00001 // GUI.h: interface for the GUI class. 00002 // 00004 00005 #ifndef GUI_H 00006 #define GUI_H 00007 00008 #include "Vector2.h" 00009 #include "Color.h" 00010 00011 /* Provides an interface for the interaction of the simulator with a GUI. Can be specialized 00012 for use under wxWidgets, MFC, etc. It is used for graphically illustrating the state of the 00013 simulator on a display. **/ 00014 class GUI { 00015 public: 00016 GUI(float iniPanX=0, float iniPanY=400, float zoom=100.0f, int signX = 1, int signY = -1); 00017 virtual ~GUI(); 00018 00019 static const Color colorTransparent; 00020 static const Color colorWhite; 00021 static const Color colorBlack; 00022 00023 void setZoom(float newZoom); 00024 00026 virtual void clear() = 0; 00027 00028 virtual void drawCircle(float x, float y, float r) = 0; 00029 void drawCircle(const Vector2& r, float R) { drawCircle((float)r.x, (float)r.y, R); } 00030 00031 virtual void drawLine(float x1, float y1, float x2, float y2) = 0; 00032 void drawLine(const Vector2& r1, const Vector2& r2){ 00033 drawLine((float)r1.x,(float)r1.y,(float)r2.x,(float)r2.y); 00034 } 00035 void drawLine(const Vector2& r1, float x2, float y2){ 00036 drawLine((float)r1.x,(float)r1.y,x2,y2); 00037 } 00038 00040 virtual void drawRectangle(float x, float y, float w, float h) = 0; 00041 00042 virtual void drawCappedRectangle(float x, float y, float l, float R, float alpha) = 0; 00043 virtual void setBrushColor(Color color) = 0; 00044 virtual void setPenColor(Color color) = 0; 00045 virtual void drawArrow(float x1, float x2, float y1, float y2) = 0; 00046 00048 virtual void outText(const char* s) = 0; 00049 00051 virtual void outTextStatusBar(const char* s, int pos) = 0; 00052 00054 virtual void drawForce(const Vector2& r, const Vector2& force) = 0; 00055 00058 virtual void drawTorque(const Vector2& r, const real alpha, const real torque) = 0; 00059 00060 float mapX(float x) { 00061 //return panX + floor(zoomX * x+0.5); 00062 return panX + zoomX * x; 00063 } 00064 00065 float mapY(float y) { 00066 //return panY + floor(zoomY * y+0.5); 00067 return panY + zoomY * y; 00068 } 00069 00070 float inverseMapX(float x){ 00071 return (float)(x-panX)/zoomX; 00072 } 00073 00074 float inverseMapY(float y){ 00075 return (float)(y-panY)/zoomY; 00076 } 00077 00078 float mapLen(float len) { 00079 //mapLen is usually used for circle's ray, so it counts twice :) 00080 return zoom * len; 00081 } 00082 00083 float panX; 00084 float panY; 00085 float zoom; 00086 int signX; 00087 int signY; 00088 float zoomX; 00089 float zoomY; 00090 }; 00091 00092 00093 #endif //GUI_H
Thyrix homepage Users' guide
(C) Arxia 2004-2005