From 131d317146eced8d088b9ec301e2580d4c2c92d6 Mon Sep 17 00:00:00 2001
From: Amanda Ghassaei <amandaghassaei@gmail.com>
Date: Tue, 27 Oct 2015 02:21:31 -0400
Subject: [PATCH] console logging

---
 js/lattice/Lattice.js       | 44 ++++++++++++++++++++-----------------
 js/menus/otherUI/Console.js |  2 +-
 2 files changed, 25 insertions(+), 21 deletions(-)

diff --git a/js/lattice/Lattice.js b/js/lattice/Lattice.js
index 3bd3472d..ca397126 100644
--- a/js/lattice/Lattice.js
+++ b/js/lattice/Lattice.js
@@ -31,24 +31,13 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'materialsPlis
             this.listenTo(this, "change:partType", this._updatePartType);
 
             this.listenTo(this, "change:cellType", function(){
-                var cellType = this.getCellType();
-                myConsole.clear();
-                myConsole.write("lattice.setCellType('" + cellType + "')");
-                this._cellTypeChanged(cellType);
-                this.reloadCells();
+                this._cellTypeChanged();
             });
             this.listenTo(this, "change:connectionType", function(){
-                var connectionType = this.getConnectionType();
-                myConsole.clear();
-                myConsole.write("lattice.setConnectionType('" + connectionType + "')");
-                this._connectionTypeChanged(connectionType);
-                this.reloadCells();
+                this._connectionTypeChanged();
             });
             this.listenTo(this, "change:applicationType", function(){
-                var applicationType = this.getApplicationType();
-                myConsole.write("lattice.setApplicationType('" + applicationType + "')");
-                this._applicationTypeChanged(applicationType);
-                this.reloadCells();
+                this._applicationTypeChanged();
             });
             this.listenTo(this, "change:aspectRatio", function(){
                 var aspectRatio = this.getAspectRatio();
@@ -62,7 +51,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'materialsPlis
             });
 
             this._applicationTypeChanged();
-            this.reloadCells();
         },
 
 
@@ -190,7 +178,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'materialsPlis
         },
 
         reloadCells: function(){
-            this.setSparseCells(this.sparseCells);
+            this._setSparseCells(this.sparseCells, this._getSubclassForLatticeType());
         },
 
         setSparseCells: function(cells){
@@ -261,7 +249,19 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'materialsPlis
 
         //latticeType
 
-        _cellTypeChanged: function(cellType){
+        _latticeTypeChanged: function(){
+
+        },
+
+        _printCurrentLatticeType: function(){
+            myConsole.write("lattice.setCellType('" + this.getCellType() + "')");
+            myConsole.write("lattice.setConnectionType('" + this.getConnectionType() + "')");
+            myConsole.write("lattice.setApplicationType('" + this.getApplicationType() + "')");
+            myConsole.write("lattice.setPartType('" + this.getPartType() + "')");
+        },
+
+        _cellTypeChanged: function(){
+            var cellType = this.getCellType();
             if (plist.allLattices[cellType].connection[this.getConnectionType()] === undefined){
                 var connectionType = _.keys(plist.allLattices[cellType].connection)[0];
                 this.set("connectionType", connectionType, {silent:true});
@@ -269,15 +269,16 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'materialsPlis
             this._connectionTypeChanged();
         },
 
-        _connectionTypeChanged: function(connectionType){
+        _connectionTypeChanged: function(){
+            var connectionType = this.getConnectionType();
             if (connectionType === undefined) connectionType = this.getConnectionType();
             var cellType = this.get("cellType");
             var appType = _.keys(plist.allLattices[cellType].connection[connectionType].type)[0];
             this.set("applicationType", appType, {silent:true});
-            this._applicationTypeChanged(appType);
+            this._applicationTypeChanged();
         },
 
-        _applicationTypeChanged: function(applicationType){
+        _applicationTypeChanged: function(){
             var latticeData = this._getLatticePlistData();
             this.set("aspectRatio", latticeData.aspectRatio.clone(), {silent:true});
 
@@ -291,6 +292,9 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'materialsPlis
             if (latticeData.options){
                 if (latticeData.options.gikLength) appState.set("gikLength", latticeData.options.gikLength);
             }
+
+            this.setSparseCells(this.sparseCells);
+            this._printCurrentLatticeType();
         },
 
         xScale: function(){
diff --git a/js/menus/otherUI/Console.js b/js/menus/otherUI/Console.js
index 69ce6ddc..7159a27c 100644
--- a/js/menus/otherUI/Console.js
+++ b/js/menus/otherUI/Console.js
@@ -86,7 +86,7 @@ define(['jquery', 'underscore', 'backbone', 'appState'], function($, _, Backbone
 //                if (e.keyCode == 38) $output.val(this.model.getPrevHistElem());
 //                else if (e.keyCode == 40) $output.val(this.model.getNewerHistElem());
                 else if (e.keyCode == 13) this._enterCommand($input);
-            }
+            } else if (e.keyCode == 9) $input.focus();
         },
 
         _enterCommand: function($input){
-- 
GitLab