extending TCustomImagePointSeries example?

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
AeroSys
Newbie
Newbie
Posts: 17
Joined: Tue Mar 01, 2005 5:00 am
Location: Saint Paul, MN
Contact:

extending TCustomImagePointSeries example?

Post by AeroSys » Wed May 04, 2005 1:20 am

I am trying to extend the TCustomImagePointSeries class so that I can assign a different bmp stored in an ImageList (actually 1 out of a list of 9) to individual points in the series. I've been following the TErrorEllipse example you sent, but I am stuck at how to over_ride the OnGetImage property? I think I am very close, can you point me to an example.

Thanks in Advance,
Matt aerosys@aerogeomatics.com

unit InnerReliabImagePoint;
//this is a new point series type extended from TCustomImagePoint
//each point in the series may have a different bmp that is stored
//in the assigned FImageList property. The logic as to which image bmp
//a point value receives depends upon it's two Inner Reliability (IR) values.
//a point coordinate has two IR values, one each for x & y respectively
//see GetImageIndex( IRx, IRy ): integer;

interface

uses
{$IFNDEF LINUX}
Windows, Messages,
{$ENDIF}
SysUtils, Classes,
{$IFDEF CLX}
QGraphics, QControls, QForms, QDialogs, QExtCtrls, QStdCtrls, QComCtrls,
{$ELSE}
Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls, ComCtrls,
{$ENDIF}
TeCanvas, TeePenDlg, TeeProcs, TeEngine, Chart, TeeTools,
Series, imaPoint;

Type

TInnerReliabilitySeries = class (TCustomImagePointSeries)
private
FImageList: TImageList;
FIRxValues: TChartValueList;
FIRyValues: TChartValueList;
FupperBound: double;
FlowerBound: double;

procedure SetIRxValues (const Value: TChartValueList);
procedure SetIRyValues (const Value: TChartValueList);
procedure SetUpperBound(const Value: double);
procedure SetLowerBound(const Value: double);
function GetImageIndex( IRx,IRy: double ): integer;
function GetBoundRegion( IRvalue: double ): integer;
public
procedure SetImageList(const Value: TImageList);
Function AddPoint(Const CenterX, CenterY, IRx, IRy : Double):Integer;


Constructor Create(AOwner: TComponent); override;
// procedure GetImage( Sender: TCustomImagePointSeries;
// ValueIndex: Integer;
// Picture: TPicture); override;

published
property ImageList: TImageList read FImageList write SetImageList;
property IRxValues: TChartValueList read FIRxValues write SetIRxValues;
property IRyValues: TChartValueList read FIRyValues write SetIRyValues;
property UpperBound: double read FupperBound write SetUpperBound;
property LowerBound: double read FlowerBound write SetLowerBound;
end;

implementation


{ TInnerReliabilitySeries }

//....................................................................
function TInnerReliabilitySeries.AddPoint(const CenterX, CenterY, IRx,
IRy: Double): Integer;
begin
IRxValues.TempValue := IRx;
IRyValues.TempValue := IRy;
result := AddXY(CenterX,CenterY);
end;

//........................................................................
// Override Create Method
//........................................................................
constructor TInnerReliabilitySeries.Create(AOwner: TComponent);
begin
inherited;
FIRxValues := TChartValueList.Create(Self,'IRx Values');
FIRyValues := TChartValueList.Create(Self,'IRy Values');
end;

//.........................................................................
function TInnerReliabilitySeries.GetBoundRegion(IRvalue: double): integer;
var
retval : integer;
begin
retval := 3;
if (Abs(IRvalue) <= LowerBound) then retval := 1
else if ((Abs(IRvalue) > LowerBound) and
(Abs(IRvalue) <= UpperBound)) then retval := 2
else if (Abs(IRvalue) > UpperBound) then retval := 3;
result := retval;
end;

//.......................................................................
// Override GetImage Method
//........................................................................
{procedure TInnerReliabilitySeries.GetImage(Sender: TCustomImagePointSeries;
ValueIndex: Integer; Picture: TPicture);
var
IRx,IRy : double; //inner reliabiliity numbers
idx : integer; //image list index
Image : TBitmap;
begin
inherited GetImage(Sender, ValueIndex, Picture);
IRx := IRxValues.Value[ ValueIndex ];
IRy := IRyValues.Value[ ValueIndex ];
idx := GetImageIndex(IRx, IRy);
FImageList.GetBitmap(idx,Image);
Picture.Bitmap := Image;
end;}

//...........................................................................
function TInnerReliabilitySeries.GetImageIndex(IRx, IRy: double): integer;
var retval : integer;
BRx,BRy : integer;
begin
retval := 8;
BRx := GetBoundRegion( IRx );
BRy := GetBoundRegion( IRy );
// LEDx LEDy
if ((BRx = 1) and (BRy = 1)) then retval := 0 // g g
else if ((BRx = 1) and (BRy = 2)) then retval := 1 // g y
else if ((BRx = 1) and (BRy = 3)) then retval := 2 // g r
else if ((BRx = 2) and (BRy = 1)) then retval := 3 // y g
else if ((BRx = 2) and (BRy = 2)) then retval := 4 // y y
else if ((BRx = 2) and (BRy = 3)) then retval := 5 // y r
else if ((BRx = 3) and (BRy = 1)) then retval := 6 // r g
else if ((BRx = 3) and (BRy = 2)) then retval := 7 // r y
else if ((BRx = 3) and (BRy = 3)) then retval := 8; // r r

//r=red g=green y=yellow
result := retval;
end;

//......................................................................
procedure TInnerReliabilitySeries.SetImageList(const Value: TImageList);
begin
FImageList := Value;
end;

//................................................................
procedure TInnerReliabilitySeries.SetIRxValues(
const Value: TChartValueList);
begin
SetChartValueList(FIRxValues,Value);
end;

//..................................................................
procedure TInnerReliabilitySeries.SetIRyValues(
const Value: TChartValueList);
begin
SetChartValueList(FIRyValues,Value);
end;

//...................................................................
procedure TInnerReliabilitySeries.SetLowerBound(const Value: double);
begin
FlowerBound := Value;
end;

//......................................................................
procedure TInnerReliabilitySeries.SetUpperBound(const Value: double);
begin
FupperBound := Value;
end;

end.

AeroSys
Newbie
Newbie
Posts: 17
Joined: Tue Mar 01, 2005 5:00 am
Location: Saint Paul, MN
Contact:

Post by AeroSys » Sat May 07, 2005 3:57 am

This is a reply from a similar post on the About Delphi forum:
From: spgilmor1 11:30 am
To: drmhstevens 2 of 2

11833.2 in reply to 11833.1

It sounds like you're confusing overriding with events.

The error message you're getting is because you're marking DoGetImage() with the override keyword. This tells it to extend from the method of the same name from the ancestor class. It sounds like you understand this part.

From what you've described of the docs, it sounds like you don't have to actually extend anything (or descend from anything). You only have to implement the handler procedure (which you've done) and assign it to the event.

The part that I think you're missing is the assignment to the event.

At some point (I recommend in the constructor or the AfterContruction procedure), you need to assign the event handler to the event.

self.OnGetImage := self.DoGetImage;

Post Reply