Changeset 731 for trunk


Ignore:
Timestamp:
Feb 26, 2008, 12:50:22 PM (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

    r730 r731  
    4545class QLabel;
    4646class QLineEdit;
     47class G4OpenGLQtViewer;
    4748
    4849#if QT_VERSION >= 0x040000
     
    6162      @param parent : parent widget
    6263  */
    63   G4OpenGLQtMovieDialog(QWidget* parent);
     64  G4OpenGLQtMovieDialog(G4OpenGLQtViewer*,QWidget*);
    6465
    6566  /** Destroys G4OpenGLQtMovieDialog */
     
    6970  QLineEdit* fSelectPath;
    7071  QString fTmpDir;
    71   QWidget *fParent;
     72  G4OpenGLQtViewer *fParentViewer;
    7273
    7374private slots :
  • trunk/geant4/visualization/OpenGL/include/G4OpenGLQtViewer.hh

    r730 r731  
    5959
    6060class G4OpenGLSceneHandler;
     61class G4OpenGLQtMovieDialog;
    6162
    6263class G4OpenGLQtViewer: public QObject, virtual public G4OpenGLViewer {
     
    112113  bool generateVectorEPS (QString,int,int,QImage);
    113114  bool generatePS_PDF(QString,int,QImage); 
     115  void showMovieParametersDialog();
    114116
    115117#if QT_VERSION < 0x040000
     
    152154  QAction *fDrawingSurfaceRemoval;
    153155  QAction *fDrawingLineSurfaceRemoval;
     156  G4OpenGLQtMovieDialog* movieParametersDialog;
    154157
    155158private slots :
     
    161164  void actionDrawingSurfaceRemoval();
    162165  void actionDrawingLineSurfaceRemoval();
    163   void actionCreateEPS();
    164   void actionCreateMovie();
     166  void actionSaveImage();
     167  void actionMovieParameters();
    165168
    166169  void showShortcuts();
  • trunk/geant4/visualization/OpenGL/src/G4OpenGLQtMovieDialog.cc

    r730 r731  
    6666
    6767G4OpenGLQtMovieDialog::G4OpenGLQtMovieDialog(
    68  QWidget* parent
     68 G4OpenGLQtViewer* parentViewer,
     69 QWidget* parentWidget
    6970)
    70   : QDialog( parent ),
    71     fParent(parent)
     71  : QDialog( parentWidget ),
     72    fParentViewer(parentViewer)
    7273{
    7374  setModal(false);
     
    126127#endif
    127128
    128   fSelectPath->setText(((G4OpenGLQtViewer*)fParent)->getEncoderPath());
     129  fSelectPath->setText(fParentViewer->getEncoderPath());
    129130
    130131  QLabel *infoLabel = new QLabel("  Press SPACE to Start/Pause video recording \n  Press RETURN to Stop video recording");
  • trunk/geant4/visualization/OpenGL/src/G4OpenGLQtViewer.cc

    r730 r731  
    301301  ,fHoldRotateEvent(false)
    302302  ,fAutoMove(false)
    303   ,fEncoderPath(NULL)
    304303{
    305304#ifdef GEANT4_QT_DEBUG
     305  fEncoderPath = "";
    306306  printf("G4OpenGLQtViewer::G4OpenGLQtViewer \n");
    307307#endif
     
    645645                    SIGNAL(activated()),
    646646                    this,
    647                     SLOT(actionCreateEPS()));
     647                    SLOT(actionSaveImage()));
    648648
    649649#else
     
    654654                    SIGNAL(triggered()),
    655655                    this,
    656                     SLOT(actionCreateEPS()));
     656                    SLOT(actionSaveImage()));
    657657#endif
    658658
    659659#if QT_VERSION < 0x040000
    660660#if QT_VERSION < 0x030200
    661   QAction *createMovie =  new QAction("&Make movie ...","&Make movie ...",CTRL+Key_M,mActions,0,true);
    662 #else
    663   QAction *createMovie =  new QAction("&Make movie ...",CTRL+Key_M,mActions);
    664 #endif
    665   createMovie->addTo(mActions);
    666   QObject ::connect(createMovie,
     661  QAction *movieParameters =  new QAction("&Movie parameters...","&Make movie ...",CTRL+Key_M,mActions,0,true);
     662#else
     663  QAction *movieParameters =  new QAction("&Make parameters...",CTRL+Key_M,mActions);
     664#endif
     665  movieParameters->addTo(mActions);
     666  QObject ::connect(movieParameters,
    667667                    SIGNAL(activated()),
    668668                    this,
    669                     SLOT(actionCreateMovie()));
     669                    SLOT(actionMovieParameters()));
    670670
    671671#else
    672672  // === Action Menu ===
    673   QAction *createMovie = mActions->addAction("Make movie ...");
    674   QObject ::connect(createMovie,
     673  QAction *movieParameters = mActions->addAction("Movie parameters...");
     674  QObject ::connect(movieParameters,
    675675                    SIGNAL(triggered()),
    676676                    this,
    677                     SLOT(actionCreateMovie()));
     677                    SLOT(actionMovieParameters()));
    678678#endif
    679679
     
    13241324
    13251325
    1326 void G4OpenGLQtViewer::actionCreateEPS() {
     1326void G4OpenGLQtViewer::actionSaveImage() {
    13271327  QString filters;
    13281328#if QT_VERSION < 0x040000
     
    14431443 
    14441444#ifdef GEANT4_QT_DEBUG
    1445   printf("G4OpenGLQtViewer::actionCreateEPS() \n");
    1446 #endif
    1447 }
    1448 
    1449 
    1450 void G4OpenGLQtViewer::actionCreateMovie() {
    1451 
    1452   G4OpenGLQtMovieDialog* movieDialog= new G4OpenGLQtMovieDialog(GLWindow);
    1453   movieDialog->show();
     1445  printf("G4OpenGLQtViewer::actionSaveImage() \n");
     1446#endif
     1447}
     1448
     1449
     1450void G4OpenGLQtViewer::actionMovieParameters() {
     1451
     1452  showMovieParametersDialog();
    14541453#ifdef GEANT4_QT_DEBUG
    1455   printf("G4OpenGLQtViewer::actionCreateMovie() \n");
    1456 #endif
    1457 }
     1454  printf("G4OpenGLQtViewer::actionMovieParameters() \n");
     1455#endif
     1456}
     1457
     1458
     1459void G4OpenGLQtViewer::showMovieParametersDialog() {
     1460  if (!movieParametersDialog) {
     1461    movieParametersDialog= new G4OpenGLQtMovieDialog(this,GLWindow);
     1462  }
     1463  movieParametersDialog->show();
     1464}
     1465
    14581466
    14591467/*
     
    20662074
    20672075  if ((event->key() == Qt::Key_Return) || (event->key() == Qt::Key_Enter)){ // end of video
    2068     fRecordFrames = false;
    2069     G4cout << "Recording Stop... \n" << G4endl;
     2076    GLWidget->setCaption( tr( " Stop Recording " ));
     2077    G4cout << "Stop Recording \n" << G4endl;
    20702078    G4cout << "Saving /temp/output.mpg \n" << G4endl;
    20712079    saveVideo("/temp/output.mpg");
     2080    fRecordFrames = false;
    20722081  }
    20732082  if (event->key() == Qt::Key_Space){ // start/pause of video
     2083
     2084    // first time, if parameters are wrong, display parameters dialog and return
     2085    if ((fRecordFrames == false) && (getEncoderPath() == NULL)) {
     2086      showMovieParametersDialog();
     2087      return;
     2088    }
    20742089    fRecordFrames = !fRecordFrames;
    20752090    if (fRecordFrames) {
    2076       G4cout << "Recording Start... \n" << G4endl;
     2091      GLWidget->setCaption( tr( " Start Recording " ));
     2092      G4cout << " Start Recording \n" << G4endl;
    20772093    } else {
    2078       G4cout << "Recording Pause... \n" << G4endl;
     2094      GLWidget->setCaption( tr( " Pause Recording" ));
     2095      G4cout << "Pause Recording \n" << G4endl;
    20792096    }
    20802097  }
     
    21032120 
    21042121
    2105 /** @return if encoder path was not specified, try to guess it and open the movie parameter dialog box.
    2106  * if path was already specified, return it.
     2122/** @return if encoder path was not specified, try to guess it.
     2123 * if path was already specified, return it.Else return ""
    21072124 */
    21082125QString G4OpenGLQtViewer::getEncoderPath() {
    2109   if (fEncoderPath == NULL) {
    2110    
    2111     //look for encoderPath
    2112     QProcess search;
    2113     search.setReadChannelMode(QProcess::MergedChannels);
    2114     search.start ("which mpeg_encode");
    2115    
    2116     if (search.waitForFinished()) {
    2117       fEncoderPath = QString::fromLocal8Bit(search.readAll());
    2118     }
    2119     G4OpenGLQtMovieDialog* movieDialog= new G4OpenGLQtMovieDialog(GLWindow);
    2120     movieDialog->show();
    2121   } else {
    2122     return fEncoderPath ;
    2123   }
     2126
     2127   if (fEncoderPath.isNull())
     2128     fEncoderPath ="";
     2129   if (fEncoderPath.isEmpty()) {
     2130 
     2131     //look for encoderPath
     2132     QProcess search;
     2133     search.setReadChannelMode(QProcess::MergedChannels);
     2134     search.start ("which mpeg_encode");
     2135 
     2136     if (search.waitForFinished()) {
     2137       fEncoderPath = QString::fromLocal8Bit(search.readAll());
     2138       // if not found, return "not found"
     2139       if (fEncoderPath.contains(" ")) {
     2140         fEncoderPath = "";
     2141       } else if (!fEncoderPath.contains("mpeg_encode")) {
     2142         fEncoderPath = "";
     2143       }
     2144     }
     2145   }
     2146  return fEncoderPath ;
    21242147}
    21252148 
Note: See TracChangeset for help on using the changeset viewer.