Changeset 564
- Timestamp:
- Aug 14, 2007, 4:57:01 PM (17 years ago)
- Location:
- trunk/geant4/visualization
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/geant4/visualization/G4History.macro
r562 r564 59 59 /gui/addButton viewer "Update scene" "/vis/scene/notifyHandlers" 60 60 /N03/event/printModulo 100 61 /gun/energy 1 GeV62 61 /run/beamOn 1 62 /gun/energy 10 GeV 63 /run/beamOn 1 -
trunk/geant4/visualization/OpenGL/include/G4OpenGLQtViewer.hh
r561 r564 69 69 void G4MousePressEvent(QPoint); 70 70 void G4MouseMoveEvent(int, int, Qt::MouseButtons); 71 void setXRotation(int angle);72 void setYRotation(int angle);73 void setZRotation(int angle);74 void normalizeAngle(int *angle);75 float getXRot();76 float getYRot();77 float getZRot();78 71 79 72 protected: … … 89 82 bool fMouseAction; // 1: rotate 0:move 90 83 QPoint lastPos; 91 float xRot;92 float yRot;93 float zRot;94 84 QAction *fDrawingWireframe; 95 85 QAction *fDrawingLineRemoval; -
trunk/geant4/visualization/OpenGL/src/G4OpenGLImmediateQtViewer.cc
r559 r564 35 35 36 36 #include "G4OpenGLImmediateQtViewer.hh" 37 #include "G4VisManager.hh" 37 38 38 39 #include "G4ios.hh" … … 61 62 printf("readyToPaint = false \n"); 62 63 readyToPaint = false; 63 // printf("G4OpenGLImmediateQtViewer::Initialise () 1\n"); 64 // CreateGLQtContext (); 65 printf("G4OpenGLImmediateQtViewer::Initialise () 2\n"); 64 CreateGLQtContext (); 65 printf("G4OpenGLImmediateQtViewer::Initialise () 2\n"); 66 66 67 67 CreateMainWindow (this); 68 68 printf("G4OpenGLImmediateQtViewer::Initialise () 3\n"); 69 69 70 //CreateFontLists (); // FIXME Does nothing!71 70 CreateFontLists (); // FIXME Does nothing! 71 72 72 printf("readyToPaint = true \n"); 73 73 readyToPaint = true; 74 74 75 75 // First Draw 76 SetView(); 77 // // printf("before ClearView\n"); 78 // // makeCurrent(); 79 // // for (int a=0;a<100000000;a++) {b = b/3.1456;} 80 printf(" ClearView\n"); 81 ClearView (); //ok, put the background correct 82 // DrawView2(); 83 ShowView(); 84 // printf("before ClearView\n"); 85 // ClearView (); //ok, put the background correct 86 // // FIXME 87 FinishView(); 76 SetView(); 77 printf(" ClearView\n"); 78 ClearView (); //ok, put the background correct 79 ShowView(); 80 FinishView(); 88 81 } 89 82 … … 94 87 printf("G4OpenGLImmediateQtViewer::InitialiseGL () 1\n"); 95 88 96 // glDrawBuffer (GL_FRONT); // FIXME : Ne marche pas avec cette ligne, mais affiche le run correctement... 89 // If a double buffer context has been forced upon us, ignore the 90 // back buffer for this OpenGLImmediate view. 91 glDrawBuffer (GL_FRONT); // FIXME : Ne marche pas avec cette ligne, mais affiche le run correctement... 97 92 // clear the buffers and window. 98 93 ClearView (); 99 94 // printf("G4OpenGLImmediateQtViewer::InitialiseGL () 2\n"); 100 95 FinishView (); 101 96 97 98 99 glDepthFunc (GL_LEQUAL); 100 glDepthMask (GL_TRUE); 101 102 printf("G4OpenGLImmediateQtViewer::InitialiseGL -------------------------------------------------------------------------------------\n"); 103 } 104 105 106 void G4OpenGLImmediateQtViewer::DrawView () { 107 108 printf("G4OpenGLImmediateQtViewer::DrawView %d %d VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n",WinSize_x, WinSize_y); 102 109 // If a double buffer context has been forced upon us, ignore the 103 110 // back buffer for this OpenGLImmediate view. 104 105 106 glDepthFunc (GL_LEQUAL); 107 glDepthMask (GL_TRUE); 108 109 printf("G4OpenGLImmediateQtViewer::InitialiseGL -------------------------------------------------------------------------------------\n"); 110 } 111 112 113 void G4OpenGLImmediateQtViewer::DrawView () { 114 115 printf("G4OpenGLImmediateQtViewer::DrawView %d %d VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n",WinSize_x, WinSize_y); 116 // glDraw(); 117 DrawView2(); 118 printf("G4OpenGLImmediateQtViewer::DrawView %d %d ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n",WinSize_x, WinSize_y); 119 120 } 121 122 void G4OpenGLImmediateQtViewer::DrawView2 () { 123 124 printf("G4OpenGLImmediateQtViewer::DrawView2 %d %d VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n",WinSize_x, WinSize_y); 125 // If a double buffer context has been forced upon us, ignore the 126 // back buffer for this OpenGLImmediate view. 127 // glDrawBuffer (GL_FRONT); 111 glDrawBuffer (GL_FRONT); 128 112 129 113 G4ViewParameters::DrawingStyle style = GetViewParameters().GetDrawingStyle(); … … 131 115 //Make sure current viewer is attached and clean... 132 116 //Qt version needed 133 //glXMakeCurrent (dpy, win, cx);134 117 glViewport (0, 0, WinSize_x, WinSize_y); 135 118 136 119 if(style!=G4ViewParameters::hlr && 137 120 haloing_enabled) { 138 printf("G4OpenGLImmediateQtViewer::DrawView 2DANS LE IF\n");121 printf("G4OpenGLImmediateQtViewer::DrawView DANS LE IF\n"); 139 122 140 123 HaloingFirstPass (); … … 150 133 ProcessView (); 151 134 FinishView (); 152 printf("G4OpenGLImmediateQtViewer::DrawView 2%d %d ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n",WinSize_x, WinSize_y);135 printf("G4OpenGLImmediateQtViewer::DrawView %d %d ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n",WinSize_x, WinSize_y); 153 136 readyToPaint = false; 154 137 } … … 162 145 { 163 146 printf("G4OpenGLImmediateQtViewer::FinishView VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n"); 164 // // if(!fHDC) return;165 147 166 148 glFlush (); 167 149 printf("G4OpenGLImmediateQtViewer::FinishView ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n"); 168 150 169 // Empty the Windows message queue : 170 // MSG event; 171 // while ( ::PeekMessage(&event, NULL, 0, 0, PM_REMOVE) ) { 172 // ::TranslateMessage(&event); 173 // ::DispatchMessage (&event); 174 // } 175 } 176 177 151 } 152 153 154 /** 155 - Lors du resize de la fenetre, on doit non pas redessiner le detecteur, mais aussi les evenements 156 */ 178 157 void G4OpenGLImmediateQtViewer::resizeGL( 179 158 int width 180 159 ,int height) 181 { 182 printf("G4OpenGLImmediateQtViewer::resizeGL VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV \n"); 183 160 { 184 161 int side = qMin(width, height); 185 162 glViewport((width - side) / 2, (height - side) / 2, side, side); … … 188 165 glOrtho(-0.5, +0.5, +0.5, -0.5, 4.0, 15.0); 189 166 glMatrixMode(GL_MODELVIEW); 190 191 167 printf("G4OpenGLImmediateQtViewer::resizeGL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n"); 192 }193 194 void G4OpenGLImmediateQtViewer::paintEvent (195 QPaintEvent * event196 )197 {198 // printf("G4OpenGLImmediateQtViewer::paintEvent VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV \n");199 // printf("Type of Event %d \n",event->type());200 // printf("G4OpenGLImmediateQtViewer::paintEvent ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n");201 return paintGL();202 168 } 203 169 … … 205 171 void G4OpenGLImmediateQtViewer::paintGL() 206 172 { 207 if (!readyToPaint) 173 if (!readyToPaint) { 174 readyToPaint= true; 208 175 return; 176 } 209 177 // DO NOT RESIZE IF SIZE HAS NOT CHANGE 210 178 if (((WinSize_x == (G4int)width())) &&(WinSize_y == (G4int) height())) { … … 212 180 } 213 181 nbPaint++; 214 printf("\n\nG4OpenGLImmediateQtViewer::paintGL VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV %d \n",nbPaint);182 printf("\n\nG4OpenGLImmediateQtViewer::paintGL VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV %d ready %d\n",nbPaint,readyToPaint); 215 183 WinSize_x = (G4int) width(); 216 184 WinSize_y = (G4int) height(); … … 220 188 SetView(); 221 189 // // printf("before ClearView\n"); 222 // // makeCurrent();223 // // for (int a=0;a<100000000;a++) {b = b/3.1456;}224 190 printf(" ClearView\n"); 225 // ClearView (); //ok, put the background correct 226 DrawView2(); 191 192 ClearView (); //ok, put the background correct 193 DrawView(); 227 194 readyToPaint = true; // could be set to false by DrawView 228 195 229 // INIT ok RUN nok ShowView(); 230 // printf("before ClearView\n"); 231 // ClearView (); //ok, put the background correct 232 // // FIXME 233 // INIT ok RUN nok FinishView(); 234 // // glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 235 // // glLoadIdentity(); 236 // // glTranslated(0.0, 0.0, -10.0); 237 238 printf("G4OpenGLImmediateQtViewer::paintGL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n\n"); 196 197 printf("G4OpenGLImmediateQtViewer::paintGL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ %d ready %d\n\n\n",nbPaint,readyToPaint); 239 198 } 240 199 200 void G4OpenGLImmediateQtViewer::updateQWidget() { 201 updateGL(); 202 } 241 203 242 204 #endif -
trunk/geant4/visualization/OpenGL/src/G4OpenGLQtViewer.cc
r553 r564 44 44 #include "G4Point3D.hh" 45 45 #include "G4Normal3D.hh" 46 #include "G4Scene.hh" 46 47 47 48 #include "G4Qt.hh" … … 49 50 #include <QtGui/qboxlayout.h> 50 51 #include <QtGui/qdialog.h> 51 #include <QtGui/q pushbutton.h>52 53 ////////////////////////////////////////////////////////////////////////////// 54 /** 55 Implementation of virtual method of G4VViewer56 52 #include <QtGui/qmenu.h> 53 54 ////////////////////////////////////////////////////////////////////////////// 55 /** 56 Implementation of virtual method of G4VViewer 57 */ 57 58 void G4OpenGLQtViewer::SetView ( 58 59 ) … … 61 62 { 62 63 printf("G4OpenGLQtViewer::SetView ++++++++++++++++++++\n"); 63 // if(!fHDC) return;64 // if(!fHGLRC) return;65 // ::wglMakeCurrent(fHDC,fHGLRC);66 // fWindow->makeCurrent();64 // if(!fHDC) return; 65 // if(!fHGLRC) return; 66 // ::wglMakeCurrent(fHDC,fHGLRC); 67 // fWindow->makeCurrent(); 67 68 G4OpenGLViewer::SetView (); 68 69 printf("G4OpenGLQtViewer::SetView --------------------\n"); … … 73 74 ////////////////////////////////////////////////////////////////////////////// 74 75 /** 75 Implementation of virtual method of G4VViewer76 76 Implementation of virtual method of G4VViewer 77 */ 77 78 void G4OpenGLQtViewer::ShowView ( 78 79 ) … … 83 84 // if(!fHDC) return; 84 85 // fWindow->resize(100, 300); 85 //glFlush ();86 glFlush (); 86 87 printf("G4OpenGLQtViewer::ShowView -----------------------\n"); 87 88 88 // // Empty the Windows message queue : 89 // MSG event; 90 // while ( ::PeekMessage(&event, NULL, 0, 0, PM_REMOVE) ) { 91 // ::TranslateMessage(&event); 92 // ::DispatchMessage (&event); 93 // } 94 } 95 96 97 // ////////////////////////////////////////////////////////////////////////////// 98 // void G4OpenGLQtViewer::GetQtConnection ( 99 // ) 100 // ////////////////////////////////////////////////////////////////////////////// 101 // //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 102 // { 103 // } 89 // // Empty the Windows message queue : 90 // MSG event; 91 // while ( ::PeekMessage(&event, NULL, 0, 0, PM_REMOVE) ) { 92 // ::TranslateMessage(&event); 93 // ::DispatchMessage (&event); 94 // } 95 } 96 97 104 98 105 99 ////////////////////////////////////////////////////////////////////////////// … … 112 106 } 113 107 108 114 109 ////////////////////////////////////////////////////////////////////////////// 115 110 void G4OpenGLQtViewer::CreateMainWindow ( 116 ) 111 QGLWidget* glWidget 112 ) 117 113 ////////////////////////////////////////////////////////////////////////////// 118 114 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// … … 120 116 121 117 if(fWindow) return; //Done. 122 printf("G4OpenGLQtViewer::CreateMainWindow 2\n");118 printf("G4OpenGLQtViewer::CreateMainWindow glWidget\n"); 123 119 124 120 // launch Qt if not … … 126 122 // G4UImanager* UI = G4UImanager::GetUIpointer(); 127 123 128 fWindow = new QGLWidget();124 fWindow = glWidget ; 129 125 // fWindow->makeCurrent(); 130 126 … … 137 133 138 134 QHBoxLayout *mainLayout = new QHBoxLayout; 139 mainLayout->addWidget(fWindow); 140 GLWindow->setLayout(mainLayout); 141 GLWindow->setWindowTitle("QGl Viewer"); 142 GLWindow->resize(100, 300); 143 GLWindow->move(QPoint(600,400)); 144 GLWindow->show(); 145 146 147 // // Bill Gates stuff... 148 // static const char className[] = "G4OpenGLQt"; 149 // static bool done = false; 150 // if(done==false) { 151 // WNDCLASS wc; 152 // wc.style = CS_HREDRAW | CS_VREDRAW; 153 // wc.lpfnWndProc = (WNDPROC)WindowProc; 154 // wc.cbClsExtra = 0; 155 // wc.cbWndExtra = 0; 156 // wc.hInstance = ::GetModuleHandle(NULL); 157 // wc.hIcon = LoadIcon (NULL, IDI_APPLICATION); 158 // wc.hCursor = LoadCursor(NULL,IDC_CROSS); 159 // wc.hbrBackground = NULL; 160 // wc.lpszMenuName = className; 161 // wc.lpszClassName = className; 162 // ::RegisterClass(&wc); 163 // done = true; 164 // } 165 166 WinSize_x = 400; 167 WinSize_y = 400; 168 if (WinSize_x < fVP.GetWindowSizeHintX ()) 169 WinSize_x = fVP.GetWindowSizeHintX (); 170 if (WinSize_y < fVP.GetWindowSizeHintY ()) 171 WinSize_y = fVP.GetWindowSizeHintY (); 172 173 // fWindow = ::CreateWindow(className,fName.c_str(), 174 // WS_OVERLAPPEDWINDOW, 175 // //WS_CHILD | WS_VISIBLE, 176 // 0,0, 177 // WinSize_x,WinSize_y, 178 // NULL, NULL, 179 // ::GetModuleHandle(NULL), 180 // NULL); 181 if(!fWindow) return; 182 183 // ::SetWindowLong(fWindow,GWL_USERDATA,LONG(this)); 184 185 // // initialize OpenGL rendering : 186 // fHDC = ::GetDC(fWindow); 187 // if( fHDC && (SetWindowPixelFormat(fHDC)==TRUE) ) { 188 // fHGLRC = ::wglCreateContext(fHDC); 189 // } 190 191 // if(fHDC && fHGLRC) { 192 // ::wglMakeCurrent(fHDC,fHGLRC); 193 // } 194 195 // ::SetForegroundWindow(fWindow); 196 // ::ShowWindow(fWindow,SW_SHOWDEFAULT); 197 // ::UpdateWindow(fWindow); 198 // ::DrawMenuBar(fWindow); 199 } 200 201 ////////////////////////////////////////////////////////////////////////////// 202 void G4OpenGLQtViewer::CreateMainWindow ( 203 QGLWidget* glWidget 204 ) 205 ////////////////////////////////////////////////////////////////////////////// 206 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 207 { 208 209 if(fWindow) return; //Done. 210 printf("G4OpenGLQtViewer::CreateMainWindow glWidget\n"); 211 212 // launch Qt if not 213 G4Qt* interactorManager = G4Qt::getInstance (); 214 // G4UImanager* UI = G4UImanager::GetUIpointer(); 215 216 fWindow = glWidget ; 217 // fWindow->makeCurrent(); 218 219 // create window 220 if (qApp) { 221 GLWindow = new QDialog();//qApp->mainWidget()); 222 } else { 223 GLWindow = new QDialog(); 224 } 225 226 QHBoxLayout *mainLayout = new QHBoxLayout; 135 227 136 mainLayout->addWidget(fWindow); 228 137 GLWindow->setLayout(mainLayout); … … 230 139 GLWindow->resize(300, 300); 231 140 GLWindow->show(); 232 233 234 // // Bill Gates stuff...235 // static const char className[] = "G4OpenGLQt";236 // static bool done = false;237 // if(done==false) {238 // WNDCLASS wc;239 // wc.style = CS_HREDRAW | CS_VREDRAW;240 // wc.lpfnWndProc = (WNDPROC)WindowProc;241 // wc.cbClsExtra = 0;242 // wc.cbWndExtra = 0;243 // wc.hInstance = ::GetModuleHandle(NULL);244 // wc.hIcon = LoadIcon (NULL, IDI_APPLICATION);245 // wc.hCursor = LoadCursor(NULL,IDC_CROSS);246 // wc.hbrBackground = NULL;247 // wc.lpszMenuName = className;248 // wc.lpszClassName = className;249 // ::RegisterClass(&wc);250 // done = true;251 // }252 141 253 WinSize_x = 400; 254 WinSize_y = 400; 255 if (WinSize_x < fVP.GetWindowSizeHintX ()) 256 WinSize_x = fVP.GetWindowSizeHintX (); 257 if (WinSize_y < fVP.GetWindowSizeHintY ()) 258 WinSize_y = fVP.GetWindowSizeHintY (); 259 260 // fWindow = ::CreateWindow(className,fName.c_str(), 261 // WS_OVERLAPPEDWINDOW, 262 // //WS_CHILD | WS_VISIBLE, 263 // 0,0, 264 // WinSize_x,WinSize_y, 265 // NULL, NULL, 266 // ::GetModuleHandle(NULL), 267 // NULL); 268 if(!fWindow) return; 269 270 // ::SetWindowLong(fWindow,GWL_USERDATA,LONG(this)); 271 272 // // initialize OpenGL rendering : 273 // fHDC = ::GetDC(fWindow); 274 // if( fHDC && (SetWindowPixelFormat(fHDC)==TRUE) ) { 275 // fHGLRC = ::wglCreateContext(fHDC); 276 // } 277 278 // if(fHDC && fHGLRC) { 279 // ::wglMakeCurrent(fHDC,fHGLRC); 280 // } 281 282 // ::SetForegroundWindow(fWindow); 283 // ::ShowWindow(fWindow,SW_SHOWDEFAULT); 284 // ::UpdateWindow(fWindow); 285 // ::DrawMenuBar(fWindow); 142 WinSize_x = 400; 143 WinSize_y = 400; 144 if (WinSize_x < fVP.GetWindowSizeHintX ()) 145 WinSize_x = fVP.GetWindowSizeHintX (); 146 if (WinSize_y < fVP.GetWindowSizeHintY ()) 147 WinSize_y = fVP.GetWindowSizeHintY (); 148 149 if(!fWindow) return; 150 printf("G4OpenGLQtViewer::CreateMainWindow glWidget END\n"); 151 152 if (!fContextMenu) 153 createPopupMenu(); 154 286 155 } 287 156 288 157 ////////////////////////////////////////////////////////////////////////////// 289 158 G4OpenGLQtViewer::G4OpenGLQtViewer ( 290 G4OpenGLSceneHandler& scene 291 ) 292 :G4VViewer (scene, -1) 293 ,G4OpenGLViewer (scene) 294 ,fWindow(0) 295 //,fHDC(0) 296 //,fHGLRC(0) 297 ////////////////////////////////////////////////////////////////////////////// 298 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 159 G4OpenGLSceneHandler& scene 160 ) 161 :G4VViewer (scene, -1) 162 ,G4OpenGLViewer (scene) 163 ,fWindow(0) 164 ,fContextMenu(0) 165 ,fMouseAction(true) 299 166 { 300 167 printf("G4OpenGLQtViewer::G4OpenGLQtViewer \n"); … … 308 175 { 309 176 printf("G4OpenGLQtViewer::~G4OpenGLQtViewer \n"); 310 // // This is the end (Jim Morisson). 311 // if (fViewId >= 0) { 312 // if(wglGetCurrentContext()!=NULL) wglMakeCurrent(NULL,NULL); 313 // if(fHGLRC) { 314 // wglDeleteContext(fHGLRC); 315 // fHGLRC = NULL; 316 // } 177 delete fContextMenu; 178 } 179 180 181 /** 182 Create a popup menu for the widget. This menu is activated by right-mouse click 183 */ 184 void G4OpenGLQtViewer::createPopupMenu() { 185 186 fContextMenu = new QMenu("All"); 187 188 QMenu *mMouseAction = fContextMenu->addMenu("&Mouse action"); 189 QAction *rotate = mMouseAction->addAction("&Rotate scene"); 190 QAction *move = mMouseAction->addAction("&Move scene"); 191 // INIT mMouse 192 createRadioAction(rotate,move,SLOT(toggleMouseAction(bool)),1); 193 194 //Style Menu 195 QMenu *mStyle = fContextMenu->addMenu("&Style"); 196 197 QMenu *mRepresentation = mStyle->addMenu("&Representation"); 198 QAction *polyhedron = mRepresentation->addAction("Polyhedron"); 199 QAction *nurbs = mRepresentation->addAction("NURBS"); 200 // INIT mStyle 201 G4ViewParameters::RepStyle style; 202 style = fVP.GetRepStyle(); 203 if (style == G4ViewParameters::polyhedron) { 204 createRadioAction(polyhedron,nurbs,SLOT(toggleRepresentation(bool)),1); 205 } else if (style == G4ViewParameters::nurbs) { 206 createRadioAction(polyhedron,nurbs,SLOT(toggleRepresentation(bool)),2); 207 } else { 208 mRepresentation->clear(); 209 } 210 211 212 QMenu *mDrawing = mStyle->addMenu("&Drawing"); 213 fDrawingWireframe = mDrawing->addAction("Wireframe"); 214 fDrawingWireframe->setCheckable(true); 215 fDrawingWireframe->setChecked(true); 216 fDrawingLineRemoval = mDrawing->addAction("Hidden line removal"); 217 fDrawingLineRemoval->setCheckable(true); 218 fDrawingSurfaceRemoval = mDrawing->addAction("Hidden Surface removal"); 219 fDrawingSurfaceRemoval->setCheckable(true); 220 fDrawingLineSurfaceRemoval = mDrawing->addAction("Hidden line and surface removal"); 221 fDrawingLineSurfaceRemoval->setCheckable(true); 222 // INIT Drawing 223 G4ViewParameters::DrawingStyle d_style; 224 d_style = fVP.GetDrawingStyle(); 225 226 fDrawingWireframe->setCheckable(true); 227 fDrawingLineRemoval->setCheckable(true); 228 fDrawingSurfaceRemoval->setCheckable(true); 229 fDrawingLineSurfaceRemoval->setCheckable(true); 230 231 if (d_style == G4ViewParameters::wireframe) { 232 fDrawingWireframe->setChecked(true); 233 } else if (d_style == G4ViewParameters::hlr) { 234 fDrawingLineRemoval->setChecked(true); 235 } else if (d_style == G4ViewParameters::hsr) { 236 fDrawingSurfaceRemoval->setChecked(true); 237 } else if (d_style == G4ViewParameters::hlhsr) { 238 fDrawingLineSurfaceRemoval->setChecked(true); 239 } else { 240 mDrawing->clear(); 241 } 242 243 QObject ::connect(fDrawingWireframe, SIGNAL(triggered(bool)),this, SLOT(actionDrawingWireframe())); 244 QObject ::connect(fDrawingLineRemoval, SIGNAL(triggered(bool)),this, SLOT(actionDrawingLineRemoval())); 245 QObject ::connect(fDrawingSurfaceRemoval, SIGNAL(triggered(bool)),this, SLOT(actionDrawingSurfaceRemoval())); 246 QObject ::connect(fDrawingLineSurfaceRemoval, SIGNAL(triggered(bool)),this, SLOT(actionDrawingLineSurfaceRemoval())); 247 248 249 QMenu *mBackground = mStyle->addMenu("&Background color"); 250 QAction *white = mBackground->addAction("White"); 251 QAction *black = mBackground->addAction("Black"); 252 if (background.GetRed() == 1. && 253 background.GetGreen() == 1. && 254 background.GetBlue() == 1.) { 255 createRadioAction(white,black,SLOT(toggleBackground(bool)),1); 256 } else { 257 createRadioAction(white,black,SLOT(toggleBackground(bool)),2); 258 } 259 260 261 // Action Menu 262 QMenu *mActions = fContextMenu->addMenu("&Actions"); 263 QAction *rotation = mActions->addAction("Rotation control panel"); 264 QAction *panning = mActions->addAction("Panning control panel"); 265 QAction *setControl = mActions->addAction("Set control panel limits"); 266 267 // Miscellany Menu 268 QMenu * mMisc = fContextMenu->addMenu("&Miscellany"); 269 QAction *miscellany = mMisc->addAction("Miscellany control panel"); 270 QAction *exitG4 = mMisc->addAction("Exit to G4Vis >"); 271 QAction *createEPS = mMisc->addAction("Create .eps file"); 272 273 // Special Menu 274 QMenu *mSpecial = fContextMenu->addMenu("S&pecial"); 275 QMenu *transparency = mSpecial->addMenu("Transparency"); 276 QAction *transparencyOn = transparency->addAction("On"); 277 QAction *transparencyOff = transparency->addAction("Off"); 278 if (transparency_enabled == false) { 279 createRadioAction(transparencyOn,transparencyOff,SLOT(toggleTransparency(bool)),2); 280 } else if (transparency_enabled == true) { 281 createRadioAction(transparencyOn,transparencyOff,SLOT(toggleTransparency(bool)),1); 282 } else { 283 mSpecial->clear(); 284 } 285 286 287 QMenu *mAntialiasing = mSpecial->addMenu("Antialiasing"); 288 QAction *antialiasingOn = mAntialiasing->addAction("On"); 289 QAction *antialiasingOff = mAntialiasing->addAction("Off"); 290 if (antialiasing_enabled == false) { 291 createRadioAction(antialiasingOn,antialiasingOff,SLOT(toggleAntialiasing(bool)),2); 292 } else if (antialiasing_enabled == true) { 293 createRadioAction(antialiasingOn,antialiasingOff,SLOT(toggleAntialiasing(bool)),1); 294 } else { 295 mAntialiasing->clear(); 296 } 297 298 QMenu *mHaloing = mSpecial->addMenu("Haloing"); 299 QAction *haloingOn = mHaloing->addAction("On"); 300 QAction *haloingOff = mHaloing->addAction("Off"); 301 if (haloing_enabled == false) { 302 createRadioAction(haloingOn,haloingOff,SLOT(toggleHaloing(bool)),2); 303 } else if (haloing_enabled == true) { 304 createRadioAction(haloingOn,haloingOff,SLOT(toggleHaloing(bool)),1); 305 } else { 306 mHaloing->clear(); 307 } 308 309 QMenu *mAux = mSpecial->addMenu("Auxiliary edges"); 310 QAction *auxOn = mAux->addAction("On"); 311 QAction *auxOff = mAux->addAction("Off"); 312 if (!fVP.IsAuxEdgeVisible()) { 313 createRadioAction(auxOn,auxOff,SLOT(toggleAux(bool)),1); 314 } else { 315 createRadioAction(auxOn,auxOff,SLOT(toggleAux(bool)),2); 316 } 317 318 319 QMenu *mFullScreen = mSpecial->addMenu("Full screen"); 320 QAction *fullOn = mFullScreen->addAction("On"); 321 QAction *fullOff = mFullScreen->addAction("Off"); 322 createRadioAction(fullOn,fullOff,SLOT(toggleFullScreen(bool)),2); 323 324 } 325 326 void G4OpenGLQtViewer::manageContextMenuEvent(QContextMenuEvent *e) 327 { 328 if (!GLWindow) return; 329 330 if (!fContextMenu) 331 createPopupMenu(); 332 333 // launch menu 334 if ( fContextMenu ) { 335 fContextMenu->exec( e->globalPos() ); 336 // delete fContextMenu; 337 } 338 e->accept(); 339 } 340 341 342 /** 343 Create a radio button menu. The two menu will be connected. When click on one, 344 eatch state will be invert and callback method will be called. 345 @param action1 first action to connect 346 @param action2 second action to connect 347 @param method callback method 348 @param nCheck: 1 : first action will be set true. 2 : second action will be set true 349 */ 350 void G4OpenGLQtViewer::createRadioAction(QAction *action1,QAction *action2, const std::string& method,unsigned int nCheck) { 351 352 action1->setCheckable(true); 353 action2->setCheckable(true); 354 355 if (nCheck ==1) 356 action1->setChecked (true); 357 else 358 action2->setChecked (true); 359 360 QObject ::connect(action1, SIGNAL(triggered(bool)),action2, SLOT(toggle())); 361 QObject ::connect(action2, SIGNAL(triggered(bool)),action1, SLOT(toggle())); 362 363 QObject ::connect(action1, SIGNAL(toggled(bool)),this, method.c_str()); 364 365 } 366 367 /** 368 Slot activate when drawing->wireframe menu is set 369 */ 370 void G4OpenGLQtViewer::actionDrawingWireframe() { 371 emit toggleDrawingAction(1); 372 } 373 374 /** 375 Slot activate when drawing->line removal menu is set 376 */ 377 void G4OpenGLQtViewer::actionDrawingLineRemoval() { 378 emit toggleDrawingAction(2); 379 } 380 381 /** 382 Slot activate when drawing->surface removal menu is set 383 */ 384 void G4OpenGLQtViewer::actionDrawingSurfaceRemoval() { 385 emit toggleDrawingAction(3); 386 } 387 388 /** 389 Slot activate when drawing->wireframe menu is set 390 */ 391 void G4OpenGLQtViewer::actionDrawingLineSurfaceRemoval() { 392 emit toggleDrawingAction(4); 393 } 394 395 396 /** 397 Slot activated when drawing menu is toggle 398 @param aAction : 1 wireframe, 2 line removal, 3 surface removal, 4 line & surface removal 399 */ 400 void G4OpenGLQtViewer::toggleDrawingAction(int aAction) { 401 402 G4ViewParameters::DrawingStyle d_style; 403 404 405 if (aAction ==1) { 406 fDrawingWireframe->setChecked (true); 407 fDrawingLineRemoval->setChecked (false); 408 fDrawingSurfaceRemoval->setChecked (false); 409 fDrawingLineSurfaceRemoval->setChecked (false); 410 411 d_style = G4ViewParameters::wireframe; 412 413 } else if (aAction ==2) { 414 fDrawingWireframe->setChecked (false); 415 fDrawingLineRemoval->setChecked (true); 416 fDrawingSurfaceRemoval->setChecked (false); 417 fDrawingLineSurfaceRemoval->setChecked (false); 418 419 d_style = G4ViewParameters::hlr; 420 421 } else if (aAction ==3) { 422 fDrawingWireframe->setChecked (false); 423 fDrawingLineRemoval->setChecked (false); 424 fDrawingSurfaceRemoval->setChecked (true); 425 fDrawingLineSurfaceRemoval->setChecked (false); 426 427 d_style = G4ViewParameters::hsr; 428 429 } else if (aAction ==4) { 430 fDrawingWireframe->setChecked (false); 431 fDrawingLineRemoval->setChecked (false); 432 fDrawingSurfaceRemoval->setChecked (false); 433 fDrawingLineSurfaceRemoval->setChecked (true); 434 435 d_style = G4ViewParameters::hlhsr; 436 } 437 fVP.SetDrawingStyle(d_style); 438 439 updateQWidget(); 440 printf("G4OpenGLQtViewer::toggleDrawingAction\n"); 441 } 442 443 444 /** 445 SLOT Activate by a click on the representation menu 446 @param check : 1 polyhedron, 0 nurbs 447 */ 448 void G4OpenGLQtViewer::toggleRepresentation(bool check) { 449 450 G4ViewParameters::RepStyle style; 451 if (check == 1) { 452 style = G4ViewParameters::polyhedron; 453 } else { 454 style = G4ViewParameters::nurbs; 455 } 456 fVP.SetRepStyle (style); 457 458 printf("G4OpenGLQtViewer::toggleRepresentation 3%d\n",check); 459 updateQWidget(); 460 printf("G4OpenGLQtViewer::toggleRepresentation 4%d\n",check); 461 } 462 463 /** 464 SLOT Activate by a click on the background menu 465 @param check : 1 white, 0 black 466 */ 467 void G4OpenGLQtViewer::toggleBackground(bool check) { 468 469 // //I need to revisit the kernel if the background colour changes and 470 // //hidden line removal is enabled, because hlr drawing utilises the 471 // //background colour in its drawing... 472 // // (Note added by JA 13/9/2005) Background now handled in view 473 // // parameters. A kernel visit is triggered on change of background. 474 if (check == 1) { 475 ((G4ViewParameters&)this->GetViewParameters()). 476 SetBackgroundColour(G4Colour(1.,1.,1.)); // White 477 } else { 478 ((G4ViewParameters&)this->GetViewParameters()). 479 SetBackgroundColour(G4Colour(0.,0.,0.)); // Black 480 } 481 updateQWidget(); 482 } 483 484 /** 485 SLOT Activate by a click on the transparency menu 486 @param check : 1 , 0 487 */ 488 void G4OpenGLQtViewer::toggleTransparency(bool check) { 489 490 if (check) { 491 transparency_enabled = false; 492 } else { 493 transparency_enabled = true; 494 } 495 SetNeedKernelVisit (true); 496 updateQWidget(); 497 } 498 499 /** 500 SLOT Activate by a click on the antialiasing menu 501 @param check : 1 , 0 502 */ 503 void G4OpenGLQtViewer::toggleAntialiasing(bool check) { 504 505 if (!check) { 506 antialiasing_enabled = false; 507 glDisable (GL_LINE_SMOOTH); 508 glDisable (GL_POLYGON_SMOOTH); 509 } else { 510 antialiasing_enabled = true; 511 glEnable (GL_LINE_SMOOTH); 512 glHint (GL_LINE_SMOOTH_HINT, GL_NICEST); 513 glEnable (GL_POLYGON_SMOOTH); 514 glHint (GL_POLYGON_SMOOTH_HINT, GL_NICEST); 515 } 516 517 updateQWidget(); 518 printf("G4OpenGLQtViewer::toggleRepresentation %d\n",check); 519 } 520 521 /** 522 SLOT Activate by a click on the haloing menu 523 @param check : 1 , 0 524 */ 525 //FIXME : I SEE NOTHING... 526 void G4OpenGLQtViewer::toggleHaloing(bool check) { 527 if (check) { 528 haloing_enabled = false; 529 } else { 530 haloing_enabled = true; 531 } 532 533 updateQWidget(); 534 535 printf("G4OpenGLQtViewer::toggleRepresentation %d\n",check); 536 } 537 538 /** 539 SLOT Activate by a click on the auxiliaire edges menu 540 @param check : 1 , 0 541 */ 542 void G4OpenGLQtViewer::toggleAux(bool check) { 543 if (check) { 544 fVP.SetAuxEdgeVisible(false); 545 } else { 546 fVP.SetAuxEdgeVisible(true); 547 } 548 SetNeedKernelVisit (true); 549 updateQWidget(); 550 551 printf("G4OpenGLQtViewer::toggleRepresentation %d\n",check); 552 } 553 554 /** 555 SLOT Activate by a click on the full screen menu 556 @param check : 1 , 0 557 */ 558 void G4OpenGLQtViewer::toggleFullScreen(bool check) { 559 GLWindow->setWindowState(GLWindow->windowState() ^ Qt::WindowFullScreen); 560 561 printf("G4OpenGLQtViewer::toggleRepresentation %d\n",check); 562 } 563 564 /** 565 SLOT Activate by a click on the mouse action menu 566 @param check : 1 , 0 567 */ 568 void G4OpenGLQtViewer::toggleMouseAction(bool check) { 569 if (check) { // rotate scene 570 fMouseAction = true; 571 } else { // move scene 572 fMouseAction = false; 573 } 574 575 printf("G4OpenGLQtViewer::toggleRepresentation %d\n",check); 576 } 577 578 579 /** 580 Save the current mouse press point 581 @param p mouse click point 582 */ 583 void G4OpenGLQtViewer::G4MousePressEvent(QPoint p) 584 { 585 lastPos = p; 586 } 587 588 /** 589 @param pos_x mouse x position 590 @param pos_y mouse y position 591 @param mButtons mouse button active 592 */ 593 void G4OpenGLQtViewer::G4MouseMoveEvent(int pos_x, int pos_y,Qt::MouseButtons mButtons) 594 { 595 int dx = pos_x - lastPos.x(); 596 int dy = pos_y - lastPos.y(); 597 598 if (fMouseAction) { // rotate 599 if (mButtons & Qt::LeftButton) { 600 //phi spin stuff here 601 602 G4Vector3D vp = fVP.GetViewpointDirection ().unit (); 603 G4Vector3D up = fVP.GetUpVector ().unit (); 604 605 G4Vector3D yprime = (up.cross(vp)).unit(); 606 G4Vector3D zprime = (vp.cross(yprime)).unit(); 607 608 G4double delta_alpha; 609 G4double delta_theta; 610 611 if (fVP.GetLightsMoveWithCamera()) { 612 delta_alpha = dy; 613 delta_theta = -dx; 614 } else { 615 delta_alpha = -dy; 616 delta_theta = dx; 617 } 618 619 delta_alpha *= deg; 620 delta_theta *= deg; 621 622 G4Vector3D new_vp = std::cos(delta_alpha) * vp + std::sin(delta_alpha) * zprime; 623 624 G4Vector3D new_up; 625 if (fVP.GetLightsMoveWithCamera()) { 626 new_up = (new_vp.cross(yprime)).unit(); 627 fVP.SetUpVector(new_up); 628 } else { 629 new_up = up; 630 } 631 //////////////// 632 // Rotates by fixed azimuthal angle delta_theta. 633 634 G4double cosalpha = new_up.dot (new_vp.unit()); 635 G4double sinalpha = std::sqrt (1. - std::pow (cosalpha, 2)); 636 yprime = (new_up.cross (new_vp.unit())).unit (); 637 G4Vector3D xprime = yprime.cross (new_up); 638 // Projection of vp on plane perpendicular to up... 639 G4Vector3D a1 = sinalpha * xprime; 640 // Required new projection... 641 G4Vector3D a2 = 642 sinalpha * (std::cos (delta_theta) * xprime + std::sin (delta_theta) * yprime); 643 // Required Increment vector... 644 G4Vector3D delta = a2 - a1; 645 // So new viewpoint is... 646 G4Vector3D viewPoint = new_vp.unit() + delta; 647 648 fVP.SetViewAndLights (viewPoint); 649 updateQWidget(); 650 651 } else if (mButtons & Qt::RightButton) { 652 // NEVER DONE BECAUSE OF MOUSE MENU 653 // printf("G4OpenGLQtViewer::mouseMoveEvent Right \n"); 654 // setXRotation(xRot + dy/2); 655 // setZRotation(zRot + dx/2); 656 // updateQWidget(); 657 } 658 } else { // move 659 660 float dx = pos_x - lastPos.x(); 661 float dy = pos_y - lastPos.y(); 317 662 318 // if(fWindow) { 319 // ::SetWindowLong(fWindow,GWL_USERDATA,LONG(NULL)); 320 // if(fHDC) ::ReleaseDC(fWindow,fHDC); 321 // ::DestroyWindow(fWindow); 322 // } 323 // } 324 } 325 326 // ////////////////////////////////////////////////////////////////////////////// 327 // LRESULT CALLBACK G4OpenGLQtViewer::WindowProc ( 328 // HWND aWindow 329 // ,UINT aMessage 330 // ,WPARAM aWParam 331 // ,LPARAM aLParam 332 // ) 333 // ////////////////////////////////////////////////////////////////////////////// 334 // //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 335 // { 336 /* 337 switch (aMessage) { 338 case WM_PAINT:{ 339 printf("debug : PAINT\n"); 340 HDC hDC; 341 PAINTSTRUCT ps; 342 hDC = BeginPaint(aWindow,&ps); 343 if(This) { 344 // FIXME : To have an automatic refresh someone have to redraw here. 345 } 346 EndPaint(aWindow, &ps); 347 348 //FIXME : have to handle WM_RESIZE 349 //pView->WinSize_x = (G4int) width; 350 //pView->WinSize_y = (G4int) height; 351 G4OpenGLQtViewer* This = 352 (G4OpenGLQtViewer*)::GetWindowLong(aWindow,GWL_USERDATA); 353 if(This) { 354 This->SetView(); 355 glViewport(0,0,This->WinSize_x,This->WinSize_y); 356 This->ClearView(); 357 This->DrawView(); 358 // WARNING : the below empty the Windows message queue... 359 This->FinishView(); 360 } 361 } return 0; 362 default: 363 return DefWindowProc(aWindow,aMessage,aWParam,aLParam); 364 } 365 */ 366 // return DefWindowProc(aWindow,aMessage,aWParam,aLParam); 367 // } 368 369 // ////////////////////////////////////////////////////////////////////////////// 370 // bool G4OpenGLQtViewer::SetWindowPixelFormat( 371 // HDC aHdc 372 // ) 373 // ////////////////////////////////////////////////////////////////////////////// 374 // //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 375 // { 376 // // The ungessable... 377 378 // PIXELFORMATDESCRIPTOR pfd; 379 // pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); 380 // pfd.nVersion = 1; 381 // pfd.dwFlags = 382 // PFD_DRAW_TO_WINDOW | 383 // PFD_SUPPORT_OPENGL | 384 // PFD_DOUBLEBUFFER | 385 // PFD_STEREO_DONTCARE; 386 // pfd.iPixelType = PFD_TYPE_RGBA; 387 // pfd.cColorBits = 32; 388 // pfd.cRedBits = 8; 389 // pfd.cRedShift = 16; 390 // pfd.cGreenBits = 8; 391 // pfd.cGreenShift = 8; 392 // pfd.cBlueBits = 8; 393 // pfd.cBlueShift = 0; 394 // pfd.cAlphaBits = 0; 395 // pfd.cAlphaShift = 0; 396 // pfd.cAccumBits = 64; 397 // pfd.cAccumRedBits = 16; 398 // pfd.cAccumGreenBits = 16; 399 // pfd.cAccumBlueBits = 16; 400 // pfd.cAccumAlphaBits = 0; 401 // pfd.cDepthBits = 32; 402 // pfd.cStencilBits = 8; 403 // pfd.cAuxBuffers = 0; 404 // pfd.iLayerType = PFD_MAIN_PLANE; 405 // pfd.bReserved = 0; 406 // pfd.dwLayerMask = 0; 407 // pfd.dwVisibleMask = 0; 408 // pfd.dwDamageMask = 0; 409 410 // int pixelIndex = ::ChoosePixelFormat(aHdc,&pfd); 411 // if (pixelIndex==0) { 412 // pixelIndex = 1; 413 // if (::DescribePixelFormat(aHdc, 414 // pixelIndex, 415 // sizeof(PIXELFORMATDESCRIPTOR), 416 // &pfd)==0) { 417 // return false; 418 // } 419 // } 420 // if (::SetPixelFormat(aHdc,pixelIndex,&pfd)==FALSE) return false; 421 // return true; 422 //} 423 663 G4Point3D stp 664 = GetSceneHandler()->GetScene()->GetStandardTargetPoint(); 665 666 G4Point3D tp = stp + fVP.GetCurrentTargetPoint (); 667 668 const G4Vector3D& upVector = fVP.GetUpVector (); 669 const G4Vector3D& vpVector = fVP.GetViewpointDirection (); 670 671 G4Vector3D unitRight = (upVector.cross (vpVector)).unit(); 672 G4Vector3D unitUp = (vpVector.cross (unitRight)).unit(); 673 674 tp += -dx * unitRight + dy * unitUp; 675 fVP.SetCurrentTargetPoint (tp - stp); 676 677 updateQWidget(); 678 } 679 lastPos = QPoint(pos_x, pos_y); 680 } 424 681 425 682 #endif -
trunk/geant4/visualization/OpenGL/src/G4OpenGLStoredQt.cc
r555 r564 25 25 // 26 26 // 27 // $Id: G4OpenGLStoredQt.cc,v 1.1 4 2007/06/2512:07:19 $27 // $Id: G4OpenGLStoredQt.cc,v 1.11 2007/06/24 12:07:19 $ 28 28 // GEANT4 tag $Name: geant4-08-02-patch-01 $ 29 29 // 30 30 // 31 31 // OpenGLStoredQt graphics system factory. 32 33 32 34 33 #ifdef G4VIS_BUILD_OPENGLQT_DRIVER … … 44 43 G4OpenGLStoredQt::G4OpenGLStoredQt (): 45 44 G4VGraphicsSystem ("OpenGLStoredQt", 46 "OGLSQ t",47 G4VisFeaturesOfOpenGL SQt (),45 "OGLSQT", 46 G4VisFeaturesOfOpenGLIQt (), 48 47 G4VGraphicsSystem::threeD) 49 48 { … … 59 58 G4VViewer* G4OpenGLStoredQt::CreateViewer 60 59 (G4VSceneHandler& scene, const G4String& name) { 61 printf(" ....................................G4OpenGLStoredQt::CreateViewer \n");60 printf("G4OpenGLStoredQt::CreateViewer \n"); 62 61 G4VViewer* pView = 63 new G4OpenGLStoredQtViewer ((G4OpenGLStoredSceneHandler&) scene, name); 62 new G4OpenGLStoredQtViewer 63 ((G4OpenGLStoredSceneHandler&) scene, name); 64 64 if (pView) { 65 65 if (pView -> GetViewId () < 0) { 66 G4cerr << "G4OpenGLStoredQt::CreateViewer: error flagged by negative" 67 " view id in G4OpenGLStoredQtViewer creation." 68 "\n Destroying view and returning null pointer." 69 << G4endl; 66 70 delete pView; 67 71 pView = 0; 68 G4cerr << "G4OpenGLStoredQt::CreateViewer: error flagged by"69 " negative view id in G4OpenGLStoredQtViewer creation."70 "\n Destroying view and returning null pointer." << G4endl;71 72 } 72 73 } … … 75 76 " new G4OpenGLStoredQtViewer." << G4endl; 76 77 } 77 printf(" ...................................G4OpenGLStoredQt::CreateViewer END\n");78 return pView;78 printf("G4OpenGLStoredQt::CreateViewer END \n"); 79 return pView; 79 80 } 80 81 81 82 #endif 82 -
trunk/geant4/visualization/OpenGL/src/G4OpenGLStoredQtViewer.cc
r555 r564 25 25 // 26 26 // 27 // $Id: G4OpenGLStoredQtViewer.cc,v 1.1 8 2007/06/25 12:07:59$27 // $Id: G4OpenGLStoredQtViewer.cc,v 1.16 2007/06/25 16:38:13 $ 28 28 // GEANT4 tag $Name: geant4-08-02-patch-01 $ 29 29 // 30 // 30 // 31 31 // Class G4OpenGLStoredQtViewer : a class derived from G4OpenGLQtViewer and 32 // G4OpenGLStoredViewer.32 // G4OpenGLStoredViewer. 33 33 34 34 #ifdef G4VIS_BUILD_OPENGLQT_DRIVER 35 35 36 36 #include "G4OpenGLStoredQtViewer.hh" 37 #include "G4VisManager.hh" 37 38 38 39 #include "G4ios.hh" … … 41 42 (G4OpenGLStoredSceneHandler& sceneHandler, 42 43 const G4String& name): 43 G4OpenGLViewer (sceneHandler), 44 G4OpenGLQtViewer (sceneHandler), 45 G4OpenGLStoredViewer (sceneHandler), 46 G4VViewer (sceneHandler, sceneHandler.IncrementViewCount (), name) { 47 44 G4VViewer (sceneHandler, sceneHandler.IncrementViewCount (), name), 45 G4OpenGLViewer (sceneHandler), 46 G4OpenGLQtViewer (sceneHandler), 47 G4OpenGLStoredViewer (sceneHandler), 48 QGLWidget() // FIXME : gerer le pb du parent ! 49 { 50 nbPaint =0; 51 hasToRepaint =false; 48 52 if (fViewId < 0) return; // In case error in base class instantiation. 49 53 } 50 54 51 void G4OpenGLStoredQtViewer::Initialise () { 52 53 //Check that G4OpenGLQtViewer got a double buffered colour visual 54 55 CreateGLQtContext (); 56 CreateMainWindow (); 57 CreateFontLists (); 58 59 // clear the buffers and window. 60 ClearView (); 61 FinishView (); 62 63 glDepthFunc (GL_LEQUAL); 64 glDepthMask (GL_TRUE); 65 } 55 G4OpenGLStoredQtViewer::~G4OpenGLStoredQtViewer() { 56 printf("GLWidget::~GLWidget \n"); 57 makeCurrent(); 58 printf("GLWidget::~GLWidget END\n"); 59 } 60 61 void G4OpenGLStoredQtViewer::Initialise() { 62 printf("GLWidget::Initialise \n"); 63 readyToPaint = false; 64 CreateGLQtContext (); 65 printf("G4OpenGLStoredQtViewer::Initialise () 2\n"); 66 67 CreateMainWindow (this); 68 printf("G4OpenGLStoredQtViewer::Initialise () 3\n"); 69 70 CreateFontLists (); // FIXME Does nothing! 71 72 printf("readyToPaint = true \n"); 73 readyToPaint = true; 74 75 // First Draw 76 SetView(); 77 printf(" ClearView\n"); 78 ClearView (); //ok, put the background correct 79 ShowView(); 80 FinishView(); 81 } 82 83 void G4OpenGLStoredQtViewer::initializeGL () { 84 85 InitializeGLView (); 86 87 printf("G4OpenGLStoredQtViewer::InitialiseGL () 1\n"); 88 89 // clear the buffers and window. 90 ClearView (); 91 // printf("G4OpenGLStoredQtViewer::InitialiseGL () 2\n"); 92 FinishView (); 93 94 glDepthFunc (GL_LEQUAL); 95 glDepthMask (GL_TRUE); 96 97 hasToRepaint =true; 98 99 printf("G4OpenGLStoredQtViewer::InitialiseGL -------------------------------------------------------------------------------------\n"); 100 } 101 66 102 67 103 void G4OpenGLStoredQtViewer::DrawView () { 68 104 69 //Make sure current viewer is attached and clean... 70 //Qt version needed 71 // glXMakeCurrent (dpy, win, cx); 72 glViewport (0, 0, WinSize_x, WinSize_y); 73 74 G4ViewParameters::DrawingStyle style = GetViewParameters().GetDrawingStyle(); 75 76 //See if things have changed from last time and remake if necessary... 77 // The fNeedKernelVisit flag might have been set by the user in 78 // /vis/viewer/rebuild, but if not, make decision and set flag only 79 // if necessary... 80 if (!fNeedKernelVisit) KernelVisitDecision (); 81 G4bool kernelVisitWasNeeded = fNeedKernelVisit; // Keep (ProcessView resets). 82 ProcessView (); 83 84 if(style!=G4ViewParameters::hlr && 85 haloing_enabled) { 86 87 HaloingFirstPass (); 88 DrawDisplayLists (); 89 glFlush (); 90 91 HaloingSecondPass (); 92 93 DrawDisplayLists (); 94 FinishView (); 95 96 } else { 97 98 // If kernel visit was needed, drawing and FinishView will already 99 // have been done, so... 100 if (!kernelVisitWasNeeded) { 101 DrawDisplayLists (); 102 FinishView (); 103 } else { 104 // However, union cutaways are implemented in DrawDisplayLists, so make 105 // an extra pass... 106 if (fVP.IsCutaway() && 107 fVP.GetCutawayMode() == G4ViewParameters::cutawayUnion) { 108 ClearView(); 109 DrawDisplayLists (); 110 FinishView (); 111 } 112 } 113 } 114 } 105 printf("G4OpenGLStoredQtViewer::DrawView %d %d VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n",WinSize_x, WinSize_y); 106 107 G4ViewParameters::DrawingStyle style = GetViewParameters().GetDrawingStyle(); 108 109 //Make sure current viewer is attached and clean... 110 //Qt version needed 111 glViewport (0, 0, WinSize_x, WinSize_y); 112 113 //See if things have changed from last time and remake if necessary... 114 // The fNeedKernelVisit flag might have been set by the user in 115 // /vis/viewer/rebuild, but if not, make decision and set flag only 116 // if necessary... 117 if (!fNeedKernelVisit) KernelVisitDecision (); 118 G4bool kernelVisitWasNeeded = fNeedKernelVisit; // Keep (ProcessView resets). 119 ProcessView (); 120 121 122 if(style!=G4ViewParameters::hlr && 123 haloing_enabled) { 124 printf("G4OpenGLStoredQtViewer::DrawView DANS LE IF\n"); 125 126 HaloingFirstPass (); 127 DrawDisplayLists (); 128 glFlush (); 129 130 HaloingSecondPass (); 131 132 DrawDisplayLists (); 133 134 } else { 135 136 // If kernel visit was needed, drawing and FinishView will already 137 // have been done, so... 138 if (!kernelVisitWasNeeded) { 139 DrawDisplayLists (); 140 } else { 141 // However, union cutaways are implemented in DrawDisplayLists, so make 142 // an extra pass... 143 if (fVP.IsCutaway() && 144 fVP.GetCutawayMode() == G4ViewParameters::cutawayUnion) { 145 ClearView(); 146 DrawDisplayLists (); 147 } 148 } 149 } 150 151 FinishView (); 152 printf("G4OpenGLStoredQtViewer::DrawView %d %d ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n",WinSize_x, WinSize_y); 153 hasToRepaint =true; 154 } 155 115 156 116 157 ////////////////////////////////////////////////////////////////////////////// … … 120 161 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 121 162 { 122 printf("................G4OpenGLStoredQtViewer::FinishView"); 123 if(!fWindow) return; 163 printf("G4OpenGLStoredQtViewer::FinishView VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n"); 124 164 125 165 glFlush (); 126 fWindow->swapBuffers (); 127 printf("................G4OpenGLStoredQtViewer::FinishView END"); 166 swapBuffers (); 167 printf("G4OpenGLStoredQtViewer::FinishView ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n"); 168 169 } 170 171 172 /** 173 - Lors du resize de la fenetre, on doit non pas redessiner le detecteur, mais aussi les evenements 174 */ 175 void G4OpenGLStoredQtViewer::resizeGL( 176 int aWidth 177 ,int aHeight) 178 { 179 glViewport(0, 0, aWidth, aHeight); 180 glMatrixMode(GL_PROJECTION); 181 glMatrixMode(GL_MODELVIEW); 182 183 if (((WinSize_x != (G4int)aWidth)) || (WinSize_y != (G4int) aHeight)) { 184 hasToRepaint =true; 185 } 186 WinSize_x = (G4int) aWidth; 187 WinSize_y = (G4int) aHeight; 188 189 printf("G4OpenGLStoredQtViewer::resizeGL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ %d %d=%d %d=%d\n",hasToRepaint,width(),aWidth,height(),aHeight); 190 } 191 192 193 194 void G4OpenGLStoredQtViewer::paintGL() 195 { 196 if (!readyToPaint) { 197 printf("\n\nG4OpenGLStoredQtViewer::paintGL ============ Not ready %d\n",readyToPaint); 198 readyToPaint= true; 199 return; 200 } 201 // DO NOT RESIZE IF SIZE HAS NOT CHANGE : 202 // WHEN CLICK ON THE FRAME FOR EXAMPLE 203 // EXECEPT WHEN MOUSE MOVE EVENT 204 if ( !hasToRepaint) { 205 if (((WinSize_x == (G4int)width())) &&(WinSize_y == (G4int) height())) { 206 printf("\n\nG4OpenGLStoredQtViewer::paintGL ============ Dont repaint\n"); 207 return; 208 } 209 } 210 nbPaint++; 211 printf("\n\nG4OpenGLStoredQtViewer::paintGL VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV %d ready %d\n",nbPaint,readyToPaint); 212 WinSize_x = (G4int) width(); 213 WinSize_y = (G4int) height(); 214 215 glViewport (0, 0, width(), height()); 216 // glLoadIdentity(); 217 218 219 SetView(); 220 221 // // printf("before ClearView\n"); 222 printf(" ClearView\n"); 223 224 ClearView (); //ok, put the background correct 225 DrawView(); 226 227 hasToRepaint =false; 228 229 printf("G4OpenGLStoredQtViewer::paintGL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ %d ready %d\n\n\n",nbPaint,readyToPaint); 230 } 231 232 void G4OpenGLStoredQtViewer::mousePressEvent(QMouseEvent *event) 233 { 234 printf("G4OpenGLStoredQtViewer::mousePressEvent\n"); 235 G4MousePressEvent(event->pos()); 236 } 237 238 void G4OpenGLStoredQtViewer::mouseMoveEvent(QMouseEvent *event) 239 { 240 G4MouseMoveEvent(event->x(),event->y(),event->buttons()); 241 // DrawView(); 242 } 243 244 245 void G4OpenGLStoredQtViewer::contextMenuEvent(QContextMenuEvent *e) 246 { 247 manageContextMenuEvent(e); 248 } 249 250 void G4OpenGLStoredQtViewer::updateQWidget() { 251 hasToRepaint= true; 252 updateGL(); 253 hasToRepaint= false; 128 254 } 129 255 -
trunk/geant4/visualization/OpenGL/src/G4OpenGLStoredViewer.cc
r529 r564 144 144 if (fG4OpenGLStoredSceneHandler.fTopPODL) 145 145 glCallList (fG4OpenGLStoredSceneHandler.fTopPODL); 146 147 for (size_t i = 0; i < fG4OpenGLStoredSceneHandler.fTOList.size(); ++i) { 146 size_t tmp_size = fG4OpenGLStoredSceneHandler.fTOList.size(); 147 G4double bsf = 1.; // Brightness scaling factor. 148 for (size_t i = 0; i < tmp_size; ++i) { 148 149 G4OpenGLStoredSceneHandler::TO& to = 149 150 fG4OpenGLStoredSceneHandler.fTOList[i]; 150 if ( to.fEndTime >= fStartTime && to.fStartTime <= fEndTime) {151 if ((!(to.fEndTime < fStartTime ))&& (!(to.fStartTime > fEndTime))) { 151 152 glPushMatrix(); 152 153 G4OpenGLTransform3D oglt (to.fTransform); 153 154 glMultMatrixd (oglt.GetGLMatrix ()); 154 155 G4Colour& c = to.fColour; 155 G4double bsf = 1.; // Brightness scaling factor.156 156 if (fFadeFactor > 0. && to.fEndTime < fEndTime) 157 157 bsf = 1. - fFadeFactor * -
trunk/geant4/visualization/OpenGL/src/G4OpenGLTransform3D.cc
r529 r564 49 49 *p++ = operator()(k,i); 50 50 } 51 *p++ = 0.; 51 *p++ = 0.; 52 52 } 53 53 m[15] = 1.; -
trunk/geant4/visualization/currentEvent.rndm
r562 r564 2 2 1878463799 3 3 0 4 9876 5 54321 4 1180857998 5 122938492 -
trunk/geant4/visualization/management/include/G4VisExecutive.icc
r561 r564 105 105 RegisterGraphicsSystem (new G4VRML1File); 106 106 RegisterGraphicsSystem (new G4VRML2File); 107 108 107 // Graphics systems needing external packages or libraries... 109 108 -
trunk/geant4/visualization/management/src/G4VisManager.cc
r558 r564 86 86 fpSceneHandler (0), 87 87 fpViewer (0), 88 fVerbosity ( warnings),88 fVerbosity (confirmations),//(warnings), 89 89 fpStateDependent (0), 90 90 fEventRefreshing (false), … … 118 118 if (fpInstance) { 119 119 G4Exception 120 ("G4VisManager: attempt to Construct more than one VisManager. ");120 ("G4VisManager: attempt to Construct more than one VisManager. "); 121 121 } 122 122 else { … … 1104 1104 void G4VisManager::BeginOfRun () 1105 1105 { 1106 //G4cout << "G4VisManager::BeginOfRun" << G4endl;1106 G4cout << "G4VisManager::BeginOfRun" << G4endl; 1107 1107 fKeptLastEvent = false; 1108 1108 fEventKeepingSuspended = false; … … 1113 1113 void G4VisManager::BeginOfEvent () 1114 1114 { 1115 //G4cout << "G4VisManager::BeginOfEvent" << G4endl;1115 G4cout << "G4VisManager::BeginOfEvent" << G4endl; 1116 1116 fTransientsDrawnThisEvent = false; 1117 1117 if (fpSceneHandler) fpSceneHandler->SetTransientsDrawnThisEvent(false); … … 1120 1120 void G4VisManager::EndOfEvent () 1121 1121 { 1122 //G4cout << "G4VisManager::EndOfEvent" << G4endl;1122 G4cout << "G4VisManager::EndOfEvent" << G4endl; 1123 1123 1124 1124 // Don't call IsValidView unless there is a scene handler. This … … 1136 1136 1137 1137 ClearTransientStoreIfMarked(); 1138 printf("G4VisManager::DrawEvent \n"); 1138 1139 fpSceneHandler->DrawEvent(currentEvent); 1140 printf("G4VisManager::DrawEvent END\n"); 1139 1141 1140 1142 G4int nEventsToBeProcessed = 0; … … 1187 1189 void G4VisManager::EndOfRun () 1188 1190 { 1189 //G4cout << "G4VisManager::EndOfRun" << G4endl;1191 G4cout << "G4VisManager::EndOfRun" << G4endl; 1190 1192 1191 1193 // Don't call IsValidView unless there is a scene handler. This
Note: See TracChangeset
for help on using the changeset viewer.