workaround for corrupt metadata file. bugfixes in the gcode preview
This commit is contained in:
parent
8bc350fa8e
commit
369a59e24a
5 changed files with 28 additions and 31 deletions
|
|
@ -28,11 +28,9 @@ $(function(){
|
|||
self.workingAreaWidthMM = ko.observable(undefined);
|
||||
self.workingAreaHeightMM = ko.observable(undefined);
|
||||
self.hwRatio = ko.computed(function(){
|
||||
// y/x = 297/216 respectively 594/432
|
||||
// y/x = 297/216 junior, respectively 594/432 senior
|
||||
var w = self.workingAreaWidthMM();
|
||||
var h = self.workingAreaHeightMM();
|
||||
// var h = self.settings.printerProfiles.currentProfileData().volume.depth();
|
||||
// var w = self.settings.printerProfiles.currentProfileData().volume.width();
|
||||
var ratio = h / w;
|
||||
return ratio;
|
||||
}, self);
|
||||
|
|
@ -84,9 +82,10 @@ $(function(){
|
|||
// matrix scales svg units to display_pixels
|
||||
self.scaleMatrixMMtoDisplay = ko.computed(function(){
|
||||
var m = new Snap.Matrix();
|
||||
var factor = self.svgDPI()/25.4 ;
|
||||
var factor = self.svgDPI()/25.4; // scale mm to 90dpi pixels
|
||||
var yShift = self.workingAreaHeightMM(); // 0,0 origin of the gcode is bottom left. (top left in the svg)
|
||||
if(!isNaN(factor)){
|
||||
m.scale(factor);
|
||||
m.scale(factor).translate(0,yShift);
|
||||
return m;
|
||||
}
|
||||
return m;
|
||||
|
|
@ -234,8 +233,11 @@ $(function(){
|
|||
|
||||
self.getCompositionSVG = function(){
|
||||
var dpiFactor = self.svgDPI()/25.4; // convert mm to pix 90dpi for inkscape, 72 for illustrator
|
||||
var w = dpiFactor * self.settings.printerProfiles.currentProfileData().volume.width;
|
||||
var h = dpiFactor * self.settings.printerProfiles.currentProfileData().volume.depth;
|
||||
var w = dpiFactor * self.workingAreaWidthMM();
|
||||
var h = dpiFactor * self.workingAreaHeightMM();
|
||||
// var w = dpiFactor * self.settings.printerProfiles.currentProfileData().volume.width;
|
||||
// var h = dpiFactor * self.settings.printerProfiles.currentProfileData().volume.depth;
|
||||
// var yTranslation = "translate(0, "+h+")";
|
||||
|
||||
var tmpsvg = snap.select("#userContent").innerSVG(); // get working area
|
||||
var svg = '<svg height="'+ h +'" version="1.1" width="'+ w +'" xmlns="http://www.w3.org/2000/svg"><defs/>'+ tmpsvg +'</svg>';
|
||||
|
|
@ -243,6 +245,7 @@ $(function(){
|
|||
};
|
||||
|
||||
self.draw_gcode = function(points, intensity){
|
||||
console.log("draw_gcode", points);
|
||||
var stroke_color = intensity === 0 ? '#BBBBBB' : '#FF0000';
|
||||
var d = 'M'+points.join(' ');
|
||||
var p = snap.path(d).attr({
|
||||
|
|
@ -252,6 +255,9 @@ $(function(){
|
|||
});
|
||||
snap.select('#gCodePreview').append(p);
|
||||
};
|
||||
self.clear_gcode = function(){
|
||||
snap.select('#gCodePreview>*').remove();
|
||||
};
|
||||
|
||||
self.onStartup = function(){
|
||||
GCODE.workingArea = self; // Temporary hack to use the gcode parser from the gCodeViewer
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
<ul class="nav nav-pills">
|
||||
<li class="active"><a href="#workingarea" data-toggle="tab">working area</a></li>
|
||||
<!--<li><a href="#designlib" data-toggle="tab">design library</a></li>-->
|
||||
<li><a href="#gcode" data-toggle="tab">gcode</a></li>
|
||||
<!--<li><a href="#gcode" data-toggle="tab">gcode</a></li>-->
|
||||
<li><a href="#focus" data-toggle="tab">focus</a></li>
|
||||
<li><a href="#term" data-toggle="tab">terminal</a></li>
|
||||
<li xstyle="display: none;" xdata-bind="visible: loginState.isAdmin">
|
||||
|
|
@ -166,25 +166,14 @@
|
|||
|
||||
{{ _('File') }}: <strong data-bind="text: filename"></strong> <strong data-bind="visible: sd">(SD)</strong><br>
|
||||
<!-- {{ _('Timelapse') }}: <strong data-bind="text: timelapseString"></strong><br>-->
|
||||
<!-- ko foreach: filament -->
|
||||
<!--<span data-bind="text: 'Filament (' + name() + '): '"></span><strong data-bind="text: formatFilament(data())"></strong><br>-->
|
||||
<!-- /ko -->
|
||||
{{ _('Approx. Total Job Time') }}: <strong data-bind="text: estimatedPrintTimeString"></strong><br>
|
||||
<div class="progress" data-bind="visible: isPrinting()">
|
||||
<div class="bar" id="job_progressBar" data-bind="style: { width: progressString() + '%' }">{{ _('Processed') }} : <strong data-bind="text: byteString"></strong></div>
|
||||
</div>
|
||||
<!-- {{ _('Print Time') }}: <strong data-bind="text: printTimeString"></strong><br>
|
||||
{{ _('Print Time Left') }}: <strong data-bind="text: printTimeLeftString"></strong><br>-->
|
||||
{{ _('Processed') }}: <strong data-bind="text: byteString"></strong><br>
|
||||
|
||||
|
||||
<div class="progress">
|
||||
<div class="bar" id="job_progressBar" data-bind="style: { width: progressString() + '%' }"></div>
|
||||
</div>
|
||||
|
||||
<!-- <div class="row-fluid print-control" style="display: none;" data-bind="visible: loginState.isUser">
|
||||
<button class="btn btn-danger span4" data-bind="click: print_with_safety_glasses_warning, enable: isOperational() && isReady() && !isPrinting() && loginState.isUser(), attr: {title: titlePrintButton}" id="job_print">
|
||||
<i class="icon-white" data-bind="css: {'icon-fire': !isPaused(), 'icon-undo': isPaused(), 'wobble': isPrinting()}"></i> <span data-bind="text: (isPaused() ? '{{ _('Restart') }}' : '{{ _('Laser') }}')">{{ _('Laser') }}</span>
|
||||
</button>
|
||||
<button class="btn span4" id="job_pause" data-bind="click: pause, enable: isOperational() && (isPrinting() || isPaused()) && loginState.isUser(), css: {active: isPaused()}, attr: {title: titlePauseButton}"><i data-bind="css: {'icon-pause': !isPaused(), 'icon-play': isPaused()}"></i> <span data-bind="visible: !isPaused()">{{ _('Pause') }}</span><span data-bind="visible: isPaused()">{{ _('Resume') }}</span></button>
|
||||
<button class="btn span4" id="job_cancel" data-bind="click: cancel, enable: isOperational() && (isPrinting() || isPaused()) && loginState.isUser()" title="{{ _('Cancels the job') }}"><i class="icon-stop"></i> {{ _('Cancel') }}</button>
|
||||
</div>-->
|
||||
<div class="row-fluid print-control" style="display: none;" data-bind="visible: loginState.isUser">
|
||||
<button class="btn btn-danger span4" data-bind="click: conversion.show_conversion_dialog, enable: isOperational() && isReady() && !isPrinting() && loginState.isUser(), attr: {title: titlePrintButton}" id="job_print">
|
||||
<i class="icon-white" data-bind="css: {'icon-fire': !isPaused(), 'icon-undo': isPaused(), 'wobble': isPrinting()}"></i> <span data-bind="text: (isPaused() ? '{{ _('Restart') }}' : '{{ _('Laser') }}')">{{ _('Laser') }}</span>
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ GCODE.renderer = (function(){
|
|||
var p1 = ctx.transformedPoint(0,0);
|
||||
var p2 = ctx.transformedPoint(canvas.width,canvas.height);
|
||||
ctx.clearRect(p1.x,p1.y,p2.x-p1.x,p2.y-p1.y);
|
||||
GCODE.workingArea.clear_gcode();
|
||||
drawGrid();
|
||||
if(renderOptions['showNextLayer'] && layerNumStore < model.length - 1) {
|
||||
drawLayer(layerNumStore + 1, 0, GCODE.renderer.getLayerNumSegments(layerNumStore + 1), true);
|
||||
|
|
@ -402,11 +403,9 @@ var drawLayer = function(layerNum, fromProgress, toProgress, isNotCurrentLayer){
|
|||
y = -cmds[i].y;
|
||||
}
|
||||
|
||||
console.log("cmd", cmds[i]);
|
||||
if(lastLaser !== cmds[i].laser){
|
||||
|
||||
GCODE.workingArea.draw_gcode(points, lastLaser);
|
||||
console.log("points", points, lastLaser, cmds[i].laser);
|
||||
points = [[prevX,prevY]];
|
||||
lastLaser = cmds[i].laser;
|
||||
}
|
||||
|
|
@ -418,7 +417,6 @@ var drawLayer = function(layerNum, fromProgress, toProgress, isNotCurrentLayer){
|
|||
prevY = y ;
|
||||
}
|
||||
GCODE.workingArea.draw_gcode(points, lastLaser);
|
||||
console.log("final", points, lastLaser);
|
||||
|
||||
}
|
||||
};
|
||||
|
|
@ -716,6 +714,7 @@ var drawLayer = function(layerNum, fromProgress, toProgress, isNotCurrentLayer){
|
|||
var p1 = ctx.transformedPoint(0, 0);
|
||||
var p2 = ctx.transformedPoint(canvas.width, canvas.height);
|
||||
ctx.clearRect(p1.x, p1.y, p2.x - p1.x, p2.y - p1.y);
|
||||
GCODE.workingArea.clear_gcode();
|
||||
drawGrid();
|
||||
if (model && model.length) {
|
||||
if (layerNum < model.length) {
|
||||
|
|
@ -792,5 +791,5 @@ var drawLayer = function(layerNum, fromProgress, toProgress, isNotCurrentLayer){
|
|||
return '-1';
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
}());
|
||||
|
|
|
|||
|
|
@ -125,10 +125,12 @@ function GcodeFilesViewModel(printerStateViewModel, loginStateViewModel, slicing
|
|||
method: "GET",
|
||||
dataType: "json",
|
||||
success: function(response) {
|
||||
|
||||
self.fromResponse(response, filenameToFocus, locationToFocus);
|
||||
self._otherRequestInProgress = false;
|
||||
},
|
||||
error: function() {
|
||||
error: function(response) {
|
||||
console.error("ajax/json error", response);
|
||||
self._otherRequestInProgress = false;
|
||||
}
|
||||
});
|
||||
|
|
@ -162,7 +164,6 @@ function GcodeFilesViewModel(printerStateViewModel, loginStateViewModel, slicing
|
|||
};
|
||||
|
||||
self.loadFile = function(file, printAfterLoad) {
|
||||
console.log("files loadFile", file);
|
||||
if (!file || !file.refs || !file.refs.hasOwnProperty("resource")) return;
|
||||
|
||||
$.ajax({
|
||||
|
|
@ -175,7 +176,6 @@ function GcodeFilesViewModel(printerStateViewModel, loginStateViewModel, slicing
|
|||
};
|
||||
|
||||
self.startGcodeWithSafetyWarning = function(gcodeFile){
|
||||
console.log("files.js startGcodeWithSafetyWarning", gcodeFile, BASEURL + "downloads/files/local/" + gcodeFile.name);
|
||||
self.loadFile(gcodeFile, false);
|
||||
|
||||
self.printerState.show_safety_glasses_warning(function(){
|
||||
|
|
|
|||
|
|
@ -242,7 +242,10 @@ class gcode(object):
|
|||
for i in range(len(maxExtrusion)):
|
||||
radius = self._filamentDiameter / 2
|
||||
self.extrusionVolume[i] = (self.extrusionAmount[i] * (math.pi * radius * radius)) / 1000
|
||||
self.totalMoveTimeMinute = totalMoveTimeMinute
|
||||
if(math.isnan(totalMoveTimeMinute)):
|
||||
self.totalMoveTimeMinute = totalMoveTimeMinute
|
||||
else:
|
||||
self.totalMoveTimeMinute = 0
|
||||
|
||||
def _parseCuraProfileString(self, comment, prefix):
|
||||
return {key: value for (key, value) in map(lambda x: x.split("=", 1), zlib.decompress(base64.b64decode(comment[len(prefix):])).split("\b"))}
|
||||
|
|
|
|||
Loading…
Reference in a new issue