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