示例#1
0
        def do_face(l,x,y):
            nf = []
            for o in l:
                nl = [odict2str(offseter(parseline(line),x,y)) for line in o.string.splitlines()]
                no = op('\n'.join(nl),o.tool, o.part)
                nf.append(no)

            return nf
示例#2
0
 def do_face_a(l,x,y,angle):
     nf = []
     for o in l:
         nl = []
         for line in o.string.splitlines():
             d = parseline(line)
             d = offseter(d,-x,-(1220-y))
             d = rotater(d,-angle)               
             d = offseter(d,x,1220-y)
             nl.append(odict2str(d))
         no = op('\n'.join(nl),o.tool, o.part)
         nf.append(no)
     return nf
示例#3
0
def draw_gcode(previous_line, current_line, grey_lines=False):
    """Decides whether to draw an air move / cut 
    / arc cw / arc ccw."""

    d = current_line
    p = previous_line 

    def radius():
        return sqrt(pow(p['X']-d['I'],2)+pow(p['Y']-d['J'],2))  

    def angle(i):
        if i == 1:
            angle = Point2D(p['X']-d['I'], p['Y']-d['J']).GetVectorAngle()
            return radians(angle)   
        elif i == 2:
            angle = Point2D(d['X']-d['I'], d['Y']-d['J']).GetVectorAngle()
            return radians(angle)   
    
    line = odict2str(d)

    if grey_lines: col = OURGREY 
    else: col = 0

    if line.startswith(moves['airmove']) and d.has_key('X'):
        cr.set_source_rgb(0.8, 0.8, 0.8)
        cr.move_to(p['X'], p['Y'])
        cr.line_to(d['X'], d['Y'])
    elif line.startswith(moves['opmove']):
        cr.set_source_rgb(col, col, col)
        cr.move_to(p['X'], p['Y'])
        cr.line_to(d['X'], d['Y'])
    elif line.startswith('G03'):
        cr.set_source_rgb(col, col, col)
        cr.arc_negative(d['I'], d['J'], radius(), angle(1), angle(2))
    elif line.startswith('G02'):
        cr.set_source_rgb(col, col, col)
        cr.arc(d['I'], d['J'], radius(), angle(1), angle(2))