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

Last change on this file since 710 was 709, checked in by garnier, 18 years ago

last commit :suppresion du move button dans le menu contextuel, on garde juste le zoom et pick. Improvments for Qt3

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