From 4bec28fbd8371deceffd1563190cb5e399d554d3 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 16 Mar 2012 16:36:04 -0700 Subject: Squashed commit of SnapManagerFixes Signed-off-by: Valerio Virgillito --- js/tools/modifier-tool-base.js | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'js/tools/modifier-tool-base.js') diff --git a/js/tools/modifier-tool-base.js b/js/tools/modifier-tool-base.js index 80f7d758..94b806fd 100755 --- a/js/tools/modifier-tool-base.js +++ b/js/tools/modifier-tool-base.js @@ -134,7 +134,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { var hitRec = snapManager.snap(point.x, point.y, do3DSnap); // TODO - Check that hitRec's element matches element that browser says we clicked on - var elt = this.application.ninja.stage.GetElement(event); + var elt = this.application.ninja.stage.GetSelectableElement(event); if(elt !== hitRec.getElement()) { hitRec = snapManager.findHitRecordForElement(elt); @@ -552,6 +552,9 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { // update the target this._mouseUpHitRec = hitRec; + var pt = hitRec.getScreenPoint(); + this.upPoint.x = pt[0]; + this.upPoint.y = pt[1]; } } } @@ -579,12 +582,15 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { this.downPoint.x = null; this.downPoint.y = null; + this.upPoint.x = null; + this.upPoint.y = null; // this.isDrawing = false; if(this._canSnap) { this.cleanupSnap(); } + this._mode = 0; } }, @@ -764,6 +770,8 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { captureSelectionDrawn: { value: function(event){ this._targets = []; + this._origin = null; + this._delta = null; var len = this.application.ninja.selectedElements.length; if(len) @@ -866,7 +874,6 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { this._updateTargets(true); } - this.endDraw(event); this._hasDraw = false; } if(this._handleMode !== null) @@ -874,6 +881,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { this._handleMode = null; this._delta = null; } + this.endDraw(event); this.DrawHandles(); } }, @@ -998,19 +1006,6 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { } }, - _updateDelta: { - value: function(delta, handleMode){ - if(this._clickedObject !== this.application.ninja.currentDocument.documentRoot) - { - this._delta += ~~(delta[handleMode]); - } - else - { - this._delta = ~~(delta[handleMode]); - } - } - }, - modifyElements: { value: function(data, event) { // override in subclasses. -- cgit v1.2.3 From dc9650af5760b1f93d6e93a383eabceacfdc0ad8 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Mon, 2 Apr 2012 15:40:25 -0700 Subject: Snapping fixes. --- js/tools/modifier-tool-base.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'js/tools/modifier-tool-base.js') diff --git a/js/tools/modifier-tool-base.js b/js/tools/modifier-tool-base.js index 94b806fd..07b28747 100755 --- a/js/tools/modifier-tool-base.js +++ b/js/tools/modifier-tool-base.js @@ -25,6 +25,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { _snapParam: { value: null }, _snapIndex: { value: -1 }, _useQuadPt: { value: false }, + _shouldUseQuadPt: { value: false }, // we set snapping capabilities depending on the tool. // The following variables are set in a tool's initializeSnapping method called on mouse down. @@ -175,6 +176,10 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { // } } + // only do quadrant snapping if the 4 corners of the element are in the drag plane + var sign = MathUtils.fpSign( VecUtils.vecDot(3,this._dragPlane,[0,0,1]) + this._dragPlane[3] - 1.0); + this._shouldUseQuadPt = (sign == 0) + var wpHitRec = hitRec.convertToWorkingPlane( this._dragPlane ); this._mouseDownHitRec = wpHitRec; this._mouseUpHitRec = null; @@ -236,6 +241,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { } } + //console.log( "ParameterizeSnap: " + paramPt ); return paramPt; } }, @@ -284,14 +290,16 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { y = x0 + ty*dy, z = 0.0; var localPt = [x,y,z]; + globalPt = viewUtils.localToGlobal( localPt, elt ); // add in the delta var hitPt = this.GetObjectHitPoint(); var scrPt = viewUtils.localToGlobal( hitPt, this._clickedObject ); - var delta = [xEvent-scrPt[0], yEvent-scrPt[1]]; + var delta = [xEvent-scrPt[0], yEvent-scrPt[1], 0-scrPt[2]]; globalPt[0] += delta[0]; globalPt[1] += delta[1]; + globalPt[2] += delta[2]; } return globalPt; @@ -517,7 +525,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { // do the snap var quadPt; - if (mouseIsDown) + if (mouseIsDown && !do3DSnap && this._shouldUseQuadPt && (this._handleMode === null) && (this._mode === 0)) quadPt = this.GetQuadrantSnapPoint(x,y); var hitRec = snapManager.snap(x, y, do3DSnap, quadPt ); @@ -806,6 +814,8 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { HandleLeftButtonDown: { value: function(event) { + console.log( "modifier-tool-base.HandleLeftButtonDown" ); + var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(event.pageX, event.pageY)); this.downPoint.x = point.x; this.downPoint.y = point.y; -- cgit v1.2.3 From bf815cbda0f7a4f2b8ca9532745fa525ed60c8d3 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Mon, 2 Apr 2012 16:58:54 -0700 Subject: IKNinja-1376 - 3D values reverted when using Selection tool to move the object. (Only happen when 3D values set in PI) We need to update the undo array for the tool if values are changed outside the active tool. I think this was the same bug causing IKNinja-1411. Signed-off-by: Nivesh Rajbhandari --- js/tools/modifier-tool-base.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'js/tools/modifier-tool-base.js') diff --git a/js/tools/modifier-tool-base.js b/js/tools/modifier-tool-base.js index 94b806fd..f58ecb53 100755 --- a/js/tools/modifier-tool-base.js +++ b/js/tools/modifier-tool-base.js @@ -448,6 +448,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { { this.isDrawing = true; this.application.ninja.stage.showSelectionBounds = false; + this._updateTargets(); if(this._canSnap) { @@ -785,7 +786,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { { this.target = this.application.ninja.currentDocument.documentRoot; } - this._updateTargets(); +// this._updateTargets(); } else { -- cgit v1.2.3 From 4d132fcbde4540c2cac6c0df613940353e2690f6 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 3 Apr 2012 12:03:16 -0700 Subject: Give user feedback about which element the Fill/InkBottle tools will act on. Signed-off-by: Nivesh Rajbhandari --- js/tools/modifier-tool-base.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'js/tools/modifier-tool-base.js') diff --git a/js/tools/modifier-tool-base.js b/js/tools/modifier-tool-base.js index f58ecb53..a1812650 100755 --- a/js/tools/modifier-tool-base.js +++ b/js/tools/modifier-tool-base.js @@ -758,6 +758,11 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { snapManager.enableGridSnap( snapManager.gridSnapEnabledAppLevel() ); this.eventManager.removeEventListener( "toolOptionsChange", this, false); this.eventManager.removeEventListener( "toolDoubleClick", this, false); + + if (this._targetedElement) { + this._targetedElement.classList.remove("active-element-outline"); + this._targetedElement = null; + } } } }, -- cgit v1.2.3 From a11ef2eed7049835c8bdfa50a2b893632c46eaa0 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 4 Apr 2012 11:11:58 -0700 Subject: Squashed commit of Preparing for the montage undo-manager: Architecture changes Reworked the add and remove elements into 1 function which can take 1 or more elements. Removed the _element from the selection array Many other changes related to those 2 changes Undo/Redo shortcuts are now using montage undo/redo manager. Signed-off-by: Valerio Virgillito --- js/tools/modifier-tool-base.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/tools/modifier-tool-base.js') diff --git a/js/tools/modifier-tool-base.js b/js/tools/modifier-tool-base.js index 94b806fd..46bb2e87 100755 --- a/js/tools/modifier-tool-base.js +++ b/js/tools/modifier-tool-base.js @@ -778,7 +778,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { { if(len === 1) { - this.target = this.application.ninja.selectedElements[0]._element; + this.target = this.application.ninja.selectedElements[0]; drawUtils.addElement(this.target); } else -- cgit v1.2.3 From 8b60a68f0152c609ad94a931472680f313678d8d Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 4 Apr 2012 11:17:50 -0700 Subject: We should require VecUtils instead of referring to the global reference since we will eventually remove that from the window object. Signed-off-by: Nivesh Rajbhandari --- js/tools/modifier-tool-base.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'js/tools/modifier-tool-base.js') diff --git a/js/tools/modifier-tool-base.js b/js/tools/modifier-tool-base.js index 5f2d29be..064f8b4b 100755 --- a/js/tools/modifier-tool-base.js +++ b/js/tools/modifier-tool-base.js @@ -9,8 +9,8 @@ var Montage = require("montage/core/core").Montage, snapManager = require("js/helper-classes/3D/snap-manager").SnapManager, viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils, vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils, - drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils, - Properties3D = ("js/models/properties-3d").Properties3D; + drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils; +// Properties3D = ("js/models/properties-3d").Properties3D; exports.ModifierToolBase = Montage.create(DrawingTool, { @@ -177,7 +177,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { } // only do quadrant snapping if the 4 corners of the element are in the drag plane - var sign = MathUtils.fpSign( VecUtils.vecDot(3,this._dragPlane,[0,0,1]) + this._dragPlane[3] - 1.0); + var sign = MathUtils.fpSign( vecUtils.vecDot(3,this._dragPlane,[0,0,1]) + this._dragPlane[3] - 1.0); this._shouldUseQuadPt = (sign == 0) var wpHitRec = hitRec.convertToWorkingPlane( this._dragPlane ); -- cgit v1.2.3 From 65e91e6b6544a34e1831c975a24b63eeba372b7b Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 5 Apr 2012 10:30:26 -0700 Subject: Commenting out console logs. Signed-off-by: Nivesh Rajbhandari --- js/tools/modifier-tool-base.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/tools/modifier-tool-base.js') diff --git a/js/tools/modifier-tool-base.js b/js/tools/modifier-tool-base.js index a86ac407..de73c861 100755 --- a/js/tools/modifier-tool-base.js +++ b/js/tools/modifier-tool-base.js @@ -820,7 +820,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { HandleLeftButtonDown: { value: function(event) { - console.log( "modifier-tool-base.HandleLeftButtonDown" ); +// console.log( "modifier-tool-base.HandleLeftButtonDown" ); var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(event.pageX, event.pageY)); this.downPoint.x = point.x; -- cgit v1.2.3