From 93ff684806c4af90518357b1904d4e4fb366ef45 Mon Sep 17 00:00:00 2001 From: Val Erastov Date: Wed, 4 Nov 2015 00:29:21 -0800 Subject: [PATCH] disable/enable showing the sketches --- web/app/3d/ctrl.js | 15 +++++++++++++-- web/app/3d/main.js | 6 ++++++ web/app/ui/toolkit.js | 9 +++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/web/app/3d/ctrl.js b/web/app/3d/ctrl.js index cb945f91..d5790206 100644 --- a/web/app/3d/ctrl.js +++ b/web/app/3d/ctrl.js @@ -11,13 +11,13 @@ TCAD.UI = function(app) { var cameraFolder = new tk.Folder("Camera"); var objectsFolder = new tk.Folder("Objects"); var modificationsFolder = new tk.Folder("Modifications"); - var extrude, cut, edit, refreshSketches, printSolids, printFace, printFaceId; + var extrude, cut, edit, refreshSketches, showSketches, printSolids, printFace, printFaceId; tk.add(mainBox, propFolder); tk.add(propFolder, extrude = new tk.Button("Extrude")); tk.add(propFolder, cut = new tk.Button("Cut")); tk.add(propFolder, edit = new tk.Button("Edit")); tk.add(propFolder, refreshSketches = new tk.Button("Refresh Sketches")); - tk.add(propFolder, new tk.Text("Message")); + tk.add(propFolder, showSketches = new tk.CheckBox("Show Sketches", true)); tk.add(mainBox, debugFolder); tk.add(debugFolder, printSolids = new tk.Button("Print Solids")); tk.add(debugFolder, printFace = new tk.Button("Print Face")); @@ -128,6 +128,17 @@ TCAD.UI = function(app) { printFaceId.root.click(function () { console.log(app.viewer.selectionMgr.selection[0].id); }); + showSketches.input.click(function () { + var enabled = this.checked; + var solids = app.findAllSolids(); + for (var i = 0; i < solids.length; i++) { + for (var j = 0; j < solids[i].polyFaces.length; j++) { + var face = solids[i].polyFaces[j]; + face.sketch3DGroup.visible = enabled; + } + } + app.viewer.render(); + }); this.solidFolder = null; }; diff --git a/web/app/3d/main.js b/web/app/3d/main.js index 28b09968..a4d3225a 100644 --- a/web/app/3d/main.js +++ b/web/app/3d/main.js @@ -51,6 +51,12 @@ TCAD.App = function() { window.addEventListener('storage', storage_handler, false); }; +TCAD.App.prototype.findAllSolids = function() { + return this.viewer.scene.children + .filter(function(obj) {return !!obj.geometry && obj.geometry.tCadId !== undefined} ) + .map(function(obj) {return obj.geometry} ) +}; + TCAD.App.prototype.findFace = function(faceId) { var solidId = faceId.split(":")[0]; var children = this.viewer.scene.children; diff --git a/web/app/ui/toolkit.js b/web/app/ui/toolkit.js index 8ceb7bce..c4176782 100644 --- a/web/app/ui/toolkit.js +++ b/web/app/ui/toolkit.js @@ -32,6 +32,15 @@ TCAD.toolkit.Button = function(title) { {class: 'tc-row tc-ctrl tc-ctrl-btn', text: title}); }; +TCAD.toolkit.CheckBox = function(title, checked) { + this.root = $('
', + {class: 'tc-row tc-ctrl tc-ctrl-btn'}); + this.root.append('') + this.input = this.root.find("input"); + this.input.prop('checked', !!checked); + console.log(this.input); +}; + TCAD.toolkit.propLayout = function(root, name, valueEl) { root.append($('', {class: 'tc-prop-name', text: name})) .append($('
', {class: 'tc-prop-value'})