Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4OpenGLQtExportDialog Class Reference

#include <G4OpenGLQtExportDialog.hh>

+ Inheritance diagram for G4OpenGLQtExportDialog:

Public Slots

void changeSizeBox ()
 
void changeVectorEPS ()
 
void textWidthChanged (const QString &)
 
void textHeightChanged (const QString &)
 

Public Member Functions

 G4OpenGLQtExportDialog (QWidget *parentw, QString format, int height=0, int width=0)
 
 ~G4OpenGLQtExportDialog ()
 
int getSliderValue ()
 
int getWidth ()
 
int getHeight ()
 
bool getVectorEPS ()
 

Detailed Description

The G4OpenGLQtExportDialog class provide a Dialog displaying differents options for each file format

Definition at line 49 of file G4OpenGLQtExportDialog.hh.

Constructor & Destructor Documentation

◆ G4OpenGLQtExportDialog()

G4OpenGLQtExportDialog::G4OpenGLQtExportDialog ( QWidget * parentw,
QString format,
int height = 0,
int width = 0 )

Construct a G4OpenGLQtExportDialog

Parameters
parentw: parent widget
format: format of save file in lower case
height: height of the original file
width: width of the original file

Definition at line 49 of file G4OpenGLQtExportDialog.cc.

55 : QDialog( parentw ),
56 isChangingSize(false)
57{
58 setWindowTitle( tr( " Export options" ));
59 originalWidth = aWidth;
60 originalHeight = aHeight;
61
62 // Initializations
63 vectorEPSCheckBox = NULL;
64 qualitySlider = NULL;
65 width = NULL;
66 height = NULL;
67 colorButton = NULL;
68 BWButton = NULL;
69
70 // global layout
71 QVBoxLayout* globalVLayout = new QVBoxLayout(this);
72 globalVLayout->setContentsMargins(10,10,10,10);
73 globalVLayout->setSpacing(10);
74
75
76
77
78 // size box
79
80 QWidget * sizeWidget = new QWidget(this); // widget containing group button
81 QVBoxLayout * sizeWidgetLayout = new QVBoxLayout(sizeWidget);
82 sizeWidgetLayout->setContentsMargins(10,10,10,10);
83
84 // original and modify radiobuttons
85
86 sizeGroupBox = new QGroupBox(tr("Size"));
87 QVBoxLayout *sizeGroupBoxLayout = new QVBoxLayout(sizeGroupBox);
88 QButtonGroup * sizeButtonGroupBox = new QButtonGroup();
89 sizeGroupBoxLayout->setContentsMargins(15,15,15,15);
90
91 original = new QRadioButton("Original");
92 modify = new QRadioButton("Modify");
93
94 sizeButtonGroupBox->addButton(original);
95 sizeButtonGroupBox->addButton(modify);
96 sizeButtonGroupBox->setExclusive(true);
97
98 sizeGroupBoxLayout->addWidget(original);
99 sizeGroupBoxLayout->addWidget(modify);
100
101 sizeGroupBox->setLayout(sizeGroupBoxLayout);
102 sizeWidgetLayout->addWidget(sizeGroupBox);
103
104 connect( sizeButtonGroupBox, SIGNAL( buttonClicked(QAbstractButton*) ), this, SLOT( changeSizeBox()) );
105 original->setChecked( true );
106
107
108 // height
109 heightWidget = new QWidget(sizeWidget);
110
111 QHBoxLayout *heightLineLayout = new QHBoxLayout(heightWidget);
112
113 QString tmp;
114
115 heightLineLayout->addWidget(new QLabel("Height",heightWidget));
116 height = new QLineEdit(tmp.setNum(originalHeight),heightWidget);
117 height->setMaxLength(5);
118 heightLineLayout->addWidget(height);
119
120 heightWidget->setLayout(heightLineLayout);
121
122 sizeWidgetLayout->addWidget(heightWidget);
123 connect( height, SIGNAL( textChanged ( const QString& ) ), this, SLOT( textHeightChanged(const QString &) ) );
124
125
126 // width
127 widthWidget = new QWidget(sizeWidget);
128
129 QHBoxLayout *widthLineLayout = new QHBoxLayout(widthWidget);
130
131 widthLineLayout->addWidget(new QLabel("Width ",widthWidget));
132 width = new QLineEdit(tmp.setNum(originalWidth),widthWidget);
133 width->setMaxLength(5);
134 widthLineLayout->addWidget(width);
135 widthWidget->setLayout(widthLineLayout);
136 sizeWidgetLayout->addWidget(widthWidget);
137 connect( width, SIGNAL( textChanged ( const QString& ) ), this, SLOT( textWidthChanged(const QString &) ) );
138
139
140
141 // ratio check box
142
143 ratioCheckBox = new QCheckBox( "Keep ratio",sizeWidget);
144 ratioCheckBox->setChecked( true );
145
146 sizeWidgetLayout->addWidget(ratioCheckBox);
147
148 ratioCheckBox->hide();
149 heightWidget->hide();
150 widthWidget->hide();
151
152 sizeWidget->setLayout(sizeWidgetLayout);
153 globalVLayout->addWidget(sizeWidget);
154
155 if (format == "eps") {
156
157 QGroupBox *EPSWidgetGroupBox = new QGroupBox(tr("EPS options"),this); // widget containing group button
158
159
160 QVBoxLayout * EPSGroupBoxLayout = new QVBoxLayout(EPSWidgetGroupBox);
161 EPSGroupBoxLayout->setContentsMargins(15,15,15,15);
162
163// colorButton = new QRadioButton("Color",EPSWidgetGroupBox);
164// BWButton = new QRadioButton("Grayscale",EPSWidgetGroupBox);
165
166// QButtonGroup * EPSColorButtonGroupBox = new QButtonGroup();
167// EPSColorButtonGroupBox->addButton(colorButton);
168// EPSColorButtonGroupBox->addButton(BWButton);
169// EPSColorButtonGroupBox->setExclusive(true);
170
171// EPSGroupBoxLayout->addWidget(colorButton);
172// EPSGroupBoxLayout->addWidget(BWButton);
173
174 vectorEPSCheckBox = new QCheckBox( "Vector EPS File",EPSWidgetGroupBox);
175 EPSGroupBoxLayout->addWidget(vectorEPSCheckBox);
176
177 EPSWidgetGroupBox->setLayout(EPSGroupBoxLayout);
178 // colorButton->setChecked( true );
179 vectorEPSCheckBox->setChecked( true );
180
181 globalVLayout->addWidget(EPSWidgetGroupBox);
182 connect( vectorEPSCheckBox, SIGNAL( clicked() ), this, SLOT( changeVectorEPS()) );
183
184 }
185
186 if ((format == "jpg") ||
187 (format == "jpeg")) {
188
189 QGroupBox *imageGroupBox = new QGroupBox(tr("Image quality"),this);
190 QHBoxLayout *hSliderLayout = new QHBoxLayout(imageGroupBox);
191 hSliderLayout->setContentsMargins(15,15,15,15);
192
193 qualitySlider= new QSlider(Qt::Horizontal,imageGroupBox);
194 qualitySlider->setMinimum(0);
195 qualitySlider->setMaximum(100);
196 qualitySlider->setTickPosition(QSlider::TicksBelow);
197 qualitySlider->setValue(60);
198 hSliderLayout->addWidget(new QLabel("Low ",imageGroupBox));
199 hSliderLayout->addWidget(qualitySlider);
200 hSliderLayout->addWidget(new QLabel(" Maximum",imageGroupBox));
201
202 imageGroupBox->setLayout(hSliderLayout);
203
204 globalVLayout->addWidget(imageGroupBox);
205 }
206
207
208 // button ok/cancel box
209
210 QWidget *buttonBox = new QWidget(this);
211
212 QHBoxLayout *buttonBoxLayout = new QHBoxLayout(buttonBox);
213
214 buttonOk = new QPushButton( tr( "&OK" ),buttonBox );
215 buttonOk->setAutoDefault( true );
216 buttonOk->setDefault( true );
217 buttonBoxLayout->addWidget(buttonOk);
218
219 buttonCancel = new QPushButton( tr( "&Cancel" ),buttonBox );
220 buttonCancel->setAutoDefault( true );
221 buttonBoxLayout->addWidget(buttonCancel);
222
223 buttonBox->setLayout(buttonBoxLayout);
224 globalVLayout->addWidget(buttonBox);
225
226
227
228 setLayout(globalVLayout);
229
230 // signals and slots connections
231 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
232 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
233}
void textHeightChanged(const QString &)
void textWidthChanged(const QString &)

