本文整理汇总了Python中shape.Shape.rotateLocation方法的典型用法代码示例。如果您正苦于以下问题:Python Shape.rotateLocation方法的具体用法?Python Shape.rotateLocation怎么用?Python Shape.rotateLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shape.Shape
的用法示例。
在下文中一共展示了Shape.rotateLocation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from shape import Shape [as 别名]
# 或者: from shape.Shape import rotateLocation [as 别名]
def __init__(self, refdef, component):
"""
"""
self._refdef = refdef
self._layer = component.get('layer') or 'top'
self._rotate = component.get('rotate') or 0
self._rotate_point = utils.toPoint(component.get('rotate-point') or [0, 0])
self._scale = component.get('scale') or 1
self._location = component.get('location') or [0, 0]
# Get footprint definition and shapes
try:
self._footprint_name = component['footprint']
except:
msg.error("Cannot find a 'footprint' name for refdef %s." % refdef)
fname = os.path.join(config.cfg['base-dir'],
config.cfg['locations']['components'],
self._footprint_name + '.json')
footprint_dict = utils.dictFromJsonFile(fname)
footprint = Footprint(footprint_dict)
footprint_shapes = footprint.getShapes()
#------------------------------------------------
# Apply component-specific modifiers to footprint
#------------------------------------------------
for sheet in ['copper', 'soldermask', 'solderpaste', 'silkscreen', 'assembly', 'drills']:
for layer in utils.getSurfaceLayers() + utils.getInternalLayers():
for shape in footprint_shapes[sheet][layer]:
# In order to apply the rotation we need to adust the location
# of each element
shape.rotateLocation(self._rotate, self._rotate_point)
shape.transformPath(self._scale,
self._rotate,
self._rotate_point,
False,
True)
#--------------------------------------
# Remove silkscreen and assembly shapes
#--------------------------------------
for sheet in ['silkscreen','assembly']:
try:
shapes_dict = component[sheet].get('shapes') or {}
except:
shapes_dict = {}
# If the setting is to not show silkscreen shapes for the
# component, delete the shapes from the shapes' dictionary
if shapes_dict.get('show') == False:
for pcb_layer in utils.getSurfaceLayers():
footprint_shapes[sheet][pcb_layer] = []
#----------------------------------------------------------
# Add silkscreen and assembly reference designator (refdef)
#----------------------------------------------------------
for sheet in ['silkscreen','assembly']:
try:
refdef_dict = component[sheet].get('refdef') or {}
except:
refdef_dict = {}
if refdef_dict.get('show') != False:
layer = refdef_dict.get('layer') or 'top'
# Rotate the refdef; if unspecified the rotation is the same as
# the rotation of the component
refdef_dict['rotate'] = refdef_dict.get('rotate') or 0
# Sometimes you'd want to keep all refdefs at the same angle
# and not rotated with the component
if refdef_dict.get('rotate-with-component') != False:
refdef_dict['rotate'] += self._rotate
refdef_dict['rotate-point'] = utils.toPoint(refdef_dict.get('rotate-point')) or self._rotate_point
refdef_dict['location'] = refdef_dict.get('location') or [0, 0]
refdef_dict['type'] = 'text'
refdef_dict['value'] = refdef
refdef_dict['font-family'] = (config.stl['layout'][sheet]['refdef'].get('font-family') or
config.stl['defaults']['font-family'])
refdef_dict['font-size'] = (config.stl['layout'][sheet]['refdef'].get('font-size') or
"2mm")
refdef_shape = Shape(refdef_dict)
refdef_shape.is_refdef = True
refdef_shape.rotateLocation(self._rotate, self._rotate_point)
style = Style(refdef_dict, sheet, 'refdef')
refdef_shape.setStyle(style)
# Add the refdef to the silkscreen/assembly list. It's
# important that this is added at the very end since the
# plcament process assumes the refdef is last
#.........这里部分代码省略.........
示例2: __init__
# 需要导入模块: from shape import Shape [as 别名]
# 或者: from shape.Shape import rotateLocation [as 别名]
def __init__(self, refdef, component):
"""
"""
self._refdef = refdef
self._layer = component.get('layer') or 'top'
self._rotate = component.get('rotate') or 0
if self._layer=='bottom':
self._rotate *= -1
self._rotate_point = utils.toPoint(component.get('rotate-point') or [0, 0])
self._scale = component.get('scale') or 1
self._location = component.get('location') or [0, 0]
# Get footprint definition and shapes
try:
self._footprint_name = component['footprint']
except:
msg.error("Cannot find a 'footprint' name for refdef %s." % refdef)
filename = self._footprint_name + '.json'
paths = [os.path.join(config.cfg['base-dir'],
config.cfg['locations']['shapes'],
filename),
os.path.join(config.cfg['base-dir'],
config.cfg['locations']['components'],
filename)]
footprint_dict = None
for path in paths:
if os.path.isfile(path):
footprint_dict = utils.dictFromJsonFile(path)
break
if footprint_dict == None:
fname_list = ""
for path in paths:
fname_list += " %s" % path
msg.error("Couldn't find shape file. Looked for it here:\n%s" % (fname_list))
footprint = Footprint(footprint_dict)
footprint_shapes = footprint.getShapes()
#------------------------------------------------
# Apply component-specific modifiers to footprint
#------------------------------------------------
for sheet in ['conductor', 'soldermask', 'solderpaste', 'pours', 'silkscreen', 'assembly', 'drills']:
for layer in config.stk['layer-names']:
for shape in footprint_shapes[sheet].get(layer) or []:
# In order to apply the rotation we need to adust the location
shape.rotateLocation(self._rotate, self._rotate_point)
shape.transformPath(scale=self._scale,
rotate=self._rotate,
rotate_point=self._rotate_point,
mirror=shape.getMirrorPlacement(),
add=True)
#--------------------------------------------------------------
# Remove silkscreen and assembly shapes if instructed
#--------------------------------------------------------------
# If the 'show' flag is 'false then remove these items from the
# shapes dictionary
#--------------------------------------------------------------
for sheet in ['silkscreen','assembly']:
try:
shapes_dict = component[sheet].get('shapes') or {}
except:
shapes_dict = {}
# If the setting is to not show silkscreen shapes for the
# component, delete the shapes from the shapes' dictionary
if shapes_dict.get('show') == False:
for pcb_layer in utils.getSurfaceLayers():
footprint_shapes[sheet][pcb_layer] = []
#----------------------------------------------------------
# Add silkscreen and assembly reference designator (refdef)
#----------------------------------------------------------
for sheet in ['silkscreen','assembly']:
try:
refdef_dict = component[sheet].get('refdef') or {}
except:
refdef_dict = {}
if refdef_dict.get('show') != False:
layer = refdef_dict.get('layer') or 'top'
# Rotate the refdef; if unspecified the rotation is the same as
# the rotation of the component
refdef_dict['rotate'] = refdef_dict.get('rotate') or 0
# Sometimes you'd want to keep all refdefs at the same angle
#.........这里部分代码省略.........