Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4OpenGLQtExportDialog.cc
Go to the documentation of this file.
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//
27//
28//
29
31
32#include <qvariant.h>
33#include <qpushbutton.h>
34#include <qcheckbox.h>
35#include <qlabel.h>
36#include <qcombobox.h>
37#include <qslider.h>
38#include <qlayout.h>
39#include <qgroupbox.h>
40#include <qradiobutton.h>
41#include <qimage.h>
42#include <qlineedit.h>
43#include <qbuttongroup.h>
44
45#ifndef G4GMAKE
46#include "moc_G4OpenGLQtExportDialog.cpp"
47#endif
48
50 QWidget* parentw
51,QString format
52 ,int aHeight
53 ,int aWidth
54)
55 : QDialog( parentw ),
56 isChangingSize(false)
57{
58 setWindowTitle( tr( " Export options" ));
59 originalWidth = aWidth;
60 originalHeight = aHeight;
61
62 // Initializations
63 qualitySlider = NULL;
64 width = NULL;
65 height = NULL;
66 colorButton = NULL;
67 BWButton = NULL;
68
69 // global layout
70 QVBoxLayout* globalVLayout = new QVBoxLayout(this);
71 globalVLayout->setMargin(10);
72 globalVLayout->setSpacing(10);
73
74
75
76
77 // size box
78
79 QWidget * sizeWidget = new QWidget(this); // widget containing group button
80 QVBoxLayout * sizeWidgetLayout = new QVBoxLayout(sizeWidget);
81 sizeWidgetLayout->setMargin (10);
82
83 // original and modify radiobuttons
84
85 sizeGroupBox = new QGroupBox(tr("Size"));
86 QVBoxLayout *sizeGroupBoxLayout = new QVBoxLayout(sizeGroupBox);
87 QButtonGroup * sizeButtonGroupBox = new QButtonGroup();
88 sizeGroupBoxLayout->setMargin (15);
89
90 original = new QRadioButton("Original");
91 modify = new QRadioButton("Modify");
92
93 sizeButtonGroupBox->addButton(original);
94 sizeButtonGroupBox->addButton(modify);
95 sizeButtonGroupBox->setExclusive(true);
96
97 sizeGroupBoxLayout->addWidget(original);
98 sizeGroupBoxLayout->addWidget(modify);
99
100 sizeGroupBox->setLayout(sizeGroupBoxLayout);
101 sizeWidgetLayout->addWidget(sizeGroupBox);
102
103 connect( sizeButtonGroupBox, SIGNAL( buttonClicked(QAbstractButton*) ), this, SLOT( changeSizeBox()) );
104 original->setChecked( true );
105
106
107 // height
108 heightWidget = new QWidget(sizeWidget);
109
110 QHBoxLayout *heightLineLayout = new QHBoxLayout(heightWidget);
111
112 QString tmp;
113
114 heightLineLayout->addWidget(new QLabel("Height",heightWidget));
115 height = new QLineEdit(tmp.setNum(originalHeight),heightWidget);
116 height->setMaxLength(5);
117 heightLineLayout->addWidget(height);
118
119 heightWidget->setLayout(heightLineLayout);
120
121 sizeWidgetLayout->addWidget(heightWidget);
122 connect( height, SIGNAL( textChanged ( const QString& ) ), this, SLOT( textHeightChanged(const QString &) ) );
123
124
125 // width
126 widthWidget = new QWidget(sizeWidget);
127
128 QHBoxLayout *widthLineLayout = new QHBoxLayout(widthWidget);
129
130 widthLineLayout->addWidget(new QLabel("Width ",widthWidget));
131 width = new QLineEdit(tmp.setNum(originalWidth),widthWidget);
132 width->setMaxLength(5);
133 widthLineLayout->addWidget(width);
134 widthWidget->setLayout(widthLineLayout);
135 sizeWidgetLayout->addWidget(widthWidget);
136 connect( width, SIGNAL( textChanged ( const QString& ) ), this, SLOT( textWidthChanged(const QString &) ) );
137
138
139
140 // ratio check box
141
142 ratioCheckBox = new QCheckBox( "Keep ratio",sizeWidget);
143 ratioCheckBox->setChecked( true );
144
145 sizeWidgetLayout->addWidget(ratioCheckBox);
146
147 ratioCheckBox->hide();
148 heightWidget->hide();
149 widthWidget->hide();
150
151 sizeWidget->setLayout(sizeWidgetLayout);
152 globalVLayout->addWidget(sizeWidget);
153
154 if (format == "eps") {
155
156 QGroupBox *EPSWidgetGroupBox = new QGroupBox(tr("EPS options"),this); // widget containing group button
157
158
159 QVBoxLayout * EPSGroupBoxLayout = new QVBoxLayout(EPSWidgetGroupBox);
160 EPSGroupBoxLayout->setMargin (15);
161
162// colorButton = new QRadioButton("Color",EPSWidgetGroupBox);
163// BWButton = new QRadioButton("Grayscale",EPSWidgetGroupBox);
164
165// QButtonGroup * EPSColorButtonGroupBox = new QButtonGroup();
166// EPSColorButtonGroupBox->addButton(colorButton);
167// EPSColorButtonGroupBox->addButton(BWButton);
168// EPSColorButtonGroupBox->setExclusive(true);
169
170// EPSGroupBoxLayout->addWidget(colorButton);
171// EPSGroupBoxLayout->addWidget(BWButton);
172
173 vectorEPSCheckBox = new QCheckBox( "Vector EPS File",EPSWidgetGroupBox);
174 EPSGroupBoxLayout->addWidget(vectorEPSCheckBox);
175
176 EPSWidgetGroupBox->setLayout(EPSGroupBoxLayout);
177 // colorButton->setChecked( true );
178 vectorEPSCheckBox->setChecked( true );
179
180 globalVLayout->addWidget(EPSWidgetGroupBox);
181 connect( vectorEPSCheckBox, SIGNAL( clicked() ), this, SLOT( changeVectorEPS()) );
182
183 }
184
185 if ((format == "jpg") ||
186 (format == "jpeg")) {
187
188 QGroupBox *imageGroupBox = new QGroupBox(tr("Image quality"),this);
189 QHBoxLayout *hSliderLayout = new QHBoxLayout(imageGroupBox);
190 hSliderLayout->setMargin (15);
191
192 qualitySlider= new QSlider(Qt::Horizontal,imageGroupBox);
193 qualitySlider->setMinimum(0);
194 qualitySlider->setMaximum(100);
195 qualitySlider->setTickPosition(QSlider::TicksBelow);
196 qualitySlider->setValue(60);
197 hSliderLayout->addWidget(new QLabel("Low ",imageGroupBox));
198 hSliderLayout->addWidget(qualitySlider);
199 hSliderLayout->addWidget(new QLabel(" Maximum",imageGroupBox));
200
201 imageGroupBox->setLayout(hSliderLayout);
202
203 globalVLayout->addWidget(imageGroupBox);
204 }
205
206
207 // button ok/cancel box
208
209 QWidget *buttonBox = new QWidget(this);
210
211 QHBoxLayout *buttonBoxLayout = new QHBoxLayout(buttonBox);
212
213 buttonOk = new QPushButton( tr( "&OK" ),buttonBox );
214 buttonOk->setAutoDefault( true );
215 buttonOk->setDefault( true );
216 buttonBoxLayout->addWidget(buttonOk);
217
218 buttonCancel = new QPushButton( tr( "&Cancel" ),buttonBox );
219 buttonCancel->setAutoDefault( true );
220 buttonBoxLayout->addWidget(buttonCancel);
221
222 buttonBox->setLayout(buttonBoxLayout);
223 globalVLayout->addWidget(buttonBox);
224
225
226
227 setLayout(globalVLayout);
228
229 // signals and slots connections
230 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
231 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
232}
233
234
235
237{
238 if (!qualitySlider) return -1;
239 return qualitySlider->value();
240}
241
243{
244 if (!height) return originalHeight;
245 return height->text().toInt();
246}
247
249{
250 if (!width) return originalWidth;
251 return width->text().toInt();
252}
253
255{
256 if (!vectorEPSCheckBox) return 0;
257 return vectorEPSCheckBox->isChecked();
258}
259
260
262{
263 if (!vectorEPSCheckBox) return;
264 if (vectorEPSCheckBox->isChecked()) {
265 sizeGroupBox->show();
266 original->show();
267 modify->show();
269 } else {
270 sizeGroupBox->hide();
271 original->hide();
272 modify->hide();
273 ratioCheckBox->hide();
274 heightWidget->hide();
275 widthWidget->hide();
276 }
277}
278
279
281{
282 if (!original) return;
283 if (!heightWidget) return;
284 if (!widthWidget) return;
285 if (!ratioCheckBox) return;
286
287 if ( original->isChecked()) {
288 ratioCheckBox->hide();
289 heightWidget->hide();
290 widthWidget->hide();
291 } else {
292 heightWidget->show();
293 widthWidget->show();
294 ratioCheckBox->show();
295 }
296}
297
298
300 const QString & s
301 )
302{
303 if (!ratioCheckBox) return;
304 if (!width) return;
305 if (isChangingSize == true) return; // exclusive slot
306
307 if (ratioCheckBox->isChecked()){
308 isChangingSize = true;
309 QString tmp;
310 height->setText(tmp.setNum((int)(s.toInt()*(double)((double)originalHeight/(double)originalWidth))));
311 isChangingSize = false;
312 }
313}
314
316 const QString & s
317)
318{
319 if (!ratioCheckBox) return;
320 if (!width) return;
321 if (isChangingSize == true) return; // exclusive slot
322
323 if (ratioCheckBox->isChecked()){
324 isChangingSize = true;
325 QString tmp;
326 width->setText(tmp.setNum(s.toInt()*originalWidth/originalHeight));
327 isChangingSize = false;
328 }
329}
330
332{
333}
void textHeightChanged(const QString &)
void textWidthChanged(const QString &)
G4OpenGLQtExportDialog(QWidget *parentw, QString format, int height=0, int width=0)