From a11ef2eed7049835c8bdfa50a2b893632c46eaa0 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 4 Apr 2012 11:11:58 -0700 Subject: Squashed commit of Preparing for the montage undo-manager: Architecture changes Reworked the add and remove elements into 1 function which can take 1 or more elements. Removed the _element from the selection array Many other changes related to those 2 changes Undo/Redo shortcuts are now using montage undo/redo manager. Signed-off-by: Valerio Virgillito --- js/tools/ShapeTool.js | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) (limited to 'js/tools/ShapeTool.js') 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, viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils, drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils, NJUtils = require("js/lib/NJUtils").NJUtils, - ElementMediator = require("js/mediators/element-mediator").ElementMediator, ShapesController = require("js/controllers/elements/shapes-controller").ShapesController, ShapeModel = require("js/models/shape-model").ShapeModel, TagTool = require("js/tools/TagTool").TagTool; @@ -62,30 +61,23 @@ exports.ShapeTool = Montage.create(DrawingTool, { { var drawData; - drawData = this.getDrawingData(); + drawData = this.getDrawingData(); if(drawData) { var canvas; - if(!this._useExistingCanvas()) - { + if(!this._useExistingCanvas()) { canvas = NJUtils.makeNJElement("canvas", "Canvas", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); - var elementModel = TagTool.makeElement(~~drawData.width, ~~drawData.height, - drawData.planeMat, drawData.midPt, canvas); + var elementModel = TagTool.makeElement(~~drawData.width, ~~drawData.height, drawData.planeMat, drawData.midPt, canvas); - ElementMediator.addElement(canvas, elementModel.data, true); canvas.elementModel.isShape = true; - } - else - { + this.application.ninja.elementMediator.addElements(canvas, elementModel.data); + } else { canvas = this._targetedElement; canvas.elementModel.controller = ShapesController; - if(!canvas.elementModel.shapeModel) - { + if(!canvas.elementModel.shapeModel) { canvas.elementModel.shapeModel = Montage.create(ShapeModel); } } - this.RenderShape(drawData.width, drawData.height, drawData.planeMat, drawData.midPt, canvas); - NJevent("elementAdded", canvas); } this.endDraw(event); @@ -93,17 +85,28 @@ exports.ShapeTool = Montage.create(DrawingTool, { this._isDrawing = false; this._hasDraw=false; - this.DrawHandles(); } }, + onAddElements: { + value: function(el) { + var drawData; + + if(drawData = this.getDrawingData()) { + this.RenderShape(drawData.width, drawData.height, drawData.planeMat, drawData.midPt, el); + } + } + }, + Configure: { value: function(wasSelected) { if(wasSelected) { this.AddCustomFeedback(); + this.application.ninja.elementMediator.addDelegate = this; } else { this.RemoveCustomFeedback(); + this.application.ninja.elementMediator.addDelegate = null; } } }, @@ -174,12 +177,12 @@ exports.ShapeTool = Montage.create(DrawingTool, { getGLWorld: { value: function (canvas, use3D) { - var world = ElementMediator.getShapeProperty(canvas, "GLWorld"); + var world = this.application.ninja.elementMediator.getShapeProperty(canvas, "GLWorld"); if(!world) { // create all the GL stuff var world = new World(canvas, use3D); - ElementMediator.setShapeProperty(canvas, "GLWorld", world); + this.application.ninja.elementMediator.setShapeProperty(canvas, "GLWorld", world); } return world; -- cgit v1.2.3