aboutsummaryrefslogtreecommitdiff
path: root/js/tools
diff options
context:
space:
mode:
Diffstat (limited to 'js/tools')
-rw-r--r--js/tools/LineTool.js8
-rw-r--r--js/tools/OvalTool.js15
-rw-r--r--js/tools/PenTool.js554
-rw-r--r--js/tools/RectTool.js15
-rw-r--r--js/tools/Rotate3DToolBase.js2
-rw-r--r--js/tools/RotateStage3DTool.js2
-rw-r--r--js/tools/SelectionTool.js40
-rw-r--r--js/tools/TagTool.js12
-rw-r--r--js/tools/modifier-tool-base.js35
9 files changed, 239 insertions, 444 deletions
diff --git a/js/tools/LineTool.js b/js/tools/LineTool.js
index 17157f23..99c374a7 100644
--- a/js/tools/LineTool.js
+++ b/js/tools/LineTool.js
@@ -203,10 +203,10 @@ exports.LineTool = Montage.create(ShapeTool, {
203 // for default stroke and fill/no materials 203 // for default stroke and fill/no materials
204 var strokeMaterial = null; 204 var strokeMaterial = null;
205 205
206 var strokeIndex = parseInt(this.options.strokeMaterial); 206 var strokeM = this.options.strokeMaterial;
207 if(strokeIndex > 0) 207 if(strokeM)
208 { 208 {
209 strokeMaterial = Object.create(MaterialsLibrary.getMaterialAt(strokeIndex-1)); 209 strokeMaterial = Object.create(MaterialsLibrary.getMaterial(strokeM));
210 } 210 }
211 211
212 var world = this.getGLWorld(canvas, this.options.use3D); 212 var world = this.getGLWorld(canvas, this.options.use3D);
@@ -232,12 +232,12 @@ exports.LineTool = Montage.create(ShapeTool, {
232 } 232 }
233 233
234 canvas.elementModel.shapeModel.strokeMaterial = strokeMaterial; 234 canvas.elementModel.shapeModel.strokeMaterial = strokeMaterial;
235 canvas.elementModel.shapeModel.strokeMaterialIndex = strokeIndex;
236 235
237 canvas.elementModel.shapeModel.strokeStyleIndex = strokeStyleIndex; 236 canvas.elementModel.shapeModel.strokeStyleIndex = strokeStyleIndex;
238 canvas.elementModel.shapeModel.strokeStyle = strokeStyle; 237 canvas.elementModel.shapeModel.strokeStyle = strokeStyle;
239 238
240 canvas.elementModel.shapeModel.GLGeomObj = line; 239 canvas.elementModel.shapeModel.GLGeomObj = line;
240 canvas.elementModel.shapeModel.useWebGl = this.options.use3D;
241 } 241 }
242 else 242 else
243 { 243 {
diff --git a/js/tools/OvalTool.js b/js/tools/OvalTool.js
index 2fa5411b..14655312 100644
--- a/js/tools/OvalTool.js
+++ b/js/tools/OvalTool.js
@@ -43,16 +43,16 @@ exports.OvalTool = Montage.create(ShapeTool, {
43 var strokeMaterial = null; 43 var strokeMaterial = null;
44 var fillMaterial = null; 44 var fillMaterial = null;
45 45
46 var strokeIndex = parseInt(this.options.strokeMaterial); 46 var strokeM = this.options.strokeMaterial;
47 if(strokeIndex > 0) 47 if(strokeM)
48 { 48 {
49 strokeMaterial = Object.create(MaterialsLibrary.getMaterialAt(strokeIndex-1)); 49 strokeMaterial = Object.create(MaterialsLibrary.getMaterial(strokeM));
50 } 50 }
51 51
52 var fillIndex = parseInt(this.options.fillMaterial); 52 var fillM = this.options.fillMaterial;
53 if(fillIndex > 0) 53 if(fillM)
54 { 54 {
55 fillMaterial = Object.create(MaterialsLibrary.getMaterialAt(fillIndex-1)); 55 fillMaterial = Object.create(MaterialsLibrary.getMaterial(fillM));
56 } 56 }
57 57
58 58
@@ -88,13 +88,12 @@ exports.OvalTool = Montage.create(ShapeTool, {
88 88
89 canvas.elementModel.shapeModel.strokeMaterial = strokeMaterial; 89 canvas.elementModel.shapeModel.strokeMaterial = strokeMaterial;
90 canvas.elementModel.shapeModel.fillMaterial = fillMaterial; 90 canvas.elementModel.shapeModel.fillMaterial = fillMaterial;
91 canvas.elementModel.shapeModel.strokeMaterialIndex = strokeIndex;
92 canvas.elementModel.shapeModel.fillMaterialIndex = fillIndex;
93 91
94 canvas.elementModel.shapeModel.strokeStyleIndex = strokeStyleIndex; 92 canvas.elementModel.shapeModel.strokeStyleIndex = strokeStyleIndex;
95 canvas.elementModel.shapeModel.strokeStyle = strokeStyle; 93 canvas.elementModel.shapeModel.strokeStyle = strokeStyle;
96 94
97 canvas.elementModel.shapeModel.GLGeomObj = oval; 95 canvas.elementModel.shapeModel.GLGeomObj = oval;
96 canvas.elementModel.shapeModel.useWebGl = this.options.use3D;
98 } 97 }
99 else 98 else
100 { 99 {
diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js
index 78344d18..9a69b53d 100644
--- a/js/tools/PenTool.js
+++ b/js/tools/PenTool.js
@@ -5,6 +5,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
5</copyright> */ 5</copyright> */
6 6
7var ShapeTool = require("js/tools/ShapeTool").ShapeTool; 7var ShapeTool = require("js/tools/ShapeTool").ShapeTool;
8var ShapesController = require("js/controllers/elements/shapes-controller").ShapesController;
8var DrawingToolBase = require("js/tools/drawing-tool-base").DrawingToolBase; 9var DrawingToolBase = require("js/tools/drawing-tool-base").DrawingToolBase;
9var defaultEventManager = require("montage/core/event/event-manager").defaultEventManager; 10var defaultEventManager = require("montage/core/event/event-manager").defaultEventManager;
10var Montage = require("montage/core/core").Montage; 11var Montage = require("montage/core/core").Montage;
@@ -12,6 +13,10 @@ var NJUtils = require("js/lib/NJUtils").NJUtils;
12var ElementMediator = require("js/mediators/element-mediator").ElementMediator; 13var ElementMediator = require("js/mediators/element-mediator").ElementMediator;
13var TagTool = require("js/tools/TagTool").TagTool; 14var TagTool = require("js/tools/TagTool").TagTool;
14var ElementController = require("js/controllers/elements/element-controller").ElementController; 15var ElementController = require("js/controllers/elements/element-controller").ElementController;
16var snapManager = require("js/helper-classes/3D/snap-manager").SnapManager;
17
18//todo remove this global var
19var g_DoPenToolMouseMove = true;
15 20
16exports.PenTool = Montage.create(ShapeTool, { 21exports.PenTool = Montage.create(ShapeTool, {
17 22
@@ -32,14 +37,10 @@ exports.PenTool = Montage.create(ShapeTool, {
32 _currentY: { value: 0, writable: true }, 37 _currentY: { value: 0, writable: true },
33 38
34 //the subpaths are what is displayed on the screen currently, with _selectedSubpath being the active one currently being edited 39 //the subpaths are what is displayed on the screen currently, with _selectedSubpath being the active one currently being edited
35 _subpaths: { value: [], writable: true },
36 _selectedSubpath: { value: null, writable: true }, 40 _selectedSubpath: { value: null, writable: true },
37 _makeMultipleSubpaths: { value: true, writable: true }, //set this to true if you want to keep making subpaths after closing current subpath 41 _makeMultipleSubpaths: { value: true, writable: true }, //set this to true if you want to keep making subpaths after closing current subpath
38 42
39 43
40 //whether or not to display the guides for debugging
41 _showGuides: { value: true, writable: true },
42
43 //whether the user has held down the Alt key 44 //whether the user has held down the Alt key
44 _isAltDown: { value: false, writable: true }, 45 _isAltDown: { value: false, writable: true },
45 46
@@ -64,6 +65,9 @@ exports.PenTool = Montage.create(ShapeTool, {
64 //the plane matrix for the first click...so the entire path is on the same plane 65 //the plane matrix for the first click...so the entire path is on the same plane
65 _penPlaneMat: { value: null, writable: true }, 66 _penPlaneMat: { value: null, writable: true },
66 67
68 //index of the anchor point that the user has hovered over
69 _hoveredAnchorIndex: {value: null, writable: true},
70
67 //constants used for picking points --- NOTE: these should be user-settable parameters 71 //constants used for picking points --- NOTE: these should be user-settable parameters
68 _PICK_POINT_RADIUS: { value: 10, writable: false }, 72 _PICK_POINT_RADIUS: { value: 10, writable: false },
69 _DISPLAY_ANCHOR_RADIUS: { value: 5, writable: false }, 73 _DISPLAY_ANCHOR_RADIUS: { value: 5, writable: false },
@@ -85,39 +89,29 @@ exports.PenTool = Montage.create(ShapeTool, {
85 ENTRY_SELECT_PATH: { value: 2, writable: false}, 89 ENTRY_SELECT_PATH: { value: 2, writable: false},
86 _entryEditMode: {value: this.ENTRY_SELECT_NONE, writable: true}, 90 _entryEditMode: {value: this.ENTRY_SELECT_NONE, writable: true},
87 91
88 // ******** Logic for selection *******
89 // (update if you change functionality!)
90 // NOTE: this is out of date...needs to be updated
91 //
92 // Start by setting edit mode to EDIT_NONE
93 //
94 // DOUBLE_CLICK (Left mouse button only):
95 //
96 //
97 // SINGLE_CLICK (Left mouse button only):
98 // If LeftClick selects an anchor point
99 // append EDIT_ANCHOR mode
100 // If LeftClick selects a previous point of selected anchor
101 // append EDIT_PREV mode
102 // If LeftClick selects a next point of selected anchor
103 // append EDIT_NEXT mode
104 //
105
106 // ********* Logic for editing *******
107 // (update if you change functionality!)
108 // NOTE: this is out of date...needs to be updated
109 //
110 // Start by computing mouse disp
111 //
112 // If EDIT_PREV_NEXT mode
113 // add disp to next and mirror it to prev
114 // ELSE
115 // If EDIT_ANCHOR (or _PREV, _NEXT)
116 // map displacement to anchor (similarly to prev and next)
117 //
118 //
119 92
120 93
94 _getUnsnappedPosition: {
95 value: function(x,y){
96 var elemSnap = snapManager.elementSnapEnabled();
97 var gridSnap = snapManager.gridSnapEnabled();
98 var alignSnap = snapManager.snapAlignEnabled();
99
100 snapManager.enableElementSnap(false);
101 snapManager.enableGridSnap(false);
102 snapManager.enableSnapAlign(false);
103
104 var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(x,y));
105 var unsnappedpos = DrawingToolBase.getHitRecPos(snapManager.snap(point.x, point.y, false));
106
107 snapManager.enableElementSnap(elemSnap);
108 snapManager.enableGridSnap(gridSnap);
109 snapManager.enableSnapAlign(alignSnap);
110
111 return unsnappedpos;
112 }
113 },
114
121 ShowToolProperties: { 115 ShowToolProperties: {
122 value: function () { 116 value: function () {
123 this._penView = PenView.create(); 117 this._penView = PenView.create();
@@ -137,21 +131,18 @@ exports.PenTool = Montage.create(ShapeTool, {
137 //NOTE: this will work on Webkit only...IE has different codes (left: 1, middle: 4, right: 2) 131 //NOTE: this will work on Webkit only...IE has different codes (left: 1, middle: 4, right: 2)
138 return; 132 return;
139 } 133 }
140 //BEGIN ShapeTool code
141 if (this._canDraw) { 134 if (this._canDraw) {
142 this._isDrawing = true; 135 this._isDrawing = true;
143 } 136 }
144 137
145 //this._targetedCanvas = stageManagerModule.stageManager.GetObjectFromPoint(event.layerX, event.layerY, this._canOperateOnStage);
146 138
147 this.startDraw(event); 139 this.startDraw(event);
148 //END ShapeTool code
149 140
150 //assume we are not starting a new path as we will set this to true if we create a new GLSubpath() 141 //assume we are not starting a new path as we will set this to true if we create a new GLSubpath()