From 4d174169fe74213ae1c5db3d98492b5e292079be Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Wed, 25 Nov 2020 09:10:00 -0500 Subject: [PATCH] add widget metadata display --- notes.md | 9 +++++---- src/kiri/main.js | 21 ++++++++++++++++++++- src/kiri/widget.js | 32 ++++++++++++++++++++++---------- web/kiri/index.css | 11 +++++++++-- web/kiri/index.html | 1 + 5 files changed, 57 insertions(+), 17 deletions(-) diff --git a/notes.md b/notes.md index 9d70e394..a55b3c82 100644 --- a/notes.md +++ b/notes.md @@ -11,13 +11,14 @@ * drag knife support * all * 2d image to 3d part +* memory optimization (worker and client proactive cleanup) * circular fit/layout when no-layout to prevent collisions ## `C` cosmetic, `F` functional, `P` performance, `B` bug fix * `F` 2D image import * `F` detect and report slow framerates -* `F` implement an in-app bug reporting system +* `F` right click / context menu (object deletion, etc) * `P` improve decimation speed by avoiding in/out of Point? * `P` duplicate objects should share same slice data unless rotated or scaled * `P` worker state cache cleanup and organization @@ -25,16 +26,16 @@ # FDM +* `B` sparse infill should follow polys between intersect points * `B` expand > 0 producing artifacts with manual supports * `B` fix adaptive slicing with multi-extruder * `B` fix supports with grouped parts -* `B` sparse infill should follow polys between intersect points * `B` multi-extruder rendering of raft fails to offset the rest of the print * `B` multi-extruder purge blocks fail to generate properly for rafts +* `F` control layer start position +* `F` redo auto supports to use poly faces rather than deltas * `F` control for size of purge block (with 0=disabled) * `F` add separate fill speed control -* `F` manual support addition / control -* `F` control layer start position * `F` polishing and other non-planar work * `F` gradient infill https://www.youtube.com/watch?v=hq53gsYREHU&feature=emb_logo * `F` feather sharp tips by reducing extrusion in area of overlap diff --git a/src/kiri/main.js b/src/kiri/main.js index 8818f23e..a4ede5b3 100644 --- a/src/kiri/main.js +++ b/src/kiri/main.js @@ -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}
${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); diff --git a/src/kiri/widget.js b/src/kiri/widget.js index 84443250..541dc536 100644 --- a/src/kiri/widget.js +++ b/src/kiri/widget.js @@ -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); } }; diff --git a/web/kiri/index.css b/web/kiri/index.css index bb69350d..cac8ef1a 100644 --- a/web/kiri/index.css +++ b/web/kiri/index.css @@ -1142,8 +1142,15 @@ th, tr, td, label { } #fps { position: fixed; - right: 5px; - bottom: 5px; font-size: 10px; + bottom: 5px; + right: 5px; + color: #000; +} +#winfo { + position: fixed; + font-size: 10px; + bottom: 5px; + left: 5px; color: #000; } diff --git a/web/kiri/index.html b/web/kiri/index.html index 6fa569ce..80f1ffda 100644 --- a/web/kiri/index.html +++ b/web/kiri/index.html @@ -389,6 +389,7 @@
+