Пример #1
0
        private void glControl1_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                if (current.ControlPoints.Count() == 1)
                {
                    current.Degree = (int)numericUpDown1.Value;
                }

                Point p = current.ControlPoints.Last();
                p.X = e.X;
                p.Y = glControl1.ClientSize.Height - e.Y;

                current.Output        = current.CurrentOutput;
                current.CurrentOutput = new List <Point>();

                current.ControlPoints.Add(new Point());
            }

            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                current.ControlPoints.RemoveAt(current.ControlPoints.Count() - 1);
                current.Compute();
                curves.Add(current);

                current = new B_SplineCurve();
                current.ControlPoints.Add(new Point());
            }
        }
Пример #2
0
        private void DrawCurve(B_SplineCurve curve, bool editing)
        {
            if (curve.Degree > 1)
            {
                GL.Enable(EnableCap.LineStipple);
                GL.LineStipple(1, Convert.ToInt16("1111000011110000", 2));
                GL.Color3((editing) ? Color.Gray : Color.Brown);
                GL.LineWidth(STIPPLELINESIZE);
                GL.Begin(PrimitiveType.LineStrip);

                foreach (Point p in curve.ControlPoints)
                {
                    GL.Vertex2(p.X, p.Y);
                }

                GL.End();

                GL.Disable(EnableCap.LineStipple);
            }

            if (!editing || curve.Degree > 1)
            {
                GL.Color3((editing) ? Color.Gray : Color.Brown);
                GL.LineWidth(LINESIZE);
                GL.Begin(PrimitiveType.LineStrip);

                foreach (Point p in curve.Output)
                {
                    GL.Vertex2(p.X, p.Y);
                }

                GL.End();
            }

            if (editing)
            {
                GL.Color3(Color.White);
                GL.LineWidth(LINESIZE);
                GL.Begin(PrimitiveType.LineStrip);

                foreach (Point p in curve.CurrentOutput)
                {
                    GL.Vertex2(p.X, p.Y);
                }

                GL.End();
            }

            GL.Color3((editing) ? Color.Yellow : Color.Brown);
            GL.PointSize(CONTROLPOINTSIZE);
            GL.Begin(PrimitiveType.Points);
            foreach (Point p in curve.ControlPoints)
            {
                GL.Vertex2(p.X, p.Y);
            }
            GL.End();
        }
Пример #3
0
        private void DrawCurve(B_SplineCurve curve, bool editing)
        {
            if (curve.Degree > 1)
            {
                GL.Enable(EnableCap.LineStipple);
                GL.LineStipple(1, Convert.ToInt16("1111000011110000", 2));
                GL.Color3((editing) ? Color.Gray : Color.Brown);
                GL.LineWidth(STIPPLELINESIZE);
                GL.Begin(PrimitiveType.LineStrip);

                foreach (Point p in curve.ControlPoints)
                {
                    GL.Vertex2(p.X, p.Y);
                }

                GL.End();

                GL.Disable(EnableCap.LineStipple);
            }

            if (!editing || curve.Degree > 1)
            {
                GL.Color3((editing) ? Color.Gray : Color.Brown);
                GL.LineWidth(LINESIZE);
                GL.Begin(PrimitiveType.LineStrip);

                foreach (Point p in curve.Output)
                {
                    GL.Vertex2(p.X, p.Y);
                }

                GL.End();
            }

            if (editing)
            {
                GL.Color3(Color.White);
                GL.LineWidth(LINESIZE);
                GL.Begin(PrimitiveType.LineStrip);

                foreach (Point p in curve.CurrentOutput)
                {
                    GL.Vertex2(p.X, p.Y);
                }

                GL.End();
            }

            GL.Color3((editing) ? Color.Yellow : Color.Brown);
            GL.PointSize(CONTROLPOINTSIZE);
            GL.Begin(PrimitiveType.Points);
            foreach (Point p in curve.ControlPoints)
            {
                GL.Vertex2(p.X, p.Y);
            }
            GL.End();
        }
Пример #4
0
        private void glControl1_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                if (current.ControlPoints.Count() == 1)
                {
                    current.Degree = (int)numericUpDown1.Value;
                }

                Point p = current.ControlPoints.Last();
                p.X = e.X;
                p.Y = glControl1.ClientSize.Height - e.Y;

                current.Output = current.CurrentOutput;
                current.CurrentOutput = new List<Point>();

                current.ControlPoints.Add(new Point());
            }

            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                current.ControlPoints.RemoveAt(current.ControlPoints.Count() - 1);
                current.Compute();
                curves.Add(current);

                current = new B_SplineCurve();
                current.ControlPoints.Add(new Point());
            }
        }