Make default no magnification to text. PEP8 Cleanup

This commit is contained in:
mrg 2020-12-09 11:42:28 -08:00
parent 9717794400
commit 0a9a946cd1
3 changed files with 101 additions and 70 deletions

View File

@ -1,4 +1,4 @@
import math
class GdsStructure:
"""Class represent a GDS Structure Object"""
@ -15,6 +15,7 @@ class GdsStructure:
self.nodes=[]
self.boxes=[]
class GdsBoundary:
"""Class represent a GDS Boundary Object"""
def __init__(self):
@ -24,6 +25,7 @@ class GdsBoundary:
self.purposeLayer=0
self.coordinates=""
class GdsPath:
"""Class represent a GDS Path Object"""
def __init__(self):
@ -112,6 +114,7 @@ class GdsPath:
lastY = y
return boundaryEquivalent
class GdsSref:
"""Class represent a GDS structure reference Object"""
def __init__(self):
@ -123,6 +126,7 @@ class GdsSref:
self.rotateAngle=""
self.coordinates=""
class GdsAref:
"""Class represent a GDS array reference Object"""
def __init__(self):
@ -134,6 +138,7 @@ class GdsAref:
self.rotateAngle=""
self.coordinates=""
class GdsText:
"""Class represent a GDS text Object"""
def __init__(self):
@ -150,6 +155,7 @@ class GdsText:
self.coordinates=""
self.textString = ""
class GdsNode:
"""Class represent a GDS Node Object"""
def __init__(self):
@ -159,6 +165,7 @@ class GdsNode:
self.nodeType=""
self.coordinates=""
class GdsBox:
"""Class represent a GDS Box Object"""
def __init__(self):

View File

@ -1,11 +1,10 @@
from .gdsPrimitives import *
from datetime import *
#from mpmath import matrix
#from numpy import matrix
import numpy as np
#import gdsPrimitives
import math
import debug
class VlsiLayout:
"""Class represent a hierarchical layout"""
@ -53,10 +52,11 @@ class VlsiLayout:
self.info['libraryName']=libraryName
self.info['gdsVersion']=gdsVersion
self.xyTree = [] #This will contain a list of all structure names
# This will contain a list of all structure names
# expanded to include srefs / arefs separately.
# each structure will have an X,Y,offset, and rotate associated
# with it. Populate via traverseTheHierarchy method.
self.xyTree = []
# temp variables used in delegate functions
self.tempCoordinates=None
@ -108,8 +108,6 @@ class VlsiLayout:
self.structures[newName] = GdsStructure()
self.structures[newName].name = newName
self.rootStructureName = newName
self.rootStructureName=newName
@ -155,7 +153,6 @@ class VlsiLayout:
debug.check(len(structureNames)==1,"Multiple possible root structures in the layout: {}".format(str(structureNames)))
self.rootStructureName = structureNames[0]
def traverseTheHierarchy(self, startingStructureName=None, delegateFunction=None,
transformPath=[], rotateAngle=0, transFlags=[0, 0, 0], coordinates=(0, 0)):
# since this is a recursive function, must deal with the default
@ -175,14 +172,18 @@ class VlsiLayout:
# set up the translation matrix
translateX = float(coordinates[0])
translateY = float(coordinates[1])
mTranslate = np.array([[1.0,0.0,translateX],[0.0,1.0,translateY],[0.0,0.0,1.0]])
mTranslate = np.array([[1.0, 0.0, translateX],
[0.0, 1.0, translateY],
[0.0, 0.0, 1.0]])
# set up the scale matrix (handles mirror X)
scaleX = 1.0
if (transFlags[0]):
scaleY = -1.0
else:
scaleY = 1.0
mScale = np.array([[scaleX,0.0,0.0],[0.0,scaleY,0.0],[0.0,0.0,1.0]])
mScale = np.array([[scaleX, 0.0, 0.0],
[0.0, scaleY, 0.0],
[0.0, 0.0, 1.0]])
# we need to keep track of all transforms in the hierarchy
# when we add an element to the xy tree, we apply all transforms from the bottom up
transformPath.append((mRotate,mScale,mTranslate))
@ -218,7 +219,6 @@ class VlsiLayout:
for layerNumber in self.layerNumbersInUse:
self.processLabelPins((layerNumber, None))
def populateCoordinateMap(self):
def addToXyTree(startingStructureName = None,transformPath = None):
uVector = np.array([[1.0],[0.0],[0.0]]) #start with normal basis vectors
@ -281,8 +281,6 @@ class VlsiLayout:
self.newLayout(newRoot)
self.rootStructureName = newRoot
def addInstance(self,layoutToAdd,nameOfLayout=0,offsetInMicrons=(0,0),mirror=None,rotate=None):
"""
Method to insert one layout into another at a particular offset.
@ -406,7 +404,7 @@ class VlsiLayout:
#add the sref to the root structure
self.structures[self.rootStructureName].paths.append(pathToAdd)
def addText(self, text, layerNumber=0, purposeNumber=0, offsetInMicrons=(0,0), magnification=0.1, rotate = None):
def addText(self, text, layerNumber=0, purposeNumber=0, offsetInMicrons=(0,0), magnification=None, rotate=None):
offsetInLayoutUnits = (self.userUnits(offsetInMicrons[0]),self.userUnits(offsetInMicrons[1]))
textToAdd = GdsText()
textToAdd.drawingLayer = layerNumber
@ -415,6 +413,7 @@ class VlsiLayout:
textToAdd.transFlags = [0,0,0]
textToAdd.textString = self.padText(text)
#textToAdd.transFlags[1] = 1
if magnification:
textToAdd.magFactor = magnification
if rotate:
#textToAdd.transFlags[2] = 1

25
compiler/processGDS.py Executable file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env python3
import sys
from gdsMill import gdsMill
if len(sys.argv) < 2:
print("Usage: {0} in.gds out.gds".format(sys.argv[0]))
sys.exit(1)
in_gds_file = sys.argv[1]
out_gds_file = sys.argv[2]
layout = gdsMill.VlsiLayout()
reader = gdsMill.Gds2reader(layout)
reader.loadFromFile(in_gds_file)
struct = layout.structures[layout.rootStructureName]
# Do something to the structure
for text in struct.texts:
print(text.textString)
text.magFactor=""
writer = gdsMill.Gds2writer(layout)
writer.writeToFile(out_gds_file)