28 #include <QtGui/QCloseEvent>
29 #include <QtGui/QMouseEvent>
30 #include <QtGui/QPainter>
32 using namespace GMap3d ;
39 QGLWidget(QGLFormat(QGL::SampleBuffers), parent , 0, Qt::SubWindow),
44 FSelection(selection),
49 parent->addWindow(
this);
56 QGLWidget(parent, share , Qt::SubWindow) ,
57 FViewType(AViewType) ,
61 FSelection(selection),
66 parent->addWindow(
this);
90 case VIEW_XYZ:
return string(
"Vue 3D");
91 case VIEW_XY:
return string(
"Vue XY");
92 case VIEW_XZ:
return string(
"Vue XZ");
93 case VIEW_YZ:
return string(
"Vue YZ");
133 glPushAttrib(GL_ALL_ATTRIB_BITS);
134 glMatrixMode(GL_PROJECTION);
136 glMatrixMode(GL_MODELVIEW);
140 glEnable(GL_DEPTH_TEST);
141 glDepthFunc(GL_LEQUAL);
144 glClearColor(0,0,0, 1);
145 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
151 glMatrixMode(GL_MODELVIEW);
153 glMatrixMode(GL_PROJECTION);
159 p.setPen(Qt::white) ;
173 glViewport(0,0,width,height);
185 glEnable(GL_DEPTH_TEST);
186 glDepthFunc(GL_LEQUAL);
193 glEnable(GL_POLYGON_MODE);
194 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
196 ::glEnable(GL_POLYGON_OFFSET_FILL);
197 ::glPolygonOffset(1.0f,1.0f);
200 static const GLfloat Material_Ks[] = {0.5, 0.5, 0.5, 1.0};
201 static const GLfloat Material_Ke[] = {0.0, 0.0, 0.0, 1.0};
202 static const GLfloat Material_Se = 100;
204 glEnable(GL_COLOR_MATERIAL);
205 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR , Material_Ks);
206 glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION , Material_Ke);
207 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, Material_Se);
210 static const GLfloat Light_Ka[] = {0.1, 0.1, 0.1, 1.0};
211 static const GLfloat Light_Kd[] = {1.0, 1.0, 1.0, 1.0};
212 static const GLfloat Light_Ks[] = {0.5, 0.5, 0.5, 1.0};
214 glLightfv(GL_LIGHT0, GL_AMBIENT , Light_Ka);
215 glLightfv(GL_LIGHT0, GL_DIFFUSE , Light_Kd);
216 glLightfv(GL_LIGHT0, GL_SPECULAR, Light_Ks);
228 GMap3d :: CControlerGMap* controler =
FOwner -> getControler() ;
232 controler->viewAddPrecompile(
FViewId, PRECOMPILE_GRID);
233 controler->viewAddPrecompile(
FViewId, PRECOMPILE_AXIS);
234 controler->viewAddPrecompile(
FViewId, PRECOMPILE_AIMED_POINT);
235 controler->viewAddPrecompile(
FViewId,
236 PRECOMPILE_OBJECT_TRANSFORMATION);
237 controler->viewAddPrecompile(
FViewId, PRECOMPILE_PREVIEW);
238 controler->viewAddPrecompile(
FViewId, PRECOMPILE_NORMAL_VECTOR);
239 controler->viewAddPrecompile(
FViewId, PRECOMPILE_SEW);
240 controler->viewAddPrecompile(
FViewId, PRECOMPILE_VERTEX);
242 controler->viewAddPrecompile(
FViewId, PRECOMPILE_SPAMOD);
243 controler->viewDisablePrecompile(
FViewId, PRECOMPILE_SPAMOD);
244 controler->getParameterSpamod(
FViewId)->setViewMode(SPAMOD_NONE);
245 #endif // MODULE_SPAMOD
246 controler->viewAddPrecompile(
FViewId, PRECOMPILE_DART);
247 controler->viewAddPrecompile(
FViewId, PRECOMPILE_FACE);
249 controler->viewDisablePrecompile(
FViewId, PRECOMPILE_SEW);
250 controler->viewDisablePrecompile(
FViewId, PRECOMPILE_VERTEX);
251 controler->viewDisablePrecompile(
FViewId, PRECOMPILE_FACE);
252 controler->viewDisablePrecompile(
FViewId, PRECOMPILE_NORMAL_VECTOR);
255 controler->loadAllParameters(
FViewId);
259 controler->getParameterAimedPosition(
FViewId)->reinit();
260 controler->getParameterEyePosition(
FViewId)->reinit();
273 CControlerGMap * controler =
FOwner -> getControler() ;
274 int y =
this -> height() - eb -> y() ;
276 if (eb->modifiers() == Qt::ControlModifier)
278 switch (eb -> button())
283 operationModeIndependentStart(MODE_OPERATION_SCENE_TRANSLATION ,
288 operationModeIndependentStart(MODE_OPERATION_SCENE_ROTATION,
291 case Qt::RightButton :
293 operationModeIndependentStart(MODE_OPERATION_SCENE_SCALE,
302 if (eb -> button() == Qt :: LeftButton)
305 setHalfSelectionOrbit(eb -> modifiers() == Qt :: ShiftModifier) ;
306 controler->operationModeStart(
FViewId,
int(eb->x()), y) ;
324 if (controler->getMode() == MODE_OPERATION_SELECTION)
330 if (eb -> modifiers() == Qt :: ShiftModifier)
331 controler -> setModeDeselectionAtStop();
334 else if (eb -> button() == Qt::MidButton)
336 if (controler->isInCreationMode())
346 #ifdef MODULE_ARCHITECTURE
347 FOwner -> getFlapSelection() -> nextLevel();
351 else if (eb -> button() == Qt :: RightButton)
353 FOwner -> getControler() -> lookAtMouseClick(
FViewId, eb -> x(), y);
361 int y =
this -> height() - em -> y() ;
362 FOwner -> getControler() -> operationModeMove(
int (em -> x()), y) ;
373 {
FCurX = int (em -> x());
FCurY = int (em -> y()); }
381 CControlerGMap * controler =
FOwner -> getControler();
383 int y =
this -> height() - eb -> y() ;
385 controler -> operationModeStop(
int(eb->x()), y);
388 if (boite != NULL) boite -> update() ;
391 if (op != NULL) op -> update() ;
399 if (e -> button() == Qt::LeftButton)
401 FOwner -> setDoubleCliquee(
this) ;