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