Class TQRbwZoomBox2

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TQRbwZoomBox2 = class(TPanel)

Description

TQRbwZoomBox2 is used as an interface for handling drawing with real number coordinates.

The functions X, XCoord, Y, and YCoord can be used to convert between real-world and screen coordinates. By default, the real-world coordinates increase to the left and upward but these directions can be reversed with HorizontalDirection and VerticalDirection.

Zooming operations are performed with BeginZoom and FinishZoom

Panning can be turned on and off with Panning.

Drawing should be done on the canvases of the PaintBox, BottomPaintBox, and Image subcomponents.

Hierarchy

Overview

Fields

Private FBottomPaintBox: TPaintBox;
Private FEndX: Integer;
Private FEndY: Integer;
Private FExaggeration: real;
Private FExaggerationDirection: TExaggerationDirection;
Private FHorizontalDirection: THorizontalDirection;
Private FImage: TImage;
Private FImmediateResize: boolean;
Private FMagnification: real;
Private FOriginX: real;
Private FOriginY: real;
Private FPaintBox: TzbPaintBox;
Private FPanning: boolean;
Private FStartX: Integer;
Private FStartY: Integer;
Private FStartXPosition: integer;
Private FStartYPosition: integer;
Private FStopXPosition: integer;
Private FStopYPosition: integer;
Private FVerticalDirection: TVerticalDirection;
Private FZooming: boolean;
Private FOnPan: TPanEvent;

Methods

Private function GetCanZoomIn: boolean;
Private function GetCanZoomOut: boolean;
Private procedure PanMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
Private procedure PanUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
Private procedure SetExaggeration(const Value: real);
Private procedure SetExaggerationDirection(const Value: TExaggerationDirection);
Private procedure SetHorizontalDirection(const Value: THorizontalDirection);
Private procedure SetImmediateResize(const Value: boolean);
Private procedure SetMagnification(Value: real);
Private procedure SetOriginX(const Value: real);
Private procedure SetOriginY(const Value: real);
Private procedure SetPanning(const Value: boolean);
Private procedure SetVerticalDirection(const Value: TVerticalDirection);
Protected procedure ContinueZoom(X, Y: Integer);
Protected procedure FinishZoom(X, Y: Integer);
Protected procedure InitWidget; override;
Protected procedure InvalidatePaintBoxesAndImage;
Protected procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
Protected procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
Protected procedure PaintZoomWindow(Sender: TObject);
Protected procedure Pan; virtual;
Protected procedure Resize; override;
Public procedure AbortZoom;
Public procedure BeginZoom(X, Y: Integer);
Public constructor Create(AOwner: TComponent); override;
Public function X(XCoord: integer): extended;
Public function XCoord(X: extended): integer;
Public function Y(YCoord: integer): extended;
Public function YCoord(Y: extended): integer;
Public procedure ZoomBy(Factor: extended);
Public procedure ZoomByAt(Factor: extended; CenterX, CenterY: integer);

Properties

Public property CanZoomIn: boolean read GetCanZoomIn;
Public property CanZoomOut: boolean read GetCanZoomOut;
Public property Panning: boolean read FPanning write SetPanning;
Published property BottomPaintBox: TPaintBox read FBottomPaintBox;
Published property Exaggeration: real read FExaggeration write SetExaggeration;
Published property ExaggerationDirection: TExaggerationDirection read FExaggerationDirection write SetExaggerationDirection default edVertical;
Published property HorizontalDirection: THorizontalDirection read FHorizontalDirection write SetHorizontalDirection;
Published property Image: TImage read FImage;
Published property ImmediateResize: boolean read FImmediateResize write SetImmediateResize;
Published property Magnification: real read FMagnification write SetMagnification;
Published property OriginX: real read FOriginX write SetOriginX;
Published property OriginY: real read FOriginY write SetOriginY;
Published property PaintBox: TzbPaintBox read FPaintBox;
Published property VerticalDirection: TVerticalDirection read FVerticalDirection write SetVerticalDirection;
Published property OnPan: TPanEvent read FOnPan write FOnPan;

Description

Fields

Private FBottomPaintBox: TPaintBox;

FBottomPaintBox: TPaintBox; See BottomPaintBox.

Private FEndX: Integer;

FEndX: Integer; FEndX is set to the mouse X coordinate in BeginZoom, ContinueZoom, and FinishZoom. See FStartX.

Private FEndY: Integer;

FEndY: Integer; FEndY is set to the mouse Y coordinate in BeginZoom, ContinueZoom, and FinishZoom. See FStartY.

Private FExaggeration: real;

FExaggeration: real; See Exaggeration.

Private FExaggerationDirection: TExaggerationDirection;

FExaggerationDirection: TExaggerationDirection; See ExaggerationDirection.

Private FHorizontalDirection: THorizontalDirection;

FHorizontalDirection: THorizontalDirection; See HorizontalDirection.

Private FImage: TImage;

FImage: TImage; See Image.

Private FImmediateResize: boolean;

FImmediateResize: boolean; See ImmediateResize.

Private FMagnification: real;

FMagnification: real; See Magnification.

Private FOriginX: real;

FOriginX: real; See OriginX.

Private FOriginY: real;

FOriginY: real; See OriginY.

Private FPaintBox: TzbPaintBox;

FPaintBox: TzbPaintBox; See PaintBox.

Private FPanning: boolean;

FPanning: boolean; See Panning.

Private FStartX: Integer;

FStartX: Integer; FStartX is set to the mouse X coordinate in BeginZoom. See FEndX.

Private FStartY: Integer;

FStartY: Integer; FStartY is set to the mouse Y coordinate in BeginZoom. See FEndY.

Private FStartXPosition: integer;

FStartXPosition: Integer; FStartXPosition is set to the mouse X coordinate in SetPanning.

Private FStartYPosition: integer;

FStartYPosition: Integer; FStartYPosition is set to the mouse Y coordinate in SetPanning.

Private FStopXPosition: integer;

FStopXPosition: Integer; FStopXPosition is set to the mouse X coordinate in Pan.

Private FStopYPosition: integer;

FStopYPosition: Integer; FStopYPosition is set to the mouse Y coordinate in Pan.

Private FVerticalDirection: TVerticalDirection;

FVerticalDirection: TVerticalDirection; See VerticalDirection.

Private FZooming: boolean;

FZooming: boolean; FZooming is True when a zooming operation is underway.

Private FOnPan: TPanEvent;

FOnPan: TPanEvent; See OnPan.

Methods

Private function GetCanZoomIn: boolean;

GetCanZoomIn returns true if Magnification is less than the maximum magnification.

Private function GetCanZoomOut: boolean;

GetCanZoomOut returns true if Magnification is greater than the minimum magnification.

Private procedure PanMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);

PanMove is the event handler for OnZbMove. If Panning is True, BottomPaintBox, PaintBox, and Image are moved so that they follow the mouse. If FZooming is True, FEndX and FEndY are updated and PaintBox is redrawn.

Private procedure PanUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);

PanUp is the event handler for OnZbUp. If Panning is True, BottomPaintBox, PaintBox, and Image are moved so that they follow the mouse. If FZooming is True, the zooming operation is either aborted or finished. See AbortZoom and FinishZoom. It is aborted if the mouse is not over the TQRbwZoomBox2.

Private procedure SetExaggeration(const Value: real);

See Exaggeration.

Private procedure SetExaggerationDirection(const Value: TExaggerationDirection);

See ExaggerationDirection.

Private procedure SetHorizontalDirection(const Value: THorizontalDirection);

See HorizontalDirection.

Private procedure SetImmediateResize(const Value: boolean);

See ImmediateResize.

Private procedure SetMagnification(Value: real);

See Magnification.

Private procedure SetOriginX(const Value: real);

See OriginX.

Private procedure SetOriginY(const Value: real);

See OriginY.

Private procedure SetPanning(const Value: boolean);

See Panning.

Private procedure SetVerticalDirection(const Value: TVerticalDirection);

See VerticalDirection.

Protected procedure ContinueZoom(X, Y: Integer);

If BeginZoom has been called, and neither AbortZoom nor FinishZoom have yet been called, ContinueZoom will draw a shape on the paintbox. One of the corners of the shape will be at the location where the zoom began. The other will be at X, and Y. X and Y are screen coordinates in the PaintBox in the TQRbwZoomBox2. You can get X and Y in OnMouseMove. ContinueZoom is called in the private method PanMove.

Protected procedure FinishZoom(X, Y: Integer);

FinishZoom terminates a zoom operation. X, and Y are the X and Y screen coordinates of the Paintbox in the TQRbwZoomBox2. You can get X and Y in OnMouseUp. FinishZoom sets the zoom level so that the area outlined by the X, and Y parameters in BeginZoom and the X, and Y parameters in FinishZoom is displayed in the TQRbwZoomBox2.

Protected procedure InitWidget; override;

InitWidget sets the Parent, Align, and Anchors properties of BottomPaintBox, Image, PaintBox. It also assigns event handlers for OnZbMove, OnZbUp, and OnZbPaint.

Protected procedure InvalidatePaintBoxesAndImage;

InvalidatePaintBoxesAndImage checks that BottomPaintBox, Image, and PaintBox can be drawn and, if so, calls Invalidate for each of them.

Protected procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;

MouseMove calls the inherited MouseMove and then calls Pan.

Protected procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;

MouseUp calls the inherited MouseUp and then calls Pan.

Protected procedure PaintZoomWindow(Sender: TObject);

