| 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 *encoderVGroupBoxLayout = new QVBoxLayout(encoderGroupBox);
|
|---|
| 88 |
|
|---|
| 89 | // Encoder Path
|
|---|
| 90 | QWidget *encoderHBox = new QWidget(encoderGroupBox);
|
|---|
| 91 | QHBoxLayout *encoderHBoxLayout = new QHBoxLayout(encoderHBox);
|
|---|
| 92 | fEncoderPath = new QLineEdit("",encoderHBox);
|
|---|
| 93 |
|
|---|
| 94 | QPushButton *encoderButton = new QPushButton(tr("..."),encoderHBox);
|
|---|
| 95 | encoderButton->setMaximumWidth (30);
|
|---|
| 96 |
|
|---|
| 97 | fEncoderStatus = new QLabel(encoderGroupBox);
|
|---|
| 98 | fEncoderStatus->setText("");
|
|---|
| 99 |
|
|---|
| 100 | #if QT_VERSION < 0x040000
|
|---|
| 101 | encoderHBoxLayout->add(fEncoderPath);
|
|---|
| 102 | encoderHBoxLayout->add(encoderButton);
|
|---|
| 103 | encoderVGroupBoxLayout->add(encoderHBox);
|
|---|
| 104 | encoderVGroupBoxLayout->add(fEncoderStatus);
|
|---|
| 105 |
|
|---|
| 106 | globalVLayout->add(encoderGroupBox);
|
|---|
| 107 | #else
|
|---|
| 108 | encoderHBoxLayout->addWidget(fEncoderPath);
|
|---|
| 109 | encoderHBoxLayout->addWidget(encoderButton);
|
|---|
| 110 | encoderVGroupBoxLayout->addWidget(encoderHBox);
|
|---|
| 111 | encoderVGroupBoxLayout->addWidget(fEncoderStatus);
|
|---|
| 112 |
|
|---|
| 113 | encoderGroupBox->setLayout(encoderVGroupBoxLayout);
|
|---|
| 114 | globalVLayout->addWidget(encoderGroupBox);
|
|---|
| 115 | #endif
|
|---|
| 116 |
|
|---|
| 117 | connect( encoderButton, SIGNAL( clicked( ) ), this, SLOT(selectEncoderPathAction() ) );
|
|---|
| 118 |
|
|---|
| 119 | fEncoderPath->setText(fParentViewer->getEncoderPath());
|
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 | // temp folder group box
|
|---|
| 123 | QGroupBox *tempFolderGroupBox = new QGroupBox(tr("Temporary folder path"));
|
|---|
| 124 | QVBoxLayout *tempFolderVGroupBoxLayout = new QVBoxLayout(tempFolderGroupBox);
|
|---|
| 125 |
|
|---|
| 126 | // temp folder Path
|
|---|
| 127 | QWidget *tempFolderHBox = new QWidget(tempFolderGroupBox);
|
|---|
| 128 | QHBoxLayout *tempFolderHBoxLayout = new QHBoxLayout(tempFolderHBox);
|
|---|
| 129 |
|
|---|
| 130 | fTempFolderPath = new QLineEdit("",tempFolderHBox);
|
|---|
| 131 |
|
|---|
| 132 | QPushButton *tempButton = new QPushButton(tr("..."),tempFolderHBox);
|
|---|
| 133 | tempButton->setMaximumWidth (30);
|
|---|
| 134 |
|
|---|
| 135 | fTempFolderStatus = new QLabel(tempFolderGroupBox);
|
|---|
| 136 | fTempFolderStatus->setText("");
|
|---|
| 137 |
|
|---|
| 138 | #if QT_VERSION < 0x040000
|
|---|
| 139 | tempFolderHBoxLayout->add(fTempFolderPath);
|
|---|
| 140 | tempFolderHBoxLayout->add(tempButton);
|
|---|
| 141 | tempFolderVGroupBoxLayout->add(tempFolderHBox);
|
|---|
| 142 | tempFolderVGroupBoxLayout->add(fTempFolderStatus);
|
|---|
| 143 |
|
|---|
| 144 | globalVLayout->add(tempFolderGroupBox);
|
|---|
| 145 | #else
|
|---|
| 146 | tempFolderHBoxLayout->addWidget(fTempFolderPath);
|
|---|
| 147 | tempFolderHBoxLayout->addWidget(tempButton);
|
|---|
| 148 | tempFolderVGroupBoxLayout->addWidget(tempFolderHBox);
|
|---|
| 149 | tempFolderVGroupBoxLayout->addWidget(fTempFolderStatus);
|
|---|
| 150 |
|
|---|
| 151 | tempFolderGroupBox->setLayout(tempFolderVGroupBoxLayout);
|
|---|
| 152 | globalVLayout->addWidget(tempFolderGroupBox);
|
|---|
| 153 | #endif
|
|---|
| 154 |
|
|---|
| 155 | connect( tempButton, SIGNAL( clicked( ) ), this, SLOT(selectTempPathAction() ) );
|
|---|
| 156 |
|
|---|
| 157 | fTempFolderPath->setText(fParentViewer->getTempFolderPath());
|
|---|
| 158 |
|
|---|
| 159 |
|
|---|
| 160 |
|
|---|
| 161 | // save file group box
|
|---|
| 162 | QGroupBox *saveFileGroupBox = new QGroupBox(tr("Save as"));
|
|---|
| 163 | QVBoxLayout *saveFileVGroupBoxLayout = new QVBoxLayout(saveFileGroupBox);
|
|---|
| 164 |
|
|---|
| 165 | // save file
|
|---|
| 166 | QWidget *saveFileHBox = new QWidget(saveFileGroupBox);
|
|---|
| 167 | QHBoxLayout *saveFileHBoxLayout = new QHBoxLayout(saveFileHBox);
|
|---|
| 168 |
|
|---|
| 169 | fSaveFileName = new QLineEdit("",saveFileHBox);
|
|---|
| 170 |
|
|---|
| 171 | QPushButton *saveButton = new QPushButton(tr("..."),saveFileHBox);
|
|---|
| 172 | saveButton->setMaximumWidth (30);
|
|---|
| 173 |
|
|---|
| 174 | fSaveFileStatus = new QLabel(saveFileGroupBox);
|
|---|
| 175 | fSaveFileStatus->setText("");
|
|---|
| 176 |
|
|---|
| 177 | #if QT_VERSION < 0x040000
|
|---|
| 178 | saveFileHBoxLayout->add(fSaveFileName);
|
|---|
| 179 | saveFileHBoxLayout->add(saveButton);
|
|---|
| 180 | saveFileVGroupBoxLayout->add(saveFileHBox);
|
|---|
| 181 | saveFileVGroupBoxLayout->add(fSaveFileStatus);
|
|---|
| 182 |
|
|---|
| 183 | globalVLayout->add(saveFileGroupBox);
|
|---|
| 184 | #else
|
|---|
| 185 | saveFileHBoxLayout->addWidget(fSaveFileName);
|
|---|
| 186 | saveFileHBoxLayout->addWidget(saveButton);
|
|---|
| 187 | saveFileVGroupBoxLayout->addWidget(saveFileHBox);
|
|---|
| 188 | saveFileVGroupBoxLayout->addWidget(fSaveFileStatus);
|
|---|
| 189 |
|
|---|
| 190 | saveFileGroupBox->setLayout(saveFileVGroupBoxLayout);
|
|---|
| 191 | globalVLayout->addWidget(saveFileGroupBox);
|
|---|
| 192 | #endif
|
|---|
| 193 |
|
|---|
| 194 | connect( saveButton, SIGNAL( clicked( ) ), this, SLOT(selectSaveFileNameAction() ) );
|
|---|
| 195 |
|
|---|
| 196 |
|
|---|
| 197 |
|
|---|
| 198 | // label
|
|---|
| 199 |
|
|---|
| 200 | QLabel *infoLabel = new QLabel(" Press SPACE to Start/Pause video recording \n Press RETURN to Stop video recording");
|
|---|
| 201 |
|
|---|
| 202 | // global status
|
|---|
| 203 | QGroupBox *statusGroupBox = new QGroupBox(tr("Status"));
|
|---|
| 204 | QVBoxLayout *statusVGroupBoxLayout = new QVBoxLayout(statusGroupBox);
|
|---|
| 205 | fGlobalStatus = new QLabel(statusGroupBox);
|
|---|
| 206 | fGlobalStatus->setText("");
|
|---|
| 207 |
|
|---|
| 208 | #if QT_VERSION < 0x040000
|
|---|
| 209 | statusVGroupBoxLayout->add(fGlobalStatus);
|
|---|
| 210 |
|
|---|
| 211 | globalVLayout->add(infoLabel);
|
|---|
| 212 | globalVLayout->add(statusGroupBox);
|
|---|
| 213 | #else
|
|---|
| 214 | statusVGroupBoxLayout->addWidget(fGlobalStatus);
|
|---|
| 215 |
|
|---|
| 216 | statusGroupBox->setLayout(statusVGroupBoxLayout);
|
|---|
| 217 | globalVLayout->addWidget(infoLabel);
|
|---|
| 218 | globalVLayout->addWidget(statusGroupBox);
|
|---|
| 219 | #endif
|
|---|
| 220 |
|
|---|
| 221 | // buttons
|
|---|
| 222 | QWidget *buttonBox = new QWidget(this);
|
|---|
| 223 |
|
|---|
| 224 | QHBoxLayout *buttonBoxLayout = new QHBoxLayout(buttonBox);
|
|---|
| 225 |
|
|---|
| 226 | QPushButton *buttonCancel = new QPushButton( tr( "&Cancel" ),buttonBox );
|
|---|
| 227 | buttonCancel->setAutoDefault( TRUE );
|
|---|
| 228 | buttonBoxLayout->addWidget(buttonCancel);
|
|---|
| 229 |
|
|---|
| 230 | QPushButton *buttonApply = new QPushButton( tr( "&Apply" ),buttonBox );
|
|---|
| 231 | buttonApply->setAutoDefault( TRUE );
|
|---|
| 232 | buttonApply->setDefault( TRUE );
|
|---|
| 233 | buttonBoxLayout->addWidget(buttonApply);
|
|---|
| 234 |
|
|---|
| 235 | QPushButton * buttonEncode = new QPushButton( tr( "&Encode" ),buttonBox );
|
|---|
| 236 | buttonEncode->setEnabled(false);
|
|---|
| 237 | buttonEncode->setAutoDefault( TRUE );
|
|---|
| 238 | buttonBoxLayout->addWidget(buttonEncode);
|
|---|
| 239 |
|
|---|
| 240 | #if QT_VERSION >= 0x040000
|
|---|
| 241 | buttonBox->setLayout(buttonBoxLayout);
|
|---|
| 242 | #endif
|
|---|
| 243 | globalVLayout->addWidget(buttonBox);
|
|---|
| 244 |
|
|---|
| 245 |
|
|---|
| 246 |
|
|---|
| 247 | #if QT_VERSION >= 0x040000
|
|---|
| 248 | setLayout(globalVLayout);
|
|---|
| 249 | #endif
|
|---|
| 250 |
|
|---|
| 251 | // signals and slots connections
|
|---|
| 252 | connect( buttonApply, SIGNAL( clicked() ), this, SLOT( checkAllParameters() ) );
|
|---|
| 253 | connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
|
|---|
| 254 | connect( buttonEncode, SIGNAL( clicked() ), this, SLOT( encode() ) );
|
|---|
| 255 | }
|
|---|
| 256 |
|
|---|
| 257 |
|
|---|
| 258 |
|
|---|
| 259 | G4OpenGLQtMovieDialog::~G4OpenGLQtMovieDialog()
|
|---|
| 260 | {
|
|---|
| 261 | }
|
|---|
| 262 |
|
|---|
| 263 | void G4OpenGLQtMovieDialog::selectEncoderPathAction()
|
|---|
| 264 | {
|
|---|
| 265 | QString nomFich = QFileDialog::getOpenFileName ( this,
|
|---|
| 266 | "Select your encoder",
|
|---|
| 267 | tr("Select your encoder ..."));
|
|---|
| 268 | if (nomFich == "") {
|
|---|
| 269 | return;
|
|---|
| 270 | }
|
|---|
| 271 | checkEncoderParameters(nomFich);
|
|---|
| 272 | }
|
|---|
| 273 |
|
|---|
| 274 | void G4OpenGLQtMovieDialog::selectTempPathAction()
|
|---|
| 275 | {
|
|---|
| 276 | QString nomFich = QFileDialog::getOpenFileName ( this,
|
|---|
| 277 | "Select temporary folder",
|
|---|
| 278 | tr("Select temporary folder ..."));
|
|---|
| 279 | if (nomFich == "") {
|
|---|
| 280 | return;
|
|---|
| 281 | }
|
|---|
| 282 | checkTempFolderParameters(nomFich);
|
|---|
| 283 | }
|
|---|
| 284 |
|
|---|
| 285 | void G4OpenGLQtMovieDialog::selectSaveFileNameAction()
|
|---|
| 286 | {
|
|---|
| 287 | QString nomFich = QFileDialog::getOpenFileName ( this,
|
|---|
| 288 | "Select saved file",
|
|---|
| 289 | tr("Select saved file ..."));
|
|---|
| 290 | if (nomFich == "") {
|
|---|
| 291 | return;
|
|---|
| 292 | }
|
|---|
| 293 | checkSaveFileNameParameters(nomFich);
|
|---|
| 294 | }
|
|---|
| 295 |
|
|---|
| 296 | void G4OpenGLQtMovieDialog::encode() {
|
|---|
| 297 | }
|
|---|
| 298 |
|
|---|
| 299 | /** Check all parameters
|
|---|
| 300 | */
|
|---|
| 301 | void G4OpenGLQtMovieDialog::checkAllParameters() {
|
|---|
| 302 | checkEncoderParameters(fEncoderPath->text());
|
|---|
| 303 | checkTempFolderParameters(fTempFolderPath->text());
|
|---|
| 304 | checkSaveFileNameParameters(fSaveFileName->text());
|
|---|
| 305 | }
|
|---|
| 306 |
|
|---|
| 307 | /**
|
|---|
| 308 | * If one of parameter is incorrect, put it in red and don't valid it
|
|---|
| 309 | * If valid, save it
|
|---|
| 310 | */
|
|---|
| 311 | void G4OpenGLQtMovieDialog::checkEncoderParameters(QString param) {
|
|---|
| 312 |
|
|---|
| 313 | QPalette palette( fEncoderPath->palette() );
|
|---|
| 314 |
|
|---|
| 315 | QString temp = fParentViewer->setEncoderPath(param);
|
|---|
| 316 | fGlobalStatus->setText("");
|
|---|
| 317 | fEncoderStatus->setText(temp);
|
|---|
| 318 | if (temp != "") {
|
|---|
| 319 | palette.setColor( QPalette::Base, Qt::red);
|
|---|
| 320 | fGlobalStatus->setText("If no valid encode defined, screen \ncapture files will be saved in the\ntemp folder in ppm format.");
|
|---|
| 321 | } else {
|
|---|
| 322 | palette.setColor( QPalette::Base, Qt::white);
|
|---|
| 323 | fEncoderPath->setText(fParentViewer->getEncoderPath());
|
|---|
| 324 | }
|
|---|
| 325 | fEncoderPath->setPalette(palette);
|
|---|
| 326 | }
|
|---|
| 327 |
|
|---|
| 328 |
|
|---|
| 329 | /**
|
|---|
| 330 | * If one of parameter is incorrect, put it in red and don't valid it
|
|---|
| 331 | * If valid, save it
|
|---|
| 332 | */
|
|---|
| 333 | void G4OpenGLQtMovieDialog::checkTempFolderParameters(QString param) {
|
|---|
| 334 |
|
|---|
| 335 | QPalette palette( fTempFolderPath->palette() );
|
|---|
| 336 |
|
|---|
| 337 | QString temp = fParentViewer->setTempFolderPath(param);
|
|---|
| 338 | fTempFolderStatus->setText(temp);
|
|---|
| 339 | if (temp != "") {
|
|---|
| 340 | palette.setColor( QPalette::Base, Qt::red);
|
|---|
| 341 | } else {
|
|---|
| 342 | palette.setColor( QPalette::Base, Qt::white);
|
|---|
| 343 | fTempFolderPath->setText(fParentViewer->getTempFolderPath());
|
|---|
| 344 | }
|
|---|
| 345 | fTempFolderPath->setPalette(palette);
|
|---|
| 346 | }
|
|---|
| 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::checkSaveFileNameParameters(QString param) {
|
|---|
| 354 |
|
|---|
| 355 | QPalette palette( fSaveFileName->palette() );
|
|---|
| 356 |
|
|---|
| 357 | QString temp = fParentViewer->setSaveFileName(param);
|
|---|
| 358 | fSaveFileStatus->setText(temp);
|
|---|
| 359 | if (temp != "") {
|
|---|
| 360 | palette.setColor( QPalette::Base, Qt::red);
|
|---|
| 361 | } else {
|
|---|
| 362 | palette.setColor( QPalette::Base, Qt::white);
|
|---|
| 363 | fSaveFileName->setText(fParentViewer->getSaveFileName());
|
|---|
| 364 | }
|
|---|
| 365 | fSaveFileName->setPalette(palette);
|
|---|
| 366 | }
|
|---|
| 367 | #endif
|
|---|