From 4ba680a7e9168d0f505a81e42a287dfbc54b4d7d Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Tue, 1 May 2012 15:26:37 -0700 Subject: Preliminary IO to new DOM view --- js/document/models/html.js | 1 - 1 file changed, 1 deletion(-) (limited to 'js/document/models/html.js') diff --git a/js/document/models/html.js b/js/document/models/html.js index ff57454b..f45a0e21 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js @@ -14,7 +14,6 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { //////////////////////////////////////////////////////////////////// // hasTemplate: { - enumerable: false, value: false } //////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From efe62dff2ba6894551fb9679d150255bae5af36e Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Fri, 4 May 2012 16:00:14 -0700 Subject: Draw 3d grid by default since app model is not hooked up yet. Signed-off-by: Nivesh Rajbhandari --- js/document/models/html.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'js/document/models/html.js') diff --git a/js/document/models/html.js b/js/document/models/html.js index f45a0e21..5eedb731 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js @@ -15,6 +15,10 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { // hasTemplate: { value: false + }, + + draw3DGrid: { + value: false } //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From b8c27edc106818ff84f93ebe30ce50359a03885b Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Mon, 7 May 2012 13:21:31 -0700 Subject: Adding webGL support for opening files Added I/O for loading webGL on open file. I/O support for saving to come. --- js/document/models/html.js | 197 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 194 insertions(+), 3 deletions(-) (limited to 'js/document/models/html.js') diff --git a/js/document/models/html.js b/js/document/models/html.js index 5eedb731..e0a18850 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js @@ -7,7 +7,10 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot //////////////////////////////////////////////////////////////////////// // var Montage = require("montage/core/core").Montage, - BaseDocumentModel = require("js/document/models/base").BaseDocumentModel; + BaseDocumentModel = require("js/document/models/base").BaseDocumentModel, + MaterialsModel = require("js/models/materials-model").MaterialsModel, + NJUtils = require("js/lib/NJUtils").NJUtils, + GLWorld = require("js/lib/drawing/world").World; //////////////////////////////////////////////////////////////////////// // exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { @@ -16,10 +19,198 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { hasTemplate: { value: false }, - + //////////////////////////////////////////////////////////////////// + // draw3DGrid: { value: false - } + }, + //////////////////////////////////////////////////////////////////// + // + _glData: { + value: null + }, + //////////////////////////////////////////////////////////////////// + // + glData: { + // + get: function() { + // + var elt = this.views.design.iframe.contentWindow.document.body; + // + if (elt) { + var matLib = MaterialsModel.exportMaterials(); + this._glData = [matLib]; + this.collectGLData(elt, this._glData ); + } else { + this._glData = null + } + // + return this._glData; + }, + // + set: function(value) { + // + var elt = this.views.design.iframe.contentWindow.document.body; + // + if (elt) { + /* + // Use this code to test the runtime version of WebGL + var cdm = new NinjaCvsRt.CanvasDataManager(); + cdm.loadGLData(elt, value, null ); + */ + + // + var i, nWorlds= value.length; + // + for (i = 0; i < nWorlds; i++) { + // get the data for the next canvas + var importStr = value[i], id, jObj, index = importStr.indexOf(';'), matLibStr, matLibObj, startIndex, endIndex, canvas, useWebGL, world; + // determine if it is the new (JSON) or old style format + if ((importStr[0] === 'v') && (index < 24)) { + // JSON format. pull off the + importStr = importStr.substr(index+1); + jObj = JSON.parse(importStr); + id = jObj.id; + } else { + // at this point the data could be either the materials library or + // an old style world. We can determine which by converting the string + // to an object via JSON.parse. That operation will fail if the string + // is an old style world. + matLibStr = 'materialLibrary;'; + index = importStr.indexOf(matLibStr); + if (index == 0) { + importStr = importStr.substr(matLibStr.length); + matLibObj = JSON.parse(importStr); + MaterialsModel.importMaterials(matLibObj); + } else { + startIndex = importStr.indexOf("id: "); + if (startIndex >= 0) { + endIndex = importStr.indexOf("\n", startIndex); + if (endIndex > 0) id = importStr.substring(startIndex+4, endIndex); + } + } + } + // + if (id != null) { + // + canvas = this.findCanvasWithID(id, elt); + // + if (canvas) { + // + if (!canvas.elementModel) { + NJUtils.makeElementModel(canvas, "Canvas", "shape", true); + } + // + if (canvas.elementModel) { + if (canvas.elementModel.shapeModel.GLWorld) { + canvas.elementModel.shapeModel.GLWorld.clearTree(); + } + // + if (jObj) { + useWebGL = jObj.webGL; + world = new GLWorld(canvas, useWebGL); + world.importJSON(jObj); + } + // + this.buildShapeModel(canvas.elementModel, world); + } + } + } + } + } + } + }, + //////////////////////////////////////////////////////////////////// + // + findCanvasWithID: { + value: function(id, elt) { + // + var i, child, nKids, foundElt, cid = elt.getAttribute("data-RDGE-id"); + // + if (cid == id) return elt; + // + if (elt.children) { + nKids = elt.children.length; + for (i=0; i= 0) { - endIndex = importStr.indexOf("\n", startIndex); - if (endIndex > 0) id = importStr.substring(startIndex+4, endIndex); - } - } - } - // - if (id != null) { - // - canvas = this.findCanvasWithID(id, elt); - // - if (canvas) { - // - if (!canvas.elementModel) { - NJUtils.makeElementModel(canvas, "Canvas", "shape", true); - } - // - if (canvas.elementModel) { - if (canvas.elementModel.shapeModel.GLWorld) { - canvas.elementModel.shapeModel.GLWorld.clearTree(); - } - // - if (jObj) { - useWebGL = jObj.webGL; - world = new GLWorld(canvas, useWebGL); - world.importJSON(jObj); - } - // - this.buildShapeModel(canvas.elementModel, world); - } - } - } - } - } - } - }, - //////////////////////////////////////////////////////////////////// - // - findCanvasWithID: { - value: function(id, elt) { - // - var i, child, nKids, foundElt, cid = elt.getAttribute("data-RDGE-id"); - // - if (cid == id) return elt; - // - if (elt.children) { - nKids = elt.children.length; - for (i=0; i --- js/document/models/html.js | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'js/document/models/html.js') diff --git a/js/document/models/html.js b/js/document/models/html.js index 1639a8e2..2764a6d6 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js @@ -26,9 +26,36 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { // webGlHelper: { value: webGlDocumentHelper - } + }, //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// + userComponents: { + value: {} + }, + + /** + * Add a reference to a component instance to the userComponents hash using the + * element UUID + */ + setComponentInstance: { + value: function(instance, el) { + this.userComponents[el.uuid] = instance; + } + }, + + /** + * Returns the component instance obj from the element + */ + getComponentFromElement: { + value: function(el) { + if(el) { + if(el.uuid) return this.userComponents[el.uuid]; + } else { + return null; + } + } + } + }); //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// \ No newline at end of file -- cgit v1.2.3 From 3811f72f8cd8caaa2d13fa695b918f25facb85c5 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Wed, 9 May 2012 16:28:13 -0700 Subject: Preliminary Montage Template Cleanup The template creator is currently not returning serializing code, but does clean the document. Need to investigate reason why, currently all components are removed on save. --- js/document/models/html.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'js/document/models/html.js') diff --git a/js/document/models/html.js b/js/document/models/html.js index 2764a6d6..b57ff832 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js @@ -22,30 +22,30 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { draw3DGrid: { value: false }, + //////////////////////////////////////////////////////////////////// + // + baseHref: { + value: null + }, //////////////////////////////////////////////////////////////////// // webGlHelper: { value: webGlDocumentHelper }, - //////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////// + // userComponents: { value: {} }, - - /** - * Add a reference to a component instance to the userComponents hash using the - * element UUID - */ + //////////////////////////////////////////////////////////////////// + //Add a reference to a component instance to the userComponents hash using the element UUID setComponentInstance: { value: function(instance, el) { this.userComponents[el.uuid] = instance; } }, - - /** - * Returns the component instance obj from the element - */ + //////////////////////////////////////////////////////////////////// + //Returns the component instance obj from the element getComponentFromElement: { value: function(el) { if(el) { @@ -55,7 +55,8 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { } } } - + //////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////// }); //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// \ No newline at end of file -- cgit v1.2.3 From 402a369c7bf164c3c6686be3a33f5e36f25e4130 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 16 May 2012 23:19:32 -0700 Subject: document controller and stage view code cleanup Signed-off-by: Valerio Virgillito --- js/document/models/html.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'js/document/models/html.js') diff --git a/js/document/models/html.js b/js/document/models/html.js index b57ff832..67457863 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js @@ -16,6 +16,11 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { // hasTemplate: { value: false + }, + //////////////////////////////////////////////////////////////////// + // + selection: { + value: [] }, //////////////////////////////////////////////////////////////////// // -- cgit v1.2.3 From 66edf78c7e5df11218ef733686965beab05c7c7d Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 18 May 2012 14:01:00 -0700 Subject: fixing a scrolling issue when multiple documents are switched Signed-off-by: Valerio Virgillito --- js/document/models/html.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'js/document/models/html.js') diff --git a/js/document/models/html.js b/js/document/models/html.js index 67457863..a97b4b5a 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js @@ -27,6 +27,23 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { draw3DGrid: { value: false }, + //////////////////////////////////////////////////////////////////// + // + scrollLeft: { + value: null + }, + + scrollTop: { + value: null + }, + + userContentLeft: { + value: null + }, + + userContentTop: { + value: null + }, //////////////////////////////////////////////////////////////////// // baseHref: { -- cgit v1.2.3 From 2b207ef8b2594927f8cd6cd63a8483d205cb86c4 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 22 May 2012 15:41:51 -0700 Subject: fixing the selection in multiple documents and some code cleanup Signed-off-by: Valerio Virgillito --- js/document/models/html.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'js/document/models/html.js') diff --git a/js/document/models/html.js b/js/document/models/html.js index a97b4b5a..9cc8ce92 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js @@ -21,6 +21,11 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { // selection: { value: [] + }, + //////////////////////////////////////////////////////////////////// + // + selectionContainer: { + value: [] }, //////////////////////////////////////////////////////////////////// // -- cgit v1.2.3 From 5914c5b2209c4b8daac4249bb76cda5c9314c4e6 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 24 May 2012 00:07:23 -0700 Subject: Cleaning up referencing to 'documentRoot' and '_document' Moved to reference new model in DOM architecture rework. This should not affect anything, just moving the references, and also the setting to the render methods in the design view. --- js/document/models/html.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'js/document/models/html.js') diff --git a/js/document/models/html.js b/js/document/models/html.js index 9cc8ce92..fd42d4de 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js @@ -63,6 +63,11 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { // userComponents: { value: {} + }, + //////////////////////////////////////////////////////////////////// + // + documentRoot: { + value: null }, //////////////////////////////////////////////////////////////////// //Add a reference to a component instance to the userComponents hash using the element UUID -- cgit v1.2.3