Moka controlers
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
precompile.hh
Go to the documentation of this file.
1 /*
2  * lib-controler : Un contrôleur générique de scène 3D.
3  * Copyright (C) 2004, Moka Team, Université de Poitiers, Laboratoire SIC
4  * http://www.sic.sp2mi.univ-poitiers.fr/
5  * Copyright (C) 2009, Guillaume Damiand, CNRS, LIRIS,
6  * guillaume.damiand@liris.cnrs.fr, http://liris.cnrs.fr/
7  *
8  * This file is part of lib-controler
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU Lesser General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  */
23 
24 //******************************************************************************
25 #ifndef PRECOMPILE_HH
26 #define PRECOMPILE_HH
27 //******************************************************************************
28 #include "controler-types.hh"
29 #include "parameter.hh"
30 
31 #ifdef _WINDOWS
32 #include <windows.h>
33 #endif
34 
35 #ifdef __APPLE__
36 #include <OpenGL/gl.h>
37 #include <OpenGL/glu.h>
38 #else
39 #include <GL/gl.h>
40 #include <GL/glu.h>
41 #endif
42 
43 //******************************************************************************
47 //******************************************************************************
48 #define PLOT( a ) \
49  (glVertex3f((a)->getX(), (a)->getY(), (a)->getZ()))
50 
51 #define LINE(a,b) (PLOT(a), PLOT(b))
52 //******************************************************************************
53 
65 //******************************************************************************
66 class CView;
67 
69 {
70 public:
71  //@name Constructeurs et destructeur.
73 
75  CPrecompile( unsigned int ANb=0 );
76 
79  CPrecompile( const CPrecompile & );
80 
83  virtual ~CPrecompile();
84 
88  virtual CPrecompile * copy() const = 0;
90 
91  //@name Méthodes virtuelles pures à implémenter dans les classes filles.
93 
94  //@name Méthodes pour l'affichage
96 
98  virtual TPrecompile getType() const = 0;
99 
101  void draw();
102 
105  void update();
106 
110  virtual void pick(int, int, CView*);
111 
113 
120  virtual void setParameter(CParameter * AParameter) = 0;
121 
126  virtual CParameter* getParameter() const = 0;
127 
128  //@name Méthodes pour gérer la mise à jour
130 
137  bool needToUpdate();
138 
143  void setToUpdate();
144 
149  void unsetToUpdate();
150 
152 
153  //@name Méthodes pour activer ou désactiver le précompile
155 
160  void enable();
161 
168  void disable();
169 
174  bool isEnabled();
175 
177 
178  //@name Méthodes pour compter le nombre de vue totale contenant ce précompile
180  unsigned int getNbView();
181  void incNbView(unsigned int ADec=1);
182  void decNbView(unsigned int ADec=1);
184 
185  //@name Méthodes pour compter le nombre de vue active contenant ce précompile
187  unsigned int getNbEnabledView();
188  void incNbEnabledView(unsigned int ADec=1);
189  void decNbEnabledView(unsigned int ADec=1);
191 
192 protected:
193 
199  void compileModel();
200 
206  virtual void drawModel() = 0;
207 
208 private:
210  bool FToUpdate;
211 
213  bool FEnable;
214 
216  unsigned int FNbView;
217 
219  unsigned int FNbEnabledView;
220 
222  GLint FCompiledList;
223 };
224 
225 //******************************************************************************
226 #endif // PRECOMPILE_HH
227 //******************************************************************************