2008-07-19 02:48:31 +12:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 2008 by BogDan Vatra *
|
|
|
|
* bogdan@licentia.eu *
|
2020-04-07 03:37:34 +12:00
|
|
|
* Copyright (C) 2010-2020 Robin Stuart *
|
2008-07-19 02:48:31 +12:00
|
|
|
* *
|
|
|
|
* This program is free software: you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
|
|
|
***************************************************************************/
|
2020-05-16 21:22:33 +12:00
|
|
|
/* vim: set ts=4 sw=4 et : */
|
2008-07-19 02:48:31 +12:00
|
|
|
|
2008-09-19 02:43:54 +12:00
|
|
|
#include "qzint.h"
|
2009-04-29 03:34:02 +12:00
|
|
|
#include <stdio.h>
|
2018-06-19 14:56:44 +12:00
|
|
|
#include <math.h>
|
2018-06-18 14:55:52 +12:00
|
|
|
#include <QFontMetrics>
|
2020-08-05 01:49:25 +12:00
|
|
|
/* the following include was necessary to compile with QT 5.18 on Windows */
|
|
|
|
/* QT 8.7 did not require it. */
|
|
|
|
#include <QPainterPath>
|
2008-07-19 02:48:31 +12:00
|
|
|
|
2016-08-14 20:58:38 +12:00
|
|
|
namespace Zint {
|
|
|
|
static const char* fontstyle = "Arial";
|
2018-06-19 14:56:44 +12:00
|
|
|
static const int fontPixelSizeSmall = 8;
|
|
|
|
static const int fontPixelSizeLarge = 12;
|
2016-08-14 20:58:38 +12:00
|
|
|
|
|
|
|
QZint::QZint() {
|
|
|
|
m_symbol = BARCODE_CODE128;
|
2019-10-21 20:29:21 +13:00
|
|
|
m_height = 0;
|
2016-08-14 20:58:38 +12:00
|
|
|
m_border = NO_BORDER;
|
2017-06-18 02:17:24 +12:00
|
|
|
m_borderWidth = 0;
|
2016-08-14 20:58:38 +12:00
|
|
|
m_securityLevel = -1;
|
|
|
|
m_fgColor = Qt::black;
|
|
|
|
m_bgColor = Qt::white;
|
2020-06-05 05:45:25 +12:00
|
|
|
m_zintSymbol = NULL;
|
2016-08-14 20:58:38 +12:00
|
|
|
m_error = 0;
|
2020-06-05 05:45:25 +12:00
|
|
|
m_input_mode = UNICODE_MODE;
|
2016-08-14 20:58:38 +12:00
|
|
|
m_scale = 1.0;
|
|
|
|
m_option_3 = 0;
|
2016-12-12 04:29:06 +13:00
|
|
|
m_hidetext = 0;
|
2016-09-19 01:09:58 +12:00
|
|
|
m_dot_size = 4.0 / 5.0;
|
2016-12-15 12:33:17 +13:00
|
|
|
target_size_horiz = 0;
|
|
|
|
target_size_vert = 0;
|
2020-06-05 05:45:25 +12:00
|
|
|
m_option_2 = 0;
|
2017-08-06 18:02:07 +12:00
|
|
|
m_whitespace = 0;
|
2020-06-05 05:45:25 +12:00
|
|
|
m_gssep = false;
|
|
|
|
m_debug = false;
|
2016-08-14 20:58:38 +12:00
|
|
|
}
|
|
|
|
|
|
|
|
QZint::~QZint() {
|
|
|
|
if (m_zintSymbol)
|
|
|
|
ZBarcode_Delete(m_zintSymbol);
|
|
|
|
}
|
|
|
|
|
2020-06-05 05:45:25 +12:00
|
|
|
void QZint::resetSymbol() {
|
2016-08-14 20:58:38 +12:00
|
|
|
if (m_zintSymbol)
|
|
|
|
ZBarcode_Delete(m_zintSymbol);
|
|
|
|
|
|
|
|
m_lastError.clear();
|
|
|
|
m_zintSymbol = ZBarcode_Create();
|
2020-06-05 05:45:25 +12:00
|
|
|
m_zintSymbol->output_options |= m_border;
|
2016-08-14 20:58:38 +12:00
|
|
|
m_zintSymbol->symbology = m_symbol;
|
|
|
|
m_zintSymbol->height = m_height;
|
|
|
|
m_zintSymbol->whitespace_width = m_whitespace;
|
|
|
|
m_zintSymbol->border_width = m_borderWidth;
|
|
|
|
m_zintSymbol->option_1 = m_securityLevel;
|
2017-10-30 10:38:39 +13:00
|
|
|
m_zintSymbol->input_mode = m_input_mode;
|
2020-06-05 05:45:25 +12:00
|
|
|
m_zintSymbol->option_2 = m_option_2;
|
2016-09-19 01:09:58 +12:00
|
|
|
m_zintSymbol->dot_size = m_dot_size;
|
2016-08-14 20:58:38 +12:00
|
|
|
if (m_hidetext) {
|
|
|
|
m_zintSymbol->show_hrt = 0;
|
|
|
|
} else {
|
|
|
|
m_zintSymbol->show_hrt = 1;
|
|
|
|
}
|
2020-05-16 21:22:33 +12:00
|
|
|
m_zintSymbol->option_3 = m_option_3;
|
2020-06-05 05:45:25 +12:00
|
|
|
m_zintSymbol->scale = m_scale;
|
|
|
|
if (m_gssep) {
|
|
|
|
m_zintSymbol->output_options |= GS1_GS_SEPARATOR;
|
|
|
|
}
|
|
|
|
if (m_debug) {
|
|
|
|
m_zintSymbol->debug |= ZINT_DEBUG_PRINT;
|
|
|
|
}
|
|
|
|
|
|
|
|
strcpy(m_zintSymbol->fgcolour, m_fgColor.name().toLatin1().right(6));
|
2020-08-05 02:10:16 +12:00
|
|
|
if (m_fgColor.alpha() != 0xff) {
|
|
|
|
strcat(m_zintSymbol->fgcolour, m_fgColor.name(QColor::HexArgb).toLatin1().mid(1,2));
|
|
|
|
}
|
2020-06-05 05:45:25 +12:00
|
|
|
strcpy(m_zintSymbol->bgcolour, m_bgColor.name().toLatin1().right(6));
|
2020-08-05 02:10:16 +12:00
|
|
|
if (m_bgColor.alpha() != 0xff) {
|
|
|
|
strcat(m_zintSymbol->bgcolour, m_bgColor.name(QColor::HexArgb).toLatin1().mid(1,2));
|
|
|
|
}
|
2020-06-05 05:45:25 +12:00
|
|
|
strcpy(m_zintSymbol->primary, m_primaryMessage.toLatin1().left(127));
|
|
|
|
}
|
|
|
|
|
|
|
|
void QZint::encode() {
|
|
|
|
resetSymbol();
|
2016-08-14 20:58:38 +12:00
|
|
|
QByteArray bstr = m_text.toUtf8();
|
2018-06-18 13:36:40 +12:00
|
|
|
m_error = ZBarcode_Encode_and_Buffer_Vector(m_zintSymbol, (unsigned char*) bstr.data(), bstr.length(), 0);
|
2018-01-22 03:59:15 +13:00
|
|
|
m_lastError = m_zintSymbol->errtxt;
|
2016-08-14 20:58:38 +12:00
|
|
|
|
2020-06-05 05:45:25 +12:00
|
|
|
switch (m_zintSymbol->output_options & (BARCODE_BIND | BARCODE_BOX)) {
|
2016-08-14 20:58:38 +12:00
|
|
|
case 0: m_border = NO_BORDER;
|
|
|
|
break;
|
|
|
|
case 2: m_border = BIND;
|
|
|
|
break;
|
|
|
|
case 4: m_border = BOX;
|
|
|
|
break;
|
|
|
|
}
|
2017-06-18 02:17:24 +12:00
|
|
|
m_borderWidth = m_zintSymbol->border_width;
|
2016-08-14 20:58:38 +12:00
|
|
|
m_whitespace = m_zintSymbol->whitespace_width;
|
|
|
|
}
|
|
|
|
|
2017-09-11 03:03:09 +12:00
|
|
|
int QZint::symbol() const {
|
2016-08-14 20:58:38 +12:00
|
|
|
return m_symbol;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QZint::setSymbol(int symbol) {
|
|
|
|
m_symbol = symbol;
|
|
|
|
}
|
|
|
|
|
2020-06-05 05:45:25 +12:00
|
|
|
int QZint::inputMode() const {
|
|
|
|
return m_input_mode;
|
|
|
|
}
|
|
|
|
|
2016-08-14 20:58:38 +12:00
|
|
|
void QZint::setInputMode(int input_mode) {
|
|
|
|
m_input_mode = input_mode;
|
|
|
|
}
|
|
|
|
|
2017-09-11 03:03:09 +12:00
|
|
|
QString QZint::text() const {
|
2016-08-14 20:58:38 +12:00
|
|
|
return m_text;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QZint::setText(const QString & text) {
|
|
|
|
m_text = text;
|
|
|
|
}
|
2017-10-24 08:37:52 +13:00
|
|
|
|
2017-09-11 03:03:09 +12:00
|
|
|
QString QZint::primaryMessage() const {
|
2016-08-14 20:58:38 +12:00
|
|
|
return m_primaryMessage;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QZint::setPrimaryMessage(const QString & primaryMessage) {
|
|
|
|
m_primaryMessage = primaryMessage;
|
|
|
|
}
|
|
|
|
|
2020-06-05 05:45:25 +12:00
|
|
|
int QZint::height() const {
|
|
|
|
return m_height;
|
|
|
|
}
|
|
|
|
|
2016-08-14 20:58:38 +12:00
|
|
|
void QZint::setHeight(int height) {
|
|
|
|
m_height = height;
|
|
|
|
}
|
|
|
|
|
2020-06-05 05:45:25 +12:00
|
|
|
int QZint::option2() const {
|
|
|
|
return m_option_2;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QZint::setOption2(int option) {
|
|
|
|
m_option_2 = option;
|
2016-08-14 20:58:38 +12:00
|
|
|
}
|
|
|
|
|
|
|
|
void QZint::setOption3(int option) {
|
|
|
|
m_option_3 = option;
|
|
|
|
}
|
|
|
|
|
2017-09-11 03:03:09 +12:00
|
|
|
float QZint::scale() const {
|
2016-08-14 20:58:38 +12:00
|
|
|
return m_scale;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QZint::setScale(float scale) {
|
|
|
|
m_scale = scale;
|
|
|
|
}
|
2017-10-24 08:37:52 +13:00
|
|
|
|
2016-09-19 01:09:58 +12:00
|
|
|
void QZint::setDotSize(float dot_size) {
|
|
|
|
m_dot_size = dot_size;
|
|
|
|
}
|
2016-08-14 20:58:38 +12:00
|
|
|
|
2017-09-11 03:03:09 +12:00
|
|
|
QColor QZint::fgColor() const {
|
2016-08-14 20:58:38 +12:00
|
|
|
return m_fgColor;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QZint::setFgColor(const QColor & fgColor) {
|
|
|
|
m_fgColor = fgColor;
|
|
|
|
}
|
|
|
|
|
2017-09-11 03:03:09 +12:00
|
|
|
QColor QZint::bgColor() const {
|
2016-08-14 20:58:38 +12:00
|
|
|
return m_bgColor;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QZint::setBgColor(const QColor & bgColor) {
|
|
|
|
m_bgColor = bgColor;
|
|
|
|
}
|
|
|
|
|
2017-09-11 03:03:09 +12:00
|
|
|
QZint::BorderType QZint::borderType() const {
|
2016-08-14 20:58:38 +12:00
|
|
|
return m_border;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QZint::setBorderType(BorderType border) {
|
|
|
|
m_border = border;
|
|
|
|
}
|
|
|
|
|
2017-09-11 03:03:09 +12:00
|
|
|
int QZint::borderWidth() const {
|
2016-08-14 20:58:38 +12:00
|
|
|
return m_borderWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QZint::setBorderWidth(int boderWidth) {
|
2017-06-18 02:17:24 +12:00
|
|
|
if (boderWidth < 0 || boderWidth > 16)
|
|
|
|
boderWidth = 0;
|
2016-08-14 20:58:38 +12:00
|
|
|
m_borderWidth = boderWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QZint::setWhitespace(int whitespace) {
|
|
|
|
m_whitespace = whitespace;
|
|
|
|
}
|
|
|
|
|
2017-09-11 03:03:09 +12:00
|
|
|
int QZint::securityLevel() const {
|
2016-08-14 20:58:38 +12:00
|
|
|
return m_securityLevel;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QZint::setSecurityLevel(int securityLevel) {
|
|
|
|
m_securityLevel = securityLevel;
|
|
|
|
}
|
|
|
|
|
2017-09-11 03:03:09 +12:00
|
|
|
int QZint::mode() const {
|
2016-08-14 20:58:38 +12:00
|
|
|
return m_securityLevel;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QZint::setMode(int securityLevel) {
|
|
|
|
m_securityLevel = securityLevel;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QZint::setHideText(bool hide) {
|
|
|
|
m_hidetext = hide;
|
|
|
|
}
|
|
|
|
|
2020-06-05 05:45:25 +12:00
|
|
|
void QZint::setTargetSize(int width, int height) {
|
|
|
|
target_size_horiz = width;
|
|
|
|
target_size_vert = height;
|
|
|
|
}
|
2016-08-14 20:58:38 +12:00
|
|
|
|
2020-06-05 05:45:25 +12:00
|
|
|
void QZint::setGSSep(bool gssep) {
|
|
|
|
m_gssep = gssep;
|
|
|
|
}
|
2016-08-14 20:58:38 +12:00
|
|
|
|
2020-06-05 05:45:25 +12:00
|
|
|
void QZint::setDebug(bool debug) {
|
|
|
|
m_debug = debug;
|
|
|
|
}
|
|
|
|
|
|
|
|
int QZint::getError() const {
|
|
|
|
return m_error;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString QZint::error_message() const {
|
|
|
|
return m_lastError;
|
|
|
|
}
|
|
|
|
|
|
|
|
const QString & QZint::lastError() const {
|
|
|
|
return m_lastError;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool QZint::hasErrors() const {
|
|
|
|
return m_lastError.length();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool QZint::save_to_file(QString filename) {
|
|
|
|
resetSymbol();
|
|
|
|
strcpy(m_zintSymbol->outfile, filename.toLatin1().left(255));
|
2016-08-14 20:58:38 +12:00
|
|
|
QByteArray bstr = m_text.toUtf8();
|
2017-12-20 11:01:45 +13:00
|
|
|
m_error = ZBarcode_Encode_and_Print(m_zintSymbol, (unsigned char*) bstr.data(), bstr.length(), 0);
|
2018-01-22 07:10:42 +13:00
|
|
|
if (m_error >= 5) {
|
2016-08-14 20:58:38 +12:00
|
|
|
m_lastError = m_zintSymbol->errtxt;
|
|
|
|
return false;
|
2017-12-20 11:01:45 +13:00
|
|
|
} else {
|
|
|
|
return true;
|
2016-08-14 20:58:38 +12:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void QZint::render(QPainter & painter, const QRectF & paintRect, AspectRatioMode mode) {
|
2018-06-18 13:36:40 +12:00
|
|
|
struct zint_vector_rect *rect;
|
|
|
|
struct zint_vector_hexagon *hex;
|
|
|
|
struct zint_vector_circle *circle;
|
|
|
|
struct zint_vector_string *string;
|
|
|
|
qreal radius;
|
2017-10-24 08:37:52 +13:00
|
|
|
|
2020-05-16 21:22:33 +12:00
|
|
|
(void)mode; /* Not currently used */
|
|
|
|
|
2016-12-15 12:33:17 +13:00
|
|
|
encode();
|
2017-10-24 08:37:52 +13:00
|
|
|
|
2016-08-14 20:58:38 +12:00
|
|
|
QFont fontSmall(fontstyle);
|
|
|
|
fontSmall.setPixelSize(fontPixelSizeSmall);
|
|
|
|
QFont fontLarge(fontstyle);
|
|
|
|
fontLarge.setPixelSize(fontPixelSizeLarge);
|
2017-10-24 08:37:52 +13:00
|
|
|
|
2018-01-22 03:59:15 +13:00
|
|
|
if (m_error >= 5) {
|
|
|
|
// Display error message instead of barcode
|
2016-12-16 08:41:20 +13:00
|
|
|
fontLarge.setPointSize(14);
|
2016-08-14 20:58:38 +12:00
|
|
|
painter.setFont(fontLarge);
|
|
|
|
painter.drawText(paintRect, Qt::AlignCenter, m_lastError);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
painter.save();
|
|
|
|
painter.setClipRect(paintRect, Qt::IntersectClip);
|
2017-10-24 08:37:52 +13:00
|
|
|
|
2016-08-14 20:58:38 +12:00
|
|
|
qreal xtr = paintRect.x();
|
|
|
|
qreal ytr = paintRect.y();
|
2018-06-18 13:36:40 +12:00
|
|
|
qreal scale;
|
|
|
|
|
|
|
|
qreal gwidth = m_zintSymbol->vector->width;
|
|
|
|
qreal gheight = m_zintSymbol->vector->height;
|
2017-10-24 08:37:52 +13:00
|
|
|
|
2016-12-15 12:33:17 +13:00
|
|
|
if (paintRect.width() / gwidth < paintRect.height() / gheight) {
|
2019-11-06 03:16:48 +13:00
|
|
|
scale = paintRect.width() / gwidth;
|
2016-12-15 12:33:17 +13:00
|
|
|
} else {
|
2019-11-06 03:16:48 +13:00
|
|
|
scale = paintRect.height() / gheight;
|
2016-12-15 12:33:17 +13:00
|
|
|
}
|
2018-06-19 14:56:44 +12:00
|
|
|
|
|
|
|
xtr += (qreal) (paintRect.width() - gwidth * scale) / 2.0;
|
|
|
|
ytr += (qreal) (paintRect.height() - gheight * scale) / 2.0;
|
2016-08-14 20:58:38 +12:00
|
|
|
|
|
|
|
painter.setBackground(QBrush(m_bgColor));
|
|
|
|
painter.fillRect(paintRect, QBrush(m_bgColor));
|
2018-06-18 13:36:40 +12:00
|
|
|
|
2016-08-14 20:58:38 +12:00
|
|
|
painter.translate(xtr, ytr);
|
2018-06-18 13:36:40 +12:00
|
|
|
painter.scale(scale, scale);
|
|
|
|
|
|
|
|
//Red square for diagnostics
|
|
|
|
//painter.fillRect(QRect(0, 0, m_zintSymbol->vector->width, m_zintSymbol->vector->height), QBrush(QColor(255,0,0,255)));
|
2016-08-14 20:58:38 +12:00
|
|
|
|
|
|
|
QPen p;
|
2017-10-24 08:37:52 +13:00
|
|
|
|
2018-06-18 13:36:40 +12:00
|
|
|
p.setWidth(1);
|
2018-06-19 14:56:44 +12:00
|
|
|
p.setColor(m_fgColor);
|
2016-08-14 20:58:38 +12:00
|
|
|
painter.setPen(p);
|
2018-06-18 13:36:40 +12:00
|
|
|
painter.setRenderHint(QPainter::Antialiasing);
|
|
|
|
|
|
|
|
// Plot rectangles
|
|
|
|
rect = m_zintSymbol->vector->rectangles;
|
|
|
|
while (rect) {
|
2020-04-07 03:37:34 +12:00
|
|
|
if (rect->colour == -1) {
|
|
|
|
painter.fillRect(rect->x, rect->y, rect->width, rect->height, QBrush(m_fgColor));
|
|
|
|
} else {
|
|
|
|
switch(rect->colour) {
|
|
|
|
case 1: // Cyan
|
|
|
|
painter.fillRect(rect->x, rect->y, rect->width, rect->height, QBrush(Qt::cyan));
|
|
|
|
break;
|
|
|
|
case 2: // Blue
|
|
|
|
painter.fillRect(rect->x, rect->y, rect->width, rect->height, QBrush(Qt::blue));
|
|
|
|
break;
|
|
|
|
case 3: // Magenta
|
|
|
|
painter.fillRect(rect->x, rect->y, rect->width, rect->height, QBrush(Qt::magenta));
|
|
|
|
break;
|
|
|
|
case 4: // Red
|
|
|
|
painter.fillRect(rect->x, rect->y, rect->width, rect->height, QBrush(Qt::red));
|
|
|
|
break;
|
|
|
|
case 5: // Yellow
|
|
|
|
painter.fillRect(rect->x, rect->y, rect->width, rect->height, QBrush(Qt::yellow));
|
|
|
|
break;
|
|
|
|
case 6: // Green
|
|
|
|
painter.fillRect(rect->x, rect->y, rect->width, rect->height, QBrush(Qt::green));
|
2020-08-12 23:19:26 +12:00
|
|
|
break;
|
|
|
|
case 8: // White
|
|
|
|
painter.fillRect(rect->x, rect->y, rect->width, rect->height, QBrush(Qt::white));
|
|
|
|
break;
|
2020-04-07 03:37:34 +12:00
|
|
|
default:
|
|
|
|
painter.fillRect(rect->x, rect->y, rect->width, rect->height, QBrush(Qt::black));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2018-06-18 13:36:40 +12:00
|
|
|
rect = rect->next;
|
2016-08-14 20:58:38 +12:00
|
|
|
}
|
2018-06-18 13:36:40 +12:00
|
|
|
|
|
|
|
// Plot hexagons
|
|
|
|
hex = m_zintSymbol->vector->hexagons;
|
|
|
|
while (hex) {
|
|
|
|
radius = hex->diameter / 2.0;
|
|
|
|
|
|
|
|
QPainterPath pt;
|
2018-06-19 14:56:44 +12:00
|
|
|
pt.moveTo(hex->x, hex->y + (1.0 * radius));
|
|
|
|
pt.lineTo(hex->x + (0.86 * radius), hex->y + (0.5 * radius));
|
|
|
|
pt.lineTo(hex->x + (0.86 * radius), hex->y - (0.5 * radius));
|
|
|
|
pt.lineTo(hex->x, hex->y - (1.0 * radius));
|
|
|
|
pt.lineTo(hex->x - (0.86 * radius), hex->y - (0.5 * radius));
|
|
|
|
pt.lineTo(hex->x - (0.86 * radius), hex->y + (0.5 * radius));
|
|
|
|
pt.lineTo(hex->x, hex->y + (1.0 * radius));
|
2018-06-18 13:36:40 +12:00
|
|
|
painter.fillPath(pt, QBrush(m_fgColor));
|
|
|
|
|
|
|
|
hex = hex->next;
|
2016-08-14 20:58:38 +12:00
|
|
|
}
|
2018-06-18 13:36:40 +12:00
|
|
|
|
|
|
|
// Plot dots (circles)
|
|
|
|
circle = m_zintSymbol->vector->circles;
|
|
|
|
while (circle) {
|
|
|
|
if (circle->colour) {
|
|
|
|
p.setColor(m_bgColor);
|
|
|
|
p.setWidth(0);
|
|
|
|
painter.setPen(p);
|
|
|
|
painter.setBrush(QBrush(m_bgColor));
|
|
|
|
} else {
|
|
|
|
p.setColor(m_fgColor);
|
|
|
|
p.setWidth(0);
|
|
|
|
painter.setPen(p);
|
|
|
|
painter.setBrush(QBrush(m_fgColor));
|
2016-08-14 20:58:38 +12:00
|
|
|
}
|
2018-06-18 13:36:40 +12:00
|
|
|
painter.drawEllipse(QPointF(circle->x, circle->y), (double) circle->diameter / 2.0, (double) circle->diameter / 2.0);
|
|
|
|
circle = circle->next;
|
2016-08-14 20:58:38 +12:00
|
|
|
}
|
2018-06-18 13:36:40 +12:00
|
|
|
|
|
|
|
// Plot text
|
|
|
|
string = m_zintSymbol->vector->strings;
|
|
|
|
if (string) {
|
|
|
|
painter.setFont(fontLarge);
|
2016-08-14 20:58:38 +12:00
|
|
|
}
|
2018-06-18 14:55:52 +12:00
|
|
|
QFontMetrics fm(fontLarge);
|
2018-06-18 13:36:40 +12:00
|
|
|
while (string) {
|
2018-06-18 14:55:52 +12:00
|
|
|
QString content = QString::fromUtf8((const char *) string->text, -1);
|
|
|
|
int width = fm.width(content, -1);
|
|
|
|
int height = fm.height();
|
|
|
|
painter.drawText(string->x - (width / 2.0), string->y - height, width, height, Qt::AlignHCenter | Qt::AlignBottom, content);
|
2018-06-18 13:36:40 +12:00
|
|
|
string = string->next;
|
2016-08-14 20:58:38 +12:00
|
|
|
}
|
2018-06-18 13:36:40 +12:00
|
|
|
|
2016-08-14 20:58:38 +12:00
|
|
|
painter.restore();
|
|
|
|
}
|
2017-08-06 18:02:07 +12:00
|
|
|
}
|