Example #1
0
 public WidgetMessage(IRenderer Renderer, int FramesToShow, QPen ForePen, QPen BorderPen)
 {
     this.renderer     = Renderer;
     this.framesToShow = FramesToShow;
     this.forePen      = ForePen;
     this.borderPen    = BorderPen;
 }
Example #2
0
 public WidgetData(Controller Controller, IRenderer Renderer, Physics Physics, Camera Camera, QPen TextPen)
 {
     this.controller = Controller;
     this.renderer   = Renderer;
     this.physics    = Physics;
     this.camera     = Camera;
     this.textPen    = TextPen;
 }
Example #3
0
        public void DrawString(string Text, QPoint Location, QPen Pen, QFont Font)
        {
#if WPF
            PendingText.Add(new Tuple <string, QPoint, QPen, QFont, bool>(Text, Location, Pen, Font, false));
#else
            DrawingTarget.DrawString(Text, Font.Font, Pen.Brush, Location.X, Location.Y);
#endif
        }
Example #4
0
 protected Instrument(IRenderer Renderer, InstrumentDataSource DataSource, QPen LinePen, QPen BackPen, QPen TextPen)
 {
     this.renderer   = Renderer;
     this.dataSource = DataSource;
     this.LinePen    = LinePen;
     this.BackPen    = BackPen;
     this.TextPen    = TextPen;
 }
Example #5
0
 public static void SetPixel(this WriteableBitmap bmp, QPen Pen, int x, int y)
 {
     unsafe
     {
         IntPtr buff   = bmp.BackBuffer;
         int *  pixels = (int *)buff.ToPointer();
         pixels[BitmapEx.Width * y + x] = Pen.BGRA;
     }
 }
Example #6
0
        public void DrawStringCentered(string Text, QPoint Location, QPen Pen, QFont Font)
        {
#if WPF
            PendingText.Add(new Tuple <string, QPoint, QPen, QFont, bool>(Text, Location, Pen, Font, true));
#else
            var size = MeasureText(Text, Font);
            DrawingTarget.DrawString(Text, Font.Font, Pen.Brush, Location.X - size.Width / 2, Location.Y - size.Height / 2);
#endif
        }
Example #7
0
        protected Dialog(IRenderer Renderer, QSize ScreenSize, CloseCallback CloseCallback, QPen ForePen, QPen BorderPen, QPen BackPen)
        {
            this.renderer      = Renderer;
            this.screenSize    = ScreenSize;
            this.closeCallback = CloseCallback;
            this.forePen       = ForePen;
            this.borderPen     = BorderPen;
            this.backPen       = BackPen;

            SetupLayout();
        }
Example #8
0
        public void RenderShape(Shape Shape, QPen Pen)
        {
            QPoint p1, p2;

            foreach (var l in Shape.Lines)
            {
                if (projector.Project2DLine(l.P1, l.P2, out p1, out p2))
                {
                    DrawingTarget.DrawLine(Pen, p1, p2);
                }
            }
        }
Example #9
0
        private void renderShape(Shape Grid, QPen Pen, QPen SpecialPen)
        {
            QPoint p1, p2;

            foreach (var l in Grid.Lines)
            {
                if (projector.Project2DLine(l.P1, l.P2, out p1, out p2))
                {
                    drawingTarget.DrawLine(l.LineType == LineType.Special ? SpecialPen : Pen, p1, p2);
                }
            }
        }
Example #10
0
        public static void FillRectangle(this WriteableBitmap bmp, QPen Pen, int x1, int y1, int x2, int y2)
        {
            unsafe
            {
                IntPtr buff   = bmp.BackBuffer;
                int *  pixels = (int *)buff.ToPointer();

                // Check boundaries
                if (x1 < 0)
                {
                    x1 = 0;
                }
                if (y1 < 0)
                {
                    y1 = 0;
                }
                if (x2 < 0)
                {
                    x2 = 0;
                }
                if (y2 < 0)
                {
                    y2 = 0;
                }
                if (x1 >= Width)
                {
                    x1 = Width - 1;
                }
                if (y1 >= Height)
                {
                    y1 = Height - 1;
                }
                if (x2 >= Width)
                {
                    x2 = Width - 1;
                }
                if (y2 >= Height)
                {
                    y2 = Height - 1;
                }

                for (int y = y1; y <= y2; y++)
                {
                    var yy = y * Width;
                    for (int x = x1; x <= x2; x++)
                    {
                        pixels[yy + x] = Pen.BGRA;
                    }
                }
            }
        }
Example #11
0
 public void FillRectangle(QRectangle Rectangle, QPen FillPen, QPen BorderPen)
 {
     DrawingTarget.FillRectangle(FillPen, Rectangle);
     DrawingTarget.DrawRectangle(BorderPen, Rectangle);
 }
