Changeset View
Changeset View
Standalone View
Standalone View
src/plugins/barcode/codeean.cpp
Show First 20 Lines • Show All 165 Lines • ▼ Show 20 Line(s) | 87 | { | |||
---|---|---|---|---|---|
166 | QPen pen(Qt::NoPen); | 166 | QPen pen(Qt::NoPen); | ||
167 | QBrush brush(QColor("black")); | 167 | QBrush brush(QColor("black")); | ||
168 | 168 | | |||
169 | // render open guard | 169 | // render open guard | ||
170 | ORORect * rect = new ORORect(); | 170 | ORORect * rect = new ORORect(); | ||
171 | rect->setPen(pen); | 171 | rect->setPen(pen); | ||
172 | rect->setBrush(brush); | 172 | rect->setBrush(brush); | ||
173 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | 173 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | ||
174 | page->addPrimitive(rect); | 174 | page->insertPrimitive(rect); | ||
175 | 175 | | |||
176 | pos += (bar_width * 2.0); | 176 | pos += (bar_width * 2.0); | ||
177 | 177 | | |||
178 | rect = new ORORect(); | 178 | rect = new ORORect(); | ||
179 | rect->setPen(pen); | 179 | rect->setPen(pen); | ||
180 | rect->setBrush(brush); | 180 | rect->setBrush(brush); | ||
181 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | 181 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | ||
182 | page->addPrimitive(rect); | 182 | page->insertPrimitive(rect); | ||
183 | 183 | | |||
184 | pos += bar_width; | 184 | pos += bar_width; | ||
185 | 185 | | |||
186 | // render first set | 186 | // render first set | ||
187 | for (int i = 0; i < 6; ++i) { | 187 | for (int i = 0; i < 6; ++i) { | ||
188 | int b = val[i+1]; | 188 | int b = val[i+1]; | ||
189 | for (int w = 0; w < 7; ++w) { | 189 | for (int w = 0; w < 7; ++w) { | ||
190 | if (_encodings[b][_parity[val[0]][i]][w]) { | 190 | if (_encodings[b][_parity[val[0]][i]][w]) { | ||
191 | rect = new ORORect(); | 191 | rect = new ORORect(); | ||
192 | rect->setPen(pen); | 192 | rect->setPen(pen); | ||
193 | rect->setBrush(brush); | 193 | rect->setBrush(brush); | ||
194 | rect->setRect(QRectF(pos, top, bar_width, draw_height - 0.07)); | 194 | rect->setRect(QRectF(pos, top, bar_width, draw_height - 0.07)); | ||
195 | page->addPrimitive(rect); | 195 | page->insertPrimitive(rect); | ||
196 | } | 196 | } | ||
197 | pos += bar_width; | 197 | pos += bar_width; | ||
198 | } | 198 | } | ||
199 | } | 199 | } | ||
200 | 200 | | |||
201 | // render center guard | 201 | // render center guard | ||
202 | pos += bar_width; | 202 | pos += bar_width; | ||
203 | 203 | | |||
204 | rect = new ORORect(); | 204 | rect = new ORORect(); | ||
205 | rect->setPen(pen); | 205 | rect->setPen(pen); | ||
206 | rect->setBrush(brush); | 206 | rect->setBrush(brush); | ||
207 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | 207 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | ||
208 | page->addPrimitive(rect); | 208 | page->insertPrimitive(rect); | ||
209 | 209 | | |||
210 | pos += (bar_width * 2.0); | 210 | pos += (bar_width * 2.0); | ||
211 | 211 | | |||
212 | rect = new ORORect(); | 212 | rect = new ORORect(); | ||
213 | rect->setPen(pen); | 213 | rect->setPen(pen); | ||
214 | rect->setBrush(brush); | 214 | rect->setBrush(brush); | ||
215 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | 215 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | ||
216 | page->addPrimitive(rect); | 216 | page->insertPrimitive(rect); | ||
217 | 217 | | |||
218 | pos += (bar_width * 2.0); | 218 | pos += (bar_width * 2.0); | ||
219 | 219 | | |||
220 | // render last set | 220 | // render last set | ||
221 | for (int i = 0; i < 6; ++i) { | 221 | for (int i = 0; i < 6; ++i) { | ||
222 | int b = val[i+7]; | 222 | int b = val[i+7]; | ||
223 | for (int w = 0; w < 7; ++w) { | 223 | for (int w = 0; w < 7; ++w) { | ||
224 | if (_encodings[b][RIGHTHAND][w]) { | 224 | if (_encodings[b][RIGHTHAND][w]) { | ||
225 | rect = new ORORect(); | 225 | rect = new ORORect(); | ||
226 | rect->setPen(pen); | 226 | rect->setPen(pen); | ||
227 | rect->setBrush(brush); | 227 | rect->setBrush(brush); | ||
228 | rect->setRect(QRectF(pos, top, bar_width, draw_height - 0.07)); | 228 | rect->setRect(QRectF(pos, top, bar_width, draw_height - 0.07)); | ||
229 | page->addPrimitive(rect); | 229 | page->insertPrimitive(rect); | ||
230 | } | 230 | } | ||
231 | pos += bar_width; | 231 | pos += bar_width; | ||
232 | } | 232 | } | ||
233 | } | 233 | } | ||
234 | 234 | | |||
235 | // render close guard | 235 | // render close guard | ||
236 | rect = new ORORect(); | 236 | rect = new ORORect(); | ||
237 | rect->setPen(pen); | 237 | rect->setPen(pen); | ||
238 | rect->setBrush(brush); | 238 | rect->setBrush(brush); | ||
239 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | 239 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | ||
240 | page->addPrimitive(rect); | 240 | page->insertPrimitive(rect); | ||
241 | 241 | | |||
242 | pos += (bar_width * 2.0); | 242 | pos += (bar_width * 2.0); | ||
243 | 243 | | |||
244 | rect = new ORORect(); | 244 | rect = new ORORect(); | ||
245 | rect->setPen(pen); | 245 | rect->setPen(pen); | ||
246 | rect->setBrush(brush); | 246 | rect->setBrush(brush); | ||
247 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | 247 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | ||
248 | page->addPrimitive(rect); | 248 | page->insertPrimitive(rect); | ||
249 | 249 | | |||
250 | QString parstr = QString::fromLatin1("%1").arg(val[0]); | 250 | QString parstr = QString::fromLatin1("%1").arg(val[0]); | ||
251 | QString leftstr = QString().sprintf("%d%d%d%d%d%d", | 251 | QString leftstr = QString().sprintf("%d%d%d%d%d%d", | ||
252 | val[1], val[2], val[3], val[4], val[5], val[6]); | 252 | val[1], val[2], val[3], val[4], val[5], val[6]); | ||
253 | QString rightstr = QString().sprintf("%d%d%d%d%d%d", | 253 | QString rightstr = QString().sprintf("%d%d%d%d%d%d", | ||
254 | val[7], val[8], val[9], val[10], val[11], val[12]); | 254 | val[7], val[8], val[9], val[10], val[11], val[12]); | ||
255 | QFont font(QLatin1String("Arial"), 6); | 255 | QFont font(QLatin1String("Arial"), 6); | ||
256 | 256 | | |||
257 | OROTextBox * tb = new OROTextBox(); | 257 | OROTextBox * tb = new OROTextBox(); | ||
258 | tb->setPosition(QPointF(r.left(), r.top() + draw_height - 0.12)); | 258 | tb->setPosition(QPointF(r.left(), r.top() + draw_height - 0.12)); | ||
259 | tb->setSize(QSizeF(quiet_zone - 0.02, 0.12)); | 259 | tb->setSize(QSizeF(quiet_zone - 0.02, 0.12)); | ||
260 | tb->setFont(font); | 260 | tb->setFont(font); | ||
261 | tb->setText(parstr); | 261 | tb->setText(parstr); | ||
262 | tb->setFlags(Qt::AlignRight | Qt::AlignTop); | 262 | tb->setFlags(Qt::AlignRight | Qt::AlignTop); | ||
263 | page->addPrimitive(tb); | 263 | page->insertPrimitive(tb); | ||
264 | 264 | | |||
265 | tb = new OROTextBox(); | 265 | tb = new OROTextBox(); | ||
266 | tb->setPosition(QPointF(r.left() + quiet_zone + 0.03, (r.top() + draw_height) - 0.07)); | 266 | tb->setPosition(QPointF(r.left() + quiet_zone + 0.03, (r.top() + draw_height) - 0.07)); | ||
267 | tb->setSize(QSizeF(0.42, 0.1)); | 267 | tb->setSize(QSizeF(0.42, 0.1)); | ||
268 | tb->setFont(font); | 268 | tb->setFont(font); | ||
269 | tb->setText(leftstr); | 269 | tb->setText(leftstr); | ||
270 | tb->setFlags(Qt::AlignHCenter | Qt::AlignTop); | 270 | tb->setFlags(Qt::AlignHCenter | Qt::AlignTop); | ||
271 | page->addPrimitive(tb); | 271 | page->insertPrimitive(tb); | ||
272 | 272 | | |||
273 | tb = new OROTextBox(); | 273 | tb = new OROTextBox(); | ||
274 | tb->setPosition(QPointF(r.left() + quiet_zone + 0.5, (r.top() + draw_height) - 0.07)); | 274 | tb->setPosition(QPointF(r.left() + quiet_zone + 0.5, (r.top() + draw_height) - 0.07)); | ||
275 | tb->setSize(QSizeF(0.42, 0.1)); | 275 | tb->setSize(QSizeF(0.42, 0.1)); | ||
276 | tb->setFont(font); | 276 | tb->setFont(font); | ||
277 | tb->setText(rightstr); | 277 | tb->setText(rightstr); | ||
278 | tb->setFlags(Qt::AlignHCenter | Qt::AlignTop); | 278 | tb->setFlags(Qt::AlignHCenter | Qt::AlignTop); | ||
279 | page->addPrimitive(tb); | 279 | page->insertPrimitive(tb); | ||
280 | } | 280 | } | ||
281 | 281 | | |||
282 | void renderCodeUPCA(OROPage * page, const QRectF & r, const QString & _str, int align) | 282 | void renderCodeUPCA(OROPage * page, const QRectF & r, const QString & _str, int align) | ||
283 | { | 283 | { | ||
284 | int val[13]; | 284 | int val[13]; | ||
285 | 285 | | |||
286 | // initialize all the values just so we can be predictable | 286 | // initialize all the values just so we can be predictable | ||
287 | for (int i = 0; i < 13; ++i) { | 287 | for (int i = 0; i < 13; ++i) { | ||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Line(s) | |||||
361 | QPen pen(Qt::NoPen); | 361 | QPen pen(Qt::NoPen); | ||
362 | QBrush brush(QColor("black")); | 362 | QBrush brush(QColor("black")); | ||
363 | 363 | | |||
364 | // render open guard | 364 | // render open guard | ||
365 | ORORect * rect = new ORORect(); | 365 | ORORect * rect = new ORORect(); | ||
366 | rect->setPen(pen); | 366 | rect->setPen(pen); | ||
367 | rect->setBrush(brush); | 367 | rect->setBrush(brush); | ||
368 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | 368 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | ||
369 | page->addPrimitive(rect); | 369 | page->insertPrimitive(rect); | ||
370 | 370 | | |||
371 | pos += (bar_width * 2.0); | 371 | pos += (bar_width * 2.0); | ||
372 | 372 | | |||
373 | rect = new ORORect(); | 373 | rect = new ORORect(); | ||
374 | rect->setPen(pen); | 374 | rect->setPen(pen); | ||
375 | rect->setBrush(brush); | 375 | rect->setBrush(brush); | ||
376 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | 376 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | ||
377 | page->addPrimitive(rect); | 377 | page->insertPrimitive(rect); | ||
378 | 378 | | |||
379 | pos += bar_width; | 379 | pos += bar_width; | ||
380 | 380 | | |||
381 | // render first set | 381 | // render first set | ||
382 | for (int i = 0; i < 6; ++i) { | 382 | for (int i = 0; i < 6; ++i) { | ||
383 | int b = val[i+1]; | 383 | int b = val[i+1]; | ||
384 | for (int w = 0; w < 7; ++w) { | 384 | for (int w = 0; w < 7; ++w) { | ||
385 | if (_encodings[b][_parity[val[0]][i]][w]) { | 385 | if (_encodings[b][_parity[val[0]][i]][w]) { | ||
386 | rect = new ORORect(); | 386 | rect = new ORORect(); | ||
387 | rect->setPen(pen); | 387 | rect->setPen(pen); | ||
388 | rect->setBrush(brush); | 388 | rect->setBrush(brush); | ||
389 | rect->setRect(QRectF(pos, top, bar_width, draw_height - (i == 0 ? 0 : 0.07))); | 389 | rect->setRect(QRectF(pos, top, bar_width, draw_height - (i == 0 ? 0 : 0.07))); | ||
390 | page->addPrimitive(rect); | 390 | page->insertPrimitive(rect); | ||
391 | } | 391 | } | ||
392 | pos += bar_width; | 392 | pos += bar_width; | ||
393 | } | 393 | } | ||
394 | } | 394 | } | ||
395 | 395 | | |||
396 | // render center guard | 396 | // render center guard | ||
397 | pos += bar_width; | 397 | pos += bar_width; | ||
398 | rect = new ORORect(); | 398 | rect = new ORORect(); | ||
399 | rect->setPen(pen); | 399 | rect->setPen(pen); | ||
400 | rect->setBrush(brush); | 400 | rect->setBrush(brush); | ||
401 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | 401 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | ||
402 | page->addPrimitive(rect); | 402 | page->insertPrimitive(rect); | ||
403 | 403 | | |||
404 | pos += (bar_width * 2.0); | 404 | pos += (bar_width * 2.0); | ||
405 | 405 | | |||
406 | rect = new ORORect(); | 406 | rect = new ORORect(); | ||
407 | rect->setPen(pen); | 407 | rect->setPen(pen); | ||
408 | rect->setBrush(brush); | 408 | rect->setBrush(brush); | ||
409 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | 409 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | ||
410 | page->addPrimitive(rect); | 410 | page->insertPrimitive(rect); | ||
411 | 411 | | |||
412 | pos += (bar_width * 2.0); | 412 | pos += (bar_width * 2.0); | ||
413 | 413 | | |||
414 | // render last set | 414 | // render last set | ||
415 | for (int i = 0; i < 6; ++i) { | 415 | for (int i = 0; i < 6; ++i) { | ||
416 | int b = val[i+7]; | 416 | int b = val[i+7]; | ||
417 | for (int w = 0; w < 7; ++w) { | 417 | for (int w = 0; w < 7; ++w) { | ||
418 | if (_encodings[b][RIGHTHAND][w]) { | 418 | if (_encodings[b][RIGHTHAND][w]) { | ||
419 | rect = new ORORect(); | 419 | rect = new ORORect(); | ||
420 | rect->setPen(pen); | 420 | rect->setPen(pen); | ||
421 | rect->setBrush(brush); | 421 | rect->setBrush(brush); | ||
422 | rect->setRect(QRectF(pos, top, bar_width, draw_height - (i == 5 ? 0 : 0.07))); | 422 | rect->setRect(QRectF(pos, top, bar_width, draw_height - (i == 5 ? 0 : 0.07))); | ||
423 | page->addPrimitive(rect); | 423 | page->insertPrimitive(rect); | ||
424 | } | 424 | } | ||
425 | pos += bar_width; | 425 | pos += bar_width; | ||
426 | } | 426 | } | ||
427 | } | 427 | } | ||
428 | 428 | | |||
429 | // render close guard | 429 | // render close guard | ||
430 | rect = new ORORect(); | 430 | rect = new ORORect(); | ||
431 | rect->setPen(pen); | 431 | rect->setPen(pen); | ||
432 | rect->setBrush(brush); | 432 | rect->setBrush(brush); | ||
433 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | 433 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | ||
434 | page->addPrimitive(rect); | 434 | page->insertPrimitive(rect); | ||
435 | 435 | | |||
436 | pos += (bar_width * 2.0); | 436 | pos += (bar_width * 2.0); | ||
437 | 437 | | |||
438 | rect = new ORORect(); | 438 | rect = new ORORect(); | ||
439 | rect->setPen(pen); | 439 | rect->setPen(pen); | ||
440 | rect->setBrush(brush); | 440 | rect->setBrush(brush); | ||
441 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | 441 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | ||
442 | page->addPrimitive(rect); | 442 | page->insertPrimitive(rect); | ||
443 | 443 | | |||
444 | QString parstr = QString::number(val[1]); | 444 | QString parstr = QString::number(val[1]); | ||
445 | QString chkstr = QString::number(val[12]); | 445 | QString chkstr = QString::number(val[12]); | ||
446 | QString leftstr = QString().sprintf("%d%d%d%d%d", | 446 | QString leftstr = QString().sprintf("%d%d%d%d%d", | ||
447 | val[2], val[3], val[4], val[5], val[6]); | 447 | val[2], val[3], val[4], val[5], val[6]); | ||
448 | QString rightstr = QString().sprintf("%d%d%d%d%d", | 448 | QString rightstr = QString().sprintf("%d%d%d%d%d", | ||
449 | val[7], val[8], val[9], val[10], val[11]); | 449 | val[7], val[8], val[9], val[10], val[11]); | ||
450 | 450 | | |||
451 | QFont font(QLatin1String("Arial"), 6); | 451 | QFont font(QLatin1String("Arial"), 6); | ||
452 | KRTextStyleData ts; | 452 | KRTextStyleData ts; | ||
453 | ts.backgroundColor = Qt::white; | 453 | ts.backgroundColor = Qt::white; | ||
454 | ts.font = font; | 454 | ts.font = font; | ||
455 | ts.foregroundColor = Qt::black; | 455 | ts.foregroundColor = Qt::black; | ||
456 | ts.backgroundOpacity = 100; | 456 | ts.backgroundOpacity = 100; | ||
457 | ts.alignment = Qt::AlignRight | Qt::AlignTop; | 457 | ts.alignment = Qt::AlignRight | Qt::AlignTop; | ||
458 | 458 | | |||
459 | OROTextBox * tb = new OROTextBox(); | 459 | OROTextBox * tb = new OROTextBox(); | ||
460 | tb->setPosition(QPointF(r.left(), r.top() + draw_height - 12)); | 460 | tb->setPosition(QPointF(r.left(), r.top() + draw_height - 12)); | ||
461 | tb->setSize(QSizeF(quiet_zone - 2, 12)); | 461 | tb->setSize(QSizeF(quiet_zone - 2, 12)); | ||
462 | tb->setTextStyle(ts); | 462 | tb->setTextStyle(ts); | ||
463 | tb->setText(parstr); | 463 | tb->setText(parstr); | ||
464 | 464 | | |||
465 | page->addPrimitive(tb); | 465 | page->insertPrimitive(tb); | ||
466 | 466 | | |||
467 | tb = new OROTextBox(); | 467 | tb = new OROTextBox(); | ||
468 | tb->setPosition(QPointF(r.left() + quiet_zone + 10, (r.top() + draw_height) - 7)); | 468 | tb->setPosition(QPointF(r.left() + quiet_zone + 10, (r.top() + draw_height) - 7)); | ||
469 | tb->setSize(QSizeF(35, 10)); | 469 | tb->setSize(QSizeF(35, 10)); | ||
470 | tb->setTextStyle(ts); | 470 | tb->setTextStyle(ts); | ||
471 | tb->setText(leftstr); | 471 | tb->setText(leftstr); | ||
472 | page->addPrimitive(tb); | 472 | page->insertPrimitive(tb); | ||
473 | 473 | | |||
474 | tb = new OROTextBox(); | 474 | tb = new OROTextBox(); | ||
475 | tb->setPosition(QPointF(r.left() + quiet_zone + 50, (r.top() + draw_height) - 7)); | 475 | tb->setPosition(QPointF(r.left() + quiet_zone + 50, (r.top() + draw_height) - 7)); | ||
476 | tb->setSize(QSizeF(35, 10)); | 476 | tb->setSize(QSizeF(35, 10)); | ||
477 | tb->setTextStyle(ts); | 477 | tb->setTextStyle(ts); | ||
478 | tb->setText(rightstr); | 478 | tb->setText(rightstr); | ||
479 | page->addPrimitive(tb); | 479 | page->insertPrimitive(tb); | ||
480 | 480 | | |||
481 | tb = new OROTextBox(); | 481 | tb = new OROTextBox(); | ||
482 | tb->setPosition(QPointF(r.left() + quiet_zone + L + 2, (r.top() + draw_height) - 12)); | 482 | tb->setPosition(QPointF(r.left() + quiet_zone + L + 2, (r.top() + draw_height) - 12)); | ||
483 | tb->setSize(QSizeF(8, 12)); | 483 | tb->setSize(QSizeF(8, 12)); | ||
484 | tb->setTextStyle(ts); | 484 | tb->setTextStyle(ts); | ||
485 | tb->setText(chkstr); | 485 | tb->setText(chkstr); | ||
486 | page->addPrimitive(tb); | 486 | page->insertPrimitive(tb); | ||
487 | } | 487 | } | ||
488 | 488 | | |||
489 | void renderCodeEAN8(OROPage * page, const QRectF & r, const QString & _str, int align) | 489 | void renderCodeEAN8(OROPage * page, const QRectF & r, const QString & _str, int align) | ||
490 | { | 490 | { | ||
491 | int val[8]; | 491 | int val[8]; | ||
492 | 492 | | |||
493 | // initialize all the values just so we can be predictable | 493 | // initialize all the values just so we can be predictable | ||
494 | for (int i = 0; i < 8; ++i) { | 494 | for (int i = 0; i < 8; ++i) { | ||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Line(s) | |||||
569 | QPen pen(Qt::NoPen); | 569 | QPen pen(Qt::NoPen); | ||
570 | QBrush brush(QColor("black")); | 570 | QBrush brush(QColor("black")); | ||
571 | 571 | | |||
572 | // render open guard | 572 | // render open guard | ||
573 | ORORect * rect = new ORORect(); | 573 | ORORect * rect = new ORORect(); | ||
574 | rect->setPen(pen); | 574 | rect->setPen(pen); | ||
575 | rect->setBrush(brush); | 575 | rect->setBrush(brush); | ||
576 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | 576 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | ||
577 | page->addPrimitive(rect); | 577 | page->insertPrimitive(rect); | ||
578 | 578 | | |||
579 | pos += (bar_width * 2.0); | 579 | pos += (bar_width * 2.0); | ||
580 | 580 | | |||
581 | rect = new ORORect(); | 581 | rect = new ORORect(); | ||
582 | rect->setPen(pen); | 582 | rect->setPen(pen); | ||
583 | rect->setBrush(brush); | 583 | rect->setBrush(brush); | ||
584 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | 584 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | ||
585 | page->addPrimitive(rect); | 585 | page->insertPrimitive(rect); | ||
586 | 586 | | |||
587 | pos += bar_width; | 587 | pos += bar_width; | ||
588 | 588 | | |||
589 | // render first set | 589 | // render first set | ||
590 | for (int i = 0; i < 4; ++i) { | 590 | for (int i = 0; i < 4; ++i) { | ||
591 | int b = val[i]; | 591 | int b = val[i]; | ||
592 | for (int w = 0; w < 7; ++w) { | 592 | for (int w = 0; w < 7; ++w) { | ||
593 | if (_encodings[b][LEFTHAND_ODD][w]) { | 593 | if (_encodings[b][LEFTHAND_ODD][w]) { | ||
594 | ORORect * rect = new ORORect(); | 594 | ORORect * rect = new ORORect(); | ||
595 | rect->setPen(pen); | 595 | rect->setPen(pen); | ||
596 | rect->setBrush(brush); | 596 | rect->setBrush(brush); | ||
597 | rect->setRect(QRectF(pos, top, bar_width, draw_height - 0.06)); | 597 | rect->setRect(QRectF(pos, top, bar_width, draw_height - 0.06)); | ||
598 | page->addPrimitive(rect); | 598 | page->insertPrimitive(rect); | ||
599 | } | 599 | } | ||
600 | pos += bar_width; | 600 | pos += bar_width; | ||
601 | } | 601 | } | ||
602 | } | 602 | } | ||
603 | 603 | | |||
604 | // render center guard | 604 | // render center guard | ||
605 | pos += bar_width; | 605 | pos += bar_width; | ||
606 | 606 | | |||
607 | rect = new ORORect(); | 607 | rect = new ORORect(); | ||
608 | rect->setPen(pen); | 608 | rect->setPen(pen); | ||
609 | rect->setBrush(brush); | 609 | rect->setBrush(brush); | ||
610 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | 610 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | ||
611 | page->addPrimitive(rect); | 611 | page->insertPrimitive(rect); | ||
612 | 612 | | |||
613 | pos += (bar_width * 2.0); | 613 | pos += (bar_width * 2.0); | ||
614 | 614 | | |||
615 | rect = new ORORect(); | 615 | rect = new ORORect(); | ||
616 | rect->setPen(pen); | 616 | rect->setPen(pen); | ||
617 | rect->setBrush(brush); | 617 | rect->setBrush(brush); | ||
618 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | 618 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | ||
619 | page->addPrimitive(rect); | 619 | page->insertPrimitive(rect); | ||
620 | 620 | | |||
621 | pos += (bar_width * 2.0); | 621 | pos += (bar_width * 2.0); | ||
622 | 622 | | |||
623 | // render last set | 623 | // render last set | ||
624 | for (int i = 0; i < 4; ++i) { | 624 | for (int i = 0; i < 4; ++i) { | ||
625 | int b = val[i+4]; | 625 | int b = val[i+4]; | ||
626 | for (int w = 0; w < 7; ++w) { | 626 | for (int w = 0; w < 7; ++w) { | ||
627 | if (_encodings[b][RIGHTHAND][w]) { | 627 | if (_encodings[b][RIGHTHAND][w]) { | ||
628 | ORORect * rect = new ORORect(); | 628 | ORORect * rect = new ORORect(); | ||
629 | rect->setPen(pen); | 629 | rect->setPen(pen); | ||
630 | rect->setBrush(brush); | 630 | rect->setBrush(brush); | ||
631 | rect->setRect(QRectF(pos, top, bar_width, draw_height - 0.06)); | 631 | rect->setRect(QRectF(pos, top, bar_width, draw_height - 0.06)); | ||
632 | page->addPrimitive(rect); | 632 | page->insertPrimitive(rect); | ||
633 | } | 633 | } | ||
634 | pos += bar_width; | 634 | pos += bar_width; | ||
635 | } | 635 | } | ||
636 | } | 636 | } | ||
637 | 637 | | |||
638 | // render close guard | 638 | // render close guard | ||
639 | rect = new ORORect(); | 639 | rect = new ORORect(); | ||
640 | rect->setPen(pen); | 640 | rect->setPen(pen); | ||
641 | rect->setBrush(brush); | 641 | rect->setBrush(brush); | ||
642 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | 642 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | ||
643 | page->addPrimitive(rect); | 643 | page->insertPrimitive(rect); | ||
644 | 644 | | |||
645 | pos += (bar_width * 2.0); | 645 | pos += (bar_width * 2.0); | ||
646 | 646 | | |||
647 | rect = new ORORect(); | 647 | rect = new ORORect(); | ||
648 | rect->setPen(pen); | 648 | rect->setPen(pen); | ||
649 | rect->setBrush(brush); | 649 | rect->setBrush(brush); | ||
650 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | 650 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | ||
651 | page->addPrimitive(rect); | 651 | page->insertPrimitive(rect); | ||
652 | 652 | | |||
653 | QString leftstr = QString().sprintf("%d%d%d%d", | 653 | QString leftstr = QString().sprintf("%d%d%d%d", | ||
654 | val[0], val[1], val[2], val[3]); | 654 | val[0], val[1], val[2], val[3]); | ||
655 | QString rightstr = QString().sprintf("%d%d%d%d", | 655 | QString rightstr = QString().sprintf("%d%d%d%d", | ||
656 | val[4], val[5], val[6], val[7]); | 656 | val[4], val[5], val[6], val[7]); | ||
657 | QFont font(QLatin1String("Arial"), 6); | 657 | QFont font(QLatin1String("Arial"), 6); | ||
658 | OROTextBox * tb = new OROTextBox(); | 658 | OROTextBox * tb = new OROTextBox(); | ||
659 | 659 | | |||
660 | tb->setPosition(QPointF(r.left() + quiet_zone + 0.03, (r.top() + draw_height) - 0.06)); | 660 | tb->setPosition(QPointF(r.left() + quiet_zone + 0.03, (r.top() + draw_height) - 0.06)); | ||
661 | tb->setSize(QSizeF(0.28, 0.10)); | 661 | tb->setSize(QSizeF(0.28, 0.10)); | ||
662 | tb->setFont(font); | 662 | tb->setFont(font); | ||
663 | tb->setText(leftstr); | 663 | tb->setText(leftstr); | ||
664 | tb->setFlags(Qt::AlignHCenter | Qt::AlignTop); | 664 | tb->setFlags(Qt::AlignHCenter | Qt::AlignTop); | ||
665 | page->addPrimitive(tb); | 665 | page->insertPrimitive(tb); | ||
666 | 666 | | |||
667 | tb = new OROTextBox(); | 667 | tb = new OROTextBox(); | ||
668 | tb->setPosition(QPointF(r.left() + quiet_zone + 0.36, (r.top() + draw_height) - 0.06)); | 668 | tb->setPosition(QPointF(r.left() + quiet_zone + 0.36, (r.top() + draw_height) - 0.06)); | ||
669 | tb->setSize(QSizeF(0.28, 0.10)); | 669 | tb->setSize(QSizeF(0.28, 0.10)); | ||
670 | tb->setFont(font); | 670 | tb->setFont(font); | ||
671 | tb->setText(rightstr); | 671 | tb->setText(rightstr); | ||
672 | tb->setFlags(Qt::AlignHCenter | Qt::AlignTop); | 672 | tb->setFlags(Qt::AlignHCenter | Qt::AlignTop); | ||
673 | page->addPrimitive(tb); | 673 | page->insertPrimitive(tb); | ||
674 | } | 674 | } | ||
675 | 675 | | |||
676 | void renderCodeUPCE(OROPage * page, const QRectF & r, const QString & _str, int align) | 676 | void renderCodeUPCE(OROPage * page, const QRectF & r, const QString & _str, int align) | ||
677 | { | 677 | { | ||
678 | int val[8]; | 678 | int val[8]; | ||
679 | 679 | | |||
680 | // initialize all the values just so we can be predictable | 680 | // initialize all the values just so we can be predictable | ||
681 | for (int i = 0; i < 8; ++i) { | 681 | for (int i = 0; i < 8; ++i) { | ||
▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Line(s) | |||||
748 | QPen pen(Qt::NoPen); | 748 | QPen pen(Qt::NoPen); | ||
749 | QBrush brush(QColor("black")); | 749 | QBrush brush(QColor("black")); | ||
750 | 750 | | |||
751 | // render open guard | 751 | // render open guard | ||
752 | ORORect * rect = new ORORect(); | 752 | ORORect * rect = new ORORect(); | ||
753 | rect->setPen(pen); | 753 | rect->setPen(pen); | ||
754 | rect->setBrush(brush); | 754 | rect->setBrush(brush); | ||
755 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | 755 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | ||
756 | page->addPrimitive(rect); | 756 | page->insertPrimitive(rect); | ||
757 | 757 | | |||
758 | pos += (bar_width * 2.0); | 758 | pos += (bar_width * 2.0); | ||
759 | 759 | | |||
760 | rect = new ORORect(); | 760 | rect = new ORORect(); | ||
761 | rect->setPen(pen); | 761 | rect->setPen(pen); | ||
762 | rect->setBrush(brush); | 762 | rect->setBrush(brush); | ||
763 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | 763 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | ||
764 | page->addPrimitive(rect); | 764 | page->insertPrimitive(rect); | ||
765 | 765 | | |||
766 | pos += bar_width; | 766 | pos += bar_width; | ||
767 | 767 | | |||
768 | // render first set | 768 | // render first set | ||
769 | for (int i = 0; i < 6; ++i) { | 769 | for (int i = 0; i < 6; ++i) { | ||
770 | int b = val[i+1]; | 770 | int b = val[i+1]; | ||
771 | for (int w = 0; w < 7; ++w) { | 771 | for (int w = 0; w < 7; ++w) { | ||
772 | if (_encodings[b][_upcparenc[val[7]][val[0]][i]][w]) { | 772 | if (_encodings[b][_upcparenc[val[7]][val[0]][i]][w]) { | ||
773 | rect = new ORORect(); | 773 | rect = new ORORect(); | ||
774 | rect->setPen(pen); | 774 | rect->setPen(pen); | ||
775 | rect->setBrush(brush); | 775 | rect->setBrush(brush); | ||
776 | rect->setRect(QRectF(pos, top, bar_width, draw_height - 7)); | 776 | rect->setRect(QRectF(pos, top, bar_width, draw_height - 7)); | ||
777 | page->addPrimitive(rect); | 777 | page->insertPrimitive(rect); | ||
778 | } | 778 | } | ||
779 | pos += bar_width; | 779 | pos += bar_width; | ||
780 | } | 780 | } | ||
781 | } | 781 | } | ||
782 | 782 | | |||
783 | // render center guard | 783 | // render center guard | ||
784 | pos += bar_width; | 784 | pos += bar_width; | ||
785 | 785 | | |||
786 | rect = new ORORect(); | 786 | rect = new ORORect(); | ||
787 | rect->setPen(pen); | 787 | rect->setPen(pen); | ||
788 | rect->setBrush(brush); | 788 | rect->setBrush(brush); | ||
789 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | 789 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | ||
790 | page->addPrimitive(rect); | 790 | page->insertPrimitive(rect); | ||
791 | 791 | | |||
792 | pos += (bar_width * 2.0); | 792 | pos += (bar_width * 2.0); | ||
793 | 793 | | |||
794 | rect = new ORORect(); | 794 | rect = new ORORect(); | ||
795 | rect->setPen(pen); | 795 | rect->setPen(pen); | ||
796 | rect->setBrush(brush); | 796 | rect->setBrush(brush); | ||
797 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | 797 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | ||
798 | page->addPrimitive(rect); | 798 | page->insertPrimitive(rect); | ||
799 | 799 | | |||
800 | pos += (bar_width * 2.0); | 800 | pos += (bar_width * 2.0); | ||
801 | 801 | | |||
802 | // render close guard | 802 | // render close guard | ||
803 | 803 | | |||
804 | rect = new ORORect(); | 804 | rect = new ORORect(); | ||
805 | rect->setPen(pen); | 805 | rect->setPen(pen); | ||
806 | rect->setBrush(brush); | 806 | rect->setBrush(brush); | ||
807 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | 807 | rect->setRect(QRectF(pos, top, bar_width, draw_height)); | ||
808 | page->addPrimitive(rect); | 808 | page->insertPrimitive(rect); | ||
809 | 809 | | |||
810 | QString parstr = QString::number(val[0]); | 810 | QString parstr = QString::number(val[0]); | ||
811 | QString chkstr = QString::number(val[7]); | 811 | QString chkstr = QString::number(val[7]); | ||
812 | QString leftstr = QString().sprintf("%d%d%d%d%d%d", | 812 | QString leftstr = QString().sprintf("%d%d%d%d%d%d", | ||
813 | val[1], val[2], val[3], val[4], val[5], val[6]); | 813 | val[1], val[2], val[3], val[4], val[5], val[6]); | ||
814 | QFont font(QLatin1String("Arial"), 6); | 814 | QFont font(QLatin1String("Arial"), 6); | ||
815 | KRTextStyleData ts; | 815 | KRTextStyleData ts; | ||
816 | ts.backgroundColor = Qt::white; | 816 | ts.backgroundColor = Qt::white; | ||
817 | ts.font = font; | 817 | ts.font = font; | ||
818 | ts.foregroundColor = Qt::black; | 818 | ts.foregroundColor = Qt::black; | ||
819 | ts.backgroundOpacity = 100; | 819 | ts.backgroundOpacity = 100; | ||
820 | ts.alignment = Qt::AlignRight | Qt::AlignTop; | 820 | ts.alignment = Qt::AlignRight | Qt::AlignTop; | ||
821 | 821 | | |||
822 | OROTextBox * tb = new OROTextBox(); | 822 | OROTextBox * tb = new OROTextBox(); | ||
823 | tb->setPosition(QPointF(r.left(), r.top() + draw_height - 12)); | 823 | tb->setPosition(QPointF(r.left(), r.top() + draw_height - 12)); | ||
824 | tb->setSize(QSizeF(quiet_zone - 2, 12)); | 824 | tb->setSize(QSizeF(quiet_zone - 2, 12)); | ||
825 | tb->setTextStyle(ts); | 825 | tb->setTextStyle(ts); | ||
826 | tb->setText(parstr); | 826 | tb->setText(parstr); | ||
827 | page->addPrimitive(tb); | 827 | page->insertPrimitive(tb); | ||
828 | 828 | | |||
829 | tb = new OROTextBox(); | 829 | tb = new OROTextBox(); | ||
830 | tb->setPosition(QPointF(r.left() + quiet_zone + 3, (r.top() + draw_height) - 7)); | 830 | tb->setPosition(QPointF(r.left() + quiet_zone + 3, (r.top() + draw_height) - 7)); | ||
831 | tb->setSize(QSizeF(42, 10)); | 831 | tb->setSize(QSizeF(42, 10)); | ||
832 | tb->setTextStyle(ts); | 832 | tb->setTextStyle(ts); | ||
833 | tb->setText(leftstr); | 833 | tb->setText(leftstr); | ||
834 | page->addPrimitive(tb); | 834 | page->insertPrimitive(tb); | ||
835 | 835 | | |||
836 | tb = new OROTextBox(); | 836 | tb = new OROTextBox(); | ||
837 | tb->setPosition(QPointF(r.left() + quiet_zone + L + 2, r.top() + draw_height - 12)); | 837 | tb->setPosition(QPointF(r.left() + quiet_zone + L + 2, r.top() + draw_height - 12)); | ||
838 | tb->setSize(QSizeF(8, 12)); | 838 | tb->setSize(QSizeF(8, 12)); | ||
839 | tb->setTextStyle(ts); | 839 | tb->setTextStyle(ts); | ||
840 | tb->setText(chkstr); | 840 | tb->setText(chkstr); | ||
841 | page->addPrimitive(tb); | 841 | page->insertPrimitive(tb); | ||
842 | } | 842 | } |