| 177 | } |
| 178 | |
| 179 | void MultiGradient::fromString(const string & gradient) |
| 180 | { |
| 181 | pos_col_.clear(); |
| 182 | |
| 183 | if (gradient.empty()) |
| 184 | { |
| 185 | pos_col_[0] = Qt::white; |
| 186 | pos_col_[100] = Qt::black; |
| 187 | return; |
| 188 | } |
| 189 | |
| 190 | string g(gradient); |
| 191 | string::iterator tmp(g.begin()); |
| 192 | double tmp_pos = 0; |
| 193 | for (string::iterator it = g.begin(); it != g.end(); ++it) |
| 194 | { |
| 195 | if (*it == '|') |
| 196 | { |
| 197 | //interploation mode |
| 198 | if (string(tmp, it) == "Linear") |
| 199 | { |
| 200 | setInterpolationMode(IM_LINEAR); |
| 201 | } |
| 202 | else if (string(tmp, it) == "Stairs") |
| 203 | { |
| 204 | setInterpolationMode(IM_STAIRS); |
| 205 | } |
| 206 | } |
| 207 | else if (*it == ';') |
| 208 | { |
| 209 | pos_col_[tmp_pos] = QColor(string(tmp, it).c_str()); |
| 210 | tmp = it + 1; |
| 211 | } |
| 212 | else if (*it == ',') |
| 213 | { |
| 214 | tmp_pos = QString(string(tmp, it).c_str()).toDouble(); |
| 215 | tmp = it + 1; |
| 216 | } |
| 217 | } |
| 218 | // last entry |
| 219 | pos_col_[tmp_pos] = QColor(string(tmp, g.end()).c_str()); |
| 220 | } |
| 221 | |
| 222 | void MultiGradient::activatePrecalculationMode(double min, double max, UInt steps) |
| 223 | { |
no test coverage detected