Browse Source

update code version by ren_chaolun

ren_chaolun* 1 tháng trước cách đây
mục cha
commit
817d1fca1e

+ 12 - 3
CInterface.h

@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
 #include <vector>
 #include <string>
 
@@ -172,12 +172,21 @@ typedef struct
     //PROCESS_INFO_STRUCT stBondInfo;
 } POINT_INFO_STRUCT;
 
+
+
 typedef struct
 {
+    int iCurrLayers;				//当前工作层
     int iLayersTotal;               //总层数
     int iTopLev;                    //最上层高度
     int iBottomLev;                 //最下层高度
-    XY_DOUBLE_STRUCT stPos;         //料盒位置
+    XY_DOUBLE_STRUCT stPos;         //料盒位置;
+    int iStatas[32];				//每层状态,0表示空,1表示有料。
+    int iLength;                    //料盒长度
+    int iLeight;                    //料盒高度
+    int iWall;                      //侧壁厚
+    int iTopWall;                   //上壁厚
+    int iBelowWall;                 //下壁厚
 }MATERIAL_BOX_STRUCT;
 
 typedef struct
@@ -501,7 +510,7 @@ public:
     /// </summary>
     /// <param name="stPointInfo">晶圆信息</param>
     /// <returns>成功返回0,否则返回错误码</returns>
-    long GetMaterialBoxAllPointInfo(vector<MATERIAL_BOX_STRUCT>& stPointInfo);
+    long GetMaterialBoxAllPointInfo(MATERIAL_BOX_STRUCT& stPointInfo);
 
     /// <summary>
     /// 移动到指定的层

+ 6 - 1
CameraMaterialGroupWnd/CameraImage/CameraImageHandler.cpp

@@ -63,6 +63,10 @@ Waffle* CameraImageHandler::getWaffle() const{
     return waffle;
 }
 
+MaterialBox* CameraImageHandler::getMaterialBox() const{
+    return materialBox;
+}
+
 void CameraImageHandler::initGroup(int CameraId) {
     QStringList dispmodel1;
     dispmodel1 << "P die align" << "D device align";
@@ -86,7 +90,7 @@ void CameraImageHandler::initGroup(int CameraId) {
         group = new Group(CameraId, ":/images/test_image/image_3.png", MaterialWindowType, dispmodel2, this);
     } else if (CameraId == 3) {
         MaterialWindowType = 3;
-        waffle = new Waffle(0);
+        materialBox = new MaterialBox(0);
         group = new Group(CameraId, ":/images/test_image/image_5.png", MaterialWindowType, dispmodel3, this);
     } else if (CameraId == 4) {
         MaterialWindowType = 1;
@@ -101,6 +105,7 @@ void CameraImageHandler::initGroup(int CameraId) {
         waffle = new Waffle(0);
         group = new Group(CameraId, ":/images/test_image/image_3.png", MaterialWindowType, dispmodel2, this);
     } else if (CameraId == 7) {
+        materialBox = new MaterialBox(0);
         MaterialWindowType = 3;
         group = new Group(CameraId, ":/images/test_image/image_5.png", MaterialWindowType, dispmodel3, this);
     } else if (CameraId == 8) {

+ 5 - 1
CameraMaterialGroupWnd/CameraImage/CameraImageHandler.h

@@ -1,8 +1,9 @@
-#ifndef CAMERAIMAGEHANDLER_H
+#ifndef CAMERAIMAGEHANDLER_H
 #define CAMERAIMAGEHANDLER_H
 #include "CameraMaterialGroupWnd/Group.h"
 #include "CameraMaterialGroupWnd/MaterialWindow/Wafer.h"
 #include "CameraMaterialGroupWnd/MaterialWindow/Waffle.h"
+#include "CameraMaterialGroupWnd/MaterialWindow/MaterialBox.h"
 
 
 class CameraImageHandler : public QWidget {
@@ -13,6 +14,8 @@ public:
     Group* getGroup() const;
     Wafer* getWafer() const;
     Waffle* getWaffle() const;
+    MaterialBox* getMaterialBox() const;
+
 
 private:
     void captureAndConvertImage(int CameraId);
@@ -20,6 +23,7 @@ private:
     void initGroup(int CameraId);
     Wafer* wafer;
     Waffle* waffle;
+    MaterialBox* materialBox;
 
     int MaterialWindowType; // 物料窗口类型标识,1代表圆晶 后面接口获取标识
 };

+ 8 - 8
CameraMaterialGroupWnd/Group.cpp

@@ -1,4 +1,4 @@
-#include "Group.h"
+#include "Group.h"
 #include "ui_Group.h"
 #include <QDebug>
 #include <QMouseEvent>
@@ -43,7 +43,7 @@ Group::Group(int Id, const QString& imagePath1, int MaterialWindowType, const QS
         waffle = new Waffle(0, ui->Imagewidget_right);
         WaffleWidget();
     } else if (MaterialWindowType == 3) {
-        materialbox = new MaterialBox(0, ui->Imagewidget_right);
+        materialbox = new MaterialBox(0,ui->Imagewidget_right);
         MaterialBoxWidget();
     }
 
@@ -143,11 +143,6 @@ void Group::WaferWidget()
 
 void Group::WaffleWidget()
 {
-    // QVBoxLayout *layout2 = new QVBoxLayout(ui->Imagewidget_right);
-    // ui->Imagewidget_right->setLayout(layout2);
-    // ui->Imagewidget_right->setFixedSize(110, 110);
-    // layout2->setContentsMargins(0, 0, 0, 0);
-    // layout2->addWidget(waffle);
     QVBoxLayout *layout2 = new QVBoxLayout(ui->Imagewidget_right);
     waffle->paintInitFrom(ui->Imagewidget_right);
 
@@ -163,10 +158,15 @@ void Group::WaffleWidget()
 void Group::MaterialBoxWidget()
 {
     QVBoxLayout *layout2 = new QVBoxLayout(ui->Imagewidget_right);
+    materialbox->paintInitFrom(ui->Imagewidget_right);
+
+    QLabel* pixmapLabel = new QLabel();
+    pixmapLabel->setPixmap(materialbox->getGlobalPixmap());
+
     ui->Imagewidget_right->setLayout(layout2);
     ui->Imagewidget_right->setFixedSize(110, 110);
     layout2->setContentsMargins(0, 0, 0, 0);
-    layout2->addWidget(materialbox);
+    layout2->addWidget(pixmapLabel);
 }
 
 void Group::onclickbutton(){

+ 1 - 0
CameraMaterialGroupWnd/MaterialWindow/Bond.cpp

@@ -0,0 +1 @@
+#include "Bond.h"

+ 31 - 0
CameraMaterialGroupWnd/MaterialWindow/Bond.h

@@ -0,0 +1,31 @@
+#ifndef BOND_H
+#define BOND_H
+#include <QApplication>
+#include <QWidget>
+#include <QPainter>
+#include <QMouseEvent>
+#include <vector>
+#include <QString>
+#include <QDebug>
+#include "CInterface.h"
+#include "BondGraphicsView.h"
+#include <QFrame>
+// 自定义绘制窗口类
+class Bond : public QWidget {
+public:
+    Bond(int flag, QWidget *parent = nullptr);
+    void paintInitFrom(QWidget *parent);
+    QPixmap getGlobalPixmap() const;
+    void initFrom(QWidget *parent);
+    BondGraphicsView* view;
+    QGraphicsScene* scene;
+private slots:
+    void handleLayerRightClicked(int layer);
+protected:
+    void paintEvent(QPaintEvent *event) override;
+
+private:
+    MATERIAL_BOX_STRUCT boxes; // 所有料盒的数据
+    QPixmap globalPixmap;
+};
+#endif // BOND_H

+ 380 - 0
CameraMaterialGroupWnd/MaterialWindow/BondGraphicsView.cpp

@@ -0,0 +1,380 @@
+#include "BondGraphicsView.h"
+#include <QDebug>
+#include <QScrollBar>
+
+BondGraphicsView::BondGraphicsView(QGraphicsScene* scene, QWidget* parent)
+    : QGraphicsView(scene, parent), selecting(false), selectionRect(nullptr),
+    scaleFactor(1.0), isDragging(false), thumbnailLabel(nullptr),
+    thumbnailVisible(false) {
+    setRenderHint(QPainter::Antialiasing);
+    // setDragMode(QGraphicsView::ScrollHandDrag); // 支持拖动视图
+    setTransformationAnchor(QGraphicsView::AnchorUnderMouse); // 缩放时以鼠标为中心
+    // 初始化缩略图标签
+    thumbnailLabel = new QLabel(this);
+    thumbnailLabel->setFixedSize(150, 150);
+    thumbnailLabel->move(0, 0);  // 默认左上角位置
+    thumbnailLabel->setStyleSheet("background-color: white; border: 1px solid gray;");
+    thumbnailLabel->installEventFilter(this);
+    thumbnailLabel->hide();
+
+    topLeftIndex = qMakePair(-1, -1);
+    bottomRightIndex = qMakePair(-1, -1);
+}
+
+// 事件过滤器用于处理缩略图拖动
+bool BondGraphicsView::eventFilter(QObject *obj, QEvent *event) {
+    static QPoint dragStartPosition;
+    if (obj == thumbnailLabel) {
+        if (event->type() == QEvent::MouseButtonPress) {
+            QMouseEvent *me = static_cast<QMouseEvent*>(event);
+            dragStartPosition = me->pos();
+            return true;
+        } else if (event->type() == QEvent::MouseMove) {
+            QMouseEvent *me = static_cast<QMouseEvent*>(event);
+
+            // 计算新位置
+            QPoint newPos = thumbnailLabel->pos() + (me->pos() - dragStartPosition);
+
+            // 限制在视图范围内
+            int maxX = this->width() - thumbnailLabel->width();
+            int maxY = this->height() - thumbnailLabel->height();
+
+            // 使用qBound限制坐标范围(0 <= x <= maxX,0 <= y <= maxY)
+            newPos.setX(qBound(0, newPos.x(), maxX));
+            newPos.setY(qBound(0, newPos.y(), maxY));
+
+            thumbnailLabel->move(newPos);
+            return true;
+        }
+    }
+    return QGraphicsView::eventFilter(obj, event);
+}
+
+void BondGraphicsView::mousePressEvent(QMouseEvent* event) {
+    if (event->button() == Qt::LeftButton) {
+        // 清空选中的 DieItem
+        for (auto& item : selectedItemsMap) {
+            DieItem* die = dynamic_cast<DieItem*>(item);
+            if (die) {
+                die->setSelected(false); // 取消选中状态
+            }
+        }
+        selectedItemsMap.clear();
+
+        if (topLeftItem && topLeftItem->scene()) {
+            topLeftItem->setRightSelected(false);
+        }
+        topLeftItem.clear();
+
+        if (bottomRightItem && bottomRightItem->scene()) {
+            bottomRightItem->setRightSelected(false);
+        }
+        bottomRightItem.clear();
+        topLeftIndex = qMakePair(-1, -1);
+        bottomRightIndex = qMakePair(-1, -1);
+        // 获取点击位置的 DieItem
+        if (selectedItem && selectedItem->scene()) {
+            selectedItem->setLeftSelected(false);
+        }
+        selectedItem.clear();
+        QGraphicsItem* item = itemAt(event->pos());
+        if (item) {
+            selectedItem = dynamic_cast<DieItem*>(item);
+            selectedItem->setLeftSelected(true);
+
+        }
+
+        setCursor(Qt::OpenHandCursor);  // 按下时设置为小手
+        selecting = true;
+        lastPos = event->pos();  // 记录鼠标位置
+    } else if (event->button() == Qt::RightButton) {
+        // 开始框选
+        selecting = true;
+        selectionStart = mapToScene(event->pos());
+        isDragging = false;
+        if (!selectionRect) {
+            selectionRect = new QGraphicsRectItem();
+            selectionRect->setPen(QPen(Qt::NoPen));
+            selectionRect->setBrush(QBrush(QColor(0, 0, 255, 50))); // 半透明蓝色
+            scene()->addItem(selectionRect);
+        }
+        selectionRect->setRect(QRectF(selectionStart, QSizeF()));
+    }
+    QGraphicsView::mousePressEvent(event);
+}
+
+void BondGraphicsView::mouseMoveEvent(QMouseEvent* event) {
+    if (selecting && selectionRect) {
+        QPointF currentPos = mapToScene(event->pos());
+        selectionRect->setRect(QRectF(selectionStart, currentPos).normalized());
+        isDragging = true;
+    } else if (selecting) {
+        // 计算鼠标当前位置与上次位置的差值
+        QPointF delta = event->pos() - lastPos;
+        // 平移视图
+        horizontalScrollBar()->setValue(horizontalScrollBar()->value() - delta.x());
+        verticalScrollBar()->setValue(verticalScrollBar()->value() - delta.y());
+        lastPos = event->pos();  // 更新鼠标位置
+    }
+    QGraphicsView::mouseMoveEvent(event);
+}
+
+void BondGraphicsView::mouseReleaseEvent(QMouseEvent* event) {
+    if (event->button() == Qt::LeftButton) {
+        setCursor(Qt::ArrowCursor);  // 松开时恢复为箭头
+        selecting = false;
+    } else if (event->button() == Qt::RightButton && selecting) {
+        selecting = false;
+        if (selectionRect && isDragging) {
+            if (selectedItem && selectedItem->scene()) {
+                selectedItem->setLeftSelected(false);
+            }
+            selectedItem.clear();
+
+            if (topLeftItem && topLeftItem->scene()) {
+                topLeftItem->setRightSelected(false);
+            }
+            topLeftItem.clear();
+
+            if (bottomRightItem && bottomRightItem->scene()) {
+                bottomRightItem->setRightSelected(false);
+            }
+            bottomRightItem.clear();
+            topLeftIndex = qMakePair(-1, -1);
+            bottomRightIndex = qMakePair(-1, -1);
+            QRectF selectedArea = selectionRect->rect();
+            scene()->removeItem(selectionRect);
+            delete selectionRect;
+            selectionRect = nullptr;
+
+            QList<QGraphicsItem*> items = scene()->items(selectedArea, Qt::IntersectsItemShape);
+            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 (selectionRect) {
+            scene()->removeItem(selectionRect);
+            delete selectionRect;
+            selectionRect = nullptr;
+        }
+        // 如果没有进行拖动,则弹出右键菜单
+        if (!isDragging) {
+            QGraphicsItem* item = itemAt(event->pos());
+            DieItem* die = dynamic_cast<DieItem*>(item);
+            QMenu menu;
+            QAction* showThumb = menu.addAction(thumbnailVisible ? "隐藏缩略图" : "显示缩略图");
+
+
+            connect(showThumb, &QAction::triggered, [this]{
+                thumbnailVisible ? hideThumbnail() : showThumbnail();
+            });
+            menu.addAction("发送位置", [this] {
+                if (selectedItem) {
+                    qDebug() << "Row:" << selectedItem->getRow() << "Col:" << selectedItem->getCol();
+                    selectedItem->setLeftSelected(false);
+                    selectedItem = nullptr;
+                }
+            });
+            if (die) {
+                menu.addAction("移动到该位置", [this, die] {
+                    for (auto& item : selectedItemsMap) {
+                        DieItem* die = dynamic_cast<DieItem*>(item);
+                        if (die) {
+                            die->setSelected(false);
+                        }
+                    }
+                    selectedItemsMap.clear();
+
+                    if (topLeftItem && topLeftItem->scene()) {
+                        topLeftItem->setRightSelected(false);
+                    }
+                    topLeftItem.clear();
+
+                    if (bottomRightItem && bottomRightItem->scene()) {
+                        bottomRightItem->setRightSelected(false);
+                    }
+                    bottomRightItem.clear();
+                    topLeftIndex = qMakePair(-1, -1);
+                    bottomRightIndex = qMakePair(-1, -1);
+
+                    if (selectedItem && selectedItem->scene()) {
+                        selectedItem->setLeftSelected(false);
+                    }
+                    selectedItem.clear();
+
+                    selectedItem = die;
+                    selectedItem->setLeftSelected(true);
+                });
+
+                // 设置区域边界点菜单
+                menu.addAction("设为左上点", [this, die] {
+                    if (topLeftItem && topLeftItem->scene()) {
+                        topLeftItem->setRightSelected(false);
+                    }
+                    topLeftItem.clear();
+                    topLeftItem = die;
+                    topLeftItem->setRightSelected(true);
+                    topLeftIndex = qMakePair(die->getRow(), die->getCol());
+                    if (bottomRightIndex.first >= 0) checkAndCreateRegion();
+                });
+
+                menu.addAction("设为右下点", [this, die] {
+                    if (bottomRightItem && bottomRightItem->scene()) {
+                        bottomRightItem->setRightSelected(false);
+                    }
+                    bottomRightItem.clear();
+                    bottomRightItem = die;
+                    bottomRightItem->setRightSelected(true);
+                    bottomRightIndex = qMakePair(die->getRow(), die->getCol());
+                    if (topLeftIndex.first >= 0) checkAndCreateRegion();
+                });
+            }
+
+            menu.addAction("清除选中区域", [this] { clearRegion(); });
+            menu.addAction("设置区域", [this] { setRegion(); });
+
+            menu.exec(event->globalPos());
+        }
+    }
+    QGraphicsView::mouseReleaseEvent(event);
+}
+
+void BondGraphicsView::wheelEvent(QWheelEvent* event) {
+    if (event->orientation() == Qt::Vertical) {
+        event->ignore(); // 忽略竖直滚轮事件(即禁用滚动条滑动)
+        return;
+    }
+    event->accept();
+}
+
+// 缩略图功能实现
+void BondGraphicsView::showThumbnail() {
+    // 本地图片路径(根据实际路径修改)
+    QString imagePath = ":/images/test_image/image_1.png";  // 替换为本地图片路径
+
+    // 加载本地图片
+    QPixmap thumb(imagePath);
+
+    if (!thumb.isNull()) {
+        // 如果图片加载成功,设置为缩略图
+        thumbnailLabel->setPixmap(thumb.scaled(150, 150, Qt::KeepAspectRatio));
+        thumbnailLabel->show();
+        thumbnailVisible = true;
+    } else {
+        // 如果加载图片失败,显示"图片加载失败"
+        thumbnailLabel->setText("图片加载失败");
+        thumbnailLabel->setAlignment(Qt::AlignCenter);  // 居中显示文本
+        thumbnailLabel->show();
+        thumbnailVisible = true;
+    }
+}
+
+void BondGraphicsView::hideThumbnail() {
+    thumbnailLabel->hide();
+    thumbnailVisible = false;
+    thumbnailLabel->move(0, 0);
+}
+void BondGraphicsView::checkAndCreateRegion()
+{
+    // 仅当两个点都有效时处理
+    if (topLeftIndex.first < 0 || bottomRightIndex.first < 0) return;
+
+    // 确定行列范围
+    int startRow = qMin(topLeftIndex.first, bottomRightIndex.first);
+    int endRow = qMax(topLeftIndex.first, bottomRightIndex.first);
+    int startCol = qMin(topLeftIndex.second, bottomRightIndex.second);
+    int endCol = qMax(topLeftIndex.second, bottomRightIndex.second);
+
+    // 遍历场景中的所有项
+    foreach (QGraphicsItem* item, scene()->items()) {
+        if (DieItem* die = dynamic_cast<DieItem*>(item)) {
+            int row = die->getRow();
+            int col = die->getCol();
+
+            // 判断是否在区域内
+            if (row >= startRow && row <= endRow &&
+                col >= startCol && col <= endCol) {
+
+                // 更新选中状态
+                die->setSelected(true);
+                selectedItemsMap.insert(qMakePair(row, col), die);
+            }
+        }
+    }
+
+    // 重置索引点
+    topLeftIndex = qMakePair(-1, -1);
+    bottomRightIndex = qMakePair(-1, -1);
+
+}
+
+void BondGraphicsView::clearRegion()
+{
+    // 清空选中的 DieItem
+    for (auto& item : selectedItemsMap) {
+        DieItem* die = dynamic_cast<DieItem*>(item);
+        if (die) {
+            die->setSelected(false); // 取消选中状态
+        }
+    }
+    selectedItemsMap.clear();
+
+    if (selectedItem && selectedItem->scene()) {
+        selectedItem->setLeftSelected(false);
+    }
+    selectedItem.clear();
+
+    if (topLeftItem && topLeftItem->scene()) {
+        topLeftItem->setRightSelected(false);
+    }
+    topLeftItem.clear();
+
+    if (bottomRightItem && bottomRightItem->scene()) {
+        bottomRightItem->setRightSelected(false);
+    }
+    bottomRightItem.clear();
+    topLeftIndex = qMakePair(-1, -1);
+    bottomRightIndex = qMakePair(-1, -1);
+
+    // 清除缩略图
+    hideThumbnail();
+
+}
+void BondGraphicsView::setRegion()
+{
+    for (auto it = selectedItemsMap.begin(); it != selectedItemsMap.end(); ++it) {
+        QPair<int, int> key = it.key();  // 获取当前元素的 key
+        qDebug() << "Row:" << key.first << ", Col:" << key.second;
+    }
+
+    // 清空选中的 DieItem
+    for (auto& item : selectedItemsMap) {
+        DieItem* die = dynamic_cast<DieItem*>(item);
+        if (die) {
+            die->setSelected(false); // 取消选中状态
+        }
+    }
+    selectedItemsMap.clear();
+
+    if (selectedItem && selectedItem->scene()) {
+        selectedItem->setLeftSelected(false);
+    }
+    selectedItem.clear();
+
+    if (topLeftItem && topLeftItem->scene()) {
+        topLeftItem->setRightSelected(false);
+    }
+    topLeftItem.clear();
+
+    if (bottomRightItem && bottomRightItem->scene()) {
+        bottomRightItem->setRightSelected(false);
+    }
+    bottomRightItem.clear();
+    topLeftIndex = qMakePair(-1, -1);
+    bottomRightIndex = qMakePair(-1, -1);
+}

+ 52 - 0
CameraMaterialGroupWnd/MaterialWindow/BondGraphicsView.h

@@ -0,0 +1,52 @@
+#ifndef BONDGRAPHICSVIEW_H
+#define BONDGRAPHICSVIEW_H
+#include <QGraphicsView>
+#include <QGraphicsScene>
+#include <QGraphicsRectItem>
+#include <QMouseEvent>
+#include "DieItem.h"
+#include <QLabel>
+#include <QPointer>
+
+class BondGraphicsView : public QGraphicsView {
+    Q_OBJECT
+
+public:
+    BondGraphicsView(QGraphicsScene* scene, QWidget* parent = nullptr);
+
+
+protected:
+    void mousePressEvent(QMouseEvent* event) override;
+    void mouseMoveEvent(QMouseEvent* event) override;
+    void mouseReleaseEvent(QMouseEvent* event) override;
+    void wheelEvent(QWheelEvent* event) override;
+    bool eventFilter(QObject *obj, QEvent *event) override;
+
+private:
+    bool selecting; // 是否正在框选
+    QPoint lastPos;
+    QPointF selectionStart; // 框选起点
+    QGraphicsRectItem* selectionRect; // 框选矩形
+    double scaleFactor; // 当前缩放比例
+    bool isDragging = false;
+    QMap<QPair<int, int>, QGraphicsItem*> selectedItemsMap;
+    QLabel *thumbnailLabel; // 缩略图标签
+    bool thumbnailVisible; // 缩略图可见状态
+
+    QPair<int, int> topLeftIndex;
+    QPair<int, int> bottomRightIndex;
+    QPointer<DieItem> selectedItem;
+    QPointer<DieItem> topLeftItem;
+    QPointer<DieItem> bottomRightItem;
+
+    void showThumbnail();
+    void hideThumbnail();
+
+    void checkAndCreateRegion();
+    void clearRegion();
+    void setRegion();
+};
+
+
+
+#endif // BONDGRAPHICSVIEW_H

+ 40 - 0
CameraMaterialGroupWnd/MaterialWindow/DraggableLine.cpp

@@ -0,0 +1,40 @@
+#include "DraggableLine.h"
+void DraggableLine::mousePressEvent(QGraphicsSceneMouseEvent* event) {
+    // 判断点击的是起点还是终点
+    QPointF clickPos = event->pos();
+    if (distance(clickPos, line().p1()) < 10) {
+        draggingStart = true;
+    } else if (distance(clickPos, line().p2()) < 10) {
+        draggingEnd = true;
+    }
+}
+
+void DraggableLine::mouseMoveEvent(QGraphicsSceneMouseEvent* event)  {
+    if (draggingStart) {
+        // 更新起点坐标
+        QLineF newLine(event->scenePos(), line().p2());
+        setLine(newLine);
+    } else if (draggingEnd) {
+        // 更新终点坐标
+        QLineF newLine(line().p1(), event->scenePos());
+        setLine(newLine);
+    }
+    update();
+}
+void DraggableLine::mouseReleaseEvent(QGraphicsSceneMouseEvent*)  {
+    draggingStart = draggingEnd = false;
+}
+
+void DraggableLine::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) {
+    painter->setPen(QPen(Qt::blue, 2));
+    painter->drawLine(line());
+
+    // 绘制可拖拽端点
+    painter->setBrush(Qt::red);
+    painter->drawEllipse(line().p1(), 5, 5);
+    painter->drawEllipse(line().p2(), 5, 5);
+}
+
+double DraggableLine::distance(const QPointF& p1, const QPointF& p2) {
+    return QLineF(p1, p2).length();
+}

+ 48 - 0
CameraMaterialGroupWnd/MaterialWindow/DraggableLine.h

@@ -0,0 +1,48 @@
+#ifndef DRAGGABLELINE_H
+#define DRAGGABLELINE_H
+#include <QApplication>
+#include <QWidget>
+#include <QPainter>
+#include <QMouseEvent>
+#include <QString>
+#include <QGraphicsView>
+#include <QGraphicsScene>
+#include <QGraphicsRectItem>
+#include <QMouseEvent>
+#include <QLabel>
+#include <QPointer>
+#include <QGraphicsItem>
+#include <QPainter>
+#include <QColor>
+#include <QGraphicsSceneEvent>
+#include <QDebug>
+#include <QFrame>
+
+// 1. 创建自定义线段类(继承QGraphicsLineItem)
+class DraggableLine : public QGraphicsLineItem {
+public:
+    explicit DraggableLine(QGraphicsItem* parent = nullptr)
+        : QGraphicsLineItem(parent) {
+        setFlag(QGraphicsItem::ItemIsMovable, false); // 禁用整体移动
+        setAcceptHoverEvents(true);
+    }
+
+    // 2. 鼠标事件处理
+protected:
+    void mousePressEvent(QGraphicsSceneMouseEvent* event) override;
+
+    void mouseMoveEvent(QGraphicsSceneMouseEvent* event) override;
+
+    void mouseReleaseEvent(QGraphicsSceneMouseEvent*) override;
+
+    // 3. 可视化增强(绘制端点)
+    void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) override ;
+
+private:
+    bool draggingStart = false;
+    bool draggingEnd = false;
+
+    double distance(const QPointF& p1, const QPointF& p2);
+};
+
+#endif // DRAGGABLELINE_H

+ 116 - 93
CameraMaterialGroupWnd/MaterialWindow/MaterialBox.cpp

@@ -1,32 +1,18 @@
-#include "MaterialBox.h"
+#include "MaterialBox.h"
 
 // 构造函数
 MaterialBox::MaterialBox(int flag, QWidget *parent) : QWidget(parent) {
     // 初始化料盒数据
     boxes = {
-        Material_box("Box 1", Idle),
-        Material_box("Box 2", Occupied),
-        Material_box("Box 3", Warning),
-        Material_box("Box 4", Idle),
-        Material_box("Box 5", Occupied),
-        Material_box("Box 6", Warning)
+        2,      // iCurrLayers
+        32,      // iLayersTotal
+        100,    // iTopLev
+        50,     // iBottomLev
+        {15.5, 20.3}, // 补全所有子成员
+        {1,0,1,1,0},
+        // ...后续成员保持相同
     };
 
-    // 根据不同窗口设置不同大小 0:小 1:中 2:大
-    // if (flag == 0) {
-    //     boxWidth = 30;  // 每个料盒的宽度
-    //     boxHeight = 18;  // 每个料盒的高度
-    //     gap = 10;        // 料盒之间的间距
-    // } else if (flag == 1) {
-    //     boxWidth = 50;  // 每个料盒的宽度
-    //     boxHeight = 18;  // 每个料盒的高度
-    //     gap = 10;
-    // } else if (flag == 2) {
-    //     boxWidth = 30;  // 每个料盒的宽度
-    //     boxHeight = 18;  // 每个料盒的高度
-    //     gap = 10;
-    // }
-
 }
 
 // 绘制事件
@@ -37,77 +23,114 @@ void MaterialBox::paintEvent(QPaintEvent *event) {
     // 设置背景颜色
     painter.fillRect(this->rect(), Qt::white);
 
-    // 网格参数
-    int boxWidth = 30;  // 每个料盒的宽度
-    int boxHeight = 18;  // 每个料盒的高度
-    int gap = 10;        // 料盒之间的间距
-    int cols = 3;        // 每行的列数
-
-    // 计算料盒的总宽度和总高度
-    int totalWidth = cols * boxWidth + (cols - 1) * gap;
-    int rows = (boxes.size() + cols - 1) / cols;  // 计算总行数
-    int totalHeight = rows * boxHeight + (rows - 1) * gap;
-
-    // 计算料盒的起始位置(居中显示)
-    int startX = (width() - totalWidth) / 2;
-    int startY = (height() - totalHeight) / 2;
-
-    // 绘制所有料盒
-    for (size_t i = 0; i < boxes.size(); ++i) {
-        int row = i / cols; // 当前料盒所在的行
-        int col = i % cols; // 当前料盒所在的列
-        int x = startX + col * (boxWidth + gap);
-        int y = startY + row * (boxHeight + gap);
-
-        // 绘制料盒外框
-        QRect boxRect(x, y, boxWidth, boxHeight);
-        painter.setPen(Qt::black);
-        painter.drawRect(boxRect);
-
-        // 根据状态设置填充颜色
-        switch (boxes[i].status) {
-        case Idle:
-            painter.setBrush(Qt::green); // 空闲状态:绿色
-            break;
-        case Occupied:
-            painter.setBrush(Qt::blue);  // 已占用状态:蓝色
-            break;
-        case Warning:
-            painter.setBrush(Qt::red);   // 警告状态:红色
-            break;
-        }
-        painter.fillRect(boxRect, painter.brush());
-
-        // 在料盒中绘制名称
-        painter.setPen(Qt::white); // 设置文字颜色为白色
-        painter.drawText(boxRect, Qt::AlignCenter, boxes[i].name);
+
+
+
+}
+void MaterialBox::paintInitFrom(QWidget *parent) {
+
+
+    // 主容器尺寸(占窗口80%)
+    const int containerWidthdp = parent->width() * 0.25;
+    const int containerHeightdp = parent->height() * 0.05;
+    const int containerWidth = parent->width() * 0.5;
+    const int containerHeight = parent->height() *0.9;
+
+    globalPixmap = QPixmap(parent->width(), parent->height());
+    globalPixmap.fill(Qt::white);  // 填充背景色为白色
+
+    // 创建 QPainter 以绘制到 QPixmap 上
+    QPainter painter(&globalPixmap);
+    painter.setRenderHint(QPainter::Antialiasing); // 启用抗锯齿
+
+    // 绘制灰色背景框
+    painter.setPen(Qt::black);
+    painter.setBrush(Qt::lightGray);
+    painter.drawRect(containerWidthdp, containerHeightdp, containerWidth, containerHeight);
+
+    // 计算内部可用空间(留5像素边距)
+    int innerWidth = containerWidth - 10; // 左右各5像素
+    int innerHeight = containerHeight - 10; // 上下各5像素
+    int innerX = containerWidthdp + containerWidth*0.1;
+    int innerY = containerHeightdp + 5;
+
+    // 根据层数自动计算间距和矩形高度
+    const int totalLayers = boxes.iLayersTotal;
+    const float spacing = static_cast<float>((static_cast<float>(innerHeight -totalLayers)) /static_cast<float>(totalLayers)); // 每个矩形之间的固定间距(像素)
+    qDebug()<<spacing;
+    float rectHeight =  2.5;
+    const float rectWeight = static_cast<float>(innerWidth);
+    if((0<=totalLayers)&&(totalLayers<=8)){
+        rectHeight =  2.5;
+    }else if((9<=totalLayers)&&(totalLayers<=16)){
+        rectHeight =  1.5;
+    }else{
+        rectHeight =  1;
     }
+
+    // 逐层绘制状态矩形
+    for(int i = 0; i < totalLayers; ++i) {
+        const QColor color = boxes.iStatas[i] ? QColor(40, 129, 5) : QColor(255, 0, 0); // 1=绿,0=红
+        const int yPos = innerY + i * (rectHeight + spacing);
+        painter.setPen(Qt::NoPen); // 去掉边框
+        painter.setBrush(color);
+        painter.drawRect(static_cast<float>(innerX), static_cast<float>(yPos), static_cast<float>(rectWeight), static_cast<float>(rectHeight));
+    }
+
+}
+
+QPixmap MaterialBox::getGlobalPixmap() const {
+    return globalPixmap;
 }
 
-// 鼠标点击事件
-// void MaterialBox::mousePressEvent(QMouseEvent *event) {
-//     int boxWidth = 30;  // 每个料盒的宽度
-//     int boxHeight = 18;  // 每个料盒的高度
-//     int gap = 10;        // 料盒之间的间距
-//     int cols = 3;        // 每行的列数
-
-//     // 计算料盒的起始位置(居中显示)
-//     int totalWidth = cols * boxWidth + (cols - 1) * gap;
-//     int startX = (width() - totalWidth) / 2;
-//     int startY = 50;
-
-//     // 遍历所有料盒,检查是否被点击
-//     for (size_t i = 0; i < boxes.size(); ++i) {
-//         int row = i / cols;
-//         int col = i % cols;
-//         int x = startX + col * (boxWidth + gap);
-//         int y = startY + row * (boxHeight + gap);
-
-//         QRect boxRect(x, y, boxWidth, boxHeight);
-//         if (boxRect.contains(event->pos())) {
-//             // 打印被点击料盒的信息
-//             qDebug() << "Clicked on:" << boxes[i].name;
-//             return;
-//         }
-//     }
-// }
+void MaterialBox::initFrom(QWidget *parent){
+
+    int ratio = parent->height()/100;
+    // 主容器尺寸(占窗口80%)
+    // qDebug()<<ratio;
+    // qDebug()<<"1111"<<parent->width()<<parent->height();
+    const int containerWidthdp = parent->width() * 0.25;
+    const int containerHeightdp = parent->height() * 0.05;
+    const int containerWidth = parent->width() * 0.5;
+    const int containerHeight = parent->height() *0.9;
+    // 计算内部可用空间(留5像素边距)
+    int innerWidth = containerWidth - 10*ratio; // 左右各5像素
+    int innerHeight = containerHeight - 10*ratio; // 上下各5像素
+    int innerX = containerWidthdp + containerWidth*0.1;
+    int innerY = containerHeightdp + 5*ratio;
+
+    // 根据层数自动计算间距和矩形高度
+    const int totalLayers = boxes.iLayersTotal;
+    const float spacing = static_cast<float>((static_cast<float>(innerHeight -totalLayers*ratio)) /static_cast<float>(totalLayers)); // 每个矩形之间的固定间距(像素)
+    qDebug()<<spacing;
+    float rectHeight =  2.5*ratio;
+    const float rectWeight = static_cast<float>(innerWidth);
+    if((0<=totalLayers)&&(totalLayers<=8)){
+        rectHeight =  2.5*ratio;
+    }else if((9<=totalLayers)&&(totalLayers<=16)){
+        rectHeight =  1.5*ratio;
+    }else{
+        rectHeight =  1*ratio;
+    }
+
+    BackgroundRect* backgroundRect = new BackgroundRect(containerWidthdp, containerHeightdp, containerWidth, containerHeight);
+    scene = new QGraphicsScene(parent);
+    view = new MaterialBoxGraphicsView(scene);
+    scene->addItem(backgroundRect);
+    for (int i = 0; i < totalLayers; ++i) {
+        MaterialBoxDie* materialBoxDie = new MaterialBoxDie(i, 0, boxes.iStatas[i],rectWeight, rectHeight);
+        materialBoxDie->setPos(innerX,(innerY+ i * (rectHeight + spacing) ));
+        scene->addItem(materialBoxDie);
+
+    }
+    connect(view, &MaterialBoxGraphicsView::layerRightClicked, this, &MaterialBox::handleLayerRightClicked);
+    view->resize(parent->width(), parent->height());
+    view->resetTransform();
+    view->setSceneRect(0, 0, parent->width(), parent->height());
+
+
+}
+void MaterialBox::handleLayerRightClicked(int layer) {
+    qDebug() << "Right-clicked on layer:" << layer;
+    // 在这里可以添加其他处理逻辑,例如发送信号到其他对象
+}

+ 13 - 14
CameraMaterialGroupWnd/MaterialWindow/MaterialBox.h

@@ -1,4 +1,4 @@
-#ifndef MATERIALBOX_H
+#ifndef MATERIALBOX_H
 #define MATERIALBOX_H
 
 #include <QApplication>
@@ -8,34 +8,33 @@
 #include <vector>
 #include <QString>
 #include <QDebug>
-
+#include "CInterface.h"
+#include "MaterialBoxGraphicsView.h"
+#include <QFrame>
 // 枚举定义:料盒的状态
 enum BoxStatus {
     Idle,       // 空闲
     Occupied,   // 已占用
-    Warning     // 警告
 };
 
-// 料盒类
-class Material_box {
-public:
-    Material_box(const QString &name, BoxStatus status)
-        : name(name), status(status) {}
-
-    QString name;     // 料盒名称或编号
-    BoxStatus status; // 状态
-};
 
 // 自定义绘制窗口类
 class MaterialBox : public QWidget {
 public:
     MaterialBox(int flag, QWidget *parent = nullptr);
-
+    void paintInitFrom(QWidget *parent);
+    QPixmap getGlobalPixmap() const;
+    void initFrom(QWidget *parent);
+    MaterialBoxGraphicsView* view;
+    QGraphicsScene* scene;
+private slots:
+    void handleLayerRightClicked(int layer);
 protected:
     void paintEvent(QPaintEvent *event) override;
 
 private:
-    std::vector<Material_box> boxes; // 所有料盒的数据
+    MATERIAL_BOX_STRUCT boxes; // 所有料盒的数据
+    QPixmap globalPixmap;
 };
 
 #endif // MATERIALBOX_H

+ 106 - 0
CameraMaterialGroupWnd/MaterialWindow/MaterialBoxGraphicsView.cpp

@@ -0,0 +1,106 @@
+#include "MaterialBoxGraphicsView.h"
+
+MaterialBoxGraphicsView::MaterialBoxGraphicsView(QGraphicsScene* scene, QWidget* parent)
+    : QGraphicsView(scene, parent){
+    setRenderHint(QPainter::Antialiasing);
+    setTransformationAnchor(QGraphicsView::AnchorUnderMouse); // 缩放时以鼠标为中心
+};
+
+
+void MaterialBoxGraphicsView::mousePressEvent(QMouseEvent* event){
+    if(event->button() == Qt::LeftButton){
+        QGraphicsItem* item = itemAt(event->pos());
+        if (item && dynamic_cast<MaterialBoxDie*>(item)) {
+            clearSeleted();
+            selectedLeftItem = dynamic_cast<MaterialBoxDie*>(item);
+            selectedLeftItem->setLeftSelected(true);
+        }else{
+            clearSeleted();
+            return;
+        }
+        setCursor(Qt::OpenHandCursor);  // 按下时设置为小手
+
+    }else if(event->button() == Qt::RightButton){
+        QGraphicsItem* item = itemAt(event->pos());
+        if (item && dynamic_cast<MaterialBoxDie*>(item)) {
+            clearSeleted();
+            selectedRightItem = dynamic_cast<MaterialBoxDie*>(item);
+            selectedRightItem->setRightSelected(true);
+            qDebug()<<selectedRightItem->getRow();
+            emit layerRightClicked(selectedRightItem->getRow()+1);
+
+        }else{
+            return;
+        }
+    }
+    QGraphicsView::mousePressEvent(event);
+}
+void MaterialBoxGraphicsView::mouseReleaseEvent(QMouseEvent* event){
+    if (event->button() == Qt::LeftButton) {
+        setCursor(Qt::ArrowCursor);  // 松开时恢复为箭头
+    }
+}
+
+void MaterialBoxGraphicsView::wheelEvent(QWheelEvent* event) {
+    if (event->orientation() == Qt::Vertical) {
+        event->ignore(); // 忽略竖直滚轮事件(即禁用滚动条滑动)
+        return;
+    }
+    event->accept();
+}
+void MaterialBoxGraphicsView::clearSeleted(){
+    if(selectedLeftItem){
+        selectedLeftItem->setLeftSelected(false);
+    }
+    if(selectedRightItem){
+        selectedRightItem->setRightSelected(false);
+    }
+}
+
+
+
+void BackgroundRect::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
+    // 绘制灰色背景框
+    painter->setPen(Qt::black);
+    painter->setBrush(Qt::lightGray);
+    painter->drawRect(m_containerWidthdp, m_containerHeightdp, m_containerWidth, m_containerHeight);
+}
+
+MaterialBoxDie::MaterialBoxDie(int row, int col, int status, qreal weight,qreal height, QGraphicsItem* parent)
+    : QGraphicsRectItem(parent), row(row), col(col), status(status){
+    setRect(0, 0, weight, height); // 设置单元格大小
+    setBrush(getColorByStatus(status));
+
+    // 设置边框(Pen)
+    setPen(QPen(QColor(0, 0, 0), 0.5)); // 黑色边框,宽度为0.5
+}
+
+void MaterialBoxDie::setLeftSelected(bool selected){
+    if (selected) {
+        setPen(QPen(Qt::blue, 2));
+        setZValue(1);
+    } else {
+        setPen(QPen(Qt::black, 0.5));  // 未选中时恢复为黑色边框
+        setZValue(0);
+    }
+}
+void MaterialBoxDie::setRightSelected(bool selected){
+    if (selected) {
+        setPen(QPen(Qt::green, 2));
+        setZValue(1);
+    } else {
+        setPen(QPen(Qt::black, 0.5));  // 未选中时恢复为黑色边框
+        setZValue(0);
+    }
+}
+QColor MaterialBoxDie::getColorByStatus(int status){
+    switch (status) {
+    case 0: return QColor(255, 0, 0); // 红色
+    case 1: return QColor(40, 129, 5); // 绿色
+    default: return QColor(0, 0, 0);
+    }
+}
+
+int MaterialBoxDie::getRow(){
+    return row;
+}

+ 86 - 0
CameraMaterialGroupWnd/MaterialWindow/MaterialBoxGraphicsView.h

@@ -0,0 +1,86 @@
+#ifndef MATERIALBOXGRAPHICSVIEW_H
+#define MATERIALBOXGRAPHICSVIEW_H
+#include <QGraphicsView>
+#include <QGraphicsScene>
+#include <QGraphicsRectItem>
+#include <QMouseEvent>
+#include <QLabel>
+#include <QPointer>
+#include <QGraphicsItem>
+#include <QPainter>
+#include <QColor>
+#include <QGraphicsSceneEvent>
+#include <QDebug>
+
+
+class BackgroundRect : public QGraphicsItem {
+public:
+    BackgroundRect(int containerWidthdp, int containerHeightdp, int containerWidth, int containerHeight)
+        : m_containerWidthdp(containerWidthdp), m_containerHeightdp(containerHeightdp), m_containerWidth(containerWidth), m_containerHeight(containerHeight) {
+        setFlag(QGraphicsItem::ItemIsSelectable);
+        setFlag(QGraphicsItem::ItemIsMovable, false);
+        setFlag(QGraphicsItem::ItemIsFocusable, false);
+        setAcceptedMouseButtons(Qt::NoButton);  // 禁用所有鼠标按键
+        setAcceptHoverEvents(false);            // 禁用悬停事件
+    }
+
+    QRectF boundingRect() const override {
+        return QRectF(m_containerWidthdp, m_containerHeightdp, m_containerWidth, m_containerHeight);
+    }
+
+    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override ;
+private:
+    int m_containerWidthdp;
+    int m_containerHeightdp;
+    int m_containerWidth;
+    int m_containerHeight;
+    // 可选:显式忽略所有鼠标事件
+    void mousePressEvent(QGraphicsSceneMouseEvent* event) override {
+        event->ignore(); // 允许事件穿透
+    }
+};
+
+class MaterialBoxDie:public QObject, public QGraphicsRectItem{
+    Q_OBJECT
+public:
+    MaterialBoxDie(int row, int col, int status, qreal weight,qreal height, QGraphicsItem* parent = nullptr);
+
+    void setLeftSelected(bool selected);
+    void setRightSelected(bool selected);
+    int getRow();
+
+private:
+    int row, col;
+    int status;
+    bool isSelected = false;
+    // 获取单元格状态颜色
+    QColor getColorByStatus(int status);
+};
+
+class MaterialBoxGraphicsView : public QGraphicsView {
+    Q_OBJECT
+
+public:
+    MaterialBoxGraphicsView(QGraphicsScene* scene, QWidget* parent = nullptr);
+signals:
+    void layerRightClicked(int layer);
+
+
+protected:
+    void mousePressEvent(QMouseEvent* event) override;
+    // void mouseMoveEvent(QMouseEvent* event) override;
+    void mouseReleaseEvent(QMouseEvent* event) override;
+    void wheelEvent(QWheelEvent* event) override;
+    // bool eventFilter(QObject *obj, QEvent *event) override;
+    void clearSeleted();
+
+private:
+    double scaleFactor; // 当前缩放比例
+    QPointer<MaterialBoxDie> selectedLeftItem;
+    QPointer<MaterialBoxDie> selectedRightItem;
+
+
+
+};
+
+#endif // MATERIALBOXGRAPHICSVIEW_H

+ 1 - 3
CameraMaterialGroupWnd/MaterialWindow/Wafer.cpp

@@ -1,4 +1,4 @@
-#include "Wafer.h"
+#include "Wafer.h"
 #include <QPainter>
 #include <QPaintEvent>
 #include <cmath>
@@ -71,10 +71,8 @@ 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;

+ 1 - 1
CameraMaterialGroupWnd/MaterialWindow/Waffle.cpp

@@ -1,4 +1,4 @@
-#include "Waffle.h"
+#include "Waffle.h"
 #include <QPainter>
 #include <QPaintEvent>
 

+ 0 - 2
MainWnd.cpp

@@ -21,8 +21,6 @@ MainWnd::MainWnd(QWidget *parent)
     }
 
 
-
-
     // // 初始化 OriginalWnd
     m_originalWnd = new OriginalWnd(this);
 

+ 26 - 64
OriginalWnd/ChartsAndCamerasWnd.cpp

@@ -290,6 +290,12 @@ void ChartsAndCamerasWnd::initFrom() {
         if(manager->getWafer()) {
             waferMap.insert(num, manager->getWafer());
         }
+        if(manager->getWafer()) {
+            waffleMap.insert(num, manager->getWaffle());
+        }
+        if(manager->getMaterialBox()){
+            materialBoxMap.insert(num,manager->getMaterialBox());
+        }
 
         delete manager;
     }
@@ -348,68 +354,6 @@ void ChartsAndCamerasWnd::initProgressBar(){
         progressBar[i]->setMaximum(100);
         progressBar[i]->setValue(initialValues[i]);
     }
-    // // ui->RedLightprogressBar->setStyleSheet(
-    // //     "QProgressBar {"
-    // //     "   border: 2px solid grey;"
-    // //     "   border-radius: 5px;"
-    // //     "   text-align: center;"
-    // //     "   color: transparent;" // 隐藏文本
-    // //     "}"
-    // //     "QProgressBar::chunk {"
-    // //     "   background-color: #E4080A;"
-    // //     "   width: 10px;"
-    // //     "   margin: 1px;"
-    // //     "}"
-    // //     );
-    // // ui->GreenLightprogressBar->setStyleSheet(
-    // //     "QProgressBar {"
-    // //     "   border: 2px solid grey;"
-    // //     "   border-radius: 5px;"
-    // //     "   text-align: center;"
-    // //     "   color: transparent;" // 隐藏文本
-    // //     "}"
-    // //     "QProgressBar::chunk {"
-    // //     "   background-color: #28B766;"
-    // //     "   width: 10px;"
-    // //     "   margin: 1px;"
-    // //     "}"
-    // //     );
-
-    // ui->BlueLightprogressBar->setStyleSheet(
-    //     "QProgressBar {"
-    //     "   border: 2px solid grey;"
-    //     "   border-radius: 10px;"
-    //     "   text-align: center;"
-    //     "   color: transparent;"
-    //     "}"
-    //     "QProgressBar::chunk {"
-    //     "   background-color: #00BFFF;"
-    //     "   width: 10px;"
-    //     "   margin: 1px;"
-    //     "}"
-    //     );
-
-
-
-
-
-
-
-
-    // // ui->DotLightprogressBar->setStyleSheet(
-    // //     "QProgressBar {"
-    // //     "   border: 2px solid grey;"
-    // //     "   border-radius: 5px;"
-    // //     "   text-align: center;"
-    // //     "   color: transparent;" // 隐藏文本
-    // //     "}"
-    // //     "QProgressBar::chunk {"
-    // //     "   background-color: #CFCFCF;"
-    // //     "   width: 10px;"
-    // //     "   margin: 1px;"
-    // //     "}"
-    //     // );
-    // qDebug() << "Progress bar style sheet set:" << ui->DotLightprogressBar->styleSheet();
 }
 
 void ChartsAndCamerasWnd::connectSliderAndLineEdit(QSlider* slider, QLineEdit* lineEdit)
@@ -494,10 +438,28 @@ void ChartsAndCamerasWnd::loadGroupSettings(int Id, int Index) {
             applyScale();
         } else if (materialWndType == 2) {
             clearLayout();
-            WaffleWidget();
+            ui->Operatewidget->clearPixmap();
+            QVBoxLayout *layout = new QVBoxLayout(ui->Operatewidget);
+            waffleMap.value(Id)->initFrom(ui->Operatewidget);
+
+            layout->setContentsMargins(0, 0, 0, 0);
+            layout->addWidget(waffleMap.value(Id)->view);
+            ui->Operatewidget->setLayout(layout);
+            currentMode = ModeView;
+            currentView = waffleMap.value(Id)->view;
+            scaleFactor = 1.0;
+            applyScale();
         } else if (materialWndType == 3) {
             clearLayout();
-            MaterialBoxWidget();
+            QVBoxLayout *layout = new QVBoxLayout(ui->Operatewidget);
+            materialBoxMap.value(Id)->initFrom(ui->Operatewidget);
+            layout->setContentsMargins(0, 0, 0, 0);
+            layout->addWidget(materialBoxMap.value(Id)->view);
+            ui->Operatewidget->setLayout(layout);
+            currentMode = ModeView;
+            currentView = materialBoxMap.value(Id)->view;
+            scaleFactor = 1.0;
+            applyScale();
         }
     }
 

+ 2 - 6
OriginalWnd/ChartsAndCamerasWnd.h

@@ -20,12 +20,6 @@ class ChartsAndCamerasWnd;
 }
 
 
