Changeset 1333 for trunk/source
- Timestamp:
- Aug 19, 2010, 5:33:35 PM (14 years ago)
- Location:
- trunk/source/visualization/OpenGL
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/visualization/OpenGL/History
r1324 r1333 17 17 * Reverse chronological order (last date on top), please * 18 18 ---------------------------------------------------------- 19 20 19th August 2010 Laurent Garnier 21 - Better way to hold Meta Keys and shortcuts 19 22 20 23 23th June 2010 Laurent Garnier -
trunk/source/visualization/OpenGL/include/G4OpenGLQtViewer.hh
r1332 r1333 120 120 void moveScene(float, float, float,bool); 121 121 void FinishView(); 122 #if QT_VERSION < 0x040000 123 void updateKeyModifierState(Qt::ButtonState); 124 #else 125 void updateKeyModifierState(Qt::KeyboardModifiers); 126 #endif 122 127 123 128 … … 202 207 G4double fXRot; 203 208 G4double fYRot; 209 bool fNoKeyPress; 210 bool fAltKeyPress; 211 bool fControlKeyPress; 212 bool fShiftKeyPress; 204 213 205 214 signals: -
trunk/source/visualization/OpenGL/src/G4OpenGLQtViewer.cc
r1332 r1333 244 244 ,fXRot(0) 245 245 ,fYRot(0) 246 ,fNoKeyPress(true) 247 ,fAltKeyPress(false) 248 ,fControlKeyPress(false) 249 ,fShiftKeyPress(false) 246 250 { 247 251 … … 950 954 */ 951 955 void G4OpenGLQtViewer::showShortcuts() { 956 G4cout << "========= Mouse Shortcuts =========" << G4endl; 952 957 if (fMouseAction == STYLE1) { // rotate 953 958 G4cout << "Click and move mouse to rotate volume " << G4endl; 959 G4cout << "ALT + Click and move mouse to rotate volume (View Direction)" << G4endl; 960 G4cout << "CTRL + Click and zoom mouse to zoom in/out" << G4endl; 961 G4cout << "SHIFT + Click and zoommove camera point of view" << G4endl; 954 962 } else if (fMouseAction == STYLE2) { //move 955 963 G4cout << "Move camera point of view with mouse" << G4endl; … … 1228 1236 SetNeedKernelVisit (true); 1229 1237 updateQWidget(); 1230 1231 1238 } 1232 1239 … … 1446 1453 { 1447 1454 #if QT_VERSION < 0x040000 1448 if ((event->button() & Qt::LeftButton) 1449 && !((event->state() & Qt::ShiftButton) 1450 || (event->state() & Qt::ControlButton) 1451 || (event->state() & Qt::AltButton) 1452 || (event->state() & Qt::MetaButton))) { 1453 #else 1454 if ((event->buttons() & Qt::LeftButton) 1455 && !((event->modifiers() & Qt::ShiftModifier) 1456 || (event->modifiers() & Qt::ControlModifier) 1457 || (event->modifiers() & Qt::AltModifier) 1458 || (event->modifiers() & Qt::MetaModifier))) { 1455 if (event->button() & Qt::LeftButton) { 1456 #else 1457 if (event->buttons() & Qt::LeftButton) { 1459 1458 #endif 1460 1459 fWindow->setMouseTracking(true); … … 1495 1494 } 1496 1495 } 1497 if (((((float)delta.y())/correctionFactor)*lTime > fNbMaxAnglePerSec) ||1498 ((((float)delta.y())/correctionFactor)*lTime < -fNbMaxAnglePerSec) ) {1496 if (((((float)delta.y())/correctionFactor)*lTime > fNbMaxAnglePerSec) || 1497 ((((float)delta.y())/correctionFactor)*lTime < -fNbMaxAnglePerSec) ) { 1499 1498 correctionFactor = (float)delta.y()*(lTime/fNbMaxAnglePerSec); 1500 1499 if (delta.y() <0 ) { … … 1502 1501 } 1503 1502 } 1503 1504 // Check Qt Versions for META Keys 1505 1506 // Click and move mouse to rotate volume 1507 // ALT + Click and move mouse to rotate volume (View Direction) 1508 // SHIFT + Click and move camera point of view 1509 // CTRL + Click and zoom mouse to zoom in/out 1504 1510 1505 1511 if (fMouseAction == STYLE1) { // rotate 1506 rotateQtScene(((float)delta.x())/correctionFactor,((float)delta.y())/correctionFactor); 1512 #ifdef G4DEBUG_VIS_OGL 1513 printf("G4OpenGLQtViewer:: ___________________________________\n"); 1514 printf("G4OpenGLQtViewer:: mouse move\n"); 1515 #endif 1516 if (fNoKeyPress) { 1517 #ifdef G4DEBUG_VIS_OGL 1518 printf("G4OpenGLQtViewer:: rotate normal\n"); 1519 #endif 1520 rotateQtScene(((float)delta.x())/correctionFactor,((float)delta.y())/correctionFactor); 1521 } else if (fAltKeyPress) { 1522 #ifdef G4DEBUG_VIS_OGL 1523 printf("G4OpenGLQtViewer:: rotate view\n"); 1524 #endif 1525 rotateQtSceneInViewDirection(((float)delta.x())/correctionFactor,((float)delta.y())/correctionFactor); 1526 } 1527 1507 1528 } else if (fMouseAction == STYLE2) { // move 1508 1529 moveScene(-((float)delta.x())/correctionFactor,-((float)delta.y())/correctionFactor,0,true); … … 1543 1564 #endif 1544 1565 1566 #if QT_VERSION < 0x040000 1567 updateKeyModifierState(event->state()); 1568 #else 1569 updateKeyModifierState(event->modifiers()); 1570 #endif 1571 1545 1572 if (fAutoMove) { 1546 1573 return; … … 1556 1583 if (fMouseAction == STYLE1) { // rotate 1557 1584 if (mButtons & Qt::LeftButton) { 1558 rotateQtScene(deltaX,deltaY); 1585 #ifdef G4DEBUG_VIS_OGL 1586 printf("G4OpenGLQtViewer:: ___________________________________\n"); 1587 printf("G4OpenGLQtViewer:: mouse move %f %f\n",((float)deltaX),((float)deltaY)); 1588 #endif 1589 if (fNoKeyPress) { 1590 #ifdef G4DEBUG_VIS_OGL 1591 printf("G4OpenGLQtViewer:: rotate normal\n"); 1592 #endif 1593 rotateQtScene(((float)deltaX),((float)deltaY)); 1594 } else if (fAltKeyPress) { 1595 #ifdef G4DEBUG_VIS_OGL 1596 printf("G4OpenGLQtViewer:: rotate view\n"); 1597 #endif 1598 rotateQtSceneInViewDirection(((float)deltaX),((float)deltaY)); 1599 } else if (fShiftKeyPress) { 1600 unsigned int sizeWin; 1601 sizeWin = getWinWidth(); 1602 if (getWinHeight() < getWinWidth()) { 1603 sizeWin = getWinHeight(); 1604 } 1605 1606 // L.Garnier : 08/2010 100 is the good value, but don't ask me why ! 1607 float factor = ((float)100/(float)sizeWin) ; 1608 moveScene(-(float)deltaX*factor,-(float)deltaY*factor,0,false); 1609 } else if (fControlKeyPress) { 1610 #ifdef G4DEBUG_VIS_OGL 1611 printf("G4OpenGLQtViewer:: zoom\n"); 1612 #endif 1613 fVP.SetZoomFactor(fVP.GetZoomFactor()*(1+((float)deltaY))); 1614 } 1559 1615 } 1560 1616 } else if (fMouseAction == STYLE2) { // move … … 1814 1870 1815 1871 1816 void G4OpenGLQtViewer::G4keyPressEvent (QKeyEvent * event)1872 void G4OpenGLQtViewer::G4keyPressEvent (QKeyEvent * event) 1817 1873 { 1818 1874 if (fHoldKeyEvent) … … 1821 1877 fHoldKeyEvent = true; 1822 1878 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 1879 1858 1880 // with no modifiers 1859 1881 #if QT_VERSION < 0x040000 1860 if (NothingPress) { 1861 #else 1862 if ((NothingPress) || (event->modifiers() == Qt::KeypadModifier )) { 1882 updateKeyModifierState(event->state()); 1883 if (fNoKeyPress) { 1884 #else 1885 updateKeyModifierState(event->modifiers()); 1886 if ((fNoKeyPress) || (event->modifiers() == Qt::KeypadModifier )) { 1863 1887 #endif 1864 1888 if (event->key() == Qt::Key_Down) { // go down … … 1917 1941 1918 1942 // Shift Modifier 1919 if ( ShiftPress) {1943 if (fShiftKeyPress) { 1920 1944 if (event->key() == Qt::Key_Down) { // rotate phi 1921 1945 rotateQtScene(0,-fDeltaRotation); … … 1933 1957 // Alt Modifier 1934 1958 } 1935 if (( AltPress)) {1959 if ((fAltKeyPress)) { 1936 1960 if (event->key() == Qt::Key_Down) { // rotate phi 1937 1961 rotateQtSceneInViewDirection(0,-fDeltaRotation); … … 1959 1983 // Control Modifier OR Command on MAC 1960 1984 } 1961 if (( ControlPress)) {1985 if ((fControlKeyPress)) { 1962 1986 if (event->key() == Qt::Key_Plus) { 1963 1987 fVP.SetZoomFactor(fVP.GetZoomFactor()*(1+fDeltaZoom)); … … 1973 1997 } 1974 1998 1999 2000 #if QT_VERSION < 0x040000 2001 void G4OpenGLQtViewer::updateKeyModifierState(Qt::ButtonState modifier) { 2002 #else 2003 void G4OpenGLQtViewer::updateKeyModifierState(Qt::KeyboardModifiers modifier) { 2004 #endif 2005 // Check Qt Versions for META Keys 2006 2007 fNoKeyPress = true; 2008 fAltKeyPress = false; 2009 fShiftKeyPress = false; 2010 fControlKeyPress = false; 2011 2012 #if QT_VERSION < 0x040000 2013 if (modifier & Qt::AltButton ) { 2014 fAltKeyPress = true; 2015 fNoKeyPress = false; 2016 } 2017 if (modifier & Qt::ShiftButton ) { 2018 fShiftKeyPress = true; 2019 fNoKeyPress = false; 2020 } 2021 if (modifier & Qt::ControlButton ) { 2022 fControlKeyPress = true; 2023 fNoKeyPress = false; 2024 } 2025 #else 2026 #ifdef G4DEBUG_VIS_OGL 2027 printf("G4OpenGLQtViewer:: ________________Key Press\n"); 2028 #endif 2029 if (modifier & Qt::AltModifier ) { 2030 fAltKeyPress = true; 2031 fNoKeyPress = false; 2032 #ifdef G4DEBUG_VIS_OGL 2033 printf("G4OpenGLQtViewer:: ________________ALT\n"); 2034 #endif 2035 } 2036 if (modifier & Qt::ShiftModifier ) { 2037 fShiftKeyPress = true; 2038 fNoKeyPress = false; 2039 #ifdef G4DEBUG_VIS_OGL 2040 printf("G4OpenGLQtViewer:: ________________Shift\n"); 2041 #endif 2042 } 2043 if (modifier & Qt::ControlModifier ) { 2044 fControlKeyPress = true; 2045 fNoKeyPress = false; 2046 #ifdef G4DEBUG_VIS_OGL 2047 printf("G4OpenGLQtViewer:: ________________Control\n"); 2048 #endif 2049 } 2050 #endif 2051 } 2052 1975 2053 1976 2054 /** Stop the video. Check all parameters and enable encoder button if all is ok.
Note: See TracChangeset
for help on using the changeset viewer.