Merge branch 'mrbeam' of https://github.com/mrbeam/OctoPrint into mrbeam
This commit is contained in:
commit
54052c2744
10 changed files with 89 additions and 599 deletions
|
|
@ -144,7 +144,7 @@ class SvgToGcodePlugin(octoprint.plugin.SlicerPlugin,
|
|||
|
||||
def get_assets(self):
|
||||
return {
|
||||
"js": ["js/svgtogcode.js", "js/vectorgraphicsconversion.js"],
|
||||
"js": ["js/svgtogcode.js", "js/convert.js"],
|
||||
"less": ["less/svgtogcode.less"],
|
||||
"css": ["css/svgtogcode.css"]
|
||||
}
|
||||
|
|
@ -194,8 +194,9 @@ class SvgToGcodePlugin(octoprint.plugin.SlicerPlugin,
|
|||
def get_slicer_properties(self):
|
||||
return dict(
|
||||
type="svgtogcode",
|
||||
name="SvgToGCode",
|
||||
same_device=True
|
||||
name="svgtogcode",
|
||||
same_device=True,
|
||||
progress_report=False
|
||||
)
|
||||
|
||||
def get_slicer_default_profile(self):
|
||||
|
|
@ -247,19 +248,22 @@ class SvgToGcodePlugin(octoprint.plugin.SlicerPlugin,
|
|||
engine_settings = self._convert_to_engine(profile_path)
|
||||
|
||||
# executable = s.get(["svgtogcode_engine"])
|
||||
executable = "/Users/philipp/Documents/dev/MrBeam/mrbeaminkscapeextension/standalone.py"
|
||||
# executable = "/Users/philipp/Documents/dev/MrBeam/mrbeam-inkscape-ext/standalone.py"
|
||||
executable = "/home/pi/mrbeam-inkscape-ext/standalone.py"
|
||||
log_path = "/home/pi/svgtogcode.log"
|
||||
# log_path = "/Users/philipp/svgtogcode.log"
|
||||
if not executable:
|
||||
return False, "Path to CuraEngine is not configured "
|
||||
|
||||
working_dir, _ = os.path.split(executable)
|
||||
# args = ['"%s"' % executable, '-v', '-p']
|
||||
# for k, v in engine_settings.items():
|
||||
# args += ["-s", '"%s=%s"' % (k, str(v))]
|
||||
# args += ['-o', '"%s"' % machinecode_path, '"%s"' % model_path]
|
||||
return False, "Path to SVG converter is not configured "
|
||||
|
||||
dest_dir, dest_file = os.path.split(machinecode_path)
|
||||
# args = ['"%s"' % executable, '-f "%s"' % dest_file, '-d "%s"' % dest_dir, '"%s"' % model_path]
|
||||
args = ['"%s"' % executable, '-f "%s"' % dest_file, '-d "%s"' % dest_dir, '"%s"' % model_path]
|
||||
working_dir, _ = os.path.split(executable)
|
||||
args = ['"%s"' % executable, '-f "%s"' % dest_file, '-d "%s"' % dest_dir]
|
||||
for k, v in engine_settings.items():
|
||||
args += ['"%s=%s"' % (k, str(v))]
|
||||
args += ['--create-log=false', '"--log-filename=%s"' % log_path,'"%s"' % model_path]
|
||||
|
||||
#python ~/mrbeam-inkscape-ext/standalone.py -f output.gcode -d output/path --engraving-laser-speed=300
|
||||
# --laser-intensity=1000 --create-log=false path/to/input.svg
|
||||
|
||||
import sarge
|
||||
command = " ".join(args)
|
||||
|
|
|
|||
|
|
@ -43,300 +43,8 @@ class GcodeFlavors(object):
|
|||
|
||||
|
||||
defaults = dict(
|
||||
layer_height=0.1,
|
||||
wall_thickness=0.8,
|
||||
solid_layer_thickness=0.6,
|
||||
nozzle_size=0.4,
|
||||
print_temperature=[220, 0, 0, 0],
|
||||
print_bed_temperature=70,
|
||||
platform_adhesion=PlatformAdhesionTypes.NONE,
|
||||
filament_diameter=[2.85, 0, 0, 0],
|
||||
filament_flow=100.0,
|
||||
bottom_thickness=0.3,
|
||||
first_layer_width_factor=100.0,
|
||||
object_sink=0.0,
|
||||
|
||||
fill_density=20,
|
||||
solid_top=True,
|
||||
solid_bottom=True,
|
||||
fill_overlap=15,
|
||||
|
||||
# speeds
|
||||
print_speed=50.0,
|
||||
travel_speed=150.0,
|
||||
bottom_layer_speed=20.0,
|
||||
infill_speed=0.0,
|
||||
outer_shell_speed=0.0,
|
||||
inner_shell_speed=0.0,
|
||||
|
||||
# dual extrusion
|
||||
overlap_dual=0.15,
|
||||
wipe_tower=False,
|
||||
wipe_tower_volume=15,
|
||||
ooze_shield=False,
|
||||
|
||||
# retraction
|
||||
retraction_enable=True,
|
||||
retraction_speed=40.0,
|
||||
retraction_amount=4.5,
|
||||
retraction_dual_amount=16.5,
|
||||
retraction_min_travel=1.5,
|
||||
retraction_combing=True,
|
||||
retraction_minimal_extrusion=0.02,
|
||||
retraction_hop=0.0,
|
||||
|
||||
# cooling
|
||||
cool_min_layer_time=5,
|
||||
fan_enabled=True,
|
||||
fan_full_height=0.5,
|
||||
fan_speed=100,
|
||||
fan_speed_max=100,
|
||||
cool_min_feedrate=10,
|
||||
cool_head_lift=False,
|
||||
|
||||
# support
|
||||
support=SupportLocationTypes.NONE,
|
||||
support_type=SupportTypes.GRID,
|
||||
support_angle=60.0,
|
||||
support_fill_rate=15,
|
||||
support_xy_distance=0.7,
|
||||
support_z_distance=0.15,
|
||||
support_dual_extrusion=SupportDualTypes.BOTH,
|
||||
|
||||
# platform adhesion
|
||||
skirt_line_count=1,
|
||||
skirt_gap=3.0,
|
||||
skirt_minimal_length=150.0,
|
||||
brim_line_count=20,
|
||||
raft_margin=5.0,
|
||||
raft_line_spacing=3.0,
|
||||
raft_base_thickness=0.3,
|
||||
raft_base_linewidth=1.0,
|
||||
raft_interface_thickness=0.27,
|
||||
raft_interface_linewidth=0.4,
|
||||
raft_airgap=0.22,
|
||||
raft_surface_layers=2,
|
||||
|
||||
# repairing
|
||||
fix_horrible_union_all_type_a=True,
|
||||
fix_horrible_union_all_type_b=False,
|
||||
fix_horrible_use_open_bits=False,
|
||||
fix_horrible_extensive_stitching=False,
|
||||
|
||||
# extras
|
||||
spiralize=False,
|
||||
follow_surface=False,
|
||||
|
||||
machine_width=205,
|
||||
machine_depth=205,
|
||||
machine_center_is_zero=False,
|
||||
has_heated_bed=False,
|
||||
gcode_flavor=GcodeFlavors.REPRAP,
|
||||
extruder_amount=1,
|
||||
steps_per_e=0,
|
||||
start_gcode=[
|
||||
# 1 extruder
|
||||
""";Sliced at: {day} {date} {time}
|
||||
;Basic settings: Layer height: {layer_height} Walls: {wall_thickness} Fill: {fill_density}
|
||||
;M190 S{print_bed_temperature} ;Uncomment to add your own bed temperature line
|
||||
;M109 S{print_temperature} ;Uncomment to add your own temperature line
|
||||
G21 ;metric values
|
||||
G90 ;absolute positioning
|
||||
M82 ;set extruder to absolute mode
|
||||
M107 ;start with the fan off
|
||||
|
||||
G28 X0 Y0 ;move X/Y to min endstops
|
||||
G28 Z0 ;move Z to min endstops
|
||||
|
||||
G1 Z15.0 F{travel_speed} ;move the platform down 15mm
|
||||
|
||||
G92 E0 ;zero the extruded length
|
||||
G1 F200 E3 ;extrude 3mm of feed stock
|
||||
G92 E0 ;zero the extruded length again
|
||||
G1 F{travel_speed}
|
||||
;Put printing message on LCD screen
|
||||
M117 Printing...
|
||||
""",
|
||||
# 2 extruders
|
||||
""";Sliced at: {day} {date} {time}
|
||||
;Basic settings: Layer height: {layer_height} Walls: {wall_thickness} Fill: {fill_density}
|
||||
;M190 S{print_bed_temperature} ;Uncomment to add your own bed temperature line
|
||||
;M104 S{print_temperature} ;Uncomment to add your own temperature line
|
||||
;M109 T1 S{print_temperature2} ;Uncomment to add your own temperature line
|
||||
;M109 T0 S{print_temperature} ;Uncomment to add your own temperature line
|
||||
G21 ;metric values
|
||||
G90 ;absolute positioning
|
||||
M107 ;start with the fan off
|
||||
|
||||
G28 X0 Y0 ;move X/Y to min endstops
|
||||
G28 Z0 ;move Z to min endstops
|
||||
|
||||
G1 Z15.0 F{travel_speed} ;move the platform down 15mm
|
||||
|
||||
T1 ;Switch to the 2nd extruder
|
||||
G92 E0 ;zero the extruded length
|
||||
G1 F200 E10 ;extrude 10mm of feed stock
|
||||
G92 E0 ;zero the extruded length again
|
||||
G1 F200 E-{retraction_dual_amount}
|
||||
|
||||
T0 ;Switch to the first extruder
|
||||
G92 E0 ;zero the extruded length
|
||||
G1 F200 E10 ;extrude 10mm of feed stock
|
||||
G92 E0 ;zero the extruded length again
|
||||
G1 F{travel_speed}
|
||||
;Put printing message on LCD screen
|
||||
M117 Printing...
|
||||
""",
|
||||
# 3 extruders
|
||||
""";Sliced at: {day} {date} {time}
|
||||
;Basic settings: Layer height: {layer_height} Walls: {wall_thickness} Fill: {fill_density}
|
||||
;M190 S{print_bed_temperature} ;Uncomment to add your own bed temperature line
|
||||
;M104 S{print_temperature} ;Uncomment to add your own temperature line
|
||||
;M109 T1 S{print_temperature2} ;Uncomment to add your own temperature line
|
||||
;M109 T0 S{print_temperature} ;Uncomment to add your own temperature line
|
||||
G21 ;metric values
|
||||
G90 ;absolute positioning
|
||||
M107 ;start with the fan off
|
||||
|
||||
G28 X0 Y0 ;move X/Y to min endstops
|
||||
G28 Z0 ;move Z to min endstops
|
||||
|
||||
G1 Z15.0 F{travel_speed} ;move the platform down 15mm
|
||||
|
||||
T2 ;Switch to the 2nd extruder
|
||||
G92 E0 ;zero the extruded length
|
||||
G1 F200 E10 ;extrude 10mm of feed stock
|
||||
G92 E0 ;zero the extruded length again
|
||||
G1 F200 E-{retraction_dual_amount}
|
||||
|
||||
T1 ;Switch to the 2nd extruder
|
||||
G92 E0 ;zero the extruded length
|
||||
G1 F200 E10 ;extrude 10mm of feed stock
|
||||
G92 E0 ;zero the extruded length again
|
||||
G1 F200 E-{retraction_dual_amount}
|
||||
|
||||
T0 ;Switch to the first extruder
|
||||
G92 E0 ;zero the extruded length
|
||||
G1 F200 E10 ;extrude 10mm of feed stock
|
||||
G92 E0 ;zero the extruded length again
|
||||
G1 F{travel_speed}
|
||||
;Put printing message on LCD screen
|
||||
M117 Printing...
|
||||
""",
|
||||
# 4 extruders
|
||||
""";Sliced at: {day} {date} {time}
|
||||
;Basic settings: Layer height: {layer_height} Walls: {wall_thickness} Fill: {fill_density}
|
||||
;M190 S{print_bed_temperature} ;Uncomment to add your own bed temperature line
|
||||
;M104 S{print_temperature} ;Uncomment to add your own temperature line
|
||||
;M109 T2 S{print_temperature2} ;Uncomment to add your own temperature line
|
||||
;M109 T1 S{print_temperature2} ;Uncomment to add your own temperature line
|
||||
;M109 T0 S{print_temperature} ;Uncomment to add your own temperature line
|
||||
G21 ;metric values
|
||||
G90 ;absolute positioning
|
||||
M107 ;start with the fan off
|
||||
|
||||
G28 X0 Y0 ;move X/Y to min endstops
|
||||
G28 Z0 ;move Z to min endstops
|
||||
|
||||
G1 Z15.0 F{travel_speed} ;move the platform down 15mm
|
||||
|
||||
T3 ;Switch to the 4th extruder
|
||||
G92 E0 ;zero the extruded length
|
||||
G1 F200 E10 ;extrude 10mm of feed stock
|
||||
G92 E0 ;zero the extruded length again
|
||||
G1 F200 E-{retraction_dual_amount}
|
||||
|
||||
T2 ;Switch to the 3th extruder
|
||||
G92 E0 ;zero the extruded length
|
||||
G1 F200 E10 ;extrude 10mm of feed stock
|
||||
G92 E0 ;zero the extruded length again
|
||||
G1 F200 E-{retraction_dual_amount}
|
||||
|
||||
T1 ;Switch to the 2nd extruder
|
||||
G92 E0 ;zero the extruded length
|
||||
G1 F200 E10 ;extrude 10mm of feed stock
|
||||
G92 E0 ;zero the extruded length again
|
||||
G1 F200 E-{retraction_dual_amount}
|
||||
|
||||
T0 ;Switch to the first extruder
|
||||
G92 E0 ;zero the extruded length
|
||||
G1 F200 E10 ;extrude 10mm of feed stock
|
||||
G92 E0 ;zero the extruded length again
|
||||
G1 F{travel_speed}
|
||||
;Put printing message on LCD screen
|
||||
M117 Printing...
|
||||
"""
|
||||
],
|
||||
end_gcode=[
|
||||
# 1 extruder
|
||||
""";End GCode
|
||||
M104 S0 ;extruder heater off
|
||||
M140 S0 ;heated bed heater off (if you have it)
|
||||
|
||||
G91 ;relative positioning
|
||||
G1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure
|
||||
G1 Z+0.5 E-5 X-20 Y-20 F{travel_speed} ;move Z up a bit and retract filament even more
|
||||
G28 X0 Y0 ;move X/Y to min endstops, so the head is out of the way
|
||||
|
||||
M84 ;steppers off
|
||||
G90 ;absolute positioning
|
||||
;{profile_string}
|
||||
""",
|
||||
# 2 extruders
|
||||
""";End GCode
|
||||
M104 T0 S0 ;extruder heater off
|
||||
M104 T1 S0 ;extruder heater off
|
||||
M140 S0 ;heated bed heater off (if you have it)
|
||||
|
||||
G91 ;relative positioning
|
||||
G1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure
|
||||
G1 Z+0.5 E-5 X-20 Y-20 F{travel_speed} ;move Z up a bit and retract filament even more
|
||||
G28 X0 Y0 ;move X/Y to min endstops, so the head is out of the way
|
||||
|
||||
M84 ;steppers off
|
||||
G90 ;absolute positioning
|
||||
;{profile_string}
|
||||
""",
|
||||
# 3 extruders
|
||||
""";End GCode
|
||||
M104 T0 S0 ;extruder heater off
|
||||
M104 T1 S0 ;extruder heater off
|
||||
M104 T2 S0 ;extruder heater off
|
||||
M140 S0 ;heated bed heater off (if you have it)
|
||||
|
||||
G91 ;relative positioning
|
||||
G1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure
|
||||
G1 Z+0.5 E-5 X-20 Y-20 F{travel_speed} ;move Z up a bit and retract filament even more
|
||||
G28 X0 Y0 ;move X/Y to min endstops, so the head is out of the way
|
||||
|
||||
M84 ;steppers off
|
||||
G90 ;absolute positioning
|
||||
;{profile_string}
|
||||
""",
|
||||
# 4 extruders
|
||||
""";End GCode
|
||||
M104 T0 S0 ;extruder heater off
|
||||
M104 T1 S0 ;extruder heater off
|
||||
M104 T2 S0 ;extruder heater off
|
||||
M104 T3 S0 ;extruder heater off
|
||||
M140 S0 ;heated bed heater off (if you have it)
|
||||
|
||||
G91 ;relative positioning
|
||||
G1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure
|
||||
G1 Z+0.5 E-5 X-20 Y-20 F{travel_speed} ;move Z up a bit and retract filament even more
|
||||
G28 X0 Y0 ;move X/Y to min endstops, so the head is out of the way
|
||||
|
||||
M84 ;steppers off
|
||||
G90 ;absolute positioning
|
||||
;{profile_string}
|
||||
"""
|
||||
],
|
||||
preSwitchExtruder_gcode=""";Switch between the current extruder and the next extruder, when printing with multiple extruders.
|
||||
;This code is added before the T(n)
|
||||
""",
|
||||
postSwitchExtruder_gcode=""";Switch between the current extruder and the next extruder, when printing with multiple extruders.
|
||||
;This code is added after the T(n)
|
||||
"""
|
||||
speed=100,
|
||||
intensity=100
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -724,102 +432,9 @@ class Profile(object):
|
|||
|
||||
def convert_to_engine(self):
|
||||
|
||||
|
||||
settings = {
|
||||
"--engraving-laser-speed": self.get_microns("layer_height"),
|
||||
"initialLayerThickness": self.get_microns("bottom_thickness") if self.get_float("bottom_thickness") > 0.0 else self.get_microns("layer_height"),
|
||||
|
||||
"--engraving-laser-speed": self.get_int("speed"),
|
||||
"--laser-intensity": self.get_int("intensity")
|
||||
}
|
||||
|
||||
for extruder in range(1, extruder_count):
|
||||
for axis in ("x", "y"):
|
||||
settings["extruderOffset[{extruder}].{axis}".format(extruder=extruder, axis=axis.upper())] = self.get_machine_extruder_offset(extruder, axis)
|
||||
|
||||
fanFullHeight = self.get_microns("fan_full_height")
|
||||
settings["fanFullOnLayerNr"] = (fanFullHeight - settings["initialLayerThickness"] - 1) / settings["layerThickness"] + 1
|
||||
if settings["fanFullOnLayerNr"] < 0:
|
||||
settings["fanFullOnLayerNr"] = 0
|
||||
|
||||
if self.get("support_type") == SupportTypes.LINES:
|
||||
settings["supportType"] = 1
|
||||
|
||||
# infill
|
||||
if self.get_float("fill_density") == 0:
|
||||
settings["sparseInfillLineDistance"] = -1
|
||||
|
||||
elif self.get_float("fill_density") == 100:
|
||||
settings["sparseInfillLineDistance"] = settings["extrusionWidth"]
|
||||
settings["downSkinCount"] = 10000
|
||||
settings["upSkinCount"] = 10000
|
||||
|
||||
else:
|
||||
settings["sparseInfillLineDistance"] = int(100 * edge_width * 1000 / self.get_float("fill_density"))
|
||||
|
||||
# brim/raft/skirt
|
||||
if self.get("platform_adhesion") == PlatformAdhesionTypes.BRIM:
|
||||
settings["skirtDistance"] = 0
|
||||
settings["skirtLineCount"] = self.get_int("brim_line_count")
|
||||
|
||||
elif self.get("platform_adhesion") == PlatformAdhesionTypes.RAFT:
|
||||
settings["skirtDistance"] = 0
|
||||
settings["skirtLineCount"] = 0
|
||||
settings["raftMargin"] = self.get_microns("raft_margin")
|
||||
settings["raftLineSpacing"] = self.get_microns("raft_line_spacing")
|
||||
settings["raftBaseThickness"] = self.get_microns("raft_base_thickness")
|
||||
settings["raftBaseLinewidth"] = self.get_microns("raft_base_linewidth")
|
||||
settings["raftInterfaceThickness"] = self.get_microns("raft_interface_thickness")
|
||||
settings["raftInterfaceLinewidth"] = self.get_microns("raft_interface_linewidth")
|
||||
settings["raftInterfaceLineSpacing"] = self.get_microns("raft_interface_linewidth") * 2
|
||||
settings["raftAirGapLayer0"] = self.get_microns("raft_airgap")
|
||||
settings["raftBaseSpeed"] = self.get_int("bottom_layer_speed")
|
||||
settings["raftFanSpeed"] = 100
|
||||
settings["raftSurfaceThickness"] = settings["raftInterfaceThickness"]
|
||||
settings["raftSurfaceLinewidth"] = int(edge_width * 1000)
|
||||
settings["raftSurfaceLineSpacing"] = int(edge_width * 1000 * 0.9)
|
||||
settings["raftSurfaceLayers"] = self.get_int("raft_surface_layers")
|
||||
settings["raftSurfaceSpeed"] = self.get_int("bottom_layer_speed")
|
||||
|
||||
else:
|
||||
settings["skirtDistance"] = self.get_microns("skirt_gap")
|
||||
settings["skirtLineCount"] = self.get_int("skirt_line_count")
|
||||
settings["skirtMinLength"] = self.get_microns("skirt_minimal_length")
|
||||
|
||||
# fixing
|
||||
if self.get_boolean("fix_horrible_union_all_type_a"):
|
||||
settings["fixHorrible"] |= 0x01
|
||||
if self.get_boolean("fix_horrible_union_all_type_b"):
|
||||
settings["fixHorrible"] |= 0x02
|
||||
if self.get_boolean("fix_horrible_use_open_bits"):
|
||||
settings["fixHorrible"] |= 0x10
|
||||
if self.get_boolean("fix_horrible_extensive_stitching"):
|
||||
settings["fixHorrible"] |= 0x04
|
||||
|
||||
if settings["layerThickness"] <= 0:
|
||||
settings["layerThickness"] = 1000
|
||||
|
||||
# gcode flavor
|
||||
if self.get("gcode_flavor") == GcodeFlavors.ULTIGCODE:
|
||||
settings["gcodeFlavor"] = 1
|
||||
elif self.get("gcode_flavor") == GcodeFlavors.MAKERBOT:
|
||||
settings["gcodeFlavor"] = 2
|
||||
elif self.get("gcode_flavor") == GcodeFlavors.BFB:
|
||||
settings["gcodeFlavor"] = 3
|
||||
elif self.get("gcode_flavor") == GcodeFlavors.MACH3:
|
||||
settings["gcodeFlavor"] = 4
|
||||
elif self.get("gcode_flavor") == GcodeFlavors.REPRAP_VOLUME:
|
||||
settings["gcodeFlavor"] = 5
|
||||
|
||||
# extras
|
||||
if self.get_boolean("spiralize"):
|
||||
settings["spiralizeMode"] = 1
|
||||
if self.get_boolean("follow_surface"):
|
||||
settings["simpleMode"] = 1
|
||||
|
||||
# dual extrusion
|
||||
if self.get_boolean("wipe_tower") and extruder_count > 1:
|
||||
import math
|
||||
settings["wipeTowerSize"] = int(math.sqrt(self.get_float("wipe_tower_volume") * 1000 * 1000 * 1000 / settings["layerThickness"]))
|
||||
if self.get_boolean("ooze_shield"):
|
||||
settings["enableOozeShield"] = 1
|
||||
|
||||
return settings
|
||||
|
|
|
|||
|
|
@ -1,4 +1,2 @@
|
|||
layer_height: 0.2
|
||||
print_temperature:
|
||||
- 220.0
|
||||
- 220.0
|
||||
speed: 100
|
||||
intensity: 100
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
$(function() {
|
||||
function VectorGraphicsConversionViewModel(loginStateViewModel) {
|
||||
function VectorConversionViewModel(loginStateViewModel) {
|
||||
var self = this;
|
||||
|
||||
self.loginState = loginStateViewModel;
|
||||
|
|
@ -12,6 +11,8 @@ function VectorGraphicsConversionViewModel(loginStateViewModel) {
|
|||
self.defaultProfile = undefined;
|
||||
|
||||
self.gcodeFilename = ko.observable();
|
||||
self.laserIntensity = ko.observable();
|
||||
self.laserSpeed = ko.observable();
|
||||
|
||||
self.title = ko.observable();
|
||||
self.slicer = ko.observable();
|
||||
|
|
@ -22,20 +23,26 @@ function VectorGraphicsConversionViewModel(loginStateViewModel) {
|
|||
self.show = function(target, file) {
|
||||
self.target = target;
|
||||
self.file = file;
|
||||
self.title(_.sprintf(gettext("Convert %(filename)s"), {filename: self.file}));
|
||||
self.title(_.sprintf(gettext("Converting %(filename)s"), {filename: self.file}));
|
||||
self.gcodeFilename(self.file.substr(0, self.file.lastIndexOf(".")));
|
||||
$("#slicing_configuration_dialog").modal("show");
|
||||
$("#dialog_vector_graphics_conversion").modal("show");
|
||||
};
|
||||
|
||||
self.slicer.subscribe(function(newValue) {
|
||||
self.profilesForSlicer(newValue);
|
||||
});
|
||||
|
||||
self.enableSliceButton = ko.computed(function() {
|
||||
return self.gcodeFilename() != undefined
|
||||
&& self.gcodeFilename().trim() != ""
|
||||
&& self.slicer() != undefined
|
||||
&& self.profile() != undefined;
|
||||
self.enableConvertButton = ko.computed(function() {
|
||||
if (self.laserIntensity() == undefined || self.laserSpeed() == undefined || self.gcodeFilename() == undefined) {
|
||||
return false;
|
||||
} else {
|
||||
var tmpIntensity = parseInt(self.laserIntensity().trim());
|
||||
var tmpSpeed = parseInt(self.laserSpeed().trim());
|
||||
var tmpGcodeFilename = self.gcodeFilename().trim();
|
||||
return tmpGcodeFilename != ""
|
||||
&& tmpIntensity > 0 && tmpIntensity <= 1000
|
||||
&& tmpSpeed >= 30 && tmpSpeed <= 2000;
|
||||
}
|
||||
});
|
||||
|
||||
self.requestData = function() {
|
||||
|
|
@ -109,7 +116,7 @@ function VectorGraphicsConversionViewModel(loginStateViewModel) {
|
|||
self.defaultProfile = selectedProfile;
|
||||
};
|
||||
|
||||
self.slice = function() {
|
||||
self.convert = function() {
|
||||
var gcodeFilename = self._sanitize(self.gcodeFilename());
|
||||
if (!_.endsWith(gcodeFilename.toLowerCase(), ".gco")
|
||||
&& !_.endsWith(gcodeFilename.toLowerCase(), ".gcode")
|
||||
|
|
@ -119,8 +126,9 @@ function VectorGraphicsConversionViewModel(loginStateViewModel) {
|
|||
|
||||
var data = {
|
||||
command: "slice",
|
||||
slicer: self.slicer(),
|
||||
profile: self.profile(),
|
||||
"profile.speed": self.laserSpeed(),
|
||||
"profile.intensity": self.laserIntensity(),
|
||||
slicer: "svgtogcode",
|
||||
gcode: gcodeFilename
|
||||
};
|
||||
|
||||
|
|
@ -132,11 +140,11 @@ function VectorGraphicsConversionViewModel(loginStateViewModel) {
|
|||
data: JSON.stringify(data)
|
||||
});
|
||||
|
||||
$("#slicing_configuration_dialog").modal("hide");
|
||||
$("#dialog_vector_graphics_conversion").modal("hide");
|
||||
|
||||
self.gcodeFilename(undefined);
|
||||
self.slicer(self.defaultSlicer);
|
||||
self.profile(self.defaultProfile);
|
||||
//self.slicer(self.defaultSlicer);
|
||||
//self.profile(self.defaultProfile);
|
||||
};
|
||||
|
||||
self._sanitize = function(name) {
|
||||
|
|
@ -146,8 +154,4 @@ function VectorGraphicsConversionViewModel(loginStateViewModel) {
|
|||
self.onStartup = function() {
|
||||
self.requestData();
|
||||
};
|
||||
}
|
||||
|
||||
ADDITIONAL_VIEWMODELS.push([VectorGraphicsConversionViewModel, ["loginStateViewModel", "settingsViewModel", "slicingViewModel"], document.getElementById("dialog_vector_graphics_conversion")]);
|
||||
|
||||
});
|
||||
}
|
||||
|
|
@ -17,175 +17,19 @@ $(function() {
|
|||
self.profileDescription = ko.observable();
|
||||
self.profileAllowOverwrite = ko.observable(true);
|
||||
|
||||
self.uploadElement = $("#settings-svgtogcode-import");
|
||||
self.uploadButton = $("#settings-svgtogcode-import-start");
|
||||
|
||||
self.profiles = new ItemListHelper(
|
||||
"plugin_svgtogcode_profiles",
|
||||
{
|
||||
"id": function(a, b) {
|
||||
if (a["key"].toLocaleLowerCase() < b["key"].toLocaleLowerCase()) return -1;
|
||||
if (a["key"].toLocaleLowerCase() > b["key"].toLocaleLowerCase()) return 1;
|
||||
return 0;
|
||||
},
|
||||
"name": function(a, b) {
|
||||
// sorts ascending
|
||||
var aName = a.name();
|
||||
if (aName === undefined) {
|
||||
aName = "";
|
||||
}
|
||||
var bName = b.name();
|
||||
if (bName === undefined) {
|
||||
bName = "";
|
||||
}
|
||||
|
||||
if (aName.toLocaleLowerCase() < bName.toLocaleLowerCase()) return -1;
|
||||
if (aName.toLocaleLowerCase() > bName.toLocaleLowerCase()) return 1;
|
||||
return 0;
|
||||
}
|
||||
},
|
||||
{},
|
||||
"id",
|
||||
[],
|
||||
[],
|
||||
5
|
||||
);
|
||||
|
||||
self._sanitize = function(name) {
|
||||
return name.replace(/[^a-zA-Z0-9\-_\.\(\) ]/g, "").replace(/ /g, "_");
|
||||
};
|
||||
|
||||
self.uploadElement.fileupload({
|
||||
dataType: "json",
|
||||
maxNumberOfFiles: 1,
|
||||
autoUpload: false,
|
||||
add: function(e, data) {
|
||||
if (data.files.length == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
self.fileName(data.files[0].name);
|
||||
|
||||
var name = self.fileName().substr(0, self.fileName().lastIndexOf("."));
|
||||
self.placeholderName(self._sanitize(name).toLowerCase());
|
||||
self.placeholderDisplayName(name);
|
||||
self.placeholderDescription("Imported from " + self.fileName() + " on " + formatDate(new Date().getTime() / 1000));
|
||||
|
||||
self.uploadButton.on("click", function() {
|
||||
var form = {
|
||||
allowOverwrite: self.profileAllowOverwrite()
|
||||
};
|
||||
|
||||
if (self.profileName() !== undefined) {
|
||||
form["name"] = self.profileName();
|
||||
}
|
||||
if (self.profileDisplayName() !== undefined) {
|
||||
form["displayName"] = self.profileDisplayName();
|
||||
}
|
||||
if (self.profileDescription() !== undefined) {
|
||||
form["description"] = self.profileDescription();
|
||||
}
|
||||
|
||||
data.formData = form;
|
||||
data.submit();
|
||||
});
|
||||
},
|
||||
done: function(e, data) {
|
||||
self.fileName(undefined);
|
||||
self.placeholderName(undefined);
|
||||
self.placeholderDisplayName(undefined);
|
||||
self.placeholderDescription(undefined);
|
||||
self.profileName(undefined);
|
||||
self.profileDisplayName(undefined);
|
||||
self.profileDescription(undefined);
|
||||
self.profileAllowOverwrite(true);
|
||||
|
||||
$("#settings-plugin-svgtogcode-import").modal("hide");
|
||||
self.requestData();
|
||||
self.slicingViewModel.requestData();
|
||||
}
|
||||
});
|
||||
|
||||
self.removeProfile = function(data) {
|
||||
if (!data.resource) {
|
||||
self.convertSVG2 = function(data) {
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
|
||||
self.profiles.removeItem(function(item) {
|
||||
return (item.key == data.key);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: data.resource(),
|
||||
type: "DELETE",
|
||||
success: function() {
|
||||
self.requestData();
|
||||
self.slicingViewModel.requestData();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
self.makeProfileDefault = function(data) {
|
||||
if (!data.resource) {
|
||||
return;
|
||||
}
|
||||
|
||||
_.each(self.profiles.items(), function(item) {
|
||||
item.isdefault(false);
|
||||
});
|
||||
var item = self.profiles.getItem(function(item) {
|
||||
return item.key == data.key;
|
||||
});
|
||||
if (item !== undefined) {
|
||||
item.isdefault(true);
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: data.resource(),
|
||||
type: "PATCH",
|
||||
dataType: "json",
|
||||
data: JSON.stringify({default: true}),
|
||||
contentType: "application/json; charset=UTF-8",
|
||||
success: function() {
|
||||
self.requestData();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
self.showImportProfileDialog = function() {
|
||||
$("#settings_plugin_svgtogcode_import").modal("show");
|
||||
};
|
||||
|
||||
self.requestData = function() {
|
||||
$.ajax({
|
||||
url: API_BASEURL + "slicing/svgtogcode/profiles",
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
success: self.fromResponse
|
||||
});
|
||||
};
|
||||
|
||||
self.fromResponse = function(data) {
|
||||
var profiles = [];
|
||||
_.each(_.keys(data), function(key) {
|
||||
profiles.push({
|
||||
key: key,
|
||||
name: ko.observable(data[key].displayName),
|
||||
description: ko.observable(data[key].description),
|
||||
isdefault: ko.observable(data[key].default),
|
||||
resource: ko.observable(data[key].resource)
|
||||
});
|
||||
});
|
||||
self.profiles.updateItems(profiles);
|
||||
};
|
||||
|
||||
self.onBeforeBinding = function () {
|
||||
self.settings = self.settingsViewModel.settings;
|
||||
self.requestData();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
// view model class, parameters for constructor, container to bind to
|
||||
ADDITIONAL_VIEWMODELS.push([SvgToGcodeViewModel, ["loginStateViewModel", "settingsViewModel", "slicingViewModel"], document.getElementById("settings_plugin_svgtogcode_dialog")]);
|
||||
});
|
||||
ADDITIONAL_VIEWMODELS.push([SvgToGcodeViewModel, ["loginStateViewModel", "settingsViewModel", "slicingViewModel"], null]);
|
||||
}});
|
||||
|
|
@ -4,8 +4,25 @@
|
|||
<h3 data-bind="text: title"></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>{{ _('Please configure which slicer and which slicing profile to use and name the GCode file to slice to below, or click "Cancel" if you do not wish to slice the file now.') }}</p>
|
||||
<p>{{ _('Please configure which slicer and which slicing profile to use and name the GCode file to slice to
|
||||
below, or click "Cancel" if you do not wish to slice the file now.') }}</p>
|
||||
<form class="form-horizontal">
|
||||
<div class="control-group">
|
||||
<label class="control-label">{{ _('Laser intensity (1-1000)') }}</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="text" data-bind="value: laserIntensity">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label">{{ _('Speed (30 - 2000)') }}</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="text" data-bind="value: laserSpeed">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label">{{ _('GCode Filename') }}</label>
|
||||
<div class="controls">
|
||||
|
|
@ -19,6 +36,6 @@
|
|||
</div>
|
||||
<div class="modal-footer">
|
||||
<a href="#" class="btn" data-dismiss="modal" aria-hidden="true">{{ _('Cancel') }}</a>
|
||||
<a href="#" class="btn btn-primary" data-bind="click: function() { if ($root.enableSliceButton()) { $root.slice() } }, enabled: enableSliceButton, css: {disabled: !$root.enableSliceButton()}">{{ _('Slice') }}</a>
|
||||
<a href="#" class="btn btn-primary" data-bind="click: function() { if ($root.enableConvertButton()) { $root.convert() } }, enabled: enableConvertButton, css: {disabled: !$root.enableConvertButton()}">{{ _('Convert') }}</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -24,9 +24,9 @@ def settings(init=False, configfile=None, basedir=None):
|
|||
|
||||
default_settings = {
|
||||
"serial": {
|
||||
"port": None,
|
||||
"baudrate": None,
|
||||
"autoconnect": False,
|
||||
"port": "/dev/ttyACM0",
|
||||
"baudrate": 115200,
|
||||
"autoconnect": True,
|
||||
"log": False,
|
||||
"timeout": {
|
||||
"detection": 0.5,
|
||||
|
|
|
|||
|
|
@ -77,7 +77,8 @@ $(function() {
|
|||
var controlViewModel = new ControlViewModel(loginStateViewModel, settingsViewModel);
|
||||
var terminalViewModel = new TerminalViewModel(loginStateViewModel, settingsViewModel);
|
||||
var slicingViewModel = new SlicingViewModel(loginStateViewModel);
|
||||
var gcodeFilesViewModel = new GcodeFilesViewModel(printerStateViewModel, loginStateViewModel, slicingViewModel);
|
||||
var vectorConversionViewModel = new VectorConversionViewModel(loginStateViewModel);
|
||||
var gcodeFilesViewModel = new GcodeFilesViewModel(printerStateViewModel, loginStateViewModel, slicingViewModel, vectorConversionViewModel);
|
||||
var gcodeViewModel = new GcodeViewModel(loginStateViewModel, settingsViewModel);
|
||||
var navigationViewModel = new NavigationViewModel(loginStateViewModel, appearanceViewModel, settingsViewModel, usersViewModel);
|
||||
var logViewModel = new LogViewModel(loginStateViewModel);
|
||||
|
|
@ -97,7 +98,8 @@ $(function() {
|
|||
gcodeViewModel: gcodeViewModel,
|
||||
navigationViewModel: navigationViewModel,
|
||||
logViewModel: logViewModel,
|
||||
slicingViewModel: slicingViewModel
|
||||
slicingViewModel: slicingViewModel,
|
||||
vectorConversionViewModel: vectorConversionViewModel
|
||||
};
|
||||
|
||||
var allViewModels = _.values(viewModelMap);
|
||||
|
|
@ -413,6 +415,7 @@ $(function() {
|
|||
}
|
||||
|
||||
ko.applyBindings(slicingViewModel, document.getElementById("slicing_configuration_dialog"));
|
||||
ko.applyBindings(vectorConversionViewModel, document.getElementById("dialog_vector_graphics_conversion"));
|
||||
|
||||
// apply bindings and signal startup
|
||||
_.each(additionalViewModels, function(additionalViewModel) {
|
||||
|
|
@ -421,7 +424,11 @@ $(function() {
|
|||
}
|
||||
|
||||
// model instance, target container
|
||||
ko.applyBindings(additionalViewModel[0], additionalViewModel[1]);
|
||||
if (additionalViewModel[1]) {
|
||||
ko.applyBindings(additionalViewModel[0], additionalViewModel[1]);
|
||||
} else {
|
||||
ko.applyBindings(additionalViewModel[0]);
|
||||
}
|
||||
|
||||
if (additionalViewModel[0].hasOwnProperty("onAfterBinding")) {
|
||||
additionalViewModel[0].onAfterBinding();
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
function GcodeFilesViewModel(printerStateViewModel, loginStateViewModel, slicingViewModel) {
|
||||
function GcodeFilesViewModel(printerStateViewModel, loginStateViewModel, slicingViewModel, vectorConversionViewModel) {
|
||||
var self = this;
|
||||
|
||||
self.printerState = printerStateViewModel;
|
||||
self.loginState = loginStateViewModel;
|
||||
self.slicing = slicingViewModel;
|
||||
self.conversion = vectorConversionViewModel;
|
||||
|
||||
self.isErrorOrClosed = ko.observable(undefined);
|
||||
self.isOperational = ko.observable(undefined);
|
||||
|
|
@ -192,7 +193,7 @@ function GcodeFilesViewModel(printerStateViewModel, loginStateViewModel, slicing
|
|||
self.convertSVG = function(file) {
|
||||
if (!file) return;
|
||||
|
||||
self.svgconversion.show(file.origin, file.name);
|
||||
self.conversion.show(file.origin, file.name);
|
||||
};
|
||||
|
||||
self.initSdCard = function() {
|
||||
|
|
|
|||
|
|
@ -248,7 +248,7 @@
|
|||
<div class="size">{{ _('Size') }}: <span data-bind="text: formatSize(size)"></span></div>
|
||||
<div class="btn-group action-buttons">
|
||||
<div class="btn btn-mini" data-bind="click: function() { if ($root.enableRemove($data)) { $root.removeFile($data); } else { return; } }, css: {disabled: !$root.enableRemove($data)}"><i class="icon-trash" title="{{ _('Remove') }}"></i></div>
|
||||
<div class="btn btn-mini" data-bind="click: function() { if ($root.enableSVGConversion($data)) { $root.convertSVG($data); } else { return; } }, css: {disabled: !$root.enableSVGConversion($data)}"><i class="icon-fire" title="{{ _('Convert to Laserpath') }}"></i></div>
|
||||
<div class="btn btn-mini" data-bind="click: function() { $root.convertSVG($data); }, css: {disabled: !$root.enableSVGConversion($data)}"><i class="icon-fire" title="{{ _('Convert to Laserpath') }}"></i></div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue