add widget metadata display
This commit is contained in:
parent
dd315aac40
commit
4d174169fe
5 changed files with 56 additions and 16 deletions
|
|
@ -67,6 +67,7 @@
|
|||
|
||||
const feature = {
|
||||
seed: true,
|
||||
meta: true, // show selected widget metadata
|
||||
controls: true, // show or not side menus
|
||||
drop_group: undefined, // optional array to group multi drop
|
||||
drop_layout: true, // layout on new drop
|
||||
|
|
@ -1154,10 +1155,27 @@
|
|||
let selcount = platform.selected_count();
|
||||
let extruders = settings.device.extruders;
|
||||
let menu_show = selcount ? 'flex': '';
|
||||
$('winfo').style.display = 'none';
|
||||
if (selcount) {
|
||||
UI.scale.classList.add('lt-enabled');
|
||||
UI.rotate.classList.add('lt-enabled');
|
||||
UI.nozzle.classList.add('lt-enabled');
|
||||
if (feature.meta && selcount === 1) {
|
||||
let sel = selection.widgets()[0];
|
||||
let name = sel.meta.file || sel.meta.url;
|
||||
if (name) {
|
||||
name = name
|
||||
.toLowerCase()
|
||||
.replace(/_/g,' ')
|
||||
.replace(/.stl/,'');
|
||||
let sp = name.indexOf('/');
|
||||
if (sp >= 0) {
|
||||
name = name.substring(sp + 1);
|
||||
}
|
||||
$('winfo').style.display = 'flex';
|
||||
$('winfo').innerHTML = `${sel.meta.vertices}<br>${name}`;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
UI.scale.classList.remove('lt-enabled');
|
||||
UI.rotate.classList.remove('lt-enabled');
|
||||
|
|
@ -1210,6 +1228,7 @@
|
|||
ajax(url, function(vertices) {
|
||||
vertices = js2o(vertices).toFloat32();
|
||||
let widget = newWidget().loadVertices(vertices);
|
||||
widget.meta.url = url;
|
||||
platform.add(widget);
|
||||
if (onload) onload(vertices, widget);
|
||||
});
|
||||
|
|
@ -1220,7 +1239,7 @@
|
|||
new MOTO.STL().load(url, function(vertices, filename) {
|
||||
if (vertices) {
|
||||
let widget = newWidget().loadVertices(vertices);
|
||||
widget.filename = filename;
|
||||
widget.meta.file = filename;
|
||||
platform.add(widget);
|
||||
if (onload) {
|
||||
onload(vertices, widget);
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@
|
|||
}
|
||||
// rotation stack (for undo)
|
||||
this.roto = [];
|
||||
// added meshes
|
||||
// added meshes (supports, tabs, etc)
|
||||
this.adds = [];
|
||||
// THREE Mesh and points
|
||||
this.mesh = null;
|
||||
|
|
@ -154,8 +154,13 @@
|
|||
load_time: 0,
|
||||
progress: 0
|
||||
};
|
||||
this.saved = false;
|
||||
this.support = false; // is synthesized support widget
|
||||
this.meta = {
|
||||
url: null,
|
||||
file: null,
|
||||
saved: false
|
||||
};
|
||||
// if this is a synthesized support widget
|
||||
this.support = false;
|
||||
}
|
||||
|
||||
/** ******************************************************************
|
||||
|
|
@ -164,7 +169,9 @@
|
|||
|
||||
Widget.loadFromCatalog = function(filename, ondone) {
|
||||
KIRI.catalog.getFile(filename, function(data) {
|
||||
ondone(newWidget().loadVertices(data));
|
||||
let widget = newWidget().loadVertices(data);
|
||||
widget.meta.file = filename;
|
||||
ondone(widget);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -175,8 +182,9 @@
|
|||
track = data.track || undefined,
|
||||
group = data.group || id,
|
||||
widget = newWidget(id, Group.forid(group)),
|
||||
meta = data.meta || widget.meta,
|
||||
ptr = widget.loadVertices(vertices);
|
||||
widget.saved = time();
|
||||
widget.meta = meta;
|
||||
// restore widget position if specified
|
||||
if (move && track && track.pos) {
|
||||
widget.track = track;
|
||||
|
|
@ -200,7 +208,8 @@
|
|||
PRO.saveToCatalog = function(filename) {
|
||||
let widget = this;
|
||||
let time = UTIL.time();
|
||||
widget.filename = filename;
|
||||
widget.meta.file = filename;
|
||||
widget.meta.save = time;
|
||||
KIRI.catalog.putFile(filename, this.getGeoVertices(), function(vertices) {
|
||||
if (vertices && vertices.length) {
|
||||
console.log("saving decimated mesh ["+vertices.length+"] time ["+(UTIL.time()-time)+"]");
|
||||
|
|
@ -213,11 +222,12 @@
|
|||
PRO.saveState = function(ondone) {
|
||||
let widget = this;
|
||||
KIRI.odb.put('ws-save-'+this.id, {
|
||||
geo:widget.getGeoVertices(),
|
||||
track:widget.track,
|
||||
group:this.group.id
|
||||
geo: widget.getGeoVertices(),
|
||||
track: widget.track,
|
||||
group: this.group.id,
|
||||
meta: this.meta
|
||||
}, function(result) {
|
||||
widget.saved = time();
|
||||
widget.meta.saved = time();
|
||||
if (ondone) ondone();
|
||||
});
|
||||
};
|
||||
|
|
@ -233,10 +243,12 @@
|
|||
this.mesh.geometry.computeFaceNormals();
|
||||
this.mesh.geometry.computeVertexNormals();
|
||||
this.points = null;
|
||||
this.meta.vertices = vertices.length / 3;
|
||||
return this;
|
||||
} else {
|
||||
let geometry = new THREE.BufferGeometry();
|
||||
geometry.setAttribute('position', new THREE.BufferAttribute(vertices, 3));
|
||||
this.meta.vertices = vertices.length / 3;
|
||||
return this.loadGeometry(geometry);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue