aboutsummaryrefslogtreecommitdiff
path: root/js/tools/PenTool.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/tools/PenTool.js')
-rwxr-xr-xjs/tools/PenTool.js41
1 files changed, 31 insertions, 10 deletions
diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js
index 60ef4f92..7fc8dd95 100755
--- a/js/tools/PenTool.js
+++ b/js/tools/PenTool.js
@@ -467,9 +467,9 @@ exports.PenTool = Montage.create(ShapeTool, {
467 if (this.application.ninja.colorController.colorToolbar.stroke.webGlColor){ 467 if (this.application.ninja.colorController.colorToolbar.stroke.webGlColor){
468 this._selectedSubpath.setStrokeColor(this.application.ninja.colorController.colorToolbar.stroke.webGlColor); 468 this._selectedSubpath.setStrokeColor(this.application.ninja.colorController.colorToolbar.stroke.webGlColor);
469 } 469 }
470 //if (this.application.ninja.colorController.colorToolbar.fill.webGlColor){ 470 if (this.application.ninja.colorController.colorToolbar.fill.webGlColor){
471 // this._selectedSubpath.setFillColor(this.application.ninja.colorController.colorToolbar.fill.webGlColor); 471 this._selectedSubpath.setFillColor(this.application.ninja.colorController.colorToolbar.fill.webGlColor);
472 //} 472 }
473 } //if this is a new path being rendered 473 } //if this is a new path being rendered
474 474
475 this._selectedSubpath.makeDirty(); 475 this._selectedSubpath.makeDirty();
@@ -584,8 +584,8 @@ exports.PenTool = Montage.create(ShapeTool, {
584 if (!canvas) { 584 if (!canvas) {
585 var newCanvas = null; 585 var newCanvas = null;
586 newCanvas = NJUtils.makeNJElement("canvas", "Subpath", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); 586 newCanvas = NJUtils.makeNJElement("canvas", "Subpath", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true);
587 var elementModel = TagTool.makeElement(parseInt(w), parseInt(h), planeMat, midPt, newCanvas); 587 var elementModel = TagTool.makeElement(parseInt(w), parseInt(h), planeMat, midPt, newCanvas, true);
588 ElementMediator.addElement(newCanvas, elementModel.data, true); 588 ElementMediator.addElements(newCanvas, elementModel.data, false);
589 589
590 // create all the GL stuff 590 // create all the GL stuff
591 var world = this.getGLWorld(newCanvas, this._useWebGL);//this.options.use3D);//this.CreateGLWorld(planeMat, midPt, newCanvas, this._useWebGL);//fillMaterial, strokeMaterial); 591 var world = this.getGLWorld(newCanvas, this._useWebGL);//this.options.use3D);//this.CreateGLWorld(planeMat, midPt, newCanvas, this._useWebGL);//fillMaterial, strokeMaterial);
@@ -594,6 +594,7 @@ exports.PenTool = Montage.create(ShapeTool, {
594 594
595 var subpath = this._selectedSubpath; //new GLSubpath(); 595 var subpath = this._selectedSubpath; //new GLSubpath();
596 subpath.setWorld(world); 596 subpath.setWorld(world);
597 subpath.setCanvas(newCanvas);
597 subpath.setPlaneMatrix(planeMat); 598 subpath.setPlaneMatrix(planeMat);
598 var planeMatInv = glmat4.inverse( planeMat, [] ); 599 var planeMatInv = glmat4.inverse( planeMat, [] );
599 subpath.setPlaneMatrixInverse(planeMatInv); 600 subpath.setPlaneMatrixInverse(planeMatInv);
@@ -601,7 +602,27 @@ exports.PenTool = Montage.create(ShapeTool, {
601 602
602 world.addObject(subpath); 603 world.addObject(subpath);
603 world.render(); 604 world.render();
605 //TODO this will not work if there are multiple shapes in the same canvas
604 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
614 newCanvas.elementModel.shapeModel.GLGeomObj = subpath;
615 newCanvas.elementModel.shapeModel.useWebGl = this.options.use3D;
616 }
617 else
618 {
619 // TODO - update the shape's info only. shapeModel will likely need an array of shapes.
620 }
621
622 if(newCanvas.elementModel.isShape)
623 {
624 this.application.ninja.selectionController.selectElement(newCanvas);
625 }
605 } //if (!canvas) { 626 } //if (!canvas) {
606 else { 627 else {
607 628
@@ -951,11 +972,11 @@ exports.PenTool = Montage.create(ShapeTool, {
951 } 972 }
952 else{ 973 else{
953 for (var i=0;i<this.application.ninja.selectedElements.length;i++){ 974 for (var i=0;i<this.application.ninja.selectedElements.length;i++){
954 var element = this.application.ninja.selectedElements[i]._element; 975 var element = this.application.ninja.selectedElements[i]
955 console.log("Entered pen tool, had selected: " + element.elementModel.selection); 976 console.log("Entered pen tool, had selected: " + element.elementModel.selection);
956 if (element.elementModel.selection === 'Subpath'){ //TODO what to do if the canvas is drawn by tag tool? 977 if (element.elementModel.selection === 'Subpath'){ //TODO what to do if the canvas is drawn by tag tool?
957 //set the pen canvas to be the selected canvas 978 //set the pen canvas to be the selected canvas
958 this._penCanvas = this.application.ninja.selectedElements[i]._element; 979 this._penCanvas = this.application.ninja.selectedElements[i];
959 980
960 // get the subpath for this world 981 // get the subpath for this world
961 this._selectedSubpath = null; 982 this._selectedSubpath = null;
@@ -1030,7 +1051,7 @@ exports.PenTool = Montage.create(ShapeTool, {
1030 var els = []; 1051 var els = [];
1031 ElementController.removeElement(this._penCanvas); 1052 ElementController.removeElement(this._penCanvas);
1032 els.push(this._penCanvas); 1053 els.push(this._penCanvas);
1033 NJevent( "deleteSelection", els ); 1054 NJevent( "elementsRemoved", els );
1034 this._penCanvas = null; 1055 this._penCanvas = null;
1035 } 1056 }
1036 } 1057 }
@@ -1046,9 +1067,9 @@ exports.PenTool = Montage.create(ShapeTool, {
1046 els.push(this.application.ninja.selectedElements[i]); 1067 els.push(this.application.ninja.selectedElements[i]);
1047 } 1068 }
1048 for(i=0; i<len; i++) { 1069 for(i=0; i<len; i++) {
1049 ElementController.removeElement(els[i]._element); 1070 ElementController.removeElement(els[i]);
1050 } 1071 }
1051 NJevent( "deleteSelection", els ); 1072 NJevent( "elementsRemoved", els );
1052 1073
1053 //clear out the selected path if it exists 1074 //clear out the selected path if it exists
1054 if (this._selectedSubpath) { 1075 if (this._selectedSubpath) {