Skip to content

Commit

Permalink
Add Truss, Support, VideoScreen, Projector
Browse files Browse the repository at this point in the history
  • Loading branch information
vanous committed Sep 11, 2023
1 parent d961f59 commit 81f4489
Show file tree
Hide file tree
Showing 3 changed files with 162 additions and 34 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,23 @@ reference implementation.
- GroupObject
- FocusPoint
- SceneObject
- Support
- Truss
- VideoScreen
- Projector
- Address
- Class
- Geometry3D
- Symbol
- Geometries
- Protocol
- Alignment
- Overwrite
- Connection
- Mapping
- Gobo
- CustomCommand
- Sources

## Development

Expand Down
175 changes: 143 additions & 32 deletions pymvr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,15 @@ def _read_xml(self, xml_node: "Element"):
self.gdtf_spec = f"{self.gdtf_spec}.gdtf"
if xml_node.find("GDTFMode") is not None:
self.gdtf_mode = xml_node.find("GDTFMode").text

self.matrix = Matrix(str_repr=xml_node.find("Matrix").text)
self.fixture_id = xml_node.find("FixtureID").text
if xml_node.find("Matrix") is not None:
self.matrix = Matrix(str_repr=xml_node.find("Matrix").text)
if xml_node.find("FixtureID") is not None:
self.fixture_id = xml_node.find("FixtureID").text

if xml_node.find("FixtureIDNumeric"):
self.fixture_id_numeric = int(xml_node.find("FixtureIDNumeric").text)
self.unit_number = int(xml_node.find("UnitNumber").text)
if xml_node.find("UnitNumber") is not None:
self.unit_number = int(xml_node.find("UnitNumber").text)

if xml_node.find("FixtureTypeId") is not None:
self.fixture_type_id = int(xml_node.find("FixtureTypeId").text or 0)
Expand All @@ -133,9 +135,11 @@ def _read_xml(self, xml_node: "Element"):
if xml_node.find("CastShadow") is not None:
self.cast_shadow = bool(xml_node.find("CastShadow").text)

self.addresses = [
Address(xml_node=i) for i in xml_node.find("Addresses").findall("Address")
]
if xml_node.find("Addresses") is not None:
self.addresses = [
Address(xml_node=i)
for i in xml_node.find("Addresses").findall("Address")
]

if xml_node.find("Alignments"):
self.alignments = [
Expand All @@ -147,17 +151,42 @@ def _read_xml(self, xml_node: "Element"):
Connection(xml_node=i)
for i in xml_node.find("Connections").findall("Connection")
]
self.custom_commands = [
CustomCommand(xml_node=i)
for i in xml_node.find("CustomCommands").findall("CustomCommand")
]
if xml_node.find("CustomCommands"):
self.custom_commands = [
CustomCommand(xml_node=i)
for i in xml_node.find("CustomCommands").findall("CustomCommand")
]
if xml_node.find("Overwrites"):
self.overwrites = [
Overwrite(xml_node=i)
for i in xml_node.find("Overwrites").findall("Overwrite")
]
if xml_node.find("Classing") is not None:
self.classing = xml_node.find("Classing").text

self.child_list = ChildList(xml_node=xml_node.find("ChildList"))

def __str__(self):
return f"{self.name}"


class BaseChildNodeExtended(BaseChildNode):
def __init__(
self,
geometries: "Geometries" = None,
child_list: Union["ChildList", None] = None,
*args,
**kwargs,
):
self.geometries = geometries
self.child_list = child_list
super().__init__(*args, **kwargs)

def _read_xml(self, xml_node: "Element"):
super()._read_xml(xml_node)
if xml_node.find("Geometries") is not None:
self.geometries = Geometries(xml_node=xml_node.find("Geometries"))

self.child_list = ChildList(xml_node=xml_node.find("ChildList"))

def __str__(self):
Expand Down Expand Up @@ -273,29 +302,54 @@ def __str__(self):
class ChildList(BaseNode):
def __init__(
self,
fixtures: List["Fixture"] = [],
focus_points: List["FocusPoint"] = [],
group_object: Union["GroupObject", None] = None,
scene_objects: List["SceneObject"] = [],
group_object: Union["GroupObject", None] = None,
focus_points: List["FocusPoint"] = [],
fixtures: List["Fixture"] = [],
supports: List["Support"] = [],
trusses: List["Truss"] = [],
video_screens: List["VideoScreen"] = [],
projectors: List["Projector"] = [],
*args,
**kwargs,
):
if fixtures is not None:
self.fixtures = fixtures
if scene_objects is not None:
self.scene_objects = scene_objects
else:
self.fixtures = []
self.scene_objects = []

self.group_object = group_object

if focus_points is not None:
self.focus_points = focus_points
else:
self.focus_points = []

if scene_objects is not None:
self.scene_objects = scene_objects
if fixtures is not None:
self.fixtures = fixtures
else:
self.scene_objects = []
self.fixtures = []

if supports is not None:
self.supports = supports
else:
self.supports = []

if trusses is not None:
self.trusses = trusses
else:
self.trusses = []

if video_screens is not None:
self.video_screens = video_screens
else:
self.video_screens = []

if projectors is not None:
self.projectors = projectors
else:
self.projectors = []

self.group_object = group_object
super().__init__(*args, **kwargs)

def _read_xml(self, xml_node: "Element"):
Expand Down Expand Up @@ -498,25 +552,57 @@ def __str__(self):
return f"{self.name}"


class SceneObject(BaseChildNode):
class SceneObject(BaseChildNodeExtended):
pass


class Truss(BaseChildNodeExtended):
pass


class Support(BaseChildNodeExtended):
def __init__(
self,
geometries: "Geometries" = None,
child_list: Union["ChildList", None] = None,
chain_length: float = 0,
*args,
**kwargs,
):
self.geometries = geometries
self.child_list = child_list
self.chain_length = chain_length
super().__init__(*args, **kwargs)

def _read_xml(self, xml_node: "Element"):
if xml_node.find("Geometries") is not None:
self.geometries = Geometries(xml_node=xml_node.find("Geometries"))
self.child_list = ChildList(xml_node=xml_node.find("ChildList"))
if xml_node.find("ChainLength") is None:
self.chain_length = float(xml_node.find("ChainLength").text or 0)

def __str__(self):
return f"{self.name}"

class VideoScreen(BaseChildNodeExtended):
def __init__(
self,
sources: "Sources" = None,
*args,
**kwargs,
):
self.sources = sources
super().__init__(*args, **kwargs)

def _read_xml(self, xml_node: "Element"):
if xml_node.find("Sources") is None:
self.sources = Sources(xml_node=xml_node.find("Sources"))


class Projector(BaseChildNodeExtended):
def __init__(
self,
projections: "Projections" = None,
*args,
**kwargs,
):
self.projections = projections
super().__init__(*args, **kwargs)

def _read_xml(self, xml_node: "Element"):
if xml_node.find("Projections") is None:
self.projections = Projections(xml_node.find("Projections"))


class Protocol(BaseNode):
Expand Down Expand Up @@ -681,4 +767,29 @@ def _read_xml(self, xml_node: "Element"):
self.custom_command = xml_node.text

def __str__(self):
return f"{self.own} {self.other}"
return f"{self.custom_command}"


class Projections(BaseNode):
...
# todo


class Sources(BaseNode):
def __init__(
self,
linked_geometry: Union[str, None] = None,
type_: Union[str, None] = None,
*args,
**kwargs,
):
self.linked_geometry = linked_geometry
self.type_ = type_
super().__init__(*args, **kwargs)

def _read_xml(self, xml_node: "Element"):
self.linked_geometry = xml_node.attrib.get("linkedGeometry")
self.type_ = xml_node.attrib.get("type")

def __str__(self):
return f"{self.linked_geometry} {self.type_}"
4 changes: 2 additions & 2 deletions tests/test_fixture_scene_object_1_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ def process_mvr_scene_object(scene_object):
# test getting focus points
name = scene_object.name
uuid = scene_object.uuid
print(name, uuid)
print("scene object", name, uuid)


def process_mvr_focus_point(focus_point):
# test getting focus points
name = focus_point.name
uuid = focus_point.uuid
print(name, uuid)
print("focus point", name, uuid)


def process_classes(mvr_scene):
Expand Down

0 comments on commit 81f4489

Please sign in to comment.