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
 PolyLines
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

pierrotsc

USA
497 Posts

Posted - Nov 28 2018 :  16:10:01  Show Profile  Reply
I am trying to see if i can convert my vector objects to the new layer kind. Does the code is supposed to work only with imageenview and not imageenvect ?

I created a blank new project and added that
procedure TForm1.FormShow(Sender: TObject);
begin
// Draw a triangle polygon
With TIEPolylineLayer( ImageEnVect1.CurrentLayer ) do
begin
  ClearAllPoints();
  AddPoint( 500, 0 );
  AddPoint( 1000, 1000 );
  AddPoint( 0, 1000 );
  PolylineClosed := True;
end;
ImageEnVect1.Update();
end;


That creates a crash when closing and i do not see anything drawn.
Best

xequte

38616 Posts

Posted - Nov 28 2018 :  18:13:13  Show Profile  Reply
Hi

Layers are TImageEnView code (Objects are TImageEnVect), so really this should only be one in a TImageEnView.

Technically TImageEnVect descends from TImageEnView, so it should work, but we don't test layers under TImageEnVect (which has been deprecated).

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

pierrotsc

USA
497 Posts

Posted - Nov 28 2018 :  18:54:00  Show Profile  Reply
Thanks, i replaced imageenvect with imageenview but i get the same behavior. nothing is drawn and i get an error when i close the program. the demo project i created just has one imageenview and the formshow event.
thanks
Go to Top of Page

xequte

38616 Posts

Posted - Nov 28 2018 :  21:50:14  Show Profile  Reply
Oh, you forgot to add a polyline layer:

ImageEnVect1.LayersAdd( ielkPolyline );

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

pierrotsc

USA
497 Posts

Posted - Nov 29 2018 :  11:29:01  Show Profile  Reply
Thank you. it now shows the triangle but i get a violation error when i close the program. I have only an imageenview and a button with this code
procedure TForm1.Button1Click(Sender: TObject);
var
shapePoints: array of TPoint;
begin
SetLength( shapePoints, 3 );
shapePoints[0] := Point( 500, 0 );
shapePoints[1] := Point( 1000, 1000 );
shapePoints[2] := Point( 0, 1000 );
TIEPolylineLayer( ImageEnView1.CurrentLayer ).SetPoints( shapePoints, True );
ImageEnView1.LayersAdd( ielkPolyline );
ImageEnView1.Update();
end;

What am i doing wrong ?
Go to Top of Page

w2m

USA
1990 Posts

Posted - Nov 29 2018 :  11:59:53  Show Profile  Reply
procedure TForm1.Button1Click(Sender: TObject);
var
  iShapePoints: array of TPoint;
begin
  SetLength( iShapePoints, 3 );
  iShapePoints[0] := Point( 500, 0 );
  iShapePoints[1] := Point( 1000, 1000 );
  iShapePoints[2] := Point( 0, 1000 ); 
  iLayer := ImageEnView1.LayersAdd(ielkPolyline);
  TIEPolylineLayer(ImageEnView1.Layers[iLayer]).SetPoints(iShapePoints, True);
  ImageEnView1.Update();
end;

Add the layer first then SetPoints.

I do not get any errors with this.

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page

pierrotsc

USA
497 Posts

Posted - Nov 29 2018 :  12:02:52  Show Profile  Reply
thanks bill. it works..no error
Go to Top of Page

xequte

38616 Posts

Posted - Nov 29 2018 :  14:54:38  Show Profile  Reply
Hi

Also, ensure that when you do a type cast, you check its type, e.g.

if ImageEnView1.CurrentLayer is TIEPolylineLayer then
TIEPolylineLayer( ImageEnView1.CurrentLayer ).SetPoints(...);


Your code above gives an A/V because ImageEnView1.CurrentLayer will be a TIEImageLayer (background layer of TImageEnView).

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

pierrotsc

USA
497 Posts

Posted - Nov 29 2018 :  14:56:30  Show Profile  Reply
Got it..Thanks
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: