function _BoundingBoxDraw( ) {
var frontOrBack = ( ( this.Parent.Fi < 90 ) || ( this.Parent.Fi >= 270 ) );
var leftOrRight = ( this.Parent.Fi >= 180 );
var topOrBottom = ( this.Parent.Th <= 0 );
drawFace( this, 'z', 'x', 'y', 0, 0, 1, topOrBottom, frontOrBack, leftOrRight );
drawFace( this, 'y', 'x', 'z', 1, 2, 3, leftOrRight, frontOrBack, topOrBottom );
drawFace( this, 'x', 'y', 'z', 2, 4, 5, frontOrBack, leftOrRight, topOrBottom );
}
####
function drawFace( me, face, primary, secondary, planeIdx, line1, line2, drawMinFace, cond2, cond3 ) {
// if this face is visible, draw it
if( ( me.Min[primary] < me.Max[primary] ) && ( me.Min[secondary] < me.Max[secondary] ) ) {
var world3D = new Vector( 0,0,0 );
world3D[face] = drawMinFace ? me.Min[face] : me.Max[face];
world3D[primary] = me.Min[primary];
world3D[secondary] = me.Min[secondary];
var screen2D = me.Parent.ScreenPos( world3D );
// calculate and construct Bbox rectangle path
ss = "M " + screen2D.x + " " + screen2D.y + " "; // move to corner 1
world3D[primary] = me.Max[primary];
screen2D = me.Parent.ScreenPos( world3D );
ss += "L " + screen2D.x + " " + screen2D.y + " "; // line to corner 2
world3D[secondary] = me.Max[secondary];
screen2D = me.Parent.ScreenPos( world3D );
ss += "L " + screen2D.x + " " + screen2D.y + " "; // line to corner 3
world3D[primary] = me.Min[primary];
screen2D = me.Parent.ScreenPos( world3D );
ss += "L " + screen2D.x + " " + screen2D.y + " z"; // line to corner 4 and close back to corner 1
me.Plane[planeIdx].setAttribute( "d", ss ); // [d]efine the path for this panes Bbox
world3D[face] = 1; world3D[primary] = 0; world3D[secondary] = 0;
// and set its attributes
me.Plane[planeIdx].setAttribute( "fill", me.Parent.GetColor( me.FillColor, me.FillColor, world3D, drawMinFace ? me.Min : me.Max ) );
me.Plane[planeIdx].setAttribute( "stroke", me.StrokeColor );
me.Plane[planeIdx].setAttribute( "stroke-width", me.StrokeWeight );
me.Plane[planeIdx].setAttribute( "visibility", "visible" );
world3D[face] = drawMinFace ? me.Min[face] : me.Max[face];
// Draw the horizontal and vertical grid lines on this Bbox face
drawGrid( me, face, primary, secondary, line1, cond3, cond2, world3D ); // horizontal
drawGrid( me, face, secondary, primary, line2, cond2, cond3, world3D ); // vertical
}
else { // else hide it.
me.Plane[planeIdx].setAttribute( "visibility", "hidden" );
for( var ii = 0; ii < 11; ii++ ) me.Line[line1][ii].setAttribute( "visibility", "hidden" );
for( var ii = 0; ii < 11; ii++ ) me.Line[line2][ii].setAttribute( "visibility", "hidden" );
}
}
####
function drawGrid( me, plane, primary, secondary, idx, cond1, cond2, pp ) {
var ii = 0, uu = 0;
var grid = _GetGrid( me.Min[primary] / me.Parent.Zoom[primary], me.Max[primary] / me.Parent.Zoom[primary], me.Scale[primary] );
if( me.GridDelta[primary] != 0 ) grid.step = me.GridDelta[primary];
for( var jj = grid.max; jj >= grid.min; jj -= grid.step ) {
pp[primary] = jj * me.Parent.Zoom[primary];
pp[secondary] = me.Min[secondary];
var vv = me.Parent.ScreenPos( pp );
fromOV( me.Line[idx][ii], vv.x, vv.y ); // Move to the start(min) of this gridline
var xx = vv.x, yy = vv.y; // copy of start x/y for later
pp[secondary] = me.Max[secondary];
vv = me.Parent.ScreenPos( pp ); // pp changed; get again
toOV( me.Line[idx][ii], vv.x, vv.y ); // And draw to the other(max) end
me.Line[idx][ii].setAttribute( "stroke", me.StrokeColor ); // Set the color
me.Line[idx][ii].setAttribute( "visibility", "visible" ); // and make visible
if( cond1 ) { // Move the tick labels to the appropriate end of the gridlines; 1.06 standoff of label; uu (fudge facto for zooming (not used)
me.Text[idx][ii].setAttribute( "x", Math.floor( xx + ( vv.x - xx ) * 1.06 ) - 50 * uu );
me.Text[idx][ii].setAttribute( "y", Math.floor( yy + ( vv.y - yy ) * 1.06 ) - 7 * uu );
}
else {
me.Text[idx][ii].setAttribute( "x", Math.floor( vv.x + ( xx - vv.x ) * 1.06 ) - 50 * uu );
me.Text[idx][ii].setAttribute( "y", Math.floor( vv.y + ( yy - vv.y ) * 1.06 ) - 7 * uu );
}
me.Text[idx][ii].setAttribute( "fill", me.StrokeColor );
me.Text[idx][ii].setAttribute( "visibility", "visible" );
if( ( ii == 1 ) && ( me.Label[primary] ) ) // if 1st (not zeroth?) gridline, add the axis label
innerTextOV( me.Text[idx][ii], me.Label[primary] );
else { // otherwise add the tick value
if( isNaN( me.Scale[primary] ) ) {
if( me.Scale[primary].substr( 0,9 ) == "function " ) {
ff = eval( "window." + me.Scale[primary].substr( 9 ) );
if( ff ) innerTextOV( me.Text[idx][ii], ff( _ScaleString( jj, grid.step ) ) );
}
else innerTextOV( me.Text[idx][ii], _ScaleString( jj, grid.step ) + me.Scale[primary] );
}
else {
if( me.Scale[primary] < 1 ) innerTextOV( me.Text[idx][ii], "" );
if( me.Scale[primary] == 1 ) innerTextOV( me.Text[idx][ii], _ScaleString( jj, grid.step ) );
if( me.Scale[primary] > 1 ) innerTextOV( me.Text[idx][ii], _DateFormat( jj, grid.step, me.Scale[primary] ) );
}
}
ii++;
}
if( me.Min[primary] < me.Max[primary] ) {
if( cond2 ) {
if( me.Min[primary] / me.Parent.Zoom[primary] > grid.min - grid.step / 3 ) innerTextOV( me.Text[idx][ii-1], "" );
}
else {
if( me.Max[primary] / me.Parent.Zoom[primary] < grid.max + grid.step / 3 ) innerTextOV( me.Text[idx][0], "" );
}
}
while( ii < 11 ) { // If we needed less than 10 grid lines, hide the rest.
me.Line[idx][ii].setAttribute( "visibility", "hidden" );
me.Text[idx][ii].setAttribute( "visibility", "hidden" );
ii++;
}
}