- 면형상 배치 오류 수정(단위테스트(Unit Test) #618)

This commit is contained in:
김민식 2025-02-14 16:16:51 +09:00
parent 60064850fd
commit 312a34bd0b
3 changed files with 26 additions and 10 deletions

View File

@ -12,7 +12,7 @@ const PlacementSurface = forwardRef((props, refs) => {
const num = ['①', '②', '③', '④', '⑤'] const num = ['①', '②', '③', '④', '⑤']
const getImageUrl = () => { const getImageUrl = () => {
if (xInversion && !yInversion) { if (xInversion && !yInversion) {
return `/static/images/canvas/shape/re_${(rotate - 2) % 4 !== 0 ? Math.abs((rotate - 2) % 4) * 90 + 'deg' : 'normal'}/plane_tab${id < 10 ? '0' + id : id}.svg` return `/static/images/canvas/shape/re_${rotate % 4 !== 0 ? Math.abs(rotate % 4) * 90 + 'deg' : 'normal'}/plane_tab${id < 10 ? '0' + id : id}.svg`
} }
if (!xInversion && yInversion) { if (!xInversion && yInversion) {
@ -20,7 +20,7 @@ const PlacementSurface = forwardRef((props, refs) => {
} }
if (xInversion && yInversion) { if (xInversion && yInversion) {
return `/static/images/canvas/shape/${(rotate + 2) % 4 !== 0 ? Math.abs((rotate + 2) % 4) * 90 + 'deg' : 'normal'}/plane_tab${id < 10 ? '0' + id : id}.svg` return `/static/images/canvas/shape/${rotate % 4 !== 0 ? Math.abs(rotate % 4) * 90 + 'deg' : 'normal'}/plane_tab${id < 10 ? '0' + id : id}.svg`
} }
if (rotate < 0) { if (rotate < 0) {

View File

@ -224,7 +224,7 @@ export default function PlacementSurfaceSetting({ id, pos = { x: 50, y: 230 } })
} }
const getScale = () => { const getScale = () => {
return `scale(${yInversion ? -1 : 1}, ${xInversion ? -1 : 1})` return `scale(${xInversion !== yInversion ? -1 : 1}, 1)`
} }
const getRotate = () => { const getRotate = () => {
@ -236,9 +236,23 @@ export default function PlacementSurfaceSetting({ id, pos = { x: 50, y: 230 } })
surfaceRefs.yInversion = yInversion // surfaceRefs.yInversion = yInversion //
surfaceRefs.rotate = rotate * 90 // surfaceRefs.rotate = rotate * 90 //
setIsHidden(true) setIsHidden(true)
console.log('surfaceRefs', surfaceRefs)
applySurfaceShape(surfaceRefs, selectedType, id) applySurfaceShape(surfaceRefs, selectedType, id)
} }
const handleRotate = () => {}
const handleInversion = (type) => {
if (type === 'x') {
setXInversion(!xInversion)
setRotate(xInversion ? rotate + 2 : rotate - 2)
// setXInversion(!xInversion)
} else if (type === 'y') {
// setRotate(rotate + 2)
setYInversion(!yInversion)
}
}
useEffect(() => { useEffect(() => {
setSelectedType(types[0]) setSelectedType(types[0])
}, []) }, [])
@ -280,8 +294,10 @@ export default function PlacementSurfaceSetting({ id, pos = { x: 50, y: 230 } })
</div> </div>
<div className="shape-library"> <div className="shape-library">
<button className="library-btn ico01" onClick={() => setRotate((yInversion !== xInversion ? rotate - 1 : rotate + 1) % 4)}></button> <button className="library-btn ico01" onClick={() => setRotate((yInversion !== xInversion ? rotate - 1 : rotate + 1) % 4)}></button>
<button className="library-btn ico02" onClick={() => setYInversion(!yInversion)}></button> {/* <button className="library-btn ico02" onClick={() => setYInversion(!yInversion)}></button>
<button className="library-btn ico03" onClick={() => setXInversion(!xInversion)}></button> <button className="library-btn ico03" onClick={() => setXInversion(!xInversion)}></button> */}
<button className="library-btn ico02" onClick={() => handleInversion('y')}></button>
<button className="library-btn ico03" onClick={() => handleInversion('x')}></button>
</div> </div>
</div> </div>
<div className="plane-detail-wrap"> <div className="plane-detail-wrap">

View File

@ -88,7 +88,7 @@ export function useSurfaceShapeBatch({ isHidden, setIsHidden }) {
console.log('surfaceRefs.xInversion', surfaceRefs.xInversion) console.log('surfaceRefs.xInversion', surfaceRefs.xInversion)
console.log('surfaceRefs.yInversion', surfaceRefs.yInversion) console.log('surfaceRefs.yInversion', surfaceRefs.yInversion)
console.log('surfaceRefs.rotate', surfaceRefs.rotate) console.log('surfaceRefs.rotate', surfaceRefs.rotate)
const { xInversion, yInversion, rotate } = surfaceRefs
const options = { const options = {
fill: 'transparent', fill: 'transparent',
stroke: 'black', stroke: 'black',
@ -102,9 +102,9 @@ export function useSurfaceShapeBatch({ isHidden, setIsHidden }) {
lockScalingX: true, // X 축 크기 조정 잠금 lockScalingX: true, // X 축 크기 조정 잠금
lockScalingY: true, // Y 축 크기 조정 잠금 lockScalingY: true, // Y 축 크기 조정 잠금
name: MENU.BATCH_CANVAS.SURFACE_SHAPE_BATCH_TEMP, name: MENU.BATCH_CANVAS.SURFACE_SHAPE_BATCH_TEMP,
flipX: surfaceRefs.yInversion, flipX: xInversion !== yInversion ? surfaceRefs.yInversion : false,
flipY: surfaceRefs.xInversion, flipY: xInversion !== yInversion ? surfaceRefs.xInversion : false,
angle: Math.abs(surfaceRefs.rotate), angle: xInversion && yInversion ? Math.abs((surfaceRefs.rotate + 180) % 360) : Math.abs(surfaceRefs.rotate),
originX: 'center', originX: 'center',
originY: 'center', originY: 'center',
pitch: globalPitch, pitch: globalPitch,
@ -199,7 +199,7 @@ export function useSurfaceShapeBatch({ isHidden, setIsHidden }) {
swalFire({ text: getMessage('common.canvas.validate.size'), icon: 'error' }) swalFire({ text: getMessage('common.canvas.validate.size'), icon: 'error' })
check = false check = false
} }
if (surfaceId === 3 && length3 > length1) { if (surfaceId === 3 && length3 >= length1) {
swalFire({ text: getMessage('surface.shape.validate.size.1to3'), icon: 'error' }) swalFire({ text: getMessage('surface.shape.validate.size.1to3'), icon: 'error' })
check = false check = false
} }