def drawPaths(self): if not self.draw_paths: for block in self.gcode.blocks: block.resetPath() return self._last = (0.,0.,0.) self.initPosition() self.cnc.resetAllMargins() drawG = self.draw_rapid or self.draw_paths or self.draw_margin for i,block in enumerate(self.gcode.blocks): start = True # start location found block.resetPath() for j,line in enumerate(block): #cmd = self.cnc.parseLine(line) try: cmd = CNC.breakLine(self.gcode.evaluate(CNC.parseLine2(line))) except: sys.stderr.write(">>> ERROR: %s\n"%(str(sys.exc_info()[1]))) sys.stderr.write(" line: %s\n"%(line)) cmd = None if cmd is None or not drawG: block.addPath(None) else: path = self.drawPath(block, cmd) self._items[path] = i,j block.addPath(path) if start and self.cnc.gcode in (1,2,3): # Mark as start the first non-rapid motion block.startPath(self.cnc.x, self.cnc.y, self.cnc.z) start = False block.endPath(self.cnc.x, self.cnc.y, self.cnc.z)
def draw(self, view=None): #, lines): if self._inDraw : return self._inDraw = True self._tzoom = 1.0 self._tafter = None xyz = self.canvas2xyz( self.canvasx(self.winfo_width()/2), self.canvasy(self.winfo_height()/2)) if view is not None: self.view = view self._last = (0.,0.,0.) self.initPosition() drawG = self.draw_rapid or self.draw_paths or self.draw_margin for i,block in enumerate(self.gcode.blocks): block.resetPath() start = True # start location found for j,line in enumerate(block): #cmd = self.cnc.parseLine(line) try: cmd = CNC.breakLine(self.gcode.evaluate(CNC.parseLine2(line))) except: sys.stderr.write(">>> ERROR: %s\n"%(str(sys.exc_info()[1]))) sys.stderr.write(" line: %s\n"%(line)) cmd = None if cmd is None or not drawG: block.addPath(None) else: path = self.drawPath(cmd, block.enable) self._items[path] = i,j block.addPath(path) if start and self.cnc.gcode in (1,2,3): # Mark as start the first non-rapid motion block.startPath(self.cnc.x, self.cnc.y, self.cnc.z) start = False block.endPath(self.cnc.x, self.cnc.y, self.cnc.z) self.drawGrid() self.drawMargin() self.drawWorkarea() self.drawProbe() self.drawAxes() # self.tag_lower(self._workarea) if self._gantry1: self.tag_raise(self._gantry1) if self._gantry2: self.tag_raise(self._gantry2) self._updateScrollBars() ij = self.plotCoords([xyz])[0] dx = int(round(self.canvasx(self.winfo_width()/2) - ij[0])) dy = int(round(self.canvasy(self.winfo_height()/2) - ij[1])) self.scan_mark(0,0) self.scan_dragto(int(round(dx)), int(round(dy)), 1) self._inDraw = False
def drawPaths(self): if not self.draw_paths: for block in self.gcode.blocks: block.resetPath() return self._last = (0.,0.,0.) self.initPosition() self.cnc.resetAllMargins() drawG = self.draw_rapid or self.draw_paths or self.draw_margin for i,block in enumerate(self.gcode.blocks): start = True # start location found block.resetPath() # Draw block tabs if self.draw_margin: for tab in block.tabs: color = block.enable and TAB_COLOR or DISABLE_COLOR item = self._drawRect(tab.xmin, tab.ymin, tab.xmax, tab.ymax, 0., fill=color) tab.path = item self._items[item[0]] = i,tab self.tag_lower(item) # Draw block for j,line in enumerate(block): #cmd = self.cnc.parseLine(line) try: cmd = CNC.breakLine(self.gcode.evaluate(CNC.parseLine2(line))) except: sys.stderr.write(_(">>> ERROR: %s\n")%(str(sys.exc_info()[1]))) sys.stderr.write(_(" line: %s\n")%(line)) cmd = None if cmd is None or not drawG: block.addPath(None) else: path = self.drawPath(block, cmd) self._items[path] = i,j block.addPath(path) if start and self.cnc.gcode in (1,2,3): # Mark as start the first non-rapid motion block.startPath(self.cnc.x, self.cnc.y, self.cnc.z) start = False block.endPath(self.cnc.x, self.cnc.y, self.cnc.z)
def evaluate(self, line): return self.gcode.evaluate(CNC.parseLine2(line, True))
def evaluate(self, line): return self.gcode.evaluate(CNC.parseLine2(line,True))