diff --git a/js/lattice/Lattice.js b/js/lattice/Lattice.js index a4086e6971e8e32b45852b52696fbfb82cb0c59f..d44739c66f7cdb0c7a0c50d61942156f76db8980 100644 --- a/js/lattice/Lattice.js +++ b/js/lattice/Lattice.js @@ -3,7 +3,7 @@ */ -define(['appState', 'plist', 'three'], function(appState, plist, THREE){ +define(['appState', 'plist', 'three', 'threeModel'], function(appState, plist, THREE, three){ var Lattice = Backbone.Model.extend({ @@ -73,7 +73,7 @@ define(['appState', 'plist', 'three'], function(appState, plist, THREE){ } } } - globals.three.render(); + three.render(); return newCells; }, @@ -86,7 +86,7 @@ define(['appState', 'plist', 'three'], function(appState, plist, THREE){ if (!cells[index.x][index.y][index.z]) { cells[index.x][index.y][index.z] = this.makeCellForLatticeType(indices); this.set("numCells", this.get("numCells")+1); - if (!noRender) globals.three.render(); + if (!noRender) three.render(); } else console.warn("already a cell there"); }, @@ -126,7 +126,7 @@ define(['appState', 'plist', 'three'], function(appState, plist, THREE){ //todo shrink cells matrix if needed this.set("numCells", this.get("numCells")-1); - globals.three.render(); + three.render(); }, //todo send clear all to three and destroy without sceneRemove to cell @@ -140,7 +140,7 @@ define(['appState', 'plist', 'three'], function(appState, plist, THREE){ this.set("nodes", []); this.set("numCells", 0); if (globals.basePlane) globals.basePlane.set("zIndex", 0); - globals.three.render(); + three.render(); }, calculateBoundingBox: function(){ @@ -193,7 +193,7 @@ define(['appState', 'plist', 'three'], function(appState, plist, THREE){ } } - globals.three.render(); + three.render(); }, _findIntersectionsInWindow: function(windowX, windowY, origin, allVertexPos){ @@ -321,7 +321,7 @@ define(['appState', 'plist', 'three'], function(appState, plist, THREE){ this._iterCells(this.get("cells"), function(cell){ if (cell) cell.setMode(cellMode); }); - globals.three.render(); + three.render(); }, _updateCellSeparation: function(){ @@ -333,7 +333,7 @@ define(['appState', 'plist', 'three'], function(appState, plist, THREE){ this._iterCells(this.get("cells"), function(cell){ if (cell) cell.updateForScale(cellMode, partType); }); - globals.three.render(); + three.render(); }, _setCellVisibility: function(){ @@ -346,7 +346,7 @@ define(['appState', 'plist', 'three'], function(appState, plist, THREE){ this._iterCells(this.get("cells"), function(cell){ if (cell) cell.hide(); }); - globals.three.render(); + three.render(); }, showCells: function(){ @@ -354,7 +354,7 @@ define(['appState', 'plist', 'three'], function(appState, plist, THREE){ this._iterCells(this.get("cells"), function(cell){ if (cell) cell.show(cellMode) }); - globals.three.render(); + three.render(); }, showCellAtIndex: function(index){ @@ -416,7 +416,7 @@ define(['appState', 'plist', 'three'], function(appState, plist, THREE){ //} cells[x][y][z] = newCell; }); - globals.three.render(); + three.render(); }, _getSubclassForLatticeType: function(loadingFromFile){ diff --git a/js/main.js b/js/main.js index b78dd18e1c2dbb9f4a1579c58a8bfb96d84d9d87..be57e720a74d04764bf931f45ac51a6391a2315d 100644 --- a/js/main.js +++ b/js/main.js @@ -27,7 +27,19 @@ requirejs.config({ //UI menuWrapper: 'menus/MenuWrapperView', menuParent: 'menus/MenuParentView', - latticeMenu: 'menus/LatticeMenuView' + latticeMenu: 'menus/LatticeMenuView', + importMenu: 'menus/LatticeMenuView', + partMenu: 'menus/PartMenuView', + scriptMenu: 'menus/ScriptMenuView', + physicsMenu: 'menus/PhysicsMenuView', + materialMenu: 'menus/MaterialMenuView', + optimizeMenu: 'menus/OptimizationMenuView', + assemblerMenu: 'menus/AssemblerMenuView', + camMenu: 'menus/CamMenuView', + animateMenu: 'menus/AnimationMenuView', + sendMenu: 'menus/SendMenuView' + + }, shim: { three: { diff --git a/js/menus/LatticeMenuView.js b/js/menus/LatticeMenuView.js index 4ef8a2ed13de705b9f98c37fa0b750eaf4c8cd13..0a639d4f51003cee11107131e7939952371c1ebe 100644 --- a/js/menus/LatticeMenuView.js +++ b/js/menus/LatticeMenuView.js @@ -4,7 +4,7 @@ define(['menuParent', 'lattice', 'plist'], function(MenuParentView, lattice, plist){ - var LatticeMenuView = MenuParentView.extend({ + return MenuParentView.extend({ events: { }, @@ -63,9 +63,6 @@ define(['menuParent', 'lattice', 'plist'], function(MenuParentView, lattice, pli ') }); - - return LatticeMenuView; - }); //Cell Separation <% if (connectionType != "freeformFace"){ %>(xy, z): <input data-type="xy" value="<%= cellSeparation.xy %>" placeholder="XY" class="form-control numberInput cellSeparation" type="text">\ diff --git a/js/menus/MenuParentView.js b/js/menus/MenuParentView.js index b10e530154544a3479eb39561aeebf97d571ef25..8d1a8712cadc0ea0a60b8ed2698ed7cd2a8e4652 100644 --- a/js/menus/MenuParentView.js +++ b/js/menus/MenuParentView.js @@ -5,7 +5,7 @@ define(['backbone'], function(Backbone){ - var MenuParentView = Backbone.View.extend({ + return Backbone.View.extend({ el: "#menuContent", @@ -14,7 +14,4 @@ define(['backbone'], function(Backbone){ } }); - - return MenuParentView; - }); \ No newline at end of file diff --git a/js/menus/PartMenuView.js b/js/menus/PartMenuView.js index 991c2150df3f936519a482c89dd5044f3eaf2c40..a060c611feaea3a4931ae75c427187f45065415a 100644 --- a/js/menus/PartMenuView.js +++ b/js/menus/PartMenuView.js @@ -2,60 +2,63 @@ * Created by aghassaei on 1/26/15. */ -PartMenuView = Backbone.View.extend({ - - el: "#menuContent", - - events: { - }, - - initialize: function(){ - - _.bindAll(this, "render"); - - //bind events - this.listenTo(globals.lattice, "change", this.render); - this.listenTo(globals.appState, "change", this.render); - }, - - render: function(){ - if (this.model.changedAttributes()["currentNav"]) return; - if (this.model.get("currentTab") != "part") return; - if ($("input[type=text]").is(":focus")) return; - this.$el.html(this.template(_.extend(globals.lattice.toJSON(), globals.appState.toJSON(), globals.plist))); - }, - - template: _.template('\ - Part Type: \ - <div class="btn-group">\ - <button data-toggle="dropdown" class="btn dropdown-toggle" type="button"><%= allPartTypes[cellType][connectionType][partType] %><span class="caret"></span></button>\ - <ul role="menu" class="dropdown-menu">\ - <% _.each(_.keys(allPartTypes[cellType][connectionType]), function(key){ %>\ - <li><a class="lattice dropdownSelector" data-property="partType" data-value="<%= key %>" href="#"><%= allPartTypes[cellType][connectionType][key] %></a></li>\ - <% }); %>\ - </ul>\ - </div><br/><br/>\ - <!--Cell Separation <% if (connectionType != "freeformFace"){ %>(xy, z): <input data-property="cellSeparation" data-key="xy" value="<%= cellSeparation.xy %>" placeholder="XY" class="form-control floatInput lattice" type="text">\ - <input data-property="cellSeparation" data-key="z" value="<%= cellSeparation.z %>" placeholder="Z" class="form-control floatInput lattice" type="text">\ - <% } else { %>( radial ): <input data-property="cellSeparation" data-key="xy" value="<%= cellSeparation.xy %>" placeholder="XY" class="form-control floatInput lattice" type="text"><% } %>\ - <br/><br/>--><br/>\ - <% if (allMaterialTypes[cellType][connectionType]){ %> \ - Materials:<br/>\ - <% _.each(_.keys(allMaterialTypes[cellType][connectionType]), function(key){ %>\ - <label class="radio colorSwatches">\ - <input type="radio" <%if (key == materialType){ %>checked<%}%> name="materialType" value="<%= key %>" data-toggle="radio" class="custom-radio lattice"><span class="icons"><span class="icon-unchecked"></span><span class="icon-checked"></span></span>\ - <div class="materialColorSwatch">\ - <div style="background-color:<% if(realisticColorScheme){ %><%= allMaterialTypes[cellType][connectionType][key].color %><% }else{ %><%= allMaterialTypes[cellType][connectionType][key].altColor %><% } %>"></div>\ - <span><%= allMaterialTypes[cellType][connectionType][key].name %></span></div>\ - </label>\ - <% }); %>\ - <br/>\ - <label class="checkbox" for="realisticColorScheme">\ - <input id="realisticColorScheme" data-property="realisticColorScheme" type="checkbox" <% if (realisticColorScheme){ %> checked="checked"<% } %> value="" data-toggle="checkbox" class="appState custom-checkbox">\ - <span class="icons"><span class="icon-unchecked"></span><span class="icon-checked"></span></span>\ - Use realistic color scheme</label>\ - <% } %>\ - <br/>\ - ') +define(['menuParent', 'lattice', 'plist'], function(MenuParentView, lattice, plist){ + return MenuParentView({ + + el: "#menuContent", + + events: { + }, + + initialize: function(){ + + _.bindAll(this, "render"); + + //bind events + this.listenTo(lattice, "change", this.render); + this.listenTo(this.model, "change", this.render); + }, + + render: function(){ + if (this.model.changedAttributes()["currentNav"]) return; + if (this.model.get("currentTab") != "part") return; + if ($("input[type=text]").is(":focus")) return; + this.$el.html(this.template(_.extend(lattice.toJSON(), this.model.toJSON(), plist))); + }, + + template: _.template('\ + Part Type: \ + <div class="btn-group">\ + <button data-toggle="dropdown" class="btn dropdown-toggle" type="button"><%= allPartTypes[cellType][connectionType][partType] %><span class="caret"></span></button>\ + <ul role="menu" class="dropdown-menu">\ + <% _.each(_.keys(allPartTypes[cellType][connectionType]), function(key){ %>\ + <li><a class="lattice dropdownSelector" data-property="partType" data-value="<%= key %>" href="#"><%= allPartTypes[cellType][connectionType][key] %></a></li>\ + <% }); %>\ + </ul>\ + </div><br/><br/>\ + <!--Cell Separation <% if (connectionType != "freeformFace"){ %>(xy, z): <input data-property="cellSeparation" data-key="xy" value="<%= cellSeparation.xy %>" placeholder="XY" class="form-control floatInput lattice" type="text">\ + <input data-property="cellSeparation" data-key="z" value="<%= cellSeparation.z %>" placeholder="Z" class="form-control floatInput lattice" type="text">\ + <% } else { %>( radial ): <input data-property="cellSeparation" data-key="xy" value="<%= cellSeparation.xy %>" placeholder="XY" class="form-control floatInput lattice" type="text"><% } %>\ + <br/><br/>--><br/>\ + <% if (allMaterialTypes[cellType][connectionType]){ %> \ + Materials:<br/>\ + <% _.each(_.keys(allMaterialTypes[cellType][connectionType]), function(key){ %>\ + <label class="radio colorSwatches">\ + <input type="radio" <%if (key == materialType){ %>checked<%}%> name="materialType" value="<%= key %>" data-toggle="radio" class="custom-radio lattice"><span class="icons"><span class="icon-unchecked"></span><span class="icon-checked"></span></span>\ + <div class="materialColorSwatch">\ + <div style="background-color:<% if(realisticColorScheme){ %><%= allMaterialTypes[cellType][connectionType][key].color %><% }else{ %><%= allMaterialTypes[cellType][connectionType][key].altColor %><% } %>"></div>\ + <span><%= allMaterialTypes[cellType][connectionType][key].name %></span></div>\ + </label>\ + <% }); %>\ + <br/>\ + <label class="checkbox" for="realisticColorScheme">\ + <input id="realisticColorScheme" data-property="realisticColorScheme" type="checkbox" <% if (realisticColorScheme){ %> checked="checked"<% } %> value="" data-toggle="checkbox" class="appState custom-checkbox">\ + <span class="icons"><span class="icon-unchecked"></span><span class="icon-checked"></span></span>\ + Use realistic color scheme</label>\ + <% } %>\ + <br/>\ + ') + + }); }); \ No newline at end of file diff --git a/js/models/PList.js b/js/models/PList.js index 7f87f81bf05ab4889abee4f750b6cdb6dba06a1b..b19973349df997734172545e1108acb6af460142 100644 --- a/js/models/PList.js +++ b/js/models/PList.js @@ -15,15 +15,15 @@ define(['three'], function(THREE){ }, navSim:{ physics:"Physics", - part:"Part", - material:"Material", - optimize:"Optimize" + part:"Part", + material:"Material", + optimize:"Optimize" }, navAssemble:{ assembler:"Assembler", - cam: "Process", - animate:"Preview", - send: "Send" + cam: "Process", + animate:"Preview", + send: "Send" } }, diff --git a/js/three/ThreeView.js b/js/three/ThreeView.js index 4bc5b80357f99fbf303d9e4ac3fae5f6a1b6e554..39de47c1c500ad79ffb960cac64a4a12592e4cfb 100644 --- a/js/three/ThreeView.js +++ b/js/three/ThreeView.js @@ -2,7 +2,7 @@ * Created by aghassaei on 1/16/15. */ -define(['backbone', 'threeModel', 'orbitControls', 'appState'], function(Backbone, threeModel, THREE, appState){ +define(['backbone', 'threeModel', 'orbitControls', 'appState'], function(Backbone, three, THREE, appState){ var ThreeView = Backbone.View.extend({ @@ -154,6 +154,6 @@ define(['backbone', 'threeModel', 'orbitControls', 'appState'], function(Backbon }); - return new ThreeView({model:threeModel}); + return new ThreeView({model:three}); }); \ No newline at end of file