From 7cbd26d475eaad817042692f9116f9a24ae60997 Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Tue, 28 Feb 2012 10:24:06 -0800 Subject: Bug fixes: 1152: allow deleting of multiple paths from inside pen tool 1128: keyboard hotkey shortcut 'P' for pen tool 941: changing width or height of the path scales the path --- js/helper-classes/RDGE/GLAnchorPoint.js | 7 +++ js/helper-classes/RDGE/GLSubpath.js | 64 ++++++++++++++++++++++++--- js/mediators/keyboard-mediator.js | 7 +++ js/tools/PenTool.js | 77 +++++++++++++++++++++++---------- 4 files changed, 127 insertions(+), 28 deletions(-) (limited to 'js') diff --git a/js/helper-classes/RDGE/GLAnchorPoint.js b/js/helper-classes/RDGE/GLAnchorPoint.js index 716f59d4..c3e95b34 100755 --- a/js/helper-classes/RDGE/GLAnchorPoint.js +++ b/js/helper-classes/RDGE/GLAnchorPoint.js @@ -133,6 +133,13 @@ GLAnchorPoint.prototype.translateAll = function (x, y, z) { } +GLAnchorPoint.prototype.scaleAll = function(sx,sy,sz){ + this._x *= sx;this._prevX *= sx;this._nextX *= sx; + this._y *= sy;this._prevY *= sy;this._nextY *= sy; + this._z *= sz;this._prevZ *= sz;this._nextZ *= sz; +} + + // ********* getters ********** GLAnchorPoint.prototype.getPosX = function () { return this._x; } GLAnchorPoint.prototype.getPosY = function () { return this._y; } diff --git a/js/helper-classes/RDGE/GLSubpath.js b/js/helper-classes/RDGE/GLSubpath.js index 3200cf59..7beb11b9 100755 --- a/js/helper-classes/RDGE/GLSubpath.js +++ b/js/helper-classes/RDGE/GLSubpath.js @@ -178,6 +178,65 @@ function GLSubpath() { } //render() this.geomType = function () { return this.GEOM_TYPE_CUBIC_BEZIER; } + + + this.setWidth = function (newW) { + //todo this doesn't work in cases where the newW is zero or if the previous width was 0/1 (i.e. the path had become degenerate in width) + //todo same as above for the setHeight function below + //scale the contents of this subpath to lie within this width + //determine the scale factor by comparing with the old width + var oldWidth = this._BBoxMax[0]-this._BBoxMin[0]; + if (oldWidth<1){ + oldWidth=1; + } + var scaleX = newW/oldWidth; + if (scaleX===1){ + return; //no need to do anything + } + + //scale the anchor point positions such that the width of the bbox is the newW + var origX = this._BBoxMin[0]; + var numAnchors = this._Anchors.length; + for (var i=0;i=0){ - this._hoveredAnchorIndex=-1; - this._selectedSubpath.removeAnchor(this._selectedSubpath.getSelectedAnchorIndex()); - this._selectedSubpath.createSamples(); - //clear the canvas - this.application.ninja.stage.clearDrawingCanvas();//stageManagerModule.stageManager.clearDrawingCanvas(); - this.DrawSubpathAnchors(this._selectedSubpath); - this.ShowSelectedSubpath(); + var len = this.application.ninja.selectedElements.length; + if (len===0) { + //clear the selected subpath...the only new additions to this function w.r.t. ToolBase + if (this._selectedSubpath){ + if (this._selectedSubpath.getSelectedAnchorIndex()>=0){ + this._hoveredAnchorIndex=-1; + this._selectedSubpath.removeAnchor(this._selectedSubpath.getSelectedAnchorIndex()); + this._selectedSubpath.createSamples(); + //clear the canvas + this.application.ninja.stage.clearDrawingCanvas();//stageManagerModule.stageManager.clearDrawingCanvas(); + this.DrawSubpathAnchors(this._selectedSubpath); + this.ShowSelectedSubpath(); + } + else { + this._selectedSubpath.clearAllAnchors(); //perhaps unnecessary + this._selectedSubpath = null; + //clear the canvas + this.application.ninja.stage.clearDrawingCanvas();//stageManagerModule.stageManager.clearDrawingCanvas(); + + //undo/redo...go through ElementController and NJEvent + var els = []; + ElementController.removeElement(this._penCanvas); + els.push(this._penCanvas); + NJevent( "deleteSelection", els ); + this._penCanvas = null; + } + } + //do nothing if there was no selected subpath and if there was no selection + } + else { + + //undo/redo...go through ElementMediator (see ElementMediator.handleDeleting() from where the much of this function is copied) + //clear the canvas + this.application.ninja.stage.clearDrawingCanvas();//stageManagerModule.stageManager.clearDrawingCanvas(); + var els = []; + for(var i = 0; i