diff --git a/js/menus/AnimationMenuView.js b/js/menus/AnimationMenuView.js index 695561bae50e8984f11213996733252f552f5773..26bb2757763da58f5f4b4e74fae507040bc8f681 100644 --- a/js/menus/AnimationMenuView.js +++ b/js/menus/AnimationMenuView.js @@ -96,6 +96,7 @@ AnimationMenuView = Backbone.View.extend({ render: function(){ if (this.model.changedAttributes()["currentNav"]) return; if (this.model.get("currentTab") != "animate") return; + if ($("input[type=text]").is(":focus")) return; if (globals.cam.get("needsPostProcessing") && !globals.cam.get("editsMadeToProgram")) globals.cam.postProcess(); this.$el.html(this.template(_.extend(this.model.toJSON(), globals.cam.toJSON()))); this._setEditorHeight(); diff --git a/js/menus/AssemblerMenuView.js b/js/menus/AssemblerMenuView.js index 902f8a29a089c1a1fb8150f6e610fc13b671f2c3..f415aab464960b2819557865b6b8eafb90314fcc 100644 --- a/js/menus/AssemblerMenuView.js +++ b/js/menus/AssemblerMenuView.js @@ -33,7 +33,7 @@ AssemblerMenuView = Backbone.View.extend({ render: function(){ if (this.model.changedAttributes()["currentNav"]) return; if (this.model.get("currentTab") != "assembler") return; - if ($("input").is(":focus")) return; + if ($("input[type=text]").is(":focus")) return; this.$el.html(this.template(_.extend(this.model.toJSON(), globals.cam.toJSON(), globals.lattice.toJSON(), globals.plist))); }, diff --git a/js/menus/CamMenuView.js b/js/menus/CamMenuView.js index f3c3d537e783a9b645a11b7b94f9e51546c654d9..88023eb2af3fb03b041ed6179bcd769543f354a3 100644 --- a/js/menus/CamMenuView.js +++ b/js/menus/CamMenuView.js @@ -35,7 +35,7 @@ CamMenuView = Backbone.View.extend({ render: function(){ if (this.model.changedAttributes()["currentNav"]) return; if (this.model.get("currentTab") != "cam") return; - if ($("input").is(":focus")) return; + if ($("input[type=text]").is(":focus")) return; var data = _.extend(this.model.toJSON(), globals.cam.toJSON(), globals.lattice.toJSON(), globals.plist); if (globals.cam.get("stockPositionRelative")){ diff --git a/js/menus/ImportMenuView.js b/js/menus/ImportMenuView.js index 074051674cb246d33734a59658020979c2da4886..cd0a6ef5973082a19eafffbc8bdac07142343aca 100644 --- a/js/menus/ImportMenuView.js +++ b/js/menus/ImportMenuView.js @@ -83,6 +83,7 @@ ImportMenuView = Backbone.View.extend({ render: function(){ if (this.model.changedAttributes()["currentNav"]) return; if (this.model.get("currentTab") != "import") return; + if ($("input[type=text]").is(":focus")) return; this.$el.html(this.template(_.extend(this.model.toJSON(), this.fillGeometry.toJSON()))); }, @@ -94,7 +95,7 @@ ImportMenuView = Backbone.View.extend({ <a href="#" id="removeFillGeo" class=" btn btn-block btn-lg btn-default">Remove Mesh</a><br/>\ <hr>\ <% } %>\ - <a href="#" class=" btn btn-block btn-lg btn-default clearCells">Clear All Cells</a><br/><br/>\ + <a href="#" class=" btn btn-block btn-lg btn-danger clearCells">Clear All Cells</a><br/><br/>\ <br/><span class="btn btn-default btn-lg btn-file fullWidth">\ Upload STL<input id="importMenuUploadSTL" type="file">\ </span><br/>\ diff --git a/js/menus/LatticeMenuView.js b/js/menus/LatticeMenuView.js index 69ff6e80ed27dc3a06cf701d5a2753539ccf7f79..60d99f1af21204db92b4348dd2a4edee6db5e94a 100644 --- a/js/menus/LatticeMenuView.js +++ b/js/menus/LatticeMenuView.js @@ -8,8 +8,6 @@ LatticeMenuView = Backbone.View.extend({ el: "#menuContent", events: { - "change #latticeScale": "_changeScale", - "slideStop #latticeMenuScaleSlider": "_changeScaleSlider" }, @@ -20,28 +18,11 @@ LatticeMenuView = Backbone.View.extend({ this.listenTo(globals.lattice, "change", this.render); }, - _changeScale: function(e){ - e.preventDefault(); - var val = parseFloat($(e.target).val()); - if (isNaN(val)) return; - globals.lattice.set("scale", val); - }, - - _changeScaleSlider: function(e){ - globals.lattice.set("scale", $(e.target)[0].value); - }, - render: function(){ if (this.model.changedAttributes()["currentNav"]) return; if (this.model.get("currentTab") != "lattice") return; - if ($("input").is(":focus")) return; + if ($("input[type=text]").is(":focus")) return; this.$el.html(this.template(_.extend(globals.lattice.toJSON(), globals.plist))); - - $('#latticeMenuScaleSlider').slider({ - formatter: function(value) { - return value; - } - }); }, template: _.template('\ @@ -89,9 +70,6 @@ LatticeMenuView = Backbone.View.extend({ </div><br/><br/>\ <% } %>\ <br/>\ - Scale: <input data-property="scale" value="<%= scale %>" placeholder="Scale" class="form-control floatInput lattice" type="text"><br/>\ - <input id="latticeMenuScaleSlider" data-slider-id="ex1Slider" type="text" data-slider-min="1" data-slider-max="100" data-slider-step="0.1" data-slider-value="<%= scale %>"/>\ - <br/>\ Units: \ <div class="btn-group">\ <button data-toggle="dropdown" class="btn dropdown-toggle" type="button"><%= allUnitTypes[units] %><span class="caret"></span></button>\ @@ -101,9 +79,9 @@ LatticeMenuView = Backbone.View.extend({ <% }); %>\ </ul>\ </div><br/><br/>\ - Num Cells: <%= numCells %><br/><br/>\ - <br/>\ - <a href="#" class="clearCells btn btn-block btn-lg btn-default">Clear All Cells</a><br/>\ + <br/><br/>\ + <a href="#" class="clearCells btn btn-block btn-lg btn-danger">Clear All Cells</a><br/>\ + Num Cells: <%= numCells %><br/>\ ') }); diff --git a/js/menus/MaterialMenuView.js b/js/menus/MaterialMenuView.js index 40f67daabab34a661886c69b0ac826f0f8c46182..7aa9d575029b2d2bd041dc097cc9801c7b596fb4 100644 --- a/js/menus/MaterialMenuView.js +++ b/js/menus/MaterialMenuView.js @@ -17,6 +17,7 @@ MaterialMenuView = Backbone.View.extend({ render: function(){ if (this.model.changedAttributes()["currentNav"]) return; if (this.model.get("currentTab") != "material") return; + if ($("input[type=text]").is(":focus")) return; this.$el.html(this.template()); }, diff --git a/js/menus/MenuWrapperView.js b/js/menus/MenuWrapperView.js index fb2c2d4b258665d08ecd810fb96ab94c44819390..a1c155f8ac10691205caeb70f1cd420940f353e4 100644 --- a/js/menus/MenuWrapperView.js +++ b/js/menus/MenuWrapperView.js @@ -13,7 +13,8 @@ MenuWrapper = Backbone.View.extend({ "click .clearCells": "_clearCells", "focusout .floatInput": "_renderTab",//force rounding if needed "focusout .intInput": "_renderTab", - "change input:checkbox": "_clickCheckbox" + "change input:checkbox": "_clickCheckbox", + "click input:radio": "_radioSelection" }, initialize: function(){ @@ -84,19 +85,11 @@ MenuWrapper = Backbone.View.extend({ newVal = parseFloat(newVal); if (key){ - if ($target.hasClass("lattice")) { - var value = _.clone(globals.lattice.get(property)); - value[key] = newVal; - globals.lattice.set(property, value); - } else if ($target.hasClass("assembler")) { - var value = _.clone(globals.cam.get(property)); - value[key] = newVal; - globals.cam.set(property, value); - } - return; + var value = _.clone(this._getPropertyOwner($target).get(property)); + value[key] = newVal; + this._getPropertyOwner($target).set(property, value); } - if ($target.hasClass("lattice")) globals.lattice.set(property, newVal); - else if ($target.hasClass("assembler")) globals.cam.set(property, newVal); + this._getPropertyOwner($target).set(property, newVal); }, _makeDropdownSelection: function(e){ @@ -104,8 +97,7 @@ MenuWrapper = Backbone.View.extend({ var property = $target.data("property"); var value = $target.data("value"); if (!property || !value) return; - if ($target.hasClass("lattice")) globals.lattice.set(property, value); - else if ($target.hasClass("assembler")) globals.cam.set(property, value); + this._getPropertyOwner($target).set(property, value); }, _clickCheckbox: function(e){ @@ -117,8 +109,14 @@ MenuWrapper = Backbone.View.extend({ console.warn("no property associated with checkbox input"); return; } - if ($target.hasClass("lattice")) globals.lattice.set(property, !globals.lattice.get(property)); - else if ($target.hasClass("assembler")) globals.cam.set(property, !globals.cam.get(property)); + this._getPropertyOwner($target).set(property, !this._getPropertyOwner($target).get(property)); + }, + + _radioSelection: function(e){ + e.preventDefault(); + var $target = $(e.target); + this._getPropertyOwner($target).set($target.attr("name"), $target.val()); + $target.blur(); }, _clearCells: function(e){ @@ -126,6 +124,14 @@ MenuWrapper = Backbone.View.extend({ globals.lattice.clearCells(); }, + _getPropertyOwner: function($target){ + if ($target.hasClass("lattice")) return globals.lattice; + if ($target.hasClass("assembler")) return globals.cam; + if ($target.hasClass("appState")) return globals.appState; + console.warn("no owner found for " + $target); + return null; + }, + diff --git a/js/menus/OptimizationMenuView.js b/js/menus/OptimizationMenuView.js index f3f5b133623d1dea9b2feabd8a067fa0c0c83050..def00e5e9aae8c95f0829501cf128101391d1597 100644 --- a/js/menus/OptimizationMenuView.js +++ b/js/menus/OptimizationMenuView.js @@ -17,6 +17,7 @@ OptimizationMenuView = Backbone.View.extend({ render: function(){ if (this.model.changedAttributes()["currentNav"]) return; if (this.model.get("currentTab") != "optimize") return; + if ($("input[type=text]").is(":focus")) return; this.$el.html(this.template()); }, diff --git a/js/menus/PartMenuView.js b/js/menus/PartMenuView.js index 1cca9485130ed7f7c6bc6507d4d3647ab7f9a811..79f5ac507d2d623a6fa199f60e126a1ff5c618ea 100644 --- a/js/menus/PartMenuView.js +++ b/js/menus/PartMenuView.js @@ -15,13 +15,14 @@ PartMenuView = Backbone.View.extend({ //bind events this.listenTo(globals.lattice, "change", this.render); + this.listenTo(globals.appState, "change", this.render); }, render: function(){ if (this.model.changedAttributes()["currentNav"]) return; if (this.model.get("currentTab") != "part") return; - if ($("input").is(":focus")) return; - this.$el.html(this.template(_.extend(globals.lattice.toJSON(), globals.plist))); + if ($("input[type=text]").is(":focus")) return; + this.$el.html(this.template(_.extend(globals.lattice.toJSON(), globals.appState.toJSON(), globals.plist))); }, template: _.template('\ @@ -34,12 +35,25 @@ PartMenuView = Backbone.View.extend({ <% }); %>\ </ul>\ </div><br/><br/>\ - Cell Separation <% if (connectionType != "freeformFace"){ %>(xy, z): <input data-property="cellSeparation" data-key="xy" value="<%= cellSeparation.xy %>" placeholder="XY" class="form-control floatInput lattice" type="text">\ + <!--Cell Separation <% if (connectionType != "freeformFace"){ %>(xy, z): <input data-property="cellSeparation" data-key="xy" value="<%= cellSeparation.xy %>" placeholder="XY" class="form-control floatInput lattice" type="text">\ <input data-property="cellSeparation" data-key="z" value="<%= cellSeparation.z %>" placeholder="Z" class="form-control floatInput lattice" type="text">\ <% } else { %>( radial ): <input data-property="cellSeparation" data-key="xy" value="<%= cellSeparation.xy %>" placeholder="XY" class="form-control floatInput lattice" type="text"><% } %>\ - <br/><br/>\ + <br/><br/>--><br/>\ <% if (allMaterialTypes[cellType][connectionType]){ %> \ - Material Type: <div class="btn-group">\ + Materials:<br/>\ + <label class="checkbox" for="realisticColorScheme">\ + <input id="realisticColorScheme" data-property="realisticColorScheme" type="checkbox" <% if (realisticColorScheme){ %> checked="checked"<% } %> value="" data-toggle="checkbox" class="appState custom-checkbox">\ + <span class="icons"><span class="icon-unchecked"></span><span class="icon-checked"></span></span>\ + Use realistic color scheme</label><br/>\ + \ + <% _.each(_.keys(allMaterialTypes[cellType][connectionType]), function(key){ %>\ + <label class="radio">\ + <input type="radio" <%if (key == materialType){ %>checked<%}%> name="materialType" value="<%= key %>" data-toggle="radio" class="custom-radio lattice"><span class="icons"><span class="icon-unchecked"></span><span class="icon-checked"></span></span>\ + <%= allMaterialTypes[cellType][connectionType][key].name %>\ + </label>\ + <% }); %>\ + <br/><br/>\ + <div class="btn-group">\ <button data-toggle="dropdown" class="btn dropdown-toggle" type="button"><%= allMaterialTypes[cellType][connectionType][materialType].name %><span class="caret"></span></button>\ <ul role="menu" class="dropdown-menu">\ <% _.each(_.keys(allMaterialTypes[cellType][connectionType]), function(key){ %>\ @@ -48,7 +62,7 @@ PartMenuView = Backbone.View.extend({ </ul>\ </div><br/><br/>\ <% } %>\ - <br/>todo: generic beam part type, part types for new lattice configurations\ + <br/>\ ') }); \ No newline at end of file diff --git a/js/menus/PhysicsMenuView.js b/js/menus/PhysicsMenuView.js index 9a29ca6892c73aa697e1eef411ebdb7f3e00f451..9db79389b49a3cc63f1519d57c46109c79b03c98 100644 --- a/js/menus/PhysicsMenuView.js +++ b/js/menus/PhysicsMenuView.js @@ -17,6 +17,7 @@ PhysicsMenuView = Backbone.View.extend({ render: function(){ if (this.model.changedAttributes()["currentNav"]) return; if (this.model.get("currentTab") != "physics") return; + if ($("input[type=text]").is(":focus")) return; this.$el.html(this.template()); }, diff --git a/js/menus/ScriptMenuView.js b/js/menus/ScriptMenuView.js index 1a7db72b9d6a53924a20a9d081f27fc39918b598..71ac975ee31ce0e6161f4edd8348864c490589e5 100644 --- a/js/menus/ScriptMenuView.js +++ b/js/menus/ScriptMenuView.js @@ -17,6 +17,7 @@ ScriptMenuView = Backbone.View.extend({ render: function(){ if (this.model.changedAttributes()["currentNav"]) return; if (this.model.get("currentTab") != "script") return; + if ($("input[type=text]").is(":focus")) return; this.$el.html(this.template(globals.plist)); }, @@ -29,7 +30,7 @@ ScriptMenuView = Backbone.View.extend({ <% }); %>\ </ul>\ </div><br/><br/><!-- /btn-group -->\ - <a href="#" class="clearCells btn btn-block btn-lg btn-default">Clear All Cells</a><br/>\ + <a href="#" class="clearCells btn btn-block btn-lg btn-danger">Clear All Cells</a><br/>\ ') }); \ No newline at end of file diff --git a/js/menus/SendMenuView.js b/js/menus/SendMenuView.js index f6a8b79cdf4da388bf257a2b6188bfbf93d71759..73d0c21d57a2e19f32f2da3d7e61d30a65574e59 100644 --- a/js/menus/SendMenuView.js +++ b/js/menus/SendMenuView.js @@ -19,6 +19,7 @@ SendMenuView = Backbone.View.extend({ render: function(){ if (this.model.changedAttributes()["currentNav"]) return; if (this.model.get("currentTab") != "send") return; + if ($("input[type=text]").is(":focus")) return; this.$el.html(this.template(this.model.toJSON())); }, diff --git a/js/menus/SketchMenuView.js b/js/menus/SketchMenuView.js index 56fa2562f90881d0b167c25f7385e841d92c1096..c8fbeb89739e0d3017c4992a32a191f2390303aa 100644 --- a/js/menus/SketchMenuView.js +++ b/js/menus/SketchMenuView.js @@ -24,6 +24,7 @@ SketchMenuView = Backbone.View.extend({ render: function(){ if (this.model.changedAttributes()["currentNav"]) return; if (this.model.get("currentTab") != "sketch") return; + if ($("input[type=text]").is(":focus")) return; this.$el.html(this.template(globals.basePlane.toJSON())); $('#zHeightSlider').slider({ diff --git a/js/models/AppState.js b/js/models/AppState.js index 52bb59f27e3fed0dc66cf94abf086120444d521c..c70fe3e05023a98c13f195fe9507bfdf0f02d9fe 100644 --- a/js/models/AppState.js +++ b/js/models/AppState.js @@ -29,6 +29,8 @@ AppState = Backbone.Model.extend({ superCellIndex: 0,//offset of superCell adds todo lattice? + realisticColorScheme: true, + stockSimulationPlaying: false, manualSelectOrigin: false//mode that allows user ot select origin from existing cell },