Esempio n. 1
0
        static internal void DrawEdge(Graphics graphics, DEdge dEdge, bool drawLabel)
        {
            DrawingEdge drawingEdge = dEdge.DrawingEdge;

            if (drawingEdge.Attr.GeometryEdge == null)
            {
                return;
            }

            if (dEdge.GraphicsPath == null)
            {
                Draw.CreateGraphicsPath(dEdge);
            }

            EdgeAttr attr = drawingEdge.Attr;

            using (Pen myPen = new Pen(dEdge.Color, attr.LineWidth)) {
                foreach (Style style in attr.Styles)
                {
                    Draw.AddStyleForPen(dEdge, myPen, style);
                }

                try {
                    graphics.DrawPath(myPen, dEdge.GraphicsPath);
                } catch {
                    //  sometimes on Vista it's just throws an out of memory exception without any obvious reason
                }
                Draw.DrawEdgeArrows(graphics, drawingEdge, dEdge.Color, myPen);
            }
            if (drawLabel)
            {
                Draw.DrawLabel(graphics, dEdge.Label);
            }
        }
Esempio n. 2
0
        internal static DGraph CreateDGraphAndGeometryInfo(DrawingGraph drawingGraph, GeometryGraph gleeGraph)
        {
            DGraph ret = new DGraph(drawingGraph);

            //create dnodes and glee node boundary curves
            foreach (GeometryNode geomNode in gleeGraph.NodeMap.Values)
            {
                DrawingNode drawingNode = geomNode.UserData as DrawingNode;
                CreateDNodeAndSetNodeBoundaryCurve(drawingGraph, ret, geomNode, drawingNode);
            }

            foreach (GeometryEdge gleeEdge in gleeGraph.Edges)
            {
                DEdge dEdge = new DEdge(ret.GetNode(gleeEdge.Source), ret.GetNode(gleeEdge.Target), gleeEdge.UserData as DrawingEdge, Connection.Connected);
                ret.AddEdge(dEdge);
                DrawingEdge drawingEdge             = dEdge.Edge;
                Microsoft.Msagl.Drawing.Label label = drawingEdge.Label;

                if (label != null)
                {
                    double width, height;
                    CreateDLabel(dEdge, label, out width, out height);
                }
            }

            return(ret);
        }
Esempio n. 3
0
        static BBNode BuildBBHierarchyUnderDObject(DObject dObject)
        {
            DNode dNode = dObject as DNode;

            if (dNode != null)
            {
                return(BuildBBHierarchyUnderDNode(dNode));
            }
            DEdge dedge = dObject as DEdge;

            if (dedge != null)
            {
                return(BuildBBHierarchyUnderDEdge(dedge));
            }
            DLabel dLabel = dObject as DLabel;

            if (dLabel != null)
            {
                return(BuildBBHierarchyUnderDLabel(dLabel));
            }

            DGraph dGraph = dObject as DGraph;

            if (dGraph != null)
            {
                dGraph.BbNode.bBox = dGraph.DrawingGraph.BoundingBox;
                return(dGraph.BbNode);
            }

            throw new InvalidOperationException();
        }
        internal static List <ObjectWithBox> TessellateCurve(DEdge dedge, double radiusForUnderlyingPolylineCorners)
        {
            DrawingEdge edge      = dedge.DrawingEdge;
            ICurve      bc        = edge.EdgeCurve;
            double      lineWidth = edge.Attr.LineWidth;
            var         ret       = new List <ObjectWithBox>();
            int         n         = 1;
            bool        done;

            do
            {
                double d = (bc.ParEnd - bc.ParStart) / n;
                done = true;
                if (n <= 64) //don't break a segment into more than 64 parts
                {
                    for (int i = 0; i < n; i++)
                    {
                        if (!WithinEpsilon(bc, d * i, d * (i + 1)))
                        {
                            n   *= 2;
                            done = false;
                            break;
                        }
                    }
                }
            } while (!done);

            double del = (bc.ParEnd - bc.ParStart) / n;

            for (int j = 0; j < n; j++)
            {
                var line = new Line(dedge, bc[del * j], bc[del * (j + 1)], lineWidth);
                ret.Add(line);
            }

            //if (dedge.Label != null)
            //    ret.Add(new LabelGeometry(dedge.Label, edge.Label.Left,
            //                              edge.Label.Bottom, new P2(edge.Label.Size.Width, edge.Label.Size.Height)));


            if (edge.Attr.ArrowAtTarget)
            {
                ret.Add(new Line(dedge, edge.EdgeCurve.End, edge.ArrowAtTargetPosition, edge.Attr.LineWidth));
            }


            if (edge.Attr.ArrowAtSource)
            {
                ret.Add(new Line(dedge, edge.EdgeCurve.Start, edge.ArrowAtSourcePosition, edge.Attr.LineWidth));
            }

            if (radiusForUnderlyingPolylineCorners > 0)
            {
                AddUnderlyingPolylineTessellation(ret, dedge, radiusForUnderlyingPolylineCorners);
            }

            return(ret);
        }
Esempio n. 5
0
        internal void DrawGraph(Graphics g)
        {
            #region drawing of database for debugging only

#if DEBUGGLEE
            Pen          myPen = new Pen(System.Drawing.Color.Blue, (float)(1 / 1000.0));
            DrawingGraph dg    = this.DrawingGraph;
            if (dg.DataBase != null)
            {
                Draw.DrawDataBase(g, myPen, dg);
            }

            bool debugDrawing = Draw.DrawDebugStuff(g, this, myPen);
            if (debugDrawing)
            {
                return;
            }
#endif
            #endregion

            if (this.drawingGraph.Attr.Border > 0)
            {
                DrawGraphBorder(this.drawingGraph.Attr.Border, g);
            }

            bool renderEdgeLabels = this.EdgeLabelsAreRendered;

            //we need to draw the edited edges last
            DEdge dEdgeSelectedForEditing = null;

            foreach (DEdge dEdge in Edges)
            {
                if (!dEdge.SelectedForEditing)
                {
                    DrawEdge(g, dEdge, renderEdgeLabels);
                }
                else //there must be no more than one edge selected for editing
                {
                    dEdgeSelectedForEditing = dEdge;
                }
            }

            foreach (DNode dnode in nodeMap.Values)
            {
                DrawNode(g, dnode);
            }


            //draw the selected edge
            if (dEdgeSelectedForEditing != null)
            {
                DrawEdge(g, dEdgeSelectedForEditing, renderEdgeLabels);
                DrawUnderlyingPolyline(g, dEdgeSelectedForEditing);
            }
        }
Esempio n. 6
0
        static BBNode BuildBBHierarchyUnderDEdge(DEdge dEdge)
        {
            if (dEdge.DrawingEdge.GeometryObject == null ||
                dEdge.Edge.GeometryEdge.Curve == null)
            {
                return(null);
            }
            List <ObjectWithBox> geometries = Tessellator.TessellateCurve(dEdge,
                                                                          dEdge.MarkedForDragging
                                                                                                                                                                                                                                                                                         ? dEdge.RadiusOfPolylineCorner
                                                                                                                                                                                                                                                                                         : 0);

            return(SpatialAlgorithm.CreateBBNodeOnGeometries(geometries));
        }
        static void AddUnderlyingPolylineTessellation(List <ObjectWithBox> list, DEdge edge,
                                                      double radiusForUnderlyingPolylineCorners)
        {
            var rad             = new P2(radiusForUnderlyingPolylineCorners, radiusForUnderlyingPolylineCorners);
            IEnumerator <P2> en = edge.DrawingEdge.GeometryEdge.UnderlyingPolyline.GetEnumerator();

            en.MoveNext();
            P2 p = en.Current;

            list.Add(new Geometry(edge, new BBox(p + rad, p - rad)));
            while (en.MoveNext())
            {
                list.Add(new Line(edge, p, p = en.Current, edge.DrawingEdge.Attr.LineWidth));
                list.Add(new Geometry(edge, new BBox(p + rad, p - rad)));
            }
        }
        internal static List<ObjectWithBox> TessellateCurve(DEdge dedge, double radiusForUnderlyingPolylineCorners) {
            DrawingEdge edge = dedge.DrawingEdge;
            ICurve bc = edge.EdgeCurve;
            double lineWidth = edge.Attr.LineWidth;
            var ret = new List<ObjectWithBox>();
            int n = 1;
            bool done;
            do {
                double d = (bc.ParEnd - bc.ParStart)/n;
                done = true;
                if (n <= 64) //don't break a segment into more than 64 parts
                    for (int i = 0; i < n; i++) {
                        if (!WithinEpsilon(bc, d*i, d*(i + 1))) {
                            n *= 2;
                            done = false;
                            break;
                        }
                    }
            } while (!done);

            double del = (bc.ParEnd - bc.ParStart)/n;

            for (int j = 0; j < n; j++) {
                var line = new Line(dedge, bc[del*j], bc[del*(j + 1)], lineWidth);
                ret.Add(line);
            }

            //if (dedge.Label != null)
            //    ret.Add(new LabelGeometry(dedge.Label, edge.Label.Left,
            //                              edge.Label.Bottom, new P2(edge.Label.Size.Width, edge.Label.Size.Height)));


            if (edge.Attr.ArrowAtTarget)
                ret.Add(new Line(dedge, edge.EdgeCurve.End, edge.ArrowAtTargetPosition, edge.Attr.LineWidth));


            if (edge.Attr.ArrowAtSource)
                ret.Add(new Line(dedge, edge.EdgeCurve.Start, edge.ArrowAtSourcePosition, edge.Attr.LineWidth));

            if (radiusForUnderlyingPolylineCorners > 0)
                AddUnderlyingPolylineTessellation(ret, dedge, radiusForUnderlyingPolylineCorners);

            return ret;
        }
