QWT API (中文) 7.0.1
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
qwt_pixel_matrix.h
1/******************************************************************************
2 * Qwt Widget Library
3 * Copyright (C) 1997 Josef Wilgen
4 * Copyright (C) 2002 Uwe Rathmann
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the Qwt License, Version 1.0
8 *
9 * Modified by ChenZongYan in 2024 <czy.t@163.com>
10 * Summary of major modifications (see ChangeLog.md for full history):
11 * 1. CMake build system & C++11 throughout.
12 * 2. Core panner/ zoomer refactored:
13 * - QwtPanner → QwtCachePanner (pixmap-cache version)
14 * - New real-time QwtPlotPanner derived from QwtPicker.
15 * 3. Zoomer supports multi-axis.
16 * 4. Parasite-plot framework:
17 * - QwtFigure, QwtPlotParasiteLayout, QwtPlotTransparentCanvas,
18 * - QwtPlotScaleEventDispatcher, built-in pan/zoom on axis.
19 * 5. New picker: QwtPlotSeriesDataPicker (works with date axis).
20 * 6. Raster & color-map extensions:
21 * - QwtGridRasterData (2-D table + interpolation)
22 * - QwtLinearColorMap::stopColors(), stopPos() API rename.
23 * 7. Bar-chart: expose pen/brush control.
24 * 8. Amalgamated build: single QwtPlot.h / QwtPlot.cpp pair in src-amalgamate.
25 *****************************************************************************/
26
27#ifndef QWT_PIXEL_MATRIX_H
28#define QWT_PIXEL_MATRIX_H
29
30#include "qwt_global.h"
31
32#include <qbitarray.h>
33#include <qrect.h>
34
49class QWT_EXPORT QwtPixelMatrix : public QBitArray
50{
51 public:
52 // Constructor with bounding rectangle
53 explicit QwtPixelMatrix( const QRect& rect );
54 // Destructor
56
57 // Set the bounding rectangle of the matrix
58 void setRect( const QRect& rect );
59 // Get the bounding rectangle
60 QRect rect() const;
61
62 // Test if a pixel has been set
63 bool testPixel( int x, int y ) const;
64 // Set a pixel and test if it was set before
65 bool testAndSetPixel( int x, int y, bool on );
66
67 // Calculate the index in the bit field for a position
68 int index( int x, int y ) const;
69
70 private:
71 QRect m_rect;
72};
73
89inline bool QwtPixelMatrix::testPixel( int x, int y ) const
90{
91 const int idx = index( x, y );
92 return ( idx >= 0 ) ? testBit( idx ) : true;
93}
94
112inline bool QwtPixelMatrix::testAndSetPixel( int x, int y, bool on )
113{
114 const int idx = index( x, y );
115 if ( idx < 0 )
116 return true;
117
118 const bool onBefore = testBit( idx );
119 setBit( idx, on );
120
121 return onBefore;
122}
123
139inline int QwtPixelMatrix::index( int x, int y ) const
140{
141 const int dx = x - m_rect.x();
142 if ( dx < 0 || dx >= m_rect.width() )
143 return -1;
144
145 const int dy = y - m_rect.y();
146 if ( dy < 0 || dy >= m_rect.height() )
147 return -1;
148
149 return dy * m_rect.width() + dx;
150}
151
152#endif
与矩形像素对应的位域
Definition qwt_pixel_matrix.h:50
bool testPixel(int x, int y) const
测试像素是否已设置
Definition qwt_pixel_matrix.h:89
bool testAndSetPixel(int x, int y, bool on)
设置像素并测试之前是否已设置
Definition qwt_pixel_matrix.h:112
int index(int x, int y) const
计算位域中对应位置的索引
Definition qwt_pixel_matrix.h:139