Changeset 732 for trunk/geant4/visualization/OpenGL
- Timestamp:
- Feb 27, 2008, 11:49:37 AM (16 years ago)
- Location:
- trunk/geant4/visualization/OpenGL
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/geant4/visualization/OpenGL/include/G4OpenGLQtMovieDialog.hh
r731 r732 39 39 class QButtonGroup; 40 40 class QPushButton; 41 class QRadioButton;42 class QCheckBox;43 class QSlider;44 class QComboBox;45 41 class QLabel; 46 42 class QLineEdit; … … 68 64 69 65 private : 70 QLineEdit* f SelectPath;71 Q String fTmpDir;66 QLineEdit* fEncoderPath; 67 QLineEdit* fTempPath; 72 68 G4OpenGLQtViewer *fParentViewer; 69 QLabel *fCheckLabel; 73 70 74 71 private slots : 75 72 void selectPathAction(); 73 void checkMovieParameters(); 76 74 }; 77 75 -
trunk/geant4/visualization/OpenGL/include/G4OpenGLQtViewer.hh
r731 r732 72 72 virtual void updateQWidget()=0; 73 73 void setupViewport(int, int); 74 voidsetEncoderPath(QString path);74 bool setEncoderPath(QString path); 75 75 QString getEncoderPath(); 76 bool setTempFolderPath(QString path); 77 QString getTempFolderPath(); 76 78 77 79 protected: … … 145 147 bool fAutoMove; 146 148 QString fEncoderPath; 149 QString fTempFolderPath; 147 150 QAction *fRotateAction; 148 151 QAction *fMoveAction; … … 154 157 QAction *fDrawingSurfaceRemoval; 155 158 QAction *fDrawingLineSurfaceRemoval; 156 G4OpenGLQtMovieDialog* movieParametersDialog;159 G4OpenGLQtMovieDialog* fMovieParametersDialog; 157 160 158 161 private slots : -
trunk/geant4/visualization/OpenGL/src/G4OpenGLQtMovieDialog.cc
r731 r732 36 36 #include "G4OpenGLQtViewer.hh" 37 37 38 // #include <qvariant.h>39 38 #include <qpushbutton.h> 40 // #include <qcheckbox.h>39 #include <qpalette.h> 41 40 #include <qlabel.h> 42 // #include <qcombobox.h>43 // #include <qslider.h>44 41 #include <qlayout.h> 45 // #include <qgroupbox.h>46 // #include <qradiobutton.h>47 // #include <qimage.h>48 42 #include <qlineedit.h> 49 43 #include <qfiledialog.h> 50 44 #include <qprocess.h> 51 45 52 // #include <qbuttongroup.h>53 46 54 47 // +---------------------------------------+ 55 48 // + Path for encoder + 49 // + _______ + 50 // + | select| ____________________ + 51 // + ------- + 52 // + Temp path + 56 53 // + _______ + 57 54 // + | select| ____________________ + … … 94 91 95 92 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 130 162 131 163 QLabel *infoLabel = new QLabel(" Press SPACE to Start/Pause video recording \n Press RETURN to Stop video recording"); … … 137 169 #endif 138 170 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 139 181 QWidget *buttonBox = new QWidget(this); 140 182 141 183 QHBoxLayout *buttonBoxLayout = new QHBoxLayout(buttonBox); 142 184 185 QPushButton *buttonCancel = new QPushButton( tr( "&Cancel" ),buttonBox ); 186 buttonCancel->setAutoDefault( TRUE ); 187 buttonBoxLayout->addWidget(buttonCancel); 143 188 144 189 QPushButton * buttonEncode = new QPushButton( tr( "&Apply" ),buttonBox ); … … 147 192 buttonBoxLayout->addWidget(buttonEncode); 148 193 149 QPushButton *buttonCancel = new QPushButton( tr( "&Cancel" ),buttonBox );150 buttonCancel->setAutoDefault( TRUE );151 buttonBoxLayout->addWidget(buttonCancel);152 153 194 #if QT_VERSION >= 0x040000 154 195 buttonBox->setLayout(buttonBoxLayout); … … 163 204 164 205 // signals and slots connections 165 connect( buttonEncode, SIGNAL( clicked() ), this, SLOT( accept() ) );206 connect( buttonEncode, SIGNAL( clicked() ), this, SLOT( checkMovieParameters() ) ); 166 207 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); 167 208 } … … 181 222 return; 182 223 } 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 */ 230 void 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 301 301 ,fHoldRotateEvent(false) 302 302 ,fAutoMove(false) 303 ,fEncoderPath("") 304 ,fTempFolderPath("/temp") 305 ,fMovieParametersDialog(NULL) 303 306 { 304 307 #ifdef GEANT4_QT_DEBUG 305 fEncoderPath = "";306 308 printf("G4OpenGLQtViewer::G4OpenGLQtViewer \n"); 307 309 #endif … … 1458 1460 1459 1461 void 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(); 1464 1466 } 1465 1467 … … 2074 2076 2075 2077 if ((event->key() == Qt::Key_Return) || (event->key() == Qt::Key_Enter)){ // end of video 2076 GLWidget->setCaption( tr( " Stop Recording " ));2077 2078 G4cout << "Stop Recording \n" << G4endl; 2078 2079 G4cout << "Saving /temp/output.mpg \n" << G4endl; … … 2089 2090 fRecordFrames = !fRecordFrames; 2090 2091 if (fRecordFrames) { 2091 GLWidget->setCaption( tr( " Start Recording " ));2092 2092 G4cout << " Start Recording \n" << G4endl; 2093 2093 } else { 2094 GLWidget->setCaption( tr( " Pause Recording" ));2095 2094 G4cout << "Pause Recording \n" << G4endl; 2096 2095 } … … 2135 2134 2136 2135 if (search.waitForFinished()) { 2137 fEncoderPath = QString ::fromLocal8Bit(search.readAll());2136 fEncoderPath = QString(QString::fromLocal8Bit(search.readAll())).trimmed(); 2138 2137 // if not found, return "not found" 2139 2138 if (fEncoderPath.contains(" ")) { … … 2150 2149 /** 2151 2150 * set the new encoder path 2151 * @return true if the path exist and file is executable, false otherwise 2152 2152 */ 2153 void G4OpenGLQtViewer::setEncoderPath(QString path) { 2153 bool 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 } 2154 2167 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 */ 2175 bool 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 */ 2203 QString G4OpenGLQtViewer::getTempFolderPath() { 2204 return fTempFolderPath ; 2205 } 2206 2207 2156 2208 2157 2209
Note: See TracChangeset
for help on using the changeset viewer.