Exemplo n.º 1
0
def writeDimensionArrow(fid, OriginX, OriginY, MaxXExtent, MaxYExtent):
    x = util.in2gerb(OriginX)
    y = util.in2gerb(OriginY)
    X = util.in2gerb(MaxXExtent)
    Y = util.in2gerb(MaxYExtent)

    # This constant is how far away from the board the centerline of the dimension
    # arrows should be, in inches.
    dimspace = 0.2

    # Convert it to Gerber (0.00001" or 2.5) units
    dimspace = util.in2gerb(dimspace)

    # Draw an arrow above the board, on the left side and right side
    makestroke.drawDimensionArrow(fid, x, Y + dimspace, makestroke.FACING_LEFT)
    makestroke.drawDimensionArrow(fid, X, Y + dimspace, makestroke.FACING_RIGHT)

    # Draw arrows to the right of the board, at top and bottom
    makestroke.drawDimensionArrow(fid, X + dimspace, Y, makestroke.FACING_UP)
    makestroke.drawDimensionArrow(fid, X + dimspace, y, makestroke.FACING_DOWN)

    # Now draw the text. First, horizontal text above the board.
    s = "{:.3f}\"".format(MaxXExtent - OriginX)
    ll, ur = makestroke.boundingBox(s, 0, 0)
    s_width = ur[0] - ll[0]   # Width in 2.5 units
    s_height = ur[1] - ll[1]  # Height in 2.5 units

    # Compute the position in 2.5 units where we should draw this. It should be
    # centered horizontally and also vertically about the dimension arrow centerline.
    posX = x + (x + X) / 2
    posX -= s_width / 2
    posY = Y + dimspace - s_height / 2
    makestroke.writeString(fid, s, posX, posY, 0)

    # Finally, draw the extending lines from the text to the arrows.
    posY = Y + dimspace
    posX1 = posX - util.in2gerb(0.1)  # 1000
    posX2 = posX + s_width + util.in2gerb(0.1)  # 1000
    makestroke.drawLine(fid, x, posY, posX1, posY)
    makestroke.drawLine(fid, posX2, posY, X, posY)

    # Now do the vertical text
    s = "{:.3f}\"".format(MaxYExtent - OriginY)
    ll, ur = makestroke.boundingBox(s, 0, 0)
    s_width = ur[0] - ll[0]
    s_height = ur[1] - ll[1]

    # As above, figure out where to draw this. Rotation will be -90 degrees
    # so new origin will be top-left of bounding box after rotation.
    posX = X + dimspace - s_height / 2
    posY = y + (y + Y) / 2
    posY += s_width / 2
    makestroke.writeString(fid, s, posX, posY, -90)

    # Draw extending lines
    posX = X + dimspace
    posY1 = posY + util.in2gerb(0.1)  # 1000
    posY2 = posY - s_width - util.in2gerb(0.1)  # 1000
    makestroke.drawLine(fid, posX, Y, posX, posY1)
    makestroke.drawLine(fid, posX, posY2, posX, y)
Exemplo n.º 2
0
def writeDimensionArrow(fid, OriginX, OriginY, MaxXExtent, MaxYExtent):
    x = util.in2gerb(OriginX)
    y = util.in2gerb(OriginY)
    X = util.in2gerb(MaxXExtent)
    Y = util.in2gerb(MaxYExtent)

    # This constant is how far away from the board the centerline of the dimension
    # arrows should be, in inches.
    dimspace = 0.2

    # Convert it to Gerber (0.00001" or 2.5) units
    dimspace = util.in2gerb(dimspace)

    # Draw an arrow above the board, on the left side and right side
    makestroke.drawDimensionArrow(fid, x, Y + dimspace, makestroke.FacingLeft)
    makestroke.drawDimensionArrow(fid, X, Y + dimspace, makestroke.FacingRight)

    # Draw arrows to the right of the board, at top and bottom
    makestroke.drawDimensionArrow(fid, X + dimspace, Y, makestroke.FacingUp)
    makestroke.drawDimensionArrow(fid, X + dimspace, y, makestroke.FacingDown)

    # Now draw the text. First, horizontal text above the board.
    s = '%.3f"' % (MaxXExtent - OriginX)
    ll, ur = makestroke.boundingBox(s, 0, 0)
    s_width = ur[0] - ll[0]  # Width in 2.5 units
    s_height = ur[1] - ll[1]  # Height in 2.5 units

    # Compute the position in 2.5 units where we should draw this. It should be
    # centered horizontally and also vertically about the dimension arrow centerline.
    posX = x + (x + X) / 2
    posX -= s_width / 2
    posY = Y + dimspace - s_height / 2
    makestroke.writeString(fid, s, posX, posY, 0)

    # Finally, draw the extending lines from the text to the arrows.
    posY = Y + dimspace
    posX1 = posX - util.in2gerb(0.1)  # 1000
    posX2 = posX + s_width + util.in2gerb(0.1)  # 1000
    makestroke.drawLine(fid, x, posY, posX1, posY)
    makestroke.drawLine(fid, posX2, posY, X, posY)

    # Now do the vertical text
    s = '%.3f"' % (MaxYExtent - OriginY)
    ll, ur = makestroke.boundingBox(s, 0, 0)
    s_width = ur[0] - ll[0]
    s_height = ur[1] - ll[1]

    # As above, figure out where to draw this. Rotation will be -90 degrees
    # so new origin will be top-left of bounding box after rotation.
    posX = X + dimspace - s_height / 2
    posY = y + (y + Y) / 2
    posY += s_width / 2
    makestroke.writeString(fid, s, posX, posY, -90)

    # Draw extending lines
    posX = X + dimspace
    posY1 = posY + util.in2gerb(0.1)  # 1000
    posY2 = posY - s_width - util.in2gerb(0.1)  # 1000
    makestroke.drawLine(fid, posX, Y, posX, posY1)
    makestroke.drawLine(fid, posX, posY2, posX, y)
