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;
120 mutable double mass = 0.0;
125 mutable double volume = 0.0;
130 mutable double density = 0.0;
133 mutable bool physics_computed =
false;
136 G4LogicalVolume* logical_ptr =
nullptr;
139 G4VSolid* solid_ptr =
nullptr;
148 void compute_physics_quantities()
const;
157 bool recursive =
false;
160 std::string solidType;
161 std::string parameters;
162 std::string position;
163 std::string rotation;
164 std::string motherVolume;
165 std::string solidsOpr;
166 std::string volDescription;
170 [[nodiscard]] std::string
get_mother()
const {
return mother; }
173 [[nodiscard]] QColor
get_color()
const {
return color; }
186 compute_physics_quantities();
192 compute_physics_quantities();
198 compute_physics_quantities();
271using g4tree_map = std::map<std::string, std::unique_ptr<G4Ttree_item>>;
312 explicit GTree(
const std::shared_ptr<GOptions>& gopt,
313 std::unordered_map<std::string, G4Volume*> g4volumes_map,
314 std::unordered_map<std::string, const GVolume*> gvolumes_map = {},
315 QWidget* parent =
nullptr);
336 std::map<std::string, g4tree_map> g4_systems_tree;
344 std::unordered_map<std::string, const GVolume*> gvolumes_map;
349 QTreeWidget* treeWidget =
nullptr;
355 QWidget* rightPanel =
nullptr;
360 QWidget* bottomPanel =
nullptr;
368 QLabel* typeLabel =
nullptr;
369 QLabel* daughtersLabel =
nullptr;
370 QLabel* nameLabel =
nullptr;
371 QLabel* materialLabel =
nullptr;
372 QLabel* massLabel =
nullptr;
373 QLabel* volumeLabel =
nullptr;
374 QLabel* densityLabel =
nullptr;
375 QLabel* solidTypeLabel =
nullptr;
376 QTextEdit* parametersLabel =
nullptr;
377 QLabel* positionLabel =
nullptr;
378 QLabel* rotationLabel =
nullptr;
379 QLabel* motherLabel =
nullptr;
380 QLabel* descriptionLabel =
nullptr;
385 QSlider* opacitySlider =
nullptr;
390 QLabel* opacityLabel =
nullptr;
398 QPushButton* inspectButton =
nullptr;
409 QPushButton* drawOverlapsButton =
nullptr;
415 void build_tree(std::unordered_map<std::string, G4Volume*> g4volumes_map);
433 void set_visibility(
const std::string& fullName,
bool visible);
440 void set_color(
const std::string& fullName,
const QColor& c);
447 void set_opacity(
const std::string& volumeName,
double opacity);
453 QWidget* right_widget();
460 int get_ndaughters(QTreeWidgetItem* item)
const;
467 G4Ttree_item* findTreeItem(
const std::string& fullName);
476 std::string current_volume_name;
479 QTimer* twinkleTimer =
nullptr;
481 QColor twinkleSavedColor;
482 double twinkleSavedOpacity = 1.0;
483 std::string twinkleVolumeName;
488 void centreTwinkle();
501 void onItemChanged(QTreeWidgetItem* item,
int column);
510 void onColorButtonClicked();
517 void onTreeItemClicked(QTreeWidgetItem* item,
int column);
524 void onCurrentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* previous);
542 void onOpacitySliderChanged(
int value);
552 void inspectVolume();
561 void drawOverlapsWarning();
566 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_solidsOpr() const
Return the boolean solid operation descriptor.
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 density, computing it on first request.
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 volume, computing it on first request.
bool get_visibility() const
Return the cached visibility state.
double get_mass() const
Return the mass, computing it on first request.
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.
GBase(const std::shared_ptr< GOptions > &gopt, std::string logger_name="")
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