Hello,
I have 2 nodes, and wanted to make 2 links between them... A->B and B->A. For the lines are not one on top of another, as do I draw them as a semi-circle?
Thanks!
function TGraphLink.CheckExistingArc(FromNode, ToNode: TGraphNode): TGraphLink;
var I: Integer;
begin
Result:=nil;
if not Assigned(FromNode) or not Assigned(ToNode) then exit;
for I:=0 to ToNode.LinkInputList.count-1 do begin
if (ToNode.LinkInputs[I].Source=FromNode)
then Result:=TGraphLink(ToNode.LinkInputs[I]);
end;
end;
procedure TGraphLink.MouseUp(Button: TMouseButton; Shift: TShiftState; const Pt: TPoint);
var
ExistingArc: TGraphLink;
begin
if not Dragging or (Button <> mbRight) or (ChangeMode <> lcmMovePoint) then
begin
inherited MouseUp(Button, Shift, Pt);
if (ChangeMode = lcmMovePoint) then begin
ExistingArc := CheckExistingArc(TGraphNode(Self.Source),TGraphNode(HookingObject));
if ExistingArc = nil
then begin
ExistingArc := CheckExistingArc(TGraphNode(HookingObject),TGraphNode(Self.Source));
if ExistingArc<>nil then begin
//Reverse Direction here
if (ExistingArc.Kind=akReverseDirected) then begin
ExistingArc.Weight:=ExistingArc.Weight+1;
end
else if (ExistingArc.Weight=1) and (ExistingArc.Kind=akDirected) then begin
ExistingArc.Kind:=akBiDirected;
end
else if (ExistingArc.Weight=1) and (ExistingArc.Kind=akBiDirected) then begin
ExistingArc.Kind:=akReverseDirected;
end
else if (ExistingArc.Kind=akDirected) then begin
ExistingArc.Weight:=ExistingArc.Weight-1;
end;
//------------------------
end;
end
else begin
//Forward Direction here
if (ExistingArc.Kind=akDirected) then begin
ExistingArc.Weight:=ExistingArc.Weight+1;
end
else if (ExistingArc.Weight=1) and (ExistingArc.Kind=akReverseDirected) then begin
ExistingArc.Kind:=akBidirected;
end
else if (ExistingArc.Weight=1) and (ExistingArc.Kind=akBiDirected) then begin
ExistingArc.Kind:=akDirected;
end
else if (ExistingArc.Kind=akReverseDirected) then begin
ExistingArc.Weight:=ExistingArc.Weight-1;
end;
//------------------------
end;
if AcceptingHook and not Assigned(ExistingArc)
then begin
Hook(MovingPoint, HookingObject);
fPrevHookingObject := Target;
fPrevSourceObject := Source;
fHooked := true;
end
else begin
if not fHooked then Delete
else if Target<>fPrevHookingObject then begin
Hook(MovingPoint, fPrevHookingObject);
end
else if Source<>fPrevSourceObject then begin
Hook(fMovingPoint, fPrevSourceObject);
end;
end;
end;
fMovingPoint := -1;
fHookingObject := nil;
fAcceptingHook := False;
ChangeMode := lcmNone;
end;
end;
Return to DELPHI AREA Projects
Users browsing this forum: No registered users and 0 guests