From 7d75185d828fb7830c11c145566e38f19a30e990 Mon Sep 17 00:00:00 2001
From: Amanda Ghassaei <amandaghassaei@gmail.com>
Date: Mon, 23 Mar 2015 20:50:31 -0400
Subject: [PATCH] diff machines for diff lattice type

---
 js/cam/Assembler.js           | 15 +++++++++++++--
 js/menus/AssemblerMenuView.js | 10 +++++-----
 js/models/AppState.js         | 31 ++++++++++++++++++++++++++++---
 3 files changed, 46 insertions(+), 10 deletions(-)

diff --git a/js/cam/Assembler.js b/js/cam/Assembler.js
index 17608f36..3cbdbc2b 100644
--- a/js/cam/Assembler.js
+++ b/js/cam/Assembler.js
@@ -8,7 +8,7 @@ Assembler = Backbone.Model.extend({
         camStrategy: "raster",
         placementOrder: "XYZ",//used for raster strategy entry
         camProcess: "gcode",
-        machineName: "shopbot",
+        machineName: "handOfGod",
         machine: null,
         exporter: null,
 
@@ -40,7 +40,7 @@ Assembler = Backbone.Model.extend({
 
     initialize: function(options){
 
-        this.set("machine", new Shopbot());
+        this.selectMachine();
 
         _.bindAll(this, "postProcess");
 
@@ -82,6 +82,17 @@ Assembler = Backbone.Model.extend({
         this._initOriginAndStock(options.lattice);
     },
 
+    selectMachine: function(machineName){
+        if (!machineName) machineName = this.get("machineName");
+        if (this.get("machine")) this.get("machine").destroy();
+        if (machineName == "shopbot"){
+            this.set("machine", new Shopbot());
+        } else if (machineName == "handOfGod"){
+            this.set("machine", new Shopbot());
+        } else console.warn("selected machine not recognized");
+        this.set("machineName", machineName);
+    },
+
     makeProgramEdits: function(data){
         this.set("dataOut", data, {silent:true});
         this.set("editsMadeToProgram", true, {silent: true});
diff --git a/js/menus/AssemblerMenuView.js b/js/menus/AssemblerMenuView.js
index bdde47f7..12032f25 100644
--- a/js/menus/AssemblerMenuView.js
+++ b/js/menus/AssemblerMenuView.js
@@ -48,22 +48,22 @@ AssemblerMenuView = Backbone.View.extend({
 
     _selectMachine: function(e){
         e.preventDefault();
-        this.assembler.set("machineName", $(e.target).data("type"));
+        this.assembler.selectMachine($(e.target).data("type"));
     },
 
     render: function(){
         if (this.model.get("currentTab") != "assembler") return;
         if ($("input").is(":focus")) return;
-        this.$el.html(this.template(_.extend(this.model.toJSON(), this.assembler.toJSON())));
+        this.$el.html(this.template(_.extend(this.model.toJSON(), this.assembler.toJSON(), dmaGlobals.lattice.toJSON())));
     },
 
     template: _.template('\
         Machine: &nbsp;&nbsp;\
             <div class="btn-group">\
-                <button data-toggle="dropdown" class="btn dropdown-toggle" type="button"><%= allMachineTypes[machineName] %><span class="caret"></span></button>\
+                <button data-toggle="dropdown" class="btn dropdown-toggle" type="button"><%= allMachineTypes[cellType][connectionType][machineName] %><span class="caret"></span></button>\
                 <ul role="menu" class="dropdown-menu">\
-                    <% _.each(_.keys(allMachineTypes), function(key){ %>\
-                        <li><a class="machineType" data-type="<%= key %>" href="#"><%= allMachineTypes[key] %></a></li>\
+                    <% _.each(_.keys(allMachineTypes[cellType][connectionType]), function(key){ %>\
+                        <li><a class="machineType" data-type="<%= key %>" href="#"><%= allMachineTypes[cellType][connectionType][key] %></a></li>\
                     <% }); %>\
                 </ul>\
             </div><br/><br/>\
diff --git a/js/models/AppState.js b/js/models/AppState.js
index 034a927c..33bd0b2a 100644
--- a/js/models/AppState.js
+++ b/js/models/AppState.js
@@ -93,9 +93,34 @@ AppState = Backbone.Model.extend({
         },
 
         allMachineTypes:{
-            handOfGod: "Hand of God",
-            shopbot: "Shopbot",
-            oneBit: "One Bit Bot",
+            octa:{
+                face: {
+                    handOfGod: "Hand of God"
+                },
+                freeformFace: {
+                    handOfGod: "Hand of God"
+                },
+                edgeRot: {
+                    shopbot: "Shopbot",
+                    oneBit: "One Bit Bot",
+                    handOfGod: "Hand of God"
+                },
+                vertex: {
+                    handOfGod: "Hand of God"
+                }
+            },
+            tetra: {
+                handOfGod: "Hand of God"
+            },
+            cube:{
+                handOfGod: "Hand of God"
+            },
+            truncatedCube:{
+                handOfGod: "Hand of God"
+            },
+            kelvin:{
+                handOfGod: "Hand of God"
+            },
             will: "Electronics Assembler"
         },
         allAssemblyStrategies: {
-- 
GitLab