The SDL Component Suite is an industry leading collection of components supporting scientific and engineering computing. Please visit the SDL Web site for more information.... |
Home ChartPack Plot3D Interface of SDL_Plot3D | |
Interface of SDL_Plot3D |
|
const defFrameCol = clBlack; { default frame color } defBakGndCol = clWhite; { default background color } defFillCol = clYellow; { default mesh fill color } defMeshCol = clBlack; { default mesh lines color } defHeight = 500; defWidth = 650; {$IFDEF PAIDVERS} SDLVersionInfo = 'plot3d_r1200_full'; IsLightEd = false; {$ELSE} SDLVersionInfo = 'plot3d_r1200_lighted'; IsLightEd = true; {$ENDIF} Release = 1200; P3BoxSize = 300; // box size in pixels of the Plot3D cube at unit magnification type TColorCodingMode = (ccmTwoColors, ccmThreeColors, ccmColorArray); TP3ScaleKind = (p3skX, p3skY, p3skZ); TMeshKind = (mkMesh, mkWaterfallHorz, mkWaterfallVert, mkWaterfallDiag, mkGrid); TMouseActionEvent = procedure (Sender: TObject; var CenterX, CenterY: integer; var RotXAngle, RotZAngle, Magnification: double; Shift: TShiftState) of object; TMouseMoveOverPlotEvent = procedure (Sender: TObject; OverPlot: boolean; Shift: TShiftState; MouseCellX, MouseCellY: integer) of object; TBeforeRenderPolygonEvent = procedure (Sender: TObject; Canvas: TCanvas; var Handled: boolean; CellX, CellY: integer; quad: TQuad; var color: TColor) of object; Tp3BeforeDrawScaleLabelEvent = procedure (Sender: TObject; Canvas: TCanvas; ScaleType: Tp3ScaleKind; var CurrentTickLabel: string; ChartX, ChartY: integer) of object; TRenderEvent = procedure (Sender: TObject; Canvas: TCanvas) of object; TPlot3D = class(TCustomControl) private CubeCorners : array [0..7,1..3] of double; { cube corners } GrafBmp : TBitmap; { off-screen graphics bitmap } FFrameCol : TColor; { color of frame } FMouseAction : TMouseActMode; { type of allowed mouse action } FRangeLowX : double; { lowest x-value of box } FRangeHighX : double; { highest x-value of box } FRangeLowY : double; { lowest y-value of box } FRangeHighY : double; { highest y-value of box } FRangeLowZ : double; { lowest z-value of box } FRangeHighZ : double; { highest z-value of box } FColorXAx : TColor; FColorYAx : TColor; FColorZAx : TColor; FColorCubeFrame : TColor; FColorCubeHidLin: TColor; FColorCubeFaceHi: TColor; FColorCubeFaceLo: TColor; FCaptX : string; { captions of axes } FCaptY : string; FCaptZ : string; FLabDistX : integer; { caption distance from axis } FLabDistY : integer; FLabDistZ : integer; FDecPlaceX : integer; { decimal places / x-axis } FDecPlaceY : integer; { decimal places / y-axis } FDecPlaceZ : integer; { decimal places / z-axis } FBoundBox : TBoundingBox; { surrounding cube } FColorBakGnd : TColor; { background color } FMeshKind : TMeshKind; { type of mesh } FColorMesh : TColor; { color of mesh lines } FColorFillHigh : TColor; { fill color of mesh } FColorFillMid : TColor; { fill color of mesh } FColorFillLow : TColor; { fill color of mesh } FColorScaleLow : double; { lower border of color scale } FColorScaleHigh : double; { upper border of color scale } FColorCodingMode: TColorCodingMode; { color encoding mode } FColBlackLine : TColor; { colors to draw the frame } FColGrayLine : TColor; { -"- } FColWhiteLine : TColor; { -"- } FColorScheme : TColorScheme; { color scheme of frames } FFrameStyle : TFrameStyle; { style of frame } FViewAngle : array[1..3] of double; { view point of data } FViewAngLimLow : array[1..3] of double; { limits of view point } FViewAngLimHigh : array[1..3] of double; { limits of view point } FVisibleXax : boolean; { visibility of axes } FVisibleYax : boolean; FVisibleZax : boolean; FMagnify : double; { 1 / magnification factor } FMagAnchor : double; { magnification anchor for rel. zoom } FMeshVisible : boolean;{TRUE: mesh is visible using ColorMesh } FNTicks : array[1..3] of integer; { number of scale ticks} FOnBefDrawSclLab: Tp3BeforeDrawScaleLabelEvent; FOnMouseAction : TMouseActionEvent; FOnDataRendered : TRenderEvent; FOnMMvOverPlot : TMouseMoveOverPlotEvent; FOnBefRndPolygon: TBeforeRenderPolygonEvent; FOnZoomPan : TZoomPanEvent; FCalibZk : double; FCalibZd : double; FColorCodeAvg : boolean; { FALSE: color coding uses max. value, else average } FCentX : integer; { center of chart } FCentY : integer; FAutoCenter : boolean; FCentXAnchor : integer; FCentYAnchor : integer; FAngleAnchor : array[1..3] of double; FMinZ : double; { minimum and maximum data values } FMaxZ : double; FSclXIntern : double; { internal scaling factor X } FSclYIntern : double; { internal scaling factor Y } FSclZIntern : double; { internal scaling factor Z } FSuppressPaint : boolean; { TRUE: suppress all paint calls } FRotMat : array[1..3,1..3] of double; { rotation matrix } MouseAnchorX : integer; { anchor for relative mouse move } MouseAnchorY : integer; procedure AdjustScaling; procedure ConstructDataBmp (cv: TCanvas; BlkWhite: boolean); function CalcIntZ (zvalue: double): double; procedure InitGraf (cv: TCanvas; BlkWhite: boolean); procedure CalcRotMatrix; function CalcColorCoding (value: double): TColor; procedure DrawAxis (cv: TCanvas; axKind: TP3ScaleKind; xxLow, yyLow, xxHigh, yyHigh: integer; RangeLow, RangeHigh: double; CubeIx1: integer); function GetRotMat (ix, iy: integer): double; function GetMagnify: double; procedure SetAutoCenter (value: boolean); procedure SetBoundBoxStyle (value: TBoundingBox); procedure SetCentX (value: integer); procedure SetCentY (value: integer); procedure SetCaptX (value: string); procedure SetCaptY (value: string); procedure SetCaptZ (value: string); procedure SetColorScheme (Value: TColorScheme); procedure SetColorCodingMode (Value: TColorCodingMode); procedure SetFrameCol (c: TColor); procedure SetColorBakGnd (c: TColor); procedure SetColorXax (c: TColor); procedure SetColorYax (c: TColor); procedure SetColorZax (c: TColor); procedure SetColorCodeAvg (value: boolean); procedure SetColCubeFrame (c: TColor); procedure SetColCubeHidLin (c: TColor); procedure SetColCubeFaceLow (c: TColor); procedure SetColCubeFaceHigh (c: TColor); procedure SetColorFillHigh (c: TColor); procedure SetColorFillMid (c: TColor); procedure SetColorFillLow (c: TColor); procedure SetColorMesh (c: TColor); function GetColorScaleHigh: double; procedure SetColorScaleHigh (Level: double); function GetColorScaleLow: double; procedure SetColorScaleLow (Level: double); procedure SetCubeCorners; procedure SetDecPlaceX (value: integer); procedure SetDecPlaceY (value: integer); procedure SetDecPlaceZ (value: integer); procedure SetFrameStyle (value: TFrameStyle); procedure SetLabDistZ (value: integer); procedure SetLabDistY (value: integer); procedure SetLabDistX (value: integer); procedure SetMagnify (mag: double); procedure SetMeshKind (meshkind: TMeshKind); procedure SetMeshVisible (meshvis: boolean); function GetNTicksX: integer; function GetNTicksY: integer; function GetNTicksZ: integer; procedure SetNTicksX (value: integer); procedure SetNTicksY (value: integer); procedure SetNTicksZ (value: integer); procedure SetRangeLowZ (value: double); procedure SetRangeHighZ (value: double); procedure SetRangeLowY (value: double); procedure SetRangeHighY (value: double); procedure SetRangeLowX (value: double); procedure SetRangeHighX (value: double); procedure SetSclX (fact: double); procedure SetSclY (fact: double); procedure SetSclZ (fact: double); function GetViewAngleX: double; function GetViewAngleZ: double; procedure SetViewAngleX (value: double); procedure SetViewAngleZ (value: double); procedure SetSuppressPaint (supp: boolean); procedure SetVisibleXAx (value: boolean); procedure SetVisibleYAx (value: boolean); procedure SetVisibleZAx (value: boolean); {$IFNDEF ISCLX} procedure WMMouseMoveOverPlot (var Message: TWMMouse); message WM_MOUSEMOVE; {$ENDIF} protected procedure GridMatChanged(Sender: TObject); procedure MouseMove (Shift: TShiftState; X,Y: integer); override; procedure MouseActionMove (var CenterX, CenterY: integer; var RotXAngle, RotZAngle, Magnification: double; Shift: TShiftState); procedure MouseMoveOverPlot (OverPlot: boolean; Shift: TShiftState; MouseCellX, MouseCellY: integer); procedure Paint; override; procedure ProcessResize(Sender: TObject); procedure DoZoomPanEvent; procedure DrawCenteredText (cv: TCanvas; Caption: string; PosX, PosY: integer); public ProjMapX : TIntMatrix; { projection map of x coordinates } ProjMapY : TIntMatrix; { projection map of y coordinates } ProjMapZ : TIntMatrix; { projection map for z buffer } GridMat : TMatrix; { grid of estimated 3D points } IsoColors : TColorArray; constructor Create(AOwner: TComponent); override; destructor Destroy; override; { various basic routines } procedure AutoScale; procedure Clear; procedure CopyToBitmap (ABitmap: TBitmap; BlkWhite, IncludeFrame: boolean); procedure CopyToBMP (FName: string; IncludeFrame: boolean); procedure CopyToClipboard (IncludeFrame: boolean); {$IFNDEF ISCLX} procedure CopyToWMF (FName: string; IncludeFrame: boolean); procedure CopyToClipboardWMF (IncludeFrame: boolean); procedure DrawOnForeignCanvas (cv: TCanvas); procedure PrintIt (ScaleF: double; BlkWhite, IncludeFrame: boolean); procedure CopyToOpenPrinter (var x,y: integer; ScaleF: double; BlkWhite, IncludeFrame: boolean); {$ENDIF} procedure Reset; property RotMat [ix,iy: integer]: double read GetRotMat; procedure SetRange (xLow, xHigh, yLow, yHigh, zLow, zHigh: double); procedure SetViewAngles (vax, vaz: double); property SuppressPaint: boolean read FSuppressPaint write SetSuppressPaint; published property Align; property AutoCenter: boolean read FAutoCenter write SetAutoCenter; property Visible; property ShowHint; property PopupMenu; property ParentShowHint; property BoundBoxStyle: TBoundingBox read FBoundBox write SetBoundboxStyle; property CaptionX: string read FCaptX write SetCaptX; property CaptionY: string read FCaptY write SetCaptY; property CaptionZ: string read FCaptZ write SetCaptZ; property CentX: integer read FCentX write SetCentX; property CentY: integer read FCentY write SetCentY; property ColorFrame: TColor read FFrameCol write SetFrameCol default DefFrameCol; property ColorBakGnd: TColor read FColorBakGnd write SetColorBakGnd; property ColorCodeAvg: boolean read FColorCodeAvg write SetColorCodeAvg; 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 ColorXCoords: TColor read FColorXax write SetColorXax; property ColorYCoords: TColor read FColorYax write SetColorYax; property ColorZCoords: TColor read FColorZax write SetColorZax; property ColorMesh: TColor read FColorMesh write SetColorMesh; property ColorHigh: TColor read FColorFillHigh write SetColorFillHigh; property ColorMid: TColor read FColorFillMid write SetColorFillMid; property ColorLow: TColor read FColorFillLow write SetColorFillLow; property ColorScaleHigh: double read GetColorScaleHigh write SetColorScaleHigh; property ColorScaleLow: double read GetColorScaleLow write SetColorScaleLow; property ColorCodingMode: TColorCodingMode read FColorCodingMode write SetColorCodingMode; property ColorScheme: TColorScheme read FColorScheme write SetColorScheme; property DecPlaceX: integer read FDecPlaceX write SetDecPlaceX; property DecPlaceY: integer read FDecPlaceY write SetDecPlaceY; property DecPlaceZ: integer read FDecPlaceZ write SetDecPlaceZ; property FrameStyle: TFrameStyle read FFrameStyle write SetFrameStyle; property LabDistX: integer read FLabDistX write SetLabDistX; property LabDistY: integer read FLabDistY write SetLabDistY; property LabDistZ: integer read FLabDistZ write SetLabDistZ; property MeshVisible: boolean read FMeshVisible write SetMeshVisible; property MeshKind: TMeshKind read FMeshKind write SetMeshKind; property Magnification: double read GetMagnify write SetMagnify; property MouseAction: TMouseActMode read FMouseAction write FMouseAction; property MinTickX: integer read GetNTicksX write SetNTicksX; property MinTickY: integer read GetNTicksY write SetNTicksY; property MinTickZ: integer read GetNTicksZ write SetNTicksZ; property RangeXLow: double read FRangeLowX write SetRangeLowX; property RangeYLow: double read FRangeLowY write SetRangeLowY; property RangeZLow: double read FRangeLowZ write SetRangeLowZ; property RangeXHigh: double read FRangeHighX write SetRangeHighX; property RangeYHigh: double read FRangeHighY write SetRangeHighY; property RangeZHigh: double read FRangeHighZ write SetRangeHighZ; property ScaleFactX: double read FSclXIntern write SetSclX; property ScaleFactY: double read FSclYIntern write SetSclY; property ScaleFactZ: double read FSclZIntern write SetSclZ; {$IFDEF GE_LEV17} property StyleElements; {$ENDIF} property ViewAngleX: double read GetViewAngleX write SetViewAngleX; property ViewAngleZ: double read GetViewAngleZ write SetViewAngleZ; property VisibleXCoords: boolean read FVisibleXax write SetVisibleXax; property VisibleYCoords: boolean read FVisibleYax write SetVisibleYax; property VisibleZCoords: boolean read FVisibleZax write SetVisibleZax; property OnDataRendered: TRenderEvent read FOnDataRendered write FOnDataRendered; property OnMouseAction: TMouseActionEvent read FOnMouseAction write FOnMouseAction; property OnClick; property OnDblClick; property OnBeforeRenderPolygon: TBeforeRenderPolygonEvent read FOnBefRndPolygon write FOnBefRndPolygon; property OnBeforeDrawScaleLabel: Tp3BeforeDrawScaleLabelEvent read FOnBefDrawSclLab write FOnBefDrawSclLab; property OnMouseMove; property OnMouseDown; property OnMouseUp; property OnMouseMoveOverPlot: TMouseMoveOverPlotEvent read FOnMMvOverPlot write FOnMMvOverPlot; property OnMouseWheel; property OnMouseWheelUp; property OnMouseWheelDown; property OnZoomPan: TZoomPanEvent read FOnZoomPan write FOnZoomPan; property OnKeyPress; property OnKeyDown; property OnKeyUp; end;
|