You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
392 lines
10 KiB
C++
392 lines
10 KiB
C++
#include "MappingUI.h"
|
|
|
|
MappingUI::MappingUI(QWidget *parent)
|
|
: QWidget(parent)
|
|
{
|
|
ui.setupUi(this);
|
|
}
|
|
|
|
MappingUI::~MappingUI()
|
|
{
|
|
QList<QGraphicsItem *> items = m_scene.items();
|
|
foreach(QGraphicsItem *item, items) {
|
|
m_scene.removeItem(item);
|
|
//delete item; // 如果需要,可以删除项以释放内存
|
|
}
|
|
|
|
m_allDieItem.clear();
|
|
m_ellipseItem.clear();
|
|
m_allLineItem.clear();
|
|
m_curDie = nullptr;
|
|
}
|
|
|
|
void MappingUI::SetRecipe(double waferDia,
|
|
double dieWidth,
|
|
double dieHeight,
|
|
double baseDiePosX,
|
|
double baseDiePosY,
|
|
double markPoint1X,
|
|
double markPoint1Y,
|
|
double markPoint2X,
|
|
double markPoint2Y,
|
|
int areaXDirectionNum,
|
|
int areaYDirectionNum)
|
|
{
|
|
m_maferRecipe.m_waferDia = waferDia;
|
|
m_maferRecipe.m_dieWidth = dieWidth;
|
|
m_maferRecipe.m_dieHeight = dieHeight;
|
|
m_maferRecipe.m_baseDiePosX = baseDiePosX;
|
|
m_maferRecipe.m_baseDiePosY = baseDiePosY;
|
|
m_maferRecipe.m_markPoint1X = markPoint1X;
|
|
m_maferRecipe.m_markPoint1Y = markPoint1Y;
|
|
m_maferRecipe.m_markPoint2X = markPoint2X;
|
|
m_maferRecipe.m_markPoint2Y = markPoint2Y;
|
|
m_maferRecipe.areaXDirectionNum = areaXDirectionNum;
|
|
m_maferRecipe.areaYDirectionNum = areaYDirectionNum;
|
|
DrawMapping();
|
|
}
|
|
|
|
void MappingUI::DrawMapping()
|
|
{
|
|
//计算每个区域X和Y方向die的数量
|
|
CountDieNumInArea();
|
|
|
|
double rectFirstPointX = m_maferRecipe.m_baseDiePosX/* - m_maferRecipe.m_dieWidth / 2.0*/;
|
|
double rectFirstPointY = m_maferRecipe.m_baseDiePosY/* + m_maferRecipe.m_dieHeight / 2.0*/;
|
|
std::shared_ptr<MyQGraphicsRectItem> rectObj = std::make_shared<MyQGraphicsRectItem>(rectFirstPointX,
|
|
rectFirstPointY,
|
|
m_maferRecipe.m_dieWidth,
|
|
m_maferRecipe.m_dieHeight);
|
|
SetDieAttr(rectObj, true, false, rectFirstPointX, rectFirstPointY);
|
|
rectObj->setBrush(BASE_POINT_COLOR);
|
|
|
|
m_allDieItem.push_back(rectObj);
|
|
m_scene.addItem(rectObj.get());
|
|
|
|
std::shared_ptr<QGraphicsEllipseItem> EllipseObj = std::make_shared<QGraphicsEllipseItem>(0,
|
|
0,
|
|
m_maferRecipe.m_waferDia,
|
|
m_maferRecipe.m_waferDia);
|
|
m_ellipseItem.push_back(EllipseObj);
|
|
EllipseObj->setPen(QPen(RECT_COLOR));
|
|
EllipseObj->setPos(-rectObj->pos().x() - m_maferRecipe.m_waferDia / 2,
|
|
-rectObj->pos().y() - m_maferRecipe.m_waferDia / 2);
|
|
m_scene.addItem(EllipseObj.get());
|
|
|
|
//基准die往上延伸
|
|
for (int i = 0; i < MAX_EXTEND_NUM; i++)
|
|
{
|
|
double xCoord = rectFirstPointX;
|
|
double yCoord = rectFirstPointY + i * m_maferRecipe.m_dieHeight;
|
|
if (yCoord < -1 * m_maferRecipe.m_waferDia / 2)
|
|
{
|
|
break;
|
|
}
|
|
LeftExtend(xCoord, yCoord);
|
|
bool isIncludeBaseDie = false;
|
|
i == 0 ? isIncludeBaseDie = true : isIncludeBaseDie = false;
|
|
RightExtend(xCoord, yCoord, isIncludeBaseDie);
|
|
}
|
|
|
|
//基准die往下延伸
|
|
for (int i = 1; i < MAX_EXTEND_NUM; i++)
|
|
{
|
|
double xCoord = rectFirstPointX;
|
|
double yCoord = rectFirstPointY - i * m_maferRecipe.m_dieHeight;
|
|
if (yCoord > m_maferRecipe.m_waferDia / 2)
|
|
{
|
|
break;
|
|
}
|
|
LeftExtend(xCoord, yCoord);
|
|
RightExtend(xCoord, yCoord, false);
|
|
}
|
|
|
|
if (m_allDieItem.size() > 0)
|
|
{
|
|
m_areaStartX = m_allDieItem[0]->xCoord();
|
|
m_areaStartY = m_allDieItem[0]->yCoord();
|
|
}
|
|
for (auto& iter : m_allDieItem)
|
|
{
|
|
if (iter->xCoord() < m_areaStartX)
|
|
{
|
|
m_areaStartX = iter->xCoord();
|
|
}
|
|
if (iter->yCoord() > m_areaStartY)
|
|
{
|
|
m_areaStartY = iter->yCoord();
|
|
}
|
|
}
|
|
double resAreaStartX = m_areaStartX;
|
|
double resAreaStartY = m_areaStartY * (-1);
|
|
|
|
//绘制区域横线
|
|
for (int i = 0; i < 10; i++)
|
|
{
|
|
std::shared_ptr<QGraphicsLineItem> LineObj = std::make_shared<QGraphicsLineItem>(resAreaStartX,
|
|
resAreaStartY + m_maferRecipe.m_dieHeight * m_readAreaYNum * i,
|
|
resAreaStartX + m_maferRecipe.m_waferDia,
|
|
resAreaStartY + m_maferRecipe.m_dieHeight * m_readAreaYNum * i);
|
|
LineObj->setPen(QPen(AREA_LINE_COLOR));
|
|
m_allLineItem.push_back(LineObj);
|
|
m_scene.addItem(LineObj.get());
|
|
}
|
|
|
|
//绘制区域竖线
|
|
for (int i = 0; i < 10; i++)
|
|
{
|
|
std::shared_ptr<QGraphicsLineItem> LineObj = std::make_shared<QGraphicsLineItem>(
|
|
resAreaStartX + m_maferRecipe.m_dieWidth * m_realAreaXNum * i,
|
|
resAreaStartY,
|
|
resAreaStartX + m_maferRecipe.m_dieWidth * m_realAreaXNum * i,
|
|
resAreaStartY + m_maferRecipe.m_waferDia);
|
|
LineObj->setPen(QPen(AREA_LINE_COLOR));
|
|
m_allLineItem.push_back(LineObj);
|
|
m_scene.addItem(LineObj.get());
|
|
}
|
|
|
|
ui.graphicsView->setScene(&m_scene);
|
|
if (!m_isScale)
|
|
{
|
|
ui.graphicsView->scale(m_scaleFactor, m_scaleFactor);
|
|
m_isScale = true;
|
|
}
|
|
}
|
|
|
|
void MappingUI::SetWaferRecipe(MaferRecipe& maferRecipe)
|
|
{
|
|
|
|
}
|
|
|
|
void MappingUI::SetLabelHide()
|
|
{
|
|
ui.horizontalLayout->removeWidget(ui.label);
|
|
ui.horizontalLayout->removeWidget(ui.label_2);
|
|
ui.label->hide();
|
|
ui.label_2->hide();
|
|
ui.verticalLayout->removeItem(ui.horizontalLayout);
|
|
}
|
|
|
|
void MappingUI::LeftExtend(double firstX, double firstY)
|
|
{
|
|
for (int i = 1; i < MAX_EXTEND_NUM; i++)
|
|
{
|
|
double rectFirstX = firstX - m_maferRecipe.m_dieWidth * i;
|
|
double rectFirstY = firstY;
|
|
|
|
if (JudgeIsInWafer(rectFirstX, rectFirstY))
|
|
{
|
|
AddDieRect(rectFirstX, rectFirstY);
|
|
}
|
|
else
|
|
{
|
|
if (rectFirstX < -1 * m_maferRecipe.m_waferDia / 2)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void MappingUI::RightExtend(double firstX, double firstY, bool isIncludeCur)
|
|
{
|
|
int startPos = 0;
|
|
isIncludeCur ? startPos = 1 : startPos = 0;
|
|
for (int i = startPos; i < MAX_EXTEND_NUM; i++)
|
|
{
|
|
double rectFirstX = firstX + m_maferRecipe.m_dieWidth * i;
|
|
double rectFirstY = firstY;
|
|
|
|
if (JudgeIsInWafer(rectFirstX, rectFirstY))
|
|
{
|
|
AddDieRect(rectFirstX, rectFirstY, "right");
|
|
}
|
|
else
|
|
{
|
|
if (rectFirstX > m_maferRecipe.m_waferDia / 2)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void MappingUI::AddDieRect(double xCoord, double yCoord, std::string direction)
|
|
{
|
|
std::shared_ptr<MyQGraphicsRectItem> rectObj = std::make_shared<MyQGraphicsRectItem>(
|
|
xCoord,
|
|
yCoord,
|
|
m_maferRecipe.m_dieWidth,
|
|
m_maferRecipe.m_dieHeight);
|
|
|
|
/*if (direction == "right")
|
|
{
|
|
xCoord += m_maferRecipe.m_dieWidth;
|
|
}*/
|
|
|
|
rectObj->setPen(QPen(RECT_COLOR));
|
|
if (JudgeIsMark(xCoord, yCoord))
|
|
{
|
|
SetDieAttr(rectObj, false, true, xCoord, yCoord);
|
|
rectObj->setBrush(MARK_POINT_COLOR);
|
|
}
|
|
else
|
|
{
|
|
SetDieAttr(rectObj, false, false, xCoord, yCoord);
|
|
}
|
|
|
|
m_allDieItem.push_back(rectObj);
|
|
m_scene.addItem(rectObj.get());
|
|
}
|
|
|
|
void MappingUI::SetDieAttr(std::shared_ptr<MyQGraphicsRectItem>& dieObj, bool isBase, bool isMark, double xCoord, double yCoord)
|
|
{
|
|
connect(dieObj.get(), SIGNAL(signal_select(double,double)), this, SLOT(slot_UpdateAllDieStatus(double, double)));
|
|
dieObj->Base(isBase);
|
|
dieObj->Mark(isMark);
|
|
dieObj->xCoord(xCoord);
|
|
dieObj->yCoord(yCoord * -1);
|
|
}
|
|
|
|
bool MappingUI::JudgeIsInWafer(double xCoord, double yCoord)
|
|
{
|
|
if (abs(xCoord) > (m_maferRecipe.m_waferDia / 2.0) || abs(yCoord) > m_maferRecipe.m_waferDia / 2.0)
|
|
{
|
|
return false;
|
|
}
|
|
int judgeIsOk = 0;
|
|
//矩形左上侧点
|
|
if (sqrt(std::pow(m_maferRecipe.m_waferDia / 2, 2) - std::pow(yCoord, 2)) > abs(xCoord) &&
|
|
sqrt(std::pow(m_maferRecipe.m_waferDia / 2, 2) - std::pow(xCoord, 2)) > abs(yCoord))
|
|
{
|
|
judgeIsOk++;
|
|
}
|
|
//矩形左下侧点
|
|
if (sqrt(std::pow(m_maferRecipe.m_waferDia / 2, 2) - std::pow(yCoord + m_maferRecipe.m_dieHeight, 2)) > abs(xCoord) &&
|
|
sqrt(std::pow(m_maferRecipe.m_waferDia / 2, 2) - std::pow(xCoord, 2)) > abs(yCoord + m_maferRecipe.m_dieHeight))
|
|
{
|
|
judgeIsOk++;
|
|
}
|
|
//矩形右上侧点
|
|
if (sqrt(std::pow(m_maferRecipe.m_waferDia / 2, 2) - std::pow(yCoord, 2)) > abs(xCoord + m_maferRecipe.m_dieWidth) &&
|
|
sqrt(std::pow(m_maferRecipe.m_waferDia / 2, 2) - std::pow(xCoord + m_maferRecipe.m_dieWidth, 2)) > abs(yCoord))
|
|
{
|
|
judgeIsOk++;
|
|
}
|
|
//矩形右下侧点
|
|
if (sqrt(std::pow(m_maferRecipe.m_waferDia / 2, 2) - std::pow(yCoord + +m_maferRecipe.m_dieHeight, 2)) > abs(xCoord + m_maferRecipe.m_dieWidth) &&
|
|
sqrt(std::pow(m_maferRecipe.m_waferDia / 2, 2) - std::pow(xCoord + m_maferRecipe.m_dieWidth, 2)) > abs(yCoord + m_maferRecipe.m_dieHeight))
|
|
{
|
|
judgeIsOk++;
|
|
}
|
|
if (4 == judgeIsOk)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool MappingUI::JudgeIsMark(double xCoord, double yCoord)
|
|
{
|
|
//判断mark1点
|
|
if (xCoord - JUDGE_DECIMAL <= m_maferRecipe.m_markPoint1X &&
|
|
xCoord + JUDGE_DECIMAL >= m_maferRecipe.m_markPoint1X &&
|
|
yCoord - JUDGE_DECIMAL <= m_maferRecipe.m_markPoint1Y &&
|
|
yCoord + JUDGE_DECIMAL >= m_maferRecipe.m_markPoint1Y)
|
|
{
|
|
return true;
|
|
}
|
|
//判断mark2点
|
|
|
|
if (xCoord - JUDGE_DECIMAL <= m_maferRecipe.m_markPoint2X &&
|
|
xCoord + JUDGE_DECIMAL >= m_maferRecipe.m_markPoint2X &&
|
|
yCoord - JUDGE_DECIMAL <= m_maferRecipe.m_markPoint2Y &&
|
|
yCoord + JUDGE_DECIMAL >= m_maferRecipe.m_markPoint2Y)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void MappingUI::CountDieNumInArea()
|
|
{
|
|
//计算每个区域X方向和Y方向一共有多少个die
|
|
if (m_maferRecipe.m_dieHeight < JUDGE_DECIMAL || m_maferRecipe.m_dieWidth < JUDGE_DECIMAL ||
|
|
m_maferRecipe.areaXDirectionNum <= 0 || m_maferRecipe.areaYDirectionNum <= 0) {
|
|
return;
|
|
}
|
|
double XDirectionNum = m_maferRecipe.m_waferDia / m_maferRecipe.m_dieWidth;
|
|
double YDirectionNum = m_maferRecipe.m_waferDia / m_maferRecipe.m_dieHeight;
|
|
|
|
double areaDieNumX = XDirectionNum / m_maferRecipe.areaXDirectionNum;
|
|
double areaDieNumY = YDirectionNum / m_maferRecipe.areaYDirectionNum;
|
|
|
|
m_realAreaXNum = floor(areaDieNumX + 1.0);
|
|
m_readAreaYNum = floor(areaDieNumY + 1.0);
|
|
}
|
|
|
|
void MappingUI::wheelEvent(QWheelEvent *event)
|
|
{
|
|
ui.graphicsView->resetMatrix();
|
|
// 滚轮向上放大,向下缩小
|
|
qDebug() << event->angleDelta().y();
|
|
if (event->angleDelta().y() > 0) {
|
|
if (m_scaleFactor < 10)
|
|
{
|
|
m_scaleFactor *= 1.05; // 放大
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (m_scaleFactor > 2)
|
|
{
|
|
m_scaleFactor /= 1.05; // 缩小
|
|
}
|
|
}
|
|
qDebug() << event->angleDelta().y()<< " "<< m_scaleFactor;
|
|
ui.graphicsView->scale(m_scaleFactor, m_scaleFactor);
|
|
}
|
|
|
|
void MappingUI::mousePressEvent(QMouseEvent *event)
|
|
{
|
|
/*if (event->button() == Qt::LeftButton)
|
|
{
|
|
for (auto& iter : m_allItem)
|
|
{
|
|
if (iter->Base() != true && iter->Mark() != true)
|
|
{
|
|
iter->setBrush(Qt::NoBrush);
|
|
}
|
|
}
|
|
}*/
|
|
}
|
|
|
|
void MappingUI::slot_UpdateAllDieStatus(double xCoord, double yCoord)
|
|
{
|
|
for (auto& iter : m_allDieItem)
|
|
{
|
|
if (iter->Base() != true && iter->Mark() != true)
|
|
{
|
|
if (!(xCoord - JUDGE_DECIMAL <= iter->xCoord() &&
|
|
xCoord + JUDGE_DECIMAL >= iter->xCoord() &&
|
|
yCoord - JUDGE_DECIMAL <= iter->yCoord() &&
|
|
yCoord + JUDGE_DECIMAL >= iter->yCoord()))
|
|
{
|
|
iter->Select(false);
|
|
iter->setBrush(Qt::NoBrush);
|
|
}
|
|
else
|
|
{
|
|
//更新die相关信息
|
|
m_curDieCoordX = xCoord;
|
|
m_curDieCoordY = yCoord;
|
|
m_curAreaIdX = iter->AreaIdX();
|
|
m_curAreaIdY = iter->AreaIdY();
|
|
m_curDie = iter;
|
|
}
|
|
}
|
|
}
|
|
QString str = QString::number(xCoord) + "," + QString::number(yCoord);
|
|
ui.label->setText(str);
|
|
}
|