Example #12
0
        public DialogDateTime(IRenderer Renderer, CloseCallback CloseCallback, DateTimeChange ChangeCallback, DateTime DateTime, bool UTC, QSize ScreenSize, QPen ForePen, QPen BorderPen, QPen BackPen)
            : base(Renderer, ScreenSize, CloseCallback, ForePen, BorderPen, BackPen)
        {
            this.changeCallback = ChangeCallback;

            date = DateTime;

            minDate = MathEx.Min(minDate, date.AddYears(-10));
            maxDate = MathEx.Max(maxDate, date.AddYears(10));

            this.utc = UTC;

            changeCallback(date);
        }
Example #13
0
 public InstrumentAttitude(IRenderer Renderer, InstrumentDataSource DataSource, QPen LinePen, QPen BackPen, QPen TextPen)
     : base(Renderer, DataSource, LinePen, BackPen, TextPen)
 {
 }
Example #14
0
        public static void DrawLine(this WriteableBitmap bmp, QPen Pen, int x1, int y1, int x2, int y2)
        {
            // Distance start and end point
            int dx = x2 - x1;
            int dy = y2 - y1;

            int len = BitmapEx.Width * BitmapEx.Height;

            const int PRECISION_SHIFT = 8;
            const int PRECISION_VALUE = 1 << PRECISION_SHIFT;

            unsafe
            {
                IntPtr buff   = bmp.BackBuffer;
                int *  pixels = (int *)buff.ToPointer();

                // Determine slope (absoulte value)
                int lenX, lenY;
                int incy1;
                if (dy >= 0)
                {
                    incy1 = PRECISION_VALUE;
                    lenY  = dy;
                }
                else
                {
                    incy1 = -PRECISION_VALUE;
                    lenY  = -dy;
                }

                int incx1;
                if (dx >= 0)
                {
                    incx1 = 1;
                    lenX  = dx;
                }
                else
                {
                    incx1 = -1;
                    lenX  = -dx;
                }

                if (lenX > lenY)
                { // x increases by +/- 1
                    // Init steps and start
                    int incy = (dy << PRECISION_SHIFT) / lenX;
                    int y    = y1 << PRECISION_SHIFT;

                    for (int i = 0; i < lenX; i++)
                    {
                        // Check boundaries
                        y1 = y >> PRECISION_SHIFT;
                        if (x1 >= 0 && x1 < BitmapEx.Width && y1 >= 0 && y1 < BitmapEx.Height)
                        {
                            pixels[y1 * BitmapEx.Width + x1] = Pen.BGRA;
                        }
                        x1 += incx1;
                        y  += incy;
                    }
                }
                else
                {
                    if (lenY == 0) // Prevent divison by zero
                    {
                        return;
                    }

                    // Init steps and start
                    // since y increases by +/-1, we can safely add (*h) before the for() loop, since there is no fractional value for y
                    int incx  = (dx << PRECISION_SHIFT) / lenY;
                    int x     = x1 << PRECISION_SHIFT;
                    int y     = y1 << PRECISION_SHIFT;
                    int index = (x1 + y1 * BitmapEx.Width) << PRECISION_SHIFT;

                    var inc = incy1 * BitmapEx.Width + incx;
                    for (int i = 0; i < lenY; i++)
                    {
                        x1 = x >> PRECISION_SHIFT;
                        y1 = y >> PRECISION_SHIFT;
                        if (x1 >= 0 && x1 < BitmapEx.Width && y1 >= 0 && y1 < BitmapEx.Height)
                        {
                            pixels[index >> PRECISION_SHIFT] = Pen.BGRA;
                        }
                        x     += incx;
                        y     += incy1;
                        index += inc;
                    }
                }
            }
        }
Example #15
0
 public void DrawString(string Text, QRectangle Rectangle, QPen Pen, QFont Font)
 {
     System.Windows.Forms.TextRenderer.DrawText(DrawingTarget, Text, Font.Font, Rectangle.ToRectangle(), Pen.Color, System.Windows.Forms.TextFormatFlags.WordBreak);
 }
Example #16
0
 public void FillRectangle(QPoint Location, QSize Size, QPen FillPen, QPen BorderPen)
 {
     this.FillRectangle(Location, Size, FillPen);
     DrawingTarget.DrawRectangle(BorderPen, Location, Size);
 }
Example #17
0
 public void FillRectangle(QPoint Location, QSize Size, QPen Pen)
 {
     DrawingTarget.FillRectangle(Pen, Location, Size);
 }
Example #18
0
 public static void DrawLine(this WriteableBitmap bmp, QPen Pen, QPoint P1, QPoint P2)
 {
     bmp.DrawLine(Pen, (int)P1.X, (int)P1.Y, (int)P2.X, (int)P2.Y);
 }
Example #19
0
 public static void DrawLine(this WriteableBitmap bmp, QPen Pen, float x1, float y1, float x2, float y2)
 {
     bmp.DrawLine(Pen, (int)x1, (int)y1, (int)x2, (int)y2);
 }
Example #20
0
 public static void FillCircle(this WriteableBitmap bmp, QPen Pen, float X, float Y, float Radius)
 {
     bmp.FillCircle(Pen, (int)X, (int)Y, (int)Radius);
 }
Example #21
0
 public InstrumentInclinometer(IRenderer Renderer, InstrumentDataSource DataSource, QPen LinePen, QPen BackPen, QPen TextPen)
     : base(Renderer, DataSource, LinePen, BackPen, TextPen)
 {
 }
Example #22
0
        public static void FillCircle(this WriteableBitmap bmp, QPen Pen, int X, int Y, int Radius)
        {
            unsafe
            {
                IntPtr buff   = bmp.BackBuffer;
                int *  pixels = (int *)buff.ToPointer();

                // Init vars
                int uh, lh, uy, ly, lx, rx;
                int x         = Radius;
                int y         = 0;
                int sq2       = (Radius * Radius) << 1;
                int xChg      = Radius * Radius * (1 - (Radius << 1));
                int yChg      = Radius * Radius;
                int err       = 0;
                int xStopping = sq2 * Radius;
                int yStopping = 0;

                // Draw first set of points counter clockwise where tangent line slope > -1.
                while (xStopping >= yStopping)
                {
                    // Draw 4 quadrant points at once
                    uy = Y + y;                  // Upper half
                    ly = Y - y;                  // Lower half
                    if (uy < 0)
                    {
                        uy = 0;          // Clip
                    }
                    if (uy >= BitmapEx.Height)
                    {
                        uy = BitmapEx.Height - 1;
                    }
                    if (ly < 0)
                    {
                        ly = 0;
                    }
                    if (ly >= BitmapEx.Height)
                    {
                        ly = BitmapEx.Height - 1;
                    }
                    uh = uy * BitmapEx.Width;                  // Upper half
                    lh = ly * BitmapEx.Width;                  // Lower half

                    rx = X + x;
                    lx = X - x;
                    if (rx < 0)
                    {
                        rx = 0;          // Clip
                    }
                    if (rx >= BitmapEx.Width)
                    {
                        rx = BitmapEx.Width - 1;      // ...
                    }
                    if (lx < 0)
                    {
                        lx = 0;
                    }
                    if (lx >= BitmapEx.Width)
                    {
                        lx = BitmapEx.Width - 1;
                    }

                    // Draw line
                    for (int i = lx; i <= rx; i++)
                    {
                        pixels[i + uh] = Pen.BGRA;      // Quadrant II to I (Actually two octants)
                        pixels[i + lh] = Pen.BGRA;      // Quadrant III to IV
                    }

                    y++;
                    yStopping += sq2;
                    err       += yChg;
                    yChg      += sq2;
                    if ((xChg + (err << 1)) > 0)
                    {
                        x--;
                        xStopping -= sq2;
                        err       += xChg;
                        xChg      += sq2;
                    }
                }

                // ReInit vars
                x  = 0;
                y  = Radius;
                uy = Y + y;                  // Upper half
                ly = Y - y;                  // Lower half
                if (uy < 0)
                {
                    uy = 0;                  // Clip
                }
                if (uy >= BitmapEx.Height)
                {
                    uy = BitmapEx.Height - 1;
                }
                if (ly < 0)
                {
                    ly = 0;
                }
                if (ly >= BitmapEx.Height)
                {
                    ly = BitmapEx.Height - 1;
                }
                uh        = uy * BitmapEx.Width;           // Upper half
                lh        = ly * BitmapEx.Width;           // Lower half
                xChg      = Radius * Radius;
                yChg      = Radius * Radius * (1 - (Radius << 1));
                err       = 0;
                xStopping = 0;
                yStopping = sq2 * Radius;

                // Draw second set of points clockwise where tangent line slope < -1.
                while (xStopping <= yStopping)
                {
                    // Draw 4 quadrant points at once
                    rx = X + x;
                    lx = X - x;
                    if (rx < 0)
                    {
                        rx = 0;                  // Clip
                    }
                    if (rx >= BitmapEx.Width)
                    {
                        rx = BitmapEx.Width - 1;
                    }
                    if (lx < 0)
                    {
                        lx = 0;
                    }
                    if (lx >= BitmapEx.Width)
                    {
                        lx = BitmapEx.Width - 1;
                    }

                    // Draw line
                    for (int i = lx; i <= rx; i++)
                    {
                        pixels[i + uh] = Pen.BGRA;      // Quadrant II to I (Actually two octants)
                        pixels[i + lh] = Pen.BGRA;      // Quadrant III to IV
                    }

                    x++;
                    xStopping += sq2;
                    err       += xChg;
                    xChg      += sq2;
                    if ((yChg + (err << 1)) > 0)
                    {
                        y--;
                        uy = Y + y;                  // Upper half
                        ly = Y - y;                  // Lower half
                        if (uy < 0)
                        {
                            uy = 0;          // Clip
                        }
                        if (uy >= BitmapEx.Height)
                        {
                            uy = BitmapEx.Height - 1;      // ...
                        }
                        if (ly < 0)
                        {
                            ly = 0;
                        }
                        if (ly >= BitmapEx.Height)
                        {
                            ly = BitmapEx.Height - 1;
                        }
                        uh         = uy * BitmapEx.Width;          // Upper half
                        lh         = ly * BitmapEx.Width;          // Lower half
                        yStopping -= sq2;
                        err       += yChg;
                        yChg      += sq2;
                    }
                }
            }
        }
