From 44669fc4401eeb8a211b7485d2c20015fc6c477e Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 13 Mar 2012 15:22:57 -0700 Subject: Fixed drawing of multiple selection bounds when in flat case. Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/3D/draw-utils.js | 136 +++++++++++-------------------------- 1 file changed, 39 insertions(+), 97 deletions(-) (limited to 'js/helper-classes') diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index 59da411f..1c00f7ea 100755 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js @@ -721,8 +721,17 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { drawSelectionBounds : { value: function( eltArray ) { this._selectionCtr = null; + var len = eltArray.length, + i, + j, + bounds, + bounds3D, + pt, + tmpPt, + ssMat, + elt; - if (eltArray.length == 0) return; + if (len === 0) return; var context = this._drawingContext; if (!context) return; @@ -731,18 +740,19 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { context.lineWidth = 2; // handle the single element case - if (eltArray.length == 1) + // TODO - Currently, the stage draws its own selection bounds for single selection case + if (len === 1) { // single selection case //console.log( "single selection" ); - var elt = eltArray[0]; + elt = eltArray[0]; this.viewUtils.pushViewportObj( elt ); // get the element bounds in world space - var bounds3D = this.viewUtils.getElementViewBounds3D( elt ); - for (var j=0; j<4; j++) { + bounds3D = this.viewUtils.getElementViewBounds3D( elt ); + for (j=0; j<4; j++) { bounds3D[j] = this.viewUtils.localToGlobal( bounds3D[j], elt ); } @@ -766,19 +776,12 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { } else { - // the multiple selection case. - //console.log( "multiple selection" ); - - // we set the root to "the world". - var saveRoot = this.viewUtils.getRootElement(); - this.viewUtils.setRootElement( this.viewUtils.getStageElement() ); - // get the plane from the first element to compare against the other elements var flat = true; var plane = this.viewUtils.getElementPlane( eltArray[0] ); - for (var i=1; i 0) || (right > 0)) ? dark : light; context.beginPath(); if ((front > 0) || (right > 0)) { context.beginPath(); -// p = this.viewUtils.localToGlobal( [x1, y0, z1], this._sourceSpaceElt ); context.moveTo( p[0], p[1] ); -// p = this.viewUtils.localToGlobal( [x1, y1, z1], this._sourceSpaceElt ); context.lineTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x1, y0, z1], ssMat ); context.moveTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x1, y1, z1], ssMat ); context.lineTo( p[0], p[1] ); context.closePath(); context.stroke(); @@ -973,8 +937,6 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { //context.strokeStyle = ((right > 0) || (back > 0)) ? dark : light; context.beginPath(); if ((right > 0) || (back > 0)) { context.beginPath(); -// p = this.viewUtils.localToGlobal( [x1, y0, z0], this._sourceSpaceElt ); context.moveTo( p[0], p[1] ); -// p = this.viewUtils.localToGlobal( [x1, y1, z0], this._sourceSpaceElt ); context.lineTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x1, y0, z0], ssMat ); context.moveTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x1, y1, z0], ssMat ); context.lineTo( p[0], p[1] ); context.closePath(); context.stroke(); @@ -983,8 +945,6 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { //context.strokeStyle = ((back > 0) || (left > 0)) ? dark : light; context.beginPath(); if ((back > 0) || (left > 0)) { context.beginPath(); -// p = this.viewUtils.localToGlobal( [x0, y0, z0], this._sourceSpaceElt ); context.moveTo( p[0], p[1] ); -// p = this.viewUtils.localToGlobal( [x0, y1, z0], this._sourceSpaceElt ); context.lineTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x0, y0, z0], ssMat ); context.moveTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x0, y1, z0], ssMat ); context.lineTo( p[0], p[1] ); context.closePath(); context.stroke(); @@ -993,8 +953,6 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { //context.strokeStyle = ((left > 0) || (front > 0)) ? dark : light; context.beginPath(); if ((left > 0) || (front > 0)) { context.beginPath(); -// p = this.viewUtils.localToGlobal( [x0, y0, z1], this._sourceSpaceElt ); context.moveTo( p[0], p[1] ); -// p = this.viewUtils.localToGlobal( [x0, y1, z1], this._sourceSpaceElt ); context.lineTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x0, y0, z1], ssMat ); context.moveTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x0, y1, z1], ssMat ); context.lineTo( p[0], p[1] ); context.closePath(); context.stroke(); @@ -1004,8 +962,6 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { //context.strokeStyle = ((front > 0) || (top > 0)) ? dark : light; context.beginPath(); if ((front > 0) || (top > 0)) { context.beginPath(); -// p = this.viewUtils.localToGlobal( [x0, y0, z1], this._sourceSpaceElt ); context.moveTo( p[0], p[1] ); -// p = this.viewUtils.localToGlobal( [x1, y0, z1], this._sourceSpaceElt ); context.lineTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x0, y0, z1], ssMat ); context.moveTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x1, y0, z1], ssMat ); context.lineTo( p[0], p[1] ); context.closePath(); context.stroke(); @@ -1014,8 +970,6 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { //context.strokeStyle = ((top > 0) || (back > 0)) ? dark : light; context.beginPath(); if ((top > 0) || (back > 0)) { context.beginPath(); -// p = this.viewUtils.localToGlobal( [x0, y0, z0], this._sourceSpaceElt ); context.moveTo( p[0], p[1] ); -// p = this.viewUtils.localToGlobal( [x1, y0, z0], this._sourceSpaceElt ); context.lineTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x0, y0, z0], ssMat ); context.moveTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x1, y0, z0], ssMat ); context.lineTo( p[0], p[1] ); context.closePath(); context.stroke(); @@ -1024,8 +978,6 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { //context.strokeStyle = ((back > 0) || (bottom > 0)) ? dark : light; context.beginPath(); if ((back > 0) || (bottom > 0)) { context.beginPath(); -// p = this.viewUtils.localToGlobal( [x0, y1, z0], this._sourceSpaceElt ); context.moveTo( p[0], p[1] ); -// p = this.viewUtils.localToGlobal( [x1, y1, z0], this._sourceSpaceElt ); context.lineTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x0, y1, z0], ssMat ); context.moveTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x1, y1, z0], ssMat ); context.lineTo( p[0], p[1] ); context.closePath(); context.stroke(); @@ -1034,8 +986,6 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { //context.strokeStyle = ((bottom > 0) || (front > 0)) ? dark : light; context.beginPath(); if ((bottom > 0) || (front > 0)) { context.beginPath(); -// p = this.viewUtils.localToGlobal( [x0, y1, z1], this._sourceSpaceElt ); context.moveTo( p[0], p[1] ); -// p = this.viewUtils.localToGlobal( [x1, y1, z1], this._sourceSpaceElt ); context.lineTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x0, y1, z1], ssMat ); context.moveTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x1, y1, z1], ssMat ); context.lineTo( p[0], p[1] ); context.closePath(); context.stroke(); @@ -1044,8 +994,6 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { // and the remaining lines - varying Z if ((top > 0) || (right > 0)) { context.beginPath(); -// p = this.viewUtils.localToGlobal( [x1, y0, z0], this._sourceSpaceElt ); context.moveTo( p[0], p[1] ); -// p = this.viewUtils.localToGlobal( [x1, y0, z1], this._sourceSpaceElt ); context.lineTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x1, y0, z0], ssMat ); context.moveTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x1, y0, z1], ssMat ); context.lineTo( p[0], p[1] ); context.closePath(); context.stroke(); @@ -1054,8 +1002,6 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { //context.strokeStyle = ((right > 0) || (bottom > 0)) ? dark : light; context.beginPath(); if ((right > 0) || (bottom > 0)) { context.beginPath(); -// p = this.viewUtils.localToGlobal( [x1, y1, z0], this._sourceSpaceElt ); context.moveTo( p[0], p[1] ); -// p = this.viewUtils.localToGlobal( [x1, y1, z1], this._sourceSpaceElt ); context.lineTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x1, y1, z0], ssMat ); context.moveTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x1, y1, z1], ssMat ); context.lineTo( p[0], p[1] ); context.closePath(); context.stroke(); @@ -1064,8 +1010,6 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { //context.strokeStyle = ((bottom > 0) || (left > 0)) ? dark : light; context.beginPath(); if ((bottom > 0) || (left > 0)) { context.beginPath(); -// p = this.viewUtils.localToGlobal( [x0, y1, z0], this._sourceSpaceElt ); context.moveTo( p[0], p[1] ); -// p = this.viewUtils.localToGlobal( [x0, y1, z1], this._sourceSpaceElt ); context.lineTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x0, y1, z0], ssMat ); context.moveTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x0, y1, z1], ssMat ); context.lineTo( p[0], p[1] ); context.closePath(); context.stroke(); @@ -1074,8 +1018,6 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { //context.strokeStyle = ((left > 0) || (top > 0)) ? dark : light; context.beginPath(); if ((left > 0) || (top > 0)) { context.beginPath(); -// p = this.viewUtils.localToGlobal( [x0, y0, z0], this._sourceSpaceElt ); context.moveTo( p[0], p[1] ); -// p = this.viewUtils.localToGlobal( [x0, y0, z1], this._sourceSpaceElt ); context.lineTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x0, y0, z0], ssMat ); context.moveTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x0, y0, z1], ssMat ); context.lineTo( p[0], p[1] ); context.closePath(); context.stroke(); -- cgit v1.2.3