Commit dbab87de authored by Amanda Ghassaei's avatar Amanda Ghassaei

user contributed json in file menu

parent 449cf435
{"lattice":{"units":"inches","scale":2.78388,"cellSeparation":{"xy":0,"z":0},"cellType":"octa","connectionType":"edgeRot", "partType":"vox"},"assembler":{"camStrategy":"raster","placementOrder":"-X-YZ","camProcess":"shopbot","machineName":"shopbot","rapidHeight":6.9,"safeHeight":0.5,"rapidSpeeds":{"xy":6,"z":4},"feedRate":{"xy":0.1,"z":0.1}}}
\ No newline at end of file
{"lattice":{"units":"inches","scale":2.78388,"cellSeparation":{"xy":0,"z":0},"cellType":"octa","connectionType":"edgeRot","partType":"vox"},"assembler":{"camStrategy":"raster","placementOrder":"XYZ","camProcess":"gcode","machineName":"oneBitBot","rapidHeight":4.5,"rapidHeightRelative":true,"safeHeight":0.5,"stockPositionRelative":true,"multipleStockPositions":false,"stockSeparation":2.78388,"rapidSpeeds":{"xy":6,"z":4},"feedRate":{"xy":0.1,"z":0.1},"simSpeed":"10","simStockNum":0,"stockHeight":0, "stockFixed":true}}
\ No newline at end of file
{"lattice":{"units":"inches","scale":0.05,"cellSeparation":{"xy":0,"z":0},"cellType":"cube","connectionType":"gik", "partType":"lego"}}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
......@@ -32,11 +32,6 @@
</div>
<div class="collapse navbar-collapse" id="navbar-collapse-01">
<ul class="nav navbar-nav navbar-left">
<li><a data-menu-id="navDesign" class="menuHoverControls" href="#">Design</a></li>
<li><a data-menu-id="navSim" class="menuHoverControls" href="#">Simulate</a></li>
<li><a data-menu-id="navOptimize" class="menuHoverControls" href="#">Optimize</a></li>
<li><a data-menu-id="navAssemble" class="menuHoverControls" href="#">Assemble</a></li>
<li><a data-menu-id="navComm" class="menuHoverControls" href="#">Comm</a></li>
<li class="dropdown navDropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">File <b class="caret"></b></a>
<span class="dropdown-arrow"></span>
......@@ -47,17 +42,25 @@
<li class="dropdown-submenu">
<a tabindex="-1">Demo Files<span class="pull-right fui-arrow-right"></span></a>
<ul class="dropdown-menu">
<li><a data-file="oneBitBot.json" class="loadDemo" href="#">One Bit Assembly</a></li>
<li><a data-file="demos/oneBitBot.json" class="jsonFile" href="#">One Bit Assembly</a></li>
</ul></li>
<li class="divider"></li>
<li class="dropdown-submenu">
<a tabindex="-1">Load User Settings<span class="pull-right fui-arrow-right"></span></a>
<a tabindex="-1">Load User Data<span class="pull-right fui-arrow-right"></span></a>
<ul class="dropdown-menu">
<li class="dropdown-submenu">
<a tabindex="-1">Amanda<span class="pull-right fui-arrow-right"></span></a>
<ul class="dropdown-menu">
<li><a id="videoRendering" href="#">Video Rendering Setup</a></li>
</ul>
</li>
<li class="dropdown-submenu">
<a tabindex="-1">Will<span class="pull-right fui-arrow-right"></span></a>
<ul class="dropdown-menu">
<!--<li><a id="resetDefaultSettings" href="#">Reset Settings</a></li>-->
<li><a data-file="ben.user" class="loadUser" href="#">Ben</a></li>
<li><a data-file="matt.user" class="loadUser" href="#">Matt</a></li>
<li><a data-file="will.user" class="loadUser" href="#">Will</a></li>
<li><a class="importJSON" href="#">From File...</a></li>
<li><a class="jsonFile" data-file="will/bounds.json" href="#">Bounds</a></li>
<li><a class="jsonFile" data-file="will/capacitor.json" href="#">Capacitor</a></li>
</ul>
</li>
</ul>
</li>
<li><a id="saveUserSettings" data-toggle="modal" data-target="#saveUserModel" href="#">Save User Settings...</a></li>
......@@ -65,6 +68,11 @@
<li><a id="exportSTL" href="#">Export STL</a></li>
</ul>
</li>
<li><a data-menu-id="navDesign" class="menuHoverControls" href="#">Design</a></li>
<li><a data-menu-id="navSim" class="menuHoverControls" href="#">Simulate</a></li>
<li><a data-menu-id="navOptimize" class="menuHoverControls" href="#">Optimize</a></li>
<li><a data-menu-id="navAssemble" class="menuHoverControls" href="#">Assemble</a></li>
<li><a data-menu-id="navComm" class="menuHoverControls" href="#">Comm</a></li>
<li class="dropdown navDropdown">
<a href="#" class="dropdown-toggle" id="viewMenuDropdown" data-toggle="dropdown">View <b class="caret"></b></a>
<span class="dropdown-arrow"></span>
......
......@@ -12,8 +12,7 @@ define(['jquery', 'underscore', 'backbone', 'plist', 'lattice', 'text!navViewMen
events: {
"click a": "_makeSelection",
"click #reset3DView": "_reset3DNavigation",
"click #videoRendering": "_videoRenderingSetup"
"click #reset3DView": "_reset3DNavigation"
},
initialize: function(){
......@@ -49,11 +48,6 @@ define(['jquery', 'underscore', 'backbone', 'plist', 'lattice', 'text!navViewMen
this.model.reset3DNavigation();
},
_videoRenderingSetup: function(e){
e.preventDefault();
window.resizeTo(1000, 700);
},
render: function(){
this.$el.html(this.template(_.extend(this.model.toJSON(), plist, lattice.toJSON())));
......
......@@ -19,15 +19,13 @@ define(['jquery', 'underscore', 'backbone', 'fileSaver', 'navViewMenu', 'appStat
"click .saveJSON": "_save",
"click .saveAsJSON": "_saveAs",
// "change #saveAsFileName": "_saveAs",//detect enter key
"click .saveUser": "_saveUser",
"change #saveUserFileName": "_saveUser",//detect enter key
"click .importJSON": "_importJSON",
"change #jsonInput": "_selectJSONFiles",
"click .loadUser": "_loadUser",
"click .loadDemo": "_loadDemo",
"click .jsonFile": "_loadJSON",
"click #viewMenuDropdown": "_renderViewMenu"
"click #viewMenuDropdown": "_renderViewMenu",
"click #videoRendering": "_videoRenderingSetup"
},
initialize: function(){
......@@ -105,6 +103,11 @@ define(['jquery', 'underscore', 'backbone', 'fileSaver', 'navViewMenu', 'appStat
this.viewMenu.render();
},
_videoRenderingSetup: function(e){
e.preventDefault();
window.resizeTo(1000, 700);//todo this doesn't work
},
_save: function(e){
......@@ -119,13 +122,6 @@ define(['jquery', 'underscore', 'backbone', 'fileSaver', 'navViewMenu', 'appStat
$('#saveAsModel').modal('hide');
},
_saveUser: function(e){
e.preventDefault();
var fileName = $("#saveUserFileName").val();
fileSaver.saveUser(fileName);
$('#saveUserModel').modal('hide');
},
......@@ -152,24 +148,14 @@ define(['jquery', 'underscore', 'backbone', 'fileSaver', 'navViewMenu', 'appStat
var extension = filename.substr(filename.length - 5);
if (extension == ".json"){
fileSaver.loadFile(JSON.parse(e.target.result));
} else if (extension == ".user"){
fileSaver.loadUser(JSON.parse(e.target.result));
} else console.warn("file type not recognized");
}
})();
},
_loadUser: function(e){
e.preventDefault();
var url = "data/users/" + $(e.target).data("file");
$.getJSON( url, function(data) {
fileSaver.loadUser(data);
});
},
_loadDemo: function(e){
_loadJSON: function(e){
e.preventDefault();
var url = "data/demos/" + $(e.target).data("file");
var url = "data/" + $(e.target).data("file");
$.getJSON( url, function(data) {
fileSaver.loadFile(data);
});
......
......@@ -35,9 +35,3 @@
</ul>
</li>
<li><a class="" href="#">Keyboard Shortcuts</a></li>
\ No newline at end of file
<li class="dropdown-submenu">
<a tabindex="-1">Amanda's Stuff<span class="pull-right fui-arrow-right"></span></a>
<ul class="dropdown-menu">
<li><a class="customClick" id="videoRendering" href="#">Video Rendering Setup</a></li>
</ul>
</li>
\ No newline at end of file
......@@ -47,17 +47,6 @@ define(['underscore', 'fileSaverLib', 'lattice', 'materials', 'ribbon', 'menuWra
}
function saveUser(name){
if (!name || name == "" || name == undefined) name = "user";
var latticeData = _.omit(_getLatticeDataToSave(), ["cells", "cellsMin", "cellsMax", "numCells"]);
var assemblerData = _.omit(_getAssemblerDataToSave(), ["dataOut", "needsPostProcessing", "editsMadeToProgram"]);
var data = {
lattice:latticeData,
assembler:assemblerData
};
_saveFile(data, name, ".user");
}
function saveSequences(seqArray, name){
_saveFile(seqArray, name || "seqs", ".txt", true);
}
......@@ -113,7 +102,7 @@ define(['underscore', 'fileSaverLib', 'lattice', 'materials', 'ribbon', 'menuWra
lattice.clearCells();
var sparseCells = data.assembly.sparseCells;
_setData(lattice, _.omit(data.assembly, "sparseCells"));
if (sparseCells) lattice._updateLatticeConfig(sparseCells);
if (sparseCells) lattice._reloadCells(sparseCells);
ribbon.render();
menuWrapper.render();
}
......@@ -125,10 +114,6 @@ define(['underscore', 'fileSaverLib', 'lattice', 'materials', 'ribbon', 'menuWra
});
}
function loadUser(data){
_setData(data);
}
function _setData(object, data){
_.each(_.keys(data), function(key){
if (data[key] && data[key].x){//vector object
......@@ -146,9 +131,7 @@ define(['underscore', 'fileSaverLib', 'lattice', 'materials', 'ribbon', 'menuWra
saveMaterial: saveMaterial,
saveMachineConfig: saveMachineConfig,
// saveAssembler: saveAssembler,
// saveUser: saveUser,
loadFile: loadFile,
// loadUser: loadUser
saveSequences: saveSequences
}
});
\ No newline at end of file
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