- Timestamp:
- Jan 11, 2008, 3:44:33 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/geant4/visualization/OpenGL/src/G4OpenGLStoredQtViewer.cc
r677 r678 54 54 QGLWidget(QGLFormat(QGL::SampleBuffers)) // FIXME : gerer le pb du parent ! 55 55 { 56 zoomAction = false;57 56 nbPaint =0; 58 57 hasToRepaint =false; … … 257 256 void G4OpenGLStoredQtViewer::paintGL() 258 257 { 259 if (zoomAction) {260 glEnable (GL_DEPTH_TEST);261 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);262 263 setupViewport(width(),height());264 SetView();265 ClearView (); //ok, put the background correct266 267 QPainter painter;268 painter.begin(this);269 // painter.setCompositionMode(QPainter::CompositionMode_DestinationOver);270 // painter.setCompositionMode(QPainter::CompositionMode_SourceOver); // diagonale en pointillé271 // painter.setCompositionMode(QPainter::CompositionMode_DestinationOver); // blanc272 // painter.setCompositionMode(QPainter::CompositionMode_Clear);// diagonale noire273 // painter.setCompositionMode(QPainter::CompositionMode_Source); // diagonale en pointillé274 // painter.setCompositionMode(QPainter::CompositionMode_Destination); // blanc275 // painter.setCompositionMode(QPainter::CompositionMode_SourceIn); // blanc ?276 // painter.setCompositionMode(QPainter::CompositionMode_DestinationIn); // blanc277 // painter.setCompositionMode(QPainter::CompositionMode_SourceOut); // digonale noire278 // painter.setCompositionMode(QPainter::CompositionMode_DestinationOut); // diagonale noire279 // painter.setCompositionMode(QPainter::CompositionMode_SourceAtop); // diagonale noire280 // painter.setCompositionMode(QPainter::CompositionMode_DestinationAtop); // blanc281 // painter.setCompositionMode(QPainter::CompositionMode_Xor); // diagonale noire282 // painter.setRenderHint(QPainter::Antialiasing);283 // painter.setBackgroundMode(Qt::OpaqueMode);284 // painter.drawImage(0, 0, glBufferImage);285 286 // painter.setRenderHint(QPainter::Antialiasing);287 // QColor bg = QColor(glBufferImage.pixel(0,0));288 // printf("%d+%d+%d+%d %d+%d+%d+%d",bg.red(),bg.green(),bg.blue(),bg.alpha(),qAlpha(glBufferImage.pixel(0,0)),qRed(glBufferImage.pixel(0,0)),qGreen(glBufferImage.pixel(0,0)),qBlue(glBufferImage.pixel(0,0)));289 // painter.setBackground(QBrush(bg));290 // // painter.drawRect(10,10,50,80);291 // // QImage test = grabFrameBuffer().copy();292 // // painter.drawImage(0, 0,test);293 for (int ay=0;ay<glBufferImage.height();ay++) {294 for (int ax=0;ax<glBufferImage.width();ax++) {295 // if(QColor(glBufferImage.pixel(ax,ay)) != bg) {296 //. painter.setPen(QColor(glBufferImage.pixel(ax,ay)));297 //. painter.drawPoint(ax,ay);298 // } else {299 // printf("o");300 // }301 // printf("%d+%d+%d+%d ",QColor(glBufferImage.pixel(ax,ay)).red(),QColor(glBufferImage.pixel(ax,ay)).green(),QColor(glBufferImage.pixel(ax,ay)).blue(),QColor(glBufferImage.pixel(ax,ay)).alpha());302 // if (glBufferImage.pixel(ax,ay) == 255) {303 // test.setPixel(ax,ay,1);304 // } else {305 // test.setPixel(ax,ay,0);306 // }307 }308 // printf("\n");309 }310 // // for (int ay=0;ay<test.height();ay++) {311 // // for (int ax=0;ax<test.width();ax++) {312 // // if (test.pixel(ax,ay) == 1) {313 // // printf(".");314 // // } else if (!test.pixel(ax,ay)) {315 // // printf("X");316 // // } else {317 // // printf("%d",test.pixel(ax,ay));318 // // }319 // // }320 // // printf("\n");321 // // }322 323 // painter.drawImage(0, 0, glBufferImage);324 // painter.drawImage(0, 0, test,0,0,-1,-1,Qt::ColorOnly);325 326 #ifdef GEANT4_QT_DEBUG327 printf("G4OpenGLStoredQtViewer::paintGL ============ zoom event\n");328 #endif329 painter.setBrush(Qt::NoBrush);330 painter.setPen(Qt::red);331 painter.setPen(Qt::DashLine);332 painter.drawRect(beginZoom.x(),beginZoom.y(),endZoom.x()-beginZoom.x(),endZoom.y()-beginZoom.y());333 painter.end();334 } else {335 258 336 259 if (!readyToPaint) { … … 376 299 hasToRepaint =false; 377 300 378 }379 301 #ifdef GEANT4_QT_DEBUG 380 302 printf("G4OpenGLStoredQtViewer::paintGL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ %d ready %d\n",nbPaint,readyToPaint); … … 391 313 } 392 314 315 /** 316 * This function was build in order to make a zoom on double clic event. 317 * It was think to build a rubberband on the zoom area, but never work fine 318 */ 393 319 void G4OpenGLStoredQtViewer::mouseDoubleClickEvent(QMouseEvent *event) 394 320 { … … 396 322 printf("G4OpenGLStoredQtViewer::mouseDoubleClickEvent\n"); 397 323 #endif 398 setMouseTracking(true); 399 zoomAction=true; 400 // makeCurrent(); 401 // glBufferImage = QImage( width(), height(), QImage::Format_ARGB32_Premultiplied ); 402 // glReadPixels( 0, 0, width(), height(), GL_RGBA, GL_UNSIGNED_BYTE, glBufferImage.bits() ); 403 glBufferImage = grabFrameBuffer().convertToFormat(QImage::Format_ARGB32);//_Premultiplied); 404 QImage acha( glBufferImage.size(), QImage::Format_RGB32 ); 405 acha.fill( Qt::black ); 406 glBufferImage.setAlphaChannel( acha ); 407 408 #ifdef GEANT4_QT_DEBUG 409 // for (int ay=0;ay<glBufferImage.height();ay++) { 410 // for (int ax=0;ax<glBufferImage.width();ax++) { 411 // if (glBufferImage.pixel(ax,ay) == 255) { 412 // printf("."); 413 // } else if (!glBufferImage.pixel(ax,ay)) { 414 // printf("X"); 415 // } else { 416 // printf("%d",glBufferImage.pixel(ax,ay)); 417 // } 418 // } 419 // printf("\n"); 420 // } 421 #endif 422 beginZoom.setX(event->x()); 423 beginZoom.setY(event->y()); 324 // setMouseTracking(true); 325 // glBufferImage = grabFrameBuffer().convertToFormat(QImage::Format_ARGB32);//_Premultiplied); 424 326 } 425 327 … … 429 331 printf("G4OpenGLStoredQtViewer::mouseReleaseEvent\n"); 430 332 #endif 431 setMouseTracking(false); 432 zoomAction =false; 333 // setMouseTracking(false); 433 334 } 434 335 435 336 void G4OpenGLStoredQtViewer::mouseMoveEvent(QMouseEvent *event) 436 337 { 437 // special case of mouse zoom action, it should draw a rect on 438 // the openGL buffer, so it could only be done in this class 439 // and sould be reimplemented in G4OpenGLImmediateQtViewer 440 if (!zoomAction) { 338 441 339 #if QT_VERSION < 0x040000 442 340 G4MouseMoveEvent(event->x(),event->y(),event->state()); … … 444 342 G4MouseMoveEvent(event->x(),event->y(),event->buttons()); 445 343 #endif 446 } else {447 #ifdef GEANT4_QT_DEBUG448 printf("G4OpenGLStoredQtViewer::mouseMoveEvent zoom\n");449 #endif450 endZoom.setX(event->x());451 endZoom.setY(event->y());452 updateGL();453 }454 // DrawView();455 344 } 456 345
Note: See TracChangeset
for help on using the changeset viewer.