import React from 'react'; import type { Drawing, DrawingToolId } from '../types'; import { useDraggablePanel } from '../hooks/useDraggablePanel'; interface ObjectTreeProps { drawings: Drawing[]; onToggleVisible: (id: string) => void; onRemove: (id: string) => void; onClose: () => void; } // 드로잉 타입 → 한글 이름 const TOOL_LABEL: Partial> = { cursor: '커서', hline: '수평선', hline_ray: '수평 레이', vline: '수직선', cross_line: '십자선', info_line: '정보선', trendline: '추세선', extended_line: '연장 추세선', ray: '레이', arrow: '화살표 추세선', fib: '피보나치 되돌림', fib_ext: '피보나치 확장', fib_channel: '피보나치 채널', fibtz: '피보나치 타임존', fib_speed_fan: '스피드 리지스턴스 팬', fib_trend_time: '추세기반 피보나치 시간', fib_circles: '피보나치 서클', fib_spiral: '피보나치 스파이럴', fib_speed_arc: '스피드 리지스턴스 아크', fib_wedge: '피보나치 웻지', pitchfork: '앤드류스 피치포크', pitchfork_schiff: '쉬프 피치포크', pitchfork_inside: '인사이드 피치포크', gann_box: '갠 박스', gann_square: '갠 스퀘어', gann_fan: '갠 팬', xabcd: 'XABCD 패턴', cypher: '사이퍼 패턴', abcd: 'ABCD 패턴', head_shoulders: '헤드 앤 숄더', channel: '추세 채널', parallel_channel: '평행 채널', disjoint_channel: '분리 채널', flat_top_bottom: '플랫 탑/바텀 채널', rect: '사각형', rotated_rect: '회전 사각형', circle: '원', ellipse: '타원', triangle: '삼각형', parallelogram: '평행사변형', polyline: '다각형', arc: '호', text: '텍스트', callout: '콜아웃', price_note: '가격 주석', arrow_mark_up: '위쪽 화살표', arrow_mark_down: '아래쪽 화살표', price_label: '가격 레이블', pencil: '자유곡선', highlight: '형광펜', trend_angle: '추세각', long_position: '매수 포지션', short_position: '숏 포지션', forecast: '예측', bar_pattern: '봉패턴', ghost_feed: '고스트피드', projection_tool: '프로젝션', anchored_vwap: '앵커드 VWAP', fixed_volume_profile: '볼륨 프로파일', price_range: '가격범위', wedge_pattern: '세모 패턴', three_drives: '쓰리 드라이브 패턴', elliott_impulse: '엘리엇 임펄스 파동', elliott_correction: '엘리엇 코렉션 파동', elliott_triangle_wave: '엘리엇 트라이앵글 웨이브', elliott_double_combo: '엘리엇 다블콤보 파동', arrow_mark: '화살표', anchored_arrow: '앵커 화살표', arrow_mark_left: '왼화살표', arrow_mark_right: '오른화살표', fixed_text: '고정위치문자', note_text: '노트', pin_mark: '핀', table_tool: '테이블', comment_mark: '코멘트', guide_line: '길잡이', flag_mark: '플래그', measure: '가격 측정', date_range: '날짜 범위', date_price_range: '날짜&가격 범위', data_window: '데이터 창', zoom: '확대/축소', magnifier: '돋보기', }; // 아이콘 기본값 const DefaultIcon = () => ; // 타입별 아이콘 const ToolIcon: Partial> = { cursor: , hline: , vline: , trendline: , ray: , fib: , fibtz: , rect: , circle: , triangle: , channel: , measure: , text: T, pencil: , pitchfork: , }; const IcEye = ({ visible }: { visible: boolean }) => visible ? ( ) : ( ); const IcTrash = () => ( ); const ObjectTree: React.FC = ({ drawings, onToggleVisible, onRemove, onClose }) => { const { panelRef, dragging, onHeaderPointerDown, headerTouchStyle, panelStyle, headerCursor, } = useDraggablePanel({ centerOnMount: true }); return (
{ if (e.target === e.currentTarget) onClose(); }}>
e.stopPropagation()} >
오브젝트 트리
{drawings.length === 0 ? (
드로잉이 없습니다
) : (
{[...drawings].reverse().map((d, idx) => { const visible = d.visible !== false; return (
{/* 색상 스와치 */} {/* 타입 아이콘 */} {ToolIcon[d.type as DrawingToolId] ?? } {/* 이름 */} {TOOL_LABEL[d.type as DrawingToolId] ?? d.type} {d.text && "{d.text}"} {/* 번호 (역순) */} #{drawings.length - idx} {/* 가시성 토글 */} {/* 삭제 */}
); })}
)}
); }; export default ObjectTree;