|
@@ -90,14 +90,20 @@ void WaferGraphicsView::mousePressEvent(QMouseEvent* event) {
|
|
selectedItem.clear();
|
|
selectedItem.clear();
|
|
QGraphicsItem* item = itemAt(event->pos());
|
|
QGraphicsItem* item = itemAt(event->pos());
|
|
if (item) {
|
|
if (item) {
|
|
- selectedItem = dynamic_cast<DieItem*>(item);
|
|
|
|
- selectedItem->setLeftSelected(true);
|
|
|
|
|
|
+ if (typeid(*item) == typeid(DieItem)) {
|
|
|
|
+ selectedItem = static_cast<DieItem*>(item);
|
|
|
|
+ selectedItem->setLeftSelected(true);
|
|
|
|
+ if (event->button() == Qt::MouseEventCreatedDoubleClick) {
|
|
|
|
+ m_pCViewInterface->GetViewMatrix()->MoveWaferToPoint(selectedItem->getDieIndex());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
setCursor(Qt::OpenHandCursor); // 按下时设置为小手
|
|
setCursor(Qt::OpenHandCursor); // 按下时设置为小手
|
|
selecting = true;
|
|
selecting = true;
|
|
lastPos = event->pos(); // 记录鼠标位置
|
|
lastPos = event->pos(); // 记录鼠标位置
|
|
|
|
+
|
|
}
|
|
}
|
|
else if (event->button() == Qt::RightButton) {
|
|
else if (event->button() == Qt::RightButton) {
|
|
// 开始框选
|
|
// 开始框选
|
|
@@ -163,12 +169,15 @@ void WaferGraphicsView::mouseReleaseEvent(QMouseEvent* event) {
|
|
|
|
|
|
QList<QGraphicsItem*> items = scene()->items(selectedArea, Qt::IntersectsItemShape);
|
|
QList<QGraphicsItem*> items = scene()->items(selectedArea, Qt::IntersectsItemShape);
|
|
for (QGraphicsItem* item : items) {
|
|
for (QGraphicsItem* item : items) {
|
|
- DieItem* die = dynamic_cast<DieItem*>(item);
|
|
|
|
- if (die) {
|
|
|
|
- // 将 DieItem 添加到 map 中
|
|
|
|
- selectedItemsMap.insert(qMakePair(die->getRow(), die->getCol()), die);
|
|
|
|
- die->setSelected(true); // 设置选中状态
|
|
|
|
|
|
+ if (typeid(*item) == typeid(DieItem)) {
|
|
|
|
+ DieItem* die = dynamic_cast<DieItem*>(item);
|
|
|
|
+ if (die) {
|
|
|
|
+ // 将 DieItem 添加到 map 中
|
|
|
|
+ selectedItemsMap.insert(qMakePair(die->getRow(), die->getCol()), die);
|
|
|
|
+ die->setSelected(true); // 设置选中状态
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (selectionRect) {
|
|
if (selectionRect) {
|
|
@@ -187,13 +196,13 @@ void WaferGraphicsView::mouseReleaseEvent(QMouseEvent* event) {
|
|
connect(showThumb, &QAction::triggered, [this] {
|
|
connect(showThumb, &QAction::triggered, [this] {
|
|
thumbnailVisible ? hideThumbnail() : showThumbnail();
|
|
thumbnailVisible ? hideThumbnail() : showThumbnail();
|
|
});
|
|
});
|
|
- menu.addAction(tr("Send Location", "发送位置"), [this] {
|
|
|
|
- if (selectedItem) {
|
|
|
|
- qDebug() << "Row:" << selectedItem->getRow() << "Col:" << selectedItem->getCol();
|
|
|
|
- selectedItem->setLeftSelected(false);
|
|
|
|
- selectedItem = nullptr;
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ //menu.addAction(tr("Send Location", "发送位置"), [this] {
|
|
|
|
+ // if (selectedItem) {
|
|
|
|
+ // qDebug() << "Row:" << selectedItem->getRow() << "Col:" << selectedItem->getCol();
|
|
|
|
+ // selectedItem->setLeftSelected(false);
|
|
|
|
+ // selectedItem = nullptr;
|
|
|
|
+ // }
|
|
|
|
+ // });
|
|
if (die) {
|
|
if (die) {
|
|
menu.addAction(tr("move to current location","移动到该位置"), [this, die] {
|
|
menu.addAction(tr("move to current location","移动到该位置"), [this, die] {
|
|
for (auto& item : selectedItemsMap) {
|
|
for (auto& item : selectedItemsMap) {
|
|
@@ -223,6 +232,7 @@ void WaferGraphicsView::mouseReleaseEvent(QMouseEvent* event) {
|
|
|
|
|
|
selectedItem = die;
|
|
selectedItem = die;
|
|
selectedItem->setLeftSelected(true);
|
|
selectedItem->setLeftSelected(true);
|
|
|
|
+ m_pCViewInterface->GetViewMatrix()->MoveWaferToPoint(die->getDieIndex());
|
|
});
|
|
});
|
|
|
|
|
|
// 设置区域边界点菜单
|
|
// 设置区域边界点菜单
|
|
@@ -268,15 +278,15 @@ void WaferGraphicsView::wheelEvent(QWheelEvent* event) {
|
|
|
|
|
|
// 缩略图功能实现
|
|
// 缩略图功能实现
|
|
void WaferGraphicsView::showThumbnail() {
|
|
void WaferGraphicsView::showThumbnail() {
|
|
- // 本地图片路径(根据实际路径修改)
|
|
|
|
- QString imagePath = ":/images/test_image/image_1.png"; // 替换为本地图片路径
|
|
|
|
|
|
+ ImageInfo image;
|
|
|
|
+ m_pCViewInterface->GetViewMatrix()->GetWaferRefImage(image);
|
|
|
|
+
|
|
|
|
+ QPixmap thumb = convertToPixmap(image);
|
|
|
|
|
|
- // 加载本地图片
|
|
|
|
- QPixmap thumb(imagePath);
|
|
|
|
|
|
|
|
if (!thumb.isNull()) {
|
|
if (!thumb.isNull()) {
|
|
// 如果图片加载成功,设置为缩略图
|
|
// 如果图片加载成功,设置为缩略图
|
|
- thumbnailLabel->setPixmap(thumb.scaled(150, 150, Qt::KeepAspectRatio));
|
|
|
|
|
|
+ thumbnailLabel->setPixmap(thumb.scaled(image.width, image.height, Qt::KeepAspectRatio));
|
|
thumbnailLabel->show();
|
|
thumbnailLabel->show();
|
|
thumbnailVisible = true;
|
|
thumbnailVisible = true;
|
|
}
|
|
}
|
|
@@ -462,4 +472,82 @@ void WaferGraphicsView::drawDieMatrix(const QPointF& center,
|
|
font.setPointSize(6); // 设置字体大小为 8,可以根据需要调整
|
|
font.setPointSize(6); // 设置字体大小为 8,可以根据需要调整
|
|
text->setFont(font); // 应用新的字体
|
|
text->setFont(font); // 应用新的字体
|
|
m_scene->addItem(text);
|
|
m_scene->addItem(text);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void WaferGraphicsView::setCViewInterface(ns_module::CViewInterface* CViewInterface) {
|
|
|
|
+ m_pCViewInterface = CViewInterface;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void WaferGraphicsView::yuv422_to_rgb888(const unsigned char* src, unsigned char* dst, int width, int height)
|
|
|
|
+{
|
|
|
|
+ for (int i = 0; i < width * height; i += 2) {
|
|
|
|
+ unsigned char y0 = src[0];
|
|
|
|
+ unsigned char u = src[1];
|
|
|
|
+ unsigned char y1 = src[2];
|
|
|
|
+ unsigned char v = src[1];
|
|
|
|
+
|
|
|
|
+ // 简单反色度插值,适用于 U/V 在相邻像素间共享的情况
|
|
|
|
+ int r, g, b;
|
|
|
|
+
|
|
|
|
+ // YUV to RGB 转换公式
|
|
|
|
+#define CLIP(x) qBound(0, int(x), 255)
|
|
|
|
+
|
|
|
|
+// Pixel 0
|
|
|
|
+ r = CLIP(y0 + 1.402 * (v - 128));
|
|
|
|
+ g = CLIP(y0 - 0.344 * (u - 128) - 0.714 * (v - 128));
|
|
|
|
+ b = CLIP(y0 + 1.772 * (u - 128));
|
|
|
|
+ *dst++ = r;
|
|
|
|
+ *dst++ = g;
|
|
|
|
+ *dst++ = b;
|
|
|
|
+
|
|
|
|
+ // Pixel 1
|
|
|
|
+ r = CLIP(y1 + 1.402 * (v - 128));
|
|
|
|
+ g = CLIP(y1 - 0.344 * (u - 128) - 0.714 * (v - 128));
|
|
|
|
+ b = CLIP(y1 + 1.772 * (u - 128));
|
|
|
|
+ *dst++ = r;
|
|
|
|
+ *dst++ = g;
|
|
|
|
+ *dst++ = b;
|
|
|
|
+
|
|
|
|
+ src += 4;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+QPixmap WaferGraphicsView::convertToPixmap(const ImageInfo& imgData)
|
|
|
|
+{
|
|
|
|
+ QImage::Format qFormat = QImage::Format_Invalid;
|
|
|
|
+
|
|
|
|
+ switch (imgData.format) {
|
|
|
|
+ case ImageFormat::GRAY8:
|
|
|
|
+ qFormat = QImage::Format_Grayscale8;
|
|
|
|
+ break;
|
|
|
|
+ case ImageFormat::RGB888:
|
|
|
|
+ qFormat = QImage::Format_RGB888;
|
|
|
|
+ break;
|
|
|
|
+ case ImageFormat::ARGB32:
|
|
|
|
+ qFormat = QImage::Format_ARGB32;
|
|
|
|
+ break;
|
|
|
|
+ case ImageFormat::RGB32:
|
|
|
|
+ qFormat = QImage::Format_RGB32;
|
|
|
|
+ break;
|
|
|
|
+ case ImageFormat::YUV422: {
|
|
|
|
+ // 需要先转换为 RGB888
|
|
|
|
+ int byteCount = imgData.width * imgData.height * 3;
|
|
|
|
+ unsigned char* rgbData = new unsigned char[byteCount];
|
|
|
|
+ yuv422_to_rgb888(imgData.data, rgbData, imgData.width, imgData.height);
|
|
|
|
+
|
|
|
|
+ QImage tmp(rgbData, imgData.width, imgData.height, QImage::Format_RGB888);
|
|
|
|
+ QPixmap pixmap = QPixmap::fromImage(tmp);
|
|
|
|
+
|
|
|
|
+ delete[] rgbData;
|
|
|
|
+ return pixmap;
|
|
|
|
+ }
|
|
|
|
+ default:
|
|
|
|
+ qDebug() << "Unsupported image format!";
|
|
|
|
+ return QPixmap();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ QImage qImg(imgData.data, imgData.width, imgData.height,
|
|
|
|
+ imgData.width * imgData.channel, qFormat);
|
|
|
|
+
|
|
|
|
+ return QPixmap::fromImage(qImg);
|
|
}
|
|
}
|