Changeset 800 for trunk/geant4/visualization/OpenGL
- Timestamp:
- May 15, 2008, 6:52:17 PM (16 years ago)
- Location:
- trunk/geant4/visualization/OpenGL
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/geant4/visualization/OpenGL/include/G4OpenGLQtViewer.hh
r798 r800 71 71 virtual ~G4OpenGLQtViewer (); 72 72 void SetView (); 73 void ClearView (); 73 74 void ShowView (); 74 75 virtual void updateQWidget()=0; … … 118 119 void savePPMToTemp(); 119 120 int fRecordFrameNumber; 121 float fRotationAngleX; 122 float fRotationAngleY; 123 float fRotationAngleZ; 120 124 121 125 private: … … 187 191 int fSpinningDelay; 188 192 int fLaunchSpinDelay; 193 float fDeltaRotationAngleX; 194 float fDeltaRotationAngleY; 195 float fDeltaRotationAngleZ; 189 196 190 197 private slots : -
trunk/geant4/visualization/OpenGL/src/G4OpenGLQtViewer.cc
r799 r800 40 40 #include "G4OpenGLQtViewer.hh" 41 41 42 #include <cmath> 42 43 #include "G4ios.hh" 43 44 #include "G4VisExtent.hh" … … 93 94 // fWindow->makeCurrent(); 94 95 G4OpenGLViewer::SetView (); 96 } 97 98 void 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; 95 111 } 96 112 … … 304 320 ,fProcess(NULL) 305 321 ,fLaunchSpinDelay(100) 322 ,fRotationAngleX(0) 323 ,fRotationAngleY(0) 324 ,fDeltaRotationAngleX(0) 325 ,fDeltaRotationAngleY(0) 306 326 { 307 327 … … 1545 1565 int cycles = 4; 1546 1566 while (fAutoMove) { 1547 if ( lastMoveTime.elapsed() > (fSpinningDelay / (cycles/2))) {1567 // if ( lastMoveTime.elapsed() > (fSpinningDelay / (cycles/2))) { 1548 1568 if (fMouseAction == STYLE1) { // rotate 1549 1569 rotateQtScene(((float)delta.x())/cycles,((float)delta.y())/cycles); … … 1553 1573 lastMoveTime.start(); 1554 1574 cycles = 1 ; 1555 }1575 // } 1556 1576 ((QApplication*)G4Qt::getInstance ())->processEvents(); 1577 #ifdef GEANT4_QT_DEBUG 1578 printf("G4OpenGLQtViewer::mouseRealease() cycle :%d \n",lastMoveTime.elapsed()); 1579 #endif 1557 1580 cycles ++ ; 1558 1581 } … … 1582 1605 fLastPos2 = fLastPos1; 1583 1606 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 1585 1626 if (fMouseAction == STYLE1) { // rotate 1586 1627 if (mButtons & Qt::LeftButton) { … … 1641 1682 return; 1642 1683 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 1646 1689 updateQWidget(); 1647 1690 … … 1660 1703 fHoldRotateEvent = true; 1661 1704 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); 1663 1728 updateQWidget(); 1664 1729 -
trunk/geant4/visualization/OpenGL/src/G4OpenGLStoredQtViewer.cc
r799 r800 122 122 123 123 #ifdef GEANT4_QT_DEBUG 124 printf("G4OpenGLQtViewer::setupViewport\n"); 125 #endif 126 #ifdef GEANT4_QT_DEBUG 124 127 printf("G4OpenGLStoredQtViewer::DrawView %d %d VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n",WinSize_x, WinSize_y); 125 128 #endif -
trunk/geant4/visualization/OpenGL/src/G4OpenGLViewer.cc
r799 r800 934 934 } else { 935 935 #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()); 937 937 #endif 938 938 new_up = up; 939 939 if (new_vp.z()*vp.z() <0) { 940 940 #ifdef GEANT4_QT_DEBUG 941 printf("G4OpenGLViewer:: ***********************************************************\n");941 // printf("G4OpenGLViewer:: ***********************************************************\n"); 942 942 #endif 943 943 new_up.set(new_up.x(),-new_up.y(),new_up.z());
Note: See TracChangeset
for help on using the changeset viewer.