-// struct SeriesInfo {
-//     QString seriesName;
-//     QColor lineColor;
-//     QPixmap markerIcon;
-//     QList<QPointF> data;
-// };
 
 class ChartsAndCamerasWnd : public QMainWindow
 {
@@ -122,6 +116,8 @@ private:
     bool isShow;
 
     QMap<int, Wafer*> waferMap;
+    QMap<int, Waffle*> waffleMap;
+    QMap<int, MaterialBox*> materialBoxMap;
     OperateMode currentMode = ModeImage;
     QGraphicsView *currentView = nullptr;
     QPoint mousePos;

+ 112 - 12
OriginalWnd/MainAndSecondaryCamerasWnd.cpp

@@ -93,6 +93,12 @@ void MainAndSecondaryCamerasWnd::initFrom()
         if(manager->getWafer()) {
             waferMap.insert(num, manager->getWafer());
         }
+        if(manager->getWafer()) {
+            waffleMap.insert(num, manager->getWaffle());
+        }
+        if(manager->getMaterialBox()){
+            materialBoxMap.insert(num,manager->getMaterialBox());
+        }
 
         delete manager;
     }
@@ -307,9 +313,28 @@ void MainAndSecondaryCamerasWnd::loadGroupSettings(int Id, int Index) {
                 Left_scaleFactor = 1.0;
                 applyScale(0);
             } else if (Last_materialWndType == 2) {
-                WaffleWidget(0);
+                ui->LeftOperatewidget->clearPixmap();
+                QVBoxLayout *layout = new QVBoxLayout(ui->LeftOperatewidget);
+                waffleMap.value(lastGroupId)->initFrom(ui->LeftOperatewidget);
+
+                layout->setContentsMargins(0, 0, 0, 0);
+                layout->addWidget(waffleMap.value(lastGroupId)->view);
+                ui->LeftOperatewidget->setLayout(layout);
+                Left_currentMode = ModeView;
+                Left_currentView = waffleMap.value(lastGroupId)->view;
+                Left_scaleFactor = 1.0;
+                applyScale(0);
             } else if (Last_materialWndType == 3) {
-                MaterialBoxWidget(0);
+                ui->LeftOperatewidget->clearPixmap();
+                QVBoxLayout *layout = new QVBoxLayout(ui->LeftOperatewidget);
+                materialBoxMap.value(lastGroupId)->initFrom(ui->LeftOperatewidget);
+                layout->setContentsMargins(0, 0, 0, 0);
+                layout->addWidget(materialBoxMap.value(lastGroupId)->view);
+                ui->LeftOperatewidget->setLayout(layout);
+                Left_currentMode = ModeView;
+                Left_currentView = materialBoxMap.value(lastGroupId)->view;
+                Left_scaleFactor = 1.0;
+                applyScale(0);
             }
         }
     } else if (Index == 2) {
@@ -349,9 +374,28 @@ void MainAndSecondaryCamerasWnd::loadGroupSettings(int Id, int Index) {
                     Left_scaleFactor = 1.0;
                     applyScale(0);
                 } else if (Last_materialWndType == 2) {
-                    WaffleWidget(0);
+                    ui->LeftOperatewidget->clearPixmap();
+                    QVBoxLayout *layout = new QVBoxLayout(ui->LeftOperatewidget);
+                    waffleMap.value(lastGroupId)->initFrom(ui->LeftOperatewidget);
+
+                    layout->setContentsMargins(0, 0, 0, 0);
+                    layout->addWidget(waffleMap.value(lastGroupId)->view);
+                    ui->LeftOperatewidget->setLayout(layout);
+                    Left_currentMode = ModeView;
+                    Left_currentView = waffleMap.value(lastGroupId)->view;
+                    Left_scaleFactor = 1.0;
+                    applyScale(0);
                 } else if (Last_materialWndType == 3) {
-                    MaterialBoxWidget(0);
+                    ui->LeftOperatewidget->clearPixmap();
+                    QVBoxLayout *layout = new QVBoxLayout(ui->LeftOperatewidget);
+                    materialBoxMap.value(lastGroupId)->initFrom(ui->LeftOperatewidget);
+                    layout->setContentsMargins(0, 0, 0, 0);
+                    layout->addWidget(materialBoxMap.value(lastGroupId)->view);
+                    ui->LeftOperatewidget->setLayout(layout);
+                    Left_currentMode = ModeView;
+                    Left_currentView = materialBoxMap.value(lastGroupId)->view;
+                    Left_scaleFactor = 1.0;
+                    applyScale(0);
                 }
             }
             ui->RightOperatewidget->clearPixmap();
@@ -391,14 +435,42 @@ void MainAndSecondaryCamerasWnd::loadGroupSettings(int Id, int Index) {
                     Left_currentView = waferMap.value(lastGroupId)->view;
                     Left_scaleFactor = 1.0;
                     applyScale(0);
-                } else if (Last_materialWndType == 2) {
-                    WaffleWidget(0);
+                } else if (Last_materialWndType == 2) {                   
+                    ui->LeftOperatewidget->clearPixmap();
+                    ui->LeftOperatewidget->clearPixmap();
+                    QVBoxLayout *layout = new QVBoxLayout(ui->LeftOperatewidget);
+                    waffleMap.value(lastGroupId)->initFrom(ui->LeftOperatewidget);
+
+                    layout->setContentsMargins(0, 0, 0, 0);
+                    layout->addWidget(waffleMap.value(lastGroupId)->view);
+                    ui->LeftOperatewidget->setLayout(layout);
+                    Left_currentMode = ModeView;
+                    Left_currentView = waffleMap.value(lastGroupId)->view;
+                    Left_scaleFactor = 1.0;
+                    applyScale(0);
                 } else if (Last_materialWndType == 3) {
-                    MaterialBoxWidget(0);
+                    ui->LeftOperatewidget->clearPixmap();
+                    QVBoxLayout *layout = new QVBoxLayout(ui->LeftOperatewidget);
+                    materialBoxMap.value(lastGroupId)->initFrom(ui->LeftOperatewidget);
+                    layout->setContentsMargins(0, 0, 0, 0);
+                    layout->addWidget(materialBoxMap.value(lastGroupId)->view);
+                    ui->LeftOperatewidget->setLayout(layout);
+                    Left_currentMode = ModeView;
+                    Left_currentView = materialBoxMap.value(lastGroupId)->view;
+                    Left_scaleFactor = 1.0;
+                    applyScale(0);
                 }
             }
