예제 #1
0
 public SolutionsModel(IEnumerable <PulsationSolutionItemModel> solutionItems)
 {
     SolutionItems = solutionItems.Select((si, i) => new SolutionItemColoredModel(si, Pallete.GetColor(i))).ToList();
 }
예제 #2
0
        public override void Render(Graphics g)
        {
            // vykreslení mřížky při zapnutém zachycování
            if (interaction.SnapToGrid)
            {
                Brush b = Brushes.DimGray;
                for (int x = 0; x < simulation.Width; x += interaction.GridSize)
                {
                    for (int y = 0; y < simulation.Height; y += interaction.GridSize)
                    {
                        g.FillRectangle(b, x, y, 1, 1);
                    }
                }
            }

            // kreslení bodů
            foreach (Vertex v in simulation.Vertices)
            {
                RenderVertex(v.Position, v.Radius, (x, y, s) =>
                {
                    if (interaction.Hover.Contains(v))
                    {
                        g.FillEllipse(Brushes.White, x, y, s, s);
                    }
                    else
                    {
                        g.DrawEllipse(Pens.White, x, y, s, s);
                    }
                });

                if (v.Fixed)
                {
                    RenderVertex(v.Position, 14, (x, y, s) =>
                    {
                        g.DrawRectangle(Pens.White, x, y, s, s);
                    });
                }
            }

            // kreslení hran
            foreach (Edge e in simulation.Edges)
            {
                Vertex u = e.U;
                Vertex v = e.V;
                Pen    p = Pens.White;

                if (RenderStrain)
                {
                    float maxStrain = simulation.MaxStrain;
                    float delta     = 1 - e.CurrentLength / e.Length;
                    float strain    = Math.Min(Math.Abs(delta), maxStrain);
                    p = new Pen(straincolor.GetColor(strain / maxStrain), 2);

                    // Show strain as text
                    // var pos = u.Position.Add(v.Position).MultiplyScalar(0.5f);
                    // g.DrawString(String.Format("{0:0.00}", strain / maxStrain), new Font("Arial", 8), new SolidBrush(Color.White), pos.X, pos.Y);
                }

                if (interaction.HoverEdges.Contains(e))
                {
                    p = new Pen(Color.White, 2);
                }

                g.DrawLine(p, v.Position, u.Position);

                if (e.IsRoad)
                {
                    PointF delta = new PointF(0, -3);
                    g.DrawLine(p, v.Position.Add(delta), u.Position.Add(delta));
                }
            }
        }