29 QWidget* parent) : QWidget(parent), log(logger) {
30 log->debug(CONSTRUCTOR,
"G4DisplayView");
34 flcd.setFamilies({
"Helvetica"});
35 flcd.setPointSize(32);
40 double thetaValue = getG4Number(jcamera.theta);
41 double phiValue = getG4Number(jcamera.phi);
43 vector<string> toggle_button_titles;
44 toggle_button_titles.emplace_back(
"Hidden\nLines");
45 toggle_button_titles.emplace_back(
"Anti\nAliasing");
46 toggle_button_titles.emplace_back(
"Auxiliary\nEdges");
47 toggle_button_titles.emplace_back(
"Field\nLines");
48 toggle_button_titles.emplace_back(
"Axes");
49 toggle_button_titles.emplace_back(
"Scale");
52 buttons_set1 =
new GQTToggleButtonWidget(80, 80, 20, toggle_button_titles,
false,
this);
53 connect(buttons_set1, &GQTToggleButtonWidget::buttonPressedIndexChanged,
this, &G4DisplayView::apply_buttons_set1);
56 QStringList theta_angle_Set;
57 for (
int t = 0; t <= 180; t += 30) { theta_angle_Set << QString::number(t); }
58 QStringList phi_angle_Set;
59 for (
int t = 0; t <= 360; t += 30) { phi_angle_Set << QString::number(t); }
62 cameraTheta =
new QSlider(Qt::Horizontal);
63 cameraTheta->setRange(0, 180);
64 cameraTheta->setSingleStep(1);
65 cameraTheta->setValue(thetaValue);
66 cameraTheta->setTracking(
true);
68 auto cameraThetaLabel =
new QLabel(tr(
"θ"));
70 QLCDNumber* theta_LCD =
new QLCDNumber(
this);
71 theta_LCD->setFont(flcd);
72 theta_LCD->setMaximumSize(QSize(45, 45));
73 theta_LCD->setSegmentStyle(QLCDNumber::Flat);
75 thetaDropdown =
new QComboBox(
this);
76 thetaDropdown->addItems(theta_angle_Set);
77 thetaDropdown->setMaximumSize(QSize(100, 45));
79 auto cameraThetaLayout =
new QHBoxLayout;
80 cameraThetaLayout->addWidget(cameraThetaLabel);
81 cameraThetaLayout->addWidget(cameraTheta);
82 cameraThetaLayout->addWidget(theta_LCD);
83 cameraThetaLayout->addWidget(thetaDropdown);
85 cameraPhi =
new QSlider(Qt::Horizontal);
86 cameraPhi->setRange(0, 360);
87 cameraPhi->setSingleStep(1);
88 cameraPhi->setValue(phiValue);
89 cameraPhi->setTracking(
true);
90 auto cameraPhiLabel =
new QLabel(tr(
"ɸ"));
92 QLCDNumber* phi_LCD =
new QLCDNumber(
this);
93 phi_LCD->setFont(flcd);
94 phi_LCD->setMaximumSize(QSize(45, 45));
95 phi_LCD->setSegmentStyle(QLCDNumber::Flat);
97 phiDropdown =
new QComboBox(
this);
98 phiDropdown->addItems(phi_angle_Set);
99 phiDropdown->setMaximumSize(QSize(100, 45));
101 auto cameraPhiLayout =
new QHBoxLayout;
102 cameraPhiLayout->addWidget(cameraPhiLabel);
103 cameraPhiLayout->addWidget(cameraPhi);
104 cameraPhiLayout->addWidget(phi_LCD);
105 cameraPhiLayout->addWidget(phiDropdown);
108 QVBoxLayout* cameraDirectionLayout =
new QVBoxLayout;
109 cameraDirectionLayout->addLayout(cameraThetaLayout);
110 cameraDirectionLayout->addSpacing(12);
111 cameraDirectionLayout->addLayout(cameraPhiLayout);
114 QGroupBox* cameraAnglesGroup =
new QGroupBox(tr(
"Camera Direction"));
115 cameraAnglesGroup->setLayout(cameraDirectionLayout);
117 connect(cameraTheta, &QSlider::valueChanged,
this, &G4DisplayView::changeCameraDirection);
118 connect(cameraTheta, &QSlider::valueChanged, theta_LCD, qOverload<int>(&QLCDNumber::display));
119 connect(thetaDropdown, &QComboBox::currentTextChanged,
120 this, [
this](
const QString&) {
121 setCameraDirection(0);
124 connect(cameraPhi, &QSlider::valueChanged,
this, &G4DisplayView::changeCameraDirection);
125 connect(cameraPhi, &QSlider::valueChanged, phi_LCD, qOverload<int>(&QLCDNumber::display));
126 connect(phiDropdown, &QComboBox::currentTextChanged,
127 this, [
this](
const QString&) {
128 setCameraDirection(1);
133 QLabel* projLabel =
new QLabel(tr(
"Projection:"));
134 perspectiveDropdown =
new QComboBox;
135 perspectiveDropdown->addItem(tr(
"Orthogonal"));
136 perspectiveDropdown->addItem(tr(
"Perspective 30"));
137 perspectiveDropdown->addItem(tr(
"Perspective 45"));
138 perspectiveDropdown->addItem(tr(
"Perspective 60"));
140 QLabel* sides_per_circlesLabel =
new QLabel(tr(
"Sides per circle:"));
141 precisionDropdown =
new QComboBox;
142 precisionDropdown->addItem(tr(
"50"));
143 precisionDropdown->addItem(tr(
"100"));
144 precisionDropdown->addItem(tr(
"200"));
145 precisionDropdown->addItem(tr(
"300"));
146 precisionDropdown->setCurrentIndex(0);
148 connect(perspectiveDropdown, &QComboBox::currentTextChanged,
this, &G4DisplayView::set_projection);
149 connect(precisionDropdown, &QComboBox::currentTextChanged,
this, &G4DisplayView::set_precision);
152 QVBoxLayout* resolutionAndPerspectiveLayout =
new QVBoxLayout;
153 resolutionAndPerspectiveLayout->addWidget(projLabel);
154 resolutionAndPerspectiveLayout->addWidget(perspectiveDropdown);
155 resolutionAndPerspectiveLayout->addSpacing(12);
156 resolutionAndPerspectiveLayout->addWidget(sides_per_circlesLabel);
157 resolutionAndPerspectiveLayout->addWidget(precisionDropdown);
159 QGroupBox* propertyGroup =
new QGroupBox(tr(
"View Properties"));
160 propertyGroup->setLayout(resolutionAndPerspectiveLayout);
162 QHBoxLayout* cameraAndPerspective =
new QHBoxLayout;
163 cameraAndPerspective->addWidget(cameraAnglesGroup);
164 cameraAndPerspective->addSpacing(12);
165 cameraAndPerspective->addWidget(propertyGroup);
169 lightTheta =
new QSlider(Qt::Horizontal);
170 lightTheta->setRange(0, 180);
171 lightTheta->setSingleStep(1);
172 lightTheta->setValue(thetaValue);
173 lightTheta->setTracking(
true);
174 auto lightThetaLabel =
new QLabel(tr(
"θ"));
176 QLCDNumber* ltheta_LCD =
new QLCDNumber(
this);
177 ltheta_LCD->setFont(flcd);
178 ltheta_LCD->setMaximumSize(QSize(45, 45));
179 ltheta_LCD->setSegmentStyle(QLCDNumber::Flat);
181 lthetaDropdown =
new QComboBox(
this);
182 lthetaDropdown->addItems(theta_angle_Set);
183 lthetaDropdown->setMaximumSize(QSize(100, 45));
185 auto lightThetaLayout =
new QHBoxLayout;
186 lightThetaLayout->addWidget(lightThetaLabel);
187 lightThetaLayout->addWidget(lightTheta);
188 lightThetaLayout->addWidget(ltheta_LCD);
189 lightThetaLayout->addWidget(lthetaDropdown);
191 lightPhi =
new QSlider(Qt::Horizontal);
192 lightPhi->setRange(0, 360);
193 lightPhi->setSingleStep(1);
194 lightPhi->setValue(phiValue);
195 lightPhi->setTracking(
true);
196 auto lightPhiLabel =
new QLabel(tr(
"ɸ"));
198 QLCDNumber* lphi_LCD =
new QLCDNumber(
this);
199 lphi_LCD->setFont(flcd);
200 lphi_LCD->setMaximumSize(QSize(45, 45));
201 lphi_LCD->setSegmentStyle(QLCDNumber::Flat);
203 lphiDropdown =
new QComboBox(
this);
204 lphiDropdown->addItems(phi_angle_Set);
205 lphiDropdown->setMaximumSize(QSize(100, 45));
207 auto lightPhiLayout =
new QHBoxLayout;
208 lightPhiLayout->addWidget(lightPhiLabel);
209 lightPhiLayout->addWidget(lightPhi);
210 lightPhiLayout->addWidget(lphi_LCD);
211 lightPhiLayout->addWidget(lphiDropdown);
213 auto lightDirectionLayout =
new QVBoxLayout;
214 lightDirectionLayout->addLayout(lightThetaLayout);
215 lightDirectionLayout->addSpacing(12);
216 lightDirectionLayout->addLayout(lightPhiLayout);
218 QGroupBox* lightAnglesGroup =
new QGroupBox(tr(
"Light Direction"));
219 lightAnglesGroup->setLayout(lightDirectionLayout);
221 connect(lightTheta, &QSlider::valueChanged,
this, &G4DisplayView::changeLightDirection);
222 connect(lightTheta, &QSlider::valueChanged, ltheta_LCD, qOverload<int>(&QLCDNumber::display));
223 connect(lthetaDropdown, &QComboBox::currentTextChanged,
224 this, [
this](
const QString&) {
225 setLightDirection(0);
228 connect(lightPhi, &QSlider::valueChanged,
this, &G4DisplayView::changeLightDirection);
229 connect(lightPhi, &QSlider::valueChanged, lphi_LCD, qOverload<int>(&QLCDNumber::display));
230 connect(lphiDropdown, &QComboBox::currentTextChanged,
231 this, [
this](
const QString&) {
232 setLightDirection(1);
237 QLabel* cullingLabel =
new QLabel(tr(
"Culling:"));
238 cullingDropdown =
new QComboBox;
239 cullingDropdown->addItem(tr(
"Reset"));
240 cullingDropdown->addItem(tr(
"Covered Daughters"));
241 cullingDropdown->addItem(tr(
"Density: 1 mg/cm3"));
242 cullingDropdown->addItem(tr(
"Density: 10 mg/cm3"));
243 cullingDropdown->addItem(tr(
"Density: 100 mg/cm3"));
244 cullingDropdown->addItem(tr(
"Density: 1 g/cm3"));
245 cullingDropdown->addItem(tr(
"Density: 10 g/cm3"));
248 QLabel* backgroundColorLabel =
new QLabel(tr(
"Background Color:"));
249 backgroundColorDropdown =
new QComboBox;
250 backgroundColorDropdown->addItem(tr(
"lightslategray"));
251 backgroundColorDropdown->addItem(tr(
"ghostwhite"));
252 backgroundColorDropdown->addItem(tr(
"black"));
253 backgroundColorDropdown->addItem(tr(
"navy"));
254 backgroundColorDropdown->addItem(tr(
"whitesmoke"));
255 backgroundColorDropdown->addItem(tr(
"lightskyblue"));
256 backgroundColorDropdown->addItem(tr(
"deepskyblue"));
257 backgroundColorDropdown->addItem(tr(
"lightsteelblue"));
258 backgroundColorDropdown->addItem(tr(
"blueviolet"));
259 backgroundColorDropdown->addItem(tr(
"turquoise"));
260 backgroundColorDropdown->addItem(tr(
"mediumaquamarine"));
261 backgroundColorDropdown->addItem(tr(
"springgreen"));
262 backgroundColorDropdown->addItem(tr(
"lawngreen"));
263 backgroundColorDropdown->addItem(tr(
"yellowgreen"));
264 backgroundColorDropdown->addItem(tr(
"lemonchiffon"));
265 backgroundColorDropdown->addItem(tr(
"antiquewhite"));
266 backgroundColorDropdown->addItem(tr(
"wheat"));
267 backgroundColorDropdown->addItem(tr(
"sienna"));
268 backgroundColorDropdown->addItem(tr(
"snow"));
269 backgroundColorDropdown->addItem(tr(
"floralwhite"));
270 backgroundColorDropdown->addItem(tr(
"lightsalmon"));
271 backgroundColorDropdown->addItem(tr(
"orchid"));
272 backgroundColorDropdown->addItem(tr(
"plum"));
273 backgroundColorDropdown->setCurrentIndex(0);
276 connect(cullingDropdown, &QComboBox::currentTextChanged,
this, &G4DisplayView::set_culling);
277 connect(backgroundColorDropdown, &QComboBox::currentTextChanged,
this, &G4DisplayView::set_background);
279 QVBoxLayout* sceneLayout =
new QVBoxLayout;
280 sceneLayout->addWidget(cullingLabel);
281 sceneLayout->addWidget(cullingDropdown);
282 sceneLayout->addSpacing(12);
283 sceneLayout->addWidget(backgroundColorLabel);
284 sceneLayout->addWidget(backgroundColorDropdown);
286 QGroupBox* spropertyGroup =
new QGroupBox(tr(
"Scene Properties"));
287 spropertyGroup->setLayout(sceneLayout);
289 QHBoxLayout* lightAndProperties =
new QHBoxLayout;
290 lightAndProperties->addWidget(lightAnglesGroup);
291 lightAndProperties->addSpacing(12);
292 lightAndProperties->addWidget(spropertyGroup);
296 sliceXEdit =
new QLineEdit(tr(
"0"));
297 sliceXEdit->setMaximumWidth(100);
298 sliceXActi =
new QCheckBox(tr(
"&On"));
299 sliceXActi->setChecked(
false);
300 sliceXInve =
new QCheckBox(tr(
"&Flip"));
301 sliceXInve->setChecked(
false);
302 auto sliceXLayout =
new QHBoxLayout;
303 sliceXLayout->addWidget(
new QLabel(tr(
"X: ")));
304 sliceXLayout->addWidget(sliceXEdit);
305 sliceXLayout->addStretch(1);
306 sliceXLayout->addWidget(sliceXActi);
307 sliceXLayout->addWidget(sliceXInve);
308 sliceXLayout->addStretch(1);
311 sliceYEdit =
new QLineEdit(tr(
"0"));
312 sliceYEdit->setMaximumWidth(100);
313 sliceYActi =
new QCheckBox(tr(
"&On"));
314 sliceYActi->setChecked(
false);
315 sliceYInve =
new QCheckBox(tr(
"&Flip"));
316 sliceYInve->setChecked(
false);
317 auto sliceYLayout =
new QHBoxLayout;
318 sliceYLayout->addWidget(
new QLabel(tr(
"Y: ")));
319 sliceYLayout->addWidget(sliceYEdit);
320 sliceYLayout->addStretch(1);
321 sliceYLayout->addWidget(sliceYActi);
322 sliceYLayout->addWidget(sliceYInve);
323 sliceYLayout->addStretch(1);
326 sliceZEdit =
new QLineEdit(tr(
"0"));
327 sliceZEdit->setMaximumWidth(100);
328 sliceZActi =
new QCheckBox(tr(
"&On"));
329 sliceZActi->setChecked(
false);
330 sliceZInve =
new QCheckBox(tr(
"&Flip"));
331 sliceZInve->setChecked(
false);
332 auto sliceZLayout =
new QHBoxLayout;
333 sliceZLayout->addWidget(
new QLabel(tr(
"Z: ")));
334 sliceZLayout->addWidget(sliceZEdit);
335 sliceZLayout->addStretch(1);
336 sliceZLayout->addWidget(sliceZActi);
337 sliceZLayout->addWidget(sliceZInve);
338 sliceZLayout->addStretch(1);
341 QPushButton* clearSliceButton =
new QPushButton(tr(
"Clear Slices"));
342 clearSliceButton->setToolTip(
"Clear Slice Planes");
343 clearSliceButton->setIcon(QIcon::fromTheme(
"edit-clear"));
344 clearSliceButton->setIconSize(QSize(16, 16));
346 connect(clearSliceButton, &QPushButton::clicked,
this, &G4DisplayView::clearSlices);
349 QGroupBox* sliceChoiceBox =
new QGroupBox(tr(
"Slices Style"));
350 sliceSectn =
new QRadioButton(tr(
"&Intersection"), sliceChoiceBox);
351 sliceUnion =
new QRadioButton(tr(
"&Union"), sliceChoiceBox);
352 sliceSectn->setChecked(
true);
354 connect(sliceSectn, &QRadioButton::toggled,
this, &G4DisplayView::slice);
355 connect(sliceUnion, &QRadioButton::toggled,
this, &G4DisplayView::slice);
357 auto sliceChoiceLayout =
new QHBoxLayout;
358 sliceChoiceLayout->addWidget(sliceSectn);
359 sliceChoiceLayout->addWidget(sliceUnion);
360 sliceChoiceBox->setLayout(sliceChoiceLayout);
364 auto sliceLayout =
new QVBoxLayout;
365 sliceLayout->addLayout(sliceXLayout);
366 sliceLayout->addLayout(sliceYLayout);
367 sliceLayout->addLayout(sliceZLayout);
368 sliceLayout->addWidget(sliceChoiceBox);
369 sliceLayout->addWidget(clearSliceButton);
373 connect(sliceXEdit, &QLineEdit::returnPressed,
this, &G4DisplayView::slice);
374 connect(sliceYEdit, &QLineEdit::returnPressed,
this, &G4DisplayView::slice);
375 connect(sliceZEdit, &QLineEdit::returnPressed,
this, &G4DisplayView::slice);
378#if QT_VERSION < QT_VERSION_CHECK(6, 7, 0)
379 connect(sliceXActi, &QCheckBox::stateChanged,
this, &G4DisplayView::slice);
380 connect(sliceYActi, &QCheckBox::stateChanged,
this, &G4DisplayView::slice);
381 connect(sliceZActi, &QCheckBox::stateChanged,
this, &G4DisplayView::slice);
382 connect(sliceXInve, &QCheckBox::stateChanged,
this, &G4DisplayView::slice);
383 connect(sliceYInve, &QCheckBox::stateChanged,
this, &G4DisplayView::slice);
384 connect(sliceZInve, &QCheckBox::stateChanged,
this, &G4DisplayView::slice);
386 connect(sliceXActi, &QCheckBox::checkStateChanged,
this, &G4DisplayView::slice);
387 connect(sliceYActi, &QCheckBox::checkStateChanged,
this, &G4DisplayView::slice);
388 connect(sliceZActi, &QCheckBox::checkStateChanged,
this, &G4DisplayView::slice);
389 connect(sliceXInve, &QCheckBox::checkStateChanged,
this, &G4DisplayView::slice);
390 connect(sliceYInve, &QCheckBox::checkStateChanged,
this, &G4DisplayView::slice);
391 connect(sliceZInve, &QCheckBox::checkStateChanged,
this, &G4DisplayView::slice);
395 QGroupBox* fieldPrecisionBox =
new QGroupBox(tr(
"Number of Field Points"));
396 field_npoints =
new QLineEdit(QString::number(field_NPOINTS),
this);
397 field_npoints->setMaximumWidth(40);
399 QFont font = field_npoints->font();
400 font.setPointSize(24);
401 field_npoints->setFont(font);
402 connect(field_npoints, &QLineEdit::returnPressed,
this, &G4DisplayView::field_precision_changed);
405 auto fieldPointsHBox =
new QHBoxLayout;
406 fieldPointsHBox->addWidget(field_npoints);
407 fieldPrecisionBox->setLayout(fieldPointsHBox);
409 auto buttons_field_HBox =
new QHBoxLayout;
410 buttons_field_HBox->addWidget(buttons_set1);
411 buttons_field_HBox->addWidget(fieldPrecisionBox);
412 fieldPrecisionBox->setMaximumHeight(3 * buttons_set1->height());
413 fieldPrecisionBox->setMaximumWidth(140);
417 auto mainLayout =
new QVBoxLayout;
418 mainLayout->addLayout(buttons_field_HBox);
419 mainLayout->addLayout(cameraAndPerspective);
420 mainLayout->addLayout(lightAndProperties);
421 mainLayout->addLayout(sliceLayout);
422 setLayout(mainLayout);