|
@@ -125,8 +125,8 @@ void Waffle::UpdataVal(const std::vector<ns_mat::WAFFLE_MATRIX_POINT_STRUCT>& ve
|
|
|
minMatrixPoint = a;
|
|
|
}
|
|
|
|
|
|
- //qDebug() << maxMatrixPoint.stPosition.x<<","<< maxMatrixPoint.stPosition.y << " " << minMatrixPoint.stPosition.x << "," << minMatrixPoint.stPosition.y;
|
|
|
- //qDebug() << a.stPosition.x << " " << a.stPosition.y;
|
|
|
+ qDebug() << maxMatrixPoint.stPosition.x<<","<< maxMatrixPoint.stPosition.y << " " << minMatrixPoint.stPosition.x << "," << minMatrixPoint.stPosition.y;
|
|
|
+ qDebug() << a.stPosition.x << " " << a.stPosition.y;
|
|
|
|
|
|
}
|
|
|
|
|
@@ -204,20 +204,22 @@ void Waffle::initFrom(QWidget *parent) {
|
|
|
//目前没提供固晶点大小,以下用测试大小,后续可替换(实际大小,接口替换处)
|
|
|
double dieWidth = 0.5;
|
|
|
double dieHeight = 0.5;
|
|
|
+
|
|
|
+ //转换大小
|
|
|
+ double dieWidthr = dieWidth / ratio;
|
|
|
+ double dieHeightr = dieHeight / ratio;
|
|
|
+ double penSize;
|
|
|
+ if (dieWidthr < 1 || dieHeightr < 1) {
|
|
|
+ penSize = 0.1;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ penSize = 1;
|
|
|
+ }
|
|
|
for (int i = 0; i < m_vWaffleData.size(); ++i) {
|
|
|
|
|
|
// 绘制固晶点
|
|
|
|
|
|
- //转换大小
|
|
|
- double dieWidthr = dieWidth / ratio;
|
|
|
- double dieHeightr = dieHeight / ratio;
|
|
|
- double penSize;
|
|
|
- if (dieWidthr < 1 || dieHeightr < 1) {
|
|
|
- penSize = 0.1;
|
|
|
- }
|
|
|
- else {
|
|
|
- penSize = 1;
|
|
|
- }
|
|
|
+
|
|
|
double diex, diey;
|
|
|
diex = (m_vWaffleData[i].stPosition.x - minPoint.x() + dieWidth) / ratio;
|
|
|
diey = (m_vWaffleData[i].stPosition.y - minPoint.y() + dieHeight) / ratio;
|
|
@@ -243,7 +245,7 @@ void Waffle::initFrom(QWidget *parent) {
|
|
|
scene->addItem(dieItem);
|
|
|
}
|
|
|
|
|
|
- QPen ptpen(Qt::blue, 0.5);
|
|
|
+ QPen ptpen(Qt::blue, penSize);
|
|
|
QFont matrixFont;
|
|
|
double matrixFontSize = qMin(dieWidth / ratio, dieHeight / ratio) * 0.1;
|
|
|
matrixFont.setPointSizeF(matrixFontSize); // 使用浮点大小
|
|
@@ -300,14 +302,15 @@ void Waffle::initFrom(QWidget *parent) {
|
|
|
);
|
|
|
QGraphicsRectItem* ptTextItem = new QGraphicsRectItem(ptTextRect);
|
|
|
ptTextItem->setPen(Qt::NoPen);
|
|
|
+ ptTextItem->setPen(QPen(Qt::yellow, 0.01));
|
|
|
scene->addItem(ptTextItem);
|
|
|
|
|
|
QGraphicsTextItem* ptText = new QGraphicsTextItem(ptTextItem);
|
|
|
ptText->setPlainText(QString(tr("DieMat%1")).arg(m_vminMatrixPoints[i].nDieMatrixId));
|
|
|
ptText->setFont(matrixFont);
|
|
|
- // 将文本居中于 ptTextRect
|
|
|
- ptText->setPos(ptTextRect.center() - QPointF(ptText->boundingRect().width() / 2,
|
|
|
- ptText->boundingRect().height() / 2));
|
|
|
+ setTextSacle(ptTextRect, ptText);
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
m_vmaxPackMatrixPoints.append(maxPackMatrixPoint);
|
|
|
m_vminPackMatrixPoints.append(minPackMatrixPoint);
|
|
@@ -326,12 +329,12 @@ void Waffle::initFrom(QWidget *parent) {
|
|
|
packmatHeight
|
|
|
);
|
|
|
|
|
|
- // 绘制die矩阵背景
|
|
|
+ // 绘制pack矩阵背景
|
|
|
QGraphicsRectItem* packItem = new QGraphicsRectItem(packRect);
|
|
|
packItem->setPen(ptpen);
|
|
|
//ptItem->setBrush(QColor("#d5e4f8"));
|
|
|
scene->addItem(packItem);
|
|
|
- // 添加die矩阵标签
|
|
|
+ // 添加pack矩阵标签
|
|
|
QRectF packTextRect(
|
|
|
packmatx,
|
|
|
packmaty,
|
|
@@ -340,14 +343,12 @@ void Waffle::initFrom(QWidget *parent) {
|
|
|
);
|
|
|
QGraphicsRectItem* packTextItem = new QGraphicsRectItem(packTextRect);
|
|
|
packTextItem->setPen(Qt::NoPen);
|
|
|
- scene->addItem(packTextItem);
|
|
|
+ //scene->addItem(packTextItem);
|
|
|
|
|
|
QGraphicsTextItem* packText = new QGraphicsTextItem(packTextItem);
|
|
|
packText->setPlainText(QString(tr("PackMat%1")).arg(m_vmaxPackMatrixPoints[i].nPackMatrixId));
|
|
|
packText->setFont(matrixFont);
|
|
|
- // 将文本居中于 ptTextRect
|
|
|
- packText->setPos(packTextRect.center() - QPointF(packText->boundingRect().width() / 2,
|
|
|
- packText->boundingRect().height() / 2));
|
|
|
+ setTextSacle(packTextRect, packText);
|
|
|
|
|
|
}
|
|
|
view->setScene(scene);
|
|
@@ -373,3 +374,26 @@ void Waffle::initFrom(QWidget *parent) {
|
|
|
QPixmap Waffle::getGlobalPixmap() const {
|
|
|
return globalPixmap;
|
|
|
}
|
|
|
+
|
|
|
+void Waffle::setTextSacle(QRectF textRect, QGraphicsTextItem* textItem) {
|
|
|
+ // 获取文本实际绘制区域
|
|
|
+ QRectF textBoundingRect = textItem->boundingRect();
|
|
|
+
|
|
|
+ // 计算缩放比例,使文本适配到 ptTextRect 内部
|
|
|
+ qreal scaleX = textRect.width() / textBoundingRect.width();
|
|
|
+ qreal scaleY = textRect.height() / textBoundingRect.height();
|
|
|
+ qreal scale = qMin(scaleX, scaleY) * 0.9; // 留一点边距
|
|
|
+
|
|
|
+ // 缩放文本
|
|
|
+ textItem->setScale(scale);
|
|
|
+
|
|
|
+ // 将文本居中于 textRect
|
|
|
+ QPointF center = textRect.center();
|
|
|
+ // 使用 QTransform 缩放矩形
|
|
|
+ QTransform transform;
|
|
|
+ transform.scale(scale, scale);
|
|
|
+ QRectF scaledRect = transform.mapRect(textBoundingRect);
|
|
|
+
|
|
|
+ textItem->setPos(center.x() - scaledRect.width() / 2,
|
|
|
+ center.y() - scaledRect.height() / 2);
|
|
|
+}
|