Commit a275c2b7 authored by Amanda Ghassaei's avatar Amanda Ghassaei

update aspect ratio and material class

parent eae1e2a9
......@@ -18,6 +18,8 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
latticeType: "willGik",
partType: null,
aspectRatio: null,
denseCellsMin: null,
overlapDetected: false,
......@@ -32,8 +34,9 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
//todo change latticeType
this.listenTo(this, "change:partType change:latticeType", this._updatePartType);
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(appState, "change:currentNav", this._navChanged);
......@@ -41,7 +44,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
this.updateThreeViewTarget();
});
this._updateLatticeType();
this._updateLatticeConfig();
},
......@@ -73,12 +76,15 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
if (latticeData.parts) newPartType = _.keys(latticeData.parts)[0];
this.set("partType", newPartType, {silent:true});
var newMaterialClass = (latticeData.materialClasses || plist.allMaterialClasses)[0];
appState.set("materialClass", newMaterialClass);
this._updateLatticeType();
},
_getLatticePlistData: function(){
return plist.allLattices[this.get("cellType")].connection[this.get("connectionType")].type[this.get("latticeType")];
_updateLatticeType: function(){
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
......@@ -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){
var cells = null;
if (data) cells = data.sparseCells;
_self._updateLatticeType(cells, self._getSubclassForLatticeType());
_self._updateLatticeConfig(cells, self._getSubclassForLatticeType());
appState.set("currentNav", "navComposite");
});
......
......@@ -41,7 +41,11 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
//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 (this._setToDefaultsSilently) this._setToDefaultsSilently();
......
......@@ -16,9 +16,7 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice', 'text!latticeM
},
_makeTemplateJSON: function(){
var aspectRatio = {aspectRatio: {x:1,y:1,z:1}};
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);
return _.extend(_.extend(lattice.toJSON(), this.model.toJSON()), plist);
},
template: _.template(template)
......
......@@ -105,9 +105,10 @@ define(['jquery', 'underscore', 'plist', 'backbone', 'lattice', 'appState', 'tex
_updateInt: function(e){
e.preventDefault();
var $target = $(e.target);
var newVal = parseInt($target.val());
var val = $target.val();
if (val == "") return;
var newVal = parseInt(val);
if (isNaN(newVal)) {
if (newVal == "") return;
console.warn("value is NaN");
return;
}
......
......@@ -105,7 +105,7 @@ define(['underscore', 'fileSaverLib', 'lattice', 'materials', 'ribbon', 'menuWra
lattice.clearCells();
var sparseCells = data.assembly.sparseCells;
_setData(lattice, _.omit(data.assembly, "sparseCells"));
if (sparseCells) lattice._updateLatticeType(sparseCells);
if (sparseCells) lattice._updateLatticeConfig(sparseCells);
ribbon.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