From: Marco W. <in...@ca...> - 2005-02-23 08:46:19
|
Hi guys, My first real need and adjustment to the code is the being able to influence the drawing order of the GraphObjects. For this to work I've done the following: * Introduced a new TDrawObjectOrder enumeration (ooZOrder, ooLinksFirst, ooNodesFirst) * Added a published property DrawObjectOrder (default value ooLinksFirst for backward compatible behaviour) * Rewritten the TSimpleGraph.Draw method a little. Below is a small snippet to show you how this influences the drawing of GraphObjects, you can compare it to the existing code in this method which always draws links first and the other objects on top of that. However this ignores the ZOrder and the need for it to happen the other way around (as it does in my case). Hope to write about more changes I've made and add even more usable changes soon... Regards, Marco. procedure TSimpleGraph.Draw(Canvas: TCanvas); var I: Integer; (* MW *) procedure DrawObjects(aType: TDrawObjects); var i: integer; begin for I := 0 to Objects.Count - 1 do with Objects[I] do if (aType = doAll) or (IsLink and (aType = doLinks)) or (not IsLink and (aType = doNodes)) then Draw(Canvas); end; begin (* MW *) case DrawObjectOrder of ooNodesFirst: DrawObjects(doNodes); ooLinksFirst: DrawObjects(doLinks); end; if Linking and ((State = gsMoveLink) or ((CommandMode = cmLinkNodes) and (FirstNodeOfLink <> nil))) then begin Canvas.Pen.Mode := pmNot; Canvas.Pen.Width := 1; Canvas.Pen.Style := psSolid; DefaultLinkClass.DrawDraft(Canvas, Rect(StartPoint.X, StartPoint.Y, StopPoint.X, StopPoint.Y)); end; (* MW *) case DrawObjectOrder of ooNodesFirst: DrawObjects(doLinks); ooLinksFirst: DrawObjects(doNodes); else DrawObjects(doAll); end; if Linking and (CommandMode = cmLinkNodes) and (FirstNodeOfLink <> nil) then ... ... |