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
 trying to copy (duplicate) a layer
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

nwscomps

185 Posts

Posted - Sep 17 2018 :  03:15:45  Show Profile  Reply
procedure TForm1.CopyLayer1Click(Sender: TObject);
begin
  fCopyIELayer.Assign(fCurrentIEView.CurrentLayer);
end;

procedure TForm1.Paste1Click(Sender: TObject);
begin
  fCurrentIEView.LayersCurrent := fCurrentIEView.LayersAdd(fCopyIELayer.Kind);
  fCurrentIEView.CurrentLayer.Assign(fCopyIELayer);
end;


I am trying this code to duplicate a layer with copy and paste, but what I get in the end is always an empty layer (no matter the kind).
Any clue on this one?
Thanks

Francesco Savastano
Nwscomps.com
Add-ons for the ImageEn Library

xequte

39053 Posts

Posted - Sep 17 2018 :  06:12:33  Show Profile  Reply
Hi Francesco

You can simply use:

fCurrentIEView.LayersAdd( SomeLayer );

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

nwscomps

185 Posts

Posted - Sep 17 2018 :  07:54:31  Show Profile  Reply
Hi Nigel, please try the code I gave. It does not matter the kind of layer I copy I always end up with an empty layer.
I also tried your suggestion, same result.

You asked what kind of layer it is, I create it with this code;

fCopyIELayer := TIELayer.Create(nil);

Then when user hits copy follows:

fCopyIELayer.Assign(fCurrentIEView.CurrentLayer);
//here the kind should determined by the assign method
Then on paste:
//I create a layer of the same kind
fCurrentIEView.LayersCurrent := fCurrentIEView.LayersAdd(fCopyIELayer.Kind);
//I assign my copy to it
fCurrentIEView.CurrentLayer.Assign(fCopyIELayer);


Francesco Savastano
Nwscomps.com
Add-ons for the ImageEn Library
Go to Top of Page

xequte

39053 Posts

Posted - Sep 17 2018 :  21:58:19  Show Profile  Reply
Hi Francesco

The problem is that fCopyIELayer is a TIELayer, but in TIELayer.Assign it checks the class. So you need to typecast the TIELayer.

I will improve this for 8.1.1. You can email me for the updated source.

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

nwscomps

185 Posts

Posted - Oct 03 2018 :  10:32:05  Show Profile  Reply
Hello Nigel,
I tried with v.8.1.1 to assign an image layer to a text layer. It still does not work. After assigning it remains an image layer. I thought this was fixed in the new version.

Francesco Savastano
Add-ons for the ImageEn Library
web: http://www.fssoft.it/delphicomps.html
Go to Top of Page

xequte

39053 Posts

Posted - Oct 03 2018 :  19:01:15  Show Profile  Reply
Hi Francesco

You cannot use assign to change the type of a class (at least I cannot think of any way in Delphi that it would be possible).

In 8.1.1 we made it possible for you to store a layer as a generic TIELayer and to assign that to other layers, but you still cannot change the type of that layer.

Instead you should remove the current layer and then create a new one using your generic TIELayer, something like.

idx := ImageEnView1.LayersCurrent;
ImageEnView1.LayersRemove( idx );
ImageEnView1.LayersInsert( idx, fStoredLayer );

(Note: You cannot remove layer 0)

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