
Step 1:

just sketching the app: the class structure, the events, the general
idea

Note: this code may be reused. pay attention to `draw_background'

Step 2:

adding basic rubber band selection stuff; the selection is recorded in
the corresponding object; try to left click and drag around the
window; for now, if there is another click, another selection is
started no matter what

Step 3:

the selection class now gets some code; functionality added: after
releasing the left button, one can now use the left button to move
individual points. a click with the left button outside the points
restarts the rubberband selection

Step 4:

The order of the selection point matters; we need a way to show that
and to allow the user to edit this order.

Showing the order can be done drawing numbers around each
point. However, this has the disadvantage of overloading the drawing
and there is some work required in order to find the best
(uncluttered) position of the numbers all the time. This is why I
chose a simpler way: The first point is drawn a bit larger and it's
square is thicker, and there is a small arrow pointing to the second
point. Given the fact we only have four points, this is a pretty good
indication of the order, without overloading the interface with
drawings. All the required modifications occur in the `draw' command
of the selection class. There should be a small modification in the
`matches_point' query also ...

About the editing: one clicks a point with the middle button and then
presses a number from one to four. The clicked point becomes the point
number <number pressed on the keyboard>. If the typed number is 5 the
whole selection is rotated "to the left" (point 2 becomes 1, 3->2,
4->3, 1->4). If it's 6 then the rotations is in the other order.

Step 5:

Ok, this is pretty much done. Only a few things are left: implementing
the "zoom" (in our case just showing the coordinates of the selection)
and something about drawing: the xor technique is usually used because
you dont have to remember what was drawn underneath your drawing (just
drawing your stuff again erases the first time's traces) and because
it maximizes contrast between the two parts (the background and the
xor-drawing). So far, the example used only the last effect (the first
was useless as everything was redrawn every time). This looks good
enough (for most apps) and it's safe. For the sake of speed, the
backgroud could be drawn in a pixmap and then the pixmap drawn as the
background in `draw_background'. Whenever there is a need to change
it, the pixmap is changed.

Added functionality in this example: clicking with the right button
anywhere (when there is a selection) shows the text representation of
the selection and resets the whole thing. There is a `zoom' method
added which displays a message box and a `reset' method which prepares
the widget for a brand new selection.

`zoom' could be redefined to do something actually useful.
