Beispiel #1
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Format.Length != 0)
            {
                hash ^= Format.GetHashCode();
            }
            if (NullFormat.Length != 0)
            {
                hash ^= NullFormat.GetHashCode();
            }
            if (Halign != global::FactSet.Protobuf.Stach.Table.HorizontalAlignment.UnknownHalign)
            {
                hash ^= Halign.GetHashCode();
            }
            if (Valign != global::FactSet.Protobuf.Stach.Table.VerticalAlignment.UnknownValign)
            {
                hash ^= Valign.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Beispiel #2
0
 ContentAlignment halign(Halign f)
 {
     if (f == Halign.m_left)   return ContentAlignment.MiddleLeft;
       if (f == Halign.m_center) return ContentAlignment.MiddleCenter;
       if (f == Halign.m_right)  return ContentAlignment.MiddleRight;
       throw new System.InvalidOperationException();
 }
Beispiel #3
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);
            }
        }
Beispiel #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);
        }
Beispiel #5
0
 ContentAlignment halign(Halign f)
 {
     if (f == Halign.m_left)
     {
         return(ContentAlignment.MiddleLeft);
     }
     if (f == Halign.m_center)
     {
         return(ContentAlignment.MiddleCenter);
     }
     if (f == Halign.m_right)
     {
         return(ContentAlignment.MiddleRight);
     }
     throw new System.InvalidOperationException();
 }
Beispiel #6
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);
            }
        }
Beispiel #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);
        }
Beispiel #8
0
        private BillBoardSize printString(string s, Halign halign, Valign valign)
        {
            char[] acodes = s.ToCharArray();
            int    nchar  = s.Length;
            float  xorig  = 0;
            float  yorig  = 2;
            float  xmove  = charWidth + charOffset;
            float  ymove  = 0;

            // Compute horizontal alignment
            switch (halign)
            {
            case Align.Halign.RIGHT:
                xorig = xorig;
                break;

            case Align.Halign.CENTER:
                xorig = nchar * xmove / 2;
                break;

            case Align.Halign.LEFT:
                xorig = nchar * xmove;
                break;

            default:
                throw new Exception("Horizontal alignement constant unknown: " + halign);
            }
            // Compute vertical alignment
            switch (valign)
            {
            case Align.Valign.TOP:
                yorig = 0;
                break;

            case Align.Valign.GROUND:
                yorig = yorig;
                break;

            case Align.Valign.CENTER:
                yorig = charHeight / 2;
                break;

            case Align.Valign.BOTTOM:
                yorig = charHeight;
                break;

            default:
                throw new Exception("Vertical alignement constant unknown: " + valign);
            }
            // Draw the bitmaps
            GL.PixelStore(PixelStoreParameter.UnpackAlignment, 1);
            int idx = 0;

            for (int c = 0; c <= acodes.Length - 1; c++)
            {
                idx = (int)(acodes[c]) - 32;
                if (idx < 0 | idx >= ascii.Length)
                {
                    GL.Bitmap(charWidth, charHeight, xorig, yorig, xmove, ymove, nonascii);
                }
                else
                {
                    GL.Bitmap(charWidth, charHeight, xorig, yorig, xmove, ymove, ascii[idx]);
                }
            }
            return(new BillBoardSize(xmove * nchar, charHeight, -xorig, -yorig));
        }