const
defDataCol = clblack; { default data color }
defFrameCol = clBlack; { default frame color }
defChartCol = clWhite; { default chart background color }
defR3Height = 300; { default height }
defR3Width = 450; { default width }
{$IFDEF PAIDVERS}
SDLVersionInfo = 'rot3d_r1210_full';
IsLightEd = false;
{$ELSE}
SDLVersionInfo = 'rot3d_r1210_lighted';
IsLightEd = true;
{$ENDIF}
Release = 1210;
type
ESDLRot3DError = class(ESDLError); { exception type to indicate errors }
Tr3Item = (tkNone, tkMarkAt, tkLineto, tkLine, tkMoveto, tkEverything);
Tr3ChartItem = record
x,y,z : double; { coordinates of Item }
color : TColor; { color of Item }
tag : longint; { user defined tag }
ItemKind : Tr3Item;
x2,y2,z2 : double; { line }
marklw : byte; { mark/line width }
end;
TAxDir = (adLeftHanded, adRightHanded);
TRenderEvent = procedure (Sender: TObject; Canvas: TCanvas) of object;
TLblRequestEvent = procedure (Sender: TObject; obj: integer;
var LblText: string; var dx, dy: integer; var HAlign: TAlignment;
var VAlign: TVerticalAlignment; LblFont: TFont) of object;
{$IFDEF GE_LEV29}
[ComponentPlatformsAttribute(pidWin32 or pidWin64 or pidWin64x)]
{$ENDIF}
TRot3D = class (TCustomControl)
private
CubeCorners : array [0..7,1..3] of longint; { cube corners }
FViewAngle : array[1..3] of double; { view point of data }
GrafBmp : TBitmap; { off-screen graphics bitmap }
FMouseAction : TMouseActMode; { type of allowed mouse action }
FDataCol : TColor; { color of data }
FLineWidth : integer; { width of lines }
FAxDir : TAxDir; { direction of axes }
FDataTag : longint; { user defined tag }
FFrameCol : TColor; { color of frame }
FChartCol : TColor; { color of chart background }
FColBlackLine : TColor; { colors to draw the frame }
FColGrayLine : TColor; { -"- }
FColWhiteLine : TColor; { -"- }
FColorScheme : TColorScheme; { color scheme of frames }
FColorCubeFrame : TColor;
FColorCubeHidLin: TColor;
FColorCubeFaceHi: TColor;
FColorCubeFaceLo: TColor;
FFontPixPerInch : integer;
FMTrace : array of TColoredPoint; {user-drawn mouse trace}
FNumMTrace : integer;
FColorMTrace : TColor;
FMTraceInvert : boolean;
FBoundBox : TBoundingBox; { surrounding cube }
FBBSize : integer; { size of bounding box }
FAxSize : integer; { length of axes }
FShowAxes : boolean; { TRUE: show axes }
FFrameStyle : TFrameStyle; { style of frame }
FIsoMetric : boolean; { isometric display if TRUE }
FAutoOrigin : boolean;{ TRUE: calculate origin automatically }
FAutoScale : boolean; { TRUE: scale data automatically }
FOrigin : array[1..3] of double; { origin of coord.syst.}
FAxName : array[1..3] of string; { name of axes }
FMagnify : integer; { 1 / magnification factor }
FMagAnchor : double; { magnification anchor for rel. zoom }
FMinCoord : array[1..3] of integer;
FMaxCoord : array[1..3] of integer;
FAngleAnchor : array[1..3] of double;
FScaleFact : array[1..3] of double;{factor for fixed scaling}
FCentX : integer; { center of chart }
FCentY : integer;
FCentXAnchor : integer;
FCentYAnchor : integer;
FRotMat : array[1..3,1..3] of longint; { rotation matrix }
NRotObj : integer; { number of objects to be rotated }
FRotDataX : array of integer; { data to be processed - x }
FRotDataY : array of integer; { data to be processed - y }
FRotDataZ : array of integer; { data to be processed - z }
FBackLink : array of longint; { pointer array to graph. items }
FRotProp : array of integer; { bit 0..23 = color,
bit 24..31 = action: $01000000 ... MoveTo
$02000000 ... LineTo
$03000000 ... MarkAt }
FRotMark : array of byte; { mark type }
FLineWid : array of byte; { line width }
FRotMat3D : boolean; { 2D or 3D rotation matrix }
FTextFontStyle : TFontStyles; { font style of text labels }
FTextMarkSize : byte; { size of character marks }
MouseAnchorX : integer; { anchor for relative mouse move }
MouseAnchorY : integer;
FNumChartItems : longint;{ no. of chart items in data container }
FNumAllocated : longint; { number of allocated container cells }
FAllocSize : integer; { allocation size for data container }
FOnDataRendered : TRenderEvent;
FOnBefRenderData: TRenderEvent;
FOnLblRequest : TLblRequestEvent;
procedure ConstructDataBmp (cv: TCanvas; BlkWhite: boolean);
procedure InitGraf (cv: TCanvas; BlkWhite: boolean; AddOn: integer);
procedure SetDataCol (c: TColor);
procedure SetDataTag (tag: longint);
procedure SetFrameCol (c: TColor);
procedure SetChartCol (c: TColor);
procedure SetColCubeFrame (c: TColor);
procedure SetColCubeHidLin (c: TColor);
procedure SetColCubeFaceLow (c: TColor);
procedure SetColCubeFaceHigh (c: TColor);
procedure SetMagnify (mag: double);
procedure SetLineWidth (wid: integer);
function GetAxNameX: string;
function GetAxNameY: string;
function GetAxNameZ: string;
function GetChartItem (idx: longint): Tr3ChartItem;
function GetMagnify: double;
function GetMTracePoint (idx: longint): TColoredPoint;
function GetTypeOfFirstItem: Tr3Item;
function GetTypeOfLastItem: Tr3Item;
function GetViewAngleX: double;
function GetViewAngleY: double;
function GetViewAngleZ: double;
function GetOriginX: double;
function GetOriginY: double;
function GetOriginZ: double;
function GetRotMat (ix, iy: integer): double;
function GetScaleFactX: double;
function GetScaleFactY: double;
function GetScaleFactZ: double;
procedure SetChartitem (idx: longint; item: Tr3ChartItem);
procedure SetColorScheme (Value: TColorScheme);
procedure SetCubeCorners;
procedure SetFrameStyle (value: TFrameStyle);
procedure SetBoundBoxStyle (value: TBoundingBox);
procedure SetBoundBoxSize (value: integer);
function GetBoundBoxSize: integer;
procedure SetAllocSize (alloc: integer);
procedure SetAxSize (value: integer);
procedure SetAxDir (value: TAxDir);
procedure SetCentX (value: integer);
procedure SetCentY (value: integer);
procedure SetIsoMetric (value: boolean);
procedure SetAutoOrigin (value: boolean);
procedure SetAutoScale (value: boolean);
procedure SetShowAxes (value: boolean);
procedure SetTextFontStyle (tfs: TFontStyles);
procedure SetTextMarkSize (tms: byte);
procedure SetViewAngleX (value: double);
procedure SetViewAngleY (value: double);
procedure SetViewAngleZ (value: double);
procedure SetOriginX (value: double);
procedure SetOriginY (value: double);
procedure SetOriginZ (value: double);
procedure SetScaleFactX (value: double);
procedure SetScaleFactY (value: double);
procedure SetScaleFactZ (value: double);
procedure SetAxNameX (value: string);
procedure SetAxNameY (value: string);
procedure SetAxNameZ (value: string);
procedure SetMRot3Axes (value: boolean);
protected
FDataContainer : array of Tr3ChartItem; { array of drawing items }
procedure MouseMove (Shift: TShiftState; X,Y: integer); override;
procedure MouseUp (Button: TMouseButton;
Shift: TShiftState; X, Y: Integer); override;
procedure CalcRotMatrix_2Ax; virtual;
procedure CalcRotMatrix_3Ax; virtual;
procedure CalcRotMatrix;
procedure DrawMouseTrace (xPos, yPos: integer; SrcBmp: TBitMap);
procedure Paint; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Clear;
procedure ClearMouseTrace;
property ColorData: TColor
read FDataCol write SetDataCol default DefDataCol;
procedure CopyToBitmap (ABitmap: TBitmap;
BlkWhite, IncludeFrame: boolean);
procedure CopyToBMP (FName: string; IncludeFrame: boolean);
{$IFNDEF ISCLX}
procedure CopyToWMF (FName: string; IncludeFrame: boolean);
procedure CopyToClipboardWMF (IncludeFrame: boolean);
procedure CopyToClipboard (IncludeFrame: boolean);
procedure PrintIt (ScaleF: double; BlkWhite, IncludeFrame: boolean);
procedure CopyToOpenPrinter (var x,y: integer; ScaleF: double;
BlkWhite, IncludeFrame: boolean);
{$ENDIF}
property DataContainer[idx: longint]: Tr3ChartItem
read GetChartItem write SetChartItem;
property DataTag: longint read FDataTag write SetDataTag;
procedure MakeVisible;
procedure Drawto (x,y,z: double);
function FindEncircledData (pg: TPDblArray;
var ItemList: TIntArray): integer;
function FindNearestItemScreen (mx, my: integer; ItemID: Tr3Item;
var dist: double): longint;
function FindNearestItemReal (mx, my, mz: double; ItemID: Tr3Item;
var dist: double): longint;
function GetItemParams (Item: longint): Tr3ChartItem;
procedure SetItemParams (Item: longint; ItParams: Tr3ChartItem);
procedure Line (x1,y1,z1, x2,y2,z2: double);
property LineWidth: integer read FLineWidth write SetLineWidth;
property MouseTrace[idx: longint]: TColoredPoint
read GetMTracePoint;
procedure Moveto (x,y,z: double);
property NumMTracePoints: longint read FNumMTrace;
procedure MarkAt (x,y,z: double; mk: byte);
property NumItems: longint read FNumChartItems;
procedure RemoveLastItem;
procedure RemoveFirstItem;
procedure RemoveItem (Index: longint);
procedure SetViewAngles (vax, vay, vaz: double);
procedure SetOrigins (vax, vay, vaz: double);
procedure SetScaleFactors (sfx, sfy, sfz: double);
property TypeOfLastItem: Tr3Item read GetTypeOfLastItem;
property TypeOfFirstItem: Tr3Item read GetTypeOfFirstItem;
property RotMat [ix,iy: integer]: double read GetRotMat;
property ScaleFactX: double
read GetScaleFactX write SetScaleFactX;
property ScaleFactY: double
read GetScaleFactY write SetScaleFactY;
property ScaleFactZ: double
read GetScaleFactZ write SetScaleFactZ;
published
property Font;
property Align;
property Visible;
property ShowHint;
property PopupMenu;
property AllocSize: integer read FAllocSize write SetAllocSize;
property CentX: integer read FCentX write SetCentX;
property CentY: integer read FCentY write SetCentY;
property ColorFrame: TColor
read FFrameCol write SetFrameCol default DefFrameCol;
property ColorChart: TColor
read FChartCol write SetChartCol default DefChartCol;
property ColorScheme: TColorScheme
read FColorScheme write SetColorScheme;
property ColorCubeFrame: TColor
read FColorCubeFrame write setColCubeFrame;
property ColorCubeHidLin: TColor
read FColorCubeHidLin write SetColCubeHidLin;
property ColorCubeFaceLow: TColor
read FColorCubeFaceLo write SetColCubeFaceLow;
property ColorCubeFaceHigh: TColor
read FColorCubeFaceHi write SetColCubeFaceHigh;
property IsoMetric: boolean read FIsoMetric write SetIsometric;
property AutoOrigin: boolean read FAutoOrigin write SetAutoOrigin;
property AutoScale: boolean read FAutoScale write SetAutoScale;
property FrameStyle: TFrameStyle
read FFrameStyle write SetFrameStyle;
property Magnification: double read GetMagnify write SetMagnify;
property MouseAction: TMouseActMode
read FMouseAction write FMouseAction;
property MouseRot3Axes: boolean read FRotMat3D write SetMRot3Axes;
property MouseTraceColor: TColor
read FColorMTrace write FColorMTrace;
property MouseTraceInvert: boolean
read FMTraceInvert write FMTraceInvert;
property BoundBoxStyle: TBoundingBox
read FBoundBox write SetBoundboxStyle;
property BoundBoxSize: integer
read GetBoundBoxSize write SetBoundBoxSize;
property AxDir: TAxDir read FAxDir write SetAxDir;
property AxSize: integer read FAxSize write SetAxSize;
property AxNameX: string read GetAxNameX write SetAxNameX;
property AxNameY: string read GetAxNameY write SetAxNameY;
property AxNameZ: string read GetAxNameZ write SetAxNameZ;
{$IFDEF GE_LEV17}
(**) property StyleElements;
{$ENDIF}
property ShowAxes: boolean read FShowAxes write SetShowAxes;
property TextFontStyle: TFontStyles
read FTextFontStyle write SetTextFontStyle;
property TextMarkSize: byte read FTextMarkSize write SetTextMarkSize;
property ViewAngleX: double
read GetViewAngleX write SetViewAngleX stored true;
property ViewAngleY: double
read GetViewAngleY write SetViewAngleY stored true;
property ViewAngleZ: double
read GetViewAngleZ write SetViewAngleZ stored true;
property OriginX: double read GetOriginX write SetOriginX;
property OriginY: double read GetOriginY write SetOriginY;
property OriginZ: double read GetOriginZ write SetOriginZ;
property OnBeforeRenderData: TRenderEvent
read FOnBefRenderData write FOnBefRenderData;
property OnDataRendered: TRenderEvent
read FOnDataRendered write FOnDataRendered;
property OnLblRequest: TLblRequestEvent
read FOnLblRequest write FOnLblRequest;
property OnClick;
property OnDblClick;
property OnMouseMove;
property OnMouseDown;
property OnMouseUp;
property OnMouseWheel;
property OnMouseWheelUp;
property OnMouseWheelDown;
property OnKeyPress;
property OnKeyDown;
property OnKeyUp;
end;
|