def plot(self, ztransforms): """Plots a route through the blueprint, then does ztransforms.""" keys = [] cursor = self.start ks = None for layer in self.layers: layer.start = cursor # first layer's start or last layer's exit pos # plan the cursor's route to designate all the areas layer.grid, layer.plots, end = router.plan_route( layer.grid, cursor) # generate key/macro sequence to render this series of plots in DF ks = Keystroker(layer.grid, self.build_config) layerkeys, cursor = ks.plot(layer.plots, cursor) keys += layerkeys + layer.onexit # move cursor back to start pos x, y, so start==end keys += ks.move(cursor, self.start, 0) #start = end # perform any awaiting z-transforms keys = self.repeat_ztransforms(ztransforms, keys, self.repeater_keys) return keys
def repeater_layers(layers, zdistance, reps): zmove = Keystroker.get_z_moves(zdistance) newlayers = [] for x in range(1, reps): newlayers += deepcopy(layers) newlayers[-1].onexit = zmove newlayers += deepcopy(layers) return newlayers
def trace_outline(self): """ Moves the cursor to the northwest corner, then clockwise to each other corner, before returning to the starting position. """ buildconfig = BuildConfig('dig') grid = self.layers[0].grid plotter = AreaPlotter(grid, buildconfig) plotter.expand_fixed_size_areas() # plot cells of d(5x5) format ks = Keystroker(grid, buildconfig) keys = [] # move to each corner beginning with NW, going clockwise, and wait # at each one lastpos = self.start for cornerdir in [ Direction(d) for d in ['nw', 'ne', 'se', 'sw', 'nw'] ]: (x, y) = cornerdir.delta() newpos = (max(0, x) * (grid.width - 1), max(0, y) * (grid.height - 1)) keys += ks.move(lastpos, newpos, allowjumps=False) + ['%'] lastpos = newpos keys += ks.move(lastpos, self.start, allowjumps=False) # trim any pauses off the ends while keys and keys[0] == '%': keys = keys[1:] while keys and keys[-1] == '%': keys = keys[:-1] # if the result is no keys, return a single wait key keys += ['%'] return keys
def trace_outline(self): """ Moves the cursor to the northwest corner, then clockwise to each other corner, before returning to the starting position. """ buildconfig = BuildConfig('dig') grid = self.layers[0].grid plotter = AreaPlotter(grid, buildconfig) plotter.expand_fixed_size_areas() # plot cells of d(5x5) format ks = Keystroker(grid, buildconfig) keys = [] # move to each corner beginning with NW, going clockwise, and wait # at each one lastpos = self.start for cornerdir in [Direction(d) for d in ['nw', 'ne', 'se', 'sw', 'nw']]: (x, y) = cornerdir.delta() newpos = ( max(0, x) * (grid.width - 1), max(0, y) * (grid.height - 1) ) keys += ks.move(lastpos, newpos, allowjumps=False) + ['%'] lastpos = newpos keys += ks.move(lastpos, self.start, allowjumps=False) # trim any pauses off the ends while keys and keys[0] == '%': keys = keys[1:] while keys and keys[-1] == '%': keys = keys[:-1] # if the result is no keys, return a single wait key keys += ['%'] return keys
def repeater_keys(keys, zdistance, reps): zmove = Keystroker.get_z_moves(zdistance) # assemble repetition of z layers' keys keys = ((keys + zmove) * (reps - 1)) + keys return keys