Changeset 1332 for trunk/source/visualization/OpenGL
- Timestamp:
- Aug 3, 2010, 4:21:16 PM (14 years ago)
- Location:
- trunk/source/visualization/OpenGL
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/visualization/OpenGL/include/G4OpenGLQtViewer.hh
r1307 r1332 116 116 void rotateQtScene(float, float); 117 117 void rotateQtCamera(float, float); 118 void rotateQtSceneInViewDirection(float, float); 119 void rotateQtCameraInViewDirection(float, float); 118 120 void moveScene(float, float, float,bool); 119 121 void FinishView(); … … 198 200 int fLaunchSpinDelay; 199 201 202 G4double fXRot; 203 G4double fYRot; 204 200 205 signals: 201 206 void rotateTheta(int); -
trunk/source/visualization/OpenGL/include/G4OpenGLViewer.hh
r1046 r1332 70 70 virtual void CreateFontLists () {} 71 71 void rotateScene (G4double dx, G4double dy,G4double delta); 72 void rotateSceneInViewDirection (G4double dx, G4double dy,G4double delta); 72 73 //////////////////////////////Vectored PostScript production functions/// 73 74 void printEPS(); -
trunk/source/visualization/OpenGL/src/G4OpenGLQtViewer.cc
r1324 r1332 242 242 ,fNbMaxAnglePerSec(360) 243 243 ,fLaunchSpinDelay(100) 244 ,fXRot(0) 245 ,fYRot(0) 244 246 { 245 247 … … 950 952 if (fMouseAction == STYLE1) { // rotate 951 953 G4cout << "Click and move mouse to rotate volume " << G4endl; 952 G4cout << "Press left/right arrows to move volume left/right" << G4endl;953 G4cout << "Press up/down arrows to move volume up/down" << G4endl;954 G4cout << "Press ALT+up/down arrows to move volume toward/forward" << G4endl;955 G4cout << "Press SHIFT+left/right arrows to rotate volume left/right" << G4endl;956 G4cout << "Press SHIFT+up/down arrows to rotate volume up/down" << G4endl;957 G4cout << "Press ALT+/- to slow/speed auto rotation/move" << G4endl;958 G4cout << "In video mode : " << G4endl;959 G4cout << " Press SPACE to Start/Pause video recording " << G4endl;960 G4cout << " Press RETURN to Stop video recording " << G4endl;961 954 } else if (fMouseAction == STYLE2) { //move 962 955 G4cout << "Move camera point of view with mouse" << G4endl; 963 G4cout << "Press left/right arrows to move volume left/right" << G4endl;964 G4cout << "Press up/down arrows to move volume up/down" << G4endl;965 G4cout << "Press ALT+up/down arrows to move volume toward/forward" << G4endl;966 G4cout << "Press SHIFT+left/right arrows to rotate volume left/right" << G4endl;967 G4cout << "Press SHIFT+up/down arrows to rotate volume up/down" << G4endl;968 G4cout << "Press +/- to zoom into volume" << G4endl;969 G4cout << "Press ALT+/- to slow/speed auto rotation/move" << G4endl;970 G4cout << "In video mode : " << G4endl;971 G4cout << " Press SPACE to Start/Pause video recording " << G4endl;972 G4cout << " Press RETURN to Stop video recording " << G4endl;973 956 } else if (fMouseAction == STYLE3) { //pick 974 957 G4cout << "Click and pick " << G4endl; 975 } else { 976 G4cout << "Move camera point of view with mouse" << G4endl; 977 G4cout << "Press left/right arrows to move volume left/right" << G4endl; 978 G4cout << "Press up/down arrows to move volume up/down" << G4endl; 979 G4cout << "Press ALT+up/down arrows to move volume toward/forward" << G4endl; 980 G4cout << "Press SHIFT+left/right arrows to rotate volume left/right" << G4endl; 981 G4cout << "Press SHIFT+up/down arrows to rotate volume up/down" << G4endl; 982 G4cout << "Press +/- to zoom into volume" << G4endl; 983 G4cout << "Press ALT+/- to slow/speed auto rotation/move" << G4endl; 984 G4cout << "In video mode : " << G4endl; 985 G4cout << " Press SPACE to Start/Pause video recording " << G4endl; 986 G4cout << " Press RETURN to Stop video recording " << G4endl; 987 } 988 958 } 959 G4cout << "========= Move Shortcuts =========" << G4endl; 960 G4cout << "Press left/right arrows to move volume left/right" << G4endl; 961 G4cout << "Press up/down arrows to move volume up/down" << G4endl; 962 G4cout << "Press '+'/'-' to move volume toward/forward" << G4endl; 963 G4cout << G4endl; 964 G4cout << "========= Rotation (Theta/Phi) Shortcuts =========" << G4endl; 965 G4cout << "Press SHIFT + left/right arrows to rotate volume left/right" << G4endl; 966 G4cout << "Press SHIFT + up/down arrows to rotate volume up/down" << G4endl; 967 G4cout << G4endl; 968 G4cout << "========= Rotation (View Direction) Shortcuts =========" << G4endl; 969 G4cout << "Press ALT + left/right to rotate volume around vertical direction" << G4endl; 970 G4cout << "Press ALT + up/down to rotate volume around horizontal direction" << G4endl; 971 G4cout << G4endl; 972 G4cout << "========= Zoom View =========" << G4endl; 973 G4cout << "Press CTRL + '+'/'-' to zoom into volume" << G4endl; 974 G4cout << G4endl; 975 G4cout << "========= Misc =========" << G4endl; 976 G4cout << "Press ALT +/- to slow/speed auto rotation/move" << G4endl; 977 G4cout << "Press H to reset view" << G4endl; 978 G4cout << "Press Esc to exit FullScreen" << G4endl; 979 G4cout << G4endl; 980 G4cout << "========= Video =========" << G4endl; 981 G4cout << "In video mode : " << G4endl; 982 G4cout << " Press SPACE to Start/Pause video recording " << G4endl; 983 G4cout << " Press RETURN to Stop video recording " << G4endl; 984 G4cout << G4endl; 989 985 } 990 986 … … 1638 1634 */ 1639 1635 1636 void G4OpenGLQtViewer::rotateQtSceneInViewDirection(float dx, float dy) 1637 { 1638 if (fHoldRotateEvent) 1639 return; 1640 fHoldRotateEvent = true; 1641 1642 fXRot +=dx; 1643 fYRot +=dy; 1644 1645 rotateSceneInViewDirection(dx,dy,fDeltaRotation/100); 1646 1647 emit rotateTheta(static_cast<int>(dx)); 1648 emit rotatePhi(static_cast<int>(dy)); 1649 updateQWidget(); 1650 1651 fHoldRotateEvent = false; 1652 } 1653 1654 /** 1655 @param dx delta mouse x position 1656 @param dy delta mouse y position 1657 */ 1658 1640 1659 void G4OpenGLQtViewer::rotateQtCamera(float dx, float dy) 1641 1660 { … … 1651 1670 fHoldRotateEvent = false; 1652 1671 } 1672 1673 /** 1674 @param dx delta mouse x position 1675 @param dy delta mouse y position 1676 */ 1677 1678 void G4OpenGLQtViewer::rotateQtCameraInViewDirection(float dx, float dy) 1679 { 1680 if (fHoldRotateEvent) 1681 return; 1682 fHoldRotateEvent = true; 1683 1684 fVP.SetUpVector(G4Vector3D(0.0, 1.0, 0.0)); 1685 fVP.SetViewAndLights (G4Vector3D(0.0, 0.0, 1.0)); 1686 1687 1688 fXRot +=dx; 1689 fYRot +=dy; 1690 1691 rotateSceneInViewDirection(fXRot,fYRot,fDeltaRotation/100); 1692 1693 emit rotateTheta(static_cast<int>(dx)); 1694 emit rotatePhi(static_cast<int>(dy)); 1695 updateQWidget(); 1696 1697 fHoldRotateEvent = false; 1698 } 1699 1653 1700 1654 1701 … … 1774 1821 fHoldKeyEvent = true; 1775 1822 1776 #if QT_VERSION < 0x040000 1777 if ((event->key() == Qt::Key_Down) && (event->state() & Qt::AltButton )) { // go backward 1778 #else 1779 if ((event->key() == Qt::Key_Down) && (event->modifiers() & Qt::AltModifier )) { // go backward 1780 #endif 1781 1782 moveScene(0,0,1,false); 1783 } 1784 #if QT_VERSION < 0x040000 1785 else if ((event->key() == Qt::Key_Up) && (event->state() & Qt::AltButton)) { // go forward 1786 #else 1787 else if ((event->key() == Qt::Key_Up) && (event->modifiers() & Qt::AltModifier)) { // go forward 1788 #endif 1789 moveScene(0,0,-1,false); 1790 } 1791 #if QT_VERSION < 0x040000 1792 if ((event->key() == Qt::Key_Down) && (event->state() & Qt::ShiftButton)) { // rotate phi 1793 #else 1794 if ((event->key() == Qt::Key_Down) && (event->modifiers() & Qt::ShiftModifier)) { // rotate phi 1795 #endif 1796 rotateQtCamera(0,-1); 1797 } 1798 #if QT_VERSION < 0x040000 1799 else if ((event->key() == Qt::Key_Up) && (event->state() & Qt::ShiftButton)) { // rotate phi 1800 #else 1801 else if ((event->key() == Qt::Key_Up) && (event->modifiers() & Qt::ShiftModifier)) { // rotate phi 1802 #endif 1803 rotateQtCamera(0,1); 1804 } 1805 #if QT_VERSION < 0x040000 1806 if ((event->key() == Qt::Key_Left) && (event->state() & Qt::ShiftButton)) { // rotate theta 1807 #else 1808 if ((event->key() == Qt::Key_Left) && (event->modifiers() & Qt::ShiftModifier)) { // rotate theta 1809 #endif 1810 rotateQtCamera(1,0); 1811 } 1812 #if QT_VERSION < 0x040000 1813 else if ((event->key() == Qt::Key_Right) && (event->state() & Qt::ShiftButton)) { // rotate theta 1814 #else 1815 else if ((event->key() == Qt::Key_Right) && (event->modifiers() & Qt::ShiftModifier)) { // rotate theta 1816 #endif 1817 rotateQtCamera(-1,0); 1818 } 1819 1820 #if QT_VERSION < 0x040000 1821 if ((event->state() & Qt::AltButton)) { 1822 #else 1823 if ((event->modifiers() & Qt::AltModifier)) { 1824 #endif 1825 if (event->key() == Qt::Key_Plus) { 1826 fDeltaRotation = fDeltaRotation/0.7; 1827 } 1828 else if (event->key() == Qt::Key_Minus) { 1829 fDeltaRotation = fDeltaRotation*0.7; 1830 } 1831 } else { 1832 if (event->key() == Qt::Key_Plus) { 1833 fVP.SetZoomFactor(fVP.GetZoomFactor()*(1+fDeltaZoom)); 1834 updateQWidget(); 1835 } 1836 else if (event->key() == Qt::Key_Minus) { 1837 fVP.SetZoomFactor(fVP.GetZoomFactor()*(1-fDeltaZoom)); 1838 updateQWidget(); 1839 } 1840 } 1841 1842 1843 if (event->key() == Qt::Key_Escape) { // escaped from full screen 1823 bool NothingPress = false; 1824 bool AltPress = false; 1825 bool ControlPress = false; 1826 bool ShiftPress = false; 1827 1828 // Check Qt Versions for META Keys 1829 1830 #if QT_VERSION < 0x040000 1831 if (event->state() & Qt::NoButton ) { 1832 NothingPress = true; 1833 } 1834 if (event->state() & Qt::AltButton ) { 1835 AltPress = true; 1836 } 1837 if (event->state() & Qt::ShiftButton ) { 1838 ShiftPress = true; 1839 } 1840 if (event->state() & Qt::ControlButton ) { 1841 ControlPress = true; 1842 } 1843 #else 1844 if (event->modifiers() & Qt::NoModifier ) { 1845 NothingPress = true; 1846 } 1847 if (event->modifiers() & Qt::AltModifier ) { 1848 AltPress = true; 1849 } 1850 if (event->modifiers() & Qt::ShiftModifier ) { 1851 ShiftPress = true; 1852 } 1853 if (event->modifiers() & Qt::ControlModifier ) { 1854 ControlPress = true; 1855 } 1856 #endif 1857 1858 // with no modifiers 1859 #if QT_VERSION < 0x040000 1860 if (NothingPress) { 1861 #else 1862 if ((NothingPress) || (event->modifiers() == Qt::KeypadModifier )) { 1863 #endif 1864 if (event->key() == Qt::Key_Down) { // go down 1865 moveScene(0,1,0,false); 1866 } 1867 else if (event->key() == Qt::Key_Up) { // go up 1868 moveScene(0,-1,0,false); 1869 } 1870 if (event->key() == Qt::Key_Left) { // go left 1871 moveScene(-1,0,0,false); 1872 } 1873 else if (event->key() == Qt::Key_Right) { // go right 1874 moveScene(1,0,0,false); 1875 } 1876 if (event->key() == Qt::Key_Minus) { // go backward 1877 moveScene(0,0,1,false); 1878 } 1879 else if (event->key() == Qt::Key_Plus) { // go forward 1880 moveScene(0,0,-1,false); 1881 } 1882 1883 // escaped from full screen 1884 if (event->key() == Qt::Key_Escape) { 1844 1885 #if QT_VERSION >= 0x030200 1845 1886 toggleFullScreen(false); 1846 1887 #endif 1847 } 1888 } 1889 } 1848 1890 // several case here : If return is pressed, in every case -> display the movie parameters dialog 1849 1891 // If one parameter is wrong -> put it in red (only save filenam could be wrong..) … … 1851 1893 // If all ok-> generate parameter file 1852 1894 // If ok -> put encoder button enabled 1853 1895 1854 1896 if ((event->key() == Qt::Key_Return) || (event->key() == Qt::Key_Enter)){ // end of video 1855 stopVideo();1897 stopVideo(); 1856 1898 } 1857 1899 if (event->key() == Qt::Key_Space){ // start/pause of video 1858 startPauseVideo(); 1859 } 1860 1861 // with no modifiers 1862 #if QT_VERSION < 0x040000 1863 if (event->state() == Qt::NoButton) { 1864 #else 1865 if ((event->modifiers() == Qt::NoModifier) || (event->modifiers() == Qt::KeypadModifier )) { 1866 #endif 1867 if (event->key() == Qt::Key_Down) { // go down 1868 moveScene(0,1,0,false); 1869 } 1870 else if (event->key() == Qt::Key_Up) { // go up 1871 moveScene(0,-1,0,false); 1872 } 1873 if (event->key() == Qt::Key_Left) { // go left 1874 moveScene(-1,0,0,false); 1875 } 1876 else if (event->key() == Qt::Key_Right) { // go right 1877 moveScene(1,0,0,false); 1878 } 1879 } 1900 startPauseVideo(); 1901 } 1902 1903 // H : Return Home view 1904 if (event->key() == Qt::Key_H){ // go Home 1905 fDeltaRotation = 1; 1906 fDeltaSceneTranslation = 0.01; 1907 fDeltaDepth = 0.01; 1908 fDeltaZoom = 0.05; 1909 fDeltaMove = 0.05; 1910 1911 fVP.SetZoomFactor(1.); 1912 fVP.SetUpVector(G4Vector3D (0., 1., 0.)); 1913 fVP.SetViewAndLights (G4Vector3D (0., 0., 1.)); 1914 1915 updateQWidget(); 1916 } 1917 1918 // Shift Modifier 1919 if (ShiftPress) { 1920 if (event->key() == Qt::Key_Down) { // rotate phi 1921 rotateQtScene(0,-fDeltaRotation); 1922 } 1923 else if (event->key() == Qt::Key_Up) { // rotate phi 1924 rotateQtScene(0,fDeltaRotation); 1925 } 1926 if (event->key() == Qt::Key_Left) { // rotate theta 1927 rotateQtScene(fDeltaRotation,0); 1928 } 1929 else if (event->key() == Qt::Key_Right) { // rotate theta 1930 rotateQtScene(-fDeltaRotation,0); 1931 } 1932 1933 // Alt Modifier 1934 } 1935 if ((AltPress)) { 1936 if (event->key() == Qt::Key_Down) { // rotate phi 1937 rotateQtSceneInViewDirection(0,-fDeltaRotation); 1938 } 1939 else if (event->key() == Qt::Key_Up) { // rotate phi 1940 rotateQtSceneInViewDirection(0,fDeltaRotation); 1941 } 1942 if (event->key() == Qt::Key_Left) { // rotate theta 1943 rotateQtSceneInViewDirection(fDeltaRotation,0); 1944 } 1945 else if (event->key() == Qt::Key_Right) { // rotate theta 1946 rotateQtSceneInViewDirection(-fDeltaRotation,0); 1947 } 1948 1949 // Rotatio +/- 1950 if (event->key() == Qt::Key_Plus) { 1951 fDeltaRotation = fDeltaRotation/0.7; 1952 G4cout << "Auto-rotation set to : " << fDeltaRotation << G4endl; 1953 } 1954 else if (event->key() == Qt::Key_Minus) { 1955 fDeltaRotation = fDeltaRotation*0.7; 1956 G4cout << "Auto-rotation set to : " << fDeltaRotation << G4endl; 1957 } 1958 1959 // Control Modifier OR Command on MAC 1960 } 1961 if ((ControlPress)) { 1962 if (event->key() == Qt::Key_Plus) { 1963 fVP.SetZoomFactor(fVP.GetZoomFactor()*(1+fDeltaZoom)); 1964 updateQWidget(); 1965 } 1966 else if (event->key() == Qt::Key_Minus) { 1967 fVP.SetZoomFactor(fVP.GetZoomFactor()*(1-fDeltaZoom)); 1968 updateQWidget(); 1969 } 1970 } 1971 1880 1972 fHoldKeyEvent = false; 1881 1973 } -
trunk/source/visualization/OpenGL/src/G4OpenGLStoredQtViewer.cc
r1328 r1332 77 77 #endif 78 78 fReadyToPaint = false; 79 initializeGL ();80 79 CreateMainWindow (this,QString(GetName())); 81 80 CreateFontLists (); … … 89 88 void G4OpenGLStoredQtViewer::initializeGL () { 90 89 91 QGLWidget::initializeGL();92 90 #ifdef G4DEBUG_VIS_OGL 93 91 printf("G4OpenGLStoredQtViewer::InitialiseGL () 0\n"); -
trunk/source/visualization/OpenGL/src/G4OpenGLViewer.cc
r1327 r1332 101 101 // glDisable (GL_POLYGON_SMOOTH); 102 102 103 #ifdef G4DEBUG_VIS_OGL104 printf("G4OpenGLViewer::Creation !!\n");105 #endif106 103 } 107 104 … … 110 107 void G4OpenGLViewer::InitializeGLView () 111 108 { 112 #ifdef G4DEBUG_VIS_OGL113 printf("G4OpenGLViewer::InitializeGLView VVVVV\n");114 #endif115 109 glClearColor (0.0, 0.0, 0.0, 0.0); 116 #ifdef G4DEBUG_VIS_OGL117 printf("G4OpenGLViewer::InitializeGLView ---1---\n");118 #endif119 110 glClearDepth (1.0); 120 #ifdef G4DEBUG_VIS_OGL121 printf("G4OpenGLViewer::InitializeGLView ---2---\n");122 #endif123 111 glDisable (GL_BLEND); 124 #ifdef G4DEBUG_VIS_OGL125 printf("G4OpenGLViewer::InitializeGLView ---3---\n");126 #endif127 112 glDisable (GL_LINE_SMOOTH); 128 #ifdef G4DEBUG_VIS_OGL129 printf("G4OpenGLViewer::InitializeGLView ---4---\n");130 #endif131 113 glDisable (GL_POLYGON_SMOOTH); 132 #ifdef G4DEBUG_VIS_OGL133 printf("G4OpenGLViewer::InitializeGLView ---5---\n");134 #endif135 114 136 115 // if (fVP != NULL) { 137 fWinSize_x = fVP.GetWindowSizeHintX(); 138 fWinSize_y = fVP.GetWindowSizeHintY(); 139 #ifdef G4DEBUG_VIS_OGL 140 printf("G4OpenGLViewer::InitializeGLView ^^^^^^\n"); 141 #endif 142 // } 116 fWinSize_x = fVP.GetWindowSizeHintX(); 117 fWinSize_y = fVP.GetWindowSizeHintY(); 118 // } 143 119 } 144 120 … … 849 825 //phi spin stuff here 850 826 827 828 #ifdef G4DEBUG_VIS_OGL 829 printf("G4OpenGLViewer::rotateScene dx:%f dy:%f delta:%f\n",dx,dy, deltaRotation); 830 #endif 831 851 832 vp = fVP.GetViewpointDirection ().unit (); 852 833 up = fVP.GetUpVector ().unit (); 853 834 835 #ifdef G4DEBUG_VIS_OGL 836 printf("G4OpenGLViewer::rotateScene vp: %f %f %f\n",vp.x(),vp.y(),vp.z()); 837 #endif 854 838 yprime = (up.cross(vp)).unit(); 855 839 zprime = (vp.cross(yprime)).unit(); … … 871 855 // to allow more than 360° rotation 872 856 873 const G4Point3D targetPoint874 = fSceneHandler.GetScene()->GetStandardTargetPoint()875 + fVP.GetCurrentTargetPoint ();876 G4double radius = fSceneHandler.GetScene()->GetExtent().GetExtentRadius();877 if(radius<=0.) radius = 1.;878 const G4double cameraDistance = fVP.GetCameraDistance (radius);879 const G4Point3D cameraPosition =880 targetPoint + cameraDistance * fVP.GetViewpointDirection().unit();857 // const G4Point3D targetPoint 858 // = fSceneHandler.GetScene()->GetStandardTargetPoint() 859 // + fVP.GetCurrentTargetPoint (); 860 // G4double radius = fSceneHandler.GetScene()->GetExtent().GetExtentRadius(); 861 // if(radius<=0.) radius = 1.; 862 // const G4double cameraDistance = fVP.GetCameraDistance (radius); 863 // const G4Point3D cameraPosition = 864 // targetPoint + cameraDistance * fVP.GetViewpointDirection().unit(); 881 865 882 866 if (fVP.GetLightsMoveWithCamera()) { 867 #ifdef G4DEBUG_VIS_OGL 868 printf("G4OpenGLViewer::rotateScene GetLightsMoveWithCamera: %f \n",new_vp.z()*vp.z()); 869 #endif 883 870 new_up = (new_vp.cross(yprime)).unit(); 884 871 if (new_vp.z()*vp.z() <0) { 872 #ifdef G4DEBUG_VIS_OGL 873 printf("G4OpenGLViewer::rotateScene R_____________________________________________\n"); 874 #endif 885 875 new_up.set(new_up.x(),-new_up.y(),new_up.z()); 886 876 } 887 877 } else { 878 #ifdef G4DEBUG_VIS_OGL 879 printf("G4OpenGLViewer::rotateScene : %f \n",new_vp.z()*vp.z()); 880 #endif 888 881 new_up = up; 889 882 if (new_vp.z()*vp.z() <0) { 883 #ifdef G4DEBUG_VIS_OGL 884 printf("G4OpenGLViewer::rotateScene X_____________________________________________\n"); 885 #endif 890 886 new_up.set(new_up.x(),-new_up.y(),new_up.z()); 891 887 } … … 906 902 delta = a2 - a1; 907 903 // So new viewpoint is... 904 908 905 viewPoint = new_vp.unit() + delta; 909 906 907 #ifdef G4DEBUG_VIS_OGL 908 printf("G4OpenGLViewer::rotateScene up: %f %f %f\n",up.x(),up.y(),up.z()); 909 printf("G4OpenGLViewer::rotateScene new up: %f %f %f\n",new_up.x(),new_up.y(),new_up.z()); 910 printf("G4OpenGLViewer::rotateScene new vp: %f %f %f delta:%f %f %f\n",new_vp.x(),new_vp.y(),new_vp.z(),delta.x(),delta.y(),delta.z()); 911 #endif 912 913 910 914 fVP.SetViewAndLights (viewPoint); 911 } 912 913 #endif 915 916 917 } 918 919 920 void G4OpenGLViewer::rotateSceneInViewDirection(G4double dx, G4double dy,G4double deltaRotation) 921 { 922 if (!fSceneHandler.GetScene()) { 923 return; 924 } 925 926 G4Vector3D vp; 927 G4Vector3D up; 928 929 G4Vector3D xprime; 930 G4Vector3D yprime; 931 G4Vector3D zprime; 932 933 G4double delta_alpha; 934 G4double delta_theta; 935 936 G4Vector3D new_vp; 937 G4Vector3D new_up; 938 939 G4double cosalpha; 940 G4double sinalpha; 941 942 G4Vector3D a1; 943 G4Vector3D a2; 944 G4Vector3D delta; 945 G4Vector3D viewPoint; 946 947 948 //phi spin stuff here 949 950 951 #ifdef G4DEBUG_VIS_OGL 952 printf("G4OpenGLViewer::rotateScene dx:%f dy:%f delta:%f\n",dx,dy, deltaRotation); 953 #endif 954 955 vp = fVP.GetViewpointDirection ().unit(); 956 up = fVP.GetUpVector ().unit(); 957 958 959 960 G4Vector3D zPrimeVector = G4Vector3D(up.y()*vp.z()-up.z()*vp.y(), 961 up.z()*vp.x()-up.x()*vp.z(), 962 up.x()*vp.y()-up.y()*vp.x()); 963 G4long zPrimeVectorX = up.y()*vp.z()-up.z()*vp.y(); 964 G4long zPrimeVectorY = up.z()*vp.x()-up.x()*vp.z(); 965 G4long zPrimeVectorZ = up.x()*vp.y()-up.y()*vp.x(); 966 967 viewPoint = vp/deltaRotation + (zPrimeVector*dx - up*dy) ; 968 new_up = G4Vector3D(viewPoint.y()*zPrimeVector.z()-viewPoint.z()*zPrimeVector.y(), 969 viewPoint.z()*zPrimeVector.x()-viewPoint.x()*zPrimeVector.z(), 970 viewPoint.x()*zPrimeVector.y()-viewPoint.y()*zPrimeVector.x()); 971 972 G4long new_upLenLong = sqrt((G4long)new_up.x()*(G4long)new_up.x()+(G4long)new_up.y()*(G4long)new_up.y()+(G4long)new_up.z()*(G4long)new_up.z()); 973 // new_up = new_up/new_upLenLong; 974 // G4double new_upLenDouble = new_up.x()*new_up.x()+new_up.y()*new_up.y()+new_up.z()*new_up.z(); 975 976 G4Vector3D new_upDiv = G4Vector3D((G4double)(new_up.x()/new_upLenLong), 977 (G4double)(new_up.y()/new_upLenLong), 978 (G4double)(new_up.z()/new_upLenLong)); 979 980 G4Vector3D new_upPrec = G4Vector3D(((G4double)(((G4long)viewPoint.y()*(G4long)zPrimeVector.z() 981 -(G4long)viewPoint.z()*(G4long)zPrimeVector.y())/new_upLenLong)), 982 ((G4double)(((G4long)viewPoint.z()*(G4long)zPrimeVector.x() 983 -(G4long)viewPoint.x()*(G4long)zPrimeVector.z())/new_upLenLong)), 984 ((G4double)(((G4long)viewPoint.x()*(G4long)zPrimeVector.y() 985 -(G4long)viewPoint.y()*(G4long)zPrimeVector.x())/new_upLenLong))); 986 G4Vector3D new_upUnit = new_up.unit(); 987 988 989 #ifdef G4DEBUG_VIS_OGL 990 printf("G4OpenGLViewer::rotateScene up: %.10lf %.10lf %.10lf len:%.10lf lenLong:%.10lf %f\n",up.x(),up.y(),up.z(), up.mag(),new_upLenLong,new_upLenLong); 991 printf("G4OpenGLViewer::rotateScene NEW new up UNIT / %.10lf %.10lf %.10lf\n",new_upUnit.x(),new_upUnit.y(),new_upUnit.z()); 992 printf("G4OpenGLViewer::rotateScene NEW new up Prec: %.10lf %.10lf %.10lf\n",new_upPrec.x(),(viewPoint.z()*zPrimeVectorX-viewPoint.x()*zPrimeVectorZ),new_upPrec.z()); 993 printf("G4OpenGLViewer::rotateScene NEW new up Div: %.10lf %.10lf %.10lf\n",new_upDiv.x(),new_upDiv.y(),new_upDiv.z()); 994 printf("G4OpenGLViewer::rotateScene vp: %f %f %f\n",vp.x(),vp.y(),vp.z()); 995 996 viewPoint = viewPoint*deltaRotation; 997 998 printf("G4OpenGLViewer::rotateScene NEW --new vp: %f %f %f\n",viewPoint.x(),viewPoint.y(),viewPoint.z()); 999 #endif 1000 1001 fVP.SetUpVector(new_upUnit); 1002 fVP.SetViewAndLights (viewPoint); 1003 } 1004 1005 #endif
Note: See TracChangeset
for help on using the changeset viewer.