Tue, 26 Sep 2017 19:08:02 +0200
SVG options: offset, original scale
SVG Bugfix: "scale" does now really fit to dimensions
15 | 1 | # This file is part of the Printrun suite. |
2 | # | |
3 | # Printrun is free software: you can redistribute it and/or modify | |
4 | # it under the terms of the GNU General Public License as published by | |
5 | # the Free Software Foundation, either version 3 of the License, or | |
6 | # (at your option) any later version. | |
7 | # | |
8 | # Printrun is distributed in the hope that it will be useful, | |
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | # GNU General Public License for more details. | |
12 | # | |
13 | # You should have received a copy of the GNU General Public License | |
14 | # along with Printrun. If not, see <http://www.gnu.org/licenses/>. | |
15 | ||
16 | import logging | |
17 | ||
18 | from .gui.widgets import MacroEditor | |
19 | ||
20 | from .utils import install_locale | |
21 | install_locale('pronterface') | |
22 | ||
23 | def injector(gcode, viz_layer, layer_idx): | |
24 | cb = lambda toadd: inject(gcode, viz_layer, layer_idx, toadd) | |
25 | z = gcode.all_layers[layer_idx].z | |
26 | z = z if z is not None else 0 | |
27 | MacroEditor(_("Inject G-Code at layer %d (Z = %.03f)") % (viz_layer, z), "", cb, True) | |
28 | ||
29 | def injector_edit(gcode, viz_layer, layer_idx): | |
30 | cb = lambda toadd: rewritelayer(gcode, viz_layer, layer_idx, toadd) | |
31 | layer = gcode.all_layers[layer_idx] | |
32 | z = layer.z | |
33 | z = z if z is not None else 0 | |
34 | lines = [line.raw for line in layer] | |
35 | MacroEditor(_("Edit G-Code of layer %d (Z = %.03f)") % (viz_layer, z), lines, cb, True) | |
36 | ||
37 | def inject(gcode, viz_layer, layer_idx, toadd): | |
38 | # TODO: save modified gcode after injection ? | |
39 | nlines = len(gcode.prepend_to_layer(toadd, layer_idx)) | |
40 | logging.info(_("Successfully injected %d lines at beginning of layer %d") % (nlines, viz_layer)) | |
41 | ||
42 | def rewritelayer(gcode, viz_layer, layer_idx, toadd): | |
43 | # TODO: save modified gcode after edit ? | |
44 | nlines = len(gcode.rewrite_layer(toadd, layer_idx)) | |
45 | logging.info(_("Successfully edited layer %d (which now contains %d lines)") % (viz_layer, nlines)) |