From f522ce09d98bbb2812ed25bb942597d854d71a1c Mon Sep 17 00:00:00 2001 From: hwc487 Date: Wed, 11 Apr 2012 16:01:33 -0700 Subject: Rotate3D tool changes --- js/tools/RotateObject3DTool.js | 141 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 140 insertions(+), 1 deletion(-) (limited to 'js/tools/RotateObject3DTool.js') diff --git a/js/tools/RotateObject3DTool.js b/js/tools/RotateObject3DTool.js index 72af6eff..7b4ec083 100755 --- a/js/tools/RotateObject3DTool.js +++ b/js/tools/RotateObject3DTool.js @@ -4,7 +4,9 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. */ -var Montage = require("montage/core/core").Montage; +var Montage = require("montage/core/core").Montage, + viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils, + snapManager = require("js/helper-classes/3D/snap-manager").SnapManager; var Rotate3DToolBase = require("js/tools/Rotate3DToolBase").Rotate3DToolBase; var toolHandleModule = require("js/stage/tool-handle"); @@ -54,6 +56,143 @@ exports.RotateObject3DTool = Montage.create(Rotate3DToolBase, { } }, + initializeSnapping : { + value : function(event) + { + console.log( "initializeSnapping" ); + + this._mouseDownHitRec = null; + this._mouseUpHitRec = null; + + snapManager.clearAvoidList(); + snapManager.clearDragPlane(); + + // the translate tool does snap align to the bounds of the object only. + // turn off snap align to the cursor. This needs to be re-enabled in the mouse up method + snapManager.enableSnapAlign( false ); + + // snap to element and snap to grid are conditionally enabled based + // on the snap results of the mouse down. enable everything for the first snap + this._snapToElements = snapManager.elementSnapEnabledAppLevel(); + this._snapToGrid = snapManager.gridSnapEnabledAppLevel(); + + this._dragPlane = null; + this._clickedOnStage = false; + var do3DSnap = true; + + if(this._handleMode === null) + { + snapManager.enableElementSnap ( true ); + snapManager.enableGridSnap ( true ); + } +// else +// { +// this._delta = null; + // special case for z-translation +// if(this._handleMode === 0) +// { +// this._dragPlane = viewUtils.getNormalToUnprojectedElementPlane(this._target); +// snapManager.setupDragPlaneFromPlane(this._dragPlane); +// do3DSnap = false; + +// snapManager.enableElementSnap ( false ); +// snapManager.enableGridSnap ( false ); +// } +// } + + if (this._targets) + { + var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, + new WebKitPoint(event.pageX, event.pageY)); + + // do the snap before setting up the avoid list to allow + // a snap on the mouse down + var hitRec = snapManager.snap(point.x, point.y, do3DSnap); + +// if(this._handleMode === 2) +// { +// // translate z doesn't snap to element so hitRec's element will always be different +// // from what the browser says we clicked on. So, skip this check. +// } +// else +// { +// // Check that hitRec's element matches element that browser says we clicked on +// // TODO - This is still not working when using a handle that is on top of an +// // element that is not currently selected +// var elt = this.application.ninja.stage.GetSelectableElement(event); +// if(elt && (elt !== hitRec.getElement())) +// { +// hitRec = snapManager.findHitRecordForElement(elt); +// } +// if(elt === this.application.ninja.currentSelectedContainer) +// { +// this._clickedOnStage = true; +// } +// } + + // we don't want to snap to selected objects during the drag +// var len = this._targets.length; +// for(var i=0; i --- js/tools/RotateObject3DTool.js | 1 + 1 file changed, 1 insertion(+) (limited to 'js/tools/RotateObject3DTool.js') diff --git a/js/tools/RotateObject3DTool.js b/js/tools/RotateObject3DTool.js index 27352231..902cf05d 100755 --- a/js/tools/RotateObject3DTool.js +++ b/js/tools/RotateObject3DTool.js @@ -18,6 +18,7 @@ exports.RotateObject3DTool = Montage.create(Rotate3DToolBase, { _initializeToolHandles: { value: function() { + this.rotateStage = false; if(!this._handles) { this._handles = []; -- cgit v1.2.3 From 7b3ef287f248c07602aefa3ba2cc907e0d16493a Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 18 Apr 2012 13:42:18 -0700 Subject: Fixing some more merge issues. Signed-off-by: Nivesh Rajbhandari --- js/tools/RotateObject3DTool.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'js/tools/RotateObject3DTool.js') diff --git a/js/tools/RotateObject3DTool.js b/js/tools/RotateObject3DTool.js index 55c9586b..c1ddb286 100755 --- a/js/tools/RotateObject3DTool.js +++ b/js/tools/RotateObject3DTool.js @@ -61,7 +61,12 @@ exports.RotateObject3DTool = Montage.create(Rotate3DToolBase, { initializeSnapping : { value : function(event) { - console.log( "initializeSnapping" ); +// console.log( "initializeSnapping" ); + + var selectedElements = this.application.ninja.selectedElements; + if(this.rotateStage) { + selectedElements = [this.application.ninja.currentDocument.documentRoot]; + } this._mouseDownHitRec = null; this._mouseUpHitRec = null; @@ -102,7 +107,7 @@ exports.RotateObject3DTool = Montage.create(Rotate3DToolBase, { // } // } - if (this._targets) + if (selectedElements.length) { var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(event.pageX, event.pageY)); @@ -159,7 +164,7 @@ exports.RotateObject3DTool = Montage.create(Rotate3DToolBase, { if(!this._dragPlane) { - if (this._targets.length === 1) + if (selectedElements.length === 1) { this._dragPlane = viewUtils.getUnprojectedElementPlane(this._clickedObject); snapManager.setupDragPlaneFromPlane(this._dragPlane); -- cgit v1.2.3 From 1f2d84716ddca3cfc9e5457f67ec1b007b3455a8 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 18 Apr 2012 15:48:20 -0700 Subject: Moving initialzeSnapping routine from RotateObject3DTool tool to Rotate3DToolBase so Rotate Stage uses the same code. Signed-off-by: Nivesh Rajbhandari --- js/tools/RotateObject3DTool.js | 142 ----------------------------------------- 1 file changed, 142 deletions(-) (limited to 'js/tools/RotateObject3DTool.js') diff --git a/js/tools/RotateObject3DTool.js b/js/tools/RotateObject3DTool.js index c1ddb286..ec2fcc0c 100755 --- a/js/tools/RotateObject3DTool.js +++ b/js/tools/RotateObject3DTool.js @@ -58,148 +58,6 @@ exports.RotateObject3DTool = Montage.create(Rotate3DToolBase, { } }, - initializeSnapping : { - value : function(event) - { -// console.log( "initializeSnapping" ); - - var selectedElements = this.application.ninja.selectedElements; - if(this.rotateStage) { - selectedElements = [this.application.ninja.currentDocument.documentRoot]; - } - - this._mouseDownHitRec = null; - this._mouseUpHitRec = null; - - snapManager.clearAvoidList(); - snapManager.clearDragPlane(); - - // the translate tool does snap align to the bounds of the object only. - // turn off snap align to the cursor. This needs to be re-enabled in the mouse up method - snapManager.enableSnapAlign( false ); - - // snap to element and snap to grid are conditionally enabled based - // on the snap results of the mouse down. enable everything for the first snap - this._snapToElements = snapManager.elementSnapEnabledAppLevel(); - this._snapToGrid = snapManager.gridSnapEnabledAppLevel(); - - this._dragPlane = null; - this._clickedOnStage = false; - var do3DSnap = true; - - if(this._handleMode === null) - { - snapManager.enableElementSnap ( true ); - snapManager.enableGridSnap ( true ); - } -// else -// { -// this._delta = null; - // special case for z-translation -// if(this._handleMode === 0) -// { -// this._dragPlane = viewUtils.getNormalToUnprojectedElementPlane(this._target); -// snapManager.setupDragPlaneFromPlane(this._dragPlane); -// do3DSnap = false; - -// snapManager.enableElementSnap ( false ); -// snapManager.enableGridSnap ( false ); -// } -// } - - if (selectedElements.length) - { - var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, - new WebKitPoint(event.pageX, event.pageY)); - - // do the snap before setting up the avoid list to allow - // a snap on the mouse down - var hitRec = snapManager.snap(point.x, point.y, do3DSnap); - -// if(this._handleMode === 2) -// { -// // translate z doesn't snap to element so hitRec's element will always be different -// // from what the browser says we clicked on. So, skip this check. -// } -// else -// { -// // Check that hitRec's element matches element that browser says we clicked on -// // TODO - This is still not working when using a handle that is on top of an -// // element that is not currently selected -// var elt = this.application.ninja.stage.GetSelectableElement(event); -// if(elt && (elt !== hitRec.getElement())) -// { -// hitRec = snapManager.findHitRecordForElement(elt); -// } -// if(elt === this.application.ninja.currentSelectedContainer) -// { -// this._clickedOnStage = true; -// } -// } - - // we don't want to snap to selected objects during the drag -// var len = this._targets.length; -// for(var i=0; i