private void BuildPaths(MapArgs e, IEnumerable <IFeature> features, out List <GraphicsPath> borderPaths)
        {
            borderPaths = new List <GraphicsPath>();
            Rectangle          clipRect    = ComputeClippingRectangle(e);
            Extent             drawExtents = e.PixelToProj(clipRect);
            SoutherlandHodgman shClip      = new SoutherlandHodgman(clipRect);

            for (int selectState = 0; selectState < 2; selectState++)
            {
                foreach (IPolygonCategory category in Symbology.Categories)
                {
                    // Determine the subset of the specified features that are visible and match the category
                    IPolygonCategory polygonCategory = category;
                    int i = selectState;
                    Func <IDrawnState, bool> isMember = state =>
                                                        state.SchemeCategory == polygonCategory &&
                                                        state.IsVisible &&
                                                        state.IsSelected == (i == 1);

                    var drawnFeatures = from feature in features
                                        where isMember(DrawingFilter[feature])
                                        select feature;

                    GraphicsPath borderPath = new GraphicsPath();
                    foreach (IFeature f in drawnFeatures)
                    {
                        BuildPolygon(DataSet.Vertex, f.ShapeIndex, borderPath, e,
                                     drawExtents.Contains(f.Envelope) ? null : shClip);
                    }
                    borderPaths.Add(borderPath);
                }
            }
        }
Exemple #2
0
        private void BuildPaths(MapArgs e, IEnumerable <IFeature> features, out Dictionary <FastDrawnState, GraphicsPath> borderPaths, bool selected)
        {
            borderPaths = new Dictionary <FastDrawnState, GraphicsPath>();

            if (selected && !DrawingFilter.DrawnStates.Any(_ => _.Value.IsSelected))
            {
                return;
            }

            Rectangle          clipRect    = ComputeClippingRectangle(e);
            Extent             drawExtents = e.PixelToProj(clipRect);
            SoutherlandHodgman shClip      = new SoutherlandHodgman(clipRect);

            var featureList = features as IList <IFeature> ?? features.ToList();

            foreach (var category in Symbology.Categories)
            {
                // Determine the subset of the specified features that are visible and match the category
                IFeatureCategory         polygonCategory = category;
                Func <IDrawnState, bool> isMember;

                if (selected)
                {
                    // get only selected features
                    isMember = state => state.SchemeCategory == polygonCategory && state.IsVisible && state.IsSelected;
                }
                else
                {
                    // get all features
                    isMember = state => state.SchemeCategory == polygonCategory && state.IsVisible;
                }

                var drawnFeatures = (from feature in featureList where isMember(DrawingFilter[feature]) select feature).ToList();

                if (drawnFeatures.Count > 0)
                {
                    GraphicsPath borderPath = new GraphicsPath();
                    foreach (IFeature f in drawnFeatures)
                    {
                        BuildPolygon(DataSet.Vertex, f.ShapeIndex, borderPath, e, drawExtents.Contains(f.Geometry.EnvelopeInternal) ? null : shClip);
                    }

                    borderPaths.Add(new FastDrawnState(selected, category), borderPath);
                }
            }
        }
