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
 Is the Undo mechanism (ObjUndo) and drawing on ImageEnVect.IEBitmap compatible ?
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Stalker4

Ukraine
39 Posts

Posted - Feb 14 2025 :  05:39:37  Show Profile  Reply
Hi,

ImageEn 13.0, Delphi 12.1 (Update 1)

There is a demo of this problem in atach.
There is some scanned document. I need to color in some parts of it. But I also want to be able to roll back some of the last changes (coloring) in it. For this I wanted to use the "Proc.Undo" (or "ObjUndo") rollback mechanism.

But it doesn't work for some reason, it doesn't want to roll back changes.

In the demo I try to use the automatic mode of rollback changes (AutoUndo = True), but I tried to use the manual mechanism as well. (AutoUndo = False), but it also almost does not work - after (ObjAutoUndo = False and ObjSaveUndo, changes are not removed at all, and after (Proc.AutoUndo = False and Proc.SaveUndo) only one last change is removed.
Question: Is this an ImageEn error or am I doing something wrong ?

attach/Stalker4/202521453928_undo.zip
318.29 KB

xequte

38793 Posts

Posted - Feb 15 2025 :  16:22:57  Show Profile  Reply
Hi

Firstly, avoid using TImageEnVect, it is a legacy component (and you make no use of the vect functionality in your demo).

Your code draws directly to the canvas. Direct editing of the bitmap does not trigger automatic saving of an undo, so you will need to manually save the undo first:

// Allow undo of an operation upon the bitmap canvas
ImageEnView1.Proc.SaveUndo( 'Draw Rectangle', ieuImage );
ImageEnView1.IEBitmap.Canvas.Pen.Color := clRed;
ImageEnView1.IEBitmap.Canvas.Rectangle( X1, Y1, X2, Y2 );
ImageEnView1.Update();

http://www.imageen.com/help/TImageEnProc.SaveUndo.html

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

Stalker4

Ukraine
39 Posts

Posted - Feb 17 2025 :  03:34:42  Show Profile  Reply
Hi,

There's a new demo in atach.

1. replaced TImageEnVect with TImageEnView (although ImageEnView has no ObjUndo methods and properties).

2. I changed the rest of the code according to your example, but still if I make several selections, the changes are canceled only for the last selection. But each time Proc.Undo should undo one last selection in sequence.

3. As for the use of Canvas, there is a commented line in the code using IEBitmap.Rectangle call (i.e. without canvas) - Proc.AutoUndo doesn't work with it either.

Maybe coloring of text (in my example I do it using Rectangle method) is not compatible with Proc.AutoUndo ?

attach/Stalker4/202521733533_undo2.zip
318.2 KB
Go to Top of Page

xequte

38793 Posts

Posted - Feb 17 2025 :  16:51:59  Show Profile  Reply
1. Instead you should be using ImageEnView1.Proc.Undo();

https://www.imageen.com/help/TImageEnProc.Undo.html

2. Before each change call SaveUndo() to save that state to the undo stack. Then each time you call ImageEnView1.Proc.Undo() you will move backwards one step in the undo stack

3. AutoUndo does not support any canvas or bitmap methods (only TImageEnProc ones). You need to manually call ImageEnView1.Proc.SaveUndo();

Also ensure you set a reasonable undo limit:

ImageEnView1.Proc.UndoLimit := 50;

https://www.imageen.com/help/TImageEnProc.UndoLimit.html

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

Stalker4

Ukraine
39 Posts

Posted - Feb 18 2025 :  03:36:40  Show Profile  Reply
Hi,

If You watch my demo (undo2) from my previous post, you will see that I did everything there as you wrote in your last post.
And yet, for some reason only one, the most recent change is canceled.

Can You make some adjustments to my demo (Undo2), so that it would undo all changes from the last to the first one in sequence ?
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: