From 4b4b5ce947cb1bcc0fc8063bb95dd935ab6c1230 Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Tue, 11 Aug 2015 13:21:18 -0400 Subject: [PATCH] hide mode toggle --- js/lattice/LatticeBase.js | 12 ++++++++++++ js/menus/templates/EStaticMenuView.html | 2 +- js/menus/templates/Ribbon.html | 1 + js/models/AppState.js | 10 +++++++++- js/simulation/electronics/eSimField.js | 4 ++-- 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/js/lattice/LatticeBase.js b/js/lattice/LatticeBase.js index e045e8ba..bc7993af 100644 --- a/js/lattice/LatticeBase.js +++ b/js/lattice/LatticeBase.js @@ -432,6 +432,18 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre _updateForMode: function(){ var cellMode = appState.get("cellMode"); var numCells = this.get("numCells"); + if (cellMode == "hide"){ + this._iterCells(this.sparseCells, function(cell){ + if (cell) cell.hide(); + }); + three.render(); + return; + } + if (appState.previous("cellMode") == "hide"){ + this._iterCells(this.sparseCells, function(cell){ + if (cell) cell.show(); + }); + } this._iterCells(this.sparseCells, function(cell){ if (cell) cell.setMode(cellMode, function(){ if (--numCells <= 0) three.render(); diff --git a/js/menus/templates/EStaticMenuView.html b/js/menus/templates/EStaticMenuView.html index 89a5a17b..382afcea 100644 --- a/js/menus/templates/EStaticMenuView.html +++ b/js/menus/templates/EStaticMenuView.html @@ -48,7 +48,7 @@ </label> <% }); %> <% if(visibleStaticSim != "none"){ %> - Simulation Z Height: <input data-property="simZHeight" value="<%= simZHeight %>" placeholder="Height" class="form-control intInput eSim" type="text"><br/><br/> + Simulation Z Height (up/down arrows): <input data-property="simZHeight" value="<%= simZHeight %>" placeholder="Height" class="form-control intInput eSim" type="text"><br/><br/> <% } %> <% } else { %> <div class="inlineWarning">No conductive groups detected, please navigate to previous tab and calculate.</div> diff --git a/js/menus/templates/Ribbon.html b/js/menus/templates/Ribbon.html index 179021b3..64cc19de 100644 --- a/js/menus/templates/Ribbon.html +++ b/js/menus/templates/Ribbon.html @@ -6,6 +6,7 @@ <a data-type="part" class="btn btn-primary btn-ribbon ribbonCellMode<% if (cellMode == "part"){ %> ribbon-selected<% } %>" href="#"><img data-type="part" src="assets/imgs/part-sm.png"></a> <% } %> <!--<a data-type="beam" class="btn btn-primary btn-ribbon ribbonCellMode<% if (cellMode == "beam"){ %> ribbon-selected<% } %>" href="#">Beam</a>--> + <a data-type="hide" class="btn btn-primary btn-ribbon ribbonCellMode<% if (cellMode == "hide"){ %> ribbon-selected"<% } %>">Hide</a> <a class="btn btn-primary btn-ribbon ribbonDeleteMode<% if (deleteMode){ %> ribbon-selected"<% } %>"><span class="fui-cross"></span></a> </div> </div> diff --git a/js/models/AppState.js b/js/models/AppState.js index a1271a8e..ef404403 100644 --- a/js/models/AppState.js +++ b/js/models/AppState.js @@ -61,7 +61,8 @@ define(['underscore', 'backbone', 'threeModel', 'three', 'plist', 'globals'], fu this.listenTo(this, "change:materialType", this._materialTypeChanged); this.listenTo(this, "change:gikLength", this._gikLengthChanged); - this.downKeys = {};//track keypresses to prevent repeat keystrokeson hold + this.downKeys = {};//track keypresses to prevent repeat keystrokes on hold + this.lastCellMode = this.get("cellMode");//store this to toggle on/off hide mode if (this.isMobile()) this.set("menuIsVisible", false); }, @@ -170,6 +171,13 @@ define(['underscore', 'backbone', 'threeModel', 'three', 'plist', 'globals'], fu case 68://d delete mode this.set("deleteMode", state); break; + case 72://h hide mode + if (state) { + this.lastCellMode = this.get("cellMode"); + this.set("cellMode", "hide"); + } + else this.set("cellMode", this.lastCellMode); + break; case 69://e // if (currentTab != "sketch") return; this.set("extrudeMode", state); diff --git a/js/simulation/electronics/eSimField.js b/js/simulation/electronics/eSimField.js index 802f3a5a..5056568d 100644 --- a/js/simulation/electronics/eSimField.js +++ b/js/simulation/electronics/eSimField.js @@ -5,7 +5,7 @@ //hold and display data for various fields -define(['underscore', 'threeModel'], function(_, three){ +define(['underscore', 'threeModel', 'lattice'], function(_, three, lattice){ function ESimField(data, offset, resolution, height, dataRange){ @@ -36,7 +36,7 @@ define(['underscore', 'threeModel'], function(_, three){ }; ESimField.prototype._setObject3DPosition = function(offset, resolution, height){ - this._object3D.position.set(offset.x, offset.y, offset.z+height/resolution); + this._object3D.position.set(offset.x, offset.y, offset.z+height*lattice.zScale()/resolution); }; ESimField.prototype._createThreeObjects = function(data, offset, size, height, object3D){ -- GitLab