aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes
diff options
context:
space:
mode:
authorPushkar Joshi2012-02-28 14:19:25 -0800
committerPushkar Joshi2012-02-28 14:19:25 -0800
commit16d6a90579cdafede931a9c818689fad2e622d8b (patch)
treee87f5d4a131d3574ef06cff1c46373d5b1046956 /js/helper-classes
parent03ca7a5ed13c25faaa9100bb666e062fd15335e6 (diff)
parent63307c9abf120985d979a40a53a0598d3f0d5c5a (diff)
downloadninja-16d6a90579cdafede931a9c818689fad2e622d8b.tar.gz
Merge branch 'pentool' into brushtool
Diffstat (limited to 'js/helper-classes')
-rwxr-xr-xjs/helper-classes/3D/draw-utils.js20
-rwxr-xr-xjs/helper-classes/3D/snap-manager.js4
-rwxr-xr-xjs/helper-classes/3D/view-utils.js8
-rwxr-xr-xjs/helper-classes/RDGE/GLAnchorPoint.js7
-rwxr-xr-xjs/helper-classes/RDGE/GLCircle.js2
-rwxr-xr-xjs/helper-classes/RDGE/GLLine.js2
-rwxr-xr-xjs/helper-classes/RDGE/GLRectangle.js2
-rwxr-xr-xjs/helper-classes/RDGE/GLSubpath.js66
-rwxr-xr-xjs/helper-classes/RDGE/GLWorld.js27
-rwxr-xr-xjs/helper-classes/RDGE/rdge-compiled.js28
-rw-r--r--js/helper-classes/RDGE/runtime/CanvasDataManager.js98
-rw-r--r--js/helper-classes/RDGE/runtime/GLRuntime.js159
-rw-r--r--js/helper-classes/RDGE/src/tools/rdge-compiled.js28
13 files changed, 395 insertions, 56 deletions
diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js
index c07391db..85870097 100755
--- a/js/helper-classes/3D/draw-utils.js
+++ b/js/helper-classes/3D/draw-utils.js
@@ -115,6 +115,26 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
115 } 115 }
116 }, 116 },
117 117
118 initializeFromDocument:{
119 value:function(){
120 var documentRootChildren = null, i;
121 //initialize with current document
122 this._eltArray = [];
123 this._planesArray = [];
124 this.setDrawingSurfaceElement(this.application.ninja.stage.canvas);
125 this.setSourceSpaceElement( this.application.ninja.stage.stageDeps.currentStage );
126 this.setWorkingPlane( Vector.create( [0,0,1,0] ) );
127
128 //Loop through all the top-level children of the current document and call drawUtils.addElement on them
129 if(this.application.ninja.currentDocument._liveNodeList.length > 0){
130 documentRootChildren = this.application.ninja.currentDocument._liveNodeList;
131 for(i=0;i<documentRootChildren.length;i++){
132 this.addElement(documentRootChildren[i]);
133 }
134 }
135 }
136 },
137
118 handleElementAdded: { 138 handleElementAdded: {
119 value: function(event) { 139 value: function(event) {
120 this.addElement(event.detail); 140 this.addElement(event.detail);
diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js
index ada6960b..94202dc5 100755
--- a/js/helper-classes/3D/snap-manager.js
+++ b/js/helper-classes/3D/snap-manager.js
@@ -521,7 +521,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
521 521
522 if (!elt.elementModel) 522 if (!elt.elementModel)
523 { 523 {
524 NJUtils.makeElementModel2(elt); 524 NJUtils.makeModelFromElement(elt);
525 } 525 }
526 elt.elementModel.isIn2DSnapCache = true; 526 elt.elementModel.isIn2DSnapCache = true;
527 } 527 }
@@ -588,7 +588,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
588 588
589 if (!elt.elementModel) 589 if (!elt.elementModel)
590 { 590 {
591 NJUtils.makeElementModel2(elt); 591 NJUtils.makeModelFromElement(elt);
592 } 592 }
593 elt.elementModel.isIn2DSnapCache = true; 593 elt.elementModel.isIn2DSnapCache = true;
594 } 594 }
diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js
index a2fac34f..bedda8bf 100755
--- a/js/helper-classes/3D/view-utils.js
+++ b/js/helper-classes/3D/view-utils.js
@@ -1226,6 +1226,14 @@ exports.ViewUtils = Montage.create(Component, {
1226 } 1226 }
1227 }, 1227 },
1228 1228
1229 getCurrentDocument:
1230 {
1231 value: function()
1232 {
1233 return snapManagerModule.SnapManager.application.ninja.currentDocument;
1234 }
1235 },
1236
1229 setStageZoom: { 1237 setStageZoom: {
1230 value:function( globalPt, zoomFactor ) { 1238 value:function( globalPt, zoomFactor ) {
1231 var localPt; 1239 var localPt;
diff --git a/js/helper-classes/RDGE/GLAnchorPoint.js b/js/helper-classes/RDGE/GLAnchorPoint.js
index 716f59d4..c3e95b34 100755
--- a/js/helper-classes/RDGE/GLAnchorPoint.js
+++ b/js/helper-classes/RDGE/GLAnchorPoint.js
@@ -133,6 +133,13 @@ GLAnchorPoint.prototype.translateAll = function (x, y, z) {
133} 133}
134 134
135 135
136GLAnchorPoint.prototype.scaleAll = function(sx,sy,sz){
137 this._x *= sx;this._prevX *= sx;this._nextX *= sx;
138 this._y *= sy;this._prevY *= sy;this._nextY *= sy;
139 this._z *= sz;this._prevZ *= sz;this._nextZ *= sz;
140}
141
142
136// ********* getters ********** 143// ********* getters **********
137GLAnchorPoint.prototype.getPosX = function () { return this._x; } 144GLAnchorPoint.prototype.getPosX = function () { return this._x; }
138GLAnchorPoint.prototype.getPosY = function () { return this._y; } 145GLAnchorPoint.prototype.getPosY = function () { return this._y; }
diff --git a/js/helper-classes/RDGE/GLCircle.js b/js/helper-classes/RDGE/GLCircle.js
index 5b32547e..712544c0 100755
--- a/js/helper-classes/RDGE/GLCircle.js
+++ b/js/helper-classes/RDGE/GLCircle.js
@@ -135,7 +135,7 @@ function GLCircle()
135 if (!world._useWebGL) return; 135 if (!world._useWebGL) return;
136 136
137 // make sure RDGE has the correct context 137 // make sure RDGE has the correct context
138 g_Engine.setContext( world.getCanvas().uuid ); 138 g_Engine.setContext( world.getCanvas().rdgeid );
139 139
140 // create the gl buffer 140 // create the gl buffer
141 var gl = world.getGLContext(); 141 var gl = world.getGLContext();
diff --git a/js/helper-classes/RDGE/GLLine.js b/js/helper-classes/RDGE/GLLine.js
index 0d815145..f715a43c 100755
--- a/js/helper-classes/RDGE/GLLine.js
+++ b/js/helper-classes/RDGE/GLLine.js
@@ -171,7 +171,7 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro
171 if (!world._useWebGL) return; 171 if (!world._useWebGL) return;
172 172
173 // make sure RDGE has the correct context 173 // make sure RDGE has the correct context
174 g_Engine.setContext( world.getCanvas().uuid ); 174 g_Engine.setContext( world.getCanvas().rdgeid );
175 175
176 // create the gl buffer 176 // create the gl buffer
177 var gl = world.getGLContext(); 177 var gl = world.getGLContext();
diff --git a/js/helper-classes/RDGE/GLRectangle.js b/js/helper-classes/RDGE/GLRectangle.js
index 5b6ff94f..3c1cb7dc 100755
--- a/js/helper-classes/RDGE/GLRectangle.js
+++ b/js/helper-classes/RDGE/GLRectangle.js
@@ -214,7 +214,7 @@ function GLRectangle()
214 if (!world._useWebGL) return; 214 if (!world._useWebGL) return;
215 215
216 // make sure RDGE has the correct context 216 // make sure RDGE has the correct context
217 g_Engine.setContext( world.getCanvas().uuid ); 217 g_Engine.setContext( world.getCanvas().rdgeid );
218 218
219 // create the gl buffer 219 // create the gl buffer
220 var gl = world.getGLContext(); 220 var gl = world.getGLContext();
diff --git a/js/helper-classes/RDGE/GLSubpath.js b/js/helper-classes/RDGE/GLSubpath.js
index 3200cf59..f3d8ad36 100755
--- a/js/helper-classes/RDGE/GLSubpath.js
+++ b/js/helper-classes/RDGE/GLSubpath.js
@@ -178,6 +178,67 @@ function GLSubpath() {
178 } //render() 178 } //render()
179 179
180 this.geomType = function () { return this.GEOM_TYPE_CUBIC_BEZIER; } 180 this.geomType = function () { return this.GEOM_TYPE_CUBIC_BEZIER; }
181
182
183 this.setWidth = function (newW) {
184 if (newW<1)
185 newW=1; //clamp minimum width to 1
186 //scale the contents of this subpath to lie within this width
187 //determine the scale factor by comparing with the old width
188 var oldWidth = this._BBoxMax[0]-this._BBoxMin[0];
189 if (oldWidth<1){
190 oldWidth=1;
191 }
192 var scaleX = newW/oldWidth;
193 if (scaleX===1){
194 return; //no need to do anything
195 }
196
197 //scale the anchor point positions such that the width of the bbox is the newW
198 var origX = this._BBoxMin[0];
199 var numAnchors = this._Anchors.length;
200 for (var i=0;i<numAnchors;i++){
201 //compute the distance from the bboxMin
202 var oldW = this._Anchors[i].getPosX() - origX;
203 var prevW = this._Anchors[i].getPrevX() - origX;
204 var nextW = this._Anchors[i].getNextX() - origX;
205
206 this._Anchors[i].setPos(origX + oldW*scaleX,this._Anchors[i].getPosY(),this._Anchors[i].getPosZ());
207 this._Anchors[i].setPrevPos(origX + prevW*scaleX,this._Anchors[i].getPrevY(),this._Anchors[i].getPrevZ());
208 this._Anchors[i].setNextPos(origX + nextW*scaleX,this._Anchors[i].getNextY(),this._Anchors[i].getNextZ());
209 }
210 this.makeDirty();
211 }
212 this.setHeight = function (newH) {
213 if (newH<1)
214 newH=1; //clamp minimum width to 1
215 //scale the contents of this subpath to lie within this height
216 //determine the scale factor by comparing with the old height
217 var oldHeight = this._BBoxMax[1]-this._BBoxMin[1];
218 if (oldHeight<1){
219 oldHeight=1;
220 }
221 var scaleY = newH/oldHeight;
222 if (scaleY===1){
223 return; //no need to do anything
224 }
225
226 //scale the anchor point positions such that the height of the bbox is the newH
227 var origY = this._BBoxMin[1];
228 var numAnchors = this._Anchors.length;
229 for (var i=0;i<numAnchors;i++){
230 //compute the distance from the bboxMin
231 var oldW = this._Anchors[i].getPosY() - origY;
232 var prevW = this._Anchors[i].getPrevY() - origY;
233 var nextW = this._Anchors[i].getNextY() - origY;
234
235 this._Anchors[i].setPos(this._Anchors[i].getPosX(), origY + oldW*scaleY,this._Anchors[i].getPosZ());
236 this._Anchors[i].setPrevPos(this._Anchors[i].getPrevX(), origY + prevW*scaleY,this._Anchors[i].getPrevZ());
237 this._Anchors[i].setNextPos(this._Anchors[i].getNextX(), origY + nextW*scaleY,this._Anchors[i].getNextZ());
238 }
239<