Exemplo n.º 3
0
def writeDimensionArrow(fid, OriginX, OriginY, MaxXExtent, MaxYExtent):
  x = util.in2gerb(OriginX)
  y = util.in2gerb(OriginY)
  X = util.in2gerb(MaxXExtent)
  Y = util.in2gerb(MaxYExtent)

  # This constant is how far away from the board the centerline of the dimension
  # arrows should be, in inches.
  # dimspace = 0.2          # KHK was the original line
  if config.Config['measurementunits'] == 'inch':  
     dimspace = 0.2 # inches
  else:
     dimspace = 10 # mm     - Distance of dimension line to board outline line

  # Convert it to Gerber (0.00001" or 2.5) units
  dimspace = util.in2gerb(dimspace)

  # Draw an arrow above the board, on the left side and right side
  makestroke.drawDimensionArrow(fid, x, Y+dimspace, makestroke.FacingLeft)
  makestroke.drawDimensionArrow(fid, X, Y+dimspace, makestroke.FacingRight)

  # Draw arrows to the right of the board, at top and bottom
  makestroke.drawDimensionArrow(fid, X+dimspace, Y, makestroke.FacingUp)
  makestroke.drawDimensionArrow(fid, X+dimspace, y, makestroke.FacingDown)

  # Now draw the text. First, horizontal text above the board.
  # s = '%.3f"' % (MaxXExtent - OriginX) # KHK orig line
  if config.Config['measurementunits'] == 'inch':  
      s = '%.3f"' % (MaxXExtent - OriginX) # inche
  else:
      s = '%.3fmm' % (MaxXExtent - OriginX) # mm 
  ll, ur = makestroke.boundingBox(s, 0, 0)
  s_width = ur[0]-ll[0]   # Width in 2.5 units
  s_height = ur[1]-ll[1]  # Height in 2.5 units

  # Compute the position in 2.5 units where we should draw this. It should be
  # centered horizontally and also vertically about the dimension arrow centerline.
  posX = x + (x+X)/2
  posX -= s_width/2
  posY = Y + dimspace - s_height/2
  makestroke.writeString(fid, s, posX, posY, 0)

  # Finally, draw the extending lines from the text to the arrows.
  posY = Y + dimspace
  #posX1 = posX - util.in2gerb(0.1*24.5) # 1000  # KHK orig. line
  if config.Config['measurementunits'] == 'inch':  
     posX1 = posX - util.in2gerb(0.1 ) # 1000
  else:
     posX1 = posX - util.in2gerb(0.1*24.5) # 1000
  # posX2 = posX + s_width + util.in2gerb(0.1*25.4) # 1000  # KHK orig. line
  if config.Config['measurementunits'] == 'inch':  
     posX2 = posX + s_width + util.in2gerb(0.1) # 1000
  else:
     posX2 = posX + s_width + util.in2gerb(0.1*25.4) # 1000
  makestroke.drawLine(fid, x, posY, posX1, posY)
  makestroke.drawLine(fid, posX2, posY, X, posY)

  # Now do the vertical text
  # s = '%.3f"' % (MaxYExtent - OriginY) # KHK orig line
  if config.Config['measurementunits'] == 'inch':  
     s = '%.3f"' % (MaxYExtent - OriginY) 
  else:
     s = '%.3fmm' % (MaxYExtent - OriginY) 
  ll, ur = makestroke.boundingBox(s, 0, 0)
  s_width = ur[0]-ll[0]
  s_height = ur[1]-ll[1]

  # As above, figure out where to draw this. Rotation will be -90 degrees
  # so new origin will be top-left of bounding box after rotation.
  posX = X + dimspace - s_height/2
  posY = y + (y+Y)/2
  posY += s_width/2
  makestroke.writeString(fid, s, posX, posY, -90)

  # Draw extending lines
  posX = X + dimspace
  # posY1 = posY + util.in2gerb(0.1) # 1000  # KHK orig. line
  if config.Config['measurementunits'] == 'inch':  
     posY1 = posY + util.in2gerb(0.1) # 1000  # KHK orig. line
  else:
     posY1 = posY + util.in2gerb(0.1*25.4) # 1000  # KHK orig. line
  # posY2 = posY - s_width - util.in2gerb(0.1) # 1000  # KHK orig. line
  if config.Config['measurementunits'] == 'inch':  
     posY2 = posY - s_width - util.in2gerb(0.1) # 1000  # KHK orig. line
  else:
     posY2 = posY - s_width - util.in2gerb(0.1*25.4) # 1000
  makestroke.drawLine(fid, posX, Y, posX, posY1)
  makestroke.drawLine(fid, posX, posY2, posX, y)