| Line | Source Code | Coverage |
|---|
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | QGLColormap::QGLColormapData QGLColormap::shared_null = { { (1) }, 0, 0 }; | - |
| 5 | | - |
| 6 | | - |
| 7 | | - |
| 8 | | - |
| 9 | QGLColormap::QGLColormap() | - |
| 10 | : d(&shared_null) | - |
| 11 | { | - |
| 12 | d->ref.ref(); | - |
| 13 | } | 0 |
| 14 | | - |
| 15 | | - |
| 16 | | - |
| 17 | | - |
| 18 | | - |
| 19 | QGLColormap::QGLColormap(const QGLColormap &map) | - |
| 20 | : d(map.d) | - |
| 21 | { | - |
| 22 | d->ref.ref(); | - |
| 23 | } | 0 |
| 24 | | - |
| 25 | | - |
| 26 | | - |
| 27 | | - |
| 28 | | - |
| 29 | QGLColormap::~QGLColormap() | - |
| 30 | { | - |
| 31 | if (!d->ref.deref()) never evaluated: !d->ref.deref() | 0 |
| 32 | cleanup(d); never executed: cleanup(d); | 0 |
| 33 | } | 0 |
| 34 | | - |
| 35 | void QGLColormap::cleanup(QGLColormap::QGLColormapData *x) | - |
| 36 | { | - |
| 37 | delete x->cells; | - |
| 38 | x->cells = 0; | - |
| 39 | delete x; | - |
| 40 | } | 0 |
| 41 | | - |
| 42 | | - |
| 43 | | - |
| 44 | | - |
| 45 | QGLColormap & QGLColormap::operator=(const QGLColormap &map) | - |
| 46 | { | - |
| 47 | map.d->ref.ref(); | - |
| 48 | if (!d->ref.deref()) never evaluated: !d->ref.deref() | 0 |
| 49 | cleanup(d); never executed: cleanup(d); | 0 |
| 50 | d = map.d; | - |
| 51 | return *this; never executed: return *this; | 0 |
| 52 | } | - |
| 53 | void QGLColormap::detach_helper() | - |
| 54 | { | - |
| 55 | QGLColormapData *x = new QGLColormapData; | - |
| 56 | x->ref.store(1); | - |
| 57 | x->cmapHandle = 0; | - |
| 58 | x->cells = 0; | - |
| 59 | if (d->cells) { never evaluated: d->cells | 0 |
| 60 | x->cells = new QVector<QRgb>(256); | - |
| 61 | *x->cells = *d->cells; | - |
| 62 | } | 0 |
| 63 | if (!d->ref.deref()) never evaluated: !d->ref.deref() | 0 |
| 64 | cleanup(d); never executed: cleanup(d); | 0 |
| 65 | d = x; | - |
| 66 | } | 0 |
| 67 | | - |
| 68 | | - |
| 69 | | - |
| 70 | | - |
| 71 | void QGLColormap::setEntry(int idx, QRgb color) | - |
| 72 | { | - |
| 73 | detach(); | - |
| 74 | if (!d->cells) never evaluated: !d->cells | 0 |
| 75 | d->cells = new QVector<QRgb>(256); never executed: d->cells = new QVector<QRgb>(256); | 0 |
| 76 | d->cells->replace(idx, color); | - |
| 77 | } | 0 |
| 78 | | - |
| 79 | | - |
| 80 | | - |
| 81 | | - |
| 82 | | - |
| 83 | | - |
| 84 | | - |
| 85 | void QGLColormap::setEntries(int count, const QRgb *colors, int base) | - |
| 86 | { | - |
| 87 | detach(); | - |
| 88 | if (!d->cells) never evaluated: !d->cells | 0 |
| 89 | d->cells = new QVector<QRgb>(256); never executed: d->cells = new QVector<QRgb>(256); | 0 |
| 90 | | - |
| 91 | qt_noop(); | - |
| 92 | | - |
| 93 | for (int i = 0; i < count; ++i) never evaluated: i < count | 0 |
| 94 | setEntry(base + i, colors[i]); never executed: setEntry(base + i, colors[i]); | 0 |
| 95 | } | 0 |
| 96 | | - |
| 97 | | - |
| 98 | | - |
| 99 | | - |
| 100 | QRgb QGLColormap::entryRgb(int idx) const | - |
| 101 | { | - |
| 102 | if (d == &shared_null || !d->cells) never evaluated: d == &shared_null never evaluated: !d->cells | 0 |
| 103 | return 0; never executed: return 0; | 0 |
| 104 | else | - |
| 105 | return d->cells->at(idx); never executed: return d->cells->at(idx); | 0 |
| 106 | } | - |
| 107 | | - |
| 108 | | - |
| 109 | | - |
| 110 | | - |
| 111 | | - |
| 112 | | - |
| 113 | void QGLColormap::setEntry(int idx, const QColor &color) | - |
| 114 | { | - |
| 115 | setEntry(idx, color.rgb()); | - |
| 116 | } | 0 |
| 117 | | - |
| 118 | | - |
| 119 | | - |
| 120 | | - |
| 121 | QColor QGLColormap::entryColor(int idx) const | - |
| 122 | { | - |
| 123 | if (d == &shared_null || !d->cells) never evaluated: d == &shared_null never evaluated: !d->cells | 0 |
| 124 | return QColor(); never executed: return QColor(); | 0 |
| 125 | else | - |
| 126 | return QColor(d->cells->at(idx)); never executed: return QColor(d->cells->at(idx)); | 0 |
| 127 | } | - |
| 128 | bool QGLColormap::isEmpty() const | - |
| 129 | { | - |
| 130 | return d == &shared_null || d->cells == 0 || d->cells->size() == 0 || d->cmapHandle == 0; never executed: return d == &shared_null || d->cells == 0 || d->cells->size() == 0 || d->cmapHandle == 0; | 0 |
| 131 | } | - |
| 132 | | - |
| 133 | | - |
| 134 | | - |
| 135 | | - |
| 136 | | - |
| 137 | int QGLColormap::size() const | - |
| 138 | { | - |
| 139 | return d->cells ? d->cells->size() : 0; never executed: return d->cells ? d->cells->size() : 0; | 0 |
| 140 | } | - |
| 141 | | - |
| 142 | | - |
| 143 | | - |
| 144 | | - |
| 145 | | - |
| 146 | int QGLColormap::find(QRgb color) const | - |
| 147 | { | - |
| 148 | if (d->cells) never evaluated: d->cells | 0 |
| 149 | return d->cells->indexOf(color); never executed: return d->cells->indexOf(color); | 0 |
| 150 | return -1; never executed: return -1; | 0 |
| 151 | } | - |
| 152 | | - |
| 153 | | - |
| 154 | | - |
| 155 | | - |
| 156 | | - |
| 157 | int QGLColormap::findNearest(QRgb color) const | - |
| 158 | { | - |
| 159 | int idx = find(color); | - |
| 160 | if (idx >= 0) never evaluated: idx >= 0 | 0 |
| 161 | return idx; never executed: return idx; | 0 |
| 162 | int mapSize = size(); | - |
| 163 | int mindist = 200000; | - |
| 164 | int r = qRed(color); | - |
| 165 | int g = qGreen(color); | - |
| 166 | int b = qBlue(color); | - |
| 167 | int rx, gx, bx, dist; | - |
| 168 | for (int i = 0; i < mapSize; ++i) { never evaluated: i < mapSize | 0 |
| 169 | QRgb ci = d->cells->at(i); | - |
| 170 | rx = r - qRed(ci); | - |
| 171 | gx = g - qGreen(ci); | - |
| 172 | bx = b - qBlue(ci); | - |
| 173 | dist = rx * rx + gx * gx + bx * bx; | - |
| 174 | if (dist < mindist) { never evaluated: dist < mindist | 0 |
| 175 | mindist = dist; | - |
| 176 | idx = i; | - |
| 177 | } | 0 |
| 178 | } | 0 |
| 179 | return idx; never executed: return idx; | 0 |
| 180 | } | - |
| 181 | | - |
| 182 | | - |
| 183 | | - |
| | |