source: trunk/geant4/visualization/OpenGL/src/G4OpenGLQtMovieDialog.cc @ 733

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

remise a niveau de movie parameters

  • Property svn:mime-type set to text/cpp
File size: 12.2 KB
RevLine 
[730]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: G4OpenGLQtMovieDialog.cc,v 1.6 2008/02/15 10:54:13 lgarnier Exp $
28// GEANT4 tag $Name:  $
29//
30//
31
32#define GEANT4_QT_DEBUG
33#ifdef G4VIS_BUILD_OPENGLQT_DRIVER
34
35#include "G4OpenGLQtMovieDialog.hh"
36#include "G4OpenGLQtViewer.hh"
37
38#include <qpushbutton.h>
[732]39#include <qpalette.h>
[730]40#include <qlabel.h>
[733]41#include <qgroupbox.h>
[730]42#include <qlayout.h>
43#include <qlineedit.h>
44#include <qfiledialog.h>
45#include <qprocess.h>
46
47
48// +---------------------------------------+
49// +        Path for encoder               +
50// +  _______                              +
51// + | select| ____________________        +
52// +  -------                              +
[732]53// +        Temp path                      +
54// +  _______                              +
55// + | select| ____________________        +
56// +  -------                              +
[730]57// +                                       +
58// + max number of frames  ________        +
59// + ....                                  +
60// +                                       +
61// +     Label : X frames Saves/Encoding   +
62// +         Cancel        Encode          +
63// +---------------------------------------+
64
65G4OpenGLQtMovieDialog::G4OpenGLQtMovieDialog(
[731]66 G4OpenGLQtViewer* parentViewer,
67 QWidget* parentWidget
[730]68)
[731]69  : QDialog( parentWidget ),
70    fParentViewer(parentViewer)
[730]71{
72  setModal(false);
73#if QT_VERSION < 0x040000
74  setCaption( tr( " Movie parameters" ));
75#else
76  setWindowTitle( tr( " Movie parameters" ));
77#endif
78
79
80  // global layout
81  QVBoxLayout* globalVLayout = new QVBoxLayout(this);
82  globalVLayout->setMargin(10);
83  globalVLayout->setSpacing(10);
84 
[733]85  // Encoder group box
86  QGroupBox *encoderGroupBox = new QGroupBox(tr("Encoder path"));               
87  QVBoxLayout *encoderVBoxLayout = new QVBoxLayout(encoderGroupBox);
88#ifdef GEANT4_QT_DEBUG
89  printf("1111\n");
[730]90#endif
91
[732]92  // Encoder Path
[733]93  QWidget *encoderHBox = new QWidget(encoderGroupBox);
94  QHBoxLayout *encoderHBoxLayout = new QHBoxLayout(encoderHBox);
95  fEncoderPath = new QLineEdit("",encoderHBox);
[730]96
[733]97  QPushButton *encoderButton = new QPushButton(tr("..."),encoderHBox);
[732]98  encoderButton->setMaximumWidth (30);
[730]99
[733]100  fEncoderStatus = new QLabel(encoderGroupBox);
101  fEncoderStatus->setText("");
102
103#ifdef GEANT4_QT_DEBUG
104  printf("2222\n");
105#endif
[732]106#if QT_VERSION < 0x040000
[733]107  encoderHBoxLayout->add(fEncoderPath);
108  encoderHBoxLayout->add(encoderButton);
109  encoderVBoxLayout->add(fEncoderStatus);
[732]110#else
[733]111  encoderHBoxLayout->addWidget(fEncoderPath);
112  encoderHBoxLayout->addWidget(encoderButton);
113  encoderVBoxLayout->addWidget(fEncoderStatus);
[732]114#endif
[730]115
[733]116#ifdef GEANT4_QT_DEBUG
117  printf("33333\n");
118#endif
[732]119#if QT_VERSION >= 0x040000
[733]120//  encoderHBox->setLayout(encoderHBoxLayout);
121  encoderGroupBox->setLayout(encoderVBoxLayout);
[732]122#endif
[733]123  connect( encoderButton, SIGNAL( clicked( ) ), this, SLOT(selectEncoderPathAction() ) );
124#ifdef GEANT4_QT_DEBUG
125  printf("4444\n");
126#endif
[732]127
[730]128#if QT_VERSION < 0x040000
[733]129  globalVLayout->add(encoderGroupBox);
[730]130#else
[733]131  globalVLayout->addWidget(encoderGroupBox);
[730]132#endif
133
[732]134  fEncoderPath->setText(fParentViewer->getEncoderPath());
[730]135
[732]136
[733]137  // temp folder group box
138  QGroupBox *tempFolderGroupBox = new QGroupBox(tr("Temporary folder path"));           
139  QVBoxLayout *tempFolderVBoxLayout = new QVBoxLayout(tempFolderGroupBox);
140
[732]141  // temp folder Path
[733]142  QWidget *tempFolderHBox = new QWidget(tempFolderGroupBox);
143  QHBoxLayout *tempFolderHBoxLayout = new QHBoxLayout(tempFolderGroupBox);
[732]144
[733]145  fTempFolderPath = new QLineEdit("",tempFolderHBox);
146
147  QPushButton *tempButton = new QPushButton(tr("..."),tempFolderHBox);
148  tempButton->setMaximumWidth (30);
149
150  fTempFolderStatus = new QLabel(tempFolderGroupBox);
151  fTempFolderStatus->setText("");
152
153#ifdef GEANT4_QT_DEBUG
154  printf("5555\n");
155#endif
[730]156#if QT_VERSION < 0x040000
[733]157  tempFolderHBoxLayout->add(fTempFolderPath);
158  tempFolderHBoxLayout->add(tempButton);
159  tempFolderVBoxLayout->add(fTempFolderStatus);
[730]160#else
[733]161  tempFolderHBoxLayout->addWidget(fTempFolderPath);
162  tempFolderHBoxLayout->addWidget(tempButton);
163  tempFolderVBoxLayout->addWidget(fTempFolderStatus);
[730]164#endif
165
[733]166#ifdef GEANT4_QT_DEBUG
167  printf("6666\n");
168#endif
169#if QT_VERSION >= 0x040000
170//  tempFolderHBox->setLayout(tempFolderHBoxLayout);
171  tempFolderGroupBox->setLayout(tempFolderVBoxLayout);
172#endif
173  connect( tempButton, SIGNAL( clicked( ) ), this, SLOT(selectTempPathAction() ) );
[732]174
[733]175#ifdef GEANT4_QT_DEBUG
176  printf("77777\n");
177#endif
[732]178#if QT_VERSION < 0x040000
[733]179  globalVLayout->add(tempFolderGroupBox);
[732]180#else
[733]181  globalVLayout->addWidget(tempFolderGroupBox);
[732]182#endif
183
[733]184  fTempFolderPath->setText(fParentViewer->getTempFolderPath());
185
186  // save file group box
187  QGroupBox *saveFileGroupBox = new QGroupBox(tr("Save as"));           
188  QVBoxLayout *saveFileVBoxLayout = new QVBoxLayout(saveFileGroupBox);
189
190  // save file
191  QWidget *saveFileHBox = new QWidget(saveFileGroupBox);
192  QHBoxLayout *saveFileHBoxLayout = new QHBoxLayout(saveFileHBox);
193
194  fSaveFileName = new QLineEdit("",saveFileHBox);
195
196  QPushButton *saveButton = new QPushButton(tr("..."),saveFileHBox);
197  saveButton->setMaximumWidth (30);
198
199  fSaveFileStatus = new QLabel(saveFileGroupBox);
200  fSaveFileStatus->setText("");
201
202#ifdef GEANT4_QT_DEBUG
203  printf("8888\n");
204#endif
205#if QT_VERSION < 0x040000
206  saveFileHBoxLayout->add(fTempFolderPath);
207  saveFileHBoxLayout->add(saveButton);
208  saveFileVBoxLayout->add(fSaveFileStatus);
209#else
210  saveFileHBoxLayout->addWidget(fTempFolderPath);
211  saveFileHBoxLayout->addWidget(saveButton);
212  saveFileVBoxLayout->addWidget(fSaveFileStatus);
213#endif
214
215#ifdef GEANT4_QT_DEBUG
216  printf("99999\n");
217#endif
[730]218#if QT_VERSION >= 0x040000
[733]219//  saveFileHBox->setLayout(saveFileHBoxLayout);
220  saveFileGroupBox->setLayout(saveFileVBoxLayout);
[730]221#endif
[733]222  connect( saveButton, SIGNAL( clicked( ) ), this, SLOT(selectSaveFileNameAction() ) );
[730]223
[733]224#ifdef GEANT4_QT_DEBUG
225  printf("11110000\n");
226#endif
[730]227#if QT_VERSION < 0x040000
[733]228  globalVLayout->add(saveFileGroupBox);
[730]229#else
[733]230  globalVLayout->addWidget(saveFileGroupBox);
[730]231#endif
232
[733]233#ifdef GEANT4_QT_DEBUG
234  printf("11111111111&\n");
235#endif
[730]236
[732]237  // label
238
[730]239  QLabel *infoLabel = new QLabel("  Press SPACE to Start/Pause video recording \n  Press RETURN to Stop video recording");
240
[733]241  // global status
242  fGlobalStatus = new QLabel("");
243
[730]244#if QT_VERSION < 0x040000
245  globalVLayout->add(infoLabel);
[733]246  globalVLayout->add(fGlobalStatus);
[730]247#else
248  globalVLayout->addWidget(infoLabel);
[733]249  globalVLayout->addWidget(fGlobalStatus);
[730]250#endif
[733]251#ifdef GEANT4_QT_DEBUG
252  printf("11112222222222é\n");
[732]253#endif
254
255  // buttons
[730]256  QWidget *buttonBox = new QWidget(this);
257
258  QHBoxLayout *buttonBoxLayout = new QHBoxLayout(buttonBox);
259
[732]260  QPushButton *buttonCancel = new QPushButton( tr( "&Cancel" ),buttonBox );
261  buttonCancel->setAutoDefault( TRUE );
262  buttonBoxLayout->addWidget(buttonCancel);
[730]263
[733]264  QPushButton *buttonApply = new QPushButton( tr( "&Apply" ),buttonBox );
265  buttonApply->setAutoDefault( TRUE );
266  buttonBoxLayout->addWidget(buttonApply);
267
268  QPushButton * buttonEncode = new QPushButton( tr( "&Encode" ),buttonBox );
[730]269  buttonEncode->setAutoDefault( TRUE );
270  buttonEncode->setDefault( TRUE );
271  buttonBoxLayout->addWidget(buttonEncode);
272
[733]273#ifdef GEANT4_QT_DEBUG
274  printf("1111333333333333\n");
275#endif
[730]276#if QT_VERSION >= 0x040000
277  buttonBox->setLayout(buttonBoxLayout);
278#endif
279  globalVLayout->addWidget(buttonBox);
280
281
[733]282#ifdef GEANT4_QT_DEBUG
283  printf("1111444444444\n");
284#endif
[730]285
286#if QT_VERSION >= 0x040000
287  setLayout(globalVLayout);
288#endif
289
290  // signals and slots connections
[733]291  connect( buttonApply, SIGNAL( clicked() ), this, SLOT( checkAllParameters() ) );
[730]292  connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
[733]293  connect( buttonEncode, SIGNAL( clicked() ), this, SLOT( encode() ) );
294#ifdef GEANT4_QT_DEBUG
295  printf("111155555555\n");
296#endif
[730]297}
298
299
300
301G4OpenGLQtMovieDialog::~G4OpenGLQtMovieDialog()
302{
303}
304
[733]305void G4OpenGLQtMovieDialog::selectEncoderPathAction()
[730]306{
307  QString nomFich =  QFileDialog::getOpenFileName ( this,
308                                                    "Select your encoder",
309                                                    tr("Select your encoder ..."));
310  if (nomFich == "") {
311    return;
312  }
[733]313  checkEncoderParameters(nomFich);
314 }
315
316void G4OpenGLQtMovieDialog::selectTempPathAction()
317{
318  QString nomFich =  QFileDialog::getOpenFileName ( this,
319                                                    "Select temporary folder",
320                                                    tr("Select temporary folder ..."));
321  if (nomFich == "") {
322    return;
323  }
324  checkTempFolderParameters(nomFich);
325 }
326
327void G4OpenGLQtMovieDialog::selectSaveFileNameAction()
328{
329  QString nomFich =  QFileDialog::getOpenFileName ( this,
330                                                    "Select saved file",
331                                                    tr("Select saved file ..."));
332  if (nomFich == "") {
333    return;
334  }
335  checkSaveFileNameParameters(nomFich);
336 }
337
338void G4OpenGLQtMovieDialog::encode() {
[730]339}
340
[733]341/** Check all parameters
342*/
343void G4OpenGLQtMovieDialog::checkAllParameters() {
344  checkEncoderParameters(fEncoderPath->text());
345  checkTempFolderParameters(fTempFolderPath->text());
346  checkSaveFileNameParameters(fSaveFileName->text());
347}
348
349        /**
[732]350 * If one of parameter is incorrect, put it in red and don't valid it
[733]351 * If valid, save it
[732]352 */
[733]353void G4OpenGLQtMovieDialog::checkEncoderParameters(QString param) {
[730]354
[732]355  QPalette palette( fEncoderPath->palette() );
356
[733]357  QString temp = fParentViewer->setEncoderPath(param);
358  fGlobalStatus->setText("");
359    fEncoderStatus->setText(temp);
360  if (temp != "") {
[732]361    palette.setColor( QPalette::Base, Qt::red);
[733]362    fGlobalStatus->setText("If no valid encode defined, screnn /ncapture files will be saved in /nthe temp folder in ppm format.");
[732]363  } else {
364    palette.setColor( QPalette::Base, Qt::white);
[733]365    fEncoderPath->setText(fParentViewer->getEncoderPath());
[732]366  }
367  fEncoderPath->setPalette(palette);
[733]368}
[732]369
370
[733]371/**
372 * If one of parameter is incorrect, put it in red and don't valid it
373 * If valid, save it
374 */
375void G4OpenGLQtMovieDialog::checkTempFolderParameters(QString param) {
[732]376
[733]377  QPalette palette( fTempFolderPath->palette() );
378
379  QString temp = fParentViewer->setTempFolderPath(param);
380    fTempFolderStatus->setText(temp);
381  if (temp != "") {
[732]382    palette.setColor( QPalette::Base, Qt::red);
383  } else {
384    palette.setColor( QPalette::Base, Qt::white);
[733]385    fTempFolderPath->setText(fParentViewer->getEncoderPath());
[732]386  }
[733]387  fTempFolderPath->setPalette(palette);
[732]388}
389
[733]390
391/**
392 * If one of parameter is incorrect, put it in red and don't valid it
393 * If valid, save it
394 */
395void G4OpenGLQtMovieDialog::checkSaveFileNameParameters(QString param) {
396
397  QPalette palette( fSaveFileName->palette() );
398
399  QString temp = fParentViewer->setSaveFileName(param);
400    fSaveFileStatus->setText(temp);
401  if (temp != "") {
402    palette.setColor( QPalette::Base, Qt::red);
403  } else {
404    palette.setColor( QPalette::Base, Qt::white);
405    fSaveFileName->setText(fParentViewer->getSaveFileName());
406  }
407  fSaveFileName->setPalette(palette);
408}
[730]409#endif
Note: See TracBrowser for help on using the repository browser.