aboutsummaryrefslogtreecommitdiff
path: root/js/tools/modifier-tool-base.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/tools/modifier-tool-base.js')
-rwxr-xr-xjs/tools/modifier-tool-base.js29
1 files changed, 25 insertions, 4 deletions
diff --git a/js/tools/modifier-tool-base.js b/js/tools/modifier-tool-base.js
index 46bb2e87..f9fd001c 100755
--- a/js/tools/modifier-tool-base.js
+++ b/js/tools/modifier-tool-base.js
@@ -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;
@@ -397,6 +405,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
397 var index = this._snapIndex; 405 var index = this._snapIndex;
398 var pt0; 406 var pt0;
399 var useViewPoint = (this._inLocalMode && (this._targets.length === 1)); 407 var useViewPoint = (this._inLocalMode && (this._targets.length === 1));
408 //console.log( "useViewPoint: " + useViewPoint );
400 if (this._useQuadPt) 409 if (this._useQuadPt)
401 { 410 {
402 pt0 = this.GetQuadrantPoint(useViewPoint); 411 pt0 = this.GetQuadrantPoint(useViewPoint);
@@ -419,6 +428,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
419 pt1 = MathUtils.transformPoint( pt1, this._startMat ); 428 pt1 = MathUtils.transformPoint( pt1, this._startMat );
420 } 429 }
421 430
431 //console.log( "getMousePoints, useViewPoint: " + useViewPoint + ", " + pt0 + " => " + pt1 );
422 return {pt0:pt0, pt1:pt1}; 432 return {pt0:pt0, pt1:pt1};
423 } 433 }
424 else 434 else
@@ -517,7 +527,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
517 527
518 // do the snap 528 // do the snap
519 var quadPt; 529 var quadPt;
520 if (mouseIsDown) 530 if (mouseIsDown && !do3DSnap && this._shouldUseQuadPt && (this._handleMode === null) && (this._mode === 0))
521 quadPt = this.GetQuadrantSnapPoint(x,y); 531 quadPt = this.GetQuadrantSnapPoint(x,y);
522 var hitRec = snapManager.snap(x, y, do3DSnap, quadPt ); 532 var hitRec = snapManager.snap(x, y, do3DSnap, quadPt );
523 533
@@ -806,6 +816,8 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
806 HandleLeftButtonDown: { 816 HandleLeftButtonDown: {
807 value: function(event) { 817 value: function(event) {
808 818
819 console.log( "modifier-tool-base.HandleLeftButtonDown" );
820
809 var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(event.pageX, event.pageY)); 821 var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(event.pageX, event.pageY));
810 this.downPoint.x = point.x; 822 this.downPoint.x = point.x;
811 this.downPoint.y = point.y; 823 this.downPoint.y = point.y;
@@ -842,8 +854,10 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
842 } 854 }
843 } 855 }
844 856
845 this.DrawHandles(this._delta); 857 if (!this._isDrawing || (this.application.ninja.selectedElements.length == 1))
846 if(this._canSnap) 858 this.DrawHandles(this._delta);
859
860 if(this._canSnap)
847 { 861 {
848 snapManager.drawLastHit(); 862 snapManager.drawLastHit();
849 } 863 }
@@ -882,6 +896,13 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
882 this._delta = null; 896 this._delta = null;
883 } 897 }
884 this.endDraw(event); 898 this.endDraw(event);
899
900 this.application.ninja.stage.draw();
901 if (this._targets && (this._targets.length > 1))
902 {
903 this._origin = null;
904 this._updateHandlesOrigin();
905 }
885 this.DrawHandles(); 906 this.DrawHandles();
886 } 907 }
887 }, 908 },