Exemple #3
0
        private void BuildPaths(MapArgs e, IEnumerable <int> indices, out Dictionary <FastDrawnState, GraphicsPath> paths, bool selected)
        {
            paths = new Dictionary <FastDrawnState, GraphicsPath>();

            var indiceList = indices as IList <int> ?? indices.ToList();

            FastDrawnState[] states = DrawnStatesNeeded ? DrawnStates : new FastDrawnState[0];
            if (DrawnStatesNeeded && indiceList.Max() >= states.Length)
            {
                AssignFastDrawnStates();
                states = DrawnStates;
            }

            if (selected && (!DrawnStatesNeeded || !DrawnStates.Any(_ => _.Selected)))
            {
                return;
            }

            if (ProgressReportingEnabled)
            {
                ProgressMeter = new ProgressMeter(ProgressHandler, "Building Paths", indiceList.Count);
            }

            FastDrawnState     state       = new FastDrawnState(selected, Symbology.Categories[0]);
            Extent             drawExtents = e.GeographicExtents;
            Rectangle          clipRect    = e.ProjToPixel(e.GeographicExtents);
            SoutherlandHodgman shClip      = new SoutherlandHodgman(clipRect);

            List <ShapeRange> shapes = DataSet.ShapeIndices;

            double[] vertices = DataSet.Vertex;

            foreach (int shp in indiceList)
            {
                if (ProgressReportingEnabled)
                {
                    ProgressMeter.Next();
                }
                if (shp >= shapes.Count)
                {
                    return;
                }
                ShapeRange shape = shapes[shp];
                if (!shape.Extent.Intersects(e.GeographicExtents))
                {
                    continue;
                }

                if (DrawnStatesNeeded)
                {
                    if (!states[shp].Visible || (selected && !states[shp].Selected))
                    {
                        continue;
                    }

                    state = new FastDrawnState(selected, states[shp].Category);
                }

                if (!paths.ContainsKey(state))
                {
                    paths.Add(state, new GraphicsPath(FillMode.Winding));
                }

                BuildPolygon(vertices, shapes[shp], paths[state], e, drawExtents.Contains(shape.Extent) ? null : shClip);
            }

            if (ProgressReportingEnabled)
            {
                ProgressMeter.Reset();
            }
        }