Esempio n. 9
0
        static void DrawUnderlyingPolyline(Graphics g, DEdge editedEdge)
        {
            Microsoft.Msagl.UnderlyingPolyline points = editedEdge.DrawingEdge.Attr.GeometryEdge.UnderlyingPolyline;
            Pen pen             = new Pen(editedEdge.Color, editedEdge.DrawingEdge.Attr.LineWidth);
            IEnumerator <P2> en = points.GetEnumerator();

            en.MoveNext();
            PointF p = P2P(en.Current);

            while (en.MoveNext())
            {
                g.DrawLine(pen, p, p = P2P(en.Current));
            }

            foreach (P2 p2 in points)
            {
                DrawCircleAroungPolylineCorner(g, p2, pen, editedEdge.RadiusOfPolylineCorner);
            }
        }
Esempio n. 10
0
        internal static DGraph CreateDGraphAndGeometryInfo(Graph drawingGraph, GeometryGraph geometryGraph,
                                                           GViewer viewer)
        {
            var dGraph = new DGraph(drawingGraph, viewer);
            //create dnodes and glee node boundary curves
            var nodeMapping = new Dictionary <GeometryNode, DNode>();

            if (geometryGraph.RootCluster != null)
            {
                foreach (var geomCluster in geometryGraph.RootCluster.AllClustersDepthFirstExcludingSelf())
                {
                    var   drawingNode = (Drawing.Node)geomCluster.UserData;
                    DNode dNode       = CreateDNodeAndSetNodeBoundaryCurveForSubgraph(drawingGraph, dGraph, geomCluster,
                                                                                      drawingNode, viewer);
                    nodeMapping[geomCluster] = dNode;
                }
            }

            foreach (GeometryNode geomNode in geometryGraph.Nodes)
            {
                var   drawingNode = (Drawing.Node)geomNode.UserData;
                DNode dNode       = CreateDNodeAndSetNodeBoundaryCurve(drawingGraph, dGraph, geomNode, drawingNode, viewer);
                nodeMapping[geomNode] = dNode;
            }

            foreach (GeometryEdge gleeEdge in geometryGraph.Edges)
            {
                var dEdge = new DEdge(nodeMapping[gleeEdge.Source], nodeMapping[gleeEdge.Target],
                                      gleeEdge.UserData as DrawingEdge, ConnectionToGraph.Connected, viewer);
                dGraph.AddEdge(dEdge);
                DrawingEdge   drawingEdge = dEdge.Edge;
                Drawing.Label label       = drawingEdge.Label;

                if (label != null)
                {
                    double width, height;
                    CreateDLabel(dEdge, label, out width, out height, viewer);
                }
            }

            return(dGraph);
        }
Esempio n. 11
0
        static void DrawUnderlyingPolyline(Graphics g, DEdge editedEdge)
        {
            SmoothedPolyline underlyingPolyline = editedEdge.DrawingEdge.GeometryEdge.UnderlyingPolyline;

            if (underlyingPolyline != null)
            {
                var pen             = new Pen(editedEdge.Color, (float)editedEdge.DrawingEdge.Attr.LineWidth);
                IEnumerator <P2> en = underlyingPolyline.GetEnumerator();
                en.MoveNext();
                PointF p = P2P(en.Current);
                while (en.MoveNext())
                {
                    g.DrawLine(pen, p, p = P2P(en.Current));
                }

                foreach (P2 p2 in underlyingPolyline)
                {
                    DrawCircleAroungPolylineCorner(g, p2, pen, editedEdge.RadiusOfPolylineCorner);
                }
            }
        }
Esempio n. 12
0
        internal static void CreateGraphicsPath(DEdge dedge)
        {
            DrawingEdge edge = dedge.DrawingEdge;

            dedge.GraphicsPath = new GraphicsPath();

            Curve c = edge.Attr.EdgeCurve as Curve;

            if (c != null)
            {
                foreach (ICurve seg in c.Segments)
                {
                    CubicBezierSegment cubic = seg as CubicBezierSegment;
                    if (cubic != null)
                    {
                        dedge.GraphicsPath.AddBezier(PointF(cubic.B(0)), PointF(cubic.B(1)), PointF(cubic.B(2)), PointF(cubic.B(3)));
                    }
                    else
                    {
                        LineSegment ls = seg as LineSegment;
                        dedge.GraphicsPath.AddLine(PointF(ls.Start), PointF(ls.End));
                    }
                }
            }
            else
            {
                LineSegment ls = edge.Attr.EdgeCurve as LineSegment;
                if (ls != null)
                {
                    dedge.GraphicsPath.AddLine(PointF(ls.Start), PointF(ls.End));
                }
                else
                {
                    CubicBezierSegment seg = (CubicBezierSegment)edge.Attr.EdgeCurve;
                    dedge.GraphicsPath.AddBezier(PointF(seg.B(0)), PointF(seg.B(1)), PointF(seg.B(2)), PointF(seg.B(3)));
                }
            }
        }
Esempio n. 13
0
        IEnumerable <DObject> RelatedObjs(DObject dObj)
        {
            yield return(dObj);

            DNode dNode = dObj as DNode;

            if (dNode != null)
            {
                foreach (DEdge e in dNode.OutEdges)
                {
                    yield return(e);
                }
                foreach (DEdge e in dNode.InEdges)
                {
                    yield return(e);
                }
                foreach (DEdge e in dNode.SelfEdges)
                {
                    yield return(e);
                }
            }
            else
            {
                DEdge dEdge = dObj as DEdge;
                if (dEdge != null)
                {
                    yield return(dEdge.Source);

                    yield return(dEdge.Target);

                    if (dEdge.Label != null)
                    {
                        yield return(dEdge.Label);
                    }
                }
            }
        }
 internal void AddSelfEdge(DEdge edge) {
     selfEdges.Add(edge);
 }
Esempio n. 15
0
 void AddEdge(DEdge dEdge)
 {
     edges.Add(dEdge);
 }
 internal void RemoveOutEdge(DEdge de) {
     outEdges.Remove(de);
 }
 internal void RemoveInEdge(DEdge de) {
     inEdges.Remove(de);
 }
Esempio n. 18
0
 void AddEdge(DEdge dEdge){
     edges.Add(dEdge);
 }
Esempio n. 19
0
        internal static DGraph CreateDGraphAndGeometryInfo(Graph drawingGraph, GeometryGraph geometryGraph,
                                                           GViewer viewer) {
            var dGraph = new DGraph(drawingGraph, viewer);
            //create dnodes and glee node boundary curves
            var nodeMapping = new Dictionary<GeometryNode, DNode>();
            if (geometryGraph.RootCluster != null)
                foreach (var geomCluster in geometryGraph.RootCluster.AllClustersDepthFirstExcludingSelf()) {
                    var drawingNode = (Drawing.Node) geomCluster.UserData;
                    DNode dNode = CreateDNodeAndSetNodeBoundaryCurveForSubgraph(drawingGraph, dGraph, geomCluster,
                                                                                drawingNode, viewer);
                    nodeMapping[geomCluster] = dNode;
                }

            foreach (GeometryNode geomNode in geometryGraph.Nodes) {
                var drawingNode = (Drawing.Node) geomNode.UserData;
                DNode dNode = CreateDNodeAndSetNodeBoundaryCurve(drawingGraph, dGraph, geomNode, drawingNode, viewer);
                nodeMapping[geomNode] = dNode;
            }

            foreach (GeometryEdge gleeEdge in geometryGraph.Edges) {
                var dEdge = new DEdge(nodeMapping[gleeEdge.Source], nodeMapping[gleeEdge.Target],
                                      gleeEdge.UserData as DrawingEdge, ConnectionToGraph.Connected, viewer);
                dGraph.AddEdge(dEdge);
                DrawingEdge drawingEdge = dEdge.Edge;
                Drawing.Label label = drawingEdge.Label;

                if (label != null) {
                    double width, height;
                    CreateDLabel(dEdge, label, out width, out height, viewer);
                }
            }

            return dGraph;
        }
 internal void RemoveSelfEdge(DEdge de) {
     selfEdges.Remove(de);
 }
