19 #include <qpainterpath.h> 23 #include <qtconcurrentrun.h> 176 const QPointF &pole,
double,
177 const QRectF &canvasRect )
const 179 const QRectF plotRect =
plot()->
plotRect( canvasRect.toRect() );
180 QRect imageRect = canvasRect.toRect();
184 painter->setClipRect( canvasRect );
186 QPainterPath clipPathCanvas;
187 clipPathCanvas.addEllipse( plotRect );
188 painter->setClipPath( clipPathCanvas, Qt::IntersectClip );
190 imageRect &= plotRect.toAlignedRect();
193 if ( radialInterval.
isValid() )
198 QRectF clipRect( 0, 0, 2 * radius, 2 * radius );
199 clipRect.moveCenter( pole );
201 imageRect &= clipRect.toRect();
203 QPainterPath clipPathRadial;
204 clipPathRadial.addEllipse( clipRect );
205 painter->setClipPath( clipPathRadial, Qt::IntersectClip );
208 const QImage image =
renderImage( azimuthMap, radialMap, pole, imageRect );
209 painter->drawImage( imageRect, image );
234 const QPointF &pole,
const QRect &rect )
const 240 ? QImage::Format_ARGB32 : QImage::Format_Indexed8 );
243 if ( !intensityRange.isValid() )
258 #if !defined(QT_NO_QFUTURE) 261 if ( numThreads <= 0 )
262 numThreads = QThread::idealThreadCount();
264 if ( numThreads <= 0 )
267 const int numRows = rect.height() / numThreads;
271 for ( uint i = 0; i < numThreads; i++ )
273 QRect tile( rect.x(), rect.y() + i * numRows, rect.width(), numRows );
274 if ( i == numThreads - 1 )
275 tile.setHeight( rect.height() - i * numRows );
279 tileInfo.
rect = tile;
280 tileInfo.
image = ℑ
282 tileInfos += tileInfo;
286 for (
int i = 0; i < tileInfos.size(); i++ )
288 if ( i == tileInfos.size() - 1 )
290 renderTile( azimuthMap, radialMap, pole, &tileInfos[i] );
295 azimuthMap, radialMap, pole, &tileInfos[i] );
298 for (
int i = 0; i < futures.size(); i++ )
299 futures[i].waitForFinished();
302 renderTile( azimuthMap, radialMap, pole, rect.topLeft(), rect, &image );
312 const QPointF &pole,
TileInfo *tileInfo )
const 336 const QPointF &pole,
const QPoint &imagePos,
337 const QRect &tile, QImage *image )
const 340 if ( !intensityRange.
isValid() )
345 const int y0 = imagePos.y();
346 const int y1 = tile.top();
347 const int y2 = tile.bottom();
349 const int x0 = imagePos.x();
350 const int x1 = tile.left();
351 const int x2 = tile.right();
355 for (
int y = y1; y <= y2; y++ )
357 const double dy = pole.y() - y;
358 const double dy2 =
qwtSqr( dy );
360 QRgb *line =
reinterpret_cast<QRgb *
>( image->scanLine( y - y0 ) );
363 for (
int x = x1; x <= x2; x++ )
365 const double dx = x - pole.x();
367 double a = doFastAtan ?
qwtFastAtan2( dy, dx ) : qAtan2( dy, dx );
372 if ( a < azimuthMap.
p1() )
375 const double r = qSqrt(
qwtSqr( dx ) + dy2 );
381 if ( qIsNaN( value ) )
394 for (
int y = y1; y <= y2; y++ )
396 const double dy = pole.y() - y;
397 const double dy2 =
qwtSqr( dy );
399 unsigned char *line = image->scanLine( y - y0 );
401 for (
int x = x1; x <= x2; x++ )
403 const double dx = x - pole.x();
405 double a = doFastAtan ?
qwtFastAtan2( dy, dx ) : qAtan2( dy, dx );
408 if ( a < azimuthMap.
p1() )
411 const double r = qSqrt(
qwtSqr( dx ) + dy2 );
419 *line++ =
static_cast<unsigned char>( index );
virtual void discardRaster()
Discard a raster.
void setPaintAttribute(PaintAttribute, bool on=true)
enum MQTTPropertyCodes value
virtual QwtInterval boundingInterval(int scaleId) const
const QwtColorMap * colorMap() const
virtual void renderTile(const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap, const QPointF &pole, const QPoint &imagePos, const QRect &tile, QImage *image) const
Render a sub-rectangle of an image.
virtual QVector< QRgb > colorTable256() const
A class representing an interval.
QwtPolarSpectrogram::PaintAttributes paintAttributes
QwtPolarPlot * plot() const
virtual ~QwtPolarSpectrogram()
Destructor.
bool testPaintAttribute(PaintAttribute) const
virtual void initRaster(const QRectF &, const QSize &raster)
Initialize a raster.
QwtPolarSpectrogram()
Constructor.
virtual QwtInterval interval(Qt::Axis) const =0
Base class for items on a polar plot.
const QwtRasterData * data() const
virtual uint colorIndex(int numColors, const QwtInterval &interval, double value) const
Map a value of a given interval into a color index.
void setItemAttribute(ItemAttribute, bool on=true)
void setZ(double z)
Set the z value.
QFlags< PaintAttribute > PaintAttributes
Paint attributes.
A class representing a text.
QwtColorMap is used to map values into colors.
virtual int rtti() const QWT_OVERRIDE
virtual double value(double x, double y) const =0
virtual QImage renderImage(const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap, const QPointF &pole, const QRect &rect) const
Render an image from the data and color map.
virtual void draw(QPainter *painter, const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap, const QPointF &pole, double radius, const QRectF &canvasRect) const QWT_OVERRIDE
QwtLinearColorMap builds a color map from color stops.
void setData(QwtRasterData *data)
double invTransform(double p) const
The map is intended to map into RGB values.
virtual QwtInterval boundingInterval(int scaleId) const QWT_OVERRIDE
QwtRasterData defines an interface to any type of raster data.
virtual QRgb rgb(const QwtInterval &interval, double value) const =0
The item is represented on the legend.
double qwtSqr(double x)
Return the square of a number.
double transform(double s) const
void setColorMap(QwtColorMap *)
double qwtFastAtan2(double y, double x)
Approximation of arc tangent ( error below 0,005 radians )
uint renderThreadCount() const
virtual void itemChanged()