30 #ifdef G4VIS_BUILD_OPENGLQT_DRIVER
35 #include <qpushbutton.h>
36 #include <qcheckbox.h>
38 #include <qcombobox.h>
41 #include <qgroupbox.h>
42 #include <qradiobutton.h>
44 #include <qlineedit.h>
45 #include <qbuttongroup.h>
47 G4OpenGLQtExportDialog::G4OpenGLQtExportDialog(
56 setWindowTitle( tr(
" Export options" ));
57 originalWidth = aWidth;
58 originalHeight = aHeight;
68 QVBoxLayout* globalVLayout =
new QVBoxLayout(
this);
69 globalVLayout->setMargin(10);
70 globalVLayout->setSpacing(10);
77 QWidget * sizeWidget =
new QWidget(
this);
78 QVBoxLayout * sizeWidgetLayout =
new QVBoxLayout(sizeWidget);
79 sizeWidgetLayout->setMargin (10);
83 sizeGroupBox =
new QGroupBox(tr(
"Size"));
84 QVBoxLayout *sizeGroupBoxLayout =
new QVBoxLayout(sizeGroupBox);
85 QButtonGroup * sizeButtonGroupBox =
new QButtonGroup();
86 sizeGroupBoxLayout->setMargin (15);
88 original =
new QRadioButton(
"Original");
89 modify =
new QRadioButton(
"Modify");
91 sizeButtonGroupBox->addButton(original);
92 sizeButtonGroupBox->addButton(modify);
93 sizeButtonGroupBox->setExclusive(
true);
95 sizeGroupBoxLayout->addWidget(original);
96 sizeGroupBoxLayout->addWidget(modify);
98 sizeGroupBox->setLayout(sizeGroupBoxLayout);
99 sizeWidgetLayout->addWidget(sizeGroupBox);
101 connect( sizeButtonGroupBox, SIGNAL( buttonClicked(QAbstractButton*) ),
this, SLOT( changeSizeBox()) );
102 original->setChecked(
true );
106 heightWidget =
new QWidget(sizeWidget);
108 QHBoxLayout *heightLineLayout =
new QHBoxLayout(heightWidget);
112 heightLineLayout->addWidget(
new QLabel(
"Height",heightWidget));
113 height =
new QLineEdit(tmp.setNum(originalHeight),heightWidget);
114 height->setMaxLength(5);
115 heightLineLayout->addWidget(height);
117 heightWidget->setLayout(heightLineLayout);
119 sizeWidgetLayout->addWidget(heightWidget);
120 connect( height, SIGNAL( textChanged (
const QString& ) ),
this, SLOT( textHeightChanged(
const QString &) ) );
124 widthWidget =
new QWidget(sizeWidget);
126 QHBoxLayout *widthLineLayout =
new QHBoxLayout(widthWidget);
128 widthLineLayout->addWidget(
new QLabel(
"Width ",widthWidget));
129 width =
new QLineEdit(tmp.setNum(originalWidth),widthWidget);
130 width->setMaxLength(5);
131 widthLineLayout->addWidget(width);
132 widthWidget->setLayout(widthLineLayout);
133 sizeWidgetLayout->addWidget(widthWidget);
134 connect( width, SIGNAL( textChanged (
const QString& ) ),
this, SLOT( textWidthChanged(
const QString &) ) );
140 ratioCheckBox =
new QCheckBox(
"Keep ratio",sizeWidget);
141 ratioCheckBox->setChecked(
true );
143 sizeWidgetLayout->addWidget(ratioCheckBox);
145 ratioCheckBox->hide();
146 heightWidget->hide();
149 sizeWidget->setLayout(sizeWidgetLayout);
150 globalVLayout->addWidget(sizeWidget);
152 if (format ==
"eps") {
154 QGroupBox *EPSWidgetGroupBox =
new QGroupBox(tr(
"EPS options"),
this);
157 QVBoxLayout * EPSGroupBoxLayout =
new QVBoxLayout(EPSWidgetGroupBox);
158 EPSGroupBoxLayout->setMargin (15);
171 vectorEPSCheckBox =
new QCheckBox(
"Vector EPS File",EPSWidgetGroupBox);
172 EPSGroupBoxLayout->addWidget(vectorEPSCheckBox);
174 EPSWidgetGroupBox->setLayout(EPSGroupBoxLayout);
176 vectorEPSCheckBox->setChecked(
true );
178 globalVLayout->addWidget(EPSWidgetGroupBox);
179 connect( vectorEPSCheckBox, SIGNAL( clicked() ),
this, SLOT( changeVectorEPS()) );
183 if ((format ==
"jpg") ||
184 (format ==
"jpeg")) {
186 QGroupBox *imageGroupBox =
new QGroupBox(tr(
"Image quality"),
this);
187 QHBoxLayout *hSliderLayout =
new QHBoxLayout(imageGroupBox);
188 hSliderLayout->setMargin (15);
190 qualitySlider=
new QSlider(Qt::Horizontal,imageGroupBox);
191 qualitySlider->setMinimum(0);
192 qualitySlider->setMaximum(100);
193 qualitySlider->setTickPosition(QSlider::TicksBelow);
194 qualitySlider->setValue(60);
195 hSliderLayout->addWidget(
new QLabel(
"Low ",imageGroupBox));
196 hSliderLayout->addWidget(qualitySlider);
197 hSliderLayout->addWidget(
new QLabel(
" Maximum",imageGroupBox));
199 imageGroupBox->setLayout(hSliderLayout);
201 globalVLayout->addWidget(imageGroupBox);
207 QWidget *buttonBox =
new QWidget(
this);
209 QHBoxLayout *buttonBoxLayout =
new QHBoxLayout(buttonBox);
211 buttonOk =
new QPushButton( tr(
"&OK" ),buttonBox );
212 buttonOk->setAutoDefault(
true );
213 buttonOk->setDefault(
true );
214 buttonBoxLayout->addWidget(buttonOk);
216 buttonCancel =
new QPushButton( tr(
"&Cancel" ),buttonBox );
217 buttonCancel->setAutoDefault(
true );
218 buttonBoxLayout->addWidget(buttonCancel);
220 buttonBox->setLayout(buttonBoxLayout);
221 globalVLayout->addWidget(buttonBox);
225 setLayout(globalVLayout);
228 connect( buttonOk, SIGNAL( clicked() ),
this, SLOT( accept() ) );
229 connect( buttonCancel, SIGNAL( clicked() ),
this, SLOT( reject() ) );
234 int G4OpenGLQtExportDialog::getSliderValue()
236 if (!qualitySlider)
return -1;
237 return qualitySlider->value();
240 int G4OpenGLQtExportDialog::getHeight()
242 if (!height)
return originalHeight;
243 return height->text().toInt();
248 if (!width)
return originalWidth;
249 return width->text().toInt();
252 bool G4OpenGLQtExportDialog::getVectorEPS()
254 if (!vectorEPSCheckBox)
return 0;
255 return vectorEPSCheckBox->isChecked();
259 void G4OpenGLQtExportDialog::changeVectorEPS()
261 if (!vectorEPSCheckBox)
return;
262 if (vectorEPSCheckBox->isChecked()) {
263 sizeGroupBox->show();
268 sizeGroupBox->hide();
271 ratioCheckBox->hide();
272 heightWidget->hide();
278 void G4OpenGLQtExportDialog::changeSizeBox()
280 if (!original)
return;
281 if (!heightWidget)
return;
282 if (!widthWidget)
return;
283 if (!ratioCheckBox)
return;
285 if ( original->isChecked()) {
286 ratioCheckBox->hide();
287 heightWidget->hide();
290 heightWidget->show();
292 ratioCheckBox->show();
297 void G4OpenGLQtExportDialog::textWidthChanged(
301 if (!ratioCheckBox)
return;
303 if (isChangingSize ==
true)
return;
305 if (ratioCheckBox->isChecked()){
306 isChangingSize =
true;
308 height->setText(tmp.setNum((
int)(s.toInt()*(double)((
double)originalHeight/(double)originalWidth))));
309 isChangingSize =
false;
313 void G4OpenGLQtExportDialog:: textHeightChanged(
317 if (!ratioCheckBox)
return;
319 if (isChangingSize ==
true)
return;
321 if (ratioCheckBox->isChecked()){
322 isChangingSize =
true;
324 width->setText(tmp.setNum(s.toInt()*originalWidth/originalHeight));
325 isChangingSize =
false;
329 G4OpenGLQtExportDialog::~G4OpenGLQtExportDialog()