From 6fa0fddb9ea5e94570f31d077819d8e7f37ed557 Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Tue, 10 Mar 2015 23:12:49 -0400 Subject: [PATCH] cam menu and other small fixes --- js/menus/CamMenuView.js | 45 ++++++++++++++++++++++++++++++++ js/menus/LatticeMenuView.js | 11 +------- js/menus/MenuWrapperView.js | 3 +++ js/menus/OptimizationMenuView.js | 7 ----- js/models/AppState.js | 6 +++++ main.html | 1 + 6 files changed, 56 insertions(+), 17 deletions(-) create mode 100644 js/menus/CamMenuView.js diff --git a/js/menus/CamMenuView.js b/js/menus/CamMenuView.js new file mode 100644 index 00000000..b37ecab9 --- /dev/null +++ b/js/menus/CamMenuView.js @@ -0,0 +1,45 @@ +/** + * Created by aghassaei on 1/26/15. + */ + + +CamMenuView = Backbone.View.extend({ + + el: "#menuContent", + + events: { + "click .camProcess": "_selectCamProcess" + }, + + + initialize: function(options){ + + this.lattice = options.lattice; + + _.bindAll(this, "render"); + this.listenTo(this.model, "change", this.render); + }, + + _selectCamProcess: function(e){ + e.preventDefault(); + this.model.set("camProcess", $(e.target).data("type")); + }, + + render: function(){ + if (this.model.get("currentTab") != "cam") return; + this.$el.html(this.template(_.extend(this.model.attributes))); + }, + + template: _.template('\ + CAM output: \ + <div class="btn-group">\ + <button data-toggle="dropdown" class="btn dropdown-toggle" type="button"><%= allCamProcesses[camProcess] %><span class="caret"></span></button>\ + <ul role="menu" class="dropdown-menu">\ + <% _.each(_.keys(allCamProcesses), function(key){ %>\ + <li><a class="camProcess" data-type="<%= key %>" href="#"><%= allCamProcesses[key] %></a></li>\ + <% }); %>\ + </ul>\ + </div><br/><br/>\ + ') + +}); \ No newline at end of file diff --git a/js/menus/LatticeMenuView.js b/js/menus/LatticeMenuView.js index 8d123555..7dfe0600 100644 --- a/js/menus/LatticeMenuView.js +++ b/js/menus/LatticeMenuView.js @@ -25,14 +25,7 @@ LatticeMenuView = Backbone.View.extend({ this.lattice = options.lattice; _.bindAll(this, "render"); -// var self = this; -// this.listenTo(this.model, "change", function(){ -// var change = false; -// _.each(_.keys(self.model.changedAttributes()), function(attribute){ -// if (attribute != "currentNav" && attribute != "currentTab") change = true; -// }); -// if (change) this.render(); -// }); + this.listenTo(this.lattice, "change", this.render); }, @@ -84,8 +77,6 @@ LatticeMenuView = Backbone.View.extend({ newConnectionType = _.keys(dmaGlobals.appState.get("allConnectionTypes")[newCellType])[0]; this.lattice.set("connectionType", newConnectionType, {silent:true}); } - this.model.set("connectionType", newConnectionType, {silent:true}); - var partType = _.keys(dmaGlobals.appState.get("allPartTypes")[newCellType][newConnectionType])[0]; this.lattice.set("partType", partType, {silent:true}); }, diff --git a/js/menus/MenuWrapperView.js b/js/menus/MenuWrapperView.js index fb6c4840..40d64b35 100644 --- a/js/menus/MenuWrapperView.js +++ b/js/menus/MenuWrapperView.js @@ -28,6 +28,7 @@ MenuWrapper = Backbone.View.extend({ this.optimizeMenu = new OptimizationMenuView({model:this.model}); this.assemblerMenu = new AssemblerMenuView({model:this.model}); this.animationMenu = new AnimationMenuView({model:lattice.get("basePlane"), appState:this.model}); + this.camMenu = new CamMenuView({model:this.model, lattice:lattice}); //data names and titles this.designMenuTabs = {lattice:"Lattice", import:"Import", sketch:"Sketch", part:"Part", script:"Script"}; @@ -80,6 +81,8 @@ MenuWrapper = Backbone.View.extend({ this.assemblerMenu.render(); } else if (tabName == "animate"){ this.animationMenu.render(); + } else if (tabName == "cam"){ + this.camMenu.render(); } else { console.warn("no tab initialized!"); $("#menuContent").html('Coming Soon.');//clear out content from menu diff --git a/js/menus/OptimizationMenuView.js b/js/menus/OptimizationMenuView.js index a9405039..1b5ef1c2 100644 --- a/js/menus/OptimizationMenuView.js +++ b/js/menus/OptimizationMenuView.js @@ -21,13 +21,6 @@ OptimizationMenuView = Backbone.View.extend({ template: _.template('\ input stiffness requirements of structure\ - <br/><br/>\ - data representation for structural optimization: <a href="http://www.demo.cs.brandeis.edu/papers/edc98.pdf">lego tree</a>, <a href="http://creativemachines.cornell.edu/sites/default/files/Cheney_MacCurdy_Clune_Lipson--Unshackling_Evolution.pdf">CPPN-NEAT (functional)</a>, octree, some other kind of tree, grammar?\ - <br/><br/>\ - optimization parameters representation may depend on application: <a href="http://en.wikipedia.org/wiki/Evolved_antenna">antenna</a>, <a href="http://2.bp.blogspot.com/-4o29mAWZjag/UURyXoraMKI/AAAAAAAAHyM/HnevUeJ68Sw/s400/yyy.bmp">nike</a>, airbus, assembler/declarative design\ - <br/><br/>\ - active components/structures: <a href="https://www.youtube.com/watch?v=z9ptOeByLA4">voxcad</a>, <a href="http://arxiv.org/pdf/cs/0004003v2.pdf">conway</a> (<a href="http://www.instructables.com/id/OTCA-Metapixel-Conways-Game-of-Life/">instructable</a>)\ - <br/><br/>\ ') }); \ No newline at end of file diff --git a/js/models/AppState.js b/js/models/AppState.js index f8ea3045..62d18488 100644 --- a/js/models/AppState.js +++ b/js/models/AppState.js @@ -48,6 +48,12 @@ AppState = Backbone.Model.extend({ } }, + allCamProcesses: { + shopbot: "Shopbot (sbp)", + gcode: "G-Code" + }, + camProcess: "shopbot", + menuIsVisible: true, //key bindings diff --git a/main.html b/main.html index 38225b86..97964b37 100644 --- a/main.html +++ b/main.html @@ -77,6 +77,7 @@ <script src="js/menus/OptimizationMenuView.js"></script> <script src="js/menus/AssemblerMenuView.js"></script> <script src="js/menus/AnimationMenuView.js"></script> + <script src="js/menus/CamMenuView.js"></script> <script src="js/threeViews/Highlighter.js"></script> <script src="js/threeViews/ThreeView.js"></script> -- GitLab