gtree
Loading...
Searching...
No Matches
right_widget.cc
Go to the documentation of this file.
1// Right-side properties panel construction for GTree.
2// Doxygen documentation is authoritative in the header; this file provides a
3// short implementation-focused description and inline comments.
4
5#include <QLabel>
6#include <QVBoxLayout>
7
8#include "gtree.h"
9
10// Build the right-side panel that shows properties and controls for the selected item.
11QWidget* GTree::right_widget() {
12 // Container is parented to the GTree widget so Qt manages lifetime.
13 auto* container = new QWidget(this);
14 auto* vlayout = new QVBoxLayout(container);
15
16 // Top widget: always present
17 auto* topLabel = new QLabel(tr("Properties"), container);
18 QFont f = topLabel->font();
19 f.setBold(true);
20 topLabel->setFont(f);
21 vlayout->addWidget(topLabel);
22
23 // Bottom widget: only visible when a tree item is pressed
24 bottomPanel = new QWidget(container);
25 auto* blayout = new QVBoxLayout(bottomPanel);
26
27 // Representation buttons (wireframe / surface / cloud).
28 std::vector<std::string> bicons;
29 bicons.push_back(":/gtree/images/wireframe");
30 bicons.push_back(":/gtree/images/surface");
31 bicons.push_back(":/gtree/images/cloud");
32 styleButtons = new GQTButtonsWidget(96, 96, bicons, false);
33 blayout->addWidget(styleButtons, 1);
34
35 // Opacity controls: label + slider + numeric value.
36 auto* opacityContainer = new QWidget(bottomPanel);
37 auto* opacityLayout = new QHBoxLayout(opacityContainer);
38 opacityLayout->setContentsMargins(0, 0, 0, 0);
39
40 auto* label = new QLabel(tr("Opacity:"), opacityContainer);
41 opacityLabel = new QLabel(tr("1.00"), opacityContainer); // default text
42
43 opacitySlider = new QSlider(Qt::Horizontal, opacityContainer);
44 opacitySlider->setRange(0, 100); // 0 → 0.0, 100 → 1.0
45 opacitySlider->setValue(100); // default fully opaque
46 opacitySlider->setSingleStep(5);
47 opacitySlider->setPageStep(10);
48
49 opacityLayout->addWidget(label);
50 opacityLayout->addWidget(opacitySlider);
51 opacityLayout->addWidget(opacityLabel);
52
53
54 // Info labels
55 typeLabel = new QLabel(bottomPanel);
56 daughtersLabel = new QLabel(bottomPanel);
57 nameLabel = new QLabel(bottomPanel);
58 materialLabel = new QLabel(bottomPanel);
59 massLabel = new QLabel(bottomPanel);
60 volumeLabel = new QLabel(bottomPanel);
61 densityLabel = new QLabel(bottomPanel);
62
63 blayout->addWidget(opacityContainer);
64 blayout->addSpacing(10);
65 blayout->addWidget(typeLabel);
66 blayout->addWidget(daughtersLabel);
67 blayout->addWidget(nameLabel);
68 blayout->addWidget(materialLabel);
69 blayout->addWidget(massLabel);
70 blayout->addWidget(volumeLabel);
71 blayout->addWidget(densityLabel);
72 blayout->addStretch();
73
74 // Hidden until a volume or system is selected in the tree.
75 bottomPanel->setVisible(false);
76
77 vlayout->addWidget(bottomPanel);
78 vlayout->addStretch();
79
80 return container;
81}