Also add one Q_PROPERTY for each coordinate (x and y) of a Point. This will
enable the controller to set and get these properties.
Since QObjects cannot be copied, we also need to change the Shape class to have
a vector of pointers to Points, instead of actual Point structs.
If the vertex of the current Shape is being moved, it may be useful to "glue" it
to a vertex of another shape, if the 2 vertices are close together. This patch
implements this. THe sticky-sensitivity is controlled by the dist_stick
variable, which is currently hardcoded but could be made configurable e.g.
through the GUI.
The patch also uses a new pure virtual method called getShapeFromMappingId(),
which is implemented by Source / Dest Canvas subclasses. getCurrentShape() is
now using this function, so it is now a non-virtual function in MapperGLCanvas.
A user may find it useful in some cases to drag and drop a whole shape, instead
of moving each vertex separately. This patch implements shape drag-and-drop by
pressing and holding the right mouse button. Point inclusion algorithm should
work for non-convex and convex polygons, as suggested in
http://www.cs.tufts.edu/comp/163/notes05/point_inclusion_handout.pdf
Pressing the left-mouse button close enough to a vertex makes that vertex the
current / active one to operate on. If the button is not released, the vertex
can be dragged on the canvas. If on the source canvas, updates on the
destination canvas can be seen dynamically.
The user needs to click within a specific distance around a vertex otherwise
the click will have no effect in vertex selection. Distances of all vertices
from the point clicked are calculated (manhattan distance, but other can be
used) and the vertex with the smallest distance is declared as the new active
one.
An active vertex variable is also added in the Shape class. Both mouse and key
events update the active vertex of a shape (tested only with quad so far). So
the active vertex is no longer a static variable in the key event handler, but
is common state shared by both mouse and key event handlers.