From f01b43abd2df3baab0085fdd61f6f817539c1f8e Mon Sep 17 00:00:00 2001
From: Amanda Ghassaei <amandaghassaei@gmail.com>
Date: Sun, 1 Feb 2015 00:44:53 -0500
Subject: [PATCH] no part mode for come geometry

---
 js/main.js                  |  8 ++++----
 js/menus/LatticeMenuView.js |  2 +-
 js/menus/MenuWrapperView.js |  9 +++++++--
 js/models/AppState.js       |  1 +
 js/models/BasePlane.js      |  1 -
 js/models/Highlighter.js    | 15 +++++++++++++++
 js/models/Lattice.js        | 17 +++++++++++++++--
 7 files changed, 43 insertions(+), 10 deletions(-)
 create mode 100644 js/models/Highlighter.js

diff --git a/js/main.js b/js/main.js
index 3c6162c2..b5183a15 100644
--- a/js/main.js
+++ b/js/main.js
@@ -10,15 +10,15 @@ $(function(){
 
     //init threeJS and geometry models
     window.three = new ThreeModel();
-    window.lattice = new Lattice();
+    var lattice = new Lattice();
 
     //setup ui
-    var appState = new AppState({lattice:window.lattice});
-    new MenuWrapper({lattice:window.lattice, model:appState});
+    var appState = new AppState({lattice:lattice});
+    new MenuWrapper({lattice:lattice, model:appState});
     new NavBar({model:appState});
 
     //threeJS View
-    new ThreeView({model:window.three, lattice:window.lattice, appState:appState});
+    new ThreeView({model:window.three, lattice:lattice, appState:appState});
 
     lattice.addCell(new THREE.Vector3(0,0,0));
 });
diff --git a/js/menus/LatticeMenuView.js b/js/menus/LatticeMenuView.js
index d683eb8a..690230ee 100644
--- a/js/menus/LatticeMenuView.js
+++ b/js/menus/LatticeMenuView.js
@@ -81,7 +81,7 @@ LatticeMenuView = Backbone.View.extend({
                 </ul>\
             </div><br/><br/>\
         Scale:&nbsp;&nbsp;<input id="latticeScale" value="<%= scale %>" placeholder="enter scale" class="form-control" type="text"><br/>\
-        NumCells:&nbsp;&nbsp;<%= numCells %><br/>\
+        Num Cells:&nbsp;&nbsp;<%= numCells %><br/>\
         <br/>\
         <a href="#" id="latticeMenuClearCells" class=" btn btn-block btn-lg btn-default">Clear All Cells</a><br/>\
         ')
diff --git a/js/menus/MenuWrapperView.js b/js/menus/MenuWrapperView.js
index b4d6987f..0bf43a12 100644
--- a/js/menus/MenuWrapperView.js
+++ b/js/menus/MenuWrapperView.js
@@ -22,6 +22,8 @@ MenuWrapper = Backbone.View.extend({
         this.partMenu = new PartMenuView({model:options.lattice, appState:this.model});
         this.scriptMenu = new ScriptMenuView({appState:this.model});
 
+        this.lattice = options.lattice;
+
         //data names and titles
         this.designMenuTabs = {lattice:"Lattice", import:"Import", sketch:"Sketch", part:"Part", script:"Script"};
         this.simMenuTabs = {physics:"Physics", part:"Part", material:"Material", optimize:"Optimize"};
@@ -29,6 +31,7 @@ MenuWrapper = Backbone.View.extend({
 
         //bind events
         this.listenTo(this.model, "change:currentNav", this.render);
+        this.listenTo(options.lattice, "change:cellType change:connectionType", this._populateAndShow);
         this.listenTo(this.model, "change:currentTab", this._updateCurrentTab);
         this.listenTo(this.model, "change:menuIsVisible", this._setVisibility);
 
@@ -80,7 +83,8 @@ MenuWrapper = Backbone.View.extend({
         this.$el.html(this.template(_.extend(this.model.attributes,
             {navDesign:this.designMenuTabs,
             navSim:this.simMenuTabs,
-            navAssemble:this.assemMenuTabs})));
+            navAssemble:this.assemMenuTabs,
+            }, this.lattice.attributes)));
         this._updateCurrentTab();
         this._show();
     },
@@ -106,7 +110,8 @@ MenuWrapper = Backbone.View.extend({
     template: _.template('\
         <ul class="nav nav-tabs nav-justified">\
         <% var dict = eval(currentNav);\
-        _.each(_.keys(dict), function(key){%>\
+        _.each(_.keys(dict), function(key){\
+            if (key == "part" && !(allPartTypes[cellType][connectionType])) return;  %>\
           <li role="presentation" class="menuWrapperTab" data-name="<%= key %>"><a href="#"><%= dict[key] %></a></li>\
         <% }); %>\
         </ul>\
diff --git a/js/models/AppState.js b/js/models/AppState.js
index 1442e706..7c487c97 100644
--- a/js/models/AppState.js
+++ b/js/models/AppState.js
@@ -77,6 +77,7 @@ AppState = Backbone.Model.extend({
 
         switch(e.keyCode){
             case 16://shift
+                e.preventDefault();
                 this.set("shift", state);
                 break;
             case 32://space bar
diff --git a/js/models/BasePlane.js b/js/models/BasePlane.js
index 3887b963..183f6ff7 100644
--- a/js/models/BasePlane.js
+++ b/js/models/BasePlane.js
@@ -55,7 +55,6 @@ BasePlane = Backbone.Model.extend({
     _createOctaFaceMesh: function(){
 
         var geometry = new THREE.Geometry();
-
         var vertices = geometry.vertices;
         var faces = geometry.faces;
 
diff --git a/js/models/Highlighter.js b/js/models/Highlighter.js
new file mode 100644
index 00000000..44ddab8f
--- /dev/null
+++ b/js/models/Highlighter.js
@@ -0,0 +1,15 @@
+/**
+ * Created by aghassaei on 2/1/15.
+ */
+
+Highlighter = Backbone.Model.extend({
+
+    defaults: {
+    },
+
+    initialize: function(options){
+
+
+    }
+
+});
\ No newline at end of file
diff --git a/js/models/Lattice.js b/js/models/Lattice.js
index 0032b21d..5bf88bd9 100644
--- a/js/models/Lattice.js
+++ b/js/models/Lattice.js
@@ -8,9 +8,22 @@ Lattice = Backbone.Model.extend({
     defaults: {
         scale: window.defaultLatticeScale,
         cellType: "octa",
-        allCellTypes: {octa:"Octahedron", cube:"Cube"},
         connectionType: "face",
-        allConnectionTypes: {octa:{face:"Face", edge:"Edge", vertex:"Vertex"}, cube:{face:"Face"}},
+        allCellTypes: {octa:"Octahedron", cube:"Cube"},
+        allConnectionTypes: {
+            octa: {face:"Face", edge:"Edge", vertex:"Vertex"},
+            cube: {face:"Face"}
+        },
+        allPartTypes:{
+            octa:{
+                face: {triangle:"Triangle"},
+                edge: {traingle:"Triangle"},
+                vertex:{square:"Square", x:"X"}
+            },
+            cube:{
+                face: null
+            }
+        },
         nodes: [],
         cells: [[[null]]],//3D matrix containing all cells and null, dynamic size
         cellsMin: {x:0, y:0, z:0},//min position of cells matrix
-- 
GitLab