//when we check for inclusion we expand the box by slack
        internal Geometry Hit(MsaglPoint p, double slack, EntityFilterDelegate filter)
        {
            if (filter != null && this.geometry != null)
            {
                if (filter(geometry.dObject) == false)
                {
                    return(null);
                }
            }
            if (left == null)
            {
                if (Box.Contains(p, slack))
                {
                    Line line = geometry as Line;

                    if (line != null)
                    {
                        if (Tessellator.DistToSegm(p, line.start, line.end) < slack + line.LineWidth / 2)
                        {
                            return(line);
                        }
                        return(null);
                    }
                    else if (Box.Contains(p))
                    {
                        return(geometry);
                    }

                    return(null);
                }
                else
                {
                    return(null);
                }
            }

            if (left.Box.Contains(p, slack))
            {
                Geometry g = left.Hit(p, slack, filter);
                if (g != null)
                {
                    return(g);
                }
            }

            if (right.Box.Contains(p, slack))
            {
                Geometry g = right.Hit(p, slack, filter);
                if (g != null)
                {
                    return(g);
                }
            }

            return(null);
        }
        //when we check for inclusion we expand the box by slack
        internal Geometry Hit(P2 p, double slack, EntityFilterDelegate filter, List<Geometry> subgraphCandidates)
        {
            if (filter != null && geometry != null)
                if (filter(geometry.dObject) == false)
                    return null;
            if (left == null)
                if (Box.Contains(p, slack))
                {
                    Line line = geometry as Line;

                    if (line != null)
                    {
                        if (Tessellator.DistToSegm(p, line.start, line.end) < slack + line.LineWidth/2)
                            return line;
                        return null;

                    }
                    if (Box.Contains(p))
                    {
                        var subg = geometry.dObject.DrawingObject as Subgraph;
                        if (subg != null)
                            subgraphCandidates.Add(geometry);
                        else
                            return geometry;
                    }

                    return null;
                }
                else
                    return null;

            if (left.Box.Contains(p, slack))
            {
                Geometry g = left.Hit(p, slack, filter, subgraphCandidates);
                if (g != null)
                {
                    return g;
                }
            }

            if (right.Box.Contains(p, slack))
            {
                Geometry g = right.Hit(p, slack, filter, subgraphCandidates);
                if (g != null)
                    return g;
            }

            return null;
        }
Ejemplo n.º 3
0
        //when we check for inclusion we expand the box by slack
        internal Geometry Hit(MsaglPoint p, double slack, EntityFilterDelegate filter)
        {
            if (filter != null && this.geometry != null)
                if (filter(geometry.dObject) == false)
                    return null;
            if (left == null)
                if (Box.Contains(p, slack))
                {
                    Line line = geometry as Line;

                    if (line != null)
                    {
                        if (Tessellator.DistToSegm(p, line.start, line.end) < slack + line.LineWidth / 2)
                            return line;
                        return null;

                    }
                    else if (Box.Contains(p))
                        return geometry;

                    return null;
                }
                else
                    return null;

            if (left.Box.Contains(p, slack))
            {
                Geometry g = left.Hit(p, slack, filter);
                if (g != null)
                {
                    return g;
                }
            }

            if (right.Box.Contains(p, slack))
            {
                Geometry g = right.Hit(p, slack, filter);
                if (g != null)
                    return g;
            }

            return null;
        }
        //when we check for inclusion we expand the box by slack
        internal Geometry Hit(P2 p, double slack, EntityFilterDelegate filter, List <Geometry> subgraphCandidates)
        {
            if (filter != null && geometry != null)
            {
                if (filter(geometry.dObject) == false)
                {
                    return(null);
                }
            }
            if (left == null)
            {
                if (Box.Contains(p, slack))
                {
                    Line line = geometry as Line;

                    if (line != null)
                    {
                        if (Tessellator.DistToSegm(p, line.start, line.end) < slack + line.LineWidth / 2)
                        {
                            return(line);
                        }
                        return(null);
                    }
                    if (Box.Contains(p))
                    {
                        var subg = geometry.dObject.DrawingObject as Subgraph;
                        if (subg != null)
                        {
                            subgraphCandidates.Add(geometry);
                        }
                        else
                        {
                            return(geometry);
                        }
                    }

                    return(null);
                }
                else
                {
                    return(null);
                }
            }

            if (left.Box.Contains(p, slack))
            {
                Geometry g = left.Hit(p, slack, filter, subgraphCandidates);
                if (g != null)
                {
                    return(g);
                }
            }

            if (right.Box.Contains(p, slack))
            {
                Geometry g = right.Hit(p, slack, filter, subgraphCandidates);
                if (g != null)
                {
                    return(g);
                }
            }

            return(null);
        }
Ejemplo n.º 5
0
        void UnconditionalHit(MouseEventArgs args, EntityFilterDelegate filter)
        {
            System.Drawing.Point point = args != null
                                             ? new System.Drawing.Point(args.X, args.Y)
                                             : DrawingPanel.PointToClient(MousePosition);

            object old = selectedDObject;
            if (bBNode == null && DGraph != null)
                bBNode = DGraph.BBNode;
            if (bBNode != null) {
                Geometry geometry = bBNode.Hit(ScreenToSource(point), GetHitSlack(), filter);

                selectedDObject = geometry == null ? null : geometry.dObject;

                if (old != selectedDObject) {
                    SetSelectedObject(selectedDObject);
                    if (ObjectUnderMouseCursorChanged != null) {
                        var changedArgs = new ObjectUnderMouseCursorChangedEventArgs((IViewerObject) old,
                                                                                     selectedDObject);
                        ObjectUnderMouseCursorChanged(this, changedArgs);
                    }
                }
            }
        }