Skip to content

Commit

Permalink
Better extruder/nozzle offset editing in the printer profiles
Browse files Browse the repository at this point in the history
If only one tool is configured, the profile dialog now won't show the offset configuration. If more than one extruder is configured offset configuration for anything but the first tool (which acts as reference for the relative offsets of the others) will be shown.

Closes #677
  • Loading branch information
foosel committed May 5, 2015
1 parent 2d14625 commit 2ef3930
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@
and [#852](https://github.com/foosel/OctoPrint/pull/852)). Printer profiles now contain a new settings ``volume.origin``
which can either be ``lowerleft`` or ``center``. For circular beds only ``center`` is supported.
* Made baudrate detection a bit more solid, still can't perform wonders.
* Only show configuration options for additional extruders if more than one is available, and don't include offset
configuration for first nozzle which acts as reference for the other offsets ([#677](https://github.com/foosel/OctoPrint/issues/677)).

### Bug Fixes

Expand Down
2 changes: 1 addition & 1 deletion src/octoprint/static/css/octoprint.css

Large diffs are not rendered by default.

26 changes: 17 additions & 9 deletions src/octoprint/static/js/app/viewmodels/printerprofiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,18 @@ $(function() {
numExtruders = 1;
}

if (numExtruders > extruderOffsets.length) {
if (numExtruders - 1 > extruderOffsets.length) {
for (var i = extruderOffsets.length; i < numExtruders; i++) {
extruderOffsets[i] = {
idx: i + 1,
x: ko.observable(0),
y: ko.observable(0)
}
}
self.editorExtruderOffsets(extruderOffsets);
}

return extruderOffsets.slice(0, numExtruders);
return extruderOffsets.slice(0, numExtruders - 1);
});

self.editorNameInvalid = ko.computed(function() {
Expand Down Expand Up @@ -319,12 +320,15 @@ $(function() {
self.editorNozzleDiameter(data.extruder.nozzleDiameter);
self.editorExtruders(data.extruder.count);
var offsets = [];
_.each(data.extruder.offsets, function(offset) {
offsets.push({
x: ko.observable(offset[0]),
y: ko.observable(offset[1])
if (data.extruder.count > 1) {
_.each(_.slice(data.extruder.offsets, 1), function(offset, index) {
offsets.push({
idx: index + 1,
x: ko.observable(offset[0]),
y: ko.observable(offset[1])
});
});
});
}
self.editorExtruderOffsets(offsets);

self.editorAxisXSpeed(data.axes.x.speed);
Expand Down Expand Up @@ -409,10 +413,14 @@ $(function() {
};

if (self.editorExtruders() > 1) {
for (var i = 1; i < self.editorExtruders(); i++) {
for (var i = 0; i < self.editorExtruders() - 1; i++) {
var offset = [0.0, 0.0];
if (i < self.editorExtruderOffsets().length) {
offset = [parseFloat(self.editorExtruderOffsets()[i]["x"]()), parseFloat(self.editorExtruderOffsets()[i]["y"]())];
try {
offset = [parseFloat(self.editorExtruderOffsets()[i]["x"]()), parseFloat(self.editorExtruderOffsets()[i]["y"]())];
} catch (exc) {
log.error("Invalid offset in profile", identifier, "for extruder", i+1, ":", self.editorExtruderOffsets()[i]["x"], ",", self.editorExtruderOffsets()[i]["y"]);
}
}
profile.extruder.offsets.push(offset);
}
Expand Down
11 changes: 6 additions & 5 deletions src/octoprint/templates/dialogs/settings/printerprofiles.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -167,19 +167,20 @@
<div class="control-group">
<label class="control-label">{{ _('Number of Extruders') }}</label>
<div class="controls">
<input type="number" class="input-mini text-right" min="1" max="5" data-bind="value: printerProfiles.editorExtruders">
<input type="number" class="input-mini text-right" min="1" max="10" data-bind="value: printerProfiles.editorExtruders">
</div>
</div>
<div class="control-group">
<label class="control-label">{{ _('Extruder Offsets') }}</label>
<div class="control-group" data-bind="visible: printerProfiles.editorExtruders() > 1">
<label class="control-label">{{ _('Nozzle Offsets (relative to first nozzle T0)') }}</label>
<!-- ko foreach: printerProfiles.koEditorExtruderOffsets -->
<div class="controls form-inline">
<label>X:</label>
<label>T<span data-bind="text: idx"></span>:</label>
<label>X</label>
<div class="input-append">
<input type="number" step="0.01" class="input-mini text-right" data-bind="value: x">
<span class="add-on">mm</span>
</div>
<label>Y:</label>
<label>Y</label>
<div class="input-append">
<input type="number" step="0.01" class="input-mini text-right" data-bind="value: y">
<span class="add-on">mm</span>
Expand Down

0 comments on commit 2ef3930

Please sign in to comment.