From 42c2a480a3883389e47d4ec291dfb55d99cf4b7f Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 29 May 2012 10:26:19 -0700 Subject: Cache perspective distance lookup to speed up user interaction. Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/3D/view-utils.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'js/helper-classes/3D') diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js index a3d09404..3c7ae6ff 100755 --- a/js/helper-classes/3D/view-utils.js +++ b/js/helper-classes/3D/view-utils.js @@ -195,7 +195,12 @@ exports.ViewUtils = Montage.create(Component, { getPerspectiveDistFromElement: { value: function( elt ) { - return ElementsMediator.getPerspectiveDist(elt); + var pDist = ElementsMediator.getPerspectiveDist(elt); + if(pDist === "none") { + return null; + } else { + return pDist; + } } }, @@ -1320,14 +1325,6 @@ exports.ViewUtils = Montage.create(Component, { } }, - getCurrentDocument: - { - value: function() - { - return snapManagerModule.SnapManager.application.ninja.currentDocument; - } - }, - setStageZoom: { value:function( globalPt, zoomFactor ) { var localPt; -- cgit v1.2.3 From 2fd6db5f46208a5aa8fa58d090f795e5b7eb99bb Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 29 May 2012 10:35:06 -0700 Subject: Sped up user-interaction by moving grid drawing into its own canvas so the layout code doesn't have to be run when modifying selected elements. Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/3D/draw-utils.js | 7 +++---- js/helper-classes/3D/snap-manager.js | 5 ++--- 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'js/helper-classes/3D') diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index 871b832d..75aa308c 100755 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js @@ -126,7 +126,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { //initialize with current document this._eltArray = []; this._planesArray = []; - this.setDrawingSurfaceElement(stage.canvas); + this.setDrawingSurfaceElement(stage.gridCanvas); this.setSourceSpaceElement( this.application.ninja.currentDocument.model.documentRoot); this.setWorkingPlane( [0,0,1,0] ); @@ -307,7 +307,6 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { } if(!changed) { - stage.layout.draw(); this.drawWorkingPlane(); this.draw3DCompass(); } @@ -631,8 +630,8 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { if (!this.isDrawingGrid()) return; var saveContext = this.getDrawingSurfaceElement(); - //this.setDrawingSurfaceElement(window.stageManager.layoutCanvas); - this.setDrawingSurfaceElement(this.application.ninja.stage.layoutCanvas); + this.setDrawingSurfaceElement(this.application.ninja.stage.gridCanvas); + this.clear(); // 3 coordinate axes for the plane var zAxis = [this._workingPlane[0], this._workingPlane[1], this._workingPlane[2]]; diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js index 069c6022..4dcda24a 100755 --- a/js/helper-classes/3D/snap-manager.js +++ b/js/helper-classes/3D/snap-manager.js @@ -21,8 +21,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { /////////////////////////////////////////////////////////////////////// // Instance variables /////////////////////////////////////////////////////////////////////// - drawingCanvas: { value: null, writable: true}, - + // we keep a stack of working planes to facilitate working on other planes temporarily _workingPlaneStack : { value: [], writable: true }, @@ -2124,7 +2123,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { if (hitRec) { var saveContext = drawUtils.getDrawingSurfaceElement(); - drawUtils.setDrawingSurfaceElement(this.drawingCanvas); + drawUtils.setDrawingSurfaceElement(this.application.ninja.stage.drawingCanvas); var context = drawUtils.getDrawingContext(); if (context) { -- cgit v1.2.3 From 961830a1ab076db70577df735f43cae5e8559e83 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 29 May 2012 14:55:19 -0700 Subject: Moving layout and stageDeps' handleOpenDocument into stage. Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/3D/draw-utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/helper-classes/3D') diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index 75aa308c..9e9a2241 100755 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js @@ -627,11 +627,11 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { { value: function () { + this.application.ninja.stage.clearGridCanvas(); if (!this.isDrawingGrid()) return; var saveContext = this.getDrawingSurfaceElement(); this.setDrawingSurfaceElement(this.application.ninja.stage.gridCanvas); - this.clear(); // 3 coordinate axes for the plane var zAxis = [this._workingPlane[0], this._workingPlane[1], this._workingPlane[2]]; -- cgit v1.2.3 From 820005437e7270e72b865a3436d7148e1dd19900 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 29 May 2012 15:42:24 -0700 Subject: Fixed bug with scrolling too much when moving objects in negative space. Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/3D/draw-utils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/helper-classes/3D') diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index 9e9a2241..c98ad8bc 100755 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js @@ -276,8 +276,8 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { stage = this.application.ninja.stage, minLeft = stage.userPaddingLeft, minTop = stage.userPaddingTop, - docLeft = stage.documentOffsetLeft, - docTop = stage.documentOffsetTop, + docLeft = stage.userContentLeft, + docTop = stage.userContentTop, l, t, plane, -- cgit v1.2.3 From 0b830a8c6415e9cc255d1593a05ae3fa9d94c5e2 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 31 May 2012 14:31:00 -0700 Subject: Adding back the stage references in the 3d classes. Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/3D/snap-manager.js | 8 +++++--- js/helper-classes/3D/view-utils.js | 38 +++++++++++++++++++++++------------- 2 files changed, 29 insertions(+), 17 deletions(-) (limited to 'js/helper-classes/3D') diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js index 4dcda24a..e3756f32 100755 --- a/js/helper-classes/3D/snap-manager.js +++ b/js/helper-classes/3D/snap-manager.js @@ -22,6 +22,8 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { // Instance variables /////////////////////////////////////////////////////////////////////// + currentStage: { value: null }, + // we keep a stack of working planes to facilitate working on other planes temporarily _workingPlaneStack : { value: [], writable: true }, @@ -82,14 +84,14 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { popWorkingPlane : { value: function () { workingPlane = this._workingPlaneStack.pop(); return workingPlane; }}, getStageWidth : { value: function () { - return parseInt(this.application.ninja.currentDocument.model.documentRoot.offsetWidth); + return parseInt(this.currentStage.offsetWidth); }}, getStageHeight : { value: function () { - return parseInt(this.application.ninja.currentDocument.model.documentRoot.offsetHeight); + return parseInt(this.currentStage.offsetHeight); }}, - getStage : { value: function() { return this.application.ninja.currentDocument.model.documentRoot; }}, + getStage : { value: function() { return this.currentStage; }}, getGridVertexHitRad : { value: function() { return this._gridVertexHitRad; }}, getGridEdgeHitRad : { value: function() { return this._gridEdgeHitRad; }}, diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js index 3c7ae6ff..5a128408 100755 --- a/js/helper-classes/3D/view-utils.js +++ b/js/helper-classes/3D/view-utils.js @@ -24,6 +24,9 @@ exports.ViewUtils = Montage.create(Component, { // keep a stack of viewport objects _viewportObjStack: { value: []}, + _rootElement: { value: null}, + _stageElement: { value: null}, + /////////////////////////////////////////////////////////////////////// // Property accessors /////////////////////////////////////////////////////////////////////// @@ -36,6 +39,13 @@ exports.ViewUtils = Montage.create(Component, { }, getViewportObj: { value: function() { return this.m_viewportObj; } }, + setRootElement: { value: function( elt ) { this._rootElement = elt; } }, + getRootElement: { value: function () { return this._rootElement; } }, + + setStageElement: { value: function( elt ) { this._stageElement = elt; } }, + getStageElement: { value: function () { return this._stageElement; } }, + + getPerspectiveDistance: { value: function () { return this._perspectiveDist; } }, /////////////////////////////////////////////////////////////////////// @@ -285,7 +295,7 @@ exports.ViewUtils = Montage.create(Component, { // into stage world space. postViewToStageWorld: { value: function( localPt, elt ) { - if ((elt == null) || (elt === this.application.ninja.currentDocument.model.documentRoot)) return localPt; + if ((elt == null) || (elt === this._stageElement)) return localPt; // get the 3D transformation and 2D offset from the element var pt = localPt.slice(0); @@ -312,7 +322,7 @@ exports.ViewUtils = Montage.create(Component, { this.popViewportObj(); // check if we are done - if (parent === this.application.ninja.currentDocument.model.documentRoot) break; + if (parent === this._stageElement) break; if (this.elementHas3D( parent )) { @@ -344,10 +354,10 @@ exports.ViewUtils = Montage.create(Component, { // if (child === this.application.ninja.currentDocument.model.documentRoot) break; // child = child.offsetParent; - if (child === this.application.ninja.currentDocument.model.documentRoot) break; - if (child === this.application.ninja.currentDocument.model.documentRoot.parentNode) break; + if (child === this._stageElement) break; + if (child === this._rootElement) break; child = child.offsetParent; - if (child === this.application.ninja.currentDocument.model.documentRoot.parentNode) break; + if (child === this._rootElement) break; } ///////////////////////////////////////////////////////// @@ -397,7 +407,7 @@ exports.ViewUtils = Montage.create(Component, { { // TODO - Commenting out flatten support until new perspective workflow is fully working // if (flatten) pt[2] = 0; -// var flatten = (parent !== this.application.ninja.currentDocument.model.documentRoot.parentNode) && (ElementsMediator.getProperty(parent, "-webkit-transform-style") !== "preserve-3d"); +// var flatten = (parent !== this._rootElement) && (ElementsMediator.getProperty(parent, "-webkit-transform-style") !== "preserve-3d"); // if(flatten) // { // pt[2] = 0; @@ -682,7 +692,7 @@ exports.ViewUtils = Montage.create(Component, { // if (elt.__ninjaXOff) xOff = elt.__ninjaXOff; // if (elt.__ninjaYOff) yOff = elt.__ninjaYOff; var offset = [xOff, yOff]; - if(elt.offsetParent && (elt.offsetParent !== this.application.ninja.currentDocument.model.documentRoot)) + if(elt.offsetParent && (elt.offsetParent !== this._stageElement)) { var pS = elt.ownerDocument.defaultView.getComputedStyle(elt.offsetParent); @@ -698,7 +708,7 @@ exports.ViewUtils = Montage.create(Component, { } } - if(elt === this.application.ninja.currentDocument.model.documentRoot) + if(elt === this._stageElement) { // TODO - Call a routine from the user document controller to get the offsets/margins // Once we expose the document controller to ViewUtils @@ -989,7 +999,7 @@ exports.ViewUtils = Montage.create(Component, { glmat4.multiply( v2s, mat, mat ); // TODO - Commenting out flatten support until new perspective workflow is fully working -// var flatten = (elt !== this.application.ninja.currentDocument.model.documentRoot.parentNode) && (elt.parentElement !== this.application.ninja.currentDocument.model.documentRoot.parentNode) && (ElementsMediator.getProperty(elt.parentElement, "-webkit-transform-style") !== "preserve-3d"); +// var flatten = (elt !== this._rootElement) && (elt.parentElement !== this._rootElement) && (ElementsMediator.getProperty(elt.parentElement, "-webkit-transform-style") !== "preserve-3d"); // if(flatten) // { // glmat4.multiply( zMat, mat, mat ); @@ -1003,10 +1013,10 @@ exports.ViewUtils = Montage.create(Component, { this.popViewportObj(); - if (elt === this.application.ninja.currentDocument.model.documentRoot) break; - if (elt === this.application.ninja.currentDocument.model.documentRoot.parentNode) break; + if (elt === this._stageElement) break; + if (elt === this._rootElement) break; elt = elt.offsetParent; - if (elt === this.application.ninja.currentDocument.model.documentRoot.parentNode) break; + if (elt === this._rootElement) break; } return mat; @@ -1040,7 +1050,7 @@ exports.ViewUtils = Montage.create(Component, { // multiply all the matrices together //mat = s2v.multiply( mat ); glmat4.multiply( s2v, mat, mat ); - if (elt === this.application.ninja.currentDocument.model.documentRoot) break; + if (elt === this._stageElement) break; //mat = objMat.multiply( mat ); glmat4.multiply( objMat, mat, mat ); if(shouldProject && pDist) @@ -1089,7 +1099,7 @@ exports.ViewUtils = Montage.create(Component, { // multiply all the matrices together //mat = s2v.multiply( mat ); glmat4.multiply( s2v, mat, mat ); - if (elt === this.application.ninja.currentDocument.model.documentRoot) break; + if (elt === this._stageElement) break; //mat = objMat.multiply( mat ); if (shouldLocalTransform) { glmat4.multiply( objMat, mat, mat ); -- cgit v1.2.3 From 6307b0930f1a8452de954ae16e293da2f575db04 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 31 May 2012 14:49:41 -0700 Subject: removing the last closeDocument handler Signed-off-by: Valerio Virgillito --- js/helper-classes/3D/draw-utils.js | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'js/helper-classes/3D') diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index c98ad8bc..a793b643 100755 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js @@ -112,7 +112,6 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { this.eventManager.addEventListener("elementsRemoved", this, false); this.eventManager.addEventListener("elementChange", this, false); this.eventManager.addEventListener("elementChanging", this, false); - this.eventManager.addEventListener("closeDocument", this, false); this.eventManager.addEventListener("elementReplaced", this, false); } }, @@ -164,15 +163,6 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { } }, - handleCloseDocument:{ - value: function() { - if(this.application.ninja.documentController._documents.length === 0){ - this._eltArray.length = 0; - this._planesArray.length = 0; - } - } - }, - handleElementAdded: { value: function(event) { var elements = event.detail; -- cgit v1.2.3