[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-kimageshop
Subject:    Re: undo/redo
From:       Carsten Pfeiffer <carpdjih () cetus ! zrz ! TU-Berlin ! DE>
Date:       1999-08-09 22:01:05
[Download RAW message or body]

On Mon, Aug 09, 1999 at 12:30:56PM +0200, Matthias Elter wrote:

Hi
 
> There are two different modifications:
> 
> - Modifications of image data: We have to make snapshots of modified
> areas per layer.
> We should keep the last few snapshots in memory (let the user adjust the
> max. memory that may be used for undo) and save older snapshots on disk.
>  
> - Other modifications that do not effect the image data (zoom in/out,
> ruler metric changes etc.): We just have to save the action that has
> been done.

for the second type (like zooming), where only the view would be affected,
I don't think undo/redo is necessary, as the operation is perfectly
reversible. But maybe there could be a history-function for those
operations.

We need a base "image operation" class; every filter, tool or whatever
inherits that and has to implement/provide an apropriate undo-mechanism.

I talked about this a while ago with a friend (Florian Hacker), and that's
what we came up with:

Every image operation creates an undo-object. The undo objects are stored
in a list.
There are different undo-implementations, a filter can subclass the base
undo-class and provide an undo-class perfectly efficient for his purposes.
E.g. one might only store the coordinates and values of pixels changed by
the filter. Or even better, an undo-implementation for a 
"paint-rectangle-tool" can reduce the coordinates to 3 edge-coordinates.

Filter independent implementations:
- the lazy one, just storing the whole previous image
- diffing the original and filtered image and saving coordinates/values of
  affected pixels

We can start with those and add better ones, later.

The Undo-class has two public methods, undo() and redo() (and maye load()
and save(), so they can be stored within an image).


The user sees these undo objects as a history in a listbox, e.g.

+---------------+
|New image      | (1st operation)
|---------------|
|Gaussion Blur  |
|---------------|
|Resize         |
|---------------|
|Selection      |
|---------------|
|Paint tool     | (last operation)
|_______________|

Now he decides, that resizing was wrong, he just selects the Gaussion Blur
state, and all the following actions are undone. The selection and paint
tool actions are not immediately destroyed - he can redo them (both
or only the the selection) as long as no further image manipulation is
performed (then, the selection and paint undo-objects are deleted and
removed from the list.


What do you think?

PS: I'll be away for a few days (surfing :-P), so I won't be able answer
in the meantime. Also, I haven't committed the brush dialog, as it's not
ready yet. There's also a generic icon chooser class, that can be used for
other dialogs, please be patient.

Cheers,
Carsten Pfeiffer
-- 
http://www.geocities.com/SiliconValley/1632/

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic