From f57727d36709bbda03b45788dc12faf31a591b40 Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Tue, 24 Apr 2012 08:28:39 -0700 Subject: re-compute and store the center of the subpath in local coordinates upon file open --- js/lib/geom/sub-path.js | 8 ++++++++ js/tools/PenTool.js | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/js/lib/geom/sub-path.js b/js/lib/geom/sub-path.js index 43420bc9..56c94df3 100755 --- a/js/lib/geom/sub-path.js +++ b/js/lib/geom/sub-path.js @@ -1106,6 +1106,14 @@ GLSubpath.prototype.importJSON = function(jo) { this._fillColor = jo.fillColor; this._dirty = true; + this.createSamples(false); + this.offsetPerBBoxMin(); + + //compute and store the center of the bbox in local space + var bboxMin = this.getBBoxMin(); + var bboxMax = this.getBBoxMax(); + var bboxMid = [0.5*(bboxMin[0]+bboxMax[0]),0.5*(bboxMin[1]+bboxMax[1]),0.5*(bboxMin[2]+bboxMax[2])]; + this.setCanvasCenterLocalCoord(bboxMid); }; GLSubpath.prototype.import = function( importStr ) { diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js index 4ff77371..8ecc9f79 100755 --- a/js/tools/PenTool.js +++ b/js/tools/PenTool.js @@ -786,7 +786,8 @@ exports.PenTool = Montage.create(ShapeTool, { glmat4.multiply( newMat, tMat, newMat); this._selectedSubpathPlaneMat = newMat; ViewUtils.setMatrixForElement(this._selectedSubpathCanvas, newMat, true); - + + //now set the center of the canvas as the center of the bounding box expressed in stage world coordinates var localToStageWorldMat = ViewUtils.getLocalToStageWorldMatrix(this._selectedSubpathCanvas, false, false); this._selectedSubpathCanvasCenter = MathUtils.transformAndDivideHomogeneousPoint(bboxMid, localToStageWorldMat); this._selectedSubpathCanvasCenter[0]+= xAdjustment; -- cgit v1.2.3