yun преди 4 седмици
родител
ревизия
c66b4d225d

+ 0 - 17
View/die-bonder-ui/CameraMaterialGroupWnd/MaterialWindow/Bond.cpp

@@ -713,23 +713,6 @@ void Bond::paintInitFrom(QWidget* parent) {
     */
 }
 
-QColor Bond::getColorByStatus() {
-    ns_mat::DIE_STATUS status;
-    //status = stPointInfo.stBondStatus.bDieStatus;
-
-
-    switch (status) {
-    //case ns_mat::DIE_STATUS::NO_PICK: return QColor(200, 200, 200);
-    //case ns_mat::DIE_STATUS::WAF_PICK_DONE: return QColor(100, 200, 230);
-    //case ns_mat::DIE_STATUS::TRANSFER_BOND_DONE: return QColor(255, 255, 0);
-    case ns_mat::DIE_STATUS::TRANSFER_PICK_DONE: return QColor(255, 165, 0);
-    case ns_mat::DIE_STATUS::LOOKUP_CALIB_DONE: return QColor(0, 150, 255);
-    case ns_mat::DIE_STATUS::BOND_DONE: return QColor(144, 238, 144);
-    case ns_mat::DIE_STATUS::BOND_DEL: return QColor(255, 50, 50);
-    default: return Qt::gray;
-    }
-}
-
 void Bond::UpdataVal(std::vector<ns_mat::POINT_INFO_STRUCT>& stPointInfo)
 {
     maxPoint = QPointF(stPointInfo[0].stBondStatus.stAlnBondPosition.x, stPointInfo[0].stBondStatus.stAlnBondPosition.y);

+ 2 - 0
View/die-bonder-ui/CameraMaterialGroupWnd/MaterialWindow/BondGraphicsView.cpp

@@ -460,6 +460,7 @@ void BondGraphicsView::setCViewInterface(ns_module::CViewInterface* CViewInterfa
 
 void BondGraphicsView::checkAndCreateRegion()
 {
+    /*
     // 仅当两个点都有效时处理
     if (topLeftIndex.first < 0 || bottomRightIndex.first < 0) return;
 
@@ -489,5 +490,6 @@ void BondGraphicsView::checkAndCreateRegion()
     // 重置索引点
     topLeftIndex = qMakePair(-1, -1);
     bottomRightIndex = qMakePair(-1, -1);
+    */
 
 }

+ 68 - 55
View/die-bonder-ui/CameraMaterialGroupWnd/MaterialWindow/Waffle.cpp

@@ -55,43 +55,26 @@ void Waffle::UpdataGenerateTestData()
 
 void Waffle::UpdataVal(const std::vector<ns_mat::WAFFLE_MATRIX_POINT_STRUCT>& veWaffle)
 {
-    maxRow = 0;
-    maxCol = 0;
-    waffleMatrixRowNum = 0;
-    waffleMatrixColNum = 0;
-    matrixInfo mInfo;
-    mInfo.maxCol = 0;
-    mInfo.maxRow = 0;
-    UINT dieMatrixId = veWaffle[0].nDieMatrixId;
+
+
+    maxPoint = QPointF(veWaffle[0].stPosition.x, veWaffle[0].stPosition.y);
+    minPoint = QPointF(veWaffle[0].stPosition.x, veWaffle[0].stPosition.y);
     for (const auto a: veWaffle)
     {
-        if (dieMatrixId != a.nDieMatrixId) {
-            matrixInfoMap.insert(dieMatrixId, mInfo);
-            dieMatrixId = a.nPackMatrixId;
-            mInfo.maxCol = 0;
-            mInfo.maxRow = 0;
-        }
-        else {
-            if (mInfo.maxRow < a.nDieRow)
-                mInfo.maxRow = a.nDieRow;
-            if (mInfo.maxCol < a.nDieCol)
-                mInfo.maxCol = a.nDieCol;
-
-        }
         m_vWaffleData.append(a);
-        if (a.nPackRow == 1 && a.nDieRow==1) {
-            waffleMatrixRowNum++;
-        }
-        if (a.nPackCol == 1 && a.nDieCol == 1) {
-            waffleMatrixColNum++;
-        }
-        if (maxRow < a.nPackRow)
-            maxRow = a.nPackRow;
-        if (maxCol < a.nPackCol)
-            maxCol = a.nPackCol;
+        //遍历找到最小和最大边界点
+        if (a.stPosition.x > maxPoint.x())
+            maxPoint.setX(a.stPosition.x);
+        if (a.stPosition.x < minPoint.x())
+            minPoint.setX(a.stPosition.x);
+        if (a.stPosition.y > maxPoint.y())
+            maxPoint.setY(a.stPosition.y);
+        if (a.stPosition.y < minPoint.y())
+            minPoint.setY(a.stPosition.y);
+
+
     }
-    matrixInfoMap.insert(dieMatrixId, mInfo);
-    qDebug() << maxRow << maxCol << waffleMatrixRowNum << waffleMatrixColNum;
+
 }
 
 void Waffle::paintEvent(QPaintEvent *event) {
@@ -147,18 +130,9 @@ void Waffle::drawWaffle(QPainter &painter, int startX, int startY, int rows, int
         }
     }
 }
-QColor Waffle::getColorByStatus(ns_mat::PICK_DIE_STATUS status) {
-    switch (status) {
-    case ns_mat::PICK_DIE_STATUS::DIE_EXIST: return QColor(0, 102, 255); // 蓝色
-    case ns_mat::PICK_DIE_STATUS::NO_EXIST: return QColor(200, 200, 200); // 浅灰
-    case ns_mat::PICK_DIE_STATUS::PICK_ING: return QColor(255, 255, 0); // 黄色
-    case ns_mat::PICK_DIE_STATUS::SKIP_DIE: return QColor(128, 128, 128); // 深灰
-    case ns_mat::PICK_DIE_STATUS::EDGE_DIE: return QColor(255, 165, 0); // 橙色
-    default: return QColor(0, 0, 0); // 默认黑色
-    }
-}
-void Waffle::paintInitFrom(QWidget *parent) {
 
+void Waffle::paintInitFrom(QWidget *parent) {
+    /*
     // 获取当前窗口的宽高
     int width = parent->width();
     int height = parent->height();
@@ -197,27 +171,66 @@ void Waffle::paintInitFrom(QWidget *parent) {
     // painter.setBrush(Qt::black);
     // painter.drawEllipse(centerX - 3, centerY - 3, 6, 6);
     painter.end(); // 结束绘制
+    */
 }
+
 void Waffle::initFrom(QWidget *parent) {
     scene = new QGraphicsScene(parent);
     view = new WaffleGraphicsView(scene);
-    /*
-    // 获取当前窗口的宽高
+    view->setCViewInterface(m_pCViewInterface);
+
     int width = parent->width();
     int height = parent->height();
+    double maxWidth = maxPoint.x() - minPoint.x();
+    double maxHeight = maxPoint.y() - minPoint.y();
+    double ratio;
 
-    // 根据行列数计算每个晶圆点的大小,选择小的边来决定
-    int cellSize = qMin(width, height) / qMax(rows, cols); // 固定大小为正方形,按最小边计算
+    if (maxHeight > maxWidth) {
+        ratio = maxHeight / (width - 100);
+    }
+    else {
+        ratio = maxWidth / (width - 100);
+    }
 
+    //目前没提供固晶点大小,以下用测试大小,后续可替换(实际大小,接口替换处)
+    double dieWidth = 20000;
+    double dieHeight = 20000;
     for (int i = 0; i < m_vWaffleData.size(); ++i) {
-        DieItem* die = new DieItem(m_vWaffleData[i].nDieRow, m_vWaffleData[i].nDieCol, m_vWaffleData[i].eStatus, cellSize);
-        die->setPos(m_vWaffleData[i].nDieCol * cellSize, m_vWaffleData[i].nDieRow * cellSize);
-        scene->addItem(die);
-    }
 
-    view->setSceneRect(scene->itemsBoundingRect());
-    view->resize(width, height);
-    */
+        // 绘制固晶点
+
+        //转换大小
+        double dieWidthr = dieWidth / ratio;
+        double dieHeightr = dieHeight / ratio;
+        double diex, diey;
+        diex = (m_vWaffleData[i].stPosition.x - minPoint.x() + dieWidth) / ratio;
+        diey = (m_vWaffleData[i].stPosition.y - minPoint.y() + dieHeight) / ratio;
+
+
+        // 计算固晶点位置
+        QRectF dieRect(
+            diex,
+            diey,
+            dieWidthr,
+            dieHeightr
+        );
+        WaffleItem* dieItem = new WaffleItem(m_vWaffleData[i]);
+        dieItem->setRect(dieRect);
+        dieItem->setZValue(1.0);
+        scene->addItem(dieItem);
+        /*
+        // 添加固晶点编号
+        QGraphicsTextItem* dieText = new QGraphicsTextItem(dieItem);
+        dieText->setPlainText("PT" + QString::number(m_vWaffleData[i].stIndex.iIndex));
+        double dieFontSize = qMin(dieWidthr, dieHeightr) * 0.2;
+        QFont font;
+        font.setPointSizeF(dieFontSize);  // 使用浮点大小
+        dieText->setFont(font);
+        dieText->setPos(dieRect.center() - QPointF(dieText->boundingRect().width() / 2,
+            dieText->boundingRect().height() / 2));
+            */
+    }
+  
 }
 QPixmap Waffle::getGlobalPixmap() const {
     return globalPixmap;

+ 4 - 8
View/die-bonder-ui/CameraMaterialGroupWnd/MaterialWindow/Waffle.h

@@ -22,7 +22,6 @@ public:
 
 
     void paintEvent(QPaintEvent *event) override;
-    QColor getColorByStatus(ns_mat::PICK_DIE_STATUS status);
     void initFrom(QWidget *parent);
     void paintInitFrom(QWidget *parent);
     QPixmap getGlobalPixmap() const;
@@ -44,13 +43,10 @@ private:
 
     int centerX, centerY;
     QPixmap globalPixmap;
-    int maxRow, maxCol;
-    int waffleMatrixRowNum, waffleMatrixColNum;
-    struct matrixInfo{
-        int maxRow;
-        int maxCol;
-    };
-    QMap<int, matrixInfo> matrixInfoMap;
+
+    QPointF maxPoint;
+    QPointF minPoint;
+    ns_module::CViewInterface* m_pCViewInterface;
 
 public:
     QGraphicsScene*     scene = nullptr;

+ 124 - 0
View/die-bonder-ui/CameraMaterialGroupWnd/MaterialWindow/WaffleGraphicsView.cpp

@@ -378,3 +378,127 @@ void WaffleGraphicsView::setRegion()
     topLeftIndex = qMakePair(-1, -1);
     bottomRightIndex = qMakePair(-1, -1);
 }
+
+void WaffleGraphicsView::setCViewInterface(ns_module::CViewInterface* CViewInterface) {
+    m_pCViewInterface = CViewInterface;
+}
+void WaffleGraphicsView::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 WaffleGraphicsView::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);
+}
+
+WaffleItem::WaffleItem(ns_mat::WAFFLE_MATRIX_POINT_STRUCT point, QGraphicsItem* parent)
+    : QGraphicsRectItem(parent), point(point) {
+    setBrush(getColorByStatus());
+    setPen(QPen(QColor(0, 0, 0), 1));
+}
+
+void WaffleItem::setSelected(bool selected) {
+    if (selected) {
+        setPen(QPen(Qt::red, 1));
+    }
+    else {
+        setPen(QPen(Qt::black, 1));  // 未选中时恢复为黑色边框
+    }
+}
+
+void WaffleItem::setLeftSelected(bool selected) {
+    if (selected) {
+        setPen(QPen(Qt::green, 1));
+    }
+    else {
+        setPen(QPen(Qt::black, 1));  // 未选中时恢复为黑色边框
+    }
+}
+
+
+void WaffleItem::hoverEnterEvent(QGraphicsSceneHoverEvent*) {
+    setZValue(1); // 悬停时提升Z值
+    update();
+}
+
+void WaffleItem::hoverLeaveEvent(QGraphicsSceneHoverEvent*) {
+    setZValue(0);
+    update();
+}
+
+QColor WaffleItem::getColorByStatus() {
+    ns_mat::PICK_DIE_STATUS status = point.eStatus;
+    switch (status) {
+    case ns_mat::PICK_DIE_STATUS::DIE_EXIST: return QColor(0, 102, 255); // 蓝色
+    case ns_mat::PICK_DIE_STATUS::NO_EXIST: return QColor(200, 200, 200); // 浅灰
+    case ns_mat::PICK_DIE_STATUS::PICK_ING: return QColor(255, 255, 0); // 黄色
+    case ns_mat::PICK_DIE_STATUS::SKIP_DIE: return QColor(128, 128, 128); // 深灰
+    case ns_mat::PICK_DIE_STATUS::EDGE_DIE: return QColor(255, 165, 0); // 橙色
+    default: return QColor(0, 0, 0); // 默认黑色
+    }
+}

