배치면 이동 시 길이 계산 수정

This commit is contained in:
hyojun.choi 2026-04-20 10:27:12 +09:00
parent 2ae3c47f59
commit a5675d41d8
2 changed files with 22 additions and 2 deletions

View File

@ -543,8 +543,19 @@ export const QPolygon = fabric.util.createClass(fabric.Polygon, {
const degree = Big(Math.atan2(dy.toNumber(), dx.toNumber())).times(180).div(Math.PI).toNumber()
// 이동/undo/redo 시 기하학 drift(round-off)로 text 수치가 변동되지 않도록
// 저장된 attributes 우선 사용. 현재 corridorDimension.column에 맞춰 값 결정:
// - realDimension(배치면 메뉴): actualSize 우선
// - corridorDimension(지붕덮개 메뉴): planeSize 우선
const preservedActualSize = this.lines[i]?.attributes?.actualSize
const preservedPlaneSize = this.lines[i]?.attributes?.planeSize
const currentColumn = (typeof window !== 'undefined' && window.__currentCorridorColumn) || 'corridorDimension'
const displayValue = currentColumn === 'realDimension'
? (preservedActualSize != null ? preservedActualSize : preservedPlaneSize != null ? preservedPlaneSize : length)
: (preservedPlaneSize != null ? preservedPlaneSize : preservedActualSize != null ? preservedActualSize : length)
// Create a new text object if it doesn't exist
const text = new fabric.Text(length.toString(), {
const text = new fabric.Text(displayValue.toString(), {
left: midPoint.x,
top: midPoint.y,
fontSize: this.fontSize,

View File

@ -219,7 +219,12 @@ export const corridorDimensionSelector = selector({
key: 'corridorDimensionSelector',
get: ({ get }) => {
const settingModalFirstOptions = get(settingModalFirstOptionsState)
return settingModalFirstOptions.dimensionDisplay.find((option) => option.selected)
const selected = settingModalFirstOptions.dimensionDisplay.find((option) => option.selected)
// Fabric 클래스(QPolygon) 등 React hook 외부에서 현재 column 참조용
if (typeof window !== 'undefined' && selected) {
window.__currentCorridorColumn = selected.column
}
return selected
},
set: ({ set }, newValue) => {
//0 : 복도치수 , 1 : 실제치수
@ -229,6 +234,10 @@ export const corridorDimensionSelector = selector({
...prev,
dimensionDisplay: prev.dimensionDisplay.map((item, index) => {
if (index === newValue) {
// Fabric 클래스(QPolygon) 등 React hook 외부에서 현재 column 참조용
if (typeof window !== 'undefined') {
window.__currentCorridorColumn = item.column
}
return { ...item, selected: true }
} else {
return { ...item, selected: false }