diff --git a/js/menus/EStaticMenuView.js b/js/menus/EStaticMenuView.js index 6dff60afba4cbedd93046ac68d1baa924837749e..b536655a6616a1f2a1838d1a15b1f0b242620b85 100644 --- a/js/menus/EStaticMenuView.js +++ b/js/menus/EStaticMenuView.js @@ -20,7 +20,7 @@ define(['jquery', 'underscore', 'menuParent', 'eSimPlist', 'text!eStaticMenuTemp getPropertyOwner: function($target){ if ($target.hasClass("eSim")) return eSim; - if ($target.hasClass("eSimGroup")) return eSim.get("conductorGroups")[$target.data("index")]; + if ($target.hasClass("eSimGroup")) return eSim.get("conductorGroups")[$target.data("id")]; return null; }, diff --git a/js/menus/templates/ESetupMenuView.html b/js/menus/templates/ESetupMenuView.html index 4fed4531e4693c60cb54206cf0d97e68ed2f1d0f..2c9e96ac27a8c13464ca1a0d255d2359793c54c2 100644 --- a/js/menus/templates/ESetupMenuView.html +++ b/js/menus/templates/ESetupMenuView.html @@ -12,8 +12,8 @@ Simulation Type: </div><br/><br/> <a href="#" id="calcConnectivity" class="btn btn-block btn-lg btn-default"><% if(conductorGroups){ %>Re-<% } %>Calculate Connectivity</a><br/> <% if(conductorGroups){ %> - Num Connected Conductors:  <%= conductorGroups.length %><br/> - <% if(conductorGroups.length > 0){ %> + Num Connected Conductors:  <%= _.keys(conductorGroups).length %><br/> + <% if(_.keys(conductorGroups).length > 0){ %> <label class="radio"> <input type="radio" <% if (visibleConductorGroup == -2){ %>checked<% } %> name="visibleConductorGroup" value="-2" data-toggle="radio" class="custom-radio eSim"><span class="icons"><span class="icon-unchecked"></span><span class="icon-checked"></span></span> Show Everything @@ -22,10 +22,10 @@ Simulation Type: <input type="radio" <% if (visibleConductorGroup == -1){ %>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){ %> + <% var index = 0; _.each(conductorGroups, function(groupData, id){ %> <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 type="radio" <% if (id == visibleConductorGroup){ %>checked<% } %> name="visibleConductorGroup" value="<%= id %>" data-toggle="radio" class="custom-radio eSim"><span class="icons"><span class="icon-unchecked"></span><span class="icon-checked"></span></span> + Group <%= ++index %> </label> <% }); %> <% } %> diff --git a/js/menus/templates/EStaticMenuView.html b/js/menus/templates/EStaticMenuView.html index c6da2f9919d97ac466ebc43ee47bcaaf0081907d..7d9239c7cd2d89e07842d58f633f2558ce284e1d 100644 --- a/js/menus/templates/EStaticMenuView.html +++ b/js/menus/templates/EStaticMenuView.html @@ -1,4 +1,4 @@ -<% if(conductorGroups && conductorGroups.length > 0){ %> +<% if(conductorGroups && _.keys(conductorGroups).length > 0){ %> Simulation Resolution: <input data-property="simulationRes" value="<%= simulationRes %>" placeholder="Resolution" class="form-control intInput eSim voltageInput" type="text"><br/><br/> Dielectric Permittivity (k): <input data-property="dielectricPerm" value="<%= dielectricPerm %>" placeholder="k" class="form-control floatInput eSim voltageInput" type="text"><br/> <label class="radio"> @@ -9,10 +9,10 @@ <input type="radio" <% if (visibleConductorGroup == -1){ %>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){ %> + <% var index = 0; _.each(conductorGroups, function(groupData, id){ %> <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 type="radio" <% if (id == visibleConductorGroup){ %>checked<% } %> name="visibleConductorGroup" value="<%= id %>" data-toggle="radio" class="custom-radio eSim"><span class="icons"><span class="icon-unchecked"></span><span class="icon-checked"></span></span> + Group <%= ++index %> <input data-property="voltage" data-index="<%= index %>" value="<%= groupData.voltage %>" placeholder="Voltage" class="form-control floatInput eSimGroup voltageInput" type="text"> <input data-property="current" data-index="<%= index %>" value="<%= groupData.current %>" placeholder="Current" class="form-control floatInput eSimGroup currentInput" type="text"> </label> diff --git a/js/simulation/electronics/LatticeEsim.js b/js/simulation/electronics/LatticeEsim.js index 3eb10101ef3ae5d234534487d80f5363d1581037..0ea05346549b6de0aef3526d864cdb720297cc5e 100644 --- a/js/simulation/electronics/LatticeEsim.js +++ b/js/simulation/electronics/LatticeEsim.js @@ -17,7 +17,7 @@ define(['lattice', 'appState', 'three', 'threeModel', 'eSim', 'eSimCell', 'eSimS _showConductors: function(){ var groupNum = eSim.get("visibleConductorGroup"); - if (!eSim.get("conductorGroups") || eSim.get("conductorGroups").length == 0 || groupNum == -2){ + if (!eSim.get("conductorGroups") || _.keys(eSim.get("conductorGroups")).length == 0 || groupNum == -2){ this.setOpaque(); three.render(); return; @@ -44,13 +44,13 @@ define(['lattice', 'appState', 'three', 'threeModel', 'eSim', 'eSimCell', 'eSimS }, _calcNumberConnectedComponents: function(){ - var groups = []; + var groups = {}; this._loopCells(this.cells, function(cell){ if (!cell) return; if (_.filter(groups, function(group){ return group.id == cell.getConductorGroupNum(); }).length == 0 && cell.isConductive()) { - groups.push({id:cell.getConductorGroupNum(), current: null, voltage: null}); + groups[cell.getConductorGroupNum()] = {current: null, voltage: null}; } }); eSim.set("conductorGroups", groups); diff --git a/js/simulation/electronics/eSim.js b/js/simulation/electronics/eSim.js index 2f045d0dea16b823cc4062febd6ec2af2dfffee1..ea9cf5cfc07160f1e0976f5085928f4b259d51bf 100644 --- a/js/simulation/electronics/eSim.js +++ b/js/simulation/electronics/eSim.js @@ -8,7 +8,7 @@ define(['underscore', 'backbone', 'threeModel'], function(_, Backbone, three){ var eSim = Backbone.Model.extend({ defaults:{ - conductorGroups: null,//[{id: xx, current:xx, voltage:xx}] + conductorGroups: null,//{{current:xx, voltage:xx}, ...} visibleConductorGroup: -1,//-2 = show everything, -1 = show all conductors globalInductance: null, voltageUnits: "1",