aboutsummaryrefslogtreecommitdiff
path: root/js/tools
diff options
context:
space:
mode:
authorNivesh Rajbhandari2012-04-18 13:42:18 -0700
committerNivesh Rajbhandari2012-04-18 13:42:18 -0700
commit7b3ef287f248c07602aefa3ba2cc907e0d16493a (patch)
treefb098120c06002204b1c6edbfea1a0f4aeb45ac0 /js/tools
parentfb20a74856a8c272d09d106765eb2e44c883f0c3 (diff)
downloadninja-7b3ef287f248c07602aefa3ba2cc907e0d16493a.tar.gz
Fixing some more merge issues.
Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com>
Diffstat (limited to 'js/tools')
-rwxr-xr-xjs/tools/Rotate3DToolBase.js31
-rwxr-xr-xjs/tools/RotateObject3DTool.js11
-rwxr-xr-xjs/tools/Translate3DToolBase.js21
3 files changed, 36 insertions, 27 deletions
diff --git a/js/tools/Rotate3DToolBase.js b/js/tools/Rotate3DToolBase.js
index 6bd92353..04bdc946 100755
--- a/js/tools/Rotate3DToolBase.js
+++ b/js/tools/Rotate3DToolBase.js
@@ -80,6 +80,11 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, {
80 pt0 = data.pt0, 80 pt0 = data.pt0,
81 pt1 = data.pt1; 81 pt1 = data.pt1;
82 82
83 var selectedElements = this.application.ninja.selectedElements;
84 if(this.rotateStage) {
85 selectedElements = [this.application.ninja.currentDocument.documentRoot];
86 }
87
83 if(this._handleMode !== null) 88 if(this._handleMode !== null)
84 { 89 {
85 if(this._activateOriginHandle) 90 if(this._activateOriginHandle)
@@ -94,12 +99,13 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, {
94 var swOrigin = MathUtils.transformAndDivideHomogeneousPoint( this._origin, g2swMat ); 99 var swOrigin = MathUtils.transformAndDivideHomogeneousPoint( this._origin, g2swMat );
95 //console.log( "modifyElements, _origin: " + this._origin + ", in stageWorld: " + swOrigin ); 100 //console.log( "modifyElements, _origin: " + this._origin + ", in stageWorld: " + swOrigin );
96 101
97 var len = this._targets.length; 102 var len = selectedElements.length;
98 if(len === 1) 103 if(len === 1)
99 { 104 {
100 var g2lMat = this._targets[0].g2l; 105 var elt = selectedElements[0];
106 var g2lMat = elt.elementModel.getProperty("g2l");
101 var localOrigin = MathUtils.transformAndDivideHomogeneousPoint( this._origin, g2lMat ); 107 var localOrigin = MathUtils.transformAndDivideHomogeneousPoint( this._origin, g2lMat );
102 var elt = this._targets[0].elt; 108
103 viewUtils.pushViewportObj( elt ); 109 viewUtils.pushViewportObj( elt );
104 var viewOrigin = viewUtils.screenToView( localOrigin[0], localOrigin[1], localOrigin[2] ); 110 var viewOrigin = viewUtils.screenToView( localOrigin[0], localOrigin[1], localOrigin[2] );
105 viewUtils.popViewportObj(); 111 viewUtils.popViewportObj();
@@ -178,7 +184,7 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, {
178 184
179 if(this._inLocalMode && (this.application.ninja.selectedElements.length === 1 || this.rotateStage) ) 185 if(this._inLocalMode && (this.application.ninja.selectedElements.length === 1 || this.rotateStage) )
180 { 186 {
181 console.log( "modifyElements: rotateLocally " ); 187// console.log( "modifyElements: rotateLocally " );
182 this._rotateLocally(mat); 188 this._rotateLocally(mat);
183 } 189 }
184 else 190 else
@@ -245,7 +251,7 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, {
245 var transformCtr = this._startOriginArray[i].slice(0); 251 var transformCtr = this._startOriginArray[i].slice(0);
246 transformCtr = MathUtils.transformPoint(transformCtr, curMat); 252 transformCtr = MathUtils.transformPoint(transformCtr, curMat);
247 253
248 console.log( "modifyElements: rotateGlobally, ctr: " + transformCtr ); 254// console.log( "modifyElements: rotateGlobally, ctr: " + transformCtr );
249 255
250 tMat[12] = transformCtr[0]; 256 tMat[12] = transformCtr[0];
251 tMat[13] = transformCtr[1]; 257 tMat[13] = transformCtr[1];
@@ -366,15 +372,15 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, {
366 self = this; 372 self = this;
367 373
368 this.application.ninja.selectedElements.forEach(function(element) { 374 this.application.ninja.selectedElements.forEach(function(element) {
369 var curMat = viewUtils.getMatrixFromElement(elt); 375 var curMat = viewUtils.getMatrixFromElement(element);
370 var curMatInv = glmat4.inverse(curMat, []); 376 var curMatInv = glmat4.inverse(curMat, []);
371 377
372 viewUtils.pushViewportObj( elt ); 378 viewUtils.pushViewportObj( element );
373 var eltCtr = viewUtils.getCenterOfProjection(); 379 var eltCtr = viewUtils.getCenterOfProjection();
374 viewUtils.popViewportObj(); 380 viewUtils.popViewportObj();
375 381
376 // cache the local to global and global to local matrices 382 // cache the local to global and global to local matrices
377 var l2gMat = viewUtils.getLocalToGlobalMatrix( elt ); 383 var l2gMat = viewUtils.getLocalToGlobalMatrix( element );
378 var g2lMat = glmat4.inverse( l2gMat, [] ); 384 var g2lMat = glmat4.inverse( l2gMat, [] );
379 eltCtr = MathUtils.transformAndDivideHomogeneousPoint( eltCtr, l2gMat ); 385 eltCtr = MathUtils.transformAndDivideHomogeneousPoint( eltCtr, l2gMat );
380 386
@@ -416,11 +422,11 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, {
416 for (i = 0; i < len; i++) 422 for (i = 0; i < len; i++)
417 { 423 {
418 // get the next element and localToGlobal matrix 424 // get the next element and localToGlobal matrix
419 elt = this.application.ninja.selectedElements[i]; 425 var elt = this.application.ninja.selectedElements[i];
420 var l2g = elt.elementModel.getProperty("l2g"); 426 var l2g = elt.elementModel.getProperty("l2g");
421 427
422 // get the element bounds in 'plane' space 428 // get the element bounds in 'plane' space
423 bounds = viewUtils.getElementViewBounds3D( elt ); 429 var bounds = viewUtils.getElementViewBounds3D( elt );
424 for (j=0; j<4; j++) 430 for (j=0; j<4; j++)
425 { 431 {
426 var localPt = bounds[j]; 432 var localPt = bounds[j];
@@ -440,7 +446,7 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, {
440 } 446 }
441 var stageWorldCtr = [ 0.5*(minPt[0] + maxPt[0]), 0.5*(minPt[1] + maxPt[1]), 0.5*(minPt[2] + maxPt[2]) ]; 447 var stageWorldCtr = [ 0.5*(minPt[0] + maxPt[0]), 0.5*(minPt[1] + maxPt[1]), 0.5*(minPt[2] + maxPt[2]) ];
442 var globalCtr = MathUtils.transformAndDivideHomogeneousPoint( stageWorldCtr, viewUtils.getStageWorldToGlobalMatrix() ); 448 var globalCtr = MathUtils.transformAndDivideHomogeneousPoint( stageWorldCtr, viewUtils.getStageWorldToGlobalMatrix() );
443 console.log( "resetting _origin to: " + this._origin ); 449// console.log( "resetting _origin to: " + this._origin );
444 450
445 return globalCtr; 451 return globalCtr;
446 } 452 }
@@ -498,7 +504,8 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, {
498 // Update transform ctr for all elements if transform origin was modified 504 // Update transform ctr for all elements if transform origin was modified
499 if (!this._origin) this._origin = this.calculateMultiSelOrigin(); 505 if (!this._origin) this._origin = this.calculateMultiSelOrigin();
500 var globalCtr = this._origin; 506 var globalCtr = this._origin;
501 for (i=0; i<len; i++) 507 var len = this.application.ninja.selectedElements.length;
508 for (var i=0; i<len; i++)
502 { 509 {
503 // get the next element and localToGlobal matrix 510 // get the next element and localToGlobal matrix
504 elt = this.application.ninja.selectedElements[i]; 511 elt = this.application.ninja.selectedElements[i];
diff --git a/js/tools/RotateObject3DTool.js b/js/tools/RotateObject3DTool.js
index 55c9586b..c1ddb286 100755
--- a/js/tools/RotateObject3DTool.js
+++ b/js/tools/RotateObject3DTool.js
@@ -61,7 +61,12 @@ exports.RotateObject3DTool = Montage.create(Rotate3DToolBase, {
61 initializeSnapping : { 61 initializeSnapping : {
62 value : function(event) 62 value : function(event)
63 { 63 {
64 console.log( "initializeSnapping" ); 64// console.log( "initializeSnapping" );
65
66 var selectedElements = this.application.ninja.selectedElements;
67 if(this.rotateStage) {
68 selectedElements = [this.application.ninja.currentDocument.documentRoot];
69 }
65 70
66 this._mouseDownHitRec = null; 71 this._mouseDownHitRec = null;
67 this._mouseUpHitRec = null; 72 this._mouseUpHitRec = null;
@@ -102,7 +107,7 @@ exports.RotateObject3DTool = Montage.create(Rotate3DToolBase, {
102// } 107// }
103// } 108// }
104 109
105 if (this._targets) 110 if (selectedElements.length)
106 { 111 {
107 var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, 112 var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas,
108 new WebKitPoint(event.pageX, event.pageY)); 113 new WebKitPoint(event.pageX, event.pageY));
@@ -159,7 +164,7 @@ exports.RotateObject3DTool = Montage.create(Rotate3DToolBase, {
159 164
160 if(!this._dragPlane) 165 if(!this._dragPlane)
161 { 166 {
162 if (this._targets.length === 1) 167 if (selectedElements.length === 1)
163 { 168 {
164 this._dragPlane = viewUtils.getUnprojectedElementPlane(this._clickedObject); 169 this._dragPlane = viewUtils.getUnprojectedElementPlane(this._clickedObject);
165 snapManager.setupDragPlaneFromPlane(this._dragPlane); 170 snapManager.setupDragPlaneFromPlane(this._dragPlane);
diff --git a/js/tools/Translate3DToolBase.js b/js/tools/Translate3DToolBase.js
index bf07e89e..f81ce6d6 100755
--- a/js/tools/Translate3DToolBase.js
+++ b/js/tools/Translate3DToolBase.js
@@ -138,11 +138,9 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
138 value: function (transMat) { 138 value: function (transMat) {
139 //console.log( "_translateGlobally, transMat: " + transMat ); 139 //console.log( "_translateGlobally, transMat: " + transMat );
140 var selectedElements = this.application.ninja.selectedElements; 140 var selectedElements = this.application.ninja.selectedElements;
141 if(this.rotateStage) {
142 selectedElements = [this.application.ninja.currentDocument.documentRoot];
143 }
144 141
145 var self = this, 142 var len = selectedElements.length,
143 self = this,
146 target = selectedElements[0], 144 target = selectedElements[0],
147 curMat = viewUtils.getMatrixFromElement( target ), 145 curMat = viewUtils.getMatrixFromElement( target ),
148 matInv = glmat4.inverse(this._startMat, []), 146 matInv = glmat4.inverse(this._startMat, []),
@@ -157,7 +155,7 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
157 155
158 var shouldUpdateStartMat = true; 156 var shouldUpdateStartMat = true;
159 157
160 if(this._clickedOnStage || ((this._handleMode === 2) && (this._targets.length > 1))) 158 if(this._clickedOnStage || ((this._handleMode === 2) && (len > 1)))
161 { 159 {
162 shouldUpdateStartMat = false; 160 shouldUpdateStartMat = false;
163 } 161 }
@@ -166,7 +164,7 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
166 this._startMat = nMat; 164 this._startMat = nMat;
167 } 165 }
168 166
169 this.application.ninja.selectedElements.forEach(function(element) { 167 selectedElements.forEach(function(element) {
170 curMat = element.elementModel.getProperty("mat").slice(0); 168 curMat = element.elementModel.getProperty("mat").slice(0);
171 169
172// glmat4.multiply(curMat, qMat, curMat); 170// glmat4.multiply(curMat, qMat, curMat);
@@ -273,7 +271,6 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
273 captureSelectionDrawn: { 271 captureSelectionDrawn: {
274 value: function(event){ 272 value: function(event){
275 this._origin = null; 273 this._origin = null;
276 this._targe