hlp:桂林国际齿轮泵代码
This commit is contained in:
@@ -0,0 +1,398 @@
|
||||
/*
|
||||
* PrintTextDisplay.cpp
|
||||
*
|
||||
* Created on: Jul 9, 2013
|
||||
* Author: yiyu
|
||||
* QQ:1036184468
|
||||
* Descriptoin:
|
||||
|
||||
*/
|
||||
|
||||
#include "PrintTextDisplay.h"
|
||||
#include <QPainter>
|
||||
#include <QPen>
|
||||
#include <QBrush>
|
||||
#include <QPaintEvent>
|
||||
#include <QDebug>
|
||||
#include <QColor>
|
||||
#include <QRect>
|
||||
#include "Public.h"
|
||||
#include <QChar>
|
||||
#include<string>
|
||||
#include<iostream>
|
||||
|
||||
PrintTextDisplay::PrintTextDisplay(QWidget *parent):
|
||||
QWidget(parent){
|
||||
setPalette(QPalette(Qt::white));
|
||||
setAutoFillBackground(true);
|
||||
scaleRatio = 2;
|
||||
origWidth = 0;
|
||||
origHeight = 0;
|
||||
setAttribute(Qt::WA_OpaquePaintEvent,true); //背景不自动重画
|
||||
updateDigitalOnly = false;
|
||||
}
|
||||
|
||||
PrintTextDisplay::~PrintTextDisplay(){
|
||||
|
||||
}
|
||||
|
||||
void PrintTextDisplay::updateSysParaToUI(){
|
||||
|
||||
}
|
||||
|
||||
void PrintTextDisplay::updateSysStatusToUI(){
|
||||
updateDigitalOnly = true;
|
||||
update(); //表示只更新变量而已,该区域一定要包含实际的打印区域,否则显示不出来
|
||||
}
|
||||
|
||||
void PrintTextDisplay::enlargeDisplay(){
|
||||
if(scaleRatio < 10){
|
||||
scaleRatio ++;
|
||||
resize(scaleRatio*origWidth,scaleRatio*origHeight);
|
||||
update();
|
||||
|
||||
}
|
||||
}
|
||||
void PrintTextDisplay::scroll_update()
|
||||
{
|
||||
update();
|
||||
}
|
||||
|
||||
void PrintTextDisplay::reduceDisplay(){
|
||||
if(scaleRatio > 1){
|
||||
scaleRatio --;
|
||||
resize(scaleRatio*origWidth,scaleRatio*origHeight);
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
//#define H02 2
|
||||
//#define H04 4
|
||||
|
||||
void PrintTextDisplay::setDisplaySize(int w,int h){
|
||||
origHeight = h;
|
||||
|
||||
origWidth = w;
|
||||
|
||||
resize(scaleRatio*origWidth,scaleRatio*(origHeight));
|
||||
}
|
||||
void PrintTextDisplay::setScaleRatio(int ratio)
|
||||
{
|
||||
if(ratio > 1)
|
||||
{
|
||||
if(ratio > 10) ratio =10;
|
||||
scaleRatio =ratio;
|
||||
resize(scaleRatio*origWidth,scaleRatio*origHeight);
|
||||
update();
|
||||
}
|
||||
}
|
||||
void PrintTextDisplay::paintEvent(QPaintEvent *event){
|
||||
// qDebug() <<"x:" << event->rect().x() << "y:" << event->rect().y() << "width:" << event->rect().width() << "height" << event->rect().height();
|
||||
|
||||
QRect updateRect = event->rect();
|
||||
//2019/11/11 prevent pic shadow
|
||||
updateRect.setY(0);
|
||||
|
||||
static int r_altermode=-1;
|
||||
|
||||
if(sysPara)
|
||||
{
|
||||
QPainter p(this);
|
||||
p.scale(scaleRatio,scaleRatio);
|
||||
p.setPen(Qt::NoPen);
|
||||
|
||||
//qDebug()<<"updateRect"<<updateRect.x()<<updateRect.y();
|
||||
//if(sysPara->para.AlterMode!=r_altermode)updateDigitalOnly=false;
|
||||
//r_altermode=sysPara->para.AlterMode;
|
||||
if(sysPara->para.AlterMode!=r_altermode) updateDigitalOnly=false;
|
||||
r_altermode=sysPara->para.AlterMode;
|
||||
//if(!updateDigitalOnly)
|
||||
{ //尽量减少不必要的刷屏动作
|
||||
|
||||
int x = updateRect.x()/scaleRatio;
|
||||
int end_x = (( sysPara->status.addSpace?2:1)*(updateRect.x() + updateRect.width())/scaleRatio) + 1;
|
||||
int w= end_x - x;
|
||||
int y = updateRect.y()/scaleRatio;
|
||||
int end_y = (updateRect.y() + updateRect.height())/scaleRatio + 1;
|
||||
int h = end_y - y;;
|
||||
p.setBrush(QColor(Qt::white));
|
||||
int y0=0;
|
||||
//if(sysPara->para.AlterMode<2) y0=y;
|
||||
if(sysPara->para.AlterMode<2) y0=0;
|
||||
|
||||
//else if(sysPara->para.AlterMode==2) y0=0;
|
||||
else if(sysPara->para.AlterMode==2) y0=y;
|
||||
|
||||
if(sysPara->status.addSpace)
|
||||
p.drawRect(x>>1,y0,w/2,h);
|
||||
else
|
||||
p.drawRect(x,y0,w,h);
|
||||
|
||||
p.setBrush(QColor(Qt::green));
|
||||
|
||||
if(sysPara->para.AlterMode<2)
|
||||
{
|
||||
|
||||
}
|
||||
else if(sysPara->para.AlterMode==2)
|
||||
{
|
||||
y = end_y;
|
||||
end_y = end_y+h;
|
||||
}
|
||||
//qDebug()<<"updateRect"<<updateRect.x()<<updateRect.y()<<w<<h<<end_x<<x;
|
||||
unsigned char *dat;
|
||||
bool MaxCol4000;
|
||||
if(!sysPara->status.flagOfNo67FPGA && sysPara->status.FPGAVersionType == 0 && sysPara->status.FPGAChipType != 1)
|
||||
MaxCol4000 = false;
|
||||
else
|
||||
MaxCol4000 = true;
|
||||
if(MaxCol4000){
|
||||
dat =sysPara->status.printDat_Normal;
|
||||
}else{
|
||||
dat =sysPara->status.printDat;
|
||||
}
|
||||
for(int i = 0; i < h && (i +y)< MAX_PRINT_ROW_NUM; i ++){
|
||||
for(int j = x; j < end_x && j < (MaxCol4000?MAX_PRINT_COL_NUM_Normal:MAX_PRINT_COL_NUM_Wide); j++){
|
||||
if(dat[j*MAX_PRINT_ROW_BYTE_NUM + (i+y)/8] & (1<<((i+y)%8))){
|
||||
if(sysPara->status.addSpace){
|
||||
p.drawRect(j/2,i+y0,1,1);j++;
|
||||
}
|
||||
else
|
||||
p.drawRect(j,i+y0,1,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//sysPara->para.qrOption.DisplayUpdate=1;
|
||||
// 二维码显示
|
||||
//if(sysPara->para.qrOption.DisplayUpdate==1)
|
||||
if(sysPara->para.qrOption.DisplayUpdate==1 && sysPara->print.QRvars[0].type != BAR) //lich fix
|
||||
{
|
||||
sysPara->para.qrOption.DisplayUpdate=0;
|
||||
int varNum=0;
|
||||
for( varNum=0;varNum<sysPara->status.QRvariNum;varNum++){
|
||||
int x = sysPara->print.QRvars[varNum].startColPos;
|
||||
int w = sysPara->print.QRvars[varNum].width;
|
||||
int end_x = x+w;
|
||||
int h = sysPara->print.QRvars[varNum].height;
|
||||
int end_y=sysPara->print.QRvars[varNum].endRowPos;
|
||||
int y = sysPara->print.QRvars[varNum].startRowPos;
|
||||
p.setBrush(QColor(Qt::white));
|
||||
|
||||
//p.drawRect(x,y,w,h);
|
||||
if(sysPara->status.addSpace)
|
||||
p.drawRect(x/2,y,w,h);
|
||||
else
|
||||
p.drawRect(x,y,w,h);
|
||||
|
||||
p.setBrush(QColor(Qt::black));
|
||||
// p.setBrush(QColor(Qt::green));
|
||||
//qDebug()<<"PrintfTextDiaplay:"<<x<<y<<end_x<<end_y;
|
||||
unsigned char *dat;
|
||||
bool MaxCol4000;
|
||||
if(!sysPara->status.flagOfNo67FPGA && sysPara->status.FPGAVersionType == 0 && sysPara->status.FPGAChipType != 1)
|
||||
MaxCol4000 = false;
|
||||
else
|
||||
MaxCol4000 = true;
|
||||
if(MaxCol4000){
|
||||
dat =sysPara->status.printDat_Normal;
|
||||
}else{
|
||||
dat =sysPara->status.printDat;
|
||||
}
|
||||
for(int i = y; i < end_y && (i +y)< MAX_PRINT_ROW_NUM; i ++){
|
||||
for(int j = x; j < end_x && j < (MaxCol4000?MAX_PRINT_COL_NUM_Normal:MAX_PRINT_COL_NUM_Wide); j++){
|
||||
if(dat[j*MAX_PRINT_ROW_BYTE_NUM + (i)/8] & (1<<((i)%8))){
|
||||
//p.drawRect(j,i,1,1);
|
||||
if(sysPara->status.addSpace){
|
||||
p.drawRect(j>>1,i,1,1);//j++;
|
||||
}
|
||||
else
|
||||
p.drawRect(j,i,1,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
for(int i = 0; i < sysPara->status.ExpiryVarNum; i++){
|
||||
int x,w,end_x,h,end_y,y;
|
||||
if(i == 0)
|
||||
{
|
||||
if(sysPara->print.CurDateVar.type = CURDATE)
|
||||
{
|
||||
x = sysPara->print.CurDateVar.startColPos;
|
||||
w = sysPara->print.CurDateVar.width;
|
||||
end_x = x+w;
|
||||
h = sysPara->print.CurDateVar.height;
|
||||
end_y = sysPara->print.CurDateVar.endRowPos;
|
||||
y = sysPara->print.CurDateVar.startRowPos;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// 变量显示
|
||||
for(int i = 0; i < sysPara->status.variNum; i++){
|
||||
vars_t *p_var = &sysPara->status.vars[i];
|
||||
int val = p_var->currVal;
|
||||
//val = 6569;
|
||||
int x = p_var->startColPos;
|
||||
int y = p_var->startRowPos;
|
||||
int rowDiff = p_var->endRowPos - p_var->startRowPos;
|
||||
int digitalNum = p_var->digitalNum;
|
||||
|
||||
if(sysPara->para.AlterMode==2){
|
||||
if(y<sysPara->status.currAlterPrintRow) continue;
|
||||
y = p_var->startRowPos-sysPara->status.currAlterPrintRow-1;
|
||||
|
||||
}
|
||||
|
||||
else if(sysPara->para.AlterMode==1){
|
||||
|
||||
if(y>=sysPara->status.currAlterPrintRow) continue;
|
||||
|
||||
}
|
||||
int base = 1; int j=0,jmin=0;
|
||||
QString str="";
|
||||
int Num=0;
|
||||
|
||||
if(digitalNum<=8 || Public::getType(p_var->type) < 9 || p_var->type == 37 || p_var->type == 38 \
|
||||
|| Public::getType(p_var->type) == 13 || Public::getType(p_var->type) == 14 || Public::getType(p_var->type) == 15) // 0-8 变量 显示刷新
|
||||
{
|
||||
for(int j = 0; j < digitalNum;j ++){
|
||||
if(val>base-1)jmin=digitalNum-j-1;
|
||||
base *= 10;
|
||||
}
|
||||
str= QString("%1").arg(val%base,digitalNum,10,QLatin1Char('0'));
|
||||
|
||||
//20240626: 以下3个判断条件为处理计米显示小数点位数,最多可显示3位
|
||||
if(!sysPara->para.rrr_nc && sysPara->para.printNumPoint && p_var->type == 7)
|
||||
{
|
||||
val /= 1000;
|
||||
str= QString("%1").arg(val%base,digitalNum,10,QLatin1Char('0'));
|
||||
str.insert(str.length()-1,".");
|
||||
str.remove(0,1);
|
||||
|
||||
}
|
||||
else if(sysPara->para.rrr_nc && !sysPara->para.printNumPoint && p_var->type == 7)
|
||||
{
|
||||
val /= 100;
|
||||
str= QString("%1").arg(val%base,digitalNum,10,QLatin1Char('0'));
|
||||
str.insert(str.length()-2,".");
|
||||
str.remove(0,1);
|
||||
}
|
||||
else if(sysPara->para.rrr_nc && sysPara->para.printNumPoint && p_var->type == 7)
|
||||
{
|
||||
val /= 10;
|
||||
str= QString("%1").arg(val%base,digitalNum,10,QLatin1Char('0'));
|
||||
str.insert(str.length()-3,".");
|
||||
str.remove(0,1);
|
||||
}
|
||||
else if(sysPara->status.specialVarPrint.MeterEnable && p_var->type == 15)
|
||||
{
|
||||
str.remove(0,1);
|
||||
str += "m";
|
||||
}
|
||||
}
|
||||
|
||||
else { // 大于 9 是什么变量呢? 随机数 显示刷新
|
||||
base = 1; j=0,jmin=0;
|
||||
for(int j = 0; j < 8;j ++){
|
||||
if(val>base-1)jmin=8-j-1;
|
||||
base *= 10;
|
||||
}
|
||||
str= QString("%1").arg(val%base,8,10,QLatin1Char('0'));
|
||||
val = QString::number( sysPara->status.calandar_and_dat.RandomValue2 ,16).toInt();
|
||||
Num = digitalNum-8;
|
||||
base = 1;
|
||||
jmin=0;
|
||||
for(int j = 0; j < Num;j ++){
|
||||
if(val>base-1)jmin=Num-j-1;
|
||||
base *= 10;
|
||||
}
|
||||
str= QString("%1").arg(val%base,Num,10,QLatin1Char('0'))+str;
|
||||
}
|
||||
|
||||
|
||||
if(!sysPara->para.Cnt1NatureValue) jmin=0;
|
||||
|
||||
p.setBrush(QColor(Qt::white));
|
||||
if(sysPara->status.addSpace)
|
||||
p.drawRect(x/2,y,p_var->width/2,p_var->height);
|
||||
else p.drawRect(x,y,p_var->width,p_var->height);
|
||||
|
||||
//p.setBrush(QColor(Qt::red));//之前都是红色
|
||||
if(p_var->type==7 || p_var->type==37 || p_var->type==57|| p_var->type==67) p.setBrush(QColor(Qt::black));//变量1
|
||||
else if(p_var->type==8 || p_var->type==38 || p_var->type==58 || p_var->type==68) p.setBrush(QColor(Qt::blue));//变量2
|
||||
else if(p_var->type==13) p.setBrush(QColor(Qt::red));//变量3
|
||||
else p.setBrush(QColor(Qt::red)); //其他
|
||||
|
||||
|
||||
|
||||
|
||||
QChar *qchar = str.data();
|
||||
int charWidth;
|
||||
if(sysPara->para.flagOfModuleDecimal || sysPara->para.flagOfModuleHide)
|
||||
charWidth = p_var->datWidth/13;
|
||||
else
|
||||
charWidth = p_var->datWidth/10;
|
||||
|
||||
for( j = jmin; j < digitalNum; j++){
|
||||
int digitalIndex;
|
||||
if(!sysPara->para.rrr_nc && sysPara->para.printNumPoint && p_var->type == 7 && j == (digitalNum-2))
|
||||
{
|
||||
digitalIndex = 10;
|
||||
}
|
||||
else if(sysPara->para.rrr_nc && !sysPara->para.printNumPoint && p_var->type == 7 && j == (digitalNum-3))
|
||||
{
|
||||
digitalIndex = 10;
|
||||
}
|
||||
else if(sysPara->para.rrr_nc && sysPara->para.printNumPoint && p_var->type == 7 && j == (digitalNum-4))
|
||||
{
|
||||
digitalIndex = 10;
|
||||
}
|
||||
else if(sysPara->status.specialVarPrint.MeterEnable && p_var->type == 15 && j == (digitalNum-1))
|
||||
{
|
||||
digitalIndex = 11;
|
||||
}
|
||||
else
|
||||
{
|
||||
digitalIndex = qchar[j].toAscii() - '0';
|
||||
}
|
||||
unsigned char *pAaddr = p_var->dat + (digitalIndex*charWidth)*p_var->rowByteNum;
|
||||
|
||||
for(int k = 0; k < rowDiff; k++){
|
||||
for(int l = 0; l < charWidth; l++){
|
||||
if(pAaddr[l*p_var->rowByteNum + k/8] & (1<<(k%8))){
|
||||
//p.drawRect(x + j*charWidth + l,y + k,1,1);
|
||||
if(sysPara->status.addSpace){
|
||||
p.drawRect((x + j*charWidth + l)/2,y + k,1,1);l++;
|
||||
}
|
||||
else
|
||||
p.drawRect(x + j*charWidth + l,y + k,1,1);
|
||||
#ifdef DEBUG3
|
||||
printf("0");
|
||||
}
|
||||
else
|
||||
printf(".");
|
||||
}
|
||||
printf("\n");
|
||||
#else
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
updateDigitalOnly = false;
|
||||
// update();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Peers</class>
|
||||
<widget class="QDialog" name="Peers">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Peers</string>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QListView" name="peers">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="mouseTracking">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="viewMode">
|
||||
<enum>QListView::IconMode</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,44 @@
|
||||
#include "dlgvarlength.h"
|
||||
#include "ui_dlgvarlength.h"
|
||||
|
||||
DlgVarLength::DlgVarLength(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::DlgVarLength)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(ui->pushButtonOK,SIGNAL(pressed()),this,SLOT(pushButtonOK_Pressed()));
|
||||
|
||||
|
||||
}
|
||||
|
||||
DlgVarLength::~DlgVarLength()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
void DlgVarLength::applyUI(int len)
|
||||
{
|
||||
int tmp=len/2;
|
||||
ui->spinHeadLen->setMaximum( tmp);
|
||||
ui->spinEndLen->setMaximum( tmp);
|
||||
|
||||
ui->spinHeadLen->setValue(headLen);
|
||||
ui->spinEndLen->setValue(endLen);
|
||||
ui->spinVarLen->setValue(varLen);
|
||||
ui->spinVarLen1->setValue(varLen1);
|
||||
ui->checkVarEN->setChecked(varEn);
|
||||
ui->pushButtonOK->setFocus();
|
||||
//ui->lab_AllLength ->setText(QString().sprintf("%0.1f",len));
|
||||
ui->lineEditAllLen ->setText(QString().sprintf("%d",len));
|
||||
}
|
||||
|
||||
void DlgVarLength::pushButtonOK_Pressed()
|
||||
{
|
||||
headLen = ui->spinHeadLen->value();
|
||||
endLen = ui->spinEndLen->value();
|
||||
varLen = ui->spinVarLen->value();
|
||||
varLen1 = ui->spinVarLen1->value();
|
||||
varEn = ui->checkVarEN->isChecked();
|
||||
emit on_set();
|
||||
this->hide();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#ifndef DLGSHOWMSG_H
|
||||
#define DLGSHOWMSG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class DlgShowMsg;
|
||||
}
|
||||
|
||||
class DlgShowMsg : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DlgShowMsg(QWidget *parent = 0);
|
||||
~DlgShowMsg();
|
||||
void showMsg(QString txt);
|
||||
void hideMsg();
|
||||
private slots:
|
||||
void OnpushButtonOKPressed();
|
||||
private:
|
||||
Ui::DlgShowMsg *ui;
|
||||
};
|
||||
|
||||
#endif // DLGSHOWMSG_H
|
||||
Reference in New Issue
Block a user