[581] | 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: G4OpenGLQtExportDialog.cc,v 0.1 2007/09/20 15:18:20 garnier $ |
---|
| 28 | // GEANT4 tag $Name: geant4-08-02-patch-01 $ |
---|
| 29 | // |
---|
| 30 | // |
---|
| 31 | |
---|
| 32 | #ifdef G4VIS_BUILD_OPENGLQT_DRIVER |
---|
| 33 | |
---|
| 34 | #include "G4OpenGLQtExportDialog.hh" |
---|
| 35 | |
---|
| 36 | #include <qvariant.h> |
---|
| 37 | #include <qpushbutton.h> |
---|
| 38 | #include <qcheckbox.h> |
---|
| 39 | #include <qlabel.h> |
---|
| 40 | #include <qcombobox.h> |
---|
[582] | 41 | #include <qslider.h> |
---|
[581] | 42 | #include <qlayout.h> |
---|
| 43 | #include <qgroupbox.h> |
---|
[583] | 44 | #include <qradiobutton.h> |
---|
[581] | 45 | #include <qimage.h> |
---|
[583] | 46 | #include <qlineedit.h> |
---|
[581] | 47 | |
---|
| 48 | G4OpenGLQtExportDialog::G4OpenGLQtExportDialog( |
---|
| 49 | QWidget* parent |
---|
[583] | 50 | ,QString nomFich |
---|
| 51 | ,int aHeight |
---|
| 52 | ,int aWidth |
---|
| 53 | ) |
---|
[581] | 54 | : QDialog( parent ) |
---|
| 55 | { |
---|
[582] | 56 | setWindowTitle( tr( " Export options" )); |
---|
[583] | 57 | originalWidth = aWidth; |
---|
| 58 | originalHeight = aHeight; |
---|
| 59 | |
---|
| 60 | // global layout |
---|
| 61 | QVBoxLayout* globalVLayout = new QVBoxLayout(); |
---|
| 62 | |
---|
[581] | 63 | |
---|
[585] | 64 | if (nomFich.endsWith(".jpg") || |
---|
| 65 | nomFich.endsWith(".jepg")) { |
---|
[581] | 66 | |
---|
[583] | 67 | QGroupBox *imageGroupBox = new QGroupBox(tr("Image quality")); |
---|
| 68 | QVBoxLayout *imageGroupBoxLayout = new QVBoxLayout; |
---|
| 69 | |
---|
[582] | 70 | QWidget *sliderBox = new QWidget; |
---|
| 71 | QHBoxLayout *hSlider = new QHBoxLayout; |
---|
| 72 | // qualityLabel = new QLabel( tr( "Image quality" ) ); |
---|
[583] | 73 | // imageGroupBoxLayout->addWidget(qualityLabel); |
---|
[582] | 74 | qualitySlider= new QSlider(Qt::Horizontal); |
---|
| 75 | qualitySlider->setMinimum(0); |
---|
| 76 | qualitySlider->setMaximum(100); |
---|
| 77 | qualitySlider->setTickPosition(QSlider::TicksBelow); |
---|
| 78 | qualitySlider->setValue(60); |
---|
| 79 | hSlider->addWidget(new QLabel("low")); |
---|
| 80 | hSlider->addWidget(qualitySlider); |
---|
| 81 | hSlider->addWidget(new QLabel("Maximum")); |
---|
| 82 | sliderBox->setLayout(hSlider); |
---|
[583] | 83 | imageGroupBoxLayout->addWidget(sliderBox); |
---|
| 84 | |
---|
| 85 | imageGroupBox->setLayout(imageGroupBoxLayout); |
---|
| 86 | globalVLayout->addWidget(imageGroupBox); |
---|
[581] | 87 | } |
---|
| 88 | |
---|
[583] | 89 | if(nomFich.endsWith(".eps") || |
---|
| 90 | nomFich.endsWith(".jpg")) { |
---|
| 91 | QGroupBox *EPSGroupBox = new QGroupBox(tr("EPS options")); |
---|
| 92 | QVBoxLayout *EPSGroupBoxLayout = new QVBoxLayout; |
---|
| 93 | |
---|
| 94 | boxEPS = new QCheckBox( "boxEPS" ); |
---|
| 95 | boxEPS->setText( "save background" ); |
---|
| 96 | boxEPS->setChecked( true ); |
---|
| 97 | |
---|
| 98 | color = new QRadioButton("Color"); |
---|
| 99 | BW = new QRadioButton("Grayscale"); |
---|
| 100 | color->setChecked( true ); |
---|
| 101 | BW->setChecked( false ); |
---|
| 102 | |
---|
[585] | 103 | connect( color, SIGNAL( toggled(bool) ), BW, SLOT( setChecked(bool) ) ); |
---|
| 104 | connect( BW, SIGNAL( toggled(bool) ), color, SLOT( setChecked(bool) ) ); |
---|
[583] | 105 | |
---|
| 106 | |
---|
| 107 | EPSGroupBoxLayout->addWidget(boxEPS); |
---|
| 108 | EPSGroupBoxLayout->addWidget(color); |
---|
| 109 | EPSGroupBoxLayout->addWidget(BW); |
---|
| 110 | EPSGroupBox->setLayout(EPSGroupBoxLayout); |
---|
| 111 | globalVLayout->addWidget(EPSGroupBox); |
---|
| 112 | |
---|
[581] | 113 | } |
---|
| 114 | |
---|
| 115 | if(nomFich.endsWith(".tif") || |
---|
| 116 | nomFich.endsWith(".tiff") || |
---|
[582] | 117 | nomFich.endsWith(".jpg") || |
---|
[581] | 118 | nomFich.endsWith(".png") || |
---|
| 119 | nomFich.endsWith(".xpm")) { |
---|
[583] | 120 | |
---|
| 121 | QGroupBox *transparencyGroupBox = new QGroupBox(tr("Transparency")); |
---|
| 122 | QVBoxLayout *transparencyGroupBoxLayout = new QVBoxLayout; |
---|
| 123 | |
---|
| 124 | boxTransparency = new QCheckBox("Save transparency"); |
---|
[581] | 125 | boxTransparency->setChecked( false ); |
---|
[583] | 126 | // boxTransparency->setEnabled(false); |
---|
| 127 | |
---|
| 128 | transparencyGroupBoxLayout->addWidget(boxTransparency); |
---|
| 129 | transparencyGroupBox->setLayout(transparencyGroupBoxLayout); |
---|
| 130 | globalVLayout->addWidget(transparencyGroupBox); |
---|
| 131 | |
---|
[581] | 132 | } |
---|
| 133 | |
---|
[584] | 134 | // size box |
---|
[583] | 135 | QGroupBox *sizeGroupBox = new QGroupBox(tr("Size")); |
---|
| 136 | QVBoxLayout *sizeGroupBoxLayout = new QVBoxLayout; |
---|
| 137 | |
---|
[584] | 138 | QHBoxLayout *modifyAndRatioLayout = new QHBoxLayout; |
---|
| 139 | QWidget* modifyAndRatioWidget = new QWidget; |
---|
| 140 | |
---|
| 141 | // original button |
---|
[583] | 142 | original = new QRadioButton("Original"); |
---|
[584] | 143 | original->setChecked( true ); |
---|
| 144 | sizeGroupBoxLayout->addWidget(original); |
---|
| 145 | |
---|
| 146 | // modify and ratio |
---|
[583] | 147 | modify = new QRadioButton("Modify"); |
---|
| 148 | modify->setChecked( false ); |
---|
[584] | 149 | |
---|
| 150 | ratioCheckBox = new QCheckBox( "Keep ratio" ); |
---|
| 151 | ratioCheckBox->setChecked( true ); |
---|
| 152 | |
---|
| 153 | modifyAndRatioLayout->addWidget(modify); |
---|
| 154 | modifyAndRatioLayout->addWidget(ratioCheckBox); |
---|
| 155 | modifyAndRatioWidget->setLayout(modifyAndRatioLayout); |
---|
| 156 | sizeGroupBoxLayout->addWidget(modifyAndRatioWidget); |
---|
| 157 | ratioCheckBox->setVisible(modify->isChecked()); |
---|
| 158 | |
---|
[585] | 159 | connect( original, SIGNAL( toggled(bool) ), modify, SLOT( setChecked(bool) ) ); |
---|
| 160 | connect( modify, SIGNAL( toggled(bool) ), original, SLOT( setChecked(bool) ) ); |
---|
[583] | 161 | connect( modify, SIGNAL( toggled(bool) ), this, SLOT( changeSizeBox(bool) ) ); |
---|
[581] | 162 | |
---|
[584] | 163 | // height |
---|
[583] | 164 | QHBoxLayout *heightLineLayout = new QHBoxLayout; |
---|
| 165 | heightWidget = new QWidget; |
---|
| 166 | QString tmp; |
---|
| 167 | |
---|
| 168 | heightLineLayout->addWidget(new QLabel("Height")); |
---|
| 169 | height = new QLineEdit(tmp.setNum(originalHeight)); |
---|
| 170 | height->setMaxLength(5); |
---|
| 171 | heightLineLayout->addWidget(height); |
---|
| 172 | heightWidget->setLayout(heightLineLayout); |
---|
| 173 | sizeGroupBoxLayout->addWidget(heightWidget); |
---|
[584] | 174 | connect( height, SIGNAL( textChanged ( const QString& ) ), this, SLOT( textHeightChanged(const QString &) ) ); |
---|
[581] | 175 | |
---|
[584] | 176 | |
---|
| 177 | // width |
---|
[583] | 178 | QHBoxLayout *widthLineLayout = new QHBoxLayout; |
---|
| 179 | widthWidget = new QWidget; |
---|
| 180 | |
---|
[585] | 181 | widthLineLayout->addWidget(new QLabel("Width ")); |
---|
[583] | 182 | width = new QLineEdit(tmp.setNum(originalWidth)); |
---|
| 183 | width->setMaxLength(5); |
---|
| 184 | widthLineLayout->addWidget(width); |
---|
| 185 | widthWidget->setLayout(widthLineLayout); |
---|
| 186 | sizeGroupBoxLayout->addWidget(widthWidget); |
---|
[584] | 187 | connect( width, SIGNAL( textChanged ( const QString& ) ), this, SLOT( textWidthChanged(const QString &) ) ); |
---|
[583] | 188 | |
---|
| 189 | sizeGroupBox->setLayout(sizeGroupBoxLayout); |
---|
| 190 | globalVLayout->addWidget(sizeGroupBox); |
---|
| 191 | |
---|
| 192 | heightWidget->setVisible(false); |
---|
| 193 | widthWidget->setVisible(false); |
---|
| 194 | |
---|
[584] | 195 | // button ok/cancel box |
---|
[583] | 196 | |
---|
| 197 | QGroupBox *buttonGroupBox = new QGroupBox(); |
---|
| 198 | QHBoxLayout *buttonGroupBoxLayout = new QHBoxLayout; |
---|
| 199 | |
---|
[581] | 200 | buttonOk = new QPushButton( tr( "&OK" ) ); |
---|
| 201 | buttonOk->setAutoDefault( TRUE ); |
---|
| 202 | buttonOk->setDefault( TRUE ); |
---|
[583] | 203 | buttonGroupBoxLayout->addWidget(buttonOk); |
---|
[581] | 204 | |
---|
| 205 | buttonCancel = new QPushButton( tr( "&Cancel" ) ); |
---|
| 206 | buttonCancel->setAutoDefault( TRUE ); |
---|
[583] | 207 | buttonGroupBoxLayout->addWidget(buttonCancel); |
---|
[581] | 208 | |
---|
[583] | 209 | buttonGroupBox->setLayout(buttonGroupBoxLayout); |
---|
| 210 | globalVLayout->addWidget(buttonGroupBox); |
---|
[581] | 211 | |
---|
| 212 | |
---|
[583] | 213 | setLayout(globalVLayout); |
---|
| 214 | |
---|
[581] | 215 | // signals and slots connections |
---|
| 216 | connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); |
---|
| 217 | connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); |
---|
| 218 | } |
---|
| 219 | |
---|
| 220 | |
---|
| 221 | |
---|
[582] | 222 | int G4OpenGLQtExportDialog::getSliderValue() |
---|
| 223 | { |
---|
| 224 | return qualitySlider->value(); |
---|
| 225 | } |
---|
| 226 | |
---|
[585] | 227 | int G4OpenGLQtExportDialog::getHeight() |
---|
| 228 | { |
---|
| 229 | return height->text().toInt(); |
---|
| 230 | } |
---|
| 231 | |
---|
| 232 | int G4OpenGLQtExportDialog::getWidth() |
---|
| 233 | { |
---|
| 234 | return width->text().toInt(); |
---|
| 235 | } |
---|
| 236 | |
---|
| 237 | |
---|
[583] | 238 | void G4OpenGLQtExportDialog::changeSizeBox(bool aChange) |
---|
[581] | 239 | { |
---|
[583] | 240 | heightWidget->setVisible(modify->isChecked()); |
---|
| 241 | widthWidget->setVisible(modify->isChecked()); |
---|
[584] | 242 | ratioCheckBox->setVisible(modify->isChecked()); |
---|
[583] | 243 | } |
---|
[581] | 244 | |
---|
[584] | 245 | void G4OpenGLQtExportDialog::textWidthChanged( |
---|
| 246 | const QString & s |
---|
| 247 | ) |
---|
[583] | 248 | { |
---|
[584] | 249 | if (ratioCheckBox->isChecked()){ |
---|
| 250 | QString tmp; |
---|
| 251 | width->setText(tmp.setNum(s.toInt()*originalHeight/originalHeight)); |
---|
| 252 | } |
---|
[581] | 253 | } |
---|
| 254 | |
---|
[584] | 255 | void G4OpenGLQtExportDialog:: textHeightChanged( |
---|
| 256 | const QString & s |
---|
| 257 | ) |
---|
| 258 | { |
---|
| 259 | if (ratioCheckBox->isChecked()){ |
---|
| 260 | QString tmp; |
---|
| 261 | width->setText(tmp.setNum(s.toInt()*originalWidth/originalWidth)); |
---|
| 262 | } |
---|
| 263 | } |
---|
[581] | 264 | |
---|
| 265 | G4OpenGLQtExportDialog::~G4OpenGLQtExportDialog() |
---|
| 266 | { |
---|
| 267 | } |
---|
| 268 | |
---|
| 269 | |
---|
| 270 | #endif |
---|