The following filters, which derive from TCanvasSelectionFilter, pass the funnel to the canvas graphics in the representation, but also to the selection feedback graphic (which is also a canvas graphic). The selection filter creates the selection feedback graphic as needed to represent the visual feedback that identifies the current selection. The filter destroys the selection feedback graphic after the funnel has processed it.
In the filter classes described in this section, the two functions that you can modify to do something else are the First and Next functions.
The following code only finds graphics that are in the selection. The selection doesn't have to be the document selection. It can be any transitory selection created to enumerate over the graphics.
TCanvasTopSelection
HitDetectionFilter
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 order. 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. Constructor
TCanvasTopSelectionHitDetectionFilter::TCanvasTopSelectionHitDetectionFilter
(const MCanvasSelection* selection) :
TCanvasSelectionFilter(),
fSelection (selection),
fSelectionPass (false),
fCurrentFeedbacker (NIL)
{
}
Destructor
First
// Copyright (C) 1995 Taligent, Inc. All rights reserved.
const MCanvasGraphic*
TCanvasTopSelectionHitDetectionFilter::First ()
{
TCanvasGraphicReadIterator *i = GetIterator ();
const MCanvasGraphic* first = NIL;
if ( i ) {
first = i->First ();
if ( first != NIL && fSelection != NIL ) {
fSelectionPass = true;
if ( fSelection->IsGraphicSelected(*first) ) {
fCurrentFeedbacker = GetGraphicFeedbacker (*first);
if (!fCurrentFeedbacker)
fCurrentFeedbacker = GetCanvasFeedbacker (*first);
first = fCurrentFeedbacker;
}
else
first = Next ();
}
}
return first;
}
Next
const MCanvasGraphic*
TCanvasTopSelectionHitDetectionFilter::Next ()
{
TCanvasGraphicReadIterator *i = GetIterator ();
const MCanvasGraphic* next = NIL;
if ( i ) {
next = i->Next ();
if ( fSelectionPass ) {
while (next != NIL && !fSelection->IsGraphicSelected(*next))
next = i->Next ();
if ( next != NIL ) {
fCurrentFeedbacker = GetGraphicFeedbacker (*next);
if (!fCurrentFeedbacker)
fCurrentFeedbacker = GetCanvasFeedbacker (*next);
next = fCurrentFeedbacker;
}
else {
fSelectionPass = false;
next = i->First ();
}
}
}
return next;
}
TCanvasTopSelection
DrawingFilter
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. Constructor
// Copyright (C) 1995 Taligent, Inc. All rights reserved.
TCanvasTopSelectionDrawingFilter::TCanvasTopSelectionDrawingFilter (const MCanvasSelection* selection) :
TCanvasSelectionFilter(),
fSelection (selection),
fSelectionPass (false),
fCurrentFeedbacker (NIL)
{
}
Destructor
First
const MCanvasGraphic*
TCanvasTopSelectionDrawingFilter::First ()
{
TCanvasGraphicReadIterator *i = GetIterator ();
const MCanvasGraphic* first = NIL;
if ( i )
first = i->Last ();
return first;
}
Next
const MCanvasGraphic*
TCanvasTopSelectionDrawingFilter::Next ()
{
TCanvasGraphicReadIterator *i = GetIterator ();
const MCanvasGraphic* next = NIL;
if ( i ) {
next = i->Previous ();
if ( next == NIL && !fSelectionPass && fSelection != NIL) {
fSelectionPass = true;
next = i->Last ();
}
if ( fSelectionPass ) {
while (next != NIL && !fSelection->IsGraphicSelected(*next))
next = i->Previous ();
if ( next != NIL ) {
fCurrentFeedbacker = GetGraphicFeedbacker (*next);
if (!fCurrentFeedbacker)
fCurrentFeedbacker = GetCanvasFeedbacker (*next);
next = fCurrentFeedbacker;
}
}
}
return next;
}
[Contents]
[Previous]
[Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Generated with WebMaker