2019-07-01 11:45:02 +02:00
|
|
|
from enum import Enum
|
|
|
|
|
|
|
|
class Transformation(object):
|
2019-07-02 14:44:25 +02:00
|
|
|
def __init__(self):
|
|
|
|
self.mirror_x = 0
|
2019-07-01 11:45:02 +02:00
|
|
|
|
2019-07-02 14:44:25 +02:00
|
|
|
self.absolute_rotation = 0
|
|
|
|
self.absolute_magnification = 0
|
2019-07-01 11:45:02 +02:00
|
|
|
|
2019-07-02 14:44:25 +02:00
|
|
|
self.zoom = 1
|
|
|
|
self.rotation = 0
|
2019-07-01 11:45:02 +02:00
|
|
|
|
|
|
|
class Element(object):
|
2019-07-02 14:44:25 +02:00
|
|
|
def __init__(self):
|
|
|
|
self.elflags = 0
|
|
|
|
self.plex = 0
|
|
|
|
self.datatype = 0
|
2019-07-01 11:45:02 +02:00
|
|
|
|
|
|
|
class Drawable(object):
|
2019-07-02 14:44:25 +02:00
|
|
|
def __init__(self):
|
|
|
|
self.layer = 0
|
2019-07-01 11:45:02 +02:00
|
|
|
|
|
|
|
class Boundary(Element, Drawable):
|
2019-07-02 14:44:25 +02:00
|
|
|
def __init__(self):
|
|
|
|
self.points = []
|
2019-07-01 11:45:02 +02:00
|
|
|
|
|
|
|
class Path(Element, Drawable):
|
|
|
|
class Styles(Enum):
|
|
|
|
SQUARE_ENDS = 0
|
|
|
|
ROUNDED_ENDS = 1
|
|
|
|
OFFSET_ENDS = 2
|
|
|
|
CUSTOM_END = 4
|
|
|
|
|
2019-07-02 14:44:25 +02:00
|
|
|
def __init__(self):
|
|
|
|
self.extendEnd = [0,0] # extend past start and end
|
|
|
|
self.width = 0
|
2019-07-02 14:54:41 +02:00
|
|
|
self.pathStyle = Path.Styles.SQUARE_ENDS
|
2019-07-01 11:45:02 +02:00
|
|
|
|
2019-07-02 14:44:25 +02:00
|
|
|
self.points = []
|
2019-07-01 11:45:02 +02:00
|
|
|
|
|
|
|
class Text(Element, Drawable):
|
|
|
|
class VJust(Enum):
|
|
|
|
Top = 0
|
|
|
|
Middle = 1
|
|
|
|
Bottom = 2
|
|
|
|
|
|
|
|
class HJust(Enum):
|
|
|
|
Left = 0
|
|
|
|
Center = 1
|
|
|
|
Right = 2
|
|
|
|
|
2019-07-02 14:44:25 +02:00
|
|
|
def __init__(self):
|
|
|
|
# text info
|
|
|
|
self.string = ""
|
|
|
|
self.position = (0,0)
|
|
|
|
|
|
|
|
# presentation
|
|
|
|
self.fontnumber = 0
|
2019-07-02 14:54:41 +02:00
|
|
|
self.verticalJustification = Text.VJust.Top
|
|
|
|
self.horizontalJustification = Text.HJust.Left
|
2019-07-01 11:45:02 +02:00
|
|
|
|
2019-07-02 14:44:25 +02:00
|
|
|
# optional path info
|
|
|
|
self.pathStype = Path.Styles.SQUARE_ENDS
|
|
|
|
self.pathWidth = 0
|
2019-07-01 11:45:02 +02:00
|
|
|
|
2019-07-02 14:44:25 +02:00
|
|
|
self.transformation = Transformation()
|
2019-07-01 11:45:02 +02:00
|
|
|
|
|
|
|
|
|
|
|
class Box(Element, Drawable):
|
2019-07-02 14:44:25 +02:00
|
|
|
def __init__(self):
|
|
|
|
self.points = []
|
2019-07-01 11:45:02 +02:00
|
|
|
|
|
|
|
class SRef(Element):
|
2019-07-02 14:44:25 +02:00
|
|
|
"""
|
|
|
|
A Structure Reference defines a single instance of a different structure in
|
|
|
|
the structure we call parent here
|
|
|
|
"""
|
|
|
|
def __init__(self):
|
|
|
|
self.position = (0,0)
|
|
|
|
self.structure = ""
|
|
|
|
|
|
|
|
self.transformation = Transformation()
|
|
|
|
|
|
|
|
self.parent = None
|
|
|
|
|
|
|
|
class ARef(SRef):
|
|
|
|
"""
|
|
|
|
An Array Reference is similar to the SRef, but it defines the instances in a grid
|
|
|
|
with size instances spaces evenly between the bound coordinates
|
|
|
|
|
|
|
|
with:
|
|
|
|
|
|
|
|
v1 = bounds[0] - position
|
|
|
|
v2 = bounds[1] - position
|
|
|
|
i = xth instance index
|
|
|
|
j = yth instance index
|
|
|
|
|
|
|
|
this will result in an array like this:
|
|
|
|
j\i | 0 | 1 | ... | size[0]
|
|
|
|
----+-----------------+---------------------------+-----+--------------------
|
|
|
|
0 | (position) | (position + v1) | ... | (bounds[0])
|
|
|
|
1 | (position + v2) | (position + v1*i + v2*j) | ... | (bounds[0] + v2)
|
|
|
|
... | ... | ... | ... | ...
|
|
|
|
size[1] | (bounds[2]) | (bounds[2] + v1) | ... | (bounds[0] + bounds[1])
|
|
|
|
|
|
|
|
"""
|
|
|
|
def __init__(self):
|
|
|
|
super(ARef, self).__init__()
|
|
|
|
|
|
|
|
# positions of last instance in X and Y direction
|
|
|
|
self.bounds = [(0,0), (0,0)]
|
|
|
|
# number of instances in X and Y direction
|
|
|
|
self.size = (0,0)
|
2019-07-01 11:45:02 +02:00
|
|
|
|
2019-07-01 14:21:45 +02:00
|
|
|
|
2019-07-01 11:45:02 +02:00
|
|
|
|