19 #include <qpainterpath.h>
22 #include <qtconcurrentrun.h>
24 #if QT_VERSION < 0x050000
179 const QPointF& pole,
double,
180 const QRectF& canvasRect )
const
182 const QRectF plotRect =
plot()->
plotRect( canvasRect.toRect() );
183 QRect imageRect = canvasRect.toRect();
187 painter->setClipRect( canvasRect );
189 QPainterPath clipPathCanvas;
190 clipPathCanvas.addEllipse( plotRect );
191 painter->setClipPath( clipPathCanvas, Qt::IntersectClip );
193 imageRect &= plotRect.toAlignedRect();
196 if ( radialInterval.
isValid() )
201 QRectF clipRect( 0, 0, 2 * radius, 2 * radius );
202 clipRect.moveCenter( pole );
204 imageRect &= clipRect.toRect();
206 QPainterPath clipPathRadial;
207 clipPathRadial.addEllipse( clipRect );
208 painter->setClipPath( clipPathRadial, Qt::IntersectClip );
211 const QImage image =
renderImage( azimuthMap, radialMap, pole, imageRect );
212 painter->drawImage( imageRect, image );
237 const QPointF& pole,
const QRect& rect )
const
243 ? QImage::Format_ARGB32 : QImage::Format_Indexed8 );
246 if ( !intensityRange.
isValid() )
261 #if !defined( QT_NO_QFUTURE )
264 if ( numThreads <= 0 )
265 numThreads = QThread::idealThreadCount();
267 if ( numThreads <= 0 )
270 const int numRows = rect.height() / numThreads;
274 for ( uint i = 0; i < numThreads; i++ )
276 QRect tile( rect.x(), rect.y() + i * numRows, rect.width(), numRows );
277 if ( i == numThreads - 1 )
278 tile.setHeight( rect.height() - i * numRows );
282 tileInfo.
rect = tile;
283 tileInfo.
image = ℑ
285 tileInfos += tileInfo;
289 for (
int i = 0; i < tileInfos.size(); i++ )
291 if ( i == tileInfos.size() - 1 )
297 futures += QtConcurrent::run(
298 #
if QT_VERSION >= 0x060000
303 azimuthMap, radialMap, pole, &tileInfos[i] );
307 for (
int i = 0; i < futures.size(); i++ )
308 futures[i].waitForFinished();
311 renderTile( azimuthMap, radialMap, pole, rect.topLeft(), rect, &image );
321 const QPointF& pole,
TileInfo* tileInfo )
const
345 const QPointF& pole,
const QPoint& imagePos,
346 const QRect& tile, QImage* image )
const
349 if ( !intensityRange.
isValid() )
354 const int y0 = imagePos.y();
355 const int y1 = tile.top();
356 const int y2 = tile.bottom();
358 const int x0 = imagePos.x();
359 const int x1 = tile.left();
360 const int x2 = tile.right();
364 for (
int y = y1;
y <= y2;
y++ )
366 const double dy = pole.y() -
y;
367 const double dy2 =
qwtSqr( dy );
369 QRgb* line =
reinterpret_cast< QRgb*
>( image->scanLine(
y - y0 ) );
372 for (
int x = x1;
x <= x2;
x++ )
374 const double dx =
x - pole.x();
376 double a = doFastAtan ?
qwtFastAtan2( dy, dx ) : qAtan2( dy, dx );
381 if ( a < azimuthMap.
p1() )
384 const double r = qSqrt(
qwtSqr( dx ) + dy2 );
390 if ( qIsNaN( value ) )
403 for (
int y = y1;
y <= y2;
y++ )
405 const double dy = pole.y() -
y;
406 const double dy2 =
qwtSqr( dy );
408 unsigned char* line = image->scanLine(
y - y0 );
410 for (
int x = x1;
x <= x2;
x++ )
412 const double dx =
x - pole.x();
414 double a = doFastAtan ?
qwtFastAtan2( dy, dx ) : qAtan2( dy, dx );
417 if ( a < azimuthMap.
p1() )
420 const double r = qSqrt(
qwtSqr( dx ) + dy2 );
428 *line++ =
static_cast< unsigned char >( index );