// SquidDiffBlocker.cpp: implementation of the SquidDiffBlocker class. // ////////////////////////////////////////////////////////////////////// #include <qrect.h> #include <qvaluelist.h> #include "SquidDiffBlocker.h" ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// SquidDiffBlocker::SquidDiffBlocker( int min ) : minblocksize( min ) { } SquidDiffBlocker::~SquidDiffBlocker() { } void SquidDiffBlocker::AddPixel( int x, int y ) { if ( list.isEmpty() ) { list.prepend( QRect( x - 1, y - 1, 3, 3 ) ); return; } QRectList::iterator it; for ( it = list.begin(); it != list.end(); ++it ) { if ( (*it).contains( x, y ) ) return; if ( (*it).top() - 1 <= y && y <= (*it).top() && (*it).left() <= x && x <= (*it).right() ) { (*it).setTop( y ); return; } if ( (*it).bottom() <= y && y <= (*it).bottom() + 1 && (*it).left() <= x && x <= (*it).right() ) { (*it).setBottom( y ); return; } if ( (*it).left() - 1 <= x && x <= (*it).left() && (*it).top() <= y && y <= (*it).bottom() ) { (*it).setLeft( x ); return; } if ( (*it).right() <= x && x <= (*it).right() + 1 && (*it).top() <= y && y <= (*it).bottom() ) { (*it).setRight( x ); return; } } list.prepend( QRect( x - 1, y - 1, 3, 3 ) ); } void SquidDiffBlocker::CleanUp() { bool acted = false; if ( list.isEmpty() ) return; QRectList::iterator it, him; for ( it = list.begin(); it != list.end(); ++it ) { (*it).addCoords( -1, -1, 1, 1 ); for ( him = it ; him != list.end(); ++him ) { (*him).addCoords( -1, -1, 1, 1 ); if ( (*it).intersects( *him ) && him != it ) { (*it) = (*it).unite( *him ); him = list.erase( him ); acted = true; } else { (*him).addCoords( 1, 1, -1, -1 ); } } (*it).addCoords( 1, 1, -1, -1 ); } if ( acted ) { CleanUp(); return; } for ( it = list.begin(); it != list.end(); ++it ) { (*it).addCoords( -1, -1, 1, 1 ); if ( (*it).width() * (*it).height() < minblocksize ) it = list.erase( it ); } for ( it = list.begin(); it != list.end(); ++it ) { if ( (*it).width() * (*it).height() < minblocksize ) { list.erase( it ); it = list.begin(); } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 2401 | Sam Stafford |
Rename SID to SQUID - avoids conflicts with another program. Also lets me use cool squid icon. |
||
//guest/sam_stafford/sid/src/SidDiffBlocker.cpp | |||||
#2 | 2050 | Sam Stafford | Settings. | ||
#1 | 2036 | Sam Stafford |
Uber-L33T "highlight" feature. Has to be seen to be believed. |