20 std::shared_ptr<GLogger> logger,
22 : QWidget(parent), log(logger) {
27 flcd.setFamilies({
"Helvetica"});
28 flcd.setPointSize(32);
37 vector<string> toggle_button_titles;
38 toggle_button_titles.emplace_back(
"Hidden\nLines");
39 toggle_button_titles.emplace_back(
"Anti\nAliasing");
40 toggle_button_titles.emplace_back(
"Auxiliary\nEdges");
41 toggle_button_titles.emplace_back(
"Field\nLines");
42 toggle_button_titles.emplace_back(
"Axes");
43 toggle_button_titles.emplace_back(
"Scale");
49 QStringList theta_angle_Set;
50 for (
int t = 0; t <= 180; t += 30) { theta_angle_Set << QString::number(t); }
51 QStringList phi_angle_Set;
52 for (
int t = 0; t <= 360; t += 30) { phi_angle_Set << QString::number(t); }
58 cameraTheta =
new QSlider(Qt::Horizontal);
59 cameraTheta->setRange(0, 180);
60 cameraTheta->setSingleStep(1);
61 cameraTheta->setValue(thetaValue);
62 cameraTheta->setTracking(
true);
64 auto cameraThetaLabel =
new QLabel(tr(
"θ"));
66 QLCDNumber* theta_LCD =
new QLCDNumber(
this);
67 theta_LCD->setFont(flcd);
68 theta_LCD->setMaximumSize(QSize(45, 45));
69 theta_LCD->setSegmentStyle(QLCDNumber::Flat);
71 thetaDropdown =
new QComboBox(
this);
72 thetaDropdown->addItems(theta_angle_Set);
73 thetaDropdown->setMaximumSize(QSize(100, 45));
75 auto cameraThetaLayout =
new QHBoxLayout;
76 cameraThetaLayout->addWidget(cameraThetaLabel);
77 cameraThetaLayout->addWidget(cameraTheta);
78 cameraThetaLayout->addWidget(theta_LCD);
79 cameraThetaLayout->addWidget(thetaDropdown);
81 cameraPhi =
new QSlider(Qt::Horizontal);
82 cameraPhi->setRange(0, 360);
83 cameraPhi->setSingleStep(1);
84 cameraPhi->setValue(phiValue);
85 cameraPhi->setTracking(
true);
87 auto cameraPhiLabel =
new QLabel(tr(
"ɸ"));
89 QLCDNumber* phi_LCD =
new QLCDNumber(
this);
90 phi_LCD->setFont(flcd);
91 phi_LCD->setMaximumSize(QSize(45, 45));
92 phi_LCD->setSegmentStyle(QLCDNumber::Flat);
94 phiDropdown =
new QComboBox(
this);
95 phiDropdown->addItems(phi_angle_Set);
96 phiDropdown->setMaximumSize(QSize(100, 45));
98 auto cameraPhiLayout =
new QHBoxLayout;
99 cameraPhiLayout->addWidget(cameraPhiLabel);
100 cameraPhiLayout->addWidget(cameraPhi);
101 cameraPhiLayout->addWidget(phi_LCD);
102 cameraPhiLayout->addWidget(phiDropdown);
104 QVBoxLayout* cameraDirectionLayout =
new QVBoxLayout;
105 cameraDirectionLayout->addLayout(cameraThetaLayout);
106 cameraDirectionLayout->addSpacing(12);
107 cameraDirectionLayout->addLayout(cameraPhiLayout);
109 QGroupBox* cameraAnglesGroup =
new QGroupBox(tr(
"Camera Direction"));
110 cameraAnglesGroup->setLayout(cameraDirectionLayout);
113 connect(cameraTheta, &QSlider::valueChanged,
this, &G4DisplayView::changeCameraDirection);
114 connect(cameraTheta, &QSlider::valueChanged, theta_LCD, qOverload<int>(&QLCDNumber::display));
117 connect(thetaDropdown, &QComboBox::currentTextChanged,
118 this, [
this](
const QString&) { setCameraDirection(0); });
120 connect(cameraPhi, &QSlider::valueChanged,
this, &G4DisplayView::changeCameraDirection);
121 connect(cameraPhi, &QSlider::valueChanged, phi_LCD, qOverload<int>(&QLCDNumber::display));
123 connect(phiDropdown, &QComboBox::currentTextChanged,
124 this, [
this](
const QString&) { setCameraDirection(1); });
131 QLabel* projLabel =
new QLabel(tr(
"Projection:"));
132 perspectiveDropdown =
new QComboBox;
133 perspectiveDropdown->addItem(tr(
"Orthogonal"));
134 perspectiveDropdown->addItem(tr(
"Perspective 30"));
135 perspectiveDropdown->addItem(tr(
"Perspective 45"));
136 perspectiveDropdown->addItem(tr(
"Perspective 60"));
139 QLabel* sides_per_circlesLabel =
new QLabel(tr(
"Sides per circle:"));
140 precisionDropdown =
new QComboBox;
141 precisionDropdown->addItem(tr(
"50"));
142 precisionDropdown->addItem(tr(
"100"));
143 precisionDropdown->addItem(tr(
"200"));
144 precisionDropdown->addItem(tr(
"300"));
145 precisionDropdown->setCurrentIndex(0);
147 connect(perspectiveDropdown, &QComboBox::currentTextChanged,
this, &G4DisplayView::set_projection);
148 connect(precisionDropdown, &QComboBox::currentTextChanged,
this, &G4DisplayView::set_precision);
150 QVBoxLayout* resolutionAndPerspectiveLayout =
new QVBoxLayout;
151 resolutionAndPerspectiveLayout->addWidget(projLabel);
152 resolutionAndPerspectiveLayout->addWidget(perspectiveDropdown);
153 resolutionAndPerspectiveLayout->addSpacing(12);
154 resolutionAndPerspectiveLayout->addWidget(sides_per_circlesLabel);
155 resolutionAndPerspectiveLayout->addWidget(precisionDropdown);
157 QGroupBox* propertyGroup =
new QGroupBox(tr(
"View Properties"));
158 propertyGroup->setLayout(resolutionAndPerspectiveLayout);
160 QHBoxLayout* cameraAndPerspective =
new QHBoxLayout;
161 cameraAndPerspective->addWidget(cameraAnglesGroup);
162 cameraAndPerspective->addSpacing(12);
163 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);
175 auto lightThetaLabel =
new QLabel(tr(
"θ"));
177 QLCDNumber* ltheta_LCD =
new QLCDNumber(
this);
178 ltheta_LCD->setFont(flcd);
179 ltheta_LCD->setMaximumSize(QSize(45, 45));
180 ltheta_LCD->setSegmentStyle(QLCDNumber::Flat);
182 lthetaDropdown =
new QComboBox(
this);
183 lthetaDropdown->addItems(theta_angle_Set);
184 lthetaDropdown->setMaximumSize(QSize(100, 45));
186 auto lightThetaLayout =
new QHBoxLayout;
187 lightThetaLayout->addWidget(lightThetaLabel);
188 lightThetaLayout->addWidget(lightTheta);
189 lightThetaLayout->addWidget(ltheta_LCD);
190 lightThetaLayout->addWidget(lthetaDropdown);
192 lightPhi =
new QSlider(Qt::Horizontal);
193 lightPhi->setRange(0, 360);
194 lightPhi->setSingleStep(1);
195 lightPhi->setValue(phiValue);
196 lightPhi->setTracking(
true);
198 auto lightPhiLabel =
new QLabel(tr(
"ɸ"));
200 QLCDNumber* lphi_LCD =
new QLCDNumber(
this);
201 lphi_LCD->setFont(flcd);
202 lphi_LCD->setMaximumSize(QSize(45, 45));
203 lphi_LCD->setSegmentStyle(QLCDNumber::Flat);
205 lphiDropdown =
new QComboBox(
this);
206 lphiDropdown->addItems(phi_angle_Set);
207 lphiDropdown->setMaximumSize(QSize(100, 45));
209 auto lightPhiLayout =
new QHBoxLayout;
210 lightPhiLayout->addWidget(lightPhiLabel);
211 lightPhiLayout->addWidget(lightPhi);
212 lightPhiLayout->addWidget(lphi_LCD);
213 lightPhiLayout->addWidget(lphiDropdown);
215 auto lightDirectionLayout =
new QVBoxLayout;
216 lightDirectionLayout->addLayout(lightThetaLayout);
217 lightDirectionLayout->addSpacing(12);
218 lightDirectionLayout->addLayout(lightPhiLayout);
220 QGroupBox* lightAnglesGroup =
new QGroupBox(tr(
"Light Direction"));
221 lightAnglesGroup->setLayout(lightDirectionLayout);
223 connect(lightTheta, &QSlider::valueChanged,
this, &G4DisplayView::changeLightDirection);
224 connect(lightTheta, &QSlider::valueChanged, ltheta_LCD, qOverload<int>(&QLCDNumber::display));
225 connect(lthetaDropdown, &QComboBox::currentTextChanged,
226 this, [
this](
const QString&) { 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&) { 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"));
247 QLabel* backgroundColorLabel =
new QLabel(tr(
"Background Color:"));
248 backgroundColorDropdown =
new QComboBox;
249 backgroundColorDropdown->addItem(tr(
"lightslategray"));
250 backgroundColorDropdown->addItem(tr(
"ghostwhite"));
251 backgroundColorDropdown->addItem(tr(
"black"));
252 backgroundColorDropdown->addItem(tr(
"navy"));
253 backgroundColorDropdown->addItem(tr(
"whitesmoke"));
254 backgroundColorDropdown->addItem(tr(
"lightskyblue"));
255 backgroundColorDropdown->addItem(tr(
"deepskyblue"));
256 backgroundColorDropdown->addItem(tr(
"lightsteelblue"));
257 backgroundColorDropdown->addItem(tr(
"blueviolet"));
258 backgroundColorDropdown->addItem(tr(
"turquoise"));
259 backgroundColorDropdown->addItem(tr(
"mediumaquamarine"));
260 backgroundColorDropdown->addItem(tr(
"springgreen"));
261 backgroundColorDropdown->addItem(tr(
"lawngreen"));
262 backgroundColorDropdown->addItem(tr(
"yellowgreen"));
263 backgroundColorDropdown->addItem(tr(
"lemonchiffon"));
264 backgroundColorDropdown->addItem(tr(
"antiquewhite"));
265 backgroundColorDropdown->addItem(tr(
"wheat"));
266 backgroundColorDropdown->addItem(tr(
"sienna"));
267 backgroundColorDropdown->addItem(tr(
"snow"));
268 backgroundColorDropdown->addItem(tr(
"floralwhite"));
269 backgroundColorDropdown->addItem(tr(
"lightsalmon"));
270 backgroundColorDropdown->addItem(tr(
"orchid"));
271 backgroundColorDropdown->addItem(tr(
"plum"));
272 backgroundColorDropdown->setCurrentIndex(0);
274 connect(cullingDropdown, &QComboBox::currentTextChanged,
this, &G4DisplayView::set_culling);
275 connect(backgroundColorDropdown, &QComboBox::currentTextChanged,
this, &G4DisplayView::set_background);
277 QVBoxLayout* sceneLayout =
new QVBoxLayout;
278 sceneLayout->addWidget(cullingLabel);
279 sceneLayout->addWidget(cullingDropdown);
280 sceneLayout->addSpacing(12);
281 sceneLayout->addWidget(backgroundColorLabel);
282 sceneLayout->addWidget(backgroundColorDropdown);
284 QGroupBox* spropertyGroup =
new QGroupBox(tr(
"Scene Properties"));
285 spropertyGroup->setLayout(sceneLayout);
287 QHBoxLayout* lightAndProperties =
new QHBoxLayout;
288 lightAndProperties->addWidget(lightAnglesGroup);
289 lightAndProperties->addSpacing(12);
290 lightAndProperties->addWidget(spropertyGroup);
297 sliceXEdit =
new QLineEdit(tr(
"0"));
298 sliceXEdit->setMaximumWidth(100);
299 sliceXActi =
new QCheckBox(tr(
"&On"));
300 sliceXActi->setChecked(
false);
301 sliceXInve =
new QCheckBox(tr(
"&Flip"));
302 sliceXInve->setChecked(
false);
304 auto sliceXLayout =
new QHBoxLayout;
305 sliceXLayout->addWidget(
new QLabel(tr(
"X: ")));
306 sliceXLayout->addWidget(sliceXEdit);
307 sliceXLayout->addStretch(1);
308 sliceXLayout->addWidget(sliceXActi);
309 sliceXLayout->addWidget(sliceXInve);
310 sliceXLayout->addStretch(1);
313 sliceYEdit =
new QLineEdit(tr(
"0"));
314 sliceYEdit->setMaximumWidth(100);
315 sliceYActi =
new QCheckBox(tr(
"&On"));
316 sliceYActi->setChecked(
false);
317 sliceYInve =
new QCheckBox(tr(
"&Flip"));
318 sliceYInve->setChecked(
false);
320 auto sliceYLayout =
new QHBoxLayout;
321 sliceYLayout->addWidget(
new QLabel(tr(
"Y: ")));
322 sliceYLayout->addWidget(sliceYEdit);
323 sliceYLayout->addStretch(1);
324 sliceYLayout->addWidget(sliceYActi);
325 sliceYLayout->addWidget(sliceYInve);
326 sliceYLayout->addStretch(1);
329 sliceZEdit =
new QLineEdit(tr(
"0"));
330 sliceZEdit->setMaximumWidth(100);
331 sliceZActi =
new QCheckBox(tr(
"&On"));
332 sliceZActi->setChecked(
false);
333 sliceZInve =
new QCheckBox(tr(
"&Flip"));
334 sliceZInve->setChecked(
false);
336 auto sliceZLayout =
new QHBoxLayout;
337 sliceZLayout->addWidget(
new QLabel(tr(
"Z: ")));
338 sliceZLayout->addWidget(sliceZEdit);
339 sliceZLayout->addStretch(1);
340 sliceZLayout->addWidget(sliceZActi);
341 sliceZLayout->addWidget(sliceZInve);
342 sliceZLayout->addStretch(1);
345 QPushButton* clearSliceButton =
new QPushButton(tr(
"Clear Slices"));
346 clearSliceButton->setToolTip(
"Clear Slice Planes");
347 clearSliceButton->setIcon(QIcon::fromTheme(
"edit-clear"));
348 clearSliceButton->setIconSize(QSize(16, 16));
349 connect(clearSliceButton, &QPushButton::clicked,
this, &G4DisplayView::clearSlices);
352 QGroupBox* sliceChoiceBox =
new QGroupBox(tr(
"Slices Style"));
353 sliceSectn =
new QRadioButton(tr(
"&Intersection"), sliceChoiceBox);
354 sliceUnion =
new QRadioButton(tr(
"&Union"), sliceChoiceBox);
355 sliceSectn->setChecked(
true);
357 connect(sliceSectn, &QRadioButton::toggled,
this, &G4DisplayView::slice);
358 connect(sliceUnion, &QRadioButton::toggled,
this, &G4DisplayView::slice);
360 auto sliceChoiceLayout =
new QHBoxLayout;
361 sliceChoiceLayout->addWidget(sliceSectn);
362 sliceChoiceLayout->addWidget(sliceUnion);
363 sliceChoiceBox->setLayout(sliceChoiceLayout);
366 auto sliceLayout =
new QVBoxLayout;
367 sliceLayout->addLayout(sliceXLayout);
368 sliceLayout->addLayout(sliceYLayout);
369 sliceLayout->addLayout(sliceZLayout);
370 sliceLayout->addWidget(sliceChoiceBox);
371 sliceLayout->addWidget(clearSliceButton);
374 connect(sliceXEdit, &QLineEdit::returnPressed,
this, &G4DisplayView::slice);
375 connect(sliceYEdit, &QLineEdit::returnPressed,
this, &G4DisplayView::slice);
376 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);
398 QGroupBox* fieldPrecisionBox =
new QGroupBox(tr(
"Number of Field Points"));
399 field_npoints =
new QLineEdit(QString::number(field_NPOINTS),
this);
400 field_npoints->setMaximumWidth(40);
402 QFont font = field_npoints->font();
403 font.setPointSize(24);
404 field_npoints->setFont(font);
406 connect(field_npoints, &QLineEdit::returnPressed,
this, &G4DisplayView::field_precision_changed);
409 auto fieldPointsHBox =
new QHBoxLayout;
410 fieldPointsHBox->addWidget(field_npoints);
411 fieldPrecisionBox->setLayout(fieldPointsHBox);
413 auto buttons_field_HBox =
new QHBoxLayout;
414 buttons_field_HBox->addWidget(buttons_set1);
415 buttons_field_HBox->addWidget(fieldPrecisionBox);
416 fieldPrecisionBox->setMaximumHeight(3 * buttons_set1->height());
417 fieldPrecisionBox->setMaximumWidth(140);
423 auto mainLayout =
new QVBoxLayout;
424 mainLayout->addLayout(buttons_field_HBox);
425 mainLayout->addLayout(cameraAndPerspective);
426 mainLayout->addLayout(lightAndProperties);
427 mainLayout->addLayout(sliceLayout);
428 setLayout(mainLayout);