diff --git a/gds/elements.py b/gds/elements.py index 0652d5b..fa9f0b4 100644 --- a/gds/elements.py +++ b/gds/elements.py @@ -1,24 +1,28 @@ from enum import Enum class Transformation(object): - mirror_x = 0 + def __init__(self): + self.mirror_x = 0 - absolute_rotation = 0 - absolute_magnification = 0 + self.absolute_rotation = 0 + self.absolute_magnification = 0 - zoom = 1 - rotation = 0 + self.zoom = 1 + self.rotation = 0 class Element(object): - elflags = 0 - plex = 0 - datatype = 0 + def __init__(self): + self.elflags = 0 + self.plex = 0 + self.datatype = 0 class Drawable(object): - layer = 0 + def __init__(self): + self.layer = 0 class Boundary(Element, Drawable): - points = [] + def __init__(self): + self.points = [] class Path(Element, Drawable): class Styles(Enum): @@ -27,11 +31,12 @@ class Path(Element, Drawable): OFFSET_ENDS = 2 CUSTOM_END = 4 - extendEnd = [0,0] # extend past start and end - width = 0 - pathStyle = Styles.SQUARE_ENDS + def __init__(self): + self.extendEnd = [0,0] # extend past start and end + self.width = 0 + self.pathStyle = Styles.SQUARE_ENDS - points = [] + self.points = [] class Text(Element, Drawable): class VJust(Enum): @@ -44,46 +49,68 @@ class Text(Element, Drawable): Center = 1 Right = 2 - # text info - string = "" - position = (0,0) - - # presentation - fontnumber = 0 - verticalJustification = VJust.Top - horizontalJustification = HJust.Left + def __init__(self): + # text info + self.string = "" + self.position = (0,0) + + # presentation + self.fontnumber = 0 + self.verticalJustification = VJust.Top + self.horizontalJustification = HJust.Left - # optional path info - pathStype = Path.Styles.SQUARE_ENDS - pathWidth = 0 + # optional path info + self.pathStype = Path.Styles.SQUARE_ENDS + self.pathWidth = 0 - transformation = Transformation() + self.transformation = Transformation() class Box(Element, Drawable): - points = [] + def __init__(self): + self.points = [] class SRef(Element): - position = (0,0) - structure = "" - - transformation = Transformation() + """ + 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() - # tree - parent = None + self.parent = None -class ARef(Element): - position = (0,0) - - # positions of last instance in X and Y direction - bounds = [(0,0), (0,0)] - # number of instances in X and Y direction - size = (0,0) +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) - structure = "" - - transformation = Transformation() - # tree - parent = None