Skip to content

Commit

Permalink
Add display device label also in 3D
Browse files Browse the repository at this point in the history
  • Loading branch information
vanous committed Sep 5, 2024
1 parent cc297f6 commit d0ff936
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
32 changes: 31 additions & 1 deletion dmx.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ class DMX(PropertyGroup):
subfixtures.DMX_PT_Subfixtures,
subfixtures.DMX_UL_Subfixture,
subfixtures.DMX_OT_Subfixture_Clear,
subfixtures.DMX_OT_Subfixture_SelectVisible,
programmer.DMX_OT_Programmer_DeselectAll,
programmer.DMX_OT_Programmer_SelectAll,
programmer.DMX_OT_Programmer_SelectFiltered,
Expand Down Expand Up @@ -812,6 +813,26 @@ def onBackgroundColor(self, context):

# # Setup > Models > Display Pigtails, Select geometries

def onDisplayLabel(self, context):
for fixture in self.fixtures:
for obj in fixture.collection.objects:
if obj.get("geometry_root", False):
if self.display_device_label == "NONE":
obj.show_name = False
elif self.display_device_label == "NAME":
obj.name = f"{fixture.name}"
obj.show_name = self.enable_device_label
elif self.display_device_label == "DMX":
obj.name = f"{fixture.universe}.{fixture.address}"
obj.show_name = self.enable_device_label
elif self.display_device_label == "FIXTURE_ID":
if fixture.fixture_id:
obj.name = f"{fixture.fixture_id}"
obj.show_name = self.enable_device_label
else:
obj.show_name = False
break

def onDisplayPigtails(self, context):
for fixture in self.fixtures:
for obj in fixture.collection.objects:
Expand Down Expand Up @@ -865,6 +886,10 @@ def onDisplay2D(self, context):
obj.hide_render = not self.display_pigtails
bpy.context.window_manager.dmx.pause_render = self.display_2D # re-enable renderer if in 3D

def update_device_label(self, context):
self.onDisplay2D(context)
self.onDisplayLabel(context)

display_pigtails: BoolProperty(
name = _("Display Pigtails"),
default = False,
Expand All @@ -875,6 +900,11 @@ def onDisplay2D(self, context):
default = False,
update = onDisplay2D)

enable_device_label: BoolProperty(
name = _("Display Device Label"),
default = False,
update = onDisplayLabel)

display_device_label: EnumProperty(
name = _("Device Label"),
default = "NAME",
Expand All @@ -884,7 +914,7 @@ def onDisplay2D(self, context):
("DMX", _("DMX"), "DMX Address"),
("FIXTURE_ID", _("Fixture ID"), "Fixture ID"),
],
update = onDisplay2D)
update = update_device_label)

def onSelectGeometries(self, context):
for fixture in self.fixtures:
Expand Down
4 changes: 3 additions & 1 deletion panels/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,10 @@ def draw(self, context):
row = layout.row()
row.prop(context.scene.dmx, "display_2D")
row = layout.row()
row.prop(context.scene.dmx, "enable_device_label")
row = layout.row()
row.prop(context.scene.dmx, "display_device_label")
row.enabled = dmx.display_2D
row.enabled = dmx.display_2D or dmx.enable_device_label
row = layout.row()
row.prop(context.scene.dmx, "display_pigtails")
row = layout.row()
Expand Down

0 comments on commit d0ff936

Please sign in to comment.