MCPcopy Create free account
hub / github.com/OpenBoardView/OpenBoardView / DrawAnnotations

Method DrawAnnotations

src/openboardview/BoardView.cpp:3014–3060  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3012}
3013
3014inline void BoardView::DrawAnnotations(ImDrawList *draw) {
3015
3016 if (!config.showAnnotations) return;
3017
3018 draw->ChannelsSetCurrent(kChannelAnnotations);
3019
3020 for (auto &ann : m_annotations.annotations) {
3021 if (ann.side == m_current_side) {
3022 ImVec2 a, b, s;
3023 if (debug) fprintf(stderr, "%d:%d:%f %f: %s\n", ann.id, ann.side, ann.x, ann.y, ann.note.c_str());
3024 a = s = CoordToScreen(ann.x, ann.y);
3025 a.x += DPI(config.annotationBoxOffset);
3026 a.y -= DPI(config.annotationBoxOffset);
3027 b = ImVec2(a.x + DPI(config.annotationBoxSize), a.y - DPI(config.annotationBoxSize));
3028
3029 if ((ann.hovered == true) && (ImGui::IsWindowHovered())) {
3030 char buf[60];
3031
3032 snprintf(buf, sizeof(buf), "%s", ann.note.c_str());
3033 buf[50] = '\0';
3034
3035 ImGui::PushStyleColor(ImGuiCol_Text, m_colors.annotationPopupTextColor);
3036 ImGui::PushStyleColor(ImGuiCol_PopupBg, m_colors.annotationPopupBackgroundColor);
3037 ImGui::BeginTooltip();
3038 ImGui::Text("%c(%0.0f,%0.0f) %s %s%c%s%c\n%s%s",
3039 m_current_side ? 'B' : 'T',
3040 ann.x,
3041 ann.y,
3042 ann.net.c_str(),
3043 ann.part.c_str(),
3044 ann.part.size() && ann.pin.size() ? '[' : ' ',
3045 ann.pin.c_str(),
3046 ann.part.size() && ann.pin.size() ? ']' : ' ',
3047 buf,
3048 ann.note.size() > 50 ? "..." : "");
3049
3050 ImGui::EndTooltip();
3051 ImGui::PopStyleColor(2);
3052 } else {
3053 }
3054 draw->AddCircleFilled(s, DPIF(2), m_colors.annotationStalkColor, 8);
3055 draw->AddRectFilled(a, b, m_colors.annotationBoxColor);
3056 draw->AddRect(a, b, m_colors.annotationStalkColor);
3057 draw->AddLine(s, a, m_colors.annotationStalkColor);
3058 }
3059 }
3060}
3061
3062bool BoardView::HighlightedPinIsHovered(void) {
3063 ImVec2 mp = ImGui::GetMousePos();

Callers

nothing calls this directly

Calls 2

DPIFunction · 0.85
DPIFFunction · 0.85

Tested by

no test coverage detected