Hit Testing

There are several situations which require finding a figure for a mouse location. For example, determining which tooltip to display when the mouse pauses on top of a figure canvas. Another example is interactive graphical applications, which must interpret dragging one figure on top of another.

There are four methods available on IFigure which perform hit testing, three of which are actually just convenience methods which call the fourth.

Hit testing must be done exactly the same way as painting. Clipping and coordinate changes must be duplicated in both. As an optimizations, branches of the figure composition tree are pruned by calling containsPoint(). If a figure does not contain the location, it returns NULL and does not search its children. By default, all figures are considered to be the rectangular region defined by their bounds, regardless of how or if they paint. This can be overridden as it is in Polyline, Ellipse, and other figures.