31#ifdef G4VIS_BUILD_OPENGLQT_DRIVER
36#include <qpushbutton.h>
43#include <qradiobutton.h>
46#include <qbuttongroup.h>
48G4OpenGLQtExportDialog::G4OpenGLQtExportDialog(
57 setWindowTitle( tr(
" Export options" ));
58 originalWidth = aWidth;
59 originalHeight = aHeight;
69 QVBoxLayout* globalVLayout =
new QVBoxLayout(
this);
70 globalVLayout->setMargin(10);
71 globalVLayout->setSpacing(10);
104 QWidget * sizeWidget =
new QWidget(
this);
105 QVBoxLayout * sizeWidgetLayout =
new QVBoxLayout(sizeWidget);
106 sizeWidgetLayout->setMargin (10);
110 sizeGroupBox =
new QGroupBox(tr(
"Size"));
111 QVBoxLayout *sizeGroupBoxLayout =
new QVBoxLayout(sizeGroupBox);
112 QButtonGroup * sizeButtonGroupBox =
new QButtonGroup();
113 sizeGroupBoxLayout->setMargin (15);
115 original =
new QRadioButton(
"Original");
116 modify =
new QRadioButton(
"Modify");
118 sizeButtonGroupBox->addButton(original);
119 sizeButtonGroupBox->addButton(modify);
120 sizeButtonGroupBox->setExclusive(
true);
122 sizeGroupBoxLayout->addWidget(original);
123 sizeGroupBoxLayout->addWidget(modify);
125 sizeGroupBox->setLayout(sizeGroupBoxLayout);
126 sizeWidgetLayout->addWidget(sizeGroupBox);
128 connect( sizeButtonGroupBox, SIGNAL( buttonClicked(QAbstractButton*) ),
this, SLOT( changeSizeBox()) );
129 original->setChecked(
true );
133 heightWidget =
new QWidget(sizeWidget);
135 QHBoxLayout *heightLineLayout =
new QHBoxLayout(heightWidget);
139 heightLineLayout->addWidget(
new QLabel(
"Height",heightWidget));
140 height =
new QLineEdit(tmp.setNum(originalHeight),heightWidget);
141 height->setMaxLength(5);
142 heightLineLayout->addWidget(height);
144 heightWidget->setLayout(heightLineLayout);
146 sizeWidgetLayout->addWidget(heightWidget);
147 connect( height, SIGNAL( textChanged (
const QString& ) ),
this, SLOT( textHeightChanged(
const QString &) ) );
151 widthWidget =
new QWidget(sizeWidget);
153 QHBoxLayout *widthLineLayout =
new QHBoxLayout(widthWidget);
155 widthLineLayout->addWidget(
new QLabel(
"Width ",widthWidget));
156 width =
new QLineEdit(tmp.setNum(originalWidth),widthWidget);
157 width->setMaxLength(5);
158 widthLineLayout->addWidget(width);
159 widthWidget->setLayout(widthLineLayout);
160 sizeWidgetLayout->addWidget(widthWidget);
161 connect( width, SIGNAL( textChanged (
const QString& ) ),
this, SLOT( textWidthChanged(
const QString &) ) );
167 ratioCheckBox =
new QCheckBox(
"Keep ratio",sizeWidget);
168 ratioCheckBox->setChecked(
true );
170 sizeWidgetLayout->addWidget(ratioCheckBox);
172 ratioCheckBox->hide();
173 heightWidget->hide();
176 sizeWidget->setLayout(sizeWidgetLayout);
177 globalVLayout->addWidget(sizeWidget);
179 if (format ==
"eps") {
181 QGroupBox *EPSWidgetGroupBox =
new QGroupBox(tr(
"EPS options"),
this);
184 QVBoxLayout * EPSGroupBoxLayout =
new QVBoxLayout(EPSWidgetGroupBox);
185 EPSGroupBoxLayout->setMargin (15);
198 vectorEPSCheckBox =
new QCheckBox(
"Vector EPS File",EPSWidgetGroupBox);
199 EPSGroupBoxLayout->addWidget(vectorEPSCheckBox);
201 EPSWidgetGroupBox->setLayout(EPSGroupBoxLayout);
203 vectorEPSCheckBox->setChecked(
true );
205 globalVLayout->addWidget(EPSWidgetGroupBox);
206 connect( vectorEPSCheckBox, SIGNAL( clicked() ),
this, SLOT( changeVectorEPS()) );
210 if ((format ==
"jpg") ||
211 (format ==
"jpeg")) {
213 QGroupBox *imageGroupBox =
new QGroupBox(tr(
"Image quality"),
this);
214 QHBoxLayout *hSliderLayout =
new QHBoxLayout(imageGroupBox);
215 hSliderLayout->setMargin (15);
217 qualitySlider=
new QSlider(Qt::Horizontal,imageGroupBox);
218 qualitySlider->setMinimum(0);
219 qualitySlider->setMaximum(100);
220 qualitySlider->setTickPosition(QSlider::TicksBelow);
221 qualitySlider->setValue(60);
222 hSliderLayout->addWidget(
new QLabel(
"Low ",imageGroupBox));
223 hSliderLayout->addWidget(qualitySlider);
224 hSliderLayout->addWidget(
new QLabel(
" Maximum",imageGroupBox));
226 imageGroupBox->setLayout(hSliderLayout);
228 globalVLayout->addWidget(imageGroupBox);
234 QWidget *buttonBox =
new QWidget(
this);
236 QHBoxLayout *buttonBoxLayout =
new QHBoxLayout(buttonBox);
238 buttonOk =
new QPushButton( tr(
"&OK" ),buttonBox );
239 buttonOk->setAutoDefault(
TRUE );
240 buttonOk->setDefault(
TRUE );
241 buttonBoxLayout->addWidget(buttonOk);
243 buttonCancel =
new QPushButton( tr(
"&Cancel" ),buttonBox );
244 buttonCancel->setAutoDefault(
TRUE );
245 buttonBoxLayout->addWidget(buttonCancel);
247 buttonBox->setLayout(buttonBoxLayout);
248 globalVLayout->addWidget(buttonBox);
252 setLayout(globalVLayout);
255 connect( buttonOk, SIGNAL( clicked() ),
this, SLOT( accept() ) );
256 connect( buttonCancel, SIGNAL( clicked() ),
this, SLOT( reject() ) );
261int G4OpenGLQtExportDialog::getSliderValue()
263 if (!qualitySlider)
return -1;
264 return qualitySlider->value();
267int G4OpenGLQtExportDialog::getHeight()
269 if (!height)
return originalHeight;
270 return height->text().toInt();
273int G4OpenGLQtExportDialog::getWidth()
275 if (!width)
return originalWidth;
276 return width->text().toInt();
279int G4OpenGLQtExportDialog::getTransparency()
281 if (!boxTransparency)
return -1;
282 return boxTransparency->isChecked();
285int G4OpenGLQtExportDialog::getNbColor()
287 if (!colorButton)
return -1;
289 if (!colorButton->isChecked())
295bool G4OpenGLQtExportDialog::getVectorEPS()
297 if (!vectorEPSCheckBox)
return 0;
298 return vectorEPSCheckBox->isChecked();
302void G4OpenGLQtExportDialog::changeVectorEPS()
304 if (!vectorEPSCheckBox)
return;
305 if (vectorEPSCheckBox->isChecked()) {
306 sizeGroupBox->show();
311 sizeGroupBox->hide();
314 ratioCheckBox->hide();
315 heightWidget->hide();
321void G4OpenGLQtExportDialog::changeSizeBox()
323 if (!original)
return;
324 if (!heightWidget)
return;
325 if (!widthWidget)
return;
326 if (!ratioCheckBox)
return;
328 if ( original->isChecked()) {
329 ratioCheckBox->hide();
330 heightWidget->hide();
333 heightWidget->show();
335 ratioCheckBox->show();
340void G4OpenGLQtExportDialog::textWidthChanged(
344 if (!ratioCheckBox)
return;
346 if (isChangingSize ==
true)
return;
348 if (ratioCheckBox->isChecked()){
349 isChangingSize =
true;
351 height->setText(tmp.setNum((
int)(s.toInt()*(
double)((
double)originalHeight/(
double)originalWidth))));
352 isChangingSize =
false;
356void G4OpenGLQtExportDialog:: textHeightChanged(
360 if (!ratioCheckBox)
return;
362 if (isChangingSize ==
true)
return;
364 if (ratioCheckBox->isChecked()){
365 isChangingSize =
true;
367 width->setText(tmp.setNum(s.toInt()*originalWidth/originalHeight));
368 isChangingSize =
false;
372G4OpenGLQtExportDialog::~G4OpenGLQtExportDialog()