From 4ea9d2e2c8a27c049d1e0292bef11de014359150 Mon Sep 17 00:00:00 2001 From: kite_lucs <334054969@qq.com> Date: Wed, 26 Aug 2026 16:23:28 +0800 Subject: [PATCH] =?UTF-8?q?hlp:=E7=BC=96=E8=BE=91=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E4=B8=8D=E8=A3=81=E5=89=AA=E5=92=8C=E5=AF=B9=E9=BD=90=E5=B7=A6?= =?UTF-8?q?=E4=B8=8A=E8=A7=92=EF=BC=8C=E4=BD=BF=E7=94=A8=E7=BB=9D=E5=AF=B9?= =?UTF-8?q?=E5=9D=90=E6=A0=87=EF=BC=9B=E4=BF=AE=E6=94=B9=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E6=A1=86=E6=BB=9A=E5=8A=A8=E6=9D=A1=E6=A0=B7=E5=BC=8F=EF=BC=9B?= =?UTF-8?q?=E4=B8=8A=E4=B8=8B=E9=A2=A0=E5=80=92=E9=BB=98=E8=AE=A4=E5=8F=96?= =?UTF-8?q?=E5=8F=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Printsetting.cpp | 6 +- QtUI.pro | 2 +- TestPrintWidget.ui | 145 ++++++++++++++++++++++++++++++++++---------- image.qrc | 1 - mainwidget.cpp | 55 ++++++++++++----- testprintwidget.cpp | 7 ++- 6 files changed, 165 insertions(+), 51 deletions(-) diff --git a/Printsetting.cpp b/Printsetting.cpp index d74848d..c8cd07b 100644 --- a/Printsetting.cpp +++ b/Printsetting.cpp @@ -814,7 +814,8 @@ void PrintSettingModel::applyToSysPara(const PrintSettingModel &model, SysPara * { // 喷印风格相关 sysPara->para.leftRightInverse = model.leftRightInverse; - sysPara->para.upDownInverse = model.upDownInverse; + //韩国反馈以左下方第一个点阵位置为 Y:1 X:1 也是离回收管最近的墨点位置 + sysPara->para.upDownInverse = !model.upDownInverse; sysPara->para.currSelectVolPara = model.volParaIndex; sysPara->para.printColDelay = model.printColDelay; sysPara->para.HighVoltageAmplitude = model.highVoltageAmplitude; @@ -900,7 +901,8 @@ PrintSettingModel PrintSettingModel::fromSysPara(SysPara *sysPara) return model; model.leftRightInverse = sysPara->para.leftRightInverse; - model.upDownInverse = sysPara->para.upDownInverse; + //韩国反馈以左下方第一个点阵位置为 Y:1 X:1 也是离回收管最近的墨点位置 + model.upDownInverse = !sysPara->para.upDownInverse; model.mode0211 = sysPara->para.mode0211; model.printColDelay = sysPara->para.printColDelay; model.highVoltageAmplitude = sysPara->para.HighVoltageAmplitude; diff --git a/QtUI.pro b/QtUI.pro index 1cdb00d..0a80ef8 100644 --- a/QtUI.pro +++ b/QtUI.pro @@ -392,4 +392,4 @@ if(contains(DEFINES,__2451WIFI__)) #SOURCES += /home/student/newDisk/2451_linux/wpa_supplicant_hostapd/wpa_supplicant_hostapd-0.8/src/common/wpa_ctrl.c #INCLUDEPATH += /home/student/newDisk/2451_linux/wpa_supplicant_hostapd/wpa_supplicant_hostapd-0.8/src #INCLUDEPATH += /home/student/newDisk/2451_linux/wpa_supplicant_hostapd/wpa_supplicant_hostapd-0.8/src/utils -} \ No newline at end of file +} diff --git a/TestPrintWidget.ui b/TestPrintWidget.ui index 0ce803f..a2de2db 100644 --- a/TestPrintWidget.ui +++ b/TestPrintWidget.ui @@ -845,17 +845,46 @@ 0 - + + + + 0 + 170 + + + + QGraphicsView QScrollBar:horizontal { + height: 28px; /* 水平滚动条高度,调大方便拖拽 */ + background: #f0f0f0; /* 轨道背景色(可自行调整) */ +} + +QGraphicsView QScrollBar::handle:horizontal { + background: #b0b0b0; /* 滑块颜色 */ + min-width: 60px; /* 滑块最小宽度,防止太小 */ + border-radius: 6px; +} + + + + Qt::ScrollBarAlwaysOn + + + + + 0 + 0 + + 16777215 - 190 + 150 @@ -880,13 +909,25 @@ + + + 0 + 0 + + + + + 16777215 + 30 + + - QLineEdit { + QLineEdit { background-color: #e5e5e5; border: 1px solid #a8a8a8; border-radius: 2px; - padding: 4px 8px; - min-height: 32px; + /*padding: 4px 8px; + min-height: 32px;*/ font-size: 16px; } @@ -897,6 +938,12 @@ + + + 16777215 + 34 + + QPushButton { background-color: #e5e5e5; @@ -921,6 +968,12 @@ + + + 16777215 + 34 + + QPushButton { background-color: #e5e5e5; @@ -960,6 +1013,12 @@ + + + 16777215 + 88 + + QLabel { background-color: #e5e5e5; @@ -978,6 +1037,12 @@ + + + 16777215 + 100 + + QLabel { background-color: #e5e5e5; @@ -999,31 +1064,6 @@ 4 - - - - QPushButton { - background-color: #87CEEB; - border: 1px solid #4682B4; - border-radius: 4px; - min-width: 40px; - min-height: 40px; - font-size: 18px; - font-weight: bold; - color: #00008B; - } - QPushButton:hover { - background-color: #ADD8E6; - } - QPushButton:pressed { - background-color: #B0E0E6; - } - - - ↑ - - - @@ -1099,10 +1139,47 @@ + + + + QPushButton { + background-color: #87CEEB; + border: 1px solid #4682B4; + border-radius: 4px; + min-width: 40px; + min-height: 40px; + font-size: 18px; + font-weight: bold; + color: #00008B; + } + QPushButton:hover { + background-color: #ADD8E6; + } + QPushButton:pressed { + background-color: #B0E0E6; + } + + + ↑ + + + + + + 0 + 35 + + + + + 16777215 + 88 + + QLabel { background-color: #e5e5e5; @@ -1121,6 +1198,12 @@ + + + 62 + 84 + + Ubuntu @@ -1133,7 +1216,7 @@ border: 1px solid #87CEEB; border-radius: 4px; min-width: 60px; - min-height: 40px; + /*min-height: 40px;*/ font-size: 24px; font-family: "Ubuntu"; color: #228B22; diff --git a/image.qrc b/image.qrc index 264c929..ba925cc 100644 --- a/image.qrc +++ b/image.qrc @@ -231,7 +231,6 @@ icon/pauseprint1.png icon/pauseprint2.png icon/TEXT.PNG - buge_record.txt icon/Epauseprint.png icon/Epauseprint1.png icon/Epauseprint2.png diff --git a/mainwidget.cpp b/mainwidget.cpp index ca3d959..435c7df 100644 --- a/mainwidget.cpp +++ b/mainwidget.cpp @@ -699,18 +699,40 @@ QList MainWidget::variableItemsUpdate() continue; } +// const QRectF itemSceneRect = item->sceneBoundingRect(); +// const QRectF itemBufferRect = itemSceneRect.translated(-contentRect.topLeft()); +// const QRectF clippedBufferRect = itemBufferRect.intersected(outputRect); +// if(clippedBufferRect.isEmpty()) +// continue; + +// QRect targetRect = clippedBufferRect.toAlignedRect(); +// totalOfDatetimeNumber++; + +// if(targetRect != itemBufferRect.toAlignedRect()) { +// const int cropX = qMax(0, targetRect.left() - itemBufferRect.toAlignedRect().left()); +// const int cropY = qMax(0, targetRect.top() - itemBufferRect.toAlignedRect().top()); +// img = img.copy(cropX, cropY, targetRect.width(), targetRect.height()); +// ++nbClipDatetimePreview; +// } + // 获取 item 的场景绝对坐标 const QRectF itemSceneRect = item->sceneBoundingRect(); - const QRectF itemBufferRect = itemSceneRect.translated(-contentRect.topLeft()); - const QRectF clippedBufferRect = itemBufferRect.intersected(outputRect); - if(clippedBufferRect.isEmpty()) + // 与输出区域裁剪(使用绝对坐标) + const QRectF clippedSceneRect = itemSceneRect.intersected(outputRect); + if(clippedSceneRect.isEmpty()) continue; - QRect targetRect = clippedBufferRect.toAlignedRect(); + QRect targetRect = clippedSceneRect.toAlignedRect(); totalOfDatetimeNumber++; - if(targetRect != itemBufferRect.toAlignedRect()) { - const int cropX = qMax(0, targetRect.left() - itemBufferRect.toAlignedRect().left()); - const int cropY = qMax(0, targetRect.top() - itemBufferRect.toAlignedRect().top()); + // 计算 item 在场景中的绝对矩形(整数对齐) + QRect itemSceneAlignedRect = itemSceneRect.toAlignedRect(); + // 如果 targetRect 和 item 原始场景矩形不一致,说明被 outputRect 裁剪了 + if(targetRect != itemSceneAlignedRect) { + // 计算裁剪偏移量:相对于 item 左上角的偏移 + const int cropX = targetRect.left() - itemSceneAlignedRect.left(); + const int cropY = targetRect.top() - itemSceneAlignedRect.top(); + // 从 preview 图片中裁剪出对应区域 + // 注意:preview 图片的尺寸等于 itemSceneAlignedRect 的尺寸(假设 preview 生成时使用了完整的 boundingRect) img = img.copy(cropX, cropY, targetRect.width(), targetRect.height()); ++nbClipDatetimePreview; } @@ -1976,11 +1998,13 @@ void MainWidget::onPreviewScene() const QRectF contentRect = pPicScene->itemsBoundingRect(); const QRect sceneRect = contentRect.toAlignedRect(); qDebug() << "sceneRect: " << sceneRect; - // 限定最大高度和宽度 - int coldot = qMin(sceneRect.width(), MaxCol4000 ? MAX_PRINT_COL_NUM_Normal : MAX_PRINT_COL_NUM_Wide); - int maxPicHeight = qMin(sceneRect.height(), int(sysPara->para.canvasHeight)); - QSize size(coldot,maxPicHeight); +// int coldot = qMin(sceneRect.width(), MaxCol4000 ? MAX_PRINT_COL_NUM_Normal : MAX_PRINT_COL_NUM_Wide); +// int maxPicHeight = qMin(sceneRect.height(), int(sysPara->para.canvasHeight)); +// QSize size(coldot,maxPicHeight); + int coldot = qMin(int(contentRect.right()), MaxCol4000 ? MAX_PRINT_COL_NUM_Normal : MAX_PRINT_COL_NUM_Wide); + QSize size(MAX_PRINT_COL_NUM_Normal,sysPara->para.canvasHeight); + if(size.isEmpty()) { //场景为空时,渲染空场景并刷新界面 @@ -2035,9 +2059,12 @@ void MainWidget::onPreviewScene() if(clippedSceneRect.isEmpty()) continue; - const QRect itemRect = clippedSceneRect.translated(-contentRect.topLeft()).toAlignedRect(); + // const QRect itemRect = clippedSceneRect.translated(-contentRect.topLeft()).toAlignedRect(); + // 直接使用场景绝对坐标,不进行平移 + const QRect itemRect = clippedSceneRect.toAlignedRect(); const QRectF sourceRect = clippedSceneRect; + if(picText && picText->sourceType() == SourceType::COUNTER) { PicCounterItem* counterItem = qgraphicsitem_cast(picText); if(!counterItem) @@ -2075,8 +2102,8 @@ void MainWidget::onPreviewScene() pPicScene->render(&painter, itemRect, sourceRect); } - sysPara->status.currPrintRow = sceneRect.height(); - sysPara->status.currPrintCol = sceneRect.width(); + sysPara->status.currPrintRow = contentRect.bottom(); + sysPara->status.currPrintCol = contentRect.right(); imageToPrintData(image, 0, 0); diff --git a/testprintwidget.cpp b/testprintwidget.cpp index bc89783..724764c 100644 --- a/testprintwidget.cpp +++ b/testprintwidget.cpp @@ -31,6 +31,7 @@ TestPrintWidget::TestPrintWidget(QWidget* parent) // m_TextEdit = ui.m_TextEdit; m_LineEdit = ui.m_LineEdit; pViewer = ui.graphicsView; + // 初始化按钮组(互斥) m_ButtonGroup = new QButtonGroup(this); m_ButtonGroup->setExclusive(true); @@ -427,6 +428,7 @@ void TestPrintWidget::openWorkFile(QString filePath){ // 将场景中所有项移动,使 pPicScene->itemsBoundingRect() 的左上角对齐到 scene 的 (0,0) // 计算当前边界并做平移(仅在有偏移时执行) + /* QRectF bounds = pPicScene->itemsBoundingRect(); if (!bounds.isNull()) { qreal dx = -bounds.x(); @@ -440,7 +442,8 @@ void TestPrintWidget::openWorkFile(QString filePath){ it->setPos(oldPos + QPointF(dx, dy)); } } - } + } + */ pViewer->centerOn(0, 0); @@ -1129,4 +1132,4 @@ void TestPrintWidget::on_btn_copy_clicked() void TestPrintWidget::on_btn_paste_clicked() { pasteCopiedLayer(); -} \ No newline at end of file +}