Changeset 561 for trunk/geant4/OpenGLQT_exemple/src
- Timestamp:
- Aug 14, 2007, 12:27:44 PM (17 years ago)
- Location:
- trunk/geant4/OpenGLQT_exemple/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/geant4/OpenGLQT_exemple/src/glwidget.cpp
r549 r561 7 7 8 8 GLWidget::GLWidget(QWidget *parent) 9 : QGLWidget( parent)9 : QGLWidget() 10 10 { 11 11 printf("GLWidget::GLWidget \n"); … … 20 20 } 21 21 22 void GLWidget::initialize() { 23 printf("GLWidget::Initialise \n"); 24 } 25 22 26 GLWidget::~GLWidget() 23 27 { … … 28 32 } 29 33 30 QSize GLWidget::minimumSizeHint() const 31 { 32 printf("GLWidget::minimumSizeHint \n"); 33 return QSize(50, 50); 34 } 35 36 QSize GLWidget::sizeHint() const 37 { 38 printf("GLWidget::SizeHint \n"); 39 return QSize(400, 400); 40 } 41 42 // void GLWidget::setXRotation(int angle) 34 // QSize GLWidget::minimumSizeHint() const 43 35 // { 44 // normalizeAngle(&angle); 45 // if (angle != xRot) { 46 // xRot = angle; 47 // emit xRotationChanged(angle); 48 // updateGL(); 49 // } 36 // printf("GLWidget::minimumSizeHint \n"); 37 // return QSize(50, 50); 50 38 // } 51 39 52 // void GLWidget::setYRotation(int angle)40 // QSize GLWidget::sizeHint() const 53 41 // { 54 // normalizeAngle(&angle); 55 // if (angle != yRot) { 56 // yRot = angle; 57 // emit yRotationChanged(angle); 58 // updateGL(); 59 // } 42 // printf("GLWidget::SizeHint \n"); 43 // return QSize(400, 400); 60 44 // } 61 45 62 // void GLWidget::setZRotation(int angle) 63 // { 64 // normalizeAngle(&angle); 65 // if (angle != zRot) { 66 // zRot = angle; 67 // emit zRotationChanged(angle); 68 // updateGL(); 69 // } 70 // } 46 void GLWidget::setXRotation(int angle) 47 { 48 normalizeAngle(&angle); 49 if (angle != xRot) { 50 xRot = angle; 51 // emit xRotationChanged(angle); 52 updateGL(); 53 } 54 } 55 56 void GLWidget::setYRotation(int angle) 57 { 58 normalizeAngle(&angle); 59 if (angle != yRot) { 60 yRot = angle; 61 // emit yRotationChanged(angle); 62 updateGL(); 63 } 64 } 65 66 void GLWidget::setZRotation(int angle) 67 { 68 normalizeAngle(&angle); 69 if (angle != zRot) { 70 zRot = angle; 71 // emit zRotationChanged(angle); 72 updateGL(); 73 } 74 } 71 75 72 76 void GLWidget::initializeGL() … … 87 91 glLoadIdentity(); 88 92 glTranslated(0.0, 0.0, -10.0); 89 glRotated(xRot / 16 .0, 1.0, 0.0, 0.0);90 glRotated(yRot / 16 .0, 0.0, 1.0, 0.0);91 glRotated(zRot / 16 .0, 0.0, 0.0, 1.0);93 glRotated(xRot / 16, 1.0, 0.0, 0.0); 94 glRotated(yRot / 16, 0.0, 1.0, 0.0); 95 glRotated(zRot / 16, 0.0, 0.0, 1.0); 92 96 glCallList(object); 93 97 printf("GLWidget::paintGL END\n"); … … 102 106 glMatrixMode(GL_PROJECTION); 103 107 glLoadIdentity(); 104 glOrtho(- 0.5, +0.5, +0.5, -0.5, 4.0, 15.0);108 glOrtho(-1., +1., -1., +1., -10., 15.0); 105 109 glMatrixMode(GL_MODELVIEW); 106 110 printf("GLWidget::resizeGL END\n"); 107 111 } 108 112 109 // void GLWidget::mousePressEvent(QMouseEvent *event) 110 // { 111 // lastPos = event->pos(); 112 // } 113 114 // void GLWidget::mouseMoveEvent(QMouseEvent *event) 115 // { 116 // int dx = event->x() - lastPos.x(); 117 // int dy = event->y() - lastPos.y(); 118 119 // if (event->buttons() & Qt::LeftButton) { 120 // setXRotation(xRot + 8 * dy); 121 // setYRotation(yRot + 8 * dx); 122 // } else if (event->buttons() & Qt::RightButton) { 123 // setXRotation(xRot + 8 * dy); 124 // setZRotation(zRot + 8 * dx); 125 // } 126 // lastPos = event->pos(); 127 // } 113 void GLWidget::mousePressEvent(QMouseEvent *event) 114 { 115 printf("GLWidget::mousePress \n"); 116 lastPos = event->pos(); 117 printf("GLWidget::mousePress END\n"); 118 } 119 120 void GLWidget::mouseMoveEvent(QMouseEvent *event) 121 { 122 printf("GLWidget::mouseEvent \n"); 123 int dx = event->x() - lastPos.x(); 124 int dy = event->y() - lastPos.y(); 125 126 if (event->buttons() & Qt::LeftButton) { 127 printf("GLWidget::mouseEvent Left 1\n"); 128 setXRotation(xRot + 8 * dy); 129 printf("GLWidget::mouseEvent Left 2\n"); 130 setYRotation(yRot + 8 * dx); 131 printf("GLWidget::mouseEvent Left 3\n"); 132 } else if (event->buttons() & Qt::RightButton) { 133 printf("GLWidget::mouseEvent Right 1\n"); 134 setXRotation(xRot + 8 * dy); 135 printf("GLWidget::mouseEvent Right 2\n"); 136 setZRotation(zRot + 8 * dx); 137 printf("GLWidget::mouseEvent Right 3\n"); 138 } 139 lastPos = event->pos(); 140 printf("GLWidget::mouseEvent END\n"); 141 } 128 142 129 143 GLuint GLWidget::makeObject() -
trunk/geant4/OpenGLQT_exemple/src/glwidget.h
r548 r561 11 11 GLWidget(QWidget *parent = 0); 12 12 ~GLWidget(); 13 void initializeGL(); 14 void initialize(); 15 void resizeGL(int width, int height); 16 void paintGL(); 13 17 14 QSize minimumSizeHint() const; 15 QSize sizeHint() const; 18 /* QSize minimumSizeHint() const; */ 19 /* QSize sizeHint() const; */ 16 20 17 /* public slots: */ 18 /* void setXRotation(int angle); */ 19 /* void setYRotation(int angle); */ 20 /* void setZRotation(int angle); */ 21 protected: 22 void setXRotation(int angle); 23 void setYRotation(int angle); 24 void setZRotation(int angle); 21 25 22 26 /* signals: */ … … 25 29 /* void zRotationChanged(int angle); */ 26 30 27 protected: 28 void initializeGL(); 29 void paintGL(); 30 void resizeGL(int width, int height); 31 /* void mousePressEvent(QMouseEvent *event); */ 32 /* void mouseMoveEvent(QMouseEvent *event); */ 31 void mousePressEvent(QMouseEvent*); 32 void mouseMoveEvent(QMouseEvent*); 33 void normalizeAngle(int *angle); 33 34 34 35 private: … … 37 38 GLdouble x3, GLdouble y3, GLdouble x4, GLdouble y4); 38 39 void extrude(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2); 39 void normalizeAngle(int *angle);40 40 41 41 GLuint object; … … 43 43 int yRot; 44 44 int zRot; 45 float reelXRot; 46 float realYRot; 47 float realZRot; 45 48 QPoint lastPos; 46 49 QColor trolltechGreen; -
trunk/geant4/OpenGLQT_exemple/src/window.cpp
r549 r561 4 4 #include "window.h" 5 5 6 Window::Window()6 Window::Window(): QDialog(0,Qt::Dialog) 7 7 { 8 8 printf("Window::Window 1\n"); … … 22 22 23 23 QHBoxLayout *mainLayout = new QHBoxLayout; 24 24 25 mainLayout->addWidget(glWidget); 25 26 printf("Window::Window 3\n"); … … 51 52 // return slider; 52 53 // } 54 55 void Window::mousePressEvent(QMouseEvent *event) 56 { 57 printf("Window::mousePressEvent \n"); 58 } 59 60 void Window::mouseReleaseEvent(QMouseEvent *event) 61 { 62 printf("Window::mouseReleaseEvent \n"); 63 } 64 65 void Window::mouseMoveEvent(QMouseEvent *event) 66 { 67 printf("Window::mouseMoveEvent \n"); 68 // int dx = event->x() - lastPos.x(); 69 // int dy = event->y() - lastPos.y(); 70 71 // if (event->buttons() & Qt::LeftButton) { 72 // } else if (event->buttons() & Qt::RightButton) { 73 // } 74 } -
trunk/geant4/OpenGLQT_exemple/src/window.h
r548 r561 3 3 4 4 #include <QWidget> 5 #include <QMenuBar> 6 #include <QDialog> 5 7 6 8 class QSlider; 7 9 class GLWidget; 8 10 9 class Window : public Q Widget11 class Window : public QDialog 10 12 { 11 /* Q_OBJECT */ 13 Q_OBJECT 12 14 13 15 public: … … 15 17 16 18 private: 19 void mousePressEvent(QMouseEvent*); 20 void mouseReleaseEvent(QMouseEvent*); 21 void mouseMoveEvent(QMouseEvent*); 17 22 /* QSlider *createSlider(); */ 18 23 19 GLWidget *glWidget; 24 GLWidget *glWidget; 25 QMenuBar *menuBar; 26 20 27 /* QSlider *xSlider; */ 21 28 /* QSlider *ySlider; */
Note: See TracChangeset
for help on using the changeset viewer.