diff options
author | Nivesh Rajbhandari | 2012-04-04 17:24:27 -0700 |
---|---|---|
committer | Nivesh Rajbhandari | 2012-04-04 17:24:27 -0700 |
commit | 01cf259da7aaa7d70789d9a7c32111d88b477463 (patch) | |
tree | 0bff3395ac681e5f685d2267f7dbc03a8e32bc4a /js/tools/modifier-tool-base.js | |
parent | 331ea08655245e3532e48bf160d5f68a04d8723f (diff) | |
parent | 13368ca6ebbc13adeafccd898dfffd7ce37cb28a (diff) | |
download | ninja-01cf259da7aaa7d70789d9a7c32111d88b477463.tar.gz |
Merge branch 'refs/heads/ToolFixes' into WebGLMaterials
Conflicts:
js/document/templates/montage-html/default_html.css
js/mediators/element-mediator.js
js/panels/properties.reel/properties.js
js/tools/BrushTool.js
js/tools/LineTool.js
js/tools/PenTool.js
js/tools/SelectionTool.js
js/tools/ShapeTool.js
js/tools/TranslateObject3DTool.js
Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com>
Diffstat (limited to 'js/tools/modifier-tool-base.js')
-rwxr-xr-x | js/tools/modifier-tool-base.js | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/js/tools/modifier-tool-base.js b/js/tools/modifier-tool-base.js index 94b806fd..a86ac407 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, | |||
9 | snapManager = require("js/helper-classes/3D/snap-manager").SnapManager, | 9 | snapManager = require("js/helper-classes/3D/snap-manager").SnapManager, |
10 | viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils, | 10 | viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils, |
11 | vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils, | 11 | vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils, |
12 | drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils, | 12 | drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils; |
13 | Properties3D = ("js/models/properties-3d").Properties3D; | 13 | // Properties3D = ("js/models/properties-3d").Properties3D; |
14 | 14 | ||
15 | exports.ModifierToolBase = Montage.create(DrawingTool, { | 15 | exports.ModifierToolBase = Montage.create(DrawingTool, { |
16 | 16 | ||
@@ -25,6 +25,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { | |||
25 | _snapParam: { value: null }, | 25 | _snapParam: { value: null }, |
26 | _snapIndex: { value: -1 }, | 26 | _snapIndex: { value: -1 }, |
27 | _useQuadPt: { value: false }, | 27 | _useQuadPt: { value: false }, |
28 | _shouldUseQuadPt: { value: false }, | ||
28 | 29 | ||
29 | // we set snapping capabilities depending on the tool. | 30 | // we set snapping capabilities depending on the tool. |
30 | // The following variables are set in a tool's initializeSnapping method called on mouse down. | 31 | // The following variables are set in a tool's initializeSnapping method called on mouse down. |
@@ -175,6 +176,10 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { | |||
175 | // } | 176 | // } |
176 | } | 177 | } |
177 | 178 | ||
179 | // only do quadrant snapping if the 4 corners of the element are in the drag plane | ||
180 | var sign = MathUtils.fpSign( vecUtils.vecDot(3,this._dragPlane,[0,0,1]) + this._dragPlane[3] - 1.0); | ||
181 | this._shouldUseQuadPt = (sign == 0) | ||
182 | |||
178 | var wpHitRec = hitRec.convertToWorkingPlane( this._dragPlane ); | 183 | var wpHitRec = hitRec.convertToWorkingPlane( this._dragPlane ); |
179 | this._mouseDownHitRec = wpHitRec; | 184 | this._mouseDownHitRec = wpHitRec; |
180 | this._mouseUpHitRec = null; | 185 | this._mouseUpHitRec = null; |
@@ -236,6 +241,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { | |||
236 | } | 241 | } |
237 | } | 242 | } |
238 | 243 | ||
244 | //console.log( "ParameterizeSnap: " + paramPt ); | ||
239 | return paramPt; | 245 | return paramPt; |
240 | } | 246 | } |
241 | }, | 247 | }, |
@@ -284,14 +290,16 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { | |||
284 | y = x0 + ty*dy, | 290 | y = x0 + ty*dy, |
285 | z = 0.0; | 291 | z = 0.0; |
286 | var localPt = [x,y,z]; | 292 | var localPt = [x,y,z]; |
293 | |||
287 | globalPt = viewUtils.localToGlobal( localPt, elt ); | 294 | globalPt = viewUtils.localToGlobal( localPt, elt ); |
288 | 295 | ||
289 | // add in the delta | 296 | // add in the delta |
290 | var hitPt = this.GetObjectHitPoint(); | 297 | var hitPt = this.GetObjectHitPoint(); |
291 | var scrPt = viewUtils.localToGlobal( hitPt, this._clickedObject ); | 298 | var scrPt = viewUtils.localToGlobal( hitPt, this._clickedObject ); |
292 | var delta = [xEvent-scrPt[0], yEvent-scrPt[1]]; | 299 | var delta = [xEvent-scrPt[0], yEvent-scrPt[1], 0-scrPt[2]]; |
293 | globalPt[0] += delta[0]; | 300 | globalPt[0] += delta[0]; |
294 | globalPt[1] += delta[1]; | 301 | globalPt[1] += delta[1]; |
302 | globalPt[2] += delta[2]; | ||
295 | } | 303 | } |
296 | 304 | ||
297 | return globalPt; | 305 | return globalPt; |
@@ -448,6 +456,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { | |||
448 | { | 456 | { |
449 | this.isDrawing = true; | 457 | this.isDrawing = true; |
450 | this.application.ninja.stage.showSelectionBounds = false; | 458 | this.application.ninja.stage.showSelectionBounds = false; |
459 | this._updateTargets(); | ||
451 | 460 | ||
452 | if(this._canSnap) | 461 | if(this._canSnap) |
453 | { | 462 | { |
@@ -517,7 +526,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { | |||
517 | 526 | ||
518 | // do the snap | 527 | // do the snap |
519 | var quadPt; | 528 | var quadPt; |
520 | if (mouseIsDown) | 529 | if (mouseIsDown && !do3DSnap && this._shouldUseQuadPt && (this._handleMode === null) && (this._mode === 0)) |
521 | quadPt = this.GetQuadrantSnapPoint(x,y); | 530 | quadPt = this.GetQuadrantSnapPoint(x,y); |
522 | var hitRec = snapManager.snap(x, y, do3DSnap, quadPt ); | 531 | var hitRec = snapManager.snap(x, y, do3DSnap, quadPt ); |
523 | 532 | ||
@@ -757,6 +766,11 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { | |||
757 | snapManager.enableGridSnap( snapManager.gridSnapEnabledAppLevel() ); | 766 | snapManager.enableGridSnap( snapManager.gridSnapEnabledAppLevel() ); |
758 | this.eventManager.removeEventListener( "toolOptionsChange", this, false); | 767 | this.eventManager.removeEventListener( "toolOptionsChange", this, false); |
759 | this.eventManager.removeEventListener( "toolDoubleClick", this, false); | 768 | this.eventManager.removeEventListener( "toolDoubleClick", this, false); |
769 | |||
770 | if (this._targetedElement) { | ||
771 | this._targetedElement.classList.remove("active-element-outline"); | ||
772 | this._targetedElement = null; | ||
773 | } | ||
760 | } | 774 | } |
761 | } | 775 | } |
762 | }, | 776 | }, |
@@ -778,14 +792,14 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { | |||
778 | { | 792 | { |
779 | if(len === 1) | 793 | if(len === 1) |
780 | { | 794 | { |
781 | this.target = this.application.ninja.selectedElements[0]._element; | 795 | this.target = this.application.ninja.selectedElements[0]; |
782 | drawUtils.addElement(this.target); | 796 | drawUtils.addElement(this.target); |
783 | } | 797 | } |
784 | else | 798 | else |
785 | { | 799 | { |
786 | this.target = this.application.ninja.currentDocument.documentRoot; | 800 | this.target = this.application.ninja.currentDocument.documentRoot; |
787 | } | 801 | } |
788 | this._updateTargets(); | 802 | // this._updateTargets(); |
789 | } | 803 | } |
790 | else | 804 | else |
791 | { | 805 | { |
@@ -806,6 +820,8 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { | |||
806 | HandleLeftButtonDown: { | 820 | HandleLeftButtonDown: { |
807 | value: function(event) { | 821 | value: function(event) { |
808 | 822 | ||
823 | console.log( "modifier-tool-base.HandleLeftButtonDown" ); | ||
824 | |||
809 | var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(event.pageX, event.pageY)); | 825 | var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(event.pageX, event.pageY)); |
810 | this.downPoint.x = point.x; | 826 | this.downPoint.x = point.x; |
811 | this.downPoint.y = point.y; | 827 | this.downPoint.y = point.y; |