allow multiple trace ops with different settings
This commit is contained in:
parent
fd3eb613aa
commit
46c225cd73
9 changed files with 95 additions and 280 deletions
|
|
@ -104,6 +104,10 @@
|
|||
}();
|
||||
};
|
||||
|
||||
Polygon.fromArray = function(array) {
|
||||
return newPolygon().fromArray(array);
|
||||
};
|
||||
|
||||
/** ******************************************************************
|
||||
* Polygon Prototype Functions
|
||||
******************************************************************* */
|
||||
|
|
@ -122,6 +126,31 @@
|
|||
}
|
||||
};
|
||||
|
||||
PRO.toArray = function() {
|
||||
let ov = this.open ? 1 : 0;
|
||||
return this.points.map((p,i) => i === 0 ? [ov,p.x,p.y,p.z] : [p.x,p.y,p.z]).flat();
|
||||
};
|
||||
|
||||
PRO.fromArray = function(array) {
|
||||
this.open = array[0] === 1;
|
||||
for (let i=1; i<array.length; ) {
|
||||
this.add(array[i++], array[i++], array[i++]);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
PRO.matches = function(poly) {
|
||||
let tarr = Array.isArray(poly) ? poly : poly.toArray();
|
||||
let parr = this.toArray();
|
||||
if (tarr.length === parr.length) {
|
||||
for (let i=0; i<tarr.length; i++) {
|
||||
if (Math.abs(tarr[i] - parr[i]) > 0.0001) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
PRO.xray = function(deep) {
|
||||
const xray = {
|
||||
id: this.id,
|
||||
|
|
@ -429,24 +458,6 @@
|
|||
x /= l;
|
||||
y /= l;
|
||||
return newPoint(x, y, this.points[0].z, null);
|
||||
// let points = this.points,
|
||||
// length = points.length,
|
||||
// incr = Math.floor(length / 3),
|
||||
// A = points[0],
|
||||
// B = points[incr],
|
||||
// C = points[incr * 2],
|
||||
// yDelta_a = B.y - A.y,
|
||||
// xDelta_a = B.x - A.x,
|
||||
// yDelta_b = C.y - B.y,
|
||||
// xDelta_b = C.x - B.x,
|
||||
// aSlope = yDelta_a / xDelta_a,
|
||||
// bSlope = yDelta_b / xDelta_b,
|
||||
// center = newPoint(0, 0, 0, null);
|
||||
//
|
||||
// center.x = (aSlope * bSlope * (A.y - C.y) + bSlope * (A.x + B.x) - aSlope * (B.x+C.x) )/(2* (bSlope-aSlope) );
|
||||
// center.y = -1 * (center.x - (A.x+B.x) / 2) / aSlope + (A.y + B.y) / 2;
|
||||
// center.z = A.z;
|
||||
// return center;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -1554,42 +1565,6 @@
|
|||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* rotate such that first and last points are the points
|
||||
* furthest apart and lowest when there is a tie breaker
|
||||
*/
|
||||
// PRO.spread = function() {
|
||||
// let poly = this,
|
||||
// points = poly.points,
|
||||
// plen = points.length,
|
||||
// i, pp, np, p, mdelta, newmax, max, shift, maxd;
|
||||
//
|
||||
// max = {d:0};
|
||||
// maxd = 0;
|
||||
// // find two most distance points
|
||||
// for (i=0; i<plen; i++) {
|
||||
// pp = points[i % plen];
|
||||
// np = points[(i+1) % plen];
|
||||
// p = ABS(pp.x - np.x) + ABS(pp.y - np.y);
|
||||
// mdelta = ABS(p - max.d);
|
||||
// newmax = p > maxd;
|
||||
// maxd = MAX(maxd,p);
|
||||
// // select lowest points (corner case = square)
|
||||
// if (newmax || (mdelta < 0.001 && max.p1 && MIN(pp.z,np.z) < MIN(max.p1.z, max.p2.z))) {
|
||||
// max = {p1:pp, p2:np, i:(i+1)%plen, d:p};
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (max.i > 0) {
|
||||
// // shift array to start at "leftmost" Point
|
||||
// shift = points.slice(max.i);
|
||||
// shift.appendAll(points.slice(0,max.i));
|
||||
// return newPolygon(shift);
|
||||
// }
|
||||
//
|
||||
// return poly;
|
||||
// }
|
||||
|
||||
/** ******************************************************************
|
||||
* Connect to base and Helpers
|
||||
******************************************************************* */
|
||||
|
|
|
|||
|
|
@ -319,6 +319,11 @@
|
|||
let poly = BASE.newPolygon(),
|
||||
vid = 0;
|
||||
|
||||
// if passed a normal array, convert to float32
|
||||
if (v.array.toFloat32) {
|
||||
v.array = v.array.toFloat32();
|
||||
}
|
||||
|
||||
while (vid < v.array.length) {
|
||||
poly.push(BASE.newPoint(v.array[vid++], v.array[vid++], v.array[vid++]));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1637,103 +1637,6 @@
|
|||
(UI.ssmClr = UC.newButton(undefined, onButtonClick, {icon:'<i class="fas fa-trash-alt"></i>'}))
|
||||
], {modes:FDM, class:"ext-buttons f-row"}),
|
||||
|
||||
// camRough: UC.newGroup(LANG.cr_menu, null, {modes:CAM, class:"rough"}),
|
||||
// camRoughTool: UC.newSelect(LANG.cc_tool, {modes:CAM}),
|
||||
// camSep: UC.newBlank({class:"pop-sep"}),
|
||||
// camRoughSpindle: UC.newInput(LANG.cc_spnd_s, {title:LANG.cc_spnd_l, convert:UC.toInt, modes:CAM, visible:spindleShow}),
|
||||
// camRoughDown: UC.newInput(LANG.cc_sdwn_s, {title:LANG.cc_sdwn_l, convert:UC.toFloat, modes:CAM, units:true}),
|
||||
// camRoughOver: UC.newInput(LANG.cc_sovr_s, {title:LANG.cc_sovr_l, convert:UC.toFloat, bound:UC.bound(0.01,1.0), modes:CAM}),
|
||||
// camRoughSpeed: UC.newInput(LANG.cc_feed_s, {title:LANG.cc_feed_l, convert:UC.toInt, modes:CAM, units:true}),
|
||||
// camRoughPlunge: UC.newInput(LANG.cc_plng_s, {title:LANG.cc_plng_l, convert:UC.toInt, modes:CAM, units:true}),
|
||||
// camRoughStock: UC.newInput(LANG.cr_lsto_s, {title:LANG.cr_lsto_l, convert:UC.toFloat, modes:CAM, units:true}),
|
||||
// camSep: UC.newBlank({class:"pop-sep"}),
|
||||
// camRoughVoid: UC.newBoolean(LANG.cr_clrp_s, onBooleanClick, {title:LANG.cr_clrp_l, modes:CAM}),
|
||||
// camRoughFlat: UC.newBoolean(LANG.cr_clrf_s, onBooleanClick, {title:LANG.cr_clrf_l, modes:CAM}),
|
||||
// camRoughTop: UC.newBoolean(LANG.cr_clrt_s, onBooleanClick, {title:LANG.cr_clrt_l, modes:CAM}),
|
||||
// camRoughIn: UC.newBoolean(LANG.cr_olin_s, onBooleanClick, {title:LANG.cr_olin_l, modes:CAM}),
|
||||
// camSep: UC.newBlank({class:"pop-sep"}),
|
||||
// camRoughAdd: UC.newRow([
|
||||
// UI.crAdd = UC.newButton('add', onButtonClick, {class: "f-col grow a-center"})
|
||||
// ], { modes: CAM, class: "ext-buttons f-row grow" }),
|
||||
//
|
||||
// camOutline: UC.newGroup(LANG.co_menu, null, {modes:CAM, class:"outline"}),
|
||||
// camOutlineTool: UC.newSelect(LANG.cc_tool, {modes:CAM}),
|
||||
// camSep: UC.newBlank({class:"pop-sep"}),
|
||||
// camOutlineSpindle: UC.newInput(LANG.cc_spnd_s, {title:LANG.cc_spnd_l, convert:UC.toInt, modes:CAM, visible:spindleShow}),
|
||||
// camOutlineDown: UC.newInput(LANG.cc_sdwn_s, {title:LANG.cc_sdwn_l, convert:UC.toFloat, modes:CAM, units:true}),
|
||||
// camOutlineOver: UC.newInput(LANG.cc_sovr_s, {title:LANG.cc_sovr_l, convert:UC.toFloat, modes:CAM, bound:UC.bound(0.01,1.0), units:true, show:() => { return UI.camOutlineWide.checked }}),
|
||||
// camOutlineSpeed: UC.newInput(LANG.cc_feed_s, {title:LANG.cc_feed_l, convert:UC.toInt, modes:CAM, units:true}),
|
||||
// camOutlinePlunge: UC.newInput(LANG.cc_plng_s, {title:LANG.cc_plng_l, convert:UC.toInt, modes:CAM, units:true}),
|
||||
// camSep: UC.newBlank({class:"pop-sep"}),
|
||||
// camOutlineDogbone: UC.newBoolean(LANG.co_dogb_s, onBooleanClick, {title:LANG.co_dogb_l, modes:CAM, show:() => { return !UI.camOutlineWide.checked }}),
|
||||
// camOutlineIn: UC.newBoolean(LANG.co_olin_s, onBooleanClick, {title:LANG.co_olin_l, modes:CAM, show:() => { return !UI.camOutlineOut.checked }}),
|
||||
// camOutlineOut: UC.newBoolean(LANG.co_olot_s, onBooleanClick, {title:LANG.co_olot_l, modes:CAM, show:() => { return !UI.camOutlineIn.checked }}),
|
||||
// camOutlineWide: UC.newBoolean(LANG.co_wide_s, onBooleanClick, {title:LANG.co_wide_l, modes:CAM, show:() => { return !UI.camOutlineIn.checked }}),
|
||||
// camSep: UC.newBlank({class:"pop-sep"}),
|
||||
// camOutlineAdd: UC.newRow([
|
||||
// UI.coAdd = UC.newButton('add', onButtonClick, {class: "f-col grow a-center"})
|
||||
// ], { modes: CAM, class: "ext-buttons f-row grow" }),
|
||||
//
|
||||
// camContour: UC.newGroup(LANG.cn_menu, null, {modes:CAM}),
|
||||
// camContourTool: UC.newSelect(LANG.cc_tool, {modes:CAM}),
|
||||
// camSep: UC.newBlank({class:"pop-sep"}),
|
||||
// camContourSpindle: UC.newInput(LANG.cc_spnd_s, {title:LANG.cc_spnd_l, convert:UC.toInt, modes:CAM, visible:spindleShow}),
|
||||
// camContourOver: UC.newInput(LANG.cc_sovr_s, {title:LANG.cc_sovr_l, convert:UC.toFloat, bound:UC.bound(0.01,1.0), modes:CAM}),
|
||||
// camContourSpeed: UC.newInput(LANG.cc_feed_s, {title:LANG.cc_feed_l, convert:UC.toInt, modes:CAM, units:true}),
|
||||
// camContourAngle: UC.newInput(LANG.cf_angl_s, {title:LANG.cf_angl_l, convert:UC.toFloat, bound:UC.bound(45,90), modes:CAM}),
|
||||
// camTolerance: UC.newInput(LANG.ou_toll_s, {title:LANG.ou_toll_l, convert:UC.toFloat, bound:UC.bound(0,10.0), modes:CAM, units:true}),
|
||||
// camSep: UC.newBlank({class:"pop-sep"}),
|
||||
// camContourCurves: UC.newBoolean(LANG.cf_curv_s, onBooleanClick, {title:LANG.cf_curv_l, modes:CAM}),
|
||||
// camContourIn: UC.newBoolean(LANG.cf_olin_s, onBooleanClick, {title:LANG.cf_olin_l, modes:CAM}),
|
||||
// camSep: UC.newBlank({class:"pop-sep"}),
|
||||
// camOutlineAdd: UC.newRow([
|
||||
// UI.ccxAdd = UC.newButton('add x', onButtonClick, {class: "f-col grow a-center"}),
|
||||
// UI.ccyAdd = UC.newButton('add y', onButtonClick, {class: "f-col grow a-center"})
|
||||
// ], { modes: CAM, class: "ext-buttons f-row grow" }),
|
||||
//
|
||||
// camTracing: UC.newGroup(LANG.cu_menu, null, {modes:CAM}),
|
||||
// camTraceTool: UC.newSelect(LANG.cc_tool, {modes:CAM}),
|
||||
// camSep: UC.newBlank({class:"pop-sep"}),
|
||||
// camTraceType: UC.newSelect(LANG.cu_type_s, {title:LANG.cu_type_l, modes:CAM}, "trace"),
|
||||
// camTraceSpeed: UC.newInput(LANG.cc_feed_s, {title:LANG.cc_feed_l, convert:UC.toInt, modes:CAM}),
|
||||
// camTracePlunge: UC.newInput(LANG.cc_plng_s, {title:LANG.cc_plng_l, convert:UC.toFloat, modes:CAM, units:true}),
|
||||
// camSep: UC.newBlank({class:"pop-sep"}),
|
||||
// camTraceSelect: UC.newRow([
|
||||
// (UI.traceAdd = UC.newButton(undefined, onButtonClick, {icon:'<i class="fas fa-plus"></i>'})),
|
||||
// (UI.traceDun = UC.newButton(undefined, onButtonClick, {icon:'<i class="fas fa-check"></i>'})),
|
||||
// (UI.traceClr = UC.newButton(undefined, onButtonClick, {icon:'<i class="fas fa-trash-alt"></i>'}))
|
||||
// ], {modes:CAM, class:"ext-buttons f-row"}),
|
||||
//
|
||||
// camDrill: UC.newGroup(LANG.cd_menu, null, {modes:CAM}),
|
||||
// camDrillTool: UC.newSelect(LANG.cc_tool, {modes:CAM}),
|
||||
// camSep: UC.newBlank({class:"pop-sep"}),
|
||||
// camDrillSpindle: UC.newInput(LANG.cc_spnd_s, {title:LANG.cc_spnd_l, convert:UC.toInt, modes:CAM, visible:spindleShow}),
|
||||
// camDrillDown: UC.newInput(LANG.cd_plpr_s, {title:LANG.cd_plpr_l, convert:UC.toFloat, modes:CAM, units:true}),
|
||||
// camDrillDownSpeed: UC.newInput(LANG.cc_plng_s, {title:LANG.cc_plng_l, convert:UC.toFloat, modes:CAM, units:true}),
|
||||
// camDrillDwell: UC.newInput(LANG.cd_dwll_s, {title:LANG.cd_dwll_l, convert:UC.toFloat, modes:CAM}),
|
||||
// camDrillLift: UC.newInput(LANG.cd_lift_s, {title:LANG.cd_lift_l, convert:UC.toFloat, modes:CAM, units:true}),
|
||||
// camSep: UC.newBlank({class:"pop-sep"}),
|
||||
// // camDrillingOn: UC.newBoolean(LANG.enable, onBooleanClick, {modes:CAM}),
|
||||
// camDrillAdd: UC.newRow([
|
||||
// UI.drAdd = UC.newButton('add', onButtonClick, {class: "f-col grow a-center"})
|
||||
// ], { modes: CAM, class: "ext-buttons f-row grow" }),
|
||||
// camSep: UC.newBlank({class:"pop-sep"}),
|
||||
// camSep: UC.newBlank({class:"pop-sep"}),
|
||||
// camDrillAdd: UC.newRow([
|
||||
// UC.newLabel('registrations', {class: "f-col grow center"})
|
||||
// ], { modes: CAM, class: "ext-buttons f-row" }),
|
||||
// // camDrillReg: UC.newSelect(LANG.cd_regi_s, {modes:CAM, title:LANG.cd_regi_l}, "drillreg"),
|
||||
// camDrillAdd: UC.newRow([
|
||||
// UI.drX2Add = UC.newButton('x axis 2', onButtonClick, {class: "f-col grow a-center"}),
|
||||
// UI.drX3Add = UC.newButton('x axis 3', onButtonClick, {class: "f-col grow a-center"}),
|
||||
// ], { modes: CAM, xclass: "ext-buttons f-row grow" }),
|
||||
// camDrillAdd: UC.newRow([
|
||||
// UI.drY2Add = UC.newButton('y axis 2', onButtonClick, {class: "f-col grow a-center"}),
|
||||
// UI.drY3Add = UC.newButton('y axis 3', onButtonClick, {class: "f-col grow a-center"}),
|
||||
// ], { modes: CAM, xclass: "ext-buttons f-row grow" }),
|
||||
//
|
||||
// camSep1: UC.newGroup(null, null, {modes:CAM, class:"set-sep"}),
|
||||
|
||||
camTabs: UC.newGroup(LANG.ct_menu, null, {modes:CAM, marker:true}),
|
||||
camTabsWidth: UC.newInput(LANG.ct_wdth_s, {title:LANG.ct_wdth_l, convert:UC.toFloat, bound:UC.bound(0.005,100), modes:CAM, units:true}),
|
||||
camTabsHeight: UC.newInput(LANG.ct_hght_s, {title:LANG.ct_hght_l, convert:UC.toFloat, bound:UC.bound(0.005,100), modes:CAM, units:true}),
|
||||
|
|
|
|||
|
|
@ -10,17 +10,16 @@
|
|||
PRO = CAM.process,
|
||||
newPolygon = BASE.newPolygon,
|
||||
newPoint = BASE.newPoint,
|
||||
toolInfo,
|
||||
isAnimate,
|
||||
isArrange,
|
||||
isCamMode,
|
||||
isParsed,
|
||||
camStock,
|
||||
current,
|
||||
poppedRec,
|
||||
API, FDM, SPACE, STACKS, MODES, VIEWS, UI, UC, LANG;
|
||||
|
||||
let traceOp = { type: "trace", mode:"follow", tool: 1000, rate: 1000, plunge: 200 },
|
||||
zaxis = { x: 0, y: 0, z: 1 },
|
||||
let zaxis = { x: 0, y: 0, z: 1 },
|
||||
popOp = {},
|
||||
func = {};
|
||||
|
||||
|
|
@ -39,8 +38,6 @@
|
|||
UC = api.uc;
|
||||
API = api;
|
||||
|
||||
toolInfo = $('tool-info');
|
||||
|
||||
// wire up animate button in ui
|
||||
api.function.animate = () => {
|
||||
api.function.prepare(() => {
|
||||
|
|
@ -65,7 +62,6 @@
|
|||
UI.label.export.innerText = 'export';
|
||||
} else {
|
||||
UI.label.slice.innerText = 'start';
|
||||
// checkOutlineSettings(api.conf.get());
|
||||
}
|
||||
// do not persist traces across page reloads
|
||||
func.traceClear();
|
||||
|
|
@ -81,28 +77,13 @@
|
|||
func.opRender();
|
||||
});
|
||||
|
||||
// function checkOutlineSettings(settings) {
|
||||
// let ui = api.ui, proc = settings.process;
|
||||
// // fix invalid in/out enabled condition
|
||||
// if (ui.camOutlineIn.checked && ui.camOutlineOut.checked) {
|
||||
// proc.camOutlineIn = proc.camOutlineOut = false;
|
||||
// ui.camOutlineIn.checked = ui.camOutlineOut.checked = false;
|
||||
// api.uc.refresh();
|
||||
// }
|
||||
// }
|
||||
|
||||
api.event.on("settings.saved", (settings) => {
|
||||
current = settings;
|
||||
let proc = settings.process;
|
||||
let hasTabs = false;
|
||||
let hasTraces = false;
|
||||
// ensure trace op is a singleton for now
|
||||
if (isCamMode && proc.ops) {
|
||||
proc.ops = proc.ops
|
||||
.filter(v => v)
|
||||
.map(op => {
|
||||
return op.type === 'trace' ? traceOp : op
|
||||
});
|
||||
proc.ops = proc.ops.filter(v => v);
|
||||
}
|
||||
// for any tabs or traces to set markers
|
||||
Object.keys(settings.widget).forEach(wid => {
|
||||
|
|
@ -110,7 +91,6 @@
|
|||
if (wannot.tab && wannot.tab.length) hasTabs = true;
|
||||
if (wannot.trace && wannot.trace.length) hasTraces = true;
|
||||
});
|
||||
// checkOutlineSettings(settings);
|
||||
// show/hide dots in enabled process pop buttons
|
||||
api.ui.camTabs.marker.style.display = hasTabs ? 'flex' : 'none';
|
||||
api.ui.camStock.marker.style.display = proc.camStockOn ? 'flex' : 'none';
|
||||
|
|
@ -184,7 +164,7 @@
|
|||
func.opAddDrill();
|
||||
break;
|
||||
case "trace":
|
||||
func.opAdd(traceOp);
|
||||
func.opAddTrace();
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
|
@ -240,6 +220,18 @@
|
|||
});
|
||||
};
|
||||
|
||||
func.opAddTrace = () => {
|
||||
let process = API.conf.get().process;
|
||||
func.opAdd({
|
||||
type: "trace",
|
||||
mode: "follow",
|
||||
tool: 1000,
|
||||
rate: 1000,
|
||||
plunge: 200,
|
||||
areas: { /* widget.id: [ polygons... ] */ }
|
||||
})
|
||||
};
|
||||
|
||||
func.opAddDrill = () => {
|
||||
let process = API.conf.get().process;
|
||||
func.opAdd({
|
||||
|
|
@ -281,45 +273,6 @@
|
|||
if (ok) func.tabClear();
|
||||
});
|
||||
break;
|
||||
case api.ui.traceAdd:
|
||||
case api.ui.traceAdd2:
|
||||
return func.traceAdd();
|
||||
case api.ui.traceDun:
|
||||
case api.ui.traceDun2:
|
||||
return func.traceDone();
|
||||
case api.ui.traceClr:
|
||||
case api.ui.traceClr2:
|
||||
api.uc.confirm("clear traces?").then(ok => {
|
||||
if (ok) func.traceClear();
|
||||
});
|
||||
break;
|
||||
case api.ui.crAdd:
|
||||
func.opAddRough();
|
||||
break;
|
||||
case api.ui.coAdd:
|
||||
func.opAddOutline();
|
||||
break;
|
||||
case api.ui.ccxAdd:
|
||||
func.opAddContour('x');
|
||||
break;
|
||||
case api.ui.ccyAdd:
|
||||
func.opAddContour('y');
|
||||
break;
|
||||
case api.ui.drAdd:
|
||||
func.opAddDrill();
|
||||
break;
|
||||
case api.ui.drX2Add:
|
||||
func.opAddRegister("X", 2);
|
||||
break;
|
||||
case api.ui.drX3Add:
|
||||
func.opAddRegister("X", 3);
|
||||
break;
|
||||
case api.ui.drY2Add:
|
||||
func.opAddRegister("Y", 2);
|
||||
break;
|
||||
case api.ui.drY3Add:
|
||||
func.opAddRegister("Y", 3);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -393,6 +346,8 @@
|
|||
unpop = func.unpop = el.unpop;
|
||||
inside = true;
|
||||
poprec.use(rec);
|
||||
// pointer to current rec for trace editing
|
||||
poppedRec = rec;
|
||||
el.appendChild(poprec.div);
|
||||
// option click event appears latent
|
||||
// and overides the sticky settings
|
||||
|
|
@ -545,7 +500,7 @@
|
|||
|
||||
// TRACE FUNCS
|
||||
let traceOn = false, lastTrace;
|
||||
api.event.on("cam.trace.add", func.traceAdd = () => {
|
||||
func.traceAdd = () => {
|
||||
if (traceOn) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -566,31 +521,33 @@
|
|||
widget.trace_stack.show();
|
||||
return;
|
||||
}
|
||||
let areas = (poppedRec.areas[widget.id] || []);
|
||||
let stack = new KIRI.Stack(widget.mesh);
|
||||
widget.trace_stack = stack;
|
||||
widget.traces.forEach(poly => {
|
||||
let match = areas.filter(arr => poly.matches(arr));
|
||||
let layers = new KIRI.Layers();
|
||||
layers.setLayer("trace", {line: 0x88aa55}, false).addPoly(poly);
|
||||
stack.addLayers(layers);
|
||||
stack.new_meshes.forEach(mesh => {
|
||||
mesh.trace = {widget, poly};
|
||||
if (match.length > 0) {
|
||||
poly._trace = match[0];
|
||||
func.traceToggle(mesh, true);
|
||||
} else {
|
||||
poly._trace = poly.toArray();
|
||||
}
|
||||
});
|
||||
widget.adds.appendAll(stack.new_meshes);
|
||||
});
|
||||
// for (let [key, val] of Object.entries(widget.sindex)) {
|
||||
// console.log('sindex', {key, val});
|
||||
// let layers = new KIRI.Layers();
|
||||
// layers.setLayer("sindex", {line: 0x55aa88}, false).addPolys(val);
|
||||
// stack.addLayers(layers);
|
||||
// }
|
||||
});
|
||||
});
|
||||
api.feature.hover = true;
|
||||
api.feature.hoverAdds = true;
|
||||
func.hover = func.traceHover;
|
||||
func.hoverUp = func.traceHoverUp;
|
||||
});
|
||||
api.event.on("cam.trace.done", func.traceDone = () => {
|
||||
};
|
||||
func.traceDone = () => {
|
||||
if (!traceOn) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -605,8 +562,7 @@
|
|||
widget.adds.removeAll(widget.trace_stack.meshes);
|
||||
}
|
||||
});
|
||||
toolInfo.style.display = '';
|
||||
});
|
||||
};
|
||||
api.event.on("cam.trace.clear", func.traceClear = () => {
|
||||
func.traceDone();
|
||||
API.widgets.all().forEach(widget => {
|
||||
|
|
@ -634,18 +590,6 @@
|
|||
let target = event.target;
|
||||
let { clientX, clientY } = event;
|
||||
let { offsetWidth, offsetHeight } = target;
|
||||
toolInfo.style.right = `${offsetWidth - clientX + 5}px`;
|
||||
toolInfo.style.bottom = `${offsetHeight - clientY + 5}px`;
|
||||
let traceInfo = lastTrace.trace.poly.traceInfo;
|
||||
let tool = new CAM.Tool(current, traceInfo.tool);
|
||||
toolInfo.innerText = [
|
||||
` tool: ${tool.getName()}`,
|
||||
` feed: ${traceInfo.speed}`,
|
||||
`plunge: ${traceInfo.plunge}`
|
||||
].join('\n');
|
||||
toolInfo.style.display = 'flex';
|
||||
} else {
|
||||
toolInfo.style.display = '';
|
||||
}
|
||||
let material = lastTrace.material[0];
|
||||
let color = material.color;
|
||||
|
|
@ -659,38 +603,31 @@
|
|||
if (!int) return;
|
||||
func.traceToggle(int.object);
|
||||
};
|
||||
func.traceToggle = function(obj) {
|
||||
func.traceToggle = function(obj, skip) {
|
||||
let material = obj.material[0];
|
||||
let { color, colorSave } = material;
|
||||
let { widget, poly } = obj.trace;
|
||||
let wannot = API.widgets.annotate(widget.id);
|
||||
let atrace = wannot.trace = wannot.trace || [];
|
||||
let wtrace = widget.trace = widget.trace || [];
|
||||
let process = current.process;
|
||||
let areas = poppedRec.areas;
|
||||
let wlist = areas[widget.id] = areas[widget.id] || [];
|
||||
obj.selected = !obj.selected;
|
||||
if (!colorSave) {
|
||||
colorSave = material.colorSave = {
|
||||
r: color.r,
|
||||
g: color.g,
|
||||
b: color.b
|
||||
};
|
||||
}
|
||||
if (obj.selected) {
|
||||
color.r = colorSave.r = 0.9;
|
||||
color.g = colorSave.g = 0;
|
||||
color.b = colorSave.b = 0.1;
|
||||
poly.traceInfo = {
|
||||
tool: process.camTraceTool,
|
||||
speed: process.camTraceSpeed,
|
||||
plunge: process.camTracePlunge,
|
||||
path: KIRI.codec.encode(poly)
|
||||
};
|
||||
wtrace.push(poly);
|
||||
atrace.push(poly.traceInfo);
|
||||
if (!skip) wlist.push(poly._trace);
|
||||
} else {
|
||||
color.r = colorSave.r = 0x88/255;
|
||||
color.g = colorSave.g = 0xaa/255;
|
||||
color.b = colorSave.b = 0x55/255;
|
||||
wtrace.remove(poly);
|
||||
atrace.remove(poly.traceInfo);
|
||||
}
|
||||
if (atrace.length) {
|
||||
func.opAdd(traceOp);
|
||||
} else {
|
||||
func.opDel(traceOp);
|
||||
if (!skip) wlist.remove(poly._trace);
|
||||
}
|
||||
API.conf.save();
|
||||
};
|
||||
|
|
@ -818,7 +755,6 @@
|
|||
select: UC.newRow([
|
||||
UC.newButton(undefined, func.traceAdd, {icon:'<i class="fas fa-plus"></i>'}),
|
||||
UC.newButton(undefined, func.traceDone, {icon:'<i class="fas fa-check"></i>'}),
|
||||
UC.newButton(undefined, func.traceClear, {icon:'<i class="fas fa-trash-alt"></i>'})
|
||||
], {class:"ext-buttons f-row"}),
|
||||
};
|
||||
|
||||
|
|
@ -941,8 +877,6 @@
|
|||
}
|
||||
});
|
||||
}
|
||||
widget.trace = null;
|
||||
delete API.widgets.annotate(widget.id).trace;
|
||||
}
|
||||
|
||||
function addbox() { return FDM.addbox(...arguments)};
|
||||
|
|
|
|||
|
|
@ -604,26 +604,25 @@
|
|||
slice(progress) {
|
||||
let { op, state } = this;
|
||||
let { settings, widget, sliceAll, updateToolDiams } = state;
|
||||
|
||||
// generate tracing offsets from chosen features
|
||||
let sliceOut = this.sliceOut = [];
|
||||
let traces = (settings.widget[widget.id] || {}).trace || [];
|
||||
traces.forEach(trace => {
|
||||
let { tool, path } = trace;
|
||||
let traceTool = new CAM.Tool(settings, tool);
|
||||
let traceToolDiam = traceTool.fluteDiameter();
|
||||
let areas = op.areas[widget.id] || [];
|
||||
let { tool, rate, plunge } = op;
|
||||
let traceTool = new CAM.Tool(settings, tool);
|
||||
let traceToolDiam = traceTool.fluteDiameter();
|
||||
updateToolDiams(traceToolDiam);
|
||||
areas.forEach(arr => {
|
||||
let slice = newSlice();
|
||||
let poly = KIRI.codec.decode(path);
|
||||
let poly = newPolygon().fromArray(arr);
|
||||
slice.addTop(poly);
|
||||
slice.camMode = PRO.TRACE;
|
||||
slice.camLines = [ poly ];
|
||||
slice.camTrace = trace;
|
||||
slice.camTrace = { tool, rate, plunge };
|
||||
if (true) slice.output()
|
||||
.setLayer("trace", {line: 0xaa00aa}, false)
|
||||
.addPolys(slice.topPolys())
|
||||
.addPolys(slice.camLines)
|
||||
sliceAll.push(slice);
|
||||
sliceOut.push(slice);
|
||||
updateToolDiams(traceToolDiam);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -387,8 +387,8 @@
|
|||
}
|
||||
|
||||
function emitTrace(slice) {
|
||||
let { tool, speed, plunge, path } = slice.camTrace;
|
||||
setTool(tool, speed, plunge);
|
||||
let { tool, rate, plunge } = slice.camTrace;
|
||||
setTool(tool, rate, plunge);
|
||||
let traceTool = new CAM.Tool(settings, tool);
|
||||
let traceToolDiam = traceTool.fluteDiameter();
|
||||
slice.camLines.forEach(poly => {
|
||||
|
|
|
|||
|
|
@ -255,7 +255,6 @@
|
|||
opts.over = true;
|
||||
slicer.slice(indices, opts);
|
||||
widget.traces = traces;
|
||||
// widget.sindex = sindex;
|
||||
return true;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1199,9 +1199,9 @@ th, tr, td, label {
|
|||
justify-content: center;
|
||||
align-items: center;
|
||||
position: absolute;
|
||||
bottom: 45px;
|
||||
left: 0;
|
||||
top: 57px;
|
||||
right: 0;
|
||||
left: 0;
|
||||
}
|
||||
#alert-border {
|
||||
display: flex;
|
||||
|
|
@ -1218,7 +1218,7 @@ th, tr, td, label {
|
|||
#alert-text {
|
||||
display: flex;
|
||||
text-align: left;
|
||||
font-weight: bold;
|
||||
font-weight: normal;
|
||||
flex-direction: column;
|
||||
margin: 3px 5px 3px 5px;
|
||||
color: black;
|
||||
|
|
|
|||
|
|
@ -406,11 +406,6 @@
|
|||
</div>
|
||||
</div>
|
||||
<div id="end" class="f-col a-center">
|
||||
<div id="alert-area">
|
||||
<div id="alert-border">
|
||||
<div id="alert-text">alerts<br>alerts<br>alerts</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="bottom">
|
||||
<div id="camops" class="f-row a-stretch j-center">
|
||||
<div class="left"></div>
|
||||
|
|
@ -456,6 +451,11 @@
|
|||
<div id="layer-animate" class="f-col a-center"></div>
|
||||
<div id="layer-toolpos" class="f-row a-center"></div>
|
||||
<div id="winfo" class="noshow"></div>
|
||||
<div id="alert-area">
|
||||
<div id="alert-border">
|
||||
<div id="alert-text">alerts<br>alerts<br>alerts</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
Loading…
Reference in a new issue