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