diff options
Diffstat (limited to 'js/helper-classes/3D/draw-utils.js')
-rwxr-xr-x | js/helper-classes/3D/draw-utils.js | 2116 |
1 files changed, 1059 insertions, 1057 deletions
diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index 235b381e..869de213 100755 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js | |||
@@ -1,24 +1,25 @@ | |||
1 | /* <copyright> | 1 | /* <copyright> |
2 | Copyright (c) 2012, Motorola Mobility, Inc | 2 | Copyright (c) 2012, Motorola Mobility LLC. |
3 | All Rights Reserved. | 3 | All Rights Reserved. |
4 | BSD License. | ||
5 | 4 | ||
6 | Redistribution and use in source and binary forms, with or without | 5 | Redistribution and use in source and binary forms, with or without |
7 | modification, are permitted provided that the following conditions are met: | 6 | modification, are permitted provided that the following conditions are met: |
8 | 7 | ||
9 | - Redistributions of source code must retain the above copyright notice, | 8 | * Redistributions of source code must retain the above copyright notice, |
10 | this list of conditions and the following disclaimer. | 9 | this list of conditions and the following disclaimer. |
11 | - Redistributions in binary form must reproduce the above copyright | 10 | |
12 | notice, this list of conditions and the following disclaimer in the | 11 | * Redistributions in binary form must reproduce the above copyright notice, |
13 | documentation and/or other materials provided with the distribution. | 12 | this list of conditions and the following disclaimer in the documentation |
14 | - Neither the name of Motorola Mobility nor the names of its contributors | 13 | and/or other materials provided with the distribution. |
15 | may be used to endorse or promote products derived from this software | 14 | |
16 | without specific prior written permission. | 15 | * Neither the name of Motorola Mobility LLC nor the names of its |
16 | contributors may be used to endorse or promote products derived from this | ||
17 | software without specific prior written permission. | ||
17 | 18 | ||
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | 22 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
@@ -42,104 +43,104 @@ var StageLine = require("js/helper-classes/3D/StageLine").StageLine; | |||
42 | 43 | ||
43 | var DrawUtils = exports.DrawUtils = Montage.create(Component, { | 44 | var DrawUtils = exports.DrawUtils = Montage.create(Component, { |
44 | 45 | ||
45 | /////////////////////////////////////////////////////////////////////// | 46 | /////////////////////////////////////////////////////////////////////// |
46 | // Instance variables | 47 | // Instance variables |
47 | /////////////////////////////////////////////////////////////////////// | 48 | /////////////////////////////////////////////////////////////////////// |
48 | viewUtils: { value: null, writable: true }, | 49 | viewUtils: { value: null, writable: true }, |
49 | snapManager: { value: null }, | 50 | snapManager: { value: null }, |
50 | ElementPlanes : { value: null, writable: true }, | 51 | ElementPlanes : { value: null, writable: true }, |
51 | 52 | ||
52 | // the drawing surface (a canvas) | 53 | // the drawing surface (a canvas) |
53 | _drawingSurfaceElt : { value: null, writable: true }, | 54 | _drawingSurfaceElt : { value: null, writable: true }, |
54 | _drawingContext : { value: null, writable: true }, | 55 | _drawingContext : { value: null, writable: true }, |
55 | 56 | ||
56 | // color to draw the lines | 57 | // color to draw the lines |
57 | _lineColor : { value: "black", writable: true}, | 58 | _lineColor : { value: "black", writable: true}, |
58 | 59 | ||
59 | // define a stack for quickly setting graphics states and restoring them | 60 | // define a stack for quickly setting graphics states and restoring them |
60 | _stateArray : { value: [], writable: true }, | 61 | _stateArray : { value: [], writable: true }, |
61 | 62 | ||
62 | // save references to the grid lines for quick redraw | 63 | // save references to the grid lines for quick redraw |
63 | _gridLineArray : {value: [], writable: true }, | 64 | _gridLineArray : {value: [], writable: true }, |
64 | 65 | ||
65 | // state for moveTo, lineTo | 66 | // state for moveTo, lineTo |
66 | _curPt : { value: null, writable: true }, | 67 | _curPt : { value: null, writable: true }, |
67 | _curVis : { value: null, writable: true }, | 68 | _curVis : { value: null, writable: true }, |
68 | 69 | ||
69 | // the element that defines the coordinate system for the displayed lines | 70 | // the element that defines the coordinate system for the displayed lines |
70 | _sourceSpaceElt : { value: null, writable: true }, | 71 | _sourceSpaceElt : { value: null, writable: true }, |
71 | 72 | ||
72 | // maintain a list of objects to hide against | 73 | // maintain a list of objects to hide against |
73 | _eltArray : {value: [], writable: true }, | 74 | _eltArray : {value: [], writable: true }, |
74 | 75 | ||
75 | // maintain a list of the planes to test against | 76 | // maintain a list of the planes to test against |
76 | _planesArray : {value: [], writable: true }, | 77 | _planesArray : {value: [], writable: true }, |
77 | 78 | ||
78 | // the working plane. | 79 | // the working plane. |
79 | // a grid may be drawn aligned with this working plane | 80 | // a grid may be drawn aligned with this working plane |
80 | _workingPlane : { value: null, writable: true }, | 81 | _workingPlane : { value: null, writable: true }, |
81 | 82 | ||
82 | // save some parameters about the grid. | 83 | // save some parameters about the grid. |
83 | // these parameters are set when the grid is drawn | 84 | // these parameters are set when the grid is drawn |
84 | _gridHorizontalSpacing : {value: 50, writable: true }, | 85 | _gridHorizontalSpacing : {value: 50, writable: true }, |
85 | _gridVerticalSpacing : {value: 50, writable: true }, | 86 | _gridVerticalSpacing : {value: 50, writable: true }, |
86 | _gridHorizontalLineCount : {value:10, writable: true }, | 87 | _gridHorizontalLineCount : {value:10, writable: true }, |
87 | _gridVerticalLineCount : {value:0, writable: true }, | 88 | _gridVerticalLineCount : {value:0, writable: true }, |
88 | _gridOrigin : {value: null, writable: true }, | 89 | _gridOrigin : {value: null, writable: true }, |
89 | 90 | ||
90 | drawXY : {value: false, writable: true }, | 91 | drawXY : {value: false, writable: true }, |
91 | drawXZ : {value: false, writable: true }, | 92 | drawXZ : {value: false, writable: true }, |
92 | drawYZ : {value: false, writable: true }, | 93 | drawYZ : {value: false, writable: true }, |
93 | 94 | ||
94 | drawElementN : {value: false, writable: true }, | 95 | drawElementN : {value: false, writable: true }, |
95 | 96 | ||
96 | _selectionCtr : {value: null, writable: true }, | 97 | _selectionCtr : {value: null, writable: true }, |
97 | 98 | ||
98 | // Properties that require element planes to be updated | 99 | // Properties that require element planes to be updated |
99 | _updatePlaneProps : {value: ["matrix", "left", "top", "width", "height"], writable: false }, | 100 | _updatePlaneProps : {value: ["matrix", "left", "top", "width", "height"], writable: false }, |
100 | _recalculateScrollOffsets : { value: false }, | 101 | _recalculateScrollOffsets : { value: false }, |
101 | 102 | ||
102 | /////////////////////////////////////////////////////////////////////// | 103 | /////////////////////////////////////////////////////////////////////// |
103 | // Property accessors | 104 | // Property accessors |
104 | /////////////////////////////////////////////////////////////////////// | 105 | /////////////////////////////////////////////////////////////////////// |
105 | setDrawingSurfaceElement : { value: function( s ) { this._drawingSurfaceElt = s; if (s) this._drawingContext = s.getContext("2d"); }}, | 106 | setDrawingSurfaceElement : { value: function( s ) { this._drawingSurfaceElt = s; if (s) this._drawingContext = s.getContext("2d"); }}, |
106 | getDrawingSurfaceElement : { value: function() { return this._drawingSurfaceElt; }}, | 107 | getDrawingSurfaceElement : { value: function() { return this._drawingSurfaceElt; }}, |
107 | 108 | ||
108 | getDrawingContext : { value: function() { return this._drawingContext; }}, | 109 | getDrawingContext : { value: function() { return this._drawingContext; }}, |
109 | 110 | ||
110 | setSourceSpaceElement : { value: function(ss) { this._sourceSpaceElt = ss; }}, | 111 | setSourceSpaceElement : { value: function(ss) { this._sourceSpaceElt = ss; }}, |
111 | getSourceSpaceElement : { value: function() { return this._sourceSpaceElt; }}, | 112 | getSourceSpaceElement : { value: function() { return this._sourceSpaceElt; }}, |
112 | 113 | ||
113 | getWorkingPlane : { value: function() { return this._workingPlane; }}, | 114 | getWorkingPlane : { value: function() { return this._workingPlane; }}, |
114 | setWorkingPlane : { value: function (wp) { this._workingPlane = wp; }}, | 115 | setWorkingPlane : { value: function (wp) { this._workingPlane = wp; }}, |
115 | 116 | ||
116 | getGridHorizontalSpacing : { value: function() { return this._gridHorizontalSpacing; }}, | 117 | getGridHorizontalSpacing : { value: function() { return this._gridHorizontalSpacing; }}, |
117 | getGridVerticalSpacing : { value: function() { return this._gridVerticalSpacing; }}, | 118 | getGridVerticalSpacing : { value: function() { return this._gridVerticalSpacing; }}, |
118 | getGridHorizontalLineCount : { value: function() { return this._gridHorizontalLineCount; }}, | 119 | getGridHorizontalLineCount : { value: function() { return this._gridHorizontalLineCount; }}, |
119 | getGridVerticalLineCount : { value: function() { return this._gridVerticalLineCount; }}, | 120 | getGridVerticalLineCount : { value: function() { return this._gridVerticalLineCount; }}, |
120 | getGridOrigin : { value: function() { return this._gridOrigin.slice(0); }}, | 121 | getGridOrigin : { value: function() { return this._gridOrigin.slice(0); }}, |
121 | 122 | ||
122 | isDrawingGrid : { value: function() { return this.drawXY || this.drawYZ || this.drawXZ; }}, | 123 | isDrawingGrid : { value: function() { return this.drawXY || this.drawYZ || this.drawXZ; }}, |
123 | isDrawingElementNormal : { value: function() { return this.drawElementN }}, | 124 | isDrawingElementNormal : { value: function() { return this.drawElementN }}, |
124 | 125 | ||
125 | getLineColor : { value: function() { return this._lineColor; }}, | 126 | getLineColor : { value: function() { return this._lineColor; }}, |
126 | setLineColor : { value: function( color ) { this._lineColor = color; }}, | 127 | setLineColor : { value: function( color ) { this._lineColor = color; }}, |
127 | 128 | ||
128 | getLineWidth : { value: function() { return this._drawingContext.lineWidth; }}, | 129 | getLineWidth : { value: function() { return this._drawingContext.lineWidth; }}, |
129 | setLineWidth : { value: function( w ) { this._drawingContext.lineWidth = w; }}, | 130 | setLineWidth : { value: function( w ) { this._drawingContext.lineWidth = w; }}, |
130 | 131 | ||
131 | 132 | ||
132 | initialize: { | 133 | initialize: { |
133 | value: function() { | 134 | value: function() { |
134 | this._gridOrigin = [0,0]; // 2D plane space point | 135 | this._gridOrigin = [0,0]; // 2D plane space point |
135 | 136 | ||
136 | this.eventManager.addEventListener("elementAdded", this, false); | 137 | this.eventManager.addEventListener("elementAdded", this, false); |
137 | this.eventManager.addEventListener("elementsRemoved", this, false); | 138 | this.eventManager.addEventListener("elementsRemoved", this, false); |
138 | this.eventManager.addEventListener("elementChange", this, false); | 139 | this.eventManager.addEventListener("elementChange", this, false); |
139 | this.eventManager.addEventListener("elementChanging", this, false); | 140 | this.eventManager.addEventListener("elementChanging", this, false); |
140 | this.eventManager.addEventListener("elementReplaced", this, false); | 141 | this.eventManager.addEventListener("elementReplaced", this, false); |
141 | } | 142 | } |
142 | }, | 143 | }, |
143 | 144 | ||
144 | initializeFromDocument:{ | 145 | initializeFromDocument:{ |
145 | value:function(adjustScrollOffsets, useStageValues){ | 146 | value:function(adjustScrollOffsets, useStageValues){ |
@@ -364,502 +365,503 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
364 | } | 365 | } |
365 | }, | 366 | }, |
366 | 367 | ||
367 | /////////////////////////////////////////////////////////////////////// | 368 | /////////////////////////////////////////////////////////////////////// |
368 | // Methods | 369 | // Methods |
369 | /////////////////////////////////////////////////// |