Class TRbwModelCube

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TRbwModelCube = class(TPaintBox)

Description

TRbwModelCube

is a TPaintBox that draws a block on itself.) Typically, the block is drawn as if all the sides were the same length so the block is a cube. The cube can be drawn as either transparent or opaque. A selected area can be drawn on the cube. (See Selection1 and Selection2.) If the user clicks on the cube, ClickDirection can be used to determine where the user clicked with respect to the selected area.

Hierarchy

Overview

Fields

Private FBottomY: integer;
Private FCanClickFace: boolean;
Private FFraction: double;
Private FLeftX: integer;
Private FMouseX: integer;
Private FMouseY: integer;
Private FOnSelectFace: TNotifyEvent;
Private FOpaque: boolean;
Private FRightX: integer;
Private FSelectedFace: TRbwFace;
Private FSelection1: double;
Private FSelection2: double;
Private FShowSelection: boolean;
Private FTopY: integer;
Private FVanishingPointX: integer;
Private FVanishingPointY: integer;
Private FXOrigin: TRbwXOrigin;
Private FYOrigin: TRbwYOrigin;
Private FZOrigin: TRbwZOrigin;
Private FSelectionColor: TColor;
Private FBreaks: TBreakCollection;

Methods

Private procedure SetCanClickFace(const Value: boolean);
Private procedure SetSelectedFace(const Value: TRbwFace);
Private procedure SetSelection1(const Value: double);
Private procedure SetSelection2(const Value: double);
Private procedure SetShowSelection(const Value: boolean);
Private procedure SetOpaque(const Value: boolean);
Private procedure SetXOrigin(const Value: TRbwXOrigin);
Private procedure SetYOrigin(const Value: TRbwYOrigin);
Private procedure SetZOrigin(const Value: TRbwZOrigin);
Private procedure SetFraction(const Value: double);
Private procedure SetLeftX(const Value: integer);
Private procedure SetTopY(const Value: integer);
Private procedure SetVanishingPointX(const Value: integer);
Private procedure SetVanishingPointY(const Value: integer);
Private function GetCubeHeight: integer;
Private function GetCubeWidth: integer;
Private procedure SetCubeHeight(const Value: integer);
Private procedure SetCubeWidth(const Value: integer);
Private procedure SetSelectionColor(const Value: TColor);
Private procedure DrawSelection(BackTopY, BackBottomY, BackLeftX, BackRightX: Integer);
Private procedure BreakChanged(Sender: TObject);
Protected procedure DblClick; override;
Protected procedure DrawCube;
Protected function GetFaceOfCube: TRbwFace;
Protected procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
Protected procedure Paint; override;
Public function ClickDirection(const X, Y: integer): TRbwClickDirection;
Public constructor Create(AOwner: TComponent); override;
Public destructor Destroy; override;

Properties

Public property Breaks: TBreakCollection read FBreaks;
Published property CanClickFace : boolean read FCanClickFace write SetCanClickFace;
Published property SelectionColor: TColor read FSelectionColor write SetSelectionColor default clRed;
Published property CubeFraction : double read FFraction write SetFraction;
Published property CubeHeight: integer read GetCubeHeight write SetCubeHeight;
Published property CubeLeftX : integer read FLeftX write SetLeftX;
Published property CubeTopY : integer read FTopY write SetTopY;
Published property CubeVanishingPointX : integer read FVanishingPointX write SetVanishingPointX;
Published property CubeVanishingPointY : integer read FVanishingPointY write SetVanishingPointY;
Published property CubeWidth: integer read GetCubeWidth write SetCubeWidth;
Published property Opaque : boolean read FOpaque write SetOpaque;
Published property SelectedFace : TRbwFace read FSelectedFace write SetSelectedFace;
Published property Selection1 : double read FSelection1 write SetSelection1;
Published property Selection2 : double read FSelection2 write SetSelection2;
Published property ShowSelection : boolean read FShowSelection write SetShowSelection;
Published property XOrigin : TRbwXOrigin read FXOrigin write SetXOrigin;
Published property YOrigin : TRbwYOrigin read FYOrigin write SetYOrigin;
Published property ZOrigin : TRbwZOrigin read FZOrigin write SetZOrigin;
Published property OnSelectFace : TNotifyEvent read FOnSelectFace write FOnSelectFace;

Description

Fields

Private FBottomY: integer;

FBottomY : integer; The bottom edge of the front of the cube

Private FCanClickFace: boolean;

FCanClickFace : boolean; See CanClickFace

Private FFraction: double;

FFraction : double; FFraction is the Fraction of the distance between the front of the cube and vanishing point at which the back of the cube is located. See CubeFraction.

Private FLeftX: integer;

FLeftX : integer; left edge of the front of the cube

Private FMouseX: integer;

FMouseX : integer; FMouseX is set to the mouse X coordinate in MouseUp.

Private FMouseY: integer;

FMouseY : integer; FMouseY is set to the mouse Y coordinate in MouseUp.

Private FOnSelectFace: TNotifyEvent;

FOnSelectFace : TNotifyEvent; See OnSelectFace.

Private FOpaque: boolean;

FOpaque : boolean; See Opaque.

Private FRightX: integer;

FRightX : integer; right edge of the front of the cube

Private FSelectedFace: TRbwFace;

FSelectedFace : TRbwFace; See SelectedFace.

Private FSelection1: double;

FSelection1 : double; See Selection1.

Private FSelection2: double;

FSelection2 : double; See Selection2.

Private FShowSelection: boolean;

FShowSelection : boolean; See ShowSelection.

Private FTopY: integer;

FTopY : integer; top edge of the front of the cube

Private FVanishingPointX: integer;

FVanishingPointX : integer; X coordinate of the vanishing point

Private FVanishingPointY: integer;

FVanishingPointY : integer; Y coordinate of the vanishing point

Private FXOrigin: TRbwXOrigin;

FXOrigin : TRbwXOrigin; See XOrigin.

Private FYOrigin: TRbwYOrigin;

FYOrigin : FYOrigin; See YOrigin.

Private FZOrigin: TRbwZOrigin;

FZOrigin : TRbwZOrigin; See ZOrigin.

Private FSelectionColor: TColor;
 
Private FBreaks: TBreakCollection;
 

Methods

Private procedure SetCanClickFace(const Value: boolean);

See CanClickFace.

Private procedure SetSelectedFace(const Value: TRbwFace);

See SelectedFace.

Private procedure SetSelection1(const Value: double);

See Selection1.

Private procedure SetSelection2(const Value: double);

See Selection2.

Private procedure SetShowSelection(const Value: boolean);

See ShowSelection.

Private procedure SetOpaque(const Value: boolean);

See Opaque.

Private procedure SetXOrigin(const Value: TRbwXOrigin);

See XOrigin.

Private procedure SetYOrigin(const Value: TRbwYOrigin);

See YOrigin.

Private procedure SetZOrigin(const Value: TRbwZOrigin);

See ZOrigin.

Private procedure SetFraction(const Value: double);

See CubeFraction.

Private procedure SetLeftX(const Value: integer);

See CubeLeftX.

Private procedure SetTopY(const Value: integer);

See CubeTopY.

Private procedure SetVanishingPointX(const Value: integer);

See CubeVanishingPointX.

Private procedure SetVanishingPointY(const Value: integer);

See CubeVanishingPointY.

Private function GetCubeHeight: integer;

See CubeHeight.

Private function GetCubeWidth: integer;

See CubeWidth.

Private procedure SetCubeHeight(const Value: integer);

See CubeHeight.

Private procedure SetCubeWidth(const Value: integer);

See CubeWidth.

Private procedure SetSelectionColor(const Value: TColor);
 
Private procedure DrawSelection(BackTopY, BackBottomY, BackLeftX, BackRightX: Integer);
 
Private procedure BreakChanged(Sender: TObject);
 
Protected procedure DblClick; override;

If CanClickFace is true, DblClick sets SelectedFace to the face on which the user double-clicked.

Protected procedure DrawCube;

DrawCube draws a perspective drawing of a cube with a selected section indicated by Selection1 and Selection2.

SelectedFace indicates the direction of the slice of the cube that is selected. faNone indicates it is undetermined. faTop indicates it is parallel to the top surface. faFront indicates it is parallel to the front surface. faSide indicates it is parallel to the side surface.

Selection1 and Selection2 give the fraction of the side of the cube along which the colored section is to be shown. The origin is determined by XOrigin, YOrigin, and ZOrigin. Selection2 should be greater than or equal to Selection1. Both Selection1 and Selection2 should be greater than or equal to 0 and less than or equal to 1.

Protected function GetFaceOfCube: TRbwFace;

GetFaceOfCube returns the face of the cube, if any, on which the user clicked. See DblClick.

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

MouseUp sets FMouseX and FMouseY.

Protected procedure Paint; override;

Paint calls DrawCube.

Public function ClickDirection(const X, Y: integer): TRbwClickDirection;

The result of ClickDirection depend on SelectedFace.

If SelectedFace = faNone, ClickDirection returns cdNone.

If SelectedFace = faTop, ClickDirection returns cdDown, cdUp or cdNone depending on whether the Point X,Y appear to be below, above, or between Selection1 and Selection2.

If SelectedFace = faFront, ClickDirection returns cdNorth, cdSouth or cdNone depending on whether the Point X,Y appear to be behind, in front of, or between Selection1 and Selection2.

If SelectedFace = faSide, ClickDirection returns cdWest, cdEast or cdNone depending on whether the Point X,Y appear to be to the right of, to the left of, or between Selection1 and Selection2.

Public constructor Create(AOwner: TComponent); override;

Create creates and instance of TRbwModelCube.

Public destructor Destroy; override;
 

Properties

Public property Breaks: TBreakCollection read FBreaks;

Protected declarations

Published property CanClickFace : boolean read FCanClickFace write SetCanClickFace;

If CanClickFace is true, the user can change SelectedFace by double clicking on a face.

Published property SelectionColor: TColor read FSelectionColor write SetSelectionColor default clRed;
 
Published property CubeFraction : double read FFraction write SetFraction;

CubeFraction is the fraction of the distance between the front of the cube and vanishing point at which the back of the cube is located.

See CubeVanishingPointX and CubeVanishingPointY.

Published property CubeHeight: integer read GetCubeHeight write SetCubeHeight;

CubeHeight is the height of the front face of the cube in pixels.

Published property CubeLeftX : integer read FLeftX write SetLeftX;

CubeLeftX is the X coordinate of the left side of the front face of the cube in pixels.

Published property CubeTopY : integer read FTopY write SetTopY;

CubeTopY is the Y coordinate of the top side of the front face of the cube in pixels.

Published property CubeVanishingPointX : integer read FVanishingPointX write SetVanishingPointX;

CubeVanishingPointX and CubeVanishingPointY define a vanishing point. The side faces of the cube are drawn by drawing lines CubeFraction of the distance between the front face and the vanishing point.

Published property CubeVanishingPointY : integer read FVanishingPointY write SetVanishingPointY;

CubeVanishingPointX and CubeVanishingPointY define a vanishing point. The side faces of the cube are drawn by drawing lines CubeFraction of the distance between the front face and the vanishing point.

Published property CubeWidth: integer read GetCubeWidth write SetCubeWidth;

CubeWidth is the width of the front face of the cube in pixels.

Published property Opaque : boolean read FOpaque write SetOpaque;

If Opaque is true, only the outside of the cube is drawn.

Published property SelectedFace : TRbwFace read FSelectedFace write SetSelectedFace;

SelectedFace determines which face of the cube the selected area represents. The selected area is drawn in red.

faNone indicates it is undetermined. faTop indicates it is parallel to the top surface. faFront indicates it is parallel to the front surface. faSide indicates it is parallel to the side surface.

See OnSelectFace.

Published property Selection1 : double read FSelection1 write SetSelection1;

Selection1 and Selection2 give the fraction of the side of the cube along which the colored section is to be shown. The origin is determined by XOrigin, YOrigin, and ZOrigin. Selection2 should be greater than or equal to Selection1. Both Selection1 and Selection2 should be greater than or equal to 0 and less than or equal to 1.

Published property Selection2 : double read FSelection2 write SetSelection2;

Selection1 and Selection2 give the fraction of the side of the cube along which the colored section is to be shown. The origin is determined by XOrigin, YOrigin, and ZOrigin. Selection2 should be greater than or equal to Selection1. Both Selection1 and Selection2 should be greater than or equal to 0 and less than or equal to 1.

Published property ShowSelection : boolean read FShowSelection write SetShowSelection;

ShowSelection indicates whether the selected area should be drawn on not.

Published property XOrigin : TRbwXOrigin read FXOrigin write SetXOrigin;

XOrigin indicates whether the origin of the cube is on the east or west.

Published property YOrigin : TRbwYOrigin read FYOrigin write SetYOrigin;

YOrigin indicates whether the origin of the cube is on the north or south.

Published property ZOrigin : TRbwZOrigin read FZOrigin write SetZOrigin;

ZOrigin indicates whether the origin of the cube is on the top or bottom.

Published property OnSelectFace : TNotifyEvent read FOnSelectFace write FOnSelectFace;

OnSelectFace is called when SelectedFace is changed.


Generated by PasDoc 0.12.1 on 2013-05-13 15:41:59