Example #1
0
        private void ScrollChanged(object sender, EventArgs e)
        {
            EntityBox entityBox = (EntityBox)sender;

            toolStripStatusLabel2.Text = entityBox.ScrollX.ToString() + "; " +
                                         entityBox.ScrollY.ToString();
        }
Example #2
0
            public SizeSettings(EntityBox entityBox)
            {
                savedEntityBox = entityBox;

                ViasBaseSize = entityBox.ViasBaseSize;
                WireBaseSize = entityBox.WireBaseSize;
            }
Example #3
0
        /// <summary>
        /// Резиновая трансформация изображений
        /// </summary>
        /// <param name="boxFrom"></param>
        /// <param name="boxTo"></param>
        private void RubberWarping(EntityBox boxFrom, EntityBox boxTo)
        {
            Delaunay delaunay = new Delaunay();

            //
            // Получить ключевые точки
            //

            List <Point2D> pointsLeft  = GetKeypoints(boxFrom);
            List <Point2D> pointsRight = GetKeypoints(boxTo);

            //
            // Добавить точки по краям изображения
            //

            float gapFromWidth  = 25;
            float gapFromHeight = 25;
            float scale         = new Vec(pointsLeft[0], pointsLeft[1]).Length() /
                                  new Vec(pointsRight[0], pointsRight[1]).Length();
            float gapToWidth  = gapFromWidth * scale;
            float gapToHeight = gapFromHeight * scale;

            AddCornerKeypoints(ref pointsLeft, gapFromWidth, gapFromHeight);
            AddCornerKeypoints(ref pointsRight, gapToWidth, gapToHeight);

            //
            // Триангулируем
            //

            List <Triangle> mesh = delaunay.GenMesh(pointsLeft);

            //
            // Сформировать изображение справа
            //

            Point2D bottomDownTo = BottomDownPoint(pointsRight);

            Bitmap   bitmap = new Bitmap((int)bottomDownTo.X + 1, (int)bottomDownTo.Y + 1);
            Graphics gr     = Graphics.FromImage(bitmap);

            gr.Clear(Color.Gray);
            boxTo.Image0 = bitmap;

            //
            // Трилатеральный перенос треугольников левого изображения в правое
            //

            foreach (Triangle sourceTri in mesh)
            {
                Triangle destTri = new Triangle();

                destTri.a = MapPoint(sourceTri.a, pointsRight);
                destTri.b = MapPoint(sourceTri.b, pointsRight);
                destTri.c = MapPoint(sourceTri.c, pointsRight);

                NonAffineTransform.WarpTriangle(boxFrom.Image0,
                                                boxTo.Image0,
                                                sourceTri, destTri);
            }
        }
Example #4
0
            public ColorSettings(EntityBox entityBox)
            {
                savedEntityBox = entityBox;

                SelectionBoxColor     = entityBox.SelectionBoxColor;
                ViasInputColor        = entityBox.ViasInputColor;
                ViasOutputColor       = entityBox.ViasOutputColor;
                ViasInoutColor        = entityBox.ViasInoutColor;
                ViasConnectColor      = entityBox.ViasConnectColor;
                ViasFloatingColor     = entityBox.ViasFloatingColor;
                ViasPowerColor        = entityBox.ViasPowerColor;
                ViasGroundColor       = entityBox.ViasGroundColor;
                WireInterconnectColor = entityBox.WireInterconnectColor;
                WirePowerColor        = entityBox.WirePowerColor;
                WireGroundColor       = entityBox.WireGroundColor;
                CellNotColor          = entityBox.CellNotColor;
                CellBufferColor       = entityBox.CellBufferColor;
                CellMuxColor          = entityBox.CellMuxColor;
                CellLogicColor        = entityBox.CellLogicColor;
                CellAdderColor        = entityBox.CellAdderColor;
                CellBusSuppColor      = entityBox.CellBusSuppColor;
                CellFlipFlopColor     = entityBox.CellFlipFlopColor;
                CellLatchColor        = entityBox.CellLatchColor;
                CellOtherColor        = entityBox.CellOtherColor;
                UnitRegfileColor      = entityBox.UnitRegfileColor;
                UnitMemoryColor       = entityBox.UnitMemoryColor;
                UnitCustomColor       = entityBox.UnitCustomColor;
                SelectionColor        = entityBox.SelectionColor;
                ViasOverrideColor     = entityBox.ViasOverrideColor;
                WireOverrideColor     = entityBox.WireOverrideColor;
                CellOverrideColor     = entityBox.CellOverrideColor;
                RegionOverrideColor   = entityBox.RegionOverrideColor;
            }
Example #5
0
        public FormSettings(EntityBox entityBox)
        {
            InitializeComponent();

            savedEntityBox = entityBox;

            propertyGridEntityBox.SelectedObject = entityBox;

            globalSettings = new GlobalSettings(entityBox);
            propertyGridGlobal.SelectedObject = globalSettings;

            colorSettings = new ColorSettings(entityBox);
            propertyGridColors.SelectedObject = colorSettings;

            prioritySettings = new PrioritySettings(entityBox);
            propertyGridPriority.SelectedObject = prioritySettings;

            opacitySettings = new OpacitySettings(entityBox);
            propertyGridOpacity.SelectedObject = opacitySettings;

            sizeSettings = new SizeSettings(entityBox);
            propertyGridSize.SelectedObject = sizeSettings;

            shapeSettings = new ShapeSettings(entityBox);
            propertyGridShape.SelectedObject = shapeSettings;
        }
Example #6
0
            public OpacitySettings(EntityBox entityBox)
            {
                savedEntityBox = entityBox;

                ViasOpacity = entityBox.ViasOpacity;
                WireOpacity = entityBox.WireOpacity;
                CellOpacity = entityBox.CellOpacity;
            }
Example #7
0
        public FormEntityLocator(EntityBox ebox)
        {
            parentBox = ebox;

            InitializeComponent();

            comboBox1.SelectedIndex = 0;
        }
Example #8
0
        private Entity AddTriangle(EntityBox box, Triangle tri, Color color)
        {
            List <Point> points = new List <Point>();

            points.Add(new Point((int)tri.a.X, (int)tri.a.Y));
            points.Add(new Point((int)tri.b.X, (int)tri.b.Y));
            points.Add(new Point((int)tri.c.X, (int)tri.c.Y));

            return(box.AddRegion(points, color));
        }
Example #9
0
            public PrioritySettings(EntityBox entityBox)
            {
                savedEntityBox = entityBox;

                ViasPriority   = entityBox.ViasPriority;
                WirePriority   = entityBox.WirePriority;
                CellPriority   = entityBox.CellPriority;
                BeaconPriority = entityBox.BeaconPriority;
                RegionPriority = entityBox.RegionPriority;
                AutoPriority   = entityBox.AutoPriority;
            }
Example #10
0
        /// <summary>
        /// Сгенерировать и показать треугольную сетку
        /// </summary>
        /// <param name="box"></param>
        private void GenerateMesh(EntityBox box)
        {
            Delaunay delaunay = new Delaunay();

            List <Point2D> points = new List <Point2D>();

            //
            // Получить ключевые точки
            //

            foreach (Entity entity in box.GetEntities())
            {
                if (entity.IsVias())
                {
                    Point   p     = box.LambdaToScreen(entity.LambdaX, entity.LambdaY);
                    Point2D point = new Point2D(p.X, p.Y);
                    points.Add(point);
                }
            }

            if (points.Count < 3)
            {
                MessageBox.Show("3 or more keypoints required!", "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            //
            // Добавить ключевые точки по углам
            //

            AddCornerKeypoints(ref points, 25, 25);

            //
            // Триангулируем
            //

            List <Triangle> mesh = delaunay.GenMesh(points);

            //
            // Отобразить треугольную сетку
            //

            Random rnd = new Random();

            foreach (Triangle tri in mesh)
            {
                Color randomColor = Color.FromArgb(rnd.Next(256), rnd.Next(256), rnd.Next(256));

                AddTriangle(box, tri, randomColor);
            }
        }
Example #11
0
    private void Start()
    {
        EntityHuman player = World.AddEntity <EntityHuman>(new Identity {
            Name  = "Inukawa",
            Cases = new Cases {
                NominativeSingular = "Inukawa",
                GenitiveSingular   = "Inukawa's",
                NominativePlural   = "Inukawas",
                GenitivePlural     = "Inukawas'"
            }
        }, "room");

        InputHandler.Player = player;

        EntityBaby        baby            = World.AddEntity <EntityBaby>("room");
        EntityEgg         babyEgg         = World.AddEntity <EntityEgg>("room");
        EntitySandwich    babySandwich    = World.AddEntity <EntitySandwich>("room");
        EntityBaseballBat babyBaseballBat = World.AddEntity <EntityBaseballBat>("room");

        baby.AddPossession(babyEgg);
        baby.AddPossession(babyBaseballBat);
        baby.AddPossession(babySandwich);

        EntityDoor     door     = World.AddEntity <EntityDoor>("room");
        EntityBox      box      = World.AddEntity <EntityBox>("room");
        EntityKey      key      = World.AddEntity <EntityKey>("room");
        EntityEgg      egg      = World.AddEntity <EntityEgg>("room");
        EntitySandwich sandwich = World.AddEntity <EntitySandwich>("room");

        door.Open   = false;
        door.Locked = true;
        door.Key    = key;

        box.Open = false;

        box.AddPossession(egg);
        box.AddPossession(key);

        player.AddPossession(sandwich);

        Parse("open the box");
        Parse("take the egg from the box");
        Parse("take the key");
        Parse("unlock the door with the key");
        Parse("open the door");
        Parse("eat the egg");
        Parse("eat the sandwich");
        Parse("eat the eggs");
        Parse("take the baby's baseball bat");
    }
Example #12
0
        public void InitGameGui()
        {
            mChatBox  = new Chatbox(GameCanvas, this);
            GameMenu  = new Menu(GameCanvas);
            Hotbar    = new HotBarWindow(GameCanvas);
            PlayerBox = new EntityBox(GameCanvas, EntityTypes.Player, Globals.Me, true);
            if (mPictureWindow == null)
            {
                mPictureWindow = new PictureWindow(GameCanvas);
            }

            mEventWindow      = new EventWindow(GameCanvas);
            mQuestOfferWindow = new QuestOfferWindow(GameCanvas);
            mDebugMenu        = new DebugMenu(GameCanvas);
        }
Example #13
0
        private bool IsKeypointExists(EntityBox box, string name)
        {
            List <Entity> _entities = box.GetEntities();

            for (int i = 0; i < _entities.Count - 1; i++)
            {
                Entity entity = _entities[i];

                if (entity.IsVias() && entity.Label == name)
                {
                    return(true);
                }
            }

            return(false);
        }
Example #14
0
        private void EntityCountChanged(object sender, EventArgs e)
        {
            EntityBox entityBox = (EntityBox)sender;

            toolStripStatusLabel6.Text  = entityBox.GetViasCount().ToString();
            toolStripStatusLabel8.Text  = entityBox.GetWireCount().ToString();
            toolStripStatusLabel10.Text = entityBox.GetCellCount().ToString();

            //
            // Update beacon list
            //

            if (listView1.Items.Count != entityBox1.GetBeaconCount())
            {
                RebuildBeaconList();
            }
        }
Example #15
0
        private List <Point2D> GetKeypoints(EntityBox box)
        {
            List <Point2D> points = new List <Point2D>();

            foreach (Entity entity in box.GetEntities())
            {
                if (entity.IsVias())
                {
                    Point   p     = box.LambdaToImage(entity.LambdaX, entity.LambdaY);
                    Point2D point = new Point2D(p.X, p.Y);
                    point.name = entity.Label;
                    points.Add(point);
                }
            }

            return(points);
        }
Example #16
0
        /// <summary>
        /// Загрузить контрольные точки из XML
        /// </summary>
        /// <param name="box"></param>
        /// <param name="filename"></param>
        private void LoadKeypoints(EntityBox box, string filename, bool left)
        {
            XmlSerializer ser = new XmlSerializer(typeof(List <Entity>));

            using (FileStream fs = new FileStream(filename, FileMode.Open))
            {
                List <Entity> list = (List <Entity>)ser.Deserialize(fs);

                foreach (Entity entity in list)
                {
                    box.root.Children.Add(entity);
                    ListInsertKeypoint(entity, left);
                }

                box.SortEntities();

                box.Invalidate();
            }
        }
Example #17
0
            public GlobalSettings(EntityBox entityBox)
            {
                savedEntityBox = entityBox;

                SelectEntitiesAfterAdd = entityBox.SelectEntitiesAfterAdd;
                Grayscale         = entityBox.Grayscale;
                Lambda            = entityBox.Lambda;
                LockScroll0       = entityBox.LockScroll0;
                LockScroll1       = entityBox.LockScroll1;
                LockScroll2       = entityBox.LockScroll2;
                LockZoom0         = entityBox.LockZoom0;
                LockZoom1         = entityBox.LockZoom1;
                LockZoom2         = entityBox.LockZoom2;
                HideGrid          = entityBox.HideGrid;
                HideLambdaMetrics = entityBox.HideLambdaMetrics;
                CellTextAlignment = entityBox.CellTextAlignment;
                ViasTextAlignment = entityBox.ViasTextAlignment;
                WireTextAlignment = entityBox.WireTextAlignment;
            }
Example #18
0
        /// <summary>
        /// Очистить треугольную сетку
        /// </summary>
        /// <param name="box"></param>
        private void ClearMesh(EntityBox box)
        {
            List <Entity> ents = new List <Entity>();

            foreach (Entity entity in box.GetEntities())
            {
                if (entity.IsRegion())
                {
                    ents.Add(entity);
                }
            }

            foreach (Entity entity in ents)
            {
                entity.parent.Children.Remove(entity);
            }

            box.Invalidate();
        }
Example #19
0
        /// <summary>
        /// Сохранить контрольные точки в XML
        /// </summary>
        /// <param name="box"></param>
        /// <param name="filename"></param>
        private void SaveKeypoints(EntityBox box, string filename)
        {
            List <Entity> kps = new List <Entity>();

            foreach (Entity entity in box.GetEntities())
            {
                if (entity.IsVias())
                {
                    kps.Add(entity);
                }
            }

            XmlSerializer ser = new XmlSerializer(typeof(List <Entity>));

            using (FileStream fs = new FileStream(filename, FileMode.Create))
            {
                ser.Serialize(fs, kps);
            }
        }
Example #20
0
        /// <summary>
        /// Верифицировать количество и названия ключевых точек
        /// </summary>
        /// <param name="sourceBox"></param>
        /// <param name="destBox"></param>
        /// <returns></returns>
        private bool VerifyKeypoints(EntityBox sourceBox, EntityBox destBox)
        {
            //
            // Получить ключевые точки
            //

            List <Point2D> pointsLeft  = GetKeypoints(sourceBox);
            List <Point2D> pointsRight = GetKeypoints(destBox);

            foreach (Point2D point in pointsLeft)
            {
                if (MapPoint(point, pointsRight) == null)
                {
                    return(false);
                }
            }

            return(true);
        }
Example #21
0
        /// <summary>
        /// Удалить контрольные точки
        /// </summary>
        /// <param name="box"></param>
        private void RemoveKeypoints(EntityBox box, bool left)
        {
            List <Entity> kps = new List <Entity>();

            foreach (Entity entity in box.GetEntities())
            {
                if (entity.IsVias())
                {
                    kps.Add(entity);
                }
            }

            foreach (Entity entity in kps)
            {
                entity.parent.Children.Remove(entity);
                ListRemoveKeypoint(entity, left);
            }

            box.Invalidate();
        }
Example #22
0
        /// <summary>
        /// Удалить контрольную точку по имени
        /// </summary>
        /// <param name="box"></param>
        /// <param name="name"></param>
        private void RemoveKeypointByName(EntityBox box, string name)
        {
            Entity kp = null;

            foreach (Entity entity in box.GetEntities())
            {
                if (entity.IsVias())
                {
                    if (entity.Label == name)
                    {
                        kp = entity;
                    }
                }
            }

            if (kp != null)
            {
                kp.parent.Children.Remove(kp);
                box.Invalidate();
            }
        }
Example #23
0
        private void LastOperation(object sender, EventArgs e)
        {
            EntityBox entityBox = (EntityBox)sender;

            toolStripStatusLabel12.Text = entityBox.GetLastOperation().ToString();
        }
Example #24
0
            public ShapeSettings(EntityBox entityBox)
            {
                savedEntityBox = entityBox;

                ViasShape = entityBox.ViasShape;
            }
Example #25
0
        public static void SaveSettings(EntityBox entityBox)
        {
            Properties.Settings settings = Properties.Settings.Default;

            /// Save global settings

            GlobalSettings global = new GlobalSettings(entityBox);

            settings.SelectEntitiesAfterAdd = global.SelectEntitiesAfterAdd;
            settings.Grayscale         = global.Grayscale;
            settings.Lambda            = global.Lambda;
            settings.LockScroll0       = global.LockScroll0;
            settings.LockScroll1       = global.LockScroll1;
            settings.LockScroll2       = global.LockScroll2;
            settings.LockZoom0         = global.LockZoom0;
            settings.LockZoom1         = global.LockZoom1;
            settings.LockZoom2         = global.LockZoom2;
            settings.HideGrid          = global.HideGrid;
            settings.HideLambdaMetrics = global.HideLambdaMetrics;
            settings.CellTextAlignment = (int)global.CellTextAlignment;
            settings.ViasTextAlignment = (int)global.ViasTextAlignment;
            settings.WireTextAlignment = (int)global.WireTextAlignment;

            /// Save color settings
            ///

            ColorSettings color = new ColorSettings(entityBox);

            settings.SelectionBoxColor     = color.SelectionBoxColor;
            settings.ViasInputColor        = color.ViasInputColor;
            settings.ViasOutputColor       = color.ViasOutputColor;
            settings.ViasInoutColor        = color.ViasInoutColor;
            settings.ViasConnectColor      = color.ViasConnectColor;
            settings.ViasFloatingColor     = color.ViasFloatingColor;
            settings.ViasPowerColor        = color.ViasPowerColor;
            settings.ViasGroundColor       = color.ViasGroundColor;
            settings.WireInterconnectColor = color.WireInterconnectColor;
            settings.WirePowerColor        = color.WirePowerColor;
            settings.WireGroundColor       = color.WireGroundColor;
            settings.CellNotColor          = color.CellNotColor;
            settings.CellBufferColor       = color.CellBufferColor;
            settings.CellMuxColor          = color.CellMuxColor;
            settings.CellLogicColor        = color.CellLogicColor;
            settings.CellAdderColor        = color.CellAdderColor;
            settings.CellBusSuppColor      = color.CellBusSuppColor;
            settings.CellFlipFlopColor     = color.CellFlipFlopColor;
            settings.CellLatchColor        = color.CellLatchColor;
            settings.CellOtherColor        = color.CellOtherColor;
            settings.UnitRegfileColor      = color.UnitRegfileColor;
            settings.UnitMemoryColor       = color.UnitMemoryColor;
            settings.UnitCustomColor       = color.UnitCustomColor;
            settings.SelectionColor        = color.SelectionColor;
            settings.ViasOverrideColor     = color.ViasOverrideColor;
            settings.WireOverrideColor     = color.WireOverrideColor;
            settings.CellOverrideColor     = color.CellOverrideColor;
            settings.RegionOverrideColor   = color.RegionOverrideColor;

            /// Save priority settings
            ///

            PrioritySettings priority = new PrioritySettings(entityBox);

            settings.ViasPriority   = priority.ViasPriority;
            settings.WirePriority   = priority.WirePriority;
            settings.CellPriority   = priority.CellPriority;
            settings.BeaconPriority = priority.BeaconPriority;
            settings.RegionPriority = priority.RegionPriority;
            settings.AutoPriority   = priority.AutoPriority;

            /// Save opacity settings
            ///

            OpacitySettings opacity = new OpacitySettings(entityBox);

            settings.ViasOpacity = opacity.ViasOpacity;
            settings.WireOpacity = opacity.WireOpacity;
            settings.CellOpacity = opacity.CellOpacity;

            /// Save shape settings
            ///

            ShapeSettings shape = new ShapeSettings(entityBox);

            settings.ViasShape = (int)shape.ViasShape;

            settings.Save();
        }
Example #26
0
        private void ZoomChanged(object sender, EventArgs e)
        {
            EntityBox entityBox = (EntityBox)sender;

            toolStripStatusLabel4.Text = entityBox.Zoom.ToString() + "%";
        }
Example #27
0
 public void SetParent(EntityBox parent)
 {
     parentBox = parent;
 }
Example #28
0
 public void SetParentControl(EntityBox parent)
 {
     parentBox = parent;
 }
Example #29
0
 private void AddTriangle(EntityBox box, Triangle tri)
 {
     box.AddWire(EntityType.WireInterconnect, (int)tri.a.X, (int)tri.a.Y, (int)tri.b.X, (int)tri.b.Y);
     box.AddWire(EntityType.WireInterconnect, (int)tri.b.X, (int)tri.b.Y, (int)tri.c.X, (int)tri.c.Y);
     box.AddWire(EntityType.WireInterconnect, (int)tri.c.X, (int)tri.c.Y, (int)tri.a.X, (int)tri.a.Y);
 }