fix starting offset with multiple widgets
This commit is contained in:
parent
89eac1edcb
commit
b735a3abef
4 changed files with 32 additions and 7 deletions
|
|
@ -3,9 +3,9 @@
|
||||||
import { $, h } from '../../moto/webui.js';
|
import { $, h } from '../../moto/webui.js';
|
||||||
import { ajax, js2o } from '../core/utils.js';
|
import { ajax, js2o } from '../core/utils.js';
|
||||||
import { api } from './api.js';
|
import { api } from './api.js';
|
||||||
import { base } from '../../geo/base.js';
|
|
||||||
import { COLOR, MODES } from '../core/consts.js';
|
import { COLOR, MODES } from '../core/consts.js';
|
||||||
import { load as file_load } from '../../load/file.js';
|
import { load as file_load } from '../../load/file.js';
|
||||||
|
import { newBounds } from '../../geo/bounds.js';
|
||||||
import { Packer } from './pack.js';
|
import { Packer } from './pack.js';
|
||||||
import { space } from '../../moto/space.js';
|
import { space } from '../../moto/space.js';
|
||||||
import { THREE } from '../../ext/three.js';
|
import { THREE } from '../../ext/three.js';
|
||||||
|
|
@ -611,8 +611,8 @@ function positionNewWidget(widget) {
|
||||||
x: dim.x / 2,
|
x: dim.x / 2,
|
||||||
y: dim.y / 2
|
y: dim.y / 2
|
||||||
};
|
};
|
||||||
const bounds = base.newBounds();
|
const bounds = newBounds();
|
||||||
const target = base.newBounds();
|
const target = newBounds();
|
||||||
const DEG2RAD = Math.PI / 180;
|
const DEG2RAD = Math.PI / 180;
|
||||||
const WIDGETS = api.widgets.all();
|
const WIDGETS = api.widgets.all();
|
||||||
// look for best position for new widget that doesn't collide
|
// look for best position for new widget that doesn't collide
|
||||||
|
|
|
||||||
|
|
@ -416,6 +416,7 @@ export function cam_export(print, online) {
|
||||||
const isOffset = offset && (offset.x || offset.y || offset.z);
|
const isOffset = offset && (offset.x || offset.y || offset.z);
|
||||||
// remap points as necessary for origins, offsets, inversions
|
// remap points as necessary for origins, offsets, inversions
|
||||||
print.output.forEach(layer => {
|
print.output.forEach(layer => {
|
||||||
|
// console.log(layer);
|
||||||
if (!Array.isArray(layer)) {
|
if (!Array.isArray(layer)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,8 @@ export async function cam_prepare(widgets, settings, update) {
|
||||||
// process `prepare` paths for a single widget
|
// process `prepare` paths for a single widget
|
||||||
export async function prepare_one(widget, settings, print, firstPoint, update) {
|
export async function prepare_one(widget, settings, print, firstPoint, update) {
|
||||||
|
|
||||||
let { device, process } = settings,
|
let { device, process, stock: set_stock } = settings,
|
||||||
|
{ center } = set_stock,
|
||||||
{ alignTop } = settings.controller,
|
{ alignTop } = settings.controller,
|
||||||
{ camArcEnabled, camArcResolution, camArcTolerance } = process,
|
{ camArcEnabled, camArcResolution, camArcTolerance } = process,
|
||||||
{ camDepthFirst, camEaseAngle, camEaseDown } = process,
|
{ camDepthFirst, camEaseAngle, camEaseDown } = process,
|
||||||
|
|
@ -144,6 +145,21 @@ export async function prepare_one(widget, settings, print, firstPoint, update) {
|
||||||
|
|
||||||
if (debug) console.log({ zSafe, wmx, wmy, wmz });
|
if (debug) console.log({ zSafe, wmx, wmy, wmz });
|
||||||
|
|
||||||
|
// function d(o) {
|
||||||
|
// console.log('<-------------------');
|
||||||
|
// for (let [k,v] of Object.entries(o)) console.log(k,v);
|
||||||
|
// console.log('------------------->');
|
||||||
|
// }
|
||||||
|
|
||||||
|
// d({
|
||||||
|
// stock,
|
||||||
|
// sstck: set_stock,
|
||||||
|
// center,
|
||||||
|
// origin,
|
||||||
|
// wmx,
|
||||||
|
// wmy
|
||||||
|
// });
|
||||||
|
|
||||||
function newLayer(op) {
|
function newLayer(op) {
|
||||||
if (layerOut.length || layerOut.mode) {
|
if (layerOut.length || layerOut.mode) {
|
||||||
newOutput.push(layerOut);
|
newOutput.push(layerOut);
|
||||||
|
|
@ -850,7 +866,15 @@ export async function prepare_one(widget, settings, print, firstPoint, update) {
|
||||||
|
|
||||||
// coming from a previous widget, use previous last point as starting point
|
// coming from a previous widget, use previous last point as starting point
|
||||||
// make top start offset configurable
|
// make top start offset configurable
|
||||||
printPoint = firstPoint || origin;
|
if (firstPoint) {
|
||||||
|
// we're coming from another widget. offset compensated below
|
||||||
|
printPoint = firstPoint;
|
||||||
|
// console.log('coming from another widget', { printPoint });
|
||||||
|
} else {
|
||||||
|
// we're the first widget output. offset is center
|
||||||
|
printPoint = origin.clone().move({ x: center.x, y: center.y });
|
||||||
|
// console.log('first widget output', { printPoint });
|
||||||
|
}
|
||||||
|
|
||||||
let ops = {
|
let ops = {
|
||||||
addGCode,
|
addGCode,
|
||||||
|
|
@ -910,7 +934,7 @@ export async function prepare_one(widget, settings, print, firstPoint, update) {
|
||||||
update((opSum + (progress * weight)) / opTot, message || op.type(), message);
|
update((opSum + (progress * weight)) / opTot, message || op.type(), message);
|
||||||
});
|
});
|
||||||
opSum += weight;
|
opSum += weight;
|
||||||
if (tool && printPoint) {
|
if (tool && printPoint && cop.type !== 'shadow') {
|
||||||
newLayer();
|
newLayer();
|
||||||
if (!isIndex) {
|
if (!isIndex) {
|
||||||
layerPush(printPoint.clone().setZ(stockZClear), 0, 0, tool);
|
layerPush(printPoint.clone().setZ(stockZClear), 0, 0, tool);
|
||||||
|
|
|
||||||
|
|
@ -692,7 +692,7 @@
|
||||||
<div id="oph1nt"><label class="hint"><a href="http://docs.octoprint.org/en/master/api/general.html?highlight=cors#cross-origin-requests" target="_help">CORS support</a> must be enabled in API settings</label></div>
|
<div id="oph1nt"><label class="hint"><a href="http://docs.octoprint.org/en/master/api/general.html?highlight=cors#cross-origin-requests" target="_help">CORS support</a> must be enabled in API settings</label></div>
|
||||||
</div>
|
</div>
|
||||||
<div id="export-support" class="f-col">
|
<div id="export-support" class="f-col">
|
||||||
<a id="export-support-a" target="support">this project neeeds your support!</a>
|
<a id="export-support-a" target="support">this project needs your support!</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="mod-x-sla" class="mod-print mdialog f-col">
|
<div id="mod-x-sla" class="mod-print mdialog f-col">
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue