diff --git a/css/main.css b/css/main.css index deace9aaaffec49775f21ca96dbf08557a1cbeed..d8f6dc1ce1d1d077f2a3697278516d98578d7dbb 100644 --- a/css/main.css +++ b/css/main.css @@ -466,3 +466,7 @@ label { position: absolute; left: 245px; } + +.assemblerTree{ + margin-left: 30px; +} \ No newline at end of file diff --git a/js/cam/Cam.js b/js/cam/Cam.js index cf40bd4197e2fd7b84cf3935959121fdb6dc2aee..329816e89b4ed97a15e48f19d2a6c5386a3eaec0 100644 --- a/js/cam/Cam.js +++ b/js/cam/Cam.js @@ -69,7 +69,7 @@ define(['underscore', 'three', 'backbone', 'appState', 'latticeCAM', 'threeModel "change:rapidHeight " + "change:machineName", this._setNeedsPostProcessing); - this.listenTo(lattice, + this.listenTo(lattice,//todo this isn't working "change:scale" + "change:units" + "change:numCells " + @@ -81,6 +81,7 @@ define(['underscore', 'three', 'backbone', 'appState', 'latticeCAM', 'threeModel this.listenTo(lattice, "change:partType", this._updatePartType); this.listenTo(appState, "change:cellMode", this._updateCellMode); this.listenTo(this, "change:machineName", this.selectMachine); + this.listenTo(this, "change:editingComponent", this._editComponent); this._navChanged(); // this._initOriginAndStock(); @@ -181,6 +182,11 @@ define(['underscore', 'three', 'backbone', 'appState', 'latticeCAM', 'threeModel three.render(); }, + _editComponent: function(){ + var componentId = this.get("editingComponent"); + if (componentId) this.get("assembler").highlight(componentId); + }, + @@ -193,7 +199,8 @@ define(['underscore', 'three', 'backbone', 'appState', 'latticeCAM', 'threeModel isVisible: function(){ var currentTab = appState.get("currentTab"); - return (currentTab == "assemblerSetup" || currentTab == "cam" || currentTab == "animate" || currentTab == "send"); + return (currentTab == "assemblerSetup" || currentTab == "cam" || currentTab == "animate" || currentTab == "send" + || currentTab == "editComponent"); }, diff --git a/js/cam/assemblers/Assembler.js b/js/cam/assemblers/Assembler.js index e1f3cf201d705fda327e443dac6b09623e1f4c4c..cd1915b5d7a08adda280be7551e078ac84111548 100644 --- a/js/cam/assemblers/Assembler.js +++ b/js/cam/assemblers/Assembler.js @@ -5,7 +5,7 @@ define(['underscore', 'appState', 'lattice', 'stlLoader', 'threeModel', 'cam', 'component', 'stockComponent'], function(_, appState, lattice, THREE, three, cam, Component, StockComponent){ - var assemblerMaterial = new THREE.MeshLambertMaterial({color:0xaaaaaa, shading: THREE.FlatShading, transparent:true, opacity:0.5}); + var assemblerMaterial = new THREE.MeshLambertMaterial({color:0xaaaaaa, shading: THREE.FlatShading, transparent:true, opacity:0.3}); var stlLoader = new THREE.STLLoader(); function Assembler(id, json){ @@ -75,7 +75,7 @@ define(['underscore', 'appState', 'lattice', 'stlLoader', 'threeModel', 'cam', ' console.warn("no geometry loaded for " + filename); return; } - components[id].makeGeometry(geo, assemblerMaterial); + components[id].makeGeometry(geo, assemblerMaterial.clone()); }); }); }; @@ -103,9 +103,22 @@ define(['underscore', 'appState', 'lattice', 'stlLoader', 'threeModel', 'cam', ' this._setTranslucent(); three.render(); }; + + Assembler.prototype.highlight = function(componentId){ + this.components[componentId].setTranslucent(false); + }; Assembler.prototype._setTranslucent = function(){ - assemblerMaterial.transparent = (appState.get("currentTab") == "cam" || appState.get("currentTab") == "assemblerSetup"); + var currentTab = appState.get("currentTab"); + var translucent = currentTab == "cam" || currentTab == "assemblerSetup"; + if (currentTab == "editComponent") return; + _.each(this.components, function(component){ + component.setTranslucent(translucent); + }); + }; + + Assembler.prototype.buildComponentTree = function(){ + }; @@ -302,8 +315,13 @@ define(['underscore', 'appState', 'lattice', 'stlLoader', 'threeModel', 'cam', ' _.each(this.components, function(component, id){ componentsJSON[id] = component.toJSON(); }); + var stockJSON = {}; + _.each(this.stock, function(thisStock, id){ + stockJSON[id] = thisStock.toJSON(); + }); return { components: componentsJSON, + stock: stockJSON, translation: this.translation, scale: this.scale, rotation: this.rotation, diff --git a/js/cam/assemblers/Component.js b/js/cam/assemblers/Component.js index 1a9b0b2b886ba89079eddbf0d3331b18fd534256..2495e3acf97858fa3d8e5757bdb28a2e4f0c5776 100644 --- a/js/cam/assemblers/Component.js +++ b/js/cam/assemblers/Component.js @@ -19,7 +19,8 @@ define(['underscore', 'cam', 'three'], function(_, cam, THREE){ Component.prototype.makeGeometry = function(geo, material){ - this.object3D.add(new THREE.Mesh(geo, material)); + this.stl = new THREE.Mesh(geo, material); + this.object3D.add(this.stl); }; Component.prototype.addChild = function(child){ @@ -65,6 +66,12 @@ define(['underscore', 'cam', 'three'], function(_, cam, THREE){ return this.id; }; + Component.prototype.setTranslucent = function(translucent){ + if (this.stl === undefined) return; + this.stl.material.transparent = translucent; + }; + + //simulation animation diff --git a/js/menus/templates/AssemblerSetupMenuView.html b/js/menus/templates/AssemblerSetupMenuView.html index 356e7d4a6008302be946073d318161a8ab90a023..be82d513df022de6c6526891616fee4818293f40 100644 --- a/js/menus/templates/AssemblerSetupMenuView.html +++ b/js/menus/templates/AssemblerSetupMenuView.html @@ -1,11 +1,11 @@ Parent/Child Tree:<br/> <% _.each(components, function(component){ %> - <%= component.name %> <a data-id="<%= component.id %>" class="editMachineComponent" href="#">Edit</a><br/> + <label class="assemblerTree"><%= component.name %> <a data-id="<%= component.id %>" class="editMachineComponent" href="#">Edit</a></label><br/> <% }); %><br/> <a href="#" id="newMachineComponent" class=" btn btn-block btn-lg btn-default">+ New Machine Component</a><br/> Stock:<br/> <% _.each(stock, function(stockEl, id){ %> - <%= stockEl.name %> <a data-id="<%= id %>" class="edit Stock" href="#">Edit</a><br/> + <label class="assemblerTree"><%= stockEl.name %> <a data-id="<%= id %>" class="edit Stock" href="#">Edit</a></label><br/> <% }); %><br/> <a href="#" id="addStock" class=" btn btn-block btn-lg btn-default">+ New Stock</a><br/> Offset (xyz):