Filters

The filter determines which canvas graphics to enumerate and in which order. The filter can change the order (sort) the canvas graphics, eliminate unwanted graphics from the enumerated list, and introduce new canvas graphics.

Iteration

All EnumerateGraphics implementations create a bidirectional, read-only iterator to iterate over the canvas graphics specified in the filter by calling MCanvasRepresentation::CreateReadIterator. This iterator is passed to the filter inside EnumerateGraphics with the SetIterator function shown below.

    void TCanvasGraphicFilter::SetIterator( TCanvasGraphicReadIterator* );
The filter acts as a unidirectional iterator that controls which graphics are to be iterated and in what order. Clients call the First function to receive the first canvas graphic, and the Next function to receive each subsequent canvas graphic. These functions return constant canvas graphics because the iterator is read-only.

      const MCanvasGraphic virtual const TCanvasGraphicFilter::MCanvasGraphic* First() = 0;
      const MCanvasGraphic virtual const TCanvasGraphicFilter::MCanvasGraphic* Next() = 0;
Filters implement selection drawing and interaction strategies in GrafEdit. A filter can skip unwanted graphics by calling TCanvasReadIterator::Next or TCanvasReadIterator:Previous multiple times before retrieving a graphic, and can change the iteration direction by translating Next to Previous and vice versa. The filter can introduce and return new graphics in place of, or in addition to, those returned by the read iterator.

Derived classes

TCanvasGraphicFilter is abstract. GrafEdit provides the following ordering, hit detection, and selection concrete filter classes.

Ordering

TCanvasBackToFrontFilter: This filter iterates over the graphics in the representation from back to front. This is useful for drawing graphics with a painters algorithm (from back to front).

TCanvasFrontToBackFilter: This filter iterates over graphics in the representation from front to back, which is a good order for hit detection because if the graphic on top is hit, there is no need to test the graphics beneath.

Hit detection and selection

The following filters pass the funnel to the canvas graphics in the representation, as well as to the selection feedback graphic (which is also a canvas graphic). The selection feedback graphic is created as needed by the selection filter to represent the visual feedback that identifies the current selection. The selection feedback graphic is destructed by the filter after the funnel has processed it. These filters derive from TCanvasSelectionFilter.

TCanvasTopSelectionHitDetectionFilter: This filter is constructed from a canvas selection. The filter iterates over the graphics in the selection from front to back and returns a TSRTFeedback instance for them. It then iterates all graphics in the representation (not just those in the selection) front to back and returns each graphic in turn. This filter algorithm is useful in hit detection when you want to know whether the end user clicked on the selection feedback graphic or on the canvas graphic. For example, if you have a graphic-specific interactor, the feedback graphic should be included in the hit detection because the feedback graphic provides interactive potential beyond that of the selected canvas graphic.

TCanvasTopSelectionDrawingFilter: This function is constructed from a canvas selection. The filter iterates over the graphics in the representation from back to front and returns a TSRTFeedback instance for them. This filter algorithm is useful for drawing with a painters algorithm (from back to front) when you want to include the selection feedback graphic. You might want to derive from TCanvasTopSelectionDrawingFilter to create similar filters with custom selection strategies.


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker