Beispiel #1
0
        public Mirror(string Name, SystemCoordinates Center, Angle Anglee, DoubleExtention Length)
        {
            angle       = Anglee;
            name        = Name;
            coordinates = Center;
            length      = Length;

            if (((DoubleExtention)angle != (DoubleExtention)90) && ((DoubleExtention)angle != (DoubleExtention)270))
            {
                DoubleExtention y = Center.X * angle.tg();
                DoubleExtention b = Center.Y - y;
                ToDraw           = new Line(angle.tg(), b); ToDraw.AngleForOnePointLines = angle;
                ToDraw.FirstEnd  = new SystemCoordinates((length / 2) * angle.cos() + Center.X, (length / 2) * angle.sin() + Center.Y);
                ToDraw.SecondEnd = Center.BuildPointReflection(ToDraw.FirstEnd);
            }
            else
            {
                ToDraw = new Line(Center.X);
                if ((DoubleExtention)angle == (DoubleExtention)90)
                {
                    ToDraw.FirstEnd  = new SystemCoordinates(Center.X, Center.Y + length / 2); ToDraw.AngleForOnePointLines = angle;
                    ToDraw.SecondEnd = Center.BuildPointReflection(ToDraw.FirstEnd);
                }
                if ((DoubleExtention)angle == (DoubleExtention)270)
                {
                    ToDraw.FirstEnd  = new SystemCoordinates(Center.X, Center.Y - length / 2); ToDraw.AngleForOnePointLines = angle;
                    ToDraw.SecondEnd = Center.BuildPointReflection(ToDraw.FirstEnd);
                }
            }
        }
Beispiel #2
0
 public override void MoveTo(SystemCoordinates to, SystemCoordinates from)
 {
     base.MoveTo(to, from);
     ToDraw.MoveTo(from, to);
     coordinates.X = ToDraw.Center.X;
     coordinates.Y = ToDraw.Center.Y;
 }
        public override void Draw(Point cursorCoordinates)
        {
            if (count == 0)
            {
                OGL.DrawFilledCircle(new Pen(Color.Yellow), cursorCoordinates, 5);
            }
            if (count == 1)
            {
                OGL.DrawFilledCircle(new Pen(Color.Yellow), cursorCoordinates, 5);
                OGL.DrawFilledCircle(new Pen(Color.Yellow), p1, 5);
            }
            if (count == 2 && (SystemCoordinates)cursorCoordinates != p1 && (SystemCoordinates)cursorCoordinates != p2)
            {
                if (SystemCoordinates.InOneLine(p1, cursorCoordinates, p2))
                {
                    OGL.DrawFilledCircle(new Pen(Color.Yellow), p1, 5);
                    OGL.DrawFilledCircle(new Pen(Color.Yellow), p2, 5);
                    Line a = new Line(p1, p2, false);
                    a.Drawer(Color.Black, 2);
                }
                else
                {
                    OGL.DrawFilledCircle(new Pen(Color.Yellow), p1, 5);
                    OGL.DrawFilledCircle(new Pen(Color.Yellow), p2, 5);
                    Circle a = new Circle(p1, cursorCoordinates, p2);
                    a.Draw();
                }
                OGL.DrawFilledCircle(new Pen(Color.Yellow), cursorCoordinates, 5);
            }
            if (count == 3 && (SystemCoordinates)cursorCoordinates != p1 && (SystemCoordinates)cursorCoordinates != p2 && (SystemCoordinates)cursorCoordinates != p3)
            {
                if (SystemCoordinates.InOneLine(p1, cursorCoordinates, p2))
                {
                    OGL.DrawFilledCircle(new Pen(Color.Yellow), p1, 5);
                    OGL.DrawFilledCircle(new Pen(Color.Yellow), p2, 5);
                    Line a = new Line(p1, p2, false);
                    a.Drawer(Color.Black, 2);
                }
                else
                {
                    OGL.DrawFilledCircle(new Pen(Color.Yellow), p1, 5);
                    OGL.DrawFilledCircle(new Pen(Color.Yellow), p2, 5);
                    Circle a = new Circle(p1, cursorCoordinates, p2);
                    a.Draw();
                }

                if (!SystemCoordinates.InOneLine(p1, p3, p2))
                {
                    Circle b = new Circle(p1, p3, p2);
                    b.Draw();
                }
                else
                {
                    Line b = new Line(p1, p2, false);
                    b.Drawer(Color.Black, 2);
                }
                OGL.DrawFilledCircle(new Pen(Color.Yellow), cursorCoordinates, 5);
                OGL.DrawFilledCircle(new Pen(Color.Yellow), p3, 5);
            }
        }
Beispiel #4
0
 public override void MoveTo(SystemCoordinates to, SystemCoordinates from)
 {
     if (ic1)
     {
         c1.Center = new SystemCoordinates(c1.Center.X - from.X + to.X, c1.Center.Y - from.Y + to.Y);
     }
     else
     {
         l1.MoveTo(from, to);
     }
     if (ic2)
     {
         c2.Center = new SystemCoordinates(c2.Center.X - from.X + to.X, c2.Center.Y - from.Y + to.Y);
     }
     else
     {
         l2.MoveTo(from, to);
     }
     if (menisk != 0)
     {
         menisk1.MoveTo(from, to);
         menisk2.MoveTo(from, to);
     }
     p2 = new SystemCoordinates(p2.X - from.X + to.X, p2.Y - from.Y + to.Y);
     p5 = new SystemCoordinates(p5.X - from.X + to.X, p5.Y - from.Y + to.Y);
     base.MoveTo(to, from);
 }
Beispiel #5
0
        public static void Draw(Angle angle, SystemCoordinates SecondEnd, SystemCoordinates FirstEnd, bool Selected = false)
        {
            Point p1 = CoordinateSystem.Instance.Converter(SecondEnd);

            p1.Y += (int)(3 * angle.cos());
            p1.X += (int)(3 * angle.sin());
            Point pp1 = new Point(p1.X + (int)(Math.Ceiling(2 * angle.sin() * (-1))), p1.Y - (int)(Math.Ceiling(2 * angle.cos())));

            if (angle.GetInDegrees() >= 69 && angle.GetInDegrees() <= 90)
            {
                pp1.Y += 1;
            }
            DoubleExtention d = FirstEnd.Distance(SecondEnd);

            d *= CoordinateSystem.Instance.Scale;
            int   length = (int)d;
            Point p2     = new Point((int)(length * angle.cos()) + p1.X, (int)(length * angle.sin() * (-1)) + p1.Y);
            Point pp2    = new Point((int)(length * angle.cos()) + pp1.X, (int)(length * angle.sin() * (-1)) + pp1.Y);

            LineDrawer.DrawLine(p1, p2, Color.Red, 5);
            if (Selected)
            {
                LineDrawer.DrawLine(pp1, pp2, Color.Blue, 3);
            }
            else
            {
                LineDrawer.DrawLine(pp1, pp2, Color.Black, 3);
            }
        }
Beispiel #6
0
        public Mirror(string SaveStr)
        {
            string[] splitted = SaveStr.Split('^');
            if (splitted.Length != 7)
            {
                throw new OpticalBuilderLib.Exceptions.ErrorWhileReading();
            }
            try
            {
                string            Name   = splitted[1];
                SystemCoordinates Center = new SystemCoordinates(Convert.ToDouble(splitted[2]), Convert.ToDouble(splitted[3]));
                Angle             Anglee = Convert.ToDouble(splitted[4]);
                DoubleExtention   Length = Convert.ToDouble(splitted[5]);
                id          = Convert.ToInt32(splitted[6]);
                angle       = Anglee;
                name        = Name;
                coordinates = Center;
                length      = Length;
                if (((DoubleExtention)angle != (DoubleExtention)90) && ((DoubleExtention)angle != (DoubleExtention)270))
                {
                    DoubleExtention y = Center.X * angle.tg();
                    DoubleExtention b = Center.Y - y;
                    ToDraw = new Line(angle.tg(), b);
                }
                else
                {
                    ToDraw = new Line(Center.X);
                }
                if (((DoubleExtention)angle != (DoubleExtention)90) && ((DoubleExtention)angle != (DoubleExtention)270))
                {
                    DoubleExtention y = Center.X * angle.tg();
                    DoubleExtention b = Center.Y - y;
                    ToDraw           = new Line(angle.tg(), b);
                    ToDraw.FirstEnd  = new SystemCoordinates((length / 2) * angle.cos() + Center.X, (length / 2) * angle.sin() + Center.Y);
                    ToDraw.SecondEnd = Center.BuildPointReflection(ToDraw.FirstEnd);
                }
                else
                {
                    ToDraw = new Line(Center.X);
                    if ((DoubleExtention)angle == (DoubleExtention)90)
                    {
                        ToDraw.FirstEnd  = new SystemCoordinates(Center.X, Center.Y + length / 2);
                        ToDraw.SecondEnd = Center.BuildPointReflection(ToDraw.FirstEnd);
                    }
                    if ((DoubleExtention)angle == (DoubleExtention)270)
                    {
                        ToDraw.FirstEnd  = new SystemCoordinates(Center.X, Center.Y - length / 2);
                        ToDraw.SecondEnd = Center.BuildPointReflection(ToDraw.FirstEnd);
                    }
                }

                ToDraw.AngleForOnePointLines = angle;
            }
            catch
            {
                throw new OpticalBuilderLib.Exceptions.ErrorWhileReading();
            }
        }
Beispiel #7
0
 public Sphere(string name, SystemCoordinates coords, DoubleExtention R, DoubleExtention od)
 {
     this.name   = name;
     coordinates = coords;
     r           = R;
     //this.id = id;
     a = new Circle(coords, R);
     opticaldensity = od;
 }
Beispiel #8
0
 public SphereMirror(string name, SystemCoordinates coords, DoubleExtention R, SystemCoordinates p1, SystemCoordinates p2, SystemCoordinates p3, bool Vognutoye)
 {
     this.name   = name;
     coordinates = coords;
     r           = R;
     a           = new Circle(p1, p2, p3);
     this.p2     = p2;
     vognutoye   = Vognutoye;
 }
Beispiel #9
0
        public override void Rotate(SystemCoordinates to, SystemCoordinates from)
        {
            Line aa = new Line(coordinates, to, false);

            aa.BuildAngle();
            Line bb = new Line(coordinates, from, false);

            bb.BuildAngle();
            Angle c = new Angle(aa.AngleForOnePointLines.GetInDegrees() - bb.AngleForOnePointLines.GetInDegrees(), false);

            base.Rotate(to, from);
        }
Beispiel #10
0
        public static void DrawLine(SystemCoordinates p1, SystemCoordinates p2, Color drawingColor, float width, bool Selected = false)
        {
            Point pp1 = CoordinateSystem.Instance.Converter(p1);
            Point pp2 = CoordinateSystem.Instance.Converter(p2);

            if (!Selected)
            {
                OGL.DrawLine(new Pen(drawingColor, width), pp1, pp2);
            }
            else
            {
                OGL.DrawLine(new Pen(Color.Blue, width), pp1, pp2);
            }
        }
Beispiel #11
0
        public override void Rotate(SystemCoordinates to, SystemCoordinates from)
        {
            Angle           fromm, too;
            DoubleExtention dst =
                ((from.X - poly.Center.X) * (from.X - poly.Center.X) + (from.Y - poly.Center.Y) * (from.Y - poly.Center.Y)).
                sqrt();

            fromm = new Angle((from.Y - poly.Center.Y) / dst, (from.X - poly.Center.X) / dst);
            dst   =
                ((to.X - poly.Center.X) * (to.X - poly.Center.X) + (to.Y - poly.Center.Y) * (to.Y - poly.Center.Y)).
                sqrt();
            too = new Angle((to.Y - poly.Center.Y) / dst, (to.X - poly.Center.X) / dst);
            poly.Rotate(new Angle(too.GetInDegrees() - fromm.GetInDegrees(), false));
            coordinates = poly.Center.Clone();
        }
Beispiel #12
0
 public override void Action(Point cursorCoordinates)
 {
     if (!control_modifier)
     {
         CoordinateSystem.Instance.Scale = CoordinateSystem.Instance.Scale * 2;
         SystemCoordinates NewCenter = cursorCoordinates;
         CoordinateSystem.Instance.DifferenceSize = NewCenter;
     }
     else
     {
         CoordinateSystem.Instance.Scale = CoordinateSystem.Instance.Scale / 2;
         SystemCoordinates NewCenter = cursorCoordinates;
         CoordinateSystem.Instance.DifferenceSize = NewCenter;
     }
 }
Beispiel #13
0
        public void Rotate(Angle new_an)
        {
            SystemCoordinates z = new SystemCoordinates(coordinates);
            SystemCoordinates p1, p2, p3, p4, p5, p6;
            DoubleExtention   l;
            Angle             a;
            Line f;

            //P1
            l = z.Distance(P1);
            f = new Line(z, P1, false);
            f.BuildAngle();
            a  = new Angle(new_an.GetInDegrees() + f.AngleForOnePointLines.GetInDegrees() - Anglee.GetInDegrees(), false);
            p1 = new SystemCoordinates(l * a.cos() + z.X, l * a.sin() + z.Y);
            //P2
            l = z.Distance(P2);
            f = new Line(z, P2, false);
            f.BuildAngle();
            a  = new Angle(new_an.GetInDegrees() + f.AngleForOnePointLines.GetInDegrees() - Anglee.GetInDegrees(), false);
            p2 = new SystemCoordinates(l * a.cos() + z.X, l * a.sin() + z.Y);
            //P3
            l = z.Distance(P3);
            f = new Line(z, P3, false);
            f.BuildAngle();
            a  = new Angle(new_an.GetInDegrees() + f.AngleForOnePointLines.GetInDegrees() - Anglee.GetInDegrees(), false);
            p3 = new SystemCoordinates(l * a.cos() + z.X, l * a.sin() + z.Y);
            //P4
            l = z.Distance(P4);
            f = new Line(z, P4, false);
            f.BuildAngle();
            a  = new Angle(new_an.GetInDegrees() + f.AngleForOnePointLines.GetInDegrees() - Anglee.GetInDegrees(), false);
            p4 = new SystemCoordinates(l * a.cos() + z.X, l * a.sin() + z.Y);
            //P5
            l = z.Distance(P5);
            f = new Line(z, P5, false);
            f.BuildAngle();
            a  = new Angle(new_an.GetInDegrees() + f.AngleForOnePointLines.GetInDegrees() - Anglee.GetInDegrees(), false);
            p5 = new SystemCoordinates(l * a.cos() + z.X, l * a.sin() + z.Y);
            //P6
            l = z.Distance(P6);
            f = new Line(z, P6, false);
            f.BuildAngle();
            a  = new Angle(new_an.GetInDegrees() + f.AngleForOnePointLines.GetInDegrees() - Anglee.GetInDegrees(), false);
            p6 = new SystemCoordinates(l * a.cos() + z.X, l * a.sin() + z.Y);
            RebuildLense(coordinates, p1, p2, p3, p4, p5, p6);
            RaiseChanged();
            ObjectCollection.Instance.RaiseObjectsChange();
        }
Beispiel #14
0
 public int DistanceToPointS(SystemCoordinates X)
 {
     if (LineArray.Count > 0)
     {
         DoubleExtention a = LineArray[0].DistanceToPoint(X);
         foreach (var line in LineArray)
         {
             a = Math.Min(a, line.DistanceToPoint(X));
         }
         return((int)Math.Ceiling(a * CoordinateSystem.Instance.Scale));
     }
     else
     {
         return(-1);
     }
 }
Beispiel #15
0
 public DoubleExtention DistanceToPoint(SystemCoordinates X)
 {
     if (LineArray.Count > 0)
     {
         DoubleExtention a = LineArray[0].DistanceToPoint(X);
         foreach (var line in LineArray)
         {
             a = Math.Min(a, line.DistanceToPoint(X));
         }
         return(a);
     }
     else
     {
         return(-1);
     }
 }
        protected int[] countClimateNeighbours(Province province)
        {
            int[] climate_count = new int[6] {
                0, 0, 0, 0, 0, 0
            };
            SystemCoordinates coords = null;

            for (int i = 0; i < 8; i++)
            {
                coords = province.Coordinates.GetNeighbour(i);
                // ignore areas outside of the world.
                if (coords.isInTileGridBounds())
                {
                    switch (Program.State.ProvinceGrid[coords.X, coords.Y].LocalClimate)
                    {
                    case Climate.Arctic:
                        climate_count[0] += 1;
                        break;

                    case Climate.SubArctic:
                        climate_count[1] += 1;
                        break;

                    case Climate.Temperate:
                        climate_count[2] += 1;
                        break;

                    case Climate.SubTropical:
                        climate_count[3] += 1;
                        break;

                    case Climate.Tropical:
                        climate_count[4] += 1;
                        break;

                    case Climate.Inferno:
                        climate_count[5] += 1;
                        break;

                    default:
                        break;
                    }
                }
            }

            return(climate_count);
        }
Beispiel #17
0
        public override void Draw(Point cursorCoordinates)
        {
            SystemCoordinates pp1  = CoordinateSystem.Instance.Converter(p1);
            SystemCoordinates curs = CoordinateSystem.Instance.Converter(cursorCoordinates);

            if (counter == 0)
            {
                OGL.DrawFilledCircle(new Pen(Color.Yellow), cursorCoordinates, 10);
            }
            if (counter == 1)
            {
                if (control_modifier == false)
                {
                    if (alt_modifier == true)
                    {
                        pp1 = pp1.BuildPointReflection(curs);
                    }
                    Line x = new Line(pp1,
                                      curs, false);
                    x.BuildAngle();
                    if (cursorCoordinates != p1)
                    {
                        MirrorDrawer.Draw(x.AngleForOnePointLines, pp1, curs);
                        OGL.DrawFilledCircle(new Pen(Color.Yellow), p1, 10);
                    }
                }
                else
                {
                    if (alt_modifier == true)
                    {
                        pp1 = pp1.BuildPointReflection(curs);
                    }
                    Line x = new Line(curs,
                                      pp1, false);
                    x.BuildAngle();
                    if (cursorCoordinates != p1)
                    {
                        MirrorDrawer.Draw(x.AngleForOnePointLines, curs, pp1);
                        OGL.DrawFilledCircle(new Pen(Color.Yellow), p1, 10);
                    }
                }
            }
            if (counter == 2)
            {
                MirrorDrawer.Draw(x.AngleForOnePointLines, x);
            }
        }
Beispiel #18
0
 public Sphere(string savestring)
 {
     //Name^X^Y^R^id;
     string[] saves = savestring.Split('^');
     if (saves.Length != 7)
     {
         //TODO: Generate error
     }
     else
     {
         name           = saves[1];
         coordinates    = new SystemCoordinates(Convert.ToDouble(saves[2]), Convert.ToDouble(saves[3]));
         r              = Convert.ToDouble(saves[4]);
         id             = Convert.ToInt32(saves[5]);
         a              = new Circle(coordinates, r);
         opticaldensity = Convert.ToDouble(saves[6]);
     }
 }
Beispiel #19
0
        public OPolygon(string savestr)
        {
            string[] splitted = savestr.Split('^');
            name = splitted[1];
            int count = Convert.ToInt32(splitted[3]);

            SystemCoordinates[] arr = new SystemCoordinates[count];
            density = Convert.ToDouble(splitted[2]);
            for (int i = 0; i < count; i++)
            {
                DoubleExtention x = Convert.ToDouble(splitted[2 * i + 4]);
                DoubleExtention y = Convert.ToDouble(splitted[2 * i + 5]);
                arr[i].X = x;
                arr[i].Y = y;
            }
            poly        = new Polygon(arr);
            coordinates = poly.Center.Clone();
        }
Beispiel #20
0
 public SphereMirror(string savestring)
 {
     string[] saves = savestring.Split('^');
     if (saves.Length != 13)
     {
         //TODO: Generate error
     }
     else
     {
         name        = saves[1];
         coordinates = new SystemCoordinates(Convert.ToDouble(saves[2]), Convert.ToDouble(saves[3]));
         r           = Convert.ToDouble(saves[4]);
         id          = Convert.ToInt32(saves[5]);
         a           = new Circle(new SystemCoordinates(Convert.ToDouble(saves[10]), Convert.ToDouble(saves[11])), new SystemCoordinates(Convert.ToDouble(saves[8]), Convert.ToDouble(saves[9])), new SystemCoordinates(Convert.ToDouble(saves[6]), Convert.ToDouble(saves[7])));
         p2          = new SystemCoordinates(Convert.ToDouble(saves[8]), Convert.ToDouble(saves[9]));
         vognutoye   = Convert.ToBoolean(saves[12]);
     }
 }
Beispiel #21
0
        private void RebuildLense(SystemCoordinates center, SystemCoordinates p1, SystemCoordinates p2,
                                  SystemCoordinates p3, SystemCoordinates p4, SystemCoordinates p5, SystemCoordinates p6)
        {
            ic1 = false;
            ic2 = false;
            if (SystemCoordinates.InOneLine(p1, p2, p3))
            {
                l1 = new Line(p1, p3, false);
            }
            else
            {
                ic1 = true;
                c1  = new Circle(p1, p2, p3);
            }
            if (SystemCoordinates.InOneLine(p4, p5, p6))
            {
                l2 = new Line(p4, p6, false);
            }
            else
            {
                ic2 = true;
                c2  = new Circle(p4, p5, p6);
            }
            //length = p1.Distance(p3);
            Line l = new Line(p1, p3, false);

            menisk = DoubleExtention.MinimumOf(p3.Distance(p4), p3.Distance(p6));
            if (menisk != 0)
            {
                if (p3.Distance(p4) < p3.Distance(p6))
                {
                    menisk1 = new Line(p3, p4, false);
                    menisk2 = new Line(p1, p6, false);
                }
                else
                {
                    menisk1 = new Line(p3, p6, false);
                    menisk2 = new Line(p1, p4, false);
                }
            }
            coordinates = center;
            this.p2     = p2;
            this.p5     = p5;
        }
Beispiel #22
0
 public Ray(string Name, int ID, SystemCoordinates Beginning, Angle Angle, string PointName, bool GenNewPoint = false)
 {
     LineArray        = new List <Line>();
     name             = Name;
     id               = ID;
     coordinates      = Beginning;
     angle            = Angle;
     current_density  = ObjectCollection.Instance.VneshDensity;
     bound_point_name = PointName;
     if (GenNewPoint)
     {
         PointName = GenName(GetSpec(ObjectTypes.BrightPoint));
         ObjectCollection.Instance.AddObject(new BrightPoint(PointName, coordinates));
     }
     bound_point_name = PointName;
     ((BrightPoint)ObjectCollection.Instance.GetObjectByName(bound_point_name)).Removal    += PointRemove;
     ((BrightPoint)ObjectCollection.Instance.GetObjectByName(bound_point_name)).NameChange += NameChange;
     FinalizedLoad = true;
 }
Beispiel #23
0
        public Lense(string name, SystemCoordinates center, SystemCoordinates p1, SystemCoordinates p2, SystemCoordinates p3, SystemCoordinates p4, SystemCoordinates p5, SystemCoordinates p6)
        {
            ic1 = false;
            ic2 = false;
            if (SystemCoordinates.InOneLine(p1, p2, p3))
            {
                l1 = new Line(p1, p3, false);
            }
            else
            {
                ic1 = true;
                c1  = new Circle(p1, p2, p3);
            }
            if (SystemCoordinates.InOneLine(p4, p5, p6))
            {
                l2 = new Line(p4, p6, false);
            }
            else
            {
                ic2 = true;
                c2  = new Circle(p4, p5, p6);
            }
            Line l = new Line(p1, p3, false);

            menisk = DoubleExtention.MinimumOf(p3.Distance(p4), p3.Distance(p6));
            if (menisk != 0)
            {
                if (p3.Distance(p4) < p3.Distance(p6))
                {
                    menisk1 = new Line(p3, p4, false);
                    menisk2 = new Line(p1, p6, false);
                }
                else
                {
                    menisk1 = new Line(p3, p6, false);
                    menisk2 = new Line(p1, p4, false);
                }
            }
            coordinates = center;
            this.name   = name;
            this.p2     = p2;
            this.p5     = p5;
        }
 public override void Action(Point cursorCoordinates)
 {
     if (count == 0)
     {
         p1 = cursorCoordinates;
         count++;
     }
     else
     {
         if (count == 1 && cursorCoordinates != p1.ToScreen())
         {
             p2 = cursorCoordinates;
             count++;
         }
         else
         {
             if (count == 2 && cursorCoordinates != p1.ToScreen() && cursorCoordinates != p2.ToScreen())
             {
                 p3 = cursorCoordinates;
                 count++;
             }
             else if (count == 3 && cursorCoordinates != p1.ToScreen() && cursorCoordinates != p2.ToScreen() &&
                      cursorCoordinates != p3.ToScreen())
             {
                 if (!(SystemCoordinates.InOneLine(p1, p3, p2) && SystemCoordinates.InOneLine(p1, cursorCoordinates, p2)))
                 {
                     p4 = cursorCoordinates;
                     count++;
                 }
             }
             if (count == 4)
             {
                 Line aa = new Line(p1, p2, false);
                 ObjectCollection.Instance.AddObject(
                     new Lense(ObjectProto.GenName(ObjectProto.GetSpec(ObjectTypes.Lense)), aa.Center, p1, p3,
                               p2, p1,
                               p4, p2));
                 Deactivate();
             }
         }
     }
 }
        public override void Action(System.Drawing.Point cursorCoordinates)
        {
            if (counter == 1)
            {
                radius = center.Distance(CoordinateSystem.Instance.Converter(cursorCoordinates));
                counter++;
            }
            if (counter == 2)
            {
                CodeFunctions.AddSphere(center, radius);
                Deactivate();
                return;
            }

            if (counter == 0)
            {
                center = CoordinateSystem.Instance.Converter(cursorCoordinates);
                counter++;
            }
        }
Beispiel #26
0
 public BrightPoint(string SaveString) //Конструктор для джерела - читання з файлу
     : base()
 {
     string[] splitted;
     splitted = SaveString.Split('^');
     if (splitted.Length != 5) //Пошкоджений файл - критична помилка, програма закривається
     {
         throw new OpticalBuilderLib.Exceptions.ErrorWhileReading();
     }
     try
     {
         name        = splitted[1];
         coordinates = new SystemCoordinates(Convert.ToDouble(splitted[2]), Convert.ToDouble(splitted[3]));
         id          = Convert.ToInt32(splitted[4]);
     }
     catch
     {
         throw new OpticalBuilderLib.Exceptions.ErrorWhileReading();//Пошкоджений файл - критична помилка, програма закривається
     }
 }
Beispiel #27
0
 public int AddRay(string Name, SystemCoordinates Beginning, Angle angle, BrightPoint bpoint, bool GenNew)
 {
     if (WarnedRays == false && WarnedRaysFinalized == false && rays.Count >= 10)
     {
         if (MessageBox.Show(STranslation.T["WarnRay"] + '\n' + STranslation.T["WantToContinue"],
                             STranslation.T["Warning"], MessageBoxButtons.OKCancel) == DialogResult.OK)
         {
             WarnedRays = false;
         }
         else
         {
             WarnedRays = true;
         }
         WarnedRaysFinalized = true;
     }
     if (WarnedRaysFinalized == false || WarnedRays == false)
     {
         if (GenNew && !ObjectExists(bpoint.Name))
         {
             AddObject(bpoint);
         }
         Ray ToAdd = new Ray(Name, rayMaxID, Beginning, angle, bpoint.Name);
         CheckExistObj = ToAdd;
         ObjectProto Found = Rays.Find(CheckExistance);
         if (Found != null)
         {
             MessageBox.Show(STranslation.T["FoundAnotherRayWithThisName"]);
             return(-1);
         }
         ObjectsChanged += new EventHandler(ToAdd.ObjectsChanged);
         Rays.Add(ToAdd);
         Rays[Rays.Count - 1].ObjectsChanged(this, new EventArgs());
         rayMaxID++;
         if (OnObjectsRaysChange != null)
         {
             OnObjectsRaysChange.Invoke(this, new EventArgs());
         }
         return(rayMaxID - 1);
     }
     return(-1);
 }
Beispiel #28
0
 public Ray(string SaveString)
 {
     string[] splitted = SaveString.Split('^');
     if (splitted.Length != 7)
     {
         throw new OpticalBuilderLib.Exceptions.ErrorWhileReading();
     }
     try
     {
         name             = splitted[1];
         id               = Convert.ToInt32(splitted[2]);
         coordinates      = new SystemCoordinates(Convert.ToDouble(splitted[3]), Convert.ToDouble(splitted[4]));
         angle            = Convert.ToDouble(splitted[5]);
         LineArray        = new List <Line>();
         current_density  = ObjectCollection.Instance.VneshDensity; //fix_when_system_is_ready
         bound_point_name = splitted[6];
     }
     catch
     {
         throw new OpticalBuilderLib.Exceptions.ErrorWhileReading();
     }
 }
Beispiel #29
0
 private void pastleToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (PastleObj != null)
     {
         string h = PastleObj.GenerateSaveString();
         PastleObj      = SaveLoad.Instance.ConstructObject(PastleObj.GetTypeSpecifier(), h);
         PastleObj.Name = ObjectProto.GenName(PastleObj.GetTypeSpecifier(),
                                              PastleObj.GetTypeSpecifier() ==
                                              ObjectProto.GetSpec(ObjectTypes.Ray));
         int id = -1;
         if (!(PastleObj is Ray))
         {
             ObjectCollection.Instance.AddObject(PastleObj);
         }
         else
         {
             ((Ray)PastleObj).Angle = new Angle(((Ray)PastleObj).Angle.GetInDegrees() + 30, false);
             id = ObjectCollection.Instance.AddRay(PastleObj.Name, PastleObj.Coordinates, ((Ray)PastleObj).Angle,
                                                   ((Ray)PastleObj).BoundPoint, true);
         }
         if (PastleObj is Ray)
         {
             SelectedItem = ObjectCollection.Instance.Select(ObjectCollection.Instance.GetRayByID(id));
         }
         else
         {
             SelectedItem = ObjectCollection.Instance.Select(PastleObj);
         }
         if (!(PastleObj is Ray))
         {
             SystemCoordinates tmp = new SystemCoordinates(PastleObj.Coordinates);
             Point             X   = tmp;
             X.X += 10;
             X.Y += 10;
             PastleObj.Coordinates = new SystemCoordinates(X);
         }
         PastleObj = SaveLoad.Instance.ConstructObject(PastleObj.GetTypeSpecifier(), PastleObj.GenerateSaveString());
     }
 }
Beispiel #30
0
        private void AddArea(Region region, Area area)
        {
            region.Areas.Add(area);
            area.Region = region;

            for (int i = 0; i < 7; i += 2)
            {
                SystemCoordinates coords = area.Coordinates.GetNeighbour(i);

                if (coords.isInAreaGridBounds())
                {
                    Area next_area = Program.State.getArea(coords);
                    if (next_area.Type == AreaType.Continent && region.Type == RegionType.Continent ||
                        next_area.Type == AreaType.Ocean && region.Type == RegionType.Ocean)
                    {
                        if (next_area.Region == null)
                        {
                            AddArea(region, next_area);
                        }
                    }
                }
            }
        }