elements: convert class members to instance members
This commit is contained in:
parent
770be5609f
commit
577a67dd6f
109
gds/elements.py
109
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)
|
||||
def __init__(self):
|
||||
# text info
|
||||
self.string = ""
|
||||
self.position = (0,0)
|
||||
|
||||
# presentation
|
||||
fontnumber = 0
|
||||
verticalJustification = VJust.Top
|
||||
horizontalJustification = HJust.Left
|
||||
# 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 = ""
|
||||
"""
|
||||
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 = ""
|
||||
|
||||
transformation = Transformation()
|
||||
self.transformation = Transformation()
|
||||
|
||||
# tree
|
||||
parent = None
|
||||
self.parent = None
|
||||
|
||||
class ARef(Element):
|
||||
position = (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
|
||||
|
||||
# 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)
|
||||
with:
|
||||
|
||||
structure = ""
|
||||
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)
|
||||
|
||||
transformation = Transformation()
|
||||
|
||||
# tree
|
||||
parent = None
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user