Skip to content
Snippets Groups Projects
Commit 2ac977f8 authored by Amanda Ghassaei's avatar Amanda Ghassaei
Browse files

one bit demo

parent 311e24d6
Branches
No related tags found
No related merge requests found
{"lattice":{"units":"inches","cells":[[[{"indices":{"x":-2,"y":-2,"z":-1}},null],[{"indices":{"x":-2,"y":-1,"z":-1}},null],[{"indices":{"x":-2,"y":0,"z":-1}},null]],[[{"indices":{"x":-1,"y":-2,"z":-1}},null],[{"indices":{"x":-1,"y":-1,"z":-1}},{"indices":{"x":-1,"y":-1,"z":0}}],[{"indices":{"x":-1,"y":0,"z":-1}},{"indices":{"x":-1,"y":0,"z":0}}]],[[{"indices":{"x":0,"y":-2,"z":-1}},null],[{"indices":{"x":0,"y":-1,"z":-1}},{"indices":{"x":0,"y":-1,"z":0}}],[{"indices":{"x":0,"y":0,"z":-1}},{"indices":{"x":0,"y":0,"z":0}}]]],"cellsMin":{"x":-2,"y":-2,"z":-1},"cellsMax":{"x":0,"y":0,"z":0},"numCells":13,"scale":2.78388,"cellSeparation":{"xy":0,"z":0},"cellType":"octa","connectionType":"edgeRot","partType":"vox"},"assembler":{"camStrategy":"raster","placementOrder":"XYZ","camProcess":"gcode","machineName":"oneBitBot","dataOut":"","needsPostProcessing":false,"editsMadeToProgram":false,"rapidHeight":5.56776,"rapidHeightRelative":true,"safeHeight":0.5,"originPosition":{"x":1.3919,"y":1.3919,"z":0},"stockPosition":{"x":6.4029,"y":1.3919,"z":3.0623},"stockPositionRelative":true,"stockFixed":true,"multipleStockPositions":false,"stockArraySize":{"x":4,"y":4},"stockSeparation":2.78388,"rapidSpeeds":{"xy":3,"z":2},"feedRate":{"xy":0.1,"z":0.1}}}
\ No newline at end of file
...@@ -115,7 +115,7 @@ ...@@ -115,7 +115,7 @@
<li class="dropdown-submenu"> <li class="dropdown-submenu">
<a tabindex="-1">Demo Files<span class="pull-right fui-arrow-right"></span></a> <a tabindex="-1">Demo Files<span class="pull-right fui-arrow-right"></span></a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li><a data-file="" class="savedDemo" href="#">Demo1</a></li> <li><a data-file="oneBitBot.json" class="savedDemo" href="#">One Bit Assembly</a></li>
<li><a data-file="" class="savedDemo" href="#">Demo2</a></li> <li><a data-file="" class="savedDemo" href="#">Demo2</a></li>
</ul> </ul>
<li class="divider"></li> <li class="divider"></li>
......
...@@ -21,7 +21,8 @@ NavBar = Backbone.View.extend({ ...@@ -21,7 +21,8 @@ NavBar = Backbone.View.extend({
"hide.bs.modal .modal": "_hideModal", "hide.bs.modal .modal": "_hideModal",
"click .importJSON": "_importJSON", "click .importJSON": "_importJSON",
"change #jsonInput": "_selectJSONFiles", "change #jsonInput": "_selectJSONFiles",
"click .savedUserSettings": "_loadSavedUser" "click .savedUserSettings": "_loadSavedUser",
"click .savedDemo": "_loadDemo"
}, },
initialize: function(){ initialize: function(){
...@@ -94,7 +95,7 @@ NavBar = Backbone.View.extend({ ...@@ -94,7 +95,7 @@ NavBar = Backbone.View.extend({
return function(e) { return function(e) {
var extension = filename.substr(filename.length - 5); var extension = filename.substr(filename.length - 5);
if (extension == ".json"){ if (extension == ".json"){
dmaGlobals.appState.loadLatticeFromJSON(e.target.result); dmaGlobals.appState.loadLatticeFromJSON(JSON.parse(e.target.result));
} else if (extension == ".user"){ } else if (extension == ".user"){
dmaGlobals.appState.loadUser(e.target.result); dmaGlobals.appState.loadUser(e.target.result);
} else console.warn("file type not recognized"); } else console.warn("file type not recognized");
...@@ -129,6 +130,14 @@ NavBar = Backbone.View.extend({ ...@@ -129,6 +130,14 @@ NavBar = Backbone.View.extend({
}); });
}, },
_loadDemo: function(e){
e.preventDefault();
var url = "data/demos/" + $(e.target).data("file");
$.getJSON( url, function(data) {
dmaGlobals.appState.loadLatticeFromJSON(data);
});
},
_showModal: function(e){ _showModal: function(e){
var input = $(e.target).find("input.filename"); var input = $(e.target).find("input.filename");
input.focus(); input.focus();
......
...@@ -314,7 +314,7 @@ AppState = Backbone.Model.extend({ ...@@ -314,7 +314,7 @@ AppState = Backbone.Model.extend({
loadLatticeFromJSON: function(data){ loadLatticeFromJSON: function(data){
dmaGlobals.lattice.clearCells(); dmaGlobals.lattice.clearCells();
this._setData(JSON.parse(data), false); this._setData(data, false);
dmaGlobals.lattice._updateLatticeType(null, null, null, true); dmaGlobals.lattice._updateLatticeType(null, null, null, true);
dmaGlobals.lattice.trigger("change:scale");//todo make this better dmaGlobals.lattice.trigger("change:scale");//todo make this better
}, },
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment