disable/enable showing the sketches

This commit is contained in:
Val Erastov 2015-11-04 00:29:21 -08:00
parent e97a7ba206
commit 93ff684806
3 changed files with 28 additions and 2 deletions

View file

@ -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;
};

View file

@ -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;

View file

@ -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 = $('<div/>',
{class: 'tc-row tc-ctrl tc-ctrl-btn'});
this.root.append('<label><input type="checkbox">' + title + '</label>')
this.input = this.root.find("input");
this.input.prop('checked', !!checked);
console.log(this.input);
};
TCAD.toolkit.propLayout = function(root, name, valueEl) {
root.append($('<span/>', {class: 'tc-prop-name', text: name}))
.append($('<div/>', {class: 'tc-prop-value'})