보조선 작성 수정
This commit is contained in:
parent
53a67b9be0
commit
1c6bb52946
@ -757,6 +757,14 @@ export function useCommonUtils() {
|
||||
})
|
||||
}
|
||||
|
||||
const deleteOuterLineObject = () => {
|
||||
const selectedOuterLine = canvas.getActiveObject()
|
||||
if (selectedOuterLine && selectedOuterLine.name === 'outerLine') {
|
||||
canvas.remove(selectedOuterLine)
|
||||
canvas.renderAll()
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
commonFunctions,
|
||||
dimensionSettings,
|
||||
@ -767,5 +775,6 @@ export function useCommonUtils() {
|
||||
copyObject,
|
||||
editText,
|
||||
changeDimensionExtendLine,
|
||||
deleteOuterLineObject,
|
||||
}
|
||||
}
|
||||
|
||||
@ -561,17 +561,62 @@ export function useAuxiliaryDrawing(id) {
|
||||
}
|
||||
|
||||
const roofBases = canvas.getObjects().filter((obj) => obj.name === 'roofBase')
|
||||
|
||||
const allLines = [...auxiliaryLines]
|
||||
/*const allLines = [...auxiliaryLines]
|
||||
|
||||
roofBases.forEach((roofBase) => {
|
||||
roofBase.lines.forEach((line) => {
|
||||
allLines.push(line)
|
||||
})
|
||||
allLines.push(...roofBase.lines)
|
||||
})*/
|
||||
|
||||
const innerLines = [...auxiliaryLines]
|
||||
const roofLines = []
|
||||
|
||||
roofBases.forEach((roofBase) => {
|
||||
innerLines.push(...roofBase.innerLines)
|
||||
roofLines.push(...roofBase.lines)
|
||||
})
|
||||
|
||||
auxiliaryLines.forEach((line1) => {
|
||||
allLines.forEach((line2) => {
|
||||
let interSectionPointsWithRoofLines = []
|
||||
|
||||
//지붕선과 만나는 점을 찾는다.
|
||||
roofLines.forEach((line2) => {
|
||||
const intersectionPoint = calculateIntersection(line1, line2)
|
||||
if (!intersectionPoint) {
|
||||
return
|
||||
}
|
||||
// 기존 점과 겹치는지 확인
|
||||
if (interSectionPointsWithRoofLines.some((point) => point.x === intersectionPoint.x && point.y === intersectionPoint.y)) {
|
||||
return
|
||||
}
|
||||
|
||||
interSectionPointsWithRoofLines.push(intersectionPoint)
|
||||
})
|
||||
|
||||
//지붕선과 만나는 점이 두개일 경우 넘친 보조선을 잘라준다 (케라바로 만든 마루)
|
||||
if (interSectionPointsWithRoofLines.length === 2) {
|
||||
const newLine = addLine(
|
||||
[
|
||||
interSectionPointsWithRoofLines[0].x,
|
||||
interSectionPointsWithRoofLines[0].y,
|
||||
interSectionPointsWithRoofLines[1].x,
|
||||
interSectionPointsWithRoofLines[1].y,
|
||||
],
|
||||
{
|
||||
stroke: 'black',
|
||||
strokeWidth: 1,
|
||||
selectable: false,
|
||||
name: 'auxiliaryLine',
|
||||
isFixed: true,
|
||||
},
|
||||
)
|
||||
lineHistory.current.push(newLine)
|
||||
removeLine(line1)
|
||||
intersectionPoints.current.push(...interSectionPointsWithRoofLines)
|
||||
return
|
||||
}
|
||||
|
||||
//보조선과 만나는 점을 찾는다.
|
||||
innerLines.forEach((line2) => {
|
||||
if (line1 === line2) {
|
||||
return
|
||||
}
|
||||
@ -615,6 +660,53 @@ export function useAuxiliaryDrawing(id) {
|
||||
lineHistory.current.push(newLine)
|
||||
removeLine(line1)
|
||||
})
|
||||
|
||||
/*auxiliaryLines.forEach((line1) => {
|
||||
allLines.forEach((line2) => {
|
||||
if (line1 === line2) {
|
||||
return
|
||||
}
|
||||
const intersectionPoint = calculateIntersection(line1, line2)
|
||||
if (!intersectionPoint) {
|
||||
return
|
||||
}
|
||||
roofAdsorptionPoints.current.push(intersectionPoint)
|
||||
intersectionPoints.current.push(intersectionPoint)
|
||||
|
||||
const distance1 = distanceBetweenPoints({ x: line1.x1, y: line1.y1 }, intersectionPoint)
|
||||
const distance2 = distanceBetweenPoints({ x: line1.x2, y: line1.y2 }, intersectionPoint)
|
||||
|
||||
if (distance1 === 0 || distance2 === 0) {
|
||||
return
|
||||
}
|
||||
//historyLine에서 기존 line을 제거한다.
|
||||
lineHistory.current = lineHistory.current.filter((history) => history !== line1)
|
||||
|
||||
let newLine
|
||||
|
||||
if (distance1 >= distance2) {
|
||||
newLine = addLine([line1.x1, line1.y1, intersectionPoint.x, intersectionPoint.y], {
|
||||
stroke: 'black',
|
||||
strokeWidth: 1,
|
||||
selectable: false,
|
||||
name: 'auxiliaryLine',
|
||||
isFixed: true,
|
||||
intersectionPoint,
|
||||
})
|
||||
} else {
|
||||
newLine = addLine([line1.x2, line1.y2, intersectionPoint.x, intersectionPoint.y], {
|
||||
stroke: 'black',
|
||||
strokeWidth: 1,
|
||||
selectable: false,
|
||||
name: 'auxiliaryLine',
|
||||
isFixed: true,
|
||||
intersectionPoint,
|
||||
})
|
||||
}
|
||||
lineHistory.current.push(newLine)
|
||||
removeLine(line1)
|
||||
})
|
||||
})*/
|
||||
})
|
||||
addCanvasMouseEventListener('mouse:move', mouseMove)
|
||||
}
|
||||
|
||||
@ -70,9 +70,7 @@ export function useMovementSetting(id) {
|
||||
updownEvent(e)
|
||||
}
|
||||
}
|
||||
const flowLineEvent = (e) => {
|
||||
console.log('flow')
|
||||
}
|
||||
const flowLineEvent = (e) => {}
|
||||
|
||||
const updownEvent = (e) => {
|
||||
const target = canvas.getActiveObject()
|
||||
@ -113,18 +111,24 @@ export function useMovementSetting(id) {
|
||||
canvas?.renderAll()
|
||||
}
|
||||
|
||||
const getOnlyDecimal = function (_number, _length) {
|
||||
let result
|
||||
|
||||
result = _number % 1
|
||||
|
||||
result = Number(result.toFixed(_length))
|
||||
|
||||
return result * 10
|
||||
}
|
||||
|
||||
const handleSave = () => {
|
||||
closePopup(id)
|
||||
if (type === TYPE.FLOW_LINE) {
|
||||
// 동선이동
|
||||
if (FLOW_LINE_REF.DOWN_LEFT_RADIO_REF.current.checked) {
|
||||
// 높이 변경: 아래, 왼쪽 체크
|
||||
} else {
|
||||
// 높이 변경: 위, 오른쪽 체크
|
||||
}
|
||||
} else {
|
||||
// 형 올림내림
|
||||
if (UP_DOWN_REF.UP_RADIO_REF.current.checked) {
|
||||
// 자릿수를 올리다 체크
|
||||
const length = Number(UP_DOWN_REF.UP_INPUT_REF.current.value)
|
||||
} else {
|
||||
// 자릿수를 내리다 체크
|
||||
const length = Number(UP_DOWN_REF.DOWN_INPUT_REF.current.value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@ -43,7 +43,7 @@ export function useContextMenu() {
|
||||
const { addPopup } = usePopup()
|
||||
const [popupId, setPopupId] = useState(uuidv4())
|
||||
const [gridColor, setGridColor] = useRecoilState(gridColorState)
|
||||
const { deleteObject, moveObject, copyObject, editText, changeDimensionExtendLine } = useCommonUtils()
|
||||
const { deleteObject, moveObject, copyObject, editText, changeDimensionExtendLine, deleteOuterLineObject } = useCommonUtils()
|
||||
const [qContextMenu, setQContextMenu] = useRecoilState(contextMenuState)
|
||||
const [cell, setCell] = useState(null)
|
||||
const [column, setColumn] = useState(null)
|
||||
@ -116,6 +116,7 @@ export function useContextMenu() {
|
||||
{
|
||||
id: 'wallLineRemove',
|
||||
name: getMessage('contextmenu.wallline.remove'),
|
||||
fn: () => deleteOuterLineObject(),
|
||||
},
|
||||
{
|
||||
id: 'imageSizeEdit',
|
||||
|
||||
@ -1166,7 +1166,7 @@ export const splitPolygonWithLines = (polygon) => {
|
||||
}
|
||||
|
||||
const isSamePoint = (a, b) => {
|
||||
return a.x === b.x && a.y === b.y
|
||||
return Math.abs(Math.round(a.x) - Math.round(b.x)) <= 1 && Math.abs(Math.round(a.y) - Math.round(b.y)) <= 1
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user