public ResourcesVisual(MapOctree snapshot, Func<MapOctree, double> getValue, Color color, Transform transform)
            {
                //const double STANDARDAREA = 1000000;
                const double STANDARDAREA = 750000;

                //TODO: Use this to get a normalization multiplier
                double totalArea = (snapshot.MaxRange.X - snapshot.MinRange.X) * (snapshot.MaxRange.Y - snapshot.MinRange.Y);
                double valueMult = totalArea / STANDARDAREA;

                _visual = new DrawingVisual();
                using (DrawingContext dc = _visual.RenderOpen())
                {
                    foreach (MapOctree node in snapshot.Descendants(o => o.Children))
                    {
                        if (node.Items == null)
                        {
                            continue;
                        }

                        // Get the color
                        Brush brush = GetBrush(node, getValue, valueMult, color);
                        if (brush == null)
                        {
                            continue;
                        }

                        // Define the rectangle
                        Point min = transform.Transform(new Point(node.MinRange.X, -node.MinRange.Y));      // need to negate Y
                        Point max = transform.Transform(new Point(node.MaxRange.X, -node.MaxRange.Y));

                        double x = min.X;
                        double y = max.Y;       // can't use min, because Y is backward

                        double width = max.X - min.X;
                        double height = Math.Abs(max.Y - min.Y);       // Y is all flipped around

                        // Fill the box
                        dc.DrawRectangle(brush, null, new Rect(x, y, width, height));
                    }
                }
            }
Beispiel #2
0
            public ResourcesVisual(MapOctree snapshot, Func <MapOctree, double> getValue, Color color, Transform transform)
            {
                //const double STANDARDAREA = 1000000;
                const double STANDARDAREA = 750000;

                //TODO: Use this to get a normalization multiplier
                double totalArea = (snapshot.MaxRange.X - snapshot.MinRange.X) * (snapshot.MaxRange.Y - snapshot.MinRange.Y);
                double valueMult = totalArea / STANDARDAREA;

                _visual = new DrawingVisual();
                using (DrawingContext dc = _visual.RenderOpen())
                {
                    foreach (MapOctree node in snapshot.Descendants(o => o.Children))
                    {
                        if (node.Items == null)
                        {
                            continue;
                        }

                        // Get the color
                        Brush brush = GetBrush(node, getValue, valueMult, color);
                        if (brush == null)
                        {
                            continue;
                        }

                        // Define the rectangle
                        Point min = transform.Transform(new Point(node.MinRange.X, -node.MinRange.Y));      // need to negate Y
                        Point max = transform.Transform(new Point(node.MaxRange.X, -node.MaxRange.Y));

                        double x = min.X;
                        double y = max.Y;       // can't use min, because Y is backward

                        double width  = max.X - min.X;
                        double height = Math.Abs(max.Y - min.Y);       // Y is all flipped around

                        // Fill the box
                        dc.DrawRectangle(brush, null, new Rect(x, y, width, height));
                    }
                }
            }