mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-05-31 08:32:35 +02:00
cody: unit dependencies: colors
git-svn-id: trunk@40040 -
This commit is contained in:
parent
d1e28f34f8
commit
60df8c91d5
@ -95,7 +95,7 @@ type
|
||||
TUsesGraph = class
|
||||
private
|
||||
FFiles: TAVLTree; // tree of TUGUnit sorted for Filename
|
||||
FStartFiles: TAVLTree; // tree of TUGUnit sorted for Filename
|
||||
FQueuedFiles: TAVLTree; // tree of TUGUnit sorted for Filename
|
||||
FTargetAll: boolean;
|
||||
FTargetFiles: TAVLTree; // tree of TUGUnit sorted for Filename
|
||||
FTargetDirsValid: boolean;
|
||||
@ -122,8 +122,8 @@ type
|
||||
function UnitCanFindTarget(ExpFilename: string): boolean;
|
||||
function IsTargetDir(ExpDir: string): boolean;
|
||||
|
||||
property FilesTree: TAVLTree read FFiles; // tree of TUGUnit sorted for Filename
|
||||
property StartFilesTree: TAVLTree read FStartFiles; // tree of TUGUnit sorted for Filename
|
||||
property FilesTree: TAVLTree read FFiles; // tree of TUGUnit sorted for Filename (all parsed)
|
||||
property QueuedFilesTree: TAVLTree read FQueuedFiles; // tree of TUGUnit sorted for Filename
|
||||
property TargetFilesTree: TAVLTree read FTargetFiles; // tree of TUGUnit sorted for Filename
|
||||
property TargetAll: boolean read FTargetAll write FTargetAll;
|
||||
end;
|
||||
@ -229,14 +229,14 @@ end;
|
||||
constructor TUsesGraph.Create;
|
||||
begin
|
||||
FFiles:=TAVLTree.Create(@CompareUGUnitFilenames);
|
||||
FStartFiles:=TAVLTree.Create(@CompareUGUnitFilenames);
|
||||
FQueuedFiles:=TAVLTree.Create(@CompareUGUnitFilenames);
|
||||
FTargetFiles:=TAVLTree.Create(@CompareUGUnitFilenames);
|
||||
end;
|
||||
|
||||
destructor TUsesGraph.Destroy;
|
||||
begin
|
||||
Clear;
|
||||
FreeAndNil(FStartFiles);
|
||||
FreeAndNil(FQueuedFiles);
|
||||
FreeAndNil(FTargetFiles);
|
||||
FreeAndNil(FFiles);
|
||||
inherited Destroy;
|
||||
@ -244,7 +244,7 @@ end;
|
||||
|
||||
procedure TUsesGraph.Clear;
|
||||
begin
|
||||
FStartFiles.Clear; // all files of StartFiles are in Files too
|
||||
FQueuedFiles.Clear; // all files of StartFiles are in Files too
|
||||
FTargetFiles.Clear; // all files of TargetFiles are in Files too
|
||||
FFiles.FreeAndClear;
|
||||
end;
|
||||
@ -256,17 +256,17 @@ var
|
||||
begin
|
||||
if FFiles.ConsistencyCheck<>0 then
|
||||
raise Exception.Create('FFiles.ConsistencyCheck');
|
||||
if FStartFiles.ConsistencyCheck<>0 then
|
||||
if FQueuedFiles.ConsistencyCheck<>0 then
|
||||
raise Exception.Create('FStartFiles.ConsistencyCheck');
|
||||
|
||||
AVLNode:=FStartFiles.FindLowest;
|
||||
AVLNode:=FQueuedFiles.FindLowest;
|
||||
while AVLNode<>nil do begin
|
||||
AnUnit:=TUGUnit(AVLNode.Data);
|
||||
if AnUnit.Filename='' then
|
||||
raise Exception.Create('AnUnit without filename');
|
||||
if FFiles.FindKey(PChar(AnUnit.Filename),@CompareFilenameAndUGUnit)=nil then
|
||||
raise Exception.Create('startfile not in files: '+AnUnit.Filename);
|
||||
AVLNode:=FStartFiles.FindSuccessor(AVLNode);
|
||||
AVLNode:=FQueuedFiles.FindSuccessor(AVLNode);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -296,19 +296,19 @@ var
|
||||
NewUnit: TUGUnit;
|
||||
begin
|
||||
if ExpFilename='' then exit;
|
||||
if FStartFiles.FindKey(PChar(ExpFilename),@CompareFilenameAndUGUnit)<>nil then
|
||||
if FQueuedFiles.FindKey(PChar(ExpFilename),@CompareFilenameAndUGUnit)<>nil then
|
||||
exit; // already a start file
|
||||
NewUnit:=GetUnit(ExpFilename,true);
|
||||
if ugufReached in NewUnit.Flags then exit; // already parsed
|
||||
// add to FFiles and FStartFiles
|
||||
// add to FFiles and FQueuedFiles
|
||||
//debugln(['TUsesGraph.AddStartUnit ',ExpFilename]);
|
||||
FStartFiles.Add(NewUnit);
|
||||
FQueuedFiles.Add(NewUnit);
|
||||
end;
|
||||
|
||||
procedure TUsesGraph.AddTargetUnit(ExpFilename: string);
|
||||
begin
|
||||
if ExpFilename='' then exit;
|
||||
if FStartFiles.FindKey(PChar(ExpFilename),@CompareFilenameAndUGUnit)<>nil then
|
||||
if FQueuedFiles.FindKey(PChar(ExpFilename),@CompareFilenameAndUGUnit)<>nil then
|
||||
exit; // already a start file
|
||||
// add to FFiles and FTargetFiles
|
||||
//debugln(['TUsesGraph.AddTargetUnit ',ExpFilename]);
|
||||
@ -428,10 +428,10 @@ begin
|
||||
StartTime:=Now
|
||||
else
|
||||
StartTime:=0;
|
||||
while FStartFiles.Count>0 do begin
|
||||
AVLNode:=FStartFiles.FindLowest;
|
||||
while FQueuedFiles.Count>0 do begin
|
||||
AVLNode:=FQueuedFiles.FindLowest;
|
||||
CurUnit:=TUGUnit(AVLNode.Data);
|
||||
FStartFiles.Delete(AVLNode);
|
||||
FQueuedFiles.Delete(AVLNode);
|
||||
Include(CurUnit.Flags,ugufReached);
|
||||
//debugln(['TUsesGraph.Parse Unit=',CurUnit.Filename,' UnitCanFindTarget=',UnitCanFindTarget(CurUnit.Filename)]);
|
||||
if UnitCanFindTarget(CurUnit.Filename) then begin
|
||||
|
@ -12,12 +12,12 @@ uses
|
||||
|
||||
resourcestring
|
||||
a='';
|
||||
rsSelectAUnit = 'Select a unit';
|
||||
rsSelectAUnit = 'Select an unit';
|
||||
rsClose = 'Close';
|
||||
|
||||
const
|
||||
FullCircle16 = 360*16;
|
||||
DefaultCategoryGapDegree16 = 0.04*FullCircle16;
|
||||
DefaultCategoryGapDegree16 = 0.02*FullCircle16;
|
||||
DefaultFirstCategoryDegree16 = 0;
|
||||
DefaultCategoryMinSize = 1.0;
|
||||
DefaultItemSize = 1.0;
|
||||
@ -406,6 +406,7 @@ var
|
||||
Cat: TCircleDiagramCategory;
|
||||
begin
|
||||
Cat:=Categories[i];
|
||||
Canvas.Brush.Color:=Cat.Color;
|
||||
RingSector(Canvas,Center.X-OuterRadius,Center.Y-OuterRadius,
|
||||
Center.X+OuterRadius,Center.Y+OuterRadius,
|
||||
single(InnerRadius)/single(OuterRadius),
|
||||
@ -486,7 +487,7 @@ begin
|
||||
,aSize.cx,aSize.cy);
|
||||
|
||||
// radius
|
||||
fInnerRadius:=0.5*Min(ClientWidth,ClientHeight);
|
||||
fInnerRadius:=0.25*Min(ClientWidth,ClientHeight);
|
||||
fOuterRadius:=1.1*InnerRadius;
|
||||
|
||||
// degrees
|
||||
@ -756,10 +757,15 @@ begin
|
||||
with CurUnitDiagram do begin
|
||||
Name:='CurUnitDiagram';
|
||||
Align:=alClient;
|
||||
fCircleCategories[uddutInterfaceUses]:=AddCategory('Interface uses');
|
||||
fCircleCategories[uddutImplementationUses]:=AddCategory('Implementation uses');
|
||||
FirstCategoryDegree16:=90*16;
|
||||
fCircleCategories[uddutUsedByInterface]:=AddCategory('Used by interfaces');
|
||||
fCircleCategories[uddutUsedByInterface].Color:=clOlive;
|
||||
fCircleCategories[uddutUsedByImplementation]:=AddCategory('Used by implementations');
|
||||
fCircleCategories[uddutUsedByImplementation].Color:=clMaroon;
|
||||
fCircleCategories[uddutImplementationUses]:=AddCategory('Implementation');
|
||||
fCircleCategories[uddutImplementationUses].Color:=clRed;
|
||||
fCircleCategories[uddutInterfaceUses]:=AddCategory('Interface');
|
||||
fCircleCategories[uddutInterfaceUses].Color:=clGreen;
|
||||
CenterCaption:=rsSelectAUnit;
|
||||
Parent:=Self;
|
||||
end;
|
||||
@ -842,22 +848,24 @@ procedure TUnitDependenciesDialog.UpdateCurUnitDiagram;
|
||||
s: String;
|
||||
begin
|
||||
Cnt:=0;
|
||||
for i:=0 to List.Count-1 do begin
|
||||
CurUses:=TUGUses(List[i]);
|
||||
if CurUses.InImplementation<>(t in [uddutImplementationUses,uddutUsedByImplementation])
|
||||
then continue;
|
||||
if t in [uddutInterfaceUses,uddutImplementationUses] then
|
||||
CurUnit:=CurUses.Owner
|
||||
else
|
||||
CurUnit:=CurUses.UsesUnit;
|
||||
s:=ExtractFileName(CurUnit.Filename);
|
||||
debugln(['UpdateCircleCategory ',s,' ',dbgs(t)]);
|
||||
if fCircleCategories[t].Count>Cnt then begin
|
||||
Item:=fCircleCategories[t].Items[Cnt];
|
||||
Item.Caption:=s
|
||||
end else
|
||||
Item:=fCircleCategories[t].AddItem(s);
|
||||
inc(Cnt);
|
||||
if List<>nil then begin
|
||||
for i:=0 to List.Count-1 do begin
|
||||
CurUses:=TUGUses(List[i]);
|
||||
if CurUses.InImplementation<>(t in [uddutImplementationUses,uddutUsedByImplementation])
|
||||
then continue;
|
||||
if t in [uddutInterfaceUses,uddutImplementationUses] then
|
||||
CurUnit:=CurUses.Owner
|
||||
else
|
||||
CurUnit:=CurUses.UsesUnit;
|
||||
s:=ExtractFileName(CurUnit.Filename);
|
||||
debugln(['UpdateCircleCategory ',s,' ',dbgs(t)]);
|
||||
if fCircleCategories[t].Count>Cnt then begin
|
||||
Item:=fCircleCategories[t].Items[Cnt];
|
||||
Item.Caption:=s
|
||||
end else
|
||||
Item:=fCircleCategories[t].AddItem(s);
|
||||
inc(Cnt);
|
||||
end;
|
||||
end;
|
||||
while fCircleCategories[t].Count>Cnt do
|
||||
fCircleCategories[t].Items[Cnt].Free;
|
||||
|
Loading…
Reference in New Issue
Block a user