Beispiel #1
0
        public GLPoint ScreenToView(GLPoint location) {
            //GL.Scale(1.0 / WindowWidth, 1.0 / WindowHeight, 1.0);
            //GL.Translate(50, 50, 0);
            //GL.Scale(WindowWidth, WindowHeight, 1.0);

            //GL.Scale(1.0 / DataWidth, 1.0 / DataHeight, 0);
            //GL.Translate(-DataOrigin.X, -DataOrigin.Y, 0);

            var x = location.X;
            var y = location.Y;

            y = WindowHeight - y;

            x -= 50;
            y -= 50;


            x = x * (DataWidth / WindowWidth);
            y = y * (DataHeight / WindowHeight);

            x += DataOrigin.X;
            y += DataOrigin.Y;

            return new GLPoint(x, y);
        }
Beispiel #2
0
 public GLRect(GLPoint point1, GLPoint point2)
 {
     Location = new GLPoint(Math.Min(point1.X, point2.X), Math.Min(point1.Y, point2.Y));
     //  Max with 0 to prevent double weirdness from causing us to be (-epsilon..0)
     Width  = Math.Max(Math.Max(point1.X, point2.X) - X, 0);
     Height = Math.Max(Math.Max(point1.Y, point2.Y) - Y, 0);
 }
Beispiel #3
0
 public Rectangle(GLColor color, bool border, GLPoint origin, GLSize size)
 {
     Origin = origin;
     Border = border;
     Size   = size;
     Color  = color;
 }
Beispiel #4
0
        public GLPoint ScreenToView(GLPoint location)
        {
            //GL.Scale(1.0 / WindowWidth, 1.0 / WindowHeight, 1.0);
            //GL.Translate(50, 50, 0);
            //GL.Scale(WindowWidth, WindowHeight, 1.0);

            //GL.Scale(1.0 / DataWidth, 1.0 / DataHeight, 0);
            //GL.Translate(-DataOrigin.X, -DataOrigin.Y, 0);

            var x = location.X;
            var y = location.Y;

            y = WindowHeight - y;

            x -= 50;
            y -= 50;


            x = x * (DataWidth / WindowWidth);
            y = y * (DataHeight / WindowHeight);

            x += DataOrigin.X;
            y += DataOrigin.Y;

            return(new GLPoint(x, y));
        }
Beispiel #5
0
 public void AddPoint(GLPoint point, bool update = true) {
     Points.Add(point);
     if (update) {
         if (Changed != null) {
             Changed(this, new LineChangedEventArgs(this));
         }
     }
 }
Beispiel #6
0
        public Line(float thickness, GLColor color, GLPoint[] points) {
            var copy = new List<GLPoint>();
            copy.AddRange(points);

            Color = color;
            Thickness = thickness;
            Points = copy;
        }
Beispiel #7
0
 public static void DrawQuad(GLPoint topLeft, GLPoint topRight, GLPoint bottomRight, GLPoint bottomLeft) {
     GL.Begin(BeginMode.Quads);
     GL.Vertex2(topLeft.X, topLeft.Y);
     GL.Vertex2(topRight.X, topRight.Y);
     GL.Vertex2(bottomRight.X, bottomRight.Y);
     GL.Vertex2(bottomLeft.X, bottomLeft.Y);
     GL.End();
 }
        public Line (float thickness , double intesity, GLPoint[] points) {
            var copy = new List<GLPoint>();
            copy.AddRange(points);

            Color = GetRandomColor(intesity);
            Thickness = thickness;
            Points = copy;
        }
Beispiel #9
0
 public static void DrawQuad(GLPoint topLeft, GLPoint topRight, GLPoint bottomRight, GLPoint bottomLeft)
 {
     GL.Begin(BeginMode.Quads);
     GL.Vertex2(topLeft.X, topLeft.Y);
     GL.Vertex2(topRight.X, topRight.Y);
     GL.Vertex2(bottomRight.X, bottomRight.Y);
     GL.Vertex2(bottomLeft.X, bottomLeft.Y);
     GL.End();
 }
Beispiel #10
0
 public void AddPoint(GLPoint point, bool update = true)
 {
     Points.Add(point);
     if (update)
     {
         if (Changed != null)
         {
             Changed(this, new LineChangedEventArgs(this));
         }
     }
 }
Beispiel #11
0
        public GLPoint ViewToScreen(GLPoint location)
        {
            var x = location.X;
            var y = location.Y;

            x -= DataOrigin.X;
            y -= DataOrigin.Y;

            x = x / (DataWidth / WindowWidth);
            y = y / (DataHeight / WindowHeight);

            x += 50;
            y += 50;

            y = WindowHeight - y;

            return(new GLPoint(x, y));
        }
        public void Draw(GraphWindow window, GLPoint location) {
            GL.Color3(1.0, 1.0, 1.0);
            GL.BindTexture(TextureTarget.Texture2D, _texture);

            var height = GetMagnitude(new Point(0, _bitmap.Height),window).Y;
            var width = GetMagnitude(new Point(_bitmap.Width, 0), window).X;

            var ox = location.X - (width / 2.0);
            var oy = location.Y - (height / 2.0);

            GL.Begin(BeginMode.Quads);
            GL.TexCoord2(0f, 0f); GL.Vertex2(ox, oy + height);
            GL.TexCoord2(1f, 0f); GL.Vertex2(ox + width, oy + height);
            GL.TexCoord2(1f, 1f); GL.Vertex2(ox + width, oy);
            GL.TexCoord2(0f, 1f); GL.Vertex2(ox, oy);
            GL.End();

            GL.BindTexture(TextureTarget.Texture2D, 0);
        }
Beispiel #13
0
        public void Draw(GLPoint origin, float? glWidth, float? glHeight, bool offsetHeight) {
            var width = glWidth ?? _bmpWidth;
            var height = glHeight ?? _bmpHeight;

            GL.BindTexture(TextureTarget.Texture2D, _texture);
            GL.PushMatrix();

            GL.Translate(Math.Round(origin.X), offsetHeight ? Math.Round(origin.Y - _font.Height/2.0) : Math.Round(origin.Y), 0);

            GL.Begin(BeginMode.Quads);
            GL.Color3(0,0,0);
            GL.TexCoord2(0f, 0f); GL.Vertex2(0, height); //topleft
            GL.TexCoord2(1f, 0f); GL.Vertex2(width, height);
            GL.TexCoord2(1f, 1f); GL.Vertex2(width, 0);
            GL.TexCoord2(0f, 1f); GL.Vertex2(0, 0);
            GL.End();

            GL.BindTexture(TextureTarget.Texture2D, 0);

            GL.PopMatrix();
        }
