Main Page | Class List | Directories | File List | Class Members | File Members

bridgeGUI.h

Go to the documentation of this file.
00001 /*
00002  * Physically Based Simulation, SS 2005
00003  *
00004  * Markus Liechti (liechtim@student.ethz.ch)
00005  * Yoshimi Takano (yoshi@student.ethz.ch)
00006  * Stefan Wismer (swismer@student.ethz.ch)
00007  *
00008  * $Id: bridgeGUI.h,v 1.20 2005/06/25 20:00:04 ytakano Exp $
00009  */
00010  
00013 #ifndef __bridgeGUI_H__
00014 #define __bridgeGUI_H__
00015 
00016 #include "opengl.h"
00017 #include "structures.h"
00018 #include "world.h"
00019 #include "bridge.h"
00020 
00022 #define EDGE_MAX_LENGTH 9.0
00023 
00025 #define DEFAULT_BRIDGE "data/example.brg"
00026 
00028 #define DEFAULT_TRAIN "data/sbahn.trn"
00029 
00031 #define SAVE_BRIDGE_1 "data/save1.brg"
00032 
00034 #define SAVE_BRIDGE_2 "data/save2.brg"
00035 
00037 #define SAVE_BRIDGE_3 "data/save3.brg"
00038 
00040 #define SAVE_BRIDGE_4 "data/save4.brg"
00041 
00045 class BridgeGUI {
00046 private:
00047         World *world;                      // a pointer to the world for simpler access
00048         int windowWidth, windowHeight;     // width and height of the window
00049         int scrollBorder;                  // size of scroll-border
00050         int lastScrollTime;                // time of last scolling action. used for limiting scrolling rate
00051 
00052         vector2 viewPos, viewSize;         // used for specifying which area to draw
00053         int viewLeftBound, viewRightBound; // bounds of the world, scrolling limits in the GUI
00054         vector2 cursor;                    // cursor in world coordinates
00055 
00056         int selVertex, selEdge;            // index of selected vertex / edge
00057         int drawVertex;                    // index of previously drawn vertex when drawing an edge
00058                                            // -1 if not currently drawing an edge
00059 
00060         GLuint *gltexture;                 // array of OpenGL texture IDs
00061 
00062         // possible application run modes
00063         enum appMode {initMode = 0, designMode = 1, simMode = 2, trainMode = 3};
00064         appMode mode;                      // current mode
00065 
00067         void initTextures();
00068 
00075         void setHSVcolor(float h, float s, float v);
00076         
00082         vector2 getPos(int x, int y);
00083         
00088         vector2 roundPos(const vector2 &v);
00089         
00094         void doMouseDetection(int x, int y);
00095 
00100         void initGL(int Width, int Height);
00101 
00105         void drawGLScene();
00106         
00110         int handleEvents();
00111 
00112 public:
00117         BridgeGUI(World *w): world(w) {}
00118         
00127         void run(int width, int height, bool fullScreen, char *bridgeFile, char *trainFile);
00128 };
00129 
00130 #endif

Generated on Sun Jul 10 22:32:04 2005 for S12 by  doxygen 1.4.2