diff options
Diffstat (limited to 'js/tools/ShapeTool.js')
-rwxr-xr-x | js/tools/ShapeTool.js | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js index 92284d78..4d8a318e 100755 --- a/js/tools/ShapeTool.js +++ b/js/tools/ShapeTool.js | |||
@@ -9,7 +9,6 @@ var Montage = require("montage/core/core").Montage, | |||
9 | viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils, | 9 | viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils, |
10 | drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils, | 10 | drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils, |
11 | NJUtils = require("js/lib/NJUtils").NJUtils, | 11 | NJUtils = require("js/lib/NJUtils").NJUtils, |
12 | ElementMediator = require("js/mediators/element-mediator").ElementMediator, | ||
13 | ShapesController = require("js/controllers/elements/shapes-controller").ShapesController, | 12 | ShapesController = require("js/controllers/elements/shapes-controller").ShapesController, |
14 | ShapeModel = require("js/models/shape-model").ShapeModel, | 13 | ShapeModel = require("js/models/shape-model").ShapeModel, |
15 | TagTool = require("js/tools/TagTool").TagTool; | 14 | TagTool = require("js/tools/TagTool").TagTool; |
@@ -62,30 +61,23 @@ exports.ShapeTool = Montage.create(DrawingTool, { | |||
62 | { | 61 | { |
63 | var drawData; | 62 | var drawData; |
64 | 63 | ||
65 | drawData = this.getDrawingData(); | 64 | drawData = this.getDrawingData(); |
66 | 65 | ||
67 | if(drawData) { | 66 | if(drawData) { |
68 | var canvas; | 67 | var canvas; |
69 | if(!this._useExistingCanvas()) | 68 | if(!this._useExistingCanvas()) { |
70 | { | ||
71 | canvas = NJUtils.makeNJElement("canvas", "Canvas", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); | 69 | canvas = NJUtils.makeNJElement("canvas", "Canvas", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); |
72 | var elementModel = TagTool.makeElement(~~drawData.width, ~~drawData.height, | 70 | var elementModel = TagTool.makeElement(~~drawData.width, ~~drawData.height, drawData.planeMat, drawData.midPt, canvas); |
73 | drawData.planeMat, drawData.midPt, canvas); | ||
74 | 71 | ||
75 | ElementMediator.addElement(canvas, elementModel.data, true); | ||
76 | canvas.elementModel.isShape = true; | 72 | canvas.elementModel.isShape = true; |
77 | } | 73 | this.application.ninja.elementMediator.addElements(canvas, elementModel.data); |
78 | else | 74 | } else { |
79 | { | ||
80 | canvas = this._targetedElement; | 75 | canvas = this._targetedElement; |
81 | canvas.elementModel.controller = ShapesController; | 76 | canvas.elementModel.controller = ShapesController; |
82 | if(!canvas.elementModel.shapeModel) | 77 | if(!canvas.elementModel.shapeModel) { |
83 | { | ||
84 | canvas.elementModel.shapeModel = Montage.create(ShapeModel); | 78 | canvas.elementModel.shapeModel = Montage.create(ShapeModel); |
85 | } | 79 | } |
86 | } | 80 | } |
87 | this.RenderShape(drawData.width, drawData.height, drawData.planeMat, drawData.midPt, canvas); | ||
88 | NJevent("elementAdded", canvas); | ||
89 | } | 81 | } |
90 | 82 | ||
91 | this.endDraw(event); | 83 | this.endDraw(event); |
@@ -93,17 +85,28 @@ exports.ShapeTool = Montage.create(DrawingTool, { | |||
93 | this._isDrawing = false; | 85 | this._isDrawing = false; |
94 | this._hasDraw=false; | 86 | this._hasDraw=false; |
95 | 87 | ||
96 | |||
97 | this.DrawHandles(); | 88 | this.DrawHandles(); |
98 | } | 89 | } |
99 | }, | 90 | }, |
100 | 91 | ||
92 | onAddElements: { | ||
93 | value: function(el) { | ||
94 | var drawData; | ||
95 | |||
96 | if(drawData = this.getDrawingData()) { | ||
97 | this.RenderShape(drawData.width, drawData.height, drawData.planeMat, drawData.midPt, el); | ||
98 | } | ||
99 | } | ||
100 | }, | ||
101 | |||
101 | Configure: { | 102 | Configure: { |
102 | value: function(wasSelected) { | 103 | value: function(wasSelected) { |
103 | if(wasSelected) { | 104 | if(wasSelected) { |
104 | this.AddCustomFeedback(); | 105 | this.AddCustomFeedback(); |
106 | this.application.ninja.elementMediator.addDelegate = this; | ||
105 | } else { | 107 | } else { |
106 | this.RemoveCustomFeedback(); | 108 | this.RemoveCustomFeedback(); |
109 | this.application.ninja.elementMediator.addDelegate = null; | ||
107 | } | 110 | } |
108 | } | 111 | } |
109 | }, | 112 | }, |
@@ -173,12 +176,12 @@ exports.ShapeTool = Montage.create(DrawingTool, { | |||
173 | getGLWorld: { | 176 | getGLWorld: { |
174 | value: function (canvas, use3D) | 177 | value: function (canvas, use3D) |
175 | { | 178 | { |
176 | var world = ElementMediator.getShapeProperty(canvas, "GLWorld"); | 179 | var world = this.application.ninja.elementMediator.getShapeProperty(canvas, "GLWorld"); |
177 | if(!world) | 180 | if(!world) |
178 | { | 181 | { |
179 | // create all the GL stuff | 182 | // create all the GL stuff |
180 | var world = new World(canvas, use3D); | 183 | var world = new World(canvas, use3D); |
181 | ElementMediator.setShapeProperty(canvas, "GLWorld", world); | 184 | this.application.ninja.elementMediator.setShapeProperty(canvas, "GLWorld", world); |
182 | } | 185 | } |
183 | 186 | ||
184 | return world; | 187 | return world; |