passing forward the image engraving parameters
This commit is contained in:
parent
18fc2fd68e
commit
b2a9c392fe
4 changed files with 159 additions and 223 deletions
|
|
@ -10,41 +10,50 @@ from . import s
|
|||
|
||||
import re
|
||||
|
||||
class SupportLocationTypes(object):
|
||||
NONE = "none"
|
||||
TOUCHING_BUILDPLATE = "buildplate"
|
||||
EVERYWHERE = "everywhere"
|
||||
|
||||
class SupportDualTypes(object):
|
||||
BOTH = "both"
|
||||
FIRST = "first"
|
||||
SECOND = "second"
|
||||
|
||||
class SupportTypes(object):
|
||||
GRID = "grid"
|
||||
LINES = "lines"
|
||||
|
||||
class PlatformAdhesionTypes(object):
|
||||
NONE = "none"
|
||||
BRIM = "brim"
|
||||
RAFT = "raft"
|
||||
|
||||
class MachineShapeTypes(object):
|
||||
SQUARE = "square"
|
||||
CIRCULAR = "circular"
|
||||
|
||||
class GcodeFlavors(object):
|
||||
REPRAP = "reprap"
|
||||
REPRAP_VOLUME = "reprap_volume"
|
||||
ULTIGCODE = "ultigcode"
|
||||
MAKERBOT = "makerbot"
|
||||
BFB = "bfb"
|
||||
MACH3 = "mach3"
|
||||
#class SupportLocationTypes(object):
|
||||
# NONE = "none"
|
||||
# TOUCHING_BUILDPLATE = "buildplate"
|
||||
# EVERYWHERE = "everywhere"
|
||||
#
|
||||
#class SupportDualTypes(object):
|
||||
# BOTH = "both"
|
||||
# FIRST = "first"
|
||||
# SECOND = "second"
|
||||
#
|
||||
#class SupportTypes(object):
|
||||
# GRID = "grid"
|
||||
# LINES = "lines"
|
||||
#
|
||||
#class PlatformAdhesionTypes(object):
|
||||
# NONE = "none"
|
||||
# BRIM = "brim"
|
||||
# RAFT = "raft"
|
||||
#
|
||||
#class MachineShapeTypes(object):
|
||||
# SQUARE = "square"
|
||||
# CIRCULAR = "circular"
|
||||
#
|
||||
#class GcodeFlavors(object):
|
||||
# REPRAP = "reprap"
|
||||
# REPRAP_VOLUME = "reprap_volume"
|
||||
# ULTIGCODE = "ultigcode"
|
||||
# MAKERBOT = "makerbot"
|
||||
# BFB = "bfb"
|
||||
# MACH3 = "mach3"
|
||||
|
||||
|
||||
defaults = dict(
|
||||
speed=100,
|
||||
intensity=100
|
||||
speed = 300,
|
||||
intensity = 500,
|
||||
beam_diameter = 0.25,
|
||||
intensity_white = 0,
|
||||
intensity_black = 500,
|
||||
feedrate_white = 1000,
|
||||
feedrate_black = 500,
|
||||
pierce_time = 0,
|
||||
contrast = 1.0,
|
||||
sharpening = 1.0,
|
||||
dither = False
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -167,6 +176,7 @@ class Profile(object):
|
|||
def merge_profile(cls, profile, overrides=None):
|
||||
import copy
|
||||
|
||||
print("# overrides", overrides)
|
||||
result = copy.deepcopy(defaults)
|
||||
for k in result.keys():
|
||||
profile_value = None
|
||||
|
|
@ -181,35 +191,12 @@ class Profile(object):
|
|||
# neither override nor profile, no need to handle this key further
|
||||
continue
|
||||
|
||||
if k in ("start_gcode", "end_gcode"):
|
||||
# the array fields need some special treatment. Basically something like this:
|
||||
#
|
||||
# override_value: [None, "b"]
|
||||
# profile_value : ["a" , None, "c"]
|
||||
# default_value : ["d" , "e" , "f", "g"]
|
||||
#
|
||||
# should merge to something like this:
|
||||
#
|
||||
# ["a" , "b" , "c", "g"]
|
||||
#
|
||||
# So override > profile > default, if neither override nor profile value are available
|
||||
# the default value should just be left as is
|
||||
|
||||
for x in xrange(len(result[k])):
|
||||
if override_value is not None and x < len(override_value) and override_value[x] is not None:
|
||||
# we have an override value for this location, so we use it
|
||||
result[k][x] = override_value[x]
|
||||
elif profile_value is not None and x < len(profile_value) and profile_value[x] is not None:
|
||||
# we have a profile value for this location, so we use it
|
||||
result[k][x] = profile_value[x]
|
||||
|
||||
else:
|
||||
# just change the result value to the override_value if available, otherwise to the profile_value if
|
||||
# that is given, else just leave as is
|
||||
if override_value is not None:
|
||||
result[k] = override_value
|
||||
elif profile_value is not None:
|
||||
result[k] = profile_value
|
||||
# just change the result value to the override_value if available, otherwise to the profile_value if
|
||||
# that is given, else just leave as is
|
||||
if override_value is not None:
|
||||
result[k] = override_value
|
||||
elif profile_value is not None:
|
||||
result[k] = profile_value
|
||||
return result
|
||||
|
||||
def __init__(self, profile):
|
||||
|
|
@ -266,175 +253,106 @@ class Profile(object):
|
|||
return default
|
||||
return int(value * 1000)
|
||||
|
||||
def get_gcode_template(self, key):
|
||||
extruder_count = s.globalGetInt(["printerParameters", "numExtruders"])
|
||||
# TODO remove safely
|
||||
# def get_gcode_template(self, key):
|
||||
# extruder_count = s.globalGetInt(["printerParameters", "numExtruders"])
|
||||
#
|
||||
# if key in self.profile:
|
||||
# gcode = self.profile[key]
|
||||
# else:
|
||||
# gcode = defaults[key]
|
||||
#
|
||||
# if key in ("start_gcode", "end_gcode"):
|
||||
# return gcode[extruder_count-1]
|
||||
# else:
|
||||
# return gcode
|
||||
|
||||
# TODO remove safely
|
||||
# def get_machine_extruder_offset(self, extruder, axis):
|
||||
# return 0.0
|
||||
|
||||
# TODO remove safely
|
||||
# def get_profile_string(self):
|
||||
# import base64
|
||||
# import zlib
|
||||
#
|
||||
# import copy
|
||||
# profile = copy.deepcopy(defaults)
|
||||
# profile.update(self.profile)
|
||||
#
|
||||
# result = []
|
||||
# for k, v in profile.items():
|
||||
# if isinstance(v, (str, unicode)):
|
||||
# result.append("{k}={v}".format(k=k, v=v.encode("utf-8")))
|
||||
# else:
|
||||
# result.append("{k}={v}".format(k=k, v=v))
|
||||
#
|
||||
# return base64.b64encode(zlib.compress("\b".join(result), 9))
|
||||
#
|
||||
# TODO remove safely
|
||||
# def replaceTagMatch(self, m):
|
||||
# import time
|
||||
#
|
||||
# pre = m.group(1)
|
||||
# tag = m.group(2)
|
||||
#
|
||||
# if tag == 'time':
|
||||
# return pre + time.strftime('%H:%M:%S')
|
||||
# if tag == 'date':
|
||||
# return pre + time.strftime('%d-%m-%Y')
|
||||
# if tag == 'day':
|
||||
# return pre + ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'][int(time.strftime('%w'))]
|
||||
# if tag == 'profile_string':
|
||||
# return pre + 'svgtogcode_OCTO_PROFILE_STRING:%s' % (self.get_profile_string())
|
||||
#
|
||||
# if pre == 'F' and tag == 'max_z_speed':
|
||||
# f = self.get_float("travel_speed") * 60
|
||||
# elif pre == 'F' and tag in ['print_speed', 'retraction_speed', 'travel_speed', 'bottom_layer_speed', 'cool_min_feedrate']:
|
||||
# f = self.get_float(tag) * 60
|
||||
# elif self.get(tag):
|
||||
# f = self.get(tag)
|
||||
# else:
|
||||
# return '%s?%s?' % (pre, tag)
|
||||
#
|
||||
# if (f % 1) == 0:
|
||||
# return pre + str(int(f))
|
||||
#
|
||||
# return pre + str(f)
|
||||
#
|
||||
|
||||
if key in self.profile:
|
||||
gcode = self.profile[key]
|
||||
else:
|
||||
gcode = defaults[key]
|
||||
# TODO remove safely
|
||||
# def get_gcode(self, key):
|
||||
# if key == "start_gcode":
|
||||
# return ""
|
||||
# else:
|
||||
# return ""
|
||||
|
||||
if key in ("start_gcode", "end_gcode"):
|
||||
return gcode[extruder_count-1]
|
||||
else:
|
||||
return gcode
|
||||
# def calculate_edge_width_and_line_count(self):
|
||||
# wall_thickness = self.get_float("wall_thickness")
|
||||
# return wall_thickness, 1
|
||||
|
||||
def get_machine_extruder_offset(self, extruder, axis):
|
||||
extruder_offsets = s.globalGet(["printerParameters", "extruderOffsets"])
|
||||
if extruder >= len(extruder_offsets):
|
||||
return 0.0
|
||||
if axis.lower() not in ("x", "y"):
|
||||
return 0.0
|
||||
return extruder_offsets[extruder][axis.lower()]
|
||||
# TODO remove safely
|
||||
# def calculate_solid_layer_count(self):
|
||||
# return 1
|
||||
|
||||
def get_profile_string(self):
|
||||
import base64
|
||||
import zlib
|
||||
|
||||
import copy
|
||||
profile = copy.deepcopy(defaults)
|
||||
profile.update(self.profile)
|
||||
for key in ("print_temperature", "print_temperature2", "print_temperature3", "print_temperature4",
|
||||
"filament_diameter", "filament_diameter2", "filament_diameter3", "filament_diameter4"):
|
||||
profile[key] = self.get(key)
|
||||
|
||||
result = []
|
||||
for k, v in profile.items():
|
||||
if isinstance(v, (str, unicode)):
|
||||
result.append("{k}={v}".format(k=k, v=v.encode("utf-8")))
|
||||
else:
|
||||
result.append("{k}={v}".format(k=k, v=v))
|
||||
|
||||
return base64.b64encode(zlib.compress("\b".join(result), 9))
|
||||
|
||||
def replaceTagMatch(self, m):
|
||||
import time
|
||||
|
||||
pre = m.group(1)
|
||||
tag = m.group(2)
|
||||
|
||||
if tag == 'time':
|
||||
return pre + time.strftime('%H:%M:%S')
|
||||
if tag == 'date':
|
||||
return pre + time.strftime('%d-%m-%Y')
|
||||
if tag == 'day':
|
||||
return pre + ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'][int(time.strftime('%w'))]
|
||||
if tag == 'profile_string':
|
||||
return pre + 'svgtogcode_OCTO_PROFILE_STRING:%s' % (self.get_profile_string())
|
||||
|
||||
if pre == 'F' and tag == 'max_z_speed':
|
||||
f = self.get_float("travel_speed") * 60
|
||||
elif pre == 'F' and tag in ['print_speed', 'retraction_speed', 'travel_speed', 'bottom_layer_speed', 'cool_min_feedrate']:
|
||||
f = self.get_float(tag) * 60
|
||||
elif self.get(tag):
|
||||
f = self.get(tag)
|
||||
else:
|
||||
return '%s?%s?' % (pre, tag)
|
||||
|
||||
if (f % 1) == 0:
|
||||
return pre + str(int(f))
|
||||
|
||||
return pre + str(f)
|
||||
|
||||
def get_gcode(self, key):
|
||||
extruder_count = s.globalGetInt(["printerParameters", "numExtruders"])
|
||||
|
||||
prefix = ""
|
||||
postfix = ""
|
||||
|
||||
if self.get("gcode_flavor") == GcodeFlavors.ULTIGCODE:
|
||||
if key == "end_gcode":
|
||||
return "M25 ;Stop reading from this point on.\n;svgtogcode_PROFILE_STRING:%s\n" % (self.get_profile_string())
|
||||
return ""
|
||||
|
||||
if key == "start_gcode":
|
||||
contents = self.get_gcode_template("start_gcode")
|
||||
|
||||
e_steps = self.get_float("steps_per_e")
|
||||
if e_steps > 0:
|
||||
prefix += "M92 E{e_steps}\n" % (e_steps)
|
||||
temp = self.get_float("print_temperature")
|
||||
|
||||
bedTemp = 0
|
||||
if self.get_boolean("has_heated_bed"):
|
||||
bedTemp = self.get_float("print_bed_temperature")
|
||||
include_bed_temps = bedTemp > 0 and not "{print_bed_temperature}" in Profile.regex_strip_comments.sub("", contents)
|
||||
|
||||
if include_bed_temps:
|
||||
prefix += "M140 S{print_bed_temperature}\n"
|
||||
|
||||
if temp > 0 and not "{print_temperature}" in Profile.regex_strip_comments.sub("", contents):
|
||||
if extruder_count > 0:
|
||||
def temp_line(temp, extruder, template):
|
||||
t = temp
|
||||
if extruder > 0:
|
||||
print_temp = self.get_float("print_temperature%d" % (extruder + 1))
|
||||
if print_temp > 0:
|
||||
t = print_temp
|
||||
return template.format(extruder=extruder, temp=t)
|
||||
for n in xrange(1, extruder_count):
|
||||
prefix += temp_line(temp, n, "M104 T{extruder} S{temp}\n")
|
||||
for n in xrange(0, extruder_count):
|
||||
prefix += temp_line(temp, n, "M109 T{extruder} S{temp}\n")
|
||||
prefix += "T0\n"
|
||||
else:
|
||||
prefix += "M109 S{temp}\n".format(temp=temp)
|
||||
|
||||
if include_bed_temps:
|
||||
prefix += "M190 S{print_bed_temperature}\n".format(bedTemp=bedTemp)
|
||||
|
||||
else:
|
||||
contents = self.get_gcode_template(key)
|
||||
|
||||
return unicode(prefix + re.sub("(.)\{([^\}]*)\}", self.replaceTagMatch, contents).rstrip() + '\n' + postfix).strip().encode('utf-8') + '\n'
|
||||
|
||||
def calculate_edge_width_and_line_count(self):
|
||||
wall_thickness = self.get_float("wall_thickness")
|
||||
nozzle_size = self.get_float("nozzle_size")
|
||||
|
||||
if self.get_boolean("spiralize") or self.get_boolean("follow_surface"):
|
||||
return wall_thickness, 1
|
||||
if wall_thickness < 0.01:
|
||||
return nozzle_size, 0
|
||||
if wall_thickness < nozzle_size:
|
||||
return wall_thickness, 1
|
||||
|
||||
edge_width = None
|
||||
line_count = int(wall_thickness / (nozzle_size - 0.0001))
|
||||
if line_count < 1:
|
||||
edge_width = nozzle_size
|
||||
line_count = 1
|
||||
line_width = wall_thickness / line_count
|
||||
line_width_alt = wall_thickness / (line_count + 1)
|
||||
if line_width > nozzle_size * 1.5:
|
||||
return line_width_alt, line_count + 1
|
||||
if not edge_width:
|
||||
edge_width = line_width
|
||||
return edge_width, line_count
|
||||
|
||||
def calculate_solid_layer_count(self):
|
||||
layer_height = self.get_float("layer_height")
|
||||
solid_thickness = self.get_float("solid_layer_thickness")
|
||||
if layer_height == 0.0:
|
||||
return 1
|
||||
import math
|
||||
return int(math.ceil(solid_thickness / (layer_height - 0.0001)))
|
||||
|
||||
def calculate_minimal_extruder_count(self):
|
||||
extruder_count = s.globalGetInt(["printerParameters", "numExtruders"])
|
||||
if extruder_count < 2:
|
||||
return 1
|
||||
if self.get("support") == SupportLocationTypes.NONE:
|
||||
return 1
|
||||
if self.get("support_dual_extrusion") == SupportDualTypes.SECOND:
|
||||
return 2
|
||||
return 1
|
||||
# TODO remove safely
|
||||
# def calculate_minimal_extruder_count(self):
|
||||
# return 1
|
||||
|
||||
def convert_to_engine(self):
|
||||
|
||||
settings = {
|
||||
"--engraving-laser-speed": self.get_int("speed"),
|
||||
"--laser-intensity": self.get_int("intensity")
|
||||
"--laser-intensity": self.get_int("intensity"),
|
||||
"--beam-diameter" : self.get_float("beam_diameter"),
|
||||
"--img-intensity-white" : self.get_int("intensity_white"),
|
||||
"--img-intensity-black" : self.get_int("intensity_black"),
|
||||
"--img-speed-white" : self.get_int("feedrate_white"),
|
||||
"--img-speed-black" : self.get_int("feedrate_black"),
|
||||
"--pierce-time" : self.get_float("pierce_time"),
|
||||
"--contrast": self.get_float("contrast"),
|
||||
"--sharpening": self.get_float("sharpening"),
|
||||
"--dither": self.get_boolean("dither")
|
||||
}
|
||||
|
||||
return settings
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ $(function(){
|
|||
|
||||
// TODO check if still in use
|
||||
self.show = function(target, file) {
|
||||
alert('still in use (line52, convert.js)');
|
||||
self.target = target;
|
||||
self.file = file;
|
||||
self.title(_.sprintf(gettext("Converting %(filename)s"), {filename: self.file}));
|
||||
|
|
@ -224,6 +225,14 @@ $(function(){
|
|||
command: "convert",
|
||||
"profile.speed": self.laserSpeed(),
|
||||
"profile.intensity": self.laserIntensity(),
|
||||
"profile.pierce_time": self.pierceTime(),
|
||||
"profile.intensity_black" : self.imgIntensityBlack(),
|
||||
"profile.intensity_white" : self.imgIntensityWhite(),
|
||||
"profile.feedrate_black" : self.imgFeedrateBlack(),
|
||||
"profile.feedrate_white" : self.imgFeedrateWhite(),
|
||||
"profile.img_contrast" : self.imgContrast(),
|
||||
"profile.img_sharpening" : self.imgSharpening(),
|
||||
"profile.img_dithering" : self.imgDithering(),
|
||||
slicer: "svgtogcode",
|
||||
gcode: gcodeFilename
|
||||
};
|
||||
|
|
@ -249,8 +258,6 @@ $(function(){
|
|||
|
||||
self.gcodeFilename(undefined);
|
||||
self.svg = undefined;
|
||||
//self.slicer(self.defaultSlicer);
|
||||
//self.profile(self.defaultProfile);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -553,6 +553,7 @@ class SlicingManager(object):
|
|||
return self.get_slicer(slicer, require_configured=require_configured).get_slicer_profile(path)
|
||||
|
||||
def _save_profile_to_path(self, slicer, path, profile, allow_overwrite=True, overrides=None, require_configured=False):
|
||||
print('_save_profile_to_path', overrides)
|
||||
self.get_slicer(slicer, require_configured=require_configured).save_slicer_profile(path, profile, allow_overwrite=allow_overwrite, overrides=overrides)
|
||||
|
||||
def _get_default_profile(self, slicer):
|
||||
|
|
|
|||
|
|
@ -51,6 +51,16 @@ $(function() {
|
|||
//~~ Initialize PNotify
|
||||
|
||||
PNotify.prototype.options.styling = "bootstrap2";
|
||||
PNotify.prototype.options.delay = 3000;
|
||||
PNotify.prototype.options.animate_speed = "fast";
|
||||
PNotify.prototype.options.animation = {
|
||||
effect_in: "fade",
|
||||
options_in: { easing: 'easeInExpo'},
|
||||
effect_out: "fade",
|
||||
options_out: { easing: 'easeInExpo'}
|
||||
};
|
||||
PNotify.prototype.options.buttons.sticker = false;
|
||||
PNotify.prototype.options.cornerclass = 'ui-pnotify-sharp';
|
||||
|
||||
//~~ Initialize view models
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue