| | |
| | | #include "Servo.h" |
| | | #include "CPageGraph2.h" |
| | | #include "afxdialogex.h" |
| | | #include "CHMPropertyDlg.h" |
| | | #include "CEquipmentPage1.h" |
| | | #include "CEquipmentPage2.h" |
| | | |
| | | |
| | | // CPageGraph2 对话框 |
| | |
| | | ASSERT(pPin1->pData); |
| | | ASSERT(pPin2->pData); |
| | | |
| | | //int nRet = ((IPin*)pPin1->pData)->checkConnectPin((IPin*)pPin2->pData); |
| | | //if (nRet >= 0) { |
| | | // return true; |
| | | //} |
| | | |
| | | return false; |
| | | }; |
| | | listener.onConnectPin = [](PIN* pPin1, PIN* pPin2) -> bool { |
| | |
| | | ASSERT(pPin1->pData); |
| | | ASSERT(pPin2->pData); |
| | | |
| | | //int nRet = ((IPin*)pPin1->pData)->connectPin((IPin*)pPin2->pData); |
| | | //if (nRet >= 0) { |
| | | // return true; |
| | | //} |
| | | |
| | | return false; |
| | | }; |
| | | listener.onDisconnectPin = [](PIN* pPin) -> bool { |
| | | ASSERT(pPin); |
| | | ASSERT(pPin->pData); |
| | | |
| | | //int nRet = ((IPin*)pPin->pData)->disconnect(); |
| | | //if (nRet >= 0) { |
| | | // return true; |
| | | //} |
| | | |
| | | return false; |
| | | }; |
| | | listener.onDeleteEqItem = [&](EQITEM* pItem) -> bool { |
| | | ASSERT(pItem); |
| | | ASSERT(pItem->pData); |
| | | return true; |
| | | // return _filterManager.unload((CFilter*)pFilter->pData) >= 0; |
| | | return false; |
| | | }; |
| | | listener.onEqItemPosChanged = [&](EQITEM* pItem, int x, int y) -> void { |
| | | ASSERT(pItem); |
| | | }; |
| | | listener.onDblckEqItem = [&](EQITEM* pItem) -> bool { |
| | | ASSERT(pItem); |
| | | SERVO::CEquipment* pEquipment = (SERVO::CEquipment*)pItem->pData; |
| | | |
| | | CHMPropertyDlg dlg(pEquipment->getName().c_str(), 600, 680); |
| | | CEquipmentPage1* pPage1 = new CEquipmentPage1(); |
| | | pPage1->setEquipment(pEquipment); |
| | | pPage1->Create(IDD_PAGE_EQUIPMENT1); |
| | | dlg.addPage(pPage1, "test1"); |
| | | |
| | | CEquipmentPage2* pPage2 = new CEquipmentPage2(); |
| | | pPage2->setEquipment(pEquipment); |
| | | pPage2->Create(IDD_PAGE_EQUIPMENT2); |
| | | dlg.addPage(pPage2, "Glass"); |
| | | |
| | | dlg.DoModal(); |
| | | return true; |
| | | }; |
| | | listener.onRclickEqItem = [&](EQITEM* pItem) -> bool { |
| | | ASSERT(pItem); |
| | | |
| | | CMenu menu, menuCommand; |
| | | CMenu* pPopupMenu; |
| | | menu.LoadMenu(IDR_MENU_EQSGRAPH_ITEM); |
| | | pPopupMenu = menu.GetSubMenu(0); |
| | | |
| | | |
| | | // 显示模式 |
| | | pPopupMenu->EnableMenuItem(ID_EQSGRAPHITEM_SMALL, MF_DISABLED | MF_GRAYED); |
| | | pPopupMenu->EnableMenuItem(ID_EQSGRAPHITEM_NORMAL, MF_DISABLED | MF_GRAYED); |
| | | pPopupMenu->EnableMenuItem(ID_EQSGRAPHITEM_LARGE, MF_DISABLED | MF_GRAYED); |
| | | if (pItem->nShowType == ITEM_SMALL) { |
| | | pPopupMenu->CheckMenuRadioItem(ID_EQSGRAPHITEM_SMALL, ID_EQSGRAPHITEM_LARGE, ID_EQSGRAPHITEM_SMALL, MF_CHECKED); |
| | | } |
| | | else if (pItem->nShowType == ITEM_LARGE) { |
| | | pPopupMenu->CheckMenuRadioItem(ID_EQSGRAPHITEM_SMALL, ID_EQSGRAPHITEM_LARGE, ID_EQSGRAPHITEM_LARGE, MF_CHECKED); |
| | | } |
| | | else { |
| | | pPopupMenu->CheckMenuRadioItem(ID_EQSGRAPHITEM_SMALL, ID_EQSGRAPHITEM_LARGE, ID_EQSGRAPHITEM_NORMAL, MF_CHECKED); |
| | | } |
| | | |
| | | |
| | | |
| | | POINT pt; |
| | | GetCursorPos(&pt); |
| | | int nCmd = pPopupMenu->TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_TOPALIGN, pt.x, pt.y, this, NULL); |
| | | if (nCmd == ID_EQSGRAPHITEM_SMALL) { |
| | | m_pEqsGraphWnd->SetItemType(pItem, ITEM_SMALL); |
| | | } |
| | | else if (nCmd == ID_EQSGRAPHITEM_NORMAL) { |
| | | m_pEqsGraphWnd->SetItemType(pItem, ITEM_NORMAL); |
| | | } |
| | | else if (nCmd == ID_EQSGRAPHITEM_LARGE) { |
| | | m_pEqsGraphWnd->SetItemType(pItem, ITEM_LARGE); |
| | | } |
| | | |
| | | |
| | | // 测试 |
| | | else if (nCmd == ID_EQSGRAPHITEM_TEST1) { |
| | | SERVO::CEquipment* pEquipment = (SERVO::CEquipment*)pItem->pData; |
| | | pEquipment->outputGlass(0); |
| | | } |
| | | else if (nCmd == ID_EQSGRAPHITEM_TEST2) { |
| | | SERVO::CEquipment* pEquipment = (SERVO::CEquipment*)pItem->pData; |
| | | pEquipment->outputGlass(1); |
| | | } |
| | | else if (nCmd == ID_EQSGRAPHITEM_TEST3) { |
| | | SERVO::CEquipment* pEquipment = (SERVO::CEquipment*)pItem->pData; |
| | | SERVO::CGlass* pGlass = pEquipment->getFrontGlass(); |
| | | if (pGlass != nullptr) { |
| | | std::string strDescription; |
| | | SERVO::CPath* pPath = pGlass->getPath(); |
| | | while (pPath != nullptr) { |
| | | pPath->getDescription(strDescription); |
| | | AfxMessageBox(strDescription.c_str()); |
| | | pPath = pPath->getNext(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | return true; |
| | | }; |
| | | listener.onSelectEqItem = [&](EQITEM* pItem) -> bool { |
| | | ASSERT(pItem); |
| | | SERVO::CEquipment* pEquipment = (SERVO::CEquipment*)pItem->pData; |
| | | theApp.m_model.notifyPtr(RX_CODE_SELECT_EQUIPMENT, pEquipment); |
| | | |
| | | return true; |
| | | }; |
| | | |
| | |
| | | void CPageGraph2::OnDestroy() |
| | | { |
| | | CDialogEx::OnDestroy(); |
| | | SaveEqsGraphData(); |
| | | |
| | | if (m_hbrBkgnd != nullptr) { |
| | | ::DeleteObject(m_hbrBkgnd); |
| | |
| | | #define OUTPIN 2 |
| | | void CPageGraph2::AddEqToGraphWnd(SERVO::CEquipment* pEquipment) |
| | | { |
| | | int x, y; |
| | | GetItemDataFormIni(pEquipment->getName().c_str(), x, y); |
| | | |
| | | EQITEM* pItem = m_pEqsGraphWnd->AddItem(0, pEquipment->getName().c_str(), (DWORD_PTR)pEquipment); |
| | | m_pEqsGraphWnd->SetItemType(pItem, ITEM_SMALL); |
| | | if (x > 0 && y > 0) { |
| | | m_pEqsGraphWnd->SetItemPos(pItem, x, y); |
| | | } |
| | | |
| | | std::vector<SERVO::CPin*>& inPins = pEquipment->getInputPins(); |
| | | for (auto inPin : inPins) { |
| | | m_pEqsGraphWnd->AddPin(pItem, INPIN, inPin->getName().c_str(), (DWORD_PTR)inPin); |
| | |
| | | if (1 == nIDEvent) { |
| | | KillTimer(1); |
| | | std::list<SERVO::CEquipment*>& eqs = theApp.m_model.m_master.getEquipmentList(); |
| | | for (auto item : eqs) { |
| | | AddEqToGraphWnd(item); |
| | | for (auto eq : eqs) { |
| | | AddEqToGraphWnd(eq); |
| | | } |
| | | |
| | | for (auto eq : eqs) { |
| | | auto& pins = eq->getOutputPins(); |
| | | for (auto pin : pins) { |
| | | SERVO::CPin* pPin2 = pin->getConnectedPin(); |
| | | if (pPin2 != nullptr) { |
| | | m_pEqsGraphWnd->ConnectPin((DWORD_PTR)eq, (DWORD_PTR)pin, (DWORD_PTR)pPin2->getEquipment(), (DWORD_PTR)pPin2); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | CDialogEx::OnTimer(nIDEvent); |
| | | } |
| | | |
| | | void CPageGraph2::SaveEqsGraphData() |
| | | { |
| | | char szFilepath[MAX_PATH]; |
| | | CString strValue; |
| | | sprintf_s(szFilepath, MAX_PATH, "%s\\EqsGraph.ini", (LPTSTR)(LPCTSTR)theApp.m_strAppDir); |
| | | std::list<SERVO::CEquipment*>& eqs = theApp.m_model.m_master.getEquipmentList(); |
| | | for (auto item : eqs) { |
| | | EQITEM* pEqItem = m_pEqsGraphWnd->GetItem((DWORD_PTR)item); |
| | | |
| | | strValue.Format(_T("%d"), pEqItem->rect.left); |
| | | WritePrivateProfileString(item->getName().c_str(), _T("Left"), |
| | | (LPTSTR)(LPCTSTR)strValue, szFilepath); |
| | | strValue.Format(_T("%d"), pEqItem->rect.top); |
| | | WritePrivateProfileString(item->getName().c_str(), _T("Top"), |
| | | (LPTSTR)(LPCTSTR)strValue, szFilepath); |
| | | } |
| | | } |
| | | |
| | | void CPageGraph2::GetItemDataFormIni(const char* pszItemName, int& left, int& top) |
| | | { |
| | | char szFilepath[MAX_PATH]; |
| | | CString strValue; |
| | | sprintf_s(szFilepath, MAX_PATH, "%s\\EqsGraph.ini", (LPTSTR)(LPCTSTR)theApp.m_strAppDir); |
| | | left = GetPrivateProfileInt(pszItemName, _T("Left"), 0, szFilepath); |
| | | top = GetPrivateProfileInt(pszItemName, _T("Top"), 0, szFilepath); |
| | | } |