lift widget duplicate into api and delegate annotations to mode client
This commit is contained in:
parent
3c7dea3626
commit
d648c2948a
4 changed files with 49 additions and 19 deletions
|
|
@ -517,25 +517,7 @@
|
|||
}
|
||||
|
||||
function duplicateSelection() {
|
||||
API.selection.for_widgets(function(widget) {
|
||||
let mesh = widget.mesh;
|
||||
let bb = mesh.getBoundingBox();
|
||||
let ow = widget;
|
||||
let nw = API.widgets.new().loadGeometry(mesh.geometry.clone());
|
||||
nw.meta.file = ow.meta.file;
|
||||
nw.meta.vertices = ow.meta.vertices;
|
||||
nw.move(bb.max.x - bb.min.x + 1, 0, 0);
|
||||
platform.add(nw,true);
|
||||
let owa = API.widgets.annotate(ow.id);
|
||||
let nwa = API.widgets.annotate(nw.id);
|
||||
if (owa.tab) {
|
||||
nwa.tab = Object.clone(owa.tab);
|
||||
nwa.tab.forEach((tab,i) => {
|
||||
tab.id = Date.now() + i
|
||||
});
|
||||
}
|
||||
KIRI.driver.CAM.restoreTabs([nw]);
|
||||
});
|
||||
API.selection.duplicate();
|
||||
}
|
||||
|
||||
function mirrorSelection() {
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@
|
|||
scale: scaleSelection,
|
||||
rotate: rotateSelection,
|
||||
mirror: mirrorSelection,
|
||||
duplicate: duplicateSelection,
|
||||
meshes: function() { return selectedMeshes.slice() },
|
||||
widgets: function(orall) {
|
||||
let sel = selectedMeshes.slice().map(m => m.widget);
|
||||
|
|
@ -1643,6 +1644,21 @@
|
|||
SPACE.update();
|
||||
}
|
||||
|
||||
function duplicateSelection() {
|
||||
API.selection.for_widgets(function(widget) {
|
||||
let mesh = widget.mesh;
|
||||
let bb = mesh.getBoundingBox();
|
||||
let ow = widget;
|
||||
let nw = API.widgets.new().loadGeometry(mesh.geometry.clone());
|
||||
nw.meta.file = ow.meta.file;
|
||||
nw.meta.vertices = ow.meta.vertices;
|
||||
nw.move(bb.max.x - bb.min.x + 1, 0, 0);
|
||||
platform.add(nw,true);
|
||||
nw.anno = ow.annotations();
|
||||
API.event.emit("widget.duplicate", nw, ow);
|
||||
});
|
||||
}
|
||||
|
||||
function mirrorSelection() {
|
||||
API.selection.for_widgets(function(widget) {
|
||||
widget.mirror();
|
||||
|
|
|
|||
|
|
@ -733,6 +733,25 @@
|
|||
func.traceClear();
|
||||
}
|
||||
});
|
||||
api.event.on("widget.duplicate", (widget, oldwidget) => {
|
||||
if (!isCamMode) {
|
||||
return;
|
||||
}
|
||||
if (traceOn) {
|
||||
func.traceDone();
|
||||
}
|
||||
unselectTraces(widget);
|
||||
if (flipping) {
|
||||
return;
|
||||
}
|
||||
let ann = API.widgets.annotate(widget.id);
|
||||
if (ann.tab) {
|
||||
ann.tab.forEach((tab,i) => {
|
||||
tab.id = Date.now() + i;
|
||||
});
|
||||
restoreTabs([widget]);
|
||||
}
|
||||
});
|
||||
api.event.on("widget.mirror", widget => {
|
||||
if (!isCamMode) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -322,6 +322,18 @@
|
|||
return;
|
||||
}
|
||||
});
|
||||
api.event.on("widget.duplicate", (widget, oldwidget) => {
|
||||
if (!isFdmMode) {
|
||||
return;
|
||||
}
|
||||
let ann = API.widgets.annotate(widget.id);
|
||||
if (ann.support) {
|
||||
for (let supp of Object.values(ann.support)) {
|
||||
supp.id = Math.abs(Math.random() * 0xffffffffffff);
|
||||
}
|
||||
restoreSupports([widget]);
|
||||
}
|
||||
});
|
||||
api.event.on("widget.mirror", widget => {
|
||||
if (!isFdmMode) {
|
||||
return;
|
||||
|
|
@ -670,5 +682,6 @@
|
|||
|
||||
FDM.delbox = delbox;
|
||||
FDM.addbox = addbox;
|
||||
FDM.restoreSupports = restoreSupports;
|
||||
|
||||
})();
|
||||
|
|
|
|||
Loading…
Reference in a new issue