ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder
ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 How do I save&recall ObjUserData in multiple image
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

superdev

5 Posts

Posted - Aug 06 2019 :  13:47:10  Show Profile  Reply
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;


xequte

4648 Posts

Posted - Aug 07 2019 :  03:34:58  Show Profile  Reply
Hi

Have you tried the UserData demo:

Demos\VectorEditor\UserDataVect\UserDataVect.dpr

Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To: