当前位置: 首页>>代码示例>>Python>>正文


Python Shape.getWidth方法代码示例

本文整理汇总了Python中shape.Shape.getWidth方法的典型用法代码示例。如果您正苦于以下问题:Python Shape.getWidth方法的具体用法?Python Shape.getWidth怎么用?Python Shape.getWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在shape.Shape的用法示例。


在下文中一共展示了Shape.getWidth方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _placeLayerIndex

# 需要导入模块: from shape import Shape [as 别名]
# 或者: from shape.Shape import getWidth [as 别名]
    def _placeLayerIndex(self):
        """
        Adds a drill index
        """

        text_dict = config.stl['layout']['layer-index']['text']
        text_dict['type'] = 'text'

        # Set the height (and width) of the rectangle (square) to the
        # size of the text
        rect_width = utils.parseDimension(text_dict['font-size'])[0]
        rect_height = rect_width
        rect_gap = 0.25

        # Get location, or generate one
        try:
            location = config.brd['layer-index']['location']
        except:
            # If not location is specified, put the drill index at the
            # top right of the board. The 'gap' defines the extra
            # spcae between the top of the largest drill and the
            # board's edge
            gap = 2
            location = [self._width/2+gap, self._height/2-rect_height/2]
        location = utils.toPoint(location)        

        rect_dict = {}
        rect_dict['type'] = 'rect'
        rect_dict['style'] = 'fill'
        rect_dict['width'] = rect_width
        rect_dict['height'] = rect_height

        # Create group for placing index
        for pcb_layer in utils.getSurfaceLayers():
            for sheet in ['copper', 'soldermask', 'silkscreen', 'assembly', 'solderpaste']:
                layer = self._layers[pcb_layer][sheet]['layer']
                transform = "translate(%s,%s)" % (location.x, config.cfg['invert-y']*location.y)
                group = et.SubElement(layer, 'g',
                                      transform=transform)
                group.set('{'+config.cfg['ns']['pcbmode']+'}type', 'layer-index')

                rect_shape = Shape(rect_dict)
                style = Style(rect_dict, sheet)
                rect_shape.setStyle(style)
                place.placeShape(rect_shape, group)

                text_dict['value'] = "%s %s" % (pcb_layer, sheet)
                #text_dict['location'] = [rect_width+rect_gap+text_width, 0]
                text_shape = Shape(text_dict)
                text_width = text_shape.getWidth()
                style = Style(text_dict, sheet)
                text_shape.setStyle(style)
                element = place.placeShape(text_shape, group)
                element.set("transform", "translate(%s,%s)" % (rect_width/2+rect_gap+text_width/2, 0))

                location.y += config.cfg['invert-y']*(rect_height+rect_gap)

            location.y += config.cfg['invert-y']*(rect_height+rect_gap*2)
开发者ID:hobzcalvin,项目名称:pcbmode,代码行数:60,代码来源:module.py

示例2: _placeOutlineDimensions

# 需要导入模块: from shape import Shape [as 别名]
# 或者: from shape.Shape import getWidth [as 别名]
    def _placeOutlineDimensions(self):
        """
        Places outline dimension arrows
        """


        def makeArrow(width, gap):
            """
            Returns a path for an arrow of width 'width' with a center gap of
            width 'gap'
            """
 
            # Length of bar perpendicular to the arrow's shaft
            base_length = 1.8
 
            # Height of arrow's head
            arrow_height = 2.5
 
            # Width of arrow's head
            arrow_base = 1.2
     
            # Create path
            path = "m %s,%s %s,%s m %s,%s %s,%s m %s,%s %s,%s m %s,%s %s,%s m %s,%s m %s,%s %s,%s m %s,%s %s,%s m %s,%s %s,%s m %s,%s %s,%s" % (-gap/2,0, -width/2+gap/2,0, 0,base_length/2, 0,-base_length, arrow_height,(base_length-arrow_base)/2, -arrow_height,arrow_base/2, arrow_height,arrow_base/2, -arrow_height,-arrow_base/2, width/2,0, gap/2,0, width/2-gap/2,0, 0,base_length/2, 0,-base_length, -arrow_height,(base_length-arrow_base)/2, arrow_height,arrow_base/2, -arrow_height,arrow_base/2, arrow_height,-arrow_base/2,) 
            
            return path



 
        # Create text shapes
        shape_dict = {}
        shape_dict['type'] = 'text'
        style_dict = config.stl['layout']['dimensions'].get('text') or {}
        shape_dict['font-family'] = style_dict.get('font-family') or "UbuntuMono-R-webfont"
        shape_dict['font-size'] = style_dict.get('font-size') or "1.5mm"
        shape_dict['line-height'] = style_dict.get('line-height') or "1mm"
        shape_dict['letter-spacing'] = style_dict.get('letter-spacing') or "0mm"

        # Locations
        arrow_gap = 1.5
        width_loc = [0, self._height/2+arrow_gap]
        height_loc = [-(self._width/2+arrow_gap), 0]

        # Width text
        width_text_dict = shape_dict.copy()
        width_text_dict['value'] = "%s mm" % round(self._width,2)
        width_text_dict['location'] = width_loc
        width_text = Shape(width_text_dict)
        style = Style(width_text_dict, 'dimensions')
        width_text.setStyle(style)

        # Height text
        height_text_dict = shape_dict.copy()
        height_text_dict['value'] = "%s mm" % round(self._height,2)
        height_text_dict['rotate'] = -90
        height_text_dict['location'] = height_loc
        height_text = Shape(height_text_dict)
        style = Style(height_text_dict, 'dimensions')
        height_text.setStyle(style)
 
        # Width arrow
        shape_dict = {}
        shape_dict['type'] = 'path'
        shape_dict['value'] = makeArrow(self._width, width_text.getWidth()*1.2)
        shape_dict['location'] = width_loc
        width_arrow = Shape(shape_dict)
        style = Style(shape_dict, 'dimensions')
        width_arrow.setStyle(style)
 
        # Height arrow
        shape_dict = {}
        shape_dict['type'] = 'path'
        shape_dict['value'] = makeArrow(self._height, height_text.getHeight()*1.2)
        shape_dict['rotate'] = -90
        shape_dict['location'] = height_loc
        height_arrow = Shape(shape_dict)
        style = Style(shape_dict, 'dimensions')
        height_arrow.setStyle(style)

        svg_layer = self._layers['dimensions']['layer']
        group = et.SubElement(svg_layer, 'g')
        group.set('{'+config.cfg['ns']['pcbmode']+'}type', 'module-shapes')
        place.placeShape(width_text, group)
        place.placeShape(height_text, group)
        place.placeShape(width_arrow, group)
        place.placeShape(height_arrow, group)
开发者ID:huigao80,项目名称:pcbmode,代码行数:88,代码来源:module.py


注:本文中的shape.Shape.getWidth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。