Ejemplo n.º 1
0
        private void view_z_MouseUp(object sender, MouseEventArgs e)
        {
            if (this.drawMode == eDrawMode.NONE || p1 == null)
            {
                return;
            }
            _tmpObject = null;

            p2 = new Points();

            p2.X = e.X;
            p2.Y = e.Y;
            p2.Z = 0;

            Util.convertToMy(p2, vp, view_z.Image, Util.eView.z);

            AObjects s = null;

            switch (this.drawMode)
            {
            case eDrawMode.SPHERE:
                s = Sphere.create_z((Points)p1.Clone(), (Points)p2.Clone(), vp);
                break;

            case eDrawMode.CYLINDER:
                s = Cylinder.create_z((Points)p1.Clone(), (Points)p2.Clone(), vp);
                break;

            case eDrawMode.LIGHT:
                s = Light.create_z((Points)p1.Clone(), (Points)p2.Clone(), vp);
                break;

            case eDrawMode.CONE:
                s = Cone.create_z((Points)p1.Clone(), (Points)p2.Clone(), vp);
                break;

            case eDrawMode.PLAN:
                s = Plan.create_z((Points)p1.Clone(), (Points)p2.Clone(), vp);
                break;
            }
            if (s != null)
            {
                ol.Add(s);
                ol.Selected = s;
            }

            redraw();
            propertyGrid.Refresh();
        }
Ejemplo n.º 2
0
Archivo: Cone.cs Proyecto: isundil/drt
        bool isInSegment(Points p, Points p2, Points p3, Util.eView view)
        {
            float  delta = 10f;
            Points p0    = (Points)p2.Clone();
            Points p1    = (Points)p3.Clone();

            p0.X += centerPoint.X;
            p1.X += centerPoint.X;
            p0.Y += centerPoint.Y;
            p1.Y += centerPoint.Y;
            p0.Z += centerPoint.Z;
            p1.Z += centerPoint.Z;

            if (view == Util.eView.x)
            {
                return(_isInSegment(delta, p.Y, p.Z, centerPoint.Y, centerPoint.Z, p0.Y, p0.Z) ||
                       _isInSegment(delta, p.Y, p.Z, p1.Y, p1.Z, centerPoint.Y, centerPoint.Z));
            }
            if (view == Util.eView.y)
            {
                return(_isInSegment(delta, p.X, p.Z, p0.X, p0.Z, centerPoint.X, centerPoint.Z) ||
                       _isInSegment(delta, p.X, p.Z, centerPoint.X, centerPoint.Z, p1.X, p1.Z));
            }
            if (view == Util.eView.z)
            {
                return(_isInSegment(delta, p.X, p.Y, p0.X, p0.Y, centerPoint.X, centerPoint.Y) ||
                       _isInSegment(delta, p.X, p.Y, centerPoint.X, centerPoint.Y, p1.X, p1.Y));
            }
            return(false);
        }
Ejemplo n.º 3
0
        public void ApplyOnPoint(Points p)
        {
            Points tmp = (Points)p.Clone();

            p.X = (int)(tmp.X * values[0] + tmp.Y * values[1] + tmp.Z * values[2]);
            p.Y = (int)(tmp.X * values[3] + tmp.Y * values[4] + tmp.Z * values[5]);
            p.Z = (int)(tmp.X * values[6] + tmp.Y * values[7] + tmp.Z * values[8]);
        }
Ejemplo n.º 4
0
        private bool drawTmpObject(MouseEventArgs e, Points p3, Util.eView v)
        {
            draw_status.Text = "Coords { X : " + p3.X + ", Y : " + p3.Y + ", Z : " + p3.Z + " }";

            if (e.Button == System.Windows.Forms.MouseButtons.Left && this.drawMode < eDrawMode.NONE)
            {
                var vx = new System.Drawing.Bitmap(view_x_cp, view_x_cp.Size);
                var vy = new System.Drawing.Bitmap(view_y_cp, view_y_cp.Size);
                var vz = new System.Drawing.Bitmap(view_z_cp, view_z_cp.Size);

                Type object_type = null;

                switch (this.drawMode)
                {
                case eDrawMode.SPHERE:
                    object_type = typeof(Sphere);
                    break;

                case eDrawMode.CYLINDER:
                    object_type = typeof(Cylinder);
                    break;

                case eDrawMode.LIGHT:
                    object_type = typeof(Light);
                    break;

                case eDrawMode.CONE:
                    object_type = typeof(Cone);
                    break;

                case eDrawMode.PLAN:
                    object_type = typeof(Plan);
                    break;
                }

                if (object_type == null)
                {
                    return(false);
                }

                if (_tmpObject != null)
                {
                    if (v == Util.eView.x)
                    {
                        _tmpObject.Radius = (int)Math.Sqrt(Math.Pow(p3.Y - _tmpObject.centerPoint.Y, 2) + Math.Pow(p3.Z - _tmpObject.centerPoint.Z, 2));
                    }
                    if (v == Util.eView.y)
                    {
                        _tmpObject.Radius = (int)Math.Sqrt(Math.Pow(p3.X - _tmpObject.centerPoint.X, 2) + Math.Pow(p3.Z - _tmpObject.centerPoint.Z, 2));
                    }
                    if (v == Util.eView.z)
                    {
                        _tmpObject.Radius = (int)Math.Sqrt(Math.Pow(p3.X - _tmpObject.centerPoint.X, 2) + Math.Pow(p3.Y - _tmpObject.centerPoint.Y, 2));
                    }
                }
                else
                {
                    if (v == Util.eView.x)
                    {
                        _tmpObject = object_type.GetMethod("create_x").Invoke(null, new object[] { (Points)p1.Clone(), (Points)p3.Clone(), vp, true }) as AObjects;
                    }
                    if (v == Util.eView.y)
                    {
                        _tmpObject = object_type.GetMethod("create_y").Invoke(null, new object[] { (Points)p1.Clone(), (Points)p3.Clone(), vp, true }) as AObjects;
                    }
                    if (v == Util.eView.z)
                    {
                        _tmpObject = object_type.GetMethod("create_z").Invoke(null, new object[] { (Points)p1.Clone(), (Points)p3.Clone(), vp, true }) as AObjects;
                    }
                }
                draw_status.Text += ", " + object_type.ToString() + " { Cx : " + _tmpObject.centerPoint.X + ", Cy : " + _tmpObject.centerPoint.Y + ", Cz : " + _tmpObject.centerPoint.Z + ", R : " + _tmpObject.Radius + " }";

                _tmpObject.Refresh();

                _tmpObject.draw_x(vx, vp, true);
                _tmpObject.draw_y(vy, vp, true);
                _tmpObject.draw_z(vz, vp, true);

                view_x.Image = vx;
                view_y.Image = vy;
                view_z.Image = vz;

                return(true);
            }

            return(false);
        }