UpLeftZooms property errors

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Thomas
Newbie
Newbie
Posts: 10
Joined: Thu Nov 25, 2004 5:00 am
Location: Calgary, Canada
Contact:

UpLeftZooms property errors

Post by Thomas » Tue Feb 01, 2005 4:44 pm

The UpLeftZooms property of TTeeZoom is described inaccurately in help. In addition, it is impossible to unzoom if the zoom direction is set to tzdVertical. To make unzoom work again, I modified TCustomChart.MouseUp in Chart.pas.

IMHO the help topic should be modified to something like this:
Gets or sets whether the zoom object will apply "zoom" when the end user drags the mouse from bottom-right to up-left direction.
By default is False.
Setting to True means the end-user will not have any way to "undo" zoom using the mouse, so you'll need to provide another way to un-zoom.
When True, dragging a rectangle will always zoom, no matter in which direction the rectangle has been dragged.
When False, dragging a rectangle from bottom-right to upper-left will "un-zoom", while dragging from upper-left to bottom-right will "zoom" (same as in previous versions).

Here is the modified code:

Code: Select all

procedure TCustomChart.MouseUp(Button: TMouseButton; Shift: TShiftState; X,
Y: Integer);
Begin
  CancelMouse:=False; { 5.03 }
  inherited;
  if Zoom.Active and (Button=Zoom.MouseButton) then
  With Zoom do
  Begin
    Active:=False;
    DrawZoomRectangle;
    Canvas.Pen.Mode:=pmCopy;
    if Direction=tzdVertical then x:=X0+MinimumPixels+1;  // 7.0
    if Direction=tzdHorizontal then y:=Y0+MinimumPixels+1;
    X1:=x;
    Y1:=y;
    if ( Abs(X1-X0)>MinimumPixels ) and
       ( Abs(Y1-Y0)>MinimumPixels ) then
    begin
      if Zoom.UpLeftZooms or (X1>X0) and (Y1>Y0) then  //MODIFIED LINE
         CalcZoomPoints { <-- do zoom in ! }
      else
         UndoZoom;      { <-- do zoom out ! }
      Invalidate;
    end;
  end;
The original code (in the modified line) tested only X1>X0, which is always
true, given the code just above, since X1 is set to X0+MinimumPixels+1.

Cheers!
Thomas

Post Reply