4#include <gemc/gqtbuttonswidget/gQtButtonsWidget.h>
5#include <gemc/g4system/g4volume.h>
6#include <gemc/gsystem/gmirror.h>
7#include <gemc/gsystem/gvolume.h>
8#include <gemc/gbase/gbase.h>
9#include <gemc/goptions/goptions.h>
13#include <QTreeWidgetItem>
88 bool is_visible =
true;
101 int representation = 1;
106 double opacity = 1.0;
111 std::string material;
121 mutable double mass = 0.0;
126 mutable double volume = 0.0;
131 mutable double density = 0.0;
134 mutable bool physics_computed =
false;
137 G4LogicalVolume* logical_ptr =
nullptr;
140 G4VSolid* solid_ptr =
nullptr;
149 void compute_physics_quantities()
const;
158 bool recursive =
false;
161 std::string solidType;
162 std::string parameters;
163 std::string position;
164 std::string rotation;
165 std::string motherVolume;
166 std::string solidsOpr;
167 std::string volDescription;
168 std::string mirrorName;
172 [[nodiscard]] std::string
get_mother()
const {
return mother; }
175 [[nodiscard]] QColor
get_color()
const {
return color; }
188 compute_physics_quantities();
194 compute_physics_quantities();
200 compute_physics_quantities();
275using g4tree_map = std::map<std::string, std::unique_ptr<G4Ttree_item>>;
317 explicit GTree(
const std::shared_ptr<GOptions>& gopt,
318 std::unordered_map<std::string, G4Volume*> g4volumes_map,
319 std::unordered_map<std::string, const GVolume*> gvolumes_map = {},
320 QWidget* parent =
nullptr,
321 std::unordered_map<std::string, const GMirror*> gmirrors_map = {});
342 std::map<std::string, g4tree_map> g4_systems_tree;
350 std::unordered_map<std::string, const GVolume*> gvolumes_map;
355 std::unordered_map<std::string, const GMirror*> gmirrors_map;
360 QTreeWidget* treeWidget =
nullptr;
366 QWidget* rightPanel =
nullptr;
371 QWidget* bottomPanel =
nullptr;
379 QLabel* typeLabel =
nullptr;
380 QLabel* daughtersLabel =
nullptr;
381 QLabel* nameLabel =
nullptr;
382 QLabel* materialLabel =
nullptr;
383 QLabel* massLabel =
nullptr;
384 QLabel* volumeLabel =
nullptr;
385 QLabel* densityLabel =
nullptr;
386 QLabel* solidTypeLabel =
nullptr;
387 QTextEdit* parametersLabel =
nullptr;
388 QLabel* positionLabel =
nullptr;
389 QLabel* rotationLabel =
nullptr;
390 QLabel* motherLabel =
nullptr;
391 QLabel* descriptionLabel =
nullptr;
399 QPushButton* mirrorButton =
nullptr;
404 QSlider* opacitySlider =
nullptr;
409 QLabel* opacityLabel =
nullptr;
417 QPushButton* inspectButton =
nullptr;
428 QPushButton* drawOverlapsButton =
nullptr;
434 void build_tree(std::unordered_map<std::string, G4Volume*> g4volumes_map);
452 void set_visibility(
const std::string& fullName,
bool visible);
459 void set_color(
const std::string& fullName,
const QColor& c);
466 void set_opacity(
const std::string& volumeName,
double opacity);
472 QWidget* right_widget();
479 int get_ndaughters(QTreeWidgetItem* item)
const;
486 G4Ttree_item* findTreeItem(
const std::string& fullName);
495 std::string current_volume_name;
498 QTimer* twinkleTimer =
nullptr;
500 QColor twinkleSavedColor;
501 double twinkleSavedOpacity = 1.0;
502 std::string twinkleVolumeName;
507 void centreTwinkle();
520 void onItemChanged(QTreeWidgetItem* item,
int column);
529 void onColorButtonClicked();
536 void onTreeItemClicked(QTreeWidgetItem* item,
int column);
543 void onCurrentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* previous);
561 void onOpacitySliderChanged(
int value);
571 void inspectVolume();
576 void showMirrorProperties();
585 void drawOverlapsWarning();
590 void onTwinkleStep();
Lightweight per-volume record used by GTree to populate the UI.
std::string get_mirrorName() const
Return the associated mirror name.
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(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, std::unordered_map< std::string, const GMirror * > gmirrors_map={})
Construct the geometry tree widget.
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.
std::map< std::string, std::unique_ptr< G4Ttree_item > > g4tree_map