Esempio n. 21
0
 internal void RemoveInEdge(DEdge de)
 {
     inEdges.Remove(de);
 }
 internal void AddInEdge(DEdge edge) {
     inEdges.Add(edge);
 }
Esempio n. 23
0
        internal static void DrawEdge(Graphics graphics, DEdge dEdge)
        {
            DrawingEdge drawingEdge = dEdge.DrawingEdge;

            if (!drawingEdge.IsVisible || drawingEdge.GeometryEdge == null)
            {
                return;
            }


            DrawingEdge edge = dEdge.DrawingEdge;

            if (edge.DrawEdgeDelegate != null)
            {
                if (edge.DrawEdgeDelegate(edge, graphics))
                {
                    return;                     //the client draws instead
                }
            }
            if (dEdge.GraphicsPath == null)
            {
                dEdge.GraphicsPath = Draw.CreateGraphicsPath(dEdge.Edge.GeometryEdge.Curve);
            }

            EdgeAttr attr = drawingEdge.Attr;

            using (var myPen = new Pen(dEdge.Color, (float)attr.LineWidth))
            {
                foreach (Style style in attr.Styles)
                {
                    Draw.AddStyleForPen(dEdge, myPen, style);
                }
                try
                {
                    if (dEdge.GraphicsPath != null)
                    {
                        graphics.DrawPath(myPen, dEdge.GraphicsPath);
                    }
                }
                catch
                {
                    //  sometimes on Vista it throws an out of memory exception without any obvious reason
                }
                Draw.DrawEdgeArrows(graphics, drawingEdge, dEdge.Color, myPen);
                if (dEdge.DrawingEdge.GeometryEdge.Label != null)
                {
                    Draw.DrawLabel(graphics, dEdge.Label);
                }

#if TEST_MSAGL
                if (DrawControlPoints)
                {
                    ICurve iCurve = dEdge.DrawingEdge.GeometryEdge.Curve;
                    var    c      = iCurve as Curve;

                    if (c != null)
                    {
                        foreach (ICurve seg in c.Segments)
                        {
                            var cubic = seg as CubicBezierSegment;
                            if (cubic != null)
                            {
                                Draw.DrawControlPoints(graphics, cubic);
                            }
                        }
                    }
                    else
                    {
                        var seg = iCurve as CubicBezierSegment;
                        if (seg != null)
                        {
                            Draw.DrawControlPoints(graphics, seg);
                        }
                    }
                }
#endif
            }
        }
Esempio n. 24
0
        /// <summary>
        /// routes an edge and returns the corresponding edge of the viewer
        /// </summary>
        /// <returns></returns>
        public IViewerEdge RouteEdge(DrawingEdge drawingEdge)
        {
            drawingEdge.Label = new Label();
            Edge geometryEdge = drawingEdge.GeometryEdge = new Edge();
            if (drawingEdge.Attr.ArrowheadAtSource != ArrowStyle.NonSpecified &&
                drawingEdge.Attr.ArrowheadAtSource != ArrowStyle.None)
                geometryEdge.EdgeGeometry.SourceArrowhead = new Arrowhead {Length = drawingEdge.Attr.ArrowheadLength};
            if (drawingEdge.Attr.ArrowheadAtSource != ArrowStyle.None)
                geometryEdge.EdgeGeometry.TargetArrowhead = new Arrowhead {Length = drawingEdge.Attr.ArrowheadLength};

            geometryEdge.GeometryParent = Graph.GeometryGraph;
            geometryEdge.Source = drawingEdge.SourceNode.GeometryNode;
            geometryEdge.Target = drawingEdge.TargetNode.GeometryNode;
            geometryEdge.SourcePort = drawingEdge.SourcePort;
            geometryEdge.TargetPort = drawingEdge.TargetPort;
            LayoutHelpers.RouteAndLabelEdges(this.Graph.GeometryGraph, Graph.LayoutAlgorithmSettings,
                                             new[] {geometryEdge});

            var dEdge = new DEdge(DGraph.FindDNode(drawingEdge.SourceNode.Id), DGraph.FindDNode(drawingEdge.TargetNode.Id),
                                  drawingEdge, ConnectionToGraph.Disconnected, this);
            dEdge.Label = new DLabel(dEdge, new Label(), this);
            return dEdge;
        }
