source: trunk/geant4/visualization/OpenGL/src/G4OpenGLQtExportDialog.cc@ 624

Last change on this file since 624 was 606, checked in by garnier, 18 years ago

r647@mac-90108: laurentgarnier | 2007-11-15 11:32:46 +0100
Ok en Qt 4.3.0

  • Property svn:mime-type set to text/cpp
File size: 10.5 KB
RevLine 
[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//
[606]27// $Id: G4OpenGLQtExportDialog.cc,v 1.4 2007/11/13 17:48:51 lgarnier Exp $
[593]28// GEANT4 tag $Name: $
[581]29//
30//
31
32#ifdef G4VIS_BUILD_OPENGLQT_DRIVER
33
34#include "G4OpenGLQtExportDialog.hh"
35
[595]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>
[581]47
48G4OpenGLQtExportDialog::G4OpenGLQtExportDialog(
49 QWidget* parent
[583]50,QString nomFich
51 ,int aHeight
52 ,int aWidth
53)
[581]54 : QDialog( parent )
55{
[599]56#if QT_VERSION < 0x040000
57 setCaption( tr( " Export options" ));
58#else
[582]59 setWindowTitle( tr( " Export options" ));
[599]60#endif
[583]61 originalWidth = aWidth;
62 originalHeight = aHeight;
63
[593]64 // Initializations
65 qualitySlider = NULL;
66 width = NULL;
67 height = NULL;
68 colorButton = NULL;
69 BWButton = NULL;
70
[583]71 // global layout
[599]72#if QT_VERSION < 0x040000
73 QVBoxLayout* globalVLayout = new QVBoxLayout(this);
74#else
[583]75 QVBoxLayout* globalVLayout = new QVBoxLayout();
[599]76#endif
[583]77
[581]78
[585]79 if (nomFich.endsWith(".jpg") ||
80 nomFich.endsWith(".jepg")) {
[581]81
[583]82 QGroupBox *imageGroupBox = new QGroupBox(tr("Image quality"));
[599]83#if QT_VERSION < 0x040000
84 QVBoxLayout *imageGroupBoxLayout = new QVBoxLayout(imageGroupBox);
85#else
[583]86 QVBoxLayout *imageGroupBoxLayout = new QVBoxLayout;
[599]87#endif
88 QWidget *sliderBox = new QWidget;
[583]89
[599]90#if QT_VERSION < 0x040000
91 QHBoxLayout *hSlider = new QHBoxLayout(sliderBox);
92#else
[582]93 QHBoxLayout *hSlider = new QHBoxLayout;
[599]94#endif
95
[582]96 // qualityLabel = new QLabel( tr( "Image quality" ) );
[583]97 // imageGroupBoxLayout->addWidget(qualityLabel);
[599]98 qualitySlider= new QSlider(Qt::Horizontal,0);
99#if QT_VERSION < 0x040000
100 qualitySlider->setMinValue(0);
101 qualitySlider->setMaxValue(100);
102 qualitySlider->setTickmarks(QSlider::Below);
103#else
[582]104 qualitySlider->setMinimum(0);
105 qualitySlider->setMaximum(100);
106 qualitySlider->setTickPosition(QSlider::TicksBelow);
[599]107#endif
[582]108 qualitySlider->setValue(60);
[599]109 hSlider->addWidget(new QLabel("low",0));
[582]110 hSlider->addWidget(qualitySlider);
[599]111 hSlider->addWidget(new QLabel("Maximum",0));
112#if QT_VERSION >= 0x040000
[582]113 sliderBox->setLayout(hSlider);
[599]114#endif
[583]115 imageGroupBoxLayout->addWidget(sliderBox);
116
[599]117#if QT_VERSION >= 0x040000
[583]118 imageGroupBox->setLayout(imageGroupBoxLayout);
[599]119#endif
[583]120 globalVLayout->addWidget(imageGroupBox);
[581]121 }
122
[589]123 if(nomFich.endsWith(".eps")) {
[583]124 QGroupBox *EPSGroupBox = new QGroupBox(tr("EPS options"));
[599]125
126#if QT_VERSION < 0x040000
127 QVBoxLayout *EPSGroupBoxLayout = new QVBoxLayout(EPSGroupBox);
128#else
[583]129 QVBoxLayout *EPSGroupBoxLayout = new QVBoxLayout;
[599]130#endif
[583]131
[589]132 // transparencyEPS = new QCheckBox( "transparencyEPS" );
133 // transparencyEPS->setText( "save background" );
134 // transparencyEPS->setChecked( true );
[583]135
[599]136 colorButton = new QRadioButton("Color",0);
137 BWButton = new QRadioButton("Grayscale",0);
[593]138 colorButton->setChecked( true );
139 BWButton->setChecked( false );
[583]140
141
[589]142 // EPSGroupBoxLayout->addWidget(transparencyEPS);
[593]143 EPSGroupBoxLayout->addWidget(colorButton);
144 EPSGroupBoxLayout->addWidget(BWButton);
[599]145#if QT_VERSION >= 0x040000
[583]146 EPSGroupBox->setLayout(EPSGroupBoxLayout);
[599]147#endif
[583]148 globalVLayout->addWidget(EPSGroupBox);
149
[581]150 }
151
152 if(nomFich.endsWith(".tif") ||
153 nomFich.endsWith(".tiff") ||
[582]154 nomFich.endsWith(".jpg") ||
[581]155 nomFich.endsWith(".png") ||
156 nomFich.endsWith(".xpm")) {
[583]157
158 QGroupBox *transparencyGroupBox = new QGroupBox(tr("Transparency"));
[599]159#if QT_VERSION < 0x040000
160 QVBoxLayout *transparencyGroupBoxLayout = new QVBoxLayout(transparencyGroupBox);
161#else
[583]162 QVBoxLayout *transparencyGroupBoxLayout = new QVBoxLayout;
[599]163#endif
[583]164
[599]165 boxTransparency = new QCheckBox("Save transparency",0);
[581]166 boxTransparency->setChecked( false );
[583]167 // boxTransparency->setEnabled(false);
168
169 transparencyGroupBoxLayout->addWidget(boxTransparency);
[599]170#if QT_VERSION >= 0x040000
[583]171 transparencyGroupBox->setLayout(transparencyGroupBoxLayout);
[599]172#endif
[583]173 globalVLayout->addWidget(transparencyGroupBox);
174
[581]175 }
176
[584]177 // size box
[583]178 QGroupBox *sizeGroupBox = new QGroupBox(tr("Size"));
[584]179 QWidget* modifyAndRatioWidget = new QWidget;
180
[599]181#if QT_VERSION < 0x040000
182 QHBoxLayout *modifyAndRatioLayout = new QHBoxLayout(modifyAndRatioWidget);
183 QVBoxLayout *sizeGroupBoxLayout = new QVBoxLayout(sizeGroupBox);
184#else
185 QHBoxLayout *modifyAndRatioLayout = new QHBoxLayout;
186 QVBoxLayout *sizeGroupBoxLayout = new QVBoxLayout;
187#endif
188
[584]189 // original button
[599]190 original = new QRadioButton("Original",0);
[584]191 original->setChecked( true );
192 sizeGroupBoxLayout->addWidget(original);
193
194 // modify and ratio
[599]195 modify = new QRadioButton("Modify",0);
[583]196 modify->setChecked( false );
[584]197
[599]198 ratioCheckBox = new QCheckBox( "Keep ratio",0 );
[584]199 ratioCheckBox->setChecked( true );
200
201 modifyAndRatioLayout->addWidget(modify);
202 modifyAndRatioLayout->addWidget(ratioCheckBox);
[599]203#if QT_VERSION >= 0x040000
[584]204 modifyAndRatioWidget->setLayout(modifyAndRatioLayout);
[599]205#endif
[584]206 sizeGroupBoxLayout->addWidget(modifyAndRatioWidget);
[599]207 if (modify->isChecked()) {
208 ratioCheckBox->show();
209 } else {
210 ratioCheckBox->hide();
211 }
[584]212
[586]213 connect( original, SIGNAL( clicked(bool) ), this, SLOT( changeSizeBox(true)) );
214 connect( modify, SIGNAL( clicked(bool) ), this, SLOT( changeSizeBox(false) ) );
[581]215
[584]216 // height
[599]217 heightWidget = new QWidget;
218
219#if QT_VERSION < 0x040000
220 QHBoxLayout *heightLineLayout = new QHBoxLayout(heightWidget);
221#else
[583]222 QHBoxLayout *heightLineLayout = new QHBoxLayout;
[599]223#endif
224
[583]225 QString tmp;
226
[599]227 heightLineLayout->addWidget(new QLabel("Height",0));
228 height = new QLineEdit(tmp.setNum(originalHeight),0);
[583]229 height->setMaxLength(5);
230 heightLineLayout->addWidget(height);
[599]231#if QT_VERSION >= 0x040000
[583]232 heightWidget->setLayout(heightLineLayout);
[599]233#endif
[583]234 sizeGroupBoxLayout->addWidget(heightWidget);
[584]235 connect( height, SIGNAL( textChanged ( const QString& ) ), this, SLOT( textHeightChanged(const QString &) ) );
[581]236
[584]237
238 // width
[583]239 widthWidget = new QWidget;
240
[599]241#if QT_VERSION < 0x040000
242 QHBoxLayout *widthLineLayout = new QHBoxLayout(widthWidget);
243#else
244 QHBoxLayout *widthLineLayout = new QHBoxLayout;
245#endif
246
247 widthLineLayout->addWidget(new QLabel("Width ",0));
248 width = new QLineEdit(tmp.setNum(originalWidth),0);
[583]249 width->setMaxLength(5);
250 widthLineLayout->addWidget(width);
[599]251#if QT_VERSION >= 0x040000
[583]252 widthWidget->setLayout(widthLineLayout);
[599]253#endif
[583]254 sizeGroupBoxLayout->addWidget(widthWidget);
[584]255 connect( width, SIGNAL( textChanged ( const QString& ) ), this, SLOT( textWidthChanged(const QString &) ) );
[583]256
[599]257#if QT_VERSION >= 0x040000
[583]258 sizeGroupBox->setLayout(sizeGroupBoxLayout);
[599]259#endif
[583]260 globalVLayout->addWidget(sizeGroupBox);
261
[599]262 heightWidget->hide();
263 widthWidget->hide();
[583]264
[584]265 // button ok/cancel box
[583]266
267 QGroupBox *buttonGroupBox = new QGroupBox();
[599]268
269#if QT_VERSION < 0x040000
270 QHBoxLayout *buttonGroupBoxLayout = new QHBoxLayout(buttonGroupBox);
271#else
[583]272 QHBoxLayout *buttonGroupBoxLayout = new QHBoxLayout;
[599]273#endif
[583]274
[599]275 buttonOk = new QPushButton( tr( "&OK" ),0 );
[581]276 buttonOk->setAutoDefault( TRUE );
277 buttonOk->setDefault( TRUE );
[583]278 buttonGroupBoxLayout->addWidget(buttonOk);
[581]279
[599]280 buttonCancel = new QPushButton( tr( "&Cancel" ),0 );
[581]281 buttonCancel->setAutoDefault( TRUE );
[583]282 buttonGroupBoxLayout->addWidget(buttonCancel);
[581]283
[599]284#if QT_VERSION >= 0x040000
[583]285 buttonGroupBox->setLayout(buttonGroupBoxLayout);
[599]286#endif
[583]287 globalVLayout->addWidget(buttonGroupBox);
[581]288
289
[599]290#if QT_VERSION >= 0x040000
[583]291 setLayout(globalVLayout);
[599]292#endif
[583]293
[581]294 // signals and slots connections
295 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
296 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
297}
298
299
300
[582]301int G4OpenGLQtExportDialog::getSliderValue()
302{
[593]303 if (!qualitySlider) return -1;
[582]304 return qualitySlider->value();
305}
306
[585]307int G4OpenGLQtExportDialog::getHeight()
308{
[593]309 if (!height) return -1;
[585]310 return height->text().toInt();
311}
312
313int G4OpenGLQtExportDialog::getWidth()
314{
[593]315 if (!width) return -1;
[585]316 return width->text().toInt();
317}
318
[593]319bool G4OpenGLQtExportDialog::getTransparency()
[586]320{
[593]321 if (!boxTransparency) return -1;
[586]322 return boxTransparency->isChecked();
323}
[585]324
[587]325int G4OpenGLQtExportDialog::getNbColor()
[581]326{
[587]327 // Black and white
[593]328 if (!colorButton->isChecked())
[586]329 return 1;
[587]330 // rgb color
[586]331 return 3;
[583]332}
[581]333
[586]334
335void G4OpenGLQtExportDialog::changeSizeBox(bool aClick)
336{
337 if (aClick) {
338 modify->toggle();
339 } else {
340 original->toggle();
341 }
342 if ( original->isChecked()) {
[599]343 heightWidget->hide();
344 widthWidget->hide();
345 ratioCheckBox->hide();
[586]346 } else {
[599]347 heightWidget->show();
348 widthWidget->show();
349 ratioCheckBox->show();
[586]350 }
351}
352
[584]353void G4OpenGLQtExportDialog::textWidthChanged(
354 const QString & s
355 )
[583]356{
[584]357 if (ratioCheckBox->isChecked()){
358 QString tmp;
359 width->setText(tmp.setNum(s.toInt()*originalHeight/originalHeight));
360 }
[581]361}
362
[584]363void G4OpenGLQtExportDialog:: textHeightChanged(
364 const QString & s
365)
366{
367 if (ratioCheckBox->isChecked()){
368 QString tmp;
369 width->setText(tmp.setNum(s.toInt()*originalWidth/originalWidth));
370 }
371}
[581]372
373G4OpenGLQtExportDialog::~G4OpenGLQtExportDialog()
374{
375}
376
377
378#endif
Note: See TracBrowser for help on using the repository browser.