The coordinates for defining and positioning objects within containers are translated to device coordinates only when the objects are displayed. Each object is defined and positioned relative to its container. The container sets the frame of reference.
At the time of display, the coordinates are modified using scalar properties (scaling factors), and offset properties. Thus, the scaling factors translate the internal values to the coordinate system of the display space, and the offsets position the scaled object in the display space.
Each time the image is zoomed or scrolled, update the scaling factors and offsets of the container, and redraw the objects in the window that owns the container.
Scaling factors and offsets can be applied to objects other than the container, but that is not necessary for matching the objects to the displayed image. The scaling factors and offsets of a container apply to all objects within the container.
After setting the scalar values to some value, the mouse movement will be snapped to the grid that represents the scaling factor.