-            
-			WaffleWidget(1);
+            ui->RightOperatewidget->clearPixmap();
+            QVBoxLayout *layout = new QVBoxLayout(ui->RightOperatewidget);
+            waffleMap.value(Id)->initFrom(ui->RightOperatewidget);
+
+            layout->setContentsMargins(0, 0, 0, 0);
+            layout->addWidget(waffleMap.value(Id)->view);
+            ui->RightOperatewidget->setLayout(layout);
+            Right_currentMode = ModeView;
+            Right_currentView = waffleMap.value(Id)->view;
+            Right_scaleFactor = 1.0;
         } else if (materialWndType == 3) {
             if (lastIndex == 1) {
                 Last_newPixmap = QPixmap(Last_imagePath1);
@@ -426,13 +498,41 @@ void MainAndSecondaryCamerasWnd::loadGroupSettings(int Id, int Index) {
                     Left_scaleFactor = 1.0;
                     applyScale(0);
                 } else if (Last_materialWndType == 2) {
-                    WaffleWidget(0);
+                    ui->LeftOperatewidget->clearPixmap();
+                    QVBoxLayout *layout = new QVBoxLayout(ui->LeftOperatewidget);
+                    waffleMap.value(lastGroupId)->initFrom(ui->LeftOperatewidget);
+
+                    layout->setContentsMargins(0, 0, 0, 0);
+                    layout->addWidget(waffleMap.value(lastGroupId)->view);
+                    ui->LeftOperatewidget->setLayout(layout);
+                    Left_currentMode = ModeView;
+                    Left_currentView = waffleMap.value(lastGroupId)->view;
+                    Left_scaleFactor = 1.0;
+                    applyScale(0);
                 } else if (Last_materialWndType == 3) {
-                    MaterialBoxWidget(0);
+                    ui->LeftOperatewidget->clearPixmap();
+                    QVBoxLayout *layout = new QVBoxLayout(ui->LeftOperatewidget);
+                    materialBoxMap.value(lastGroupId)->initFrom(ui->LeftOperatewidget);
+                    layout->setContentsMargins(0, 0, 0, 0);
+                    layout->addWidget(materialBoxMap.value(lastGroupId)->view);
+                    ui->LeftOperatewidget->setLayout(layout);
+                    Left_currentMode = ModeView;
+                    Left_currentView = materialBoxMap.value(lastGroupId)->view;
+                    Left_scaleFactor = 1.0;
+                    applyScale(0);
                 }
             }
             
-			MaterialBoxWidget(1);
+            ui->RightOperatewidget->clearPixmap();
+            QVBoxLayout *layout = new QVBoxLayout(ui->RightOperatewidget);
+            materialBoxMap.value(Id)->initFrom(ui->RightOperatewidget);
+            layout->setContentsMargins(0, 0, 0, 0);
+            layout->addWidget(materialBoxMap.value(Id)->view);
+            ui->RightOperatewidget->setLayout(layout);
+            Left_currentMode = ModeView;
+            Left_currentView = materialBoxMap.value(Id)->view;
+            Left_scaleFactor = 1.0;
+            applyScale(0);
         }
     }
 

