20 std::shared_ptr<GLogger> logger,
22 : QWidget(parent), log(logger) {
27 flcd.setFamilies({
"Helvetica"});
28 flcd.setPointSize(32);
40 vector<string> toggle_button_titles;
41 toggle_button_titles.emplace_back(
"Hidden\nLines");
42 toggle_button_titles.emplace_back(
"Anti\nAliasing");
43 toggle_button_titles.emplace_back(
"Auxiliary\nEdges");
44 toggle_button_titles.emplace_back(
"Field\nLines");
45 toggle_button_titles.emplace_back(
"Axes");
46 toggle_button_titles.emplace_back(
"Scale");
52 QStringList theta_angle_Set;
53 for (
int t = 0; t <= 180; t += 30) { theta_angle_Set << QString::number(t); }
54 QStringList phi_angle_Set;
55 for (
int t = 0; t <= 360; t += 30) { phi_angle_Set << QString::number(t); }
61 cameraTheta =
new QSlider(Qt::Horizontal);
62 cameraTheta->setRange(0, 180);
63 cameraTheta->setSingleStep(1);
64 cameraTheta->setValue(thetaValue);
65 cameraTheta->setTracking(
true);
67 auto cameraThetaLabel =
new QLabel(tr(
"θ"));
69 QLCDNumber* theta_LCD =
new QLCDNumber(
this);
70 theta_LCD->setFont(flcd);
71 theta_LCD->setMaximumSize(QSize(45, 45));
72 theta_LCD->setSegmentStyle(QLCDNumber::Flat);
74 thetaDropdown =
new QComboBox(
this);
75 thetaDropdown->addItems(theta_angle_Set);
76 thetaDropdown->setMaximumSize(QSize(100, 45));
78 auto cameraThetaLayout =
new QHBoxLayout;
79 cameraThetaLayout->addWidget(cameraThetaLabel);
80 cameraThetaLayout->addWidget(cameraTheta);
81 cameraThetaLayout->addWidget(theta_LCD);
82 cameraThetaLayout->addWidget(thetaDropdown);
84 cameraPhi =
new QSlider(Qt::Horizontal);
85 cameraPhi->setRange(0, 360);
86 cameraPhi->setSingleStep(1);
87 cameraPhi->setValue(phiValue);
88 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);
107 QVBoxLayout* cameraDirectionLayout =
new QVBoxLayout;
108 cameraDirectionLayout->addLayout(cameraThetaLayout);
109 cameraDirectionLayout->addSpacing(12);
110 cameraDirectionLayout->addLayout(cameraPhiLayout);
112 QGroupBox* cameraAnglesGroup =
new QGroupBox(tr(
"Camera Direction"));
113 cameraAnglesGroup->setLayout(cameraDirectionLayout);
116 connect(cameraTheta, &QSlider::valueChanged,
this, &G4DisplayView::changeCameraDirection);
117 connect(cameraTheta, &QSlider::valueChanged, theta_LCD, qOverload<int>(&QLCDNumber::display));
120 connect(thetaDropdown, &QComboBox::currentTextChanged,
121 this, [
this](
const QString&) { setCameraDirection(0); });
123 connect(cameraPhi, &QSlider::valueChanged,
this, &G4DisplayView::changeCameraDirection);
124 connect(cameraPhi, &QSlider::valueChanged, phi_LCD, qOverload<int>(&QLCDNumber::display));
126 connect(phiDropdown, &QComboBox::currentTextChanged,
127 this, [
this](
const QString&) { setCameraDirection(1); });
134 QLabel* projLabel =
new QLabel(tr(
"Projection:"));
135 perspectiveDropdown =
new QComboBox;
136 perspectiveDropdown->addItem(tr(
"Orthogonal"));
137 perspectiveDropdown->addItem(tr(
"Perspective 30"));
138 perspectiveDropdown->addItem(tr(
"Perspective 45"));
139 perspectiveDropdown->addItem(tr(
"Perspective 60"));
142 QLabel* sides_per_circlesLabel =
new QLabel(tr(
"Sides per circle:"));
143 precisionDropdown =
new QComboBox;
144 precisionDropdown->addItem(tr(
"50"));
145 precisionDropdown->addItem(tr(
"100"));
146 precisionDropdown->addItem(tr(
"200"));
147 precisionDropdown->addItem(tr(
"300"));
148 precisionDropdown->setCurrentIndex(0);
150 connect(perspectiveDropdown, &QComboBox::currentTextChanged,
this, &G4DisplayView::set_projection);
151 connect(precisionDropdown, &QComboBox::currentTextChanged,
this, &G4DisplayView::set_precision);
153 QVBoxLayout* resolutionAndPerspectiveLayout =
new QVBoxLayout;
154 resolutionAndPerspectiveLayout->addWidget(projLabel);
155 resolutionAndPerspectiveLayout->addWidget(perspectiveDropdown);
156 resolutionAndPerspectiveLayout->addSpacing(12);
157 resolutionAndPerspectiveLayout->addWidget(sides_per_circlesLabel);
158 resolutionAndPerspectiveLayout->addWidget(precisionDropdown);
160 QGroupBox* propertyGroup =
new QGroupBox(tr(
"View Properties"));
161 propertyGroup->setLayout(resolutionAndPerspectiveLayout);
163 QHBoxLayout* cameraAndPerspective =
new QHBoxLayout;
164 cameraAndPerspective->addWidget(cameraAnglesGroup);
165 cameraAndPerspective->addSpacing(12);
166 cameraAndPerspective->addWidget(propertyGroup);
172 lightTheta =
new QSlider(Qt::Horizontal);
173 lightTheta->setRange(0, 180);
174 lightTheta->setSingleStep(1);
175 lightTheta->setValue(lightThetaValue);
176 lightTheta->setTracking(
true);
178 auto lightThetaLabel =
new QLabel(tr(
"θ"));
180 QLCDNumber* ltheta_LCD =
new QLCDNumber(
this);
181 ltheta_LCD->setFont(flcd);
182 ltheta_LCD->setMaximumSize(QSize(45, 45));
183 ltheta_LCD->setSegmentStyle(QLCDNumber::Flat);
185 lthetaDropdown =
new QComboBox(
this);
186 lthetaDropdown->addItems(theta_angle_Set);
187 lthetaDropdown->setMaximumSize(QSize(100, 45));
189 auto lightThetaLayout =
new QHBoxLayout;
190 lightThetaLayout->addWidget(lightThetaLabel);
191 lightThetaLayout->addWidget(lightTheta);
192 lightThetaLayout->addWidget(ltheta_LCD);
193 lightThetaLayout->addWidget(lthetaDropdown);
195 lightPhi =
new QSlider(Qt::Horizontal);
196 lightPhi->setRange(0, 360);
197 lightPhi->setSingleStep(1);
198 lightPhi->setValue(lightPhiValue);
199 lightPhi->setTracking(
true);
201 auto lightPhiLabel =
new QLabel(tr(
"ɸ"));
203 QLCDNumber* lphi_LCD =
new QLCDNumber(
this);
204 lphi_LCD->setFont(flcd);
205 lphi_LCD->setMaximumSize(QSize(45, 45));
206 lphi_LCD->setSegmentStyle(QLCDNumber::Flat);
208 lphiDropdown =
new QComboBox(
this);
209 lphiDropdown->addItems(phi_angle_Set);
210 lphiDropdown->setMaximumSize(QSize(100, 45));
212 auto lightPhiLayout =
new QHBoxLayout;
213 lightPhiLayout->addWidget(lightPhiLabel);
214 lightPhiLayout->addWidget(lightPhi);
215 lightPhiLayout->addWidget(lphi_LCD);
216 lightPhiLayout->addWidget(lphiDropdown);
218 auto lightDirectionLayout =
new QVBoxLayout;
219 lightDirectionLayout->addLayout(lightThetaLayout);
220 lightDirectionLayout->addSpacing(12);
221 lightDirectionLayout->addLayout(lightPhiLayout);
223 QGroupBox* lightAnglesGroup =
new QGroupBox(tr(
"Light Direction"));
224 lightAnglesGroup->setLayout(lightDirectionLayout);
226 connect(lightTheta, &QSlider::valueChanged,
this, &G4DisplayView::changeLightDirection);
227 connect(lightTheta, &QSlider::valueChanged, ltheta_LCD, qOverload<int>(&QLCDNumber::display));
228 connect(lthetaDropdown, &QComboBox::currentTextChanged,
229 this, [
this](
const QString&) { setLightDirection(0); });
231 connect(lightPhi, &QSlider::valueChanged,
this, &G4DisplayView::changeLightDirection);
232 connect(lightPhi, &QSlider::valueChanged, lphi_LCD, qOverload<int>(&QLCDNumber::display));
233 connect(lphiDropdown, &QComboBox::currentTextChanged,
234 this, [
this](
const QString&) { setLightDirection(1); });
240 QLabel* cullingLabel =
new QLabel(tr(
"Culling:"));
241 cullingDropdown =
new QComboBox;
242 cullingDropdown->addItem(tr(
"Reset"));
243 cullingDropdown->addItem(tr(
"Covered Daughters"));
244 cullingDropdown->addItem(tr(
"Density: 1 mg/cm3"));
245 cullingDropdown->addItem(tr(
"Density: 10 mg/cm3"));
246 cullingDropdown->addItem(tr(
"Density: 100 mg/cm3"));
247 cullingDropdown->addItem(tr(
"Density: 1 g/cm3"));
248 cullingDropdown->addItem(tr(
"Density: 10 g/cm3"));
250 QLabel* backgroundColorLabel =
new QLabel(tr(
"Background Color:"));
251 backgroundColorDropdown =
new QComboBox;
252 backgroundColorDropdown->addItem(tr(
"lightslategray"));
253 backgroundColorDropdown->addItem(tr(
"ghostwhite"));
254 backgroundColorDropdown->addItem(tr(
"black"));
255 backgroundColorDropdown->addItem(tr(
"navy"));
256 backgroundColorDropdown->addItem(tr(
"whitesmoke"));
257 backgroundColorDropdown->addItem(tr(
"lightskyblue"));
258 backgroundColorDropdown->addItem(tr(
"deepskyblue"));
259 backgroundColorDropdown->addItem(tr(
"lightsteelblue"));
260 backgroundColorDropdown->addItem(tr(
"blueviolet"));
261 backgroundColorDropdown->addItem(tr(
"turquoise"));
262 backgroundColorDropdown->addItem(tr(
"mediumaquamarine"));
263 backgroundColorDropdown->addItem(tr(
"springgreen"));
264 backgroundColorDropdown->addItem(tr(
"lawngreen"));
265 backgroundColorDropdown->addItem(tr(
"yellowgreen"));
266 backgroundColorDropdown->addItem(tr(
"lemonchiffon"));
267 backgroundColorDropdown->addItem(tr(
"antiquewhite"));
268 backgroundColorDropdown->addItem(tr(
"wheat"));
269 backgroundColorDropdown->addItem(tr(
"sienna"));
270 backgroundColorDropdown->addItem(tr(
"snow"));
271 backgroundColorDropdown->addItem(tr(
"floralwhite"));
272 backgroundColorDropdown->addItem(tr(
"lightsalmon"));
273 backgroundColorDropdown->addItem(tr(
"orchid"));
274 backgroundColorDropdown->addItem(tr(
"plum"));
275 backgroundColorDropdown->setCurrentIndex(0);
277 connect(cullingDropdown, &QComboBox::currentTextChanged,
this, &G4DisplayView::set_culling);
278 connect(backgroundColorDropdown, &QComboBox::currentTextChanged,
this, &G4DisplayView::set_background);
280 QVBoxLayout* sceneLayout =
new QVBoxLayout;
281 sceneLayout->addWidget(cullingLabel);
282 sceneLayout->addWidget(cullingDropdown);
283 sceneLayout->addSpacing(12);
284 sceneLayout->addWidget(backgroundColorLabel);
285 sceneLayout->addWidget(backgroundColorDropdown);
287 QGroupBox* spropertyGroup =
new QGroupBox(tr(
"Scene Properties"));
288 spropertyGroup->setLayout(sceneLayout);
290 QHBoxLayout* lightAndProperties =
new QHBoxLayout;
291 lightAndProperties->addWidget(lightAnglesGroup);
292 lightAndProperties->addSpacing(12);
293 lightAndProperties->addWidget(spropertyGroup);
300 sliceXEdit =
new QLineEdit(tr(
"0"));
301 sliceXEdit->setMaximumWidth(100);
302 sliceXActi =
new QCheckBox(tr(
"&On"));
303 sliceXActi->setChecked(
false);
304 sliceXInve =
new QCheckBox(tr(
"&Flip"));
305 sliceXInve->setChecked(
false);
307 auto sliceXLayout =
new QHBoxLayout;
308 sliceXLayout->addWidget(
new QLabel(tr(
"X: ")));
309 sliceXLayout->addWidget(sliceXEdit);
310 sliceXLayout->addStretch(1);
311 sliceXLayout->addWidget(sliceXActi);
312 sliceXLayout->addWidget(sliceXInve);
313 sliceXLayout->addStretch(1);
316 sliceYEdit =
new QLineEdit(tr(
"0"));
317 sliceYEdit->setMaximumWidth(100);
318 sliceYActi =
new QCheckBox(tr(
"&On"));
319 sliceYActi->setChecked(
false);
320 sliceYInve =
new QCheckBox(tr(
"&Flip"));
321 sliceYInve->setChecked(
false);
323 auto sliceYLayout =
new QHBoxLayout;
324 sliceYLayout->addWidget(
new QLabel(tr(
"Y: ")));
325 sliceYLayout->addWidget(sliceYEdit);
326 sliceYLayout->addStretch(1);
327 sliceYLayout->addWidget(sliceYActi);
328 sliceYLayout->addWidget(sliceYInve);
329 sliceYLayout->addStretch(1);
332 sliceZEdit =
new QLineEdit(tr(
"0"));
333 sliceZEdit->setMaximumWidth(100);
334 sliceZActi =
new QCheckBox(tr(
"&On"));
335 sliceZActi->setChecked(
false);
336 sliceZInve =
new QCheckBox(tr(
"&Flip"));
337 sliceZInve->setChecked(
false);
339 auto sliceZLayout =
new QHBoxLayout;
340 sliceZLayout->addWidget(
new QLabel(tr(
"Z: ")));
341 sliceZLayout->addWidget(sliceZEdit);
342 sliceZLayout->addStretch(1);
343 sliceZLayout->addWidget(sliceZActi);
344 sliceZLayout->addWidget(sliceZInve);
345 sliceZLayout->addStretch(1);
348 QPushButton* clearSliceButton =
new QPushButton(tr(
"Clear Slices"));
349 clearSliceButton->setToolTip(
"Clear Slice Planes");
350 clearSliceButton->setIcon(QIcon::fromTheme(
"edit-clear"));
351 clearSliceButton->setIconSize(QSize(16, 16));
352 connect(clearSliceButton, &QPushButton::clicked,
this, &G4DisplayView::clearSlices);
355 QGroupBox* sliceChoiceBox =
new QGroupBox(tr(
"Slices Style"));
356 sliceSectn =
new QRadioButton(tr(
"&Intersection"), sliceChoiceBox);
357 sliceUnion =
new QRadioButton(tr(
"&Union"), sliceChoiceBox);
358 sliceSectn->setChecked(
true);
360 connect(sliceSectn, &QRadioButton::toggled,
this, &G4DisplayView::slice);
361 connect(sliceUnion, &QRadioButton::toggled,
this, &G4DisplayView::slice);
363 auto sliceChoiceLayout =
new QHBoxLayout;
364 sliceChoiceLayout->addWidget(sliceSectn);
365 sliceChoiceLayout->addWidget(sliceUnion);
366 sliceChoiceBox->setLayout(sliceChoiceLayout);
369 auto sliceLayout =
new QVBoxLayout;
370 sliceLayout->addLayout(sliceXLayout);
371 sliceLayout->addLayout(sliceYLayout);
372 sliceLayout->addLayout(sliceZLayout);
373 sliceLayout->addWidget(sliceChoiceBox);
374 sliceLayout->addWidget(clearSliceButton);
377 connect(sliceXEdit, &QLineEdit::returnPressed,
this, &G4DisplayView::slice);
378 connect(sliceYEdit, &QLineEdit::returnPressed,
this, &G4DisplayView::slice);
379 connect(sliceZEdit, &QLineEdit::returnPressed,
this, &G4DisplayView::slice);
381#if QT_VERSION < QT_VERSION_CHECK(6, 7, 0)
382 connect(sliceXActi, &QCheckBox::stateChanged,
this, &G4DisplayView::slice);
383 connect(sliceYActi, &QCheckBox::stateChanged,
this, &G4DisplayView::slice);
384 connect(sliceZActi, &QCheckBox::stateChanged,
this, &G4DisplayView::slice);
385 connect(sliceXInve, &QCheckBox::stateChanged,
this, &G4DisplayView::slice);
386 connect(sliceYInve, &QCheckBox::stateChanged,
this, &G4DisplayView::slice);
387 connect(sliceZInve, &QCheckBox::stateChanged,
this, &G4DisplayView::slice);
389 connect(sliceXActi, &QCheckBox::checkStateChanged,
this, &G4DisplayView::slice);
390 connect(sliceYActi, &QCheckBox::checkStateChanged,
this, &G4DisplayView::slice);
391 connect(sliceZActi, &QCheckBox::checkStateChanged,
this, &G4DisplayView::slice);
392 connect(sliceXInve, &QCheckBox::checkStateChanged,
this, &G4DisplayView::slice);
393 connect(sliceYInve, &QCheckBox::checkStateChanged,
this, &G4DisplayView::slice);
394 connect(sliceZInve, &QCheckBox::checkStateChanged,
this, &G4DisplayView::slice);
401 QGroupBox* fieldPrecisionBox =
new QGroupBox(tr(
"Number of Field Points"));
402 field_npoints =
new QLineEdit(QString::number(field_NPOINTS),
this);
403 field_npoints->setMaximumWidth(40);
405 QFont font = field_npoints->font();
406 font.setPointSize(24);
407 field_npoints->setFont(font);
409 connect(field_npoints, &QLineEdit::returnPressed,
this, &G4DisplayView::field_precision_changed);
412 auto fieldPointsHBox =
new QHBoxLayout;
413 fieldPointsHBox->addWidget(field_npoints);
414 fieldPrecisionBox->setLayout(fieldPointsHBox);
416 auto buttons_field_HBox =
new QHBoxLayout;
417 buttons_field_HBox->addWidget(buttons_set1);
418 buttons_field_HBox->addWidget(fieldPrecisionBox);
419 fieldPrecisionBox->setMaximumHeight(3 * buttons_set1->height());
420 fieldPrecisionBox->setMaximumWidth(140);
426 auto mainLayout =
new QVBoxLayout;
427 mainLayout->addLayout(buttons_field_HBox);
428 mainLayout->addLayout(cameraAndPerspective);
429 mainLayout->addLayout(lightAndProperties);
430 mainLayout->addLayout(sliceLayout);
431 setLayout(mainLayout);