Changeset 750 for trunk/geant4/visualization
- Timestamp:
- Mar 10, 2008, 2:17:54 PM (17 years ago)
- Location:
- trunk/geant4/visualization/OpenGL
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/geant4/visualization/OpenGL/include/G4OpenGLQtMovieDialog.hh
r747 r750 75 75 QLabel *fRecordingInfos; 76 76 QPushButton *fButtonEncode; 77 QPushButton *fButtonApply; 77 78 78 79 bool checkEncoderParameters(QString); … … 88 89 void selectSaveFileNameAction(); 89 90 void encode(); 91 void resetRecording(); 90 92 }; 91 93 -
trunk/geant4/visualization/OpenGL/include/G4OpenGLQtViewer.hh
r749 r750 57 57 class QMouseEvent; 58 58 class QKeyEvent; 59 class QProcess; 59 60 60 61 class G4OpenGLSceneHandler; … … 81 82 bool isStopped(); 82 83 bool isReadyToEncode(); 83 bool encodeVideo(); 84 void resetRecording(); 85 void encodeVideo(); 84 86 bool generateMpegEncoderParameters(); 85 87 … … 115 117 private: 116 118 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}; 118 120 119 121 void createPopupMenu(); … … 202 204 void toggleAux(bool); 203 205 void toggleFullScreen(bool); 206 void processFinished(int); 207 void processStdout(); 204 208 // Only use for Qt>4.0 205 209 // void dialogClosed(); -
trunk/geant4/visualization/OpenGL/src/G4OpenGLQtMovieDialog.cc
r748 r750 238 238 buttonBoxLayout->addWidget(buttonCancel); 239 239 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); 244 248 245 249 fButtonEncode = new QPushButton( tr( "&Encode" ),buttonBox ); … … 260 264 261 265 // 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() ) ); 263 268 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); 264 269 connect( fButtonEncode, SIGNAL( clicked() ), this, SLOT( encode() ) ); … … 268 273 fEncoderPath->setText(fParentViewer->getEncoderPath()); 269 274 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))); 270 280 271 281 if (fParentViewer->getEncoderPath() == "") { … … 289 299 return; 290 300 } 291 checkEncoderParameters(nomFich); 301 fEncoderPath->setText(nomFich); 302 checkAllParameters(); 292 303 } 304 293 305 294 306 void G4OpenGLQtMovieDialog::selectTempPathAction() … … 300 312 return; 301 313 } 302 checkTempFolderParameters(nomFich); 314 fTempFolderPath->setText(nomFich); 315 checkAllParameters(); 303 316 } 317 304 318 305 319 void G4OpenGLQtMovieDialog::selectSaveFileNameAction() … … 311 325 return; 312 326 } 313 checkSaveFileNameParameters(nomFich); 327 fSaveFileName->setText(nomFich); 328 checkAllParameters(); 314 329 } 330 315 331 316 332 void G4OpenGLQtMovieDialog::encode() { … … 334 350 } 335 351 } 352 fButtonApply->setEnabled(false); 336 353 } 337 354 … … 397 414 398 415 QString temp = fParentViewer->setSaveFileName(param); 399 416 fSaveFileStatus->setText(temp); 400 417 if (temp != "") { 401 418 palette.setColor( QPalette::Base, Qt::red); … … 410 427 411 428 429 void G4OpenGLQtMovieDialog::resetRecording() { 430 fParentViewer->resetRecording(); 431 } 432 433 412 434 void G4OpenGLQtMovieDialog::setRecordingStatus(QString txt) { 413 435 fButtonEncode->setEnabled(fParentViewer->isReadyToEncode()); … … 415 437 } 416 438 439 417 440 void G4OpenGLQtMovieDialog::setRecordingInfos(QString txt) { 418 441 fRecordingInfos->setText(txt); -
trunk/geant4/visualization/OpenGL/src/G4OpenGLQtViewer.cc
r749 r750 324 324 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 325 325 { 326 G4cout <<removeTempFolder().toStdString().c_str() ;326 G4cout <<removeTempFolder().toStdString().c_str() <<G4endl; 327 327 #ifdef GEANT4_QT_DEBUG 328 328 printf("G4OpenGLQtViewer::~G4OpenGLQtViewer \n"); … … 1319 1319 #endif 1320 1320 if (res == false) { 1321 setRecordingStatus(WAIT);1321 resetRecording(); 1322 1322 setRecordingInfos("Can't save tmp file "+filePath); 1323 1323 return; … … 2129 2129 fMovieParametersDialog->checkAllParameters(); 2130 2130 } else { 2131 setRecordingStatus(WAIT);2131 resetRecording(); 2132 2132 setRecordingInfos("No frame to encode."); 2133 2133 } … … 2175 2175 void G4OpenGLQtViewer::setRecordingStatus(RECORDING_STEP step) { 2176 2176 2177 #ifdef GEANT4_QT_DEBUG2178 printf("setRecordingStatus \n");2179 #endif2180 2177 QString txt = ""; 2181 2178 if (step == WAIT) { … … 2194 2191 } else if (step == ENCODE) { 2195 2192 txt = "Encoding..."; 2193 } else if (step == FAILED) { 2194 txt = "Failed to encode..."; 2196 2195 } else { 2197 2196 } … … 2297 2296 } 2298 2297 2298 void G4OpenGLQtViewer::resetRecording() { 2299 setRecordingStatus(WAIT); 2300 } 2299 2301 2300 2302 /** … … 2432 2434 if (res) { 2433 2435 if (d->rmdir(fMovieTempFolderPath)) { 2436 fMovieTempFolderPath = ""; 2434 2437 return ""; 2435 2438 } else { … … 2646 2649 void G4OpenGLQtViewer::encodeVideo() 2647 2650 { 2651 #ifdef GEANT4_QT_DEBUG 2652 printf("G4OpenGLQtViewer::encodeVideo \n"); 2653 #endif 2648 2654 if ((getEncoderPath() != "") && (getSaveFileName() != "")) { 2649 2655 fProcess = new QProcess(); 2650 2656 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 2680 void 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 2702 void 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 } 2660 2740 2661 2741 /*
Note: See TracChangeset
for help on using the changeset viewer.