Geant4 11.1.1
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 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}
void textHeightChanged(const QString &)
void textWidthChanged(const QString &)

◆ ~G4OpenGLQtExportDialog()

G4OpenGLQtExportDialog::~G4OpenGLQtExportDialog ( )

Destroys G4OpenGLQtExportDialog

Definition at line 331 of file G4OpenGLQtExportDialog.cc.

332{
333}

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 280 of file G4OpenGLQtExportDialog.cc.

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}

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 261 of file G4OpenGLQtExportDialog.cc.

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}

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 242 of file G4OpenGLQtExportDialog.cc.

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

◆ getSliderValue()

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

Definition at line 236 of file G4OpenGLQtExportDialog.cc.

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

◆ getVectorEPS()

bool G4OpenGLQtExportDialog::getVectorEPS ( )

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

Definition at line 254 of file G4OpenGLQtExportDialog.cc.

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

◆ getWidth()

int G4OpenGLQtExportDialog::getWidth ( )

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

Definition at line 248 of file G4OpenGLQtExportDialog.cc.

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

◆ 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 315 of file G4OpenGLQtExportDialog.cc.

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}

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 299 of file G4OpenGLQtExportDialog.cc.

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}

Referenced by G4OpenGLQtExportDialog().


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