Changeset 733 for trunk/geant4
- Timestamp:
- Mar 4, 2008, 2:29:54 PM (17 years ago)
- Location:
- trunk/geant4/visualization/OpenGL
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/geant4/visualization/OpenGL/include/G4OpenGLQtMovieDialog.hh
r732 r733 65 65 private : 66 66 QLineEdit* fEncoderPath; 67 QLineEdit* fTempPath; 67 QLineEdit* fTempFolderPath; 68 QLineEdit* fSaveFileName; 68 69 G4OpenGLQtViewer *fParentViewer; 69 QLabel *fCheckLabel; 70 QLabel *fEncoderStatus; 71 QLabel *fTempFolderStatus; 72 QLabel *fSaveFileStatus; 73 QLabel *fGlobalStatus; 74 75 void checkEncoderParameters(QString); 76 void checkTempFolderParameters(QString); 77 void checkSaveFileNameParameters(QString); 70 78 71 79 private slots : 72 void selectPathAction(); 73 void checkMovieParameters(); 80 void selectEncoderPathAction(); 81 void selectTempPathAction(); 82 void selectSaveFileNameAction(); 83 void checkAllParameters(); 84 void encode(); 74 85 }; 75 86 -
trunk/geant4/visualization/OpenGL/include/G4OpenGLQtViewer.hh
r732 r733 72 72 virtual void updateQWidget()=0; 73 73 void setupViewport(int, int); 74 boolsetEncoderPath(QString path);74 QString setEncoderPath(QString path); 75 75 QString getEncoderPath(); 76 boolsetTempFolderPath(QString path);76 QString setTempFolderPath(QString path); 77 77 QString getTempFolderPath(); 78 QString setSaveFileName(QString path); 79 QString getSaveFileName(); 78 80 79 81 protected: … … 148 150 QString fEncoderPath; 149 151 QString fTempFolderPath; 152 QString fSaveFileName; 150 153 QAction *fRotateAction; 151 154 QAction *fMoveAction; -
trunk/geant4/visualization/OpenGL/src/G4OpenGLQtMovieDialog.cc
r732 r733 39 39 #include <qpalette.h> 40 40 #include <qlabel.h> 41 #include <qgroupbox.h> 41 42 #include <qlayout.h> 42 43 #include <qlineedit.h> … … 82 83 globalVLayout->setSpacing(10); 83 84 84 QLabel *pathLabel = new QLabel("Select path for encoder :"); 85 86 #if QT_VERSION < 0x040000 87 globalVLayout->add(pathLabel); 88 #else 89 globalVLayout->addWidget(pathLabel); 90 #endif 91 85 // Encoder group box 86 QGroupBox *encoderGroupBox = new QGroupBox(tr("Encoder path")); 87 QVBoxLayout *encoderVBoxLayout = new QVBoxLayout(encoderGroupBox); 88 #ifdef GEANT4_QT_DEBUG 89 printf("1111\n"); 90 #endif 92 91 93 92 // 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); 93 QWidget *encoderHBox = new QWidget(encoderGroupBox); 94 QHBoxLayout *encoderHBoxLayout = new QHBoxLayout(encoderHBox); 95 fEncoderPath = new QLineEdit("",encoderHBox); 96 97 QPushButton *encoderButton = new QPushButton(tr("..."),encoderHBox); 105 98 encoderButton->setMaximumWidth (30); 106 99 107 #if QT_VERSION < 0x040000 108 selectPathLineLayout->add(encoderButton); 109 #else 110 selectPathLineLayout->addWidget(encoderButton); 111 #endif 112 100 fEncoderStatus = new QLabel(encoderGroupBox); 101 fEncoderStatus->setText(""); 102 103 #ifdef GEANT4_QT_DEBUG 104 printf("2222\n"); 105 #endif 106 #if QT_VERSION < 0x040000 107 encoderHBoxLayout->add(fEncoderPath); 108 encoderHBoxLayout->add(encoderButton); 109 encoderVBoxLayout->add(fEncoderStatus); 110 #else 111 encoderHBoxLayout->addWidget(fEncoderPath); 112 encoderHBoxLayout->addWidget(encoderButton); 113 encoderVBoxLayout->addWidget(fEncoderStatus); 114 #endif 115 116 #ifdef GEANT4_QT_DEBUG 117 printf("33333\n"); 118 #endif 113 119 #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); 120 // encoderHBox->setLayout(encoderHBoxLayout); 121 encoderGroupBox->setLayout(encoderVBoxLayout); 122 #endif 123 connect( encoderButton, SIGNAL( clicked( ) ), this, SLOT(selectEncoderPathAction() ) ); 124 #ifdef GEANT4_QT_DEBUG 125 printf("4444\n"); 126 #endif 127 128 #if QT_VERSION < 0x040000 129 globalVLayout->add(encoderGroupBox); 130 #else 131 globalVLayout->addWidget(encoderGroupBox); 122 132 #endif 123 133 … … 125 135 126 136 137 // temp folder group box 138 QGroupBox *tempFolderGroupBox = new QGroupBox(tr("Temporary folder path")); 139 QVBoxLayout *tempFolderVBoxLayout = new QVBoxLayout(tempFolderGroupBox); 140 127 141 // 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); 142 QWidget *tempFolderHBox = new QWidget(tempFolderGroupBox); 143 QHBoxLayout *tempFolderHBoxLayout = new QHBoxLayout(tempFolderGroupBox); 144 145 fTempFolderPath = new QLineEdit("",tempFolderHBox); 146 147 QPushButton *tempButton = new QPushButton(tr("..."),tempFolderHBox); 139 148 tempButton->setMaximumWidth (30); 140 149 141 #if QT_VERSION < 0x040000 142 selectEncoderLineLayout->add(tempButton); 143 #else 144 selectEncoderLineLayout->addWidget(tempButton); 145 #endif 146 150 fTempFolderStatus = new QLabel(tempFolderGroupBox); 151 fTempFolderStatus->setText(""); 152 153 #ifdef GEANT4_QT_DEBUG 154 printf("5555\n"); 155 #endif 156 #if QT_VERSION < 0x040000 157 tempFolderHBoxLayout->add(fTempFolderPath); 158 tempFolderHBoxLayout->add(tempButton); 159 tempFolderVBoxLayout->add(fTempFolderStatus); 160 #else 161 tempFolderHBoxLayout->addWidget(fTempFolderPath); 162 tempFolderHBoxLayout->addWidget(tempButton); 163 tempFolderVBoxLayout->addWidget(fTempFolderStatus); 164 #endif 165 166 #ifdef GEANT4_QT_DEBUG 167 printf("6666\n"); 168 #endif 147 169 #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 170 // tempFolderHBox->setLayout(tempFolderHBoxLayout); 171 tempFolderGroupBox->setLayout(tempFolderVBoxLayout); 172 #endif 173 connect( tempButton, SIGNAL( clicked( ) ), this, SLOT(selectTempPathAction() ) ); 174 175 #ifdef GEANT4_QT_DEBUG 176 printf("77777\n"); 177 #endif 178 #if QT_VERSION < 0x040000 179 globalVLayout->add(tempFolderGroupBox); 180 #else 181 globalVLayout->addWidget(tempFolderGroupBox); 182 #endif 183 184 fTempFolderPath->setText(fParentViewer->getTempFolderPath()); 185 186 // save file group box 187 QGroupBox *saveFileGroupBox = new QGroupBox(tr("Save as")); 188 QVBoxLayout *saveFileVBoxLayout = new QVBoxLayout(saveFileGroupBox); 189 190 // save file 191 QWidget *saveFileHBox = new QWidget(saveFileGroupBox); 192 QHBoxLayout *saveFileHBoxLayout = new QHBoxLayout(saveFileHBox); 193 194 fSaveFileName = new QLineEdit("",saveFileHBox); 195 196 QPushButton *saveButton = new QPushButton(tr("..."),saveFileHBox); 197 saveButton->setMaximumWidth (30); 198 199 fSaveFileStatus = new QLabel(saveFileGroupBox); 200 fSaveFileStatus->setText(""); 201 202 #ifdef GEANT4_QT_DEBUG 203 printf("8888\n"); 204 #endif 205 #if QT_VERSION < 0x040000 206 saveFileHBoxLayout->add(fTempFolderPath); 207 saveFileHBoxLayout->add(saveButton); 208 saveFileVBoxLayout->add(fSaveFileStatus); 209 #else 210 saveFileHBoxLayout->addWidget(fTempFolderPath); 211 saveFileHBoxLayout->addWidget(saveButton); 212 saveFileVBoxLayout->addWidget(fSaveFileStatus); 213 #endif 214 215 #ifdef GEANT4_QT_DEBUG 216 printf("99999\n"); 217 #endif 218 #if QT_VERSION >= 0x040000 219 // saveFileHBox->setLayout(saveFileHBoxLayout); 220 saveFileGroupBox->setLayout(saveFileVBoxLayout); 221 #endif 222 connect( saveButton, SIGNAL( clicked( ) ), this, SLOT(selectSaveFileNameAction() ) ); 223 224 #ifdef GEANT4_QT_DEBUG 225 printf("11110000\n"); 226 #endif 227 #if QT_VERSION < 0x040000 228 globalVLayout->add(saveFileGroupBox); 229 #else 230 globalVLayout->addWidget(saveFileGroupBox); 231 #endif 232 233 #ifdef GEANT4_QT_DEBUG 234 printf("11111111111&\n"); 235 #endif 160 236 161 237 // label … … 163 239 QLabel *infoLabel = new QLabel(" Press SPACE to Start/Pause video recording \n Press RETURN to Stop video recording"); 164 240 241 // global status 242 fGlobalStatus = new QLabel(""); 243 165 244 #if QT_VERSION < 0x040000 166 245 globalVLayout->add(infoLabel); 246 globalVLayout->add(fGlobalStatus); 167 247 #else 168 248 globalVLayout->addWidget(infoLabel); 169 #endif 170 171 // check infos 172 fCheckLabel = new QLabel(""); 173 174 #if QT_VERSION < 0x040000 175 globalVLayout->add(fCheckLabel); 176 #else 177 globalVLayout->addWidget(fCheckLabel); 249 globalVLayout->addWidget(fGlobalStatus); 250 #endif 251 #ifdef GEANT4_QT_DEBUG 252 printf("11112222222222é\n"); 178 253 #endif 179 254 … … 187 262 buttonBoxLayout->addWidget(buttonCancel); 188 263 189 QPushButton * buttonEncode = new QPushButton( tr( "&Apply" ),buttonBox ); 264 QPushButton *buttonApply = new QPushButton( tr( "&Apply" ),buttonBox ); 265 buttonApply->setAutoDefault( TRUE ); 266 buttonBoxLayout->addWidget(buttonApply); 267 268 QPushButton * buttonEncode = new QPushButton( tr( "&Encode" ),buttonBox ); 190 269 buttonEncode->setAutoDefault( TRUE ); 191 270 buttonEncode->setDefault( TRUE ); 192 271 buttonBoxLayout->addWidget(buttonEncode); 193 272 273 #ifdef GEANT4_QT_DEBUG 274 printf("1111333333333333\n"); 275 #endif 194 276 #if QT_VERSION >= 0x040000 195 277 buttonBox->setLayout(buttonBoxLayout); … … 198 280 199 281 282 #ifdef GEANT4_QT_DEBUG 283 printf("1111444444444\n"); 284 #endif 200 285 201 286 #if QT_VERSION >= 0x040000 … … 204 289 205 290 // signals and slots connections 206 connect( button Encode, SIGNAL( clicked() ), this, SLOT( checkMovieParameters() ) );291 connect( buttonApply, SIGNAL( clicked() ), this, SLOT( checkAllParameters() ) ); 207 292 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); 293 connect( buttonEncode, SIGNAL( clicked() ), this, SLOT( encode() ) ); 294 #ifdef GEANT4_QT_DEBUG 295 printf("111155555555\n"); 296 #endif 208 297 } 209 298 … … 214 303 } 215 304 216 void G4OpenGLQtMovieDialog::select PathAction()305 void G4OpenGLQtMovieDialog::selectEncoderPathAction() 217 306 { 218 307 QString nomFich = QFileDialog::getOpenFileName ( this, … … 222 311 return; 223 312 } 224 fEncoderPath->setText(nomFich); 225 } 313 checkEncoderParameters(nomFich); 314 } 315 316 void G4OpenGLQtMovieDialog::selectTempPathAction() 317 { 318 QString nomFich = QFileDialog::getOpenFileName ( this, 319 "Select temporary folder", 320 tr("Select temporary folder ...")); 321 if (nomFich == "") { 322 return; 323 } 324 checkTempFolderParameters(nomFich); 325 } 326 327 void G4OpenGLQtMovieDialog::selectSaveFileNameAction() 328 { 329 QString nomFich = QFileDialog::getOpenFileName ( this, 330 "Select saved file", 331 tr("Select saved file ...")); 332 if (nomFich == "") { 333 return; 334 } 335 checkSaveFileNameParameters(nomFich); 336 } 337 338 void G4OpenGLQtMovieDialog::encode() { 339 } 340 341 /** Check all parameters 342 */ 343 void G4OpenGLQtMovieDialog::checkAllParameters() { 344 checkEncoderParameters(fEncoderPath->text()); 345 checkTempFolderParameters(fTempFolderPath->text()); 346 checkSaveFileNameParameters(fSaveFileName->text()); 347 } 348 349 /** 350 * If one of parameter is incorrect, put it in red and don't valid it 351 * If valid, save it 352 */ 353 void G4OpenGLQtMovieDialog::checkEncoderParameters(QString param) { 354 355 QPalette palette( fEncoderPath->palette() ); 356 357 QString temp = fParentViewer->setEncoderPath(param); 358 fGlobalStatus->setText(""); 359 fEncoderStatus->setText(temp); 360 if (temp != "") { 361 palette.setColor( QPalette::Base, Qt::red); 362 fGlobalStatus->setText("If no valid encode defined, screnn /ncapture files will be saved in /nthe temp folder in ppm format."); 363 } else { 364 palette.setColor( QPalette::Base, Qt::white); 365 fEncoderPath->setText(fParentViewer->getEncoderPath()); 366 } 367 fEncoderPath->setPalette(palette); 368 } 369 226 370 227 371 /** 228 372 * If one of parameter is incorrect, put it in red and don't valid it 373 * If valid, save it 229 374 */ 230 void G4OpenGLQtMovieDialog::checkMovieParameters() { 231 232 fCheckLabel->setText(""); 233 QPalette palette( fEncoderPath->palette() ); 234 235 if (!fParentViewer->setEncoderPath(fEncoderPath->text())) { 375 void G4OpenGLQtMovieDialog::checkTempFolderParameters(QString param) { 376 377 QPalette palette( fTempFolderPath->palette() ); 378 379 QString temp = fParentViewer->setTempFolderPath(param); 380 fTempFolderStatus->setText(temp); 381 if (temp != "") { 236 382 palette.setColor( QPalette::Base, Qt::red); 237 fCheckLabel->setText ("Encoder path does not exist or file is not executable\n");238 383 } else { 239 384 palette.setColor( QPalette::Base, Qt::white); 240 } 241 fEncoderPath->setPalette(palette); 242 243 244 245 if (!fParentViewer->setTempFolderPath(fTempPath->text())) { 385 fTempFolderPath->setText(fParentViewer->getEncoderPath()); 386 } 387 fTempFolderPath->setPalette(palette); 388 } 389 390 391 /** 392 * If one of parameter is incorrect, put it in red and don't valid it 393 * If valid, save it 394 */ 395 void G4OpenGLQtMovieDialog::checkSaveFileNameParameters(QString param) { 396 397 QPalette palette( fSaveFileName->palette() ); 398 399 QString temp = fParentViewer->setSaveFileName(param); 400 fSaveFileStatus->setText(temp); 401 if (temp != "") { 246 402 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 403 } else { 249 404 palette.setColor( QPalette::Base, Qt::white); 250 }251 fTempPath->setPalette(palette);252 } 253 254 #endif 405 fSaveFileName->setText(fParentViewer->getSaveFileName()); 406 } 407 fSaveFileName->setPalette(palette); 408 } 409 #endif -
trunk/geant4/visualization/OpenGL/src/G4OpenGLQtViewer.cc
r732 r733 663 663 QAction *movieParameters = new QAction("&Movie parameters...","&Make movie ...",CTRL+Key_M,mActions,0,true); 664 664 #else 665 QAction *movieParameters = new QAction("&M ake parameters...",CTRL+Key_M,mActions);665 QAction *movieParameters = new QAction("&Movie parameters...",CTRL+Key_M,mActions); 666 666 #endif 667 667 movieParameters->addTo(mActions); … … 1995 1995 1996 1996 fHoldKeyEvent = true; 1997 if (event->key() == Qt::Key_Down) { 1998 #ifdef GEANT4_QT_DEBUG 1999 printf("G4OpenGLQtViewer::G4keyPressEvent Down\n"); 2000 #endif 2001 } else if (event->key() == Qt::Key_Up) { 2002 #ifdef GEANT4_QT_DEBUG 2003 printf("G4OpenGLQtViewer::G4keyPressEvent Up\n"); 2004 #endif 2005 } else if (event->key() == Qt::Key_Plus) { 2006 #ifdef GEANT4_QT_DEBUG 2007 printf("G4OpenGLQtViewer::G4keyPressEvent Plus\n"); 2008 #endif 2009 } else if (event->key() == Qt::Key_Minus) { 2010 #ifdef GEANT4_QT_DEBUG 2011 printf("G4OpenGLQtViewer::G4keyPressEvent Minus\n"); 2012 #endif 2013 } 2014 if (event->modifiers() & Qt::AltModifier ) { 2015 #ifdef GEANT4_QT_DEBUG 2016 printf("G4OpenGLQtViewer::G4keyPressEvent Alt\n"); 2017 #endif 2018 } else if (event->modifiers() & Qt::ShiftModifier) { 2019 #ifdef GEANT4_QT_DEBUG 2020 printf("G4OpenGLQtViewer::G4keyPressEvent Shift\n"); 2021 #endif 2022 } 1997 2023 1998 2024 #if QT_VERSION < 0x040000 … … 2149 2175 /** 2150 2176 * set the new encoder path 2151 * @return true if the path exist and file is executable, falseotherwise2177 * @return "" if correct. The error otherwise 2152 2178 */ 2153 boolG4OpenGLQtViewer::setEncoderPath(QString path) {2179 QString G4OpenGLQtViewer::setEncoderPath(QString path) { 2154 2180 QFile *f = new QFile(path); 2155 2181 if (!f->exists()) { 2156 2182 #ifdef GEANT4_QT_DEBUG 2157 printf("G4OpenGLQtViewer::setEncoderPath NOT E 2158 #endif 2159 return false;2183 printf("G4OpenGLQtViewer::setEncoderPath NOT EXIST\n"); 2184 #endif 2185 return "Path does not exist"; 2160 2186 } 2161 2187 if (!(f->permissions() & QFile::ExeUser)) { … … 2163 2189 printf("G4OpenGLQtViewer::setEncoderPath No WRITE ACCES\n"); 2164 2190 #endif 2165 return false;2191 return "File exist but is not executable"; 2166 2192 } 2167 2193 fEncoderPath = path; 2168 return true;2194 return ""; 2169 2195 } 2170 2196 2171 2197 /** 2172 2198 * set the temp folder path 2173 * @return true if the path exist and we could write in, falseotherwise2199 * @return "" if correct. The error otherwise 2174 2200 */ 2175 boolG4OpenGLQtViewer::setTempFolderPath(QString path) {2201 QString G4OpenGLQtViewer::setTempFolderPath(QString path) { 2176 2202 2177 2203 QDir *d = new QDir(path); 2178 2204 if (!d->exists(path)) { 2179 return false;2205 return "Path does not exist"; 2180 2206 } 2181 2207 … … 2193 2219 2194 2220 if (!found) 2195 return false;2221 return "Path exist, but is not write accessible"; 2196 2222 2197 2223 fTempFolderPath = path; 2198 return true;2224 return ""; 2199 2225 } 2200 2226 … … 2205 2231 } 2206 2232 2233 /** 2234 * set the save file name path 2235 * @return "" if correct. The error otherwise 2236 */ 2237 QString G4OpenGLQtViewer::setSaveFileName(QString path) { 2238 2239 QDir *d = new QDir(path); 2240 if (!d->exists(path)) { 2241 return "Path does not exist"; 2242 } 2243 2244 d->setFilter( QDir::Dirs | QDir::Readable | QDir::Writable ); 2245 QStringList subDirList = d->entryList(); 2246 bool found = false; 2247 2248 for (QStringList::ConstIterator it = subDirList.begin() ;(it != subDirList.end()) ; it++) { 2249 const QString currentDir = *it; 2250 2251 if (currentDir == ".") { // we found it 2252 found = true; 2253 } 2254 } 2255 2256 if (!found) 2257 return "Path exist, but is not write accessible"; 2258 2259 fSaveFileName = path; 2260 return ""; 2261 } 2262 2263 /** @return the save file path 2264 */ 2265 QString G4OpenGLQtViewer::getSaveFileName() { 2266 return fSaveFileName ; 2267 } 2207 2268 2208 2269
Note: See TracChangeset
for help on using the changeset viewer.