Esempio n. 1
0
        public Valign layoutVertical(AxeDirection direction, Valign val, float zdir)
        {
            Valign vAlign;

            if (val == null || val == Valign.DEFAULT)
            {
                if (direction == AxeDirection.AxeZ)
                {
                    vAlign = Valign.CENTER;
                }
                else
                {
                    if (zdir > 0)
                    {
                        vAlign = Valign.TOP;
                    }
                    else
                    {
                        vAlign = Valign.BOTTOM;
                    }
                }
            }
            else
            {
                vAlign = val;
            }
            return(vAlign);
        }
Esempio n. 2
0
        public void drawAxisTicks(Camera cam, AxeDirection direction, Color color, Halign hal, Valign val, float tickLength, BoundingBox3d ticksTxtBounds, float xpos,
                                  float ypos, float zpos, float xdir, float ydir, float zdir, float[] ticks)
        {
            double xlab;
            double ylab;
            double zlab;
            String tickLabel = "";

            for (int t = 0; t < ticks.Length; t++)
            {
                // Shift the tick vector along the selected axis
                // and set the tick length
                switch (direction)
                {
                case AxeDirection.AxeX:
                    xpos      = ticks[t];
                    xlab      = xpos;
                    ylab      = (_yrange / tickLength) * ydir + ypos;
                    zlab      = (_zrange / tickLength) * zdir + zpos;
                    tickLabel = _layout.XTickRenderer.Format(xpos);
                    break;

                case AxeDirection.AxeY:
                    ypos      = ticks[t];
                    xlab      = (_xrange / tickLength) * xdir + xpos;
                    ylab      = ypos;
                    zlab      = (_zrange / tickLength) * zdir + zpos;
                    tickLabel = _layout.YTickRenderer.Format(ypos);
                    break;

                case AxeDirection.AxeZ:
                    zpos      = ticks[t];
                    xlab      = (_xrange / tickLength) * xdir + xpos;
                    ylab      = (_yrange / tickLength) * ydir + ypos;
                    zlab      = zpos;
                    tickLabel = _layout.ZTickRenderer.Format(zpos);
                    break;

                default:
                    throw new Exception("Unsupported axe direction");
                }
                Coord3d tickPosition = new Coord3d(xlab, ylab, zlab);

                if (_layout.TickLineDisplayed)
                {
                    drawTickLine(color, xpos, ypos, zpos, xlab, ylab, zlab);
                }

                // Select the alignement of the tick label
                Halign hAlign = layoutHorizontal(direction, cam, hal, tickPosition);
                Valign vAlign = layoutVertical(direction, val, zdir);

                // Draw the text label of the current tick
                drawAxisTickNumericLabel(direction, cam, color, hAlign, vAlign, ticksTxtBounds, tickLabel, tickPosition);
            }
        }
Esempio n. 3
0
        public void drawAxisTickNumericLabel(AxeDirection direction, Camera cam, Color color, Halign hAlign, Valign vAlign, BoundingBox3d ticksTxtBounds, String tickLabel,
                                             Coord3d tickPosition)
        {
            GL.LoadIdentity();
            GL.Scale(_scale.x, _scale.y, _scale.z);

            BoundingBox3d tickBounds = _txt.drawText(cam, tickLabel, tickPosition, hAlign, vAlign, color);

            if (tickBounds != null)
            {
                ticksTxtBounds.Add(tickBounds);
            }
        }
Esempio n. 4
0
        public Halign layoutHorizontal(AxeDirection direction, Camera cam, Halign hal, Coord3d tickPosition)
        {
            Halign hAlign;

            if (hal == null || hal == Halign.DEFAULT)
            {
                hAlign = cam.side(tickPosition) ? Halign.LEFT : Halign.RIGHT;
            }
            else
            {
                hAlign = hal;
            }
            return(hAlign);
        }
Esempio n. 5
0
 public void drawAxisLabel(Camera cam, AxeDirection direction, Color color, BoundingBox3d ticksTxtBounds, double xlab, double ylab, double zlab, String axeLabel)
 {
     if ((direction == AxeDirection.AxeX && _layout.XAxeLabelDisplayed) ||
         (direction == AxeDirection.AxeY && _layout.YAxeLabelDisplayed) ||
         (direction == AxeDirection.AxeZ && _layout.ZAxeLabelDisplayed))
     {
         Coord3d       labelPosition = new Coord3d(xlab, ylab, zlab);
         BoundingBox3d labelBounds   = _txt.drawText(cam, axeLabel, labelPosition, Halign.CENTER, Valign.CENTER, color);
         if (labelBounds != null)
         {
             ticksTxtBounds.Add(labelBounds);
         }
     }
 }
