- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
/**
* Helper classes for computing window query on rectangles
*/
class VerticalSegmentIntersect : public std::unary_function < PRGlyph, ptrdiff_t > {
ptrdiff_t m_Lhs;
ptrdiff_t m_Rhs;
public:
VerticalSegmentIntersect ( ptrdiff_t top, ptrdiff_t bottom ) throw() : m_Lhs(top+top), m_Rhs(bottom+bottom) {}
ptrdiff_t operator() ( PRGlyph inpGlyph ) const throw() {
QRect const* area = inpGlyph->GetGlyphArea();
ptrdiff_t x = area->bottom() + area->top(), y = area->bottom() - area->top();
if (y < x - m_Rhs ) return 0;
if (y < m_Lhs - x ) return 0;
return 1;
}
};
class HorisontalSegmentIntersect : public std::unary_function < PRGlyph, ptrdiff_t > {
ptrdiff_t m_Lhs;
ptrdiff_t m_Rhs;
public:
HorisontalSegmentIntersect ( ptrdiff_t left, ptrdiff_t right ) throw() : m_Lhs(left+left), m_Rhs(right+right) {}
ptrdiff_t operator() ( PRGlyph inpGlyph ) const throw() {
QRect const* area = inpGlyph->GetGlyphArea();
ptrdiff_t x = area->right() + area->left(), y = area->right() - area->left();
if (y < x - m_Rhs ) return 0;
if (y < m_Lhs - x ) return 0;
return 1;
}
};
/**
* Helper classes for computing containment query on rectangles
*/
class VerticalSegmentContains : public std::unary_function < PRGlyph, ptrdiff_t > {
ptrdiff_t m_Lhs;
ptrdiff_t m_Rhs;
public:
VerticalSegmentContains ( ptrdiff_t top, ptrdiff_t bottom ) throw() : m_Lhs(top+top), m_Rhs(bottom+bottom) {}
ptrdiff_t operator() ( PRGlyph inpGlyph ) const throw() {
QRect const* area = inpGlyph->GetGlyphArea();
ptrdiff_t x = area->bottom() + area->top(), y = area->bottom() - area->top();
if ( y > x - m_Lhs ) return 0;
if ( y > m_Rhs - x ) return 0;
return 1;
}
};
class HorisontalSegmentContains : public std::unary_function < PRGlyph, ptrdiff_t > {
ptrdiff_t m_Lhs;
ptrdiff_t m_Rhs;
public:
HorisontalSegmentContains ( ptrdiff_t left, ptrdiff_t right ) throw() : m_Lhs(left+left), m_Rhs(right+right) {}
ptrdiff_t operator() ( PRGlyph inpGlyph ) const throw() {
QRect const* area = inpGlyph->GetGlyphArea();
ptrdiff_t x = area->right() + area->left(), y = area->right() - area->left();
if ( y > x - m_Lhs ) return 0;
if ( y > m_Rhs - x ) return 0;
return 1;
}
};
// compute the window query on m_GlyphData rectangles
QVector<PRGlyph> :: iterator windowq = m_Selection.isValid() ?
std::partition ( m_GlyphData.begin(),
std::partition ( m_GlyphData.begin(), m_GlyphData.end(), VerticalSegmentIntersect ( m_Selection.top(), m_Selection.bottom() ) ),
HorisontalSegmentIntersect ( m_Selection.left(), m_Selection.right() )
) : m_GlyphData.begin();
// compute the containment query on window query rectangles (the containment query resuls is always subset of window query )
QVector<PRGlyph> :: iterator containq = std::partition ( m_GlyphData.begin(),
std::partition ( m_GlyphData.begin(), windowq, VerticalSegmentContains ( m_Selection.top(), m_Selection.bottom() ) ),
HorisontalSegmentContains ( m_Selection.left(), m_Selection.right() )
);