123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305 |
- #include "Wafer.h"
- #include <QPainter>
- #include <QPaintEvent>
- #include <cmath>
- #include <QDebug>
- #include <QPushButton>
- #include <QGridLayout>
- #include "ImageWidget.h"
- Wafer::Wafer(int flag, QWidget *parent) : QWidget(parent) {
-
- }
- void Wafer::UpdataGenerateTestData()
- {
-
- }
- void Wafer::UpdataVal(const std::vector<ns_mat::WAFER_MATRIX_POINT_INFO_STRUCT>& veWafer)
- {
- int currentDieMatrixId = veWafer[0].nDieMatrixId;
- int rowMax = veWafer[0].nDieRow;
- int colsMax = veWafer[0].nDieCol;
- double minx = veWafer[0].stPosition.x;
- double miny = veWafer[0].stPosition.y;
- double maxx = veWafer[0].stPosition.x;
- double maxy = veWafer[0].stPosition.y;
- for (const auto a : veWafer)
- {
- waferData.append(a);
- qDebug() << a.stPosition.x << " " << a.stPosition.y;
- if (a.nDieMatrixId != currentDieMatrixId) {
- maxRow_Colmap.insert(currentDieMatrixId, { rowMax ,colsMax,minx,miny,maxx,maxy });
- currentDieMatrixId = a.nDieMatrixId;
- rowMax = a.nDieRow;
- colsMax = a.nDieCol;
- minx = a.stPosition.x;
- maxx = a.stPosition.x;
- miny = a.stPosition.y;
- maxy = a.stPosition.y;
- }
- else {
- if (a.nDieRow >= rowMax) rowMax = a.nDieRow;
- if (a.nDieCol >= colsMax) colsMax = a.nDieCol;
- 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.y <= miny) miny = a.stPosition.y;
- }
- }
- maxRow_Colmap.insert(currentDieMatrixId, { rowMax ,colsMax,minx,miny,maxx,maxy });
- }
- QColor Wafer::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 Wafer::paintInitFrom(QWidget *parent) {
-
- }
- void Wafer::initFrom(QWidget* parent) {
-
- double width, height;
- if (parent == nullptr) {
- width = 493;
- height = 493;
- }
- else {
- width = parent->width();
- height = parent->height();
- }
-
-
- scene = new QGraphicsScene(parent);
- view = new WaferGraphicsView(scene);
- 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;
-
- angle = 90.00;
-
- view->initWafer(center,
- radius,
- dieLong, dieWide,angle);
- 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);
- }
- 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());
-
- globalPixmap = QPixmap(width, height);
- globalPixmap.fill(Qt::white);
- QPixmap originalPixmap = QPixmap::grabWidget(view);
-
- QSize targetSize(width, height);
-
- QPixmap scaledPixmap = originalPixmap.scaled(
- targetSize,
- Qt::IgnoreAspectRatio,
- Qt::SmoothTransformation
- );
- globalPixmap = scaledPixmap;
-
-
- }
- QPixmap Wafer::getGlobalPixmap() const {
- return globalPixmap;
- }
- void Wafer::setWaferInfo(ns_module::CViewInterface* CViewInterface) {
- m_pCViewInterface = CViewInterface;
- long result = m_pCViewInterface->GetViewMatrix()->GetDieSize(m_dieLong,m_dieWide);
- m_pCViewInterface->GetViewMatrix()->GetWaferSize(m_centerX, m_centerY,m_radius);
-
-
- m_radius = 10000;
- m_centerX = 0;
- m_centerY = 0;
- }
|