From 0dd072437e271e2786af79bd6486e1d6c3476bc5 Mon Sep 17 00:00:00 2001 From: Robin Stuart Date: Sat, 17 Sep 2016 11:39:01 +0100 Subject: [PATCH] Add Codablock options to Studio Also remove divide by zero bug calculating row height --- backend/library.c | 13 ++++++------- frontend/main.c | 2 +- frontend_qt4/frontend_qt4.pro | 1 + frontend_qt4/mainwindow.cpp | 30 +++++++++++++++++++++++++++--- frontend_qt4/resources.qrc | 1 + 5 files changed, 36 insertions(+), 11 deletions(-) diff --git a/backend/library.c b/backend/library.c index 821ba560..4d59db8e 100644 --- a/backend/library.c +++ b/backend/library.c @@ -378,23 +378,22 @@ static int hibc(struct zint_symbol *symbol, unsigned char source[], size_t lengt static void check_row_heights(struct zint_symbol *symbol) { /* Check that rows with undefined heights are never less than 5x */ - int large_bar_count; + int large_bar_count = 0; int i; - int preset_height; - int large_bar_height; + int preset_height = 0; + int large_bar_height = 0; - large_bar_count = 0; - preset_height = 0; for (i = 0; i < symbol->rows; i++) { preset_height += symbol->row_height[i]; if (symbol->row_height[i] == 0) { large_bar_count++; } } - large_bar_height = (symbol->height - preset_height) / large_bar_count; - + if (large_bar_count == 0) { symbol->height = preset_height; + } else { + large_bar_height = (symbol->height - preset_height) / large_bar_count; } if (large_bar_height < 5) { diff --git a/frontend/main.c b/frontend/main.c index e081f49e..d051c583 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -52,7 +52,7 @@ void types(void) { "21: Leitcode 70: RM4SCC 116: Han Xin Code\n" "22: Identcode 71: Data Matrix 128: Aztec Runes\n" "23: Code 16k 72: EAN-14 129: Code 32\n" - "24: Code 49 74: Codablock 130: Comp EAN\n" + "24: Code 49 74: Codablock-F 130: Comp EAN\n" "25: Code 93 75: NVE-18 131: Comp GS1-128\n" "28: Flattermarken 76: Japanese Post 132: Comp DataBar Omni\n" "29: GS1 DataBar Omni 77: Korea Post 133: Comp DataBar Ltd\n" diff --git a/frontend_qt4/frontend_qt4.pro b/frontend_qt4/frontend_qt4.pro index c2eefa36..d3412141 100644 --- a/frontend_qt4/frontend_qt4.pro +++ b/frontend_qt4/frontend_qt4.pro @@ -25,6 +25,7 @@ FORMS += extData.ui \ grpC49.ui \ grpChannel.ui \ grpCodeOne.ui \ + grpCodablockF.ui \ grpDBExtend.ui \ grpDM.ui \ grpGrid.ui \ diff --git a/frontend_qt4/mainwindow.cpp b/frontend_qt4/mainwindow.cpp index 85a51af1..3b37d239 100644 --- a/frontend_qt4/mainwindow.cpp +++ b/frontend_qt4/mainwindow.cpp @@ -39,7 +39,7 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags fl) "Aztec Runes", "Channel Code", "Codabar", - "Codablock", + "Codablock-F", "Code 11", "Code 128 (ISO 15417)", "Code 16k", @@ -57,7 +57,7 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags fl) "Data Matrix (ISO 16022)", "Deutsche Post Identcode", "Deutsche Post Leitcode", - "DotCode", + "DotCode", "Dutch Post KIX", "EAN-14", "European Article Number (EAN)", @@ -71,7 +71,7 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags fl) "GS1 DataBar Stacked", "GS1 DataBar Stacked Omnidirectional", "Han Xin (Chinese Sensible) Code", - "ITF-14", + "ITF-14", "International Standard Book Number (ISBN)", "Japanese Postal Barcode", "Korean Postal Barcode", @@ -365,6 +365,21 @@ void MainWindow::change_options() connect(m_optionWidget->findChild("radC16kStand"), SIGNAL(toggled( bool )), SLOT(update_preview())); } + if(metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_CODABLOCKF) + { + QFile file (":/grpCodablockF.ui"); + if (!file.open(QIODevice::ReadOnly)) + return; + m_optionWidget=uiload.load(&file); + file.close(); + tabMain->insertTab(1,m_optionWidget,tr("Codablock-F")); + connect(m_optionWidget->findChild("radCbfAutosize"), SIGNAL(toggled( bool )), SLOT(update_preview())); + connect(m_optionWidget->findChild("radCbfSetWidth"), SIGNAL(toggled( bool )), SLOT(update_preview())); + connect(m_optionWidget->findChild("radCbfSetHeight"), SIGNAL(toggled( bool )), SLOT(update_preview())); + connect(m_optionWidget->findChild("cmbCbfWidth"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview())); + connect(m_optionWidget->findChild("cmbCbfHeight"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview())); + } + if(metaObject()->enumerator(0).value(bstyle->currentIndex()) == BARCODE_DATAMATRIX) { QFile file(":/grpDM.ui"); @@ -744,6 +759,15 @@ void MainWindow::update_preview() m_bc.bc.setInputMode(GS1_MODE); break; + case BARCODE_CODABLOCKF: + m_bc.bc.setSymbol(BARCODE_CODABLOCKF); + if(m_optionWidget->findChild("radCbfSetWidth")->isChecked()) + m_bc.bc.setWidth(m_optionWidget->findChild("cmbCbfWidth")->currentIndex() + 6); + // Height selection uses option 1 in zint_symbol + if(m_optionWidget->findChild("radCbfSetHeight")->isChecked()) + m_bc.bc.setSecurityLevel(m_optionWidget->findChild("cmbCbfHeight")->currentIndex() + 1); + break; + case BARCODE_DATAMATRIX: m_bc.bc.setSecurityLevel(1); if(m_optionWidget->findChild("radDM200HIBC")->isChecked()) diff --git a/frontend_qt4/resources.qrc b/frontend_qt4/resources.qrc index 9882f077..e220588e 100644 --- a/frontend_qt4/resources.qrc +++ b/frontend_qt4/resources.qrc @@ -23,5 +23,6 @@ images/zint.png grpHX.ui grpDotCode.ui + grpCodablockF.ui