improvements when just starting a single gcode file.
This commit is contained in:
parent
ccee370d4f
commit
bccd87f6dc
4 changed files with 53 additions and 52 deletions
|
|
@ -184,44 +184,48 @@ $(function(){
|
||||||
};
|
};
|
||||||
|
|
||||||
self.convert = function() {
|
self.convert = function() {
|
||||||
var gcodeFilename = self._sanitize(self.gcodeFilename());
|
if(self.gcodeFilesToAppend.length === 1 && self.svg === undefined){
|
||||||
if (!_.endsWith(gcodeFilename.toLowerCase(), ".gco")
|
self.files.startGcodeWithSafetyWarning(self.gcodeFilesToAppend[0]);
|
||||||
&& !_.endsWith(gcodeFilename.toLowerCase(), ".gcode")
|
|
||||||
&& !_.endsWith(gcodeFilename.toLowerCase(), ".g")) {
|
|
||||||
gcodeFilename = gcodeFilename + ".gco";
|
|
||||||
}
|
|
||||||
|
|
||||||
var data = {
|
|
||||||
command: "convert",
|
|
||||||
"profile.speed": self.laserSpeed(),
|
|
||||||
"profile.intensity": self.laserIntensity(),
|
|
||||||
slicer: "svgtogcode",
|
|
||||||
gcode: gcodeFilename
|
|
||||||
};
|
|
||||||
|
|
||||||
if(self.svg !== undefined){
|
|
||||||
data.svg = self.svg;
|
|
||||||
} else {
|
} else {
|
||||||
data.svg = '<svg height="0" version="1.1" width="0" xmlns="http://www.w3.org/2000/svg"><defs/></svg>';
|
var gcodeFilename = self._sanitize(self.gcodeFilename());
|
||||||
|
if (!_.endsWith(gcodeFilename.toLowerCase(), ".gco")
|
||||||
|
&& !_.endsWith(gcodeFilename.toLowerCase(), ".gcode")
|
||||||
|
&& !_.endsWith(gcodeFilename.toLowerCase(), ".g")) {
|
||||||
|
gcodeFilename = gcodeFilename + ".gco";
|
||||||
|
}
|
||||||
|
|
||||||
|
var data = {
|
||||||
|
command: "convert",
|
||||||
|
"profile.speed": self.laserSpeed(),
|
||||||
|
"profile.intensity": self.laserIntensity(),
|
||||||
|
slicer: "svgtogcode",
|
||||||
|
gcode: gcodeFilename
|
||||||
|
};
|
||||||
|
|
||||||
|
if(self.svg !== undefined){
|
||||||
|
data.svg = self.svg;
|
||||||
|
} else {
|
||||||
|
data.svg = '<svg height="0" version="1.1" width="0" xmlns="http://www.w3.org/2000/svg"><defs/></svg>';
|
||||||
|
}
|
||||||
|
if(self.gcodeFilesToAppend !== undefined){
|
||||||
|
data.gcodeFilesToAppend = self.gcodeFilesToAppend;
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: API_BASEURL + "files/convert",
|
||||||
|
type: "POST",
|
||||||
|
dataType: "json",
|
||||||
|
contentType: "application/json; charset=UTF-8",
|
||||||
|
data: JSON.stringify(data)
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#dialog_vector_graphics_conversion").modal("hide");
|
||||||
|
|
||||||
|
self.gcodeFilename(undefined);
|
||||||
|
self.svg = undefined;
|
||||||
|
//self.slicer(self.defaultSlicer);
|
||||||
|
//self.profile(self.defaultProfile);
|
||||||
}
|
}
|
||||||
if(self.gcodeFilesToAppend !== undefined){
|
|
||||||
data.gcodeFilesToAppend = self.gcodeFilesToAppend;
|
|
||||||
}
|
|
||||||
|
|
||||||
$.ajax({
|
|
||||||
url: API_BASEURL + "files/convert",
|
|
||||||
type: "POST",
|
|
||||||
dataType: "json",
|
|
||||||
contentType: "application/json; charset=UTF-8",
|
|
||||||
data: JSON.stringify(data)
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#dialog_vector_graphics_conversion").modal("hide");
|
|
||||||
|
|
||||||
self.gcodeFilename(undefined);
|
|
||||||
self.svg = undefined;
|
|
||||||
//self.slicer(self.defaultSlicer);
|
|
||||||
//self.profile(self.defaultProfile);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
self._sanitize = function(name) {
|
self._sanitize = function(name) {
|
||||||
|
|
|
||||||
|
|
@ -15,13 +15,13 @@ $(function(){
|
||||||
|
|
||||||
self.command = ko.observable(undefined);
|
self.command = ko.observable(undefined);
|
||||||
|
|
||||||
self.isErrorOrClosed = ko.observable(undefined);
|
// self.isErrorOrClosed = ko.observable(undefined);
|
||||||
self.isOperational = ko.observable(undefined);
|
// self.isOperational = ko.observable(undefined);
|
||||||
self.isPrinting = ko.observable(undefined);
|
// self.isPrinting = ko.observable(undefined);
|
||||||
self.isPaused = ko.observable(undefined);
|
// self.isPaused = ko.observable(undefined);
|
||||||
self.isError = ko.observable(undefined);
|
// self.isError = ko.observable(undefined);
|
||||||
self.isReady = ko.observable(undefined);
|
// self.isReady = ko.observable(undefined);
|
||||||
self.isLoading = ko.observable(undefined);
|
// self.isLoading = ko.observable(undefined);
|
||||||
|
|
||||||
self.availableHeight = ko.observable(undefined);
|
self.availableHeight = ko.observable(undefined);
|
||||||
self.availableWidth = ko.observable(undefined);
|
self.availableWidth = ko.observable(undefined);
|
||||||
|
|
@ -151,7 +151,6 @@ $(function(){
|
||||||
};
|
};
|
||||||
|
|
||||||
self.placeGcode = function(file){
|
self.placeGcode = function(file){
|
||||||
console.log(file);
|
|
||||||
var previewId = self.getEntryId(file);
|
var previewId = self.getEntryId(file);
|
||||||
|
|
||||||
if(snap.select('#'+previewId)){
|
if(snap.select('#'+previewId)){
|
||||||
|
|
@ -242,7 +241,6 @@ $(function(){
|
||||||
};
|
};
|
||||||
|
|
||||||
self.removeSVG = function(file){
|
self.removeSVG = function(file){
|
||||||
console.log("removeSVG", file.previewId, self.placedDesigns.indexOf(file));
|
|
||||||
snap.select('#'+file.previewId).remove();
|
snap.select('#'+file.previewId).remove();
|
||||||
self.placedDesigns.remove(file);
|
self.placedDesigns.remove(file);
|
||||||
// TODO debug why remove always clears all items of this type.
|
// TODO debug why remove always clears all items of this type.
|
||||||
|
|
@ -265,7 +263,6 @@ $(function(){
|
||||||
};
|
};
|
||||||
|
|
||||||
self.templateFor = function(data) {
|
self.templateFor = function(data) {
|
||||||
console.log("data", data);
|
|
||||||
var extension = data.name.split('.').pop().toLowerCase();
|
var extension = data.name.split('.').pop().toLowerCase();
|
||||||
if (extension === "svg") {
|
if (extension === "svg") {
|
||||||
return "wa_template_" + data.type + "_svg";
|
return "wa_template_" + data.type + "_svg";
|
||||||
|
|
@ -372,7 +369,6 @@ $(function(){
|
||||||
stroke: stroke_color,
|
stroke: stroke_color,
|
||||||
strokeWidth: 1
|
strokeWidth: 1
|
||||||
});
|
});
|
||||||
console.log("target", target);
|
|
||||||
snap.select(target).append(p);
|
snap.select(target).append(p);
|
||||||
};
|
};
|
||||||
self.clear_gcode = function(){
|
self.clear_gcode = function(){
|
||||||
|
|
|
||||||
|
|
@ -270,9 +270,9 @@
|
||||||
<tspan
|
<tspan
|
||||||
x="368.571426" y="712.36218" id="tspan2991"
|
x="368.571426" y="712.36218" id="tspan2991"
|
||||||
style="text-anchor:middle;text-align:center" /></text>
|
style="text-anchor:middle;text-align:center" /></text>
|
||||||
<g id="userContent"></g>
|
<g id="userContent" data-bind="visible: !state.isPrinting() && !state.isPaused()"></g>
|
||||||
<g id="placedGcodes" data-bind="attr: { transform: scaleMatrixMMtoDisplay() }"></g>
|
<g id="placedGcodes" data-bind="visible: !state.isPrinting() && !state.isPaused(), attr: { transform: scaleMatrixMMtoDisplay() }"></g>
|
||||||
<g id="gCodePreview" data-bind="attr: { transform: scaleMatrixMMtoDisplay() }"></g>
|
<g id="gCodePreview" data-bind="visible: state.isPrinting() || state.isPaused(), attr: { transform: scaleMatrixMMtoDisplay() }"></g>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -476,8 +476,9 @@ def gcodeConvertCommand():
|
||||||
|
|
||||||
i = 1;
|
i = 1;
|
||||||
while(fileManager.file_exists(target, gcode_name)):
|
while(fileManager.file_exists(target, gcode_name)):
|
||||||
name, ext = os.path.splitext(filename)
|
name, ext = os.path.splitext(gcode_name)
|
||||||
gcode_name = name+'.'+str(i)+'.'+ext
|
gcode_name = name+'.'+str(i)+ext
|
||||||
|
i += 1
|
||||||
|
|
||||||
# prohibit overwriting the file that is currently being printed
|
# prohibit overwriting the file that is currently being printed
|
||||||
currentOrigin, currentFilename = _getCurrentFile()
|
currentOrigin, currentFilename = _getCurrentFile()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue