Exemple #1
0
        private void DrawMarker(Graphics g, BOMEntry.RefDesc r, bool soldered, float S, bool current, bool activedes)
        {
            float R  = 2;
            float cx = (float)r.x - R / S;
            float cy = (float)r.y - R / S;


            Color CurrentColor = soldered ? Color.Green : Color.Yellow;

            if (current)
            {
                float R2  = 5;
                float cx2 = (float)r.x - R2 / S;
                float cy2 = (float)r.y - R2 / S;
                g.FillRectangle(new SolidBrush(CurrentColor), cx2, cy2, R2 / S * 2, R2 / S * 2);
            }
            if (activedes)
            {
                float R2  = 8;
                float cx2 = (float)r.x - R2 / S;
                float cy2 = (float)r.y - R2 / S;
                g.FillRectangle(new SolidBrush(Color.HotPink), cx2, cy2, R2 / S * 2, R2 / S * 2);
            }
            g.FillRectangle(soldered ? Brushes.Green : Brushes.Red, cx, cy, R / S * 2, R / S * 2);
        }
Exemple #2
0
        private void DrawMarker(Color PartCol, Graphics g, BOMEntry.RefDesc r, bool soldered, float S, bool current, bool activedes)
        {
            float R  = 2;
            float cx = (float)r.x - R / S;
            float cy = (float)r.y - R / S;

            float sa = (float)Math.Sin((-r.angle * Math.PI * 2) / 360.0);
            float ca = (float)Math.Cos((-r.angle * Math.PI * 2) / 360.0);

            g.DrawArc(new Pen(PartCol, 1.0f / S), new RectangleF((float)r.x - 0.5f, (float)r.y - 0.5f, 1, 1), 270, (float)-r.angle);
            g.DrawLine(new Pen(PartCol, 1.0f / S), (float)r.x, (float)r.y, (float)r.x + sa * 1.0f, (float)r.y - ca * 1.0f);

            Color CurrentColor = soldered ? Color.Green : Color.Yellow;

            if (current)
            {
                float R2  = 5;
                float cx2 = (float)r.x - R2 / S;
                float cy2 = (float)r.y - R2 / S;
                g.FillRectangle(new SolidBrush(CurrentColor), cx2, cy2, R2 / S * 2, R2 / S * 2);
            }
            if (activedes)
            {
                float R2  = 8;
                float cx2 = (float)r.x - R2 / S;
                float cy2 = (float)r.y - R2 / S;

                g.DrawArc(new Pen(Color.HotPink, 1.0f / S), new RectangleF((float)r.x - 2.5f, (float)r.y - 2.5f, 5, 5), 270, (float)-r.angle);
                g.DrawLine(new Pen(Color.HotPink, 1.0f / S), (float)r.x, (float)r.y, (float)r.x + sa * 3.0f, (float)r.y - ca * 3.0f);

                g.FillRectangle(new SolidBrush(Color.HotPink), cx2, cy2, R2 / S * 2, R2 / S * 2);
            }
            g.FillRectangle(new SolidBrush(PartCol), cx, cy, R / S * 2, R / S * 2);
        }
Exemple #3
0
        private void PictureBox1_MouseDown(object sender, MouseEventArgs e)
        {
            Bitmap   B = new Bitmap(10, 10);
            Graphics G = Graphics.FromImage(B);

            G.TranslateTransform(10, 10);

            float S = (float)Math.Min(pictureBox1.Width / (TheBox.Width() - 20), pictureBox1.Height / (TheBox.Height() - 20));

            if (TopView)
            {
                G.ScaleTransform(S * 0.8f, -S * 0.8f);
                G.TranslateTransform((float)-TheBox.TopLeft.X, (float)-TheBox.TopLeft.Y - (float)TheBox.Height());
            }
            else
            {
                G.ScaleTransform(-S * 0.8f, -S * 0.8f);
                G.TranslateTransform((float)(-TheBox.TopLeft.X - TheBox.Width()), (float)-TheBox.TopLeft.Y - (float)TheBox.Height());
            }


            var inverseTransform = G.Transform.Clone();

            inverseTransform.Invert();
            Point [] location = new Point[1]; Point p = new Point(e.X, e.Y); location[0] = p;

            inverseTransform.TransformPoints(location);



            double rx = location[0].X, ry = location[0].Y;

            Console.WriteLine("mouse: {0}, {1} - tranlated to {2},{3}", e.X, e.Y, rx, ry);
            ToolX = rx;
            ToolY = ry;

            var   PL      = SolderTool.GetPartList();
            float clodist = 1000000l;

            BOMEntry.RefDesc  closest = null;
            PartList.ListItem LI;
            foreach (var v in PL)
            {
                foreach (var r in v.RefDes)
                {
                    float DX   = (float)r.x - (float)ToolX;
                    float DY   = (float)r.y - (float)ToolY;
                    float dist = (float)Math.Sqrt(DX * DX + DY * DY);
//                    DrawMarker(G, r, v.soldered, S, Current, r == ActiveDes);
                    if (dist < clodist)
                    {
                        clodist     = dist;
                        ActiveEntry = v;
                        closest     = r;
                    }
                }
            }
            ActiveDes = closest;

            pictureBox1.Invalidate();
        }
