aboutsummaryrefslogtreecommitdiff
path: root/js/tools/PenTool.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/tools/PenTool.js')
-rwxr-xr-xjs/tools/PenTool.js39
1 files changed, 38 insertions, 1 deletions
diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js
index 71a91870..779b7f16 100755
--- a/js/tools/PenTool.js
+++ b/js/tools/PenTool.js
@@ -278,6 +278,9 @@ exports.PenTool = Montage.create(ShapeTool, {
278 this.application.ninja.stage.clearDrawingCanvas(); 278 this.application.ninja.stage.clearDrawingCanvas();
279 this._hoveredAnchorIndex = -1; 279 this._hoveredAnchorIndex = -1;
280 280
281 //set the cursor to be the default cursor
282 this.application.ninja.stage.drawingCanvas.style.cursor = "auto";
283
281 if (this._isDrawing) { 284 if (this._isDrawing) {
282 var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(event.pageX, event.pageY)); 285 var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(event.pageX, event.pageY));
283 //go through the drawing toolbase to get the position of the mouse 286 //go through the drawing toolbase to get the position of the mouse
@@ -348,6 +351,14 @@ exports.PenTool = Montage.create(ShapeTool, {
348 var selAnchor = this._selectedSubpath.pickAnchor(currMousePos[0], currMousePos[1], currMousePos[2], this._PICK_POINT_RADIUS); 351 var selAnchor = this._selectedSubpath.pickAnchor(currMousePos[0], currMousePos[1], currMousePos[2], this._PICK_POINT_RADIUS);
349 if (selAnchor >=0) { 352 if (selAnchor >=0) {
350 this._hoveredAnchorIndex = selAnchor; 353 this._hoveredAnchorIndex = selAnchor;
354 } else {
355 //detect if the current mouse position will hit the path
356 var pathHitTestData = this._selectedSubpath.pathHitTest(currMousePos[0], currMousePos[1], currMousePos[2], this._PICK_POINT_RADIUS);
357 if (pathHitTestData[0]!==-1){
358 //change the cursor
359 var cursor = "url('images/cursors/penAdd.png') 10 10,default";
360 this.application.ninja.stage.drawingCanvas.style.cursor = cursor;
361 }
351 } 362 }
352 } 363 }
353 } //else of if (this._isDrawing) { 364 } //else of if (this._isDrawing) {
@@ -356,7 +367,6 @@ exports.PenTool = Montage.create(ShapeTool, {
356 if (this._selectedSubpath){ 367 if (this._selectedSubpath){
357 this.DrawSubpathAnchors(this._selectedSubpath); 368 this.DrawSubpathAnchors(this._selectedSubpath);
358 } 369 }
359
360 }//value: function(event) 370 }//value: function(event)
361 },//HandleMouseMove 371 },//HandleMouseMove
362 372
@@ -584,6 +594,7 @@ exports.PenTool = Montage.create(ShapeTool, {
584 594
585 var subpath = this._selectedSubpath; //new GLSubpath(); 595 var subpath = this._selectedSubpath; //new GLSubpath();
586 subpath.setWorld(world); 596 subpath.setWorld(world);
597 subpath.setCanvas(newCanvas);
587 subpath.setPlaneMatrix(planeMat); 598 subpath.setPlaneMatrix(planeMat);
588 var planeMatInv = glmat4.inverse( planeMat, [] ); 599 var planeMatInv = glmat4.inverse( planeMat, [] );
589 subpath.setPlaneMatrixInverse(planeMatInv); 600 subpath.setPlaneMatrixInverse(planeMatInv);
@@ -591,7 +602,33 @@ exports.PenTool = Montage.create(ShapeTool, {
591 602
592 world.addObject(subpath); 603 world.addObject(subpath);
593 world.render(); 604 world.render();
605 //TODO this will not work if there are multiple shapes in the same canvas
594 newCanvas.elementModel.shapeModel.GLGeomObj = subpath; 606 newCanvas.elementModel.shapeModel.GLGeomObj = subpath;
607 newCanvas.elementModel.shapeModel.shapeCount++;
608 if(newCanvas.elementModel.shapeModel.shapeCount === 1)
609 {
610 newCanvas.elementModel.selection = "Subpath";
611 newCanvas.elementModel.pi = "SubpathPi";
612 newCanvas.elementModel.shapeModel.strokeSize = this.options.strokeSize.value + " " + this.options.strokeSize.units;
613 var strokeColor = subpath.getStrokeColor();
614 newCanvas.elementModel.shapeModel.stroke = strokeColor;
615 if(strokeColor) {
616 newCanvas.elementModel.shapeModel.border = this.application.ninja.colorController.colorToolbar.stroke;
617 }
618 newCanvas.elementModel.shapeModel.strokeMaterial = subpath.getStrokeMaterial();
619
620 newCanvas.elementModel.shapeModel.GLGeomObj = subpath;
621 newCanvas.elementModel.shapeModel.useWebGl = this.options.use3D;
622 }
623 else
624 {
625 // TODO - update the shape's info only. shapeModel will likely need an array of shapes.
626 }
627
628 if(newCanvas.elementModel.isShape)
629 {
630 this.application.ninja.selectionController.selectElement(newCanvas);
631 }
595 } //if (!canvas) { 632 } //if (!canvas) {
596 else { 633 else {
597 634