aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/helper-classes/RDGE/GLSubpath.js19
-rw-r--r--js/tools/PenTool.js44
2 files changed, 25 insertions, 38 deletions
diff --git a/js/helper-classes/RDGE/GLSubpath.js b/js/helper-classes/RDGE/GLSubpath.js
index 74134a7e..383194d4 100644
--- a/js/helper-classes/RDGE/GLSubpath.js
+++ b/js/helper-classes/RDGE/GLSubpath.js
@@ -146,6 +146,8 @@ function GLSubpath() {
146 ctx.lineCap = lineCap[1]; 146 ctx.lineCap = lineCap[1];
147 ctx.beginPath(); 147 ctx.beginPath();
148 148
149 /*
150 commenting this out for now because of Chrome bug where coincident endpoints of bezier curve cause the curve to not be rendered
149 var prevAnchor = this.getAnchor(0); 151 var prevAnchor = this.getAnchor(0);
150 ctx.moveTo(prevAnchor.getPosX()-bboxMin[0],prevAnchor.getPosY()-bboxMin[1]); 152 ctx.moveTo(prevAnchor.getPosX()-bboxMin[0],prevAnchor.getPosY()-bboxMin[1]);
151 for (var i = 1; i < numAnchors; i++) { 153 for (var i = 1; i < numAnchors; i++) {
@@ -157,18 +159,19 @@ function GLSubpath() {
157 var currAnchor = this.getAnchor(0); 159 var currAnchor = this.getAnchor(0);
158 ctx.bezierCurveTo(prevAnchor.getNextX()-bboxMin[0],prevAnchor.getNextY()-bboxMin[1], currAnchor.getPrevX()-bboxMin[0], currAnchor.getPrevY()-bboxMin[1], currAnchor.getPosX()-bboxMin[0], currAnchor.getPosY()-bboxMin[1]); 160 ctx.bezierCurveTo(prevAnchor.getNextX()-bboxMin[0],prevAnchor.getNextY()-bboxMin[1], currAnchor.getPrevX()-bboxMin[0], currAnchor.getPrevY()-bboxMin[1], currAnchor.getPosX()-bboxMin[0], currAnchor.getPosY()-bboxMin[1]);
159 prevAnchor = currAnchor; 161 prevAnchor = currAnchor;
160 }
161 if (this._isClosed){
162 ctx.fill(); 162 ctx.fill();
163 } 163 }
164 */
164 165
165 /*
166 var numPoints = this._samples.length/3; 166 var numPoints = this._samples.length/3;
167 ctx.moveTo(this._samples[0],this._samples[1]); 167 ctx.moveTo(this._samples[0]-bboxMin[0],this._samples[1]-bboxMin[1]);
168 for (var i=0;i<numPoints;i++){ 168 for (var i=0;i<numPoints;i++){
169 ctx.lineTo(this._samples[3*i]-bboxMin[0],this._samples[3*i + 1]-bboxMin[1]); 169 ctx.lineTo(this._samples[3*i]-bboxMin[0],this._samples[3*i + 1]-bboxMin[1]);
170 } 170 }
171 */ 171 if (this._isClosed === true) {
172 ctx.lineTo(this._samples[0]-bboxMin[0],this._samples[1]-bboxMin[1]);
173 ctx.fill();
174 }
172 ctx.stroke(); 175 ctx.stroke();
173 ctx.restore(); 176 ctx.restore();
174 } //render() 177 } //render()
@@ -224,10 +227,8 @@ GLSubpath.prototype.removeAnchor = function (index) {
224 retAnchor = this._Anchors.splice(index, 1); 227 retAnchor = this._Anchors.splice(index, 1);
225 this._dirty = true; 228 this._dirty = true;
226 } 229 }
227 //deselect the removed anchor if necessary 230 //deselect the removed anchor
228 if (this._selectedAnchorIndex === index){ 231 this._selectedAnchorIndex = -1;
229 this._selectedAnchorIndex = -1;
230 }
231 return retAnchor; 232 return retAnchor;
232} 233}
233 234
diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js
index cb2ea85a..5b48d3c9 100644
--- a/js/tools/PenTool.js
+++ b/js/tools/PenTool.js
@@ -142,15 +142,12 @@ exports.PenTool = Montage.create(ShapeTool, {
142 //NOTE: this will work on Webkit only...IE has different codes (left: 1, middle: 4, right: 2) 142 //NOTE: this will work on Webkit only...IE has different codes (left: 1, middle: 4, right: 2)
143 return; 143 return;
144 } 144 }
145 //BEGIN ShapeTool code
146 if (this._canDraw) { 145 if (this._canDraw) {
147 this._isDrawing = true; 146 this._isDrawing = true;
148 } 147 }
149 148
150 //this._targetedCanvas = stageManagerModule.stageManager.GetObjectFromPoint(event.layerX, event.layerY, this._canOperateOnStage);
151 149
152 this.startDraw(event); 150 this.startDraw(event);
153 //END ShapeTool code
154 151
155 //assume we are not starting a new path as we will set this to true if we create a new GLSubpath() 152 //assume we are not starting a new path as we will set this to true if we create a new GLSubpath()
156 this._isNewPath = false; 153 this._isNewPath = false;
@@ -269,6 +266,8 @@ exports.PenTool = Montage.create(ShapeTool, {
269 if (!g_DoPenToolMouseMove){ 266 if (!g_DoPenToolMouseMove){
270 NJevent("enableStageMove"); 267 NJevent("enableStageMove");
271 } 268 }
269
270 this._hoveredAnchorIndex = -1;
272 } //value: function (event) { 271 } //value: function (event) {
273 }, //HandleLeftButtonDown 272 }, //HandleLeftButtonDown
274 273
@@ -370,7 +369,7 @@ exports.PenTool = Montage.create(ShapeTool, {
370 } 369 }
371 370
372 }//value: function(event) 371 }//value: function(event)
373 }, 372 },//HandleMouseMove
374 373
375 //TODO Optimize! This function is probably no longer needed 374 //TODO Optimize! This function is probably no longer needed
376 TranslateSelectedSubpathPerPenCanvas:{ 375 TranslateSelectedSubpathPerPenCanvas:{
@@ -499,6 +498,7 @@ exports.PenTool = Montage.create(ShapeTool, {
499 if (!g_DoPenToolMouseMove){ 498 if (!g_DoPenToolMouseMove){
500 NJevent("disableStageMove"); 499 NJevent("disableStageMove");
501 } 500 }
501 this._hoveredAnchorIndex = -1;
502 } 502 }
503 }, 503 },
504 504
@@ -664,15 +664,17 @@ exports.PenTool = Montage.create(ShapeTool, {
664 }, //BuildSecondCtrlPoint:{ 664 }, //BuildSecondCtrlPoint:{
665 665
666 666
667 /*
667 deleteSelection: { 668 deleteSelection: {
668 value: function() { 669 value: function() {
669 //clear the selected subpath...the only new additions to this function w.r.t. ToolBase 670 //clear the selected subpath...the only new additions to this function w.r.t. ToolBase
670 if (this._selectedSubpath){ 671 if (this._selectedSubpath){
671 if (this._selectedSubpath.getSelectedAnchorIndex()>=0){ 672 if (this._selectedSubpath.getSelectedAnchorIndex()>=0){
672 this._selectedSubpath.removeAnchor(this._selectedSubpath.getSelectedAnchorIndex()); 673 this._selectedSubpath.removeAnchor(this._selectedSubpath.getSelectedAnchorIndex());
674 this._selectedSubpath.createSamples();
673 //clear the canvas 675 //clear the canvas
674 this.application.ninja.stage.clearDrawingCanvas();//stageManagerModule.stageManager.clearDrawingCanvas(); 676 this.application.ninja.stage.clearDrawingCanvas();
675 this.DrawSubpathAnchors(this._selectedSubpath); 677 this.DrawSubpathAnchors(this._selectedSubpath);
676 this.ShowSelectedSubpath(); 678 this.ShowSelectedSubpath();
677 } 679 }
678 else { 680 else {
@@ -681,28 +683,14 @@ exports.PenTool = Montage.create(ShapeTool, {
681 this._selectedSubpath.createSamples(); 683 this._selectedSubpath.createSamples();
682 this._selectedSubpath = null; 684 this._selectedSubpath = null;
683 //clear the canvas 685 //clear the canvas
684 this.application.ninja.stage.clearDrawingCanvas();//stageManagerModule.stageManager.clearDrawingCanvas(); 686 this.application.ninja.stage.clearDrawingCanvas();
685
686 //TODO begin code block taken from ToolBase...figure out how to override it correctly
687 var item;
688 /*
689 if(!selectionManagerModule.selectionManager.isDocument) {
690 for(var i=0; item = selectionManagerModule.selectionManager.selectedItems[i]; i++) {
691 drawUtils.removeElement(item._element); // TODO This was called twice - After the event.
692 window.snapManager.removeElementFrom2DCache( item._element ); // TODO Check with Nivesh about it.
693 DocumentControllerModule.DocumentController.RemoveElement(item._element);
694 }
695
696 NJevent( "deleteSelection" );
697 }
698 */
699 //end code block taken from ToolBase
700
701 this._penCanvas = null; 687 this._penCanvas = null;
702 } 688 }
703 } 689 }
704 } 690 }
705 }, 691 },
692 */
693
706 694
707 HandleDoubleClick: { 695 HandleDoubleClick: {
708 value: function () { 696 value: function () {
@@ -710,9 +698,6 @@ exports.PenTool = Montage.create(ShapeTool, {
710 if (this._selectedSubpath && this._selectedSubpath.getSelectedAnchorIndex() !== -1) { 698 if (this._selectedSubpath && this._selectedSubpath.getSelectedAnchorIndex() !== -1) {
711 var selAnchor = this._selectedSubpath.getAnchor(this._selectedSubpath.getSelectedAnchorIndex()); 699 var selAnchor = this._selectedSubpath.getAnchor(this._selectedSubpath.getSelectedAnchorIndex());
712 var pos = Vector.create([selAnchor.getPosX(), selAnchor.getPosY(), selAnchor.getPosZ()]); 700 var pos = Vector.create([selAnchor.getPosX(), selAnchor.getPosY(), selAnchor.getPosZ()]);
713 //var prev = Vector.create([selAnchor.getPrevX(), selAnchor.getPrevY(), selAnchor.getPrevZ()]);
714 //var next = Vector.create([selAnchor.getNextX(), selAnchor.getNextY(), selAnchor.getNextZ()]);
715
716 var distToPrev = selAnchor.getPrevDistanceSq(pos[0], pos[1], pos[2]); 701 var distToPrev = selAnchor.getPrevDistanceSq(pos[0], pos[1], pos[2]);
717 var distToNext = selAnchor.getNextDistanceSq(pos[0], pos[1], pos[2]); 702 var distToNext = selAnchor.getNextDistanceSq(pos[0], pos[1], pos[2]);
718 var threshSq = 0; // 4 * this._PICK_POINT_RADIUS * this._PICK_POINT_RADIUS; 703 var threshSq = 0; // 4 * this._PICK_POINT_RADIUS * this._PICK_POINT_RADIUS;
@@ -820,8 +805,8 @@ exports.PenTool = Montage.create(ShapeTool, {
820 if (ctx.lineWidth == subpath.getStrokeWidth()) 805 if (ctx.lineWidth == subpath.getStrokeWidth())
821 ctx.lineWidth = 3; 806 ctx.lineWidth = 3;
822 ctx.strokeStyle = "black"; 807 ctx.strokeStyle = "black";
823 if (subpath.getStrokeColor()) 808 //if (subpath.getStrokeColor())
824 ctx.strokeStyle = MathUtils.colorToHex( subpath.getStrokeColor() ); 809 // ctx.strokeStyle = MathUtils.colorToHex( subpath.getStrokeColor() );
825 ctx.beginPath(); 810 ctx.beginPath();
826 var p0x = subpath.getAnchor(0).getPosX()+ horizontalOffset; 811 var p0x = subpath.getAnchor(0).getPosX()+ horizontalOffset;
827 var p0y = subpath.getAnchor(0).getPosY()+ verticalOffset; 812 var p0y = subpath.getAnchor(0).getPosY()+ verticalOffset;
@@ -884,7 +869,7 @@ exports.PenTool = Montage.create(ShapeTool, {
884 //display the hovered over anchor point 869 //display the hovered over anchor point
885 ctx.lineWidth = 2; 870 ctx.lineWidth = 2;
886 ctx.strokeStyle = "black"; 871 ctx.strokeStyle = "black";
887 if (this._hoveredAnchorIndex>=0) { 872 if (this._hoveredAnchorIndex && this._hoveredAnchorIndex>=0) {
888 var px = subpath.getAnchor(this._hoveredAnchorIndex).getPosX(); 873 var px = subpath.getAnchor(this._hoveredAnchorIndex).getPosX();
889 var py = subpath.getAnchor(this._hoveredAnchorIndex).getPosY(); 874 var py = subpath.getAnchor(this._hoveredAnchorIndex).getPosY();
890 ctx.beginPath(); 875 ctx.beginPath();
@@ -1061,6 +1046,7 @@ exports.PenTool = Montage.create(ShapeTool, {
1061 //clear the selected subpath...the only new additions to this function w.r.t. ToolBase 1046 //clear the selected subpath...the only new additions to this function w.r.t. ToolBase
1062 if (this._selectedSubpath){ 1047 if (this._selectedSubpath){
1063 if (this._selectedSubpath.getSelectedAnchorIndex()>=0){ 1048 if (this._selectedSubpath.getSelectedAnchorIndex()>=0){
1049 this._hoveredAnchorIndex=-1;
1064 this._selectedSubpath.removeAnchor(this._selectedSubpath.getSelectedAnchorIndex()); 1050 this._selectedSubpath.removeAnchor(this._selectedSubpath.getSelectedAnchorIndex());
1065 this._selectedSubpath.createSamples(); 1051 this._selectedSubpath.createSamples();
1066 //clear the canvas 1052 //clear the canvas