From 612a8cc2e5c8312c2e76eb2dd0d413c6117e5ad0 Mon Sep 17 00:00:00 2001
From: Amanda Ghassaei <amandaghassaei@gmail.com>
Date: Sat, 8 Aug 2015 13:41:44 -0400
Subject: [PATCH] eod

---
 js/lattice/LatticeEsim.js               |  4 +++-
 js/menus/EStaticMenuView.js             | 12 ++++++++++--
 js/menus/templates/ESetupMenuView.html  |  6 +++---
 js/menus/templates/EStaticMenuView.html | 19 +++++++++++++++++--
 js/simulation/electronics/eSim.js       |  2 +-
 5 files changed, 34 insertions(+), 9 deletions(-)

diff --git a/js/lattice/LatticeEsim.js b/js/lattice/LatticeEsim.js
index 80061c6e..ac8f21ff 100644
--- a/js/lattice/LatticeEsim.js
+++ b/js/lattice/LatticeEsim.js
@@ -46,7 +46,9 @@ define(['lattice', 'appState', 'threeModel', 'eSim', 'eSimCell', 'eSimSuperCell'
             var groups = [];
             this._loopCells(this.cells, function(cell){
                 if (!cell) return;
-                if (groups.indexOf(cell.getConductorGroupNum()) < 0 && cell.isConductive()) groups.push(cell.getConductorGroupNum());
+                if (groups.indexOf(cell.getConductorGroupNum()) < 0 && cell.isConductive()) {
+                    groups.push({id:cell.getConductorGroupNum(), current: null, voltage: null});
+                }
             });
             eSim.set("conductorGroups", groups);
         },
diff --git a/js/menus/EStaticMenuView.js b/js/menus/EStaticMenuView.js
index 6257fdef..328d3616 100644
--- a/js/menus/EStaticMenuView.js
+++ b/js/menus/EStaticMenuView.js
@@ -3,7 +3,8 @@
  */
 
 
-define(['jquery', 'underscore', 'menuParent', 'plist', 'text!eStaticMenuTemplate'], function($, _, MenuParentView, plist, template){
+define(['jquery', 'underscore', 'menuParent', 'plist', 'text!eStaticMenuTemplate', 'eSim'],
+    function($, _, MenuParentView, plist, template, eSim){
 
     return MenuParentView.extend({
 
@@ -11,12 +12,19 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'text!eStaticMenuTemplate
         },
 
         _initialize: function(){
+            this.listenTo(eSim, "change", this.render);
         },
 
-        _makeTemplateJSON: function(){
+        getPropertyOwner: function($target){
+            if ($target.hasClass("eSim")) return eSim;
             return null;
         },
 
+        _makeTemplateJSON: function(){
+            console.log(eSim.get("conductorGroups"));
+            return _.extend(this.model.toJSON(), eSim.toJSON());
+        },
+
         template: _.template(template)
     });
 });
\ No newline at end of file
diff --git a/js/menus/templates/ESetupMenuView.html b/js/menus/templates/ESetupMenuView.html
index 741707ab..155d7837 100644
--- a/js/menus/templates/ESetupMenuView.html
+++ b/js/menus/templates/ESetupMenuView.html
@@ -18,10 +18,10 @@ Simulation Type: &nbsp;&nbsp;
             <input type="radio" <% if (visibleConductorGroup < 0){ %>checked<% } %> name="visibleConductorGroup" value="-1" data-toggle="radio" class="custom-radio eSim"><span class="icons"><span class="icon-unchecked"></span><span class="icon-checked"></span></span>
             Show All Conducting Groups
         </label>
-        <% _.each(conductorGroups, function(groupNum, index){ %>
+        <% _.each(conductorGroups, function(groupData, index){ %>
             <label class="radio">
-                <input type="radio" <% if (groupNum == visibleConductorGroup){ %>checked<% } %> name="visibleConductorGroup" value="<%= groupNum %>" data-toggle="radio" class="custom-radio eSim"><span class="icons"><span class="icon-unchecked"></span><span class="icon-checked"></span></span>
-                Group Num <%= index + 1 %>
+                <input type="radio" <% if (groupData.id == visibleConductorGroup){ %>checked<% } %> name="visibleConductorGroup" value="<%= groupData.id %>" data-toggle="radio" class="custom-radio eSim"><span class="icons"><span class="icon-unchecked"></span><span class="icon-checked"></span></span>
+                Group <%= index + 1 %>
             </label>
         <% }); %>
     <% } %>
diff --git a/js/menus/templates/EStaticMenuView.html b/js/menus/templates/EStaticMenuView.html
index 3db74993..08524b07 100644
--- a/js/menus/templates/EStaticMenuView.html
+++ b/js/menus/templates/EStaticMenuView.html
@@ -1,3 +1,18 @@
-static calculations:<br/>
-capacitance<br/>
+<% if(conductorGroups && conductorGroups.length > 0){ %>
+    <label class="radio">
+        <input type="radio" <% if (visibleConductorGroup < 0){ %>checked<% } %> name="visibleConductorGroup" value="-1" data-toggle="radio" class="custom-radio eSim"><span class="icons"><span class="icon-unchecked"></span><span class="icon-checked"></span></span>
+        Show All Conducting Groups
+    </label>
+    <% _.each(conductorGroups, function(groupData, index){ %>
+        <label class="radio">
+            <input type="radio" <% if (groupData.id == visibleConductorGroup){ %>checked<% } %> name="visibleConductorGroup" value="<%= groupData.id %>" data-toggle="radio" class="custom-radio eSim"><span class="icons"><span class="icon-unchecked"></span><span class="icon-checked"></span></span>
+            Group <%= index + 1 %>
+            <input data-property="voltage" value="<%= groupData.voltage %>" placeholder="Voltage" class="form-control floatInput eSim" type="text">
+            <input data-property="current" value="<%= groupData.current %>" placeholder="Current" class="form-control floatInput eSim" type="text">
+        </label>
+    <% }); %>
+<% } %>
+
+Capacitance:<br/>
+
 inductance<br/>
\ No newline at end of file
diff --git a/js/simulation/electronics/eSim.js b/js/simulation/electronics/eSim.js
index 60f59d86..e4f64174 100644
--- a/js/simulation/electronics/eSim.js
+++ b/js/simulation/electronics/eSim.js
@@ -8,7 +8,7 @@ define(['underscore', 'backbone'], function(_, Backbone){
     var eSim = Backbone.Model.extend({
 
         defaults:{
-            conductorGroups: null,
+            conductorGroups: null,//[{id: xx, current:xx, voltage:xx}]
             visibleConductorGroup: -1
         }
 
-- 
GitLab