Commit a275c2b7 authored by Amanda Ghassaei's avatar Amanda Ghassaei
Browse files

update aspect ratio and material class

parent eae1e2a9
...@@ -18,6 +18,8 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre ...@@ -18,6 +18,8 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
latticeType: "willGik", latticeType: "willGik",
partType: null, partType: null,
aspectRatio: null,
denseCellsMin: null, denseCellsMin: null,
overlapDetected: false, overlapDetected: false,
...@@ -32,8 +34,9 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre ...@@ -32,8 +34,9 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
//todo change latticeType //todo change latticeType
this.listenTo(this, "change:partType change:latticeType", this._updatePartType); this.listenTo(this, "change:partType change:latticeType", this._updatePartType);
this.listenTo(this, "change:cellType change:connectionType", function(){ this.listenTo(this, "change:cellType change:connectionType", function(){
this._updateLatticeType();//pass no params this._updateLatticeConfig();//pass no params
}); });
this.listenTo(this, "change:latticeType", this._updateLatticeType);
this.listenTo(this, "change:cellSeparation", this._updateCellSeparation); this.listenTo(this, "change:cellSeparation", this._updateCellSeparation);
this.listenTo(appState, "change:currentNav", this._navChanged); this.listenTo(appState, "change:currentNav", this._navChanged);
...@@ -41,7 +44,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre ...@@ -41,7 +44,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
this.updateThreeViewTarget(); this.updateThreeViewTarget();
}); });
this._updateLatticeType(); this._updateLatticeConfig();
}, },
...@@ -73,12 +76,15 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre ...@@ -73,12 +76,15 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
if (latticeData.parts) newPartType = _.keys(latticeData.parts)[0]; if (latticeData.parts) newPartType = _.keys(latticeData.parts)[0];
this.set("partType", newPartType, {silent:true}); this.set("partType", newPartType, {silent:true});
var newMaterialClass = (latticeData.materialClasses || plist.allMaterialClasses)[0]; this._updateLatticeType();
appState.set("materialClass", newMaterialClass);
}, },
_getLatticePlistData: function(){ _updateLatticeType: function(){
return plist.allLattices[this.get("cellType")].connection[this.get("connectionType")].type[this.get("latticeType")]; var latticeData = this._getLatticePlistData();
this.set("aspectRatio", latticeData.aspectRatio.clone(), {silent:true});
var newMaterialClass = (latticeData.materialClasses || _.keys(plist.allMaterialClasses))[0];
appState.set("materialClass", newMaterialClass);
}, },
_setDefaultCellMode: function(){//if no part associated with this lattice type _setDefaultCellMode: function(){//if no part associated with this lattice type
...@@ -244,7 +250,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre ...@@ -244,7 +250,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
self.compositeEditor = new CompositeEditorLattice(_.extend({id:id}, _.omit(data, "sparseCells")), null, function(_self){ self.compositeEditor = new CompositeEditorLattice(_.extend({id:id}, _.omit(data, "sparseCells")), null, function(_self){
var cells = null; var cells = null;
if (data) cells = data.sparseCells; if (data) cells = data.sparseCells;
_self._updateLatticeType(cells, self._getSubclassForLatticeType()); _self._updateLatticeConfig(cells, self._getSubclassForLatticeType());
appState.set("currentNav", "navComposite"); appState.set("currentNav", "navComposite");
}); });
......
...@@ -41,7 +41,11 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre ...@@ -41,7 +41,11 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
//lattice type //lattice type
_updateLatticeType: function(cells, subclass){//do not clear cells if loading from file (cells array contains important metadata) _getLatticePlistData: function(){
return plist.allLattices[this.get("cellType")].connection[this.get("connectionType")].type[this.get("latticeType")];
},
_updateLatticeConfig: function(cells, subclass){//do not clear cells if loading from file (cells array contains important metadata)
if (!cells) { if (!cells) {
if (this._setToDefaultsSilently) this._setToDefaultsSilently(); if (this._setToDefaultsSilently) this._setToDefaultsSilently();
......
...@@ -16,9 +16,7 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice', 'text!latticeM ...@@ -16,9 +16,7 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice', 'text!latticeM
}, },
_makeTemplateJSON: function(){ _makeTemplateJSON: function(){
var aspectRatio = {aspectRatio: {x:1,y:1,z:1}}; return _.extend(_.extend(lattice.toJSON(), this.model.toJSON()), plist);
if (lattice.xScale) aspectRatio = {aspectRatio: {x:lattice.xScale(0), y:lattice.yScale(0), z:lattice.zScale(0)}};
return _.extend(_.extend(lattice.toJSON(), this.model.toJSON()), plist, aspectRatio);
}, },
template: _.template(template) template: _.template(template)
......
...@@ -105,9 +105,10 @@ define(['jquery', 'underscore', 'plist', 'backbone', 'lattice', 'appState', 'tex ...@@ -105,9 +105,10 @@ define(['jquery', 'underscore', 'plist', 'backbone', 'lattice', 'appState', 'tex
_updateInt: function(e){ _updateInt: function(e){
e.preventDefault(); e.preventDefault();
var $target = $(e.target); var $target = $(e.target);
var newVal = parseInt($target.val()); var val = $target.val();
if (val == "") return;
var newVal = parseInt(val);
if (isNaN(newVal)) { if (isNaN(newVal)) {
if (newVal == "") return;
console.warn("value is NaN"); console.warn("value is NaN");
return; return;
} }
......
...@@ -105,7 +105,7 @@ define(['underscore', 'fileSaverLib', 'lattice', 'materials', 'ribbon', 'menuWra ...@@ -105,7 +105,7 @@ define(['underscore', 'fileSaverLib', 'lattice', 'materials', 'ribbon', 'menuWra
lattice.clearCells(); lattice.clearCells();
var sparseCells = data.assembly.sparseCells; var sparseCells = data.assembly.sparseCells;
_setData(lattice, _.omit(data.assembly, "sparseCells")); _setData(lattice, _.omit(data.assembly, "sparseCells"));
if (sparseCells) lattice._updateLatticeType(sparseCells); if (sparseCells) lattice._updateLatticeConfig(sparseCells);
ribbon.render(); ribbon.render();
menuWrapper.render(); menuWrapper.render();
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment