Go to the documentation of this file.
22 #include <qtconcurrentrun.h>
24 #define DEBUG_RENDER 0
27 #include <qelapsedtimer.h>
38 if ( QSysInfo::ByteOrder == QSysInfo::BigEndian )
40 return ( ch[0] & 0x7f ) == 0x7f && ch[1] > 0xf0;
44 return ( ch[7] & 0x7f ) == 0x7f && ch[6] > 0xf0;
226 numColors = qMax( numColors, 0 );
257 const QColor&
color, qreal width, Qt::PenStyle style )
482 const QRectF& area,
const QSize& imageSize )
const
484 if ( imageSize.isEmpty() ||
m_data->
data == NULL
491 if ( !intensityRange.
isValid() )
495 ? QImage::Format_ARGB32 : QImage::Format_Indexed8;
497 QImage image( imageSize,
format );
509 #if !defined( QT_NO_QFUTURE )
512 if ( numThreads <= 0 )
513 numThreads = QThread::idealThreadCount();
515 if ( numThreads <= 0 )
518 const int numRows = imageSize.height() / numThreads;
521 futures.reserve( numThreads - 1 );
523 for ( uint i = 0; i < numThreads; i++ )
525 QRect tile( 0, i * numRows, image.width(), numRows );
526 if ( i == numThreads - 1 )
528 tile.setHeight( image.height() - i * numRows );
533 futures += QtConcurrent::run(
534 #
if QT_VERSION >= 0x060000
539 xMap, yMap, tile, &image );
543 for (
int i = 0; i < futures.size(); i++ )
544 futures[i].waitForFinished();
547 const QRect tile( 0, 0, image.width(), image.height() );
552 const qint64 elapsed =
time.elapsed();
553 qDebug() <<
"renderImage" << imageSize << elapsed;
574 const QRect& tile, QImage* image )
const
577 if ( range.
width() <= 0.0 )
588 for (
int y = tile.top();
y <= tile.bottom();
y++ )
592 QRgb* line =
reinterpret_cast< QRgb*
>( image->scanLine(
y ) );
595 for (
int x = tile.left();
x <= tile.right();
x++ )
605 else if ( numColors == 0 )
612 *line++ = rgbTable[index];
619 for (
int y = tile.top();
y <= tile.bottom();
y++ )
623 unsigned char* line = image->scanLine(
y );
626 for (
int x = tile.left();
x <= tile.right();
x++ )
639 *line++ =
static_cast< unsigned char >( index );
664 const QRectF& area,
const QRect& rect )
const
666 QSize raster = rect.size() / 2;
668 const QRectF pixelRect =
pixelHint( area );
669 if ( !pixelRect.isEmpty() )
671 const QSize res(
qwtCeil( rect.width() / pixelRect.width() ),
672 qwtCeil( rect.height() / pixelRect.height() ) );
673 raster = raster.boundedTo( res );
690 const QRectF& rect,
const QSize& raster )
const
717 for (
int l = 0; l < numLevels; l++ )
722 if ( pen.style() == Qt::NoPen )
725 if ( pen.style() == Qt::NoPen )
728 painter->setPen( pen );
730 const QPolygonF& lines = contourLines[level];
731 for (
int i = 0; i < lines.size(); i += 2 )
733 const QPointF p1( xMap.
transform( lines[i].x() ),
735 const QPointF p2( xMap.
transform( lines[i + 1].x() ),
756 const QRectF& canvasRect )
const
764 const int margin = 2;
765 QRectF rasterRect( canvasRect.x() - margin, canvasRect.y() - margin,
766 canvasRect.width() + 2 * margin, canvasRect.height() + 2 * margin );
774 if ( area.isEmpty() )
781 raster = raster.boundedTo( rasterRect.toRect().size() );
782 if ( raster.isValid() )
bool testDisplayMode(DisplayMode) const
void setDisplayMode(DisplayMode, bool on=true)
double invTransform(double p) const
const QwtRasterData * data() const
QwtLinearColorMap builds a color map from color stops.
virtual void legendChanged()
virtual void initRaster(const QRectF &, const QSize &raster)
Initialize a raster.
void setColorMap(QwtColorMap *)
virtual QVector< QRgb > colorTable(int numColors) const
virtual QVector< QRgb > colorTable256() const
void setContourLevels(const QList< double > &)
QVector< QRgb > colorTable
virtual QRectF pixelHint(const QRectF &) const QWT_OVERRIDE
Pixel hint.
virtual QwtInterval interval(Qt::Axis) const =0
A class, which displays raster data.
void renderTile(const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRect &tile, QImage *) const
Render a tile of an image.
@ Legend
The item is represented on the legend.
void setConrecFlag(QwtRasterData::ConrecFlag, bool on)
QPen defaultContourPen() const
void setDefaultContourPen(const QColor &, qreal width=0.0, Qt::PenStyle=Qt::SolidLine)
bool testAttribute(Attribute) const
virtual uint colorIndex(int numColors, const QwtInterval &interval, double value) const
Map a value of a given interval into a color index.
@ RGB
The map is intended to map into RGB values.
virtual QRectF pixelHint(const QRectF &) const
Pixel hint.
bool testConrecFlag(QwtRasterData::ConrecFlag) const
A class representing an interval.
virtual ~QwtPlotSpectrogram()
Destructor.
QMap< double, QPolygonF > ContourLines
Contour lines.
double width() const
Return the width of an interval.
virtual void drawContourLines(QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QwtRasterData::ContourLines &) const
QList< double > contourLevels
virtual QwtRasterData::ContourLines renderContourLines(const QRectF &rect, const QSize &raster) const
void setZ(double z)
Set the z value.
static void drawLine(QPainter *, qreal x1, qreal y1, qreal x2, qreal y2)
Wrapper for QPainter::drawLine()
@ IgnoreAllVerticesOnLevel
Ignore all vertices on the same level.
void setData(QwtRasterData *data)
QwtPlotSpectrogram(const QString &title=QString())
void setColorTableSize(int numColors)
virtual QImage renderImage(const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &area, const QSize &imageSize) const QWT_OVERRIDE
Render an image from data and color map.
int colorTableSize() const
virtual void draw(QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect) const QWT_OVERRIDE
Draw the raster data.
virtual void draw(QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect) const QWT_OVERRIDE
Draw the spectrogram.
double transform(double s) const
virtual QRectF boundingRect() const QWT_OVERRIDE
virtual void itemChanged()
virtual QwtInterval interval(Qt::Axis) const QWT_OVERRIDE
virtual int rtti() const QWT_OVERRIDE
virtual QSize contourRasterSize(const QRectF &, const QRect &) const
Return the raster to be used by the CONREC contour algorithm.
static int sort(lua_State *L)
auto format(const text_style &ts, const S &format_str, const Args &... args) -> std::basic_string< Char >
@ ImageMode
The values are mapped to colors using a color map.
QwtRasterData::ConrecFlags conrecFlags
@ Rtti_PlotSpectrogram
For QwtPlotSpectrogram.
virtual QRgb rgb(const QwtInterval &interval, double value) const =0
void setItemAttribute(ItemAttribute, bool on=true)
virtual void discardRaster()
Discard a raster.
const QwtColorMap * colorMap() const
virtual double value(double x, double y) const =0
@ IgnoreOutOfRange
Ignore all values, that are out of range.
QwtRasterData defines an interface to any type of raster data.
ConrecFlag
Flags to modify the contour algorithm.
QwtColorMap is used to map values into colors.
virtual QPen contourPen(double level) const
Calculate the pen for a contour line.
@ ContourMode
The data is displayed using contour lines.
virtual ContourLines contourLines(const QRectF &rect, const QSize &raster, const QList< double > &levels, ConrecFlags) const
QList< double > contourLevels() const
static bool qwtIsNaN(double d)
uint renderThreadCount() const
plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:46