4#include <gemc/gqtbuttonswidget/gQtButtonsWidget.h>
5#include <gemc/g4system/g4volume.h>
6#include <gemc/gsystem/gvolume.h>
7#include <gemc/gbase/gbase.h>
8#include <gemc/goptions/goptions.h>
12#include <QTreeWidgetItem>
87 bool is_visible =
true;
100 int representation = 1;
105 double opacity = 1.0;
110 std::string material;
125 double density = 0.0;
134 bool recursive =
false;
137 std::string solidType;
138 std::string parameters;
139 std::string position;
140 std::string rotation;
141 std::string motherVolume;
142 std::string volDescription;
146 [[nodiscard]] std::string
get_mother()
const {
return mother; }
149 [[nodiscard]] QColor
get_color()
const {
return color; }
161 [[nodiscard]]
double get_mass()
const {
return mass; }
236using g4tree_map = std::map<std::string, std::unique_ptr<G4Ttree_item>>;
276 explicit GTree(
const std::shared_ptr<GOptions>& gopt,
277 std::unordered_map<std::string, G4Volume*> g4volumes_map,
278 std::unordered_map<std::string, const GVolume*> gvolumes_map = {},
279 QWidget* parent =
nullptr);
300 std::map<std::string, g4tree_map> g4_systems_tree;
308 std::unordered_map<std::string, const GVolume*> gvolumes_map;
313 QTreeWidget* treeWidget =
nullptr;
319 QWidget* rightPanel =
nullptr;
324 QWidget* bottomPanel =
nullptr;
332 QLabel* typeLabel =
nullptr;
333 QLabel* daughtersLabel =
nullptr;
334 QLabel* nameLabel =
nullptr;
335 QLabel* materialLabel =
nullptr;
336 QLabel* massLabel =
nullptr;
337 QLabel* volumeLabel =
nullptr;
338 QLabel* densityLabel =
nullptr;
339 QLabel* solidTypeLabel =
nullptr;
340 QTextEdit* parametersLabel =
nullptr;
341 QLabel* positionLabel =
nullptr;
342 QLabel* rotationLabel =
nullptr;
343 QLabel* motherLabel =
nullptr;
344 QLabel* descriptionLabel =
nullptr;
349 QSlider* opacitySlider =
nullptr;
354 QLabel* opacityLabel =
nullptr;
362 QPushButton* inspectButton =
nullptr;
373 QPushButton* drawOverlapsButton =
nullptr;
379 void build_tree(std::unordered_map<std::string, G4Volume*> g4volumes_map);
397 void set_visibility(
const std::string& fullName,
bool visible);
404 void set_color(
const std::string& fullName,
const QColor& c);
411 void set_opacity(
const std::string& volumeName,
double opacity);
417 QWidget* right_widget();
424 int get_ndaughters(QTreeWidgetItem* item)
const;
431 G4Ttree_item* findTreeItem(
const std::string& fullName);
440 std::string current_volume_name;
443 QTimer* twinkleTimer =
nullptr;
445 QColor twinkleSavedColor;
446 double twinkleSavedOpacity = 1.0;
447 std::string twinkleVolumeName;
452 void centreTwinkle();
465 void onItemChanged(QTreeWidgetItem* item,
int column);
474 void onColorButtonClicked();
481 void onTreeItemClicked(QTreeWidgetItem* item,
int column);
488 void onCurrentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* previous);
506 void onOpacitySliderChanged(
int value);
516 void inspectVolume();
525 void drawOverlapsWarning();
530 void onTwinkleStep();
Lightweight per-volume record used by GTree to populate the UI.
void set_recursive(bool recursive)
Set the recursive flag.
int get_representation() const
Return the cached representation mode.
std::string get_motherVolume() const
Return the mother volume name.
static std::string vname_from_v4name(std::string v4name)
Extract the "leaf" volume name from a full volume name.
double get_opacity() const
Return the cached opacity (alpha) in [0,1].
std::string get_volDescription() const
Return the volume description.
std::string get_rotation() const
Return the placement rotation string with units.
double get_density() const
Return the cached density.
void set_color(const QColor &c)
Update the cached color.
void set_opacity(double opacity)
Update the cached opacity.
double get_volume() const
Return the cached volume.
bool get_visibility() const
Return the cached visibility state.
double get_mass() const
Return the cached mass.
QColor get_color() const
Return the cached RGB color.
bool get_recursive() const
Return the cached recursive flag.
std::string get_solidType() const
Return the solid type string (e.g. "G4Box").
static std::string system_from_v4name(std::string v4name)
Extract the system name from a full volume name.
std::string get_position() const
Return the placement position string with units.
std::string get_parameters() const
Return the solid parameters string with units.
std::string get_material() const
Return the cached material name.
G4Ttree_item(G4Volume *g4volume, const GVolume *gvolume=nullptr)
Construct a cached record for a single geometry volume.
std::string get_mother() const
Return the cached mother name.
Qt widget that displays the geometry hierarchy and allows interactive style edits.
GTree & operator=(const GTree &)=delete
Non-assignable: the widget owns unique model resources.
GTree(const GTree &)=delete
Non-copyable: the widget owns unique model resources.
GTree(const std::shared_ptr< GOptions > &gopt, std::unordered_map< std::string, G4Volume * > g4volumes_map, std::unordered_map< std::string, const GVolume * > gvolumes_map={}, QWidget *parent=nullptr)
Construct the geometry tree widget.
std::map< std::string, std::unique_ptr< G4Ttree_item > > g4tree_map