diff --git a/docs/source/user_guide/user_guide_reference_sources_generic_source.rst b/docs/source/user_guide/user_guide_reference_sources_generic_source.rst index 8357e4b5d..1dcbae9b1 100644 --- a/docs/source/user_guide/user_guide_reference_sources_generic_source.rst +++ b/docs/source/user_guide/user_guide_reference_sources_generic_source.rst @@ -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 diff --git a/opengate/sources/generic.py b/opengate/sources/generic.py index b6ba43a68..99e9e3586 100644 --- a/opengate/sources/generic.py +++ b/opengate/sources/generic.py @@ -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." )