diff --git a/js/lattice/LatticeEsim.js b/js/lattice/LatticeEsim.js index a120eab088c370b13e352c8f1a1fdd8b38ab21de..99bdbbce817ce88e99514933614c26a7a29b8867 100644 --- a/js/lattice/LatticeEsim.js +++ b/js/lattice/LatticeEsim.js @@ -67,6 +67,14 @@ define(['lattice', 'appState', 'threeModel', 'eSim', 'eSimCell', 'eSimSuperCell' if (index.x-1 >= 0) callback(this.cells[index.x-1][index.y][index.z]); if (index.y+1 < yLength) callback(this.cells[index.x][index.y+1][index.z]); if (index.y-1 >= 0) callback(this.cells[index.x][index.y-1][index.z]); + }, + + calcCapacitance: function(){ + + }, + + calcInductance: function(){ + } }; diff --git a/js/menus/EStaticMenuView.js b/js/menus/EStaticMenuView.js index 50b25b7b9d203e8afad1a2cda3316ffc2bbcf42b..152028182ea3c95711746a8a043ea82bbdccde3c 100644 --- a/js/menus/EStaticMenuView.js +++ b/js/menus/EStaticMenuView.js @@ -3,12 +3,14 @@ */ -define(['jquery', 'underscore', 'menuParent', 'plist', 'text!eStaticMenuTemplate', 'eSim'], - function($, _, MenuParentView, plist, template, eSim){ +define(['jquery', 'underscore', 'menuParent', 'plist', 'text!eStaticMenuTemplate', 'eSim', 'latticeESim'], + function($, _, MenuParentView, plist, template, eSim, lattice){ return MenuParentView.extend({ events: { + "click #calcCapacitance": "_calcCapacitance", + "click #calcInductance": "_calcInductance" }, _initialize: function(){ @@ -21,6 +23,25 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'text!eStaticMenuTemplate return null; }, + _calcCapacitance: function(e){ + e.preventDefault(); + if (this._checkGroupData("voltage")) lattice.calcCapacitance(); + else console.warn("voltage data missing"); + }, + + _calcInductance: function(e){ + e.preventDefault(); + if (this._checkGroupData("current")) lattice.calcInductance(); + else console.warn("current data missing"); + }, + + _checkGroupData: function(property){ + var missingGroups = _.filter(eSim.get("conductorGroups"), function(group){ + return group[property] === null; + }); + return missingGroups.length == 0; + }, + _makeTemplateJSON: function(){ return _.extend(this.model.toJSON(), eSim.toJSON()); },