Ignore:
Timestamp:
Aug 14, 2007, 12:27:44 PM (17 years ago)
Author:
garnier
Message:

r563@mac-90108: laurentgarnier | 2007-08-14 12:28:16 +0200
mise a jour suite au plantage de svk (cheksum error) suite au crash du DD en juin

Location:
trunk/geant4/OpenGLQT_exemple/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/geant4/OpenGLQT_exemple/src/glwidget.cpp

    r549 r561  
    77
    88 GLWidget::GLWidget(QWidget *parent)
    9      : QGLWidget(parent)
     9     : QGLWidget()
    1010 {
    1111   printf("GLWidget::GLWidget \n");
     
    2020 }
    2121
     22 void  GLWidget::initialize() {
     23   printf("GLWidget::Initialise \n");
     24 }
     25
    2226 GLWidget::~GLWidget()
    2327 {
     
    2832 }
    2933
    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
    4335//  {
    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);
    5038//  }
    5139
    52 //  void GLWidget::setYRotation(int angle)
     40//  QSize GLWidget::sizeHint() const
    5341//  {
    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);
    6044//  }
    6145
    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 }
    7175
    7276 void GLWidget::initializeGL()
     
    8791     glLoadIdentity();
    8892     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);
    9296     glCallList(object);
    9397   printf("GLWidget::paintGL END\n");
     
    102106     glMatrixMode(GL_PROJECTION);
    103107     glLoadIdentity();
    104      glOrtho(-0.5, +0.5, +0.5, -0.5, 4.0, 15.0);
     108     glOrtho(-1., +1., -1., +1., -10., 15.0);
    105109     glMatrixMode(GL_MODELVIEW);
    106110   printf("GLWidget::resizeGL END\n");
    107111 }
    108112
    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 }
    128142
    129143 GLuint GLWidget::makeObject()
  • trunk/geant4/OpenGLQT_exemple/src/glwidget.h

    r548 r561  
    1111     GLWidget(QWidget *parent = 0);
    1212     ~GLWidget();
     13     void initializeGL();
     14     void initialize();
     15     void resizeGL(int width, int height);
     16     void paintGL();
    1317
    14      QSize minimumSizeHint() const;
    15      QSize sizeHint() const;
     18/*      QSize minimumSizeHint() const; */
     19/*      QSize sizeHint() const; */
    1620
    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);
    2125
    2226/*  signals: */
     
    2529/*      void zRotationChanged(int angle); */
    2630
    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);
    3334
    3435 private:
     
    3738               GLdouble x3, GLdouble y3, GLdouble x4, GLdouble y4);
    3839     void extrude(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2);
    39      void normalizeAngle(int *angle);
    4040
    4141     GLuint object;
     
    4343     int yRot;
    4444     int zRot;
     45     float reelXRot;
     46     float realYRot;
     47     float realZRot;
    4548     QPoint lastPos;
    4649     QColor trolltechGreen;
  • trunk/geant4/OpenGLQT_exemple/src/window.cpp

    r549 r561  
    44 #include "window.h"
    55
    6  Window::Window()
     6Window::Window(): QDialog(0,Qt::Dialog)
    77 {
    88   printf("Window::Window 1\n");
     
    2222
    2323     QHBoxLayout *mainLayout = new QHBoxLayout;
     24
    2425     mainLayout->addWidget(glWidget);
    2526   printf("Window::Window 3\n");
     
    5152//      return slider;
    5253//  }
     54
     55void Window::mousePressEvent(QMouseEvent *event)
     56{
     57  printf("Window::mousePressEvent \n");
     58}
     59
     60void Window::mouseReleaseEvent(QMouseEvent *event)
     61{
     62  printf("Window::mouseReleaseEvent \n");
     63}
     64
     65void 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  
    33
    44 #include <QWidget>
     5 #include <QMenuBar>
     6 #include <QDialog>
    57
    68 class QSlider;
    79 class GLWidget;
    810
    9  class Window : public QWidget
     11 class Window : public QDialog
    1012 {
    11 /*      Q_OBJECT */
     13      Q_OBJECT
    1214
    1315 public:
     
    1517
    1618 private:
     19  void mousePressEvent(QMouseEvent*);
     20  void mouseReleaseEvent(QMouseEvent*);
     21  void mouseMoveEvent(QMouseEvent*);
    1722/*      QSlider *createSlider(); */
    1823
    19      GLWidget *glWidget;
     24  GLWidget *glWidget;
     25  QMenuBar *menuBar;
     26
    2027/*      QSlider *xSlider; */
    2128/*      QSlider *ySlider; */
Note: See TracChangeset for help on using the changeset viewer.