aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/3D/draw-utils.js
diff options
context:
space:
mode:
authorValerio Virgillito2012-07-09 14:35:44 -0700
committerValerio Virgillito2012-07-09 14:35:44 -0700
commit84b3327bd92faafab7954b5eb64c7abe24a3fe13 (patch)
tree3f56cbed2f08c5a81ea79eaf0bcb9bd031d8a627 /js/helper-classes/3D/draw-utils.js
parentc0a42c56f768a873ba637f5b86d5f6a84d4a3312 (diff)
parent40c6eb2c06b34f65a74d59ef9687251952858bab (diff)
downloadninja-84b3327bd92faafab7954b5eb64c7abe24a3fe13.tar.gz
Merge branch 'normalize' of https://github.com/kriskowal/ninja-internal
Conflicts: js/components/gradientpicker.reel/gradientpicker.js js/components/tools-properties/text-properties.reel/text-properties.js js/document/views/base.js js/document/views/design.js js/helper-classes/3D/StageLine.js js/helper-classes/3D/draw-utils.js js/lib/drawing/world.js js/lib/geom/circle.js js/lib/geom/line.js js/lib/geom/rectangle.js js/lib/geom/shape-primitive.js js/lib/rdge/materials/bump-metal-material.js js/lib/rdge/materials/flag-material.js js/lib/rdge/materials/fly-material.js js/lib/rdge/materials/julia-material.js js/lib/rdge/materials/keleidoscope-material.js js/lib/rdge/materials/mandel-material.js js/lib/rdge/materials/material.js js/lib/rdge/materials/plasma-material.js js/lib/rdge/materials/pulse-material.js js/lib/rdge/materials/radial-gradient-material.js js/lib/rdge/materials/taper-material.js js/lib/rdge/materials/twist-vert-material.js js/lib/rdge/materials/water-material.js js/panels/Materials/materials-library-panel.reel/materials-library-panel.html js/panels/Materials/materials-library-panel.reel/materials-library-panel.js js/panels/Materials/materials-popup.reel/materials-popup.html js/panels/Materials/materials-popup.reel/materials-popup.js js/tools/LineTool.js Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'js/helper-classes/3D/draw-utils.js')
-rwxr-xr-xjs/helper-classes/3D/draw-utils.js2082
1 files changed, 1041 insertions, 1041 deletions
diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js
index 617b61ef..5d3a1e2f 100755
--- a/js/helper-classes/3D/draw-utils.js
+++ b/js/helper-classes/3D/draw-utils.js
@@ -42,104 +42,104 @@ var StageLine = require("js/helper-classes/3D/StageLine").StageLine;
42 42
43var DrawUtils = exports.DrawUtils = Montage.create(Component, { 43var DrawUtils = exports.DrawUtils = Montage.create(Component, {
44 44
45 /////////////////////////////////////////////////////////////////////// 45 ///////////////////////////////////////////////////////////////////////
46 // Instance variables 46 // Instance variables
47 /////////////////////////////////////////////////////////////////////// 47 ///////////////////////////////////////////////////////////////////////
48 viewUtils: { value: null, writable: true }, 48 viewUtils: { value: null, writable: true },
49 snapManager: { value: null }, 49 snapManager: { value: null },
50 ElementPlanes : { value: null, writable: true }, 50 ElementPlanes : { value: null, writable: true },
51 51
52 // the drawing surface (a canvas) 52 // the drawing surface (a canvas)
53 _drawingSurfaceElt : { value: null, writable: true }, 53 _drawingSurfaceElt : { value: null, writable: true },
54 _drawingContext : { value: null, writable: true }, 54 _drawingContext : { value: null, writable: true },
55 55
56 // color to draw the lines 56 // color to draw the lines
57 _lineColor : { value: "black", writable: true}, 57 _lineColor : { value: "black", writable: true},
58 58
59 // define a stack for quickly setting graphics states and restoring them 59 // define a stack for quickly setting graphics states and restoring them
60 _stateArray : { value: [], writable: true }, 60 _stateArray : { value: [], writable: true },
61 61
62 // save references to the grid lines for quick redraw 62 // save references to the grid lines for quick redraw
63 _gridLineArray : {value: [], writable: true }, 63 _gridLineArray : {value: [], writable: true },
64 64
65 // state for moveTo, lineTo 65 // state for moveTo, lineTo
66 _curPt : { value: null, writable: true }, 66 _curPt : { value: null, writable: true },
67 _curVis : { value: null, writable: true }, 67 _curVis : { value: null, writable: true },
68 68
69 // the element that defines the coordinate system for the displayed lines 69 // the element that defines the coordinate system for the displayed lines
70 _sourceSpaceElt : { value: null, writable: true }, 70 _sourceSpaceElt : { value: null, writable: true },
71 71
72 // maintain a list of objects to hide against 72 // maintain a list of objects to hide against
73 _eltArray : {value: [], writable: true }, 73 _eltArray : {value: [], writable: true },
74 74
75 // maintain a list of the planes to test against 75 // maintain a list of the planes to test against
76 _planesArray : {value: [], writable: true }, 76 _planesArray : {value: [], writable: true },
77 77
78 // the working plane. 78 // the working plane.
79 // a grid may be drawn aligned with this working plane 79 // a grid may be drawn aligned with this working plane
80 _workingPlane : { value: null, writable: true }, 80 _workingPlane : { value: null, writable: true },
81 81
82 // save some parameters about the grid. 82 // save some parameters about the grid.
83 // these parameters are set when the grid is drawn 83 // these parameters are set when the grid is drawn
84 _gridHorizontalSpacing : {value: 50, writable: true }, 84 _gridHorizontalSpacing : {value: 50, writable: true },
85 _gridVerticalSpacing : {value: 50, writable: true }, 85 _gridVerticalSpacing : {value: 50, writable: true },
86 _gridHorizontalLineCount : {value:10, writable: true }, 86 _gridHorizontalLineCount : {value:10, writable: true },
87 _gridVerticalLineCount : {value:0, writable: true }, 87 _gridVerticalLineCount : {value:0, writable: true },
88 _gridOrigin : {value: null, writable: true }, 88 _gridOrigin : {value: null, writable: true },
89 89
90 drawXY : {value: false, writable: true }, 90 drawXY : {value: false, writable: true },
91 drawXZ : {value: false, writable: true }, 91 drawXZ : {value: false, writable: true },
92 drawYZ : {value: false, writable: true }, 92 drawYZ : {value: false, writable: true },
93 93
94 drawElementN : {value: false, writable: true }, 94 drawElementN : {value: false, writable: true },
95 95
96 _selectionCtr : {value: null, writable: true }, 96 _selectionCtr : {value: null, writable: true },
97 97
98 // Properties that require element planes to be updated 98 // Properties that require element planes to be updated
99 _updatePlaneProps : {value: ["matrix", "left", "top", "width", "height"], writable: false }, 99 _updatePlaneProps : {value: ["matrix", "left", "top", "width", "height"], writable: false },
100 _recalculateScrollOffsets : { value: false }, 100 _recalculateScrollOffsets : { value: false },
101 101
102 /////////////////////////////////////////////////////////////////////// 102 ///////////////////////////////////////////////////////////////////////
103 // Property accessors 103 // Property accessors
104 /////////////////////////////////////////////////////////////////////// 104 ///////////////////////////////////////////////////////////////////////
105 setDrawingSurfaceElement : { value: function( s ) { this._drawingSurfaceElt = s; if (s) this._drawingContext = s.getContext("2d"); }}, 105 setDrawingSurfaceElement : { value: function( s ) { this._drawingSurfaceElt = s; if (s) this._drawingContext = s.getContext("2d"); }},
106 getDrawingSurfaceElement : { value: function() { return this._drawingSurfaceElt; }}, 106 getDrawingSurfaceElement : { value: function() { return this._drawingSurfaceElt; }},
107 107
108 getDrawingContext : { value: function() { return this._drawingContext; }}, 108 getDrawingContext : { value: function() { return this._drawingContext; }},
109 109
110 setSourceSpaceElement : { value: function(ss) { this._sourceSpaceElt = ss; }}, 110 setSourceSpaceElement : { value: function(ss) { this._sourceSpaceElt = ss; }},
111 getSourceSpaceElement : { value: function() { return this._sourceSpaceElt; }}, 111 getSourceSpaceElement : { value: function() { return this._sourceSpaceElt; }},
112 112
113 getWorkingPlane : { value: function() { return this._workingPlane; }}, 113 getWorkingPlane : { value: function() { return this._workingPlane; }},
114 setWorkingPlane : { value: function (wp) { this._workingPlane = wp; }}, 114 setWorkingPlane : { value: function (wp) { this._workingPlane = wp; }},
115 115
116 getGridHorizontalSpacing : { value: function() { return this._gridHorizontalSpacing; }}, 116 getGridHorizontalSpacing : { value: function() { return this._gridHorizontalSpacing; }},
117 getGridVerticalSpacing : { value: function() { return this._gridVerticalSpacing; }}, 117 getGridVerticalSpacing : { value: function() { return this._gridVerticalSpacing; }},
118 getGridHorizontalLineCount : { value: function() { return this._gridHorizontalLineCount; }}, 118 getGridHorizontalLineCount : { value: function() { return this._gridHorizontalLineCount; }},
119 getGridVerticalLineCount : { value: function() { return this._gridVerticalLineCount; }}, 119 getGridVerticalLineCount : { value: function() { return this._gridVerticalLineCount; }},
120 getGridOrigin : { value: function() { return this._gridOrigin.slice(0); }}, 120 getGridOrigin : { value: function() { return this._gridOrigin.slice(0); }},
121 121
122 isDrawingGrid : { value: function() { return this.drawXY || this.drawYZ || this.drawXZ; }}, 122 isDrawingGrid : { value: function() { return this.drawXY || this.drawYZ || this.drawXZ; }},
123 isDrawingElementNormal : { value: function() { return this.drawElementN }}, 123 isDrawingElementNormal : { value: function() { return this.drawElementN }},
124 124
125 getLineColor : { value: function() { return this._lineColor; }}, 125 getLineColor : { value: function() { return this._lineColor; }},
126 setLineColor : { value: function( color ) { this._lineColor = color; }}, 126 setLineColor : { value: function( color ) { this._lineColor = color; }},
127 127
128 getLineWidth : { value: function() { return this._drawingContext.lineWidth; }}, 128 getLineWidth : { value: function() { return this._drawingContext.lineWidth; }},
129 setLineWidth : { value: function( w ) { this._drawingContext.lineWidth = w; }}, 129 setLineWidth : { value: function( w ) { this._drawingContext.lineWidth = w; }},
130 130
131 131
132 initialize: { 132 initialize: {
133 value: function() { 133 value: function() {
134 this._gridOrigin = [0,0]; // 2D plane space point 134 this._gridOrigin = [0,0]; // 2D plane space point
135 135
136 this.eventManager.addEventListener("elementAdded", this, false); 136 this.eventManager.addEventListener("elementAdded", this, false);
137 this.eventManager.addEventListener("elementsRemoved", this, false); 137 this.eventManager.addEventListener("elementsRemoved", this, false);
138 this.eventManager.addEventListener("elementChange", this, false); 138 this.eventManager.addEventListener("elementChange", this, false);
139 this.eventManager.addEventListener("elementChanging", this, false); 139 this.eventManager.addEventListener("elementChanging", this, false);
140 this.eventManager.addEventListener("elementReplaced", this, false); 140 this.eventManager.addEventListener("elementReplaced", this, false);
141 } 141 }
142 }, 142 },
143 143
144 initializeFromDocument:{ 144 initializeFromDocument:{
145 value:function(adjustScrollOffsets, useStageValues){ 145 value:function(adjustScrollOffsets, useStageValues){
@@ -364,503 +364,503 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
364 } 364 }
365 }, 365 },
366 366
367 /////////////////////////////////////////////////////////////////////// 367 ///////////////////////////////////////////////////////////////////////
368 // Methods 368 // Methods
369 /////////////////////////////////////////////////////////////////////// 369 ///////////////////////////////////////////////////////////////////////
370 370
371 addElement: { 371 addElement: {
372 value: function( elt ) { 372 value: function( elt ) {
373 // check if we already know about this object 373 // check if we already know about this object
374 var n = this._eltArray.length; 374 var n = this._eltArray.length;
375 for (var i=0; i<n; i++) { 375 for (var i=0; i<n; i++) {
376 if (elt == this._eltArray[i]) { 376 if (elt == this._eltArray[i]) {
377 return; 377 return;
378 } 378 }
379 } 379 }
380 380
381 this._eltArray.push( elt ); 381 this._eltArray.push( elt );
382 382
383 // create the planes for this element 383 // create the planes for this element
384 var plane = Object.create(this.ElementPlanes, {}); 384 var plane = Object.create(this.ElementPlanes, {});
385 plane.setElement( elt ); 385 plane.setElement( elt );
386 plane.init(); 386 plane.init();
387 this._planesArray.push( plane );