diff --git a/js/cam/Assembler.js b/js/cam/Assembler.js new file mode 100644 index 0000000000000000000000000000000000000000..44964c5ab081dbcca64fc4605f64aea5150899e0 --- /dev/null +++ b/js/cam/Assembler.js @@ -0,0 +1,21 @@ +/** + * Created by aghassaei on 3/10/15. + */ + +Assembler = Backbone.Model.extend({ + + defaults: { + camStrategy: "xRaster", + camProcess: "shopbot" + }, + + initialize: function(){ + + //bind events + + }, + + destroy: function(){ + } + +}); \ No newline at end of file diff --git a/js/cam/ShopbotExporter.js b/js/cam/ShopbotExporter.js new file mode 100644 index 0000000000000000000000000000000000000000..f25bf3a3c1ee168393b11ec7e36ecebd3d2a145a --- /dev/null +++ b/js/cam/ShopbotExporter.js @@ -0,0 +1,11 @@ +/** + * Created by aghassaei on 3/10/15. + */ + +function ShopbotExporter() { + +} + +ShopbotExporter.prototype.exportAndSave = function(){ + +}; diff --git a/js/main.js b/js/main.js index 2b6fdd3350f86131c051dbe2f3fd27abbb4176ee..dad9fc39a598f4b67b376c80e07bf1d751ceb19b 100644 --- a/js/main.js +++ b/js/main.js @@ -16,7 +16,9 @@ $(function(){ dmaGlobals.lattice = new Lattice(); dmaGlobals.lattice._updateLatticeType();//todo get rid of this - dmaGlobals.appState = new AppState({lattice:dmaGlobals.lattice}); + dmaGlobals.assembler = new Assembler(); + dmaGlobals.appState = new AppState(); + //ui new NavBar({model:dmaGlobals.appState}); diff --git a/js/menus/AnimationMenuView.js b/js/menus/AnimationMenuView.js index 362f06af3264b2afd5c6065f213d28f318fb3c85..730458f2b94fedfe5acdeef6e43488c46b8a6f82 100644 --- a/js/menus/AnimationMenuView.js +++ b/js/menus/AnimationMenuView.js @@ -26,7 +26,7 @@ AnimationMenuView = Backbone.View.extend({ render: function(){ if (this.appState.get("currentTab") != "animate") return; - this.$el.html(this.template(this.model.attributes)); + this.$el.html(this.template(this.model.toJSON())); }, template: _.template('\ diff --git a/js/menus/AssemblerMenuView.js b/js/menus/AssemblerMenuView.js index aa1a23aaed21059eb542026f4a6981ae0de09c14..a56c4e1e7a6e5967794d81b41f2bee392c5bbe4d 100644 --- a/js/menus/AssemblerMenuView.js +++ b/js/menus/AssemblerMenuView.js @@ -8,24 +8,36 @@ AssemblerMenuView = Backbone.View.extend({ el: "#menuContent", events: { + "click .camStrategy": "_selectCamStrategy" }, initialize: function(options){ + this.assembler = options.assembler; + _.bindAll(this, "render"); + this.listenTo(this.assembler, "change", this.render); + }, + + _selectCamStrategy: function(e){ + e.preventDefault(); + this.assembler.set("camStrategy", $(e.target).data("type")); }, render: function(){ if (this.model.get("currentTab") != "assembler") return; - this.$el.html(this.template()); + this.$el.html(this.template(_.extend(this.model.toJSON(), this.assembler.toJSON()))); }, - template: _.template("\ - <a href='https://www.youtube.com/watch?v=1Cv7qaz63nQ'>Kiva simulation</a><br/><br/>\ - <a href='http://fab.cba.mit.edu/classes/865.15/people/will.langford/2_replicating/index.html'>will's demo</a><br/><br/>\ - <a href='http://www.eecs.harvard.edu/ssr/papers/iros11wksp-werfel.pdf'>asynchronous, multi-agent assembly algorithms</a> (doesn't necessarily have to be swarm-based)\ - <a href='https://www.youtube.com/watch?v=XNoNpjYQN4s'>video</a>\ - <br/><br/>\ - ") - + template: _.template('\ + Strategy: \ + <div class="btn-group">\ + <button data-toggle="dropdown" class="btn dropdown-toggle" type="button"><%= allAssemblyStrategies[camStrategy] %><span class="caret"></span></button>\ + <ul role="menu" class="dropdown-menu">\ + <% _.each(_.keys(allAssemblyStrategies), function(key){ %>\ + <li><a class="camStrategy" data-type="<%= key %>" href="#"><%= allAssemblyStrategies[key] %></a></li>\ + <% }); %>\ + </ul>\ + </div><br/><br/>\ + ') }); \ No newline at end of file diff --git a/js/menus/CamMenuView.js b/js/menus/CamMenuView.js index 5c9c933c43e0b2d4c440519d57a5299f66f07704..d08343d09392a106ee9b3d4226cc7599ee53c674 100644 --- a/js/menus/CamMenuView.js +++ b/js/menus/CamMenuView.js @@ -15,19 +15,20 @@ CamMenuView = Backbone.View.extend({ initialize: function(options){ this.lattice = options.lattice; + this.assembler = options.assembler; _.bindAll(this, "render"); - this.listenTo(this.model, "change:camProcess", this.render); + this.listenTo(this.assembler, "change", this.render); }, _selectCamProcess: function(e){ e.preventDefault(); - this.model.set("camProcess", $(e.target).data("type")); + this.assembler.set("camProcess", $(e.target).data("type")); }, render: function(){ if (this.model.get("currentTab") != "cam") return; - this.$el.html(this.template(_.extend(this.model.attributes))); + this.$el.html(this.template(_.extend(this.model.toJSON(), this.assembler.toJSON()))); }, template: _.template('\ diff --git a/js/menus/ImportMenuView.js b/js/menus/ImportMenuView.js index a4c111c6222e73359555e8065a566b5a858d24aa..a8ac6483e0a0da678fc91eae82c82c7331f5e9f9 100644 --- a/js/menus/ImportMenuView.js +++ b/js/menus/ImportMenuView.js @@ -88,7 +88,7 @@ ImportMenuView = Backbone.View.extend({ render: function(){ if (this.appState.get("currentTab") != "import") return; - this.$el.html(this.template(this.model.attributes)); + this.$el.html(this.template(this.model.toJSON())); }, // makeDimensionString: function(){ diff --git a/js/menus/LatticeMenuView.js b/js/menus/LatticeMenuView.js index 7dfe0600f1de7109892db9728758fddb21019308..0caee85385f058028bb49742dd5fd969723bf844 100644 --- a/js/menus/LatticeMenuView.js +++ b/js/menus/LatticeMenuView.js @@ -97,7 +97,7 @@ LatticeMenuView = Backbone.View.extend({ render: function(){ if (this.model.get("currentTab") != "lattice") return; - this.$el.html(this.template(_.extend(this.model.attributes, this.lattice.attributes))); + this.$el.html(this.template(_.extend(this.model.toJSON(), this.lattice.toJSON()))); $('#scaleSlider').slider({ formatter: function(value) { diff --git a/js/menus/MenuWrapperView.js b/js/menus/MenuWrapperView.js index 40d64b35187aaa38fa9429016b4acd0f81325e31..248deb412d89a6f7e896ad78a762604cbe31f3f5 100644 --- a/js/menus/MenuWrapperView.js +++ b/js/menus/MenuWrapperView.js @@ -26,9 +26,9 @@ MenuWrapper = Backbone.View.extend({ this.physicsMenu = new PhysicsMenuView({model:this.model}); this.materialMenu = new MaterialMenuView({model:this.model}); this.optimizeMenu = new OptimizationMenuView({model:this.model}); - this.assemblerMenu = new AssemblerMenuView({model:this.model}); + this.assemblerMenu = new AssemblerMenuView({model:this.model, assembler: dmaGlobals.assembler}); this.animationMenu = new AnimationMenuView({model:lattice.get("basePlane"), appState:this.model}); - this.camMenu = new CamMenuView({model:this.model, lattice:lattice}); + this.camMenu = new CamMenuView({model:this.model, lattice:lattice, assembler:dmaGlobals.assembler}); //data names and titles this.designMenuTabs = {lattice:"Lattice", import:"Import", sketch:"Sketch", part:"Part", script:"Script"}; diff --git a/js/menus/PartMenuView.js b/js/menus/PartMenuView.js index 18f1b00982c2c0c55d79cfd65f3aca1431b5b5e2..c9ad50493c5bdab9c7468041730f159b67a7a664 100644 --- a/js/menus/PartMenuView.js +++ b/js/menus/PartMenuView.js @@ -31,7 +31,7 @@ PartMenuView = Backbone.View.extend({ render: function(){ if (this.model.get("currentTab") != "part") return; - this.$el.html(this.template(_.extend(this.model.attributes, this.lattice.attributes))); + this.$el.html(this.template(_.extend(this.model.toJSON(), this.lattice.toJSON()))); $('#columnSepSlider').slider({ formatter: function(value) { diff --git a/js/menus/SketchMenuView.js b/js/menus/SketchMenuView.js index 0b69b789e1877a356ad0575b697ab511f6622b93..6d7df911a95f8e4bc6c31347c23f27466164f4c5 100644 --- a/js/menus/SketchMenuView.js +++ b/js/menus/SketchMenuView.js @@ -25,7 +25,7 @@ SketchMenuView = Backbone.View.extend({ render: function(){ if (this.appState.get("currentTab") != "sketch") return; - this.$el.html(this.template(this.model.get("basePlane").attributes)); + this.$el.html(this.template(this.model.get("basePlane").toJSON())); $('#zHeightSlider').slider({ formatter: function(value) { diff --git a/js/models/AppState.js b/js/models/AppState.js index 62d18488dd3b448cca906fb43df32d6ad7b87df8..7755818e74ad1e9ca018bd01841fb5b33ebda8a3 100644 --- a/js/models/AppState.js +++ b/js/models/AppState.js @@ -48,11 +48,14 @@ AppState = Backbone.Model.extend({ } }, + allAssemblyStrategies: { + xRaster: "X Raster", + yRaster: "Y Raster" + }, allCamProcesses: { shopbot: "Shopbot (sbp)", gcode: "G-Code" }, - camProcess: "shopbot", menuIsVisible: true, @@ -62,7 +65,7 @@ AppState = Backbone.Model.extend({ extrudeMode: false }, - initialize: function(options){ + initialize: function(){ _.bindAll(this, "_handleKeyStroke"); @@ -74,7 +77,6 @@ AppState = Backbone.Model.extend({ this.listenTo(this, "change:currentNav", this._updateCurrentTabForNav); this.listenTo(this, "change:currentTab", this._updateCellMode); - this.lattice = options.lattice;//this doesn't need to be tracked for changes this.downKeys = {};//track keypresses to prevent repeat keystrokeson hold if (this.isMobile()) this.set("menuIsVisible", false); @@ -105,10 +107,10 @@ AppState = Backbone.Model.extend({ _updateCellMode: function(){ var currentTab = this.get("currentTab"); - if (currentTab == "lattice") this.lattice.set("cellMode", "cell"); - else if (currentTab == "import") this.lattice.set("cellMode", "cell"); - else if (currentTab == "sketch") this.lattice.set("cellMode", "cell"); - else if (currentTab == "part") this.lattice.set("cellMode", "part"); + if (currentTab == "lattice") dmaGlobals.lattice.set("cellMode", "cell"); + else if (currentTab == "import") dmaGlobals.lattice.set("cellMode", "cell"); + else if (currentTab == "sketch") dmaGlobals.lattice.set("cellMode", "cell"); + else if (currentTab == "part") dmaGlobals.lattice.set("cellMode", "part"); }, //update to last tab open in that section @@ -155,9 +157,9 @@ AppState = Backbone.Model.extend({ this.set("extrudeMode", state); break; case 80://p part mode - var cellMode = this.lattice.get("cellMode"); - if (cellMode == "part") this.lattice.set("cellMode", "cell"); - else if (cellMode == "cell") this.lattice.set("cellMode", "part"); + var cellMode = dmaGlobals.lattice.get("cellMode"); + if (cellMode == "part") dmaGlobals.lattice.set("cellMode", "cell"); + else if (cellMode == "cell") dmaGlobals.lattice.set("cellMode", "part"); break; case 83://s save if (e.ctrlKey || e.metaKey){//command diff --git a/main.html b/main.html index 97964b37cac9097c9eb2f48398ef8f69f23422ac..132c58601e65a3c4f81f52b5d4bef1501fcf81e4 100644 --- a/main.html +++ b/main.html @@ -63,6 +63,8 @@ <script src="js/models/BasePlane.js"></script> <script src="js/models/extrudeVisualizer.js"></script> <script src="js/models/AppState.js"></script> + <script src="js/cam/Assembler.js"></script> + <script src="js/cam/ShopbotExporter.js"></script> <!--views--> <script src="js/menus/MenuWrapperView.js"></script>