Просмотр исходного кода

修复晶圆矩阵框然后加深选中效果,小窗口同步问题

yun 1 день назад
Родитель
Сommit
8009c1a53a

+ 48 - 17
View/die-bonder-ui/CameraMaterialGroupWnd/Group.cpp

@@ -45,18 +45,18 @@ Group::Group(int groupId,const CameraInfo& cameraInfo, ns_module::CViewInterface
 
     if (cameraInfo.eType == 1) 
     {
-        m_pWafer = new Wafer(0, ui->Imagewidget_right);
-        if (m_pCViewInterface != nullptr)
-        {
-            std::vector<ns_mat::WAFER_MATRIX_POINT_INFO_STRUCT> veWafer;
-            m_pCViewInterface->GetViewMatrix()->GetWaferAllPointInfo(veWafer);
-            m_pWafer->UpdataVal(veWafer);
-        }
-        else
-        {
-            m_pWafer->UpdataGenerateTestData();
-        }
-        WaferWidget();
+        //m_pWafer = new Wafer(0, ui->Imagewidget_right);
+        //if (m_pCViewInterface != nullptr)
+        //{
+        //    std::vector<ns_mat::WAFER_MATRIX_POINT_INFO_STRUCT> veWafer;
+        //    m_pCViewInterface->GetViewMatrix()->GetWaferAllPointInfo(veWafer);
+        //    m_pWafer->UpdataVal(veWafer);
+        //}
+        //else
+        //{
+        //    m_pWafer->UpdataGenerateTestData();
+        //}
+        //WaferWidget();
     } 
     else if (cameraInfo.eType == 2) 
     {
@@ -220,11 +220,36 @@ void Group::saveGroupSettings(int Id, int materialWndType)
 
 void Group::WaferWidget()
 {
-    QVBoxLayout *layout2 = new QVBoxLayout(ui->Imagewidget_right);
+    //QVBoxLayout *layout2 = new QVBoxLayout(ui->Imagewidget_right);
+    //m_pWafer->paintInitFrom(ui->Imagewidget_right);
+
+    //QLabel* pixmapLabel = new QLabel();
+    //pixmapLabel->setPixmap(m_pWafer->getGlobalPixmap());
+
+    //ui->Imagewidget_right->setLayout(layout2);
+    //ui->Imagewidget_right->setFixedSize(110, 110);
+    //layout2->setContentsMargins(0, 0, 0, 0);
+    //layout2->addWidget(pixmapLabel);
+} 
+void Group::setWafer(Wafer* wafer) {
+    m_pWafer = wafer;
+}
+void Group::setWaferWidget(QPixmap pixmap) {
+    QVBoxLayout* layout2 = new QVBoxLayout(ui->Imagewidget_right);
     m_pWafer->paintInitFrom(ui->Imagewidget_right);
-
+    int width, height;
+    width = ui->Imagewidget_right->width();
+    height = ui->Imagewidget_right->height();
+    QSize targetSize(width, height);
+
+    // 不保持比例,直接拉伸到指定尺寸
+    QPixmap scaledPixmap = pixmap.scaled(
+        targetSize,
+        Qt::IgnoreAspectRatio,
+        Qt::SmoothTransformation
+    );
     QLabel* pixmapLabel = new QLabel();
-    pixmapLabel->setPixmap(m_pWafer->getGlobalPixmap());
+    pixmapLabel->setPixmap(scaledPixmap);
 
     ui->Imagewidget_right->setLayout(layout2);
     ui->Imagewidget_right->setFixedSize(110, 110);
@@ -398,8 +423,8 @@ void Group::loadBorderSettings()
         borderInfoSettings.endGroup();
     }
 
-    ui->leftBackground->setStyleSheet(leftStyle);
-    ui->rightBackground->setStyleSheet(rightStyle);
+    //ui->leftBackground->setStyleSheet(leftStyle);
+    //ui->rightBackground->setStyleSheet(rightStyle);
 
     if (isCurrentlySelected) {
         m_pCurrentlySelectedGroup = this;
@@ -531,18 +556,24 @@ void Group::initBorderStyle(int index,int color) {
     if (index == 2) {
         if(color == 0){
             ui->rightBackground->setStyleSheet("border: 2px solid blue;");
+            m_pPreviouslySelectedBlueGroup = this;
         }
         else {
             ui->rightBackground->setStyleSheet("border: 2px solid red;");
+            m_pCurrentlySelectedGroup = this;
         }
  
     }
     else {
         if (color == 0) {
             ui->leftBackground->setStyleSheet("border: 2px solid blue;");
+            m_pPreviouslySelectedBlueGroup = this;
         }
         else {
             ui->leftBackground->setStyleSheet("border: 2px solid red;");
+            m_pCurrentlySelectedGroup = this;
         }
     }
+    
+    
 }

+ 2 - 0
View/die-bonder-ui/CameraMaterialGroupWnd/Group.h

@@ -35,6 +35,8 @@ public:
     int getCurrentComboBoxIndex();
     void setCurrentCombox(const int index);
     void initBorderStyle(int index,int color);
+    void setWaferWidget(QPixmap pixmap);
+    void setWafer(Wafer* wafer);
 
 signals:
     void send_button_Signal();

+ 2 - 3
View/die-bonder-ui/CameraMaterialGroupWnd/MaterialWindow/DieItem.cpp

@@ -15,7 +15,7 @@ void DieItem::setSelected(bool selected) {
 
 void DieItem::setLeftSelected(bool selected) {
     if (selected) {
-        setPen(QPen(Qt::green, 1));
+        setPen(QPen(Qt::red, 1.5));
         setZValue(1);
     } else {
         setPen(QPen(Qt::black, 0.5));  // 未选中时恢复为黑色边框
@@ -80,8 +80,7 @@ void DieItem::updateAppearance() {
         default:            fillColor = Qt::gray; break;
         }
     }
-
-    setPen(QPen(Qt::black, 1));
+    setPen(QPen(Qt::black, 0.5));
     setBrush(fillColor);
     row = m_info.nDieRow;
     col = m_info.nDieCol;

+ 103 - 75
View/die-bonder-ui/CameraMaterialGroupWnd/MaterialWindow/Wafer.cpp

@@ -5,7 +5,7 @@
 #include <QDebug>
 #include <QPushButton>
 #include <QGridLayout>
-
+#include "ImageWidget.h"
 Wafer::Wafer(int flag, QWidget *parent) : QWidget(parent) {
    
 }
@@ -92,7 +92,7 @@ void Wafer::UpdataVal(const std::vector<ns_mat::WAFER_MATRIX_POINT_INFO_STRUCT>&
             if (a.stPosition.x >= maxx) maxx = a.stPosition.x;
             if (a.stPosition.y >= maxy) maxy = a.stPosition.y;
             if (a.stPosition.x <= minx) minx = a.stPosition.x;
-            if (a.stPosition.x <= miny) miny = a.stPosition.y;
+            if (a.stPosition.y <= miny) miny = a.stPosition.y;
         }
     }
     maxRow_Colmap.insert(currentDieMatrixId, { rowMax ,colsMax,minx,miny,maxx,maxy });
@@ -114,90 +114,105 @@ QColor Wafer::getColorByStatus(ns_mat::PICK_DIE_STATUS status) {
 void Wafer::paintInitFrom(QWidget *parent) {
     /*
     // 获取当前窗口的宽高
-    int width = parent->width();
-    int height = parent->height();
-    // 根据行列数计算每个晶圆点的大小,选择小的边来决定
-    int cellSize = qMin(width, height) / qMax(rows, cols); // 固定大小为正方形,按最小边计算
-    // 计算左上角偏移量,居中显示
-    int offsetX = (width - cellSize * cols) / 2;
-    int offsetY = (height - cellSize * rows) / 2;
+    double width, height;
+    width = 493;
+    height = 493;
 
-    // 创建一个 QPixmap 对象用于保存绘制的图像
-    globalPixmap = QPixmap(width, height);
-    globalPixmap.fill(Qt::white);  // 填充背景色为白色
 
-    // 创建 QPainter 以绘制到 QPixmap 上
-    QPainter painter(&globalPixmap);
-    painter.setRenderHint(QPainter::Antialiasing); // 启用抗锯齿
+    ImageWidget* Operatewidget;
+    Operatewidget = new ImageWidget();
+    
+    Operatewidget->setGeometry(QRect(0, 0, 493, 493));
 
-    // 设置画笔为无边框
-    painter.setPen(Qt::NoPen);
 
-    // 绘制每个晶圆点
-    for (int i = 0; i < waferData.size(); ++i) {
-        int x = offsetX + waferData[i].nDieCol * cellSize;
-        int y = offsetY + waferData[i].nDieRow * cellSize;
+    // 创建视图
+    scene = new QGraphicsScene(Operatewidget);
+    view = new WaferGraphicsView(scene);
+   //cene->setSceneRect(0, 0, 493, 493);
+    view->resize(width, height);
+    view->setCViewInterface(m_pCViewInterface);
+    //获取当前角度
+    double angle;
+    m_pCViewInterface->GetViewMatrix()->GetWaferTableAngle(angle);
+    QPointF center(width / 2.0, height / 2.0);
+    QPointF pointf(m_centerX, m_centerY);
+    double radius = width / 2 - 10;
+    //比例
+    double radio = m_radius / radius;
+    int dieLong = m_dieLong / radio;
+    int dieWide = m_dieWide / radio;
 
-        // 根据点的状态设置颜色
-        painter.setBrush(getColorByStatus(waferData[i].eStatus));
+    //test 实际使用时需要删除或注释
+    angle = 0.00;
+    // 初始化晶圆参数
+    view->initWafer(center, // 中心坐标
+        radius,              // 半径
+        dieLong, dieWide, angle);          // 固晶点显示尺寸
 
-        // 绘制晶圆点(每个点是一个矩形)
-        painter.drawRect(x, y, cellSize, cellSize);
-    }
+// 添加固晶点
+    int currentDieMatrixId = -1;
+    double referPointX = 0.0;
+    double referPointY = 0.0;
+    MaxRow_Col maxRow_Col;
+    double minx, miny, maxx, maxy, widthMatrix, heightMatrix;
+    for (int i = 0; i < waferData.size(); ++i) {
+        //判断是否属于同一个矩阵
+        if (waferData[i].nDieMatrixId != currentDieMatrixId) {
+            //重新画矩阵框然后配置新的参考点
+            currentDieMatrixId = waferData[i].nDieMatrixId;
+            referPointX = center.x() + (waferData[i].stPosition.x - m_centerX) / radio;
+            referPointY = center.y() - (waferData[i].stPosition.y - m_centerY) / radio;
+            maxRow_Col = maxRow_Colmap.value(currentDieMatrixId);
+            minx = center.x() + (maxRow_Col.minX - m_centerX) / radio - 20;
+            miny = center.y() - (maxRow_Col.minY - m_centerY) / radio + 20;
+            maxx = center.x() + (maxRow_Col.maxX - m_centerX) / radio + 20;
+            maxy = center.y() - (maxRow_Col.maxY - m_centerY) / radio - 20;
+            widthMatrix = maxx - minx;
+            heightMatrix = miny - maxy;
+            view->drawDieMatrix(QPointF(minx, maxy), widthMatrix, heightMatrix, currentDieMatrixId);
 
-    // 根据角度绘制黑点
-    int centerX, centerY;
-    int angle = 0;
-    switch (angle) {
-    case 0: {
-        centerX = offsetX + (cols / 2) * cellSize;
-        centerY = offsetY + (rows - 1) * cellSize;
-        break;
-    }
-    case 90: {
-        centerX = offsetX;
-        centerY = offsetY + (rows / 2) * cellSize;
-        break;
-    }
-    case 180: {
-        centerX = offsetX + (cols / 2) * cellSize;
-        centerY = offsetY;
-        break;
-    }
-    case 270: {
-        centerX = offsetX + (cols - 1) * cellSize;
-        centerY = offsetY + (rows / 2) * cellSize;
-        break;
-    }
-    default:
-        return;
+        }
+        referPointX = center.x() + (waferData[i].stPosition.x - m_centerX) / radio;
+        referPointY = center.y() - (waferData[i].stPosition.y - m_centerY) / radio;
+
+        view->addDiePoint(QPointF(referPointX, referPointY), waferData[i]);
     }
+    scene->setSceneRect(0, 0, view->width(), view->height());
 
-    painter.setBrush(Qt::black);
-    painter.drawEllipse(centerX - 3, centerY - 3, 6, 6);
-    painter.end(); // 结束绘制
+    int cur_width, cur_height;
+    cur_width = parent->width();
+    cur_height = parent->height();
+    // 创建一个 QPixmap 对象用于保存绘制的图像
+    globalPixmap = QPixmap(cur_width, cur_height);
+    globalPixmap.fill(Qt::white);  // 填充背景色为白色
+    QPixmap originalPixmap = QPixmap::grabWidget(view);
+    // 设置目标尺寸
+    QSize targetSize(cur_width, cur_height);
+
+    // 不保持比例,直接拉伸到指定尺寸
+    QPixmap scaledPixmap = originalPixmap.scaled(
+        targetSize,
+        Qt::IgnoreAspectRatio,
+        Qt::SmoothTransformation
+    );
+    globalPixmap = scaledPixmap;
     */
 }
 
 void Wafer::initFrom(QWidget* parent) {
-    //scene = new QGraphicsScene(parent);
-    //view = new WaferGraphicsView(scene);
-
-    //// 获取当前窗口的宽高
-    double width = parent->width();
-    double height = parent->height();
 
-    //// 根据行列数计算每个晶圆点的大小,选择小的边来决定
-    //int cellSize = qMin(width, height) / qMax(rows, cols); // 固定大小为正方形,按最小边计算
-
-    //for (int i = 0; i < waferData.size(); ++i) {
-    //    DieItem* die = new DieItem(waferData[i].nDieRow, waferData[i].nDieCol, waferData[i].eStatus, cellSize);
-    //    die->setPos(waferData[i].nDieCol * cellSize, waferData[i].nDieRow * cellSize);
-    //    scene->addItem(die);
-    //}
+    // 获取当前窗口的宽高
+    double width, height;
+    if (parent == nullptr) {
+        width = 493;
+        height = 493;
+    }
+    else {
+        width = parent->width();
+        height = parent->height();
+    }
 
-    //view->setSceneRect(scene->itemsBoundingRect());
-    //view->resize(width, height);
+   
 
     // 创建视图
     scene = new QGraphicsScene(parent);
@@ -248,12 +263,26 @@ void Wafer::initFrom(QWidget* parent) {
         referPointX = center.x() + (waferData[i].stPosition.x - m_centerX) / radio;
         referPointY = center.y() - (waferData[i].stPosition.y - m_centerY) / radio;
 
-        //test
-        //referPointX = i * 5;
-        //referPointY = i * 5;
+
         view->addDiePoint(QPointF(referPointX, referPointY),waferData[i]);
     }
     scene->setSceneRect(0, 0, view->width(), view->height());
+
+
+    // 创建一个 QPixmap 对象用于保存绘制的图像
+    globalPixmap = QPixmap(width, height);
+    globalPixmap.fill(Qt::white);  // 填充背景色为白色
+    QPixmap originalPixmap = QPixmap::grabWidget(view);
+    // 设置目标尺寸(例如:宽度 200,高度 150)
+    QSize targetSize(width, height);
+
+    // 不保持比例,直接拉伸到指定尺寸
+    QPixmap scaledPixmap = originalPixmap.scaled(
+       targetSize,
+       Qt::IgnoreAspectRatio,
+       Qt::SmoothTransformation
+    );
+    globalPixmap = scaledPixmap;
     
     
 }
@@ -267,7 +296,6 @@ void Wafer::setWaferInfo(ns_module::CViewInterface* CViewInterface) {
     long result = m_pCViewInterface->GetViewMatrix()->GetDieSize(m_dieLong,m_dieWide);
 
    m_pCViewInterface->GetViewMatrix()->GetWaferSize(m_centerX, m_centerY,m_radius);
-
     //这里到时候更新接口时替换真实圆心点的数据
     /*m_dieLong = 10;
     m_dieWide = 10;*/

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

@@ -22,7 +22,7 @@ public:
     void setCViewInterface(ns_module::CViewInterface* CViewInterface);
     QPixmap convertToPixmap(const ImageInfo& imgData);
     void yuv422_to_rgb888(const unsigned char* src, unsigned char* dst, int width, int height);
-
+    QGraphicsScene* m_scene;
 protected:
     void mousePressEvent(QMouseEvent* event) override;
     void mouseMoveEvent(QMouseEvent* event) override;
@@ -47,7 +47,7 @@ private:
     QPointer<DieItem> topLeftItem;
     QPointer<DieItem> bottomRightItem;
 
-    QGraphicsScene* m_scene;
+    
     QPointF m_center;
     double m_radius;
     QSize m_dieSize;

+ 2 - 0
View/die-bonder-ui/OriginalWnd/ChartsAndCamerasWnd.cpp

@@ -295,6 +295,8 @@ void ChartsAndCamerasWnd::initFrom() {
             if (manager->getWafer())
             {
                 waferMap.insert(num, manager->getWafer());
+                ui->viewwidgetgroup->setWafer(waferMap.value(i + 1));
+                m_allGroup[i]->setWaferWidget(ui->viewwidgetgroup->getWafer()->getGlobalPixmap());
             }
             if (manager->getWaffle())
             {

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

@@ -124,6 +124,8 @@ void MainAndSecondaryCamerasWnd::InitPage()
             if (manager->getWafer())
             {
                 m_mapWaferMap.insert(num, manager->getWafer());
+                ui->viewwidgetgroup_L->setWafer(m_mapWaferMap.value(i + 1));
+                m_allGroup[i]->setWaferWidget(ui->viewwidgetgroup_L->getWafer()->getGlobalPixmap());
             }
             if (manager->getWaffle()) {
                 m_mapWaffleMap.insert(num, manager->getWaffle());
@@ -327,7 +329,6 @@ void MainAndSecondaryCamerasWnd::initLeftAndRightWidget() {
 void MainAndSecondaryCamerasWnd::BindImageOrMaterial(int location, int index) {
     if (location == m_nLastLeft) {
         if (index == m_nImageIndex) {
-
             m_veCurrentSelectGroup_L.isBond = true;
             connect(m_veCurrentSelectGroup_L.pSelectGroup, &Group::SetUpDataImageShowSig,
                 this, &MainAndSecondaryCamerasWnd::GetGroupImageShowSignalsTo_L);

+ 2 - 0
View/die-bonder-ui/OriginalWnd/SingleCameraOperationWnd.cpp

@@ -87,6 +87,8 @@ void SingleCameraOperationWnd::initFrom() {
             }
             if (manager->getWafer()) {
                 waferMap.insert(num, manager->getWafer());
+                ui->viewwidgetgroup->setWafer(waferMap.value(i + 1));
+                m_allGroup[i]->setWaferWidget(ui->viewwidgetgroup->getWafer()->getGlobalPixmap());
             }
             if (manager->getWaffle()) {
                 waffleMap.insert(num, manager->getWaffle());

+ 4 - 0
View/die-bonder-ui/Src/RewriteControl/ControlOperationPage.cpp

@@ -222,6 +222,10 @@ void ControlOperationPage::KindsofWidget(kinds kind)
     }
 }
 
+Wafer* ControlOperationPage::getWafer() {
+    return m_wafer;
+}
+
 void ControlOperationPage::setWafer(Wafer* wafer) {
     m_wafer = wafer;
     updateMaterialWidget(wafer_kind);

+ 1 - 0
View/die-bonder-ui/Src/RewriteControl/ControlOperationPage.h

@@ -51,6 +51,7 @@ public:
     void setScaleFactorSize(QPixmap scaledImage);
     void setComboBox(const QList<QPair<QString, QString>> fileList, const int index);
     void setEnableControls(bool enable);
+    Wafer* getWafer();
 
     /**更新硬件指针
      */