Ignore:
Timestamp:
Feb 27, 2008, 11:49:37 AM (16 years ago)
Author:
garnier
Message:

debut de la boite de dialog pour les param video

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

Legend:

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

    r731 r732  
    3939class QButtonGroup;
    4040class QPushButton;
    41 class QRadioButton;
    42 class QCheckBox;
    43 class QSlider;
    44 class QComboBox;
    4541class QLabel;
    4642class QLineEdit;
     
    6864
    6965private :
    70   QLineEdit* fSelectPath;
    71   QString fTmpDir;
     66  QLineEdit* fEncoderPath;
     67  QLineEdit* fTempPath;
    7268  G4OpenGLQtViewer *fParentViewer;
     69  QLabel *fCheckLabel;
    7370
    7471private slots :
    7572  void selectPathAction();
     73  void checkMovieParameters();
    7674};
    7775
  • trunk/geant4/visualization/OpenGL/include/G4OpenGLQtViewer.hh

    r731 r732  
    7272  virtual void updateQWidget()=0;
    7373  void setupViewport(int, int);
    74   void setEncoderPath(QString path);
     74  bool setEncoderPath(QString path);
    7575  QString getEncoderPath();
     76  bool setTempFolderPath(QString path);
     77  QString getTempFolderPath();
    7678
    7779protected:
     
    145147  bool fAutoMove;
    146148  QString fEncoderPath;
     149  QString fTempFolderPath;
    147150  QAction *fRotateAction;
    148151  QAction *fMoveAction;
     
    154157  QAction *fDrawingSurfaceRemoval;
    155158  QAction *fDrawingLineSurfaceRemoval;
    156   G4OpenGLQtMovieDialog* movieParametersDialog;
     159  G4OpenGLQtMovieDialog* fMovieParametersDialog;
    157160
    158161private slots :
  • trunk/geant4/visualization/OpenGL/src/G4OpenGLQtMovieDialog.cc

    r731 r732  
    3636#include "G4OpenGLQtViewer.hh"
    3737
    38 // #include <qvariant.h>
    3938#include <qpushbutton.h>
    40 // #include <qcheckbox.h>
     39#include <qpalette.h>
    4140#include <qlabel.h>
    42 // #include <qcombobox.h>
    43 // #include <qslider.h>
    4441#include <qlayout.h>
    45 // #include <qgroupbox.h>
    46 // #include <qradiobutton.h>
    47 // #include <qimage.h>
    4842#include <qlineedit.h>
    4943#include <qfiledialog.h>
    5044#include <qprocess.h>
    5145
    52 // #include <qbuttongroup.h>
    5346
    5447// +---------------------------------------+
    5548// +        Path for encoder               +
     49// +  _______                              +
     50// + | select| ____________________        +
     51// +  -------                              +
     52// +        Temp path                      +
    5653// +  _______                              +
    5754// + | select| ____________________        +
     
    9491
    9592
    96 
    97   // width
    98   QWidget *selectPathWidget = new QWidget(this);
    99 
    100   QHBoxLayout *selectPathLineLayout = new QHBoxLayout(selectPathWidget);
    101 
    102 
    103   fSelectPath = new QLineEdit("",selectPathWidget);
    104 #if QT_VERSION < 0x040000
    105   selectPathLineLayout->add(fSelectPath);
    106 #else
    107   selectPathLineLayout->addWidget(fSelectPath);
    108 #endif
    109 
    110   QPushButton *pathButton = new QPushButton(tr("..."),selectPathWidget);
    111 
    112 #if QT_VERSION < 0x040000
    113   selectPathLineLayout->add(pathButton);
    114 #else
    115   selectPathLineLayout->addWidget(pathButton);
    116 #endif
    117 
    118 #if QT_VERSION >= 0x040000
    119   selectPathWidget->setLayout(selectPathLineLayout);
    120 #endif
    121   connect( pathButton, SIGNAL( clicked( ) ), this, SLOT(selectPathAction() ) );
    122 
    123 #if QT_VERSION < 0x040000
    124   globalVLayout->add(selectPathWidget);
    125 #else
    126   globalVLayout->addWidget(selectPathWidget);
    127 #endif
    128 
    129   fSelectPath->setText(fParentViewer->getEncoderPath());
     93  // 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);
     105  encoderButton->setMaximumWidth (30);
     106
     107#if QT_VERSION < 0x040000
     108  selectPathLineLayout->add(encoderButton);
     109#else
     110  selectPathLineLayout->addWidget(encoderButton);
     111#endif
     112
     113#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);
     122#endif
     123
     124  fEncoderPath->setText(fParentViewer->getEncoderPath());
     125
     126
     127  // 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);
     139  tempButton->setMaximumWidth (30);
     140
     141#if QT_VERSION < 0x040000
     142  selectEncoderLineLayout->add(tempButton);
     143#else
     144  selectEncoderLineLayout->addWidget(tempButton);
     145#endif
     146
     147#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
     160
     161  // label
    130162
    131163  QLabel *infoLabel = new QLabel("  Press SPACE to Start/Pause video recording \n  Press RETURN to Stop video recording");
     
    137169#endif
    138170
     171  // check infos
     172  fCheckLabel = new QLabel("");
     173
     174#if QT_VERSION < 0x040000
     175  globalVLayout->add(fCheckLabel);
     176#else
     177  globalVLayout->addWidget(fCheckLabel);
     178#endif
     179
     180  // buttons
    139181  QWidget *buttonBox = new QWidget(this);
    140182
    141183  QHBoxLayout *buttonBoxLayout = new QHBoxLayout(buttonBox);
    142184
     185  QPushButton *buttonCancel = new QPushButton( tr( "&Cancel" ),buttonBox );
     186  buttonCancel->setAutoDefault( TRUE );
     187  buttonBoxLayout->addWidget(buttonCancel);
    143188
    144189  QPushButton * buttonEncode = new QPushButton( tr( "&Apply" ),buttonBox );
     
    147192  buttonBoxLayout->addWidget(buttonEncode);
    148193
    149   QPushButton *buttonCancel = new QPushButton( tr( "&Cancel" ),buttonBox );
    150   buttonCancel->setAutoDefault( TRUE );
    151   buttonBoxLayout->addWidget(buttonCancel);
    152 
    153194#if QT_VERSION >= 0x040000
    154195  buttonBox->setLayout(buttonBoxLayout);
     
    163204
    164205  // signals and slots connections
    165   connect( buttonEncode, SIGNAL( clicked() ), this, SLOT( accept() ) );
     206  connect( buttonEncode, SIGNAL( clicked() ), this, SLOT( checkMovieParameters() ) );
    166207  connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
    167208}
     
    181222    return;
    182223  }
    183   fSelectPath->setText(nomFich);
    184 }
    185 
    186 
    187 #endif
     224  fEncoderPath->setText(nomFich);
     225}
     226
     227/**
     228 * If one of parameter is incorrect, put it in red and don't valid it
     229 */
     230void G4OpenGLQtMovieDialog::checkMovieParameters() {
     231
     232  fCheckLabel->setText("");
     233  QPalette palette( fEncoderPath->palette() );
     234
     235  if (!fParentViewer->setEncoderPath(fEncoderPath->text())) {
     236    palette.setColor( QPalette::Base, Qt::red);
     237    fCheckLabel->setText ("Encoder path does not exist or file is not executable\n");
     238  } else {
     239    palette.setColor( QPalette::Base, Qt::white);
     240  }
     241  fEncoderPath->setPalette(palette);
     242
     243
     244
     245  if (!fParentViewer->setTempFolderPath(fTempPath->text())) {
     246    palette.setColor( QPalette::Base, Qt::red);
     247    fCheckLabel->setText (fCheckLabel->text()+"Temp folder does not exist or no write access to write in\n");
     248  } else {
     249    palette.setColor( QPalette::Base, Qt::white);
     250  }
     251  fTempPath->setPalette(palette);
     252}
     253
     254#endif
  • trunk/geant4/visualization/OpenGL/src/G4OpenGLQtViewer.cc

    r731 r732  
    301301  ,fHoldRotateEvent(false)
    302302  ,fAutoMove(false)
     303  ,fEncoderPath("")
     304  ,fTempFolderPath("/temp")
     305  ,fMovieParametersDialog(NULL)
    303306{
    304307#ifdef GEANT4_QT_DEBUG
    305   fEncoderPath = "";
    306308  printf("G4OpenGLQtViewer::G4OpenGLQtViewer \n");
    307309#endif
     
    14581460
    14591461void G4OpenGLQtViewer::showMovieParametersDialog() {
    1460   if (!movieParametersDialog) {
    1461     movieParametersDialog= new G4OpenGLQtMovieDialog(this,GLWindow);
    1462   }
    1463   movieParametersDialog->show();
     1462  if (!fMovieParametersDialog) {
     1463    fMovieParametersDialog= new G4OpenGLQtMovieDialog(this,GLWindow);
     1464  }
     1465  fMovieParametersDialog->show();
    14641466}
    14651467
     
    20742076
    20752077  if ((event->key() == Qt::Key_Return) || (event->key() == Qt::Key_Enter)){ // end of video
    2076     GLWidget->setCaption( tr( " Stop Recording " ));
    20772078    G4cout << "Stop Recording \n" << G4endl;
    20782079    G4cout << "Saving /temp/output.mpg \n" << G4endl;
     
    20892090    fRecordFrames = !fRecordFrames;
    20902091    if (fRecordFrames) {
    2091       GLWidget->setCaption( tr( " Start Recording " ));
    20922092      G4cout << " Start Recording \n" << G4endl;
    20932093    } else {
    2094       GLWidget->setCaption( tr( " Pause Recording" ));
    20952094      G4cout << "Pause Recording \n" << G4endl;
    20962095    }
     
    21352134 
    21362135     if (search.waitForFinished()) {
    2137        fEncoderPath = QString::fromLocal8Bit(search.readAll());
     2136       fEncoderPath = QString(QString::fromLocal8Bit(search.readAll())).trimmed();
    21382137       // if not found, return "not found"
    21392138       if (fEncoderPath.contains(" ")) {
     
    21502149/**
    21512150 * set the new encoder path
     2151 * @return true if the path exist and file is executable, false otherwise
    21522152*/
    2153 void G4OpenGLQtViewer::setEncoderPath(QString path) {
     2153bool G4OpenGLQtViewer::setEncoderPath(QString path) {
     2154  QFile *f = new QFile(path);
     2155  if (!f->exists()) {
     2156#ifdef GEANT4_QT_DEBUG
     2157  printf("G4OpenGLQtViewer::setEncoderPath NOT E        XIST\n");
     2158#endif
     2159    return false;
     2160  }
     2161  if (!(f->permissions() & QFile::ExeUser)) {
     2162#ifdef GEANT4_QT_DEBUG
     2163  printf("G4OpenGLQtViewer::setEncoderPath No WRITE ACCES\n");
     2164#endif
     2165    return false;
     2166  }
    21542167  fEncoderPath = path;
    2155 }
     2168  return true;
     2169}
     2170
     2171/**
     2172 * set the temp folder path
     2173 * @return true if the path exist and we could write in, false otherwise
     2174*/
     2175bool G4OpenGLQtViewer::setTempFolderPath(QString path) {
     2176
     2177  QDir *d = new QDir(path);
     2178  if (!d->exists(path)) {
     2179    return false;
     2180  }
     2181
     2182  d->setFilter( QDir::Dirs | QDir::Readable | QDir::Writable );
     2183  QStringList subDirList = d->entryList();
     2184  bool found = false;
     2185
     2186  for (QStringList::ConstIterator it = subDirList.begin() ;(it != subDirList.end()) ; it++) {
     2187    const QString currentDir = *it;
     2188   
     2189    if (currentDir == ".") { // we found it
     2190      found = true;
     2191    }
     2192  }
     2193
     2194  if (!found)
     2195    return false;
     2196 
     2197  fTempFolderPath = path;
     2198  return true;
     2199}
     2200
     2201/** @return the temp folder path
     2202 */
     2203QString G4OpenGLQtViewer::getTempFolderPath() {
     2204  return fTempFolderPath ;
     2205}
     2206 
     2207
    21562208 
    21572209
Note: See TracChangeset for help on using the changeset viewer.