31 #ifdef G4VIS_BUILD_OPENGLQT_DRIVER
36 #include <qpushbutton.h>
37 #include <qcheckbox.h>
39 #include <qcombobox.h>
42 #include <qgroupbox.h>
43 #include <qradiobutton.h>
45 #include <qlineedit.h>
46 #include <qbuttongroup.h>
48 G4OpenGLQtExportDialog::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);
78 QWidget * sizeWidget =
new QWidget(
this);
79 QVBoxLayout * sizeWidgetLayout =
new QVBoxLayout(sizeWidget);
80 sizeWidgetLayout->setMargin (10);
84 sizeGroupBox =
new QGroupBox(tr(
"Size"));
85 QVBoxLayout *sizeGroupBoxLayout =
new QVBoxLayout(sizeGroupBox);
86 QButtonGroup * sizeButtonGroupBox =
new QButtonGroup();
87 sizeGroupBoxLayout->setMargin (15);
89 original =
new QRadioButton(
"Original");
90 modify =
new QRadioButton(
"Modify");
92 sizeButtonGroupBox->addButton(original);
93 sizeButtonGroupBox->addButton(modify);
94 sizeButtonGroupBox->setExclusive(
true);
96 sizeGroupBoxLayout->addWidget(original);
97 sizeGroupBoxLayout->addWidget(modify);
99 sizeGroupBox->setLayout(sizeGroupBoxLayout);
100 sizeWidgetLayout->addWidget(sizeGroupBox);
102 connect( sizeButtonGroupBox, SIGNAL( buttonClicked(QAbstractButton*) ),
this, SLOT( changeSizeBox()) );
103 original->setChecked(
true );
107 heightWidget =
new QWidget(sizeWidget);
109 QHBoxLayout *heightLineLayout =
new QHBoxLayout(heightWidget);
113 heightLineLayout->addWidget(
new QLabel(
"Height",heightWidget));
114 height =
new QLineEdit(tmp.setNum(originalHeight),heightWidget);
115 height->setMaxLength(5);
116 heightLineLayout->addWidget(height);
118 heightWidget->setLayout(heightLineLayout);
120 sizeWidgetLayout->addWidget(heightWidget);
121 connect( height, SIGNAL( textChanged (
const QString& ) ),
this, SLOT( textHeightChanged(
const QString &) ) );
125 widthWidget =
new QWidget(sizeWidget);
127 QHBoxLayout *widthLineLayout =
new QHBoxLayout(widthWidget);
129 widthLineLayout->addWidget(
new QLabel(
"Width ",widthWidget));
130 width =
new QLineEdit(tmp.setNum(originalWidth),widthWidget);
131 width->setMaxLength(5);
132 widthLineLayout->addWidget(
width);
133 widthWidget->setLayout(widthLineLayout);
134 sizeWidgetLayout->addWidget(widthWidget);
135 connect(
width, SIGNAL( textChanged (
const QString& ) ),
this, SLOT( textWidthChanged(
const QString &) ) );
141 ratioCheckBox =
new QCheckBox(
"Keep ratio",sizeWidget);
142 ratioCheckBox->setChecked(
true );
144 sizeWidgetLayout->addWidget(ratioCheckBox);
146 ratioCheckBox->hide();
147 heightWidget->hide();
150 sizeWidget->setLayout(sizeWidgetLayout);
151 globalVLayout->addWidget(sizeWidget);
153 if (format ==
"eps") {
155 QGroupBox *EPSWidgetGroupBox =
new QGroupBox(tr(
"EPS options"),
this);
158 QVBoxLayout * EPSGroupBoxLayout =
new QVBoxLayout(EPSWidgetGroupBox);
159 EPSGroupBoxLayout->setMargin (15);
172 vectorEPSCheckBox =
new QCheckBox(
"Vector EPS File",EPSWidgetGroupBox);
173 EPSGroupBoxLayout->addWidget(vectorEPSCheckBox);
175 EPSWidgetGroupBox->setLayout(EPSGroupBoxLayout);
177 vectorEPSCheckBox->setChecked(
true );
179 globalVLayout->addWidget(EPSWidgetGroupBox);
180 connect( vectorEPSCheckBox, SIGNAL( clicked() ),
this, SLOT( changeVectorEPS()) );
184 if ((format ==
"jpg") ||
185 (format ==
"jpeg")) {
187 QGroupBox *imageGroupBox =
new QGroupBox(tr(
"Image quality"),
this);
188 QHBoxLayout *hSliderLayout =
new QHBoxLayout(imageGroupBox);
189 hSliderLayout->setMargin (15);
191 qualitySlider=
new QSlider(Qt::Horizontal,imageGroupBox);
192 qualitySlider->setMinimum(0);
193 qualitySlider->setMaximum(100);
194 qualitySlider->setTickPosition(QSlider::TicksBelow);
195 qualitySlider->setValue(60);
196 hSliderLayout->addWidget(
new QLabel(
"Low ",imageGroupBox));
197 hSliderLayout->addWidget(qualitySlider);
198 hSliderLayout->addWidget(
new QLabel(
" Maximum",imageGroupBox));
200 imageGroupBox->setLayout(hSliderLayout);
202 globalVLayout->addWidget(imageGroupBox);
208 QWidget *buttonBox =
new QWidget(
this);
210 QHBoxLayout *buttonBoxLayout =
new QHBoxLayout(buttonBox);
212 buttonOk =
new QPushButton( tr(
"&OK" ),buttonBox );
213 buttonOk->setAutoDefault(
true );
214 buttonOk->setDefault(
true );
215 buttonBoxLayout->addWidget(buttonOk);
217 buttonCancel =
new QPushButton( tr(
"&Cancel" ),buttonBox );
218 buttonCancel->setAutoDefault(
true );
219 buttonBoxLayout->addWidget(buttonCancel);
221 buttonBox->setLayout(buttonBoxLayout);
222 globalVLayout->addWidget(buttonBox);
226 setLayout(globalVLayout);
229 connect( buttonOk, SIGNAL( clicked() ),
this, SLOT( accept() ) );
230 connect( buttonCancel, SIGNAL( clicked() ),
this, SLOT( reject() ) );
235 int G4OpenGLQtExportDialog::getSliderValue()
237 if (!qualitySlider)
return -1;
238 return qualitySlider->value();
241 int G4OpenGLQtExportDialog::getHeight()
243 if (!height)
return originalHeight;
244 return height->text().toInt();
249 if (!
width)
return originalWidth;
250 return width->text().toInt();
253 bool G4OpenGLQtExportDialog::getVectorEPS()
255 if (!vectorEPSCheckBox)
return 0;
256 return vectorEPSCheckBox->isChecked();
260 void G4OpenGLQtExportDialog::changeVectorEPS()
262 if (!vectorEPSCheckBox)
return;
263 if (vectorEPSCheckBox->isChecked()) {
264 sizeGroupBox->show();
269 sizeGroupBox->hide();
272 ratioCheckBox->hide();
273 heightWidget->hide();
279 void G4OpenGLQtExportDialog::changeSizeBox()
281 if (!original)
return;
282 if (!heightWidget)
return;
283 if (!widthWidget)
return;
284 if (!ratioCheckBox)
return;
286 if ( original->isChecked()) {
287 ratioCheckBox->hide();
288 heightWidget->hide();
291 heightWidget->show();
293 ratioCheckBox->show();
298 void G4OpenGLQtExportDialog::textWidthChanged(
302 if (!ratioCheckBox)
return;
304 if (isChangingSize ==
true)
return;
306 if (ratioCheckBox->isChecked()){
307 isChangingSize =
true;
309 height->setText(tmp.setNum((
int)(s.toInt()*(double)((
double)originalHeight/(double)originalWidth))));
310 isChangingSize =
false;
314 void G4OpenGLQtExportDialog:: textHeightChanged(
318 if (!ratioCheckBox)
return;
320 if (isChangingSize ==
true)
return;
322 if (ratioCheckBox->isChecked()){
323 isChangingSize =
true;
325 width->setText(tmp.setNum(s.toInt()*originalWidth/originalHeight));
326 isChangingSize =
false;
330 G4OpenGLQtExportDialog::~G4OpenGLQtExportDialog()
G4double getWidth(const ParticleType t)
Get particle width (in s)