cody: lvlgraph: more level space for broader levels

git-svn-id: trunk@40450 -
This commit is contained in:
mattias 2013-02-28 22:14:47 +00:00
parent 68ce7a5e9a
commit 7fb6dd6a8f

View File

@ -738,17 +738,20 @@ type
procedure LvlGraphMinimizeCrossings(Graph: TLvlGraph); procedure LvlGraphMinimizeCrossings(Graph: TLvlGraph);
var var
g: TMinXGraph; g: TMinXGraph;
{%H-}Run: int64;
begin begin
if (Graph.LevelCount<2) or (Graph.NodeCount<3) then exit; if (Graph.LevelCount<2) or (Graph.NodeCount<3) then exit;
g:=TMinXGraph.Create(Graph); g:=TMinXGraph.Create(Graph);
try try
if length(g.Pairs)=0 then exit; if length(g.Pairs)=0 then exit;
g.InitSearch; g.InitSearch;
Run:=0;
debugln(['LvlGraphMinimizeCrossings Graph.NodeCount=',Graph.NodeCount]); debugln(['LvlGraphMinimizeCrossings Graph.NodeCount=',Graph.NodeCount]);
{$IFDEF CheckMinXGraph}
g.SwitchAndShuffle(100*Graph.NodeCount, g.SwitchAndShuffle(100*Graph.NodeCount,
Min(10000,Graph.NodeCount*Graph.NodeCount)); Min(10000,Graph.NodeCount*Graph.NodeCount));
{$ELSE}
g.SwitchAndShuffle(100*Graph.NodeCount,
Min(100000,Graph.NodeCount*Graph.NodeCount));
{$ENDIF}
g.Apply; g.Apply;
finally finally
g.Free; g.Free;
@ -1849,11 +1852,11 @@ begin
if not Node.Visible then if not Node.Visible then
x1+=NodeStyle.Width div 2; x1+=NodeStyle.Width div 2;
if TargetNode.Visible then if TargetNode.Visible then
x2+=NodeStyle.Width div 2 x2+=NodeStyle.Width
else else
x2+=NodeStyle.Width div 2; x2+=NodeStyle.Width div 2;
Canvas.Pen.Color:=clRed; Canvas.Pen.Color:=clRed;
Canvas.Line(x1,y1,x2+NodeStyle.Width,y2); Canvas.Line(x1,y1,x2,y2);
end; end;
end; end;
end; end;
@ -2061,8 +2064,8 @@ begin
SetLength(LevelTxtWidths,Graph.LevelCount); SetLength(LevelTxtWidths,Graph.LevelCount);
for i:=0 to Graph.LevelCount-1 do begin for i:=0 to Graph.LevelCount-1 do begin
// compute needed width of the level // compute needed width of the level
LevelTxtWidths[i]:=Max(NodeStyle.Width,Canvas.TextWidth('NodeX'));
Level:=Graph.Levels[i]; Level:=Graph.Levels[i];
LevelTxtWidths[i]:=Max(NodeStyle.Width,Canvas.TextWidth('NodeX'+StringOfChar('j',Min(20,Level.Count))));
for j:=0 to Level.Count-1 do for j:=0 to Level.Count-1 do
if Level[j].Visible then if Level[j].Visible then
LevelTxtWidths[i]:=Max(LevelTxtWidths[i], Canvas.TextWidth(Level[j].Caption)); LevelTxtWidths[i]:=Max(LevelTxtWidths[i], Canvas.TextWidth(Level[j].Caption));
@ -2695,7 +2698,7 @@ begin
Edge:=SourceNode.OutEdges[e]; Edge:=SourceNode.OutEdges[e];
TargetNode:=Edge.Target; TargetNode:=Edge.Target;
if TargetNode.Level.Index-SourceNode.Level.Index<=1 then continue; if TargetNode.Level.Index-SourceNode.Level.Index<=1 then continue;
debugln(['TLvlGraph.SplitLongEdges long edge: ',SourceNode.Caption,' ',TargetNode.Caption]); //debugln(['TLvlGraph.SplitLongEdges long edge: ',SourceNode.Caption,' ',TargetNode.Caption]);
Weight:=Edge.Weight; Weight:=Edge.Weight;
// remove long edge // remove long edge
Edge.Free; Edge.Free;
@ -2730,7 +2733,7 @@ begin
Edge:=TargetNode.InEdges[e]; Edge:=TargetNode.InEdges[e];
SourceNode:=Edge.Source; SourceNode:=Edge.Source;
if TargetNode.Level.Index-SourceNode.Level.Index<=1 then continue; if TargetNode.Level.Index-SourceNode.Level.Index<=1 then continue;
debugln(['TLvlGraph.SplitLongEdges long edge: ',SourceNode.Caption,' ',TargetNode.Caption]); //debugln(['TLvlGraph.SplitLongEdges long edge: ',SourceNode.Caption,' ',TargetNode.Caption]);
Weight:=Edge.Weight; Weight:=Edge.Weight;
// remove long edge // remove long edge
Edge.Free; Edge.Free;