Changeset 554 for trunk/geant4/visualization/OpenGL
- Timestamp:
- Jul 12, 2007, 5:33:07 PM (17 years ago)
- Location:
- trunk/geant4/visualization/OpenGL
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/geant4/visualization/OpenGL/include/G4OpenGLImmediateQtViewer.hh
r552 r554 63 63 int readyToPaint; 64 64 65 66 private:67 GLuint makeObject();68 void quad(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2,69 GLdouble x3, GLdouble y3, GLdouble x4, GLdouble y4);70 void extrude(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2);71 /* void normalizeAngle(int *angle); */72 73 GLuint object;74 int xRot;75 int yRot;76 int zRot;77 QPoint lastPos;78 QColor trolltechGreen;79 QColor trolltechPurple;80 81 65 }; 82 66 -
trunk/geant4/visualization/OpenGL/src/G4OpenGLImmediateQtViewer.cc
r553 r554 49 49 50 50 if (fViewId < 0) return; // In case error in base class instantiation. 51 printf("GLWidget::GLWidget \n");52 object = 0;53 xRot = 0;54 yRot = 0;55 zRot = 0;56 57 trolltechGreen = QColor::fromCmykF(0.40, 0.0, 1.0, 0.0);58 trolltechPurple = QColor::fromCmykF(0.39, 0.39, 0.0, 0.0);59 printf("GLWidget::GLWidget END\n");60 51 } 61 52 … … 63 54 printf("GLWidget::~GLWidget \n"); 64 55 makeCurrent(); 65 glDeleteLists(object, 1);66 56 printf("GLWidget::~GLWidget END\n"); 67 57 } … … 85 75 86 76 void G4OpenGLImmediateQtViewer::initializeGL () { 87 printf("GLWidget::initializeGL \n"); 88 qglClearColor(trolltechPurple.dark()); 89 object = makeObject(); 90 glShadeModel(GL_FLAT); 91 glEnable(GL_DEPTH_TEST); 92 glEnable(GL_CULL_FACE); 93 printf("GLWidget::initializeGL END\n"); 94 95 // printf("G4OpenGLImmediateQtViewer::InitialiseGL ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); 96 97 // // ensure a suitable window was found 98 99 100 // InitializeGLView (); 101 102 // printf("G4OpenGLImmediateQtViewer::InitialiseGL () 1\n"); 103 104 // // clear the buffers and window. 105 // // ClearView (); 77 78 InitializeGLView (); 79 80 printf("G4OpenGLImmediateQtViewer::InitialiseGL () 1\n"); 81 82 // clear the buffers and window. 83 // ClearView (); 106 84 // printf("G4OpenGLImmediateQtViewer::InitialiseGL () 2\n"); 107 //// FinishView ();108 109 //// If a double buffer context has been forced upon us, ignore the110 //// back buffer for this OpenGLImmediate view.85 // FinishView (); 86 87 // If a double buffer context has been forced upon us, ignore the 88 // back buffer for this OpenGLImmediate view. 111 89 // glDrawBuffer (GL_FRONT); 112 90 113 //glDepthFunc (GL_LEQUAL);114 //glDepthMask (GL_TRUE);115 116 //printf("G4OpenGLImmediateQtViewer::InitialiseGL -------------------------------------------------------------------------------------\n");91 glDepthFunc (GL_LEQUAL); 92 glDepthMask (GL_TRUE); 93 94 printf("G4OpenGLImmediateQtViewer::InitialiseGL -------------------------------------------------------------------------------------\n"); 117 95 } 118 96 … … 121 99 122 100 printf("G4OpenGLImmediateQtViewer::DrawView %d %d VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n",WinSize_x, WinSize_y); 123 // If a double buffer context has been forced upon us, ignore the 124 // back buffer for this OpenGLImmediate view. 125 // glDrawBuffer (GL_FRONT); 126 127 // G4ViewParameters::DrawingStyle style = GetViewParameters().GetDrawingStyle(); 128 129 // //Make sure current viewer is attached and clean... 130 // //Qt version needed 131 // //glXMakeCurrent (dpy, win, cx); 132 // glViewport (0, 0, WinSize_x, WinSize_y); 133 134 // if(style!=G4ViewParameters::hlr && 135 // haloing_enabled) { 136 137 // HaloingFirstPass (); 138 // NeedKernelVisit (); 139 // ProcessView (); 140 // glFlush (); 141 142 // HaloingSecondPass (); 143 144 // } 145 146 // NeedKernelVisit (); // Always need to visit G4 kernel. 147 // ProcessView (); 148 // FinishView (); 101 glDraw(); 149 102 printf("G4OpenGLImmediateQtViewer::DrawView %d %d ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n",WinSize_x, WinSize_y); 150 103 … … 194 147 // // if(!fHDC) return; 195 148 196 //glFlush ();149 glFlush (); 197 150 printf("G4OpenGLImmediateQtViewer::FinishView ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n"); 198 151 … … 263 216 264 217 265 266 267 GLuint G4OpenGLImmediateQtViewer::makeObject()268 {269 GLuint list = glGenLists(1);270 glNewList(list, GL_COMPILE);271 272 glBegin(GL_QUADS);273 274 GLdouble x1 = +0.06;275 GLdouble y1 = -0.14;276 GLdouble x2 = +0.14;277 GLdouble y2 = -0.06;278 GLdouble x3 = +0.08;279 GLdouble y3 = +0.00;280 GLdouble x4 = +0.30;281 GLdouble y4 = +0.22;282 283 quad(x1, y1, x2, y2, y2, x2, y1, x1);284 quad(x3, y3, x4, y4, y4, x4, y3, x3);285 286 extrude(x1, y1, x2, y2);287 extrude(x2, y2, y2, x2);288 extrude(y2, x2, y1, x1);289 extrude(y1, x1, x1, y1);290 extrude(x3, y3, x4, y4);291 extrude(x4, y4, y4, x4);292 extrude(y4, x4, y3, x3);293 294 const double Pi = 3.14159265358979323846;295 const int NumSectors = 200;296 297 for (int i = 0; i < NumSectors; ++i) {298 double angle1 = (i * 2 * Pi) / NumSectors;299 GLdouble x5 = 0.30 * sin(angle1);300 GLdouble y5 = 0.30 * cos(angle1);301 GLdouble x6 = 0.20 * sin(angle1);302 GLdouble y6 = 0.20 * cos(angle1);303 304 double angle2 = ((i + 1) * 2 * Pi) / NumSectors;305 GLdouble x7 = 0.20 * sin(angle2);306 GLdouble y7 = 0.20 * cos(angle2);307 GLdouble x8 = 0.30 * sin(angle2);308 GLdouble y8 = 0.30 * cos(angle2);309 310 quad(x5, y5, x6, y6, x7, y7, x8, y8);311 312 extrude(x6, y6, x7, y7);313 extrude(x8, y8, x5, y5);314 }315 316 glEnd();317 318 glEndList();319 return list;320 }321 322 void G4OpenGLImmediateQtViewer::quad(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2,323 GLdouble x3, GLdouble y3, GLdouble x4, GLdouble y4)324 {325 qglColor(trolltechGreen);326 327 glVertex3d(x1, y1, -0.05);328 glVertex3d(x2, y2, -0.05);329 glVertex3d(x3, y3, -0.05);330 glVertex3d(x4, y4, -0.05);331 332 glVertex3d(x4, y4, +0.05);333 glVertex3d(x3, y3, +0.05);334 glVertex3d(x2, y2, +0.05);335 glVertex3d(x1, y1, +0.05);336 }337 338 void G4OpenGLImmediateQtViewer::extrude(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2)339 {340 qglColor(trolltechGreen.dark(250 + int(100 * x1)));341 342 glVertex3d(x1, y1, +0.05);343 glVertex3d(x2, y2, +0.05);344 glVertex3d(x2, y2, -0.05);345 glVertex3d(x1, y1, -0.05);346 }347 348 218 #endif -
trunk/geant4/visualization/OpenGL/src/G4OpenGLImmediateSceneHandler.cc
r541 r554 152 152 void G4OpenGLImmediateSceneHandler::ClearTransientStore () { 153 153 G4VSceneHandler::ClearTransientStore (); 154 155 154 // Make sure screen corresponds to graphical database... 156 155 if (fpViewer) {
Note: See TracChangeset
for help on using the changeset viewer.