aboutsummaryrefslogtreecommitdiff
path: root/js/tools
diff options
context:
space:
mode:
Diffstat (limited to 'js/tools')
-rwxr-xr-xjs/tools/PenTool.js98
1 files changed, 53 insertions, 45 deletions
diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js
index 57da4698..31dadb80 100755
--- a/js/tools/PenTool.js
+++ b/js/tools/PenTool.js
@@ -278,9 +278,15 @@ 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 281 //set the cursor to be the default cursor (depending on whether the selected subpath has any points yet)
282 this.application.ninja.stage.drawingCanvas.style.cursor = //"auto"; 282 if (this._selectedSubpath && this._selectedSubpath.getNumAnchors()>0){
283 "url('images/cursors/penCursors/Pen_newPath.png') 0 0, default"; 283 this.application.ninja.stage.drawingCanvas.style.cursor = //"auto";
284 "url('images/cursors/penCursors/Pen_.png') 5 1, default";
285 }
286 else {
287 this.application.ninja.stage.drawingCanvas.style.cursor = //"auto";
288 "url('images/cursors/penCursors/Pen_newPath.png') 5 1, default";
289 }
284 290
285 if (this._isDrawing) { 291 if (this._isDrawing) {
286 var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(event.pageX, event.pageY)); 292 var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(event.pageX, event.pageY));
@@ -353,14 +359,14 @@ exports.PenTool = Montage.create(ShapeTool, {
353 if (selAnchorRetCode[0] >=0) { 359 if (selAnchorRetCode[0] >=0) {
354 this._hoveredAnchorIndex = selAnchorRetCode[0]; 360 this._hoveredAnchorIndex = selAnchorRetCode[0];
355 var lastAnchorIndex = this._selectedSubpath.getNumAnchors()-1; 361 var lastAnchorIndex = this._selectedSubpath.getNumAnchors()-1;
356 var cursor = "url('images/cursors/penCursors/Pen_anchorSelect.png') 0 0, default"; 362 var cursor = "url('images/cursors/penCursors/Pen_anchorSelect.png') 5 1, default";
357 if (this._selectedSubpath.getIsClosed()===false){ 363 if (this._selectedSubpath.getIsClosed()===false){
358 if (this._entryEditMode === this.ENTRY_SELECT_PATH && !this._isPickedEndPointInSelectPathMode && (this._hoveredAnchorIndex===0 || this._hoveredAnchorIndex===lastAnchorIndex)){ 364 if (this._entryEditMode === this.ENTRY_SELECT_PATH && !this._isPickedEndPointInSelectPathMode && (this._hoveredAnchorIndex===0 || this._hoveredAnchorIndex===lastAnchorIndex)){
359 //if we're in SELECT_PATH mode, have not yet clicked on the end anchors, AND we hovered over one of the end anchors 365 //if we're in SELECT_PATH mode, have not yet clicked on the end anchors, AND we hovered over one of the end anchors
360 cursor = "url('images/cursors/penCursors/Pen_append.png') 0 0, default"; 366 cursor = "url('images/cursors/penCursors/Pen_append.png') 5 1, default";
361 } else if ( this._selectedSubpath.getSelectedAnchorIndex()===lastAnchorIndex && this._hoveredAnchorIndex===0) { 367 } else if ( this._selectedSubpath.getSelectedAnchorIndex()===lastAnchorIndex && this._hoveredAnchorIndex===0) {
362 //if we've selected the last anchor and hover over the first anchor 368 //if we've selected the last anchor and hover over the first anchor
363 cursor = "url('images/cursors/penCursors/Pen_closePath.png') 0 0, default"; 369 cursor = "url('images/cursors/penCursors/Pen_closePath.png') 5 1, default";
364 } 370 }
365 } //if path is not closed 371 } //if path is not closed
366 this.application.ninja.stage.drawingCanvas.style.cursor = cursor; 372 this.application.ninja.stage.drawingCanvas.style.cursor = cursor;
@@ -369,7 +375,7 @@ exports.PenTool = Montage.create(ShapeTool, {
369 var pathHitTestData = this._selectedSubpath.pathHitTest(currMousePos[0], currMousePos[1], currMousePos[2], this._PICK_POINT_RADIUS*0.5); 375 var pathHitTestData = this._selectedSubpath.pathHitTest(currMousePos[0], currMousePos[1], currMousePos[2], this._PICK_POINT_RADIUS*0.5);
370 if (pathHitTestData[0]!==-1){ 376 if (pathHitTestData[0]!==-1){
371 //change the cursor 377 //change the cursor
372 var cursor = "url('images/cursors/penCursors/Pen_plus.png') 0 0, default"; 378 var cursor = "url('images/cursors/penCursors/Pen_plus.png') 5 1, default";
373 this.application.ninja.stage.drawingCanvas.style.cursor = cursor; 379 this.application.ninja.stage.drawingCanvas.style.cursor = cursor;
374 } 380 }
375 } 381 }
@@ -638,7 +644,8 @@ exports.PenTool = Montage.create(ShapeTool, {
638 // TODO - update the shape's info only. shapeModel will likely need an array of shapes. 644 // TODO - update the shape's info only. shapeModel will likely need an array of shapes.
639 } 645 }
640 646
641 if(newCanvas.elementModel.isShape) 647 //if(newCanvas.elementModel.isShape)
648 if (true)
642 { 649 {
643 this.application.ninja.selectionController.selectElement(newCanvas); 650 this.application.ninja.selectionController.selectElement(newCanvas);
644 } 651 }
@@ -681,6 +688,12 @@ exports.PenTool = Montage.create(ShapeTool, {
681 688
682 //TODO this will not work if there are multiple shapes in the same canvas 689 //TODO this will not work if there are multiple shapes in the same canvas
683 canvas.elementModel.shapeModel.GLGeomObj = subpath; 690 canvas.elementModel.shapeModel.GLGeomObj = subpath;
691
692 //if(newCanvas.elementModel.isShape)
693 if (true)
694 {
695 this.application.ninja.selectionController.selectElement(canvas);
696 }
684 } //else of if (!canvas) { 697 } //else of if (!canvas) {
685 } //value: function (w, h, planeMat, midPt, canvas) { 698 } //value: function (w, h, planeMat, midPt, canvas) {
686 }, //RenderShape: { 699 }, //RenderShape: {
@@ -1047,37 +1060,32 @@ exports.PenTool = Montage.create(ShapeTool, {
1047 1060
1048 handleDelete:{ 1061 handleDelete:{
1049 value: function(event){ 1062 value: function(event){
1050 var len = this.application.ninja.selectedElements.length; 1063 //clear the selected subpath...the only new additions to this function w.r.t. ToolBase
1051 if (len===0) { 1064 if (this._selectedSubpath){
1052 //clear the selected subpath...the only new additions to this function w.r.t. ToolBase 1065 if (this._selectedSubpath.getSelectedAnchorIndex()>=0){
1053 if (this._selectedSubpath){ 1066 this._hoveredAnchorIndex=-1;
1054 if (this._selectedSubpath.getSelectedAnchorIndex()>=0){ 1067 this._selectedSubpath.removeAnchor(this._selectedSubpath.getSelectedAnchorIndex());
1055 this._hoveredAnchorIndex=-1; 1068 this._selectedSubpath.createSamples();
1056 this._selectedSubpath.removeAnchor(this._selectedSubpath.getSelectedAnchorIndex()); 1069 //clear the canvas
1057 this._selectedSubpath.createSamples(); 1070 this.application.ninja.stage.clearDrawingCanvas();//stageManagerModule.stageManager.clearDrawingCanvas();
1058 //clear the canvas 1071 this.DrawSubpathAnchors(this._selectedSubpath);
1059 this.application.ninja.stage.clearDrawingCanvas();//stageManagerModule.stageManager.clearDrawingCanvas(); 1072 this.ShowSelectedSubpath();
1060 this.DrawSubpathAnchors(this._selectedSubpath);
1061 this.ShowSelectedSubpath();
1062 }
1063 else {
1064 this._selectedSubpath.clearAllAnchors(); //perhaps unnecessary
1065 this._selectedSubpath = null;
1066 //clear the canvas
1067 this.application.ninja.stage.clearDrawingCanvas();//stageManagerModule.stageManager.clearDrawingCanvas();
1068
1069 //undo/redo...go through ElementController and NJEvent
1070 var els = [];
1071 ElementController.removeElement(this._penCanvas);
1072 els.push(this._penCanvas);
1073 NJevent( "deleteSelection", els );
1074 this._penCanvas = null;
1075 }
1076 } 1073 }
1077 //do nothing if there was no selected subpath and if there was no selection 1074 else {
1075 this._selectedSubpath.clearAllAnchors(); //perhaps unnecessary
1076 this._selectedSubpath = null;
1077 //clear the canvas
1078 this.application.ninja.stage.clearDrawingCanvas();//stageManagerModule.stageManager.clearDrawingCanvas();
1079
1080 //undo/redo...go through ElementController and NJEvent
1081 var els = [];
1082 ElementController.removeElement(this._penCanvas);
1083 els.push(this._penCanvas);
1084 NJevent( "deleteSelection", els );
1085 this._penCanvas = null;
1086 }
1078 } 1087 }
1079 else { 1088 else {
1080
1081 //undo/redo...go through ElementMediator (see ElementMediator.handleDeleting() from where the much of this function is copied) 1089 //undo/redo...go through ElementMediator (see ElementMediator.handleDeleting() from where the much of this function is copied)
1082 //clear the canvas 1090 //clear the canvas
1083 this.application.ninja.stage.clearDrawingCanvas();//stageManagerModule.stageManager.clearDrawingCanvas(); 1091 this.application.ninja.stage.clearDrawingCanvas();//stageManagerModule.stageManager.clearDrawingCanvas();
@@ -1090,15 +1098,15 @@ exports.PenTool = Montage.create(ShapeTool, {
1090 } 1098 }
1091 NJevent( "deleteSelection", els ); 1099 NJevent( "deleteSelection", els );
1092 1100
1093 //clear out the selected path if it exists 1101 //clear out the selected path if it exists
1094 if (this._selectedSubpath) { 1102 if (this._selectedSubpath) {
1095 this._selectedSubpath.clearAllAnchors(); 1103 this._selectedSubpath.clearAllAnchors();
1096 this._selectedSubpath = null; 1104 this._selectedSubpath = null;
1097 if (this._entryEditMode === this.ENTRY_SELECT_PATH){ 1105 if (this._entryEditMode === this.ENTRY_SELECT_PATH){
1098 this._entryEditMode = this.ENTRY_SELECT_NONE; 1106 this._entryEditMode = this.ENTRY_SELECT_NONE;
1099 } 1107 }
1100 this._penCanvas = null; 1108 this._penCanvas = null;
1101 } 1109 }
1102 } 1110 }
1103 //redraw the stage to update it 1111 //redraw the stage to update it
1104 this.application.ninja.stage.draw(); 1112 this.application.ninja.stage.draw();