Exemple #4
0
        /// <summary>
        /// Appends the specified polygon to the graphics path.
        /// </summary>
        /// <param name="vertices">The vertices.</param>
        /// <param name="shpx">The shape range.</param>
        /// <param name="borderPath">The border path.</param>
        /// <param name="args">The map arguments.</param>
        /// <param name="shClip">The southerland hodgmen polygon clipper.</param>
        private static void BuildPolygon(double[] vertices, ShapeRange shpx, GraphicsPath borderPath, MapArgs args, SoutherlandHodgman shClip)
        {
            double minX = args.MinX;
            double maxY = args.MaxY;
            double dx   = args.Dx;
            double dy   = args.Dy;

            for (int prt = 0; prt < shpx.Parts.Count; prt++)
            {
                PartRange prtx   = shpx.Parts[prt];
                int       start  = prtx.StartIndex;
                int       end    = prtx.EndIndex;
                var       points = new List <double[]>(end - start + 1);

                for (int i = start; i <= end; i++)
                {
                    var pt = new[] { (vertices[i * 2] - minX) * dx, (maxY - vertices[(i * 2) + 1]) * dy };
                    points.Add(pt);
                }

                if (shClip != null)
                {
                    points = shClip.Clip(points);
                }

                var intPoints = DuplicationPreventer.Clean(points).ToArray();
                if (intPoints.Length < 2)
                {
                    continue;
                }

                borderPath.StartFigure();
                borderPath.AddLines(intPoints);
            }
        }
        /// <summary>
        /// Appends the specified polygon to the graphics path.
        /// </summary>
        private static void BuildPolygon(double[] vertices, ShapeRange shpx, GraphicsPath borderPath, MapArgs args, SoutherlandHodgman shClip)
        {
            double minX = args.MinX;
            double maxY = args.MaxY;
            double dx   = args.Dx;
            double dy   = args.Dy;

            for (int prt = 0; prt < shpx.Parts.Count; prt++)
            {
                PartRange       prtx   = shpx.Parts[prt];
                int             start  = prtx.StartIndex;
                int             end    = prtx.EndIndex;
                List <double[]> points = new List <double[]>();

                for (int i = start; i <= end; i++)
                {
                    double[] pt = new double[2];
                    pt[X] = (vertices[i * 2] - minX) * dx;
                    pt[Y] = (maxY - vertices[i * 2 + 1]) * dy;
                    points.Add(pt);
                }
                if (null != shClip)
                {
                    points = shClip.Clip(points);
                }
                List <Point> intPoints = DuplicationPreventer.Clean(points);
                if (intPoints.Count < 2)
                {
                    points.Clear();
                    continue;
                }

                //Would be nice to figure out how to get rid of this lock
                lock (lock1)
                {
                    borderPath.StartFigure();
                    Point[] pointArray = intPoints.ToArray();
                    borderPath.AddLines(pointArray);
                }
                points.Clear();
            }
        }
        /// <summary>
        /// Appends the specified polygon to the graphics path.
        /// </summary>
        private static void BuildPolygon(double[] vertices, ShapeRange shpx, GraphicsPath borderPath, MapArgs args, SoutherlandHodgman shClip)
        {
            double minX = args.MinX;
            double maxY = args.MaxY;
            double dx = args.Dx;
            double dy = args.Dy;

            for (int prt = 0; prt < shpx.Parts.Count; prt++)
            {
                PartRange prtx = shpx.Parts[prt];
                int start = prtx.StartIndex;
                int end = prtx.EndIndex;
                var points = new List<double[]>(end - start + 1);

                for (int i = start; i <= end; i++)
                {
                    var pt = new[]
                    {
                        (vertices[i*2] - minX)*dx,
                        (maxY - vertices[i*2 + 1])*dy
                    };
                    points.Add(pt);
                }
                if (null != shClip)
                {
                    points = shClip.Clip(points);
                }
                var intPoints = DuplicationPreventer.Clean(points).ToArray();
                if (intPoints.Length < 2)
                {
                    continue;
                }

                borderPath.StartFigure();
                borderPath.AddLines(intPoints);
            }
        }
        private void BuildPaths(MapArgs e, IEnumerable <int> indices, out List <GraphicsPath> paths)
        {
            DateTime startTime = DateTime.Now;

            paths = new List <GraphicsPath>();
            Rectangle          clipRect    = ComputeClippingRectangle(e);
            Extent             drawExtents = e.PixelToProj(clipRect);
            SoutherlandHodgman shClip      = new SoutherlandHodgman(clipRect);

            List <GraphicsPath> graphPaths = new List <GraphicsPath>();
            Dictionary <FastDrawnState, GraphicsPath> borders = new Dictionary <FastDrawnState, GraphicsPath>();

            for (int selectState = 0; selectState < 2; selectState++)
            {
                foreach (IPolygonCategory category in Symbology.Categories)
                {
                    FastDrawnState state = new FastDrawnState(selectState == 1, category);

                    GraphicsPath border = new GraphicsPath();
                    borders.Add(state, border);
                    graphPaths.Add(border);
                }
            }

            paths.AddRange(graphPaths);

            List <ShapeRange> shapes = DataSet.ShapeIndices;

            double[] vertices = DataSet.Vertex;

            if (ProgressReportingEnabled)
            {
                ProgressMeter = new ProgressMeter(ProgressHandler, "Building Paths", indices.Count());
            }

            if (!DrawnStatesNeeded)
            {
                FastDrawnState state = new FastDrawnState(false, Symbology.Categories[0]);

                foreach (int shp in indices)
                {
                    if (ProgressReportingEnabled)
                    {
                        ProgressMeter.Next();
                    }
                    ShapeRange shape = shapes[shp];
                    if (!shape.Extent.Intersects(e.GeographicExtents))
                    {
                        return;
                    }
                    if (shp >= shapes.Count)
                    {
                        return;
                    }
                    if (!borders.ContainsKey(state))
                    {
                        return;
                    }

                    BuildPolygon(vertices, shapes[shp], borders[state], e, drawExtents.Contains(shape.Extent) ? null : shClip);
                }
            }
            else
            {
                FastDrawnState[] states = DrawnStates;
                foreach (GraphicsPath borderPath in borders.Values)
                {
                    if (borderPath != null)
                    {
                        borderPath.FillMode = FillMode.Winding;
                    }
                }

                foreach (int shp in indices)
                {
                    if (ProgressReportingEnabled)
                    {
                        ProgressMeter.Next();
                    }
                    if (shp >= shapes.Count)
                    {
                        return;
                    }
                    if (shp >= states.Length)
                    {
                        AssignFastDrawnStates();
                        states = DrawnStates;
                    }
                    if (states[shp].Visible == false)
                    {
                        continue;
                    }
                    ShapeRange shape = shapes[shp];
                    if (!shape.Extent.Intersects(e.GeographicExtents))
                    {
                        return;
                    }
                    if (drawExtents.Contains(shape.Extent))
                    {
                        FastDrawnState state = states[shp];
                        if (!borders.ContainsKey(state))
                        {
                            return;
                        }
                        BuildPolygon(vertices, shapes[shp], borders[state], e, null);
                    }
                    else
                    {
                        FastDrawnState state = states[shp];
                        if (!borders.ContainsKey(state))
                        {
                            return;
                        }
                        BuildPolygon(vertices, shapes[shp], borders[state], e, shClip);
                    }
                }
            }
            if (ProgressReportingEnabled)
            {
                ProgressMeter.Reset();
            }

            TimeSpan interval = DateTime.Now - startTime;

            totalTime += interval.TotalMilliseconds;

            //Console.WriteLine("Total milliseconds: " + totalTime.ToString());
        }
        private void BuildPaths(MapArgs e, IEnumerable<IFeature> features, out List<GraphicsPath> borderPaths)
        {
            borderPaths = new List<GraphicsPath>();
            Rectangle clipRect = ComputeClippingRectangle(e);
            Extent drawExtents = e.PixelToProj(clipRect);
            SoutherlandHodgman shClip = new SoutherlandHodgman(clipRect);

            for (int selectState = 0; selectState < 2; selectState++)
            {
                foreach (IPolygonCategory category in Symbology.Categories)
                {
                    // Determine the subset of the specified features that are visible and match the category
                    IPolygonCategory polygonCategory = category;
                    int i = selectState;
                    Func<IDrawnState, bool> isMember = state =>
                                                       state.SchemeCategory == polygonCategory &&
                                                       state.IsVisible &&
                                                       state.IsSelected == (i == 1);

                    var drawnFeatures = from feature in features
                                        where isMember(DrawingFilter[feature])
                                        select feature;

                    GraphicsPath borderPath = new GraphicsPath();
                    foreach (IFeature f in drawnFeatures)
                    {
                        BuildPolygon(DataSet.Vertex, f.ShapeIndex, borderPath, e,
                                     drawExtents.Contains(f.Envelope) ? null : shClip);
                    }
                    borderPaths.Add(borderPath);
                }
            }
        }
        private void BuildPaths(MapArgs e, IEnumerable<int> indices, out List<GraphicsPath> paths)
        {
            paths = new List<GraphicsPath>();
            Extent drawExtents = e.GeographicExtents;
            Rectangle clipRect = e.ProjToPixel(e.GeographicExtents);
            SoutherlandHodgman shClip = new SoutherlandHodgman(clipRect);

            List<GraphicsPath> graphPaths = new List<GraphicsPath>();
            Dictionary<FastDrawnState, GraphicsPath> borders = new Dictionary<FastDrawnState, GraphicsPath>();
            for (int selectState = 0; selectState < 2; selectState++)
            {
                foreach (IPolygonCategory category in Symbology.Categories)
                {
                    FastDrawnState state = new FastDrawnState(selectState == 1, category);

                    GraphicsPath border = new GraphicsPath();
                    borders.Add(state, border);
                    graphPaths.Add(border);
                }
            }

            paths.AddRange(graphPaths);

            List<ShapeRange> shapes = DataSet.ShapeIndices;
            double[] vertices = DataSet.Vertex;

            if (ProgressReportingEnabled)
            {
                ProgressMeter = new ProgressMeter(ProgressHandler, "Building Paths", indices.Count());
            }

            if (!DrawnStatesNeeded)
            {
                FastDrawnState state = new FastDrawnState(false, Symbology.Categories[0]);

                foreach (int shp in indices)
                {
                    if (ProgressReportingEnabled) ProgressMeter.Next();
                    ShapeRange shape = shapes[shp];
                    if (!shape.Extent.Intersects(e.GeographicExtents)) return;
                    if (shp >= shapes.Count) return;
                    if (!borders.ContainsKey(state)) return;

                    BuildPolygon(vertices, shapes[shp], borders[state], e, drawExtents.Contains(shape.Extent) ? null : shClip);
                }
            }
            else
            {
                FastDrawnState[] states = DrawnStates;
                foreach (GraphicsPath borderPath in borders.Values)
                {
                    if (borderPath != null)
                    {
                        borderPath.FillMode = FillMode.Winding;
                    }
                }

                foreach (int shp in indices)
                {
                    if (ProgressReportingEnabled) ProgressMeter.Next();
                    if (shp >= shapes.Count) return;
                    if (shp >= states.Length)
                    {
                        AssignFastDrawnStates();
                        states = DrawnStates;
                    }
                    if (states[shp].Visible == false) continue;
                    ShapeRange shape = shapes[shp];
                    if (!shape.Extent.Intersects(e.GeographicExtents)) continue;
                    if (drawExtents.Contains(shape.Extent))
                    {
                        FastDrawnState state = states[shp];
                        if (!borders.ContainsKey(state)) continue;
                        BuildPolygon(vertices, shapes[shp], borders[state], e, null);
                    }
                    else
                    {
                        FastDrawnState state = states[shp];
                        if (!borders.ContainsKey(state)) continue;
                        BuildPolygon(vertices, shapes[shp], borders[state], e, shClip);
                    }
                }
            }
            if (ProgressReportingEnabled) ProgressMeter.Reset();
        }
        /// <summary>
        /// Appends the specified polygon to the graphics path.
        /// </summary>
        private static void BuildPolygon(double[] vertices, ShapeRange shpx, GraphicsPath borderPath, MapArgs args, SoutherlandHodgman shClip)
        {
            double minX = args.MinX;
            double maxY = args.MaxY;
            double dx = args.Dx;
            double dy = args.Dy;

            for (int prt = 0; prt < shpx.Parts.Count; prt++)
            {
                PartRange prtx = shpx.Parts[prt];
                int start = prtx.StartIndex;
                int end = prtx.EndIndex;
                List<double[]> points = new List<double[]>();

                for (int i = start; i <= end; i++)
                {
                    double[] pt = new double[2];
                    pt[X] = (vertices[i * 2] - minX) * dx;
                    pt[Y] = (maxY - vertices[i * 2 + 1]) * dy;
                    points.Add(pt);
                }
                if (null != shClip)
                {
                    points = shClip.Clip(points);
                }
                List<Point> intPoints = DuplicationPreventer.Clean(points);
                if (intPoints.Count < 2)
                {
                    points.Clear();
                    continue;
                }

                //Would be nice to figure out how to get rid of this lock
                lock (lock1)
                {
                    borderPath.StartFigure();
                    Point[] pointArray = intPoints.ToArray();
                    borderPath.AddLines(pointArray);
                }
                points.Clear();
            }
        }
Exemple #11
0
        /// <summary>
        /// Appends the specified polygon to the graphics path.
        /// </summary>
        private static void BuildPolygon(ShapeRange shpx, GraphicsPath borderPath, MapArgs args, SoutherlandHodgman shClip)
        {
            var minX = args.MinX;
            var maxY = args.MaxY;
            var dx = args.Dx;
            var dy = args.Dy;

            foreach (var prtx in shpx.Parts)
            {
                var points = prtx.Select(v => new Vertex((v.X - minX)*dx, (maxY - v.Y)*dy)).ToList();
                if (shClip != null)
                {
                    points = shClip.Clip(points);
                }
                var intPoints = DuplicationPreventer.Clean(points).ToArray();
                if (intPoints.Length < 2) continue;

                borderPath.StartFigure();
                borderPath.AddLines(intPoints);
            }
        }
Exemple #12
0
        private void BuildPaths(MapArgs e, IEnumerable<int> indices, out List<GraphicsPath> paths)
        {
            paths = new List<GraphicsPath>();
            var clipRect = ComputeClippingRectangle(e);
            var drawExtents = e.PixelToProj(clipRect);
            var shClip = new SoutherlandHodgman(clipRect);

            var graphPaths = new List<GraphicsPath>();
            var borders = new Dictionary<FastDrawnState, GraphicsPath>();
            for (var selectState = 0; selectState < 2; selectState++)
            {
                foreach (var category in Symbology.Categories)
                {
                    var state = new FastDrawnState(selectState == 1, category);
                    var border = new GraphicsPath {FillMode = FillMode.Winding};
                    borders.Add(state, border);
                    graphPaths.Add(border);
                }
            }

            paths.AddRange(graphPaths);

            var states = DrawnStates;
            foreach (var shp in indices)
            {
                var state = states[shp];
                if (!state.Visible) continue;
                if (!borders.ContainsKey(state)) continue;

                var shape = DataSet.GetShape(shp, false);
                if (!shape.Range.Extent.Intersects(e.GeographicExtents)) continue;

                BuildPolygon(shape.Range, borders[state], e,
                    drawExtents.Contains(shape.Range.Extent) ? null : shClip);
            }
        }