Commit 63a60e33 authored by Amanda Ghassaei's avatar Amanda Ghassaei
Browse files

stopping pt

parent bffabbb2
...@@ -26,6 +26,9 @@ define(['underscore', 'appState', 'lattice', 'stlLoader', 'threeModel', 'cam', ' ...@@ -26,6 +26,9 @@ define(['underscore', 'appState', 'lattice', 'stlLoader', 'threeModel', 'cam', '
this.customHome = json.customHome || function(){}; this.customHome = json.customHome || function(){};
this.customPickUpStock = json.customPickUpStock || function(){}; this.customPickUpStock = json.customPickUpStock || function(){};
this.customPlacePart = json.customPlacePart || function(){}; this.customPlacePart = json.customPlacePart || function(){};
this.customFunctionsContext = {
clearHeight: 8
};
this.object3D = new THREE.Object3D(); this.object3D = new THREE.Object3D();
three.sceneAdd(this.object3D); three.sceneAdd(this.object3D);
...@@ -422,6 +425,12 @@ define(['underscore', 'appState', 'lattice', 'stlLoader', 'threeModel', 'cam', ' ...@@ -422,6 +425,12 @@ define(['underscore', 'appState', 'lattice', 'stlLoader', 'threeModel', 'cam', '
this.object3D = null; this.object3D = null;
}; };
Assembler.prototype.saveJSON = function(){
return {
}
};
Assembler.prototype.toJSON = function(){ Assembler.prototype.toJSON = function(){
var componentsJSON = {}; var componentsJSON = {};
_.each(this.components, function(component, id){ _.each(this.components, function(component, id){
......
...@@ -278,6 +278,11 @@ define(['underscore', 'cam', 'three'], function(_, cam, THREE){ ...@@ -278,6 +278,11 @@ define(['underscore', 'cam', 'three'], function(_, cam, THREE){
}; };
Component.prototype.saveJSON = function(){
};
Component.prototype.toJSON = function(){ Component.prototype.toJSON = function(){
var childIDs = []; var childIDs = [];
_.each(this.children, function(child){ _.each(this.children, function(child){
......
...@@ -14,6 +14,8 @@ require.config({ ...@@ -14,6 +14,8 @@ require.config({
bootstrapSlider: '../dependencies/bootstrap-slider/bootstrap-slider', bootstrapSlider: '../dependencies/bootstrap-slider/bootstrap-slider',
fileSaverLib: '../dependencies/loaders/FileSaver.min', fileSaverLib: '../dependencies/loaders/FileSaver.min',
numeric: '../dependencies/numeric-1.2.6', numeric: '../dependencies/numeric-1.2.6',
codeMirrorJS: '../dependencies/codemirror/javascript',
codeMirror: '../dependencies/codemirror/codemirror',
//three //three
three: '../dependencies/three', three: '../dependencies/three',
...@@ -141,6 +143,7 @@ require.config({ ...@@ -141,6 +143,7 @@ require.config({
navViewMenuTemplate: 'menus/templates/NavViewMenu.html', navViewMenuTemplate: 'menus/templates/NavViewMenu.html',
ribbonTemplate: 'menus/templates/Ribbon.html', ribbonTemplate: 'menus/templates/Ribbon.html',
modalViewTemplate: 'menus/templates/ModalView.html', modalViewTemplate: 'menus/templates/ModalView.html',
scriptView: 'menus/ScriptView',
menuWrapperTemplate: 'menus/templates/MenuWrapperView.html', menuWrapperTemplate: 'menus/templates/MenuWrapperView.html',
latticeMenuTemplate: 'menus/templates/LatticeMenuView.html', latticeMenuTemplate: 'menus/templates/LatticeMenuView.html',
importMenuTemplate: 'menus/templates/ImportMenuView.html', importMenuTemplate: 'menus/templates/ImportMenuView.html',
...@@ -230,6 +233,10 @@ require.config({ ...@@ -230,6 +233,10 @@ require.config({
}, },
'numeric': { 'numeric': {
exports: 'numeric' exports: 'numeric'
},
'codeMirror': {
deps: ['codeMirrorJS'],
exports: 'CodeMirror'
} }
} }
......
...@@ -3,87 +3,96 @@ ...@@ -3,87 +3,96 @@
*/ */
ScriptView = Backbone.View.extend({
el: "#scriptView", define(['jquery', 'underscore', 'backbone', 'appState', 'codeMirror'], function($, _, Backbone, appState, CodeMirror){
events: {
"click #runScript": "_runScript", var ScriptView = Backbone.View.extend({
"click #saveScript": "_saveScript",
"click #loadScript": "_loadScript" el: "#scriptView",
},
events: {
initialize: function(){ "click #runScript": "_runScript",
"click #saveScript": "_saveScript",
_.bindAll(this, "render", "_handleKeyStroke"); "click #loadScript": "_loadScript"
},
//bind events
$(document).bind('keydown', {}, this._handleKeyStroke); initialize: function(){
this.render();
_.bindAll(this, "render", "_handleKeyStroke");
this.listenTo(globals.appState, "change:scriptIsVisible", this._setVisibility);
}, //bind events
// $(document).bind('keydown', {}, this._handleKeyStroke);
_handleKeyStroke: function(e){ this.render();
if (e.keyCode == 82 && this.model.get("currentTab") == "script"){
if (e.shiftKey || !e.metaKey) return; this.listenTo(this.model, "change:scriptIsVisible", this._setVisibility);
},
// _handleKeyStroke: function(e){
// if (e.keyCode == 82 && this.model.get("currentTab") == "script"){
// if (e.shiftKey || !e.metaKey) return;
// e.preventDefault();
// e.stopPropagation();
// // appState.runScript(globals.codeMirror.getValue());
// }
// },
_runScript: function(e){
e.preventDefault(); e.preventDefault();
e.stopPropagation(); // appState.runScript(globals.codeMirror.getValue());
// globals.appState.runScript(globals.codeMirror.getValue()); },
}
}, // _saveScript: function(e){
// e.preventDefault();
_runScript: function(e){ // // appState.syncScript(globals.codeMirror.getValue());
e.preventDefault(); // // globals.saveFile(globals.script, "linkageScript", ".js");
// globals.appState.runScript(globals.codeMirror.getValue()); // },
}, //
// _loadScript: function(e){
_saveScript: function(e){ // e.preventDefault();
e.preventDefault(); // $("#fileInput").click();
// globals.appState.syncScript(globals.codeMirror.getValue()); // },
// globals.saveFile(globals.script, "linkageScript", ".js");
}, _setEditorHeight: function(){
var $editor = $('.CodeMirror');
_loadScript: function(e){ var height = this.$el.height()-$editor.position().top;
e.preventDefault(); height = Math.max(height, 250);
$("#fileInput").click(); $editor.css({height:height +"px"});
}, },
_setEditorHeight: function(){ _setVisibility: function(){
var $editor = $('.CodeMirror'); if(this.model.get("scriptIsVisible")) this._show();
var height = this.$el.height()-$editor.position().top; else this._hide();
height = Math.max(height, 250); },
$editor.css({height:height +"px"});
}, _hide: function(){
var width = this.$el.parent().width();
_setVisibility: function(){ this.$el.animate({left: "-" + width + "px"});
if(this.model.get("scriptIsVisible")) this._show(); },
else this._hide();
}, _show: function(){
this.$el.animate({left: "0"});
_hide: function(){ },
var width = this.$el.parent().width();
this.$el.animate({left: "-" + width + "px"}); render: function(){
}, this.$el.html(this.template({script:"test"}));
CodeMirror.fromTextArea(document.getElementById("scriptEditor"), {
_show: function(){ lineNumbers: true,
this.$el.animate({left: "0"}); mode: "javascript"
}, });
this._setEditorHeight();
render: function(){ },
this.$el.html(this.template({script:globals.script}));
globals.codeMirror = CodeMirror.fromTextArea(document.getElementById("scriptEditor"), { template: _.template('\
lineNumbers: true, <div class="col-sm-4"><a href="#" id="loadScript" class=" btn btn-lg btn-block btn-default">Load Script</a></div>\
mode: "javascript" <div class="col-sm-4"><a href="#" id="runScript" class=" btn btn-lg btn-block btn-default">Run Script&nbsp&nbsp&nbsp(CTRL/&#8984; + R)</a></div>\
}); <div class="col-sm-4"><a href="#" id="saveScript" class=" btn btn-lg btn-block btn-default">Save Script</a></div><br/><br/>\
this._setEditorHeight(); <textarea id="scriptEditor"><%= script %></textarea><br/>\
}, ')
template: _.template('\ });
<div class="col-sm-4"><a href="#" id="loadScript" class=" btn btn-lg btn-block btn-default">Load Script</a></div>\
<div class="col-sm-4"><a href="#" id="runScript" class=" btn btn-lg btn-block btn-default">Run Script&nbsp&nbsp&nbsp(CTRL/&#8984; + R)</a></div>\
<div class="col-sm-4"><a href="#" id="saveScript" class=" btn btn-lg btn-block btn-default">Save Script</a></div><br/><br/>\ return new ScriptView({model: appState});
<textarea id="scriptEditor"><%= script %></textarea><br/>\
')
}); });
\ No newline at end of file
...@@ -129,7 +129,6 @@ define(['three'], function(THREE){ ...@@ -129,7 +129,6 @@ define(['three'], function(THREE){
rapidHeight:30, rapidHeight:30,
rapidHeightRelative: true, rapidHeightRelative: true,
safeHeight: 4.5, safeHeight: 4.5,
clearHeight: 8,
originPosition: new THREE.Vector3(0,0,0), originPosition: new THREE.Vector3(0,0,0),
rapidSpeeds:{xy: 250, z: 250}, rapidSpeeds:{xy: 250, z: 250},
feedRate:{xy: 6, z: 6} feedRate:{xy: 6, z: 6}
......
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