void ZebraPaintEngine::drawBarcode ( const QPointF & p, const QString &format, int height, int width, int narrowBar, QString barcodeData ) { QString barcodeFont; if(format == "3of9" || format == "3of9+") barcodeFont = "B3"; else if(format == "128") barcodeFont = "BC,,N,N,N,A"; else if(format == "ean13" || format == "upc-a") barcodeFont = "B8"; else if(format == "ean8") barcodeFont = "B8"; else if(format == "upc-e") barcodeFont = "B9"; else if(format == "i2of5") barcodeFont = "BI"; else if(format.contains("datamatrix")) { DmtxInfos dmtxInfos = extractInfosDtmx(format); int eltSize = qRound (qBound((qreal)2.0, (qreal)height / (qreal)dmtxInfos.ySize, (qreal)20.0)); barcodeFont = QString("BX,%1,200,%2,%3").arg(eltSize).arg(dmtxInfos.xSize).arg(dmtxInfos.ySize); } else { drawText(p, "ERR: " + format); } QTransform transform = painter()->worldTransform(); int yInDots = (int)(transform.dy()); int xInDots = (int)(transform.dx()); QString rotation = transformRotationCmd(); if(rotation == rotation90Cmd()) { xInDots -= height; } else if(rotation == rotation180Cmd()) { yInDots -= height; // we can't calculate the printed barcode width, so we can't print 180� and 270� correctly! Well done Zebra! // we use the TextItem's width instead as a fallback xInDots -= width; } else if(rotation == rotation270Cmd()) { yInDots -= width; } qreal narrowWidthRatio = 2.5; m_printBuffer += QString(m_CmdPrefix + "FO%1,%2" + m_CmdPrefix + "FW%3").arg(xInDots).arg(yInDots).arg(transformRotationCmd()); m_printBuffer += QString(m_CmdPrefix + "BY%1,%2,%3" + m_CmdPrefix + barcodeFont + m_CmdPrefix + "FD" + barcodeData + m_CmdPrefix + "FS\n").arg(narrowBar).arg(narrowWidthRatio).arg(height); }
void BarcodeEditor::setDatamatrixEditor(QString format) { DmtxInfos dmtxInfos = extractInfosDtmx(format); if(dmtxInfos.type <24) { this->cbFormat->setCurrentIndex(iDatamatrix_square); this->dMatrixSquare->setCursorValue(dmtxInfos.type); this->cbFormat_ViewConfig(iDatamatrix_square); } else { this->cbFormat->setCurrentIndex(iDatamatrix_rect); this->dMatrixRect->setIndexValue(dmtxInfos.type - 24); this->cbFormat_ViewConfig(iDatamatrix_rect); } if(dmtxInfos.align == "L") this->rbAlignLeft->setChecked(true); if(dmtxInfos.align == "C") this->rbAlignCenter->setChecked(true); if(dmtxInfos.align == "R") this->rbAlignRight->setChecked(true); }