aboutsummaryrefslogtreecommitdiff
path: root/js/tools/ShapeTool.js
diff options
context:
space:
mode:
authorJose Antonio Marquez2012-04-04 11:50:54 -0700
committerJose Antonio Marquez2012-04-04 11:50:54 -0700
commit0a469a14757b8cea262c21f652e75c85c9903f4b (patch)
treec388fdc93e9707e7d66f51ef41eb1d9b366716c7 /js/tools/ShapeTool.js
parent6034e3aa1d033149ba9ca8f0578e0a95889a7e46 (diff)
parent8482e23cd9b8c4700b5130f2588e5eb24d376536 (diff)
downloadninja-0a469a14757b8cea262c21f652e75c85c9903f4b.tar.gz
Merge branch 'refs/heads/Ninja-Internal' into FileIO
Diffstat (limited to 'js/tools/ShapeTool.js')
-rwxr-xr-xjs/tools/ShapeTool.js37
1 files changed, 20 insertions, 17 deletions
diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js
index d3a36163..34b3615b 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 },
@@ -174,12 +177,12 @@ exports.ShapeTool = Montage.create(DrawingTool, {
174 getGLWorld: { 177 getGLWorld: {
175 value: function (canvas, use3D) 178 value: function (canvas, use3D)
176 { 179 {
177 var world = ElementMediator.getShapeProperty(canvas, "GLWorld"); 180 var world = this.application.ninja.elementMediator.getShapeProperty(canvas, "GLWorld");
178 if(!world) 181 if(!world)
179 { 182 {
180 // create all the GL stuff 183 // create all the GL stuff
181 var world = new World(canvas, use3D); 184 var world = new World(canvas, use3D);
182 ElementMediator.setShapeProperty(canvas, "GLWorld", world); 185 this.application.ninja.elementMediator.setShapeProperty(canvas, "GLWorld", world);
183 } 186 }
184 187
185 return world; 188 return world;