add contour bridging option, tab color/opacity update on light/dark change

This commit is contained in:
Stewart Allen 2022-10-04 22:14:30 -04:00
commit 66da2789b2
5 changed files with 40 additions and 5 deletions

View file

@ -139,6 +139,11 @@ CAM.init = function(kiri, api) {
"selection.rotate"
], updateStock);
api.event.on([
// update tab color/opacity on dark/light change
"boolean.update"
], updateTabs);
api.event.on("preview.end", () => {
isParsed = false;
if (isCamMode && camStock) {
@ -997,6 +1002,7 @@ CAM.init = function(kiri, api) {
angle: 'camContourAngle',
tolerance: 'camTolerance',
flatness: 'camFlatness',
bridging: 'camContourBridge',
curves: 'camContourCurves',
inside: 'camContourIn',
axis: 'X'
@ -1008,8 +1014,10 @@ CAM.init = function(kiri, api) {
step: UC.newInput(LANG.cc_sovr_s, {title:LANG.cc_sovr_l, convert:UC.toFloat, bound:UC.bound(0.01,1.0)}),
rate: UC.newInput(LANG.cc_feed_s, {title:LANG.cc_feed_l, convert:UC.toInt, units:true}),
angle: UC.newInput(LANG.cf_angl_s, {title:LANG.cf_angl_l, convert:UC.toFloat, bound:UC.bound(45,90)}),
sep: UC.newBlank({class:"pop-sep"}),
flatness: UC.newInput(LANG.ou_flat_s, {title:LANG.ou_flat_l, convert:UC.toFloat, bound:UC.bound(0,1.0), units:true, round:4}),
tolerance: UC.newInput(LANG.ou_toll_s, {title:LANG.ou_toll_l, convert:UC.toFloat, bound:UC.bound(0,10.0), units:true, round:4}),
bridging: UC.newInput(LANG.ou_brdg_s, {title:LANG.ou_brdg_l, convert:UC.toFloat, bound:UC.bound(0,1000.0), units:true, round:4, show:(op) => op.inputs.curves.checked}),
sep: UC.newBlank({class:"pop-sep"}),
curves: UC.newBoolean(LANG.cf_curv_s, undefined, {title:LANG.cf_curv_l}),
inside: UC.newBoolean(LANG.cf_olin_s, undefined, {title:LANG.cf_olin_l})
@ -1187,7 +1195,7 @@ function createTabBox(iw, ic, n) {
const rot = new THREE.Quaternion().setFromAxisAngle(zaxis, Math.atan2(n.y, n.x));
const pos = { x:ic.x, y:ic.y, z:ic.z };
const dim = { x:camTabsDepth, y:camTabsWidth, z:camTabsHeight };
const tab = addbox(pos, 0x0000dd, 'tabb', dim, { rotate: rot });
const tab = addbox(pos, boxColor(), 'tabb', dim, { rotate: rot, opacity: boxOpacity() });
return { pos, dim, rot, tab, width: camTabsWidth, height: camTabsHeight };
}
@ -1197,8 +1205,8 @@ function addWidgetTab(widget, rec) {
// prevent duplicate restore from repeated settings load calls
if (!tabs[id]) {
pos.box = addbox(
pos, 0x0000dd, id,
dim, { group: widget.mesh, rotate: rot }
pos, boxColor(), id,
dim, { group: widget.mesh, rotate: rot, opacity: boxOpacity() }
);
pos.box.tab = Object.assign({widget, id}, pos);
widget.adds.push(pos.box);
@ -1228,6 +1236,18 @@ function clearTabs(widget, skiprec) {
}
}
function updateTabs() {
// update tab color and opacity
API.widgets.all().forEach(widget => {
Object.values(widget.tabs || {}).forEach(rec => {
for (let rec of widget.adds || []) {
rec.material.color = new THREE.Color(boxColor());
rec.material.opacity = boxOpacity();
}
});
});
}
function unselectTraces(widget, skip) {
if (widget.trace_stack) {
widget.trace_stack.meshes.forEach(mesh => {
@ -1256,8 +1276,17 @@ function validateTools(tools) {
}
function addbox() { return FDM.addbox(...arguments)};
function delbox() { return FDM.delbox(...arguments)};
function boxColor() {
return API.space.is_dark() ? 0x00ddff : 0x0000dd;
}
function boxOpacity() {
return API.space.is_dark() ? 0.75 : 0.6;
}
function animate() {
isAnimate = true;
API.widgets.opacity(isParsed ? 0 : 0.75);

View file

@ -32,6 +32,7 @@ class Topo {
bounds = widget.getBoundingBox().clone(),
tolerance = contour.tolerance,
flatness = contour.flatness || 0.005,
bridge = contour.bridging || 10,
proc = settings.process,
shadow = tshadow,
minX = bounds.min.x,
@ -148,7 +149,9 @@ class Topo {
// todo: merge co-linear, not just co-planar
if (lastP && Math.abs(lastP.z - z) < flatness) {
if (curvesOnly) {
end_poly();
if ((newtrace.last() || lastP).distTo2D(newP) >= bridge) {
end_poly();
}
} else {
latent = newP;
}

View file

@ -665,7 +665,7 @@ function addbox(point, color, name, dim = {x:1,y:1,z:1,rz:0}, opt = {}) {
new BoxGeometry(dim.x, dim.y, dim.z),
new MeshPhongMaterial({
transparent: true,
opacity: 0.5,
opacity: opt.opacity || 0.5,
color
})
);

View file

@ -534,6 +534,7 @@ const conf = exports({
camFastFeedZ: 300,
camTolerance: 0,
camFlatness: 0.001,
camContourBridge: 10,
camStockX: 5,
camStockY: 5,
camStockZ: 0,

View file

@ -600,6 +600,8 @@ self.kiri.lang['en-us'] = {
ou_toll_l: ["surface precision","in workspace units","lower is slower and","uses more memory","0 = automatic based","on animate preference"],
ou_flat_s: "flatness",
ou_flat_l: ["delta z below which two adjacent","points are considered co-linear"],
ou_brdg_s: "bridging",
ou_brdg_l: ["flat distance between curved","areas to bridge with a cut"],
ou_zanc_s: "z anchor",
ou_zanc_l: ["controls the position of the part","when stock Z exceeds part Z"],
ou_ztof_s: "z offset",