◆ ~G4OpenGLQtExportDialog()

G4OpenGLQtExportDialog::~G4OpenGLQtExportDialog ( )

Destroys G4OpenGLQtExportDialog

Definition at line 332 of file G4OpenGLQtExportDialog.cc.

333{
334}

Member Function Documentation

◆ changeSizeBox

void G4OpenGLQtExportDialog::changeSizeBox ( )
slot

Called by a clic on modify/original size button.This will invert buttons and hide/unhide size

Definition at line 281 of file G4OpenGLQtExportDialog.cc.

282{
283 if (!original) return;
284 if (!heightWidget) return;
285 if (!widthWidget) return;
286 if (!ratioCheckBox) return;
287
288 if ( original->isChecked()) {
289 ratioCheckBox->hide();
290 heightWidget->hide();
291 widthWidget->hide();
292 } else {
293 heightWidget->show();
294 widthWidget->show();
295 ratioCheckBox->show();
296 }
297}

Referenced by changeVectorEPS(), and G4OpenGLQtExportDialog().

◆ changeVectorEPS

void G4OpenGLQtExportDialog::changeVectorEPS ( )
slot

Called by a clic on vectorEPS check box.If vectorEPS checkBox is checked, it will enable change size buttons. Else it will disable them.

Definition at line 262 of file G4OpenGLQtExportDialog.cc.

263{
264 if (!vectorEPSCheckBox) return;
265 if (vectorEPSCheckBox->isChecked()) {
266 sizeGroupBox->show();
267 original->show();
268 modify->show();
270 } else {
271 sizeGroupBox->hide();
272 original->hide();
273 modify->hide();
274 ratioCheckBox->hide();
275 heightWidget->hide();
276 widthWidget->hide();
277 }
278}

Referenced by G4OpenGLQtExportDialog().

◆ getHeight()

int G4OpenGLQtExportDialog::getHeight ( )

return the new height for file if format has a height widget, instead return the original value

Definition at line 243 of file G4OpenGLQtExportDialog.cc.

244{
245 if (!height) return originalHeight;
246 return height->text().toInt();
247}

◆ getSliderValue()

int G4OpenGLQtExportDialog::getSliderValue ( )
Returns
the value of the slider if format has a slider widget, instead return -1

Definition at line 237 of file G4OpenGLQtExportDialog.cc.

238{
239 if (!qualitySlider) return -1;
240 return qualitySlider->value();
241}

◆ getVectorEPS()

bool G4OpenGLQtExportDialog::getVectorEPS ( )

return if vector EPS is checked, if button does'nt exist, return 0

Definition at line 255 of file G4OpenGLQtExportDialog.cc.

256{
257 if (!vectorEPSCheckBox) return 0;
258 return vectorEPSCheckBox->isChecked();
259}

◆ getWidth()

int G4OpenGLQtExportDialog::getWidth ( )

return the new width for file if format has a width widget, instead return the original value

Definition at line 249 of file G4OpenGLQtExportDialog.cc.

250{
251 if (!width) return originalWidth;
252 return width->text().toInt();
253}

◆ textHeightChanged

void G4OpenGLQtExportDialog::textHeightChanged ( const QString & s)
slot

Called by changing value in width lineEdit. If ratio is keep, will also change the height

Definition at line 316 of file G4OpenGLQtExportDialog.cc.

319{
320 if (!ratioCheckBox) return;
321 if (!width) return;
322 if (isChangingSize == true) return; // exclusive slot
323
324 if (ratioCheckBox->isChecked()){
325 isChangingSize = true;
326 QString tmp;
327 width->setText(tmp.setNum(s.toInt()*originalWidth/originalHeight));
328 isChangingSize = false;
329 }
330}

Referenced by G4OpenGLQtExportDialog().

◆ textWidthChanged

void G4OpenGLQtExportDialog::textWidthChanged ( const QString & s)
slot

Called by changing value in height lineEdit. If ratio is keep, will also change the width

Definition at line 300 of file G4OpenGLQtExportDialog.cc.

303{
304 if (!ratioCheckBox) return;
305 if (!width) return;
306 if (isChangingSize == true) return; // exclusive slot
307
308 if (ratioCheckBox->isChecked()){
309 isChangingSize = true;
310 QString tmp;
311 height->setText(tmp.setNum((int)(s.toInt()*(double)((double)originalHeight/(double)originalWidth))));
312 isChangingSize = false;
313 }
314}

Referenced by G4OpenGLQtExportDialog().


The documentation for this class was generated from the following files: