CGFLib - A library for Computer Graphics @ FEUP
 All Classes Files Functions Variables Pages
CGFinterface.h
Go to the documentation of this file.
1 #ifndef CG_CGFinterface
2 #define CG_CGFinterface
3 
10 #include <GL/glui.h>
11 
12 // forward declaration of scene
13 class CGFscene;
14 
17 {
18  public:
19  CGFinterface();
20  virtual ~CGFinterface();
21 
22  // Initialization methods
23 
24  void init(int parent);
25  virtual void initGUI();
26 
27  // Link to scene
28  void setScene(CGFscene *scene);
29 
30  // Active interface selection
31 
32  static void setActiveInterface(CGFinterface *gli)
33  { activeInterface=gli; };
34 
40  static void preprocessKeyboard(unsigned char key, int x, int y);
41  static void preprocessMouse(int button, int state, int x, int y);
42  static void preprocessMouseMoved(int x, int y);
43  static void preprocessPassiveMouseMoved(int x, int y);
44 
45 
46  // Handlers to be overridden by subclasses
47 
53  virtual void processKeyboard(unsigned char key, int x, int y);
54  virtual void processMouse(int button, int state, int x, int y);
55  virtual void processMouseMoved(int x, int y);
56  virtual void processPassiveMouseMoved(int x, int y);
57 
58 
59  static void preprocessGUI(GLUI_Control *ctrl);
60  virtual void processGUI(GLUI_Control *ctrl);
61  void syncVars();
62 
68  GLUI_Checkbox* addCheckbox(char* name, int* value = (int*) 0, int id = -1);
69  GLUI_Checkbox* addCheckboxToPanel(GLUI_Panel *p,char* name, int* value= (int*) 0,int id = -1);
70 
71  GLUI_Button* addButton(char* name,int id = -1);
72  GLUI_Button* addButtonToPanel(GLUI_Panel *p,char* name,int id = -1);
73 
74  void addColumn();
75  void addColumnToPanel(GLUI_Panel *p);
76 
77  GLUI_EditText* addEditText(char* name, char* var = (char*) 0,int id = -1);
78  GLUI_EditText* addEditText(char* name, int* var = (int*) 0,int id = -1);
79  GLUI_EditText* addEditText(char* name, float* var = (float*) 0,int id = -1);
80  GLUI_EditText* addEditTextToPanel(GLUI_Panel *p,char* name, char* var = (char*) 0,int id = -1);
81  GLUI_EditText* addEditTextToPanel(GLUI_Panel *p,char* name, int* var= (int*) 0,int id = -1);
82  GLUI_EditText* addEditTextToPanel(GLUI_Panel *p,char* name, float* var= (float*) 0,int id = -1);
83 
84  GLUI_Listbox* addListbox(char* name, int* var= (int*) 0, int id = -1);
85  GLUI_Listbox* addListboxToPanel(GLUI_Panel *p,char* name, int* var= (int*) 0, int id = -1);
86 
87  GLUI_Panel* addPanel(char* name, int type = 1);
88  GLUI_Panel* addPanelToPanel(GLUI_Panel *p,char* name, int type = 1);
89 
90  GLUI_RadioButton* addRadioButtonToGroup(GLUI_RadioGroup * group, char * name);
91 
92  GLUI_RadioGroup* addRadioGroup(int *var, int id=-1);
93  GLUI_RadioGroup* addRadioGroupToPanel(GLUI_Panel* p,int *var= (int*) 0, int id=-1);
94 
95  GLUI_Rollout* addRollout(char *name, int open=1, int type =1);
96  GLUI_Rollout* addRolloutToPanel(GLUI_Panel* p,char *name, int open=1, int type =1);
97 
98  GLUI_Rotation* addRotation(char* name, float* var= (float*) 0, int id=-1);
99  GLUI_Rotation* addRotationToPanel(GLUI_Panel* p,char* name, float* var= (float*) 0, int id=-1);
100 
101  void addSeparator();
102  void addSeparatorToPanel(GLUI_Panel * p);
103 
104  GLUI_Spinner* addSpinner(char* name, int type = 2, int* var= (int*)0, int id=-1);
105  GLUI_Spinner* addSpinnerToPanel(GLUI_Panel* p,char* name, int type = 2, int* var= (int*)0, int id=-1);
106 
107  GLUI_StaticText* addStaticText(char* name);
108  GLUI_StaticText* addStaticTextToPanel(GLUI_Panel *p,char* name);
109 
110  GLUI_Translation* addTranslation(char* name, int type = GLUI_TRANSLATION_X, float* var = (float*) 0, int id=-1);
111  GLUI_Translation* addTranslationToPanel(GLUI_Panel* p,char* name, int type = GLUI_TRANSLATION_X, float* var= (float*) 0, int id=-1);
113 
114  protected:
115 
117 
118  static int modifiers;
119  static CGFinterface * activeInterface;
120  GLUI* glui_window;
121 
122 
123  // state and control variables to handle mouse interaction
124  float displacementX;
125  float displacementY;
126  bool pressing_left;
127  bool pressing_middle;
128  bool pressing_right;
129  float prev_X;
130  float prev_Y;
131 };
132 
133 
134 #endif