Changeset 750 for trunk


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

avancement sur le encode

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

Legend:

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

    r747 r750  
    7575  QLabel *fRecordingInfos;
    7676  QPushButton *fButtonEncode;
     77  QPushButton *fButtonApply;
    7778
    7879  bool checkEncoderParameters(QString);
     
    8889  void selectSaveFileNameAction();
    8990  void encode();
     91  void resetRecording();
    9092};
    9193
  • trunk/geant4/visualization/OpenGL/include/G4OpenGLQtViewer.hh

    r749 r750  
    5757class QMouseEvent;
    5858class QKeyEvent;
     59class QProcess;
    5960
    6061class G4OpenGLSceneHandler;
     
    8182  bool isStopped();
    8283  bool isReadyToEncode();
    83   bool encodeVideo();
     84  void resetRecording();
     85  void encodeVideo();
    8486  bool generateMpegEncoderParameters();
    8587
     
    115117private:
    116118  enum mouseActions {STYLE1,STYLE2,STYLE3,STYLE4};
    117   enum RECORDING_STEP {WAIT,START,PAUSE,CONTINUE,STOP,READY_TO_ENCODE,ENCODE};
     119  enum RECORDING_STEP {WAIT,START,PAUSE,CONTINUE,STOP,READY_TO_ENCODE,ENCODE,FAILED,SUCCESS};
    118120
    119121  void createPopupMenu();
     
    202204  void toggleAux(bool);
    203205  void toggleFullScreen(bool);
     206  void processFinished(int);
     207  void processStdout();
    204208  // Only use for Qt>4.0
    205209  //  void dialogClosed();
  • trunk/geant4/visualization/OpenGL/src/G4OpenGLQtMovieDialog.cc

    r748 r750  
    238238  buttonBoxLayout->addWidget(buttonCancel);
    239239
    240   QPushButton *buttonApply = new QPushButton( tr( "&Apply" ),buttonBox );
    241   buttonApply->setAutoDefault( TRUE );
    242   buttonApply->setDefault( TRUE );
    243   buttonBoxLayout->addWidget(buttonApply);
     240  QPushButton *buttonReset = new QPushButton( tr( "&Reset" ),buttonBox );
     241  buttonReset->setAutoDefault( TRUE );
     242  buttonBoxLayout->addWidget(buttonReset);
     243
     244  fButtonApply = new QPushButton( tr( "&Apply" ),buttonBox );
     245  fButtonApply->setAutoDefault( TRUE );
     246  fButtonApply->setEnabled(true);
     247  buttonBoxLayout->addWidget(fButtonApply);
    244248
    245249  fButtonEncode = new QPushButton( tr( "&Encode" ),buttonBox );
     
    260264
    261265  // signals and slots connections
    262   connect( buttonApply, SIGNAL( clicked() ), this, SLOT( checkAllParameters() ) );
     266  connect( fButtonApply, SIGNAL( clicked() ), this, SLOT( checkAllParameters() ) );
     267  connect( buttonReset, SIGNAL( clicked() ), this, SLOT( resetRecording() ) );
    263268  connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
    264269  connect( fButtonEncode, SIGNAL( clicked() ), this, SLOT( encode() ) );
     
    268273  fEncoderPath->setText(fParentViewer->getEncoderPath());
    269274  fTempFolderPath->setText(fParentViewer->getTempFolderPath());
     275
     276  // connect line edit signals
     277  connect (fEncoderPath,SIGNAL(textEdited ( const QString&)),fButtonApply,SLOT(setEnabled(true)));
     278  connect (fTempFolderPath,SIGNAL(textEdited ( const QString&)),fButtonApply,SLOT(setEnabled(true)));
     279  connect (fSaveFileName,SIGNAL(textEdited ( const QString&)),fButtonApply,SLOT(setEnabled(true)));
    270280
    271281  if (fParentViewer->getEncoderPath() == "") {
     
    289299    return;
    290300  }
    291   checkEncoderParameters(nomFich);
     301  fEncoderPath->setText(nomFich);
     302  checkAllParameters();
    292303 }
     304
    293305
    294306void G4OpenGLQtMovieDialog::selectTempPathAction()
     
    300312    return;
    301313  }
    302   checkTempFolderParameters(nomFich);
     314  fTempFolderPath->setText(nomFich);
     315  checkAllParameters();
    303316 }
     317
    304318
    305319void G4OpenGLQtMovieDialog::selectSaveFileNameAction()
     
    311325    return;
    312326  }
    313   checkSaveFileNameParameters(nomFich);
     327  fSaveFileName->setText(nomFich);
     328  checkAllParameters();
    314329 }
     330
    315331
    316332void G4OpenGLQtMovieDialog::encode() {
     
    334350    }
    335351  }
     352  fButtonApply->setEnabled(false);
    336353}
    337354
     
    397414
    398415  QString temp = fParentViewer->setSaveFileName(param);
    399     fSaveFileStatus->setText(temp);
     416  fSaveFileStatus->setText(temp);
    400417  if (temp != "") {
    401418    palette.setColor( QPalette::Base, Qt::red);
     
    410427
    411428
     429void G4OpenGLQtMovieDialog::resetRecording() {
     430  fParentViewer->resetRecording();
     431}
     432
     433
    412434void G4OpenGLQtMovieDialog::setRecordingStatus(QString txt) {
    413435  fButtonEncode->setEnabled(fParentViewer->isReadyToEncode());
     
    415437}
    416438
     439
    417440void G4OpenGLQtMovieDialog::setRecordingInfos(QString txt) {
    418441  fRecordingInfos->setText(txt);
  • trunk/geant4/visualization/OpenGL/src/G4OpenGLQtViewer.cc

    r749 r750  
    324324//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
    325325{
    326   G4cout <<removeTempFolder().toStdString().c_str();
     326  G4cout <<removeTempFolder().toStdString().c_str() <<G4endl;
    327327#ifdef GEANT4_QT_DEBUG
    328328  printf("G4OpenGLQtViewer::~G4OpenGLQtViewer \n");
     
    13191319#endif
    13201320  if (res == false) {
    1321     setRecordingStatus(WAIT);
     1321    resetRecording();
    13221322    setRecordingInfos("Can't save tmp file "+filePath);
    13231323    return;
     
    21292129    fMovieParametersDialog->checkAllParameters();
    21302130  } else {
    2131     setRecordingStatus(WAIT);
     2131    resetRecording();
    21322132    setRecordingInfos("No frame to encode.");
    21332133  }
     
    21752175void G4OpenGLQtViewer::setRecordingStatus(RECORDING_STEP step) {
    21762176 
    2177 #ifdef GEANT4_QT_DEBUG
    2178   printf("setRecordingStatus \n");
    2179 #endif
    21802177  QString txt = "";
    21812178  if (step == WAIT) {
     
    21942191  } else if (step == ENCODE) {
    21952192    txt  = "Encoding...";
     2193  } else if (step == FAILED) {
     2194    txt  = "Failed to encode...";
    21962195  } else {
    21972196  }
     
    22972296}
    22982297
     2298void G4OpenGLQtViewer::resetRecording() {
     2299    setRecordingStatus(WAIT);
     2300}
    22992301
    23002302/**
     
    24322434  if (res) {
    24332435    if (d->rmdir(fMovieTempFolderPath)) {
     2436      fMovieTempFolderPath = "";
    24342437      return "";
    24352438    } else {
     
    26462649void G4OpenGLQtViewer::encodeVideo()
    26472650{
     2651#ifdef GEANT4_QT_DEBUG
     2652  printf("G4OpenGLQtViewer::encodeVideo \n");
     2653#endif
    26482654  if ((getEncoderPath() != "") && (getSaveFileName() != "")) {
    26492655    fProcess = new QProcess();
    26502656    fProcess->execute (fEncoderPath, QStringList(fMovieTempFolderPath+fParameterFileName));
    2651   QObject ::connect(fProcess,
    2652                     SIGNAL(finished ( int exitCode, QProcess::ExitStatus exitStatus )),
    2653                     this,
    2654                     SLOT(processFinished( int exitCode, QProcess::ExitStatus exitStatus ));
    2655   }
    2656 }
    2657 
    2658       setRecordingStatus(WAIT);
    2659       setRecordingInfos(removeTempFolder());
     2657#if QT_VERSION > 0x040100
     2658        QObject ::connect(fProcess,SIGNAL(finished ( int,QProcess::ExitStatus)),
     2659                      this,SLOT(processFinished( int));
     2660#else
     2661#if QT_VERSION > 0x040000
     2662        QObject ::connect(fProcess,SIGNAL(finished ( int)),
     2663                      this,SLOT(processFinished( int)));
     2664        QObject ::connect(fProcess,SIGNAL(readyReadStandardOutput ()),
     2665                      this,SLOT(processStdout()));
     2666#else
     2667        QObject ::connect(fProcess,SIGNAL(finished ( int)),
     2668                      this,SLOT(processFinished( int)));
     2669        QObject ::connect(fProcess,SIGNAL(readyReadStdOut ()),
     2670                      this,SLOT(processStdout()));
     2671#endif
     2672#endif
     2673  }
     2674#ifdef GEANT4_QT_DEBUG
     2675  printf("G4OpenGLQtViewer::encodeVideo END\n");
     2676#endif
     2677}
     2678
     2679
     2680void G4OpenGLQtViewer::processStdout()
     2681{
     2682#ifdef GEANT4_QT_DEBUG
     2683  printf("processStdout \n");
     2684#endif
     2685#ifdef GEANT4_QT_DEBUG
     2686#if QT_VERSION > 0x040100
     2687#else
     2688#if QT_VERSION > 0x040000
     2689  printf("processStdout %s\n",fProcess->readAllStandardOutput ().data());
     2690#else
     2691  printf("processStdout %s\n",fProcess->readStdout ().data());
     2692
     2693#endif
     2694#endif
     2695#endif
     2696#ifdef GEANT4_QT_DEBUG
     2697  printf("processStdout END\n");
     2698#endif
     2699}
     2700
     2701
     2702void G4OpenGLQtViewer::processFinished(int exitCode)
     2703{
     2704#ifdef GEANT4_QT_DEBUG
     2705  printf("processFinished \n");
     2706#endif
     2707
     2708  QString txt = "";
     2709  if (exitCode) {
     2710    setRecordingStatus(SUCCESS);
     2711  } else {
     2712    QString txt;
     2713        switch (fProcess->error()) {
     2714          case QProcess::FailedToStart:
     2715        txt = "The process failed to start. Either the invoked program is missing, or you may have insufficient permissions to invoke the program.";
     2716                break;
     2717          case QProcess::Crashed:
     2718        txt = "The process crashed some time after starting successfully.";
     2719                break;
     2720          case QProcess::Timedout:
     2721        txt = "The last waitFor...() function timed out. The state of QProcess is unchanged, and you can try calling waitFor...() again.";
     2722                break;
     2723          case QProcess::WriteError:
     2724        txt = "An error occurred when attempting to write to the process. For example, the process may not be running, or it may have closed its input channel.";
     2725            break;
     2726          case QProcess::ReadError:
     2727        txt = "An error occurred when attempting to read from the process. For example, the process may not be running.";
     2728            break;
     2729          case QProcess::UnknownError:
     2730        txt = "An unknown error occurred. This is the default return value of error().";
     2731                break;
     2732    }
     2733    setRecordingStatus(FAILED);
     2734  }
     2735  setRecordingInfos(txt+"\n"+removeTempFolder());
     2736#ifdef GEANT4_QT_DEBUG
     2737  printf("processFinished END\n");
     2738#endif
     2739}
    26602740
    26612741/*
Note: See TracChangeset for help on using the changeset viewer.