Changeset 800


Ignore:
Timestamp:
May 15, 2008, 6:52:17 PM (16 years ago)
Author:
garnier
Message:

r838@wl-72126: garnier | 2008-05-15 18:52:11 +0200
en test avec les glRotation

Location:
trunk/geant4/visualization/OpenGL
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/geant4/visualization/OpenGL/include/G4OpenGLQtViewer.hh

    r798 r800  
    7171  virtual ~G4OpenGLQtViewer ();
    7272  void SetView ();
     73  void ClearView ();
    7374  void ShowView ();
    7475  virtual void updateQWidget()=0;
     
    118119  void savePPMToTemp();
    119120  int fRecordFrameNumber;
     121  float fRotationAngleX;
     122  float fRotationAngleY;
     123  float fRotationAngleZ;
    120124
    121125private:
     
    187191  int fSpinningDelay;
    188192  int fLaunchSpinDelay;
     193  float fDeltaRotationAngleX;
     194  float fDeltaRotationAngleY;
     195  float fDeltaRotationAngleZ;
    189196
    190197private slots :
  • trunk/geant4/visualization/OpenGL/src/G4OpenGLQtViewer.cc

    r799 r800  
    4040#include "G4OpenGLQtViewer.hh"
    4141
     42#include <cmath>
    4243#include "G4ios.hh"
    4344#include "G4VisExtent.hh"
     
    9394  //  fWindow->makeCurrent();
    9495  G4OpenGLViewer::SetView ();
     96}
     97
     98void G4OpenGLQtViewer::ClearView (
     99)
     100//////////////////////////////////////////////////////////////////////////////
     101//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
     102{
     103  G4OpenGLViewer::ClearView ();
     104  //  glLoadIdentity();
     105  glRotatef(fRotationAngleX, 1.0, 0.0, 0.0);
     106  glRotatef(fRotationAngleY, 0.0, 1.0, 0.0);
     107  glRotatef(fRotationAngleZ, 0.0, 0.0, 1.0);
     108  fRotationAngleZ +=fDeltaRotationAngleZ;
     109  fRotationAngleY +=fDeltaRotationAngleY;
     110  fRotationAngleX +=fDeltaRotationAngleX;
    95111}
    96112
     
    304320  ,fProcess(NULL)
    305321  ,fLaunchSpinDelay(100)
     322  ,fRotationAngleX(0)
     323  ,fRotationAngleY(0)
     324  ,fDeltaRotationAngleX(0)
     325  ,fDeltaRotationAngleY(0)
    306326{
    307327
     
    15451565    int cycles = 4;
    15461566    while (fAutoMove) {
    1547       if ( lastMoveTime.elapsed() > (fSpinningDelay / (cycles/2))) {
     1567      //      if ( lastMoveTime.elapsed() > (fSpinningDelay / (cycles/2))) {
    15481568        if (fMouseAction == STYLE1) {  // rotate
    15491569          rotateQtScene(((float)delta.x())/cycles,((float)delta.y())/cycles);
     
    15531573        lastMoveTime.start();
    15541574        cycles = 1 ;
    1555       }
     1575        //      }
    15561576      ((QApplication*)G4Qt::getInstance ())->processEvents();
     1577#ifdef GEANT4_QT_DEBUG
     1578        printf("G4OpenGLQtViewer::mouseRealease() cycle :%d \n",lastMoveTime.elapsed());
     1579#endif
    15571580      cycles ++ ;
    15581581    }
     
    15821605  fLastPos2 = fLastPos1;
    15831606  fLastPos1 = QPoint(pos_x, pos_y);
    1584  
     1607  int deltaX = fLastPos2.x()-fLastPos1.x();
     1608  int deltaY = fLastPos2.y()-fLastPos1.y();
     1609
     1610  // try to get the x,y mouve into user friendly rotation
     1611
     1612  float cox = std::cos ((fRotationAngleX*M_PI)/180);
     1613  float coy = std::cos ((fRotationAngleY*M_PI)/180);
     1614  float coz = 1;
     1615  float six = std::sin ((fRotationAngleX*M_PI)/180);
     1616  float siy = std::sin ((fRotationAngleY*M_PI)/180);
     1617  float siz = 0;
     1618
     1619  float dx = coy*(siz*deltaY+coz*deltaX);
     1620  float dy = six*(siy*(siz*deltaY+coz*deltaX))+cox*(coz*deltaY-siz*deltaX);
     1621  float dz = cox*(siy*(siz*deltaY+coz*deltaX))-six*(coz*deltaY-siz*deltaX);
     1622 
     1623#ifdef GEANT4_QT_DEBUG
     1624  printf("G4OpenGLQtViewer::MouseMove %d,%d Rot:%f,%f new : %f %f %f\n",deltaX,deltaY,fRotationAngleX,fRotationAngleY,dx,dy,dz);
     1625#endif
    15851626  if (fMouseAction == STYLE1) {  // rotate
    15861627    if (mButtons & Qt::LeftButton) {
     
    16411682    return;
    16421683  fHoldRotateEvent = true;
    1643 
    1644   rotateScene(dx,0,fDeltaRotation);
    1645   rotateScene(0,dy,fDeltaRotation);
     1684  fDeltaRotationAngleX = dx;
     1685  fDeltaRotationAngleY = dy;
     1686  //  rotateScene(dx,0,fDeltaRotation);
     1687  //  rotateScene(0,dy,fDeltaRotation);
     1688
    16461689  updateQWidget();
    16471690 
     
    16601703  fHoldRotateEvent = true;
    16611704
    1662   rotateScene(dx,dy,fDeltaRotation);
     1705  fDeltaRotationAngleX = dx;
     1706  fDeltaRotationAngleY = dy;
     1707
     1708  float cox = std::cos ((fRotationAngleX*M_PI)/180);
     1709  float coy = std::cos ((fRotationAngleY*M_PI)/180);
     1710  float coz = 1;
     1711  float six = std::sin ((fRotationAngleX*M_PI)/180);
     1712  float siy = std::sin ((fRotationAngleY*M_PI)/180);
     1713  float siz = 0;
     1714
     1715  float dx2 = coy*(siz*dy+coz*dx);
     1716  float dy2 = six*(siy*(siz*dy+coz*dx))+cox*(coz*dy-siz*dx);
     1717  float dz2 = cox*(siy*(siz*dy+coz*dx))-six*(coz*dy-siz*dx);
     1718 
     1719#ifdef GEANT4_QT_DEBUG
     1720  printf("G4OpenGLQtViewer::MouseMove %f,%f Rot:%f,%f new : %f %f %f\n",dx,dy,fRotationAngleX,fRotationAngleY,dx2,dy2,dz2);
     1721#endif
     1722
     1723  fDeltaRotationAngleX = dx2;
     1724  fDeltaRotationAngleY = dy2;
     1725  fDeltaRotationAngleZ = dz2;
     1726
     1727  //  rotateScene(dx,dy,fDeltaRotation);
    16631728  updateQWidget();
    16641729 
  • trunk/geant4/visualization/OpenGL/src/G4OpenGLStoredQtViewer.cc

    r799 r800  
    122122
    123123#ifdef GEANT4_QT_DEBUG
     124  printf("G4OpenGLQtViewer::setupViewport\n");
     125#endif
     126#ifdef GEANT4_QT_DEBUG
    124127  printf("G4OpenGLStoredQtViewer::DrawView %d %d   VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n",WinSize_x, WinSize_y);
    125128#endif
  • trunk/geant4/visualization/OpenGL/src/G4OpenGLViewer.cc

    r799 r800  
    934934  } else {
    935935#ifdef GEANT4_QT_DEBUG
    936     printf("G4OpenGLViewer:: %f %f %f - %f %f %f \n",up.x(),up.y(),up.z(),new_vp.x(),new_vp.y(),new_vp.z());
     936    //    printf("G4OpenGLViewer:: %f %f %f - %f %f %f \n",up.x(),up.y(),up.z(),new_vp.x(),new_vp.y(),new_vp.z());
    937937#endif
    938938    new_up = up;
    939939    if (new_vp.z()*vp.z() <0) {
    940940#ifdef GEANT4_QT_DEBUG
    941       printf("G4OpenGLViewer:: ***********************************************************\n");
     941      //      printf("G4OpenGLViewer:: ***********************************************************\n");
    942942#endif
    943943      new_up.set(new_up.x(),-new_up.y(),new_up.z());
Note: See TracChangeset for help on using the changeset viewer.