Esempio n. 25
0
        /// <summary>
        /// drawing edge already has its geometry in place
        /// </summary>
        /// <param name="drawingEdge"></param>
        /// <returns></returns>
        public IViewerEdge CreateEdgeWithGivenGeometry(DrawingEdge drawingEdge)
        {
            drawingEdge.Label = new Label();
            Edge geometryEdge = drawingEdge.GeometryEdge;
            Debug.Assert(geometryEdge != null);
            geometryEdge.GeometryParent = Graph.GeometryGraph;

            var dEdge = new DEdge(DGraph.FindDNode(drawingEdge.SourceNode.Id), DGraph.FindDNode(drawingEdge.TargetNode.Id),
                                  drawingEdge, ConnectionToGraph.Disconnected, this);
            dEdge.Label = new DLabel(dEdge, new Label(), this);
            return dEdge;
        }
Esempio n. 26
0
        internal void DrawGraph(Graphics g)
        {
            #region drawing of database for debugging only

#if TEST_MSAGL
            Graph dg = DrawingGraph;

            if (dg.DataBase != null)
            {
                var myPen = new Pen(Color.Blue, (float)(1 / 1000.0));
                Draw.DrawDataBase(g, myPen, dg);
            }

            if (NeedToDrawDebugStuff())
            {
                var myPen = new Pen(Color.Blue, (float)(1 / 1000.0));
                Draw.DrawDebugStuff(g, this, myPen);
            }
#endif

            #endregion

            if (drawingGraph.Attr.Border > 0)
            {
                DrawGraphBorder(drawingGraph.Attr.Border, g);
            }

            //we need to draw the edited edges last
            DEdge dEdgeSelectedForEditing = null;

            foreach (var subgraph in drawingGraph.RootSubgraph.AllSubgraphsWidthFirstExcludingSelf())
            {
                DrawNode(g, nodeMap[subgraph.Id]);
            }


            foreach (DEdge dEdge in Edges)
            {
                if (!dEdge.SelectedForEditing)
                {
                    DrawEdge(g, dEdge);
                }
                else                 //there must be no more than one edge selected for editing
                {
                    dEdgeSelectedForEditing = dEdge;
                }
            }


            foreach (DNode dnode in nodeMap.Values)
            {
                if (!(dnode.DrawingNode is Subgraph))
                {
                    DrawNode(g, dnode);
                }
            }

            //draw the selected edge
            if (dEdgeSelectedForEditing != null)
            {
                DrawEdge(g, dEdgeSelectedForEditing);
                DrawUnderlyingPolyline(g, dEdgeSelectedForEditing);
            }

            if (Viewer.SourcePortIsPresent)
            {
                DrawPortAtLocation(g, Viewer.SourcePortLocation);
            }
            if (Viewer.TargetPortIsPresent)
            {
                DrawPortAtLocation(g, Viewer.TargetPortLocation);
            }
        }
Esempio n. 27
0
 internal void AddOutEdge(DEdge edge)
 {
     outEdges.Add(edge);
 }
Esempio n. 28
0
        internal static void DrawEdge(Graphics graphics, DEdge dEdge){
            DrawingEdge drawingEdge = dEdge.DrawingEdge;
            if (!drawingEdge.IsVisible || drawingEdge.GeometryEdge == null)
                return;


            DrawingEdge edge = dEdge.DrawingEdge;
            if (edge.DrawEdgeDelegate != null)
                if (edge.DrawEdgeDelegate(edge, graphics))
                    return; //the client draws instead

            if (dEdge.GraphicsPath == null)
                dEdge.GraphicsPath = Draw.CreateGraphicsPath(dEdge.Edge.GeometryEdge.Curve);

            EdgeAttr attr = drawingEdge.Attr;

            using (var myPen = new Pen(dEdge.Color, (float)attr.LineWidth)){
                foreach (Style style in attr.Styles){
                    Draw.AddStyleForPen(dEdge, myPen, style);
                }
                try{
                    if (dEdge.GraphicsPath != null)
                        graphics.DrawPath(myPen, dEdge.GraphicsPath);
                }
                catch{
                    //  sometimes on Vista it throws an out of memory exception without any obvious reason
                }
                Draw.DrawEdgeArrows(graphics, drawingEdge, dEdge.Color, myPen);
                if (dEdge.DrawingEdge.GeometryEdge.Label != null)
                    Draw.DrawLabel(graphics, dEdge.Label);

#if TEST_MSAGL
                if (DrawControlPoints){
                    ICurve iCurve = dEdge.DrawingEdge.GeometryEdge.Curve;
                    var c = iCurve as Curve;

                    if (c != null){
                        foreach (ICurve seg in c.Segments){
                            var cubic = seg as CubicBezierSegment;
                            if (cubic != null)
                                Draw.DrawControlPoints(graphics, cubic);
                        }
                    }
                    else{
                        var seg = iCurve as CubicBezierSegment;
                        if (seg != null)
                            Draw.DrawControlPoints(graphics, seg);
                    }
                }

#endif
            }
        }
Esempio n. 29
0
 internal void AddSelfEdge(DEdge edge)
 {
     selfEdges.Add(edge);
 }
 internal void AddOutEdge(DEdge edge) {
     outEdges.Add(edge);
 }
Esempio n. 31
0
 internal void AddInEdge(DEdge edge)
 {
     inEdges.Add(edge);
 }
Esempio n. 32
0
 static BBNode BuildBBHierarchyUnderDEdge(DEdge dEdge){
     if (dEdge.DrawingEdge.GeometryObject == null ||
         dEdge.Edge.GeometryEdge.Curve == null)
         return null;
     List<ObjectWithBox> geometries = Tessellator.TessellateCurve(dEdge,
                                                                  dEdge.MarkedForDragging
                                                                      ? dEdge.RadiusOfPolylineCorner
                                                                      : 0);
     return SpatialAlgorithm.CreateBBNodeOnGeometries(geometries);
 }
Esempio n. 33
0
 internal void RemoveOutEdge(DEdge de)
 {
     outEdges.Remove(de);
 }
Esempio n. 34
0
        static void DrawUnderlyingPolyline(Graphics g, DEdge editedEdge){
            SmoothedPolyline underlyingPolyline = editedEdge.DrawingEdge.GeometryEdge.UnderlyingPolyline;
            if (underlyingPolyline != null){
                var pen = new Pen(editedEdge.Color, (float)editedEdge.DrawingEdge.Attr.LineWidth);
                IEnumerator<P2> en = underlyingPolyline.GetEnumerator();
                en.MoveNext();
                PointF p = P2P(en.Current);
                while (en.MoveNext())
                    g.DrawLine(pen, p, p = P2P(en.Current));

                foreach (P2 p2 in underlyingPolyline)
                    DrawCircleAroungPolylineCorner(g, p2, pen, editedEdge.RadiusOfPolylineCorner);
            }
        }
Esempio n. 35
0
 internal void RemoveSelfEdge(DEdge de)
 {
     selfEdges.Remove(de);
 }
 static void AddUnderlyingPolylineTessellation(List<ObjectWithBox> list, DEdge edge,
                                               double radiusForUnderlyingPolylineCorners) {
     var rad = new P2(radiusForUnderlyingPolylineCorners, radiusForUnderlyingPolylineCorners);
     IEnumerator<P2> en = edge.DrawingEdge.GeometryEdge.UnderlyingPolyline.GetEnumerator();
     en.MoveNext();
     P2 p = en.Current;
     list.Add(new Geometry(edge, new BBox(p + rad, p - rad)));
     while (en.MoveNext()) {
         list.Add(new Line(edge, p, p = en.Current, edge.DrawingEdge.Attr.LineWidth));
         list.Add(new Geometry(edge, new BBox(p + rad, p - rad)));
     }
 }