diff options
Diffstat (limited to 'js/tools/PenTool.js')
-rwxr-xr-x | js/tools/PenTool.js | 45 |
1 files changed, 36 insertions, 9 deletions
diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js index 60ef4f92..4a16a491 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(); |
@@ -585,7 +585,7 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
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); |
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,33 @@ 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 | 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 | } | ||
605 | } //if (!canvas) { | 632 | } //if (!canvas) { |
606 | else { | 633 | else { |
607 | 634 | ||
@@ -951,11 +978,11 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
951 | } | 978 | } |
952 | else{ | 979 | else{ |
953 | for (var i=0;i<this.application.ninja.selectedElements.length;i++){ | 980 | for (var i=0;i<this.application.ninja.selectedElements.length;i++){ |
954 | var element = this.application.ninja.selectedElements[i]._element; | 981 | var element = this.application.ninja.selectedElements[i] |
955 | console.log("Entered pen tool, had selected: " + element.elementModel.selection); | 982 | 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? | 983 | 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 | 984 | //set the pen canvas to be the selected canvas |
958 | this._penCanvas = this.application.ninja.selectedElements[i]._element; | 985 | this._penCanvas = this.application.ninja.selectedElements[i]; |
959 | 986 | ||
960 | // get the subpath for this world | 987 | // get the subpath for this world |
961 | this._selectedSubpath = null; | 988 | this._selectedSubpath = null; |
@@ -1030,7 +1057,7 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
1030 | var els = []; | 1057 | var els = []; |
1031 | ElementController.removeElement(this._penCanvas); | 1058 | ElementController.removeElement(this._penCanvas); |
1032 | els.push(this._penCanvas); | 1059 | els.push(this._penCanvas); |
1033 | NJevent( "deleteSelection", els ); | 1060 | NJevent( "elementsRemoved", els ); |
1034 | this._penCanvas = null; | 1061 | this._penCanvas = null; |
1035 | } | 1062 | } |
1036 | } | 1063 | } |
@@ -1046,9 +1073,9 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
1046 | els.push(this.application.ninja.selectedElements[i]); | 1073 | els.push(this.application.ninja.selectedElements[i]); |
1047 | } | 1074 | } |
1048 | for(i=0; i<len; i++) { | 1075 | for(i=0; i<len; i++) { |
1049 | ElementController.removeElement(els[i]._element); | 1076 | ElementController.removeElement(els[i]); |
1050 | } | 1077 | } |
1051 | NJevent( "deleteSelection", els ); | 1078 | NJevent( "elementsRemoved", els ); |
1052 | 1079 | ||
1053 | //clear out the selected path if it exists | 1080 | //clear out the selected path if it exists |
1054 | if (this._selectedSubpath) { | 1081 | if (this._selectedSubpath) { |