Skip to content

fix(drill): draw labelled alignment points on the drill map canvas - #716

Merged
fixcik merged 2 commits into
masterfrom
fix/drill-map-alignment-points
Jul 18, 2026
Merged

fix(drill): draw labelled alignment points on the drill map canvas#716
fixcik merged 2 commits into
masterfrom
fix/drill-map-alignment-points

Conversation

@fixcik

@fixcik fixcik commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Refs #715

На полотне окна «План сверловки» не отображались точки центровки (реперы и пользовательские точки), из-за чего в мастере «По точкам, вручную» было сложно ориентироваться — список справа не с чем сопоставить на карте.

Что сделано:

  • DrillMapCanvas теперь рисует эффективные точки центровки (реперные отверстия + пользовательские точки) — маркер «кольцо с крестом» из редактора панели (AlignmentPointLayer), постоянный экранный размер.
  • Рядом с каждым маркером — подпись с тем же именем, что в списке мастера («Репер N» / «Точка N»); нумерация вынесена в общий хелпер alignmentPointOrdinals и переиспользуется мастером (карта и список гарантированно совпадают).
  • AlignmentPointLayer получил опциональный проп labels (Konva Text, слой не слушает события — не влияет на hit-test и hot-path перерисовок при опросе GRBL).
  • Юнит-тест на нумерацию.

Проверено: pnpm build (tsc + i18n-check) и pnpm test (888 тестов) зелёные. Визуальную проверку в живом окне сверловки оставляю пользователю.

Summary by CodeRabbit

  • Новые возможности

    • На карте сверлильной операции отображаются выровненные и пользовательские точки с подписями.
    • Нумерация точек регистрации и пользовательских точек стала последовательной и единообразной.
    • Подписи локализуются и сохраняют читаемый размер при масштабировании.
  • Исправления

    • Улучшена согласованность обозначений точек в мастере задания рабочих нулей.
  • Тесты

    • Добавлены проверки корректной нумерации точек разных типов.

@fixcik
fixcik enabled auto-merge (squash) July 18, 2026 15:15
@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Добавлены единые порядковые номера для регистрационных и пользовательских точек, локализованные подписи на карте сверления и передача эффективных точек из редактора операции в DrillMapCanvas.

Changes

Подписи точек выравнивания

Layer / File(s) Summary
Порядковые номера и имена точек
cuprum-ui/src/lib/alignmentPoints.ts, cuprum-ui/src/lib/alignmentPoints.test.ts, cuprum-ui/src/components/drill/WorkZeroPointsWizard.tsx
Добавлена независимая нумерация регистрационных и пользовательских точек; мастер использует её при формировании отображаемых имён, а тесты проверяют порядок номеров.
Рендеринг локализованных подписей
cuprum-ui/src/components/panel/AlignmentPointLayer.tsx, cuprum-ui/src/components/drill/DrillMapCanvas.tsx
AlignmentPointLayer отображает текстовые подписи рядом с маркерами, а DrillMapCanvas формирует локализованные labels и подключает слой при валидном масштабе.
Интеграция с редактором операции
cuprum-ui/src/components/operations/DrillOperationEditor.tsx
Редактор вычисляет эффективные точки из tooling holes и alignment points и передаёт их в DrillMapCanvas.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant DrillOperationEditor
  participant effectiveAlignmentPoints
  participant DrillMapCanvas
  participant AlignmentPointLayer
  DrillOperationEditor->>effectiveAlignmentPoints: передаёт tooling_holes и alignment_points
  effectiveAlignmentPoints-->>DrillOperationEditor: возвращает эффективные точки
  DrillOperationEditor->>DrillMapCanvas: передаёт alignmentPoints
  DrillMapCanvas->>AlignmentPointLayer: передаёт координаты и локализованные labels
  AlignmentPointLayer-->>DrillMapCanvas: отображает точки и подписи
Loading

Possibly related PRs

  • fixcik/cuprum#709: Добавляет модель alignment_points, используемую для построения эффективных точек в этом изменении.

