type
TMyData=record
szName: String[64];
dMatch: double;
Color : TColor;
end;
PMyData=^TMyData;
TMyGroup=class(TObject)
private
FszName : string;
public
imgSource : TImageEnVect;
Light : TLight;
published
property Name : string read FszName write FszName;
end;
var MyGroup : TObjectList;
function TfrmMain.Add_AreaVector(var imgTarget: TImageEnVect; Area: TArea): Boolean;
var i : Integer;
rec : TRect;
mydata: PMyData;
t : TMyData;
begin
with imgTarget do begin
rec.Left := Area.posXY.X;
rec.Top := Area.posXY.Y;
rec.Right := Area.posXY.X + Area.sizeXY.Width;
rec.Bottom := Area.posXY.Y + Area.sizeXY.Height;
i:=AddNewObject(iekTEXT,rec,Area.Color);
ObjName[i] := Area.szName;
ObjText[i] := Area.szName;
ObjTextAlign[i] := iejCenter;
ObjTextEditable[i]:=False;
t.szName := Area.szName;
t.dMatch := Area.dMatch;
getmem(mydata, sizeof(TMyData));
mydata^.szName := t.szName;
mydata^.dMatch := t.dMatch;
mydata^.Color := t.Color;
ObjUserData[i] := mydata;
ObjUserDataLength[i] := sizeof(TMyData);
end;
end;
procedure TfrmMain.btnGroup_AddClick(Sender: TObject);
var Group_ : TMyGroup;
Area_ : TArea;
begin
imgView.RemoveAllObjects;
Group_ := TMyGroup.Create;
with Group_ do begin
Name := edtGroupName.Text;
imgSource := TImageEnVect.Create(nil);
imgSource.Assign(imgView);
Light.Top := edtControl_LightTop.Value;
Light.Bottom := edtControl_LightBottom.Value;
end;
with Area_ do begin
szName:='Align Start';
dMatch := edtGroupMatch.FloatValue;
sizeXY.Width := 120;
sizeXY.Height := 120;
posXY := Point(Round(imgView.Bitmap.Width * 1/4) - sizeXY.Width div 2,Round(imgView.Bitmap.Height * 1/2) - sizeXY.Height div 2 );
Color := clFuchsia;
end;
Add_AreaVector(Group_.imgSource,Area_);
with Area_ do begin
szName:='Align End';
dMatch := edtGroupMatch.FloatValue;
sizeXY.Width := 120;
sizeXY.Height := 120;
posXY := Point(Round(imgView.Bitmap.Width * 3/4) - sizeXY.Width div 2,Round(imgView.Bitmap.Height * 1/2) - sizeXY.Height div 2 );
Color := clFuchsia;
end;
Add_AreaVector(Group_.imgSource,Area_);
MyGroup.Add(Group_);
imgView.Assign(Group_.imgSource);
Update_GroupGrid;
grdGroup.Row:=MyGroup.Count;
end;