Page 1 of 1

Simple Graph Demo - Link/Line length

PostPosted: February 7th, 2009, 10:27 am
by Athabasca
Hello Kambiz,

I have a problem in the Simple Graph Demo:
A Link/Line placed on startpoint X=1 or Y=1 can no longer be reduced by select the endpoint.

Can you help?

I use Version 2.72

Re: Simple Graph Demo - Link/Line length

PostPosted: February 7th, 2009, 10:11 pm
by Kambiz
I took a look at the bug and found its origin. But it is not easy to fix because needs some major changes on logic behind dragging.

Re: Simple Graph Demo - Link/Line length

PostPosted: February 21st, 2009, 2:58 pm
by madfish
you can fix this problem by modify the code as following:

Code: Select all
procedure TSimpleGraph.PerformDragBy(dX, dY: Integer);
var
  I: Integer;
  Mobility: TObjectSides;
  MinX, MinY: Integer; // by qlg
begin
  if Assigned(DragSource) and ((dX <> 0) or (dY <> 0)) then
  begin
    Mobility := [];
    for I := 0 to DraggingObjects.Count - 1 do
      Mobility := Mobility + DraggingObjects[I].QueryMobility(DragHitTest);
    GraphConstraints.SourceRect := DraggingBounds;
    //------------------ commented by qlg begin
    //if not GraphConstraints.ConfineOffset(dX, dY, Mobility) then
    //  Exit;
    //------------------ commented by qlg end
    BeginUpdate;
    try
      MinX := 0;
      MinY := 0;
      for I := 0 to DraggingObjects.Count - 1 do
      begin
        DraggingObjects[I].OffsetHitTest(DragHitTest, dX, dY);
        MinX := Min(MinX, DraggingObjects[I].BoundsRect.Left); // added by qlg
        MinY := Min(MinY, DraggingObjects[I].BoundsRect.Top);  // added by qlg
      end;

      //------------------by qlg begin
      if (MinX < 0) and (MinY < 0) then
        for I := 0 to Objects.Count - 1 do
          Objects[I].OffsetHitTest(GHT_BODY_MASK, -MinX, -MinY)
      else
      if MinX < 0 then
        for I := 0 to Objects.Count - 1 do
          Objects[I].OffsetHitTest(GHT_BODY_MASK, -MinX, 0)
      else
      if MinY < 0 then
        for I := 0 to Objects.Count - 1 do
          Objects[I].OffsetHitTest(GHT_BODY_MASK, 0, -MinY)
      //------------------by qlg end
    finally
      EndUpdate;
    end;
    Inc(fDragTargetPt.X, dX);
    Inc(fDragTargetPt.Y, dY);
    ScrollInView(fDragTargetPt);
  end;
end;

Re: Simple Graph Demo - Link/Line length

PostPosted: February 21st, 2009, 5:31 pm
by Athabasca
Not quite true. A rectangle moves down when the line on top applied.

Re: Simple Graph Demo - Link/Line length

PostPosted: March 1st, 2009, 11:44 am
by Athabasca
Pity that this did not further elaborated.