| 2438 | } |
| 2439 | |
| 2440 | inline void BoardView::DrawParts(ImDrawList *draw) { |
| 2441 | // float psz = (float)m_pinDiameter * 0.5f * m_scale; |
| 2442 | double angle; |
| 2443 | double distance = 0; |
| 2444 | uint32_t color = m_colors.partOutlineColor; |
| 2445 | // int rendered = 0; |
| 2446 | char p0, p1; // first two characters of the part name, code-writing |
| 2447 | // convenience more than anything else |
| 2448 | |
| 2449 | draw->ChannelsSetCurrent(kChannelPolylines); |
| 2450 | /* |
| 2451 | * If a pin has been selected, we mask out the colour to |
| 2452 | * enhance (relatively) the appearance of the pin(s) |
| 2453 | */ |
| 2454 | if (config.pinSelectMasks && ((m_pinSelected) || m_pinHighlighted.size())) { |
| 2455 | color = (m_colors.partOutlineColor & m_colors.selectedMaskParts) | m_colors.orMaskParts; |
| 2456 | } |
| 2457 | |
| 2458 | for (auto &part : m_board->Components()) { |
| 2459 | int pincount = 0; |
| 2460 | double min_x, min_y, max_x, max_y, aspect; |
| 2461 | std::vector<ImVec2> pva; |
| 2462 | std::array<ImVec2, 4> dbox; // default box, if there's nothing else claiming to render the part different. |
| 2463 | |
| 2464 | if (part->is_dummy()) continue; |
| 2465 | |
| 2466 | /* |
| 2467 | * |
| 2468 | * When we first load the board, the outline of each part isn't (yet) rendered |
| 2469 | * or determined/calculated. So, the first time we display the board we |
| 2470 | * compute the outline and store it for later. |
| 2471 | * |
| 2472 | * This also sets the pin diameters too. |
| 2473 | * |
| 2474 | */ |
| 2475 | if (!part->outline_done) { // should only need to do this once for most parts |
| 2476 | if (part->pins.size() == 0) { |
| 2477 | if (debug) fprintf(stderr, "WARNING: Drawing empty part %s\n", part->name.c_str()); |
| 2478 | draw->AddRect(CoordToScreen(part->p1.x + DPIF(10), part->p1.y + DPIF(10)), |
| 2479 | CoordToScreen(part->p2.x - DPIF(10), part->p2.y - DPIF(10)), |
| 2480 | 0xff0000ff); |
| 2481 | draw->AddText( |
| 2482 | CoordToScreen(part->p1.x + DPIF(10), part->p1.y - DPIF(50)), m_colors.partTextColor, part->name.c_str()); |
| 2483 | continue; |
| 2484 | } |
| 2485 | |
| 2486 | for (auto &pin : part->pins) { |
| 2487 | pincount++; |
| 2488 | |
| 2489 | // scale box around pins as a fallback, else either use polygon or convex |
| 2490 | // hull for better shape fidelity |
| 2491 | if (pincount == 1) { |
| 2492 | min_x = pin->position.x; |
| 2493 | min_y = pin->position.y; |
| 2494 | max_x = min_x; |
| 2495 | max_y = min_y; |
| 2496 | } |
| 2497 |
nothing calls this directly
no test coverage detected