Changeset 733 for trunk


Ignore:
Timestamp:
Mar 4, 2008, 2:29:54 PM (16 years ago)
Author:
garnier
Message:

remise a niveau de movie parameters

Location:
trunk/geant4/visualization/OpenGL
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/geant4/visualization/OpenGL/include/G4OpenGLQtMovieDialog.hh

    r732 r733  
    6565private :
    6666  QLineEdit* fEncoderPath;
    67   QLineEdit* fTempPath;
     67  QLineEdit* fTempFolderPath;
     68  QLineEdit* fSaveFileName;
    6869  G4OpenGLQtViewer *fParentViewer;
    69   QLabel *fCheckLabel;
     70  QLabel *fEncoderStatus;
     71  QLabel *fTempFolderStatus;
     72  QLabel *fSaveFileStatus;
     73  QLabel *fGlobalStatus;
     74
     75  void checkEncoderParameters(QString);
     76  void checkTempFolderParameters(QString);
     77  void checkSaveFileNameParameters(QString);
    7078
    7179private slots :
    72   void selectPathAction();
    73   void checkMovieParameters();
     80  void selectEncoderPathAction();
     81  void selectTempPathAction();
     82  void selectSaveFileNameAction();
     83  void checkAllParameters();
     84  void encode();
    7485};
    7586
  • trunk/geant4/visualization/OpenGL/include/G4OpenGLQtViewer.hh

    r732 r733  
    7272  virtual void updateQWidget()=0;
    7373  void setupViewport(int, int);
    74   bool setEncoderPath(QString path);
     74  QString setEncoderPath(QString path);
    7575  QString getEncoderPath();
    76   bool setTempFolderPath(QString path);
     76  QString setTempFolderPath(QString path);
    7777  QString getTempFolderPath();
     78  QString setSaveFileName(QString path);
     79  QString getSaveFileName();
    7880
    7981protected:
     
    148150  QString fEncoderPath;
    149151  QString fTempFolderPath;
     152  QString fSaveFileName;
    150153  QAction *fRotateAction;
    151154  QAction *fMoveAction;
  • trunk/geant4/visualization/OpenGL/src/G4OpenGLQtMovieDialog.cc

    r732 r733  
    3939#include <qpalette.h>
    4040#include <qlabel.h>
     41#include <qgroupbox.h>
    4142#include <qlayout.h>
    4243#include <qlineedit.h>
     
    8283  globalVLayout->setSpacing(10);
    8384 
    84   QLabel *pathLabel = new QLabel("Select path for encoder :");
    85 
    86 #if QT_VERSION < 0x040000
    87   globalVLayout->add(pathLabel);
    88 #else
    89   globalVLayout->addWidget(pathLabel);
    90 #endif
    91 
     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");
     90#endif
    9291
    9392  // Encoder Path
    94 
    95   QWidget *selectEncoderWidget = new QWidget(this);
    96   QHBoxLayout *selectPathLineLayout = new QHBoxLayout(selectEncoderWidget);
    97   fEncoderPath = new QLineEdit("",selectEncoderWidget);
    98 #if QT_VERSION < 0x040000
    99   selectPathLineLayout->add(fEncoderPath);
    100 #else
    101   selectPathLineLayout->addWidget(fEncoderPath);
    102 #endif
    103 
    104   QPushButton *encoderButton = new QPushButton(tr("..."),selectEncoderWidget);
     93  QWidget *encoderHBox = new QWidget(encoderGroupBox);
     94  QHBoxLayout *encoderHBoxLayout = new QHBoxLayout(encoderHBox);
     95  fEncoderPath = new QLineEdit("",encoderHBox);
     96
     97  QPushButton *encoderButton = new QPushButton(tr("..."),encoderHBox);
    10598  encoderButton->setMaximumWidth (30);
    10699
    107 #if QT_VERSION < 0x040000
    108   selectPathLineLayout->add(encoderButton);
    109 #else
    110   selectPathLineLayout->addWidget(encoderButton);
    111 #endif
    112 
     100  fEncoderStatus = new QLabel(encoderGroupBox);
     101  fEncoderStatus->setText("");
     102
     103#ifdef GEANT4_QT_DEBUG
     104  printf("2222\n");
     105#endif
     106#if QT_VERSION < 0x040000
     107  encoderHBoxLayout->add(fEncoderPath);
     108  encoderHBoxLayout->add(encoderButton);
     109  encoderVBoxLayout->add(fEncoderStatus);
     110#else
     111  encoderHBoxLayout->addWidget(fEncoderPath);
     112  encoderHBoxLayout->addWidget(encoderButton);
     113  encoderVBoxLayout->addWidget(fEncoderStatus);
     114#endif
     115
     116#ifdef GEANT4_QT_DEBUG
     117  printf("33333\n");
     118#endif
    113119#if QT_VERSION >= 0x040000
    114   selectEncoderWidget->setLayout(selectPathLineLayout);
    115 #endif
    116   connect( encoderButton, SIGNAL( clicked( ) ), this, SLOT(selectPathAction() ) );
    117 
    118 #if QT_VERSION < 0x040000
    119   globalVLayout->add(selectEncoderWidget);
    120 #else
    121   globalVLayout->addWidget(selectEncoderWidget);
     120//  encoderHBox->setLayout(encoderHBoxLayout);
     121  encoderGroupBox->setLayout(encoderVBoxLayout);
     122#endif
     123  connect( encoderButton, SIGNAL( clicked( ) ), this, SLOT(selectEncoderPathAction() ) );
     124#ifdef GEANT4_QT_DEBUG
     125  printf("4444\n");
     126#endif
     127
     128#if QT_VERSION < 0x040000
     129  globalVLayout->add(encoderGroupBox);
     130#else
     131  globalVLayout->addWidget(encoderGroupBox);
    122132#endif
    123133
     
    125135
    126136
     137  // temp folder group box
     138  QGroupBox *tempFolderGroupBox = new QGroupBox(tr("Temporary folder path"));           
     139  QVBoxLayout *tempFolderVBoxLayout = new QVBoxLayout(tempFolderGroupBox);
     140
    127141  // temp folder Path
    128   QWidget *selectTempFolderWidget = new QWidget(this);
    129   QHBoxLayout *selectEncoderLineLayout = new QHBoxLayout(selectTempFolderWidget);
    130 
    131   fTempPath = new QLineEdit("",selectTempFolderWidget);
    132 #if QT_VERSION < 0x040000
    133   selectEncoderLineLayout->add(fTempPath);
    134 #else
    135   selectEncoderLineLayout->addWidget(fTempPath);
    136 #endif
    137 
    138   QPushButton *tempButton = new QPushButton(tr("..."),selectTempFolderWidget);
     142  QWidget *tempFolderHBox = new QWidget(tempFolderGroupBox);
     143  QHBoxLayout *tempFolderHBoxLayout = new QHBoxLayout(tempFolderGroupBox);
     144
     145  fTempFolderPath = new QLineEdit("",tempFolderHBox);
     146
     147  QPushButton *tempButton = new QPushButton(tr("..."),tempFolderHBox);
    139148  tempButton->setMaximumWidth (30);
    140149
    141 #if QT_VERSION < 0x040000
    142   selectEncoderLineLayout->add(tempButton);
    143 #else
    144   selectEncoderLineLayout->addWidget(tempButton);
    145 #endif
    146 
     150  fTempFolderStatus = new QLabel(tempFolderGroupBox);
     151  fTempFolderStatus->setText("");
     152
     153#ifdef GEANT4_QT_DEBUG
     154  printf("5555\n");
     155#endif
     156#if QT_VERSION < 0x040000
     157  tempFolderHBoxLayout->add(fTempFolderPath);
     158  tempFolderHBoxLayout->add(tempButton);
     159  tempFolderVBoxLayout->add(fTempFolderStatus);
     160#else
     161  tempFolderHBoxLayout->addWidget(fTempFolderPath);
     162  tempFolderHBoxLayout->addWidget(tempButton);
     163  tempFolderVBoxLayout->addWidget(fTempFolderStatus);
     164#endif
     165
     166#ifdef GEANT4_QT_DEBUG
     167  printf("6666\n");
     168#endif
    147169#if QT_VERSION >= 0x040000
    148   selectTempFolderWidget->setLayout(selectEncoderLineLayout);
    149 #endif
    150   connect( tempButton, SIGNAL( clicked( ) ), this, SLOT(selectPathAction() ) );
    151 
    152 #if QT_VERSION < 0x040000
    153   globalVLayout->add(selectTempFolderWidget);
    154 #else
    155   globalVLayout->addWidget(selectTempFolderWidget);
    156 #endif
    157 
    158   fTempPath->setText(fParentViewer->getTempFolderPath());
    159 
     170//  tempFolderHBox->setLayout(tempFolderHBoxLayout);
     171  tempFolderGroupBox->setLayout(tempFolderVBoxLayout);
     172#endif
     173  connect( tempButton, SIGNAL( clicked( ) ), this, SLOT(selectTempPathAction() ) );
     174
     175#ifdef GEANT4_QT_DEBUG
     176  printf("77777\n");
     177#endif
     178#if QT_VERSION < 0x040000
     179  globalVLayout->add(tempFolderGroupBox);
     180#else
     181  globalVLayout->addWidget(tempFolderGroupBox);
     182#endif
     183
     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
     218#if QT_VERSION >= 0x040000
     219//  saveFileHBox->setLayout(saveFileHBoxLayout);
     220  saveFileGroupBox->setLayout(saveFileVBoxLayout);
     221#endif
     222  connect( saveButton, SIGNAL( clicked( ) ), this, SLOT(selectSaveFileNameAction() ) );
     223
     224#ifdef GEANT4_QT_DEBUG
     225  printf("11110000\n");
     226#endif
     227#if QT_VERSION < 0x040000
     228  globalVLayout->add(saveFileGroupBox);
     229#else
     230  globalVLayout->addWidget(saveFileGroupBox);
     231#endif
     232
     233#ifdef GEANT4_QT_DEBUG
     234  printf("11111111111&\n");
     235#endif
    160236
    161237  // label
     
    163239  QLabel *infoLabel = new QLabel("  Press SPACE to Start/Pause video recording \n  Press RETURN to Stop video recording");
    164240
     241  // global status
     242  fGlobalStatus = new QLabel("");
     243
    165244#if QT_VERSION < 0x040000
    166245  globalVLayout->add(infoLabel);
     246  globalVLayout->add(fGlobalStatus);
    167247#else
    168248  globalVLayout->addWidget(infoLabel);
    169 #endif
    170 
    171   // check infos
    172   fCheckLabel = new QLabel("");
    173 
    174 #if QT_VERSION < 0x040000
    175   globalVLayout->add(fCheckLabel);
    176 #else
    177   globalVLayout->addWidget(fCheckLabel);
     249  globalVLayout->addWidget(fGlobalStatus);
     250#endif
     251#ifdef GEANT4_QT_DEBUG
     252  printf("11112222222222é\n");
    178253#endif
    179254
     
    187262  buttonBoxLayout->addWidget(buttonCancel);
    188263
    189   QPushButton * buttonEncode = new QPushButton( tr( "&Apply" ),buttonBox );
     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 );
    190269  buttonEncode->setAutoDefault( TRUE );
    191270  buttonEncode->setDefault( TRUE );
    192271  buttonBoxLayout->addWidget(buttonEncode);
    193272
     273#ifdef GEANT4_QT_DEBUG
     274  printf("1111333333333333\n");
     275#endif
    194276#if QT_VERSION >= 0x040000
    195277  buttonBox->setLayout(buttonBoxLayout);
     
    198280
    199281
     282#ifdef GEANT4_QT_DEBUG
     283  printf("1111444444444\n");
     284#endif
    200285
    201286#if QT_VERSION >= 0x040000
     
    204289
    205290  // signals and slots connections
    206   connect( buttonEncode, SIGNAL( clicked() ), this, SLOT( checkMovieParameters() ) );
     291  connect( buttonApply, SIGNAL( clicked() ), this, SLOT( checkAllParameters() ) );
    207292  connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
     293  connect( buttonEncode, SIGNAL( clicked() ), this, SLOT( encode() ) );
     294#ifdef GEANT4_QT_DEBUG
     295  printf("111155555555\n");
     296#endif
    208297}
    209298
     
    214303}
    215304
    216 void G4OpenGLQtMovieDialog::selectPathAction()
     305void G4OpenGLQtMovieDialog::selectEncoderPathAction()
    217306{
    218307  QString nomFich =  QFileDialog::getOpenFileName ( this,
     
    222311    return;
    223312  }
    224   fEncoderPath->setText(nomFich);
    225 }
     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() {
     339}
     340
     341/** Check all parameters
     342*/
     343void G4OpenGLQtMovieDialog::checkAllParameters() {
     344  checkEncoderParameters(fEncoderPath->text());
     345  checkTempFolderParameters(fTempFolderPath->text());
     346  checkSaveFileNameParameters(fSaveFileName->text());
     347}
     348
     349        /**
     350 * If one of parameter is incorrect, put it in red and don't valid it
     351 * If valid, save it
     352 */
     353void G4OpenGLQtMovieDialog::checkEncoderParameters(QString param) {
     354
     355  QPalette palette( fEncoderPath->palette() );
     356
     357  QString temp = fParentViewer->setEncoderPath(param);
     358  fGlobalStatus->setText("");
     359    fEncoderStatus->setText(temp);
     360  if (temp != "") {
     361    palette.setColor( QPalette::Base, Qt::red);
     362    fGlobalStatus->setText("If no valid encode defined, screnn /ncapture files will be saved in /nthe temp folder in ppm format.");
     363  } else {
     364    palette.setColor( QPalette::Base, Qt::white);
     365    fEncoderPath->setText(fParentViewer->getEncoderPath());
     366  }
     367  fEncoderPath->setPalette(palette);
     368}
     369
    226370
    227371/**
    228372 * If one of parameter is incorrect, put it in red and don't valid it
     373 * If valid, save it
    229374 */
    230 void G4OpenGLQtMovieDialog::checkMovieParameters() {
    231 
    232   fCheckLabel->setText("");
    233   QPalette palette( fEncoderPath->palette() );
    234 
    235   if (!fParentViewer->setEncoderPath(fEncoderPath->text())) {
     375void G4OpenGLQtMovieDialog::checkTempFolderParameters(QString param) {
     376
     377  QPalette palette( fTempFolderPath->palette() );
     378
     379  QString temp = fParentViewer->setTempFolderPath(param);
     380    fTempFolderStatus->setText(temp);
     381  if (temp != "") {
    236382    palette.setColor( QPalette::Base, Qt::red);
    237     fCheckLabel->setText ("Encoder path does not exist or file is not executable\n");
    238383  } else {
    239384    palette.setColor( QPalette::Base, Qt::white);
    240   }
    241   fEncoderPath->setPalette(palette);
    242 
    243 
    244 
    245   if (!fParentViewer->setTempFolderPath(fTempPath->text())) {
     385    fTempFolderPath->setText(fParentViewer->getEncoderPath());
     386  }
     387  fTempFolderPath->setPalette(palette);
     388}
     389
     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 != "") {
    246402    palette.setColor( QPalette::Base, Qt::red);
    247     fCheckLabel->setText (fCheckLabel->text()+"Temp folder does not exist or no write access to write in\n");
    248403  } else {
    249404    palette.setColor( QPalette::Base, Qt::white);
    250   }
    251   fTempPath->setPalette(palette);
    252 }
    253 
    254 #endif
     405    fSaveFileName->setText(fParentViewer->getSaveFileName());
     406  }
     407  fSaveFileName->setPalette(palette);
     408}
     409#endif
  • trunk/geant4/visualization/OpenGL/src/G4OpenGLQtViewer.cc

    r732 r733  
    663663  QAction *movieParameters =  new QAction("&Movie parameters...","&Make movie ...",CTRL+Key_M,mActions,0,true);
    664664#else
    665   QAction *movieParameters =  new QAction("&Make parameters...",CTRL+Key_M,mActions);
     665  QAction *movieParameters =  new QAction("&Movie parameters...",CTRL+Key_M,mActions);
    666666#endif
    667667  movieParameters->addTo(mActions);
     
    19951995
    19961996  fHoldKeyEvent = true;
     1997  if (event->key() == Qt::Key_Down) {
     1998#ifdef GEANT4_QT_DEBUG
     1999  printf("G4OpenGLQtViewer::G4keyPressEvent Down\n");
     2000#endif
     2001  } else if (event->key() == Qt::Key_Up) {
     2002#ifdef GEANT4_QT_DEBUG
     2003  printf("G4OpenGLQtViewer::G4keyPressEvent Up\n");
     2004#endif
     2005  } else if (event->key() == Qt::Key_Plus) {
     2006#ifdef GEANT4_QT_DEBUG
     2007  printf("G4OpenGLQtViewer::G4keyPressEvent Plus\n");
     2008#endif
     2009  } else if (event->key() == Qt::Key_Minus) {
     2010#ifdef GEANT4_QT_DEBUG
     2011  printf("G4OpenGLQtViewer::G4keyPressEvent Minus\n");
     2012#endif
     2013  }
     2014  if (event->modifiers() & Qt::AltModifier ) {
     2015#ifdef GEANT4_QT_DEBUG
     2016  printf("G4OpenGLQtViewer::G4keyPressEvent Alt\n");
     2017#endif
     2018  } else if (event->modifiers() & Qt::ShiftModifier) {
     2019#ifdef GEANT4_QT_DEBUG
     2020  printf("G4OpenGLQtViewer::G4keyPressEvent Shift\n");
     2021#endif
     2022  }
    19972023
    19982024#if QT_VERSION < 0x040000
     
    21492175/**
    21502176 * set the new encoder path
    2151  * @return true if the path exist and file is executable, false otherwise
     2177 * @return "" if correct. The error otherwise
    21522178*/
    2153 bool G4OpenGLQtViewer::setEncoderPath(QString path) {
     2179QString G4OpenGLQtViewer::setEncoderPath(QString path) {
    21542180  QFile *f = new QFile(path);
    21552181  if (!f->exists()) {
    21562182#ifdef GEANT4_QT_DEBUG
    2157   printf("G4OpenGLQtViewer::setEncoderPath NOT E        XIST\n");
    2158 #endif
    2159     return false;
     2183  printf("G4OpenGLQtViewer::setEncoderPath NOT EXIST\n");
     2184#endif
     2185    return "Path does not exist";
    21602186  }
    21612187  if (!(f->permissions() & QFile::ExeUser)) {
     
    21632189  printf("G4OpenGLQtViewer::setEncoderPath No WRITE ACCES\n");
    21642190#endif
    2165     return false;
     2191    return "File exist but is not executable";
    21662192  }
    21672193  fEncoderPath = path;
    2168   return true;
     2194  return "";
    21692195}
    21702196
    21712197/**
    21722198 * set the temp folder path
    2173  * @return true if the path exist and we could write in, false otherwise
     2199 * @return "" if correct. The error otherwise
    21742200*/
    2175 bool G4OpenGLQtViewer::setTempFolderPath(QString path) {
     2201QString G4OpenGLQtViewer::setTempFolderPath(QString path) {
    21762202
    21772203  QDir *d = new QDir(path);
    21782204  if (!d->exists(path)) {
    2179     return false;
     2205    return "Path does not exist";
    21802206  }
    21812207
     
    21932219
    21942220  if (!found)
    2195     return false;
     2221    return "Path exist, but is not write accessible";
    21962222 
    21972223  fTempFolderPath = path;
    2198   return true;
     2224  return "";
    21992225}
    22002226
     
    22052231}
    22062232 
     2233/**
     2234 * set the save file name path
     2235 * @return "" if correct. The error otherwise
     2236*/
     2237QString G4OpenGLQtViewer::setSaveFileName(QString path) {
     2238
     2239  QDir *d = new QDir(path);
     2240  if (!d->exists(path)) {
     2241    return "Path does not exist";
     2242  }
     2243
     2244  d->setFilter( QDir::Dirs | QDir::Readable | QDir::Writable );
     2245  QStringList subDirList = d->entryList();
     2246  bool found = false;
     2247
     2248  for (QStringList::ConstIterator it = subDirList.begin() ;(it != subDirList.end()) ; it++) {
     2249    const QString currentDir = *it;
     2250   
     2251    if (currentDir == ".") { // we found it
     2252      found = true;
     2253    }
     2254  }
     2255
     2256  if (!found)
     2257    return "Path exist, but is not write accessible";
     2258 
     2259  fSaveFileName = path;
     2260  return "";
     2261}
     2262
     2263/** @return the save file path
     2264 */
     2265QString G4OpenGLQtViewer::getSaveFileName() {
     2266  return fSaveFileName ;
     2267}
    22072268
    22082269 
Note: See TracChangeset for help on using the changeset viewer.