30#ifdef G4VIS_BUILD_OPENGLQT_DRIVER
35#include <qpushbutton.h>
42#include <qradiobutton.h>
45#include <qbuttongroup.h>
48#include "moc_G4OpenGLQtExportDialog.cpp"
51G4OpenGLQtExportDialog::G4OpenGLQtExportDialog(
60 setWindowTitle( tr(
" Export options" ));
61 originalWidth = aWidth;
62 originalHeight = aHeight;
72 QVBoxLayout* globalVLayout =
new QVBoxLayout(
this);
73 globalVLayout->setMargin(10);
74 globalVLayout->setSpacing(10);
81 QWidget * sizeWidget =
new QWidget(
this);
82 QVBoxLayout * sizeWidgetLayout =
new QVBoxLayout(sizeWidget);
83 sizeWidgetLayout->setMargin (10);
87 sizeGroupBox =
new QGroupBox(tr(
"Size"));
88 QVBoxLayout *sizeGroupBoxLayout =
new QVBoxLayout(sizeGroupBox);
89 QButtonGroup * sizeButtonGroupBox =
new QButtonGroup();
90 sizeGroupBoxLayout->setMargin (15);
92 original =
new QRadioButton(
"Original");
93 modify =
new QRadioButton(
"Modify");
95 sizeButtonGroupBox->addButton(original);
96 sizeButtonGroupBox->addButton(modify);
97 sizeButtonGroupBox->setExclusive(
true);
99 sizeGroupBoxLayout->addWidget(original);
100 sizeGroupBoxLayout->addWidget(modify);
102 sizeGroupBox->setLayout(sizeGroupBoxLayout);
103 sizeWidgetLayout->addWidget(sizeGroupBox);
105 connect( sizeButtonGroupBox, SIGNAL( buttonClicked(QAbstractButton*) ),
this, SLOT( changeSizeBox()) );
106 original->setChecked(
true );
110 heightWidget =
new QWidget(sizeWidget);
112 QHBoxLayout *heightLineLayout =
new QHBoxLayout(heightWidget);
116 heightLineLayout->addWidget(
new QLabel(
"Height",heightWidget));
117 height =
new QLineEdit(tmp.setNum(originalHeight),heightWidget);
118 height->setMaxLength(5);
119 heightLineLayout->addWidget(height);
121 heightWidget->setLayout(heightLineLayout);
123 sizeWidgetLayout->addWidget(heightWidget);
124 connect( height, SIGNAL( textChanged (
const QString& ) ),
this, SLOT( textHeightChanged(
const QString &) ) );
128 widthWidget =
new QWidget(sizeWidget);
130 QHBoxLayout *widthLineLayout =
new QHBoxLayout(widthWidget);
132 widthLineLayout->addWidget(
new QLabel(
"Width ",widthWidget));
133 width =
new QLineEdit(tmp.setNum(originalWidth),widthWidget);
134 width->setMaxLength(5);
135 widthLineLayout->addWidget(width);
136 widthWidget->setLayout(widthLineLayout);
137 sizeWidgetLayout->addWidget(widthWidget);
138 connect( width, SIGNAL( textChanged (
const QString& ) ),
this, SLOT( textWidthChanged(
const QString &) ) );
144 ratioCheckBox =
new QCheckBox(
"Keep ratio",sizeWidget);
145 ratioCheckBox->setChecked(
true );
147 sizeWidgetLayout->addWidget(ratioCheckBox);
149 ratioCheckBox->hide();
150 heightWidget->hide();
153 sizeWidget->setLayout(sizeWidgetLayout);
154 globalVLayout->addWidget(sizeWidget);
156 if (format ==
"eps") {
158 QGroupBox *EPSWidgetGroupBox =
new QGroupBox(tr(
"EPS options"),
this);
161 QVBoxLayout * EPSGroupBoxLayout =
new QVBoxLayout(EPSWidgetGroupBox);
162 EPSGroupBoxLayout->setMargin (15);
175 vectorEPSCheckBox =
new QCheckBox(
"Vector EPS File",EPSWidgetGroupBox);
176 EPSGroupBoxLayout->addWidget(vectorEPSCheckBox);
178 EPSWidgetGroupBox->setLayout(EPSGroupBoxLayout);
180 vectorEPSCheckBox->setChecked(
true );
182 globalVLayout->addWidget(EPSWidgetGroupBox);
183 connect( vectorEPSCheckBox, SIGNAL( clicked() ),
this, SLOT( changeVectorEPS()) );
187 if ((format ==
"jpg") ||
188 (format ==
"jpeg")) {
190 QGroupBox *imageGroupBox =
new QGroupBox(tr(
"Image quality"),
this);
191 QHBoxLayout *hSliderLayout =
new QHBoxLayout(imageGroupBox);
192 hSliderLayout->setMargin (15);
194 qualitySlider=
new QSlider(Qt::Horizontal,imageGroupBox);
195 qualitySlider->setMinimum(0);
196 qualitySlider->setMaximum(100);
197 qualitySlider->setTickPosition(QSlider::TicksBelow);
198 qualitySlider->setValue(60);
199 hSliderLayout->addWidget(
new QLabel(
"Low ",imageGroupBox));
200 hSliderLayout->addWidget(qualitySlider);
201 hSliderLayout->addWidget(
new QLabel(
" Maximum",imageGroupBox));
203 imageGroupBox->setLayout(hSliderLayout);
205 globalVLayout->addWidget(imageGroupBox);
211 QWidget *buttonBox =
new QWidget(
this);
213 QHBoxLayout *buttonBoxLayout =
new QHBoxLayout(buttonBox);
215 buttonOk =
new QPushButton( tr(
"&OK" ),buttonBox );
216 buttonOk->setAutoDefault(
true );
217 buttonOk->setDefault(
true );
218 buttonBoxLayout->addWidget(buttonOk);
220 buttonCancel =
new QPushButton( tr(
"&Cancel" ),buttonBox );
221 buttonCancel->setAutoDefault(
true );
222 buttonBoxLayout->addWidget(buttonCancel);
224 buttonBox->setLayout(buttonBoxLayout);
225 globalVLayout->addWidget(buttonBox);
229 setLayout(globalVLayout);
232 connect( buttonOk, SIGNAL( clicked() ),
this, SLOT( accept() ) );
233 connect( buttonCancel, SIGNAL( clicked() ),
this, SLOT( reject() ) );
238int G4OpenGLQtExportDialog::getSliderValue()
240 if (!qualitySlider)
return -1;
241 return qualitySlider->value();
244int G4OpenGLQtExportDialog::getHeight()
246 if (!height)
return originalHeight;
247 return height->text().toInt();
250int G4OpenGLQtExportDialog::getWidth()
252 if (!width)
return originalWidth;
253 return width->text().toInt();
256bool G4OpenGLQtExportDialog::getVectorEPS()
258 if (!vectorEPSCheckBox)
return 0;
259 return vectorEPSCheckBox->isChecked();
263void G4OpenGLQtExportDialog::changeVectorEPS()
265 if (!vectorEPSCheckBox)
return;
266 if (vectorEPSCheckBox->isChecked()) {
267 sizeGroupBox->show();
272 sizeGroupBox->hide();
275 ratioCheckBox->hide();
276 heightWidget->hide();
282void G4OpenGLQtExportDialog::changeSizeBox()
284 if (!original)
return;
285 if (!heightWidget)
return;
286 if (!widthWidget)
return;
287 if (!ratioCheckBox)
return;
289 if ( original->isChecked()) {
290 ratioCheckBox->hide();
291 heightWidget->hide();
294 heightWidget->show();
296 ratioCheckBox->show();
301void G4OpenGLQtExportDialog::textWidthChanged(
305 if (!ratioCheckBox)
return;
307 if (isChangingSize ==
true)
return;
309 if (ratioCheckBox->isChecked()){
310 isChangingSize =
true;
312 height->setText(tmp.setNum((
int)(s.toInt()*(
double)((
double)originalHeight/(
double)originalWidth))));
313 isChangingSize =
false;
317void G4OpenGLQtExportDialog:: textHeightChanged(
321 if (!ratioCheckBox)
return;
323 if (isChangingSize ==
true)
return;
325 if (ratioCheckBox->isChecked()){
326 isChangingSize =
true;
328 width->setText(tmp.setNum(s.toInt()*originalWidth/originalHeight));
329 isChangingSize =
false;
333G4OpenGLQtExportDialog::~G4OpenGLQtExportDialog()