aboutsummaryrefslogtreecommitdiff
path: root/js/tools
diff options
context:
space:
mode:
Diffstat (limited to 'js/tools')
-rwxr-xr-xjs/tools/PenTool.js64
1 files changed, 39 insertions, 25 deletions
diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js
index d5cf6439..0cfc9331 100755
--- a/js/tools/PenTool.js
+++ b/js/tools/PenTool.js
@@ -186,26 +186,26 @@ exports.PenTool = Montage.create(ShapeTool, {
186 }, 186 },
187 187
188 _removeSelectedSubpathAndCanvas:{ 188 _removeSelectedSubpathAndCanvas:{
189 value: function(removeSelectedSubpath, removeSelectedSubpathCanvas){ 189 value: function(removeSelectedSubpath){
190 if (removeSelectedSubpathCanvas) { 190 if (removeSelectedSubpath){
191 if (removeSelectedSubpath){ 191 this._selectedSubpath.clearAllAnchors(); //perhaps unnecessary
192 this._selectedSubpath.clearAllAnchors(); //perhaps unnecessary 192 this._selectedSubpath = null;
193 this._selectedSubpath = null; 193 if (this._entryEditMode === this.ENTRY_SELECT_PATH){
194 if (this._entryEditMode === this.ENTRY_SELECT_PATH){ 194 this._entryEditMode = this.ENTRY_SELECT_NONE;
195 this._entryEditMode = this.ENTRY_SELECT_NONE;
196 }
197 this._subtool = this.SUBTOOL_NONE;
198 } 195 }
199 //clear the canvas 196 this._subtool = this.SUBTOOL_NONE;
200 this.application.ninja.stage.clearDrawingCanvas();//stageManagerModule.stageManager.clearDrawingCanvas(); 197 } else {
201 198 this._selectedSubpath.setCanvas(null);
202 //undo/redo...go through ElementController and NJEvent
203 var els = [];
204 ElementController.removeElement(this._selectedSubpathCanvas);
205 els.push(this._selectedSubpathCanvas);
206 NJevent( "elementsRemoved", els );
207 this._selectedSubpathCanvas = null;
208 } 199 }
200 //clear the canvas
201 this.application.ninja.stage.clearDrawingCanvas();//stageManagerModule.stageManager.clearDrawingCanvas();
202
203 //undo/redo...go through ElementController and NJEvent
204 var els = [];
205 ElementController.removeElement(this._selectedSubpathCanvas);
206 els.push(this._selectedSubpathCanvas);
207 NJevent( "elementsRemoved", els );
208 this._selectedSubpathCanvas = null;
209 } 209 }
210 }, 210 },
211 211
@@ -213,26 +213,39 @@ exports.PenTool = Montage.create(ShapeTool, {
213 value: function(){ 213 value: function(){
214 this._hoveredAnchorIndex=-1; 214 this._hoveredAnchorIndex=-1;
215 this._selectedSubpath.removeAnchor(this._selectedSubpath.getSelectedAnchorIndex()); 215 this._selectedSubpath.removeAnchor(this._selectedSubpath.getSelectedAnchorIndex());
216 this._selectedSubpath.createSamples(false); 216 if (this._selectedSubpath.getNumAnchors()===1){
217 //convert the remaining anchor point to stage world coords
218 var xDelta = snapManager.getStageWidth()*0.5;
219 var yDelta = snapManager.getStageHeight()*0.5;
220 var anchor = this._selectedSubpath.getAnchor(0);
221 var swPos = ViewUtils.localToStageWorld([anchor.getPosX(),anchor.getPosY(),anchor.getPosZ()], this._selectedSubpathCanvas);
222 anchor.setPos(swPos[0]+xDelta, swPos[1]+yDelta, swPos[2]);
223 swPos = ViewUtils.localToStageWorld([anchor.getPrevX(),anchor.getPrevY(),anchor.getPrevZ()], this._selectedSubpathCanvas);
224 anchor.setPrevPos(swPos[0]+xDelta, swPos[1]+yDelta, swPos[2]);
225 swPos = ViewUtils.localToStageWorld([anchor.getNextX(),anchor.getNextY(),anchor.getNextZ()], this._selectedSubpathCanvas);
226 anchor.setNextPos(swPos[0]+xDelta, swPos[1]+yDelta, swPos[2]);
227 }
217 //clear the canvas 228 //clear the canvas
218 this.application.ninja.stage.clearDrawingCanvas();//stageManagerModule.stageManager.clearDrawingCanvas(); 229 this.application.ninja.stage.clearDrawingCanvas();//stageManagerModule.stageManager.clearDrawingCanvas();
219 this.PrepareSelectedSubpathForRendering();
220 this.DrawSubpathAnchors(this._selectedSubpath);
221 var removeSelectedSubpath=true; 230 var removeSelectedSubpath=true;
222 var removeSelectedSubpathCanvas=false;
223 var newNumAnchors = this._selectedSubpath.getNumAnchors(); 231 var newNumAnchors = this._selectedSubpath.getNumAnchors();
224 if (newNumAnchors>1) { 232 if (newNumAnchors>1) {
233 this._selectedSubpath.createSamples(false);
234 this.PrepareSelectedSubpathForRendering();
225 this.ShowSelectedSubpath(); 235 this.ShowSelectedSubpath();
226 } 236 }
227 else { 237 else {
238 //since we have 0 or 1 anchors, we will remove the selected canvas (as the path does not exist)
228 if (newNumAnchors===0){ 239 if (newNumAnchors===0){
229 removeSelectedSubpath = true; 240 removeSelectedSubpath = true;
230 } else{ 241 } else{
231 removeSelectedSubpath = false; //don't remove the selected subpath if there is still one anchor 242 removeSelectedSubpath = false; //don't remove the selected subpath if there is still one anchor
232 } 243 }
233 removeSelectedSubpathCanvas = true; 244 this._removeSelectedSubpathAndCanvas(removeSelectedSubpath);
245 }
246 if (!removeSelectedSubpath){
247 this.DrawSubpathAnchors(this._selectedSubpath);
234 } 248 }
235 this._removeSelectedSubpathAndCanvas(removeSelectedSubpath, removeSelectedSubpathCanvas);
236 } 249 }
237 }, 250 },
238 251
@@ -1487,7 +1500,8 @@ exports.PenTool = Montage.create(ShapeTool, {
1487 if (this._selectedSubpath.getSelectedAnchorIndex()>=0){ 1500 if (this._selectedSubpath.getSelectedAnchorIndex()>=0){
1488 this._removeSelectedAnchorPoint(); 1501 this._removeSelectedAnchorPoint();
1489 } else { 1502 } else {
1490 this._removeSelectedSubpathAndCanvas(true, true); 1503 //remove the entire subpath and its canvas if no anchor was selected
1504 this._removeSelectedSubpathAndCanvas(true);
1491 } 1505 }
1492 } 1506 }
1493 else { 1507 else {