fix(drill): draw labelled alignment points on the drill map canvas - #716
Conversation
📝 WalkthroughWalkthroughДобавлены единые порядковые номера для регистрационных и пользовательских точек, локализованные подписи на карте сверления и передача эффективных точек из редактора операции в ChangesПодписи точек выравнивания
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: отображает точки и подписи
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
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. Comment |
There was a problem hiding this comment.
🧹 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
📒 Files selected for processing (6)
cuprum-ui/src/components/drill/DrillMapCanvas.tsxcuprum-ui/src/components/drill/WorkZeroPointsWizard.tsxcuprum-ui/src/components/operations/DrillOperationEditor.tsxcuprum-ui/src/components/panel/AlignmentPointLayer.tsxcuprum-ui/src/lib/alignmentPoints.test.tscuprum-ui/src/lib/alignmentPoints.ts
Refs #715
На полотне окна «План сверловки» не отображались точки центровки (реперы и пользовательские точки), из-за чего в мастере «По точкам, вручную» было сложно ориентироваться — список справа не с чем сопоставить на карте.
Что сделано:
DrillMapCanvasтеперь рисует эффективные точки центровки (реперные отверстия + пользовательские точки) — маркер «кольцо с крестом» из редактора панели (AlignmentPointLayer), постоянный экранный размер.alignmentPointOrdinalsи переиспользуется мастером (карта и список гарантированно совпадают).AlignmentPointLayerполучил опциональный пропlabels(KonvaText, слой не слушает события — не влияет на hit-test и hot-path перерисовок при опросе GRBL).Проверено:
pnpm build(tsc + i18n-check) иpnpm test(888 тестов) зелёные. Визуальную проверку в живом окне сверловки оставляю пользователю.Summary by CodeRabbit
Новые возможности
Исправления
Тесты