123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- #include "TemplateControl.h"
- #include "ui_TemplateControl.h"
- #include "Src/common/JMessageTip.h"
- #include <QMenu>
- TemplateControl::TemplateControl(QWidget *parent)
- : QWidget(parent)
- , ui(new Ui::TemplateControl)
- {
- ui->setupUi(this);
- Init();
- }
- TemplateControl::~TemplateControl()
- {
- delete ui;
- }
- void TemplateControl::UpDataVal(const ns_db::CONFIG_BASE_STRUCT& control)
- {
- }
- void TemplateControl::Init()
- {
- m_manageDB = CManageDB::GetInstance();
- if (m_manageDB == nullptr)
- {
- return;
- }
- m_pProduct = m_manageDB->GetCProduct();
- if (m_pProduct == nullptr)
- {
- return;
- }
- m_pTemplateCViewInterface = ns_module::CViewInterface::GetInstance();
- m_CamerAndLamp = ns_module::CCamerAndLamp::GetInstance();
- m_vecPrTemplate = m_manageDB->GetCProduct()->GetPrTemplate();
- m_pProgramCViewInterface = ns_module::CViewInterface::GetInstance();
- for (int i = 0; i < m_vecPrTemplate.size(); i++)
- {
- AddPrTemplatePage(i, m_vecPrTemplate[i]);
- }
- ui->tempComboBox->setStyleSheet("QComboBox::item:selected {color: red;"); // 字体颜色变红
- }
- void TemplateControl::AddPrTemplatePage(int vectorIndex, PR_TEMPLATE& prTemplate)
- {
- // 显示模板ID列表
- ui->tempComboBox->addItem(QString::number(prTemplate.iTemplateId));
- }
- void TemplateControl::TemplateMoveToXYZRAxisPosition(UINT iModuleType, X_Y_Z_R_STRUCT pos)
- {
- // 将 iModuleType 转换为对应的字符串
- auto it = g_mapModuleList.find(static_cast<MODULE_LIST>(iModuleType));
- if (it != g_mapModuleList.end())
- {
- // 获取模块类型的字符串
- std::string moduleTypeStr = it->second;
- // 通过调用 ModuleMoveTo 函数,传递不同的轴类型和位置
- m_pTemplateCViewInterface->GetViewMotion()->ModuleMoveTo(moduleTypeStr, "X", pos.x);
- m_pTemplateCViewInterface->GetViewMotion()->ModuleMoveTo(moduleTypeStr, "Y", pos.y);
- m_pTemplateCViewInterface->GetViewMotion()->ModuleMoveTo(moduleTypeStr, "Z", pos.z);
- m_pTemplateCViewInterface->GetViewMotion()->ModuleMoveTo(moduleTypeStr, "R", pos.r);
- }
- else
- {
- // 如果找不到对应的模块类型,抛出错误或处理异常
- std::cerr << "Invalid module type!" << std::endl;
- }
- }
- void TemplateControl::onCreateParamPickTempClicked()
- {
- // TODO: 创建模板理解还有点问题
- int nCount = ui->tempComboBox->count();
- UINT iBondInfoId = ui->tempComboBox->itemText(nCount - 1).toInt() + 1;//当前模板叠加1
- ui->tempComboBox->addItem(QString::number(iBondInfoId));
- m_pProgramCViewInterface->GetViewMatrix()->CreateBondMatrixTemplate(BOND_MATRIX_TEMPLATE_TYPE::TEMPLATE_WAFER_PICK, iBondInfoId);
- //UpdateShowBondInfoData(iBondInfoId);
- BOND_INFO_STRUCT _stBondInfoData;
- m_manageDB->GetCProduct()->GetBondInfoData(iBondInfoId, _stBondInfoData);
- //m_curBondInfo.iPickPRStrategyId = _stBondInfoData.iPickPRStrategyId;
- m_vecPrTemplate = m_manageDB->GetCProduct()->GetPrTemplate();
- //m_vecPrStrategy = m_manageDB->GetCProduct()->GetPrStrategy();
- // UpdateTemplateParamCombox(1, _stBondInfoData.iPickPRStrategyId);
- // 更新样式
-
- ui->tempComboBox->setCurrentIndex(nCount);
-
- }
- void TemplateControl::on_TemplateControl_customContextMenuRequested(const QPoint &pos)
- {
- QMenu menu;
- QAction* pEditTemplate = menu.addAction(tr("Edit Template", "编辑模板"));
- connect(pEditTemplate, &QAction::triggered, [&]()
- {
- if (m_pTemplateCViewInterface)
- {
- m_pTemplateCViewInterface->GetViewMatrix()->ModifyBondMatrixTemplate(m_vecPrTemplate[m_nIndexvecPrTemplate].iTemplateId);
- }
- });
- QAction* pCreateTemplate = menu.addAction(tr("Create Template", "创建模板"));
- connect(pCreateTemplate, &QAction::triggered, [&]() {
- onCreateParamPickTempClicked();
- });
- QAction* pPositioningTemplate = menu.addAction(tr("Positioning Template", "定位模板"));
- connect(pPositioningTemplate, &QAction::triggered, [&]()
- {
- bool reply = JMessageTip::Message_question(tr("Confirmation", "确认操作"), tr("Are all the axes confirmed to have moved to the template position ?", "确定所有轴移动到模板位置?"), this);
- if (reply)
- {
- ns_db::PR_TEMPLATE pr = m_vecPrTemplate[m_nIndexvecPrTemplate];
- TemplateMoveToXYZRAxisPosition(pr.iModuleType, pr.stGrabPos);
- }
- });
- QAction* pLightadjus = menu.addAction(tr("Light adjus", "灯光调节"));
- connect(pLightadjus, &QAction::triggered, [&]()
- {
- if (m_CamerAndLamp!=nullptr)
- {
- //TODO: 为什么联提供一起设置在呢?
- ns_db::PR_TEMPLATE pr = m_vecPrTemplate[m_nIndexvecPrTemplate];
- m_CamerAndLamp->SetRedLight(pr.iCameraId, pr.iRedLight);
- m_CamerAndLamp->SetBlueLight(pr.iCameraId, pr.iBlueLight);
- m_CamerAndLamp->SetGreenLight(pr.iCameraId, pr.iBlueLight);
- m_CamerAndLamp->SetPointLight(pr.iCameraId, pr.iPointLight);
- }
- });
- menu.exec(this->mapToGlobal(pos));
- }
- void TemplateControl::on_tempComboBox_currentIndexChanged(int index)
- {
- m_nIndexvecPrTemplate = index;
- }
|