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
 Object Property Defaults
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

egrobler

42 Posts

Posted - Apr 08 2014 :  12:41:03  Show Profile  Reply
Hi Everyone,
If I create 2 lines:
with ImageEnVect1 do
begin
  ObjKind[-1] := iekLINE;
  ObjLeft[-1] := 0; ObjTop[-1] := 0;
  ObjWidth[-1] := 100; ObjHeight[-1] := 100;
  ObjPenColor[-1] := clRed;
  ObjPenWidth[-1] := 10;
  AddNewObject;
end;

with ImageEnVect1 do
begin
  ObjKind[-1] := iekLINE;
  ObjLeft[-1] := 0; ObjTop[-1] := 200;
  ObjWidth[-1] := 100; ObjHeight[-1] := 100;
  ObjPenColor[-1] := clBlue;
  //ObjPenWidth is still 10 from previous object
  AddNewObject;
end;

then the second line will also have a ObjPenWidth of 10.
So the lines will be different if I move the 2 blocks of code around (create blue line first).

How can I reset the TImageEnVect.fNewObj to it's initial/default values? (I am using ImageEn 5.0.6)

Regards
Eric

w2m

USA
1990 Posts

Posted - Apr 08 2014 :  15:01:14  Show Profile  Reply
Why don't you just set the ObjPenWidth[-1] := xx with the second line?

William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Custom ImageEn Development
Go to Top of Page

egrobler

42 Posts

Posted - Apr 08 2014 :  15:35:57  Show Profile  Reply
> Why don't you just set the ObjPenWidth[-1] := xx with the second line?

Because it is bad practice to have to deal with side effects.

ObjPenWidth is not enough, I also have to think about
PenStyle.

And if it is a ieBOX what about
BrushStyle
BoxHighlight
BoxHighlight
etc.

I assume your answer is that one cannot revert to the default values/settings?

My suggestion is that in the next version the initialization code inside the constructor is re-factored to a SetDefaultObjectProperties method.
constructor TImageEnVect.Create(Owner: TComponent);
begin
...
  with fNewObj do
  begin
    x1 := 0;
    y1 := 0;
    x2 := IEDEFWIDTH - 1;
    y2 := IEDEFHEIGHT - 1;
    a1 := 0;
    a2 := 2 * pi;
    PenColor := clWhite;
    PenStyle := psSolid;
    PenWidth := 1;
    ...
  end;
...
end;


Regards
Eric
Go to Top of Page

xequte

38608 Posts

Posted - Apr 08 2014 :  16:42:52  Show Profile  Reply
Hi Eric

Thanks for your suggestion. We'll probably look at doing this as a parameter to AddNewObject.



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

egrobler

42 Posts

Posted - Apr 08 2014 :  17:11:02  Show Profile  Reply
Thank you Nigel
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: