From 83b5a9266496078b04978e9fd6b791745f456646 Mon Sep 17 00:00:00 2001
From: Amanda Ghassaei <amandaghassaei@gmail.com>
Date: Mon, 26 Oct 2015 21:55:11 -0400
Subject: [PATCH] more console stuff

---
 js/lattice/Lattice.js       | 8 +++++++-
 js/lattice/LatticeBase.js   | 5 ++++-
 js/menus/otherUI/Console.js | 4 ++++
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/js/lattice/Lattice.js b/js/lattice/Lattice.js
index 03dfa973..92ee6109 100644
--- a/js/lattice/Lattice.js
+++ b/js/lattice/Lattice.js
@@ -119,6 +119,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'materialsPlis
                 myConsole.warn("no cell type " + cellType + ", lattice.setCellType operation cancelled");
                 return;
             }
+            myConsole.clear();
             myConsole.write("lattice.setCellType('" + cellType + "')");
             return this.setProperty("cellType", cellType, silent);
         },
@@ -131,6 +132,8 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'materialsPlis
                     ", lattice.setConnectionType operation cancelled");
                 return;
             }
+            myConsole.clear();
+            myConsole.write("lattice.setCellType('" + cellType + "')");
             myConsole.write("lattice.setConnectionType('" + connectionType + "')");
             return this.setProperty("connectionType", connectionType, silent);
         },
@@ -192,6 +195,8 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'materialsPlis
                 console.warn("no cells given to setSparseCells");
                 return;
             }
+            myConsole.clear();
+            myConsole.write("lattice.setCells(" + JSON.stringify(cells) + ")");
             this._setSparseCells(cells, this._getSubclassForLatticeType());
         },
 
@@ -208,7 +213,8 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'materialsPlis
 
         _setSparseCells: function(cells, subclass){
 
-            if ((this.get("numCells") > 0 && (this.get("connectionType") == "gik" || this.previous("connectionType") == "gik"))) this.clearCells();
+            if ((this.get("connectionType") == "gik" || this.previous("connectionType") == "gik") &&
+                this.get("applicationType") != this.previous("applicationType")) this.clearCells();
 
             this._setDefaultCellMode();//cell mode
 
diff --git a/js/lattice/LatticeBase.js b/js/lattice/LatticeBase.js
index 0ce171b8..1f226c4b 100644
--- a/js/lattice/LatticeBase.js
+++ b/js/lattice/LatticeBase.js
@@ -235,7 +235,9 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
                 myConsole.warn("no cell, lattice.removeCell operation cancelled");
                 return;
             }
-            myConsole.write("lattice.removeCell(" + cell + ")");
+            var json = cell.toJSON();
+            json.index = cell.getIndex();
+            myConsole.write("lattice.removeCell(" + JSON.stringify(json) + ")");
             this._removeCell(cell);
             three.render();
         },
@@ -256,6 +258,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
         },
 
         clearCells: function(silent){
+            myConsole.clear();
             myConsole.write("lattice.clearCells()");
             this._clearCells(silent);
         },
diff --git a/js/menus/otherUI/Console.js b/js/menus/otherUI/Console.js
index 3e09e5f2..625095bc 100644
--- a/js/menus/otherUI/Console.js
+++ b/js/menus/otherUI/Console.js
@@ -54,6 +54,10 @@ define(['jquery', 'underscore', 'backbone', 'appState'], function($, _, Backbone
 
         },
 
+        clear: function(){
+            $("#consoleOutput").html("");
+        },
+
         _writeOutput: function(html){
             var $output = $("#consoleOutput");
             var height = $output.height();
-- 
GitLab