+ 25 - 2
View/die-bonder-ui/CameraMaterialGroupWnd/MaterialWindow/WaffleGraphicsView.h

@@ -7,13 +7,15 @@
 #include "DieItem.h"
 #include <QLabel>
 #include <QPointer>
-
+#include <CViewInterface.h>
 class WaffleGraphicsView : public QGraphicsView {
     Q_OBJECT
 
 public:
     WaffleGraphicsView(QGraphicsScene* scene, QWidget* parent = nullptr);
-
+    QPixmap convertToPixmap(const ImageInfo& imgData);
+    void yuv422_to_rgb888(const unsigned char* src, unsigned char* dst, int width, int height);
+    void setCViewInterface(ns_module::CViewInterface* CViewInterface);
 
 protected:
     void mousePressEvent(QMouseEvent* event) override;
@@ -45,6 +47,27 @@ private:
     void checkAndCreateRegion();
     void clearRegion();
     void setRegion();
+
+    ns_module::CViewInterface* m_pCViewInterface;
+};
+
+class WaffleItem : public QObject, public QGraphicsRectItem {
+public:
+    WaffleItem(ns_mat::WAFFLE_MATRIX_POINT_STRUCT point, QGraphicsItem* parent = nullptr);
+
+    void setSelected(bool selected);
+    void setLeftSelected(bool selected);
+
+
+
+private:
+
+    // 获取单元格状态颜色
+    QColor getColorByStatus();
+    WAFFLE_MATRIX_POINT_STRUCT point;
+protected:
+    void hoverEnterEvent(QGraphicsSceneHoverEvent*) override;
+    void hoverLeaveEvent(QGraphicsSceneHoverEvent*) override;
 };
 
 #endif // WAFFLEGRAPHICSVIEW_H

+ 1 - 1
View/die-bonder-ui/OriginalWnd/MainAndSecondaryCamerasWnd.cpp

@@ -105,7 +105,7 @@ void MainAndSecondaryCamerasWnd::InitPage()
             }
             else
             {
-                m_pMainCameraBind->m_vecCamera[i].eType = MATERIAL_BOND;
+                m_pMainCameraBind->m_vecCamera[i].eType = MATERIAL_WAFFLE;
                 manager = new CameraImageHandler(num, m_pMainCameraBind->m_vecCamera[i]);
             }
 

BIN
View/die-bonder-ui/images/TopStatusBar/HostStatus1.png


BIN
View/die-bonder-ui/images/TopStatusBar/MachineLink1.png