summaryrefslogtreecommitdiff
path: root/gr-qtgui/lib/plot_raster.cc
diff options
context:
space:
mode:
authorMarcus Müller <mmueller@gnuradio.org>2019-08-07 21:45:12 +0200
committerMarcus Müller <marcus@hostalia.de>2019-08-09 23:04:28 +0200
commitf7bbf2c1d8d780294f3e016aff239ca35eb6516e (patch)
treee09ab6112e02b2215b2d59ac24d3d6ea2edac745 /gr-qtgui/lib/plot_raster.cc
parent78431dc6941e3acc67c858277dfe4a0ed583643c (diff)
Tree: clang-format without the include sorting
Diffstat (limited to 'gr-qtgui/lib/plot_raster.cc')
-rw-r--r--gr-qtgui/lib/plot_raster.cc286
1 files changed, 127 insertions, 159 deletions
diff --git a/gr-qtgui/lib/plot_raster.cc b/gr-qtgui/lib/plot_raster.cc
index f565977d5b..a339ec64bb 100644
--- a/gr-qtgui/lib/plot_raster.cc
+++ b/gr-qtgui/lib/plot_raster.cc
@@ -37,43 +37,35 @@
typedef QVector<QRgb> QwtColorTable;
-class PlotTimeRasterImage: public QImage
+class PlotTimeRasterImage : public QImage
{
// This class hides some Qt3/Qt4 API differences
public:
- PlotTimeRasterImage(const QSize &size, QwtColorMap::Format format):
- QImage(size, format == QwtColorMap::RGB
- ? QImage::Format_ARGB32 : QImage::Format_Indexed8 )
- {
- }
-
- PlotTimeRasterImage(const QImage &other):
- QImage(other)
- {
- }
-
- void initColorTable(const QImage& other)
- {
- setColorTable(other.colorTable());
- }
+ PlotTimeRasterImage(const QSize& size, QwtColorMap::Format format)
+ : QImage(size,
+ format == QwtColorMap::RGB ? QImage::Format_ARGB32
+ : QImage::Format_Indexed8)
+ {
+ }
+
+ PlotTimeRasterImage(const QImage& other) : QImage(other) {}
+
+ void initColorTable(const QImage& other) { setColorTable(other.colorTable()); }
};
class PlotTimeRaster::PrivateData
{
public:
- PrivateData()
- {
- data = NULL;
- colorMap = new QwtLinearColorMap();
- }
-
- ~PrivateData()
- {
- delete colorMap;
- }
-
- TimeRasterData *data;
- QwtColorMap *colorMap;
+ PrivateData()
+ {
+ data = NULL;
+ colorMap = new QwtLinearColorMap();
+ }
+
+ ~PrivateData() { delete colorMap; }
+
+ TimeRasterData* data;
+ QwtColorMap* colorMap;
};
/*!
@@ -87,8 +79,7 @@ public:
\sa QwtPlotItem::setItemAttribute(), QwtPlotItem::setZ()
*/
-PlotTimeRaster::PlotTimeRaster(const QString &title)
- : QwtPlotRasterItem(title)
+PlotTimeRaster::PlotTimeRaster(const QString& title) : QwtPlotRasterItem(title)
{
d_data = new PrivateData();
@@ -99,29 +90,14 @@ PlotTimeRaster::PlotTimeRaster(const QString &title)
}
//! Destructor
-PlotTimeRaster::~PlotTimeRaster()
-{
- delete d_data;
-}
+PlotTimeRaster::~PlotTimeRaster() { delete d_data; }
-const TimeRasterData*
-PlotTimeRaster::data()const
-{
- return d_data->data;
-}
+const TimeRasterData* PlotTimeRaster::data() const { return d_data->data; }
-void
-PlotTimeRaster::setData(TimeRasterData *data)
-{
- d_data->data = data;
-}
+void PlotTimeRaster::setData(TimeRasterData* data) { d_data->data = data; }
//! \return QwtPlotItem::Rtti_PlotSpectrogram
-int
-PlotTimeRaster::rtti() const
-{
- return QwtPlotItem::Rtti_PlotGrid;
-}
+int PlotTimeRaster::rtti() const { return QwtPlotItem::Rtti_PlotGrid; }
/*!
Change the color map
@@ -134,8 +110,7 @@ PlotTimeRaster::rtti() const
\sa colorMap(), QwtScaleWidget::setColorBarEnabled(),
QwtScaleWidget::setColorMap()
*/
-void
-PlotTimeRaster::setColorMap(const QwtColorMap *map)
+void PlotTimeRaster::setColorMap(const QwtColorMap* map)
{
delete d_data->colorMap;
d_data->colorMap = (QwtColorMap*)map;
@@ -148,10 +123,7 @@ PlotTimeRaster::setColorMap(const QwtColorMap *map)
\return Color Map used for mapping the intensity values to colors
\sa setColorMap()
*/
-const QwtColorMap &PlotTimeRaster::colorMap() const
-{
- return *d_data->colorMap;
-}
+const QwtColorMap& PlotTimeRaster::colorMap() const { return *d_data->colorMap; }
/*!
\return Bounding rect of the data
@@ -160,7 +132,7 @@ const QwtColorMap &PlotTimeRaster::colorMap() const
#if QWT_VERSION < 0x060000
QwtDoubleRect PlotTimeRaster::boundingRect() const
{
- return d_data->data->boundingRect();
+ return d_data->data->boundingRect();
}
#endif
@@ -174,9 +146,9 @@ QwtDoubleRect PlotTimeRaster::boundingRect() const
\return data().rasterHint(rect)
*/
#if QWT_VERSION < 0x060000
-QSize PlotTimeRaster::rasterHint(const QwtDoubleRect &rect) const
+QSize PlotTimeRaster::rasterHint(const QwtDoubleRect& rect) const
{
- return d_data->data->rasterHint(rect);
+ return d_data->data->rasterHint(rect);
}
#endif
@@ -198,135 +170,132 @@ QSize PlotTimeRaster::rasterHint(const QwtDoubleRect &rect) const
QwtColorMap::colorIndex()
*/
#if QWT_VERSION < 0x060000
-QImage PlotTimeRaster::renderImage(const QwtScaleMap &xMap,
- const QwtScaleMap &yMap,
- const QwtDoubleRect &area) const
+QImage PlotTimeRaster::renderImage(const QwtScaleMap& xMap,
+ const QwtScaleMap& yMap,
+ const QwtDoubleRect& area) const
#else
-QImage PlotTimeRaster::renderImage(const QwtScaleMap &xMap,
- const QwtScaleMap &yMap,
- const QRectF &area,
- const QSize &size) const
+QImage PlotTimeRaster::renderImage(const QwtScaleMap& xMap,
+ const QwtScaleMap& yMap,
+ const QRectF& area,
+ const QSize& size) const
#endif
{
- if(area.isEmpty())
- return QImage();
+ if (area.isEmpty())
+ return QImage();
#if QWT_VERSION < 0x060000
- QRect rect = transform(xMap, yMap, area);
- const QSize res = d_data->data->rasterHint(area);
+ QRect rect = transform(xMap, yMap, area);
+ const QSize res = d_data->data->rasterHint(area);
#else
- QRect rect = QwtScaleMap::transform(xMap, yMap, area).toRect();
- const QSize res(-1,-1);
+ QRect rect = QwtScaleMap::transform(xMap, yMap, area).toRect();
+ const QSize res(-1, -1);
#endif
- QwtScaleMap xxMap = xMap;
- QwtScaleMap yyMap = yMap;
-
- if(res.isValid()) {
- /*
- It is useless to render an image with a higher resolution
- than the data offers. Of course someone will have to
- scale this image later into the size of the given rect, but f.e.
- in case of postscript this will done on the printer.
- */
- rect.setSize(rect.size().boundedTo(res));
-
- int px1 = rect.x();
- int px2 = rect.x() + rect.width();
- if(xMap.p1() > xMap.p2())
- qSwap(px1, px2);
-
- double sx1 = area.x();
- double sx2 = area.x() + area.width();
- if(xMap.s1() > xMap.s2())
- qSwap(sx1, sx2);
-
- int py1 = rect.y();
- int py2 = rect.y() + rect.height();
- if(yMap.p1() > yMap.p2())
- qSwap(py1, py2);
-
- double sy1 = area.y();
- double sy2 = area.y() + area.height();
- if(yMap.s1() > yMap.s2())
- qSwap(sy1, sy2);
-
- xxMap.setPaintInterval(px1, px2);
- xxMap.setScaleInterval(sx1, sx2);
- yyMap.setPaintInterval(py1, py2);
- yyMap.setScaleInterval(sy1, sy2);
- }
-
- PlotTimeRasterImage image(rect.size(), d_data->colorMap->format());
+ QwtScaleMap xxMap = xMap;
+ QwtScaleMap yyMap = yMap;
+
+ if (res.isValid()) {
+ /*
+ It is useless to render an image with a higher resolution
+ than the data offers. Of course someone will have to
+ scale this image later into the size of the given rect, but f.e.
+ in case of postscript this will done on the printer.
+ */
+ rect.setSize(rect.size().boundedTo(res));
+
+ int px1 = rect.x();
+ int px2 = rect.x() + rect.width();
+ if (xMap.p1() > xMap.p2())
+ qSwap(px1, px2);
+
+ double sx1 = area.x();
+ double sx2 = area.x() + area.width();
+ if (xMap.s1() > xMap.s2())
+ qSwap(sx1, sx2);
+
+ int py1 = rect.y();
+ int py2 = rect.y() + rect.height();
+ if (yMap.p1() > yMap.p2())
+ qSwap(py1, py2);
+
+ double sy1 = area.y();
+ double sy2 = area.y() + area.height();
+ if (yMap.s1() > yMap.s2())
+ qSwap(sy1, sy2);
+
+ xxMap.setPaintInterval(px1, px2);
+ xxMap.setScaleInterval(sx1, sx2);
+ yyMap.setPaintInterval(py1, py2);
+ yyMap.setScaleInterval(sy1, sy2);
+ }
+
+ PlotTimeRasterImage image(rect.size(), d_data->colorMap->format());
#if QWT_VERSION < 0x060000
- const QwtDoubleInterval intensityRange = d_data->data->range();
+ const QwtDoubleInterval intensityRange = d_data->data->range();
#else
- const QwtInterval intensityRange = d_data->data->interval(Qt::ZAxis);
+ const QwtInterval intensityRange = d_data->data->interval(Qt::ZAxis);
#endif
- if(!intensityRange.isValid())
- return image;
+ if (!intensityRange.isValid())
+ return image;
- d_data->data->initRaster(area, rect.size());
+ d_data->data->initRaster(area, rect.size());
- if(d_data->colorMap->format() == QwtColorMap::RGB) {
- for(int y = rect.top(); y <= rect.bottom(); y++) {
- const double ty = yyMap.invTransform(y);
+ if (d_data->colorMap->format() == QwtColorMap::RGB) {
+ for (int y = rect.top(); y <= rect.bottom(); y++) {
+ const double ty = yyMap.invTransform(y);
- QRgb *line = (QRgb *)image.scanLine(y - rect.top());
+ QRgb* line = (QRgb*)image.scanLine(y - rect.top());
- for(int x = rect.left(); x <= rect.right(); x++) {
- const double tx = xxMap.invTransform(x);
+ for (int x = rect.left(); x <= rect.right(); x++) {
+ const double tx = xxMap.invTransform(x);
- *line++ = d_data->colorMap->rgb(intensityRange,
- d_data->data->value(tx, ty));
- }
- }
- d_data->data->incrementResidual();
- }
- else if(d_data->colorMap->format() == QwtColorMap::Indexed) {
- image.setColorTable(d_data->colorMap->colorTable(intensityRange));
+ *line++ =
+ d_data->colorMap->rgb(intensityRange, d_data->data->value(tx, ty));
+ }
+ }
+ d_data->data->incrementResidual();
+ } else if (d_data->colorMap->format() == QwtColorMap::Indexed) {
+ image.setColorTable(d_data->colorMap->colorTable(intensityRange));
- for(int y = rect.top(); y <= rect.bottom(); y++) {
- const double ty = yyMap.invTransform(y);
+ for (int y = rect.top(); y <= rect.bottom(); y++) {
+ const double ty = yyMap.invTransform(y);
- unsigned char *line = image.scanLine(y - rect.top());
- for(int x = rect.left(); x <= rect.right(); x++) {
- const double tx = xxMap.invTransform(x);
+ unsigned char* line = image.scanLine(y - rect.top());
+ for (int x = rect.left(); x <= rect.right(); x++) {
+ const double tx = xxMap.invTransform(x);
- *line++ = d_data->colorMap->colorIndex(intensityRange,
- d_data->data->value(tx, ty));
- }
+ *line++ = d_data->colorMap->colorIndex(intensityRange,
+ d_data->data->value(tx, ty));
+ }
+ }
}
- }
- d_data->data->discardRaster();
+ d_data->data->discardRaster();
- // Mirror the image in case of inverted maps
+ // Mirror the image in case of inverted maps
- const bool hInvert = xxMap.p1() > xxMap.p2();
- const bool vInvert = yyMap.p1() > yyMap.p2();
- if(hInvert || vInvert) {
- image = image.mirrored(hInvert, vInvert);
- }
+ const bool hInvert = xxMap.p1() > xxMap.p2();
+ const bool vInvert = yyMap.p1() > yyMap.p2();
+ if (hInvert || vInvert) {
+ image = image.mirrored(hInvert, vInvert);
+ }
- return image;
+ return image;
}
#if QWT_VERSION < 0x060000
-QwtDoubleInterval
-PlotTimeRaster::interval(Qt::Axis ax) const
+QwtDoubleInterval PlotTimeRaster::interval(Qt::Axis ax) const
{
- return d_data->data->range();
+ return d_data->data->range();
}
#else
-QwtInterval
-PlotTimeRaster::interval(Qt::Axis ax) const
+QwtInterval PlotTimeRaster::interval(Qt::Axis ax) const
{
- return d_data->data->interval(ax);
+ return d_data->data->interval(ax);
}
#endif
@@ -342,11 +311,10 @@ PlotTimeRaster::interval(Qt::Axis ax) const
QwtPlotRasterItem::draw, drawContourLines
*/
-void PlotTimeRaster::draw(QPainter *painter,
- const QwtScaleMap &xMap,
- const QwtScaleMap &yMap,
- const QRect &canvasRect) const
+void PlotTimeRaster::draw(QPainter* painter,
+ const QwtScaleMap& xMap,
+ const QwtScaleMap& yMap,
+ const QRect& canvasRect) const
{
- QwtPlotRasterItem::draw(painter, xMap, yMap, canvasRect);
+ QwtPlotRasterItem::draw(painter, xMap, yMap, canvasRect);
}
-