microsoft / microsoft/automatic-graph-layout

Microsoft.Msagl.GraphViewerGdi.GViewer.CreateEdgeWithGivenGeometry() is losing Label

Open
#35 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
1.5k
Forks
319
Avg merge
38m
Merged PRs (30d)
1

Description

Microsoft.Msagl.GraphViewerGdi.GViewer.CreateEdgeWithGivenGeometry(DrawingEdge drawingEdge) { drawingEdge.Label = new Label(); (...)

This makes us lose the Label.Text passed. I've corrected it:

    public IViewerEdge CreateEdgeWithGivenGeometry(DrawingEdge drawingEdge)
    {
        //ADAC: protect parameter Label 
        if (drawingEdge.Label == null)
            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);
        //ADAC: use parameter Label
        //dEdge.Label = new DLabel(dEdge, new Label(), this);
        dEdge.Label = new DLabel(dEdge, drawingEdge.Label, this);
        return dEdge;
    }

but when using:

                    Microsoft.Msagl.Drawing.Edge dEdge = this.fGViewer.AddEdge(nodeFound.Node, node1, false);
                    dEdge.LabelText = ete.LabelText;
                    dEdge.Attr.Color = ete.Color;
                    dEdge.UserData = ete.UserData;
                    //(...)
                    if (OnEdgeAdding != null)
                        OnEdgeAdding(dEdge);

                    fGViewer.CreateEdgeWithGivenGeometry(dEdge);
                    fGViewer.SetEdgeLabel(dEdge, dEdge.Label);

The edge is created but the label is still not present.
Well, I'll have to really study the code to be able to use it. Its object hierarchy is not easy...

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with GViewer.CreateEdgeWithGivenGeometry(DrawingEdge) and trace the shown AddEdge, CreateEdgeWithGivenGeometry, and SetEdgeLabel call sequence. Inspect how drawingEdge.Label, LabelText, and the created edge's label are propagated; done means the label text passed to AddEdge remains present on the created edge.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
computer-graphics, desktop-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.