Changeset 731 for trunk/geant4/visualization/OpenGL
- Timestamp:
- Feb 26, 2008, 12:50:22 PM (17 years ago)
- Location:
- trunk/geant4/visualization/OpenGL
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/geant4/visualization/OpenGL/include/G4OpenGLQtMovieDialog.hh
r730 r731 45 45 class QLabel; 46 46 class QLineEdit; 47 class G4OpenGLQtViewer; 47 48 48 49 #if QT_VERSION >= 0x040000 … … 61 62 @param parent : parent widget 62 63 */ 63 G4OpenGLQtMovieDialog( QWidget* parent);64 G4OpenGLQtMovieDialog(G4OpenGLQtViewer*,QWidget*); 64 65 65 66 /** Destroys G4OpenGLQtMovieDialog */ … … 69 70 QLineEdit* fSelectPath; 70 71 QString fTmpDir; 71 QWidget *fParent;72 G4OpenGLQtViewer *fParentViewer; 72 73 73 74 private slots : -
trunk/geant4/visualization/OpenGL/include/G4OpenGLQtViewer.hh
r730 r731 59 59 60 60 class G4OpenGLSceneHandler; 61 class G4OpenGLQtMovieDialog; 61 62 62 63 class G4OpenGLQtViewer: public QObject, virtual public G4OpenGLViewer { … … 112 113 bool generateVectorEPS (QString,int,int,QImage); 113 114 bool generatePS_PDF(QString,int,QImage); 115 void showMovieParametersDialog(); 114 116 115 117 #if QT_VERSION < 0x040000 … … 152 154 QAction *fDrawingSurfaceRemoval; 153 155 QAction *fDrawingLineSurfaceRemoval; 156 G4OpenGLQtMovieDialog* movieParametersDialog; 154 157 155 158 private slots : … … 161 164 void actionDrawingSurfaceRemoval(); 162 165 void actionDrawingLineSurfaceRemoval(); 163 void action CreateEPS();164 void action CreateMovie();166 void actionSaveImage(); 167 void actionMovieParameters(); 165 168 166 169 void showShortcuts(); -
trunk/geant4/visualization/OpenGL/src/G4OpenGLQtMovieDialog.cc
r730 r731 66 66 67 67 G4OpenGLQtMovieDialog::G4OpenGLQtMovieDialog( 68 QWidget* parent 68 G4OpenGLQtViewer* parentViewer, 69 QWidget* parentWidget 69 70 ) 70 : QDialog( parent ),71 fParent (parent)71 : QDialog( parentWidget ), 72 fParentViewer(parentViewer) 72 73 { 73 74 setModal(false); … … 126 127 #endif 127 128 128 fSelectPath->setText( ((G4OpenGLQtViewer*)fParent)->getEncoderPath());129 fSelectPath->setText(fParentViewer->getEncoderPath()); 129 130 130 131 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 301 301 ,fHoldRotateEvent(false) 302 302 ,fAutoMove(false) 303 ,fEncoderPath(NULL)304 303 { 305 304 #ifdef GEANT4_QT_DEBUG 305 fEncoderPath = ""; 306 306 printf("G4OpenGLQtViewer::G4OpenGLQtViewer \n"); 307 307 #endif … … 645 645 SIGNAL(activated()), 646 646 this, 647 SLOT(action CreateEPS()));647 SLOT(actionSaveImage())); 648 648 649 649 #else … … 654 654 SIGNAL(triggered()), 655 655 this, 656 SLOT(action CreateEPS()));656 SLOT(actionSaveImage())); 657 657 #endif 658 658 659 659 #if QT_VERSION < 0x040000 660 660 #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, 667 667 SIGNAL(activated()), 668 668 this, 669 SLOT(action CreateMovie()));669 SLOT(actionMovieParameters())); 670 670 671 671 #else 672 672 // === Action Menu === 673 QAction * createMovie = mActions->addAction("Make movie...");674 QObject ::connect( createMovie,673 QAction *movieParameters = mActions->addAction("Movie parameters..."); 674 QObject ::connect(movieParameters, 675 675 SIGNAL(triggered()), 676 676 this, 677 SLOT(action CreateMovie()));677 SLOT(actionMovieParameters())); 678 678 #endif 679 679 … … 1324 1324 1325 1325 1326 void G4OpenGLQtViewer::action CreateEPS() {1326 void G4OpenGLQtViewer::actionSaveImage() { 1327 1327 QString filters; 1328 1328 #if QT_VERSION < 0x040000 … … 1443 1443 1444 1444 #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 1450 void G4OpenGLQtViewer::actionMovieParameters() { 1451 1452 showMovieParametersDialog(); 1454 1453 #ifdef GEANT4_QT_DEBUG 1455 printf("G4OpenGLQtViewer::actionCreateMovie() \n"); 1456 #endif 1457 } 1454 printf("G4OpenGLQtViewer::actionMovieParameters() \n"); 1455 #endif 1456 } 1457 1458 1459 void G4OpenGLQtViewer::showMovieParametersDialog() { 1460 if (!movieParametersDialog) { 1461 movieParametersDialog= new G4OpenGLQtMovieDialog(this,GLWindow); 1462 } 1463 movieParametersDialog->show(); 1464 } 1465 1458 1466 1459 1467 /* … … 2066 2074 2067 2075 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; 2070 2078 G4cout << "Saving /temp/output.mpg \n" << G4endl; 2071 2079 saveVideo("/temp/output.mpg"); 2080 fRecordFrames = false; 2072 2081 } 2073 2082 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 } 2074 2089 fRecordFrames = !fRecordFrames; 2075 2090 if (fRecordFrames) { 2076 G4cout << "Recording Start... \n" << G4endl; 2091 GLWidget->setCaption( tr( " Start Recording " )); 2092 G4cout << " Start Recording \n" << G4endl; 2077 2093 } else { 2078 G4cout << "Recording Pause... \n" << G4endl; 2094 GLWidget->setCaption( tr( " Pause Recording" )); 2095 G4cout << "Pause Recording \n" << G4endl; 2079 2096 } 2080 2097 } … … 2103 2120 2104 2121 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 "" 2107 2124 */ 2108 2125 QString 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 ; 2124 2147 } 2125 2148
Note: See TracChangeset
for help on using the changeset viewer.