During zooming operations, a rectangle is drawn on PaintBox to indicate the area that will be visible after zooming is complete. PaintZoomWindow is used to draw that rectangle.

Protected procedure Pan; virtual;

If Panning is true, BottomPaintBox, Image, and PaintBox are moved to follow the mouse. Then OnPan is called.

Protected procedure Resize; override;

If ImmediateResize is True, Resize causes BottomPaintBox, Image, and PaintBox to be resized to fit ClientWidth and ClientHeight.

Public procedure AbortZoom;

If for some reason you want to terminate a zoom operation without doing the zoom, call AbortZoom instead of FinishZoom. AbortZoom is called from PanUp.

Public procedure BeginZoom(X, Y: Integer);

BeginZoom starts a zooming operation. X, and Y are the X and Y screen coordinates of the PaintBox in the TQRbwZoomBox2. You can get those in OnMouseDown.

Public constructor Create(AOwner: TComponent); override;

Create creates an instance of TQRbwZoomBox2.

Public function X(XCoord: integer): extended;

X converts a screen coordinate into a real-number X coordinate.

Public function XCoord(X: extended): integer;

XCoord converts a real-number X coordinate into a screen coordinate.

Public function Y(YCoord: integer): extended;

Y converts a screen coordinate into a real-number Y coordinate.

Public function YCoord(Y: extended): integer;

YCoord converts a real-number Y coordinate into a screen coordinate.

Public procedure ZoomBy(Factor: extended);

ZoomBy increase the magnification by Factor by calling ZoomByAt and using the center of the TQRbwZoomBox2 as (CenterX, CenterY).

Public procedure ZoomByAt(Factor: extended; CenterX, CenterY: integer);

ZoomByAt changes the magnification by Factor and then adjusts OriginX and OriginY so that the point represented by the screen coordinates (CenterX, CenterY) will still have screen coordinates (CenterX, CenterY). For example, suppose there is a point with real-world coordinates of (1,1) and screen coordinates of (100,100). If the OnMouseUp event was used to call ZoomByAt with (CenterX,CenterY) = (100, 100), the point will still have screen coordinates of (100, 100) after applying ZoomByAt.

Properties

Public property CanZoomIn: boolean read GetCanZoomIn;

Read CanZoomIn to determine whether it is possible to zoom in.

Public property CanZoomOut: boolean read GetCanZoomOut;

Read CanZoomOut to determine whether it is possible to zoom out.

Public property Panning: boolean read FPanning write SetPanning;

Set Panning to True to start a panning operation. Set Panning to False to stop a panning operation. See Pan for what happens during a panning operation.

Published property BottomPaintBox: TPaintBox read FBottomPaintBox;

BottomPaintBox is one of two TPaintBox's on which the user can draw. The other is PaintBox. See also Image.

Published property Exaggeration: real read FExaggeration write SetExaggeration;

Exaggeration is used to allow either vertical or horizontal exaggeration. Exaggeration affects how screen coordinates map to real-world coordinates. See ExaggerationDirection.

Published property ExaggerationDirection: TExaggerationDirection read FExaggerationDirection write SetExaggerationDirection default edVertical;

ExaggerationDirection controls the direction in which Exaggeration is applied.

Published property HorizontalDirection: THorizontalDirection read FHorizontalDirection write SetHorizontalDirection;

HorizontalDirection indicates the direction in which the X-coordinates increase. hdRight indicates they increase towards the right, hdLeft indicates they increase towards the left.

Published property Image: TImage read FImage;

Image is a TImage on which the user can draw. See also PaintBox and BottomPaintBox.

Published property ImmediateResize: boolean read FImmediateResize write SetImmediateResize;

See Resize.

Published property Magnification: real read FMagnification write SetMagnification;

Magnification is the ratio of distances in screen coordinates to corresponding distances in real-world coordinates. Usually Magnification is not set directly. See BeginZoom, FinishZoom, ZoomBy and ZoomByAt.

Published property OriginX: real read FOriginX write SetOriginX;

OriginX is the screen X-coordinate that corresponds to a real-world X-coordinate of zero.

Published property OriginY: real read FOriginY write SetOriginY;

OriginY is the screen Y-coordinate that corresponds to a real-world Y-coordinate of zero.

Published property PaintBox: TzbPaintBox read FPaintBox;

PaintBox is one of two TPaintBox's on which the user can draw. The other is BottomPaintBox. See also Image.

Published property VerticalDirection: TVerticalDirection read FVerticalDirection write SetVerticalDirection;

VerticalDirection indicates the direction in which the Y-coordinates increase. vdDown indicates they increase downward, vdUp indicates they increase upward.

Published property OnPan: TPanEvent read FOnPan write FOnPan;

OnPan is called during panning operations to indicate the amount of panning. See Pan.


Generated by PasDoc 0.10.0 on 2006-10-31 09:56:44