hlp:编辑内容不裁剪和对齐左上角,使用绝对坐标;修改编辑框滚动条样式;上下颠倒默认取反
This commit is contained in:
+4
-2
@@ -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;
|
||||
|
||||
+114
-31
@@ -845,17 +845,46 @@
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="MyView" name="graphicsView"/>
|
||||
<widget class="MyView" name="graphicsView">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>170</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QGraphicsView QScrollBar:horizontal {
|
||||
height: 28px; /* 水平滚动条高度,调大方便拖拽 */
|
||||
background: #f0f0f0; /* 轨道背景色(可自行调整) */
|
||||
}
|
||||
|
||||
QGraphicsView QScrollBar::handle:horizontal {
|
||||
background: #b0b0b0; /* 滑块颜色 */
|
||||
min-width: 60px; /* 滑块最小宽度,防止太小 */
|
||||
border-radius: 6px;
|
||||
}
|
||||
</string>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOn</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="controlAreaFrame">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>190</height>
|
||||
<height>150</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
@@ -880,13 +909,25 @@
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="m_LineEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string>QLineEdit {
|
||||
<string notr="true">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;
|
||||
}</string>
|
||||
</property>
|
||||
@@ -897,6 +938,12 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="m_btnLeft_Control1">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>34</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string>QPushButton {
|
||||
background-color: #e5e5e5;
|
||||
@@ -921,6 +968,12 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="m_btnRight_Control1">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>34</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string>QPushButton {
|
||||
background-color: #e5e5e5;
|
||||
@@ -960,6 +1013,12 @@
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="m_lblY">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>88</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string>QLabel {
|
||||
background-color: #e5e5e5;
|
||||
@@ -978,6 +1037,12 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="m_lblX">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string>QLabel {
|
||||
background-color: #e5e5e5;
|
||||
@@ -999,31 +1064,6 @@
|
||||
<property name="spacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="m_btnUp">
|
||||
<property name="styleSheet">
|
||||
<string>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;
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>↑</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="m_btnLeft_Arrow">
|
||||
<property name="styleSheet">
|
||||
@@ -1099,10 +1139,47 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="m_btnUp">
|
||||
<property name="styleSheet">
|
||||
<string>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;
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>↑</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="m_lblID">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>88</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string>QLabel {
|
||||
background-color: #e5e5e5;
|
||||
@@ -1121,6 +1198,12 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="m_btnCheck">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>62</width>
|
||||
<height>84</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Ubuntu</family>
|
||||
@@ -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;
|
||||
|
||||
@@ -231,7 +231,6 @@
|
||||
<file>icon/pauseprint1.png</file>
|
||||
<file>icon/pauseprint2.png</file>
|
||||
<file>icon/TEXT.PNG</file>
|
||||
<file>buge_record.txt</file>
|
||||
<file>icon/Epauseprint.png</file>
|
||||
<file>icon/Epauseprint1.png</file>
|
||||
<file>icon/Epauseprint2.png</file>
|
||||
|
||||
+41
-14
@@ -699,18 +699,40 @@ QList<QRect> 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<PicCounterItem*>(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);
|
||||
|
||||
|
||||
@@ -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();
|
||||
@@ -441,6 +443,7 @@ void TestPrintWidget::openWorkFile(QString filePath){
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
pViewer->centerOn(0, 0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user