private PhysicalLayoutModel InjectDesign(PhysicalLayoutModel physicalLayout, QcLayout qcLayout) { if (qcLayout == default) { return(physicalLayout); } var counter = 0; return(new PhysicalLayoutModel { PhysicalRows = physicalLayout.PhysicalRows .Select(x => { return new PhysicalRow { PhysicalKeys = x.PhysicalKeys .Select(y => { var key = qcLayout.QcKeys.ElementAtOrDefault(counter); counter++; return new PhysicalKey(y.Tag) { Label = key.Label, Row = key.Row, Col = key.Col, Width = key.Width, Height = key.Height, }; }), }; }), }); }
private PhysicalLayoutModel InjectDesign(PhysicalLayoutModel physicalLayout, QcLayout qcLayout) { if (qcLayout == default) { return(physicalLayout); } double originY = 0; var counter = 0; return(new PhysicalLayoutModel { PhysicalRows = physicalLayout.PhysicalRows .Select((row, rowIndex) => { double offsetX = 0; double offsetY = 0; return new PhysicalRow { PhysicalKeys = row.PhysicalKeys .Select((key, colIndex) => { var qcKey = qcLayout.QcKeys.ElementAtOrDefault(counter); if (rowIndex == 0 && colIndex == 0) { originY = qcKey.Y; offsetY = qcKey.Y; } else if (colIndex == 0) { offsetY = qcKey.Y - originY - rowIndex; } else { var preQcKey = qcLayout.QcKeys.ElementAtOrDefault(counter - 1); offsetY = qcKey.Y - preQcKey.Y; } counter++; var physKey = new PhysicalKey(key.Tag) { Label = qcKey.Label, Row = rowIndex, Col = colIndex, OffsetX = Math.Round(qcKey.X - offsetX - colIndex, 3), OffsetY = Math.Round(offsetY, 3), Width = qcKey.Width, Height = qcKey.Height, }; if (physKey.Width != 0) { offsetX += physKey.Width - 1; } if (physKey.OffsetX != 0) { offsetX += physKey.OffsetX; } return physKey; }), }; }), }); }