+ 3 - 1
OriginalWnd/MainAndSecondaryCamerasWnd.h

@@ -1,4 +1,4 @@
-#ifndef MAINANDSECONDARYCAMERASWND_H
+#ifndef MAINANDSECONDARYCAMERASWND_H
 #define MAINANDSECONDARYCAMERASWND_H
 
 #include <QMainWindow>
@@ -81,6 +81,8 @@ private:
     bool isShow;
     bool isShow_L;
     QMap<int, Wafer*> waferMap;
+    QMap<int, Waffle*> waffleMap;
+    QMap<int, MaterialBox*> materialBoxMap;
     OperateMode Left_currentMode = ModeImage;
     OperateMode Right_currentMode = ModeImage;
     QGraphicsView *Left_currentView = nullptr;

+ 25 - 3
OriginalWnd/SingleCameraOperationWnd.cpp

@@ -77,6 +77,9 @@ void SingleCameraOperationWnd::initFrom() {
         if(manager->getWafer()) {
             waffleMap.insert(num, manager->getWaffle());
         }
+        if(manager->getMaterialBox()){
+            materialBoxMap.insert(num,manager->getMaterialBox());
+        }
 
         delete manager;
     }
@@ -239,7 +242,7 @@ void SingleCameraOperationWnd::loadGroupSettings(int Id, int Index) {
     } else if (Index == 2) {
         if (materialWndType == 1) {
             clearLayout();
-            // ui->Operatewidget->clearPixmap();
+            ui->Operatewidget->clearPixmap();
             QVBoxLayout *layout = new QVBoxLayout(ui->Operatewidget);
             waferMap.value(Id)->initFrom(ui->Operatewidget);
 
@@ -265,7 +268,17 @@ void SingleCameraOperationWnd::loadGroupSettings(int Id, int Index) {
             applyScale();
         } else if (materialWndType == 3) {
             clearLayout();
-            MaterialBoxWidget();
+            QVBoxLayout *layout = new QVBoxLayout(ui->Operatewidget);
+            materialBoxMap.value(Id)->initFrom(ui->Operatewidget);
+            layout->setContentsMargins(0, 0, 0, 0);
+            layout->addWidget(materialBoxMap.value(Id)->view);
+            ui->Operatewidget->setLayout(layout);
+            currentMode = ModeView;
+            currentView = materialBoxMap.value(Id)->view;
+            scaleFactor = 1.0;
+            applyScale();
+
+            // MaterialBoxWidget();
         }
     }
 
@@ -377,7 +390,16 @@ void SingleCameraOperationWnd::on_ZoomOutButton_clicked() {
     updateScale(scaleFactor * 0.9);
 
 }
-
+void SingleCameraOperationWnd::on_RulerButton_clicked(){
+    // 创建初始线段(示例长度200像素)
+    // DraggableLine* line = new DraggableLine;
+    // line->setLine(0, 0, 200, 0); // 水平线段
+    // if (currentView != nullptr) {
+    //     currentView->scene()->addItem(line);
+    //     line->setPos(20, 20);
+    //     currentView->viewport()->update();
+    // }
+}
 
 void SingleCameraOperationWnd::wheelEvent(QWheelEvent *event)
 {

+ 5 - 3
OriginalWnd/SingleCameraOperationWnd.h

@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
 #ifndef SINGLECAMERAOPERATIONWND_H
 #define SINGLECAMERAOPERATIONWND_H
 
@@ -10,6 +10,7 @@
 #include "CameraMaterialGroupWnd/MaterialWindow/MaterialBox.h"
 #include "CameraDataHandleAndShow.h"
 #include "CameraMaterialGroupWnd/CameraImage/CameraImageHandler.h"
+#include "CameraMaterialGroupWnd/MaterialWindow/DraggableLine.h"
 namespace Ui {
 class SingleCameraOperationWnd;
 }
@@ -64,9 +65,9 @@ private slots:
     }
 
     void on_ZoomOutButton_clicked();
+    void on_RulerButton_clicked();
 
-private:
-    Ui::SingleCameraOperationWnd *ui;
+private : Ui::SingleCameraOperationWnd *ui;
 
     QPixmap currentPixmap;
     qreal scaleFactor;
@@ -82,6 +83,7 @@ private:
     int currentCameraId;
     QMap<int, Wafer*> waferMap;
     QMap<int, Waffle*> waffleMap;
+    QMap<int, MaterialBox*> materialBoxMap;
     OperateMode currentMode = ModeImage;
     QGraphicsView *currentView = nullptr;
     QPoint mousePos;

+ 8 - 0
SBTdie-bonder-ui.pro

@@ -13,8 +13,12 @@ CONFIG += c++14
 SOURCES += \
     CameraMaterialGroupWnd/CameraImage/CameraImageHandler.cpp \
     CameraMaterialGroupWnd/Group.cpp \
+    CameraMaterialGroupWnd/MaterialWindow/Bond.cpp \
+    CameraMaterialGroupWnd/MaterialWindow/BondGraphicsView.cpp \
     CameraMaterialGroupWnd/MaterialWindow/DieItem.cpp \
+    CameraMaterialGroupWnd/MaterialWindow/DraggableLine.cpp \
     CameraMaterialGroupWnd/MaterialWindow/MaterialBox.cpp \
+    CameraMaterialGroupWnd/MaterialWindow/MaterialBoxGraphicsView.cpp \
     CameraMaterialGroupWnd/MaterialWindow/Wafer.cpp \
     CameraMaterialGroupWnd/MaterialWindow/WaferGraphicsView.cpp \
     CameraMaterialGroupWnd/MaterialWindow/Waffle.cpp \
@@ -37,8 +41,12 @@ HEADERS += \
     CInterface.h \
     CameraMaterialGroupWnd/CameraImage/CameraImageHandler.h \
     CameraMaterialGroupWnd/Group.h \
+    CameraMaterialGroupWnd/MaterialWindow/Bond.h \
+    CameraMaterialGroupWnd/MaterialWindow/BondGraphicsView.h \
     CameraMaterialGroupWnd/MaterialWindow/DieItem.h \
+    CameraMaterialGroupWnd/MaterialWindow/DraggableLine.h \
     CameraMaterialGroupWnd/MaterialWindow/MaterialBox.h \
+    CameraMaterialGroupWnd/MaterialWindow/MaterialBoxGraphicsView.h \
     CameraMaterialGroupWnd/MaterialWindow/Wafer.h \
     CameraMaterialGroupWnd/MaterialWindow/WaferGraphicsView.h \
     CameraMaterialGroupWnd/MaterialWindow/Waffle.h \