From 4834e66369c2b8072d7223297bb7f30dbe39e268 Mon Sep 17 00:00:00 2001
From: Amanda Ghassaei <amandaghassaei@gmail.com>
Date: Wed, 24 Jun 2015 15:23:44 -0700
Subject: [PATCH] gik composite view is happy

---
 js/cells/DMACell.js                        | 13 +++++++++++--
 js/cells/supercells/DMASuperCell.js        |  8 ++++++++
 js/cells/supercells/GIKSuperCell.js        |  8 ++++++++
 js/lattice/latticeSubclasses/GIKLattice.js |  1 +
 js/menus/CompositeMenuView.js              |  5 +++++
 5 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/js/cells/DMACell.js b/js/cells/DMACell.js
index d020a0a6..8a7f399b 100644
--- a/js/cells/DMACell.js
+++ b/js/cells/DMACell.js
@@ -245,7 +245,7 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'globals', '
 
         switch(mode) {
             case "supercell":
-                if (!this.superCell && !this.cells) mode = "cell";//top level item
+                if (this._isTopLayerCell()) mode = "cell";//top level item
                 setVisiblity();
                 break;
             case "cell":
@@ -278,7 +278,7 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'globals', '
 
         function setVisiblity(){
             var visible = true;
-            if (mode == "supercell") visible = !(self.superCell && self.cells);//middle layers are always hidden in supercell mode
+            if (mode == "supercell") visible = !self._isMiddleLayer();//middle layers are always hidden in supercell mode
 
             _.each(self.object3D.children, function(child){
                 if (child.name == "object3D") return;
@@ -293,6 +293,15 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'globals', '
         }
     };
 
+    DMACell.prototype._isMiddleLayer = function(){
+        return false;
+    };
+
+    DMACell.prototype._isTopLayerCell = function(){
+        return this.superCell === null || this.superCell === undefined;
+    };
+
+
 
 
 
diff --git a/js/cells/supercells/DMASuperCell.js b/js/cells/supercells/DMASuperCell.js
index c44d1293..37d16d71 100644
--- a/js/cells/supercells/DMASuperCell.js
+++ b/js/cells/supercells/DMASuperCell.js
@@ -95,6 +95,14 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cell'],
 
     };
 
+    DMASuperCell.prototype._isMiddleLayer = function(){
+        return this.superCell !== null && this.superCell !== undefined;
+    };
+
+    DMASuperCell.prototype._isTopLayerCell = function(){
+        return false;
+    };
+
 
 
 
diff --git a/js/cells/supercells/GIKSuperCell.js b/js/cells/supercells/GIKSuperCell.js
index 00022aaa..27832141 100644
--- a/js/cells/supercells/GIKSuperCell.js
+++ b/js/cells/supercells/GIKSuperCell.js
@@ -61,6 +61,14 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'superCell',
         return "cell";
     };
 
+    GIKSuperCell.prototype._isMiddleLayer = function(){
+        return false;
+    };
+
+    GIKSuperCell.prototype._isTopLayerCell = function(){
+        return this.superCell === null || this.superCell === undefined;
+    };
+
     GIKSuperCell.prototype.toJSON = function(){
         var data = DMASuperCell.prototype.toJSON.call(this);
         if (!this.length) console.warn("no length assigned to gik supercell");
diff --git a/js/lattice/latticeSubclasses/GIKLattice.js b/js/lattice/latticeSubclasses/GIKLattice.js
index ec35be0f..0b7250b0 100644
--- a/js/lattice/latticeSubclasses/GIKLattice.js
+++ b/js/lattice/latticeSubclasses/GIKLattice.js
@@ -14,6 +14,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
             require([this.getHighlighterFile()], function(superCellHighlighter){
                 globals.highlighter = new superCellHighlighter();
             });
+            appState.set("superCellRange", new THREE.Vector3(appState.get("gikLength"), 1, 1));
         },
 
         getHighlighterFile: function(){
diff --git a/js/menus/CompositeMenuView.js b/js/menus/CompositeMenuView.js
index 7f7867d3..d2f25ca3 100644
--- a/js/menus/CompositeMenuView.js
+++ b/js/menus/CompositeMenuView.js
@@ -39,6 +39,11 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice', 'globals', 'ma
             lattice.compositeEditor._changeRandomColor();
         },
 
+        getPropertyOwner: function($target){
+            if ($target.hasClass("compositeEditor")) return lattice.compositeEditor;
+            return null;
+        },
+
         updateHex: function(hex){
             //update hex without rendering
             $("#compositeColor").css("border-color", hex);
-- 
GitLab