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
 Polyline layer creation
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

pierrotsc

USA
497 Posts

Posted - Apr 18 2021 :  13:34:52  Show Profile  Reply
I think i am trying too hard but cannot figure out this one.
I have a background picture and want to draw a polyline on another layer on top of my background.

I am missing something. every time i draw, it had the polyline on the same layer as the background.
Here's my code.
ActiveImageEnView().MouseInteractGeneral := [];
ActiveImageEnView().LayerOptions := ActiveImageEnView().LayerOptions +
[loAllowMultiSelect, loAutoSelectMask, loShowRotationGrip];


ActiveImageEnView().LayersAdd(TIELayerKind(ielkPolyline));
ActiveImageEnView().LayersAutoClosePolylines := iecmOnNearFinish;
ActiveImageEnView().MouseInteractLayers := [mlMoveLayers, mlEditLayerPoints,
mlRotateLayers, mlResizeLayers, mlDrawCreatePolylineLayers];
ActiveImageEnView().CurrentLayer.FillColor := clNone;
ActiveImageEnView().CurrentLayer.BorderWidth := 3;
ActiveImageEnView().CurrentLayer.BorderColor := clred;
ActiveImageEnView().Update;

Thank you
Pierre

xequte

38107 Posts

Posted - Apr 19 2021 :  00:56:45  Show Profile  Reply
Hi Pierre

Have you tried the demo:

\Demos\LayerEditing\Layers_Lines\Layers.dpr

Looking at your code you add a blank polyline layer, that is not needed:

ActiveImageEnView().LayersAdd(TIELayerKind(ielkPolyline));

As mlDrawCreatePolylineLayers will automatically create a polyline layer as the user draws.

If you check ActiveImageEnView().LayersCount (or a TImageEnLayerMView to your project), you will see it will increase as each polyline is drawn.





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

pierrotsc

USA
497 Posts

Posted - Apr 19 2021 :  08:01:01  Show Profile  Reply
Originally the line
ActiveImageEnView().LayersAdd(TIELayerKind(ielkPolyline));

was commented.
when i draw, the polyline is showing on my background layer in the TImageEnLayerMView window. it does not add another layer.

I will look at the layer demo.

Thanks
Pierre
Go to Top of Page

pierrotsc

USA
497 Posts

Posted - Apr 19 2021 :  11:43:16  Show Profile  Reply
Just looked at the layer demo. it uses the
ImageEnView1.LayersAdd( TIELayerKind( cmbAddLayer.ItemIndex ));

So when i do that, it works too.
It does not use the mlDrawCreatePolylineLayers
On the newlayer event, it makes an explosion. Not really what i am looking for.
case LayerKind of
ielkPolyline : if mlCreatePolylineLayers in ImageEnView1.MouseInteractLayers then // This ensures we don't fill the points when drawing our own polyline using mlClickCreatePolylineLayer
TIEPolylineLayer( ImageEnView1.CurrentLayer ).SetPoints( iesExplosion, True );

So, for me using :
ActiveImageEnView().MouseInteractLayers := [mlMoveLayers, mlEditLayerPoints,
mlRotateLayers, mlResizeLayers, mlDrawCreatePolylineLayers];

do draw a polyline but not on a new layer.

Best
Go to Top of Page

xequte

38107 Posts

Posted - Apr 19 2021 :  17:29:06  Show Profile  Reply
Hi

I think there might be some confusion. mlDrawCreatePolylineLayers cannot "draw" onto an image layer (background is image layer) so a new layer must be being created in this situation.

Did you change LayersCount?

Please add a TImageEnLayerMView, connect it to the TImageEnView and observe what happens when you draw a polyline (a new polyline layer should appear).



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

xequte

38107 Posts

Posted - Apr 19 2021 :  17:31:27  Show Profile  Reply
Also, you have looked at the wrong demo. Please look at this one:

\Demos\LayerEditing\Layers_Lines\Layers.dpr

Which shows freehand polyline drawing.

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

pierrotsc

USA
497 Posts

Posted - Apr 19 2021 :  17:33:32  Show Profile  Reply
Ok, when I draw a poly line on top of my image background, the layer view only show the layer background with the poly line inside. So I get one layer and not 2. I have a timageenmview layer connected to my imageenview.
Go to Top of Page

xequte

38107 Posts

Posted - Apr 19 2021 :  17:39:38  Show Profile  Reply
Hi

Please attach some screenshots so I can better understand what is happening.



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

pierrotsc

USA
497 Posts

Posted - Apr 19 2021 :  18:25:04  Show Profile  Reply
So i drew a polyline on top of my image background. the brush color filled it.

Go to Top of Page

xequte

38107 Posts

Posted - Apr 20 2021 :  01:54:22  Show Profile  Reply
Hi

You must have some auto-merge code in this unit. In your OnLayerNotify event perhaps??? Please email me the source for this demo.

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

pierrotsc

USA
497 Posts

Posted - Apr 20 2021 :  08:15:54  Show Profile  Reply
Nigel, you are correct. did not look at that because every kind of other layer i add, it did not behave live that. i wonder why. this is my onlayer event

procedure TMainForm.ImageEnViewLayerNotifyEx(Sender: TObject; layer: Integer;
  Event: TIELayerEvent);
const
  Auto_Merge_Layers = true;
begin
  if Auto_Merge_Layers and (layer > 0) then
  begin
    // For text layers with automatic text editing (loAutoTextEditing in LayerOptions) don't merge till we complete editing
    if ((TImageEnView(Sender).Layers[layer].Kind = ielkText) and
      (Event = ielEdited)) or
      ((TImageEnView(Sender).Layers[layer].Kind <> ielkText) and
      (Event = ielCreated)) then
      TImageEnView(Sender).LayersMerge(0, layer);
  end;
end;


The thing is, would it not merge text layers only ?
Best
Go to Top of Page

pierrotsc

USA
497 Posts

Posted - Apr 20 2021 :  14:36:44  Show Profile  Reply
Nigel, i found my coding error. Thanks for finding the auto_merge culprit.
Best
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: