improvements when just starting a single gcode file.

This commit is contained in:
Teja 2015-02-02 11:27:26 +01:00
parent ccee370d4f
commit bccd87f6dc
4 changed files with 53 additions and 52 deletions

View file

@ -184,44 +184,48 @@ $(function(){
};
self.convert = function() {
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;
if(self.gcodeFilesToAppend.length === 1 && self.svg === undefined){
self.files.startGcodeWithSafetyWarning(self.gcodeFilesToAppend[0]);
} 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) {

View file

@ -15,13 +15,13 @@ $(function(){
self.command = ko.observable(undefined);
self.isErrorOrClosed = ko.observable(undefined);
self.isOperational = ko.observable(undefined);
self.isPrinting = ko.observable(undefined);
self.isPaused = ko.observable(undefined);
self.isError = ko.observable(undefined);
self.isReady = ko.observable(undefined);
self.isLoading = ko.observable(undefined);
// self.isErrorOrClosed = ko.observable(undefined);
// self.isOperational = ko.observable(undefined);
// self.isPrinting = ko.observable(undefined);
// self.isPaused = ko.observable(undefined);
// self.isError = ko.observable(undefined);
// self.isReady = ko.observable(undefined);
// self.isLoading = ko.observable(undefined);
self.availableHeight = ko.observable(undefined);
self.availableWidth = ko.observable(undefined);
@ -151,7 +151,6 @@ $(function(){
};
self.placeGcode = function(file){
console.log(file);
var previewId = self.getEntryId(file);
if(snap.select('#'+previewId)){
@ -242,7 +241,6 @@ $(function(){
};
self.removeSVG = function(file){
console.log("removeSVG", file.previewId, self.placedDesigns.indexOf(file));
snap.select('#'+file.previewId).remove();
self.placedDesigns.remove(file);
// TODO debug why remove always clears all items of this type.
@ -265,7 +263,6 @@ $(function(){
};
self.templateFor = function(data) {
console.log("data", data);
var extension = data.name.split('.').pop().toLowerCase();
if (extension === "svg") {
return "wa_template_" + data.type + "_svg";
@ -372,7 +369,6 @@ $(function(){
stroke: stroke_color,
strokeWidth: 1
});
console.log("target", target);
snap.select(target).append(p);
};
self.clear_gcode = function(){

View file

@ -270,9 +270,9 @@
<tspan
x="368.571426" y="712.36218" id="tspan2991"
style="text-anchor:middle;text-align:center" /></text>
<g id="userContent"></g>
<g id="placedGcodes" data-bind="attr: { transform: scaleMatrixMMtoDisplay() }"></g>
<g id="gCodePreview" data-bind="attr: { transform: scaleMatrixMMtoDisplay() }"></g>
<g id="userContent" data-bind="visible: !state.isPrinting() && !state.isPaused()"></g>
<g id="placedGcodes" data-bind="visible: !state.isPrinting() && !state.isPaused(), attr: { transform: scaleMatrixMMtoDisplay() }"></g>
<g id="gCodePreview" data-bind="visible: state.isPrinting() || state.isPaused(), attr: { transform: scaleMatrixMMtoDisplay() }"></g>
</g>
</svg>

View file

@ -476,8 +476,9 @@ def gcodeConvertCommand():
i = 1;
while(fileManager.file_exists(target, gcode_name)):
name, ext = os.path.splitext(filename)
gcode_name = name+'.'+str(i)+'.'+ext
name, ext = os.path.splitext(gcode_name)
gcode_name = name+'.'+str(i)+ext
i += 1
# prohibit overwriting the file that is currently being printed
currentOrigin, currentFilename = _getCurrentFile()