Beispiel #14
0
        public void Draw(GLPoint origin, float?glWidth, float?glHeight, bool offsetHeight)
        {
            var width  = glWidth ?? _bmpWidth;
            var height = glHeight ?? _bmpHeight;

            GL.BindTexture(TextureTarget.Texture2D, _texture);
            GL.PushMatrix();

            GL.Translate(Math.Round(origin.X), offsetHeight ? Math.Round(origin.Y - _font.Height / 2.0) : Math.Round(origin.Y), 0);

            GL.Begin(BeginMode.Quads);
            GL.Color3(0, 0, 0);
            GL.TexCoord2(0f, 0f); GL.Vertex2(0, height); //topleft
            GL.TexCoord2(1f, 0f); GL.Vertex2(width, height);
            GL.TexCoord2(1f, 1f); GL.Vertex2(width, 0);
            GL.TexCoord2(0f, 1f); GL.Vertex2(0, 0);
            GL.End();

            GL.BindTexture(TextureTarget.Texture2D, 0);

            GL.PopMatrix();
        }
        public void Draw(GLPoint origin) {
            var width = 200;
            var height = 50;
            using (var bmp = new Bitmap(width, height)) {
                using (var g = Graphics.FromImage(bmp)) {
                    g.Clear(Color.Transparent);
                    g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
                    g.DrawString(Text, _font, Brushes.Black, new PointF(0, 25));
                }

                GL.BindTexture(TextureTarget.Texture2D, _texture);

                GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)All.Linear);
                GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)All.Linear);

                var data = bmp.LockBits(new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

                GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, width, height, 0,
                    PixelFormat.Bgra, PixelType.UnsignedByte, data.Scan0);

                bmp.UnlockBits(data);
            }

            GL.PushMatrix();

            GL.Translate(origin.X, origin.Y, 0);

            GL.Begin(BeginMode.Quads);
            GL.TexCoord2(0f, 0f); GL.Vertex2(0, height); //topleft
            GL.TexCoord2(1f, 0f); GL.Vertex2(width, height);
            GL.TexCoord2(1f, 1f); GL.Vertex2(width, 0);
            GL.TexCoord2(0f, 1f); GL.Vertex2(0, 0);
            GL.End();

            GL.BindTexture(TextureTarget.Texture2D, 0);

            GL.PopMatrix();
        }
        public void Draw(GraphWindow window, GLPoint location)
        {
            if (_disposed)
            {
                throw new ObjectDisposedException("PersistentTexture");
            }
            GL.Color3(1.0, 1.0, 1.0);
            GL.BindTexture(TextureTarget.Texture2D, _texture);

            var height = GetMagnitude(new Point(0, _bitmap.Height), window).Y;
            var width  = GetMagnitude(new Point(_bitmap.Width, 0), window).X;

            var ox = location.X - (width / 2.0);
            var oy = location.Y - (height / 2.0);

            GL.Begin(BeginMode.Quads);
            GL.TexCoord2(0f, 0f); GL.Vertex2(ox, oy + height);
            GL.TexCoord2(1f, 0f); GL.Vertex2(ox + width, oy + height);
            GL.TexCoord2(1f, 1f); GL.Vertex2(ox + width, oy);
            GL.TexCoord2(0f, 1f); GL.Vertex2(ox, oy);
            GL.End();

            GL.BindTexture(TextureTarget.Texture2D, 0);
        }
 public void AddPoint(GLPoint point) {
     Points.Add(point);
     if (Changed != null) {
         Changed(this, new LineChangedEventArgs(this));
     }
 }
 public Rectangle(GLColor color, bool border, GLPoint origin, GLSize size) {
     Origin = origin;
     Border = border;
     Size = size;
     Color = color;
 }
Beispiel #19
0
        public GLPoint ViewToScreen(GLPoint location) {
            var x = location.X;
            var y = location.Y;

            x -= DataOrigin.X;
            y -= DataOrigin.Y;

            x = x / (DataWidth / WindowWidth);
            y = y / (DataHeight / WindowHeight);

            x += 50;
            y += 50;

            y = WindowHeight - y;

            return new GLPoint(x, y);

        }
Beispiel #20
0
 public static void DrawVertices(GLPoint[] points) {
     foreach (var p in points) {
         GL.Vertex2(p.X, p.Y);
     }
 }
Beispiel #21
0
 public GLRect(double x, double y, double width, double height) {
     Location = new GLPoint(x, y);
     Width = width;
     Height = height;
 }
Beispiel #22
0
 public GLRect(GLPoint point1, GLPoint point2) {
     Location = new GLPoint(Math.Min(point1.X, point2.X),Math.Min(point1.Y, point2.Y));
     //  Max with 0 to prevent double weirdness from causing us to be (-epsilon..0) 
     Width = Math.Max(Math.Max(point1.X, point2.X) - X, 0);
     Height = Math.Max(Math.Max(point1.Y, point2.Y) - Y, 0);
 }
Beispiel #23
0
 public GLRect(double x, double y, double width, double height)
 {
     Location = new GLPoint(x, y);
     Width    = width;
     Height   = height;
 }