aboutsummaryrefslogtreecommitdiff
path: root/js/tools
diff options
context:
space:
mode:
Diffstat (limited to 'js/tools')
-rwxr-xr-xjs/tools/PenTool.js20
1 files changed, 13 insertions, 7 deletions
diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js
index cd15b36b..8065e1a6 100755
--- a/js/tools/PenTool.js
+++ b/js/tools/PenTool.js
@@ -182,12 +182,23 @@ exports.PenTool = Montage.create(ShapeTool, {
182 console.log("Warning...PenTool handleMouseDown: changing from SELECT_PATH to SELECT_NONE"); 182 console.log("Warning...PenTool handleMouseDown: changing from SELECT_PATH to SELECT_NONE");
183 } 183 }
184 } 184 }
185 185
186 //build the mouse down position in local coordinates
187 var drawingCanvas = this._selectedSubpath.getCanvas();
188 if (!drawingCanvas){
189 drawingCanvas = ViewUtils.getStageElement();
190 }
191 var globalMousePos = this._getUnsnappedScreenPosition(event.pageX, event.pageY);
192 var localMousePos = ViewUtils.globalToLocal(globalMousePos, drawingCanvas);
193
194
186 var prevSelectedAnchorIndex = this._selectedSubpath.getSelectedAnchorIndex(); 195 var prevSelectedAnchorIndex = this._selectedSubpath.getSelectedAnchorIndex();
187 // ************* Add/Select Anchor Point ************* 196 // ************* Add/Select Anchor Point *************
188 //check if the clicked location is close to an anchor point...if so, make that anchor the selected point and do nothing else 197 //check if the clicked location is close to an anchor point...if so, make that anchor the selected point and do nothing else
189 // BUT if the anchor point selected is the first anchor point, check if the previous selected anchor was the last anchor point...in that case, close the path 198 // BUT if the anchor point selected is the first anchor point, check if the previous selected anchor was the last anchor point...in that case, close the path
190 var selParam = this._selectedSubpath.pickPath(mouseDownPos[0], mouseDownPos[1], mouseDownPos[2], this._PICK_POINT_RADIUS); 199
200 //var selParam = this._selectedSubpath.pickPath(mouseDownPos[0], mouseDownPos[1], mouseDownPos[2], this._PICK_POINT_RADIUS);
201 var selParam = this._selectedSubpath.pickPath(localMousePos[0], localMousePos[1], localMousePos[2], this._PICK_POINT_RADIUS, true);
191 var whichPoint = this._selectedSubpath.getSelectedMode(); 202 var whichPoint = this._selectedSubpath.getSelectedMode();
192 if (whichPoint & this._selectedSubpath.SEL_ANCHOR) { 203 if (whichPoint & this._selectedSubpath.SEL_ANCHOR) {
193 //if we're in ENTRY_SELECT_PATH mode AND we have not yet clicked on the endpoint AND if we have now clicked on the endpoint 204 //if we're in ENTRY_SELECT_PATH mode AND we have not yet clicked on the endpoint AND if we have now clicked on the endpoint
@@ -288,9 +299,6 @@ exports.PenTool = Montage.create(ShapeTool, {
288 }, //HandleLeftButtonDown 299 }, //HandleLeftButtonDown
289 300
290 301
291 //need to override this function because the ShapeTool's definition contains a clearDrawingCanvas call - Pushkar
292 // might not need to override once we draw using OpenGL instead of SVG
293 // Also took out all the snapping code for now...need to add that back
294 HandleMouseMove: 302 HandleMouseMove:
295 { 303 {
296 value: function (event) { 304 value: function (event) {
@@ -647,7 +655,6 @@ exports.PenTool = Montage.create(ShapeTool, {
647 } //if this is a new path being rendered 655 } //if this is a new path being rendered
648 656
649 this._selectedSubpath.makeDirty(); 657 this._selectedSubpath.makeDirty();
650
651 this._selectedSubpath.createSamples(); 658 this._selectedSubpath.createSamples();
652 //if we have some samples to render... 659 //if we have some samples to render...
653 if (this._selectedSubpath.getNumAnchors() > 1) { 660 if (this._selectedSubpath.getNumAnchors() > 1) {
@@ -1011,7 +1018,6 @@ exports.PenTool = Montage.create(ShapeTool, {
1011 ctx.stroke(); 1018 ctx.stroke();
1012 } 1019 }
1013 1020
1014
1015 //display selected anchor and its prev. and next points 1021 //display selected anchor and its prev. and next points
1016 if (this._selectedSubpath && subpath === this._selectedSubpath && this._selectedSubpath.getSelectedAnchorIndex()!== -1) { 1022 if (this._selectedSubpath && subpath === this._selectedSubpath && this._selectedSubpath.getSelectedAnchorIndex()!== -1) {
1017 ctx.lineWidth = 1; 1023 ctx.lineWidth = 1;