Exemple #4
0
        private void Render(PnPProcDoc D, Graphics G, bool after)
        {
            G.TranslateTransform(G.ClipBounds.Width / 2, G.ClipBounds.Height / 2);

            TheBox.Reset();
            //   TheBox.FitPoint(0, 0);
            TheBox.AddBox(D.Box);
            if (idx > -1)
            {
                var rd = pnp.selectedrefdes[idx % pnp.selectedrefdes.Count()];
                BOMEntry.RefDesc refd = D.B.GetRefDes(rd);
                if (refd != null)
                {
                    TheBox.Reset();
                    TheBox.FitPoint(refd.x - 10, refd.y - 10);
                    TheBox.FitPoint(refd.x + 10, refd.y + 10);
                }
            }

            float S = (float)Math.Min(pictureBox1.Width / (TheBox.Width()), pictureBox1.Height / (TheBox.Height()));

            bool TopView = false;

            if (PostDisplay)
            {
                TopView = D.FlipBoard ? false : true;
            }

            var C = TheBox.Center();

            G.ScaleTransform(S * 0.8f, -S * 0.8f);
            G.TranslateTransform((float)-C.X, (float)-C.Y);

            RenderLayerSets(G, S, BoardSide.Both, BoardLayer.Outline, Color.Gray, true);

            if (pnp.bottomsilkvisible)
            {
                RenderLayerSets(G, S, BoardSide.Bottom, BoardLayer.Silk, Color.White, true);
            }
            if (pnp.topsilkvisible)
            {
                RenderLayerSets(G, S, BoardSide.Top, BoardLayer.Silk, Color.DarkGray, true);
            }

            var B = D.B;

            if (after)
            {
                B = D.BPost;
            }
            int curpart = 0;

            foreach (var p in B.DeviceTree)
            {
                foreach (var pp in p.Value.Values)
                {
                    var curcol = Helpers.RefractionNormalledMaxBrightnessAndSat(curpart / p.Value.Values.Count());
                    curpart++;
                    foreach (var rf in pp.RefDes)
                    {
                        DrawMarker(curcol, G, rf, true, S, false, pnp.selectedrefdes.Contains(rf.NameOnBoard));
                    }
                }
            }
        }
Exemple #5
0
 public REFDesItem(BOMEntry.RefDesc rd, BOMEntry e)
 {
     refdes = rd;
     entry  = e;
 }
Exemple #6
0
        private void Render(PnPProcDoc D, Graphics G, bool after)
        {
            TheBox.Reset();
            TheBox.FitPoint(0, 0);
            if (after)
            {
                TheBox.AddBox(D.FixSet.BoundingBox);
            }
            else
            {
                TheBox.AddBox(D.Box);
            }

            //TheBox.FitPoint(-250, -250);
            //TheBox.FitPoint(250, 250);
            if (idx > -1)
            {
                var rd = pnp.selectedrefdes[idx % pnp.selectedrefdes.Count()];
                BOMEntry.RefDesc refd = D.B.GetRefDes(rd);
                if (after)
                {
                    refd = D.BPost.GetRefDes(rd);
                }
                if (refd != null)
                {
                    TheBox.Reset();
                    TheBox.FitPoint(refd.x - zoomfac, refd.y - zoomfac);
                    TheBox.FitPoint(refd.x + zoomfac, refd.y + zoomfac);
                }
            }
            var P = pictureBox1;

            var Bb = TheBox;

            float S = Helpers.SetupMatrixForExtends(G, P, Bb, 2);

            MarkPoint(G, Color.Blue, "zero", 0, 0, S);
            MarkPoint(G, Color.Green, "zero", (float)D.FixOffset.X, (float)D.FixOffset.Y, S);


            RenderParts(D, after, G, BoardSide.Bottom, S);
            RenderLayerSets(after, G, S, BoardSide.Both, BoardLayer.Outline, Color.FromArgb(210, 4, 20, 4), false);
            RenderLayerSets(after, G, S, BoardSide.Both, BoardLayer.Outline, Color.Gray, true);

            if (pnp.bottomsilkvisible)
            {
                RenderLayerSets(after, G, S, BoardSide.Bottom, BoardLayer.Silk, Color.FromArgb(160, 160, 160), false);;
                RenderLayerSets(after, G, S, BoardSide.Bottom, BoardLayer.SolderMask, Color.FromArgb(100, 100, 10), false);
            }
            if (pnp.topsilkvisible)
            {
                RenderLayerSets(after, G, S, BoardSide.Top, BoardLayer.Silk, Color.FromArgb(160, 160, 160), false);
                RenderLayerSets(after, G, S, BoardSide.Top, BoardLayer.SolderMask, Color.FromArgb(100, 100, 10), false);
            }



            RenderParts(D, after, G, BoardSide.Top, S);

            var B = D.B;

            if (after)
            {
                B = D.BPost;
            }
            int           curpart  = 0;
            List <string> AllNames = new List <string>();

            foreach (var p in B.DeviceTree)
            {
                foreach (var pp in p.Value.Values)
                {
                    AllNames.Add(pp.Combined());
                }
            }
            AllNames.Sort();
            Font F = new Font("Arial", 3);

            foreach (var p in B.DeviceTree)
            {
                foreach (var pp in p.Value.Values)
                {
                    int idx    = AllNames.IndexOf(pp.Combined());
                    var curcol = Helpers.RefractionNormalledMaxBrightnessAndSat(idx / (float)AllNames.Count());
                    foreach (var rf in pp.RefDes)
                    {
                        bool active = pnp.selectedrefdes.Contains(rf.NameOnBoard);
                        DrawMarker(curcol, G, rf, true, S, false, active);
                        if (active)
                        {
                            DrawText(G, rf.NameOnBoard, new PointF((float)rf.x, (float)rf.y), new RectangleF(0, 0, 50, 20));
                        }
                    }
                }
            }
        }