source: trunk/geant4/visualization/OpenGL/src/G4OpenGLQtViewer.cc @ 702

Last change on this file since 702 was 702, checked in by garnier, 16 years ago

deplacement keys ok. Debut d a jout bouton perspective

  • Property svn:mime-type set to text/cpp
File size: 55.9 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer                                           *
4// *                                                                  *
5// * The  Geant4 software  is  copyright of the Copyright Holders  of *
6// * the Geant4 Collaboration.  It is provided  under  the terms  and *
7// * conditions of the Geant4 Software License,  included in the file *
8// * LICENSE and available at  http://cern.ch/geant4/license .  These *
9// * include a list of copyright holders.                             *
10// *                                                                  *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work  make  any representation or  warranty, express or implied, *
14// * regarding  this  software system or assume any liability for its *
15// * use.  Please see the license in the file  LICENSE  and URL above *
16// * for the full disclaimer and the limitation of liability.         *
17// *                                                                  *
18// * This  code  implementation is the result of  the  scientific and *
19// * technical work of the GEANT4 collaboration.                      *
20// * By using,  copying,  modifying or  distributing the software (or *
21// * any work based  on the software)  you  agree  to acknowledge its *
22// * use  in  resulting  scientific  publications,  and indicate your *
23// * acceptance of all terms of the Geant4 Software license.          *
24// ********************************************************************
25//
26//
27// $Id: G4OpenGLQtViewer.cc,v 1.9 2008/01/15 11:05:08 lgarnier Exp $
28// GEANT4 tag $Name:  $
29//
30//
31// G4OpenGLQtViewer : Class to provide Qt specific
32//                     functionality for OpenGL in GEANT4
33//
34// 27/06/2003 : G.Barrand : implementation (at last !).
35
36#ifdef G4VIS_BUILD_OPENGLQT_DRIVER
37
38#define GEANT4_QT_DEBUG
39
40#include "G4OpenGLQtViewer.hh"
41
42#include "G4ios.hh"
43#include "G4VisExtent.hh"
44#include "G4LogicalVolume.hh"
45#include "G4VSolid.hh"
46#include "G4Point3D.hh"
47#include "G4Normal3D.hh"
48#include "G4Scene.hh"
49#include "G4OpenGLQtExportDialog.hh"
50
51#include "G4Qt.hh"
52#include "G4UImanager.hh"
53#include "G4UIcommandTree.hh"
54#include <qapplication.h>
55#include <qlayout.h>
56#include <qdialog.h>
57
58#if QT_VERSION >= 0x040000
59#include <qmenu.h>
60#include <qimagewriter.h>
61#else
62#include <qaction.h>
63#include <qwidgetlist.h>
64#include <qpopupmenu.h>
65#include <qimage.h>
66#endif
67
68#include <qmessagebox.h>
69#include <qfiledialog.h>
70#include <qprinter.h>
71#include <qpainter.h>
72#include <qgl.h> // include <qglwidget.h>
73#include <qdialog.h>
74#include <qevent.h> //include <qcontextmenuevent.h>
75
76
77//////////////////////////////////////////////////////////////////////////////
78/**
79   Implementation of virtual method of G4VViewer
80*/
81void G4OpenGLQtViewer::SetView (
82)
83//////////////////////////////////////////////////////////////////////////////
84//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
85{
86#ifdef GEANT4_QT_DEBUG
87  printf("G4OpenGLQtViewer::SetView ++++++++++++++++++++\n");
88#endif
89  //   if(!fHDC) return;
90  //   if(!fHGLRC) return;
91  //   ::wglMakeCurrent(fHDC,fHGLRC);
92  //  fWindow->makeCurrent();
93  G4OpenGLViewer::SetView ();
94#ifdef GEANT4_QT_DEBUG
95  printf("G4OpenGLQtViewer::SetView --------------------\n");
96#endif
97}
98
99/**
100 * Set the viewport of the scene
101 */
102void G4OpenGLQtViewer::setupViewport(int aWidth, int aHeight)
103{
104  int side = qMin(aWidth, aHeight);
105  glViewport((aWidth - side) / 2, (aHeight - side) / 2, side, side);
106 
107  glMatrixMode(GL_PROJECTION);
108  glLoadIdentity();
109  glOrtho(-0.5, +0.5, +0.5, -0.5, 4.0, 15.0);
110  glMatrixMode(GL_MODELVIEW);
111}
112
113
114//////////////////////////////////////////////////////////////////////////////
115/**
116   Implementation of virtual method of G4VViewer
117*/
118void G4OpenGLQtViewer::ShowView (
119)
120//////////////////////////////////////////////////////////////////////////////
121//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
122{
123#ifdef GEANT4_QT_DEBUG
124  printf("G4OpenGLQtViewer::ShowView  +++++++++++++++++++++\n");
125#endif
126  if (!GLWindow) {
127    G4cerr << "Visualization window not defined, please choose one before\n" << G4endl;
128  } else {
129#if QT_VERSION < 0x040000
130    GLWindow->setActiveWindow();
131#else
132    GLWindow->activateWindow();
133#endif
134#ifdef GEANT4_QT_DEBUG
135    printf("G4OpenGLQtViewer::ShowView -----------------------\n");
136#endif
137  }
138  glFlush ();
139  //   // Empty the Windows message queue :
140  //   MSG event;
141  //   while ( ::PeekMessage(&event, NULL, 0, 0, PM_REMOVE) ) {
142  //     ::TranslateMessage(&event);
143  //     ::DispatchMessage (&event);
144  //   }
145}
146
147
148
149//////////////////////////////////////////////////////////////////////////////
150void G4OpenGLQtViewer::CreateGLQtContext (
151)
152//////////////////////////////////////////////////////////////////////////////
153//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
154{
155#ifdef GEANT4_QT_DEBUG
156  printf("G4OpenGLQtViewer::CreateGLQtContext \n");
157#endif
158}
159
160
161//////////////////////////////////////////////////////////////////////////////
162void G4OpenGLQtViewer::CreateMainWindow (
163 QGLWidget* glWidget
164)
165//////////////////////////////////////////////////////////////////////////////
166//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
167{
168
169  if(fWindow) return; //Done.
170#ifdef GEANT4_QT_DEBUG
171  printf("G4OpenGLQtViewer::CreateMainWindow glWidget\n");
172#endif
173
174  // launch Qt if not
175  G4Qt* interactorManager = G4Qt::getInstance ();
176  //  G4UImanager* UI = G4UImanager::GetUIpointer();
177
178  fWindow = glWidget ;
179  //  fWindow->makeCurrent();
180
181  // create window
182  if (((QApplication*)interactorManager->GetMainInteractor())) {
183    // look for the main window
184    bool found = false;
185#if QT_VERSION < 0x040000
186    // theses lines does nothing exept this one "GLWindow = new QDialog(0..."
187    // but if I comment them, it doesn't work...
188    QWidgetList  *list = QApplication::allWidgets();
189    QWidgetListIt it( *list );         // iterate over the widgets
190    QWidget * widget;
191    while ( (widget=it.current()) != 0 ) {  // for each widget...
192      ++it;
193      if ((found== false) && (widget->inherits("QMainWindow"))) {
194        GLWindow = new QDialog(0,0,FALSE,Qt::WStyle_Title | Qt::WStyle_SysMenu | Qt::WStyle_MinMax );
195        found = true;
196      }
197    }
198    delete list;                      // delete the list, not the widgets
199#else
200    foreach (QWidget *widget, QApplication::allWidgets()) {
201      if ((found== false) && (widget->inherits("QMainWindow"))) {
202        GLWindow = new QDialog(0,Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint);
203        found = true;
204      }
205    }
206#endif
207
208#if QT_VERSION < 0x040000
209    glWidget->reparent(GLWindow,0,QPoint(0,0)); 
210#else
211    glWidget->setParent(GLWindow); 
212#endif
213
214    if (found==false) {
215#ifdef GEANT4_QT_DEBUG
216      printf("G4OpenGLQtViewer::CreateMainWindow case Qapp exist, but not found\n");
217#endif
218      GLWindow = new QDialog();
219    }
220  } else {
221#ifdef GEANT4_QT_DEBUG
222    printf("G4OpenGLQtViewer::CreateMainWindow case Qapp exist\n");
223#endif
224    GLWindow = new QDialog();
225  }
226
227  QHBoxLayout *mainLayout = new QHBoxLayout(GLWindow);
228
229  mainLayout->addWidget(fWindow);
230
231#if QT_VERSION < 0x040000
232  GLWindow->setCaption( tr( "QGl Viewer" ));
233#else
234  GLWindow->setLayout(mainLayout);
235  GLWindow->setWindowTitle(tr("QGl Viewer"));
236#endif
237  GLWindow->resize(300, 300);
238  GLWindow->move(900,300);
239  GLWindow->show();
240 
241  // delete the pointer if close this
242  //  GLWindow->setAttribute(Qt::WA_DeleteOnClose);
243
244#if QT_VERSION >= 0x040000
245  QObject ::connect(GLWindow,
246                    SIGNAL(rejected()),
247                    this,
248                    SLOT(dialogClosed()));
249#endif
250
251  WinSize_x = 400;
252  WinSize_y = 400;
253  if (WinSize_x < fVP.GetWindowSizeHintX ())
254    WinSize_x = fVP.GetWindowSizeHintX ();
255  if (WinSize_y < fVP.GetWindowSizeHintY ())
256    WinSize_y = fVP.GetWindowSizeHintY ();
257
258  if(!fWindow) return;
259#ifdef GEANT4_QT_DEBUG
260  printf("G4OpenGLQtViewer::CreateMainWindow glWidget END\n");
261#endif
262
263  if (!fContextMenu)
264    createPopupMenu();
265
266}
267
268#if QT_VERSION >= 0x040000
269/**  Close the dialog and set the pointer to NULL
270 */
271void G4OpenGLQtViewer::dialogClosed() {
272#ifdef GEANT4_QT_DEBUG
273  printf("G4OpenGLQtViewer::dialogClosed END\n");
274#endif
275  //  GLWindow = NULL;
276}
277#endif
278
279//////////////////////////////////////////////////////////////////////////////
280G4OpenGLQtViewer::G4OpenGLQtViewer (
281                                    G4OpenGLSceneHandler& scene
282                                    )
283  :G4VViewer (scene, -1)
284  ,G4OpenGLViewer (scene)
285  ,fWindow(0)
286  ,fContextMenu(0)
287  ,fMouseAction(STYLE1)
288  ,fDeltaSceneTranslation(1/100)
289  ,fDeltaZoom(2)
290  ,holdKeyEvent(false)
291{
292#ifdef GEANT4_QT_DEBUG
293  printf("G4OpenGLQtViewer::G4OpenGLQtViewer \n");
294#endif
295}
296
297//////////////////////////////////////////////////////////////////////////////
298G4OpenGLQtViewer::~G4OpenGLQtViewer (
299)
300//////////////////////////////////////////////////////////////////////////////
301//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
302{
303#ifdef GEANT4_QT_DEBUG
304  printf("G4OpenGLQtViewer::~G4OpenGLQtViewer \n");
305#endif
306}
307
308
309/**
310   Create a popup menu for the widget. This menu is activated by right-mouse click
311*/
312void G4OpenGLQtViewer::createPopupMenu()    {
313
314#if QT_VERSION < 0x040000
315  fContextMenu = new QPopupMenu( GLWindow,"All" );
316#else
317  fContextMenu = new QMenu("All");
318#endif
319
320#if QT_VERSION < 0x040000
321  QPopupMenu *mMouseAction = new QPopupMenu( fContextMenu );
322  fContextMenu->insertItem("&Mouse actions");
323#else
324  QMenu *mMouseAction = fContextMenu->addMenu("&Mouse actions");
325#endif
326
327#if QT_VERSION < 0x040000
328  // === Mouse menu ===
329
330  fMouseRotate = new QPopupMenu(mMouseAction);
331  mMouseAction->insertItem("&Rotate",fMouseRotate);
332
333  mMouseAction->setCheckable(true);
334  fMouseRotate->setCheckable(true);
335
336  fMouseMove = new QPopupMenu(mMouseAction);
337  mMouseAction->insertItem("&Move",fMouseMove);
338  fMouseMove->setCheckable(true);
339
340  fMouseZoom = new QPopupMenu(mMouseAction);
341  mMouseAction->insertItem("&Zoom",fMouseZoom);
342  fMouseZoom->setCheckable(true);
343
344  fMousePick = new QPopupMenu(mMouseAction);
345  mMouseAction->insertItem("&Pick",fMousePick);
346  fMousePick->setCheckable(true);
347
348#else
349  // === Mouse menu ===
350
351  fMouseRotate = mMouseAction->addAction("Rotate");
352  fMouseRotate->setCheckable(true);
353
354  fMouseMove = mMouseAction->addAction("Move");
355  fMouseMove->setCheckable(true);
356
357  fMouseZoom = mMouseAction->addAction("Zoom");
358  fMouseZoom->setCheckable(true);
359
360  fMousePick = mMouseAction->addAction("Pick");
361  fMousePick->setCheckable(true);
362#endif
363
364  // INIT mMouse
365#if QT_VERSION < 0x040000
366  fMouseRotate->setItemCheckeded(0,true);
367
368  QObject ::connect(fMouseRotate,
369                    SIGNAL(activated(int)),
370                    this,
371                    SLOT(actionMouseRotate()));
372
373  QObject ::connect(fMouseMove,
374                    SIGNAL(activated(int)),
375                    this,
376                    SLOT(actionMouseMove()));
377
378  QObject ::connect(fMouseZoom,
379                    SIGNAL(activated(int)),
380                    this,
381                    SLOT(actionMouseZoom()));
382
383  QObject ::connect(fMousePick,
384                    SIGNAL(activated(int)),
385                    this,
386                    SLOT(actionMousePick()));
387
388#else
389  fMouseRotate->setChecked(true);
390
391  QObject ::connect(fMouseRotate,
392                    SIGNAL(triggered(bool)),
393                    this,
394                    SLOT(actionMouseRotate()));
395
396  QObject ::connect(fMouseMove,
397                    SIGNAL(triggered(bool)),
398                    this,
399                    SLOT(actionMouseMove()));
400
401  QObject ::connect(fMouseZoom,
402                    SIGNAL(triggered(bool)),
403                    this,
404                    SLOT(actionMouseZoom()));
405
406  QObject ::connect(fMousePick,
407                    SIGNAL(triggered(bool)),
408                    this,
409                    SLOT(actionMousePick()));
410#endif
411
412#if QT_VERSION < 0x040000
413  // === Style Menu ===
414  QPopupMenu *mStyle = new QPopupMenu(fContextMenu);
415
416  QPopupMenu *mRepresentation = new QPopupMenu(fContextMenu);
417
418  QPopupMenu *mProjection = new QPopupMenu(fProjection);
419
420#if QT_VERSION < 0x030200
421  QAction *polyhedron = new QAction("&Polyhedron","&Polyhedron",CTRL+Key_P,mRepresentation);
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);
426#else
427  QAction *polyhedron = new QAction("&Polyhedron",CTRL+Key_P,mRepresentation);
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);
432#endif
433  polyhedron->addTo(mRepresentation);
434  nurbs->addTo(mRepresentation);
435
436  ortho->addTo(mProjection);
437  perspective->addTo(mProjection);
438
439  mStyle->insertItem("&Representation",mRepresentation);
440  mStyle->insertItem("&Projection",mProjection);
441  fContextMenu->insertItem("&Style",mStyle);
442
443
444#else
445  // === Style Menu ===
446  QMenu *mStyle = fContextMenu->addMenu("&Style");
447
448  QMenu *mRepresentation = mStyle->addMenu("&Representation");
449  QAction *polyhedron = mRepresentation->addAction("Polyhedron");
450  QAction *nurbs = mRepresentation->addAction("NURBS");
451
452  QAction *ortho = mRepresentation->addAction("Orthographic");
453  QAction *perspective = mRepresentation->addAction("Persepective");
454#endif
455
456  // INIT mRepresentation
457  G4ViewParameters::RepStyle style;
458  style = fVP.GetRepStyle();
459  if (style == G4ViewParameters::polyhedron) {
460    createRadioAction(polyhedron,nurbs,SLOT(toggleRepresentation(bool)),1);
461  } else if (style == G4ViewParameters::nurbs) {
462    createRadioAction(polyhedron,nurbs,SLOT(toggleRepresentation(bool)),2);
463  } else {
464    mRepresentation->clear();
465  }
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  }
473
474#if QT_VERSION < 0x040000
475  // === Drawing Menu ===
476  QPopupMenu *mDrawing = new QPopupMenu(fContextMenu);
477  fContextMenu->insertItem("&Drawing",mDrawing);
478
479  fDrawingWireframe = new QPopupMenu(mDrawing);
480  mDrawing->insertItem("&Wireframe",fDrawingWireframe);
481
482  mDrawing->setCheckable(true);
483  fDrawingWireframe->setCheckable(true);
484
485  fDrawingLineRemoval = new QPopupMenu(mDrawing);
486  mDrawing->insertItem("&Hidden line removal",fDrawingLineRemoval);
487  fDrawingLineRemoval->setCheckable(true);
488
489  fDrawingSurfaceRemoval = new QPopupMenu(mDrawing);
490  mDrawing->insertItem("&Hidden surface removal",fDrawingSurfaceRemoval);
491  fDrawingSurfaceRemoval->setCheckable(true);
492
493  fDrawingLineSurfaceRemoval = new QPopupMenu(mDrawing);
494  mDrawing->insertItem("&Hidden line and surface removal",fDrawingLineSurfaceRemoval);
495  fDrawingLineSurfaceRemoval->setCheckable(true);
496
497#else
498  // === Drawing Menu ===
499  QMenu *mDrawing = mStyle->addMenu("&Drawing");
500
501  fDrawingWireframe = mDrawing->addAction("Wireframe");
502  fDrawingWireframe->setCheckable(true);
503
504  fDrawingLineRemoval = mDrawing->addAction("Hidden line removal");
505  fDrawingLineRemoval->setCheckable(true);
506
507  fDrawingSurfaceRemoval = mDrawing->addAction("Hidden Surface removal");
508  fDrawingSurfaceRemoval->setCheckable(true);
509
510  fDrawingLineSurfaceRemoval = mDrawing->addAction("Hidden line and surface removal");
511  fDrawingLineSurfaceRemoval->setCheckable(true);
512#endif
513  // INIT Drawing
514  G4ViewParameters::DrawingStyle d_style;
515  d_style = fVP.GetDrawingStyle();
516 
517#if QT_VERSION < 0x040000
518  if (d_style == G4ViewParameters::wireframe) {
519    fDrawingWireframe->setItemChecked(0,true);
520  } else if (d_style == G4ViewParameters::hlr) {
521    fDrawingLineRemoval->setItemChecked(0,true);
522  } else if (d_style == G4ViewParameters::hsr) {
523    fDrawingSurfaceRemoval->setItemChecked(0,true);
524  } else if (d_style == G4ViewParameters::hlhsr) {
525    fDrawingLineSurfaceRemoval->setItemChecked(0,true);
526  } else {
527    mDrawing->clear();
528  }
529#ifdef GEANT4_QT_DEBUG
530  printf("G4OpenGLQtViewer:: fDrawingWireframe 1\n");
531#endif
532  QObject ::connect(fDrawingWireframe,
533                    SIGNAL(activated(int)),
534                    this,
535                    SLOT(actionDrawingWireframe()));
536#ifdef GEANT4_QT_DEBUG
537  printf("G4OpenGLQtViewer:: fDrawingWireframe 2\n");
538#endif
539  QObject ::connect(fDrawingLineRemoval,
540                    SIGNAL(activated(int)),
541                    this,
542                    SLOT(actionDrawingLineRemoval()));
543  QObject ::connect(fDrawingSurfaceRemoval,
544                    SIGNAL(activated(int)),
545                    this,
546                    SLOT(actionDrawingSurfaceRemoval()));
547  QObject ::connect(fDrawingLineSurfaceRemoval,
548                    SIGNAL(activated(int)),
549                    this,
550                    SLOT(actionDrawingLineSurfaceRemoval()));
551#else
552  if (d_style == G4ViewParameters::wireframe) {
553    fDrawingWireframe->setChecked(true);
554  } else if (d_style == G4ViewParameters::hlr) {
555    fDrawingLineRemoval->setChecked(true);
556  } else if (d_style == G4ViewParameters::hsr) {
557    fDrawingSurfaceRemoval->setChecked(true);
558  } else if (d_style == G4ViewParameters::hlhsr) {
559    fDrawingLineSurfaceRemoval->setChecked(true);
560  } else {
561    mDrawing->clear();
562  }
563  QObject ::connect(fDrawingWireframe,
564                    SIGNAL(triggered(bool)),
565                    this,
566                    SLOT(actionDrawingWireframe()));
567  QObject ::connect(fDrawingLineRemoval,
568                    SIGNAL(triggered(bool)),
569                    this,
570                    SLOT(actionDrawingLineRemoval()));
571  QObject ::connect(fDrawingSurfaceRemoval,
572                    SIGNAL(triggered(bool)),
573                    this,
574                    SLOT(actionDrawingSurfaceRemoval()));
575  QObject ::connect(fDrawingLineSurfaceRemoval,
576                    SIGNAL(triggered(bool)),
577                    this,
578                    SLOT(actionDrawingLineSurfaceRemoval()));
579#endif
580
581
582
583#if QT_VERSION < 0x040000
584  QPopupMenu *mBackground = new QPopupMenu(mStyle);
585  mStyle->insertItem("&Background color",mBackground);
586
587#if QT_VERSION < 0x030200
588  QAction *white = new QAction("&White","&White",CTRL+Key_W,mBackground);
589  QAction *black =  new QAction("&Black","&Black",CTRL+Key_B,mBackground);
590#else
591  QAction *white = new QAction("&White",CTRL+Key_W,mBackground);
592  QAction *black =  new QAction("&Black",CTRL+Key_B,mBackground);
593#endif
594  white->addTo(mBackground);
595  black->addTo(mBackground);
596
597#else
598  QMenu *mBackground = mStyle->addMenu("&Background color");
599  QAction *white = mBackground->addAction("White");
600  QAction *black = mBackground->addAction("Black");
601
602#endif
603  if (background.GetRed() == 1. &&
604      background.GetGreen() == 1. &&
605      background.GetBlue() == 1.) {
606    createRadioAction(white,black,SLOT(toggleBackground(bool)),1);
607  } else {
608    createRadioAction(white,black,SLOT(toggleBackground(bool)),2);
609  }
610
611
612#if QT_VERSION < 0x040000
613  // === Action Menu ===
614  QPopupMenu *mActions = new QPopupMenu(fContextMenu);
615  fContextMenu->insertItem("&Actions",mActions);
616
617#if QT_VERSION < 0x030200
618  QAction *createEPS =  new QAction("&Save as ...","&Save as ...",CTRL+Key_S,mActions);
619#else
620  QAction *createEPS =  new QAction("&Save as ...",CTRL+Key_S,mActions);
621#endif
622  createEPS->addTo(mActions);
623  QObject ::connect(createEPS,
624                    SIGNAL(activated()),
625                    this,
626                    SLOT(actionCreateEPS()));
627
628#else
629  // === Action Menu ===
630  QMenu *mActions = fContextMenu->addMenu("&Actions");
631  QAction *createEPS = mActions->addAction("Save as ...");
632  QObject ::connect(createEPS,
633                    SIGNAL(triggered()),
634                    this,
635                    SLOT(actionCreateEPS()));
636#endif
637
638
639
640#if QT_VERSION < 0x040000
641  // === Special Menu ===
642  QPopupMenu *mSpecial = new QPopupMenu(fContextMenu);
643  fContextMenu->insertItem("S&pecial",mSpecial);
644
645  QPopupMenu *mTransparency = new QPopupMenu(mSpecial);
646  mSpecial->insertItem("Transparency",mTransparency);
647
648#if QT_VERSION < 0x030200
649  QAction *transparencyOn = new QAction("&On","&On",CTRL+Key_O,mTransparency);
650  QAction *transparencyOff = new QAction("&Off","&Off",CTRL+Key_F,mTransparency);
651#else
652  QAction *transparencyOn = new QAction("&On",CTRL+Key_O,mTransparency);
653  QAction *transparencyOff = new QAction("&Off",CTRL+Key_F,mTransparency);
654#endif
655  transparencyOn->addTo(mTransparency);
656  transparencyOff->addTo(mTransparency);
657
658#else
659  // === Special Menu ===
660  QMenu *mSpecial = fContextMenu->addMenu("S&pecial");
661  QMenu *mTransparency = mSpecial->addMenu("Transparency");
662  QAction *transparencyOn = mTransparency->addAction("On");
663  QAction *transparencyOff = mTransparency->addAction("Off");
664#endif
665
666  if (transparency_enabled == false) {
667    createRadioAction(transparencyOn,transparencyOff,SLOT(toggleTransparency(bool)),2);
668  } else if (transparency_enabled == true) {
669    createRadioAction(transparencyOn,transparencyOff,SLOT(toggleTransparency(bool)),1);
670  } else {
671    mSpecial->clear();
672  }
673
674
675#if QT_VERSION < 0x040000
676  QPopupMenu *mAntialiasing = new QPopupMenu(mSpecial);
677  mSpecial->insertItem("Antialiasing",mAntialiasing);
678
679#if QT_VERSION < 0x030200
680  QAction *antialiasingOn = new QAction("&On","&On",CTRL+Key_O,mAntialiasing);
681  QAction *antialiasingOff = new QAction("&Off","&Off",CTRL+Key_F,mAntialiasing);
682#else
683  QAction *antialiasingOn = new QAction("&On",CTRL+Key_O,mAntialiasing);
684  QAction *antialiasingOff = new QAction("&Off",CTRL+Key_F,mAntialiasing);
685#endif
686  antialiasingOn->addTo(mAntialiasing);
687  antialiasingOff->addTo(mAntialiasing);
688
689#else
690  QMenu *mAntialiasing = mSpecial->addMenu("Antialiasing");
691  QAction *antialiasingOn = mAntialiasing->addAction("On");
692  QAction *antialiasingOff = mAntialiasing->addAction("Off");
693#endif
694
695  if (antialiasing_enabled == false) {
696    createRadioAction(antialiasingOn,antialiasingOff,SLOT(toggleAntialiasing(bool)),2);
697  } else if (antialiasing_enabled == true) {
698    createRadioAction(antialiasingOn,antialiasingOff,SLOT(toggleAntialiasing(bool)),1);
699  } else {
700    mAntialiasing->clear();
701  }
702
703#if QT_VERSION < 0x040000
704  QPopupMenu *mHaloing = new QPopupMenu(mSpecial);
705  mSpecial->insertItem("Haloing",mHaloing);
706
707#if QT_VERSION < 0x030200
708  QAction *haloingOn = new QAction("&On","&On",CTRL+Key_O,mHaloing);
709  QAction *haloingOff = new QAction("&Off","&Off",CTRL+Key_F,mHaloing);
710#else
711  QAction *haloingOn = new QAction("&On",CTRL+Key_O,mHaloing);
712  QAction *haloingOff = new QAction("&Off",CTRL+Key_F,mHaloing);
713#endif
714  haloingOn->addTo(mHaloing);
715  haloingOff->addTo(mHaloing);
716#else
717  QMenu *mHaloing = mSpecial->addMenu("Haloing");
718  QAction *haloingOn = mHaloing->addAction("On");
719  QAction *haloingOff = mHaloing->addAction("Off");
720#endif
721  if (haloing_enabled == false) {
722    createRadioAction(haloingOn,haloingOff,SLOT(toggleHaloing(bool)),2);
723  } else if (haloing_enabled == true) {
724    createRadioAction(haloingOn,haloingOff,SLOT(toggleHaloing(bool)),1);
725  } else {
726    mHaloing->clear();
727  }
728
729#if QT_VERSION < 0x040000
730  QPopupMenu *mAux = new QPopupMenu(mSpecial);
731  mSpecial->insertItem("Auxiliairy edges",mAux);
732
733#if QT_VERSION < 0x030200
734  QAction *auxOn = new QAction("&On","&On",CTRL+Key_O,mAux);
735  QAction *auxOff = new QAction("&Off","&Off",CTRL+Key_F,mAux);
736#else
737  QAction *auxOn = new QAction("&On",CTRL+Key_O,mAux);
738  QAction *auxOff = new QAction("&Off",CTRL+Key_F,mAux);
739#endif
740  auxOn->addTo(mAux);
741  auxOff->addTo(mAux);
742
743#else
744  QMenu *mAux = mSpecial->addMenu("Auxiliary edges");
745  QAction *auxOn = mAux->addAction("On");
746  QAction *auxOff = mAux->addAction("Off");
747#endif
748  if (!fVP.IsAuxEdgeVisible()) {
749    createRadioAction(auxOn,auxOff,SLOT(toggleAux(bool)),1);
750  } else {
751    createRadioAction(auxOn,auxOff,SLOT(toggleAux(bool)),2);
752  }
753
754
755#if QT_VERSION >= 0x030200
756#if QT_VERSION < 0x040000
757  QPopupMenu *mFullScreen = new QPopupMenu(mSpecial);
758  mSpecial->insertItem("Full screen",mFullScreen);
759
760  QAction *fullOn = new QAction("&On",CTRL+Key_O,mFullScreen);
761  QAction *fullOff = new QAction("&Off",CTRL+Key_F,mFullScreen);
762  fullOn->addTo(mFullScreen);
763  fullOff->addTo(mFullScreen);
764#else
765  QMenu *mFullScreen = mSpecial->addMenu("Full screen");
766  QAction *fullOn = mFullScreen->addAction("On");
767  QAction *fullOff = mFullScreen->addAction("Off");
768#endif
769  createRadioAction(fullOn,fullOff,SLOT(toggleFullScreen(bool)),2);
770#endif
771
772}
773
774void G4OpenGLQtViewer::manageContextMenuEvent(QContextMenuEvent *e)
775{
776  if (!GLWindow) {
777    G4cerr << "Visualization window not defined, please choose one before\n" << G4endl;
778  } else {
779 
780    if (!fContextMenu)
781      createPopupMenu();
782   
783    // launch menu
784    if ( fContextMenu ) {
785      fContextMenu->exec( e->globalPos() );
786      //    delete fContextMenu;
787    }
788  }
789  e->accept();
790}
791
792
793/**
794   Create a radio button menu. The two menu will be connected. When click on one,
795   eatch state will be invert and callback method will be called.
796   @param action1 first action to connect
797   @param action2 second action to connect
798   @param method callback method
799   @param nCheck: 1 : first action will be set true. 2 : second action will be set true
800*/
801#if QT_VERSION < 0x040000
802void G4OpenGLQtViewer::createRadioAction(QAction *action1,QAction *action2, const std::string& method,unsigned int nCheck) {
803
804  if (action1->parent()->inherits("QPopupMenu")){
805    ((QPopupMenu*)action1->parent())->setCheckable(true);
806  }
807  ((QPopupMenu*)action1->parent())->setItemChecked(0,true);
808  ((QPopupMenu*)action1->parent())->setItemChecked(1,true);
809
810  if (nCheck ==1)
811    ((QPopupMenu*)action1->parent())->setItemChecked(0,true);
812  else
813    ((QPopupMenu*)action1->parent())->setItemChecked(1,true);
814   
815  //FIXME : Should not work on Qt3
816  QObject ::connect(action1, SIGNAL(activated()),action2, SLOT(toggle()));
817  QObject ::connect(action2, SIGNAL(activated()),action1, SLOT(toggle()));
818
819  QObject ::connect(action1, SIGNAL(toggled(bool)),this, method.c_str());
820}
821
822#else
823void G4OpenGLQtViewer::createRadioAction(QAction *action1,QAction *action2, const std::string& method,unsigned int nCheck) {
824
825  action1->setCheckable(true);
826  action2->setCheckable(true);
827
828  if (nCheck ==1)
829    action1->setChecked (true);
830  else
831    action2->setChecked (true);
832   
833  QObject ::connect(action1, SIGNAL(triggered(bool)),action2, SLOT(toggle()));
834  QObject ::connect(action2, SIGNAL(triggered(bool)),action1, SLOT(toggle()));
835
836  QObject ::connect(action1, SIGNAL(toggled(bool)),this, method.c_str());
837
838}
839#endif
840
841/**
842   Slot activate when mouseAction->rotate menu is set
843 */
844void G4OpenGLQtViewer::actionMouseRotate() {
845  emit toggleMouseAction(STYLE1);
846}
847
848/**
849   Slot activate when mouseAction->move menu is set
850 */
851void G4OpenGLQtViewer::actionMouseMove() {
852  emit toggleMouseAction(STYLE2);
853}
854
855/**
856   Slot activate when mouseAction->pick menu is set
857 */
858void G4OpenGLQtViewer::actionMouseZoom() {
859#ifdef GEANT4_QT_DEBUG
860  printf("G4OpenGLQtViewer::actionMouseZoom \n");
861#endif
862  emit toggleMouseAction(STYLE3);
863}
864
865/**
866   Slot activate when mouseAction->zoom menu is set
867 */
868void G4OpenGLQtViewer::actionMousePick() {
869#ifdef GEANT4_QT_DEBUG
870  printf("G4OpenGLQtViewer::actionMousePick \n");
871#endif
872  emit toggleMouseAction(STYLE4);
873}
874
875/**
876   Slot activate when drawing->wireframe menu is set
877 */
878void G4OpenGLQtViewer::actionDrawingWireframe() {
879  emit toggleDrawingAction(1);
880}
881
882/**
883   Slot activate when drawing->line removal menu is set
884 */
885void G4OpenGLQtViewer::actionDrawingLineRemoval() {
886  emit toggleDrawingAction(2);
887}
888
889/**
890   Slot activate when drawing->surface removal menu is set
891 */
892void G4OpenGLQtViewer::actionDrawingSurfaceRemoval() {
893  emit toggleDrawingAction(3);
894}
895
896/**
897   Slot activate when drawing->wireframe menu is set
898 */
899void G4OpenGLQtViewer::actionDrawingLineSurfaceRemoval() {
900  emit toggleDrawingAction(4);
901}
902
903
904/**
905   Slot activated when mouse action is toggle
906   @param aAction : STYLE1, STYLE2, STYLE3
907 */
908void G4OpenGLQtViewer::toggleMouseAction(mouseActions aAction) {
909 
910  if (aAction == STYLE1) {
911    G4cout << "Clic and move mouse to rotate Volume \n" << G4endl;
912    G4cout << "Press left/right arrows to move camera left/right\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;
915    G4cout << "Press +/- to zoom into volume\n" << G4endl;
916#if QT_VERSION < 0x040000
917    fMouseRotate->setItemChecked (0,true);
918    fMouseMove->setItemChecked (0,false);
919    fMouseZoom->setItemChecked (0,false);
920    fMousePick->setItemChecked (0,false);
921#else
922    fMouseRotate->setChecked (true);
923    fMouseMove->setChecked (false);
924    fMouseZoom->setChecked (false);
925    fMousePick->setChecked (false);
926#endif
927    fMouseAction = STYLE1;
928    fVP.SetPicking(false);
929  } else  if (aAction == STYLE2) {
930    G4cout << "Clic and move mouse to move Volume \n" << G4endl;
931#if QT_VERSION < 0x040000
932    fMouseRotate->setItemChecked (0,false);
933    fMouseMove->setItemChecked (0,true);
934    fMouseZoom->setItemChecked (0,false);
935    fMousePick->setItemChecked (0,false);
936#else
937    fMouseRotate->setChecked (false);
938    fMouseMove->setChecked (true);
939    fMouseZoom->setChecked (false);
940    fMousePick->setChecked (false);
941#endif
942    fMouseAction = STYLE2;
943    fVP.SetPicking(false);
944  } else  if (aAction == STYLE3) {
945    G4cout << "Clic and move mouse to rotate Volume \n" << G4endl;
946#if QT_VERSION < 0x040000
947    fMouseRotate->setItemChecked (0,false);
948    fMouseMove->setItemChecked (0,false);
949    fMouseZoom->setItemChecked (0,true);
950    fMousePick->setItemChecked (0,false);
951#else
952    fMouseRotate->setChecked (false);
953    fMouseMove->setChecked (false);
954    fMouseZoom->setChecked (true);
955    fMousePick->setChecked (false);
956#endif
957    fMouseAction = STYLE3;
958    fVP.SetPicking(false);
959  } else  if (aAction == STYLE4) {
960#if QT_VERSION < 0x040000
961    fMouseRotate->setItemChecked (0,false);
962    fMouseMove->setItemChecked (0,false);
963    fMouseZoom->setItemChecked (0,false);
964    fMousePick->setItemChecked (0,true);
965#else
966    fMouseRotate->setChecked (false);
967    fMouseMove->setChecked (false);
968    fMouseZoom->setChecked (false);
969    fMousePick->setChecked (true);
970#endif
971    fVP.SetPicking(true);
972    fMouseAction = STYLE4;
973  }
974
975}
976/**
977   Slot activated when drawing menu is toggle
978   Warning : When G4OpenGLStoredQtViewer::DrawView() method call,
979   KernelVisitDecision () will be call and will set the fNeedKernelVisit
980   to 1. See G4XXXStoredViewer::CompareForKernelVisit for explanations.
981   It will cause a redraw of the view
982   @param aAction : 1 wireframe, 2 line removal, 3 surface removal, 4 line & surface removal
983   @see G4OpenGLStoredQtViewer::DrawView
984   @see G4XXXStoredViewer::CompareForKernelVisit
985 */
986void G4OpenGLQtViewer::toggleDrawingAction(int aAction) {
987
988  G4ViewParameters::DrawingStyle d_style;
989 
990
991  if (aAction ==1) {
992#if QT_VERSION < 0x040000
993    fDrawingWireframe->setItemChecked (0,true);
994    fDrawingLineRemoval->setItemChecked (0,false);
995    fDrawingSurfaceRemoval->setItemChecked (0,false);
996    fDrawingLineSurfaceRemoval->setItemChecked (0,false);
997#else
998    fDrawingWireframe->setChecked (true);
999    fDrawingLineRemoval->setChecked (false);
1000    fDrawingSurfaceRemoval->setChecked (false);
1001    fDrawingLineSurfaceRemoval->setChecked (false);
1002#endif
1003
1004    d_style = G4ViewParameters::wireframe;
1005
1006  } else  if (aAction ==2) {
1007#if QT_VERSION < 0x040000
1008    fDrawingWireframe->setItemChecked (0,false);
1009    fDrawingLineRemoval->setItemChecked (0,true);
1010    fDrawingSurfaceRemoval->setItemChecked (0,false);
1011    fDrawingLineSurfaceRemoval->setItemChecked (0,false);
1012#else
1013    fDrawingWireframe->setChecked (false);
1014    fDrawingLineRemoval->setChecked (true);
1015    fDrawingSurfaceRemoval->setChecked (false);
1016    fDrawingLineSurfaceRemoval->setChecked (false);
1017#endif
1018
1019    d_style = G4ViewParameters::hlr;
1020
1021  } else  if (aAction ==3) {
1022#if QT_VERSION < 0x040000
1023    fDrawingWireframe->setItemChecked (0,false);
1024    fDrawingLineRemoval->setItemChecked (0,false);
1025    fDrawingSurfaceRemoval->setItemChecked (0,true);
1026    fDrawingLineSurfaceRemoval->setItemChecked (0,false);
1027#else
1028    fDrawingWireframe->setChecked (false);
1029    fDrawingLineRemoval->setChecked (false);
1030    fDrawingSurfaceRemoval->setChecked (true);
1031    fDrawingLineSurfaceRemoval->setChecked (false);
1032#endif
1033
1034    d_style = G4ViewParameters::hsr;
1035
1036  } else  if (aAction ==4) {
1037#if QT_VERSION < 0x040000
1038    fDrawingWireframe->setItemChecked (0,false);
1039    fDrawingLineRemoval->setItemChecked (0,false);
1040    fDrawingSurfaceRemoval->setItemChecked (0,false);
1041    fDrawingLineSurfaceRemoval->setItemChecked (0,true);
1042#else
1043    fDrawingWireframe->setChecked (false);
1044    fDrawingLineRemoval->setChecked (false);
1045    fDrawingSurfaceRemoval->setChecked (false);
1046    fDrawingLineSurfaceRemoval->setChecked (true);
1047#endif
1048    d_style = G4ViewParameters::hlhsr;
1049  }
1050  fVP.SetDrawingStyle(d_style);
1051
1052  updateQWidget();
1053#ifdef GEANT4_QT_DEBUG
1054  printf("G4OpenGLQtViewer::toggleDrawingAction\n");
1055#endif
1056}
1057
1058
1059/**
1060   SLOT Activate by a click on the representation menu
1061   Warning : When G4OpenGLStoredQtViewer::DrawView() method call,
1062   KernelVisitDecision () will be call and will set the fNeedKernelVisit
1063   to 1. See G4XXXStoredViewer::CompareForKernelVisit for explanations.
1064   It will cause a redraw of the view
1065   @param check : 1 polyhedron, 0 nurbs
1066   @see G4OpenGLStoredQtViewer::DrawView
1067   @see G4XXXStoredViewer::CompareForKernelVisit
1068*/
1069void G4OpenGLQtViewer::toggleRepresentation(bool check) {
1070
1071  G4ViewParameters::RepStyle style;
1072  if (check == 1) {
1073    style = G4ViewParameters::polyhedron;
1074  } else {
1075    style = G4ViewParameters::nurbs;
1076  }
1077  fVP.SetRepStyle (style);
1078
1079#ifdef GEANT4_QT_DEBUG
1080  printf("G4OpenGLQtViewer::toggleRepresentation 3%d\n",check);
1081#endif
1082  updateQWidget();
1083#ifdef GEANT4_QT_DEBUG
1084  printf("G4OpenGLQtViewer::toggleRepresentation 4%d\n",check);
1085#endif
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*/
1098void 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
1139
1140/**
1141   SLOT Activate by a click on the background menu
1142@param check : 1 white, 0 black
1143*/
1144void G4OpenGLQtViewer::toggleBackground(bool check) {
1145
1146  //   //I need to revisit the kernel if the background colour changes and
1147  //   //hidden line removal is enabled, because hlr drawing utilises the
1148  //   //background colour in its drawing...
1149  //   // (Note added by JA 13/9/2005) Background now handled in view
1150  //   // parameters.  A kernel visit is triggered on change of background.
1151  if (check == 1) {
1152    ((G4ViewParameters&)this->GetViewParameters()).
1153      SetBackgroundColour(G4Colour(1.,1.,1.));  // White
1154  } else {
1155    ((G4ViewParameters&)this->GetViewParameters()).
1156      SetBackgroundColour(G4Colour(0.,0.,0.));  // Black
1157  }
1158  updateQWidget();
1159}
1160
1161/**
1162   SLOT Activate by a click on the transparency menu
1163@param check : 1 , 0
1164*/
1165void G4OpenGLQtViewer::toggleTransparency(bool check) {
1166 
1167  if (check) {
1168    transparency_enabled = false;
1169  } else {
1170    transparency_enabled = true;
1171  }
1172  SetNeedKernelVisit (true);
1173  updateQWidget();
1174}
1175
1176/**
1177   SLOT Activate by a click on the antialiasing menu
1178@param check : 1 , 0
1179*/
1180void G4OpenGLQtViewer::toggleAntialiasing(bool check) {
1181
1182  if (!check) {
1183    antialiasing_enabled = false;
1184    glDisable (GL_LINE_SMOOTH);
1185    glDisable (GL_POLYGON_SMOOTH);
1186  } else {
1187    antialiasing_enabled = true;
1188    glEnable (GL_LINE_SMOOTH);
1189    glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);
1190    glEnable (GL_POLYGON_SMOOTH);
1191    glHint (GL_POLYGON_SMOOTH_HINT, GL_NICEST);
1192  }
1193
1194  updateQWidget();
1195#ifdef GEANT4_QT_DEBUG
1196  printf("G4OpenGLQtViewer::toggleRepresentation %d\n",check);
1197#endif
1198}
1199
1200/**
1201   SLOT Activate by a click on the haloing menu
1202@param check : 1 , 0
1203*/
1204//FIXME : I SEE NOTHING...
1205void G4OpenGLQtViewer::toggleHaloing(bool check) {
1206  if (check) {
1207    haloing_enabled = false;
1208  } else {
1209    haloing_enabled = true;
1210  }
1211
1212  updateQWidget();
1213
1214#ifdef GEANT4_QT_DEBUG
1215  printf("G4OpenGLQtViewer::toggleRepresentation %d\n",check);
1216#endif
1217}
1218
1219/**
1220   SLOT Activate by a click on the auxiliaire edges menu
1221@param check : 1 , 0
1222*/
1223void G4OpenGLQtViewer::toggleAux(bool check) {
1224  if (check) {
1225    fVP.SetAuxEdgeVisible(false);
1226  } else {
1227    fVP.SetAuxEdgeVisible(true);
1228  }
1229  SetNeedKernelVisit (true);
1230  updateQWidget();
1231
1232#ifdef GEANT4_QT_DEBUG
1233  printf("G4OpenGLQtViewer::toggleRepresentation %d\n",check);
1234#endif
1235}
1236
1237/**
1238   SLOT Activate by a click on the full screen menu
1239@param check : 1 , 0
1240*/
1241void G4OpenGLQtViewer::toggleFullScreen(bool check) {
1242#if QT_VERSION >= 0x030200
1243  GLWindow->setWindowState(GLWindow->windowState() ^ Qt::WindowFullScreen);
1244#else
1245  G4cerr << "This version of G4UI Could not generate the selected format\n" << G4endl;
1246#endif
1247#ifdef GEANT4_QT_DEBUG
1248  printf("G4OpenGLQtViewer::toggleRepresentation %d\n",check);
1249#endif
1250}
1251
1252void G4OpenGLQtViewer::actionCreateEPS() {
1253  QString filters;
1254#if QT_VERSION < 0x040000
1255  QStrList listFormat=QImageIO::outputFormats();
1256  char *tmp=listFormat.first();
1257  while (tmp!=0) {
1258    filters += QString(tmp) + ";;";
1259    tmp=listFormat.next();
1260  }
1261#else
1262  QList<QByteArray> formats =  QImageWriter::supportedImageFormats ();
1263  for (int i = 0; i < formats.size(); ++i) {
1264    filters +=formats.at(i) + ";;";
1265  }
1266#endif
1267  filters += "eps;;";
1268  filters += "ps;;";
1269  filters += "pdf";
1270  QString* selectedFormat = new QString();
1271#if QT_VERSION < 0x040000
1272  QString nomFich =  QFileDialog::getSaveFileName ( ".",
1273                                                    filters,
1274                                                    GLWindow,
1275                                                    "Save file dialog",
1276                                                    tr("Save as ..."),
1277                                                    selectedFormat );
1278#else
1279  QString nomFich =  QFileDialog::getSaveFileName ( GLWindow,
1280                                                    tr("Save as ..."),
1281                                                    ".",
1282                                                    filters,
1283                                                    selectedFormat );
1284#endif
1285  // bmp jpg jpeg png ppm xbm xpm
1286  if (nomFich == "") {
1287    return;
1288  }
1289#if QT_VERSION < 0x040000
1290  nomFich += "."+QString(selectedFormat->ascii());
1291  QString format = selectedFormat->lower();
1292#else
1293  nomFich += "."+QString(selectedFormat->toStdString().c_str());
1294  QString format = selectedFormat->toLower();
1295#endif
1296  G4OpenGLQtExportDialog* exportDialog= new G4OpenGLQtExportDialog(GLWindow,format,fWindow->height(),fWindow->width());
1297  if(  exportDialog->exec()) {
1298
1299    QImage image;
1300    bool res = false;
1301    if ((exportDialog->getWidth() !=fWindow->width()) ||
1302        (exportDialog->getHeight() !=fWindow->height())) {
1303      if (format != QString("eps")) {
1304      G4cerr << "Export->Change Size : This function is not implemented, to export in another size, please resize your frame to what you need\n" << G4endl;
1305     
1306      //    rescaleImage(exportDialog->getWidth(),exportDialog->getHeight());// re-scale image
1307      //      QGLWidget* glResized = fWindow;
1308
1309      // FIXME :
1310      // L.Garnier : I've try to implement change size function, but the problem is
1311      // the renderPixmap function call the QGLWidget to resize and it doesn't draw
1312      // the content of this widget... It only draw the background.
1313
1314      //      fWindow->renderPixmap (exportDialog->getWidth()*2,exportDialog->getHeight()*2,true );
1315
1316      //      QPixmap pixmap = fWindow->renderPixmap ();
1317     
1318      //      image = pixmap->toImage();
1319      //      glResized->resize(exportDialog->getWidth()*2,exportDialog->getHeight()*2);
1320      //      image = glResized->grabFrameBuffer();
1321      }     
1322    } else {
1323      image = fWindow->grabFrameBuffer();
1324    }   
1325    if (format == QString("eps")) {
1326      if (exportDialog->getVectorEPS()) {
1327        res = generateVectorEPS(nomFich,exportDialog->getWidth(),exportDialog->getHeight(),image);
1328      } else {
1329        res = generateEPS(nomFich,exportDialog->getNbColor(),image);
1330      }
1331    } else if ((format == "ps") || (format == "pdf")) {
1332      res = generatePS_PDF(nomFich,exportDialog->getNbColor(),image);
1333    } else if ((format == "tif") ||
1334               (format == "tiff") ||
1335               (format == "jpg") ||
1336               (format == "jpeg") ||
1337               (format == "png") ||
1338               (format == "pbm") ||
1339               (format == "pgm") ||
1340               (format == "ppm") ||
1341               (format == "bmp") ||
1342               (format == "xbm") ||
1343               (format == "xpm")) {
1344#if QT_VERSION < 0x040000
1345      res = image.save(nomFich,selectedFormat->ascii(),exportDialog->getSliderValue());
1346#else
1347      res = image.save(nomFich,0,exportDialog->getSliderValue());
1348#endif
1349    } else {
1350      G4cerr << "This version of G4UI Could not generate the selected format\n" << G4endl;
1351    }
1352    if (res == false) {
1353#if QT_VERSION < 0x040000
1354      G4cerr << "Error while saving file... "<<nomFich.ascii()<<"\n" << G4endl;
1355#else
1356      G4cerr << "Error while saving file... "<<nomFich.toStdString().c_str()<<"\n" << G4endl;
1357#endif
1358    } else {
1359#if QT_VERSION < 0x040000
1360      G4cout << "File "<<nomFich.ascii()<<" has been saved \n" << G4endl;
1361#else
1362      G4cout << "File "<<nomFich.toStdString().c_str()<<" has been saved \n" << G4endl;
1363#endif
1364    }
1365   
1366  } else { // cancel selected
1367    return;
1368  }
1369 
1370#ifdef GEANT4_QT_DEBUG
1371  printf("G4OpenGLQtViewer::actionCreateEPS() \n");
1372#endif
1373}
1374
1375/*
1376// http://www.google.com/codesearch?hl=en&q=+jpg+Qt+quality+QDialog+show:FZkUoth8oiw:TONpW2mR-_c:tyTfrKMO-xI&sa=N&cd=2&ct=rc&cs_p=http://soft.proindependent.com/src/qtiplot-0.8.9.zip&cs_f=qtiplot-0.8.9/qtiplot/src/application.cpp#a0
1377
1378void Graph::exportToSVG(const QString& fname)
1379{
1380  // enable workaround for Qt3 misalignments
1381  QwtPainter::setSVGMode(true);
1382  QPicture picture;
1383  QPainter p(&picture);
1384  d_plot->print(&p, d_plot->rect());
1385  p.end();
1386
1387  picture.save(fname, "svg");
1388}
1389*/
1390
1391
1392
1393
1394/**
1395   Save the current mouse press point
1396   @param p mouse click point
1397*/
1398void G4OpenGLQtViewer::G4MousePressEvent(QPoint p)
1399{
1400  fLastPos = p;
1401  if (fMouseAction == STYLE4){  // pick
1402    Pick(p.x(),p.y());
1403  }
1404}
1405
1406
1407/**
1408   @param pos_x mouse x position
1409   @param pos_y mouse y position
1410   @param mButtons mouse button active
1411*/
1412
1413#if QT_VERSION < 0x040000
1414void G4OpenGLQtViewer::G4MouseEvent(int pos_x, int pos_y,Qt::ButtonState mButtons)
1415#else
1416void G4OpenGLQtViewer::G4MouseEvent(int pos_x, int pos_y,Qt::MouseButtons mButtons)
1417#endif
1418{
1419  int dx = pos_x - fLastPos.x();
1420  int dy = pos_y - fLastPos.y();
1421  if (fMouseAction == STYLE1) {  // rotate
1422    if (mButtons & Qt::LeftButton) {
1423      G4MouseRotateEvent(dx,dy);
1424    }
1425  } else   if (fMouseAction == STYLE2){  // move
1426    if (mButtons & Qt::LeftButton) {
1427      G4MouseMoveEvent(dx,dy,0);
1428    }
1429  } else   if (fMouseAction == STYLE3){  // zoom
1430    if (mButtons & Qt::LeftButton) {
1431      G4cerr << "Zoom not implemented for the moment\n" << G4endl;
1432    }
1433  }
1434  fLastPos = QPoint(pos_x, pos_y);
1435}
1436
1437/**
1438   @param dx delta mouse x position
1439   @param dy delta mouse y position
1440*/
1441
1442void G4OpenGLQtViewer::G4MouseMoveEvent(int dx, int dy, int dz)
1443{
1444  G4Point3D stp
1445    = GetSceneHandler()->GetScene()->GetStandardTargetPoint();
1446 
1447  G4Point3D tp = stp + fVP.GetCurrentTargetPoint ();
1448 
1449  const G4Vector3D& upVector = fVP.GetUpVector ();
1450  const G4Vector3D& vpVector = fVP.GetViewpointDirection ();
1451 
1452  G4Vector3D unitRight = (upVector.cross (vpVector)).unit();
1453  G4Vector3D unitUp    = (vpVector.cross (unitRight)).unit();
1454 
1455#ifdef GEANT4_QT_DEBUG
1456  G4cout << fVP<<G4endl;
1457  printf("Mouse event Target Point : %f %f %f\n",tp.x(),tp.y(),tp.z());
1458  printf("Mouse event upVector : %f %f %f\n",upVector.x(),upVector.y(),upVector.z());
1459  printf("Mouse event vpVector Point : %f %f %f\n",vpVector.x(),vpVector.y(),vpVector.z());
1460  printf("Mouse event unitRight Point : %f %f %f\n",unitRight.x(),unitRight.y(),unitRight.z());
1461  printf("Mouse event unitUp Point : %f %f %f\n",unitUp.x(),unitUp.y(),unitUp.z());
1462#endif
1463  tp += -dx * unitRight + dy * unitUp + dz * vpVector;
1464  fVP.SetCurrentTargetPoint (tp - stp);
1465 
1466  updateQWidget();
1467}
1468
1469
1470/**
1471   @param dx delta mouse x position
1472   @param dy delta mouse y position
1473*/
1474
1475void G4OpenGLQtViewer::G4MouseRotateEvent(int dx, int dy)
1476{
1477  //phi spin stuff here
1478 
1479  G4Vector3D vp = fVP.GetViewpointDirection ().unit ();
1480  G4Vector3D up = fVP.GetUpVector ().unit ();
1481 
1482  G4Vector3D yprime = (up.cross(vp)).unit();
1483  G4Vector3D zprime = (vp.cross(yprime)).unit();
1484 
1485  G4double delta_alpha;
1486  G4double delta_theta;
1487 
1488  if (fVP.GetLightsMoveWithCamera()) {
1489    delta_alpha = dy;
1490    delta_theta = -dx;
1491  } else {
1492    delta_alpha = -dy;
1493    delta_theta = dx;
1494  }   
1495 
1496  delta_alpha *= deg;
1497  delta_theta *= deg;
1498 
1499  G4Vector3D new_vp = std::cos(delta_alpha) * vp + std::sin(delta_alpha) * zprime;
1500 
1501  G4Vector3D new_up;
1502  if (fVP.GetLightsMoveWithCamera()) {
1503    new_up = (new_vp.cross(yprime)).unit();
1504    fVP.SetUpVector(new_up);
1505  } else {
1506    new_up = up;
1507  }
1508  ////////////////
1509  // Rotates by fixed azimuthal angle delta_theta.
1510 
1511  G4double cosalpha = new_up.dot (new_vp.unit());
1512  G4double sinalpha = std::sqrt (1. - std::pow (cosalpha, 2));
1513  yprime = (new_up.cross (new_vp.unit())).unit ();
1514  G4Vector3D xprime = yprime.cross (new_up);
1515  // Projection of vp on plane perpendicular to up...
1516  G4Vector3D a1 = sinalpha * xprime;
1517  // Required new projection...
1518  G4Vector3D a2 =
1519    sinalpha * (std::cos (delta_theta) * xprime + std::sin (delta_theta) * yprime);
1520  // Required Increment vector...
1521  G4Vector3D delta = a2 - a1;
1522  // So new viewpoint is...
1523  G4Vector3D viewPoint = new_vp.unit() + delta;
1524 
1525  fVP.SetViewAndLights (viewPoint);
1526  updateQWidget();
1527 
1528}
1529
1530/** This is the benning of a rescale function. It does nothing for the moment
1531    @param aWidth : new width
1532    @param aHeight : new height
1533*/
1534void G4OpenGLQtViewer::rescaleImage(
1535 int aWidth
1536,int aHeight
1537){
1538#ifdef GEANT4_QT_DEBUG
1539  printf("should rescale \n");
1540#endif
1541  GLfloat* feedback_buffer;
1542  GLint returned;
1543  FILE* file;
1544 
1545//   feedback_buffer = new GLfloat[size];
1546//   glFeedbackBuffer (size, GL_3D_COLOR, feedback_buffer);
1547//   glRenderMode (GL_FEEDBACK);
1548 
1549//   glViewport (0, 0, aWidth, aHeight);
1550//   DrawView();
1551//   returned = glRenderMode (GL_RENDER);
1552
1553}
1554
1555/**
1556   Generate Vectorial Encapsulated Postscript form image
1557   @param aFilename : name of file
1558   @param aInColor : numbers of colors : 1->BW 2->RGB 3->RGB+Alpha
1559   @param aImage : Image to print
1560*/
1561bool G4OpenGLQtViewer::generateVectorEPS (
1562 QString aFilename
1563,int aWidth
1564,int aHeight
1565,QImage aImage
1566)
1567{
1568  // Print vectored PostScript
1569 
1570  G4int size = 5000000;
1571
1572  GLfloat* feedback_buffer;
1573  GLint returned;
1574  FILE* file;
1575 
1576  feedback_buffer = new GLfloat[size];
1577  glFeedbackBuffer (size, GL_3D_COLOR, feedback_buffer);
1578  glRenderMode (GL_FEEDBACK);
1579 
1580  int side = qMin(aWidth, aHeight);
1581  glViewport((aWidth - side) / 2, (aHeight - side) / 2, side, side);
1582  DrawView();
1583
1584  returned = glRenderMode (GL_RENDER);
1585 
1586 
1587#if QT_VERSION < 0x040000
1588  file = fopen (aFilename.ascii(), "w");
1589#else
1590  file = fopen (aFilename.toStdString().c_str(), "w");
1591#endif
1592  if (file) {
1593    spewWireframeEPS (file, returned, feedback_buffer, "rendereps");
1594  } else {
1595#if QT_VERSION < 0x040000
1596    G4cerr << "Could not open "<< aFilename.ascii()<<"\n" << G4endl;
1597#else
1598    G4cerr << "Could not open "<< aFilename.toStdString().c_str()<<"\n" << G4endl;
1599#endif
1600  }
1601 
1602  delete[] feedback_buffer;
1603
1604  return true;
1605}
1606
1607/**
1608   Generate Encapsulated Postscript form image
1609   @param aFilename : name of file
1610   @param aInColor : numbers of colors : 1->BW 2->RGB 3->RGB+Alpha
1611   @param aImage : Image to print
1612*/
1613bool G4OpenGLQtViewer::generateEPS (
1614 QString aFilename
1615,int aInColor
1616,QImage aImage
1617)
1618{
1619  // FIXME
1620#ifdef GEANT4_QT_DEBUG
1621  printf("saving EPS\n");
1622#endif
1623
1624  FILE* fp;
1625
1626  if (aImage.bits () == NULL)
1627    return false;
1628 
1629#if QT_VERSION < 0x040000
1630  fp = fopen (aFilename.ascii(), "w");
1631#else
1632  fp = fopen (aFilename.toStdString().c_str(), "w");
1633#endif
1634  if (fp == NULL) {
1635    return false;
1636  }
1637 
1638  fprintf (fp, "%%!PS-Adobe-2.0 EPSF-1.2\n");
1639#if QT_VERSION < 0x040000
1640  fprintf (fp, "%%%%Title: %s\n", aFilename.ascii());
1641#else
1642  fprintf (fp, "%%%%Title: %s\n", aFilename.toStdString().c_str());
1643#endif
1644  fprintf (fp, "%%%%Creator: OpenGL pixmap render output\n");
1645  fprintf (fp, "%%%%BoundingBox: 0 0 %d %d\n", aImage.width(), aImage.height());
1646  fprintf (fp, "%%%%EndComments\n");
1647  fprintf (fp, "gsave\n");
1648  fprintf (fp, "/bwproc {\n");
1649  fprintf (fp, "    rgbproc\n");
1650  fprintf (fp, "    dup length 3 idiv string 0 3 0 \n");
1651  fprintf (fp, "    5 -1 roll {\n");
1652  fprintf (fp, "    add 2 1 roll 1 sub dup 0 eq\n");
1653  fprintf (fp, "    { pop 3 idiv 3 -1 roll dup 4 -1 roll dup\n");
1654  fprintf (fp, "       3 1 roll 5 -1 roll } put 1 add 3 0 \n");
1655  fprintf (fp, "    { 2 1 roll } ifelse\n");
1656  fprintf (fp, "    }forall\n");
1657  fprintf (fp, "    pop pop pop\n");
1658  fprintf (fp, "} def\n");
1659  fprintf (fp, "systemdict /colorimage known not {\n");
1660  fprintf (fp, "   /colorimage {\n");
1661  fprintf (fp, "       pop\n");
1662  fprintf (fp, "       pop\n");
1663  fprintf (fp, "       /rgbproc exch def\n");
1664  fprintf (fp, "       { bwproc } image\n");
1665  fprintf (fp, "   }  def\n");
1666  fprintf (fp, "} if\n");
1667  fprintf (fp, "/picstr %d string def\n", aImage.width() * aInColor);
1668  fprintf (fp, "%d %d scale\n", aImage.width(), aImage.height());
1669  fprintf (fp, "%d %d %d\n", aImage.width(), aImage.height(), 8);
1670  fprintf (fp, "[%d 0 0 %d 0 0]\n", aImage.width(), aImage.height());
1671  fprintf (fp, "{currentfile picstr readhexstring pop}\n");
1672  fprintf (fp, "false %d\n", aInColor);
1673  fprintf (fp, "colorimage\n");
1674 
1675
1676  int width = aImage.width();
1677  int height = aImage.height();
1678  int depth = aImage.depth();
1679  int size = width*height;
1680 
1681  if (depth == 1)
1682    size = (width+7)/8*height;
1683  else if (aInColor == 1)
1684    size = size*3;
1685 
1686  int i = 0;
1687  //  if ( aInColor ==1 ) {
1688  // FIXME : L. Garnier. For the moment 10 dec 2007, I could not find a way
1689  // to save correctly grayscale Image. I mean that color or grayscale image
1690  // have the same file save size !
1691 
1692  /* } else*/ if (depth == 8) {
1693    for(int y=height-1; y >=0 ; y--) {
1694      const uchar * s = aImage.scanLine(y);
1695      for(int x=0; x <width; x++) {
1696        QRgb rgb = aImage.color(s[x]);
1697        if (aInColor == 1) {
1698          fprintf (fp, " %02hx ",(unsigned char)qGray(rgb));
1699          i++;
1700        } else {
1701          fprintf (fp, " %02hx %02hx %02hx",
1702                   (unsigned char) qRed(rgb),
1703                   (unsigned char) qGreen(rgb),
1704                   (unsigned char) qBlue(rgb));
1705          i += 3;
1706        }
1707      }
1708      fprintf (fp, "\n");
1709    }
1710  } else {
1711#if QT_VERSION < 0x040000
1712    bool alpha = aImage.hasAlphaBuffer();
1713#else
1714    bool alpha = aImage.hasAlphaChannel();
1715    for(int y=height-1; y >=0 ; y--) {
1716      QRgb * s = (QRgb*)(aImage.scanLine(y));
1717      for(int x=0; x <width; x++) {
1718        QRgb rgb = (*s++);
1719        if (alpha && qAlpha(rgb) < 0x40) // 25% alpha, convert to white -
1720          rgb = qRgb(0xff, 0xff, 0xff);
1721        if (aInColor == 1) {
1722          fprintf (fp, " %02hx ",(unsigned char)qGray(rgb));
1723          i++;
1724        } else {
1725          fprintf (fp, " %02hx %02hx %02hx",
1726                   (unsigned char) qRed(rgb),
1727                   (unsigned char) qGreen(rgb),
1728                   (unsigned char) qBlue(rgb));
1729          i += 3;
1730        }
1731      }
1732      fprintf (fp, "\n");
1733    }
1734#endif
1735
1736  }
1737
1738  fprintf (fp, "grestore\n");
1739  fprintf (fp, "showpage\n");
1740  fclose (fp);
1741
1742  return true;
1743}
1744/**
1745   Generate Postscript or PDF form image
1746   @param aFilename : name of file
1747   @param aInColor : numbers of colors : 1->BW 2->RGB
1748   @param aImage : Image to print
1749*/
1750bool G4OpenGLQtViewer::generatePS_PDF (
1751 QString aFilename
1752,int aInColor
1753,QImage aImage
1754)
1755{
1756
1757#if QT_VERSION < 0x040000
1758#ifdef Q_WS_MAC || Q_WS_X11
1759  QPrinter printer;
1760  //  printer.setPageSize(pageSize);
1761  if (aInColor == 1) {
1762    printer.setColorMode(QPrinter::GrayScale);
1763  } else {
1764    printer.setColorMode(QPrinter::Color);
1765  }
1766
1767  /* FIXME : I don't know which format it will save...
1768     if (aFilename.endsWith(".ps")) {
1769     printer.setOutputFormat(QPrinter::PostScriptFormat);
1770     } else {
1771     printer.setOutputFormat(QPrinter::PdfFormat);
1772     }
1773  */
1774  printer.setOutputFileName(aFilename);
1775  //  printer.setFullPage ( true);
1776  QPainter paint(&printer);
1777  paint.drawImage (0,0,aImage );
1778  paint.end();
1779#else
1780  G4cerr << "This fonction is only supported on Mac OsX or X11 with Qt3. Full platform supported with Qt4\n" << G4endl;
1781#endif
1782#else
1783  QPrinter printer;
1784  //  printer.setPageSize(pageSize);
1785
1786  // FIXME : L. Garnier 4/12/07
1787  // This is not working, it does nothing. Image is staying in color mode
1788  // So I have desactivate the B/W button in GUI
1789  if ((!aImage.isGrayscale ()) &&(aInColor ==1 )) {
1790#if QT_VERSION < 0x040000
1791    aImage = aImage.convertDepth(1,Qt::MonoOnly);
1792#else
1793    aImage = aImage.convertToFormat ( aImage.format(), Qt::MonoOnly);
1794#endif
1795  }
1796
1797
1798  if (aFilename.endsWith(".ps")) {
1799#if QT_VERSION > 0x040200
1800    printer.setOutputFormat(QPrinter::PostScriptFormat);
1801#endif
1802  } else {
1803#if QT_VERSION > 0x040100
1804    printer.setOutputFormat(QPrinter::PdfFormat);
1805#endif
1806  }
1807#if QT_VERSION > 0x040100
1808  printer.setOutputFileName(aFilename);
1809#endif
1810  //  printer.setFullPage ( true);
1811  QPainter paint(&printer);
1812  paint.drawImage (0,0,aImage);
1813  paint.end();
1814#endif
1815  return true;
1816}
1817
1818#endif
1819
1820void G4OpenGLQtViewer::G4keyPressEvent (QKeyEvent * event)
1821{
1822  if (holdKeyEvent)
1823    return;
1824
1825  holdKeyEvent = true;
1826
1827#ifdef GEANT4_QT_DEBUG
1828  printf("G4OpenGLQtViewer::keyPressEvent count:%d autoRepeat:%d key:%d\n",event->count(),event->isAutoRepeat(),event->key());
1829#endif
1830if (event->modifiers() & Qt::ShiftModifier)
1831    {
1832      printf("-------------------------\n");
1833    }
1834
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
1844    {
1845      G4MouseMoveEvent(0,1,0);
1846    }
1847  else if (event->key() == Qt::Key_Up)  // go up
1848    {
1849      G4MouseMoveEvent(0,-1,0);
1850    }
1851  else if (event->key() == Qt::Key_Left) // go left
1852    {
1853      G4MouseMoveEvent(-1,0,0);
1854    }
1855  else if (event->key() == Qt::Key_Right) // go right
1856    {
1857      G4MouseMoveEvent(1,0,0);
1858    }
1859  else if (event->key() == Qt::Key_Plus) // zoom in
1860    {
1861      fVP.SetZoomFactor(fVP.GetZoomFactor()*fDeltaZoom);
1862      updateQWidget();
1863    }
1864  else if (event->key() == Qt::Key_Minus) // zoom out
1865    {
1866      fVP.SetZoomFactor(fVP.GetZoomFactor()/fDeltaZoom);
1867      updateQWidget();
1868    }
1869#ifdef GEANT4_QT_DEBUG
1870  printf("G4OpenGLQtViewer::keyPressEvent END\n");
1871#endif
1872  holdKeyEvent = false;
1873}
1874
1875/*
1876 
1877void MultiLayer::exportToSVG(const QString& fname)
1878{
1879  QPicture picture;
1880  QPainter p(&picture);
1881  for (int i=0;i<(int)graphsList->count();i++)
1882    {
1883      Graph *gr=(Graph *)graphsList->at(i);
1884      Plot *myPlot= (Plot *)gr->plotWidget();
1885     
1886      QPoint pos=gr->pos();
1887     
1888      int width=int(myPlot->frameGeometry().width());
1889      int height=int(myPlot->frameGeometry().height());
1890     
1891      myPlot->print(&p, QRect(pos,QSize(width,height)));
1892    }
1893 
1894  p.end();
1895  picture.save(fname, "svg");
1896}
1897*/
1898
Note: See TracBrowser for help on using the repository browser.