Commit 82ba2887 authored by Amanda Ghassaei's avatar Amanda Ghassaei
Browse files

new plist structure, in progress of updating ui and logic

parent 32b79837
...@@ -15,6 +15,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre ...@@ -15,6 +15,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
cellType: "cube", cellType: "cube",
connectionType: "gik", connectionType: "gik",
latticeType: "willGik",
partType: null, partType: null,
denseCellsMin: null, denseCellsMin: null,
...@@ -28,7 +29,8 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre ...@@ -28,7 +29,8 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
__initialize: function(){ __initialize: function(){
this.listenTo(this, "change:partType", this._updatePartType); //todo change latticeType
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._updateLatticeType();//pass no params
}); });
...@@ -53,17 +55,35 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre ...@@ -53,17 +55,35 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
_setToDefaultsSilently: function(){ _setToDefaultsSilently: function(){
var newCellType = this.get("cellType"); var newCellType = this.get("cellType");
var newConnectionType = this.get("connectionType"); var newConnectionType = this.get("connectionType");
if (newConnectionType == this.previous("connectionType")){ if (newConnectionType == this.previous("connectionType")){
newConnectionType = _.keys(plist["allConnectionTypes"][newCellType])[0]; newConnectionType = _.keys(plist.allLattices[newCellType].connection)[0];
this.set("connectionType", newConnectionType, {silent:true}); this.set("connectionType", newConnectionType, {silent:true});
} }
var partType = _.keys(plist["allPartTypes"][newCellType][newConnectionType])[0];
this.set("partType", partType, {silent:true}); var newLatticeType = this.get("latticeType");
appState.set("materialClass", plist.allMaterialTypes[newCellType][newConnectionType]); if (newLatticeType === this.previous("latticeType")){
newLatticeType = _.keys(plist.allLattices[newCellType].connection[newConnectionType].type)[0];
this.set("latticeType", newLatticeType, {silent:true});
}
var latticeData = this._getLatticePlistData();
var newPartType = null;
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);
},
_getLatticePlistData: function(){
return plist.allLattices[this.get("cellType")].connection[this.get("connectionType")].type[this.get("latticeType")];
}, },
_setDefaultCellMode: function(){//if no part associated with this lattice type _setDefaultCellMode: function(){//if no part associated with this lattice type
if (!plist["allPartTypes"][this.get("cellType")][this.get("connectionType")]){ var latticeData = this._getLatticePlistData();
if (latticeData.parts === null){
var currentMode = appState.get("cellMode"); var currentMode = appState.get("cellMode");
if (currentMode == "cell" || currentMode == "supercell") return; if (currentMode == "cell" || currentMode == "supercell") return;
appState.set("cellMode", "cell"); appState.set("cellMode", "cell");
...@@ -73,7 +93,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre ...@@ -73,7 +93,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
_getSubclassForLatticeType: function(){ _getSubclassForLatticeType: function(){
var cellType = this.get("cellType"); var cellType = this.get("cellType");
var connectionType = this.get("connectionType"); var connectionType = this.get("connectionType");
var subclass = plist.allLatticeSubclasses[cellType][connectionType]; var subclass = plist.allLattices[cellType].connection[connectionType].subclass;
if (subclass === undefined){ if (subclass === undefined){
console.warn("unrecognized cell type " + cellType); console.warn("unrecognized cell type " + cellType);
return null; return null;
......
Cell Type:    Cell Type:   
<div class="btn-group"> <div class="btn-group">
<button data-toggle="dropdown" class="btn dropdown-toggle" type="button"><%= allCellTypes[cellType] %><span class="caret"></span></button> <button data-toggle="dropdown" class="btn dropdown-toggle" type="button"><%= allLattices[cellType].name %><span class="caret"></span></button>
<ul role="menu" class="dropdown-menu"> <ul role="menu" class="dropdown-menu">
<% _.each(_.keys(allCellTypes), function(key){ %> <% _.each(allLattices, function(cellTypeData, key){ %>
<li><a class="lattice dropdownSelector" data-property="cellType" data-value="<%= key %>" href="#"><%= allCellTypes[key] %></a></li> <li><a class="lattice dropdownSelector" data-property="cellType" data-value="<%= key %>" href="#"><%= cellTypeData.name %></a></li>
<% }); %> <% }); %>
</ul> </ul>
</div><br/><br/> </div><br/><br/>
Cell Connection:&nbsp;&nbsp; Cell Connection:&nbsp;&nbsp;
<div class="btn-group"> <div class="btn-group">
<button data-toggle="dropdown" class="btn dropdown-toggle" type="button"><%= allConnectionTypes[cellType][connectionType] %>-Connected<span class="caret"></span></button> <button data-toggle="dropdown" class="btn dropdown-toggle" type="button"><%= allLattices[cellType].connection[connectionType].name %>-Connected<span class="caret"></span></button>
<ul role="menu" class="dropdown-menu"> <ul role="menu" class="dropdown-menu">
<% _.each(_.keys(allConnectionTypes[cellType]), function(key){ %> <% _.each(allLattices[cellType].connection, function(connectionTypeData, key){ %>
<li><a class="lattice dropdownSelector" data-property="connectionType" data-value="<%= key %>" href="#"><%= allConnectionTypes[cellType][key] %></a></li> <li><a class="lattice dropdownSelector" data-property="connectionType" data-value="<%= key %>" href="#"><%= connectionTypeData.name %></a></li>
<% }); %>
</ul>
</div><br/><br/>
Type:&nbsp;&nbsp;
<div class="btn-group">
<button data-toggle="dropdown" class="btn dropdown-toggle" type="button"><%= allLattices[cellType].connection[connectionType].type[latticeType].name %><span class="caret"></span></button>
<ul role="menu" class="dropdown-menu">
<% _.each(allLattices[cellType].connection[connectionType].type, function(latticeTypeData, key){ %>
<li><a class="lattice dropdownSelector" data-property="latticeType" data-value="<%= key %>" href="#"><%= latticeTypeData.name %></a></li>
<% }); %> <% }); %>
</ul> </ul>
</div><br/><br/> </div><br/><br/>
......
<ul class="nav nav-tabs nav-justified"> <ul class="nav nav-tabs nav-justified">
<% _.each(allMenus[currentNav].tabs, function(tabName, key){ <% _.each(allMenus[currentNav].tabs, function(tabName, key){
if (key == "part" && !(allPartTypes[cellType][connectionType])) return; %> if (key == "part" && allLattices[cellType].connection[connectionType].type[latticeType].parts === null) return; %>
<li role="presentation" class="menuWrapperTab" data-name="<%= key %>"><a href="#"><%= tabName %></a></li> <li role="presentation" class="menuWrapperTab" data-name="<%= key %>"><a href="#"><%= tabName %></a></li>
<% }); %> <% }); %>
</ul> </ul>
\ No newline at end of file
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<div class="btn-group"> <div class="btn-group">
<a data-type="supercell" class="btn btn-primary btn-ribbon ribbonCellMode<% if (cellMode == "supercell"){ %> ribbon-selected<% } %>" href="#"><img data-type="supercell" src="assets/imgs/super-sm.png"></a> <a data-type="supercell" class="btn btn-primary btn-ribbon ribbonCellMode<% if (cellMode == "supercell"){ %> ribbon-selected<% } %>" href="#"><img data-type="supercell" src="assets/imgs/super-sm.png"></a>
<a data-type="cell" class="btn btn-primary btn-ribbon ribbonCellMode<% if (cellMode == "cell"){ %> ribbon-selected<% } %>" href="#"><img data-type="cell" src="assets/imgs/cell-sm.png"></a> <a data-type="cell" class="btn btn-primary btn-ribbon ribbonCellMode<% if (cellMode == "cell"){ %> ribbon-selected<% } %>" href="#"><img data-type="cell" src="assets/imgs/cell-sm.png"></a>
<% if (allPartTypes[cellType][connectionType]){ %> <% if (allLattices[cellType].connection[connectionType].type[latticeType].parts){ %>
<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="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="beam" class="btn btn-primary btn-ribbon ribbonCellMode<% if (cellMode == "beam"){ %> ribbon-selected<% } %>" href="#">Beam</a>-->
......
Supports Markdown
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