修复状态机的部分异常、计数器编辑与预览更新、修复时间、轮班图元的高度多一行的问题

This commit is contained in:
2026-09-09 14:31:55 +08:00
parent 84e20a440c
commit 831fc0d639
18 changed files with 271 additions and 768 deletions
-58
View File
@@ -11,11 +11,6 @@ CounterVarSet::CounterVarSet(QWidget *parent) :
{ {
ui->setupUi(this); ui->setupUi(this);
ui->label_35->hide();
ui->spinBoxdecimalpointnum->hide();
ui->pushButtonVAR->hide();
ui->checkVARLEN->hide();
init(); init();
} }
@@ -34,16 +29,6 @@ void CounterVarSet::init()
void CounterVarSet::buttonClickedSlot() void CounterVarSet::buttonClickedSlot()
{ {
// 编辑
// if (editFlag) {
// m_textEdit->clear();
// on_buttonInsertVari_pressed();
// applyUIPara();
// emit sig_updateSelectedCounter();
// editFlag = false;
// return;
// }
// 添加 // 添加
QPushButton* btn = qobject_cast<QPushButton*>(sender()); QPushButton* btn = qobject_cast<QPushButton*>(sender());
if (btn == ui->checkBtn) if (btn == ui->checkBtn)
@@ -61,8 +46,6 @@ CounterViewModel CounterVarSet::getCounterConfig()
unsigned char splitMode = 0; unsigned char splitMode = 0;
getValue(&viewModel.counterType, &viewModel.digitalNum, &splitMode); getValue(&viewModel.counterType, &viewModel.digitalNum, &splitMode);
viewModel.letterSpace = ui->letterSpaceSpinBox->value(); viewModel.letterSpace = ui->letterSpaceSpinBox->value();
viewModel.charWidth = ui->charWidthSpinBox->value();
viewModel.enbCustomCharWidth = ui->enbCharWidthSpinBox->isChecked();
applyUIPara(); applyUIPara();
@@ -78,8 +61,6 @@ void CounterVarSet::setCounterConfig(CounterViewModel viewModel)
ui->radioButtonVar2->setChecked(viewModel.counterType == COUNTER_TYPE_2 ? true : false); ui->radioButtonVar2->setChecked(viewModel.counterType == COUNTER_TYPE_2 ? true : false);
ui->tabWidget->setCurrentIndex(viewModel.counterType == COUNTER_TYPE_1 ? 1 : 2); ui->tabWidget->setCurrentIndex(viewModel.counterType == COUNTER_TYPE_1 ? 1 : 2);
ui->letterSpaceSpinBox->setValue(viewModel.letterSpace); ui->letterSpaceSpinBox->setValue(viewModel.letterSpace);
ui->charWidthSpinBox->setValue(viewModel.charWidth);
ui->enbCharWidthSpinBox->setChecked(viewModel.enbCustomCharWidth);
updateSysParaToUI(); updateSysParaToUI();
} }
@@ -111,17 +92,12 @@ void CounterVarSet::applyUIPara()
m_vm.cnt1Settings.startValue = ui->spinBoxCnt1StartValue->value(); m_vm.cnt1Settings.startValue = ui->spinBoxCnt1StartValue->value();
m_vm.cnt1Settings.stepValue = ui->spinBoxCnt1StepValue->value(); m_vm.cnt1Settings.stepValue = ui->spinBoxCnt1StepValue->value();
m_vm.cnt1Settings.currValue = ui->spinBoxCnt1CurrValue->value(); m_vm.cnt1Settings.currValue = ui->spinBoxCnt1CurrValue->value();
m_vm.cnt1Settings.editCurrValue = ui->checkBoxResetCnt1CurrValue->isChecked();
m_vm.cnt2Settings.endValue = ui->spinBoxCnt2EndValue->value(); m_vm.cnt2Settings.endValue = ui->spinBoxCnt2EndValue->value();
m_vm.cnt2Settings.repeatValue = ui->spinBoxCnt2RepeateCnt->value(); m_vm.cnt2Settings.repeatValue = ui->spinBoxCnt2RepeateCnt->value();
m_vm.cnt2Settings.startValue = ui->spinBoxCnt2StartValue->value(); m_vm.cnt2Settings.startValue = ui->spinBoxCnt2StartValue->value();
m_vm.cnt2Settings.stepValue = ui->spinBoxCnt2StepValue->value(); m_vm.cnt2Settings.stepValue = ui->spinBoxCnt2StepValue->value();
m_vm.cnt2Settings.currValue = ui->spinBoxCnt2CurrValue->value(); m_vm.cnt2Settings.currValue = ui->spinBoxCnt2CurrValue->value();
m_vm.cnt2Settings.editCurrValue = ui->checkBoxResetCnt2CurrValue->isChecked();
ui->checkBoxResetCnt1CurrValue->setChecked(false);
ui->checkBoxResetCnt2CurrValue->setChecked(false);
} }
void CounterVarSet::updateSysParaToUI() void CounterVarSet::updateSysParaToUI()
@@ -137,16 +113,6 @@ void CounterVarSet::updateSysParaToUI()
ui->spinBoxCnt2StartValue->setValue(m_vm.cnt2Settings.startValue); ui->spinBoxCnt2StartValue->setValue(m_vm.cnt2Settings.startValue);
ui->spinBoxCnt2StepValue->setValue(m_vm.cnt2Settings.stepValue); ui->spinBoxCnt2StepValue->setValue(m_vm.cnt2Settings.stepValue);
ui->spinBoxCnt2CurrValue->setValue(m_vm.cnt2Settings.currValue); ui->spinBoxCnt2CurrValue->setValue(m_vm.cnt2Settings.currValue);
// 电眼触发计数器动作 选择
// ui->eleCNT1IncEn->setChecked( (sysPara->para.eleEyeClearCntInSynMode & 0x10)?1:0);
// ui->radCNT1ResetEn->setChecked( (sysPara->para.eleEyeClearCntInSynMode & 0x10)?0:1);
// ui->eleCNT2IncEn->setChecked( (sysPara->para.eleEyeClearCntInSynMode & 0x20)?1:0);
// ui->radCNT2ResetEn->setChecked( (sysPara->para.eleEyeClearCntInSynMode & 0x20)?0:1);
ui->checkBoxResetCnt1CurrValue->setChecked(false);
ui->checkBoxResetCnt2CurrValue->setChecked(false);
} }
void CounterVarSet::applyStyleSheet() void CounterVarSet::applyStyleSheet()
@@ -349,27 +315,3 @@ void CounterVarSet::applyStyleSheet()
this->setStyleSheet(styleSheet); this->setStyleSheet(styleSheet);
} }
void CounterVarSet::on_checkBoxResetCnt1CurrValue_released()
{
bool checked = ui->checkBoxResetCnt1CurrValue->isChecked();
ui->spinBoxCnt1CurrValue->setEnabled(checked);
}
void CounterVarSet::on_checkBoxResetCnt2CurrValue_released()
{
bool checked = ui->checkBoxResetCnt2CurrValue->isChecked();
ui->spinBoxCnt2CurrValue->setEnabled(checked);
}
void CounterVarSet::on_pushOnlyCNT1Clear_pressed()
{
// 转由主界面实现清零 byons@2026年4月25日
// sysPara->devOp->clearProductCnt(1<<2); // 计数器1单独清零
}
void CounterVarSet::on_pushOnlyCNT2Clear_pressed()
{
// sysPara->devOp->clearProductCnt(1<<3);// 计数器2单独清零
}
+2 -8
View File
@@ -10,6 +10,8 @@ namespace Ui {
class CounterVarSet; class CounterVarSet;
} }
class CounterEditor;
class CounterVarSet : public QWidget class CounterVarSet : public QWidget
{ {
Q_OBJECT Q_OBJECT
@@ -40,14 +42,6 @@ signals:
private slots: private slots:
void buttonClickedSlot(); void buttonClickedSlot();
void on_checkBoxResetCnt1CurrValue_released();
void on_checkBoxResetCnt2CurrValue_released();
void on_pushOnlyCNT1Clear_pressed();
void on_pushOnlyCNT2Clear_pressed();
private: private:
Ui::CounterVarSet *ui; Ui::CounterVarSet *ui;
+5
View File
@@ -3228,6 +3228,11 @@ void DevOp::writeFpgaCalandar(bool Enable){
step = 1; step = 1;
step = step < 0?(100000000 + step):step; step = step < 0?(100000000 + step):step;
sysPara->para.calandar_and_dat.cnt2Step = QString::number(step).toUInt(0,16); sysPara->para.calandar_and_dat.cnt2Step = QString::number(step).toUInt(0,16);
sysPara->status.cnt3CurrentValueInitDoneFlag = true;
sysPara->status.cnt2CurrentValueInitDoneFlag = true;
sysPara->status.cnt1CurrentValueInitDoneFlag = true;
// 与vx5相反,调换过值位置,比如0:4改为4:0 // 与vx5相反,调换过值位置,比如0:4改为4:0
sysPara->para.calandar_and_dat.cntCurrValueInitEnable = sysPara->para.calandar_and_dat.cntCurrValueInitEnable =
(sysPara->status.cnt3CurrentValueInitDoneFlag?4:0)+ (sysPara->status.cnt3CurrentValueInitDoneFlag?4:0)+
+18 -7
View File
@@ -298,8 +298,24 @@ void InkJetPrinter::showEvent(QShowEvent *e)
QWidget::showEvent(e); QWidget::showEvent(e);
if(firstShow) { if(firstShow) {
loadLastWorkAndPreparePrint();
firstShow = false; firstShow = false;
static QTimer* fpgaReadyTimer = new QTimer(this);
fpgaReadyTimer->setInterval(1000);
connect(fpgaReadyTimer, &QTimer::timeout, this, [this](){
if(sysPara->status.build_dat.builTime != 0) {
loadLastWorkAndPreparePrint();
fpgaReadyTimer->stop();
fpgaReadyTimer->deleteLater();
fpgaReadyTimer = nullptr;
}
else {
qDebug() << "FPGA not connected yet.";
}
});
fpgaReadyTimer->start();
} }
} }
@@ -1011,7 +1027,7 @@ void InkJetPrinter::timerHandler(void){
arg((MAX_SELF_CHECK_CNT - sysPara->status.selfCheckCnt)/100)); arg((MAX_SELF_CHECK_CNT - sysPara->status.selfCheckCnt)/100));
} }
#ifdef QT_DEBUG #ifdef QT_DEBUG
if(sysPara->status.selfCheckCnt >= 1500) // 测试自检改为15s if(sysPara->status.selfCheckCnt >= 500) // 测试自检改为15s
#else #else
if(sysPara->status.selfCheckCnt >= MAX_SELF_CHECK_CNT) if(sysPara->status.selfCheckCnt >= MAX_SELF_CHECK_CNT)
#endif #endif
@@ -2933,11 +2949,6 @@ bool InkJetPrinter::loadWorkFileAndPreparePrint(const QString &filename)
PrintSettingModel::applyToSysPara(model, sysPara); PrintSettingModel::applyToSysPara(model, sysPara);
// 应用完数据之后,将当前值编辑标志位清除,避免下次读取时为 true
model.cnt1Settings.editCurrValue = false;
model.cnt2Settings.editCurrValue = false;
PicSceneLoader::saveSceneToXmlFile(filename, scene, &model);
ret = m_MainWidget->generatePrintContent(scene); ret = m_MainWidget->generatePrintContent(scene);
if(!ret) { if(!ret) {
LogInfo::setRunStatusText(QString("Failed to generate print content from work file: %1").arg(filename)); LogInfo::setRunStatusText(QString("Failed to generate print content from work file: %1").arg(filename));
+3 -3
View File
@@ -219,9 +219,9 @@ void PrintTextDisplay::paintEvent(QPaintEvent *event){
vars_t *p_var = &sysPara->status.vars[i]; vars_t *p_var = &sysPara->status.vars[i];
int val = p_var->currVal; int val = p_var->currVal;
#ifdef QT_DEBUG // #ifdef QT_DEBUG
val = 123078; // val = 123078;
#endif // #endif
int x = p_var->startColPos; int x = p_var->startColPos;
int y = p_var->startRowPos; int y = p_var->startRowPos;
int rowDiff = p_var->endRowPos - p_var->startRowPos; int rowDiff = p_var->endRowPos - p_var->startRowPos;
-8
View File
@@ -755,7 +755,6 @@ void PrintSettingModel::loadFromXml(PrintSettingModel& model, const QXmlStreamAt
model.cnt1Settings.repeatValue = readIntAttrOrDefault("cnt1RepeatValue", model.cnt1Settings.repeatValue); model.cnt1Settings.repeatValue = readIntAttrOrDefault("cnt1RepeatValue", model.cnt1Settings.repeatValue);
model.cnt1Settings.stepValue = readIntAttrOrDefault("cnt1StepValue", model.cnt1Settings.stepValue); model.cnt1Settings.stepValue = readIntAttrOrDefault("cnt1StepValue", model.cnt1Settings.stepValue);
model.cnt1Settings.currValue = readIntAttrOrDefault("cnt1CurrValue", model.cnt1Settings.currValue); model.cnt1Settings.currValue = readIntAttrOrDefault("cnt1CurrValue", model.cnt1Settings.currValue);
model.cnt1Settings.editCurrValue = readBoolAttrOrDefault("cnt1EditCurrValue", model.cnt1Settings.editCurrValue);
model.cnt1Settings.eleEyeIncEn = readBoolAttrOrDefault("cnt1EleEyeIncEn", model.cnt1Settings.eleEyeIncEn); model.cnt1Settings.eleEyeIncEn = readBoolAttrOrDefault("cnt1EleEyeIncEn", model.cnt1Settings.eleEyeIncEn);
model.cnt2Settings.startValue = readIntAttrOrDefault("cnt2StartValue", model.cnt2Settings.startValue); model.cnt2Settings.startValue = readIntAttrOrDefault("cnt2StartValue", model.cnt2Settings.startValue);
@@ -763,7 +762,6 @@ void PrintSettingModel::loadFromXml(PrintSettingModel& model, const QXmlStreamAt
model.cnt2Settings.repeatValue = readIntAttrOrDefault("cnt2RepeatValue", model.cnt2Settings.repeatValue); model.cnt2Settings.repeatValue = readIntAttrOrDefault("cnt2RepeatValue", model.cnt2Settings.repeatValue);
model.cnt2Settings.stepValue = readIntAttrOrDefault("cnt2StepValue", model.cnt2Settings.stepValue); model.cnt2Settings.stepValue = readIntAttrOrDefault("cnt2StepValue", model.cnt2Settings.stepValue);
model.cnt2Settings.currValue = readIntAttrOrDefault("cnt2CurrValue", model.cnt2Settings.currValue); model.cnt2Settings.currValue = readIntAttrOrDefault("cnt2CurrValue", model.cnt2Settings.currValue);
model.cnt2Settings.editCurrValue = readBoolAttrOrDefault("cnt2EditCurrValue", model.cnt2Settings.editCurrValue);
model.cnt2Settings.eleEyeIncEn = readBoolAttrOrDefault("cnt2EleEyeIncEn", model.cnt2Settings.eleEyeIncEn); model.cnt2Settings.eleEyeIncEn = readBoolAttrOrDefault("cnt2EleEyeIncEn", model.cnt2Settings.eleEyeIncEn);
} }
@@ -798,7 +796,6 @@ void PrintSettingModel::saveToXml(const PrintSettingModel& model, QXmlStreamWrit
writer.writeAttribute("cnt1RepeatValue", QString::number(model.cnt1Settings.repeatValue)); writer.writeAttribute("cnt1RepeatValue", QString::number(model.cnt1Settings.repeatValue));
writer.writeAttribute("cnt1StepValue", QString::number(model.cnt1Settings.stepValue)); writer.writeAttribute("cnt1StepValue", QString::number(model.cnt1Settings.stepValue));
writer.writeAttribute("cnt1CurrValue", QString::number(model.cnt1Settings.currValue)); writer.writeAttribute("cnt1CurrValue", QString::number(model.cnt1Settings.currValue));
writer.writeAttribute("cnt1EditCurrValue", QString::number(model.cnt1Settings.editCurrValue));
writer.writeAttribute("cnt1EleEyeIncEn", QString::number(model.cnt1Settings.eleEyeIncEn)); writer.writeAttribute("cnt1EleEyeIncEn", QString::number(model.cnt1Settings.eleEyeIncEn));
writer.writeAttribute("cnt2StartValue", QString::number(model.cnt2Settings.startValue)); writer.writeAttribute("cnt2StartValue", QString::number(model.cnt2Settings.startValue));
@@ -806,7 +803,6 @@ void PrintSettingModel::saveToXml(const PrintSettingModel& model, QXmlStreamWrit
writer.writeAttribute("cnt2RepeatValue", QString::number(model.cnt2Settings.repeatValue)); writer.writeAttribute("cnt2RepeatValue", QString::number(model.cnt2Settings.repeatValue));
writer.writeAttribute("cnt2StepValue", QString::number(model.cnt2Settings.stepValue)); writer.writeAttribute("cnt2StepValue", QString::number(model.cnt2Settings.stepValue));
writer.writeAttribute("cnt2CurrValue", QString::number(model.cnt2Settings.currValue)); writer.writeAttribute("cnt2CurrValue", QString::number(model.cnt2Settings.currValue));
writer.writeAttribute("cnt2EditCurrValue", QString::number(model.cnt2Settings.editCurrValue));
writer.writeAttribute("cnt2EleEyeIncEn", QString::number(model.cnt2Settings.eleEyeIncEn)); writer.writeAttribute("cnt2EleEyeIncEn", QString::number(model.cnt2Settings.eleEyeIncEn));
} }
@@ -883,14 +879,12 @@ void PrintSettingModel::applyToSysPara(const PrintSettingModel &model, SysPara *
sysPara->para.cnt1StepValue = model.cnt1Settings.stepValue; sysPara->para.cnt1StepValue = model.cnt1Settings.stepValue;
sysPara->para.cnt1RepeateValue = model.cnt1Settings.repeatValue; sysPara->para.cnt1RepeateValue = model.cnt1Settings.repeatValue;
sysPara->para.cnt1CurrValue = model.cnt1Settings.currValue; sysPara->para.cnt1CurrValue = model.cnt1Settings.currValue;
sysPara->status.cnt1CurrentValueInitDoneFlag = model.cnt1Settings.editCurrValue;
sysPara->para.cnt2EndValue = model.cnt2Settings.endValue; sysPara->para.cnt2EndValue = model.cnt2Settings.endValue;
sysPara->para.cnt2StartValue = model.cnt2Settings.startValue; sysPara->para.cnt2StartValue = model.cnt2Settings.startValue;
sysPara->para.cnt2StepValue = model.cnt2Settings.stepValue; sysPara->para.cnt2StepValue = model.cnt2Settings.stepValue;
sysPara->para.cnt2RepeateValue = model.cnt2Settings.repeatValue; sysPara->para.cnt2RepeateValue = model.cnt2Settings.repeatValue;
sysPara->para.cnt2CurrValue = model.cnt2Settings.currValue; sysPara->para.cnt2CurrValue = model.cnt2Settings.currValue;
sysPara->status.cnt2CurrentValueInitDoneFlag = model.cnt2Settings.editCurrValue;
} }
PrintSettingModel PrintSettingModel::fromSysPara(SysPara *sysPara) PrintSettingModel PrintSettingModel::fromSysPara(SysPara *sysPara)
@@ -947,14 +941,12 @@ PrintSettingModel PrintSettingModel::fromSysPara(SysPara *sysPara)
model.cnt1Settings.repeatValue = sysPara->para.cnt1RepeateValue; model.cnt1Settings.repeatValue = sysPara->para.cnt1RepeateValue;
model.cnt1Settings.stepValue = sysPara->para.cnt1StepValue; model.cnt1Settings.stepValue = sysPara->para.cnt1StepValue;
model.cnt1Settings.currValue = sysPara->para.cnt1CurrValue; model.cnt1Settings.currValue = sysPara->para.cnt1CurrValue;
model.cnt1Settings.editCurrValue = sysPara->status.cnt1CurrentValueInitDoneFlag;
model.cnt2Settings.startValue = sysPara->para.cnt2StartValue; model.cnt2Settings.startValue = sysPara->para.cnt2StartValue;
model.cnt2Settings.endValue = sysPara->para.cnt2EndValue; model.cnt2Settings.endValue = sysPara->para.cnt2EndValue;
model.cnt2Settings.repeatValue = sysPara->para.cnt2RepeateValue; model.cnt2Settings.repeatValue = sysPara->para.cnt2RepeateValue;
model.cnt2Settings.stepValue = sysPara->para.cnt2StepValue; model.cnt2Settings.stepValue = sysPara->para.cnt2StepValue;
model.cnt2Settings.currValue = sysPara->para.cnt2CurrValue; model.cnt2Settings.currValue = sysPara->para.cnt2CurrValue;
model.cnt2Settings.editCurrValue = sysPara->status.cnt2CurrentValueInitDoneFlag;
return model; return model;
} }
-1
View File
@@ -104,7 +104,6 @@ void PrinterStateManager::requestTransition(PrinterEvent event)
qDebug() << "Request event:" << static_cast<int>(event) qDebug() << "Request event:" << static_cast<int>(event)
<< "Current:" << stateName(); << "Current:" << stateName();
m_currentState = PrinterState::READY;
Transition* trans = findTransition(event); Transition* trans = findTransition(event);
if (!trans) { if (!trans) {
qDebug() << "Invalid transition, ignored"; qDebug() << "Invalid transition, ignored";
+1 -1
View File
@@ -1,6 +1,6 @@
#ifndef PRINTERSTATEMANAGER_H #ifndef PRINTERSTATEMANAGER_H
#define PRINTERSTATEMANAGER_H #define PRINTERSTATEMANAGER_H
#pragma once
#include <QObject> #include <QObject>
#include <QVector> #include <QVector>
#include "SysPara.h" #include "SysPara.h"
+94 -475
View File
@@ -293,6 +293,9 @@
<height>50</height> <height>50</height>
</size> </size>
</property> </property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="minimum"> <property name="minimum">
<number>1</number> <number>1</number>
</property> </property>
@@ -321,6 +324,9 @@
<height>50</height> <height>50</height>
</size> </size>
</property> </property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="maximum"> <property name="maximum">
<number>99999999</number> <number>99999999</number>
</property> </property>
@@ -328,65 +334,9 @@
<number>9999</number> <number>9999</number>
</property> </property>
</widget> </widget>
<widget class="QPushButton" name="pushButtonVAR">
<property name="geometry">
<rect>
<x>263</x>
<y>197</y>
<width>100</width>
<height>50</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>50</height>
</size>
</property>
<property name="text">
<string>可变长度</string>
</property>
</widget>
<widget class="QCheckBox" name="checkVARLEN">
<property name="geometry">
<rect>
<x>369</x>
<y>197</y>
<width>100</width>
<height>50</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>50</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QSpinBox" name="spinBoxCnt1CurrValue"> <widget class="QSpinBox" name="spinBoxCnt1CurrValue">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>true</bool>
</property> </property>
<property name="geometry"> <property name="geometry">
<rect> <rect>
@@ -408,6 +358,9 @@
<height>50</height> <height>50</height>
</size> </size>
</property> </property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="minimum"> <property name="minimum">
<number>0</number> <number>0</number>
</property> </property>
@@ -455,31 +408,6 @@
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="label_35">
<property name="geometry">
<rect>
<x>51</x>
<y>197</y>
<width>100</width>
<height>50</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>50</height>
</size>
</property>
<property name="text">
<string>小数点位数</string>
</property>
</widget>
<widget class="QSpinBox" name="spinBoxCnt1StartValue"> <widget class="QSpinBox" name="spinBoxCnt1StartValue">
<property name="geometry"> <property name="geometry">
<rect> <rect>
@@ -501,6 +429,9 @@
<height>50</height> <height>50</height>
</size> </size>
</property> </property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="maximum"> <property name="maximum">
<number>9999999</number> <number>9999999</number>
</property> </property>
@@ -628,6 +559,9 @@
<property name="inputMethodHints"> <property name="inputMethodHints">
<set>Qt::ImhDigitsOnly</set> <set>Qt::ImhDigitsOnly</set>
</property> </property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="minimum"> <property name="minimum">
<number>-49999999</number> <number>-49999999</number>
</property> </property>
@@ -638,17 +572,17 @@
<number>1</number> <number>1</number>
</property> </property>
</widget> </widget>
<widget class="QSpinBox" name="spinBoxdecimalpointnum"> <widget class="QLabel" name="label_28">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>156</x> <x>50</x>
<y>200</y> <y>140</y>
<width>100</width> <width>100</width>
<height>50</height> <height>50</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum"> <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@@ -665,148 +599,52 @@
<height>50</height> <height>50</height>
</size> </size>
</property> </property>
<property name="maximum">
<number>3</number>
</property>
</widget>
<widget class="QWidget" name="horizontalWidget" native="true">
<property name="geometry">
<rect>
<x>270</x>
<y>139</y>
<width>100</width>
<height>50</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>50</height>
</size>
</property>
<property name="layoutDirection"> <property name="layoutDirection">
<enum>Qt::LeftToRight</enum> <enum>Qt::LeftToRight</enum>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>37</width>
<height>17</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="checkBoxResetCnt1CurrValue">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>当前值: </string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="widget" native="true">
<property name="geometry">
<rect>
<x>56</x>
<y>139</y>
<width>100</width>
<height>50</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>50</height>
</size>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="eleCNT1IncEn">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text"> <property name="text">
<string>增量值: </string> <string>增量值: </string>
</property> </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> <widget class="QLabel" name="label_14">
</layout> <property name="geometry">
<rect>
<x>260</x>
<y>140</y>
<width>100</width>
<height>50</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>50</height>
</size>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>当前值: </string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</widget> </widget>
<widget class="QWidget" name="tab_3"> <widget class="QWidget" name="tab_3">
@@ -846,6 +684,9 @@
<property name="styleSheet"> <property name="styleSheet">
<string notr="true"/> <string notr="true"/>
</property> </property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="maximum"> <property name="maximum">
<number>9999999</number> <number>9999999</number>
</property> </property>
@@ -917,6 +758,9 @@
<height>50</height> <height>50</height>
</size> </size>
</property> </property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="minimum"> <property name="minimum">
<number>1</number> <number>1</number>
</property> </property>
@@ -951,6 +795,9 @@
<height>50</height> <height>50</height>
</size> </size>
</property> </property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="minimum"> <property name="minimum">
<number>-49999999</number> <number>-49999999</number>
</property> </property>
@@ -1070,6 +917,9 @@
<height>50</height> <height>50</height>
</size> </size>
</property> </property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="maximum"> <property name="maximum">
<number>999999</number> <number>999999</number>
</property> </property>
@@ -1116,7 +966,7 @@
</widget> </widget>
<widget class="QSpinBox" name="spinBoxCnt2CurrValue"> <widget class="QSpinBox" name="spinBoxCnt2CurrValue">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>true</bool>
</property> </property>
<property name="geometry"> <property name="geometry">
<rect> <rect>
@@ -1144,6 +994,9 @@
<height>50</height> <height>50</height>
</size> </size>
</property> </property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="minimum"> <property name="minimum">
<number>0</number> <number>0</number>
</property> </property>
@@ -1154,43 +1007,15 @@
<number>1</number> <number>1</number>
</property> </property>
</widget> </widget>
<widget class="QWidget" name="widget_2" native="true"> <widget class="QLabel" name="label_12">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>270</x> <x>260</x>
<y>139</y> <y>140</y>
<width>100</width> <width>100</width>
<height>50</height> <height>50</height>
</rect> </rect>
</property> </property>
<property name="minimumSize">
<size>
<width>100</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>50</height>
</size>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="checkBoxResetCnt2CurrValue">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@@ -1199,8 +1024,8 @@
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>100</width>
<height>32</height> <height>50</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
@@ -1209,56 +1034,25 @@
<height>50</height> <height>50</height>
</size> </size>
</property> </property>
<property name="styleSheet"> <property name="layoutDirection">
<string notr="true">QRadioButton::indicator { <enum>Qt::LeftToRight</enum>
width: 25px;
height: 25px;
}</string>
</property> </property>
<property name="text"> <property name="text">
<string>当前值: </string> <string>当前值: </string>
</property> </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> <widget class="QLabel" name="label_26">
</layout>
</widget>
<widget class="QWidget" name="widget_3" native="true">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>56</x> <x>50</x>
<y>139</y> <y>140</y>
<width>100</width> <width>100</width>
<height>50</height> <height>50</height>
</rect> </rect>
</property> </property>
<property name="minimumSize">
<size>
<width>100</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>50</height>
</size>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>6</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="eleCNT2IncEn">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@@ -1267,8 +1061,8 @@ height: 25px;
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>100</width>
<height>32</height> <height>50</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
@@ -1277,93 +1071,14 @@ height: 25px;
<height>50</height> <height>50</height>
</size> </size>
</property> </property>
<property name="styleSheet"> <property name="layoutDirection">
<string notr="true"/> <enum>Qt::LeftToRight</enum>
</property> </property>
<property name="text"> <property name="text">
<string>增量值: </string> <string>增量值: </string>
</property> </property>
</widget> <property name="alignment">
</item> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</layout>
</widget>
</widget>
<widget class="QWidget" name="extraTab">
<attribute name="title">
<string>额外设置</string>
</attribute>
<widget class="QSpinBox" name="charWidthSpinBox">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>280</x>
<y>130</y>
<width>101</width>
<height>31</height>
</rect>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
</widget>
<widget class="QPushButton" name="pushButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>390</x>
<y>130</y>
<width>31</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>←</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_2">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>430</x>
<y>130</y>
<width>31</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>→</string>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>40</x>
<y>30</y>
<width>661</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string>如果预览与打印显示不正确,调整此设置可能恢复。</string>
</property>
</widget>
<widget class="QCheckBox" name="enbCharWidthSpinBox">
<property name="geometry">
<rect>
<x>280</x>
<y>90</y>
<width>171</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>自定义字符宽度</string>
</property> </property>
</widget> </widget>
</widget> </widget>
@@ -1397,38 +1112,6 @@ height: 25px;
</widget> </widget>
<resources/> <resources/>
<connections> <connections>
<connection>
<sender>pushButton</sender>
<signal>clicked()</signal>
<receiver>charWidthSpinBox</receiver>
<slot>stepDown()</slot>
<hints>
<hint type="sourcelabel">
<x>430</x>
<y>175</y>
</hint>
<hint type="destinationlabel">
<x>336</x>
<y>176</y>
</hint>
</hints>
</connection>
<connection>
<sender>pushButton_2</sender>
<signal>clicked()</signal>
<receiver>charWidthSpinBox</receiver>
<slot>stepUp()</slot>
<hints>
<hint type="sourcelabel">
<x>472</x>
<y>175</y>
</hint>
<hint type="destinationlabel">
<x>336</x>
<y>174</y>
</hint>
</hints>
</connection>
<connection> <connection>
<sender>pushButton_3</sender> <sender>pushButton_3</sender>
<signal>clicked()</signal> <signal>clicked()</signal>
@@ -1461,69 +1144,5 @@ height: 25px;
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection>
<sender>enbCharWidthSpinBox</sender>
<signal>clicked(bool)</signal>
<receiver>charWidthSpinBox</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>337</x>
<y>135</y>
</hint>
<hint type="destinationlabel">
<x>347</x>
<y>177</y>
</hint>
</hints>
</connection>
<connection>
<sender>enbCharWidthSpinBox</sender>
<signal>clicked(bool)</signal>
<receiver>pushButton</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>392</x>
<y>134</y>
</hint>
<hint type="destinationlabel">
<x>429</x>
<y>167</y>
</hint>
</hints>
</connection>
<connection>
<sender>enbCharWidthSpinBox</sender>
<signal>clicked(bool)</signal>
<receiver>pushButton_2</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>409</x>
<y>130</y>
</hint>
<hint type="destinationlabel">
<x>461</x>
<y>183</y>
</hint>
</hints>
</connection>
<connection>
<sender>checkBoxResetCnt1CurrValue</sender>
<signal>toggled(bool)</signal>
<receiver>spinBoxCnt1CurrValue</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>335</x>
<y>198</y>
</hint>
<hint type="destinationlabel">
<x>453</x>
<y>198</y>
</hint>
</hints>
</connection>
</connections> </connections>
</ui> </ui>
+11 -9
View File
@@ -199,7 +199,7 @@ bool MainWidget::generatePrintContent(PicScene *scene)
this->pPicScene = scene; this->pPicScene = scene;
onPreviewScene(); onPreviewScene();
// SendPrintDataToFpga(0); SendPrintDataToFpga(0);
return true; return true;
} }
@@ -946,11 +946,6 @@ void MainWidget::updateTotalCnt(int en)
void MainWidget::on_m_StartBtn_clicked() void MainWidget::on_m_StartBtn_clicked()
{ {
if(sysPara){ if(sysPara){
bool MaxCol4000;
if(sysPara->status.flagOfNo67FPGA)
MaxCol4000 = true;
else
MaxCol4000 = false;
test_flag = 0; test_flag = 0;
if (!checkTriggerMode()) return; if (!checkTriggerMode()) return;
@@ -958,11 +953,13 @@ void MainWidget::on_m_StartBtn_clicked()
// 打印状态交给状态机修改 // 打印状态交给状态机修改
// sysPara->status.isPrinting=false; // sysPara->status.isPrinting=false;
auto mgr = PrinterStateManager::instance(); auto mgr = PrinterStateManager::instance();
#if !defined(FPGA_TEST) && !defined(QT_DEBUG)
if (mgr && mgr->canStopPrint()) { if (mgr && mgr->canStopPrint()) {
mgr->requestTransition(PrinterEvent::StopPrint); mgr->requestTransition(PrinterEvent::StopPrint);
} else {return;} } else {return;}
#endif
SendPrintDataToFpga(0); // 0--正常打印,1--打印交替部分信息1; 2--打印交替部分信息2, // SendPrintDataToFpga(0); // 0--正常打印,1--打印交替部分信息1; 2--打印交替部分信息2,
/*-------------------------------------------------------------------*/ /*-------------------------------------------------------------------*/
sysPara->status.lastSynColDelay = -1; //目的是为了清空原来的数据 sysPara->status.lastSynColDelay = -1; //目的是为了清空原来的数据
@@ -999,11 +996,13 @@ void MainWidget::on_m_StopBtn_clicked()
} }
// sysPara->status.isPrinting=false;// 打印状态交给状态机修改 // sysPara->status.isPrinting=false;// 打印状态交给状态机修改
auto mgr = PrinterStateManager::instance(); auto mgr = PrinterStateManager::instance();
#if !defined(FPGA_TEST) && !defined(QT_DEBUG)
if (mgr && mgr->canStopPrint()) { if (mgr && mgr->canStopPrint()) {
mgr->requestTransition(PrinterEvent::StopPrint); mgr->requestTransition(PrinterEvent::StopPrint);
} else { } else {
return; return;
} }
#endif
sysPara->devOp->printCtrl2(1); sysPara->devOp->printCtrl2(1);
sysPara->devOp->printCtrl( PRINT_CTRL_STOP);//:PRINT_CTRL_STOPSYNCNT sysPara->devOp->printCtrl( PRINT_CTRL_STOP);//:PRINT_CTRL_STOPSYNCNT
@@ -2373,8 +2372,6 @@ bool MainWidget::updatePhaseIndicatorLight(){
LogInfo::setRunStatusText(tr("相位故障,准备关机")); LogInfo::setRunStatusText(tr("相位故障,准备关机"));
setRunStatus(tr("相位故障,准备关机")); setRunStatus(tr("相位故障,准备关机"));
strTitle = tr("相位故障,准备关机"); strTitle = tr("相位故障,准备关机");
} }
} }
else if(sysPara->para.suspendAfterPhaseFault){ else if(sysPara->para.suspendAfterPhaseFault){
@@ -2531,6 +2528,11 @@ bool MainWidget::checkTriggerMode()
} }
#endif #endif
bool MaxCol4000;
if(sysPara->status.flagOfNo67FPGA)
MaxCol4000 = true;
else
MaxCol4000 = false;
if(sysPara->status.currPrintCol > (MaxCol4000?MAX_PRINT_COL_NUM_Normal:MAX_PRINT_COL_NUM_Wide)){ if(sysPara->status.currPrintCol > (MaxCol4000?MAX_PRINT_COL_NUM_Normal:MAX_PRINT_COL_NUM_Wide)){
QMessageBox::critical(0,tr("错误"),tr("当前总列数 %1 ,支持的总列数为 %2,请减少打印串的长度").arg(sysPara->status.currPrintCol).arg((MaxCol4000?MAX_PRINT_COL_NUM_Normal:MAX_PRINT_COL_NUM_Wide))); QMessageBox::critical(0,tr("错误"),tr("当前总列数 %1 ,支持的总列数为 %2,请减少打印串的长度").arg(sysPara->status.currPrintCol).arg((MaxCol4000?MAX_PRINT_COL_NUM_Normal:MAX_PRINT_COL_NUM_Wide)));
return false; return false;
-18
View File
@@ -8,9 +8,6 @@ CounterEditor::CounterEditor(QWidget *parent) :
{ {
ui->setupUi(this); ui->setupUi(this);
connect(ui->checkBoxResetCnt2CurrValue, &QCheckBox::toggled,
this, &CounterEditor::onEditCurrValueToggled);
connect(ui->cbBoxCounterType, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &CounterEditor::onCounterTypeChanged); connect(ui->cbBoxCounterType, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &CounterEditor::onCounterTypeChanged);
connect(ui->cbBoxDigitalNum, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &CounterEditor::onDigitalNumChanged); connect(ui->cbBoxDigitalNum, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &CounterEditor::onDigitalNumChanged);
@@ -20,9 +17,6 @@ CounterEditor::CounterEditor(QWidget *parent) :
connect(ui->spinBoxCnt2StepValue, QOverload<int>::of(&QSpinBox::valueChanged), this, [this](int) {fetchCounterConfigFromView();} ); connect(ui->spinBoxCnt2StepValue, QOverload<int>::of(&QSpinBox::valueChanged), this, [this](int) {fetchCounterConfigFromView();} );
connect(ui->spinBoxCnt2CurrValue, QOverload<int>::of(&QSpinBox::valueChanged), this, [this](int) {fetchCounterConfigFromView();} ); connect(ui->spinBoxCnt2CurrValue, QOverload<int>::of(&QSpinBox::valueChanged), this, [this](int) {fetchCounterConfigFromView();} );
connect(ui->checkBoxResetCnt2CurrValue, &QCheckBox::clicked, this, [this](bool) {fetchCounterConfigFromView();} );
connect(ui->eleCNT2IncEn, &QCheckBox::clicked, this, [this](bool) {fetchCounterConfigFromView();} );
setViewModel(m_vm); setViewModel(m_vm);
} }
@@ -63,15 +57,6 @@ void CounterEditor::setViewModel(CounterEditorVM vm)
ui->spinBoxCnt2CurrValue->setValue(cnt.currValue); ui->spinBoxCnt2CurrValue->setValue(cnt.currValue);
ui->spinBoxCnt2CurrValue->blockSignals(b); ui->spinBoxCnt2CurrValue->blockSignals(b);
b = ui->checkBoxResetCnt2CurrValue->blockSignals(true);
ui->checkBoxResetCnt2CurrValue->setChecked(cnt.editCurrValue);
ui->checkBoxResetCnt2CurrValue->blockSignals(b);
b = ui->eleCNT2IncEn->blockSignals(true);
ui->eleCNT2IncEn->setChecked(cnt.eleEyeIncEn);
ui->eleCNT2IncEn->blockSignals(b);
ui->spinBoxCnt2CurrValue->setEnabled(cnt.editCurrValue);
ui->labelCnt2CurrValue->setText(QString::number(cnt.currValue)); ui->labelCnt2CurrValue->setText(QString::number(cnt.currValue));
b = ui->cbBoxCounterType->blockSignals(true); b = ui->cbBoxCounterType->blockSignals(true);
@@ -124,8 +109,6 @@ void CounterEditor::fetchCounterConfigFromView()
cnt.repeatValue = ui->spinBoxCnt2RepeateCnt->value(); cnt.repeatValue = ui->spinBoxCnt2RepeateCnt->value();
cnt.stepValue = ui->spinBoxCnt2StepValue->value(); cnt.stepValue = ui->spinBoxCnt2StepValue->value();
cnt.currValue = ui->spinBoxCnt2CurrValue->value(); cnt.currValue = ui->spinBoxCnt2CurrValue->value();
cnt.editCurrValue = ui->checkBoxResetCnt2CurrValue->isChecked();
cnt.eleEyeIncEn = ui->eleCNT2IncEn->isChecked();
} }
/** /**
@@ -134,5 +117,4 @@ void CounterEditor::fetchCounterConfigFromView()
*/ */
void CounterEditor::onEditCurrValueToggled() void CounterEditor::onEditCurrValueToggled()
{ {
ui->spinBoxCnt2CurrValue->setEnabled(ui->checkBoxResetCnt2CurrValue->isChecked());
} }
-1
View File
@@ -24,7 +24,6 @@ struct CounterEditorVM {
int repeatValue = 1; int repeatValue = 1;
int stepValue = 1; int stepValue = 1;
int currValue = 1; int currValue = 1;
bool editCurrValue = false; // 对应 checkBoxResetCnt2CurrValue:勾选才允许重置/编辑当前值
bool eleEyeIncEn = false; // 对应 eleCNT2IncEn:电眼触发使计数器+1 bool eleEyeIncEn = false; // 对应 eleCNT2IncEn:电眼触发使计数器+1
}; };
+47 -148
View File
@@ -238,6 +238,9 @@
<property name="styleSheet"> <property name="styleSheet">
<string notr="true"/> <string notr="true"/>
</property> </property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="maximum"> <property name="maximum">
<number>9999999</number> <number>9999999</number>
</property> </property>
@@ -309,6 +312,9 @@
<height>50</height> <height>50</height>
</size> </size>
</property> </property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="minimum"> <property name="minimum">
<number>1</number> <number>1</number>
</property> </property>
@@ -343,6 +349,9 @@
<height>50</height> <height>50</height>
</size> </size>
</property> </property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="minimum"> <property name="minimum">
<number>-49999999</number> <number>-49999999</number>
</property> </property>
@@ -462,6 +471,9 @@
<height>50</height> <height>50</height>
</size> </size>
</property> </property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="maximum"> <property name="maximum">
<number>999999</number> <number>999999</number>
</property> </property>
@@ -536,6 +548,9 @@
<height>50</height> <height>50</height>
</size> </size>
</property> </property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="minimum"> <property name="minimum">
<number>0</number> <number>0</number>
</property> </property>
@@ -546,154 +561,6 @@
<number>1</number> <number>1</number>
</property> </property>
</widget> </widget>
<widget class="QWidget" name="widget_2" native="true">
<property name="geometry">
<rect>
<x>270</x>
<y>179</y>
<width>100</width>
<height>50</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>50</height>
</size>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="leftMargin">
<number>1</number>
</property>
<property name="topMargin">
<number>1</number>
</property>
<property name="rightMargin">
<number>1</number>
</property>
<property name="bottomMargin">
<number>1</number>
</property>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="checkBoxResetCnt2CurrValue">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>50</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">QRadioButton::indicator {
width: 25px;
height: 25px;
}</string>
</property>
<property name="text">
<string>当前值: </string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="widget_3" native="true">
<property name="geometry">
<rect>
<x>56</x>
<y>179</y>
<width>100</width>
<height>50</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="eleCNT2IncEn">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>50</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">QRadioButton::indicator {
width: 25px;
height: 25px;
}</string>
</property>
<property name="text">
<string>增量值: </string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="geometry"> <property name="geometry">
<rect> <rect>
@@ -790,6 +657,38 @@ height: 25px;
</property> </property>
</item> </item>
</widget> </widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>260</x>
<y>180</y>
<width>100</width>
<height>50</height>
</rect>
</property>
<property name="text">
<string>当前值: </string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>50</x>
<y>180</y>
<width>100</width>
<height>50</height>
</rect>
</property>
<property name="text">
<string>增量值: </string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</widget> </widget>
<resources/> <resources/>
<connections/> <connections/>
+36 -5
View File
@@ -4,6 +4,7 @@
#include <QFontMetrics> #include <QFontMetrics>
#include <QString> #include <QString>
#include <QHash> #include <QHash>
#include <QPainter>
QHash<QString, int> defCharWidthMap; QHash<QString, int> defCharWidthMap;
@@ -27,10 +28,10 @@ QVariant PicCounterItem::source()
void PicCounterItem::setSource(QVariant var) void PicCounterItem::setSource(QVariant var)
{ {
PicTextItem::setSource(var); PicTextItem::setSource(var);
setCounter(counterType(), digitalNum()); setCounter(counterType(), digitalNum(), m_displayNum);
} }
void PicCounterItem::setCounter(COUNTER_TYPE type, int digitalNum) void PicCounterItem::setCounter(COUNTER_TYPE type, int digitalNum, int displayNum)
{ {
if(type != COUNTER_TYPE_1 && type != COUNTER_TYPE_2) { if(type != COUNTER_TYPE_1 && type != COUNTER_TYPE_2) {
qWarning() << "Missing counter type: " << type; qWarning() << "Missing counter type: " << type;
@@ -63,9 +64,30 @@ void PicCounterItem::setCounter(COUNTER_TYPE type, int digitalNum)
int height = font.pixelSize(); int height = font.pixelSize();
width += letterSpace(); width += letterSpace();
// 计算像素长度最长的数字 0 - 9
int digital = 0;
int digitalWidth = 0;
for(int i = 0; i <= 9; ++i) {
auto w = fontMetrics.horizontalAdvance(QString::number(i));
if(w > digitalWidth) {
digitalWidth = w;
digital = i;
}
}
m_counterType = type; m_counterType = type;
m_digitalNum = qBound(1, digitalNum, 8); m_digitalNum = qBound(1, digitalNum, 8);
m_digitalImg = strToImage(QString("8").repeated(m_digitalNum)); m_digitalImg = strToImage(QString::number(digital).repeated(m_digitalNum));
m_displayNum = displayNum;
// 临时使用这种手法显示当前值吧
m_digitalImg.fill(0x00000000);
auto displayNumImage = strToImage(QString::number(displayNum).rightJustified(m_digitalNum, '0').right(m_digitalNum));
QPainter p;
p.begin(&m_digitalImg);
p.drawImage(QPoint(0, 0), displayNumImage);
p.end();
applyModify(); applyModify();
qInfo() << "Counter item set to " << type ; qInfo() << "Counter item set to " << type ;
@@ -84,7 +106,7 @@ int PicCounterItem::charWidth()
void PicCounterItem::setCharWidth(int width) void PicCounterItem::setCharWidth(int width)
{ {
m_charWidthMap[font().family()] = width; m_charWidthMap[font().family()] = width;
setCounter(counterType(), digitalNum()); setCounter(counterType(), digitalNum(), m_displayNum);
} }
QImage PicCounterItem::itemImage() QImage PicCounterItem::itemImage()
@@ -96,6 +118,7 @@ void PicCounterItem::setCustomAttrs(const QXmlStreamAttributes &attrs)
{ {
auto typeRef = attrs.value("counter_type"); auto typeRef = attrs.value("counter_type");
auto digitalNumRef = attrs.value("digital_num"); auto digitalNumRef = attrs.value("digital_num");
auto displayNumRef = attrs.value("display_num");
bool ok = false; bool ok = false;
int counterType = typeRef.toInt(&ok); int counterType = typeRef.toInt(&ok);
@@ -111,7 +134,14 @@ void PicCounterItem::setCustomAttrs(const QXmlStreamAttributes &attrs)
return; return;
} }
setCounter(static_cast<COUNTER_TYPE>(counterType), digitalNum); ok = false;
int displayNum = displayNumRef.toInt(&ok);
if(!ok || displayNum <= 0) {
qWarning() << "Invalied counter display number: " << displayNum;
return;
}
setCounter(static_cast<COUNTER_TYPE>(counterType), digitalNum, displayNum);
qInfo() << "Loaded attrs from xml: " << " counter type: " << counterType << ", digitalNum: " << digitalNum; qInfo() << "Loaded attrs from xml: " << " counter type: " << counterType << ", digitalNum: " << digitalNum;
} }
@@ -119,6 +149,7 @@ void PicCounterItem::saveCustomAttrs(QXmlStreamAttributes &attrs)
{ {
attrs.append("counter_type", QString::number(counterType())); attrs.append("counter_type", QString::number(counterType()));
attrs.append("digital_num", QString::number(digitalNum())); attrs.append("digital_num", QString::number(digitalNum()));
attrs.append("display_num", QString::number(m_displayNum));
qInfo() << "Set attrs to xml: " << " counter type: " << counterType() << ", digitalNum: " << digitalNum(); qInfo() << "Set attrs to xml: " << " counter type: " << counterType() << ", digitalNum: " << digitalNum();
} }
+2 -1
View File
@@ -13,7 +13,7 @@ public:
virtual QVariant source() override; virtual QVariant source() override;
virtual void setSource(QVariant var) override; virtual void setSource(QVariant var) override;
void setCounter(COUNTER_TYPE type, int digitalNum); void setCounter(COUNTER_TYPE type, int digitalNum, int displayNum);
COUNTER_TYPE counterType() const { return m_counterType; } COUNTER_TYPE counterType() const { return m_counterType; }
@@ -43,6 +43,7 @@ private:
int m_digitalNum; int m_digitalNum;
QImage m_digitalImg; QImage m_digitalImg;
QHash<QString, int> m_charWidthMap; QHash<QString, int> m_charWidthMap;
int m_displayNum = 0;
}; };
#endif // _PIC_COUNTER_ITEM_H_ #endif // _PIC_COUNTER_ITEM_H_
+14 -12
View File
@@ -191,7 +191,7 @@ QImage PicDateItem::itemImage()
return currImg; return currImg;
int width = qMax(currImg.width(), m_maxSize.width()); int width = qMax(currImg.width(), m_maxSize.width());
int height = qMax(currImg.height(), m_maxSize.height()); int height = currImg.height();
QImage img(width, height, QImage::Format_ARGB32); QImage img(width, height, QImage::Format_ARGB32);
img.fill(QColor(0,0,0,0).rgba()); img.fill(QColor(0,0,0,0).rgba());
@@ -206,17 +206,19 @@ QImage PicDateItem::itemImage()
QRectF PicDateItem::boundingRect() const QRectF PicDateItem::boundingRect() const
{ {
// 优先使用已经应用变换后的 m_itemImage(与 PicTextItem 保持一致) return PicTextItem::boundingRect();
if (!m_itemImage.isNull()) {
return QRectF(0, 0, m_itemImage.width(), m_itemImage.height());
}
// 否则基于缓存的最大像素尺寸和粗体倍数估算 // // 优先使用已经应用变换后的 m_itemImage(与 PicTextItem 保持一致)
int w = m_maxSize.width(); // if (!m_itemImage.isNull()) {
int h = m_maxSize.height(); // return QRectF(0, 0, m_itemImage.width(), m_itemImage.height());
if (w <= 0 || h <= 0) // }
return QGraphicsTextItem::boundingRect();
qreal bw = qreal(w) * qMax(1, m_boldMultiple); // // 否则基于缓存的最大像素尺寸和粗体倍数估算
return QRectF(0, 0, bw, qreal(h)); // int w = m_maxSize.width();
// int h = m_maxSize.height();
// if (w <= 0 || h <= 0)
// return QGraphicsTextItem::boundingRect();
// qreal bw = qreal(w) * qMax(1, m_boldMultiple);
// return QRectF(0, 0, bw, qreal(h));
} }
+14 -1
View File
@@ -104,7 +104,16 @@ QImage PicScheduleShiftItem::itemImage()
if(str.isEmpty()) { if(str.isEmpty()) {
return QImage(); return QImage();
} }
return strToImage(str); auto forceImg = strToImage(str);
QImage backgroundImg(m_maxSize.width(), forceImg.height(), QImage::Format_ARGB32);
backgroundImg.fill(0x00000000);
QPainter p;
p.begin(&backgroundImg);
p.drawImage(QPoint(0, 0), forceImg);
p.end();
return backgroundImg;
} }
QSize PicScheduleShiftItem::calcMaxSize() QSize PicScheduleShiftItem::calcMaxSize()
@@ -123,6 +132,10 @@ QSize PicScheduleShiftItem::calcMaxSize()
QRectF PicScheduleShiftItem::boundingRect() const QRectF PicScheduleShiftItem::boundingRect() const
{ {
auto r = PicTextItem::boundingRect();
r.setWidth(m_maxSize.width());
return r;
if (!m_itemImage.isNull()) { if (!m_itemImage.isNull()) {
return QRectF(0, 0, m_itemImage.width(), m_itemImage.height()); return QRectF(0, 0, m_itemImage.width(), m_itemImage.height());
} }
+25 -13
View File
@@ -447,6 +447,20 @@ void TestPrintWidget::openWorkFile(QString filePath){
m_printSetting->setModel(m_printSettingModel); m_printSetting->setModel(m_printSettingModel);
} }
for(auto item : pPicScene->items()) {
auto txtItem = dynamic_cast<PicTextItem*>(item);
if(!txtItem || txtItem->sourceType() != SourceType::COUNTER)
continue;
auto cntItem = dynamic_cast<PicCounterItem*>(item);
if(!cntItem)
continue;
auto currValue = cntItem->counterType() == COUNTER_TYPE_1 ?
m_printSettingModel.cnt1Settings.currValue : m_printSettingModel.cnt2Settings.currValue;
cntItem->setCounter(cntItem->counterType(), cntItem->digitalNum(), currValue);
}
qDebug() << "xmlfileName:" << xmlfileName; qDebug() << "xmlfileName:" << xmlfileName;
} }
@@ -553,7 +567,9 @@ void TestPrintWidget::pasteCopiedLayer()
if (dstCounter) { if (dstCounter) {
dstCounter->setCustomFont(m_copiedCounterFontFamily); dstCounter->setCustomFont(m_copiedCounterFontFamily);
dstCounter->setLetterSpace(m_copiedCounterLetterSpace); dstCounter->setLetterSpace(m_copiedCounterLetterSpace);
dstCounter->setCounter(static_cast<COUNTER_TYPE>(m_copiedCounterType), m_copiedCounterDigitalNum);
int displayNum = static_cast<COUNTER_TYPE>(m_copiedCounterType) == COUNTER_TYPE_1 ? m_printSettingModel.cnt1Settings.currValue : m_printSettingModel.cnt2Settings.currValue;
dstCounter->setCounter(static_cast<COUNTER_TYPE>(m_copiedCounterType), m_copiedCounterDigitalNum, displayNum);
} }
} }
@@ -780,14 +796,9 @@ void TestPrintWidget::onItemEditorAccepted()
{ {
if(!itemEditor || !itemEditor->currentItem()) return; if(!itemEditor || !itemEditor->currentItem()) return;
if(itemEditor->currentItem()->source() == SourceType::UNKNOWN) {
// Nothing....
}
else {
PicTextItem* textItem = itemEditor->currentItem(); PicTextItem* textItem = itemEditor->currentItem();
textItem->applyModify(); textItem->applyModify();
} }
}
void TestPrintWidget::onSceneFocusedItemPosChanged(QPoint p) void TestPrintWidget::onSceneFocusedItemPosChanged(QPoint p)
{ {
@@ -1069,8 +1080,9 @@ void TestPrintWidget::addCounterItem(CounterViewModel vm, QSharedPointer<QFont>
if(item->sourceType() == SourceType::COUNTER) { if(item->sourceType() == SourceType::COUNTER) {
auto counterItem = dynamic_cast<PicCounterItem*>(item); auto counterItem = dynamic_cast<PicCounterItem*>(item);
counterItem->setCounter(static_cast<COUNTER_TYPE>(vm.counterType), vm.digitalNum);
counterItem->setLetterSpace(int(font.letterSpacing())); counterItem->setLetterSpace(int(font.letterSpacing()));
int displayNum = static_cast<COUNTER_TYPE>(vm.counterType) == COUNTER_TYPE_1 ? vm.cnt1Settings.currValue : vm.cnt2Settings.currValue;
counterItem->setCounter(static_cast<COUNTER_TYPE>(vm.counterType), vm.digitalNum, displayNum);
if(vm.enbCustomCharWidth) { if(vm.enbCustomCharWidth) {
counterItem->setCharWidth(vm.charWidth); counterItem->setCharWidth(vm.charWidth);
} }
@@ -1088,17 +1100,17 @@ void TestPrintWidget::addCounterItem(CounterViewModel vm, QSharedPointer<QFont>
pPicScene->clearSelection(); pPicScene->clearSelection();
PicCounterItem* item = new PicCounterItem(); PicCounterItem* item = new PicCounterItem();
pPicScene->addItem(item); pPicScene->addItem(item);
item->setCounter(static_cast<COUNTER_TYPE>(vm.counterType), vm.digitalNum);
item->setLetterSpace(static_cast<int>(font.letterSpacing()));
int displayNum = static_cast<COUNTER_TYPE>(vm.counterType) == COUNTER_TYPE_1 ? vm.cnt1Settings.currValue : vm.cnt2Settings.currValue;
item->setCounter(static_cast<COUNTER_TYPE>(vm.counterType), vm.digitalNum, displayNum);
auto boundingRect = pPicScene->itemsBoundingRect(); auto boundingRect = pPicScene->itemsBoundingRect();
int y = sysPara->para.canvasHeight - item->boundingRect().height(); int y = sysPara->para.canvasHeight - item->boundingRect().height();
item->setPos(x_item, y); item->setPos(x_item, y);
x_item = x_item + boundingRect.right() + 5; x_item = x_item + boundingRect.right() + 5;
item->setSelected(true); item->setSelected(true);
item->setLetterSpace(static_cast<int>(font.letterSpacing()));
// item->setCustomFont(font.family());
if(vm.enbCustomCharWidth) {
item->setCharWidth(vm.charWidth);
}
m_printSettingModel.cnt1Settings = vm.cnt1Settings; m_printSettingModel.cnt1Settings = vm.cnt1Settings;
m_printSettingModel.cnt2Settings = vm.cnt2Settings; m_printSettingModel.cnt2Settings = vm.cnt2Settings;