aboutsummaryrefslogtreecommitdiff
path: root/js/lib/geom
diff options
context:
space:
mode:
authorPushkar Joshi2012-04-16 16:03:29 -0700
committerPushkar Joshi2012-04-16 16:03:29 -0700
commit7c82ee4f217ea86ee4ebee80da29481f31e5019d (patch)
tree4fada8c618b12f1b3fb952abb576ca88b0d131e3 /js/lib/geom
parent1348f297cb8e42b395d377b21dfd25c1cefacdd4 (diff)
downloadninja-7c82ee4f217ea86ee4ebee80da29481f31e5019d.tar.gz
re-enable some hit testing and change the code for obtaining 3D (stage world) point when there is no canvas yet
Diffstat (limited to 'js/lib/geom')
-rwxr-xr-xjs/lib/geom/sub-path.js55
1 files changed, 4 insertions, 51 deletions
diff --git a/js/lib/geom/sub-path.js b/js/lib/geom/sub-path.js
index 31bf4632..62937461 100755
--- a/js/lib/geom/sub-path.js
+++ b/js/lib/geom/sub-path.js
@@ -614,13 +614,14 @@ GLSubpath.prototype.pickPath = function (pickX, pickY, pickZ, radius, testOnly)
614 }//if is within bbox 614 }//if is within bbox
615 } 615 }
616 616
617 if (retCode!== this.SEL_NONE)
618 retCode = retCode | this.SEL_PATH; //ensure that path is also selected if anything else is selected
619
617 if (!testOnly){ 620 if (!testOnly){
618 if (retCode!== this.SEL_NONE)
619 retCode = retCode | this.SEL_PATH; //ensure that path is also selected if anything else is selected
620 this._selectMode = retCode; 621 this._selectMode = retCode;
621 this._selectedAnchorIndex = selAnchorIndex; 622 this._selectedAnchorIndex = selAnchorIndex;
622 } 623 }
623 return [selAnchorIndex,retParam]; 624 return [selAnchorIndex,retParam, retCode];
624}; //GLSubpath.pickPath function 625}; //GLSubpath.pickPath function
625 626
626GLSubpath.prototype.getSelectedAnchorIndex = function () { 627GLSubpath.prototype.getSelectedAnchorIndex = function () {
@@ -693,54 +694,6 @@ GLSubpath.prototype.setStrokeWidth = function (w) {
693 ElementMediator.setProperty(canvasArray, "height", [penCanvasNewHeight+"px"], "Changing", "penTool"); 694 ElementMediator.setProperty(canvasArray, "height", [penCanvasNewHeight+"px"], "Changing", "penTool");
694 ElementMediator.setProperty(canvasArray, "left", [penCanvasNewLeft+"px"],"Changing", "penTool"); 695 ElementMediator.setProperty(canvasArray, "left", [penCanvasNewLeft+"px"],"Changing", "penTool");
695 ElementMediator.setProperty(canvasArray, "top", [penCanvasNewTop+ "px"],"Changing", "penTool"); 696 ElementMediator.setProperty(canvasArray, "top", [penCanvasNewTop+ "px"],"Changing", "penTool");
696
697 /*
698 //compute the current location of the canvas for this subpath
699 this.createSamples(); //this will also update the bounding box
700 var bboxMin = this.getBBoxMin();
701 var bboxMax = this.getBBoxMax();
702 var bboxMid = [0.5 * (bboxMax[0] + bboxMin[0]), 0.5 * (bboxMax[1] + bboxMin[1]), 0]; //ignore the Z coord. for local coordinates
703
704 //go from local coordinates to stage world
705 var ViewUtils = require("js/helper-classes/3D/view-utils").ViewUtils;
706 var SnapManager = require("js/helper-classes/3D/snap-manager").SnapManager;
707 var localToStageWorldMat = ViewUtils.getLocalToStageWorldMatrix(this._canvas, true, true);
708 var bboxMidSW = MathUtils.transformAndDivideHomogeneousPoint(bboxMid, localToStageWorldMat);
709 bboxMidSW[0]+=SnapManager.getStageWidth()*0.5;
710 bboxMidSW[1]+=SnapManager.getStageHeight()*0.5;
711
712 this._strokeWidth = Math.round(w);
713 this._dirty=true;
714
715 // **** adjust the local coordinates to account for the change in stroke width ****
716 this.computeBoundingBox(); //this will take the new strokewidth into account
717 this.offsetPerBBoxMin(); //this will shift the local coordinates such that the bbox min point is at (0,0)
718
719 // **** adjust the canvas position to account for the change in stroke width
720 var ElementMediator = require("js/mediators/element-mediator").ElementMediator;
721 //build the width and height of this canvas by looking at local coordinates
722 bboxMin = this.getBBoxMin();
723 bboxMax = this.getBBoxMax();
724 var width = Math.round(bboxMax[0] - bboxMin[0]);
725 var height = Math.round(bboxMax[1] - bboxMin[1]);
726 var left = Math.round(bboxMidSW[0] - 0.5 * width);
727 var top = Math.round(bboxMidSW[1] - 0.5 * height);
728
729 var canvasArray=[this._canvas];
730 ElementMediator.setProperty(canvasArray, "width", [width+"px"], "Changing", "penTool");
731 ElementMediator.setProperty(canvasArray, "height", [height+"px"], "Changing", "penTool");
732
733 //check if the canvas was translated
734 var penCanvasCurrentLeft = parseInt(ElementMediator.getProperty(this._canvas, "left"));
735 var penCanvasCurrentTop = parseInt(ElementMediator.getProperty(this._canvas, "top"));
736 left = Math.round(penCanvasCurrentLeft - diffStrokeWidth*0.5);
737 top = Math.round(penCanvasCurrentTop - diffStrokeWidth*0.5);
738
739 //left = Math.round(bboxMidSW[0] - 0.5 * width);
740 //top = Math.round(bboxMidSW[1] - 0.5 * height);
741 ElementMediator.setProperty(canvasArray, "left", [left+"px"],"Changing", "penTool");
742 ElementMediator.setProperty(canvasArray, "top", [top+ "px"],"Changing", "penTool");
743 */
744}; 697};
745 698
746GLSubpath.prototype.getStrokeColor = function () { 699GLSubpath.prototype.getStrokeColor = function () {