Poem

Я — кролик, прыгаю по карте,
Точки светятся в новом наряде.
Номера ровны, подписи ясны,
Регистрационные и личные — прекрасны!
Пусть сверло танцует без забот —
Кролик метки бережно несёт.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Заголовок точно отражает основное изменение: отрисовку подписанных alignment points на drill map canvas.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@fixcik
fixcik merged commit 9e94524 into master Jul 18, 2026
3 of 4 checks passed
@fixcik
fixcik deleted the fix/drill-map-alignment-points branch July 18, 2026 15:18

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
cuprum-ui/src/components/drill/DrillMapCanvas.tsx (1)

329-352: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Извлеките дублирующуюся логику в общий хук.

Код формирования подписей (alignLabels и names), использующий alignmentPointOrdinals и useTranslation, полностью дублируется в двух компонентах. Рекомендуется вынести эту логику в общий пользовательский React-хук (например, useAlignmentPointLabels), чтобы избежать дублирования кода и расхождений в будущем.

  • cuprum-ui/src/components/drill/DrillMapCanvas.tsx#L329-L352: Замените этот блок локального useMemo на вызов общего хука.
  • cuprum-ui/src/components/drill/WorkZeroPointsWizard.tsx#L134-L140: Замените локальный useMemo на вызов того же общего хука.
♻️ Пример возможного хука
import { useMemo } from "react";
import { useTranslation } from "react-i18next";
import { alignmentPointOrdinals, type EffectiveAlignmentPoint } from "`@/lib/alignmentPoints`";

export function useAlignmentPointLabels(points?: EffectiveAlignmentPoint[]) {
  const { t } = useTranslation("drill");

  return useMemo(() => {
    const m = new Map<string, string>();
    if (!points?.length) return m;

    const ord = alignmentPointOrdinals(points);
    for (const p of points) {
      const n = ord.get(p.point.id) ?? 0;
      m.set(
        p.point.id,
        p.source === "registration"
          ? t("wizard2.pointNameRegistration", { n })
          : t("wizard2.pointNameUser", { n }),
      );
    }
    return m;
  }, [points, t]);
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cuprum-ui/src/components/drill/DrillMapCanvas.tsx` around lines 329 - 352,
The alignment-point label generation is duplicated across both components. Add a
shared useAlignmentPointLabels hook using alignmentPointOrdinals and the drill
translation, then replace the local label useMemo in
cuprum-ui/src/components/drill/DrillMapCanvas.tsx lines 329-352 and
cuprum-ui/src/components/drill/WorkZeroPointsWizard.tsx lines 134-140 with that
hook; both sites should consume the shared result while preserving the existing
labels and empty-input behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@cuprum-ui/src/components/drill/DrillMapCanvas.tsx`:
- Around line 329-352: The alignment-point label generation is duplicated across
both components. Add a shared useAlignmentPointLabels hook using
alignmentPointOrdinals and the drill translation, then replace the local label
useMemo in cuprum-ui/src/components/drill/DrillMapCanvas.tsx lines 329-352 and
cuprum-ui/src/components/drill/WorkZeroPointsWizard.tsx lines 134-140 with that
hook; both sites should consume the shared result while preserving the existing
labels and empty-input behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 3a268aee-f529-4d82-8921-ce49b0aa26dc

📥 Commits

Reviewing files that changed from the base of the PR and between 0812f03 and 994d410.

📒 Files selected for processing (6)
  • cuprum-ui/src/components/drill/DrillMapCanvas.tsx
  • cuprum-ui/src/components/drill/WorkZeroPointsWizard.tsx
  • cuprum-ui/src/components/operations/DrillOperationEditor.tsx
  • cuprum-ui/src/components/panel/AlignmentPointLayer.tsx
  • cuprum-ui/src/lib/alignmentPoints.test.ts
  • cuprum-ui/src/lib/alignmentPoints.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant