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

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

Bounton perspective Ok. Inversion des commandes rotation

  • Property svn:mime-type set to text/cpp
File size: 55.5 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#include "G4UnitsTable.hh"
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(fContextMenu);
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  QMenu *mProjection = mStyle->addMenu("&Projection");
450  QAction *polyhedron = mRepresentation->addAction("Polyhedron");
451  QAction *nurbs = mRepresentation->addAction("NURBS");
452
453  QAction *ortho = mProjection->addAction("Orthographic");
454  QAction *perspective = mProjection->addAction("Persepective");
455#endif
456
457  // INIT mRepresentation
458  G4ViewParameters::RepStyle style;
459  style = fVP.GetRepStyle();
460  if (style == G4ViewParameters::polyhedron) {
461    createRadioAction(polyhedron,nurbs,SLOT(toggleRepresentation(bool)),1);
462  } else if (style == G4ViewParameters::nurbs) {
463    createRadioAction(polyhedron,nurbs,SLOT(toggleRepresentation(bool)),2);
464  } else {
465    mRepresentation->clear();
466  }
467
468  // INIT mProjection
469  if (fVP.GetFieldHalfAngle() == 0) {
470    createRadioAction(ortho, perspective,SLOT(toggleProjection(bool)),1);
471  } else {
472    createRadioAction(ortho, perspective,SLOT(toggleProjection(bool)),2);
473  }
474
475#if QT_VERSION < 0x040000
476  // === Drawing Menu ===
477  QPopupMenu *mDrawing = new QPopupMenu(fContextMenu);
478  fContextMenu->insertItem("&Drawing",mDrawing);
479
480  fDrawingWireframe = new QPopupMenu(mDrawing);
481  mDrawing->insertItem("&Wireframe",fDrawingWireframe);
482
483  mDrawing->setCheckable(true);
484  fDrawingWireframe->setCheckable(true);
485
486  fDrawingLineRemoval = new QPopupMenu(mDrawing);
487  mDrawing->insertItem("&Hidden line removal",fDrawingLineRemoval);
488  fDrawingLineRemoval->setCheckable(true);
489
490  fDrawingSurfaceRemoval = new QPopupMenu(mDrawing);
491  mDrawing->insertItem("&Hidden surface removal",fDrawingSurfaceRemoval);
492  fDrawingSurfaceRemoval->setCheckable(true);
493
494  fDrawingLineSurfaceRemoval = new QPopupMenu(mDrawing);
495  mDrawing->insertItem("&Hidden line and surface removal",fDrawingLineSurfaceRemoval);
496  fDrawingLineSurfaceRemoval->setCheckable(true);
497
498#else
499  // === Drawing Menu ===
500  QMenu *mDrawing = mStyle->addMenu("&Drawing");
501
502  fDrawingWireframe = mDrawing->addAction("Wireframe");
503  fDrawingWireframe->setCheckable(true);
504
505  fDrawingLineRemoval = mDrawing->addAction("Hidden line removal");
506  fDrawingLineRemoval->setCheckable(true);
507
508  fDrawingSurfaceRemoval = mDrawing->addAction("Hidden Surface removal");
509  fDrawingSurfaceRemoval->setCheckable(true);
510
511  fDrawingLineSurfaceRemoval = mDrawing->addAction("Hidden line and surface removal");
512  fDrawingLineSurfaceRemoval->setCheckable(true);
513#endif
514  // INIT Drawing
515  G4ViewParameters::DrawingStyle d_style;
516  d_style = fVP.GetDrawingStyle();
517 
518#if QT_VERSION < 0x040000
519  if (d_style == G4ViewParameters::wireframe) {
520    fDrawingWireframe->setItemChecked(0,true);
521  } else if (d_style == G4ViewParameters::hlr) {
522    fDrawingLineRemoval->setItemChecked(0,true);
523  } else if (d_style == G4ViewParameters::hsr) {
524    fDrawingSurfaceRemoval->setItemChecked(0,true);
525  } else if (d_style == G4ViewParameters::hlhsr) {
526    fDrawingLineSurfaceRemoval->setItemChecked(0,true);
527  } else {
528    mDrawing->clear();
529  }
530#ifdef GEANT4_QT_DEBUG
531  printf("G4OpenGLQtViewer:: fDrawingWireframe 1\n");
532#endif
533  QObject ::connect(fDrawingWireframe,
534                    SIGNAL(activated(int)),
535                    this,
536                    SLOT(actionDrawingWireframe()));
537#ifdef GEANT4_QT_DEBUG
538  printf("G4OpenGLQtViewer:: fDrawingWireframe 2\n");
539#endif
540  QObject ::connect(fDrawingLineRemoval,
541                    SIGNAL(activated(int)),
542                    this,
543                    SLOT(actionDrawingLineRemoval()));
544  QObject ::connect(fDrawingSurfaceRemoval,
545                    SIGNAL(activated(int)),
546                    this,
547                    SLOT(actionDrawingSurfaceRemoval()));
548  QObject ::connect(fDrawingLineSurfaceRemoval,
549                    SIGNAL(activated(int)),
550                    this,
551                    SLOT(actionDrawingLineSurfaceRemoval()));
552#else
553  if (d_style == G4ViewParameters::wireframe) {
554    fDrawingWireframe->setChecked(true);
555  } else if (d_style == G4ViewParameters::hlr) {
556    fDrawingLineRemoval->setChecked(true);
557  } else if (d_style == G4ViewParameters::hsr) {
558    fDrawingSurfaceRemoval->setChecked(true);
559  } else if (d_style == G4ViewParameters::hlhsr) {
560    fDrawingLineSurfaceRemoval->setChecked(true);
561  } else {
562    mDrawing->clear();
563  }
564  QObject ::connect(fDrawingWireframe,
565                    SIGNAL(triggered(bool)),
566                    this,
567                    SLOT(actionDrawingWireframe()));
568  QObject ::connect(fDrawingLineRemoval,
569                    SIGNAL(triggered(bool)),
570                    this,
571                    SLOT(actionDrawingLineRemoval()));
572  QObject ::connect(fDrawingSurfaceRemoval,
573                    SIGNAL(triggered(bool)),
574                    this,
575                    SLOT(actionDrawingSurfaceRemoval()));
576  QObject ::connect(fDrawingLineSurfaceRemoval,
577                    SIGNAL(triggered(bool)),
578                    this,
579                    SLOT(actionDrawingLineSurfaceRemoval()));
580#endif
581
582
583
584#if QT_VERSION < 0x040000
585  QPopupMenu *mBackground = new QPopupMenu(mStyle);
586  mStyle->insertItem("&Background color",mBackground);
587
588#if QT_VERSION < 0x030200
589  QAction *white = new QAction("&White","&White",CTRL+Key_W,mBackground);
590  QAction *black =  new QAction("&Black","&Black",CTRL+Key_B,mBackground);
591#else
592  QAction *white = new QAction("&White",CTRL+Key_W,mBackground);
593  QAction *black =  new QAction("&Black",CTRL+Key_B,mBackground);
594#endif
595  white->addTo(mBackground);
596  black->addTo(mBackground);
597
598#else
599  QMenu *mBackground = mStyle->addMenu("&Background color");
600  QAction *white = mBackground->addAction("White");
601  QAction *black = mBackground->addAction("Black");
602
603#endif
604  if (background.GetRed() == 1. &&
605      background.GetGreen() == 1. &&
606      background.GetBlue() == 1.) {
607    createRadioAction(white,black,SLOT(toggleBackground(bool)),1);
608  } else {
609    createRadioAction(white,black,SLOT(toggleBackground(bool)),2);
610  }
611
612
613#if QT_VERSION < 0x040000
614  // === Action Menu ===
615  QPopupMenu *mActions = new QPopupMenu(fContextMenu);
616  fContextMenu->insertItem("&Actions",mActions);
617
618#if QT_VERSION < 0x030200
619  QAction *createEPS =  new QAction("&Save as ...","&Save as ...",CTRL+Key_S,mActions);
620#else
621  QAction *createEPS =  new QAction("&Save as ...",CTRL+Key_S,mActions);
622#endif
623  createEPS->addTo(mActions);
624  QObject ::connect(createEPS,
625                    SIGNAL(activated()),
626                    this,
627                    SLOT(actionCreateEPS()));
628
629#else
630  // === Action Menu ===
631  QMenu *mActions = fContextMenu->addMenu("&Actions");
632  QAction *createEPS = mActions->addAction("Save as ...");
633  QObject ::connect(createEPS,
634                    SIGNAL(triggered()),
635                    this,
636                    SLOT(actionCreateEPS()));
637#endif
638
639
640
641#if QT_VERSION < 0x040000
642  // === Special Menu ===
643  QPopupMenu *mSpecial = new QPopupMenu(fContextMenu);
644  fContextMenu->insertItem("S&pecial",mSpecial);
645
646  QPopupMenu *mTransparency = new QPopupMenu(mSpecial);
647  mSpecial->insertItem("Transparency",mTransparency);
648
649#if QT_VERSION < 0x030200
650  QAction *transparencyOn = new QAction("&On","&On",CTRL+Key_O,mTransparency);
651  QAction *transparencyOff = new QAction("&Off","&Off",CTRL+Key_F,mTransparency);
652#else
653  QAction *transparencyOn = new QAction("&On",CTRL+Key_O,mTransparency);
654  QAction *transparencyOff = new QAction("&Off",CTRL+Key_F,mTransparency);
655#endif
656  transparencyOn->addTo(mTransparency);
657  transparencyOff->addTo(mTransparency);
658
659#else
660  // === Special Menu ===
661  QMenu *mSpecial = fContextMenu->addMenu("S&pecial");
662  QMenu *mTransparency = mSpecial->addMenu("Transparency");
663  QAction *transparencyOn = mTransparency->addAction("On");
664  QAction *transparencyOff = mTransparency->addAction("Off");
665#endif
666
667  if (transparency_enabled == false) {
668    createRadioAction(transparencyOn,transparencyOff,SLOT(toggleTransparency(bool)),2);
669  } else if (transparency_enabled == true) {
670    createRadioAction(transparencyOn,transparencyOff,SLOT(toggleTransparency(bool)),1);
671  } else {
672    mSpecial->clear();
673  }
674
675
676#if QT_VERSION < 0x040000
677  QPopupMenu *mAntialiasing = new QPopupMenu(mSpecial);
678  mSpecial->insertItem("Antialiasing",mAntialiasing);
679
680#if QT_VERSION < 0x030200
681  QAction *antialiasingOn = new QAction("&On","&On",CTRL+Key_O,mAntialiasing);
682  QAction *antialiasingOff = new QAction("&Off","&Off",CTRL+Key_F,mAntialiasing);
683#else
684  QAction *antialiasingOn = new QAction("&On",CTRL+Key_O,mAntialiasing);
685  QAction *antialiasingOff = new QAction("&Off",CTRL+Key_F,mAntialiasing);
686#endif
687  antialiasingOn->addTo(mAntialiasing);
688  antialiasingOff->addTo(mAntialiasing);
689
690#else
691  QMenu *mAntialiasing = mSpecial->addMenu("Antialiasing");
692  QAction *antialiasingOn = mAntialiasing->addAction("On");
693  QAction *antialiasingOff = mAntialiasing->addAction("Off");
694#endif
695
696  if (antialiasing_enabled == false) {
697    createRadioAction(antialiasingOn,antialiasingOff,SLOT(toggleAntialiasing(bool)),2);
698  } else if (antialiasing_enabled == true) {
699    createRadioAction(antialiasingOn,antialiasingOff,SLOT(toggleAntialiasing(bool)),1);
700  } else {
701    mAntialiasing->clear();
702  }
703
704#if QT_VERSION < 0x040000
705  QPopupMenu *mHaloing = new QPopupMenu(mSpecial);
706  mSpecial->insertItem("Haloing",mHaloing);
707
708#if QT_VERSION < 0x030200
709  QAction *haloingOn = new QAction("&On","&On",CTRL+Key_O,mHaloing);
710  QAction *haloingOff = new QAction("&Off","&Off",CTRL+Key_F,mHaloing);
711#else
712  QAction *haloingOn = new QAction("&On",CTRL+Key_O,mHaloing);
713  QAction *haloingOff = new QAction("&Off",CTRL+Key_F,mHaloing);
714#endif
715  haloingOn->addTo(mHaloing);
716  haloingOff->addTo(mHaloing);
717#else
718  QMenu *mHaloing = mSpecial->addMenu("Haloing");
719  QAction *haloingOn = mHaloing->addAction("On");
720  QAction *haloingOff = mHaloing->addAction("Off");
721#endif
722  if (haloing_enabled == false) {
723    createRadioAction(haloingOn,haloingOff,SLOT(toggleHaloing(bool)),2);
724  } else if (haloing_enabled == true) {
725    createRadioAction(haloingOn,haloingOff,SLOT(toggleHaloing(bool)),1);
726  } else {
727    mHaloing->clear();
728  }
729
730#if QT_VERSION < 0x040000
731  QPopupMenu *mAux = new QPopupMenu(mSpecial);
732  mSpecial->insertItem("Auxiliairy edges",mAux);
733
734#if QT_VERSION < 0x030200
735  QAction *auxOn = new QAction("&On","&On",CTRL+Key_O,mAux);
736  QAction *auxOff = new QAction("&Off","&Off",CTRL+Key_F,mAux);
737#else
738  QAction *auxOn = new QAction("&On",CTRL+Key_O,mAux);
739  QAction *auxOff = new QAction("&Off",CTRL+Key_F,mAux);
740#endif
741  auxOn->addTo(mAux);
742  auxOff->addTo(mAux);
743
744#else
745  QMenu *mAux = mSpecial->addMenu("Auxiliary edges");
746  QAction *auxOn = mAux->addAction("On");
747  QAction *auxOff = mAux->addAction("Off");
748#endif
749  if (!fVP.IsAuxEdgeVisible()) {
750    createRadioAction(auxOn,auxOff,SLOT(toggleAux(bool)),1);
751  } else {
752    createRadioAction(auxOn,auxOff,SLOT(toggleAux(bool)),2);
753  }
754
755
756#if QT_VERSION >= 0x030200
757#if QT_VERSION < 0x040000
758  QPopupMenu *mFullScreen = new QPopupMenu(mSpecial);
759  mSpecial->insertItem("Full screen",mFullScreen);
760
761  QAction *fullOn = new QAction("&On",CTRL+Key_O,mFullScreen);
762  QAction *fullOff = new QAction("&Off",CTRL+Key_F,mFullScreen);
763  fullOn->addTo(mFullScreen);
764  fullOff->addTo(mFullScreen);
765#else
766  QMenu *mFullScreen = mSpecial->addMenu("Full screen");
767  QAction *fullOn = mFullScreen->addAction("On");
768  QAction *fullOff = mFullScreen->addAction("Off");
769#endif
770  createRadioAction(fullOn,fullOff,SLOT(toggleFullScreen(bool)),2);
771#endif
772
773}
774
775void G4OpenGLQtViewer::manageContextMenuEvent(QContextMenuEvent *e)
776{
777  if (!GLWindow) {
778    G4cerr << "Visualization window not defined, please choose one before\n" << G4endl;
779  } else {
780 
781    if (!fContextMenu)
782      createPopupMenu();
783   
784    // launch menu
785    if ( fContextMenu ) {
786      fContextMenu->exec( e->globalPos() );
787      //    delete fContextMenu;
788    }
789  }
790  e->accept();
791}
792
793
794/**
795   Create a radio button menu. The two menu will be connected. When click on one,
796   eatch state will be invert and callback method will be called.
797   @param action1 first action to connect
798   @param action2 second action to connect
799   @param method callback method
800   @param nCheck: 1 : first action will be set true. 2 : second action will be set true
801*/
802#if QT_VERSION < 0x040000
803void G4OpenGLQtViewer::createRadioAction(QAction *action1,QAction *action2, const std::string& method,unsigned int nCheck) {
804
805  if (action1->parent()->inherits("QPopupMenu")){
806    ((QPopupMenu*)action1->parent())->setCheckable(true);
807  }
808  ((QPopupMenu*)action1->parent())->setItemChecked(0,true);
809  ((QPopupMenu*)action1->parent())->setItemChecked(1,true);
810
811  if (nCheck ==1)
812    ((QPopupMenu*)action1->parent())->setItemChecked(0,true);
813  else
814    ((QPopupMenu*)action1->parent())->setItemChecked(1,true);
815   
816  //FIXME : Should not work on Qt3
817  QObject ::connect(action1, SIGNAL(activated()),action2, SLOT(toggle()));
818  QObject ::connect(action2, SIGNAL(activated()),action1, SLOT(toggle()));
819
820  QObject ::connect(action1, SIGNAL(toggled(bool)),this, method.c_str());
821}
822
823#else
824void G4OpenGLQtViewer::createRadioAction(QAction *action1,QAction *action2, const std::string& method,unsigned int nCheck) {
825
826  action1->setCheckable(true);
827  action2->setCheckable(true);
828
829  if (nCheck ==1)
830    action1->setChecked (true);
831  else
832    action2->setChecked (true);
833   
834  QObject ::connect(action1, SIGNAL(triggered(bool)),action2, SLOT(toggle()));
835  QObject ::connect(action2, SIGNAL(triggered(bool)),action1, SLOT(toggle()));
836
837  QObject ::connect(action1, SIGNAL(toggled(bool)),this, method.c_str());
838
839}
840#endif
841
842/**
843   Slot activate when mouseAction->rotate menu is set
844 */
845void G4OpenGLQtViewer::actionMouseRotate() {
846  emit toggleMouseAction(STYLE1);
847}
848
849/**
850   Slot activate when mouseAction->move menu is set
851 */
852void G4OpenGLQtViewer::actionMouseMove() {
853  emit toggleMouseAction(STYLE2);
854}
855
856/**
857   Slot activate when mouseAction->pick menu is set
858 */
859void G4OpenGLQtViewer::actionMouseZoom() {
860#ifdef GEANT4_QT_DEBUG
861  printf("G4OpenGLQtViewer::actionMouseZoom \n");
862#endif
863  emit toggleMouseAction(STYLE3);
864}
865
866/**
867   Slot activate when mouseAction->zoom menu is set
868 */
869void G4OpenGLQtViewer::actionMousePick() {
870#ifdef GEANT4_QT_DEBUG
871  printf("G4OpenGLQtViewer::actionMousePick \n");
872#endif
873  emit toggleMouseAction(STYLE4);
874}
875
876/**
877   Slot activate when drawing->wireframe menu is set
878 */
879void G4OpenGLQtViewer::actionDrawingWireframe() {
880  emit toggleDrawingAction(1);
881}
882
883/**
884   Slot activate when drawing->line removal menu is set
885 */
886void G4OpenGLQtViewer::actionDrawingLineRemoval() {
887  emit toggleDrawingAction(2);
888}
889
890/**
891   Slot activate when drawing->surface removal menu is set
892 */
893void G4OpenGLQtViewer::actionDrawingSurfaceRemoval() {
894  emit toggleDrawingAction(3);
895}
896
897/**
898   Slot activate when drawing->wireframe menu is set
899 */
900void G4OpenGLQtViewer::actionDrawingLineSurfaceRemoval() {
901  emit toggleDrawingAction(4);
902}
903
904
905/**
906   Slot activated when mouse action is toggle
907   @param aAction : STYLE1, STYLE2, STYLE3
908 */
909void G4OpenGLQtViewer::toggleMouseAction(mouseActions aAction) {
910 
911  if (aAction == STYLE1) {
912    G4cout << "Clic and move mouse to rotate Volume \n" << G4endl;
913    G4cout << "Press left/right arrows to move camera left/right\n" << G4endl;
914    G4cout << "Press up/down arrows to move camera up/down\n" << G4endl;
915    G4cout << "Press SHIFT+up/down arrows to move camera toward/forward\n" << G4endl;
916    G4cout << "Press +/- to zoom into volume\n" << G4endl;
917#if QT_VERSION < 0x040000
918    fMouseRotate->setItemChecked (0,true);
919    fMouseMove->setItemChecked (0,false);
920    fMouseZoom->setItemChecked (0,false);
921    fMousePick->setItemChecked (0,false);
922#else
923    fMouseRotate->setChecked (true);
924    fMouseMove->setChecked (false);
925    fMouseZoom->setChecked (false);
926    fMousePick->setChecked (false);
927#endif
928    fMouseAction = STYLE1;
929    fVP.SetPicking(false);
930  } else  if (aAction == STYLE2) {
931    G4cout << "Clic and move mouse to move Volume \n" << G4endl;
932#if QT_VERSION < 0x040000
933    fMouseRotate->setItemChecked (0,false);
934    fMouseMove->setItemChecked (0,true);
935    fMouseZoom->setItemChecked (0,false);
936    fMousePick->setItemChecked (0,false);
937#else
938    fMouseRotate->setChecked (false);
939    fMouseMove->setChecked (true);
940    fMouseZoom->setChecked (false);
941    fMousePick->setChecked (false);
942#endif
943    fMouseAction = STYLE2;
944    fVP.SetPicking(false);
945  } else  if (aAction == STYLE3) {
946    G4cout << "Clic and move mouse to rotate Volume \n" << G4endl;
947#if QT_VERSION < 0x040000
948    fMouseRotate->setItemChecked (0,false);
949    fMouseMove->setItemChecked (0,false);
950    fMouseZoom->setItemChecked (0,true);
951    fMousePick->setItemChecked (0,false);
952#else
953    fMouseRotate->setChecked (false);
954    fMouseMove->setChecked (false);
955    fMouseZoom->setChecked (true);
956    fMousePick->setChecked (false);
957#endif
958    fMouseAction = STYLE3;
959    fVP.SetPicking(false);
960  } else  if (aAction == STYLE4) {
961#if QT_VERSION < 0x040000
962    fMouseRotate->setItemChecked (0,false);
963    fMouseMove->setItemChecked (0,false);
964    fMouseZoom->setItemChecked (0,false);
965    fMousePick->setItemChecked (0,true);
966#else
967    fMouseRotate->setChecked (false);
968    fMouseMove->setChecked (false);
969    fMouseZoom->setChecked (false);
970    fMousePick->setChecked (true);
971#endif
972    fVP.SetPicking(true);
973    fMouseAction = STYLE4;
974  }
975
976}
977/**
978   Slot activated when drawing menu is toggle
979   Warning : When G4OpenGLStoredQtViewer::DrawView() method call,
980   KernelVisitDecision () will be call and will set the fNeedKernelVisit
981   to 1. See G4XXXStoredViewer::CompareForKernelVisit for explanations.
982   It will cause a redraw of the view
983   @param aAction : 1 wireframe, 2 line removal, 3 surface removal, 4 line & surface removal
984   @see G4OpenGLStoredQtViewer::DrawView
985   @see G4XXXStoredViewer::CompareForKernelVisit
986 */
987void G4OpenGLQtViewer::toggleDrawingAction(int aAction) {
988
989  G4ViewParameters::DrawingStyle d_style;
990 
991
992  if (aAction ==1) {
993#if QT_VERSION < 0x040000
994    fDrawingWireframe->setItemChecked (0,true);
995    fDrawingLineRemoval->setItemChecked (0,false);
996    fDrawingSurfaceRemoval->setItemChecked (0,false);
997    fDrawingLineSurfaceRemoval->setItemChecked (0,false);
998#else
999    fDrawingWireframe->setChecked (true);
1000    fDrawingLineRemoval->setChecked (false);
1001    fDrawingSurfaceRemoval->setChecked (false);
1002    fDrawingLineSurfaceRemoval->setChecked (false);
1003#endif
1004
1005    d_style = G4ViewParameters::wireframe;
1006
1007  } else  if (aAction ==2) {
1008#if QT_VERSION < 0x040000
1009    fDrawingWireframe->setItemChecked (0,false);
1010    fDrawingLineRemoval->setItemChecked (0,true);
1011    fDrawingSurfaceRemoval->setItemChecked (0,false);
1012    fDrawingLineSurfaceRemoval->setItemChecked (0,false);
1013#else
1014    fDrawingWireframe->setChecked (false);
1015    fDrawingLineRemoval->setChecked (true);
1016    fDrawingSurfaceRemoval->setChecked (false);
1017    fDrawingLineSurfaceRemoval->setChecked (false);
1018#endif
1019
1020    d_style = G4ViewParameters::hlr;
1021
1022  } else  if (aAction ==3) {
1023#if QT_VERSION < 0x040000
1024    fDrawingWireframe->setItemChecked (0,false);
1025    fDrawingLineRemoval->setItemChecked (0,false);
1026    fDrawingSurfaceRemoval->setItemChecked (0,true);
1027    fDrawingLineSurfaceRemoval->setItemChecked (0,false);
1028#else
1029    fDrawingWireframe->setChecked (false);
1030    fDrawingLineRemoval->setChecked (false);
1031    fDrawingSurfaceRemoval->setChecked (true);
1032    fDrawingLineSurfaceRemoval->setChecked (false);
1033#endif
1034
1035    d_style = G4ViewParameters::hsr;
1036
1037  } else  if (aAction ==4) {
1038#if QT_VERSION < 0x040000
1039    fDrawingWireframe->setItemChecked (0,false);
1040    fDrawingLineRemoval->setItemChecked (0,false);
1041    fDrawingSurfaceRemoval->setItemChecked (0,false);
1042    fDrawingLineSurfaceRemoval->setItemChecked (0,true);
1043#else
1044    fDrawingWireframe->setChecked (false);
1045    fDrawingLineRemoval->setChecked (false);
1046    fDrawingSurfaceRemoval->setChecked (false);
1047    fDrawingLineSurfaceRemoval->setChecked (true);
1048#endif
1049    d_style = G4ViewParameters::hlhsr;
1050  }
1051  fVP.SetDrawingStyle(d_style);
1052
1053  updateQWidget();
1054#ifdef GEANT4_QT_DEBUG
1055  printf("G4OpenGLQtViewer::toggleDrawingAction\n");
1056#endif
1057}
1058
1059
1060/**
1061   SLOT Activate by a click on the representation menu
1062   Warning : When G4OpenGLStoredQtViewer::DrawView() method call,
1063   KernelVisitDecision () will be call and will set the fNeedKernelVisit
1064   to 1. See G4XXXStoredViewer::CompareForKernelVisit for explanations.
1065   It will cause a redraw of the view
1066   @param check : 1 polyhedron, 0 nurbs
1067   @see G4OpenGLStoredQtViewer::DrawView
1068   @see G4XXXStoredViewer::CompareForKernelVisit
1069*/
1070void G4OpenGLQtViewer::toggleRepresentation(bool check) {
1071
1072  G4ViewParameters::RepStyle style;
1073  if (check == 1) {
1074    style = G4ViewParameters::polyhedron;
1075  } else {
1076    style = G4ViewParameters::nurbs;
1077  }
1078  fVP.SetRepStyle (style);
1079
1080  updateQWidget();
1081}
1082
1083/**
1084   SLOT Activate by a click on the projection menu
1085   Warning : When G4OpenGLStoredQtViewer::DrawView() method call,
1086   KernelVisitDecision () will be call and will set the fNeedKernelVisit
1087   to 1. See G4XXXStoredViewer::CompareForKernelVisit for explanations.
1088   It will cause a redraw of the view
1089   @param check : 1 orthographic, 2 perspective
1090   @see G4OpenGLStoredQtViewer::DrawView
1091   @see G4XXXStoredViewer::CompareForKernelVisit
1092*/
1093void G4OpenGLQtViewer::toggleProjection(bool check) {
1094
1095  if (check == 1) {
1096    fVP.SetFieldHalfAngle (0);
1097  } else {
1098
1099    // look for the default parameter hidden in G4UIcommand parameters
1100    G4UImanager* UI = G4UImanager::GetUIpointer();
1101    if(UI==NULL)
1102      return;
1103    G4UIcommandTree * treeTop = UI->GetTree();
1104
1105    // find command
1106    G4UIcommand* command = treeTop->FindPath("/vis/viewer/set/projection");
1107    if (!command)
1108      return;
1109
1110    // find param
1111    G4UIparameter * angleParam = NULL;
1112    for(G4int i=0;  i<command->GetParameterEntries(); i++)
1113    {
1114      if( command->GetParameter(i)->GetParameterName() == "field-half-angle" ) {
1115        angleParam = command->GetParameter(i);
1116      }
1117    }
1118    if (!angleParam)
1119      return;
1120
1121    // find unit
1122    G4UIparameter * unitParam = NULL;
1123    for(G4int i=0;  i<command->GetParameterEntries(); i++)
1124    {
1125      if( command->GetParameter(i)->GetParameterName() == "unit" ) {
1126        unitParam = command->GetParameter(i);
1127      }
1128    }
1129    if (!unitParam)
1130      return;
1131
1132    G4double defaultValue = command->ConvertToDouble(angleParam->GetDefaultValue())
1133                            * G4UnitDefinition::GetValueOf(unitParam->GetDefaultValue());
1134    if (defaultValue > 89.5 || defaultValue <= 0.0) {
1135      G4cerr << "Field half angle should be 0 < angle <= 89.5 degrees. Check your default Field half angle parameter\n";
1136    } else {
1137      G4cout << "Perspective view has been set to default value. Field half angle="<<angleParam->GetDefaultValue() <<" \n" << G4endl;
1138      fVP.SetFieldHalfAngle (defaultValue);
1139      SetView ();
1140    }
1141  } 
1142  updateQWidget();
1143}
1144
1145
1146/**
1147   SLOT Activate by a click on the background menu
1148@param check : 1 white, 0 black
1149*/
1150void G4OpenGLQtViewer::toggleBackground(bool check) {
1151
1152  //   //I need to revisit the kernel if the background colour changes and
1153  //   //hidden line removal is enabled, because hlr drawing utilises the
1154  //   //background colour in its drawing...
1155  //   // (Note added by JA 13/9/2005) Background now handled in view
1156  //   // parameters.  A kernel visit is triggered on change of background.
1157  if (check == 1) {
1158    ((G4ViewParameters&)this->GetViewParameters()).
1159      SetBackgroundColour(G4Colour(1.,1.,1.));  // White
1160  } else {
1161    ((G4ViewParameters&)this->GetViewParameters()).
1162      SetBackgroundColour(G4Colour(0.,0.,0.));  // Black
1163  }
1164  updateQWidget();
1165}
1166
1167/**
1168   SLOT Activate by a click on the transparency menu
1169@param check : 1 , 0
1170*/
1171void G4OpenGLQtViewer::toggleTransparency(bool check) {
1172 
1173  if (check) {
1174    transparency_enabled = false;
1175  } else {
1176    transparency_enabled = true;
1177  }
1178  SetNeedKernelVisit (true);
1179  updateQWidget();
1180}
1181
1182/**
1183   SLOT Activate by a click on the antialiasing menu
1184@param check : 1 , 0
1185*/
1186void G4OpenGLQtViewer::toggleAntialiasing(bool check) {
1187
1188  if (!check) {
1189    antialiasing_enabled = false;
1190    glDisable (GL_LINE_SMOOTH);
1191    glDisable (GL_POLYGON_SMOOTH);
1192  } else {
1193    antialiasing_enabled = true;
1194    glEnable (GL_LINE_SMOOTH);
1195    glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);
1196    glEnable (GL_POLYGON_SMOOTH);
1197    glHint (GL_POLYGON_SMOOTH_HINT, GL_NICEST);
1198  }
1199
1200  updateQWidget();
1201}
1202
1203/**
1204   SLOT Activate by a click on the haloing menu
1205@param check : 1 , 0
1206*/
1207//FIXME : I SEE NOTHING...
1208void G4OpenGLQtViewer::toggleHaloing(bool check) {
1209  if (check) {
1210    haloing_enabled = false;
1211  } else {
1212    haloing_enabled = true;
1213  }
1214
1215  updateQWidget();
1216
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}
1233
1234/**
1235   SLOT Activate by a click on the full screen menu
1236@param check : 1 , 0
1237*/
1238void G4OpenGLQtViewer::toggleFullScreen(bool check) {
1239#if QT_VERSION >= 0x030200
1240  GLWindow->setWindowState(GLWindow->windowState() ^ Qt::WindowFullScreen);
1241#else
1242  G4cerr << "This version of G4UI Could not generate the selected format\n" << G4endl;
1243#endif
1244}
1245
1246void G4OpenGLQtViewer::actionCreateEPS() {
1247  QString filters;
1248#if QT_VERSION < 0x040000
1249  QStrList listFormat=QImageIO::outputFormats();
1250  char *tmp=listFormat.first();
1251  while (tmp!=0) {
1252    filters += QString(tmp) + ";;";
1253    tmp=listFormat.next();
1254  }
1255#else
1256  QList<QByteArray> formats =  QImageWriter::supportedImageFormats ();
1257  for (int i = 0; i < formats.size(); ++i) {
1258    filters +=formats.at(i) + ";;";
1259  }
1260#endif
1261  filters += "eps;;";
1262  filters += "ps;;";
1263  filters += "pdf";
1264  QString* selectedFormat = new QString();
1265#if QT_VERSION < 0x040000
1266  QString nomFich =  QFileDialog::getSaveFileName ( ".",
1267                                                    filters,
1268                                                    GLWindow,
1269                                                    "Save file dialog",
1270                                                    tr("Save as ..."),
1271                                                    selectedFormat );
1272#else
1273  QString nomFich =  QFileDialog::getSaveFileName ( GLWindow,
1274                                                    tr("Save as ..."),
1275                                                    ".",
1276                                                    filters,
1277                                                    selectedFormat );
1278#endif
1279  // bmp jpg jpeg png ppm xbm xpm
1280  if (nomFich == "") {
1281    return;
1282  }
1283#if QT_VERSION < 0x040000
1284  nomFich += "."+QString(selectedFormat->ascii());
1285  QString format = selectedFormat->lower();
1286#else
1287  nomFich += "."+QString(selectedFormat->toStdString().c_str());
1288  QString format = selectedFormat->toLower();
1289#endif
1290  G4OpenGLQtExportDialog* exportDialog= new G4OpenGLQtExportDialog(GLWindow,format,fWindow->height(),fWindow->width());
1291  if(  exportDialog->exec()) {
1292
1293    QImage image;
1294    bool res = false;
1295    if ((exportDialog->getWidth() !=fWindow->width()) ||
1296        (exportDialog->getHeight() !=fWindow->height())) {
1297      if (format != QString("eps")) {
1298      G4cerr << "Export->Change Size : This function is not implemented, to export in another size, please resize your frame to what you need\n" << G4endl;
1299     
1300      //    rescaleImage(exportDialog->getWidth(),exportDialog->getHeight());// re-scale image
1301      //      QGLWidget* glResized = fWindow;
1302
1303      // FIXME :
1304      // L.Garnier : I've try to implement change size function, but the problem is
1305      // the renderPixmap function call the QGLWidget to resize and it doesn't draw
1306      // the content of this widget... It only draw the background.
1307
1308      //      fWindow->renderPixmap (exportDialog->getWidth()*2,exportDialog->getHeight()*2,true );
1309
1310      //      QPixmap pixmap = fWindow->renderPixmap ();
1311     
1312      //      image = pixmap->toImage();
1313      //      glResized->resize(exportDialog->getWidth()*2,exportDialog->getHeight()*2);
1314      //      image = glResized->grabFrameBuffer();
1315      }     
1316    } else {
1317      image = fWindow->grabFrameBuffer();
1318    }   
1319    if (format == QString("eps")) {
1320      if (exportDialog->getVectorEPS()) {
1321        res = generateVectorEPS(nomFich,exportDialog->getWidth(),exportDialog->getHeight(),image);
1322      } else {
1323        res = generateEPS(nomFich,exportDialog->getNbColor(),image);
1324      }
1325    } else if ((format == "ps") || (format == "pdf")) {
1326      res = generatePS_PDF(nomFich,exportDialog->getNbColor(),image);
1327    } else if ((format == "tif") ||
1328               (format == "tiff") ||
1329               (format == "jpg") ||
1330               (format == "jpeg") ||
1331               (format == "png") ||
1332               (format == "pbm") ||
1333               (format == "pgm") ||
1334               (format == "ppm") ||
1335               (format == "bmp") ||
1336               (format == "xbm") ||
1337               (format == "xpm")) {
1338#if QT_VERSION < 0x040000
1339      res = image.save(nomFich,selectedFormat->ascii(),exportDialog->getSliderValue());
1340#else
1341      res = image.save(nomFich,0,exportDialog->getSliderValue());
1342#endif
1343    } else {
1344      G4cerr << "This version of G4UI Could not generate the selected format\n" << G4endl;
1345    }
1346    if (res == false) {
1347#if QT_VERSION < 0x040000
1348      G4cerr << "Error while saving file... "<<nomFich.ascii()<<"\n" << G4endl;
1349#else
1350      G4cerr << "Error while saving file... "<<nomFich.toStdString().c_str()<<"\n" << G4endl;
1351#endif
1352    } else {
1353#if QT_VERSION < 0x040000
1354      G4cout << "File "<<nomFich.ascii()<<" has been saved \n" << G4endl;
1355#else
1356      G4cout << "File "<<nomFich.toStdString().c_str()<<" has been saved \n" << G4endl;
1357#endif
1358    }
1359   
1360  } else { // cancel selected
1361    return;
1362  }
1363 
1364#ifdef GEANT4_QT_DEBUG
1365  printf("G4OpenGLQtViewer::actionCreateEPS() \n");
1366#endif
1367}
1368
1369/*
1370// 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
1371
1372void Graph::exportToSVG(const QString& fname)
1373{
1374  // enable workaround for Qt3 misalignments
1375  QwtPainter::setSVGMode(true);
1376  QPicture picture;
1377  QPainter p(&picture);
1378  d_plot->print(&p, d_plot->rect());
1379  p.end();
1380
1381  picture.save(fname, "svg");
1382}
1383*/
1384
1385
1386
1387
1388/**
1389   Save the current mouse press point
1390   @param p mouse click point
1391*/
1392void G4OpenGLQtViewer::G4MousePressEvent(QPoint p)
1393{
1394  fLastPos = p;
1395  if (fMouseAction == STYLE4){  // pick
1396    Pick(p.x(),p.y());
1397  }
1398}
1399
1400
1401/**
1402   @param pos_x mouse x position
1403   @param pos_y mouse y position
1404   @param mButtons mouse button active
1405*/
1406
1407#if QT_VERSION < 0x040000
1408void G4OpenGLQtViewer::G4MouseEvent(int pos_x, int pos_y,Qt::ButtonState mButtons)
1409#else
1410void G4OpenGLQtViewer::G4MouseEvent(int pos_x, int pos_y,Qt::MouseButtons mButtons)
1411#endif
1412{
1413  int dx = fLastPos.x() - pos_x;
1414  int dy = fLastPos.y() - pos_y;
1415  if (fMouseAction == STYLE1) {  // rotate
1416    if (mButtons & Qt::LeftButton) {
1417      G4MouseRotateEvent(dx,dy);
1418    }
1419  } else   if (fMouseAction == STYLE2){  // move
1420    if (mButtons & Qt::LeftButton) {
1421      G4MouseMoveEvent(dx,dy,0);
1422    }
1423  } else   if (fMouseAction == STYLE3){  // zoom
1424    if (mButtons & Qt::LeftButton) {
1425      G4cerr << "Zoom not implemented for the moment\n" << G4endl;
1426    }
1427  }
1428  fLastPos = QPoint(pos_x, pos_y);
1429}
1430
1431/**
1432   @param dx delta mouse x position
1433   @param dy delta mouse y position
1434*/
1435
1436void G4OpenGLQtViewer::G4MouseMoveEvent(int dx, int dy, int dz)
1437{
1438  G4Point3D stp
1439    = GetSceneHandler()->GetScene()->GetStandardTargetPoint();
1440 
1441  G4Point3D tp = stp + fVP.GetCurrentTargetPoint ();
1442 
1443  const G4Vector3D& upVector = fVP.GetUpVector ();
1444  const G4Vector3D& vpVector = fVP.GetViewpointDirection ();
1445 
1446  G4Vector3D unitRight = (upVector.cross (vpVector)).unit();
1447  G4Vector3D unitUp    = (vpVector.cross (unitRight)).unit();
1448 
1449#ifdef GEANT4_QT_DEBUG
1450  G4cout << fVP<<G4endl;
1451  printf("Mouse event Target Point : %f %f %f\n",tp.x(),tp.y(),tp.z());
1452  printf("Mouse event upVector : %f %f %f\n",upVector.x(),upVector.y(),upVector.z());
1453  printf("Mouse event vpVector Point : %f %f %f\n",vpVector.x(),vpVector.y(),vpVector.z());
1454  printf("Mouse event unitRight Point : %f %f %f\n",unitRight.x(),unitRight.y(),unitRight.z());
1455  printf("Mouse event unitUp Point : %f %f %f\n",unitUp.x(),unitUp.y(),unitUp.z());
1456#endif
1457  tp += -dx * unitRight + dy * unitUp + dz * vpVector;
1458  fVP.SetCurrentTargetPoint (tp - stp);
1459 
1460  updateQWidget();
1461}
1462
1463
1464/**
1465   @param dx delta mouse x position
1466   @param dy delta mouse y position
1467*/
1468
1469void G4OpenGLQtViewer::G4MouseRotateEvent(int dx, int dy)
1470{
1471  //phi spin stuff here
1472 
1473  G4Vector3D vp = fVP.GetViewpointDirection ().unit ();
1474  G4Vector3D up = fVP.GetUpVector ().unit ();
1475 
1476  G4Vector3D yprime = (up.cross(vp)).unit();
1477  G4Vector3D zprime = (vp.cross(yprime)).unit();
1478 
1479  G4double delta_alpha;
1480  G4double delta_theta;
1481 
1482  if (fVP.GetLightsMoveWithCamera()) {
1483    delta_alpha = dy;
1484    delta_theta = -dx;
1485  } else {
1486    delta_alpha = -dy;
1487    delta_theta = dx;
1488  }   
1489 
1490  delta_alpha *= deg;
1491  delta_theta *= deg;
1492 
1493  G4Vector3D new_vp = std::cos(delta_alpha) * vp + std::sin(delta_alpha) * zprime;
1494 
1495  G4Vector3D new_up;
1496  if (fVP.GetLightsMoveWithCamera()) {
1497    new_up = (new_vp.cross(yprime)).unit();
1498    fVP.SetUpVector(new_up);
1499  } else {
1500    new_up = up;
1501  }
1502  ////////////////
1503  // Rotates by fixed azimuthal angle delta_theta.
1504 
1505  G4double cosalpha = new_up.dot (new_vp.unit());
1506  G4double sinalpha = std::sqrt (1. - std::pow (cosalpha, 2));
1507  yprime = (new_up.cross (new_vp.unit())).unit ();
1508  G4Vector3D xprime = yprime.cross (new_up);
1509  // Projection of vp on plane perpendicular to up...
1510  G4Vector3D a1 = sinalpha * xprime;
1511  // Required new projection...
1512  G4Vector3D a2 =
1513    sinalpha * (std::cos (delta_theta) * xprime + std::sin (delta_theta) * yprime);
1514  // Required Increment vector...
1515  G4Vector3D delta = a2 - a1;
1516  // So new viewpoint is...
1517  G4Vector3D viewPoint = new_vp.unit() + delta;
1518 
1519  fVP.SetViewAndLights (viewPoint);
1520  updateQWidget();
1521 
1522}
1523
1524/** This is the benning of a rescale function. It does nothing for the moment
1525    @param aWidth : new width
1526    @param aHeight : new height
1527*/
1528void G4OpenGLQtViewer::rescaleImage(
1529 int aWidth
1530,int aHeight
1531){
1532#ifdef GEANT4_QT_DEBUG
1533  printf("should rescale \n");
1534#endif
1535  GLfloat* feedback_buffer;
1536  GLint returned;
1537  FILE* file;
1538 
1539//   feedback_buffer = new GLfloat[size];
1540//   glFeedbackBuffer (size, GL_3D_COLOR, feedback_buffer);
1541//   glRenderMode (GL_FEEDBACK);
1542 
1543//   glViewport (0, 0, aWidth, aHeight);
1544//   DrawView();
1545//   returned = glRenderMode (GL_RENDER);
1546
1547}
1548
1549/**
1550   Generate Vectorial Encapsulated Postscript form image
1551   @param aFilename : name of file
1552   @param aInColor : numbers of colors : 1->BW 2->RGB 3->RGB+Alpha
1553   @param aImage : Image to print
1554*/
1555bool G4OpenGLQtViewer::generateVectorEPS (
1556 QString aFilename
1557,int aWidth
1558,int aHeight
1559,QImage aImage
1560)
1561{
1562  // Print vectored PostScript
1563 
1564  G4int size = 5000000;
1565
1566  GLfloat* feedback_buffer;
1567  GLint returned;
1568  FILE* file;
1569 
1570  feedback_buffer = new GLfloat[size];
1571  glFeedbackBuffer (size, GL_3D_COLOR, feedback_buffer);
1572  glRenderMode (GL_FEEDBACK);
1573 
1574  int side = qMin(aWidth, aHeight);
1575  glViewport((aWidth - side) / 2, (aHeight - side) / 2, side, side);
1576  DrawView();
1577
1578  returned = glRenderMode (GL_RENDER);
1579 
1580 
1581#if QT_VERSION < 0x040000
1582  file = fopen (aFilename.ascii(), "w");
1583#else
1584  file = fopen (aFilename.toStdString().c_str(), "w");
1585#endif
1586  if (file) {
1587    spewWireframeEPS (file, returned, feedback_buffer, "rendereps");
1588  } else {
1589#if QT_VERSION < 0x040000
1590    G4cerr << "Could not open "<< aFilename.ascii()<<"\n" << G4endl;
1591#else
1592    G4cerr << "Could not open "<< aFilename.toStdString().c_str()<<"\n" << G4endl;
1593#endif
1594  }
1595 
1596  delete[] feedback_buffer;
1597
1598  return true;
1599}
1600
1601/**
1602   Generate Encapsulated Postscript form image
1603   @param aFilename : name of file
1604   @param aInColor : numbers of colors : 1->BW 2->RGB 3->RGB+Alpha
1605   @param aImage : Image to print
1606*/
1607bool G4OpenGLQtViewer::generateEPS (
1608 QString aFilename
1609,int aInColor
1610,QImage aImage
1611)
1612{
1613  // FIXME
1614#ifdef GEANT4_QT_DEBUG
1615  printf("saving EPS\n");
1616#endif
1617
1618  FILE* fp;
1619
1620  if (aImage.bits () == NULL)
1621    return false;
1622 
1623#if QT_VERSION < 0x040000
1624  fp = fopen (aFilename.ascii(), "w");
1625#else
1626  fp = fopen (aFilename.toStdString().c_str(), "w");
1627#endif
1628  if (fp == NULL) {
1629    return false;
1630  }
1631 
1632  fprintf (fp, "%%!PS-Adobe-2.0 EPSF-1.2\n");
1633#if QT_VERSION < 0x040000
1634  fprintf (fp, "%%%%Title: %s\n", aFilename.ascii());
1635#else
1636  fprintf (fp, "%%%%Title: %s\n", aFilename.toStdString().c_str());
1637#endif
1638  fprintf (fp, "%%%%Creator: OpenGL pixmap render output\n");
1639  fprintf (fp, "%%%%BoundingBox: 0 0 %d %d\n", aImage.width(), aImage.height());
1640  fprintf (fp, "%%%%EndComments\n");
1641  fprintf (fp, "gsave\n");
1642  fprintf (fp, "/bwproc {\n");
1643  fprintf (fp, "    rgbproc\n");
1644  fprintf (fp, "    dup length 3 idiv string 0 3 0 \n");
1645  fprintf (fp, "    5 -1 roll {\n");
1646  fprintf (fp, "    add 2 1 roll 1 sub dup 0 eq\n");
1647  fprintf (fp, "    { pop 3 idiv 3 -1 roll dup 4 -1 roll dup\n");
1648  fprintf (fp, "       3 1 roll 5 -1 roll } put 1 add 3 0 \n");
1649  fprintf (fp, "    { 2 1 roll } ifelse\n");
1650  fprintf (fp, "    }forall\n");
1651  fprintf (fp, "    pop pop pop\n");
1652  fprintf (fp, "} def\n");
1653  fprintf (fp, "systemdict /colorimage known not {\n");
1654  fprintf (fp, "   /colorimage {\n");
1655  fprintf (fp, "       pop\n");
1656  fprintf (fp, "       pop\n");
1657  fprintf (fp, "       /rgbproc exch def\n");
1658  fprintf (fp, "       { bwproc } image\n");
1659  fprintf (fp, "   }  def\n");
1660  fprintf (fp, "} if\n");
1661  fprintf (fp, "/picstr %d string def\n", aImage.width() * aInColor);
1662  fprintf (fp, "%d %d scale\n", aImage.width(), aImage.height());
1663  fprintf (fp, "%d %d %d\n", aImage.width(), aImage.height(), 8);
1664  fprintf (fp, "[%d 0 0 %d 0 0]\n", aImage.width(), aImage.height());
1665  fprintf (fp, "{currentfile picstr readhexstring pop}\n");
1666  fprintf (fp, "false %d\n", aInColor);
1667  fprintf (fp, "colorimage\n");
1668 
1669
1670  int width = aImage.width();
1671  int height = aImage.height();
1672  int depth = aImage.depth();
1673  int size = width*height;
1674 
1675  if (depth == 1)
1676    size = (width+7)/8*height;
1677  else if (aInColor == 1)
1678    size = size*3;
1679 
1680  int i = 0;
1681  //  if ( aInColor ==1 ) {
1682  // FIXME : L. Garnier. For the moment 10 dec 2007, I could not find a way
1683  // to save correctly grayscale Image. I mean that color or grayscale image
1684  // have the same file save size !
1685 
1686  /* } else*/ if (depth == 8) {
1687    for(int y=height-1; y >=0 ; y--) {
1688      const uchar * s = aImage.scanLine(y);
1689      for(int x=0; x <width; x++) {
1690        QRgb rgb = aImage.color(s[x]);
1691        if (aInColor == 1) {
1692          fprintf (fp, " %02hx ",(unsigned char)qGray(rgb));
1693          i++;
1694        } else {
1695          fprintf (fp, " %02hx %02hx %02hx",
1696                   (unsigned char) qRed(rgb),
1697                   (unsigned char) qGreen(rgb),
1698                   (unsigned char) qBlue(rgb));
1699          i += 3;
1700        }
1701      }
1702      fprintf (fp, "\n");
1703    }
1704  } else {
1705#if QT_VERSION < 0x040000
1706    bool alpha = aImage.hasAlphaBuffer();
1707#else
1708    bool alpha = aImage.hasAlphaChannel();
1709    for(int y=height-1; y >=0 ; y--) {
1710      QRgb * s = (QRgb*)(aImage.scanLine(y));
1711      for(int x=0; x <width; x++) {
1712        QRgb rgb = (*s++);
1713        if (alpha && qAlpha(rgb) < 0x40) // 25% alpha, convert to white -
1714          rgb = qRgb(0xff, 0xff, 0xff);
1715        if (aInColor == 1) {
1716          fprintf (fp, " %02hx ",(unsigned char)qGray(rgb));
1717          i++;
1718        } else {
1719          fprintf (fp, " %02hx %02hx %02hx",
1720                   (unsigned char) qRed(rgb),
1721                   (unsigned char) qGreen(rgb),
1722                   (unsigned char) qBlue(rgb));
1723          i += 3;
1724        }
1725      }
1726      fprintf (fp, "\n");
1727    }
1728#endif
1729
1730  }
1731
1732  fprintf (fp, "grestore\n");
1733  fprintf (fp, "showpage\n");
1734  fclose (fp);
1735
1736  return true;
1737}
1738/**
1739   Generate Postscript or PDF form image
1740   @param aFilename : name of file
1741   @param aInColor : numbers of colors : 1->BW 2->RGB
1742   @param aImage : Image to print
1743*/
1744bool G4OpenGLQtViewer::generatePS_PDF (
1745 QString aFilename
1746,int aInColor
1747,QImage aImage
1748)
1749{
1750
1751#if QT_VERSION < 0x040000
1752#ifdef Q_WS_MAC || Q_WS_X11
1753  QPrinter printer;
1754  //  printer.setPageSize(pageSize);
1755  if (aInColor == 1) {
1756    printer.setColorMode(QPrinter::GrayScale);
1757  } else {
1758    printer.setColorMode(QPrinter::Color);
1759  }
1760
1761  /* FIXME : I don't know which format it will save...
1762     if (aFilename.endsWith(".ps")) {
1763     printer.setOutputFormat(QPrinter::PostScriptFormat);
1764     } else {
1765     printer.setOutputFormat(QPrinter::PdfFormat);
1766     }
1767  */
1768  printer.setOutputFileName(aFilename);
1769  //  printer.setFullPage ( true);
1770  QPainter paint(&printer);
1771  paint.drawImage (0,0,aImage );
1772  paint.end();
1773#else
1774  G4cerr << "This fonction is only supported on Mac OsX or X11 with Qt3. Full platform supported with Qt4\n" << G4endl;
1775#endif
1776#else
1777  QPrinter printer;
1778  //  printer.setPageSize(pageSize);
1779
1780  // FIXME : L. Garnier 4/12/07
1781  // This is not working, it does nothing. Image is staying in color mode
1782  // So I have desactivate the B/W button in GUI
1783  if ((!aImage.isGrayscale ()) &&(aInColor ==1 )) {
1784#if QT_VERSION < 0x040000
1785    aImage = aImage.convertDepth(1,Qt::MonoOnly);
1786#else
1787    aImage = aImage.convertToFormat ( aImage.format(), Qt::MonoOnly);
1788#endif
1789  }
1790
1791
1792  if (aFilename.endsWith(".ps")) {
1793#if QT_VERSION > 0x040200
1794    printer.setOutputFormat(QPrinter::PostScriptFormat);
1795#endif
1796  } else {
1797#if QT_VERSION > 0x040100
1798    printer.setOutputFormat(QPrinter::PdfFormat);
1799#endif
1800  }
1801#if QT_VERSION > 0x040100
1802  printer.setOutputFileName(aFilename);
1803#endif
1804  //  printer.setFullPage ( true);
1805  QPainter paint(&printer);
1806  paint.drawImage (0,0,aImage);
1807  paint.end();
1808#endif
1809  return true;
1810}
1811
1812#endif
1813
1814void G4OpenGLQtViewer::G4keyPressEvent (QKeyEvent * event)
1815{
1816  if (holdKeyEvent)
1817    return;
1818
1819  holdKeyEvent = true;
1820
1821  if ((event->key() == Qt::Key_Down) && (event->modifiers() & Qt::ShiftModifier)) // go backward
1822    {
1823      G4MouseMoveEvent(0,0,1);
1824    }
1825  else if ((event->key() == Qt::Key_Up) && (event->modifiers() & Qt::ShiftModifier))  // go forward
1826    {
1827      G4MouseMoveEvent(0,0,-1);
1828    }
1829 else if (event->key() == Qt::Key_Down) // go down
1830    {
1831      G4MouseMoveEvent(0,1,0);
1832    }
1833  else if (event->key() == Qt::Key_Up)  // go up
1834    {
1835      G4MouseMoveEvent(0,-1,0);
1836    }
1837  else if (event->key() == Qt::Key_Left) // go left
1838    {
1839      G4MouseMoveEvent(-1,0,0);
1840    }
1841  else if (event->key() == Qt::Key_Right) // go right
1842    {
1843      G4MouseMoveEvent(1,0,0);
1844    }
1845  else if (event->key() == Qt::Key_Plus) // zoom in
1846    {
1847      fVP.SetZoomFactor(fVP.GetZoomFactor()*fDeltaZoom);
1848      updateQWidget();
1849    }
1850  else if (event->key() == Qt::Key_Minus) // zoom out
1851    {
1852      fVP.SetZoomFactor(fVP.GetZoomFactor()/fDeltaZoom);
1853      updateQWidget();
1854    }
1855  holdKeyEvent = false;
1856}
1857
1858/*
1859 
1860void MultiLayer::exportToSVG(const QString& fname)
1861{
1862  QPicture picture;
1863  QPainter p(&picture);
1864  for (int i=0;i<(int)graphsList->count();i++)
1865    {
1866      Graph *gr=(Graph *)graphsList->at(i);
1867      Plot *myPlot= (Plot *)gr->plotWidget();
1868     
1869      QPoint pos=gr->pos();
1870     
1871      int width=int(myPlot->frameGeometry().width());
1872      int height=int(myPlot->frameGeometry().height());
1873     
1874      myPlot->print(&p, QRect(pos,QSize(width,height)));
1875    }
1876 
1877  p.end();
1878  picture.save(fname, "svg");
1879}
1880*/
1881
Note: See TracBrowser for help on using the repository browser.