Example #23
0
        public static void DrawRectangle(this WriteableBitmap bmp, QPen Pen, int x1, int y1, int x2, int y2)
        {
            unsafe
            {
                IntPtr buff   = bmp.BackBuffer;
                int *  pixels = (int *)buff.ToPointer();

                // Check boundaries
                if (x1 < 0)
                {
                    x1 = 0;
                }
                if (y1 < 0)
                {
                    y1 = 0;
                }
                if (x2 < 0)
                {
                    x2 = 0;
                }
                if (y2 < 0)
                {
                    y2 = 0;
                }
                if (x1 >= Width)
                {
                    x1 = Width - 1;
                }
                if (y1 >= Height)
                {
                    y1 = Height - 1;
                }
                if (x2 >= Width)
                {
                    x2 = Width - 1;
                }
                if (y2 >= Height)
                {
                    y2 = Height - 1;
                }

                int startY = y1 * Width;
                int endY   = y2 * Width;

                int offset2      = endY + x1;
                int endOffset    = startY + x2;
                int startYPlusX1 = startY + x1;

                // top and bottom horizontal scanlines
                for (int x = startYPlusX1; x <= endOffset; x++)
                {
                    pixels[x]       = Pen.BGRA; // top horizontal line
                    pixels[offset2] = Pen.BGRA; // bottom horizontal line
                    offset2++;
                }

                // offset2 == endY + x2

                // vertical scanlines
                endOffset = startYPlusX1 + Width;
                offset2  -= Width;

                for (int y = startY + x2 + Width; y < offset2; y += Width)
                {
                    pixels[y]         = Pen.BGRA; // right vertical line
                    pixels[endOffset] = Pen.BGRA; // left vertical line

                    endOffset += Width;
                }
            }
        }
Example #24
0
        public DialogLatLong(IRenderer Renderer, CloseCallback CloseCallback, LatLongChange ChangeCallback, double Latitude, double Longitude, QSize ScreenSize, QPen ForePen, QPen BorderPen, QPen BackPen) : base(Renderer, ScreenSize, CloseCallback, ForePen, BorderPen, BackPen)
        {
            this.changeCallback = ChangeCallback;

            Latitude.ToComponents(out latDeg, out latMin, out latSec, out north);
            Longitude.ToComponents(out lngDeg, out lngMin, out lngSec, out east);
        }
Example #25
0
 static QPen()
 {
     Black  = new QPen(0, 0, 0);
     White  = new QPen(255, 255, 255);
     Yellow = new QPen(255, 255, 0);
 }
Example #26
0
 public void DrawArc(QRectangle Rectangle, double StartAngle, double SweepAngle, QPen Pen)
 {
     this.DrawArc(Rectangle, (float)StartAngle, (float)SweepAngle, Pen);
 }
Example #27
0
 public static void SetPixel(this WriteableBitmap bmp, QPen Pen, float x, float y)
 {
     bmp.SetPixel(Pen, (int)x, (int)y);
 }
Example #28
0
 public void DrawRectangle(QRectangle Rectangle, QPen Pen)
 {
     DrawingTarget.DrawRectangle(Pen, Rectangle.Location, Rectangle.Size);
 }
Example #29
0
 public InstrumentFieldOfView(IRenderer Renderer, InstrumentDataSource DataSource, QPen LinePen, QPen BackPen, QPen TextPen)
     : base(Renderer, DataSource, LinePen, BackPen, TextPen)
 {
 }
Example #30
0
 public static void FillRectangle(this WriteableBitmap bmp, QPen Pen, QPoint Point, QSize Size)
 {
     bmp.FillRectangle(Pen, (int)Point.X, (int)Point.Y, (int)(Point.X + Size.Width), (int)(Point.Y + Size.Height));
 }