iCub-main
animationview.h
Go to the documentation of this file.
1 /*
2 * animationview.h
3 */
4 
5 /*
6 * Copyright (C) 2009 RobotCub Consortium
7 * Author: Alessandro Scalzo alessandro.scalzo@iit.it
8 * CopyPolicy: Released under the terms of the GNU GPL v2.0.
9 *
10 * Based on:
11 *
12 * Qavimator
13 * Copyright (C) 2006 by Zi Ree *
14 * Zi Ree @ SecondLife *
15 * Released under the terms of the GNU GPL v2.0.
16 */
17 
18 #ifndef ANIMATIONVIEW_H
19 #define ANIMATIONVIEW_H
20 
21 #include <QtOpenGL/qgl.h>
22 #include <qtimer.h>
23 
24 #include "camera.h"
25 #include "bvh.h"
26 #include "objectsthread.h"
27 #include "subtitilessthread.h"
28 
29 
30 //#include "rotation.h"
31 //#include "prop.h"
32 
33 // defines where we start counting opengl ids for parts with multiple animations
34 // first animation counts 0-ANIMATION_INCREMENT-1, next ANIMATION_INCREMENT++
35 #define ANIMATION_INCREMENT 100
36 
37 #define OBJECT_START 8000
38 
39 #define DRAG_HANDLE_START OBJECT_START+1000
40 #define DRAG_HANDLE_X DRAG_HANDLE_START
41 #define DRAG_HANDLE_Y DRAG_HANDLE_START+1
42 #define DRAG_HANDLE_Z DRAG_HANDLE_START+2
43 #define SCALE_HANDLE_X DRAG_HANDLE_START+3
44 #define SCALE_HANDLE_Y DRAG_HANDLE_START+4
45 #define SCALE_HANDLE_Z DRAG_HANDLE_START+5
46 #define ROTATE_HANDLE_X DRAG_HANDLE_START+6
47 #define ROTATE_HANDLE_Y DRAG_HANDLE_START+7
48 #define ROTATE_HANDLE_Z DRAG_HANDLE_START+8
49 
50 class QMouseEvent;
51 
52 class AnimationView : public QGLWidget
53 {
54  Q_OBJECT
55 
56 public:
57  AnimationView(QWidget* parent);
59 
60  // This function clears the animations
61  void clear();
62  void init(yarp::os::ResourceFinder& config);
63 
64  void startTimer(int msec)
65  {
66  mTimer.start(msec);
67  }
68  void stopTimer()
69  {
70  mTimer.stop();
71  }
72 
73  QStringList& partNames(){ return pBVH->partNames; }
74 
75 signals:
77 
78  public slots:
79  void resetCamera();
80  void timerTimeout(){ repaint(); }
81 
82  protected slots:
83  void draw();
84 
85 protected:
86  //enum { MODE_PARTS, MODE_SKELETON, MODE_ROT_AXES };
87 
88  virtual void paintGL();
89  virtual void paintOverlayGL();
90  virtual void initializeGL();
91  virtual void mouseMoveEvent(QMouseEvent* event);
92  virtual void mousePressEvent(QMouseEvent* event);
93  virtual void mouseReleaseEvent(QMouseEvent* event);
94  virtual void mouseDoubleClickEvent(QMouseEvent* event);
95  virtual void wheelEvent(QWheelEvent* event);
96  virtual void keyPressEvent(QKeyEvent* event);
97  virtual void keyReleaseEvent(QKeyEvent* event);
98  virtual void resizeEvent(QResizeEvent* newSize);
99 
100  void drawFloor();
101 
103  char modifier;
104 
106 
107  QTimer mTimer;
111 
112  QPoint clickPos; // holds the mouse click position for dragging
113  QPoint returnPos; // holds the mouse position to return to after dragging
114 
117 
118  int dragX, dragY; // holds the last mouse drag offset
119  int oldDragX, oldDragY; // holds the mouse position before the last drag
120 
121  int drawMode;
123 
124  void setProjection();
125  void setModelView();
126 
128  void drawCircle(int axis, float radius, int width);
129 };
130 
131 #endif
void timerTimeout()
Definition: animationview.h:80
virtual void keyReleaseEvent(QKeyEvent *event)
void clearSelected()
QStringList & partNames()
Definition: animationview.h:73
void backgroundClicked()
SubtitlesManager * mSubtitlesManager
virtual void keyPressEvent(QKeyEvent *event)
virtual void mouseDoubleClickEvent(QMouseEvent *event)
AnimationView(QWidget *parent)
void stopTimer()
Definition: animationview.h:68
virtual void wheelEvent(QWheelEvent *event)
virtual void paintGL()
virtual void mouseMoveEvent(QMouseEvent *event)
virtual void mousePressEvent(QMouseEvent *event)
void startTimer(int msec)
Definition: animationview.h:64
virtual void initializeGL()
void drawCircle(int axis, float radius, int width)
ObjectsManager * mObjectsManager
virtual void paintOverlayGL()
virtual void mouseReleaseEvent(QMouseEvent *event)
virtual void resizeEvent(QResizeEvent *newSize)
void init(yarp::os::ResourceFinder &config)
void setModelView()
Definition: bvh.h:59
QStringList partNames
Definition: bvh.h:65
Definition: camera.h:22