Esempio n. 6
0
        public float[] getAxisTicks(AxeDirection direction)
        {
            float[] ticks;
            switch (direction)
            {
            case AxeDirection.AxeX:
                ticks = _layout.XTicks();
                break;

            case AxeDirection.AxeY:
                ticks = _layout.YTicks();
                break;

            case AxeDirection.AxeZ:
                ticks = _layout.ZTicks();
                break;

            default:
                throw new Exception("Unsupported axe direction");
            }
            return(ticks);
        }
Esempio n. 7
0
        internal BoundingBox3d drawTicks(Camera cam, int axis, AxeDirection direction, Color color, Halign hal, Valign val)
        {
            int           quad_0         = 0;
            int           quad_1         = 0;
            float         tickLength     = 20.0f; // with respect to range
            float         axeLabelDist   = 2.5f;
            BoundingBox3d ticksTxtBounds = new BoundingBox3d();

            // Retrieve the quads that intersect and create the selected axe
            switch (direction)
            {
            case AxeDirection.AxeX:
                quad_0 = _axeXquads[axis, 0];
                quad_1 = _axeXquads[axis, 1];
                break;

            case AxeDirection.AxeY:
                quad_0 = _axeYquads[axis, 0];
                quad_1 = _axeYquads[axis, 1];
                break;

            case AxeDirection.AxeZ:
                quad_0 = _axeZquads[axis, 0];
                quad_1 = _axeZquads[axis, 1];
                break;

            default:
                throw new Exception("Unsupported axe direction");
            }

            // Computes PoSition of ticks lying on the selected axe
            // (i.e. 1st point of the tick line)
            float xpos = _normx[quad_0] + _normx[quad_1];
            float ypos = _normy[quad_0] + _normy[quad_1];
            float zpos = _normz[quad_0] + _normz[quad_1];

            // Computes the DIRection of the ticks
            // assuming initial vector point is the center
            float xdir = (float)((_normx[quad_0] + _normx[quad_1]) - _center.x);
            float ydir = (float)((_normy[quad_0] + _normy[quad_1]) - _center.y);
            float zdir = (float)((_normz[quad_0] + _normz[quad_1]) - _center.z);

            xdir = (xdir == 0 ? 0 : xdir / Math.Abs(xdir));             // so that direction as length 1
            ydir = (ydir == 0 ? 0 : ydir / Math.Abs(ydir));
            zdir = (zdir == 0 ? 0 : zdir / Math.Abs(zdir));


            // Variables for storing the position of the Label position
            // (2nd point on the tick line)
            float xlab = 0;
            float ylab = 0;
            float zlab = 0;

            // Draw the label for axis
            string axeLabel = null;
            int    dist     = 1;

            switch (direction)
            {
            case AxeDirection.AxeX:
                xlab     = (float)_center.x;
                ylab     = axeLabelDist * (_yrange / tickLength) * dist * ydir + ypos;
                zlab     = axeLabelDist * (_zrange / tickLength) * dist * zdir + zpos;
                axeLabel = _layout.XAxeLabel;
                break;

            case AxeDirection.AxeY:
                xlab     = axeLabelDist * (_xrange / tickLength) * dist * xdir + xpos;
                ylab     = (float)_center.y;
                zlab     = axeLabelDist * (_zrange / tickLength) * dist * zdir + zpos;
                axeLabel = _layout.YAxeLabel;
                break;

            case AxeDirection.AxeZ:
                xlab     = axeLabelDist * (_xrange / tickLength) * dist * xdir + xpos;
                ylab     = axeLabelDist * (_yrange / tickLength) * dist * ydir + ypos;
                zlab     = (float)_center.z;
                axeLabel = _layout.ZAxeLabel;
                break;

            default:
                throw new Exception("Unsupported axe direction");
            }

            drawAxisLabel(cam, direction, color, ticksTxtBounds, xlab, ylab, zlab, axeLabel);
            drawAxisTicks(cam, direction, color, hal, val, tickLength, ticksTxtBounds, xpos, ypos, zpos, xdir, ydir, zdir, getAxisTicks(direction));
            return(ticksTxtBounds);
        }
Esempio n. 8
0
 internal BoundingBox3d drawTicks(Camera cam, int axis, AxeDirection direction, Color color)
 {
     return(drawTicks(cam, axis, direction, color, Halign.DEFAULT, Valign.DEFAULT));
 }