Esempio n. 1
0
        public EvoGL(Form f, SimpleOpenGlControl mySimpleGlControl, Point windowSize, Point windowPosition)
        {
            //Setup Thread && start
            //_evoGlThread = new Thread(DrawThread);
            //_evoGlThread.Start();

            //Wait for OpenGL To Set
            //while (_myOpenGlControl == null)
            //{ }

            //Set Gl Control
            _myOpenGlControl = mySimpleGlControl;

            //var d = delegate(object o) {
            //    int x = 5;
            //};

            //Set Draw
            _myTimer.Interval = (int)(1000.0 / this._reqFPS);

            if (this._myTimer.Interval == 0)
                this._myTimer.Interval = 1;

            _myTimer.Tick += new EventHandler(delegate(object o, EventArgs ea) {
                this._myOpenGlControl.Refresh(); });
            _myOpenGlControl.Paint += new System.Windows.Forms.PaintEventHandler(this.openGlControl_Paint);

            //Set Gl MouesControls
            _myOpenGlControl.MouseDown += new System.Windows.Forms.MouseEventHandler(this.openGlControl_MouseDown);
            _myOpenGlControl.MouseMove += new System.Windows.Forms.MouseEventHandler(this.openGlControl_MouseMove);
            _myOpenGlControl.MouseUp += new System.Windows.Forms.MouseEventHandler(this.openGlControl_MouseUp);
            _myOpenGlControl.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.openGlControl_MouseWheel);
            _myOpenGlControl.MouseHover += new System.EventHandler(this.openGlControl_MouseHover);

            //Set Form
            f.Resize += new EventHandler(this.MainForm_ResizeEnd);

            //Set Window
            setWindow(windowSize, windowPosition);

            //Initialize
            InitializeContexts();

            //Set OGLSize
            this._myOpenGlControl.Width = (int)this._windowSize.X;
            this._myOpenGlControl.Height = (int)this._windowSize.Y;
            _OGLSize = new Point(_myOpenGlControl.Size.Width, _myOpenGlControl.Size.Height);
            this.Resize();

            //Start FPS clock
            this._fpsClock = new Clock(true, 0, 333);
        }
Esempio n. 2
0
        protected void ResizeWindowSize()
        {
            double nx = _windowSize.X;
            double ny = _windowSize.Y;

            //If X change
            if (_myOpenGlControl.Size.Width != _OGLSize.X)
            {
                double xchange = _myOpenGlControl.Size.Width / _OGLSize.X;

                nx = nx * xchange;
            }

            //If Y change
            if (_myOpenGlControl.Size.Height != _OGLSize.Y)
            {
                double ychange = _myOpenGlControl.Size.Height / _OGLSize.Y;

                ny = ny * ychange;
            }

            //Set Window Size
            _windowSize = new Point(nx, ny);

            //Set OGLSize
            _OGLSize = new Point(_myOpenGlControl.Size.Width, _myOpenGlControl.Size.Height);
        }
Esempio n. 3
0
        public void Zoom(double scrollMag, double scrollUnits, Point zpt)
        {
            //Get Old window position for zoom point adj
            Point owps = _windowPos.Add(_windowSize.Multiply(.5));

            //Get new Window size
            double nx = _windowSize.X + (_windowSize.X * scrollMag * Math.Sign(-1 * scrollUnits));
            double ny = _windowSize.Y + (_windowSize.Y * scrollMag * Math.Sign(-1 * scrollUnits));

            //Get new window Pos
            _windowPos = new Point(_windowPos.X + ((_windowSize.X - nx) / 2), _windowPos.Y + ((_windowSize.Y - ny) / 2));

            if (scrollUnits > 0)
            {
                //_windowPos = _windowPos
                //.Add(DesktopToContentPoint(zpt).Subtract(owps).Multiply(
                //Math.Sqrt(
                //mag)
                //)
                //.Multiply(Math.Sign(ed))
                //);
            }

            //Get new WindowSize
            _windowSize = new Point(nx, ny);

            //Set Zoom
            _zoom = _zoom * (1 - (scrollMag * Math.Sign(-1 * scrollUnits)));

            //SetOpenGl
            setOpenGL();
        }
Esempio n. 4
0
 public Point ContentToDesktopPoint(Point pt)
 {
     return new Point(
         (_myOpenGlControl.Size.Width * (pt.X - _windowPos.X)) / _windowSize.X,
         (_myOpenGlControl.Size.Height * (pt.Y - _windowPos.Y)) / _windowSize.Y);
 }
Esempio n. 5
0
            //Draw Function
            public void DrawSelf(EvoGL drawer)
            {
                //If Circle
                if (this._isCircle)
                {
                    this._DrawCircle(drawer);
                    return;
                }

                //Base
                if (this.DrawGrid)
                    drawer.DrawGrid(this._startPoint, this._graphSize, 5.0, 1.0);

                //Draw BarGraph objects
                if (this.BarGraphPoints != null)
                {
                    for (int i = 0; i < this.BarGraphPoints.Length; i++)
                    {
                        if (DrawDistribution)
                        {
                            var bw = (this.BarWidth * .99) / 2.0;
                            for (int j = 0; j < this.BarGraphPoints[i].Length; j++)
                            {
                                var p = this.BarGraphPoints[i][j].Add(this._startPoint);
                                var np = new Point[4];

                                np[0] = new Point(p.X - bw, p.Y * _graphSize.Y);
                                np[1] = new Point(p.X + bw, p.Y * _graphSize.Y);
                                np[2] = new Point(p.X + bw, 0);
                                np[3] = new Point(p.X - bw, 0);

                                drawer.DrawPolygonShadow(np, this.GetColor(i), 1.0, .25);
                                //drawer.DrawLine(new Point(p.X, 0), new Point(p.X, p.Y * _graphSize.Y), Color.White, 1.0);
                            }
                        }
                        else
                        {
                           drawer.DrawLines(this.BarGraphPoints[i].ToList<Point>(), this.GetColor(i), 1.0);

                            /*
                            var sp = new SortedValueList<Point>("<=");
                            for (int j = 0; j < this.BarGraphPoints[i].Length; j++)
                                sp.Add(this.BarGraphPoints[i][j], this.BarGraphPoints[i][j].X);

                            var np = new Point[sp.Count + 3];
                            np[0] = new Point(sp[0].Add(this._startPoint).X, this._startPoint.Y);
                            for (int j = 0; i < sp.Count; j++)
                                np[j + 1] = new Point(sp[j].X, sp[j].Y * this._graphSize.Y).Add(this._startPoint);
                            np[sp.Count + 1] = new Point(np[sp.Count].X, this._startPoint.Y);
                            np[sp.Count + 2] = new Point(np[0].X, this._startPoint.Y);

                            //drawer.DrawLines(np.ToList<Point>(), this.MyColor, 1.0);
                            drawer.DrawPolygonShadow(np.ToArray<Point>(), Color.White, 1.0, .5);
                             */
                        }
                    }
                }

                //Draw Horizontals
                for (int i = 0; i < this.Verticals.Count; i++)
                {
                    var px = this.Verticals[i] + this._startPoint.X;
                    //drawer.DrawLine(new Point(px, this._startPoint.Y), new Point(px, this._startPoint.Y + this._graphSize.Y), this.MyColor, 1.0);
                }

                Gl.glEnd();
            }
Esempio n. 6
0
 public static GraphObject CreateCircle(Point center, double radius, Color c)
 {
     return new GraphObject(center, radius, c, "circle");
 }
Esempio n. 7
0
 public GraphObject(Point start, Point size)
     : this(start, size, Color.White)
 {
 }
Esempio n. 8
0
 public void SetCircle(Point p, double r)
 {
     lock (this.LOCK)
     {
         this.type = 1;
         this.val1 = p.X;
         this.val2 = p.Y;
         this.val3 = r;
     }
 }
Esempio n. 9
0
 public void DrawGrid(Point size, double gridDepth)
 {
     DrawGrid(new Point(), size, gridDepth, 1);
 }
Esempio n. 10
0
        public void DrawGrid(Point start, Point size, double gridDepth, double gridSep)
        {
            Gl.glColor3d(1, 1, 1);
            Gl.glLineWidth(1f);
            Gl.glBegin(Gl.GL_LINES);

            float darker = .05f, lighter = .15f;

            Point end = start.Add(size);

            for (float x = (float)start.X; x <= end.X; x += Convert.ToSingle(Math.Sign(end.X - start.X) * gridSep))
            {
                if (x % gridDepth == 0) { Gl.glColor3f(lighter, lighter, lighter); }
                else { Gl.glColor3f(darker, darker, darker); }

                Gl.glVertex2f(x, (float)start.Y);
                Gl.glVertex2f(x, (float)end.Y);
            }
            for (float y = (float)start.Y; y <= end.Y; y += Convert.ToSingle(Math.Sign(end.Y - start.Y) * gridSep))
            {
                if (y % gridDepth == 0) { Gl.glColor3f(lighter, lighter, lighter); }
                else { Gl.glColor3f(darker, darker, darker); }

                Gl.glVertex2f((float)start.X, y);
                Gl.glVertex2f((float)end.X, y);
            }

            Gl.glEnd();
        }
Esempio n. 11
0
 public void DrawCircleShadow(Point p, Double r, Color c)
 {
     DrawCircleShadow(p, r, c, c);
 }
Esempio n. 12
0
 public void DrawCircleShadow(Point p, Double r, Color c, Color fc)
 {
     DrawCircle(p, r, fc.Multiply(.25), true, 1);
     DrawCircle(p, r, c, false, r);
 }
Esempio n. 13
0
        public void DrawCircle(Point p, Double r, Color c, bool fill, double rfill)
        {
            //If is worth Drawing
            //if (!p.IsWithin(this._windowPos, this._windowPos.Add(this._windowSize)))
            //{ return; }

            //Set radius
            double radius = r;

            //set Color
            Gl.glColor3d(c.RedScaled, c.GreenScaled, c.BlueScaled);
            //Gl.glColor4f(c.redf(), c.greenf(), c.bluef(), .1f);

            //Set Thickness
            if (rfill >= 1)
            { Gl.glLineWidth((float)rfill); }

            //Set Fill
            if (!fill)
            { Gl.glBegin(Gl.GL_LINE_STRIP); }
            else
            { Gl.glBegin(Gl.GL_TRIANGLE_FAN); }

            //Get Start Points
            double nx = p.X; double ny = p.Y;

            //Cycle Through Points around circle
            for (double angle = 0; angle <= 360; angle += 3)
            {
                Angle da = new Angle(angle);
                nx = (p.X + Math.Cos(da.Radians) * radius);
                ny = (p.Y + Math.Sin(da.Radians) * radius);
                Gl.glVertex2d(nx, ny);
            }

            Gl.glEnd();

            Gl.glLineWidth(1f);
        }
Esempio n. 14
0
 public void DrawCircle(Point p, Double r, Color c)
 {
     DrawCircle(p, r, c, false, r); ;
 }
Esempio n. 15
0
 //Getters
 public Point DesktopToContentPoint(Point pt)
 {
     return new Point(
         _windowPos.X + (pt.X / _myOpenGlControl.Size.Width) * _windowSize.X,
         _windowPos.Y + (pt.Y / _myOpenGlControl.Size.Height) * _windowSize.Y);
 }
Esempio n. 16
0
 protected void setWindow(Point windowSize, Point windowPosition)
 {
     _windowSize = windowSize;
     _windowPos = windowPosition;
 }
Esempio n. 17
0
 public static DrawObject CreateCircle(Point p, double r)
 {
     var o = new DrawObject();
     o.SetCircle(p, r);
     return o;
 }
Esempio n. 18
0
        public void DrawLine(Point p1, Point p2, Color c, double thick)
        {
            //If is worth Drawing
            if (!p1.IsWithin(this._windowPos, this._windowPos.Add(this._windowSize)) &&
                !p2.IsWithin(this._windowPos, this._windowPos.Add(this._windowSize)))
            { return; }

            //SEt Color
            Gl.glColor3d(c.RedScaled, c.GreenScaled, c.BlueScaled);

            //Set Line Width
            Gl.glLineWidth((float)thick);

            //Set GlDrawType
            Gl.glBegin(Gl.GL_LINE_STRIP);

            //Add Line Points
            Gl.glVertex2d(p1.X, p1.Y);
            Gl.glVertex2d(p2.X, p2.Y);

            //End Draw
            Gl.glEnd();
        }
Esempio n. 19
0
 //Constructor
 public GraphObject(Point startPoint, Point graphSize, Color c)
 {
     this._startPoint = startPoint;
     this._graphSize = graphSize;
     this.MyColors = new List<Color> { c };
 }
Esempio n. 20
0
        public void DrawPolygon(Point[] pts, Color c, double thick, bool fill, double rfill)
        {
            //set Color
            Gl.glColor3d(c.RedScaled, c.GreenScaled, c.BlueScaled);
            //Gl.glColor4f(c.redf(), c.greenf(), c.bluef(), .1f);

            //Set Thickness
            if (thick >= 1)
            { Gl.glLineWidth((float)thick); }

            //Set Fill
            if (!fill)
            { Gl.glBegin(Gl.GL_LINE_STRIP); }
            else
            {
                Gl.glBegin(Gl.GL_TRIANGLE_FAN);
                c = c.Multiply(rfill);
            }

            Gl.glColor3d(c.RedScaled, c.GreenScaled, c.BlueScaled);

            //Cycle Through Points around circle
            for (int i = 0; i < pts.Length; i++)
                Gl.glVertex2d(pts[i].X, pts[i].Y);
            Gl.glVertex2d(pts[0].X, pts[0].Y);

            Gl.glEnd();

            Gl.glLineWidth(1f);
        }
Esempio n. 21
0
            //private constructors
            private GraphObject(Point center, double radius, Color c, string type)
            {
                if (type == "circle")
                {
                    this._startPoint = center;
                    this._radius = radius;
                    this._baseColor = c;
                    this._isCircle = true;
                    return;
                }

                throw new Exception("Unhandled region");
            }
Esempio n. 22
0
 public void DrawPolygonShadow(Point[] pts, Color c, double thick, double rfill)
 {
     this.DrawPolygon(pts, c, thick, true, rfill);
     this.DrawPolygon(pts, c, thick, false, 0);
 }
Esempio n. 23
0
 //Creators
 public static GraphObject CreateGraph(Point start, Point size)
 {
     return new GraphObject(start, size);
 }
Esempio n. 24
0
        public void DrawSquare(Point upperLeft, double length, Color c)
        {
            //SEt Color
            Gl.glColor3d(c.RedScaled, c.GreenScaled, c.BlueScaled);

            //Set Line Width
            Gl.glLineWidth((float)1.0);

            //Set GlDrawType
            //Gl.glBegin(Gl.GL_LINE_STRIP);
            Gl.glBegin(Gl.GL_TRIANGLE_FAN);

            //Cycle
            //for (int i = 0; i < ps.Count - 1; i++)
            //{
                var p1 = new Point(upperLeft.X, upperLeft.Y);
                var p2 = new Point(upperLeft.X + length, upperLeft.Y);
                var p3 = new Point(upperLeft.X + length, upperLeft.Y - length);
                var p4 = new Point(upperLeft.X, upperLeft.Y - length);

                //If is worth Drawing
                // (!ps[i].IsWithin(this._windowPos, this._windowPos.Add(this._windowSize)) &&
                //    !(ps[i + 1].IsWithin(this._windowPos, this._windowPos.Add(this._windowSize))))
                //{ continue; }

                //Add Line Points
                Gl.glVertex2d(upperLeft.X, upperLeft.Y);
                Gl.glVertex2d(upperLeft.X + length, upperLeft.Y);
                Gl.glVertex2d(upperLeft.X + length, upperLeft.Y - length);
                Gl.glVertex2d(upperLeft.X, upperLeft.Y - length);
            //}

            //End Draw
            Gl.glEnd();
        }
Esempio n. 25
0
        private void panelMain_MouseHover(object sender, EventArgs e)
        {
            var mp = new EvolutionTools.Point(MousePosition.X, MousePosition.Y);
            if (this.Cursor == Cursors.Default)
            {
                if (this.modernToolStripMenuItem.Checked)
                {
                    var formCenter = new EvolutionTools.Point(this.Location).Add(new EvolutionTools.Point(this.Size).Divide(2));
                    var corner = new EvolutionTools.Point(this.Location.X + this.Size.Width, this.Location.Y);
                    var mpvect = mp.Subtract(formCenter);
                    var cnvect = mp.Subtract(formCenter);

                    //Angle mpa =

                    if (mpvect.X >= formCenter.X)
                    {
                        //if (mpvect.Y >= formCenter.Y)
                        //this.Cursor = Cursors.

                    }
                    else
                    {

                    }

                    //if (cos >)
                    this.Cursor = Cursors.SizeAll;
                }
            }

            var nl = new System.Drawing.Point((int)mp.X, (int)mp.Y);

            if (this.Cursor != Cursors.Default && _lastMP != null)
            {
                this.Width += (nl.X - _lastMP.Value.X);
            }

            this._lastMP = nl;
            return;
        }
Esempio n. 26
0
 //Public Gl Functions
 public void CenterScreen(Point p)
 {
     Point center = new Point(_windowPos.X + _windowSize.X / 2, _windowPos.Y + _windowSize.Y / 2);
     _windowPos = new Point(_windowPos.X + (p.X - center.X), (_windowPos.Y + p.Y - center.Y));
     setOpenGL();
 }