Listing 2. Drawing the Points in Pixmap
/* Munch for a while on _points, until either we
* finish it off or run out of time.
*/
QPainter p;
p.begin(_buf);
struct timeval tv;
struct timezone tz;
gettimeofday(&tv, &tz);
double cur_time = double(tv.tv_sec)*1000.0 +
double(tv.tv_usec)/1000.0;
double deadline_time = cur_time + MAX_RENDER_TIME_MSEC;
bool dirty = false; // true if _buf changed
while ((cur_time <= deadline_time) && (_pti <
_points->size())) {
DoubPt newPt = (*_points)[_pti];
if (rtpClip(_map.viewPort, &lastPt, &newPt)) {
p.drawLine(rtpMap(_map, lastPt), rtpMap(_map,
newPt));
dirty = true;
}
lastPt = (*_points)[_pti++];
gettimeofday(&tv, &tz);
cur_time = double(tv.tv_sec)*1000.0 +
double(tv.tv_usec)/1000.0;
}
p.end();
Copyright © 1994 - 2018 Linux Journal. All rights reserved.