Changeset 702 for trunk/geant4
- Timestamp:
- Jan 29, 2008, 3:21:26 PM (17 years ago)
- Location:
- trunk/geant4/visualization/OpenGL
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/geant4/visualization/OpenGL/include/G4OpenGLQtViewer.hh
r696 r702 111 111 mouseActions fMouseAction; // 1: rotate 0:move 112 112 QPoint fLastPos; 113 /* delta of scene translation. This delta is put in % of the scene view */113 /** delta of scene translation. This delta is put in % of the scene view */ 114 114 float fDeltaSceneTranslation; 115 /* delta of left right move. This delta is put in % of the scene view */115 /** delta of left right move. This delta is put in % of the scene view */ 116 116 float fDeltaZoom; 117 117 /** To ensure key event are keep one by one */ 118 bool holdKeyEvent; 118 119 #if QT_VERSION < 0x040000 119 120 QPopupMenu *fMouseRotate; … … 150 151 void toggleMouseAction(mouseActions); 151 152 void toggleRepresentation(bool); 153 void toggleProjection(bool); 152 154 void toggleBackground(bool); 153 155 void toggleTransparency(bool); -
trunk/geant4/visualization/OpenGL/src/G4OpenGLQtViewer.cc
r701 r702 50 50 51 51 #include "G4Qt.hh" 52 #include "G4UIsession.hh"53 52 #include "G4UImanager.hh" 53 #include "G4UIcommandTree.hh" 54 54 #include <qapplication.h> 55 55 #include <qlayout.h> … … 288 288 ,fDeltaSceneTranslation(1/100) 289 289 ,fDeltaZoom(2) 290 ,holdKeyEvent(false) 290 291 { 291 292 #ifdef GEANT4_QT_DEBUG … … 415 416 QPopupMenu *mRepresentation = new QPopupMenu(fContextMenu); 416 417 418 QPopupMenu *mProjection = new QPopupMenu(fProjection); 419 417 420 #if QT_VERSION < 0x030200 418 421 QAction *polyhedron = new QAction("&Polyhedron","&Polyhedron",CTRL+Key_P,mRepresentation); 419 422 QAction *nurbs = new QAction("&NURBS","&NURBS",CTRL+Key_N,mRepresentation); 423 424 QAction *ortho = new QAction("&Orthographic","&Orthographic",CTRL+Key_O,mProjection); 425 QAction *perspective = new QAction("&Perspective","&Perspective",CTRL+Key_P,mProjection); 420 426 #else 421 427 QAction *polyhedron = new QAction("&Polyhedron",CTRL+Key_P,mRepresentation); 422 428 QAction *nurbs = new QAction("&NURBS",CTRL+Key_N,mRepresentation); 429 430 QAction *ortho = new QAction("&Orthographic",CTRL+Key_O,mProjection); 431 QAction *perspective = new QAction("&Perspective",CTRL+Key_P,mProjection); 423 432 #endif 424 433 polyhedron->addTo(mRepresentation); 425 434 nurbs->addTo(mRepresentation); 426 435 436 ortho->addTo(mProjection); 437 perspective->addTo(mProjection); 438 427 439 mStyle->insertItem("&Representation",mRepresentation); 440 mStyle->insertItem("&Projection",mProjection); 428 441 fContextMenu->insertItem("&Style",mStyle); 442 429 443 430 444 #else … … 435 449 QAction *polyhedron = mRepresentation->addAction("Polyhedron"); 436 450 QAction *nurbs = mRepresentation->addAction("NURBS"); 437 #endif 438 // INIT mStyle 451 452 QAction *ortho = mRepresentation->addAction("Orthographic"); 453 QAction *perspective = mRepresentation->addAction("Persepective"); 454 #endif 455 456 // INIT mRepresentation 439 457 G4ViewParameters::RepStyle style; 440 458 style = fVP.GetRepStyle(); … … 447 465 } 448 466 467 // INIT mProjection 468 if (fVP.GetFieldHalfAngle() == 0) { 469 createRadioAction(ortho, perspective,SLOT(toggleProjection(bool)),1); 470 } else { 471 createRadioAction(ortho, perspective,SLOT(toggleProjection(bool)),2); 472 } 449 473 450 474 #if QT_VERSION < 0x040000 … … 887 911 G4cout << "Clic and move mouse to rotate Volume \n" << G4endl; 888 912 G4cout << "Press left/right arrows to move camera left/right\n" << G4endl; 889 G4cout << "Press up/down arrows to move camera toward/forward\n" << G4endl;890 G4cout << "Press SHIFT+up/down arrows to move camera up/down\n" << G4endl;913 G4cout << "Press up/down arrows to move camera up/down\n" << G4endl; 914 G4cout << "Press SHIFT+up/down arrows to move camera toward/forward\n" << G4endl; 891 915 G4cout << "Press +/- to zoom into volume\n" << G4endl; 892 916 #if QT_VERSION < 0x040000 … … 1061 1085 #endif 1062 1086 } 1087 1088 /** 1089 SLOT Activate by a click on the projection menu 1090 Warning : When G4OpenGLStoredQtViewer::DrawView() method call, 1091 KernelVisitDecision () will be call and will set the fNeedKernelVisit 1092 to 1. See G4XXXStoredViewer::CompareForKernelVisit for explanations. 1093 It will cause a redraw of the view 1094 @param check : 1 orthographic, 2 perspective 1095 @see G4OpenGLStoredQtViewer::DrawView 1096 @see G4XXXStoredViewer::CompareForKernelVisit 1097 */ 1098 void G4OpenGLQtViewer::toggleProjection(bool check) { 1099 1100 if (check == 1) { 1101 fVP.SetFieldHalfAngle (0); 1102 } else { 1103 // look for the default parameter hidden in G4UIcommand parameters 1104 G4UImanager* UI = G4UImanager::GetUIpointer(); 1105 if(UI==NULL) 1106 return; 1107 G4UIcommandTree * treeTop = UI->GetTree(); 1108 1109 // find command 1110 G4UIcommand* command = treeTop->FindPath("/vis/viewer/set/projection"); 1111 if (!command) 1112 return; 1113 1114 // find param 1115 G4UIparameter * param = NULL; 1116 1117 for(G4int i=0; i<command->GetParameterEntries(); i++) 1118 { 1119 if( command->GetParameter(i)->GetParameterName() == "field-half-angle" ) { 1120 param = command->GetParameter(i); 1121 } 1122 } 1123 if (!param) 1124 return; 1125 G4double defaultValue = command->ConvertToDouble(param->GetDefaultValue()); 1126 G4cout << "Perspective view has been set to default value. Field half angle="<<defaultValue <<" \n" << G4endl; 1127 fVP.SetFieldHalfAngle (defaultValue); 1128 } 1129 1130 #ifdef GEANT4_QT_DEBUG 1131 printf("G4OpenGLQtViewer::toggleRepresentation 3%d\n",check); 1132 #endif 1133 updateQWidget(); 1134 #ifdef GEANT4_QT_DEBUG 1135 printf("G4OpenGLQtViewer::toggleRepresentation 4%d\n",check); 1136 #endif 1137 } 1138 1063 1139 1064 1140 /** … … 1744 1820 void G4OpenGLQtViewer::G4keyPressEvent (QKeyEvent * event) 1745 1821 { 1822 if (holdKeyEvent) 1823 return; 1824 1825 holdKeyEvent = true; 1826 1746 1827 #ifdef GEANT4_QT_DEBUG 1747 1828 printf("G4OpenGLQtViewer::keyPressEvent count:%d autoRepeat:%d key:%d\n",event->count(),event->isAutoRepeat(),event->key()); … … 1752 1833 } 1753 1834 1754 if ((event->key() == Qt::Key_Down) && (event->modifiers() & Qt::ShiftModifier)) // go up 1835 if ((event->key() == Qt::Key_Down) && (event->modifiers() & Qt::ShiftModifier)) // go backward 1836 { 1837 G4MouseMoveEvent(0,0,1); 1838 } 1839 else if ((event->key() == Qt::Key_Up) && (event->modifiers() & Qt::ShiftModifier)) // go forward 1840 { 1841 G4MouseMoveEvent(0,0,-1); 1842 } 1843 else if (event->key() == Qt::Key_Down) // go down 1755 1844 { 1756 1845 G4MouseMoveEvent(0,1,0); 1757 1846 } 1758 else if ( (event->key() == Qt::Key_Up) && (event->modifiers() & Qt::ShiftModifier)) // go down1847 else if (event->key() == Qt::Key_Up) // go up 1759 1848 { 1760 1849 G4MouseMoveEvent(0,-1,0); 1761 }1762 else if (event->key() == Qt::Key_Down) // go backward1763 {1764 G4MouseMoveEvent(0,0,-1);1765 }1766 else if (event->key() == Qt::Key_Up) // go forward1767 {1768 G4MouseMoveEvent(0,0,1);1769 1850 } 1770 1851 else if (event->key() == Qt::Key_Left) // go left … … 1786 1867 updateQWidget(); 1787 1868 } 1869 #ifdef GEANT4_QT_DEBUG 1870 printf("G4OpenGLQtViewer::keyPressEvent END\n"); 1871 #endif 1872 holdKeyEvent = false; 1788 1873 } 1789 1874 … … 1811 1896 } 1812 1897 */ 1898 -
trunk/geant4/visualization/OpenGL/src/G4OpenGLStoredQtViewer.cc
r696 r702 365 365 366 366 #endif 367
Note: See TracChangeset
for help on using the changeset viewer.