English 中文(简体)
QuickGraph GraphvizRecord doesn t display in vertices
原标题:

I m trying to build a Graphviz graph containing record vertices using QuickGraph. So far, I have this:

var algo = new GraphvizAlgorithm<Entity, EntityEdge>(this);
algo.CommonVertexFormat.Shape = GraphvizVertexShape.Record;
algo.CommonVertexFormat.Style = GraphvizVertexStyle.Filled;
algo.FormatVertex += new FormatVertexEventHandler<Entity>(FormatVertex);

private void FormatVertex(object sender, FormatVertexEventArgs<Entity> e) {
    Entity ent = e.Vertex;
    GraphvizRecord rec = new GraphvizRecord();

    GraphvizRecordCell rootCell = new GraphvizRecordCell();
    rootCell.Text = ent.ClassName + "\n" + ent.TargetName;

    var inputs = ent.GetUniqueInputNames();

    foreach (string input in inputs) {
        GraphvizRecordCell cell = new GraphvizRecordCell();
        cell.Text = input;
        cell.Port = input;
        rootCell.Cells.Add(cell);
    }

    rec.Cells.Add(rootCell);

    e.VertexFormatter.Record = rec;
}

When I generate the graph, however, the vertices show a label instead of a record. What am I doing wrong?

EDIT

Here s the dot output.

digraph G {
    bgcolor="#454545FF"
    node [fillcolor="#505050FF", color="#2A2A2AFF", shape=record, fontname="Verdana",  fontsize=10, label="", style=filled, fontcolor="#FFFFFFFF"];
    edge [ fontsize=10, fontcolor="#FFFFFFFF", color="#ECA706FF", fontname="Verdana"];
    0 [label="EntityMap.Entity"];
    1 [label="EntityMap.Entity"];
    2 [label="EntityMap.Entity"];
    3 [label="EntityMap.Entity"];
    4 [label="EntityMap.Entity"];
    5 [label="EntityMap.Entity"];
    6 [label="EntityMap.Entity"];
    7 [label="EntityMap.Entity"];
    8 [label="EntityMap.Entity"];
    9 [label="EntityMap.Entity"];
    10 [label="EntityMap.Entity"];
    11 [label="EntityMap.Entity"];
    12 [label="EntityMap.Entity"];
    13 [label="EntityMap.Entity"];
    14 [label="EntityMap.Entity"];
    15 [label="EntityMap.Entity"];
    0 -> 0 [ label="OnPlayerUse", headport="EnableMotion", headlabel=""];
    0 -> 1 [ label="OnPlayerUse", headport="Explode", headlabel=""];
    0 -> 6 [ label="OnPlayerUse", headport="Compare", headlabel=""];
    0 -> 5 [ label="OnPlayerUse", headport="RevertToDefaultRelationship", headlabel=""];
    3 -> 4 [ label="OnTrigger", headport="Wake", headlabel=""];
    4 -> 2 [ label="OnFoundEnemy", headport="Display", headlabel=""];
    6 -> 15 [ label="OnEqualTo", headport="EmitAISound", headlabel=""];
    6 -> 4 [ label="OnEqualTo", headport="Wake", headlabel=""];
    7 -> 8 [ label="OnStartTouch", headport="Command", headlabel="+duck"];
    7 -> 8 [ label="OnEndTouch", headport="Command", headlabel="-duck"];
    7 -> 9 [ label="OnEndTouch", headport="Enable", headlabel=""];
    7 -> 10 [ label="OnEndTouch", headport="Fade", headlabel=""];
    7 -> 7 [ label="OnEndTouch", headport="Disable", headlabel=""];
    12 -> 11 [ label="OnMapSpawn", headport="Fade", headlabel=""];
    13 -> 6 [ label="OnPass", headport="SetValue", headlabel="1"];
    14 -> 6 [ label="OnPass", headport="SetValue", headlabel="1"];
}
问题回答

There are details missing in the root cells, specifically the names of the object methods. I guess the dotoutput line

0 [label="EntityMap.Entity"];

...should really be:

0 [label="<EnableMotion> EntityMap.Entity"];

(...and I guess they shouldn t all be named EntityMap.Entity?)

I cannot really tell where in your program the edges are introduced, but it seems like the edges are rendered based on different information than the vertices.

Running dot manually (dot foo.dot -Tpng -o foo.png) might give you more informative error/warning messages.





相关问题
C#和WPF从媒体记录录像

我的申请将HLSL的沙分效应适用于使用矫正器的媒体。 我如何实时记录和拯救经过修改的录像?

ocaml record type and null

I m trying to define type like: type aaa = NULL | {a: int; b: int};; But the compiler does not allow to do it. I m not sure of the reason why we can t mix record type with anything else. I need to ...

QuickGraph GraphvizRecord doesn t display in vertices

I m trying to build a Graphviz graph containing record vertices using QuickGraph. So far, I have this: var algo = new GraphvizAlgorithm<Entity, EntityEdge>(this); algo.CommonVertexFormat.Shape =...

QSqlTableModel.insertRecord() is very slow

I am using PyQt to insert records into a MySQL database. the code basically looks like self.table = QSqlTableModel() self.table.setTable( mytable ) while True: rec = self.table.record() values = ...

delphi records and c structs

Task: Application written in Delphi accepts a structure (record in terms of Delphi) of three fields. I can send the pointer of this structure using SendMessage (Win32 API) function. So a question is:...

C#: Record and Playback GUI Events

how can i record and playback mouse and keybaord events. i need this to capture the user interactions with my application so that later on i can play to see what user did.

热门标签