From e2a8cd8b91f0c0b55d594baf17bb04e076663dd9 Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Sun, 9 Aug 2015 23:28:32 -0400 Subject: [PATCH] setup for cap ind calc --- js/lattice/LatticeEsim.js | 8 ++++++++ js/menus/EStaticMenuView.js | 25 +++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/js/lattice/LatticeEsim.js b/js/lattice/LatticeEsim.js index a120eab0..99bdbbce 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 50b25b7b..15202818 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()); }, -- GitLab