aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xjs/helper-classes/3D/draw-utils.js34
-rwxr-xr-xjs/helper-classes/3D/snap-manager.js12
-rwxr-xr-xjs/tools/ShapeTool.js3
-rwxr-xr-xjs/tools/drawing-tool-base.js63
-rwxr-xr-xjs/tools/drawing-tool.js3
5 files changed, 83 insertions, 32 deletions
diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js
index 81a740e0..88830964 100755
--- a/js/helper-classes/3D/draw-utils.js
+++ b/js/helper-classes/3D/draw-utils.js
@@ -651,6 +651,21 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
651 this._lineColor = saveColor; 651 this._lineColor = saveColor;
652 this._drawingContext.lineWidth = saveLineWidth; 652 this._drawingContext.lineWidth = saveLineWidth;
653 653
654 if(this.application.ninja.currentDocument.documentRoot.id !== "UserContent") {
655 // draw an outline around the body
656 var stagePt = MathUtils.getPointOnPlane([0,0,1,0]);
657 var stageMat = this.getPlaneToWorldMatrix([0,0,1], stagePt);
658 // glmat4.multiply( tMat, stageMat, stageMat);
659 pt0 = [0, 0, 0];
660 pt1 = [0, height, 0];
661 delta = [width, 0, 0];
662 this.drawGridLines(pt0, pt1, delta, stageMat, 2);
663 pt0 = [0, 0, 0];
664 pt1 = [width, 0, 0];
665 delta = [0, height, 0];
666 this.drawGridLines(pt0, pt1, delta, stageMat, 2);
667 }
668
654 // draw the lines 669 // draw the lines
655 this.redrawGridLines(); 670 this.redrawGridLines();
656 671
@@ -752,12 +767,27 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
752 this._drawingContext.lineWidth = 0.25; 767 this._drawingContext.lineWidth = 0.25;
753 768
754 // draw the lines 769 // draw the lines
755 var nLines = this._gridLineArray.length; 770 var line,
771 nLines = this._gridLineArray.length;
772 if(this.application.ninja.currentDocument.documentRoot.id !== "UserContent") {
773 nLines = this._gridLineArray.length-4;
774 }
775
756 for (var i = 0; i < nLines; i++) { 776 for (var i = 0; i < nLines; i++) {
757 var line = this._gridLineArray[i]; 777 line = this._gridLineArray[i];
758 this.drawIntersectedLine(line, this._drawingContext); 778 this.drawIntersectedLine(line, this._drawingContext);
759 } 779 }
760 780
781 if(this.application.ninja.currentDocument.documentRoot.id !== "UserContent") {
782 this._lineColor = "red";
783 i = nLines;
784 nLines += 4;
785 for (; i < nLines; i++) {
786 line = this._gridLineArray[i];
787 this.drawIntersectedLine(line, this._drawingContext);
788 }
789 }
790
761 this.popState(); 791 this.popState();
762 } 792 }
763 }, 793 },
diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js
index 7fc492a5..f4bfc12b 100755
--- a/js/helper-classes/3D/snap-manager.js
+++ b/js/helper-classes/3D/snap-manager.js
@@ -1617,7 +1617,11 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
1617 if (x > y) { 1617 if (x > y) {
1618 if (x > z) { 1618 if (x > z) {
1619 plane[0] = 1; 1619 plane[0] = 1;
1620 plane[3] = this.getStageWidth() / 2.0; 1620 if(this.application.ninja.currentDocument.documentRoot.id !== "UserContent") {
1621 plane[3] = stage.scrollWidth / 2.0;
1622 } else {
1623 plane[3] = this.getStageWidth() / 2.0;
1624 }
1621 if (dir[0] > 0) plane[3] = -plane[3]; 1625 if (dir[0] > 0) plane[3] = -plane[3];
1622 change = !drawUtils.drawYZ; 1626 change = !drawUtils.drawYZ;
1623 drawUtils.drawXY = drawUtils.drawXZ = false; 1627 drawUtils.drawXY = drawUtils.drawXZ = false;
@@ -1635,7 +1639,11 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
1635 else { 1639 else {
1636 if (y > z) { 1640 if (y > z) {
1637 plane[1] = 1; 1641 plane[1] = 1;
1638 plane[3] = this.getStageHeight() / 2.0; 1642 if(this.application.ninja.currentDocument.documentRoot.id !== "UserContent") {
1643 plane[3] = stage.scrollHeight / 2.0;
1644 } else {
1645 plane[3] = this.getStageHeight() / 2.0;
1646 }
1639 if (dir[1] > 0) plane[3] = -plane[3]; 1647 if (dir[1] > 0) plane[3] = -plane[3];
1640 change = !drawUtils.drawXZ; 1648 change = !drawUtils.drawXZ;
1641 drawUtils.drawXY = drawUtils.drawYZ = false; 1649 drawUtils.drawXY = drawUtils.drawYZ = false;
diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js
index 8f45891d..d2337000 100755
--- a/js/tools/ShapeTool.js
+++ b/js/tools/ShapeTool.js
@@ -106,6 +106,9 @@ exports.ShapeTool = Montage.create(DrawingTool, {
106 if(wasSelected) { 106 if(wasSelected) {
107 this.AddCustomFeedback(); 107 this.AddCustomFeedback();
108 this.application.ninja.elementMediator.addDelegate = this; 108 this.application.ninja.elementMediator.addDelegate = this;
109 if(this.application.ninja.currentSelectedContainer.nodeName === "CANVAS") {
110 this._targetedElement = this.application.ninja.currentSelectedContainer;
111 }
109 } else { 112 } else {
110 this.RemoveCustomFeedback(); 113 this.RemoveCustomFeedback();
111 this.application.ninja.elementMediator.addDelegate = null; 114 this.application.ninja.elementMediator.addDelegate = null;
diff --git a/js/tools/drawing-tool-base.js b/js/tools/drawing-tool-base.js
index 0b51aa28..7d97f105 100755
--- a/js/tools/drawing-tool-base.js
+++ b/js/tools/drawing-tool-base.js
@@ -24,6 +24,9 @@ exports.DrawingToolBase = Montage.create(Montage, {
24 value: null 24 value: null
25 }, 25 },
26 26
27 dragPlane: {
28 value: null
29 },
27 /** 30 /**
28 * Used on the initial MouseDown for Drawing Tools 31 * Used on the initial MouseDown for Drawing Tools
29 * 32 *
@@ -33,28 +36,30 @@ exports.DrawingToolBase = Montage.create(Montage, {
33 * 2 - Y value converted to screen point 36 * 2 - Y value converted to screen point
34 */ 37 */
35 getInitialSnapPoint: { 38 getInitialSnapPoint: {
36 value: function(x,y) { 39 value: function(x, y, shapeCanvas) {
40 snapManager.clearDragPlane();
41
37 // update the snap settings 42 // update the snap settings
38 snapManager.enableSnapAlign( snapManager.snapAlignEnabledAppLevel() ); 43 snapManager.enableSnapAlign( snapManager.snapAlignEnabledAppLevel() );
39 snapManager.enableElementSnap( snapManager.elementSnapEnabledAppLevel() ); 44 snapManager.enableElementSnap( snapManager.elementSnapEnabledAppLevel() );
40 snapManager.enableGridSnap( snapManager.gridSnapEnabledAppLevel() ); 45 snapManager.enableGridSnap( snapManager.gridSnapEnabledAppLevel() );
41 46
42 // do the snap 47 // do the snap
43 var hitRec = snapManager.snap(x, y, true); 48 this.dragPlane = null;
44 var dragPlane; 49 var hitRec = snapManager.snap(x, y, true);
45 if (hitRec) { 50 if (hitRec) {
46 // set up the working plane and convert the hit record to be working plane relative 51 if (shapeCanvas)
47 if (hitRec.getElement() === snapManager.application.ninja.currentSelectedContainer)
48 { 52 {
49 dragPlane = viewUtils.getUnprojectedElementPlane( hitRec.getElement() ); 53 this.dragPlane = viewUtils.getUnprojectedElementPlane( shapeCanvas );
50 snapManager.setupDragPlaneFromPlane( dragPlane ); 54 snapManager.setupDragPlaneFromPlane( this.dragPlane );
51 } 55 }
52 else 56 else
53 { 57 {
54 dragPlane = snapManager.setupDragPlanes( hitRec ); 58 this.dragPlane = snapManager.setupDragPlanes( hitRec, true );
55 } 59 }
60// console.log( "drag plane: " + this.dragPlane );
56 61
57 var wpHitRec = hitRec.convertToWorkingPlane( dragPlane ); 62 var wpHitRec = hitRec.convertToWorkingPlane( this.dragPlane );
58 var pt = hitRec.getScreenPoint(); 63 var pt = hitRec.getScreenPoint();
59 64
60 return( [wpHitRec, pt[0], pt[1]] ); 65 return( [wpHitRec, pt[0], pt[1]] );
@@ -72,28 +77,32 @@ exports.DrawingToolBase = Montage.create(Montage, {
72 snapManager.enableElementSnap( snapManager.elementSnapEnabledAppLevel() ); 77 snapManager.enableElementSnap( snapManager.elementSnapEnabledAppLevel() );
73 snapManager.enableGridSnap( snapManager.gridSnapEnabledAppLevel() ); 78 snapManager.enableGridSnap( snapManager.gridSnapEnabledAppLevel() );
74 79
75
76 // do the first snap
77 var hitRec = snapManager.snap(x, y, snap3d ); 80 var hitRec = snapManager.snap(x, y, snap3d );
78 if (hitRec) { 81 if (hitRec) {
79 if ((hitRec.getType() !== hitRec.SNAP_TYPE_STAGE) && !hitRec.isSomeGridTypeSnap()) { 82// if ((hitRec.getType() !== hitRec.SNAP_TYPE_STAGE) && !hitRec.isSomeGridTypeSnap()) {
80 hitRec = hitRec.convertToWorkingPlane( snapManager.getDragPlane() ); 83// hitRec = hitRec.convertToWorkingPlane( snapManager.getDragPlane() );
81 } 84// }
82 85//
83 if(downHitRec !== null) { 86// if(downHitRec !== null) {
84 // if we are working off-plane, do a snap to the projected locations of the geometry 87// // if we are working off-plane, do a snap to the projected locations of the geometry
85 var thePlane = workingPlane; 88// var thePlane = workingPlane;
86 if (snapManager.hasDragPlane()) 89// if (snapManager.hasDragPlane())
87 { 90// {
88 thePlane = snapManager.getDragPlane(); 91// thePlane = snapManager.getDragPlane();
89 } 92// }
90 93//
91 // Return the up HitRec 94// // Return the up HitRec
92 return hitRec; 95// return hitRec;
93 } else { 96// } else {
94 return null; 97// return null;
98// }
99 if(downHitRec) {
100 hitRec = hitRec.convertToWorkingPlane(this.dragPlane);
101 } else if ((hitRec.getType() !== hitRec.SNAP_TYPE_STAGE) && !hitRec.isSomeGridTypeSnap()) {
102 hitRec = hitRec.convertToWorkingPlane( snapManager.getDragPlane() );
95 } 103 }
96 } 104 }
105 return hitRec;
97 }