void CCircuitView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { // TODO: ¿©±â¿¡ ¸Þ½ÃÁö 󸮱â Äڵ带 Ãß°¡ ¹×/¶Ç´Â ±âº»°ªÀ» È£ÃâÇÕ´Ï´Ù. if (nChar == VK_DELETE) { CLogicSimulatorDoc *pDoc = (CLogicSimulatorDoc *)GetDocument(); int lin = pDoc->currBox->lines.size(); int lon = pDoc->currBox->logicInfo.size(); for (int i = 0; i < lin; i++) { if (pDoc->currBox->lines.at(i)->isSelected == TRUE) { delete pDoc->currBox->lines.at(i); pDoc->currBox->lines.erase(pDoc->currBox->lines.begin() + i); lin--; } } for (int i = 0; i < lon; i++) { if (pDoc->currBox->logicInfo.at(i)->isSelected == TRUE) { //OUT & INPIN Ưº° Ãë±Þ if (pDoc->currBox->logicInfo.at(i)->objectName == PIN) { Pin* TP = (Pin*)pDoc->currBox->logicInfo.at(i); if (TP->getConNum() >= 0) pDoc->currBox->ConnInput[TP->getConNum()] = FALSE; pDoc->currBox->NumInput--; } else if (pDoc->currBox->logicInfo.at(i)->objectName == OUTPIN) { Out* TO = (Out*)pDoc->currBox->logicInfo.at(i); if (TO->getConNum() >= 0) pDoc->currBox->ConnOutput[TO->getConNum()] = FALSE; pDoc->currBox->NumOuput--; } delete pDoc->currBox->logicInfo.at(i); pDoc->currBox->logicInfo.erase(pDoc->currBox->logicInfo.begin() + i); lon--; } } pDoc->currBox->LineCheck(); pDoc->CheckPoint(); Invalidate(); } CView::OnKeyDown(nChar, nRepCnt, nFlags); }
void CCircuitView::OnEditCut() { CLogicSimulatorDoc *pDoc = (CLogicSimulatorDoc *)GetDocument(); int lin = pDoc->currBox->lines.size(); int lon = pDoc->currBox->logicInfo.size(); pDoc->currBox->store.lines.clear(); pDoc->currBox->store.type.clear(); pDoc->currBox->store.name.clear(); CUTED = TRUE; PASTED = FALSE; //º¹»çÇÒ ¼± Á¤º¸¹Þ±â for (int i = 0; i < lin; i++) { if (pDoc->currBox->lines.at(i)->isSelected == TRUE) { LineObject temp = *pDoc->currBox->lines.at(i); temp.line[0].x += 50; temp.line[0].y += 50; temp.line[1].x += 50; temp.line[1].y += 50; pDoc->currBox->store.lines.push_back(temp); } } //º¹»çÇÒ ¿ÀºêÁ§Æ® Á¤º¸ ¹Þ±â for (int i = 0; i < lon; i++) { if (pDoc->currBox->logicInfo.at(i)->isSelected == TRUE) { pDoc->currBox->store.name.push_back(pDoc->currBox->logicInfo.at(i)->objectName); pDoc->currBox->store.type.push_back(pDoc->currBox->logicInfo.at(i)->objectType); pDoc->currBox->store.facing = pDoc->currBox->logicInfo.at(i)->facing; pDoc->currBox->store.dec.x = pDoc->currBox->logicInfo.at(i)->bottom.x + 50; pDoc->currBox->store.dec.y = (pDoc->currBox->logicInfo.at(i)->top.y + pDoc->currBox->logicInfo.at(i)->bottom.y) / 2 + 50; } } //º¹»çÇÏ°í Áö¿öÁØ´Ù. lin = pDoc->currBox->lines.size(); lon = pDoc->currBox->logicInfo.size(); for (int i = 0; i < lin; i++) { if (pDoc->currBox->lines.at(i)->isSelected == TRUE) { delete pDoc->currBox->lines.at(i); pDoc->currBox->lines.erase(pDoc->currBox->lines.begin() + i); lin--; } } for (int i = 0; i < lon; i++) { if (pDoc->currBox->logicInfo.at(i)->isSelected == TRUE) { //OUT & INPIN Ưº° Ãë±Þ if (pDoc->currBox->logicInfo.at(i)->objectName == PIN) { Pin* TP = (Pin*)pDoc->currBox->logicInfo.at(i); if (TP->getConNum() >= 0) pDoc->currBox->ConnInput[TP->getConNum()] = FALSE; pDoc->currBox->NumInput--; } else if (pDoc->currBox->logicInfo.at(i)->objectName == OUTPIN) { Out* TO = (Out*)pDoc->currBox->logicInfo.at(i); if (TO->getConNum() >= 0) pDoc->currBox->ConnOutput[TO->getConNum()] = FALSE; pDoc->currBox->NumOuput--; } delete pDoc->currBox->logicInfo.at(i); pDoc->currBox->logicInfo.erase(pDoc->currBox->logicInfo.begin() + i); lon--; } } Invalidate(); }
void Graph::OnPaint() { CPaintDC dc(this); // device context for painting CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd(); CLogicSimulatorDoc* pDoc = (CLogicSimulatorDoc *)pFrame->GetActiveDocument(); dc.SetBkMode(TRANSPARENT); if (previousInput < 0) previousInput = pDoc->currBox->NumInput; else if (previousInput != pDoc->currBox->NumInput) { UpdateGraph = 1; previousInput = pDoc->currBox->NumInput; } dc.DrawText(_T("입력핀"), CRect(0, 0, 50, 50), DT_LEFT); int input = 0 , curr =20; for (int i = 0; i < pDoc->currBox->logicInfo.size(); i++) { CString Fornumber; if (pDoc->currBox->logicInfo.at(i)->objectName == PIN) { Pin* PT = (Pin*)pDoc->currBox->logicInfo.at(i); Fornumber.Format(_T("ID : %d, Label : %s"), PT->getConNum(), PT->label); if (PT->getConNum() >= 0) inputValue[PT->getConNum()] = PT->getOutput(); dc.TextOutW(0, curr, Fornumber); curr += 50; } } dc.TextOutW(0, curr, _T("출력핀")); curr += 20; for (int i = 0; i < pDoc->currBox->logicInfo.size(); i++) { CString Fornumber; if (pDoc->currBox->logicInfo.at(i)->objectName == OUTPIN) { Out* PT = (Out*)pDoc->currBox->logicInfo.at(i); Fornumber.Format(_T("ID : %d, Label : %s"), PT->getConNum(), PT->label); if (PT->getConNum() >= 0) outputValue[PT->getConNum()] = PT->getOutput(); dc.TextOutW(0, curr, Fornumber); curr += 50; } } int i ,final_i; CPen pen; pen.CreatePen(PS_SOLID, 3, RGB(255, 0, 0)); // 빨간색 펜 생성 dc.SelectObject(&pen); for (i = 0; i < pDoc->currBox->NumInput; i++) { for (int j = 1; j < (count < 200 ? count : 200); j++) { inputline[i][j - 1].x += 5; } for (int j = (count < 200 ? count : 200); j >= 1; j--) { inputline[i][j].x = inputline[i][j - 1].x; inputline[i][j].y = inputline[i][j - 1].y; } //그리기 if (inputValue[i]) { inputline[i][0].x = 0; inputline[i][0].y = 45 + 50 * i; } else { inputline[i][0].x = 0; inputline[i][0].y = 60 + 50 * i; } dc.Polyline(inputline[i], (count < 200 ? count : 200)); } final_i = i; if (UpdateGraph) { for (i = 0; i < 10; i++) { for (int j = 0; j < 250; j++) { outputline[i][j].y = 80 + 50 * (i + final_i); } } UpdateGraph = false; } pen.DeleteObject(); pen.CreatePen(PS_SOLID, 3, RGB(0, 0, 255)); // 파란색 펜 생성 dc.SelectObject(&pen); for (i = 0; i < pDoc->currBox->NumOuput; i++) { for (int j = 1; j < (count < 200 ? count : 200); j++) { outputline[i][j - 1].x += 5; } for (int j = (count < 200 ? count : 200); j >= 1; j--) { outputline[i][j].x = outputline[i][j - 1].x; outputline[i][j].y = outputline[i][j - 1].y; } //그리기 if (outputValue[i]) { outputline[i][0].x = 0; outputline[i][0].y = 65 + 50 * (i + final_i); } else { outputline[i][0].x = 0; outputline[i][0].y = 80 + 50 * (i + final_i); } dc.Polyline(outputline[i], (count < 200 ? count : 200)); } //dc.Rectangle(10, 10, 10, 100); }