| 1 | //
|
|---|
| 2 | // ********************************************************************
|
|---|
| 3 | // * License and Disclaimer *
|
|---|
| 4 | // * *
|
|---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of *
|
|---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and *
|
|---|
| 7 | // * conditions of the Geant4 Software License, included in the file *
|
|---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These *
|
|---|
| 9 | // * include a list of copyright holders. *
|
|---|
| 10 | // * *
|
|---|
| 11 | // * Neither the authors of this software system, nor their employing *
|
|---|
| 12 | // * institutes,nor the agencies providing financial support for this *
|
|---|
| 13 | // * work make any representation or warranty, express or implied, *
|
|---|
| 14 | // * regarding this software system or assume any liability for its *
|
|---|
| 15 | // * use. Please see the license in the file LICENSE and URL above *
|
|---|
| 16 | // * for the full disclaimer and the limitation of liability. *
|
|---|
| 17 | // * *
|
|---|
| 18 | // * This code implementation is the result of the scientific and *
|
|---|
| 19 | // * technical work of the GEANT4 collaboration. *
|
|---|
| 20 | // * By using, copying, modifying or distributing the software (or *
|
|---|
| 21 | // * any work based on the software) you agree to acknowledge its *
|
|---|
| 22 | // * use in resulting scientific publications, and indicate your *
|
|---|
| 23 | // * acceptance of all terms of the Geant4 Software license. *
|
|---|
| 24 | // ********************************************************************
|
|---|
| 25 | //
|
|---|
| 26 | //
|
|---|
| 27 | // $Id: G4OpenGLQtMovieDialog.cc,v 1.6 2008/02/15 10:54:13 lgarnier Exp $
|
|---|
| 28 | // GEANT4 tag $Name: $
|
|---|
| 29 | //
|
|---|
| 30 | //
|
|---|
| 31 |
|
|---|
| 32 | #define GEANT4_QT_DEBUG
|
|---|
| 33 | #ifdef G4VIS_BUILD_OPENGLQT_DRIVER
|
|---|
| 34 |
|
|---|
| 35 | #include "G4OpenGLQtMovieDialog.hh"
|
|---|
| 36 | #include "G4OpenGLQtViewer.hh"
|
|---|
| 37 |
|
|---|
| 38 | #include <qpushbutton.h>
|
|---|
| 39 | #include <qpalette.h>
|
|---|
| 40 | #include <qlabel.h>
|
|---|
| 41 | #include <qgroupbox.h>
|
|---|
| 42 | #include <qlayout.h>
|
|---|
| 43 | #include <qlineedit.h>
|
|---|
| 44 | #include <qfiledialog.h>
|
|---|
| 45 | #include <qprocess.h>
|
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 | // +---------------------------------------+
|
|---|
| 49 | // + Path for encoder +
|
|---|
| 50 | // + _______ +
|
|---|
| 51 | // + | select| ____________________ +
|
|---|
| 52 | // + ------- +
|
|---|
| 53 | // + Temp path +
|
|---|
| 54 | // + _______ +
|
|---|
| 55 | // + | select| ____________________ +
|
|---|
| 56 | // + ------- +
|
|---|
| 57 | // + +
|
|---|
| 58 | // + max number of frames ________ +
|
|---|
| 59 | // + .... +
|
|---|
| 60 | // + +
|
|---|
| 61 | // + Label : X frames Saves/Encoding +
|
|---|
| 62 | // + Cancel Encode +
|
|---|
| 63 | // +---------------------------------------+
|
|---|
| 64 |
|
|---|
| 65 | G4OpenGLQtMovieDialog::G4OpenGLQtMovieDialog(
|
|---|
| 66 | G4OpenGLQtViewer* parentViewer,
|
|---|
| 67 | QWidget* parentWidget
|
|---|
| 68 | )
|
|---|
| 69 | : QDialog( parentWidget ),
|
|---|
| 70 | fParentViewer(parentViewer)
|
|---|
| 71 | {
|
|---|
| 72 | setModal(false);
|
|---|
| 73 | #if QT_VERSION < 0x040000
|
|---|
| 74 | setCaption( tr( " Movie parameters" ));
|
|---|
| 75 | #else
|
|---|
| 76 | setWindowTitle( tr( " Movie parameters" ));
|
|---|
| 77 | #endif
|
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 | // global layout
|
|---|
| 81 | QVBoxLayout* globalVLayout = new QVBoxLayout(this);
|
|---|
| 82 | globalVLayout->setMargin(10);
|
|---|
| 83 | globalVLayout->setSpacing(10);
|
|---|
| 84 |
|
|---|
| 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
|
|---|
| 91 |
|
|---|
| 92 | // Encoder Path
|
|---|
| 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);
|
|---|
| 98 | encoderButton->setMaximumWidth (30);
|
|---|
| 99 |
|
|---|
| 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
|
|---|
| 119 | #if QT_VERSION >= 0x040000
|
|---|
| 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);
|
|---|
| 132 | #endif
|
|---|
| 133 |
|
|---|
| 134 | fEncoderPath->setText(fParentViewer->getEncoderPath());
|
|---|
| 135 |
|
|---|
| 136 |
|
|---|
| 137 | // temp folder group box
|
|---|
| 138 | QGroupBox *tempFolderGroupBox = new QGroupBox(tr("Temporary folder path"));
|
|---|
| 139 | QVBoxLayout *tempFolderVBoxLayout = new QVBoxLayout(tempFolderGroupBox);
|
|---|
| 140 |
|
|---|
| 141 | // temp folder Path
|
|---|
| 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);
|
|---|
| 148 | tempButton->setMaximumWidth (30);
|
|---|
| 149 |
|
|---|
| 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
|
|---|
| 169 | #if QT_VERSION >= 0x040000
|
|---|
| 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
|
|---|
| 236 |
|
|---|
| 237 | // label
|
|---|
| 238 |
|
|---|
| 239 | QLabel *infoLabel = new QLabel(" Press SPACE to Start/Pause video recording \n Press RETURN to Stop video recording");
|
|---|
| 240 |
|
|---|
| 241 | // global status
|
|---|
| 242 | fGlobalStatus = new QLabel("");
|
|---|
| 243 |
|
|---|
| 244 | #if QT_VERSION < 0x040000
|
|---|
| 245 | globalVLayout->add(infoLabel);
|
|---|
| 246 | globalVLayout->add(fGlobalStatus);
|
|---|
| 247 | #else
|
|---|
| 248 | globalVLayout->addWidget(infoLabel);
|
|---|
| 249 | globalVLayout->addWidget(fGlobalStatus);
|
|---|
| 250 | #endif
|
|---|
| 251 | #ifdef GEANT4_QT_DEBUG
|
|---|
| 252 | printf("11112222222222é\n");
|
|---|
| 253 | #endif
|
|---|
| 254 |
|
|---|
| 255 | // buttons
|
|---|
| 256 | QWidget *buttonBox = new QWidget(this);
|
|---|
| 257 |
|
|---|
| 258 | QHBoxLayout *buttonBoxLayout = new QHBoxLayout(buttonBox);
|
|---|
| 259 |
|
|---|
| 260 | QPushButton *buttonCancel = new QPushButton( tr( "&Cancel" ),buttonBox );
|
|---|
| 261 | buttonCancel->setAutoDefault( TRUE );
|
|---|
| 262 | buttonBoxLayout->addWidget(buttonCancel);
|
|---|
| 263 |
|
|---|
| 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 );
|
|---|
| 269 | buttonEncode->setAutoDefault( TRUE );
|
|---|
| 270 | buttonEncode->setDefault( TRUE );
|
|---|
| 271 | buttonBoxLayout->addWidget(buttonEncode);
|
|---|
| 272 |
|
|---|
| 273 | #ifdef GEANT4_QT_DEBUG
|
|---|
| 274 | printf("1111333333333333\n");
|
|---|
| 275 | #endif
|
|---|
| 276 | #if QT_VERSION >= 0x040000
|
|---|
| 277 | buttonBox->setLayout(buttonBoxLayout);
|
|---|
| 278 | #endif
|
|---|
| 279 | globalVLayout->addWidget(buttonBox);
|
|---|
| 280 |
|
|---|
| 281 |
|
|---|
| 282 | #ifdef GEANT4_QT_DEBUG
|
|---|
| 283 | printf("1111444444444\n");
|
|---|
| 284 | #endif
|
|---|
| 285 |
|
|---|
| 286 | #if QT_VERSION >= 0x040000
|
|---|
| 287 | setLayout(globalVLayout);
|
|---|
| 288 | #endif
|
|---|
| 289 |
|
|---|
| 290 | // signals and slots connections
|
|---|
| 291 | connect( buttonApply, SIGNAL( clicked() ), this, SLOT( checkAllParameters() ) );
|
|---|
| 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
|
|---|
| 297 | }
|
|---|
| 298 |
|
|---|
| 299 |
|
|---|
| 300 |
|
|---|
| 301 | G4OpenGLQtMovieDialog::~G4OpenGLQtMovieDialog()
|
|---|
| 302 | {
|
|---|
| 303 | }
|
|---|
| 304 |
|
|---|
| 305 | void G4OpenGLQtMovieDialog::selectEncoderPathAction()
|
|---|
| 306 | {
|
|---|
| 307 | QString nomFich = QFileDialog::getOpenFileName ( this,
|
|---|
| 308 | "Select your encoder",
|
|---|
| 309 | tr("Select your encoder ..."));
|
|---|
| 310 | if (nomFich == "") {
|
|---|
| 311 | return;
|
|---|
| 312 | }
|
|---|
| 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 |
|
|---|
| 370 |
|
|---|
| 371 | /**
|
|---|
| 372 | * If one of parameter is incorrect, put it in red and don't valid it
|
|---|
| 373 | * If valid, save it
|
|---|
| 374 | */
|
|---|
| 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 != "") {
|
|---|
| 382 | palette.setColor( QPalette::Base, Qt::red);
|
|---|
| 383 | } else {
|
|---|
| 384 | palette.setColor( QPalette::Base, Qt::white);
|
|---|
| 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 != "") {
|
|---|
| 402 | palette.setColor( QPalette::Base, Qt::red);
|
|---|
| 403 | } else {
|
|---|
| 404 | palette.setColor( QPalette::Base, Qt::white);
|
|---|
| 405 | fSaveFileName->setText(fParentViewer->getSaveFileName());
|
|---|
| 406 | }
|
|---|
| 407 | fSaveFileName->setPalette(palette);
|
|---|
| 408 | }
|
|---|
| 409 | #endif
|
|---|