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
 Learning Layers - Multiple Objects
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

HMArnold

USA
23 Posts

Posted - Sep 15 2024 :  15:27:48  Show Profile  Reply
I'm trying to draw simple shapes using the new TImageEnView environment in response to mouse movement.

In the old TImageEnVect you could add as many shapes or lines as you wanted, each with a handle that could be erased individually.

With the new TImageEnView, this code...

if TrgtC1 <> 0 then Image.LayersRemove(TrgtC1);
if TrgtC2 <> 0 then Image.LayersRemove(TrgtC2);

Rect.Create(Point(Vrtx.X-10,Vrtx.y-10),Point(Vrtx.X+10,Vrtx.Y+10));
TrgtC1 := Image.LayersAdd(iesEllipse, Rect, clRed, 3);

Rect.Create(Point(Vrtx.X-2,Vrtx.y-2),Point(Vrtx.X+2,Vrtx.Y+2));
TrgtC2 := Image.LayersAdd(iesEllipse, Rect, clBlue, 1);

Produces two concentric circles, but only erases one as the mouse moves.

Is there a single shape layer and all your shapes goes on that or is there supposed to be a different layer for each shape?

How do you add objects that have individually erasable handles?

I find lots of examples and demos with a single object, but none with two or more

Thanks

HM Arnold

xequte

38496 Posts

Posted - Sep 15 2024 :  23:08:52  Show Profile  Reply
Hi

The result of LayersAdd() is an index, so you shouldn't pass that to LayersRemove() if the indexes of your layers may change.

You should identify your layers in some way, e.g. with a name:

if TrgtC1 <> '' then 
begin
  ImageEnView1.LayersRemove( ImageEnView1.LayersNameToIndex( TrgtC1 ));
  TrgtC1 := '';
end;  
if TrgtC2 <> '' then 
begin
  ImageEnView1.LayersRemove( ImageEnView1.LayersNameToIndex( TrgtC2 ));
  TrgtC2 := '';
end;  

Rect.Create(Point(Vrtx.X-10,Vrtx.y-10),Point(Vrtx.X+10,Vrtx.Y+10));
ImageEnView1.LayersAdd( iesEllipse, Rect, clRed, 3 );
TrgtC1 := 'TempLayer_' + IntToStr( Random( 10000 ));
ImageEnView1.CurrentLayer.Name := TrgtC1;

Rect.Create(Point(Vrtx.X-2,Vrtx.y-2),Point(Vrtx.X+2,Vrtx.Y+2));
ImageEnView1.LayersAdd(iesEllipse, Rect, clBlue, 1);
TrgtC2 := 'TempLayer_' + IntToStr( Random( 10000 ));
ImageEnView1.CurrentLayer.Name := TrgtC2;


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

HMArnold

USA
23 Posts

Posted - Sep 16 2024 :  07:14:16  Show Profile  Reply
Thanks very much.

My use of two layers is because I haven't found anything about adding multiple objects to a single layer. Is there a way to do that?

If so, I can put everything on that layer and work with it all at once, even moving the entire layer with a MouseMove hopefully.

Is that possible?

If not, a triangle is always 3 layers with 3 names?



HM Arnold
Go to Top of Page

xequte

38496 Posts

Posted - Sep 17 2024 :  00:54:19  Show Profile  Reply
Hi

Not sure what you mean by a triangle being three layers. A triangle only requires one TIEShapeLayer or TIEPolylineLayer. If you need multiple shapes on a single layer, you could create a TIEPolylineLayer with a complex path (SVG type path with MoveTo, LineTo, CurveTo, etc):

http://www.imageen.com/help/TIEPolylineLayer.EnableComplexPath.html




Alternatively, you could use a "virtual layer", i.e. just draw the layer as required. Take a look at:

\Demos\LayerEditing\Layers_CustomDraw\LayersDraw.dpr

Or painted as it is sized:

\Demos\LayerEditing\SVGVectorLayers\SVGLayers.dpr


You can easily output your shapes to the Layer.Bitmap.IECanvas using the TIECanvas methods like:

http://www.imageen.com/help/TIECanvas.AdvancedDrawShape.html



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