[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 | |
---|
[586] | 94 | transparencyEPS = new QCheckBox( "transparencyEPS" ); |
---|
| 95 | transparencyEPS->setText( "save background" ); |
---|
| 96 | transparencyEPS->setChecked( true ); |
---|
[583] | 97 | |
---|
| 98 | color = new QRadioButton("Color"); |
---|
| 99 | BW = new QRadioButton("Grayscale"); |
---|
| 100 | color->setChecked( true ); |
---|
| 101 | BW->setChecked( false ); |
---|
| 102 | |
---|
| 103 | |
---|
[586] | 104 | EPSGroupBoxLayout->addWidget(transparencyEPS); |
---|
[583] | 105 | EPSGroupBoxLayout->addWidget(color); |
---|
| 106 | EPSGroupBoxLayout->addWidget(BW); |
---|
| 107 | EPSGroupBox->setLayout(EPSGroupBoxLayout); |
---|
| 108 | globalVLayout->addWidget(EPSGroupBox); |
---|
| 109 | |
---|
[581] | 110 | } |
---|
| 111 | |
---|
| 112 | if(nomFich.endsWith(".tif") || |
---|
| 113 | nomFich.endsWith(".tiff") || |
---|
[582] | 114 | nomFich.endsWith(".jpg") || |
---|
[581] | 115 | nomFich.endsWith(".png") || |
---|
| 116 | nomFich.endsWith(".xpm")) { |
---|
[583] | 117 | |
---|
| 118 | QGroupBox *transparencyGroupBox = new QGroupBox(tr("Transparency")); |
---|
| 119 | QVBoxLayout *transparencyGroupBoxLayout = new QVBoxLayout; |
---|
| 120 | |
---|
| 121 | boxTransparency = new QCheckBox("Save transparency"); |
---|
[581] | 122 | boxTransparency->setChecked( false ); |
---|
[583] | 123 | // boxTransparency->setEnabled(false); |
---|
| 124 | |
---|
| 125 | transparencyGroupBoxLayout->addWidget(boxTransparency); |
---|
| 126 | transparencyGroupBox->setLayout(transparencyGroupBoxLayout); |
---|
| 127 | globalVLayout->addWidget(transparencyGroupBox); |
---|
| 128 | |
---|
[581] | 129 | } |
---|
| 130 | |
---|
[584] | 131 | // size box |
---|
[583] | 132 | QGroupBox *sizeGroupBox = new QGroupBox(tr("Size")); |
---|
| 133 | QVBoxLayout *sizeGroupBoxLayout = new QVBoxLayout; |
---|
| 134 | |
---|
[584] | 135 | QHBoxLayout *modifyAndRatioLayout = new QHBoxLayout; |
---|
| 136 | QWidget* modifyAndRatioWidget = new QWidget; |
---|
| 137 | |
---|
| 138 | // original button |
---|
[583] | 139 | original = new QRadioButton("Original"); |
---|
[584] | 140 | original->setChecked( true ); |
---|
| 141 | sizeGroupBoxLayout->addWidget(original); |
---|
| 142 | |
---|
| 143 | // modify and ratio |
---|
[583] | 144 | modify = new QRadioButton("Modify"); |
---|
| 145 | modify->setChecked( false ); |
---|
[584] | 146 | |
---|
| 147 | ratioCheckBox = new QCheckBox( "Keep ratio" ); |
---|
| 148 | ratioCheckBox->setChecked( true ); |
---|
| 149 | |
---|
| 150 | modifyAndRatioLayout->addWidget(modify); |
---|
| 151 | modifyAndRatioLayout->addWidget(ratioCheckBox); |
---|
| 152 | modifyAndRatioWidget->setLayout(modifyAndRatioLayout); |
---|
| 153 | sizeGroupBoxLayout->addWidget(modifyAndRatioWidget); |
---|
| 154 | ratioCheckBox->setVisible(modify->isChecked()); |
---|
| 155 | |
---|
[586] | 156 | connect( original, SIGNAL( clicked(bool) ), this, SLOT( changeSizeBox(true)) ); |
---|
| 157 | connect( modify, SIGNAL( clicked(bool) ), this, SLOT( changeSizeBox(false) ) ); |
---|
[581] | 158 | |
---|
[584] | 159 | // height |
---|
[583] | 160 | QHBoxLayout *heightLineLayout = new QHBoxLayout; |
---|
| 161 | heightWidget = new QWidget; |
---|
| 162 | QString tmp; |
---|
| 163 | |
---|
| 164 | heightLineLayout->addWidget(new QLabel("Height")); |
---|
| 165 | height = new QLineEdit(tmp.setNum(originalHeight)); |
---|
| 166 | height->setMaxLength(5); |
---|
| 167 | heightLineLayout->addWidget(height); |
---|
| 168 | heightWidget->setLayout(heightLineLayout); |
---|
| 169 | sizeGroupBoxLayout->addWidget(heightWidget); |
---|
[584] | 170 | connect( height, SIGNAL( textChanged ( const QString& ) ), this, SLOT( textHeightChanged(const QString &) ) ); |
---|
[581] | 171 | |
---|
[584] | 172 | |
---|
| 173 | // width |
---|
[583] | 174 | QHBoxLayout *widthLineLayout = new QHBoxLayout; |
---|
| 175 | widthWidget = new QWidget; |
---|
| 176 | |
---|
[585] | 177 | widthLineLayout->addWidget(new QLabel("Width ")); |
---|
[583] | 178 | width = new QLineEdit(tmp.setNum(originalWidth)); |
---|
| 179 | width->setMaxLength(5); |
---|
| 180 | widthLineLayout->addWidget(width); |
---|
| 181 | widthWidget->setLayout(widthLineLayout); |
---|
| 182 | sizeGroupBoxLayout->addWidget(widthWidget); |
---|
[584] | 183 | connect( width, SIGNAL( textChanged ( const QString& ) ), this, SLOT( textWidthChanged(const QString &) ) ); |
---|
[583] | 184 | |
---|
| 185 | sizeGroupBox->setLayout(sizeGroupBoxLayout); |
---|
| 186 | globalVLayout->addWidget(sizeGroupBox); |
---|
| 187 | |
---|
| 188 | heightWidget->setVisible(false); |
---|
| 189 | widthWidget->setVisible(false); |
---|
| 190 | |
---|
[584] | 191 | // button ok/cancel box |
---|
[583] | 192 | |
---|
| 193 | QGroupBox *buttonGroupBox = new QGroupBox(); |
---|
| 194 | QHBoxLayout *buttonGroupBoxLayout = new QHBoxLayout; |
---|
| 195 | |
---|
[581] | 196 | buttonOk = new QPushButton( tr( "&OK" ) ); |
---|
| 197 | buttonOk->setAutoDefault( TRUE ); |
---|
| 198 | buttonOk->setDefault( TRUE ); |
---|
[583] | 199 | buttonGroupBoxLayout->addWidget(buttonOk); |
---|
[581] | 200 | |
---|
| 201 | buttonCancel = new QPushButton( tr( "&Cancel" ) ); |
---|
| 202 | buttonCancel->setAutoDefault( TRUE ); |
---|
[583] | 203 | buttonGroupBoxLayout->addWidget(buttonCancel); |
---|
[581] | 204 | |
---|
[583] | 205 | buttonGroupBox->setLayout(buttonGroupBoxLayout); |
---|
| 206 | globalVLayout->addWidget(buttonGroupBox); |
---|
[581] | 207 | |
---|
| 208 | |
---|
[583] | 209 | setLayout(globalVLayout); |
---|
| 210 | |
---|
[581] | 211 | // signals and slots connections |
---|
| 212 | connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); |
---|
| 213 | connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); |
---|
| 214 | } |
---|
| 215 | |
---|
| 216 | |
---|
| 217 | |
---|
[582] | 218 | int G4OpenGLQtExportDialog::getSliderValue() |
---|
| 219 | { |
---|
| 220 | return qualitySlider->value(); |
---|
| 221 | } |
---|
| 222 | |
---|
[585] | 223 | int G4OpenGLQtExportDialog::getHeight() |
---|
| 224 | { |
---|
| 225 | return height->text().toInt(); |
---|
| 226 | } |
---|
| 227 | |
---|
| 228 | int G4OpenGLQtExportDialog::getWidth() |
---|
| 229 | { |
---|
| 230 | return width->text().toInt(); |
---|
| 231 | } |
---|
| 232 | |
---|
[586] | 233 | int G4OpenGLQtExportDialog::getTransparency() |
---|
| 234 | { |
---|
| 235 | return boxTransparency->isChecked(); |
---|
| 236 | } |
---|
[585] | 237 | |
---|
[587] | 238 | int G4OpenGLQtExportDialog::getNbColor() |
---|
[581] | 239 | { |
---|
[587] | 240 | // Black and white |
---|
[586] | 241 | if (!color->isChecked()) |
---|
| 242 | return 1; |
---|
[587] | 243 | // rgb color with alpha |
---|
[586] | 244 | if (color->isChecked() && transparencyEPS->isChecked()) |
---|
| 245 | return 4; |
---|
[587] | 246 | // rgb color |
---|
[586] | 247 | return 3; |
---|
[583] | 248 | } |
---|
[581] | 249 | |
---|
[586] | 250 | |
---|
| 251 | void G4OpenGLQtExportDialog::changeSizeBox(bool aClick) |
---|
| 252 | { |
---|
| 253 | if (aClick) { |
---|
| 254 | modify->toggle(); |
---|
| 255 | } else { |
---|
| 256 | original->toggle(); |
---|
| 257 | } |
---|
| 258 | if ( original->isChecked()) { |
---|
| 259 | heightWidget->setVisible(false); |
---|
| 260 | widthWidget->setVisible(false); |
---|
| 261 | ratioCheckBox->setVisible(false); |
---|
| 262 | } else { |
---|
| 263 | heightWidget->setVisible(true); |
---|
| 264 | widthWidget->setVisible(true); |
---|
| 265 | ratioCheckBox->setVisible(true); |
---|
| 266 | } |
---|
| 267 | } |
---|
| 268 | |
---|
[584] | 269 | void G4OpenGLQtExportDialog::textWidthChanged( |
---|
| 270 | const QString & s |
---|
| 271 | ) |
---|
[583] | 272 | { |
---|
[584] | 273 | if (ratioCheckBox->isChecked()){ |
---|
| 274 | QString tmp; |
---|
| 275 | width->setText(tmp.setNum(s.toInt()*originalHeight/originalHeight)); |
---|
| 276 | } |
---|
[581] | 277 | } |
---|
| 278 | |
---|
[584] | 279 | void G4OpenGLQtExportDialog:: textHeightChanged( |
---|
| 280 | const QString & s |
---|
| 281 | ) |
---|
| 282 | { |
---|
| 283 | if (ratioCheckBox->isChecked()){ |
---|
| 284 | QString tmp; |
---|
| 285 | width->setText(tmp.setNum(s.toInt()*originalWidth/originalWidth)); |
---|
| 286 | } |
---|
| 287 | } |
---|
[581] | 288 | |
---|
| 289 | G4OpenGLQtExportDialog::~G4OpenGLQtExportDialog() |
---|
| 290 | { |
---|
| 291 | } |
---|
| 292 | |
---|
| 293 | |
---|
| 294 | #endif |
---|