
Originally Posted by
talk2amulya
well, why dont u derive from QRectF and write the function urself. I dont think QT guys are gonna add anything like that

Having QRectF, QLineF, QPointF, and
QRectF::intersects( const QRectF& )
QRectF::contains( const QPointF& )
QLine::intersect( const QLineF& ) // <== why not use "intersects" to be consistent?
and it is reasonable to expect QRectF::intersects( const QLineF& ). It is definitely needed for rendering purpose.
I need to draw a polyline with over 20,000 points, it is very slow to draw them all when there is an exposure event, and I found QStyleOptionGraphicsItem::exposedRect
So I do
for ( int idx = 0; idx < totalPoints; idx++ ) {
If ( exposedRect.
intersects( QLineF( p1, p2
) ) { // perhaps I need to do QLineF::cutThrough( const QRectF& )? painter->drawLine( p1, p2 );
}
}
for ( int idx = 0; idx < totalPoints; idx++ ) {
QPointF p1 = ...
QPointF p2 = ...
If ( exposedRect.intersects( QLineF( p1, p2 ) ) { // perhaps I need to do QLineF::cutThrough( const QRectF& )?
painter->drawLine( p1, p2 );
}
}
To copy to clipboard, switch view to plain text mode
That is, only line segment that intersects with the exposed rectangle, then I do the draw. This improves the performance tremendously. Yes, I write my own "intersects" for now. But it should be provided by Qt as it is definitely needed for fast rendering.
This bring up my other question, what does QPainter do behind the scene? Performance is very bad when trying to draw a polyline with over 10,000 points, although the exposed area may only have 20 points...
But after adding "intersetcs", it becomes much faster even though checking has to be done for all line segments...
Bookmarks