Skip to content

Commit dfa79a6

Browse files
committed
implemented empty drawlogical volume - until g4 will fix it
1 parent 1d46bde commit dfa79a6

5 files changed

Lines changed: 72 additions & 1 deletion

File tree

.github/workflows/test.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
name: Test
22

3+
run-name: triggered by ${{ inputs.triggered_by || 'manual' }}
4+
35
permissions:
46
contents: read
57

@@ -12,6 +14,11 @@ concurrency:
1214

1315
on:
1416
workflow_dispatch:
17+
inputs:
18+
triggered_by:
19+
description: 'What triggered this run'
20+
required: false
21+
default: 'manual'
1522
pull_request:
1623
paths-ignore:
1724
- "**/*.md"

gemc/gtree/gtree.cc

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <QTextEdit>
1212
#include <QVBoxLayout>
1313
#include <QColorDialog>
14+
#include <QMessageBox>
1415
#include <QSignalBlocker>
1516
#include <QTimer>
1617

@@ -638,17 +639,23 @@ void GTree::onTreeItemClicked(QTreeWidgetItem* item, int /*column*/) {
638639
opacitySlider->setVisible(true);
639640
}
640641

641-
// Update the inspect button with the selected volume's leaf name.
642+
// Update the inspect and draw-overlaps buttons with the selected volume's leaf name.
642643
if (inspectButton) {
643644
const QString leaf = QString::fromStdString(G4Ttree_item::vname_from_v4name(current_volume_name));
644645
inspectButton->setText(tr("Inspect %1").arg(leaf));
645646
inspectButton->setVisible(true);
646647
}
648+
if (drawOverlapsButton) {
649+
const QString leaf = QString::fromStdString(G4Ttree_item::vname_from_v4name(current_volume_name));
650+
drawOverlapsButton->setText(tr("Draw Logical Overlaps %1").arg(leaf));
651+
drawOverlapsButton->setVisible(true);
652+
}
647653
}
648654
else {
649655
styleButtons->setVisible(false);
650656
opacitySlider->setVisible(false);
651657
if (inspectButton) inspectButton->setVisible(false);
658+
if (drawOverlapsButton) drawOverlapsButton->setVisible(false);
652659
// Systems don't have a single material etc.
653660
materialLabel->setText(tr(""));
654661
massLabel->setText(tr(""));
@@ -824,6 +831,16 @@ void GTree::inspectVolume() {
824831
}
825832

826833

834+
// Warn that /vis/drawLogicalVolume is not yet usable due to a Geant4 11.4.1 TOOLSSG bug.
835+
void GTree::drawOverlapsWarning() {
836+
QMessageBox::warning(this,
837+
tr("Not yet implemented"),
838+
tr("Draw Logical Overlaps will be implemented when Geant4 fixes the\n"
839+
"G4ToolsSGSceneHandler::GetOrCreateNode \"World mis-match\" crash\n"
840+
"triggered by /vis/drawLogicalVolume in Geant4 11.4.1."));
841+
}
842+
843+
827844
// Convert slider position to alpha and apply it to the currently selected volume.
828845
void GTree::onOpacitySliderChanged(int value) {
829846
if (current_volume_name.empty())

gemc/gtree/gtree.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,17 @@ class GTree : public QWidget, public GBase<GTree>
361361
*/
362362
QPushButton* inspectButton = nullptr;
363363

364+
/**
365+
* \brief Full-width button that will invoke /vis/drawLogicalVolume for overlap visualization.
366+
*
367+
* Not yet functional: blocked by a Geant4 11.4.1 TOOLSSG bug
368+
* (G4ToolsSGSceneHandler::GetOrCreateNode throws "World mis-match" FatalException
369+
* for the standalone PVPlacement created by G4LogicalVolumeModel).
370+
* Displays a warning until the upstream fix is available.
371+
* The label is updated to "Draw Logical Overlaps <volumename>" whenever a volume is selected.
372+
*/
373+
QPushButton* drawOverlapsButton = nullptr;
374+
364375
/**
365376
* \brief Build the internal system/volume model from the supplied volume map.
366377
* \param g4volumes_map Map from full volume names to `G4Volume*` wrappers.
@@ -504,6 +515,15 @@ private slots:
504515
*/
505516
void inspectVolume();
506517

518+
/**
519+
* \brief Show a warning that Draw Logical Overlaps is not yet implemented.
520+
*
521+
* /vis/drawLogicalVolume crashes in Geant4 11.4.1 with the TOOLSSG driver
522+
* (G4ToolsSGSceneHandler::GetOrCreateNode "World mis-match" FatalException).
523+
* This slot will be wired to the real implementation once Geant4 is fixed.
524+
*/
525+
void drawOverlapsWarning();
526+
507527
/**
508528
* \brief Advance one step of the twinkle color animation; restore original on completion.
509529
*/

gemc/gtree/right_widget.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,17 @@ QWidget* GTree::right_widget() {
106106
connect(inspectButton, &QPushButton::clicked, this, &GTree::inspectVolume);
107107
blayout->addWidget(inspectButton);
108108

109+
// Draw Logical Overlaps button: not yet functional — blocked by Geant4 11.4.1 TOOLSSG bug.
110+
blayout->addSpacing(4);
111+
drawOverlapsButton = new QPushButton(bottomPanel);
112+
drawOverlapsButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
113+
drawOverlapsButton->setStyleSheet(
114+
"QPushButton { border: 2px solid black; border-radius: 4px; padding: 4px 8px; }"
115+
"QPushButton:hover { background-color: palette(highlight); color: palette(highlighted-text); }"
116+
);
117+
connect(drawOverlapsButton, &QPushButton::clicked, this, &GTree::drawOverlapsWarning);
118+
blayout->addWidget(drawOverlapsButton);
119+
109120
// Hidden until a volume or system is selected in the tree.
110121
bottomPanel->setVisible(false);
111122

releases/0.3.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ This version includes:
1212
- `GEMC_PLUGIN_PATH` and `-plugin_path` for external plugin discovery
1313
- Pre-parse plugin options hook for dynamic plugin option registration
1414
- ROOT gstreamer and event-action bug fixes
15+
- Fixed geometry-tree opacity slider resetting volume color to original
1516
- Plotting tests for digitizing-SD examples and Cherenkov photon hit maps
1617

1718
<br/>
@@ -142,6 +143,12 @@ This version includes:
142143
semi-transparent lighter background to the parameters box so it stands out; the parameters box
143144
is hidden when a system node is selected; all numeric parameter values are formatted to a
144145
maximum of three decimal places and values smaller than 10⁻⁷ are shown as 0.
146+
- Fixed a bug in the geometry-tree opacity slider where adjusting a volume's opacity
147+
would silently reset its color to the original definition value. `GTree::set_color`
148+
now updates the cached `G4Ttree_item` model entry and includes the current opacity in
149+
the `/vis/geometry/set/colour` command, so color and opacity are always kept in sync.
150+
The twinkle-animation restore path received the same fix so the model is consistent
151+
after the animation completes.
145152
- Replaced the separate `punit`, `aunit`, and `vunit` fields in `gparticle` with
146153
direct `value*unit` notation on each kinematic field (e.g. `p: 4*GeV`,
147154
`theta: 23*deg`, `vz: -10*cm`). A plain number without a unit is still accepted
@@ -427,3 +434,12 @@ Both x86_64 and ARM64 platforms are supported.
427434
carry non-empty parameter data; added `formatVal()` in `gtree.cc` to format all numeric
428435
parameter tokens to at most three significant decimal places and to collapse values smaller
429436
than 10⁻⁷ to zero.
437+
- Fixed geometry-tree color/opacity desync: `GTree::set_color` was sending the
438+
`/vis/geometry/set/colour` command without updating the `G4Ttree_item` model cache and
439+
without including the alpha channel, so a subsequent opacity-slider change read stale RGB
440+
values from the model and reset the visible color. `set_color` now calls
441+
`item->set_color(c)`, reads `item->get_opacity()` to preserve the current alpha, and
442+
appends it to the colour command. Changed `G4Ttree_item::set_color` to accept
443+
`const QColor&`. The twinkle restore branch in `onTwinkleStep` now also calls
444+
`item->set_color(twinkleSavedColor)` and `item->set_opacity(twinkleSavedOpacity)` before
445+
issuing the restore command, keeping the model consistent after animation.

0 commit comments

Comments
 (0)