Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ before ``sim.run()``:
source.visualization.color = "red"
source.visualization.size = 3

The visualization of the source is only available with ``"qt"``.
The visualization of the source is only available with ``"qt"`` and single
thread mode.

The ``count`` parameter controls the number of sampled positions. Values
larger than 10000 are reduced to 2000. The ``size`` parameter controls the
Expand Down
9 changes: 8 additions & 1 deletion opengate/sources/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,11 +312,18 @@ def validate_color(self, color, prefix=""):
def validate(self, parent_obj, attr_name: str, parent_context: str = None):
context_name = super().validate(parent_obj, attr_name, parent_context)
b = getattr(parent_obj, attr_name)

if not parent_obj.simulation.visu:
return context_name # Skip validation if visualization is disabled

if b.count <= 0:
logger.info(
f"For source {parent_obj.name}, visualization count is set to {b.count}. No visualization will be performed."
)
elif b.count > 10000:
elif parent_obj.simulation.number_of_threads > 1:
fatal(f"Source visualization is not supported when using multiple threads.")

if b.count > 10000:
warning(
f"For source {parent_obj.name}, visualization count is too high ({b.count}), using 2000 instead."
)
Expand Down
Loading